@agentrq/acp-gateway 0.2.14 → 0.2.16

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.
@@ -1 +1 @@
1
- {"version":3,"file":"agentInfo.test.js","sourceRoot":"","sources":["../../src/__tests__/agentInfo.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,yBAAyB,EACzB,aAAa,EACb,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAEzB,4EAA4E;AAC5E,SAAS,UAAU,CAAC,SAAS,GAA4B,EAAE;IACzD,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,GAAG,SAAS,EAAE,CAAC;AAC9C,CAAC;AAED,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,IAAI,GAAG,iBAAiB,CAC5B,UAAU,CAAC;YACT,SAAS,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,OAAO,EAAE;SACtF,CAAC,EACF,mBAAmB,CACpB,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;IACjF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,IAAI,GAAG,iBAAiB,CAC5B,UAAU,CAAC,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,EAC9D,cAAc,CACf,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ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A"}
@@ -4,7 +4,8 @@ import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import { EventEmitter } from "node:events";
6
6
  import * as acp from "@agentclientprotocol/sdk";
7
- import { createAcpSessionSwitcher, checkForNextTask, mapMcpServers, TaskQueue, getOrCreateSession, activeSessions, authConfig, modelConfig, createSessionWithAuth, isInteractiveTerminal, openAgentConnection, parseGatewayArgs, assertAgentRunnable, helpText, isRunnable, resolveOnPath, spawnTarget, needsShell, escapeCmdCommand, quoteForCmd, spawnArgsFor, terminateAgentProcess, printHelp, resolveAgentCommand, runListAgents, pickHumanApprovalMode, enforceHumanApprovalMode, handleAgentModeChange, runAgentCommand, findActiveSession, handleTaskCancellation, cancelledTaskSeq, markTaskCancelled, isTaskCancelled, nextTaskSeq, supportsCloseSession, closeSession, closeAllSessions, setupSignalHandlers, } from "../index.js";
7
+ import { createAcpSessionSwitcher, checkForNextTask, mapMcpServers, TaskQueue, getOrCreateSession, openIdleSession, resetIdleSession, activeSessions, AuthenticationFailed, IDLE_SESSION_KEY, loginCommandFor, authConfig, modelConfig, createSessionWithAuth, isInteractiveTerminal, openAgentConnection, parseGatewayArgs, assertAgentRunnable, helpText, isRunnable, resolveOnPath, spawnTarget, needsShell, escapeCmdCommand, quoteForCmd, spawnArgsFor, terminateAgentProcess, printHelp, resolveAgentCommand, runListAgents, pickHumanApprovalMode, enforceHumanApprovalMode, handleAgentModeChange, runAgentCommand, findActiveSession, handleTaskCancellation, handleSetModel, applyModelSelection, cancelledTaskSeq, markTaskCancelled, isTaskCancelled, nextTaskSeq, supportsCloseSession, closeSession, closeAllSessions, setupSignalHandlers, } from "../index.js";
8
+ import { sendModelsNotification } from "../acpClient.js";
8
9
  import { AUTH_REQUIRED_CODE } from "../auth.js";
9
10
  /**
10
11
  * A stand-in for the workspace bridge.
@@ -34,6 +35,12 @@ vi.mock("node:child_process", async () => {
34
35
  }),
35
36
  };
36
37
  });
38
+ /** Lets a test make the next `session/new` fail, e.g. with auth_required. */
39
+ const { newSessionError, newSessionHangs } = vi.hoisted(() => ({
40
+ newSessionError: { value: null },
41
+ /** Lets a test make `session/new` never answer, like an agent gone quiet. */
42
+ newSessionHangs: { value: false },
43
+ }));
37
44
  vi.mock("@agentclientprotocol/sdk", async () => {
38
45
  const actual = await vi.importActual("@agentclientprotocol/sdk");
39
46
  return {
@@ -41,7 +48,13 @@ vi.mock("@agentclientprotocol/sdk", async () => {
41
48
  ClientSideConnection: vi.fn().mockImplementation(function () {
42
49
  return {
43
50
  initialize: vi.fn().mockResolvedValue({ protocolVersion: "0.1.0" }),
44
- newSession: vi.fn().mockResolvedValue({ sessionId: "test-sess-123" }),
51
+ newSession: vi.fn().mockImplementation(async () => {
52
+ if (newSessionHangs.value)
53
+ return new Promise(() => { });
54
+ if (newSessionError.value)
55
+ throw newSessionError.value;
56
+ return { sessionId: "test-sess-123" };
57
+ }),
45
58
  prompt: vi.fn().mockResolvedValue({ stopReason: "complete" }),
46
59
  };
47
60
  }),
@@ -395,6 +408,9 @@ describe("index", () => {
395
408
  describe("getOrCreateSession", () => {
396
409
  beforeEach(() => {
397
410
  activeSessions.clear();
411
+ resetIdleSession();
412
+ newSessionError.value = null;
413
+ newSessionHangs.value = false;
398
414
  });
399
415
  it("should spawn a new session when not cached", async () => {
400
416
  const mockBridge = fakeBridge();
@@ -405,6 +421,138 @@ describe("index", () => {
405
421
  expect(session.sessionId).toBe("test-sess-123");
406
422
  expect(activeSessions.has("T-New")).toBe(true);
407
423
  });
424
+ it("files a session opened with no task under the idle key", async () => {
425
+ // This is the session the gateway opens at startup so a workspace can say
426
+ // what its agent offers before any work arrives.
427
+ const mockBridge = fakeBridge();
428
+ const session = await getOrCreateSession(undefined, ["node", "agent.js"], [], { env: {} }, mockBridge);
429
+ expect(session).toBeDefined();
430
+ expect(activeSessions.has(IDLE_SESSION_KEY)).toBe(true);
431
+ });
432
+ it("hands the startup session to the first task rather than opening a second", async () => {
433
+ // Sessions are keyed by task, so without this the first real task would
434
+ // spawn a second agent alongside the one already running.
435
+ const mockBridge = fakeBridge();
436
+ const idle = await getOrCreateSession(undefined, ["node", "agent.js"], [], { env: {} }, mockBridge);
437
+ const forTask = await getOrCreateSession("T-First", ["node", "agent.js"], [], { env: {} }, mockBridge);
438
+ expect(forTask).toBe(idle);
439
+ expect(activeSessions.has("T-First")).toBe(true);
440
+ expect(activeSessions.has(IDLE_SESSION_KEY)).toBe(false);
441
+ expect(activeSessions.size).toBe(1);
442
+ });
443
+ it("attributes what an adopted session reports to the task that took it", async () => {
444
+ // Everything the session says afterwards — models, commands, replies —
445
+ // belongs to that task, so the task id has to follow the adoption.
446
+ const mockBridge = fakeBridge();
447
+ const idle = await getOrCreateSession(undefined, ["node", "agent.js"], [], { env: {} }, mockBridge);
448
+ mockBridge.sendNotification.mockClear();
449
+ await getOrCreateSession("T-Owner", ["node", "agent.js"], [], { env: {} }, mockBridge);
450
+ await idle.acpClient.sendCommandsToWorkspace(idle.sessionId, [{ name: "init", description: "d" }]);
451
+ expect(mockBridge.sendNotification).toHaveBeenCalledWith("notifications/claude/channel/commands", expect.objectContaining({ task_id: "T-Owner" }));
452
+ });
453
+ it("gives a second task its own session, having only one to hand over", async () => {
454
+ const mockBridge = fakeBridge();
455
+ await getOrCreateSession(undefined, ["node", "agent.js"], [], { env: {} }, mockBridge);
456
+ const first = await getOrCreateSession("T-A", ["node", "agent.js"], [], { env: {} }, mockBridge);
457
+ const second = await getOrCreateSession("T-B", ["node", "agent.js"], [], { env: {} }, mockBridge);
458
+ expect(second).not.toBe(first);
459
+ expect(activeSessions.has("T-A")).toBe(true);
460
+ expect(activeSessions.has("T-B")).toBe(true);
461
+ });
462
+ it("opens the idle session at startup", async () => {
463
+ const mockBridge = fakeBridge();
464
+ await openIdleSession(["node", "agent.js"], [], { env: {} }, mockBridge);
465
+ expect(activeSessions.has(IDLE_SESSION_KEY)).toBe(true);
466
+ });
467
+ it("never fails when the agent cannot be started", async () => {
468
+ // The safety property of the whole change: a broken agent used to fail
469
+ // when the first task arrived, and it still must. Failing at startup
470
+ // would turn it into a gateway that will not run at all.
471
+ const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => { });
472
+ const mockBridge = fakeBridge();
473
+ newSessionError.value = new Error("agent will not start");
474
+ // Survivable: it says the gateway can carry on, and the first task retries.
475
+ await expect(openIdleSession(["node", "agent.js"], [], { env: {} }, mockBridge)).resolves.toBe("unknown");
476
+ expect(activeSessions.has(IDLE_SESSION_KEY)).toBe(false);
477
+ expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("the first task will start one"), expect.anything());
478
+ consoleSpy.mockRestore();
479
+ });
480
+ it("reports that the gateway cannot continue when the agent is unauthenticated", async () => {
481
+ // Carrying on would leave the workspace showing a live agent that fails
482
+ // every task it is given, which is worse than not running at all.
483
+ const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => { });
484
+ const mockBridge = fakeBridge();
485
+ newSessionError.value = { code: -32000, data: { authRequired: true }, message: "auth_required" };
486
+ const outcome = await openIdleSession(["node", "agent.js"], [], { env: {} }, mockBridge);
487
+ expect(outcome).toBe("unauthenticated");
488
+ expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("until it is authenticated"));
489
+ expect(activeSessions.has(IDLE_SESSION_KEY)).toBe(false);
490
+ // Nothing was claimed about an agent that never started.
491
+ expect(mockBridge.sendNotification).not.toHaveBeenCalledWith("notifications/claude/channel/models", expect.anything());
492
+ consoleSpy.mockRestore();
493
+ });
494
+ it("shuts down when the login itself went wrong", async () => {
495
+ // A terminal login the human abandoned, a login subcommand exiting
496
+ // non-zero, no usable method on a headless run: all of them come back as
497
+ // AuthenticationFailed, so none of them has to be recognised by its
498
+ // message. The conclusion is the same — an agent that cannot authenticate
499
+ // cannot work.
500
+ const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => { });
501
+ const mockBridge = fakeBridge();
502
+ newSessionError.value = new AuthenticationFailed(new Error('Terminal login "oauth" failed (code=1, signal=null).'));
503
+ const outcome = await openIdleSession(["node", "agent.js"], [], { env: {} }, mockBridge);
504
+ expect(outcome).toBe("unauthenticated");
505
+ expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("npx @agentrq/acp-gateway@latest --login"));
506
+ consoleSpy.mockRestore();
507
+ });
508
+ it("tells the owner of an API-key agent to set the key, not to log in", async () => {
509
+ // Plenty of agents never ask anyone to log in — they read a key from the
510
+ // environment. When one of those refuses, sending its owner looking for a
511
+ // login prompt that does not exist is worse than saying nothing.
512
+ const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => { });
513
+ const mockBridge = fakeBridge();
514
+ newSessionError.value = new AuthenticationFailed(new Error("auth_required"), false);
515
+ const outcome = await openIdleSession(["node", "agent.js"], [], { env: {} }, mockBridge);
516
+ expect(outcome).toBe("unauthenticated");
517
+ expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("expecting a credential of its own"));
518
+ expect(consoleSpy).not.toHaveBeenCalledWith(expect.stringContaining("--login"));
519
+ consoleSpy.mockRestore();
520
+ });
521
+ it("gives up waiting on an agent that never opens a session", async () => {
522
+ // Nothing reaches the workspace until this settles, so an agent that
523
+ // spawns and then goes quiet would otherwise take the whole gateway with
524
+ // it — a worse failure than the one the startup session fixes.
525
+ const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => { });
526
+ const mockBridge = fakeBridge();
527
+ newSessionHangs.value = true;
528
+ const outcome = await openIdleSession(["node", "agent.js"], [], { env: {} }, mockBridge, loginCommandFor("some-agent"), 20);
529
+ expect(outcome).toBe("unknown");
530
+ expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("has not opened a session"));
531
+ consoleSpy.mockRestore();
532
+ });
533
+ it("keeps running when the agent merely failed to start", async () => {
534
+ // Not the same thing at all: that may have been a race, it used to fail
535
+ // when the first task arrived, and it still should.
536
+ const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => { });
537
+ const mockBridge = fakeBridge();
538
+ newSessionError.value = new Error("spawn ENOENT");
539
+ const outcome = await openIdleSession(["node", "agent.js"], [], { env: {} }, mockBridge);
540
+ // Survivable, so the gateway keeps running.
541
+ expect(outcome).toBe("unknown");
542
+ expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("the first task will start one"), expect.anything());
543
+ consoleSpy.mockRestore();
544
+ });
545
+ it("makes a task wait for a startup session still coming up, rather than starting a second agent", async () => {
546
+ // Opening one can take a long time when an agent wants a human to log in,
547
+ // and a task arriving in that window used to find nothing cached.
548
+ const mockBridge = fakeBridge();
549
+ const startup = openIdleSession(["node", "agent.js"], [], { env: {} }, mockBridge);
550
+ const forTask = getOrCreateSession("T-Racer", ["node", "agent.js"], [], { env: {} }, mockBridge);
551
+ await startup;
552
+ const session = await forTask;
553
+ expect(activeSessions.size).toBe(1);
554
+ expect(activeSessions.get("T-Racer")).toBe(session);
555
+ });
408
556
  it("should return cached session when already created", async () => {
409
557
  const mockBridge = fakeBridge();
410
558
  const configs = [];
@@ -849,6 +997,20 @@ describe("index", () => {
849
997
  // gets its own: two backslashes and a quote need five and a quote.
850
998
  expect(quoteForCmd('a\\\\"b')).toBe('^"a\\\\\\\\\\^"b^"');
851
999
  });
1000
+ it("stays fast on a long run of backslashes", () => {
1001
+ // The two regexes this replaced asked for a run of backslashes followed
1002
+ // by a quote, so a long run with no quote after it was re-tried from
1003
+ // every position in the run. 50k backslashes took long enough to matter;
1004
+ // counting the run once does not care.
1005
+ const run = "\\".repeat(50_000);
1006
+ const started = Date.now();
1007
+ const quoted = quoteForCmd(run);
1008
+ const elapsed = Date.now() - started;
1009
+ // Untouched, because nothing follows them but the closing quote — which
1010
+ // is exactly the case that doubles them.
1011
+ expect(quoted).toBe(`^"${"\\".repeat(100_000)}^"`);
1012
+ expect(elapsed).toBeLessThan(1_000);
1013
+ });
852
1014
  });
