toolroll 0.9.108 → 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 +34 -0
- 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 +37 -34
- package/dist/browser-crew.js +4 -4
- 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 +12 -13
- package/dist/cli.js +4 -3
- package/dist/console-chrome.js +10 -3
- package/dist/contracts/console-api.js +4 -3
- 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/git-views.js +38 -38
- package/dist/guides.js +11 -10
- package/dist/keymap.js +1 -1
- package/dist/lead-context.js +1 -1
- package/dist/limits-ui.js +1 -1
- package/dist/live-bus.js +70 -13
- package/dist/needs-you.js +3 -3
- package/dist/nightly-github.js +2 -2
- package/dist/operate.js +111 -3
- package/dist/project-delete-ui.js +2 -1
- package/dist/project-delete.js +1 -0
- package/dist/provider-auth.js +1 -1
- package/dist/release.js +1 -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/serve.js +32 -29
- 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 +100 -10
- package/dist/server/pages.js +79 -53
- 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 +2 -2
- package/dist/server/render-projects.js +5 -5
- 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 +13 -4
- 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 +164 -19
- package/dist/server/task-views.js +47 -13
- package/dist/server/tasks.js +143 -90
- package/dist/server/welcome.js +6 -5
- package/dist/settings-groups-ui.js +24 -105
- package/dist/settings-proofs.js +5 -2
- package/dist/sqlite-telemetry.js +70 -21
- package/dist/store.js +108 -9
- package/dist/task-link.js +64 -0
- package/dist/tui.js +1 -1
- package/dist/typed-words-schema.js +18 -0
- package/dist/welcome-facts.js +3 -2
- package/dist/work-index.js +126 -29
- package/dist/work-reads.js +279 -0
- package/package.json +4 -2
|
@@ -25,6 +25,7 @@ import { createHash } from "node:crypto";
|
|
|
25
25
|
import { join } from "node:path";
|
|
26
26
|
import { buildsViews, CHEVRON_ICON, consoleSpend, GRIP_HANDLE, isOverdue, projectChip, relativeAge, safePrUrl, screen, sentenceCase, TO_FRONT_ICON, when, whenTime } from "./chrome.js";
|
|
27
27
|
import { reviewHref, taskHref } from "./http.js";
|
|
28
|
+
import { taskLinkOf } from "../task-link.js";
|
|
28
29
|
import { criterionMatrixSummary, incidentWords, PHASE_WORDS, phaseWords } from "./render-results.js";
|
|
29
30
|
import { decisionAnswerCard, decisionAnswerScript, dispatchHeadline, statusLineHtml, workDiagnosticsHtml } from "./render-tasks.js";
|
|
30
31
|
export const TASK_STATES = ["queued", "running", "done", "failed", "cancelled"];
|
|
@@ -107,7 +108,7 @@ export function boardBody(data, ciRed) {
|
|
|
107
108
|
}
|
|
108
109
|
const shown = cards.slice(0, CAP);
|
|
109
110
|
const more = cards.length - shown.length;
|
|
110
|
-
return html `<details class="lane lane-${key}"${shown.length === 0 ? null : html ` open`}><summary><h2>${laneChip(key === "attention" && cards.length === 0 ? "queued" : key, title)} <span class="lane-count">${cards.length}${data.saturated ? "+" : ""}</span></h2></summary><p class="hint">${hint}</p>${shown.length === 0 ? html `<p class="meta lane-empty">nothing here</p>` : shown.map((card, index) => renderOne(card, index))}${more > 0 ? html `<a class="lane-more" href="/
|
|
111
|
+
return html `<details class="lane lane-${key}"${shown.length === 0 ? null : html ` open`}><summary><h2>${laneChip(key === "attention" && cards.length === 0 ? "queued" : key, title)} <span class="lane-count">${cards.length}${data.saturated ? "+" : ""}</span></h2></summary><p class="hint">${hint}</p>${shown.length === 0 ? html `<p class="meta lane-empty">nothing here</p>` : shown.map((card, index) => renderOne(card, index))}${more > 0 ? html `<a class="lane-more" href="/">+${more} more in Work</a>` : null}</details>`;
|
|
111
112
|
};
|
|
112
113
|
const facts = (rows) => rows.length === 0
|
|
113
114
|
? null
|
|
@@ -182,8 +183,8 @@ export function boardBody(data, ciRed) {
|
|
|
182
183
|
: html `<p class="meta board-scope">${data.all
|
|
183
184
|
? html `${data.project === null
|
|
184
185
|
? html `<strong>All projects</strong>`
|
|
185
|
-
: html `<a href="
|
|
186
|
-
: html `<strong>${projectName(data.project)}</strong> · <a href="
|
|
186
|
+
: html `<a href="/?view=board">${projectName(data.project)}</a> · <strong>all projects</strong>`} — every project this server serves, each card wearing its project`
|
|
187
|
+
: html `<strong>${projectName(data.project)}</strong> · <a href="/?view=board">all projects</a>`}</p>`;
|
|
187
188
|
const ago = (minutes) => minutes < 60 ? `${minutes}m` : minutes < 48 * 60 ? `${Math.round(minutes / 60)}h` : `${Math.round(minutes / (24 * 60))}d`;
|
|
188
189
|
const deltaLine = data.delta === null
|
|
189
190
|
? null
|
|
@@ -196,7 +197,7 @@ export function boardBody(data, ciRed) {
|
|
|
196
197
|
].filter((one) => one !== null), html ` · `)}</p>`;
|
|
197
198
|
return joinHtml([
|
|
198
199
|
html `<h1>Board</h1>`,
|
|
199
|
-
data.all ? null : html `<p class="meta board-view"><strong>State</strong> · <a href="
|
|
200
|
+
data.all ? null : html `<p class="meta board-view"><strong>State</strong> · <a href="/?view=order">order →</a> <span class="meta">drag to reorder, or to keep a task for one builder</span></p>`,
|
|
200
201
|
deltaLine,
|
|
201
202
|
toggle,
|
|
202
203
|
workerStrip(data.workers, data.cards, data.now),
|
|
@@ -205,7 +206,7 @@ export function boardBody(data, ciRed) {
|
|
|
205
206
|
lane("queued", "Queued", "Starts when a builder is free.", queuedCard),
|
|
206
207
|
lane("waiting", "Waiting", "Paused until a time, another task, or a requirement is ready.", plain),
|
|
207
208
|
lane("building", "Building", "One agent per card, in its own workspace.", building),
|
|
208
|
-
html `<details class="lane lane-done"${data.done.length === 0 ? null : html ` open`}><summary><h2>${laneChip("done", html `<a href="
|
|
209
|
+
html `<details class="lane lane-done"${data.done.length === 0 ? null : html ` open`}><summary><h2>${laneChip("done", html `<a href="/?view=done">Done recently</a>`)}</h2></summary><p class="hint">The most recent. The full list is under Done.</p>${doneCards}</details>`,
|
|
209
210
|
html `</div>`,
|
|
210
211
|
], "\n");
|
|
211
212
|
}
|
|
@@ -301,7 +302,7 @@ export function workRowChip(row) {
|
|
|
301
302
|
function workActionHref(row) {
|
|
302
303
|
const target = row.primaryAction?.target;
|
|
303
304
|
if (row.primaryAction?.code === 'open-result' && target?.runId != null)
|
|
304
|
-
return
|
|
305
|
+
return taskLinkOf({ task: target.taskId, run: target.runId });
|
|
305
306
|
return browserWorkActionHref(row);
|
|
306
307
|
}
|
|
307
308
|
export function workPage(chrome, data) {
|
|
@@ -358,7 +359,7 @@ export function workPage(chrome, data) {
|
|
|
358
359
|
['finished', 'Finished', data.board.finished, 'completed', 'Nothing has finished yet.'],
|
|
359
360
|
].map(([key, label, page, view, empty]) => ({ key, label, count: page.totals[view], href: query({ view, layout: 'list' }), empty, rows: page.items.map(rowOf) }));
|
|
360
361
|
const putAwayLink = data.canPutAway === true && data.view !== 'archived' ? { label: 'Archive old tasks', href: '/tasks/archive' } : null;
|
|
361
|
-
const toolLinks = [['
|
|
362
|
+
const toolLinks = [['/?view=order', 'Order the queue'], ['/recipes', 'Recipes'], ...(chrome.projectScoped ? [] : [['/', 'Every project']]), ['/ledger', 'Audit log']];
|
|
362
363
|
const newTaskHref = lens === null ? '/tasks/new' : `/tasks/new?project=${encodeURIComponent(lens)}`;
|
|
363
364
|
const emptyNow = data.work.items.length > 0 ? null : filtered && !data.previous ? { text: `No tasks are ${data.state} in this view.`, action: { label: 'Show every state', href: href(data.view, undefined, null) } } : {
|
|
364
365
|
text: data.previous ? 'There are no more tasks on this page.' : current.empty,
|
|
@@ -388,33 +389,14 @@ export function workPage(chrome, data) {
|
|
|
388
389
|
...TASK_STATES.map(one => ({ label: one.charAt(0).toUpperCase() + one.slice(1), href: href(data.view, undefined, one), active: data.state === one }))],
|
|
389
390
|
};
|
|
390
391
|
const legacyTabs = html `<nav class="work-views" aria-label="Task views">${WORK_VIEWS.map(one => html `<a href="${href(one.key)}"${one.key === data.view ? html ` class="active" aria-current="page"` : null}>${one.label}<span class="count">${data.work.totals[one.key]}</span></a>`)}</nav>`;
|
|
391
|
-
const rowHtml = (row) =>
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
? `/review?result=${encodeURIComponent(target.taskId)}&run=${target.runId}`
|
|
400
|
-
: browserWorkActionHref(row);
|
|
401
|
-
const action = actionHref === null || row.primaryAction === null ? null : html `<a class="work-action" data-primary-action href="${actionHref}">${row.primaryAction.label} →</a>`;
|
|
402
|
-
const project = data.multiProject || row.repo === null ? html `<span class="project-label">${row.repo === null ? 'Unplaced' : projectName(row.repo)}</span>` : null;
|
|
403
|
-
const act = tidyAct(row);
|
|
404
|
-
const putAway = act === null ? null : postForm(act.action, html `<button type="submit" class="quiet">${act.label}</button>`, { hidden: { return: returnTo }, attrs: { class: 'inline', 'data-tidy-act': 'put-away' } });
|
|
405
|
-
return html `<article class="work-row" data-task="${row.rootId}" data-work-status="${row.status.token}" data-work-views="${row.status.views.join(' ')}"><div class="work-row-main"><a class="work-title" href="${taskHref(row.rootId)}">${row.title}</a><p class="work-meta">${project}<span>${relativeAge(row.updatedAt, data.now)}</span><span class="mono">${row.rootId}</span></p></div><div class="work-row-status">${statusLineHtml(row.status)}${action}${putAway}${row.familyProblem === null ? null : html `<p class="problem">${row.familyProblem}</p>`}${row.status.views.includes('needs-you') && !['write-scope', 'approve-scope'].includes(row.primaryAction?.code ?? '') && row.status.detail !== row.status.label && row.status.detail !== row.familyProblem ? html `<p class="work-detail">${row.status.detail}</p>` : null}${workDiagnosticsHtml(row.status.diagnostics)}</div></article>`;
|
|
406
|
-
};
|
|
407
|
-
const stateLinks = html `<nav class="work-states" aria-label="Task state"><span class="meta">State:</span> ${joinHtml([html `<a href="${href(data.view, undefined, null)}"${filtered ? null : html ` aria-current="page"`}>Any</a>`,
|
|
408
|
-
...TASK_STATES.map(one => html `<a href="${href(data.view, undefined, one)}"${data.state === one ? html ` aria-current="page"` : null}>${one}</a>`)], html ` · `)}</nav>`;
|
|
409
|
-
const list = data.work.items.length === 0 && filtered && !data.previous
|
|
410
|
-
? html `<div class="work-empty" data-work-empty="${data.view}"><p>No tasks are ${data.state} in this view.</p><a href="${href(data.view, undefined, null)}">Show every state →</a></div>`
|
|
411
|
-
: data.work.items.length === 0
|
|
412
|
-
? html `<div class="work-empty" data-work-empty="${data.view}"><p>${data.previous ? 'There are no more tasks on this page.' : current.empty}</p>${data.view === 'all' && !data.previous ? html `<p><a class="button-link" href="${chrome.chat === true ? '/chat' : '/tasks/new'}">${chrome.chat === true ? 'Start in chat' : 'Add a task'}</a></p>` : html `<a href="${href('all')}">See all tasks →</a>`}</div>`
|
|
413
|
-
: html `<div class="work-list">${data.work.items.map(rowHtml)}</div>`;
|
|
414
|
-
const pages = !data.previous && data.work.nextCursor === null ? null : html `<nav class="row work-pagination" aria-label="Task pages">${data.previous ? html `<a class="button-link" href="${href(data.view)}">First page</a>` : null}${data.work.nextCursor === null ? null : html `<a class="button-link" rel="next" href="${href(data.view, data.work.nextCursor)}">Next page</a>`}</nav>`;
|
|
415
|
-
const tools = html `<details class="work-tools"><summary>Work tools${CHEVRON_ICON}</summary><nav class="work-tools-menu">${[['/', 'Home'], ['/tasks?view=board', 'Board'], ['/tasks?view=order', 'Order'], ['/recipes', 'Recipes'], ...(chrome.projectScoped ? [] : [['/tasks?scope=all', 'Every project']]), ['/ledger', 'Audit log']]
|
|
416
|
-
.map(([path, label]) => html `<a href="${path}">${label}</a>`)}</nav></details>`;
|
|
417
|
-
return screen('work', html `<div class="work-head"><h1>Tasks</h1>${putAwayLink === null ? null : html `<a class="button-link" href="${putAwayLink.href}" data-put-away-old>${putAwayLink.label}</a>`}${tools}</div>${limitsHtml(data.limits ?? null)}${legacyTabs}${stateLinks}${list}${pages}`, { chrome, workspace: { view } });
|
|
392
|
+
const rowHtml = (row) => row.archived !== undefined
|
|
393
|
+
? html `<article class="work-row" data-task="${row.rootId}" data-work-status="archived" data-work-views="archived"><a class="work-title" href="${taskHref(row.rootId)}">${row.title}</a> <span class="status-label">Archived</span></article>`
|
|
394
|
+
: html `<article class="work-row" data-task="${row.rootId}" data-work-status="${row.status.token}" data-work-views="${row.status.views.join(' ')}"><a class="work-title" href="${taskHref(row.rootId)}">${row.title}</a> <span class="status-label">${row.status.label}</span></article>`;
|
|
395
|
+
const list = data.work.items.length === 0
|
|
396
|
+
? html `<p class="work-empty" data-work-empty="${data.view}">${filtered && !data.previous ? `No tasks are ${data.state} in this view.` : data.previous ? 'There are no more tasks on this page.' : current.empty}</p>`
|
|
397
|
+
: html `<div class="work-list">${data.work.items.map(rowHtml)}</div>`;
|
|
398
|
+
const pages = !data.previous && data.work.nextCursor === null ? null : html `<nav class="work-pagination" aria-label="Task pages">${data.previous ? html `<a href="${href(data.view)}">First page</a>` : null} ${data.work.nextCursor === null ? null : html `<a rel="next" href="${href(data.view, data.work.nextCursor)}">Next page</a>`}</nav>`;
|
|
399
|
+
return screen('work', html `${limitsHtml(data.limits ?? null)}${legacyTabs}${list}${pages}`, { chrome, workspace: { view } });
|
|
418
400
|
}
|
|
419
401
|
export function githubIdentityOf(remoteUrl) {
|
|
420
402
|
const trimmed = remoteUrl.trim();
|
|
@@ -472,7 +454,7 @@ export function queueScript() {
|
|
|
472
454
|
`function tell(){if(!stamp)return;if(paused()){stamp.textContent="paused while you edit";return;}` +
|
|
473
455
|
`stamp.textContent="updated "+Math.round((Date.now()-last)/1000)+"s ago";}setInterval(tell,1000);` +
|
|
474
456
|
`function cycle(){if(document.hidden||busy||paused()){setTimeout(cycle,wait);return;}busy=true;` +
|
|
475
|
-
`fetch("
|
|
457
|
+
`fetch("/?view=order&fragment=1",{redirect:"manual",cache:"no-store"})` +
|
|
476
458
|
`.then(function(r){if(r.type==="opaqueredirect"||r.status===401||r.status===403){location.href="/login";return null;}` +
|
|
477
459
|
`return r.ok?r.text():null;})` +
|
|
478
460
|
`.then(function(t){if(t&&!paused()){region.innerHTML=t;last=Date.now();}})` +
|
|
@@ -501,13 +483,13 @@ export function queueScript() {
|
|
|
501
483
|
`var old=card.querySelector(".queue-problem");if(old)old.remove();` +
|
|
502
484
|
`var row=document.createElement("p");row.className="problem queue-problem";row.setAttribute("role","alert");row.textContent=text;card.appendChild(row);return true;}` +
|
|
503
485
|
`fetch("/queue/move",{method:"POST",headers:(window.soKeyHeaders||function(h){return h})({"Content-Type":"application/x-www-form-urlencoded"}),body:post.toString(),redirect:"manual"})` +
|
|
504
|
-
`.then(function(r){if(r.ok)return fetch("
|
|
486
|
+
`.then(function(r){if(r.ok)return fetch("/?view=order&fragment=1",{redirect:"manual",cache:"no-store"}).then(function(f){` +
|
|
505
487
|
`if(f.type==="opaqueredirect"||f.status===401||f.status===403){location.href="/login";return false;}return f.ok?f.text():null;});` +
|
|
506
488
|
`if(r.type==="opaqueredirect"||r.status===401||r.status===403){location.href="/login";return false;}` +
|
|
507
489
|
`var kind=(r.headers&&r.headers.get?r.headers.get("content-type"):"")||"";` +
|
|
508
490
|
`if(r.status===409&&kind.indexOf("text/plain")===0){return r.text().then(function(text){return problem(drag.task,text)?false:null;});}` +
|
|
509
491
|
`return null;})` +
|
|
510
|
-
`.then(function(t){if(t===false)return;if(t&&!paused()){region.innerHTML=t;last=Date.now();}else if(t===null){location.href="
|
|
492
|
+
`.then(function(t){if(t===false)return;if(t&&!paused()){region.innerHTML=t;last=Date.now();}else if(t===null){location.href="/?view=order";}})` +
|
|
511
493
|
`.catch(function(){})` +
|
|
512
494
|
`.then(function(){tell();});});` +
|
|
513
495
|
`})();`);
|
|
@@ -515,11 +497,11 @@ export function queueScript() {
|
|
|
515
497
|
export function putAwayPage(chrome, data) {
|
|
516
498
|
const groups = tidyGroups(data.items, data.days);
|
|
517
499
|
const count = data.items.length;
|
|
518
|
-
const crumbs = html `<nav class="kit-crumbs" aria-label="Breadcrumb"><ol><li><a href="/
|
|
500
|
+
const crumbs = html `<nav class="kit-crumbs" aria-label="Breadcrumb"><ol><li><a href="/">Work</a></li><li><span aria-current="page">Archive old tasks</span></li></ol></nav>`;
|
|
519
501
|
const daysForm = html `<form method="get" action="/tasks/archive" class="put-away-days"><label>Also finished tasks untouched for <input type="number" name="days" min="1" max="365" value="${String(data.days)}" inputmode="numeric"> days</label><button type="submit" class="secondary">Update list</button></form>`;
|
|
520
502
|
const list = joinHtml(groups.map(group => html `<fieldset class="put-away-group" data-tidy-group="${group.rule}"><legend>${group.label}<span class="count">${String(group.items.length)}</span></legend><ul>${group.items.map(item => html `<li><label class="put-away-item" data-tidy-task="${item.taskId}"><input type="checkbox" name="task" value="${item.taskId}" checked><span class="put-away-title">${item.title}</span><span class="put-away-why">${item.reason}</span><span class="put-away-id">${item.taskId}${item.repo === null ? "" : ` · ${projectName(item.repo)}`}${item.members.length > 1 ? ` · ${item.members.length} versions` : ""}</span></label></li>`)}</ul></fieldset>`));
|
|
521
503
|
const body = count === 0
|
|
522
|
-
? html `<p class="kit-state">Nothing to archive right now.</p><p><a href="
|
|
504
|
+
? html `<p class="kit-state">Nothing to archive right now.</p><p><a href="/?view=archived">See archived tasks →</a></p>`
|
|
523
505
|
: stepUpForm({ proof: "tasks-put-away", action: "/work/put-away", id: "put-away", hidden: { digest: data.digest, days: data.days },
|
|
524
506
|
body: html `${list}`, save: { label: "Archive selected", idle: `${count} ${count === 1 ? "task" : "tasks"} selected` }, confirm: `Archive the selected tasks. You can restore any of them from Archived.` });
|
|
525
507
|
return screen("Archive old tasks", html `<div class="put-away">${crumbs}<h1>Archive old tasks</h1>\
|
|
@@ -182,7 +182,7 @@ export function serverErrorPage(options) {
|
|
|
182
182
|
return shell("Toolroll is updating", outPage({
|
|
183
183
|
brand: BRAND_HTML, title: "Toolroll is updating",
|
|
184
184
|
sub: "Work that is running can finish. New work starts again after the update, usually within two minutes.",
|
|
185
|
-
body: html `<div class="k-acts">${options.retry === null ? "" : btn("Try again", { variant: "primary", href: options.retry })}${btn("Go to
|
|
185
|
+
body: html `<div class="k-acts">${options.retry === null ? "" : btn("Try again", { variant: "primary", href: options.retry })}${btn("Go to Work", { href: "/" })}</div>`,
|
|
186
186
|
}), { nav: false });
|
|
187
187
|
}
|
|
188
188
|
return shell("Something went wrong", outPage({
|
|
@@ -191,7 +191,7 @@ export function serverErrorPage(options) {
|
|
|
191
191
|
: "Toolroll couldn't finish that. Open the page again to see what changed before you try again.",
|
|
192
192
|
body: joinHtml([
|
|
193
193
|
facts([["Reference", html `<span class="k-mono">${options.reference}</span>`], ["When", options.at.toISOString().slice(0, 16).replace("T", " ")]]),
|
|
194
|
-
html `<div class="k-acts">${options.retry === null ? "" : btn("Try again", { variant: "primary", href: options.retry })}${btn("Go to
|
|
194
|
+
html `<div class="k-acts">${options.retry === null ? "" : btn("Try again", { variant: "primary", href: options.retry })}${btn("Go to Work", { href: "/" })}</div>`,
|
|
195
195
|
]),
|
|
196
196
|
foot: "If it keeps happening, the reference helps whoever runs this Toolroll find it in the log.",
|
|
197
197
|
}), { nav: false });
|
|
@@ -151,17 +151,17 @@ export function projectPage(chrome, data) {
|
|
|
151
151
|
const counts = peek === null
|
|
152
152
|
? note("Not scanned yet.")
|
|
153
153
|
: html `<p>${joinHtml([
|
|
154
|
-
countWords(peek.waiting, peek.waiting === 1 ? "needs you" : "need you", "/
|
|
155
|
-
countWords(peek.running, "running", "/
|
|
156
|
-
countWords(peek.queued, "queued", "
|
|
157
|
-
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"),
|
|
158
158
|
], " · ")}</p>`;
|
|
159
159
|
const tasks = data.tasks.length === 0
|
|
160
160
|
? note(`Nothing needs you or is running in ${data.name}.`)
|
|
161
161
|
: html `${data.tasks.map(task => row({
|
|
162
162
|
href: task.href, chip: task.needs ? status("needs") : status("running"), title: task.title, desc: task.reason, wait: task.needs,
|
|
163
163
|
meta: task.since === null ? "" : html `<span class="k-num">${relativeAge(task.since, data.now)}</span>`,
|
|
164
|
-
}))}${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`) : ""}`;
|
|
165
165
|
const setup = facts([
|
|
166
166
|
["Folder", mono(data.path)],
|
|
167
167
|
...(data.checks === null ? [] : [["Checks", html `<a class="k-link" href="${data.checks.href}">${data.checks.level}</a>`]]),
|
|
@@ -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") {
|
|
@@ -227,8 +229,8 @@ get("tasks", "done", "/done", RETIRED);
|
|
|
227
229
|
get("settings", "mode", "/mode");
|
|
228
230
|
get("people", "people.page", "/people", { limited: "unscoped", ...free });
|
|
229
231
|
get("pages", "system", "/system", free);
|
|
230
|
-
get("pages", "start-builder", "/start-builder", { limited: "unscoped", ...free });
|
|
231
|
-
get("tasks", "tasks", "/tasks",
|
|
232
|
+
get("pages", "start-builder", "/start-builder", { limited: "unscoped", ...free, retired: true });
|
|
233
|
+
get("tasks", "tasks", "/tasks", RETIRED);
|
|
232
234
|
get("tasks", "queue", "/queue", RETIRED);
|
|
233
235
|
get("pages", "peek", "/peek", free);
|
|
234
236
|
get("pages", "agents", "/agents", { limited: "unscoped", ...free });
|
|
@@ -268,6 +270,7 @@ for (const one of ["run", "start", "new", "edit", "from-task", "preview", "expor
|
|
|
268
270
|
get("flows", "recipes.other", "^\\/recipes\\/.*$", { sample: "/recipes/unknown" });
|
|
269
271
|
get("tasks", "routines", "/routines", { limited: "collection" });
|
|
270
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" });
|
|
271
274
|
get("chat", "chat.mate-status", "/chat/mate/status", { ...free, role: "approver", roleBrowser: true, roleRefusal: SESSION_JSON });
|
|
272
275
|
get("chat", "chat.demo-live", "/chat/demo/live", free);
|
|
273
276
|
get("chat", "chat.page", "/chat", { project: "conversation", limited: "conversation", ...free });
|
|
@@ -300,8 +303,13 @@ get("settings", "settings.knowledge", "/settings/knowledge", { limited: "unscope
|
|
|
300
303
|
get("settings", "settings.learning", "/settings/learning", { limited: "unscoped", ...free });
|
|
301
304
|
get("settings", "settings.telegram", "/settings/telegram", { limited: "self", ...free, ...approver("An approver can pair their own phone.", "/settings") });
|
|
302
305
|
get("settings", "settings.page", "/settings", { limited: "unscoped", ...free });
|
|
303
|
-
for (const one of ["general", "agents", "alerts", "projects", "access", "system"
|
|
306
|
+
for (const one of ["general", "agents", "computers", "alerts", "projects", "access", "system"])
|
|
304
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
|
+
}
|
|
305
313
|
get("pages", "health", "/health", { ...free, ...anyOperator("An instance operator reads server health.", "/") });
|
|
306
314
|
get("pages", "metrics", "/metrics", { ...free, ...anyOperator("An instance operator reads metrics.", "/") });
|
|
307
315
|
get("chat", "push.key", "/push/key");
|
|
@@ -376,12 +384,13 @@ post("settings", "settings.project-fallback", "/settings/project/fallback", { sc
|
|
|
376
384
|
post("settings", "settings.project-writes", "/settings/project/writes", { scope: "step-up", callers: ["cookie"] });
|
|
377
385
|
post("settings", "settings.project-check-access", "/settings/project/check-access", { scope: "step-up", callers: ["cookie"] });
|
|
378
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") });
|
|
379
388
|
post("settings", "settings.project-delete", "/settings/project/delete", { scope: "step-up", ...operator("An instance operator deletes projects.", "/settings/project") });
|
|
380
389
|
get("tasks", "sweep.page", "^\\/sweeps\\/[1-9][0-9]{0,9}$", { ...free, limited: "unscoped", sample: "/sweeps/1" });
|
|
381
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") });
|
|
382
391
|
get("settings", "settings.passwordless", "/settings/passwordless", { ...free, ...operator("An instance operator sets Passwordless.", "/settings") });
|
|
383
392
|
post("settings", "settings.passwordless-send", "/settings/passwordless", { callers: ["cookie"], ...operator("An instance operator sets Passwordless.", "/settings") });
|
|
384
|
-
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") });
|
|
385
394
|
post("settings", "settings.release-approval-send", "/settings/release-approval", { callers: ["cookie"], ...approver("An approver sets how releases are approved.", "/settings/approval") });
|
|
386
395
|
post("pages", "ledger.checkpoint", "/ledger/checkpoint", operator("An instance operator makes ledger checkpoints.", "/ledger"));
|
|
387
396
|
const SETTINGS_ACT_ROLES = {
|