@rowan-agent/agent 0.14.3 → 0.15.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 +807 -795
- package/dist/index.js +105 -48
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _rowan_agent_models from '@rowan-agent/models';
|
|
2
|
-
import { LlmContentPart,
|
|
2
|
+
import { LlmContentPart, ModelRef, ContentBlock, ModelConfig, StreamFn } from '@rowan-agent/models';
|
|
3
3
|
export { ModelConfig, ModelRef, StreamFn, ThinkingLevel } from '@rowan-agent/models';
|
|
4
4
|
import Type from 'typebox';
|
|
5
5
|
|
|
@@ -55,622 +55,279 @@ type ToolResult = {
|
|
|
55
55
|
error?: string;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
type
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/** Phase transition history. */
|
|
62
|
-
phaseTransitions: Array<{
|
|
63
|
-
from: string;
|
|
64
|
-
to: string;
|
|
65
|
-
ts: string;
|
|
66
|
-
}>;
|
|
67
|
-
/** Number of times compaction was triggered. */
|
|
68
|
-
compactionCount: number;
|
|
69
|
-
/** Number of retry attempts due to transient errors. */
|
|
70
|
-
retryCount: number;
|
|
71
|
-
/** Loop start timestamp. */
|
|
72
|
-
startedAt: string;
|
|
73
|
-
/** Loop start time as epoch ms (for duration calculation). */
|
|
74
|
-
startedAtMs: number;
|
|
75
|
-
/** Loop end timestamp (set on completion). */
|
|
76
|
-
endedAt?: string;
|
|
77
|
-
/** Total wall-clock duration in ms. */
|
|
78
|
-
durationMs?: number;
|
|
79
|
-
};
|
|
80
|
-
type ExecutionState = {
|
|
81
|
-
currentPhase: string;
|
|
82
|
-
attempt: number;
|
|
83
|
-
metrics: LoopMetrics;
|
|
84
|
-
status: "idle" | "running" | "suspended" | "completed" | "aborted" | "failed";
|
|
85
|
-
initialPhasePayload?: JsonValue;
|
|
86
|
-
continuation?: ExecutionContinuationState;
|
|
87
|
-
runInteractions?: RunInteractionState;
|
|
88
|
-
phaseInteractions?: RunInteractionState;
|
|
89
|
-
};
|
|
90
|
-
type ExecutionContinuationState = {
|
|
91
|
-
isContinuing: boolean;
|
|
92
|
-
previousPayload?: unknown;
|
|
93
|
-
previousResults: Array<{
|
|
94
|
-
name: string;
|
|
95
|
-
output?: unknown;
|
|
96
|
-
}>;
|
|
97
|
-
pendingInstruction?: string;
|
|
98
|
-
previousPhaseMessageId?: string;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
type RunInteractionKind = "user_input" | "permission" | "elicitation" | "confirmation";
|
|
102
|
-
type RunInteractionStatus = "pending" | "answered" | "replied" | "cancelled";
|
|
103
|
-
type RunInteraction = Readonly<{
|
|
104
|
-
id: string;
|
|
105
|
-
phase: string;
|
|
106
|
-
kind: RunInteractionKind;
|
|
107
|
-
prompt: string;
|
|
108
|
-
payload?: JsonValue;
|
|
109
|
-
createdAt: string;
|
|
110
|
-
status: RunInteractionStatus;
|
|
111
|
-
answer?: JsonValue;
|
|
112
|
-
reply?: string;
|
|
113
|
-
/** The Run is only waiting for the next user message, not asking a question. */
|
|
114
|
-
turnBoundary?: true;
|
|
115
|
-
toolCallId?: string;
|
|
116
|
-
result?: Readonly<{
|
|
117
|
-
answered?: string;
|
|
118
|
-
replied?: string;
|
|
119
|
-
cancelled?: string;
|
|
120
|
-
}>;
|
|
58
|
+
type PhaseRegistrySelection = Readonly<{
|
|
59
|
+
entryPhaseId: string | null;
|
|
60
|
+
phaseIds: readonly string[];
|
|
121
61
|
}>;
|
|
122
|
-
type
|
|
123
|
-
|
|
124
|
-
|
|
62
|
+
type AgentDefinition = Readonly<{
|
|
63
|
+
name: string;
|
|
64
|
+
description: string;
|
|
125
65
|
prompt: string;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}>;
|
|
134
|
-
type RunInteractionState = Readonly<{
|
|
135
|
-
requests: readonly RunInteraction[];
|
|
136
|
-
answers: Readonly<Record<string, JsonValue>>;
|
|
137
|
-
checkpoint?: JsonValue;
|
|
138
|
-
}>;
|
|
139
|
-
type RunInteractionDriver = Readonly<{
|
|
140
|
-
signal: AbortSignal;
|
|
141
|
-
request(input: RunInteractionRequest): RunInteraction;
|
|
142
|
-
pending(): readonly RunInteraction[];
|
|
143
|
-
answers(): ReadonlyMap<string, JsonValue>;
|
|
144
|
-
checkpoint(): JsonValue | undefined;
|
|
145
|
-
clearCheckpoint(): void;
|
|
146
|
-
suspend(input?: Readonly<{
|
|
147
|
-
checkpoint?: JsonValue;
|
|
148
|
-
}>): never;
|
|
66
|
+
tools?: readonly string[];
|
|
67
|
+
skills?: readonly string[];
|
|
68
|
+
/** Host-supplied Skills private to this Agent Definition/Bundle. */
|
|
69
|
+
bundledSkills?: readonly Skill[];
|
|
70
|
+
phases?: PhaseRegistrySelection;
|
|
71
|
+
contexts?: readonly string[];
|
|
72
|
+
model?: ModelRef;
|
|
149
73
|
}>;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
constructor();
|
|
153
|
-
}
|
|
154
|
-
declare class RunInteractionBoundary extends Error {
|
|
155
|
-
readonly state: ExecutionState;
|
|
156
|
-
readonly interactions: readonly RunInteraction[];
|
|
157
|
-
constructor(state: ExecutionState, interactions: readonly RunInteraction[]);
|
|
158
|
-
}
|
|
74
|
+
/** Parse one Markdown definition using the same frontmatter vocabulary as Phase resources. */
|
|
75
|
+
declare function parseAgentDefinition(raw: string): AgentDefinition;
|
|
159
76
|
|
|
160
|
-
|
|
161
|
-
type
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
type
|
|
165
|
-
type
|
|
166
|
-
type
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
type ConfigToken = OpaqueId<"ConfigToken">;
|
|
172
|
-
type OwnerToken = OpaqueId<"OwnerToken">;
|
|
173
|
-
type EventCursor = OpaqueId<"EventCursor">;
|
|
174
|
-
type AgentListCursor = OpaqueId<"AgentListCursor">;
|
|
175
|
-
type RunListCursor = OpaqueId<"RunListCursor">;
|
|
176
|
-
type JsonPrimitive = null | boolean | number | string;
|
|
177
|
-
type JsonValue = JsonPrimitive | readonly JsonValue[] | {
|
|
178
|
-
readonly [key: string]: JsonValue;
|
|
179
|
-
};
|
|
180
|
-
type JsonObject = Readonly<Record<string, JsonValue>>;
|
|
181
|
-
type Metadata = JsonObject;
|
|
182
|
-
type TextContent = Readonly<{
|
|
183
|
-
type: "text";
|
|
184
|
-
text: string;
|
|
185
|
-
}>;
|
|
186
|
-
type ImageContent = Readonly<{
|
|
187
|
-
type: "image";
|
|
188
|
-
data: string;
|
|
189
|
-
mimeType: string;
|
|
190
|
-
}>;
|
|
191
|
-
type ThinkingContent = Readonly<{
|
|
192
|
-
type: "thinking";
|
|
193
|
-
thinking: string;
|
|
194
|
-
signature?: string;
|
|
77
|
+
type ResourceKind = "agent" | "tool" | "skill" | "phase";
|
|
78
|
+
type ResourceSourceId = string;
|
|
79
|
+
/** Rowan-native contribution aliases. Hosts may adapt their domain handlers to
|
|
80
|
+
* these existing Tool/Phase lifecycles without importing host Scope types. */
|
|
81
|
+
type ToolContribution = Tool$1;
|
|
82
|
+
type PhaseContribution = Phase;
|
|
83
|
+
type ResourceView = Readonly<{
|
|
84
|
+
agents: readonly ResourceSourceId[];
|
|
85
|
+
tools: readonly ResourceSourceId[];
|
|
86
|
+
skills: readonly ResourceSourceId[];
|
|
87
|
+
phases: readonly ResourceSourceId[];
|
|
195
88
|
}>;
|
|
196
|
-
type
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
/** Provider/model correlation, retained only to reconstruct the next request. */
|
|
200
|
-
providerToolCallId?: string;
|
|
89
|
+
type ResourceRef = Readonly<{
|
|
90
|
+
kind: ResourceKind;
|
|
91
|
+
sourceId: ResourceSourceId;
|
|
201
92
|
name: string;
|
|
202
|
-
input: JsonValue;
|
|
203
|
-
}>;
|
|
204
|
-
type ToolExecutionResult$1 = Readonly<{
|
|
205
|
-
ok: true;
|
|
206
|
-
content: JsonValue;
|
|
207
|
-
}> | Readonly<{
|
|
208
|
-
ok: false;
|
|
209
|
-
content: JsonValue;
|
|
210
|
-
error: string;
|
|
211
|
-
}>;
|
|
212
|
-
type DurableToolResult = Readonly<{
|
|
213
|
-
toolCallId: ToolCallId;
|
|
214
|
-
toolName: string;
|
|
215
|
-
}> & ToolExecutionResult$1;
|
|
216
|
-
type ToolResultContent = Readonly<{
|
|
217
|
-
type: "tool_result";
|
|
218
|
-
toolCallId: ToolCallId;
|
|
219
|
-
/** Provider/model correlation, retained only to reconstruct the next request. */
|
|
220
|
-
providerToolCallId?: string;
|
|
221
|
-
result: ToolExecutionResult$1;
|
|
222
|
-
}>;
|
|
223
|
-
type UserContent = string | readonly (TextContent | ImageContent)[];
|
|
224
|
-
type AssistantContent = string | readonly (TextContent | ThinkingContent | ToolUseContent)[];
|
|
225
|
-
type ToolMessageContent = readonly [ToolResultContent, ...ToolResultContent[]];
|
|
226
|
-
type MessageContent = UserContent | AssistantContent | ToolMessageContent;
|
|
227
|
-
type MessageBase = Readonly<{
|
|
228
|
-
id: MessageId;
|
|
229
|
-
agentId: AgentId;
|
|
230
|
-
runId: RunId;
|
|
231
|
-
/** Monotonic active revision. Omitted on legacy/initial messages and read as 0. */
|
|
232
|
-
messageRevision?: number;
|
|
233
|
-
metadata?: Metadata;
|
|
234
|
-
sequenceWithinRun: number;
|
|
235
|
-
createdAt: string;
|
|
236
|
-
}>;
|
|
237
|
-
type UserMessage = MessageBase & Readonly<{
|
|
238
|
-
role: "user";
|
|
239
|
-
content: UserContent;
|
|
240
93
|
}>;
|
|
241
|
-
type
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
94
|
+
type ResourceDiagnostic = Readonly<{
|
|
95
|
+
kind: "invalid" | "missing" | "collision";
|
|
96
|
+
sourceId: ResourceSourceId;
|
|
97
|
+
message: string;
|
|
98
|
+
path?: string;
|
|
245
99
|
}>;
|
|
246
|
-
type
|
|
247
|
-
|
|
248
|
-
|
|
100
|
+
type LoadResult = Readonly<{
|
|
101
|
+
revision: string;
|
|
102
|
+
registered: readonly ResourceRef[];
|
|
103
|
+
skipped: readonly ResourceDiagnostic[];
|
|
249
104
|
}>;
|
|
250
|
-
type
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
prompt: string;
|
|
255
|
-
phase: string;
|
|
256
|
-
status: "answered" | "replied" | "cancelled";
|
|
257
|
-
answer?: JsonValue;
|
|
258
|
-
reply?: string;
|
|
259
|
-
toolCallId?: ToolCallId;
|
|
260
|
-
result?: Readonly<{
|
|
261
|
-
answered?: string;
|
|
262
|
-
replied?: string;
|
|
263
|
-
cancelled?: string;
|
|
264
|
-
}>;
|
|
105
|
+
type LoadInput<T> = Readonly<{
|
|
106
|
+
sourceId: ResourceSourceId;
|
|
107
|
+
directory?: string;
|
|
108
|
+
values?: readonly T[];
|
|
265
109
|
}>;
|
|
266
|
-
type
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
110
|
+
type ResolvedResourceView = Readonly<{
|
|
111
|
+
agents: readonly AgentDefinition[];
|
|
112
|
+
tools: readonly Tool$1[];
|
|
113
|
+
skills: readonly Skill[];
|
|
114
|
+
phases: readonly Phase[];
|
|
115
|
+
revisions: Readonly<Record<ResourceKind, readonly string[]>>;
|
|
116
|
+
refs: Readonly<Record<ResourceKind, readonly ResourceRef[]>>;
|
|
272
117
|
}>;
|
|
273
|
-
type
|
|
274
|
-
|
|
275
|
-
code:
|
|
276
|
-
message: string;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}>
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}>;
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
118
|
+
type ResourceRegistryErrorCode = "invalid_source_id" | "invalid_resource_name" | "resource_collision" | "resource_input_missing" | "resource_directory_not_supported" | "unknown_resource_source" | "implicit_source_protected";
|
|
119
|
+
declare class ResourceRegistryError extends Error {
|
|
120
|
+
readonly code: ResourceRegistryErrorCode;
|
|
121
|
+
constructor(code: ResourceRegistryErrorCode, message: string);
|
|
122
|
+
}
|
|
123
|
+
type RegistryValue = AgentDefinition | Tool$1 | Skill | Phase;
|
|
124
|
+
/**
|
|
125
|
+
* Runtime Resource Registry source transaction and view resolver.
|
|
126
|
+
*
|
|
127
|
+
* Directory normalization is intentionally added by the typed loader slice;
|
|
128
|
+
* this first module owns only the atomic source/revision/collision semantics.
|
|
129
|
+
*/
|
|
130
|
+
declare class ResourceRegistry {
|
|
131
|
+
private readonly sources;
|
|
132
|
+
/** Sources registered by the bootstrap boundary (currently Extensions). */
|
|
133
|
+
private readonly implicitSources;
|
|
134
|
+
private revisionSequence;
|
|
135
|
+
loadAgents(input: LoadInput<AgentDefinition>): Promise<LoadResult>;
|
|
136
|
+
loadSkills(input: LoadInput<Skill>): Promise<LoadResult>;
|
|
137
|
+
loadPhases(input: LoadInput<Phase>): Promise<LoadResult>;
|
|
138
|
+
loadTools(input: Readonly<{
|
|
139
|
+
sourceId: ResourceSourceId;
|
|
140
|
+
values: readonly ToolContribution[];
|
|
141
|
+
}>): Promise<LoadResult>;
|
|
142
|
+
unload(input: Readonly<{
|
|
143
|
+
kind: ResourceKind;
|
|
144
|
+
sourceId: ResourceSourceId;
|
|
145
|
+
}>): Promise<LoadResult>;
|
|
146
|
+
resolveView(view: ResourceView): ResolvedResourceView;
|
|
147
|
+
/** Mark one already-loaded source as implicit for every Resource View. */
|
|
148
|
+
protected markImplicit(kind: ResourceKind, sourceId: ResourceSourceId): void;
|
|
149
|
+
/** Bootstrap-only helper for replacing an implicit contribution source. */
|
|
150
|
+
protected replaceImplicit<T extends RegistryValue>(kind: ResourceKind, sourceId: ResourceSourceId, values: readonly T[]): Promise<LoadResult>;
|
|
151
|
+
protected hasImplicit(kind: ResourceKind, sourceId: ResourceSourceId): boolean;
|
|
152
|
+
private withImplicit;
|
|
153
|
+
private collect;
|
|
154
|
+
private commit;
|
|
155
|
+
private resolveKind;
|
|
156
|
+
private resolveRevisions;
|
|
157
|
+
private resolveRefs;
|
|
158
|
+
private sourcesFor;
|
|
159
|
+
private nextRevision;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
type ModelInvokeOutput = {
|
|
163
|
+
text: string;
|
|
164
|
+
contentBlocks: ContentBlock[];
|
|
165
|
+
toolCalls: ToolCall[];
|
|
166
|
+
stopReason?: string;
|
|
167
|
+
};
|
|
168
|
+
/** Snapshot of phase-level context for restore */
|
|
169
|
+
type PhaseContextSnapshot = {
|
|
170
|
+
systemPrompt: string;
|
|
171
|
+
messages: AgentMessage[];
|
|
172
|
+
currentPhase: string;
|
|
173
|
+
availablePhases: string[];
|
|
174
|
+
turnNumber: number;
|
|
175
|
+
payload?: unknown;
|
|
176
|
+
};
|
|
177
|
+
/** Execution capabilities for a phase — operates on PhaseContext. */
|
|
178
|
+
type PhaseExecution = {
|
|
179
|
+
snapshot(): PhaseContextSnapshot;
|
|
180
|
+
restore(snapshot: PhaseContextSnapshot): void;
|
|
181
|
+
invokeModel(context: PhaseContext, options?: {
|
|
182
|
+
output?: "reply" | "internal";
|
|
183
|
+
}): Promise<ModelInvokeOutput>;
|
|
184
|
+
reportStatus(status: PhaseStatus): Promise<void>;
|
|
185
|
+
executeTool(context: AgentContext, toolCall: ToolCall): Promise<ToolResult>;
|
|
186
|
+
executeTools(context: AgentContext, toolCalls: readonly ToolCall[], contentBlocks?: readonly ContentBlock[]): Promise<readonly ToolResult[]>;
|
|
187
|
+
interaction: RunInteractionDriver;
|
|
188
|
+
/** Message lifecycle manager for streaming updates from programmatic phases */
|
|
189
|
+
messages: PhaseMessageManager;
|
|
190
|
+
};
|
|
191
|
+
/** Message lifecycle manager for streaming updates */
|
|
192
|
+
type PhaseMessageManager = {
|
|
193
|
+
/** Get all visible messages in the transcript */
|
|
194
|
+
visible(): AgentMessage[];
|
|
195
|
+
/** Reserve the eventual message identity before stream deltas arrive. */
|
|
196
|
+
reserve(role: "assistant" | "tool", metadata?: Record<string, unknown>): string;
|
|
197
|
+
/** Start a new message stream, returns message id */
|
|
198
|
+
start(role: "assistant" | "tool", content: AgentMessage["content"], metadata?: Record<string, unknown>): string;
|
|
199
|
+
/** Stream a text delta */
|
|
200
|
+
update(messageId: string, delta: string): Promise<void>;
|
|
201
|
+
/** Replace the active message content with model-native content parts */
|
|
202
|
+
replaceContent(messageId: string, content: string | LlmContentPart[]): void;
|
|
203
|
+
/** End the message stream, appends to transcript */
|
|
204
|
+
end(messageId: string): Promise<void>;
|
|
205
|
+
/** Drop an unstarted stream that produced no content. */
|
|
206
|
+
discard(messageId: string): void;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
interface SourceInfo {
|
|
210
|
+
source: string;
|
|
211
|
+
baseDir?: string;
|
|
212
|
+
displayName?: string;
|
|
213
|
+
}
|
|
214
|
+
/** Register a Phase by directory path or Phase object; PHASE.md and direct child Skills are loaded atomically when a path is supplied. */
|
|
215
|
+
type PhaseRegistration = string | Phase;
|
|
216
|
+
/**
|
|
217
|
+
* Tool definition for registering LLM-callable tools via `api.tool.register()`.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* api.tool.register({
|
|
222
|
+
* name: "search_docs",
|
|
223
|
+
* description: "Search documentation",
|
|
224
|
+
* parameters: { type: "object", properties: { query: { type: "string" } } },
|
|
225
|
+
* execute: async (args, ctx) => {
|
|
226
|
+
* return { content: [{ type: "text", text: "result" }] };
|
|
227
|
+
* },
|
|
228
|
+
* });
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
interface ToolDefinition {
|
|
232
|
+
/** Tool name (used in LLM tool calls) */
|
|
315
233
|
name: string;
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
234
|
+
/** Description for LLM */
|
|
235
|
+
description: string;
|
|
236
|
+
/** Parameter schema (JSON Schema) */
|
|
237
|
+
parameters: Record<string, unknown>;
|
|
238
|
+
/** Execute the tool */
|
|
239
|
+
execute: (args: unknown, context: ToolInvocationContext, signal?: AbortSignal) => Promise<ToolExecutionResult$1>;
|
|
240
|
+
/** Optional: per-tool execution mode override */
|
|
241
|
+
executionMode?: "sequential" | "parallel";
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Result from tool execution.
|
|
245
|
+
*/
|
|
246
|
+
interface ToolExecutionResult$1 {
|
|
247
|
+
/** Content blocks to return to the LLM */
|
|
248
|
+
content: Array<{
|
|
249
|
+
type: string;
|
|
250
|
+
text?: string;
|
|
251
|
+
[key: string]: unknown;
|
|
334
252
|
}>;
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
253
|
+
/** Whether this is an error result */
|
|
254
|
+
isError?: boolean;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Registered tool with source metadata.
|
|
258
|
+
*/
|
|
259
|
+
interface RegisteredTool {
|
|
260
|
+
definition: ToolDefinition;
|
|
261
|
+
sourceInfo: SourceInfo;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Structured extension error with attribution.
|
|
265
|
+
*/
|
|
266
|
+
interface ExtensionError {
|
|
267
|
+
/** Path of the extension that caused the error */
|
|
268
|
+
extensionPath: string;
|
|
269
|
+
/** Event or operation that caused the error */
|
|
270
|
+
event: string;
|
|
271
|
+
/** Error message */
|
|
272
|
+
error: string;
|
|
273
|
+
/** Optional stack trace */
|
|
274
|
+
stack?: string;
|
|
275
|
+
}
|
|
276
|
+
/** Error listener callback type. */
|
|
277
|
+
type ExtensionErrorListener = (error: ExtensionError) => void;
|
|
278
|
+
type ExecOptions = {
|
|
279
|
+
/** Working directory for the command. Defaults to cwd passed to runtime. */
|
|
280
|
+
cwd?: string;
|
|
281
|
+
/** Environment variables to add/override. */
|
|
282
|
+
env?: Record<string, string>;
|
|
283
|
+
/** Timeout in milliseconds. */
|
|
284
|
+
timeout?: number;
|
|
285
|
+
/** AbortSignal for cancellation. */
|
|
286
|
+
signal?: AbortSignal;
|
|
287
|
+
};
|
|
288
|
+
type ExecResult = {
|
|
289
|
+
exitCode: number;
|
|
290
|
+
stdout: string;
|
|
291
|
+
stderr: string;
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Shared runtime state created by loader, used during registration and runtime.
|
|
295
|
+
* All ExtensionAPI instances reference this shared state.
|
|
296
|
+
*
|
|
297
|
+
* It only owns the lifetime guard shared by captured Extension API objects.
|
|
298
|
+
*/
|
|
299
|
+
interface ExtensionRuntime {
|
|
300
|
+
/** Throws when this extension instance is stale after runtime replacement. */
|
|
301
|
+
assertActive: () => void;
|
|
302
|
+
/** Marks this extension instance as stale after runtime replacement or reload. */
|
|
303
|
+
invalidate: (message?: string) => void;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Result of loading extensions from filesystem.
|
|
307
|
+
* The runner takes these and creates Extension tracking objects.
|
|
308
|
+
*/
|
|
309
|
+
type LoadExtensionsResult = {
|
|
310
|
+
extensions: LoadedExtension[];
|
|
311
|
+
errors: Array<{
|
|
312
|
+
path: string;
|
|
313
|
+
error: string;
|
|
340
314
|
}>;
|
|
341
|
-
resultMessageId: MessageId;
|
|
342
|
-
reason: string;
|
|
343
|
-
}>);
|
|
344
|
-
type DurableEventBase = Readonly<{
|
|
345
|
-
id: EventId;
|
|
346
|
-
schemaVersion: 1;
|
|
347
|
-
cursor: EventCursor;
|
|
348
|
-
durability: "durable";
|
|
349
|
-
agentId: AgentId;
|
|
350
|
-
runId: RunId;
|
|
351
|
-
runRevision: number;
|
|
352
|
-
metadata?: Metadata;
|
|
353
|
-
createdAt: string;
|
|
354
|
-
}>;
|
|
355
|
-
type PhaseEntered = DurableEventBase & Readonly<{
|
|
356
|
-
kind: "phase_entered";
|
|
357
|
-
executionId: ExecutionId;
|
|
358
|
-
phaseId: string;
|
|
359
|
-
visit: number;
|
|
360
|
-
}>;
|
|
361
|
-
type MessageCommitted = DurableEventBase & Readonly<{
|
|
362
|
-
kind: "message_committed";
|
|
363
|
-
message: Message;
|
|
364
|
-
}>;
|
|
365
|
-
type MessageRevised = DurableEventBase & Readonly<{
|
|
366
|
-
kind: "message_revised";
|
|
367
|
-
message: UserMessage;
|
|
368
|
-
previousRevision: number;
|
|
369
|
-
invalidatedRunIds: readonly RunId[];
|
|
370
|
-
targetRunId: RunId;
|
|
371
|
-
cutoffSequenceWithinRun: number;
|
|
372
|
-
}>;
|
|
373
|
-
type RunStateChanged = DurableEventBase & (Readonly<{
|
|
374
|
-
kind: "run_state_changed";
|
|
375
|
-
from: null;
|
|
376
|
-
to: "queued";
|
|
377
|
-
}> | Readonly<{
|
|
378
|
-
kind: "run_state_changed";
|
|
379
|
-
from: "input_required";
|
|
380
|
-
to: "queued";
|
|
381
|
-
}> | Readonly<{
|
|
382
|
-
kind: "run_state_changed";
|
|
383
|
-
from: "queued";
|
|
384
|
-
to: "running";
|
|
385
|
-
}> | Readonly<{
|
|
386
|
-
kind: "run_state_changed";
|
|
387
|
-
from: "running";
|
|
388
|
-
to: "input_required";
|
|
389
|
-
interactions: readonly RunInteraction[];
|
|
390
|
-
answers: Readonly<Record<string, JsonValue>>;
|
|
391
|
-
}> | Readonly<{
|
|
392
|
-
kind: "run_state_changed";
|
|
393
|
-
from: "running";
|
|
394
|
-
to: "completed";
|
|
395
|
-
outcome: Outcome;
|
|
396
|
-
output?: AssistantMessage;
|
|
397
|
-
}> | Readonly<{
|
|
398
|
-
kind: "run_state_changed";
|
|
399
|
-
from: "queued";
|
|
400
|
-
to: "failed";
|
|
401
|
-
failure: QueuedRunFailure;
|
|
402
|
-
}> | Readonly<{
|
|
403
|
-
kind: "run_state_changed";
|
|
404
|
-
from: "running";
|
|
405
|
-
to: "failed";
|
|
406
|
-
failure: RunningRunFailure;
|
|
407
|
-
}> | Readonly<{
|
|
408
|
-
kind: "run_state_changed";
|
|
409
|
-
from: "queued" | "running" | "input_required";
|
|
410
|
-
to: "cancelled";
|
|
411
|
-
reason?: string;
|
|
412
|
-
}>);
|
|
413
|
-
type ToolStateChanged = DurableEventBase & (Readonly<{
|
|
414
|
-
kind: "tool_state_changed";
|
|
415
|
-
transition: Readonly<{
|
|
416
|
-
from: null;
|
|
417
|
-
to: "pending";
|
|
418
|
-
}>;
|
|
419
|
-
toolCall: Extract<ToolCallSnapshot, {
|
|
420
|
-
state: "pending";
|
|
421
|
-
}>;
|
|
422
|
-
}> | Readonly<{
|
|
423
|
-
kind: "tool_state_changed";
|
|
424
|
-
transition: Readonly<{
|
|
425
|
-
from: "pending";
|
|
426
|
-
to: "running";
|
|
427
|
-
}>;
|
|
428
|
-
toolCall: Extract<ToolCallSnapshot, {
|
|
429
|
-
state: "running";
|
|
430
|
-
}>;
|
|
431
|
-
}> | Readonly<{
|
|
432
|
-
kind: "tool_state_changed";
|
|
433
|
-
transition: Readonly<{
|
|
434
|
-
from: "pending";
|
|
435
|
-
to: "failed";
|
|
436
|
-
}>;
|
|
437
|
-
toolCall: Extract<ToolCallSnapshot, {
|
|
438
|
-
state: "failed";
|
|
439
|
-
}>;
|
|
440
|
-
}> | Readonly<{
|
|
441
|
-
kind: "tool_state_changed";
|
|
442
|
-
transition: Readonly<{
|
|
443
|
-
from: "running";
|
|
444
|
-
to: "pending";
|
|
445
|
-
}>;
|
|
446
|
-
toolCall: Extract<ToolCallSnapshot, {
|
|
447
|
-
state: "pending";
|
|
448
|
-
}>;
|
|
449
|
-
}> | Readonly<{
|
|
450
|
-
kind: "tool_state_changed";
|
|
451
|
-
transition: Readonly<{
|
|
452
|
-
from: "running";
|
|
453
|
-
to: "pending";
|
|
454
|
-
}>;
|
|
455
|
-
toolCall: Extract<ToolCallSnapshot, {
|
|
456
|
-
state: "pending";
|
|
457
|
-
}>;
|
|
458
|
-
}> | Readonly<{
|
|
459
|
-
kind: "tool_state_changed";
|
|
460
|
-
transition: Readonly<{
|
|
461
|
-
from: "running";
|
|
462
|
-
to: "completed";
|
|
463
|
-
}>;
|
|
464
|
-
toolCall: Extract<ToolCallSnapshot, {
|
|
465
|
-
state: "completed";
|
|
466
|
-
}>;
|
|
467
|
-
}> | Readonly<{
|
|
468
|
-
kind: "tool_state_changed";
|
|
469
|
-
transition: Readonly<{
|
|
470
|
-
from: "running";
|
|
471
|
-
to: "failed";
|
|
472
|
-
}>;
|
|
473
|
-
toolCall: Extract<ToolCallSnapshot, {
|
|
474
|
-
state: "failed";
|
|
475
|
-
}>;
|
|
476
|
-
}> | Readonly<{
|
|
477
|
-
kind: "tool_state_changed";
|
|
478
|
-
transition: Readonly<{
|
|
479
|
-
from: "running";
|
|
480
|
-
to: "indeterminate";
|
|
481
|
-
}>;
|
|
482
|
-
toolCall: Extract<ToolCallSnapshot, {
|
|
483
|
-
state: "indeterminate";
|
|
484
|
-
}>;
|
|
485
|
-
}>);
|
|
486
|
-
type DurableRunEvent = PhaseEntered | MessageCommitted | MessageRevised | RunStateChanged | ToolStateChanged;
|
|
487
|
-
type MessageDelta = Readonly<{
|
|
488
|
-
kind: "message_delta";
|
|
489
|
-
durability: "transient";
|
|
490
|
-
runId: RunId;
|
|
491
|
-
executionId: ExecutionId;
|
|
492
|
-
messageId: MessageId;
|
|
493
|
-
offset: number;
|
|
494
|
-
text: string;
|
|
495
|
-
}>;
|
|
496
|
-
type ThinkingDelta = Readonly<{
|
|
497
|
-
kind: "thinking_delta";
|
|
498
|
-
durability: "transient";
|
|
499
|
-
runId: RunId;
|
|
500
|
-
executionId: ExecutionId;
|
|
501
|
-
messageId: MessageId;
|
|
502
|
-
blockIndex: number;
|
|
503
|
-
offset: number;
|
|
504
|
-
text: string;
|
|
505
|
-
}>;
|
|
506
|
-
type ToolProgress = Readonly<{
|
|
507
|
-
kind: "tool_progress";
|
|
508
|
-
durability: "transient";
|
|
509
|
-
runId: RunId;
|
|
510
|
-
executionId: ExecutionId;
|
|
511
|
-
toolCallId: ToolCallId;
|
|
512
|
-
progress: JsonValue;
|
|
513
|
-
}>;
|
|
514
|
-
type PhaseStatusEvent = Readonly<{
|
|
515
|
-
kind: "phase_status";
|
|
516
|
-
durability: "transient";
|
|
517
|
-
runId: RunId;
|
|
518
|
-
executionId: ExecutionId;
|
|
519
|
-
phaseId: string;
|
|
520
|
-
status: PhaseStatus;
|
|
521
|
-
}>;
|
|
522
|
-
type RunEvent = DurableRunEvent | MessageDelta | ThinkingDelta | ToolProgress | PhaseStatusEvent;
|
|
523
|
-
|
|
524
|
-
type ModelInvokeOutput = {
|
|
525
|
-
text: string;
|
|
526
|
-
contentBlocks: ContentBlock[];
|
|
527
|
-
toolCalls: ToolCall[];
|
|
528
|
-
stopReason?: string;
|
|
529
|
-
};
|
|
530
|
-
/** Snapshot of phase-level context for restore */
|
|
531
|
-
type PhaseContextSnapshot = {
|
|
532
|
-
systemPrompt: string;
|
|
533
|
-
messages: AgentMessage[];
|
|
534
|
-
currentPhase: string;
|
|
535
|
-
availablePhases: string[];
|
|
536
|
-
turnNumber: number;
|
|
537
|
-
payload?: unknown;
|
|
538
315
|
};
|
|
539
|
-
/**
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}): Promise<ModelInvokeOutput>;
|
|
546
|
-
reportStatus(status: PhaseStatus): Promise<void>;
|
|
547
|
-
executeTool(context: AgentContext, toolCall: ToolCall): Promise<ToolResult>;
|
|
548
|
-
executeTools(context: AgentContext, toolCalls: readonly ToolCall[], contentBlocks?: readonly ContentBlock[]): Promise<readonly ToolResult[]>;
|
|
549
|
-
interaction: RunInteractionDriver;
|
|
550
|
-
/** Message lifecycle manager for streaming updates from programmatic phases */
|
|
551
|
-
messages: PhaseMessageManager;
|
|
552
|
-
};
|
|
553
|
-
/** Message lifecycle manager for streaming updates */
|
|
554
|
-
type PhaseMessageManager = {
|
|
555
|
-
/** Get all visible messages in the transcript */
|
|
556
|
-
visible(): AgentMessage[];
|
|
557
|
-
/** Reserve the eventual message identity before stream deltas arrive. */
|
|
558
|
-
reserve(role: "assistant" | "tool", metadata?: Record<string, unknown>): string;
|
|
559
|
-
/** Start a new message stream, returns message id */
|
|
560
|
-
start(role: "assistant" | "tool", content: AgentMessage["content"], metadata?: Record<string, unknown>): string;
|
|
561
|
-
/** Stream a text delta */
|
|
562
|
-
update(messageId: string, delta: string): Promise<void>;
|
|
563
|
-
/** Replace the active message content with model-native content parts */
|
|
564
|
-
replaceContent(messageId: string, content: string | LlmContentPart[]): void;
|
|
565
|
-
/** End the message stream, appends to transcript */
|
|
566
|
-
end(messageId: string): Promise<void>;
|
|
567
|
-
/** Drop an unstarted stream that produced no content. */
|
|
568
|
-
discard(messageId: string): void;
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
type PhaseRegistrySelection = Readonly<{
|
|
572
|
-
entryPhaseId: string | null;
|
|
573
|
-
phaseIds: readonly string[];
|
|
574
|
-
}>;
|
|
575
|
-
type AgentDefinition = Readonly<{
|
|
316
|
+
/**
|
|
317
|
+
* Pre-initialization extension form — factory + metadata.
|
|
318
|
+
* Runner.loadExtensions() calls the factory and creates the full Extension object.
|
|
319
|
+
*/
|
|
320
|
+
interface LoadedExtension {
|
|
321
|
+
path: string;
|
|
576
322
|
name: string;
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
model?: ModelRef;
|
|
586
|
-
}>;
|
|
587
|
-
/** Parse one Markdown definition using the same frontmatter vocabulary as Phase resources. */
|
|
588
|
-
declare function parseAgentDefinition(raw: string): AgentDefinition;
|
|
589
|
-
|
|
590
|
-
type ResourceKind = "agent" | "tool" | "skill" | "phase";
|
|
591
|
-
type ResourceSourceId = string;
|
|
592
|
-
/** Rowan-native contribution aliases. Hosts may adapt their domain handlers to
|
|
593
|
-
* these existing Tool/Phase lifecycles without importing host Scope types. */
|
|
594
|
-
type ToolContribution = Tool$1;
|
|
595
|
-
type PhaseContribution = Phase;
|
|
596
|
-
type ResourceView = Readonly<{
|
|
597
|
-
agents: readonly ResourceSourceId[];
|
|
598
|
-
tools: readonly ResourceSourceId[];
|
|
599
|
-
skills: readonly ResourceSourceId[];
|
|
600
|
-
phases: readonly ResourceSourceId[];
|
|
601
|
-
}>;
|
|
602
|
-
type ResourceRef = Readonly<{
|
|
603
|
-
kind: ResourceKind;
|
|
604
|
-
sourceId: ResourceSourceId;
|
|
605
|
-
name: string;
|
|
606
|
-
}>;
|
|
607
|
-
type ResourceDiagnostic = Readonly<{
|
|
608
|
-
kind: "invalid" | "missing" | "collision";
|
|
609
|
-
sourceId: ResourceSourceId;
|
|
610
|
-
message: string;
|
|
611
|
-
path?: string;
|
|
612
|
-
}>;
|
|
613
|
-
type LoadResult = Readonly<{
|
|
614
|
-
revision: string;
|
|
615
|
-
registered: readonly ResourceRef[];
|
|
616
|
-
skipped: readonly ResourceDiagnostic[];
|
|
617
|
-
}>;
|
|
618
|
-
type LoadInput<T> = Readonly<{
|
|
619
|
-
sourceId: ResourceSourceId;
|
|
620
|
-
directory?: string;
|
|
621
|
-
values?: readonly T[];
|
|
622
|
-
}>;
|
|
623
|
-
type ResolvedResourceView = Readonly<{
|
|
624
|
-
agents: readonly AgentDefinition[];
|
|
625
|
-
tools: readonly Tool$1[];
|
|
626
|
-
skills: readonly Skill[];
|
|
627
|
-
phases: readonly Phase[];
|
|
628
|
-
revisions: Readonly<Record<ResourceKind, readonly string[]>>;
|
|
629
|
-
refs: Readonly<Record<ResourceKind, readonly ResourceRef[]>>;
|
|
630
|
-
}>;
|
|
631
|
-
type ResourceRegistryErrorCode = "invalid_source_id" | "invalid_resource_name" | "resource_collision" | "resource_input_missing" | "resource_directory_not_supported" | "unknown_resource_source" | "implicit_source_protected";
|
|
632
|
-
declare class ResourceRegistryError extends Error {
|
|
633
|
-
readonly code: ResourceRegistryErrorCode;
|
|
634
|
-
constructor(code: ResourceRegistryErrorCode, message: string);
|
|
635
|
-
}
|
|
636
|
-
type RegistryValue = AgentDefinition | Tool$1 | Skill | Phase;
|
|
637
|
-
/**
|
|
638
|
-
* Runtime Resource Registry source transaction and view resolver.
|
|
639
|
-
*
|
|
640
|
-
* Directory normalization is intentionally added by the typed loader slice;
|
|
641
|
-
* this first module owns only the atomic source/revision/collision semantics.
|
|
642
|
-
*/
|
|
643
|
-
declare class ResourceRegistry {
|
|
644
|
-
private readonly sources;
|
|
645
|
-
/** Sources registered by the bootstrap boundary (currently Extensions). */
|
|
646
|
-
private readonly implicitSources;
|
|
647
|
-
private revisionSequence;
|
|
648
|
-
loadAgents(input: LoadInput<AgentDefinition>): Promise<LoadResult>;
|
|
649
|
-
loadSkills(input: LoadInput<Skill>): Promise<LoadResult>;
|
|
650
|
-
loadPhases(input: LoadInput<Phase>): Promise<LoadResult>;
|
|
651
|
-
loadTools(input: Readonly<{
|
|
652
|
-
sourceId: ResourceSourceId;
|
|
653
|
-
values: readonly ToolContribution[];
|
|
654
|
-
}>): Promise<LoadResult>;
|
|
655
|
-
unload(input: Readonly<{
|
|
656
|
-
kind: ResourceKind;
|
|
657
|
-
sourceId: ResourceSourceId;
|
|
658
|
-
}>): Promise<LoadResult>;
|
|
659
|
-
resolveView(view: ResourceView): ResolvedResourceView;
|
|
660
|
-
/** Mark one already-loaded source as implicit for every Resource View. */
|
|
661
|
-
protected markImplicit(kind: ResourceKind, sourceId: ResourceSourceId): void;
|
|
662
|
-
/** Bootstrap-only helper for replacing an implicit contribution source. */
|
|
663
|
-
protected replaceImplicit<T extends RegistryValue>(kind: ResourceKind, sourceId: ResourceSourceId, values: readonly T[]): Promise<LoadResult>;
|
|
664
|
-
protected hasImplicit(kind: ResourceKind, sourceId: ResourceSourceId): boolean;
|
|
665
|
-
private withImplicit;
|
|
666
|
-
private collect;
|
|
667
|
-
private commit;
|
|
668
|
-
private resolveKind;
|
|
669
|
-
private resolveRevisions;
|
|
670
|
-
private resolveRefs;
|
|
671
|
-
private sourcesFor;
|
|
672
|
-
private nextRevision;
|
|
673
|
-
}
|
|
323
|
+
factory: ExtensionFactory;
|
|
324
|
+
manifest?: ExtensionManifest;
|
|
325
|
+
}
|
|
326
|
+
/** Extension manifest from package.json `rowan` field. */
|
|
327
|
+
interface ExtensionManifest {
|
|
328
|
+
entry?: string;
|
|
329
|
+
name?: string;
|
|
330
|
+
}
|
|
674
331
|
|
|
675
332
|
/**
|
|
676
333
|
* EventBus — simple pub/sub for inter-extension communication.
|
|
@@ -794,6 +451,79 @@ interface ExtensionUtils {
|
|
|
794
451
|
formatJson(value: unknown): string;
|
|
795
452
|
}
|
|
796
453
|
|
|
454
|
+
/**
|
|
455
|
+
* Extension API object passed to extension factory function.
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* ```typescript
|
|
459
|
+
* export default function(api: ExtensionAPI) {
|
|
460
|
+
* // api provides all extension APIs
|
|
461
|
+
* }
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
464
|
+
interface ExtensionAPI {
|
|
465
|
+
/**
|
|
466
|
+
* Subscribe to a hook event.
|
|
467
|
+
*
|
|
468
|
+
* @param eventType - Hook type, e.g. "before_tool_call"
|
|
469
|
+
* @param handler - Hook handler, can return result to modify behavior
|
|
470
|
+
*/
|
|
471
|
+
on<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
|
|
472
|
+
/** Unsubscribe from a hook event. */
|
|
473
|
+
off<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
|
|
474
|
+
/** Tool capabilities — register and unregister custom tools. */
|
|
475
|
+
tool: {
|
|
476
|
+
/** Register a custom LLM-callable tool. */
|
|
477
|
+
register(tool: ToolDefinition): void;
|
|
478
|
+
/** Unregister a previously registered tool by name. */
|
|
479
|
+
unregister(toolName: string): void;
|
|
480
|
+
};
|
|
481
|
+
/** Register a model provider. */
|
|
482
|
+
registerProvider(config: _rowan_agent_models.ProviderConfig): void;
|
|
483
|
+
/** Unregister a model provider. */
|
|
484
|
+
unregisterProvider(name: string): void;
|
|
485
|
+
/** Extension manifest from package.json `rowan` field. */
|
|
486
|
+
manifest?: ExtensionManifest;
|
|
487
|
+
/** Utility functions. */
|
|
488
|
+
utils: ExtensionUtils;
|
|
489
|
+
/** Runtime context — cwd, signal, exec, message access, etc. */
|
|
490
|
+
context: ExtensionContext;
|
|
491
|
+
/** Shared event bus for inter-extension communication. */
|
|
492
|
+
events: EventBus;
|
|
493
|
+
/** Phase execution capabilities — provides Phase In/Out, phase identity, phase routing, and registration. */
|
|
494
|
+
phase: {
|
|
495
|
+
/** Register a Phase directory bundle or Phase object. */
|
|
496
|
+
register(phase: PhaseRegistration): Promise<void>;
|
|
497
|
+
/** Unregister a previously registered phase by name. */
|
|
498
|
+
unregister(phaseName: string): void;
|
|
499
|
+
/** Phase In: get payload from previous phase */
|
|
500
|
+
getPayload(): unknown;
|
|
501
|
+
/** Phase Out: set payload for next phase */
|
|
502
|
+
setPayload(payload: unknown): void;
|
|
503
|
+
/** Phase Out: set outcome message */
|
|
504
|
+
setMessage(message: string): void;
|
|
505
|
+
/** Get current phase name */
|
|
506
|
+
getCurrentPhase(): string;
|
|
507
|
+
/** Set next phase (lower priority than PHASE.md target) */
|
|
508
|
+
setNextPhase(phaseName: string): void;
|
|
509
|
+
/** Get the next phase set by setNextPhase */
|
|
510
|
+
getNextPhase(): string | undefined;
|
|
511
|
+
/** Get the message set by setMessage */
|
|
512
|
+
getMessage(): string | undefined;
|
|
513
|
+
/** Phase Settings contributions registered by the Phase extension. */
|
|
514
|
+
settings: {
|
|
515
|
+
register(provider: PhaseSettingsProvider): void;
|
|
516
|
+
};
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Extension factory function.
|
|
521
|
+
* Receives ExtensionAPI for registering hooks, phases, and providers.
|
|
522
|
+
*/
|
|
523
|
+
type ExtensionDisposer = () => void | Promise<void>;
|
|
524
|
+
type ExtensionFactoryResult = void | ExtensionDisposer;
|
|
525
|
+
type ExtensionFactory = (api: ExtensionAPI) => ExtensionFactoryResult | Promise<ExtensionFactoryResult>;
|
|
526
|
+
|
|
797
527
|
/**
|
|
798
528
|
* Extension runner — manages extension loading and hook execution.
|
|
799
529
|
*
|
|
@@ -1111,7 +841,7 @@ type Tool$1 = Readonly<{
|
|
|
1111
841
|
core?: boolean;
|
|
1112
842
|
description: string;
|
|
1113
843
|
parameters: Type.TSchema;
|
|
1114
|
-
execute(args: JsonValue, context: ToolInvocationContext, signal: AbortSignal): Promise<ToolExecutionResult
|
|
844
|
+
execute(args: JsonValue, context: ToolInvocationContext, signal: AbortSignal): Promise<ToolExecutionResult>;
|
|
1115
845
|
}>;
|
|
1116
846
|
type ContextCandidate = Readonly<{
|
|
1117
847
|
name: string;
|
|
@@ -1134,10 +864,10 @@ type BeforeToolCall = (input: Readonly<{
|
|
|
1134
864
|
}>) => BeforeToolCallDecision | Promise<BeforeToolCallDecision>;
|
|
1135
865
|
type AfterToolCall = (input: Readonly<{
|
|
1136
866
|
tool: Tool$1;
|
|
1137
|
-
result: ToolExecutionResult
|
|
867
|
+
result: ToolExecutionResult;
|
|
1138
868
|
context: ToolInvocationContext;
|
|
1139
869
|
signal: AbortSignal;
|
|
1140
|
-
}>) => ToolExecutionResult
|
|
870
|
+
}>) => ToolExecutionResult | Promise<ToolExecutionResult>;
|
|
1141
871
|
type InvocationSource = "auto" | "implicit" | "external";
|
|
1142
872
|
type InvocationCatalogEntry = Readonly<{
|
|
1143
873
|
kind: "phase" | "skill";
|
|
@@ -1198,6 +928,10 @@ type ToolBatchCommit = Readonly<{
|
|
|
1198
928
|
run: RunRecord;
|
|
1199
929
|
toolCalls: readonly ToolCallSnapshot[];
|
|
1200
930
|
}>;
|
|
931
|
+
type EntryPhaseSpec = Readonly<{
|
|
932
|
+
phase: string;
|
|
933
|
+
payload?: JsonValue;
|
|
934
|
+
}>;
|
|
1201
935
|
type RunRecord = Readonly<{
|
|
1202
936
|
id: RunId;
|
|
1203
937
|
agentId: AgentId;
|
|
@@ -1213,6 +947,7 @@ type RunRecord = Readonly<{
|
|
|
1213
947
|
}>;
|
|
1214
948
|
metadata?: Metadata;
|
|
1215
949
|
phasePayload?: JsonValue;
|
|
950
|
+
entryPhases?: readonly EntryPhaseSpec[];
|
|
1216
951
|
pinnedConfigToken?: ConfigToken;
|
|
1217
952
|
checkpoint?: ExecutionCheckpoint;
|
|
1218
953
|
currentPhaseId?: string;
|
|
@@ -1271,6 +1006,7 @@ type RunSnapshotBase = Readonly<{
|
|
|
1271
1006
|
metadata?: Metadata;
|
|
1272
1007
|
/** Effective entry Phase payload the Run started with (defaults filled). */
|
|
1273
1008
|
phasePayload?: JsonValue;
|
|
1009
|
+
entryPhases?: readonly EntryPhaseSpec[];
|
|
1274
1010
|
messageCount: number;
|
|
1275
1011
|
toolCallCount: number;
|
|
1276
1012
|
currentPhaseId?: string;
|
|
@@ -1378,6 +1114,7 @@ interface OwnedStore {
|
|
|
1378
1114
|
input: UserInput;
|
|
1379
1115
|
metadata?: Metadata;
|
|
1380
1116
|
phasePayload?: JsonValue;
|
|
1117
|
+
entryPhases?: readonly EntryPhaseSpec[];
|
|
1381
1118
|
pinnedConfigToken?: ConfigToken;
|
|
1382
1119
|
idempotencyKey: string;
|
|
1383
1120
|
}): Promise<RunRecord>;
|
|
@@ -1462,7 +1199,7 @@ interface OwnedStore {
|
|
|
1462
1199
|
execution: ExecutionToken;
|
|
1463
1200
|
expectedRevision: number;
|
|
1464
1201
|
toolCallId: ToolCallId;
|
|
1465
|
-
result: ToolExecutionResult
|
|
1202
|
+
result: ToolExecutionResult;
|
|
1466
1203
|
state: "completed" | "failed" | "indeterminate";
|
|
1467
1204
|
reason?: string;
|
|
1468
1205
|
}): Promise<ToolCommit>;
|
|
@@ -1560,6 +1297,7 @@ interface AgentRuntime$1 {
|
|
|
1560
1297
|
idempotencyKey: string;
|
|
1561
1298
|
metadata?: Metadata;
|
|
1562
1299
|
phasePayload?: JsonValue;
|
|
1300
|
+
entryPhases?: ReadonlyArray<EntryPhaseSpec>;
|
|
1563
1301
|
}): Promise<AgentRun>;
|
|
1564
1302
|
run(runId: RunId): AgentRun;
|
|
1565
1303
|
contextStatus(agentId: AgentId, options?: {
|
|
@@ -1598,201 +1336,472 @@ type ConsumerRegistration = Readonly<{
|
|
|
1598
1336
|
waterline: EventCursor;
|
|
1599
1337
|
}>;
|
|
1600
1338
|
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
* Tool definition for registering LLM-callable tools via `api.tool.register()`.
|
|
1610
|
-
*
|
|
1611
|
-
* @example
|
|
1612
|
-
* ```typescript
|
|
1613
|
-
* api.tool.register({
|
|
1614
|
-
* name: "search_docs",
|
|
1615
|
-
* description: "Search documentation",
|
|
1616
|
-
* parameters: { type: "object", properties: { query: { type: "string" } } },
|
|
1617
|
-
* execute: async (args, ctx) => {
|
|
1618
|
-
* return { content: [{ type: "text", text: "result" }] };
|
|
1619
|
-
* },
|
|
1620
|
-
* });
|
|
1621
|
-
* ```
|
|
1622
|
-
*/
|
|
1623
|
-
interface ToolDefinition {
|
|
1624
|
-
/** Tool name (used in LLM tool calls) */
|
|
1625
|
-
name: string;
|
|
1626
|
-
/** Description for LLM */
|
|
1627
|
-
description: string;
|
|
1628
|
-
/** Parameter schema (JSON Schema) */
|
|
1629
|
-
parameters: Record<string, unknown>;
|
|
1630
|
-
/** Execute the tool */
|
|
1631
|
-
execute: (args: unknown, context: ToolInvocationContext, signal?: AbortSignal) => Promise<ToolExecutionResult>;
|
|
1632
|
-
/** Optional: per-tool execution mode override */
|
|
1633
|
-
executionMode?: "sequential" | "parallel";
|
|
1634
|
-
}
|
|
1635
|
-
/**
|
|
1636
|
-
* Result from tool execution.
|
|
1637
|
-
*/
|
|
1638
|
-
interface ToolExecutionResult {
|
|
1639
|
-
/** Content blocks to return to the LLM */
|
|
1640
|
-
content: Array<{
|
|
1641
|
-
type: string;
|
|
1642
|
-
text?: string;
|
|
1643
|
-
[key: string]: unknown;
|
|
1339
|
+
type LoopMetrics = {
|
|
1340
|
+
/** Number of phase iterations executed. */
|
|
1341
|
+
iterations: number;
|
|
1342
|
+
/** Phase transition history. */
|
|
1343
|
+
phaseTransitions: Array<{
|
|
1344
|
+
from: string;
|
|
1345
|
+
to: string;
|
|
1346
|
+
ts: string;
|
|
1644
1347
|
}>;
|
|
1645
|
-
/**
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
/**
|
|
1656
|
-
|
|
1657
|
-
*/
|
|
1658
|
-
interface ExtensionError {
|
|
1659
|
-
/** Path of the extension that caused the error */
|
|
1660
|
-
extensionPath: string;
|
|
1661
|
-
/** Event or operation that caused the error */
|
|
1662
|
-
event: string;
|
|
1663
|
-
/** Error message */
|
|
1664
|
-
error: string;
|
|
1665
|
-
/** Optional stack trace */
|
|
1666
|
-
stack?: string;
|
|
1667
|
-
}
|
|
1668
|
-
/** Error listener callback type. */
|
|
1669
|
-
type ExtensionErrorListener = (error: ExtensionError) => void;
|
|
1670
|
-
type ExecOptions = {
|
|
1671
|
-
/** Working directory for the command. Defaults to cwd passed to runtime. */
|
|
1672
|
-
cwd?: string;
|
|
1673
|
-
/** Environment variables to add/override. */
|
|
1674
|
-
env?: Record<string, string>;
|
|
1675
|
-
/** Timeout in milliseconds. */
|
|
1676
|
-
timeout?: number;
|
|
1677
|
-
/** AbortSignal for cancellation. */
|
|
1678
|
-
signal?: AbortSignal;
|
|
1348
|
+
/** Number of times compaction was triggered. */
|
|
1349
|
+
compactionCount: number;
|
|
1350
|
+
/** Number of retry attempts due to transient errors. */
|
|
1351
|
+
retryCount: number;
|
|
1352
|
+
/** Loop start timestamp. */
|
|
1353
|
+
startedAt: string;
|
|
1354
|
+
/** Loop start time as epoch ms (for duration calculation). */
|
|
1355
|
+
startedAtMs: number;
|
|
1356
|
+
/** Loop end timestamp (set on completion). */
|
|
1357
|
+
endedAt?: string;
|
|
1358
|
+
/** Total wall-clock duration in ms. */
|
|
1359
|
+
durationMs?: number;
|
|
1679
1360
|
};
|
|
1680
|
-
type
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1361
|
+
type ExecutionState = {
|
|
1362
|
+
currentPhase: string;
|
|
1363
|
+
attempt: number;
|
|
1364
|
+
metrics: LoopMetrics;
|
|
1365
|
+
status: "idle" | "running" | "suspended" | "completed" | "aborted" | "failed";
|
|
1366
|
+
initialPhasePayload?: JsonValue;
|
|
1367
|
+
entryPhases?: readonly EntryPhaseSpec[];
|
|
1368
|
+
continuation?: ExecutionContinuationState;
|
|
1369
|
+
runInteractions?: RunInteractionState;
|
|
1370
|
+
phaseInteractions?: RunInteractionState;
|
|
1684
1371
|
};
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
interface ExtensionRuntime {
|
|
1692
|
-
/** Throws when this extension instance is stale after runtime replacement. */
|
|
1693
|
-
assertActive: () => void;
|
|
1694
|
-
/** Marks this extension instance as stale after runtime replacement or reload. */
|
|
1695
|
-
invalidate: (message?: string) => void;
|
|
1696
|
-
}
|
|
1697
|
-
/**
|
|
1698
|
-
* Result of loading extensions from filesystem.
|
|
1699
|
-
* The runner takes these and creates Extension tracking objects.
|
|
1700
|
-
*/
|
|
1701
|
-
type LoadExtensionsResult = {
|
|
1702
|
-
extensions: LoadedExtension[];
|
|
1703
|
-
errors: Array<{
|
|
1704
|
-
path: string;
|
|
1705
|
-
error: string;
|
|
1372
|
+
type ExecutionContinuationState = {
|
|
1373
|
+
isContinuing: boolean;
|
|
1374
|
+
previousPayload?: unknown;
|
|
1375
|
+
previousResults: Array<{
|
|
1376
|
+
name: string;
|
|
1377
|
+
output?: unknown;
|
|
1706
1378
|
}>;
|
|
1379
|
+
pendingInstruction?: string;
|
|
1380
|
+
previousPhaseMessageId?: string;
|
|
1707
1381
|
};
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1382
|
+
|
|
1383
|
+
type RunInteractionKind = "user_input" | "permission" | "elicitation" | "confirmation";
|
|
1384
|
+
type RunInteractionStatus = "pending" | "answered" | "replied" | "cancelled";
|
|
1385
|
+
type RunInteraction = Readonly<{
|
|
1386
|
+
id: string;
|
|
1387
|
+
phase: string;
|
|
1388
|
+
kind: RunInteractionKind;
|
|
1389
|
+
prompt: string;
|
|
1390
|
+
payload?: JsonValue;
|
|
1391
|
+
createdAt: string;
|
|
1392
|
+
status: RunInteractionStatus;
|
|
1393
|
+
answer?: JsonValue;
|
|
1394
|
+
reply?: string;
|
|
1395
|
+
/** The Run is only waiting for the next user message, not asking a question. */
|
|
1396
|
+
turnBoundary?: true;
|
|
1397
|
+
toolCallId?: string;
|
|
1398
|
+
result?: Readonly<{
|
|
1399
|
+
answered?: string;
|
|
1400
|
+
replied?: string;
|
|
1401
|
+
cancelled?: string;
|
|
1402
|
+
}>;
|
|
1403
|
+
}>;
|
|
1404
|
+
type RunInteractionRequest = Readonly<{
|
|
1405
|
+
id?: string;
|
|
1406
|
+
kind: RunInteractionKind;
|
|
1407
|
+
prompt: string;
|
|
1408
|
+
payload?: JsonValue;
|
|
1409
|
+
toolCallId?: string;
|
|
1410
|
+
result?: Readonly<{
|
|
1411
|
+
answered?: string;
|
|
1412
|
+
replied?: string;
|
|
1413
|
+
cancelled?: string;
|
|
1414
|
+
}>;
|
|
1415
|
+
}>;
|
|
1416
|
+
type RunInteractionState = Readonly<{
|
|
1417
|
+
requests: readonly RunInteraction[];
|
|
1418
|
+
answers: Readonly<Record<string, JsonValue>>;
|
|
1419
|
+
checkpoint?: JsonValue;
|
|
1420
|
+
}>;
|
|
1421
|
+
type RunInteractionDriver = Readonly<{
|
|
1422
|
+
signal: AbortSignal;
|
|
1423
|
+
request(input: RunInteractionRequest): RunInteraction;
|
|
1424
|
+
pending(): readonly RunInteraction[];
|
|
1425
|
+
answers(): ReadonlyMap<string, JsonValue>;
|
|
1426
|
+
checkpoint(): JsonValue | undefined;
|
|
1427
|
+
clearCheckpoint(): void;
|
|
1428
|
+
suspend(input?: Readonly<{
|
|
1429
|
+
checkpoint?: JsonValue;
|
|
1430
|
+
}>): never;
|
|
1431
|
+
}>;
|
|
1432
|
+
declare class RunInteractionCancelledError extends Error {
|
|
1433
|
+
readonly code: "run_interaction_cancelled";
|
|
1434
|
+
constructor();
|
|
1717
1435
|
}
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1436
|
+
declare class RunInteractionBoundary extends Error {
|
|
1437
|
+
readonly state: ExecutionState;
|
|
1438
|
+
readonly interactions: readonly RunInteraction[];
|
|
1439
|
+
constructor(state: ExecutionState, interactions: readonly RunInteraction[]);
|
|
1722
1440
|
}
|
|
1723
1441
|
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
/**
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1442
|
+
declare const opaqueIdBrand: unique symbol;
|
|
1443
|
+
type OpaqueId<Kind extends string> = string & {
|
|
1444
|
+
readonly [opaqueIdBrand]: Kind;
|
|
1445
|
+
};
|
|
1446
|
+
type AgentId = OpaqueId<"AgentId">;
|
|
1447
|
+
type RunId = OpaqueId<"RunId">;
|
|
1448
|
+
type MessageId = OpaqueId<"MessageId">;
|
|
1449
|
+
type ToolCallId = OpaqueId<"ToolCallId">;
|
|
1450
|
+
type EventId = OpaqueId<"EventId">;
|
|
1451
|
+
type ExecutionId = OpaqueId<"ExecutionId">;
|
|
1452
|
+
type OutcomeId = OpaqueId<"OutcomeId">;
|
|
1453
|
+
type ConfigToken = OpaqueId<"ConfigToken">;
|
|
1454
|
+
type OwnerToken = OpaqueId<"OwnerToken">;
|
|
1455
|
+
type EventCursor = OpaqueId<"EventCursor">;
|
|
1456
|
+
type AgentListCursor = OpaqueId<"AgentListCursor">;
|
|
1457
|
+
type RunListCursor = OpaqueId<"RunListCursor">;
|
|
1458
|
+
type JsonPrimitive = null | boolean | number | string;
|
|
1459
|
+
type JsonValue = JsonPrimitive | readonly JsonValue[] | {
|
|
1460
|
+
readonly [key: string]: JsonValue;
|
|
1461
|
+
};
|
|
1462
|
+
type JsonObject = Readonly<Record<string, JsonValue>>;
|
|
1463
|
+
type Metadata = JsonObject;
|
|
1464
|
+
type TextContent = Readonly<{
|
|
1465
|
+
type: "text";
|
|
1466
|
+
text: string;
|
|
1467
|
+
}>;
|
|
1468
|
+
type ImageContent = Readonly<{
|
|
1469
|
+
type: "image";
|
|
1470
|
+
data: string;
|
|
1471
|
+
mimeType: string;
|
|
1472
|
+
}>;
|
|
1473
|
+
type ThinkingContent = Readonly<{
|
|
1474
|
+
type: "thinking";
|
|
1475
|
+
thinking: string;
|
|
1476
|
+
signature?: string;
|
|
1477
|
+
}>;
|
|
1478
|
+
type ToolUseContent = Readonly<{
|
|
1479
|
+
type: "tool_use";
|
|
1480
|
+
toolCallId: ToolCallId;
|
|
1481
|
+
/** Provider/model correlation, retained only to reconstruct the next request. */
|
|
1482
|
+
providerToolCallId?: string;
|
|
1483
|
+
name: string;
|
|
1484
|
+
input: JsonValue;
|
|
1485
|
+
}>;
|
|
1486
|
+
type ToolExecutionResult = Readonly<{
|
|
1487
|
+
ok: true;
|
|
1488
|
+
content: JsonValue;
|
|
1489
|
+
}> | Readonly<{
|
|
1490
|
+
ok: false;
|
|
1491
|
+
content: JsonValue;
|
|
1492
|
+
error: string;
|
|
1493
|
+
}>;
|
|
1494
|
+
type DurableToolResult = Readonly<{
|
|
1495
|
+
toolCallId: ToolCallId;
|
|
1496
|
+
toolName: string;
|
|
1497
|
+
}> & ToolExecutionResult;
|
|
1498
|
+
type ToolResultContent = Readonly<{
|
|
1499
|
+
type: "tool_result";
|
|
1500
|
+
toolCallId: ToolCallId;
|
|
1501
|
+
/** Provider/model correlation, retained only to reconstruct the next request. */
|
|
1502
|
+
providerToolCallId?: string;
|
|
1503
|
+
result: ToolExecutionResult;
|
|
1504
|
+
}>;
|
|
1505
|
+
type UserContent = string | readonly (TextContent | ImageContent)[];
|
|
1506
|
+
type AssistantContent = string | readonly (TextContent | ThinkingContent | ToolUseContent)[];
|
|
1507
|
+
type ToolMessageContent = readonly [ToolResultContent, ...ToolResultContent[]];
|
|
1508
|
+
type MessageContent = UserContent | AssistantContent | ToolMessageContent;
|
|
1509
|
+
type MessageBase = Readonly<{
|
|
1510
|
+
id: MessageId;
|
|
1511
|
+
agentId: AgentId;
|
|
1512
|
+
runId: RunId;
|
|
1513
|
+
/** Monotonic active revision. Omitted on legacy/initial messages and read as 0. */
|
|
1514
|
+
messageRevision?: number;
|
|
1515
|
+
metadata?: Metadata;
|
|
1516
|
+
sequenceWithinRun: number;
|
|
1517
|
+
createdAt: string;
|
|
1518
|
+
}>;
|
|
1519
|
+
type UserMessage = MessageBase & Readonly<{
|
|
1520
|
+
role: "user";
|
|
1521
|
+
content: UserContent;
|
|
1522
|
+
}>;
|
|
1523
|
+
type AssistantMessage = MessageBase & Readonly<{
|
|
1524
|
+
role: "assistant";
|
|
1525
|
+
content: AssistantContent;
|
|
1526
|
+
interrupted?: boolean;
|
|
1527
|
+
}>;
|
|
1528
|
+
type ToolMessage = MessageBase & Readonly<{
|
|
1529
|
+
role: "tool";
|
|
1530
|
+
content: ToolMessageContent;
|
|
1531
|
+
}>;
|
|
1532
|
+
type InteractionRecord = MessageBase & Readonly<{
|
|
1533
|
+
role: "interaction";
|
|
1534
|
+
interactionId: string;
|
|
1535
|
+
kind: "user_input" | "permission" | "elicitation" | "confirmation";
|
|
1536
|
+
prompt: string;
|
|
1537
|
+
phase: string;
|
|
1538
|
+
status: "answered" | "replied" | "cancelled";
|
|
1539
|
+
answer?: JsonValue;
|
|
1540
|
+
reply?: string;
|
|
1541
|
+
toolCallId?: ToolCallId;
|
|
1542
|
+
result?: Readonly<{
|
|
1543
|
+
answered?: string;
|
|
1544
|
+
replied?: string;
|
|
1545
|
+
cancelled?: string;
|
|
1546
|
+
}>;
|
|
1547
|
+
}>;
|
|
1548
|
+
type Message = UserMessage | AssistantMessage | ToolMessage | InteractionRecord;
|
|
1549
|
+
type Outcome = Readonly<{
|
|
1550
|
+
id: OutcomeId;
|
|
1551
|
+
message: string;
|
|
1552
|
+
payload?: JsonValue;
|
|
1553
|
+
toolResults?: readonly DurableToolResult[];
|
|
1554
|
+
}>;
|
|
1555
|
+
type RunState = "queued" | "running" | "input_required" | "completed" | "failed" | "cancelled";
|
|
1556
|
+
type RunFailure = Readonly<{
|
|
1557
|
+
code: "configuration_unavailable";
|
|
1558
|
+
message: string;
|
|
1559
|
+
}> | Readonly<{
|
|
1560
|
+
code: "checkpoint_incompatible";
|
|
1561
|
+
message: string;
|
|
1562
|
+
expected: Readonly<{
|
|
1563
|
+
codec: string;
|
|
1564
|
+
versions: readonly number[];
|
|
1565
|
+
}>;
|
|
1566
|
+
actual: Readonly<{
|
|
1567
|
+
codec: string;
|
|
1568
|
+
version: number;
|
|
1569
|
+
}>;
|
|
1570
|
+
}> | Readonly<{
|
|
1571
|
+
code: "runtime_interrupted";
|
|
1572
|
+
message: string;
|
|
1573
|
+
ownerEpoch: number;
|
|
1574
|
+
}> | Readonly<{
|
|
1575
|
+
code: "tool_indeterminate";
|
|
1576
|
+
message: string;
|
|
1577
|
+
toolCallIds: readonly [ToolCallId, ...ToolCallId[]];
|
|
1578
|
+
}> | Readonly<{
|
|
1579
|
+
code: "execution_failed";
|
|
1580
|
+
message: string;
|
|
1581
|
+
details?: JsonValue;
|
|
1582
|
+
}>;
|
|
1583
|
+
type QueuedRunFailure = Extract<RunFailure, {
|
|
1584
|
+
code: "configuration_unavailable" | "checkpoint_incompatible";
|
|
1585
|
+
}>;
|
|
1586
|
+
type RunningRunFailure = Extract<RunFailure, {
|
|
1587
|
+
code: "runtime_interrupted" | "tool_indeterminate" | "execution_failed";
|
|
1588
|
+
}>;
|
|
1589
|
+
type ToolCallState = "pending" | "running" | "completed" | "failed" | "indeterminate";
|
|
1590
|
+
type ToolCallSnapshotBase = Readonly<{
|
|
1591
|
+
id: ToolCallId;
|
|
1592
|
+
providerToolCallId: string;
|
|
1593
|
+
agentId: AgentId;
|
|
1594
|
+
runId: RunId;
|
|
1595
|
+
executionId: ExecutionId;
|
|
1596
|
+
requestMessageId: MessageId;
|
|
1597
|
+
name: string;
|
|
1598
|
+
args: JsonValue;
|
|
1599
|
+
createdAt: string;
|
|
1600
|
+
updatedAt: string;
|
|
1601
|
+
}>;
|
|
1602
|
+
type ToolCallSnapshot = ToolCallSnapshotBase & (Readonly<{
|
|
1603
|
+
state: "pending";
|
|
1604
|
+
}> | Readonly<{
|
|
1605
|
+
state: "running";
|
|
1606
|
+
}> | Readonly<{
|
|
1607
|
+
state: "completed";
|
|
1608
|
+
result: DurableToolResult & Readonly<{
|
|
1609
|
+
ok: true;
|
|
1610
|
+
}>;
|
|
1611
|
+
resultMessageId: MessageId;
|
|
1612
|
+
}> | Readonly<{
|
|
1613
|
+
state: "failed";
|
|
1614
|
+
result: DurableToolResult & Readonly<{
|
|
1615
|
+
ok: false;
|
|
1616
|
+
}>;
|
|
1617
|
+
resultMessageId: MessageId;
|
|
1618
|
+
}> | Readonly<{
|
|
1619
|
+
state: "indeterminate";
|
|
1620
|
+
result: DurableToolResult & Readonly<{
|
|
1621
|
+
ok: false;
|
|
1622
|
+
}>;
|
|
1623
|
+
resultMessageId: MessageId;
|
|
1624
|
+
reason: string;
|
|
1625
|
+
}>);
|
|
1626
|
+
type DurableEventBase = Readonly<{
|
|
1627
|
+
id: EventId;
|
|
1628
|
+
schemaVersion: 1;
|
|
1629
|
+
cursor: EventCursor;
|
|
1630
|
+
durability: "durable";
|
|
1631
|
+
agentId: AgentId;
|
|
1632
|
+
runId: RunId;
|
|
1633
|
+
runRevision: number;
|
|
1634
|
+
metadata?: Metadata;
|
|
1635
|
+
createdAt: string;
|
|
1636
|
+
}>;
|
|
1637
|
+
type PhaseEntered = DurableEventBase & Readonly<{
|
|
1638
|
+
kind: "phase_entered";
|
|
1639
|
+
executionId: ExecutionId;
|
|
1640
|
+
phaseId: string;
|
|
1641
|
+
visit: number;
|
|
1642
|
+
}>;
|
|
1643
|
+
type MessageCommitted = DurableEventBase & Readonly<{
|
|
1644
|
+
kind: "message_committed";
|
|
1645
|
+
message: Message;
|
|
1646
|
+
}>;
|
|
1647
|
+
type MessageRevised = DurableEventBase & Readonly<{
|
|
1648
|
+
kind: "message_revised";
|
|
1649
|
+
message: UserMessage;
|
|
1650
|
+
previousRevision: number;
|
|
1651
|
+
invalidatedRunIds: readonly RunId[];
|
|
1652
|
+
targetRunId: RunId;
|
|
1653
|
+
cutoffSequenceWithinRun: number;
|
|
1654
|
+
}>;
|
|
1655
|
+
type RunStateChanged = DurableEventBase & (Readonly<{
|
|
1656
|
+
kind: "run_state_changed";
|
|
1657
|
+
from: null;
|
|
1658
|
+
to: "queued";
|
|
1659
|
+
}> | Readonly<{
|
|
1660
|
+
kind: "run_state_changed";
|
|
1661
|
+
from: "input_required";
|
|
1662
|
+
to: "queued";
|
|
1663
|
+
}> | Readonly<{
|
|
1664
|
+
kind: "run_state_changed";
|
|
1665
|
+
from: "queued";
|
|
1666
|
+
to: "running";
|
|
1667
|
+
}> | Readonly<{
|
|
1668
|
+
kind: "run_state_changed";
|
|
1669
|
+
from: "running";
|
|
1670
|
+
to: "input_required";
|
|
1671
|
+
interactions: readonly RunInteraction[];
|
|
1672
|
+
answers: Readonly<Record<string, JsonValue>>;
|
|
1673
|
+
}> | Readonly<{
|
|
1674
|
+
kind: "run_state_changed";
|
|
1675
|
+
from: "running";
|
|
1676
|
+
to: "completed";
|
|
1677
|
+
outcome: Outcome;
|
|
1678
|
+
output?: AssistantMessage;
|
|
1679
|
+
}> | Readonly<{
|
|
1680
|
+
kind: "run_state_changed";
|
|
1681
|
+
from: "queued";
|
|
1682
|
+
to: "failed";
|
|
1683
|
+
failure: QueuedRunFailure;
|
|
1684
|
+
}> | Readonly<{
|
|
1685
|
+
kind: "run_state_changed";
|
|
1686
|
+
from: "running";
|
|
1687
|
+
to: "failed";
|
|
1688
|
+
failure: RunningRunFailure;
|
|
1689
|
+
}> | Readonly<{
|
|
1690
|
+
kind: "run_state_changed";
|
|
1691
|
+
from: "queued" | "running" | "input_required";
|
|
1692
|
+
to: "cancelled";
|
|
1693
|
+
reason?: string;
|
|
1694
|
+
}>);
|
|
1695
|
+
type ToolStateChanged = DurableEventBase & (Readonly<{
|
|
1696
|
+
kind: "tool_state_changed";
|
|
1697
|
+
transition: Readonly<{
|
|
1698
|
+
from: null;
|
|
1699
|
+
to: "pending";
|
|
1700
|
+
}>;
|
|
1701
|
+
toolCall: Extract<ToolCallSnapshot, {
|
|
1702
|
+
state: "pending";
|
|
1703
|
+
}>;
|
|
1704
|
+
}> | Readonly<{
|
|
1705
|
+
kind: "tool_state_changed";
|
|
1706
|
+
transition: Readonly<{
|
|
1707
|
+
from: "pending";
|
|
1708
|
+
to: "running";
|
|
1709
|
+
}>;
|
|
1710
|
+
toolCall: Extract<ToolCallSnapshot, {
|
|
1711
|
+
state: "running";
|
|
1712
|
+
}>;
|
|
1713
|
+
}> | Readonly<{
|
|
1714
|
+
kind: "tool_state_changed";
|
|
1715
|
+
transition: Readonly<{
|
|
1716
|
+
from: "pending";
|
|
1717
|
+
to: "failed";
|
|
1718
|
+
}>;
|
|
1719
|
+
toolCall: Extract<ToolCallSnapshot, {
|
|
1720
|
+
state: "failed";
|
|
1721
|
+
}>;
|
|
1722
|
+
}> | Readonly<{
|
|
1723
|
+
kind: "tool_state_changed";
|
|
1724
|
+
transition: Readonly<{
|
|
1725
|
+
from: "running";
|
|
1726
|
+
to: "pending";
|
|
1727
|
+
}>;
|
|
1728
|
+
toolCall: Extract<ToolCallSnapshot, {
|
|
1729
|
+
state: "pending";
|
|
1730
|
+
}>;
|
|
1731
|
+
}> | Readonly<{
|
|
1732
|
+
kind: "tool_state_changed";
|
|
1733
|
+
transition: Readonly<{
|
|
1734
|
+
from: "running";
|
|
1735
|
+
to: "pending";
|
|
1736
|
+
}>;
|
|
1737
|
+
toolCall: Extract<ToolCallSnapshot, {
|
|
1738
|
+
state: "pending";
|
|
1739
|
+
}>;
|
|
1740
|
+
}> | Readonly<{
|
|
1741
|
+
kind: "tool_state_changed";
|
|
1742
|
+
transition: Readonly<{
|
|
1743
|
+
from: "running";
|
|
1744
|
+
to: "completed";
|
|
1745
|
+
}>;
|
|
1746
|
+
toolCall: Extract<ToolCallSnapshot, {
|
|
1747
|
+
state: "completed";
|
|
1748
|
+
}>;
|
|
1749
|
+
}> | Readonly<{
|
|
1750
|
+
kind: "tool_state_changed";
|
|
1751
|
+
transition: Readonly<{
|
|
1752
|
+
from: "running";
|
|
1753
|
+
to: "failed";
|
|
1754
|
+
}>;
|
|
1755
|
+
toolCall: Extract<ToolCallSnapshot, {
|
|
1756
|
+
state: "failed";
|
|
1757
|
+
}>;
|
|
1758
|
+
}> | Readonly<{
|
|
1759
|
+
kind: "tool_state_changed";
|
|
1760
|
+
transition: Readonly<{
|
|
1761
|
+
from: "running";
|
|
1762
|
+
to: "indeterminate";
|
|
1763
|
+
}>;
|
|
1764
|
+
toolCall: Extract<ToolCallSnapshot, {
|
|
1765
|
+
state: "indeterminate";
|
|
1766
|
+
}>;
|
|
1767
|
+
}>);
|
|
1768
|
+
type DurableRunEvent = PhaseEntered | MessageCommitted | MessageRevised | RunStateChanged | ToolStateChanged;
|
|
1769
|
+
type MessageDelta = Readonly<{
|
|
1770
|
+
kind: "message_delta";
|
|
1771
|
+
durability: "transient";
|
|
1772
|
+
runId: RunId;
|
|
1773
|
+
executionId: ExecutionId;
|
|
1774
|
+
messageId: MessageId;
|
|
1775
|
+
offset: number;
|
|
1776
|
+
text: string;
|
|
1777
|
+
}>;
|
|
1778
|
+
type ThinkingDelta = Readonly<{
|
|
1779
|
+
kind: "thinking_delta";
|
|
1780
|
+
durability: "transient";
|
|
1781
|
+
runId: RunId;
|
|
1782
|
+
executionId: ExecutionId;
|
|
1783
|
+
messageId: MessageId;
|
|
1784
|
+
blockIndex: number;
|
|
1785
|
+
offset: number;
|
|
1786
|
+
text: string;
|
|
1787
|
+
}>;
|
|
1788
|
+
type ToolProgress = Readonly<{
|
|
1789
|
+
kind: "tool_progress";
|
|
1790
|
+
durability: "transient";
|
|
1791
|
+
runId: RunId;
|
|
1792
|
+
executionId: ExecutionId;
|
|
1793
|
+
toolCallId: ToolCallId;
|
|
1794
|
+
progress: JsonValue;
|
|
1795
|
+
}>;
|
|
1796
|
+
type PhaseStatusEvent = Readonly<{
|
|
1797
|
+
kind: "phase_status";
|
|
1798
|
+
durability: "transient";
|
|
1799
|
+
runId: RunId;
|
|
1800
|
+
executionId: ExecutionId;
|
|
1801
|
+
phaseId: string;
|
|
1802
|
+
status: PhaseStatus;
|
|
1803
|
+
}>;
|
|
1804
|
+
type RunEvent = DurableRunEvent | MessageDelta | ThinkingDelta | ToolProgress | PhaseStatusEvent;
|
|
1796
1805
|
|
|
1797
1806
|
type PhaseStatusState = "running" | "completed";
|
|
1798
1807
|
/** Normalized status event exposed to Runtime consumers. */
|
|
@@ -2197,6 +2206,7 @@ declare class AgentRuntime implements AgentRuntime$1 {
|
|
|
2197
2206
|
idempotencyKey: string;
|
|
2198
2207
|
metadata?: Metadata;
|
|
2199
2208
|
phasePayload?: JsonValue;
|
|
2209
|
+
entryPhases?: ReadonlyArray<EntryPhaseSpec>;
|
|
2200
2210
|
}): Promise<AgentRun>;
|
|
2201
2211
|
run(runId: RunId): AgentRun;
|
|
2202
2212
|
listAgents(input?: {
|
|
@@ -2333,6 +2343,7 @@ declare class InMemoryStore implements DurableStore {
|
|
|
2333
2343
|
input: UserInput;
|
|
2334
2344
|
metadata?: Metadata;
|
|
2335
2345
|
phasePayload?: JsonValue;
|
|
2346
|
+
entryPhases?: readonly EntryPhaseSpec[];
|
|
2336
2347
|
pinnedConfigToken?: ConfigToken;
|
|
2337
2348
|
idempotencyKey: string;
|
|
2338
2349
|
}): RunRecord;
|
|
@@ -2411,7 +2422,7 @@ declare class InMemoryStore implements DurableStore {
|
|
|
2411
2422
|
execution: ExecutionToken;
|
|
2412
2423
|
expectedRevision: number;
|
|
2413
2424
|
toolCallId: ToolCallId;
|
|
2414
|
-
result: ToolExecutionResult
|
|
2425
|
+
result: ToolExecutionResult;
|
|
2415
2426
|
state: "completed" | "failed" | "indeterminate";
|
|
2416
2427
|
reason?: string;
|
|
2417
2428
|
}): ToolCommit;
|
|
@@ -2535,6 +2546,7 @@ declare class SqliteStore implements DurableStore {
|
|
|
2535
2546
|
input: UserInput;
|
|
2536
2547
|
metadata?: Metadata;
|
|
2537
2548
|
phasePayload?: JsonValue;
|
|
2549
|
+
entryPhases?: readonly EntryPhaseSpec[];
|
|
2538
2550
|
pinnedConfigToken?: ConfigToken;
|
|
2539
2551
|
idempotencyKey: string;
|
|
2540
2552
|
}): Promise<RunRecord>;
|
|
@@ -2625,7 +2637,7 @@ declare class SqliteStore implements DurableStore {
|
|
|
2625
2637
|
execution: ExecutionToken;
|
|
2626
2638
|
expectedRevision: number;
|
|
2627
2639
|
toolCallId: ToolCallId;
|
|
2628
|
-
result: ToolExecutionResult
|
|
2640
|
+
result: ToolExecutionResult;
|
|
2629
2641
|
state: "completed" | "failed" | "indeterminate";
|
|
2630
2642
|
reason?: string;
|
|
2631
2643
|
}): Promise<ToolCommit>;
|
|
@@ -2865,4 +2877,4 @@ declare function parseFrontmatter<T = Record<string, unknown>>(raw: string): Fro
|
|
|
2865
2877
|
|
|
2866
2878
|
declare function createCoreTools(input?: CoreToolContext): Tool$1[];
|
|
2867
2879
|
|
|
2868
|
-
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 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 InteractionRecord, type InvocationCatalogEntry, type InvocationSource, 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 PhaseInput, type PhaseInvocation, type PhaseMessageManager, type PhaseOutput, type PhaseRegistry, type PhaseRegistrySelection, type PhaseSettingsBadge, type PhaseSettingsContext, type PhaseSettingsControl, type PhaseSettingsDefinition, type PhaseSettingsItem, type PhaseSettingsOption, type PhaseSettingsProvider, type PhaseSettingsSection, 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 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 RunState, type RunStateChanged, type RunSummary, RuntimeBootstrapRegistry, RuntimeError, type RuntimeErrorCode, type RuntimeErrorDetails, RuntimeExtensionLifetime, STOP_PHASE_ID, type Skill, SqliteStore, type TextContent, type ThinkingContent, type ThinkingDelta, type Tool$1 as Tool, type ToolCallContext, type ToolCallId, type ToolCallSnapshot, type ToolCallState, type ToolContribution, type ToolDefinition, type ToolExecutionResult
|
|
2880
|
+
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 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 InteractionRecord, type InvocationCatalogEntry, type InvocationSource, 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 PhaseInput, type PhaseInvocation, type PhaseMessageManager, type PhaseOutput, type PhaseRegistry, type PhaseRegistrySelection, type PhaseSettingsBadge, type PhaseSettingsContext, type PhaseSettingsControl, type PhaseSettingsDefinition, type PhaseSettingsItem, type PhaseSettingsOption, type PhaseSettingsProvider, type PhaseSettingsSection, 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 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 RunState, type RunStateChanged, type RunSummary, RuntimeBootstrapRegistry, RuntimeError, type RuntimeErrorCode, type RuntimeErrorDetails, RuntimeExtensionLifetime, STOP_PHASE_ID, type Skill, SqliteStore, type TextContent, type ThinkingContent, type ThinkingDelta, type Tool$1 as Tool, type ToolCallContext, 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, createCompactPhase, createCorePhases, createCoreTools, createDefaultPhase, createStopPhase, isConfigurationSnapshot, isRuntimeError, loadExtensionsFromPath as loadExtensions, loadPhase, loadPhaseSettings, loadPhases, loadSkill, loadSkills, parseAgentDefinition, parseFrontmatter, resolveConfigurationSnapshot };
|