853
1015
  describe("spawnArgsFor", () => {
854
1016
  it("passes the command through when no shell is involved", () => {
@@ -987,6 +1149,35 @@ describe("index", () => {
987
1149
  expect(resolved.command.slice(1)).toEqual(["-y", "@google/gemini-cli@0.58.0", "--acp"]);
988
1150
  expect(resolved.env).toEqual({ K: "v" });
989
1151
  });
1152
+ it("reports who the registry says the agent is, before it has been started", async () => {
1153
+ // This is the only name available while the gateway is idle: the agent
1154
+ // itself does not speak until a task starts it, and until then a
1155
+ // workspace can only see the gateway.
1156
+ const errorSpy = vi.spyOn(console, "error").mockImplementation(() => { });
1157
+ const fetchImpl = vi.fn().mockResolvedValue({
1158
+ ok: true,
1159
+ json: async () => ({
1160
+ version: "1.0.0",
1161
+ agents: [
1162
+ {
1163
+ id: "antigravity-acp",
1164
+ name: "Google Antigravity",
1165
+ version: "1.1.1",
1166
+ description: "…",
1167
+ distribution: { npx: { package: "antigravity-acp@1.1.1", args: [] } },
1168
+ },
1169
+ ],
1170
+ }),
1171
+ });
1172
+ const resolved = await resolveAgentCommand(options({ agentId: "antigravity-acp" }), [], fetchImpl);
1173
+ errorSpy.mockRestore();
1174
+ expect(resolved.identity).toEqual({ name: "Google Antigravity", version: "1.1.1" });
1175
+ });
1176
+ it("has no identity to report for a command given after --", async () => {
1177
+ // Nothing named it, so there is nothing to say until the agent does.
1178
+ const resolved = await resolveAgentCommand(options(), ["gemini", "--acp"], vi.fn());
1179
+ expect(resolved.identity).toBeUndefined();
1180
+ });
990
1181
  it("should surface a registry id that does not exist", async () => {
991
1182
  const fetchImpl = vi.fn().mockResolvedValue({
992
1183
  ok: true,
@@ -1457,6 +1648,209 @@ describe("index", () => {
1457
1648
  });
1458
1649
  });
1459
1650
  });
1651
+ describe("choosing a model at runtime", () => {
1652
+ // Everything here rests on one contract: the interface marks a chosen model
1653
+ // pending and only a models notification releases it. So every path has to
1654
+ // end in a report — including the ones that fail — or the picker is left
1655
+ // claiming a model the agent never adopted, with nothing to correct it.
1656
+ beforeEach(() => {
1657
+ activeSessions.clear();
1658
+ });
1659
+ afterEach(() => {
1660
+ activeSessions.clear();
1661
+ });
1662
+ const known = {
1663
+ configId: "model",
1664
+ currentModelId: "a",
1665
+ models: [
1666
+ { id: "a", name: "Model A", current: true },
1667
+ { id: "b", name: "Model B", current: false },
1668
+ ],
1669
+ };
1670
+ /** A session whose ACP set succeeds, reporting the new list back. */
1671
+ const sessionThatSwitches = () => {
1672
+ const sendModelsToWorkspace = vi.fn();
1673
+ const setSessionConfigOption = vi.fn().mockResolvedValue({
1674
+ configOptions: [
1675
+ {
1676
+ id: "model",
1677
+ type: "select",
1678
+ category: "model",
1679
+ currentValue: "b",
1680
+ options: [
1681
+ { value: "a", name: "Model A" },
1682
+ { value: "b", name: "Model B" },
1683
+ ],
1684
+ },
1685
+ ],
1686
+ });
1687
+ const session = {
1688
+ sessionId: "sess-1",
1689
+ connection: { setSessionConfigOption },
1690
+ acpClient: { sendModelsToWorkspace, lastModelsFor: () => known },
1691
+ };
1692
+ return { session, sendModelsToWorkspace, setSessionConfigOption };
1693
+ };
1694
+ it("switches the named session and reports what the agent ended up on", async () => {
1695
+ const { session, sendModelsToWorkspace, setSessionConfigOption } = sessionThatSwitches();
1696
+ activeSessions.set("task-1", session);
1697
+ await handleSetModel({ sessionId: "sess-1", configId: "model", modelId: "b" });
1698
+ expect(setSessionConfigOption).toHaveBeenCalledWith({
1699
+ sessionId: "sess-1",
1700
+ configId: "model",
1701
+ value: "b",
1702
+ });
1703
+ // The agent's own answer, not the id that was asked for.
1704
+ expect(sendModelsToWorkspace).toHaveBeenCalledWith("sess-1", expect.objectContaining({ currentModelId: "b" }));
1705
+ });
1706
+ it("puts back what was true when the agent refuses the switch", async () => {
1707
+ const sendModelsToWorkspace = vi.fn();
1708
+ const session = {
1709
+ sessionId: "sess-1",
1710
+ connection: {
1711
+ setSessionConfigOption: vi.fn().mockRejectedValue(new Error("nope")),
1712
+ },
1713
+ acpClient: { sendModelsToWorkspace, lastModelsFor: () => known },
1714
+ };
1715
+ activeSessions.set("task-1", session);
1716
+ await handleSetModel({ sessionId: "sess-1", configId: "model", modelId: "b" });
1717
+ // Still on "a": the picker reverts instead of hanging on "b" forever.
1718
+ expect(sendModelsToWorkspace).toHaveBeenCalledWith("sess-1", expect.objectContaining({ currentModelId: "a" }));
1719
+ });
1720
+ it("does not throw when no session matches", async () => {
1721
+ // The session went away between the human clicking and this arriving.
1722
+ await expect(handleSetModel({ sessionId: "sess-gone", configId: "model", modelId: "b" })).resolves.toBeUndefined();
1723
+ });
1724
+ it("answers for a session that has already ended", async () => {
1725
+ // The agent exited, taking its client with it, so there is nothing left to
1726
+ // set. The picker is still holding a pending model, so what was last true
1727
+ // for that session goes out over the bridge to release it.
1728
+ const sendNotification = vi.fn().mockResolvedValue(undefined);
1729
+ await sendModelsNotification({ sendNotification }, "sess-ended", known);
1730
+ sendNotification.mockClear();
1731
+ await handleSetModel({ sessionId: "sess-ended", configId: "model", modelId: "b" }, { sendNotification });
1732
+ expect(sendNotification).toHaveBeenCalledWith("notifications/claude/channel/models", expect.objectContaining({ session_id: "sess-ended", current_model: "a" }));
1733
+ });
1734
+ it("stays quiet about a set that names no session and matches none", async () => {
1735
+ // With no id and nothing running there is nothing to identify, let alone
1736
+ // report on.
1737
+ const sendNotification = vi.fn().mockResolvedValue(undefined);
1738
+ await handleSetModel({ configId: "model", modelId: "b" }, { sendNotification });
1739
+ expect(sendNotification).not.toHaveBeenCalled();
1740
+ });
1741
+ it("stays quiet about a session it has never heard of", async () => {
1742
+ // Nothing was ever reported for it, so there is no truth to put back and
1743
+ // inventing one would be worse than the silence.
1744
+ const sendNotification = vi.fn().mockResolvedValue(undefined);
1745
+ await handleSetModel({ sessionId: "sess-never-seen", configId: "model", modelId: "b" }, { sendNotification });
1746
+ expect(sendNotification).not.toHaveBeenCalled();
1747
+ });
1748
+ it("answers a notification naming no model instead of ignoring it", async () => {
1749
+ const { session, sendModelsToWorkspace, setSessionConfigOption } = sessionThatSwitches();
1750
+ activeSessions.set("task-1", session);
1751
+ await handleSetModel({ sessionId: "sess-1", configId: "model" });
1752
+ expect(setSessionConfigOption).not.toHaveBeenCalled();
1753
+ // A malformed notification is still a pending picker on the other end.
1754
+ expect(sendModelsToWorkspace).toHaveBeenCalledWith("sess-1", known);
1755
+ });
1756
+ it("refuses a model the session never advertised, and says what it has", async () => {
1757
+ const { session, sendModelsToWorkspace, setSessionConfigOption } = sessionThatSwitches();
1758
+ activeSessions.set("task-1", session);
1759
+ await handleSetModel({ sessionId: "sess-1", configId: "model", modelId: "not-a-model" });
1760
+ expect(setSessionConfigOption).not.toHaveBeenCalled();
1761
+ expect(sendModelsToWorkspace).toHaveBeenCalledWith("sess-1", known);
1762
+ });
1763
+ it("reports without asking the agent when the model is already current", async () => {
1764
+ const { session, sendModelsToWorkspace, setSessionConfigOption } = sessionThatSwitches();
1765
+ activeSessions.set("task-1", session);
1766
+ await handleSetModel({ sessionId: "sess-1", configId: "model", modelId: "a" });
1767
+ expect(setSessionConfigOption).not.toHaveBeenCalled();
1768
+ expect(sendModelsToWorkspace).toHaveBeenCalledWith("sess-1", known);
1769
+ });
1770
+ it("resolves a model by display name, for a --model typed by a human", async () => {
1771
+ const { session, setSessionConfigOption } = sessionThatSwitches();
1772
+ await applyModelSelection({
1773
+ connection: session.connection,
1774
+ acpClient: session.acpClient,
1775
+ sessionId: "sess-1",
1776
+ known,
1777
+ requested: "Model B",
1778
+ });
1779
+ expect(setSessionConfigOption).toHaveBeenCalledWith({
1780
+ sessionId: "sess-1",
1781
+ configId: "model",
1782
+ value: "b",
1783
+ });
1784
+ });
1785
+ it("marks the chosen model current when the agent answers without its config", async () => {
1786
+ // Some agents acknowledge the write without repeating their options. The
1787
+ // interface still has to end up with something selected.
1788
+ const sendModelsToWorkspace = vi.fn();
1789
+ const acpClient = { sendModelsToWorkspace, lastModelsFor: () => known };
1790
+ await applyModelSelection({
1791
+ connection: { setSessionConfigOption: vi.fn().mockResolvedValue({}) },
1792
+ acpClient,
1793
+ sessionId: "sess-1",
1794
+ known,
1795
+ requested: "b",
1796
+ });
1797
+ expect(sendModelsToWorkspace).toHaveBeenCalledWith("sess-1", expect.objectContaining({
1798
+ currentModelId: "b",
1799
+ models: [
1800
+ expect.objectContaining({ id: "a", current: false }),
1801
+ expect.objectContaining({ id: "b", current: true }),
1802
+ ],
1803
+ }));
1804
+ });
1805
+ it("puts back the newest report, not the snapshot taken before the set", async () => {
1806
+ // The agent moved to "c" on its own while the set was in flight, and then
1807
+ // refused the set. Reverting to the pre-set snapshot would claim the
1808
+ // session is on "a" — a model it has already left — and, since every
1809
+ // report is recorded, would write that stale list back over the newer one.
1810
+ const fresher = {
1811
+ configId: "model",
1812
+ currentModelId: "c",
1813
+ models: [{ id: "c", name: "Model C", current: true }],
1814
+ };
1815
+ const sendModelsToWorkspace = vi.fn();
1816
+ await applyModelSelection({
1817
+ connection: {
1818
+ setSessionConfigOption: vi.fn().mockRejectedValue(new Error("nope")),
1819
+ },
1820
+ acpClient: { sendModelsToWorkspace, lastModelsFor: () => fresher },
1821
+ sessionId: "sess-1",
1822
+ known,
1823
+ requested: "b",
1824
+ });
1825
+ expect(sendModelsToWorkspace).toHaveBeenCalledWith("sess-1", fresher);
1826
+ });
1827
+ it("falls back to the caller's snapshot when nothing has been reported yet", async () => {
1828
+ // The startup path: --model runs against a session that has not sent a
1829
+ // models notification, so the list from session/new is all there is.
1830
+ const sendModelsToWorkspace = vi.fn();
1831
+ await applyModelSelection({
1832
+ connection: {
1833
+ setSessionConfigOption: vi.fn().mockRejectedValue(new Error("nope")),
1834
+ },
1835
+ acpClient: { sendModelsToWorkspace, lastModelsFor: () => undefined },
1836
+ sessionId: "sess-1",
1837
+ known,
1838
+ requested: "b",
1839
+ });
1840
+ expect(sendModelsToWorkspace).toHaveBeenCalledWith("sess-1", known);
1841
+ });
1842
+ it("says so rather than guessing when there is no config option to write to", async () => {
1843
+ const sendModelsToWorkspace = vi.fn();
1844
+ const setSessionConfigOption = vi.fn();
1845
+ await applyModelSelection({
1846
+ connection: { setSessionConfigOption },
1847
+ acpClient: { sendModelsToWorkspace, lastModelsFor: () => undefined },
1848
+ sessionId: "sess-1",
1849
+ requested: "b",
1850
+ });
1851
+ expect(setSessionConfigOption).not.toHaveBeenCalled();
1852
+ });
1853
+ });
1460
1854
  describe("handleAgentModeChange", () => {
1461
1855
  const modes = {
1462
1856
  currentModeId: "ask",
@@ -1712,4 +2106,15 @@ describe("index", () => {
1712
2106
  });
1713
2107
  });
1714
2108
  });
2109
+ describe("loginCommandFor", () => {
2110
+ it("names the agent, so nobody has to work the command out", () => {
2111
+ expect(loginCommandFor("antigravity-acp")).toBe("npx @agentrq/acp-gateway@latest --login --agent antigravity-acp");
2112
+ });
2113
+ it("repeats the command after -- when no registry id named the agent", () => {
2114
+ expect(loginCommandFor(undefined, ["node", "my-agent.js"])).toBe("npx @agentrq/acp-gateway@latest --login -- node my-agent.js");
2115
+ });
2116
+ it("falls back to the bare command when nothing identifies the agent", () => {
2117
+ expect(loginCommandFor()).toBe("npx @agentrq/acp-gateway@latest --login");
2118
+ });
2119
+ });
1715
2120
  //# sourceMappingURL=index.test.js.map