@rowan-agent/agent 0.9.6 → 0.9.8

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
@@ -50,6 +50,473 @@ type ToolResult = {
50
50
  error?: string;
51
51
  };
52
52
 
53
+ /** Durable and transient DTOs owned by the event-driven Agent Runtime. */
54
+
55
+ declare const opaqueIdBrand: unique symbol;
56
+ type OpaqueId<Kind extends string> = string & {
57
+ readonly [opaqueIdBrand]: Kind;
58
+ };
59
+ type AgentId = OpaqueId<"AgentId">;
60
+ type RunId = OpaqueId<"RunId">;
61
+ type MessageId = OpaqueId<"MessageId">;
62
+ type InputRequestId = OpaqueId<"InputRequestId">;
63
+ type ToolCallId = OpaqueId<"ToolCallId">;
64
+ type EventId = OpaqueId<"EventId">;
65
+ type ExecutionId = OpaqueId<"ExecutionId">;
66
+ type OutcomeId = OpaqueId<"OutcomeId">;
67
+ type ConfigToken = OpaqueId<"ConfigToken">;
68
+ type OwnerToken = OpaqueId<"OwnerToken">;
69
+ type EventCursor = OpaqueId<"EventCursor">;
70
+ type AgentListCursor = OpaqueId<"AgentListCursor">;
71
+ type RunListCursor = OpaqueId<"RunListCursor">;
72
+ type JsonPrimitive = null | boolean | number | string;
73
+ type JsonValue = JsonPrimitive | readonly JsonValue[] | {
74
+ readonly [key: string]: JsonValue;
75
+ };
76
+ type JsonObject = Readonly<Record<string, JsonValue>>;
77
+ type Metadata = JsonObject;
78
+ type TextContent = Readonly<{
79
+ type: "text";
80
+ text: string;
81
+ }>;
82
+ type ImageContent = Readonly<{
83
+ type: "image";
84
+ data: string;
85
+ mimeType: string;
86
+ }>;
87
+ type ThinkingContent = Readonly<{
88
+ type: "thinking";
89
+ thinking: string;
90
+ signature?: string;
91
+ }>;
92
+ type ToolUseContent = Readonly<{
93
+ type: "tool_use";
94
+ toolCallId: ToolCallId;
95
+ /** Provider/model correlation, retained only to reconstruct the next request. */
96
+ providerToolCallId?: string;
97
+ name: string;
98
+ input: JsonValue;
99
+ }>;
100
+ type ToolExecutionResult$1 = Readonly<{
101
+ ok: true;
102
+ content: JsonValue;
103
+ }> | Readonly<{
104
+ ok: false;
105
+ content: JsonValue;
106
+ error: string;
107
+ }>;
108
+ type DurableToolResult = Readonly<{
109
+ toolCallId: ToolCallId;
110
+ toolName: string;
111
+ }> & ToolExecutionResult$1;
112
+ type ToolResultContent = Readonly<{
113
+ type: "tool_result";
114
+ toolCallId: ToolCallId;
115
+ /** Provider/model correlation, retained only to reconstruct the next request. */
116
+ providerToolCallId?: string;
117
+ result: ToolExecutionResult$1;
118
+ }>;
119
+ type UserContent = string | readonly (TextContent | ImageContent)[];
120
+ type AssistantContent = string | readonly (TextContent | ThinkingContent | ToolUseContent)[];
121
+ type ToolMessageContent = readonly [ToolResultContent, ...ToolResultContent[]];
122
+ type MessageContent = UserContent | AssistantContent | ToolMessageContent;
123
+ type MessageBase = Readonly<{
124
+ id: MessageId;
125
+ agentId: AgentId;
126
+ runId: RunId;
127
+ /** Monotonic active revision. Omitted on legacy/initial messages and read as 0. */
128
+ messageRevision?: number;
129
+ metadata?: Metadata;
130
+ sequenceWithinRun: number;
131
+ createdAt: string;
132
+ }>;
133
+ type UserMessage = MessageBase & Readonly<{
134
+ role: "user";
135
+ content: UserContent;
136
+ }>;
137
+ type AssistantMessage = MessageBase & Readonly<{
138
+ role: "assistant";
139
+ content: AssistantContent;
140
+ interrupted?: boolean;
141
+ }>;
142
+ type ToolMessage = MessageBase & Readonly<{
143
+ role: "tool";
144
+ content: ToolMessageContent;
145
+ }>;
146
+ type Message = UserMessage | AssistantMessage | ToolMessage;
147
+ type Outcome = Readonly<{
148
+ id: OutcomeId;
149
+ message: string;
150
+ payload?: JsonValue;
151
+ toolResults?: readonly DurableToolResult[];
152
+ }>;
153
+ type RunState = "queued" | "running" | "input_required" | "completed" | "failed" | "cancelled";
154
+ type RunFailure = Readonly<{
155
+ code: "configuration_unavailable";
156
+ message: string;
157
+ }> | Readonly<{
158
+ code: "checkpoint_incompatible";
159
+ message: string;
160
+ expected: Readonly<{
161
+ codec: string;
162
+ versions: readonly number[];
163
+ }>;
164
+ actual: Readonly<{
165
+ codec: string;
166
+ version: number;
167
+ }>;
168
+ }> | Readonly<{
169
+ code: "runtime_interrupted";
170
+ message: string;
171
+ ownerEpoch: number;
172
+ }> | Readonly<{
173
+ code: "tool_indeterminate";
174
+ message: string;
175
+ toolCallIds: readonly [ToolCallId, ...ToolCallId[]];
176
+ }> | Readonly<{
177
+ code: "execution_failed";
178
+ message: string;
179
+ details?: JsonValue;
180
+ }>;
181
+ type QueuedRunFailure = Extract<RunFailure, {
182
+ code: "configuration_unavailable" | "checkpoint_incompatible";
183
+ }>;
184
+ type RunningRunFailure = Extract<RunFailure, {
185
+ code: "runtime_interrupted" | "tool_indeterminate" | "execution_failed";
186
+ }>;
187
+ type ToolCallState = "pending" | "running" | "completed" | "failed" | "indeterminate";
188
+ type ToolCallSnapshotBase = Readonly<{
189
+ id: ToolCallId;
190
+ providerToolCallId: string;
191
+ agentId: AgentId;
192
+ runId: RunId;
193
+ executionId: ExecutionId;
194
+ requestMessageId: MessageId;
195
+ name: string;
196
+ args: JsonValue;
197
+ createdAt: string;
198
+ updatedAt: string;
199
+ }>;
200
+ type ToolCallSnapshot = ToolCallSnapshotBase & (Readonly<{
201
+ state: "pending";
202
+ }> | Readonly<{
203
+ state: "running";
204
+ }> | Readonly<{
205
+ state: "completed";
206
+ result: DurableToolResult & Readonly<{
207
+ ok: true;
208
+ }>;
209
+ resultMessageId: MessageId;
210
+ }> | Readonly<{
211
+ state: "failed";
212
+ result: DurableToolResult & Readonly<{
213
+ ok: false;
214
+ }>;
215
+ resultMessageId: MessageId;
216
+ }> | Readonly<{
217
+ state: "indeterminate";
218
+ result: DurableToolResult & Readonly<{
219
+ ok: false;
220
+ }>;
221
+ resultMessageId: MessageId;
222
+ reason: string;
223
+ }>);
224
+ type DurableEventBase = Readonly<{
225
+ id: EventId;
226
+ schemaVersion: 1;
227
+ cursor: EventCursor;
228
+ durability: "durable";
229
+ agentId: AgentId;
230
+ runId: RunId;
231
+ runRevision: number;
232
+ metadata?: Metadata;
233
+ createdAt: string;
234
+ }>;
235
+ type MessageCommitted = DurableEventBase & Readonly<{
236
+ kind: "message_committed";
237
+ message: Message;
238
+ }>;
239
+ type MessageRevised = DurableEventBase & Readonly<{
240
+ kind: "message_revised";
241
+ message: UserMessage;
242
+ previousRevision: number;
243
+ invalidatedRunIds: readonly RunId[];
244
+ targetRunId: RunId;
245
+ cutoffSequenceWithinRun: number;
246
+ }>;
247
+ type RunStateChanged = DurableEventBase & (Readonly<{
248
+ kind: "run_state_changed";
249
+ from: null;
250
+ to: "queued";
251
+ }> | Readonly<{
252
+ kind: "run_state_changed";
253
+ from: "input_required";
254
+ to: "queued";
255
+ }> | Readonly<{
256
+ kind: "run_state_changed";
257
+ from: "queued";
258
+ to: "running";
259
+ }> | Readonly<{
260
+ kind: "run_state_changed";
261
+ from: "running";
262
+ to: "input_required";
263
+ request: Readonly<{
264
+ id: InputRequestId;
265
+ phase: string;
266
+ prompt: AssistantMessage;
267
+ }>;
268
+ interactions: readonly PhaseInteraction[];
269
+ answers: Readonly<Record<string, JsonValue>>;
270
+ }> | Readonly<{
271
+ kind: "run_state_changed";
272
+ from: "running";
273
+ to: "completed";
274
+ outcome: Outcome;
275
+ output?: AssistantMessage;
276
+ }> | Readonly<{
277
+ kind: "run_state_changed";
278
+ from: "queued";
279
+ to: "failed";
280
+ failure: QueuedRunFailure;
281
+ }> | Readonly<{
282
+ kind: "run_state_changed";
283
+ from: "running";
284
+ to: "failed";
285
+ failure: RunningRunFailure;
286
+ }> | Readonly<{
287
+ kind: "run_state_changed";
288
+ from: "queued" | "running" | "input_required";
289
+ to: "cancelled";
290
+ reason?: string;
291
+ }>);
292
+ type ToolStateChanged = DurableEventBase & (Readonly<{
293
+ kind: "tool_state_changed";
294
+ transition: Readonly<{
295
+ from: null;
296
+ to: "pending";
297
+ }>;
298
+ toolCall: Extract<ToolCallSnapshot, {
299
+ state: "pending";
300
+ }>;
301
+ }> | Readonly<{
302
+ kind: "tool_state_changed";
303
+ transition: Readonly<{
304
+ from: "pending";
305
+ to: "running";
306
+ }>;
307
+ toolCall: Extract<ToolCallSnapshot, {
308
+ state: "running";
309
+ }>;
310
+ }> | Readonly<{
311
+ kind: "tool_state_changed";
312
+ transition: Readonly<{
313
+ from: "pending";
314
+ to: "failed";
315
+ }>;
316
+ toolCall: Extract<ToolCallSnapshot, {
317
+ state: "failed";
318
+ }>;
319
+ }> | Readonly<{
320
+ kind: "tool_state_changed";
321
+ transition: Readonly<{
322
+ from: "running";
323
+ to: "completed";
324
+ }>;
325
+ toolCall: Extract<ToolCallSnapshot, {
326
+ state: "completed";
327
+ }>;
328
+ }> | Readonly<{
329
+ kind: "tool_state_changed";
330
+ transition: Readonly<{
331
+ from: "running";
332
+ to: "failed";
333
+ }>;
334
+ toolCall: Extract<ToolCallSnapshot, {
335
+ state: "failed";
336
+ }>;
337
+ }> | Readonly<{
338
+ kind: "tool_state_changed";
339
+ transition: Readonly<{
340
+ from: "running";
341
+ to: "indeterminate";
342
+ }>;
343
+ toolCall: Extract<ToolCallSnapshot, {
344
+ state: "indeterminate";
345
+ }>;
346
+ }>);
347
+ type DurableRunEvent = MessageCommitted | MessageRevised | RunStateChanged | ToolStateChanged;
348
+ type MessageDelta = Readonly<{
349
+ kind: "message_delta";
350
+ durability: "transient";
351
+ runId: RunId;
352
+ executionId: ExecutionId;
353
+ messageId: MessageId;
354
+ offset: number;
355
+ text: string;
356
+ }>;
357
+ type ToolProgress = Readonly<{
358
+ kind: "tool_progress";
359
+ durability: "transient";
360
+ runId: RunId;
361
+ executionId: ExecutionId;
362
+ toolCallId: ToolCallId;
363
+ progress: JsonValue;
364
+ }>;
365
+ type RunEvent = DurableRunEvent | MessageDelta | ToolProgress;
366
+
367
+ interface BeforePhaseEvent {
368
+ type: "before_phase";
369
+ phaseId: string;
370
+ input: PhaseContext;
371
+ }
372
+ interface AfterPhaseEvent {
373
+ type: "after_phase";
374
+ phaseId: string;
375
+ output: PhaseOutput;
376
+ }
377
+ interface BeforePromptEvent {
378
+ type: "before_prompt";
379
+ phaseId: string;
380
+ input: PhaseContext;
381
+ }
382
+ interface BeforeToolCallEvent {
383
+ type: "before_tool_call";
384
+ tool: Tool$1;
385
+ args: unknown;
386
+ }
387
+ interface AfterToolCallEvent {
388
+ type: "after_tool_call";
389
+ tool: Tool$1;
390
+ result: ToolResult;
391
+ }
392
+ type HookEvent = BeforePhaseEvent | AfterPhaseEvent | BeforePromptEvent | BeforeToolCallEvent | AfterToolCallEvent;
393
+ interface BeforePhaseResult {
394
+ abort?: Outcome$1;
395
+ skip?: {
396
+ route: string;
397
+ message: string;
398
+ };
399
+ input?: PhaseContext;
400
+ }
401
+ interface AfterPhaseResult {
402
+ abort?: Outcome$1;
403
+ retry?: PhaseContext;
404
+ output?: PhaseOutput;
405
+ }
406
+ interface BeforePromptResult {
407
+ input?: PhaseContext;
408
+ }
409
+ interface BeforeToolCallResult {
410
+ allow: boolean;
411
+ reason?: string;
412
+ }
413
+ interface AfterToolCallResult {
414
+ result?: ToolResult;
415
+ }
416
+ interface HookResultMap {
417
+ before_phase: BeforePhaseResult | undefined;
418
+ after_phase: AfterPhaseResult | undefined;
419
+ before_prompt: BeforePromptResult | undefined;
420
+ before_tool_call: BeforeToolCallResult | undefined;
421
+ after_tool_call: AfterToolCallResult | undefined;
422
+ }
423
+ type HookEventType = HookEvent["type"];
424
+ type HookHandler<K extends HookEventType> = (event: Extract<HookEvent, {
425
+ type: K;
426
+ }>) => HookResultMap[K] | Promise<HookResultMap[K]> | void | Promise<void>;
427
+ declare class HooksManager {
428
+ private handlers;
429
+ on<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
430
+ off<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
431
+ emit<K extends HookEventType>(eventType: K, event: Extract<HookEvent, {
432
+ type: K;
433
+ }>): Promise<void>;
434
+ emitFirst<K extends HookEventType>(eventType: K, event: Extract<HookEvent, {
435
+ type: K;
436
+ }>): Promise<HookResultMap[K] | undefined>;
437
+ }
438
+
439
+ type LoopMetrics = {
440
+ /** Number of phase iterations executed. */
441
+ iterations: number;
442
+ /** Phase transition history. */
443
+ phaseTransitions: Array<{
444
+ from: string;
445
+ to: string;
446
+ ts: string;
447
+ }>;
448
+ /** Number of times compaction was triggered. */
449
+ compactionCount: number;
450
+ /** Number of retry attempts due to transient errors. */
451
+ retryCount: number;
452
+ /** Loop start timestamp. */
453
+ startedAt: string;
454
+ /** Loop start time as epoch ms (for duration calculation). */
455
+ startedAtMs: number;
456
+ /** Loop end timestamp (set on completion). */
457
+ endedAt?: string;
458
+ /** Total wall-clock duration in ms. */
459
+ durationMs?: number;
460
+ };
461
+ type ExecutionState = {
462
+ currentPhase: string;
463
+ attempt: number;
464
+ metrics: LoopMetrics;
465
+ status: "idle" | "running" | "suspended" | "completed" | "aborted" | "failed";
466
+ continuation?: ExecutionContinuationState;
467
+ phaseInteractions?: PhaseInteractionState;
468
+ };
469
+ type ExecutionContinuationState = {
470
+ isContinuing: boolean;
471
+ previousPayload?: unknown;
472
+ previousResults: Array<{
473
+ name: string;
474
+ output?: unknown;
475
+ }>;
476
+ pendingInstruction?: string;
477
+ previousPhaseMessageId?: string;
478
+ };
479
+
480
+ type PhaseInteractionKind = "user_input" | "permission" | "elicitation" | "confirmation";
481
+ type PhaseInteractionStatus = "pending" | "answered" | "denied" | "cancelled" | "expired";
482
+ type PhaseInteraction = Readonly<{
483
+ id: string;
484
+ phase: string;
485
+ kind: PhaseInteractionKind;
486
+ prompt: string;
487
+ payload?: JsonValue;
488
+ createdAt: string;
489
+ status: PhaseInteractionStatus;
490
+ }>;
491
+ type PhaseInteractionState = Readonly<{
492
+ requests: readonly PhaseInteraction[];
493
+ answers: Readonly<Record<string, JsonValue>>;
494
+ checkpoint?: JsonValue;
495
+ }>;
496
+ type PhaseInteractionDriver = Readonly<{
497
+ signal: AbortSignal;
498
+ request(input: Readonly<{
499
+ id?: string;
500
+ kind: PhaseInteractionKind;
501
+ prompt: string;
502
+ payload?: JsonValue;
503
+ }>): PhaseInteraction;
504
+ pending(): readonly PhaseInteraction[];
505
+ answers(): ReadonlyMap<string, JsonValue>;
506
+ suspend(input?: Readonly<{
507
+ checkpoint?: JsonValue;
508
+ }>): never;
509
+ }>;
510
+ declare class PhaseInteractionCancelledError extends Error {
511
+ readonly code: "phase_interaction_cancelled";
512
+ constructor();
513
+ }
514
+ declare class PhaseInteractionBoundary extends Error {
515
+ readonly state: ExecutionState;
516
+ readonly interactions: readonly PhaseInteraction[];
517
+ constructor(state: ExecutionState, interactions: readonly PhaseInteraction[]);
518
+ }
519
+
53
520
  type ModelInvokeOutput = {
54
521
  text: string;
55
522
  contentBlocks: ContentBlock[];
@@ -72,6 +539,7 @@ type PhaseExecution = {
72
539
  invokeModel(context: PhaseContext): Promise<ModelInvokeOutput>;
73
540
  executeTool(context: AgentContext, toolCall: ToolCall): Promise<ToolResult>;
74
541
  executeTools(context: AgentContext, toolCalls: readonly ToolCall[]): Promise<readonly ToolResult[]>;
542
+ interaction: PhaseInteractionDriver;
75
543
  };
76
544
 
77
545
  /**
@@ -106,14 +574,14 @@ interface ToolDefinition {
106
574
  /** Parameter schema (JSON Schema) */
107
575
  parameters: Record<string, unknown>;
108
576
  /** Execute the tool */
109
- execute: (args: unknown, signal?: AbortSignal) => Promise<ToolExecutionResult$1>;
577
+ execute: (args: unknown, signal?: AbortSignal) => Promise<ToolExecutionResult>;
110
578
  /** Optional: per-tool execution mode override */
111
579
  executionMode?: "sequential" | "parallel";
112
580
  }
