toolroll 0.9.117 → 0.9.119
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 +42 -0
- package/README.md +14 -14
- package/dist/agent-fence.js +54 -6
- package/dist/assignment.js +40 -29
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +32 -31
- package/dist/builder.js +295 -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/coding-context.js +16 -2
- package/dist/coding-provider.js +7 -3
- package/dist/coding-workspace.js +5 -5
- package/dist/contracts/console-api.js +4 -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 +72 -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 +51 -0
- package/dist/flexible-session.js +84 -11
- package/dist/install-mode.js +1 -1
- package/dist/invoke.js +18 -6
- package/dist/local-landing.js +500 -0
- package/dist/local-owner.js +1 -0
- package/dist/operate.js +143 -22
- package/dist/passwordless.js +1 -1
- package/dist/planner.js +6 -1
- package/dist/project-delete.js +1 -0
- package/dist/project-skills.js +28 -13
- 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 +8 -4
- package/dist/scout.js +6 -2
- package/dist/serve.js +31 -14
- package/dist/server/direct-chat.js +88 -3
- package/dist/server/engine-api.js +43 -5
- package/dist/server/render-results.js +3 -1
- package/dist/server/render-tasks.js +10 -1
- package/dist/server/route-table.js +9 -0
- package/dist/server/settings.js +31 -7
- package/dist/server/task-views.js +15 -0
- package/dist/server/tasks.js +63 -3
- package/dist/settings-groups-ui.js +2 -2
- package/dist/skills-manifest.js +57 -0
- package/dist/store.js +29 -4
- package/dist/surface.js +9 -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 +17 -6
- package/dist/workspace-ui.js +1 -1
- package/package.json +3 -2
- package/scripts/release-proof.mjs +240 -0
|
@@ -6,6 +6,7 @@ import { actualCheckAccess, checkoutLaunchOf, checkoutRunner, ranAtLine, widestR
|
|
|
6
6
|
import { mkdtempSync, rmSync } from "node:fs";
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
8
|
import { join } from "node:path";
|
|
9
|
+
import { verifyCommandAt } from "./store.js";
|
|
9
10
|
import { refArchived } from "./task-archive.js";
|
|
10
11
|
import { belongsToRelease } from "./release-authority.js";
|
|
11
12
|
import { run as execRun } from "./exec.js";
|
|
@@ -13,7 +14,7 @@ import { hardenedGit } from "./teardown-git.js";
|
|
|
13
14
|
import { approvedCommandShell, SETUP_ENV_ALLOWLIST, SETUP_ENV_DENYLIST } from "./builder.js";
|
|
14
15
|
import { runWithIsolatedDatabase } from "./child-database.js";
|
|
15
16
|
import { boundStreamHeadTail, readVerifiedArtifact, redactSecretLines, scanForSecrets, storeEvidence } from "./evidence.js";
|
|
16
|
-
import { CHECK_LEVEL_WORDS, checkCommandFor, repoClause, repoOfRun, runCheckLevel } from "./check-levels.js";
|
|
17
|
+
import { CHECK_LEVEL_WORDS, checkCommandFor, quickVerifyKey, repoClause, repoOfRun, runCheckLevel } from "./check-levels.js";
|
|
17
18
|
import { fileTaskProposal } from "./proposal.js";
|
|
18
19
|
export const CHECKS_REQUESTED = "checks requested";
|
|
19
20
|
export const CHECKS_STARTED = "checks started";
|
|
@@ -30,8 +31,8 @@ function ledgerFor(store, runId) {
|
|
|
30
31
|
.map(row => ({ id: Number(row["id"]), actor: String(row["actor"]), at: String(row["at"]), outcome: String(row["outcome"]),
|
|
31
32
|
detail: row["detail"] === null ? null : String(row["detail"]), action: String(row["action"]) }));
|
|
32
33
|
}
|
|
33
|
-
export function followUpChecksOf(store, runId, now = new Date(), root) {
|
|
34
|
-
const rows = ledgerFor(store, runId);
|
|
34
|
+
export function followUpChecksOf(store, runId, now = new Date(), root, asOf) {
|
|
35
|
+
const rows = asOf === undefined ? ledgerFor(store, runId) : ledgerFor(store, runId).filter(row => Date.parse(row.at) <= asOf.getTime());
|
|
35
36
|
const receipts = new Map();
|
|
36
37
|
if (root !== undefined) {
|
|
37
38
|
for (const artifact of store.artifactsFor(runId).filter(one => one.kind === "structured-output" && one.capture === FOLLOW_UP_RECEIPT)) {
|
|
@@ -61,7 +62,10 @@ export function followUpChecksOf(store, runId, now = new Date(), root) {
|
|
|
61
62
|
if (repo === null)
|
|
62
63
|
return false;
|
|
63
64
|
try {
|
|
64
|
-
|
|
65
|
+
if (asOf === undefined)
|
|
66
|
+
return checkCommandFor(store, repo, level).command?.digest === digest;
|
|
67
|
+
const then = (level === "quick" ? verifyCommandAt(store, quickVerifyKey(repo), asOf) : null) ?? verifyCommandAt(store, repo, asOf);
|
|
68
|
+
return then?.digest === digest;
|
|
65
69
|
}
|
|
66
70
|
catch {
|
|
67
71
|
return false;
|
package/dist/scout.js
CHANGED
|
@@ -222,8 +222,11 @@ async function scoutWith(store, request, outputDir) {
|
|
|
222
222
|
}
|
|
223
223
|
const clock = request.clock ?? (() => now);
|
|
224
224
|
let projectSkillContext;
|
|
225
|
+
let projectSkills;
|
|
225
226
|
try {
|
|
226
|
-
|
|
227
|
+
let manifest;
|
|
228
|
+
({ text: projectSkillContext, manifest } = skillsContext(store, root, request.runId));
|
|
229
|
+
projectSkills = { root, manifest };
|
|
227
230
|
}
|
|
228
231
|
catch (error) {
|
|
229
232
|
return { ok: false, kind: "failure", reason: "skills-unavailable", message: `Project skills could not be loaded: ${error instanceof Error ? error.message : String(error)}` };
|
|
@@ -306,6 +309,7 @@ async function scoutWith(store, request, outputDir) {
|
|
|
306
309
|
omitEnv: [...AGENT_ENV_DENYLIST, ...(proxy === null ? [] : PROXY_BYPASS_ENV.filter(name => !(name in proxyEnv)))],
|
|
307
310
|
...(proxy === null ? {} : { env: proxyEnv }),
|
|
308
311
|
...(proxy === null ? {} : { network: { via: [portOf(proxy.url), ...(browserServer === null ? [] : [portOf(browserServer.url)])] } }),
|
|
312
|
+
skills: projectSkills,
|
|
309
313
|
...(agent === undefined ? {} : { runner: agent }),
|
|
310
314
|
...(request.onProviderSpawn === undefined ? {} : { onSpawn: request.onProviderSpawn }),
|
|
311
315
|
clock,
|
|
@@ -463,7 +467,7 @@ async function scoutWith(store, request, outputDir) {
|
|
|
463
467
|
skipPermissions: false,
|
|
464
468
|
resumeSession: session,
|
|
465
469
|
...(structured ? { jsonSchema: SCOUT_OUTPUT_JSON_SCHEMA } : {}),
|
|
466
|
-
}, { cwd: worktree, timeoutMs: SHORTEN_TIMEOUT_MS, omitEnv: AGENT_ENV_DENYLIST, ...(agent === undefined ? {} : { runner: agent }), clock });
|
|
470
|
+
}, { cwd: worktree, timeoutMs: SHORTEN_TIMEOUT_MS, omitEnv: AGENT_ENV_DENYLIST, skills: projectSkills, ...(agent === undefined ? {} : { runner: agent }), clock });
|
|
467
471
|
if (spoken.kind === "refused" || spoken.outcome.timedOut || spoken.outcome.code !== 0 || !heartbeat(store, request.leaseId, clock()).ok)
|
|
468
472
|
return null;
|
|
469
473
|
const head = await git(GIT, ["--no-optional-locks", "rev-parse", "HEAD"], { cwd: worktree });
|
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,5 @@
|
|
|
1
1
|
import { dirname, join } from "node:path";
|
|
2
|
+
import { inRehearsal } from "../rehearsal.js";
|
|
2
3
|
import { tmpdir } from "node:os";
|
|
3
4
|
import { checkEngineResponse, ENGINE_API_VERSION, } from "../contracts/engine-api.js";
|
|
4
5
|
import { DirectChatHost, directChatPostureOf, importLegacyDirectChatJson, isDirectChatProvider, } from "../direct-chat.js";
|
|
@@ -10,7 +11,10 @@ import { backgroundInstalled } from "../laptop-background.js";
|
|
|
10
11
|
import { localOwnerStandsNow } from "../local-owner.js";
|
|
11
12
|
import { projectName, rowVisible } from "../project.js";
|
|
12
13
|
import { handlersOf } from "./handler-registry.js";
|
|
13
|
-
import { respond } from "./http.js";
|
|
14
|
+
import { redirect, respond } from "./http.js";
|
|
15
|
+
import { html, postForm } from "../html.js";
|
|
16
|
+
import { screen } from "./chrome.js";
|
|
17
|
+
import { btn } from "./kit.js";
|
|
14
18
|
import { rereadBrowser } from "./live.js";
|
|
15
19
|
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
20
|
const ARTIFACT_PATH = /^\/engine\/direct-chats\/([a-f0-9]{32})\/artifacts\/([a-f0-9]{32})$/;
|
|
@@ -27,7 +31,8 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
27
31
|
deps.bus.publish({ revision: `dc:${note.threadId}:${Date.now()}` });
|
|
28
32
|
},
|
|
29
33
|
});
|
|
30
|
-
|
|
34
|
+
const rehearsing = inRehearsal();
|
|
35
|
+
if (!rehearsing && !deps.disableLegacyImport && !store.isDemo() && dbFile && dbFile !== ":memory:" && soloNow(store)) {
|
|
31
36
|
try {
|
|
32
37
|
const owners = store.handle
|
|
33
38
|
.prepare("SELECT name, generation FROM approver WHERE revoked_at IS NULL")
|
|
@@ -39,7 +44,8 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
39
44
|
catch {
|
|
40
45
|
}
|
|
41
46
|
}
|
|
42
|
-
|
|
47
|
+
if (!rehearsing)
|
|
48
|
+
host.startPolling();
|
|
43
49
|
const json = (ctx, status, value) => respond(ctx.response, status, "application/json", JSON.stringify(value));
|
|
44
50
|
const checked = (ctx, status, name, value) => json(ctx, status, checkEngineResponse(name, value));
|
|
45
51
|
function admit(ctx, act) {
|
|
@@ -558,9 +564,88 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
558
564
|
deps.bus.publish({ revision: `dc:${threadId}:ship-cancel:${Date.now()}` });
|
|
559
565
|
return checked(ctx, 200, "directChatMutated", { ok: true, said: "Auto-merge cancelled." });
|
|
560
566
|
}
|
|
567
|
+
const PAGE_PATH = /^\/direct-chats\/([a-f0-9]{32})(?:\/(ship-review|ship))?$/;
|
|
568
|
+
const STATUS_WORDS = { completed: "Finished", failed: "Failed", interrupted: "Stopped", running: "Working", queued: "Waiting" };
|
|
569
|
+
const DIFF_SHOWN = 200_000;
|
|
570
|
+
function pageRefusal(ctx, status, words) {
|
|
571
|
+
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") }));
|
|
572
|
+
}
|
|
573
|
+
async function pageList(ctx) {
|
|
574
|
+
const gate = admit(ctx, null);
|
|
575
|
+
if (!gate.ok)
|
|
576
|
+
return pageRefusal(ctx, gate.status, gate.error);
|
|
577
|
+
const threads = host.listThreads(gate.who.name, null).filter(t => canReachThread(gate.who.name, t));
|
|
578
|
+
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>`);
|
|
579
|
+
const body = threads.length === 0
|
|
580
|
+
? html `<h1>Direct Chats</h1><p>No Direct Chats yet. Ask the lead in Chat to start one in a project.</p>`
|
|
581
|
+
: html `<h1>Direct Chats</h1><ul class="k-list" data-direct-chats>${rows}</ul>`;
|
|
582
|
+
return runtime.sendScreen(ctx.response, 200, screen("Direct Chats", body, { chrome: runtime.chromeFor(null, "tasks") }));
|
|
583
|
+
}
|
|
584
|
+
async function pageDetail(ctx) {
|
|
585
|
+
const gate = admit(ctx, null);
|
|
586
|
+
if (!gate.ok)
|
|
587
|
+
return pageRefusal(ctx, gate.status, gate.error);
|
|
588
|
+
const threadId = PAGE_PATH.exec(ctx.url.pathname)?.[1] ?? "";
|
|
589
|
+
const found = host.getThread(gate.who.name, threadId);
|
|
590
|
+
if (found === null || !canReachThread(gate.who.name, found.thread))
|
|
591
|
+
return pageRefusal(ctx, 404, "That Direct Chat isn't here.");
|
|
592
|
+
const { thread, turns, diff, running } = found;
|
|
593
|
+
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>`);
|
|
594
|
+
const shownDiff = diff.diffText.length > DIFF_SHOWN ? `${diff.diffText.slice(0, DIFF_SHOWN)}\n… (shortened)` : diff.diffText;
|
|
595
|
+
const changes = diff.changedFiles.length === 0 ? html `<p class="k-note">No changes in its copy of the project.</p>`
|
|
596
|
+
: 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>`}`;
|
|
597
|
+
const ships = listDirectChatShips(store, thread.id);
|
|
598
|
+
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>`;
|
|
599
|
+
const shipAct = running || diff.changedFiles.length === 0 ? "" : postForm(`/direct-chats/${thread.id}/ship-review`, btn("Review Ship", { variant: "primary", type: "submit" }));
|
|
600
|
+
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}<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>`;
|
|
601
|
+
return runtime.sendScreen(ctx.response, 200, screen(thread.title || "Direct Chat", body, { chrome: runtime.chromeFor(thread.repo, "tasks") }));
|
|
602
|
+
}
|
|
603
|
+
async function pageShipReview(ctx) {
|
|
604
|
+
const gate = admit(ctx, "read");
|
|
605
|
+
if (!gate.ok)
|
|
606
|
+
return pageRefusal(ctx, gate.status, gate.error);
|
|
607
|
+
const threadId = PAGE_PATH.exec(ctx.url.pathname)?.[1] ?? "";
|
|
608
|
+
const thread = host.getThreadRecord(gate.who.name, threadId);
|
|
609
|
+
if (thread === null || !canReachThread(gate.who.name, thread))
|
|
610
|
+
return pageRefusal(ctx, 404, "That Direct Chat isn't here.");
|
|
611
|
+
const res = previewDirectChatShip(store, { stateRoot: host.stateRoot, owner: gate.who.name, threadId, mode: undefined, title: undefined, goal: undefined });
|
|
612
|
+
if (!res.ok)
|
|
613
|
+
return pageRefusal(ctx, res.status, res.error);
|
|
614
|
+
const preview = res.preview;
|
|
615
|
+
const local = gate.who.authority === "local-owner";
|
|
616
|
+
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>`;
|
|
617
|
+
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 } });
|
|
618
|
+
return runtime.sendScreen(ctx.response, 200, screen("Ship", html `<h1>Ship ${preview.title}</h1>${facts}${form}`, { chrome: runtime.chromeFor(thread.repo, "tasks") }));
|
|
619
|
+
}
|
|
620
|
+
async function pageShip(ctx) {
|
|
621
|
+
const gate = admit(ctx, "direct-chat-ship");
|
|
622
|
+
if (!gate.ok)
|
|
623
|
+
return pageRefusal(ctx, gate.status, gate.error);
|
|
624
|
+
const threadId = PAGE_PATH.exec(ctx.url.pathname)?.[1] ?? "";
|
|
625
|
+
const thread = host.getThreadRecord(gate.who.name, threadId);
|
|
626
|
+
if (thread === null || !canReachThread(gate.who.name, thread))
|
|
627
|
+
return pageRefusal(ctx, 404, "That Direct Chat isn't here.");
|
|
628
|
+
const mode = ctx.posted.get("mode") ?? "";
|
|
629
|
+
const termsDigest = ctx.posted.get("termsDigest") ?? "";
|
|
630
|
+
if ((mode !== "ship" && mode !== "keep-branch") || !HEX32.test(termsDigest))
|
|
631
|
+
return pageRefusal(ctx, 400, "That Ship isn't the one on screen. Review it again.");
|
|
632
|
+
const password = ctx.posted.get("password") ?? undefined;
|
|
633
|
+
const localOwner = gate.who.authority === "local-owner" && gate.who.session.localGeneration !== null ? { localGeneration: gate.who.session.localGeneration } : null;
|
|
634
|
+
const res = executeDirectChatShip(store, { stateRoot: host.stateRoot, owner: gate.who.name, threadId, mode, termsDigest,
|
|
635
|
+
title: ctx.posted.get("title") ?? undefined, goal: ctx.posted.get("goal") ?? undefined, password, localOwner });
|
|
636
|
+
if (!res.ok)
|
|
637
|
+
return pageRefusal(ctx, res.status, res.error);
|
|
638
|
+
host.refreshDiffCache(thread);
|
|
639
|
+
deps.bus.publish({ revision: `dc:${threadId}:ship:${Date.now()}` });
|
|
640
|
+
return redirect(ctx.response, `/direct-chats/${threadId}`);
|
|
641
|
+
}
|
|
561
642
|
return {
|
|
562
643
|
host,
|
|
563
644
|
registrations: handlersOf("tasks", {
|
|
645
|
+
"direct-chat.page-list": pageList,
|
|
646
|
+
"direct-chat.page": pageDetail,
|
|
647
|
+
"direct-chat.page-ship-review": pageShipReview,
|
|
648
|
+
"direct-chat.page-ship": pageShip,
|
|
564
649
|
"direct-chat.list": list,
|
|
565
650
|
"direct-chat.detail": detail,
|
|
566
651
|
"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,7 @@ 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 { admitFlexibleThreadOwner, answerFlexibleRequest, cancelFlexibleThreadShip, closeFlexibleSessions, closeFlexibleThread, continueFlexibleThread, flexibleThreadShipTerms, latestFlexibleShip, sendBackFlexibleThread, shipFlexibleThread, tidyEndedFlexibleThreads, flexibleThreadChangeOf, flexibleThreadLiveOf, flexibleThreadsOf, FLEXIBLE_WAIT_MS, flexibleThreadsExist, flexibleWorkOpen, openFlexibleSessions, recoverFlexibleHolders, startFlexibleThread, settleFlexibleStops, tickFlexibleSessions, waitFlexibleThreadChange } from "../flexible-session.js";
|
|
13
|
+
import { admitFlexibleThreadOwner, answerFlexibleRequest, cancelFlexibleThreadShip, closeFlexibleSessions, closeFlexibleThread, continueFlexibleThread, flexibleThreadShipTerms, latestFlexibleShip, sendBackFlexibleThread, shipFlexibleThread, tidyEndedFlexibleThreads, flexibleThreadChangeOf, flexibleThreadLiveOf, flexibleThreadsOf, FLEXIBLE_WAIT_MS, flexibleThreadsExist, flexibleWorkOpen, openFlexibleSessions, recoverFlexibleHolders, startFlexibleThread, settleFlexibleStops, tickFlexibleSessions, waitFlexibleThreadChange, flexibleThreadChanges, flexibleThreadTipOf } from "../flexible-session.js";
|
|
13
14
|
import { createFlexibleLauncher } from "../flexible-launcher.js";
|
|
14
15
|
import { FLEXIBLE_NEXT_WORDS, flexibleReadiness, flexibleStartCard } from "../flexible-start.js";
|
|
15
16
|
import { summaryLines } from "../approval-summary.js";
|
|
@@ -21,7 +22,7 @@ import { packageVersion } from "../monitoring.js";
|
|
|
21
22
|
import { readChildWindow } from "../live-children-read.js";
|
|
22
23
|
import { readMainWindow } from "../live-main-read.js";
|
|
23
24
|
import { runLiveCommands } from "../store.js";
|
|
24
|
-
import { agentsReadOf, resultDiffContextOf, resultDiffFileOf, resultDiffOf, resultRunsOf, stepCardsOf, taskResultOf } from "../engine-reads.js";
|
|
25
|
+
import { agentsReadOf, resultDiffContextOf, resultDiffFileOf, resultDiffOf, resultRunsOf, stepCardsOf, taskResultOf, threadDiffFileOf, threadDiffOf } from "../engine-reads.js";
|
|
25
26
|
import { leadChatOf } from "../engine-chat.js";
|
|
26
27
|
import { remoteAllows } from "../operate-remote.js";
|
|
27
28
|
import { verifyApproverStanding } from "../principal.js";
|
|
@@ -143,6 +144,8 @@ export function createEngineHandlers(runtime) {
|
|
|
143
144
|
let flexible = null;
|
|
144
145
|
let launcher = null;
|
|
145
146
|
const openHost = () => {
|
|
147
|
+
if (inRehearsal())
|
|
148
|
+
return null;
|
|
146
149
|
if (flexible !== null)
|
|
147
150
|
return flexible;
|
|
148
151
|
const opened = openFlexibleSessions(store);
|
|
@@ -206,6 +209,41 @@ export function createEngineHandlers(runtime) {
|
|
|
206
209
|
...(known === read.facts.version ? {} : { thread: read.facts }) };
|
|
207
210
|
return sendChecked(response, 200, "liveSessionWindow", body);
|
|
208
211
|
}
|
|
212
|
+
const changesRead = new Map();
|
|
213
|
+
async function threadChanges(id) {
|
|
214
|
+
const tip = flexibleThreadTipOf(store, id);
|
|
215
|
+
const held = changesRead.get(id);
|
|
216
|
+
if (held !== undefined && tip !== null && held.tip === tip)
|
|
217
|
+
return held.changes;
|
|
218
|
+
const read = await flexibleThreadChanges(store, { thread: id });
|
|
219
|
+
if (changesRead.size >= 32)
|
|
220
|
+
changesRead.delete(changesRead.keys().next().value);
|
|
221
|
+
if (read.tip !== null && read.tip === tip)
|
|
222
|
+
changesRead.set(id, { tip: read.tip, changes: read.changes });
|
|
223
|
+
return read.changes;
|
|
224
|
+
}
|
|
225
|
+
async function liveThreadDiff(ctx) {
|
|
226
|
+
const { url, who, request, response } = ctx;
|
|
227
|
+
if (who.via !== "cookie")
|
|
228
|
+
return refusal(response, 403, "session");
|
|
229
|
+
const params = url.searchParams, fileParam = params.get("file");
|
|
230
|
+
if ([...params.keys()].some(key => key !== "file") || params.getAll("file").length > 1 || (fileParam !== null && !/^(0|[1-9][0-9]{0,5})$/.test(fileParam)))
|
|
231
|
+
return refusal(response, 400, "request");
|
|
232
|
+
const flexible = threadsRead();
|
|
233
|
+
if (flexible === null)
|
|
234
|
+
return refusal(response, 404, "thread");
|
|
235
|
+
const id = url.pathname.slice("/agents/live/thread/".length, -"/diff".length);
|
|
236
|
+
if (ownedThread(request, who, flexible, id) === null)
|
|
237
|
+
return refusal(response, 404, "thread");
|
|
238
|
+
const changes = await threadChanges(id);
|
|
239
|
+
const turn = Number(store.handle.prepare("SELECT max(seq) AS seq FROM thread_turn WHERE thread = ? AND status <> 'withdrawn'").get(id)?.["seq"] ?? 0);
|
|
240
|
+
if (ownedThread(request, who, flexible, id) === null)
|
|
241
|
+
return refusal(response, 404, "thread");
|
|
242
|
+
if (fileParam === null)
|
|
243
|
+
return sendChecked(response, 200, "resultDiff", threadDiffOf(id, turn, changes));
|
|
244
|
+
const one = threadDiffFileOf(id, turn, changes, Number(fileParam));
|
|
245
|
+
return one === null ? refusal(response, 404, "file") : sendChecked(response, 200, "resultDiffFile", one);
|
|
246
|
+
}
|
|
209
247
|
async function liveThreads(ctx) {
|
|
210
248
|
const { url, who, request, response } = ctx;
|
|
211
249
|
if (who.via !== "cookie")
|
|
@@ -516,7 +554,7 @@ export function createEngineHandlers(runtime) {
|
|
|
516
554
|
if (!sent.ok)
|
|
517
555
|
return acted(response, 409, "refused", sent.message);
|
|
518
556
|
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." :
|
|
557
|
+
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
558
|
turn: sent.turn });
|
|
521
559
|
}
|
|
522
560
|
const threadClose = (act) => async (ctx) => {
|
|
@@ -618,7 +656,7 @@ export function createEngineHandlers(runtime) {
|
|
|
618
656
|
held, launcher, now: new Date() });
|
|
619
657
|
if (!sent.ok)
|
|
620
658
|
return acted(response, 409, "refused", sent.message);
|
|
621
|
-
return acted(response, 200, "done", `Sent back. Turn ${sent.seq} started
|
|
659
|
+
return acted(response, 200, "done", `Sent back. Turn ${sent.seq} started; the agent has the conversation so far.`);
|
|
622
660
|
}
|
|
623
661
|
async function leadChat(ctx) {
|
|
624
662
|
const { url, who, request, response, now } = ctx;
|
|
@@ -755,7 +793,7 @@ export function createEngineHandlers(runtime) {
|
|
|
755
793
|
}
|
|
756
794
|
},
|
|
757
795
|
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,
|
|
796
|
+
...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,
|
|
759
797
|
"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 }),
|
|
760
798
|
...handlersOf("tasks", { "task.steps": taskSteps, "task.approval": taskApproval, "task.diff": taskDiff, "task.result": taskResult }),
|
|
761
799
|
...handlersOf("people", {}, { "edge.login-link-json": redeemLink }),
|
|
@@ -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 shared = accepted || assignment?.receipt == null ? null : owedAcceptance(assignment.receipt, assignment.readiness?.blockers ?? []);
|
|
583
584
|
const owed = accepted ? null : youCheck?.accept != null ? { note: null } : panel.panel.need?.accept != null ? { note: panel.panel.need.accept.note }
|
|
584
|
-
: blocked === ACCEPT_NEEDS_REASON ? { note: "Why is this safe to accept?" } : null;
|
|
585
|
+
: shared === "person-check" ? { note: null } : 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)
|
|
@@ -1606,6 +1607,7 @@ export function resultPanelParts(detail, o) {
|
|
|
1606
1607
|
html `<details class="result-pin"><summary>Attach to a file or line</summary>`,
|
|
1607
1608
|
html `<div class="diff-comment-target"><label>File<input type="text" name="path" placeholder="src/…" aria-label="file" class="mono"></label>`,
|
|
1608
1609
|
html `<label>Line<input type="text" name="line" placeholder="—" aria-label="line" inputmode="numeric"></label></div></details>`,
|
|
1610
|
+
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
1611
|
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
1612
|
]), { attrs: { class: "diff-comment-form", id: "comment-form" }, returnTo: o.returnTo, hidden: { tab: o.tab, request: o.requestToken } })}</details>`);
|
|
1611
1613
|
}
|
|
@@ -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
|
+
}
|
|
@@ -64,6 +64,7 @@ const LOCAL_POSTS = Object.freeze({
|
|
|
64
64
|
"task.act.resume-arm": "resume-run",
|
|
65
65
|
"task.act.resume": "resume-run",
|
|
66
66
|
"task.act.complete": "complete-task",
|
|
67
|
+
"task.act.land": "land-task",
|
|
67
68
|
"task.act.plan": "request-plan",
|
|
68
69
|
"task.act.requeue": "retry-build",
|
|
69
70
|
"task.act.route": "change-task-agents",
|
|
@@ -87,6 +88,8 @@ const LOCAL_POSTS = Object.freeze({
|
|
|
87
88
|
"direct-chat.repair": "direct-chat-manage",
|
|
88
89
|
"direct-chat.ship-preview": "read",
|
|
89
90
|
"direct-chat.ship": "direct-chat-ship",
|
|
91
|
+
"direct-chat.page-ship-review": "read",
|
|
92
|
+
"direct-chat.page-ship": "direct-chat-ship",
|
|
90
93
|
"direct-chat.ship-cancel": "direct-chat-manage",
|
|
91
94
|
"term.agent-sign-in": "agent-sign-in",
|
|
92
95
|
"term.agent-install": "agent-install",
|
|
@@ -273,6 +276,8 @@ get("tasks", "term.socket", `^\\/term\\/${TERMINAL}\\/socket$`, { ...TERM, sampl
|
|
|
273
276
|
const DIRECT_CHAT = { ...free, callers: ["cookie"], project: "none", limited: "deny", ...operator("Direct chat is for local solo operators.", "/") };
|
|
274
277
|
get("tasks", "direct-chat.list", "/engine/direct-chats", DIRECT_CHAT);
|
|
275
278
|
get("tasks", "direct-chat.detail", `^\\/engine\\/direct-chats\\/${TERMINAL}$`, { ...DIRECT_CHAT, sample: `/engine/direct-chats/${"a".repeat(32)}` });
|
|
279
|
+
get("tasks", "direct-chat.page-list", "/direct-chats", DIRECT_CHAT);
|
|
280
|
+
get("tasks", "direct-chat.page", `^\\/direct-chats\\/${TERMINAL}$`, { ...DIRECT_CHAT, sample: `/direct-chats/${"a".repeat(32)}` });
|
|
276
281
|
get("tasks", "direct-chat.artifact", `^\\/engine\\/direct-chats\\/${TERMINAL}\\/artifacts\\/${TERMINAL}$`, { ...DIRECT_CHAT, sample: `/engine/direct-chats/${"a".repeat(32)}/artifacts/${"b".repeat(32)}` });
|
|
277
282
|
get("pages", "projects.browse", "/projects/browse", free);
|
|
278
283
|
get("pages", "projects.pick", "/projects/pick", { ...free, callers: ["cookie"], project: "none", ...approver("Sign in as an approver to add projects.", "/projects") });
|
|
@@ -321,6 +326,7 @@ get("pages", "agents.live", "/agents/live", { limited: "unscoped", callers: ["co
|
|
|
321
326
|
get("pages", "agents.live.read", `^\\/agents\\/live\\/${ID}$`, { limited: "unscoped", callers: ["cookie"], ...free, sample: "/agents/live/1" });
|
|
322
327
|
get("pages", "agents.live.run", `^\\/agents\\/live\\/run\\/${ID}$`, { limited: "unscoped", callers: ["cookie", "bearer"], ...free, sample: "/agents/live/run/1" });
|
|
323
328
|
get("pages", "agents.live.thread", "^\\/agents\\/live\\/thread\\/[0-9a-f]{32}$", { limited: "unscoped", callers: ["cookie"], ...free, sample: `/agents/live/thread/${"a".repeat(32)}` });
|
|
329
|
+
get("pages", "agents.live.thread.diff", "^\\/agents\\/live\\/thread\\/[0-9a-f]{32}\\/diff$", { limited: "unscoped", callers: ["cookie"], ...free, sample: `/agents/live/thread/${"a".repeat(32)}/diff` });
|
|
324
330
|
get("pages", "agents.live.threads", "/agents/live/threads", { limited: "unscoped", callers: ["cookie"], ...free });
|
|
325
331
|
post("pages", "agents.live.thread.answer", "^\\/agents\\/live\\/thread\\/[0-9a-f]{32}\\/answer$", { limited: "unscoped", callers: ["cookie"], project: "none", sample: `/agents/live/thread/${"a".repeat(32)}/answer` });
|
|
326
332
|
post("pages", "agents.live.thread.start", "/agents/live/thread", { limited: "unscoped", callers: ["cookie"], project: "none", ...approver("An approver starts threads.") });
|
|
@@ -440,6 +446,8 @@ post("tasks", "direct-chat.apply-main", `^\\/engine\\/direct-chats\\/${TERMINAL}
|
|
|
440
446
|
post("tasks", "direct-chat.repair", `^\\/engine\\/direct-chats\\/${TERMINAL}\\/repair$`, { ...DIRECT_CHAT, sample: `/engine/direct-chats/${"a".repeat(32)}/repair` });
|
|
441
447
|
post("tasks", "direct-chat.ship-preview", `^\\/engine\\/direct-chats\\/${TERMINAL}\\/ship-preview$`, { ...DIRECT_CHAT, sample: `/engine/direct-chats/${"a".repeat(32)}/ship-preview` });
|
|
442
448
|
post("tasks", "direct-chat.ship", `^\\/engine\\/direct-chats\\/${TERMINAL}\\/ship$`, { ...DIRECT_CHAT, scope: "step-up", sample: `/engine/direct-chats/${"a".repeat(32)}/ship` });
|
|
449
|
+
post("tasks", "direct-chat.page-ship-review", `^\\/direct-chats\\/${TERMINAL}\\/ship-review$`, { ...DIRECT_CHAT, sample: `/direct-chats/${"a".repeat(32)}/ship-review` });
|
|
450
|
+
post("tasks", "direct-chat.page-ship", `^\\/direct-chats\\/${TERMINAL}\\/ship$`, { ...DIRECT_CHAT, scope: "step-up", sample: `/direct-chats/${"a".repeat(32)}/ship` });
|
|
443
451
|
post("tasks", "direct-chat.ship-cancel", `^\\/engine\\/direct-chats\\/${TERMINAL}\\/ship-cancel$`, { ...DIRECT_CHAT, sample: `/engine/direct-chats/${"a".repeat(32)}/ship-cancel` });
|
|
444
452
|
for (const one of ["send", "stop", "resume", "recover", "continue", "ship", "answer"])
|
|
445
453
|
post("tasks", `code.${one}-send`, `^\\/code\\/${SESSION}\\/${one}$`, { ...CODING_ACT, sample: `/code/${"a".repeat(32)}/${one}` });
|
|
@@ -616,6 +624,7 @@ post("tasks", "task.act.route", `^\\/t\\/${TASK}\\/route$`, { project: "task", l
|
|
|
616
624
|
post("tasks", "task.act.retry-review", `^\\/t\\/${TASK}\\/retry-review$`, { project: "task", limited: "resource", sample: "/t/one/retry-review" });
|
|
617
625
|
post("tasks", "task.act.complete", `^\\/t\\/${TASK}\\/complete$`, { project: "task", limited: "resource", sample: "/t/one/complete", ...approver("Only an approver can mark a result complete.") });
|
|
618
626
|
post("tasks", "task.act.merge", `^\\/t\\/${TASK}\\/merge$`, { project: "task", limited: "resource", sample: "/t/one/merge", ...approver("Only an approver can merge.") });
|
|
627
|
+
post("tasks", "task.act.land", `^\\/t\\/${TASK}\\/land$`, { project: "task", limited: "resource", sample: "/t/one/land", ...approver("Only an approver can land work.") });
|
|
619
628
|
post("tasks", "task.act.recheck-stopped", `^\\/t\\/${TASK}\\/recheck-stopped$`, { project: "task", limited: "resource", sample: "/t/one/recheck-stopped", ...approver("Only an approver can have Toolroll check a build again.") });
|
|
620
629
|
post("tasks", "task.act.stop-carrying", `^\\/t\\/${TASK}\\/stop-carrying$`, { project: "task", limited: "resource", sample: "/t/one/stop-carrying", ...approver("Only an approver can stop carrying a release.") });
|
|
621
630
|
post("tasks", "task.act.stop", `^\\/t\\/${TASK}\\/stop$`, { project: "task", limited: "resource", sample: "/t/one/stop" });
|
package/dist/server/settings.js
CHANGED
|
@@ -495,10 +495,10 @@ ${connectionHtml(asked, connection, task)}${command === null ? "" : html `<p>On
|
|
|
495
495
|
}
|
|
496
496
|
async function pullRequestsPage(ctx) {
|
|
497
497
|
const { url, who, response, project } = ctx;
|
|
498
|
-
const repo = url.searchParams.get("repo") ?? "";
|
|
499
498
|
const known = [...new Set([...managedRepos(), ...store.knownRepos(), ...store.listProjects().map(one => one.path)])];
|
|
500
|
-
|
|
501
|
-
|
|
499
|
+
const repo = projectForPage(ctx, "/settings/pull-requests", "Pull requests", known);
|
|
500
|
+
if (repo === null || who.via !== "cookie")
|
|
501
|
+
return;
|
|
502
502
|
const publishing = publishingOf(store, repo);
|
|
503
503
|
const canChange = who.role === "approver" && !store.isDemo();
|
|
504
504
|
const check = publishing.on || !canChange ? null : lastChecks.known(`publishing:${repo}`)?.value ?? "unchecked";
|
|
@@ -508,10 +508,10 @@ ${connectionHtml(asked, connection, task)}${command === null ? "" : html `<p>On
|
|
|
508
508
|
}
|
|
509
509
|
async function checksPage(ctx) {
|
|
510
510
|
const { url, who, response, project } = ctx;
|
|
511
|
-
const repo = url.searchParams.get("repo") ?? "";
|
|
512
511
|
const known = [...new Set([...managedRepos(), ...store.knownRepos(), ...store.listProjects().map(one => one.path)])];
|
|
513
|
-
|
|
514
|
-
|
|
512
|
+
const repo = projectForPage(ctx, "/settings/checks", "Checks", known);
|
|
513
|
+
if (repo === null || who.via !== "cookie")
|
|
514
|
+
return;
|
|
515
515
|
const quick = liveQuickCommand(store, repo);
|
|
516
516
|
const body = (checkSettingsHtml({ repo, name: projectName(repo), csrf: who.session.csrf, canChange: who.role === "approver" && !store.isDemo(),
|
|
517
517
|
level: projectCheckLevel(store, repo).level, full: store.liveVerifyCommand(repo), quick, suggestion: quick === null ? suggestQuickCommand(repo) : null,
|
|
@@ -571,7 +571,7 @@ ${connectionHtml(asked, connection, task)}${command === null ? "" : html `<p>On
|
|
|
571
571
|
if (!authenticateCredential(who, body.get("password") ?? "").ok)
|
|
572
572
|
return back("problem", "Enter your Toolroll password to turn Passwordless on.");
|
|
573
573
|
setPasswordless(store, true, who.name, now);
|
|
574
|
-
return back("said", "Passwordless is on.
|
|
574
|
+
return back("said", "Passwordless is on. Approvals need no password now; changes that add a way in still ask.");
|
|
575
575
|
}
|
|
576
576
|
async function knowledgePage(ctx) {
|
|
577
577
|
const { url, who, response, project } = ctx;
|
|
@@ -3432,6 +3432,30 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
3432
3432
|
: self ? `Removed.${stopWords} Your threads can't reach Claude until you add one again. The token still works at Claude until you revoke it in your Claude account.`
|
|
3433
3433
|
: `Removed ${person}'s Claude sign-in for threads.${stopWords} Their threads can't reach Claude until they add one again.`);
|
|
3434
3434
|
}
|
|
3435
|
+
function projectForPage(ctx, path, title, known) {
|
|
3436
|
+
const { url, who, response, project } = ctx;
|
|
3437
|
+
const named = url.searchParams.get("repo");
|
|
3438
|
+
if (who.via !== "cookie") {
|
|
3439
|
+
refuse(response, who, 404, "No such project.", "/projects");
|
|
3440
|
+
return null;
|
|
3441
|
+
}
|
|
3442
|
+
if (named !== null) {
|
|
3443
|
+
if (!known.includes(named) || !visible(named)) {
|
|
3444
|
+
refuse(response, who, 404, "No such project.", "/projects");
|
|
3445
|
+
return null;
|
|
3446
|
+
}
|
|
3447
|
+
return named;
|
|
3448
|
+
}
|
|
3449
|
+
const mine = known.filter(repo => visible(repo));
|
|
3450
|
+
if (project != null && mine.includes(project))
|
|
3451
|
+
return project;
|
|
3452
|
+
if (mine.length === 1)
|
|
3453
|
+
return mine[0];
|
|
3454
|
+
const body = mine.length === 0 ? html `<p>No projects yet. <a class="k-link" href="/projects">Add one on Projects</a>.</p>`
|
|
3455
|
+
: html `<p>Pick a project.</p>${projectPicker(path, mine.map(repo => ({ repo, name: projectName(repo) })), "")}`;
|
|
3456
|
+
sendScreen(response, 200, screen(title, settingsSubPage("projects", title, body), { chrome: chromeFor(project, "projects") }));
|
|
3457
|
+
return null;
|
|
3458
|
+
}
|
|
3435
3459
|
return { registrations, modelsView };
|
|
3436
3460
|
}
|
|
3437
3461
|
function savedLoginOf(store) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { localOwnerRefusal } from "../local-owner.js";
|
|
2
|
+
import { landedWords, landingOf, publishesThroughPullRequests } from "../local-landing.js";
|
|
2
3
|
import { requestContext } from "./request-context.js";
|
|
3
4
|
import { heldFindingCount } from "../findings.js";
|
|
4
5
|
import { familyInWebReach } from "../findings.js";
|
|
@@ -605,6 +606,18 @@ export function createTaskViews(runtime) {
|
|
|
605
606
|
return null;
|
|
606
607
|
return { taskId: rootId, view: null, offer: { taskId: receipt.taskId, runId: receipt.runId, digest: receipt.digest }, target };
|
|
607
608
|
}
|
|
609
|
+
function taskLandingOf(taskId, who) {
|
|
610
|
+
const repo = runtime.store.lookupRef(taskId)?.repo ?? null;
|
|
611
|
+
if (repo === null || publishesThroughPullRequests(runtime.store, repo))
|
|
612
|
+
return null;
|
|
613
|
+
const rootId = runtime.familyOf(taskId)?.root.id ?? taskId;
|
|
614
|
+
const record = landingOf(runtime.store, rootId);
|
|
615
|
+
const complete = assignmentOf(runtime.store, taskId, runtime.clock(), runtime.workAccess(), runtime.evidenceRoot)?.state === "complete";
|
|
616
|
+
if (!complete && record === null)
|
|
617
|
+
return null;
|
|
618
|
+
const person = who.via === "cookie" && who.role === "approver";
|
|
619
|
+
return { taskId: rootId, landed: landedWords(runtime.store, rootId), canLand: person && complete && (record === null || record.undone), canUndo: person && record !== null && !record.undone };
|
|
620
|
+
}
|
|
608
621
|
function failureOf(runs, assignment, readLog = true) {
|
|
609
622
|
const last = latestFinishedAttempt(runs);
|
|
610
623
|
if (last === null)
|
|
@@ -736,6 +749,7 @@ export function createTaskViews(runtime) {
|
|
|
736
749
|
if (resultSection !== null && extras.result.current)
|
|
737
750
|
presentedData.resultSection = resultSection;
|
|
738
751
|
presentedData.pullRequest = taskPullRequestOf(taskId, who);
|
|
752
|
+
presentedData.landing = taskLandingOf(taskId, who);
|
|
739
753
|
if (family !== null && family.problem === null) {
|
|
740
754
|
presentedData.family = { root: { id: family.root.id, title: family.root.title, createdAt: family.root.createdAt, goal: runtime.store.getScope(family.root.id)?.goal ?? null },
|
|
741
755
|
versions: family.versions.map(one => ({ id: one.id, title: one.title, state: one.state })),
|
|
@@ -1038,6 +1052,7 @@ export function createTaskViews(runtime) {
|
|
|
1038
1052
|
terminal,
|
|
1039
1053
|
publication,
|
|
1040
1054
|
pullRequestTo: pullRequestTargetOf(run.id),
|
|
1055
|
+
buildNowOnSendBack: who.via === "cookie" && who.authority === "local-owner" && who.role === "approver",
|
|
1041
1056
|
publishing: pullRequestTargetOf(run.id) !== null ? "pull-request" : publishingOf(runtime.store, runtime.store.refById(run.taskRef)?.repo ?? null).on ? "other" : "off",
|
|
1042
1057
|
ciFailing: publication !== null && publication.prNumber !== null && runtime.store.hasOpenCiEpisode(publication.githubRepo, publication.prNumber),
|
|
1043
1058
|
files,
|