toolroll 0.9.107 → 0.9.109
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 +54 -0
- package/README.md +4 -3
- package/dist/advanced-view.js +0 -1
- package/dist/agent-fence.js +35 -4
- package/dist/agent-state.js +5 -2
- package/dist/assignment-ui.js +5 -5
- package/dist/assignment.js +5 -2
- package/dist/browser/terminal.js +1 -1
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +38 -33
- package/dist/browser-crew.js +4 -4
- package/dist/browser-shell.js +1 -1
- package/dist/browser-workspace.js +4 -11
- package/dist/builder.js +9 -1
- package/dist/chat-controls.js +6 -5
- package/dist/chat-decide.js +1 -1
- package/dist/chat-quiet.js +3 -3
- package/dist/chat-voice.js +2 -2
- package/dist/cli-help.js +17 -13
- package/dist/cli.js +4 -3
- package/dist/console-chrome.js +10 -3
- package/dist/contracts/cli.js +2 -0
- package/dist/contracts/console-api.js +5 -4
- package/dist/contracts/handoff.js +4 -0
- 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/dispatch.js +3 -8
- package/dist/flexible-available.js +1 -0
- package/dist/flexible-schema.js +32 -0
- package/dist/flexible-thread-schema.js +30 -0
- package/dist/flexible-thread.js +526 -0
- package/dist/flexible-ui.js +44 -0
- package/dist/flexible.js +359 -0
- package/dist/folder-look.js +65 -4
- package/dist/git-views.js +38 -38
- package/dist/guides.js +14 -11
- package/dist/keymap.js +1 -1
- package/dist/lead-cli.js +2 -1
- package/dist/lead-context.js +1 -1
- package/dist/limits-ui.js +1 -1
- package/dist/live-bus.js +82 -12
- package/dist/login-secrets.js +43 -0
- package/dist/needs-you.js +3 -3
- package/dist/nightly-github.js +2 -2
- package/dist/operate.js +278 -21
- package/dist/project-admission.js +60 -29
- package/dist/project-delete-ui.js +2 -1
- package/dist/project-delete.js +1 -0
- package/dist/project.js +73 -0
- package/dist/provider-auth.js +1 -1
- package/dist/release.js +1 -0
- package/dist/repos.js +37 -0
- 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-hooks.js +1 -0
- package/dist/sample-project.js +167 -9
- package/dist/scope.js +17 -2
- package/dist/serve.js +47 -32
- package/dist/server/chat.js +9 -9
- package/dist/server/chrome.js +16 -16
- package/dist/server/guards.js +10 -4
- package/dist/server/home.js +37 -5
- package/dist/server/http.js +4 -2
- package/dist/server/in-place.js +5 -4
- package/dist/server/kit.js +2 -2
- package/dist/server/live.js +103 -10
- package/dist/server/login-help.js +67 -0
- package/dist/server/pages.js +258 -78
- package/dist/server/people-tokens.js +36 -24
- package/dist/server/render-chat.js +1 -1
- package/dist/server/render-history.js +18 -4
- package/dist/server/render-new-task.js +2 -2
- package/dist/server/render-pages.js +21 -39
- package/dist/server/render-people.js +16 -4
- package/dist/server/render-projects.js +63 -15
- package/dist/server/render-results.js +26 -10
- package/dist/server/render-tasks.js +26 -17
- package/dist/server/retired-routes.js +37 -4
- package/dist/server/route-policy.js +8 -0
- package/dist/server/route-table.js +15 -5
- package/dist/server/settings-computers.js +140 -0
- package/dist/server/settings-scripts.js +15 -0
- package/dist/server/settings-section-table.js +56 -0
- package/dist/server/settings-sections.js +258 -0
- package/dist/server/settings.js +167 -19
- package/dist/server/task-views.js +47 -13
- package/dist/server/tasks.js +143 -90
- package/dist/server/welcome.js +35 -23
- package/dist/settings-groups-ui.js +34 -106
- package/dist/settings-proofs.js +5 -2
- package/dist/sqlite-telemetry.js +70 -21
- package/dist/store.js +141 -9
- package/dist/surface.js +4 -1
- package/dist/task-link.js +64 -0
- package/dist/task-outcome-cli.js +99 -4
- package/dist/tui-source.js +11 -3
- package/dist/tui.js +39 -39
- package/dist/typed-words-schema.js +18 -0
- package/dist/welcome-facts.js +15 -7
- package/dist/work-index.js +126 -29
- package/dist/work-reads.js +279 -0
- package/package.json +4 -2
|
@@ -11,7 +11,7 @@ import { acts, approvalFactsNow, approvalTerms, approveForm, btn, chip, count, d
|
|
|
11
11
|
import {} from "./render-pages.js";
|
|
12
12
|
export function shortPathOf(path) {
|
|
13
13
|
const home = homedir();
|
|
14
|
-
return path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
|
|
14
|
+
return path === home ? "~" : path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
|
|
15
15
|
}
|
|
16
16
|
export function projectHref(name, path, ambiguous, page = "") {
|
|
17
17
|
return `/projects/${encodeURIComponent(name)}${page === "" ? "" : `/${page}`}${ambiguous ? `?path=${encodeURIComponent(path)}` : ""}`;
|
|
@@ -29,6 +29,7 @@ const mono = (text) => html `<span class="k-mono">${text}</span>`;
|
|
|
29
29
|
const sentence = (text) => text === "" ? text : `${text.charAt(0).toUpperCase()}${text.slice(1)}`;
|
|
30
30
|
const refused = (text) => /nothing (changed|was)/i.test(text) ? sentence(text) : `${sentence(text).replace(/[.\s]+$/, "")}. Nothing changed.`;
|
|
31
31
|
export function addWaysHtml(data) {
|
|
32
|
+
const local = data.local ?? { outside: false, pick: false, pathProblem: null, pathValue: "" };
|
|
32
33
|
const onboard = data.onboard;
|
|
33
34
|
const github = onboard === null
|
|
34
35
|
? null
|
|
@@ -46,15 +47,19 @@ export function addWaysHtml(data) {
|
|
|
46
47
|
onboard.roots.length === 1 ? note(html `Clones into ${mono(shortPathOf(onboard.roots[0] ?? ""))}.`) : "",
|
|
47
48
|
]), { attrs: { class: "k-sec" } }),
|
|
48
49
|
])}</section>`;
|
|
49
|
-
const
|
|
50
|
-
|
|
50
|
+
const thisComputer = html `<section class="k-sec" aria-labelledby="add-local"><h3 id="add-local">From this computer</h3>${joinHtml([
|
|
51
|
+
local.pathProblem === null ? "" : notice(refused(local.pathProblem)),
|
|
52
|
+
local.pick ? acts(btn("Browse…", { sm: true, href: "/projects/pick" }))
|
|
53
|
+
: data.browsable ? acts(btn("Choose a folder", { sm: true, href: "/projects/browse" })) : "",
|
|
51
54
|
postForm("/projects/open", joinHtml([
|
|
52
|
-
field({ id: "add-path", label: "Or enter an exact path",
|
|
53
|
-
|
|
55
|
+
field({ id: "add-path", label: "Or enter an exact path",
|
|
56
|
+
hint: local.outside ? "Add any git repository on this computer — outside your projects folder, Toolroll asks for your password." : "It must be a git repository.",
|
|
57
|
+
error: null,
|
|
58
|
+
control: input({ id: "add-path", name: "path", hint: true, error: local.pathProblem !== null, value: local.pathValue, attrs: { placeholder: "~/code/your-repo", autocomplete: "off", spellcheck: "false", autocapitalize: "none" } }) }),
|
|
54
59
|
acts(btn("Add and open", { sm: true, type: "submit", variant: "primary" })),
|
|
55
|
-
]), { attrs: { class: "k-sec" }, returnTo: data.returnTo }),
|
|
60
|
+
]), { attrs: { class: "k-sec" }, returnTo: data.returnTo, hidden: { via: "path" } }),
|
|
56
61
|
])}</section>`;
|
|
57
|
-
return html `<div class="k-sec">${github ?? ""}${
|
|
62
|
+
return html `<div class="k-sec">${github ?? ""}${thisComputer}</div>`;
|
|
58
63
|
}
|
|
59
64
|
export function cloneReviewHtml(onboard, problem) {
|
|
60
65
|
if (onboard === null || !onboard.enabled || onboard.record === null)
|
|
@@ -97,8 +102,10 @@ export function projectsPage(chrome, data) {
|
|
|
97
102
|
const review = cloneReviewHtml(data.onboard, data.problemAt === "clone" ? data.problem : null);
|
|
98
103
|
const reviewHasProblem = review !== null && data.problemAt === "clone";
|
|
99
104
|
const said = data.problemAt === "said" && data.problem !== null ? sentence(data.problem) : null;
|
|
100
|
-
const
|
|
101
|
-
const
|
|
105
|
+
const pathProblem = data.problemAt === "path" ? data.problem : null;
|
|
106
|
+
const topProblem = data.problem === null || said !== null || linkProblem !== null || pathProblem !== null || reviewHasProblem ? null : data.problemAt === "clone" ? sentence(data.problem) : refused(data.problem);
|
|
107
|
+
const addHtml = addWaysHtml({ browsable: data.browsable, onboard: data.onboard, returnTo: data.returnTo, linkProblem,
|
|
108
|
+
...(data.local === undefined ? {} : { local: { ...data.local, pathProblem } }) });
|
|
102
109
|
const rowHtml = (one) => row({
|
|
103
110
|
href: one.href, chip: one.status === null ? html `` : one.status === "needs" ? chip(waitingWords(one.waiting), "ask") : status(one.status), title: one.name, wait: one.status === "needs",
|
|
104
111
|
desc: mono(one.shortPath), meta: html `<span>${one.summary ?? "Not scanned"}</span>${one.open ? html `<span>Open now</span>` : ""}`,
|
|
@@ -118,7 +125,7 @@ export function projectsPage(chrome, data) {
|
|
|
118
125
|
], "\n");
|
|
119
126
|
return screen(title, body, { chrome, workspace: { view: {
|
|
120
127
|
kind: "projects", choosing, problem: topProblem, said, returnTo: data.returnTo, recent, available,
|
|
121
|
-
add: { html: htmlString(addHtml), review: review === null ? null : htmlString(review), openOnLoad: linkProblem !== null },
|
|
128
|
+
add: { html: htmlString(addHtml), review: review === null ? null : htmlString(review), openOnLoad: linkProblem !== null || pathProblem !== null },
|
|
122
129
|
} } });
|
|
123
130
|
}
|
|
124
131
|
function activityHtml(report) {
|
|
@@ -144,17 +151,17 @@ export function projectPage(chrome, data) {
|
|
|
144
151
|
const counts = peek === null
|
|
145
152
|
? note("Not scanned yet.")
|
|
146
153
|
: html `<p>${joinHtml([
|
|
147
|
-
countWords(peek.waiting, peek.waiting === 1 ? "needs you" : "need you", "/
|
|
148
|
-
countWords(peek.running, "running", "/
|
|
149
|
-
countWords(peek.queued, "queued", "
|
|
150
|
-
countWords(peek.doneRecently, "built today", "
|
|
154
|
+
countWords(peek.waiting, peek.waiting === 1 ? "needs you" : "need you", "/"),
|
|
155
|
+
countWords(peek.running, "running", "/"),
|
|
156
|
+
countWords(peek.queued, "queued", "/?view=order"),
|
|
157
|
+
countWords(peek.doneRecently, "built today", "/?view=done"),
|
|
151
158
|
], " · ")}</p>`;
|
|
152
159
|
const tasks = data.tasks.length === 0
|
|
153
160
|
? note(`Nothing needs you or is running in ${data.name}.`)
|
|
154
161
|
: html `${data.tasks.map(task => row({
|
|
155
162
|
href: task.href, chip: task.needs ? status("needs") : status("running"), title: task.title, desc: task.reason, wait: task.needs,
|
|
156
163
|
meta: task.since === null ? "" : html `<span class="k-num">${relativeAge(task.since, data.now)}</span>`,
|
|
157
|
-
}))}${data.moreTasks > 0 ? note(data.open ? html `<a class="k-link" href="/
|
|
164
|
+
}))}${data.moreTasks > 0 ? note(data.open ? html `<a class="k-link" href="/">${data.moreTasks} more in Work</a>` : `${data.moreTasks} more`) : ""}`;
|
|
158
165
|
const setup = facts([
|
|
159
166
|
["Folder", mono(data.path)],
|
|
160
167
|
...(data.checks === null ? [] : [["Checks", html `<a class="k-link" href="${data.checks.href}">${data.checks.level}</a>`]]),
|
|
@@ -232,3 +239,44 @@ export const unknownProject = (name) => ({ title: `There is no project called ${
|
|
|
232
239
|
export function waitingWords(count) {
|
|
233
240
|
return `${count} waiting on you`;
|
|
234
241
|
}
|
|
242
|
+
export function folderPickerPage(chrome, view) {
|
|
243
|
+
const title = "Choose a repository";
|
|
244
|
+
const crumbs = view.at === null ? "" : html `<nav class="k-mono" aria-label="Folder">${joinHtml(view.at.crumbs.map(one => one.href === null
|
|
245
|
+
? html `<span aria-current="location">${one.label}</span>`
|
|
246
|
+
: html `<a class="k-link" href="${one.href}">${one.label}</a>`), html `<span aria-hidden="true"> / </span>`)}</nav>`;
|
|
247
|
+
const gits = view.entries.filter(one => one.git).length;
|
|
248
|
+
const list = view.lookProblem !== null ? notice(view.lookProblem)
|
|
249
|
+
: view.entries.length === 0 && view.chosen !== null ? ""
|
|
250
|
+
: view.entries.length === 0 ? empty({ title: "No repositories here.", text: view.at?.up ? "Go up one folder, or try a shortcut." : "Try a shortcut." })
|
|
251
|
+
: html `${gits === 0 ? note("No repositories here. Open a folder to look inside it.") : ""}${group("Folders", count(view.entries.length))}${view.entries.map(one => row({
|
|
252
|
+
href: one.href, chip: one.git ? chip(one.registered ? "Project" : "Git repository", "") : html ``, title: one.name,
|
|
253
|
+
desc: one.git ? (one.registered ? "Already added" : "Choose to add it") : "Folder",
|
|
254
|
+
}))}`;
|
|
255
|
+
const body = joinHtml([
|
|
256
|
+
phoneHeader(title, { back: view.back[0] }),
|
|
257
|
+
doc(docHeader({ back: view.back, title, meta: crumbs, same: true }), view.problem === null ? "" : notice(sentence(view.problem)), view.said === null ? "" : infoLine(sentence(view.said)), view.chosen ?? "", view.shortcuts.length === 0 && !view.at?.up ? "" : html `<nav class="k-acts" aria-label="Go to">${view.at?.up ? btn("Up one folder", { sm: true, lead: "back", href: view.at.up }) : ""}${view.shortcuts.map(one => btn(one.label, { sm: true, variant: "ghost", href: one.href }))}</nav>`, html `<div>${list}</div>`),
|
|
258
|
+
], "\n");
|
|
259
|
+
return screen(title, body, { chrome });
|
|
260
|
+
}
|
|
261
|
+
export const typedPasswordField = (id) => field({ id, label: "Your password",
|
|
262
|
+
control: html `<input class="k-input" id="${id}" type="password" name="password" data-so-typed autocomplete="current-password" required>` });
|
|
263
|
+
export function pickRepoChosen(data) {
|
|
264
|
+
const form = (label, extra = "") => postForm("/projects/open", joinHtml([extra, acts(btn(label, { type: "submit", variant: "primary" }))]), { returnTo: "/projects", hidden: { path: data.path, via: "path" } });
|
|
265
|
+
const text = data.refusal !== null ? sentence(data.refusal)
|
|
266
|
+
: data.state === "open" ? "Already a project here."
|
|
267
|
+
: data.state === "outside" ? "It’s outside your projects folder, so Toolroll asks for your password."
|
|
268
|
+
: data.state === "blocked" ? "It’s outside your projects folder. Only an approver signed in with a password can add it."
|
|
269
|
+
: "Adds it as a project.";
|
|
270
|
+
const acts_ = data.refusal !== null || data.state === "blocked" ? ""
|
|
271
|
+
: data.state === "open" ? form("Open") : data.state === "outside" ? form("Add and open", typedPasswordField("pick-password")) : form("Add and open");
|
|
272
|
+
return slots({ status: html `<h2>${data.name}</h2>`, text: html `${mono(shortPathOf(data.path))} · ${text}`, acts: acts_, terms: "", attrs: { "aria-label": `Add ${data.name}` } });
|
|
273
|
+
}
|
|
274
|
+
export function outsideAddPage(chrome, data) {
|
|
275
|
+
const title = "Add a project from outside your projects folder";
|
|
276
|
+
const back = ["/projects", "Projects"];
|
|
277
|
+
const body = joinHtml([
|
|
278
|
+
phoneHeader(title, { back: back[0] }),
|
|
279
|
+
doc(docHeader({ back, title, same: true }), pickRepoChosen({ name: data.name, path: data.path, state: "outside", refusal: null })),
|
|
280
|
+
], "\n");
|
|
281
|
+
return screen(title, body, { chrome });
|
|
282
|
+
}
|
|
@@ -27,6 +27,7 @@ import { ACCEPT_NEEDS_REASON, acceptWordsOf, cantAcceptYetOf, evidenceProblemOf,
|
|
|
27
27
|
import { createHash, randomBytes } from "node:crypto";
|
|
28
28
|
import { buildsViews, oneLineOf, projectChip, safePrUrl, screen, sentenceCase, strokeIcon, when, whenTime } from "./chrome.js";
|
|
29
29
|
import { chatResultHref, reviewHref, taskChatHref, taskHref } from "./http.js";
|
|
30
|
+
import { taskLinkOf } from "../task-link.js";
|
|
30
31
|
import { attributes, html, htmlString, joinHtml, postForm, reauth } from "../html.js";
|
|
31
32
|
import { chip, facts } from "./kit.js";
|
|
32
33
|
import { publicationFactsOf, statusActionHref, statusLineHtml } from "./render-tasks.js";
|
|
@@ -519,6 +520,9 @@ export function reviewCockpitDetailParts(view, csrf, noted, canRetryReview, tab,
|
|
|
519
520
|
problem: view.detail === null ? view.historyProblem : null,
|
|
520
521
|
next: reviewNextActionOf(view, csrf, host.kind === "task" && run !== null ? `${host.base}&run=${run.id}` : undefined), complete: null, decision: null, checks: null, intent: intentView, noRun: null, panel: null,
|
|
521
522
|
notes: view.notes.map(one => ({ author: one.author, at: one.createdAt, note: one.note })),
|
|
523
|
+
agentReport: run === null || view.detail === null ? null : view.detail.handoff?.report ?? EMPTY_AGENT_REPORT,
|
|
524
|
+
youSaid: (view.youSaid ?? []).map(one => ({ kind: one.kind, author: one.author, you: one.author === user, at: one.at, note: quotedNoteOf(one.note),
|
|
525
|
+
question: one.question === null ? null : quotedNoteOf(one.question) })),
|
|
522
526
|
efficiency: view.efficiency ?? null,
|
|
523
527
|
network: view.network ?? null,
|
|
524
528
|
timing: view.timing ?? null,
|
|
@@ -537,10 +541,9 @@ export function reviewCockpitDetailParts(view, csrf, noted, canRetryReview, tab,
|
|
|
537
541
|
return { html: html `<section class="cockpit-detail">${joinHtml(parts, "\n")}</section>`, selected: { ...selected, noRun: "This task has no finished build record, so there are no captured changes or checks to review." } };
|
|
538
542
|
}
|
|
539
543
|
const extraChecks = reviewRetryPanel(view.taskId, run.id, view.reviewRetry, { csrf, canAct: false, returnTo: null });
|
|
540
|
-
const here = reviewHref(view.taskId);
|
|
541
544
|
const at = (section = "summary") => host.kind === "task"
|
|
542
545
|
? `${host.base}&run=${run.id}${section === "summary" ? "" : `§ion=${section}`}`
|
|
543
|
-
:
|
|
546
|
+
: taskLinkOf({ task: view.taskId, run: run.id, section });
|
|
544
547
|
const assignment = view.assignment === null ? null : assignmentWithEvidence(view.assignment, receiptStatusOf(view.detail.receipt), run.id);
|
|
545
548
|
const saved = assignment?.receipt?.checks;
|
|
546
549
|
const checks = saved === undefined || assignment?.receipt == null ? undefined
|
|
@@ -549,7 +552,14 @@ export function reviewCockpitDetailParts(view, csrf, noted, canRetryReview, tab,
|
|
|
549
552
|
parts.push(html `<p class="${checks.status === "failed" || checks.status === "unavailable" ? "problem" : "meta"}" data-actual-checks="${checks.status}">${checks.status === "unavailable" && saved.cause === "command-changed" ? CHECK_COMMAND_CHANGED : html `${checks.status === "unavailable" && saved.status !== "unavailable" ? `${CHECK_UNREADABLE} ` : ""}${checks.detail}`}${checks.logArtifactId === null ? "" : html ` <a href="/r/${run.id}/evidence/${checks.logArtifactId}">Open check output</a>`}</p>`);
|
|
550
553
|
if (assignment?.completion != null)
|
|
551
554
|
parts.push(html `<p class="meta" data-result-completed>Accepted by ${assignment.completion.actor.replace(/^operator:/, "")}.</p>`);
|
|
555
|
+
const own = taskLinkOf({ task: view.taskId, run: run.id });
|
|
556
|
+
const ownOr = (href) => href === own || /^[&#]/.test(href.slice(own.length)) && href.startsWith(own) ? href.slice(own.length) : null;
|
|
557
|
+
const failure = view.failure == null ? null : { line: view.failure.line, evidence: view.failure.evidence, suggestion: view.failure.suggestion, retry: view.failure.retry,
|
|
558
|
+
link: view.failure.link === null || (ownOr(view.failure.link.href) !== null && !view.failure.link.href.includes("#")) ? null
|
|
559
|
+
: host.kind === "task" && ownOr(view.failure.link.href)?.startsWith("§ion=") === true ? { ...view.failure.link, href: `${host.base}&run=${run.id}${ownOr(view.failure.link.href)}` } : view.failure.link,
|
|
560
|
+
...(view.failure.acceptAnyway == null ? {} : { acceptAnyway: { ...view.failure.acceptAnyway, returnTo: at() } }) };
|
|
552
561
|
const panel = resultPanelParts(view.detail, {
|
|
562
|
+
...(host.kind === "task" && host.alone === true && failure !== null ? { failed: { line: failure.line, evidence: failure.evidence, link: failure.link } } : {}),
|
|
553
563
|
place: "review",
|
|
554
564
|
tab,
|
|
555
565
|
csrf,
|
|
@@ -595,10 +605,6 @@ export function reviewCockpitDetailParts(view, csrf, noted, canRetryReview, tab,
|
|
|
595
605
|
? { action: `/r/${run.id}/checks`, level: followUps.full ? "full" : "quick", returnTo: at("checks") } : null;
|
|
596
606
|
const need = panel.panel.need;
|
|
597
607
|
const nextKind = selected.next?.kind;
|
|
598
|
-
const failure = view.failure == null ? null : { line: view.failure.line, evidence: view.failure.evidence, suggestion: view.failure.suggestion, retry: view.failure.retry,
|
|
599
|
-
link: view.failure.link === null || (view.failure.link.href.startsWith(`${here}&run=${run.id}`) && !view.failure.link.href.includes("#")) ? null
|
|
600
|
-
: host.kind === "task" && view.failure.link.href.startsWith(`${here}&run=${run.id}&tab=`) ? { ...view.failure.link, href: view.failure.link.href.replace(`${here}&run=${run.id}&tab=`, `${host.base}&run=${run.id}§ion=`) } : view.failure.link,
|
|
601
|
-
...(view.failure.acceptAnyway == null ? {} : { acceptAnyway: { ...view.failure.acceptAnyway, returnTo: at() } }) };
|
|
602
608
|
const actFacts = failure !== null
|
|
603
609
|
? { accept: null, runChecks: runChecks !== null, checksRunning, blocked: null, canRequest: false, need: null, next: null, failed: { retry: failure.retry !== null, acceptAnyway: failure.acceptAnyway !== undefined } }
|
|
604
610
|
: {
|
|
@@ -1590,6 +1596,7 @@ export function resultPanelParts(detail, o) {
|
|
|
1590
1596
|
revisionSealFields(detail.comments, detail.sourceDigest),
|
|
1591
1597
|
html `<input type="hidden" data-recorded-requests value="${[...detail.comments, ...(detail.pastComments ?? [])].filter(one => one.sourceKey?.startsWith(`review:${o.user}:`)).map(one => one.sourceKey.slice(`review:${o.user}:`.length)).join(",")}">`,
|
|
1592
1598
|
html `<input type="hidden" name="image" value=""><figure class="feedback-image" data-feedback-image hidden><img alt="Selected screenshot" hidden><figcaption></figcaption><button type="button" class="quiet" data-remove-image>Remove image</button></figure>`,
|
|
1599
|
+
html `<input type="hidden" name="context" value=""><div class="meta" data-request-context-line hidden></div>`,
|
|
1593
1600
|
html `<textarea name="note" rows="2" maxlength="${LIMITS.note}" placeholder="Describe the change…" aria-label="review comment" aria-describedby="comment-note-limit"${o.noted ? " autofocus" : ""}></textarea>`,
|
|
1594
1601
|
html `<span class="meta diff-comment-limit" id="comment-note-limit">up to ${LIMITS.note} characters</span>`,
|
|
1595
1602
|
html `<details class="result-pin"><summary>Attach to a file or line</summary>`,
|
|
@@ -1610,10 +1617,12 @@ export function resultPanelParts(detail, o) {
|
|
|
1610
1617
|
html `<section class="card result-panel" id="result" data-result-panel data-result-place="${o.place}" data-result-lead="${lead}" data-result-task="${detail.rootId ?? detail.taskId}" data-result-user="${o.user}"${attributes(resultFactsAttributeMap(facts))}>`,
|
|
1611
1618
|
o.back === null ? "" : html `<p class="result-back"><a href="${o.back.href}" data-result-back>← ${o.back.label}</a></p>`,
|
|
1612
1619
|
(detail.history ?? ""),
|
|
1613
|
-
|
|
1614
|
-
? html `<header class="result-head"><div data-headline-tone="
|
|
1615
|
-
:
|
|
1616
|
-
|
|
1620
|
+
o.failed != null
|
|
1621
|
+
? html `<header class="result-head" data-result-failed><div data-headline-tone="danger"><h2 class="status-headline" data-work-status="failed"><i aria-hidden="true"></i>Failed</h2><p class="status-sentence" data-failure-reason>${o.failed.line}</p>${o.failed.evidence === null && o.failed.link === null ? "" : html `<p class="meta" data-failure-evidence>${o.failed.evidence ?? ""}${o.failed.evidence !== null && o.failed.link !== null ? " " : ""}${o.failed.link === null ? "" : html `<a href="${o.failed.link.href}" data-failure-log>${o.failed.link.label}</a>`}</p>`}</div></header>`
|
|
1622
|
+
: taskStatus !== null && o.headStatus !== false
|
|
1623
|
+
? html `<header class="result-head"><div data-headline-tone="${taskStatus.tone}"><h2 class="status-headline" data-work-status="${status.token}"><i aria-hidden="true"></i>${taskStatus.headline}</h2><p class="status-sentence">${taskStatus.sentence}</p></div></header>`
|
|
1624
|
+
: html `<header class="result-head"><div><h2>${heading}</h2></div>${o.headStatus === false ? "" : statusLineHtml(status)}</header>`,
|
|
1625
|
+
o.failed != null ? "" : html `<p class="result-summary">${outcome}</p>`,
|
|
1617
1626
|
current == null || o.place === "review" && (current.state === "ready-to-check" || current.state === "complete") ? "" :
|
|
1618
1627
|
html `<div class="verdict" data-current-outcome data-headline="${taskStatus.headline}">${statusDetailsHtml(taskStatus)}${statusWhyHtml(taskStatus)}</div>`,
|
|
1619
1628
|
attentionHtml,
|
|
@@ -1643,6 +1652,8 @@ export function resultPanelParts(detail, o) {
|
|
|
1643
1652
|
learning: detail.learning === undefined ? "" : htmlString(detail.learning),
|
|
1644
1653
|
request: detail.skillTest ? null : htmlString(joinHtml(requestParts, "\n")),
|
|
1645
1654
|
canRequest: detail.canAnnotate && o.csrf !== "",
|
|
1655
|
+
sendBack: detail.skillTest || !detail.canAnnotate || o.csrf === "" ? null
|
|
1656
|
+
: { action: `/r/${runId}/comment`, batch: revisionBatchOf(detail.comments), source: revisionSourceOf(detail.sourceDigest), request: o.requestToken },
|
|
1646
1657
|
need,
|
|
1647
1658
|
requestQuiet: detail.canAnnotate && o.csrf !== "" && detail.comments.length === 0 && (detail.pastComments?.length ?? 0) === 0 && detail.revisions.length === 0,
|
|
1648
1659
|
};
|
|
@@ -1820,3 +1831,8 @@ export function runFactsFragment(run, taskId, live, route = null) {
|
|
|
1820
1831
|
}
|
|
1821
1832
|
return runFactsRows(run, taskId, live, route);
|
|
1822
1833
|
}
|
|
1834
|
+
export const EMPTY_AGENT_REPORT = Object.freeze({ decisions: [], assumptions: [], notDone: [], risks: [] });
|
|
1835
|
+
export function quotedNoteOf(note) {
|
|
1836
|
+
const flat = note.replace(/\s+/g, " ").trim();
|
|
1837
|
+
return flat.length <= 280 ? flat : `${flat.slice(0, 279).trimEnd()}…`;
|
|
1838
|
+
}
|
|
@@ -52,6 +52,7 @@ import { TEXT_LIMITS } from "../text-limits.js";
|
|
|
52
52
|
import { isOverdue, oneLineOf, projectChip, regionScript, safePrUrl, screen, SENSITIVE_INPUT, sentenceCase, shortDigest, whenTime } from "./chrome.js";
|
|
53
53
|
import { steerDestinationWords, steerStandingParts } from "../steer-status.js";
|
|
54
54
|
import { reviewHref, taskChatHref, taskHref } from "./http.js";
|
|
55
|
+
import { taskLinkFromLegacy, taskLinkOf } from "../task-link.js";
|
|
55
56
|
import { coordinatorProposalsSection } from "./render-chat.js";
|
|
56
57
|
import { completionReceiptCard, criterionMatrixHtml, evidenceWords, homePhaseWords, incidentWords, pullRequestCardHtml, reasonWords, receiptStatusOf, repairChainHtml, reportItemsHtml, reviewRetryPanel, runNoun, runOutcomeBadge, semanticCoverageHtml, verificationExplanation, verificationRecovered } from "./render-results.js";
|
|
57
58
|
import {} from "./session.js";
|
|
@@ -1480,7 +1481,7 @@ export function taskBodyParts(data) {
|
|
|
1480
1481
|
releaseCiRunning: data.releaseCiRunning === true,
|
|
1481
1482
|
rebuild: data.assignment?.need != null && "key" in data.assignment.need && data.assignment.need.key === "replan" ? data.assignment.need.build : null,
|
|
1482
1483
|
editHref: data.csrf !== "" && data.planSha != null && data.planDocument !== null ? "#plan-edit" : "#scope",
|
|
1483
|
-
notNowHref: "/
|
|
1484
|
+
notNowHref: "/",
|
|
1484
1485
|
sticky: approvalLeads,
|
|
1485
1486
|
earlier: { active: data.assignment?.earlierActive ?? 0, running: data.assignment?.earlierRunning ?? 0 },
|
|
1486
1487
|
edit: data.csrf === "" ? null
|
|
@@ -1620,7 +1621,7 @@ export function taskBodyParts(data) {
|
|
|
1620
1621
|
? prop("last attempt", html `<a href="/r/${data.runs[0].id}">${runNoun(data.runs[0])} #${data.runs[0].id}</a> · ${data.runs[0].role === "planner" && data.runs[0].reason === "plan-drafted" ? "planned" : wasInterrupted(data.runs[0]) ? "interrupted" : data.runs[0].id === liveHistoryRunId ? "running" : data.runs[0].outcome ?? "never finished"} · ${data.runs[0].runner}`)
|
|
1621
1622
|
: "";
|
|
1622
1623
|
const queueRow = data.position !== null && data.position !== undefined && task.state === "queued"
|
|
1623
|
-
? prop("queue", html `${data.position.position} of ${data.position.total}${data.position.column === null ? " in the shared queue" : html ` in ${data.position.column}'s queue`} · <a href="
|
|
1624
|
+
? prop("queue", html `${data.position.position} of ${data.position.total}${data.position.column === null ? " in the shared queue" : html ` in ${data.position.column}'s queue`} · <a href="/?view=order">reorder</a>`)
|
|
1624
1625
|
: "";
|
|
1625
1626
|
const scopeRow = scope === null
|
|
1626
1627
|
? prop("plan", "none yet")
|
|
@@ -1641,7 +1642,7 @@ export function taskBodyParts(data) {
|
|
|
1641
1642
|
facts.push({ label: "Last attempt", parts: [{ label: `${runNoun(lastRun)} #${lastRun.id}`, href: `/r/${lastRun.id}` },
|
|
1642
1643
|
` · ${lastRun.role === "planner" && lastRun.reason === "plan-drafted" ? "planned" : wasInterrupted(lastRun) ? "interrupted" : lastRun.id === liveHistoryRunId ? "running" : lastRun.outcome ?? "never finished"} · ${lastRun.runner}`] });
|
|
1643
1644
|
if (data.position !== null && data.position !== undefined && task.state === "queued") {
|
|
1644
|
-
facts.push({ label: "Queue", parts: [`${data.position.position} of ${data.position.total}${data.position.column === null ? " in the shared queue" : ` in ${data.position.column}'s queue`} · `, { label: "Reorder", href: "
|
|
1645
|
+
facts.push({ label: "Queue", parts: [`${data.position.position} of ${data.position.total}${data.position.column === null ? " in the shared queue" : ` in ${data.position.column}'s queue`} · `, { label: "Reorder", href: "/?view=order" }] });
|
|
1645
1646
|
}
|
|
1646
1647
|
facts.push(scope === null ? { label: "Plan", parts: ["none yet"] }
|
|
1647
1648
|
: approval.approved && data.autoRelease != null ? { label: "Approved plan", parts: [autoReleaseWords(data.autoRelease)] }
|
|
@@ -1659,7 +1660,7 @@ export function taskBodyParts(data) {
|
|
|
1659
1660
|
? (votes.length === 0 ? "needs two approvers" : `approved by ${votes.join(", ")} · needs one more`)
|
|
1660
1661
|
: data.approvalRules.words] });
|
|
1661
1662
|
}
|
|
1662
|
-
facts.push({ label: "Audit", parts: [{ label: "Audit record", href:
|
|
1663
|
+
facts.push({ label: "Audit", parts: [{ label: "Audit record", href: taskLinkOf({ task: task.id, record: true }) }] });
|
|
1663
1664
|
if (data.budgetHold != null)
|
|
1664
1665
|
facts.push({ label: "Budget", parts: [`${data.budgetHold} · `, { label: "Spend", href: "/spend" }] });
|
|
1665
1666
|
if (data.policyHold != null)
|
|
@@ -2044,10 +2045,7 @@ export function taskBodyParts(data) {
|
|
|
2044
2045
|
const retry = failedCard && task.state === "failed" && !data.claimed && !stopControlsActive && data.csrf !== ""
|
|
2045
2046
|
? { action: `${taskHref(task.id)}/requeue`, pins: data.retryPins ?? null, ...(data.failure == null ? {} : { note: retryNoteOf(data.failure.suggestion) }) } : null;
|
|
2046
2047
|
const runChecks = data.runChecks ?? null;
|
|
2047
|
-
const resultPageOf = (href) =>
|
|
2048
|
-
const chat = href === null ? null : /^\/chat\?task=([A-Za-z0-9._~%-]{1,200})&result=([0-9]{1,15})(?:&tab=(changes|checks))?(#[A-Za-z0-9_-]{1,80})?$/.exec(href);
|
|
2049
|
-
return chat === null ? href : `/review?result=${chat[1]}&run=${chat[2]}${chat[3] === undefined ? "" : `&tab=${chat[3]}`}${chat[4] ?? ""}`;
|
|
2050
|
-
};
|
|
2048
|
+
const resultPageOf = (href) => href === null ? null : taskLinkFromLegacy(href) ?? href;
|
|
2051
2049
|
const inPlaceChecks = (card) => {
|
|
2052
2050
|
const status = data.demo === true ? demoChecksOf(card.status) : card.status;
|
|
2053
2051
|
return { ...card, status: { ...status, details: status.details.map(one => one.action?.href?.endsWith("#follow-ups") === true ? { ...one, action: runChecks === null ? null : { label: one.action.label, href: runChecks.action } }
|
|
@@ -2086,7 +2084,7 @@ export function taskBodyParts(data) {
|
|
|
2086
2084
|
revision: data.revision == null || "problem" in data.revision ? null : data.revision,
|
|
2087
2085
|
revisionSourceHref: data.revision == null || "problem" in data.revision ? "" : `/r/${data.revision.sourceRun}`,
|
|
2088
2086
|
repairChain: data.repairChain ?? null, route: data.route, coordinator: data.coordinator ?? null, origin: data.origin ?? null,
|
|
2089
|
-
deliverable: data.deliverable ?? "branch", releaseCiRunning: data.releaseCiRunning === true, editHref: "#scope", notNowHref: "/
|
|
2087
|
+
deliverable: data.deliverable ?? "branch", releaseCiRunning: data.releaseCiRunning === true, editHref: "#scope", notNowHref: "/", sticky: false,
|
|
2090
2088
|
earlier: { active: data.assignment?.earlierActive ?? 0, running: data.assignment?.earlierRunning ?? 0 }, edit: null,
|
|
2091
2089
|
};
|
|
2092
2090
|
const sheetParts = sheetShown === null ? null : approvalSheetParts(sheetShown);
|
|
@@ -2142,7 +2140,7 @@ export function taskBodyParts(data) {
|
|
|
2142
2140
|
approve: data.archived != null || sheetInput === null || dependencyChoiceNeeded || data.csrf === "" ? null : approveKitOf(sheetInput, data.approvalFresh ?? null),
|
|
2143
2141
|
approved: scope !== null && approval.approved ? approvedKitOf(scope, approval, data.approvalProof ?? null) : null,
|
|
2144
2142
|
more,
|
|
2145
|
-
audit: facts.some(one => one.label === "Audit") ? { label: "Full record", href:
|
|
2143
|
+
audit: facts.some(one => one.label === "Audit") ? { label: "Full record", href: taskLinkOf({ task: rootOf, record: true }) } : null,
|
|
2146
2144
|
recheckStopped: data.csrf !== "" && data.assignment?.primaryAction?.code === "recheck-stopped" && data.assignment.primaryAction.target.runId !== null
|
|
2147
2145
|
? { action: `${taskHref(data.assignment.rootId)}/recheck-stopped`, run: data.assignment.primaryAction.target.runId } : null,
|
|
2148
2146
|
rebuild,
|
|
@@ -2186,29 +2184,40 @@ export function taskBodyParts(data) {
|
|
|
2186
2184
|
})(),
|
|
2187
2185
|
};
|
|
2188
2186
|
const rowFacts = data.archived != null ? null : stepRowsOf(view);
|
|
2189
|
-
|
|
2187
|
+
let composed = false;
|
|
2188
|
+
const rowsHtmlOf = (section) => rowFacts === null ? null : (() => {
|
|
2190
2189
|
const here = rowFacts.find(row => row.state === "current" || row.state === "stuck") ?? rowFacts.find(row => row.open) ?? rowFacts.at(-1);
|
|
2190
|
+
const ready = rowFacts.find(row => row.key === "ready");
|
|
2191
|
+
const outcomeFirst = view.approve == null && view.status !== null && ready !== undefined
|
|
2192
|
+
&& (ready.state === "current" || ready.state === "stuck" || rowFacts.every(row => row.state === "done" || row.state === "skipped"));
|
|
2191
2193
|
const bodyOf = (key) => joinHtml([
|
|
2192
|
-
key === here.key ? statusHtml : "",
|
|
2194
|
+
key === here.key && !outcomeFirst ? statusHtml : "",
|
|
2193
2195
|
key === "plan" ? planCard : "",
|
|
2194
2196
|
key === "approve" ? (approvalHtml !== "" ? approvalHtml : view.approved == null ? "" : html `<p class="meta">${view.approved.automatic ? `Approved automatically by ${view.approved.rule ?? "a rule"}` : `Approved by ${view.approved.by}`} · ${whenTime(view.approved.at)}</p>`) : "",
|
|
2195
2197
|
key === "build" ? joinHtml([controlHtml, progressCard, revisionLedgerCard]) : "",
|
|
2196
2198
|
key === "ready" && previousResult !== null ? html `<section class="task-previous-result" aria-label="${previousResult.title}">${previousResult.html}</section>` : "",
|
|
2197
2199
|
]);
|
|
2198
|
-
|
|
2200
|
+
const rows = stepRows(rowFacts.map(row => ({ key: row.key, label: row.label, mark: row.mark, sentence: row.sentence, needsYou: row.needsYou, current: row.state === "current" || row.state === "stuck",
|
|
2199
2201
|
at: row.at, when: row.at === null ? "" : whenText(row.at), body: bodyOf(row.key), open: true })));
|
|
2202
|
+
if (!outcomeFirst)
|
|
2203
|
+
return rows;
|
|
2204
|
+
if (section !== null)
|
|
2205
|
+
composed = true;
|
|
2206
|
+
return joinHtml([html `<div class="task-outcome" data-task-outcome>${statusHtml}${section ?? ""}</div>`,
|
|
2207
|
+
html `<details class="k-disclose task-steps" data-task-steps><summary>Plan and steps</summary>${rows}</details>`]);
|
|
2200
2208
|
})();
|
|
2201
|
-
|
|
2209
|
+
const withResult = nativeBody(rowsHtmlOf(data.resultSection ?? null));
|
|
2210
|
+
return { html: withResult, view, ...(composed ? { bare: nativeBody(rowsHtmlOf(null)) } : {}) };
|
|
2202
2211
|
}
|
|
2203
2212
|
export function taskBody(data) {
|
|
2204
2213
|
return taskBodyParts(data).html;
|
|
2205
2214
|
}
|
|
2206
2215
|
export function taskPage(chrome, data) {
|
|
2207
2216
|
const first = taskBodyParts(data);
|
|
2208
|
-
const sensitive = SENSITIVE_INPUT.test(htmlString(first.html)) || (chrome.listPane !== undefined && SENSITIVE_INPUT.test(htmlString(chrome.listPane)));
|
|
2217
|
+
const sensitive = SENSITIVE_INPUT.test(htmlString(first.bare ?? first.html)) || (chrome.listPane !== undefined && SENSITIVE_INPUT.test(htmlString(chrome.listPane)));
|
|
2209
2218
|
if (sensitive) {
|
|
2210
2219
|
const degraded = taskBodyParts({ ...data, degraded: "sensitive" });
|
|
2211
|
-
return screen(`task \u00b7 ${data.task.id}`, degraded.html, { chrome, workspace: { view: degraded.view } });
|
|
2220
|
+
return screen(`task \u00b7 ${data.task.id}`, degraded.html, { chrome, workspace: { view: degraded.view, ...(degraded.bare === undefined ? {} : { pageHtml: degraded.bare }) } });
|
|
2212
2221
|
}
|
|
2213
2222
|
const liveRunId = data.liveRunId ?? null;
|
|
2214
2223
|
const liveRun = liveRunId === null ? undefined : data.runs.find(one => one.id === liveRunId);
|
|
@@ -2225,7 +2234,7 @@ export function taskPage(chrome, data) {
|
|
|
2225
2234
|
app.push({ kind: "answer" });
|
|
2226
2235
|
return screen(`task \u00b7 ${data.task.id}`, first.html, {
|
|
2227
2236
|
chrome,
|
|
2228
|
-
workspace: { view: first.view },
|
|
2237
|
+
workspace: { view: first.view, ...(first.bare === undefined ? {} : { pageHtml: first.bare }) },
|
|
2229
2238
|
...(script === "" ? {} : { functional: { script, fetches: true, app } }),
|
|
2230
2239
|
});
|
|
2231
2240
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { SAFETY } from "./http.js";
|
|
2
|
+
import { taskLinkFromLegacy, taskLinkOf } from "../task-link.js";
|
|
2
3
|
export function tasksHref(over = {}) {
|
|
3
4
|
const q = new URLSearchParams();
|
|
4
|
-
if (over.scope
|
|
5
|
-
q.set("scope", "all");
|
|
6
|
-
else if (over.project != null)
|
|
5
|
+
if (over.scope !== "all" && over.project != null)
|
|
7
6
|
q.set("project", over.project);
|
|
8
7
|
if (over.view != null && over.view !== "all")
|
|
9
8
|
q.set("view", over.view);
|
|
@@ -11,10 +10,26 @@ export function tasksHref(over = {}) {
|
|
|
11
10
|
q.set("state", over.state);
|
|
12
11
|
if (over.cursor != null)
|
|
13
12
|
q.set("cursor", over.cursor);
|
|
14
|
-
return
|
|
13
|
+
return `/${q.size === 0 ? "" : `?${q}`}`;
|
|
15
14
|
}
|
|
16
15
|
const projectOf = (url) => url.searchParams.getAll("project").length === 1 ? url.searchParams.get("project") : null;
|
|
17
16
|
const LIST_VIEWS = { all: "all", "needs-you": "needs-you", running: "running", queued: "queued", completed: "completed", done: "completed", archived: "archived", ready: "ready" };
|
|
17
|
+
export const SETTINGS_RETIRED = {
|
|
18
|
+
"settings.group-advanced": { to: "/settings/general", section: "advanced", keep: ["said", "problem"], open: true },
|
|
19
|
+
"start-builder": { to: "/settings/computers", section: "start", keep: ["task", "said", "problem"] },
|
|
20
|
+
};
|
|
21
|
+
export function settingsRetiredHref(retirement, url) {
|
|
22
|
+
const query = new URLSearchParams();
|
|
23
|
+
for (const key of retirement.keep) {
|
|
24
|
+
const values = url.searchParams.getAll(key);
|
|
25
|
+
if (values.length === 1)
|
|
26
|
+
query.set(key, values[0]);
|
|
27
|
+
}
|
|
28
|
+
query.set("section", retirement.section);
|
|
29
|
+
if (retirement.open === true)
|
|
30
|
+
query.set("open", "1");
|
|
31
|
+
return `${retirement.to}?${query}`;
|
|
32
|
+
}
|
|
18
33
|
export const RETIRED_ROUTES = {
|
|
19
34
|
work: url => {
|
|
20
35
|
const board = url.searchParams.get("layout") === "board";
|
|
@@ -30,8 +45,21 @@ export const RETIRED_ROUTES = {
|
|
|
30
45
|
queue: url => tasksHref({ view: "order", project: projectOf(url) }),
|
|
31
46
|
done: url => tasksHref({ view: "done", project: projectOf(url) }),
|
|
32
47
|
review: url => tasksHref({ view: "ready", project: projectOf(url) }),
|
|
48
|
+
tasks: url => {
|
|
49
|
+
const template = url.searchParams.get("template");
|
|
50
|
+
if (template !== null)
|
|
51
|
+
return `/tasks/new?template=${encodeURIComponent(template)}`;
|
|
52
|
+
return `/${url.search}`;
|
|
53
|
+
},
|
|
33
54
|
"work.put-away": url => { const days = url.searchParams.get("days"); return days !== null && /^[0-9]{1,3}$/.test(days) ? `/tasks/archive?days=${days}` : "/tasks/archive"; },
|
|
55
|
+
...Object.fromEntries(Object.entries(SETTINGS_RETIRED).map(([id, retirement]) => [id, (url) => settingsRetiredHref(retirement, url)])),
|
|
34
56
|
};
|
|
57
|
+
export const TASK_VIEW_REDIRECTS = {
|
|
58
|
+
review: (url) => url.searchParams.has("result") ? taskLinkFromLegacy(`${url.pathname}${url.search}`) : null,
|
|
59
|
+
"run.page": (url, taskId, runId) => url.searchParams.has("record") || url.searchParams.has("fragment") ? null : taskLinkOf({ task: taskId, run: runId, section: sectionOf(url.searchParams.get("tab")) }),
|
|
60
|
+
"task.evidence": (url, rootId) => url.searchParams.get("format") === "json" || url.searchParams.has("print") ? null : taskLinkOf({ task: rootId, record: true }),
|
|
61
|
+
};
|
|
62
|
+
const sectionOf = (raw) => raw === "changes" || raw === "checks" || raw === "summary" ? raw : null;
|
|
35
63
|
export function retiredRedirect(id, url, response) {
|
|
36
64
|
const to = RETIRED_ROUTES[id];
|
|
37
65
|
if (to === undefined)
|
|
@@ -40,3 +68,8 @@ export function retiredRedirect(id, url, response) {
|
|
|
40
68
|
response.writeHead(301, { ...SAFETY });
|
|
41
69
|
response.end();
|
|
42
70
|
}
|
|
71
|
+
export function retiredHandler(id) {
|
|
72
|
+
if (RETIRED_ROUTES[id] === undefined)
|
|
73
|
+
throw new Error(`no retired route ${id}`);
|
|
74
|
+
return async (ctx) => retiredRedirect(id, ctx.url, ctx.response);
|
|
75
|
+
}
|
|
@@ -14,6 +14,14 @@ export function evaluateRoutePolicy(route, principal, resolve, operationScope) {
|
|
|
14
14
|
return { ok: false, status: 403, reason: 'project' };
|
|
15
15
|
return { ok: true };
|
|
16
16
|
}
|
|
17
|
+
export function routePrincipalOf(who) {
|
|
18
|
+
return { caller: who.via, capability: who.via === 'bearer' && who.principal !== undefined ? who.principal.scope : who.role === 'approver' ? 'act' : 'read',
|
|
19
|
+
viewer: who.role === 'viewer', token: who.via === 'bearer' && who.principal !== undefined };
|
|
20
|
+
}
|
|
21
|
+
export function holdsRole(route, who, isOperator) {
|
|
22
|
+
return route.role === 'any' || ((!route.roleBrowser || who.via === 'cookie') &&
|
|
23
|
+
(route.role === 'approver' ? who.role === 'approver' : isOperator(who.name)));
|
|
24
|
+
}
|
|
17
25
|
const edgePolicy = new AsyncLocalStorage();
|
|
18
26
|
export function withEdgePolicy(route, run) { return edgePolicy.run({ route }, run); }
|
|
19
27
|
export function adapterPolicy(principal, scope, resolve = source => source === 'none' || source === 'adapter') {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CHANGE_DOCUMENTS } from "./settings-section-table.js";
|
|
1
2
|
const CONSOLE = ["cookie", "bearer"];
|
|
2
3
|
const exact = (path) => `^${path.replace(/[.*+?^${}()|[\]\\/]/g, m => (m === "/" ? "\\/" : `\\${m}`))}$`;
|
|
3
4
|
const sampleOf = (pattern) => {
|
|
@@ -120,6 +121,7 @@ export const EDGE_LOCAL = Object.freeze({
|
|
|
120
121
|
"edge.password-set-page": { local: "allow", why: "reads only: the local owner's form for a first password, or \"already set — sign in\"" },
|
|
121
122
|
"edge.password-set": { local: "allow", why: "the one credential act a local owner may make: its first password (Origin, CSRF and key proved by the handler; enrollOwnerPassword re-checks local mode, the owner and password_set=0 in its own transaction); a session with a password set is refused" },
|
|
122
123
|
live: { local: "allow", why: "observational only; the agent watch lease is a keyed POST (agents.watch)" },
|
|
124
|
+
"live.ping": { local: "allow", why: "observational only: asks this session's own open stream for a pong; writes nothing" },
|
|
123
125
|
});
|
|
124
126
|
function localMarkOf(stage, method, id) {
|
|
125
127
|
if (stage === "edge") {
|
|
@@ -198,6 +200,7 @@ get("tasks", "term.state", "/term/state", TERM);
|
|
|
198
200
|
get("tasks", "term.session", `^\\/term\\/${TERMINAL}$`, { ...TERM, sample: `/term/${"a".repeat(32)}` });
|
|
199
201
|
get("tasks", "term.socket", `^\\/term\\/${TERMINAL}\\/socket$`, { ...TERM, sample: `/term/${"a".repeat(32)}/socket` });
|
|
200
202
|
get("pages", "projects.browse", "/projects/browse", free);
|
|
203
|
+
get("pages", "projects.pick", "/projects/pick", { ...free, callers: ["cookie"], project: "none", ...approver("Sign in as an approver to add projects.", "/projects") });
|
|
201
204
|
get("pages", "projects.github", "/projects/github", { ...free, callers: ["cookie"], callerRefusal: { status: 403, type: "text/plain; charset=utf-8", body: "listing repositories feeds a browser session's act" },
|
|
202
205
|
...anyApprover("your login can watch — adding projects is an approver's act") });
|
|
203
206
|
get("pages", "projects.page", "/projects", { limited: "unscoped", ...free });
|
|
@@ -226,8 +229,8 @@ get("tasks", "done", "/done", RETIRED);
|
|
|
226
229
|
get("settings", "mode", "/mode");
|
|
227
230
|
get("people", "people.page", "/people", { limited: "unscoped", ...free });
|
|
228
231
|
get("pages", "system", "/system", free);
|
|
229
|
-
get("pages", "start-builder", "/start-builder", { limited: "unscoped", ...free });
|
|
230
|
-
get("tasks", "tasks", "/tasks",
|
|
232
|
+
get("pages", "start-builder", "/start-builder", { limited: "unscoped", ...free, retired: true });
|
|
233
|
+
get("tasks", "tasks", "/tasks", RETIRED);
|
|
231
234
|
get("tasks", "queue", "/queue", RETIRED);
|
|
232
235
|
get("pages", "peek", "/peek", free);
|
|
233
236
|
get("pages", "agents", "/agents", { limited: "unscoped", ...free });
|
|
@@ -267,6 +270,7 @@ for (const one of ["run", "start", "new", "edit", "from-task", "preview", "expor
|
|
|
267
270
|
get("flows", "recipes.other", "^\\/recipes\\/.*$", { sample: "/recipes/unknown" });
|
|
268
271
|
get("tasks", "routines", "/routines", { limited: "collection" });
|
|
269
272
|
edge("live", "live", "GET", "/live", { callers: ["cookie", "bearer"], scope: "read", project: "adapter", proof: "adapter" });
|
|
273
|
+
edge("live", "live.ping", "GET", "/live/ping", { callers: ["cookie"], scope: "read", project: "adapter", proof: "adapter" });
|
|
270
274
|
get("chat", "chat.mate-status", "/chat/mate/status", { ...free, role: "approver", roleBrowser: true, roleRefusal: SESSION_JSON });
|
|
271
275
|
get("chat", "chat.demo-live", "/chat/demo/live", free);
|
|
272
276
|
get("chat", "chat.page", "/chat", { project: "conversation", limited: "conversation", ...free });
|
|
@@ -299,8 +303,13 @@ get("settings", "settings.knowledge", "/settings/knowledge", { limited: "unscope
|
|
|
299
303
|
get("settings", "settings.learning", "/settings/learning", { limited: "unscoped", ...free });
|
|
300
304
|
get("settings", "settings.telegram", "/settings/telegram", { limited: "self", ...free, ...approver("An approver can pair their own phone.", "/settings") });
|
|
301
305
|
get("settings", "settings.page", "/settings", { limited: "unscoped", ...free });
|
|
302
|
-
for (const one of ["general", "agents", "alerts", "projects", "access", "system"
|
|
306
|
+
for (const one of ["general", "agents", "computers", "alerts", "projects", "access", "system"])
|
|
303
307
|
get("settings", `settings.group-${one}`, `/settings/${one}`, { limited: "unscoped", ...free });
|
|
308
|
+
get("settings", "settings.group-advanced", "/settings/advanced", { limited: "unscoped", ...free, retired: true });
|
|
309
|
+
for (const one of CHANGE_DOCUMENTS) {
|
|
310
|
+
const { local: _local, ...policy } = one.section.policy;
|
|
311
|
+
get("settings", `settings.change.${one.id}`, `/settings/change/${one.id}`, { ...policy });
|
|
312
|
+
}
|
|
304
313
|
get("pages", "health", "/health", { ...free, ...anyOperator("An instance operator reads server health.", "/") });
|
|
305
314
|
get("pages", "metrics", "/metrics", { ...free, ...anyOperator("An instance operator reads metrics.", "/") });
|
|
306
315
|
get("chat", "push.key", "/push/key");
|
|
@@ -375,12 +384,13 @@ post("settings", "settings.project-fallback", "/settings/project/fallback", { sc
|
|
|
375
384
|
post("settings", "settings.project-writes", "/settings/project/writes", { scope: "step-up", callers: ["cookie"] });
|
|
376
385
|
post("settings", "settings.project-check-access", "/settings/project/check-access", { scope: "step-up", callers: ["cookie"] });
|
|
377
386
|
post("settings", "settings.project-sandbox", "/settings/project/sandbox", { scope: "step-up", callers: ["cookie"] });
|
|
387
|
+
post("settings", "settings.project-flexible", "/settings/project/flexible", { project: "form", callers: ["cookie"], ...approver("An approver for this project changes how its work starts.", "/settings/project") });
|
|
378
388
|
post("settings", "settings.project-delete", "/settings/project/delete", { scope: "step-up", ...operator("An instance operator deletes projects.", "/settings/project") });
|
|
379
389
|
get("tasks", "sweep.page", "^\\/sweeps\\/[1-9][0-9]{0,9}$", { ...free, limited: "unscoped", sample: "/sweeps/1" });
|
|
380
390
|
post("tasks", "sweep.cancel-rest", "^\\/sweeps\\/[1-9][0-9]{0,9}\\/cancel-rest$", { limited: "unscoped", sample: "/sweeps/1/cancel-rest", ...approver("An approver cancels a sweep's work.", "/chat") });
|
|
381
391
|
get("settings", "settings.passwordless", "/settings/passwordless", { ...free, ...operator("An instance operator sets Passwordless.", "/settings") });
|
|
382
392
|
post("settings", "settings.passwordless-send", "/settings/passwordless", { callers: ["cookie"], ...operator("An instance operator sets Passwordless.", "/settings") });
|
|
383
|
-
post("settings", "settings.local-mode-off", "/settings/local-mode/off", { callers: ["cookie"], scope: "step-up", ...operator("An instance operator turns off local mode.", "/settings/
|
|
393
|
+
post("settings", "settings.local-mode-off", "/settings/local-mode/off", { callers: ["cookie"], scope: "step-up", ...operator("An instance operator turns off local mode.", "/settings/general?section=local-mode") });
|
|
384
394
|
post("settings", "settings.release-approval-send", "/settings/release-approval", { callers: ["cookie"], ...approver("An approver sets how releases are approved.", "/settings/approval") });
|
|
385
395
|
post("pages", "ledger.checkpoint", "/ledger/checkpoint", operator("An instance operator makes ledger checkpoints.", "/ledger"));
|
|
386
396
|
const SETTINGS_ACT_ROLES = {
|
|
@@ -449,7 +459,7 @@ post("pages", "projects.github-list", "/projects/github", { callers: ["cookie"],
|
|
|
449
459
|
post("pages", "projects.select", "/projects/select", { project: "form-path", limited: "unscoped", viewer: true });
|
|
450
460
|
post("pages", "projects.map-refresh", "^\\/projects\\/[^/]+\\/map\\/refresh$", { project: "form", sample: "/projects/payments-api/map/refresh", ...approver("An approver asks for a check of main.", "/projects") });
|
|
451
461
|
post("pages", "projects.remove", "/projects/remove", { project: "form", ...operator("An instance operator removes projects.", "/settings/project") });
|
|
452
|
-
post("pages", "projects.open", "/projects/open", { project: "
|
|
462
|
+
post("pages", "projects.open", "/projects/open", { project: "none" });
|
|
453
463
|
post("tasks", "tasks.add", "/tasks/add", { project: "form", limited: "collection", bodyCap: LARGE_FORM });
|
|
454
464
|
post("tasks", "tasks.fast", "/tasks/fast", { callers: ["cookie"], project: "none", limited: "collection", ...approver("An approver starts builds.", "/tasks/new") });
|
|
455
465
|
post("tasks", "queue.move", "/queue/move");
|