@mono-agent/agent-runtime 0.4.0 → 0.5.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 (119) hide show
  1. package/ARCHITECTURE.md +37 -16
  2. package/MIGRATION.md +185 -7
  3. package/README.md +24 -14
  4. package/package.json +103 -10
  5. package/src/agent/allowlists.js +3 -0
  6. package/src/agent/approval.js +3 -0
  7. package/src/agent/compaction.js +244 -1
  8. package/src/agent/prompt/skill-index.js +6 -0
  9. package/src/agent/sandbox-seam.js +227 -0
  10. package/src/agent/tool-bloat.js +8 -2
  11. package/src/agent/tools/bash.js +16 -8
  12. package/src/agent/tools/edit.js +7 -3
  13. package/src/agent/tools/glob.js +11 -5
  14. package/src/agent/tools/grep.js +11 -5
  15. package/src/agent/tools/pi-bridge.js +227 -45
  16. package/src/agent/tools/read.js +28 -3
  17. package/src/agent/tools/shared/output-truncation.js +8 -3
  18. package/src/agent/tools/shared/path-resolver.js +24 -18
  19. package/src/agent/tools/shared/ripgrep.js +33 -6
  20. package/src/agent/tools/shared/runtime-context.js +60 -50
  21. package/src/agent/tools/shared/tool-context.js +157 -0
  22. package/src/agent/tools/web-fetch.js +21 -10
  23. package/src/agent/tools/web-search.js +11 -4
  24. package/src/agent/tools/write.js +7 -3
  25. package/src/agent/transcript.js +16 -1
  26. package/src/ai/cost.js +128 -3
  27. package/src/ai/failure.js +96 -4
  28. package/src/ai/live-input-prompt.js +11 -1
  29. package/src/ai/providers/claude-cli.js +2 -2
  30. package/src/ai/providers/claude-sdk.js +55 -12
  31. package/src/ai/providers/codex-app.js +36 -23
  32. package/src/ai/providers/opencode-app.js +2 -2
  33. package/src/ai/providers/opencode-discovery.js +2 -2
  34. package/src/ai/providers/pi-events.js +5 -0
  35. package/src/ai/providers/pi-models.js +21 -4
  36. package/src/ai/providers/pi-native/compaction-driver.js +394 -0
  37. package/src/ai/providers/pi-native/result-builder.js +312 -0
  38. package/src/ai/providers/pi-native/session-lifecycle.js +438 -0
  39. package/src/ai/providers/pi-native/stream-subscriber.js +148 -0
  40. package/src/ai/providers/pi-native/structured-output.js +130 -0
  41. package/src/ai/providers/pi-native/turn-runner.js +278 -0
  42. package/src/ai/providers/pi-native.js +415 -1106
  43. package/src/ai/runtime/model-refs.js +30 -0
  44. package/src/ai/runtime/registry.js +29 -0
  45. package/src/ai/runtime/router.js +96 -12
  46. package/src/ai/runtime/session-liveness.js +110 -0
  47. package/src/ai/runtime/sessions.js +16 -0
  48. package/src/ai/types.js +252 -19
  49. package/src/index.js +1 -1
  50. package/src/pi-auth.js +147 -16
  51. package/src/runtime-brand.js +21 -1
  52. package/src/runtime.js +72 -8
  53. package/types/agent/allowlists.d.ts +25 -0
  54. package/types/agent/approval.d.ts +30 -0
  55. package/types/agent/compaction.d.ts +97 -0
  56. package/types/agent/index.d.ts +5 -0
  57. package/types/agent/prompt/skill-index.d.ts +19 -0
  58. package/types/agent/sandbox-seam.d.ts +148 -0
  59. package/types/agent/tool-bloat.d.ts +22 -0
  60. package/types/agent/tools/bash.d.ts +16 -0
  61. package/types/agent/tools/edit.d.ts +14 -0
  62. package/types/agent/tools/glob.d.ts +16 -0
  63. package/types/agent/tools/grep.d.ts +22 -0
  64. package/types/agent/tools/index.d.ts +10 -0
  65. package/types/agent/tools/pi-bridge.d.ts +144 -0
  66. package/types/agent/tools/read.d.ts +19 -0
  67. package/types/agent/tools/shared/constants.d.ts +13 -0
  68. package/types/agent/tools/shared/dedup.d.ts +8 -0
  69. package/types/agent/tools/shared/output-truncation.d.ts +22 -0
  70. package/types/agent/tools/shared/path-resolver.d.ts +6 -0
  71. package/types/agent/tools/shared/ripgrep.d.ts +38 -0
  72. package/types/agent/tools/shared/runtime-context.d.ts +27 -0
  73. package/types/agent/tools/shared/tool-context.d.ts +48 -0
  74. package/types/agent/tools/web-fetch.d.ts +13 -0
  75. package/types/agent/tools/web-search.d.ts +11 -0
  76. package/types/agent/tools/write.d.ts +12 -0
  77. package/types/agent/transcript.d.ts +45 -0
  78. package/types/ai/backend.d.ts +41 -0
  79. package/types/ai/cost.d.ts +96 -0
  80. package/types/ai/failure.d.ts +117 -0
  81. package/types/ai/file-change-stats.d.ts +75 -0
  82. package/types/ai/index.d.ts +7 -0
  83. package/types/ai/live-input-prompt.d.ts +6 -0
  84. package/types/ai/observer.d.ts +68 -0
  85. package/types/ai/providers/claude-cli.d.ts +211 -0
  86. package/types/ai/providers/claude-sdk.d.ts +66 -0
  87. package/types/ai/providers/claude-subagents.d.ts +2 -0
  88. package/types/ai/providers/codex-app.d.ts +151 -0
  89. package/types/ai/providers/opencode-app.d.ts +95 -0
  90. package/types/ai/providers/opencode-discovery.d.ts +4 -0
  91. package/types/ai/providers/pi-errors.d.ts +3 -0
  92. package/types/ai/providers/pi-events.d.ts +24 -0
  93. package/types/ai/providers/pi-messages.d.ts +5 -0
  94. package/types/ai/providers/pi-models.d.ts +57 -0
  95. package/types/ai/providers/pi-native/compaction-driver.d.ts +86 -0
  96. package/types/ai/providers/pi-native/result-builder.d.ts +168 -0
  97. package/types/ai/providers/pi-native/session-lifecycle.d.ts +62 -0
  98. package/types/ai/providers/pi-native/stream-subscriber.d.ts +50 -0
  99. package/types/ai/providers/pi-native/structured-output.d.ts +69 -0
  100. package/types/ai/providers/pi-native/turn-runner.d.ts +60 -0
  101. package/types/ai/providers/pi-native.d.ts +18 -0
  102. package/types/ai/registry.d.ts +1 -0
  103. package/types/ai/runtime/capabilities-used.d.ts +21 -0
  104. package/types/ai/runtime/capabilities.d.ts +33 -0
  105. package/types/ai/runtime/context-windows.d.ts +8 -0
  106. package/types/ai/runtime/fast-mode.d.ts +2 -0
  107. package/types/ai/runtime/model-refs.d.ts +35 -0
  108. package/types/ai/runtime/registry.d.ts +38 -0
  109. package/types/ai/runtime/router.d.ts +56 -0
  110. package/types/ai/runtime/session-liveness.d.ts +55 -0
  111. package/types/ai/runtime/sessions.d.ts +38 -0
  112. package/types/ai/streaming/codex-events.d.ts +30 -0
  113. package/types/ai/streaming/opencode-events.d.ts +41 -0
  114. package/types/ai/types.d.ts +702 -0
  115. package/types/index.d.ts +7 -0
  116. package/types/pi-auth.d.ts +28 -0
  117. package/types/runtime-brand.d.ts +30 -0
  118. package/types/runtime.d.ts +10 -0
  119. package/src/ai/providers/pi-sdk.js +0 -35
