|
1 | | -import { EventEmitter } from "node:events"; |
2 | 1 | import { describe, expect, it, vi } from "vitest"; |
3 | 2 | import { randomUUID } from "node:crypto"; |
4 | 3 | import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
@@ -206,77 +205,6 @@ describe("classifyCodexStderrLine", () => { |
206 | 205 | message: line, |
207 | 206 | }); |
208 | 207 | }); |
209 | | - |
210 | | - it("emits process/stderr as a notification event", () => { |
211 | | - const manager = new CodexAppServerManager(); |
212 | | - const events: Array<{ method: string; kind: string; message?: string }> = []; |
213 | | - manager.on("event", (event) => { |
214 | | - events.push({ |
215 | | - method: event.method, |
216 | | - kind: event.kind, |
217 | | - ...(event.message ? { message: event.message } : {}), |
218 | | - }); |
219 | | - }); |
220 | | - |
221 | | - const output = new EventEmitter(); |
222 | | - const stderr = new EventEmitter(); |
223 | | - const child = new EventEmitter() as EventEmitter & { stderr: EventEmitter }; |
224 | | - child.stderr = stderr; |
225 | | - |
226 | | - type ProcessListenerHarnessContext = { |
227 | | - session: { |
228 | | - provider: "codex"; |
229 | | - status: "ready"; |
230 | | - threadId: ThreadId; |
231 | | - runtimeMode: "full-access"; |
232 | | - createdAt: string; |
233 | | - updatedAt: string; |
234 | | - }; |
235 | | - child: EventEmitter & { stderr: EventEmitter }; |
236 | | - output: EventEmitter; |
237 | | - pending: Map<string, unknown>; |
238 | | - pendingApprovals: Map<string, unknown>; |
239 | | - pendingUserInputs: Map<string, unknown>; |
240 | | - nextRequestId: number; |
241 | | - stopping: boolean; |
242 | | - }; |
243 | | - |
244 | | - const context: ProcessListenerHarnessContext = { |
245 | | - session: { |
246 | | - provider: "codex" as const, |
247 | | - status: "ready" as const, |
248 | | - threadId: asThreadId("thread-1"), |
249 | | - runtimeMode: "full-access" as const, |
250 | | - createdAt: "2026-02-10T00:00:00.000Z", |
251 | | - updatedAt: "2026-02-10T00:00:00.000Z", |
252 | | - }, |
253 | | - child, |
254 | | - output, |
255 | | - pending: new Map(), |
256 | | - pendingApprovals: new Map(), |
257 | | - pendingUserInputs: new Map(), |
258 | | - nextRequestId: 1, |
259 | | - stopping: false, |
260 | | - }; |
261 | | - |
262 | | - ( |
263 | | - manager as unknown as { |
264 | | - attachProcessListeners: (context: ProcessListenerHarnessContext) => void; |
265 | | - } |
266 | | - ).attachProcessListeners(context); |
267 | | - |
268 | | - const line = |
269 | | - "2026-03-10T01:03:53.921955Z ERROR codex_core::models_manager::manager: failed to renew cache TTL: EOF while parsing a value at line 1 column 0"; |
270 | | - stderr.emit("data", Buffer.from(`${line}\n`)); |
271 | | - |
272 | | - expect(events).toEqual([ |
273 | | - { |
274 | | - method: "process/stderr", |
275 | | - kind: "notification", |
276 | | - message: line, |
277 | | - }, |
278 | | - ]); |
279 | | - }); |
280 | 208 | }); |
281 | 209 |
|
282 | 210 | describe("process stderr events", () => { |
|
0 commit comments