@kodelyth/codex 2026.5.40 → 2026.5.42

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 (178) hide show
  1. package/dist/client-ChMX13_o.js +642 -0
  2. package/dist/client-factory-D3dIsp4Y.js +9 -0
  3. package/dist/command-formatters-BRW7_Nu7.js +519 -0
  4. package/dist/command-handlers-P2IqtXaZ.js +1462 -0
  5. package/dist/compact-baos5flR.js +329 -0
  6. package/dist/computer-use-VfLvTMaa.js +367 -0
  7. package/dist/config-CezENx_E.js +510 -0
  8. package/dist/doctor-contract-api.js +53 -0
  9. package/dist/harness.js +51 -0
  10. package/dist/index.js +1133 -0
  11. package/dist/media-understanding-provider.js +335 -0
  12. package/dist/models-B9DhrIwD.js +110 -0
  13. package/dist/node-cli-sessions-De4_DuFw.js +1216 -0
  14. package/dist/plugin-activation-BlMuJeXz.js +452 -0
  15. package/dist/prompt-overlay.js +12 -0
  16. package/dist/protocol-C9UWI98H.js +9 -0
  17. package/dist/protocol-validators-BGBspNmF.js +5988 -0
  18. package/dist/provider-catalog.js +84 -0
  19. package/dist/provider-discovery.js +33 -0
  20. package/dist/provider.js +150 -0
  21. package/dist/rate-limit-cache-CHuacE27.js +24 -0
  22. package/dist/request-CTQKUxaa.js +89 -0
  23. package/dist/rolldown-runtime-DUslC3ob.js +14 -0
  24. package/dist/run-attempt-DqV2OU1R.js +5366 -0
  25. package/dist/session-binding-3PzU7ZTW.js +222 -0
  26. package/dist/shared-client-Cnyr9dyT.js +631 -0
  27. package/dist/side-question-CP5XlA0U.js +667 -0
  28. package/dist/test-api.js +45 -0
  29. package/dist/thread-lifecycle-DBJetBuV.js +1561 -0
  30. package/dist/vision-tools-Cl_5a93K.js +1379 -0
  31. package/doctor-contract-api.test.ts +44 -0
  32. package/doctor-contract-api.ts +68 -0
  33. package/harness.ts +72 -0
  34. package/index.test.ts +230 -0
  35. package/index.ts +66 -0
  36. package/klaw.plugin.json +24 -85
  37. package/media-understanding-provider.test.ts +486 -0
  38. package/media-understanding-provider.ts +521 -0
  39. package/package.json +3 -3
  40. package/prompt-overlay-runtime-contract.test.ts +48 -0
  41. package/prompt-overlay.ts +21 -0
  42. package/provider-catalog.ts +83 -0
  43. package/provider-discovery.ts +45 -0
  44. package/provider.test.ts +384 -0
  45. package/provider.ts +243 -0
  46. package/src/app-server/app-inventory-cache.test.ts +176 -0
  47. package/src/app-server/app-inventory-cache.ts +324 -0
  48. package/src/app-server/approval-bridge.test.ts +1471 -0
  49. package/src/app-server/approval-bridge.ts +1211 -0
  50. package/src/app-server/auth-bridge.test.ts +1449 -0
  51. package/src/app-server/auth-bridge.ts +614 -0
  52. package/src/app-server/auth-profile-runtime-contract.test.ts +239 -0
  53. package/src/app-server/capabilities.ts +27 -0
  54. package/src/app-server/client-factory.ts +24 -0
  55. package/src/app-server/client.test.ts +563 -0
  56. package/src/app-server/client.ts +715 -0
  57. package/src/app-server/compact.test.ts +710 -0
  58. package/src/app-server/compact.ts +500 -0
  59. package/src/app-server/computer-use.test.ts +788 -0
  60. package/src/app-server/computer-use.ts +683 -0
  61. package/src/app-server/config.test.ts +879 -0
  62. package/src/app-server/config.ts +1038 -0
  63. package/src/app-server/context-engine-projection.test.ts +252 -0
  64. package/src/app-server/context-engine-projection.ts +403 -0
  65. package/src/app-server/delivery-no-reply-runtime-contract.test.ts +80 -0
  66. package/src/app-server/dynamic-tool-diagnostics.ts +73 -0
  67. package/src/app-server/dynamic-tool-profile.ts +69 -0
  68. package/src/app-server/dynamic-tools.test.ts +1302 -0
  69. package/src/app-server/dynamic-tools.ts +623 -0
  70. package/src/app-server/elicitation-bridge.test.ts +1056 -0
  71. package/src/app-server/elicitation-bridge.ts +783 -0
  72. package/src/app-server/event-projector.test.ts +2668 -0
  73. package/src/app-server/event-projector.ts +2057 -0
  74. package/src/app-server/image-payload-sanitizer.test.ts +49 -0
  75. package/src/app-server/image-payload-sanitizer.ts +167 -0
  76. package/src/app-server/klaw-owned-tool-runtime-contract.test.ts +456 -0
  77. package/src/app-server/local-runtime-attribution.ts +39 -0
  78. package/src/app-server/managed-binary.test.ts +139 -0
  79. package/src/app-server/managed-binary.ts +193 -0
  80. package/src/app-server/models.test.ts +246 -0
  81. package/src/app-server/models.ts +172 -0
  82. package/src/app-server/native-hook-relay.test.ts +271 -0
  83. package/src/app-server/native-hook-relay.ts +150 -0
  84. package/src/app-server/native-subagent-task-mirror.test.ts +573 -0
  85. package/src/app-server/native-subagent-task-mirror.ts +497 -0
  86. package/src/app-server/outcome-fallback-runtime-contract.test.ts +404 -0
  87. package/src/app-server/plugin-activation.test.ts +336 -0
  88. package/src/app-server/plugin-activation.ts +283 -0
  89. package/src/app-server/plugin-app-cache-key.ts +74 -0
  90. package/src/app-server/plugin-approval-roundtrip.ts +122 -0
  91. package/src/app-server/plugin-inventory.test.ts +355 -0
  92. package/src/app-server/plugin-inventory.ts +357 -0
  93. package/src/app-server/plugin-thread-config.test.ts +865 -0
  94. package/src/app-server/plugin-thread-config.ts +455 -0
  95. package/src/app-server/protocol-generated/json/DynamicToolCallParams.json +33 -0
  96. package/src/app-server/protocol-generated/json/v2/ErrorNotification.json +199 -0
  97. package/src/app-server/protocol-generated/json/v2/GetAccountResponse.json +102 -0
  98. package/src/app-server/protocol-generated/json/v2/ModelListResponse.json +227 -0
  99. package/src/app-server/protocol-generated/json/v2/ThreadResumeResponse.json +2630 -0
  100. package/src/app-server/protocol-generated/json/v2/ThreadStartResponse.json +2630 -0
  101. package/src/app-server/protocol-generated/json/v2/TurnCompletedNotification.json +1659 -0
  102. package/src/app-server/protocol-generated/json/v2/TurnStartResponse.json +1655 -0
  103. package/src/app-server/protocol-validators.test.ts +75 -0
  104. package/src/app-server/protocol-validators.ts +203 -0
  105. package/src/app-server/protocol.ts +520 -0
  106. package/src/app-server/rate-limit-cache.ts +48 -0
  107. package/src/app-server/rate-limits.test.ts +202 -0
  108. package/src/app-server/rate-limits.ts +583 -0
  109. package/src/app-server/request.ts +73 -0
  110. package/src/app-server/run-attempt.context-engine.test.ts +1004 -0
  111. package/src/app-server/run-attempt.test.ts +9477 -0
  112. package/src/app-server/run-attempt.ts +4683 -0
  113. package/src/app-server/run-attempt.vision-tools.test.ts +35 -0
  114. package/src/app-server/schema-normalization-runtime-contract.test.ts +206 -0
  115. package/src/app-server/session-binding.test.ts +303 -0
  116. package/src/app-server/session-binding.ts +398 -0
  117. package/src/app-server/session-history.ts +44 -0
  118. package/src/app-server/shared-client.test.ts +589 -0
  119. package/src/app-server/shared-client.ts +289 -0
  120. package/src/app-server/side-question.test.ts +1175 -0
  121. package/src/app-server/side-question.ts +1007 -0
  122. package/src/app-server/test-support.ts +48 -0
  123. package/src/app-server/thread-lifecycle.test.ts +447 -0
  124. package/src/app-server/thread-lifecycle.ts +939 -0
  125. package/src/app-server/thread-lifecycle.user-mcp-servers.test.ts +442 -0
  126. package/src/app-server/timeout.ts +9 -0
  127. package/src/app-server/tool-progress-normalization.ts +77 -0
  128. package/src/app-server/trajectory.test.ts +205 -0
  129. package/src/app-server/trajectory.ts +365 -0
  130. package/src/app-server/transcript-mirror.test.ts +524 -0
  131. package/src/app-server/transcript-mirror.ts +208 -0
  132. package/src/app-server/transcript-repair-runtime-contract.test.ts +44 -0
  133. package/src/app-server/transport-stdio.test.ts +171 -0
  134. package/src/app-server/transport-stdio.ts +107 -0
  135. package/src/app-server/transport-websocket.test.ts +69 -0
  136. package/src/app-server/transport-websocket.ts +90 -0
  137. package/src/app-server/transport.ts +117 -0
  138. package/src/app-server/user-input-bridge.test.ts +249 -0
  139. package/src/app-server/user-input-bridge.ts +316 -0
  140. package/src/app-server/version.ts +4 -0
  141. package/src/app-server/vision-tools.ts +12 -0
  142. package/src/command-account.ts +544 -0
  143. package/src/command-formatters.ts +425 -0
  144. package/src/command-handlers.ts +2004 -0
  145. package/src/command-rpc.test.ts +16 -0
  146. package/src/command-rpc.ts +142 -0
  147. package/src/commands.test.ts +3312 -0
  148. package/src/commands.ts +65 -0
  149. package/src/conversation-binding-data.ts +124 -0
  150. package/src/conversation-binding.test.ts +599 -0
  151. package/src/conversation-binding.ts +561 -0
  152. package/src/conversation-control.test.ts +126 -0
  153. package/src/conversation-control.ts +303 -0
  154. package/src/conversation-turn-collector.test.ts +191 -0
  155. package/src/conversation-turn-collector.ts +186 -0
  156. package/src/conversation-turn-input.test.ts +141 -0
  157. package/src/conversation-turn-input.ts +106 -0
  158. package/src/manifest.test.ts +20 -0
  159. package/src/migration/apply.ts +501 -0
  160. package/src/migration/helpers.ts +55 -0
  161. package/src/migration/plan.ts +461 -0
  162. package/src/migration/provider.test.ts +1741 -0
  163. package/src/migration/provider.ts +41 -0
  164. package/src/migration/source.ts +643 -0
  165. package/src/migration/targets.ts +25 -0
  166. package/src/node-cli-sessions.test.ts +180 -0
  167. package/src/node-cli-sessions.ts +711 -0
  168. package/test-api.ts +82 -0
  169. package/tsconfig.json +16 -0
  170. package/doctor-contract-api.js +0 -7
  171. package/harness.js +0 -7
  172. package/index.js +0 -7
  173. package/media-understanding-provider.js +0 -7
  174. package/prompt-overlay.js +0 -7
  175. package/provider-catalog.js +0 -7
  176. package/provider-discovery.js +0 -7
  177. package/provider.js +0 -7
  178. package/test-api.js +0 -7
