@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,573 +0,0 @@
1
- import { describe, expect, it, vi } from "vitest";
2
- import {
3
- codexNativeSubagentRunId,
4
- CodexNativeSubagentTaskMirror,
5
- type TaskLifecycleRuntime,
6
- } from "./native-subagent-task-mirror.js";
7
-
8
- function createRuntime() {
9
- return {
10
- createRunningTaskRun: vi.fn(),
11
- recordTaskRunProgressByRunId: vi.fn(() => []),
12
- finalizeTaskRunByRunId: vi.fn(() => []),
13
- } as unknown as TaskLifecycleRuntime;
14
- }
15
-
16
- describe("CodexNativeSubagentTaskMirror", () => {
17
- it("creates a silent task-registry task for a native Codex subagent thread", () => {
18
- const runtime = createRuntime();
19
- const mirror = new CodexNativeSubagentTaskMirror(
20
- {
21
- parentThreadId: "parent-thread",
22
- requesterSessionKey: "agent:main:main",
23
- agentId: "main",
24
- now: () => 20_000,
25
- },
26
- runtime,
27
- );
28
-
29
- mirror.handleNotification({
30
- method: "thread/started",
31
- params: {
32
- thread: {
33
- id: "child-thread",
34
- sessionId: "session-tree",
35
- preview: "write the Madrid wine script",
36
- createdAt: 10,
37
- status: { type: "active", activeFlags: [] },
38
- source: {
39
- subAgent: {
40
- thread_spawn: {
41
- parent_thread_id: "parent-thread",
42
- depth: 1,
43
- agent_nickname: "Poincare",
44
- agent_role: "worker",
45
- },
46
- },
47
- },
48
- },
49
- },
50
- });
51
-
52
- expect(runtime.createRunningTaskRun).toHaveBeenCalledWith({
53
- runtime: "subagent",
54
- taskKind: "codex-native",
55
- sourceId: "codex-thread:child-thread",
56
- requesterSessionKey: "agent:main:main",
57
- ownerKey: "agent:main:main",
58
- scopeKind: "session",
59
- agentId: "main",
60
- runId: "codex-thread:child-thread",
61
- label: "Poincare",
62
- task: "write the Madrid wine script",
63
- notifyPolicy: "silent",
64
- deliveryStatus: "not_applicable",
65
- preferMetadata: true,
66
- startedAt: 10_000,
67
- lastEventAt: 20_000,
68
- progressSummary: "Codex native subagent started.",
69
- });
70
- expect(vi.mocked(runtime.createRunningTaskRun).mock.calls[0]?.[0]).not.toHaveProperty(
71
- "childSessionKey",
72
- );
73
- expect(runtime.recordTaskRunProgressByRunId).toHaveBeenCalledWith({
74
- runId: "codex-thread:child-thread",
75
- runtime: "subagent",
76
- lastEventAt: 20_000,
77
- progressSummary: "Codex native subagent is active.",
78
- });
79
- });
80
-
81
- it("ignores subagent threads spawned by a different parent thread", () => {
82
- const runtime = createRuntime();
83
- const mirror = new CodexNativeSubagentTaskMirror(
84
- {
85
- parentThreadId: "parent-thread",
86
- requesterSessionKey: "agent:main:main",
87
- },
88
- runtime,
89
- );
90
-
91
- mirror.handleNotification({
92
- method: "thread/started",
93
- params: {
94
- thread: {
95
- id: "other-child",
96
- source: {
97
- subAgent: {
98
- thread_spawn: {
99
- parent_thread_id: "other-parent",
100
- depth: 1,
101
- },
102
- },
103
- },
104
- },
105
- },
106
- });
107
-
108
- expect(runtime.createRunningTaskRun).not.toHaveBeenCalled();
109
- expect(runtime.recordTaskRunProgressByRunId).not.toHaveBeenCalled();
110
- expect(runtime.finalizeTaskRunByRunId).not.toHaveBeenCalled();
111
- });
112
-
113
- it("deduplicates repeated thread-started notifications for the same child thread", () => {
114
- const runtime = createRuntime();
115
- const mirror = new CodexNativeSubagentTaskMirror(
116
- {
117
- parentThreadId: "parent-thread",
118
- requesterSessionKey: "agent:main:main",
119
- },
120
- runtime,
121
- );
122
- const notification = {
123
- method: "thread/started",
124
- params: {
125
- thread: {
126
- id: "child-thread",
127
- source: {
128
- subAgent: {
129
- thread_spawn: {
130
- parent_thread_id: "parent-thread",
131
- depth: 1,
132
- },
133
- },
134
- },
135
- },
136
- },
137
- } as const;
138
-
139
- mirror.handleNotification(notification);
140
- mirror.handleNotification(notification);
141
-
142
- expect(runtime.createRunningTaskRun).toHaveBeenCalledTimes(1);
143
- });
144
-
145
- it("maps Codex thread status changes onto the mirrored task run", () => {
146
- const runtime = createRuntime();
147
- const mirror = new CodexNativeSubagentTaskMirror(
148
- {
149
- parentThreadId: "parent-thread",
150
- requesterSessionKey: "agent:main:main",
151
- now: () => 30_000,
152
- },
153
- runtime,
154
- );
155
-
156
- mirror.handleNotification({
157
- method: "thread/status/changed",
158
- params: {
159
- threadId: "child-thread",
160
- status: { type: "idle" },
161
- },
162
- });
163
- mirror.handleNotification({
164
- method: "thread/status/changed",
165
- params: {
166
- threadId: "failed-child",
167
- status: { type: "systemError" },
168
- },
169
- });
170
-
171
- expect(runtime.finalizeTaskRunByRunId).toHaveBeenNthCalledWith(1, {
172
- runId: codexNativeSubagentRunId("child-thread"),
173
- runtime: "subagent",
174
- status: "succeeded",
175
- endedAt: 30_000,
176
- lastEventAt: 30_000,
177
- progressSummary: "Codex native subagent is idle.",
178
- terminalSummary: "Codex native subagent finished.",
179
- });
180
- expect(runtime.finalizeTaskRunByRunId).toHaveBeenNthCalledWith(2, {
181
- runId: codexNativeSubagentRunId("failed-child"),
182
- runtime: "subagent",
183
- status: "failed",
184
- endedAt: 30_000,
185
- lastEventAt: 30_000,
186
- error: "Codex app-server reported a system error for the native subagent thread.",
187
- progressSummary: "Codex native subagent hit a system error.",
188
- terminalSummary: "Codex native subagent failed.",
189
- });
190
- });
191
-
192
- it("creates and updates tasks from Codex collab agent item state", () => {
193
- const runtime = createRuntime();
194
- const mirror = new CodexNativeSubagentTaskMirror(
195
- {
196
- parentThreadId: "parent-thread",
197
- requesterSessionKey: "agent:main:main",
198
- now: () => 40_000,
199
- },
200
- runtime,
201
- );
202
-
203
- mirror.handleNotification({
204
- method: "item/completed",
205
- params: {
206
- item: {
207
- type: "collabAgentToolCall",
208
- tool: "spawnAgent",
209
- senderThreadId: "parent-thread",
210
- receiverThreadIds: ["child-thread"],
211
- prompt: "write the proof file",
212
- agentsStates: {
213
- "child-thread": {
214
- status: "pendingInit",
215
- message: null,
216
- },
217
- },
218
- },
219
- },
220
- });
221
- mirror.handleNotification({
222
- method: "item/completed",
223
- params: {
224
- item: {
225
- type: "collabAgentToolCall",
226
- tool: "wait",
227
- senderThreadId: "parent-thread",
228
- receiverThreadIds: [],
229
- agentsStates: {
230
- "child-thread": {
231
- status: "completed",
232
- message: "done",
233
- },
234
- },
235
- },
236
- },
237
- });
238
-
239
- expect(runtime.createRunningTaskRun).toHaveBeenCalledWith({
240
- runtime: "subagent",
241
- taskKind: "codex-native",
242
- sourceId: "codex-thread:child-thread",
243
- requesterSessionKey: "agent:main:main",
244
- ownerKey: "agent:main:main",
245
- scopeKind: "session",
246
- runId: "codex-thread:child-thread",
247
- label: "Codex subagent",
248
- task: "write the proof file",
249
- notifyPolicy: "silent",
250
- deliveryStatus: "not_applicable",
251
- preferMetadata: true,
252
- startedAt: 40_000,
253
- lastEventAt: 40_000,
254
- progressSummary: "Codex native subagent spawned.",
255
- });
256
- expect(vi.mocked(runtime.createRunningTaskRun).mock.calls[0]?.[0]).not.toHaveProperty(
257
- "childSessionKey",
258
- );
259
- expect(runtime.recordTaskRunProgressByRunId).toHaveBeenCalledWith({
260
- runId: "codex-thread:child-thread",
261
- runtime: "subagent",
262
- lastEventAt: 40_000,
263
- progressSummary: "Codex native subagent is initializing.",
264
- });
265
- expect(runtime.finalizeTaskRunByRunId).toHaveBeenCalledWith({
266
- runId: "codex-thread:child-thread",
267
- runtime: "subagent",
268
- status: "succeeded",
269
- endedAt: 40_000,
270
- lastEventAt: 40_000,
271
- progressSummary: "done",
272
- terminalSummary: "done",
273
- });
274
- });
275
-
276
- it("finalizes stale collab agent state from the blocked tool call status", () => {
277
- const runtime = createRuntime();
278
- const mirror = new CodexNativeSubagentTaskMirror(
279
- {
280
- parentThreadId: "parent-thread",
281
- requesterSessionKey: "agent:main:main",
282
- now: () => 45_000,
283
- },
284
- runtime,
285
- );
286
-
287
- mirror.handleNotification({
288
- method: "item/completed",
289
- params: {
290
- item: {
291
- type: "collabAgentToolCall",
292
- tool: "spawnAgent",
293
- status: "blocked",
294
- senderThreadId: "parent-thread",
295
- receiverThreadIds: ["child-thread"],
296
- prompt: "read cwd",
297
- agentsStates: {
298
- "child-thread": {
299
- status: "pendingInit",
300
- message: "Native hook relay unavailable",
301
- },
302
- },
303
- },
304
- },
305
- });
306
-
307
- expect(runtime.recordTaskRunProgressByRunId).not.toHaveBeenCalledWith({
308
- runId: "codex-thread:child-thread",
309
- runtime: "subagent",
310
- lastEventAt: 45_000,
311
- progressSummary: "Native hook relay unavailable",
312
- });
313
- expect(runtime.finalizeTaskRunByRunId).toHaveBeenCalledWith({
314
- runId: "codex-thread:child-thread",
315
- runtime: "subagent",
316
- status: "succeeded",
317
- endedAt: 45_000,
318
- lastEventAt: 45_000,
319
- progressSummary: "Native hook relay unavailable",
320
- terminalSummary: "Native hook relay unavailable",
321
- terminalOutcome: "blocked",
322
- });
323
- });
324
-
325
- it("does not treat completed tool calls as completed subagents", () => {
326
- const runtime = createRuntime();
327
- const mirror = new CodexNativeSubagentTaskMirror(
328
- {
329
- parentThreadId: "parent-thread",
330
- requesterSessionKey: "agent:main:main",
331
- now: () => 46_000,
332
- },
333
- runtime,
334
- );
335
-
336
- mirror.handleNotification({
337
- method: "item/completed",
338
- params: {
339
- item: {
340
- type: "collabAgentToolCall",
341
- tool: "spawnAgent",
342
- status: "completed",
343
- senderThreadId: "parent-thread",
344
- receiverThreadIds: ["child-thread"],
345
- prompt: "read cwd",
346
- agentsStates: {
347
- "child-thread": {
348
- status: "pendingInit",
349
- message: null,
350
- },
351
- },
352
- },
353
- },
354
- });
355
-
356
- expect(runtime.recordTaskRunProgressByRunId).toHaveBeenCalledWith({
357
- runId: "codex-thread:child-thread",
358
- runtime: "subagent",
359
- lastEventAt: 46_000,
360
- progressSummary: "Codex native subagent is initializing.",
361
- });
362
- expect(runtime.finalizeTaskRunByRunId).not.toHaveBeenCalled();
363
- });
364
-
365
- it("does not treat failed non-spawn tool calls as failed subagents", () => {
366
- const runtime = createRuntime();
367
- const mirror = new CodexNativeSubagentTaskMirror(
368
- {
369
- parentThreadId: "parent-thread",
370
- requesterSessionKey: "agent:main:main",
371
- now: () => 47_000,
372
- },
373
- runtime,
374
- );
375
-
376
- mirror.handleNotification({
377
- method: "item/completed",
378
- params: {
379
- item: {
380
- type: "collabAgentToolCall",
381
- tool: "wait",
382
- status: "failed",
383
- senderThreadId: "parent-thread",
384
- receiverThreadIds: [],
385
- agentsStates: {
386
- "child-thread": {
387
- status: "running",
388
- message: "wait timed out",
389
- },
390
- },
391
- },
392
- },
393
- });
394
-
395
- expect(runtime.recordTaskRunProgressByRunId).toHaveBeenCalledWith({
396
- runId: "codex-thread:child-thread",
397
- runtime: "subagent",
398
- lastEventAt: 47_000,
399
- progressSummary: "wait timed out",
400
- });
401
- expect(runtime.finalizeTaskRunByRunId).not.toHaveBeenCalled();
402
- });
403
-
404
- it("preserves a completed collab agent message when the thread later goes idle", () => {
405
- const runtime = createRuntime();
406
- const mirror = new CodexNativeSubagentTaskMirror(
407
- {
408
- parentThreadId: "parent-thread",
409
- requesterSessionKey: "agent:main:main",
410
- now: () => 50_000,
411
- },
412
- runtime,
413
- );
414
-
415
- mirror.handleNotification({
416
- method: "item/completed",
417
- params: {
418
- item: {
419
- type: "collabAgentToolCall",
420
- tool: "spawnAgent",
421
- senderThreadId: "parent-thread",
422
- receiverThreadIds: ["child-thread"],
423
- prompt: "write the proof file",
424
- agentsStates: {
425
- "child-thread": {
426
- status: "completed",
427
- message: "No user task is specified.",
428
- },
429
- },
430
- },
431
- },
432
- });
433
- mirror.handleNotification({
434
- method: "thread/status/changed",
435
- params: {
436
- threadId: "child-thread",
437
- status: { type: "idle" },
438
- },
439
- });
440
-
441
- expect(runtime.finalizeTaskRunByRunId).toHaveBeenCalledTimes(1);
442
- expect(runtime.finalizeTaskRunByRunId).toHaveBeenCalledWith({
443
- runId: "codex-thread:child-thread",
444
- runtime: "subagent",
445
- status: "succeeded",
446
- endedAt: 50_000,
447
- lastEventAt: 50_000,
448
- progressSummary: "No user task is specified.",
449
- terminalSummary: "No user task is specified.",
450
- });
451
- });
452
-
453
- it("lets terminal collab agent state correct an earlier idle thread status", () => {
454
- const runtime = createRuntime();
455
- const mirror = new CodexNativeSubagentTaskMirror(
456
- {
457
- parentThreadId: "parent-thread",
458
- requesterSessionKey: "agent:main:main",
459
- now: () => 55_000,
460
- },
461
- runtime,
462
- );
463
-
464
- mirror.handleNotification({
465
- method: "thread/status/changed",
466
- params: {
467
- threadId: "child-thread",
468
- status: { type: "idle" },
469
- },
470
- });
471
- mirror.handleNotification({
472
- method: "item/completed",
473
- params: {
474
- item: {
475
- type: "collabAgentToolCall",
476
- tool: "spawnAgent",
477
- status: "failed",
478
- senderThreadId: "parent-thread",
479
- receiverThreadIds: ["child-thread"],
480
- prompt: "read cwd",
481
- agentsStates: {
482
- "child-thread": {
483
- status: "pendingInit",
484
- message: "Native hook relay unavailable",
485
- },
486
- },
487
- },
488
- },
489
- });
490
-
491
- expect(runtime.finalizeTaskRunByRunId).toHaveBeenNthCalledWith(1, {
492
- runId: "codex-thread:child-thread",
493
- runtime: "subagent",
494
- status: "succeeded",
495
- endedAt: 55_000,
496
- lastEventAt: 55_000,
497
- progressSummary: "Codex native subagent is idle.",
498
- terminalSummary: "Codex native subagent finished.",
499
- });
500
- expect(runtime.finalizeTaskRunByRunId).toHaveBeenNthCalledWith(2, {
501
- runId: "codex-thread:child-thread",
502
- runtime: "subagent",
503
- status: "failed",
504
- endedAt: 55_000,
505
- lastEventAt: 55_000,
506
- error: "Native hook relay unavailable",
507
- progressSummary: "Native hook relay unavailable",
508
- terminalSummary: "Native hook relay unavailable",
509
- });
510
- });
511
-
512
- it("normalizes collab agent status spelling from alternate event surfaces", () => {
513
- const runtime = createRuntime();
514
- const mirror = new CodexNativeSubagentTaskMirror(
515
- {
516
- parentThreadId: "parent-thread",
517
- requesterSessionKey: "agent:main:main",
518
- now: () => 60_000,
519
- },
520
- runtime,
521
- );
522
-
523
- mirror.handleNotification({
524
- method: "item/completed",
525
- params: {
526
- item: {
527
- type: "collabAgentToolCall",
528
- tool: "spawnAgent",
529
- senderThreadId: "parent-thread",
530
- receiverThreadIds: ["child-thread"],
531
- agentsStates: {
532
- "child-thread": {
533
- status: "pending_init",
534
- message: null,
535
- },
536
- },
537
- },
538
- },
539
- });
540
- mirror.handleNotification({
541
- method: "item/completed",
542
- params: {
543
- item: {
544
- type: "collabAgentToolCall",
545
- tool: "wait",
546
- senderThreadId: "parent-thread",
547
- agentsStates: {
548
- "child-thread": {
549
- status: "success",
550
- message: "done",
551
- },
552
- },
553
- },
554
- },
555
- });
556
-
557
- expect(runtime.recordTaskRunProgressByRunId).toHaveBeenCalledWith({
558
- runId: "codex-thread:child-thread",
559
- runtime: "subagent",
560
- lastEventAt: 60_000,
561
- progressSummary: "Codex native subagent is initializing.",
562
- });
563
- expect(runtime.finalizeTaskRunByRunId).toHaveBeenCalledWith({
564
- runId: "codex-thread:child-thread",
565
- runtime: "subagent",
566
- status: "succeeded",
567
- endedAt: 60_000,
568
- lastEventAt: 60_000,
569
- progressSummary: "done",
570
- terminalSummary: "done",
571
- });
572
- });
573
- });