@zvada/agent-server 0.2.0
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/LICENSE +21 -0
- package/README.md +71 -0
- package/package.json +87 -0
- package/src/client/client.ts +589 -0
- package/src/client/index.ts +18 -0
- package/src/client/transports.ts +84 -0
- package/src/core/agents/acp/acp-agent.ts +322 -0
- package/src/core/agents/acp/adapter.ts +260 -0
- package/src/core/agents/acp/client.ts +212 -0
- package/src/core/agents/acp/known-agents.ts +29 -0
- package/src/core/agents/acp/mappings.ts +136 -0
- package/src/core/agents/base.ts +145 -0
- package/src/core/agents/claude-code/adapter.ts +451 -0
- package/src/core/agents/claude-code/claude-agent.ts +235 -0
- package/src/core/agents/claude-code/generator-session.ts +344 -0
- package/src/core/agents/claude-code/options.ts +161 -0
- package/src/core/agents/claude-code/session-manager.ts +159 -0
- package/src/core/agents/codex-app-server/adapter.ts +214 -0
- package/src/core/agents/codex-app-server/client.ts +221 -0
- package/src/core/agents/codex-app-server/codex-app-server-agent.ts +385 -0
- package/src/core/agents/codex-items.ts +122 -0
- package/src/core/agents/codex-sdk/adapter.ts +204 -0
- package/src/core/agents/codex-sdk/codex-sdk-agent.ts +236 -0
- package/src/core/agents/config-fingerprint.ts +19 -0
- package/src/core/agents/error-classifier.ts +68 -0
- package/src/core/agents/registry.ts +40 -0
- package/src/core/agents/session-store.ts +72 -0
- package/src/core/agents/tool-meta.ts +68 -0
- package/src/core/agents/types.ts +54 -0
- package/src/core/index.ts +114 -0
- package/src/core/presets.ts +78 -0
- package/src/core/provision/extract.ts +31 -0
- package/src/core/provision/index.ts +10 -0
- package/src/core/provision/npm.ts +114 -0
- package/src/core/provision/pins.ts +51 -0
- package/src/core/provision/platform.ts +73 -0
- package/src/core/provision/provisioner.ts +478 -0
- package/src/core/proxy/anthropic-proxy.ts +69 -0
- package/src/core/proxy/api-key-store.ts +34 -0
- package/src/core/proxy/index.ts +7 -0
- package/src/core/runtime/agent-runtime.ts +363 -0
- package/src/core/runtime/event-processor.ts +218 -0
- package/src/core/runtime/event-sink.ts +37 -0
- package/src/core/utils/errors.ts +41 -0
- package/src/index.ts +4 -0
- package/src/protocol/async-queue.ts +68 -0
- package/src/protocol/config.ts +100 -0
- package/src/protocol/factories.ts +125 -0
- package/src/protocol/harness.ts +50 -0
- package/src/protocol/ids.ts +53 -0
- package/src/protocol/index.ts +16 -0
- package/src/protocol/lifecycle.ts +309 -0
- package/src/protocol/models.ts +45 -0
- package/src/protocol/part-input.ts +58 -0
- package/src/protocol/parts.ts +60 -0
- package/src/protocol/thinking.ts +32 -0
- package/src/protocol/tokens.ts +39 -0
- package/src/protocol/tool-state.ts +89 -0
- package/src/protocol/wire.ts +313 -0
- package/src/server/acp/binding.ts +163 -0
- package/src/server/acp/translate.ts +160 -0
- package/src/server/agent-server.ts +357 -0
- package/src/server/bin.ts +174 -0
- package/src/server/index.ts +24 -0
- package/src/server/install.ts +51 -0
- package/src/server/session-log.ts +66 -0
- package/src/server/transports.ts +149 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Adam Zvada
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# @zvada/agent-server
|
|
2
|
+
|
|
3
|
+
A standardized, harness-agnostic **agent execution engine**: run Claude Code,
|
|
4
|
+
OpenAI Codex (SDK + app-server), and any [ACP](https://agentclientprotocol.com)
|
|
5
|
+
agent behind one interface with a single normalized event stream, multi-turn
|
|
6
|
+
sessions, resume, engine-brokered permissions, and pinned CLI provisioning.
|
|
7
|
+
|
|
8
|
+
One package, four seats — pick the subpath for how you consume it:
|
|
9
|
+
|
|
10
|
+
| Import | Seat |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| `@zvada/agent-server` (or `/protocol`) | **The wire contract** — zod schemas for `Part`, `LifecycleEvent`, `RunRequest`, wire method envelopes, harness/model/thinking vocabulary, token usage, UUIDv7 ids. Zod-only, safe in any runtime (workers, browsers, node, bun). |
|
|
13
|
+
| `@zvada/agent-server/core` | **The engine** — `AgentRuntime`, harness agents + adapters, registry, CLI provisioning. Embed it in-process behind an `EventSink`. |
|
|
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
|
+
| `@zvada/agent-server/client` | **The typed consumer client** — spawn/connect/attach, `runTurn` as an async iterable, permission responses, reconnect with sequenced replay healing. Depends only on the contract + node builtins. |
|
|
16
|
+
| `@zvada/agent-server/core/proxy` | Optional BYOK Anthropic proxy building block. |
|
|
17
|
+
|
|
18
|
+
## Embed the engine
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { AgentRuntime, callbackSink, createAgentRegistry } from "@zvada/agent-server/core";
|
|
22
|
+
|
|
23
|
+
const runtime = new AgentRuntime(createAgentRegistry({ provision: { mode: "pinned" } }));
|
|
24
|
+
await runtime.run(
|
|
25
|
+
{
|
|
26
|
+
sessionId: "s1",
|
|
27
|
+
input: "What does this repo do?",
|
|
28
|
+
config: { harness: "claude-code", cwd: process.cwd(), thinkingLevel: "high" },
|
|
29
|
+
},
|
|
30
|
+
callbackSink((event) => console.log(event.type)),
|
|
31
|
+
);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Agent SDKs (`@anthropic-ai/claude-agent-sdk`, `@openai/codex-sdk`,
|
|
35
|
+
`@agentclientprotocol/sdk`) are **optional peer dependencies**, loaded lazily —
|
|
36
|
+
a harness only needs its own SDK present.
|
|
37
|
+
|
|
38
|
+
## Run the wire server
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
bunx @zvada/agent-server --listen 4747 # WebSocket wire
|
|
42
|
+
bunx @zvada/agent-server --stdio # stdio wire (for spawners)
|
|
43
|
+
bunx @zvada/agent-server --acp # act as an ACP v1 agent (Zed-spawnable)
|
|
44
|
+
bunx @zvada/agent-server install # prefetch pinned claude/codex CLIs
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Talk to one
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { AgentServerClient } from "@zvada/agent-server/client";
|
|
51
|
+
|
|
52
|
+
const client = await AgentServerClient.connect("ws://127.0.0.1:4747");
|
|
53
|
+
const turn = await client.runTurn({ input: "hi", config: { harness: "claude-code", cwd: "." } });
|
|
54
|
+
for await (const event of turn.events) console.log(event.type);
|
|
55
|
+
await client.closeSession(turn.sessionId);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Notes
|
|
59
|
+
|
|
60
|
+
- Ships as TypeScript source (Bun-first; the client and stdio/dial server
|
|
61
|
+
transports also run under Node >= 20). Consumers compiling with `tsc` need
|
|
62
|
+
`allowImportingTsExtensions`.
|
|
63
|
+
- The wire vocabulary tracks the
|
|
64
|
+
[Agent Client Protocol](https://agentclientprotocol.com) where concepts
|
|
65
|
+
overlap.
|
|
66
|
+
- Full docs, architecture, and the live test harness live in the
|
|
67
|
+
[repository](https://github.com/zvadaadam/agent-server).
|
|
68
|
+
- Supersedes the four split packages `@zvada/agent-server-{protocol,core,server,client}`
|
|
69
|
+
(now deprecated); the subpaths above are their one-to-one replacements.
|
|
70
|
+
|
|
71
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zvada/agent-server",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Harness-agnostic agent execution engine: run Claude Code, Codex (SDK/CLI + app-server), and any ACP agent behind one interface with a normalized event stream, multi-turn sessions, and resume. Root export is the wire contract; /core, /server, /client are the seats.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"agent",
|
|
9
|
+
"ai",
|
|
10
|
+
"protocol",
|
|
11
|
+
"claude",
|
|
12
|
+
"claude-code",
|
|
13
|
+
"codex",
|
|
14
|
+
"acp",
|
|
15
|
+
"harness",
|
|
16
|
+
"engine",
|
|
17
|
+
"streaming",
|
|
18
|
+
"json-rpc"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/zvadaadam/agent-server.git",
|
|
23
|
+
"directory": "packages/agent-server"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"bun": ">=1.2.0"
|
|
27
|
+
},
|
|
28
|
+
"files": ["src", "README.md", "LICENSE"],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"bin": {
|
|
33
|
+
"agent-server": "./src/server/bin.ts"
|
|
34
|
+
},
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./src/index.ts",
|
|
38
|
+
"default": "./src/index.ts"
|
|
39
|
+
},
|
|
40
|
+
"./protocol": {
|
|
41
|
+
"types": "./src/protocol/index.ts",
|
|
42
|
+
"default": "./src/protocol/index.ts"
|
|
43
|
+
},
|
|
44
|
+
"./core": {
|
|
45
|
+
"types": "./src/core/index.ts",
|
|
46
|
+
"default": "./src/core/index.ts"
|
|
47
|
+
},
|
|
48
|
+
"./core/proxy": {
|
|
49
|
+
"types": "./src/core/proxy/index.ts",
|
|
50
|
+
"default": "./src/core/proxy/index.ts"
|
|
51
|
+
},
|
|
52
|
+
"./server": {
|
|
53
|
+
"types": "./src/server/index.ts",
|
|
54
|
+
"default": "./src/server/index.ts"
|
|
55
|
+
},
|
|
56
|
+
"./client": {
|
|
57
|
+
"types": "./src/client/index.ts",
|
|
58
|
+
"default": "./src/client/index.ts"
|
|
59
|
+
},
|
|
60
|
+
"./package.json": "./package.json"
|
|
61
|
+
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"zod": "^4.0.0"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"@agentclientprotocol/sdk": ">=1.2.0",
|
|
67
|
+
"@anthropic-ai/claude-agent-sdk": ">=0.2.0",
|
|
68
|
+
"@openai/codex-sdk": ">=0.40.0"
|
|
69
|
+
},
|
|
70
|
+
"peerDependenciesMeta": {
|
|
71
|
+
"@agentclientprotocol/sdk": {
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
"@anthropic-ai/claude-agent-sdk": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
77
|
+
"@openai/codex-sdk": {
|
|
78
|
+
"optional": true
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"devDependencies": {
|
|
82
|
+
"@agentclientprotocol/sdk": "^1.2.1",
|
|
83
|
+
"@anthropic-ai/claude-agent-sdk": "^0.3.168",
|
|
84
|
+
"@openai/codex-sdk": "^0.146.1",
|
|
85
|
+
"@types/bun": "^1.2.0"
|
|
86
|
+
}
|
|
87
|
+
}
|