@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
@@ -5,6 +5,7 @@ import { createClaudeCodeTransformer } from "./agents/claude-code/adapter.js";
5
5
  import { ClaudeCodeAgent } from "./agents/claude-code/claude-agent.js";
6
6
  import { createCodexAppServerTransformer } from "./agents/codex-app-server/adapter.js";
7
7
  import { CodexAppServerAgent, } from "./agents/codex-app-server/codex-agent.js";
8
+ import { geminiHarness } from "./agents/gemini/profile.js";
8
9
  import { AgentRegistry } from "./agents/registry.js";
9
10
  import { createScriptedTransformer } from "./agents/scripted/adapter.js";
10
11
  import { ScriptedAgent } from "./agents/scripted/scripted-agent.js";
@@ -45,6 +46,18 @@ const HARNESSES = {
45
46
  }),
46
47
  createCodexAppServerTransformer,
47
48
  ],
49
+ gemini: (opts, cliPath, processes) => {
50
+ const { idleTimeoutMs, cancelConfirmMs, cancelGraceMs, hostTools, inheritConfig } = opts;
51
+ return geminiHarness({
52
+ ...(inheritConfig && { inheritConfig }),
53
+ resolveCliPath: cliPath("agy"),
54
+ idleTimeoutMs,
55
+ cancelConfirmMs,
56
+ cancelGraceMs,
57
+ hostTools,
58
+ processes,
59
+ });
60
+ },
48
61
  acp: (opts, _cliPath, processes) => {
49
62
  if (!opts.acp) {
50
63
  throw new Error("the acp harness requires CreateRegistryOptions.acp (resolveLaunch)");
@@ -1,6 +1,7 @@
1
1
  import { spawn as nodeSpawn } from "node:child_process";
2
2
  import { StderrTail } from "../agents/stderr-tail.js";
3
- import { onAbort } from "../utils/deadline.js";
3
+ import { onAbort, withTimeout } from "../utils/deadline.js";
4
+ import { AgentExitedError } from "../utils/errors.js";
4
5
  import { bootId, startToken, verifyRecord } from "./identity.js";
5
6
  import { lifeline } from "./lifeline.js";
6
7
  import { POSIX, aliveTargets, readProcessTable, signalTargets, treeTargets, } from "./process-table.js";
@@ -10,6 +11,8 @@ export const DEFAULT_GRACE_MS = 3_000;
10
11
  const STDERR_TAIL_MAX = 2048;
11
12
  /** How long an exit waits for its stdout's and stderr's last words, as the Claude SDK's own spawner waits for stderr. */
12
13
  const OUTPUT_CLOSE_WAIT_MS = 200;
14
+ /** A broken transport may precede the exit that explains it. */
15
+ const EXIT_REASON_WAIT_MS = 1_000;
13
16
  const POLL_MS = 50;
14
17
  /** How long a SIGKILLed tree may take to be gone before it counts as not stopped. */
15
18
  const KILL_WAIT_MS = 1_000;
@@ -73,6 +76,25 @@ export class NativeProcess {
73
76
  get stderrTail() {
74
77
  return this.tail.text;
75
78
  }
79
+ /** The stderr a failure can show, including when the process printed nothing. */
80
+ get stderrSummary() {
81
+ const tail = this.stderrTail.trim().replace(/\s+/g, " ");
82
+ return tail ? `Last stderr: ${tail}` : "It printed nothing on stderr.";
83
+ }
84
+ /** Once the transport is lost, give the process a moment to exit and drain its output. */
85
+ async exitAfterDisconnect() {
86
+ return (await withTimeout(this.exited, EXIT_REASON_WAIT_MS))?.value;
87
+ }
88
+ // @ref LLP 0016.000#when-a-process-exits-before-answering — one exit sentence for every harness
89
+ exitError(name, { code, signal }, requests) {
90
+ const status = signal
91
+ ? `on ${signal}`
92
+ : code !== null
93
+ ? `with code ${code}`
94
+ : "without an exit status";
95
+ const pending = [...new Set(requests)].join(", ");
96
+ return new AgentExitedError(`${name} exited unexpectedly ${status}${pending ? ` before answering ${pending}` : ""}. ${this.stderrSummary}`);
97
+ }
76
98
  /**
77
99
  * Stop it and everything under it: SIGTERM to its group and its tool
78
100
  * sessions, SIGKILL to what is left after the grace. Whether all of it is
@@ -27,8 +27,56 @@ export async function openToAll(path) {
27
27
  else if (info.isFile())
28
28
  await chmod(path, info.mode & 0o100 ? 0o755 : 0o644);
29
29
  }
30
- export function noBinary(pkg) {
31
- return new CliProvisionError(`downloaded ${pkg.name}@${pkg.registryVersion} has no binary`);
30
+ /** `name` is `<package>@<version>` (`<tool>@<version>` for a file). */
31
+ export function noBinary(name) {
32
+ return new CliProvisionError(`downloaded ${name} has no binary`);
33
+ }
34
+ /**
35
+ * Where an npm build's tarball is and what it must match, asked before a
36
+ * byte of it is fetched: the registry's metadata, refused when it names
37
+ * another tarball than the table pins.
38
+ */
39
+ async function locateTarball(job, { pkg, expected }) {
40
+ const dist = await fetchDist(job.registry, pkg.name, pkg.registryVersion, job.fetch, job.timeouts);
41
+ if (expected.source === "release" && dist.integrity !== expected.integrity) {
42
+ throw new CliProvisionError(`${withoutSecrets(job.registry)} serves another ${pkg.name}@${pkg.registryVersion} than this release pins ` +
43
+ `(${dist.integrity.slice(0, 24)}…, pinned ${expected.integrity.slice(0, 24)}…)`,
44
+ // A digest's digits are no status code: classified by what it is, not its words.
45
+ { category: "internal" });
46
+ }
47
+ return {
48
+ url: dist.tarball,
49
+ integrity: expected.source === "release" ? expected.integrity : dist.integrity,
50
+ };
51
+ }
52
+ /** The tarball, extracted into the staging folder. */
53
+ async function extracted(job, download, staging) {
54
+ const dir = join(staging, "x");
55
+ await mkdir(dir, { mode: 0o700 });
56
+ await job.extract(download, dir);
57
+ return dir;
58
+ }
59
+ /**
60
+ * The download, unpacked into the folder that becomes the install: an npm
61
+ * tarball's payload, or a folder holding only the file's executable under
62
+ * its installed name (the tarball's `member`, or the file itself; a member
63
+ * that is not a regular file is no binary).
64
+ */
65
+ async function unpack(job, download, staging) {
66
+ const { plan } = job;
67
+ if (plan.kind === "npm")
68
+ return plan.payload(await extracted(job, download, staging));
69
+ let executable = download;
70
+ if (plan.member) {
71
+ const member = binaryIn(await extracted(job, download, staging), [plan.member]);
72
+ if (!member)
73
+ throw noBinary(plan.name);
74
+ executable = member;
75
+ }
76
+ const dir = join(staging, "build");
77
+ await mkdir(dir, { mode: 0o700 });
78
+ await rename(executable, join(dir, plan.binary));
79
+ return dir;
32
80
  }
33
81
  /**
34
82
  * Download a build, check it against what it must match, unpack it in a
@@ -37,21 +85,19 @@ export function noBinary(pkg) {
37
85
  * one that loses adopts the winner's tree. Answers the bytes downloaded.
38
86
  */
39
87
  export async function installBuild(job) {
40
- const { spec, pkg, expected, root, dir } = job;
41
- const staging = join(root, ".tmp", `${pkg.name.replace("/", "-")}-${pkg.registryVersion}-${process.pid}-${randomBytes(4).toString("hex")}`);
88
+ const { plan, binaries, root, dir } = job;
89
+ const { name } = plan;
90
+ const stem = plan.kind === "npm"
91
+ ? `${plan.pkg.name.replace("/", "-")}-${plan.pkg.registryVersion}`
92
+ : plan.name.replace("@", "-");
93
+ const staging = join(root, ".tmp", `${stem}-${process.pid}-${randomBytes(4).toString("hex")}`);
42
94
  try {
43
95
  managedDirectory(root, dirname(staging), true);
44
96
  await mkdir(staging, { mode: 0o700 });
45
- const dist = await fetchDist(job.registry, pkg.name, pkg.registryVersion, job.fetch, job.timeouts);
46
- if (expected.source === "release" && dist.integrity !== expected.integrity) {
47
- throw new CliProvisionError(`${withoutSecrets(job.registry)} serves another ${pkg.name}@${pkg.registryVersion} than this release pins ` +
48
- `(${dist.integrity.slice(0, 24)}…, pinned ${expected.integrity.slice(0, 24)}…)`,
49
- // A digest's digits are no status code: classified by what it is, not its words.
50
- { category: "internal" });
51
- }
52
- const tgz = join(staging, "package.tgz");
97
+ const { url, integrity } = plan.kind === "npm" ? await locateTarball(job, plan) : plan;
98
+ const download = join(staging, plan.kind === "npm" ? "package.tgz" : "download");
53
99
  let reportedAt = 0;
54
- const bytes = await downloadWithIntegrity(dist.tarball, tgz, expected.source === "release" ? expected.integrity : dist.integrity, job.fetch, {
100
+ const bytes = await downloadWithIntegrity(url, download, integrity, job.fetch, {
55
101
  timeouts: job.timeouts,
56
102
  onBytes: (receivedBytes, totalBytes) => {
57
103
  const now = Date.now();
@@ -62,18 +108,16 @@ export async function installBuild(job) {
62
108
  },
63
109
  });
64
110
  job.onProgress("verifying", bytes, bytes);
65
- const extracted = join(staging, "x");
66
- await mkdir(extracted, { mode: 0o700 });
67
- await job.extract(tgz, extracted);
68
- const payload = await spec.payload(extracted);
69
- const binary = binaryIn(payload, spec.binaries);
111
+ const payload = await unpack(job, download, staging);
112
+ const binary = binaryIn(payload, binaries);
70
113
  if (!binary)
71
- throw noBinary(pkg);
72
- const sha256 = expected.source === "registry" ? undefined : expected.sha256;
73
- if (sha256) {
114
+ throw noBinary(name);
115
+ const expected = plan.kind === "npm" ? plan.expected : undefined;
116
+ const sha256 = expected?.source === "registry" ? undefined : expected?.sha256;
117
+ if (expected && sha256) {
74
118
  const actual = await sha256Of(binary);
75
119
  if (actual !== sha256) {
76
- throw new CliProvisionError(`${pkg.name}@${pkg.registryVersion}'s binary is not the build ${expected.source === "local" ? expected.vouchedBy : "this release pins"} names (sha256 ${actual}, expected ${sha256})`, { category: "internal" });
120
+ throw new CliProvisionError(`${name}'s binary is not the build ${expected.source === "local" ? expected.vouchedBy : "this release pins"} names (sha256 ${actual}, expected ${sha256})`, { category: "internal" });
77
121
  }
78
122
  }
79
123
  await chmod(binary, 0o755);
@@ -85,12 +129,12 @@ export async function installBuild(job) {
85
129
  catch (error) {
86
130
  // Lost the race with another process installing the same build: the
87
131
  // directory is version-keyed, so its tree is what we would have written.
88
- if (trustedBinaryIn(root, dir, spec.binaries))
132
+ if (trustedBinaryIn(root, dir, binaries))
89
133
  return bytes;
90
- throw new CliProvisionError(`${dir} is there but holds no ${spec.binaries[0]}: remove it, and it installs again`, { cause: error });
134
+ throw new CliProvisionError(`${dir} is there but holds no ${binaries[0]}: remove it, and it installs again`, { cause: error });
91
135
  }
92
- if (!trustedBinaryIn(root, dir, spec.binaries))
93
- throw noBinary(pkg);
136
+ if (!trustedBinaryIn(root, dir, binaries))
137
+ throw noBinary(name);
94
138
  return bytes;
95
139
  }
96
140
  finally {
@@ -13,6 +13,10 @@
13
13
  * governs downloads (compiled binaries, bare sandboxes, `pinned` mode); in
14
14
  * `auto` an installed `@openai/codex` package (a lockfile's) runs instead,
15
15
  * and a `codex` on PATH only in `system` mode.
16
+ * - `agy` is the version of Google's Antigravity CLI the gemini harness
17
+ * downloads. Google's update manifest names only its latest build, so a
18
+ * refresh records the version it names: a bump moves to that one, and
19
+ * only forward. The person's own install runs only in `system` mode.
16
20
  *
17
21
  * A bump is `bun run bump -- <tool>`: it writes what changed upstream, moves
18
22
  * the pin, and runs both refreshes, `releases:refresh` (each platform's build
@@ -23,4 +27,5 @@
23
27
  export const DEFAULT_PINS = {
24
28
  claude: "0.3.327",
25
29
  codex: "0.169.1",
30
+ agy: "1.5.14",
26
31
  };
@@ -9,7 +9,7 @@ import { expectedBuild } from "./checksums.js";
9
9
  import { extractTarGz } from "./extract.js";
10
10
  import { installBuild, noBinary } from "./install-build.js";
11
11
  import { DEFAULT_DOWNLOAD_TIMEOUTS, DEFAULT_NPM_REGISTRY, withoutSecrets, } from "./npm.js";
12
- import { detectPlatform } from "./platform.js";
12
+ import { detectPlatform, platformName } from "./platform.js";
13
13
  import { CLI_RELEASES } from "./releases.js";
14
14
  import { CLI_TOOLS, CLI_TOOL_SPECS, binaryIn } from "./tools.js";
15
15
  function failureOf(error) {
@@ -25,10 +25,11 @@ function messageOf(error) {
25
25
  return error instanceof Error ? error.message : String(error);
26
26
  }
27
27
  /**
28
- * Resolves the native CLIs the harnesses spawn (`claude`, `codex`) and — in
29
- * managed modes — downloads the pinned builds from the npm registry into a
30
- * local cache, checked against this release's table of them (`releases.ts`)
31
- * and installed atomically (`install-build.ts`), so concurrent processes
28
+ * Resolves the native CLIs the harnesses spawn (`CLI_TOOLS`) and — in
29
+ * managed modes — downloads the pinned builds from where each comes from
30
+ * (the npm registry, or the address the release table names) into a local
31
+ * cache, checked against this release's table of them (`releases.ts`) and
32
+ * installed atomically (`install-build.ts`), so concurrent processes
32
33
  * converge on one copy. What differs per tool is its `CLI_TOOL_SPECS` entry.
33
34
  *
34
35
  * One instance per runtime; `resolve` is memoized per tool (a failure clears
@@ -263,8 +264,31 @@ export class CliProvisioner {
263
264
  this.say(note);
264
265
  version = spec.defaultVersion();
265
266
  }
266
- const pkg = spec.package(this.platform, version);
267
- return { version, pkg, entry: `${version}-${pkg.suffix}` };
267
+ const pkg = spec.source.kind === "npm" ? spec.source.package(this.platform, version) : undefined;
268
+ const suffix = pkg?.suffix ?? platformName(this.platform);
269
+ const name = pkg ? `${pkg.name}@${pkg.registryVersion}` : `${tool}@${version}`;
270
+ return { version, suffix, entry: `${version}-${suffix}`, pkg, name };
271
+ }
272
+ // @ref LLP 0010#source-kinds — the one place a build's pin is checked: a `url` build the table does not hold is refused
273
+ /**
274
+ * What installing `build` takes, resolved before anything is fetched: an
275
+ * npm build's package and what it must match (said once when that is not
276
+ * this release's table), or the file the table names for a `url` source.
277
+ */
278
+ plan(tool, build) {
279
+ const { source, localBuild } = CLI_TOOL_SPECS[tool];
280
+ const { version, suffix, name } = build;
281
+ const expected = expectedBuild(tool, version, suffix, this.releases, localBuild);
282
+ if (source.kind === "npm") {
283
+ if (expected.source !== "release")
284
+ this.say(`${tool} ${version} (${suffix}) is not pinned by this agent-server release: checked against ${expected.source === "local" ? expected.vouchedBy : "the registry's checksum only"}`);
285
+ const pkg = build.pkg ?? source.package(this.platform, version);
286
+ return { kind: "npm", name, pkg, expected, payload: source.payload };
287
+ }
288
+ if (expected.source !== "release" || !expected.url)
289
+ throw new CliProvisionError(`${tool} ${version} (${suffix}) is not a build this agent-server release pins, and only a pinned build of ${tool} downloads: pin the release's version, or name a binary with its override`, { category: "invalid_request" });
290
+ const { url, integrity } = expected;
291
+ return { kind: "file", name, url, integrity, ...source.executable(this.platform) };
268
292
  }
269
293
  /** Pin trusted aliases to their physical location and recheck on every use. */
270
294
  ensureTrustedCacheRoot() {
@@ -282,7 +306,7 @@ export class CliProvisioner {
282
306
  await this.download(tool, build, root, dir);
283
307
  path = trustedBinaryIn(root, dir, spec.binaries);
284
308
  if (!path)
285
- throw noBinary(build.pkg);
309
+ throw noBinary(build.name);
286
310
  }
287
311
  await this.used(tool, build.entry, true);
288
312
  // The cache grew: what no process used for a while goes. Best effort.
@@ -293,7 +317,7 @@ export class CliProvisioner {
293
317
  /** Download and install one build, reporting its progress to the observers and the log. */
294
318
  async download(tool, build, root, dir) {
295
319
  const spec = CLI_TOOL_SPECS[tool];
296
- const { version, pkg } = build;
320
+ const { version } = build;
297
321
  let progress = { tool, version, phase: "downloading", receivedBytes: 0 };
298
322
  const report = (next) => {
299
323
  progress = { ...progress, ...next };
@@ -310,14 +334,13 @@ export class CliProvisioner {
310
334
  const startedAt = Date.now();
311
335
  try {
312
336
  report({});
313
- const expected = expectedBuild(tool, version, pkg.suffix, this.releases, spec.localBuild);
314
- if (expected.source !== "release")
315
- this.say(`${tool} ${version} (${pkg.suffix}) is not pinned by this agent-server release: checked against ${expected.source === "local" ? expected.vouchedBy : "the registry's checksum only"}`);
316
- this.log(`downloading ${tool} ${version} (${pkg.suffix}) from ${withoutSecrets(this.registry)}…`);
337
+ const plan = this.plan(tool, build);
338
+ // A file is where the table says; an npm build, the registry's.
339
+ const from = plan.kind === "file" ? new URL(plan.url).origin : withoutSecrets(this.registry);
340
+ this.log(`downloading ${tool} ${version} (${build.suffix}) from ${from}…`);
317
341
  const bytes = await installBuild({
318
- spec,
319
- pkg,
320
- expected,
342
+ plan,
343
+ binaries: spec.binaries,
321
344
  root,
322
345
  dir,
323
346
  registry: this.registry,
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * The pinned CLIs' builds, by platform: each npm tarball's integrity, and for
3
3
  * Claude the binary's sha256 from Anthropic's signed release manifest (its
4
- * signature verified when this file was generated).
4
+ * signature verified when this file was generated); for agy each build's
5
+ * address and the sha512 Google's unsigned update manifest named for it.
5
6
  */
6
7
  export const CLI_RELEASES = {
7
8
  claude: {
@@ -65,4 +66,41 @@ export const CLI_RELEASES = {
65
66
  },
66
67
  },
67
68
  },
69
+ agy: {
70
+ version: "1.5.14",
71
+ builds: {
72
+ "darwin-arm64": {
73
+ integrity: "sha512-JoMP1Gv7kgDQc88+cb+UtwdVJVe0OA7AGv1umfOisDDmVCLasYZ/dzGAeGkt78hZp1R9F+xLCx6TafE8nDyupg==",
74
+ url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/darwin-arm/cli_mac_arm64.tar.gz",
75
+ },
76
+ "darwin-x64": {
77
+ integrity: "sha512-G2ofxtvka6bZ0EBdG2CVGJ816/xMPDPOsf0bbQyf1wK1KsELZLi1Ku0NjXGuAsXfPP/V4+PTdUnC2v/M4qhTxw==",
78
+ url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/darwin-x64/cli_mac_x64.tar.gz",
79
+ },
80
+ "linux-arm64": {
81
+ integrity: "sha512-ybKbukdfY6GoAWGuk7pysiHHpYbZhR5NAGFUZwS6tm1rJ2CyXXFtGRck/HVk8yRkVu4VHiiqN69I281yvcbEYw==",
82
+ url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/linux-arm/cli_linux_arm64.tar.gz",
83
+ },
84
+ "linux-x64": {
85
+ integrity: "sha512-gzEdPzVFZ2EtwWwa4uqbUD1vaDOqThONOaoinaPzu5mw5NfMoLzkeWsAYNalHYET63RJ7V3A55AL8hcQfqW/+Q==",
86
+ url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/linux-x64/cli_linux_x64.tar.gz",
87
+ },
88
+ "linux-arm64-musl": {
89
+ integrity: "sha512-9uNfw9qyzUn9Qpbd7ghBucxMcCC2xqrqZFLFs0UrCtjWZFHJCY5Bitay9uq8yBzfExBe0EOQMkixHW+ySucJqw==",
90
+ url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/linux-arm-musl/cli_linux_arm64_musl.tar.gz",
91
+ },
92
+ "linux-x64-musl": {
93
+ integrity: "sha512-HaJJInJ8W06ENp0IQ1ddfW8YChlG4txCiRca0ePKkllOaHck0ZAqfYPkB/mPCo07fD6XbwNoD9gNvtLS2gDA7Q==",
94
+ url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/linux-x64-musl/cli_linux_x64_musl.tar.gz",
95
+ },
96
+ "win32-arm64": {
97
+ integrity: "sha512-ss5UYs8YRbJcBcplG1vZNzX9gH+Oe0DGHQ6ZRF3xp2uX7iTIkNX1ugRT+EjKF0901JKtGQGi3cul16m0OZ3f7w==",
98
+ url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/windows-arm/cli_windows_arm64.exe",
99
+ },
100
+ "win32-x64": {
101
+ integrity: "sha512-eFVIsjJC7JESdZu0tSXZSj1NLpho5c7bnqNOXOAduwCr9d5mxB2PSQPopDeURfaFSD+Zns6Rhnv72dSBJ2DYNQ==",
102
+ url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/windows-x64/cli_windows_x64.exe",
103
+ },
104
+ },
105
+ },
68
106
  };
@@ -1,18 +1,20 @@
1
1
  import { existsSync, lstatSync, readFileSync, readdirSync, realpathSync, } from "node:fs";
2
2
  import { readdir } from "node:fs/promises";
3
3
  import { createRequire } from "node:module";
4
+ import { homedir } from "node:os";
4
5
  import { dirname, join, resolve } from "node:path";
5
6
  import { pathToFileURL } from "node:url";
6
7
  import { CliNotFoundError, CliProvisionError } from "../utils/errors.js";
7
8
  import { DEFAULT_PINS } from "./pins.js";
8
9
  import { claudePackageSuffix, codexPackageSuffix, findOnPath, } from "./platform.js";
9
10
  /**
10
- * The managed CLIs. Each native harness maps onto exactly one of these; the
11
+ * The managed CLIs. Each native harness maps onto exactly one of these, and
12
+ * so does `gemini`, a profile on the ACP agent that runs Google's `agy`; the
11
13
  * `acp` harness maps onto none (its agent binaries are arbitrary third-party
12
14
  * commands the operator supplies, not something we pin or download), nor does
13
15
  * `scripted`, which runs no process.
14
16
  */
15
- export const CLI_TOOLS = ["claude", "codex"];
17
+ export const CLI_TOOLS = ["claude", "codex", "agy"];
16
18
  /**
17
19
  * Which managed CLI a harness runs on — `undefined` for unmanaged harnesses
18
20
  * (`acp`, `scripted`). Exhaustive by construction: adding a harness fails to
@@ -21,6 +23,7 @@ export const CLI_TOOLS = ["claude", "codex"];
21
23
  const TOOL_FOR_HARNESS = {
22
24
  "claude-code": "claude",
23
25
  "codex-app-server": "codex",
26
+ gemini: "agy",
24
27
  acp: undefined,
25
28
  scripted: undefined,
26
29
  };
@@ -150,6 +153,7 @@ const CODEX_BINARIES = [join("bin", "codex"), join("bin", "codex.exe")];
150
153
  */
151
154
  export const CLI_TOOL_SPECS = {
152
155
  claude: {
156
+ title: "Claude Code",
153
157
  overrideEnv: "CLAUDE_CLI_PATH",
154
158
  binaries: ["claude", "claude.exe"],
155
159
  platforms: [
@@ -162,10 +166,23 @@ export const CLI_TOOL_SPECS = {
162
166
  "win32-arm64",
163
167
  "win32-x64",
164
168
  ],
165
- // The platform packages carry the native CLI matched to the SDK JS.
166
- package: (platform, version) => {
167
- const suffix = claudePackageSuffix(platform);
168
- return { name: `@anthropic-ai/claude-agent-sdk-${suffix}`, registryVersion: version, suffix };
169
+ source: {
170
+ kind: "npm",
171
+ // The platform packages carry the native CLI matched to the SDK JS.
172
+ package: (platform, version) => {
173
+ const suffix = claudePackageSuffix(platform);
174
+ return {
175
+ name: `@anthropic-ai/claude-agent-sdk-${suffix}`,
176
+ registryVersion: version,
177
+ suffix,
178
+ };
179
+ },
180
+ payload: async (extractedRoot) => {
181
+ const dir = join(extractedRoot, "package");
182
+ if (existsSync(dir))
183
+ return dir;
184
+ throw new CliProvisionError("claude tarball has no package/ directory");
185
+ },
169
186
  },
170
187
  // The on-disk SDK's version (the pair that actually runs) over the
171
188
  // release default, which only decides inside compiled binaries. Even
@@ -203,12 +220,6 @@ export const CLI_TOOL_SPECS = {
203
220
  const path = join(platformDir, claudeManifestBuild(sdk.dir, suffix)?.binary ?? "claude");
204
221
  return existsSync(path) ? { path, version: sdk.version } : undefined;
205
222
  },
206
- payload: async (extractedRoot) => {
207
- const dir = join(extractedRoot, "package");
208
- if (existsSync(dir))
209
- return dir;
210
- throw new CliProvisionError("claude tarball has no package/ directory");
211
- },
212
223
  // The SDK on disk names its own CLI's checksum, for a version this
213
224
  // release did not pin (a consumer's lockfile moved the SDK).
214
225
  localBuild: (suffix, version) => {
@@ -218,6 +229,7 @@ export const CLI_TOOL_SPECS = {
218
229
  },
219
230
  },
220
231
  codex: {
232
+ title: "Codex CLI",
221
233
  overrideEnv: "CODEX_CLI_PATH",
222
234
  binaries: CODEX_BINARIES,
223
235
  // Its linux builds are static, so there is no musl variant.
@@ -229,10 +241,25 @@ export const CLI_TOOL_SPECS = {
229
241
  "win32-arm64",
230
242
  "win32-x64",
231
243
  ],
232
- // Codex publishes its platform builds as version suffixes of one package.
233
- package: (platform, version) => {
234
- const suffix = codexPackageSuffix(platform);
235
- return { name: "@openai/codex", registryVersion: `${version}-${suffix}`, suffix };
244
+ source: {
245
+ kind: "npm",
246
+ // Codex publishes its platform builds as version suffixes of one package.
247
+ package: (platform, version) => {
248
+ const suffix = codexPackageSuffix(platform);
249
+ return { name: "@openai/codex", registryVersion: `${version}-${suffix}`, suffix };
250
+ },
251
+ // Codex vendors per-target trees: package/vendor/<rust-triple>/bin/codex.
252
+ // Install the whole tree — the CLI expects its vendored rg/zsh siblings.
253
+ payload: async (extractedRoot) => {
254
+ const vendor = join(extractedRoot, "package", "vendor");
255
+ const entries = existsSync(vendor) ? await readdir(vendor) : [];
256
+ for (const entry of entries) {
257
+ const dir = join(vendor, entry);
258
+ if (binaryIn(dir, CODEX_BINARIES))
259
+ return dir;
260
+ }
261
+ throw new CliProvisionError("codex tarball has no vendor/<target>/bin/codex");
262
+ },
236
263
  },
237
264
  defaultVersion: () => DEFAULT_PINS.codex,
238
265
  // @ref LLP 0001#d18--the-engine-installs-the-clis-it-runs-pinned-builds-checked-before-a-turn — a lockfile's build, or in `system` the operator's PATH
@@ -261,19 +288,51 @@ export const CLI_TOOL_SPECS = {
261
288
  const path = searchPath ? findOnPath("codex", env, platform.platform) : undefined;
262
289
  return path ? { path } : undefined;
263
290
  },
264
- // Codex vendors per-target trees: package/vendor/<rust-triple>/bin/codex.
265
- // Install the whole tree — the CLI expects its vendored rg/zsh siblings.
266
- payload: async (extractedRoot) => {
267
- const vendor = join(extractedRoot, "package", "vendor");
268
- const entries = existsSync(vendor) ? await readdir(vendor) : [];
269
- for (const entry of entries) {
270
- const dir = join(vendor, entry);
271
- if (binaryIn(dir, CODEX_BINARIES))
272
- return dir;
273
- }
274
- throw new CliProvisionError("codex tarball has no vendor/<target>/bin/codex");
275
- },
276
291
  // A bare spawn would just ENOENT.
277
292
  notOnHost: () => new CliNotFoundError("codex", 'install it, set $CODEX_CLI_PATH, or use provision mode "auto"'),
278
293
  },
294
+ // Google's Antigravity CLI, for the gemini harness.
295
+ agy: {
296
+ title: "Antigravity CLI",
297
+ overrideEnv: "ANTIGRAVITY_CLI_PATH",
298
+ binaries: ["agy", "agy.exe"],
299
+ platforms: [
300
+ "darwin-arm64",
301
+ "darwin-x64",
302
+ "linux-arm64",
303
+ "linux-x64",
304
+ "linux-arm64-musl",
305
+ "linux-x64-musl",
306
+ "win32-arm64",
307
+ "win32-x64",
308
+ ],
309
+ // Google publishes no package: each build is a file its update manifest
310
+ // names, with a sha512 and no signature, recorded at refresh
311
+ // (`scripts/refresh-cli-releases.ts`). The tarball's one member is
312
+ // `antigravity`, which its installer puts in place as `agy`; Windows'
313
+ // build is the executable itself.
314
+ source: {
315
+ kind: "url",
316
+ executable: ({ platform }) => platform === "win32" ? { binary: "agy.exe" } : { binary: "agy", member: "antigravity" },
317
+ },
318
+ defaultVersion: () => DEFAULT_PINS.agy,
319
+ // @ref LLP 0010#source-kinds — the person's own agy updates itself: only `system` runs it
320
+ // Where Google's installers put it (`install.sh`: ~/.local/bin/agy;
321
+ // `install.ps1` and `install.cmd`: %LOCALAPPDATA%\agy\bin\agy.exe),
322
+ // then PATH, in `system` mode only: nobody chose that build for this
323
+ // engine, and it updates itself.
324
+ hostInstall: ({ platform, env, searchPath }) => {
325
+ if (!searchPath)
326
+ return undefined;
327
+ const windows = platform.platform === "win32";
328
+ const local = windows ? env.LOCALAPPDATA : (env.HOME ?? homedir());
329
+ const installed = local &&
330
+ binaryIn(windows ? join(local, "agy", "bin") : join(local, ".local", "bin"), [
331
+ windows ? "agy.exe" : "agy",
332
+ ]);
333
+ const path = installed || findOnPath("agy", env, platform.platform);
334
+ return path ? { path } : undefined;
335
+ },
336
+ notOnHost: () => new CliNotFoundError("agy", 'install Google\'s Antigravity CLI (https://antigravity.google/docs/getting-started), set $ANTIGRAVITY_CLI_PATH, or use provision mode "auto"'),
337
+ },
279
338
  };
@@ -89,8 +89,8 @@ export const refuse = {
89
89
  limitSettingUp: (retryAfter, detail) => new OperatorError("limit_setting_up", `As many workspaces as this host sets up at once are being set up. Nothing was started. Try again in about ${retryAfter}s.`, { detail, retryAfter }),
90
90
  limitRate: (count, retryAfter) => new OperatorError("limit_rate", `You started ${count} sessions in the last minute (the limit). Nothing was started. Try again in ${retryAfter}s.`, { retryAfter }),
91
91
  limitResources: (retryAfter, detail) => new OperatorError("limit_resources", `This computer cannot take another session now. Nothing was started.${retryAfter ? ` Try again in ${retryAfter}s.` : ""}`, { detail, retryAfter }),
92
- staleCursor: (hint, ref) => new OperatorError("stale_cursor", `That cursor no longer points into ${q(ref)}. Nothing was read.`, {
93
- next: hint("read_session", { session: ref }),
92
+ staleCursor: (hint, ref, selection) => new OperatorError("stale_cursor", `That cursor no longer points into ${q(ref)}. Nothing was read.`, {
93
+ next: hint("read_session", selection ? { session: ref, ...selection, full: true } : { session: ref }),
94
94
  }),
95
95
  unsupported: (detail) => new OperatorError("unsupported", `This cannot be done here. ${NOTHING}`, { detail }),
96
96
  failed: () => new OperatorError("failed", "The tool failed; nothing more is known. Try again, or tell the person."),