toolroll 0.9.118 → 0.9.120
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 +63 -0
- package/README.md +22 -22
- package/dist/assignment.js +43 -30
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +32 -31
- package/dist/builder.js +288 -237
- package/dist/central-recovery-stage.js +3 -3
- package/dist/check-failure.js +2 -2
- package/dist/check-levels.js +3 -0
- package/dist/check-report.js +58 -7
- package/dist/cli-help.js +1 -0
- package/dist/codex-limits.js +40 -22
- package/dist/contracts/console-api.js +6 -1
- package/dist/contracts/engine-api.js +1 -0
- package/dist/contracts/release-check.js +7 -4
- package/dist/contracts/release-terms.js +11 -2
- package/dist/contracts/verification-receipt.js +1 -1
- package/dist/deploy-gate.js +7 -1
- package/dist/direct-chat.js +3 -3
- package/dist/easy-start.js +8 -6
- package/dist/engine-reads.js +74 -0
- package/dist/flexible-conversation-schema.js +24 -0
- package/dist/flexible-conversation.js +162 -0
- package/dist/flexible-custody.js +3 -0
- package/dist/flexible-import.js +89 -0
- package/dist/flexible-save.js +128 -0
- package/dist/flexible-session.js +93 -13
- package/dist/flexible-ship.js +3 -3
- package/dist/flexible-thread.js +2 -2
- package/dist/install-mode.js +1 -1
- package/dist/local-checks.js +32 -0
- package/dist/local-landing.js +758 -0
- package/dist/local-owner.js +3 -0
- package/dist/operate.js +165 -26
- package/dist/passwordless.js +1 -1
- package/dist/plan-limits-demand.js +48 -0
- package/dist/project-delete.js +1 -0
- package/dist/rehearsal.js +27 -0
- package/dist/release-adapters.js +170 -2
- package/dist/release-approval.js +11 -8
- package/dist/release-card.js +7 -2
- package/dist/release-carry.js +1 -1
- package/dist/release-cli.js +115 -14
- package/dist/release-main-proof.js +49 -0
- package/dist/release-main.js +110 -0
- package/dist/release-recheck.js +10 -3
- package/dist/release.js +221 -33
- package/dist/reply-shape.js +6 -1
- package/dist/result-actions.js +7 -1
- package/dist/result-follow-ups.js +30 -12
- package/dist/review-context.js +2 -1
- package/dist/serve.js +31 -14
- package/dist/server/direct-chat.js +109 -3
- package/dist/server/engine-api.js +65 -6
- package/dist/server/render-results.js +8 -4
- package/dist/server/render-tasks.js +10 -1
- package/dist/server/route-table.js +15 -1
- package/dist/server/send-back-build.js +4 -0
- package/dist/server/settings.js +33 -7
- package/dist/server/task-views.js +20 -0
- package/dist/server/tasks.js +108 -6
- package/dist/settings-groups-ui.js +3 -3
- package/dist/store.js +29 -4
- package/dist/subscription-usage.js +11 -5
- package/dist/surface.js +11 -2
- package/dist/task-base.js +23 -4
- package/dist/task-outcome-cli.js +10 -1
- 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/verification-evidence.js +20 -7
- package/dist/workspace-ui.js +1 -1
- package/package.json +2 -1
- package/scripts/release-proof.mjs +240 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { keepCheckScreenshots } from "./check-screenshots.js";
|
|
2
2
|
import { CHECK_RECOVERY_HELD, readCheckRecoveryHoldsForRun } from "./check-recovery-hold.js";
|
|
3
3
|
import { widerThan } from "./check-access.js";
|
|
4
|
+
import { localChecksStanding, LocalChecksLapsed } from "./local-checks.js";
|
|
4
5
|
import { recheckStanding } from "./check-only-standing.js";
|
|
5
6
|
import { actualCheckAccess, checkoutLaunchOf, checkoutRunner, ranAtLine, widestRan } from "./invoke.js";
|
|
6
7
|
import { mkdtempSync, rmSync } from "node:fs";
|
|
7
8
|
import { tmpdir } from "node:os";
|
|
8
9
|
import { join } from "node:path";
|
|
10
|
+
import { verifyCommandAt } from "./store.js";
|
|
9
11
|
import { refArchived } from "./task-archive.js";
|
|
10
12
|
import { belongsToRelease } from "./release-authority.js";
|
|
11
13
|
import { run as execRun } from "./exec.js";
|
|
@@ -13,7 +15,7 @@ import { hardenedGit } from "./teardown-git.js";
|
|
|
13
15
|
import { approvedCommandShell, SETUP_ENV_ALLOWLIST, SETUP_ENV_DENYLIST } from "./builder.js";
|
|
14
16
|
import { runWithIsolatedDatabase } from "./child-database.js";
|
|
15
17
|
import { boundStreamHeadTail, readVerifiedArtifact, redactSecretLines, scanForSecrets, storeEvidence } from "./evidence.js";
|
|
16
|
-
import { CHECK_LEVEL_WORDS, checkCommandFor, repoClause, repoOfRun, runCheckLevel } from "./check-levels.js";
|
|
18
|
+
import { CHECK_LEVEL_WORDS, checkCommandFor, quickVerifyKey, repoClause, repoOfRun, runCheckLevel } from "./check-levels.js";
|
|
17
19
|
import { fileTaskProposal } from "./proposal.js";
|
|
18
20
|
export const CHECKS_REQUESTED = "checks requested";
|
|
19
21
|
export const CHECKS_STARTED = "checks started";
|
|
@@ -30,8 +32,8 @@ function ledgerFor(store, runId) {
|
|
|
30
32
|
.map(row => ({ id: Number(row["id"]), actor: String(row["actor"]), at: String(row["at"]), outcome: String(row["outcome"]),
|
|
31
33
|
detail: row["detail"] === null ? null : String(row["detail"]), action: String(row["action"]) }));
|
|
32
34
|
}
|
|
33
|
-
export function followUpChecksOf(store, runId, now = new Date(), root) {
|
|
34
|
-
const rows = ledgerFor(store, runId);
|
|
35
|
+
export function followUpChecksOf(store, runId, now = new Date(), root, asOf) {
|
|
36
|
+
const rows = asOf === undefined ? ledgerFor(store, runId) : ledgerFor(store, runId).filter(row => Date.parse(row.at) <= asOf.getTime());
|
|
35
37
|
const receipts = new Map();
|
|
36
38
|
if (root !== undefined) {
|
|
37
39
|
for (const artifact of store.artifactsFor(runId).filter(one => one.kind === "structured-output" && one.capture === FOLLOW_UP_RECEIPT)) {
|
|
@@ -61,7 +63,10 @@ export function followUpChecksOf(store, runId, now = new Date(), root) {
|
|
|
61
63
|
if (repo === null)
|
|
62
64
|
return false;
|
|
63
65
|
try {
|
|
64
|
-
|
|
66
|
+
if (asOf === undefined)
|
|
67
|
+
return checkCommandFor(store, repo, level).command?.digest === digest;
|
|
68
|
+
const then = (level === "quick" ? verifyCommandAt(store, quickVerifyKey(repo), asOf) : null) ?? verifyCommandAt(store, repo, asOf);
|
|
69
|
+
return then?.digest === digest;
|
|
65
70
|
}
|
|
66
71
|
catch {
|
|
67
72
|
return false;
|
|
@@ -72,7 +77,7 @@ export function followUpChecksOf(store, runId, now = new Date(), root) {
|
|
|
72
77
|
const started = rows.find(row => row.action === CHECKS_STARTED && row.outcome === String(request.id)) ?? null;
|
|
73
78
|
const finished = rows.find(row => row.action === CHECKS_FINISHED && row.outcome.startsWith(`${request.id}:`)) ?? null;
|
|
74
79
|
const base = { request: request.id, runId, level: request.outcome, head, digest, actor: request.actor, at: request.at,
|
|
75
|
-
why: why === "pull-request" ? "pull-request" : why === "batch" ? "batch" : why === "recheck" ? "recheck" : "person", exitCode: null, logArtifactId: null, note: null,
|
|
80
|
+
why: why === "pull-request" ? "pull-request" : why === "batch" ? "batch" : why === "recheck" ? "recheck" : why === "local-owner" ? "local-owner" : "person", exitCode: null, logArtifactId: null, note: null,
|
|
76
81
|
...(why === "batch" ? { base: /^[a-f0-9]{40}$/.test(recordedBase) ? recordedBase : null } : {}) };
|
|
77
82
|
if (finished !== null) {
|
|
78
83
|
const status = finished.outcome.slice(String(request.id).length + 1);
|
|
@@ -209,13 +214,22 @@ export async function runFollowUpCheck(store, root, request, deps = {}) {
|
|
|
209
214
|
const held = finish("not-run", "The result's commit changed after checks were asked for.");
|
|
210
215
|
return held ?? followUpChecksOf(store, runId, now(), root).find(one => one.request === request) ?? null;
|
|
211
216
|
}
|
|
212
|
-
const authorized = wanted.why === "recheck" ? recheckStanding(store, { request, runId, head: target.head, digest: wanted.digest })
|
|
213
|
-
|
|
217
|
+
const authorized = wanted.why === "recheck" ? recheckStanding(store, { request, runId, head: target.head, digest: wanted.digest })
|
|
218
|
+
: wanted.why === "local-owner" ? localChecksStanding(store, { by: wanted.actor, taskId: target.taskId }) : null;
|
|
219
|
+
if ((wanted.why === "recheck" || wanted.why === "local-owner") && !authorized?.ok) {
|
|
214
220
|
const held = finish("not-run", authorized?.problem ?? "Its authorization couldn't be read.");
|
|
215
221
|
return held ?? followUpChecksOf(store, runId, now(), root).find(one => one.request === request) ?? null;
|
|
216
222
|
}
|
|
217
|
-
const proveLaunch = () => {
|
|
218
|
-
|
|
223
|
+
const proveLaunch = () => {
|
|
224
|
+
const held = heldNow();
|
|
225
|
+
if (held !== null)
|
|
226
|
+
throw new CheckRecoveryBlocked(held);
|
|
227
|
+
if (wanted.why === "local-owner") {
|
|
228
|
+
const standing = localChecksStanding(store, { by: wanted.actor, taskId: target.taskId });
|
|
229
|
+
if (!standing.ok)
|
|
230
|
+
throw new LocalChecksLapsed(standing.problem);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
219
233
|
const guardedRunner = (file, args, options) => { proveLaunch(); return runner(file, args, options); };
|
|
220
234
|
const git = deps.git ?? hardenedGit((file, args, options) => { proveLaunch(); return execRun(file, args, options); });
|
|
221
235
|
const launched = (inner) => (file, args, options) => {
|
|
@@ -279,9 +293,13 @@ export async function runFollowUpCheck(store, root, request, deps = {}) {
|
|
|
279
293
|
}
|
|
280
294
|
}
|
|
281
295
|
catch (error) {
|
|
282
|
-
if (
|
|
283
|
-
|
|
284
|
-
|
|
296
|
+
if (error instanceof LocalChecksLapsed)
|
|
297
|
+
result = { ran: false, failure: error.message };
|
|
298
|
+
else {
|
|
299
|
+
if (!(error instanceof CheckRecoveryBlocked))
|
|
300
|
+
throw error;
|
|
301
|
+
heldControl = error.control;
|
|
302
|
+
}
|
|
285
303
|
}
|
|
286
304
|
finally {
|
|
287
305
|
if (checkoutCreated)
|
package/dist/review-context.js
CHANGED
|
@@ -5,6 +5,7 @@ import { hasForbiddenControls } from "./decision.js";
|
|
|
5
5
|
import { EVIDENCE_CAPS, isBinaryAssetPath, isImagePath, readVerifiedArtifact, redactSecretLines, scanForSecrets, storeEvidence } from "./evidence.js";
|
|
6
6
|
import { parseProof } from "./proof.js";
|
|
7
7
|
import { noLazyFetch } from "./teardown-git.js";
|
|
8
|
+
import { familyStartOf } from "./task-base.js";
|
|
8
9
|
export const LEGACY_REVIEW_CONTEXT_LIMITS = {
|
|
9
10
|
itemBytes: 48 * 1024,
|
|
10
11
|
aggregateBytes: 192 * 1024,
|
|
@@ -657,7 +658,7 @@ export async function deriveReviewContext(store, git, args, lineage) {
|
|
|
657
658
|
const stat = JSON.parse(statBytes.toString("utf8"));
|
|
658
659
|
if (stat?.filesTruncated === true)
|
|
659
660
|
sourceProblems.push("the source run's diff-stat file list is truncated");
|
|
660
|
-
else if (stat?.schema !== 1 || stat.base !== sourceRun.baseRevision || stat.head !== sourceHead || stat.filesTruncated !== false || !Array.isArray(stat.files) || stat.files.length > 400 || stat.fileCount !== stat.files.length || !stat.files.every(one => one !== null && typeof one.path === "string" && safeContextPath(one.path)) || new Set(stat.files.map(one => one.path)).size !== stat.files.length)
|
|
661
|
+
else if (stat?.schema !== 1 || (stat.base !== sourceRun.baseRevision && stat.base !== familyStartOf(store, sourceRun.taskRef)) || stat.head !== sourceHead || stat.filesTruncated !== false || !Array.isArray(stat.files) || stat.files.length > 400 || stat.fileCount !== stat.files.length || !stat.files.every(one => one !== null && typeof one.path === "string" && safeContextPath(one.path)) || new Set(stat.files.map(one => one.path)).size !== stat.files.length)
|
|
661
662
|
sourceProblems.push("the source run's diff-stat shape, endpoints or path inventory is unsupported");
|
|
662
663
|
else
|
|
663
664
|
sourceDiffPaths = stat.files.map(one => one.path);
|
package/dist/serve.js
CHANGED
|
@@ -64,6 +64,7 @@ import {} from "./tools-ui.js";
|
|
|
64
64
|
import { WORK_INDEX_MAX_LIMIT, workCountsByProject, workIndexPage } from "./work-index.js";
|
|
65
65
|
import { withWorkReads } from "./work-reads.js";
|
|
66
66
|
import { createEngineHandlers } from "./server/engine-api.js";
|
|
67
|
+
import { enterRehearsal } from "./rehearsal.js";
|
|
67
68
|
import { WORKSPACE_MOTION_SCRIPT } from "./workspace-motion.js";
|
|
68
69
|
import { prepareWorkspaceRevision, WorkspaceValidatorCache } from "./workspace-revision.js";
|
|
69
70
|
import { createHash, randomBytes } from "node:crypto";
|
|
@@ -146,6 +147,16 @@ import { loadConsoleUrl } from "./webhooks.js";
|
|
|
146
147
|
import { reviewFactsOf } from "./workspace-ui.js";
|
|
147
148
|
import { WorktreePool } from "./worktree.js";
|
|
148
149
|
export function createDecisionServer(options) {
|
|
150
|
+
const leaveRehearsal = options.rehearsal === true ? enterRehearsal() : null;
|
|
151
|
+
try {
|
|
152
|
+
return buildDecisionServer(options, leaveRehearsal);
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
leaveRehearsal?.();
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function buildDecisionServer(options, leaveRehearsal) {
|
|
149
160
|
const identities = options.identities ?? syncProjectIdentities();
|
|
150
161
|
const { projectFamilyPeek, familiesInView, familyTasksInView, revisionDestination, runIsLive, runIsTaskResult, revisionViewOf, taskViewData, routeViewOf, taskChatFocus, pullRequestTargetOf, failureOf, explainAttempt, taskScreen, armTaskResume, planViewOf, planContractViewOf, revisionDocOf, revisionLedgerOf, resultDetailOf } = createTaskViews({
|
|
151
162
|
get store() { return store; },
|
|
@@ -566,8 +577,12 @@ export function createDecisionServer(options) {
|
|
|
566
577
|
}
|
|
567
578
|
});
|
|
568
579
|
});
|
|
569
|
-
|
|
570
|
-
|
|
580
|
+
if (options.rehearsal !== true) {
|
|
581
|
+
server.once('listening', () => store.telemetry.start());
|
|
582
|
+
server.once('close', () => store.telemetry.stop());
|
|
583
|
+
}
|
|
584
|
+
if (leaveRehearsal !== null)
|
|
585
|
+
server.once('close', leaveRehearsal);
|
|
571
586
|
const publicOrigin = (() => {
|
|
572
587
|
if (options.publicUrl === undefined)
|
|
573
588
|
return null;
|
|
@@ -598,7 +613,8 @@ export function createDecisionServer(options) {
|
|
|
598
613
|
const flushBudget = () => { try {
|
|
599
614
|
requestBudget.flush();
|
|
600
615
|
}
|
|
601
|
-
catch { }
|
|
616
|
+
catch { } if (options.rehearsal !== true)
|
|
617
|
+
engineHandlers.upkeep(); };
|
|
602
618
|
const timer = setInterval(flushBudget, REQUEST_BUDGET_FLUSH_MS);
|
|
603
619
|
timer.unref?.();
|
|
604
620
|
server.on("close", () => { clearInterval(timer); flushBudget(); });
|
|
@@ -1708,19 +1724,20 @@ export function createDecisionServer(options) {
|
|
|
1708
1724
|
}
|
|
1709
1725
|
let leadMaintenance = null;
|
|
1710
1726
|
let leadClosing = false;
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1727
|
+
if (options.rehearsal !== true)
|
|
1728
|
+
server.once('listening', () => consoleFolders(options, identities, () => {
|
|
1729
|
+
team.start();
|
|
1730
|
+
personalQueue.start();
|
|
1731
|
+
leadMaintenance = startMaintenance({ intervalMs: 5_000, shouldStop: () => leadClosing,
|
|
1732
|
+
run: () => runLeadFollowPass({ store, repos: managedRepos, evidenceRoot, clock,
|
|
1733
|
+
provider: () => { const enabled = chatEnablement(); return enabled.ok ? { config: enabled.config, key: enabled.key } : null; },
|
|
1734
|
+
fetcher: chatFetcher, ...(options.subscriptionChatRunner ? { subscriptionRunner: options.subscriptionChatRunner } : {}) }),
|
|
1735
|
+
onError: error => recordLeadFollowFailure(store, error, clock()),
|
|
1736
|
+
});
|
|
1737
|
+
}));
|
|
1721
1738
|
let backgroundChecks = null;
|
|
1722
1739
|
let agentsCheckedAt = 0;
|
|
1723
|
-
if (options.backgroundChecks === true)
|
|
1740
|
+
if (options.backgroundChecks === true && options.rehearsal !== true)
|
|
1724
1741
|
server.once('listening', () => {
|
|
1725
1742
|
try {
|
|
1726
1743
|
secretFolder();
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
1
2
|
import { dirname, join } from "node:path";
|
|
3
|
+
import { inRehearsal } from "../rehearsal.js";
|
|
2
4
|
import { tmpdir } from "node:os";
|
|
3
5
|
import { checkEngineResponse, ENGINE_API_VERSION, } from "../contracts/engine-api.js";
|
|
4
6
|
import { DirectChatHost, directChatPostureOf, importLegacyDirectChatJson, isDirectChatProvider, } from "../direct-chat.js";
|
|
@@ -10,7 +12,10 @@ import { backgroundInstalled } from "../laptop-background.js";
|
|
|
10
12
|
import { localOwnerStandsNow } from "../local-owner.js";
|
|
11
13
|
import { projectName, rowVisible } from "../project.js";
|
|
12
14
|
import { handlersOf } from "./handler-registry.js";
|
|
13
|
-
import { respond } from "./http.js";
|
|
15
|
+
import { redirect, respond } from "./http.js";
|
|
16
|
+
import { html, postForm } from "../html.js";
|
|
17
|
+
import { screen } from "./chrome.js";
|
|
18
|
+
import { btn, field, textarea } from "./kit.js";
|
|
14
19
|
import { rereadBrowser } from "./live.js";
|
|
15
20
|
const THREAD_PATH = /^\/engine\/direct-chats\/([a-f0-9]{32})(?:\/(messages|stop|model|delete|attachments|apply-main-edits|repair|ship-preview|ship|ship-cancel))?$/;
|
|
16
21
|
const ARTIFACT_PATH = /^\/engine\/direct-chats\/([a-f0-9]{32})\/artifacts\/([a-f0-9]{32})$/;
|
|
@@ -27,7 +32,8 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
27
32
|
deps.bus.publish({ revision: `dc:${note.threadId}:${Date.now()}` });
|
|
28
33
|
},
|
|
29
34
|
});
|
|
30
|
-
|
|
35
|
+
const rehearsing = inRehearsal();
|
|
36
|
+
if (!rehearsing && !deps.disableLegacyImport && !store.isDemo() && dbFile && dbFile !== ":memory:" && soloNow(store)) {
|
|
31
37
|
try {
|
|
32
38
|
const owners = store.handle
|
|
33
39
|
.prepare("SELECT name, generation FROM approver WHERE revoked_at IS NULL")
|
|
@@ -39,7 +45,8 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
39
45
|
catch {
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
|
-
|
|
48
|
+
if (!rehearsing)
|
|
49
|
+
host.startPolling();
|
|
43
50
|
const json = (ctx, status, value) => respond(ctx.response, status, "application/json", JSON.stringify(value));
|
|
44
51
|
const checked = (ctx, status, name, value) => json(ctx, status, checkEngineResponse(name, value));
|
|
45
52
|
function admit(ctx, act) {
|
|
@@ -558,9 +565,108 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
558
565
|
deps.bus.publish({ revision: `dc:${threadId}:ship-cancel:${Date.now()}` });
|
|
559
566
|
return checked(ctx, 200, "directChatMutated", { ok: true, said: "Auto-merge cancelled." });
|
|
560
567
|
}
|
|
568
|
+
const PAGE_PATH = /^\/direct-chats\/([a-f0-9]{32})(?:\/(ship-review|ship|reply))?$/;
|
|
569
|
+
const STATUS_WORDS = { completed: "Finished", failed: "Failed", interrupted: "Stopped", running: "Working", queued: "Waiting" };
|
|
570
|
+
const DIFF_SHOWN = 200_000;
|
|
571
|
+
function pageRefusal(ctx, status, words) {
|
|
572
|
+
runtime.sendScreen(ctx.response, status, screen("Direct Chats", html `<h1>Direct Chats</h1><p class="problem" role="alert">${words}</p><p><a class="k-link" href="/direct-chats">All Direct Chats</a></p>`, { chrome: runtime.chromeFor(null, "tasks") }));
|
|
573
|
+
}
|
|
574
|
+
async function pageList(ctx) {
|
|
575
|
+
const gate = admit(ctx, null);
|
|
576
|
+
if (!gate.ok)
|
|
577
|
+
return pageRefusal(ctx, gate.status, gate.error);
|
|
578
|
+
const threads = host.listThreads(gate.who.name, null).filter(t => canReachThread(gate.who.name, t));
|
|
579
|
+
const rows = threads.map(t => html `<li class="k-row" data-direct-chat="${t.id}"><a class="k-link" href="/direct-chats/${t.id}"><b>${t.title || "Direct Chat"}</b></a> <span class="k-note">${t.project} · ${t.provider}${t.running ? " · Working" : t.lastStatus === null ? "" : ` · ${STATUS_WORDS[t.lastStatus] ?? t.lastStatus}`}${t.changedFilesCount > 0 ? ` · ${t.changedFilesCount} ${t.changedFilesCount === 1 ? "file" : "files"} changed` : ""}</span></li>`);
|
|
580
|
+
const body = threads.length === 0
|
|
581
|
+
? html `<h1>Direct Chats</h1><p>No Direct Chats yet. Ask the lead in Chat to start one in a project.</p>`
|
|
582
|
+
: html `<h1>Direct Chats</h1><ul class="k-list" data-direct-chats>${rows}</ul>`;
|
|
583
|
+
return runtime.sendScreen(ctx.response, 200, screen("Direct Chats", body, { chrome: runtime.chromeFor(null, "tasks") }));
|
|
584
|
+
}
|
|
585
|
+
async function pageDetail(ctx) {
|
|
586
|
+
const gate = admit(ctx, null);
|
|
587
|
+
if (!gate.ok)
|
|
588
|
+
return pageRefusal(ctx, gate.status, gate.error);
|
|
589
|
+
const threadId = PAGE_PATH.exec(ctx.url.pathname)?.[1] ?? "";
|
|
590
|
+
const found = host.getThread(gate.who.name, threadId);
|
|
591
|
+
if (found === null || !canReachThread(gate.who.name, found.thread))
|
|
592
|
+
return pageRefusal(ctx, 404, "That Direct Chat isn't here.");
|
|
593
|
+
const { thread, turns, diff, running } = found;
|
|
594
|
+
const turnHtml = turns.map(turn => html `<section class="card" data-turn="${turn.id}"><p><b>You</b> · <span class="k-note">${STATUS_WORDS[turn.status] ?? turn.status}</span></p><p class="pre-wrap">${turn.userPrompt}</p>${turn.assistantText.trim() === "" ? "" : html `<p><b>${thread.provider === "claude" ? "Claude" : thread.provider === "codex" ? "Codex" : "Gemini"}</b></p><p class="pre-wrap">${turn.assistantText}</p>`}${turn.errorText === null ? "" : html `<p class="problem">${turn.errorText}</p>`}</section>`);
|
|
595
|
+
const shownDiff = diff.diffText.length > DIFF_SHOWN ? `${diff.diffText.slice(0, DIFF_SHOWN)}\n… (shortened)` : diff.diffText;
|
|
596
|
+
const changes = diff.changedFiles.length === 0 ? html `<p class="k-note">No changes in its copy of the project.</p>`
|
|
597
|
+
: html `<p class="k-note">${diff.changedFiles.length} ${diff.changedFiles.length === 1 ? "file" : "files"} changed in its own copy of the project, as of its last turn${running ? " (it's still working)" : ""}.</p><ul>${diff.changedFiles.map(file => html `<li class="k-mono">${file}</li>`)}</ul>${shownDiff === "" ? "" : html `<details><summary>The changes</summary><pre class="k-mono" data-direct-chat-diff>${shownDiff}</pre></details>`}`;
|
|
598
|
+
const ships = listDirectChatShips(store, thread.id);
|
|
599
|
+
const shipped = ships.length === 0 ? "" : html `<ul>${ships.map(one => html `<li>${one.mode === "keep-branch" ? "Saved as branch" : "Shipped"} <span class="k-mono">${one.branch}</span> · ${one.state}${one.taskId === null ? "" : html ` · <a class="k-link" href="/t/${encodeURIComponent(one.taskId)}">Open task</a>`}</li>`)}</ul>`;
|
|
600
|
+
const shipAct = running || diff.changedFiles.length === 0 ? "" : postForm(`/direct-chats/${thread.id}/ship-review`, btn("Review Ship", { variant: "primary", type: "submit" }));
|
|
601
|
+
const reply = thread.isLegacy ? html `<p class="k-note" data-direct-chat-read-only>Imported from an earlier version: read only. Start a new Direct Chat to go on.</p>`
|
|
602
|
+
: running ? html `<p class="k-note">It's working on your last message. Reply when it finishes.</p>`
|
|
603
|
+
: postForm(`/direct-chats/${thread.id}/reply`, html `${field({ id: "direct-chat-reply", label: "Reply", control: textarea({ id: "direct-chat-reply", name: "prompt", rows: 3, attrs: { required: true, maxlength: "20000" } }) })}${btn("Send", { variant: "primary", type: "submit" })}`, { hidden: { request: randomBytes(16).toString("hex") } });
|
|
604
|
+
const body = html `<h1>${thread.title || "Direct Chat"}</h1><p class="k-note">${thread.project} · ${thread.provider}${thread.modelId ? ` · ${thread.modelId}` : ""}${running ? " · Working" : ""}</p>${turnHtml}${reply}<h2>Changes</h2>${changes}<h2>Ship</h2>${shipped}${shipAct === "" && ships.length === 0 ? html `<p class="k-note">${running ? "Ship opens when it finishes." : "Nothing to ship yet."}</p>` : shipAct}<p><a class="k-link" href="/direct-chats">All Direct Chats</a></p>`;
|
|
605
|
+
return runtime.sendScreen(ctx.response, 200, screen(thread.title || "Direct Chat", body, { chrome: runtime.chromeFor(thread.repo, "tasks") }));
|
|
606
|
+
}
|
|
607
|
+
async function pageReply(ctx) {
|
|
608
|
+
const gate = admit(ctx, "direct-chat-send");
|
|
609
|
+
if (!gate.ok)
|
|
610
|
+
return pageRefusal(ctx, gate.status, gate.error);
|
|
611
|
+
const threadId = PAGE_PATH.exec(ctx.url.pathname)?.[1] ?? "";
|
|
612
|
+
const thread = host.getThreadRecord(gate.who.name, threadId);
|
|
613
|
+
if (thread === null || !canReachThread(gate.who.name, thread))
|
|
614
|
+
return pageRefusal(ctx, 404, "That Direct Chat isn't here.");
|
|
615
|
+
const prompt = ctx.posted.get("prompt") ?? "";
|
|
616
|
+
if (prompt.trim() === "")
|
|
617
|
+
return pageRefusal(ctx, 400, "Write a reply first. Nothing was sent.");
|
|
618
|
+
const res = await host.sendMessage({ owner: gate.who.name, threadId, requestId: ctx.posted.get("request") ?? "", prompt });
|
|
619
|
+
if (!res.ok)
|
|
620
|
+
return pageRefusal(ctx, res.status, res.error);
|
|
621
|
+
return redirect(ctx.response, `/direct-chats/${threadId}`);
|
|
622
|
+
}
|
|
623
|
+
async function pageShipReview(ctx) {
|
|
624
|
+
const gate = admit(ctx, "read");
|
|
625
|
+
if (!gate.ok)
|
|
626
|
+
return pageRefusal(ctx, gate.status, gate.error);
|
|
627
|
+
const threadId = PAGE_PATH.exec(ctx.url.pathname)?.[1] ?? "";
|
|
628
|
+
const thread = host.getThreadRecord(gate.who.name, threadId);
|
|
629
|
+
if (thread === null || !canReachThread(gate.who.name, thread))
|
|
630
|
+
return pageRefusal(ctx, 404, "That Direct Chat isn't here.");
|
|
631
|
+
const res = previewDirectChatShip(store, { stateRoot: host.stateRoot, owner: gate.who.name, threadId, mode: undefined, title: undefined, goal: undefined });
|
|
632
|
+
if (!res.ok)
|
|
633
|
+
return pageRefusal(ctx, res.status, res.error);
|
|
634
|
+
const preview = res.preview;
|
|
635
|
+
const local = gate.who.authority === "local-owner";
|
|
636
|
+
const facts = html `<ul><li>${preview.mode === "keep-branch" ? "Saved as branch" : "Shipped from branch"} <span class="k-mono">${preview.branch}</span></li><li>${preview.changedFiles.length} ${preview.changedFiles.length === 1 ? "file" : "files"}: ${preview.changedFiles.slice(0, 20).join(", ")}${preview.changedFiles.length > 20 ? "…" : ""}</li><li>${preview.checkCommand === null ? "No check command" : html `Check: <span class="k-mono">${preview.checkCommand}</span>`}</li><li>${preview.mergeSummary}</li>${preview.autoMergeReason === null ? "" : html `<li>${preview.autoMergeReason}</li>`}</ul>`;
|
|
637
|
+
const form = postForm(`/direct-chats/${threadId}/ship`, html `${local ? "" : html `<label>Password<input type="password" name="password" autocomplete="current-password" required></label>`}${btn(preview.mode === "keep-branch" ? "Save the branch" : "Ship it", { variant: "primary", type: "submit" })} ${btn("Cancel", { variant: "ghost", href: `/direct-chats/${threadId}` })}`, { hidden: { mode: preview.mode, termsDigest: preview.termsDigest, title: preview.title, goal: preview.goal } });
|
|
638
|
+
return runtime.sendScreen(ctx.response, 200, screen("Ship", html `<h1>Ship ${preview.title}</h1>${facts}${form}`, { chrome: runtime.chromeFor(thread.repo, "tasks") }));
|
|
639
|
+
}
|
|
640
|
+
async function pageShip(ctx) {
|
|
641
|
+
const gate = admit(ctx, "direct-chat-ship");
|
|
642
|
+
if (!gate.ok)
|
|
643
|
+
return pageRefusal(ctx, gate.status, gate.error);
|
|
644
|
+
const threadId = PAGE_PATH.exec(ctx.url.pathname)?.[1] ?? "";
|
|
645
|
+
const thread = host.getThreadRecord(gate.who.name, threadId);
|
|
646
|
+
if (thread === null || !canReachThread(gate.who.name, thread))
|
|
647
|
+
return pageRefusal(ctx, 404, "That Direct Chat isn't here.");
|
|
648
|
+
const mode = ctx.posted.get("mode") ?? "";
|
|
649
|
+
const termsDigest = ctx.posted.get("termsDigest") ?? "";
|
|
650
|
+
if ((mode !== "ship" && mode !== "keep-branch") || !HEX32.test(termsDigest))
|
|
651
|
+
return pageRefusal(ctx, 400, "That Ship isn't the one on screen. Review it again.");
|
|
652
|
+
const password = ctx.posted.get("password") ?? undefined;
|
|
653
|
+
const localOwner = gate.who.authority === "local-owner" && gate.who.session.localGeneration !== null ? { localGeneration: gate.who.session.localGeneration } : null;
|
|
654
|
+
const res = executeDirectChatShip(store, { stateRoot: host.stateRoot, owner: gate.who.name, threadId, mode, termsDigest,
|
|
655
|
+
title: ctx.posted.get("title") ?? undefined, goal: ctx.posted.get("goal") ?? undefined, password, localOwner });
|
|
656
|
+
if (!res.ok)
|
|
657
|
+
return pageRefusal(ctx, res.status, res.error);
|
|
658
|
+
host.refreshDiffCache(thread);
|
|
659
|
+
deps.bus.publish({ revision: `dc:${threadId}:ship:${Date.now()}` });
|
|
660
|
+
return redirect(ctx.response, `/direct-chats/${threadId}`);
|
|
661
|
+
}
|
|
561
662
|
return {
|
|
562
663
|
host,
|
|
563
664
|
registrations: handlersOf("tasks", {
|
|
665
|
+
"direct-chat.page-list": pageList,
|
|
666
|
+
"direct-chat.page": pageDetail,
|
|
667
|
+
"direct-chat.page-ship-review": pageShipReview,
|
|
668
|
+
"direct-chat.page-ship": pageShip,
|
|
669
|
+
"direct-chat.page-reply": pageReply,
|
|
564
670
|
"direct-chat.list": list,
|
|
565
671
|
"direct-chat.detail": detail,
|
|
566
672
|
"direct-chat.start": start,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { inRehearsal } from "../rehearsal.js";
|
|
1
2
|
import { homedir } from "node:os";
|
|
2
3
|
import { randomBytes } from "node:crypto";
|
|
3
4
|
import { boardRunOf } from "../agent-board.js";
|
|
@@ -9,7 +10,8 @@ import { flexibleAvailable } from "../flexible-available.js";
|
|
|
9
10
|
import { laptopShipProblem } from "../flexible-laptop.js";
|
|
10
11
|
import { threadsStatusNote, tidyFlexibleSignIns } from "../flexible-sign-in.js";
|
|
11
12
|
import { FLEXIBLE_UNAVAILABLE } from "../flexible.js";
|
|
12
|
-
import {
|
|
13
|
+
import { saveFlexibleBranch } from "../flexible-save.js";
|
|
14
|
+
import { admitFlexibleThreadOwner, answerFlexibleRequest, cancelFlexibleThreadShip, closeFlexibleSessions, closeFlexibleThread, continueFlexibleThread, flexibleThreadShipTerms, latestFlexibleShip, sendBackFlexibleThread, shipFlexibleThread, tidyEndedFlexibleThreads, flexibleThreadChangeOf, flexibleThreadEdited, flexibleThreadLiveOf, flexibleThreadsOf, FLEXIBLE_WAIT_MS, flexibleThreadsExist, flexibleWorkOpen, openFlexibleSessions, recoverFlexibleHolders, startFlexibleThread, settleFlexibleStops, tickFlexibleSessions, waitFlexibleThreadChange, flexibleThreadChanges, flexibleThreadTipOf } from "../flexible-session.js";
|
|
13
15
|
import { createFlexibleLauncher } from "../flexible-launcher.js";
|
|
14
16
|
import { FLEXIBLE_NEXT_WORDS, flexibleReadiness, flexibleStartCard } from "../flexible-start.js";
|
|
15
17
|
import { summaryLines } from "../approval-summary.js";
|
|
@@ -21,7 +23,7 @@ import { packageVersion } from "../monitoring.js";
|
|
|
21
23
|
import { readChildWindow } from "../live-children-read.js";
|
|
22
24
|
import { readMainWindow } from "../live-main-read.js";
|
|
23
25
|
import { runLiveCommands } from "../store.js";
|
|
24
|
-
import { agentsReadOf, resultDiffContextOf, resultDiffFileOf, resultDiffOf, resultRunsOf, stepCardsOf, taskResultOf } from "../engine-reads.js";
|
|
26
|
+
import { agentsReadOf, resultDiffContextOf, resultDiffFileOf, resultDiffOf, resultRunsOf, stepCardsOf, taskResultOf, threadDiffFileOf, threadDiffOf } from "../engine-reads.js";
|
|
25
27
|
import { leadChatOf } from "../engine-chat.js";
|
|
26
28
|
import { remoteAllows } from "../operate-remote.js";
|
|
27
29
|
import { verifyApproverStanding } from "../principal.js";
|
|
@@ -143,6 +145,8 @@ export function createEngineHandlers(runtime) {
|
|
|
143
145
|
let flexible = null;
|
|
144
146
|
let launcher = null;
|
|
145
147
|
const openHost = () => {
|
|
148
|
+
if (inRehearsal())
|
|
149
|
+
return null;
|
|
146
150
|
if (flexible !== null)
|
|
147
151
|
return flexible;
|
|
148
152
|
const opened = openFlexibleSessions(store);
|
|
@@ -206,6 +210,41 @@ export function createEngineHandlers(runtime) {
|
|
|
206
210
|
...(known === read.facts.version ? {} : { thread: read.facts }) };
|
|
207
211
|
return sendChecked(response, 200, "liveSessionWindow", body);
|
|
208
212
|
}
|
|
213
|
+
const changesRead = new Map();
|
|
214
|
+
async function threadChanges(id) {
|
|
215
|
+
const tip = flexibleThreadTipOf(store, id);
|
|
216
|
+
const held = changesRead.get(id);
|
|
217
|
+
if (held !== undefined && tip !== null && held.tip === tip)
|
|
218
|
+
return held.changes;
|
|
219
|
+
const read = await flexibleThreadChanges(store, { thread: id });
|
|
220
|
+
if (changesRead.size >= 32)
|
|
221
|
+
changesRead.delete(changesRead.keys().next().value);
|
|
222
|
+
if (read.tip !== null && read.tip === tip)
|
|
223
|
+
changesRead.set(id, { tip: read.tip, changes: read.changes });
|
|
224
|
+
return read.changes;
|
|
225
|
+
}
|
|
226
|
+
async function liveThreadDiff(ctx) {
|
|
227
|
+
const { url, who, request, response } = ctx;
|
|
228
|
+
if (who.via !== "cookie")
|
|
229
|
+
return refusal(response, 403, "session");
|
|
230
|
+
const params = url.searchParams, fileParam = params.get("file");
|
|
231
|
+
if ([...params.keys()].some(key => key !== "file") || params.getAll("file").length > 1 || (fileParam !== null && !/^(0|[1-9][0-9]{0,5})$/.test(fileParam)))
|
|
232
|
+
return refusal(response, 400, "request");
|
|
233
|
+
const flexible = threadsRead();
|
|
234
|
+
if (flexible === null)
|
|
235
|
+
return refusal(response, 404, "thread");
|
|
236
|
+
const id = url.pathname.slice("/agents/live/thread/".length, -"/diff".length);
|
|
237
|
+
if (ownedThread(request, who, flexible, id) === null)
|
|
238
|
+
return refusal(response, 404, "thread");
|
|
239
|
+
const changes = await threadChanges(id);
|
|
240
|
+
const turn = Number(store.handle.prepare("SELECT max(seq) AS seq FROM thread_turn WHERE thread = ? AND status <> 'withdrawn'").get(id)?.["seq"] ?? 0);
|
|
241
|
+
if (ownedThread(request, who, flexible, id) === null)
|
|
242
|
+
return refusal(response, 404, "thread");
|
|
243
|
+
if (fileParam === null)
|
|
244
|
+
return sendChecked(response, 200, "resultDiff", threadDiffOf(id, turn, changes, { edited: flexibleThreadEdited(flexible, { thread: id }) }));
|
|
245
|
+
const one = threadDiffFileOf(id, turn, changes, Number(fileParam));
|
|
246
|
+
return one === null ? refusal(response, 404, "file") : sendChecked(response, 200, "resultDiffFile", one);
|
|
247
|
+
}
|
|
209
248
|
async function liveThreads(ctx) {
|
|
210
249
|
const { url, who, request, response } = ctx;
|
|
211
250
|
if (who.via !== "cookie")
|
|
@@ -516,7 +555,7 @@ export function createEngineHandlers(runtime) {
|
|
|
516
555
|
if (!sent.ok)
|
|
517
556
|
return acted(response, 409, "refused", sent.message);
|
|
518
557
|
const again = sent.resent === undefined ? "" : `Your earlier send (turn ${sent.resent.seq}) never reached the agent${sent.resent.detail === null ? "" : ` (${sent.resent.detail.slice(0, 200)})`}, so it was sent again. `;
|
|
519
|
-
return json(response, 200, { outcome: "done", words: again + (sent.replayed ? "That reply was already sent." :
|
|
558
|
+
return json(response, 200, { outcome: "done", words: again + (sent.replayed ? "That reply was already sent." : `Sent. Turn ${sent.seq} started; the agent has the conversation so far.`),
|
|
520
559
|
turn: sent.turn });
|
|
521
560
|
}
|
|
522
561
|
const threadClose = (act) => async (ctx) => {
|
|
@@ -618,7 +657,27 @@ export function createEngineHandlers(runtime) {
|
|
|
618
657
|
held, launcher, now: new Date() });
|
|
619
658
|
if (!sent.ok)
|
|
620
659
|
return acted(response, 409, "refused", sent.message);
|
|
621
|
-
return acted(response, 200, "done", `Sent back. Turn ${sent.seq} started
|
|
660
|
+
return acted(response, 200, "done", `Sent back. Turn ${sent.seq} started; the agent has the conversation so far.`);
|
|
661
|
+
}
|
|
662
|
+
async function threadSave(ctx) {
|
|
663
|
+
const { url, who, request, response } = ctx;
|
|
664
|
+
const flexible = threadsRead();
|
|
665
|
+
if (flexible === null)
|
|
666
|
+
return acted(response, 404, "refused", "There's no such thread.");
|
|
667
|
+
if (who.via !== "cookie" || rereadBrowser(runtime, request, who) === null)
|
|
668
|
+
return acted(response, 403, "refused", "Only a person signed in here can save a thread's work.");
|
|
669
|
+
const id = url.pathname.slice("/agents/live/thread/".length, -"/save".length);
|
|
670
|
+
if (ownedThread(request, who, flexible, id) === null)
|
|
671
|
+
return acted(response, 404, "refused", "There's no such thread.");
|
|
672
|
+
if (who.authority === "local-owner" && localActNow(store, "save-thread") === null)
|
|
673
|
+
return acted(response, 403, "refused", "Sign in with your password to do this.");
|
|
674
|
+
const held = sessionHeld(who, flexible, id);
|
|
675
|
+
if (held === null || !held())
|
|
676
|
+
return acted(response, 403, "refused", "Only a person signed in here can save a thread's work.");
|
|
677
|
+
const saved = await saveFlexibleBranch(store, { thread: id, by: { name: who.name, generation: who.session.generation }, now: new Date(), prove: held });
|
|
678
|
+
if (!saved.ok)
|
|
679
|
+
return acted(response, 409, "refused", saved.message);
|
|
680
|
+
return acted(response, 200, "done", `${saved.already ? `Already saved as ${saved.branch}.` : `Saved as ${saved.branch} (commit ${saved.candidate.slice(0, 12)}).`} ${saved.next}`);
|
|
622
681
|
}
|
|
623
682
|
async function leadChat(ctx) {
|
|
624
683
|
const { url, who, request, response, now } = ctx;
|
|
@@ -755,8 +814,8 @@ export function createEngineHandlers(runtime) {
|
|
|
755
814
|
}
|
|
756
815
|
},
|
|
757
816
|
registrations: [
|
|
758
|
-
...handlersOf("pages", { "engine.hello": hello, "engine.agents": agents, "engine.agents-check": agentsCheck, "engine.chat": leadChat, "agents.live.run": liveRun, "agents.live.thread": liveThread, "agents.live.threads": liveThreads,
|
|
759
|
-
"agents.live.thread.answer": threadAnswer, "agents.live.thread.start": threadStart, "agents.live.thread.turn": threadTurn, "agents.live.thread.stop": threadClose("stop"), "agents.live.thread.end": threadClose("end"), "agents.live.thread.ship": threadShip, "agents.live.thread.ship-cancel": threadShipCancel, "agents.live.thread.ship-send-back": threadShipSendBack }),
|
|
817
|
+
...handlersOf("pages", { "engine.hello": hello, "engine.agents": agents, "engine.agents-check": agentsCheck, "engine.chat": leadChat, "agents.live.run": liveRun, "agents.live.thread": liveThread, "agents.live.thread.diff": liveThreadDiff, "agents.live.threads": liveThreads,
|
|
818
|
+
"agents.live.thread.answer": threadAnswer, "agents.live.thread.start": threadStart, "agents.live.thread.turn": threadTurn, "agents.live.thread.stop": threadClose("stop"), "agents.live.thread.end": threadClose("end"), "agents.live.thread.ship": threadShip, "agents.live.thread.ship-cancel": threadShipCancel, "agents.live.thread.ship-send-back": threadShipSendBack, "agents.live.thread.save": threadSave }),
|
|
760
819
|
...handlersOf("tasks", { "task.steps": taskSteps, "task.approval": taskApproval, "task.diff": taskDiff, "task.result": taskResult }),
|
|
761
820
|
...handlersOf("people", {}, { "edge.login-link-json": redeemLink }),
|
|
762
821
|
],
|
|
@@ -580,8 +580,9 @@ export function reviewCockpitDetailParts(view, csrf, noted, canRetryReview, tab,
|
|
|
580
580
|
const hardStop = hardBlockerOf(assignment) ?? view.detail.completeRefusal ?? null;
|
|
581
581
|
const blocked = hardStop ?? cantAcceptYetOf(proof?.verdict ?? null, proof?.reasons ?? [], accepted);
|
|
582
582
|
const youCheck = panel.panel.youCheck;
|
|
583
|
-
const
|
|
584
|
-
|
|
583
|
+
const shared = accepted || assignment?.receipt == null ? null : owedAcceptance(assignment.receipt, assignment.readiness?.blockers ?? []);
|
|
584
|
+
const owed = accepted ? null : youCheck?.accept != null || shared === "person-check" ? { note: null }
|
|
585
|
+
: shared === "exception" || blocked === ACCEPT_NEEDS_REASON ? { note: "Why is this safe to accept?" } : null;
|
|
585
586
|
const complete = hardStop === null && assignment?.state === "ready-to-check" && assignment.receipt !== null && canRetryReview && csrf !== ""
|
|
586
587
|
? { action: `${taskHref(view.taskId)}/complete`, receipt: assignment.receipt.digest, run: run.id, accept: owed, ...(host.kind === "task" ? { returnTo: at() } : {}) } : null;
|
|
587
588
|
if (complete !== null)
|
|
@@ -1331,6 +1332,7 @@ export function resultPanelParts(detail, o) {
|
|
|
1331
1332
|
const humanReview = manualReviewOnly(proof === null ? null : { ...proof, verdict: proof.verdict ?? "" });
|
|
1332
1333
|
const need = needActionOf(current, taskStatus, o.csrf, o.returnTo, {
|
|
1333
1334
|
accepted: proof?.accepted != null, humanReview, run: run.id, action: `${taskHref(detail.taskId)}/accept-proof`, refuted: proof?.verdict === "refuted",
|
|
1335
|
+
exception: current?.receipt == null ? !humanReview : owedAcceptance(current.receipt, current.readiness?.blockers ?? []) === "exception",
|
|
1334
1336
|
rebuildable: proof?.accepted == null && proof?.verdict !== "verified" && proof?.verdict !== "attested" && !(detail.publication !== null && ["pushed", "opened"].includes(detail.publication.state))
|
|
1335
1337
|
});
|
|
1336
1338
|
const directAssessment = proof?.matrix.some(row => row.assessment !== undefined) === true;
|
|
@@ -1606,6 +1608,7 @@ export function resultPanelParts(detail, o) {
|
|
|
1606
1608
|
html `<details class="result-pin"><summary>Attach to a file or line</summary>`,
|
|
1607
1609
|
html `<div class="diff-comment-target"><label>File<input type="text" name="path" placeholder="src/…" aria-label="file" class="mono"></label>`,
|
|
1608
1610
|
html `<label>Line<input type="text" name="line" placeholder="—" aria-label="line" inputmode="numeric"></label></div></details>`,
|
|
1611
|
+
detail.buildNowOnSendBack === true ? html `<label class="meta result-build-now"><input type="checkbox" name="approve" value="1" data-build-now> Build again right away, on the same terms with these notes</label>` : "",
|
|
1609
1612
|
html `<div class="result-feedback-actions"><button type="submit" name="intent" value="revise" data-request-changes>Send back</button><button type="submit" name="intent" value="note" class="quiet" data-save-feedback>Save for later</button></div>`,
|
|
1610
1613
|
]), { attrs: { class: "diff-comment-form", id: "comment-form" }, returnTo: o.returnTo, hidden: { tab: o.tab, request: o.requestToken } })}</details>`);
|
|
1611
1614
|
}
|
|
@@ -1702,9 +1705,10 @@ export function needActionOf(assignment, status, csrf, returnTo, result) {
|
|
|
1702
1705
|
if (action?.code === "retry-task" && status.need.key === "rebuild" && csrf !== "")
|
|
1703
1706
|
return { label: status.need.action.label, ...rebuild };
|
|
1704
1707
|
if (result !== undefined) {
|
|
1708
|
+
const exception = result.refuted === true || (result.exception ?? !result.humanReview);
|
|
1705
1709
|
if ((status.need.key === "review-result" || result.refuted === true) && !result.accepted && csrf !== "")
|
|
1706
|
-
return { label:
|
|
1707
|
-
accept: { action: result.action, run: result.run, returnTo, note:
|
|
1710
|
+
return { label: exception ? "Accept with exception" : "Accept result", href: null, confirm: null,
|
|
1711
|
+
accept: { action: result.action, run: result.run, returnTo, note: exception ? "Why is this safe to accept?" : null } };
|
|
1708
1712
|
const here = (action?.code === "open-result" || action?.code === "inspect-run") && action.target.runId === result.run;
|
|
1709
1713
|
if (here && csrf !== "" && !result.accepted && result.humanReview)
|
|
1710
1714
|
return { label: "Accept result", href: null, confirm: null, accept: { action: result.action, run: result.run, returnTo, note: null } };
|
|
@@ -1285,7 +1285,7 @@ export function taskBodyParts(data) {
|
|
|
1285
1285
|
const humanReview = manualReviewOnly({ verdict: proof.proofVerdict ?? "", reasons: proof.proofReasons, matrix: proof.proofMatrix });
|
|
1286
1286
|
const acceptForm = accepted || data.csrf === ""
|
|
1287
1287
|
? ""
|
|
1288
|
-
: html `<details class="proof-exception"><summary>${humanReview ? "Accept result" : "Accept with exception"}</summary>${postForm(`${taskHref(task.id)}/accept-proof`, html `<input type="text" name="note" maxlength="500" placeholder="${humanReview ? "What did you verify?" : "Why is this safe to accept?"}" aria-label="${humanReview ? "review note" : "exception reason"}" required><button type="submit">${humanReview ? "Accept result" : "Accept with exception"}</button>`, {
|
|
1288
|
+
: html `<details class="proof-exception"><summary>${humanReview ? "Accept result" : "Accept with exception"}</summary>${postForm(`${taskHref(task.id)}/accept-proof`, html `<input type="text" name="note" maxlength="500" placeholder="${humanReview ? "What did you verify?" : "Why is this safe to accept?"}" aria-label="${humanReview ? "review note" : "exception reason"}"${humanReview ? "" : html ` required`}><button type="submit">${humanReview ? "Accept result" : "Accept with exception"}</button>`, {
|
|
1289
1289
|
attrs: { class: "proof-exception-form" },
|
|
1290
1290
|
hidden: { run: proof.runId },
|
|
1291
1291
|
})}</details>`;
|
|
@@ -2150,6 +2150,7 @@ export function taskBodyParts(data) {
|
|
|
2150
2150
|
{ key: "route-change", html: data.routeChange == null ? "" : htmlString(html `<div class="card"><p>${data.routeChange}</p></div>`) },
|
|
2151
2151
|
{ key: "fast-grown", html: data.fastGrown == null || data.csrf === "" ? "" : htmlString(html `<div class="card"><p>${data.fastGrown}</p>${postForm(`${taskHref(task.id)}/keep-grown`, btn("Approve it", { variant: "primary", type: "submit" }))}</div>`) },
|
|
2152
2152
|
{ key: "pull-request", html: fragmentString(pullRequestCard) },
|
|
2153
|
+
{ key: "landing", html: data.landing == null ? "" : htmlString(landingCardHtml(data.landing, data.csrf)) },
|
|
2153
2154
|
{ key: "needs-scope", html: fragmentString(needsScopeCard) },
|
|
2154
2155
|
{ key: "mirror", html: fragmentString(mirrorCard) }, { key: "attempt", html: fragmentString(attemptPanel), ...(liveRunId === null ? {} : { instance: String(liveRunId) }) },
|
|
2155
2156
|
].filter(one => one.html !== ""),
|
|
@@ -2340,3 +2341,11 @@ function agentlessRoute(dispatch, route) {
|
|
|
2340
2341
|
export function cancelPinsOf(state, runs) {
|
|
2341
2342
|
return { state, run: runs.length === 0 ? "none" : String(Math.max(...runs.map(one => one.id))) };
|
|
2342
2343
|
}
|
|
2344
|
+
export function landingCardHtml(landing, csrf) {
|
|
2345
|
+
const act = csrf === "" ? "" : landing.canLand
|
|
2346
|
+
? postForm(`${taskHref(landing.taskId)}/land`, btn("Land it", { type: "submit" }))
|
|
2347
|
+
: landing.canUndo ? postForm(`${taskHref(landing.taskId)}/land`, btn("Undo landing", { variant: "ghost", type: "submit" }), { hidden: { undo: "1" } }) : "";
|
|
2348
|
+
const title = landing.landed !== null && !landing.canLand ? landing.landed : "Not on your branch yet";
|
|
2349
|
+
const meta = landing.canLand ? "You see where it lands before anything moves." : "";
|
|
2350
|
+
return html `<section class="card" id="land" data-landing="${landing.landed === null ? "no" : "yes"}"><strong>${title}</strong>${meta === "" ? "" : html `<p class="meta">${meta}</p>`}${act}</section>`;
|
|
2351
|
+
}
|