@weaveio/weave-adapter-opencode 0.0.0-preview-20260708084849
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.
- package/README.md +83 -0
- package/dist/adapter.d.ts +218 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/command-templates.d.ts +38 -0
- package/dist/command-templates.d.ts.map +1 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26155 -0
- package/dist/model-resolution.d.ts +112 -0
- package/dist/model-resolution.d.ts.map +1 -0
- package/dist/opencode-client.d.ts +94 -0
- package/dist/opencode-client.d.ts.map +1 -0
- package/dist/plugin.d.ts +184 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +23973 -0
- package/dist/projection-helpers.d.ts +59 -0
- package/dist/projection-helpers.d.ts.map +1 -0
- package/dist/reconcile-agent.d.ts +131 -0
- package/dist/reconcile-agent.d.ts.map +1 -0
- package/dist/run-workflow.d.ts +127 -0
- package/dist/run-workflow.d.ts.map +1 -0
- package/dist/runtime-command-projection.d.ts +365 -0
- package/dist/runtime-command-projection.d.ts.map +1 -0
- package/dist/sdk-types.d.ts +56 -0
- package/dist/sdk-types.d.ts.map +1 -0
- package/dist/skill-discovery.d.ts +73 -0
- package/dist/skill-discovery.d.ts.map +1 -0
- package/dist/start-plan-execution.d.ts +164 -0
- package/dist/start-plan-execution.d.ts.map +1 -0
- package/dist/tool-policy-mapping.d.ts +77 -0
- package/dist/tool-policy-mapping.d.ts.map +1 -0
- package/dist/translate-agent.d.ts +48 -0
- package/dist/translate-agent.d.ts.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Command Projection — OpenCode adapter-owned command handlers and renderers.
|
|
3
|
+
*
|
|
4
|
+
* This module is the OpenCode adapter's projection layer for the six runtime
|
|
5
|
+
* command operations defined in the shared engine:
|
|
6
|
+
*
|
|
7
|
+
* | Command | Engine operation | OpenCode label |
|
|
8
|
+
* |----------------------|-----------------------|---------------------------|
|
|
9
|
+
* | Start plan | `startPlan` | `/weave:start` |
|
|
10
|
+
* | Run named workflow | `runNamedWorkflow` | `/weave:run` |
|
|
11
|
+
* | Inspect status | `inspectStatus` | `/weave:status` |
|
|
12
|
+
* | Abort execution | `abortExecution` | `/weave:abort` |
|
|
13
|
+
* | Advance step | `advanceStep` | `/weave:advance` |
|
|
14
|
+
* | Runtime health | `runtimeHealth` | `/weave:health` |
|
|
15
|
+
*
|
|
16
|
+
* ## Boundary rules
|
|
17
|
+
*
|
|
18
|
+
* - Argument parsing, command labels, and OpenCode-specific messages are
|
|
19
|
+
* adapter-owned and live here.
|
|
20
|
+
* - Lifecycle state-transition logic is **never duplicated** — all delegated
|
|
21
|
+
* to the matching engine operation.
|
|
22
|
+
* - Native slash/TUI affordances that are not yet implemented in this slice
|
|
23
|
+
* are documented as degraded equivalents (see `DEGRADED_AFFORDANCES`).
|
|
24
|
+
* - `/start-work` is out of scope for this module.
|
|
25
|
+
*
|
|
26
|
+
* ## Rendered result shapes
|
|
27
|
+
*
|
|
28
|
+
* Each handler returns a `ProjectionResult<T>` — a discriminated union of
|
|
29
|
+
* `success`, `failure`, and `degraded` outcomes. Adapters format these for
|
|
30
|
+
* slash commands, plugin tools, UI actions, or scripts without duplicating
|
|
31
|
+
* lifecycle logic.
|
|
32
|
+
*
|
|
33
|
+
* @see packages/engine/src/runtime-command-operations/types.ts — engine types
|
|
34
|
+
* @see packages/adapters/opencode/src/start-plan-execution.ts — /weave:start delivery path
|
|
35
|
+
* @see packages/adapters/opencode/src/run-workflow.ts — named-workflow execution
|
|
36
|
+
* @see docs/adapter-boundary.md
|
|
37
|
+
* @see docs/specs/30-spec-minimal-runtime-command-lifecycle/30-spec-minimal-runtime-command-lifecycle.md
|
|
38
|
+
*/
|
|
39
|
+
import type { AdapterHealthReport, AdvanceStepInput, CommandOperationError, ExecutionAbortedData, ExecutionStartedData, ExecutionStatusData, PlanStateProvider, RuntimeHealthData, RuntimeStore, StepAdvancedData } from "@weaveio/weave-engine";
|
|
40
|
+
import type { OpenCodeAdapter } from "./adapter.js";
|
|
41
|
+
/**
|
|
42
|
+
* OpenCode slash-command labels for each projected runtime command.
|
|
43
|
+
*
|
|
44
|
+
* These are adapter-owned identifiers. Core packages must never reference them.
|
|
45
|
+
* `/start-work` is out of scope for this module — see `start-plan-execution.ts`.
|
|
46
|
+
*/
|
|
47
|
+
export declare const WEAVE_COMMAND_LABELS: {
|
|
48
|
+
readonly startPlan: "/weave:start";
|
|
49
|
+
readonly runWorkflow: "/weave:run";
|
|
50
|
+
readonly status: "/weave:status";
|
|
51
|
+
readonly abort: "/weave:abort";
|
|
52
|
+
readonly advance: "/weave:advance";
|
|
53
|
+
readonly health: "/weave:health";
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Native slash/TUI affordances that are not yet implemented in this slice.
|
|
57
|
+
*
|
|
58
|
+
* These are documented as degraded equivalents. Adapters that register
|
|
59
|
+
* OpenCode slash commands should surface these notes to users when the
|
|
60
|
+
* native affordance is unavailable.
|
|
61
|
+
*/
|
|
62
|
+
export declare const DEGRADED_AFFORDANCES: readonly {
|
|
63
|
+
readonly command: string;
|
|
64
|
+
readonly reason: string;
|
|
65
|
+
readonly equivalent: string;
|
|
66
|
+
}[];
|
|
67
|
+
/**
|
|
68
|
+
* A successful projection result carrying renderer-ready data.
|
|
69
|
+
*/
|
|
70
|
+
export interface ProjectionSuccess<T> {
|
|
71
|
+
readonly outcome: "success";
|
|
72
|
+
readonly command: string;
|
|
73
|
+
readonly data: T;
|
|
74
|
+
/** Human-readable summary for OpenCode slash-command output. */
|
|
75
|
+
readonly message: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A failed projection result carrying a typed engine error.
|
|
79
|
+
*/
|
|
80
|
+
export interface ProjectionFailure {
|
|
81
|
+
readonly outcome: "failure";
|
|
82
|
+
readonly command: string;
|
|
83
|
+
readonly error: CommandOperationError;
|
|
84
|
+
/** Human-readable error message for OpenCode slash-command output. */
|
|
85
|
+
readonly message: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A degraded projection result — the operation partially succeeded or ran
|
|
89
|
+
* with reduced capability.
|
|
90
|
+
*/
|
|
91
|
+
export interface ProjectionDegraded<T> {
|
|
92
|
+
readonly outcome: "degraded";
|
|
93
|
+
readonly command: string;
|
|
94
|
+
readonly data?: T;
|
|
95
|
+
/** Human-readable degradation reason for OpenCode slash-command output. */
|
|
96
|
+
readonly message: string;
|
|
97
|
+
/** Actionable hint for the user. */
|
|
98
|
+
readonly hint?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Discriminated union of all projection result variants.
|
|
102
|
+
*/
|
|
103
|
+
export type ProjectionResult<T> = ProjectionSuccess<T> | ProjectionFailure | ProjectionDegraded<T>;
|
|
104
|
+
/**
|
|
105
|
+
* Input for the projected start-plan command.
|
|
106
|
+
*
|
|
107
|
+
* Adapter-owned: argument parsing, default values, and OpenCode-specific
|
|
108
|
+
* fields are resolved here before delegating to the engine's `startPlan`.
|
|
109
|
+
*/
|
|
110
|
+
export interface StartPlanProjectionInput {
|
|
111
|
+
/** Name of the plan file to start. */
|
|
112
|
+
readonly planName: string;
|
|
113
|
+
/** Name of the workflow to use for plan execution. */
|
|
114
|
+
readonly workflowName: string;
|
|
115
|
+
/** Human-readable goal for this execution instance. */
|
|
116
|
+
readonly goal: string;
|
|
117
|
+
/** URL-safe slug for this execution instance. */
|
|
118
|
+
readonly slug: string;
|
|
119
|
+
/** Owner identifier for the execution lease. */
|
|
120
|
+
readonly ownerId: string;
|
|
121
|
+
/** Runtime store for persisting the workflow instance and lease. */
|
|
122
|
+
readonly store: RuntimeStore;
|
|
123
|
+
/** Provider for plan file existence checks. */
|
|
124
|
+
readonly planStateProvider: PlanStateProvider;
|
|
125
|
+
/** Workflow registry — maps workflow names to workflow configs. */
|
|
126
|
+
readonly workflows: Record<string, unknown>;
|
|
127
|
+
/** OpenCode adapter instance — `spawnSubagent` is called for each DispatchAgentEffect. */
|
|
128
|
+
readonly adapter: OpenCodeAdapter;
|
|
129
|
+
/** Optional ISO-8601 timestamp override (for testing). */
|
|
130
|
+
readonly now?: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Input for the projected run-named-workflow command.
|
|
134
|
+
*
|
|
135
|
+
* Adapter-owned: argument parsing, default values, and OpenCode-specific
|
|
136
|
+
* fields are resolved here before delegating to the engine's `runNamedWorkflow`.
|
|
137
|
+
*/
|
|
138
|
+
export interface RunWorkflowProjectionInput {
|
|
139
|
+
/** Name of the workflow to run. */
|
|
140
|
+
readonly workflowName: string;
|
|
141
|
+
/** Human-readable goal for this execution instance. */
|
|
142
|
+
readonly goal: string;
|
|
143
|
+
/** URL-safe slug for this execution instance. */
|
|
144
|
+
readonly slug: string;
|
|
145
|
+
/** Owner identifier for the execution lease. */
|
|
146
|
+
readonly ownerId: string;
|
|
147
|
+
/** Runtime store for persisting the workflow instance and lease. */
|
|
148
|
+
readonly store: RuntimeStore;
|
|
149
|
+
/** Workflow registry — maps workflow names to workflow configs. */
|
|
150
|
+
readonly workflows: Record<string, unknown>;
|
|
151
|
+
/** OpenCode adapter instance — `spawnSubagent` is called for each DispatchAgentEffect. */
|
|
152
|
+
readonly adapter: OpenCodeAdapter;
|
|
153
|
+
/** Optional plan state provider for plan_created/plan_complete steps. */
|
|
154
|
+
readonly planStateProvider?: PlanStateProvider;
|
|
155
|
+
/** Optional ISO-8601 timestamp override (for testing). */
|
|
156
|
+
readonly now?: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Input for the projected inspect-status command.
|
|
160
|
+
*/
|
|
161
|
+
export interface InspectStatusProjectionInput {
|
|
162
|
+
/** Workflow instance to inspect. */
|
|
163
|
+
readonly workflowInstanceId: string;
|
|
164
|
+
/** Runtime store for reading the workflow instance. */
|
|
165
|
+
readonly store: RuntimeStore;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Input for the projected abort-execution command.
|
|
169
|
+
*/
|
|
170
|
+
export interface AbortExecutionProjectionInput {
|
|
171
|
+
/** Workflow instance to abort. */
|
|
172
|
+
readonly workflowInstanceId: string;
|
|
173
|
+
/** Active lease ID for the execution. */
|
|
174
|
+
readonly leaseId: string;
|
|
175
|
+
/** Abort signal: `"cancel"` terminates; `"pause"` suspends. */
|
|
176
|
+
readonly signal: "cancel" | "pause";
|
|
177
|
+
/** Runtime store for reading/writing the workflow instance. */
|
|
178
|
+
readonly store: RuntimeStore;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Input for the projected advance-step command.
|
|
182
|
+
*/
|
|
183
|
+
export interface AdvanceStepProjectionInput {
|
|
184
|
+
/** Workflow instance containing the blocked step. */
|
|
185
|
+
readonly workflowInstanceId: string;
|
|
186
|
+
/** Active lease ID for the execution. */
|
|
187
|
+
readonly leaseId: string;
|
|
188
|
+
/** Name of the step to advance. */
|
|
189
|
+
readonly stepName: string;
|
|
190
|
+
/** Completion signal describing how the step finished. */
|
|
191
|
+
readonly completionSignal: AdvanceStepInput["completionSignal"];
|
|
192
|
+
/** Runtime store for reading/writing the workflow instance. */
|
|
193
|
+
readonly store: RuntimeStore;
|
|
194
|
+
/** Optional plan state provider for plan_created/plan_complete steps. */
|
|
195
|
+
readonly planStateProvider?: PlanStateProvider;
|
|
196
|
+
/** Optional workflow execution context for step completion routing. */
|
|
197
|
+
readonly context?: AdvanceStepInput["context"];
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Input for the projected runtime-health command.
|
|
201
|
+
*
|
|
202
|
+
* Adapters build the `AdapterHealthReport` before calling this handler.
|
|
203
|
+
* The engine never performs harness-specific probes.
|
|
204
|
+
*/
|
|
205
|
+
export interface RuntimeHealthProjectionInput {
|
|
206
|
+
/** Adapter-supplied health report from the capability contract. */
|
|
207
|
+
readonly healthReport: AdapterHealthReport;
|
|
208
|
+
/** Explicit list of operations the adapter considers degraded. */
|
|
209
|
+
readonly degradedOperations?: readonly string[];
|
|
210
|
+
/** Explicit list of operations the adapter considers unsupported. */
|
|
211
|
+
readonly unsupportedOperations?: readonly string[];
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* OpenCode adapter-owned projection of the six runtime command operations.
|
|
215
|
+
*
|
|
216
|
+
* Each method:
|
|
217
|
+
* 1. Parses/validates adapter-owned arguments.
|
|
218
|
+
* 2. Delegates to the matching shared engine operation.
|
|
219
|
+
* 3. Renders a typed `ProjectionResult<T>` — success, failure, or degraded.
|
|
220
|
+
*
|
|
221
|
+
* No lifecycle state-transition logic is duplicated here. All lifecycle
|
|
222
|
+
* semantics are owned by the engine operations.
|
|
223
|
+
*
|
|
224
|
+
* ## Usage
|
|
225
|
+
*
|
|
226
|
+
* ```ts
|
|
227
|
+
* const projection = new RuntimeCommandProjection();
|
|
228
|
+
*
|
|
229
|
+
* const result = await projection.handleStartPlan({
|
|
230
|
+
* planName: "feature-auth",
|
|
231
|
+
* workflowName: "tapestry-execution",
|
|
232
|
+
* goal: "Implement authentication",
|
|
233
|
+
* slug: "implement-authentication",
|
|
234
|
+
* ownerId: "weave:start",
|
|
235
|
+
* store,
|
|
236
|
+
* planStateProvider: adapter.planStateProvider,
|
|
237
|
+
* workflows: config.workflows,
|
|
238
|
+
* adapter,
|
|
239
|
+
* });
|
|
240
|
+
*
|
|
241
|
+
* result.match(
|
|
242
|
+
* (r) => { if (r.outcome === "success") console.log(r.message); },
|
|
243
|
+
* () => {}, // never — ProjectionResult is always ok
|
|
244
|
+
* );
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
export declare class RuntimeCommandProjection {
|
|
248
|
+
/**
|
|
249
|
+
* Handle the `/weave:start` command — start execution of a named plan.
|
|
250
|
+
*
|
|
251
|
+
* Delegates to the engine's `startPlan` operation. Supplies the adapter-owned
|
|
252
|
+
* `projectEffect` callback that calls `adapter.spawnSubagent` for each
|
|
253
|
+
* `DispatchAgentEffect`. Returns a typed `ProjectionResult<ExecutionStartedData>`.
|
|
254
|
+
*
|
|
255
|
+
* No lifecycle state-transition logic is duplicated here.
|
|
256
|
+
*
|
|
257
|
+
* @param input - Start-plan projection parameters.
|
|
258
|
+
* @returns `ProjectionResult<ExecutionStartedData>` — always resolves (never rejects).
|
|
259
|
+
*/
|
|
260
|
+
handleStartPlan(input: StartPlanProjectionInput): Promise<ProjectionResult<ExecutionStartedData>>;
|
|
261
|
+
/**
|
|
262
|
+
* Handle the `/weave:run` command — explicitly run a named workflow.
|
|
263
|
+
*
|
|
264
|
+
* Delegates to the engine's `runNamedWorkflow` operation. Supplies the
|
|
265
|
+
* adapter-owned `projectEffect` callback. Returns a typed
|
|
266
|
+
* `ProjectionResult<ExecutionStartedData>`.
|
|
267
|
+
*
|
|
268
|
+
* Named workflow execution is explicitly separate from ordinary plan
|
|
269
|
+
* execution. `/start-work` is out of scope for this handler.
|
|
270
|
+
*
|
|
271
|
+
* No lifecycle state-transition logic is duplicated here.
|
|
272
|
+
*
|
|
273
|
+
* @param input - Run-workflow projection parameters.
|
|
274
|
+
* @returns `ProjectionResult<ExecutionStartedData>` — always resolves.
|
|
275
|
+
*/
|
|
276
|
+
handleRunWorkflow(input: RunWorkflowProjectionInput): Promise<ProjectionResult<ExecutionStartedData>>;
|
|
277
|
+
/**
|
|
278
|
+
* Handle the `/weave:status` command — read-only inspection of execution state.
|
|
279
|
+
*
|
|
280
|
+
* Delegates to the engine's `inspectStatus` operation. This is a read-only
|
|
281
|
+
* operation — it never creates instances, acquires leases, or emits effects.
|
|
282
|
+
*
|
|
283
|
+
* No lifecycle state-transition logic is duplicated here.
|
|
284
|
+
*
|
|
285
|
+
* @param input - Inspect-status projection parameters.
|
|
286
|
+
* @returns `ProjectionResult<ExecutionStatusData>` — always resolves.
|
|
287
|
+
*/
|
|
288
|
+
handleInspectStatus(input: InspectStatusProjectionInput): Promise<ProjectionResult<ExecutionStatusData>>;
|
|
289
|
+
/**
|
|
290
|
+
* Handle the `/weave:abort` command — cancel or pause an active execution.
|
|
291
|
+
*
|
|
292
|
+
* Delegates to the engine's `abortExecution` operation. Returns a typed
|
|
293
|
+
* `ProjectionResult<ExecutionAbortedData>`.
|
|
294
|
+
*
|
|
295
|
+
* **Degraded affordance**: the native TUI abort button is not yet wired to
|
|
296
|
+
* this handler. Users can invoke it via plugin tool or script.
|
|
297
|
+
*
|
|
298
|
+
* No lifecycle state-transition logic is duplicated here.
|
|
299
|
+
*
|
|
300
|
+
* @param input - Abort-execution projection parameters.
|
|
301
|
+
* @returns `ProjectionResult<ExecutionAbortedData>` — always resolves.
|
|
302
|
+
*/
|
|
303
|
+
handleAbortExecution(input: AbortExecutionProjectionInput): Promise<ProjectionResult<ExecutionAbortedData>>;
|
|
304
|
+
/**
|
|
305
|
+
* Handle the `/weave:advance` command — advance or complete a blocked step.
|
|
306
|
+
*
|
|
307
|
+
* Delegates to the engine's `advanceStep` operation. Returns a typed
|
|
308
|
+
* `ProjectionResult<StepAdvancedData>`.
|
|
309
|
+
*
|
|
310
|
+
* **Degraded affordance**: the native TUI step-advance UI is not yet wired
|
|
311
|
+
* to this handler. Users can invoke it via plugin tool or script.
|
|
312
|
+
*
|
|
313
|
+
* No lifecycle state-transition logic is duplicated here.
|
|
314
|
+
*
|
|
315
|
+
* @param input - Advance-step projection parameters.
|
|
316
|
+
* @returns `ProjectionResult<StepAdvancedData>` — always resolves.
|
|
317
|
+
*/
|
|
318
|
+
handleAdvanceStep(input: AdvanceStepProjectionInput): Promise<ProjectionResult<StepAdvancedData>>;
|
|
319
|
+
/**
|
|
320
|
+
* Handle the `/weave:health` command — report adapter/runtime readiness.
|
|
321
|
+
*
|
|
322
|
+
* Delegates to the engine's `runtimeHealth` operation. This is a pure
|
|
323
|
+
* operation — it performs no harness I/O. Adapters build the
|
|
324
|
+
* `AdapterHealthReport` before calling this handler.
|
|
325
|
+
*
|
|
326
|
+
* Returns a typed `ProjectionResult<RuntimeHealthData>`. The result is
|
|
327
|
+
* always `success` (the engine's `runtimeHealth` never fails), but the
|
|
328
|
+
* data may indicate degraded or unsupported operations.
|
|
329
|
+
*
|
|
330
|
+
* No lifecycle state-transition logic is duplicated here.
|
|
331
|
+
*
|
|
332
|
+
* @param input - Runtime-health projection parameters.
|
|
333
|
+
* @returns `ProjectionResult<RuntimeHealthData>` — always resolves as success.
|
|
334
|
+
*/
|
|
335
|
+
handleRuntimeHealth(input: RuntimeHealthProjectionInput): Promise<ProjectionResult<RuntimeHealthData>>;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Build a minimal `AdapterHealthReport` for the OpenCode adapter.
|
|
339
|
+
*
|
|
340
|
+
* This is a convenience helper for tests and plugin entry points that need
|
|
341
|
+
* to construct a health report without duplicating the capability contract
|
|
342
|
+
* boilerplate. Production callers should build a full capability contract
|
|
343
|
+
* using `buildAdapterHealthReport` from `@weaveio/weave-engine`.
|
|
344
|
+
*
|
|
345
|
+
* The report declares `command-entrypoints` as `emulated` (OpenCode exposes
|
|
346
|
+
* slash commands as the explicit delivery path) and all other required
|
|
347
|
+
* capabilities as `native` or `emulated` based on the adapter's known
|
|
348
|
+
* implementation state.
|
|
349
|
+
*
|
|
350
|
+
* @param overrides - Optional capability overrides for testing.
|
|
351
|
+
* @returns A normalized `AdapterHealthReport`.
|
|
352
|
+
*/
|
|
353
|
+
export declare function buildOpenCodeHealthReport(overrides?: {
|
|
354
|
+
readonly commandEntrypointsReadiness?: "native" | "emulated" | "degraded" | "unsupported";
|
|
355
|
+
readonly degradedOperations?: readonly string[];
|
|
356
|
+
readonly unsupportedOperations?: readonly string[];
|
|
357
|
+
}): AdapterHealthReport;
|
|
358
|
+
/**
|
|
359
|
+
* Create a default `InMemoryRuntimeStore` for use in projection handlers.
|
|
360
|
+
*
|
|
361
|
+
* Convenience re-export for callers that need a store without importing
|
|
362
|
+
* directly from `@weaveio/weave-engine`.
|
|
363
|
+
*/
|
|
364
|
+
export { createInMemoryRuntimeStore as createDefaultStore } from "@weaveio/weave-engine";
|
|
365
|
+
//# sourceMappingURL=runtime-command-projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-command-projection.d.ts","sourceRoot":"","sources":["../src/runtime-command-projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAEV,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAY/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AASpD;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;;;CAOU,CAAC;AAM5C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,EAWS,CAAC;AAMX;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB,gEAAgE;IAChE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;IACtC,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CA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;;OAeG;IACG,mBAAmB,CACvB,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;CAgDhD;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,CAAC,EAAE;IACpD,QAAQ,CAAC,2BAA2B,CAAC,EACjC,QAAQ,GACR,UAAU,GACV,UAAU,GACV,aAAa,CAAC;IAClB,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChD,QAAQ,CAAC,qBAAqB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACpD,GAAG,mBAAmB,CAqFtB;AAMD;;;;;GAKG;AACH,OAAO,EAAE,0BAA0B,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable re-exports of `@opencode-ai/sdk` types used by the OpenCode adapter.
|
|
3
|
+
*
|
|
4
|
+
* This is the ONLY file in the adapter allowed to import directly from
|
|
5
|
+
* `@opencode-ai/sdk`. All other adapter modules must import from `./sdk-types`
|
|
6
|
+
* to insulate the rest of the adapter from SDK version churn.
|
|
7
|
+
*
|
|
8
|
+
* Only types that the adapter actively uses are re-exported here. Unused SDK
|
|
9
|
+
* types are intentionally omitted to keep the surface minimal.
|
|
10
|
+
*/
|
|
11
|
+
export type {
|
|
12
|
+
/**
|
|
13
|
+
* OpenCode agent descriptor as returned by the API — used when reading the
|
|
14
|
+
* current agent list from a running OpenCode instance.
|
|
15
|
+
*/
|
|
16
|
+
Agent as OpenCodeAgent,
|
|
17
|
+
/**
|
|
18
|
+
* OpenCode agent configuration shape — used when materialising a Weave
|
|
19
|
+
* `AgentDescriptor` into an OpenCode agent entry.
|
|
20
|
+
*/
|
|
21
|
+
AgentConfig as OpenCodeAgentConfig,
|
|
22
|
+
/**
|
|
23
|
+
* Top-level OpenCode config — used when reading or patching the running
|
|
24
|
+
* OpenCode configuration via the SDK client.
|
|
25
|
+
*/
|
|
26
|
+
Config as OpenCodeConfig,
|
|
27
|
+
/**
|
|
28
|
+
* OpenCode model descriptor — used for available-model lookup and
|
|
29
|
+
* model-intent resolution.
|
|
30
|
+
*/
|
|
31
|
+
Model as OpenCodeModel,
|
|
32
|
+
/**
|
|
33
|
+
* The generated SDK client class — used to communicate with a running
|
|
34
|
+
* OpenCode server instance.
|
|
35
|
+
*/
|
|
36
|
+
OpencodeClient,
|
|
37
|
+
/**
|
|
38
|
+
* Client configuration options — used when constructing an `OpencodeClient`.
|
|
39
|
+
*/
|
|
40
|
+
OpencodeClientConfig,
|
|
41
|
+
/**
|
|
42
|
+
* OpenCode provider descriptor — used when enumerating available providers
|
|
43
|
+
* and their models.
|
|
44
|
+
*/
|
|
45
|
+
Provider as OpenCodeProvider,
|
|
46
|
+
/**
|
|
47
|
+
* OpenCode session descriptor — used when querying active sessions.
|
|
48
|
+
*/
|
|
49
|
+
Session as OpenCodeSession, } from "@opencode-ai/sdk";
|
|
50
|
+
export {
|
|
51
|
+
/**
|
|
52
|
+
* Factory function that creates a pre-configured `OpencodeClient` pointed at
|
|
53
|
+
* the running OpenCode server. Accepts an optional `directory` override.
|
|
54
|
+
*/
|
|
55
|
+
createOpencodeClient, } from "@opencode-ai/sdk";
|
|
56
|
+
//# sourceMappingURL=sdk-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-types.d.ts","sourceRoot":"","sources":["../src/sdk-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,YAAY;AACV;;;GAGG;AACH,KAAK,IAAI,aAAa;AACtB;;;GAGG;AACH,WAAW,IAAI,mBAAmB;AAClC;;;GAGG;AACH,MAAM,IAAI,cAAc;AACxB;;;GAGG;AACH,KAAK,IAAI,aAAa;AACtB;;;GAGG;AACH,cAAc;AACd;;GAEG;AACH,oBAAoB;AACpB;;;GAGG;AACH,QAAQ,IAAI,gBAAgB;AAC5B;;GAEG;AACH,OAAO,IAAI,eAAe,GAC3B,MAAM,kBAAkB,CAAC;AAE1B,OAAO;AACL;;;GAGG;AACH,oBAAoB,GACrB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter-local skill validation for the OpenCode adapter.
|
|
3
|
+
*
|
|
4
|
+
* This module provides helpers for working with harness-provided skill data.
|
|
5
|
+
* It does NOT perform filesystem scanning — skill discovery is owned by the
|
|
6
|
+
* OpenCode harness (SDK/runtime), which tells the adapter which skills are
|
|
7
|
+
* available. The adapter's role is to:
|
|
8
|
+
*
|
|
9
|
+
* 1. Accept the harness-provided `SkillInfo[]` list (injected at construction
|
|
10
|
+
* time or supplied by the SDK at runtime).
|
|
11
|
+
* 2. Validate declared skill names against that list.
|
|
12
|
+
* 3. Surface missing declared skills as hard errors so the engine's
|
|
13
|
+
* `resolveSkillsForAgent()` can emit `MissingSkill` errors.
|
|
14
|
+
*
|
|
15
|
+
* ## Adapter / Harness Boundary
|
|
16
|
+
*
|
|
17
|
+
* - **Harness-owned**: which skills exist, where their files live, how they
|
|
18
|
+
* are loaded and mounted into an agent's context. The OpenCode SDK/runtime
|
|
19
|
+
* provides this information.
|
|
20
|
+
* - **Adapter-owned**: receiving the harness-provided list, forwarding it to
|
|
21
|
+
* the engine, and validating declared skill names against it.
|
|
22
|
+
* - **Engine-owned**: matching declared skill names against `SkillInfo.name`
|
|
23
|
+
* values and emitting `MissingSkill` errors for unresolved names.
|
|
24
|
+
*
|
|
25
|
+
* ## Hard-error semantics
|
|
26
|
+
*
|
|
27
|
+
* Missing declared skills are hard errors (not silent skips). When an agent's
|
|
28
|
+
* `skills [...]` declaration references a skill that is not in the
|
|
29
|
+
* harness-provided list, `validateDeclaredSkills()` returns
|
|
30
|
+
* `err(MissingSkillsError)` with the missing names. Callers must not suppress
|
|
31
|
+
* those errors.
|
|
32
|
+
*
|
|
33
|
+
* Boundary rule: this module must not import from `@opencode-ai/sdk` directly.
|
|
34
|
+
* All SDK type imports flow through `./sdk-types`.
|
|
35
|
+
*/
|
|
36
|
+
import type { SkillInfo } from "@weaveio/weave-engine";
|
|
37
|
+
import { type Result } from "neverthrow";
|
|
38
|
+
/**
|
|
39
|
+
* Discriminated error returned by `validateDeclaredSkills()` when one or more
|
|
40
|
+
* declared skill names are absent from the harness-provided available list.
|
|
41
|
+
*/
|
|
42
|
+
export interface MissingSkillsError {
|
|
43
|
+
readonly type: "MissingSkillsError";
|
|
44
|
+
/** Names of the skills that were declared but not found in the available list. */
|
|
45
|
+
readonly missingSkills: string[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Build a `SkillInfo[]` list from an explicit list of skill names.
|
|
49
|
+
*
|
|
50
|
+
* Use this when the harness SDK provides skill names as strings and you need
|
|
51
|
+
* to construct the `SkillInfo[]` list expected by the engine.
|
|
52
|
+
*
|
|
53
|
+
* @param names - Skill names provided by the harness.
|
|
54
|
+
* @returns `SkillInfo[]` with no adapter metadata.
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildSkillInfoList(names: string[]): SkillInfo[];
|
|
57
|
+
/**
|
|
58
|
+
* Validate that all declared skill names are present in the harness-provided
|
|
59
|
+
* available list.
|
|
60
|
+
*
|
|
61
|
+
* Returns `ok(void)` when all declared skills are available, or
|
|
62
|
+
* `err(MissingSkillsError)` with the names of missing skills.
|
|
63
|
+
*
|
|
64
|
+
* This is a convenience helper for adapters that want to validate skill
|
|
65
|
+
* availability before calling the engine's `resolveSkillsForAgent()`.
|
|
66
|
+
*
|
|
67
|
+
* @param declaredSkills - Skill names declared by the agent.
|
|
68
|
+
* @param availableSkills - Skills provided by the harness to the adapter.
|
|
69
|
+
* @param disabledSkills - Skill names that are globally disabled (skipped).
|
|
70
|
+
* @returns `ok(void)` when all non-disabled declared skills are available.
|
|
71
|
+
*/
|
|
72
|
+
export declare function validateDeclaredSkills(declaredSkills: string[], availableSkills: SkillInfo[], disabledSkills?: string[]): Result<void, MissingSkillsError>;
|
|
73
|
+
//# sourceMappingURL=skill-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-discovery.d.ts","sourceRoot":"","sources":["../src/skill-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAMlD;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,kFAAkF;IAClF,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC;CAClC;AAMD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAE/D;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,MAAM,EAAE,EACxB,eAAe,EAAE,SAAS,EAAE,EAC5B,cAAc,GAAE,MAAM,EAAO,GAC5B,MAAM,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAelC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* start-plan-execution — adapter-owned projection of the engine's start-plan operation.
|
|
3
|
+
*
|
|
4
|
+
* This module is the OpenCode adapter's projection of the reusable `startPlan`
|
|
5
|
+
* engine operation. It supplies the adapter-owned `projectEffect` callback
|
|
6
|
+
* (calling `adapter.spawnSubagent`) and maps the engine's typed
|
|
7
|
+
* `CommandOperationError` result back to the adapter-owned
|
|
8
|
+
* `StartPlanExecutionError` discriminated union.
|
|
9
|
+
*
|
|
10
|
+
* ## Boundary rule
|
|
11
|
+
*
|
|
12
|
+
* This module is adapter-owned. It must not import from `@weaveio/weave-core` directly
|
|
13
|
+
* (config types are accepted as parameters, not fetched). Command naming is
|
|
14
|
+
* adapter-owned — the engine never references `WEAVE_START_COMMAND` or
|
|
15
|
+
* `WEAVE_START_LEGACY_COMMAND`.
|
|
16
|
+
*
|
|
17
|
+
* ## Command name preference
|
|
18
|
+
*
|
|
19
|
+
* - `/weave:start` — preferred command surface when the harness supports namespaced
|
|
20
|
+
* commands (e.g. OpenCode's `/namespace:command` syntax).
|
|
21
|
+
* - `/start-work` — legacy compatibility alias; adapters may register this as a
|
|
22
|
+
* secondary entry point for backwards compatibility.
|
|
23
|
+
*
|
|
24
|
+
* See `WEAVE_START_COMMAND` and `WEAVE_START_LEGACY_COMMAND` constants below.
|
|
25
|
+
*/
|
|
26
|
+
import type { PlanStateProvider, RuntimeStore } from "@weaveio/weave-engine";
|
|
27
|
+
import { type ResultAsync } from "neverthrow";
|
|
28
|
+
import type { OpenCodeAdapter } from "./adapter.js";
|
|
29
|
+
import type { RunWorkflowError, RunWorkflowInput, RunWorkflowResult } from "./run-workflow.js";
|
|
30
|
+
/**
|
|
31
|
+
* Preferred command name for the explicit plan-execution delivery path.
|
|
32
|
+
*
|
|
33
|
+
* When the harness supports namespaced commands (e.g. OpenCode's
|
|
34
|
+
* `/namespace:command` syntax), register this as the primary entry point.
|
|
35
|
+
*
|
|
36
|
+
* This constant is adapter-owned. Core packages must never reference it.
|
|
37
|
+
*/
|
|
38
|
+
export declare const WEAVE_START_COMMAND: "/weave:start";
|
|
39
|
+
/**
|
|
40
|
+
* Legacy compatibility command name for the explicit plan-execution delivery path.
|
|
41
|
+
*
|
|
42
|
+
* Adapters may register this as a secondary entry point for backwards
|
|
43
|
+
* compatibility with users who have muscle memory for the older command surface.
|
|
44
|
+
*
|
|
45
|
+
* Prefer `WEAVE_START_COMMAND` for new integrations.
|
|
46
|
+
*/
|
|
47
|
+
export declare const WEAVE_START_LEGACY_COMMAND: "/start-work";
|
|
48
|
+
/**
|
|
49
|
+
* Default workflow name used by `startPlanExecution` when no explicit
|
|
50
|
+
* `workflowName` is provided.
|
|
51
|
+
*
|
|
52
|
+
* `tapestry-execution` is the builtin workflow for executing an existing named
|
|
53
|
+
* plan end-to-end. It is the correct default for the `/weave:start` delivery
|
|
54
|
+
* path because that path is invoked when a plan already exists.
|
|
55
|
+
*/
|
|
56
|
+
export declare const DEFAULT_EXECUTION_WORKFLOW: "tapestry-execution";
|
|
57
|
+
/**
|
|
58
|
+
* Discriminated union of errors that `startPlanExecution` can return.
|
|
59
|
+
*
|
|
60
|
+
* - `PlanNotFound` — the plan does not exist according to the `PlanStateProvider`.
|
|
61
|
+
* - `InvalidPlanName` — the plan name failed the safe-name check in the
|
|
62
|
+
* `PlanStateProvider` (contains `/`, `..`, `\0`, or other unsafe characters).
|
|
63
|
+
* - `ProviderUnavailable` — the `PlanStateProvider` could not be queried (I/O
|
|
64
|
+
* error or the provider was not supplied).
|
|
65
|
+
* - `WorkflowError` — the underlying `startPlan` call returned an error.
|
|
66
|
+
*/
|
|
67
|
+
export type StartPlanExecutionError = {
|
|
68
|
+
readonly type: "PlanNotFound";
|
|
69
|
+
readonly planName: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly type: "InvalidPlanName";
|
|
72
|
+
readonly planName: string;
|
|
73
|
+
} | {
|
|
74
|
+
readonly type: "ProviderUnavailable";
|
|
75
|
+
readonly cause: Error | {
|
|
76
|
+
readonly message: string;
|
|
77
|
+
};
|
|
78
|
+
} | {
|
|
79
|
+
readonly type: "WorkflowError";
|
|
80
|
+
readonly cause: RunWorkflowError;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Input for `startPlanExecution`.
|
|
84
|
+
*/
|
|
85
|
+
export interface StartPlanExecutionInput {
|
|
86
|
+
/**
|
|
87
|
+
* Name of the plan to execute.
|
|
88
|
+
*
|
|
89
|
+
* Must match a plan file at `.weave/plans/<planName>.md` (or wherever the
|
|
90
|
+
* `PlanStateProvider` implementation resolves plan files).
|
|
91
|
+
*/
|
|
92
|
+
readonly planName: string;
|
|
93
|
+
/**
|
|
94
|
+
* Full WeaveConfig containing workflow definitions.
|
|
95
|
+
*
|
|
96
|
+
* Must include the workflow referenced by `workflowName` (defaults to
|
|
97
|
+
* `tapestry-execution`).
|
|
98
|
+
*
|
|
99
|
+
* Typed as `RunWorkflowInput["config"]` to avoid a direct `@weaveio/weave-core`
|
|
100
|
+
* import — the adapter boundary requires that core types flow through
|
|
101
|
+
* adapter-owned modules, not be imported directly.
|
|
102
|
+
*/
|
|
103
|
+
readonly config: RunWorkflowInput["config"];
|
|
104
|
+
/**
|
|
105
|
+
* Provider for querying plan file state.
|
|
106
|
+
*
|
|
107
|
+
* Used to validate that the plan exists before calling `startPlan`.
|
|
108
|
+
* When omitted, `startPlanExecution` returns a `ProviderUnavailable` error
|
|
109
|
+
* without touching the store.
|
|
110
|
+
*
|
|
111
|
+
* Typically `adapter.planStateProvider` (set during `adapter.init()`).
|
|
112
|
+
*/
|
|
113
|
+
readonly planStateProvider: PlanStateProvider | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* OpenCode adapter instance — `spawnSubagent` is called for each
|
|
116
|
+
* `DispatchAgentEffect` emitted by the workflow execution loop.
|
|
117
|
+
*/
|
|
118
|
+
readonly adapter: OpenCodeAdapter;
|
|
119
|
+
/**
|
|
120
|
+
* Human-readable goal for this execution instance.
|
|
121
|
+
*
|
|
122
|
+
* Passed through to `startPlan` as `goal`. Defaults to
|
|
123
|
+
* `"Execute plan: <planName>"` when omitted.
|
|
124
|
+
*/
|
|
125
|
+
readonly goal?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Workflow name to execute.
|
|
128
|
+
*
|
|
129
|
+
* Defaults to `DEFAULT_EXECUTION_WORKFLOW` (`"tapestry-execution"`).
|
|
130
|
+
*/
|
|
131
|
+
readonly workflowName?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Runtime Store instance.
|
|
134
|
+
*
|
|
135
|
+
* Passed through to `startPlan`. Callers that need status/control to inspect
|
|
136
|
+
* the execution later must supply a shared store instance here. Defaults to
|
|
137
|
+
* a fresh `InMemoryRuntimeStore` when omitted.
|
|
138
|
+
*/
|
|
139
|
+
readonly store?: RuntimeStore;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Adapter-owned projection of the engine's `startPlan` command operation.
|
|
143
|
+
*
|
|
144
|
+
* Validates that the named plan exists via `PlanStateProvider.planExists()`
|
|
145
|
+
* before delegating to the engine's `startPlan` operation. Fails without
|
|
146
|
+
* creating a `WorkflowInstance` when the plan is missing or the provider is
|
|
147
|
+
* unavailable.
|
|
148
|
+
*
|
|
149
|
+
* ## Execution flow
|
|
150
|
+
*
|
|
151
|
+
* 1. Guard: if `planStateProvider` is `undefined`, return `ProviderUnavailable`.
|
|
152
|
+
* 2. Delegate to `startPlan` (engine-owned) with:
|
|
153
|
+
* - `planStateProvider` for plan existence validation (engine validates before
|
|
154
|
+
* touching the store).
|
|
155
|
+
* - `projectEffect` callback that calls `adapter.spawnSubagent` for each
|
|
156
|
+
* `DispatchAgentEffect` emitted by the workflow runner.
|
|
157
|
+
* 3. Map `CommandOperationError` → `StartPlanExecutionError`.
|
|
158
|
+
* 4. Map `ExecutionStartedData` → `RunWorkflowResult`.
|
|
159
|
+
*
|
|
160
|
+
* @param input - Execution parameters.
|
|
161
|
+
* @returns `ok(RunWorkflowResult)` on success, or `err(StartPlanExecutionError)`.
|
|
162
|
+
*/
|
|
163
|
+
export declare function startPlanExecution(input: StartPlanExecutionInput): ResultAsync<RunWorkflowResult, StartPlanExecutionError>;
|
|
164
|
+
//# sourceMappingURL=start-plan-execution.d.ts.map
|