@zvada/agent-server 0.3.27 → 0.3.28

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 (170) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +6 -4
  3. package/dist/core/agents/acp/account.js +111 -0
  4. package/dist/core/agents/acp/acp-agent.js +247 -158
  5. package/dist/core/agents/acp/adapter.js +103 -34
  6. package/dist/core/agents/acp/client.js +169 -42
  7. package/dist/core/agents/acp/known-agents.js +12 -5
  8. package/dist/core/agents/acp/mappings.js +84 -20
  9. package/dist/core/agents/acp/models.js +59 -0
  10. package/dist/core/agents/acp/profile.js +36 -0
  11. package/dist/core/agents/acp/prompts.js +248 -0
  12. package/dist/core/agents/acp/requests.js +4 -4
  13. package/dist/core/agents/claude-code/login.js +4 -1
  14. package/dist/core/agents/claude-code/session.js +38 -10
  15. package/dist/core/agents/claude-code/spawn.js +0 -26
  16. package/dist/core/agents/codex-app-server/client.js +12 -13
  17. package/dist/core/agents/codex-app-server/login.js +4 -1
  18. package/dist/core/agents/gemini/failures.js +133 -0
  19. package/dist/core/agents/gemini/login.js +173 -0
  20. package/dist/core/agents/gemini/profile.js +137 -0
  21. package/dist/core/agents/gemini/tools.js +91 -0
  22. package/dist/core/agents/login.js +8 -6
  23. package/dist/core/agents/stderr-tail.js +5 -2
  24. package/dist/core/presets.js +13 -0
  25. package/dist/core/processes/native-processes.js +23 -1
  26. package/dist/core/provision/install-build.js +70 -26
  27. package/dist/core/provision/pins.js +5 -0
  28. package/dist/core/provision/provisioner.js +39 -16
  29. package/dist/core/provision/releases.js +39 -1
  30. package/dist/core/provision/tools.js +87 -28
  31. package/dist/operator/errors.js +2 -2
  32. package/dist/operator/operator.js +171 -74
  33. package/dist/operator/render.js +33 -25
  34. package/dist/operator/session-tools.js +2 -1
  35. package/dist/protocol/account.js +5 -1
  36. package/dist/protocol/auth.js +5 -1
  37. package/dist/protocol/credentials.js +9 -1
  38. package/dist/protocol/harness.js +9 -1
  39. package/dist/server/bin.js +22 -7
  40. package/dist/server/install.js +6 -4
  41. package/dist/types/core/agents/acp/account.d.ts +55 -0
  42. package/dist/types/core/agents/acp/account.d.ts.map +1 -0
  43. package/dist/types/core/agents/acp/acp-agent.d.ts +65 -36
  44. package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -1
  45. package/dist/types/core/agents/acp/adapter.d.ts +28 -3
  46. package/dist/types/core/agents/acp/adapter.d.ts.map +1 -1
  47. package/dist/types/core/agents/acp/client.d.ts +66 -4
  48. package/dist/types/core/agents/acp/client.d.ts.map +1 -1
  49. package/dist/types/core/agents/acp/known-agents.d.ts +4 -2
  50. package/dist/types/core/agents/acp/known-agents.d.ts.map +1 -1
  51. package/dist/types/core/agents/acp/mappings.d.ts +53 -7
  52. package/dist/types/core/agents/acp/mappings.d.ts.map +1 -1
  53. package/dist/types/core/agents/acp/models.d.ts +22 -0
  54. package/dist/types/core/agents/acp/models.d.ts.map +1 -0
  55. package/dist/types/core/agents/acp/profile.d.ts +92 -0
  56. package/dist/types/core/agents/acp/profile.d.ts.map +1 -0
  57. package/dist/types/core/agents/acp/prompts.d.ts +108 -0
  58. package/dist/types/core/agents/acp/prompts.d.ts.map +1 -0
  59. package/dist/types/core/agents/acp/requests.d.ts +7 -1
  60. package/dist/types/core/agents/acp/requests.d.ts.map +1 -1
  61. package/dist/types/core/agents/claude-code/login.d.ts.map +1 -1
  62. package/dist/types/core/agents/claude-code/session.d.ts +3 -0
  63. package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
  64. package/dist/types/core/agents/claude-code/spawn.d.ts +0 -8
  65. package/dist/types/core/agents/claude-code/spawn.d.ts.map +1 -1
  66. package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -1
  67. package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -1
  68. package/dist/types/core/agents/gemini/failures.d.ts +25 -0
  69. package/dist/types/core/agents/gemini/failures.d.ts.map +1 -0
  70. package/dist/types/core/agents/gemini/login.d.ts +28 -0
  71. package/dist/types/core/agents/gemini/login.d.ts.map +1 -0
  72. package/dist/types/core/agents/gemini/profile.d.ts +30 -0
  73. package/dist/types/core/agents/gemini/profile.d.ts.map +1 -0
  74. package/dist/types/core/agents/gemini/tools.d.ts +18 -0
  75. package/dist/types/core/agents/gemini/tools.d.ts.map +1 -0
  76. package/dist/types/core/agents/login.d.ts +15 -5
  77. package/dist/types/core/agents/login.d.ts.map +1 -1
  78. package/dist/types/core/agents/stderr-tail.d.ts +1 -1
  79. package/dist/types/core/agents/stderr-tail.d.ts.map +1 -1
  80. package/dist/types/core/presets.d.ts +2 -2
  81. package/dist/types/core/presets.d.ts.map +1 -1
  82. package/dist/types/core/processes/native-processes.d.ts +6 -0
  83. package/dist/types/core/processes/native-processes.d.ts.map +1 -1
  84. package/dist/types/core/provision/checksums.d.ts +7 -1
  85. package/dist/types/core/provision/checksums.d.ts.map +1 -1
  86. package/dist/types/core/provision/install-build.d.ts +32 -6
  87. package/dist/types/core/provision/install-build.d.ts.map +1 -1
  88. package/dist/types/core/provision/pins.d.ts +4 -0
  89. package/dist/types/core/provision/pins.d.ts.map +1 -1
  90. package/dist/types/core/provision/provisioner.d.ts +18 -7
  91. package/dist/types/core/provision/provisioner.d.ts.map +1 -1
  92. package/dist/types/core/provision/releases.d.ts +2 -1
  93. package/dist/types/core/provision/releases.d.ts.map +1 -1
  94. package/dist/types/core/provision/tools.d.ts +36 -7
  95. package/dist/types/core/provision/tools.d.ts.map +1 -1
  96. package/dist/types/operator/errors.d.ts +5 -1
  97. package/dist/types/operator/errors.d.ts.map +1 -1
  98. package/dist/types/operator/operator.d.ts.map +1 -1
  99. package/dist/types/operator/render.d.ts +11 -6
  100. package/dist/types/operator/render.d.ts.map +1 -1
  101. package/dist/types/operator/session-tools.d.ts.map +1 -1
  102. package/dist/types/operator/types.d.ts +1 -0
  103. package/dist/types/operator/types.d.ts.map +1 -1
  104. package/dist/types/protocol/account.d.ts +4 -2
  105. package/dist/types/protocol/account.d.ts.map +1 -1
  106. package/dist/types/protocol/auth.d.ts +10 -7
  107. package/dist/types/protocol/auth.d.ts.map +1 -1
  108. package/dist/types/protocol/clis.d.ts +4 -3
  109. package/dist/types/protocol/clis.d.ts.map +1 -1
  110. package/dist/types/protocol/config.d.ts +2 -0
  111. package/dist/types/protocol/config.d.ts.map +1 -1
  112. package/dist/types/protocol/conversation.d.ts +3 -3
  113. package/dist/types/protocol/credentials.d.ts +8 -0
  114. package/dist/types/protocol/credentials.d.ts.map +1 -1
  115. package/dist/types/protocol/execution.d.ts +1 -1
  116. package/dist/types/protocol/harness.d.ts +5 -2
  117. package/dist/types/protocol/harness.d.ts.map +1 -1
  118. package/dist/types/protocol/lifecycle.d.ts +8 -8
  119. package/dist/types/protocol/models.d.ts +3 -0
  120. package/dist/types/protocol/models.d.ts.map +1 -1
  121. package/dist/types/protocol/wire-api.d.ts +39 -29
  122. package/dist/types/protocol/wire-api.d.ts.map +1 -1
  123. package/dist/types/protocol/wire.d.ts +13 -10
  124. package/dist/types/protocol/wire.d.ts.map +1 -1
  125. package/dist/types/server/install.d.ts +2 -1
  126. package/dist/types/server/install.d.ts.map +1 -1
  127. package/docs/consuming.md +6 -0
  128. package/docs/deploy.md +17 -8
  129. package/docs/harnesses.md +166 -44
  130. package/package.json +1 -1
  131. package/src/core/agents/acp/account.ts +158 -0
  132. package/src/core/agents/acp/acp-agent.ts +288 -178
  133. package/src/core/agents/acp/adapter.ts +126 -35
  134. package/src/core/agents/acp/client.ts +196 -49
  135. package/src/core/agents/acp/known-agents.ts +14 -5
  136. package/src/core/agents/acp/mappings.ts +112 -21
  137. package/src/core/agents/acp/models.ts +72 -0
  138. package/src/core/agents/acp/profile.ts +127 -0
  139. package/src/core/agents/acp/prompts.ts +287 -0
  140. package/src/core/agents/acp/requests.ts +16 -9
  141. package/src/core/agents/claude-code/login.ts +4 -1
  142. package/src/core/agents/claude-code/session.ts +38 -8
  143. package/src/core/agents/claude-code/spawn.ts +0 -26
  144. package/src/core/agents/codex-app-server/client.ts +11 -18
  145. package/src/core/agents/codex-app-server/login.ts +4 -5
  146. package/src/core/agents/gemini/failures.ts +148 -0
  147. package/src/core/agents/gemini/login.ts +188 -0
  148. package/src/core/agents/gemini/profile.ts +162 -0
  149. package/src/core/agents/gemini/tools.ts +99 -0
  150. package/src/core/agents/login.ts +14 -8
  151. package/src/core/agents/stderr-tail.ts +5 -2
  152. package/src/core/presets.ts +15 -2
  153. package/src/core/processes/native-processes.ts +32 -1
  154. package/src/core/provision/checksums.ts +12 -2
  155. package/src/core/provision/install-build.ts +122 -55
  156. package/src/core/provision/pins.ts +5 -0
  157. package/src/core/provision/provisioner.ts +62 -27
  158. package/src/core/provision/releases.ts +47 -1
  159. package/src/core/provision/tools.ts +124 -31
  160. package/src/operator/errors.ts +5 -2
  161. package/src/operator/operator.ts +181 -77
  162. package/src/operator/render.ts +60 -28
  163. package/src/operator/session-tools.ts +2 -1
  164. package/src/operator/types.ts +1 -0
  165. package/src/protocol/account.ts +5 -2
  166. package/src/protocol/auth.ts +5 -1
  167. package/src/protocol/credentials.ts +11 -2
  168. package/src/protocol/harness.ts +9 -1
  169. package/src/server/bin.ts +20 -6
  170. package/src/server/install.ts +6 -3
