






















@@ -250,6 +250,7 @@ describe("requestExecApprovalDecision", () => {
250250await registerExecApprovalRequestForHost({
251251approvalId: "approval-id",
252252command: 'ls | grep "stuff" | python -c \'print("hi")\'',
253+commandHighlighting: true,
253254workdir: "/tmp/project",
254255host: "node",
255256security: "allowlist",
@@ -264,6 +265,47 @@ describe("requestExecApprovalDecision", () => {
264265expect(payload?.commandSpans).toContainEqual({ startIndex: 20, endIndex: 26 });
265266});
266267268+it("does not generate command spans by default", async () => {
269+vi.mocked(callGatewayTool).mockResolvedValue({ id: "approval-id", expiresAtMs: 1234 });
270+271+await registerExecApprovalRequestForHost({
272+approvalId: "approval-id",
273+command: 'ls | grep "stuff" | python -c \'print("hi")\'',
274+workdir: "/tmp/project",
275+host: "node",
276+security: "allowlist",
277+ask: "always",
278+});
279+280+expect(commandExplainerMock.explainShellCommand).not.toHaveBeenCalled();
281+expect(commandExplainerMock.formatCommandSpans).not.toHaveBeenCalled();
282+const payload = vi.mocked(callGatewayTool).mock.calls[0]?.[2] as
283+| { commandSpans?: unknown }
284+| undefined;
285+expect(payload?.commandSpans).toBeUndefined();
286+});
287+288+it("does not generate command spans when command highlighting is disabled", async () => {
289+vi.mocked(callGatewayTool).mockResolvedValue({ id: "approval-id", expiresAtMs: 1234 });
290+291+await registerExecApprovalRequestForHost({
292+approvalId: "approval-id",
293+command: 'ls | grep "stuff" | python -c \'print("hi")\'',
294+commandHighlighting: false,
295+workdir: "/tmp/project",
296+host: "node",
297+security: "allowlist",
298+ask: "always",
299+});
300+301+expect(commandExplainerMock.explainShellCommand).not.toHaveBeenCalled();
302+expect(commandExplainerMock.formatCommandSpans).not.toHaveBeenCalled();
303+const payload = vi.mocked(callGatewayTool).mock.calls[0]?.[2] as
304+| { commandSpans?: unknown }
305+| undefined;
306+expect(payload?.commandSpans).toBeUndefined();
307+});
308+267309it("uses system run plan command text for host approval explanations", async () => {
268310vi.mocked(callGatewayTool).mockResolvedValue({ id: "approval-id", expiresAtMs: 1234 });
269311@@ -276,6 +318,7 @@ describe("requestExecApprovalDecision", () => {
276318agentId: null,
277319sessionKey: null,
278320},
321+commandHighlighting: true,
279322workdir: "/tmp/project",
280323host: "node",
281324security: "allowlist",
@@ -362,6 +405,7 @@ describe("requestExecApprovalDecision", () => {
362405approvalId: "approval-id",
363406command: "echo hi",
364407commandSpans: [{ startIndex: 0, endIndex: 4 }],
408+commandHighlighting: true,
365409workdir: "/tmp/project",
366410host: "node",
367411security: "allowlist",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。