opencode-swarm 7.188.2 → 7.188.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
  2. package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
  3. package/dist/cli/{auto-checkpoint-e4r8nfq5.js → auto-checkpoint-gp13e1h5.js} +8 -8
  4. package/dist/cli/{checkpoint-ejm8n9y5.js → checkpoint-61vy6pjg.js} +16 -16
  5. package/dist/cli/{coder-settlement-hped4xgs.js → coder-settlement-2s4rr23t.js} +12 -12
  6. package/dist/cli/{config-doctor-1qp1jmz4.js → config-doctor-0pjjr594.js} +15 -15
  7. package/dist/cli/{core-j5yff7rq.js → core-qdn60dm0.js} +3 -3
  8. package/dist/cli/{curation-policy-v64ctcbd.js → curation-policy-2rdbwc6a.js} +6 -6
  9. package/dist/cli/{curator-jf60p665.js → curator-8yqmmn5w.js} +42 -42
  10. package/dist/cli/{curator-drift-2sypkddx.js → curator-drift-n4t27md5.js} +8 -8
  11. package/dist/cli/curator-llm-factory-30n2fnef.js +82 -0
  12. package/dist/cli/{doctor-knowledge-receipt-phase-id-xyecjehq.js → doctor-knowledge-receipt-phase-id-vk9c6t3k.js} +8 -8
  13. package/dist/cli/{evidence-summary-service-k2g6hj96.js → evidence-summary-service-xpdx8se9.js} +19 -19
  14. package/dist/cli/{gate-evidence-vmzyfpsp.js → gate-evidence-px2mexyg.js} +7 -7
  15. package/dist/cli/guardrail-explain-38hmb1s9.js +83 -0
  16. package/dist/cli/{guardrail-log-2htm6kes.js → guardrail-log-y61ewh6d.js} +7 -7
  17. package/dist/cli/{guardrail-reset-dbwzk3p9.js → guardrail-reset-3arv6rfs.js} +42 -42
  18. package/dist/cli/{hive-promoter-c24qc0e1.js → hive-promoter-5naewxf9.js} +42 -42
  19. package/dist/cli/{index-bf1meb32.js → index-0yqa3awy.js} +2 -2
  20. package/dist/cli/{index-m1qy7f1e.js → index-103gsfn1.js} +1 -1
  21. package/dist/cli/{index-9wfjc4cn.js → index-195msz9x.js} +1 -1
  22. package/dist/cli/{index-r6e8syr3.js → index-1d51nz8d.js} +1 -1
  23. package/dist/cli/{index-edf2eztc.js → index-1e4s8cyt.js} +4 -4
  24. package/dist/cli/{index-rwabrcsg.js → index-2ajapc0r.js} +1 -1
  25. package/dist/cli/{index-dwm3czmf.js → index-3034m1wv.js} +4 -4
  26. package/dist/cli/{index-bejxkee0.js → index-4czf0es9.js} +1 -1
  27. package/dist/cli/{index-wb01w8ex.js → index-4vgvybav.js} +2 -2
  28. package/dist/cli/{index-0v2svrev.js → index-4zran0jk.js} +1 -1
  29. package/dist/cli/{index-0rzc71q8.js → index-53me7h10.js} +5 -5
  30. package/dist/cli/{index-md4xx63t.js → index-64nkt4ek.js} +1 -1
  31. package/dist/cli/{index-4e3qcwfb.js → index-6kckcdd7.js} +3 -3
  32. package/dist/cli/{index-1466xg5c.js → index-6kf62j82.js} +1 -1
  33. package/dist/cli/{index-1hqybe51.js → index-6qtgyzw2.js} +3 -3
  34. package/dist/cli/{index-jd3hvnqn.js → index-75bm071p.js} +2 -2
  35. package/dist/cli/{index-mb1reyw3.js → index-8tf5tewn.js} +2 -2
  36. package/dist/cli/{index-rn5hh7pp.js → index-8zs4v02d.js} +6 -6
  37. package/dist/cli/{index-51dww7y9.js → index-94b58ssa.js} +82 -82
  38. package/dist/cli/{index-rx9phqsj.js → index-a5z8eqs0.js} +44 -44
  39. package/dist/cli/{index-9b86vn97.js → index-bqqyxmpk.js} +7 -7
  40. package/dist/cli/{index-x2p51ka9.js → index-d3p96wkj.js} +6 -6
  41. package/dist/cli/{index-41v699sv.js → index-d74wbpqc.js} +7 -7
  42. package/dist/cli/{index-gd41qkx3.js → index-dka1ra21.js} +7 -7
  43. package/dist/cli/{index-b02cdy5w.js → index-fm0yan3t.js} +4 -4
  44. package/dist/cli/{index-b9pz70d0.js → index-ge4hk20b.js} +2 -2
  45. package/dist/cli/{index-9hsnarbv.js → index-gmmz119k.js} +1 -1
  46. package/dist/cli/{index-7sbyvk99.js → index-gyhj562n.js} +2 -2
  47. package/dist/cli/{index-4htcpbs4.js → index-h83221w1.js} +3 -3
  48. package/dist/cli/{index-wxf5feq2.js → index-j7pqzxyq.js} +2 -2
  49. package/dist/cli/{index-a8gvszr2.js → index-jc0jxg7y.js} +2 -2
  50. package/dist/cli/{index-zwgh0gty.js → index-jkz10gm7.js} +1 -1
  51. package/dist/cli/{index-kxj8bqtj.js → index-ntyc39rv.js} +2 -2
  52. package/dist/cli/{index-fq78x7th.js → index-p8kv9hh6.js} +11 -11
  53. package/dist/cli/{index-mf19yqss.js → index-qwrx78m5.js} +2 -2
  54. package/dist/cli/{index-yay1xxzk.js → index-rqheyf9e.js} +4 -4
  55. package/dist/cli/{index-pz26qx3x.js → index-sh7se0x5.js} +7 -7
  56. package/dist/cli/{index-tr901ma3.js → index-tr6kaa6q.js} +5 -5
  57. package/dist/cli/{index-cc1vzq4m.js → index-v09x4k5h.js} +1 -1
  58. package/dist/cli/{index-x73e0zkb.js → index-vx59q2ex.js} +1 -1
  59. package/dist/cli/{index-ea10gcja.js → index-wftdsx38.js} +5 -5
  60. package/dist/cli/{index-k1aek1xr.js → index-wsab75et.js} +3 -3
  61. package/dist/cli/{index-9hag235h.js → index-ww91zjzk.js} +1 -1
  62. package/dist/cli/{index-vhwbxtzt.js → index-xn48kjf4.js} +2 -2
  63. package/dist/cli/{index-zyc869ys.js → index-yacpp9jq.js} +3 -3
  64. package/dist/cli/{index-3dvzvhrp.js → index-yctaaj1k.js} +5 -5
  65. package/dist/cli/{index-m6k9fsae.js → index-ywpn0arj.js} +42 -42
  66. package/dist/cli/index.js +43 -43
  67. package/dist/cli/{knowledge-escalator-5sqgd4pg.js → knowledge-escalator-2c4svh7n.js} +14 -14
  68. package/dist/cli/{knowledge-events-05yp3j0n.js → knowledge-events-7zea5hzr.js} +12 -12
  69. package/dist/cli/{knowledge-link-9gx2djyd.js → knowledge-link-r9nx1eaj.js} +5 -5
  70. package/dist/cli/{knowledge-store-zx3qkamt.js → knowledge-store-rdya1anx.js} +6 -6
  71. package/dist/cli/{knowledge-validator-pc399we4.js → knowledge-validator-qnc4byyh.js} +8 -8
  72. package/dist/cli/{mcp-8ptynxsv.js → mcp-z21kvvnf.js} +1 -1
  73. package/dist/cli/{model-preflight-bhxpnrb6.js → model-preflight-jbg35f6e.js} +42 -42
  74. package/dist/cli/{pending-delegations-6wcwj6sp.js → pending-delegations-c1yjybf1.js} +12 -12
  75. package/dist/cli/{pr-subscriptions-22q1p6wg.js → pr-subscriptions-2mngc0jg.js} +12 -12
  76. package/dist/cli/{pr-workflow-gate-5v9yabv2.js → pr-workflow-gate-h4s5w5y0.js} +42 -42
  77. package/dist/cli/{runner-x8sbydkw.js → runner-3ynjanks.js} +6 -6
  78. package/dist/cli/{scan-cursor-dkd9jvvq.js → scan-cursor-385k9dkp.js} +7 -7
  79. package/dist/cli/{schema-nsnc7dm8.js → schema-cp8sqp1b.js} +1 -1
  80. package/dist/cli/{scope-persistence-hwafwz1n.js → scope-persistence-d587cb6v.js} +15 -15
  81. package/dist/cli/{server-k52tg8j6.js → server-t0wansfd.js} +51 -43
  82. package/dist/cli/{skill-generator-ak2vxhqe.js → skill-generator-f2j1jnqf.js} +16 -16
  83. package/dist/cli/{snapshot-coordination-init-nwh6z0a6.js → snapshot-coordination-init-9gvgq52n.js} +42 -42
  84. package/dist/cli/{speckit-checkoff-wydtzjmn.js → speckit-checkoff-zw0w6ekx.js} +4 -4
  85. package/dist/cli/{telemetry-d0j31j5d.js → telemetry-eq1cwq2x.js} +1 -1
  86. package/dist/cli/{workspace-snapshot-y60ay5eq.js → workspace-snapshot-w60bykdz.js} +3 -3
  87. package/dist/cli/{worktree-collision-ownership-5fbzrgnm.js → worktree-collision-ownership-0d8xf1d8.js} +13 -13
  88. package/dist/cli/{worktree-isolation-643nwna7.js → worktree-isolation-ds8n4a16.js} +42 -42
  89. package/dist/context-map/capsule-builder.d.ts +14 -1
  90. package/dist/context-map/persistence.d.ts +9 -0
  91. package/dist/context-map/post-agent-update.d.ts +90 -1
  92. package/dist/host/v2/agents-commands.d.ts +41 -0
  93. package/dist/host/v2/events.d.ts +39 -0
  94. package/dist/host/v2/guidance.d.ts +30 -0
  95. package/dist/host/v2/hooks.d.ts +31 -0
  96. package/dist/host/v2/setup.d.ts +61 -0
  97. package/dist/host/v2/tools.d.ts +41 -0
  98. package/dist/host/v2/types.d.ts +291 -0
  99. package/dist/index.d.ts +1 -0
  100. package/dist/index.js +14 -13
  101. package/dist/tools/syntax-check.d.ts +14 -0
  102. package/dist/types/context-capsule.d.ts +12 -0
  103. package/dist/types/context-map.d.ts +1 -1
  104. package/package.json +1 -1
  105. package/dist/cli/curator-llm-factory-we3t6fqd.js +0 -82
  106. package/dist/cli/guardrail-explain-cpr1hh21.js +0 -83