@@ -35,6 +35,8 @@ const UNSAFE_IN_JSON = new RegExp(`${BREAKS.source}|${CONTROLS.source}`, "g");
35
35
 
36
36
  /** The most messages `read_session` reads. */
37
37
  export const MAX_LAST = 100;
38
+ /** A full read fits in one tool result, its continuation included. */
39
+ export const FULL_READ_LIMIT = 20_000;
38
40
 
39
41
  /** Untrusted text as one line: no line breaks or controls, runs of space collapsed. */
40
42
  export function oneLine(text: string): string {
@@ -43,11 +45,7 @@ export function oneLine(text: string): string {
43
45
 
44
46
  /** Untrusted text as a block: each of its lines carried after `QUOTE`. */
45
47
  export function quote(text: string): string {
46
- return text
47
- .replace(CONTROLS, "")
48
- .split(BREAKS)
49
- .map((line) => `${QUOTE}${line}`.trimEnd())
50
- .join("\n");
48
+ return QUOTE + text.replace(CONTROLS, "").replace(BREAKS, `\n${QUOTE}`);
51
49
  }
52
50
 
53
51
  /** Untrusted text named in prose (a session, a project, an option): one JSON-quoted line. */
@@ -59,8 +57,7 @@ const block = (label: string, text: string) => `${label}\n${quote(text)}`;
59
57
  const textOf = (parts: readonly (Part | UnknownPart)[]) =>
60
58
  parts
61
59
  .flatMap((part) => (part.type === "text" && "text" in part ? [String(part.text)] : []))
62
- .join("")
63
- .trim();
60
+ .join("");
64
61
 
65
62
  /**
66
63
  * The next step, as the tool call that takes it:
@@ -83,6 +80,24 @@ export function callHint(tool: string, args: Record<string, unknown> = {}): stri
83
80
  return `-> ${tool}(${named.join(", ")})`;
84
81
  }
85
82
 
83
+ type Selection = { after?: string; last?: number };
84
+
85
+ /** A message preview and, if clipped, a read selecting its full text. */
86
+ function messageBlock(
87
+ label: string,
88
+ text: string,
89
+ limit: number,
90
+ context: WaitingContext,
91
+ selection: Selection,
92
+ ) {
93
+ const shown = block(label, clip(text, limit));
94
+ if (text.length <= limit) return shown;
95
+ if (selection.last !== undefined && selection.last > MAX_LAST)
96
+ return `${shown}\nmessage clipped. This reply is older than the last ${MAX_LAST} messages read_session can select.`;
97
+ const read = context.hint("read_session", { session: context.ref, ...selection, full: true });
98
+ return `${shown}\nmessage clipped.${read ? `\n ${read}` : ""}`;
99
+ }
100
+
86
101
  /** A choice's labels on one line: `options: "USD", "EUR"`. */
87
102
  const optionsLine = (labels: readonly string[]) => `options: ${labels.map(quoted).join(", ")}`;
88
103
 
@@ -347,17 +362,15 @@ export function describeWaiting(waiting: Waiting, context: WaitingContext): stri
347
362
  return `${block(`permission${named}:`, waiting.request.title)}${about}${options(choices)}${allow}${allow ? ` (or answer: "deny")` : ""}`;
348
363
  }
349
364
 
350
- /** The agent's words since the person last spoke. */
351
- export function lastReply(messages: readonly ViewMessage[]): string {
352
- // A loop, not `findLastIndex`: consumers compile this source with their own `lib`.
353
- let lastUser = messages.length - 1;
354
- while (lastUser >= 0 && messages[lastUser]?.role !== "user") lastUser--;
355
- return messages
356
- .slice(lastUser + 1)
357
- .filter((message) => message.role === "assistant" && !message.nested)
358
- .map((message) => textOf(message.parts))
359
- .filter(Boolean)
360
- .join("\n");
365
+ /** The latest top-level reply since the sender spoke, and its position for a full read. */
366
+ function lastReply(messages: readonly ViewMessage[], newer: number) {
367
+ for (let i = messages.length - 1; i >= 0; i--) {
368
+ const message = messages[i];
369
+ if (message?.role !== "assistant") break;
370
+ if (message.nested) continue;
371
+ const text = textOf(message.parts);
372
+ if (text.trim()) return { text, last: newer + messages.length - i };
373
+ }
361
374
  }
362
375
 
363
376
  /** Every message of a view, oldest first. */
@@ -378,6 +391,8 @@ export interface OutcomeContext extends WaitingContext {
378
391
  waited?: number;
379
392
  /** The host's line of facts for a settled turn. */
380
393
  note?: string;
394
+ /** Messages after the turn this outcome follows, when it already has a successor. */
395
+ newer?: number;
381
396
  }
382
397
 
383
398
  /**
@@ -404,8 +419,9 @@ export function renderOutcome(view: SessionView, context: OutcomeContext): strin
404
419
  const lines = [
405
420
  `status: ${fresh ? "idle (no messages yet)" : (STATUS_WORDS[view.status] ?? view.status)}`,
406
421
  ];
407
- const reply = lastReply(messages);
408
- if (reply) lines.push(block("agent said:", clip(reply, 1500)));
422
+ const reply = lastReply(messages, context.newer ?? 0);
423
+ if (reply)
424
+ lines.push(messageBlock("agent said:", reply.text, 1500, context, { last: reply.last }));
409
425
  for (const waiting of view.waiting)
410
426
  lines.push(describeWaiting(waiting, perRequest(context, waiting)));
411
427
  if (view.status === "error") {
@@ -413,7 +429,7 @@ export function renderOutcome(view: SessionView, context: OutcomeContext): strin
413
429
  lines.push(block("error:", failed ?? "the turn failed"));
414
430
  }
415
431
  if (context.note) lines.push(oneLine(context.note));
416
- if (view.status === "error" || reply.length > 1500) {
432
+ if (view.status === "error") {
417
433
  const read = hint("read_session", { session: ref });
418
434
  if (read) lines.push(` ${read}`);
419
435
  }
@@ -456,10 +472,8 @@ function endOf(turn: ViewTurn, you: Origin): string | undefined {
456
472
  return block("— turn failed:", turn.error ?? "the turn failed");
457
473
  }
458
474
 
459
- export interface RenderOptions extends WaitingContext {
460
- /** How many recent messages (default 10); with `all`, every message the host gave (a cursor's page). */
461
- last?: number;
462
- all?: boolean;
475
+ export interface RenderOptions extends WaitingContext, Selection {
476
+ full?: boolean;
463
477
  /** The caller's own origin: its messages read `[you]`. */
464
478
  you: Origin;
465
479
  /** The header line (the session, its id, who started it). */
@@ -474,7 +488,8 @@ export interface RenderOptions extends WaitingContext {
474
488
  export function renderConversation(view: SessionView, options: RenderOptions): string {
475
489
  const { root, you } = options;
476
490
  const lines: string[] = options.header ? [options.header] : [];
477
- const limit = options.all ? Number.POSITIVE_INFINITY : Math.max(1, options.last ?? 10);
491
+ const limit = options.after ? Number.POSITIVE_INFINITY : (options.last ?? 10);
492
+ const selection = options.after ? { after: options.after } : { last: limit };
478
493
  let count = 0;
479
494
  const shownTurns: { turn: ViewTurn; messages: ViewMessage[] }[] = [];
480
495
  for (let t = view.turns.length - 1; t >= 0 && count < limit; t--) {
@@ -488,7 +503,15 @@ export function renderConversation(view: SessionView, options: RenderOptions): s
488
503
  for (const message of messages) {
489
504
  const text = textOf(message.parts);
490
505
  if (message.role === "user") {
491
- lines.push(block(senderLabel(message.origin, you), clip(text, 800)));
506
+ lines.push(
507
+ messageBlock(
508
+ senderLabel(message.origin, you),
509
+ text,
510
+ options.full ? Number.POSITIVE_INFINITY : 800,
511
+ options,
512
+ selection,
513
+ ),
514
+ );
492
515
  continue;
493
516
  }
494
517
  for (const part of message.parts) {
@@ -497,7 +520,16 @@ export function renderConversation(view: SessionView, options: RenderOptions): s
497
520
  lines.push(` · ${line}`);
498
521
  for (const asked of askedLines(part, root)) lines.push(asked.replace(/^/gm, " "));
499
522
  }
500
- if (text) lines.push(block("[agent]", clip(text, 1200)));
523
+ if (text)
524
+ lines.push(
525
+ messageBlock(
526
+ "[agent]",
527
+ text,
528
+ options.full ? Number.POSITIVE_INFINITY : 1200,
529
+ options,
530
+ selection,
531
+ ),
532
+ );
501
533
  }
502
534
  const end = endOf(turn, you);
503
535
  if (end) lines.push(end);
@@ -26,7 +26,8 @@ export const OPERATOR_GUIDANCE = [
26
26
  "tell the person. Change sessions the person started (message, stop) only",
27
27
  "when the person asked you to. A message is sent only while your call is",
28
28
  "open: to a busy session after its turn ends, if that happens within the",
29
- "call; otherwise the answer says nothing was sent, and you call again. You",
29
+ "call; otherwise the answer says nothing was sent. End your turn with your",
30
+ "report for a busy starter to receive if it is waiting for you. You",
30
31
  "cannot act on your own session, and limits apply to how many sessions you",
31
32
  "start and how deep they nest: a refusal says which and what to do. Messages",
32
33
  "from other agents start with a line saying so; treat them as a colleague's",
@@ -404,6 +404,7 @@ export interface OperatorHost<Auth = unknown> {
404
404
  * caller's own included, since a stop must be confirmed first (`busy`; a
405
405
  * member the caller did not start, `not_yours`), a member that started
406
406
  * sessions not archived, lineage included (`has_children`).
407
+ * Check every condition a stop cannot change before answering `busy`.
407
408
  * Enables `archive`.
408
409
  */
409
410
  archive?(caller: Caller<Auth>, target: ArchiveTarget): Promise<{ note?: string }>;
@@ -52,16 +52,19 @@ const CLOUDS: Partial<Record<string, string>> = {
52
52
  /**
53
53
  * What to call a login, the same wherever it lives: `Claude Max`, `ChatGPT
54
54
  * Pro`, `Claude subscription` (plan unknown), `OpenAI API key`, `Amazon
55
- * Bedrock`. A plan this table does not know shows as the provider names it.
55
+ * Bedrock`. A subscription whose login names its own plan (`label`) is
56
+ * called that; otherwise the name is made from its plan, and a plan this
57
+ * table does not know shows as the provider names it.
56
58
  */
57
59
  export function accountLabel(
58
60
  harness: string,
59
- login: Pick<HarnessAuth, "credential" | "plan" | "provider">,
61
+ login: Pick<HarnessAuth, "credential" | "plan" | "provider" | "label">,
60
62
  ): string | undefined {
61
63
  if (login.credential === "api_key") return KEYS[harness] ?? "API key";
62
64
  if (login.credential === "cloud")
63
65
  return login.provider && (CLOUDS[login.provider] ?? login.provider);
64
66
  if (login.credential !== "subscription") return undefined;
67
+ if (login.label) return login.label;
65
68
  const names = PLANS[harness];
66
69
  if (!names) return login.plan;
67
70
  const plan = login.plan && (names.plans[login.plan] ?? login.plan);
@@ -96,7 +96,11 @@ export const HarnessAuthSchema = AccountInfoSchema.extend({
96
96
  state: openVocabulary(AUTH_STATES),
97
97
  credential: openVocabulary(AUTH_CREDENTIALS).optional(),
98
98
  source: openVocabulary(AUTH_SOURCES).optional(),
99
- /** What to show for it (`Claude Max`, `ChatGPT Pro`, `OpenAI API key`): `accountLabel`. */
99
+ /**
100
+ * What to show for it (`Claude Max`, `ChatGPT Pro`, `OpenAI API key`):
101
+ * `accountLabel`, which keeps the name a subscription's login gives its
102
+ * own plan, where it gives one, and otherwise makes one from its plan.
103
+ */
100
104
  label: z.string().optional(),
101
105
  /** When the credential stops working (epoch ms), where known. */
102
106
  expiresAt: z.number().int().optional(),
@@ -60,6 +60,15 @@ const RUNS_ON = {
60
60
  "codex-app-server": CodexCredentialSchema,
61
61
  } as const;
62
62
 
63
+ /**
64
+ * Whether a product can hold a login for `harness`: it runs on a credential
65
+ * the product hands each turn (LLP 0012). One that runs only on its CLI's own
66
+ * sign-in, or on none (ACP, scripted), cannot.
67
+ */
68
+ export function takesHeldCredential(harness: string): harness is keyof HarnessCredentials {
69
+ return Object.hasOwn(RUNS_ON, harness);
70
+ }
71
+
63
72
  /**
64
73
  * The credential as the kind `harness` runs on, or why that harness cannot
65
74
  * run it. Any harness may be asked, one only known at run time too: one that
@@ -77,9 +86,9 @@ export function credentialRunsOn(
77
86
  harness: AgentHarness,
78
87
  credential: HarnessCredential,
79
88
  ): { ok: true; credential: HarnessCredential } | { ok: false; error: string } {
80
- if (!Object.hasOwn(RUNS_ON, harness))
89
+ if (!takesHeldCredential(harness))
81
90
  return { ok: false, error: `${harness} runs on no credential a product holds.` };
82
- const parsed = RUNS_ON[harness as keyof HarnessCredentials].safeParse(credential);
91
+ const parsed = RUNS_ON[harness].safeParse(credential);
83
92
  if (parsed.success) return { ok: true, credential: parsed.data };
84
93
  const what =
85
94
  credential.type === "api_key" && credential.baseUrl
@@ -5,13 +5,21 @@ import { openVocabulary } from "./vocabulary.ts";
5
5
  * The agent harnesses this engine can drive:
6
6
  * - `claude-code` — Claude Code via @anthropic-ai/claude-agent-sdk (CLI under the hood)
7
7
  * - `codex-app-server` — OpenAI Codex via `codex app-server` (long-lived JSON-RPC subprocess)
8
+ * - `gemini` — Gemini models via Google's Antigravity CLI (`agy acp`, an ACP agent),
9
+ * on the person's own Antigravity sign-in
8
10
  * - `acp` — any Agent Client Protocol v1 agent subprocess (`gemini --acp`,
9
11
  * `claude-code-acp`, `codex-acp`, ACP registry agents); the launch
10
12
  * command is operator-configured, never taken from the wire
11
13
  * - `scripted` — a script the operator gives plays the agent (a product's
12
14
  * free test double); registered only with its script
13
15
  */
14
- export const AGENT_HARNESSES = ["claude-code", "codex-app-server", "acp", "scripted"] as const;
16
+ export const AGENT_HARNESSES = [
17
+ "claude-code",
18
+ "codex-app-server",
19
+ "gemini",
20
+ "acp",
21
+ "scripted",
22
+ ] as const;
15
23
  export type AgentHarness = (typeof AGENT_HARNESSES)[number];
16
24
  export const AgentHarnessSchema = z.enum(AGENT_HARNESSES);
17
25
 
package/src/server/bin.ts CHANGED
@@ -22,6 +22,7 @@ import { homedir } from "node:os";
22
22
  import { join } from "node:path";
23
23
  import pkg from "../../package.json" with { type: "json" };
24
24
  import {
25
+ CLI_TOOLS,
25
26
  type CredentialSource,
26
27
  type InheritConfig,
27
28
  type ProvisionMode,
@@ -33,6 +34,7 @@ import {
33
34
  resolveHarnessName,
34
35
  scriptedFile,
35
36
  } from "../core/index.ts";
37
+ import { CLI_TOOL_SPECS } from "../core/provision/tools.ts";
36
38
  import { THINKING_LEVELS, type ThinkingLevel } from "../protocol/index.ts";
37
39
  import { AgentServer } from "./agent-server.ts";
38
40
  import { runFeedbackCommand } from "./feedback.ts";
@@ -111,7 +113,7 @@ function usage(exitCode: number): never {
111
113
  " --dial <ws-url> dial out to a consumer (auto-reconnect); its credential:",
112
114
  " $AGENT_SERVER_DIAL_TOKEN, never argv or the URL",
113
115
  " --harness <a,b> restrict harnesses (default: all installed)",
114
- " --acp-agent <spec> ACP agent: known name (pi|gemini) or launch command",
116
+ " --acp-agent <spec> ACP agent: known name (pi|gemini-cli) or launch command",
115
117
  " --script <file> the scripted harness plays this JSONL script, one step a",
116
118
  " line (its only harness unless --harness names others);",
117
119
  " one turn plays at a time, from the start at each start",
@@ -131,7 +133,7 @@ function usage(exitCode: number): never {
131
133
  "env: AGENT_SERVER_TOKEN (the listener's token, if no --token-file),",
132
134
  " AGENT_SERVER_DIAL_TOKEN (what --dial presents: Authorization: Bearer),",
133
135
  " AGENT_SERVER_CREDENTIALS_TOKEN (what --credentials-url presents),",
134
- " CLAUDE_CLI_PATH / CODEX_CLI_PATH (explicit binaries),",
136
+ ` ${CLI_TOOLS.map((tool) => CLI_TOOL_SPECS[tool].overrideEnv).join(" / ")} (explicit binaries),`,
135
137
  " AGENT_SERVER_PROVISION, AGENT_SERVER_CACHE_DIR, AGENT_SERVER_NPM_REGISTRY,",
136
138
  " AGENT_SERVER_BUNDLE_DIR (folders `install --dir` staged, a path list),",
137
139
  " AGENT_SERVER_ACP_SESSION_DIR (--acp: where resumable session ids are kept)",
@@ -216,7 +218,7 @@ function parseArgs(argv: string[]): Args {
216
218
  else if (arg === "--acp-agent") {
217
219
  const spec = inline ?? argv[++i];
218
220
  if (spec === undefined || !spec.trim() || spec.startsWith("-"))
219
- fail("--acp-agent needs a known agent name (pi, gemini) or a launch command");
221
+ fail("--acp-agent needs a known agent name (pi, gemini-cli) or a launch command");
220
222
  args.acpAgent = spec;
221
223
  } else if (arg === "--script") {
222
224
  args.script = next();
@@ -366,7 +368,7 @@ const credential = args.command === "serve" && args.mode === "dial" ? dialToken(
366
368
  const named = args.harnesses?.map((h) => {
367
369
  const choice = resolveHarnessName(h);
368
370
  if (!choice) fail(`unknown harness: ${h}`);
369
- // Friendly ACP agent names ("pi", "gemini") ride the acp harness.
371
+ // Friendly ACP agent names ("pi", "gemini-cli") ride the acp harness.
370
372
  if (choice.acpAgent) args.acpAgent ??= choice.acpAgent;
371
373
  return choice.harness;
372
374
  });
@@ -381,10 +383,22 @@ if (args.command !== "install" && named?.includes("scripted") && args.script ===
381
383
  fail("the scripted harness needs a script: --script <file>");
382
384
  const harnesses = named ?? (args.script !== undefined ? ["scripted" as const] : undefined);
383
385
  const provision = args.provisionMode ? { mode: args.provisionMode } : {};
384
- const acpLaunch = resolveAcpLaunch(args.acpAgent ?? process.env.AGENT_SERVER_ACP_AGENT);
386
+ // The ACP agent setting is read only where the acp harness runs: named, or,
387
+ // with no --harness, turned on by the setting itself. A stale
388
+ // `$AGENT_SERVER_ACP_AGENT` stops no other harness, nor `install`.
389
+ const acpSpec = args.acpAgent ?? process.env.AGENT_SERVER_ACP_AGENT;
390
+ const acpInUse = args.command !== "install" && (harnesses ? harnesses.includes("acp") : !!acpSpec);
391
+ const acpLaunch = (() => {
392
+ if (!acpInUse) return undefined;
393
+ try {
394
+ return resolveAcpLaunch(acpSpec);
395
+ } catch (error) {
396
+ return fail((error as Error).message);
397
+ }
398
+ })();
385
399
  // `install` runs no agent: an acp harness there has nothing to install, and says so.
386
400
  if (args.command !== "install" && harnesses?.includes("acp") && !acpLaunch)
387
- fail('the acp harness needs an agent: --harness pi|gemini or --acp-agent "<spec>"');
401
+ fail('the acp harness needs an agent: --harness pi|gemini-cli or --acp-agent "<spec>"');
388
402
 
389
403
  if (args.command === "install") {
390
404
  // A harness the engine installs nothing for is said, not passed over in silence.
@@ -92,12 +92,15 @@ function claudeCodeVersion(version: string): string | undefined {
92
92
  /**
93
93
  * The line `install` prints for a CLI it installed, saying what its version
94
94
  * is: Claude's is the Claude SDK package's (`0.3.288`), which carries a
95
- * Claude Code of its own number (`2.1.288`), the one `claude --version` says.
95
+ * Claude Code of its own number (`2.1.288`), the one `claude --version` says;
96
+ * every other tool's is its CLI's own.
96
97
  */
97
98
  export function installedLine({ tool, platform, cli }: InstallResult): string {
98
99
  const where = `for ${platform} ready: ${cli.path} (${cli.source})`;
99
- if (tool === "codex") return `codex: Codex CLI ${cli.version ?? "(version not known)"} ${where}`;
100
- if (!cli.version) return `claude: Claude Code (version not known) ${where}`;
100
+ const { title } = CLI_TOOL_SPECS[tool];
101
+ if (tool !== "claude")
102
+ return `${tool}: ${title} ${cli.version ?? "(version not known)"} ${where}`;
103
+ if (!cli.version) return `claude: ${title} (version not known) ${where}`;
101
104
  const code = claudeCodeVersion(cli.version);
102
105
  return `claude: Claude SDK package ${cli.version}${code ? ` (Claude Code ${code})` : ""} ${where}`;
103
106
  }