@rowan-agent/agent 0.19.2 → 0.20.0

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/index.d.ts CHANGED
@@ -1,60 +1,53 @@
1
1
  import * as _rowan_agent_models from '@rowan-agent/models';
2
- import { LlmContentPart, ModelRef, ContentBlock, ScopeRef, ToolKind, ToolAnnotations, ToolCallStatus, ToolProgress, ToolCallContent, ToolCallLocation, JsonValue as JsonValue$1, JsonObject as JsonObject$1, ModelConfig, StreamFn, ThinkingLevel, ToolCall as ToolCall$1, ToolCallUpdate } from '@rowan-agent/models';
2
+ import { ContentBlock, LlmContentPart, ModelRef, ScopeRef, ToolCallStatus, JsonValue as JsonValue$1, ToolProgress, ToolCallContent, ToolCallLocation, JsonObject as JsonObject$1, ToolKind, ModelConfig, StreamFn, ToolAnnotations, ThinkingLevel, ToolCall as ToolCall$1, ToolCallUpdate } from '@rowan-agent/models';
3
3
  export { ModelConfig, ModelRef, ProviderCallContext, ProviderConfig, ProviderModelConfig, ProviderStreamFn, ScopeRef, StreamFn, ThinkingLevel, ToolAnnotations, ToolCall, ToolCallContent, ToolCallLocation, ToolCallOptions, ToolCallOutcome, ToolCallStatus, ToolCallUpdate, ToolDefinitionSummary, ToolKind, ToolProgress } from '@rowan-agent/models';
4
4
  import Type from 'typebox';
5
5
 
