Skip to content

Port server entry + orchestrator to v2 plugin contract #71

Description

@frap129

Question

Rework the server plugin entry (src/index.ts) and orchestrator (src/runtime/orchestrator.ts) to the v2 module contract: default export { id, setup(ctx) } instead of { id, server: async (input) => hooks }.

Key work:

  • v2 loads only the default export; the __testOnly named-export workaround is dead code — retire it, moving test seams to wherever the v2 contract offers (constructor injection, or a separate export consumed only by tests via direct import, e.g. a createRuntime() factory in a non-entry module).
  • Wire v2 hooks: ctx.tool.hook("execute.before"|"execute.after", ...) (payloads changed: before has mutable input, rejection via Tool.Error; after has { status, result?/error? } with mutable result), ctx.session.hook("context", ...) for transient injection, ctx.session.synthetic(...) for durable injection (replaces the chat.message hook path), and ctx.session.prompt(..., { resume: false }) for the awaited no-reply admission.
  • pluginInput.client → the v2 plugin context is itself the client (ctx.session, etc.); adapt src/runtime/client-adapter.ts.
  • Note: v2 synthetic messages do NOT run prompt hooks; check whether chat-capture.ts (which reads chat.message input for model/agent tracking) has a v2 source of truth (e.g. context hook event fields, or ctx.session.context).
  • Keep hooks' registration signature aligned with packages/plugin/src/promise/{tool,session}.ts from the sst/opencode beta branch.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

v2Part of the opencode v2 migration effortwayfinder:taskWork required to unblock a wayfinding decision

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions