toolroll 0.9.109 → 0.9.111
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 +73 -0
- package/README.md +5 -1
- package/THIRD_PARTY_NOTICES.md +30 -0
- package/dist/agent-detect.js +244 -0
- package/dist/agent-fence.js +12 -1
- package/dist/agent-said-schema.js +4 -0
- package/dist/agent-said.js +23 -0
- package/dist/agentconfig.js +2 -2
- package/dist/approval-summary.js +375 -0
- package/dist/attest.js +2 -2
- package/dist/browser/THIRD_PARTY_NOTICES.txt +30 -0
- package/dist/browser/workspace.css +2 -2
- package/dist/browser/workspace.js +27 -27
- package/dist/builder.js +42 -3
- package/dist/chat-actions.js +24 -17
- package/dist/chat-core.js +3 -1
- package/dist/chat-decide.js +101 -46
- 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-task-actions.js +6 -0
- package/dist/check-report.js +1 -1
- package/dist/claim.js +28 -13
- package/dist/cli-help.js +1 -1
- package/dist/cli.js +2 -0
- package/dist/codex-limits.js +21 -8
- package/dist/console-instance.js +11 -1
- package/dist/contracts/console-api.js +13 -7
- package/dist/contracts/engine-api.js +283 -0
- package/dist/contracts/route.js +1 -0
- package/dist/coordinator.js +2 -2
- package/dist/discord-api.js +4 -3
- package/dist/discord-chat.js +3 -1
- package/dist/dispatch.js +1 -1
- package/dist/dispose.js +15 -9
- package/dist/easy-start-args.js +7 -3
- package/dist/easy-start.js +40 -1
- package/dist/egress.js +72 -10
- package/dist/engine-handoff.js +34 -0
- package/dist/engine-reads.js +338 -0
- package/dist/eval-world.js +3 -2
- package/dist/evidence.js +2 -0
- package/dist/fast-start.js +68 -18
- 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-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-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.js +175 -25
- package/dist/flexible-turns-schema.js +69 -0
- package/dist/flexible-turns.js +490 -0
- package/dist/flexible.js +10 -1
- 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 +6 -3
- package/dist/install-mode.js +225 -0
- package/dist/integrations.js +6 -1
- package/dist/lead-doors.js +7 -1
- package/dist/limits-ui.js +7 -0
- package/dist/live-reply.js +6 -0
- package/dist/live-terminal.js +425 -29
- package/dist/local-owner.js +7 -0
- package/dist/model-choices.js +12 -6
- package/dist/needs-you.js +2 -0
- package/dist/notification-delivery.js +11 -0
- package/dist/operate.js +128 -37
- package/dist/outbound-privacy.js +204 -0
- package/dist/passwordless.js +2 -1
- package/dist/phase-routing.js +3 -1
- package/dist/plane-review.js +1 -1
- package/dist/project-delete.js +14 -0
- package/dist/proposal.js +2 -2
- package/dist/provider-connection.js +19 -5
- 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 +10 -1
- package/dist/route-store.js +3 -3
- 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 +62 -13
- package/dist/server/chrome.js +3 -1
- 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/http.js +7 -0
- package/dist/server/link-redemption.js +52 -0
- package/dist/server/mutation-key.js +21 -7
- package/dist/server/pages.js +72 -40
- package/dist/server/people-tokens.js +17 -41
- package/dist/server/render-chat.js +1 -0
- package/dist/server/render-new-task.js +3 -3
- package/dist/server/render-results.js +4 -4
- package/dist/server/render-tasks.js +133 -139
- package/dist/server/route-table.js +32 -1
- package/dist/server/settings-section-table.js +6 -0
- package/dist/server/settings-sections.js +69 -0
- package/dist/server/settings.js +120 -10
- package/dist/server/task-views.js +8 -2
- package/dist/server/tasks.js +56 -12
- package/dist/server/terminals.js +181 -28
- package/dist/server/welcome.js +35 -10
- package/dist/settings-groups-ui.js +2 -2
- package/dist/settings-proofs.js +14 -9
- package/dist/slack-api.js +4 -3
- package/dist/slack-chat.js +5 -3
- package/dist/spend.js +46 -12
- package/dist/status-probe.js +343 -0
- package/dist/store.js +181 -12
- package/dist/task-sizing-schema.js +14 -0
- package/dist/task-sizing.js +76 -10
- 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/toolroll-update.js +3 -1
- 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 +1 -1
- package/dist/webhooks.js +14 -4
- package/dist/welcome-facts.js +22 -15
- package/dist/work-index.js +2 -2
- package/dist/workspace-ui.js +5 -0
- package/package.json +1 -1
- package/scripts/crash-canary.mjs +1 -1
- package/scripts/pilot.mjs +1 -1
- package/scripts/provider-canary.mjs +5 -3
|
@@ -14,6 +14,12 @@ export const SETTINGS_SECTIONS = Object.freeze([
|
|
|
14
14
|
read: ["password-holder"], scope: { passwordless: ["installation"] }, act: {}, changes: [], opens: false, scripts: [], oldIds: [] },
|
|
15
15
|
{ id: "version", area: "general", title: "Version", pinnedFrom: "settings.group-general", policy: GROUP_PAGE,
|
|
16
16
|
read: [], scope: { "updates-version": ["installation"], "package-version": ["operator"] }, act: { updates: ["operator"] }, changes: [], opens: false, scripts: [], oldIds: [] },
|
|
17
|
+
{ id: "install-mode", area: "general", title: "Solo or team", pinnedFrom: "settings.group-general", policy: GROUP_PAGE,
|
|
18
|
+
read: [], scope: {}, act: { "just-me": ["full-session", "operator"] }, changes: [{ id: "just-me", act: "just-me", proof: "install-solo" }],
|
|
19
|
+
opens: false, scripts: [], oldIds: [] },
|
|
20
|
+
{ id: "task-sizing", area: "general", title: "Size tasks with a quick model call (Claude Haiku, on your plan)", pinnedFrom: "settings.group-general", policy: GROUP_PAGE,
|
|
21
|
+
read: ["installation"], scope: {}, act: { switch: ["cookie-session", "operator"] }, changes: [{ id: "task-sizing", act: "switch", proof: "task-sizing" }],
|
|
22
|
+
opens: false, scripts: [], oldIds: [] },
|
|
17
23
|
{ id: "advanced", area: "general", title: "Show advanced features", pinnedFrom: "settings.group-advanced", policy: GROUP_PAGE,
|
|
18
24
|
read: [], scope: { "operator-pages": ["operator"] }, act: { switch: ["cookie-session"] }, changes: [], opens: true, scripts: [], oldIds: ["show-advanced"] },
|
|
19
25
|
{ id: "local-mode", area: "general", title: "Local mode", pinnedFrom: "settings.group-access", policy: GROUP_PAGE,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ADVANCED_PAGES } from "../advanced-view.js";
|
|
2
2
|
import { accentNote, ACCENT_PRESETS } from "../accent-colors.js";
|
|
3
|
+
import { installModeLine, justMeAllowed, TEAM_FACT_WORDS } from "../install-mode.js";
|
|
3
4
|
import { html, joinHtml, postForm } from "../html.js";
|
|
4
5
|
import { kitSectionForm } from "../settings-kit.js";
|
|
5
6
|
import { evaluateRoutePolicy, holdsRole } from "./route-policy.js";
|
|
@@ -237,12 +238,80 @@ function localModeSection(deps) {
|
|
|
237
238
|
},
|
|
238
239
|
};
|
|
239
240
|
}
|
|
241
|
+
function installModeSection(deps) {
|
|
242
|
+
return {
|
|
243
|
+
loadSummary: ctx => {
|
|
244
|
+
const read = deps.installMode();
|
|
245
|
+
const canSwitch = ctx.can["just-me"] === true;
|
|
246
|
+
return { mode: read.mode, facts: read.facts, canSwitch, offered: canSwitch && justMeAllowed(read) };
|
|
247
|
+
},
|
|
248
|
+
render: ({ declaration, summary, attrs }) => {
|
|
249
|
+
const line = installModeLine(summary.mode);
|
|
250
|
+
return settingsSection({ id: "install-mode", title: line.label, attrs, lead: line.words,
|
|
251
|
+
...(summary.offered ? { right: btn("It's just me", { sm: true, href: changeHref(declaration.changes[0]) }) } : {}), body: html `` });
|
|
252
|
+
},
|
|
253
|
+
refusal: "An instance operator signed in with a password says it's just them.",
|
|
254
|
+
renderChange: ({ declaration, summary, problem }) => {
|
|
255
|
+
const home = sectionHref(declaration);
|
|
256
|
+
const title = "It's just me";
|
|
257
|
+
const blocked = summary === null ? [] : summary.facts.filter(fact => fact !== "existing-install" && !fact.endsWith("-added"));
|
|
258
|
+
const words = summary === null || summary.mode === "solo"
|
|
259
|
+
? html `${infoLine("This install is solo.")}<div class="k-acts">${btn("Back to General", { href: home })}</div>`
|
|
260
|
+
: !summary.offered
|
|
261
|
+
? html `${blocked.map(fact => notice(TEAM_FACT_WORDS[fact]))}<div class="k-acts">${btn("Back to General", { href: home })}</div>`
|
|
262
|
+
: joinHtml([
|
|
263
|
+
html `<p>Approvals and Accept then need only you signed in. Signing in, tokens and connecting things still ask for your password. If anyone joins, this install switches back to Team.</p>`,
|
|
264
|
+
problem === null ? "" : notice(problem),
|
|
265
|
+
kitSectionForm({ proof: "install-solo", action: "/settings/install-mode/solo", id: "just-me-form", native: true, save: { label: title }, confirm: title, body: html `` }),
|
|
266
|
+
html `<div class="k-acts">${btn("Cancel", { variant: "ghost", href: home })}</div>`,
|
|
267
|
+
]);
|
|
268
|
+
return { title, body: html `<div data-kit-page>${phoneHeader(title, { back: home })}${doc(docHeader({ title, back: [home, "General"], same: true }), words)}</div>` };
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
export const TASK_SIZING_OFF_WORDS = "Off: no model call before you approve; uncertain tasks get a plan first.";
|
|
273
|
+
const SIZER_NAME = { claude: "Claude Haiku, on your plan", jev: "Jev via OpenRouter, your credit" };
|
|
274
|
+
const SIZER_SHORT = { claude: "Claude Haiku", jev: "Jev via OpenRouter" };
|
|
275
|
+
function taskSizingSection(deps) {
|
|
276
|
+
return {
|
|
277
|
+
loadSummary: ctx => {
|
|
278
|
+
const read = deps.taskSizing();
|
|
279
|
+
return { on: read.on && !read.byEnv, byEnv: read.byEnv, canSwitch: ctx.can["switch"] === true, sizer: read.sizer, available: read.available, moved: read.chosen && !read.on };
|
|
280
|
+
},
|
|
281
|
+
render: ({ summary, attrs }) => settingsSection({ id: "task-sizing", title: `Size tasks with a quick model call (${SIZER_NAME[summary.on && summary.sizer !== null ? summary.sizer : summary.available]})`, state: summary.on ? " · on" : " · off", attrs,
|
|
282
|
+
lead: summary.byEnv ? "Off: TOOLROLL_NO_TASK_CLASSIFIER is set on this computer, so no model call happens before you approve; uncertain tasks get a plan first."
|
|
283
|
+
: summary.on ? `On: before you approve, a quick call to ${SIZER_SHORT[summary.sizer]} sizes each new task, and the plan names it.`
|
|
284
|
+
: summary.moved && summary.sizer !== null ? `Off: you turned it on for ${SIZER_SHORT[summary.sizer]}, but ${SIZER_SHORT[summary.available]} is the one available now, so nothing is sent. Turn it on again to choose it. Uncertain tasks get a plan first.`
|
|
285
|
+
: TASK_SIZING_OFF_WORDS,
|
|
286
|
+
...(summary.canSwitch && !summary.byEnv ? { right: btn(summary.on ? "Turn off" : "Turn on", { sm: true, href: "/settings/change/task-sizing" }) } : {}), body: html `` }),
|
|
287
|
+
refusal: "An instance operator changes how tasks are sized.",
|
|
288
|
+
renderChange: ({ declaration, summary, problem }) => {
|
|
289
|
+
const home = sectionHref(declaration);
|
|
290
|
+
const on = summary?.on === true;
|
|
291
|
+
const choice = summary === null ? "claude" : on && summary.sizer !== null ? summary.sizer : summary.available;
|
|
292
|
+
const title = `Size tasks with a quick model call (${SIZER_NAME[choice]})`;
|
|
293
|
+
const words = summary === null || summary.byEnv
|
|
294
|
+
? html `${infoLine("TOOLROLL_NO_TASK_CLASSIFIER is set on this computer, so task sizing stays off.")}<div class="k-acts">${btn("Back to General", { href: home })}</div>`
|
|
295
|
+
: joinHtml([
|
|
296
|
+
html `<p>${on ? `Turn it off. ${TASK_SIZING_OFF_WORDS}` : choice === "jev"
|
|
297
|
+
? "Turn it on. Before you approve, each new task's words go to Jev through your OpenRouter key (your credit) to size it: small ones build at once on a fast model, risky ones plan first, and the plan names the model that sized it. Only Jev is asked; if the key goes, sizing turns itself off."
|
|
298
|
+
: "Turn it on. Before you approve, a quick call to Claude Haiku on your own plan sizes each new task: small ones build at once on a fast model, risky ones plan first, and the plan names the model that sized it. Only Claude is asked; if an OpenRouter key is saved later, sizing turns itself off until you choose again."}</p>`,
|
|
299
|
+
problem === null ? "" : notice(problem),
|
|
300
|
+
kitSectionForm({ proof: "task-sizing", action: "/settings/task-sizing", id: "task-sizing-form", native: true, save: { label: on ? "Turn off" : "Turn on" }, confirm: on ? "Turn off task sizing" : "Turn on task sizing", hidden: { enabled: on ? "off" : "on", sizer: choice }, body: html `` }),
|
|
301
|
+
html `<div class="k-acts">${btn("Cancel", { variant: "ghost", href: home })}</div>`,
|
|
302
|
+
]);
|
|
303
|
+
return { title, body: html `<div data-kit-page>${phoneHeader(title, { back: home })}${doc(docHeader({ title, back: [home, "General"], same: true }), words)}</div>` };
|
|
304
|
+
},
|
|
305
|
+
};
|
|
306
|
+
}
|
|
240
307
|
export function generalSections(deps) {
|
|
241
308
|
return {
|
|
242
309
|
appearance: appearanceSection(),
|
|
243
310
|
"this-browser": thisBrowserSection(),
|
|
244
311
|
"your-password": yourPasswordSection(deps),
|
|
245
312
|
version: versionSection(deps),
|
|
313
|
+
"install-mode": installModeSection(deps),
|
|
314
|
+
"task-sizing": taskSizingSection(deps),
|
|
246
315
|
advanced: advancedSection(),
|
|
247
316
|
"local-mode": localModeSection(deps),
|
|
248
317
|
};
|
package/dist/server/settings.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PASSWORDLESS_TRADE, passwordlessSetting, setPasswordless } from "../passwordless.js";
|
|
2
|
+
import { declareJustMe, installModeNow, sessionStandsIn, soloNow, TEAM_FACT_WORDS } from "../install-mode.js";
|
|
2
3
|
import { ACP_AGENTS, isKeyedProvider } from "../acp-agents.js";
|
|
3
4
|
import { LIVE_VIEW_CONSENT, liveViewConsentDigest, setLiveCommands } from "../live-detail.js";
|
|
4
5
|
import { CONSOLE_FORMS, readForm } from "../contracts/console-api.js";
|
|
@@ -23,6 +24,7 @@ import { adapterPolicy } from "./route-policy.js";
|
|
|
23
24
|
import { createHash } from "node:crypto";
|
|
24
25
|
import { basename, dirname, join } from "node:path";
|
|
25
26
|
import { INSTALLATION_SCOPE } from "../agentconfig.js";
|
|
27
|
+
import { checkEngineResponse, ENGINE_API_VERSION } from "../contracts/engine-api.js";
|
|
26
28
|
import { rulesSummary } from "../approval-rules-ui.js";
|
|
27
29
|
import { installMethod } from "../install-method.js";
|
|
28
30
|
import { logEvent } from "../log.js";
|
|
@@ -92,7 +94,7 @@ import { decideProposal, defaultTidyAnalyzer, listProposals, memoryStatus } from
|
|
|
92
94
|
import { checkModels, isNewModel, modelOptions, modelWords, RUNTIME_TOOLS, runtimeStates, seenModels, setWatch, updateRuntime, watchState } from "../model-catalog.js";
|
|
93
95
|
import { modelsHtml, modelsScript } from "../models-ui.js";
|
|
94
96
|
import { acceptSuggestion, dismissSuggestion, grantWords, keepRule, modelName, ruleWords, rulesOf, setSuggestModels, startTrial, stopTrial, suggestionsFor, suggestionWords, suggestModelsOn, trialOffersFor, trialOfferWords, trialsOf, trialWords, turnOffRule } from "../route-rules.js";
|
|
95
|
-
import { ALL_SLOTS, applyModelChoices, browserWords, checkScope, DEFAULT_PRESET, defaultAgentOf, fillDefaultRouting, isPresetName, newerModels, PRESETS, presetChange, presetInUse, previewModelChange, recentRuns, rowAt, slotKey, SLOTS, slotWords, stateDigest, switchChange } from "../model-choices.js";
|
|
97
|
+
import { AGENT_PRESETS, ALL_SLOTS, applyModelChoices, browserWords, checkScope, DEFAULT_PRESET, defaultAgentOf, fillDefaultRouting, isPresetName, newerModels, PRESETS, presetChange, presetInUse, previewModelChange, recentRuns, rowAt, slotKey, SLOTS, slotWords, stateDigest, switchChange } from "../model-choices.js";
|
|
96
98
|
import { HEADROOM_FIVE_HOUR_LIMIT, HEADROOM_WEEKLY_LIMIT, exactModelId } from "../phase-routing.js";
|
|
97
99
|
import { RISKY_MEANS, SIZE_MEANS, SIZING_CLAUDE_MODEL } from "../task-sizing.js";
|
|
98
100
|
import { CHAT_APPROVE_ALL, CHECK_REPAIR_LIMIT, MODE_MAX_DAYS, modeDigestOf, modeTermsJson, modeWords, presetTerms } from "../modes.js";
|
|
@@ -148,6 +150,8 @@ import { sweepSchedule } from "../storage-sweep-schedule.js";
|
|
|
148
150
|
import { storageHtml } from "../storage-ui.js";
|
|
149
151
|
import { landedSummary } from "../landed-cleanup.js";
|
|
150
152
|
import { bytesWords, parseCleanup, parseIdle } from "../storage.js";
|
|
153
|
+
import { setTaskSizing, taskSizingSetting } from "../task-sizing.js";
|
|
154
|
+
import { localActNow } from "../local-owner.js";
|
|
151
155
|
import { checkoutIdle, isDigestTime, leadQuickAnswersOn, liveBackupState, setCheckoutIdle, localModeOf, RESULT_SCREENSHOTS, setLeadQuickAnswers, setLiveBackupSettings, setLocalModeOff } from "../store.js";
|
|
152
156
|
import { defaultLiveFolder, liveFolderOf, liveFolderProblem } from "../live-backup.js";
|
|
153
157
|
import { LIVE_EVERY } from "../backup-ui.js";
|
|
@@ -544,7 +548,7 @@ ${connectionHtml(asked, connection, task)}${command === null ? "" : html `<p>On
|
|
|
544
548
|
const setting = passwordlessSetting(store);
|
|
545
549
|
const said = url.searchParams.get("said"), problem = url.searchParams.get("problem");
|
|
546
550
|
const since = setting.at === null ? null : `${setting.on ? "on" : "off"} since ${new Date(setting.at).toLocaleString("en-US", { dateStyle: "medium", timeStyle: "short" })}, by ${setting.setBy ?? "someone"}`;
|
|
547
|
-
return sendScreen(response, 200, screen("Passwordless", passwordlessHtml({ on:
|
|
551
|
+
return sendScreen(response, 200, screen("Passwordless", passwordlessHtml({ on: sessionStandsIn(store), since, trade: PASSWORDLESS_TRADE, said, problem }), { chrome: chromeFor(project, "settings") }));
|
|
548
552
|
}
|
|
549
553
|
async function passwordlessSave(ctx) {
|
|
550
554
|
const { response, now, posted } = ctx;
|
|
@@ -726,7 +730,7 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
|
|
|
726
730
|
const updates = minimal ? null : settingsUpdates(who.name, csrf);
|
|
727
731
|
const lastBackup = operator ? store.backupRuns(1)[0] ?? null : null;
|
|
728
732
|
const accounts = minimal || !operator ? null : store.accountFacts().filter(one => one.revokedAt === null);
|
|
729
|
-
const passwordless = minimal ? null :
|
|
733
|
+
const passwordless = minimal ? null : sessionStandsIn(store);
|
|
730
734
|
const facts = {
|
|
731
735
|
name: who.name, approver: who.role === "approver", operator, browser: who.via === "cookie", installation: !minimal,
|
|
732
736
|
said: url.searchParams.get("said"), problem: url.searchParams.get("problem"),
|
|
@@ -1243,12 +1247,16 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
|
|
|
1243
1247
|
return refuse(response, who, 403, "An approver sets up pull requests.", "/projects");
|
|
1244
1248
|
const back = sayTo(response, `/settings/pull-requests?repo=${encodeURIComponent(repo)}`);
|
|
1245
1249
|
const act = body.get("act");
|
|
1246
|
-
|
|
1250
|
+
const provedGeneration = store.accountOf(who.name)?.generation ?? -1;
|
|
1251
|
+
if (!(act === "on" ? authenticateCredential(who, body.get("password") ?? "", repo) : authenticateApprover(who, body.get("password") ?? "", repo)).ok)
|
|
1247
1252
|
return back("problem", "Enter your Toolroll password to change pull requests.");
|
|
1248
1253
|
if (act === "on") {
|
|
1249
1254
|
const checked = await checkPublishing(repo, options.publishExec === undefined ? {} : { exec: options.publishExec });
|
|
1250
1255
|
if (!checked.ok)
|
|
1251
1256
|
return back("problem", checked.message);
|
|
1257
|
+
const account = store.accountOf(who.name);
|
|
1258
|
+
if (account === null || account.revokedAt !== null || account.role !== "approver" || account.generation !== provedGeneration || !store.accountCanAccess(who.name, repo))
|
|
1259
|
+
return back("problem", "Your access changed meanwhile. Nothing changed.");
|
|
1252
1260
|
if (checked.plan.githubRepo !== body.get("github") || checked.plan.base !== body.get("base"))
|
|
1253
1261
|
return back("problem", "GitHub answered differently from what you saw. Check the details again.");
|
|
1254
1262
|
savePublishing(store, checked.plan, who.name, {}, now);
|
|
@@ -1442,7 +1450,7 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
|
|
|
1442
1450
|
if (!options.configDir)
|
|
1443
1451
|
return refuse(response, who, 403, "An instance operator sets up monitoring.", "/settings");
|
|
1444
1452
|
const back = sayTo(response, "/settings/monitoring");
|
|
1445
|
-
if (!
|
|
1453
|
+
if (!authenticateCredential(who, body.get("password") ?? "").ok)
|
|
1446
1454
|
return back("problem", "Enter your Toolroll password to change monitoring.");
|
|
1447
1455
|
const before = readMonitoring(options.configDir);
|
|
1448
1456
|
const saved = saveMonitoring(options.configDir, { webhook: body.get("webhook") ?? "", folder: body.get("folder") ?? "", tracesEndpoint: body.get("traces") ?? "",
|
|
@@ -1490,8 +1498,11 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
|
|
|
1490
1498
|
if (connectionsOf(store, target).find(one => one.id === service.id)?.state !== "open")
|
|
1491
1499
|
return back(`${projectName(target)} already has ${service.label}.`);
|
|
1492
1500
|
}
|
|
1493
|
-
|
|
1501
|
+
const provedGeneration = store.accountOf(who.name)?.generation ?? -1;
|
|
1502
|
+
if (!authenticateCredential(who, body.get("password") ?? "").ok)
|
|
1494
1503
|
return back("Enter your Toolroll password to connect a tool.");
|
|
1504
|
+
if ((store.accountOf(who.name)?.generation ?? -2) !== provedGeneration)
|
|
1505
|
+
return back("Your sign-in changed. Connect again.");
|
|
1495
1506
|
if (local !== null) {
|
|
1496
1507
|
const had = projectToolsOf(store, repo).find(one => one.name === local.id);
|
|
1497
1508
|
if (had !== undefined && localAppOf(had.spec) === null)
|
|
@@ -1520,12 +1531,15 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
|
|
|
1520
1531
|
const started = await startConnect({ service: service.id, repo: target, by: who.name, origin, kit: also === null ? kit : null, template, readOnly }, options.connectFetch ?? fetch);
|
|
1521
1532
|
if (!started.ok)
|
|
1522
1533
|
return back(started.said);
|
|
1534
|
+
const standing = store.accountOf(who.name);
|
|
1535
|
+
if (standing === null || standing.revokedAt !== null || standing.role !== "approver" || standing.generation !== provedGeneration || !store.accountCanAccess(who.name, target))
|
|
1536
|
+
return back("Your sign-in changed. Connect again.");
|
|
1523
1537
|
for (const [key, visit] of connectVisits)
|
|
1524
1538
|
if (visit.expires < Date.now())
|
|
1525
1539
|
connectVisits.delete(key);
|
|
1526
1540
|
const kitSet = kit === null || also !== null ? null : kitOf(kit);
|
|
1527
1541
|
const installed = kitSet === null || !kitSet.tools.some(one => one.tool === service.id) ? null : kitInstalled(store, kitSet, target);
|
|
1528
|
-
connectVisits.set(started.state, { ...started.visit, generation:
|
|
1542
|
+
connectVisits.set(started.state, { ...started.visit, generation: provedGeneration,
|
|
1529
1543
|
grant: installed === null ? null : { subagent: installed.mate.id, tool: service.id, repo: target } });
|
|
1530
1544
|
return goOutside(response, started.go, `Going to ${service.label} to sign in…`, { state: started.state, path: CONNECT_CALLBACK, secure: origin.startsWith("https:") });
|
|
1531
1545
|
}
|
|
@@ -1543,9 +1557,12 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
|
|
|
1543
1557
|
}
|
|
1544
1558
|
const action = body.get("action") ?? "";
|
|
1545
1559
|
const name = body.get("name") ?? "";
|
|
1546
|
-
|
|
1560
|
+
const widening = ["add-catalog", "add-custom", "import", "secret"].includes(action);
|
|
1561
|
+
const provedGeneration = store.accountOf(who.name)?.generation ?? -1;
|
|
1562
|
+
if (widening && !authenticateCredential(who, body.get("password") ?? "").ok) {
|
|
1547
1563
|
return back("problem", "Enter your Toolroll password to change this project's tools.");
|
|
1548
1564
|
}
|
|
1565
|
+
const stillProved = () => { const account = store.accountOf(who.name); return account !== null && account.revokedAt === null && account.role === "approver" && account.generation === provedGeneration && store.accountCanAccess(who.name, repo); };
|
|
1549
1566
|
const now = clock();
|
|
1550
1567
|
const finish = (added, label) => {
|
|
1551
1568
|
if (!added.ok)
|
|
@@ -1582,6 +1599,8 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
|
|
|
1582
1599
|
projectConfig = looked.value;
|
|
1583
1600
|
}
|
|
1584
1601
|
const found = discoverTools(repo, await codexServers(repo), toolHome, process.env, projectConfig);
|
|
1602
|
+
if (!stillProved())
|
|
1603
|
+
return back("problem", "Your access changed while this was read. Nothing was added.");
|
|
1585
1604
|
const added = [], problems = [];
|
|
1586
1605
|
for (const one of wanted) {
|
|
1587
1606
|
const match = found.find(tool => tool.spec.name === one);
|
|
@@ -2136,7 +2155,7 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2136
2155
|
if (wanted !== "auto" && wanted !== "bypassPermissions") {
|
|
2137
2156
|
return refuse(response, who, 400, "permissions must be Auto or Full access", "/settings");
|
|
2138
2157
|
}
|
|
2139
|
-
if (wanted === "bypassPermissions" && store.permissionDefault().mode !== "bypassPermissions" && !
|
|
2158
|
+
if (wanted === "bypassPermissions" && store.permissionDefault().mode !== "bypassPermissions" && !authenticateCredential(who, body.get("password") ?? "").ok) {
|
|
2140
2159
|
return redirect(response, `/settings/approval?problem=${encodeURIComponent("Enter your Toolroll password to start new tasks with Full access. Nothing changed.")}#defaults`);
|
|
2141
2160
|
}
|
|
2142
2161
|
store.setPermissionDefault(wanted, who.name, now);
|
|
@@ -2219,6 +2238,8 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2219
2238
|
? `the ${provider} key is removed — ${provider} uses its own login, so builds are unaffected`
|
|
2220
2239
|
: `the ${provider} key is removed — an environment variable, if one exists, takes over`)}#providers`);
|
|
2221
2240
|
}
|
|
2241
|
+
if (!authenticateCredential(who, body.get("password") ?? "").ok)
|
|
2242
|
+
return redirect(response, `/settings/agents?problem=${encodeURIComponent("Enter your Toolroll password to save a key. Nothing changed.")}#providers`);
|
|
2222
2243
|
const wantedMode = body.get("auth-mode");
|
|
2223
2244
|
const value = (body.get("value") ?? "").trim();
|
|
2224
2245
|
const modeSelected = wantedMode === "subscription" || wantedMode === "api-key";
|
|
@@ -2250,6 +2271,8 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2250
2271
|
if (options.telegramTokenFile === undefined)
|
|
2251
2272
|
return refuse(response, who, 404, "There's no page at this address.", "/chat");
|
|
2252
2273
|
const body = readForm(posted, CONSOLE_FORMS.telegramToken);
|
|
2274
|
+
if (!authenticateCredential(who, body.get("password") ?? "").ok)
|
|
2275
|
+
return redirect(response, `/settings/alerts?problem=${encodeURIComponent("Enter your Toolroll password to save the bot token. Nothing changed.")}#telegram-token`);
|
|
2253
2276
|
const value = body.get("token") ?? "";
|
|
2254
2277
|
const saved = saveBotToken(options.telegramTokenFile, value);
|
|
2255
2278
|
if (!saved.ok)
|
|
@@ -2263,6 +2286,8 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2263
2286
|
const body = readForm(posted, CONSOLE_FORMS.email);
|
|
2264
2287
|
const said = (words, key = "said") => redirect(response, `/settings/alerts?${key}=${encodeURIComponent(words)}#email`);
|
|
2265
2288
|
if (op === "save") {
|
|
2289
|
+
if (!authenticateCredential(who, body.get("token") ?? "").ok)
|
|
2290
|
+
return said("Enter your Toolroll password to save email. Nothing changed.", "problem");
|
|
2266
2291
|
const saved = saveEmailSettings(options.configDir, { host: body.get("host"), port: body.get("port"), secure: body.get("secure"), user: body.get("user"), from: body.get("from"), password: body.get("password"), imapHost: body.get("imapHost"), imapPort: body.get("imapPort") });
|
|
2267
2292
|
return saved.ok ? said(saved.said) : said(saved.message, "problem");
|
|
2268
2293
|
}
|
|
@@ -2290,6 +2315,8 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2290
2315
|
await disconnectGoogle(options.configDir, options.googleFetch ?? fetch);
|
|
2291
2316
|
return said("Google disconnected. Email goes through the mail server again, if one is set up.");
|
|
2292
2317
|
}
|
|
2318
|
+
if (!authenticateCredential(who, body.get("password") ?? "").ok)
|
|
2319
|
+
return redirect(response, `/settings/alerts?problem=${encodeURIComponent("Enter your Toolroll password to connect Google. Nothing changed.")}#email`);
|
|
2293
2320
|
const saved = saveGoogleClient(options.configDir, { clientId: body.get("clientId"), clientSecret: body.get("clientSecret") });
|
|
2294
2321
|
if (!saved.ok)
|
|
2295
2322
|
return said(saved.message);
|
|
@@ -2609,6 +2636,7 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2609
2636
|
"settings.passwordless": passwordlessPage,
|
|
2610
2637
|
"settings.passwordless-send": passwordlessSave,
|
|
2611
2638
|
"settings.local-mode-off": localModeOff,
|
|
2639
|
+
"settings.just-me": justMe,
|
|
2612
2640
|
"settings.release-approval-send": releaseApprovalSave,
|
|
2613
2641
|
"settings.project-flexible": projectFlexible,
|
|
2614
2642
|
"settings.lead": leadPage,
|
|
@@ -2674,6 +2702,7 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2674
2702
|
"settings.models-watch": modelsAct("watch"),
|
|
2675
2703
|
"settings.models-update": modelsAct("update"),
|
|
2676
2704
|
"settings.models-agent": modelsSave,
|
|
2705
|
+
"engine.models": modelsRead,
|
|
2677
2706
|
"settings.models-apply": modelsApply,
|
|
2678
2707
|
"settings.models-act": modelsAct("other"),
|
|
2679
2708
|
"settings.models-accept": modelsRuleAct("accept"),
|
|
@@ -2736,6 +2765,7 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2736
2765
|
"settings.lead-identity": leadIdentity,
|
|
2737
2766
|
"settings.lead-about": leadAbout,
|
|
2738
2767
|
"settings.lead-quick": leadQuick,
|
|
2768
|
+
"settings.task-sizing": taskSizingAct,
|
|
2739
2769
|
"settings.lead-promise-cancel": leadPromiseCancel,
|
|
2740
2770
|
"settings.lead-on": leadOn,
|
|
2741
2771
|
"settings.code-map": codeMapAct("switch"),
|
|
@@ -2856,6 +2886,31 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2856
2886
|
const done = count === 0 ? "Nothing changed." : `${what}: ${count} change${count === 1 ? "" : "s"} saved for tasks filed from now on.`;
|
|
2857
2887
|
return { key: "said", words: result.unresolved === null ? done : `${done} Some roles have no model yet, so new tasks can't be filed here.` };
|
|
2858
2888
|
}
|
|
2889
|
+
async function modelsRead(ctx) {
|
|
2890
|
+
const { who, response, now } = ctx;
|
|
2891
|
+
if (who.via !== "cookie")
|
|
2892
|
+
return respond(response, 403, "application/json", JSON.stringify({ error: "session" }));
|
|
2893
|
+
const operator = store.isInstanceOperator(who.name) && !store.isDemo();
|
|
2894
|
+
const canChange = operator && (who.authority === "full" || soloNow(store));
|
|
2895
|
+
const view = modelsView(canChange, who.session.csrf, now, null, null);
|
|
2896
|
+
const keys = ["plan", "build", "review"];
|
|
2897
|
+
const roles = keys.map(key => {
|
|
2898
|
+
const role = view.roles.find(one => one.key === key);
|
|
2899
|
+
return { key, label: role.label, current: role.current, words: role.words,
|
|
2900
|
+
choices: role.groups.map(group => ({ provider: group.provider, label: group.label, models: group.options.map(option => ({ value: option.value, label: option.label })) })) };
|
|
2901
|
+
});
|
|
2902
|
+
const build = rowAt(store, INSTALLATION_SCOPE, { phase: "build", tier: "routine" });
|
|
2903
|
+
const presets = ["claude", "codex"].map(agent => ({
|
|
2904
|
+
agent, name: agent === "claude" ? "Claude Code" : "Codex", words: AGENT_PRESETS[agent].words,
|
|
2905
|
+
fields: Object.fromEntries(SLOTS.map(slot => { const model = AGENT_PRESETS[agent].rows[slotKey(slot)]; return [slotKey(slot), model === null || model === undefined ? "clear" : `${agent}|${model}`]; })),
|
|
2906
|
+
}));
|
|
2907
|
+
const checked = checkScope(store, null);
|
|
2908
|
+
response.setHeader("cache-control", "no-store");
|
|
2909
|
+
return respond(response, 200, "application/json", JSON.stringify(checkEngineResponse("models", {
|
|
2910
|
+
version: ENGINE_API_VERSION, canChange, digest: stateDigest(store, INSTALLATION_SCOPE), problem: checked.kind === "ok" ? null : browserWords(checked.problem),
|
|
2911
|
+
roles, defaultAgent: build?.provider ?? null, presets,
|
|
2912
|
+
})));
|
|
2913
|
+
}
|
|
2859
2914
|
async function modelsSave(ctx) {
|
|
2860
2915
|
const { response, now, posted } = ctx;
|
|
2861
2916
|
const who = browserCaller(ctx.who);
|
|
@@ -2933,6 +2988,59 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
2933
2988
|
return back("problem", turned.reason === "not-on" ? "Local mode is already off." : "Only an instance operator can turn off local mode.");
|
|
2934
2989
|
return done("said", "Local mode is off. This computer's browser signs in with your password now.");
|
|
2935
2990
|
}
|
|
2991
|
+
async function taskSizingAct(ctx) {
|
|
2992
|
+
const { response, now, posted } = ctx;
|
|
2993
|
+
const who = browserCaller(ctx.who);
|
|
2994
|
+
const body = readForm(posted, CONSOLE_FORMS.taskSizing);
|
|
2995
|
+
const done = sayTo(response, "/settings/general?section=task-sizing");
|
|
2996
|
+
const back = sayTo(response, "/settings/change/task-sizing");
|
|
2997
|
+
if (["password", "enabled", "sizer"].some(field => body.sent.getAll(field).length > 1))
|
|
2998
|
+
return back("problem", "That form was sent twice over. Nothing changed.");
|
|
2999
|
+
const wanted = body.get("enabled");
|
|
3000
|
+
if (wanted !== "on" && wanted !== "off")
|
|
3001
|
+
return back("problem", "Choose on or off.");
|
|
3002
|
+
const shown = body.get("sizer");
|
|
3003
|
+
const saved = store.transact(() => {
|
|
3004
|
+
if (!store.isInstanceOperator(who.name))
|
|
3005
|
+
return "proof";
|
|
3006
|
+
if (who.authority !== "full" && localActNow(store, "task-sizing-switch") === null)
|
|
3007
|
+
return "proof";
|
|
3008
|
+
if (!authenticateApprover(who, body.get("password") ?? "").ok)
|
|
3009
|
+
return "proof";
|
|
3010
|
+
const available = taskSizingSetting(store).available;
|
|
3011
|
+
if (wanted === "on" && shown !== available)
|
|
3012
|
+
return "moved";
|
|
3013
|
+
setTaskSizing(store, wanted === "on" ? available : false, who.name, now);
|
|
3014
|
+
return "ok";
|
|
3015
|
+
});
|
|
3016
|
+
if (saved === "proof")
|
|
3017
|
+
return back("problem", "Enter your Toolroll password to change task sizing.");
|
|
3018
|
+
if (saved === "moved")
|
|
3019
|
+
return back("problem", "Which model would size your tasks changed since you looked. Nothing changed; look again.");
|
|
3020
|
+
const read = taskSizingSetting(store);
|
|
3021
|
+
return done("said", wanted === "on" ? `Task sizing is on. Each new task is sized by ${read.available === "jev" ? "Jev through your OpenRouter key" : "a quick call to Claude Haiku on your plan"} before you approve.` : "Task sizing is off. No model call before you approve; uncertain tasks get a plan first.");
|
|
3022
|
+
}
|
|
3023
|
+
async function justMe(ctx) {
|
|
3024
|
+
const { response, now, posted } = ctx;
|
|
3025
|
+
const who = browserCaller(ctx.who);
|
|
3026
|
+
const body = readForm(posted, CONSOLE_FORMS.justMe);
|
|
3027
|
+
const done = sayTo(response, "/settings/general?section=install-mode");
|
|
3028
|
+
const back = sayTo(response, "/settings/change/just-me");
|
|
3029
|
+
if (body.sent.getAll("password").length > 1)
|
|
3030
|
+
return back("problem", "That form was sent twice over. Nothing changed.");
|
|
3031
|
+
if (who.authority !== "full")
|
|
3032
|
+
return back("problem", "Sign in with your password to do this.");
|
|
3033
|
+
const said = store.transact(() => {
|
|
3034
|
+
if (!authenticateCredential(who, body.get("password") ?? "").ok)
|
|
3035
|
+
return null;
|
|
3036
|
+
return declareJustMe(store, who.name, now);
|
|
3037
|
+
});
|
|
3038
|
+
if (said === null)
|
|
3039
|
+
return back("problem", "Enter your Toolroll password to say it's just you.");
|
|
3040
|
+
if (!said.ok)
|
|
3041
|
+
return back("problem", said.reason === "already-solo" ? "This install is already solo." : said.reason === "not-owner" ? "Only an instance operator can say this." : said.facts.map(fact => TEAM_FACT_WORDS[fact]).join(" "));
|
|
3042
|
+
return done("said", "This install is solo now.");
|
|
3043
|
+
}
|
|
2936
3044
|
function suggestedView(repo, projects, asked, now) {
|
|
2937
3045
|
const repos = repo === null ? projects : [repo];
|
|
2938
3046
|
const offers = repos.flatMap(one => suggestionsFor(store, one, now));
|
|
@@ -3087,8 +3195,10 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
3087
3195
|
updatesVersion: name => settingsUpdates(name, "")?.current ?? null,
|
|
3088
3196
|
packageVersion: PACKAGE_VERSION,
|
|
3089
3197
|
firstResult: now => { const at = store.firstSuccessAt(now), since = store.installationStartedAt(); return at === null || since === null ? null : firstResultWords(since, at); },
|
|
3090
|
-
passwordless: () =>
|
|
3198
|
+
passwordless: () => sessionStandsIn(store),
|
|
3091
3199
|
localModeOn: () => localModeOf(store)?.enabled === true,
|
|
3200
|
+
installMode: () => installModeNow(store),
|
|
3201
|
+
taskSizing: () => taskSizingSetting(store),
|
|
3092
3202
|
});
|
|
3093
3203
|
const computersDeps = {
|
|
3094
3204
|
computers: (now, manage) => computersOf(store, now, visible, manage),
|
|
@@ -58,10 +58,11 @@ import { buildReviewOf } from "../review-switch.js";
|
|
|
58
58
|
import { isAlive as runnerAlive } from "../runner.js";
|
|
59
59
|
import { approvalOf } from "../scope.js";
|
|
60
60
|
import { oneLineOf, refuse, screen, withScript } from "./chrome.js";
|
|
61
|
-
import { chatResultHref, reviewHref, taskChatHref, taskHref } from "./http.js";
|
|
61
|
+
import { chatResultHref, refusedInPlace, reviewHref, taskChatHref, taskHref } from "./http.js";
|
|
62
62
|
import { decisionsFor } from "./render-chat.js";
|
|
63
63
|
import {} from "./render-pages.js";
|
|
64
64
|
import { completionReceiptView, diffFileAnchor, evidenceLinksFor, followUpsFor, orderChangedFiles, parseReviewDiff, proofBundleView, receiptStatusOf, withinSignedTouches } from "./render-results.js";
|
|
65
|
+
import { approvalSummaryOf, summaryContextOf } from "../approval-summary.js";
|
|
65
66
|
import { approvalFormDigest, consentDoorOf, nonceHashOf, publicationFactsOf, resumeCeremonyPage, resumeDigestOf, taskBody, taskPage } from "./render-tasks.js";
|
|
66
67
|
import {} from "./session.js";
|
|
67
68
|
import { mergeReadyViewOf } from "./merge-ready-view.js";
|
|
@@ -241,8 +242,9 @@ export function createTaskViews(runtime) {
|
|
|
241
242
|
const revision = revisionViewOf(ref);
|
|
242
243
|
const revisionBroken = revision !== null && "problem" in revision;
|
|
243
244
|
const planView = ref === null ? null : planViewOf(ref.id);
|
|
244
|
-
const approvalDigest = scope === null ? null : approvalFormDigest(scope.digest, planView?.sha256 ?? null);
|
|
245
245
|
const routeView = routeViewOf(taskId, ref, scope, now, who);
|
|
246
|
+
const approvalSummary = scope === null ? null : approvalSummaryOf(scope, summaryContextOf(runtime.store, taskId, scope, now, routeView?.evidence ?? null));
|
|
247
|
+
const approvalDigest = scope === null ? null : approvalFormDigest(scope.digest, planView?.sha256 ?? null, approvalSummary?.key ?? null);
|
|
246
248
|
const nonce = who.via === "cookie" && scope !== null && approvalDigest !== null && !approvalOf(scope).approved && !revisionBroken && ref?.plan !== "requested" && consentDoorOf(scope, routeView).open
|
|
247
249
|
? render.mintNonce === false ? "unminted" : runtime.mintApprovalNonce(who.name, taskId, approvalDigest)
|
|
248
250
|
: "";
|
|
@@ -406,6 +408,7 @@ export function createTaskViews(runtime) {
|
|
|
406
408
|
mirror: runtime.store.mirrorByTask(taskId),
|
|
407
409
|
scope,
|
|
408
410
|
approvalDigest,
|
|
411
|
+
approvalSummary,
|
|
409
412
|
route: routeView,
|
|
410
413
|
canEditRoute: who.role === "approver",
|
|
411
414
|
resultRecord: resultRecordWordsOf(runtime.store, taskId, runtime.evidenceRoot, now),
|
|
@@ -547,6 +550,7 @@ export function createTaskViews(runtime) {
|
|
|
547
550
|
scope,
|
|
548
551
|
nonce: view.nonce,
|
|
549
552
|
digest: view.approvalDigest ?? scope.digest,
|
|
553
|
+
summary: view.approvalSummary ?? null,
|
|
550
554
|
planDocument: view.planDocument,
|
|
551
555
|
planContract: view.planContract ?? null,
|
|
552
556
|
deliverable: view.deliverable ?? "branch",
|
|
@@ -691,6 +695,8 @@ export function createTaskViews(runtime) {
|
|
|
691
695
|
};
|
|
692
696
|
}
|
|
693
697
|
function taskScreen(response, who, taskId, problem, status, scopeDraft, cancelDraft, editPlan = false, extras = {}) {
|
|
698
|
+
if (problem !== null && refusedInPlace(response, status, problem))
|
|
699
|
+
return;
|
|
694
700
|
const admittedFamily = runtime.familyOf(taskId);
|
|
695
701
|
if (admittedFamily?.problem != null)
|
|
696
702
|
return runtime.sendScreen(response, status, screen(admittedFamily.root.title, html `<h1>${admittedFamily.root.title}</h1><p>${admittedFamily.current.state}</p><p class="problem" data-history-problem>${admittedFamily.problem}</p>${extras.result == null ? "" : html `<section class="task-result-tab" id="task-result" aria-label="Result" data-result-task="${extras.result.selected.taskId}">${extras.result.html}</section>`}`, { chrome: runtime.chromeFor(admittedFamily.root.repo, "tasks"), ...(extras.result == null ? {} : { functional: { script: `${reviewEvidenceScript()}${RESULT_REVIEW_SCRIPT}` } }) }));
|
package/dist/server/tasks.js
CHANGED
|
@@ -67,6 +67,7 @@ import { structuredHandoffView, terminalDiffView } from "../result-evidence-read
|
|
|
67
67
|
import { fileAddTestsTask, requestFollowUpChecks } from '../result-follow-ups.js';
|
|
68
68
|
import { commentSourceKey, isRevisionFeedback, parseResultTab, resultReturnTarget } from "../result-review.js";
|
|
69
69
|
import { isAlive as runnerAlive } from "../runner.js";
|
|
70
|
+
import { soloNow } from "../install-mode.js";
|
|
70
71
|
import { passwordlessSessionFor, acceptanceLinesToInput, acceptanceToLines, approvalOf, approve as approveScope, freshnessFor, freshlyApprovable, localApprovalEligible, spendingOnlyOnSuccess, ssoNowAvailable, withFreshness, modeFilingCoverage, PLACEHOLDER_RUBRIC, proposeGuarded } from "../scope.js";
|
|
71
72
|
import { subagentNames as subagentNamesOf } from "../spend.js";
|
|
72
73
|
import { verifiedAuthor } from "../store.js";
|
|
@@ -80,20 +81,23 @@ import { buildProgressOf, parseWorkView } from "../workspace-ui.js";
|
|
|
80
81
|
import { requestContext } from "./request-context.js";
|
|
81
82
|
import { boardTickScript, oneLineOf, QUEUE_VIEW, refuse, regionScript, screen, transcriptScript, whenTime } from "./chrome.js";
|
|
82
83
|
import { retiredHandler, retiredRedirect, TASK_VIEW_REDIRECTS } from "./retired-routes.js";
|
|
83
|
-
import { answersInPlace, chatReturnWithSaid, matchTaskPath, redirect, respond, reviewHref, safeChatReturn, safeReturn, SAFETY, taskChatHref, taskHref } from "./http.js";
|
|
84
|
+
import { answersInPlace, refusedInPlace, chatReturnWithSaid, matchTaskPath, redirect, respond, reviewHref, safeChatReturn, safeReturn, SAFETY, taskChatHref, taskHref } from "./http.js";
|
|
84
85
|
import { taskLinkOf } from "../task-link.js";
|
|
85
86
|
import { putAwayPage, boardBody, boardWorkers, QUEUE_FRONT, queueBody, queueScript, TASK_STATES, workPage } from "./render-pages.js";
|
|
86
87
|
import { runEfficiencyOf } from "../run-efficiency.js";
|
|
87
88
|
import { timingFor } from "../latency-timeline.js";
|
|
88
89
|
import { ACCEPT_ANYWAY_NEEDS_REASON, editorFileHref, proofBundleView, rankReviewQueue, RESULT_REFUSALS, REVIEW_QUEUE_CAP, reviewCockpitDetailParts, reviewCockpitPage, reviewPriorityOf, runFactsFragment, runOutcomeBadge, withRefusal } from "./render-results.js";
|
|
90
|
+
import { approvalSummaryFor } from "../approval-summary.js";
|
|
89
91
|
import { approvalFormDigest, approveRefusalWords, checkProgressHtml, consentDoorOf, nonceHashOf, PermissionsWouldChange, requirementsFromEditor, resumeDigestOf, taskOf } from "./render-tasks.js";
|
|
90
92
|
import {} from "./session.js";
|
|
91
93
|
import { approveReleaseCard, releaseApprovalCard, releaseSheetHref, releaseTaskOf } from "../release-approval.js";
|
|
92
94
|
import { releaseSheetPage } from "./render-release.js";
|
|
93
95
|
import { approvalFactsNow } from "./kit.js";
|
|
94
96
|
import { localOwnerRefusal } from "../local-owner.js";
|
|
97
|
+
import { firstTaskRouted } from "../welcome-facts.js";
|
|
98
|
+
export const FIRST_TASK_DETECT_WAIT_MS = 8_000;
|
|
95
99
|
export function createTasksHandlers(runtime) {
|
|
96
|
-
const { identities, store, peekSay, peekCache, PEEK_CACHE_TTL_MS, peekInFlight, PEEK_GLOBAL_INFLIGHT, peekBySession, PEEK_SESSION_INFLIGHT, clock, peekName, PEEK_FRAGMENT_BYTES, peekEvict, evidenceRoot, sendScreen, chromeFor, visible, consumeApprovalNonce, authenticateApprover, options, mintApprovalNonce, taskScreen, unscopedMode, admissionList, planViewOf, revisionViewOf, runIsTaskResult, leadPrincipal, familyOf, armTaskResume, runIsLive, revisionLedgerOf, resultDetailOf, reviewFactsFor, taskRepoOf, runVisible, restricted, codingActorAllowed, codingProjectAllowed, managedRepos, routeViewOf, workAccess, firstRunStepsNow, revisionDocOf, failureOf, dockedConversation, planContractViewOf, familiesInView, explainAttempt, taskChatFocus, familyTasksInView, liveCeiling, projectOf, ceiling, bustBadge, revisionDestination } = runtime;
|
|
100
|
+
const { identities, store, peekSay, peekCache, PEEK_CACHE_TTL_MS, peekInFlight, PEEK_GLOBAL_INFLIGHT, peekBySession, PEEK_SESSION_INFLIGHT, clock, peekName, PEEK_FRAGMENT_BYTES, peekEvict, evidenceRoot, sendScreen, chromeFor, visible, consumeApprovalNonce, authenticateApprover, authenticateCredential, options, mintApprovalNonce, taskScreen, unscopedMode, admissionList, planViewOf, revisionViewOf, runIsTaskResult, leadPrincipal, familyOf, armTaskResume, runIsLive, revisionLedgerOf, resultDetailOf, reviewFactsFor, taskRepoOf, runVisible, restricted, codingActorAllowed, codingProjectAllowed, managedRepos, routeViewOf, workAccess, firstRunStepsNow, revisionDocOf, failureOf, dockedConversation, planContractViewOf, familiesInView, explainAttempt, taskChatFocus, familyTasksInView, liveCeiling, projectOf, ceiling, bustBadge, revisionDestination } = runtime;
|
|
97
101
|
function noPage(who, response) {
|
|
98
102
|
return refuse(response, who, 404, "There's no page at this address.", "/chat");
|
|
99
103
|
}
|
|
@@ -651,7 +655,7 @@ export function createTasksHandlers(runtime) {
|
|
|
651
655
|
const decision = body.get('decision');
|
|
652
656
|
if (decision !== 'accept' && decision !== 'decline' && decision !== 'cancel')
|
|
653
657
|
return fail(400, 'Choose an explicit decision for this request.');
|
|
654
|
-
if (pending.kind !== 'questions' && decision === 'accept' && !
|
|
658
|
+
if (pending.kind !== 'questions' && decision === 'accept' && !authenticateCredential(who, body.get('password') ?? '').ok)
|
|
655
659
|
return fail(403, 'Enter your password to approve this additional access.');
|
|
656
660
|
const answers = body.has('answers') ? JSON.parse(body.get('answers')) : Object.fromEntries(pending.questions.map(q => [q.id, { answers: [body.get(`question:${q.id}`) ?? ''] }]));
|
|
657
661
|
runtime.coding.answer(id, actor, token, decision, answers);
|
|
@@ -747,7 +751,12 @@ export function createTasksHandlers(runtime) {
|
|
|
747
751
|
}
|
|
748
752
|
if (who.via === "cookie" && body.get("plain") !== "1" && repo !== "" && goal === "" && notThis === "" && touchesGiven.length === 0 && !scout && id === "" && after === ""
|
|
749
753
|
&& (qualityMode === null || qualityMode === "default") && (permissionMode === null || permissionMode === "auto")) {
|
|
750
|
-
|
|
754
|
+
if (firstTaskRouted(store) === null)
|
|
755
|
+
await runtime.localAgentsSettled(FIRST_TASK_DETECT_WAIT_MS);
|
|
756
|
+
const fast = await prepareFastStart(store, { actor: who.name, repo, title: typed.trim(), via: "console", ...(permissionMode === null ? {} : { permissionMode }), password: fastPasswordFacts(who),
|
|
757
|
+
planFirst: body.get("plan-first") === "1" }, now);
|
|
758
|
+
if (fast.eligible && requestContext.getStore()?.terminalAct === true)
|
|
759
|
+
return answerTermsInPlace(response, { preview: fast.preview, digest: fast.digest, terms: fastTermsRows(store, fast.scope, repo) });
|
|
751
760
|
if (fast.eligible)
|
|
752
761
|
return sendScreen(response, 200, fastStartPage(chromeFor(project ?? null, "tasks"), { title: typed.trim(), repo, preview: fast.preview, digest: fast.digest, terms: fastTermsRows(store, fast.scope, repo) }));
|
|
753
762
|
}
|
|
@@ -1595,7 +1604,16 @@ export function createTasksHandlers(runtime) {
|
|
|
1595
1604
|
return redirect(response, taskHref(taskId));
|
|
1596
1605
|
}
|
|
1597
1606
|
case "unhold": {
|
|
1598
|
-
|
|
1607
|
+
const shown = readForm(posted, CONSOLE_FORMS.taskUnhold).get("hold");
|
|
1608
|
+
if (shown !== null && !/^[1-9][0-9]{0,15}$/.test(shown))
|
|
1609
|
+
return taskScreen(response, who, taskId, "not resumed: name the hold that was shown", 400);
|
|
1610
|
+
const ended = store.getTask(taskId)?.state;
|
|
1611
|
+
if (ended === "cancelled" || ended === "done") {
|
|
1612
|
+
return taskScreen(response, who, taskId, ended === "cancelled" ? "This task was cancelled, so there is nothing to resume." : "This task is finished, so there is nothing to resume.", 409);
|
|
1613
|
+
}
|
|
1614
|
+
const released = store.unhold(ref.id, {}, now, shown === null ? undefined : Number(shown));
|
|
1615
|
+
if (shown !== null && !released)
|
|
1616
|
+
return taskScreen(response, who, taskId, "This task's hold changed since it was shown — look again before resuming.", 409);
|
|
1599
1617
|
return redirect(response, taskHref(taskId));
|
|
1600
1618
|
}
|
|
1601
1619
|
case "stop-carrying": {
|
|
@@ -1623,9 +1641,16 @@ export function createTasksHandlers(runtime) {
|
|
|
1623
1641
|
replayed = retried.replayed;
|
|
1624
1642
|
}
|
|
1625
1643
|
else {
|
|
1626
|
-
const
|
|
1644
|
+
const sentRun = body.get("run") ?? null, sentDigest = body.get("digest") ?? null;
|
|
1645
|
+
let pins;
|
|
1646
|
+
if (sentRun !== null || sentDigest !== null) {
|
|
1647
|
+
if (sentRun === null || !/^[1-9][0-9]{0,14}$/.test(sentRun) || sentDigest === null || !/^[a-f0-9]{32}$/.test(sentDigest))
|
|
1648
|
+
return taskScreen(response, who, taskId, TASK_CHANGED_SINCE, 409);
|
|
1649
|
+
pins = { run: Number(sentRun), digest: sentDigest };
|
|
1650
|
+
}
|
|
1651
|
+
const requeued = store.requeueTask(taskId, who.name, now, undefined, pins);
|
|
1627
1652
|
if (!requeued.ok) {
|
|
1628
|
-
return taskScreen(response, who, taskId, `not requeued: ${requeued.reason}`, 409);
|
|
1653
|
+
return taskScreen(response, who, taskId, requeued.reason === "stale" ? TASK_CHANGED_SINCE : `not requeued: ${requeued.reason}`, 409);
|
|
1629
1654
|
}
|
|
1630
1655
|
}
|
|
1631
1656
|
if (note !== "" && !replayed) {
|
|
@@ -1768,7 +1793,17 @@ export function createTasksHandlers(runtime) {
|
|
|
1768
1793
|
case "cancel": {
|
|
1769
1794
|
const body = readForm(posted, CONSOLE_FORMS.taskCancel);
|
|
1770
1795
|
const reason = body.get("reason") ?? undefined;
|
|
1771
|
-
const
|
|
1796
|
+
const seenState = body.get("state"), seenRun = body.get("run");
|
|
1797
|
+
if ((seenState === null) !== (seenRun === null) || (seenRun !== null && !/^(?:none|[1-9][0-9]{0,15})$/.test(seenRun))) {
|
|
1798
|
+
return taskScreen(response, who, taskId, "not cancelled: name both the state and the build that were shown", 400);
|
|
1799
|
+
}
|
|
1800
|
+
if (who.via === "cookie" && seenState === null)
|
|
1801
|
+
return taskScreen(response, who, taskId, "not cancelled: name both the state and the build that were shown", 400);
|
|
1802
|
+
const seen = seenState === null || seenRun === null ? undefined : { state: seenState, run: seenRun === "none" ? null : Number(seenRun) };
|
|
1803
|
+
const cancelled = withActor({ account: who.name, lead: false }, () => store.cancelTask(taskId, now, reason, seen));
|
|
1804
|
+
if (!cancelled.ok && cancelled.reason === "changed") {
|
|
1805
|
+
return taskScreen(response, who, taskId, "This task changed since it was shown — look again before cancelling.", 409);
|
|
1806
|
+
}
|
|
1772
1807
|
if (!cancelled.ok) {
|
|
1773
1808
|
if (cancelled.reason === "reason-required" || cancelled.reason === "bad-reason") {
|
|
1774
1809
|
return taskScreen(response, who, taskId, cancelled.reason === "reason-required"
|
|
@@ -1981,8 +2016,11 @@ export function createTasksHandlers(runtime) {
|
|
|
1981
2016
|
const scopeRow = store.getScope(taskId);
|
|
1982
2017
|
if (scopeRow === null)
|
|
1983
2018
|
return approvalProblem("refused", "this task has no scope to approve", 409);
|
|
1984
|
-
const
|
|
1985
|
-
|
|
2019
|
+
const formDigestNow = () => {
|
|
2020
|
+
const live = store.getScope(taskId);
|
|
2021
|
+
return live === null ? null : approvalFormDigest(live.digest, planViewOf(ref.id)?.sha256 ?? null, approvalSummaryFor(store, taskId, now)?.key ?? null);
|
|
2022
|
+
};
|
|
2023
|
+
const expectedDigest = formDigestNow();
|
|
1986
2024
|
if (digest !== expectedDigest) {
|
|
1987
2025
|
return approvalProblem("refused", "the scope or plan changed while this form was open — read the latest version and approve again", 409);
|
|
1988
2026
|
}
|
|
@@ -1992,7 +2030,7 @@ export function createTasksHandlers(runtime) {
|
|
|
1992
2030
|
return approvalProblem("refused", `approval is blocked: ${view.problem}`, 409);
|
|
1993
2031
|
}
|
|
1994
2032
|
}
|
|
1995
|
-
const approved = spendingOnlyOnSuccess(() => withFreshness("approve-standard", () => approveScope(store, taskId, who.name, now, scopeRow.digest, token)), result => !result.ok && !(result.reason === "second-approver" && !result.already));
|
|
2033
|
+
const approved = spendingOnlyOnSuccess(() => withFreshness("approve-standard", () => store.transact(() => formDigestNow() !== digest ? { ok: false, reason: "changed" } : approveScope(store, taskId, who.name, now, scopeRow.digest, token))), result => !result.ok && !(result.reason === "second-approver" && !result.already));
|
|
1996
2034
|
if (!approved.ok) {
|
|
1997
2035
|
if (approved.reason === "second-approver")
|
|
1998
2036
|
return approvalProblem("vote", gateWords({ verdict: "vote", have: approved.have, need: 2, already: approved.already }), 200);
|
|
@@ -2590,6 +2628,8 @@ export function createTasksHandlers(runtime) {
|
|
|
2590
2628
|
});
|
|
2591
2629
|
function newTaskScreen(ctx, status, problem, draft, text = null) {
|
|
2592
2630
|
const { who, response, project } = ctx;
|
|
2631
|
+
if (problem !== null && refusedInPlace(response, status, problem))
|
|
2632
|
+
return;
|
|
2593
2633
|
const chainable = store
|
|
2594
2634
|
.listTasksScoped(project, undefined, 100, null)
|
|
2595
2635
|
.filter(one => one.state !== "done" && one.state !== "cancelled" && visible(one.repo))
|
|
@@ -2602,7 +2642,7 @@ export function createTasksHandlers(runtime) {
|
|
|
2602
2642
|
const startsOn = draft?.values?.get("repo") ?? project ?? chrome.projects?.[0]?.path ?? null;
|
|
2603
2643
|
const found = startsOn === null ? null : runtime.firstTasks.get(startsOn)?.found ?? null;
|
|
2604
2644
|
const ideas = found ?? (runtime.firstRunStepsNow(ctx.now) !== null && !store.hasAnyWork() ? firstTaskSuggestions({ issues: [], todos: [] }) : []);
|
|
2605
|
-
return sendScreen(response, status, newTaskPage(chrome, project, revision, problem, chainable, store.permissionDefault().mode, store.qualityDefault().mode, chrome.projects ?? [], draft, text, ideas, ctx.url.searchParams.get("from")?.slice(0, 300) ?? null));
|
|
2645
|
+
return sendScreen(response, status, newTaskPage(chrome, project, revision, problem, chainable, store.permissionDefault().mode, store.qualityDefault().mode, chrome.projects ?? [], draft, text, ideas, ctx.url.searchParams.get("from")?.slice(0, 300) ?? null, soloNow(store)));
|
|
2606
2646
|
}
|
|
2607
2647
|
function fastPasswordFacts(who) {
|
|
2608
2648
|
return { passwordless: passwordlessSessionFor(store, who.name), localOwner: who.via === "cookie" && who.authority === "local-owner",
|
|
@@ -2898,3 +2938,7 @@ export function withContext(context, typed) {
|
|
|
2898
2938
|
return [(context ?? "").trim(), typed.trim()].filter(one => one !== "").join("\n\n");
|
|
2899
2939
|
}
|
|
2900
2940
|
export const YOU_SAID_CAP = 8;
|
|
2941
|
+
export function answerTermsInPlace(response, offer) {
|
|
2942
|
+
respond(response, 200, "application/json; charset=utf-8", JSON.stringify({ outcome: "terms", preview: offer.preview, digest: offer.digest, terms: offer.terms.map(([label, words]) => ({ label, words })) }));
|
|
2943
|
+
}
|
|
2944
|
+
export const TASK_CHANGED_SINCE = "This task changed since you looked. Review it again.";
|