@kodelyth/codex 2026.5.42 → 2026.6.2

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 (138) hide show
  1. package/package.json +17 -2
  2. package/doctor-contract-api.test.ts +0 -44
  3. package/doctor-contract-api.ts +0 -68
  4. package/harness.ts +0 -72
  5. package/index.test.ts +0 -230
  6. package/index.ts +0 -66
  7. package/media-understanding-provider.test.ts +0 -486
  8. package/media-understanding-provider.ts +0 -521
  9. package/prompt-overlay-runtime-contract.test.ts +0 -48
  10. package/prompt-overlay.ts +0 -21
  11. package/provider-catalog.ts +0 -83
  12. package/provider-discovery.ts +0 -45
  13. package/provider.test.ts +0 -384
  14. package/provider.ts +0 -243
  15. package/src/app-server/app-inventory-cache.test.ts +0 -176
  16. package/src/app-server/app-inventory-cache.ts +0 -324
  17. package/src/app-server/approval-bridge.test.ts +0 -1471
  18. package/src/app-server/approval-bridge.ts +0 -1211
  19. package/src/app-server/auth-bridge.test.ts +0 -1449
  20. package/src/app-server/auth-bridge.ts +0 -614
  21. package/src/app-server/auth-profile-runtime-contract.test.ts +0 -239
  22. package/src/app-server/capabilities.ts +0 -27
  23. package/src/app-server/client-factory.ts +0 -24
  24. package/src/app-server/client.test.ts +0 -563
  25. package/src/app-server/client.ts +0 -715
  26. package/src/app-server/compact.test.ts +0 -710
  27. package/src/app-server/compact.ts +0 -500
  28. package/src/app-server/computer-use.test.ts +0 -788
  29. package/src/app-server/computer-use.ts +0 -683
  30. package/src/app-server/config.test.ts +0 -879
  31. package/src/app-server/config.ts +0 -1038
  32. package/src/app-server/context-engine-projection.test.ts +0 -252
  33. package/src/app-server/context-engine-projection.ts +0 -403
  34. package/src/app-server/delivery-no-reply-runtime-contract.test.ts +0 -80
  35. package/src/app-server/dynamic-tool-diagnostics.ts +0 -73
  36. package/src/app-server/dynamic-tool-profile.ts +0 -69
  37. package/src/app-server/dynamic-tools.test.ts +0 -1302
  38. package/src/app-server/dynamic-tools.ts +0 -623
  39. package/src/app-server/elicitation-bridge.test.ts +0 -1056
  40. package/src/app-server/elicitation-bridge.ts +0 -783
  41. package/src/app-server/event-projector.test.ts +0 -2668
  42. package/src/app-server/event-projector.ts +0 -2057
  43. package/src/app-server/image-payload-sanitizer.test.ts +0 -49
  44. package/src/app-server/image-payload-sanitizer.ts +0 -167
  45. package/src/app-server/klaw-owned-tool-runtime-contract.test.ts +0 -456
  46. package/src/app-server/local-runtime-attribution.ts +0 -39
  47. package/src/app-server/managed-binary.test.ts +0 -139
  48. package/src/app-server/managed-binary.ts +0 -193
  49. package/src/app-server/models.test.ts +0 -246
  50. package/src/app-server/models.ts +0 -172
  51. package/src/app-server/native-hook-relay.test.ts +0 -271
  52. package/src/app-server/native-hook-relay.ts +0 -150
  53. package/src/app-server/native-subagent-task-mirror.test.ts +0 -573
  54. package/src/app-server/native-subagent-task-mirror.ts +0 -497
  55. package/src/app-server/outcome-fallback-runtime-contract.test.ts +0 -404
  56. package/src/app-server/plugin-activation.test.ts +0 -336
  57. package/src/app-server/plugin-activation.ts +0 -283
  58. package/src/app-server/plugin-app-cache-key.ts +0 -74
  59. package/src/app-server/plugin-approval-roundtrip.ts +0 -122
  60. package/src/app-server/plugin-inventory.test.ts +0 -355
  61. package/src/app-server/plugin-inventory.ts +0 -357
  62. package/src/app-server/plugin-thread-config.test.ts +0 -865
  63. package/src/app-server/plugin-thread-config.ts +0 -455
  64. package/src/app-server/protocol-generated/json/DynamicToolCallParams.json +0 -33
  65. package/src/app-server/protocol-generated/json/v2/ErrorNotification.json +0 -199
  66. package/src/app-server/protocol-generated/json/v2/GetAccountResponse.json +0 -102
  67. package/src/app-server/protocol-generated/json/v2/ModelListResponse.json +0 -227
  68. package/src/app-server/protocol-generated/json/v2/ThreadResumeResponse.json +0 -2630
  69. package/src/app-server/protocol-generated/json/v2/ThreadStartResponse.json +0 -2630
  70. package/src/app-server/protocol-generated/json/v2/TurnCompletedNotification.json +0 -1659
  71. package/src/app-server/protocol-generated/json/v2/TurnStartResponse.json +0 -1655
  72. package/src/app-server/protocol-validators.test.ts +0 -75
  73. package/src/app-server/protocol-validators.ts +0 -203
  74. package/src/app-server/protocol.ts +0 -520
  75. package/src/app-server/rate-limit-cache.ts +0 -48
  76. package/src/app-server/rate-limits.test.ts +0 -202
  77. package/src/app-server/rate-limits.ts +0 -583
  78. package/src/app-server/request.ts +0 -73
  79. package/src/app-server/run-attempt.context-engine.test.ts +0 -1004
  80. package/src/app-server/run-attempt.test.ts +0 -9477
  81. package/src/app-server/run-attempt.ts +0 -4683
  82. package/src/app-server/run-attempt.vision-tools.test.ts +0 -35
  83. package/src/app-server/schema-normalization-runtime-contract.test.ts +0 -206
  84. package/src/app-server/session-binding.test.ts +0 -303
  85. package/src/app-server/session-binding.ts +0 -398
  86. package/src/app-server/session-history.ts +0 -44
  87. package/src/app-server/shared-client.test.ts +0 -589
  88. package/src/app-server/shared-client.ts +0 -289
  89. package/src/app-server/side-question.test.ts +0 -1175
  90. package/src/app-server/side-question.ts +0 -1007
  91. package/src/app-server/test-support.ts +0 -48
  92. package/src/app-server/thread-lifecycle.test.ts +0 -447
  93. package/src/app-server/thread-lifecycle.ts +0 -939
  94. package/src/app-server/thread-lifecycle.user-mcp-servers.test.ts +0 -442
  95. package/src/app-server/timeout.ts +0 -9
  96. package/src/app-server/tool-progress-normalization.ts +0 -77
  97. package/src/app-server/trajectory.test.ts +0 -205
  98. package/src/app-server/trajectory.ts +0 -365
  99. package/src/app-server/transcript-mirror.test.ts +0 -524
  100. package/src/app-server/transcript-mirror.ts +0 -208
  101. package/src/app-server/transcript-repair-runtime-contract.test.ts +0 -44
  102. package/src/app-server/transport-stdio.test.ts +0 -171
  103. package/src/app-server/transport-stdio.ts +0 -107
  104. package/src/app-server/transport-websocket.test.ts +0 -69
  105. package/src/app-server/transport-websocket.ts +0 -90
  106. package/src/app-server/transport.ts +0 -117
  107. package/src/app-server/user-input-bridge.test.ts +0 -249
  108. package/src/app-server/user-input-bridge.ts +0 -316
  109. package/src/app-server/version.ts +0 -4
  110. package/src/app-server/vision-tools.ts +0 -12
  111. package/src/command-account.ts +0 -544
  112. package/src/command-formatters.ts +0 -425
  113. package/src/command-handlers.ts +0 -2004
  114. package/src/command-rpc.test.ts +0 -16
  115. package/src/command-rpc.ts +0 -142
  116. package/src/commands.test.ts +0 -3312
  117. package/src/commands.ts +0 -65
  118. package/src/conversation-binding-data.ts +0 -124
  119. package/src/conversation-binding.test.ts +0 -599
  120. package/src/conversation-binding.ts +0 -561
  121. package/src/conversation-control.test.ts +0 -126
  122. package/src/conversation-control.ts +0 -303
  123. package/src/conversation-turn-collector.test.ts +0 -191
  124. package/src/conversation-turn-collector.ts +0 -186
  125. package/src/conversation-turn-input.test.ts +0 -141
  126. package/src/conversation-turn-input.ts +0 -106
  127. package/src/manifest.test.ts +0 -20
  128. package/src/migration/apply.ts +0 -501
  129. package/src/migration/helpers.ts +0 -55
  130. package/src/migration/plan.ts +0 -461
  131. package/src/migration/provider.test.ts +0 -1741
  132. package/src/migration/provider.ts +0 -41
  133. package/src/migration/source.ts +0 -643
  134. package/src/migration/targets.ts +0 -25
  135. package/src/node-cli-sessions.test.ts +0 -180
  136. package/src/node-cli-sessions.ts +0 -711
  137. package/test-api.ts +0 -82
  138. package/tsconfig.json +0 -16
@@ -1,520 +0,0 @@
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
- }
@@ -1,48 +0,0 @@
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
- }