toolroll 0.9.115 → 0.9.117
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 +55 -0
- package/README.md +43 -26
- package/dist/acp-agents.js +14 -1
- package/dist/acp-client.js +19 -1
- package/dist/agent-change-check.js +60 -0
- package/dist/agent-change-schema.js +19 -0
- package/dist/agent-detect.js +11 -1
- package/dist/agent-fence.js +39 -10
- package/dist/agent-network-request.js +108 -0
- package/dist/agent-requests.js +105 -0
- package/dist/approval-summary.js +3 -3
- package/dist/backup.js +17 -1
- package/dist/batch-checks.js +81 -18
- package/dist/browser/terminal.js +41 -41
- package/dist/browser/workspace.css +2 -2
- package/dist/browser/workspace.js +36 -36
- package/dist/builder.js +3 -1
- package/dist/candidate-materialize.js +119 -0
- package/dist/central-enrollment-contract.js +156 -0
- package/dist/central-recovery-stage.js +329 -0
- package/dist/chat-actions.js +101 -2
- package/dist/chat-channel.js +40 -0
- package/dist/check-only-standing.js +13 -0
- package/dist/check-only.js +25 -13
- package/dist/check-recovery-hold.js +199 -0
- package/dist/check-recovery-index-schema.js +3 -0
- package/dist/check-screenshots.js +83 -0
- package/dist/cli.js +125 -6
- package/dist/codex-limits.js +4 -0
- package/dist/connect-cli.js +257 -11
- package/dist/contracts/chat-actions.js +4 -0
- package/dist/contracts/console-api.js +15 -4
- package/dist/contracts/engine-api.js +344 -2
- package/dist/contracts/lead-tools.js +56 -2
- package/dist/contracts/provider.js +1 -1
- package/dist/contracts/route.js +1 -1
- package/dist/contracts/terminal-connection.js +50 -0
- package/dist/converse.js +80 -4
- package/dist/device-pair.js +280 -0
- package/dist/direct-chat-artifacts.js +347 -0
- package/dist/direct-chat-catalog.js +311 -0
- package/dist/direct-chat-fence.js +96 -0
- package/dist/direct-chat-git.js +343 -0
- package/dist/direct-chat-laptop.js +19 -0
- package/dist/direct-chat-schema.js +181 -0
- package/dist/direct-chat-ship.js +861 -0
- package/dist/direct-chat-workspace.js +389 -0
- package/dist/direct-chat.js +2107 -0
- package/dist/doctor.js +1 -1
- package/dist/easy-start.js +18 -0
- package/dist/egress.js +25 -4
- package/dist/engine-chat.js +454 -0
- package/dist/engine-reads.js +141 -13
- package/dist/exec.js +4 -3
- package/dist/flexible-agents.js +8 -16
- package/dist/flexible-authority-end.js +2 -0
- package/dist/flexible-interactive-schema.js +133 -0
- package/dist/flexible-interactive.js +94 -0
- package/dist/flexible-session.js +117 -49
- package/dist/flexible-ship.js +87 -7
- package/dist/flexible-sign-in.js +10 -0
- package/dist/flexible-start.js +21 -3
- package/dist/flexible-thread.js +2 -3
- package/dist/flexible-turns.js +26 -5
- package/dist/flexible.js +13 -0
- package/dist/flow-triggers.js +13 -4
- package/dist/flows-ui.js +54 -20
- package/dist/handoff-cli.js +630 -0
- package/dist/invoke.js +55 -13
- package/dist/lead-contract.js +5 -4
- package/dist/lead-doors.js +80 -1
- package/dist/lead-progress.js +9 -0
- package/dist/lead-tools.js +682 -10
- package/dist/lead.js +37 -9
- package/dist/live-bus.js +11 -0
- package/dist/live-terminal.js +132 -12
- package/dist/local-handoff.js +363 -0
- package/dist/local-owner-acts.js +264 -2
- package/dist/local-owner.js +16 -1
- package/dist/multiplayer-handoff.js +528 -0
- package/dist/multiplayer-presence.js +471 -0
- package/dist/names.js +17 -4
- package/dist/needs-you.js +10 -0
- package/dist/operate.js +280 -19
- package/dist/policy.js +2 -2
- package/dist/project-delete-ui.js +18 -11
- package/dist/project-delete.js +65 -4
- package/dist/project-tools.js +1 -1
- package/dist/prompt.js +1 -1
- package/dist/provider-connection.js +2 -0
- package/dist/provider-home.js +251 -8
- package/dist/provider.js +3 -2
- package/dist/publish.js +119 -64
- package/dist/pull-request-flow.js +35 -14
- package/dist/read-executor-worker.js +1 -1
- package/dist/read-executor.js +95 -1
- package/dist/restore-retirement.js +152 -0
- package/dist/result-follow-ups.js +116 -37
- package/dist/route-change.js +44 -4
- package/dist/scope.js +62 -5
- package/dist/serve.js +49 -5
- package/dist/server/chat.js +94 -13
- package/dist/server/console.css +9 -9
- package/dist/server/direct-chat.js +583 -0
- package/dist/server/engine-api.js +219 -21
- package/dist/server/flows.js +47 -13
- package/dist/server/found-repos.js +25 -0
- package/dist/server/guards.js +20 -6
- package/dist/server/live.js +81 -23
- package/dist/server/pages.js +67 -13
- package/dist/server/people-tokens.js +47 -6
- package/dist/server/remote.js +29 -0
- package/dist/server/render-results.js +6 -2
- package/dist/server/render-settings.js +4 -2
- package/dist/server/render-tasks.js +18 -17
- package/dist/server/route-table.js +69 -2
- package/dist/server/settings.js +22 -7
- package/dist/server/task-views.js +15 -3
- package/dist/server/tasks.js +39 -2
- package/dist/server/terminals.js +185 -11
- package/dist/settings-proofs.js +1 -1
- package/dist/spend-report.js +2 -2
- package/dist/spend.js +3 -3
- package/dist/store.js +600 -59
- package/dist/subagent-admin.js +23 -10
- package/dist/subagent-backup-schema.js +36 -0
- package/dist/subagent-backup.js +92 -0
- package/dist/subagent-week.js +2 -2
- package/dist/subagent-work.js +70 -47
- package/dist/subagents-ui.js +6 -2
- package/dist/subagents.js +5 -2
- package/dist/subscription-chat.js +36 -5
- package/dist/subscription-usage.js +233 -0
- package/dist/task-live.js +2 -1
- package/dist/teardown-git.js +34 -4
- package/dist/terminal-connection.js +159 -0
- package/dist/terminal-safety.js +114 -0
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/dist/tui-contract.js +1 -1
- package/dist/tui-launch.js +32 -1
- package/dist/workspace-identity-schema.js +21 -0
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,61 @@ Each release opens with one line on its theme, then **New**, **Changed**, **Fixe
|
|
|
4
4
|
the ones it has). Each item is at most two lines and says where to find it. Notes for maintainers (CI, the release
|
|
5
5
|
tooling) go on the GitHub release, not here. Entries before 0.9.104 use the older format.
|
|
6
6
|
|
|
7
|
+
## 0.9.117 — 2026-11-25
|
|
8
|
+
|
|
9
|
+
Interactive agent threads keep working reply after reply, Direct Chat arrives, and agents get tighter fences.
|
|
10
|
+
|
|
11
|
+
### New
|
|
12
|
+
|
|
13
|
+
- **Direct Chat:** chat with Claude, Codex or Gemini in an isolated copy of your project, see each turn's diff, and
|
|
14
|
+
Ship what you reviewed. It runs inside the same sandbox and network rules as a build.
|
|
15
|
+
- **The Toolroll Mac app (preview), built from source:** `cd mac && ./build-app.sh`. It finds or starts your local
|
|
16
|
+
Toolroll, and approvals use Touch ID or your password.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **Ship says what it needs before you press anything,** and commits exactly the files you previewed: a file
|
|
21
|
+
changed after the preview, even made executable, stops the Ship.
|
|
22
|
+
- **Changing a task's model keeps your approval only when the project's tools are unchanged;** otherwise it asks again.
|
|
23
|
+
- **An agent's network request shows exactly what it would change** and applies only that, to your settings as they
|
|
24
|
+
are when you approve.
|
|
25
|
+
- **Esc leaves the Diff tab,** and accepting or sending back a result takes you out of it.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- **Replying to a thread works every time.** A reply after a finished turn no longer stops its own new agent.
|
|
30
|
+
- **Typed text no longer runs as workbench keys,** a reply sent twice runs once, and turning threads off stops only
|
|
31
|
+
the agents that were running.
|
|
32
|
+
- **Codex builds keep their own conversation history,** never another task's or yours.
|
|
33
|
+
- **Codex and OpenRouter builds follow your project's network settings on a Mac,** including **Allow this Mac's
|
|
34
|
+
local services**.
|
|
35
|
+
- **Restoring a backup retires its chat-app connections and pairing codes;** pair your chat apps again after.
|
|
36
|
+
|
|
37
|
+
### Action needed
|
|
38
|
+
|
|
39
|
+
- **Codex:** if a build says its sign-in expired, run `codex login` once.
|
|
40
|
+
- **Direct Chat** uses each agent's own sign-in (`claude`, `codex`), not API keys set on the Toolroll server.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## 0.9.116 — 2026-11-19
|
|
44
|
+
|
|
45
|
+
Clearer recovery for threads and AI teammates, with consistent light and dark colours.
|
|
46
|
+
|
|
47
|
+
### New
|
|
48
|
+
|
|
49
|
+
- **Optional Codex backup for AI teammates.** Set its model in the teammate's Settings. Your ChatGPT sign-in
|
|
50
|
+
can answer when Claude hits its limit or isn't installed; existing tool approvals and daily limits remain.
|
|
51
|
+
|
|
52
|
+
### Changed
|
|
53
|
+
|
|
54
|
+
- **Flow colours follow your theme.** The colour picker uses the standard controls and marks the selected colour.
|
|
55
|
+
- **Quieter surfaces.** Chat, workspace panels and overlays use the shared shadow and dimming styles.
|
|
56
|
+
|
|
57
|
+
### Fixed
|
|
58
|
+
|
|
59
|
+
- **Thread connection errors explain the next step.** Review changes, then reply to retry. An uncertain outcome
|
|
60
|
+
still says so; retrying is always your choice.
|
|
61
|
+
|
|
7
62
|
## 0.9.115 — 2026-11-18
|
|
8
63
|
|
|
9
64
|
Interactive agent threads (beta) get their everyday loop, a failed plan is no longer a dead end, and every screen
|
package/README.md
CHANGED
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
### Your agents build. You decide.
|
|
9
9
|
|
|
10
|
-
**Delegate
|
|
10
|
+
**Delegate changes. Review verified diffs. Ship in one keystroke — in the native macOS app or your terminal.**
|
|
11
11
|
|
|
12
12
|
<picture>
|
|
13
13
|
<source media="(prefers-color-scheme: light)" srcset="docs/media/terminal-workbench-light.png">
|
|
14
|
-
<img src="docs/media/terminal-workbench.png" alt="
|
|
14
|
+
<img src="docs/media/terminal-workbench.png" alt="Toolroll: native macOS app and terminal workbench with tasks that need you and live streaming output" width="900">
|
|
15
15
|
</picture>
|
|
16
|
-
<sub>
|
|
16
|
+
<sub>Native SwiftUI macOS app and keyboard-driven terminal workbench, zero Electron, zero telemetry.</sub>
|
|
17
17
|
|
|
18
|
-
For Claude Code, Codex and Gemini
|
|
18
|
+
For Claude Code, Codex, and Gemini — using the subscriptions already on your machine.
|
|
19
19
|
|
|
20
20
|
[](https://www.npmjs.com/package/toolroll)
|
|
21
21
|
[](https://github.com/ap9000/toolroll/actions/workflows/ci.yml)
|
|
@@ -29,37 +29,54 @@ For Claude Code, Codex and Gemini, on your own machine.
|
|
|
29
29
|
|
|
30
30
|
## Quick start
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
### Native macOS app (recommended on Mac)
|
|
33
|
+
|
|
34
|
+
Install the native SwiftUI macOS app and local CLI together via Homebrew Cask (macOS 14 Sonoma+, Apple Silicon & Intel):
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
brew install --cask ap9000/toolroll/toolroll
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Or download the signed, notarized `Toolroll-<version>-macos.dmg` directly from [GitHub Releases](https://github.com/ap9000/toolroll/releases/latest) and drag **Toolroll.app** to Applications. On launch, Toolroll automatically discovers or starts your local engine — no manual terminal setup required.
|
|
41
|
+
|
|
42
|
+
<details>
|
|
43
|
+
<summary>Building the native Mac app from source</summary>
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
cd mac && bash build-app.sh && open build/Toolroll.app
|
|
47
|
+
# Or package a local .dmg:
|
|
48
|
+
cd mac && bash build-dmg.sh
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
See [macOS release & signing guide](docs/guide/mac-release.md) for Developer ID signing, notarization, and Homebrew Cask automation.
|
|
52
|
+
|
|
53
|
+
</details>
|
|
54
|
+
|
|
55
|
+
### CLI & Terminal Workbench (macOS or Linux)
|
|
56
|
+
|
|
57
|
+
Requires Node.js 22.20+, git 2.41+, and Claude Code (`claude`), Codex (`codex`), or Gemini signed in on this computer. On Linux, also install the sandbox tools: `sudo apt update && sudo apt install bubblewrap socat ripgrep`.
|
|
35
58
|
|
|
36
59
|
```sh
|
|
37
60
|
curl -fsSL https://raw.githubusercontent.com/ap9000/toolroll/main/install.sh | sh
|
|
38
61
|
```
|
|
39
62
|
|
|
40
|
-
|
|
63
|
+
Or with Homebrew / npm:
|
|
41
64
|
|
|
42
65
|
```sh
|
|
43
|
-
|
|
66
|
+
brew install ap9000/toolroll/toolroll # or: npm install -g toolroll
|
|
44
67
|
toolroll
|
|
45
68
|
```
|
|
46
69
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
press `a` to accept (confirm after reading), or `r` to request a revision. Elsewhere, press
|
|
58
|
-
`s` to try a small sample project, add your own with
|
|
59
|
-
`toolroll repos add <folder>`, or open the browser (press `w`, or run
|
|
60
|
-
`toolroll --web`). To look around
|
|
61
|
-
first, `toolroll demo` opens a seeded sandbox with no model calls and no spend.
|
|
62
|
-
More: [Getting started](docs/guide/getting-started.md).
|
|
70
|
+
<details>
|
|
71
|
+
<summary>Upgrading from the older <code>standing-orders</code> npm package</summary>
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
npm uninstall -g standing-orders && npm install -g toolroll
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
</details>
|
|
78
|
+
|
|
79
|
+
Toolroll opens locally with no password and no login file — on your own computer you're already in. Start a **Direct Chat** for fast interactive iteration in an isolated clone, or delegate a **Task** to build while you walk away. Every result returns **Ready** with its diff and real check status; press `⌘⏎` (Mac app) or `a` (terminal) to accept and ship, or send it back with notes. To explore without model calls or spend, run `toolroll demo`. More: [Getting started](docs/guide/getting-started.md).
|
|
63
80
|
|
|
64
81
|
## The terminal loop
|
|
65
82
|
|
|
@@ -122,7 +139,7 @@ the CLI or MCP. Every act lands in one ledger.
|
|
|
122
139
|
| **Approvals** | Digest-bound scopes, password step-up, typed decisions with reversibility, expiring operating modes |
|
|
123
140
|
| **Agents** | Claude Code, Codex, Gemini, OpenRouter; an exact model per phase; subscription or API key |
|
|
124
141
|
| **Models** | One editor (Settings → Models): "Sized by job" by default (Haiku for small tasks, Sonnet for routine, Opus for large or risky, Opus plans and reviews), or "Opus for everything"; every change shown before → after and logged |
|
|
125
|
-
| **Surfaces** |
|
|
142
|
+
| **Surfaces** | Native macOS app (SwiftUI), terminal workbench, web console (desktop & phone), CLI, Telegram, Slack, Discord, Teams, MCP |
|
|
126
143
|
| **Flows** | Zones on a canvas; triggers from schedules, GitHub, Linear, webhooks, email and chat; scripts, drafts, AI triage |
|
|
127
144
|
| **Team** | Team server, OpenID Connect sign-in, per-person API tokens, project grants, subagents |
|
|
128
145
|
| **Audit** | Hash-chained action ledger (`toolroll ledger verify`), evidence packs, full export |
|
package/dist/acp-agents.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const ACP_PROVIDER_IDS = ["opencode", "cursor", "cline", "qwen", "goose"];
|
|
1
|
+
export const ACP_PROVIDER_IDS = ["opencode", "cursor", "cline", "qwen", "goose", "antigravity"];
|
|
2
2
|
export const ACP_AGENTS = {
|
|
3
3
|
opencode: {
|
|
4
4
|
name: "OpenCode",
|
|
@@ -40,6 +40,19 @@ export const ACP_AGENTS = {
|
|
|
40
40
|
home: [".config/goose"],
|
|
41
41
|
configSurface: ["~/.config/goose (providers, extensions)", "repository .goosehints", "its own sign-in"],
|
|
42
42
|
},
|
|
43
|
+
antigravity: {
|
|
44
|
+
name: "Antigravity",
|
|
45
|
+
binary: "agy",
|
|
46
|
+
argv: ["acp"],
|
|
47
|
+
authMethod: "oauth-personal",
|
|
48
|
+
signIn: "agy acp --login",
|
|
49
|
+
home: [".gemini"],
|
|
50
|
+
configSurface: [
|
|
51
|
+
"~/.gemini (Antigravity login, rules, skills, MCP servers)",
|
|
52
|
+
"repository GEMINI.md and AGENTS.md",
|
|
53
|
+
"its own Google account sign-in (agy acp --login)",
|
|
54
|
+
],
|
|
55
|
+
},
|
|
43
56
|
};
|
|
44
57
|
const ACP = new Set(ACP_PROVIDER_IDS);
|
|
45
58
|
export function isAcpProvider(provider) {
|
package/dist/acp-client.js
CHANGED
|
@@ -327,10 +327,17 @@ export function createAcpConversation(options) {
|
|
|
327
327
|
return { send: [], live: [] };
|
|
328
328
|
}
|
|
329
329
|
if (error !== null) {
|
|
330
|
-
if (errorCode === AUTH_REQUIRED)
|
|
330
|
+
if (errorCode === AUTH_REQUIRED || purpose === "authenticate")
|
|
331
331
|
return fail("auth-required", errorText);
|
|
332
332
|
return fail(purpose === "model" ? "model-unavailable" : "protocol", `${purpose}: ${errorText}`);
|
|
333
333
|
}
|
|
334
|
+
if (purpose === "authenticate") {
|
|
335
|
+
if (result !== null && (!isRecord(result) || !meta(result)))
|
|
336
|
+
return fail("protocol", "authenticate: the answer was not an object");
|
|
337
|
+
keep({ type: "acp.auth", methodId: options.authMethod ?? "" });
|
|
338
|
+
phase = "session";
|
|
339
|
+
return { send: [request("session/new", { cwd: options.cwd, mcpServers: options.mcpServers ?? [] }, "session/new")], live: [] };
|
|
340
|
+
}
|
|
334
341
|
if (!isRecord(result))
|
|
335
342
|
return fail("protocol", `${purpose}: the answer was not an object`);
|
|
336
343
|
if (purpose === "initialize") {
|
|
@@ -349,6 +356,17 @@ export function createAcpConversation(options) {
|
|
|
349
356
|
const sessions = isRecord(capabilities) ? capabilities["sessionCapabilities"] : undefined;
|
|
350
357
|
canClose = isRecord(sessions) && isRecord(sessions["close"]);
|
|
351
358
|
keep({ type: "acp.agent", name: agent.name, version: agent.version });
|
|
359
|
+
const authMethod = typeof options.authMethod === "string" && options.authMethod !== "" ? options.authMethod : null;
|
|
360
|
+
if (authMethod !== null) {
|
|
361
|
+
const methods = result["authMethods"];
|
|
362
|
+
if (Array.isArray(methods) && methods.length > 0) {
|
|
363
|
+
if (!methods.some(one => isRecord(one) && one["id"] === authMethod)) {
|
|
364
|
+
return fail("auth-required", `the agent does not advertise ${authMethod} authentication`);
|
|
365
|
+
}
|
|
366
|
+
phase = "authenticate";
|
|
367
|
+
return { send: [request("authenticate", { methodId: authMethod }, "authenticate")], live: [] };
|
|
368
|
+
}
|
|
369
|
+
}
|
|
352
370
|
phase = "session";
|
|
353
371
|
return { send: [request("session/new", { cwd: options.cwd, mcpServers: options.mcpServers ?? [] }, "session/new")], live: [] };
|
|
354
372
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { canonicalJson } from "./canonical-json.js";
|
|
2
|
+
import { legOf, routeFromJson, sameSpec } from "./phase-routing.js";
|
|
3
|
+
import { levelOfProfile } from "./policy.js";
|
|
4
|
+
const KEPT_PROFILE_KEYS = ["network", "writes", "checkAccess", "fencePolicy", "readDeny", "machLookup"];
|
|
5
|
+
const same = (a, b) => canonicalJson(a ?? null) === canonicalJson(b ?? null);
|
|
6
|
+
const pairOf = (leg) => ({ provider: leg.provider, model: leg.model });
|
|
7
|
+
export function agentOnlyChange(sealed, next, billingOf) {
|
|
8
|
+
const was = routeFromJson(sealed.routeJson ?? null), now = routeFromJson(next.routeJson ?? null);
|
|
9
|
+
if (was === null || now === null)
|
|
10
|
+
return { ok: false, why: "a route can't be read" };
|
|
11
|
+
const terms = routeTermsProblem(was, now);
|
|
12
|
+
if (terms !== null)
|
|
13
|
+
return { ok: false, why: terms };
|
|
14
|
+
const changed = ["plan", "build", "repair", "review"].filter(phase => !sameSpec(legOf(was, phase), legOf(now, phase)));
|
|
15
|
+
const phase = changed.length === 1 && changed[0] === "plan" ? "plan"
|
|
16
|
+
: changed.includes("build") && changed.every(one => one === "build" || one === "repair") ? "build" : null;
|
|
17
|
+
if (phase === null)
|
|
18
|
+
return { ok: false, why: changed.length === 0 ? "no agent changed" : `${changed.join(", ")} changed` };
|
|
19
|
+
if (changed.includes("repair") && legOf(now, "repair").provider !== legOf(now, "build").provider)
|
|
20
|
+
return { ok: false, why: "the repair agent changed on its own" };
|
|
21
|
+
const others = (route) => route.overrides.filter(one => one.phase !== phase && !(phase === "build" && one.phase === "repair"));
|
|
22
|
+
if (!same(others(was), others(now)))
|
|
23
|
+
return { ok: false, why: "another role's choice changed" };
|
|
24
|
+
const profile = profileProblem(sealed.profile, next.profile, phase, legOf(now, "build"));
|
|
25
|
+
if (profile !== null)
|
|
26
|
+
return { ok: false, why: profile };
|
|
27
|
+
if ((sealed.chainJson ?? null) !== (next.chainJson ?? null))
|
|
28
|
+
return { ok: false, why: "the fallback chain changed" };
|
|
29
|
+
const from = pairOf(legOf(was, phase)), to = pairOf(legOf(now, phase));
|
|
30
|
+
if (billingOf(from.provider) !== billingOf(to.provider))
|
|
31
|
+
return { ok: false, why: "how the agent bills changed" };
|
|
32
|
+
return { ok: true, phase, from, to };
|
|
33
|
+
}
|
|
34
|
+
function routeTermsProblem(was, now) {
|
|
35
|
+
if (was.version !== now.version)
|
|
36
|
+
return "the route's version changed";
|
|
37
|
+
if (was.risk !== now.risk || was.qualityMode !== now.qualityMode || was.publication !== now.publication)
|
|
38
|
+
return "the route's terms changed";
|
|
39
|
+
if (!same([...was.evidence].sort(), [...now.evidence].sort()) || !same(was.demands, now.demands) || !same(was.size, now.size))
|
|
40
|
+
return "the route's terms changed";
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
function profileProblem(was, now, phase, build) {
|
|
44
|
+
if (was == null || now == null)
|
|
45
|
+
return "a profile can't be read";
|
|
46
|
+
if (phase === "plan")
|
|
47
|
+
return same(was, now) ? null : "the build settings changed";
|
|
48
|
+
if (now.provider !== build.provider || now.model !== build.model)
|
|
49
|
+
return "the build settings don't name the new builder";
|
|
50
|
+
if (was.provider === now.provider) {
|
|
51
|
+
const rest = (one) => ({ ...one, model: undefined, repairModel: undefined });
|
|
52
|
+
return same(rest(was), rest(now)) ? null : "the build settings changed";
|
|
53
|
+
}
|
|
54
|
+
if (levelOfProfile(was) !== levelOfProfile(now))
|
|
55
|
+
return "what the builder may do changed";
|
|
56
|
+
for (const key of KEPT_PROFILE_KEYS)
|
|
57
|
+
if (!same(was[key], now[key]))
|
|
58
|
+
return "what builds may reach changed";
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const V180_SCHEMA = `
|
|
2
|
+
CREATE TABLE IF NOT EXISTS pending_agent_change (
|
|
3
|
+
task_ref INTEGER PRIMARY KEY REFERENCES task_ref(id),
|
|
4
|
+
phase TEXT NOT NULL CHECK (phase IN ('plan', 'build')),
|
|
5
|
+
provider TEXT NOT NULL,
|
|
6
|
+
model TEXT NOT NULL,
|
|
7
|
+
apply_when TEXT NOT NULL CHECK (apply_when IN ('next-run', 'restart')),
|
|
8
|
+
saw_digest TEXT NOT NULL,
|
|
9
|
+
run INTEGER REFERENCES run(id),
|
|
10
|
+
by TEXT NOT NULL,
|
|
11
|
+
local_generation INTEGER NOT NULL,
|
|
12
|
+
account_generation INTEGER NOT NULL,
|
|
13
|
+
transport TEXT NOT NULL CHECK (transport IN ('browser', 'terminal')),
|
|
14
|
+
at TEXT NOT NULL,
|
|
15
|
+
problem TEXT
|
|
16
|
+
);
|
|
17
|
+
`;
|
|
18
|
+
export const V180_TABLES = Object.freeze(["pending_agent_change"]);
|
|
19
|
+
export const V180_STEPS = Object.freeze(["pending-agent-change"]);
|
package/dist/agent-detect.js
CHANGED
|
@@ -18,6 +18,7 @@ const ACP_LOGIN = {
|
|
|
18
18
|
goose: { kind: "file", path: (home, env) => join(xdg(env, "XDG_CONFIG_HOME", home, ".config"), "goose", "config.yaml"), how: "set up" },
|
|
19
19
|
cursor: { kind: "none" },
|
|
20
20
|
cline: { kind: "none" },
|
|
21
|
+
antigravity: { kind: "file", path: home => join(home, ".gemini", "oauth_creds.json"), how: "Google account" },
|
|
21
22
|
};
|
|
22
23
|
export const DETECTED_AGENTS = [
|
|
23
24
|
{ id: "claude", name: "Claude Code", binary: "claude", signIn: "claude auth login", install: "npm install -g @anthropic-ai/claude-code", login: { kind: "checker" } },
|
|
@@ -89,6 +90,8 @@ export async function detectAgents(options = {}) {
|
|
|
89
90
|
return out(resolved === null ? "not-installed" : "unknown");
|
|
90
91
|
if (answer.state === "not-installed" || (KEY_ANSWERS.has(answer.state) && resolved === null))
|
|
91
92
|
return out("not-installed");
|
|
93
|
+
if (answer.launchIssue === "command-not-found")
|
|
94
|
+
return { ...out("unknown"), next: "The status command exited with code 127. Check that the agent and its helpers are on Toolroll's trusted PATH." };
|
|
92
95
|
if (SIGNED_IN.has(answer.state))
|
|
93
96
|
return out("signed-in", KEY_ANSWERS.has(answer.state) ? "API key" : answer.method ?? "signed in");
|
|
94
97
|
return out(SIGNED_OUT.has(answer.state) ? "signed-out" : "unknown");
|
|
@@ -102,7 +105,7 @@ export function withNext(agent, routed, acpChecked) {
|
|
|
102
105
|
return agent;
|
|
103
106
|
if (FIRST_TASK_ORDER.includes(agent.id)) {
|
|
104
107
|
const ready = agent.state === "signed-in" && (routed === null || routed === agent.id);
|
|
105
|
-
return { ...agent, ready, next: agent.state === "signed-in" && !ready ? CHOOSE_AGENT :
|
|
108
|
+
return { ...agent, ready, next: agent.state === "signed-in" && !ready ? CHOOSE_AGENT : agent.next };
|
|
106
109
|
}
|
|
107
110
|
if (isAcpProvider(agent.id)) {
|
|
108
111
|
const checked = acpChecked?.(agent.id) ?? false;
|
|
@@ -143,6 +146,10 @@ export function firstRunAgentLines(rows, firstTask, checking = false, routed = n
|
|
|
143
146
|
lines.push(`${one.name} is signed in. ${one.next}`);
|
|
144
147
|
continue;
|
|
145
148
|
}
|
|
149
|
+
if (one.state === "unknown" && one.next !== null && FIRST_TASK_ORDER.includes(one.id)) {
|
|
150
|
+
lines.push(`${one.name}: ${one.next}`);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
146
153
|
if (one.signIn !== null)
|
|
147
154
|
lines.push(`Sign in to ${one.name}: run \`${one.signIn}\`${one.state === "unknown" ? " (its sign-in couldn't be checked)" : ""}`);
|
|
148
155
|
}
|
|
@@ -180,6 +187,9 @@ export const AGENT_SETUP = Object.freeze({
|
|
|
180
187
|
note: "Its sign-in starts Qwen Code: type /auth and finish in the browser, then /quit." },
|
|
181
188
|
goose: { install: "curl -fsSL https://github.com/block/goose/releases/download/stable/download_cli.sh | bash", installRun: null, signIn: ACP_AGENTS.goose.signIn,
|
|
182
189
|
signInRun: { binary: "goose", args: ["configure"] }, key: null, check: ACP_CHECK("goose"), note: null },
|
|
190
|
+
antigravity: { install: null, installRun: null, signIn: ACP_AGENTS.antigravity.signIn,
|
|
191
|
+
signInRun: { binary: "agy", args: ["acp", "--login"] }, key: null, check: ACP_CHECK("antigravity"),
|
|
192
|
+
note: "Uses your Google account through Antigravity ACP (`agy acp`). Run `agy install` if `agy` is not on PATH." },
|
|
183
193
|
});
|
|
184
194
|
export function agentSetupOf(id) {
|
|
185
195
|
return Object.prototype.hasOwnProperty.call(AGENT_SETUP, id) ? AGENT_SETUP[id] : null;
|
package/dist/agent-fence.js
CHANGED
|
@@ -136,6 +136,13 @@ export function agentFence(options) {
|
|
|
136
136
|
catch { }
|
|
137
137
|
fence.add(backups);
|
|
138
138
|
fence.add(real(backups));
|
|
139
|
+
const codexSessions = join(state, CODEX_SESSIONS_DIR);
|
|
140
|
+
try {
|
|
141
|
+
mkdirSync(codexSessions, { mode: 0o700 });
|
|
142
|
+
}
|
|
143
|
+
catch { }
|
|
144
|
+
fence.add(codexSessions);
|
|
145
|
+
fence.add(real(codexSessions));
|
|
139
146
|
const threads = join(state, FLEXIBLE_THREADS_DIR);
|
|
140
147
|
try {
|
|
141
148
|
mkdirSync(threads, { mode: 0o700 });
|
|
@@ -197,6 +204,8 @@ export function agentFence(options) {
|
|
|
197
204
|
fence.add(gitViewsRoot(home));
|
|
198
205
|
for (const secrets of existingFolders(home, { dot: true }))
|
|
199
206
|
fence.add(secrets);
|
|
207
|
+
for (const path of operatorCodexHomes(home, worktree))
|
|
208
|
+
fence.add(path);
|
|
200
209
|
if (options.databaseFile !== null && options.databaseFile !== "" && options.databaseFile !== ":memory:") {
|
|
201
210
|
const stream = readMonitoring(dirname(real(options.databaseFile))).folder?.path;
|
|
202
211
|
if (stream !== undefined)
|
|
@@ -367,7 +376,7 @@ function otherRunFolders(folders) {
|
|
|
367
376
|
}
|
|
368
377
|
const uid = process.getuid?.();
|
|
369
378
|
return entries.filter(entry => RUN_FOLDER_PREFIXES.some(prefix => entry.startsWith(prefix))).map(entry => join(folders.root, entry)).filter(path => {
|
|
370
|
-
if (path === folders.own)
|
|
379
|
+
if (path === folders.own || (folders.alsoOwn ?? []).includes(path))
|
|
371
380
|
return false;
|
|
372
381
|
try {
|
|
373
382
|
const held = lstatSync(path);
|
|
@@ -411,6 +420,7 @@ export function grantFolder(path, create = true) {
|
|
|
411
420
|
const ACP_DATA = {
|
|
412
421
|
goose: [".local/share/goose", ".local/state/goose"],
|
|
413
422
|
qwen: [".qwen/tmp", ".qwen/history"],
|
|
423
|
+
antigravity: [".gemini/antigravity-cli", ".gemini/tmp", ".gemini/logs"],
|
|
414
424
|
};
|
|
415
425
|
const CLAUDE_SHORTENED = "-[a-z0-9]+(/|$)";
|
|
416
426
|
const ATOMIC_NAMES = "([.~][^/]*)?$";
|
|
@@ -489,6 +499,10 @@ export function buildCacheFolder(repo, home = homedir(), platform = process.plat
|
|
|
489
499
|
const root = platform === "darwin" ? join(home, "Library", "Caches") : env["XDG_CACHE_HOME"] !== undefined && isAbsolute(env["XDG_CACHE_HOME"]) ? env["XDG_CACHE_HOME"] : join(home, ".cache");
|
|
490
500
|
return join(root, "toolroll-builds", createHash("sha256").update(real(repo)).digest("hex").slice(0, 16));
|
|
491
501
|
}
|
|
502
|
+
export const PLAIN_AGENT_ENV = ["PATH", "LANG", "LC_ALL", "LC_CTYPE", "LC_MESSAGES", "TERM", "TZ", "USER", "LOGNAME", "SHELL", "COLORTERM"];
|
|
503
|
+
export function plainAgentEnv(base) {
|
|
504
|
+
return Object.fromEntries(PLAIN_AGENT_ENV.flatMap(name => base[name] === undefined ? [] : [[name, base[name]]]));
|
|
505
|
+
}
|
|
492
506
|
export function buildCacheEnv(folder) {
|
|
493
507
|
const at = (name) => join(folder, name);
|
|
494
508
|
return {
|
|
@@ -583,6 +597,21 @@ function worktreeGitDir(worktree) {
|
|
|
583
597
|
return null;
|
|
584
598
|
}
|
|
585
599
|
}
|
|
600
|
+
export function operatorCodexHomes(home, worktree = null, env = process.env) {
|
|
601
|
+
const named = env["CODEX_HOME"];
|
|
602
|
+
const candidates = [join(home, ".codex"), ...(named !== undefined && isAbsolute(named) ? [named] : [])].flatMap(path => [path, resolvedPath(path)]);
|
|
603
|
+
return [...new Set(candidates)].filter(path => path !== sep && path !== home && !inside(home, path) && !(worktree !== null && (worktree === path || inside(worktree, path)))
|
|
604
|
+
&& (process.platform !== "linux" || existsSync(path)));
|
|
605
|
+
}
|
|
606
|
+
export const CODEX_SESSIONS_DIR = "codex-sessions";
|
|
607
|
+
export function codexSessionsName(workspaceId, recoveryGeneration, taskRef) {
|
|
608
|
+
return createHash("sha256").update(`codex-sessions:${workspaceId}:${recoveryGeneration}:${taskRef}`, "utf8").digest("hex").slice(0, 32);
|
|
609
|
+
}
|
|
610
|
+
export function codexSessionsFolder(databaseFile, identity, taskRef) {
|
|
611
|
+
if (databaseFile === null || databaseFile === "" || databaseFile === ":memory:" || identity.id === "" || identity.recoveryGeneration === "")
|
|
612
|
+
return null;
|
|
613
|
+
return join(dirname(real(databaseFile)), CODEX_SESSIONS_DIR, codexSessionsName(identity.id, identity.recoveryGeneration, taskRef));
|
|
614
|
+
}
|
|
586
615
|
const toml = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
587
616
|
export function codexFenceArgv(fence, fullAccess, grants = NO_GRANTS) {
|
|
588
617
|
const access = codexFilesystem(fence, fullAccess, grants);
|
|
@@ -794,7 +823,7 @@ export function srtTermsOf(fence, grants = NO_GRANTS) {
|
|
|
794
823
|
for (const root of runRoots(folders)) {
|
|
795
824
|
for (const prefix of RUN_FOLDER_PREFIXES)
|
|
796
825
|
denyRead.add(join(root, `${prefix}*`));
|
|
797
|
-
for (const path of otherRunFolders({ root, own: folders.own })) {
|
|
826
|
+
for (const path of otherRunFolders({ root, own: folders.own, ...(folders.alsoOwn === undefined ? {} : { alsoOwn: folders.alsoOwn }) })) {
|
|
798
827
|
denyRead.add(path);
|
|
799
828
|
if (grants.writes === undefined)
|
|
800
829
|
denyWrite.add(path);
|
|
@@ -802,6 +831,8 @@ export function srtTermsOf(fence, grants = NO_GRANTS) {
|
|
|
802
831
|
}
|
|
803
832
|
if (folders.own !== null)
|
|
804
833
|
allowRead.add(folders.own);
|
|
834
|
+
for (const path of folders.alsoOwn ?? [])
|
|
835
|
+
allowRead.add(path);
|
|
805
836
|
}
|
|
806
837
|
const pool = grants.pool;
|
|
807
838
|
if (pool !== undefined) {
|
|
@@ -831,8 +862,8 @@ export function srtTermsOf(fence, grants = NO_GRANTS) {
|
|
|
831
862
|
const readConfig = { denyOnly: [...denyRead].sort(), allowWithinDeny: [...allowRead].sort() };
|
|
832
863
|
const writes = grants.writes;
|
|
833
864
|
const signInWrites = [...grants.signIns?.writes ?? [], ...(grants.signIns?.transcripts ?? []).map(folder => join(folder, "*.jsonl"))];
|
|
834
|
-
const allowOnly = writes === undefined ? ["/", ...(pool?.own == null ? [] : [real(pool.own)]), ...(folders?.own == null ? [] : [folders.own])]
|
|
835
|
-
: [...writes.subpaths, ...writes.prefixes.map(one => `${one.path}*`), ...signInWrites, ...getDefaultWritePaths({ denyRead: readConfig.denyOnly, allowRead: readConfig.allowWithinDeny })
|
|
865
|
+
const allowOnly = writes === undefined ? ["/", ...(pool?.own == null ? [] : [real(pool.own)]), ...(folders?.own == null ? [] : [folders.own]), ...(folders?.alsoOwn ?? [])]
|
|
866
|
+
: [...writes.subpaths, ...(folders?.alsoOwn ?? []), ...writes.prefixes.map(one => `${one.path}*`), ...signInWrites, ...getDefaultWritePaths({ denyRead: readConfig.denyOnly, allowRead: readConfig.allowWithinDeny })
|
|
836
867
|
.filter(path => grants.noSharedTemp !== true || !SHARED_TEMP.includes(path))];
|
|
837
868
|
const network = grants.network;
|
|
838
869
|
return {
|
|
@@ -853,12 +884,12 @@ export function sandboxedSpawn(file, args, fence, grants = NO_GRANTS, cwd, temp)
|
|
|
853
884
|
}
|
|
854
885
|
export const FENCE_SUMMARY = [
|
|
855
886
|
{
|
|
856
|
-
agent: "**Claude, Gemini, ACP agents**",
|
|
887
|
+
agent: "**Claude, Gemini, ACP agents; Codex and OpenRouter on a Mac**",
|
|
857
888
|
auto: "Anthropic's sandbox-runtime (Seatbelt on macOS; bubblewrap and its seccomp filter on Linux, which also needs socat and ripgrep): reads your home folder except the folders the project lists, never Toolroll's folders; other tasks' work read, never written; writes only the checkout, its Git data, the project's caches, the run's temp folder and the agent's own session files (anywhere outside the fence, under a project set to write anywhere), never the runtime's protected names in the checkout (Git hooks and config, shell profiles, `.mcp.json`, editor settings); no Apple Events. Neither (Windows, or a Linux missing one of those): the build doesn't start, unless an instance operator allows unconfined agents",
|
|
858
889
|
full: "same",
|
|
859
890
|
},
|
|
860
891
|
{
|
|
861
|
-
agent: "**Codex / OpenRouter** (
|
|
892
|
+
agent: "**Codex / OpenRouter** (Linux)",
|
|
862
893
|
auto: "Codex's own sandbox, given the same fence: reads your home folder except the folders the project lists, never Toolroll's folders; other tasks' work read, never written; writes only the checkout, its Git data and the project's caches (anywhere outside the fence, under a project set to write anywhere); no network",
|
|
863
894
|
full: "the same reads and writes, with the fence; its commands reach the network only when the project's network is open",
|
|
864
895
|
},
|
|
@@ -875,9 +906,7 @@ export function signInGrants(home, checkout, platform = process.platform) {
|
|
|
875
906
|
const read = SIGN_IN_FILES(platform).map(name => join(base, name)).filter(path => signInIsItself(base, path));
|
|
876
907
|
const transcript = claudeProjectFolder(base, real(checkout));
|
|
877
908
|
const folder = transcript.byPrefix || !existsSync(join(base, ".claude")) ? null : grantFolder(transcript.path);
|
|
878
|
-
|
|
879
|
-
const writes = grantFolder(codex, false) === null ? [] : ["sessions", "log"].map(name => grantFolder(join(codex, name))).filter((path) => path !== null);
|
|
880
|
-
return { read, transcripts: folder === null || platform !== "darwin" ? [] : [folder], writes, mach: platform === "darwin" ? ["com.apple.trustd.agent"] : [] };
|
|
909
|
+
return { read, transcripts: folder === null || platform !== "darwin" ? [] : [folder], writes: [], mach: platform === "darwin" ? ["com.apple.trustd.agent"] : [] };
|
|
881
910
|
}
|
|
882
911
|
export function signInIsItself(base, path) {
|
|
883
912
|
let at = base;
|
|
@@ -1026,6 +1055,6 @@ export function serverGrantsOf(grants) {
|
|
|
1026
1055
|
return {
|
|
1027
1056
|
...rest,
|
|
1028
1057
|
...(rest.pool === undefined ? {} : { pool: { ...rest.pool, own: null } }),
|
|
1029
|
-
...(rest.runFolders === undefined ? {} : { runFolders: {
|
|
1058
|
+
...(rest.runFolders === undefined ? {} : { runFolders: { root: rest.runFolders.root, own: null, ...(rest.runFolders.also === undefined ? {} : { also: rest.runFolders.also }) } }),
|
|
1030
1059
|
};
|
|
1031
1060
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { listAgentRequests, resolveAgentRequest } from "./agent-requests.js";
|
|
3
|
+
import { canonicalJson } from "./canonical-json.js";
|
|
4
|
+
import { MAX_NETWORK_HOSTS, normalizeHost } from "./egress.js";
|
|
5
|
+
import { proposeNetworkChanges } from "./route-change.js";
|
|
6
|
+
export const NETWORK_REQUEST_OLD = "This request was made by an older version of Toolroll. Ask the agent to request it again.";
|
|
7
|
+
export const NETWORK_REQUEST_CHANGED = "This request or the project's network changed since you looked. Nothing changed; review it again.";
|
|
8
|
+
const hostList = (value) => {
|
|
9
|
+
if (value === undefined)
|
|
10
|
+
return [];
|
|
11
|
+
if (!Array.isArray(value) || value.length > MAX_NETWORK_HOSTS)
|
|
12
|
+
return null;
|
|
13
|
+
const hosts = [];
|
|
14
|
+
for (const one of value) {
|
|
15
|
+
if (typeof one !== "string")
|
|
16
|
+
return null;
|
|
17
|
+
const host = normalizeHost(one);
|
|
18
|
+
if (host === null)
|
|
19
|
+
return null;
|
|
20
|
+
hosts.push(host);
|
|
21
|
+
}
|
|
22
|
+
return [...new Set(hosts)].sort();
|
|
23
|
+
};
|
|
24
|
+
export function readNetworkChange(params) {
|
|
25
|
+
if (params === null || typeof params !== "object")
|
|
26
|
+
return null;
|
|
27
|
+
const change = params.change;
|
|
28
|
+
if (change === null || typeof change !== "object" || Array.isArray(change))
|
|
29
|
+
return null;
|
|
30
|
+
const { add, remove, mode, local, ...rest } = change;
|
|
31
|
+
if (Object.keys(rest).length > 0)
|
|
32
|
+
return null;
|
|
33
|
+
const adds = hostList(add), removes = hostList(remove);
|
|
34
|
+
if (adds === null || removes === null || adds.some(one => removes.includes(one)))
|
|
35
|
+
return null;
|
|
36
|
+
if (mode !== undefined && mode !== null && mode !== "open" && mode !== "allowlist")
|
|
37
|
+
return null;
|
|
38
|
+
if (local !== undefined && local !== null && local !== "any" && local !== "proxy-only")
|
|
39
|
+
return null;
|
|
40
|
+
return { add: adds, remove: removes, mode: mode ?? null, local: local ?? null };
|
|
41
|
+
}
|
|
42
|
+
function changeWords(change, after) {
|
|
43
|
+
const words = [];
|
|
44
|
+
if (change.mode === "open")
|
|
45
|
+
words.push("Let builds reach any host");
|
|
46
|
+
if (change.mode === "allowlist")
|
|
47
|
+
words.push("Limit builds to the listed hosts");
|
|
48
|
+
if (change.add.length > 0)
|
|
49
|
+
words.push(`Allow ${change.add.join(", ")}`);
|
|
50
|
+
if (change.remove.length > 0)
|
|
51
|
+
words.push(`Stop allowing ${change.remove.join(", ")}`);
|
|
52
|
+
if (change.local === "any")
|
|
53
|
+
words.push("Let builds reach this Mac's local services");
|
|
54
|
+
if (change.local === "proxy-only")
|
|
55
|
+
words.push("Stop builds reaching this Mac's local services");
|
|
56
|
+
words.push(after.mode === "open" ? "Builds may then reach any host." : after.hosts.length === 0 ? "Builds then reach no extra hosts." : `Builds may then reach ${after.hosts.join(", ")}.`);
|
|
57
|
+
return words;
|
|
58
|
+
}
|
|
59
|
+
export function networkRequestTerms(store, request, repo) {
|
|
60
|
+
if (request.kind !== "network" || request.repo !== repo)
|
|
61
|
+
return { ok: false, problem: "That request isn't about this project's network." };
|
|
62
|
+
if (request.status !== "pending")
|
|
63
|
+
return { ok: false, problem: "That request was already answered." };
|
|
64
|
+
const change = readNetworkChange(request.params);
|
|
65
|
+
if (change === null)
|
|
66
|
+
return { ok: false, problem: NETWORK_REQUEST_OLD };
|
|
67
|
+
const before = store.projectNetwork(repo);
|
|
68
|
+
const after = {
|
|
69
|
+
mode: change.mode ?? before.mode,
|
|
70
|
+
hosts: [...new Set([...before.hosts.filter(one => !change.remove.includes(one)), ...change.add])].sort(),
|
|
71
|
+
loopback: change.local ?? before.loopback,
|
|
72
|
+
};
|
|
73
|
+
if (after.hosts.length > MAX_NETWORK_HOSTS)
|
|
74
|
+
return { ok: false, problem: `A project lists at most ${MAX_NETWORK_HOSTS} hosts.` };
|
|
75
|
+
const digest = createHash("sha256").update(`toolroll:agent-network-request:${canonicalJson({ v: 1, id: request.id, repo, kind: "network", change, before, after })}`, "utf8").digest("hex").slice(0, 32);
|
|
76
|
+
const requester = typeof request.requester === "string" ? request.requester.slice(0, 80) : "Agent";
|
|
77
|
+
const why = typeof request.why === "string" ? request.why.slice(0, 600) : "";
|
|
78
|
+
return { ok: true, terms: { id: request.id, repo, requester, why, change, before, after, digest, words: changeWords(change, after) } };
|
|
79
|
+
}
|
|
80
|
+
export function pendingNetworkRequests(store, repo) {
|
|
81
|
+
const databaseFile = store.databaseFile();
|
|
82
|
+
if (databaseFile === null)
|
|
83
|
+
return [];
|
|
84
|
+
return listAgentRequests(databaseFile, { status: "pending", repo }).flatMap(one => {
|
|
85
|
+
const read = networkRequestTerms(store, one, repo);
|
|
86
|
+
return read.ok ? [read.terms] : [];
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
export function approveNetworkRequest(store, input) {
|
|
90
|
+
const databaseFile = store.databaseFile();
|
|
91
|
+
if (databaseFile === null)
|
|
92
|
+
return { ok: false, problem: "That request isn't available." };
|
|
93
|
+
const done = store.transact(() => {
|
|
94
|
+
const request = listAgentRequests(databaseFile).find(one => one.id === input.id);
|
|
95
|
+
if (request === undefined)
|
|
96
|
+
return { ok: false, problem: "That request isn't available." };
|
|
97
|
+
const read = networkRequestTerms(store, request, input.repo);
|
|
98
|
+
if (!read.ok)
|
|
99
|
+
return read;
|
|
100
|
+
if (read.terms.digest !== input.digest)
|
|
101
|
+
return { ok: false, problem: NETWORK_REQUEST_CHANGED };
|
|
102
|
+
store.setProjectNetwork(input.repo, read.terms.after, input.by, input.now);
|
|
103
|
+
return { ok: true, terms: read.terms, waiting: proposeNetworkChanges(store, input.repo, input.now) };
|
|
104
|
+
});
|
|
105
|
+
if (done.ok)
|
|
106
|
+
resolveAgentRequest(databaseFile, input.id, "approved", done.terms.words.join(" · "), input.now);
|
|
107
|
+
return done;
|
|
108
|
+
}
|