@@ -0,0 +1,520 @@
1
+ export type JsonValue = null | boolean | number | string | JsonValue[] | JsonObject;
2
+ export type JsonObject = { [key: string]: JsonValue };
3
+ export type CodexServiceTier = string;
4
+
5
+ export type CodexAppServerRequestMethod = keyof CodexAppServerRequestResultMap | (string & {});
6
+ export type CodexAppServerRequestParams<M extends CodexAppServerRequestMethod> =
7
+ M extends keyof CodexAppServerRequestParamsOverride
8
+ ? CodexAppServerRequestParamsOverride[M]
9
+ : unknown;
10
+
11
+ export type CodexAppServerRequestResult<M extends CodexAppServerRequestMethod> =
12
+ M extends keyof CodexAppServerRequestResultMap
13
+ ? CodexAppServerRequestResultMap[M]
14
+ : JsonValue | undefined;
15
+
16
+ export type RpcRequest = {
17
+ id?: number | string;
18
+ method: string;
19
+ params?: JsonValue;
20
+ };
21
+
22
+ export type RpcResponse = {
23
+ id: number | string;
24
+ result?: JsonValue;
25
+ error?: {
26
+ code?: number;
27
+ message: string;
28
+ data?: JsonValue;
29
+ };
30
+ };
31
+
32
+ export type RpcMessage = RpcRequest | RpcResponse;
33
+
34
+ export type CodexInitializeParams = {
35
+ clientInfo: {
36
+ name: string;
37
+ title?: string;
38
+ version?: string;
39
+ };
40
+ capabilities?: JsonObject;
41
+ };
42
+
43
+ export type CodexInitializeResponse = {
44
+ serverInfo?: {
45
+ name?: string;
46
+ version?: string;
47
+ };
48
+ protocolVersion?: string;
49
+ userAgent?: string;
50
+ };
51
+
52
+ export type CodexUserInput =
53
+ | {
54
+ type: "text";
55
+ text: string;
56
+ text_elements?: JsonValue[];
57
+ }
58
+ | {
59
+ type: "image";
60
+ url: string;
61
+ }
62
+ | {
63
+ type: "localImage";
64
+ path: string;
65
+ };
66
+
67
+ export type CodexDynamicToolSpec = JsonObject & {
68
+ name: string;
69
+ description: string;
70
+ inputSchema: JsonValue;
71
+ };
72
+
73
+ export type CodexThreadStartParams = JsonObject & {
74
+ input?: CodexUserInput[];
75
+ cwd?: string;
76
+ model?: string;
77
+ modelProvider?: string | null;
78
+ approvalPolicy?: string | JsonObject;
79
+ approvalsReviewer?: string | null;
80
+ sandbox?: CodexSandboxPolicy;
81
+ serviceTier?: CodexServiceTier | null;
82
+ dynamicTools?: CodexDynamicToolSpec[] | null;
83
+ developerInstructions?: string;
84
+ experimentalRawEvents?: boolean;
85
+ persistExtendedHistory?: boolean;
86
+ };
87
+
88
+ export type CodexThreadResumeParams = JsonObject & {
89
+ threadId: string;
90
+ model?: string;
91
+ modelProvider?: string | null;
92
+ };
93
+
94
+ export type CodexThreadStartResponse = {
95
+ thread: CodexThread;
96
+ model: string;
97
+ modelProvider?: string | null;
98
+ };
99
+
100
+ export type CodexThreadForkParams = CodexThreadStartParams & {
101
+ threadId: string;
102
+ baseInstructions?: string;
103
+ ephemeral?: boolean;
104
+ threadSource?: string | JsonObject;
105
+ excludeTurns?: boolean;
106
+ };
107
+
108
+ export type CodexThreadForkResponse = CodexThreadStartResponse;
109
+
110
+ export type CodexThreadResumeResponse = {
111
+ thread: CodexThread;
112
+ model: string;
113
+ modelProvider?: string | null;
114
+ };
115
+
116
+ export type CodexThreadInjectItemsParams = JsonObject & {
117
+ threadId: string;
118
+ items: JsonValue[];
119
+ };
120
+
121
+ export type CodexThreadUnsubscribeParams = JsonObject & {
122
+ threadId: string;
123
+ };
124
+
125
+ export type CodexTurnInterruptParams = JsonObject & {
126
+ threadId: string;
127
+ turnId: string;
128
+ };
129
+
130
+ export type CodexTurnStartParams = JsonObject & {
131
+ threadId: string;
132
+ input?: CodexUserInput[];
133
+ cwd?: string;
134
+ model?: string;
135
+ approvalPolicy?: string | JsonObject;
136
+ approvalsReviewer?: string | null;
137
+ sandboxPolicy?: CodexSandboxPolicy;
138
+ serviceTier?: CodexServiceTier | null;
139
+ effort?: string | null;
140
+ collaborationMode?: {
141
+ mode: string;
142
+ settings: JsonObject & {
143
+ developer_instructions: string | null;
144
+ };
145
+ } | null;
146
+ };
147
+
148
+ export type CodexSandboxPolicy = string | JsonObject;
149
+
150
+ export type CodexTurnStartResponse = {
151
+ turn: CodexTurn;
152
+ };
153
+
154
+ export type CodexTurn = {
155
+ id: string;
156
+ threadId: string;
157
+ status?: string;
158
+ error?: CodexErrorNotification["error"];
159
+ startedAt?: string | null;
160
+ completedAt?: string | null;
161
+ durationMs?: number | null;
162
+ items: CodexThreadItem[];
163
+ };
164
+
165
+ export type CodexThread = {
166
+ id: string;
167
+ sessionId?: string;
168
+ name?: string | null;
169
+ preview?: string | null;
170
+ createdAt?: number | null;
171
+ updatedAt?: number | null;
172
+ status?: CodexThreadStatus | null;
173
+ cwd?: string | null;
174
+ source?: CodexSessionSource | null;
175
+ threadSource?: string | null;
176
+ agentNickname?: string | null;
177
+ agentRole?: string | null;
178
+ };
179
+
180
+ export type CodexThreadStatus =
181
+ | { type: "notLoaded" }
182
+ | { type: "idle" }
183
+ | { type: "systemError" }
184
+ | { type: "active"; activeFlags?: string[] };
185
+
186
+ export type CodexSubAgentThreadSpawnSource = {
187
+ parent_thread_id: string;
188
+ depth?: number;
189
+ agent_path?: string | null;
190
+ agent_nickname?: string | null;
191
+ agent_role?: string | null;
192
+ };
193
+
194
+ export type CodexSubAgentSource =
195
+ | "review"
196
+ | "compact"
197
+ | "memory_consolidation"
198
+ | { thread_spawn: CodexSubAgentThreadSpawnSource }
199
+ | { other: string };
200
+
201
+ export type CodexSessionSource =
202
+ | "cli"
203
+ | "vscode"
204
+ | "exec"
205
+ | "appServer"
206
+ | "unknown"
207
+ | { custom: string }
208
+ | { subAgent: CodexSubAgentSource };
209
+
210
+ export type CodexThreadStartedNotification = {
211
+ thread: CodexThread;
212
+ };
213
+
214
+ export type CodexThreadStatusChangedNotification = {
215
+ threadId: string;
216
+ status: CodexThreadStatus;
217
+ };
218
+
219
+ export type CodexThreadItem = {
220
+ id: string;
221
+ type: string;
222
+ title: string | null;
223
+ status: string | null;
224
+ name: string | null;
225
+ tool: string | null;
226
+ server: string | null;
227
+ command: string | null;
228
+ cwd: string | null;
229
+ query: string | null;
230
+ arguments?: JsonValue;
231
+ result?: JsonValue;
232
+ error?: CodexErrorNotification["error"];
233
+ exitCode?: number | null;
234
+ durationMs?: number | null;
235
+ aggregatedOutput: string | null;
236
+ text: string;
237
+ contentItems?: CodexDynamicToolCallOutputContentItem[] | null;
238
+ changes: Array<{ path: string; kind: string }>;
239
+ [key: string]: unknown;
240
+ };
241
+
242
+ export type CodexServerNotification = {
243
+ method: string;
244
+ params?: JsonValue;
245
+ };
246
+
247
+ export type CodexDynamicToolCallParams = {
248
+ namespace?: string | null;
249
+ threadId: string;
250
+ turnId: string;
251
+ callId: string;
252
+ tool: string;
253
+ arguments?: JsonValue;
254
+ };
255
+
256
+ export type CodexDynamicToolCallResponse = {
257
+ contentItems: CodexDynamicToolCallOutputContentItem[];
258
+ diagnosticTerminalType?: CodexDynamicToolDiagnosticTerminalType;
259
+ success: boolean;
260
+ };
261
+
262
+ export type CodexDynamicToolDiagnosticTerminalType = "blocked" | "completed" | "error";
263
+
264
+ export type CodexDynamicToolCallOutputContentItem =
265
+ | {
266
+ type: "inputText";
267
+ text: string;
268
+ }
269
+ | {
270
+ type: "inputImage";
271
+ imageUrl: string;
272
+ }
273
+ | JsonObject;
274
+
275
+ export type CodexErrorNotification = {
276
+ error: {
277
+ message?: string;
278
+ codexErrorInfo?: {
279
+ message?: string;
280
+ [key: string]: unknown;
281
+ };
282
+ [key: string]: unknown;
283
+ };
284
+ message?: string;
285
+ };
286
+
287
+ export type CodexTurnCompletedNotification = {
288
+ turn: CodexTurn;
289
+ };
290
+
291
+ export type CodexModel = {
292
+ id?: string;
293
+ model?: string;
294
+ displayName?: string | null;
295
+ description?: string | null;
296
+ hidden: boolean;
297
+ isDefault: boolean;
298
+ inputModalities: string[];
299
+ supportedReasoningEfforts: CodexReasoningEffortOption[];
300
+ defaultReasoningEffort?: string | null;
301
+ };
302
+
303
+ export type CodexReasoningEffortOption = {
304
+ reasoningEffort?: string | null;
305
+ };
306
+
307
+ export type CodexModelListResponse = {
308
+ data: CodexModel[];
309
+ nextCursor?: string | null;
310
+ };
311
+
312
+ export type CodexGetAccountResponse = {
313
+ account?: JsonValue;
314
+ requiresOpenaiAuth?: boolean;
315
+ };
316
+
317
+ export type CodexChatgptAuthTokensRefreshResponse = {
318
+ accessToken: string;
319
+ chatgptAccountId: string;
320
+ chatgptPlanType: string | null;
321
+ };
322
+
323
+ export type CodexLoginAccountParams =
324
+ | {
325
+ type: "apiKey";
326
+ apiKey: string;
327
+ }
328
+ | {
329
+ type: "chatgptAuthTokens";
330
+ accessToken: string;
331
+ chatgptAccountId: string;
332
+ chatgptPlanType: string | null;
333
+ };
334
+
335
+ export type CodexPluginSummary = {
336
+ id: string;
337
+ name: string;
338
+ source?: JsonObject;
339
+ installed: boolean;
340
+ enabled: boolean;
341
+ installPolicy?: string;
342
+ authPolicy?: string;
343
+ availability?: string;
344
+ interface?: JsonValue;
345
+ };
346
+
347
+ export type CodexAppSummary = {
348
+ id: string;
349
+ name: string;
350
+ description?: string | null;
351
+ installUrl?: string | null;
352
+ needsAuth: boolean;
353
+ };
354
+
355
+ export type CodexPluginDetail = {
356
+ marketplaceName?: string;
357
+ marketplacePath?: string | null;
358
+ summary: CodexPluginSummary;
359
+ description?: string | null;
360
+ skills?: JsonValue[];
361
+ apps: CodexAppSummary[];
362
+ mcpServers: string[];
363
+ };
364
+
365
+ export type CodexPluginMarketplaceEntry = {
366
+ name: string;
367
+ path?: string | null;
368
+ interface?: JsonValue;
369
+ plugins: CodexPluginSummary[];
370
+ };
371
+
372
+ export type CodexPluginListResponse = {
373
+ marketplaces: CodexPluginMarketplaceEntry[];
374
+ marketplaceLoadErrors?: JsonValue[];
375
+ featuredPluginIds?: string[];
376
+ };
377
+
378
+ export type CodexPluginReadResponse = {
379
+ plugin: CodexPluginDetail;
380
+ };
381
+
382
+ export type CodexPluginListParams = {
383
+ cwds: string[];
384
+ };
385
+
386
+ export type CodexPluginReadParams = {
387
+ marketplacePath?: string;
388
+ remoteMarketplaceName?: string;
389
+ pluginName: string;
390
+ };
391
+
392
+ export type CodexPluginInstallParams = CodexPluginReadParams;
393
+
394
+ export type CodexPluginInstallResponse = {
395
+ authPolicy: string;
396
+ appsNeedingAuth: CodexAppSummary[];
397
+ };
398
+
399
+ export type CodexAppInfo = {
400
+ id: string;
401
+ name: string;
402
+ description?: string | null;
403
+ logoUrl?: string | null;
404
+ logoUrlDark?: string | null;
405
+ distributionChannel?: string | null;
406
+ branding?: JsonValue;
407
+ appMetadata?: JsonValue;
408
+ labels?: JsonValue;
409
+ installUrl?: string | null;
410
+ isAccessible: boolean;
411
+ isEnabled: boolean;
412
+ pluginDisplayNames: string[];
413
+ };
414
+
415
+ export type CodexAppsListParams = {
416
+ cursor?: string | null;
417
+ limit?: number;
418
+ forceRefetch?: boolean;
419
+ };
420
+
421
+ export type CodexAppsListResponse = {
422
+ data: CodexAppInfo[];
423
+ nextCursor?: string | null;
424
+ };
425
+
426
+ export type CodexSkillsListParams = {
427
+ cwds: string[];
428
+ forceReload?: boolean;
429
+ };
430
+
431
+ export type CodexSkillsListResponse = {
432
+ data: JsonValue[];
433
+ nextCursor?: string | null;
434
+ };
435
+
436
+ export type CodexHooksListParams = {
437
+ cwds: string[];
438
+ };
439
+
440
+ export type CodexHooksListResponse = {
441
+ data: JsonValue[];
442
+ nextCursor?: string | null;
443
+ };
444
+
445
+ export type CodexMcpServerStatus = {
446
+ name: string;
447
+ tools: JsonObject;
448
+ };
449
+
450
+ export type CodexListMcpServerStatusResponse = {
451
+ data: CodexMcpServerStatus[];
452
+ nextCursor?: string | null;
453
+ };
454
+
455
+ export type CodexRequestObject = Record<string, unknown>;
456
+
457
+ export declare namespace v2 {
458
+ export type AppInfo = CodexAppInfo;
459
+ export type AppSummary = CodexAppSummary;
460
+ export type AppsListParams = CodexAppsListParams;
461
+ export type AppsListResponse = CodexAppsListResponse;
462
+ export type HooksListParams = CodexHooksListParams;
463
+ export type HooksListResponse = CodexHooksListResponse;
464
+ export type PluginDetail = CodexPluginDetail;
465
+ export type PluginInstallParams = CodexPluginInstallParams;
466
+ export type PluginInstallResponse = CodexPluginInstallResponse;
467
+ export type PluginListParams = CodexPluginListParams;
468
+ export type PluginListResponse = CodexPluginListResponse;
469
+ export type PluginMarketplaceEntry = CodexPluginMarketplaceEntry;
470
+ export type PluginReadParams = CodexPluginReadParams;
471
+ export type PluginReadResponse = CodexPluginReadResponse;
472
+ export type PluginSummary = CodexPluginSummary;
473
+ export type SkillsListParams = CodexSkillsListParams;
474
+ export type SkillsListResponse = CodexSkillsListResponse;
475
+ }
476
+
477
+ type CodexAppServerRequestParamsOverride = {
478
+ "thread/fork": CodexThreadForkParams;
479
+ "thread/inject_items": CodexThreadInjectItemsParams;
480
+ "thread/start": CodexThreadStartParams;
481
+ "thread/unsubscribe": CodexThreadUnsubscribeParams;
482
+ "turn/interrupt": CodexTurnInterruptParams;
483
+ };
484
+
485
+ type CodexAppServerRequestResultMap = {
486
+ initialize: CodexInitializeResponse;
487
+ "account/rateLimits/read": JsonValue;
488
+ "account/read": CodexGetAccountResponse;
489
+ "app/list": CodexAppsListResponse;
490
+ "config/mcpServer/reload": JsonValue;
491
+ "experimentalFeature/enablement/set": JsonValue;
492
+ "feedback/upload": JsonValue;
493
+ "hooks/list": CodexHooksListResponse;
494
+ "marketplace/add": JsonValue;
495
+ "mcpServerStatus/list": CodexListMcpServerStatusResponse;
496
+ "model/list": CodexModelListResponse;
497
+ "plugin/install": CodexPluginInstallResponse;
498
+ "plugin/list": CodexPluginListResponse;
499
+ "plugin/read": CodexPluginReadResponse;
500
+ "review/start": JsonValue;
501
+ "skills/list": CodexSkillsListResponse;
502
+ "thread/compact/start": JsonValue;
503
+ "thread/fork": CodexThreadForkResponse;
504
+ "thread/inject_items": JsonValue;
505
+ "thread/list": JsonValue;
506
+ "thread/resume": CodexThreadResumeResponse;
507
+ "thread/start": CodexThreadStartResponse;
508
+ "thread/unsubscribe": JsonValue;
509
+ "turn/interrupt": JsonValue;
510
+ "turn/start": CodexTurnStartResponse;
511
+ "turn/steer": JsonValue;
512
+ };
513
+
514
+ export function isJsonObject(value: JsonValue | undefined): value is JsonObject {
515
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
516
+ }
517
+
518
+ export function isRpcResponse(message: RpcMessage): message is RpcResponse {
519
+ return "id" in message && !("method" in message);
520
+ }
@@ -0,0 +1,48 @@
1
+ import type { JsonValue } from "./protocol.js";
2
+
3
+ const DEFAULT_CODEX_RATE_LIMIT_CACHE_MAX_AGE_MS = 10 * 60_000;
4
+ const CODEX_RATE_LIMIT_CACHE_STATE = Symbol.for("klaw.codexRateLimitCacheState");
5
+
6
+ type CodexRateLimitCacheState = {
7
+ value?: JsonValue;
8
+ updatedAtMs?: number;
9
+ };
10
+
11
+ function getCodexRateLimitCacheState(): CodexRateLimitCacheState {
12
+ const globalState = globalThis as typeof globalThis & {
13
+ [CODEX_RATE_LIMIT_CACHE_STATE]?: CodexRateLimitCacheState;
14
+ };
15
+ globalState[CODEX_RATE_LIMIT_CACHE_STATE] ??= {};
16
+ return globalState[CODEX_RATE_LIMIT_CACHE_STATE];
17
+ }
18
+
19
+ export function rememberCodexRateLimits(value: JsonValue | undefined, nowMs = Date.now()): void {
20
+ if (value === undefined) {
21
+ return;
22
+ }
23
+ const state = getCodexRateLimitCacheState();
24
+ state.value = value;
25
+ state.updatedAtMs = nowMs;
26
+ }
27
+
28
+ export function readRecentCodexRateLimits(options?: {
29
+ nowMs?: number;
30
+ maxAgeMs?: number;
31
+ }): JsonValue | undefined {
32
+ const state = getCodexRateLimitCacheState();
33
+ if (state.value === undefined || state.updatedAtMs === undefined) {
34
+ return undefined;
35
+ }
36
+ const nowMs = options?.nowMs ?? Date.now();
37
+ const maxAgeMs = options?.maxAgeMs ?? DEFAULT_CODEX_RATE_LIMIT_CACHE_MAX_AGE_MS;
38
+ if (maxAgeMs >= 0 && nowMs - state.updatedAtMs > maxAgeMs) {
39
+ return undefined;
40
+ }
41
+ return state.value;
42
+ }
43
+
44
+ export function resetCodexRateLimitCacheForTests(): void {
45
+ const state = getCodexRateLimitCacheState();
46
+ state.value = undefined;
47
+ state.updatedAtMs = undefined;
48
+ }