@rynx-ai/runtime 0.1.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 (69) hide show
  1. package/dist/claude/executor.d.ts +17 -0
  2. package/dist/claude/executor.js +28 -0
  3. package/dist/claude/models.d.ts +10 -0
  4. package/dist/claude/models.js +33 -0
  5. package/dist/claude/native-bridge.d.ts +133 -0
  6. package/dist/claude/native-bridge.js +299 -0
  7. package/dist/claude/native-hook-main.d.ts +2 -0
  8. package/dist/claude/native-hook-main.js +74 -0
  9. package/dist/claude/native-hooks.d.ts +41 -0
  10. package/dist/claude/native-hooks.js +73 -0
  11. package/dist/claude/native-integration.d.ts +213 -0
  12. package/dist/claude/native-integration.js +665 -0
  13. package/dist/claude/native-message-display-main.d.ts +2 -0
  14. package/dist/claude/native-message-display-main.js +51 -0
  15. package/dist/claude/native-status-main.d.ts +2 -0
  16. package/dist/claude/native-status-main.js +105 -0
  17. package/dist/claude/status.d.ts +23 -0
  18. package/dist/claude/status.js +118 -0
  19. package/dist/claude/transcript.d.ts +79 -0
  20. package/dist/claude/transcript.js +272 -0
  21. package/dist/claude/trust.d.ts +6 -0
  22. package/dist/claude/trust.js +85 -0
  23. package/dist/codex/rollout-synth.d.ts +37 -0
  24. package/dist/codex/rollout-synth.js +212 -0
  25. package/dist/codex-app-server/client.d.ts +138 -0
  26. package/dist/codex-app-server/client.js +341 -0
  27. package/dist/codex-app-server/forwarder.d.ts +92 -0
  28. package/dist/codex-app-server/forwarder.js +188 -0
  29. package/dist/codex-app-server/mapping.d.ts +19 -0
  30. package/dist/codex-app-server/mapping.js +189 -0
  31. package/dist/codex-app-server/protocol.d.ts +472 -0
  32. package/dist/codex-app-server/protocol.js +12 -0
  33. package/dist/codex-app-server/transport.d.ts +139 -0
  34. package/dist/codex-app-server/transport.js +422 -0
  35. package/dist/codex-app-server/ws-channel.d.ts +72 -0
  36. package/dist/codex-app-server/ws-channel.js +233 -0
  37. package/dist/codex-child-env.d.ts +1 -0
  38. package/dist/codex-child-env.js +27 -0
  39. package/dist/codex-home.d.ts +47 -0
  40. package/dist/codex-home.js +135 -0
  41. package/dist/codex-session-store.d.ts +42 -0
  42. package/dist/codex-session-store.js +126 -0
  43. package/dist/host.d.ts +324 -0
  44. package/dist/host.js +1323 -0
  45. package/dist/index.d.ts +18 -0
  46. package/dist/index.js +17 -0
  47. package/dist/models-catalog.d.ts +18 -0
  48. package/dist/models-catalog.js +27 -0
  49. package/dist/runner/child.d.ts +58 -0
  50. package/dist/runner/child.js +268 -0
  51. package/dist/runner/manager.d.ts +175 -0
  52. package/dist/runner/manager.js +458 -0
  53. package/dist/runner/protocol.d.ts +195 -0
  54. package/dist/runner/protocol.js +41 -0
  55. package/dist/runner/transport.d.ts +36 -0
  56. package/dist/runner/transport.js +72 -0
  57. package/dist/runner-main.d.ts +2 -0
  58. package/dist/runner-main.js +61 -0
  59. package/dist/runtime-status.d.ts +16 -0
  60. package/dist/runtime-status.js +80 -0
  61. package/dist/terminal/claude-tui.d.ts +27 -0
  62. package/dist/terminal/claude-tui.js +13 -0
  63. package/dist/terminal/codex-tui.d.ts +54 -0
  64. package/dist/terminal/codex-tui.js +26 -0
  65. package/dist/terminal/registry.d.ts +42 -0
  66. package/dist/terminal/registry.js +70 -0
  67. package/dist/terminal/tmux.d.ts +150 -0
  68. package/dist/terminal/tmux.js +364 -0
  69. package/package.json +32 -0
