toolroll 0.9.108 → 0.9.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/dist/advanced-view.js +0 -1
- package/dist/agent-detect.js +244 -0
- package/dist/agent-fence.js +47 -5
- package/dist/agent-state.js +5 -2
- package/dist/agentconfig.js +2 -2
- package/dist/approval-summary.js +344 -0
- package/dist/assignment-ui.js +5 -5
- package/dist/assignment.js +5 -2
- package/dist/attest.js +2 -2
- package/dist/browser/terminal.js +1 -1
- package/dist/browser/workspace.css +2 -2
- package/dist/browser/workspace.js +37 -34
- package/dist/browser-crew.js +4 -4
- package/dist/browser-workspace.js +4 -11
- package/dist/builder.js +45 -3
- package/dist/chat-actions.js +24 -17
- package/dist/chat-controls.js +6 -5
- package/dist/chat-core.js +3 -1
- package/dist/chat-decide.js +102 -47
- package/dist/chat-delivery-state.js +2 -0
- package/dist/chat-delivery.js +3 -2
- package/dist/chat-live.js +2 -1
- package/dist/chat-quiet.js +3 -3
- package/dist/chat-task-actions.js +6 -0
- package/dist/chat-voice.js +2 -2
- package/dist/check-report.js +1 -1
- package/dist/cli-help.js +12 -13
- package/dist/cli.js +6 -3
- package/dist/console-chrome.js +10 -3
- package/dist/console-instance.js +10 -1
- package/dist/contracts/console-api.js +14 -8
- package/dist/contracts/engine-api.js +271 -0
- package/dist/contracts/handoff.js +4 -0
- package/dist/coordinator.js +2 -2
- package/dist/decision.js +17 -0
- package/dist/demo-chat.js +1 -1
- package/dist/demo.js +6 -0
- package/dist/design/kit.js +4 -3
- package/dist/discord-api.js +4 -3
- package/dist/discord-chat.js +3 -1
- package/dist/dispatch.js +3 -8
- package/dist/easy-start-args.js +7 -3
- package/dist/easy-start.js +25 -0
- package/dist/egress.js +72 -10
- package/dist/engine-handoff.js +34 -0
- package/dist/engine-reads.js +261 -0
- package/dist/eval-world.js +3 -2
- package/dist/evidence.js +2 -0
- package/dist/fast-start.js +55 -14
- package/dist/fast-terms.js +2 -2
- package/dist/first-run.js +10 -2
- package/dist/flexible-agents.js +234 -0
- package/dist/flexible-answers-schema.js +61 -0
- package/dist/flexible-answers.js +889 -0
- package/dist/flexible-available.js +1 -0
- package/dist/flexible-custody.js +494 -0
- package/dist/flexible-import.js +782 -0
- package/dist/flexible-launch-schema.js +72 -0
- package/dist/flexible-launch.js +331 -0
- package/dist/flexible-launcher.js +88 -0
- package/dist/flexible-levels.js +34 -0
- package/dist/flexible-merge-guard.js +47 -0
- package/dist/flexible-refs.js +47 -0
- package/dist/flexible-relay-cancel.js +19 -0
- package/dist/flexible-relay-schema.js +55 -0
- package/dist/flexible-relay-upstreams.js +36 -0
- package/dist/flexible-relay.js +1032 -0
- package/dist/flexible-schema.js +32 -0
- package/dist/flexible-session.js +732 -0
- package/dist/flexible-ship-schema.js +81 -0
- package/dist/flexible-ship.js +694 -0
- package/dist/flexible-start.js +80 -0
- package/dist/flexible-thread-schema.js +30 -0
- package/dist/flexible-thread.js +676 -0
- package/dist/flexible-turns-schema.js +69 -0
- package/dist/flexible-turns.js +490 -0
- package/dist/flexible-ui.js +44 -0
- package/dist/flexible.js +368 -0
- package/dist/flow-actions.js +6 -4
- package/dist/flow-steps.js +1 -1
- package/dist/flows-cli.js +2 -1
- package/dist/git-views.js +44 -41
- package/dist/guides.js +11 -10
- package/dist/install-mode.js +225 -0
- package/dist/keymap.js +1 -1
- package/dist/lead-context.js +1 -1
- package/dist/lead-doors.js +7 -1
- package/dist/limits-ui.js +8 -1
- package/dist/live-bus.js +70 -13
- package/dist/live-reply.js +6 -0
- package/dist/live-terminal.js +425 -29
- package/dist/local-owner.js +6 -0
- package/dist/model-choices.js +12 -6
- package/dist/needs-you.js +3 -3
- package/dist/nightly-github.js +2 -2
- package/dist/notification-delivery.js +11 -0
- package/dist/operate.js +185 -33
- package/dist/outbound-privacy.js +204 -0
- package/dist/passwordless.js +2 -1
- package/dist/project-delete-ui.js +2 -1
- package/dist/project-delete.js +15 -0
- package/dist/provider-auth.js +1 -1
- package/dist/provider-connection.js +5 -3
- package/dist/publish.js +5 -0
- package/dist/pull-request-flow.js +26 -7
- package/dist/push.js +5 -1
- package/dist/release-card.js +11 -3
- package/dist/release.js +11 -1
- package/dist/result-actions.js +3 -0
- package/dist/result-evidence-readers.js +8 -2
- package/dist/result-review.js +20 -9
- package/dist/route-store.js +2 -2
- package/dist/sandbox-launch.js +32 -8
- package/dist/sandbox-runtime.js +16 -7
- package/dist/sandbox-tools.js +176 -0
- package/dist/scope.js +12 -36
- package/dist/scout-net.js +7 -2
- package/dist/serve.js +90 -40
- package/dist/server/chat.js +9 -9
- package/dist/server/chrome.js +19 -17
- package/dist/server/console.css +33 -6
- package/dist/server/engine-api.js +378 -0
- package/dist/server/flows.js +2 -2
- package/dist/server/guards.js +10 -4
- package/dist/server/home.js +37 -5
- package/dist/server/http.js +11 -2
- package/dist/server/in-place.js +5 -4
- package/dist/server/kit.js +2 -2
- package/dist/server/link-redemption.js +52 -0
- package/dist/server/live.js +100 -10
- package/dist/server/mutation-key.js +21 -7
- package/dist/server/pages.js +129 -74
- package/dist/server/people-tokens.js +17 -41
- package/dist/server/render-chat.js +2 -1
- package/dist/server/render-history.js +18 -4
- package/dist/server/render-new-task.js +4 -4
- package/dist/server/render-pages.js +21 -39
- package/dist/server/render-people.js +2 -2
- package/dist/server/render-projects.js +5 -5
- package/dist/server/render-results.js +30 -14
- package/dist/server/render-tasks.js +155 -155
- package/dist/server/retired-routes.js +37 -4
- package/dist/server/route-policy.js +8 -0
- package/dist/server/route-table.js +43 -5
- package/dist/server/settings-computers.js +140 -0
- package/dist/server/settings-scripts.js +15 -0
- package/dist/server/settings-section-table.js +59 -0
- package/dist/server/settings-sections.js +291 -0
- package/dist/server/settings.js +247 -28
- package/dist/server/task-views.js +55 -15
- package/dist/server/tasks.js +168 -98
- package/dist/server/terminals.js +181 -28
- package/dist/server/welcome.js +40 -14
- package/dist/settings-groups-ui.js +26 -107
- package/dist/settings-proofs.js +18 -11
- package/dist/slack-api.js +4 -3
- package/dist/slack-chat.js +5 -3
- package/dist/spend.js +46 -12
- package/dist/sqlite-telemetry.js +70 -21
- package/dist/status-probe.js +343 -0
- package/dist/store.js +206 -10
- package/dist/task-link.js +64 -0
- package/dist/teams-api.js +4 -3
- package/dist/teams-chat.js +4 -2
- package/dist/telegram-lead.js +2 -1
- package/dist/telegram-live.js +2 -1
- package/dist/telegram-team.js +2 -1
- package/dist/telegram.js +17 -5
- package/dist/trusted-path.js +162 -0
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/dist/tui-launch.js +282 -0
- package/dist/tui-source.js +5 -3
- package/dist/tui.js +2 -2
- package/dist/typed-words-schema.js +18 -0
- package/dist/webhooks.js +8 -4
- package/dist/welcome-facts.js +25 -17
- package/dist/work-index.js +126 -29
- package/dist/work-reads.js +279 -0
- package/dist/workspace-ui.js +5 -0
- package/package.json +4 -2
- package/scripts/crash-canary.mjs +1 -1
- package/scripts/pilot.mjs +1 -1
- package/scripts/provider-canary.mjs +5 -3
package/dist/server/tasks.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { advancedShownNow } from "../advanced-view.js";
|
|
2
2
|
import { titleWithin } from "../task-text.js";
|
|
3
3
|
import { parseFeedbackImage, sameFeedbackImage } from "../result-review.js";
|
|
4
|
-
import { archiveTaskFamily, dropFeedbackImage, releaseAuthorityOfTask, restoreTaskFamily, revokeRelease, runCheckStamp, runLiveCommands } from "../store.js";
|
|
4
|
+
import { archiveTaskFamily, dropFeedbackImage, markTypedByPerson, typedNotesFor, releaseAuthorityOfTask, restoreTaskFamily, revokeRelease, runCheckStamp, runLiveCommands } from "../store.js";
|
|
5
5
|
import { ranWords } from "../check-stamp.js";
|
|
6
6
|
import { applyTidy, approverStandsNow, familyRepoOf, releaseFactsOf, tidyDays, tidyDigest, tidyPreview, TIDY_DEFAULT_DAYS } from "../tidy.js";
|
|
7
7
|
import { steerCapabilityOf } from "../steer-capabilities.js";
|
|
@@ -42,7 +42,7 @@ import { closeFinding, familyInWebReach, familyRootOf, getFinding, NOT_ON_TASK,
|
|
|
42
42
|
import { labelProviderCapture, providerCapture } from "../provider-capture.js";
|
|
43
43
|
import { fastStartBuild, keepGrownChange, prepareFastStart } from "../fast-start.js";
|
|
44
44
|
import { evidencePack } from "../evidence-pack.js";
|
|
45
|
-
import { decisionPage, evidenceRecordPage, runPage } from "./render-history.js";
|
|
45
|
+
import { decisionPage, evidenceRecordPage, evidenceRecordSection, runPage } from "./render-history.js";
|
|
46
46
|
import { readVerifiedArtifact, readVerifiedReport, writeEvidenceFile } from "../evidence.js";
|
|
47
47
|
import { computeGaps } from "../gaps.js";
|
|
48
48
|
import { limitsView } from "../limits-ui.js";
|
|
@@ -67,6 +67,7 @@ import { structuredHandoffView, terminalDiffView } from "../result-evidence-read
|
|
|
67
67
|
import { fileAddTestsTask, requestFollowUpChecks } from '../result-follow-ups.js';
|
|
68
68
|
import { commentSourceKey, isRevisionFeedback, parseResultTab, resultReturnTarget } from "../result-review.js";
|
|
69
69
|
import { isAlive as runnerAlive } from "../runner.js";
|
|
70
|
+
import { soloNow } from "../install-mode.js";
|
|
70
71
|
import { passwordlessSessionFor, acceptanceLinesToInput, acceptanceToLines, approvalOf, approve as approveScope, freshnessFor, freshlyApprovable, localApprovalEligible, spendingOnlyOnSuccess, ssoNowAvailable, withFreshness, modeFilingCoverage, PLACEHOLDER_RUBRIC, proposeGuarded } from "../scope.js";
|
|
71
72
|
import { subagentNames as subagentNamesOf } from "../spend.js";
|
|
72
73
|
import { verifiedAuthor } from "../store.js";
|
|
@@ -79,27 +80,31 @@ import { WorkIndexCursorError, workIndexPage } from "../work-index.js";
|
|
|
79
80
|
import { buildProgressOf, parseWorkView } from "../workspace-ui.js";
|
|
80
81
|
import { requestContext } from "./request-context.js";
|
|
81
82
|
import { boardTickScript, oneLineOf, QUEUE_VIEW, refuse, regionScript, screen, transcriptScript, whenTime } from "./chrome.js";
|
|
82
|
-
import { retiredRedirect } from "./retired-routes.js";
|
|
83
|
-
import { answersInPlace, chatReturnWithSaid, matchTaskPath, redirect, respond, reviewHref, safeChatReturn, safeReturn, SAFETY, taskChatHref, taskHref } from "./http.js";
|
|
83
|
+
import { retiredHandler, retiredRedirect, TASK_VIEW_REDIRECTS } from "./retired-routes.js";
|
|
84
|
+
import { answersInPlace, refusedInPlace, chatReturnWithSaid, matchTaskPath, redirect, respond, reviewHref, safeChatReturn, safeReturn, SAFETY, taskChatHref, taskHref } from "./http.js";
|
|
85
|
+
import { taskLinkOf } from "../task-link.js";
|
|
84
86
|
import { putAwayPage, boardBody, boardWorkers, QUEUE_FRONT, queueBody, queueScript, TASK_STATES, workPage } from "./render-pages.js";
|
|
85
87
|
import { runEfficiencyOf } from "../run-efficiency.js";
|
|
86
88
|
import { timingFor } from "../latency-timeline.js";
|
|
87
89
|
import { ACCEPT_ANYWAY_NEEDS_REASON, editorFileHref, proofBundleView, rankReviewQueue, RESULT_REFUSALS, REVIEW_QUEUE_CAP, reviewCockpitDetailParts, reviewCockpitPage, reviewPriorityOf, runFactsFragment, runOutcomeBadge, withRefusal } from "./render-results.js";
|
|
90
|
+
import { approvalSummaryFor } from "../approval-summary.js";
|
|
88
91
|
import { approvalFormDigest, approveRefusalWords, checkProgressHtml, consentDoorOf, nonceHashOf, PermissionsWouldChange, requirementsFromEditor, resumeDigestOf, taskOf } from "./render-tasks.js";
|
|
89
92
|
import {} from "./session.js";
|
|
90
93
|
import { approveReleaseCard, releaseApprovalCard, releaseSheetHref, releaseTaskOf } from "../release-approval.js";
|
|
91
94
|
import { releaseSheetPage } from "./render-release.js";
|
|
92
95
|
import { approvalFactsNow } from "./kit.js";
|
|
93
96
|
import { localOwnerRefusal } from "../local-owner.js";
|
|
97
|
+
import { firstTaskRouted } from "../welcome-facts.js";
|
|
98
|
+
export const FIRST_TASK_DETECT_WAIT_MS = 8_000;
|
|
94
99
|
export function createTasksHandlers(runtime) {
|
|
95
|
-
const { identities, store, peekSay, peekCache, PEEK_CACHE_TTL_MS, peekInFlight, PEEK_GLOBAL_INFLIGHT, peekBySession, PEEK_SESSION_INFLIGHT, clock, peekName, PEEK_FRAGMENT_BYTES, peekEvict, evidenceRoot, sendScreen, chromeFor, visible, consumeApprovalNonce, authenticateApprover, options, mintApprovalNonce, taskScreen, unscopedMode, admissionList, planViewOf, revisionViewOf, runIsTaskResult, leadPrincipal, familyOf, armTaskResume, runIsLive, revisionLedgerOf, resultDetailOf, reviewFactsFor, taskRepoOf, runVisible, restricted, codingActorAllowed, codingProjectAllowed, managedRepos, routeViewOf, workAccess, firstRunStepsNow, revisionDocOf, failureOf, dockedConversation, planContractViewOf, familiesInView, explainAttempt, taskChatFocus, familyTasksInView, liveCeiling, projectOf, ceiling, bustBadge, revisionDestination } = runtime;
|
|
100
|
+
const { identities, store, peekSay, peekCache, PEEK_CACHE_TTL_MS, peekInFlight, PEEK_GLOBAL_INFLIGHT, peekBySession, PEEK_SESSION_INFLIGHT, clock, peekName, PEEK_FRAGMENT_BYTES, peekEvict, evidenceRoot, sendScreen, chromeFor, visible, consumeApprovalNonce, authenticateApprover, authenticateCredential, options, mintApprovalNonce, taskScreen, unscopedMode, admissionList, planViewOf, revisionViewOf, runIsTaskResult, leadPrincipal, familyOf, armTaskResume, runIsLive, revisionLedgerOf, resultDetailOf, reviewFactsFor, taskRepoOf, runVisible, restricted, codingActorAllowed, codingProjectAllowed, managedRepos, routeViewOf, workAccess, firstRunStepsNow, revisionDocOf, failureOf, dockedConversation, planContractViewOf, familiesInView, explainAttempt, taskChatFocus, familyTasksInView, liveCeiling, projectOf, ceiling, bustBadge, revisionDestination } = runtime;
|
|
96
101
|
function noPage(who, response) {
|
|
97
102
|
return refuse(response, who, 404, "There's no page at this address.", "/chat");
|
|
98
103
|
}
|
|
99
104
|
const showCode = (part, posted = false) => async (ctx) => {
|
|
100
105
|
const { url, who, response, project } = ctx;
|
|
101
106
|
if (who.via !== 'cookie' || !codingActorAllowed({ name: who.name, generation: who.session.generation }))
|
|
102
|
-
return refuse(response, who, 403, 'Coding sessions require installation-wide operator access. You can manage project tasks in Work.', '/
|
|
107
|
+
return refuse(response, who, 403, 'Coding sessions require installation-wide operator access. You can manage project tasks in Work.', '/');
|
|
103
108
|
const actor = { name: who.name, generation: who.session.generation };
|
|
104
109
|
const sessionId = part === "workspace" || part === "unknown" ? null : /^\/code\/([a-f0-9]{32})/.exec(url.pathname)[1];
|
|
105
110
|
const read = part === "state" || part === "changes" ? part : null;
|
|
@@ -140,7 +145,7 @@ export function createTasksHandlers(runtime) {
|
|
|
140
145
|
if (!codingActorAllowed(actor))
|
|
141
146
|
return read !== null
|
|
142
147
|
? respond(response, 403, 'application/json', JSON.stringify({ ok: false, error: 'Your access changed. Sign in again.' }))
|
|
143
|
-
: refuse(response, who, 403, 'Your access changed. Sign in again.', '/
|
|
148
|
+
: refuse(response, who, 403, 'Your access changed. Sign in again.', '/');
|
|
144
149
|
const message = error instanceof Error ? error.message : 'The coding workspace is unavailable.';
|
|
145
150
|
if (part === 'ship')
|
|
146
151
|
return sendScreen(response, 409, screen('Review for shipping', html `<h1>Prepare this result</h1><p>${message}</p><a href="/code/${sessionId}">Back to coding</a>`, { chrome: chromeFor(project, 'code') }));
|
|
@@ -149,12 +154,14 @@ export function createTasksHandlers(runtime) {
|
|
|
149
154
|
return sendScreen(response, 404, screen('Coding session unavailable', html `<h1>Session unavailable</h1><p>${message}</p><a href="/code">Open coding workspace</a>`, { chrome: chromeFor(project, 'code') }));
|
|
150
155
|
}
|
|
151
156
|
};
|
|
152
|
-
async function
|
|
157
|
+
async function workListOf(ctx) {
|
|
153
158
|
const { url, who, response, now, project } = ctx;
|
|
154
159
|
const view = parseWorkView(url.searchParams.get("view"));
|
|
155
160
|
const wantedState = url.searchParams.get("state");
|
|
156
|
-
if (wantedState !== null && !TASK_STATES.includes(wantedState))
|
|
157
|
-
|
|
161
|
+
if (wantedState !== null && !TASK_STATES.includes(wantedState)) {
|
|
162
|
+
refuse(response, who, 400, "no such state", "/");
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
158
165
|
const state = wantedState;
|
|
159
166
|
const rollup = project === null && !unscopedMode;
|
|
160
167
|
let work;
|
|
@@ -171,30 +178,36 @@ export function createTasksHandlers(runtime) {
|
|
|
171
178
|
}
|
|
172
179
|
}
|
|
173
180
|
catch (error) {
|
|
174
|
-
if (error instanceof WorkIndexCursorError)
|
|
175
|
-
|
|
181
|
+
if (error instanceof WorkIndexCursorError) {
|
|
182
|
+
refuse(response, who, 400, 'This task page has expired. Open the first page.', '/');
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
176
185
|
throw error;
|
|
177
186
|
}
|
|
178
|
-
const enrich = (page) =>
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
187
|
+
const enrich = (page) => {
|
|
188
|
+
let admitted;
|
|
189
|
+
return { ...page, items: page.items.map((item) => {
|
|
190
|
+
if (item.liveRunId !== null) {
|
|
191
|
+
const ref = store.lookupRef(item.activeTaskId);
|
|
192
|
+
const recorded = ref === null ? null : store.latestCheckpointForRun(item.liveRunId);
|
|
193
|
+
if (ref === null || recorded === null || recorded.taskRef !== ref.id)
|
|
194
|
+
return item;
|
|
195
|
+
const plan = store.currentPlanRevision(ref.id);
|
|
196
|
+
const parsed = plan === null ? null : (() => { const doc = revisionDocOf(plan); return doc === null ? null : parseExecutionPlanDocument(doc.document); })();
|
|
197
|
+
const words = new Map(parsed?.ok === true ? milestonesOf(parsed.document).map(one => [one.id, one.description]) : []);
|
|
198
|
+
const steps = buildProgressOf(recorded.snapshot.milestones.map(one => ({ description: words.get(one.id) ?? null, state: one.state, note: one.note ?? null })));
|
|
199
|
+
return steps === null ? item : { ...item, progress: steps.line };
|
|
200
|
+
}
|
|
201
|
+
if (item.state !== "failed")
|
|
183
202
|
return item;
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const family = familyOf(item.activeTaskId);
|
|
193
|
-
if (family === null || family.problem !== null)
|
|
194
|
-
return item;
|
|
195
|
-
const failure = failureOf(family.versions.flatMap(version => store.runsFor(version.refId)), null, false);
|
|
196
|
-
return failure.kind === "reason" ? item : { ...item, status: { ...item.status, detail: failure.line } };
|
|
197
|
-
}) });
|
|
203
|
+
admitted ??= { repos: admissionList(), unplaced: visible(null) };
|
|
204
|
+
const family = store.taskFamilyOf(item.activeTaskId, admitted.repos, admitted.unplaced);
|
|
205
|
+
if (family === null || family.problem !== null)
|
|
206
|
+
return item;
|
|
207
|
+
const failure = failureOf(family.versions.flatMap(version => store.runsFor(version.refId)), null, false);
|
|
208
|
+
return failure.kind === "reason" ? item : { ...item, status: { ...item.status, detail: failure.line } };
|
|
209
|
+
}) };
|
|
210
|
+
};
|
|
198
211
|
work = enrich(work);
|
|
199
212
|
const board = url.searchParams.get("layout") !== "board" ? null : (() => {
|
|
200
213
|
const column = (view) => enrich(workIndexPage(store, now, workAccess(), { view, limit: BOARD_COLUMN_LIMIT, project, root: evidenceRoot, ...(state === null ? {} : { state }) }));
|
|
@@ -216,12 +229,7 @@ export function createTasksHandlers(runtime) {
|
|
|
216
229
|
? limitsView(store.providerLimits(), store.budgets().length === 0 ? [] : store.monthSpendCached(now).budgets, { project: projectName, subagent: id => subagentNamesOf(store.handle).get(id) ?? `Subagent ${id}` }, now)
|
|
217
230
|
: null,
|
|
218
231
|
});
|
|
219
|
-
|
|
220
|
-
const docked = projectThread === null ? null : dockedConversation(who, null, projectThread, now, `/tasks?project=${encodeURIComponent(projectThread)}`);
|
|
221
|
-
if (docked !== null)
|
|
222
|
-
page.workspace = { ...page.workspace, conversation: docked, pageHtml: page.body };
|
|
223
|
-
page.refreshSeconds = work.totals.running > 0 ? 10 : 30;
|
|
224
|
-
return sendScreen(response, 200, page);
|
|
232
|
+
return { screen: page, work, filtered: state !== null || url.searchParams.has('cursor') };
|
|
225
233
|
}
|
|
226
234
|
function reviewRowOf(row, now) {
|
|
227
235
|
const assignment = assignmentOf(store, row.taskId, now, workAccess(), evidenceRoot);
|
|
@@ -288,10 +296,13 @@ export function createTasksHandlers(runtime) {
|
|
|
288
296
|
const chosen = picked?.chosen ?? null, attemptRow = picked?.attemptRow ?? null, beyond = picked?.beyond ?? null;
|
|
289
297
|
const selectedRow = wantedId === null ? ranked[0] ?? null : chosen;
|
|
290
298
|
if (expectedRun !== null && wantedId !== null && chosen === null)
|
|
291
|
-
return refuse(response, who, 404, "No such result in your projects.", "/
|
|
299
|
+
return refuse(response, who, 404, "No such result in your projects.", "/");
|
|
292
300
|
if (expectedRun !== null && (!/^[1-9]\d*$/.test(expectedRun) || selectedRow?.runId !== Number(expectedRun))) {
|
|
293
|
-
return sendScreen(response, 409, screen("Result changed", html `<h1>Result changed</h1><p>This acceptance link no longer matches the current result. Review the current task before accepting.</p><p class="refusal-back"><a class="button-link" href="
|
|
301
|
+
return sendScreen(response, 409, screen("Result changed", html `<h1>Result changed</h1><p>This acceptance link no longer matches the current result. Review the current task before accepting.</p><p class="refusal-back"><a class="button-link" href="/?view=ready">Review results</a></p>`, { chrome: chromeFor(project, "runs") }));
|
|
294
302
|
}
|
|
303
|
+
const resultHome = wantedId !== null && chosen !== null ? TASK_VIEW_REDIRECTS.review(url) : null;
|
|
304
|
+
if (resultHome !== null)
|
|
305
|
+
return redirect(response, resultHome);
|
|
295
306
|
const selected = picked !== null ? picked.selected : selectedRow === null ? null : reviewCockpitViewOf(selectedRow, who, now);
|
|
296
307
|
const reviewPage = reviewCockpitPage(chromeFor(wantedId === null ? project : chosenProject, "runs"), {
|
|
297
308
|
queue: ranked,
|
|
@@ -314,14 +325,9 @@ export function createTasksHandlers(runtime) {
|
|
|
314
325
|
reviewPage.workspace = { ...reviewPage.workspace, conversation: reviewDocked, pageHtml: reviewPage.body };
|
|
315
326
|
return sendScreen(response, 200, reviewPage);
|
|
316
327
|
}
|
|
317
|
-
async function
|
|
328
|
+
async function workListFor(ctx) {
|
|
318
329
|
const { url } = ctx;
|
|
319
|
-
const template = url.searchParams.get("template");
|
|
320
|
-
if (template !== null)
|
|
321
|
-
return redirect(ctx.response, `/tasks/new?template=${encodeURIComponent(template)}`);
|
|
322
330
|
const view = url.searchParams.get("view");
|
|
323
|
-
if (view === "order")
|
|
324
|
-
return showOrder(ctx);
|
|
325
331
|
const read = new URL(url.href);
|
|
326
332
|
if (view === "board") {
|
|
327
333
|
read.searchParams.delete("view");
|
|
@@ -333,7 +339,7 @@ export function createTasksHandlers(runtime) {
|
|
|
333
339
|
read.searchParams.delete("scope");
|
|
334
340
|
read.searchParams.set("all", "1");
|
|
335
341
|
}
|
|
336
|
-
return
|
|
342
|
+
return workListOf({ ...ctx, url: read });
|
|
337
343
|
}
|
|
338
344
|
async function showOrder(ctx) {
|
|
339
345
|
const { url, who, response, project } = ctx;
|
|
@@ -344,7 +350,7 @@ export function createTasksHandlers(runtime) {
|
|
|
344
350
|
const region = queueRegionFor(project, csrf, revision, clock());
|
|
345
351
|
return sendScreen(response, 200, screen("order", joinHtml([
|
|
346
352
|
html `<h1>Order the queue</h1>`,
|
|
347
|
-
html `<p class="meta board-view"><a href="
|
|
353
|
+
html `<p class="meta board-view"><a href="/?view=board">Board</a> · <strong>order</strong> <span class="meta">— drag to reorder, or onto a builder to keep it for that builder</span></p>`,
|
|
348
354
|
html `<div id="queue-region">${region}</div>`,
|
|
349
355
|
html `<p class="meta" id="queue-region-stamp"></p>`,
|
|
350
356
|
], "\n"), { chrome: chromeFor(project, "work"), functional: { script: queueScript(), fetches: true } }));
|
|
@@ -355,7 +361,7 @@ export function createTasksHandlers(runtime) {
|
|
|
355
361
|
const ref = Number.isSafeInteger(number) ? store.refForId(number) : null;
|
|
356
362
|
const task = ref === null || ref.backend !== "built-in" ? null : ref.externalId;
|
|
357
363
|
if (task === null || ref === null || ref.repo === null || !visible(ref.repo) || !store.accountCanAccess(who.name, ref.repo)) {
|
|
358
|
-
return refuse(response, who, 404, "There's no page at this address.", "/
|
|
364
|
+
return refuse(response, who, 404, "There's no page at this address.", "/");
|
|
359
365
|
}
|
|
360
366
|
return redirectGet(response, taskHref(task));
|
|
361
367
|
}
|
|
@@ -374,7 +380,7 @@ export function createTasksHandlers(runtime) {
|
|
|
374
380
|
return noPage(who, response);
|
|
375
381
|
const family = familyOf(task.taskId);
|
|
376
382
|
if (family === null)
|
|
377
|
-
return refuse(response, who, 404, "no such task", "/
|
|
383
|
+
return refuse(response, who, 404, "no such task", "/");
|
|
378
384
|
const version = url.searchParams.get("version");
|
|
379
385
|
if (version !== null && !family.versions.some(one => one.id === version))
|
|
380
386
|
return refuse(response, who, 404, "That version is not available for this task.", taskHref(family.root.id));
|
|
@@ -391,21 +397,37 @@ export function createTasksHandlers(runtime) {
|
|
|
391
397
|
return refuse(response, who, 404, "No such result for this task.", taskHref(family.root.id));
|
|
392
398
|
const owner = named === null || version !== null ? null : (() => { const ref = store.getRun(named)?.taskRef; const id = ref === undefined ? null : store.externalIdFor(ref); return id !== null && family.versions.some(one => one.id === id) ? id : null; })();
|
|
393
399
|
const shown = version ?? owner ?? family.current.id;
|
|
394
|
-
const
|
|
395
|
-
|
|
400
|
+
const readProject = (() => { const repo = store.lookupRef(shown)?.repo ?? null; return repo !== null && visible(repo) ? repo : ctx.project; })();
|
|
401
|
+
const picked = selectResultFor(shown, named, readProject, who, ctx.now);
|
|
402
|
+
if (named !== null && picked.chosen?.runId !== named) {
|
|
403
|
+
const ran = store.getRun(named);
|
|
404
|
+
const ours = ran !== null && runVisible(ran) && family.versions.some(one => one.refId === ran.taskRef) && runIsTaskResult(ran);
|
|
405
|
+
if (ours)
|
|
406
|
+
return sendScreen(response, 409, screen("Result changed", html `<h1>Result changed</h1><p>This link no longer matches the current result. Review the current result before accepting.</p><p class="refusal-back"><a class="button-link" href="${taskLinkOf({ task: family.root.id, result: true })}">Open the current result</a></p>`, { chrome: chromeFor(family.root.repo, "tasks") }));
|
|
396
407
|
return refuse(response, who, 404, "No such result for this task.", taskHref(family.root.id));
|
|
408
|
+
}
|
|
397
409
|
const base = `${taskHref(family.root.id)}?${shown !== family.current.id ? `version=${encodeURIComponent(shown)}&` : ""}tab=result`;
|
|
398
410
|
const csrf = who.via === "cookie" ? who.session.csrf : "";
|
|
399
411
|
const result = picked.selected === null ? null : (() => {
|
|
400
|
-
const
|
|
401
|
-
const
|
|
402
|
-
|
|
412
|
+
const latest = named === null ? picked.chosen?.runId ?? null : selectResultFor(shown, null, readProject, who, ctx.now).chosen?.runId ?? null;
|
|
413
|
+
const current = shown === family.current.id && (picked.chosen?.runId ?? null) === latest;
|
|
414
|
+
const parts = reviewCockpitDetailParts(picked.selected, csrf, url.searchParams.get("noted") !== null, who.via === "cookie" && who.role === "approver", parseResultTab(url.searchParams.get("section")), who.name, { kind: "task", base, alone: !current });
|
|
415
|
+
const refusedCode = url.searchParams.get("refused") ?? "";
|
|
416
|
+
const refusal = Object.hasOwn(RESULT_REFUSALS, refusedCode) ? RESULT_REFUSALS[refusedCode] : null;
|
|
417
|
+
return { html: refusal === null ? parts.html : html `<p class="problem" data-result-refusal>${refusal}</p>${parts.html}`,
|
|
418
|
+
selected: refusal === null ? parts.selected : { ...parts.selected, problem: refusal },
|
|
419
|
+
current };
|
|
403
420
|
})();
|
|
421
|
+
const record = url.searchParams.get("tab") === "record" ? (() => {
|
|
422
|
+
const access = workAccess();
|
|
423
|
+
const pack = evidencePack(store, family.root.id, access, who.name, ctx.now, evidenceRoot);
|
|
424
|
+
return pack === null ? null : evidenceRecordSection(pack);
|
|
425
|
+
})() : null;
|
|
404
426
|
const admissible = new Set(family.versions.flatMap(one => {
|
|
405
427
|
const ref = store.lookupRef(one.id);
|
|
406
|
-
return ref === null ? [] : store.runsFor(ref.id).filter(run => resultRunAdmissible(one.id, run,
|
|
428
|
+
return ref === null ? [] : store.runsFor(ref.id).filter(run => resultRunAdmissible(one.id, run, readProject)).map(run => run.id);
|
|
407
429
|
}));
|
|
408
|
-
return taskScreen(response, who, shown, null, 200, undefined, undefined, url.searchParams.get("edit") === "plan", { tab, result, admissible });
|
|
430
|
+
return taskScreen(response, who, shown, null, 200, undefined, undefined, url.searchParams.get("edit") === "plan", { tab, result, admissible, record });
|
|
409
431
|
}
|
|
410
432
|
async function showTaskEvidence(ctx) {
|
|
411
433
|
const { url, who, response, now } = ctx;
|
|
@@ -415,12 +437,15 @@ export function createTasksHandlers(runtime) {
|
|
|
415
437
|
const access = workAccess();
|
|
416
438
|
const family = store.taskFamilyOf(evidence.taskId, access.repos, access.includeUnplaced);
|
|
417
439
|
if (family === null || !visible(family.root.repo))
|
|
418
|
-
return refuse(response, who, 404, "no such task", "/
|
|
440
|
+
return refuse(response, who, 404, "no such task", "/");
|
|
419
441
|
if (evidence.taskId !== family.root.id)
|
|
420
442
|
return redirect(response, `${taskHref(family.root.id)}/evidence${url.search}`);
|
|
443
|
+
const recordHome = TASK_VIEW_REDIRECTS["task.evidence"](url, family.root.id);
|
|
444
|
+
if (recordHome !== null)
|
|
445
|
+
return redirectGet(response, recordHome);
|
|
421
446
|
const pack = evidencePack(store, family.root.id, access, who.name, now, evidenceRoot);
|
|
422
447
|
if (pack === null)
|
|
423
|
-
return refuse(response, who, 404, "no such task", "/
|
|
448
|
+
return refuse(response, who, 404, "no such task", "/");
|
|
424
449
|
if (url.searchParams.get("format") === "json") {
|
|
425
450
|
response.writeHead(200, { "content-type": "application/json; charset=utf-8", "content-disposition": `attachment; filename="evidence-${family.root.id.replace(/[^A-Za-z0-9._-]/g, "_")}.json"`,
|
|
426
451
|
"cache-control": "no-store", "x-content-type-options": "nosniff" });
|
|
@@ -504,14 +529,13 @@ export function createTasksHandlers(runtime) {
|
|
|
504
529
|
const lines = liveWindowLines(window, runLiveCommands(store, found.id), keys);
|
|
505
530
|
return respond(response, 200, "application/json", JSON.stringify({ text: lines.length === 0 ? "" : `${lines.join("\n")}\n`, nextOffset: window.nextOffset, gen: window.gen, inKey: keys.inKey, keyTail: keys.tail ?? "", final }));
|
|
506
531
|
}
|
|
507
|
-
|
|
532
|
+
const resultHome = TASK_VIEW_REDIRECTS["run.page"](url, taskId, found.id);
|
|
533
|
+
if (resultHome !== null && !running && found.role === "builder" && (found.outcome === "built" || found.outcome === "no-change") &&
|
|
508
534
|
completedRowFor(taskId, null)?.runId === found.id) {
|
|
509
|
-
|
|
510
|
-
return redirect(response, `${reviewHref(taskId, found.id)}${tab === "summary" ? "" : `&tab=${tab}`}`);
|
|
535
|
+
return redirect(response, resultHome);
|
|
511
536
|
}
|
|
512
|
-
if (
|
|
513
|
-
|
|
514
|
-
return redirect(response, `${reviewHref(taskId, found.id)}${tab === "summary" ? "" : `&tab=${tab}`}`);
|
|
537
|
+
if (resultHome !== null && !running && (found.role === "builder" || found.role === "scout") && attemptRowFor(taskId, found.id, null) !== null) {
|
|
538
|
+
return redirect(response, resultHome);
|
|
515
539
|
}
|
|
516
540
|
const artifacts = store.artifactsFor(found.id);
|
|
517
541
|
return sendScreen(response, 200, runPage(chromeFor(project, "runs", runListPane(project, found.id)), found, taskId, artifacts, terminalDiffView(artifacts, evidenceRoot), store.notesForRun(found.id), who.via === "cookie" ? who.session.csrf : "", store.liveDiffComments(found.id).filter(isRevisionFeedback), (() => {
|
|
@@ -631,7 +655,7 @@ export function createTasksHandlers(runtime) {
|
|
|
631
655
|
const decision = body.get('decision');
|
|
632
656
|
if (decision !== 'accept' && decision !== 'decline' && decision !== 'cancel')
|
|
633
657
|
return fail(400, 'Choose an explicit decision for this request.');
|
|
634
|
-
if (pending.kind !== 'questions' && decision === 'accept' && !
|
|
658
|
+
if (pending.kind !== 'questions' && decision === 'accept' && !authenticateCredential(who, body.get('password') ?? '').ok)
|
|
635
659
|
return fail(403, 'Enter your password to approve this additional access.');
|
|
636
660
|
const answers = body.has('answers') ? JSON.parse(body.get('answers')) : Object.fromEntries(pending.questions.map(q => [q.id, { answers: [body.get(`question:${q.id}`) ?? ''] }]));
|
|
637
661
|
runtime.coding.answer(id, actor, token, decision, answers);
|
|
@@ -727,7 +751,12 @@ export function createTasksHandlers(runtime) {
|
|
|
727
751
|
}
|
|
728
752
|
if (who.via === "cookie" && body.get("plain") !== "1" && repo !== "" && goal === "" && notThis === "" && touchesGiven.length === 0 && !scout && id === "" && after === ""
|
|
729
753
|
&& (qualityMode === null || qualityMode === "default") && (permissionMode === null || permissionMode === "auto")) {
|
|
730
|
-
|
|
754
|
+
if (firstTaskRouted(store) === null)
|
|
755
|
+
await runtime.localAgentsSettled(FIRST_TASK_DETECT_WAIT_MS);
|
|
756
|
+
const fast = await prepareFastStart(store, { actor: who.name, repo, title: typed.trim(), via: "console", ...(permissionMode === null ? {} : { permissionMode }), password: fastPasswordFacts(who),
|
|
757
|
+
planFirst: body.get("plan-first") === "1" }, now);
|
|
758
|
+
if (fast.eligible && requestContext.getStore()?.terminalAct === true)
|
|
759
|
+
return answerTermsInPlace(response, { preview: fast.preview, digest: fast.digest, terms: fastTermsRows(store, fast.scope, repo) });
|
|
731
760
|
if (fast.eligible)
|
|
732
761
|
return sendScreen(response, 200, fastStartPage(chromeFor(project ?? null, "tasks"), { title: typed.trim(), repo, preview: fast.preview, digest: fast.digest, terms: fastTermsRows(store, fast.scope, repo) }));
|
|
733
762
|
}
|
|
@@ -931,7 +960,7 @@ export function createTasksHandlers(runtime) {
|
|
|
931
960
|
const back = taskHref(act.taskId);
|
|
932
961
|
const ref = store.lookupRef(act.taskId);
|
|
933
962
|
if (ref === null || !visible(ref.repo))
|
|
934
|
-
return refuse(response, who, 404, "no such task", "/
|
|
963
|
+
return refuse(response, who, 404, "no such task", "/");
|
|
935
964
|
const named = (body.get("run") ?? "").trim();
|
|
936
965
|
const run = /^[0-9]{1,15}$/.test(named) ? store.getRun(Number(named)) : null;
|
|
937
966
|
const runTask = run === null ? null : store.externalIdFor(run.taskRef);
|
|
@@ -964,7 +993,7 @@ export function createTasksHandlers(runtime) {
|
|
|
964
993
|
return taskScreen(response, who, act.taskId, "The demo merges nothing.", 403);
|
|
965
994
|
const ref = store.lookupRef(act.taskId);
|
|
966
995
|
if (ref === null || !visible(ref.repo))
|
|
967
|
-
return refuse(response, who, 404, "no such task", "/
|
|
996
|
+
return refuse(response, who, 404, "no such task", "/");
|
|
968
997
|
const named = (body.get("run") ?? "").trim();
|
|
969
998
|
const run = /^[0-9]{1,15}$/.test(named) ? store.getRun(Number(named)) : null;
|
|
970
999
|
const runTask = run === null ? null : store.externalIdFor(run.taskRef);
|
|
@@ -1021,7 +1050,7 @@ export function createTasksHandlers(runtime) {
|
|
|
1021
1050
|
return redirect(response, `/r/${id}`);
|
|
1022
1051
|
}
|
|
1023
1052
|
async function runComment(ctx) {
|
|
1024
|
-
const { url, who, response, now, posted } = ctx;
|
|
1053
|
+
const { url, who, response, now, posted, request: incoming } = ctx;
|
|
1025
1054
|
const diffComment = /^\/r\/([0-9]{1,15})\/comment$/.exec(url.pathname);
|
|
1026
1055
|
if (diffComment === null)
|
|
1027
1056
|
return noPage(who, response);
|
|
@@ -1053,13 +1082,17 @@ export function createTasksHandlers(runtime) {
|
|
|
1053
1082
|
const image = parseFeedbackImage(body.get("image"));
|
|
1054
1083
|
if (image === false)
|
|
1055
1084
|
return refuse(response, who, 400, "Choose a screenshot from this result again. Your draft is unchanged.", back);
|
|
1085
|
+
const typedNote = (body.get("note") ?? "").trim();
|
|
1086
|
+
const sentNote = withContext(body.get("context"), typedNote);
|
|
1056
1087
|
if (body.get("intent") === "revise") {
|
|
1057
1088
|
const result = requestResultChanges(store, evidenceRoot, {
|
|
1058
1089
|
run: id, batch: body.get("batch"), source: body.get("source"), actor: who.name,
|
|
1059
1090
|
repos: admissionList(), includeUnplaced: visible(null), allowMode: who.via === "cookie",
|
|
1060
|
-
origin: who.via === "cookie" ? "person" : "machine",
|
|
1061
|
-
note:
|
|
1091
|
+
origin: who.via === "cookie" ? "person" : "machine", typedWords: who.via === "cookie" ? typedNote : null,
|
|
1092
|
+
note: sentNote, path: body.get("path") ?? "", line: body.get("line") ?? "", request: body.get("request"), image,
|
|
1062
1093
|
}, now);
|
|
1094
|
+
if (answersInPlace(incoming))
|
|
1095
|
+
return result.ok ? answerActInPlace(response, "done", "Sent back. The revision is filed.", 200) : answerActInPlace(response, "refused", result.message, result.status);
|
|
1063
1096
|
if (!result.ok) {
|
|
1064
1097
|
const request = body.get("request") ?? "";
|
|
1065
1098
|
const retryBase = image === null ? back : `/r/${id}?record=1`;
|
|
@@ -1076,7 +1109,7 @@ export function createTasksHandlers(runtime) {
|
|
|
1076
1109
|
if (!proven.ok) {
|
|
1077
1110
|
return refuse(response, who, 409, `the terminal diff no longer verifies (${proven.problem}) — nothing to comment on`, back);
|
|
1078
1111
|
}
|
|
1079
|
-
const note = validateNote(
|
|
1112
|
+
const note = validateNote(sentNote);
|
|
1080
1113
|
if (!note.ok)
|
|
1081
1114
|
return refuse(response, who, 400, note.problem, back);
|
|
1082
1115
|
const rawPath = (body.get("path") ?? "").trim();
|
|
@@ -1095,7 +1128,10 @@ export function createTasksHandlers(runtime) {
|
|
|
1095
1128
|
const imageProblem = feedbackImageProblem(store, evidenceRoot, id, image);
|
|
1096
1129
|
if (imageProblem !== null)
|
|
1097
1130
|
return { problem: imageProblem };
|
|
1098
|
-
|
|
1131
|
+
const inserted = store.addDiffComment({ artifactId: terminal.id, runId: id, path, line, note: note.note, author: who.name, image, ...(sourceKey === undefined ? {} : { sourceKey }) }, now);
|
|
1132
|
+
if (inserted !== null && who.via === "cookie")
|
|
1133
|
+
markTypedByPerson(store, { comment: inserted }, who.name, typedNote, now);
|
|
1134
|
+
return { inserted };
|
|
1099
1135
|
});
|
|
1100
1136
|
if ("problem" in saved)
|
|
1101
1137
|
return refuse(response, who, 409, saved.problem, `/r/${id}?record=1#request-changes`);
|
|
@@ -1167,7 +1203,7 @@ export function createTasksHandlers(runtime) {
|
|
|
1167
1203
|
const asked = requestFollowUpChecks(store, { runId: id, level, actor: who.name }, now);
|
|
1168
1204
|
if (!asked.ok)
|
|
1169
1205
|
return refuse(response, who, 409, asked.message, back);
|
|
1170
|
-
return redirect(response, back.startsWith("/t/") ? back : `${back.split("#")[0]}#follow-ups`);
|
|
1206
|
+
return redirect(response, back.startsWith("/t/") && !/[?&]tab=result(?:[&#]|$)/.test(back) ? back : `${back.split("#")[0]}#follow-ups`);
|
|
1171
1207
|
}
|
|
1172
1208
|
const filed = fileAddTestsTask(store, evidenceRoot, { runId: id, actor: who.name, filedVia: "console", ...(admissionList() === null ? {} : { admittedRepos: admissionList() }) }, now);
|
|
1173
1209
|
if (!filed.ok)
|
|
@@ -1360,10 +1396,10 @@ export function createTasksHandlers(runtime) {
|
|
|
1360
1396
|
function taskMutation(response, who, taskId, verb, posted, now, request = null) {
|
|
1361
1397
|
const ref = store.lookupRef(taskId);
|
|
1362
1398
|
if (ref === null || store.getTask(taskId) === null) {
|
|
1363
|
-
return refuse(response, who, 404, "no such task", "/
|
|
1399
|
+
return refuse(response, who, 404, "no such task", "/");
|
|
1364
1400
|
}
|
|
1365
1401
|
if (!visible(ref.repo)) {
|
|
1366
|
-
return refuse(response, who, 404, "no such task", "/
|
|
1402
|
+
return refuse(response, who, 404, "no such task", "/");
|
|
1367
1403
|
}
|
|
1368
1404
|
switch (verb) {
|
|
1369
1405
|
case "steer": {
|
|
@@ -1384,7 +1420,7 @@ export function createTasksHandlers(runtime) {
|
|
|
1384
1420
|
if (ended === null || ended.taskRef !== ref.id || !/^[A-Za-z0-9-]{8,64}$/.test(keyRaw) || body.has("run") || (afterBack !== null && afterBack !== "task" && afterFlow === null)) {
|
|
1385
1421
|
return taskScreen(response, who, taskId, "that note did not say which agent it came from, so nothing was sent", 400);
|
|
1386
1422
|
}
|
|
1387
|
-
const filed = store.fileSteerNoteForRun(taskId, verifiedAuthor(who.name), body.get("note") ?? "", now, { run: ended.id, key: keyRaw, onward: true });
|
|
1423
|
+
const filed = typedSteer(store, who, () => store.fileSteerNoteForRun(taskId, verifiedAuthor(who.name), body.get("note") ?? "", now, { run: ended.id, key: keyRaw, onward: true }), now, body.get("note"));
|
|
1388
1424
|
if (afterBack !== null) {
|
|
1389
1425
|
if (filed.ok)
|
|
1390
1426
|
return redirect(response, afterFlow !== null ? `/flows/${afterFlow.flow}?card=${afterFlow.card}&sent=${keyRaw}` : `${taskHref(taskId)}?sent=${keyRaw}#steering`);
|
|
@@ -1409,7 +1445,7 @@ export function createTasksHandlers(runtime) {
|
|
|
1409
1445
|
if (capability !== null && capability.send === null) {
|
|
1410
1446
|
return from === "agents" ? redirect(response, `/agents?run=${shown.id}&said=steer-no-notes`) : taskScreen(response, who, taskId, capability.words, 409);
|
|
1411
1447
|
}
|
|
1412
|
-
const bound = store.fileSteerNoteForRun(taskId, verifiedAuthor(who.name), body.get("note") ?? "", now, { run: shown.id, key: keyRaw });
|
|
1448
|
+
const bound = typedSteer(store, who, () => store.fileSteerNoteForRun(taskId, verifiedAuthor(who.name), body.get("note") ?? "", now, { run: shown.id, key: keyRaw }), now, body.get("note"));
|
|
1413
1449
|
if (from === "task") {
|
|
1414
1450
|
if (bound.ok)
|
|
1415
1451
|
return redirect(response, flowBack !== null ? `/flows/${flowBack.flow}?card=${flowBack.card}&sent=${keyRaw}` : `${taskHref(taskId)}?sent=${keyRaw}#steering`);
|
|
@@ -1424,7 +1460,7 @@ export function createTasksHandlers(runtime) {
|
|
|
1424
1460
|
return redirect(response, `/agents?run=${shown.id}&said=steer-invalid`);
|
|
1425
1461
|
return redirect(response, `/agents?run=${shown.id}&said=steer-stale`);
|
|
1426
1462
|
}
|
|
1427
|
-
const filed = store.fileSteerNote(taskId, verifiedAuthor(who.name), body.get("note") ?? "", now);
|
|
1463
|
+
const filed = typedSteer(store, who, () => store.fileSteerNote(taskId, verifiedAuthor(who.name), body.get("note") ?? "", now), now, body.get("note"));
|
|
1428
1464
|
if (!filed.ok) {
|
|
1429
1465
|
const said = filed.reason === "task-finished"
|
|
1430
1466
|
? "this task is finished — a note has no next attempt to reach"
|
|
@@ -1448,7 +1484,7 @@ export function createTasksHandlers(runtime) {
|
|
|
1448
1484
|
if (asked === null || asked.taskRef !== ref.id)
|
|
1449
1485
|
return taskScreen(response, who, taskId, "that question is not on this task", 404);
|
|
1450
1486
|
const answered = answerAgentQuestion(store, { question: id, answer: body.get("answer") ?? "", author: who.name, at: now,
|
|
1451
|
-
file: (task, note) => store.fileSteerNote(task, verifiedAuthor(who.name), note, now) });
|
|
1487
|
+
file: (task, note) => typedSteer(store, who, () => store.fileSteerNote(task, verifiedAuthor(who.name), note, now), now, body.get("answer"), asked.question) });
|
|
1452
1488
|
const said = answered.ok ? "replied" : answered.reason === "invalid-answer" || answered.reason === "not-saved" ? "reply-invalid" : answered.reason === "closed" ? "reply-closed" : "reply-stale";
|
|
1453
1489
|
return redirect(response, `/agents?run=${asked.run}&said=${said}`);
|
|
1454
1490
|
}
|
|
@@ -1582,7 +1618,8 @@ export function createTasksHandlers(runtime) {
|
|
|
1582
1618
|
}
|
|
1583
1619
|
case "requeue": {
|
|
1584
1620
|
const body = readForm(posted, CONSOLE_FORMS.taskRequeue);
|
|
1585
|
-
const
|
|
1621
|
+
const typedNote = (body.get("note") ?? "").trim();
|
|
1622
|
+
const note = withContext(body.get("context"), typedNote);
|
|
1586
1623
|
if (note !== "" && who.via !== "cookie")
|
|
1587
1624
|
return refuse(response, who, 403, "steering is a browser session's act");
|
|
1588
1625
|
if (note !== "" && !validateNote(note).ok)
|
|
@@ -1601,7 +1638,7 @@ export function createTasksHandlers(runtime) {
|
|
|
1601
1638
|
}
|
|
1602
1639
|
}
|
|
1603
1640
|
if (note !== "" && !replayed) {
|
|
1604
|
-
const filed = store.fileSteerNote(taskId, verifiedAuthor(who.name), note, now);
|
|
1641
|
+
const filed = typedSteer(store, who, () => store.fileSteerNote(taskId, verifiedAuthor(who.name), note, now), now, typedNote);
|
|
1605
1642
|
if (!filed.ok)
|
|
1606
1643
|
return taskScreen(response, who, taskId, "Retried. The note wasn't saved; add it under Steering.", 409);
|
|
1607
1644
|
}
|
|
@@ -1953,8 +1990,11 @@ export function createTasksHandlers(runtime) {
|
|
|
1953
1990
|
const scopeRow = store.getScope(taskId);
|
|
1954
1991
|
if (scopeRow === null)
|
|
1955
1992
|
return approvalProblem("refused", "this task has no scope to approve", 409);
|
|
1956
|
-
const
|
|
1957
|
-
|
|
1993
|
+
const formDigestNow = () => {
|
|
1994
|
+
const live = store.getScope(taskId);
|
|
1995
|
+
return live === null ? null : approvalFormDigest(live.digest, planViewOf(ref.id)?.sha256 ?? null, approvalSummaryFor(store, taskId, now)?.key ?? null);
|
|
1996
|
+
};
|
|
1997
|
+
const expectedDigest = formDigestNow();
|
|
1958
1998
|
if (digest !== expectedDigest) {
|
|
1959
1999
|
return approvalProblem("refused", "the scope or plan changed while this form was open — read the latest version and approve again", 409);
|
|
1960
2000
|
}
|
|
@@ -1964,7 +2004,7 @@ export function createTasksHandlers(runtime) {
|
|
|
1964
2004
|
return approvalProblem("refused", `approval is blocked: ${view.problem}`, 409);
|
|
1965
2005
|
}
|
|
1966
2006
|
}
|
|
1967
|
-
const approved = spendingOnlyOnSuccess(() => withFreshness("approve-standard", () => approveScope(store, taskId, who.name, now, scopeRow.digest, token)), result => !result.ok && !(result.reason === "second-approver" && !result.already));
|
|
2007
|
+
const approved = spendingOnlyOnSuccess(() => withFreshness("approve-standard", () => store.transact(() => formDigestNow() !== digest ? { ok: false, reason: "changed" } : approveScope(store, taskId, who.name, now, scopeRow.digest, token))), result => !result.ok && !(result.reason === "second-approver" && !result.already));
|
|
1968
2008
|
if (!approved.ok) {
|
|
1969
2009
|
if (approved.reason === "second-approver")
|
|
1970
2010
|
return approvalProblem("vote", gateWords({ verdict: "vote", have: approved.have, need: 2, already: approved.already }), 200);
|
|
@@ -2011,7 +2051,7 @@ export function createTasksHandlers(runtime) {
|
|
|
2011
2051
|
}
|
|
2012
2052
|
if (note === null && store.getTask(taskId)?.state === "failed") {
|
|
2013
2053
|
const back = body.get("return") === null ? null : safeReturn(body.get("return"));
|
|
2014
|
-
if (back !== null && back.startsWith("/review?"))
|
|
2054
|
+
if (back !== null && (back.startsWith("/review?") || /^\/t\/[^/?#]+\?(?:[^#]*&)?tab=result(?:[&#]|$)/.test(back)))
|
|
2015
2055
|
return redirect(response, withRefusal(back, "reason"));
|
|
2016
2056
|
return taskScreen(response, who, taskId, ACCEPT_ANYWAY_NEEDS_REASON, 400);
|
|
2017
2057
|
}
|
|
@@ -2022,12 +2062,13 @@ export function createTasksHandlers(runtime) {
|
|
|
2022
2062
|
const body = readForm(posted, CONSOLE_FORMS.taskComplete);
|
|
2023
2063
|
const principal = who.via === "cookie" ? leadPrincipal(who) : null;
|
|
2024
2064
|
if (principal === null)
|
|
2025
|
-
return refuse(response, who, 403, "Your access changed. Sign in again.");
|
|
2065
|
+
return answersInPlace(request) ? answerActInPlace(response, "refused", "Your access changed. Sign in again.", 403) : refuse(response, who, 403, "Your access changed. Sign in again.");
|
|
2026
2066
|
const digest = body.get("receipt") ?? "";
|
|
2027
2067
|
const namedRun = body.get("run") ?? "";
|
|
2028
2068
|
const current = assignmentOf(store, taskId, now, { principal: "operator", repos: principal.repos }, evidenceRoot);
|
|
2029
2069
|
if (current === null || current.receipt?.taskId !== taskId || !/^[0-9]{1,15}$/.test(namedRun) || current.receipt.runId !== Number(namedRun)) {
|
|
2030
|
-
|
|
2070
|
+
const changed = "This result changed. Open the current result before marking it complete.";
|
|
2071
|
+
return answersInPlace(request) ? answerActInPlace(response, "refused", changed, 409) : taskScreen(response, who, taskId, changed, 409);
|
|
2031
2072
|
}
|
|
2032
2073
|
if (body.get("accept") === "1") {
|
|
2033
2074
|
const rawNote = (body.get("note") ?? "").trim();
|
|
@@ -2035,13 +2076,16 @@ export function createTasksHandlers(runtime) {
|
|
|
2035
2076
|
if (rawNote !== "") {
|
|
2036
2077
|
const validated = validateNote(rawNote);
|
|
2037
2078
|
if (!validated.ok)
|
|
2038
|
-
return taskScreen(response, who, taskId, validated.problem, 400);
|
|
2079
|
+
return answersInPlace(request) ? answerActInPlace(response, "refused", validated.problem, 400) : taskScreen(response, who, taskId, validated.problem, 400);
|
|
2039
2080
|
note = validated.note;
|
|
2040
2081
|
}
|
|
2041
2082
|
const publish = body.get("publish") === "1";
|
|
2042
2083
|
const finished = acceptAndCompleteAsOperator(store, taskId, { runId: Number(namedRun), receiptDigest: digest, note }, principal, now, evidenceRoot, publish ? accepted => completeAndOpenPullRequest(store, { taskId, digest: accepted, runId: Number(namedRun), who: principal, root: evidenceRoot }, now) : undefined);
|
|
2043
2084
|
if (!finished.ok)
|
|
2044
|
-
return
|
|
2085
|
+
return answersInPlace(request) ? answerActInPlace(response, "refused", finished.message, finished.reason === "needs-reason" ? 400 : 409)
|
|
2086
|
+
: taskScreen(response, who, taskId, finished.message, finished.reason === "needs-reason" ? 400 : 409);
|
|
2087
|
+
if (answersInPlace(request) && !publish)
|
|
2088
|
+
return answerActInPlace(response, "done", "Accepted. The task is complete.", 200);
|
|
2045
2089
|
return redirect(response, publish ? `${taskHref(familyOf(taskId)?.root.id ?? taskId)}#merge` : body.get("return") === null ? reviewHref(taskId, Number(namedRun)) : safeReturn(body.get("return")));
|
|
2046
2090
|
}
|
|
2047
2091
|
if (body.get("publish") === "1") {
|
|
@@ -2052,7 +2096,9 @@ export function createTasksHandlers(runtime) {
|
|
|
2052
2096
|
}
|
|
2053
2097
|
const completed = checkAssignmentAsOperator(store, taskId, digest, principal, now, evidenceRoot);
|
|
2054
2098
|
if (!completed.ok)
|
|
2055
|
-
return taskScreen(response, who, taskId, completed.message, 409);
|
|
2099
|
+
return answersInPlace(request) ? answerActInPlace(response, "refused", completed.message, 409) : taskScreen(response, who, taskId, completed.message, 409);
|
|
2100
|
+
if (answersInPlace(request))
|
|
2101
|
+
return answerActInPlace(response, "done", "Marked complete.", 200);
|
|
2056
2102
|
return redirect(response, body.get("return") === null ? reviewHref(taskId, Number(namedRun)) : safeReturn(body.get("return")));
|
|
2057
2103
|
}
|
|
2058
2104
|
case "retry-review": {
|
|
@@ -2102,7 +2148,10 @@ export function createTasksHandlers(runtime) {
|
|
|
2102
2148
|
const note = (body.get("note") ?? "").trim();
|
|
2103
2149
|
const asked = body.get("mode") === "resume"
|
|
2104
2150
|
? store.requestResume({ taskId, runId: Number(named), by: verifiedAuthor(who.name), via: "web", requestId: body.get("request") ?? "" }, now)
|
|
2105
|
-
: store
|
|
2151
|
+
: typedSteer(store, who, () => {
|
|
2152
|
+
const paused = store.requestPause({ taskId, runId: Number(named), by: verifiedAuthor(who.name), via: "web", requestId: body.get("request") ?? "", ...(note === "" ? {} : { note }) }, now);
|
|
2153
|
+
return paused.ok && !paused.duplicate && paused.note !== null ? { ...paused, id: paused.note } : paused;
|
|
2154
|
+
}, now, note);
|
|
2106
2155
|
if (!asked.ok) {
|
|
2107
2156
|
const words = {
|
|
2108
2157
|
stale: `build #${named} has stopped taking notes — reload to see the current attempt`,
|
|
@@ -2345,6 +2394,7 @@ export function createTasksHandlers(runtime) {
|
|
|
2345
2394
|
reviewRetry: store.reviewRetryStateOf(run.id),
|
|
2346
2395
|
review: reviewFactsFor(run.id),
|
|
2347
2396
|
notes: store.notesForRun(run.id),
|
|
2397
|
+
youSaid: typedNotesFor(store, row.taskId, YOU_SAID_CAP),
|
|
2348
2398
|
};
|
|
2349
2399
|
}
|
|
2350
2400
|
function decisionEvidence(response, decisionId, artifactId) {
|
|
@@ -2482,7 +2532,7 @@ export function createTasksHandlers(runtime) {
|
|
|
2482
2532
|
"board": async (ctx) => retiredRedirect("board", ctx.url, ctx.response),
|
|
2483
2533
|
"review": async (ctx) => ctx.url.searchParams.has("result") ? showReview(ctx) : retiredRedirect("review", ctx.url, ctx.response),
|
|
2484
2534
|
"done": async (ctx) => retiredRedirect("done", ctx.url, ctx.response),
|
|
2485
|
-
"tasks":
|
|
2535
|
+
"tasks": retiredHandler("tasks"),
|
|
2486
2536
|
"queue": async (ctx) => retiredRedirect("queue", ctx.url, ctx.response),
|
|
2487
2537
|
"n.task": showNumberedTask,
|
|
2488
2538
|
"tasks.new": showNewTask,
|
|
@@ -2552,6 +2602,8 @@ export function createTasksHandlers(runtime) {
|
|
|
2552
2602
|
});
|
|
2553
2603
|
function newTaskScreen(ctx, status, problem, draft, text = null) {
|
|
2554
2604
|
const { who, response, project } = ctx;
|
|
2605
|
+
if (problem !== null && refusedInPlace(response, status, problem))
|
|
2606
|
+
return;
|
|
2555
2607
|
const chainable = store
|
|
2556
2608
|
.listTasksScoped(project, undefined, 100, null)
|
|
2557
2609
|
.filter(one => one.state !== "done" && one.state !== "cancelled" && visible(one.repo))
|
|
@@ -2564,7 +2616,7 @@ export function createTasksHandlers(runtime) {
|
|
|
2564
2616
|
const startsOn = draft?.values?.get("repo") ?? project ?? chrome.projects?.[0]?.path ?? null;
|
|
2565
2617
|
const found = startsOn === null ? null : runtime.firstTasks.get(startsOn)?.found ?? null;
|
|
2566
2618
|
const ideas = found ?? (runtime.firstRunStepsNow(ctx.now) !== null && !store.hasAnyWork() ? firstTaskSuggestions({ issues: [], todos: [] }) : []);
|
|
2567
|
-
return sendScreen(response, status, newTaskPage(chrome, project, revision, problem, chainable, store.permissionDefault().mode, store.qualityDefault().mode, chrome.projects ?? [], draft, text, ideas, ctx.url.searchParams.get("from")?.slice(0, 300) ?? null));
|
|
2619
|
+
return sendScreen(response, status, newTaskPage(chrome, project, revision, problem, chainable, store.permissionDefault().mode, store.qualityDefault().mode, chrome.projects ?? [], draft, text, ideas, ctx.url.searchParams.get("from")?.slice(0, 300) ?? null, soloNow(store)));
|
|
2568
2620
|
}
|
|
2569
2621
|
function fastPasswordFacts(who) {
|
|
2570
2622
|
return { passwordless: passwordlessSessionFor(store, who.name), localOwner: who.via === "cookie" && who.authority === "local-owner",
|
|
@@ -2608,7 +2660,7 @@ export function createTasksHandlers(runtime) {
|
|
|
2608
2660
|
return noPage(who, response);
|
|
2609
2661
|
const { taskId } = act;
|
|
2610
2662
|
if (familyInWebReach(store, who, taskId, visible) === null)
|
|
2611
|
-
return refuse(response, who, 403, "That task is outside your access.", "/
|
|
2663
|
+
return refuse(response, who, 403, "That task is outside your access.", "/");
|
|
2612
2664
|
const number = (name) => Number(body.get(name) ?? "");
|
|
2613
2665
|
const back = () => redirect(response, `${taskHref(taskId)}#findings`);
|
|
2614
2666
|
const refused = (message) => taskScreen(response, who, taskId, message, 409);
|
|
@@ -2667,7 +2719,7 @@ export function createTasksHandlers(runtime) {
|
|
|
2667
2719
|
default: return refused("Reload the page and try again.");
|
|
2668
2720
|
}
|
|
2669
2721
|
}
|
|
2670
|
-
return { registrations, runListPane, peekFragment, taskMutation, queueRegionFor, ciFailingFor, completedRowFor, attemptRowFor, resultRowOf, reviewCockpitViewOf, decisionEvidence, runEvidence, sendArtifact, peekGuards, liveRunIds };
|
|
2722
|
+
return { registrations, workListFor, showOrder, runListPane, peekFragment, taskMutation, queueRegionFor, ciFailingFor, completedRowFor, attemptRowFor, resultRowOf, reviewCockpitViewOf, decisionEvidence, runEvidence, sendArtifact, peekGuards, liveRunIds };
|
|
2671
2723
|
}
|
|
2672
2724
|
export function createTidyHandlers(runtime) {
|
|
2673
2725
|
const { store, sendScreen, chromeFor, authenticateApprover, workAccess, bustBadge } = runtime;
|
|
@@ -2694,13 +2746,13 @@ export function createTidyHandlers(runtime) {
|
|
|
2694
2746
|
if (!done.ok)
|
|
2695
2747
|
return back(done.message);
|
|
2696
2748
|
bustBadge();
|
|
2697
|
-
return redirect(response, "
|
|
2749
|
+
return redirect(response, "/?view=archived");
|
|
2698
2750
|
}
|
|
2699
2751
|
const oneTask = (kind) => async (ctx) => {
|
|
2700
2752
|
const { url, who, response, now, posted } = ctx;
|
|
2701
2753
|
const act = matchTaskPath(url.pathname, `/${kind}$`);
|
|
2702
2754
|
if (act === null)
|
|
2703
|
-
return refuse(response, who, 404, "There's no page at this address.", "/
|
|
2755
|
+
return refuse(response, who, 404, "There's no page at this address.", "/");
|
|
2704
2756
|
const body = readForm(posted, kind === "archive" ? CONSOLE_FORMS.taskArchive : CONSOLE_FORMS.taskRestore);
|
|
2705
2757
|
const standing = (refs) => approverStandsNow(store, who.name, familyRepoOf(store, refs));
|
|
2706
2758
|
const done = kind === "archive"
|
|
@@ -2845,3 +2897,21 @@ export function localOwnerRetry(store, taskId, run, digest, now) {
|
|
|
2845
2897
|
const done = retryAsLocalOwner(store, taskId, { run: Number(run), digest }, now);
|
|
2846
2898
|
return done.ok ? { ok: true, replayed: done.replayed } : { ok: false, status: done.reason === "local-owner" || done.reason === "refused" || done.reason === "limit" ? 403 : 409, message: done.message };
|
|
2847
2899
|
}
|
|
2900
|
+
export function answerActInPlace(response, outcome, words, status) {
|
|
2901
|
+
respond(response, status, "application/json; charset=utf-8", JSON.stringify({ outcome, words }));
|
|
2902
|
+
}
|
|
2903
|
+
function typedSteer(store, who, file, now, words, question = null) {
|
|
2904
|
+
return store.transact(() => {
|
|
2905
|
+
const filed = file();
|
|
2906
|
+
if (filed.ok && typeof filed.id === "number" && who.via === "cookie")
|
|
2907
|
+
markTypedByPerson(store, { steer: filed.id }, who.name, words, now, question);
|
|
2908
|
+
return filed;
|
|
2909
|
+
});
|
|
2910
|
+
}
|
|
2911
|
+
export function withContext(context, typed) {
|
|
2912
|
+
return [(context ?? "").trim(), typed.trim()].filter(one => one !== "").join("\n\n");
|
|
2913
|
+
}
|
|
2914
|
+
export const YOU_SAID_CAP = 8;
|
|
2915
|
+
export function answerTermsInPlace(response, offer) {
|
|
2916
|
+
respond(response, 200, "application/json; charset=utf-8", JSON.stringify({ outcome: "terms", preview: offer.preview, digest: offer.digest, terms: offer.terms.map(([label, words]) => ({ label, words })) }));
|
|
2917
|
+
}
|