@zvada/agent-server 0.3.26 → 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.
- package/CHANGELOG.md +71 -0
- package/README.md +7 -5
- package/dist/client/client.js +27 -11
- package/dist/client/connection.js +35 -3
- package/dist/core/agents/acp/account.js +111 -0
- package/dist/core/agents/acp/acp-agent.js +247 -158
- package/dist/core/agents/acp/adapter.js +103 -34
- package/dist/core/agents/acp/client.js +169 -42
- package/dist/core/agents/acp/known-agents.js +12 -5
- package/dist/core/agents/acp/mappings.js +84 -20
- package/dist/core/agents/acp/models.js +59 -0
- package/dist/core/agents/acp/profile.js +36 -0
- package/dist/core/agents/acp/prompts.js +248 -0
- package/dist/core/agents/acp/requests.js +4 -4
- package/dist/core/agents/claude-code/approvals.js +1 -1
- package/dist/core/agents/claude-code/login.js +4 -1
- package/dist/core/agents/claude-code/session.js +38 -10
- package/dist/core/agents/claude-code/spawn.js +0 -26
- package/dist/core/agents/codex-app-server/client.js +12 -13
- package/dist/core/agents/codex-app-server/login.js +4 -1
- package/dist/core/agents/codex-app-server/plan-approval.js +1 -1
- package/dist/core/agents/gemini/failures.js +133 -0
- package/dist/core/agents/gemini/login.js +173 -0
- package/dist/core/agents/gemini/profile.js +137 -0
- package/dist/core/agents/gemini/tools.js +91 -0
- package/dist/core/agents/login.js +8 -6
- package/dist/core/agents/scripted/scripted-agent.js +30 -3
- package/dist/core/agents/stderr-tail.js +5 -2
- package/dist/core/presets.js +17 -1
- package/dist/core/processes/native-processes.js +23 -1
- package/dist/core/provision/install-build.js +70 -26
- package/dist/core/provision/pins.js +5 -0
- package/dist/core/provision/provisioner.js +39 -16
- package/dist/core/provision/releases.js +39 -1
- package/dist/core/provision/tools.js +87 -28
- package/dist/core/runtime/agent-runtime.js +15 -5
- package/dist/core/runtime/event-processor.js +13 -8
- package/dist/core/runtime/origin-line.js +42 -0
- package/dist/core/runtime/request-broker.js +2 -1
- package/dist/core/runtime/steering.js +4 -3
- package/dist/core/runtime/turn.js +6 -4
- package/dist/operator/errors.js +97 -0
- package/dist/operator/index.js +10 -5
- package/dist/operator/mcp.js +7 -12
- package/dist/operator/operator.js +1431 -378
- package/dist/operator/refs.js +59 -0
- package/dist/operator/render.js +199 -94
- package/dist/operator/session-tools.js +88 -0
- package/dist/operator/types.js +30 -0
- package/dist/operator/view.js +82 -27
- package/dist/protocol/account.js +5 -1
- package/dist/protocol/auth.js +5 -1
- package/dist/protocol/config.js +12 -5
- package/dist/protocol/conversation.js +3 -0
- package/dist/protocol/credentials.js +9 -1
- package/dist/protocol/harness.js +9 -1
- package/dist/protocol/history.js +2 -1
- package/dist/protocol/index.js +1 -0
- package/dist/protocol/lifecycle.js +19 -0
- package/dist/protocol/origin.js +39 -0
- package/dist/protocol/reduce.js +2 -0
- package/dist/protocol/wire.js +17 -0
- package/dist/server/bin.js +22 -7
- package/dist/server/install.js +6 -4
- package/dist/server/routes.js +15 -5
- package/dist/types/client/client.d.ts.map +1 -1
- package/dist/types/client/connection.d.ts +14 -2
- package/dist/types/client/connection.d.ts.map +1 -1
- package/dist/types/client/turns.d.ts +2 -2
- package/dist/types/client/turns.d.ts.map +1 -1
- package/dist/types/core/agents/acp/account.d.ts +55 -0
- package/dist/types/core/agents/acp/account.d.ts.map +1 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts +65 -36
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -1
- package/dist/types/core/agents/acp/adapter.d.ts +28 -3
- package/dist/types/core/agents/acp/adapter.d.ts.map +1 -1
- package/dist/types/core/agents/acp/client.d.ts +66 -4
- package/dist/types/core/agents/acp/client.d.ts.map +1 -1
- package/dist/types/core/agents/acp/known-agents.d.ts +4 -2
- package/dist/types/core/agents/acp/known-agents.d.ts.map +1 -1
- package/dist/types/core/agents/acp/mappings.d.ts +53 -7
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -1
- package/dist/types/core/agents/acp/models.d.ts +22 -0
- package/dist/types/core/agents/acp/models.d.ts.map +1 -0
- package/dist/types/core/agents/acp/profile.d.ts +92 -0
- package/dist/types/core/agents/acp/profile.d.ts.map +1 -0
- package/dist/types/core/agents/acp/prompts.d.ts +108 -0
- package/dist/types/core/agents/acp/prompts.d.ts.map +1 -0
- package/dist/types/core/agents/acp/requests.d.ts +7 -1
- package/dist/types/core/agents/acp/requests.d.ts.map +1 -1
- package/dist/types/core/agents/base.d.ts +2 -0
- package/dist/types/core/agents/base.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/login.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/session.d.ts +3 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/spawn.d.ts +0 -8
- package/dist/types/core/agents/claude-code/spawn.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -1
- package/dist/types/core/agents/gemini/failures.d.ts +25 -0
- package/dist/types/core/agents/gemini/failures.d.ts.map +1 -0
- package/dist/types/core/agents/gemini/login.d.ts +28 -0
- package/dist/types/core/agents/gemini/login.d.ts.map +1 -0
- package/dist/types/core/agents/gemini/profile.d.ts +30 -0
- package/dist/types/core/agents/gemini/profile.d.ts.map +1 -0
- package/dist/types/core/agents/gemini/tools.d.ts +18 -0
- package/dist/types/core/agents/gemini/tools.d.ts.map +1 -0
- package/dist/types/core/agents/login.d.ts +15 -5
- package/dist/types/core/agents/login.d.ts.map +1 -1
- package/dist/types/core/agents/scripted/scripted-agent.d.ts +14 -1
- package/dist/types/core/agents/scripted/scripted-agent.d.ts.map +1 -1
- package/dist/types/core/agents/stderr-tail.d.ts +1 -1
- package/dist/types/core/agents/stderr-tail.d.ts.map +1 -1
- package/dist/types/core/presets.d.ts +2 -2
- package/dist/types/core/presets.d.ts.map +1 -1
- package/dist/types/core/processes/native-processes.d.ts +6 -0
- package/dist/types/core/processes/native-processes.d.ts.map +1 -1
- package/dist/types/core/provision/checksums.d.ts +7 -1
- package/dist/types/core/provision/checksums.d.ts.map +1 -1
- package/dist/types/core/provision/install-build.d.ts +32 -6
- package/dist/types/core/provision/install-build.d.ts.map +1 -1
- package/dist/types/core/provision/pins.d.ts +4 -0
- package/dist/types/core/provision/pins.d.ts.map +1 -1
- package/dist/types/core/provision/provisioner.d.ts +18 -7
- package/dist/types/core/provision/provisioner.d.ts.map +1 -1
- package/dist/types/core/provision/releases.d.ts +2 -1
- package/dist/types/core/provision/releases.d.ts.map +1 -1
- package/dist/types/core/provision/tools.d.ts +36 -7
- package/dist/types/core/provision/tools.d.ts.map +1 -1
- package/dist/types/core/runtime/agent-runtime.d.ts +4 -2
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -1
- package/dist/types/core/runtime/event-processor.d.ts +2 -2
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -1
- package/dist/types/core/runtime/origin-line.d.ts +15 -0
- package/dist/types/core/runtime/origin-line.d.ts.map +1 -0
- package/dist/types/core/runtime/request-broker.d.ts +1 -1
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -1
- package/dist/types/core/runtime/steering.d.ts +7 -4
- package/dist/types/core/runtime/steering.d.ts.map +1 -1
- package/dist/types/core/runtime/turn.d.ts.map +1 -1
- package/dist/types/operator/errors.d.ts +87 -0
- package/dist/types/operator/errors.d.ts.map +1 -0
- package/dist/types/operator/index.d.ts +10 -5
- package/dist/types/operator/index.d.ts.map +1 -1
- package/dist/types/operator/mcp.d.ts +1 -1
- package/dist/types/operator/mcp.d.ts.map +1 -1
- package/dist/types/operator/operator.d.ts +15 -197
- package/dist/types/operator/operator.d.ts.map +1 -1
- package/dist/types/operator/refs.d.ts +25 -0
- package/dist/types/operator/refs.d.ts.map +1 -0
- package/dist/types/operator/render.d.ts +67 -22
- package/dist/types/operator/render.d.ts.map +1 -1
- package/dist/types/operator/session-tools.d.ts +61 -0
- package/dist/types/operator/session-tools.d.ts.map +1 -0
- package/dist/types/operator/types.d.ts +442 -0
- package/dist/types/operator/types.d.ts.map +1 -0
- package/dist/types/operator/view.d.ts +19 -29
- package/dist/types/operator/view.d.ts.map +1 -1
- package/dist/types/protocol/account.d.ts +4 -2
- package/dist/types/protocol/account.d.ts.map +1 -1
- package/dist/types/protocol/auth.d.ts +10 -7
- package/dist/types/protocol/auth.d.ts.map +1 -1
- package/dist/types/protocol/clis.d.ts +4 -3
- package/dist/types/protocol/clis.d.ts.map +1 -1
- package/dist/types/protocol/config.d.ts +22 -5
- package/dist/types/protocol/config.d.ts.map +1 -1
- package/dist/types/protocol/conversation.d.ts +47 -6
- package/dist/types/protocol/conversation.d.ts.map +1 -1
- package/dist/types/protocol/credentials.d.ts +8 -0
- package/dist/types/protocol/credentials.d.ts.map +1 -1
- package/dist/types/protocol/execution.d.ts +1 -1
- package/dist/types/protocol/harness.d.ts +5 -2
- package/dist/types/protocol/harness.d.ts.map +1 -1
- package/dist/types/protocol/history.d.ts +1 -1
- package/dist/types/protocol/history.d.ts.map +1 -1
- package/dist/types/protocol/index.d.ts +1 -0
- package/dist/types/protocol/index.d.ts.map +1 -1
- package/dist/types/protocol/lifecycle.d.ts +48 -10
- package/dist/types/protocol/lifecycle.d.ts.map +1 -1
- package/dist/types/protocol/models.d.ts +3 -0
- package/dist/types/protocol/models.d.ts.map +1 -1
- package/dist/types/protocol/origin.d.ts +49 -0
- package/dist/types/protocol/origin.d.ts.map +1 -0
- package/dist/types/protocol/reduce.d.ts.map +1 -1
- package/dist/types/protocol/wire-api.d.ts +78 -30
- package/dist/types/protocol/wire-api.d.ts.map +1 -1
- package/dist/types/protocol/wire.d.ts +78 -12
- package/dist/types/protocol/wire.d.ts.map +1 -1
- package/dist/types/server/install.d.ts +2 -1
- package/dist/types/server/install.d.ts.map +1 -1
- package/dist/types/server/routes.d.ts.map +1 -1
- package/docs/consuming.md +62 -121
- package/docs/deploy.md +17 -8
- package/docs/harnesses.md +166 -44
- package/docs/sync-history.md +2 -1
- package/package.json +1 -1
- package/src/client/client.ts +36 -9
- package/src/client/connection.ts +31 -1
- package/src/client/turns.ts +2 -1
- package/src/core/agents/acp/account.ts +158 -0
- package/src/core/agents/acp/acp-agent.ts +288 -178
- package/src/core/agents/acp/adapter.ts +126 -35
- package/src/core/agents/acp/client.ts +196 -49
- package/src/core/agents/acp/known-agents.ts +14 -5
- package/src/core/agents/acp/mappings.ts +112 -21
- package/src/core/agents/acp/models.ts +72 -0
- package/src/core/agents/acp/profile.ts +127 -0
- package/src/core/agents/acp/prompts.ts +287 -0
- package/src/core/agents/acp/requests.ts +16 -9
- package/src/core/agents/base.ts +2 -0
- package/src/core/agents/claude-code/approvals.ts +2 -2
- package/src/core/agents/claude-code/login.ts +4 -1
- package/src/core/agents/claude-code/session.ts +38 -8
- package/src/core/agents/claude-code/spawn.ts +0 -26
- package/src/core/agents/codex-app-server/client.ts +11 -18
- package/src/core/agents/codex-app-server/login.ts +4 -5
- package/src/core/agents/codex-app-server/plan-approval.ts +1 -1
- package/src/core/agents/gemini/failures.ts +148 -0
- package/src/core/agents/gemini/login.ts +188 -0
- package/src/core/agents/gemini/profile.ts +162 -0
- package/src/core/agents/gemini/tools.ts +99 -0
- package/src/core/agents/login.ts +14 -8
- package/src/core/agents/scripted/scripted-agent.ts +42 -3
- package/src/core/agents/stderr-tail.ts +5 -2
- package/src/core/presets.ts +19 -3
- package/src/core/processes/native-processes.ts +32 -1
- package/src/core/provision/checksums.ts +12 -2
- package/src/core/provision/install-build.ts +122 -55
- package/src/core/provision/pins.ts +5 -0
- package/src/core/provision/provisioner.ts +62 -27
- package/src/core/provision/releases.ts +47 -1
- package/src/core/provision/tools.ts +124 -31
- package/src/core/runtime/agent-runtime.ts +31 -7
- package/src/core/runtime/event-processor.ts +13 -6
- package/src/core/runtime/origin-line.ts +43 -0
- package/src/core/runtime/request-broker.ts +2 -0
- package/src/core/runtime/steering.ts +8 -4
- package/src/core/runtime/turn.ts +11 -4
- package/src/operator/errors.ts +221 -0
- package/src/operator/index.ts +18 -23
- package/src/operator/mcp.ts +7 -16
- package/src/operator/operator.ts +1684 -610
- package/src/operator/refs.ts +75 -0
- package/src/operator/render.ts +260 -118
- package/src/operator/session-tools.ts +127 -0
- package/src/operator/types.ts +506 -0
- package/src/operator/view.ts +93 -42
- package/src/protocol/account.ts +5 -2
- package/src/protocol/auth.ts +5 -1
- package/src/protocol/config.ts +14 -6
- package/src/protocol/conversation.ts +3 -0
- package/src/protocol/credentials.ts +11 -2
- package/src/protocol/harness.ts +9 -1
- package/src/protocol/history.ts +2 -1
- package/src/protocol/index.ts +1 -0
- package/src/protocol/lifecycle.ts +21 -0
- package/src/protocol/origin.ts +47 -0
- package/src/protocol/reduce.ts +4 -0
- package/src/protocol/wire.ts +18 -0
- package/src/server/bin.ts +20 -6
- package/src/server/install.ts +6 -3
- package/src/server/routes.ts +16 -5
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,77 @@ 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
|
+
|
|
48
|
+
## 0.3.27
|
|
49
|
+
|
|
50
|
+
### Breaking
|
|
51
|
+
|
|
52
|
+
- `./operator` is v2 and replaces v1: callers are `SessionCaller` or `ExternalCaller`,
|
|
53
|
+
the host is the new `OperatorHost` (`list`, `view`, `send` and capabilities), and the
|
|
54
|
+
tools are `whoami`, `list_sessions`, `read_session`, `wait_for_sessions`, `list_models`,
|
|
55
|
+
`start_session`, `send_message`, `answer_request`, `stop_sessions`, `archive` (LLP 0019).
|
|
56
|
+
- The operator holds nothing between calls: a message is sent only while its call is
|
|
57
|
+
open. A host refuses at its own commit by throwing `Refused` (code, sessions, state);
|
|
58
|
+
caps across starters are the host's, and `start` delivers the first task as the turn
|
|
59
|
+
`StartInput.turnId` (LLP 0019).
|
|
60
|
+
|
|
61
|
+
### Added
|
|
62
|
+
|
|
63
|
+
- `origin` on `turn/start`, `turn/steer` and `RunRequest` (`OriginSchema`: `person`,
|
|
64
|
+
`session`, `assistant`): the agent reads one line saying an agent sent it, the user
|
|
65
|
+
message's `message.started` carries `origin`, and a retry from another sender is
|
|
66
|
+
`turnConflict`. `initialize` answers `features: ["origin"]`; the client refuses a
|
|
67
|
+
non-person origin to a server without it, re-sends after a redial included. An
|
|
68
|
+
origin's ids and names are at most 255 characters (`ORIGIN_FIELD_MAX`); a
|
|
69
|
+
`TurnHandle`'s `steer` takes one. Conversation checkpoints are format `v2` (LLP 0019).
|
|
70
|
+
- `permission.requested` says what it decides: `purpose` is `plan` for a plan's
|
|
71
|
+
approval and `tool` otherwise (`PERMISSION_PURPOSES`, open; none reads as `tool`).
|
|
72
|
+
`./operator` reads a plan from it, not from its option ids (LLP 0002, Permissions).
|
|
73
|
+
- `operatorSessionTools` and `OPERATOR_GUIDANCE`: the operator as a session's own
|
|
74
|
+
tools, through the engine's delivery of host tools (LLP 0019, LLP 0018).
|
|
75
|
+
- A host's own tool is given its call's deadline and signal (`CallScope`), and a
|
|
76
|
+
refusal's archive hint names a workspace's only chat as its workspace (`Archivable`;
|
|
77
|
+
`refuse.hasChildren` and `refuse.limitSessions` take one) (LLP 0019).
|
|
78
|
+
- `OperatorOptions.onError(error, tool, caller)`: the host sees each unexpected failure a
|
|
79
|
+
call answers without, once; never a refusal, and it cannot change the answer (LLP 0019).
|
|
80
|
+
|
|
10
81
|
## 0.3.26
|
|
11
82
|
|
|
12
83
|
### 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
|
|
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:
|
|
@@ -14,7 +14,7 @@ One package, seven seats — pick the subpath for how you consume it:
|
|
|
14
14
|
| `@zvada/agent-server/server` | **The standard wire** — serve the engine over JSON-RPC 2.0 NDJSON (stdio / WebSocket listen / dial-out) with quick-ack turns, per-session `seq`, bounded replay, and an ACP v1 binding (`--acp`). Ships the `agent-server` bin. |
|
|
15
15
|
| `@zvada/agent-server/client` | **The typed consumer client** — spawn/connect/attach, `runTurn` as an async iterable, permission responses, reconnect with sequenced replay healing (a turn start whose ack a dropped connection lost is re-sent and joins the running turn), `subscribe` / `joinTurn` to follow a session or a turn another client started, the harnesses' logins (`authStatus`, `login`). Depends only on the contract + node builtins. |
|
|
16
16
|
| `@zvada/agent-server/accounts` | **A login the product holds** — sign a subscription in for a credential the product stores (ChatGPT, Claude), renew it, and answer each turn's credential request (`createCredentialHandler`, `credentialsFrom`). `fetch` and Web Crypto only: it runs in a Worker. |
|
|
17
|
-
| `@zvada/agent-server/operator` | **Operator tools** — the session tools an outside
|
|
17
|
+
| `@zvada/agent-server/operator` | **Operator tools** — the session tools an outside assistant, your window or your own sessions' agents operate your product's coding agents with, over an `OperatorHost` you implement, and a dependency-free MCP binding (`createMcpHandler`). Protocol and zod only. See [consuming](docs/consuming.md#let-agents-operate-your-sessions), LLP 0014 and LLP 0019. |
|
|
18
18
|
| `@zvada/agent-server/sync` | **Experimental.** Optional durable journal port and history helpers: transfer, open, follow, managed sync. |
|
|
19
19
|
| `@zvada/agent-server/sync/sqlite` | **Experimental.** Bun SQLite journal with its history and checkpoint store. |
|
|
20
20
|
| `@zvada/agent-server/sync/node-sqlite` | **Experimental.** Same storage under Node >=22.16 using built-in SQLite (itself experimental in Node 22). |
|
|
@@ -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:
|
package/dist/client/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthUpdatedSchema, HarnessCliProgressSchema, SessionOverflowParamsSchema, WIRE_ERROR_CODES, WIRE_METHODS, decodeWireEventEnvelope, decodeWireMessage, generateUUIDv7, } from "../protocol/index.js";
|
|
1
|
+
import { AuthUpdatedSchema, HarnessCliProgressSchema, SessionOverflowParamsSchema, WIRE_ERROR_CODES, WIRE_FEATURES, WIRE_METHODS, agentOrigin, decodeWireEventEnvelope, decodeWireMessage, generateUUIDv7, } from "../protocol/index.js";
|
|
2
2
|
import { Connection, ConnectionClosedError, ConnectionRefusedError, ProtocolVersionMismatchError, } from "./connection.js";
|
|
3
3
|
import { createHistoryClient } from "./history.js";
|
|
4
4
|
import { Listeners } from "./listeners.js";
|
|
@@ -163,7 +163,7 @@ export class AgentServerClient {
|
|
|
163
163
|
// Before the first `await`: a cancel sent right behind this call goes out after the start.
|
|
164
164
|
const release = this.starts.begin(sessionId, turnId);
|
|
165
165
|
try {
|
|
166
|
-
await this.initialize();
|
|
166
|
+
carriesOrigin(await this.initialize(), params.origin);
|
|
167
167
|
if (this.turns.running(sessionId))
|
|
168
168
|
throw new Error(`session ${sessionId} already has an active turn`);
|
|
169
169
|
const handle = this.turns.open(sessionId, turnId, true);
|
|
@@ -175,7 +175,7 @@ export class AgentServerClient {
|
|
|
175
175
|
(ack) => {
|
|
176
176
|
if (!ack.terminal)
|
|
177
177
|
this.joinAt(handle, ack.headSeq, { turnId });
|
|
178
|
-
});
|
|
178
|
+
}, (server) => carriesOrigin(server, params.origin));
|
|
179
179
|
release();
|
|
180
180
|
const accepted = await sending;
|
|
181
181
|
const { terminal } = accepted;
|
|
@@ -211,12 +211,12 @@ export class AgentServerClient {
|
|
|
211
211
|
// As in `runTurn`: a cancel sent right behind this call goes out after the start.
|
|
212
212
|
const release = this.starts.begin(sessionId, turnId);
|
|
213
213
|
try {
|
|
214
|
-
await this.initialize();
|
|
214
|
+
carriesOrigin(await this.initialize(), params.origin);
|
|
215
215
|
// `request` sends (or fails for no connection) in this call.
|
|
216
216
|
const answer = this.connection.request(WIRE_METHODS.turnStart, { ...params, sessionId, turnId }, (ack) => {
|
|
217
217
|
if (params.subscribe !== false && !ack.terminal)
|
|
218
218
|
this.streams.joined(sessionId, ack.headSeq, { turnId });
|
|
219
|
-
});
|
|
219
|
+
}, (server) => carriesOrigin(server, params.origin));
|
|
220
220
|
release();
|
|
221
221
|
return await answer;
|
|
222
222
|
}
|
|
@@ -263,7 +263,7 @@ export class AgentServerClient {
|
|
|
263
263
|
* steer's user message, its receipt, reaches it.
|
|
264
264
|
*/
|
|
265
265
|
async steerTurn(params) {
|
|
266
|
-
await this.initialize();
|
|
266
|
+
carriesOrigin(await this.initialize(), params.origin);
|
|
267
267
|
const { sessionId, turnId } = params;
|
|
268
268
|
// One it cannot subscribe to still takes the steer; only its receipt is lost.
|
|
269
269
|
if (!this.streams.follows(sessionId))
|
|
@@ -272,10 +272,7 @@ export class AgentServerClient {
|
|
|
272
272
|
if (ack.activeTurn?.turnId === turnId)
|
|
273
273
|
this.streams.joined(sessionId, ack.headSeq, { turnId });
|
|
274
274
|
}).catch(() => undefined);
|
|
275
|
-
return this.connection.resend(WIRE_METHODS.turnSteer, {
|
|
276
|
-
...params,
|
|
277
|
-
steerId: params.steerId ?? generateUUIDv7(),
|
|
278
|
-
});
|
|
275
|
+
return this.connection.resend(WIRE_METHODS.turnSteer, { ...params, steerId: params.steerId ?? generateUUIDv7() }, undefined, (server) => carriesOrigin(server, params.origin));
|
|
279
276
|
}
|
|
280
277
|
/**
|
|
281
278
|
* Cancel the session's active turn; resolves once cancellation propagated.
|
|
@@ -669,7 +666,13 @@ export class AgentServerClient {
|
|
|
669
666
|
get catchUp() {
|
|
670
667
|
return handle.catchUp;
|
|
671
668
|
},
|
|
672
|
-
steer: (input, steerId) => this.steerTurn({
|
|
669
|
+
steer: (input, steerId, origin) => this.steerTurn({
|
|
670
|
+
sessionId,
|
|
671
|
+
turnId,
|
|
672
|
+
input,
|
|
673
|
+
...(steerId !== undefined && { steerId }),
|
|
674
|
+
...(origin && { origin }),
|
|
675
|
+
}),
|
|
673
676
|
};
|
|
674
677
|
}
|
|
675
678
|
/**
|
|
@@ -743,3 +746,16 @@ export class AgentServerClient {
|
|
|
743
746
|
return this.connection.request(WIRE_METHODS.sessionSubscribe, params, onAnswer);
|
|
744
747
|
}
|
|
745
748
|
}
|
|
749
|
+
// @ref LLP 0019#origin-on-the-wire-and-to-the-model — fail closed: an origin a server would strip reads as the person's
|
|
750
|
+
/**
|
|
751
|
+
* Refuse to send another sender's input to a server that does not carry
|
|
752
|
+
* `origin`: its schema would drop the field, and the agent would read the
|
|
753
|
+
* message as the person's. The person's input goes anywhere.
|
|
754
|
+
*/
|
|
755
|
+
function carriesOrigin(server, origin) {
|
|
756
|
+
if (!agentOrigin(origin))
|
|
757
|
+
return;
|
|
758
|
+
if (server.features?.includes(WIRE_FEATURES.origin))
|
|
759
|
+
return;
|
|
760
|
+
throw new Error("This server does not carry a message's origin (no `origin` in its features); nothing was sent. Upgrade the server, or send the input as the person's.");
|
|
761
|
+
}
|
|
@@ -73,6 +73,10 @@ export class Connection {
|
|
|
73
73
|
/** The server process (or, durable, the journal) whose logs the client follows. */
|
|
74
74
|
serverIdentity;
|
|
75
75
|
initializing = null;
|
|
76
|
+
/** The current transport's handshake, once answered; cleared when it is asked again. */
|
|
77
|
+
negotiated;
|
|
78
|
+
/** The transport `negotiated` was answered on: a feature check holds only for it. */
|
|
79
|
+
negotiatedOn = null;
|
|
76
80
|
reconnecting = false;
|
|
77
81
|
/** Ends the redial backoff early: `close()` must not wait it out. */
|
|
78
82
|
stopBackoff = null;
|
|
@@ -110,6 +114,10 @@ export class Connection {
|
|
|
110
114
|
if (transport.closed)
|
|
111
115
|
throw new ConnectionClosedError("transport opened already closed");
|
|
112
116
|
this.transport = transport;
|
|
117
|
+
// A new transport's server is not the old one's until its own handshake says so.
|
|
118
|
+
this.initializing = null;
|
|
119
|
+
this.negotiated = undefined;
|
|
120
|
+
this.negotiatedOn = null;
|
|
113
121
|
this.host.opened(this.reconnecting);
|
|
114
122
|
transport.onLine((line) => {
|
|
115
123
|
if (this.transport === transport)
|
|
@@ -122,6 +130,9 @@ export class Connection {
|
|
|
122
130
|
* client for good: it rejects with `ProtocolVersionMismatchError`.
|
|
123
131
|
*/
|
|
124
132
|
initialize() {
|
|
133
|
+
if (!this.initializing)
|
|
134
|
+
this.negotiated = undefined;
|
|
135
|
+
const on = this.transport;
|
|
125
136
|
this.initializing ??= this.request(WIRE_METHODS.initialize, {
|
|
126
137
|
protocolVersion: WIRE_PROTOCOL_VERSION,
|
|
127
138
|
client: this.options.clientInfo,
|
|
@@ -137,6 +148,8 @@ export class Connection {
|
|
|
137
148
|
if (this.serverIdentity !== undefined && this.serverIdentity !== identity)
|
|
138
149
|
this.host.serverChanged();
|
|
139
150
|
this.serverIdentity = identity;
|
|
151
|
+
this.negotiated = result;
|
|
152
|
+
this.negotiatedOn = on;
|
|
140
153
|
return result;
|
|
141
154
|
})
|
|
142
155
|
.catch((error) => {
|
|
@@ -156,12 +169,25 @@ export class Connection {
|
|
|
156
169
|
return this.refusal ?? refusal;
|
|
157
170
|
}
|
|
158
171
|
/** A request, its answer read as `WIRE_API` reads the method's. */
|
|
159
|
-
request(method, params, onAnswer
|
|
172
|
+
request(method, params, onAnswer,
|
|
173
|
+
/** Asked with the handshake of the very transport the request goes on; throw to send nothing. */
|
|
174
|
+
admit) {
|
|
160
175
|
if (this.closed)
|
|
161
176
|
return Promise.reject(this.refusal ?? new ConnectionClosedError("client closed"));
|
|
162
177
|
const transport = this.transport;
|
|
163
178
|
if (!transport)
|
|
164
179
|
return Promise.reject(new ConnectionClosedError("not connected"));
|
|
180
|
+
if (admit) {
|
|
181
|
+
// This transport's handshake not answered yet: wait for it, then ask again.
|
|
182
|
+
if (this.negotiatedOn !== transport || !this.negotiated)
|
|
183
|
+
return this.initialize().then(() => this.request(method, params, onAnswer, admit));
|
|
184
|
+
try {
|
|
185
|
+
admit(this.negotiated);
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
return Promise.reject(error);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
165
191
|
return this.rpc.request(transport, method, params, WIRE_API[method].decode, onAnswer);
|
|
166
192
|
}
|
|
167
193
|
/**
|
|
@@ -173,11 +199,17 @@ export class Connection {
|
|
|
173
199
|
* re-sends at most: a server that accepts connections but never answers
|
|
174
200
|
* would otherwise be retried forever.
|
|
175
201
|
*/
|
|
176
|
-
async resend(method, params, onAnswer
|
|
202
|
+
async resend(method, params, onAnswer,
|
|
203
|
+
/**
|
|
204
|
+
* Asked with the server this attempt goes to, before each send, re-sends
|
|
205
|
+
* included: a redial may reach another build of the server. Throw to send
|
|
206
|
+
* nothing (LLP 0019: an origin that server would strip).
|
|
207
|
+
*/
|
|
208
|
+
admit) {
|
|
177
209
|
for (let resends = 0;; resends++) {
|
|
178
210
|
const identity = this.serverIdentity;
|
|
179
211
|
try {
|
|
180
|
-
return await this.request(method, params, onAnswer);
|
|
212
|
+
return await this.request(method, params, onAnswer, admit);
|
|
181
213
|
}
|
|
182
214
|
catch (error) {
|
|
183
215
|
if (!(error instanceof ConnectionClosedError) || !this.redials || resends >= MAX_RESENDS)
|
|
@@ -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
|
+
}
|