@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
package/CHANGELOG.md CHANGED
@@ -7,6 +7,44 @@ and the measurements. Evidence lives in the LLP, not here. A release groups
7
7
  its bullets under Breaking, Added, Changed and Fixed, breaking first. The
8
8
  released sections below that predate this convention are kept as written.
9
9
 
10
+ ## 0.3.28
11
+
12
+ ### Changed
13
+
14
+ - Claude, Codex and ACP report an unexpected process exit as `process_exit` in one sentence: the
15
+ exit status, any unanswered request, and a one-line redacted stderr summary or that it printed
16
+ nothing. A Claude exit whose stderr named an authentication failure was `auth`; a refused resume
17
+ stays `resume_failed`; Codex's `initialize` timeout shows stderr (LLP 0016.000).
18
+ - `archive` asks the host first and stops a member only when the host answers `busy` naming the
19
+ caller's own sessions, once per member: a host checks everything a stop cannot change before it
20
+ answers `busy` (LLP 0019).
21
+ - `list_models` with an unknown agent, and `list_sessions` with an unknown project or workspace,
22
+ are refused naming the valid choices, where they answered an empty list (LLP 0019).
23
+ - An unsettled `wait_for_sessions` says how long it waited and why it was cut short (the per-call
24
+ limit, the connection's end, the caller), and its retry hint keeps `until`. A wait quotes the
25
+ agent's latest reply (LLP 0019).
26
+
27
+ ### Added
28
+
29
+ - `gemini`, a harness in the default set: Gemini on Google's Antigravity CLI, `agy` 1.5.14, installed and pinned as the
30
+ other CLIs are (`$ANTIGRAVITY_CLI_PATH`; the person's own only in `system`). On every ACP agent `accept_edits` asks for
31
+ a command, no turn runs in a mode it did not ask, a level is fitted to the model and reported as run, and parts keep
32
+ their order; `AcpLaunch` takes `fixedEnv`. ACP agent `gemini` is now `gemini-cli` (LLP 0020, LLP 0016.000, LLP 0010).
33
+ - `read_session` takes `full: true` for whole message text and `page`, copied from its hint, to
34
+ continue a long read (a result holds 20,000 characters). A read that changed between pages is
35
+ `stale_cursor` with the call to start again; a clipped message names the call that reads it
36
+ whole (LLP 0019).
37
+
38
+ ### Fixed
39
+
40
+ - A Claude turn whose CLI exits before its result fails with `process_exit`, where it ended
41
+ `end_turn` with nothing: partial replies stay, unread steers are listed undelivered, a stopped
42
+ turn stays cancelled. Under an operator's own spawner the error says the turn ended without a
43
+ result (LLP 0013 F14, LLP 0016.000).
44
+ - `start_session` calls that differ only in thinking level or title start separate sessions, and
45
+ a session whose `send_message` finds the session that started it busy is told to end its turn
46
+ with the report (LLP 0019).
47
+
10
48
  ## 0.3.27
11
49
 
12
50
  ### Breaking
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @zvada/agent-server
2
2
 
3
3
  A standardized, harness-agnostic **agent execution engine**: run Claude Code,
4
- OpenAI Codex (app-server), and any [ACP](https://agentclientprotocol.com)
5
- agent behind one interface with a single normalized event stream, multi-turn
4
+ OpenAI Codex (app-server), Gemini through Google's Antigravity CLI, and any
5
+ [ACP](https://agentclientprotocol.com) agent behind one interface with a single normalized event stream, multi-turn
6
6
  sessions, resume, engine-brokered permissions, and pinned CLI provisioning.
7
7
 
8
8
  One package, seven seats — pick the subpath for how you consume it:
@@ -43,7 +43,9 @@ await runtime.run(
43
43
 
44
44
  Agent SDKs (`@anthropic-ai/claude-agent-sdk`, `@agentclientprotocol/sdk`) are
45
45
  **optional peer dependencies**, loaded lazily — a harness only needs its own
46
- SDK present. Codex needs none: its harness drives the `codex` CLI directly.
46
+ SDK present. Codex needs none: its harness drives the `codex` CLI directly. The
47
+ `gemini` harness runs Google's `agy` through the ACP SDK; the engine installs
48
+ and pins it as it does `claude` and `codex`.
47
49
 
48
50
  ## Run the wire server
49
51
 
@@ -54,7 +56,7 @@ with `bunx @zvada/agent-server`.
54
56
  bunx @zvada/agent-server --listen 4747 # WebSocket wire on 127.0.0.1
55
57
  bunx @zvada/agent-server --stdio # stdio wire (for spawners)
56
58
  bunx @zvada/agent-server --acp # act as an ACP v1 agent (Zed-spawnable)
57
- bunx @zvada/agent-server install # prefetch pinned claude/codex CLIs
59
+ bunx @zvada/agent-server install # prefetch pinned claude/codex/agy CLIs
58
60
  ```
59
61
 
60
62
  Under Node, run the compiled bin:
@@ -0,0 +1,111 @@
1
+ import { mkdtempSync, rmSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { onAbort, untilAborted } from "../../utils/deadline.js";
5
+ import { AcpClient } from "./client.js";
6
+ /** ACP protocol major version this harness speaks. */
7
+ const PROTOCOL_VERSION = 1;
8
+ /** Deadline for `initialize` on a freshly spawned agent (mirrors codex startup). */
9
+ const INITIALIZE_TIMEOUT_MS = 15_000;
10
+ /** Deadline for session lifecycle requests (`session/new`, `session/resume`). */
11
+ export const SESSION_REQUEST_TIMEOUT_MS = 30_000;
12
+ /** The profile's launch, refused when it has none; a cancel ends the wait. */
13
+ export async function launchOf(profile, signal) {
14
+ signal?.throwIfAborted();
15
+ const launch = await untilAborted(Promise.resolve(profile.launch()), signal);
16
+ signal?.throwIfAborted();
17
+ if (!launch) {
18
+ throw new Error(`${profile.harness} harness is not configured: it has no agent launch command`);
19
+ }
20
+ return launch;
21
+ }
22
+ /** Start an agent of the profile's harness on the engine's processes. */
23
+ export function startClient(start, options) {
24
+ const clientOptions = {
25
+ ...options,
26
+ clientName: start.clientName,
27
+ processes: start.processes,
28
+ harness: start.profile.harness,
29
+ };
30
+ return start.createClient ? start.createClient(clientOptions) : AcpClient.create(clientOptions);
31
+ }
32
+ /** `initialize` the agent, and refuse one its profile cannot drive. */
33
+ export async function initialize(client, start) {
34
+ const init = await client.request("initialize", {
35
+ protocolVersion: PROTOCOL_VERSION,
36
+ // The engine brokers the agent's requests for input, form or URL;
37
+ // a turn whose client cannot answer declines them.
38
+ clientCapabilities: { elicitation: { form: {}, url: {} } },
39
+ clientInfo: {
40
+ name: start.clientName ?? "agent-server",
41
+ version: start.clientVersion ?? "0.0.0",
42
+ },
43
+ }, INITIALIZE_TIMEOUT_MS);
44
+ start.profile.accept?.(init);
45
+ return init;
46
+ }
47
+ /**
48
+ * A folder of no project for an agent to start in, since an agent loads the
49
+ * rules, skills and hooks of the folder it runs in (Antigravity takes it as
50
+ * its workspace): a new one each time (`mkdtemp`, 0700), which nobody else
51
+ * can plant a project in, removed once `gone` settles (its process exited).
52
+ */
53
+ export function privateFolder() {
54
+ const path = mkdtempSync(join(tmpdir(), "agent-server-acp-"));
55
+ return {
56
+ path,
57
+ removeAfter: async (gone) => {
58
+ await gone;
59
+ rmSync(path, { recursive: true, force: true });
60
+ },
61
+ };
62
+ }
63
+ /**
64
+ * The account an agent runs on, read through a session with no turn: the
65
+ * agent starts in a folder of no project, opens a session, is used, and ends.
66
+ * Its model list and its login read it this way.
67
+ */
68
+ export class AcpAccount {
69
+ start;
70
+ constructor(start) {
71
+ this.start = start;
72
+ }
73
+ get processes() {
74
+ return this.start.processes;
75
+ }
76
+ launch(signal) {
77
+ return launchOf(this.start.profile, signal);
78
+ }
79
+ /**
80
+ * Start the agent in a folder of its own (`privateFolder`), `initialize`
81
+ * it, run `use`, and end it; `signal` ends it sooner.
82
+ */
83
+ async connect(options, use) {
84
+ const launch = await this.launch(options.signal);
85
+ const folder = privateFolder();
86
+ const cwd = folder.path;
87
+ let client;
88
+ const offAbort = onAbort(options.signal, () => client?.close());
89
+ try {
90
+ client = await startClient(this.start, {
91
+ launch,
92
+ cwd,
93
+ ...(options.env && { env: options.env }),
94
+ });
95
+ options.signal?.throwIfAborted();
96
+ return await use(client, await initialize(client, this.start), cwd);
97
+ }
98
+ finally {
99
+ offAbort();
100
+ client?.close();
101
+ await folder.removeAfter(client?.gone());
102
+ }
103
+ }
104
+ /** As `connect`, with a session opened in its folder for `use`, and never prompted. */
105
+ open(options, use) {
106
+ return this.connect(options, async (client, init, cwd) => {
107
+ const session = await client.request("session/new", { cwd, mcpServers: [] }, SESSION_REQUEST_TIMEOUT_MS);
108
+ return use(client, { init, session });
109
+ });
110
+ }
111
+ }