@mono-agent/agent-runtime 0.20.11 → 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 +288 -26
- package/README.md +352 -477
- package/package.json +13 -44
- package/src/agent/tool-bloat.js +145 -9
- package/src/agent/tools/agent-tool.js +108 -9
- package/src/agent/tools/bash.js +11 -26
- package/src/agent/tools/codex-subscription-search.js +123 -29
- package/src/agent/tools/exec.js +10 -2
- package/src/agent/tools/index.js +7 -0
- package/src/agent/tools/monitor.js +149 -0
- package/src/agent/tools/pi-bridge.js +123 -19
- package/src/agent/tools/shared/bash-environment.js +31 -0
- package/src/agent/tools/shared/monitors.js +293 -0
- 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 +26 -6
- 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/cost.js +13 -68
- package/src/ai/failure.js +3 -3
- package/src/ai/index.js +5 -17
- package/src/ai/observer.js +8 -0
- package/src/ai/pi-interop.js +221 -1
- package/src/ai/pi-oauth-compat.js +1 -1
- package/src/ai/provider-check.js +131 -0
- package/src/ai/providers/codex/app-server-client.js +592 -0
- package/src/ai/providers/pi-models.js +18 -10
- package/src/ai/providers/pi-native/compaction-driver.js +94 -42
- package/src/ai/providers/pi-native/compaction-summary.js +140 -0
- package/src/ai/providers/pi-native/harness-adapter.js +376 -0
- 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 +38 -14
- package/src/ai/providers/pi-native/session-lifecycle.js +253 -55
- package/src/ai/providers/pi-native/stream-subscriber.js +52 -6
- package/src/ai/providers/pi-native/terminal-recovery.js +40 -0
- package/src/ai/providers/pi-native/turn-runner.js +279 -28
- package/src/ai/providers/pi-native.js +206 -61
- package/src/ai/runtime/capabilities.js +11 -56
- package/src/ai/runtime/live-input-events.js +250 -54
- package/src/ai/runtime/model-refs.js +118 -153
- package/src/ai/runtime/registry.js +22 -56
- package/src/ai/runtime/router.js +76 -417
- package/src/ai/runtime/session-liveness.js +3 -4
- package/src/ai/runtime/sessions.js +4 -5
- package/src/ai/runtime/tool-policy.js +0 -2
- package/src/ai/tool-lifecycle.js +32 -18
- package/src/ai/types.js +37 -112
- package/src/index.js +0 -6
- package/src/runtime.js +29 -16
- package/types/agent/tool-bloat.d.ts +1 -1
- package/types/agent/tools/agent-tool.d.ts +4 -2
- package/types/agent/tools/bash.d.ts +5 -3
- package/types/agent/tools/codex-subscription-search.d.ts +7 -3
- package/types/agent/tools/exec.d.ts +5 -3
- package/types/agent/tools/index.d.ts +1 -0
- package/types/agent/tools/monitor.d.ts +47 -0
- package/types/agent/tools/pi-bridge.d.ts +7 -4
- package/types/agent/tools/shared/bash-environment.d.ts +4 -0
- package/types/agent/tools/shared/monitors.d.ts +98 -0
- package/types/agent/tools/shared/process-jobs.d.ts +5 -1
- package/types/agent/tools/shared/process-runner.d.ts +14 -4
- 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/cost.d.ts +1 -2
- package/types/ai/index.d.ts +2 -4
- package/types/ai/observer.d.ts +6 -0
- package/types/ai/pi-interop.d.ts +81 -0
- package/types/ai/provider-check.d.ts +53 -0
- package/types/ai/providers/codex/app-server-client.d.ts +37 -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 +58 -0
- 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 +14 -4
- package/types/ai/providers/pi-native/session-lifecycle.d.ts +25 -6
- package/types/ai/providers/pi-native/stream-subscriber.d.ts +2 -2
- package/types/ai/providers/pi-native/terminal-recovery.d.ts +2 -0
- package/types/ai/providers/pi-native/turn-runner.d.ts +68 -10
- package/types/ai/providers/pi-native.d.ts +21 -4
- package/types/ai/runtime/capabilities.d.ts +21 -70
- package/types/ai/runtime/live-input-events.d.ts +32 -8
- package/types/ai/runtime/model-refs.d.ts +0 -24
- package/types/ai/runtime/router.d.ts +3 -10
- package/types/ai/runtime/tool-policy.d.ts +0 -2
- package/types/ai/tool-lifecycle.d.ts +4 -3
- package/types/ai/types.d.ts +162 -256
- package/types/index.d.ts +0 -1
- package/src/ai/providers/acp-client.js +0 -1149
- package/src/ai/providers/acp-privacy.js +0 -124
- package/src/ai/providers/acp-public.js +0 -21
- package/src/ai/providers/acp-session-tokens.js +0 -282
- package/src/ai/providers/acp-transport.js +0 -356
- package/src/ai/providers/acp.js +0 -543
- package/src/ai/providers/claude-cli.js +0 -883
- package/src/ai/providers/claude-sandbox.js +0 -71
- package/src/ai/providers/claude-sdk-discovery-worker.js +0 -53
- package/src/ai/providers/claude-sdk-discovery.js +0 -352
- package/src/ai/providers/claude-sdk.js +0 -1127
- package/src/ai/providers/claude-subagent-activity.js +0 -719
- package/src/ai/providers/claude-subagents.js +0 -88
- package/src/ai/providers/codex-app.js +0 -2946
- package/src/ai/providers/opencode-app.js +0 -1109
- package/src/ai/providers/opencode-discovery.js +0 -39
- package/src/ai/providers/opencode-server.js +0 -508
- package/src/ai/runtime/context-windows.js +0 -46
- package/src/ai/runtime/fast-mode.js +0 -8
- package/src/ai/streaming/codex-events.js +0 -146
- package/src/ai/streaming/opencode-events.js +0 -59
- package/types/ai/providers/acp-client.d.ts +0 -227
- package/types/ai/providers/acp-privacy.d.ts +0 -25
- package/types/ai/providers/acp-public.d.ts +0 -7
- package/types/ai/providers/acp-session-tokens.d.ts +0 -41
- package/types/ai/providers/acp-transport.d.ts +0 -45
- package/types/ai/providers/acp.d.ts +0 -93
- package/types/ai/providers/claude-cli.d.ts +0 -305
- package/types/ai/providers/claude-sandbox.d.ts +0 -79
- package/types/ai/providers/claude-sdk-discovery-worker.d.ts +0 -1
- package/types/ai/providers/claude-sdk-discovery.d.ts +0 -97
- package/types/ai/providers/claude-sdk.d.ts +0 -138
- package/types/ai/providers/claude-subagent-activity.d.ts +0 -53
- package/types/ai/providers/claude-subagents.d.ts +0 -18
- package/types/ai/providers/codex-app.d.ts +0 -151
- package/types/ai/providers/opencode-app.d.ts +0 -96
- package/types/ai/providers/opencode-discovery.d.ts +0 -4
- package/types/ai/providers/opencode-server.d.ts +0 -20
- package/types/ai/runtime/context-windows.d.ts +0 -9
- package/types/ai/runtime/fast-mode.d.ts +0 -2
- package/types/ai/streaming/codex-events.d.ts +0 -40
- package/types/ai/streaming/opencode-events.d.ts +0 -42
|
@@ -45,7 +45,7 @@ export function thinkingLevelForEffort(effort: string, capabilities: any): strin
|
|
|
45
45
|
export function toolResultErrorOverride(details: any): {
|
|
46
46
|
isError: true;
|
|
47
47
|
} | undefined;
|
|
48
|
-
export function buildTurnHarness(runState: any, { session, piModels, model, thinkingLevel, systemPrompt, outputSchema, tools, transport, maxRetries, maxRetryDelayMs, steeringMode,
|
|
48
|
+
export function buildTurnHarness(runState: any, { session, piModels, model, thinkingLevel, systemPrompt, outputSchema, tools, transport, maxRetries, maxRetryDelayMs, steeringMode, options, }: {
|
|
49
49
|
session: any;
|
|
50
50
|
piModels: any;
|
|
51
51
|
model: any;
|
|
@@ -57,27 +57,80 @@ export function buildTurnHarness(runState: any, { session, piModels, model, thin
|
|
|
57
57
|
maxRetries: any;
|
|
58
58
|
maxRetryDelayMs: any;
|
|
59
59
|
steeringMode: any;
|
|
60
|
-
|
|
60
|
+
options: any;
|
|
61
|
+
}): Promise<{
|
|
62
|
+
getPromptCacheRequest: () => any;
|
|
63
|
+
models: any;
|
|
64
|
+
getModel: () => any;
|
|
65
|
+
getThinkingLevel: () => any;
|
|
66
|
+
getActiveTools: () => any;
|
|
67
|
+
setActiveTools(names: any): Promise<void>;
|
|
68
|
+
setCompactionSettings(settings: any): Promise<void>;
|
|
69
|
+
appendMessage(message: any): Promise<any>;
|
|
70
|
+
prompt(text: any, promptOptions: any): Promise<any>;
|
|
71
|
+
steer(message: any): Promise<string>;
|
|
72
|
+
cancelQueued(entryId: any): Promise<any>;
|
|
73
|
+
abort(): Promise<void>;
|
|
74
|
+
waitForIdle(): any;
|
|
75
|
+
compact(): Promise<any>;
|
|
76
|
+
on(type: any, handler: any): any;
|
|
77
|
+
subscribe(listener: any): () => void;
|
|
78
|
+
abortOpenOperations(): Promise<void>;
|
|
79
|
+
close(): Promise<void>;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Subscribe only after prior history has been seeded. Pi emits message
|
|
83
|
+
* lifecycle events for manual appendMessage() calls; subscribing earlier makes
|
|
84
|
+
* restored assistant messages look like fresh output boundaries.
|
|
85
|
+
* @param {any} runState
|
|
86
|
+
* @param {{harness: any, onEvent: (event: any) => void, options: any, toolLimits: any, sdk: string, reference: string}} deps
|
|
87
|
+
*/
|
|
88
|
+
export function activateTurnHarness(runState: any, { harness, onEvent, options, toolLimits, sdk, reference, }: {
|
|
89
|
+
harness: any;
|
|
90
|
+
onEvent: (event: any) => void;
|
|
61
91
|
options: any;
|
|
62
92
|
toolLimits: any;
|
|
63
|
-
sdk:
|
|
64
|
-
reference:
|
|
65
|
-
}):
|
|
93
|
+
sdk: string;
|
|
94
|
+
reference: string;
|
|
95
|
+
}): void;
|
|
66
96
|
/**
|
|
67
97
|
* Start the live-input steering consumer. Consumes follow-up messages and steers
|
|
68
98
|
* the harness mid-run; the consumer is tied to run completion (an internal
|
|
69
99
|
* runComplete flag) so it stops steering once the run finishes and does not
|
|
70
100
|
* swallow a follow-up meant for a later turn. Returns a `stop()` teardown.
|
|
71
|
-
* @param {{harness: any, options: any, onEvent: (event: any) => void}} deps
|
|
101
|
+
* @param {{harness: any, options: any, onEvent: (event: any) => void, promptEpoch?: any}} deps
|
|
72
102
|
* @returns {{stop: () => Promise<void>}}
|
|
73
103
|
*/
|
|
74
|
-
export function startLiveInput({ harness, options, onEvent }: {
|
|
104
|
+
export function startLiveInput({ harness, options, onEvent, promptEpoch }: {
|
|
75
105
|
harness: any;
|
|
76
106
|
options: any;
|
|
77
107
|
onEvent: (event: any) => void;
|
|
108
|
+
promptEpoch?: any;
|
|
78
109
|
}): {
|
|
79
110
|
stop: () => Promise<void>;
|
|
80
111
|
};
|
|
112
|
+
/**
|
|
113
|
+
* Own exact Pi run/entry correlation for the one main prompt in this Mono run.
|
|
114
|
+
* @param {{harness: any, onEvent: (event: any) => void}} deps
|
|
115
|
+
*/
|
|
116
|
+
export function createLiveInputPromptEpoch({ harness, onEvent }: {
|
|
117
|
+
harness: any;
|
|
118
|
+
onEvent: (event: any) => void;
|
|
119
|
+
}): {
|
|
120
|
+
ownedRunId: () => string;
|
|
121
|
+
consumedInputIds: () => any[];
|
|
122
|
+
register(entryId: any, message: any): void;
|
|
123
|
+
isConsumed: (entryId: any) => boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Own the admitted operation as soon as Pi reports its id, before the run
|
|
126
|
+
* settles, so entries consumed mid-run are acknowledged when their
|
|
127
|
+
* message_end arrives rather than in one batch at the end of the run.
|
|
128
|
+
* Safe in either order with run_start; a conflicting id invalidates.
|
|
129
|
+
*/
|
|
130
|
+
confirm(operationId: any): void;
|
|
131
|
+
finish(operationId: any): void;
|
|
132
|
+
close(): void;
|
|
133
|
+
};
|
|
81
134
|
/**
|
|
82
135
|
* Run a single prompt on the harness and wait for it to go idle. A stream error
|
|
83
136
|
* surfaces on the harness (not a throw), so a thrown prompt is captured as
|
|
@@ -85,9 +138,14 @@ export function startLiveInput({ harness, options, onEvent }: {
|
|
|
85
138
|
* @param {any} harness
|
|
86
139
|
* @param {string} promptText
|
|
87
140
|
* @param {Array<any>} promptImages
|
|
88
|
-
* @
|
|
141
|
+
* @param {{onOperationAdmitted?: (operationId: string) => void}} [hooks]
|
|
142
|
+
* `onOperationAdmitted` fires as soon as Pi admits the run, before any
|
|
143
|
+
* provider request, so the live-input epoch can own the operation up front.
|
|
144
|
+
* @returns {Promise<{runError: any, operationId?: string}>}
|
|
89
145
|
*/
|
|
90
|
-
export function runHarnessPrompt(harness: any, promptText: string, promptImages: Array<any
|
|
146
|
+
export function runHarnessPrompt(harness: any, promptText: string, promptImages: Array<any>, hooks?: {
|
|
147
|
+
onOperationAdmitted?: (operationId: string) => void;
|
|
148
|
+
}): Promise<{
|
|
91
149
|
runError: any;
|
|
150
|
+
operationId?: string;
|
|
92
151
|
}>;
|
|
93
|
-
import { AgentHarness } from "@earendil-works/pi-agent-core";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Resolve mono-agent's programmatic mode once per run. Tool builders mark
|
|
3
|
+
* stateful/mutating tools sequential; the Pi 0.85 harness adapter promotes any
|
|
4
|
+
* such marker to its global toolExecution setting because mixed scheduling is
|
|
5
|
+
* no longer available upstream.
|
|
5
6
|
*/
|
|
6
7
|
export function resolvePiToolExecutionMode(options?: {}): {
|
|
7
8
|
mode: any;
|
|
@@ -24,7 +25,23 @@ export function generatePiNativeResponse(systemPrompt: any, options?: {}): Promi
|
|
|
24
25
|
export namespace piNativeRuntimeBridge {
|
|
25
26
|
export let id: string;
|
|
26
27
|
export let kind: string;
|
|
27
|
-
export let capabilities:
|
|
28
|
+
export let capabilities: {
|
|
29
|
+
kind: "pi";
|
|
30
|
+
} & {
|
|
31
|
+
supports_session_resume: boolean;
|
|
32
|
+
supports_native_subagents: boolean;
|
|
33
|
+
supports_request_tool_environment: boolean;
|
|
34
|
+
supports_mcp_apps: boolean;
|
|
35
|
+
tool_policy: "projected";
|
|
36
|
+
streaming: boolean;
|
|
37
|
+
structured_output: boolean;
|
|
38
|
+
native_runtime_config: any;
|
|
39
|
+
supports_mcp: boolean;
|
|
40
|
+
supports_skills: boolean;
|
|
41
|
+
supports_builtin_tools: boolean;
|
|
42
|
+
supports_live_input: boolean;
|
|
43
|
+
runtime: string;
|
|
44
|
+
};
|
|
28
45
|
export function supports(ref: any): boolean;
|
|
29
46
|
export { generatePiNativeResponse as execute };
|
|
30
47
|
}
|
|
@@ -1,84 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @param {*} [_legacySelection]
|
|
3
|
+
* @returns {{kind: "pi"} & typeof RUNTIME_CAPABILITIES.pi}
|
|
4
|
+
*/
|
|
5
|
+
export function runtimeCapabilities(_legacySelection?: any): {
|
|
6
|
+
kind: "pi";
|
|
7
|
+
} & typeof RUNTIME_CAPABILITIES.pi;
|
|
2
8
|
export namespace COMMON_CAPABILITIES {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export let supports_fast_mode: boolean;
|
|
15
|
-
export { TOOL_POLICY_PROJECTED as tool_policy };
|
|
9
|
+
let streaming: boolean;
|
|
10
|
+
let structured_output: boolean;
|
|
11
|
+
let supports_session_resume: boolean;
|
|
12
|
+
let native_runtime_config: any;
|
|
13
|
+
let supports_mcp: boolean;
|
|
14
|
+
let supports_mcp_apps: boolean;
|
|
15
|
+
let supports_skills: boolean;
|
|
16
|
+
let supports_builtin_tools: boolean;
|
|
17
|
+
let supports_live_input: boolean;
|
|
18
|
+
let supports_native_subagents: boolean;
|
|
19
|
+
let supports_request_tool_environment: boolean;
|
|
16
20
|
}
|
|
17
21
|
export namespace RUNTIME_CAPABILITIES {
|
|
18
|
-
namespace
|
|
22
|
+
namespace pi {
|
|
19
23
|
let supports_session_resume_1: boolean;
|
|
20
24
|
export { supports_session_resume_1 as supports_session_resume };
|
|
21
|
-
export let runtime: string;
|
|
22
|
-
}
|
|
23
|
-
namespace pi {
|
|
24
|
-
let supports_session_resume_2: boolean;
|
|
25
|
-
export { supports_session_resume_2 as supports_session_resume };
|
|
26
25
|
let supports_native_subagents_1: boolean;
|
|
27
26
|
export { supports_native_subagents_1 as supports_native_subagents };
|
|
28
27
|
let supports_request_tool_environment_1: boolean;
|
|
29
28
|
export { supports_request_tool_environment_1 as supports_request_tool_environment };
|
|
30
29
|
let supports_mcp_apps_1: boolean;
|
|
31
30
|
export { supports_mcp_apps_1 as supports_mcp_apps };
|
|
32
|
-
|
|
33
|
-
export
|
|
34
|
-
}
|
|
35
|
-
namespace codex {
|
|
36
|
-
let supports_session_resume_3: boolean;
|
|
37
|
-
export { supports_session_resume_3 as supports_session_resume };
|
|
38
|
-
let supports_fast_mode_1: boolean;
|
|
39
|
-
export { supports_fast_mode_1 as supports_fast_mode };
|
|
40
|
-
export { TOOL_POLICY_ALLOW_ALL_ONLY as tool_policy };
|
|
41
|
-
let runtime_2: string;
|
|
42
|
-
export { runtime_2 as runtime };
|
|
43
|
-
}
|
|
44
|
-
namespace opencode {
|
|
45
|
-
let structured_output_1: boolean;
|
|
46
|
-
export { structured_output_1 as structured_output };
|
|
47
|
-
let supports_session_resume_4: boolean;
|
|
48
|
-
export { supports_session_resume_4 as supports_session_resume };
|
|
49
|
-
let supports_mcp_1: boolean;
|
|
50
|
-
export { supports_mcp_1 as supports_mcp };
|
|
51
|
-
let supports_skills_1: boolean;
|
|
52
|
-
export { supports_skills_1 as supports_skills };
|
|
53
|
-
let supports_live_input_1: boolean;
|
|
54
|
-
export { supports_live_input_1 as supports_live_input };
|
|
55
|
-
let supports_native_subagents_2: boolean;
|
|
56
|
-
export { supports_native_subagents_2 as supports_native_subagents };
|
|
57
|
-
export { TOOL_POLICY_ALLOW_ALL_ONLY as tool_policy };
|
|
58
|
-
let runtime_3: string;
|
|
59
|
-
export { runtime_3 as runtime };
|
|
60
|
-
}
|
|
61
|
-
namespace acp {
|
|
62
|
-
let structured_output_2: boolean;
|
|
63
|
-
export { structured_output_2 as structured_output };
|
|
64
|
-
let supports_session_resume_5: boolean;
|
|
65
|
-
export { supports_session_resume_5 as supports_session_resume };
|
|
66
|
-
let supports_mcp_2: boolean;
|
|
67
|
-
export { supports_mcp_2 as supports_mcp };
|
|
68
|
-
let supports_skills_2: boolean;
|
|
69
|
-
export { supports_skills_2 as supports_skills };
|
|
70
|
-
let supports_builtin_tools_1: boolean;
|
|
71
|
-
export { supports_builtin_tools_1 as supports_builtin_tools };
|
|
72
|
-
let supports_live_input_2: boolean;
|
|
73
|
-
export { supports_live_input_2 as supports_live_input };
|
|
74
|
-
let supports_native_subagents_3: boolean;
|
|
75
|
-
export { supports_native_subagents_3 as supports_native_subagents };
|
|
76
|
-
let supports_request_tool_environment_2: boolean;
|
|
77
|
-
export { supports_request_tool_environment_2 as supports_request_tool_environment };
|
|
78
|
-
export { TOOL_POLICY_ALLOW_ALL_ONLY as tool_policy };
|
|
79
|
-
let runtime_4: string;
|
|
80
|
-
export { runtime_4 as runtime };
|
|
31
|
+
export { TOOL_POLICY_PROJECTED as tool_policy };
|
|
32
|
+
export let runtime: string;
|
|
81
33
|
}
|
|
82
34
|
}
|
|
83
35
|
import { TOOL_POLICY_PROJECTED } from "./tool-policy.js";
|
|
84
|
-
import { TOOL_POLICY_ALLOW_ALL_ONLY } from "./tool-policy.js";
|
|
@@ -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,35 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {string} value
|
|
3
|
-
* @returns {string}
|
|
4
|
-
*/
|
|
5
|
-
export function canonicalizeLegacyModelReference(value: string): string;
|
|
6
1
|
/**
|
|
7
2
|
* @param {string} value
|
|
8
3
|
* @returns {RuntimeModelRef}
|
|
9
4
|
*/
|
|
10
5
|
export function normalizeRuntimeModelReference(value: string): RuntimeModelRef;
|
|
11
|
-
/**
|
|
12
|
-
* @param {string} value
|
|
13
|
-
* @returns {RuntimeModelRef["sdk"]}
|
|
14
|
-
*/
|
|
15
|
-
export function sdkFromModelReference(value: string): RuntimeModelRef["sdk"];
|
|
16
6
|
/**
|
|
17
7
|
* @param {string} value
|
|
18
8
|
* @returns {RuntimeModelRef}
|
|
19
9
|
*/
|
|
20
10
|
export function parseRuntimeModelReference(value: string): RuntimeModelRef;
|
|
21
|
-
/**
|
|
22
|
-
* @param {string|RuntimeModelRef} modelRefOrParsed
|
|
23
|
-
* @param {string} executionMode
|
|
24
|
-
* @returns {string|null}
|
|
25
|
-
*/
|
|
26
|
-
export function executionModeIncompatibilityReason(modelRefOrParsed: string | RuntimeModelRef, executionMode: string): string | null;
|
|
27
|
-
/**
|
|
28
|
-
* @param {string|RuntimeModelRef} modelRefOrParsed
|
|
29
|
-
* @param {string} executionMode
|
|
30
|
-
* @returns {boolean}
|
|
31
|
-
*/
|
|
32
|
-
export function isModelCompatibleWithExecutionMode(modelRefOrParsed: string | RuntimeModelRef, executionMode: string): boolean;
|
|
33
|
-
export const ACTIVE_RUNTIME_KINDS: string[];
|
|
34
|
-
export const RESERVED_RUNTIME_KINDS: string[];
|
|
35
11
|
export type RuntimeModelRef = import("../types.js").RuntimeModelRef;
|
|
@@ -2,22 +2,18 @@
|
|
|
2
2
|
* @param {Object} [options]
|
|
3
3
|
* @param {AgentRuntimeHostOptions} [options.host]
|
|
4
4
|
* @param {ReadonlyArray<RuntimeModelRef|RouterChainEntryInput>} [options.chain]
|
|
5
|
-
* @param {
|
|
6
|
-
* @param {(input: {model: RuntimeModelRef, executionMode: string|null, attemptIndex: number, retryIndex: number, routeSafety: "uniform"|"per-route-native"}) => (RouterAttemptResolution|Promise<RouterAttemptResolution>)} [options.resolveAttempt]
|
|
5
|
+
* @param {(input: {model: RuntimeModelRef, attemptIndex: number, retryIndex: number}) => (RouterAttemptResolution|Promise<RouterAttemptResolution>)} [options.resolveAttempt]
|
|
7
6
|
* @param {Partial<RouterRetryPolicy>} [options.retry] Backoff shape for same-model
|
|
8
7
|
* retries. Per-route retry counts live on each chain entry's `attempts`.
|
|
9
8
|
* @returns {AgentRuntimeInstance & {chain: () => Array<RouterChainEntry>}}
|
|
10
9
|
*/
|
|
11
|
-
export function createRouterRuntime({ host, chain,
|
|
10
|
+
export function createRouterRuntime({ host, chain, resolveAttempt, retry }?: {
|
|
12
11
|
host?: AgentRuntimeHostOptions;
|
|
13
12
|
chain?: ReadonlyArray<RuntimeModelRef | RouterChainEntryInput>;
|
|
14
|
-
routeSafety?: "uniform" | "per-route-native";
|
|
15
13
|
resolveAttempt?: (input: {
|
|
16
14
|
model: RuntimeModelRef;
|
|
17
|
-
executionMode: string | null;
|
|
18
15
|
attemptIndex: number;
|
|
19
16
|
retryIndex: number;
|
|
20
|
-
routeSafety: "uniform" | "per-route-native";
|
|
21
17
|
}) => (RouterAttemptResolution | Promise<RouterAttemptResolution>);
|
|
22
18
|
retry?: Partial<RouterRetryPolicy>;
|
|
23
19
|
}): AgentRuntimeInstance & {
|
|
@@ -30,12 +26,10 @@ export type RuntimeRunOptions = import("../types.js").RuntimeRunOptions;
|
|
|
30
26
|
export type RuntimeResult = import("../types.js").RuntimeResult;
|
|
31
27
|
/**
|
|
32
28
|
* A chain entry as accepted by createRouterRuntime: either the shorthand bare
|
|
33
|
-
* RuntimeModelRef, or the full `{model,
|
|
34
|
-
* attempts?}` form.
|
|
29
|
+
* RuntimeModelRef, or the full `{model, effort?, requires?, attempts?}` form.
|
|
35
30
|
*/
|
|
36
31
|
export type RouterChainEntryInput = {
|
|
37
32
|
model: RuntimeModelRef;
|
|
38
|
-
executionMode?: string;
|
|
39
33
|
effort?: string | null;
|
|
40
34
|
requires?: {
|
|
41
35
|
[x: string]: any;
|
|
@@ -44,7 +38,6 @@ export type RouterChainEntryInput = {
|
|
|
44
38
|
};
|
|
45
39
|
export type RouterChainEntry = {
|
|
46
40
|
model: RuntimeModelRef;
|
|
47
|
-
executionMode: string | null;
|
|
48
41
|
effort: string | null | undefined;
|
|
49
42
|
requires: {
|
|
50
43
|
[x: string]: any;
|
|
@@ -11,5 +11,3 @@
|
|
|
11
11
|
export function isAllowAllToolPolicy(allowedTools: any, disallowedTools: any): boolean;
|
|
12
12
|
/** @type {"projected"} */
|
|
13
13
|
export const TOOL_POLICY_PROJECTED: "projected";
|
|
14
|
-
/** @type {"allow_all_only"} */
|
|
15
|
-
export const TOOL_POLICY_ALLOW_ALL_ONLY: "allow_all_only";
|
|
@@ -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
|
};
|