@mono-agent/agent-runtime 0.20.14 → 0.21.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/ARCHITECTURE.md +50 -11
- package/MIGRATION.md +30 -7
- package/README.md +219 -35
- package/package.json +9 -4
- package/src/agent/tool-bloat.js +145 -9
- package/src/agent/tools/agent-tool.js +104 -5
- package/src/agent/tools/bash.js +10 -2
- package/src/agent/tools/codex-subscription-search.js +122 -28
- package/src/agent/tools/exec.js +10 -2
- package/src/agent/tools/monitor.js +11 -2
- package/src/agent/tools/pi-bridge.js +33 -14
- package/src/agent/tools/shared/monitors.js +22 -3
- package/src/agent/tools/shared/path-resolver.js +25 -6
- package/src/agent/tools/shared/process-jobs.js +6 -1
- package/src/agent/tools/shared/process-runner.js +3 -1
- package/src/agent/tools/shared/tool-context.js +8 -0
- package/src/agent/tools/web-access-interstitial.js +70 -0
- package/src/agent/tools/web-browser-render.js +83 -58
- package/src/agent/tools/web-controller.js +112 -21
- package/src/agent/tools/web-document-extractor.js +379 -0
- package/src/agent/tools/web-fetch.js +271 -243
- package/src/agent/tools/web-request.js +65 -0
- package/src/agent/tools/web-search-output.js +165 -0
- package/src/agent/tools/web-search-state.js +75 -0
- package/src/agent/tools/web-search.js +532 -71
- package/src/ai/failure.js +3 -3
- package/src/ai/index.js +1 -0
- package/src/ai/observer.js +8 -0
- package/src/ai/pi-interop.js +156 -0
- package/src/ai/provider-check.js +131 -0
- package/src/ai/providers/pi-native/compaction-driver.js +45 -21
- package/src/ai/providers/pi-native/compaction-summary.js +140 -0
- package/src/ai/providers/pi-native/harness-adapter.js +40 -2
- package/src/ai/providers/pi-native/prompt-cache-diagnostics.js +103 -0
- package/src/ai/providers/pi-native/provider-attribution.js +102 -0
- package/src/ai/providers/pi-native/result-builder.js +28 -4
- package/src/ai/providers/pi-native/session-lifecycle.js +167 -24
- package/src/ai/providers/pi-native/stream-subscriber.js +30 -2
- package/src/ai/providers/pi-native/terminal-recovery.js +40 -0
- package/src/ai/providers/pi-native/turn-runner.js +245 -13
- package/src/ai/providers/pi-native.js +159 -40
- package/src/ai/runtime/live-input-events.js +250 -54
- package/src/ai/runtime/router.js +30 -11
- package/src/ai/tool-lifecycle.js +32 -18
- package/src/ai/types.js +26 -5
- package/src/runtime.js +24 -5
- package/types/agent/tool-bloat.d.ts +1 -1
- package/types/agent/tools/agent-tool.d.ts +4 -1
- package/types/agent/tools/bash.d.ts +5 -3
- package/types/agent/tools/codex-subscription-search.d.ts +6 -2
- package/types/agent/tools/exec.d.ts +5 -3
- package/types/agent/tools/monitor.d.ts +5 -2
- package/types/agent/tools/pi-bridge.d.ts +6 -4
- package/types/agent/tools/shared/monitors.d.ts +17 -2
- package/types/agent/tools/shared/process-jobs.d.ts +5 -1
- package/types/agent/tools/shared/process-runner.d.ts +3 -2
- package/types/agent/tools/shared/tool-context.d.ts +2 -0
- package/types/agent/tools/web-access-interstitial.d.ts +23 -0
- package/types/agent/tools/web-browser-render.d.ts +4 -1
- package/types/agent/tools/web-controller.d.ts +4 -2
- package/types/agent/tools/web-document-extractor.d.ts +27 -0
- package/types/agent/tools/web-fetch.d.ts +19 -24
- package/types/agent/tools/web-request.d.ts +20 -0
- package/types/agent/tools/web-search-output.d.ts +31 -0
- package/types/agent/tools/web-search-state.d.ts +21 -0
- package/types/agent/tools/web-search.d.ts +10 -45
- package/types/ai/index.d.ts +1 -0
- package/types/ai/observer.d.ts +6 -0
- package/types/ai/pi-interop.d.ts +61 -0
- package/types/ai/provider-check.d.ts +53 -0
- package/types/ai/providers/pi-native/compaction-driver.d.ts +2 -1
- package/types/ai/providers/pi-native/compaction-summary.d.ts +19 -0
- package/types/ai/providers/pi-native/harness-adapter.d.ts +3 -1
- package/types/ai/providers/pi-native/prompt-cache-diagnostics.d.ts +3 -0
- package/types/ai/providers/pi-native/provider-attribution.d.ts +26 -0
- package/types/ai/providers/pi-native/result-builder.d.ts +11 -1
- package/types/ai/providers/pi-native/session-lifecycle.d.ts +23 -5
- package/types/ai/providers/pi-native/terminal-recovery.d.ts +2 -0
- package/types/ai/providers/pi-native/turn-runner.d.ts +36 -5
- package/types/ai/runtime/live-input-events.d.ts +32 -8
- package/types/ai/tool-lifecycle.d.ts +4 -3
- package/types/ai/types.d.ts +140 -12
|
@@ -1,22 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {{
|
|
3
|
-
* @typedef {{
|
|
2
|
+
* @typedef {{providerEntryId?: string, providerRunId?: string}} RuntimeLiveInputEvidence
|
|
3
|
+
* @typedef {{reason: "delivery_uncertain", providerEntryId?: string, providerRunId?: string}} RuntimeLiveInputUncertainty
|
|
4
|
+
* @typedef {{body: string, id?: string, receivedAt?: string, logicalOwner?: object, accepted?: (evidence?: RuntimeLiveInputEvidence) => unknown, acknowledge?: (evidence?: RuntimeLiveInputEvidence) => unknown, uncertain?: (details: RuntimeLiveInputUncertainty) => unknown, reject?: (reason?: unknown) => unknown}} RuntimeLiveInputMessage
|
|
5
|
+
* @typedef {{message: RuntimeLiveInputMessage, callbackMessage: RuntimeLiveInputMessage, logicalOwner?: object, inputId: string, receivedAt?: string, phase: "available"|"leased"|"native_accepted"|"consumed"|"uncertain", attempt: number, generation: number}} LiveInputOwner
|
|
6
|
+
* @typedef {{type: string, [key: string]: unknown}} LiveInputEvent
|
|
4
7
|
*/
|
|
5
8
|
/**
|
|
6
9
|
* @param {AsyncIterable<RuntimeLiveInputMessage>|undefined} liveInput
|
|
7
|
-
* @param {(event:
|
|
10
|
+
* @param {(event: LiveInputEvent) => void} onEvent
|
|
8
11
|
* @returns {AsyncIterable<RuntimeLiveInputMessage>|undefined}
|
|
9
12
|
*/
|
|
10
|
-
export function instrumentLiveInputAppliedEvents(liveInput: AsyncIterable<RuntimeLiveInputMessage> | undefined,
|
|
13
|
+
export function instrumentLiveInputAppliedEvents(liveInput: AsyncIterable<RuntimeLiveInputMessage> | undefined, onEvent: (event: LiveInputEvent) => void): AsyncIterable<RuntimeLiveInputMessage> | undefined;
|
|
14
|
+
export type RuntimeLiveInputEvidence = {
|
|
15
|
+
providerEntryId?: string;
|
|
16
|
+
providerRunId?: string;
|
|
17
|
+
};
|
|
18
|
+
export type RuntimeLiveInputUncertainty = {
|
|
19
|
+
reason: "delivery_uncertain";
|
|
20
|
+
providerEntryId?: string;
|
|
21
|
+
providerRunId?: string;
|
|
22
|
+
};
|
|
11
23
|
export type RuntimeLiveInputMessage = {
|
|
12
24
|
body: string;
|
|
13
25
|
id?: string;
|
|
14
26
|
receivedAt?: string;
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
logicalOwner?: object;
|
|
28
|
+
accepted?: (evidence?: RuntimeLiveInputEvidence) => unknown;
|
|
29
|
+
acknowledge?: (evidence?: RuntimeLiveInputEvidence) => unknown;
|
|
30
|
+
uncertain?: (details: RuntimeLiveInputUncertainty) => unknown;
|
|
31
|
+
reject?: (reason?: unknown) => unknown;
|
|
17
32
|
};
|
|
18
|
-
export type
|
|
19
|
-
|
|
33
|
+
export type LiveInputOwner = {
|
|
34
|
+
message: RuntimeLiveInputMessage;
|
|
35
|
+
callbackMessage: RuntimeLiveInputMessage;
|
|
36
|
+
logicalOwner?: object;
|
|
20
37
|
inputId: string;
|
|
21
38
|
receivedAt?: string;
|
|
39
|
+
phase: "available" | "leased" | "native_accepted" | "consumed" | "uncertain";
|
|
40
|
+
attempt: number;
|
|
41
|
+
generation: number;
|
|
42
|
+
};
|
|
43
|
+
export type LiveInputEvent = {
|
|
44
|
+
type: string;
|
|
45
|
+
[key: string]: unknown;
|
|
22
46
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {{sink?: (event: any) => Promise<any>, onObserve?: (event: any) => void, onEvent?: (event: any) => void, abortSignal?: AbortSignal}} options
|
|
2
|
+
* @param {{sink?: (event: any) => Promise<any>, onObserve?: (event: any) => void, onLifecycleAdmitted?: (event: any) => void, onEvent?: (event: any) => void, abortSignal?: AbortSignal}} options
|
|
3
3
|
*/
|
|
4
|
-
export function createToolLifecycleEventGate({ sink, onObserve, onEvent, abortSignal }: {
|
|
4
|
+
export function createToolLifecycleEventGate({ sink, onObserve, onLifecycleAdmitted, onEvent, abortSignal }: {
|
|
5
5
|
sink?: (event: any) => Promise<any>;
|
|
6
6
|
onObserve?: (event: any) => void;
|
|
7
|
+
onLifecycleAdmitted?: (event: any) => void;
|
|
7
8
|
onEvent?: (event: any) => void;
|
|
8
9
|
abortSignal?: AbortSignal;
|
|
9
10
|
}): {
|
|
@@ -35,7 +36,7 @@ export function historyMetadata(persisted: any, terminalStateValue: string | und
|
|
|
35
36
|
originalBytes?: number;
|
|
36
37
|
truncated?: any;
|
|
37
38
|
terminalState?: string;
|
|
38
|
-
persistence:
|
|
39
|
+
persistence: any;
|
|
39
40
|
sequence?: number;
|
|
40
41
|
recordId?: any;
|
|
41
42
|
};
|
package/types/ai/types.d.ts
CHANGED
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
* nested native agent. Informational only; `id` remains the attachment key.
|
|
30
30
|
* @property {number} [costUsd] Priced delegation cost, when the runtime can
|
|
31
31
|
* attribute it to this subagent.
|
|
32
|
+
* @property {*} [attribution] Bounded provider-route attribution for the
|
|
33
|
+
* completed child run. Consumers must treat it as operator telemetry.
|
|
32
34
|
*/
|
|
33
35
|
/**
|
|
34
36
|
* @typedef {"agent_started"|"started"|"completed"|"message"|"agent_completed"} RuntimeSubagentActivityPhase
|
|
@@ -89,7 +91,7 @@
|
|
|
89
91
|
* @typedef {Readonly<{
|
|
90
92
|
* recordId?: string,
|
|
91
93
|
* sequence?: number,
|
|
92
|
-
* persistence: "persisted"|"failed",
|
|
94
|
+
* persistence: "persisted"|"deferred"|"failed",
|
|
93
95
|
* truncated?: boolean,
|
|
94
96
|
* originalBytes?: number,
|
|
95
97
|
* retainedBytes?: number,
|
|
@@ -107,6 +109,7 @@
|
|
|
107
109
|
* @typedef {Object} RuntimeObserver
|
|
108
110
|
* Per-call or host-level observer merged by createObserverHub (ai/observer.js).
|
|
109
111
|
* Loose on purpose: observer.js is not a kernel seam file.
|
|
112
|
+
* @property {(event: RuntimeToolLifecycleEvent) => void} [recordToolLifecycle] Synchronous admission before queued lifecycle persistence.
|
|
110
113
|
* @property {(event: RuntimeEvent) => (void|Promise<void>)} [onEvent]
|
|
111
114
|
* @property {() => (void|Promise<void>)} [flush]
|
|
112
115
|
*/
|
|
@@ -163,11 +166,14 @@
|
|
|
163
166
|
* @property {RuntimeModelRef} model Resolved model reference; see parseRuntimeModelReference.
|
|
164
167
|
* @property {string} [sessionId] Host conversation/session key for resumable bridges.
|
|
165
168
|
* @property {string} [providerSessionId] Provider-owned resume id for resumable bridges.
|
|
169
|
+
* @property {string} [providerAttributionSessionId] Host-owned provider attribution continuity key; does not authorize transcript resume.
|
|
170
|
+
* @property {{runId: string, revision: number}} [sessionRecovery] Host-owned durable recovery opt-in.
|
|
166
171
|
* @property {boolean} [sessionKeepAlive] Keep resumable provider state alive after the turn.
|
|
167
172
|
* @property {number} [sessionIdleTimeoutMs] Idle TTL for resumable provider state.
|
|
168
|
-
* @property {AsyncIterable<{body: string, id?: string, receivedAt?: string, acknowledge?: () =>
|
|
173
|
+
* @property {AsyncIterable<{body: string, id?: string, receivedAt?: string, logicalOwner?: object, accepted?: (evidence?: {providerEntryId?: string, providerRunId?: string}) => unknown, acknowledge?: (evidence?: {providerEntryId?: string, providerRunId?: string}) => unknown, uncertain?: (details: {reason: "delivery_uncertain", providerEntryId?: string, providerRunId?: string}) => unknown, reject?: (error?: unknown) => unknown}>} [liveInput] Stream of in-flight user messages for steering an active run. Native acceptance, exact transcript consumption, and uncertain delivery are distinct synchronous callbacks; thenables are never awaited as settlement confirmation. An optional opaque logicalOwner object proves that a later same-id value is a fresh callback lease for the first logical owner, not an independent duplicate.
|
|
169
174
|
* @property {ReadonlyArray<*>} [observers] Per-call observers (see RuntimeObserver) merged with host-level (createRuntime) observers.
|
|
170
175
|
* @property {(event: RuntimeEvent) => void} [onEvent]
|
|
176
|
+
* @property {boolean} [promptCacheDiagnostics] Emit metadata-only prompt-cache request fingerprints.
|
|
171
177
|
* @property {RuntimeToolLifecycleSink} [toolLifecycleSink] Awaited host-owned incremental lifecycle persistence boundary.
|
|
172
178
|
* @property {ReadonlyArray<Object>} [messages]
|
|
173
179
|
* @property {string} [effort]
|
|
@@ -179,23 +185,31 @@
|
|
|
179
185
|
* @property {ReadonlyArray<string>} [disallowedTools]
|
|
180
186
|
* @property {string} [permissionMode]
|
|
181
187
|
* @property {number} [maxTurns]
|
|
188
|
+
* @property {number} [providerCheckMaxTokens] Internal provider-check output cap; ordinary callers must omit it.
|
|
189
|
+
* @property {{env(name: string): Promise<string|undefined>, fileExists(path: string): Promise<boolean>}} [providerCheckAuthContext] Internal provider-check effective auth context; ordinary callers must omit it.
|
|
182
190
|
* @property {Object} [outputSchema]
|
|
183
191
|
* @property {string} [runArtifactDir]
|
|
184
192
|
* @property {AbortSignal} [abortSignal]
|
|
193
|
+
* @property {(artifact: {filename: string, buffer: Buffer, toolName: string, toolUseId: (string|null)}) => (string|null)} [persistArtifact] Host-owned synchronous artifact writer bound to this run.
|
|
185
194
|
* @property {{schema: 1, values: Readonly<Record<string, string>>, pathPrepend?: readonly string[]}} [toolEnvironment] Host-only environment for Bash, Exec, and nested subagents in this run.
|
|
186
195
|
* @property {import('../agent/sandbox-seam.js').SandboxPolicy} [sandboxPolicy] Per-run sandbox policy; merged monotonically with the host policy (see resolveSandboxPolicy, agent/tools/shared/tool-context.js).
|
|
187
196
|
* @property {import('../agent/sandbox-seam.js').RuntimeSandboxEngine} [sandboxEngine] Per-run concrete sandbox engine handed to the active sandbox implementation.
|
|
188
197
|
* @property {import('../agent/sandbox-seam.js').RuntimeSandbox} [sandbox] Per-run sandbox IMPLEMENTATION override; when set it enforces this run's tools instead of the host/ToolContext impl (precedence run > host > passthrough). Policy DATA still merges monotonically (I13); this overrides only the enforcing code.
|
|
189
198
|
* @property {RuntimeToolLimits} [toolLimits] Typed per-run tool-output limits (supported replacement for the deprecated `settings` tool keys).
|
|
199
|
+
* @property {readonly string[]} [mcpCallNoTotalTimeoutTools] Exact `server:tool`
|
|
200
|
+
* names whose host-owned lifecycle has no total deadline. Inactivity and abort still apply.
|
|
190
201
|
* @property {RuntimeCompactionPolicy} [compaction] Typed per-run compaction policy (supported replacement for the deprecated `settings` compaction keys).
|
|
191
202
|
* @property {RuntimePromptOverrides} [prompts] Per-run prompt-fragment overrides (run wins over the host default).
|
|
192
|
-
* @property {
|
|
203
|
+
* @property {any} [webRequestCoordinator] Host-owned shared web admission and quota state.
|
|
204
|
+
* @property {{backend?: "auto"|"searxng"|"ollama"|"codex"|"keyless", maxRequestsPerRun?: number, endpoint?: string, searxng?: {endpoint?: string}, ollama?: {baseUrl?: string, apiKey?: string, apiKeyEnv?: string, trustPublicUrl?: boolean}, codex?: {model?: string}}} [webSearchConfig] Run-scoped WebSearch backend configuration.
|
|
205
|
+
* @property {any} [webSearchState] Private request budget and provider deferral state for one logical run.
|
|
193
206
|
* @property {{render?: "never"|"auto", browserCommand?: string}} [webFetchConfig] Run-scoped WebFetch extraction/render configuration.
|
|
194
207
|
* @property {"sequential"|"safe-parallel"} [piToolExecutionMode] Pi built-in tool scheduling mode. Safe parallelism is the default.
|
|
195
208
|
* @property {"one-at-a-time"|"all"} [piToolParallelismMode] DEPRECATED. Compatibility alias mapped to piToolExecutionMode.
|
|
196
209
|
* @property {Object} [settings] DEPRECATED. Legacy flat settings bag; consumed only as a per-group FALLBACK when the corresponding typed object (`toolLimits` / `compaction`) is absent. Consuming any key emits one `deprecated_settings_option` runtime_warning per run. Migrate via resolveRuntimePolicies (@mono-agent/runtime-adapter).
|
|
197
210
|
* @property {RuntimeSubagentsOptions} [subagents] In-process `Agent` built-in: profiles, caps, and the nested-run callback.
|
|
198
211
|
* @property {import('../agent/tools/shared/process-jobs.js').ProcessJobsController} [processJobs] Pi-native-only structural process-job controller. When absent, Exec/Bash schemas and foreground behavior are unchanged.
|
|
212
|
+
* @property {{chainDepth: number, maxChainDepth: number, remainingStarts: number, unavailableReason?: string}} [processJobsAvailability] Host-owned request lineage diagnostics, including when the controller is unavailable.
|
|
199
213
|
* @property {import('../agent/tools/shared/monitors.js').MonitorsController} [monitors] Pi-native-only structural monitor controller. When absent, the Monitor and MonitorStop tools are not registered at all.
|
|
200
214
|
* @property {Object} [diagnosticsSeed] Set by createRouterRuntime (ai/runtime/router.js) with a `resume_snapshot` when
|
|
201
215
|
* failing over mid-chain; a host-level coordinator may relay it forward (see agent/transcript.js), not read by any
|
|
@@ -206,7 +220,7 @@
|
|
|
206
220
|
*/
|
|
207
221
|
/**
|
|
208
222
|
* @typedef {RuntimeRunOptions
|
|
209
|
-
* & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "
|
|
223
|
+
* & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools">
|
|
210
224
|
* & {runtimeBrand: import('../runtime-brand.js').RuntimeBrand, toolContext?: import('../agent/tools/shared/tool-context.js').ToolContext, observerHub: {emit: (event: RuntimeEvent) => void, flush: () => Promise<void>}}
|
|
211
225
|
* } RuntimeRequest
|
|
212
226
|
* The request shape a bridge's `execute(systemPrompt, req)` receives as its
|
|
@@ -273,11 +287,13 @@
|
|
|
273
287
|
* @property {number} [numTurns]
|
|
274
288
|
* @property {string} [model]
|
|
275
289
|
* @property {string} [effort]
|
|
290
|
+
* @property {string} [effectiveEffort] Provider-effective reasoning/thinking level when reported.
|
|
276
291
|
* @property {RuntimeSdkId} [sdk]
|
|
277
292
|
* @property {boolean} [cancelled]
|
|
278
293
|
* @property {string|null} [error]
|
|
279
294
|
* @property {Object|null} [errorDetails]
|
|
280
295
|
* @property {string|null} [failureKind]
|
|
296
|
+
* @property {{runId: string, revision: number, providerSessionId: string, modelKey: string, tipId: string}} [providerSessionRecovery]
|
|
281
297
|
* @property {string|null} [providerSessionId]
|
|
282
298
|
* @property {string|null} [stderrTail] Bounded stderr tail from a CLI-backed bridge; see createStderrTail (ai/failure.js).
|
|
283
299
|
* @property {Array<Object>} [runtimeWarnings]
|
|
@@ -367,6 +383,8 @@
|
|
|
367
383
|
* host-integration callbacks (bound once, applied to every run via hostDefaults).
|
|
368
384
|
* @property {string} [workspace]
|
|
369
385
|
* @property {string} [repoRoot]
|
|
386
|
+
* @property {ReadonlyArray<string>} [additionalReadRoots]
|
|
387
|
+
* @property {ReadonlyArray<string>} [additionalWriteRoots]
|
|
370
388
|
* @property {string} [ripgrepPath]
|
|
371
389
|
* @property {string} [qaOutputDir]
|
|
372
390
|
* @property {import('../agent/sandbox-seam.js').SandboxPolicy} [sandboxPolicy]
|
|
@@ -391,6 +409,8 @@
|
|
|
391
409
|
* (createRuntime's TOOL_RUNTIME_KEYS pick).
|
|
392
410
|
* @property {string} [workspace]
|
|
393
411
|
* @property {string} [repoRoot]
|
|
412
|
+
* @property {ReadonlyArray<string>} [additionalReadRoots]
|
|
413
|
+
* @property {ReadonlyArray<string>} [additionalWriteRoots]
|
|
394
414
|
* @property {string} [ripgrepPath]
|
|
395
415
|
* @property {string} [qaOutputDir]
|
|
396
416
|
* @property {import('../agent/sandbox-seam.js').SandboxPolicy} [sandboxPolicy]
|
|
@@ -402,9 +422,10 @@
|
|
|
402
422
|
* The object `createRuntime`/`createRouterRuntime` return.
|
|
403
423
|
* @property {(systemPrompt: string, options: RuntimeRunOptions) => Promise<RuntimeResult>} run
|
|
404
424
|
* @property {(next?: AgentRuntimeToolOptions) => void} configureTools
|
|
425
|
+
* @property {(receipt: NonNullable<RuntimeResult["providerSessionRecovery"]>, context: {appliedInputIds: readonly string[]}) => Promise<boolean>} recoverSession
|
|
405
426
|
* @property {(providerSessionId: string) => Promise<boolean>} syncSession
|
|
406
427
|
* @property {(providerSessionId: string) => Promise<void>} refreshSession Guarantees the id has no reusable process-local handle; rejects on failure.
|
|
407
|
-
* @property {(providerSessionId: string, sessionsRoot: string) => Promise<void>} retireDurableSession
|
|
428
|
+
* @property {(providerSessionId: string, sessionsRoot: string) => Promise<void>} retireDurableSession Deletes every currently materialized durable transcript with the exact id; callers retry after an active retired run settles to reclaim any late same-name append. Absence is success.
|
|
408
429
|
* @property {(providerSessionId: string) => Promise<boolean>} disposeSession
|
|
409
430
|
* @property {(providerSessionId: string) => Promise<boolean>} invalidateSession
|
|
410
431
|
* @property {() => Promise<void>} disposeAllSessions
|
|
@@ -471,6 +492,11 @@ export type RuntimeSubagentIdentity = {
|
|
|
471
492
|
* attribute it to this subagent.
|
|
472
493
|
*/
|
|
473
494
|
costUsd?: number;
|
|
495
|
+
/**
|
|
496
|
+
* Bounded provider-route attribution for the
|
|
497
|
+
* completed child run. Consumers must treat it as operator telemetry.
|
|
498
|
+
*/
|
|
499
|
+
attribution?: any;
|
|
474
500
|
};
|
|
475
501
|
/**
|
|
476
502
|
* `agent_started`/`agent_completed` bracket the delegation; `started`/`completed`
|
|
@@ -549,7 +575,7 @@ export type RuntimeToolLifecycleEvent = RuntimeToolLifecycleInvocationEvent | Ru
|
|
|
549
575
|
export type RuntimeToolLifecyclePersistence = Readonly<{
|
|
550
576
|
recordId?: string;
|
|
551
577
|
sequence?: number;
|
|
552
|
-
persistence: "persisted" | "failed";
|
|
578
|
+
persistence: "persisted" | "deferred" | "failed";
|
|
553
579
|
truncated?: boolean;
|
|
554
580
|
originalBytes?: number;
|
|
555
581
|
retainedBytes?: number;
|
|
@@ -565,6 +591,10 @@ export type RuntimeToolLifecycleSink = (event: RuntimeToolLifecycleEvent) => Pro
|
|
|
565
591
|
* Loose on purpose: observer.js is not a kernel seam file.
|
|
566
592
|
*/
|
|
567
593
|
export type RuntimeObserver = {
|
|
594
|
+
/**
|
|
595
|
+
* Synchronous admission before queued lifecycle persistence.
|
|
596
|
+
*/
|
|
597
|
+
recordToolLifecycle?: (event: RuntimeToolLifecycleEvent) => void;
|
|
568
598
|
onEvent?: (event: RuntimeEvent) => (void | Promise<void>);
|
|
569
599
|
flush?: () => (void | Promise<void>);
|
|
570
600
|
};
|
|
@@ -688,6 +718,17 @@ export type RuntimeRunOptions = {
|
|
|
688
718
|
* Provider-owned resume id for resumable bridges.
|
|
689
719
|
*/
|
|
690
720
|
providerSessionId?: string;
|
|
721
|
+
/**
|
|
722
|
+
* Host-owned provider attribution continuity key; does not authorize transcript resume.
|
|
723
|
+
*/
|
|
724
|
+
providerAttributionSessionId?: string;
|
|
725
|
+
/**
|
|
726
|
+
* Host-owned durable recovery opt-in.
|
|
727
|
+
*/
|
|
728
|
+
sessionRecovery?: {
|
|
729
|
+
runId: string;
|
|
730
|
+
revision: number;
|
|
731
|
+
};
|
|
691
732
|
/**
|
|
692
733
|
* Keep resumable provider state alive after the turn.
|
|
693
734
|
*/
|
|
@@ -697,20 +738,37 @@ export type RuntimeRunOptions = {
|
|
|
697
738
|
*/
|
|
698
739
|
sessionIdleTimeoutMs?: number;
|
|
699
740
|
/**
|
|
700
|
-
* Stream of in-flight user messages for steering an active run.
|
|
741
|
+
* Stream of in-flight user messages for steering an active run. Native acceptance, exact transcript consumption, and uncertain delivery are distinct synchronous callbacks; thenables are never awaited as settlement confirmation. An optional opaque logicalOwner object proves that a later same-id value is a fresh callback lease for the first logical owner, not an independent duplicate.
|
|
701
742
|
*/
|
|
702
743
|
liveInput?: AsyncIterable<{
|
|
703
744
|
body: string;
|
|
704
745
|
id?: string;
|
|
705
746
|
receivedAt?: string;
|
|
706
|
-
|
|
707
|
-
|
|
747
|
+
logicalOwner?: object;
|
|
748
|
+
accepted?: (evidence?: {
|
|
749
|
+
providerEntryId?: string;
|
|
750
|
+
providerRunId?: string;
|
|
751
|
+
}) => unknown;
|
|
752
|
+
acknowledge?: (evidence?: {
|
|
753
|
+
providerEntryId?: string;
|
|
754
|
+
providerRunId?: string;
|
|
755
|
+
}) => unknown;
|
|
756
|
+
uncertain?: (details: {
|
|
757
|
+
reason: "delivery_uncertain";
|
|
758
|
+
providerEntryId?: string;
|
|
759
|
+
providerRunId?: string;
|
|
760
|
+
}) => unknown;
|
|
761
|
+
reject?: (error?: unknown) => unknown;
|
|
708
762
|
}>;
|
|
709
763
|
/**
|
|
710
764
|
* Per-call observers (see RuntimeObserver) merged with host-level (createRuntime) observers.
|
|
711
765
|
*/
|
|
712
766
|
observers?: ReadonlyArray<any>;
|
|
713
767
|
onEvent?: (event: RuntimeEvent) => void;
|
|
768
|
+
/**
|
|
769
|
+
* Emit metadata-only prompt-cache request fingerprints.
|
|
770
|
+
*/
|
|
771
|
+
promptCacheDiagnostics?: boolean;
|
|
714
772
|
/**
|
|
715
773
|
* Awaited host-owned incremental lifecycle persistence boundary.
|
|
716
774
|
*/
|
|
@@ -736,9 +794,29 @@ export type RuntimeRunOptions = {
|
|
|
736
794
|
disallowedTools?: ReadonlyArray<string>;
|
|
737
795
|
permissionMode?: string;
|
|
738
796
|
maxTurns?: number;
|
|
797
|
+
/**
|
|
798
|
+
* Internal provider-check output cap; ordinary callers must omit it.
|
|
799
|
+
*/
|
|
800
|
+
providerCheckMaxTokens?: number;
|
|
801
|
+
/**
|
|
802
|
+
* Internal provider-check effective auth context; ordinary callers must omit it.
|
|
803
|
+
*/
|
|
804
|
+
providerCheckAuthContext?: {
|
|
805
|
+
env(name: string): Promise<string | undefined>;
|
|
806
|
+
fileExists(path: string): Promise<boolean>;
|
|
807
|
+
};
|
|
739
808
|
outputSchema?: any;
|
|
740
809
|
runArtifactDir?: string;
|
|
741
810
|
abortSignal?: AbortSignal;
|
|
811
|
+
/**
|
|
812
|
+
* Host-owned synchronous artifact writer bound to this run.
|
|
813
|
+
*/
|
|
814
|
+
persistArtifact?: (artifact: {
|
|
815
|
+
filename: string;
|
|
816
|
+
buffer: Buffer;
|
|
817
|
+
toolName: string;
|
|
818
|
+
toolUseId: (string | null);
|
|
819
|
+
}) => (string | null);
|
|
742
820
|
/**
|
|
743
821
|
* Host-only environment for Bash, Exec, and nested subagents in this run.
|
|
744
822
|
*/
|
|
@@ -763,6 +841,11 @@ export type RuntimeRunOptions = {
|
|
|
763
841
|
* Typed per-run tool-output limits (supported replacement for the deprecated `settings` tool keys).
|
|
764
842
|
*/
|
|
765
843
|
toolLimits?: RuntimeToolLimits;
|
|
844
|
+
/**
|
|
845
|
+
* Exact `server:tool`
|
|
846
|
+
* names whose host-owned lifecycle has no total deadline. Inactivity and abort still apply.
|
|
847
|
+
*/
|
|
848
|
+
mcpCallNoTotalTimeoutTools?: readonly string[];
|
|
766
849
|
/**
|
|
767
850
|
* Typed per-run compaction policy (supported replacement for the deprecated `settings` compaction keys).
|
|
768
851
|
*/
|
|
@@ -771,16 +854,34 @@ export type RuntimeRunOptions = {
|
|
|
771
854
|
* Per-run prompt-fragment overrides (run wins over the host default).
|
|
772
855
|
*/
|
|
773
856
|
prompts?: RuntimePromptOverrides;
|
|
857
|
+
/**
|
|
858
|
+
* Host-owned shared web admission and quota state.
|
|
859
|
+
*/
|
|
860
|
+
webRequestCoordinator?: any;
|
|
774
861
|
/**
|
|
775
862
|
* Run-scoped WebSearch backend configuration.
|
|
776
863
|
*/
|
|
777
864
|
webSearchConfig?: {
|
|
778
|
-
backend?: "auto" | "searxng" | "codex" | "keyless";
|
|
865
|
+
backend?: "auto" | "searxng" | "ollama" | "codex" | "keyless";
|
|
866
|
+
maxRequestsPerRun?: number;
|
|
779
867
|
endpoint?: string;
|
|
868
|
+
searxng?: {
|
|
869
|
+
endpoint?: string;
|
|
870
|
+
};
|
|
871
|
+
ollama?: {
|
|
872
|
+
baseUrl?: string;
|
|
873
|
+
apiKey?: string;
|
|
874
|
+
apiKeyEnv?: string;
|
|
875
|
+
trustPublicUrl?: boolean;
|
|
876
|
+
};
|
|
780
877
|
codex?: {
|
|
781
878
|
model?: string;
|
|
782
879
|
};
|
|
783
880
|
};
|
|
881
|
+
/**
|
|
882
|
+
* Private request budget and provider deferral state for one logical run.
|
|
883
|
+
*/
|
|
884
|
+
webSearchState?: any;
|
|
784
885
|
/**
|
|
785
886
|
* Run-scoped WebFetch extraction/render configuration.
|
|
786
887
|
*/
|
|
@@ -808,6 +909,15 @@ export type RuntimeRunOptions = {
|
|
|
808
909
|
* Pi-native-only structural process-job controller. When absent, Exec/Bash schemas and foreground behavior are unchanged.
|
|
809
910
|
*/
|
|
810
911
|
processJobs?: import("../agent/tools/shared/process-jobs.js").ProcessJobsController;
|
|
912
|
+
/**
|
|
913
|
+
* Host-owned request lineage diagnostics, including when the controller is unavailable.
|
|
914
|
+
*/
|
|
915
|
+
processJobsAvailability?: {
|
|
916
|
+
chainDepth: number;
|
|
917
|
+
maxChainDepth: number;
|
|
918
|
+
remainingStarts: number;
|
|
919
|
+
unavailableReason?: string;
|
|
920
|
+
};
|
|
811
921
|
/**
|
|
812
922
|
* Pi-native-only structural monitor controller. When absent, the Monitor and MonitorStop tools are not registered at all.
|
|
813
923
|
*/
|
|
@@ -834,7 +944,7 @@ export type RuntimeRunOptions = {
|
|
|
834
944
|
* createRuntime), and the per-run observerHub (onEvent is overridden to the
|
|
835
945
|
* hub's emit). `systemPrompt` is passed positionally, not folded into this object.
|
|
836
946
|
*/
|
|
837
|
-
export type RuntimeRequest = RuntimeRunOptions & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "
|
|
947
|
+
export type RuntimeRequest = RuntimeRunOptions & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools"> & {
|
|
838
948
|
runtimeBrand: import("../runtime-brand.js").RuntimeBrand;
|
|
839
949
|
toolContext?: import("../agent/tools/shared/tool-context.js").ToolContext;
|
|
840
950
|
observerHub: {
|
|
@@ -943,11 +1053,22 @@ export type RuntimeResult = {
|
|
|
943
1053
|
numTurns?: number;
|
|
944
1054
|
model?: string;
|
|
945
1055
|
effort?: string;
|
|
1056
|
+
/**
|
|
1057
|
+
* Provider-effective reasoning/thinking level when reported.
|
|
1058
|
+
*/
|
|
1059
|
+
effectiveEffort?: string;
|
|
946
1060
|
sdk?: RuntimeSdkId;
|
|
947
1061
|
cancelled?: boolean;
|
|
948
1062
|
error?: string | null;
|
|
949
1063
|
errorDetails?: any | null;
|
|
950
1064
|
failureKind?: string | null;
|
|
1065
|
+
providerSessionRecovery?: {
|
|
1066
|
+
runId: string;
|
|
1067
|
+
revision: number;
|
|
1068
|
+
providerSessionId: string;
|
|
1069
|
+
modelKey: string;
|
|
1070
|
+
tipId: string;
|
|
1071
|
+
};
|
|
951
1072
|
providerSessionId?: string | null;
|
|
952
1073
|
/**
|
|
953
1074
|
* Bounded stderr tail from a CLI-backed bridge; see createStderrTail (ai/failure.js).
|
|
@@ -1066,6 +1187,8 @@ export type CompactionRecordedPayload = {
|
|
|
1066
1187
|
export type AgentRuntimeHostOptions = {
|
|
1067
1188
|
workspace?: string;
|
|
1068
1189
|
repoRoot?: string;
|
|
1190
|
+
additionalReadRoots?: ReadonlyArray<string>;
|
|
1191
|
+
additionalWriteRoots?: ReadonlyArray<string>;
|
|
1069
1192
|
ripgrepPath?: string;
|
|
1070
1193
|
qaOutputDir?: string;
|
|
1071
1194
|
sandboxPolicy?: import("../agent/sandbox-seam.js").SandboxPolicy;
|
|
@@ -1119,6 +1242,8 @@ export type AgentRuntimeHostOptions = {
|
|
|
1119
1242
|
export type AgentRuntimeToolOptions = {
|
|
1120
1243
|
workspace?: string;
|
|
1121
1244
|
repoRoot?: string;
|
|
1245
|
+
additionalReadRoots?: ReadonlyArray<string>;
|
|
1246
|
+
additionalWriteRoots?: ReadonlyArray<string>;
|
|
1122
1247
|
ripgrepPath?: string;
|
|
1123
1248
|
qaOutputDir?: string;
|
|
1124
1249
|
sandboxPolicy?: import("../agent/sandbox-seam.js").SandboxPolicy;
|
|
@@ -1131,13 +1256,16 @@ export type AgentRuntimeToolOptions = {
|
|
|
1131
1256
|
export type AgentRuntimeInstance = {
|
|
1132
1257
|
run: (systemPrompt: string, options: RuntimeRunOptions) => Promise<RuntimeResult>;
|
|
1133
1258
|
configureTools: (next?: AgentRuntimeToolOptions) => void;
|
|
1259
|
+
recoverSession: (receipt: NonNullable<RuntimeResult["providerSessionRecovery"]>, context: {
|
|
1260
|
+
appliedInputIds: readonly string[];
|
|
1261
|
+
}) => Promise<boolean>;
|
|
1134
1262
|
syncSession: (providerSessionId: string) => Promise<boolean>;
|
|
1135
1263
|
/**
|
|
1136
1264
|
* Guarantees the id has no reusable process-local handle; rejects on failure.
|
|
1137
1265
|
*/
|
|
1138
1266
|
refreshSession: (providerSessionId: string) => Promise<void>;
|
|
1139
1267
|
/**
|
|
1140
|
-
*
|
|
1268
|
+
* Deletes every currently materialized durable transcript with the exact id; callers retry after an active retired run settles to reclaim any late same-name append. Absence is success.
|
|
1141
1269
|
*/
|
|
1142
1270
|
retireDurableSession: (providerSessionId: string, sessionsRoot: string) => Promise<void>;
|
|
1143
1271
|
disposeSession: (providerSessionId: string) => Promise<boolean>;
|