@@ -0,0 +1,189 @@
1
+ /** Map one thread item (`item/started` | `item/completed`) to events. */
2
+ export function mapCodexItem(method, item) {
3
+ const events = [];
4
+ const isStart = method === "item/started";
5
+ const isEnd = method === "item/completed";
6
+ switch (item.type) {
7
+ case "commandExecution": {
8
+ const commandItem = item;
9
+ events.push({
10
+ type: "tool",
11
+ event: isStart ? "on_tool_start" : "on_tool_end",
12
+ name: "command_execution",
13
+ input: isStart
14
+ ? { id: commandItem.id, command: commandItem.command, cwd: commandItem.cwd }
15
+ : undefined,
16
+ output: isEnd
17
+ ? {
18
+ id: commandItem.id,
19
+ command: commandItem.command,
20
+ status: commandItem.status,
21
+ aggregatedOutput: commandItem.aggregatedOutput ?? null,
22
+ exitCode: commandItem.exitCode ?? null,
23
+ }
24
+ : undefined,
25
+ data: { method, item },
26
+ });
27
+ return { events };
28
+ }
29
+ case "fileChange": {
30
+ events.push({
31
+ type: "tool",
32
+ event: isStart ? "on_tool_start" : "on_tool_end",
33
+ name: "file_change",
34
+ input: isStart ? { id: item.id } : undefined,
35
+ output: isEnd
36
+ ? {
37
+ id: item.id,
38
+ changes: item.changes,
39
+ status: item.status,
40
+ }
41
+ : undefined,
42
+ data: { method, item },
43
+ });
44
+ return { events };
45
+ }
46
+ case "mcpToolCall": {
47
+ const mcp = item;
48
+ events.push({
49
+ type: "tool",
50
+ event: isStart ? "on_tool_start" : "on_tool_end",
51
+ name: `mcp:${mcp.server ?? "unknown"}:${mcp.tool ?? "unknown"}`,
52
+ input: isStart ? { id: mcp.id, arguments: mcp.arguments } : undefined,
53
+ output: isEnd ? { id: mcp.id, status: mcp.status, result: mcp.result } : undefined,
54
+ data: { method, item },
55
+ });
56
+ return { events };
57
+ }
58
+ case "dynamicToolCall": {
59
+ const dyn = item;
60
+ events.push({
61
+ type: "tool",
62
+ event: isStart ? "on_tool_start" : "on_tool_end",
63
+ name: `dynamic:${dyn.namespace ?? "default"}:${dyn.tool ?? "unknown"}`,
64
+ input: isStart ? { id: dyn.id, arguments: dyn.arguments } : undefined,
65
+ output: isEnd ? { id: dyn.id, status: dyn.status, success: dyn.success } : undefined,
66
+ data: { method, item },
67
+ });
68
+ return { events };
69
+ }
70
+ case "webSearch": {
71
+ events.push({
72
+ type: "tool",
73
+ event: isStart ? "on_tool_start" : "on_tool_end",
74
+ name: "web_search",
75
+ input: isStart
76
+ ? { id: item.id, query: item.query }
77
+ : undefined,
78
+ output: isEnd ? { id: item.id } : undefined,
79
+ data: { method, item },
80
+ });
81
+ return { events };
82
+ }
83
+ case "agentMessage": {
84
+ const text = item.text?.trim() ?? "";
85
+ if (isEnd && text) {
86
+ events.push({ type: "message_completed", itemId: item.id, text });
87
+ return { events, finalText: text };
88
+ }
89
+ return { events };
90
+ }
91
+ case "plan": {
92
+ events.push({ type: "runtime_debug", channel: "codexEvent", data: { method, item } });
93
+ return { events };
94
+ }
95
+ case "reasoning": {
96
+ events.push({
97
+ type: "reasoning_completed",
98
+ itemId: item.id,
99
+ summary: item.summary ?? [],
100
+ });
101
+ return { events };
102
+ }
103
+ default:
104
+ events.push({ type: "runtime_debug", channel: "codexEvent", data: { method, item } });
105
+ return { events };
106
+ }
107
+ }
108
+ /** Map one codex app-server notification to events (+ turn/usage/error signals). */
109
+ export function mapCodexNotification(method, params) {
110
+ const events = [];
111
+ const typed = { method, params };
112
+ switch (typed.method) {
113
+ case "thread/started":
114
+ return { events };
115
+ case "turn/started":
116
+ return { events };
117
+ case "turn/completed": {
118
+ const turnPayload = typed.params?.turn;
119
+ if (turnPayload?.status === "failed" && turnPayload.error?.message) {
120
+ return { events, fatalError: new Error(turnPayload.error.message), turnCompleted: true };
121
+ }
122
+ return { events, turnCompleted: true };
123
+ }
124
+ case "turn/plan/updated": {
125
+ const planParams = typed.params;
126
+ events.push({ type: "plan", steps: planParams.plan ?? [] });
127
+ return { events };
128
+ }
129
+ case "turn/diff/updated": {
130
+ const diffParams = typed.params;
131
+ events.push({ type: "turn_diff", diff: diffParams.diff ?? diffParams.unifiedDiff ?? "" });
132
+ return { events };
133
+ }
134
+ case "item/started":
135
+ case "item/completed": {
136
+ const item = typed.params.item;
137
+ return item ? mapCodexItem(method, item) : { events };
138
+ }
139
+ case "item/agentMessage/delta": {
140
+ const delta = typed.params.delta ?? "";
141
+ if (delta) {
142
+ events.push({
143
+ type: "token",
144
+ text: delta,
145
+ metadata: { source: "app_server", itemId: typed.params.itemId },
146
+ });
147
+ }
148
+ return { events };
149
+ }
150
+ case "item/reasoning/summaryTextDelta":
151
+ case "item/reasoning/textDelta": {
152
+ const p = typed.params;
153
+ events.push({
154
+ type: "reasoning_delta",
155
+ text: p.delta ?? "",
156
+ summaryIndex: p.summaryIndex ?? 0,
157
+ itemId: p.itemId,
158
+ });
159
+ return { events };
160
+ }
161
+ case "item/commandExecution/outputDelta": {
162
+ const p = typed.params;
163
+ const delta = p.delta ?? "";
164
+ if (delta && p.itemId)
165
+ events.push({ type: "tool_output_delta", callId: p.itemId, delta });
166
+ return { events };
167
+ }
168
+ case "item/fileChange/patchUpdated": {
169
+ const p = typed.params;
170
+ events.push({ type: "file_change", changes: p.changes ?? [] });
171
+ return { events };
172
+ }
173
+ case "thread/tokenUsage/updated": {
174
+ const p = typed.params;
175
+ return { events, usage: p.tokenUsage };
176
+ }
177
+ case "error": {
178
+ const p = typed.params;
179
+ if (p.willRetry) {
180
+ events.push({ type: "runtime_debug", channel: "codexEvent", data: { method, params } });
181
+ return { events };
182
+ }
183
+ return { events, fatalError: new Error(p.error?.message ?? "Codex emitted an error notification") };
184
+ }
185
+ default:
186
+ events.push({ type: "runtime_debug", channel: "codexEvent", data: { method, params } });
187
+ return { events };
188
+ }
189
+ }
@@ -0,0 +1,472 @@
1
+ /**
2
+ * Hand-curated subset of the Codex App Server JSON-RPC protocol.
3
+ *
4
+ * Source of truth: `codex app-server generate-ts --out <dir>` produces the
5
+ * full TypeScript bindings (~150 files). This file only mirrors the shapes
6
+ * the bridge consumes today. Unused notification / request payloads are
7
+ * captured with a permissive `Record<string, unknown>` so future Codex
8
+ * releases keep parsing without code changes here.
9
+ *
10
+ * Re-generate the upstream bindings periodically to spot field renames.
11
+ */
12
+ export type RequestId = string | number;
13
+ export interface JsonRpcRequestEnvelope<TParams = unknown> {
14
+ jsonrpc?: "2.0";
15
+ id: RequestId;
16
+ method: string;
17
+ params?: TParams;
18
+ }
19
+ export interface JsonRpcSuccessEnvelope<TResult = unknown> {
20
+ jsonrpc?: "2.0";
21
+ id: RequestId;
22
+ result: TResult;
23
+ }
24
+ export interface JsonRpcErrorEnvelope {
25
+ jsonrpc?: "2.0";
26
+ id: RequestId;
27
+ error: {
28
+ code: number;
29
+ message: string;
30
+ data?: unknown;
31
+ };
32
+ }
33
+ export interface JsonRpcNotificationEnvelope<TParams = unknown> {
34
+ jsonrpc?: "2.0";
35
+ method: string;
36
+ params?: TParams;
37
+ }
38
+ export type JsonRpcIncoming = JsonRpcSuccessEnvelope | JsonRpcErrorEnvelope | JsonRpcRequestEnvelope | JsonRpcNotificationEnvelope;
39
+ export interface ClientInfo {
40
+ name: string;
41
+ title?: string | null;
42
+ version: string;
43
+ }
44
+ export interface InitializeResponse {
45
+ userAgent: string;
46
+ codexHome: string;
47
+ platformFamily: string;
48
+ platformOs: string;
49
+ }
50
+ export interface GetAuthStatusParams {
51
+ includeToken?: boolean;
52
+ refreshToken?: boolean;
53
+ }
54
+ export interface GetAuthStatusResponse {
55
+ authMethod: "chatgpt" | "apikey" | string;
56
+ authToken: string | null;
57
+ requiresOpenaiAuth: boolean;
58
+ }
59
+ export type AskForApproval = "untrusted" | "on-failure" | "on-request" | "never";
60
+ export type SandboxMode = "read-only" | "workspace-write" | "danger-full-access";
61
+ export type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh";
62
+ export interface ThreadStartParams {
63
+ model?: string | null;
64
+ modelProvider?: string | null;
65
+ cwd?: string | null;
66
+ approvalPolicy?: AskForApproval | null;
67
+ sandbox?: SandboxMode | null;
68
+ config?: Record<string, unknown> | null;
69
+ baseInstructions?: string | null;
70
+ developerInstructions?: string | null;
71
+ ephemeral?: boolean | null;
72
+ }
73
+ export interface ThreadResumeParams extends ThreadStartParams {
74
+ threadId: string;
75
+ /** When true, the resume response omits the thread's `turns` backlog (used to
76
+ * SUBSCRIBE without re-replaying history). When false/absent, the response
77
+ * carries `thread.turns[].items[]` — the backfill the forwarder replays for a
78
+ * fresh thread's first turn (omnigent's `_replay_resume_response`). */
79
+ excludeTurns?: boolean;
80
+ }
81
+ /** One turn in a resumed thread's backlog (`thread/resume` response). */
82
+ export interface ResumedTurn {
83
+ id?: string;
84
+ turnId?: string;
85
+ items?: ThreadItem[];
86
+ }
87
+ /** The `thread` object a `thread/resume` response carries (id + optional backlog). */
88
+ export interface ResumedThread {
89
+ id: string;
90
+ turns?: ResumedTurn[];
91
+ [key: string]: unknown;
92
+ }
93
+ export interface ThreadDescriptor {
94
+ id: string;
95
+ cwd: string;
96
+ modelProvider?: string;
97
+ status?: string;
98
+ [key: string]: unknown;
99
+ }
100
+ export type UserInput = {
101
+ type: "text";
102
+ text: string;
103
+ text_elements?: unknown[];
104
+ } | {
105
+ type: "image";
106
+ url: string;
107
+ } | {
108
+ type: "localImage";
109
+ path: string;
110
+ };
111
+ export interface TurnStartParams {
112
+ threadId: string;
113
+ input: UserInput[];
114
+ cwd?: string | null;
115
+ approvalPolicy?: AskForApproval | null;
116
+ model?: string | null;
117
+ effort?: ReasoningEffort | null;
118
+ }
119
+ export interface TurnInterruptParams {
120
+ threadId: string;
121
+ turnId: string;
122
+ }
123
+ export interface TurnSteerParams {
124
+ threadId: string;
125
+ /**
126
+ * Active turn id precondition. `turn/steer` fails if it does not match the
127
+ * currently running turn (e.g. the turn already finished).
128
+ */
129
+ expectedTurnId: string;
130
+ input: UserInput[];
131
+ }
132
+ export type TurnStatus = "completed" | "interrupted" | "failed" | "inProgress";
133
+ export interface TurnPlanStep {
134
+ step: string;
135
+ status: "pending" | "inProgress" | "completed";
136
+ }
137
+ export type CommandExecutionStatus = "inProgress" | "completed" | "failed" | "declined";
138
+ export type PatchApplyStatus = "inProgress" | "completed" | "failed" | "declined";
139
+ export interface ThreadItemBase {
140
+ id: string;
141
+ type: string;
142
+ }
143
+ export interface UserMessageItem extends ThreadItemBase {
144
+ type: "userMessage";
145
+ content: UserInput[];
146
+ }
147
+ export interface AgentMessageItem extends ThreadItemBase {
148
+ type: "agentMessage";
149
+ text: string;
150
+ phase?: string | null;
151
+ }
152
+ export interface ReasoningItem extends ThreadItemBase {
153
+ type: "reasoning";
154
+ summary: string[];
155
+ content: string[];
156
+ }
157
+ export interface PlanItem extends ThreadItemBase {
158
+ type: "plan";
159
+ text: string;
160
+ }
161
+ export interface CommandExecutionItem extends ThreadItemBase {
162
+ type: "commandExecution";
163
+ command: string;
164
+ cwd: string;
165
+ status: CommandExecutionStatus;
166
+ aggregatedOutput: string | null;
167
+ exitCode: number | null;
168
+ durationMs: number | null;
169
+ }
170
+ export interface FileChangeItem extends ThreadItemBase {
171
+ type: "fileChange";
172
+ changes: Array<{
173
+ path: string;
174
+ kind: string;
175
+ diff: string;
176
+ }>;
177
+ status: PatchApplyStatus;
178
+ }
179
+ export interface McpToolCallItem extends ThreadItemBase {
180
+ type: "mcpToolCall";
181
+ server: string;
182
+ tool: string;
183
+ status: "inProgress" | "completed" | "failed";
184
+ arguments: unknown;
185
+ result?: unknown;
186
+ error?: unknown;
187
+ durationMs?: number | null;
188
+ }
189
+ export interface DynamicToolCallItem extends ThreadItemBase {
190
+ type: "dynamicToolCall";
191
+ namespace: string | null;
192
+ tool: string;
193
+ arguments: unknown;
194
+ status: "inProgress" | "completed" | "failed";
195
+ success?: boolean | null;
196
+ }
197
+ export interface WebSearchItem extends ThreadItemBase {
198
+ type: "webSearch";
199
+ query: string;
200
+ }
201
+ export type ThreadItem = UserMessageItem | AgentMessageItem | ReasoningItem | PlanItem | CommandExecutionItem | FileChangeItem | McpToolCallItem | DynamicToolCallItem | WebSearchItem | (ThreadItemBase & Record<string, unknown>);
202
+ export interface ThreadSummary {
203
+ id?: string;
204
+ threadId?: string;
205
+ name?: string | null;
206
+ preview?: string | null;
207
+ cwd?: string | null;
208
+ createdAt?: string | number | null;
209
+ updatedAt?: string | number | null;
210
+ [key: string]: unknown;
211
+ }
212
+ export interface ThreadListParams {
213
+ cursor?: string | null;
214
+ limit?: number | null;
215
+ sortKey?: string | null;
216
+ sortDirection?: string | null;
217
+ archived?: boolean | null;
218
+ }
219
+ export interface ThreadListResponse {
220
+ data: ThreadSummary[];
221
+ nextCursor?: string | null;
222
+ [key: string]: unknown;
223
+ }
224
+ export interface ThreadForkParams {
225
+ threadId: string;
226
+ path?: string | null;
227
+ model?: string | null;
228
+ modelProvider?: string | null;
229
+ cwd?: string | null;
230
+ approvalPolicy?: AskForApproval | null;
231
+ sandbox?: SandboxMode | null;
232
+ }
233
+ export interface ThreadSettingsUpdateParams {
234
+ threadId: string;
235
+ cwd?: string | null;
236
+ approvalPolicy?: AskForApproval | null;
237
+ sandboxPolicy?: Record<string, unknown> | null;
238
+ /** Named permissions profile id; cannot be combined with `sandboxPolicy`. */
239
+ permissions?: string | null;
240
+ model?: string | null;
241
+ serviceTier?: string | null;
242
+ effort?: ReasoningEffort | null;
243
+ summary?: string | null;
244
+ collaborationMode?: Record<string, unknown> | null;
245
+ personality?: string | null;
246
+ }
247
+ export interface ModelListParams {
248
+ cursor?: string | null;
249
+ limit?: number | null;
250
+ }
251
+ export interface ModelInfo {
252
+ id: string;
253
+ model: string;
254
+ displayName?: string;
255
+ description?: string;
256
+ hidden?: boolean;
257
+ isDefault?: boolean;
258
+ supportsPersonality?: boolean;
259
+ [key: string]: unknown;
260
+ }
261
+ export interface ModelListResponse {
262
+ data: ModelInfo[];
263
+ nextCursor?: string | null;
264
+ }
265
+ export type CollaborationModeMask = Record<string, unknown>;
266
+ export interface CollaborationModeListResponse {
267
+ data: CollaborationModeMask[];
268
+ }
269
+ export type ThreadGoalStatus = "active" | "paused" | "completed" | string;
270
+ export interface ThreadGoalSetParams {
271
+ threadId: string;
272
+ objective?: string | null;
273
+ status?: ThreadGoalStatus | null;
274
+ tokenBudget?: number | null;
275
+ }
276
+ export interface ThreadGoalGetParams {
277
+ threadId: string;
278
+ }
279
+ export interface ThreadGoalClearParams {
280
+ threadId: string;
281
+ }
282
+ export interface ThreadGoal {
283
+ objective?: string | null;
284
+ status?: ThreadGoalStatus | null;
285
+ [key: string]: unknown;
286
+ }
287
+ export interface ThreadGoalGetResponse {
288
+ goal?: ThreadGoal | null;
289
+ [key: string]: unknown;
290
+ }
291
+ export type ReviewTarget = {
292
+ type: "uncommittedChanges";
293
+ } | {
294
+ type: "baseBranch";
295
+ branch: string;
296
+ } | {
297
+ type: "commit";
298
+ sha: string;
299
+ title?: string | null;
300
+ } | {
301
+ type: "custom";
302
+ instructions: string;
303
+ };
304
+ export interface ReviewStartParams {
305
+ threadId: string;
306
+ target: ReviewTarget;
307
+ delivery?: Record<string, unknown> | null;
308
+ }
309
+ export interface ReviewStartResponse {
310
+ reviewThreadId?: string | null;
311
+ [key: string]: unknown;
312
+ }
313
+ export interface ThreadStartedNotificationParams {
314
+ thread: ThreadDescriptor;
315
+ }
316
+ export interface TurnStartedNotificationParams {
317
+ threadId: string;
318
+ turn: {
319
+ id: string;
320
+ } & Record<string, unknown>;
321
+ }
322
+ export interface TurnCompletedNotificationParams {
323
+ threadId: string;
324
+ turn: {
325
+ id: string;
326
+ status: TurnStatus;
327
+ error?: unknown;
328
+ } & Record<string, unknown>;
329
+ }
330
+ export interface TurnPlanUpdatedNotificationParams {
331
+ threadId: string;
332
+ turnId: string;
333
+ explanation?: string | null;
334
+ plan: TurnPlanStep[];
335
+ }
336
+ export interface TurnDiffUpdatedNotificationParams {
337
+ threadId: string;
338
+ turnId: string;
339
+ /** Aggregated turn-level unified diff (generated binding field name). */
340
+ diff?: string;
341
+ /** @deprecated older hand-written field name; prefer `diff`. */
342
+ unifiedDiff?: string;
343
+ [key: string]: unknown;
344
+ }
345
+ export interface ItemStartedNotificationParams {
346
+ item: ThreadItem;
347
+ threadId: string;
348
+ turnId: string;
349
+ startedAtMs: number;
350
+ }
351
+ export interface ItemCompletedNotificationParams {
352
+ item: ThreadItem;
353
+ threadId: string;
354
+ turnId: string;
355
+ completedAtMs: number;
356
+ }
357
+ export interface AgentMessageDeltaNotificationParams {
358
+ threadId: string;
359
+ turnId: string;
360
+ itemId: string;
361
+ delta: string;
362
+ }
363
+ export interface ReasoningSummaryTextDeltaNotificationParams {
364
+ threadId: string;
365
+ turnId: string;
366
+ itemId: string;
367
+ delta: string;
368
+ summaryIndex: number;
369
+ }
370
+ export interface CommandExecutionOutputDeltaNotificationParams {
371
+ threadId: string;
372
+ turnId: string;
373
+ itemId: string;
374
+ delta: string;
375
+ }
376
+ export interface FileChangePatchUpdatedNotificationParams {
377
+ threadId: string;
378
+ turnId: string;
379
+ itemId: string;
380
+ changes?: Array<{
381
+ path: string;
382
+ kind: string;
383
+ diff: string;
384
+ }>;
385
+ [key: string]: unknown;
386
+ }
387
+ export interface ThreadTokenUsageUpdatedNotificationParams {
388
+ threadId: string;
389
+ turnId: string;
390
+ tokenUsage: Record<string, unknown>;
391
+ }
392
+ export interface ErrorNotificationParams {
393
+ error: {
394
+ message: string;
395
+ additionalDetails?: string | null;
396
+ };
397
+ willRetry: boolean;
398
+ threadId: string;
399
+ turnId: string;
400
+ }
401
+ export type ServerNotification = {
402
+ method: "thread/started";
403
+ params: ThreadStartedNotificationParams;
404
+ } | {
405
+ method: "turn/started";
406
+ params: TurnStartedNotificationParams;
407
+ } | {
408
+ method: "turn/completed";
409
+ params: TurnCompletedNotificationParams;
410
+ } | {
411
+ method: "turn/plan/updated";
412
+ params: TurnPlanUpdatedNotificationParams;
413
+ } | {
414
+ method: "turn/diff/updated";
415
+ params: TurnDiffUpdatedNotificationParams;
416
+ } | {
417
+ method: "item/started";
418
+ params: ItemStartedNotificationParams;
419
+ } | {
420
+ method: "item/completed";
421
+ params: ItemCompletedNotificationParams;
422
+ } | {
423
+ method: "item/agentMessage/delta";
424
+ params: AgentMessageDeltaNotificationParams;
425
+ } | {
426
+ method: "item/reasoning/summaryTextDelta";
427
+ params: ReasoningSummaryTextDeltaNotificationParams;
428
+ } | {
429
+ method: "item/reasoning/textDelta";
430
+ params: ReasoningSummaryTextDeltaNotificationParams;
431
+ } | {
432
+ method: "item/commandExecution/outputDelta";
433
+ params: CommandExecutionOutputDeltaNotificationParams;
434
+ } | {
435
+ method: "item/fileChange/patchUpdated";
436
+ params: FileChangePatchUpdatedNotificationParams;
437
+ } | {
438
+ method: "thread/tokenUsage/updated";
439
+ params: ThreadTokenUsageUpdatedNotificationParams;
440
+ } | {
441
+ method: "error";
442
+ params: ErrorNotificationParams;
443
+ } | {
444
+ method: string;
445
+ params?: Record<string, unknown>;
446
+ };
447
+ export interface CommandExecutionRequestApprovalParams {
448
+ threadId: string;
449
+ turnId: string;
450
+ itemId: string;
451
+ startedAtMs: number;
452
+ approvalId?: string | null;
453
+ reason?: string | null;
454
+ command?: string | null;
455
+ cwd?: string | null;
456
+ }
457
+ export type CommandExecutionApprovalDecision = "accept" | "acceptForSession" | "decline" | "cancel";
458
+ export interface CommandExecutionRequestApprovalResponse {
459
+ decision: CommandExecutionApprovalDecision;
460
+ }
461
+ export interface FileChangeRequestApprovalParams {
462
+ threadId: string;
463
+ turnId: string;
464
+ itemId: string;
465
+ startedAtMs: number;
466
+ reason?: string | null;
467
+ grantRoot?: string | null;
468
+ }
469
+ export type FileChangeApprovalDecision = "accept" | "acceptForSession" | "decline" | "cancel";
470
+ export interface FileChangeRequestApprovalResponse {
471
+ decision: FileChangeApprovalDecision;
472
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Hand-curated subset of the Codex App Server JSON-RPC protocol.
3
+ *
4
+ * Source of truth: `codex app-server generate-ts --out <dir>` produces the
5
+ * full TypeScript bindings (~150 files). This file only mirrors the shapes
6
+ * the bridge consumes today. Unused notification / request payloads are
7
+ * captured with a permissive `Record<string, unknown>` so future Codex
8
+ * releases keep parsing without code changes here.
9
+ *
10
+ * Re-generate the upstream bindings periodically to spot field renames.
11
+ */
12
+ export {};