@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
|
@@ -69,7 +69,10 @@ export declare class CodexSessions {
|
|
|
69
69
|
* new one, on the same thread. Codex caches an authenticated model WebSocket across turns, so
|
|
70
70
|
* login alone cannot switch its identity: an account or key change
|
|
71
71
|
* restarts the process and resumes the thread. Same-account token renewal
|
|
72
|
-
* keeps it warm.
|
|
72
|
+
* of a login the engine hands it keeps it warm. One on its store's own
|
|
73
|
+
* login is replaced once the store's `auth.json` changed, whatever the
|
|
74
|
+
* change: the engine reads no login to tell a renewal from another
|
|
75
|
+
* account. An unchanged `mcp_servers` table keeps it warm, the servers
|
|
73
76
|
* the thread carries. A thread's config is fixed once it is open, so
|
|
74
77
|
* another table resumes the thread in a new process, which checks them
|
|
75
78
|
* against Codex's configuration again before the thread opens: the user
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../../src/core/agents/codex-app-server/session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,KAAK,SAAS,EAA0B,MAAM,kBAAkB,CAAC;AAG1E,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAA0C,MAAM,UAAU,CAAC;AACpG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EACN,KAAK,oBAAoB,EAEzB,KAAK,iBAAiB,EAItB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,cAAc,EAAsB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,0EAA0E;AAC1E,MAAM,WAAW,YAAa,SAAQ,oBAAoB;IACzD,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,kFAAkF;IAClF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,GAAG,EAAE,aAAa,CAAC;IACnB;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,EAAE,CAAC;IAClB,yEAAyE;IACzE,MAAM,EAAE,WAAW,CAAC;IACpB,2EAA2E;IAC3E,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB;;;;OAIG;IACH,mBAAmB,IAAI,OAAO,CAAC;IAC/B,wGAAwG;IACxG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,aAAa,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,SAAS,CAAC,CAA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GAAG,YAAY;IAIlD;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CACN,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,cAAc,EACpB,GAAG,EAAE,YAAY,GACf,OAAO,CAAC,YAAY,CAAC;IAIxB,mGAAmG;IACnG,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,GAAG,IAAI;IAM3E,6FAA6F;IAC7F,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI;IAI5D,8EAA8E;IAC9E,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAInC;;;OAGG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,SAAS;IAU9D;;;;;OAKG;IACH,UAAU,IAAI,IAAI;IAIlB;;;;;OAKG;IACH,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAIlC;;;;;;OAMG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzC,6DAA6D;IAC7D,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAO7B;;;;;;;;OAQG;YACW,eAAe;IA+B7B;;;;OAIG;YACW,KAAK;CA6DnB"}
|
|
@@ -51,6 +51,14 @@ export interface ProcessHarness<P extends PooledProcess, T> {
|
|
|
51
51
|
* `env` value, say). Absent: one store, which every login change names.
|
|
52
52
|
*/
|
|
53
53
|
store?(turn: T): string;
|
|
54
|
+
/**
|
|
55
|
+
* A mark of the store's login as it looks now (never the login), for a
|
|
56
|
+
* process that keeps the login it started with. Taken as a start begins and
|
|
57
|
+
* compared when a turn takes a process that fits it: a difference is
|
|
58
|
+
* `loginChanged`. Undefined: nothing to follow this turn. Absent: only a
|
|
59
|
+
* login change the engine is told of replaces a process (LLP 0016.000).
|
|
60
|
+
*/
|
|
61
|
+
loginMark?(turn: T): string | undefined;
|
|
54
62
|
/** The conversation the turn resumes, when it names one. */
|
|
55
63
|
resumeOf(turn: T): string | undefined;
|
|
56
64
|
/** The conversations a warm process is on: a turn that resumes another needs another process. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-pool.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/process-pool.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAa,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACvC,iFAAiF;IACjF,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACtD;;;OAGG;IACH,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC7B,MAAM,EAAE,YAAY,CAAC;CACrB;AAED,iFAAiF;AACjF,MAAM,MAAM,aAAa,GACtB,QAAQ,GACR,aAAa,GACb,cAAc,GACd,mBAAmB,GACnB,YAAY,GACZ,cAAc,CAAC;AAElB;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GACzB,MAAM,GACN,UAAU,GACV,UAAU,GACV,QAAQ,GACR,YAAY,aAAa,EAAE,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,aAAa,EAAE,CAAC;IACzD;;;OAGG;IACH,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;IACxB,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,MAAM,GAAG,SAAS,CAAC;IACtC,iGAAiG;IACjG,eAAe,CAAC,OAAO,E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;IACH,UAAU,IAAI,IAAI;IAIlB;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO;IAMxC;;;;;;OAMG;IACG,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/C;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAO/B,OAAO,CAAC,UAAU;IAIlB,yDAAyD;IACzD,OAAO,CAAC,KAAK;IAKb,iGAAiG;YACnF,MAAM;YAWN,KAAK;IA4CnB,2FAA2F;IAC3F,OAAO,CAAC,GAAG;IAuBX,wFAAwF;IACxF,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,MAAM;IAOd,0DAA0D;IAC1D,OAAO,CAAC,MAAM;IAQd,uFAAuF;IACvF,OAAO,CAAC,GAAG;IAOX,OAAO,CAAC,SAAS;CAMjB"}
|
|
@@ -62,8 +62,8 @@ export interface CreateRegistryOptions {
|
|
|
62
62
|
cancelConfirmMs?: number;
|
|
63
63
|
/**
|
|
64
64
|
* How long after a cancel the engine ends an agent that has not stopped:
|
|
65
|
-
* 2 s on Codex
|
|
66
|
-
*
|
|
65
|
+
* 2 s on Codex, 10 s on Claude and on an ACP agent by default; its turn
|
|
66
|
+
* then ends `cancelled`.
|
|
67
67
|
*/
|
|
68
68
|
cancelGraceMs?: number;
|
|
69
69
|
/** Codex embed-tier authentication and process options; CLI resolution stays provisioner-owned. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../../src/core/presets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAY,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAK3E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE9E,OAAO,EAEN,KAAK,0BAA0B,EAC/B,MAAM,0CAA0C,C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,EAAE,gBAAgB,CAAC;IAC7B;;;OAGG;IACH,GAAG,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;IACnD;;;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC;IACpD;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mGAAmG;IACnG,cAAc,CAAC,EAAE,IAAI,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAC;IAC5D;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,oBAAoB,CAAC;CACvC;AA8FD,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,IAAI,GAAE,qBAA0B,GAAG,aAAa,CAsBnF;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,IAAI,GAAE,qBAA0B,GAAG,YAAY,CAEjF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../../src/server/bin.ts"],"names":[],"mappings":""}
|
|
@@ -45,7 +45,8 @@ export declare function assertListenOptions(opts: ListenOptions): void;
|
|
|
45
45
|
* Accept WebSocket clients (agnt's model: the consumer connects to us). Each
|
|
46
46
|
* accepted socket becomes an attached transport, which receives the sessions
|
|
47
47
|
* it subscribes to. It answers native clients, and browsers only from
|
|
48
|
-
* `allowedOrigins`; beyond loopback it requires a `token`.
|
|
48
|
+
* `allowedOrigins`; beyond loopback it requires a `token`. Bun only: under
|
|
49
|
+
* any other runtime it throws an error that says what works there.
|
|
49
50
|
*/
|
|
50
51
|
export declare function listen(server: AgentServer, opts?: ListenOptions): {
|
|
51
52
|
url: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transports.d.ts","sourceRoot":"","sources":["../../../src/server/transports.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAqC,MAAM,sBAAsB,CAAC;AAC7F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,KAAK,GAAE,MAAM,CAAC,cAA8B;AAC5C,iGAAiG;AACjG,MAAM,GAAE,MAAM,CAAC,cAAc,GAAG;IAAE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAmB,GACnF,aAAa,CAcf;AA2BD,MAAM,WAAW,aAAa;IAC7B,oCAAoC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAKD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,CAe7D;AAkCD
|
|
1
|
+
{"version":3,"file":"transports.d.ts","sourceRoot":"","sources":["../../../src/server/transports.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAqC,MAAM,sBAAsB,CAAC;AAC7F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,KAAK,GAAE,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-sqlite.ts";
|
|
2
2
|
/** Node >=22.16 adapter (node:sqlite). Same schema and guarantees as Bun.
|
|
3
|
-
*
|
|
3
|
+
* `node:sqlite` loads when a journal opens, not when this module does: a
|
|
4
|
+
* bundle holding both adapters (the bin, compiled by Bun into one binary)
|
|
5
|
+
* hoists a static import of it, which Bun, without the module, refuses at
|
|
6
|
+
* start; and Node 22 warns that it is experimental on its first load. */
|
|
4
7
|
export declare class NodeSqliteSessionJournal extends SqliteJournal {
|
|
5
8
|
constructor(path: string);
|
|
6
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-sqlite.d.ts","sourceRoot":"","sources":["../../../src/sync/node-sqlite.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD;
|
|
1
|
+
{"version":3,"file":"node-sqlite.d.ts","sourceRoot":"","sources":["../../../src/sync/node-sqlite.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;;yEAIyE;AACzE,qBAAa,wBAAyB,SAAQ,aAAa;gBAC9C,IAAI,EAAE,MAAM;CAYxB"}
|
package/docs/consuming.md
CHANGED
|
@@ -555,8 +555,12 @@ for every harness. `cancelConfirmMs` (2 s by default) is how long a cancel
|
|
|
555
555
|
waits for the agent to confirm it stopped before it answers `unconfirmed`;
|
|
556
556
|
a turn still starting is confirmed once it has ended within it.
|
|
557
557
|
`cancelGraceMs` is how long after a cancel the engine ends an agent that has
|
|
558
|
-
not stopped, and its turn then ends `cancelled`: 2 s on Codex, 10 s on
|
|
559
|
-
ACP agent
|
|
558
|
+
not stopped, and its turn then ends `cancelled`: 2 s on Codex, 10 s on
|
|
559
|
+
Claude and on an ACP agent. A Claude CLI that never answers its interrupt (a
|
|
560
|
+
hung or frozen process) is ended then, `onSessionEnd` says `replaced`, and
|
|
561
|
+
the session's next turn resumes the conversation on a new process. A Claude
|
|
562
|
+
cancel is `cancelled` when its turn ended within `cancelConfirmMs`, by the
|
|
563
|
+
interrupt or by that grace.
|
|
560
564
|
|
|
561
565
|
Embedded `runtime.cancel(harness, sessionId)` cancels the session's active
|
|
562
566
|
turn without a turn ID check. Prefer a per-turn `AbortSignal` when cancellation
|
|
@@ -717,7 +721,11 @@ match what you want asked. To tell which of your tools a call is, read
|
|
|
717
721
|
`mcp.server` and `mcp.tool` on the tool part or the permission request's
|
|
718
722
|
`toolCall`, the same on both harnesses: `toolName` is each harness's own
|
|
719
723
|
spelling (`mcp__<server>__<tool>` on Claude, `<server>.<tool>` on Codex).
|
|
720
|
-
|
|
724
|
+
A Claude `toolPolicy`, which sees no part, gets Claude's own name and the
|
|
725
|
+
same `mcp` in its context. A Codex consent that cannot be linked to one
|
|
726
|
+
started call (none is open, or two of the tool are and neither has its
|
|
727
|
+
arguments) gets a `toolCallId` of its own and still names the server and the
|
|
728
|
+
tool its message names; one whose message names no tool carries no `mcp`.
|
|
721
729
|
|
|
722
730
|
## Own your session resources
|
|
723
731
|
|
|
@@ -891,6 +899,8 @@ Treat `unknownSession` on replay as "session over", not as an error to retry.
|
|
|
891
899
|
|
|
892
900
|
## Let an outside agent operate your sessions
|
|
893
901
|
|
|
902
|
+
In this section the operator is that outside agent; elsewhere in this guide
|
|
903
|
+
it is whoever runs the engine (an operator option).
|
|
894
904
|
`@zvada/agent-server/operator` gives a hosted assistant (ChatGPT, Claude, a
|
|
895
905
|
CLI agent) the tools to operate your product's coding agents:
|
|
896
906
|
`list_sessions`, `read_session`, `start_session`, `send_message`,
|
|
@@ -1034,6 +1044,18 @@ exact peer) shows up here; the turn still runs.
|
|
|
1034
1044
|
These are the signals the engine deliberately does not fail turns over — a
|
|
1035
1045
|
product that doesn't surface them debugs blind.
|
|
1036
1046
|
|
|
1047
|
+
## Run it on Bun or Node
|
|
1048
|
+
|
|
1049
|
+
Import the package as it is, under either runtime: Bun loads its TypeScript
|
|
1050
|
+
sources, Node and your bundler its compiled JavaScript (`dist/`), and your
|
|
1051
|
+
`tsc` its declarations, so you need no loader, `allowImportingTsExtensions`
|
|
1052
|
+
or transpiling of its sources. Two things are Bun's alone: `listen` (under
|
|
1053
|
+
Node, serve over stdio, `dial`, or your own WebSocket server's sockets
|
|
1054
|
+
through `channelTransport` and `server.attach`) and `./sync/sqlite` (under
|
|
1055
|
+
Node, `./sync/node-sqlite`). The bin under Node is
|
|
1056
|
+
`node node_modules/@zvada/agent-server/dist/server/bin.js`
|
|
1057
|
+
([deploy](deploy.md#on-node)).
|
|
1058
|
+
|
|
1037
1059
|
## Wire transports
|
|
1038
1060
|
|
|
1039
1061
|
`spawn` (stdio subprocess), `connect` (dial a `--listen` server; reconnects
|
|
@@ -1055,7 +1077,11 @@ followed to its end); `subscribeAll()` is for observers: every session, live
|
|
|
1055
1077
|
from then, with no history (`session/subscribeAll` on the wire; `unsubscribeAll()`
|
|
1056
1078
|
is `session/unsubscribeAll`). The client follows every session from the
|
|
1057
1079
|
call until `unsubscribeAll()`: a connection that drops before the answer asks
|
|
1058
|
-
the server it redials, and `subscribeAll()` resolves on that answer.
|
|
1080
|
+
the server it redials, and `subscribeAll()` resolves on that answer. On a
|
|
1081
|
+
client that redials it resolves only once a server has answered, and fails
|
|
1082
|
+
only when one refuses it, the redials run out (`maxReconnectAttempts`) or the
|
|
1083
|
+
client closes: do not await it on a start path while no engine may be up,
|
|
1084
|
+
since the client follows every session from the call either way. `joinTurn(sessionId, {fromSeq})` watches the
|
|
1059
1085
|
session and joins the turn it runs (`undefined` when none): a handle that
|
|
1060
1086
|
yields the kept events from `fromSeq` (default: the turn's start), then the
|
|
1061
1087
|
turn's open parts, then live frames through its `turn.ended`, each once,
|
package/docs/deploy.md
CHANGED
|
@@ -132,6 +132,34 @@ in a turn's error as in `clis/*`, carry URLs without their credentials or
|
|
|
132
132
|
query. The CLI says a download's start,
|
|
133
133
|
its quarters and its end, and `/info` shows the session harness's CLI.
|
|
134
134
|
|
|
135
|
+
## On Node
|
|
136
|
+
|
|
137
|
+
The package runs on Node as well as Bun. Under Bun each export loads its
|
|
138
|
+
TypeScript source (the `bun` export condition); under Node, and in a
|
|
139
|
+
bundler that does not target Bun, its compiled JavaScript in `dist/`
|
|
140
|
+
(`default`). Tested from the packed tarball on Node 22.16, 22.23 and 24.21
|
|
141
|
+
and Bun 1.3.6 (`test/package/runtime.test.ts`). What differs on Node:
|
|
142
|
+
|
|
143
|
+
- **The bin.** `bin` stays the Bun one (`src/server/bin.ts`). Under Node:
|
|
144
|
+
`node node_modules/@zvada/agent-server/dist/server/bin.js`, with the same
|
|
145
|
+
flags.
|
|
146
|
+
- **`--listen` and `listen` need Bun** (`Bun.serve`): under Node the bin
|
|
147
|
+
refuses `--listen` before it starts, and `listen` throws an error that
|
|
148
|
+
says what works there. Serve over `--stdio` (`stdioTransport`), `--dial`
|
|
149
|
+
(`dial`), or attach each socket of a WebSocket server of your own
|
|
150
|
+
(`channelTransport`, then `server.attach`).
|
|
151
|
+
- **The journal.** `--journal` opens `node:sqlite` under Node (Node >= 22.16;
|
|
152
|
+
Node 22 warns once that it is experimental) and `bun:sqlite` under Bun. In
|
|
153
|
+
code, `./sync/node-sqlite` is Node's and `./sync/sqlite` Bun's, which does
|
|
154
|
+
not load under Node. The Node adapter loads `node:sqlite` when a journal
|
|
155
|
+
opens, not on import, so a bundle holding both adapters starts on either
|
|
156
|
+
runtime.
|
|
157
|
+
- **A bundler** picks the compiled files (esbuild, tsup, Vite, and Bun's own
|
|
158
|
+
with `--target=node`); Bun's with `--target=bun`, as `bun build --compile`
|
|
159
|
+
below, picks the sources. The engine's source paths are unchanged
|
|
160
|
+
(`src/` stays in the package), so a build that copies or maps them keeps
|
|
161
|
+
working.
|
|
162
|
+
|
|
135
163
|
## Single binary & sandbox cold starts
|
|
136
164
|
|
|
137
165
|
The server compiles to a self-contained executable — no bun, node, or
|
package/docs/harnesses.md
CHANGED
|
@@ -70,6 +70,7 @@ warm multi-turn reuse, a unified `ThinkingLevel`, and normalized token usage.
|
|
|
70
70
|
| the words said with a refusal (capability `rejectionMessages`) | ✅ the denial tells Claude what the user said | ❌ a bare verdict (a plan's answer carries them) |
|
|
71
71
|
| `elicitation` (questions, MCP input) | `AskUserQuestion`; MCP `onElicitation` (form, url) | `request_user_input` in every mode (each thread starts with Codex's `default_mode_request_user_input`; declined in a turn that does not opt in); MCP elicitation (form, url) |
|
|
72
72
|
| steering (`turn/steer`) | ✅ uuid-stamped messages, read where Claude replays them; a late steer runs as one more query in the turn | ✅ `turn/steer`, read where Codex starts its user message |
|
|
73
|
+
| a cancel (`turn/cancel`) | the SDK's interrupt, confirmed once Claude acknowledges it or the turn ends within `cancelConfirmMs`; a turn Claude has not ended `cancelGraceMs` (10 s) after it has its process ended, and the next turn resumes on a new one | `turn/interrupt`, then the turn's commands stopped (below); its process ended when either is not done within `cancelGraceMs` (2 s) |
|
|
73
74
|
| image / file input (capabilities `images`, `files`) | images (data or http(s) URL), PDFs, text files (`files: text, pdf`) | images (data or local path), text files inline (`files: text`), local files as mentions |
|
|
74
75
|
| `includeRaw` | ✅ | ✅ |
|
|
75
76
|
|
|
@@ -417,7 +418,18 @@ recipe is in
|
|
|
417
418
|
A login lands in the store a turn with the same `env` uses (`CLAUDE_CONFIG_DIR`,
|
|
418
419
|
`CODEX_HOME`). Claude reports the credential a turn would run with, so a key in
|
|
419
420
|
the environment shows as `source: "environment"` over any login. A login change
|
|
420
|
-
starts each session's next turn on a new CLI. Codex
|
|
421
|
+
starts each session's next turn on a new CLI. A Codex session on its home's own
|
|
422
|
+
login also follows a change made outside the engine (`codex login` in a
|
|
423
|
+
terminal, another app): when the home's `auth.json` (a link followed to its
|
|
424
|
+
target) changed since its app-server started, the next turn starts a new one,
|
|
425
|
+
which resumes the thread; a turn already running finishes first. The engine
|
|
426
|
+
never opens the file, so any rewrite counts, a ChatGPT token Codex renewed
|
|
427
|
+
(about every ten days per login) included: one colder turn. A sign-out removes
|
|
428
|
+
the file, and the next turn fails `auth`. Not followed: a keychain store
|
|
429
|
+
(`cli_auth_credentials_store = "keyring"`, or `auto` with a keychain), and a
|
|
430
|
+
session the engine hands a login to (`credentials`, `userLogin`, `apiKey`),
|
|
431
|
+
which is logged in again at each turn. A warm Claude CLI reads its store on
|
|
432
|
+
each request (LLP 0011). Codex logins below `inheritConfig:
|
|
421
433
|
"all"` land in the `CODEX_HOME` the request's `env` names; under
|
|
422
434
|
`codexAppServer.userLogin` the turns in those homes run on the user's own
|
|
423
435
|
login, which a request with no `env` reads and signs in. The engine reads and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zvada/agent-server",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.24",
|
|
4
4
|
"description": "Harness-agnostic agent execution engine: run Claude Code, Codex (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
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,16 @@
|
|
|
25
25
|
"engines": {
|
|
26
26
|
"bun": ">=1.2.0"
|
|
27
27
|
},
|
|
28
|
-
"files": [
|
|
28
|
+
"files": [
|
|
29
|
+
"src",
|
|
30
|
+
"dist/types",
|
|
31
|
+
"dist/**/*.js",
|
|
32
|
+
"docs",
|
|
33
|
+
"AGENTS.md",
|
|
34
|
+
"README.md",
|
|
35
|
+
"CHANGELOG.md",
|
|
36
|
+
"LICENSE"
|
|
37
|
+
],
|
|
29
38
|
"publishConfig": {
|
|
30
39
|
"access": "public"
|
|
31
40
|
},
|
|
@@ -39,83 +48,99 @@
|
|
|
39
48
|
".": {
|
|
40
49
|
"agent-server-source": "./src/index.ts",
|
|
41
50
|
"types": "./dist/types/index.d.ts",
|
|
42
|
-
"
|
|
51
|
+
"bun": "./src/index.ts",
|
|
52
|
+
"default": "./dist/index.js"
|
|
43
53
|
},
|
|
44
54
|
"./protocol": {
|
|
45
55
|
"agent-server-source": "./src/protocol/index.ts",
|
|
46
56
|
"types": "./dist/types/protocol/index.d.ts",
|
|
47
|
-
"
|
|
57
|
+
"bun": "./src/protocol/index.ts",
|
|
58
|
+
"default": "./dist/protocol/index.js"
|
|
48
59
|
},
|
|
49
60
|
"./protocol/factories": {
|
|
50
61
|
"agent-server-source": "./src/protocol/factories.ts",
|
|
51
62
|
"types": "./dist/types/protocol/factories.d.ts",
|
|
52
|
-
"
|
|
63
|
+
"bun": "./src/protocol/factories.ts",
|
|
64
|
+
"default": "./dist/protocol/factories.js"
|
|
53
65
|
},
|
|
54
66
|
"./protocol/guards": {
|
|
55
67
|
"agent-server-source": "./src/protocol/guards.ts",
|
|
56
68
|
"types": "./dist/types/protocol/guards.d.ts",
|
|
57
|
-
"
|
|
69
|
+
"bun": "./src/protocol/guards.ts",
|
|
70
|
+
"default": "./dist/protocol/guards.js"
|
|
58
71
|
},
|
|
59
72
|
"./protocol/stop-reasons": {
|
|
60
73
|
"agent-server-source": "./src/protocol/stop-reasons.ts",
|
|
61
74
|
"types": "./dist/types/protocol/stop-reasons.d.ts",
|
|
62
|
-
"
|
|
75
|
+
"bun": "./src/protocol/stop-reasons.ts",
|
|
76
|
+
"default": "./dist/protocol/stop-reasons.js"
|
|
63
77
|
},
|
|
64
78
|
"./protocol/seq-cursor": {
|
|
65
79
|
"agent-server-source": "./src/protocol/seq-cursor.ts",
|
|
66
80
|
"types": "./dist/types/protocol/seq-cursor.d.ts",
|
|
67
|
-
"
|
|
81
|
+
"bun": "./src/protocol/seq-cursor.ts",
|
|
82
|
+
"default": "./dist/protocol/seq-cursor.js"
|
|
68
83
|
},
|
|
69
84
|
"./protocol/selectors": {
|
|
70
85
|
"agent-server-source": "./src/protocol/selectors.ts",
|
|
71
86
|
"types": "./dist/types/protocol/selectors.d.ts",
|
|
72
|
-
"
|
|
87
|
+
"bun": "./src/protocol/selectors.ts",
|
|
88
|
+
"default": "./dist/protocol/selectors.js"
|
|
73
89
|
},
|
|
74
90
|
"./core": {
|
|
75
91
|
"agent-server-source": "./src/core/index.ts",
|
|
76
92
|
"types": "./dist/types/core/index.d.ts",
|
|
77
|
-
"
|
|
93
|
+
"bun": "./src/core/index.ts",
|
|
94
|
+
"default": "./dist/core/index.js"
|
|
78
95
|
},
|
|
79
96
|
"./core/proxy": {
|
|
80
97
|
"agent-server-source": "./src/core/proxy/index.ts",
|
|
81
98
|
"types": "./dist/types/core/proxy/index.d.ts",
|
|
82
|
-
"
|
|
99
|
+
"bun": "./src/core/proxy/index.ts",
|
|
100
|
+
"default": "./dist/core/proxy/index.js"
|
|
83
101
|
},
|
|
84
102
|
"./server": {
|
|
85
103
|
"agent-server-source": "./src/server/index.ts",
|
|
86
104
|
"types": "./dist/types/server/index.d.ts",
|
|
87
|
-
"
|
|
105
|
+
"bun": "./src/server/index.ts",
|
|
106
|
+
"default": "./dist/server/index.js"
|
|
88
107
|
},
|
|
89
108
|
"./client": {
|
|
90
109
|
"agent-server-source": "./src/client/index.ts",
|
|
91
110
|
"types": "./dist/types/client/index.d.ts",
|
|
92
|
-
"
|
|
111
|
+
"bun": "./src/client/index.ts",
|
|
112
|
+
"default": "./dist/client/index.js"
|
|
93
113
|
},
|
|
94
114
|
"./accounts": {
|
|
95
115
|
"agent-server-source": "./src/accounts/index.ts",
|
|
96
116
|
"types": "./dist/types/accounts/index.d.ts",
|
|
97
|
-
"
|
|
117
|
+
"bun": "./src/accounts/index.ts",
|
|
118
|
+
"default": "./dist/accounts/index.js"
|
|
98
119
|
},
|
|
99
120
|
"./operator": {
|
|
100
121
|
"agent-server-source": "./src/operator/index.ts",
|
|
101
122
|
"types": "./dist/types/operator/index.d.ts",
|
|
102
|
-
"
|
|
123
|
+
"bun": "./src/operator/index.ts",
|
|
124
|
+
"default": "./dist/operator/index.js"
|
|
103
125
|
},
|
|
104
126
|
"./package.json": "./package.json",
|
|
105
127
|
"./sync": {
|
|
106
128
|
"agent-server-source": "./src/sync/index.ts",
|
|
107
129
|
"types": "./dist/types/sync/index.d.ts",
|
|
108
|
-
"
|
|
130
|
+
"bun": "./src/sync/index.ts",
|
|
131
|
+
"default": "./dist/sync/index.js"
|
|
109
132
|
},
|
|
110
133
|
"./sync/sqlite": {
|
|
111
134
|
"agent-server-source": "./src/sync/sqlite.ts",
|
|
112
135
|
"types": "./dist/types/sync/sqlite.d.ts",
|
|
113
|
-
"
|
|
136
|
+
"bun": "./src/sync/sqlite.ts",
|
|
137
|
+
"default": "./dist/sync/sqlite.js"
|
|
114
138
|
},
|
|
115
139
|
"./sync/node-sqlite": {
|
|
116
140
|
"agent-server-source": "./src/sync/node-sqlite.ts",
|
|
117
141
|
"types": "./dist/types/sync/node-sqlite.d.ts",
|
|
118
|
-
"
|
|
142
|
+
"bun": "./src/sync/node-sqlite.ts",
|
|
143
|
+
"default": "./dist/sync/node-sqlite.js"
|
|
119
144
|
}
|
|
120
145
|
},
|
|
121
146
|
"peerDependencies": {
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "../elicitation.ts";
|
|
16
16
|
import { PLAN_OPTIONS, PLAN_TITLE, approvedPlanMode } from "../plan.ts";
|
|
17
17
|
import { type ClaudeToolPolicy, fromSdkPermissionMode, toSdkPermissionMode } from "./options.ts";
|
|
18
|
-
import { claudeToolMeta } from "./tools.ts";
|
|
18
|
+
import { claudeMcpTool, claudeToolMeta } from "./tools.ts";
|
|
19
19
|
import type { ClaudeTurn } from "./turn.ts";
|
|
20
20
|
|
|
21
21
|
/** What a request needs of the turn it is asked in. */
|
|
@@ -69,6 +69,9 @@ export function createCanUseTool(deps: {
|
|
|
69
69
|
}): CanUseTool {
|
|
70
70
|
return async (toolName, input, options) => {
|
|
71
71
|
const { signal, toolUseID, agentID, suggestions, blockedPath, decisionReason } = options;
|
|
72
|
+
// The policy gets the `mcp` the request will carry; the rest of the
|
|
73
|
+
// request's metadata is read after the policy, which may change `input`.
|
|
74
|
+
const mcp = claudeMcpTool(toolName, deps.mcpServers?.());
|
|
72
75
|
// The host's policy sees every call first, questions and plans too: a
|
|
73
76
|
// host answers a plan through its own channel (AGNT does). A policy
|
|
74
77
|
// that wants the user to answer them returns undefined.
|
|
@@ -80,6 +83,7 @@ export function createCanUseTool(deps: {
|
|
|
80
83
|
suggestions,
|
|
81
84
|
blockedPath,
|
|
82
85
|
decisionReason,
|
|
86
|
+
...(mcp && { mcp }),
|
|
83
87
|
});
|
|
84
88
|
if (verdict) return verdict;
|
|
85
89
|
const turn = deps.turn();
|
|
@@ -28,9 +28,16 @@ import {
|
|
|
28
28
|
type ClaudeSessionPool,
|
|
29
29
|
claudeSessionPool,
|
|
30
30
|
} from "./session.ts";
|
|
31
|
+
import type { ClaudeTurn } from "./turn.ts";
|
|
31
32
|
|
|
32
33
|
type ClaudeContent = SDKUserMessage["message"]["content"];
|
|
33
34
|
|
|
35
|
+
/**
|
|
36
|
+
* How long after a cancel a turn Claude has not ended has its process ended,
|
|
37
|
+
* unless `cancelGraceMs` says otherwise (LLP 0001, D9).
|
|
38
|
+
*/
|
|
39
|
+
const CANCEL_GRACE_MS = 10_000;
|
|
40
|
+
|
|
34
41
|
const CAPABILITIES: AgentCapabilities = {
|
|
35
42
|
multiTurn: true,
|
|
36
43
|
sessionResume: true,
|
|
@@ -117,9 +124,11 @@ export class ClaudeCodeAgent extends SessionAgent {
|
|
|
117
124
|
readonly login: ClaudeCliLogin;
|
|
118
125
|
private readonly pool: ClaudeSessionPool;
|
|
119
126
|
private readonly credentials?: ClaudeCredentials;
|
|
127
|
+
private readonly cancelGraceMs: number;
|
|
120
128
|
|
|
121
129
|
constructor(private readonly agentOptions: ClaudeCodeAgentOptions = {}) {
|
|
122
130
|
super({ cancelConfirmMs: agentOptions.cancelConfirmMs });
|
|
131
|
+
this.cancelGraceMs = agentOptions.cancelGraceMs ?? CANCEL_GRACE_MS;
|
|
123
132
|
this.processes = agentOptions.processes ?? sharedNativeProcesses();
|
|
124
133
|
this.pool = claudeSessionPool({ ...agentOptions, processes: this.processes });
|
|
125
134
|
this.login = new ClaudeCliLogin({
|
|
@@ -151,11 +160,15 @@ export class ClaudeCodeAgent extends SessionAgent {
|
|
|
151
160
|
controller: AbortController,
|
|
152
161
|
): AsyncIterableIterator<ClaudeRawEvent> {
|
|
153
162
|
let held: ClaudeSession | undefined;
|
|
163
|
+
// The turn a cancel may interrupt, once it is sent.
|
|
164
|
+
let interruptible: ClaudeTurn | undefined;
|
|
154
165
|
let unconfirmedSession: ClaudeSession | undefined;
|
|
155
166
|
let removeInterrupt: (() => void) | undefined;
|
|
156
167
|
// @ref LLP 0001#d10--built-in-turns-own-their-logical-session-through-cleanup — a start under way ends at the abort, at once
|
|
157
168
|
// Until the turn has its process, the abort is the whole stop.
|
|
158
|
-
this.cancelWith(options, async () =>
|
|
169
|
+
this.cancelWith(options, async () =>
|
|
170
|
+
held ? this.interrupt(held, interruptible, options.sessionId) : true,
|
|
171
|
+
);
|
|
159
172
|
try {
|
|
160
173
|
controller.signal.throwIfAborted();
|
|
161
174
|
// @ref LLP 0010#a-turn-waits-for-its-cli-until-it-is-cancelled — the install is the server's
|
|
@@ -211,13 +224,17 @@ export class ClaudeCodeAgent extends SessionAgent {
|
|
|
211
224
|
permissions: options.onPermissionRequest,
|
|
212
225
|
elicitation: options.onElicitationRequest,
|
|
213
226
|
});
|
|
227
|
+
interruptible = turn;
|
|
214
228
|
try {
|
|
215
229
|
await this.openSteering(options, (request) =>
|
|
216
230
|
session.steer(toClaudeContent(request.input), request.steerId)
|
|
217
231
|
? "steered"
|
|
218
232
|
: "no_active_turn",
|
|
219
233
|
);
|
|
220
|
-
removeInterrupt = onAbort(controller.signal, () =>
|
|
234
|
+
removeInterrupt = onAbort(controller.signal, () => {
|
|
235
|
+
void session.interruptTurn();
|
|
236
|
+
void session.endUnstopped(turn, this.cancelGraceMs);
|
|
237
|
+
});
|
|
221
238
|
const mcpServers = session.mcp.names;
|
|
222
239
|
if (mcpServers.length) yield { type: "agentServer/mcpServers", names: mcpServers };
|
|
223
240
|
let sawOutput = false;
|
|
@@ -324,10 +341,20 @@ export class ClaudeCodeAgent extends SessionAgent {
|
|
|
324
341
|
* classifies as cancelled even when the generator drains to a natural end
|
|
325
342
|
* before the SDK interrupt lands (the abort-order race that could surface
|
|
326
343
|
* a clean user cancel as `error`/`end_turn`). The SDK interrupt's
|
|
327
|
-
* round-trip
|
|
344
|
+
* round-trip confirms the cancel, and so does the turn's end, whoever ended
|
|
345
|
+
* it: Claude, or the grace that ended its process (`endUnstopped`). An
|
|
346
|
+
* interrupt that fails while the turn runs is unconfirmed at once.
|
|
328
347
|
*/
|
|
329
|
-
private async interrupt(
|
|
330
|
-
|
|
348
|
+
private async interrupt(
|
|
349
|
+
session: ClaudeSession,
|
|
350
|
+
turn: ClaudeTurn | undefined,
|
|
351
|
+
sessionId: string,
|
|
352
|
+
): Promise<boolean> {
|
|
353
|
+
// @ref LLP 0016.000#the-cancel-answer — a turn that ended is confirmed stopped, however it ended
|
|
354
|
+
const interrupting = session.interruptTurn();
|
|
355
|
+
const interrupted = turn
|
|
356
|
+
? await Promise.race([interrupting, turn.ended.then(() => true)])
|
|
357
|
+
: await interrupting;
|
|
331
358
|
if (!interrupted) {
|
|
332
359
|
emitDiagnostic(this.agentOptions.onDiagnostic, {
|
|
333
360
|
type: "interruptTimeout",
|
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
PermissionUpdate,
|
|
6
6
|
SettingSource,
|
|
7
7
|
} from "@anthropic-ai/claude-agent-sdk";
|
|
8
|
-
import type { PermissionMode } from "../../../protocol/index.ts";
|
|
8
|
+
import type { McpTool, PermissionMode } from "../../../protocol/index.ts";
|
|
9
9
|
import type { DiagnosticHandler } from "../../diagnostics.ts";
|
|
10
10
|
import type { NativeProcesses } from "../../processes/native-processes.ts";
|
|
11
11
|
import type { AgentExecuteOptions } from "../base.ts";
|
|
@@ -72,6 +72,12 @@ export type ClaudeToolPolicy = (
|
|
|
72
72
|
blockedPath?: string;
|
|
73
73
|
/** The SDK's explanation for why this permission request fired, when it gives one. */
|
|
74
74
|
decisionReason?: string;
|
|
75
|
+
/**
|
|
76
|
+
* An MCP tool's server and tool, as the permission request for this call
|
|
77
|
+
* names them (by the servers the session attached, so a server whose name
|
|
78
|
+
* holds `__` resolves); absent for a tool that is no MCP tool.
|
|
79
|
+
*/
|
|
80
|
+
mcp?: McpTool;
|
|
75
81
|
},
|
|
76
82
|
) => PermissionResult | undefined | Promise<PermissionResult | undefined>;
|
|
77
83
|
|
|
@@ -111,13 +117,19 @@ export interface ClaudeCodeAgentOptions {
|
|
|
111
117
|
/** Idle time before an unused session's subprocess is shut down (default 5 minutes). */
|
|
112
118
|
idleTimeoutMs?: number;
|
|
113
119
|
/**
|
|
114
|
-
* How long a cancel waits for Claude to acknowledge its interrupt
|
|
115
|
-
* it answers `confirmed: false`
|
|
116
|
-
* and how long a turn the runtime
|
|
117
|
-
*
|
|
118
|
-
* process and the turn running (LLP 0016, decision 11).
|
|
120
|
+
* How long a cancel waits for Claude to acknowledge its interrupt, or for
|
|
121
|
+
* its turn to end, before it answers `confirmed: false`
|
|
122
|
+
* (`CANCEL_CONFIRM_MS`, 2 s, by default), and how long a turn the runtime
|
|
123
|
+
* stopped reading has to end before its process is replaced.
|
|
119
124
|
*/
|
|
120
125
|
cancelConfirmMs?: number;
|
|
126
|
+
/**
|
|
127
|
+
* How long after a cancel a turn Claude has not ended has its process
|
|
128
|
+
* ended (10 s by default); the turn then ends `cancelled`, `onSessionEnd`
|
|
129
|
+
* says `replaced`, and the session's next turn resumes the conversation
|
|
130
|
+
* on a new process (LLP 0001, D9).
|
|
131
|
+
*/
|
|
132
|
+
cancelGraceMs?: number;
|
|
121
133
|
/**
|
|
122
134
|
* In-process MCP servers to attach to every session (the SDK's
|
|
123
135
|
* `createSdkMcpServer` output). Called once per session spawn. Operator
|
|
@@ -135,11 +147,12 @@ export interface ClaudeCodeAgentOptions {
|
|
|
135
147
|
/**
|
|
136
148
|
* Called exactly once when a live session's subprocess ends, with why:
|
|
137
149
|
* `idle` (idle-timeout eviction), `replaced` (config change or host resume
|
|
138
|
-
* required a new process
|
|
139
|
-
* (terminateAll). The
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
150
|
+
* required a new process, or a cancelled turn outlived `cancelGraceMs`),
|
|
151
|
+
* `released` (explicit release/close), `shutdown` (terminateAll). The
|
|
152
|
+
* seam for host-managed per-session resources — BYOK proxy keys,
|
|
153
|
+
* recorders — instead of re-deriving termination from side effects.
|
|
154
|
+
* NOTE: `replaced` sessions usually respawn immediately with context
|
|
155
|
+
* preserved; drop only resources bound to the dead subprocess.
|
|
143
156
|
*/
|
|
144
157
|
onSessionEnd?: (sessionId: string, reason: ClaudeSessionEndReason) => void;
|
|
145
158
|
/** Operational diagnostics (interrupt timeouts). */
|
|
@@ -378,6 +378,19 @@ export class ClaudeSession implements PooledProcess, PooledClient {
|
|
|
378
378
|
if (this.turn === turn) await this.terminate("replaced");
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
+
// @ref LLP 0001#d9--the-wire-is-quick-ack-json-rpc-requests-flow-one-way — cancelGraceMs: an agent that has not stopped is ended
|
|
382
|
+
/**
|
|
383
|
+
* End the process of a cancelled `turn` that has not ended within
|
|
384
|
+
* `graceMs`: Claude did not stop it (a frozen or hung CLI), and nothing
|
|
385
|
+
* else would. The turn's events end, so it ends cancelled, and the pool
|
|
386
|
+
* hears `replaced` (`onSessionEnd`); the next turn resumes on a new
|
|
387
|
+
* process. A turn that ended, and any turn after it, is left alone.
|
|
388
|
+
*/
|
|
389
|
+
async endUnstopped(turn: ClaudeTurn, graceMs: number): Promise<void> {
|
|
390
|
+
if ((await withTimeout(turn.ended, graceMs)) === undefined && this.turn === turn)
|
|
391
|
+
await this.terminate("replaced");
|
|
392
|
+
}
|
|
393
|
+
|
|
381
394
|
private async interrupt(turn: ClaudeTurn | undefined, timeoutMs: number): Promise<boolean> {
|
|
382
395
|
if (this.state === "idle" || this.state === "terminated") return true;
|
|
383
396
|
if (this.state === "starting" || !this.cliStarted || !this.query) {
|