@@ -0,0 +1,30 @@
1
+ /**
2
+ * v2 guidance delivery — the session `context` hook (issue #3004 / #2910, R1
3
+ * in ADR-0003).
4
+ *
5
+ * Transport mapping (docs/host/v2-hook-inventory.md row 6/7):
6
+ *
7
+ * - The v1 MESSAGES transform chain runs first against a translated view of
8
+ * `event.messages`. On v1 its guidance injections ride USER-role carrier
9
+ * messages (`swarm-guidance:*` ids, fenced text) because the v1 host drops
10
+ * role:'system' entries (#2526). The v2 host renders `event.system`
11
+ * natively, so those carriers are RE-HOMED here into `event.system` as
12
+ * text parts and removed from the message list — each guidance unit has
13
+ * exactly one destination.
14
+ * - The v1 SYSTEM transform chain then runs with a translated input and its
15
+ * (unfenced) strings are appended as further `event.system` text parts —
16
+ * exactly what the v1 system surface receives.
17
+ *
18
+ * `event.agent` is an Agent.Info-shaped object on v2; it is normalized to a
19
+ * name before any v1 agent comparison (frozen C4 header requirement).
20
+ *
21
+ * Part-kind mapping (R10): text parts map 1:1; non-text content kinds
22
+ * (media, tool-call, tool-result, reasoning, step-start, compaction, effort)
23
+ * are preserved untouched on their message — the v1 chain's steps only read
24
+ * and write `type === 'text'` parts.
25
+ */
26
+ import type { V1HooksSubset, V2PluginContext, V2Registration, V2SessionContextEvent } from './types';
27
+ /** The v2 context hook body. */
28
+ export declare function onV2ContextEvent(event: V2SessionContextEvent, hooks: V1HooksSubset, directory: string): Promise<void>;
29
+ /** Register the context hook on the v2 session domain. */
30
+ export declare function registerV2ContextHook(ctx: V2PluginContext, hooks: V1HooksSubset, directory: string, registrations: V2Registration[]): Promise<void>;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * v2 lifecycle hook adapters — tool execute.before/after, session compaction,
3
+ * session prompt (issue #3004 / #2910).
4
+ *
5
+ * Each adapter wraps the SAME v1 handler functions with payload translation:
6
+ *
7
+ * - `tool.execute.before`: v2 `{tool, sessionID, agent, messageID, id,
8
+ * input}` → v1 `{tool, sessionID, callID, agent}` + mutable output
9
+ * `{args}`; the v1 chain's `output.args` mutation is applied back onto
10
+ * `event.input` in place.
11
+ * - `tool.execute.after`: v1 `{title, output, metadata}` mutable output is
12
+ * fed a best-effort translation of the v2 completed/error result.
13
+ * (v2 has no title surface; the translation targets the fields the v1
14
+ * toolAfter chain reads.)
15
+ * - `compaction`: translated session/model identity; the v1 customizer's
16
+ * directive output has no v1→v2 mapping yet — the turn-generation advance
17
+ * and the customizer still run (inventory row).
18
+ * - `prompt`: the v1 `chat.message` chain (model fallback preflight,
19
+ * delegation ledger, cache-cohort seeding) runs against a translated
20
+ * envelope. The #2989 chat-boundary model override writes
21
+ * `output.message.model`, which the v2 SessionPrompt has no field for —
22
+ * v1-only for now (inventory row).
23
+ *
24
+ * Denial semantics: a v1 hook throw propagates as the v2 hook error
25
+ * (fail-closed preserved; documented v2 delta in the inventory).
26
+ */
27
+ import type { V1HooksSubset, V2PluginContext, V2Registration } from './types';
28
+ /** Register the tool hooks (execute.before/after). */
29
+ export declare function registerV2ToolHooks(ctx: V2PluginContext, hooks: V1HooksSubset, directory: string, registrations: V2Registration[]): Promise<void>;
30
+ /** Register the compaction + prompt session hooks. */
31
+ export declare function registerV2SessionHooks(ctx: V2PluginContext, hooks: V1HooksSubset, directory: string, registrations: V2Registration[]): Promise<void>;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * OpenCode 2 (v2 plugin API) setup entrypoint — issue #3004 / #2910.
3
+ *
4
+ * The v2 host validates the plugin's default export against
5
+ * `{ id, setup | effect }` (sst/opencode v2 line, packages/core/src/plugin/
6
+ * module.ts). The v1 `server()` path stays byte-stable for OpenCode 1 hosts;
7
+ * this module is what `setup(ctx)` runs on OpenCode 2 hosts.
8
+ *
9
+ * Architecture (ADR-0003): the adapter reuses the SAME initialization core and
10
+ * the SAME v1 hook set — it only TRANSLATES registration surfaces:
11
+ *
12
+ * - tools: `hooks.tool` map → `ctx.tool.transform(editor.add)` (one source,
13
+ * `buildPluginToolObject`; no parallel name list — enforced by
14
+ * scripts/check-tool-registration.ts);
15
+ * - agents + commands: the v1 `config` hook is invoked against a synthetic
16
+ * `opencodeConfig` object, making the config hook itself the shared
17
+ * builder (auto-select promotions and the command table are reused
18
+ * verbatim — zero extraction from src/index.ts);
19
+ * - guidance: the v1 messages/system transform chains run against a
20
+ * translated session event; the #2526 USER-role guidance carriers the
21
+ * messages chain materializes are re-homed into `event.system` (v2 renders
22
+ * system natively — the user→system transport delta is recorded in
23
+ * docs/host/v2-hook-inventory.md);
24
+ * - lifecycle: tool execute.before/after, compaction, prompt hooks and the
25
+ * event subscription are wired with payload translation; `setup` returns
26
+ * a single Cleanup that disposes every Registration and runs the v1
27
+ * dispose teardown.
28
+ *
29
+ * Init boundedness (AGENTS.md invariant 1): every `await` in src/host/** is
30
+ * either on the same physical line as a `withTimeout(` call or inside a
31
+ * function named deferred-…/cleanup-… (the frozen C6 source-scan convention).
32
+ * The shared initialization wrapper (`deps.runInit`) is injected by
33
+ * src/index.ts so no module cycle is created and the FATAL-fail surface stays
34
+ * with the v1 wrapper.
35
+ */
36
+ import type { V1HooksSubset, V2PluginContext } from './types';
37
+ /** Dependencies injected from src/index.ts (avoids an index↔host cycle). */
38
+ export interface V2SetupDependencies {
39
+ /** The shared server-initialization wrapper (begin-interval → init core → schedule deferred → end-interval). */
40
+ runInit: (input: unknown) => Promise<V1HooksSubset>;
41
+ }
42
+ /** Normalize a v2 agent reference (Agent.Info object or bare string) to a name. */
43
+ export declare function normalizeV2AgentRef(agent: unknown): string | undefined;
44
+ /**
45
+ * Register the plugin on an OpenCode 2 host. Throws propagate to the v2 host
46
+ * (which skips the plugin) after a FATAL stderr line from the shared wrapper —
47
+ * the same posture the v1 server() path has (issue #675).
48
+ */
49
+ export declare function openCodeSwarmV2Setup(ctx: V2PluginContext, deps: V2SetupDependencies): Promise<() => Promise<void>>;
50
+ /**
51
+ * Seed the v1 session state a translated hook event implies. Shared by the
52
+ * guidance/prompt/tool-hook adapters so the v1 chain sees the same session
53
+ * identity the v1 host would have seeded via chat.message.
54
+ */
55
+ export declare function seedV1SessionState(sessionID: string | undefined, agentRef: unknown, directory: string): string | undefined;
56
+ /**
57
+ * Convert a v1 zod args shape into the JSON-schema-ish `input` value the v2
58
+ * tool editor accepts. Cached per tool at registration time (transforms must
59
+ * be synchronous and cheap).
60
+ */
61
+ export declare function v2ToolInputSchema(args: unknown): unknown;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * v2 tool registration — issue #3004 / #2910.
3
+ *
4
+ * Registers every tool from the SAME map the v1 host receives
5
+ * (`hooks.tool`, built by `buildPluginToolObject` from `TOOL_MANIFEST` — the
6
+ * single source; scripts/check-tool-registration.ts enforces that no parallel
7
+ * name list exists here).
8
+ *
9
+ * The execute adapter synthesizes the FULL v1 `ToolContext` (AGENTS.md
10
+ * invariant 4: `.swarm/` must resolve against the project root captured at
11
+ * setup, never `process.cwd()`): `directory`/`worktree` are injected, the v2
12
+ * `signal` becomes the v1 `abort`, `progress` bridges v1 `metadata({title?,
13
+ * metadata?})`, and `ask` bridges to the v2 permission domain when available
14
+ * and fails closed otherwise.
15
+ *
16
+ * Result mapping: v1 `string | {title?, output, metadata?, attachments?}` →
17
+ * v2 `{content, metadata}` (v2 has no title/attachment surface — inventory
18
+ * row in docs/host/v2-hook-inventory.md).
19
+ */
20
+ import type { V1HooksSubset, V2PluginContext, V2Registration, V2ToolContext } from './types';
21
+ interface V1ToolContextShape {
22
+ sessionID: string;
23
+ messageID: string;
24
+ agent: string;
25
+ directory: string;
26
+ worktree: string;
27
+ abort: AbortSignal;
28
+ metadata: (input: {
29
+ title?: string;
30
+ metadata?: Record<string, unknown>;
31
+ }) => void;
32
+ ask: (input: unknown) => Promise<void>;
33
+ }
34
+ /** Synthesize the v1 ToolContext the plugin's tools expect (R2 in ADR-0003). */
35
+ declare function synthesizeV1ToolContext(context: V2ToolContext, projectRoot: string, permissionBridge: ((input: unknown) => Promise<void>) | undefined): V1ToolContextShape;
36
+ /** Register all v1 tools on the v2 tool domain. */
37
+ export declare function registerV2Tools(ctx: V2PluginContext, hooks: V1HooksSubset, projectRoot: string, registrations: V2Registration[]): Promise<void>;
38
+ export declare const _internals: {
39
+ synthesizeV1ToolContext: typeof synthesizeV1ToolContext;
40
+ };
41
+ export {};
@@ -0,0 +1,291 @@
1
+ /**
2
+ * Vendored structural types for the OpenCode 2 plugin API.
3
+ *
4
+ * Provenance: distilled from `@opencode/plugin@2.0.20`
5
+ * `dist/promise/{plugin,registration,tool,session,command,agent,event,storage,app,options}.d.ts`
6
+ * and `@opencode/schema@2.0.20` `dist/{tool,agent,location}.d.ts`,
7
+ * `@opencode/ai` `dist/schema/messages.d.ts` (fetched 2026-09-30, issue #3004).
8
+ * Structural only — deliberately no runtime dependency on `@opencode/plugin`.
9
+ *
10
+ * Drift guard: DEFERRED to the #2910 follow-up PR (a check-host-contract v2 digest leg over this corpus, plus the dual-host CI lane); until it lands, type truth rests on this provenance pin and the live-host smoke. See docs/host/v2-hook-inventory.md for the full v1-to-v2 map.
11
+ *
12
+ * Only the surfaces this adapter consumes are typed. Unknown fields are
13
+ * intentionally left off; the adapter never relies on their absence.
14
+ * Upstream: @opencode/plugin@2.0.20 and @opencode/schema@2.0.20 (MIT, sst/opencode).
15
+ */
16
+ /** v2 `App` — host identity (dist/app.d.ts). */
17
+ export interface V2App {
18
+ readonly name: string;
19
+ readonly version: string;
20
+ readonly channel: string;
21
+ }
22
+ /** v2 `Location.Info` — project anchor (dist/location.d.ts). */
23
+ export interface V2Location {
24
+ readonly directory: string;
25
+ readonly workspaceID?: string;
26
+ readonly project?: {
27
+ readonly id?: string;
28
+ readonly directory?: string;
29
+ readonly canonical?: string;
30
+ };
31
+ }
32
+ /** v2 `PluginOptions` (dist/options.d.ts). */
33
+ export type V2PluginOptions = Readonly<Record<string, unknown>>;
34
+ /** v2 `Registration` (dist/promise/registration.d.ts). */
35
+ export interface V2Registration {
36
+ readonly dispose: () => Promise<void>;
37
+ }
38
+ /** v2 `Tool.Result` content parts (schema/tool.d.ts). */
39
+ export type V2ToolContent = {
40
+ readonly type: 'text';
41
+ readonly text: string;
42
+ } | {
43
+ readonly type: 'file';
44
+ readonly uri: string;
45
+ readonly mime: string;
46
+ readonly name?: string;
47
+ };
48
+ /** v2 `Tool.Result` (schema/tool.d.ts). */
49
+ export interface V2ToolResult {
50
+ readonly output?: unknown;
51
+ readonly content?: string | ReadonlyArray<V2ToolContent>;
52
+ readonly metadata?: Readonly<Record<string, unknown>>;
53
+ }
54
+ /** v2 tool `ToolContext` (dist/promise/tool.d.ts). */
55
+ export interface V2ToolContext {
56
+ readonly sessionID: string;
57
+ readonly agent: unknown;
58
+ readonly messageID: string;
59
+ readonly id: string;
60
+ readonly signal: AbortSignal;
61
+ readonly progress: (update: Readonly<Record<string, unknown>>) => Promise<void>;
62
+ }
63
+ /** v2 `Tool.Info` shape accepted by `ToolEditor.add` (dist/promise/tool.d.ts). */
64
+ export interface V2ToolInfo {
65
+ readonly name: string;
66
+ readonly description: string;
67
+ readonly input: unknown;
68
+ readonly execute: (input: unknown, context: V2ToolContext) => Promise<V2ToolResult>;
69
+ }
70
+ /** v2 `ToolEditor` (dist/promise/tool.d.ts). */
71
+ export interface V2ToolEditor {
72
+ add(tool: V2ToolInfo): void;
73
+ list(): Array<V2ToolInfo & {
74
+ readonly id: string;
75
+ }>;
76
+ get(id: string): (V2ToolInfo & {
77
+ readonly id: string;
78
+ }) | undefined;
79
+ update(id: string, update: (tool: unknown) => void): void;
80
+ remove(id: string): void;
81
+ namespace(namespace: {
82
+ readonly name: string;
83
+ readonly description: string;
84
+ }): void;
85
+ }
86
+ /** v2 `ToolDomain` (dist/promise/tool.d.ts) — hook payloads inline. */
87
+ export interface V2ToolDomain {
88
+ readonly transform: (callback: (editor: V2ToolEditor) => void) => Promise<V2Registration>;
89
+ readonly reload: () => Promise<void>;
90
+ readonly hook: (name: 'execute.before' | 'execute.after', callback: (input: V2ToolHookInput) => Promise<void> | void) => Promise<V2Registration>;
91
+ }
92
+ export interface V2ToolHookInput {
93
+ readonly tool: string;
94
+ readonly sessionID: string;
95
+ readonly agent: unknown;
96
+ readonly messageID: string;
97
+ readonly id: string;
98
+ input?: unknown;
99
+ readonly status?: 'completed' | 'error';
100
+ readonly result?: V2ToolResult;
101
+ readonly error?: {
102
+ message?: string;
103
+ [key: string]: unknown;
104
+ };
105
+ }
106
+ /** v2 text part on the system surface (`SystemPart`, @opencode/ai messages.d.ts). */
107
+ export interface V2SystemPart {
108
+ type: 'text';
109
+ text: string;
110
+ cache?: unknown;
111
+ metadata?: Record<string, unknown>;
112
+ }
113
+ /** v2 `Message` (abbreviated to the text-relevant surface). */
114
+ export interface V2Message {
115
+ id?: string;
116
+ role: 'system' | 'user' | 'assistant' | 'tool';
117
+ content: Array<{
118
+ type: string;
119
+ text?: string;
120
+ [key: string]: unknown;
121
+ }>;
122
+ [key: string]: unknown;
123
+ }
124
+ /** v2 `SessionContext` event (dist/promise/session.d.ts; DeepMutable in place). */
125
+ export interface V2SessionContextEvent {
126
+ readonly sessionID: string;
127
+ readonly agent: unknown;
128
+ readonly model?: {
129
+ id?: string;
130
+ providerID?: string;
131
+ [key: string]: unknown;
132
+ };
133
+ system: V2SystemPart[];
134
+ messages: V2Message[];
135
+ options: Record<string, unknown>;
136
+ tools: Record<string, {
137
+ description: string;
138
+ input: unknown;
139
+ }>;
140
+ }
141
+ /** v2 `SessionCompaction` event (extends SessionContext + settable result). */
142
+ export interface V2SessionCompactionEvent extends V2SessionContextEvent {
143
+ result?: {
144
+ summary: string;
145
+ [key: string]: unknown;
146
+ };
147
+ }
148
+ /** v2 `SessionPrompt` event (dist/promise/session.d.ts). */
149
+ export interface V2SessionPromptEvent {
150
+ readonly sessionID: string;
151
+ readonly messageID: string;
152
+ prompt: {
153
+ text: string;
154
+ files?: unknown[];
155
+ agents?: unknown[];
156
+ skills?: unknown[];
157
+ };
158
+ readonly delivery?: string;
159
+ }
160
+ /** v2 `SessionDomain` (only hook used by this adapter). */
161
+ export interface V2SessionDomain {
162
+ readonly hook: (name: 'context' | 'compaction' | 'prompt', callback: (event: never) => Promise<void> | void) => Promise<V2Registration>;
163
+ readonly prompt?: (sessionID: string, input: {
164
+ text: string;
165
+ } | {
166
+ command: string;
167
+ args?: string;
168
+ }) => Promise<unknown>;
169
+ }
170
+ /** v2 `CommandDefinition` / `CommandEditor` (dist/promise/command.d.ts). */
171
+ export interface V2CommandInvocation {
172
+ readonly sessionID: string;
173
+ readonly prompt: {
174
+ text: string;
175
+ [key: string]: unknown;
176
+ };
177
+ readonly delivery?: string;
178
+ }
179
+ export interface V2CommandDefinition {
180
+ readonly name: string;
181
+ readonly description?: string;
182
+ readonly execute: (input: V2CommandInvocation) => Promise<void>;
183
+ }
184
+ export interface V2CommandDomain {
185
+ readonly transform: (callback: (editor: {
186
+ add(definition: V2CommandDefinition): void;
187
+ }) => void) => Promise<V2Registration>;
188
+ readonly reload: () => Promise<void>;
189
+ }
190
+ /** v2 `Agent.Info` (schema/agent.d.ts; only fields this adapter writes). */
191
+ export interface V2AgentInfo {
192
+ id: string;
193
+ name: string;
194
+ mode: 'subagent' | 'primary' | 'all';
195
+ hidden: boolean;
196
+ request: {
197
+ settings: Record<string, unknown>;
198
+ headers: Record<string, string>;
199
+ body: Record<string, unknown>;
200
+ };
201
+ system?: string;
202
+ description?: string;
203
+ model?: {
204
+ id: string;
205
+ providerID: string;
206
+ variant?: string;
207
+ };
208
+ permissions?: Array<{
209
+ action: string;
210
+ resource: string;
211
+ effect: 'allow' | 'deny' | 'ask';
212
+ }>;
213
+ }
214
+ /** v2 `AgentEditor` (dist/promise/agent.d.ts). */
215
+ export interface V2AgentEditor {
216
+ list(): V2AgentInfo[];
217
+ get(id: string): V2AgentInfo | undefined;
218
+ default(id: string | undefined): void;
219
+ update(id: string, update: (agent: V2AgentInfo) => void): void;
220
+ remove(id: string): void;
221
+ }
222
+ /** v2 `AgentDomain`. */
223
+ export interface V2AgentDomain {
224
+ readonly transform: (callback: (editor: V2AgentEditor) => void) => Promise<V2Registration>;
225
+ readonly reload: () => Promise<void>;
226
+ }
227
+ /** v2 `EventDomain.subscribe` — async iterable of host events. */
228
+ export interface V2EventEnvelope {
229
+ readonly type?: string;
230
+ readonly [key: string]: unknown;
231
+ }
232
+ export interface V2EventDomain {
233
+ readonly subscribe?: (...args: unknown[]) => AsyncIterable<V2EventEnvelope> | Promise<AsyncIterable<V2EventEnvelope>>;
234
+ }
235
+ /** v2 `PermissionDomain` (only used for the v1 ask() bridge, best-effort). */
236
+ export interface V2PermissionDomain {
237
+ readonly reply?: (input: unknown) => Promise<unknown>;
238
+ readonly list?: () => Promise<unknown[]>;
239
+ readonly hook?: (name: 'evaluate', callback: (input: unknown) => Promise<void> | void) => Promise<V2Registration>;
240
+ }
241
+ /**
242
+ * v2 `Context` (dist/promise/plugin.d.ts) — only the domains this adapter
243
+ * touches; everything else stays reachable through the index signature so a
244
+ * superset host context is accepted.
245
+ */
246
+ export interface V2PluginContext {
247
+ readonly app: V2App;
248
+ readonly location: V2Location;
249
+ readonly options: V2PluginOptions;
250
+ readonly tool: V2ToolDomain;
251
+ readonly agent: V2AgentDomain;
252
+ readonly command: V2CommandDomain;
253
+ readonly session: V2SessionDomain;
254
+ readonly event: V2EventDomain;
255
+ readonly permission?: V2PermissionDomain;
256
+ readonly [key: string]: unknown;
257
+ }
258
+ /** v2 `Cleanup` — the return of `setup`. */
259
+ export type V2Cleanup = () => Promise<void> | void;
260
+ /** The v1-shaped hooks object the adapter consumes (structural subset). */
261
+ export interface V1HooksSubset {
262
+ name?: string;
263
+ tool?: Record<string, {
264
+ description?: string;
265
+ args?: unknown;
266
+ execute?: (args: unknown, ctx: unknown) => Promise<unknown>;
267
+ }>;
268
+ agent?: Record<string, unknown>;
269
+ config?: (opencodeConfig: Record<string, unknown>) => Promise<void>;
270
+ event?: (input: {
271
+ event: {
272
+ type?: string;
273
+ properties?: Record<string, unknown>;
274
+ };
275
+ }) => Promise<void>;
276
+ dispose?: () => Promise<void>;
277
+ 'command.execute.before'?: (input: unknown, output: unknown) => Promise<void>;
278
+ 'tool.execute.before'?: (input: unknown, output: unknown) => Promise<unknown> | Promise<void>;
279
+ 'tool.execute.after'?: (input: unknown, output: unknown) => Promise<unknown> | Promise<void>;
280
+ 'chat.message'?: (input: unknown, output: unknown) => Promise<unknown> | Promise<void>;
281
+ 'experimental.chat.messages.transform'?: (input: unknown, output: {
282
+ messages: unknown[];
283
+ }) => Promise<void>;
284
+ 'experimental.chat.system.transform'?: (input: {
285
+ sessionID?: string;
286
+ model?: unknown;
287
+ }, output: {
288
+ system: string[];
289
+ }) => Promise<void>;
290
+ 'experimental.session.compacting'?: (input: unknown, output: unknown) => Promise<void>;
291
+ }
package/dist/index.d.ts CHANGED
@@ -86,6 +86,7 @@ type PendingCostCorrection = {
86
86
  declare const _default: {
87
87
  id: "opencode-swarm";
88
88
  server: Plugin;
89
+ setup: (ctx: unknown) => Promise<() => Promise<void>>;
89
90
  };
90
91
  export default _default;
91
92
  export type { AgentDefinition } from './agents';