@@ -0,0 +1,75 @@
1
+ export function readFileChangeSnapshot(path: any): {
2
+ exists: boolean;
3
+ line_count: number;
4
+ size?: undefined;
5
+ unavailable_reason?: undefined;
6
+ content?: undefined;
7
+ } | {
8
+ exists: boolean;
9
+ size: number;
10
+ unavailable_reason: string;
11
+ line_count?: undefined;
12
+ content?: undefined;
13
+ } | {
14
+ exists: boolean;
15
+ size: number;
16
+ content: string;
17
+ line_count: number;
18
+ unavailable_reason?: undefined;
19
+ } | {
20
+ exists: boolean;
21
+ line_count: number;
22
+ unavailable_reason: any;
23
+ size?: undefined;
24
+ content?: undefined;
25
+ };
26
+ export function statsForCompletedChange(change: any, before: any, after: any): {
27
+ before_lines: number;
28
+ after_lines: number;
29
+ added_lines: number;
30
+ removed_lines: number;
31
+ changed_lines: number;
32
+ } | {
33
+ before_lines: any;
34
+ after_lines: any;
35
+ unavailable_reason: any;
36
+ };
37
+ export function fileChangeSummary(changes: any): {
38
+ files: any;
39
+ added_lines: any;
40
+ removed_lines: any;
41
+ changed_lines: any;
42
+ unavailable_count: any;
43
+ };
44
+ export function createFileChangePayload(raw: any, { cwd, snapshots }?: {
45
+ cwd?: string;
46
+ snapshots?: Map<any, any>;
47
+ }): {
48
+ summary?: any;
49
+ changes: any;
50
+ status: any;
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
+ };
@@ -0,0 +1,7 @@
1
+ export * from "./registry.js";
2
+ export * from "./runtime/model-refs.js";
3
+ export * from "./runtime/registry.js";
4
+ export { createSessionRegistry, disposeAllProviderSessions, disposeProviderSession } from "./runtime/sessions.js";
5
+ export { createMetricsObserver, createObserverHub } from "./observer.js";
6
+ export { generatePiNativeResponse, piNativeRuntimeBridge } from "./providers/pi-native.js";
7
+ export { buildCapabilitiesUsed, toolCompactionAppliedFromWarnings, UNKNOWN_CAPABILITY } from "./runtime/capabilities-used.js";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param {string} text
3
+ * @param {import('./types.js').RuntimePromptOverrides} [prompts]
4
+ * @returns {string}
5
+ */
6
+ export function formatLiveInputGuidance(text: string, prompts?: import("./types.js").RuntimePromptOverrides): string;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @typedef Observer
3
+ * @property {string=} name
4
+ * @property {(event: object) => void} recordEvent
5
+ * @property {(metric: object) => void=} recordMetric
6
+ * @property {() => (void | Promise<void>)=} flush
7
+ */
8
+ export function createObserverHub({ observers, onEvent }?: {
9
+ observers?: any[];
10
+ onEvent?: any;
11
+ }): {
12
+ emit: (event: any) => void;
13
+ recordMetric: (metric: any) => void;
14
+ flush: () => Promise<void>;
15
+ observers: () => any[];
16
+ };
17
+ export function createMetricsObserver({ name }?: {
18
+ name?: string;
19
+ }): {
20
+ name: string;
21
+ recordEvent: (event: any) => void;
22
+ recordMetric: () => void;
23
+ snapshot: () => {
24
+ events: {
25
+ total: number;
26
+ byType: any;
27
+ };
28
+ tokens: {
29
+ input: number;
30
+ output: number;
31
+ cacheReadTokens: number;
32
+ cacheCreationTokens: number;
33
+ };
34
+ cost: {
35
+ cumulativeUsd: number;
36
+ };
37
+ cache: {
38
+ hits: number;
39
+ misses: number;
40
+ hitRatio: number;
41
+ readTokensFromEvents: number;
42
+ };
43
+ tools: {
44
+ callsByName: any;
45
+ errorsByName: any;
46
+ };
47
+ errors: {
48
+ total: number;
49
+ byKind: any;
50
+ };
51
+ turns: {
52
+ count: number;
53
+ latencyMsP50: any;
54
+ latencyMsP95: any;
55
+ };
56
+ approvals: {
57
+ pending: number;
58
+ granted: number;
59
+ denied: number;
60
+ };
61
+ };
62
+ };
63
+ export type Observer = {
64
+ name?: string | undefined;
65
+ recordEvent: (event: object) => void;
66
+ recordMetric?: ((metric: object) => void) | undefined;
67
+ flush?: (() => (void | Promise<void>)) | undefined;
68
+ };
@@ -0,0 +1,211 @@
1
+ export function createThinkingBuffer(): {
2
+ isStreamShape: (raw: any) => boolean;
3
+ onStreamEvent: (raw: any) => void;
4
+ rehydrate: (assistantRaw: any) => any;
5
+ };
6
+ export function normalizeCliEvent(raw: any, context?: {}): any;
7
+ export function buildCliCommand({ sdk, model, effort, cwd, schemaPath, outputSchema, systemPrompt, prompt, mcpConfigPath, mcpServers, allowedTools, disallowedTools, permissionMode, maxTurns, skillDirs, resumeSessionId, nativeSubagents, contextWindow, }: {
8
+ sdk: any;
9
+ model: any;
10
+ effort: any;
11
+ cwd: any;
12
+ schemaPath: any;
13
+ outputSchema: any;
14
+ systemPrompt: any;
15
+ prompt: any;
16
+ mcpConfigPath: any;
17
+ mcpServers: any;
18
+ allowedTools: any;
19
+ disallowedTools: any;
20
+ permissionMode: any;
21
+ maxTurns: any;
22
+ skillDirs: any;
23
+ resumeSessionId: any;
24
+ nativeSubagents: any;
25
+ contextWindow: any;
26
+ }): {
27
+ command: string;
28
+ args: any[];
29
+ cwd: any;
30
+ };
31
+ export function generateCliResponse(systemPrompt: any, options?: {}): Promise<{
32
+ text: any;
33
+ structuredResult: undefined;
34
+ structuredResultSource: string;
35
+ events: any[];
36
+ usage: {
37
+ input_tokens: any;
38
+ output_tokens: any;
39
+ cache_read_tokens: any;
40
+ cache_creation_tokens: any;
41
+ cost_usd: number;
42
+ };
43
+ durationMs: number;
44
+ numTurns: number;
45
+ model: string;
46
+ effort: any;
47
+ sdk: any;
48
+ providerSessionId: any;
49
+ provider_session_id: any;
50
+ cancelled: boolean;
51
+ error: any;
52
+ failureKind: string;
53
+ stderrTail: string;
54
+ diagnostics: {
55
+ had_partial_progress?: boolean;
56
+ pi_error_code?: string;
57
+ };
58
+ capabilitiesUsed: {
59
+ prompt_cache_active: any;
60
+ thinking_enabled: any;
61
+ structured_output_enforced: boolean;
62
+ subagent_invoked: any;
63
+ mcp_servers_used: any[];
64
+ native_subagents_used: any[];
65
+ tool_compaction_applied: boolean;
66
+ context_compaction_applied: any;
67
+ };
68
+ } | {
69
+ text: any;
70
+ structuredResult: undefined;
71
+ structuredResultSource: string;
72
+ events: any[];
73
+ usage: {};
74
+ durationMs: number;
75
+ numTurns: number;
76
+ model: any;
77
+ effort: any;
78
+ sdk: any;
79
+ providerSessionId: any;
80
+ provider_session_id: any;
81
+ cancelled: boolean;
82
+ error: any;
83
+ failureKind: string;
84
+ stderrTail: string;
85
+ diagnostics: {
86
+ had_partial_progress?: boolean;
87
+ pi_error_code?: string;
88
+ };
89
+ capabilitiesUsed: {
90
+ prompt_cache_active: any;
91
+ thinking_enabled: any;
92
+ structured_output_enforced: boolean;
93
+ subagent_invoked: any;
94
+ mcp_servers_used: any[];
95
+ native_subagents_used: any[];
96
+ tool_compaction_applied: boolean;
97
+ context_compaction_applied: any;
98
+ };
99
+ }>;
100
+ export namespace claudeCodeBackend {
101
+ export let kind: string;
102
+ export namespace capabilities {
103
+ export let streaming: boolean;
104
+ export let structured_output: boolean;
105
+ export let supports_session_resume: boolean;
106
+ export let native_runtime_config: any;
107
+ export let supports_mcp: boolean;
108
+ export let supports_skills: boolean;
109
+ export let supports_builtin_tools: boolean;
110
+ export let supports_live_input: boolean;
111
+ export let supports_native_subagents: boolean;
112
+ let kind_1: string;
113
+ export { kind_1 as kind };
114
+ export let runtime: string;
115
+ }
116
+ export { generateCliResponse as execute };
117
+ }
118
+ export namespace codexCliBackend {
119
+ let kind_2: string;
120
+ export { kind_2 as kind };
121
+ export namespace capabilities_1 {
122
+ let kind_3: string;
123
+ export { kind_3 as kind };
124
+ let runtime_1: string;
125
+ export { runtime_1 as runtime };
126
+ }
127
+ export { capabilities_1 as capabilities };
128
+ export { generateCliResponse as execute };
129
+ }
130
+ export namespace claudeCodeRuntimeBridge {
131
+ export let id: string;
132
+ let kind_4: string;
133
+ export { kind_4 as kind };
134
+ export namespace capabilities_2 {
135
+ let kind_5: string;
136
+ export { kind_5 as kind };
137
+ let runtime_2: string;
138
+ export { runtime_2 as runtime };
139
+ }
140
+ export { capabilities_2 as capabilities };
141
+ export function supports(ref: any, options: any): boolean;
142
+ export function execute(systemPrompt: any, options: any): Promise<{
143
+ text: any;
144
+ structuredResult: undefined;
145
+ structuredResultSource: string;
146
+ events: any[];
147
+ usage: {
148
+ input_tokens: any;
149
+ output_tokens: any;
150
+ cache_read_tokens: any;
151
+ cache_creation_tokens: any;
152
+ cost_usd: number;
153
+ };
154
+ durationMs: number;
155
+ numTurns: number;
156
+ model: string;
157
+ effort: any;
158
+ sdk: any;
159
+ providerSessionId: any;
160
+ provider_session_id: any;
161
+ cancelled: boolean;
162
+ error: any;
163
+ failureKind: string;
164
+ stderrTail: string;
165
+ diagnostics: {
166
+ had_partial_progress?: boolean;
167
+ pi_error_code?: string;
168
+ };
169
+ capabilitiesUsed: {
170
+ prompt_cache_active: any;
171
+ thinking_enabled: any;
172
+ structured_output_enforced: boolean;
173
+ subagent_invoked: any;
174
+ mcp_servers_used: any[];
175
+ native_subagents_used: any[];
176
+ tool_compaction_applied: boolean;
177
+ context_compaction_applied: any;
178
+ };
179
+ } | {
180
+ text: any;
181
+ structuredResult: undefined;
182
+ structuredResultSource: string;
183
+ events: any[];
184
+ usage: {};
185
+ durationMs: number;
186
+ numTurns: number;
187
+ model: any;
188
+ effort: any;
189
+ sdk: any;
190
+ providerSessionId: any;
191
+ provider_session_id: any;
192
+ cancelled: boolean;
193
+ error: any;
194
+ failureKind: string;
195
+ stderrTail: string;
196
+ diagnostics: {
197
+ had_partial_progress?: boolean;
198
+ pi_error_code?: string;
199
+ };
200
+ capabilitiesUsed: {
201
+ prompt_cache_active: any;
202
+ thinking_enabled: any;
203
+ structured_output_enforced: boolean;
204
+ subagent_invoked: any;
205
+ mcp_servers_used: any[];
206
+ native_subagents_used: any[];
207
+ tool_compaction_applied: boolean;
208
+ context_compaction_applied: any;
209
+ };
210
+ }>;
211
+ }
@@ -0,0 +1,66 @@
1
+ export function toolPayloadLimit(options: any): {
2
+ bytes: number;
3
+ usedSettings: boolean;
4
+ };
5
+ export function generateClaudeResponse(systemPrompt: any, options: any): Promise<{
6
+ text: string;
7
+ structuredResult: any;
8
+ structuredResultSource: string;
9
+ events: any[];
10
+ usage: {
11
+ input_tokens: any;
12
+ output_tokens: any;
13
+ cache_read_tokens: any;
14
+ cache_creation_tokens: any;
15
+ cost_usd: number;
16
+ };
17
+ durationMs: number;
18
+ numTurns: number;
19
+ model: any;
20
+ effort: any;
21
+ sdk: string;
22
+ cancelled: boolean;
23
+ error: any;
24
+ errorDetails: {
25
+ claude_error_subtype: any;
26
+ last_text_excerpt: string;
27
+ last_tool_name: any;
28
+ had_partial_progress: boolean;
29
+ tool_results_seen: number;
30
+ turn_count: number;
31
+ max_turns_hit: boolean;
32
+ structured_output_retry_exhausted: boolean;
33
+ last_structured_output_rejection: any;
34
+ provider_session_id: any;
35
+ };
36
+ failureKind: string;
37
+ providerSessionId: string;
38
+ runtimeWarnings: {
39
+ warning_kind: string;
40
+ message: any;
41
+ }[];
42
+ capabilitiesUsed: {
43
+ prompt_cache_active: any;
44
+ thinking_enabled: any;
45
+ structured_output_enforced: boolean;
46
+ subagent_invoked: any;
47
+ mcp_servers_used: any[];
48
+ native_subagents_used: any[];
49
+ tool_compaction_applied: boolean;
50
+ context_compaction_applied: any;
51
+ };
52
+ }>;
53
+ export namespace claudeSdkBackend {
54
+ export let kind: string;
55
+ export let capabilities: any;
56
+ export { generateClaudeResponse as execute };
57
+ }
58
+ export namespace claudeRuntimeBridge {
59
+ export let id: string;
60
+ let kind_1: string;
61
+ export { kind_1 as kind };
62
+ let capabilities_1: any;
63
+ export { capabilities_1 as capabilities };
64
+ export function supports(ref: any): boolean;
65
+ export { generateClaudeResponse as execute };
66
+ }
@@ -0,0 +1,2 @@
1
+ export function claudeNativeAgentDefinitions(nativeSubagents: any): {};
2
+ export function claudeToolsWithNativeSubagents(allowedTools: any, nativeSubagents: any): any;
@@ -0,0 +1,151 @@
1
+ /**
2
+ * @param {{command?: string, args?: string[], cwd?: any, env?: any, onNotification?: (msg: any) => void}} [options]
3
+ */
4
+ export function createCodexAppServerClient({ command, args, cwd, env, onNotification, }?: {
5
+ command?: string;
6
+ args?: string[];
7
+ cwd?: any;
8
+ env?: any;
9
+ onNotification?: (msg: any) => void;
10
+ }): {
11
+ request: (method: any, params: any, { timeoutMs }?: {
12
+ timeoutMs?: number;
13
+ }) => Promise<any>;
14
+ close: () => void;
15
+ child: import("child_process").ChildProcessWithoutNullStreams;
16
+ closed: Promise<any>;
17
+ };
18
+ export function generateCodexAppResponse(systemPrompt: any, options?: {}): Promise<{
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: string;
29
+ providerSessionId: any;
30
+ provider_session_id: any;
31
+ cancelled: boolean;
32
+ error: any;
33
+ failureKind: any;
34
+ diagnostics: {
35
+ codex_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
+ text: any;
49
+ structuredResult: any;
50
+ structuredResultSource: any;
51
+ events: any[];
52
+ usage: {
53
+ input_tokens: any;
54
+ output_tokens: any;
55
+ cache_read_tokens: any;
56
+ cache_creation_tokens: any;
57
+ cost_usd: number;
58
+ };
59
+ durationMs: number;
60
+ numTurns: number;
61
+ model: string;
62
+ effort: any;
63
+ sdk: string;
64
+ providerSessionId: any;
65
+ provider_session_id: any;
66
+ cancelled: boolean;
67
+ error: any;
68
+ failureKind: string;
69
+ diagnostics: {
70
+ had_partial_progress?: boolean;
71
+ codex_error_code?: string;
72
+ };
73
+ capabilitiesUsed: {
74
+ prompt_cache_active: any;
75
+ thinking_enabled: any;
76
+ structured_output_enforced: boolean;
77
+ subagent_invoked: any;
78
+ mcp_servers_used: any[];
79
+ native_subagents_used: any[];
80
+ tool_compaction_applied: boolean;
81
+ context_compaction_applied: any;
82
+ };
83
+ } | {
84
+ text: any;
85
+ structuredResult: any;
86
+ structuredResultSource: any;
87
+ events: any[];
88
+ usage: {};
89
+ durationMs: number;
90
+ numTurns: number;
91
+ model: any;
92
+ effort: any;
93
+ sdk: string;
94
+ providerSessionId: any;
95
+ provider_session_id: any;
96
+ cancelled: boolean;
97
+ error: any;
98
+ failureKind: string;
99
+ diagnostics: {
100
+ had_partial_progress?: boolean;
101
+ codex_error_code?: undefined;
102
+ } | {
103
+ had_partial_progress?: boolean;
104
+ stderr_tail?: any;
105
+ codex_error_code: string;
106
+ codex_request_method: any;
107
+ codex_request_timeout_ms: any;
108
+ } | {
109
+ had_partial_progress?: boolean;
110
+ codex_error_code: string;
111
+ };
112
+ capabilitiesUsed: {
113
+ prompt_cache_active: any;
114
+ thinking_enabled: any;
115
+ structured_output_enforced: boolean;
116
+ subagent_invoked: any;
117
+ mcp_servers_used: any[];
118
+ native_subagents_used: any[];
119
+ tool_compaction_applied: boolean;
120
+ context_compaction_applied: any;
121
+ };
122
+ }>;
123
+ export namespace codexAppBackend {
124
+ export let kind: string;
125
+ export { CODEX_APP_CAPABILITIES as capabilities };
126
+ export { generateCodexAppResponse as execute };
127
+ }
128
+ export namespace codexAppRuntimeBridge {
129
+ export let id: string;
130
+ let kind_1: string;
131
+ export { kind_1 as kind };
132
+ export { CODEX_APP_CAPABILITIES as capabilities };
133
+ export function supports(ref: any, options: any): boolean;
134
+ export { generateCodexAppResponse as execute };
135
+ }
136
+ declare namespace CODEX_APP_CAPABILITIES {
137
+ let kind_2: string;
138
+ export { kind_2 as kind };
139
+ export let runtime: string;
140
+ export let streaming: boolean;
141
+ export let structured_output: boolean;
142
+ export let supports_session_resume: boolean;
143
+ export let native_runtime_config: any;
144
+ export let supports_mcp: boolean;
145
+ export let supports_skills: boolean;
146
+ export let supports_builtin_tools: boolean;
147
+ export let supports_live_input: boolean;
148
+ export let supports_native_subagents: boolean;
149
+ export let supports_fast_mode: boolean;
150
+ }
151
+ export {};
@@ -0,0 +1,95 @@
1
+ export function opencodeMcpConfig(mcpServers?: {}): {};
2
+ export function mapErrorFailureKind(error: any): "usage_limit" | "provider_unavailable" | "cancelled";
3
+ export function mapSpawnFailureKind(err: any): "spawn" | "provider_unavailable";
4
+ export namespace opencodeAppRuntimeBridge {
5
+ export let id: string;
6
+ export let kind: string;
7
+ export { OPENCODE_APP_CAPABILITIES as capabilities };
8
+ export function supports(ref: any, options: any): boolean;
9
+ export { generateOpencodeAppResponse as execute };
10
+ }
11
+ declare namespace OPENCODE_APP_CAPABILITIES {
12
+ let kind_1: string;
13
+ export { kind_1 as kind };
14
+ export let runtime: string;
15
+ export let streaming: boolean;
16
+ export let structured_output: boolean;
17
+ export let supports_session_resume: boolean;
18
+ export let native_runtime_config: any;
19
+ export let supports_mcp: boolean;
20
+ export let supports_skills: boolean;
21
+ export let supports_builtin_tools: boolean;
22
+ export let supports_live_input: boolean;
23
+ export let supports_native_subagents: boolean;
24
+ export let supports_fast_mode: boolean;
25
+ }
26
+ declare function generateOpencodeAppResponse(systemPrompt: any, options?: {}): Promise<{
27
+ text: string;
28
+ structuredResult: any;
29
+ structuredResultSource: any;
30
+ events: any[];
31
+ usage: {
32
+ cost_usd: any;
33
+ input_tokens?: any;
34
+ output_tokens?: any;
35
+ cache_read_tokens?: any;
36
+ cache_creation_tokens?: any;
37
+ };
38
+ durationMs: number;
39
+ numTurns: number;
40
+ model: any;
41
+ effort: any;
42
+ sdk: string;
43
+ providerSessionId: any;
44
+ provider_session_id: any;
45
+ cancelled: boolean;
46
+ error: any;
47
+ failureKind: string;
48
+ diagnostics: {};
49
+ capabilitiesUsed: {
50
+ prompt_cache_active: any;
51
+ thinking_enabled: any;
52
+ structured_output_enforced: boolean;
53
+ subagent_invoked: any;
54
+ mcp_servers_used: any[];
55
+ native_subagents_used: any[];
56
+ tool_compaction_applied: boolean;
57
+ context_compaction_applied: any;
58
+ };
59
+ } | {
60
+ text: string;
61
+ structuredResult: any;
62
+ structuredResultSource: any;
63
+ events: any[];
64
+ usage: {
65
+ cost_usd: number;
66
+ input_tokens: any;
67
+ output_tokens: any;
68
+ cache_read_tokens: any;
69
+ cache_creation_tokens: any;
70
+ };
71
+ durationMs: number;
72
+ numTurns: number;
73
+ model: any;
74
+ effort: any;
75
+ sdk: string;
76
+ providerSessionId: any;
77
+ provider_session_id: any;
78
+ cancelled: boolean;
79
+ error: any;
80
+ failureKind: string;
81
+ diagnostics: {
82
+ had_partial_progress?: boolean;
83
+ };
84
+ capabilitiesUsed: {
85
+ prompt_cache_active: any;
86
+ thinking_enabled: any;
87
+ structured_output_enforced: boolean;
88
+ subagent_invoked: any;
89
+ mcp_servers_used: any[];
90
+ native_subagents_used: any[];
91
+ tool_compaction_applied: boolean;
92
+ context_compaction_applied: any;
93
+ };
94
+ }>;
95
+ export {};
@@ -0,0 +1,4 @@
1
+ export function discoverOpencodeProviders({ createServer }?: {
2
+ createServer?: typeof createOpencode;
3
+ }): Promise<any>;
4
+ import { createOpencode } from "@opencode-ai/sdk";
@@ -0,0 +1,3 @@
1
+ export function normalizePiErrorMessage(message: any): any;
2
+ export function isContextLimitError(message: any): boolean;
3
+ export function parseContextLimitFromError(message: any): number;