@zvada/agent-server 0.3.26 → 0.3.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -0
- package/README.md +7 -5
- package/dist/client/client.js +27 -11
- package/dist/client/connection.js +35 -3
- package/dist/core/agents/acp/account.js +111 -0
- package/dist/core/agents/acp/acp-agent.js +247 -158
- package/dist/core/agents/acp/adapter.js +103 -34
- package/dist/core/agents/acp/client.js +169 -42
- package/dist/core/agents/acp/known-agents.js +12 -5
- package/dist/core/agents/acp/mappings.js +84 -20
- package/dist/core/agents/acp/models.js +59 -0
- package/dist/core/agents/acp/profile.js +36 -0
- package/dist/core/agents/acp/prompts.js +248 -0
- package/dist/core/agents/acp/requests.js +4 -4
- package/dist/core/agents/claude-code/approvals.js +1 -1
- package/dist/core/agents/claude-code/login.js +4 -1
- package/dist/core/agents/claude-code/session.js +38 -10
- package/dist/core/agents/claude-code/spawn.js +0 -26
- package/dist/core/agents/codex-app-server/client.js +12 -13
- package/dist/core/agents/codex-app-server/login.js +4 -1
- package/dist/core/agents/codex-app-server/plan-approval.js +1 -1
- package/dist/core/agents/gemini/failures.js +133 -0
- package/dist/core/agents/gemini/login.js +173 -0
- package/dist/core/agents/gemini/profile.js +137 -0
- package/dist/core/agents/gemini/tools.js +91 -0
- package/dist/core/agents/login.js +8 -6
- package/dist/core/agents/scripted/scripted-agent.js +30 -3
- package/dist/core/agents/stderr-tail.js +5 -2
- package/dist/core/presets.js +17 -1
- package/dist/core/processes/native-processes.js +23 -1
- package/dist/core/provision/install-build.js +70 -26
- package/dist/core/provision/pins.js +5 -0
- package/dist/core/provision/provisioner.js +39 -16
- package/dist/core/provision/releases.js +39 -1
- package/dist/core/provision/tools.js +87 -28
- package/dist/core/runtime/agent-runtime.js +15 -5
- package/dist/core/runtime/event-processor.js +13 -8
- package/dist/core/runtime/origin-line.js +42 -0
- package/dist/core/runtime/request-broker.js +2 -1
- package/dist/core/runtime/steering.js +4 -3
- package/dist/core/runtime/turn.js +6 -4
- package/dist/operator/errors.js +97 -0
- package/dist/operator/index.js +10 -5
- package/dist/operator/mcp.js +7 -12
- package/dist/operator/operator.js +1431 -378
- package/dist/operator/refs.js +59 -0
- package/dist/operator/render.js +199 -94
- package/dist/operator/session-tools.js +88 -0
- package/dist/operator/types.js +30 -0
- package/dist/operator/view.js +82 -27
- package/dist/protocol/account.js +5 -1
- package/dist/protocol/auth.js +5 -1
- package/dist/protocol/config.js +12 -5
- package/dist/protocol/conversation.js +3 -0
- package/dist/protocol/credentials.js +9 -1
- package/dist/protocol/harness.js +9 -1
- package/dist/protocol/history.js +2 -1
- package/dist/protocol/index.js +1 -0
- package/dist/protocol/lifecycle.js +19 -0
- package/dist/protocol/origin.js +39 -0
- package/dist/protocol/reduce.js +2 -0
- package/dist/protocol/wire.js +17 -0
- package/dist/server/bin.js +22 -7
- package/dist/server/install.js +6 -4
- package/dist/server/routes.js +15 -5
- package/dist/types/client/client.d.ts.map +1 -1
- package/dist/types/client/connection.d.ts +14 -2
- package/dist/types/client/connection.d.ts.map +1 -1
- package/dist/types/client/turns.d.ts +2 -2
- package/dist/types/client/turns.d.ts.map +1 -1
- package/dist/types/core/agents/acp/account.d.ts +55 -0
- package/dist/types/core/agents/acp/account.d.ts.map +1 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts +65 -36
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -1
- package/dist/types/core/agents/acp/adapter.d.ts +28 -3
- package/dist/types/core/agents/acp/adapter.d.ts.map +1 -1
- package/dist/types/core/agents/acp/client.d.ts +66 -4
- package/dist/types/core/agents/acp/client.d.ts.map +1 -1
- package/dist/types/core/agents/acp/known-agents.d.ts +4 -2
- package/dist/types/core/agents/acp/known-agents.d.ts.map +1 -1
- package/dist/types/core/agents/acp/mappings.d.ts +53 -7
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -1
- package/dist/types/core/agents/acp/models.d.ts +22 -0
- package/dist/types/core/agents/acp/models.d.ts.map +1 -0
- package/dist/types/core/agents/acp/profile.d.ts +92 -0
- package/dist/types/core/agents/acp/profile.d.ts.map +1 -0
- package/dist/types/core/agents/acp/prompts.d.ts +108 -0
- package/dist/types/core/agents/acp/prompts.d.ts.map +1 -0
- package/dist/types/core/agents/acp/requests.d.ts +7 -1
- package/dist/types/core/agents/acp/requests.d.ts.map +1 -1
- package/dist/types/core/agents/base.d.ts +2 -0
- package/dist/types/core/agents/base.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/login.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/session.d.ts +3 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/spawn.d.ts +0 -8
- package/dist/types/core/agents/claude-code/spawn.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -1
- package/dist/types/core/agents/gemini/failures.d.ts +25 -0
- package/dist/types/core/agents/gemini/failures.d.ts.map +1 -0
- package/dist/types/core/agents/gemini/login.d.ts +28 -0
- package/dist/types/core/agents/gemini/login.d.ts.map +1 -0
- package/dist/types/core/agents/gemini/profile.d.ts +30 -0
- package/dist/types/core/agents/gemini/profile.d.ts.map +1 -0
- package/dist/types/core/agents/gemini/tools.d.ts +18 -0
- package/dist/types/core/agents/gemini/tools.d.ts.map +1 -0
- package/dist/types/core/agents/login.d.ts +15 -5
- package/dist/types/core/agents/login.d.ts.map +1 -1
- package/dist/types/core/agents/scripted/scripted-agent.d.ts +14 -1
- package/dist/types/core/agents/scripted/scripted-agent.d.ts.map +1 -1
- package/dist/types/core/agents/stderr-tail.d.ts +1 -1
- package/dist/types/core/agents/stderr-tail.d.ts.map +1 -1
- package/dist/types/core/presets.d.ts +2 -2
- package/dist/types/core/presets.d.ts.map +1 -1
- package/dist/types/core/processes/native-processes.d.ts +6 -0
- package/dist/types/core/processes/native-processes.d.ts.map +1 -1
- package/dist/types/core/provision/checksums.d.ts +7 -1
- package/dist/types/core/provision/checksums.d.ts.map +1 -1
- package/dist/types/core/provision/install-build.d.ts +32 -6
- package/dist/types/core/provision/install-build.d.ts.map +1 -1
- package/dist/types/core/provision/pins.d.ts +4 -0
- package/dist/types/core/provision/pins.d.ts.map +1 -1
- package/dist/types/core/provision/provisioner.d.ts +18 -7
- package/dist/types/core/provision/provisioner.d.ts.map +1 -1
- package/dist/types/core/provision/releases.d.ts +2 -1
- package/dist/types/core/provision/releases.d.ts.map +1 -1
- package/dist/types/core/provision/tools.d.ts +36 -7
- package/dist/types/core/provision/tools.d.ts.map +1 -1
- package/dist/types/core/runtime/agent-runtime.d.ts +4 -2
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -1
- package/dist/types/core/runtime/event-processor.d.ts +2 -2
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -1
- package/dist/types/core/runtime/origin-line.d.ts +15 -0
- package/dist/types/core/runtime/origin-line.d.ts.map +1 -0
- package/dist/types/core/runtime/request-broker.d.ts +1 -1
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -1
- package/dist/types/core/runtime/steering.d.ts +7 -4
- package/dist/types/core/runtime/steering.d.ts.map +1 -1
- package/dist/types/core/runtime/turn.d.ts.map +1 -1
- package/dist/types/operator/errors.d.ts +87 -0
- package/dist/types/operator/errors.d.ts.map +1 -0
- package/dist/types/operator/index.d.ts +10 -5
- package/dist/types/operator/index.d.ts.map +1 -1
- package/dist/types/operator/mcp.d.ts +1 -1
- package/dist/types/operator/mcp.d.ts.map +1 -1
- package/dist/types/operator/operator.d.ts +15 -197
- package/dist/types/operator/operator.d.ts.map +1 -1
- package/dist/types/operator/refs.d.ts +25 -0
- package/dist/types/operator/refs.d.ts.map +1 -0
- package/dist/types/operator/render.d.ts +67 -22
- package/dist/types/operator/render.d.ts.map +1 -1
- package/dist/types/operator/session-tools.d.ts +61 -0
- package/dist/types/operator/session-tools.d.ts.map +1 -0
- package/dist/types/operator/types.d.ts +442 -0
- package/dist/types/operator/types.d.ts.map +1 -0
- package/dist/types/operator/view.d.ts +19 -29
- package/dist/types/operator/view.d.ts.map +1 -1
- package/dist/types/protocol/account.d.ts +4 -2
- package/dist/types/protocol/account.d.ts.map +1 -1
- package/dist/types/protocol/auth.d.ts +10 -7
- package/dist/types/protocol/auth.d.ts.map +1 -1
- package/dist/types/protocol/clis.d.ts +4 -3
- package/dist/types/protocol/clis.d.ts.map +1 -1
- package/dist/types/protocol/config.d.ts +22 -5
- package/dist/types/protocol/config.d.ts.map +1 -1
- package/dist/types/protocol/conversation.d.ts +47 -6
- package/dist/types/protocol/conversation.d.ts.map +1 -1
- package/dist/types/protocol/credentials.d.ts +8 -0
- package/dist/types/protocol/credentials.d.ts.map +1 -1
- package/dist/types/protocol/execution.d.ts +1 -1
- package/dist/types/protocol/harness.d.ts +5 -2
- package/dist/types/protocol/harness.d.ts.map +1 -1
- package/dist/types/protocol/history.d.ts +1 -1
- package/dist/types/protocol/history.d.ts.map +1 -1
- package/dist/types/protocol/index.d.ts +1 -0
- package/dist/types/protocol/index.d.ts.map +1 -1
- package/dist/types/protocol/lifecycle.d.ts +48 -10
- package/dist/types/protocol/lifecycle.d.ts.map +1 -1
- package/dist/types/protocol/models.d.ts +3 -0
- package/dist/types/protocol/models.d.ts.map +1 -1
- package/dist/types/protocol/origin.d.ts +49 -0
- package/dist/types/protocol/origin.d.ts.map +1 -0
- package/dist/types/protocol/reduce.d.ts.map +1 -1
- package/dist/types/protocol/wire-api.d.ts +78 -30
- package/dist/types/protocol/wire-api.d.ts.map +1 -1
- package/dist/types/protocol/wire.d.ts +78 -12
- package/dist/types/protocol/wire.d.ts.map +1 -1
- package/dist/types/server/install.d.ts +2 -1
- package/dist/types/server/install.d.ts.map +1 -1
- package/dist/types/server/routes.d.ts.map +1 -1
- package/docs/consuming.md +62 -121
- package/docs/deploy.md +17 -8
- package/docs/harnesses.md +166 -44
- package/docs/sync-history.md +2 -1
- package/package.json +1 -1
- package/src/client/client.ts +36 -9
- package/src/client/connection.ts +31 -1
- package/src/client/turns.ts +2 -1
- package/src/core/agents/acp/account.ts +158 -0
- package/src/core/agents/acp/acp-agent.ts +288 -178
- package/src/core/agents/acp/adapter.ts +126 -35
- package/src/core/agents/acp/client.ts +196 -49
- package/src/core/agents/acp/known-agents.ts +14 -5
- package/src/core/agents/acp/mappings.ts +112 -21
- package/src/core/agents/acp/models.ts +72 -0
- package/src/core/agents/acp/profile.ts +127 -0
- package/src/core/agents/acp/prompts.ts +287 -0
- package/src/core/agents/acp/requests.ts +16 -9
- package/src/core/agents/base.ts +2 -0
- package/src/core/agents/claude-code/approvals.ts +2 -2
- package/src/core/agents/claude-code/login.ts +4 -1
- package/src/core/agents/claude-code/session.ts +38 -8
- package/src/core/agents/claude-code/spawn.ts +0 -26
- package/src/core/agents/codex-app-server/client.ts +11 -18
- package/src/core/agents/codex-app-server/login.ts +4 -5
- package/src/core/agents/codex-app-server/plan-approval.ts +1 -1
- package/src/core/agents/gemini/failures.ts +148 -0
- package/src/core/agents/gemini/login.ts +188 -0
- package/src/core/agents/gemini/profile.ts +162 -0
- package/src/core/agents/gemini/tools.ts +99 -0
- package/src/core/agents/login.ts +14 -8
- package/src/core/agents/scripted/scripted-agent.ts +42 -3
- package/src/core/agents/stderr-tail.ts +5 -2
- package/src/core/presets.ts +19 -3
- package/src/core/processes/native-processes.ts +32 -1
- package/src/core/provision/checksums.ts +12 -2
- package/src/core/provision/install-build.ts +122 -55
- package/src/core/provision/pins.ts +5 -0
- package/src/core/provision/provisioner.ts +62 -27
- package/src/core/provision/releases.ts +47 -1
- package/src/core/provision/tools.ts +124 -31
- package/src/core/runtime/agent-runtime.ts +31 -7
- package/src/core/runtime/event-processor.ts +13 -6
- package/src/core/runtime/origin-line.ts +43 -0
- package/src/core/runtime/request-broker.ts +2 -0
- package/src/core/runtime/steering.ts +8 -4
- package/src/core/runtime/turn.ts +11 -4
- package/src/operator/errors.ts +221 -0
- package/src/operator/index.ts +18 -23
- package/src/operator/mcp.ts +7 -16
- package/src/operator/operator.ts +1684 -610
- package/src/operator/refs.ts +75 -0
- package/src/operator/render.ts +260 -118
- package/src/operator/session-tools.ts +127 -0
- package/src/operator/types.ts +506 -0
- package/src/operator/view.ts +93 -42
- package/src/protocol/account.ts +5 -2
- package/src/protocol/auth.ts +5 -1
- package/src/protocol/config.ts +14 -6
- package/src/protocol/conversation.ts +3 -0
- package/src/protocol/credentials.ts +11 -2
- package/src/protocol/harness.ts +9 -1
- package/src/protocol/history.ts +2 -1
- package/src/protocol/index.ts +1 -0
- package/src/protocol/lifecycle.ts +21 -0
- package/src/protocol/origin.ts +47 -0
- package/src/protocol/reduce.ts +4 -0
- package/src/protocol/wire.ts +18 -0
- package/src/server/bin.ts +20 -6
- package/src/server/install.ts +6 -3
- package/src/server/routes.ts +16 -5
package/dist/operator/view.js
CHANGED
|
@@ -1,35 +1,90 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* the same shape directly. Nothing here knows about projects, workspaces,
|
|
7
|
-
* accounts or storage: those are the host's.
|
|
2
|
+
* What the operator needs to know about one session, however its host keeps
|
|
3
|
+
* it. A host that holds a folded `ConversationState` gets it with `viewOf`; a
|
|
4
|
+
* host that keeps its own rows builds the same shape. Nothing here knows about
|
|
5
|
+
* projects, workspaces, accounts or storage: those are the host's.
|
|
8
6
|
*/
|
|
9
7
|
import { conversationMessages, pendingElicitations, pendingPermissions, } from "../protocol/conversation.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
// @ref LLP 0019#answer_request-write — a plan only when the engine says so; anything else is a permission
|
|
9
|
+
/** A decision's kind, from its `purpose`: `plan` when it says so, else a permission. */
|
|
10
|
+
export function waitingOf(request) {
|
|
11
|
+
return { kind: request.purpose === "plan" ? "plan" : "permission", request };
|
|
13
12
|
}
|
|
14
|
-
/**
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
/** Whether a status needs no more waiting: a wait returns it. */
|
|
14
|
+
export const settledStatus = (status) => status !== "working" && status !== "setting_up";
|
|
15
|
+
/**
|
|
16
|
+
* The view of a session whose events were folded with the engine's reducer,
|
|
17
|
+
* with its turn facts (`running`, `lastEnded`) from every turn, not a page.
|
|
18
|
+
*/
|
|
19
19
|
export function viewOf(state) {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
return viewWithFacts(state);
|
|
21
|
+
}
|
|
22
|
+
/** One turn of a folded state, by id: the host's `turn`, for a host that folds. */
|
|
23
|
+
export function turnOf(state, turnId) {
|
|
24
|
+
const turn = state.turns.find((t) => t.turnId === turnId);
|
|
25
|
+
if (!turn)
|
|
26
|
+
return { state: "unknown" };
|
|
27
|
+
if (turn.status === "active")
|
|
28
|
+
return { state: "running" };
|
|
29
|
+
return {
|
|
30
|
+
state: "ended",
|
|
31
|
+
outcome: turn.error ? "failed" : turn.stopReason === "cancelled" ? "cancelled" : "done",
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function viewWithFacts(state) {
|
|
35
|
+
const messages = conversationMessages(state);
|
|
36
|
+
const waiting = [
|
|
37
|
+
...pendingElicitations(state).map((request) => ({ kind: "question", request })),
|
|
38
|
+
...pendingPermissions(state).map(waitingOf),
|
|
39
|
+
];
|
|
40
|
+
const turns = state.turns.map((turn) => {
|
|
41
|
+
const outcome = turn.status === "active"
|
|
42
|
+
? "running"
|
|
43
|
+
: turn.error
|
|
44
|
+
? "failed"
|
|
45
|
+
: turn.stopReason === "cancelled"
|
|
46
|
+
? "cancelled"
|
|
47
|
+
: "done";
|
|
48
|
+
return {
|
|
49
|
+
turnId: turn.turnId,
|
|
50
|
+
outcome,
|
|
51
|
+
...(turn.error ? { error: turn.error.message } : {}),
|
|
52
|
+
messages: messages
|
|
53
|
+
.filter((message) => message.turnId === turn.turnId)
|
|
54
|
+
.map((message) => ({
|
|
55
|
+
role: message.role,
|
|
56
|
+
parts: message.parts,
|
|
57
|
+
...(message.parentToolCallId ? { nested: true } : {}),
|
|
58
|
+
...(message.origin ? { origin: message.origin } : {}),
|
|
59
|
+
})),
|
|
60
|
+
startedAt: turn.startedAt,
|
|
61
|
+
...(turn.endedAt !== undefined ? { endedAt: turn.endedAt } : {}),
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
const last = turns.at(-1)?.outcome;
|
|
65
|
+
const status = waiting.length
|
|
66
|
+
? "needs_input"
|
|
67
|
+
: last === "running"
|
|
68
|
+
? "working"
|
|
69
|
+
: last === "failed"
|
|
70
|
+
? "error"
|
|
71
|
+
: last === "cancelled"
|
|
72
|
+
? "stopped"
|
|
73
|
+
: "idle";
|
|
74
|
+
const running = turns.find((t) => t.outcome === "running")?.turnId;
|
|
75
|
+
const ended = [...turns].reverse().find((t) => t.outcome !== "running");
|
|
22
76
|
return {
|
|
23
|
-
status
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
77
|
+
status,
|
|
78
|
+
turns,
|
|
79
|
+
waiting,
|
|
80
|
+
...(running ? { running } : {}),
|
|
81
|
+
...(ended
|
|
82
|
+
? {
|
|
83
|
+
lastEnded: {
|
|
84
|
+
turnId: ended.turnId,
|
|
85
|
+
outcome: ended.outcome,
|
|
86
|
+
},
|
|
87
|
+
}
|
|
88
|
+
: {}),
|
|
34
89
|
};
|
|
35
90
|
}
|
package/dist/protocol/account.js
CHANGED
|
@@ -46,7 +46,9 @@ const CLOUDS = {
|
|
|
46
46
|
/**
|
|
47
47
|
* What to call a login, the same wherever it lives: `Claude Max`, `ChatGPT
|
|
48
48
|
* Pro`, `Claude subscription` (plan unknown), `OpenAI API key`, `Amazon
|
|
49
|
-
* Bedrock`. A
|
|
49
|
+
* Bedrock`. A subscription whose login names its own plan (`label`) is
|
|
50
|
+
* called that; otherwise the name is made from its plan, and a plan this
|
|
51
|
+
* table does not know shows as the provider names it.
|
|
50
52
|
*/
|
|
51
53
|
export function accountLabel(harness, login) {
|
|
52
54
|
if (login.credential === "api_key")
|
|
@@ -55,6 +57,8 @@ export function accountLabel(harness, login) {
|
|
|
55
57
|
return login.provider && (CLOUDS[login.provider] ?? login.provider);
|
|
56
58
|
if (login.credential !== "subscription")
|
|
57
59
|
return undefined;
|
|
60
|
+
if (login.label)
|
|
61
|
+
return login.label;
|
|
58
62
|
const names = PLANS[harness];
|
|
59
63
|
if (!names)
|
|
60
64
|
return login.plan;
|
package/dist/protocol/auth.js
CHANGED
|
@@ -83,7 +83,11 @@ export const HarnessAuthSchema = AccountInfoSchema.extend({
|
|
|
83
83
|
state: openVocabulary(AUTH_STATES),
|
|
84
84
|
credential: openVocabulary(AUTH_CREDENTIALS).optional(),
|
|
85
85
|
source: openVocabulary(AUTH_SOURCES).optional(),
|
|
86
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* What to show for it (`Claude Max`, `ChatGPT Pro`, `OpenAI API key`):
|
|
88
|
+
* `accountLabel`, which keeps the name a subscription's login gives its
|
|
89
|
+
* own plan, where it gives one, and otherwise makes one from its plan.
|
|
90
|
+
*/
|
|
87
91
|
label: z.string().optional(),
|
|
88
92
|
/** When the credential stops working (epoch ms), where known. */
|
|
89
93
|
expiresAt: z.number().int().optional(),
|
package/dist/protocol/config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { AgentHarnessSchema } from "./harness.js";
|
|
3
|
+
import { OriginSchema, agentOrigin } from "./origin.js";
|
|
3
4
|
import { AgentInputSchema } from "./part-input.js";
|
|
4
5
|
import { ThinkingLevelSchema } from "./thinking.js";
|
|
5
6
|
import { openVocabulary } from "./vocabulary.js";
|
|
@@ -144,14 +145,20 @@ export const RunRequestSchema = z.object({
|
|
|
144
145
|
turnId: z.string(),
|
|
145
146
|
input: AgentInputSchema,
|
|
146
147
|
config: RunConfigSchema,
|
|
148
|
+
/** Who sent the input; absent is the person (`OriginSchema`). */
|
|
149
|
+
origin: OriginSchema.optional(),
|
|
147
150
|
});
|
|
151
|
+
// @ref LLP 0019#origin-on-the-wire-and-to-the-model — another sender is another turn
|
|
148
152
|
/**
|
|
149
|
-
* What makes a turn the same turn when a client sends its ids again: its
|
|
150
|
-
* and the config that shapes what the agent does. What a
|
|
151
|
-
* can change without making it another turn stays out:
|
|
152
|
-
* per-session URL), the environment, the API key, and
|
|
153
|
+
* What makes a turn the same turn when a client sends its ids again: its
|
|
154
|
+
* input, who sent it, and the config that shapes what the agent does. What a
|
|
155
|
+
* client's own restart can change without making it another turn stays out:
|
|
156
|
+
* MCP endpoints (a fresh per-session URL), the environment, the API key, and
|
|
157
|
+
* raw passthrough. The person's origin, said or not, adds nothing, so a
|
|
158
|
+
* request's identity is what it was before origins existed.
|
|
153
159
|
*/
|
|
154
160
|
export function turnIdentity(request) {
|
|
155
161
|
const { mcpServers: _mcp, env: _env, apiKey: _key, includeRaw: _raw, ...config } = request.config;
|
|
156
|
-
|
|
162
|
+
const origin = agentOrigin(request.origin);
|
|
163
|
+
return { input: request.input, config, ...(origin && { origin }) };
|
|
157
164
|
}
|
|
@@ -4,6 +4,7 @@ import { ErrorCategorySchema, ErrorInfoSchema } from "./errors.js";
|
|
|
4
4
|
import { TurnExecutionSchema } from "./execution.js";
|
|
5
5
|
import { HarnessIdSchema } from "./harness.js";
|
|
6
6
|
import { CompactionStatusSchema, CompactionTriggerSchema, ElicitationOutcomeSchema, ElicitationRequestedEventSchema, ErrorEventSchema, LimitStatusSchema, LimitWindowSchema, PermissionOutcomeSchema, PermissionRequestedEventSchema, SessionEndReasonSchema, StopReasonSchema, UnknownEventSchema, } from "./lifecycle.js";
|
|
7
|
+
import { ReportedOriginSchema } from "./origin.js";
|
|
7
8
|
import { PartSchema, UnknownPartSchema } from "./parts.js";
|
|
8
9
|
import { EpochMsSchema } from "./time.js";
|
|
9
10
|
import { DEFAULT_TOKEN_USAGE, TokenUsageSchema } from "./tokens.js";
|
|
@@ -24,6 +25,8 @@ export const ConversationMessageSchema = z.object({
|
|
|
24
25
|
/** Set when this is a sub-agent's output — nest it under that tool call. */
|
|
25
26
|
parentToolCallId: z.string().optional(),
|
|
26
27
|
model: z.string().optional(),
|
|
28
|
+
/** A user message's sender when it is not the person (`message.started`'s `origin`). */
|
|
29
|
+
origin: ReportedOriginSchema.optional(),
|
|
27
30
|
parts: z.array(z.union([PartSchema, UnknownPartSchema])),
|
|
28
31
|
startedAt: EpochMsSchema,
|
|
29
32
|
endedAt: EpochMsSchema.optional(),
|
|
@@ -46,8 +46,16 @@ const RUNS_ON = {
|
|
|
46
46
|
"claude-code": ClaudeCredentialSchema,
|
|
47
47
|
"codex-app-server": CodexCredentialSchema,
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Whether a product can hold a login for `harness`: it runs on a credential
|
|
51
|
+
* the product hands each turn (LLP 0012). One that runs only on its CLI's own
|
|
52
|
+
* sign-in, or on none (ACP, scripted), cannot.
|
|
53
|
+
*/
|
|
54
|
+
export function takesHeldCredential(harness) {
|
|
55
|
+
return Object.hasOwn(RUNS_ON, harness);
|
|
56
|
+
}
|
|
49
57
|
export function credentialRunsOn(harness, credential) {
|
|
50
|
-
if (!
|
|
58
|
+
if (!takesHeldCredential(harness))
|
|
51
59
|
return { ok: false, error: `${harness} runs on no credential a product holds.` };
|
|
52
60
|
const parsed = RUNS_ON[harness].safeParse(credential);
|
|
53
61
|
if (parsed.success)
|
package/dist/protocol/harness.js
CHANGED
|
@@ -4,13 +4,21 @@ import { openVocabulary } from "./vocabulary.js";
|
|
|
4
4
|
* The agent harnesses this engine can drive:
|
|
5
5
|
* - `claude-code` — Claude Code via @anthropic-ai/claude-agent-sdk (CLI under the hood)
|
|
6
6
|
* - `codex-app-server` — OpenAI Codex via `codex app-server` (long-lived JSON-RPC subprocess)
|
|
7
|
+
* - `gemini` — Gemini models via Google's Antigravity CLI (`agy acp`, an ACP agent),
|
|
8
|
+
* on the person's own Antigravity sign-in
|
|
7
9
|
* - `acp` — any Agent Client Protocol v1 agent subprocess (`gemini --acp`,
|
|
8
10
|
* `claude-code-acp`, `codex-acp`, ACP registry agents); the launch
|
|
9
11
|
* command is operator-configured, never taken from the wire
|
|
10
12
|
* - `scripted` — a script the operator gives plays the agent (a product's
|
|
11
13
|
* free test double); registered only with its script
|
|
12
14
|
*/
|
|
13
|
-
export const AGENT_HARNESSES = [
|
|
15
|
+
export const AGENT_HARNESSES = [
|
|
16
|
+
"claude-code",
|
|
17
|
+
"codex-app-server",
|
|
18
|
+
"gemini",
|
|
19
|
+
"acp",
|
|
20
|
+
"scripted",
|
|
21
|
+
];
|
|
14
22
|
export const AgentHarnessSchema = z.enum(AGENT_HARNESSES);
|
|
15
23
|
export const HarnessIdSchema = openVocabulary(AGENT_HARNESSES);
|
|
16
24
|
export function isAgentHarness(value) {
|
package/dist/protocol/history.js
CHANGED
|
@@ -155,7 +155,8 @@ export const HistoryWaitSchema = z.object({
|
|
|
155
155
|
});
|
|
156
156
|
/** Projection cache format changes whenever reducer semantics become incompatible.
|
|
157
157
|
* Raw canonical events remain authoritative and are never pruned by this cache. */
|
|
158
|
-
|
|
158
|
+
// v2: user messages carry `origin` (LLP 0019); a v1 checkpoint was folded without it.
|
|
159
|
+
export const CONVERSATION_CHECKPOINT_FORMAT = "agent-server.conversation.v2";
|
|
159
160
|
export const HistoryCheckpointRequestSchema = z.object({ through: HistoryVersionSchema });
|
|
160
161
|
export const HistoryCheckpointSchema = z.object({
|
|
161
162
|
version: HistoryVersionSchema,
|
package/dist/protocol/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { TurnExecutionSchema } from "./execution.js";
|
|
|
5
5
|
import { isKnownLifecycleEventType } from "./guards.js";
|
|
6
6
|
import { HarnessIdSchema } from "./harness.js";
|
|
7
7
|
import { MetaSchema } from "./meta.js";
|
|
8
|
+
import { ReportedOriginSchema } from "./origin.js";
|
|
8
9
|
import { PartSchema, decodePart } from "./parts.js";
|
|
9
10
|
import { EpochMsSchema } from "./time.js";
|
|
10
11
|
import { TokenUsageSchema } from "./tokens.js";
|
|
@@ -244,6 +245,12 @@ export const MessageStartedEventSchema = z.object({
|
|
|
244
245
|
* the turn asked for.
|
|
245
246
|
*/
|
|
246
247
|
model: z.string().optional(),
|
|
248
|
+
/**
|
|
249
|
+
* A user message's sender when it is not the person: the request's
|
|
250
|
+
* `origin`, the turn's echo and a steer's alike. Absent on the person's
|
|
251
|
+
* messages and on every assistant message.
|
|
252
|
+
*/
|
|
253
|
+
origin: ReportedOriginSchema.optional(),
|
|
247
254
|
...stamped,
|
|
248
255
|
});
|
|
249
256
|
/**
|
|
@@ -365,10 +372,22 @@ export const PermissionOutcomeSchema = z.discriminatedUnion("outcome", [
|
|
|
365
372
|
* `options` is THE source of buttons — clients render the server's list,
|
|
366
373
|
* never derive affordances from local policy.
|
|
367
374
|
*/
|
|
375
|
+
// @ref LLP 0019#answer_request-write — the kind of a request is said, never read from its options
|
|
376
|
+
/**
|
|
377
|
+
* What a permission request decides. OPEN: `tool`, whether a tool call may
|
|
378
|
+
* run (every built-in harness's tool approvals, and an ACP agent's, whose
|
|
379
|
+
* requests are tool-scoped); `plan`, whether to leave planning and carry out
|
|
380
|
+
* a plan (Claude's and Codex's plan approvals). A value this build does not
|
|
381
|
+
* know, or none, is read as `tool`: the stricter one.
|
|
382
|
+
*/
|
|
383
|
+
export const PERMISSION_PURPOSES = ["tool", "plan"];
|
|
384
|
+
export const PermissionPurposeSchema = openVocabulary(PERMISSION_PURPOSES);
|
|
368
385
|
export const PermissionRequestedEventSchema = z.object({
|
|
369
386
|
type: z.literal("permission.requested"),
|
|
370
387
|
...inTurn,
|
|
371
388
|
requestId: z.string(),
|
|
389
|
+
/** What it decides; absent on an older engine's events, which read as `tool`. */
|
|
390
|
+
purpose: PermissionPurposeSchema.optional(),
|
|
372
391
|
/** Human-readable one-line prompt, always present (render this). */
|
|
373
392
|
title: z.string(),
|
|
374
393
|
/**
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// @ref LLP 0019#origin-on-the-wire-and-to-the-model — who sent a message, carried from the request to the echo
|
|
3
|
+
/**
|
|
4
|
+
* Who sent a turn's or a steer's message. Absent, or `person`, is the person
|
|
5
|
+
* the product serves; anything else is an agent, and the engine tells the
|
|
6
|
+
* receiving model so in one line before the input it is given. `name` is the
|
|
7
|
+
* host's, untrusted: the engine quotes it.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The longest id or name an origin carries, in UTF-16 units: at most 765
|
|
11
|
+
* bytes of UTF-8, under the 1 KiB below which a journal never cuts a string
|
|
12
|
+
* to fit (`sync/fit.ts`), so a kept origin reads back exactly as it was sent.
|
|
13
|
+
* The line the model reads clips a name further, to 200 characters.
|
|
14
|
+
*/
|
|
15
|
+
export const ORIGIN_FIELD_MAX = 255;
|
|
16
|
+
const field = z.string().min(1).max(ORIGIN_FIELD_MAX);
|
|
17
|
+
export const OriginSchema = z.discriminatedUnion("kind", [
|
|
18
|
+
z.object({ kind: z.literal("person") }),
|
|
19
|
+
/** Another session; `name` is how the host's tools name it (`deus/voyager:2`). */
|
|
20
|
+
z.object({ kind: z.literal("session"), sessionId: field, name: field.optional() }),
|
|
21
|
+
/** An outside assistant the person connected. */
|
|
22
|
+
z.object({ kind: z.literal("assistant"), id: field, name: field }),
|
|
23
|
+
]);
|
|
24
|
+
const KNOWN_ORIGIN_KINDS = ["person", "session", "assistant"];
|
|
25
|
+
/**
|
|
26
|
+
* An origin as the stream reports it (the user message's `origin`): one this
|
|
27
|
+
* build knows, or a newer engine's kind, kept intact rather than refused.
|
|
28
|
+
*/
|
|
29
|
+
export const ReportedOriginSchema = z.union([
|
|
30
|
+
OriginSchema,
|
|
31
|
+
// A kind this build does not know, kept whole; a known kind must be well formed.
|
|
32
|
+
z
|
|
33
|
+
.looseObject({ kind: z.string().min(1).regex(/\S/, "must not be blank") })
|
|
34
|
+
.refine((origin) => !KNOWN_ORIGIN_KINDS.includes(origin.kind), "a malformed known origin"),
|
|
35
|
+
]);
|
|
36
|
+
/** The origin as the engine carries it: undefined for the person, whose messages carry none. */
|
|
37
|
+
export function agentOrigin(origin) {
|
|
38
|
+
return origin && origin.kind !== "person" ? origin : undefined;
|
|
39
|
+
}
|
package/dist/protocol/reduce.js
CHANGED
|
@@ -61,6 +61,8 @@ function openMessage(state, init, record) {
|
|
|
61
61
|
// depth alongside the producer gate: a hand-built or replayed
|
|
62
62
|
// `message.started{role:"user", model}` does not leak into the fold.
|
|
63
63
|
...(init.role === "assistant" && init.model !== undefined && { model: init.model }),
|
|
64
|
+
// Who sent a user message, when not the person; never on the agent's own.
|
|
65
|
+
...(init.role === "user" && init.origin !== undefined && { origin: init.origin }),
|
|
64
66
|
parts: [],
|
|
65
67
|
startedAt: init.timestamp,
|
|
66
68
|
};
|
package/dist/protocol/wire.js
CHANGED
|
@@ -3,6 +3,7 @@ import { RunConfigSchema } from "./config.js";
|
|
|
3
3
|
import { AgentCapabilitiesSchema, AgentHarnessSchema } from "./harness.js";
|
|
4
4
|
import { ElicitationOutcomeSchema, LifecycleEventSchema, PermissionOutcomeSchema, TurnEndedEventSchema, decodeLifecycleEvent, } from "./lifecycle.js";
|
|
5
5
|
import { ModelListSchema } from "./models.js";
|
|
6
|
+
import { OriginSchema } from "./origin.js";
|
|
6
7
|
import { AgentInputSchema } from "./part-input.js";
|
|
7
8
|
/**
|
|
8
9
|
* The standard wire: JSON-RPC 2.0 over a newline-delimited JSON
|
|
@@ -34,6 +35,16 @@ import { AgentInputSchema } from "./part-input.js";
|
|
|
34
35
|
* `session/unsubscribeAll`, each with its own answer, not `{all: true}`.
|
|
35
36
|
*/
|
|
36
37
|
export const WIRE_PROTOCOL_VERSION = 6;
|
|
38
|
+
/**
|
|
39
|
+
* What a server takes beyond its protocol version, named in `initialize`'s
|
|
40
|
+
* `features`. A field a server's schema does not know is stripped, not
|
|
41
|
+
* refused, so a client asks before it sends one whose loss would change
|
|
42
|
+
* what the agent does.
|
|
43
|
+
* - `origin`: `turn/start` and `turn/steer` carry who sent the input, and the
|
|
44
|
+
* agent is told when it is not the person (LLP 0019). A client sends a
|
|
45
|
+
* non-person origin only to a server that names it.
|
|
46
|
+
*/
|
|
47
|
+
export const WIRE_FEATURES = { origin: "origin" };
|
|
37
48
|
// ---- JSON-RPC 2.0 envelopes --------------------------------------------------
|
|
38
49
|
export const JsonRpcIdSchema = z.union([z.string(), z.number()]);
|
|
39
50
|
export const JsonRpcErrorSchema = z.object({
|
|
@@ -183,6 +194,8 @@ export const InitializeResultSchema = z.object({
|
|
|
183
194
|
historyId: z.string().optional(),
|
|
184
195
|
/** Capabilities per registered harness — only available harnesses appear. */
|
|
185
196
|
harnesses: z.record(z.string(), AgentCapabilitiesSchema),
|
|
197
|
+
/** What it takes beyond the protocol version (`WIRE_FEATURES`); absent on older servers. */
|
|
198
|
+
features: z.array(z.string()).optional(),
|
|
186
199
|
});
|
|
187
200
|
/**
|
|
188
201
|
* `turn/start` params are a RunRequest whose ids may be omitted — the server
|
|
@@ -195,6 +208,8 @@ export const TurnStartParamsSchema = z.object({
|
|
|
195
208
|
turnId: z.string().min(1).optional(),
|
|
196
209
|
input: AgentInputSchema,
|
|
197
210
|
config: RunConfigSchema,
|
|
211
|
+
/** Who sent the input; absent is the person. The agent is told when it is not (LLP 0019). */
|
|
212
|
+
origin: OriginSchema.optional(),
|
|
198
213
|
/**
|
|
199
214
|
* Stream the session to the caller from the head at admission until the
|
|
200
215
|
* turn ends, as `session/subscribe {sessionId, turnId}` does. Default true;
|
|
@@ -261,6 +276,8 @@ export const TurnSteerParamsSchema = z.object({
|
|
|
261
276
|
turnId: z.string().min(1),
|
|
262
277
|
steerId: z.string().min(1).optional(),
|
|
263
278
|
input: AgentInputSchema.refine((input) => (typeof input === "string" ? input.trim() !== "" : input.length > 0), "a steer carries input"),
|
|
279
|
+
/** Who sent the input; absent is the person. Part of the steer's identity, as its input is. */
|
|
280
|
+
origin: OriginSchema.optional(),
|
|
264
281
|
});
|
|
265
282
|
/**
|
|
266
283
|
* What a steer did, as one outcome:
|
package/dist/server/bin.js
CHANGED
|
@@ -21,7 +21,8 @@ import { readFileSync, statSync } from "node:fs";
|
|
|
21
21
|
import { homedir } from "node:os";
|
|
22
22
|
import { join } from "node:path";
|
|
23
23
|
import pkg from "../../package.json" with { type: "json" };
|
|
24
|
-
import { createAgentRuntime, credentialsFromUrl, isInheritConfig, resolveAcpLaunch, resolveHarnessName, scriptedFile, } from "../core/index.js";
|
|
24
|
+
import { CLI_TOOLS, createAgentRuntime, credentialsFromUrl, isInheritConfig, resolveAcpLaunch, resolveHarnessName, scriptedFile, } from "../core/index.js";
|
|
25
|
+
import { CLI_TOOL_SPECS } from "../core/provision/tools.js";
|
|
25
26
|
import { THINKING_LEVELS } from "../protocol/index.js";
|
|
26
27
|
import { AgentServer } from "./agent-server.js";
|
|
27
28
|
import { runFeedbackCommand } from "./feedback.js";
|
|
@@ -62,7 +63,7 @@ function usage(exitCode) {
|
|
|
62
63
|
" --dial <ws-url> dial out to a consumer (auto-reconnect); its credential:",
|
|
63
64
|
" $AGENT_SERVER_DIAL_TOKEN, never argv or the URL",
|
|
64
65
|
" --harness <a,b> restrict harnesses (default: all installed)",
|
|
65
|
-
" --acp-agent <spec> ACP agent: known name (pi|gemini) or launch command",
|
|
66
|
+
" --acp-agent <spec> ACP agent: known name (pi|gemini-cli) or launch command",
|
|
66
67
|
" --script <file> the scripted harness plays this JSONL script, one step a",
|
|
67
68
|
" line (its only harness unless --harness names others);",
|
|
68
69
|
" one turn plays at a time, from the start at each start",
|
|
@@ -82,7 +83,7 @@ function usage(exitCode) {
|
|
|
82
83
|
"env: AGENT_SERVER_TOKEN (the listener's token, if no --token-file),",
|
|
83
84
|
" AGENT_SERVER_DIAL_TOKEN (what --dial presents: Authorization: Bearer),",
|
|
84
85
|
" AGENT_SERVER_CREDENTIALS_TOKEN (what --credentials-url presents),",
|
|
85
|
-
|
|
86
|
+
` ${CLI_TOOLS.map((tool) => CLI_TOOL_SPECS[tool].overrideEnv).join(" / ")} (explicit binaries),`,
|
|
86
87
|
" AGENT_SERVER_PROVISION, AGENT_SERVER_CACHE_DIR, AGENT_SERVER_NPM_REGISTRY,",
|
|
87
88
|
" AGENT_SERVER_BUNDLE_DIR (folders `install --dir` staged, a path list),",
|
|
88
89
|
" AGENT_SERVER_ACP_SESSION_DIR (--acp: where resumable session ids are kept)",
|
|
@@ -168,7 +169,7 @@ function parseArgs(argv) {
|
|
|
168
169
|
else if (arg === "--acp-agent") {
|
|
169
170
|
const spec = inline ?? argv[++i];
|
|
170
171
|
if (spec === undefined || !spec.trim() || spec.startsWith("-"))
|
|
171
|
-
fail("--acp-agent needs a known agent name (pi, gemini) or a launch command");
|
|
172
|
+
fail("--acp-agent needs a known agent name (pi, gemini-cli) or a launch command");
|
|
172
173
|
args.acpAgent = spec;
|
|
173
174
|
}
|
|
174
175
|
else if (arg === "--script") {
|
|
@@ -331,7 +332,7 @@ const named = args.harnesses?.map((h) => {
|
|
|
331
332
|
const choice = resolveHarnessName(h);
|
|
332
333
|
if (!choice)
|
|
333
334
|
fail(`unknown harness: ${h}`);
|
|
334
|
-
// Friendly ACP agent names ("pi", "gemini") ride the acp harness.
|
|
335
|
+
// Friendly ACP agent names ("pi", "gemini-cli") ride the acp harness.
|
|
335
336
|
if (choice.acpAgent)
|
|
336
337
|
args.acpAgent ??= choice.acpAgent;
|
|
337
338
|
return choice.harness;
|
|
@@ -347,10 +348,24 @@ if (args.command !== "install" && named?.includes("scripted") && args.script ===
|
|
|
347
348
|
fail("the scripted harness needs a script: --script <file>");
|
|
348
349
|
const harnesses = named ?? (args.script !== undefined ? ["scripted"] : undefined);
|
|
349
350
|
const provision = args.provisionMode ? { mode: args.provisionMode } : {};
|
|
350
|
-
|
|
351
|
+
// The ACP agent setting is read only where the acp harness runs: named, or,
|
|
352
|
+
// with no --harness, turned on by the setting itself. A stale
|
|
353
|
+
// `$AGENT_SERVER_ACP_AGENT` stops no other harness, nor `install`.
|
|
354
|
+
const acpSpec = args.acpAgent ?? process.env.AGENT_SERVER_ACP_AGENT;
|
|
355
|
+
const acpInUse = args.command !== "install" && (harnesses ? harnesses.includes("acp") : !!acpSpec);
|
|
356
|
+
const acpLaunch = (() => {
|
|
357
|
+
if (!acpInUse)
|
|
358
|
+
return undefined;
|
|
359
|
+
try {
|
|
360
|
+
return resolveAcpLaunch(acpSpec);
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
return fail(error.message);
|
|
364
|
+
}
|
|
365
|
+
})();
|
|
351
366
|
// `install` runs no agent: an acp harness there has nothing to install, and says so.
|
|
352
367
|
if (args.command !== "install" && harnesses?.includes("acp") && !acpLaunch)
|
|
353
|
-
fail('the acp harness needs an agent: --harness pi|gemini or --acp-agent "<spec>"');
|
|
368
|
+
fail('the acp harness needs an agent: --harness pi|gemini-cli or --acp-agent "<spec>"');
|
|
354
369
|
if (args.command === "install") {
|
|
355
370
|
// A harness the engine installs nothing for is said, not passed over in silence.
|
|
356
371
|
for (const [i, harness] of (harnesses ?? []).entries())
|
package/dist/server/install.js
CHANGED
|
@@ -44,14 +44,16 @@ function claudeCodeVersion(version) {
|
|
|
44
44
|
/**
|
|
45
45
|
* The line `install` prints for a CLI it installed, saying what its version
|
|
46
46
|
* is: Claude's is the Claude SDK package's (`0.3.288`), which carries a
|
|
47
|
-
* Claude Code of its own number (`2.1.288`), the one `claude --version` says
|
|
47
|
+
* Claude Code of its own number (`2.1.288`), the one `claude --version` says;
|
|
48
|
+
* every other tool's is its CLI's own.
|
|
48
49
|
*/
|
|
49
50
|
export function installedLine({ tool, platform, cli }) {
|
|
50
51
|
const where = `for ${platform} ready: ${cli.path} (${cli.source})`;
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
const { title } = CLI_TOOL_SPECS[tool];
|
|
53
|
+
if (tool !== "claude")
|
|
54
|
+
return `${tool}: ${title} ${cli.version ?? "(version not known)"} ${where}`;
|
|
53
55
|
if (!cli.version)
|
|
54
|
-
return `claude:
|
|
56
|
+
return `claude: ${title} (version not known) ${where}`;
|
|
55
57
|
const code = claudeCodeVersion(cli.version);
|
|
56
58
|
return `claude: Claude SDK package ${cli.version}${code ? ` (Claude Code ${code})` : ""} ${where}`;
|
|
57
59
|
}
|
package/dist/server/routes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WIRE_METHODS, WIRE_PROTOCOL_VERSION, WireRefusal, generateUUIDv7, } from "../protocol/index.js";
|
|
1
|
+
import { WIRE_FEATURES, WIRE_METHODS, WIRE_PROTOCOL_VERSION, WireRefusal, generateUUIDv7, } from "../protocol/index.js";
|
|
2
2
|
function assertHarness(runtime, harness) {
|
|
3
3
|
if (!runtime.harnesses.includes(harness))
|
|
4
4
|
throw new WireRefusal("harnessNotAvailable", `harness not available: ${harness}`, {
|
|
@@ -70,12 +70,17 @@ export function executionRoutes(host) {
|
|
|
70
70
|
const harnesses = {};
|
|
71
71
|
for (const harness of runtime.harnesses)
|
|
72
72
|
harnesses[harness] = runtime.capabilities(harness);
|
|
73
|
-
return {
|
|
73
|
+
return {
|
|
74
|
+
protocolVersion: WIRE_PROTOCOL_VERSION,
|
|
75
|
+
...host.identity,
|
|
76
|
+
harnesses,
|
|
77
|
+
features: Object.values(WIRE_FEATURES),
|
|
78
|
+
};
|
|
74
79
|
},
|
|
75
80
|
[WIRE_METHODS.turnStart]: (parsed, context) => {
|
|
76
81
|
if (!host.accepting())
|
|
77
82
|
throw new WireRefusal("shuttingDown", "server is shutting down");
|
|
78
|
-
const { config, input } = parsed;
|
|
83
|
+
const { config, input, origin } = parsed;
|
|
79
84
|
assertHarness(runtime, config.harness);
|
|
80
85
|
const sessionId = parsed.sessionId ?? generateUUIDv7();
|
|
81
86
|
const turnId = parsed.turnId ?? generateUUIDv7();
|
|
@@ -91,7 +96,7 @@ export function executionRoutes(host) {
|
|
|
91
96
|
// caller to the turn while it runs. A durable store remembers every
|
|
92
97
|
// turn it admitted, the runtime only its recent ones. The same turnId
|
|
93
98
|
// with different input is a caller bug → turnConflict.
|
|
94
|
-
const request = { sessionId, turnId, input, config };
|
|
99
|
+
const request = { sessionId, turnId, input, config, ...(origin && { origin }) };
|
|
95
100
|
const duplicate = store.duplicateOf(request) ?? converged(request);
|
|
96
101
|
if (duplicate) {
|
|
97
102
|
const headSeq = store.point(sessionId)?.headSeq;
|
|
@@ -144,7 +149,12 @@ export function executionRoutes(host) {
|
|
|
144
149
|
};
|
|
145
150
|
},
|
|
146
151
|
// @ref LLP 0001#d13--input-while-a-turn-runs-steers-it — the runtime decides
|
|
147
|
-
[WIRE_METHODS.turnSteer]: ({ sessionId, turnId, steerId, input }) => runtime.steer(sessionId, {
|
|
152
|
+
[WIRE_METHODS.turnSteer]: ({ sessionId, turnId, steerId, input, origin }) => runtime.steer(sessionId, {
|
|
153
|
+
turnId,
|
|
154
|
+
steerId: steerId ?? generateUUIDv7(),
|
|
155
|
+
input,
|
|
156
|
+
...(origin && { origin }),
|
|
157
|
+
}),
|
|
148
158
|
[WIRE_METHODS.sessionClose]: async ({ sessionId }) => {
|
|
149
159
|
gate.assertIdle(sessionId);
|
|
150
160
|
const harness = store.closing(sessionId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,KAAK,WAAW,EAEhB,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,kBAAkB,EAEvB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAA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AO,CAAC,SAAS;IAMjB,+FAA+F;IAC/F,OAAO,CAAC,WAAW;IAOnB,qFAAqF;IACrF,OAAO,CAAC,cAAc;IAMtB;;;;OAIG;YACW,UAAU;IAYxB,6FAA6F;IAC7F,OAAO,CAAC,WAAW;CAMnB"}
|
|
@@ -169,6 +169,10 @@ export declare class Connection {
|
|
|
169
169
|
/** The server process (or, durable, the journal) whose logs the client follows. */
|
|
170
170
|
private serverIdentity;
|
|
171
171
|
private initializing;
|
|
172
|
+
/** The current transport's handshake, once answered; cleared when it is asked again. */
|
|
173
|
+
private negotiated;
|
|
174
|
+
/** The transport `negotiated` was answered on: a feature check holds only for it. */
|
|
175
|
+
private negotiatedOn;
|
|
172
176
|
private reconnecting;
|
|
173
177
|
/** Ends the redial backoff early: `close()` must not wait it out. */
|
|
174
178
|
private stopBackoff;
|
|
@@ -186,7 +190,9 @@ export declare class Connection {
|
|
|
186
190
|
/** The server speaks another protocol version: the client is closed by its refusal, which this returns. */
|
|
187
191
|
private mismatched;
|
|
188
192
|
/** A request, its answer read as `WIRE_API` reads the method's. */
|
|
189
|
-
request<M extends WireRequestMethod>(method: M, params: WireParams<M>, onAnswer?: OnAnswer<WireDecodedResult<M
|
|
193
|
+
request<M extends WireRequestMethod>(method: M, params: WireParams<M>, onAnswer?: OnAnswer<WireDecodedResult<M>>,
|
|
194
|
+
/** Asked with the handshake of the very transport the request goes on; throw to send nothing. */
|
|
195
|
+
admit?: (server: InitializeResult) => void): Promise<WireDecodedResult<M>>;
|
|
190
196
|
/**
|
|
191
197
|
* A request the server converges on when repeated (`turn/start`,
|
|
192
198
|
* `turn/steer`), re-sent over a redialed connection: a start whose ack was
|
|
@@ -196,7 +202,13 @@ export declare class Connection {
|
|
|
196
202
|
* re-sends at most: a server that accepts connections but never answers
|
|
197
203
|
* would otherwise be retried forever.
|
|
198
204
|
*/
|
|
199
|
-
resend<M extends WireRequestMethod>(method: M, params: WireParams<M>, onAnswer?: OnAnswer<WireDecodedResult<M
|
|
205
|
+
resend<M extends WireRequestMethod>(method: M, params: WireParams<M>, onAnswer?: OnAnswer<WireDecodedResult<M>>,
|
|
206
|
+
/**
|
|
207
|
+
* Asked with the server this attempt goes to, before each send, re-sends
|
|
208
|
+
* included: a redial may reach another build of the server. Throw to send
|
|
209
|
+
* nothing (LLP 0019: an origin that server would strip).
|
|
210
|
+
*/
|
|
211
|
+
admit?: (server: InitializeResult) => void): Promise<WireDecodedResult<M>>;
|
|
200
212
|
close(): void;
|
|
201
213
|
private dropped;
|
|
202
214
|
private redial;
|