113
581
  /**
114
582
  * Result from tool execution.
115
583
  */
116
- interface ToolExecutionResult$1 {
584
+ interface ToolExecutionResult {
117
585
  /** Content blocks to return to the LLM */
118
586
  content: Array<{
119
587
  type: string;
@@ -196,110 +664,38 @@ interface LoadedExtension {
196
664
  /** Extension manifest from package.json `rowan` field. */
197
665
  interface ExtensionManifest {
198
666
  entry?: string;
199
- name?: string;
200
- }
201
-
202
- /**
203
- * EventBus — simple pub/sub for inter-extension communication.
204
- *
205
- * Extensions can emit and subscribe to arbitrary events via `api.events`.
206
- * This allows extensions to coordinate without direct coupling.
207
- *
208
- * @example
209
- * ```typescript
210
- * // Extension A
211
- * api.events.on("my-plugin:ready", (data) => {
212
- * console.log("Plugin ready:", data);
213
- * });
214
- *
215
- * // Extension B
216
- * api.events.emit("my-plugin:ready", { version: "1.0" });
217
- * ```
218
- */
219
- type Listener = (...args: unknown[]) => void;
220
- interface EventBus {
221
- /** Subscribe to an event. Returns unsubscribe function. */
222
- on(event: string, listener: Listener): () => void;
223
- /** Emit an event to all subscribers. */
224
- emit(event: string, ...args: unknown[]): void;
225
- /** Remove all listeners for an event, or all listeners if no event specified. */
226
- off(event?: string): void;
227
- /** Check if there are listeners for an event. */
228
- has(event: string): boolean;
229
- /** Get listener count for an event. */
230
- count(event: string): number;
231
- }
232
-
233
- interface BeforePhaseEvent {
234
- type: "before_phase";
235
- phaseId: string;
236
- input: PhaseContext;
237
- }
238
- interface AfterPhaseEvent {
239
- type: "after_phase";
240
- phaseId: string;
241
- output: PhaseOutput;
242
- }
243
- interface BeforePromptEvent {
244
- type: "before_prompt";
245
- phaseId: string;
246
- input: PhaseContext;
247
- }
248
- interface BeforeToolCallEvent {
249
- type: "before_tool_call";
250
- tool: Tool$1;
251
- args: unknown;
252
- }
253
- interface AfterToolCallEvent {
254
- type: "after_tool_call";
255
- tool: Tool$1;
256
- result: ToolResult;
257
- }
258
- type HookEvent = BeforePhaseEvent | AfterPhaseEvent | BeforePromptEvent | BeforeToolCallEvent | AfterToolCallEvent;
259
- interface BeforePhaseResult {
260
- abort?: Outcome$1;
261
- skip?: {
262
- route: string;
263
- message: string;
264
- };
265
- input?: PhaseContext;
266
- }
267
- interface AfterPhaseResult {
268
- abort?: Outcome$1;
269
- retry?: PhaseContext;
270
- output?: PhaseOutput;
271
- }
272
- interface BeforePromptResult {
273
- input?: PhaseContext;
274
- }
275
- interface BeforeToolCallResult {
276
- allow: boolean;
277
- reason?: string;
278
- }
279
- interface AfterToolCallResult {
280
- result?: ToolResult;
281
- }
282
- interface HookResultMap {
283
- before_phase: BeforePhaseResult | undefined;
284
- after_phase: AfterPhaseResult | undefined;
285
- before_prompt: BeforePromptResult | undefined;
286
- before_tool_call: BeforeToolCallResult | undefined;
287
- after_tool_call: AfterToolCallResult | undefined;
667
+ name?: string;
288
668
  }
289
- type HookEventType = HookEvent["type"];
290
- type HookHandler<K extends HookEventType> = (event: Extract<HookEvent, {
291
- type: K;
292
- }>) => HookResultMap[K] | Promise<HookResultMap[K]> | void | Promise<void>;
293
- declare class HooksManager {
294
- private handlers;
295
- on<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
296
- off<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
297
- emit<K extends HookEventType>(eventType: K, event: Extract<HookEvent, {
298
- type: K;
299
- }>): Promise<void>;
300
- emitFirst<K extends HookEventType>(eventType: K, event: Extract<HookEvent, {
301
- type: K;
302
- }>): Promise<HookResultMap[K] | undefined>;
669
+
670
+ /**
671
+ * EventBus — simple pub/sub for inter-extension communication.
672
+ *
673
+ * Extensions can emit and subscribe to arbitrary events via `api.events`.
674
+ * This allows extensions to coordinate without direct coupling.
675
+ *
676
+ * @example
677
+ * ```typescript
678
+ * // Extension A
679
+ * api.events.on("my-plugin:ready", (data) => {
680
+ * console.log("Plugin ready:", data);
681
+ * });
682
+ *
683
+ * // Extension B
684
+ * api.events.emit("my-plugin:ready", { version: "1.0" });
685
+ * ```
686
+ */
687
+ type Listener = (...args: unknown[]) => void;
688
+ interface EventBus {
689
+ /** Subscribe to an event. Returns unsubscribe function. */
690
+ on(event: string, listener: Listener): () => void;
691
+ /** Emit an event to all subscribers. */
692
+ emit(event: string, ...args: unknown[]): void;
693
+ /** Remove all listeners for an event, or all listeners if no event specified. */
694
+ off(event?: string): void;
695
+ /** Check if there are listeners for an event. */
696
+ has(event: string): boolean;
697
+ /** Get listener count for an event. */
698
+ count(event: string): number;
303
699
  }
304
700
 
305
701
  /**
@@ -623,398 +1019,87 @@ declare function parseAgentDefinition(raw: string): AgentDefinition;
623
1019
  type ResourceKind = "agent" | "tool" | "skill" | "phase";
624
1020
  type ResourceSourceId = string;
625
1021
  /** Rowan-native contribution aliases. Hosts may adapt their domain handlers to
626
- * these existing Tool/Phase lifecycles without importing host Scope types. */
627
- type ToolContribution = Tool;
628
- type PhaseContribution = Phase;
629
- type ResourceView = Readonly<{
630
- agents: readonly ResourceSourceId[];
631
- tools: readonly ResourceSourceId[];
632
- skills: readonly ResourceSourceId[];
633
- phases: readonly ResourceSourceId[];
634
- }>;
635
- type ResourceRef = Readonly<{
636
- kind: ResourceKind;
637
- sourceId: ResourceSourceId;
638
- name: string;
639
- }>;
640
- type ResourceDiagnostic = Readonly<{
641
- kind: "invalid" | "missing" | "collision";
642
- sourceId: ResourceSourceId;
643
- message: string;
644
- path?: string;
645
- }>;
646
- type LoadResult = Readonly<{
647
- revision: string;
648
- registered: readonly ResourceRef[];
649
- skipped: readonly ResourceDiagnostic[];
650
- }>;
651
- type LoadInput<T> = Readonly<{
652
- sourceId: ResourceSourceId;
653
- directory?: string;
654
- values?: readonly T[];
655
- }>;
656
- type ResolvedResourceView = Readonly<{
657
- agents: readonly AgentDefinition[];
658
- tools: readonly Tool[];
659
- skills: readonly Skill[];
660
- phases: readonly Phase[];
661
- revisions: Readonly<Record<ResourceKind, readonly string[]>>;
662
- refs: Readonly<Record<ResourceKind, readonly ResourceRef[]>>;
663
- }>;
664
- type ResourceRegistryErrorCode = "invalid_source_id" | "invalid_resource_name" | "resource_collision" | "resource_input_missing" | "resource_directory_not_supported" | "unknown_resource_source" | "implicit_source_protected";
665
- declare class ResourceRegistryError extends Error {
666
- readonly code: ResourceRegistryErrorCode;
667
- constructor(code: ResourceRegistryErrorCode, message: string);
668
- }
669
- type RegistryValue = AgentDefinition | Tool | Skill | Phase;
670
- /**
671
- * Runtime Resource Registry source transaction and view resolver.
672
- *
673
- * Directory normalization is intentionally added by the typed loader slice;
674
- * this first module owns only the atomic source/revision/collision semantics.
675
- */
676
- declare class ResourceRegistry {
677
- private readonly sources;
678
- /** Sources registered by the bootstrap boundary (currently Extensions). */
679
- private readonly implicitSources;
680
- private revisionSequence;
681
- loadAgents(input: LoadInput<AgentDefinition>): Promise<LoadResult>;
682
- loadSkills(input: LoadInput<Skill>): Promise<LoadResult>;
683
- loadPhases(input: LoadInput<Phase>): Promise<LoadResult>;
684
- loadTools(input: Readonly<{
685
- sourceId: ResourceSourceId;
686
- values: readonly ToolContribution[];
687
- }>): Promise<LoadResult>;
688
- unload(input: Readonly<{
689
- kind: ResourceKind;
690
- sourceId: ResourceSourceId;
691
- }>): Promise<LoadResult>;
692
- resolveView(view: ResourceView): ResolvedResourceView;
693
- /** Mark one already-loaded source as implicit for every Resource View. */
694
- protected markImplicit(kind: ResourceKind, sourceId: ResourceSourceId): void;
695
- /** Bootstrap-only helper for replacing an implicit contribution source. */
696
- protected replaceImplicit<T extends RegistryValue>(kind: ResourceKind, sourceId: ResourceSourceId, values: readonly T[]): Promise<LoadResult>;
697
- protected hasImplicit(kind: ResourceKind, sourceId: ResourceSourceId): boolean;
698
- private withImplicit;
699
- private collect;
700
- private commit;
701
- private resolveKind;
702
- private resolveRevisions;
703
- private resolveRefs;
704
- private sourcesFor;
705
- private nextRevision;
706
- }
707
-
708
- /** Durable and transient DTOs owned by the event-driven Agent Runtime. */
709
- declare const opaqueIdBrand: unique symbol;
710
- type OpaqueId<Kind extends string> = string & {
711
- readonly [opaqueIdBrand]: Kind;
712
- };
713
- type AgentId = OpaqueId<"AgentId">;
714
- type RunId = OpaqueId<"RunId">;
715
- type MessageId = OpaqueId<"MessageId">;
716
- type InputRequestId = OpaqueId<"InputRequestId">;
717
- type ToolCallId = OpaqueId<"ToolCallId">;
718
- type EventId = OpaqueId<"EventId">;
719
- type ExecutionId = OpaqueId<"ExecutionId">;
720
- type OutcomeId = OpaqueId<"OutcomeId">;
721
- type ConfigToken = OpaqueId<"ConfigToken">;
722
- type OwnerToken = OpaqueId<"OwnerToken">;
723
- type EventCursor = OpaqueId<"EventCursor">;
724
- type AgentListCursor = OpaqueId<"AgentListCursor">;
725
- type RunListCursor = OpaqueId<"RunListCursor">;
726
- type JsonPrimitive = null | boolean | number | string;
727
- type JsonValue = JsonPrimitive | readonly JsonValue[] | {
728
- readonly [key: string]: JsonValue;
729
- };
730
- type JsonObject = Readonly<Record<string, JsonValue>>;
731
- type Metadata = JsonObject;
732
- type TextContent = Readonly<{
733
- type: "text";
734
- text: string;
735
- }>;
736
- type ImageContent = Readonly<{
737
- type: "image";
738
- data: string;
739
- mimeType: string;
740
- }>;
741
- type ThinkingContent = Readonly<{
742
- type: "thinking";
743
- thinking: string;
744
- signature?: string;
745
- }>;
746
- type ToolUseContent = Readonly<{
747
- type: "tool_use";
748
- toolCallId: ToolCallId;
749
- /** Provider/model correlation, retained only to reconstruct the next request. */
750
- providerToolCallId?: string;
751
- name: string;
752
- input: JsonValue;
753
- }>;
754
- type ToolExecutionResult = Readonly<{
755
- ok: true;
756
- content: JsonValue;
757
- }> | Readonly<{
758
- ok: false;
759
- content: JsonValue;
760
- error: string;
761
- }>;
762
- type DurableToolResult = Readonly<{
763
- toolCallId: ToolCallId;
764
- toolName: string;
765
- }> & ToolExecutionResult;
766
- type ToolResultContent = Readonly<{
767
- type: "tool_result";
768
- toolCallId: ToolCallId;
769
- /** Provider/model correlation, retained only to reconstruct the next request. */
770
- providerToolCallId?: string;
771
- result: ToolExecutionResult;
772
- }>;
773
- type UserContent = string | readonly (TextContent | ImageContent)[];
774
- type AssistantContent = string | readonly (TextContent | ThinkingContent | ToolUseContent)[];
775
- type ToolMessageContent = readonly [ToolResultContent, ...ToolResultContent[]];
776
- type MessageContent = UserContent | AssistantContent | ToolMessageContent;
777
- type MessageBase = Readonly<{
778
- id: MessageId;
779
- agentId: AgentId;
780
- runId: RunId;
781
- /** Monotonic active revision. Omitted on legacy/initial messages and read as 0. */
782
- messageRevision?: number;
783
- metadata?: Metadata;
784
- sequenceWithinRun: number;
785
- createdAt: string;
786
- }>;
787
- type UserMessage = MessageBase & Readonly<{
788
- role: "user";
789
- content: UserContent;
790
- }>;
791
- type AssistantMessage = MessageBase & Readonly<{
792
- role: "assistant";
793
- content: AssistantContent;
794
- interrupted?: boolean;
795
- }>;
796
- type ToolMessage = MessageBase & Readonly<{
797
- role: "tool";
798
- content: ToolMessageContent;
799
- }>;
800
- type Message = UserMessage | AssistantMessage | ToolMessage;
801
- type Outcome = Readonly<{
802
- id: OutcomeId;
803
- message: string;
804
- payload?: JsonValue;
805
- toolResults?: readonly DurableToolResult[];
806
- }>;
807
- type RunState = "queued" | "running" | "input_required" | "completed" | "failed" | "cancelled";
808
- type RunFailure = Readonly<{
809
- code: "configuration_unavailable";
810
- message: string;
811
- }> | Readonly<{
812
- code: "checkpoint_incompatible";
813
- message: string;
814
- expected: Readonly<{
815
- codec: string;
816
- versions: readonly number[];
817
- }>;
818
- actual: Readonly<{
819
- codec: string;
820
- version: number;
821
- }>;
822
- }> | Readonly<{
823
- code: "runtime_interrupted";
824
- message: string;
825
- ownerEpoch: number;
826
- }> | Readonly<{
827
- code: "tool_indeterminate";
828
- message: string;
829
- toolCallIds: readonly [ToolCallId, ...ToolCallId[]];
830
- }> | Readonly<{
831
- code: "execution_failed";
832
- message: string;
833
- details?: JsonValue;
834
- }>;
835
- type QueuedRunFailure = Extract<RunFailure, {
836
- code: "configuration_unavailable" | "checkpoint_incompatible";
837
- }>;
838
- type RunningRunFailure = Extract<RunFailure, {
839
- code: "runtime_interrupted" | "tool_indeterminate" | "execution_failed";
1022
+ * these existing Tool/Phase lifecycles without importing host Scope types. */
1023
+ type ToolContribution = Tool;
1024
+ type PhaseContribution = Phase;
1025
+ type ResourceView = Readonly<{
1026
+ agents: readonly ResourceSourceId[];
1027
+ tools: readonly ResourceSourceId[];
1028
+ skills: readonly ResourceSourceId[];
1029
+ phases: readonly ResourceSourceId[];
840
1030
  }>;
841
- type ToolCallState = "pending" | "running" | "completed" | "failed" | "indeterminate";
842
- type ToolCallSnapshotBase = Readonly<{
843
- id: ToolCallId;
844
- providerToolCallId: string;
845
- agentId: AgentId;
846
- runId: RunId;
847
- executionId: ExecutionId;
848
- requestMessageId: MessageId;
1031
+ type ResourceRef = Readonly<{
1032
+ kind: ResourceKind;
1033
+ sourceId: ResourceSourceId;
849
1034
  name: string;
850
- args: JsonValue;
851
- createdAt: string;
852
- updatedAt: string;
853
- }>;
854
- type ToolCallSnapshot = ToolCallSnapshotBase & (Readonly<{
855
- state: "pending";
856
- }> | Readonly<{
857
- state: "running";
858
- }> | Readonly<{
859
- state: "completed";
860
- result: DurableToolResult & Readonly<{
861
- ok: true;
862
- }>;
863
- resultMessageId: MessageId;
864
- }> | Readonly<{
865
- state: "failed";
866
- result: DurableToolResult & Readonly<{
867
- ok: false;
868
- }>;
869
- resultMessageId: MessageId;
870
- }> | Readonly<{
871
- state: "indeterminate";
872
- result: DurableToolResult & Readonly<{
873
- ok: false;
874
- }>;
875
- resultMessageId: MessageId;
876
- reason: string;
877
- }>);
878
- type DurableEventBase = Readonly<{
879
- id: EventId;
880
- schemaVersion: 1;
881
- cursor: EventCursor;
882
- durability: "durable";
883
- agentId: AgentId;
884
- runId: RunId;
885
- runRevision: number;
886
- metadata?: Metadata;
887
- createdAt: string;
888
1035
  }>;
889
- type MessageCommitted = DurableEventBase & Readonly<{
890
- kind: "message_committed";
891
- message: Message;
1036
+ type ResourceDiagnostic = Readonly<{
1037
+ kind: "invalid" | "missing" | "collision";
1038
+ sourceId: ResourceSourceId;
1039
+ message: string;
1040
+ path?: string;
892
1041
  }>;
893
- type MessageRevised = DurableEventBase & Readonly<{
894
- kind: "message_revised";
895
- message: UserMessage;
896
- previousRevision: number;
897
- invalidatedRunIds: readonly RunId[];
898
- targetRunId: RunId;
899
- cutoffSequenceWithinRun: number;
1042
+ type LoadResult = Readonly<{
1043
+ revision: string;
1044
+ registered: readonly ResourceRef[];
1045
+ skipped: readonly ResourceDiagnostic[];
900
1046
  }>;
901
- type RunStateChanged = DurableEventBase & (Readonly<{
902
- kind: "run_state_changed";
903
- from: null;
904
- to: "queued";
905
- }> | Readonly<{
906
- kind: "run_state_changed";
907
- from: "input_required";
908
- to: "queued";
909
- }> | Readonly<{
910
- kind: "run_state_changed";
911
- from: "queued";
912
- to: "running";
913
- }> | Readonly<{
914
- kind: "run_state_changed";
915
- from: "running";
916
- to: "input_required";
917
- request: Readonly<{
918
- id: InputRequestId;
919
- phase: string;
920
- prompt: AssistantMessage;
921
- }>;
922
- }> | Readonly<{
923
- kind: "run_state_changed";
924
- from: "running";
925
- to: "completed";
926
- outcome: Outcome;
927
- output?: AssistantMessage;
928
- }> | Readonly<{
929
- kind: "run_state_changed";
930
- from: "queued";
931
- to: "failed";
932
- failure: QueuedRunFailure;
933
- }> | Readonly<{
934
- kind: "run_state_changed";
935
- from: "running";
936
- to: "failed";
937
- failure: RunningRunFailure;
938
- }> | Readonly<{
939
- kind: "run_state_changed";
940
- from: "queued" | "running" | "input_required";
941
- to: "cancelled";
942
- reason?: string;
943
- }>);
944
- type ToolStateChanged = DurableEventBase & (Readonly<{
945
- kind: "tool_state_changed";
946
- transition: Readonly<{
947
- from: null;
948
- to: "pending";
949
- }>;
950
- toolCall: Extract<ToolCallSnapshot, {
951
- state: "pending";
952
- }>;
953
- }> | Readonly<{
954
- kind: "tool_state_changed";
955
- transition: Readonly<{
956
- from: "pending";
957
- to: "running";
958
- }>;
959
- toolCall: Extract<ToolCallSnapshot, {
960
- state: "running";
961
- }>;
962
- }> | Readonly<{
963
- kind: "tool_state_changed";
964
- transition: Readonly<{
965
- from: "pending";
966
- to: "failed";
967
- }>;
968
- toolCall: Extract<ToolCallSnapshot, {
969
- state: "failed";
970
- }>;
971
- }> | Readonly<{
972
- kind: "tool_state_changed";
973
- transition: Readonly<{
974
- from: "running";
975
- to: "completed";
976
- }>;
977
- toolCall: Extract<ToolCallSnapshot, {
978
- state: "completed";
979
- }>;
980
- }> | Readonly<{
981
- kind: "tool_state_changed";
982
- transition: Readonly<{
983
- from: "running";
984
- to: "failed";
985
- }>;
986
- toolCall: Extract<ToolCallSnapshot, {
987
- state: "failed";
988
- }>;
989
- }> | Readonly<{
990
- kind: "tool_state_changed";
991
- transition: Readonly<{
992
- from: "running";
993
- to: "indeterminate";
994
- }>;
995
- toolCall: Extract<ToolCallSnapshot, {
996
- state: "indeterminate";
997
- }>;
998
- }>);
999
- type DurableRunEvent = MessageCommitted | MessageRevised | RunStateChanged | ToolStateChanged;
1000
- type MessageDelta = Readonly<{
1001
- kind: "message_delta";
1002
- durability: "transient";
1003
- runId: RunId;
1004
- executionId: ExecutionId;
1005
- messageId: MessageId;
1006
- offset: number;
1007
- text: string;
1047
+ type LoadInput<T> = Readonly<{
1048
+ sourceId: ResourceSourceId;
1049
+ directory?: string;
1050
+ values?: readonly T[];
1008
1051
  }>;
1009
- type ToolProgress = Readonly<{
1010
- kind: "tool_progress";
1011
- durability: "transient";
1012
- runId: RunId;
1013
- executionId: ExecutionId;
1014
- toolCallId: ToolCallId;
1015
- progress: JsonValue;
1052
+ type ResolvedResourceView = Readonly<{
1053
+ agents: readonly AgentDefinition[];
1054
+ tools: readonly Tool[];
1055
+ skills: readonly Skill[];
1056
+ phases: readonly Phase[];
1057
+ revisions: Readonly<Record<ResourceKind, readonly string[]>>;
1058
+ refs: Readonly<Record<ResourceKind, readonly ResourceRef[]>>;
1016
1059
  }>;
1017
- type RunEvent = DurableRunEvent | MessageDelta | ToolProgress;
1060
+ type ResourceRegistryErrorCode = "invalid_source_id" | "invalid_resource_name" | "resource_collision" | "resource_input_missing" | "resource_directory_not_supported" | "unknown_resource_source" | "implicit_source_protected";
1061
+ declare class ResourceRegistryError extends Error {
1062
+ readonly code: ResourceRegistryErrorCode;
1063
+ constructor(code: ResourceRegistryErrorCode, message: string);
1064
+ }
1065
+ type RegistryValue = AgentDefinition | Tool | Skill | Phase;
1066
+ /**
1067
+ * Runtime Resource Registry source transaction and view resolver.
1068
+ *
1069
+ * Directory normalization is intentionally added by the typed loader slice;
1070
+ * this first module owns only the atomic source/revision/collision semantics.
1071
+ */
1072
+ declare class ResourceRegistry {
1073
+ private readonly sources;
1074
+ /** Sources registered by the bootstrap boundary (currently Extensions). */
1075
+ private readonly implicitSources;
1076
+ private revisionSequence;
1077
+ loadAgents(input: LoadInput<AgentDefinition>): Promise<LoadResult>;
1078
+ loadSkills(input: LoadInput<Skill>): Promise<LoadResult>;
1079
+ loadPhases(input: LoadInput<Phase>): Promise<LoadResult>;
1080
+ loadTools(input: Readonly<{
1081
+ sourceId: ResourceSourceId;
1082
+ values: readonly ToolContribution[];
1083
+ }>): Promise<LoadResult>;
1084
+ unload(input: Readonly<{
1085
+ kind: ResourceKind;
1086
+ sourceId: ResourceSourceId;
1087
+ }>): Promise<LoadResult>;
1088
+ resolveView(view: ResourceView): ResolvedResourceView;
1089
+ /** Mark one already-loaded source as implicit for every Resource View. */
1090
+ protected markImplicit(kind: ResourceKind, sourceId: ResourceSourceId): void;
1091
+ /** Bootstrap-only helper for replacing an implicit contribution source. */
1092
+ protected replaceImplicit<T extends RegistryValue>(kind: ResourceKind, sourceId: ResourceSourceId, values: readonly T[]): Promise<LoadResult>;
1093
+ protected hasImplicit(kind: ResourceKind, sourceId: ResourceSourceId): boolean;
1094
+ private withImplicit;
1095
+ private collect;
1096
+ private commit;
1097
+ private resolveKind;
1098
+ private resolveRevisions;
1099
+ private resolveRefs;
1100
+ private sourcesFor;
1101
+ private nextRevision;
1102
+ }
1018
1103
 
1019
1104
  /**
1020
1105
  * Extension runner — manages extension loading and hook execution.
@@ -1290,7 +1375,7 @@ type Tool = Readonly<{
1290
1375
  name: string;
1291
1376
  description: string;
1292
1377
  parameters: Type.TSchema;
1293
- execute(args: JsonValue, context: ToolInvocationContext, signal: AbortSignal): Promise<ToolExecutionResult>;
1378
+ execute(args: JsonValue, context: ToolInvocationContext, signal: AbortSignal): Promise<ToolExecutionResult$1>;
1294
1379
  }>;
1295
1380
  type ContextCandidate = Readonly<{
1296
1381
  name: string;
@@ -1314,10 +1399,10 @@ type BeforeToolCall = (input: Readonly<{
1314
1399
  }>>;
1315
1400
  type AfterToolCall = (input: Readonly<{
1316
1401
  tool: Tool;
1317
- result: ToolExecutionResult;
1402
+ result: ToolExecutionResult$1;
1318
1403
  context: ToolInvocationContext;
1319
1404
  signal: AbortSignal;
1320
- }>) => ToolExecutionResult | Promise<ToolExecutionResult>;
1405
+ }>) => ToolExecutionResult$1 | Promise<ToolExecutionResult$1>;
1321
1406
  type AgentResources = Readonly<{
1322
1407
  tools: readonly Tool[];
1323
1408
  skills: readonly Skill[];
@@ -1390,6 +1475,7 @@ type InputRequiredCommit = Readonly<{
1390
1475
  run: RunRecord;
1391
1476
  prompt: AssistantMessage;
1392
1477
  request: InputRequest;
1478
+ interactions: readonly PhaseInteraction[];
1393
1479
  }>;
1394
1480
  type ToolCallReservation = Readonly<{
1395
1481
  providerToolCallId: string;
@@ -1422,6 +1508,8 @@ type RunRecord = Readonly<{
1422
1508
  pinnedConfigToken?: ConfigToken;
1423
1509
  checkpoint?: ExecutionCheckpoint;
1424
1510
  openInputRequest?: InputRequest;
1511
+ openInteractions?: readonly PhaseInteraction[];
1512
+ interactionAnswers?: Readonly<Record<string, JsonValue>>;
1425
1513
  execution?: ExecutionToken;
1426
1514
  outcome?: Outcome;
1427
1515
  failure?: RunFailure;
@@ -1488,6 +1576,8 @@ type RunSnapshot = RunSnapshotBase & (Readonly<{
1488
1576
  phase: string;
1489
1577
  prompt: AssistantMessage;
1490
1578
  }>;
1579
+ interactions: readonly PhaseInteraction[];
1580
+ answers: Readonly<Record<string, JsonValue>>;
1491
1581
  }> | Readonly<{
1492
1582
  state: "completed";
1493
1583
  outcome: Outcome;
@@ -1504,6 +1594,8 @@ type RunBoundary = Readonly<{
1504
1594
  requestId: InputRequestId;
1505
1595
  phase: string;
1506
1596
  prompt: AssistantMessage;
1597
+ interactions: readonly PhaseInteraction[];
1598
+ answers: Readonly<Record<string, JsonValue>>;
1507
1599
  }> | Readonly<{
1508
1600
  type: "completed";
1509
1601
  outcome: Outcome;
@@ -1600,6 +1692,8 @@ interface OwnedStore {
1600
1692
  phase: string;
1601
1693
  prompt: AssistantMessage;
1602
1694
  checkpoint: ExecutionCheckpoint;
1695
+ interactions?: readonly PhaseInteraction[];
1696
+ interactionAnswers?: Readonly<Record<string, JsonValue>>;
1603
1697
  }): Promise<InputRequiredCommit>;
1604
1698
  answerInput(input: {
1605
1699
  runId: RunId;
@@ -1608,6 +1702,12 @@ interface OwnedStore {
1608
1702
  input: UserInput;
1609
1703
  messageId?: MessageId;
1610
1704
  }): Promise<RunRecord>;
1705
+ answerInteraction(input: {
1706
+ runId: RunId;
1707
+ interactionId: string;
1708
+ expectedRevision: number;
1709
+ input: JsonValue;
1710
+ }): Promise<RunRecord>;
1611
1711
  commitOutcome(input: {
1612
1712
  runId: RunId;
1613
1713
  execution: ExecutionToken;
@@ -1644,7 +1744,7 @@ interface OwnedStore {
1644
1744
  execution: ExecutionToken;
1645
1745
  expectedRevision: number;
1646
1746
  toolCallId: ToolCallId;
1647
- result: ToolExecutionResult;
1747
+ result: ToolExecutionResult$1;
1648
1748
  state: "completed" | "failed" | "indeterminate";
1649
1749
  reason?: string;
1650
1750
  }): Promise<ToolCommit>;
@@ -1703,6 +1803,10 @@ interface AgentRun {
1703
1803
  requestId: InputRequestId;
1704
1804
  input: UserInput;
1705
1805
  }): Promise<void>;
1806
+ respondInteraction(input: {
1807
+ interactionId: string;
1808
+ input: JsonValue;
1809
+ }): Promise<void>;
1706
1810
  cancel(reason?: string): Promise<RunBoundary>;
1707
1811
  }
1708
1812
  interface AgentRuntime$1 {
@@ -1851,6 +1955,10 @@ declare class AgentRuntime implements AgentRuntime$1 {
1851
1955
  requestId: InputRequestId;
1852
1956
  input: UserInput;
1853
1957
  }): Promise<void>;
1958
+ respondInteraction(runId: RunId, input: {
1959
+ interactionId: string;
1960
+ input: JsonValue;
1961
+ }): Promise<void>;
1854
1962
  cancel(runId: RunId, reason?: string): Promise<RunBoundary>;
1855
1963
  private pump;
1856
1964
  private execute;
@@ -1973,6 +2081,8 @@ declare class InMemoryStore implements DurableStore {
1973
2081
  phase: string;
1974
2082
  prompt: AssistantMessage;
1975
2083
  checkpoint: ExecutionCheckpoint;
2084
+ interactions?: readonly PhaseInteraction[];
2085
+ interactionAnswers?: Readonly<Record<string, JsonValue>>;
1976
2086
  }): InputRequiredCommit;
1977
2087
  answerInput(lease: OwnerLease, input: {
1978
2088
  runId: RunId;
@@ -1981,6 +2091,12 @@ declare class InMemoryStore implements DurableStore {
1981
2091
  input: UserInput;
1982
2092
  messageId?: MessageId;
1983
2093
  }): RunRecord;
2094
+ answerInteraction(lease: OwnerLease, input: {
2095
+ runId: RunId;
2096
+ interactionId: string;
2097
+ expectedRevision: number;
2098
+ input: JsonValue;
2099
+ }): RunRecord;
1984
2100
  reserveToolCall(lease: OwnerLease, input: {
1985
2101
  runId: RunId;
1986
2102
  execution: ExecutionToken;
@@ -2014,7 +2130,7 @@ declare class InMemoryStore implements DurableStore {
2014
2130
  execution: ExecutionToken;
2015
2131
  expectedRevision: number;
2016
2132
  toolCallId: ToolCallId;
2017
- result: ToolExecutionResult;
2133
+ result: ToolExecutionResult$1;
2018
2134
  state: "completed" | "failed" | "indeterminate";
2019
2135
  reason?: string;
2020
2136
  }): ToolCommit;
@@ -2136,6 +2252,8 @@ declare class SqliteStore implements DurableStore {
2136
2252
  phase: string;
2137
2253
  prompt: AssistantMessage;
2138
2254
  checkpoint: ExecutionCheckpoint;
2255
+ interactions?: readonly PhaseInteraction[];
2256
+ interactionAnswers?: Readonly<Record<string, JsonValue>>;
2139
2257
  }): Promise<InputRequiredCommit>;
2140
2258
  answerInput(lease: OwnerLease, input: {
2141
2259
  runId: RunId;
@@ -2144,6 +2262,12 @@ declare class SqliteStore implements DurableStore {
2144
2262
  input: UserInput;
2145
2263
  messageId?: MessageId;
2146
2264
  }): Promise<RunRecord>;
2265
+ answerInteraction(lease: OwnerLease, input: {
2266
+ runId: RunId;
2267
+ interactionId: string;
2268
+ expectedRevision: number;
2269
+ input: JsonValue;
2270
+ }): Promise<RunRecord>;
2147
2271
  commitOutcome(lease: OwnerLease, input: {
2148
2272
  runId: RunId;
2149
2273
  execution: ExecutionToken;
@@ -2185,7 +2309,7 @@ declare class SqliteStore implements DurableStore {
2185
2309
  execution: ExecutionToken;
2186
2310
  expectedRevision: number;
2187
2311
  toolCallId: ToolCallId;
2188
- result: ToolExecutionResult;
2312
+ result: ToolExecutionResult$1;
2189
2313
  state: "completed" | "failed" | "indeterminate";
2190
2314
  reason?: string;
2191
2315
  }): Promise<ToolCommit>;
@@ -2399,4 +2523,4 @@ declare function parseFrontmatter<T = Record<string, unknown>>(raw: string): Fro
2399
2523
 
2400
2524
  declare function createCoreTools(input?: CoreToolContext): Tool[];
2401
2525
 
2402
- export { type AfterToolCall, type AgentConfig, type AgentConfigRequest, type AgentConfiguration, type AgentDefinition, type AgentId, type AgentListCursor, type AgentRecord, type AgentResources, type AgentRun, AgentRuntime, type AgentRuntimeOptions, type AgentSummary, type AnyRuntimeError, type AssistantContent, type AssistantMessage, type BeforeToolCall, type ConfigProvider, type ConfigPutResult, type ConfigResolution, type ConfigToken, type ConfigurationSnapshot, type ContextCandidate, type CoreToolContext, type DefinitionLayer, type DurableConsumer, type DurableRunEvent, type DurableStore, type DurableToolResult, type EventCursor, type EventId, type ExecutionCheckpoint, type ExecutionId, type ExecutionToken, type ExtensionAPI, type ExtensionActivationError, type ExtensionActivationResult, type ExtensionContribution, type ExtensionDisposer, type ExtensionFactory, type ExtensionFactoryResult, ExtensionLifetimeError, type ExtensionLifetimeErrorCode, type ExtensionLoadInput, type FrontmatterResult, type HistorySeed, type HookEvent, type HookEventType, type HookHandler, InMemoryConfigProvider, InMemoryStore, type InputRequest, type InputRequestId, type InputRequiredCommit, type JsonObject, type JsonPrimitive, type JsonValue, 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 OpaqueId, type Outcome, type OwnerLease, type OwnerToken, type Page, type Phase, type PhaseContext, type PhaseContribution, type PhaseExecutionIdentity, type PhaseInvocation, type PhaseOutput, type PhaseRegistry, type PhaseRegistrySelection, type PhaseState, type ResolvedResourceView, type ResourceDiagnostic, type ResourceKind, type ResourceRef, ResourceRegistry, ResourceRegistryError, type ResourceRegistryErrorCode, type ResourceSourceId, type ResourceView, type RetentionResult, type RunBoundary, type RunClaim, type RunEvent, type RunFailure, type RunId, type RunListCursor, type RunRecord, type RunSnapshot, type RunState, type RunStateChanged, type RunSummary, RuntimeBootstrapRegistry, RuntimeError, type RuntimeErrorCode, type RuntimeErrorDetails, RuntimeExtensionLifetime, type Skill, SqliteStore, type TextContent, type ThinkingContent, type Tool, type ToolCallId, type ToolCallSnapshot, type ToolCallState, type ToolContribution, type ToolDefinition, type ToolExecutionResult, type ToolInvocationContext, type ToolMessage, type ToolMessageContent, type ToolProgress, type ToolResultContent, type ToolStateChanged, type ToolUseContent, type UserContent, type UserInput, type UserMessage, brandConfigToken, createCoreTools, isRuntimeError, loadExtensionsFromPath as loadExtensions, loadPhase, loadPhases, loadSkill, loadSkills, materializeConfigurationSnapshot, parseAgentDefinition, parseFrontmatter, resolveConfigurationSnapshot };
2526
+ export { type AfterToolCall, type AgentConfig, type AgentConfigRequest, type AgentConfiguration, type AgentDefinition, type AgentId, type AgentListCursor, type AgentRecord, type AgentResources, type AgentRun, AgentRuntime, type AgentRuntimeOptions, type AgentSummary, type AnyRuntimeError, type AssistantContent, type AssistantMessage, type BeforeToolCall, type ConfigProvider, type ConfigPutResult, type ConfigResolution, type ConfigToken, type ConfigurationSnapshot, type ContextCandidate, type CoreToolContext, type DefinitionLayer, type DurableConsumer, type DurableRunEvent, type DurableStore, type DurableToolResult, type EventCursor, type EventId, type ExecutionCheckpoint, type ExecutionId, type ExecutionToken, type ExtensionAPI, type ExtensionActivationError, type ExtensionActivationResult, type ExtensionContribution, type ExtensionDisposer, type ExtensionFactory, type ExtensionFactoryResult, ExtensionLifetimeError, type ExtensionLifetimeErrorCode, type ExtensionLoadInput, type FrontmatterResult, type HistorySeed, type HookEvent, type HookEventType, type HookHandler, InMemoryConfigProvider, InMemoryStore, type InputRequest, type InputRequestId, type InputRequiredCommit, type JsonObject, type JsonPrimitive, type JsonValue, 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 OpaqueId, type Outcome, type OwnerLease, type OwnerToken, type Page, type Phase, type PhaseContext, type PhaseContribution, type PhaseExecution, type PhaseExecutionIdentity, type PhaseInteraction, PhaseInteractionBoundary, PhaseInteractionCancelledError, type PhaseInteractionDriver, type PhaseInteractionKind, type PhaseInteractionState, type PhaseInteractionStatus, type PhaseInvocation, type PhaseOutput, type PhaseRegistry, type PhaseRegistrySelection, type PhaseState, type ResolvedResourceView, type ResourceDiagnostic, type ResourceKind, type ResourceRef, ResourceRegistry, ResourceRegistryError, type ResourceRegistryErrorCode, type ResourceSourceId, type ResourceView, type RetentionResult, type RunBoundary, type RunClaim, type RunEvent, type RunFailure, type RunId, type RunListCursor, type RunRecord, type RunSnapshot, type RunState, type RunStateChanged, type RunSummary, RuntimeBootstrapRegistry, RuntimeError, type RuntimeErrorCode, type RuntimeErrorDetails, RuntimeExtensionLifetime, type Skill, SqliteStore, type TextContent, type ThinkingContent, type Tool, type ToolCallId, type ToolCallSnapshot, type ToolCallState, type ToolContribution, type ToolDefinition, type ToolExecutionResult$1 as ToolExecutionResult, type ToolInvocationContext, type ToolMessage, type ToolMessageContent, type ToolProgress, type ToolResultContent, type ToolStateChanged, type ToolUseContent, type UserContent, type UserInput, type UserMessage, brandConfigToken, createCoreTools, isRuntimeError, loadExtensionsFromPath as loadExtensions, loadPhase, loadPhases, loadSkill, loadSkills, materializeConfigurationSnapshot, parseAgentDefinition, parseFrontmatter, resolveConfigurationSnapshot };