@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
|
@@ -5,7 +5,8 @@ import type { CliReleases } from "./checksums.ts";
|
|
|
5
5
|
/**
|
|
6
6
|
* The pinned CLIs' builds, by platform: each npm tarball's integrity, and for
|
|
7
7
|
* Claude the binary's sha256 from Anthropic's signed release manifest (its
|
|
8
|
-
* signature verified when this file was generated)
|
|
8
|
+
* signature verified when this file was generated); for agy each build's
|
|
9
|
+
* address and the sha512 Google's unsigned update manifest named for it.
|
|
9
10
|
*/
|
|
10
11
|
export const CLI_RELEASES: CliReleases = {
|
|
11
12
|
claude: {
|
|
@@ -83,4 +84,49 @@ export const CLI_RELEASES: CliReleases = {
|
|
|
83
84
|
},
|
|
84
85
|
},
|
|
85
86
|
},
|
|
87
|
+
agy: {
|
|
88
|
+
version: "1.5.14",
|
|
89
|
+
builds: {
|
|
90
|
+
"darwin-arm64": {
|
|
91
|
+
integrity:
|
|
92
|
+
"sha512-JoMP1Gv7kgDQc88+cb+UtwdVJVe0OA7AGv1umfOisDDmVCLasYZ/dzGAeGkt78hZp1R9F+xLCx6TafE8nDyupg==",
|
|
93
|
+
url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/darwin-arm/cli_mac_arm64.tar.gz",
|
|
94
|
+
},
|
|
95
|
+
"darwin-x64": {
|
|
96
|
+
integrity:
|
|
97
|
+
"sha512-G2ofxtvka6bZ0EBdG2CVGJ816/xMPDPOsf0bbQyf1wK1KsELZLi1Ku0NjXGuAsXfPP/V4+PTdUnC2v/M4qhTxw==",
|
|
98
|
+
url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/darwin-x64/cli_mac_x64.tar.gz",
|
|
99
|
+
},
|
|
100
|
+
"linux-arm64": {
|
|
101
|
+
integrity:
|
|
102
|
+
"sha512-ybKbukdfY6GoAWGuk7pysiHHpYbZhR5NAGFUZwS6tm1rJ2CyXXFtGRck/HVk8yRkVu4VHiiqN69I281yvcbEYw==",
|
|
103
|
+
url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/linux-arm/cli_linux_arm64.tar.gz",
|
|
104
|
+
},
|
|
105
|
+
"linux-x64": {
|
|
106
|
+
integrity:
|
|
107
|
+
"sha512-gzEdPzVFZ2EtwWwa4uqbUD1vaDOqThONOaoinaPzu5mw5NfMoLzkeWsAYNalHYET63RJ7V3A55AL8hcQfqW/+Q==",
|
|
108
|
+
url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/linux-x64/cli_linux_x64.tar.gz",
|
|
109
|
+
},
|
|
110
|
+
"linux-arm64-musl": {
|
|
111
|
+
integrity:
|
|
112
|
+
"sha512-9uNfw9qyzUn9Qpbd7ghBucxMcCC2xqrqZFLFs0UrCtjWZFHJCY5Bitay9uq8yBzfExBe0EOQMkixHW+ySucJqw==",
|
|
113
|
+
url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/linux-arm-musl/cli_linux_arm64_musl.tar.gz",
|
|
114
|
+
},
|
|
115
|
+
"linux-x64-musl": {
|
|
116
|
+
integrity:
|
|
117
|
+
"sha512-HaJJInJ8W06ENp0IQ1ddfW8YChlG4txCiRca0ePKkllOaHck0ZAqfYPkB/mPCo07fD6XbwNoD9gNvtLS2gDA7Q==",
|
|
118
|
+
url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/linux-x64-musl/cli_linux_x64_musl.tar.gz",
|
|
119
|
+
},
|
|
120
|
+
"win32-arm64": {
|
|
121
|
+
integrity:
|
|
122
|
+
"sha512-ss5UYs8YRbJcBcplG1vZNzX9gH+Oe0DGHQ6ZRF3xp2uX7iTIkNX1ugRT+EjKF0901JKtGQGi3cul16m0OZ3f7w==",
|
|
123
|
+
url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/windows-arm/cli_windows_arm64.exe",
|
|
124
|
+
},
|
|
125
|
+
"win32-x64": {
|
|
126
|
+
integrity:
|
|
127
|
+
"sha512-eFVIsjJC7JESdZu0tSXZSj1NLpho5c7bnqNOXOAduwCr9d5mxB2PSQPopDeURfaFSD+Zns6Rhnv72dSBJ2DYNQ==",
|
|
128
|
+
url: "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/windows-x64/cli_windows_x64.exe",
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
86
132
|
};
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from "node:fs";
|
|
9
9
|
import { readdir } from "node:fs/promises";
|
|
10
10
|
import { createRequire } from "node:module";
|
|
11
|
+
import { homedir } from "node:os";
|
|
11
12
|
import { dirname, join, resolve } from "node:path";
|
|
12
13
|
import { pathToFileURL } from "node:url";
|
|
13
14
|
import type { AgentHarness } from "../../protocol/index.ts";
|
|
@@ -22,12 +23,13 @@ import {
|
|
|
22
23
|
} from "./platform.ts";
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
|
-
* The managed CLIs. Each native harness maps onto exactly one of these
|
|
26
|
+
* The managed CLIs. Each native harness maps onto exactly one of these, and
|
|
27
|
+
* so does `gemini`, a profile on the ACP agent that runs Google's `agy`; the
|
|
26
28
|
* `acp` harness maps onto none (its agent binaries are arbitrary third-party
|
|
27
29
|
* commands the operator supplies, not something we pin or download), nor does
|
|
28
30
|
* `scripted`, which runs no process.
|
|
29
31
|
*/
|
|
30
|
-
export const CLI_TOOLS = ["claude", "codex"] as const;
|
|
32
|
+
export const CLI_TOOLS = ["claude", "codex", "agy"] as const;
|
|
31
33
|
export type CliTool = (typeof CLI_TOOLS)[number];
|
|
32
34
|
|
|
33
35
|
/**
|
|
@@ -38,6 +40,7 @@ export type CliTool = (typeof CLI_TOOLS)[number];
|
|
|
38
40
|
const TOOL_FOR_HARNESS: Record<AgentHarness, CliTool | undefined> = {
|
|
39
41
|
"claude-code": "claude",
|
|
40
42
|
"codex-app-server": "codex",
|
|
43
|
+
gemini: "agy",
|
|
41
44
|
acp: undefined,
|
|
42
45
|
scripted: undefined,
|
|
43
46
|
};
|
|
@@ -46,7 +49,7 @@ export function toolForHarness(harness: AgentHarness): CliTool | undefined {
|
|
|
46
49
|
return TOOL_FOR_HARNESS[harness];
|
|
47
50
|
}
|
|
48
51
|
|
|
49
|
-
/** What to download for one tool on one platform. */
|
|
52
|
+
/** What to download from npm for one tool on one platform. */
|
|
50
53
|
export interface ToolPackage {
|
|
51
54
|
name: string;
|
|
52
55
|
/** Exact version string the registry knows (codex encodes the platform here). */
|
|
@@ -55,6 +58,35 @@ export interface ToolPackage {
|
|
|
55
58
|
suffix: string;
|
|
56
59
|
}
|
|
57
60
|
|
|
61
|
+
/** A tool published as npm packages: the registry's metadata names each tarball and its integrity. */
|
|
62
|
+
export interface NpmSource {
|
|
63
|
+
readonly kind: "npm";
|
|
64
|
+
/** The registry package carrying this platform's build of `version`. */
|
|
65
|
+
package(platform: PlatformInfo, version: string): ToolPackage;
|
|
66
|
+
/** The directory of an extracted tarball that becomes the install. */
|
|
67
|
+
payload(extractedRoot: string): Promise<string>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// @ref LLP 0010#source-kinds — a `url` build is the table's: nothing at run time can vouch for another
|
|
71
|
+
/**
|
|
72
|
+
* A tool published as files at addresses its vendor names: only this
|
|
73
|
+
* release's table says where each build is and what it must match
|
|
74
|
+
* (`CliBuild.url`), so a version the table does not hold is not downloaded.
|
|
75
|
+
* Its cache folders are named by the platform (`platformName`).
|
|
76
|
+
*/
|
|
77
|
+
export interface UrlSource {
|
|
78
|
+
readonly kind: "url";
|
|
79
|
+
/**
|
|
80
|
+
* This platform's executable: its name in the install (one of
|
|
81
|
+
* `binaries`), and its name in the gzipped tarball the download is; no
|
|
82
|
+
* `member`, the download is the executable itself.
|
|
83
|
+
*/
|
|
84
|
+
executable(platform: PlatformInfo): { readonly binary: string; readonly member?: string };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Where a tool's builds come from. */
|
|
88
|
+
export type CliSource = NpmSource | UrlSource;
|
|
89
|
+
|
|
58
90
|
/** Where a host install is looked for. */
|
|
59
91
|
export interface HostMachine {
|
|
60
92
|
platform: PlatformInfo;
|
|
@@ -68,14 +100,16 @@ export interface HostMachine {
|
|
|
68
100
|
|
|
69
101
|
/** What the provisioner knows of one managed CLI. */
|
|
70
102
|
export interface CliToolSpec {
|
|
103
|
+
/** What people call it: `install` says it (`Codex CLI 0.169.1`). */
|
|
104
|
+
readonly title: string;
|
|
71
105
|
/** The variable an operator points at the binary to run instead (never the wire's). */
|
|
72
106
|
readonly overrideEnv: string;
|
|
73
107
|
/** Where the binary sits in an installed tree; the first regular file wins. */
|
|
74
108
|
readonly binaries: readonly string[];
|
|
75
109
|
/** The platforms the vendor publishes a build for, as the cache names them. */
|
|
76
110
|
readonly platforms: readonly string[];
|
|
77
|
-
/**
|
|
78
|
-
|
|
111
|
+
/** Where its builds come from, and how one becomes the install. */
|
|
112
|
+
readonly source: CliSource;
|
|
79
113
|
/** The version to download when no pin is set. */
|
|
80
114
|
defaultVersion(): string;
|
|
81
115
|
/** Why the default may not be the build that runs, when this machine cannot tell (said once). */
|
|
@@ -88,8 +122,6 @@ export interface CliToolSpec {
|
|
|
88
122
|
* SDK's manifest names its own CLI's sha256.
|
|
89
123
|
*/
|
|
90
124
|
localBuild?(suffix: string, version: string): LocalBuild | undefined;
|
|
91
|
-
/** The directory of an extracted tarball that becomes the install. */
|
|
92
|
-
payload(extractedRoot: string): Promise<string>;
|
|
93
125
|
/**
|
|
94
126
|
* What `system` mode fails with when the host has none; absent, the
|
|
95
127
|
* harness's own resolution speaks (the Claude SDK finds its sibling
|
|
@@ -228,6 +260,7 @@ const CODEX_BINARIES = [join("bin", "codex"), join("bin", "codex.exe")];
|
|
|
228
260
|
*/
|
|
229
261
|
export const CLI_TOOL_SPECS: Record<CliTool, CliToolSpec> = {
|
|
230
262
|
claude: {
|
|
263
|
+
title: "Claude Code",
|
|
231
264
|
overrideEnv: "CLAUDE_CLI_PATH",
|
|
232
265
|
binaries: ["claude", "claude.exe"],
|
|
233
266
|
platforms: [
|
|
@@ -240,10 +273,22 @@ export const CLI_TOOL_SPECS: Record<CliTool, CliToolSpec> = {
|
|
|
240
273
|
"win32-arm64",
|
|
241
274
|
"win32-x64",
|
|
242
275
|
],
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
276
|
+
source: {
|
|
277
|
+
kind: "npm",
|
|
278
|
+
// The platform packages carry the native CLI matched to the SDK JS.
|
|
279
|
+
package: (platform, version) => {
|
|
280
|
+
const suffix = claudePackageSuffix(platform);
|
|
281
|
+
return {
|
|
282
|
+
name: `@anthropic-ai/claude-agent-sdk-${suffix}`,
|
|
283
|
+
registryVersion: version,
|
|
284
|
+
suffix,
|
|
285
|
+
};
|
|
286
|
+
},
|
|
287
|
+
payload: async (extractedRoot) => {
|
|
288
|
+
const dir = join(extractedRoot, "package");
|
|
289
|
+
if (existsSync(dir)) return dir;
|
|
290
|
+
throw new CliProvisionError("claude tarball has no package/ directory");
|
|
291
|
+
},
|
|
247
292
|
},
|
|
248
293
|
// The on-disk SDK's version (the pair that actually runs) over the
|
|
249
294
|
// release default, which only decides inside compiled binaries. Even
|
|
@@ -277,11 +322,6 @@ export const CLI_TOOL_SPECS: Record<CliTool, CliToolSpec> = {
|
|
|
277
322
|
const path = join(platformDir, claudeManifestBuild(sdk.dir, suffix)?.binary ?? "claude");
|
|
278
323
|
return existsSync(path) ? { path, version: sdk.version } : undefined;
|
|
279
324
|
},
|
|
280
|
-
payload: async (extractedRoot) => {
|
|
281
|
-
const dir = join(extractedRoot, "package");
|
|
282
|
-
if (existsSync(dir)) return dir;
|
|
283
|
-
throw new CliProvisionError("claude tarball has no package/ directory");
|
|
284
|
-
},
|
|
285
325
|
// The SDK on disk names its own CLI's checksum, for a version this
|
|
286
326
|
// release did not pin (a consumer's lockfile moved the SDK).
|
|
287
327
|
localBuild: (suffix, version) => {
|
|
@@ -292,6 +332,7 @@ export const CLI_TOOL_SPECS: Record<CliTool, CliToolSpec> = {
|
|
|
292
332
|
},
|
|
293
333
|
},
|
|
294
334
|
codex: {
|
|
335
|
+
title: "Codex CLI",
|
|
295
336
|
overrideEnv: "CODEX_CLI_PATH",
|
|
296
337
|
binaries: CODEX_BINARIES,
|
|
297
338
|
// Its linux builds are static, so there is no musl variant.
|
|
@@ -303,10 +344,24 @@ export const CLI_TOOL_SPECS: Record<CliTool, CliToolSpec> = {
|
|
|
303
344
|
"win32-arm64",
|
|
304
345
|
"win32-x64",
|
|
305
346
|
],
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
347
|
+
source: {
|
|
348
|
+
kind: "npm",
|
|
349
|
+
// Codex publishes its platform builds as version suffixes of one package.
|
|
350
|
+
package: (platform, version) => {
|
|
351
|
+
const suffix = codexPackageSuffix(platform);
|
|
352
|
+
return { name: "@openai/codex", registryVersion: `${version}-${suffix}`, suffix };
|
|
353
|
+
},
|
|
354
|
+
// Codex vendors per-target trees: package/vendor/<rust-triple>/bin/codex.
|
|
355
|
+
// Install the whole tree — the CLI expects its vendored rg/zsh siblings.
|
|
356
|
+
payload: async (extractedRoot) => {
|
|
357
|
+
const vendor = join(extractedRoot, "package", "vendor");
|
|
358
|
+
const entries = existsSync(vendor) ? await readdir(vendor) : [];
|
|
359
|
+
for (const entry of entries) {
|
|
360
|
+
const dir = join(vendor, entry);
|
|
361
|
+
if (binaryIn(dir, CODEX_BINARIES)) return dir;
|
|
362
|
+
}
|
|
363
|
+
throw new CliProvisionError("codex tarball has no vendor/<target>/bin/codex");
|
|
364
|
+
},
|
|
310
365
|
},
|
|
311
366
|
defaultVersion: () => DEFAULT_PINS.codex,
|
|
312
367
|
// @ref LLP 0001#d18--the-engine-installs-the-clis-it-runs-pinned-builds-checked-before-a-turn — a lockfile's build, or in `system` the operator's PATH
|
|
@@ -333,17 +388,6 @@ export const CLI_TOOL_SPECS: Record<CliTool, CliToolSpec> = {
|
|
|
333
388
|
const path = searchPath ? findOnPath("codex", env, platform.platform) : undefined;
|
|
334
389
|
return path ? { path } : undefined;
|
|
335
390
|
},
|
|
336
|
-
// Codex vendors per-target trees: package/vendor/<rust-triple>/bin/codex.
|
|
337
|
-
// Install the whole tree — the CLI expects its vendored rg/zsh siblings.
|
|
338
|
-
payload: async (extractedRoot) => {
|
|
339
|
-
const vendor = join(extractedRoot, "package", "vendor");
|
|
340
|
-
const entries = existsSync(vendor) ? await readdir(vendor) : [];
|
|
341
|
-
for (const entry of entries) {
|
|
342
|
-
const dir = join(vendor, entry);
|
|
343
|
-
if (binaryIn(dir, CODEX_BINARIES)) return dir;
|
|
344
|
-
}
|
|
345
|
-
throw new CliProvisionError("codex tarball has no vendor/<target>/bin/codex");
|
|
346
|
-
},
|
|
347
391
|
// A bare spawn would just ENOENT.
|
|
348
392
|
notOnHost: () =>
|
|
349
393
|
new CliNotFoundError(
|
|
@@ -351,4 +395,53 @@ export const CLI_TOOL_SPECS: Record<CliTool, CliToolSpec> = {
|
|
|
351
395
|
'install it, set $CODEX_CLI_PATH, or use provision mode "auto"',
|
|
352
396
|
),
|
|
353
397
|
},
|
|
398
|
+
// Google's Antigravity CLI, for the gemini harness.
|
|
399
|
+
agy: {
|
|
400
|
+
title: "Antigravity CLI",
|
|
401
|
+
overrideEnv: "ANTIGRAVITY_CLI_PATH",
|
|
402
|
+
binaries: ["agy", "agy.exe"],
|
|
403
|
+
platforms: [
|
|
404
|
+
"darwin-arm64",
|
|
405
|
+
"darwin-x64",
|
|
406
|
+
"linux-arm64",
|
|
407
|
+
"linux-x64",
|
|
408
|
+
"linux-arm64-musl",
|
|
409
|
+
"linux-x64-musl",
|
|
410
|
+
"win32-arm64",
|
|
411
|
+
"win32-x64",
|
|
412
|
+
],
|
|
413
|
+
// Google publishes no package: each build is a file its update manifest
|
|
414
|
+
// names, with a sha512 and no signature, recorded at refresh
|
|
415
|
+
// (`scripts/refresh-cli-releases.ts`). The tarball's one member is
|
|
416
|
+
// `antigravity`, which its installer puts in place as `agy`; Windows'
|
|
417
|
+
// build is the executable itself.
|
|
418
|
+
source: {
|
|
419
|
+
kind: "url",
|
|
420
|
+
executable: ({ platform }) =>
|
|
421
|
+
platform === "win32" ? { binary: "agy.exe" } : { binary: "agy", member: "antigravity" },
|
|
422
|
+
},
|
|
423
|
+
defaultVersion: () => DEFAULT_PINS.agy,
|
|
424
|
+
// @ref LLP 0010#source-kinds — the person's own agy updates itself: only `system` runs it
|
|
425
|
+
// Where Google's installers put it (`install.sh`: ~/.local/bin/agy;
|
|
426
|
+
// `install.ps1` and `install.cmd`: %LOCALAPPDATA%\agy\bin\agy.exe),
|
|
427
|
+
// then PATH, in `system` mode only: nobody chose that build for this
|
|
428
|
+
// engine, and it updates itself.
|
|
429
|
+
hostInstall: ({ platform, env, searchPath }) => {
|
|
430
|
+
if (!searchPath) return undefined;
|
|
431
|
+
const windows = platform.platform === "win32";
|
|
432
|
+
const local = windows ? env.LOCALAPPDATA : (env.HOME ?? homedir());
|
|
433
|
+
const installed =
|
|
434
|
+
local &&
|
|
435
|
+
binaryIn(windows ? join(local, "agy", "bin") : join(local, ".local", "bin"), [
|
|
436
|
+
windows ? "agy.exe" : "agy",
|
|
437
|
+
]);
|
|
438
|
+
const path = installed || findOnPath("agy", env, platform.platform);
|
|
439
|
+
return path ? { path } : undefined;
|
|
440
|
+
},
|
|
441
|
+
notOnHost: () =>
|
|
442
|
+
new CliNotFoundError(
|
|
443
|
+
"agy",
|
|
444
|
+
'install Google\'s Antigravity CLI (https://antigravity.google/docs/getting-started), set $ANTIGRAVITY_CLI_PATH, or use provision mode "auto"',
|
|
445
|
+
),
|
|
446
|
+
},
|
|
354
447
|
};
|
|
@@ -10,11 +10,17 @@ import type {
|
|
|
10
10
|
HarnessCliProgress,
|
|
11
11
|
ModelList,
|
|
12
12
|
ModelsListParams,
|
|
13
|
+
Origin,
|
|
13
14
|
PermissionOutcome,
|
|
14
15
|
RunRequest,
|
|
15
16
|
TurnSteerResult,
|
|
16
17
|
} from "../../protocol/index.ts";
|
|
17
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
RunRequestSchema,
|
|
20
|
+
agentOrigin,
|
|
21
|
+
canonicalJson,
|
|
22
|
+
turnIdentity,
|
|
23
|
+
} from "../../protocol/index.ts";
|
|
18
24
|
import type { CancelResult, SteerRequest } from "../agents/base.ts";
|
|
19
25
|
import type { AgentRegistry } from "../agents/registry.ts";
|
|
20
26
|
import type { DiagnosticHandler } from "../diagnostics.ts";
|
|
@@ -26,6 +32,7 @@ import { type EventSink, EventSinkError } from "./event-sink.ts";
|
|
|
26
32
|
import { awaitingInstall, harnessCliProgress, harnessClis } from "./harness-clis.ts";
|
|
27
33
|
import { HarnessLogins } from "./harness-logins.ts";
|
|
28
34
|
import { ModelLists, catalogModelList } from "./model-lists.ts";
|
|
35
|
+
import { withOriginLine } from "./origin-line.ts";
|
|
29
36
|
import { StandingRules } from "./permission-policy.ts";
|
|
30
37
|
import type { RequestAnswers, RequestKind } from "./request-broker.ts";
|
|
31
38
|
import {
|
|
@@ -370,12 +377,19 @@ export class AgentRuntime {
|
|
|
370
377
|
* ended; the same id with other input throws `TurnConflictError`. Input the
|
|
371
378
|
* harness cannot take throws, as it would fail a turn.
|
|
372
379
|
*/
|
|
373
|
-
async steer(
|
|
374
|
-
|
|
380
|
+
async steer(
|
|
381
|
+
sessionId: string,
|
|
382
|
+
request: SteerRequest & { origin?: Origin },
|
|
383
|
+
): Promise<TurnSteerResult> {
|
|
384
|
+
const { turnId, steerId, input, origin: sent } = request;
|
|
375
385
|
if (typeof input === "string" ? input.trim() === "" : input.length === 0) {
|
|
376
386
|
throw new Error("a steer carries input");
|
|
377
387
|
}
|
|
378
|
-
|
|
388
|
+
// Another sender is another steer; the person's origin, said or not, adds nothing.
|
|
389
|
+
// Its own copy, taken at admission: the caller's object may change after.
|
|
390
|
+
const given = agentOrigin(sent);
|
|
391
|
+
const origin = given && { ...given };
|
|
392
|
+
const inputKey = canonicalJson(origin ? { input, origin } : input);
|
|
379
393
|
const turn = this.turns.get(turnKeyOf(sessionId, turnId));
|
|
380
394
|
const known = turn
|
|
381
395
|
? turn.steers.find(steerId)
|
|
@@ -395,9 +409,19 @@ export class AgentRuntime {
|
|
|
395
409
|
const agent = this.registry.getAgent(turn.harness);
|
|
396
410
|
const deliver = agent.capabilities.steering ? agent.steer?.bind(agent) : undefined;
|
|
397
411
|
if (!deliver) return { outcome: "unsupported" };
|
|
398
|
-
// Its echo is the caller's input; the agent is given it well-formed
|
|
399
|
-
|
|
400
|
-
|
|
412
|
+
// Its echo is the caller's input; the agent is given it well-formed, after
|
|
413
|
+
// the sender's line when it is not the person.
|
|
414
|
+
return await turn.steers.accept(
|
|
415
|
+
steerId,
|
|
416
|
+
inputKey,
|
|
417
|
+
input,
|
|
418
|
+
() =>
|
|
419
|
+
deliver(sessionId, {
|
|
420
|
+
turnId,
|
|
421
|
+
steerId,
|
|
422
|
+
input: wellFormedInput(withOriginLine(input, origin)),
|
|
423
|
+
}),
|
|
424
|
+
origin,
|
|
401
425
|
);
|
|
402
426
|
}
|
|
403
427
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
agentOrigin,
|
|
2
3
|
createSteerEchoParts,
|
|
3
4
|
createUserEchoParts,
|
|
4
5
|
echoMessageId,
|
|
@@ -10,6 +11,7 @@ import type {
|
|
|
10
11
|
AgentInput,
|
|
11
12
|
Delta,
|
|
12
13
|
LifecycleEvent,
|
|
14
|
+
Origin,
|
|
13
15
|
Part,
|
|
14
16
|
TurnEndedEvent,
|
|
15
17
|
TurnExecution,
|
|
@@ -129,8 +131,8 @@ export class EventProcessor {
|
|
|
129
131
|
* id (`echoMessageId`), so a consumer that minted the turnId can predict the
|
|
130
132
|
* whole echo instead of reconciling a look-alike against it.
|
|
131
133
|
*/
|
|
132
|
-
*echoUserMessage(input: AgentInput): Generator<LifecycleEvent> {
|
|
133
|
-
yield* this.openMessage("user", undefined, echoMessageId(this.turnId));
|
|
134
|
+
*echoUserMessage(input: AgentInput, origin?: Origin): Generator<LifecycleEvent> {
|
|
135
|
+
yield* this.openMessage("user", undefined, echoMessageId(this.turnId), undefined, origin);
|
|
134
136
|
for (const part of createUserEchoParts(input, this.turnId)) {
|
|
135
137
|
yield* this.emitPart(part);
|
|
136
138
|
}
|
|
@@ -145,10 +147,10 @@ export class EventProcessor {
|
|
|
145
147
|
* already echoed, is ignored.
|
|
146
148
|
*/
|
|
147
149
|
private *echoSteer(steerId: string): Generator<LifecycleEvent> {
|
|
148
|
-
const
|
|
149
|
-
if (
|
|
150
|
-
yield* this.openMessage("user", undefined, steerMessageId(steerId));
|
|
151
|
-
for (const part of createSteerEchoParts(input, steerId)) {
|
|
150
|
+
const steer = this.steers.read(steerId);
|
|
151
|
+
if (steer === undefined) return;
|
|
152
|
+
yield* this.openMessage("user", undefined, steerMessageId(steerId), undefined, steer.origin);
|
|
153
|
+
for (const part of createSteerEchoParts(steer.input, steerId)) {
|
|
152
154
|
yield* this.emitPart(part);
|
|
153
155
|
}
|
|
154
156
|
yield* this.closeMessage();
|
|
@@ -320,6 +322,8 @@ export class EventProcessor {
|
|
|
320
322
|
id?: string,
|
|
321
323
|
/** The model the harness said produced it. */
|
|
322
324
|
model?: string,
|
|
325
|
+
/** A user message's sender, when not the person. */
|
|
326
|
+
origin?: Origin,
|
|
323
327
|
): Generator<LifecycleEvent, string> {
|
|
324
328
|
if (this.openMessageId) yield* this.closeMessage();
|
|
325
329
|
if (role === "assistant") this.answered = true;
|
|
@@ -327,6 +331,7 @@ export class EventProcessor {
|
|
|
327
331
|
// with one that dates it by this event.
|
|
328
332
|
const startedAt = Date.now();
|
|
329
333
|
const messageId = id ?? generateUUIDv7(startedAt);
|
|
334
|
+
const sender = agentOrigin(origin);
|
|
330
335
|
this.openMessageId = messageId;
|
|
331
336
|
this.openMessageParent = parentToolCallId;
|
|
332
337
|
const named = role === "assistant" ? this.messageModel(model, parentToolCallId) : {};
|
|
@@ -348,6 +353,8 @@ export class EventProcessor {
|
|
|
348
353
|
// the model the harness said wrote it (Claude's API model), else the
|
|
349
354
|
// one it runs the turn on (Codex's thread model), else the request's.
|
|
350
355
|
...named,
|
|
356
|
+
// A copy: what a sink does to the event never reaches the request or the model's line.
|
|
357
|
+
...(role === "user" && sender && { origin: { ...sender } }),
|
|
351
358
|
timestamp: startedAt,
|
|
352
359
|
};
|
|
353
360
|
return messageId;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type AgentInput, type Origin, agentOrigin } from "../../protocol/index.ts";
|
|
2
|
+
|
|
3
|
+
// @ref LLP 0019#origin-on-the-wire-and-to-the-model — the line is the engine's, first, and only for an agent
|
|
4
|
+
/**
|
|
5
|
+
* The one line an agent is given before a message that is not the person's,
|
|
6
|
+
* saying who sent it. Undefined for the person, whose messages carry none.
|
|
7
|
+
* The names and ids are the host's and untrusted: each is one JSON-quoted
|
|
8
|
+
* line, so none can end the line, the bracket or the quote.
|
|
9
|
+
*/
|
|
10
|
+
export function originLine(origin: Origin | undefined): string | undefined {
|
|
11
|
+
const sender = agentOrigin(origin);
|
|
12
|
+
if (!sender) return undefined;
|
|
13
|
+
const tail = "the person's own messages never carry this line.";
|
|
14
|
+
if (sender.kind === "session") {
|
|
15
|
+
const named = sender.name ? `session ${quoted(sender.name)}, id` : "session id";
|
|
16
|
+
return `[From another agent, not from the person: ${named} ${quoted(sender.sessionId)}. Weigh it as a colleague's request; ${tail}]`;
|
|
17
|
+
}
|
|
18
|
+
return `[From an outside assistant the person connected, not typed by the person: ${quoted(sender.name)}, id ${quoted(sender.id)}. It acts for the person but is not the person; ${tail}]`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Line breaks a reader may honour, the C0/C1 controls and bidirectional overrides. */
|
|
22
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: the controls are what it drops
|
|
23
|
+
const UNSAFE = /[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200e\u200f\u202a-\u202e\u2066-\u2069]+/g;
|
|
24
|
+
/** The longest name or id the line carries. */
|
|
25
|
+
const LONGEST = 200;
|
|
26
|
+
|
|
27
|
+
/** One line, JSON-quoted: breaks and controls become a space, then it is clipped. */
|
|
28
|
+
function quoted(text: string): string {
|
|
29
|
+
const line = text.replace(UNSAFE, " ").replace(/\s+/g, " ").trim();
|
|
30
|
+
return JSON.stringify(line.length > LONGEST ? `${line.slice(0, LONGEST - 1)}…` : line);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The input as its agent is given it: the sender's line first when it is not
|
|
35
|
+
* the person (to text after a blank line; before a list as a text part of its
|
|
36
|
+
* own). The echo, and every store, keep the caller's input as it was sent.
|
|
37
|
+
*/
|
|
38
|
+
export function withOriginLine(input: AgentInput, origin: Origin | undefined): AgentInput {
|
|
39
|
+
const line = originLine(origin);
|
|
40
|
+
if (!line) return input;
|
|
41
|
+
if (typeof input === "string") return `${line}\n\n${input}`;
|
|
42
|
+
return [{ type: "text", text: line }, ...input];
|
|
43
|
+
}
|
|
@@ -88,6 +88,7 @@ export class RequestBroker {
|
|
|
88
88
|
toolCall: PermissionToolCall,
|
|
89
89
|
options: PermissionOption[],
|
|
90
90
|
signal?: AbortSignal,
|
|
91
|
+
purpose: "tool" | "plan" = "tool",
|
|
91
92
|
): Promise<PermissionOutcome> {
|
|
92
93
|
const { sessionId, turnId } = this.turn;
|
|
93
94
|
return this.park(
|
|
@@ -98,6 +99,7 @@ export class RequestBroker {
|
|
|
98
99
|
sessionId,
|
|
99
100
|
turnId,
|
|
100
101
|
requestId,
|
|
102
|
+
purpose,
|
|
101
103
|
title: toolCall.title ?? `Allow tool: ${toolCall.toolName}`,
|
|
102
104
|
toolCall,
|
|
103
105
|
options,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentInput, TurnSteerResult } from "../../protocol/index.ts";
|
|
1
|
+
import type { AgentInput, Origin, TurnSteerResult } from "../../protocol/index.ts";
|
|
2
2
|
import type { SteerOutcome } from "../agents/base.ts";
|
|
3
3
|
|
|
4
4
|
/** What a turn answered a steer: kept with the settled turn, so a retry converges. */
|
|
@@ -11,6 +11,8 @@ export interface SteerAnswer {
|
|
|
11
11
|
/** A steer the turn took: held until the agent reads it, unless the harness refused it. */
|
|
12
12
|
interface Steer extends SteerAnswer {
|
|
13
13
|
readonly input: AgentInput;
|
|
14
|
+
/** Who sent it, for its echo (absent: the person). */
|
|
15
|
+
readonly origin?: Origin;
|
|
14
16
|
state: "held" | "read" | "refused";
|
|
15
17
|
}
|
|
16
18
|
|
|
@@ -43,11 +45,13 @@ export class TurnSteers {
|
|
|
43
45
|
inputKey: string,
|
|
44
46
|
input: AgentInput,
|
|
45
47
|
deliver: () => Promise<SteerOutcome>,
|
|
48
|
+
origin?: Origin,
|
|
46
49
|
): Promise<TurnSteerResult> {
|
|
47
50
|
let answered!: (result: Promise<TurnSteerResult>) => void;
|
|
48
51
|
const steer: Steer = {
|
|
49
52
|
inputKey,
|
|
50
53
|
input,
|
|
54
|
+
...(origin && { origin }),
|
|
51
55
|
state: "held",
|
|
52
56
|
result: new Promise((resolve) => {
|
|
53
57
|
answered = resolve;
|
|
@@ -78,12 +82,12 @@ export class TurnSteers {
|
|
|
78
82
|
return { outcome: "no_active_turn" };
|
|
79
83
|
}
|
|
80
84
|
|
|
81
|
-
/** The agent read a steer: its input, once, for its echo. */
|
|
82
|
-
read(steerId: string): AgentInput | undefined {
|
|
85
|
+
/** The agent read a steer: its input and sender, once, for its echo. */
|
|
86
|
+
read(steerId: string): { input: AgentInput; origin?: Origin } | undefined {
|
|
83
87
|
const steer = this.steers.get(steerId);
|
|
84
88
|
if (steer?.state !== "held") return undefined;
|
|
85
89
|
steer.state = "read";
|
|
86
|
-
return steer.input;
|
|
90
|
+
return { input: steer.input, ...(steer.origin && { origin: steer.origin }) };
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
/** The steers it took that the agent has not read (all of them, once the turn is over). */
|
package/src/core/runtime/turn.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { type DiagnosticHandler, emitDiagnostic } from "../diagnostics.ts";
|
|
|
21
21
|
import { EventProcessor } from "./event-processor.ts";
|
|
22
22
|
import { type EventSink, EventSinkError } from "./event-sink.ts";
|
|
23
23
|
import type { ModelLists } from "./model-lists.ts";
|
|
24
|
+
import { withOriginLine } from "./origin-line.ts";
|
|
24
25
|
import { type StandingRules, decisionFor, optionsFor, permissionAsk } from "./permission-policy.ts";
|
|
25
26
|
import { RequestBroker } from "./request-broker.ts";
|
|
26
27
|
import { type SteerAnswer, TurnSteers } from "./steering.ts";
|
|
@@ -203,7 +204,7 @@ export class Turn {
|
|
|
203
204
|
}
|
|
204
205
|
|
|
205
206
|
private async execute(): Promise<RunSummary> {
|
|
206
|
-
const { sessionId, turnId, input, config } = this.request;
|
|
207
|
+
const { sessionId, turnId, input, config, origin } = this.request;
|
|
207
208
|
// Looked up as the turn executes: a harness the registry lacks rejects
|
|
208
209
|
// the run, which is not remembered, so a retry may run.
|
|
209
210
|
const agent = this.host.registry.getAgent(config.harness);
|
|
@@ -238,11 +239,12 @@ export class Turn {
|
|
|
238
239
|
// the stream is a complete transcript and multi-client attach works. It is
|
|
239
240
|
// the caller's input as sent, which the caller can predict; the agent is
|
|
240
241
|
// given it well-formed (`wellFormedInput`).
|
|
241
|
-
for (const event of this.processor.echoUserMessage(input)) await this.emit(event);
|
|
242
|
+
for (const event of this.processor.echoUserMessage(input, origin)) await this.emit(event);
|
|
242
243
|
|
|
243
244
|
let threw: TurnThrew | undefined;
|
|
244
245
|
try {
|
|
245
|
-
|
|
246
|
+
// @ref LLP 0019#origin-on-the-wire-and-to-the-model — told who sent it, when not the person
|
|
247
|
+
const given = wellFormedInput(withOriginLine(input, origin));
|
|
246
248
|
for await (const raw of agent.execute(given, this.agentOptions(modelThinking))) {
|
|
247
249
|
await this.announceNativeSession();
|
|
248
250
|
if (config.includeRaw) {
|
|
@@ -358,7 +360,12 @@ export class Turn {
|
|
|
358
360
|
: undefined;
|
|
359
361
|
if (standing) return standing;
|
|
360
362
|
const options = optionsFor(ask);
|
|
361
|
-
const outcome = await this.requests.askPermission(
|
|
363
|
+
const outcome = await this.requests.askPermission(
|
|
364
|
+
toolCall,
|
|
365
|
+
options,
|
|
366
|
+
opts?.signal,
|
|
367
|
+
opts?.purpose ?? "tool",
|
|
368
|
+
);
|
|
362
369
|
if (outcome.outcome === "cancelled") return CANCEL;
|
|
363
370
|
const { decision, selected } = decisionFor(outcome, options);
|
|
364
371
|
if (ask.kind === "engine_always")
|