

























@@ -151,6 +151,17 @@ type MockNodeInvokeParams = {
151151params?: Record<string, unknown>;
152152};
153153154+function expectSystemRunInvoke(params: { invokeTimeoutMs: number; runTimeoutMs: number }) {
155+expect(callGatewayToolMock).toHaveBeenCalledWith(
156+"node.invoke",
157+expect.objectContaining({ timeoutMs: params.invokeTimeoutMs }),
158+expect.objectContaining({
159+command: "system.run",
160+params: expect.objectContaining({ timeoutMs: params.runTimeoutMs }),
161+}),
162+);
163+}
164+154165describe("executeNodeHostCommand", () => {
155166beforeAll(async () => {
156167({ executeNodeHostCommand } = await import("./bash-tools.exec-host-node.js"));
@@ -276,13 +287,14 @@ describe("executeNodeHostCommand", () => {
276287expect(callGatewayToolMock).toHaveBeenNthCalledWith(
2772883,
278289"node.invoke",
279-expect.anything(),
290+expect.objectContaining({ timeoutMs: 35_000 }),
280291expect.objectContaining({
281292command: "system.run",
282293params: expect.objectContaining({
283294approved: true,
284295approvalDecision: "allow-once",
285296systemRunPlan: preparedPlan,
297+timeoutMs: 30_000,
286298}),
287299}),
288300);
@@ -365,13 +377,14 @@ describe("executeNodeHostCommand", () => {
365377expect(callGatewayToolMock).toHaveBeenCalledTimes(1);
366378expect(callGatewayToolMock).toHaveBeenCalledWith(
367379"node.invoke",
368-expect.anything(),
380+expect.objectContaining({ timeoutMs: 35_000 }),
369381expect.objectContaining({
370382command: "system.run",
371383params: expect.objectContaining({
372384command: ["bash", "-lc", "bun ./script.ts"],
373385rawCommand: "bun ./script.ts",
374386suppressNotifyOnExit: true,
387+timeoutMs: 30_000,
375388}),
376389}),
377390);
@@ -386,6 +399,42 @@ describe("executeNodeHostCommand", () => {
386399);
387400});
388401402+it("forwards explicit timeouts to node system.run", async () => {
403+await executeNodeHostCommand({
404+command: "bun ./script.ts",
405+workdir: "/tmp/work",
406+env: {},
407+security: "full",
408+ask: "off",
409+timeoutSec: 12,
410+defaultTimeoutSec: 30,
411+approvalRunningNoticeMs: 0,
412+warnings: [],
413+agentId: "requested-agent",
414+sessionKey: "requested-session",
415+});
416+417+expectSystemRunInvoke({ invokeTimeoutMs: 17_000, runTimeoutMs: 12_000 });
418+});
419+420+it("forwards timeout zero to node system.run and keeps the invoke wait bounded", async () => {
421+await executeNodeHostCommand({
422+command: "bun ./script.ts",
423+workdir: "/tmp/work",
424+env: {},
425+security: "full",
426+ask: "off",
427+timeoutSec: 0,
428+defaultTimeoutSec: 30,
429+approvalRunningNoticeMs: 0,
430+warnings: [],
431+agentId: "requested-agent",
432+sessionKey: "requested-session",
433+});
434+435+expectSystemRunInvoke({ invokeTimeoutMs: 35_000, runTimeoutMs: 0 });
436+});
437+389438it("denies timed-out inline-eval requests instead of invoking the node", async () => {
390439detectInterpreterInlineEvalArgvMock.mockReturnValue(INLINE_EVAL_HIT);
391440resolveApprovalDecisionOrUndefinedMock.mockResolvedValue(null);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。