substrate-ai 0.20.64 → 0.20.66
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/dist/adapter-registry-BbVWH3Yv.js +4 -0
- package/dist/cli/index.js +172 -25
- package/dist/{decision-router-BA__VYIp.js → decision-router-DblHY8se.js} +1 -1
- package/dist/{decisions-4F91LrVD.js → decisions-DilHo99V.js} +2 -2
- package/dist/{dist-W2emvN3F.js → dist-K_RRWnBX.js} +2 -2
- package/dist/{errors-CKFu8YI9.js → errors-pSiZbn6e.js} +2 -2
- package/dist/{experimenter-BgpUcUaW.js → experimenter-DT9v2Pto.js} +1 -1
- package/dist/health-D6MKxV46.js +1715 -0
- package/dist/health-rGXaJvYJ.js +8 -0
- package/dist/index-c924O9mj.d.ts +1432 -0
- package/dist/index.d.ts +56 -735
- package/dist/index.js +2 -2
- package/dist/interactive-prompt-kzkG24Rn.js +183 -0
- package/dist/{health-DudlnqXd.js → manifest-read-g4zt3DXJ.js} +280 -2014
- package/dist/modules/interactive-prompt/index.d.ts +86 -0
- package/dist/modules/interactive-prompt/index.js +6 -0
- package/dist/recovery-engine-BKGBeBnW.js +281 -0
- package/dist/{routing-0ykvBl_4.js → routing-CzF0p6lI.js} +2 -2
- package/dist/{run-CCxsv-9M.js → run-7h2-DIjt.js} +282 -37
- package/dist/run-DB9P6m_P.js +14 -0
- package/dist/src/modules/decision-router/index.js +1 -1
- package/dist/src/modules/recovery-engine/index.d.ts +1101 -0
- package/dist/src/modules/recovery-engine/index.js +5 -0
- package/dist/{upgrade-OFeC_NIx.js → upgrade-DxzQ1nss.js} +3 -3
- package/dist/{upgrade-aW7GYL2F.js → upgrade-MP9XzrI6.js} +2 -2
- package/dist/version-manager-impl-GZDUBt0Q.js +4 -0
- package/dist/work-graph-repository-DZyJv5pV.js +265 -0
- package/package.json +1 -1
- package/dist/adapter-registry-k7ZX3Bz6.js +0 -4
- package/dist/health-CLNmnZiw.js +0 -6
- package/dist/run-ChxsPICN.js +0 -10
- package/dist/version-manager-impl-BCSf5E3j.js +0 -4
- /package/dist/{decisions-C0pz9Clx.js → decisions-CzSIEeGP.js} +0 -0
- /package/dist/{routing-CcBOCuC9.js → routing-DFxoKHDt.js} +0 -0
- /package/dist/{version-manager-impl-FH4TTnXm.js → version-manager-impl-qFBiO4Eh.js} +0 -0
|
@@ -0,0 +1,1432 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region packages/core/dist/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Core types for Substrate
|
|
6
|
+
* Shared type definitions used across all modules
|
|
7
|
+
*/
|
|
8
|
+
/** Unique identifier for a task in the DAG */
|
|
9
|
+
/**
|
|
10
|
+
* Core types for Substrate
|
|
11
|
+
* Shared type definitions used across all modules
|
|
12
|
+
*/
|
|
13
|
+
/** Unique identifier for a task in the DAG */
|
|
14
|
+
type TaskId$1 = string;
|
|
15
|
+
/** Unique identifier for a worker/agent instance */
|
|
16
|
+
|
|
17
|
+
/** Unique identifier for a registered agent type */
|
|
18
|
+
type AgentId = string;
|
|
19
|
+
/** Status of an individual task */
|
|
20
|
+
|
|
21
|
+
/** Billing mode for a worker/agent */
|
|
22
|
+
type BillingMode = 'subscription' | 'api' | 'free'; //#endregion
|
|
23
|
+
//#region packages/core/dist/events/types.d.ts
|
|
24
|
+
/** Severity level for errors and log messages */
|
|
25
|
+
/**
|
|
26
|
+
* Base event type primitives for the TypedEventBus system.
|
|
27
|
+
*
|
|
28
|
+
* These types are the foundation of the event bus contract.
|
|
29
|
+
* All event maps must satisfy EventMap; all handlers must satisfy EventHandler<T>.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Base constraint for event maps.
|
|
33
|
+
* Each key is an event name (string), and the value is the payload type.
|
|
34
|
+
*
|
|
35
|
+
* Using `object` (not `Record<string, unknown>`) so that TypeScript interfaces
|
|
36
|
+
* with named properties (without index signatures) satisfy the constraint.
|
|
37
|
+
* TypeScript interfaces extend `object` but may not extend `Record<string, unknown>`
|
|
38
|
+
* unless they have an explicit index signature.
|
|
39
|
+
*/
|
|
40
|
+
type EventMap = object;
|
|
41
|
+
/**
|
|
42
|
+
* A typed event handler function for payload type T.
|
|
43
|
+
*/
|
|
44
|
+
type EventHandler<T> = (payload: T) => void;
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region packages/core/dist/events/event-bus.d.ts
|
|
48
|
+
//# sourceMappingURL=types.d.ts.map
|
|
49
|
+
/**
|
|
50
|
+
* A type-safe event bus parameterized over an event map E.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const bus: TypedEventBus<CoreEvents & SdlcEvents> = createEventBus()
|
|
54
|
+
* bus.on('orchestrator:story-complete', ({ storyKey }) => { ... })
|
|
55
|
+
*/
|
|
56
|
+
interface TypedEventBus<E extends EventMap> {
|
|
57
|
+
/**
|
|
58
|
+
* Emit an event with a typed payload.
|
|
59
|
+
* All registered handlers for this event key are called synchronously.
|
|
60
|
+
*/
|
|
61
|
+
emit<K extends keyof E>(event: K, payload: E[K]): void;
|
|
62
|
+
/**
|
|
63
|
+
* Register a handler for an event.
|
|
64
|
+
*/
|
|
65
|
+
on<K extends keyof E>(event: K, handler: EventHandler<E[K]>): void;
|
|
66
|
+
/**
|
|
67
|
+
* Unregister a previously registered handler.
|
|
68
|
+
*/
|
|
69
|
+
off<K extends keyof E>(event: K, handler: EventHandler<E[K]>): void;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region packages/core/dist/routing/routing-decision.d.ts
|
|
74
|
+
/**
|
|
75
|
+
* Concrete implementation of TypedEventBus backed by Node.js EventEmitter.
|
|
76
|
+
*
|
|
77
|
+
* Dispatch is SYNCHRONOUS — all handlers run before emit() returns (per ADR-004).
|
|
78
|
+
* maxListeners is set to 100 to avoid spurious warnings in large systems.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* const bus = new TypedEventBusImpl<CoreEvents & SdlcEvents>()
|
|
82
|
+
* bus.on('orchestrator:story-complete', ({ storyKey }) => { ... })
|
|
83
|
+
* bus.emit('orchestrator:story-complete', { storyKey: '1-1', reviewCycles: 1 })
|
|
84
|
+
*/
|
|
85
|
+
/**
|
|
86
|
+
* RoutingDecision — type definition and factory for routing decisions.
|
|
87
|
+
*
|
|
88
|
+
* A RoutingDecision is the output of the RoutingEngine.routeTask() method.
|
|
89
|
+
* It captures which agent was selected, the billing mode, and the rationale
|
|
90
|
+
* for the routing choice (NFR7 — audit trail for cost tracking).
|
|
91
|
+
*/
|
|
92
|
+
/**
|
|
93
|
+
* Advisory recommendation from monitor agent.
|
|
94
|
+
* Defined locally to avoid importing the monitor module into core.
|
|
95
|
+
*
|
|
96
|
+
* The core fields mirror the monitor module's concrete Recommendation type
|
|
97
|
+
* (all required) so that:
|
|
98
|
+
* 1. monitor.Recommendation is structurally assignable to MonitorRecommendation ✓
|
|
99
|
+
* 2. MonitorRecommendation is structurally assignable to monitor.Recommendation ✓
|
|
100
|
+
* (extra optional fields `model` and `rationale` are permitted by structural typing)
|
|
101
|
+
*
|
|
102
|
+
* This bidirectional compatibility prevents TypeScript errors when callers store
|
|
103
|
+
* `decision.monitorRecommendation` in a Recommendation-typed variable (AC2, Story 41-4).
|
|
104
|
+
*/
|
|
105
|
+
interface MonitorRecommendation {
|
|
106
|
+
task_type: string;
|
|
107
|
+
current_agent: string;
|
|
108
|
+
recommended_agent: string;
|
|
109
|
+
reason: string;
|
|
110
|
+
/** Confidence tier — 'low', 'medium', or 'high' */
|
|
111
|
+
confidence: 'low' | 'medium' | 'high';
|
|
112
|
+
current_success_rate: number;
|
|
113
|
+
recommended_success_rate: number;
|
|
114
|
+
current_avg_tokens: number;
|
|
115
|
+
recommended_avg_tokens: number;
|
|
116
|
+
improvement_percentage: number;
|
|
117
|
+
sample_size_current: number;
|
|
118
|
+
sample_size_recommended: number;
|
|
119
|
+
/** Optional model override suggestion (used in some contexts) */
|
|
120
|
+
model?: string;
|
|
121
|
+
rationale?: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The result of a routing decision for a task.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* {
|
|
128
|
+
* taskId: 'task-1',
|
|
129
|
+
* agent: 'claude',
|
|
130
|
+
* billingMode: 'subscription',
|
|
131
|
+
* rationale: 'Subscription-first: Claude subscription available, tokens within limit',
|
|
132
|
+
* fallbackChain: ['claude', 'codex'],
|
|
133
|
+
* }
|
|
134
|
+
*/
|
|
135
|
+
interface RoutingDecision {
|
|
136
|
+
/** Task identifier this decision was made for */
|
|
137
|
+
taskId: string;
|
|
138
|
+
/** Selected CLI agent name (e.g., 'claude', 'codex', 'gemini') */
|
|
139
|
+
agent: string;
|
|
140
|
+
/** Billing mode for this routing decision */
|
|
141
|
+
billingMode: 'subscription' | 'api' | 'unavailable';
|
|
142
|
+
/** Optional model preference if specified in routing policy */
|
|
143
|
+
model?: string;
|
|
144
|
+
/** Human-readable rationale for the routing choice (required for NFR7 audit) */
|
|
145
|
+
rationale: string;
|
|
146
|
+
/** Agents tried in order during fallback chain evaluation */
|
|
147
|
+
fallbackChain?: string[];
|
|
148
|
+
/** Estimated cost in USD for this task (if known) */
|
|
149
|
+
estimatedCostUsd?: number;
|
|
150
|
+
/** Rate limit state at time of decision */
|
|
151
|
+
rateLimit?: {
|
|
152
|
+
tokensUsedInWindow: number;
|
|
153
|
+
limit: number;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Advisory recommendation from monitor agent (AC5, Story 8.6).
|
|
157
|
+
* Present when use_monitor_recommendations=true and a recommendation is available.
|
|
158
|
+
* This is informational only — routing policy always takes precedence.
|
|
159
|
+
*/
|
|
160
|
+
monitorRecommendation?: MonitorRecommendation;
|
|
161
|
+
/**
|
|
162
|
+
* Whether the monitor agent was consulted for this routing decision (AC5).
|
|
163
|
+
* True when use_monitor_recommendations=true, regardless of whether a
|
|
164
|
+
* recommendation was available.
|
|
165
|
+
*/
|
|
166
|
+
monitorInfluenced: boolean;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region packages/core/dist/dispatch/types.d.ts
|
|
171
|
+
/**
|
|
172
|
+
* Builder for constructing RoutingDecision objects with a fluent API.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* const decision = makeRoutingDecision('task-1')
|
|
176
|
+
* .withAgent('claude', 'subscription')
|
|
177
|
+
* .withRationale('Subscription-first: Claude subscription available')
|
|
178
|
+
* .withFallbackChain(['claude', 'codex'])
|
|
179
|
+
* .build()
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Logger interface compatible with both pino-style loggers and console.
|
|
184
|
+
* Methods accept any argument pattern: (msg: string) or (obj: unknown, msg?: string).
|
|
185
|
+
*/
|
|
186
|
+
interface ILogger {
|
|
187
|
+
info(...args: unknown[]): void;
|
|
188
|
+
warn(...args: unknown[]): void;
|
|
189
|
+
error(...args: unknown[]): void;
|
|
190
|
+
debug(...args: unknown[]): void;
|
|
191
|
+
} //#endregion
|
|
192
|
+
//#region packages/core/dist/config/types.d.ts
|
|
193
|
+
|
|
194
|
+
//# sourceMappingURL=types.d.ts.map
|
|
195
|
+
declare const SubstrateConfigSchema: z.ZodObject<{
|
|
196
|
+
config_format_version: z.ZodEnum<{
|
|
197
|
+
1: "1";
|
|
198
|
+
}>;
|
|
199
|
+
task_graph_version: z.ZodOptional<z.ZodEnum<{
|
|
200
|
+
1: "1";
|
|
201
|
+
}>>;
|
|
202
|
+
global: z.ZodObject<{
|
|
203
|
+
log_level: z.ZodEnum<{
|
|
204
|
+
trace: "trace";
|
|
205
|
+
debug: "debug";
|
|
206
|
+
info: "info";
|
|
207
|
+
warn: "warn";
|
|
208
|
+
error: "error";
|
|
209
|
+
fatal: "fatal";
|
|
210
|
+
}>;
|
|
211
|
+
max_concurrent_tasks: z.ZodNumber;
|
|
212
|
+
budget_cap_tokens: z.ZodNumber;
|
|
213
|
+
budget_cap_usd: z.ZodNumber;
|
|
214
|
+
workspace_dir: z.ZodOptional<z.ZodString>;
|
|
215
|
+
update_check: z.ZodOptional<z.ZodBoolean>;
|
|
216
|
+
}, z.core.$strict>;
|
|
217
|
+
providers: z.ZodObject<{
|
|
218
|
+
claude: z.ZodOptional<z.ZodObject<{
|
|
219
|
+
enabled: z.ZodBoolean;
|
|
220
|
+
cli_path: z.ZodOptional<z.ZodString>;
|
|
221
|
+
subscription_routing: z.ZodEnum<{
|
|
222
|
+
subscription: "subscription";
|
|
223
|
+
api: "api";
|
|
224
|
+
auto: "auto";
|
|
225
|
+
disabled: "disabled";
|
|
226
|
+
}>;
|
|
227
|
+
max_concurrent: z.ZodNumber;
|
|
228
|
+
rate_limit: z.ZodOptional<z.ZodObject<{
|
|
229
|
+
tokens: z.ZodNumber;
|
|
230
|
+
window_seconds: z.ZodNumber;
|
|
231
|
+
}, z.core.$strict>>;
|
|
232
|
+
api_key_env: z.ZodOptional<z.ZodString>;
|
|
233
|
+
api_billing: z.ZodBoolean;
|
|
234
|
+
}, z.core.$strict>>;
|
|
235
|
+
codex: z.ZodOptional<z.ZodObject<{
|
|
236
|
+
enabled: z.ZodBoolean;
|
|
237
|
+
cli_path: z.ZodOptional<z.ZodString>;
|
|
238
|
+
subscription_routing: z.ZodEnum<{
|
|
239
|
+
subscription: "subscription";
|
|
240
|
+
api: "api";
|
|
241
|
+
auto: "auto";
|
|
242
|
+
disabled: "disabled";
|
|
243
|
+
}>;
|
|
244
|
+
max_concurrent: z.ZodNumber;
|
|
245
|
+
rate_limit: z.ZodOptional<z.ZodObject<{
|
|
246
|
+
tokens: z.ZodNumber;
|
|
247
|
+
window_seconds: z.ZodNumber;
|
|
248
|
+
}, z.core.$strict>>;
|
|
249
|
+
api_key_env: z.ZodOptional<z.ZodString>;
|
|
250
|
+
api_billing: z.ZodBoolean;
|
|
251
|
+
}, z.core.$strict>>;
|
|
252
|
+
gemini: z.ZodOptional<z.ZodObject<{
|
|
253
|
+
enabled: z.ZodBoolean;
|
|
254
|
+
cli_path: z.ZodOptional<z.ZodString>;
|
|
255
|
+
subscription_routing: z.ZodEnum<{
|
|
256
|
+
subscription: "subscription";
|
|
257
|
+
api: "api";
|
|
258
|
+
auto: "auto";
|
|
259
|
+
disabled: "disabled";
|
|
260
|
+
}>;
|
|
261
|
+
max_concurrent: z.ZodNumber;
|
|
262
|
+
rate_limit: z.ZodOptional<z.ZodObject<{
|
|
263
|
+
tokens: z.ZodNumber;
|
|
264
|
+
window_seconds: z.ZodNumber;
|
|
265
|
+
}, z.core.$strict>>;
|
|
266
|
+
api_key_env: z.ZodOptional<z.ZodString>;
|
|
267
|
+
api_billing: z.ZodBoolean;
|
|
268
|
+
}, z.core.$strict>>;
|
|
269
|
+
}, z.core.$strict>;
|
|
270
|
+
cost_tracker: z.ZodOptional<z.ZodObject<{
|
|
271
|
+
enabled: z.ZodBoolean;
|
|
272
|
+
token_rates_provider: z.ZodEnum<{
|
|
273
|
+
builtin: "builtin";
|
|
274
|
+
custom: "custom";
|
|
275
|
+
}>;
|
|
276
|
+
track_planning_costs: z.ZodBoolean;
|
|
277
|
+
savings_reporting: z.ZodBoolean;
|
|
278
|
+
}, z.core.$strict>>;
|
|
279
|
+
budget: z.ZodOptional<z.ZodObject<{
|
|
280
|
+
default_task_budget_usd: z.ZodNumber;
|
|
281
|
+
default_session_budget_usd: z.ZodNumber;
|
|
282
|
+
planning_costs_count_against_budget: z.ZodBoolean;
|
|
283
|
+
warning_threshold_percent: z.ZodNumber;
|
|
284
|
+
}, z.core.$strict>>;
|
|
285
|
+
telemetry: z.ZodOptional<z.ZodObject<{
|
|
286
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
287
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
288
|
+
meshUrl: z.ZodOptional<z.ZodString>;
|
|
289
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
290
|
+
}, z.core.$strict>>;
|
|
291
|
+
trivialOutputThreshold: z.ZodOptional<z.ZodNumber>;
|
|
292
|
+
}, z.core.$loose>;
|
|
293
|
+
type SubstrateConfig = z.infer<typeof SubstrateConfigSchema>; //#endregion
|
|
294
|
+
//#region packages/core/dist/events/core-events.d.ts
|
|
295
|
+
/** Unique task identifier */
|
|
296
|
+
type TaskId = string;
|
|
297
|
+
/** Unique worker identifier */
|
|
298
|
+
type WorkerId = string;
|
|
299
|
+
/** Result of a completed task */
|
|
300
|
+
interface EventTaskResult {
|
|
301
|
+
output?: string;
|
|
302
|
+
exitCode?: number;
|
|
303
|
+
tokensUsed?: number;
|
|
304
|
+
inputTokens?: number;
|
|
305
|
+
outputTokens?: number;
|
|
306
|
+
durationMs?: number;
|
|
307
|
+
costUsd?: number;
|
|
308
|
+
agent?: string;
|
|
309
|
+
}
|
|
310
|
+
/** Error payload for a failed task */
|
|
311
|
+
interface EventTaskError {
|
|
312
|
+
message: string;
|
|
313
|
+
code?: string;
|
|
314
|
+
stack?: string;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Typed map of all core infrastructure events.
|
|
318
|
+
* SDLC-specific events (orchestrator:story-*, plan:*, solutioning:*, story:*, pipeline:*)
|
|
319
|
+
* are excluded and belong to SdlcEvents.
|
|
320
|
+
*/
|
|
321
|
+
interface CoreEvents {
|
|
322
|
+
/** Task has all dependencies satisfied and is ready to be assigned */
|
|
323
|
+
'task:ready': {
|
|
324
|
+
taskId: TaskId;
|
|
325
|
+
taskType?: string;
|
|
326
|
+
};
|
|
327
|
+
/** A worker has begun execution of a task */
|
|
328
|
+
'task:started': {
|
|
329
|
+
taskId: TaskId;
|
|
330
|
+
workerId: WorkerId;
|
|
331
|
+
agent: string;
|
|
332
|
+
};
|
|
333
|
+
/** Incremental progress report from a running task */
|
|
334
|
+
'task:progress': {
|
|
335
|
+
taskId: TaskId;
|
|
336
|
+
message: string;
|
|
337
|
+
tokensUsed?: number;
|
|
338
|
+
};
|
|
339
|
+
/** Task has completed successfully */
|
|
340
|
+
'task:complete': {
|
|
341
|
+
taskId: TaskId;
|
|
342
|
+
result: EventTaskResult;
|
|
343
|
+
taskType?: string;
|
|
344
|
+
};
|
|
345
|
+
/** Task has failed with an error */
|
|
346
|
+
'task:failed': {
|
|
347
|
+
taskId: TaskId;
|
|
348
|
+
error: EventTaskError;
|
|
349
|
+
};
|
|
350
|
+
/** Task was cancelled */
|
|
351
|
+
'task:cancelled': {
|
|
352
|
+
taskId: TaskId;
|
|
353
|
+
reason: string;
|
|
354
|
+
};
|
|
355
|
+
/** Task is being retried after a failure */
|
|
356
|
+
'task:retrying': {
|
|
357
|
+
taskId: TaskId;
|
|
358
|
+
attempt: number;
|
|
359
|
+
maxAttempts: number;
|
|
360
|
+
};
|
|
361
|
+
/** A task has been routed to an agent with billing mode decision */
|
|
362
|
+
'task:routed': {
|
|
363
|
+
taskId: TaskId;
|
|
364
|
+
decision: RoutingDecision;
|
|
365
|
+
};
|
|
366
|
+
/** Budget cap has been set for a task */
|
|
367
|
+
'task:budget-set': {
|
|
368
|
+
taskId: TaskId;
|
|
369
|
+
budgetUsd: number;
|
|
370
|
+
};
|
|
371
|
+
/** A worker subprocess was spawned */
|
|
372
|
+
'worker:spawned': {
|
|
373
|
+
workerId: WorkerId;
|
|
374
|
+
taskId: TaskId;
|
|
375
|
+
agent: string;
|
|
376
|
+
};
|
|
377
|
+
/** A worker subprocess was terminated */
|
|
378
|
+
'worker:terminated': {
|
|
379
|
+
workerId: WorkerId;
|
|
380
|
+
reason: string;
|
|
381
|
+
};
|
|
382
|
+
/** Spending is approaching the configured budget limit */
|
|
383
|
+
'budget:warning': {
|
|
384
|
+
taskId: TaskId;
|
|
385
|
+
currentSpend: number;
|
|
386
|
+
limit: number;
|
|
387
|
+
};
|
|
388
|
+
/** Spending has exceeded the configured budget limit */
|
|
389
|
+
'budget:exceeded': {
|
|
390
|
+
taskId: TaskId;
|
|
391
|
+
spend: number;
|
|
392
|
+
limit: number;
|
|
393
|
+
};
|
|
394
|
+
/** Task is approaching its budget cap (80% threshold) */
|
|
395
|
+
'budget:warning:task': {
|
|
396
|
+
taskId: TaskId;
|
|
397
|
+
currentCostUsd: number;
|
|
398
|
+
budgetUsd: number;
|
|
399
|
+
percentageUsed: number;
|
|
400
|
+
};
|
|
401
|
+
/** Task has exceeded its budget cap — force-terminate worker */
|
|
402
|
+
'budget:exceeded:task': {
|
|
403
|
+
taskId: TaskId;
|
|
404
|
+
currentCostUsd: number;
|
|
405
|
+
budgetUsd: number;
|
|
406
|
+
};
|
|
407
|
+
/** Session-wide budget is approaching the cap (80% threshold) */
|
|
408
|
+
'budget:warning:session': {
|
|
409
|
+
sessionId: string;
|
|
410
|
+
currentCostUsd: number;
|
|
411
|
+
budgetUsd: number;
|
|
412
|
+
percentageUsed: number;
|
|
413
|
+
};
|
|
414
|
+
/** Session-wide budget has been exceeded — terminate all workers */
|
|
415
|
+
'session:budget:exceeded': {
|
|
416
|
+
sessionId: string;
|
|
417
|
+
currentCostUsd: number;
|
|
418
|
+
budgetUsd: number;
|
|
419
|
+
};
|
|
420
|
+
/** Budget cap has been set for a session */
|
|
421
|
+
'session:budget-set': {
|
|
422
|
+
sessionId: string;
|
|
423
|
+
budgetUsd: number;
|
|
424
|
+
};
|
|
425
|
+
/** A task graph has been loaded and validated */
|
|
426
|
+
'graph:loaded': {
|
|
427
|
+
sessionId: string;
|
|
428
|
+
taskCount: number;
|
|
429
|
+
readyCount: number;
|
|
430
|
+
};
|
|
431
|
+
/** All tasks in the graph have completed or failed */
|
|
432
|
+
'graph:complete': {
|
|
433
|
+
totalTasks: number;
|
|
434
|
+
completedTasks: number;
|
|
435
|
+
failedTasks: number;
|
|
436
|
+
totalCostUsd: number;
|
|
437
|
+
};
|
|
438
|
+
/** Graph execution was cancelled */
|
|
439
|
+
'graph:cancelled': {
|
|
440
|
+
cancelledTasks: number;
|
|
441
|
+
};
|
|
442
|
+
/** Graph execution was paused */
|
|
443
|
+
'graph:paused': Record<string, never>;
|
|
444
|
+
/** Graph execution was resumed */
|
|
445
|
+
'graph:resumed': Record<string, never>;
|
|
446
|
+
/** A git worktree was created for a task */
|
|
447
|
+
'worktree:created': {
|
|
448
|
+
taskId: TaskId;
|
|
449
|
+
branchName: string;
|
|
450
|
+
worktreePath: string;
|
|
451
|
+
createdAt?: Date;
|
|
452
|
+
};
|
|
453
|
+
/** A task's worktree branch was merged */
|
|
454
|
+
'worktree:merged': {
|
|
455
|
+
taskId: TaskId;
|
|
456
|
+
branch: string;
|
|
457
|
+
mergedFiles: string[];
|
|
458
|
+
};
|
|
459
|
+
/** A merge conflict was detected in a task's worktree */
|
|
460
|
+
'worktree:conflict': {
|
|
461
|
+
taskId: TaskId;
|
|
462
|
+
branch: string;
|
|
463
|
+
conflictingFiles: string[];
|
|
464
|
+
};
|
|
465
|
+
/** A task's worktree was removed */
|
|
466
|
+
'worktree:removed': {
|
|
467
|
+
taskId: TaskId;
|
|
468
|
+
branchName: string;
|
|
469
|
+
};
|
|
470
|
+
/** A task's cost has been recorded by the cost tracker */
|
|
471
|
+
'cost:recorded': {
|
|
472
|
+
taskId: string;
|
|
473
|
+
sessionId: string;
|
|
474
|
+
costUsd: number;
|
|
475
|
+
savingsUsd: number;
|
|
476
|
+
billingMode: 'subscription' | 'api';
|
|
477
|
+
};
|
|
478
|
+
/** A task's metrics have been recorded by the monitor */
|
|
479
|
+
'monitor:metrics_recorded': {
|
|
480
|
+
taskId: string;
|
|
481
|
+
agent: string;
|
|
482
|
+
taskType: string;
|
|
483
|
+
};
|
|
484
|
+
/** A routing recommendation has been generated by the monitor */
|
|
485
|
+
'monitor:recommendation_generated': {
|
|
486
|
+
taskType: string;
|
|
487
|
+
recommendedAgent: string;
|
|
488
|
+
confidence: number;
|
|
489
|
+
};
|
|
490
|
+
/** Configuration has been reloaded */
|
|
491
|
+
'config:reloaded': {
|
|
492
|
+
path: string;
|
|
493
|
+
previousConfig: SubstrateConfig;
|
|
494
|
+
newConfig: SubstrateConfig;
|
|
495
|
+
changedKeys: string[];
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* Emitted when a sub-agent dispatch is resolved to a specific model via RoutingResolver.
|
|
499
|
+
*/
|
|
500
|
+
'routing:model-selected': {
|
|
501
|
+
dispatchId: string;
|
|
502
|
+
taskType: string;
|
|
503
|
+
phase: string;
|
|
504
|
+
model: string;
|
|
505
|
+
source: 'phase' | 'override';
|
|
506
|
+
};
|
|
507
|
+
/**
|
|
508
|
+
* Emitted by RoutingTuner when it successfully applies an auto-tune downgrade.
|
|
509
|
+
*/
|
|
510
|
+
'routing:auto-tuned': {
|
|
511
|
+
runId: string;
|
|
512
|
+
phase: string;
|
|
513
|
+
oldModel: string;
|
|
514
|
+
newModel: string;
|
|
515
|
+
estimatedSavingsPct: number;
|
|
516
|
+
};
|
|
517
|
+
/** A provider has become unavailable */
|
|
518
|
+
'provider:unavailable': {
|
|
519
|
+
provider: string;
|
|
520
|
+
reason: 'rate_limit' | 'disabled';
|
|
521
|
+
resetAtMs?: number;
|
|
522
|
+
};
|
|
523
|
+
/** A provider has become available */
|
|
524
|
+
'provider:available': {
|
|
525
|
+
provider: string;
|
|
526
|
+
};
|
|
527
|
+
/** A newer version of the toolkit is available */
|
|
528
|
+
'version:update_available': {
|
|
529
|
+
currentVersion: string;
|
|
530
|
+
latestVersion: string;
|
|
531
|
+
breaking: boolean;
|
|
532
|
+
};
|
|
533
|
+
/** A sub-agent subprocess was spawned by the dispatch engine */
|
|
534
|
+
'agent:spawned': {
|
|
535
|
+
dispatchId: string;
|
|
536
|
+
agent: string;
|
|
537
|
+
taskType: string;
|
|
538
|
+
};
|
|
539
|
+
/** Incremental stdout data received from a running sub-agent */
|
|
540
|
+
'agent:output': {
|
|
541
|
+
dispatchId: string;
|
|
542
|
+
data: string;
|
|
543
|
+
};
|
|
544
|
+
/** A sub-agent completed successfully */
|
|
545
|
+
'agent:completed': {
|
|
546
|
+
dispatchId: string;
|
|
547
|
+
exitCode: number;
|
|
548
|
+
output: string;
|
|
549
|
+
/** Estimated input tokens (char-length heuristic) */
|
|
550
|
+
inputTokens?: number;
|
|
551
|
+
/** Estimated output tokens (char-length heuristic) */
|
|
552
|
+
outputTokens?: number;
|
|
553
|
+
};
|
|
554
|
+
/** A sub-agent exited with a non-zero code or encountered an error */
|
|
555
|
+
'agent:failed': {
|
|
556
|
+
dispatchId: string;
|
|
557
|
+
error: string;
|
|
558
|
+
exitCode: number;
|
|
559
|
+
};
|
|
560
|
+
/** A sub-agent was killed because it exceeded its timeout */
|
|
561
|
+
'agent:timeout': {
|
|
562
|
+
dispatchId: string;
|
|
563
|
+
timeoutMs: number;
|
|
564
|
+
};
|
|
565
|
+
/**
|
|
566
|
+
* A dispatch was killed by the timeout handler.
|
|
567
|
+
* Emitted for both the initial attempt (attemptNumber: 1) and the retry
|
|
568
|
+
* attempt (attemptNumber: 2, 1.5× the initial timeout).
|
|
569
|
+
* Story 66-4: closes obs_2026-05-04_023 fix #3.
|
|
570
|
+
* Story 66-5: adds stderrTail/stdoutTail forensic capture
|
|
571
|
+
* (obs_2026-05-04_023 fix #4). Optional for backward-compat.
|
|
572
|
+
*/
|
|
573
|
+
'dispatch:spawnsync-timeout': {
|
|
574
|
+
type: 'dispatch:spawnsync-timeout';
|
|
575
|
+
storyKey: string;
|
|
576
|
+
taskType: string;
|
|
577
|
+
attemptNumber: 1 | 2;
|
|
578
|
+
timeoutMs: number;
|
|
579
|
+
elapsedAtKill: number;
|
|
580
|
+
pid?: number;
|
|
581
|
+
occurredAt: string;
|
|
582
|
+
/** Tail of subprocess stderr captured at kill time (~64KB max, UTF-8) */
|
|
583
|
+
stderrTail?: string;
|
|
584
|
+
/** Tail of subprocess stdout captured at kill time (~64KB max, UTF-8) */
|
|
585
|
+
stdoutTail?: string;
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* Two or more concurrent stories have overlapping target file paths.
|
|
589
|
+
* Motivating incidents: Epic 66 run a832487a + Epic 67 run a59e4c96
|
|
590
|
+
* (concurrent-dispatch races that caused transient verification failures).
|
|
591
|
+
* Mirror of OrchestratorEvents['dispatch:cross-story-file-collision'];
|
|
592
|
+
* both must stay in sync.
|
|
593
|
+
*/
|
|
594
|
+
'dispatch:cross-story-file-collision': {
|
|
595
|
+
storyKeys: string[];
|
|
596
|
+
collisionPaths: string[];
|
|
597
|
+
recommendedAction: 'serialize' | 'warn';
|
|
598
|
+
};
|
|
599
|
+
/**
|
|
600
|
+
* Cross-story race recovery succeeded: fresh verification passed for a story
|
|
601
|
+
* whose original verification result was recorded before a concurrent story's
|
|
602
|
+
* commit landed on overlapping files.
|
|
603
|
+
*
|
|
604
|
+
* Story 70-1. Motivating incidents: Epic 66 (run a832487a), Epic 67 (run a59e4c96).
|
|
605
|
+
* Mirror of OrchestratorEvents['pipeline:cross-story-race-recovered'];
|
|
606
|
+
* both must stay in sync.
|
|
607
|
+
*/
|
|
608
|
+
'pipeline:cross-story-race-recovered': {
|
|
609
|
+
runId: string;
|
|
610
|
+
storyKey: string;
|
|
611
|
+
originalFindings: unknown[];
|
|
612
|
+
freshFindings: unknown[];
|
|
613
|
+
recoveryDurationMs: number;
|
|
614
|
+
};
|
|
615
|
+
/**
|
|
616
|
+
* Cross-story race recovery completed but fresh verification still failed:
|
|
617
|
+
* the story genuinely has issues that are not attributable to the race condition.
|
|
618
|
+
*
|
|
619
|
+
* Story 70-1. Motivating incidents: Epic 66 (run a832487a), Epic 67 (run a59e4c96).
|
|
620
|
+
* Mirror of OrchestratorEvents['pipeline:cross-story-race-still-failed'];
|
|
621
|
+
* both must stay in sync.
|
|
622
|
+
*/
|
|
623
|
+
'pipeline:cross-story-race-still-failed': {
|
|
624
|
+
runId: string;
|
|
625
|
+
storyKey: string;
|
|
626
|
+
freshFindings: unknown[];
|
|
627
|
+
recoveryDurationMs: number;
|
|
628
|
+
};
|
|
629
|
+
/**
|
|
630
|
+
* Story 72-2: A critical halt decision was skipped under --non-interactive mode.
|
|
631
|
+
*
|
|
632
|
+
* Emitted when the pipeline would have prompted the operator (interactive stdin
|
|
633
|
+
* read) but --non-interactive suppressed stdin and auto-applied the default
|
|
634
|
+
* action instead. Operators reviewing the run via `substrate report` can see
|
|
635
|
+
* which halts were auto-skipped and what actions were applied.
|
|
636
|
+
*
|
|
637
|
+
* Mirror of OrchestratorEvents['decision:halt-skipped-non-interactive']; both
|
|
638
|
+
* must stay in sync.
|
|
639
|
+
*/
|
|
640
|
+
'decision:halt-skipped-non-interactive': {
|
|
641
|
+
runId: string;
|
|
642
|
+
/** Halt decision type that was skipped (e.g., 'halt:escalation', 'halt:critical'). */
|
|
643
|
+
decisionType: string;
|
|
644
|
+
/** Severity of the skipped halt (e.g., 'critical'). */
|
|
645
|
+
severity: string;
|
|
646
|
+
/** Action that was applied in place of the operator prompt (e.g., 'continue'). */
|
|
647
|
+
defaultAction: string;
|
|
648
|
+
/** Human-readable reason for skipping (e.g., 'non-interactive: stdin prompt suppressed'). */
|
|
649
|
+
reason: string;
|
|
650
|
+
};
|
|
651
|
+
/**
|
|
652
|
+
* Story 72-1: A halt-able decision was routed and the policy requires halting.
|
|
653
|
+
* Emitted when routeDecision() returns halt=true for a given policy.
|
|
654
|
+
* Mirror of OrchestratorEvents['decision:halt']; both must stay in sync.
|
|
655
|
+
*/
|
|
656
|
+
'decision:halt': {
|
|
657
|
+
runId: string;
|
|
658
|
+
/** The decision type that triggered the halt (e.g., 'cost-ceiling-exhausted'). */
|
|
659
|
+
decisionType: string;
|
|
660
|
+
/** Severity of the decision (e.g., 'critical', 'fatal'). */
|
|
661
|
+
severity: string;
|
|
662
|
+
/** Human-readable reason for the halt. */
|
|
663
|
+
reason: string;
|
|
664
|
+
};
|
|
665
|
+
/**
|
|
666
|
+
* Story 72-1: A halt-able decision was routed and the policy allows autonomous action.
|
|
667
|
+
* Emitted when routeDecision() returns halt=false for a given policy.
|
|
668
|
+
* Caller applies defaultAction without operator intervention.
|
|
669
|
+
* Mirror of OrchestratorEvents['decision:autonomous']; both must stay in sync.
|
|
670
|
+
*/
|
|
671
|
+
'decision:autonomous': {
|
|
672
|
+
runId: string;
|
|
673
|
+
/** The decision type that was routed autonomously (e.g., 'build-verification-failure'). */
|
|
674
|
+
decisionType: string;
|
|
675
|
+
/** Severity of the decision (e.g., 'info', 'warning', 'critical'). */
|
|
676
|
+
severity: string;
|
|
677
|
+
/** The action applied autonomously (e.g., 'escalate-without-halt', 'continue-autonomous'). */
|
|
678
|
+
defaultAction: string;
|
|
679
|
+
/** Human-readable reason for autonomous action. */
|
|
680
|
+
reason: string;
|
|
681
|
+
};
|
|
682
|
+
/** Orchestrator has been fully initialized and is ready to process tasks */
|
|
683
|
+
'orchestrator:ready': Record<string, never>;
|
|
684
|
+
/** Orchestrator shutdown has been initiated */
|
|
685
|
+
'orchestrator:shutdown': {
|
|
686
|
+
reason: string;
|
|
687
|
+
};
|
|
688
|
+
/**
|
|
689
|
+
* Story 73-1: Tier A auto-retry — recovery engine re-dispatched a story
|
|
690
|
+
* with diagnosis + findings prepended to the retry prompt.
|
|
691
|
+
*
|
|
692
|
+
* Mirror of OrchestratorEvents['recovery:tier-a-retry']; both must stay in sync.
|
|
693
|
+
*/
|
|
694
|
+
'recovery:tier-a-retry': {
|
|
695
|
+
runId: string;
|
|
696
|
+
storyKey: string;
|
|
697
|
+
rootCause: string;
|
|
698
|
+
attempt: number;
|
|
699
|
+
retryBudgetRemaining: number;
|
|
700
|
+
};
|
|
701
|
+
/**
|
|
702
|
+
* Story 73-1: Tier B re-scope proposal — recovery engine appended a
|
|
703
|
+
* re-scope proposal to RunManifest.pending_proposals.
|
|
704
|
+
*
|
|
705
|
+
* Mirror of OrchestratorEvents['recovery:tier-b-proposal']; both must stay in sync.
|
|
706
|
+
*/
|
|
707
|
+
'recovery:tier-b-proposal': {
|
|
708
|
+
runId: string;
|
|
709
|
+
storyKey: string;
|
|
710
|
+
rootCause: string;
|
|
711
|
+
attempts: number;
|
|
712
|
+
suggestedAction: string;
|
|
713
|
+
blastRadius: string[];
|
|
714
|
+
};
|
|
715
|
+
/**
|
|
716
|
+
* Story 73-1: Tier C halt — recovery engine determined a halt is required.
|
|
717
|
+
* The orchestrator yields to the Decision Router / Interactive Prompt (Story 73-2).
|
|
718
|
+
*
|
|
719
|
+
* Mirror of OrchestratorEvents['recovery:tier-c-halt']; both must stay in sync.
|
|
720
|
+
*/
|
|
721
|
+
'recovery:tier-c-halt': {
|
|
722
|
+
runId: string;
|
|
723
|
+
storyKey: string;
|
|
724
|
+
rootCause: string;
|
|
725
|
+
};
|
|
726
|
+
/**
|
|
727
|
+
* Story 73-1: Safety valve — pending_proposals count reached 5 or more.
|
|
728
|
+
* The orchestrator exits the main loop with code 1.
|
|
729
|
+
*
|
|
730
|
+
* Mirror of OrchestratorEvents['pipeline:halted-pending-proposals']; both
|
|
731
|
+
* must stay in sync.
|
|
732
|
+
*/
|
|
733
|
+
'pipeline:halted-pending-proposals': {
|
|
734
|
+
runId: string;
|
|
735
|
+
pendingProposalsCount: number;
|
|
736
|
+
};
|
|
737
|
+
} //#endregion
|
|
738
|
+
//#region packages/core/dist/persistence/types.d.ts
|
|
739
|
+
|
|
740
|
+
//# sourceMappingURL=core-events.d.ts.map
|
|
741
|
+
/**
|
|
742
|
+
* Unified async database adapter interface.
|
|
743
|
+
* All persistence backends implement this interface.
|
|
744
|
+
*/
|
|
745
|
+
interface DatabaseAdapter {
|
|
746
|
+
/**
|
|
747
|
+
* The persistence backend powering this adapter.
|
|
748
|
+
* - 'dolt': backed by a Dolt SQL database (persists to disk)
|
|
749
|
+
* - 'memory': backed by in-memory Maps (no persistence, lost on process exit)
|
|
750
|
+
*/
|
|
751
|
+
readonly backendType: 'dolt' | 'memory';
|
|
752
|
+
/**
|
|
753
|
+
* Execute a SQL query and return typed rows.
|
|
754
|
+
* @param sql - SQL query string (use ? for parameter placeholders)
|
|
755
|
+
* @param params - Optional array of parameter values
|
|
756
|
+
*/
|
|
757
|
+
query<T = unknown>(sql: string, params?: unknown[]): Promise<T[]>;
|
|
758
|
+
/**
|
|
759
|
+
* Execute a SQL statement with no return value.
|
|
760
|
+
* Suitable for DDL statements (CREATE TABLE, DROP TABLE) and DML without results.
|
|
761
|
+
* @param sql - SQL statement string
|
|
762
|
+
*/
|
|
763
|
+
exec(sql: string): Promise<void>;
|
|
764
|
+
/**
|
|
765
|
+
* Execute a function within a database transaction.
|
|
766
|
+
* Commits on successful return, rolls back on thrown error.
|
|
767
|
+
* @param fn - Async function that receives the adapter and performs operations
|
|
768
|
+
*/
|
|
769
|
+
transaction<T>(fn: (adapter: DatabaseAdapter) => Promise<T>): Promise<T>;
|
|
770
|
+
/**
|
|
771
|
+
* Close the database connection and release all resources.
|
|
772
|
+
*/
|
|
773
|
+
close(): Promise<void>;
|
|
774
|
+
/**
|
|
775
|
+
* Query story keys from the `ready_stories` SQL view.
|
|
776
|
+
*
|
|
777
|
+
* Returns an array of story key strings (e.g. ['31-1', '31-2']) for stories
|
|
778
|
+
* whose status is `planned` or `ready` and whose hard dependencies are all
|
|
779
|
+
* `complete` in the work graph.
|
|
780
|
+
*
|
|
781
|
+
* Returns `[]` when:
|
|
782
|
+
* - The `ready_stories` view does not exist (story 31-1 schema not applied)
|
|
783
|
+
* - The `stories` table is empty (story 31-2 ingestion has not run)
|
|
784
|
+
* - The adapter does not support the work graph (InMemory)
|
|
785
|
+
*
|
|
786
|
+
* Callers should treat `[]` as a signal to fall through to the legacy
|
|
787
|
+
* story discovery chain (decisions table → epic-shard → epics.md).
|
|
788
|
+
*/
|
|
789
|
+
queryReadyStories(): Promise<string[]>;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
//#endregion
|
|
793
|
+
//#region packages/core/dist/config/errors.d.ts
|
|
794
|
+
/**
|
|
795
|
+
* Configuration for the `createDatabaseAdapter` factory.
|
|
796
|
+
*/
|
|
797
|
+
/**
|
|
798
|
+
* Config-specific error classes for @substrate-ai/core.
|
|
799
|
+
*
|
|
800
|
+
* AdtError is defined here as the canonical base class. ConfigError and
|
|
801
|
+
* ConfigIncompatibleFormatError extend it. The monolith's src/core/errors.ts
|
|
802
|
+
* re-exports AdtError from here so that all error classes share the same
|
|
803
|
+
* base class instance — enabling instanceof checks to work across the
|
|
804
|
+
* monolith/core boundary.
|
|
805
|
+
*/
|
|
806
|
+
/** Base error class for all Substrate errors */
|
|
807
|
+
declare class AdtError extends Error {
|
|
808
|
+
readonly code: string;
|
|
809
|
+
readonly context: Record<string, unknown>;
|
|
810
|
+
constructor(message: string, code: string, context?: Record<string, unknown>);
|
|
811
|
+
toJSON(): Record<string, unknown>;
|
|
812
|
+
}
|
|
813
|
+
/** Error thrown when configuration is invalid or missing */
|
|
814
|
+
declare class ConfigError extends AdtError {
|
|
815
|
+
constructor(message: string, context?: Record<string, unknown>);
|
|
816
|
+
}
|
|
817
|
+
/** Error thrown when a config file uses an incompatible format version */
|
|
818
|
+
declare class ConfigIncompatibleFormatError extends AdtError {
|
|
819
|
+
constructor(message: string, context?: Record<string, unknown>);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
//#endregion
|
|
823
|
+
//#region packages/core/dist/adapters/types.d.ts
|
|
824
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
825
|
+
/**
|
|
826
|
+
* A spawn command descriptor that the orchestrator uses to invoke a CLI agent.
|
|
827
|
+
* Contains all information needed to execute an agent process.
|
|
828
|
+
*/
|
|
829
|
+
interface SpawnCommand {
|
|
830
|
+
/** The binary to execute (e.g., "claude", "codex", "gemini") */
|
|
831
|
+
binary: string;
|
|
832
|
+
/** Arguments to pass to the binary */
|
|
833
|
+
args: string[];
|
|
834
|
+
/** Optional environment variable overrides */
|
|
835
|
+
env?: Record<string, string>;
|
|
836
|
+
/** Optional list of environment variable keys to unset in the child process */
|
|
837
|
+
unsetEnvKeys?: string[];
|
|
838
|
+
/** Working directory for the process */
|
|
839
|
+
cwd: string;
|
|
840
|
+
/** Optional data to pipe to stdin */
|
|
841
|
+
stdin?: string;
|
|
842
|
+
/** Optional timeout in milliseconds */
|
|
843
|
+
timeoutMs?: number;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Options passed to adapter methods for each invocation.
|
|
847
|
+
* Controls execution context for a specific task run.
|
|
848
|
+
*/
|
|
849
|
+
interface AdapterOptions {
|
|
850
|
+
/** Path to the git worktree for this task */
|
|
851
|
+
worktreePath: string;
|
|
852
|
+
/** Billing mode to use for this execution */
|
|
853
|
+
billingMode: BillingMode;
|
|
854
|
+
/** Optional model identifier override */
|
|
855
|
+
model?: string;
|
|
856
|
+
/** Optional additional CLI flags to append */
|
|
857
|
+
additionalFlags?: string[];
|
|
858
|
+
/** Optional API key override (used when billingMode is 'api') */
|
|
859
|
+
apiKey?: string;
|
|
860
|
+
/** Optional maximum agentic turns (passed as --max-turns to Claude CLI) */
|
|
861
|
+
maxTurns?: number;
|
|
862
|
+
/**
|
|
863
|
+
* Optional OTLP endpoint URL for telemetry export (Story 27-9).
|
|
864
|
+
* When set, injects OTLP env vars into the spawned process so that
|
|
865
|
+
* Claude Code exports telemetry to the local IngestionServer.
|
|
866
|
+
* Example: "http://localhost:4318"
|
|
867
|
+
*/
|
|
868
|
+
otlpEndpoint?: string;
|
|
869
|
+
/**
|
|
870
|
+
* Optional story key for OTEL resource attribute tagging.
|
|
871
|
+
* Injected as `substrate.story_key` via OTEL_RESOURCE_ATTRIBUTES
|
|
872
|
+
* so the telemetry pipeline can group spans/events per story.
|
|
873
|
+
*/
|
|
874
|
+
storyKey?: string;
|
|
875
|
+
/**
|
|
876
|
+
* Optional maximum context tokens. Historically passed as --max-context-tokens to
|
|
877
|
+
* Claude CLI; that flag was removed in Claude Code v2.x and is now silently ignored
|
|
878
|
+
* by the claude-adapter. The field remains on the options shape for backward compat
|
|
879
|
+
* with callers (Story 30-8 efficiency-gated retry logic) but no longer constrains
|
|
880
|
+
* dispatch behavior. --max-turns continues to bound dispatch length.
|
|
881
|
+
*/
|
|
882
|
+
maxContextTokens?: number;
|
|
883
|
+
/**
|
|
884
|
+
* Optional optimization directives derived from prior stories' telemetry (Story 30-6).
|
|
885
|
+
* When set, appended to the system prompt to guide the sub-agent toward efficient patterns.
|
|
886
|
+
* Generated by TelemetryAdvisor.formatOptimizationDirectives().
|
|
887
|
+
*/
|
|
888
|
+
optimizationDirectives?: string;
|
|
889
|
+
/** Dispatch context: task type (create-story, dev-story, code-review, etc.) for OTLP attribution */
|
|
890
|
+
taskType?: string;
|
|
891
|
+
/** Dispatch context: unique dispatch ID for per-dispatch telemetry correlation */
|
|
892
|
+
dispatchId?: string;
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* Capabilities reported by an adapter for this CLI agent.
|
|
896
|
+
* Used for routing and planning decisions.
|
|
897
|
+
*/
|
|
898
|
+
interface AdapterCapabilities {
|
|
899
|
+
/** Whether the agent outputs structured JSON */
|
|
900
|
+
supportsJsonOutput: boolean;
|
|
901
|
+
/** Whether the agent supports streaming output */
|
|
902
|
+
supportsStreaming: boolean;
|
|
903
|
+
/** Whether the agent supports subscription-based billing */
|
|
904
|
+
supportsSubscriptionBilling: boolean;
|
|
905
|
+
/** Whether the agent supports API-key-based billing */
|
|
906
|
+
supportsApiBilling: boolean;
|
|
907
|
+
/** Whether the agent can generate task planning graphs */
|
|
908
|
+
supportsPlanGeneration: boolean;
|
|
909
|
+
/** Maximum context tokens the agent supports */
|
|
910
|
+
maxContextTokens: number;
|
|
911
|
+
/** Task types this agent can handle */
|
|
912
|
+
supportedTaskTypes: string[];
|
|
913
|
+
/** Programming languages the agent supports */
|
|
914
|
+
supportedLanguages: string[];
|
|
915
|
+
/**
|
|
916
|
+
* Timeout multiplier relative to default dispatch timeouts.
|
|
917
|
+
* Agents that are slower (e.g., Codex) declare a multiplier > 1.0
|
|
918
|
+
* so the dispatcher scales timeouts automatically.
|
|
919
|
+
* Default: 1.0 (no scaling).
|
|
920
|
+
*/
|
|
921
|
+
timeoutMultiplier?: number;
|
|
922
|
+
/**
|
|
923
|
+
* Whether the agent supports a --system-prompt flag.
|
|
924
|
+
* Claude Code: true. Codex/Gemini: false.
|
|
925
|
+
* When false, system-level instructions must be embedded in the prompt itself.
|
|
926
|
+
*/
|
|
927
|
+
supportsSystemPrompt?: boolean;
|
|
928
|
+
/**
|
|
929
|
+
* Whether the agent exports OTLP telemetry (spans, metrics, logs).
|
|
930
|
+
* Claude Code: true. Codex/Gemini: false.
|
|
931
|
+
* When false, telemetry is heuristic-only (character-based token estimates).
|
|
932
|
+
*/
|
|
933
|
+
supportsOtlpExport?: boolean;
|
|
934
|
+
/**
|
|
935
|
+
* Whether the dispatcher should append a YAML output format reminder to prompts.
|
|
936
|
+
* Claude Code: false (follows methodology pack format instructions reliably).
|
|
937
|
+
* Codex/Gemini: true (need explicit final nudge to emit fenced YAML blocks).
|
|
938
|
+
*/
|
|
939
|
+
requiresYamlSuffix?: boolean;
|
|
940
|
+
/**
|
|
941
|
+
* Default maximum review cycles for this agent backend.
|
|
942
|
+
* Claude Code: 2 (converges quickly). Codex: 3 (needs more iterations).
|
|
943
|
+
* Overridden by explicit --max-review-cycles CLI flag.
|
|
944
|
+
*/
|
|
945
|
+
defaultMaxReviewCycles?: number;
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Result returned from an adapter health check.
|
|
949
|
+
* Indicates whether the CLI binary is present and functional.
|
|
950
|
+
*/
|
|
951
|
+
interface AdapterHealthResult {
|
|
952
|
+
/** Whether the adapter is considered healthy and usable */
|
|
953
|
+
healthy: boolean;
|
|
954
|
+
/** Detected version string of the CLI binary */
|
|
955
|
+
version?: string;
|
|
956
|
+
/** Full path to the CLI binary, if resolved */
|
|
957
|
+
cliPath?: string;
|
|
958
|
+
/** Error message when healthy is false */
|
|
959
|
+
error?: string;
|
|
960
|
+
/** Detected billing mode(s) available for this adapter */
|
|
961
|
+
detectedBillingModes?: BillingMode[];
|
|
962
|
+
/** Whether the CLI supports headless/non-interactive mode */
|
|
963
|
+
supportsHeadless: boolean;
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Parsed result from a task execution.
|
|
967
|
+
* Normalized representation from CLI agent JSON output.
|
|
968
|
+
*/
|
|
969
|
+
interface TaskResult {
|
|
970
|
+
/** Task identifier this result belongs to */
|
|
971
|
+
taskId?: TaskId$1;
|
|
972
|
+
/** Whether the task completed successfully */
|
|
973
|
+
success: boolean;
|
|
974
|
+
/** Primary output content from the agent */
|
|
975
|
+
output: string;
|
|
976
|
+
/** Error message if the task failed */
|
|
977
|
+
error?: string;
|
|
978
|
+
/** Raw exit code from the CLI process */
|
|
979
|
+
exitCode: number;
|
|
980
|
+
/** Execution metadata */
|
|
981
|
+
metadata?: {
|
|
982
|
+
executionTime?: number;
|
|
983
|
+
tokensUsed?: TokenEstimate;
|
|
984
|
+
};
|
|
985
|
+
/**
|
|
986
|
+
* True when the dispatcher's AdapterOutputNormalizer exhausted all
|
|
987
|
+
* normalization strategies without extracting parseable YAML.
|
|
988
|
+
* Authoritative signal for the 'adapter-format' root cause category (story 53-10).
|
|
989
|
+
* Optional — existing callers without the field continue to compile unchanged.
|
|
990
|
+
*/
|
|
991
|
+
adapterError?: boolean;
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Token usage estimate for budget tracking.
|
|
995
|
+
*/
|
|
996
|
+
interface TokenEstimate {
|
|
997
|
+
/** Estimated input tokens */
|
|
998
|
+
input: number;
|
|
999
|
+
/** Estimated output tokens */
|
|
1000
|
+
output: number;
|
|
1001
|
+
/** Total token estimate */
|
|
1002
|
+
total: number;
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Request input for plan generation.
|
|
1006
|
+
*/
|
|
1007
|
+
interface PlanRequest {
|
|
1008
|
+
/** High-level goal or description of work to plan */
|
|
1009
|
+
goal: string;
|
|
1010
|
+
/** Additional context for the planning agent */
|
|
1011
|
+
context?: string;
|
|
1012
|
+
/** Maximum number of tasks to generate */
|
|
1013
|
+
maxTasks?: number;
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Parsed result from a plan generation invocation.
|
|
1017
|
+
*/
|
|
1018
|
+
interface PlanParseResult {
|
|
1019
|
+
/** Whether plan generation succeeded */
|
|
1020
|
+
success: boolean;
|
|
1021
|
+
/** Parsed list of planned task descriptions */
|
|
1022
|
+
tasks: PlannedTask[];
|
|
1023
|
+
/** Error message if plan generation failed */
|
|
1024
|
+
error?: string;
|
|
1025
|
+
/** Raw output for debugging */
|
|
1026
|
+
rawOutput?: string;
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* A single task entry in a generated plan.
|
|
1030
|
+
*/
|
|
1031
|
+
interface PlannedTask {
|
|
1032
|
+
/** Task title */
|
|
1033
|
+
title: string;
|
|
1034
|
+
/** Detailed description */
|
|
1035
|
+
description: string;
|
|
1036
|
+
/** Estimated complexity (1-10) */
|
|
1037
|
+
complexity?: number;
|
|
1038
|
+
/** Other task titles this task depends on */
|
|
1039
|
+
dependencies?: string[];
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Result from a single adapter discovery attempt.
|
|
1043
|
+
*/
|
|
1044
|
+
interface AdapterDiscoveryResult {
|
|
1045
|
+
/** Adapter id that was tried */
|
|
1046
|
+
adapterId: AgentId;
|
|
1047
|
+
/** Display name of the adapter */
|
|
1048
|
+
displayName: string;
|
|
1049
|
+
/** Health check result */
|
|
1050
|
+
healthResult: AdapterHealthResult;
|
|
1051
|
+
/** Whether the adapter was registered (healthy) */
|
|
1052
|
+
registered: boolean;
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Summary result from discoverAndRegister().
|
|
1056
|
+
*/
|
|
1057
|
+
interface DiscoveryReport {
|
|
1058
|
+
/** Number of adapters successfully registered */
|
|
1059
|
+
registeredCount: number;
|
|
1060
|
+
/** Number of adapters that failed health checks */
|
|
1061
|
+
failedCount: number;
|
|
1062
|
+
/** Per-adapter detail results */
|
|
1063
|
+
results: AdapterDiscoveryResult[];
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
//#endregion
|
|
1067
|
+
//#region packages/core/dist/adapters/worker-adapter.d.ts
|
|
1068
|
+
//# sourceMappingURL=types.d.ts.map
|
|
1069
|
+
/**
|
|
1070
|
+
* WorkerAdapter — the interface every CLI agent adapter must implement.
|
|
1071
|
+
*
|
|
1072
|
+
* Adapters are responsible for:
|
|
1073
|
+
* 1. Verifying their CLI binary is installed and responsive (healthCheck)
|
|
1074
|
+
* 2. Constructing the spawn command to execute a task (buildCommand)
|
|
1075
|
+
* 3. Constructing the spawn command for plan generation (buildPlanningCommand)
|
|
1076
|
+
* 4. Parsing task result output from the CLI (parseOutput)
|
|
1077
|
+
* 5. Parsing plan result output from the CLI (parsePlanOutput)
|
|
1078
|
+
* 6. Estimating token usage for budget tracking (estimateTokens)
|
|
1079
|
+
* 7. Reporting their capabilities for routing decisions (getCapabilities)
|
|
1080
|
+
*/
|
|
1081
|
+
interface WorkerAdapter {
|
|
1082
|
+
/**
|
|
1083
|
+
* Unique identifier for this adapter type.
|
|
1084
|
+
* Used as the Map key in AdapterRegistry.
|
|
1085
|
+
* @example "claude-code"
|
|
1086
|
+
*/
|
|
1087
|
+
readonly id: AgentId;
|
|
1088
|
+
/**
|
|
1089
|
+
* Human-readable display name for the adapter.
|
|
1090
|
+
* @example "Claude Code"
|
|
1091
|
+
*/
|
|
1092
|
+
readonly displayName: string;
|
|
1093
|
+
/**
|
|
1094
|
+
* Semantic version of this adapter implementation.
|
|
1095
|
+
* @example "1.0.0"
|
|
1096
|
+
*/
|
|
1097
|
+
readonly adapterVersion: string;
|
|
1098
|
+
/**
|
|
1099
|
+
* Verify that the underlying CLI binary is installed, accessible, and
|
|
1100
|
+
* able to respond in headless/non-interactive mode.
|
|
1101
|
+
*
|
|
1102
|
+
* This method must NOT throw — failures should be captured in the returned
|
|
1103
|
+
* AdapterHealthResult.
|
|
1104
|
+
*
|
|
1105
|
+
* @returns A promise resolving to health check details
|
|
1106
|
+
*
|
|
1107
|
+
* @example
|
|
1108
|
+
* ```typescript
|
|
1109
|
+
* const result = await adapter.healthCheck()
|
|
1110
|
+
* if (!result.healthy) console.error(result.error)
|
|
1111
|
+
* ```
|
|
1112
|
+
*/
|
|
1113
|
+
healthCheck(): Promise<AdapterHealthResult>;
|
|
1114
|
+
/**
|
|
1115
|
+
* Generate the spawn command to execute a coding task.
|
|
1116
|
+
*
|
|
1117
|
+
* The returned SpawnCommand must set `cwd` to options.worktreePath so the
|
|
1118
|
+
* CLI agent operates in the correct git worktree (NFR10).
|
|
1119
|
+
*
|
|
1120
|
+
* @param prompt Prompt or description of the task to execute
|
|
1121
|
+
* @param options Per-invocation execution options
|
|
1122
|
+
* @returns SpawnCommand ready to be executed by the orchestrator
|
|
1123
|
+
*
|
|
1124
|
+
* @example
|
|
1125
|
+
* ```typescript
|
|
1126
|
+
* const cmd = adapter.buildCommand('Fix the failing tests', { worktreePath: '/tmp/wt', billingMode: 'api' })
|
|
1127
|
+
* // spawn(cmd.binary, cmd.args, { cwd: cmd.cwd, env: { ...process.env, ...cmd.env } })
|
|
1128
|
+
* ```
|
|
1129
|
+
*/
|
|
1130
|
+
buildCommand(prompt: string, options: AdapterOptions): SpawnCommand;
|
|
1131
|
+
/**
|
|
1132
|
+
* Generate the spawn command to invoke the CLI agent for plan generation.
|
|
1133
|
+
*
|
|
1134
|
+
* @param request Plan request with goal and context
|
|
1135
|
+
* @param options Per-invocation execution options
|
|
1136
|
+
* @returns SpawnCommand for the planning invocation
|
|
1137
|
+
*/
|
|
1138
|
+
buildPlanningCommand(request: PlanRequest, options: AdapterOptions): SpawnCommand;
|
|
1139
|
+
/**
|
|
1140
|
+
* Parse the raw CLI process output into a normalized TaskResult.
|
|
1141
|
+
*
|
|
1142
|
+
* This method must handle all output variations including:
|
|
1143
|
+
* - Valid JSON stdout
|
|
1144
|
+
* - Non-JSON stdout (fallback)
|
|
1145
|
+
* - Non-zero exit codes
|
|
1146
|
+
* - Combined stdout + stderr
|
|
1147
|
+
*
|
|
1148
|
+
* @param stdout Standard output captured from the CLI process
|
|
1149
|
+
* @param stderr Standard error captured from the CLI process
|
|
1150
|
+
* @param exitCode Exit code from the CLI process
|
|
1151
|
+
* @returns Normalized TaskResult
|
|
1152
|
+
*/
|
|
1153
|
+
parseOutput(stdout: string, stderr: string, exitCode: number): TaskResult;
|
|
1154
|
+
/**
|
|
1155
|
+
* Parse the raw CLI output from a planning invocation into a PlanParseResult.
|
|
1156
|
+
*
|
|
1157
|
+
* @param stdout Standard output from the planning invocation
|
|
1158
|
+
* @param stderr Standard error from the planning invocation
|
|
1159
|
+
* @param exitCode Exit code from the planning invocation
|
|
1160
|
+
* @returns Parsed plan result
|
|
1161
|
+
*/
|
|
1162
|
+
parsePlanOutput(stdout: string, stderr: string, exitCode: number): PlanParseResult;
|
|
1163
|
+
/**
|
|
1164
|
+
* Estimate the token count for a given prompt string.
|
|
1165
|
+
*
|
|
1166
|
+
* Used for pre-execution budget checks. Implementations may use heuristics
|
|
1167
|
+
* (e.g., character count / 3) when exact tokenizers are unavailable.
|
|
1168
|
+
*
|
|
1169
|
+
* @param prompt The prompt text to estimate
|
|
1170
|
+
* @returns TokenEstimate with input, output, and total projections
|
|
1171
|
+
*
|
|
1172
|
+
* @example
|
|
1173
|
+
* ```typescript
|
|
1174
|
+
* const estimate = adapter.estimateTokens('Fix the failing tests in auth.ts')
|
|
1175
|
+
* if (estimate.total > budgetCap) throw new BudgetExceededError(...)
|
|
1176
|
+
* ```
|
|
1177
|
+
*/
|
|
1178
|
+
estimateTokens(prompt: string): TokenEstimate;
|
|
1179
|
+
/**
|
|
1180
|
+
* Return the capabilities of this adapter's underlying CLI agent.
|
|
1181
|
+
*
|
|
1182
|
+
* The returned object is used by the orchestrator for:
|
|
1183
|
+
* - Routing decisions (which adapter handles which task type)
|
|
1184
|
+
* - Plan generation eligibility
|
|
1185
|
+
* - Budget mode selection
|
|
1186
|
+
*
|
|
1187
|
+
* @returns AdapterCapabilities for this agent
|
|
1188
|
+
*/
|
|
1189
|
+
getCapabilities(): AdapterCapabilities;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
//#endregion
|
|
1193
|
+
//#region packages/core/dist/adapters/adapter-registry.d.ts
|
|
1194
|
+
/**
|
|
1195
|
+
* AdapterRegistry — public interface for the adapter registry.
|
|
1196
|
+
*
|
|
1197
|
+
* Defined here (not in types.ts) to avoid a circular dependency between
|
|
1198
|
+
* types.ts and worker-adapter.ts. AdapterRegistry references WorkerAdapter,
|
|
1199
|
+
* which is defined in this file, so placing it here keeps the dep graph acyclic.
|
|
1200
|
+
*
|
|
1201
|
+
* The concrete implementation (AdapterRegistry class) lives in the monolith
|
|
1202
|
+
* until Epic 41. This interface exposes only the public method surface.
|
|
1203
|
+
*
|
|
1204
|
+
* Usage:
|
|
1205
|
+
* ```typescript
|
|
1206
|
+
* const registry: AdapterRegistry = new ConcreteAdapterRegistry()
|
|
1207
|
+
* const report = await registry.discoverAndRegister()
|
|
1208
|
+
* const claude = registry.get('claude-code')
|
|
1209
|
+
* ```
|
|
1210
|
+
*/
|
|
1211
|
+
/**
|
|
1212
|
+
* AdapterRegistry manages the lifecycle of WorkerAdapter instances.
|
|
1213
|
+
*
|
|
1214
|
+
* Usage:
|
|
1215
|
+
* ```typescript
|
|
1216
|
+
* const registry = new AdapterRegistry()
|
|
1217
|
+
* const report = await registry.discoverAndRegister()
|
|
1218
|
+
* const claude = registry.get('claude-code')
|
|
1219
|
+
* ```
|
|
1220
|
+
*/
|
|
1221
|
+
declare class AdapterRegistry {
|
|
1222
|
+
private readonly _adapters;
|
|
1223
|
+
/**
|
|
1224
|
+
* Register an adapter by its id.
|
|
1225
|
+
* Overwrites any existing adapter with the same id.
|
|
1226
|
+
*/
|
|
1227
|
+
register(adapter: WorkerAdapter): void;
|
|
1228
|
+
/**
|
|
1229
|
+
* Retrieve a registered adapter by id.
|
|
1230
|
+
* @returns The adapter, or undefined if not registered
|
|
1231
|
+
*/
|
|
1232
|
+
get(id: AgentId): WorkerAdapter | undefined;
|
|
1233
|
+
/**
|
|
1234
|
+
* Return all registered adapters as an array.
|
|
1235
|
+
*/
|
|
1236
|
+
getAll(): WorkerAdapter[];
|
|
1237
|
+
/**
|
|
1238
|
+
* Return all registered adapters that support plan generation.
|
|
1239
|
+
*/
|
|
1240
|
+
getPlanningCapable(): WorkerAdapter[];
|
|
1241
|
+
/**
|
|
1242
|
+
* Instantiate all built-in adapters, run health checks sequentially,
|
|
1243
|
+
* and register those that pass.
|
|
1244
|
+
*
|
|
1245
|
+
* Failed adapters are included in the report but do NOT prevent startup.
|
|
1246
|
+
*
|
|
1247
|
+
* @returns Discovery report with per-adapter results
|
|
1248
|
+
*/
|
|
1249
|
+
discoverAndRegister(): Promise<DiscoveryReport>;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
//#endregion
|
|
1253
|
+
//#region packages/core/dist/adapters/claude-adapter.d.ts
|
|
1254
|
+
//# sourceMappingURL=adapter-registry.d.ts.map
|
|
1255
|
+
/**
|
|
1256
|
+
* Adapter for the Claude Code CLI agent.
|
|
1257
|
+
*
|
|
1258
|
+
* Capabilities: JSON output, streaming, both billing modes, plan generation.
|
|
1259
|
+
* Health check: runs `claude --version` to verify install.
|
|
1260
|
+
* Billing detection: detects subscription vs API via version output or env.
|
|
1261
|
+
*/
|
|
1262
|
+
declare class ClaudeCodeAdapter implements WorkerAdapter {
|
|
1263
|
+
readonly id: AgentId;
|
|
1264
|
+
readonly displayName = "Claude Code";
|
|
1265
|
+
readonly adapterVersion = "1.0.0";
|
|
1266
|
+
private readonly _logger;
|
|
1267
|
+
constructor(logger?: ILogger);
|
|
1268
|
+
/**
|
|
1269
|
+
* Verify the `claude` binary is installed and responsive.
|
|
1270
|
+
* Detects subscription vs API billing mode.
|
|
1271
|
+
*/
|
|
1272
|
+
healthCheck(): Promise<AdapterHealthResult>;
|
|
1273
|
+
/**
|
|
1274
|
+
* Build spawn command for a coding task.
|
|
1275
|
+
* Uses: `claude -p --model <model> --dangerously-skip-permissions --system-prompt <minimal>`
|
|
1276
|
+
* Prompt is delivered via stdin (not CLI arg) to avoid E2BIG on large prompts.
|
|
1277
|
+
*/
|
|
1278
|
+
buildCommand(prompt: string, options: AdapterOptions): SpawnCommand;
|
|
1279
|
+
/**
|
|
1280
|
+
* Build spawn command for plan generation.
|
|
1281
|
+
*/
|
|
1282
|
+
buildPlanningCommand(request: PlanRequest, options: AdapterOptions): SpawnCommand;
|
|
1283
|
+
/**
|
|
1284
|
+
* Parse Claude Code JSON output into a TaskResult.
|
|
1285
|
+
*/
|
|
1286
|
+
parseOutput(stdout: string, stderr: string, exitCode: number): TaskResult;
|
|
1287
|
+
/**
|
|
1288
|
+
* Parse Claude plan generation output.
|
|
1289
|
+
*/
|
|
1290
|
+
parsePlanOutput(stdout: string, stderr: string, exitCode: number): PlanParseResult;
|
|
1291
|
+
/**
|
|
1292
|
+
* Estimate token count using character-based heuristic.
|
|
1293
|
+
*/
|
|
1294
|
+
estimateTokens(prompt: string): TokenEstimate;
|
|
1295
|
+
/**
|
|
1296
|
+
* Return Claude Code capabilities.
|
|
1297
|
+
*/
|
|
1298
|
+
getCapabilities(): AdapterCapabilities;
|
|
1299
|
+
private _detectBillingModes;
|
|
1300
|
+
private _buildPlanningPrompt;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
//#endregion
|
|
1304
|
+
//#region packages/core/dist/adapters/codex-adapter.d.ts
|
|
1305
|
+
//# sourceMappingURL=claude-adapter.d.ts.map
|
|
1306
|
+
/**
|
|
1307
|
+
* Adapter for the OpenAI Codex CLI agent.
|
|
1308
|
+
*
|
|
1309
|
+
* Codex CLI uses stdin for the prompt and outputs JSON when --json flag is used.
|
|
1310
|
+
* Codex supports subscription billing (via `codex login`) and API key billing.
|
|
1311
|
+
*/
|
|
1312
|
+
declare class CodexCLIAdapter implements WorkerAdapter {
|
|
1313
|
+
readonly id: AgentId;
|
|
1314
|
+
readonly displayName = "Codex CLI";
|
|
1315
|
+
readonly adapterVersion = "1.0.0";
|
|
1316
|
+
private readonly _logger;
|
|
1317
|
+
constructor(logger?: ILogger);
|
|
1318
|
+
/**
|
|
1319
|
+
* Verify the `codex` binary is installed and responsive.
|
|
1320
|
+
*/
|
|
1321
|
+
healthCheck(): Promise<AdapterHealthResult>;
|
|
1322
|
+
/**
|
|
1323
|
+
* Build spawn command for a coding task.
|
|
1324
|
+
* Uses: `codex exec` with prompt delivered via stdin.
|
|
1325
|
+
*
|
|
1326
|
+
* Do NOT use --json: it produces a JSONL event stream that prevents
|
|
1327
|
+
* extractYamlBlock from finding the structured result block in stdout.
|
|
1328
|
+
* Raw text output is required (same rationale as Claude adapter).
|
|
1329
|
+
*/
|
|
1330
|
+
buildCommand(prompt: string, options: AdapterOptions): SpawnCommand;
|
|
1331
|
+
/**
|
|
1332
|
+
* Build spawn command for plan generation.
|
|
1333
|
+
* Uses codex exec with a JSON plan generation prompt via stdin.
|
|
1334
|
+
*/
|
|
1335
|
+
buildPlanningCommand(request: PlanRequest, options: AdapterOptions): SpawnCommand;
|
|
1336
|
+
/**
|
|
1337
|
+
* Parse Codex CLI output into a TaskResult.
|
|
1338
|
+
*
|
|
1339
|
+
* With raw text mode (no --json), stdout is the agent's direct output.
|
|
1340
|
+
* YAML extraction happens in the dispatcher's extractYamlBlock, not here.
|
|
1341
|
+
*/
|
|
1342
|
+
parseOutput(stdout: string, stderr: string, exitCode: number): TaskResult;
|
|
1343
|
+
/**
|
|
1344
|
+
* Parse Codex plan generation output.
|
|
1345
|
+
*/
|
|
1346
|
+
parsePlanOutput(stdout: string, stderr: string, exitCode: number): PlanParseResult;
|
|
1347
|
+
/**
|
|
1348
|
+
* Estimate token count using character-based heuristic.
|
|
1349
|
+
*/
|
|
1350
|
+
estimateTokens(prompt: string): TokenEstimate;
|
|
1351
|
+
/**
|
|
1352
|
+
* Return Codex CLI capabilities.
|
|
1353
|
+
*/
|
|
1354
|
+
getCapabilities(): AdapterCapabilities;
|
|
1355
|
+
private _buildPlanningPrompt;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
//#endregion
|
|
1359
|
+
//#region packages/core/dist/adapters/gemini-adapter.d.ts
|
|
1360
|
+
//# sourceMappingURL=codex-adapter.d.ts.map
|
|
1361
|
+
/**
|
|
1362
|
+
* Adapter for the Google Gemini CLI agent.
|
|
1363
|
+
*
|
|
1364
|
+
* Gemini CLI follows similar patterns to Claude Code: prompt via `-p` flag,
|
|
1365
|
+
* JSON output via `--output-format json`, and model via `--model`.
|
|
1366
|
+
*/
|
|
1367
|
+
declare class GeminiCLIAdapter implements WorkerAdapter {
|
|
1368
|
+
readonly id: AgentId;
|
|
1369
|
+
readonly displayName = "Gemini CLI";
|
|
1370
|
+
readonly adapterVersion = "1.0.0";
|
|
1371
|
+
private readonly _logger;
|
|
1372
|
+
constructor(logger?: ILogger);
|
|
1373
|
+
/**
|
|
1374
|
+
* Verify the `gemini` binary is installed and responsive.
|
|
1375
|
+
* Detects subscription vs API billing mode.
|
|
1376
|
+
*/
|
|
1377
|
+
healthCheck(): Promise<AdapterHealthResult>;
|
|
1378
|
+
/**
|
|
1379
|
+
* Build spawn command for a coding task.
|
|
1380
|
+
* Uses: `gemini -p <prompt> --output-format json --model <model>`
|
|
1381
|
+
*/
|
|
1382
|
+
buildCommand(prompt: string, options: AdapterOptions): SpawnCommand;
|
|
1383
|
+
/**
|
|
1384
|
+
* Build spawn command for plan generation.
|
|
1385
|
+
*/
|
|
1386
|
+
buildPlanningCommand(request: PlanRequest, options: AdapterOptions): SpawnCommand;
|
|
1387
|
+
/**
|
|
1388
|
+
* Parse Gemini CLI JSON output into a TaskResult.
|
|
1389
|
+
*/
|
|
1390
|
+
parseOutput(stdout: string, stderr: string, exitCode: number): TaskResult;
|
|
1391
|
+
/**
|
|
1392
|
+
* Parse Gemini plan generation output.
|
|
1393
|
+
*/
|
|
1394
|
+
parsePlanOutput(stdout: string, stderr: string, exitCode: number): PlanParseResult;
|
|
1395
|
+
/**
|
|
1396
|
+
* Estimate token count using character-based heuristic.
|
|
1397
|
+
*/
|
|
1398
|
+
estimateTokens(prompt: string): TokenEstimate;
|
|
1399
|
+
/**
|
|
1400
|
+
* Return Gemini CLI capabilities.
|
|
1401
|
+
*/
|
|
1402
|
+
getCapabilities(): AdapterCapabilities;
|
|
1403
|
+
private _detectBillingModes;
|
|
1404
|
+
private _buildPlanningPrompt;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
//#endregion
|
|
1408
|
+
//#region packages/core/dist/monitor/recommendation-types.d.ts
|
|
1409
|
+
//# sourceMappingURL=gemini-adapter.d.ts.map
|
|
1410
|
+
/**
|
|
1411
|
+
* Recommendation Types — data structures for the routing recommendations engine.
|
|
1412
|
+
* Migrated to @substrate-ai/core (Story 41-7)
|
|
1413
|
+
*/
|
|
1414
|
+
type ConfidenceLevel = 'low' | 'medium' | 'high';
|
|
1415
|
+
interface Recommendation {
|
|
1416
|
+
task_type: string;
|
|
1417
|
+
current_agent: string;
|
|
1418
|
+
recommended_agent: string;
|
|
1419
|
+
reason: string;
|
|
1420
|
+
confidence: ConfidenceLevel;
|
|
1421
|
+
current_success_rate: number;
|
|
1422
|
+
recommended_success_rate: number;
|
|
1423
|
+
current_avg_tokens: number;
|
|
1424
|
+
recommended_avg_tokens: number;
|
|
1425
|
+
improvement_percentage: number;
|
|
1426
|
+
sample_size_current: number;
|
|
1427
|
+
sample_size_recommended: number;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
//#endregion
|
|
1431
|
+
export { AdapterDiscoveryResult, AdapterRegistry, AdtError, ClaudeCodeAdapter, CodexCLIAdapter, ConfigError, ConfigIncompatibleFormatError, CoreEvents, DatabaseAdapter, DiscoveryReport, GeminiCLIAdapter, Recommendation, TypedEventBus };
|
|
1432
|
+
//# sourceMappingURL=index-c924O9mj.d.ts.map
|