Skip to content

feat(plugin-api): expose minimal session/workflow orchestration - #386

Open
theshwal wants to merge 1 commit into
co-l:developfrom
theshwal:feat/plugin-orchestration-api
Open

theshwal wants to merge 1 commit into
co-l:developfrom
theshwal:feat/plugin-orchestration-api

Conversation

@theshwal

@theshwal theshwal commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Plugin API v2 extension. Plugins can now call a tiny host facade via
context.host (PluginHost) to:

  • create sessions (context.host.sessions.create)
  • stop sessions (context.host.sessions.stop)
  • launch workflows (context.host.workflows.launch)

Design rationale

The facade reuses the session manager and the task-seeded workflow
launcher already used by the MCP / WS paths so we don't introduce a
second implementation. The isRunning cycle stays entirely managed
by OpenFox; we never expose SessionManager, launchWorkflowRun, or
setRunning.

Plugins get exactly three generic operations already used by the
native MCP / WS surfaces. The API is generic and reusable by any
plugin, not specific to a single consumer.

Public surface

interface PluginSessions {
  create(input: {
    projectId: string
    title?: string
  }): Promise<{
    sessionId: string
    workdir?: string
  }>
  stop(sessionId: string): void
}

interface PluginWorkflows {
  launch(input: {
    sessionId: string
    workflowId: string
    params?: Record<string, string>
    content?: string
    subGroup?: string
  }): void
}

interface PluginHost {
  readonly sessions: PluginSessions
  readonly workflows: PluginWorkflows
}

interface PluginContext {
  // ...
  readonly host?: PluginHost
}

Implementation

  • src/plugin/index.ts: new interfaces + optional host? field on
    PluginContext (and on the tool context so RPC handlers see it too).
  • src/server/plugins/host.ts: new currentHost field + setHost method;
    createContext snapshots host via a lazy getter so plugins loaded
    before setHost still see the new value.
  • src/server/index.ts: setHost({sessions, workflows}) wired after the
    tasks launcher is initialised.

Tests

src/server/plugins/host.test.ts covers:

  • context.host is absent when setHost was never called
  • context.host is present when setHost was called before plugin load
  • setHost propagates to existing contexts (lazy getter)
  • setHost(undefined) removes the host from existing contexts

Verification

  • npm run typecheck (server + web): 0 errors
  • npm run lint: 0 errors (one targeted eslint-disable for the
    no-this-alias rule required by the lazy-getter pattern)
  • npm run test:unit: 434 files / 5843 tests passing, 29 skipped, 0 failed

AI-Enhanced Development

AI Models: MiniMax M3

What is NOT in this PR

  • SessionManager is not exposed
  • launchWorkflowRun is not exposed
  • setRunning is not exposed
  • no host/port/token plumbing is leaked to plugins
  • no second implementation of the business logic — the facade simply
    delegates to the existing primitives used by MCP / tasks

Plugin API v2 extension. Plugins can call a tiny host facade via
context.host (PluginHost) to:
- create sessions (context.host.sessions.create)
- stop sessions (context.host.sessions.stop)
- launch workflows (context.host.workflows.launch)

The facade reuses the session manager and the task-seeded workflow
launcher already used by the MCP / WS paths so we don't introduce a
second implementation. The isRunning cycle stays entirely managed by
OpenFox; we never expose SessionManager, launchWorkflowRun, or setRunning.

Implementation:
- src/plugin/index.ts: new PluginSessions, PluginWorkflows, PluginHost
  interfaces + optional host? field on PluginContext (and on the tool
  context for handlers/tools).
- src/server/plugins/host.ts: new currentHost field + setHost method;
  createContext now snapshots host via a lazy getter so plugins loaded
  before setHost still see the new value. RPC handler context enriched
  with the host too.
- src/server/index.ts: setHost({sessions, workflows}) wired after the
  tasks launcher is initialised.

Tests:
- src/server/plugins/host.test.ts: 4 new cases — context.host is absent
  when setHost was never called, present when called before plugin
  load, propagates to existing contexts (lazy getter), removed when
  setHost(undefined) is called.

Verified:
- npm run typecheck (server + web): 0 errors
- npm run lint: 0 errors (one targeted eslint-disable for the
  no-this-alias rule required by the lazy-getter pattern)
- npm run test:unit: 434 files / 5843 tests passing, 29 skipped, 0 failed
@github-actions github-actions Bot added the enhancement New feature or request label Sep 27, 2026
@theshwal theshwal closed this Sep 27, 2026
@theshwal theshwal reopened this Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant