@zvada/agent-server 0.3.23 → 0.3.24
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 +34 -0
- package/README.md +14 -5
- package/dist/accounts/chatgpt.js +144 -0
- package/dist/accounts/check.js +71 -0
- package/dist/accounts/claude.js +80 -0
- package/dist/accounts/endpoint.js +104 -0
- package/dist/accounts/http.js +58 -0
- package/dist/accounts/index.js +9 -0
- package/dist/client/client.js +686 -0
- package/dist/client/connection.js +338 -0
- package/dist/client/history.js +49 -0
- package/dist/client/index.js +6 -0
- package/dist/client/listeners.js +19 -0
- package/dist/client/logins.js +92 -0
- package/dist/client/rpc.js +105 -0
- package/dist/client/streams.js +432 -0
- package/dist/client/transports.js +118 -0
- package/dist/client/turns.js +122 -0
- package/dist/core/agents/acp/acp-agent.js +425 -0
- package/dist/core/agents/acp/adapter.js +231 -0
- package/dist/core/agents/acp/client.js +222 -0
- package/dist/core/agents/acp/known-agents.js +57 -0
- package/dist/core/agents/acp/mappings.js +164 -0
- package/dist/core/agents/acp/requests.js +79 -0
- package/dist/core/agents/attachments.js +14 -0
- package/dist/core/agents/base.js +64 -0
- package/dist/core/agents/claude-code/adapter.js +474 -0
- package/dist/core/agents/claude-code/approvals.js +245 -0
- package/dist/core/agents/claude-code/claude-agent.js +319 -0
- package/dist/core/agents/claude-code/credentials.js +142 -0
- package/dist/core/agents/claude-code/events.js +11 -0
- package/dist/core/agents/claude-code/login.js +217 -0
- package/dist/core/agents/claude-code/mcp.js +181 -0
- package/dist/core/agents/claude-code/models.js +74 -0
- package/dist/core/agents/claude-code/options.js +240 -0
- package/dist/core/agents/claude-code/outcome.js +204 -0
- package/dist/core/agents/claude-code/results.js +58 -0
- package/dist/core/agents/claude-code/sdk-pair.js +59 -0
- package/dist/core/agents/claude-code/session.js +593 -0
- package/dist/core/agents/claude-code/spawn.js +125 -0
- package/dist/core/agents/claude-code/spend.js +118 -0
- package/dist/core/agents/claude-code/tools.js +131 -0
- package/dist/core/agents/claude-code/turn-usage.js +121 -0
- package/dist/core/agents/claude-code/turn.js +199 -0
- package/dist/core/agents/codex-app-server/adapter.js +463 -0
- package/dist/core/agents/codex-app-server/client.js +338 -0
- package/dist/core/agents/codex-app-server/codex-agent.js +294 -0
- package/dist/core/agents/codex-app-server/commands.js +184 -0
- package/dist/core/agents/codex-app-server/credentials.js +92 -0
- package/dist/core/agents/codex-app-server/effort.js +13 -0
- package/dist/core/agents/codex-app-server/events.js +18 -0
- package/dist/core/agents/codex-app-server/homes.js +118 -0
- package/dist/core/agents/codex-app-server/input.js +52 -0
- package/dist/core/agents/codex-app-server/items.js +307 -0
- package/dist/core/agents/codex-app-server/login.js +183 -0
- package/dist/core/agents/codex-app-server/mcp.js +323 -0
- package/dist/core/agents/codex-app-server/models.js +160 -0
- package/dist/core/agents/codex-app-server/options.js +155 -0
- package/dist/core/agents/codex-app-server/plan-approval.js +124 -0
- package/dist/core/agents/codex-app-server/protocol.js +38 -0
- package/dist/core/agents/codex-app-server/requests.js +250 -0
- package/dist/core/agents/codex-app-server/session.js +278 -0
- package/dist/core/agents/codex-app-server/subagents.js +260 -0
- package/dist/core/agents/codex-app-server/thread-settings.js +214 -0
- package/dist/core/agents/codex-app-server/turn-items.js +69 -0
- package/dist/core/agents/codex-app-server/turn.js +448 -0
- package/dist/core/agents/codex-app-server/user-login.js +78 -0
- package/dist/core/agents/config-fingerprint.js +10 -0
- package/dist/core/agents/credentials.js +71 -0
- package/dist/core/agents/diffs.js +27 -0
- package/dist/core/agents/elicitation.js +42 -0
- package/dist/core/agents/inherit-config.js +5 -0
- package/dist/core/agents/login.js +56 -0
- package/dist/core/agents/mcp-config.js +109 -0
- package/dist/core/agents/plan.js +6 -0
- package/dist/core/agents/process-pool.js +307 -0
- package/dist/core/agents/registry.js +49 -0
- package/dist/core/agents/scripted/adapter.js +86 -0
- package/dist/core/agents/scripted/mcp-call.js +74 -0
- package/dist/core/agents/scripted/scripted-agent.js +330 -0
- package/dist/core/agents/scripted/scripts.js +154 -0
- package/dist/core/agents/scripted/steps.js +87 -0
- package/dist/core/agents/session-agent.js +209 -0
- package/dist/core/agents/stderr-tail.js +71 -0
- package/dist/core/agents/thinking-levels.js +9 -0
- package/dist/core/agents/types.js +1 -0
- package/dist/core/diagnostics.js +23 -0
- package/dist/core/index.js +31 -0
- package/dist/core/presets.js +114 -0
- package/dist/core/processes/identity.js +91 -0
- package/dist/core/processes/lifeline.js +210 -0
- package/dist/core/processes/native-processes.js +299 -0
- package/dist/core/processes/process-table.js +163 -0
- package/dist/core/provision/cache-trust.js +121 -0
- package/dist/core/provision/cache-usage.js +61 -0
- package/dist/core/provision/checksums.js +22 -0
- package/dist/core/provision/extract.js +28 -0
- package/dist/core/provision/index.js +4 -0
- package/dist/core/provision/install-build.js +99 -0
- package/dist/core/provision/npm.js +316 -0
- package/dist/core/provision/pins.js +35 -0
- package/dist/core/provision/platform.js +65 -0
- package/dist/core/provision/provisioner.js +372 -0
- package/dist/core/provision/releases.js +68 -0
- package/dist/core/provision/tools.js +279 -0
- package/dist/core/proxy/anthropic-proxy.js +163 -0
- package/dist/core/proxy/api-key-store.js +30 -0
- package/dist/core/proxy/index.js +3 -0
- package/dist/core/proxy/loopback.js +86 -0
- package/dist/core/runtime/agent-runtime.js +434 -0
- package/dist/core/runtime/event-processor.js +379 -0
- package/dist/core/runtime/event-sink.js +65 -0
- package/dist/core/runtime/harness-clis.js +83 -0
- package/dist/core/runtime/harness-logins.js +313 -0
- package/dist/core/runtime/login-reads.js +71 -0
- package/dist/core/runtime/model-lists.js +160 -0
- package/dist/core/runtime/permission-policy.js +84 -0
- package/dist/core/runtime/request-broker.js +139 -0
- package/dist/core/runtime/steering.js +79 -0
- package/dist/core/runtime/turn-outcome.js +16 -0
- package/dist/core/runtime/turn.js +329 -0
- package/dist/core/utils/bounded.js +13 -0
- package/dist/core/utils/deadline.js +57 -0
- package/dist/core/utils/errors.js +176 -0
- package/dist/core/utils/is-record.js +4 -0
- package/dist/core/utils/loopback.js +11 -0
- package/dist/index.js +4 -0
- package/dist/operator/index.js +10 -0
- package/dist/operator/mcp.js +139 -0
- package/dist/operator/operator.js +499 -0
- package/dist/operator/render.js +408 -0
- package/dist/operator/view.js +35 -0
- package/dist/protocol/account.js +96 -0
- package/dist/protocol/async-queue.js +65 -0
- package/dist/protocol/auth.js +169 -0
- package/dist/protocol/canonical.js +18 -0
- package/dist/protocol/clis.js +63 -0
- package/dist/protocol/config.js +137 -0
- package/dist/protocol/conversation.js +231 -0
- package/dist/protocol/credentials.js +141 -0
- package/dist/protocol/errors.js +181 -0
- package/dist/protocol/execution.js +28 -0
- package/dist/protocol/factories.js +231 -0
- package/dist/protocol/guards.js +71 -0
- package/dist/protocol/harness.js +93 -0
- package/dist/protocol/history.js +201 -0
- package/dist/protocol/ids.js +37 -0
- package/dist/protocol/index.js +36 -0
- package/dist/protocol/lifecycle.js +562 -0
- package/dist/protocol/meta-keys.js +17 -0
- package/dist/protocol/meta.js +13 -0
- package/dist/protocol/model-catalog.js +223 -0
- package/dist/protocol/models.js +84 -0
- package/dist/protocol/part-input.js +94 -0
- package/dist/protocol/parts.js +166 -0
- package/dist/protocol/plan.js +31 -0
- package/dist/protocol/reduce.js +484 -0
- package/dist/protocol/selectors.js +136 -0
- package/dist/protocol/seq-cursor.js +37 -0
- package/dist/protocol/stop-reasons.js +41 -0
- package/dist/protocol/thinking.js +31 -0
- package/dist/protocol/time.js +21 -0
- package/dist/protocol/tokens.js +57 -0
- package/dist/protocol/tool-closure.js +70 -0
- package/dist/protocol/tool-state.js +153 -0
- package/dist/protocol/verify.js +467 -0
- package/dist/protocol/vocabulary.js +27 -0
- package/dist/protocol/wire-api.js +94 -0
- package/dist/protocol/wire.js +669 -0
- package/dist/server/acp/binding.js +251 -0
- package/dist/server/acp/session-records.js +53 -0
- package/dist/server/acp/translate.js +401 -0
- package/dist/server/agent-server.js +338 -0
- package/dist/server/bin.js +492 -0
- package/dist/server/feedback.js +216 -0
- package/dist/server/history.js +123 -0
- package/dist/server/index.js +8 -0
- package/dist/server/install.js +171 -0
- package/dist/server/open-parts.js +87 -0
- package/dist/server/routes.js +291 -0
- package/dist/server/secrets.js +19 -0
- package/dist/server/session-gate.js +54 -0
- package/dist/server/session-log.js +66 -0
- package/dist/server/session-store.js +243 -0
- package/dist/server/subscriptions.js +189 -0
- package/dist/server/transports.js +214 -0
- package/dist/server/wire-error.js +26 -0
- package/dist/sync/event-log.js +89 -0
- package/dist/sync/fit.js +202 -0
- package/dist/sync/history-reader.js +33 -0
- package/dist/sync/history-sqlite.js +281 -0
- package/dist/sync/history.js +163 -0
- package/dist/sync/index.js +5 -0
- package/dist/sync/journal-sqlite.js +316 -0
- package/dist/sync/journal.js +10 -0
- package/dist/sync/live-tails.js +85 -0
- package/dist/sync/node-sqlite.js +27 -0
- package/dist/sync/projection.js +32 -0
- package/dist/sync/recovery.js +117 -0
- package/dist/sync/retry.js +45 -0
- package/dist/sync/schema.js +73 -0
- package/dist/sync/sql.js +94 -0
- package/dist/sync/sqlite-file.js +31 -0
- package/dist/sync/sqlite.js +18 -0
- package/dist/sync/worker.js +212 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +4 -1
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/options.d.ts +24 -11
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/session.d.ts +8 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/homes.d.ts +6 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/login.d.ts +12 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/session.d.ts +4 -1
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -1
- package/dist/types/core/agents/process-pool.d.ts +8 -0
- package/dist/types/core/agents/process-pool.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/server/bin.d.ts +3 -0
- package/dist/types/server/bin.d.ts.map +1 -0
- package/dist/types/server/transports.d.ts +2 -1
- package/dist/types/server/transports.d.ts.map +1 -1
- package/dist/types/sync/node-sqlite.d.ts +4 -1
- package/dist/types/sync/node-sqlite.d.ts.map +1 -1
- package/docs/consuming.md +30 -4
- package/docs/deploy.md +28 -0
- package/docs/harnesses.md +13 -1
- package/package.json +43 -18
- package/src/core/agents/claude-code/approvals.ts +5 -1
- package/src/core/agents/claude-code/claude-agent.ts +32 -5
- package/src/core/agents/claude-code/options.ts +24 -11
- package/src/core/agents/claude-code/session.ts +13 -0
- package/src/core/agents/codex-app-server/homes.ts +11 -2
- package/src/core/agents/codex-app-server/login.ts +30 -0
- package/src/core/agents/codex-app-server/requests.ts +7 -6
- package/src/core/agents/codex-app-server/session.ts +11 -2
- package/src/core/agents/process-pool.ts +30 -4
- package/src/core/presets.ts +3 -2
- package/src/server/bin.ts +25 -10
- package/src/server/transports.ts +6 -1
- package/src/sync/node-sqlite.ts +19 -3
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/** What the pinned CLIs listed for the maintainer's login when this release was built. */
|
|
2
|
+
export const GENERATED_MODEL_CATALOG = {
|
|
3
|
+
cli: {
|
|
4
|
+
claude: "0.3.288",
|
|
5
|
+
codex: "0.160.0",
|
|
6
|
+
},
|
|
7
|
+
models: [
|
|
8
|
+
{
|
|
9
|
+
id: "default",
|
|
10
|
+
harness: "claude-code",
|
|
11
|
+
label: "Default (recommended)",
|
|
12
|
+
description: "Opus 5.5 · Best for everyday, complex tasks",
|
|
13
|
+
resolvedId: "claude-opus-5-5",
|
|
14
|
+
isDefault: true,
|
|
15
|
+
thinking: {
|
|
16
|
+
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: "opus",
|
|
21
|
+
harness: "claude-code",
|
|
22
|
+
label: "Opus 5.5",
|
|
23
|
+
description: "For complex work and everyday tasks",
|
|
24
|
+
resolvedId: "claude-opus-5-5",
|
|
25
|
+
thinking: {
|
|
26
|
+
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "sonnet",
|
|
31
|
+
harness: "claude-code",
|
|
32
|
+
label: "Sonnet 5.5",
|
|
33
|
+
description: "Most efficient for simpler tasks",
|
|
34
|
+
resolvedId: "claude-sonnet-5-5",
|
|
35
|
+
thinking: {
|
|
36
|
+
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "fable",
|
|
41
|
+
harness: "claude-code",
|
|
42
|
+
label: "Fable 5.1",
|
|
43
|
+
description: "Most capable for your hardest and longest-running tasks",
|
|
44
|
+
resolvedId: "claude-fable-5-1",
|
|
45
|
+
thinking: {
|
|
46
|
+
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: "haiku",
|
|
51
|
+
harness: "claude-code",
|
|
52
|
+
label: "Haiku 4.5",
|
|
53
|
+
description: "Fastest for quick answers",
|
|
54
|
+
resolvedId: "claude-haiku-4-5-20251001",
|
|
55
|
+
thinking: {
|
|
56
|
+
levels: [],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "claude-sonnet-5",
|
|
61
|
+
harness: "claude-code",
|
|
62
|
+
label: "Sonnet 5",
|
|
63
|
+
description: "Efficient for routine tasks",
|
|
64
|
+
thinking: {
|
|
65
|
+
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "claude-opus-5",
|
|
70
|
+
harness: "claude-code",
|
|
71
|
+
label: "Opus 5",
|
|
72
|
+
description: "Best for everyday, complex tasks",
|
|
73
|
+
thinking: {
|
|
74
|
+
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "claude-fable-5",
|
|
79
|
+
harness: "claude-code",
|
|
80
|
+
label: "Fable 5",
|
|
81
|
+
description: "Most capable for your hardest and longest-running tasks",
|
|
82
|
+
thinking: {
|
|
83
|
+
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: "claude-opus-4-8",
|
|
88
|
+
harness: "claude-code",
|
|
89
|
+
label: "Opus 4.8",
|
|
90
|
+
description: "Best for everyday, complex tasks",
|
|
91
|
+
thinking: {
|
|
92
|
+
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: "claude-opus-4-7",
|
|
97
|
+
harness: "claude-code",
|
|
98
|
+
label: "Opus 4.7",
|
|
99
|
+
description: "Best for everyday, complex tasks",
|
|
100
|
+
thinking: {
|
|
101
|
+
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: "claude-opus-4-6",
|
|
106
|
+
harness: "claude-code",
|
|
107
|
+
label: "Opus 4.6",
|
|
108
|
+
description: "Best for everyday, complex tasks",
|
|
109
|
+
thinking: {
|
|
110
|
+
levels: ["low", "medium", "high", "max"],
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: "claude-sonnet-4-6",
|
|
115
|
+
harness: "claude-code",
|
|
116
|
+
label: "Sonnet 4.6",
|
|
117
|
+
description: "Efficient for routine tasks",
|
|
118
|
+
thinking: {
|
|
119
|
+
levels: ["low", "medium", "high", "max"],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: "gpt-6.1-sol",
|
|
124
|
+
harness: "codex-app-server",
|
|
125
|
+
label: "GPT-6.1-Sol",
|
|
126
|
+
description: "Latest workhorse model for coding and everyday work.",
|
|
127
|
+
isDefault: true,
|
|
128
|
+
thinking: {
|
|
129
|
+
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
130
|
+
default: "low",
|
|
131
|
+
},
|
|
132
|
+
images: true,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: "gpt-6-astra",
|
|
136
|
+
harness: "codex-app-server",
|
|
137
|
+
label: "GPT-6-Astra",
|
|
138
|
+
description: "Frontier intelligence for the most demanding work.",
|
|
139
|
+
thinking: {
|
|
140
|
+
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
141
|
+
default: "medium",
|
|
142
|
+
},
|
|
143
|
+
images: true,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: "gpt-6.1-terra",
|
|
147
|
+
harness: "codex-app-server",
|
|
148
|
+
label: "GPT-6.1 Terra",
|
|
149
|
+
description: "GPT-6.1 Terra Codex model.",
|
|
150
|
+
thinking: {
|
|
151
|
+
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
152
|
+
default: "low",
|
|
153
|
+
},
|
|
154
|
+
images: true,
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: "gpt-6-sol",
|
|
158
|
+
harness: "codex-app-server",
|
|
159
|
+
label: "GPT-6-Sol",
|
|
160
|
+
description: "Previous generation workhorse model.",
|
|
161
|
+
thinking: {
|
|
162
|
+
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
163
|
+
default: "medium",
|
|
164
|
+
},
|
|
165
|
+
images: true,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: "gpt-6-luna",
|
|
169
|
+
harness: "codex-app-server",
|
|
170
|
+
label: "GPT-6-Luna",
|
|
171
|
+
description: "Fast and affordable model for easier tasks.",
|
|
172
|
+
thinking: {
|
|
173
|
+
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
174
|
+
default: "medium",
|
|
175
|
+
},
|
|
176
|
+
images: true,
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
id: "gpt-5.6-sol",
|
|
180
|
+
harness: "codex-app-server",
|
|
181
|
+
label: "GPT-5.6-Sol",
|
|
182
|
+
description: "Older generation workhorse model.",
|
|
183
|
+
thinking: {
|
|
184
|
+
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
185
|
+
default: "low",
|
|
186
|
+
},
|
|
187
|
+
images: true,
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
id: "gpt-5.6-terra",
|
|
191
|
+
harness: "codex-app-server",
|
|
192
|
+
label: "GPT-5.6-Terra",
|
|
193
|
+
description: "Older balanced model for straightforward work.",
|
|
194
|
+
thinking: {
|
|
195
|
+
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
196
|
+
default: "medium",
|
|
197
|
+
},
|
|
198
|
+
images: true,
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: "gpt-5.6-luna",
|
|
202
|
+
harness: "codex-app-server",
|
|
203
|
+
label: "GPT-5.6-Luna",
|
|
204
|
+
description: "Older fast and efficient model.",
|
|
205
|
+
thinking: {
|
|
206
|
+
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
207
|
+
default: "medium",
|
|
208
|
+
},
|
|
209
|
+
images: true,
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
id: "gpt-5.5",
|
|
213
|
+
harness: "codex-app-server",
|
|
214
|
+
label: "GPT-5.5",
|
|
215
|
+
description: "Legacy coding model.",
|
|
216
|
+
thinking: {
|
|
217
|
+
levels: ["low", "medium", "high", "xhigh"],
|
|
218
|
+
default: "medium",
|
|
219
|
+
},
|
|
220
|
+
images: true,
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AgentHarnessSchema } from "./harness.js";
|
|
3
|
+
import { MetaSchema } from "./meta.js";
|
|
4
|
+
import { GENERATED_MODEL_CATALOG } from "./model-catalog.js";
|
|
5
|
+
import { ThinkingLevelSchema, isThinkingLevel } from "./thinking.js";
|
|
6
|
+
import { EpochMsSchema } from "./time.js";
|
|
7
|
+
/**
|
|
8
|
+
* One model a harness can run, in the same shape for every harness. Claude
|
|
9
|
+
* fills it from `supportedModels()`, Codex from `model/list`. Pass `id` as
|
|
10
|
+
* `config.model`.
|
|
11
|
+
*/
|
|
12
|
+
export const ModelDescriptorSchema = z.object({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
harness: AgentHarnessSchema,
|
|
15
|
+
label: z.string(),
|
|
16
|
+
description: z.string().optional(),
|
|
17
|
+
/** The model an alias runs (Claude `opus` -> `claude-opus-5-5`), when it differs from `id`. */
|
|
18
|
+
resolvedId: z.string().optional(),
|
|
19
|
+
/** The model a turn runs when its config names none. */
|
|
20
|
+
isDefault: z.boolean().optional(),
|
|
21
|
+
thinking: z.object({
|
|
22
|
+
/** The levels the model runs as distinct settings, lowest first. Empty: no thinking control. */
|
|
23
|
+
levels: z.array(ThinkingLevelSchema),
|
|
24
|
+
/** The model's own default, when the harness states one. Never invented. */
|
|
25
|
+
default: ThinkingLevelSchema.optional(),
|
|
26
|
+
}),
|
|
27
|
+
/** Accepts image input. Absent: the harness does not say. */
|
|
28
|
+
images: z.boolean().optional(),
|
|
29
|
+
_meta: MetaSchema,
|
|
30
|
+
});
|
|
31
|
+
/** The models a harness offers, as `models/list` and `AgentRuntime.models()` return them. */
|
|
32
|
+
export const ModelListSchema = z.object({
|
|
33
|
+
harness: AgentHarnessSchema,
|
|
34
|
+
models: z.array(ModelDescriptorSchema),
|
|
35
|
+
/**
|
|
36
|
+
* `live`: the harness's CLI listed them for this login and folder.
|
|
37
|
+
* `catalog`: agent-server's built-in list, generated from the pinned CLIs.
|
|
38
|
+
* Served when the harness cannot list models or its CLI did not answer.
|
|
39
|
+
*/
|
|
40
|
+
source: z.enum(["live", "catalog"]),
|
|
41
|
+
/**
|
|
42
|
+
* Why the last read of the CLI failed (a logged-out CLI, a timeout). With
|
|
43
|
+
* `source: "catalog"` there is no live list yet; with `"live"` this is the
|
|
44
|
+
* previous list, from `fetchedAt`.
|
|
45
|
+
*/
|
|
46
|
+
error: z.string().optional(),
|
|
47
|
+
/** When the list was read. */
|
|
48
|
+
fetchedAt: EpochMsSchema,
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Parse a model list from a server that may be newer than this build: a
|
|
52
|
+
* thinking level this build does not know is dropped from `levels` (and from
|
|
53
|
+
* `default`) instead of failing the whole list.
|
|
54
|
+
*/
|
|
55
|
+
export function decodeModelList(value) {
|
|
56
|
+
const raw = value;
|
|
57
|
+
if (!Array.isArray(raw?.models))
|
|
58
|
+
return ModelListSchema.parse(value);
|
|
59
|
+
const models = raw.models.map((model) => {
|
|
60
|
+
const thinking = model?.thinking;
|
|
61
|
+
if (!thinking || typeof thinking !== "object")
|
|
62
|
+
return model;
|
|
63
|
+
const levels = Array.isArray(thinking.levels)
|
|
64
|
+
? thinking.levels.filter((level) => typeof level === "string" && isThinkingLevel(level))
|
|
65
|
+
: thinking.levels;
|
|
66
|
+
const known = typeof thinking.default === "string" && isThinkingLevel(thinking.default);
|
|
67
|
+
const { default: _dropped, ...rest } = thinking;
|
|
68
|
+
return {
|
|
69
|
+
...model,
|
|
70
|
+
thinking: { ...rest, levels, ...(known && { default: thinking.default }) },
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
return ModelListSchema.parse({ ...value, models });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The models each harness's pinned CLI listed when this release was built
|
|
77
|
+
* (`bun run models:refresh`), for a picker without a live list. The live list
|
|
78
|
+
* is the account's own: prefer `AgentRuntime.models()` / `client.listModels()`.
|
|
79
|
+
*/
|
|
80
|
+
export const CATALOG_MODELS = GENERATED_MODEL_CATALOG.models;
|
|
81
|
+
/** The catalog's thinking levels for a model; `undefined` when it isn't listed. */
|
|
82
|
+
export function modelThinkingLevels(harness, model) {
|
|
83
|
+
return CATALOG_MODELS.find((m) => m.harness === harness && m.id === model)?.thinking.levels;
|
|
84
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* A UI-authored span over the text (mentions, pills, inline references) that
|
|
4
|
+
* survives the round trip through the model, the user echo, and persistence.
|
|
5
|
+
* The model sees plain text; `byteRange` is [start, end) over the UTF-8 bytes
|
|
6
|
+
* of the parent `text`.
|
|
7
|
+
*/
|
|
8
|
+
export const TextElementSchema = z.object({
|
|
9
|
+
byteRange: z
|
|
10
|
+
.tuple([z.number().int().nonnegative(), z.number().int().nonnegative()])
|
|
11
|
+
.refine(([start, end]) => start <= end, {
|
|
12
|
+
// A reversed range would survive the echo and persistence, and every
|
|
13
|
+
// consumer slicing with it would render an empty or wrong span with
|
|
14
|
+
// the producer bug invisible — reject it at the boundary.
|
|
15
|
+
message: "byteRange must be ordered: start <= end",
|
|
16
|
+
}),
|
|
17
|
+
/** Human-readable placeholder for the element, displayed in the UI. */
|
|
18
|
+
placeholder: z.string().optional(),
|
|
19
|
+
});
|
|
20
|
+
/** Inbound user content for a turn: plain text, or multimodal blocks. */
|
|
21
|
+
export const TextPartInputSchema = z.object({
|
|
22
|
+
type: z.literal("text"),
|
|
23
|
+
id: z.string().optional(),
|
|
24
|
+
text: z.string().min(1),
|
|
25
|
+
elements: z.array(TextElementSchema).optional(),
|
|
26
|
+
});
|
|
27
|
+
export const ImagePartInputSchema = z
|
|
28
|
+
.object({
|
|
29
|
+
type: z.literal("image"),
|
|
30
|
+
id: z.string().optional(),
|
|
31
|
+
/** Either a URL or base64 `data` (one is required). */
|
|
32
|
+
url: z.string().min(1).optional(),
|
|
33
|
+
data: z.string().min(1).optional(),
|
|
34
|
+
mimeType: z.string(),
|
|
35
|
+
// No `filename` here: ImagePartSchema has no such field, so accepting it
|
|
36
|
+
// would validate a value the echo then silently drops.
|
|
37
|
+
// @ref LLP 0002#input-the-echo-can-carry — accept only what the echo carries
|
|
38
|
+
})
|
|
39
|
+
.refine((part) => (part.data !== undefined) !== (part.url !== undefined), {
|
|
40
|
+
// Exactly one, matching the OUTPUT part schemas' `exactlyOneSource`: an
|
|
41
|
+
// input carrying both would echo as a part every consumer's decode
|
|
42
|
+
// rejects — the ambiguity dies at the boundary, not on the stream.
|
|
43
|
+
message: "image input requires exactly one of data | url",
|
|
44
|
+
});
|
|
45
|
+
export const FilePartInputSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
type: z.literal("file"),
|
|
48
|
+
id: z.string().optional(),
|
|
49
|
+
url: z.string().min(1).optional(),
|
|
50
|
+
data: z.string().min(1).optional(),
|
|
51
|
+
mimeType: z.string(),
|
|
52
|
+
filename: z.string().optional(),
|
|
53
|
+
})
|
|
54
|
+
.refine((part) => (part.data !== undefined) !== (part.url !== undefined), {
|
|
55
|
+
message: "file input requires exactly one of data | url",
|
|
56
|
+
});
|
|
57
|
+
export const PartInputSchema = z.discriminatedUnion("type", [
|
|
58
|
+
TextPartInputSchema,
|
|
59
|
+
ImagePartInputSchema,
|
|
60
|
+
FilePartInputSchema,
|
|
61
|
+
]);
|
|
62
|
+
/** A turn's input is either a bare string or a list of typed parts. */
|
|
63
|
+
export const AgentInputSchema = z.union([z.string(), z.array(PartInputSchema)]);
|
|
64
|
+
/**
|
|
65
|
+
* Decode an untrusted value (an HTTP body, a queue message, a DB column) into
|
|
66
|
+
* an `AgentInput`, or throw with a message that names the offending path.
|
|
67
|
+
*
|
|
68
|
+
* The schema is the contract; a hand-rolled decoder in front of it is where
|
|
69
|
+
* tolerance for shapes the engine never accepted creeps in (`content` arrays,
|
|
70
|
+
* bare `{text}` objects) and where the error a product shows its user
|
|
71
|
+
* degrades to "invalid input". (An empty STRING is valid input — deliberately:
|
|
72
|
+
* "continue" semantics belong to the product, not the schema.)
|
|
73
|
+
*/
|
|
74
|
+
export function parseAgentInput(value) {
|
|
75
|
+
const parsed = AgentInputSchema.safeParse(value);
|
|
76
|
+
if (parsed.success)
|
|
77
|
+
return parsed.data;
|
|
78
|
+
// A union failure's own message is just "Invalid input" — the useful paths
|
|
79
|
+
// and messages live one level down, in the per-branch issue lists.
|
|
80
|
+
const flattened = parsed.error.issues.flatMap((issue) => issue.code === "invalid_union" ? issue.errors.flat() : [issue]);
|
|
81
|
+
const detail = flattened
|
|
82
|
+
.map((issue) => `${issue.path.length ? `${issue.path.join(".")}: ` : ""}${issue.message}`)
|
|
83
|
+
.join("; ");
|
|
84
|
+
throw new Error(`invalid agent input: ${detail}`, { cause: parsed.error });
|
|
85
|
+
}
|
|
86
|
+
/** Collapse an AgentInput down to the text the model sees first. */
|
|
87
|
+
export function inputToText(input) {
|
|
88
|
+
if (typeof input === "string")
|
|
89
|
+
return input;
|
|
90
|
+
return input
|
|
91
|
+
.filter((p) => p.type === "text")
|
|
92
|
+
.map((p) => p.text)
|
|
93
|
+
.join("\n\n");
|
|
94
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { isKnownPartType } from "./guards.js";
|
|
3
|
+
import { MetaSchema } from "./meta.js";
|
|
4
|
+
import { OpenTimeSpanSchema } from "./time.js";
|
|
5
|
+
import { McpToolSchema, ToolKindSchema, ToolLocationSchema, ToolStateSchema, } from "./tool-state.js";
|
|
6
|
+
/**
|
|
7
|
+
* A Part is the atomic unit of message content, normalized across harnesses.
|
|
8
|
+
* Every part belongs to a message within a session. Parts stream: a TextPart
|
|
9
|
+
* arrives `streaming` and is finalized `done`; a ToolPart's `state` advances
|
|
10
|
+
* through the tool lifecycle. `parentToolCallId` links a part produced inside
|
|
11
|
+
* a sub-agent / nested tool execution back to the tool call that spawned it.
|
|
12
|
+
*
|
|
13
|
+
* Parts carry NO ordering fields — position is the event's knowledge
|
|
14
|
+
* (`partIndex`/`outputIndex` on message.* events); a part re-stated late (a
|
|
15
|
+
* tool completing after its message ended) must not be able to contradict its
|
|
16
|
+
* own position.
|
|
17
|
+
*
|
|
18
|
+
* Rule: this union contains only part types adapters actually emit — the
|
|
19
|
+
* protocol advertises nothing it doesn't deliver. There is deliberately no
|
|
20
|
+
* compaction part (compaction is the `session.compaction` entity) and no
|
|
21
|
+
* step/turn-mechanics part (mechanics live in events).
|
|
22
|
+
*/
|
|
23
|
+
const PartBase = z.object({
|
|
24
|
+
/** UUIDv7 — THE upsert key. */
|
|
25
|
+
id: z.string(),
|
|
26
|
+
sessionId: z.string(),
|
|
27
|
+
messageId: z.string(),
|
|
28
|
+
/** Set when this part was produced inside the subagent spawned by that tool call. */
|
|
29
|
+
parentToolCallId: z.string().optional(),
|
|
30
|
+
_meta: MetaSchema,
|
|
31
|
+
});
|
|
32
|
+
export const TextPartSchema = PartBase.extend({
|
|
33
|
+
type: z.literal("text"),
|
|
34
|
+
text: z.string(),
|
|
35
|
+
state: z.enum(["streaming", "done"]).optional(),
|
|
36
|
+
});
|
|
37
|
+
export const ReasoningPartSchema = PartBase.extend({
|
|
38
|
+
type: z.literal("reasoning"),
|
|
39
|
+
text: z.string(),
|
|
40
|
+
state: z.enum(["streaming", "done"]).optional(),
|
|
41
|
+
/** Thought duration, when the adapter can stamp it (deus renders it). */
|
|
42
|
+
time: OpenTimeSpanSchema.optional(),
|
|
43
|
+
/** Harness extras — e.g. `{ redacted: true }` for Claude redacted_thinking. */
|
|
44
|
+
providerMetadata: z.record(z.string(), z.unknown()).optional(),
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Metadata about the subagent a `task`-kind tool spawned, populated from the
|
|
48
|
+
* spawning tool's input (Claude `Task`: description/subagent_type/model).
|
|
49
|
+
* `agentId` is the harness-native id — the only reliable way to attribute
|
|
50
|
+
* PARALLEL subagents. Presence of `subagent` implies `kind: "task"`; tool-name
|
|
51
|
+
* allowlists are forbidden.
|
|
52
|
+
*/
|
|
53
|
+
export const SubagentMetadataSchema = z.object({
|
|
54
|
+
type: z.string().optional(),
|
|
55
|
+
description: z.string().optional(),
|
|
56
|
+
model: z.string().optional(),
|
|
57
|
+
agentId: z.string().optional(),
|
|
58
|
+
});
|
|
59
|
+
export const ToolPartSchema = PartBase.extend({
|
|
60
|
+
type: z.literal("tool"),
|
|
61
|
+
toolCallId: z.string(),
|
|
62
|
+
/** Provider-native tool name (`Bash`, `shell`, `mcp.search`, …) — the renderer dispatch key. */
|
|
63
|
+
toolName: z.string(),
|
|
64
|
+
/** Normalized classification of what the call does (ACP ToolKind + `task`). */
|
|
65
|
+
kind: ToolKindSchema.optional(),
|
|
66
|
+
/** A call to an MCP tool: its server and tool, when the harness knows both. `toolName` stays the harness's own. */
|
|
67
|
+
mcp: McpToolSchema.optional(),
|
|
68
|
+
/** Human-readable label when the harness provides one. */
|
|
69
|
+
title: z.string().optional(),
|
|
70
|
+
/** A command's line as the agent wrote it, apart from any wrapper the harness adds. `state.input` stays the harness's own. */
|
|
71
|
+
command: z.string().optional(),
|
|
72
|
+
/** A fetch's address. */
|
|
73
|
+
url: z.string().optional(),
|
|
74
|
+
/** Files this call touches, for follow-along UIs. */
|
|
75
|
+
locations: z.array(ToolLocationSchema).optional(),
|
|
76
|
+
/** Present when this tool spawned a subagent (implies kind "task"). */
|
|
77
|
+
subagent: SubagentMetadataSchema.optional(),
|
|
78
|
+
state: ToolStateSchema,
|
|
79
|
+
});
|
|
80
|
+
/** Native worker activity, including harnesses without a public spawning tool call. */
|
|
81
|
+
export const SubagentPartSchema = PartBase.extend({
|
|
82
|
+
type: z.literal("subagent"),
|
|
83
|
+
nativeActivityId: z.string(),
|
|
84
|
+
nativeThreadId: z.string(),
|
|
85
|
+
path: z.string().optional(),
|
|
86
|
+
activity: z.enum(["started", "interacted", "interrupted", "completed"]),
|
|
87
|
+
});
|
|
88
|
+
/**
|
|
89
|
+
* Exactly one of `data` (base64) | `url` — ENFORCED, not merely documented: a
|
|
90
|
+
* payload-less blob part renders as a broken image, and one carrying both
|
|
91
|
+
* leaves every consumer to invent its own precedence rule.
|
|
92
|
+
*/
|
|
93
|
+
const exactlyOneSource = (part) => (part.data !== undefined) !== (part.url !== undefined);
|
|
94
|
+
/** Exactly one of `data` (base64) | `url`. Emitted by the user echo and image tool results. */
|
|
95
|
+
export const ImagePartSchema = PartBase.extend({
|
|
96
|
+
type: z.literal("image"),
|
|
97
|
+
data: z.string().min(1).optional(),
|
|
98
|
+
url: z.string().min(1).optional(),
|
|
99
|
+
mimeType: z.string(),
|
|
100
|
+
}).refine(exactlyOneSource, { message: "image part requires exactly one of data | url" });
|
|
101
|
+
/** Exactly one of `data` (base64) | `url`. Emitted by the user echo. */
|
|
102
|
+
export const FilePartSchema = PartBase.extend({
|
|
103
|
+
type: z.literal("file"),
|
|
104
|
+
data: z.string().min(1).optional(),
|
|
105
|
+
url: z.string().min(1).optional(),
|
|
106
|
+
mimeType: z.string(),
|
|
107
|
+
filename: z.string().optional(),
|
|
108
|
+
}).refine(exactlyOneSource, { message: "file part requires exactly one of data | url" });
|
|
109
|
+
export const PartSchema = z.discriminatedUnion("type", [
|
|
110
|
+
TextPartSchema,
|
|
111
|
+
ReasoningPartSchema,
|
|
112
|
+
ToolPartSchema,
|
|
113
|
+
SubagentPartSchema,
|
|
114
|
+
ImagePartSchema,
|
|
115
|
+
FilePartSchema,
|
|
116
|
+
]);
|
|
117
|
+
/** A preserved unknown part as persisted state holds it: its address, and everything else kept. */
|
|
118
|
+
export const UnknownPartSchema = z.looseObject({
|
|
119
|
+
type: z.string(),
|
|
120
|
+
id: z.string(),
|
|
121
|
+
sessionId: z.string(),
|
|
122
|
+
messageId: z.string(),
|
|
123
|
+
parentToolCallId: z.string().optional(),
|
|
124
|
+
raw: z.record(z.string(), z.unknown()),
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* Decode a wire value into a Part, preserving unknown part types instead of
|
|
128
|
+
* failing the whole event that carries them (preservation is a STORAGE and FORWARDING
|
|
129
|
+
* requirement — a newer server's part type must survive a round trip through
|
|
130
|
+
* an older consumer). Throws on a known type with a malformed body, and on an
|
|
131
|
+
* unknown part that lacks the addressing fields every part owns: without
|
|
132
|
+
* `id`/`sessionId`/`messageId` there is nothing to upsert by, so it cannot be
|
|
133
|
+
* preserved in any useful sense.
|
|
134
|
+
*/
|
|
135
|
+
export function decodePart(value) {
|
|
136
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
137
|
+
throw new Error("part must be an object");
|
|
138
|
+
}
|
|
139
|
+
const record = value;
|
|
140
|
+
if (isKnownPartType(record.type))
|
|
141
|
+
return PartSchema.parse(value);
|
|
142
|
+
const { type, id, sessionId, messageId, parentToolCallId } = record;
|
|
143
|
+
if (typeof type !== "string" || type.length === 0) {
|
|
144
|
+
throw new Error("part is missing its type");
|
|
145
|
+
}
|
|
146
|
+
if (typeof id !== "string" || typeof sessionId !== "string" || typeof messageId !== "string") {
|
|
147
|
+
throw new Error(`unknown part type "${type}" is missing its id/sessionId/messageId address`);
|
|
148
|
+
}
|
|
149
|
+
const meta = record._meta;
|
|
150
|
+
return {
|
|
151
|
+
type,
|
|
152
|
+
id,
|
|
153
|
+
sessionId,
|
|
154
|
+
messageId,
|
|
155
|
+
...(typeof parentToolCallId === "string" ? { parentToolCallId } : {}),
|
|
156
|
+
// Extensions live in `_meta` on every shape — surface it on the
|
|
157
|
+
// preserved part too, so a consumer reading `part._meta` does not need
|
|
158
|
+
// to know to dig through `raw` for it.
|
|
159
|
+
...(meta !== null && typeof meta === "object" && !Array.isArray(meta)
|
|
160
|
+
? { _meta: meta }
|
|
161
|
+
: {}),
|
|
162
|
+
raw: record,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
// `PART_TYPES`, `isKnownPartType` and `isUnknownPart` live in `./guards.ts` —
|
|
166
|
+
// same exports from the barrel, but reachable without loading zod.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** The ids of a plan's options: each is the permission mode the session goes on in. */
|
|
2
|
+
export const PLAN_OPTION_IDS = {
|
|
3
|
+
acceptEdits: "accept_edits",
|
|
4
|
+
approve: "default",
|
|
5
|
+
keepPlanning: "plan",
|
|
6
|
+
};
|
|
7
|
+
// @ref LLP 0001#d4--permission-requests-are-first-class-protocol — a plan's approval picks the mode
|
|
8
|
+
/**
|
|
9
|
+
* How a user answers an agent's plan: go on in a mode, or keep planning. Each
|
|
10
|
+
* option's id is the permission mode the session goes on in. These are Claude
|
|
11
|
+
* Code's own choices; Codex's TUI asks the same ("implement this plan" / "stay
|
|
12
|
+
* in Plan mode"). Auto-accepting edits is a standing choice for the edits to
|
|
13
|
+
* come (`allow_always`, as claude-agent-acp marks it), so an approver that
|
|
14
|
+
* takes the one-time approval implements asking for each edit. No standing
|
|
15
|
+
* rule answers a later plan: the broker keeps none for a harness's options.
|
|
16
|
+
*/
|
|
17
|
+
export const PLAN_OPTIONS = [
|
|
18
|
+
{
|
|
19
|
+
optionId: PLAN_OPTION_IDS.acceptEdits,
|
|
20
|
+
name: "Yes, and auto-accept edits",
|
|
21
|
+
kind: "allow_always",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
optionId: PLAN_OPTION_IDS.approve,
|
|
25
|
+
name: "Yes, and manually approve edits",
|
|
26
|
+
kind: "allow_once",
|
|
27
|
+
},
|
|
28
|
+
{ optionId: PLAN_OPTION_IDS.keepPlanning, name: "No, keep planning", kind: "reject_once" },
|
|
29
|
+
];
|
|
30
|
+
/** What a plan's approval asks. */
|
|
31
|
+
export const PLAN_TITLE = "Implement this plan?";
|