toolroll 0.9.108 → 0.9.110
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 +69 -0
- package/dist/advanced-view.js +0 -1
- package/dist/agent-detect.js +244 -0
- package/dist/agent-fence.js +47 -5
- package/dist/agent-state.js +5 -2
- package/dist/agentconfig.js +2 -2
- package/dist/approval-summary.js +344 -0
- package/dist/assignment-ui.js +5 -5
- package/dist/assignment.js +5 -2
- package/dist/attest.js +2 -2
- package/dist/browser/terminal.js +1 -1
- package/dist/browser/workspace.css +2 -2
- package/dist/browser/workspace.js +37 -34
- package/dist/browser-crew.js +4 -4
- package/dist/browser-workspace.js +4 -11
- package/dist/builder.js +45 -3
- package/dist/chat-actions.js +24 -17
- package/dist/chat-controls.js +6 -5
- package/dist/chat-core.js +3 -1
- package/dist/chat-decide.js +102 -47
- package/dist/chat-delivery-state.js +2 -0
- package/dist/chat-delivery.js +3 -2
- package/dist/chat-live.js +2 -1
- package/dist/chat-quiet.js +3 -3
- package/dist/chat-task-actions.js +6 -0
- package/dist/chat-voice.js +2 -2
- package/dist/check-report.js +1 -1
- package/dist/cli-help.js +12 -13
- package/dist/cli.js +6 -3
- package/dist/console-chrome.js +10 -3
- package/dist/console-instance.js +10 -1
- package/dist/contracts/console-api.js +14 -8
- package/dist/contracts/engine-api.js +271 -0
- package/dist/contracts/handoff.js +4 -0
- package/dist/coordinator.js +2 -2
- package/dist/decision.js +17 -0
- package/dist/demo-chat.js +1 -1
- package/dist/demo.js +6 -0
- package/dist/design/kit.js +4 -3
- package/dist/discord-api.js +4 -3
- package/dist/discord-chat.js +3 -1
- package/dist/dispatch.js +3 -8
- package/dist/easy-start-args.js +7 -3
- package/dist/easy-start.js +25 -0
- package/dist/egress.js +72 -10
- package/dist/engine-handoff.js +34 -0
- package/dist/engine-reads.js +261 -0
- package/dist/eval-world.js +3 -2
- package/dist/evidence.js +2 -0
- package/dist/fast-start.js +55 -14
- package/dist/fast-terms.js +2 -2
- package/dist/first-run.js +10 -2
- package/dist/flexible-agents.js +234 -0
- package/dist/flexible-answers-schema.js +61 -0
- package/dist/flexible-answers.js +889 -0
- package/dist/flexible-available.js +1 -0
- package/dist/flexible-custody.js +494 -0
- package/dist/flexible-import.js +782 -0
- package/dist/flexible-launch-schema.js +72 -0
- package/dist/flexible-launch.js +331 -0
- package/dist/flexible-launcher.js +88 -0
- package/dist/flexible-levels.js +34 -0
- package/dist/flexible-merge-guard.js +47 -0
- package/dist/flexible-refs.js +47 -0
- package/dist/flexible-relay-cancel.js +19 -0
- package/dist/flexible-relay-schema.js +55 -0
- package/dist/flexible-relay-upstreams.js +36 -0
- package/dist/flexible-relay.js +1032 -0
- package/dist/flexible-schema.js +32 -0
- package/dist/flexible-session.js +732 -0
- package/dist/flexible-ship-schema.js +81 -0
- package/dist/flexible-ship.js +694 -0
- package/dist/flexible-start.js +80 -0
- package/dist/flexible-thread-schema.js +30 -0
- package/dist/flexible-thread.js +676 -0
- package/dist/flexible-turns-schema.js +69 -0
- package/dist/flexible-turns.js +490 -0
- package/dist/flexible-ui.js +44 -0
- package/dist/flexible.js +368 -0
- package/dist/flow-actions.js +6 -4
- package/dist/flow-steps.js +1 -1
- package/dist/flows-cli.js +2 -1
- package/dist/git-views.js +44 -41
- package/dist/guides.js +11 -10
- package/dist/install-mode.js +225 -0
- package/dist/keymap.js +1 -1
- package/dist/lead-context.js +1 -1
- package/dist/lead-doors.js +7 -1
- package/dist/limits-ui.js +8 -1
- package/dist/live-bus.js +70 -13
- package/dist/live-reply.js +6 -0
- package/dist/live-terminal.js +425 -29
- package/dist/local-owner.js +6 -0
- package/dist/model-choices.js +12 -6
- package/dist/needs-you.js +3 -3
- package/dist/nightly-github.js +2 -2
- package/dist/notification-delivery.js +11 -0
- package/dist/operate.js +185 -33
- package/dist/outbound-privacy.js +204 -0
- package/dist/passwordless.js +2 -1
- package/dist/project-delete-ui.js +2 -1
- package/dist/project-delete.js +15 -0
- package/dist/provider-auth.js +1 -1
- package/dist/provider-connection.js +5 -3
- package/dist/publish.js +5 -0
- package/dist/pull-request-flow.js +26 -7
- package/dist/push.js +5 -1
- package/dist/release-card.js +11 -3
- package/dist/release.js +11 -1
- package/dist/result-actions.js +3 -0
- package/dist/result-evidence-readers.js +8 -2
- package/dist/result-review.js +20 -9
- package/dist/route-store.js +2 -2
- package/dist/sandbox-launch.js +32 -8
- package/dist/sandbox-runtime.js +16 -7
- package/dist/sandbox-tools.js +176 -0
- package/dist/scope.js +12 -36
- package/dist/scout-net.js +7 -2
- package/dist/serve.js +90 -40
- package/dist/server/chat.js +9 -9
- package/dist/server/chrome.js +19 -17
- package/dist/server/console.css +33 -6
- package/dist/server/engine-api.js +378 -0
- package/dist/server/flows.js +2 -2
- package/dist/server/guards.js +10 -4
- package/dist/server/home.js +37 -5
- package/dist/server/http.js +11 -2
- package/dist/server/in-place.js +5 -4
- package/dist/server/kit.js +2 -2
- package/dist/server/link-redemption.js +52 -0
- package/dist/server/live.js +100 -10
- package/dist/server/mutation-key.js +21 -7
- package/dist/server/pages.js +129 -74
- package/dist/server/people-tokens.js +17 -41
- package/dist/server/render-chat.js +2 -1
- package/dist/server/render-history.js +18 -4
- package/dist/server/render-new-task.js +4 -4
- package/dist/server/render-pages.js +21 -39
- package/dist/server/render-people.js +2 -2
- package/dist/server/render-projects.js +5 -5
- package/dist/server/render-results.js +30 -14
- package/dist/server/render-tasks.js +155 -155
- package/dist/server/retired-routes.js +37 -4
- package/dist/server/route-policy.js +8 -0
- package/dist/server/route-table.js +43 -5
- package/dist/server/settings-computers.js +140 -0
- package/dist/server/settings-scripts.js +15 -0
- package/dist/server/settings-section-table.js +59 -0
- package/dist/server/settings-sections.js +291 -0
- package/dist/server/settings.js +247 -28
- package/dist/server/task-views.js +55 -15
- package/dist/server/tasks.js +168 -98
- package/dist/server/terminals.js +181 -28
- package/dist/server/welcome.js +40 -14
- package/dist/settings-groups-ui.js +26 -107
- package/dist/settings-proofs.js +18 -11
- package/dist/slack-api.js +4 -3
- package/dist/slack-chat.js +5 -3
- package/dist/spend.js +46 -12
- package/dist/sqlite-telemetry.js +70 -21
- package/dist/status-probe.js +343 -0
- package/dist/store.js +206 -10
- package/dist/task-link.js +64 -0
- package/dist/teams-api.js +4 -3
- package/dist/teams-chat.js +4 -2
- package/dist/telegram-lead.js +2 -1
- package/dist/telegram-live.js +2 -1
- package/dist/telegram-team.js +2 -1
- package/dist/telegram.js +17 -5
- package/dist/trusted-path.js +162 -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-launch.js +282 -0
- package/dist/tui-source.js +5 -3
- package/dist/tui.js +2 -2
- package/dist/typed-words-schema.js +18 -0
- package/dist/webhooks.js +8 -4
- package/dist/welcome-facts.js +25 -17
- package/dist/work-index.js +126 -29
- package/dist/work-reads.js +279 -0
- package/dist/workspace-ui.js +5 -0
- package/package.json +4 -2
- package/scripts/crash-canary.mjs +1 -1
- package/scripts/pilot.mjs +1 -1
- package/scripts/provider-canary.mjs +5 -3
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ACCENT_PRESETS, accentNote } from "./accent-colors.js";
|
|
2
1
|
import {} from "./browser-workspace.js";
|
|
3
2
|
import { SETTINGS_GROUP_ICONS, SETTINGS_GROUPS, plural } from "./design/kit.js";
|
|
4
3
|
import { digestTimes } from "./digest-times.js";
|
|
@@ -8,11 +7,11 @@ import {} from "./scope.js";
|
|
|
8
7
|
import { qualityModeTitle } from "./quality.js";
|
|
9
8
|
import {} from "./store.js";
|
|
10
9
|
import { kitSectionForm, SECRET_OPT_OUTS } from "./settings-kit.js";
|
|
11
|
-
import {
|
|
10
|
+
import { START_BUILDER_HREF } from "./needs-you.js";
|
|
12
11
|
import { btn, chip, codeLine, disclose, formRow, infoLine, input, needsPanel, note, notice, radios, select, settingsLink, settingsLinks, settingsRecord, settingsSection, settingsShell, switchInput, } from "./server/kit.js";
|
|
13
12
|
export const GROUP_PATHS = {
|
|
14
|
-
"/settings": "hub", "/settings/
|
|
15
|
-
"/settings/projects": "projects", "/settings/access": "access", "/settings/system": "system",
|
|
13
|
+
"/settings": "hub", "/settings/agents": "agents", "/settings/alerts": "alerts",
|
|
14
|
+
"/settings/projects": "projects", "/settings/access": "access", "/settings/system": "system",
|
|
16
15
|
};
|
|
17
16
|
const CHAT_APPS = [["telegram", "Telegram"], ["slack", "Slack"], ["discord", "Discord"], ["teams", "Teams"]];
|
|
18
17
|
const and = (names) => names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names[0] ?? "";
|
|
@@ -23,8 +22,8 @@ const answered = (facts) => facts.problem ? notice(sentence(facts.problem)) : fa
|
|
|
23
22
|
export function settingsNeeds(facts) {
|
|
24
23
|
const out = [];
|
|
25
24
|
if (facts.workers !== null && facts.approver && !facts.workers.some(one => one.tone === "ok")) {
|
|
26
|
-
out.push({ group: "
|
|
27
|
-
text: "Approved work waits until a computer builds it. Run toolroll up on the computer with your projects.", action: ["Start taking work",
|
|
25
|
+
out.push({ group: "computers", title: facts.workers.length === 0 ? "Nothing is taking work" : "Nothing is taking work right now",
|
|
26
|
+
text: "Approved work waits until a computer builds it. Run toolroll up on the computer with your projects.", action: ["Start taking work", START_BUILDER_HREF] });
|
|
28
27
|
}
|
|
29
28
|
if (facts.telegram.failing)
|
|
30
29
|
out.push({ group: "alerts", title: "Telegram isn’t delivering", text: facts.telegram.delivery ?? "Alerts to your phone are failing.", action: ["Open Telegram", "/settings/telegram"] });
|
|
@@ -38,13 +37,17 @@ export function needsByGroup(items) {
|
|
|
38
37
|
out[item.group] = (out[item.group] ?? 0) + 1;
|
|
39
38
|
return out;
|
|
40
39
|
}
|
|
41
|
-
const flagsOf = (counts) => Object.fromEntries(Object.keys(counts).map(key => [key, true]));
|
|
40
|
+
export const flagsOf = (counts) => Object.fromEntries(Object.keys(counts).map(key => [key, true]));
|
|
42
41
|
const themeWords = (theme) => theme === "light" ? "Light" : theme === "dark" ? "Dark" : "Match this device";
|
|
43
42
|
function agentsWords(facts) {
|
|
44
43
|
const signed = facts.providers?.find(one => one.connection !== null && one.tone === "ok") ?? facts.providers?.find(one => one.tone === "ok");
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
return signed ? `${signed.name}: ${signed.words}` : facts.providers === null ? "Models, chat and tools" : "No agent signed in yet";
|
|
45
|
+
}
|
|
46
|
+
function computersWords(facts) {
|
|
47
|
+
if (facts.workers === null)
|
|
48
|
+
return "Connect a builder: the computer that does the work";
|
|
49
|
+
const taking = facts.workers.filter(one => one.tone === "ok").length;
|
|
50
|
+
return taking === 0 ? "Nothing is taking work yet" : `${plural(taking, "computer", "computers")} taking work`;
|
|
48
51
|
}
|
|
49
52
|
function alertsWords(facts) {
|
|
50
53
|
const configured = facts.messaging?.configured ?? [];
|
|
@@ -71,26 +74,19 @@ function systemWords(facts) {
|
|
|
71
74
|
}
|
|
72
75
|
function localModeSection(facts) {
|
|
73
76
|
const local = facts.local;
|
|
74
|
-
if (local === undefined || local === null)
|
|
75
|
-
return html ``;
|
|
76
|
-
if (local.owner) {
|
|
77
|
-
return local.passwordSet ? html `` : settingsSection({ id: "set-password", title: "Let agents work on their own",
|
|
78
|
-
lead: "Agents can work on their own, merge and release only after you set a password.",
|
|
79
|
-
body: html `<div class="k-acts">${btn("Set a password", { sm: true, href: "/password/set?next=%2Fsettings" })}</div>` });
|
|
80
|
-
}
|
|
81
|
-
if (!local.canTurnOff)
|
|
77
|
+
if (local === undefined || local === null || !local.owner || local.passwordSet)
|
|
82
78
|
return html ``;
|
|
83
|
-
return settingsSection({ id: "
|
|
84
|
-
lead: "
|
|
85
|
-
body:
|
|
86
|
-
confirm: "Turn off local mode", body: html `` }) });
|
|
79
|
+
return settingsSection({ id: "set-password", title: "Let agents work on their own",
|
|
80
|
+
lead: "Agents can work on their own, merge and release only after you set a password.",
|
|
81
|
+
body: html `<div class="k-acts">${btn("Set a password", { sm: true, href: "/password/set?next=%2Fsettings" })}</div>` });
|
|
87
82
|
}
|
|
88
83
|
export function settingsHub(facts) {
|
|
89
84
|
const items = settingsNeeds(facts);
|
|
90
85
|
const counts = needsByGroup(items);
|
|
91
86
|
const words = {
|
|
92
|
-
general: [`Theme: ${themeWords(facts.theme).toLowerCase()}`, facts.version === null ? null : `Toolroll ${facts.version}`].filter(Boolean).join(" · "),
|
|
87
|
+
general: [`Theme: ${themeWords(facts.theme).toLowerCase()}`, facts.version === null ? null : `Toolroll ${facts.version}`, `advanced features ${advancedOn(facts) ? "on" : "off"}`].filter(Boolean).join(" · "),
|
|
93
88
|
agents: agentsWords(facts),
|
|
89
|
+
computers: computersWords(facts),
|
|
94
90
|
alerts: alertsWords(facts),
|
|
95
91
|
approval: approvalWords(facts),
|
|
96
92
|
projects: facts.projects.length === 0 ? "No projects yet" : `${plural(facts.projects.length, "project", "projects")} · network, checks, pull requests and tools for each`,
|
|
@@ -100,7 +96,6 @@ export function settingsHub(facts) {
|
|
|
100
96
|
};
|
|
101
97
|
const shown = SETTINGS_GROUPS.filter(([, slug]) => slug !== "spend" || facts.operator).filter(([, slug]) => slug !== "system" || facts.operator || facts.approver)
|
|
102
98
|
.filter(([, slug]) => slug !== "spend" || advancedOn(facts));
|
|
103
|
-
words["advanced"] = advancedWords(facts);
|
|
104
99
|
const panel = needsPanel(items.map((item, index) => ({ title: item.title, text: item.text, action: btn(item.action[0], { variant: index === 0 ? "primary" : "outline", href: item.action[1] }) })));
|
|
105
100
|
return settingsShell({
|
|
106
101
|
group: "hub", title: "Settings", flags: flagsOf(counts),
|
|
@@ -113,81 +108,24 @@ export function settingsHub(facts) {
|
|
|
113
108
|
});
|
|
114
109
|
}
|
|
115
110
|
export const HUB_ANCHORS = {
|
|
116
|
-
providers: "/settings/agents#providers", workers: "/settings/
|
|
111
|
+
providers: "/settings/agents#providers", workers: "/settings/computers#workers", email: "/settings/alerts#email", "settings-chat-apps": "/settings/alerts#chat-apps",
|
|
117
112
|
"telegram-token": "/settings/alerts#telegram-token", phone: "/settings/alerts#phone", notifications: "/settings/alerts#notifications",
|
|
118
113
|
updates: "/settings/system#updates", accent: "/settings/general#appearance", appearance: "/settings/general#appearance",
|
|
119
114
|
};
|
|
120
115
|
export const HUB_ANCHOR_SCRIPT = `(function(){var m=${JSON.stringify(HUB_ANCHORS)};var h=decodeURIComponent(location.hash.slice(1));if(Object.prototype.hasOwnProperty.call(m,h))location.replace(m[h]);})();`;
|
|
121
|
-
const ACCENT_CHOICES = ACCENT_PRESETS.slice(0, 6);
|
|
122
|
-
export function generalGroup(facts, flags) {
|
|
123
|
-
const themeButton = (value, label) => html `<button type="submit" name="theme" value="${value}" aria-pressed="${String(facts.theme === value)}">${label}</button>`;
|
|
124
|
-
const custom = ACCENT_CHOICES.some(one => one.hex === facts.accent) ? null : facts.accent;
|
|
125
|
-
const accentNoteWords = accentNote(facts.accent);
|
|
126
|
-
const appearance = settingsSection({
|
|
127
|
-
id: "appearance", title: "Appearance", state: " · saved for this browser",
|
|
128
|
-
body: joinHtml([
|
|
129
|
-
formRow("Theme", "Light, dark, or whatever this device uses.", postForm("/settings/appearance", html `<div class="k-seg" role="group" aria-label="Theme">${themeButton("system", "Match device")}${themeButton("light", "Light")}${themeButton("dark", "Dark")}</div>`, { returnTo: "/settings/general" })),
|
|
130
|
-
kitSectionForm({ proof: "appearance", action: "/settings/appearance", id: "accent", gate: true, hidden: { return: "/settings/general" },
|
|
131
|
-
body: joinHtml([
|
|
132
|
-
formRow("Accent", "Buttons, focus and what needs you.", select({ name: "accent", label: "Accent", current: facts.accent, items: [...ACCENT_CHOICES.map(one => [one.hex, one.id === "ink" ? "Ink (default)" : one.name]), ...(custom === null ? [] : [[custom, `Your own colour (${custom})`]])] })),
|
|
133
|
-
accentNoteWords === null ? "" : note(accentNoteWords),
|
|
134
|
-
]) }),
|
|
135
|
-
disclose("Use your own colour", kitSectionForm({ proof: "appearance", action: "/settings/appearance", id: "accent-own", gate: true, hidden: { return: "/settings/general" },
|
|
136
|
-
body: formRow("Your own colour", "Six hex digits, like #6e56cf.", input({ id: "accent-hex", name: "accent", value: custom ?? "", attrs: { placeholder: "#6e56cf", spellcheck: "false", autocomplete: "off", "aria-label": "Your own colour", pattern: "#?[0-9a-fA-F]{6}", required: true } })) }), custom !== null),
|
|
137
|
-
]),
|
|
138
|
-
});
|
|
139
|
-
const browser = settingsSection({
|
|
140
|
-
id: "this-browser", title: "This browser",
|
|
141
|
-
body: joinHtml([
|
|
142
|
-
formRow("Remembered password", "After you type your password, standard approvals skip it on this computer for 15 minutes. Forget ends that now.", facts.browser ? postForm("/session/forget-password", btn("Forget now", { sm: true, type: "submit" }), { returnTo: "/settings/general" }) : html ``, "inline"),
|
|
143
|
-
]),
|
|
144
|
-
});
|
|
145
|
-
const password = settingsSection({
|
|
146
|
-
id: "your-password", title: "Your password",
|
|
147
|
-
body: joinHtml([
|
|
148
|
-
formRow("Where it is", "If you started Toolroll with toolroll up, your password is saved on the computer running Toolroll. Toolroll never shows it in a browser. To read it, run this there:", html ``, "wide"),
|
|
149
|
-
codeLine("cat ~/.config/toolroll/.toolroll-secrets/up-login.txt"),
|
|
150
|
-
facts.passwordless === null ? "" : formRow("Passwordless", "Sign in once; most approvals then need no password.", btn(`${facts.passwordless ? "On" : "Off"} · Change`, { sm: true, href: "/settings/passwordless" }), "inline"),
|
|
151
|
-
]),
|
|
152
|
-
});
|
|
153
|
-
const version = facts.version === null ? "" : settingsSection({
|
|
154
|
-
id: "version", title: "Version",
|
|
155
|
-
body: joinHtml([
|
|
156
|
-
formRow("Toolroll", facts.firstResult ?? "Installed on this computer.", html `<span class="k-mono">${facts.version}</span>`, "inline"),
|
|
157
|
-
facts.operator ? formRow("Updates", null, btn("Open updates", { sm: true, variant: "ghost", href: "/settings/updates" }), "inline") : "",
|
|
158
|
-
]),
|
|
159
|
-
});
|
|
160
|
-
const withPassword = passwordFree(facts) ? [] : [browser, password];
|
|
161
|
-
return settingsShell({ group: "general", title: "General", lead: "How Toolroll looks and behaves in this browser.", flags, body: joinHtml([answered(facts), appearance, ...withPassword, version]) });
|
|
162
|
-
}
|
|
163
116
|
const toneChip = (tone, words) => chip(words, tone === "ok" ? "done" : tone === "warn" ? "failed" : "");
|
|
164
117
|
function providerRecord(one) {
|
|
165
118
|
const form = kitSectionForm({ proof: "provider-key", action: "/settings/provider-key", id: `provider-${one.provider}`, gate: true, hidden: { provider: one.provider }, save: { label: `Save ${one.name}` },
|
|
166
119
|
body: joinHtml([
|
|
167
120
|
one.connection === null ? "" : formRow("Sign-in", `${one.connection.words}${one.connection.facts ? ` · ${one.connection.facts}` : ""}`, html `<button class="k-btn k-btn-ghost k-btn-sm" type="submit" formaction="/settings/connection/check" formnovalidate><span class="k-face">Check again</span></button>`, "inline"),
|
|
168
121
|
one.subscriptionCapable ? formRow("How it’s paid", `${one.usage} · ${one.envName}`, select({ name: "auth-mode", label: `How ${one.name} is paid`, current: one.mode, items: [["subscription", `${one.name} subscription`], ["api-key", "API key"]] })) : note(`${one.usage} · ${one.envName}`),
|
|
169
|
-
formRow(`${one.name} API key`, "Stored privately on this computer and never shown again.
|
|
122
|
+
formRow(`${one.name} API key`, "Stored privately on this computer and never shown again.", html `<input class="k-input" id="key-${one.provider}" type="password" name="value" autocomplete="off" spellcheck="false" autocapitalize="none" data-so-secret data-1p-ignore data-lpignore="${SECRET_OPT_OUTS["data-lpignore"]}" data-bwignore data-form-type="other" aria-label="${one.name} API key" placeholder="${one.set ? "Paste to replace the stored key" : "Paste a key"}">`),
|
|
170
123
|
]) });
|
|
171
|
-
const remove = one.set ? kitSectionForm({ proof: "provider-key", action: "/settings/provider-key-clear", id: `provider-${one.provider}-clear`, hidden: { provider: one.provider }, save: { label: "Remove key", variant: "danger" },
|
|
124
|
+
const remove = one.set ? kitSectionForm({ proof: "provider-key-clear", action: "/settings/provider-key-clear", id: `provider-${one.provider}-clear`, hidden: { provider: one.provider }, save: { label: "Remove key", variant: "danger" },
|
|
172
125
|
body: note("Runs that use this API key stop until you add one again.") }) : "";
|
|
173
126
|
return settingsRecord({ title: html `${one.name} ${toneChip(one.tone, one.words)}`, sub: one.connection === null ? one.usage : `${one.connection.words}${one.connection.facts ? ` · ${one.connection.facts}` : ""}`,
|
|
174
127
|
attrs: { "data-provider": one.provider }, more: disclose(`Manage ${one.name}`, joinHtml([form, remove])) });
|
|
175
128
|
}
|
|
176
|
-
function workersSection(workers) {
|
|
177
|
-
return settingsSection({
|
|
178
|
-
id: "workers", title: "Builders", lead: "The computers that build approved work, and what each runs now.",
|
|
179
|
-
body: workers.length === 0
|
|
180
|
-
? joinHtml([note("No builder is connected. Run this on the computer with your projects:"), codeLine("toolroll up")])
|
|
181
|
-
: joinHtml([
|
|
182
|
-
...workers.map(one => settingsRecord({
|
|
183
|
-
title: html `<span class="k-mono">${one.name}</span> ${chip(one.state, one.tone === "ok" ? "done" : one.tone === "off" ? "failed" : "")}`,
|
|
184
|
-
sub: one.running.length === 0 ? "Nothing running" : joinHtml(one.running.map(task => html `<a class="k-link" href="${task.href}">${task.title}</a>${task.project === null ? "" : html ` <span class="k-muted">${task.project}</span>`}`), " · "),
|
|
185
|
-
when: html `<span class="k-num">${one.busy} of ${one.capacity}</span> running`, attrs: { "data-worker": one.name },
|
|
186
|
-
})),
|
|
187
|
-
note(html `To change how many a builder runs at once: <code class="k-mono">toolroll runner capacity <name> <n></code>`),
|
|
188
|
-
]),
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
129
|
export function agentsGroup(facts, flags) {
|
|
192
130
|
const providers = facts.providers === null ? "" : settingsSection({
|
|
193
131
|
id: "providers", title: "How agents are paid for", lead: "A plan first; an API key is used when the agent is set to it, or for agents without a plan. Keys stay on this computer.",
|
|
@@ -204,7 +142,7 @@ export function agentsGroup(facts, flags) {
|
|
|
204
142
|
]);
|
|
205
143
|
return settingsShell({
|
|
206
144
|
group: "agents", title: "Agents and models", lead: "Which agent does the work, how it’s paid for, and which model plans, builds and reviews.", flags,
|
|
207
|
-
body: joinHtml([answered(facts), providers, facts.workers === null ? "" :
|
|
145
|
+
body: joinHtml([answered(facts), providers, facts.workers === null ? "" : html `<div id="workers">${settingsLinks(null, [settingsLink({ href: "/settings/computers?section=builders", title: "Computers that build", status: "In Settings → Computers" })], { label: "Computers" })}</div>`, links]),
|
|
208
146
|
});
|
|
209
147
|
}
|
|
210
148
|
function chatAppsSection(facts) {
|
|
@@ -234,7 +172,7 @@ function reachSection(facts) {
|
|
|
234
172
|
const projects = (chat.projects ?? []).length === 0 ? "" : joinHtml([
|
|
235
173
|
...chat.projects.map(one => kitSectionForm({ proof: "notifications-mute", action: "/settings/notifications/mute", id: `mute-${one.repo.replace(/[^a-z0-9]+/gi, "-")}`, gate: true, hidden: { repo: one.repo },
|
|
236
174
|
body: formRow(one.name, one.muted ? "Muted: no pings" : "Pings on", switchInput({ id: `pings-${one.repo.replace(/[^a-z0-9]+/gi, "-")}`, name: "pings", label: "Pings", on: !one.muted, attrs: { "aria-label": `Pings for ${one.name}` } }), "inline") })),
|
|
237
|
-
note("Muted projects still show in
|
|
175
|
+
note("Muted projects still show in Work and the evening digest."),
|
|
238
176
|
]);
|
|
239
177
|
return settingsSection({ id: "notifications", title: "What reaches you", body: joinHtml([form, projects]) });
|
|
240
178
|
}
|
|
@@ -429,9 +367,10 @@ export function accessGroup(facts, flags) {
|
|
|
429
367
|
...(facts.operator && (advancedOn(facts) || facts.passwordless === true) ? [
|
|
430
368
|
settingsLink({ href: "/settings/passwordless", title: "Passwordless", status: facts.passwordless ? "On: signing in is the only password" : "Off: approvals ask for your password" })
|
|
431
369
|
] : []),
|
|
370
|
+
...(facts.local?.canTurnOff === true ? [html `<div id="local-mode">${settingsLink({ href: "/settings/general?section=local-mode", title: "Local mode", status: "On · in General" })}</div>`] : []),
|
|
432
371
|
];
|
|
433
372
|
return settingsShell({ group: "access", title: "People and sign-in", lead: "Who can get in, how they sign in, and the ways in they hold.", flags,
|
|
434
|
-
body: joinHtml([answered(facts),
|
|
373
|
+
body: joinHtml([answered(facts), settingsLinks(null, links, { label: "People and sign-in" })]) });
|
|
435
374
|
}
|
|
436
375
|
function updatesSection(updates) {
|
|
437
376
|
const latest = updates.latest;
|
|
@@ -458,10 +397,8 @@ export function systemGroup(facts, flags) {
|
|
|
458
397
|
...(advancedOn(facts) ? [settingsLink({ href: "/settings/monitoring", title: "Monitoring", status: "Send the audit stream and traces to your own systems" })] : []),
|
|
459
398
|
settingsLink({ href: "/settings/data", title: "Data export", status: "Everything except secrets, as one download" }),
|
|
460
399
|
settingsLink({ href: "/settings/integrations", title: "Integrations", status: "Which connected services work" }),
|
|
461
|
-
...(advancedOn(facts) ? [settingsLink({ href: "/fleet", title: "Builders", status: "Every computer that builds, on Agents" })] : []),
|
|
462
400
|
]) : settingsLinks("In this group", [
|
|
463
401
|
settingsLink({ href: "/settings/integrations", title: "Integrations", status: "Which connected services work" }),
|
|
464
|
-
...(advancedOn(facts) ? [settingsLink({ href: "/fleet", title: "Builders", status: "Every computer that builds" })] : []),
|
|
465
402
|
]);
|
|
466
403
|
return settingsShell({ group: "system", title: "System", lead: "This Toolroll’s version, backups, storage and what leaves this computer.", flags,
|
|
467
404
|
body: joinHtml([answered(facts), facts.updates === null ? "" : updatesSection(facts.updates), links]) });
|
|
@@ -470,13 +407,11 @@ export function settingsGroupPage(group, facts) {
|
|
|
470
407
|
const flags = flagsOf(needsByGroup(settingsNeeds(facts)));
|
|
471
408
|
switch (group) {
|
|
472
409
|
case "hub": return settingsHub(facts);
|
|
473
|
-
case "general": return generalGroup(facts, flags);
|
|
474
410
|
case "agents": return agentsGroup(facts, flags);
|
|
475
411
|
case "alerts": return alertsGroup(facts, flags);
|
|
476
412
|
case "projects": return projectsGroup(facts, flags);
|
|
477
413
|
case "access": return accessGroup(facts, flags);
|
|
478
414
|
case "system": return systemGroup(facts, flags);
|
|
479
|
-
case "advanced": return advancedGroup(facts, flags);
|
|
480
415
|
case "approval": return settingsHub(facts);
|
|
481
416
|
}
|
|
482
417
|
}
|
|
@@ -616,19 +551,3 @@ function passwordFree(facts) {
|
|
|
616
551
|
return facts.local?.owner === true && !facts.local.passwordSet;
|
|
617
552
|
}
|
|
618
553
|
function advancedOn(facts) { return facts.advanced === undefined || facts.advanced.on; }
|
|
619
|
-
function advancedWords(facts) {
|
|
620
|
-
return advancedOn(facts) ? "On: every page shows in the menus" : "Off: menus show only the main steps";
|
|
621
|
-
}
|
|
622
|
-
export function advancedGroup(facts, flags) {
|
|
623
|
-
const on = advancedOn(facts);
|
|
624
|
-
const change = facts.advanced?.canChange === true
|
|
625
|
-
? postForm("/settings/advanced", btn(on ? "Turn off" : "Turn on", { sm: true, type: "submit" }), { hidden: { advanced: on ? "off" : "on" } })
|
|
626
|
-
: html ``;
|
|
627
|
-
const toggle = settingsSection({ id: "show-advanced", title: "Show advanced features", state: on ? " · on" : " · off", right: change,
|
|
628
|
-
lead: "Flows, other computers, spend limits, operating modes and the rest, in your menus. They keep working either way, and each opens from below.",
|
|
629
|
-
body: html `` });
|
|
630
|
-
const pages = ADVANCED_PAGES.filter(one => one.operator !== true || facts.operator)
|
|
631
|
-
.map(one => settingsLink({ href: one.href, title: one.title, status: one.words }));
|
|
632
|
-
return settingsShell({ group: "advanced", title: "Advanced", lead: "Everything beyond filing, approving and accepting work.", flags,
|
|
633
|
-
body: joinHtml([answered(facts), toggle, settingsLinks("Advanced pages", pages)]) });
|
|
634
|
-
}
|
package/dist/settings-proofs.js
CHANGED
|
@@ -11,15 +11,14 @@ export const PROOF_INVENTORY = [
|
|
|
11
11
|
{ id: "notifications-mute", action: "Mute a project", routes: ["/settings/notifications/mute"], form: "notificationsMute", field: null, proof: "none", ...NONE, role: "any", secrets: [], terms: [] },
|
|
12
12
|
{ id: "messaging", action: "Choose the chat app that receives alerts", routes: ["/settings/messaging"], form: "messaging", field: null, proof: "none", ...NONE, role: "any", secrets: [], terms: [] },
|
|
13
13
|
{ id: "telegram-digest", action: "Set the Telegram digest", routes: ["/settings/telegram-digest"], form: "telegramDigest", field: null, proof: "none", ...NONE, role: "any", secrets: [], terms: [] },
|
|
14
|
-
{ id: "provider-key", action: "
|
|
15
|
-
{ id: "
|
|
16
|
-
{ id: "
|
|
17
|
-
{ id: "google", action: "Connect or disconnect Google", routes: ["/settings/google", "/settings/google/disconnect"], form: "google", field: null, proof: "none", ...NONE, role: "any", secrets: ["clientSecret"], terms: [] },
|
|
14
|
+
{ id: "provider-key-clear", action: "Clear an AI provider key", routes: ["/settings/provider-key-clear"], form: "providerKey", field: null, proof: "none", ...NONE, role: "any", secrets: [], terms: [] },
|
|
15
|
+
{ id: "email-test", action: "Test email", routes: ["/settings/email-test", "/settings/email-read-test"], form: "email", field: null, proof: "none", ...NONE, role: "any", secrets: [], terms: [] },
|
|
16
|
+
{ id: "google-disconnect", action: "Disconnect Google", routes: ["/settings/google/disconnect"], form: "google", field: null, proof: "none", ...NONE, role: "any", secrets: [], terms: [] },
|
|
18
17
|
{ id: "appearance", action: "Change the theme or accent", routes: ["/settings/appearance"], form: "appearance", field: null, proof: "none", ...NONE, role: "any", secrets: [], terms: [] },
|
|
19
18
|
{ id: "chat-approval-confirm", action: "Review approving from chat", routes: ["/settings/chat-approval/confirm", "/settings/chat-approval/off"], form: "chatApproval", field: null, proof: "none", ...NONE, role: "approver", secrets: [], terms: [] },
|
|
20
19
|
{ id: "models-rules-off", action: "Turn an earned rule off, stop a trial, say Not now, or turn suggestions off", routes: ["/settings/models/turn-off", "/settings/models/not-now", "/settings/models/suggest-off", "/settings/models/stop"], form: "modelsRules", field: null, proof: "none", ...NONE, role: "operator", secrets: [], terms: [] },
|
|
21
20
|
...CHAT_APPS.map(([app, name, form]) => ({ id: `${app}-alerts`, action: `Send alerts to ${name}`, routes: [`/settings/${app}/alerts`], form, field: null, proof: "none", ...NONE, role: "approver", secrets: [], terms: [] })),
|
|
22
|
-
{ id: "permission-default", action: "Start new tasks with Full access", routes: ["/settings/permission-default"], form: "permissionDefault", field: "password", proof: "
|
|
21
|
+
{ id: "permission-default", action: "Start new tasks with Full access", routes: ["/settings/permission-default"], form: "permissionDefault", field: "password", proof: "credential", when: "only when widening to Full access", ...CREDENTIAL, role: "any", secrets: [], terms: [] },
|
|
23
22
|
{ id: "spend-budget", action: "Set a monthly limit", routes: ["/spend/budget"], form: "spendBudget", field: "password", proof: "step-up", ...ACCEPT, role: "operator", secrets: [], terms: [] },
|
|
24
23
|
{ id: "models-agent", action: "Change which model does each job", routes: ["/settings/models/agent"], form: "modelsChange", field: "password", proof: "step-up", ...ACCEPT, role: "operator", secrets: [], terms: ["scope", "digest"] },
|
|
25
24
|
{ id: "models-rules", action: "Accept a suggested model, try a cheaper one, keep a paused rule, or turn suggestions on", routes: ["/settings/models/accept", "/settings/models/keep", "/settings/models/suggest-on", "/settings/models/try"], form: "modelsRules", field: "password", proof: "step-up", ...ACCEPT, role: "operator", secrets: [], terms: ["scope", "id", "rule"], note: "the rule door re-proves the session and its generation in the write" },
|
|
@@ -33,9 +32,9 @@ export const PROOF_INVENTORY = [
|
|
|
33
32
|
["data", "Download everything", "data", "operator"],
|
|
34
33
|
].map(([path, action, form, role]) => ({ id: path, action, routes: [`/settings/${path}`], form, field: "password", proof: "step-up", ...ACCEPT, role, secrets: [], terms: path === "approval" ? ["repo"] : [] })),
|
|
35
34
|
{ id: "pull-requests", action: "Change pull-request settings, or turn them off", routes: ["/settings/pull-requests"], form: "pullRequests", field: "password", proof: "step-up", ...ACCEPT, role: "any", handlerRole: "an approver of the project", secrets: [], terms: ["repo", "act"] },
|
|
36
|
-
{ id: "pull-requests-on", action: "Turn pull requests on", routes: ["/settings/pull-requests"], select: { field: "act", value: "on" }, form: "pullRequests", field: "password", proof: "
|
|
35
|
+
{ id: "pull-requests-on", action: "Turn pull requests on", routes: ["/settings/pull-requests"], select: { field: "act", value: "on" }, form: "pullRequests", field: "password", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver of the project", secrets: [], terms: ["repo", "act", "github", "base"], note: "`github` and `base` are what the page showed; the handler checks again and refuses a difference" },
|
|
37
36
|
{ id: "checks", action: "Change checks", routes: ["/settings/checks"], form: "checks", field: "password", proof: "step-up", ...ACCEPT, role: "any", handlerRole: "an approver of the project", secrets: [], terms: ["repo", "act"] },
|
|
38
|
-
{ id: "monitoring", action: "Change monitoring", routes: ["/settings/monitoring"], form: "monitoring", field: "password", proof: "
|
|
37
|
+
{ id: "monitoring", action: "Change monitoring", routes: ["/settings/monitoring"], form: "monitoring", field: "password", proof: "credential", ...CREDENTIAL, role: "operator", secrets: ["header-value"], terms: [] },
|
|
39
38
|
{ id: "updates", action: "Update Toolroll", routes: ["/settings/updates", "/settings/updates/seen", "/settings/updates/cancel"], form: "updates", field: "password", proof: "step-up", ...ACCEPT, role: "operator", secrets: [], terms: [] },
|
|
40
39
|
{ id: "storage-cleanup", action: "Choose when checkouts are removed", routes: ["/settings/storage"], form: "storage", field: "password", proof: "step-up", ...ACCEPT, role: "operator", secrets: [], terms: [] },
|
|
41
40
|
{ id: "storage-clean", action: "Clean up checkouts", routes: ["/settings/storage/clean"], form: "storage", field: "password", proof: "step-up", ...ACCEPT, role: "operator", secrets: [], terms: ["preview"], note: "`preview` is the digest of what the page showed; a changed list is refused" },
|
|
@@ -43,19 +42,26 @@ export const PROOF_INVENTORY = [
|
|
|
43
42
|
{ id: "storage-discard", action: "Discard a checkout", routes: ["/settings/storage/discard"], form: "storage", field: "password", proof: "step-up", ...ACCEPT, role: "operator", secrets: [], terms: ["path"] },
|
|
44
43
|
{ id: "project-live-view", action: "Show a project's commands in the live view", routes: ["/settings/project/live-view"], form: "projectLiveView", field: "password", proof: "step-up", ...ACCEPT, role: "any", handlerRole: "an approver of the project", secrets: [], terms: ["repo", "nonce"] },
|
|
45
44
|
{ id: "project-delete", action: "Delete a project", routes: ["/settings/project/delete"], form: "projectDelete", field: "password", proof: "step-up", ...ACCEPT, role: "operator", secrets: [], terms: ["repo", "step"], note: "the project's name typed too" },
|
|
46
|
-
{ id: "tools-connect", action: "Connect a tool", routes: ["/settings/tools/connect"], form: "toolsConnect", field: "password", proof: "
|
|
47
|
-
{ id: "tools-change", action: "Change a project's tools", routes: ["/settings/tools/change"], form: "toolsChange", field: "password", proof: "
|
|
45
|
+
{ id: "tools-connect", action: "Connect a tool", routes: ["/settings/tools/connect"], form: "toolsConnect", field: "password", proof: "credential", ...CREDENTIAL, role: "approver", secrets: [], terms: ["repo", "shown"], note: "`shown` is the project the page showed (a post from another project is refused), not a digest" },
|
|
46
|
+
{ id: "tools-change", action: "Change a project's tools", routes: ["/settings/tools/change"], form: "toolsChange", field: "password", proof: "credential", when: "only to add a tool (catalog, custom, import) or set a secret", ...CREDENTIAL, role: "approver", secrets: ["value"], terms: ["repo", "shown", "action"] },
|
|
48
47
|
...CHAT_APPS.map(([app, name, form]) => ({ id: `${app}-close`, action: `Unpair or disconnect ${name}`, routes: [`/settings/${app}/unpair`, `/settings/${app}/disconnect`], form, field: "password", proof: "step-up", ...ACCEPT, role: "approver", secrets: [], terms: [] })),
|
|
49
48
|
{ id: "telegram-unpair", action: "Unpair your phone from Telegram", routes: ["/settings/telegram/unpair"], form: "telegramPair", field: "password", proof: "step-up", ...ACCEPT, role: "approver", secrets: [], terms: [] },
|
|
50
49
|
{ id: "people-close", action: "Cancel an invite or remove a person", routes: ["/people/invite-revoke", "/people/revoke"], form: "peopleRevoke", field: "token", proof: "step-up", ...ACCEPT, role: "any", handlerRole: "an approver", secrets: [], terms: [] },
|
|
51
50
|
{ id: "project-setup", action: "Approve project setup", routes: ["/control/setup-approve"], form: "projectSetup", field: "token", proof: "step-up", ...ACCEPT, role: "any", handlerRole: "an approver of the project; models for a new installation need an instance operator", secrets: [], terms: ["repo", "nonce", "fingerprint", "provider", "model", "command", "seconds"], note: "the nonce is spent before the password is checked: after a refusal, review again; the reviewed inputs are previewed again and must match the fingerprint" },
|
|
52
51
|
{ id: "project-instructions", action: "Add the agent instructions", routes: ["/control/instructions-approve"], form: "projectSetup", field: "token", proof: "step-up", ...ACCEPT, role: "any", handlerRole: "an approver of the project", secrets: [], terms: ["repo", "nonce", "fingerprint"], note: "the nonce is spent before the password is checked" },
|
|
52
|
+
{ id: "runner-retire", action: "Retire a computer that builds", routes: ["/fleet/runner/retire"], form: "runnerRetire", field: "token", proof: "step-up", ...ACCEPT, role: "any", handlerRole: "an approver, from a browser", secrets: [], terms: ["name"] },
|
|
53
53
|
{ id: "local-mode-off", action: "Turn off local mode", routes: ["/settings/local-mode/off"], form: "localModeOff", field: "password", proof: "step-up", ...ACCEPT, role: "operator", handlerRole: "a full session (never the local owner)", secrets: [], terms: [] },
|
|
54
54
|
{ id: "mode-sign", action: "Sign an operating mode", routes: ["/mode/sign"], form: "mode", field: "token", proof: "step-up", ...ACCEPT, role: "any", handlerRole: "an approver of the project", secrets: [], terms: MODE_TERMS },
|
|
55
55
|
{ id: "mode-sign-chat-approve", action: "Sign an operating mode that lets your chat app approve", routes: ["/mode/sign"], select: { field: "chat-approve", value: "1" }, form: "mode", field: "token", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver of the project", secrets: [], terms: MODE_TERMS },
|
|
56
56
|
{ id: "mode-sign-repair", action: "Sign an operating mode that repairs failed checks by itself", routes: ["/mode/sign"], select: { field: "repair-auto", value: "1" }, form: "mode", field: "token", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver of the project", secrets: [], terms: MODE_TERMS },
|
|
57
|
+
{ id: "install-solo", action: "Say it's just you", routes: ["/settings/install-mode/solo"], form: "justMe", field: "password", proof: "credential", ...CREDENTIAL, role: "operator", handlerRole: "a full session (never the local owner)", secrets: [], terms: [] },
|
|
58
|
+
{ id: "provider-key", action: "Save an AI provider key", routes: ["/settings/provider-key"], form: "providerKey", field: "password", proof: "credential", ...CREDENTIAL, role: "any", secrets: ["value"], terms: [] },
|
|
59
|
+
{ id: "telegram-token", action: "Save the Telegram bot token", routes: ["/settings/telegram-token"], form: "telegramToken", field: "password", proof: "credential", ...CREDENTIAL, role: "any", secrets: ["token"], notProof: ["token"], terms: [] },
|
|
60
|
+
{ id: "email", action: "Set up email", routes: ["/settings/email"], form: "email", field: "token", proof: "credential", ...CREDENTIAL, role: "any", secrets: ["password"], notProof: ["password"], terms: [] },
|
|
61
|
+
{ id: "google", action: "Connect Google", routes: ["/settings/google"], form: "google", field: "password", proof: "credential", ...CREDENTIAL, role: "any", secrets: ["clientSecret"], terms: [] },
|
|
57
62
|
{ id: "passwordless-on", action: "Turn Passwordless on", routes: ["/settings/passwordless"], form: "passwordless", field: "password", proof: "credential", when: "only to turn it on (off needs nothing)", ...CREDENTIAL, role: "operator", secrets: [], terms: [] },
|
|
58
63
|
{ id: "sign-in", action: "Change sign-in (SSO)", routes: ["/settings/sign-in"], form: "signIn", field: "password", proof: "credential", when: "every action except Test", ...CREDENTIAL, role: "operator", secrets: ["client-secret"], terms: [] },
|
|
64
|
+
{ id: "project-flexible", action: "Turn on Flexible", routes: ["/settings/project/flexible"], form: "projectFlexible", field: "password", proof: "credential", when: "only to turn it on (lowering and turning off need nothing)", ...CREDENTIAL, role: "approver", handlerRole: "an approver of the project", secrets: [], terms: ["repo", "action", "digest"], note: "`digest` is the terms the page showed; the handler rebuilds them and refuses a difference" },
|
|
59
65
|
{ id: "release-approval", action: "Approve releases automatically", routes: ["/settings/release-approval"], form: "releaseApproval", field: "password", proof: "credential", when: "only to approve automatically (Ask me needs nothing)", ...CREDENTIAL, role: "approver", handlerRole: "an approver of the project", secrets: [], terms: ["repo"] },
|
|
60
66
|
{ id: "project-network", action: "Change what builds may reach", routes: ["/settings/project/network"], form: "projectNetwork", field: "password", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver of the project", secrets: [], terms: ["repo"] },
|
|
61
67
|
{ id: "project-fallback", action: "Change a project's fallback agents", routes: ["/settings/project/fallback"], form: "projectFallback", field: "password", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver of the project", secrets: [], terms: [] },
|
|
@@ -64,8 +70,9 @@ export const PROOF_INVENTORY = [
|
|
|
64
70
|
{ id: "project-check-access", action: "Narrow how far checks reach", routes: ["/settings/project/check-access"], form: "projectCheckAccess", field: "password", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver of the project", secrets: [], terms: ["repo"], note: "for a form that can only narrow; one that offers a wider level uses project-check-access-widen" },
|
|
65
71
|
{ id: "project-check-access-widen", action: "Widen how far checks reach", routes: ["/settings/project/check-access"], explicit: true, form: "projectCheckAccess", field: "password", proof: "typed-now-operator", ...TYPED, role: "any", handlerRole: "an instance operator", secrets: [], terms: ["repo"], note: "the server decides whether a choice widens; a form offering any wider level asks for this proof" },
|
|
66
72
|
...CHAT_APPS.map(([app, name, form, secrets]) => ({ id: `${app}-open`, action: `Connect or pair ${name}`, routes: [`/settings/${app}/connect`, `/settings/${app}/pair`], form, field: "password", proof: "credential", ...CREDENTIAL, role: "approver", secrets, terms: [] })),
|
|
67
|
-
{ id: "sessions-token", action: "Make an API token", routes: ["/settings/sessions"], form: "sessions", field: "password", proof: "credential", when: "only to make a token (ending sessions and revoking tokens need nothing)", ...CREDENTIAL, role: "any", secrets: [], notProof: ["token"], terms: [], note: "`token` here names an API token to revoke" },
|
|
68
|
-
{ id: "people-invite", action: "Invite someone", routes: ["/people/invite"], form: "peopleInvite", field: "token", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver", secrets: [], terms: [] },
|
|
73
|
+
{ id: "sessions-token", action: "Make an API token", routes: ["/settings/sessions"], form: "sessions", field: "password", proof: "credential", when: "only to make a token (ending sessions and revoking tokens need nothing)", ...CREDENTIAL, role: "any", secrets: [], notProof: ["token"], terms: [], reveal: "once", note: "`token` here names an API token to revoke" },
|
|
74
|
+
{ id: "people-invite", action: "Invite someone", routes: ["/people/invite"], form: "peopleInvite", field: "token", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver", secrets: [], terms: [], reveal: "once" },
|
|
75
|
+
{ id: "runner-register", action: "Register a computer that builds", routes: ["/fleet/runner/register"], form: "runnerRegister", field: "token", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver, from a browser", secrets: [], terms: ["nonce"], reveal: "once", note: "`token` is the person's own password; `nonce` is the register document's one-use form token (spent before the password is checked: after a refusal, register again from the document); the worker's new token is shown once on the answer and only its hash is kept" },
|
|
69
76
|
{ id: "people-projects", action: "Change a person's projects", routes: ["/people/projects"], form: "peopleProjects", field: "token", proof: "credential", ...CREDENTIAL, role: "operator", secrets: [], terms: ["name"] },
|
|
70
77
|
{ id: "telegram-pair", action: "Pair your phone with Telegram", routes: ["/settings/telegram/pair"], form: "telegramPair", field: "password", proof: "typed-password", ...TYPED, role: "approver", secrets: [], terms: [] },
|
|
71
78
|
{ id: "chat-approval-save", action: "Turn on approving from chat", routes: ["/settings/chat-approval/save"], form: "chatApproval", field: "token", proof: "typed-password", ...TYPED, role: "approver", secrets: [], terms: ["nonce", "digest", "scope", "full-access", "cap-usd"] },
|
package/dist/slack-api.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ChatDeliveryError } from "./chat-delivery-state.js";
|
|
1
|
+
import { ChatDeliveryError, withheldPart } from "./chat-delivery-state.js";
|
|
2
|
+
import { guardSlack } from "./outbound-privacy.js";
|
|
2
3
|
import { chmodSync, readFileSync, renameSync, rmSync, writeFileSync, } from "node:fs";
|
|
3
4
|
import { join } from "node:path";
|
|
4
5
|
import { randomBytes } from "node:crypto";
|
|
@@ -46,7 +47,7 @@ const errors = new Set([
|
|
|
46
47
|
"edit_window_closed",
|
|
47
48
|
]);
|
|
48
49
|
export function slackApi(token, fetcher = fetch) {
|
|
49
|
-
return async (method, args = {}) => {
|
|
50
|
+
return guardSlack(async (method, args = {}) => {
|
|
50
51
|
if (!/^[a-zA-Z]+(?:\.[a-zA-Z]+){1,2}$/.test(method))
|
|
51
52
|
throw new SlackError("Invalid Slack method");
|
|
52
53
|
let response;
|
|
@@ -85,7 +86,7 @@ export function slackApi(token, fetcher = fetch) {
|
|
|
85
86
|
? String(body.error)
|
|
86
87
|
: "Slack could not complete the request", 5_000, body.error === "internal_error" || body.error === "fatal_error");
|
|
87
88
|
return body;
|
|
88
|
-
};
|
|
89
|
+
}, withheldPart);
|
|
89
90
|
}
|
|
90
91
|
export const slackCredentialFile = (dir) => join(dir, "slack-connection.json");
|
|
91
92
|
export function loadSlackCredentials(dir) {
|
package/dist/slack-chat.js
CHANGED
|
@@ -10,13 +10,14 @@ import { processChatEvent, planChatNotifications, channelAccess, planRoomMessage
|
|
|
10
10
|
import { proposalPreview, proposalLink, proposalOutcomeText, armedCardText, armedYesLabel, } from "./chat-channel.js";
|
|
11
11
|
import { LEAD_MESSAGE_MAX_CHARS } from "./lead.js";
|
|
12
12
|
import { renderReply } from "./reply-shape.js";
|
|
13
|
-
import { ChatDeliveryError, ChatState, chatHash, chatRetryAt, partContent } from "./chat-delivery-state.js";
|
|
13
|
+
import { ChatDeliveryError, ChatState, chatHash, chatRetryAt, partContent, withheldPart } from "./chat-delivery-state.js";
|
|
14
14
|
import { readChatPart } from "./contracts/chat-content.js";
|
|
15
15
|
import { readSlackBlockActions, readSlackButton, SLACK_LINK_ACTION } from "./contracts/slack-callback.js";
|
|
16
16
|
import { object, slackId, slackTs, slackMember, SlackError, uploadSlackBytes, } from "./slack-api.js";
|
|
17
17
|
import { resultImageFileName, safeResultImageCaption, verifyResultImage, } from "./chat-evidence.js";
|
|
18
18
|
import {} from "./store.js";
|
|
19
19
|
import { isLiveMessage, liveSpacingOf } from "./chat-live.js";
|
|
20
|
+
import { checkedChunks, guardSlack, taskSubject } from "./outbound-privacy.js";
|
|
20
21
|
const SLACK_REFUSED_BLOCKS = new Set(["invalid_blocks", "invalid_blocks_format", "invalid_arguments", "msg_too_long", "msg_blocks_too_long"]);
|
|
21
22
|
const SLACK_UNEDITABLE = new Set(["message_not_found", "cant_update_message", "edit_window_closed"]);
|
|
22
23
|
const nowOf = (options) => options.clock?.() ?? new Date();
|
|
@@ -137,7 +138,7 @@ export function slackBlocks(text, buttons = []) {
|
|
|
137
138
|
});
|
|
138
139
|
text = lines.slice(1).join("\n").trim();
|
|
139
140
|
}
|
|
140
|
-
for (const part of split(text))
|
|
141
|
+
for (const part of checkedChunks(text, split(text)))
|
|
141
142
|
blocks.push({
|
|
142
143
|
type: "section",
|
|
143
144
|
text: { type: "plain_text", text: part, emoji: true },
|
|
@@ -147,7 +148,7 @@ export function slackBlocks(text, buttons = []) {
|
|
|
147
148
|
return blocks;
|
|
148
149
|
}
|
|
149
150
|
export function slackVoiceBlocks(mrkdwn, buttons = []) {
|
|
150
|
-
const blocks = split(mrkdwn).map((part) => ({
|
|
151
|
+
const blocks = checkedChunks(mrkdwn, split(mrkdwn)).map((part) => ({
|
|
151
152
|
type: "section",
|
|
152
153
|
text: { type: "mrkdwn", text: part, verbatim: true },
|
|
153
154
|
}));
|
|
@@ -205,6 +206,7 @@ export async function deliverSlackPart(options) {
|
|
|
205
206
|
if (event.kind === "notice" && options.canNotify?.() === false)
|
|
206
207
|
return false;
|
|
207
208
|
const content = partContent(row.payload);
|
|
209
|
+
options = { ...options, api: guardSlack(options.api, withheldPart, taskSubject(store, content.task ?? content.image?.taskId)) };
|
|
208
210
|
const destination = content.channel ?? binding.channel;
|
|
209
211
|
let text = content.text, buttons = [];
|
|
210
212
|
if (content.task &&
|
package/dist/spend.js
CHANGED
|
@@ -55,14 +55,14 @@ export function ceilingPriceFor(db, provider) {
|
|
|
55
55
|
return row === undefined || row["input_usd"] == null || row["output_usd"] == null ? null
|
|
56
56
|
: { inputUsd: Number(row["input_usd"]), outputUsd: Number(row["output_usd"]), model: "highest listed price" };
|
|
57
57
|
}
|
|
58
|
-
export function priceWork(db, work) {
|
|
58
|
+
export function priceWork(db, work, lookup = (provider, model) => priceFor(db, provider, model) ?? ceilingPriceFor(db, provider)) {
|
|
59
59
|
if (work.billing === "subscription")
|
|
60
60
|
return { microusd: 0, source: "subscription", price: null };
|
|
61
61
|
if (work.costUsd !== null && Number.isFinite(work.costUsd))
|
|
62
62
|
return { microusd: Math.round(work.costUsd * 1_000_000), source: "reported", price: null };
|
|
63
63
|
if (work.tokensIn === null && work.tokensOut === null)
|
|
64
64
|
return { microusd: null, source: "unpriced", price: null };
|
|
65
|
-
const price =
|
|
65
|
+
const price = lookup(work.provider, work.model);
|
|
66
66
|
if (price === null)
|
|
67
67
|
return { microusd: null, source: "unpriced", price: null };
|
|
68
68
|
return { microusd: Math.round((work.tokensIn ?? 0) * price.inputUsd + (work.tokensOut ?? 0) * price.outputUsd), source: "estimated", price };
|
|
@@ -172,12 +172,33 @@ export function filersOf(db) {
|
|
|
172
172
|
return found;
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
|
-
export function spendItems(db, from, to,
|
|
176
|
-
const
|
|
175
|
+
export function spendItems(db, from, to, readMode = provider => billingOf(provider, db)) {
|
|
176
|
+
const modes = new Map();
|
|
177
|
+
const modeOf = (provider) => { let mode = modes.get(provider); if (mode === undefined) {
|
|
178
|
+
mode = readMode(provider);
|
|
179
|
+
modes.set(provider, mode);
|
|
180
|
+
} return mode; };
|
|
181
|
+
const prices = new Map();
|
|
182
|
+
const lookup = (provider, model) => {
|
|
183
|
+
const key = `${provider}\n${model ?? ""}`;
|
|
184
|
+
if (!prices.has(key))
|
|
185
|
+
prices.set(key, priceFor(db, provider, model) ?? ceilingPriceFor(db, provider));
|
|
186
|
+
return prices.get(key);
|
|
187
|
+
};
|
|
188
|
+
const has = db.prepare(`SELECT EXISTS(SELECT 1 FROM run WHERE started_at >= ?1 AND started_at < ?2) AS runs,
|
|
189
|
+
EXISTS(SELECT 1 FROM subagent_turn WHERE at >= ?1 AND at < ?2) AS subagent,
|
|
190
|
+
(EXISTS(SELECT 1 FROM chat_turn WHERE created_at >= ?1 AND created_at < ?2) OR EXISTS(SELECT 1 FROM mate_turn WHERE created_at >= ?1 AND created_at < ?2)) AS chat,
|
|
191
|
+
EXISTS(SELECT 1 FROM side_spend WHERE at >= ?1 AND at < ?2) AS side,
|
|
192
|
+
EXISTS(SELECT 1 FROM flow_step_run WHERE kind = 'sort' AND started_at >= ?1 AND started_at < ?2) AS sort,
|
|
193
|
+
EXISTS(SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'thread_turn') AS threads,
|
|
194
|
+
EXISTS(SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'thread_relay_pending') AS reservations`).get(from, to) ?? {};
|
|
195
|
+
const any = (key) => Number(has[key]) === 1;
|
|
196
|
+
let filers = null;
|
|
197
|
+
const subagentOf = (repo, filedBy, kind) => (filers ??= subagentFilers(db))(repo, filedBy, kind);
|
|
177
198
|
const filerOf = filersOf(db);
|
|
178
199
|
const text = (value) => value == null ? null : String(value);
|
|
179
200
|
const count = (value) => value == null ? null : Number(value);
|
|
180
|
-
const runs = db.prepare(`SELECT run.id, run.task_ref, run.provider, run.model, run.cost_usd, run.tokens_in, run.tokens_out, run.started_at, run.auth_mode,
|
|
201
|
+
const runs = !any("runs") ? [] : db.prepare(`SELECT run.id, run.task_ref, run.provider, run.model, run.cost_usd, run.tokens_in, run.tokens_out, run.started_at, run.auth_mode,
|
|
181
202
|
r.external_id AS task, r.repo, r.filed_by, r.filed_by_kind, r.revision_of, s.microusd, s.source, s.billing
|
|
182
203
|
FROM run JOIN task_ref r ON r.id = run.task_ref LEFT JOIN run_spend s ON s.run = run.id
|
|
183
204
|
WHERE run.started_at >= ? AND run.started_at < ? ORDER BY run.id`).all(from, to);
|
|
@@ -186,7 +207,7 @@ export function spendItems(db, from, to, modeOf = provider => billingOf(provider
|
|
|
186
207
|
const billing = row["billing"] === "subscription" || row["billing"] === "api-key" ? row["billing"]
|
|
187
208
|
: row["auth_mode"] === "subscription" || row["auth_mode"] === "api-key" ? row["auth_mode"] : modeOf(provider);
|
|
188
209
|
const settled = row["source"] != null;
|
|
189
|
-
const priced = settled ? null : priceWork(db, { provider, model: text(row["model"]), costUsd: count(row["cost_usd"]), tokensIn: count(row["tokens_in"]), tokensOut: count(row["tokens_out"]), billing });
|
|
210
|
+
const priced = settled ? null : priceWork(db, { provider, model: text(row["model"]), costUsd: count(row["cost_usd"]), tokensIn: count(row["tokens_in"]), tokensOut: count(row["tokens_out"]), billing }, lookup);
|
|
190
211
|
const filer = row["filed_by"] == null && row["revision_of"] != null ? filerOf(Number(row["task_ref"]))
|
|
191
212
|
: { repo: text(row["repo"]), filedBy: text(row["filed_by"]), kind: text(row["filed_by_kind"]) };
|
|
192
213
|
const kind = filer.kind;
|
|
@@ -200,15 +221,15 @@ export function spendItems(db, from, to, modeOf = provider => billingOf(provider
|
|
|
200
221
|
taskId: String(row["task"]), runId: Number(row["id"]), authMode: billing,
|
|
201
222
|
};
|
|
202
223
|
});
|
|
203
|
-
for (const row of db.prepare(`SELECT t.at, t.subagent, t.model, t.cost_usd, t.tokens_in, t.tokens_out, t.billing, m.repo FROM subagent_turn t JOIN subagent m ON m.id = t.subagent
|
|
224
|
+
for (const row of !any("subagent") ? [] : db.prepare(`SELECT t.at, t.subagent, t.model, t.cost_usd, t.tokens_in, t.tokens_out, t.billing, m.repo FROM subagent_turn t JOIN subagent m ON m.id = t.subagent
|
|
204
225
|
WHERE t.at >= ? AND t.at < ? ORDER BY t.id`).all(from, to)) {
|
|
205
226
|
const billing = row["billing"] === "api-key" ? "api-key" : "subscription";
|
|
206
|
-
const priced = priceWork(db, { provider: "claude", model: text(row["model"]), costUsd: count(row["cost_usd"]), tokensIn: count(row["tokens_in"]), tokensOut: count(row["tokens_out"]), billing });
|
|
227
|
+
const priced = priceWork(db, { provider: "claude", model: text(row["model"]), costUsd: count(row["cost_usd"]), tokensIn: count(row["tokens_in"]), tokensOut: count(row["tokens_out"]), billing }, lookup);
|
|
207
228
|
items.push({ at: String(row["at"]), kind: "subagent", microusd: priced.microusd, source: priced.source, project: String(row["repo"]), person: null,
|
|
208
229
|
subagent: Number(row["subagent"]), provider: "claude", model: text(row["model"]),
|
|
209
230
|
tokensIn: count(row["tokens_in"]), tokensOut: count(row["tokens_out"]), taskId: null, runId: null, authMode: billing });
|
|
210
231
|
}
|
|
211
|
-
for (const row of db.prepare(`SELECT created_at AS at, approver, provider, model, settled_microusd, tokens_in, tokens_out, NULL AS project
|
|
232
|
+
for (const row of !any("chat") ? [] : db.prepare(`SELECT created_at AS at, approver, provider, model, settled_microusd, tokens_in, tokens_out, NULL AS project
|
|
212
233
|
FROM chat_turn WHERE mate_turn IS NULL AND created_at >= ? AND created_at < ?
|
|
213
234
|
UNION ALL SELECT t.created_at, t.approver, COALESCE((SELECT c.provider FROM chat_turn c WHERE c.mate_turn = t.id ORDER BY c.id LIMIT 1), 'lead'),
|
|
214
235
|
(SELECT c.model FROM chat_turn c WHERE c.mate_turn = t.id ORDER BY c.id LIMIT 1), t.settled_microusd, t.tokens_in, t.tokens_out,
|
|
@@ -221,19 +242,32 @@ export function spendItems(db, from, to, modeOf = provider => billingOf(provider
|
|
|
221
242
|
project: text(row["project"]), person: text(row["approver"]), subagent: null, provider, model: text(row["model"]),
|
|
222
243
|
tokensIn: count(row["tokens_in"]), tokensOut: count(row["tokens_out"]), taskId: null, runId: null, authMode: subscription ? "subscription" : "api-key" });
|
|
223
244
|
}
|
|
224
|
-
for (const row of db.prepare("SELECT at, kind, repo, provider, model, cost_usd, billing FROM side_spend WHERE at >= ? AND at < ? ORDER BY id").all(from, to)) {
|
|
245
|
+
for (const row of !any("side") ? [] : db.prepare("SELECT at, kind, repo, provider, model, cost_usd, billing FROM side_spend WHERE at >= ? AND at < ? ORDER BY id").all(from, to)) {
|
|
225
246
|
const billing = row["billing"] === "api-key" ? "api-key" : "subscription";
|
|
226
|
-
const priced = priceWork(db, { provider: String(row["provider"]), model: text(row["model"]), costUsd: count(row["cost_usd"]), tokensIn: null, tokensOut: null, billing });
|
|
247
|
+
const priced = priceWork(db, { provider: String(row["provider"]), model: text(row["model"]), costUsd: count(row["cost_usd"]), tokensIn: null, tokensOut: null, billing }, lookup);
|
|
227
248
|
items.push({ at: String(row["at"]), kind: "draft", microusd: priced.microusd, source: priced.source, project: text(row["repo"]), person: null, subagent: null,
|
|
228
249
|
provider: String(row["provider"]), model: text(row["model"]), tokensIn: null, tokensOut: null, taskId: null, runId: null, authMode: billing });
|
|
229
250
|
}
|
|
230
|
-
for (const row of db.prepare(`SELECT fs.started_at AS at, json_extract(fs.decision_json, '$.cost') AS cost, json_extract(fs.decision_json, '$.model') AS model, f.repo
|
|
251
|
+
for (const row of !any("sort") ? [] : db.prepare(`SELECT fs.started_at AS at, json_extract(fs.decision_json, '$.cost') AS cost, json_extract(fs.decision_json, '$.model') AS model, f.repo
|
|
231
252
|
FROM flow_step_run fs JOIN flow_card c ON c.id = fs.card JOIN flow f ON f.id = c.flow
|
|
232
253
|
WHERE fs.kind = 'sort' AND fs.decision_json IS NOT NULL AND fs.started_at >= ? AND fs.started_at < ? ORDER BY fs.started_at`).all(from, to)) {
|
|
233
254
|
const cost = typeof row["cost"] === "number" && Number.isFinite(row["cost"]) && row["cost"] >= 0 ? row["cost"] : null;
|
|
234
255
|
items.push({ at: String(row["at"]), kind: "sort", microusd: cost === null ? null : Math.round(cost * 1_000_000), source: cost === null ? "unpriced" : "reported",
|
|
235
256
|
project: text(row["repo"]), person: null, subagent: null, provider: "openrouter", model: text(row["model"]), tokensIn: null, tokensOut: null, taskId: null, runId: null, authMode: "api-key" });
|
|
236
257
|
}
|
|
258
|
+
if (any("threads")) {
|
|
259
|
+
const reservations = any("reservations");
|
|
260
|
+
for (const row of db.prepare(`SELECT COALESCE(started_at, admitted_at) AS at, repo, owner, provider, model, billing, status, cost_basis, cost_microusd, tokens_in, tokens_out,
|
|
261
|
+
${reservations ? "(status IN ('finished', 'interrupted', 'unknown') AND id IN (SELECT turn FROM thread_relay_pending))" : "0"} AS unsettled
|
|
262
|
+
FROM thread_turn WHERE status <> 'withdrawn' AND COALESCE(started_at, admitted_at) >= ? AND COALESCE(started_at, admitted_at) < ? ORDER BY admitted_at, id`).all(from, to)) {
|
|
263
|
+
const billing = row["billing"] === "subscription" ? "subscription" : "api-key";
|
|
264
|
+
const blind = billing === "api-key" && (row["cost_basis"] === "unknown" || Number(row["unsettled"]) === 1);
|
|
265
|
+
items.push({ at: String(row["at"]), kind: "flexible", microusd: billing === "subscription" ? 0 : blind ? null : Number(row["cost_microusd"]),
|
|
266
|
+
source: billing === "subscription" ? "subscription" : blind ? "unpriced" : row["cost_basis"] === "measured" ? "reported" : "estimated",
|
|
267
|
+
project: String(row["repo"]), person: String(row["owner"]), subagent: null, provider: String(row["provider"]), model: text(row["model"]),
|
|
268
|
+
tokensIn: count(row["tokens_in"]), tokensOut: count(row["tokens_out"]), taskId: null, runId: null, authMode: billing });
|
|
269
|
+
}
|
|
270
|
+
}
|
|
237
271
|
return items;
|
|
238
272
|
}
|
|
239
273
|
export function countsToward(item, budget) {
|