@mono-agent/agent-runtime 0.6.1 → 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.
Files changed (44) hide show
  1. package/README.md +36 -16
  2. package/package.json +14 -7
  3. package/src/agent/approval.js +52 -17
  4. package/src/agent/sandbox-seam.js +1 -0
  5. package/src/agent/tools/pi-bridge.js +15 -42
  6. package/src/agent/tools/shared/ripgrep.js +12 -8
  7. package/src/ai/file-change-stats.js +0 -21
  8. package/src/ai/index.js +8 -0
  9. package/src/ai/providers/claude-cli.js +109 -5
  10. package/src/ai/providers/claude-sandbox.js +71 -0
  11. package/src/ai/providers/claude-sdk-discovery-worker.js +53 -0
  12. package/src/ai/providers/claude-sdk-discovery.js +352 -0
  13. package/src/ai/providers/claude-sdk.js +315 -163
  14. package/src/ai/providers/codex-app.js +823 -78
  15. package/src/ai/providers/opencode-app.js +682 -96
  16. package/src/ai/providers/opencode-server.js +508 -0
  17. package/src/ai/providers/pi-native/stream-subscriber.js +9 -0
  18. package/src/ai/runtime/capabilities.js +12 -0
  19. package/src/ai/runtime/context-windows.js +8 -0
  20. package/src/ai/runtime/registry.js +8 -2
  21. package/src/ai/runtime/router.js +627 -29
  22. package/src/ai/streaming/codex-events.js +7 -15
  23. package/src/ai/types.js +29 -2
  24. package/src/index.js +6 -0
  25. package/src/runtime.js +17 -1
  26. package/types/agent/approval.d.ts +4 -7
  27. package/types/agent/sandbox-seam.d.ts +5 -0
  28. package/types/ai/backend.d.ts +16 -0
  29. package/types/ai/file-change-stats.d.ts +0 -24
  30. package/types/ai/index.d.ts +1 -0
  31. package/types/ai/providers/claude-cli.d.ts +116 -0
  32. package/types/ai/providers/claude-sandbox.d.ts +79 -0
  33. package/types/ai/providers/claude-sdk-discovery-worker.d.ts +1 -0
  34. package/types/ai/providers/claude-sdk-discovery.d.ts +97 -0
  35. package/types/ai/providers/claude-sdk.d.ts +81 -5
  36. package/types/ai/providers/codex-app.d.ts +11 -7
  37. package/types/ai/providers/opencode-app.d.ts +15 -16
  38. package/types/ai/providers/opencode-server.d.ts +20 -0
  39. package/types/ai/runtime/capabilities.d.ts +19 -0
  40. package/types/ai/runtime/context-windows.d.ts +1 -0
  41. package/types/ai/runtime/router.d.ts +24 -23
  42. package/types/ai/streaming/codex-events.d.ts +15 -6
  43. package/types/ai/types.d.ts +75 -2
  44. package/types/index.d.ts +1 -0
@@ -70,22 +70,14 @@ export function normalizeCodexItemEvent(raw, context = {}) {
70
70
  if (type === "file_change") {
71
71
  const id = itemId(item, "file_change");
72
72
  const payload = fileChangePayload(raw, item, context);
73
- if (!isCompleted(raw)) {
74
- return {
75
- type: "assistant",
76
- message: { content: [{ type: "tool_use", id, name: "file_edit", input: payload }] },
77
- };
78
- }
79
73
  return {
80
- type: "user",
81
- message: {
82
- content: [{
83
- type: "tool_result",
84
- tool_use_id: id,
85
- content: item.error || payload,
86
- is_error: itemFailed(item),
87
- }],
88
- },
74
+ type: "file_change",
75
+ id,
76
+ status: payload.status,
77
+ changes: payload.changes,
78
+ ...(payload.summary ? { summary: payload.summary } : {}),
79
+ ...(item.error ? { error: item.error } : {}),
80
+ is_error: itemFailed(item),
89
81
  };
90
82
  }
91
83
 
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 after the first.
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, pickDefined(next, TOOL_RUNTIME_KEYS));
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: any;
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
@@ -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
  };
@@ -49,27 +49,3 @@ export function createFileChangePayload(raw: any, { cwd, snapshots }?: {
49
49
  changes: any;
50
50
  status: any;
51
51
  };
52
- export function createFileEditToolUseEvent(id: any, payload: any): {
53
- type: string;
54
- message: {
55
- content: {
56
- type: string;
57
- id: any;
58
- name: string;
59
- input: any;
60
- }[];
61
- };
62
- };
63
- export function createFileEditToolResultEvent(id: any, payload: any, { isError }?: {
64
- isError?: boolean;
65
- }): {
66
- type: string;
67
- message: {
68
- content: {
69
- type: string;
70
- tool_use_id: any;
71
- content: any;
72
- is_error: boolean;
73
- }[];
74
- };
75
- };
@@ -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,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: any;
97
+ claude_error_subtype: string;
26
98
  last_text_excerpt: string;
27
- last_tool_name: any;
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: any;
34
- provider_session_id: any;
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: string;
112
+ failureKind: any;
37
113
  providerSessionId: string;
38
114
  runtimeWarnings: {
39
115
  warning_kind: string;