6
- type AgentMessage = {
7
- id: string;
8
- role: "system" | "user" | "assistant" | "tool";
9
- content: string | LlmContentPart[];
10
- createdAt: string;
11
- metadata?: Record<string, unknown> & {
12
- phase?: string;
13
- };
14
- };
15
- type Skill = {
16
- name: string;
17
- description: string;
18
- /** Absolute path to the SKILL.md file */
19
- filePath: string;
20
- /** Directory containing the SKILL.md file */
21
- baseDir: string;
22
- /** Full body content of the SKILL.md (after frontmatter) */
23
- content: string;
24
- /** Do not automatically inject this Skill into the model Context. */
25
- disableAutoInvocation?: boolean;
26
- /** Do not expose this Skill to direct user invocation. */
27
- disableImplicitInvocation?: boolean;
28
- /** @deprecated Use disableAutoInvocation; kept only for old in-memory callers during cutover. */
29
- disableModelInvocation?: boolean;
6
+ type ModelInvokeOutput = {
7
+ text: string;
8
+ contentBlocks: ContentBlock[];
9
+ toolCalls: ToolCall[];
10
+ stopReason?: string;
30
11
  };
31
- type Outcome$1 = {
32
- id: string;
33
- message: string;
34
- /** Publish this outcome's message as an assistant message before completing the run. */
35
- display?: boolean;
12
+ /** Snapshot of phase-level context for restore */
13
+ type PhaseContextSnapshot = {
14
+ systemPrompt: string;
15
+ messages: AgentMessage[];
16
+ currentPhase: string;
17
+ availablePhases: string[];
18
+ turnNumber: number;
36
19
  payload?: unknown;
37
- toolResults?: Array<{
38
- toolCallId: string;
39
- toolName: string;
40
- ok: boolean;
41
- content: unknown;
42
- error?: string;
43
- }>;
44
20
  };
45
- type ToolCall = {
46
- id: string;
47
- name: string;
48
- args: unknown;
21
+ /** Execution capabilities for a phase — operates on PhaseContext. */
22
+ type PhaseExecution = {
23
+ snapshot(): PhaseContextSnapshot;
24
+ restore(snapshot: PhaseContextSnapshot): void;
25
+ invokeModel(context: PhaseContext, options?: {
26
+ output?: "reply" | "internal";
27
+ }): Promise<ModelInvokeOutput>;
28
+ reportStatus(status: PhaseStatus): Promise<void>;
29
+ executeTool(context: AgentContext, toolCall: ToolCall): Promise<ToolResult>;
30
+ executeTools(context: AgentContext, toolCalls: readonly ToolCall[], contentBlocks?: readonly ContentBlock[]): Promise<readonly ToolResult[]>;
31
+ interaction: RunInteractionDriver;
32
+ /** Message lifecycle manager for streaming updates from programmatic phases */
33
+ messages: PhaseMessageManager;
49
34
  };
50
- type ToolResult = {
51
- toolCallId: string;
52
- toolName: string;
53
- ok: boolean;
54
- content: unknown;
55
- error?: string;
56
- structuredContent?: unknown;
57
- isError?: boolean;
35
+ /** Message lifecycle manager for streaming updates */
36
+ type PhaseMessageManager = {
37
+ /** Get all visible messages in the transcript */
38
+ visible(): AgentMessage[];
39
+ /** Reserve the eventual message identity before stream deltas arrive. */
40
+ reserve(role: "assistant" | "tool", metadata?: Record<string, unknown>): string;
41
+ /** Start a new message stream, returns message id */
42
+ start(role: "assistant" | "tool", content: AgentMessage["content"], metadata?: Record<string, unknown>): string;
43
+ /** Stream a text delta */
44
+ update(messageId: string, delta: string): Promise<void>;
45
+ /** Replace the active message content with model-native content parts */
46
+ replaceContent(messageId: string, content: string | LlmContentPart[]): void;
47
+ /** End the message stream, appends to transcript */
48
+ end(messageId: string): Promise<void>;
49
+ /** Drop an unstarted stream that produced no content. */
50
+ discard(messageId: string): void;
58
51
  };
59
52
 
60
53
  type PhaseRegistrySelection = Readonly<{
@@ -161,261 +154,45 @@ declare class ResourceRegistry {
161
154
  private nextRevision;
162
155
  }
163
156
 
164
- type ModelInvokeOutput = {
165
- text: string;
166
- contentBlocks: ContentBlock[];
167
- toolCalls: ToolCall[];
168
- stopReason?: string;
169
- };
170
- /** Snapshot of phase-level context for restore */
171
- type PhaseContextSnapshot = {
172
- systemPrompt: string;
173
- messages: AgentMessage[];
174
- currentPhase: string;
175
- availablePhases: string[];
176
- turnNumber: number;
177
- payload?: unknown;
178
- };
179
- /** Execution capabilities for a phase — operates on PhaseContext. */
180
- type PhaseExecution = {
181
- snapshot(): PhaseContextSnapshot;
182
- restore(snapshot: PhaseContextSnapshot): void;
183
- invokeModel(context: PhaseContext, options?: {
184
- output?: "reply" | "internal";
185
- }): Promise<ModelInvokeOutput>;
186
- reportStatus(status: PhaseStatus): Promise<void>;
187
- executeTool(context: AgentContext, toolCall: ToolCall): Promise<ToolResult>;
188
- executeTools(context: AgentContext, toolCalls: readonly ToolCall[], contentBlocks?: readonly ContentBlock[]): Promise<readonly ToolResult[]>;
189
- interaction: RunInteractionDriver;
190
- /** Message lifecycle manager for streaming updates from programmatic phases */
191
- messages: PhaseMessageManager;
192
- };
193
- /** Message lifecycle manager for streaming updates */
194
- type PhaseMessageManager = {
195
- /** Get all visible messages in the transcript */
196
- visible(): AgentMessage[];
197
- /** Reserve the eventual message identity before stream deltas arrive. */
198
- reserve(role: "assistant" | "tool", metadata?: Record<string, unknown>): string;
199
- /** Start a new message stream, returns message id */
200
- start(role: "assistant" | "tool", content: AgentMessage["content"], metadata?: Record<string, unknown>): string;
201
- /** Stream a text delta */
202
- update(messageId: string, delta: string): Promise<void>;
203
- /** Replace the active message content with model-native content parts */
204
- replaceContent(messageId: string, content: string | LlmContentPart[]): void;
205
- /** End the message stream, appends to transcript */
206
- end(messageId: string): Promise<void>;
207
- /** Drop an unstarted stream that produced no content. */
208
- discard(messageId: string): void;
209
- };
210
-
211
- type HostContribution = {
212
- readonly kind: string;
213
- readonly id: string;
214
- } & {
215
- readonly [key: string]: JsonValue;
216
- };
217
- interface ExtensionStateStore {
218
- get(key: string): Promise<JsonValue | undefined>;
219
- set(key: string, value: JsonValue): Promise<void>;
220
- delete(key: string): Promise<void>;
221
- }
222
- interface ExtensionHost {
223
- getConfig(extensionId: string, scope?: ScopeRef): Promise<JsonObject | null> | JsonObject | null;
224
- onConfigChanged?(listener: (extensionId: string, scope: ScopeRef) => void): (() => void) | void;
225
- getAgentState(extensionId: string, agentId: string, key: string): Promise<JsonValue | undefined> | JsonValue | undefined;
226
- setAgentState(extensionId: string, agentId: string, key: string, value: JsonValue): Promise<void> | void;
227
- deleteAgentState(extensionId: string, agentId: string, key: string): Promise<void> | void;
228
- getGlobalState(extensionId: string, key: string): Promise<JsonValue | undefined> | JsonValue | undefined;
229
- setGlobalState(extensionId: string, key: string, value: JsonValue): Promise<void> | void;
230
- deleteGlobalState(extensionId: string, key: string): Promise<void> | void;
231
- }
232
- type ExtensionToolContribution = {
233
- kind: "tool";
234
- name: string;
235
- description: string;
236
- };
237
- type ExtensionCapabilityContribution = ExtensionToolContribution;
238
- type ExtensionCapability = {
239
- extensionId: string;
240
- kind: "tool";
241
- name: string;
242
- description: string;
243
- };
244
- interface SourceInfo {
245
- source: string;
246
- baseDir?: string;
247
- displayName?: string;
248
- }
249
- /** Register a Phase by directory path or Phase object; PHASE.md and direct child Skills are loaded atomically when a path is supplied. */
250
- type PhaseRegistration = string | Phase;
251
157
  /**
252
- * Tool definition for registering LLM-callable tools via `api.tools.register()`.
158
+ * EventBus — simple pub/sub for inter-extension communication.
159
+ *
160
+ * Extensions can emit and subscribe to arbitrary events via `api.events`.
161
+ * This allows extensions to coordinate without direct coupling.
253
162
  *
254
163
  * @example
255
164
  * ```typescript
256
- * api.tools.register({
257
- * name: "search_docs",
258
- * description: "Search documentation",
259
- * parameters: { type: "object", properties: { query: { type: "string" } } },
260
- * execute: async (args, ctx) => {
261
- * return { content: [{ type: "text", text: "result" }] };
262
- * },
165
+ * // Extension A
166
+ * api.events.on("my-plugin:ready", (data) => {
167
+ * console.log("Plugin ready:", data);
263
168
  * });
169
+ *
170
+ * // Extension B
171
+ * api.events.emit("my-plugin:ready", { version: "1.0" });
264
172
  * ```
265
173
  */
266
- interface ToolDefinition {
267
- /** Tool name (used in LLM tool calls) */
268
- name: string;
269
- /** Description for LLM */
270
- description: string;
271
- /** Parameter schema (JSON Schema) */
272
- parameters: Record<string, unknown>;
273
- /** Optional: one-line snippet shown in the system prompt tool list */
274
- promptSnippet?: string;
275
- /** Optional: additional guidelines appended to system prompt */
276
- promptGuidelines?: string[];
277
- kind?: ToolKind;
278
- annotations?: ToolAnnotations;
279
- _meta?: JsonObject;
280
- present?: (call: {
281
- status: ToolCallStatus;
282
- args: JsonValue;
283
- progress?: ToolProgress;
284
- result?: ToolExecutionResult;
285
- }) => {
286
- title?: string;
287
- content?: ToolCallContent[];
288
- locations?: ToolCallLocation[];
289
- _meta?: JsonObject;
290
- } | undefined | void | Promise<{
291
- title?: string;
292
- content?: ToolCallContent[];
293
- locations?: ToolCallLocation[];
294
- _meta?: JsonObject;
295
- } | undefined | void>;
296
- /** Execute the tool */
297
- execute: (args: unknown, context: ToolInvocationContext, signal?: AbortSignal) => Promise<ToolExecutionResult>;
298
- /** Optional: per-tool execution mode override */
299
- executionMode?: "sequential" | "parallel";
174
+ type Listener = (...args: unknown[]) => void;
175
+ interface EventBus {
176
+ /** Subscribe to an event. Returns unsubscribe function. */
177
+ on(event: string, listener: Listener): () => void;
178
+ /** Emit an event to all subscribers. */
179
+ emit(event: string, ...args: unknown[]): void;
180
+ /** Remove all listeners for an event, or all listeners if no event specified. */
181
+ off(event?: string): void;
182
+ /** Check if there are listeners for an event. */
183
+ has(event: string): boolean;
184
+ /** Get listener count for an event. */
185
+ count(event: string): number;
300
186
  }
301
187
 
302
188
  /**
303
- * Registered tool with source metadata.
189
+ * @module extensions/context
190
+ *
191
+ * Extension context types — runtime state and phase execution context.
192
+ *
193
+ * For ExtensionAPI and createExtensionAPI, see ./api.ts
304
194
  */
305
- interface RegisteredTool {
306
- definition: ToolDefinition;
307
- sourceInfo: SourceInfo;
308
- }
309
- /**
310
- * Structured extension error with attribution.
311
- */
312
- interface ExtensionError {
313
- /** Path of the extension that caused the error */
314
- extensionPath: string;
315
- /** Event or operation that caused the error */
316
- event: string;
317
- /** Error message */
318
- error: string;
319
- /** Optional stack trace */
320
- stack?: string;
321
- }
322
- /** Error listener callback type. */
323
- type ExtensionErrorListener = (error: ExtensionError) => void;
324
- type ExecOptions = {
325
- /** Working directory for the command. Defaults to cwd passed to runtime. */
326
- cwd?: string;
327
- /** Environment variables to add/override. */
328
- env?: Record<string, string>;
329
- /** Timeout in milliseconds. */
330
- timeout?: number;
331
- /** AbortSignal for cancellation. */
332
- signal?: AbortSignal;
333
- };
334
- type ExecResult = {
335
- exitCode: number;
336
- stdout: string;
337
- stderr: string;
338
- };
339
- /**
340
- * Shared runtime state created by loader, used during registration and runtime.
341
- * All ExtensionAPI instances reference this shared state.
342
- *
343
- * It only owns the lifetime guard shared by captured Extension API objects.
344
- */
345
- interface ExtensionRuntime {
346
- /** Throws when this extension instance is stale after runtime replacement. */
347
- assertActive: () => void;
348
- /** Marks this extension instance as stale after runtime replacement or reload. */
349
- invalidate: (message?: string) => void;
350
- }
351
- /**
352
- * Result of loading extensions from filesystem.
353
- * The runner takes these and creates Extension tracking objects.
354
- */
355
- type LoadExtensionsResult = {
356
- extensions: LoadedExtension[];
357
- errors: Array<{
358
- path: string;
359
- error: string;
360
- }>;
361
- };
362
- /**
363
- * Pre-initialization extension form — factory + metadata.
364
- * Runner.loadExtensions() calls the factory and creates the full Extension object.
365
- */
366
- interface LoadedExtension {
367
- id?: string;
368
- path: string;
369
- name: string;
370
- factory: ExtensionFactory;
371
- manifest?: ExtensionManifest;
372
- }
373
- /** Extension manifest from package.json `rowan` field. */
374
- interface ExtensionManifest {
375
- id?: string;
376
- entry?: string;
377
- name?: string;
378
- }
379
-
380
- /**
381
- * EventBus — simple pub/sub for inter-extension communication.
382
- *
383
- * Extensions can emit and subscribe to arbitrary events via `api.events`.
384
- * This allows extensions to coordinate without direct coupling.
385
- *
386
- * @example
387
- * ```typescript
388
- * // Extension A
389
- * api.events.on("my-plugin:ready", (data) => {
390
- * console.log("Plugin ready:", data);
391
- * });
392
- *
393
- * // Extension B
394
- * api.events.emit("my-plugin:ready", { version: "1.0" });
395
- * ```
396
- */
397
- type Listener = (...args: unknown[]) => void;
398
- interface EventBus {
399
- /** Subscribe to an event. Returns unsubscribe function. */
400
- on(event: string, listener: Listener): () => void;
401
- /** Emit an event to all subscribers. */
402
- emit(event: string, ...args: unknown[]): void;
403
- /** Remove all listeners for an event, or all listeners if no event specified. */
404
- off(event?: string): void;
405
- /** Check if there are listeners for an event. */
406
- has(event: string): boolean;
407
- /** Get listener count for an event. */
408
- count(event: string): number;
409
- }
410
-
411
- /**
412
- * @module extensions/context
413
- *
414
- * Extension context types — runtime state and phase execution context.
415
- *
416
- * For ExtensionAPI and createExtensionAPI, see ./api.ts
417
- */
418
-
195
+
419
196
  /**
420
197
  * Runtime context available to extensions during event handler execution.
421
198
  *
@@ -499,107 +276,6 @@ interface ExtensionUtils {
499
276
  formatJson(value: unknown): string;
500
277
  }
501
278
 
502
- /**
503
- * Extension API object passed to extension factory function.
504
- *
505
- * @example
506
- * ```typescript
507
- * export default function(api: ExtensionAPI) {
508
- * // api provides all extension APIs
509
- * }
510
- * ```
511
- */
512
- interface ExtensionAPI {
513
- /** Hook events — subscribe or unsubscribe. */
514
- hooks: {
515
- /**
516
- * Subscribe to a hook event.
517
- *
518
- * @param eventType - Hook type, e.g. "before_tool_call"
519
- * @param handler - Hook handler, can return result to modify behavior
520
- */
521
- on<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
522
- /** Unsubscribe from a hook event. */
523
- off<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
524
- };
525
- /** Extension configuration — read own layered config or listen for changes. */
526
- config: {
527
- /** Get the extension's own effective configuration block. */
528
- get(scope?: ScopeRef): Promise<JsonObject | null>;
529
- /** Listen for configuration changes for a scope. */
530
- changed(handler: (scope: ScopeRef) => void): void;
531
- };
532
- /** Extension state — scoped to run (in-memory) or agent (durable) or global (durable). */
533
- state: {
534
- /** Run-scoped in-memory state; dropped when the Run ends. */
535
- run(runId: string): ExtensionStateStore;
536
- /** Agent-scoped durable state; persisted with the Agent record. */
537
- agent(agentId: string): ExtensionStateStore;
538
- /** Extension-scoped durable state; survives process restarts. */
539
- global(): ExtensionStateStore;
540
- };
541
- /** Tool capabilities — register and unregister custom tools. */
542
- tools: {
543
- /** Register a custom LLM-callable tool. */
544
- register(tool: ToolDefinition): void;
545
- /** Unregister a previously registered tool by name. */
546
- unregister(toolName: string): void;
547
- };
548
- /** Capability contributions — advertise tools or features to the host. */
549
- capabilities: {
550
- /** Contribute a capability to the host. Returns a disposer to remove the contribution. */
551
- contribute(contribution: ExtensionCapabilityContribution): () => void;
552
- };
553
- /** Model provider registration. */
554
- providers: {
555
- /** Register a model provider. Registering with an existing id replaces it. */
556
- register(config: _rowan_agent_models.ProviderConfig): void;
557
- /** Unregister a model provider by id. */
558
- unregister(id: string): void;
559
- };
560
- /** Phase execution capabilities — provides Phase In/Out, phase identity, phase routing, and registration. */
561
- phases: {
562
- /** Register a Phase directory bundle or Phase object. */
563
- register(phase: PhaseRegistration): Promise<void>;
564
- /** Unregister a previously registered phase by name. */
565
- unregister(phaseName: string): void;
566
- /** Phase In: get payload from previous phase */
567
- getPayload(): unknown;
568
- /** Phase Out: set payload for next phase */
569
- setPayload(payload: unknown): void;
570
- /** Phase Out: set outcome message */
571
- setMessage(message: string): void;
572
- /** Get current phase name */
573
- getCurrentPhase(): string;
574
- /** Set next phase (lower priority than PHASE.md target) */
575
- setNextPhase(phaseName: string): void;
576
- /** Get the next phase set by setNextPhase */
577
- getNextPhase(): string | undefined;
578
- /** Get the message set by setMessage */
579
- getMessage(): string | undefined;
580
- };
581
- /** Declarative host contributions. */
582
- host: {
583
- /** Contribute a declarative declaration to the host. Returns a disposer to remove the contribution. */
584
- contribute<T extends HostContribution>(contribution: T): () => void;
585
- };
586
- /** Extension manifest from package.json `rowan` field. */
587
- manifest?: ExtensionManifest;
588
- /** Utility functions. */
589
- utils: ExtensionUtils;
590
- /** Runtime context — cwd, signal, exec, message access, etc. */
591
- context: ExtensionContext;
592
- /** Shared event bus for inter-extension communication. */
593
- events: EventBus;
594
- }
595
- /**
596
- * Extension factory function.
597
- * Receives ExtensionAPI for registering hooks, phases, and providers.
598
- */
599
- type ExtensionDisposer = () => void | Promise<void>;
600
- type ExtensionFactoryResult = void | ExtensionDisposer;
601
- type ExtensionFactory = (api: ExtensionAPI) => ExtensionFactoryResult | Promise<ExtensionFactoryResult>;
602
-
603
279
  declare class InMemoryExtensionHost implements ExtensionHost {
604
280
  private readonly configs;
605
281
  private readonly agentState;
@@ -983,6 +659,7 @@ type UserInput = string | Readonly<{
983
659
  content: UserContent;
984
660
  metadata?: Metadata;
985
661
  thinkingLevel?: ThinkingLevel;
662
+ providerOptions?: JsonObject;
986
663
  }>;
987
664
  type HistorySeed = readonly Message[];
988
665
  type ContextStatus = Readonly<{
@@ -1052,10 +729,6 @@ type Tool$1 = Readonly<{
1052
729
  } | undefined | void>;
1053
730
  execute(args: JsonValue, context: ToolInvocationContext, signal: AbortSignal): Promise<ToolExecutionResult>;
1054
731
  }>;
1055
- type ContextCandidate = Readonly<{
1056
- name: string;
1057
- value: JsonValue;
1058
- }>;
1059
732
  type BeforeToolCallDecision = Readonly<{
1060
733
  allow: true;
1061
734
  }> | Readonly<{
@@ -1170,7 +843,7 @@ type RunRecord = Readonly<{
1170
843
  openInteractions?: readonly RunInteraction[];
1171
844
  interactionAnswers?: Readonly<Record<string, JsonValue>>;
1172
845
  execution?: ExecutionToken;
1173
- outcome?: Outcome;
846
+ outcome?: Outcome$1;
1174
847
  failure?: RunFailure;
1175
848
  cancellationReason?: string;
1176
849
  createdAt: string;
@@ -1242,7 +915,7 @@ type RunSnapshot = RunSnapshotBase & (Readonly<{
1242
915
  answers: Readonly<Record<string, JsonValue>>;
1243
916
  }> | Readonly<{
1244
917
  state: "completed";
1245
- outcome: Outcome;
918
+ outcome: Outcome$1;
1246
919
  output?: AssistantMessage;
1247
920
  }> | Readonly<{
1248
921
  state: "failed";
@@ -1257,7 +930,7 @@ type RunBoundary = Readonly<{
1257
930
  answers: Readonly<Record<string, JsonValue>>;
1258
931
  }> | Readonly<{
1259
932
  type: "completed";
1260
- outcome: Outcome;
933
+ outcome: Outcome$1;
1261
934
  output?: AssistantMessage;
1262
935
  }> | Readonly<{
1263
936
  type: "failed";
@@ -1345,6 +1018,7 @@ interface OwnedStore {
1345
1018
  executionId?: ExecutionId;
1346
1019
  messageId?: MessageId;
1347
1020
  configToken?: ConfigToken;
1021
+ additionalContexts?: readonly ContextCandidate[];
1348
1022
  }): Promise<RunClaim>;
1349
1023
  failQueuedRun(input: {
1350
1024
  runId: RunId;
@@ -1386,7 +1060,7 @@ interface OwnedStore {
1386
1060
  runId: RunId;
1387
1061
  execution: ExecutionToken;
1388
1062
  expectedRevision: number;
1389
- outcome?: Outcome;
1063
+ outcome?: Outcome$1;
1390
1064
  failure?: RunFailure;
1391
1065
  output?: AssistantMessage;
1392
1066
  }): Promise<RunRecord>;
@@ -1600,48 +1274,656 @@ type ConsumerRegistration = Readonly<{
1600
1274
  waterline: EventCursor;
1601
1275
  }>;
1602
1276
 
1603
- type LoopMetrics = {
1604
- /** Number of phase iterations executed. */
1605
- iterations: number;
1606
- /** Phase transition history. */
1607
- phaseTransitions: Array<{
1608
- from: string;
1609
- to: string;
1610
- ts: string;
1611
- }>;
1612
- /** Number of times compaction was triggered. */
1613
- compactionCount: number;
1614
- /** Number of retry attempts due to transient errors. */
1615
- retryCount: number;
1616
- /** Loop start timestamp. */
1617
- startedAt: string;
1618
- /** Loop start time as epoch ms (for duration calculation). */
1619
- startedAtMs: number;
1620
- /** Loop end timestamp (set on completion). */
1621
- endedAt?: string;
1622
- /** Total wall-clock duration in ms. */
1623
- durationMs?: number;
1624
- };
1625
- type ExecutionState = {
1626
- currentPhase: string;
1627
- attempt: number;
1628
- metrics: LoopMetrics;
1629
- status: "idle" | "running" | "suspended" | "completed" | "aborted" | "failed";
1630
- initialPhasePayload?: JsonValue;
1631
- entryPhases?: readonly EntryPhaseSpec[];
1632
- continuation?: ExecutionContinuationState;
1633
- runInteractions?: RunInteractionState;
1634
- phaseInteractions?: RunInteractionState;
1635
- };
1636
- type ExecutionContinuationState = {
1637
- isContinuing: boolean;
1638
- previousPayload?: unknown;
1639
- previousResults: Array<{
1640
- name: string;
1641
- output?: unknown;
1642
- }>;
1643
- pendingInstruction?: string;
1644
- previousPhaseMessageId?: string;
1277
+ type HostContribution = {
1278
+ readonly kind: string;
1279
+ readonly id: string;
1280
+ } & {
1281
+ readonly [key: string]: JsonValue;
1282
+ };
1283
+ interface ExtensionStateStore {
1284
+ get(key: string): Promise<JsonValue | undefined>;
1285
+ set(key: string, value: JsonValue): Promise<void>;
1286
+ delete(key: string): Promise<void>;
1287
+ }
1288
+ interface ExtensionHost {
1289
+ getConfig(extensionId: string, scope?: ScopeRef): Promise<JsonObject | null> | JsonObject | null;
1290
+ onConfigChanged?(listener: (extensionId: string, scope: ScopeRef) => void): (() => void) | void;
1291
+ getAgentState(extensionId: string, agentId: string, key: string): Promise<JsonValue | undefined> | JsonValue | undefined;
1292
+ setAgentState(extensionId: string, agentId: string, key: string, value: JsonValue): Promise<void> | void;
1293
+ deleteAgentState(extensionId: string, agentId: string, key: string): Promise<void> | void;
1294
+ getGlobalState(extensionId: string, key: string): Promise<JsonValue | undefined> | JsonValue | undefined;
1295
+ setGlobalState(extensionId: string, key: string, value: JsonValue): Promise<void> | void;
1296
+ deleteGlobalState(extensionId: string, key: string): Promise<void> | void;
1297
+ }
1298
+ type ExtensionToolContribution = {
1299
+ kind: "tool";
1300
+ name: string;
1301
+ description: string;
1302
+ };
1303
+ type ExtensionCapabilityContribution = ExtensionToolContribution;
1304
+ type ExtensionCapability = {
1305
+ extensionId: string;
1306
+ kind: "tool";
1307
+ name: string;
1308
+ description: string;
1309
+ };
1310
+ interface SourceInfo {
1311
+ source: string;
1312
+ baseDir?: string;
1313
+ displayName?: string;
1314
+ }
1315
+ /** Register a Phase by directory path or Phase object; PHASE.md and direct child Skills are loaded atomically when a path is supplied. */
1316
+ type PhaseRegistration = string | Phase;
1317
+ /**
1318
+ * Tool definition for registering LLM-callable tools via `api.tools.register()`.
1319
+ *
1320
+ * @example
1321
+ * ```typescript
1322
+ * api.tools.register({
1323
+ * name: "search_docs",
1324
+ * description: "Search documentation",
1325
+ * parameters: { type: "object", properties: { query: { type: "string" } } },
1326
+ * execute: async (args, ctx) => {
1327
+ * return { content: [{ type: "text", text: "result" }] };
1328
+ * },
1329
+ * });
1330
+ * ```
1331
+ */
1332
+ interface ToolDefinition {
1333
+ /** Tool name (used in LLM tool calls) */
1334
+ name: string;
1335
+ /** Description for LLM */
1336
+ description: string;
1337
+ /** Parameter schema (JSON Schema) */
1338
+ parameters: Record<string, unknown>;
1339
+ /** Optional: one-line snippet shown in the system prompt tool list */
1340
+ promptSnippet?: string;
1341
+ /** Optional: additional guidelines appended to system prompt */
1342
+ promptGuidelines?: string[];
1343
+ kind?: ToolKind;
1344
+ annotations?: ToolAnnotations;
1345
+ _meta?: JsonObject;
1346
+ present?: (call: {
1347
+ status: ToolCallStatus;
1348
+ args: JsonValue;
1349
+ progress?: ToolProgress;
1350
+ result?: ToolExecutionResult;
1351
+ }) => {
1352
+ title?: string;
1353
+ content?: ToolCallContent[];
1354
+ locations?: ToolCallLocation[];
1355
+ _meta?: JsonObject;
1356
+ } | undefined | void | Promise<{
1357
+ title?: string;
1358
+ content?: ToolCallContent[];
1359
+ locations?: ToolCallLocation[];
1360
+ _meta?: JsonObject;
1361
+ } | undefined | void>;
1362
+ /** Execute the tool */
1363
+ execute: (args: unknown, context: ToolInvocationContext, signal?: AbortSignal) => Promise<ToolExecutionResult>;
1364
+ /** Optional: per-tool execution mode override */
1365
+ executionMode?: "sequential" | "parallel";
1366
+ }
1367
+
1368
+ /**
1369
+ * Registered tool with source metadata.
1370
+ */
1371
+ interface RegisteredTool {
1372
+ definition: ToolDefinition;
1373
+ sourceInfo: SourceInfo;
1374
+ }
1375
+ /**
1376
+ * Structured extension error with attribution.
1377
+ */
1378
+ interface ExtensionError {
1379
+ /** Path of the extension that caused the error */
1380
+ extensionPath: string;
1381
+ /** Event or operation that caused the error */
1382
+ event: string;
1383
+ /** Error message */
1384
+ error: string;
1385
+ /** Optional stack trace */
1386
+ stack?: string;
1387
+ }
1388
+ /** Error listener callback type. */
1389
+ type ExtensionErrorListener = (error: ExtensionError) => void;
1390
+ type ExecOptions = {
1391
+ /** Working directory for the command. Defaults to cwd passed to runtime. */
1392
+ cwd?: string;
1393
+ /** Environment variables to add/override. */
1394
+ env?: Record<string, string>;
1395
+ /** Timeout in milliseconds. */
1396
+ timeout?: number;
1397
+ /** AbortSignal for cancellation. */
1398
+ signal?: AbortSignal;
1399
+ };
1400
+ type ExecResult = {
1401
+ exitCode: number;
1402
+ stdout: string;
1403
+ stderr: string;
1404
+ };
1405
+ /**
1406
+ * Shared runtime state created by loader, used during registration and runtime.
1407
+ * All ExtensionAPI instances reference this shared state.
1408
+ *
1409
+ * It only owns the lifetime guard shared by captured Extension API objects.
1410
+ */
1411
+ interface ExtensionRuntime {
1412
+ /** Throws when this extension instance is stale after runtime replacement. */
1413
+ assertActive: () => void;
1414
+ /** Marks this extension instance as stale after runtime replacement or reload. */
1415
+ invalidate: (message?: string) => void;
1416
+ }
1417
+ /**
1418
+ * Result of loading extensions from filesystem.
1419
+ * The runner takes these and creates Extension tracking objects.
1420
+ */
1421
+ type LoadExtensionsResult = {
1422
+ extensions: LoadedExtension[];
1423
+ errors: Array<{
1424
+ path: string;
1425
+ error: string;
1426
+ }>;
1427
+ };
1428
+ /**
1429
+ * Pre-initialization extension form — factory + metadata.
1430
+ * Runner.loadExtensions() calls the factory and creates the full Extension object.
1431
+ */
1432
+ interface LoadedExtension {
1433
+ id?: string;
1434
+ path: string;
1435
+ name: string;
1436
+ factory: ExtensionFactory;
1437
+ manifest?: ExtensionManifest;
1438
+ }
1439
+ /** Extension manifest from package.json `rowan` field. */
1440
+ interface ExtensionManifest {
1441
+ id?: string;
1442
+ entry?: string;
1443
+ name?: string;
1444
+ }
1445
+
1446
+ /**
1447
+ * Extension API object passed to extension factory function.
1448
+ *
1449
+ * @example
1450
+ * ```typescript
1451
+ * export default function(api: ExtensionAPI) {
1452
+ * // api provides all extension APIs
1453
+ * }
1454
+ * ```
1455
+ */
1456
+ interface ExtensionAPI {
1457
+ /** Hook events — subscribe or unsubscribe. */
1458
+ hooks: {
1459
+ /**
1460
+ * Subscribe to a hook event.
1461
+ *
1462
+ * @param eventType - Hook type, e.g. "before_tool_call"
1463
+ * @param handler - Hook handler, can return result to modify behavior
1464
+ */
1465
+ on<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
1466
+ /** Unsubscribe from a hook event. */
1467
+ off<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
1468
+ };
1469
+ /** Extension configuration — read own layered config or listen for changes. */
1470
+ config: {
1471
+ /** Get the extension's own effective configuration block. */
1472
+ get(scope?: ScopeRef): Promise<JsonObject | null>;
1473
+ /** Listen for configuration changes for a scope. */
1474
+ changed(handler: (scope: ScopeRef) => void): void;
1475
+ };
1476
+ /** Extension state — scoped to run (in-memory) or agent (durable) or global (durable). */
1477
+ state: {
1478
+ /** Run-scoped in-memory state; dropped when the Run ends. */
1479
+ run(runId: string): ExtensionStateStore;
1480
+ /** Agent-scoped durable state; persisted with the Agent record. */
1481
+ agent(agentId: string): ExtensionStateStore;
1482
+ /** Extension-scoped durable state; survives process restarts. */
1483
+ global(): ExtensionStateStore;
1484
+ };
1485
+ /** Tool capabilities — register and unregister custom tools. */
1486
+ tools: {
1487
+ /** Register a custom LLM-callable tool. */
1488
+ register(tool: ToolDefinition): void;
1489
+ /** Unregister a previously registered tool by name. */
1490
+ unregister(toolName: string): void;
1491
+ };
1492
+ /** Capability contributions — advertise tools or features to the host. */
1493
+ capabilities: {
1494
+ /** Contribute a capability to the host. Returns a disposer to remove the contribution. */
1495
+ contribute(contribution: ExtensionCapabilityContribution): () => void;
1496
+ };
1497
+ /** Model provider registration. */
1498
+ providers: {
1499
+ /** Register a model provider. Registering with an existing id replaces it. */
1500
+ register(config: _rowan_agent_models.ProviderConfig): void;
1501
+ /** Unregister a model provider by id. */
1502
+ unregister(id: string): void;
1503
+ };
1504
+ /** Phase execution capabilities — provides Phase In/Out, phase identity, phase routing, and registration. */
1505
+ phases: {
1506
+ /** Register a Phase directory bundle or Phase object. */
1507
+ register(phase: PhaseRegistration): Promise<void>;
1508
+ /** Unregister a previously registered phase by name. */
1509
+ unregister(phaseName: string): void;
1510
+ /** Phase In: get payload from previous phase */
1511
+ getPayload(): unknown;
1512
+ /** Phase Out: set payload for next phase */
1513
+ setPayload(payload: unknown): void;
1514
+ /** Phase Out: set outcome message */
1515
+ setMessage(message: string): void;
1516
+ /** Get current phase name */
1517
+ getCurrentPhase(): string;
1518
+ /** Set next phase (lower priority than PHASE.md target) */
1519
+ setNextPhase(phaseName: string): void;
1520
+ /** Get the next phase set by setNextPhase */
1521
+ getNextPhase(): string | undefined;
1522
+ /** Get the message set by setMessage */
1523
+ getMessage(): string | undefined;
1524
+ };
1525
+ /** Declarative host contributions. */
1526
+ host: {
1527
+ /** Contribute a declarative declaration to the host. Returns a disposer to remove the contribution. */
1528
+ contribute<T extends HostContribution>(contribution: T): () => void;
1529
+ };
1530
+ /** Extension manifest from package.json `rowan` field. */
1531
+ manifest?: ExtensionManifest;
1532
+ /** Utility functions. */
1533
+ utils: ExtensionUtils;
1534
+ /** Runtime context — cwd, signal, exec, message access, etc. */
1535
+ context: ExtensionContext;
1536
+ /** Shared event bus for inter-extension communication. */
1537
+ events: EventBus;
1538
+ }
1539
+ /**
1540
+ * Extension factory function.
1541
+ * Receives ExtensionAPI for registering hooks, phases, and providers.
1542
+ */
1543
+ type ExtensionDisposer = () => void | Promise<void>;
1544
+ type ExtensionFactoryResult = void | ExtensionDisposer;
1545
+ type ExtensionFactory = (api: ExtensionAPI) => ExtensionFactoryResult | Promise<ExtensionFactoryResult>;
1546
+
1547
+ type PhaseStatusState = "running" | "completed";
1548
+ /** Normalized status event exposed to Runtime consumers. */
1549
+ type PhaseStatus = Readonly<{
1550
+ state: PhaseStatusState;
1551
+ /** Stable consumer-facing status identifier, e.g. `compacting`. */
1552
+ kind: string;
1553
+ /** Optional human-readable detail for UI/status consumers. */
1554
+ message?: string;
1555
+ /** Structured status payload. */
1556
+ payload?: unknown;
1557
+ }>;
1558
+ /** Unified phase output — model-driven routing is optional; programmatic phases may normalize omission to stop. */
1559
+ type PhaseOutput = {
1560
+ /** User-visible assistant message. */
1561
+ message?: string;
1562
+ /** Final status update for non-conversational consumers. */
1563
+ status?: PhaseStatus;
1564
+ /** Route to next phase, or "continue" to re-execute current phase, or "stop" to end. Undefined means no model route. */
1565
+ route?: string;
1566
+ /** Phase name that produced this output */
1567
+ phase?: string;
1568
+ /** Tool calls from the model invocation (used by framework for route extraction) */
1569
+ toolCalls?: Array<{
1570
+ id: string;
1571
+ name: string;
1572
+ args: unknown;
1573
+ }>;
1574
+ /** Route reason extracted from route tool call (for hooks to inspect) */
1575
+ routeReason?: string;
1576
+ /** Structured data from this phase, passed to the next phase */
1577
+ payload?: unknown;
1578
+ };
1579
+ /** Phase machine state — tracks position and inter-phase data */
1580
+ interface PhaseState {
1581
+ current: string;
1582
+ available: string[];
1583
+ iterations: number;
1584
+ payload?: unknown;
1585
+ }
1586
+ type PhaseInvocation = {
1587
+ mode: "serial";
1588
+ instanceId: string;
1589
+ } | {
1590
+ mode: "parallel";
1591
+ instanceId: string;
1592
+ groupId: string;
1593
+ index: number;
1594
+ count: number;
1595
+ sourcePhaseId: string;
1596
+ };
1597
+ /** Durable identity of the Run execution currently invoking a Phase. */
1598
+ type PhaseExecutionIdentity = Readonly<{
1599
+ agentId: string;
1600
+ runId: string;
1601
+ executionId: string;
1602
+ /** Original durable Run input, before any Phase-local interpretation. */
1603
+ input?: UserContent;
1604
+ /** Opaque metadata captured at the durable boundary; Rowan does not decode it. */
1605
+ agentMetadata?: Readonly<Record<string, unknown>>;
1606
+ runMetadata?: Readonly<Record<string, unknown>>;
1607
+ scope?: _rowan_agent_models.ScopeRef;
1608
+ cwd?: string;
1609
+ }>;
1610
+ /** Everything a phase needs to execute */
1611
+ interface PhaseContext {
1612
+ systemPrompt: string;
1613
+ messages: AgentMessage[];
1614
+ /** Phase-filtered tools */
1615
+ tools: Tool[];
1616
+ /** Phase-filtered skills */
1617
+ skills: Skill[];
1618
+ /** Phase machine state */
1619
+ state: PhaseState;
1620
+ /** Identity and dispatch metadata for this phase execution */
1621
+ readonly invocation: PhaseInvocation;
1622
+ /** Durable Run identity for cross-store integrations and idempotent commands. */
1623
+ readonly execution: PhaseExecutionIdentity;
1624
+ /** Additional guideline bullets appended to the system prompt */
1625
+ promptGuidelines?: string[];
1626
+ /** Text to append after the system prompt */
1627
+ appendSystemPrompt?: string;
1628
+ }
1629
+ /** JSON-safe structural defaults declared by a Phase's `input` mapping. */
1630
+ type PhaseInput = Readonly<Record<string, JsonValue>>;
1631
+ /** JSON-safe option metadata exposed to a host Settings surface. */
1632
+ interface SettingsOption {
1633
+ value: string;
1634
+ label: string;
1635
+ description?: string;
1636
+ disabled?: boolean;
1637
+ }
1638
+ interface SettingsBadge {
1639
+ label: string;
1640
+ tone?: "neutral" | "success" | "review" | "danger";
1641
+ }
1642
+ interface SettingsItem {
1643
+ id: string;
1644
+ title: string;
1645
+ description?: string;
1646
+ badges?: readonly SettingsBadge[];
1647
+ }
1648
+ type SettingsControl = {
1649
+ type: "boolean";
1650
+ path: string;
1651
+ label: string;
1652
+ description?: string;
1653
+ } | {
1654
+ type: "number";
1655
+ path: string;
1656
+ label: string;
1657
+ description?: string;
1658
+ min?: number;
1659
+ max?: number;
1660
+ step?: number;
1661
+ unit?: string;
1662
+ scale?: number;
1663
+ } | {
1664
+ type: "select";
1665
+ path: string;
1666
+ label: string;
1667
+ description?: string;
1668
+ options: readonly SettingsOption[];
1669
+ } | {
1670
+ type: "text";
1671
+ path: string;
1672
+ label: string;
1673
+ description?: string;
1674
+ placeholder?: string;
1675
+ format?: "string" | "string-array" | "key-value";
1676
+ multiline?: boolean;
1677
+ } | {
1678
+ type: "collection";
1679
+ path: string;
1680
+ label: string;
1681
+ description?: string;
1682
+ items: readonly SettingsItem[];
1683
+ fields: readonly SettingsControl[];
1684
+ add?: {
1685
+ label: string;
1686
+ idLabel?: string;
1687
+ fields: readonly SettingsControl[];
1688
+ };
1689
+ removeLabel?: string;
1690
+ };
1691
+ interface SettingsSection {
1692
+ id: string;
1693
+ title: string;
1694
+ description?: string;
1695
+ controls: readonly SettingsControl[];
1696
+ }
1697
+ /** Declarative, host-neutral Settings surface. */
1698
+ interface SettingsDefinition {
1699
+ description?: string;
1700
+ sections: readonly SettingsSection[];
1701
+ }
1702
+ /**
1703
+ * Loaded Phase object
1704
+ */
1705
+ interface Phase {
1706
+ /** Unique phase identity and display name. */
1707
+ name: string;
1708
+ /** Rowan-owned built-in Phase; built-ins are never filtered or disabled. */
1709
+ core?: boolean;
1710
+ /** Description */
1711
+ description: string;
1712
+ /** Restricted tools (undefined = all tools available) */
1713
+ tools?: string[];
1714
+ /** Skills bundled directly inside this phase directory. Inline phases may omit this (equivalent to []). */
1715
+ skills?: Skill[];
1716
+ /** Forced next phase */
1717
+ target?: string;
1718
+ /** Structural JSON-safe input defaults */
1719
+ input?: PhaseInput;
1720
+ /** If true, phase gets a fresh context when executed in parallel */
1721
+ isolated?: boolean;
1722
+ /** Path to PHASE.md file */
1723
+ filePath: string;
1724
+ /** Phase directory path */
1725
+ baseDir: string;
1726
+ /** PHASE.md body content */
1727
+ content: string;
1728
+ /** Model override for this phase (resolved from frontmatter) */
1729
+ model?: ModelRef;
1730
+ /** Do not automatically inject this Phase into the model route catalog/context. */
1731
+ disableAutoInvocation?: boolean;
1732
+ /** Do not expose this Phase to direct user invocation. */
1733
+ disableImplicitInvocation?: boolean;
1734
+ /** ExtensionAPI factory function used for registration or programmatic execution. */
1735
+ factory?: (api: ExtensionAPI) => Promise<void>;
1736
+ /** Direct run function */
1737
+ run?: (context: PhaseContext, execution: PhaseExecution) => Promise<PhaseOutput | void>;
1738
+ }
1739
+ /**
1740
+ * Phase registry containing all loaded phases
1741
+ */
1742
+ interface PhaseRegistry {
1743
+ /** Map of phase name to Phase object */
1744
+ phases: Map<string, Phase>;
1745
+ /** Entry phase name (null until Agent applies its default phase) */
1746
+ entryPhaseId: string | null;
1747
+ }
1748
+
1749
+ interface BeforePhaseEvent {
1750
+ type: "before_phase";
1751
+ phaseId: string;
1752
+ input: PhaseContext;
1753
+ }
1754
+ interface AfterPhaseEvent {
1755
+ type: "after_phase";
1756
+ phaseId: string;
1757
+ output: PhaseOutput;
1758
+ }
1759
+ interface BeforePromptEvent {
1760
+ type: "before_prompt";
1761
+ phaseId: string;
1762
+ input: PhaseContext;
1763
+ }
1764
+ interface BeforeToolCallEvent {
1765
+ type: "before_tool_call";
1766
+ tool: Tool;
1767
+ args: unknown;
1768
+ readonly runId?: string;
1769
+ readonly agentId?: string;
1770
+ readonly toolCallId?: string;
1771
+ readonly metadata?: Readonly<Record<string, unknown>>;
1772
+ readonly answer?: unknown;
1773
+ readonly scope?: ScopeRef;
1774
+ readonly turn?: JsonObject;
1775
+ }
1776
+ interface AfterToolCallEvent {
1777
+ type: "after_tool_call";
1778
+ tool: Tool;
1779
+ result: ToolResult;
1780
+ readonly runId?: string;
1781
+ readonly agentId?: string;
1782
+ readonly toolCallId?: string;
1783
+ readonly metadata?: Readonly<Record<string, unknown>>;
1784
+ readonly scope?: ScopeRef;
1785
+ readonly turn?: JsonObject;
1786
+ }
1787
+ interface RunStartEvent {
1788
+ type: "run_start";
1789
+ runId: string;
1790
+ agentId: string;
1791
+ metadata: Readonly<Record<string, unknown>>;
1792
+ turn: JsonObject;
1793
+ }
1794
+ interface RunEndEvent {
1795
+ type: "run_end";
1796
+ runId: string;
1797
+ agentId: string;
1798
+ outcome: unknown;
1799
+ }
1800
+ type HookEvent = BeforePhaseEvent | AfterPhaseEvent | BeforePromptEvent | BeforeToolCallEvent | AfterToolCallEvent | RunStartEvent | RunEndEvent;
1801
+ interface BeforePhaseResult {
1802
+ abort?: Outcome;
1803
+ skip?: {
1804
+ route: string;
1805
+ message: string;
1806
+ };
1807
+ input?: PhaseContext;
1808
+ }
1809
+ interface AfterPhaseResult {
1810
+ abort?: Outcome;
1811
+ retry?: PhaseContext;
1812
+ output?: PhaseOutput;
1813
+ }
1814
+ interface BeforePromptResult {
1815
+ input?: PhaseContext;
1816
+ }
1817
+ interface BeforeToolCallResult {
1818
+ allow?: boolean;
1819
+ reason?: string;
1820
+ interaction?: RunInteractionRequest;
1821
+ }
1822
+ interface AfterToolCallResult {
1823
+ result?: ToolResult;
1824
+ }
1825
+ interface HookResultMap {
1826
+ before_phase: BeforePhaseResult | undefined;
1827
+ after_phase: AfterPhaseResult | undefined;
1828
+ before_prompt: BeforePromptResult | undefined;
1829
+ before_tool_call: BeforeToolCallResult | undefined;
1830
+ after_tool_call: AfterToolCallResult | undefined;
1831
+ run_start: void;
1832
+ run_end: void;
1833
+ }
1834
+ type HookEventType = HookEvent["type"];
1835
+ type HookHandler<K extends HookEventType> = (event: Extract<HookEvent, {
1836
+ type: K;
1837
+ }>) => HookResultMap[K] | Promise<HookResultMap[K]> | void | Promise<void>;
1838
+ declare class HooksManager {
1839
+ private handlers;
1840
+ on<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
1841
+ off<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
1842
+ emit<K extends HookEventType>(eventType: K, event: Extract<HookEvent, {
1843
+ type: K;
1844
+ }>): Promise<void>;
1845
+ emitFirst<K extends HookEventType>(eventType: K, event: Extract<HookEvent, {
1846
+ type: K;
1847
+ }>): Promise<HookResultMap[K] | undefined>;
1848
+ }
1849
+
1850
+ type ToolContext = Pick<AgentContext, "skills"> & {
1851
+ toolCallId: string;
1852
+ interaction?: RunInteractionDriver;
1853
+ };
1854
+ type ToolExecutionMode = "sequential" | "parallel";
1855
+ type Tool<TArgs = unknown> = {
1856
+ name: string;
1857
+ /** Rowan-owned Core Tool; Core Tools bypass Phase filtering. */
1858
+ core?: boolean;
1859
+ description: string;
1860
+ parameters: Type.TSchema;
1861
+ /** One-line snippet shown in the system prompt tool list. */
1862
+ promptSnippet?: string;
1863
+ /** Additional guidelines appended to the system prompt when this tool is active. */
1864
+ promptGuidelines?: string[];
1865
+ /** Whether this tool can run concurrently with others. Default: "parallel". */
1866
+ executionMode?: ToolExecutionMode;
1867
+ _meta?: JsonObject$1;
1868
+ execute(args: TArgs, context: ToolContext, signal?: AbortSignal): Promise<ToolResult>;
1869
+ };
1870
+ /** Context snapshot passed into the low-level agent loop. */
1871
+ type AgentContext = {
1872
+ /** System prompt included with the request. */
1873
+ systemPrompt: string;
1874
+ /** Transcript visible to the model. */
1875
+ messages: AgentMessage[];
1876
+ /** Tools available for this run. */
1877
+ tools: Tool[];
1878
+ /** Skills available for this run. */
1879
+ skills: Skill[];
1880
+ /** Custom phases for this run. Agent normalizes this with the built-in default phase. */
1881
+ phases?: PhaseRegistry;
1882
+ cwd?: string;
1883
+ };
1884
+
1885
+ type LoopMetrics = {
1886
+ /** Number of phase iterations executed. */
1887
+ iterations: number;
1888
+ /** Phase transition history. */
1889
+ phaseTransitions: Array<{
1890
+ from: string;
1891
+ to: string;
1892
+ ts: string;
1893
+ }>;
1894
+ /** Number of times compaction was triggered. */
1895
+ compactionCount: number;
1896
+ /** Number of retry attempts due to transient errors. */
1897
+ retryCount: number;
1898
+ /** Loop start timestamp. */
1899
+ startedAt: string;
1900
+ /** Loop start time as epoch ms (for duration calculation). */
1901
+ startedAtMs: number;
1902
+ /** Loop end timestamp (set on completion). */
1903
+ endedAt?: string;
1904
+ /** Total wall-clock duration in ms. */
1905
+ durationMs?: number;
1906
+ };
1907
+ type ExecutionState = {
1908
+ currentPhase: string;
1909
+ attempt: number;
1910
+ metrics: LoopMetrics;
1911
+ status: "idle" | "running" | "suspended" | "completed" | "aborted" | "failed";
1912
+ initialPhasePayload?: JsonValue;
1913
+ entryPhases?: readonly EntryPhaseSpec[];
1914
+ continuation?: ExecutionContinuationState;
1915
+ runInteractions?: RunInteractionState;
1916
+ phaseInteractions?: RunInteractionState;
1917
+ };
1918
+ type ExecutionContinuationState = {
1919
+ isContinuing: boolean;
1920
+ previousPayload?: unknown;
1921
+ previousResults: Array<{
1922
+ name: string;
1923
+ output?: unknown;
1924
+ }>;
1925
+ pendingInstruction?: string;
1926
+ previousPhaseMessageId?: string;
1645
1927
  };
1646
1928
 
1647
1929
  type RunInteractionKind = "user_input" | "permission" | "elicitation" | "confirmation";
@@ -1792,9 +2074,14 @@ type MessageBase = Readonly<{
1792
2074
  sequenceWithinRun: number;
1793
2075
  createdAt: string;
1794
2076
  }>;
2077
+ type ContextCandidate = Readonly<{
2078
+ name: string;
2079
+ value: JsonValue;
2080
+ }>;
1795
2081
  type UserMessage = MessageBase & Readonly<{
1796
2082
  role: "user";
1797
2083
  content: UserContent;
2084
+ contexts?: readonly ContextCandidate[];
1798
2085
  }>;
1799
2086
  type AssistantMessage = MessageBase & Readonly<{
1800
2087
  role: "assistant";
@@ -1822,7 +2109,7 @@ type InteractionRecord = MessageBase & Readonly<{
1822
2109
  }>;
1823
2110
  }>;
1824
2111
  type Message = UserMessage | AssistantMessage | ToolMessage | InteractionRecord;
1825
- type Outcome = Readonly<{
2112
+ type Outcome$1 = Readonly<{
1826
2113
  id: OutcomeId;
1827
2114
  message: string;
1828
2115
  payload?: JsonValue;
@@ -1940,7 +2227,7 @@ type RunStateChanged = DurableEventBase & (Readonly<{
1940
2227
  kind: "run_state_changed";
1941
2228
  from: "running";
1942
2229
  to: "completed";
1943
- outcome: Outcome;
2230
+ outcome: Outcome$1;
1944
2231
  output?: AssistantMessage;
1945
2232
  }> | Readonly<{
1946
2233
  kind: "run_state_changed";
@@ -2007,377 +2294,94 @@ type ToolCallDelta = Readonly<{
2007
2294
  durability: "transient";
2008
2295
  runId: RunId;
2009
2296
  executionId: ExecutionId;
2010
- messageId: MessageId;
2011
- providerToolCallId: string;
2012
- toolName: string;
2013
- arguments: string;
2014
- args: JsonValue | undefined;
2015
- }>;
2016
- type PhaseStatusEvent = Readonly<{
2017
- kind: "phase_status";
2018
- durability: "transient";
2019
- runId: RunId;
2020
- executionId: ExecutionId;
2021
- phaseId: string;
2022
- status: PhaseStatus;
2023
- }>;
2024
- type ModelRetry = Readonly<{
2025
- kind: "model_retry";
2026
- durability: "transient";
2027
- runId: RunId;
2028
- executionId: ExecutionId;
2029
- attempt: number;
2030
- maxRetries: number;
2031
- delayMs: number;
2032
- error: string;
2033
- }>;
2034
- type LiveInteractionEvent = Readonly<{
2035
- kind: "live_interaction";
2036
- durability: "transient";
2037
- runId: RunId;
2038
- executionId?: ExecutionId;
2039
- interaction: RunInteraction;
2040
- }>;
2041
- type RunEvent = DurableRunEvent | MessageDelta | ThinkingDelta | ToolCallDelta | PhaseStatusEvent | ModelRetry | LiveInteractionEvent | Extract<ToolStateChanged, {
2042
- durability: "transient";
2043
- }>;
2044
-
2045
- type PhaseStatusState = "running" | "completed";
2046
- /** Normalized status event exposed to Runtime consumers. */
2047
- type PhaseStatus = Readonly<{
2048
- state: PhaseStatusState;
2049
- /** Stable consumer-facing status identifier, e.g. `compacting`. */
2050
- kind: string;
2051
- /** Optional human-readable detail for UI/status consumers. */
2052
- message?: string;
2053
- /** Structured status payload. */
2054
- payload?: unknown;
2055
- }>;
2056
- /** Unified phase output — model-driven routing is optional; programmatic phases may normalize omission to stop. */
2057
- type PhaseOutput = {
2058
- /** User-visible assistant message. */
2059
- message?: string;
2060
- /** Final status update for non-conversational consumers. */
2061
- status?: PhaseStatus;
2062
- /** Route to next phase, or "continue" to re-execute current phase, or "stop" to end. Undefined means no model route. */
2063
- route?: string;
2064
- /** Phase name that produced this output */
2065
- phase?: string;
2066
- /** Tool calls from the model invocation (used by framework for route extraction) */
2067
- toolCalls?: Array<{
2068
- id: string;
2069
- name: string;
2070
- args: unknown;
2071
- }>;
2072
- /** Route reason extracted from route tool call (for hooks to inspect) */
2073
- routeReason?: string;
2074
- /** Structured data from this phase, passed to the next phase */
2075
- payload?: unknown;
2076
- };
2077
- /** Phase machine state — tracks position and inter-phase data */
2078
- interface PhaseState {
2079
- current: string;
2080
- available: string[];
2081
- iterations: number;
2082
- payload?: unknown;
2083
- }
2084
- type PhaseInvocation = {
2085
- mode: "serial";
2086
- instanceId: string;
2087
- } | {
2088
- mode: "parallel";
2089
- instanceId: string;
2090
- groupId: string;
2091
- index: number;
2092
- count: number;
2093
- sourcePhaseId: string;
2094
- };
2095
- /** Durable identity of the Run execution currently invoking a Phase. */
2096
- type PhaseExecutionIdentity = Readonly<{
2097
- agentId: string;
2098
- runId: string;
2099
- executionId: string;
2100
- /** Original durable Run input, before any Phase-local interpretation. */
2101
- input?: UserContent;
2102
- /** Opaque metadata captured at the durable boundary; Rowan does not decode it. */
2103
- agentMetadata?: Readonly<Record<string, unknown>>;
2104
- runMetadata?: Readonly<Record<string, unknown>>;
2105
- scope?: _rowan_agent_models.ScopeRef;
2106
- cwd?: string;
2107
- }>;
2108
- /** Everything a phase needs to execute */
2109
- interface PhaseContext {
2110
- systemPrompt: string;
2111
- messages: AgentMessage[];
2112
- /** Phase-filtered tools */
2113
- tools: Tool[];
2114
- /** Phase-filtered skills */
2115
- skills: Skill[];
2116
- /** Phase machine state */
2117
- state: PhaseState;
2118
- /** Identity and dispatch metadata for this phase execution */
2119
- readonly invocation: PhaseInvocation;
2120
- /** Durable Run identity for cross-store integrations and idempotent commands. */
2121
- readonly execution: PhaseExecutionIdentity;
2122
- /** Additional guideline bullets appended to the system prompt */
2123
- promptGuidelines?: string[];
2124
- /** Text to append after the system prompt */
2125
- appendSystemPrompt?: string;
2126
- }
2127
- /** JSON-safe structural defaults declared by a Phase's `input` mapping. */
2128
- type PhaseInput = Readonly<Record<string, JsonValue>>;
2129
- /** JSON-safe option metadata exposed to a host Settings surface. */
2130
- interface SettingsOption {
2131
- value: string;
2132
- label: string;
2133
- description?: string;
2134
- disabled?: boolean;
2135
- }
2136
- interface SettingsBadge {
2137
- label: string;
2138
- tone?: "neutral" | "success" | "review" | "danger";
2139
- }
2140
- interface SettingsItem {
2141
- id: string;
2142
- title: string;
2143
- description?: string;
2144
- badges?: readonly SettingsBadge[];
2145
- }
2146
- type SettingsControl = {
2147
- type: "boolean";
2148
- path: string;
2149
- label: string;
2150
- description?: string;
2151
- } | {
2152
- type: "number";
2153
- path: string;
2154
- label: string;
2155
- description?: string;
2156
- min?: number;
2157
- max?: number;
2158
- step?: number;
2159
- unit?: string;
2160
- scale?: number;
2161
- } | {
2162
- type: "select";
2163
- path: string;
2164
- label: string;
2165
- description?: string;
2166
- options: readonly SettingsOption[];
2167
- } | {
2168
- type: "text";
2169
- path: string;
2170
- label: string;
2171
- description?: string;
2172
- placeholder?: string;
2173
- format?: "string" | "string-array" | "key-value";
2174
- multiline?: boolean;
2175
- } | {
2176
- type: "collection";
2177
- path: string;
2178
- label: string;
2179
- description?: string;
2180
- items: readonly SettingsItem[];
2181
- fields: readonly SettingsControl[];
2182
- add?: {
2183
- label: string;
2184
- idLabel?: string;
2185
- fields: readonly SettingsControl[];
2297
+ messageId: MessageId;
2298
+ providerToolCallId: string;
2299
+ toolName: string;
2300
+ arguments: string;
2301
+ args: JsonValue | undefined;
2302
+ }>;
2303
+ type PhaseStatusEvent = Readonly<{
2304
+ kind: "phase_status";
2305
+ durability: "transient";
2306
+ runId: RunId;
2307
+ executionId: ExecutionId;
2308
+ phaseId: string;
2309
+ status: PhaseStatus;
2310
+ }>;
2311
+ type ModelRetry = Readonly<{
2312
+ kind: "model_retry";
2313
+ durability: "transient";
2314
+ runId: RunId;
2315
+ executionId: ExecutionId;
2316
+ attempt: number;
2317
+ maxRetries: number;
2318
+ delayMs: number;
2319
+ error: string;
2320
+ }>;
2321
+ type LiveInteractionEvent = Readonly<{
2322
+ kind: "live_interaction";
2323
+ durability: "transient";
2324
+ runId: RunId;
2325
+ executionId?: ExecutionId;
2326
+ interaction: RunInteraction;
2327
+ }>;
2328
+ type RunEvent = DurableRunEvent | MessageDelta | ThinkingDelta | ToolCallDelta | PhaseStatusEvent | ModelRetry | LiveInteractionEvent | Extract<ToolStateChanged, {
2329
+ durability: "transient";
2330
+ }>;
2331
+
2332
+ type AgentMessage = {
2333
+ id: string;
2334
+ role: "system" | "user" | "assistant" | "tool";
2335
+ content: string | LlmContentPart[];
2336
+ createdAt: string;
2337
+ metadata?: Record<string, unknown> & {
2338
+ phase?: string;
2186
2339
  };
2187
- removeLabel?: string;
2340
+ contexts?: readonly ContextCandidate[];
2188
2341
  };
2189
- interface SettingsSection {
2190
- id: string;
2191
- title: string;
2192
- description?: string;
2193
- controls: readonly SettingsControl[];
2194
- }
2195
- /** Declarative, host-neutral Settings surface. */
2196
- interface SettingsDefinition {
2197
- description?: string;
2198
- sections: readonly SettingsSection[];
2199
- }
2200
- /**
2201
- * Loaded Phase object
2202
- */
2203
- interface Phase {
2204
- /** Unique phase identity and display name. */
2342
+ type Skill = {
2205
2343
  name: string;
2206
- /** Rowan-owned built-in Phase; built-ins are never filtered or disabled. */
2207
- core?: boolean;
2208
- /** Description */
2209
2344
  description: string;
2210
- /** Restricted tools (undefined = all tools available) */
2211
- tools?: string[];
2212
- /** Skills bundled directly inside this phase directory. Inline phases may omit this (equivalent to []). */
2213
- skills?: Skill[];
2214
- /** Forced next phase */
2215
- target?: string;
2216
- /** Structural JSON-safe input defaults */
2217
- input?: PhaseInput;
2218
- /** If true, phase gets a fresh context when executed in parallel */
2219
- isolated?: boolean;
2220
- /** Path to PHASE.md file */
2345
+ /** Absolute path to the SKILL.md file */
2221
2346
  filePath: string;
2222
- /** Phase directory path */
2347
+ /** Directory containing the SKILL.md file */
2223
2348
  baseDir: string;
2224
- /** PHASE.md body content */
2349
+ /** Full body content of the SKILL.md (after frontmatter) */
2225
2350
  content: string;
2226
- /** Model override for this phase (resolved from frontmatter) */
2227
- model?: ModelRef;
2228
- /** Do not automatically inject this Phase into the model route catalog/context. */
2351
+ /** Do not automatically inject this Skill into the model Context. */
2229
2352
  disableAutoInvocation?: boolean;
2230
- /** Do not expose this Phase to direct user invocation. */
2353
+ /** Do not expose this Skill to direct user invocation. */
2231
2354
  disableImplicitInvocation?: boolean;
2232
- /** ExtensionAPI factory function used for registration or programmatic execution. */
2233
- factory?: (api: ExtensionAPI) => Promise<void>;
2234
- /** Direct run function */
2235
- run?: (context: PhaseContext, execution: PhaseExecution) => Promise<PhaseOutput | void>;
2236
- }
2237
- /**
2238
- * Phase registry containing all loaded phases
2239
- */
2240
- interface PhaseRegistry {
2241
- /** Map of phase name to Phase object */
2242
- phases: Map<string, Phase>;
2243
- /** Entry phase name (null until Agent applies its default phase) */
2244
- entryPhaseId: string | null;
2245
- }
2246
-
2247
- interface BeforePhaseEvent {
2248
- type: "before_phase";
2249
- phaseId: string;
2250
- input: PhaseContext;
2251
- }
2252
- interface AfterPhaseEvent {
2253
- type: "after_phase";
2254
- phaseId: string;
2255
- output: PhaseOutput;
2256
- }
2257
- interface BeforePromptEvent {
2258
- type: "before_prompt";
2259
- phaseId: string;
2260
- input: PhaseContext;
2261
- }
2262
- interface BeforeToolCallEvent {
2263
- type: "before_tool_call";
2264
- tool: Tool;
2265
- args: unknown;
2266
- readonly runId?: string;
2267
- readonly agentId?: string;
2268
- readonly toolCallId?: string;
2269
- readonly metadata?: Readonly<Record<string, unknown>>;
2270
- readonly answer?: unknown;
2271
- readonly scope?: ScopeRef;
2272
- readonly turn?: JsonObject;
2273
- }
2274
- interface AfterToolCallEvent {
2275
- type: "after_tool_call";
2276
- tool: Tool;
2277
- result: ToolResult;
2278
- readonly runId?: string;
2279
- readonly agentId?: string;
2280
- readonly toolCallId?: string;
2281
- readonly metadata?: Readonly<Record<string, unknown>>;
2282
- readonly scope?: ScopeRef;
2283
- readonly turn?: JsonObject;
2284
- }
2285
- interface RunStartEvent {
2286
- type: "run_start";
2287
- runId: string;
2288
- agentId: string;
2289
- metadata: Readonly<Record<string, unknown>>;
2290
- turn: JsonObject;
2291
- }
2292
- interface RunEndEvent {
2293
- type: "run_end";
2294
- runId: string;
2295
- agentId: string;
2296
- outcome: unknown;
2297
- }
2298
- type HookEvent = BeforePhaseEvent | AfterPhaseEvent | BeforePromptEvent | BeforeToolCallEvent | AfterToolCallEvent | RunStartEvent | RunEndEvent;
2299
- interface BeforePhaseResult {
2300
- abort?: Outcome$1;
2301
- skip?: {
2302
- route: string;
2303
- message: string;
2304
- };
2305
- input?: PhaseContext;
2306
- }
2307
- interface AfterPhaseResult {
2308
- abort?: Outcome$1;
2309
- retry?: PhaseContext;
2310
- output?: PhaseOutput;
2311
- }
2312
- interface BeforePromptResult {
2313
- input?: PhaseContext;
2314
- }
2315
- interface BeforeToolCallResult {
2316
- allow?: boolean;
2317
- reason?: string;
2318
- interaction?: RunInteractionRequest;
2319
- }
2320
- interface AfterToolCallResult {
2321
- result?: ToolResult;
2322
- }
2323
- interface HookResultMap {
2324
- before_phase: BeforePhaseResult | undefined;
2325
- after_phase: AfterPhaseResult | undefined;
2326
- before_prompt: BeforePromptResult | undefined;
2327
- before_tool_call: BeforeToolCallResult | undefined;
2328
- after_tool_call: AfterToolCallResult | undefined;
2329
- run_start: void;
2330
- run_end: void;
2331
- }
2332
- type HookEventType = HookEvent["type"];
2333
- type HookHandler<K extends HookEventType> = (event: Extract<HookEvent, {
2334
- type: K;
2335
- }>) => HookResultMap[K] | Promise<HookResultMap[K]> | void | Promise<void>;
2336
- declare class HooksManager {
2337
- private handlers;
2338
- on<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
2339
- off<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
2340
- emit<K extends HookEventType>(eventType: K, event: Extract<HookEvent, {
2341
- type: K;
2342
- }>): Promise<void>;
2343
- emitFirst<K extends HookEventType>(eventType: K, event: Extract<HookEvent, {
2344
- type: K;
2345
- }>): Promise<HookResultMap[K] | undefined>;
2346
- }
2347
-
2348
- type ToolContext = Pick<AgentContext, "skills"> & {
2349
- toolCallId: string;
2350
- interaction?: RunInteractionDriver;
2355
+ /** @deprecated Use disableAutoInvocation; kept only for old in-memory callers during cutover. */
2356
+ disableModelInvocation?: boolean;
2351
2357
  };
2352
- type ToolExecutionMode = "sequential" | "parallel";
2353
- type Tool<TArgs = unknown> = {
2358
+ type Outcome = {
2359
+ id: string;
2360
+ message: string;
2361
+ /** Publish this outcome's message as an assistant message before completing the run. */
2362
+ display?: boolean;
2363
+ payload?: unknown;
2364
+ toolResults?: Array<{
2365
+ toolCallId: string;
2366
+ toolName: string;
2367
+ ok: boolean;
2368
+ content: unknown;
2369
+ error?: string;
2370
+ }>;
2371
+ };
2372
+ type ToolCall = {
2373
+ id: string;
2354
2374
  name: string;
2355
- /** Rowan-owned Core Tool; Core Tools bypass Phase filtering. */
2356
- core?: boolean;
2357
- description: string;
2358
- parameters: Type.TSchema;
2359
- /** One-line snippet shown in the system prompt tool list. */
2360
- promptSnippet?: string;
2361
- /** Additional guidelines appended to the system prompt when this tool is active. */
2362
- promptGuidelines?: string[];
2363
- /** Whether this tool can run concurrently with others. Default: "parallel". */
2364
- executionMode?: ToolExecutionMode;
2365
- _meta?: JsonObject$1;
2366
- execute(args: TArgs, context: ToolContext, signal?: AbortSignal): Promise<ToolResult>;
2375
+ args: unknown;
2367
2376
  };
2368
- /** Context snapshot passed into the low-level agent loop. */
2369
- type AgentContext = {
2370
- /** System prompt included with the request. */
2371
- systemPrompt: string;
2372
- /** Transcript visible to the model. */
2373
- messages: AgentMessage[];
2374
- /** Tools available for this run. */
2375
- tools: Tool[];
2376
- /** Skills available for this run. */
2377
- skills: Skill[];
2378
- /** Custom phases for this run. Agent normalizes this with the built-in default phase. */
2379
- phases?: PhaseRegistry;
2380
- cwd?: string;
2377
+ type ToolResult = {
2378
+ toolCallId: string;
2379
+ toolName: string;
2380
+ ok: boolean;
2381
+ content: unknown;
2382
+ error?: string;
2383
+ structuredContent?: unknown;
2384
+ isError?: boolean;
2381
2385
  };
2382
2386
 
2383
2387
  /**
@@ -2694,6 +2698,7 @@ declare class InMemoryStore implements DurableStore {
2694
2698
  executionId?: ExecutionId;
2695
2699
  messageId?: MessageId;
2696
2700
  configToken?: ConfigToken;
2701
+ additionalContexts?: readonly ContextCandidate[];
2697
2702
  }): RunClaim;
2698
2703
  failQueuedRun(lease: OwnerLease, input: {
2699
2704
  runId: RunId;
@@ -2789,7 +2794,7 @@ declare class InMemoryStore implements DurableStore {
2789
2794
  runId: RunId;
2790
2795
  execution: ExecutionToken;
2791
2796
  expectedRevision: number;
2792
- outcome?: Outcome;
2797
+ outcome?: Outcome$1;
2793
2798
  failure?: RunFailure;
2794
2799
  output?: AssistantMessage;
2795
2800
  }): RunRecord;
@@ -2944,6 +2949,7 @@ declare class SqliteStore implements DurableStore {
2944
2949
  executionId?: ExecutionId;
2945
2950
  messageId?: MessageId;
2946
2951
  configToken?: ConfigToken;
2952
+ additionalContexts?: readonly ContextCandidate[];
2947
2953
  }): Promise<RunClaim>;
2948
2954
  failQueuedRun(lease: OwnerLease, input: {
2949
2955
  runId: RunId;
@@ -2987,7 +2993,7 @@ declare class SqliteStore implements DurableStore {
2987
2993
  runId: RunId;
2988
2994
  execution: ExecutionToken;
2989
2995
  expectedRevision: number;
2990
- outcome?: Outcome;
2996
+ outcome?: Outcome$1;
2991
2997
  failure?: RunFailure;
2992
2998
  output?: AssistantMessage;
2993
2999
  }): Promise<RunRecord>;
@@ -3303,4 +3309,4 @@ declare function parseFrontmatter<T = Record<string, unknown>>(raw: string): Fro
3303
3309
 
3304
3310
  declare function createCoreTools(input?: CoreToolContext): Tool$1[];
3305
3311
 
3306
- export { type AfterToolCall, type AgentConfiguration, type AgentDefinition, type AgentId, type AgentListCursor, type AgentRecord, type AgentRun, AgentRuntime, type AgentRuntimeOptions, type AgentSummary, type AnyRuntimeError, type AssistantContent, type AssistantMessage, type BeforeToolCall, COMPACT_PHASE_ID, type ConfigProvider, type ConfigPutResult, type ConfigResolution, type ConfigToken, type ConfigurationSnapshot, type ContextCandidate, type ContextCompactionRecord, type ContextStatus, type CoreToolContext, DEFAULT_PHASE_ID, type DefinitionLayer, type DurableConsumer, type DurableRunEvent, type DurableStore, type DurableToolResult, type EntryPhaseSpec, type EventCursor, type EventId, type ExecutionCheckpoint, type ExecutionId, type ExecutionToken, type ExtensionAPI, type ExtensionActivationError, type ExtensionActivationResult, type ExtensionCapability, type ExtensionCapabilityContribution, type ExtensionContribution, type ExtensionDisposer, type ExtensionFactory, type ExtensionFactoryResult, type ExtensionHost, ExtensionLifetimeError, type ExtensionLifetimeErrorCode, type ExtensionLoadInput, type ExtensionStateStore, type ExtensionToolContribution, type FrontmatterResult, type HistorySeed, type HookEvent, type HookEventType, type HookHandler, type HostContribution, InMemoryConfigProvider, InMemoryExtensionHost, InMemoryStore, type InteractionRecord, type InvocationCatalogEntry, type InvocationSource, type JsonObject, type JsonPrimitive, type JsonValue, type LiveInteractionEvent, type LoadExtensionsResult, type LoadInput, type LoadResult, type LoadedExtension, type Message, type MessageBase, type MessageCommitted, type MessageContent, type MessageDelta, type MessageId, type MessageRevised, type MessageRevisionResult, type Metadata, type ModelRetry, type OpaqueId, type Outcome, type OwnerLease, type OwnerToken, type Page, type Phase, type PhaseContext, type PhaseContribution, type PhaseExecution, type PhaseExecutionIdentity, type PhaseInput, type PhaseInvocation, type PhaseMessageManager, type PhaseOutput, type PhaseRegistry, type PhaseRegistrySelection, type PhaseState, type PhaseStatus, type PhaseStatusState, type ResolvedResourceView, type ResourceDiagnostic, type ResourceKind, type ResourceRef, ResourceRegistry, ResourceRegistryError, type ResourceRegistryErrorCode, type ResourceSourceId, type ResourceView, type RetentionResult, type RunBoundary, type RunClaim, type RunEndEvent, type RunEvent, type RunFailure, type RunId, type RunInteraction, RunInteractionBoundary, RunInteractionCancelledError, type RunInteractionDriver, type RunInteractionKind, type RunInteractionRequest, type RunInteractionState, type RunInteractionStatus, type RunListCursor, type RunRecord, type RunSnapshot, type RunStartEvent, type RunState, type RunStateChanged, type RunSummary, RuntimeBootstrapRegistry, RuntimeError, type RuntimeErrorCode, type RuntimeErrorDetails, RuntimeExtensionLifetime, STOP_PHASE_ID, type SettingsBadge, type SettingsControl, type SettingsDefinition, type SettingsItem, type SettingsOption, type SettingsSection, type Skill, SqliteStore, type TextContent, type ThinkingContent, type ThinkingDelta, type Tool$1 as Tool, type ToolCallContext, type ToolCallDelta, type ToolCallId, type ToolCallPresentationInput, type ToolCallPresentationOutput, type ToolCallSnapshot, type ToolCallState, type ToolContribution, type ToolDefinition, type ToolExecutionResult, type ToolInvocationContext, type ToolMessage, type ToolMessageContent, type ToolResultContent, type ToolStateChanged, type ToolUseContent, type UserContent, type UserInput, type UserMessage, type WithdrawnUserInput, brandConfigToken, createCompactPhase, createCorePhases, createCoreTools, createDefaultPhase, createStopPhase, isConfigurationSnapshot, isRuntimeError, loadExtensionsFromPath as loadExtensions, loadPhase, loadPhases, loadSkill, loadSkills, mergeToolCall, parseAgentDefinition, parseFrontmatter, resolveConfigurationSnapshot };
3312
+ export { type AfterToolCall, type AgentConfiguration, type AgentDefinition, type AgentId, type AgentListCursor, type AgentRecord, type AgentRun, AgentRuntime, type AgentRuntimeOptions, type AgentSummary, type AnyRuntimeError, type AssistantContent, type AssistantMessage, type BeforeToolCall, COMPACT_PHASE_ID, type ConfigProvider, type ConfigPutResult, type ConfigResolution, type ConfigToken, type ConfigurationSnapshot, type ContextCandidate, type ContextCompactionRecord, type ContextStatus, type CoreToolContext, DEFAULT_PHASE_ID, type DefinitionLayer, type DurableConsumer, type DurableRunEvent, type DurableStore, type DurableToolResult, type EntryPhaseSpec, type EventCursor, type EventId, type ExecutionCheckpoint, type ExecutionId, type ExecutionToken, type ExtensionAPI, type ExtensionActivationError, type ExtensionActivationResult, type ExtensionCapability, type ExtensionCapabilityContribution, type ExtensionContribution, type ExtensionDisposer, type ExtensionFactory, type ExtensionFactoryResult, type ExtensionHost, ExtensionLifetimeError, type ExtensionLifetimeErrorCode, type ExtensionLoadInput, type ExtensionStateStore, type ExtensionToolContribution, type FrontmatterResult, type HistorySeed, type HookEvent, type HookEventType, type HookHandler, type HostContribution, InMemoryConfigProvider, InMemoryExtensionHost, InMemoryStore, type InteractionRecord, type InvocationCatalogEntry, type InvocationSource, type JsonObject, type JsonPrimitive, type JsonValue, type LiveInteractionEvent, type LoadExtensionsResult, type LoadInput, type LoadResult, type LoadedExtension, type Message, type MessageBase, type MessageCommitted, type MessageContent, type MessageDelta, type MessageId, type MessageRevised, type MessageRevisionResult, type Metadata, type ModelRetry, type OpaqueId, type Outcome$1 as Outcome, type OwnerLease, type OwnerToken, type Page, type Phase, type PhaseContext, type PhaseContribution, type PhaseExecution, type PhaseExecutionIdentity, type PhaseInput, type PhaseInvocation, type PhaseMessageManager, type PhaseOutput, type PhaseRegistry, type PhaseRegistrySelection, type PhaseState, type PhaseStatus, type PhaseStatusState, type ResolvedResourceView, type ResourceDiagnostic, type ResourceKind, type ResourceRef, ResourceRegistry, ResourceRegistryError, type ResourceRegistryErrorCode, type ResourceSourceId, type ResourceView, type RetentionResult, type RunBoundary, type RunClaim, type RunEndEvent, type RunEvent, type RunFailure, type RunId, type RunInteraction, RunInteractionBoundary, RunInteractionCancelledError, type RunInteractionDriver, type RunInteractionKind, type RunInteractionRequest, type RunInteractionState, type RunInteractionStatus, type RunListCursor, type RunRecord, type RunSnapshot, type RunStartEvent, type RunState, type RunStateChanged, type RunSummary, RuntimeBootstrapRegistry, RuntimeError, type RuntimeErrorCode, type RuntimeErrorDetails, RuntimeExtensionLifetime, STOP_PHASE_ID, type SettingsBadge, type SettingsControl, type SettingsDefinition, type SettingsItem, type SettingsOption, type SettingsSection, type Skill, SqliteStore, type TextContent, type ThinkingContent, type ThinkingDelta, type Tool$1 as Tool, type ToolCallContext, type ToolCallDelta, type ToolCallId, type ToolCallPresentationInput, type ToolCallPresentationOutput, type ToolCallSnapshot, type ToolCallState, type ToolContribution, type ToolDefinition, type ToolExecutionResult, type ToolInvocationContext, type ToolMessage, type ToolMessageContent, type ToolResultContent, type ToolStateChanged, type ToolUseContent, type UserContent, type UserInput, type UserMessage, type WithdrawnUserInput, brandConfigToken, createCompactPhase, createCorePhases, createCoreTools, createDefaultPhase, createStopPhase, isConfigurationSnapshot, isRuntimeError, loadExtensionsFromPath as loadExtensions, loadPhase, loadPhases, loadSkill, loadSkills, mergeToolCall, parseAgentDefinition, parseFrontmatter, resolveConfigurationSnapshot };