@mono-agent/agent-runtime 0.6.2 → 0.8.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 +36 -16
- package/package.json +14 -7
- package/src/agent/approval.js +52 -17
- package/src/agent/sandbox-seam.js +1 -0
- package/src/agent/tools/pi-bridge.js +2 -0
- package/src/agent/tools/shared/ripgrep.js +12 -8
- package/src/ai/index.js +8 -0
- package/src/ai/providers/claude-cli.js +109 -5
- package/src/ai/providers/claude-sandbox.js +71 -0
- package/src/ai/providers/claude-sdk-discovery-worker.js +53 -0
- package/src/ai/providers/claude-sdk-discovery.js +352 -0
- package/src/ai/providers/claude-sdk.js +313 -35
- package/src/ai/providers/codex-app.js +823 -78
- package/src/ai/providers/opencode-app.js +682 -96
- package/src/ai/providers/opencode-server.js +508 -0
- package/src/ai/runtime/capabilities.js +12 -0
- package/src/ai/runtime/context-windows.js +8 -0
- package/src/ai/runtime/registry.js +8 -2
- package/src/ai/runtime/router.js +627 -29
- package/src/ai/types.js +29 -2
- package/src/index.js +6 -0
- package/src/runtime.js +17 -1
- package/types/agent/approval.d.ts +4 -7
- package/types/agent/sandbox-seam.d.ts +5 -0
- package/types/ai/backend.d.ts +16 -0
- package/types/ai/index.d.ts +1 -0
- package/types/ai/providers/claude-cli.d.ts +116 -0
- package/types/ai/providers/claude-sandbox.d.ts +79 -0
- package/types/ai/providers/claude-sdk-discovery-worker.d.ts +1 -0
- package/types/ai/providers/claude-sdk-discovery.d.ts +97 -0
- package/types/ai/providers/claude-sdk.d.ts +81 -5
- package/types/ai/providers/codex-app.d.ts +11 -7
- package/types/ai/providers/opencode-app.d.ts +15 -16
- package/types/ai/providers/opencode-server.d.ts +20 -0
- package/types/ai/runtime/capabilities.d.ts +19 -0
- package/types/ai/runtime/context-windows.d.ts +1 -0
- package/types/ai/runtime/router.d.ts +24 -23
- package/types/ai/types.d.ts +75 -2
- package/types/index.d.ts +1 -0
package/src/ai/types.js
CHANGED
|
@@ -46,6 +46,27 @@
|
|
|
46
46
|
* context_compaction_applied, ...) adds its own extra fields.
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
|
+
/** @typedef {"uniform"|"per-route-native"} RuntimeRouteSafetyMode */
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @typedef {"mono-agent-monotonic"|"disabled"|"mono-agent-srt"|"mono-agent-srt-unsafe-host-fallback"|"provider-native"|"codex-native"|"unsupported"} RuntimeRouteSandboxContract
|
|
53
|
+
* Fixed telemetry vocabulary for a route's sandbox posture. The
|
|
54
|
+
* `mono-agent-srt-unsafe-host-fallback` describes a policy that prefers SRT but
|
|
55
|
+
* explicitly permits host execution if unavailable; it does not claim which
|
|
56
|
+
* branch ran for a particular command.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/** @typedef {"mono-agent-monotonic"|"mono-agent-policy"|"provider-representable"|"exact-allow-all"|"unsupported"} RuntimeRouteToolsContract */
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @typedef {Object} RuntimeRouteSafetyContract
|
|
63
|
+
* Bounded, credential-free description of the sandbox/tool contract applied
|
|
64
|
+
* to one fallback route.
|
|
65
|
+
* @property {RuntimeRouteSafetyMode} mode
|
|
66
|
+
* @property {RuntimeRouteSandboxContract} sandbox
|
|
67
|
+
* @property {RuntimeRouteToolsContract} tools
|
|
68
|
+
*/
|
|
69
|
+
|
|
49
70
|
/**
|
|
50
71
|
* @typedef {Object} RuntimeObserver
|
|
51
72
|
* Per-call or host-level observer merged by createObserverHub (ai/observer.js).
|
|
@@ -107,6 +128,10 @@
|
|
|
107
128
|
* The options object a host passes to `createRuntime(host).run(systemPrompt, options)`.
|
|
108
129
|
* @property {RuntimeModelRef} model Resolved model reference; see parseRuntimeModelReference.
|
|
109
130
|
* @property {string} [executionMode] "sdk" (default) or "cli"; selects which bridge variant handles the model.
|
|
131
|
+
* @property {string} [sessionId] Host conversation/session key for resumable bridges.
|
|
132
|
+
* @property {string} [providerSessionId] Provider-owned resume id for resumable bridges.
|
|
133
|
+
* @property {boolean} [sessionKeepAlive] Keep resumable provider state alive after the turn.
|
|
134
|
+
* @property {number} [sessionIdleTimeoutMs] Idle TTL for resumable provider state.
|
|
110
135
|
* @property {boolean} [liveInput] Whether this run expects a live/streaming input channel.
|
|
111
136
|
* @property {ReadonlyArray<*>} [observers] Per-call observers (see RuntimeObserver) merged with host-level (createRuntime) observers.
|
|
112
137
|
* @property {(event: RuntimeEvent) => void} [onEvent]
|
|
@@ -115,6 +140,7 @@
|
|
|
115
140
|
* @property {boolean} [fastMode]
|
|
116
141
|
* @property {string} [cwd]
|
|
117
142
|
* @property {Object<string, Object>} [mcpServers]
|
|
143
|
+
* @property {ReadonlyArray<Object>} [skills] Runtime skill metadata for progressive disclosure.
|
|
118
144
|
* @property {ReadonlyArray<string>} [allowedTools]
|
|
119
145
|
* @property {ReadonlyArray<string>} [disallowedTools]
|
|
120
146
|
* @property {string} [permissionMode]
|
|
@@ -173,7 +199,8 @@
|
|
|
173
199
|
* @property {Array<Object>} [runtimeWarnings]
|
|
174
200
|
* @property {Object} [diagnostics]
|
|
175
201
|
* @property {Object} [capabilitiesUsed]
|
|
176
|
-
* @property {Array<{model: RuntimeModelRef, failureKind: (string|null), requestId?: (string|null), retryableSubkind?: (string|null), requirements?: Object}>} [failoverHistory] Set by createRouterRuntime (ai/runtime/router.js) on every attempt
|
|
202
|
+
* @property {Array<{model: RuntimeModelRef, failureKind: (string|null), requestId?: (string|null), retryableSubkind?: (string|null), requirements?: Object, routeSafety?: RuntimeRouteSafetyMode, safetyContract?: RuntimeRouteSafetyContract}>} [failoverHistory] Set by createRouterRuntime (ai/runtime/router.js) on every failed/skipped attempt.
|
|
203
|
+
* @property {Array<{attemptIndex: number, model: RuntimeModelRef, routeSafety: RuntimeRouteSafetyMode, safetyContract: RuntimeRouteSafetyContract, status: string}>} [routeSafetyHistory] Bounded route-safety audit emitted by createRouterRuntime.
|
|
177
204
|
*/
|
|
178
205
|
|
|
179
206
|
/**
|
|
@@ -299,4 +326,4 @@
|
|
|
299
326
|
* @property {() => Promise<void>} disposeAllSessions
|
|
300
327
|
*/
|
|
301
328
|
|
|
302
|
-
export const PROVIDER_KIND_VALUES = ["claude", "pi", "codex"];
|
|
329
|
+
export const PROVIDER_KIND_VALUES = ["claude", "pi", "codex", "opencode"];
|
package/src/index.js
CHANGED
|
@@ -18,6 +18,12 @@ export {
|
|
|
18
18
|
DEFAULT_RUNTIME_BRAND,
|
|
19
19
|
resolveRuntimeBrand,
|
|
20
20
|
} from "./runtime-brand.js";
|
|
21
|
+
export {
|
|
22
|
+
CLAUDE_SDK_CATALOG_VERSION,
|
|
23
|
+
discoverClaudeSdkModels,
|
|
24
|
+
normalizeClaudeSdkCatalog,
|
|
25
|
+
normalizeClaudeSdkModelId,
|
|
26
|
+
} from "./ai/providers/claude-sdk-discovery.js";
|
|
21
27
|
|
|
22
28
|
export * from "./ai/index.js";
|
|
23
29
|
export * from "./agent/index.js";
|
package/src/runtime.js
CHANGED
|
@@ -77,6 +77,22 @@ function pickDefined(source, keys) {
|
|
|
77
77
|
return out;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Select recognized keys that are present even when their value is undefined.
|
|
82
|
+
* `configureTools` uses this variant so callers can explicitly clear state
|
|
83
|
+
* held by the long-lived per-instance ToolContext.
|
|
84
|
+
* @param {Object<string, *>} source
|
|
85
|
+
* @param {Array<string>} keys
|
|
86
|
+
* @returns {Object<string, *>}
|
|
87
|
+
*/
|
|
88
|
+
function pickPresent(source, keys) {
|
|
89
|
+
const out = {};
|
|
90
|
+
for (const key of keys) {
|
|
91
|
+
if (source && key in source) out[key] = source[key];
|
|
92
|
+
}
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
|
|
80
96
|
const PROMPT_OVERRIDE_KEYS = ["structuredOutputInstruction", "structuredOutputFinalization", "liveInputGuidance"];
|
|
81
97
|
|
|
82
98
|
/**
|
|
@@ -157,7 +173,7 @@ export function createRuntime(host = {}) {
|
|
|
157
173
|
return result;
|
|
158
174
|
},
|
|
159
175
|
configureTools(next = {}) {
|
|
160
|
-
updateToolContext(toolContext,
|
|
176
|
+
updateToolContext(toolContext, pickPresent(next, TOOL_RUNTIME_KEYS));
|
|
161
177
|
},
|
|
162
178
|
async disposeSession(providerSessionId) {
|
|
163
179
|
return disposeProviderSession(providerSessionId);
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {{onToolApprovalRequest?: any, defaultRiskTier?: string, timeoutMs?: number, onEvent?: (event: any) => void, riskTiersByTool?: any, alwaysAllowTools?: any}} [options]
|
|
2
|
+
* @param {{onToolApprovalRequest?: any, defaultRiskTier?: string, timeoutMs?: number, onEvent?: (event: any) => void, riskTiersByTool?: any, alwaysAllowTools?: any, autoApproveLowRisk?: boolean}} [options]
|
|
3
3
|
*/
|
|
4
|
-
export function createApprovalManager({ onToolApprovalRequest, defaultRiskTier, timeoutMs, onEvent, riskTiersByTool, alwaysAllowTools, }?: {
|
|
4
|
+
export function createApprovalManager({ onToolApprovalRequest, defaultRiskTier, timeoutMs, onEvent, riskTiersByTool, alwaysAllowTools, autoApproveLowRisk, }?: {
|
|
5
5
|
onToolApprovalRequest?: any;
|
|
6
6
|
defaultRiskTier?: string;
|
|
7
7
|
timeoutMs?: number;
|
|
8
8
|
onEvent?: (event: any) => void;
|
|
9
9
|
riskTiersByTool?: any;
|
|
10
10
|
alwaysAllowTools?: any;
|
|
11
|
+
autoApproveLowRisk?: boolean;
|
|
11
12
|
}): {
|
|
12
13
|
request: (toolCall?: {}) => Promise<{
|
|
13
|
-
decision: string;
|
|
14
|
-
reason: string;
|
|
15
|
-
riskTier: any;
|
|
16
|
-
} | {
|
|
17
14
|
requestId: any;
|
|
18
15
|
riskTier: any;
|
|
19
16
|
decision: any;
|
|
20
|
-
reason:
|
|
17
|
+
reason: string;
|
|
21
18
|
}>;
|
|
22
19
|
riskTierFor: (toolName: any) => any;
|
|
23
20
|
sessionAllowlist: () => Set<any>;
|
|
@@ -7,6 +7,10 @@ export type SandboxCommandSpec = {
|
|
|
7
7
|
env?: {
|
|
8
8
|
[x: string]: string;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Trusted per-command capability.
|
|
12
|
+
*/
|
|
13
|
+
allowLocalBinding?: boolean;
|
|
10
14
|
};
|
|
11
15
|
export type PreparedSandboxCommand = SandboxCommandSpec & {
|
|
12
16
|
sandboxed: boolean;
|
|
@@ -85,6 +89,7 @@ export class SandboxUnavailableError extends Error {
|
|
|
85
89
|
* @property {ReadonlyArray<string>} [args]
|
|
86
90
|
* @property {string} [cwd]
|
|
87
91
|
* @property {Object<string, string|undefined>} [env]
|
|
92
|
+
* @property {boolean} [allowLocalBinding] Trusted per-command capability.
|
|
88
93
|
*/
|
|
89
94
|
/**
|
|
90
95
|
* @typedef {SandboxCommandSpec & {sandboxed: boolean, cleanup?: () => Promise<void>}} PreparedSandboxCommand
|
package/types/ai/backend.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export const BACKEND_CAPABILITIES: {
|
|
|
12
12
|
supports_builtin_tools: boolean;
|
|
13
13
|
supports_live_input: boolean;
|
|
14
14
|
supports_native_subagents: boolean;
|
|
15
|
+
supports_fast_mode: boolean;
|
|
15
16
|
runtime: string;
|
|
16
17
|
};
|
|
17
18
|
pi: {
|
|
@@ -24,10 +25,12 @@ export const BACKEND_CAPABILITIES: {
|
|
|
24
25
|
supports_skills: boolean;
|
|
25
26
|
supports_builtin_tools: boolean;
|
|
26
27
|
supports_live_input: boolean;
|
|
28
|
+
supports_fast_mode: boolean;
|
|
27
29
|
runtime: string;
|
|
28
30
|
};
|
|
29
31
|
codex: {
|
|
30
32
|
supports_session_resume: boolean;
|
|
33
|
+
supports_fast_mode: boolean;
|
|
31
34
|
streaming: boolean;
|
|
32
35
|
structured_output: boolean;
|
|
33
36
|
native_runtime_config: any;
|
|
@@ -38,4 +41,17 @@ export const BACKEND_CAPABILITIES: {
|
|
|
38
41
|
supports_native_subagents: boolean;
|
|
39
42
|
runtime: string;
|
|
40
43
|
};
|
|
44
|
+
opencode: {
|
|
45
|
+
structured_output: boolean;
|
|
46
|
+
supports_session_resume: boolean;
|
|
47
|
+
supports_mcp: boolean;
|
|
48
|
+
supports_skills: boolean;
|
|
49
|
+
supports_live_input: boolean;
|
|
50
|
+
supports_native_subagents: boolean;
|
|
51
|
+
streaming: boolean;
|
|
52
|
+
native_runtime_config: any;
|
|
53
|
+
supports_builtin_tools: boolean;
|
|
54
|
+
supports_fast_mode: boolean;
|
|
55
|
+
runtime: string;
|
|
56
|
+
};
|
|
41
57
|
};
|
package/types/ai/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export * from "./runtime/registry.js";
|
|
|
4
4
|
export { createSessionRegistry, disposeAllProviderSessions, disposeProviderSession } from "./runtime/sessions.js";
|
|
5
5
|
export { createMetricsObserver, createObserverHub } from "./observer.js";
|
|
6
6
|
export { generatePiNativeResponse, piNativeRuntimeBridge } from "./providers/pi-native.js";
|
|
7
|
+
export { CLAUDE_SDK_CATALOG_VERSION, createClaudeSdkDiscoveryIsolation, curatedClaudeSdkModels, discoverClaudeSdkModels, normalizeClaudeSdkCatalog, normalizeClaudeSdkModelId } from "./providers/claude-sdk-discovery.js";
|
|
7
8
|
export { buildCapabilitiesUsed, toolCompactionAppliedFromWarnings, UNKNOWN_CAPABILITY } from "./runtime/capabilities-used.js";
|
|
@@ -29,6 +29,64 @@ export function buildCliCommand({ sdk, model, effort, cwd, schemaPath, outputSch
|
|
|
29
29
|
cwd: any;
|
|
30
30
|
};
|
|
31
31
|
export function generateCliResponse(systemPrompt: any, options?: {}): Promise<{
|
|
32
|
+
text: any;
|
|
33
|
+
structuredResult: any;
|
|
34
|
+
structuredResultSource: any;
|
|
35
|
+
events: any[];
|
|
36
|
+
usage: {};
|
|
37
|
+
durationMs: number;
|
|
38
|
+
numTurns: number;
|
|
39
|
+
model: any;
|
|
40
|
+
effort: any;
|
|
41
|
+
sdk: any;
|
|
42
|
+
providerSessionId: any;
|
|
43
|
+
provider_session_id: any;
|
|
44
|
+
cancelled: boolean;
|
|
45
|
+
error: any;
|
|
46
|
+
failureKind: string;
|
|
47
|
+
diagnostics: {
|
|
48
|
+
claude_error_code: any;
|
|
49
|
+
};
|
|
50
|
+
capabilitiesUsed: {
|
|
51
|
+
prompt_cache_active: any;
|
|
52
|
+
thinking_enabled: any;
|
|
53
|
+
structured_output_enforced: boolean;
|
|
54
|
+
subagent_invoked: any;
|
|
55
|
+
mcp_servers_used: any[];
|
|
56
|
+
native_subagents_used: any[];
|
|
57
|
+
tool_compaction_applied: boolean;
|
|
58
|
+
context_compaction_applied: any;
|
|
59
|
+
};
|
|
60
|
+
} | {
|
|
61
|
+
text: any;
|
|
62
|
+
structuredResult: any;
|
|
63
|
+
structuredResultSource: any;
|
|
64
|
+
events: any[];
|
|
65
|
+
usage: {};
|
|
66
|
+
durationMs: number;
|
|
67
|
+
numTurns: number;
|
|
68
|
+
model: any;
|
|
69
|
+
effort: any;
|
|
70
|
+
sdk: string;
|
|
71
|
+
providerSessionId: any;
|
|
72
|
+
provider_session_id: any;
|
|
73
|
+
cancelled: boolean;
|
|
74
|
+
error: any;
|
|
75
|
+
failureKind: string;
|
|
76
|
+
diagnostics: {
|
|
77
|
+
codex_error_code: any;
|
|
78
|
+
};
|
|
79
|
+
capabilitiesUsed: {
|
|
80
|
+
prompt_cache_active: any;
|
|
81
|
+
thinking_enabled: any;
|
|
82
|
+
structured_output_enforced: boolean;
|
|
83
|
+
subagent_invoked: any;
|
|
84
|
+
mcp_servers_used: any[];
|
|
85
|
+
native_subagents_used: any[];
|
|
86
|
+
tool_compaction_applied: boolean;
|
|
87
|
+
context_compaction_applied: any;
|
|
88
|
+
};
|
|
89
|
+
} | {
|
|
32
90
|
text: any;
|
|
33
91
|
structuredResult: undefined;
|
|
34
92
|
structuredResultSource: string;
|
|
@@ -140,6 +198,64 @@ export namespace claudeCodeRuntimeBridge {
|
|
|
140
198
|
export { capabilities_2 as capabilities };
|
|
141
199
|
export function supports(ref: any, options: any): boolean;
|
|
142
200
|
export function execute(systemPrompt: any, options: any): Promise<{
|
|
201
|
+
text: any;
|
|
202
|
+
structuredResult: any;
|
|
203
|
+
structuredResultSource: any;
|
|
204
|
+
events: any[];
|
|
205
|
+
usage: {};
|
|
206
|
+
durationMs: number;
|
|
207
|
+
numTurns: number;
|
|
208
|
+
model: any;
|
|
209
|
+
effort: any;
|
|
210
|
+
sdk: any;
|
|
211
|
+
providerSessionId: any;
|
|
212
|
+
provider_session_id: any;
|
|
213
|
+
cancelled: boolean;
|
|
214
|
+
error: any;
|
|
215
|
+
failureKind: string;
|
|
216
|
+
diagnostics: {
|
|
217
|
+
claude_error_code: any;
|
|
218
|
+
};
|
|
219
|
+
capabilitiesUsed: {
|
|
220
|
+
prompt_cache_active: any;
|
|
221
|
+
thinking_enabled: any;
|
|
222
|
+
structured_output_enforced: boolean;
|
|
223
|
+
subagent_invoked: any;
|
|
224
|
+
mcp_servers_used: any[];
|
|
225
|
+
native_subagents_used: any[];
|
|
226
|
+
tool_compaction_applied: boolean;
|
|
227
|
+
context_compaction_applied: any;
|
|
228
|
+
};
|
|
229
|
+
} | {
|
|
230
|
+
text: any;
|
|
231
|
+
structuredResult: any;
|
|
232
|
+
structuredResultSource: any;
|
|
233
|
+
events: any[];
|
|
234
|
+
usage: {};
|
|
235
|
+
durationMs: number;
|
|
236
|
+
numTurns: number;
|
|
237
|
+
model: any;
|
|
238
|
+
effort: any;
|
|
239
|
+
sdk: string;
|
|
240
|
+
providerSessionId: any;
|
|
241
|
+
provider_session_id: any;
|
|
242
|
+
cancelled: boolean;
|
|
243
|
+
error: any;
|
|
244
|
+
failureKind: string;
|
|
245
|
+
diagnostics: {
|
|
246
|
+
codex_error_code: any;
|
|
247
|
+
};
|
|
248
|
+
capabilitiesUsed: {
|
|
249
|
+
prompt_cache_active: any;
|
|
250
|
+
thinking_enabled: any;
|
|
251
|
+
structured_output_enforced: boolean;
|
|
252
|
+
subagent_invoked: any;
|
|
253
|
+
mcp_servers_used: any[];
|
|
254
|
+
native_subagents_used: any[];
|
|
255
|
+
tool_compaction_applied: boolean;
|
|
256
|
+
context_compaction_applied: any;
|
|
257
|
+
};
|
|
258
|
+
} | {
|
|
143
259
|
text: any;
|
|
144
260
|
structuredResult: undefined;
|
|
145
261
|
structuredResultSource: string;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude owns its built-in tool subprocesses, so mono-agent's runtime tool
|
|
3
|
+
* context cannot wrap them with the configured srt engine. An explicit `off`
|
|
4
|
+
* policy is inert and remains valid; every enforcing mono-agent mode must fail
|
|
5
|
+
* before the provider starts instead of silently running outside that policy.
|
|
6
|
+
*/
|
|
7
|
+
export function claudeSandboxPolicyProblem(options: any): string;
|
|
8
|
+
/** Typed provider result used by Claude bridges for fail-closed capability paths. */
|
|
9
|
+
export function claudeCapabilityMismatchResult({ model, effort, sdk, providerSessionId, durationMs, outputSchema, error, errorCode, }: {
|
|
10
|
+
model: any;
|
|
11
|
+
effort: any;
|
|
12
|
+
sdk: any;
|
|
13
|
+
providerSessionId?: any;
|
|
14
|
+
durationMs?: number;
|
|
15
|
+
outputSchema: any;
|
|
16
|
+
error: any;
|
|
17
|
+
errorCode: any;
|
|
18
|
+
}): {
|
|
19
|
+
text: any;
|
|
20
|
+
structuredResult: any;
|
|
21
|
+
structuredResultSource: any;
|
|
22
|
+
events: any[];
|
|
23
|
+
usage: {};
|
|
24
|
+
durationMs: number;
|
|
25
|
+
numTurns: number;
|
|
26
|
+
model: any;
|
|
27
|
+
effort: any;
|
|
28
|
+
sdk: any;
|
|
29
|
+
providerSessionId: any;
|
|
30
|
+
provider_session_id: any;
|
|
31
|
+
cancelled: boolean;
|
|
32
|
+
error: any;
|
|
33
|
+
failureKind: string;
|
|
34
|
+
diagnostics: {
|
|
35
|
+
claude_error_code: any;
|
|
36
|
+
};
|
|
37
|
+
capabilitiesUsed: {
|
|
38
|
+
prompt_cache_active: any;
|
|
39
|
+
thinking_enabled: any;
|
|
40
|
+
structured_output_enforced: boolean;
|
|
41
|
+
subagent_invoked: any;
|
|
42
|
+
mcp_servers_used: any[];
|
|
43
|
+
native_subagents_used: any[];
|
|
44
|
+
tool_compaction_applied: boolean;
|
|
45
|
+
context_compaction_applied: any;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
/** Typed provider result used by both Claude bridges for the sandbox path. */
|
|
49
|
+
export function claudeSandboxCapabilityMismatchResult(options: any): {
|
|
50
|
+
text: any;
|
|
51
|
+
structuredResult: any;
|
|
52
|
+
structuredResultSource: any;
|
|
53
|
+
events: any[];
|
|
54
|
+
usage: {};
|
|
55
|
+
durationMs: number;
|
|
56
|
+
numTurns: number;
|
|
57
|
+
model: any;
|
|
58
|
+
effort: any;
|
|
59
|
+
sdk: any;
|
|
60
|
+
providerSessionId: any;
|
|
61
|
+
provider_session_id: any;
|
|
62
|
+
cancelled: boolean;
|
|
63
|
+
error: any;
|
|
64
|
+
failureKind: string;
|
|
65
|
+
diagnostics: {
|
|
66
|
+
claude_error_code: any;
|
|
67
|
+
};
|
|
68
|
+
capabilitiesUsed: {
|
|
69
|
+
prompt_cache_active: any;
|
|
70
|
+
thinking_enabled: any;
|
|
71
|
+
structured_output_enforced: boolean;
|
|
72
|
+
subagent_invoked: any;
|
|
73
|
+
mcp_servers_used: any[];
|
|
74
|
+
native_subagents_used: any[];
|
|
75
|
+
tool_compaction_applied: boolean;
|
|
76
|
+
context_compaction_applied: any;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export const CLAUDE_SANDBOX_POLICY_UNSUPPORTED: "Claude SDK/CLI cannot enforce mono-agent's native srt sandbox scopes. Remove the mono-agent sandbox policy or use a Pi runtime for exact readableRoots, writableRoots, denyWrite, and network rules.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the versioned, SDK-matched fallback without exposing mutable shared
|
|
3
|
+
* objects to callers.
|
|
4
|
+
*/
|
|
5
|
+
export function curatedClaudeSdkModels(): {
|
|
6
|
+
supportedEfforts: ClaudeSdkEffort[];
|
|
7
|
+
/**
|
|
8
|
+
* Exact model id accepted by the SDK.
|
|
9
|
+
*/
|
|
10
|
+
model: string;
|
|
11
|
+
/**
|
|
12
|
+
* Canonical mono-agent reference.
|
|
13
|
+
*/
|
|
14
|
+
reference: `claude:${string}`;
|
|
15
|
+
displayName: string;
|
|
16
|
+
description: string;
|
|
17
|
+
supportsAdaptiveThinking: boolean;
|
|
18
|
+
supportsFastMode: boolean;
|
|
19
|
+
source: "discovered" | "cached";
|
|
20
|
+
catalogVersion: typeof CLAUDE_SDK_CATALOG_VERSION;
|
|
21
|
+
}[];
|
|
22
|
+
/**
|
|
23
|
+
* Normalize only exact Claude model ids. CLI convenience aliases are rejected
|
|
24
|
+
* so persisted configuration never changes meaning when an alias advances.
|
|
25
|
+
* Exact dated ids and a canonical `[1m]` suffix are preserved.
|
|
26
|
+
* @param {unknown} value
|
|
27
|
+
* @returns {string|null}
|
|
28
|
+
*/
|
|
29
|
+
export function normalizeClaudeSdkModelId(value: unknown): string | null;
|
|
30
|
+
/**
|
|
31
|
+
* Whitelist the SDK initialization catalog into the public mono-agent shape.
|
|
32
|
+
* No account, organization, token source, raw error, or unknown SDK field can
|
|
33
|
+
* cross this boundary.
|
|
34
|
+
* @param {unknown} rows
|
|
35
|
+
* @param {"discovered"|"cached"} [source]
|
|
36
|
+
* @returns {ClaudeSdkCatalogModel[]}
|
|
37
|
+
*/
|
|
38
|
+
export function normalizeClaudeSdkCatalog(rows: unknown, source?: "discovered" | "cached"): ClaudeSdkCatalogModel[];
|
|
39
|
+
/** @internal Exported for deterministic isolation tests. */
|
|
40
|
+
export function createClaudeSdkDiscoveryIsolation({ baseEnvironment }?: {
|
|
41
|
+
baseEnvironment?: NodeJS.ProcessEnv;
|
|
42
|
+
}): Promise<{
|
|
43
|
+
root: string;
|
|
44
|
+
cwd: string;
|
|
45
|
+
env: {
|
|
46
|
+
HOME: string;
|
|
47
|
+
CLAUDE_CONFIG_DIR: string;
|
|
48
|
+
XDG_CONFIG_HOME: string;
|
|
49
|
+
XDG_CACHE_HOME: string;
|
|
50
|
+
XDG_DATA_HOME: string;
|
|
51
|
+
XDG_STATE_HOME: string;
|
|
52
|
+
TMPDIR: string;
|
|
53
|
+
TMP: string;
|
|
54
|
+
TEMP: string;
|
|
55
|
+
CLAUDE_AGENT_SDK_CLIENT_APP: string;
|
|
56
|
+
MCP_CONNECTION_NONBLOCKING: string;
|
|
57
|
+
};
|
|
58
|
+
cleanup: () => Promise<void>;
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Discover Claude's current model catalog in a throwaway, no-auth process.
|
|
62
|
+
* Failure is deliberately non-fatal: the exact SDK-versioned curated catalog
|
|
63
|
+
* remains available with `source: "cached"`.
|
|
64
|
+
*
|
|
65
|
+
* @param {Object} [options]
|
|
66
|
+
* @param {number} [options.timeoutMs]
|
|
67
|
+
* @param {readonly string[]} [options.authoredModelRefs]
|
|
68
|
+
* @param {typeof fork} [options.forkProcess]
|
|
69
|
+
* @param {(isolation: Awaited<ReturnType<typeof createClaudeSdkDiscoveryIsolation>>) => void} [options.onIsolation]
|
|
70
|
+
* @returns {Promise<ClaudeSdkCatalogModel[]>}
|
|
71
|
+
*/
|
|
72
|
+
export function discoverClaudeSdkModels({ timeoutMs, authoredModelRefs, forkProcess, onIsolation, }?: {
|
|
73
|
+
timeoutMs?: number;
|
|
74
|
+
authoredModelRefs?: readonly string[];
|
|
75
|
+
forkProcess?: typeof fork;
|
|
76
|
+
onIsolation?: (isolation: Awaited<ReturnType<typeof createClaudeSdkDiscoveryIsolation>>) => void;
|
|
77
|
+
}): Promise<ClaudeSdkCatalogModel[]>;
|
|
78
|
+
export const CLAUDE_SDK_CATALOG_VERSION: "claude-agent-sdk-0.3.206";
|
|
79
|
+
export type ClaudeSdkEffort = "low" | "medium" | "high" | "xhigh" | "max";
|
|
80
|
+
export type ClaudeSdkCatalogModel = {
|
|
81
|
+
/**
|
|
82
|
+
* Exact model id accepted by the SDK.
|
|
83
|
+
*/
|
|
84
|
+
model: string;
|
|
85
|
+
/**
|
|
86
|
+
* Canonical mono-agent reference.
|
|
87
|
+
*/
|
|
88
|
+
reference: `claude:${string}`;
|
|
89
|
+
displayName: string;
|
|
90
|
+
description: string;
|
|
91
|
+
supportedEfforts: readonly ClaudeSdkEffort[];
|
|
92
|
+
supportsAdaptiveThinking: boolean;
|
|
93
|
+
supportsFastMode: boolean;
|
|
94
|
+
source: "discovered" | "cached";
|
|
95
|
+
catalogVersion: typeof CLAUDE_SDK_CATALOG_VERSION;
|
|
96
|
+
};
|
|
97
|
+
import { fork } from "node:child_process";
|
|
@@ -1,8 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preserve the provider default when effort is omitted. The current Agent SDK
|
|
3
|
+
* accepts the five values below verbatim; mono-agent must not infer thinking
|
|
4
|
+
* enablement/disablement from a requested effort level.
|
|
5
|
+
* @param {unknown} effort
|
|
6
|
+
* @returns {{effort?: "low" | "medium" | "high" | "xhigh" | "max"}}
|
|
7
|
+
*/
|
|
8
|
+
export function claudeEffortOptions(effort: unknown): {
|
|
9
|
+
effort?: "low" | "medium" | "high" | "xhigh" | "max";
|
|
10
|
+
};
|
|
11
|
+
/** @param {string} model @param {unknown} contextWindow */
|
|
12
|
+
export function claudeSdkModelForQuery(model: string, contextWindow: unknown): string;
|
|
1
13
|
export function toolPayloadLimit(options: any): {
|
|
2
14
|
bytes: number;
|
|
3
15
|
usedSettings: boolean;
|
|
4
16
|
};
|
|
5
17
|
export function generateClaudeResponse(systemPrompt: any, options: any): Promise<{
|
|
18
|
+
text: any;
|
|
19
|
+
structuredResult: any;
|
|
20
|
+
structuredResultSource: any;
|
|
21
|
+
events: any[];
|
|
22
|
+
usage: {};
|
|
23
|
+
durationMs: number;
|
|
24
|
+
numTurns: number;
|
|
25
|
+
model: any;
|
|
26
|
+
effort: any;
|
|
27
|
+
sdk: any;
|
|
28
|
+
providerSessionId: any;
|
|
29
|
+
provider_session_id: any;
|
|
30
|
+
cancelled: boolean;
|
|
31
|
+
error: any;
|
|
32
|
+
failureKind: string;
|
|
33
|
+
diagnostics: {
|
|
34
|
+
claude_error_code: any;
|
|
35
|
+
};
|
|
36
|
+
capabilitiesUsed: {
|
|
37
|
+
prompt_cache_active: any;
|
|
38
|
+
thinking_enabled: any;
|
|
39
|
+
structured_output_enforced: boolean;
|
|
40
|
+
subagent_invoked: any;
|
|
41
|
+
mcp_servers_used: any[];
|
|
42
|
+
native_subagents_used: any[];
|
|
43
|
+
tool_compaction_applied: boolean;
|
|
44
|
+
context_compaction_applied: any;
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
text: string;
|
|
48
|
+
structuredResult: any;
|
|
49
|
+
structuredResultSource: any;
|
|
50
|
+
events: any[];
|
|
51
|
+
usage: {};
|
|
52
|
+
durationMs: number;
|
|
53
|
+
numTurns: number;
|
|
54
|
+
model: any;
|
|
55
|
+
effort: any;
|
|
56
|
+
sdk: string;
|
|
57
|
+
cancelled: boolean;
|
|
58
|
+
error: string;
|
|
59
|
+
errorDetails: {
|
|
60
|
+
claude_error_code: string;
|
|
61
|
+
claude_error_category: string;
|
|
62
|
+
retryable: boolean;
|
|
63
|
+
};
|
|
64
|
+
failureKind: string;
|
|
65
|
+
providerSessionId: string;
|
|
66
|
+
runtimeWarnings: any[];
|
|
67
|
+
capabilitiesUsed: {
|
|
68
|
+
prompt_cache_active: any;
|
|
69
|
+
thinking_enabled: any;
|
|
70
|
+
structured_output_enforced: boolean;
|
|
71
|
+
subagent_invoked: any;
|
|
72
|
+
mcp_servers_used: any[];
|
|
73
|
+
native_subagents_used: any[];
|
|
74
|
+
tool_compaction_applied: boolean;
|
|
75
|
+
context_compaction_applied: any;
|
|
76
|
+
};
|
|
77
|
+
} | {
|
|
6
78
|
text: string;
|
|
7
79
|
structuredResult: any;
|
|
8
80
|
structuredResultSource: string;
|
|
@@ -22,18 +94,22 @@ export function generateClaudeResponse(systemPrompt: any, options: any): Promise
|
|
|
22
94
|
cancelled: boolean;
|
|
23
95
|
error: any;
|
|
24
96
|
errorDetails: {
|
|
25
|
-
claude_error_subtype:
|
|
97
|
+
claude_error_subtype: string;
|
|
26
98
|
last_text_excerpt: string;
|
|
27
|
-
last_tool_name:
|
|
99
|
+
last_tool_name: string;
|
|
28
100
|
had_partial_progress: boolean;
|
|
29
101
|
tool_results_seen: number;
|
|
30
102
|
turn_count: number;
|
|
31
103
|
max_turns_hit: boolean;
|
|
32
104
|
structured_output_retry_exhausted: boolean;
|
|
33
|
-
last_structured_output_rejection:
|
|
34
|
-
provider_session_id:
|
|
105
|
+
last_structured_output_rejection: string;
|
|
106
|
+
provider_session_id: string;
|
|
107
|
+
claude_error_code: string;
|
|
108
|
+
claude_error_category: any;
|
|
109
|
+
retryable: boolean;
|
|
110
|
+
request_id: any;
|
|
35
111
|
};
|
|
36
|
-
failureKind:
|
|
112
|
+
failureKind: any;
|
|
37
113
|
providerSessionId: string;
|
|
38
114
|
runtimeWarnings: {
|
|
39
115
|
warning_kind: string;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {{command?: string, args?: string[], cwd?: any, env?: any, onNotification?: (msg: any) => void}} [options]
|
|
2
|
+
* @param {{command?: string, args?: string[], cwd?: any, env?: any, redactionValues?: string[], onNotification?: (msg: any) => void, onServerRequest?: (msg: any) => Promise<any> | any, shutdownGraceMs?: number, killGraceMs?: number}} [options]
|
|
3
3
|
*/
|
|
4
|
-
export function createCodexAppServerClient({ command, args, cwd, env, onNotification, }?: {
|
|
4
|
+
export function createCodexAppServerClient({ command, args, cwd, env, redactionValues, onNotification, onServerRequest, shutdownGraceMs, killGraceMs, }?: {
|
|
5
5
|
command?: string;
|
|
6
6
|
args?: string[];
|
|
7
7
|
cwd?: any;
|
|
8
8
|
env?: any;
|
|
9
|
+
redactionValues?: string[];
|
|
9
10
|
onNotification?: (msg: any) => void;
|
|
11
|
+
onServerRequest?: (msg: any) => Promise<any> | any;
|
|
12
|
+
shutdownGraceMs?: number;
|
|
13
|
+
killGraceMs?: number;
|
|
10
14
|
}): {
|
|
11
15
|
request: (method: any, params: any, { timeoutMs }?: {
|
|
12
16
|
timeoutMs?: number;
|
|
13
17
|
}) => Promise<any>;
|
|
14
|
-
close: () => void
|
|
18
|
+
close: () => Promise<void>;
|
|
15
19
|
child: import("child_process").ChildProcessWithoutNullStreams;
|
|
16
20
|
closed: Promise<any>;
|
|
17
21
|
};
|
|
@@ -64,7 +68,7 @@ export function generateCodexAppResponse(systemPrompt: any, options?: {}): Promi
|
|
|
64
68
|
providerSessionId: any;
|
|
65
69
|
provider_session_id: any;
|
|
66
70
|
cancelled: boolean;
|
|
67
|
-
error:
|
|
71
|
+
error: string;
|
|
68
72
|
failureKind: string;
|
|
69
73
|
diagnostics: {
|
|
70
74
|
had_partial_progress?: boolean;
|
|
@@ -94,16 +98,16 @@ export function generateCodexAppResponse(systemPrompt: any, options?: {}): Promi
|
|
|
94
98
|
providerSessionId: any;
|
|
95
99
|
provider_session_id: any;
|
|
96
100
|
cancelled: boolean;
|
|
97
|
-
error:
|
|
101
|
+
error: string;
|
|
98
102
|
failureKind: string;
|
|
99
103
|
diagnostics: {
|
|
100
104
|
had_partial_progress?: boolean;
|
|
101
105
|
codex_error_code?: undefined;
|
|
102
106
|
} | {
|
|
103
107
|
had_partial_progress?: boolean;
|
|
104
|
-
stderr_tail?:
|
|
108
|
+
stderr_tail?: string;
|
|
105
109
|
codex_error_code: string;
|
|
106
|
-
codex_request_method:
|
|
110
|
+
codex_request_method: string;
|
|
107
111
|
codex_request_timeout_ms: any;
|
|
108
112
|
} | {
|
|
109
113
|
had_partial_progress?: boolean;
|