@rowan-agent/agent 0.29.0 → 0.31.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/README.md +1 -1
- package/dist/chunk-HL6TMTA5.js +265 -0
- package/dist/index-jC_-oKbx.d.ts +2257 -0
- package/dist/index.d.ts +4 -3398
- package/dist/index.js +5 -13298
- package/dist/runtime.d.ts +947 -0
- package/dist/runtime.js +12991 -0
- package/package.json +6 -2
|
@@ -0,0 +1,947 @@
|
|
|
1
|
+
import { E as ExtensionHost, H as HostApiExtension, A as AgentRuntime$1, a as AgentRuntimeOptions, L as LoadInput, b as AgentDefinition, c as LoadResult, S as Skill, P as Phase, T as Tool, R as ResourceKind, d as AgentConfiguration, e as HistorySeed, f as AgentId, g as AgentDeletionRequest, M as MessageId, U as UserContent, h as MessageRevisionResult, i as RunId, j as ToolCallId, k as EventCursor, C as ContextStatus, l as UserInput, m as AgentRun, n as EntryPhaseSpec, o as AgentListCursor, p as Page, q as AgentSummary, r as RunState, s as RunListCursor, t as RunSummary, I as InvocationSource, u as InvocationCatalogEntry, D as DurableRunEvent, v as DurableConsumer, w as ExtensionCapability, x as RunSnapshot, y as Message, z as RunBoundary, B as RunEvent, F as DurableStore, G as AgentRecord, J as RunRecord, K as ToolCallSnapshot, N as ContextCompactionRecord, O as OwnerLease, Q as OwnedStore, V as ConfigToken, W as ExecutionId, X as ContextCandidate, Y as RunClaim, Z as RunFailure, _ as ExecutionToken, $ as AssistantMessage, a0 as ExecutionCheckpoint, a1 as RunInteraction, a2 as ToolCommit, a3 as ToolCallReservation, a4 as ToolBatchCommit, a5 as Outcome, a6 as ConsumerRegistration, a7 as RetentionResult, a8 as ConfigProvider, a9 as ConfigurationSnapshot, aa as ConfigPutResult, ab as ConfigResolution, ac as PhaseRegistry, ad as LoadedExtension } from './index-jC_-oKbx.js';
|
|
2
|
+
export { ae as DefinitionLayer, af as ExtensionActivationError, ag as ExtensionActivationResult, ah as ExtensionContribution, ai as ExtensionLifetimeError, aj as ExtensionLifetimeErrorCode, ak as ExtensionLoadInput, al as LoadExtensionsResult, am as ModelRetry, an as OpaqueId, ao as OwnerToken, ap as PhaseRegistrySelection, aq as ResolvedResourceView, ar as ResourceDiagnostic, as as ResourceRef, at as ResourceRegistry, au as ResourceRegistryError, av as ResourceRegistryErrorCode, aw as ResourceSourceId, ax as ResourceView, ay as RuntimeBootstrapRegistry, az as RuntimeExtensionLifetime, aA as extensionSourceId, aB as isConfigurationSnapshot, aC as mergeToolCall, aD as parseAgentDefinition, aE as resolveConfigurationSnapshot } from './index-jC_-oKbx.js';
|
|
3
|
+
import * as _rowan_agent_models from '@rowan-agent/models';
|
|
4
|
+
import { JsonObject, JsonValue, ScopeRef, ModelRef, LlmTokenUsage, StreamBlock, ToolKind, ToolCallLocation, ToolCallContent, ToolResult, ToolCall, ToolCallUpdate } from '@rowan-agent/models';
|
|
5
|
+
import 'typebox';
|
|
6
|
+
|
|
7
|
+
declare class InMemoryExtensionHost implements ExtensionHost {
|
|
8
|
+
private readonly configs;
|
|
9
|
+
private readonly agentState;
|
|
10
|
+
private readonly globalState;
|
|
11
|
+
private readonly listeners;
|
|
12
|
+
extendApi?(extensionId: string): HostApiExtension | undefined;
|
|
13
|
+
constructor(options?: {
|
|
14
|
+
configs?: Record<string, Record<string, JsonObject>>;
|
|
15
|
+
agentState?: Record<string, Record<string, Record<string, JsonValue>>>;
|
|
16
|
+
globalState?: Record<string, Record<string, JsonValue>>;
|
|
17
|
+
extendApi?: (extensionId: string) => HostApiExtension | undefined;
|
|
18
|
+
});
|
|
19
|
+
setConfig(extensionId: string, config: JsonObject | null, scope?: ScopeRef): void;
|
|
20
|
+
getConfig(extensionId: string, scope?: ScopeRef): JsonObject | null;
|
|
21
|
+
onConfigChanged(listener: (extensionId: string, scope: ScopeRef) => void): () => void;
|
|
22
|
+
notifyConfigChanged(extensionId: string, scope?: ScopeRef): void;
|
|
23
|
+
getAgentState(extensionId: string, agentId: string, key: string): JsonValue | undefined;
|
|
24
|
+
setAgentState(extensionId: string, agentId: string, key: string, value: JsonValue): void;
|
|
25
|
+
deleteAgentState(extensionId: string, agentId: string, key: string): void;
|
|
26
|
+
getGlobalState(extensionId: string, key: string): JsonValue | undefined;
|
|
27
|
+
setGlobalState(extensionId: string, key: string, value: JsonValue): void;
|
|
28
|
+
deleteGlobalState(extensionId: string, key: string): void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare class AgentRuntime implements AgentRuntime$1 {
|
|
32
|
+
private readonly concurrency;
|
|
33
|
+
private readonly owned;
|
|
34
|
+
private readonly commands;
|
|
35
|
+
private readonly storeIncarnation;
|
|
36
|
+
private readonly activeAgents;
|
|
37
|
+
private readonly executions;
|
|
38
|
+
private readonly executionDone;
|
|
39
|
+
private readonly cancellationRequested;
|
|
40
|
+
private readonly cancellationReasons;
|
|
41
|
+
private readonly autoCompactionRuns;
|
|
42
|
+
private readonly consumers;
|
|
43
|
+
private readonly transientEvents;
|
|
44
|
+
readonly host: ExtensionHost;
|
|
45
|
+
private readonly resources;
|
|
46
|
+
private readonly startedRuns;
|
|
47
|
+
private readonly liveInteractions;
|
|
48
|
+
private heartbeat?;
|
|
49
|
+
private pumping;
|
|
50
|
+
private closed;
|
|
51
|
+
private readonly retryDelayMs?;
|
|
52
|
+
private constructor();
|
|
53
|
+
static init(options: AgentRuntimeOptions): Promise<AgentRuntime>;
|
|
54
|
+
private publishLiveInteraction;
|
|
55
|
+
private cancelLiveInteractions;
|
|
56
|
+
private handleRunEnd;
|
|
57
|
+
loadAgents(input: LoadInput<AgentDefinition>): Promise<LoadResult>;
|
|
58
|
+
loadSkills(input: LoadInput<Skill>): Promise<LoadResult>;
|
|
59
|
+
loadPhases(input: LoadInput<Phase>): Promise<LoadResult>;
|
|
60
|
+
loadTools(input: Readonly<{
|
|
61
|
+
sourceId: string;
|
|
62
|
+
values: readonly Tool[];
|
|
63
|
+
}>): Promise<LoadResult>;
|
|
64
|
+
unload(input: Readonly<{
|
|
65
|
+
kind: ResourceKind;
|
|
66
|
+
sourceId: string;
|
|
67
|
+
}>): Promise<LoadResult>;
|
|
68
|
+
createAgent(config: AgentConfiguration, options?: {
|
|
69
|
+
idempotencyKey?: string;
|
|
70
|
+
metadata?: JsonObject;
|
|
71
|
+
historySeed?: HistorySeed;
|
|
72
|
+
}): Promise<AgentId>;
|
|
73
|
+
updateAgentConfig(agentId: AgentId, config: AgentConfiguration, options: {
|
|
74
|
+
idempotencyKey: string;
|
|
75
|
+
}): Promise<void>;
|
|
76
|
+
deleteAgent(input: AgentDeletionRequest): Promise<void>;
|
|
77
|
+
revise(agentId: AgentId, input: {
|
|
78
|
+
messageId: MessageId;
|
|
79
|
+
expectedMessageRevision: number;
|
|
80
|
+
content: UserContent;
|
|
81
|
+
operationId: string;
|
|
82
|
+
effectDigestConfirmation?: string;
|
|
83
|
+
}): Promise<MessageRevisionResult>;
|
|
84
|
+
compact(input?: {
|
|
85
|
+
now?: string;
|
|
86
|
+
retentionMs?: number;
|
|
87
|
+
}): Promise<Readonly<{
|
|
88
|
+
deletedRunIds: readonly RunId[];
|
|
89
|
+
deletedToolCallIds: readonly ToolCallId[];
|
|
90
|
+
deletedEventCount: number;
|
|
91
|
+
retentionFloor: EventCursor;
|
|
92
|
+
skipped?: "active_consumers" | "no_eligible_events";
|
|
93
|
+
}>>;
|
|
94
|
+
contextStatus(agentId: AgentId, options?: {
|
|
95
|
+
contextWindow?: number;
|
|
96
|
+
}): Promise<ContextStatus>;
|
|
97
|
+
runPhase(agentId: AgentId, options: {
|
|
98
|
+
phase: string;
|
|
99
|
+
payload?: JsonValue;
|
|
100
|
+
input?: UserInput;
|
|
101
|
+
yieldToInput?: boolean;
|
|
102
|
+
idempotencyKey?: string;
|
|
103
|
+
}): Promise<AgentRun>;
|
|
104
|
+
compactContext(agentId: AgentId, options?: {
|
|
105
|
+
input?: UserInput;
|
|
106
|
+
instructions?: string;
|
|
107
|
+
idempotencyKey?: string;
|
|
108
|
+
}): Promise<AgentRun>;
|
|
109
|
+
start(agentId: AgentId, input: UserInput, options: {
|
|
110
|
+
idempotencyKey: string;
|
|
111
|
+
metadata?: JsonObject;
|
|
112
|
+
scope?: ScopeRef;
|
|
113
|
+
cwd?: string;
|
|
114
|
+
phasePayload?: JsonValue;
|
|
115
|
+
entryPhases?: ReadonlyArray<EntryPhaseSpec>;
|
|
116
|
+
}): Promise<AgentRun>;
|
|
117
|
+
run(runId: RunId): AgentRun;
|
|
118
|
+
listAgents(input?: {
|
|
119
|
+
after?: AgentListCursor;
|
|
120
|
+
limit?: number;
|
|
121
|
+
}): Promise<Page<AgentSummary, AgentListCursor>>;
|
|
122
|
+
listRuns(input?: {
|
|
123
|
+
agentId?: AgentId;
|
|
124
|
+
states?: readonly RunState[];
|
|
125
|
+
after?: RunListCursor;
|
|
126
|
+
limit?: number;
|
|
127
|
+
}): Promise<Page<RunSummary, RunListCursor>>;
|
|
128
|
+
listInvocations(agentId: AgentId, options: {
|
|
129
|
+
source: InvocationSource;
|
|
130
|
+
}): Promise<readonly InvocationCatalogEntry[]>;
|
|
131
|
+
consume(input: {
|
|
132
|
+
consumerId: string;
|
|
133
|
+
signal: AbortSignal;
|
|
134
|
+
onEvent(event: DurableRunEvent, context: Readonly<{
|
|
135
|
+
signal: AbortSignal;
|
|
136
|
+
}>): void | Promise<void>;
|
|
137
|
+
}): Promise<DurableConsumer>;
|
|
138
|
+
listCapabilities(): readonly ExtensionCapability[];
|
|
139
|
+
onCapabilitiesChanged(listener: (capabilities: readonly ExtensionCapability[]) => void): () => void;
|
|
140
|
+
triggerUiAction(event: {
|
|
141
|
+
contributionId: string;
|
|
142
|
+
actionId: string;
|
|
143
|
+
scope?: ScopeRef;
|
|
144
|
+
}): void;
|
|
145
|
+
private liveInteract;
|
|
146
|
+
close(): Promise<void>;
|
|
147
|
+
snapshot(runId: RunId): Promise<RunSnapshot>;
|
|
148
|
+
history(agentId: AgentId): Promise<readonly Message[]>;
|
|
149
|
+
respondInteraction(runId: RunId, input: {
|
|
150
|
+
interactionId: string;
|
|
151
|
+
input?: JsonValue;
|
|
152
|
+
cancel?: boolean;
|
|
153
|
+
}): Promise<void>;
|
|
154
|
+
cancel(runId: RunId, reason?: string): Promise<RunBoundary>;
|
|
155
|
+
private pump;
|
|
156
|
+
private execute;
|
|
157
|
+
private failQueued;
|
|
158
|
+
private resolveContextWindow;
|
|
159
|
+
private executeTool;
|
|
160
|
+
private executeToolBatch;
|
|
161
|
+
private executeAndCommitTool;
|
|
162
|
+
private foldToolInteractionRecords;
|
|
163
|
+
private requireAgent;
|
|
164
|
+
private archiveDirFor;
|
|
165
|
+
private runConsumer;
|
|
166
|
+
observe(runId: RunId, options?: {
|
|
167
|
+
after?: EventCursor;
|
|
168
|
+
signal?: AbortSignal;
|
|
169
|
+
}): AsyncIterable<RunEvent>;
|
|
170
|
+
wait(runId: RunId, options?: {
|
|
171
|
+
signal?: AbortSignal;
|
|
172
|
+
}): Promise<RunBoundary>;
|
|
173
|
+
private assertOpen;
|
|
174
|
+
/** Resolve one stored configuration to the snapshot this execution uses. A
|
|
175
|
+
* stored snapshot is already source-qualified and is used as it stands. */
|
|
176
|
+
private resolveConfig;
|
|
177
|
+
private startHeartbeat;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
type Mutable<T> = {
|
|
181
|
+
-readonly [Key in keyof T]: T[Key];
|
|
182
|
+
};
|
|
183
|
+
type StoredAgent = Mutable<AgentRecord>;
|
|
184
|
+
type StoredRun = Mutable<RunRecord>;
|
|
185
|
+
type StoredToolCall = Mutable<ToolCallSnapshot>;
|
|
186
|
+
type IdempotencyReceipt = {
|
|
187
|
+
payload: string;
|
|
188
|
+
result: unknown;
|
|
189
|
+
};
|
|
190
|
+
type StoreMutationRecorder = {
|
|
191
|
+
onAgentUpsert(agent: StoredAgent): void;
|
|
192
|
+
onAgentDelete(agentId: AgentId): void;
|
|
193
|
+
onRunUpsert(run: StoredRun): void;
|
|
194
|
+
onRunDelete(runId: RunId): void;
|
|
195
|
+
onMessageInsert(message: Message): void;
|
|
196
|
+
onMessageDelete(messageId: MessageId): void;
|
|
197
|
+
onToolCallUpsert(toolCall: StoredToolCall): void;
|
|
198
|
+
onToolCallDelete(toolCallId: ToolCallId): void;
|
|
199
|
+
onEventAppend(event: DurableRunEvent): void;
|
|
200
|
+
onEventsTruncate(deletedEventIds: string[]): void;
|
|
201
|
+
onIdempotencyUpsert(scope: string, receipt: IdempotencyReceipt): void;
|
|
202
|
+
onIdempotencyDelete(scope: string): void;
|
|
203
|
+
onOperationReceiptUpsert(key: string, receipt: IdempotencyReceipt): void;
|
|
204
|
+
onOperationReceiptDelete(key: string): void;
|
|
205
|
+
onConsumerCheckpointUpsert(consumerId: string, cursor: EventCursor): void;
|
|
206
|
+
onConsumerCheckpointDelete(consumerId: string): void;
|
|
207
|
+
onContextCompactionUpsert(agentId: AgentId, record: ContextCompactionRecord): void;
|
|
208
|
+
onRetentionFloorChange(floor: number): void;
|
|
209
|
+
};
|
|
210
|
+
type InMemoryStoreState = Readonly<{
|
|
211
|
+
incarnation: string;
|
|
212
|
+
agents: readonly AgentRecord[];
|
|
213
|
+
runs: readonly RunRecord[];
|
|
214
|
+
messages: readonly Message[];
|
|
215
|
+
toolCalls: readonly ToolCallSnapshot[];
|
|
216
|
+
events: readonly DurableRunEvent[];
|
|
217
|
+
idempotency: readonly (readonly [string, IdempotencyReceipt])[];
|
|
218
|
+
operationReceipts: readonly (readonly [string, IdempotencyReceipt])[];
|
|
219
|
+
historySeeds?: readonly (readonly [AgentId, readonly Message[]])[];
|
|
220
|
+
consumerCheckpoints?: readonly (readonly [string, EventCursor])[];
|
|
221
|
+
retentionFloor?: number;
|
|
222
|
+
nextAgentSequence: readonly (readonly [AgentId, number])[];
|
|
223
|
+
nextReadySequence: readonly (readonly [AgentId, number])[];
|
|
224
|
+
eventSequence: number;
|
|
225
|
+
contextCompactions?: readonly (readonly [AgentId, ContextCompactionRecord])[];
|
|
226
|
+
}>;
|
|
227
|
+
declare class InMemoryStore implements DurableStore {
|
|
228
|
+
private readonly incarnation;
|
|
229
|
+
private readonly agents;
|
|
230
|
+
private readonly runs;
|
|
231
|
+
private readonly messages;
|
|
232
|
+
private readonly toolCalls;
|
|
233
|
+
private readonly events;
|
|
234
|
+
private readonly idempotency;
|
|
235
|
+
private readonly operationReceipts;
|
|
236
|
+
private readonly historySeeds;
|
|
237
|
+
private readonly consumerCheckpoints;
|
|
238
|
+
private readonly nextAgentSequence;
|
|
239
|
+
private readonly nextReadySequence;
|
|
240
|
+
private owner?;
|
|
241
|
+
private ownerEpoch;
|
|
242
|
+
private eventSequence;
|
|
243
|
+
private retentionFloor;
|
|
244
|
+
private readonly contextCompactions;
|
|
245
|
+
private recorder?;
|
|
246
|
+
private readonly runReceiptKeys;
|
|
247
|
+
constructor(options?: {
|
|
248
|
+
incarnation?: string;
|
|
249
|
+
});
|
|
250
|
+
setChangeRecorder(recorder?: StoreMutationRecorder): void;
|
|
251
|
+
private touchAgent;
|
|
252
|
+
private touchRun;
|
|
253
|
+
private storeMessage;
|
|
254
|
+
private storeToolCall;
|
|
255
|
+
private appendEvent;
|
|
256
|
+
inferRunIdForReceipt(key: string, payload: string): RunId | undefined;
|
|
257
|
+
dropRunOperationReceipts(runId: RunId): void;
|
|
258
|
+
compactTerminalReceipts(): number;
|
|
259
|
+
static fromState(state: InMemoryStoreState): InMemoryStore;
|
|
260
|
+
exportState(): InMemoryStoreState;
|
|
261
|
+
exportMetadata(): Record<string, unknown>;
|
|
262
|
+
attachOwner(lease: OwnerLease): void;
|
|
263
|
+
interruptOwner(ownerEpoch: number, message?: string): void;
|
|
264
|
+
openOwner(input: {
|
|
265
|
+
ownerId: string;
|
|
266
|
+
leaseMs: number;
|
|
267
|
+
}): Promise<OwnedStore>;
|
|
268
|
+
assertOwner(lease: OwnerLease, requireLive?: boolean): void;
|
|
269
|
+
renewOwner(lease: OwnerLease, leaseMs: number): OwnerLease;
|
|
270
|
+
releaseOwner(lease: OwnerLease): void;
|
|
271
|
+
reserveAgent(lease: OwnerLease, input: {
|
|
272
|
+
idempotencyKey: string;
|
|
273
|
+
metadata?: JsonObject;
|
|
274
|
+
configIdentity?: string;
|
|
275
|
+
historySeed?: HistorySeed;
|
|
276
|
+
}): AgentRecord;
|
|
277
|
+
activateAgent(lease: OwnerLease, agentId: AgentId, configToken?: ConfigToken, configIdentity?: string): AgentRecord;
|
|
278
|
+
updateAgentConfigToken(lease: OwnerLease, input: {
|
|
279
|
+
agentId: AgentId;
|
|
280
|
+
token: ConfigToken;
|
|
281
|
+
configIdentity?: string;
|
|
282
|
+
idempotencyKey: string;
|
|
283
|
+
}): AgentRecord;
|
|
284
|
+
deleteAgent(lease: OwnerLease, input: AgentDeletionRequest): void;
|
|
285
|
+
reviseMessage(lease: OwnerLease, input: {
|
|
286
|
+
agentId: AgentId;
|
|
287
|
+
messageId: MessageId;
|
|
288
|
+
expectedMessageRevision: number;
|
|
289
|
+
content: UserContent;
|
|
290
|
+
operationId: string;
|
|
291
|
+
effectDigestConfirmation?: string;
|
|
292
|
+
}): MessageRevisionResult;
|
|
293
|
+
private commitInteractionRecord;
|
|
294
|
+
createRun(lease: OwnerLease, input: {
|
|
295
|
+
agentId: AgentId;
|
|
296
|
+
input: UserInput;
|
|
297
|
+
metadata?: JsonObject;
|
|
298
|
+
scope?: ScopeRef;
|
|
299
|
+
cwd?: string;
|
|
300
|
+
phasePayload?: JsonValue;
|
|
301
|
+
entryPhases?: readonly EntryPhaseSpec[];
|
|
302
|
+
pinnedConfigToken?: ConfigToken;
|
|
303
|
+
idempotencyKey: string;
|
|
304
|
+
}): RunRecord;
|
|
305
|
+
claimRun(lease: OwnerLease, input: {
|
|
306
|
+
runId: RunId;
|
|
307
|
+
expectedRevision: number;
|
|
308
|
+
executionId?: ExecutionId;
|
|
309
|
+
messageId?: MessageId;
|
|
310
|
+
configToken?: ConfigToken;
|
|
311
|
+
additionalContexts?: readonly ContextCandidate[];
|
|
312
|
+
}): RunClaim;
|
|
313
|
+
failQueuedRun(lease: OwnerLease, input: {
|
|
314
|
+
runId: RunId;
|
|
315
|
+
expectedRevision: number;
|
|
316
|
+
failure: Extract<RunFailure, {
|
|
317
|
+
code: "configuration_unavailable" | "checkpoint_incompatible";
|
|
318
|
+
}>;
|
|
319
|
+
}): RunRecord;
|
|
320
|
+
commitPhaseEntered(lease: OwnerLease, input: {
|
|
321
|
+
runId: RunId;
|
|
322
|
+
execution: ExecutionToken;
|
|
323
|
+
expectedRevision: number;
|
|
324
|
+
phaseId: string;
|
|
325
|
+
visit: number;
|
|
326
|
+
}): RunRecord;
|
|
327
|
+
/** Commit a parallel Phase's reply while its Run is still running. */
|
|
328
|
+
commitPhaseOutput(lease: OwnerLease, input: {
|
|
329
|
+
runId: RunId;
|
|
330
|
+
execution: ExecutionToken;
|
|
331
|
+
expectedRevision: number;
|
|
332
|
+
message: AssistantMessage;
|
|
333
|
+
}): RunRecord;
|
|
334
|
+
commitInputRequired(lease: OwnerLease, input: {
|
|
335
|
+
runId: RunId;
|
|
336
|
+
execution: ExecutionToken;
|
|
337
|
+
expectedRevision: number;
|
|
338
|
+
phase: string;
|
|
339
|
+
prompt?: AssistantMessage;
|
|
340
|
+
checkpoint: ExecutionCheckpoint;
|
|
341
|
+
interactions?: readonly RunInteraction[];
|
|
342
|
+
interactionAnswers?: Readonly<Record<string, JsonValue>>;
|
|
343
|
+
pendingToolCallIds?: readonly ToolCallId[];
|
|
344
|
+
}): RunRecord;
|
|
345
|
+
answerInteraction(lease: OwnerLease, input: {
|
|
346
|
+
runId: RunId;
|
|
347
|
+
interactionId: string;
|
|
348
|
+
expectedRevision: number;
|
|
349
|
+
input?: JsonValue;
|
|
350
|
+
cancel?: boolean;
|
|
351
|
+
}): RunRecord;
|
|
352
|
+
reserveToolCall(lease: OwnerLease, input: {
|
|
353
|
+
runId: RunId;
|
|
354
|
+
execution: ExecutionToken;
|
|
355
|
+
expectedRevision: number;
|
|
356
|
+
requestMessageId: MessageId;
|
|
357
|
+
name: string;
|
|
358
|
+
args: JsonValue;
|
|
359
|
+
toolCallId?: ToolCallId;
|
|
360
|
+
providerToolCallId?: string;
|
|
361
|
+
model?: ModelRef;
|
|
362
|
+
usage?: LlmTokenUsage;
|
|
363
|
+
}): ToolCommit;
|
|
364
|
+
reserveToolCalls(lease: OwnerLease, input: {
|
|
365
|
+
runId: RunId;
|
|
366
|
+
execution: ExecutionToken;
|
|
367
|
+
expectedRevision: number;
|
|
368
|
+
requestMessageId: MessageId;
|
|
369
|
+
calls: readonly ToolCallReservation[];
|
|
370
|
+
/** The model response's blocks, so the request message keeps what preceded the Tool Calls. */
|
|
371
|
+
contentBlocks?: readonly StreamBlock[];
|
|
372
|
+
model?: ModelRef;
|
|
373
|
+
usage?: LlmTokenUsage;
|
|
374
|
+
}): ToolBatchCommit;
|
|
375
|
+
startToolCall(lease: OwnerLease, input: {
|
|
376
|
+
runId: RunId;
|
|
377
|
+
execution: ExecutionToken;
|
|
378
|
+
expectedRevision: number;
|
|
379
|
+
toolCallId: ToolCallId;
|
|
380
|
+
title?: string;
|
|
381
|
+
kind?: ToolKind;
|
|
382
|
+
locations?: ToolCallLocation[];
|
|
383
|
+
content?: ToolCallContent[];
|
|
384
|
+
_meta?: JsonObject;
|
|
385
|
+
}): ToolCommit;
|
|
386
|
+
suspendToolCall(lease: OwnerLease, input: {
|
|
387
|
+
runId: RunId;
|
|
388
|
+
execution: ExecutionToken;
|
|
389
|
+
expectedRevision: number;
|
|
390
|
+
toolCallId: ToolCallId;
|
|
391
|
+
}): ToolCommit;
|
|
392
|
+
commitToolResult(lease: OwnerLease, input: {
|
|
393
|
+
runId: RunId;
|
|
394
|
+
execution: ExecutionToken;
|
|
395
|
+
expectedRevision: number;
|
|
396
|
+
toolCallId: ToolCallId;
|
|
397
|
+
result: ToolResult;
|
|
398
|
+
state: "completed" | "failed" | "indeterminate";
|
|
399
|
+
reason?: string;
|
|
400
|
+
title?: string;
|
|
401
|
+
kind?: ToolKind;
|
|
402
|
+
content?: ToolCallContent[];
|
|
403
|
+
locations?: ToolCallLocation[];
|
|
404
|
+
rawOutput?: JsonValue;
|
|
405
|
+
_meta?: JsonObject;
|
|
406
|
+
}): ToolCommit;
|
|
407
|
+
commitOutcome(lease: OwnerLease, input: {
|
|
408
|
+
runId: RunId;
|
|
409
|
+
execution: ExecutionToken;
|
|
410
|
+
expectedRevision: number;
|
|
411
|
+
outcome?: Outcome;
|
|
412
|
+
failure?: RunFailure;
|
|
413
|
+
output?: AssistantMessage;
|
|
414
|
+
}): RunRecord;
|
|
415
|
+
cancelRun(lease: OwnerLease, input: {
|
|
416
|
+
runId: RunId;
|
|
417
|
+
expectedRevision?: number;
|
|
418
|
+
reason?: string;
|
|
419
|
+
output?: AssistantMessage;
|
|
420
|
+
}): RunRecord;
|
|
421
|
+
recordToolCall(lease: OwnerLease, input: {
|
|
422
|
+
runId: RunId;
|
|
423
|
+
execution?: ExecutionToken;
|
|
424
|
+
update: ToolCall | ToolCallUpdate;
|
|
425
|
+
external?: boolean;
|
|
426
|
+
contentIndex?: number;
|
|
427
|
+
}): DurableRunEvent;
|
|
428
|
+
snapshotRun(lease: OwnerLease, runId: RunId): RunSnapshot;
|
|
429
|
+
listAgents(lease: OwnerLease): readonly AgentRecord[];
|
|
430
|
+
listRuns(lease: OwnerLease, input?: {
|
|
431
|
+
agentId?: AgentId;
|
|
432
|
+
states?: readonly RunState[];
|
|
433
|
+
}): readonly RunRecord[];
|
|
434
|
+
listEvents(lease: OwnerLease, input?: {
|
|
435
|
+
after?: EventCursor;
|
|
436
|
+
}): readonly DurableRunEvent[];
|
|
437
|
+
openConsumer(lease: OwnerLease, consumerId: string): ConsumerRegistration;
|
|
438
|
+
advanceConsumerCheckpoint(lease: OwnerLease, input: {
|
|
439
|
+
consumerId: string;
|
|
440
|
+
cursor: EventCursor;
|
|
441
|
+
}): void;
|
|
442
|
+
compact(lease: OwnerLease, input?: {
|
|
443
|
+
now?: string;
|
|
444
|
+
retentionMs?: number;
|
|
445
|
+
}): RetentionResult;
|
|
446
|
+
private replay;
|
|
447
|
+
private writeReceipt;
|
|
448
|
+
private replayOperation;
|
|
449
|
+
private writeOperationReceipt;
|
|
450
|
+
/**
|
|
451
|
+
* A Claim receipt exists for idempotent replay of one live Execution Attempt
|
|
452
|
+
* and carries that Attempt's history. Dropping it when the Attempt ends keeps
|
|
453
|
+
* one history snapshot per Agent instead of one per Attempt.
|
|
454
|
+
*/
|
|
455
|
+
private dropClaimReceipt;
|
|
456
|
+
/**
|
|
457
|
+
* A new owner fences the Execution Attempts of the previous one, so no Claim
|
|
458
|
+
* receipt from before the takeover can be replayed. Sweeping them reclaims
|
|
459
|
+
* the history snapshots a store accumulated while no Attempt ended under
|
|
460
|
+
* this Runtime.
|
|
461
|
+
*/
|
|
462
|
+
dropSettledClaimReceipts(): void;
|
|
463
|
+
private requireAgent;
|
|
464
|
+
private requireRun;
|
|
465
|
+
private requireToolCall;
|
|
466
|
+
private assertNoOpenTools;
|
|
467
|
+
private interruptToolCall;
|
|
468
|
+
private assertState;
|
|
469
|
+
private assertRevision;
|
|
470
|
+
private assertExecution;
|
|
471
|
+
private nextSequence;
|
|
472
|
+
private nextReady;
|
|
473
|
+
private nextMessageSequence;
|
|
474
|
+
private messagesForRun;
|
|
475
|
+
private withdrawUserInputIfNoOutput;
|
|
476
|
+
history(lease: OwnerLease, agentId: AgentId): readonly Message[];
|
|
477
|
+
contextStatus(lease: OwnerLease, agentId: AgentId, contextWindow: number): ContextStatus;
|
|
478
|
+
contextMessages(lease: OwnerLease, agentId: AgentId, recentTokenBudget?: number): readonly Message[];
|
|
479
|
+
commitContextCompaction(lease: OwnerLease, record: ContextCompactionRecord): ContextCompactionRecord;
|
|
480
|
+
private activeHistory;
|
|
481
|
+
private appendMessage;
|
|
482
|
+
private appendTransition;
|
|
483
|
+
private appendToolTransition;
|
|
484
|
+
private baseEvent;
|
|
485
|
+
private cursorForRun;
|
|
486
|
+
private parseCursor;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
declare class SqliteStore implements DurableStore {
|
|
490
|
+
private readonly database;
|
|
491
|
+
private readonly archiveRoot;
|
|
492
|
+
private readonly mirroredEventIds;
|
|
493
|
+
private readonly mirroredCompactionIds;
|
|
494
|
+
private mirroredAgents;
|
|
495
|
+
private closed;
|
|
496
|
+
private configured;
|
|
497
|
+
private cachedMemory?;
|
|
498
|
+
private cachedOwner?;
|
|
499
|
+
private isLegacyState;
|
|
500
|
+
private stmtUpsertAgent?;
|
|
501
|
+
private stmtDeleteAgent?;
|
|
502
|
+
private stmtUpsertRun?;
|
|
503
|
+
private stmtDeleteRun?;
|
|
504
|
+
private stmtInsertMessage?;
|
|
505
|
+
private stmtDeleteMessage?;
|
|
506
|
+
private stmtUpsertToolCall?;
|
|
507
|
+
private stmtDeleteToolCall?;
|
|
508
|
+
private stmtInsertEvent?;
|
|
509
|
+
private stmtDeleteEvent?;
|
|
510
|
+
private stmtUpsertIdempotency?;
|
|
511
|
+
private stmtDeleteIdempotency?;
|
|
512
|
+
private stmtUpsertCheckpoint?;
|
|
513
|
+
private stmtDeleteCheckpoint?;
|
|
514
|
+
private stmtUpdateMeta?;
|
|
515
|
+
private stmtUpdateState?;
|
|
516
|
+
constructor(filename?: string);
|
|
517
|
+
openOwner(input: {
|
|
518
|
+
ownerId: string;
|
|
519
|
+
leaseMs: number;
|
|
520
|
+
}): Promise<OwnedStore>;
|
|
521
|
+
close(): void;
|
|
522
|
+
exportState(): InMemoryStoreState;
|
|
523
|
+
/** Filesystem location owned by this Store for one Agent's readable archive. */
|
|
524
|
+
contextArchiveDir(agentId: AgentId): string;
|
|
525
|
+
reserveAgent(lease: OwnerLease, input: {
|
|
526
|
+
idempotencyKey: string;
|
|
527
|
+
metadata?: JsonObject;
|
|
528
|
+
configIdentity?: string;
|
|
529
|
+
historySeed?: HistorySeed;
|
|
530
|
+
}): Promise<AgentRecord>;
|
|
531
|
+
activateAgent(lease: OwnerLease, agentId: AgentId, configToken?: ConfigToken, configIdentity?: string): Promise<AgentRecord>;
|
|
532
|
+
updateAgentConfigToken(lease: OwnerLease, input: {
|
|
533
|
+
agentId: AgentId;
|
|
534
|
+
token: ConfigToken;
|
|
535
|
+
configIdentity?: string;
|
|
536
|
+
idempotencyKey: string;
|
|
537
|
+
}): Promise<AgentRecord>;
|
|
538
|
+
deleteAgent(lease: OwnerLease, input: AgentDeletionRequest): Promise<void>;
|
|
539
|
+
reviseMessage(lease: OwnerLease, input: {
|
|
540
|
+
agentId: AgentId;
|
|
541
|
+
messageId: MessageId;
|
|
542
|
+
expectedMessageRevision: number;
|
|
543
|
+
content: UserContent;
|
|
544
|
+
operationId: string;
|
|
545
|
+
effectDigestConfirmation?: string;
|
|
546
|
+
}): Promise<MessageRevisionResult>;
|
|
547
|
+
contextStatus(lease: OwnerLease, agentId: AgentId, contextWindow: number): Promise<ContextStatus>;
|
|
548
|
+
contextMessages(lease: OwnerLease, agentId: AgentId, recentTokenBudget?: number): Promise<readonly Message[]>;
|
|
549
|
+
commitContextCompaction(lease: OwnerLease, record: ContextCompactionRecord): Promise<ContextCompactionRecord>;
|
|
550
|
+
createRun(lease: OwnerLease, input: {
|
|
551
|
+
agentId: AgentId;
|
|
552
|
+
input: UserInput;
|
|
553
|
+
metadata?: JsonObject;
|
|
554
|
+
scope?: ScopeRef;
|
|
555
|
+
cwd?: string;
|
|
556
|
+
phasePayload?: JsonValue;
|
|
557
|
+
entryPhases?: readonly EntryPhaseSpec[];
|
|
558
|
+
pinnedConfigToken?: ConfigToken;
|
|
559
|
+
idempotencyKey: string;
|
|
560
|
+
}): Promise<RunRecord>;
|
|
561
|
+
claimRun(lease: OwnerLease, input: {
|
|
562
|
+
runId: RunId;
|
|
563
|
+
expectedRevision: number;
|
|
564
|
+
executionId?: ExecutionId;
|
|
565
|
+
messageId?: MessageId;
|
|
566
|
+
configToken?: ConfigToken;
|
|
567
|
+
additionalContexts?: readonly ContextCandidate[];
|
|
568
|
+
}): Promise<RunClaim>;
|
|
569
|
+
failQueuedRun(lease: OwnerLease, input: {
|
|
570
|
+
runId: RunId;
|
|
571
|
+
expectedRevision: number;
|
|
572
|
+
failure: Extract<RunFailure, {
|
|
573
|
+
code: "configuration_unavailable" | "checkpoint_incompatible";
|
|
574
|
+
}>;
|
|
575
|
+
}): Promise<RunRecord>;
|
|
576
|
+
commitPhaseEntered(lease: OwnerLease, input: {
|
|
577
|
+
runId: RunId;
|
|
578
|
+
execution: ExecutionToken;
|
|
579
|
+
expectedRevision: number;
|
|
580
|
+
phaseId: string;
|
|
581
|
+
visit: number;
|
|
582
|
+
}): Promise<RunRecord>;
|
|
583
|
+
commitPhaseOutput(lease: OwnerLease, input: {
|
|
584
|
+
runId: RunId;
|
|
585
|
+
execution: ExecutionToken;
|
|
586
|
+
expectedRevision: number;
|
|
587
|
+
message: AssistantMessage;
|
|
588
|
+
}): Promise<RunRecord>;
|
|
589
|
+
commitInputRequired(lease: OwnerLease, input: {
|
|
590
|
+
runId: RunId;
|
|
591
|
+
execution: ExecutionToken;
|
|
592
|
+
expectedRevision: number;
|
|
593
|
+
phase: string;
|
|
594
|
+
prompt?: AssistantMessage;
|
|
595
|
+
checkpoint: ExecutionCheckpoint;
|
|
596
|
+
interactions?: readonly RunInteraction[];
|
|
597
|
+
interactionAnswers?: Readonly<Record<string, JsonValue>>;
|
|
598
|
+
pendingToolCallIds?: readonly ToolCallId[];
|
|
599
|
+
}): Promise<RunRecord>;
|
|
600
|
+
answerInteraction(lease: OwnerLease, input: {
|
|
601
|
+
runId: RunId;
|
|
602
|
+
interactionId: string;
|
|
603
|
+
expectedRevision: number;
|
|
604
|
+
input?: JsonValue;
|
|
605
|
+
cancel?: boolean;
|
|
606
|
+
}): Promise<RunRecord>;
|
|
607
|
+
commitOutcome(lease: OwnerLease, input: {
|
|
608
|
+
runId: RunId;
|
|
609
|
+
execution: ExecutionToken;
|
|
610
|
+
expectedRevision: number;
|
|
611
|
+
outcome?: Outcome;
|
|
612
|
+
failure?: RunFailure;
|
|
613
|
+
output?: AssistantMessage;
|
|
614
|
+
}): Promise<RunRecord>;
|
|
615
|
+
reserveToolCall(lease: OwnerLease, input: {
|
|
616
|
+
runId: RunId;
|
|
617
|
+
execution: ExecutionToken;
|
|
618
|
+
expectedRevision: number;
|
|
619
|
+
requestMessageId: MessageId;
|
|
620
|
+
name: string;
|
|
621
|
+
args: JsonValue;
|
|
622
|
+
toolCallId?: ToolCallId;
|
|
623
|
+
providerToolCallId?: string;
|
|
624
|
+
title?: string;
|
|
625
|
+
kind?: ToolKind;
|
|
626
|
+
locations?: ToolCallLocation[];
|
|
627
|
+
content?: ToolCallContent[];
|
|
628
|
+
_meta?: JsonObject;
|
|
629
|
+
model?: _rowan_agent_models.ModelRef;
|
|
630
|
+
usage?: _rowan_agent_models.LlmTokenUsage;
|
|
631
|
+
}): Promise<ToolCommit>;
|
|
632
|
+
reserveToolCalls(lease: OwnerLease, input: {
|
|
633
|
+
runId: RunId;
|
|
634
|
+
execution: ExecutionToken;
|
|
635
|
+
expectedRevision: number;
|
|
636
|
+
requestMessageId: MessageId;
|
|
637
|
+
calls: readonly ToolCallReservation[];
|
|
638
|
+
contentBlocks?: readonly StreamBlock[];
|
|
639
|
+
model?: _rowan_agent_models.ModelRef;
|
|
640
|
+
usage?: _rowan_agent_models.LlmTokenUsage;
|
|
641
|
+
}): Promise<ToolBatchCommit>;
|
|
642
|
+
startToolCall(lease: OwnerLease, input: {
|
|
643
|
+
runId: RunId;
|
|
644
|
+
execution: ExecutionToken;
|
|
645
|
+
expectedRevision: number;
|
|
646
|
+
toolCallId: ToolCallId;
|
|
647
|
+
title?: string;
|
|
648
|
+
kind?: ToolKind;
|
|
649
|
+
locations?: ToolCallLocation[];
|
|
650
|
+
content?: ToolCallContent[];
|
|
651
|
+
_meta?: JsonObject;
|
|
652
|
+
}): Promise<ToolCommit>;
|
|
653
|
+
suspendToolCall(lease: OwnerLease, input: {
|
|
654
|
+
runId: RunId;
|
|
655
|
+
execution: ExecutionToken;
|
|
656
|
+
expectedRevision: number;
|
|
657
|
+
toolCallId: ToolCallId;
|
|
658
|
+
}): Promise<ToolCommit>;
|
|
659
|
+
commitToolResult(lease: OwnerLease, input: {
|
|
660
|
+
runId: RunId;
|
|
661
|
+
execution: ExecutionToken;
|
|
662
|
+
expectedRevision: number;
|
|
663
|
+
toolCallId: ToolCallId;
|
|
664
|
+
result: ToolResult;
|
|
665
|
+
state: "completed" | "failed" | "indeterminate";
|
|
666
|
+
reason?: string;
|
|
667
|
+
title?: string;
|
|
668
|
+
kind?: ToolKind;
|
|
669
|
+
content?: ToolCallContent[];
|
|
670
|
+
locations?: ToolCallLocation[];
|
|
671
|
+
rawOutput?: JsonValue;
|
|
672
|
+
_meta?: JsonObject;
|
|
673
|
+
}): Promise<ToolCommit>;
|
|
674
|
+
cancelRun(lease: OwnerLease, input: {
|
|
675
|
+
runId: RunId;
|
|
676
|
+
expectedRevision?: number;
|
|
677
|
+
reason?: string;
|
|
678
|
+
output?: AssistantMessage;
|
|
679
|
+
}): Promise<RunRecord>;
|
|
680
|
+
recordToolCall(lease: OwnerLease, input: {
|
|
681
|
+
runId: RunId;
|
|
682
|
+
execution?: ExecutionToken;
|
|
683
|
+
update: ToolCall | ToolCallUpdate;
|
|
684
|
+
external?: boolean;
|
|
685
|
+
contentIndex?: number;
|
|
686
|
+
}): Promise<DurableRunEvent>;
|
|
687
|
+
snapshotRun(lease: OwnerLease, runId: RunId): Promise<RunSnapshot>;
|
|
688
|
+
history(lease: OwnerLease, agentId: AgentId): Promise<readonly Message[]>;
|
|
689
|
+
listAgents(lease: OwnerLease): Promise<readonly AgentRecord[]>;
|
|
690
|
+
listRuns(lease: OwnerLease, input?: {
|
|
691
|
+
agentId?: AgentId;
|
|
692
|
+
states?: readonly RunState[];
|
|
693
|
+
}): Promise<readonly RunRecord[]>;
|
|
694
|
+
listEvents(lease: OwnerLease, input?: {
|
|
695
|
+
after?: EventCursor;
|
|
696
|
+
}): Promise<readonly DurableRunEvent[]>;
|
|
697
|
+
openConsumer(lease: OwnerLease, consumerId: string): Promise<ConsumerRegistration>;
|
|
698
|
+
advanceConsumerCheckpoint(lease: OwnerLease, input: {
|
|
699
|
+
consumerId: string;
|
|
700
|
+
cursor: EventCursor;
|
|
701
|
+
}): Promise<void>;
|
|
702
|
+
compact(lease: OwnerLease, input?: {
|
|
703
|
+
now?: string;
|
|
704
|
+
retentionMs?: number;
|
|
705
|
+
}): Promise<RetentionResult>;
|
|
706
|
+
renewOwner(lease: OwnerLease, leaseMs: number): Promise<OwnerLease>;
|
|
707
|
+
sealAndReleaseOwner(lease: OwnerLease): Promise<void>;
|
|
708
|
+
private read;
|
|
709
|
+
private write;
|
|
710
|
+
private invoke;
|
|
711
|
+
private ensureSchema;
|
|
712
|
+
private isCurrentSchema;
|
|
713
|
+
private configure;
|
|
714
|
+
private catalog;
|
|
715
|
+
private readOwner;
|
|
716
|
+
private writeOwner;
|
|
717
|
+
private readState;
|
|
718
|
+
private loadTableBackedState;
|
|
719
|
+
private ensureTableBackedStorage;
|
|
720
|
+
private getStmtUpsertAgent;
|
|
721
|
+
private getStmtDeleteAgent;
|
|
722
|
+
private getStmtUpsertRun;
|
|
723
|
+
private getStmtDeleteRun;
|
|
724
|
+
private getStmtInsertMessage;
|
|
725
|
+
private getStmtDeleteMessage;
|
|
726
|
+
private getStmtUpsertToolCall;
|
|
727
|
+
private getStmtDeleteToolCall;
|
|
728
|
+
private getStmtInsertEvent;
|
|
729
|
+
private getStmtDeleteEvent;
|
|
730
|
+
private getStmtUpsertIdempotency;
|
|
731
|
+
private getStmtDeleteIdempotency;
|
|
732
|
+
private getStmtUpsertCheckpoint;
|
|
733
|
+
private getStmtDeleteCheckpoint;
|
|
734
|
+
private getStmtUpdateMeta;
|
|
735
|
+
private getStmtUpdateState;
|
|
736
|
+
private persistChanges;
|
|
737
|
+
private writeFullStateToTables;
|
|
738
|
+
private mirrorChanges;
|
|
739
|
+
/** Append the semantic durable event mirror and remove deleted Agent sidecars. */
|
|
740
|
+
private mirrorInitialState;
|
|
741
|
+
private requireMatchingOwner;
|
|
742
|
+
private immediateTransaction;
|
|
743
|
+
private readTransaction;
|
|
744
|
+
private assertOpen;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/** A deterministic provider for tests and embedded hosts without a separate registry. */
|
|
748
|
+
declare class InMemoryConfigProvider implements ConfigProvider {
|
|
749
|
+
private readonly entries;
|
|
750
|
+
private readonly operations;
|
|
751
|
+
put(input: {
|
|
752
|
+
agentId: AgentId;
|
|
753
|
+
agentMetadata?: JsonObject;
|
|
754
|
+
config: AgentConfiguration | ConfigurationSnapshot;
|
|
755
|
+
operationId: string;
|
|
756
|
+
signal: AbortSignal;
|
|
757
|
+
}): Promise<ConfigPutResult>;
|
|
758
|
+
resolve(input: {
|
|
759
|
+
agentId: AgentId;
|
|
760
|
+
agentMetadata?: JsonObject;
|
|
761
|
+
token: ConfigToken;
|
|
762
|
+
signal: AbortSignal;
|
|
763
|
+
}): Promise<ConfigResolution>;
|
|
764
|
+
}
|
|
765
|
+
declare function brandConfigToken(raw: unknown): ConfigToken;
|
|
766
|
+
|
|
767
|
+
type RuntimeErrorCode = "invalid_argument" | "runtime_closed" | "runtime_already_owned" | "runtime_ownership_lost" | "agent_not_found" | "run_not_found" | "run_state_conflict" | "context_busy" | "message_history_compacted" | "message_revision_conflict" | "tool_effect_confirmation_required" | "input_request_conflict" | "idempotency_conflict" | "configuration_unavailable" | "checkpoint_incompatible" | "consumer_already_active" | "invalid_cursor" | "store_unavailable" | "unsupported_store_version";
|
|
768
|
+
type RuntimeErrorDetails = {
|
|
769
|
+
invalid_argument: Readonly<{
|
|
770
|
+
argument: string;
|
|
771
|
+
reason: string;
|
|
772
|
+
}>;
|
|
773
|
+
runtime_closed: null;
|
|
774
|
+
runtime_already_owned: Readonly<{
|
|
775
|
+
expiresAt: string;
|
|
776
|
+
retryAfterMs: number;
|
|
777
|
+
}>;
|
|
778
|
+
runtime_ownership_lost: Readonly<{
|
|
779
|
+
reason: "expired" | "released" | "epoch_advanced";
|
|
780
|
+
expectedEpoch: number;
|
|
781
|
+
actualEpoch: number;
|
|
782
|
+
expiresAt?: string;
|
|
783
|
+
}>;
|
|
784
|
+
agent_not_found: Readonly<{
|
|
785
|
+
agentId: AgentId;
|
|
786
|
+
}>;
|
|
787
|
+
run_not_found: Readonly<{
|
|
788
|
+
runId: RunId;
|
|
789
|
+
}>;
|
|
790
|
+
run_state_conflict: Readonly<{
|
|
791
|
+
runId: RunId;
|
|
792
|
+
expected: readonly RunState[];
|
|
793
|
+
actual: RunState;
|
|
794
|
+
}>;
|
|
795
|
+
context_busy: Readonly<{
|
|
796
|
+
agentId: AgentId;
|
|
797
|
+
runId?: RunId;
|
|
798
|
+
actual: RunState;
|
|
799
|
+
}>;
|
|
800
|
+
message_history_compacted: Readonly<{
|
|
801
|
+
agentId: AgentId;
|
|
802
|
+
messageId: MessageId;
|
|
803
|
+
}>;
|
|
804
|
+
message_revision_conflict: Readonly<{
|
|
805
|
+
agentId: AgentId;
|
|
806
|
+
messageId: MessageId;
|
|
807
|
+
expected: number;
|
|
808
|
+
actual: number;
|
|
809
|
+
}>;
|
|
810
|
+
tool_effect_confirmation_required: Readonly<{
|
|
811
|
+
agentId: AgentId;
|
|
812
|
+
messageId: MessageId;
|
|
813
|
+
effectDigest: string;
|
|
814
|
+
toolCallIds: readonly ToolCallId[];
|
|
815
|
+
}>;
|
|
816
|
+
input_request_conflict: Readonly<{
|
|
817
|
+
runId: RunId;
|
|
818
|
+
interactionId?: string;
|
|
819
|
+
requestId?: string;
|
|
820
|
+
reason: "not_found" | "wrong_run" | "different_answer";
|
|
821
|
+
}>;
|
|
822
|
+
idempotency_conflict: Readonly<{
|
|
823
|
+
scope: "create_agent" | "update_agent_config" | "start_run";
|
|
824
|
+
idempotencyKey: string;
|
|
825
|
+
}>;
|
|
826
|
+
configuration_unavailable: Readonly<{
|
|
827
|
+
agentId: AgentId;
|
|
828
|
+
runId?: RunId;
|
|
829
|
+
retryable: boolean;
|
|
830
|
+
reason: string;
|
|
831
|
+
}>;
|
|
832
|
+
checkpoint_incompatible: Readonly<{
|
|
833
|
+
runId: RunId;
|
|
834
|
+
expected: Readonly<{
|
|
835
|
+
codec: string;
|
|
836
|
+
versions: readonly number[];
|
|
837
|
+
}>;
|
|
838
|
+
actual: Readonly<{
|
|
839
|
+
codec: string;
|
|
840
|
+
version: number;
|
|
841
|
+
}>;
|
|
842
|
+
}>;
|
|
843
|
+
consumer_already_active: Readonly<{
|
|
844
|
+
consumerId: string;
|
|
845
|
+
}>;
|
|
846
|
+
invalid_cursor: Readonly<{
|
|
847
|
+
cursorType: "agent_list" | "run_list" | "event";
|
|
848
|
+
reason: "malformed" | "wrong_store" | "wrong_collection" | "filter_mismatch" | "beyond_waterline" | "expired";
|
|
849
|
+
}>;
|
|
850
|
+
store_unavailable: Readonly<{
|
|
851
|
+
operation: string;
|
|
852
|
+
retryable: boolean;
|
|
853
|
+
reason: string;
|
|
854
|
+
}>;
|
|
855
|
+
unsupported_store_version: Readonly<{
|
|
856
|
+
found: string | null;
|
|
857
|
+
supported: string;
|
|
858
|
+
}>;
|
|
859
|
+
};
|
|
860
|
+
type AnyRuntimeError = {
|
|
861
|
+
[Code in RuntimeErrorCode]: RuntimeError<Code>;
|
|
862
|
+
}[RuntimeErrorCode];
|
|
863
|
+
declare class RuntimeError<Code extends RuntimeErrorCode = RuntimeErrorCode> extends Error {
|
|
864
|
+
readonly code: Code;
|
|
865
|
+
readonly details: RuntimeErrorDetails[Code];
|
|
866
|
+
constructor(code: Code, details: RuntimeErrorDetails[Code], message?: Code);
|
|
867
|
+
}
|
|
868
|
+
declare function isRuntimeError(value: unknown): value is AnyRuntimeError;
|
|
869
|
+
|
|
870
|
+
declare function loadSkill(path: string): Promise<Skill>;
|
|
871
|
+
declare function loadSkills(targetPath: string): Promise<Skill[]>;
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* Load a single phase from a PHASE.md file or phase directory.
|
|
875
|
+
*
|
|
876
|
+
* If a directory is provided, the loader reads its PHASE.md.
|
|
877
|
+
*/
|
|
878
|
+
declare function loadPhase(targetPath: string): Promise<Phase>;
|
|
879
|
+
/**
|
|
880
|
+
* Load all phases from the target directory.
|
|
881
|
+
*
|
|
882
|
+
* Scans for subdirectories containing PHASE.md files.
|
|
883
|
+
* Returns PhaseRegistry with entryPhaseId:
|
|
884
|
+
* - null by default (caller must explicitly set to start from a specific phase)
|
|
885
|
+
* - Set to a specific phase name to start from that phase
|
|
886
|
+
*
|
|
887
|
+
* When entryPhaseId is null, Agent normalizes the registry to start from its default phase.
|
|
888
|
+
*/
|
|
889
|
+
declare function loadPhases(targetPath: string): Promise<PhaseRegistry>;
|
|
890
|
+
|
|
891
|
+
declare const DEFAULT_PHASE_ID = "default";
|
|
892
|
+
declare const STOP_PHASE_ID = "stop";
|
|
893
|
+
declare const COMPACT_PHASE_ID = "compact";
|
|
894
|
+
declare function createDefaultPhase(): Phase;
|
|
895
|
+
declare function createStopPhase(): Phase;
|
|
896
|
+
declare function createCompactPhase(): Phase;
|
|
897
|
+
declare function createCorePhases(): Phase[];
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Extension loader — discovers and loads extensions from the filesystem.
|
|
901
|
+
*
|
|
902
|
+
* Uses the new LoadedExtension type that works with ExtensionRunner.
|
|
903
|
+
*/
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Load extensions from the exact target path.
|
|
907
|
+
*
|
|
908
|
+
* If the target is a directory with its own extension entry, load that extension.
|
|
909
|
+
* Otherwise, scan its immediate children for extension packages/files.
|
|
910
|
+
*/
|
|
911
|
+
declare function loadExtensionsFromPath(path: string): Promise<{
|
|
912
|
+
extensions: LoadedExtension[];
|
|
913
|
+
errors: Array<{
|
|
914
|
+
path: string;
|
|
915
|
+
error: string;
|
|
916
|
+
}>;
|
|
917
|
+
}>;
|
|
918
|
+
|
|
919
|
+
/** Parsed frontmatter result */
|
|
920
|
+
interface FrontmatterResult<T = Record<string, unknown>> {
|
|
921
|
+
frontmatter: T;
|
|
922
|
+
body: string;
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Parse YAML frontmatter from markdown content.
|
|
926
|
+
* Parse YAML frontmatter and return the markdown body after the closing delimiter.
|
|
927
|
+
*/
|
|
928
|
+
declare function parseFrontmatter<T = Record<string, unknown>>(raw: string): FrontmatterResult<T>;
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* `root` anchors relative paths and the Bash working directory. It is not a
|
|
932
|
+
* filesystem sandbox: core Tools use the permissions of the host process.
|
|
933
|
+
*/
|
|
934
|
+
type CoreToolContext = {
|
|
935
|
+
root?: string;
|
|
936
|
+
/** Directory for complete Tool Result spill files. */
|
|
937
|
+
archiveDir?: string;
|
|
938
|
+
maxReadBytes?: number;
|
|
939
|
+
maxReadLines?: number;
|
|
940
|
+
bashTimeoutMs?: number;
|
|
941
|
+
maxBashOutputBytes?: number;
|
|
942
|
+
};
|
|
943
|
+
|
|
944
|
+
/** Adapt the established host-filesystem Core Tools to the durable Runtime Tool contract. */
|
|
945
|
+
declare function createRuntimeCoreTools(input?: CoreToolContext): Tool[];
|
|
946
|
+
|
|
947
|
+
export { AgentConfiguration, AgentDefinition, AgentRecord, AgentRuntime, AgentRuntimeOptions, type AnyRuntimeError, COMPACT_PHASE_ID, ConfigProvider, ConfigPutResult, ConfigResolution, ConfigToken, ConfigurationSnapshot, type CoreToolContext, DEFAULT_PHASE_ID, DurableStore, EntryPhaseSpec, ExecutionCheckpoint, ExecutionId, ExecutionToken, ExtensionHost, type FrontmatterResult, HistorySeed, HostApiExtension, InMemoryConfigProvider, InMemoryExtensionHost, InMemoryStore, InvocationCatalogEntry, InvocationSource, LoadInput, LoadResult, LoadedExtension, Outcome, OwnerLease, PhaseRegistry, ResourceKind, RetentionResult, RunClaim, RunRecord, RuntimeError, type RuntimeErrorCode, type RuntimeErrorDetails, STOP_PHASE_ID, Skill, SqliteStore, brandConfigToken, createCompactPhase, createCorePhases, createRuntimeCoreTools as createCoreTools, createDefaultPhase, createStopPhase, isRuntimeError, loadExtensionsFromPath as loadExtensions, loadPhase, loadPhases, loadSkill, loadSkills, parseFrontmatter };
|