toolroll 0.9.119 → 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 +31 -0
- package/README.md +8 -8
- package/dist/assignment.js +9 -7
- package/dist/browser/workspace.js +23 -23
- package/dist/builder.js +2 -1
- package/dist/cli-help.js +1 -0
- package/dist/codex-limits.js +40 -22
- package/dist/contracts/console-api.js +2 -0
- package/dist/engine-reads.js +3 -1
- package/dist/flexible-import.js +38 -0
- package/dist/flexible-save.js +128 -0
- package/dist/flexible-session.js +9 -2
- package/dist/flexible-ship.js +3 -3
- package/dist/flexible-thread.js +2 -2
- package/dist/local-checks.js +32 -0
- package/dist/local-landing.js +321 -63
- package/dist/local-owner.js +2 -0
- package/dist/operate.js +25 -7
- package/dist/plan-limits-demand.js +48 -0
- package/dist/result-follow-ups.js +22 -8
- package/dist/review-context.js +2 -1
- package/dist/server/direct-chat.js +24 -3
- package/dist/server/engine-api.js +24 -3
- package/dist/server/render-results.js +6 -4
- package/dist/server/route-table.js +6 -1
- package/dist/server/send-back-build.js +4 -0
- package/dist/server/settings.js +2 -0
- package/dist/server/task-views.js +8 -3
- package/dist/server/tasks.js +51 -9
- package/dist/settings-groups-ui.js +1 -1
- package/dist/subscription-usage.js +11 -5
- package/dist/surface.js +3 -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 +3 -1
- package/package.json +1 -1
package/dist/operate.js
CHANGED
|
@@ -4,6 +4,7 @@ import { readStoredGeminiStatus, refreshSubscriptions } from "./subscription-usa
|
|
|
4
4
|
import { liveCommandsShown } from "./live-detail.js";
|
|
5
5
|
import { flexibleArmedPass } from "./flexible-ship.js";
|
|
6
6
|
import { directChatArmedPass } from "./direct-chat-ship.js";
|
|
7
|
+
import { saveFlexibleBranch } from "./flexible-save.js";
|
|
7
8
|
import { closeFlexibleThread, flexibleShipNeedsFor, flexibleThreadRecords, flexibleThreadShipTerms, flexibleThreadTitleOf, latestFlexibleShip, removeFlexibleThreadCopy, shipFlexibleThread, stopFlexibleThreadsEverywhere } from "./flexible-session.js";
|
|
8
9
|
import { runCardCommand } from "./card-cli.js";
|
|
9
10
|
import { mintSecret } from "./secret-mint.js";
|
|
@@ -126,7 +127,7 @@ import { isWritesMode, writesWords } from "./writes-mode.js";
|
|
|
126
127
|
import { linuxFenceAvailable, macosFenceAvailable } from "./agent-fence.js";
|
|
127
128
|
import { parseMachLookup, parseReadDeny, readDenyWords } from "./project-sandbox.js";
|
|
128
129
|
import { LOCAL_POLICY } from "./surface.js";
|
|
129
|
-
import { land, landingWords, publishesThroughPullRequests, PULL_REQUESTS_INSTEAD, readLanding } from "./local-landing.js";
|
|
130
|
+
import { handoffWords, land, landingWords, publishesThroughPullRequests, PULL_REQUESTS_INSTEAD, readLanding } from "./local-landing.js";
|
|
130
131
|
import { asLocalOwner, currentLocalOwner, localActNow, LOCAL_MODE_CONFINES, localModeOn, localOwnerRefusal, localOwnerRequested } from "./local-owner.js";
|
|
131
132
|
import { CHECK_ACCESS_WARNINGS, checkAccessRunsAs, checkAccessWords, isCheckAccess, signInHostsMissing, signInsUnavailableWords, widerThan } from "./check-access.js";
|
|
132
133
|
import { CLI_PASSWORD_SOURCE, withPasswordSource } from "./sign-in-guard.js";
|
|
@@ -365,6 +366,8 @@ export const OPERATE_HELP = `toolroll — operating the queue
|
|
|
365
366
|
remotely, name a token with --token-name)
|
|
366
367
|
toolroll task complete <id> mark the current result complete (--digest for JSON/agents);
|
|
367
368
|
[--pull-request] --pull-request also opens its pull request
|
|
369
|
+
toolroll task land <id> put accepted work on the project's own branch (no pull requests): shows what lands
|
|
370
|
+
where, then --yes --key <key> lands it as one commit; --undo reverts it
|
|
368
371
|
toolroll task merge <id> --as <you> --token <t>
|
|
369
372
|
merge the task's pull request once checks pass
|
|
370
373
|
[--anyway] merge without waiting for the full check
|
|
@@ -7835,7 +7838,7 @@ async function addTask(positional, flags, context) {
|
|
|
7835
7838
|
}
|
|
7836
7839
|
}
|
|
7837
7840
|
const next = filedRef !== null && filedRef.repo !== null && filedRef.plan === null && !flags.has("report")
|
|
7838
|
-
? "Next: run `toolroll`, select it and press p to ask for a plan." : null;
|
|
7841
|
+
? "Next: run `toolroll`, select it and press p to ask for a plan. To build without a plan, file it with `toolroll task new` instead." : null;
|
|
7839
7842
|
return succeed(write, json, "task add", {
|
|
7840
7843
|
task: outcome.task,
|
|
7841
7844
|
...(replaces === undefined ? {} : { replaces }),
|
|
@@ -8176,7 +8179,8 @@ function showTask(positional, context) {
|
|
|
8176
8179
|
` ${task.title}`,
|
|
8177
8180
|
...(detail.work === null ? [] : [
|
|
8178
8181
|
` status: ${shared?.headline ?? detail.work.status.label}${shared === null ? "" : `${shared.headline === "On hold" ? " · " : " — "}${shared.sentence}`}`,
|
|
8179
|
-
...(primaryAction === null
|
|
8182
|
+
...(primaryAction === null || (checkedByPerson && (primaryAction.code === "open-result" || primaryAction.code === "inspect-run")) ? []
|
|
8183
|
+
: [` next: ${primaryAction.label}${primaryAction.target.decisionId === null ? "" : ` — decision #${primaryAction.target.decisionId}`}`]),
|
|
8180
8184
|
]),
|
|
8181
8185
|
...(task.state !== "done" || detail.proofVerdict === null
|
|
8182
8186
|
? []
|
|
@@ -13106,8 +13110,8 @@ async function threadCommand(positional, flags, context) {
|
|
|
13106
13110
|
const { store, write, json, clock } = context;
|
|
13107
13111
|
const verb = positional[0] ?? "list";
|
|
13108
13112
|
const command = `thread ${verb}`;
|
|
13109
|
-
if (!["list", "show", "end", "remove", "ship"].includes(verb))
|
|
13110
|
-
return fail(write, json, command, "usage", "`toolroll thread list|show|end|remove|ship <thread>`", EXIT.usage);
|
|
13113
|
+
if (!["list", "show", "end", "remove", "ship", "save"].includes(verb))
|
|
13114
|
+
return fail(write, json, command, "usage", "`toolroll thread list|show|end|remove|ship|save <thread>`", EXIT.usage);
|
|
13111
13115
|
const personOnly = "Only you, as a person, work with your own threads here; never a token, the lead, a chat app or a machine.";
|
|
13112
13116
|
if (machineActing() || process.env["TOOLROLL_LEAD_TOKEN"] !== undefined || process.env["TOOLROLL_REMOTE_TOKEN"] !== undefined)
|
|
13113
13117
|
return fail(write, json, command, "person-only", personOnly, EXIT.refused);
|
|
@@ -13194,6 +13198,12 @@ async function threadCommand(positional, flags, context) {
|
|
|
13194
13198
|
await stopFlexibleThreadsEverywhere(store, { reason: "its owner ended the thread", thread, clock });
|
|
13195
13199
|
return succeed(write, json, command, { thread, already: done.already }, () => [done.already ? "This thread had already ended." : "Ended. You can still ship its work for a week; then its copy is tidied."]);
|
|
13196
13200
|
}
|
|
13201
|
+
if (verb === "save") {
|
|
13202
|
+
const saved = await saveFlexibleBranch(store, { thread, by: { name: who.name, generation: account.generation }, now: clock(), prove: proveNow });
|
|
13203
|
+
if (!saved.ok)
|
|
13204
|
+
return fail(write, json, command, saved.reason, saved.message, EXIT.refused);
|
|
13205
|
+
return succeed(write, json, command, { thread, branch: saved.branch, commit: saved.candidate, already: saved.already, files: saved.changedPaths, next: saved.next }, () => [saved.already ? `Already saved as ${saved.branch} (commit ${saved.candidate.slice(0, 12)}).` : `Saved as ${saved.branch} (commit ${saved.candidate.slice(0, 12)}, ${saved.changedPaths.length} file${saved.changedPaths.length === 1 ? "" : "s"}).`, saved.next]);
|
|
13206
|
+
}
|
|
13197
13207
|
const removed = await removeFlexibleThreadCopy(store, { thread, by: who.name, now: clock(), prove: proveNow });
|
|
13198
13208
|
return removed.ok ? succeed(write, json, command, { thread }, () => ["Removed its working copy. Its record stays."]) : fail(write, json, command, removed.reason, removed.message, EXIT.refused);
|
|
13199
13209
|
}
|
|
@@ -13409,7 +13419,8 @@ async function landTaskCommand(positional, flags, context) {
|
|
|
13409
13419
|
return succeed(write, json, command, { landed: read.landed }, () => [`${id} · Landed on ${read.landed.ref.replace(/^refs\/heads\//, "")} (${read.landed.commit.slice(0, 7)}).`]);
|
|
13410
13420
|
const plan = read.plan;
|
|
13411
13421
|
return succeed(write, json, command, { plan }, () => [...landingWords(plan),
|
|
13412
|
-
`To ${undo ? "undo it" : "land it"}: toolroll task land ${id}${into === undefined ? "" : ` --into ${into}`}${undo ? " --undo" : ""} --yes --key ${plan.key}
|
|
13422
|
+
`To ${undo ? "undo it" : "land it"}: toolroll task land ${id}${into === undefined ? "" : ` --into ${into}`}${undo ? " --undo" : ""} --yes --key ${plan.key}${local === null ? " --as <you>" : ""}`,
|
|
13423
|
+
...(local === null ? ["That asks for your Toolroll password."] : [])]);
|
|
13413
13424
|
}
|
|
13414
13425
|
if (key === undefined || !/^[0-9a-f]{16}$/.test(key))
|
|
13415
13426
|
return fail(write, json, command, "usage", "--yes needs the --key `toolroll task land` showed you, so what lands is what you read.", EXIT.usage);
|
|
@@ -13429,8 +13440,15 @@ async function landTaskCommand(positional, flags, context) {
|
|
|
13429
13440
|
const result = await land(store, id, { key, ...(into === undefined ? {} : { into }), ...(undo ? { undo: true } : {}) }, authority, access, now, { root: context.evidenceRoot });
|
|
13430
13441
|
if (!result.ok)
|
|
13431
13442
|
return fail(write, json, command, result.reason, result.message, EXIT.refused);
|
|
13443
|
+
if (result.handoff !== null) {
|
|
13444
|
+
const handoff = result.handoff;
|
|
13445
|
+
return succeed(write, json, command, { landing: result }, () => [
|
|
13446
|
+
`${id} · Landing commit ${result.commit.slice(0, 7)} is ready (kept at ${handoff.ref}). Your project folder has ${result.branch} checked out, so Toolroll didn't touch it.`,
|
|
13447
|
+
handoffWords(handoff, result.commit)
|
|
13448
|
+
]);
|
|
13449
|
+
}
|
|
13432
13450
|
return succeed(write, json, command, { landing: result }, () => [
|
|
13433
|
-
`${id} · ${result.replayed ? "Already " : ""}${result.kind === "undo" ? "Undone" : "Landed"} on ${result.branch} (${result.commit.slice(0, 7)})${result.mode === "ref" ? "; no folder had it open" : ""}.`,
|
|
13451
|
+
`${id} · ${result.replayed ? "Already " : ""}${result.kind === "undo" ? "Undone" : "Landed"} on ${result.branch} (${result.commit.slice(0, 7)})${result.mode === "ref" ? "; no folder had it open" : result.mode === "files" ? "; your project folder's files are updated" : ""}.`,
|
|
13434
13452
|
...(result.warning === null ? [] : [result.warning])
|
|
13435
13453
|
]);
|
|
13436
13454
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const PLAN_LIMITS_VIEW_WINDOW_MS = 10 * 60_000;
|
|
2
|
+
const QUEUED_RECENTLY_MS = 60 * 60_000;
|
|
3
|
+
const RUNNING_AT_MOST_MS = 6 * 3_600_000;
|
|
4
|
+
const viewedAt = new WeakMap();
|
|
5
|
+
const listeners = new WeakMap();
|
|
6
|
+
export function notePlanLimitsViewed(store, at) {
|
|
7
|
+
viewedAt.set(store, at.getTime());
|
|
8
|
+
for (const listener of listeners.get(store) ?? []) {
|
|
9
|
+
try {
|
|
10
|
+
listener();
|
|
11
|
+
}
|
|
12
|
+
catch { }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function onPlanLimitsViewed(store, listener) {
|
|
16
|
+
const set = listeners.get(store) ?? new Set();
|
|
17
|
+
set.add(listener);
|
|
18
|
+
listeners.set(store, set);
|
|
19
|
+
return () => { set.delete(listener); };
|
|
20
|
+
}
|
|
21
|
+
function any(store, sql, ...values) {
|
|
22
|
+
try {
|
|
23
|
+
return store.handle.prepare(sql).get(...values) !== undefined;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function agentWorkActive(store, now) {
|
|
30
|
+
const queuedSince = new Date(now.getTime() - QUEUED_RECENTLY_MS).toISOString();
|
|
31
|
+
const runningSince = new Date(now.getTime() - RUNNING_AT_MOST_MS).toISOString();
|
|
32
|
+
return any(store, "SELECT 1 FROM task WHERE state = 'running' OR (state = 'queued' AND updated_at > ?) LIMIT 1", queuedSince)
|
|
33
|
+
|| any(store, "SELECT 1 FROM run WHERE outcome IS NULL AND started_at > ? LIMIT 1", runningSince)
|
|
34
|
+
|| any(store, "SELECT 1 FROM thread_turn WHERE status IN ('admitted', 'running') AND admitted_at > ? LIMIT 1", runningSince)
|
|
35
|
+
|| any(store, "SELECT 1 FROM direct_chat_turn WHERE status = 'running' AND created_at > ? LIMIT 1", runningSince)
|
|
36
|
+
|| any(store, "SELECT 1 FROM lead_queue WHERE status IN ('queued', 'running') LIMIT 1");
|
|
37
|
+
}
|
|
38
|
+
export function planLimitsWanted(store, now) {
|
|
39
|
+
const viewed = viewedAt.get(store);
|
|
40
|
+
if (viewed !== undefined && now.getTime() - viewed >= 0 && now.getTime() - viewed < PLAN_LIMITS_VIEW_WINDOW_MS)
|
|
41
|
+
return true;
|
|
42
|
+
return agentWorkActive(store, now);
|
|
43
|
+
}
|
|
44
|
+
export function directChatRunning(store, provider, now) {
|
|
45
|
+
const since = new Date(now.getTime() - RUNNING_AT_MOST_MS).toISOString();
|
|
46
|
+
return any(store, `SELECT 1 FROM direct_chat_turn JOIN direct_chat_thread ON direct_chat_thread.id = direct_chat_turn.thread_id
|
|
47
|
+
WHERE direct_chat_turn.status = 'running' AND direct_chat_turn.created_at > ? AND direct_chat_thread.provider = ? LIMIT 1`, since, provider);
|
|
48
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
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";
|
|
@@ -76,7 +77,7 @@ export function followUpChecksOf(store, runId, now = new Date(), root, asOf) {
|
|
|
76
77
|
const started = rows.find(row => row.action === CHECKS_STARTED && row.outcome === String(request.id)) ?? null;
|
|
77
78
|
const finished = rows.find(row => row.action === CHECKS_FINISHED && row.outcome.startsWith(`${request.id}:`)) ?? null;
|
|
78
79
|
const base = { request: request.id, runId, level: request.outcome, head, digest, actor: request.actor, at: request.at,
|
|
79
|
-
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,
|
|
80
81
|
...(why === "batch" ? { base: /^[a-f0-9]{40}$/.test(recordedBase) ? recordedBase : null } : {}) };
|
|
81
82
|
if (finished !== null) {
|
|
82
83
|
const status = finished.outcome.slice(String(request.id).length + 1);
|
|
@@ -213,13 +214,22 @@ export async function runFollowUpCheck(store, root, request, deps = {}) {
|
|
|
213
214
|
const held = finish("not-run", "The result's commit changed after checks were asked for.");
|
|
214
215
|
return held ?? followUpChecksOf(store, runId, now(), root).find(one => one.request === request) ?? null;
|
|
215
216
|
}
|
|
216
|
-
const authorized = wanted.why === "recheck" ? recheckStanding(store, { request, runId, head: target.head, digest: wanted.digest })
|
|
217
|
-
|
|
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) {
|
|
218
220
|
const held = finish("not-run", authorized?.problem ?? "Its authorization couldn't be read.");
|
|
219
221
|
return held ?? followUpChecksOf(store, runId, now(), root).find(one => one.request === request) ?? null;
|
|
220
222
|
}
|
|
221
|
-
const proveLaunch = () => {
|
|
222
|
-
|
|
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
|
+
};
|
|
223
233
|
const guardedRunner = (file, args, options) => { proveLaunch(); return runner(file, args, options); };
|
|
224
234
|
const git = deps.git ?? hardenedGit((file, args, options) => { proveLaunch(); return execRun(file, args, options); });
|
|
225
235
|
const launched = (inner) => (file, args, options) => {
|
|
@@ -283,9 +293,13 @@ export async function runFollowUpCheck(store, root, request, deps = {}) {
|
|
|
283
293
|
}
|
|
284
294
|
}
|
|
285
295
|
catch (error) {
|
|
286
|
-
if (
|
|
287
|
-
|
|
288
|
-
|
|
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
|
+
}
|
|
289
303
|
}
|
|
290
304
|
finally {
|
|
291
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);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
1
2
|
import { dirname, join } from "node:path";
|
|
2
3
|
import { inRehearsal } from "../rehearsal.js";
|
|
3
4
|
import { tmpdir } from "node:os";
|
|
@@ -14,7 +15,7 @@ import { handlersOf } from "./handler-registry.js";
|
|
|
14
15
|
import { redirect, respond } from "./http.js";
|
|
15
16
|
import { html, postForm } from "../html.js";
|
|
16
17
|
import { screen } from "./chrome.js";
|
|
17
|
-
import { btn } from "./kit.js";
|
|
18
|
+
import { btn, field, textarea } from "./kit.js";
|
|
18
19
|
import { rereadBrowser } from "./live.js";
|
|
19
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))?$/;
|
|
20
21
|
const ARTIFACT_PATH = /^\/engine\/direct-chats\/([a-f0-9]{32})\/artifacts\/([a-f0-9]{32})$/;
|
|
@@ -564,7 +565,7 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
564
565
|
deps.bus.publish({ revision: `dc:${threadId}:ship-cancel:${Date.now()}` });
|
|
565
566
|
return checked(ctx, 200, "directChatMutated", { ok: true, said: "Auto-merge cancelled." });
|
|
566
567
|
}
|
|
567
|
-
const PAGE_PATH = /^\/direct-chats\/([a-f0-9]{32})(?:\/(ship-review|ship))?$/;
|
|
568
|
+
const PAGE_PATH = /^\/direct-chats\/([a-f0-9]{32})(?:\/(ship-review|ship|reply))?$/;
|
|
568
569
|
const STATUS_WORDS = { completed: "Finished", failed: "Failed", interrupted: "Stopped", running: "Working", queued: "Waiting" };
|
|
569
570
|
const DIFF_SHOWN = 200_000;
|
|
570
571
|
function pageRefusal(ctx, status, words) {
|
|
@@ -597,9 +598,28 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
597
598
|
const ships = listDirectChatShips(store, thread.id);
|
|
598
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>`;
|
|
599
600
|
const shipAct = running || diff.changedFiles.length === 0 ? "" : postForm(`/direct-chats/${thread.id}/ship-review`, btn("Review Ship", { variant: "primary", type: "submit" }));
|
|
600
|
-
const
|
|
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>`;
|
|
601
605
|
return runtime.sendScreen(ctx.response, 200, screen(thread.title || "Direct Chat", body, { chrome: runtime.chromeFor(thread.repo, "tasks") }));
|
|
602
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
|
+
}
|
|
603
623
|
async function pageShipReview(ctx) {
|
|
604
624
|
const gate = admit(ctx, "read");
|
|
605
625
|
if (!gate.ok)
|
|
@@ -646,6 +666,7 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
646
666
|
"direct-chat.page": pageDetail,
|
|
647
667
|
"direct-chat.page-ship-review": pageShipReview,
|
|
648
668
|
"direct-chat.page-ship": pageShip,
|
|
669
|
+
"direct-chat.page-reply": pageReply,
|
|
649
670
|
"direct-chat.list": list,
|
|
650
671
|
"direct-chat.detail": detail,
|
|
651
672
|
"direct-chat.start": start,
|
|
@@ -10,7 +10,8 @@ import { flexibleAvailable } from "../flexible-available.js";
|
|
|
10
10
|
import { laptopShipProblem } from "../flexible-laptop.js";
|
|
11
11
|
import { threadsStatusNote, tidyFlexibleSignIns } from "../flexible-sign-in.js";
|
|
12
12
|
import { FLEXIBLE_UNAVAILABLE } from "../flexible.js";
|
|
13
|
-
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";
|
|
14
15
|
import { createFlexibleLauncher } from "../flexible-launcher.js";
|
|
15
16
|
import { FLEXIBLE_NEXT_WORDS, flexibleReadiness, flexibleStartCard } from "../flexible-start.js";
|
|
16
17
|
import { summaryLines } from "../approval-summary.js";
|
|
@@ -240,7 +241,7 @@ export function createEngineHandlers(runtime) {
|
|
|
240
241
|
if (ownedThread(request, who, flexible, id) === null)
|
|
241
242
|
return refusal(response, 404, "thread");
|
|
242
243
|
if (fileParam === null)
|
|
243
|
-
return sendChecked(response, 200, "resultDiff", threadDiffOf(id, turn, changes));
|
|
244
|
+
return sendChecked(response, 200, "resultDiff", threadDiffOf(id, turn, changes, { edited: flexibleThreadEdited(flexible, { thread: id }) }));
|
|
244
245
|
const one = threadDiffFileOf(id, turn, changes, Number(fileParam));
|
|
245
246
|
return one === null ? refusal(response, 404, "file") : sendChecked(response, 200, "resultDiffFile", one);
|
|
246
247
|
}
|
|
@@ -658,6 +659,26 @@ export function createEngineHandlers(runtime) {
|
|
|
658
659
|
return acted(response, 409, "refused", sent.message);
|
|
659
660
|
return acted(response, 200, "done", `Sent back. Turn ${sent.seq} started; the agent has the conversation so far.`);
|
|
660
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}`);
|
|
681
|
+
}
|
|
661
682
|
async function leadChat(ctx) {
|
|
662
683
|
const { url, who, request, response, now } = ctx;
|
|
663
684
|
const remote = who.via === "bearer" && who.principal !== undefined && isRemoteTerminalRequest(request);
|
|
@@ -794,7 +815,7 @@ export function createEngineHandlers(runtime) {
|
|
|
794
815
|
},
|
|
795
816
|
registrations: [
|
|
796
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,
|
|
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 }),
|
|
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 }),
|
|
798
819
|
...handlersOf("tasks", { "task.steps": taskSteps, "task.approval": taskApproval, "task.diff": taskDiff, "task.result": taskResult }),
|
|
799
820
|
...handlersOf("people", {}, { "edge.login-link-json": redeemLink }),
|
|
800
821
|
],
|
|
@@ -581,8 +581,8 @@ export function reviewCockpitDetailParts(view, csrf, noted, canRetryReview, tab,
|
|
|
581
581
|
const blocked = hardStop ?? cantAcceptYetOf(proof?.verdict ?? null, proof?.reasons ?? [], accepted);
|
|
582
582
|
const youCheck = panel.panel.youCheck;
|
|
583
583
|
const shared = accepted || assignment?.receipt == null ? null : owedAcceptance(assignment.receipt, assignment.readiness?.blockers ?? []);
|
|
584
|
-
const owed = accepted ? null : youCheck?.accept != null
|
|
585
|
-
: shared === "
|
|
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;
|
|
586
586
|
const complete = hardStop === null && assignment?.state === "ready-to-check" && assignment.receipt !== null && canRetryReview && csrf !== ""
|
|
587
587
|
? { action: `${taskHref(view.taskId)}/complete`, receipt: assignment.receipt.digest, run: run.id, accept: owed, ...(host.kind === "task" ? { returnTo: at() } : {}) } : null;
|
|
588
588
|
if (complete !== null)
|
|
@@ -1332,6 +1332,7 @@ export function resultPanelParts(detail, o) {
|
|
|
1332
1332
|
const humanReview = manualReviewOnly(proof === null ? null : { ...proof, verdict: proof.verdict ?? "" });
|
|
1333
1333
|
const need = needActionOf(current, taskStatus, o.csrf, o.returnTo, {
|
|
1334
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",
|
|
1335
1336
|
rebuildable: proof?.accepted == null && proof?.verdict !== "verified" && proof?.verdict !== "attested" && !(detail.publication !== null && ["pushed", "opened"].includes(detail.publication.state))
|
|
1336
1337
|
});
|
|
1337
1338
|
const directAssessment = proof?.matrix.some(row => row.assessment !== undefined) === true;
|
|
@@ -1704,9 +1705,10 @@ export function needActionOf(assignment, status, csrf, returnTo, result) {
|
|
|
1704
1705
|
if (action?.code === "retry-task" && status.need.key === "rebuild" && csrf !== "")
|
|
1705
1706
|
return { label: status.need.action.label, ...rebuild };
|
|
1706
1707
|
if (result !== undefined) {
|
|
1708
|
+
const exception = result.refuted === true || (result.exception ?? !result.humanReview);
|
|
1707
1709
|
if ((status.need.key === "review-result" || result.refuted === true) && !result.accepted && csrf !== "")
|
|
1708
|
-
return { label:
|
|
1709
|
-
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 } };
|
|
1710
1712
|
const here = (action?.code === "open-result" || action?.code === "inspect-run") && action.target.runId === result.run;
|
|
1711
1713
|
if (here && csrf !== "" && !result.accepted && result.humanReview)
|
|
1712
1714
|
return { label: "Accept result", href: null, confirm: null, accept: { action: result.action, run: result.run, returnTo, note: null } };
|
|
@@ -55,6 +55,7 @@ const LOCAL_POSTS = Object.freeze({
|
|
|
55
55
|
"agents.live.thread.ship": "ship-thread",
|
|
56
56
|
"agents.live.thread.ship-cancel": "cancel-ship",
|
|
57
57
|
"agents.live.thread.ship-send-back": "reply-thread",
|
|
58
|
+
"agents.live.thread.save": "save-thread",
|
|
58
59
|
"task.act.reply": "answer-question",
|
|
59
60
|
"task.act.stop": "stop-run",
|
|
60
61
|
"task.act.cancel": "stop-run",
|
|
@@ -72,6 +73,7 @@ const LOCAL_POSTS = Object.freeze({
|
|
|
72
73
|
"flow.trigger.resume": "trigger-resume",
|
|
73
74
|
"flow.trigger.check": "trigger-run",
|
|
74
75
|
"flow.trigger.press": "trigger-run",
|
|
76
|
+
"run.act.checks": "run-checks",
|
|
75
77
|
"run.act.revise": "request-revision",
|
|
76
78
|
"run.act.note": "request-revision",
|
|
77
79
|
"run.act.comment": "request-revision",
|
|
@@ -90,6 +92,7 @@ const LOCAL_POSTS = Object.freeze({
|
|
|
90
92
|
"direct-chat.ship": "direct-chat-ship",
|
|
91
93
|
"direct-chat.page-ship-review": "read",
|
|
92
94
|
"direct-chat.page-ship": "direct-chat-ship",
|
|
95
|
+
"direct-chat.page-reply": "direct-chat-send",
|
|
93
96
|
"direct-chat.ship-cancel": "direct-chat-manage",
|
|
94
97
|
"term.agent-sign-in": "agent-sign-in",
|
|
95
98
|
"term.agent-install": "agent-install",
|
|
@@ -336,6 +339,7 @@ post("pages", "agents.live.thread.end", "^\\/agents\\/live\\/thread\\/[0-9a-f]{3
|
|
|
336
339
|
post("pages", "agents.live.thread.ship", "^\\/agents\\/live\\/thread\\/[0-9a-f]{32}\\/ship$", { limited: "unscoped", callers: ["cookie"], project: "none", ...approver("An approver ships their own thread's work."), sample: `/agents/live/thread/${"a".repeat(32)}/ship` });
|
|
337
340
|
post("pages", "agents.live.thread.ship-cancel", "^\\/agents\\/live\\/thread\\/[0-9a-f]{32}\\/ship\\/cancel$", { limited: "unscoped", callers: ["cookie"], project: "none", sample: `/agents/live/thread/${"a".repeat(32)}/ship/cancel` });
|
|
338
341
|
post("pages", "agents.live.thread.ship-send-back", "^\\/agents\\/live\\/thread\\/[0-9a-f]{32}\\/ship\\/send-back$", { limited: "unscoped", callers: ["cookie"], project: "none", ...approver("An approver sends back their own thread's Ship."), sample: `/agents/live/thread/${"a".repeat(32)}/ship/send-back` });
|
|
342
|
+
post("pages", "agents.live.thread.save", "^\\/agents\\/live\\/thread\\/[0-9a-f]{32}\\/save$", { limited: "unscoped", callers: ["cookie"], project: "none", ...approver("An approver saves their own thread's work as a branch."), sample: `/agents/live/thread/${"a".repeat(32)}/save` });
|
|
339
343
|
get("pages", "agents.terminals", "/agents/terminals", TERM);
|
|
340
344
|
get("pages", "fleet", "/fleet", free);
|
|
341
345
|
get("tasks", "tasks.new", "/tasks/new", { limited: "collection", ...free });
|
|
@@ -448,6 +452,7 @@ post("tasks", "direct-chat.ship-preview", `^\\/engine\\/direct-chats\\/${TERMINA
|
|
|
448
452
|
post("tasks", "direct-chat.ship", `^\\/engine\\/direct-chats\\/${TERMINAL}\\/ship$`, { ...DIRECT_CHAT, scope: "step-up", sample: `/engine/direct-chats/${"a".repeat(32)}/ship` });
|
|
449
453
|
post("tasks", "direct-chat.page-ship-review", `^\\/direct-chats\\/${TERMINAL}\\/ship-review$`, { ...DIRECT_CHAT, sample: `/direct-chats/${"a".repeat(32)}/ship-review` });
|
|
450
454
|
post("tasks", "direct-chat.page-ship", `^\\/direct-chats\\/${TERMINAL}\\/ship$`, { ...DIRECT_CHAT, scope: "step-up", sample: `/direct-chats/${"a".repeat(32)}/ship` });
|
|
455
|
+
post("tasks", "direct-chat.page-reply", `^\\/direct-chats\\/${TERMINAL}\\/reply$`, { ...DIRECT_CHAT, scope: "step-up", sample: `/direct-chats/${"a".repeat(32)}/reply` });
|
|
451
456
|
post("tasks", "direct-chat.ship-cancel", `^\\/engine\\/direct-chats\\/${TERMINAL}\\/ship-cancel$`, { ...DIRECT_CHAT, sample: `/engine/direct-chats/${"a".repeat(32)}/ship-cancel` });
|
|
452
457
|
for (const one of ["send", "stop", "resume", "recover", "continue", "ship", "answer"])
|
|
453
458
|
post("tasks", `code.${one}-send`, `^\\/code\\/${SESSION}\\/${one}$`, { ...CODING_ACT, sample: `/code/${"a".repeat(32)}/${one}` });
|
|
@@ -660,7 +665,7 @@ for (const one of ["prepare", "preview", "import", "save"])
|
|
|
660
665
|
post("flows", `recipes.${one}-send`, `/recipes/${one}`, { limited: "collection" });
|
|
661
666
|
post("flows", "recipes.launch-send", "/recipes/launch", { limited: "collection" });
|
|
662
667
|
for (const one of ["note", "comment", "revise", "draft-repair", "checks", "add-tests"])
|
|
663
|
-
post("tasks", `run.act.${one}`, `^\\/r\\/${ID}\\/${one}$`, { project: "run", limited: "resource", sample: `/r/1/${one}
|
|
668
|
+
post("tasks", `run.act.${one}`, `^\\/r\\/${ID}\\/${one}$`, { project: "run", limited: "resource", sample: `/r/1/${one}`, ...(one === "comment" ? { freshness: "allowlist" } : {}) });
|
|
664
669
|
post("tasks", "run.act.reveal", `^\\/r\\/${ID}\\/reveal$`, { project: "run", limited: "resource", callers: ["cookie"], sample: "/r/1/reveal", ...approver("Only an approver can show an agent's files.") });
|
|
665
670
|
post("tasks", "session.editor-links", "/session/editor-links", { viewer: true });
|
|
666
671
|
post("tasks", "agents.seen", "/agents/seen", { callers: ["cookie"], project: "none", limited: "unscoped", viewer: true });
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { freshnessFor, passwordlessSessionFor, ssoNowAvailable, withFreshness } from "../scope.js";
|
|
2
|
+
export function sessionYesPossible(store, by, preview) {
|
|
3
|
+
return passwordlessSessionFor(store, by) || ssoNowAvailable(by) || withFreshness("approve-standard", () => freshnessFor(by, Date.now(), preview)) !== null;
|
|
4
|
+
}
|
package/dist/server/settings.js
CHANGED
|
@@ -146,6 +146,7 @@ import { approvalFactsNow } from "./kit.js";
|
|
|
146
146
|
import { spendReport, spendReportCsv, spendRows } from "../spend-report.js";
|
|
147
147
|
import { savingsReportOrError } from "../route-savings.js";
|
|
148
148
|
import { limitsView } from "../limits-ui.js";
|
|
149
|
+
import { notePlanLimitsViewed } from "../plan-limits-demand.js";
|
|
149
150
|
import { budgetStates, monthNamed, spendItems, usd as spendUsd, subagentNames as subagentNamesOf } from "../spend.js";
|
|
150
151
|
import { removeSsoSettings, saveSsoSettings, SSO_CALLBACK, ssoChangeWords } from "../sso-settings.js";
|
|
151
152
|
import { ssoSettingsHtml } from "../sso-ui.js";
|
|
@@ -209,6 +210,7 @@ export function createSettingsHandlers(runtime) {
|
|
|
209
210
|
fieldError: url.searchParams.get("field") === "usd" ? url.searchParams.get("problem") : null,
|
|
210
211
|
problem: url.searchParams.get("field") === "usd" ? null : url.searchParams.get("problem"),
|
|
211
212
|
};
|
|
213
|
+
notePlanLimitsViewed(store, now);
|
|
212
214
|
const windows = limitsView(store.providerLimits(), [], { project: projectName, subagent: id => subagentNames.get(id) ?? `Subagent ${id}` }, now);
|
|
213
215
|
const view = { month: month.name, previous: shift(-1), next: month.name === current.name ? null : shift(1), current: current.name, report: spendReport(rows),
|
|
214
216
|
budgets, unlimited, targets, windows, subagentNames, edit, facts: approvalFactsNow(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { localOwnerRefusal } from "../local-owner.js";
|
|
2
|
-
import { landedWords, landingOf, publishesThroughPullRequests } from "../local-landing.js";
|
|
2
|
+
import { broughtInOnBranch, landedWords, landingOf, publishesThroughPullRequests, recognisedOnBranch } from "../local-landing.js";
|
|
3
3
|
import { requestContext } from "./request-context.js";
|
|
4
4
|
import { heldFindingCount } from "../findings.js";
|
|
5
5
|
import { familyInWebReach } from "../findings.js";
|
|
@@ -14,6 +14,7 @@ import { agentSaidOf, releaseProgressFor, shipChecksForTask } from "../store.js"
|
|
|
14
14
|
import { releaseCiRunningOf } from "../release-ci-hold.js";
|
|
15
15
|
import { releaseObligationsOf } from "../release-recheck.js";
|
|
16
16
|
import { approvalProofOf, freshnessFor, withFreshness } from "../scope.js";
|
|
17
|
+
import { sessionYesPossible } from "./send-back-build.js";
|
|
17
18
|
import { approvalPasswordField } from "../approval-password.js";
|
|
18
19
|
import { fastChangeProblem, fastStarted } from "../fast-start.js";
|
|
19
20
|
import { routeChangeOf } from "../route-change.js";
|
|
@@ -612,10 +613,14 @@ export function createTaskViews(runtime) {
|
|
|
612
613
|
return null;
|
|
613
614
|
const rootId = runtime.familyOf(taskId)?.root.id ?? taskId;
|
|
614
615
|
const record = landingOf(runtime.store, rootId);
|
|
615
|
-
const
|
|
616
|
+
const assignment = assignmentOf(runtime.store, taskId, runtime.clock(), runtime.workAccess(), runtime.evidenceRoot);
|
|
617
|
+
const complete = assignment?.state === "complete";
|
|
616
618
|
if (!complete && record === null)
|
|
617
619
|
return null;
|
|
618
620
|
const person = who.via === "cookie" && who.role === "approver";
|
|
621
|
+
const onBranch = record === null || record.undone ? recognisedOnBranch(runtime.store, repo, rootId, complete ? assignment?.receipt?.head ?? null : null, baseGit) : null;
|
|
622
|
+
if (onBranch !== null)
|
|
623
|
+
return { taskId: rootId, landed: onBranch, canLand: false, canUndo: person && broughtInOnBranch(runtime.store, repo, rootId, baseGit) };
|
|
619
624
|
return { taskId: rootId, landed: landedWords(runtime.store, rootId), canLand: person && complete && (record === null || record.undone), canUndo: person && record !== null && !record.undone };
|
|
620
625
|
}
|
|
621
626
|
function failureOf(runs, assignment, readLog = true) {
|
|
@@ -1052,7 +1057,7 @@ export function createTaskViews(runtime) {
|
|
|
1052
1057
|
terminal,
|
|
1053
1058
|
publication,
|
|
1054
1059
|
pullRequestTo: pullRequestTargetOf(run.id),
|
|
1055
|
-
buildNowOnSendBack: who.via === "cookie" && who.
|
|
1060
|
+
buildNowOnSendBack: who.via === "cookie" && who.role === "approver" && (who.authority === "local-owner" || sessionYesPossible(runtime.store, who.name, true)),
|
|
1056
1061
|
publishing: pullRequestTargetOf(run.id) !== null ? "pull-request" : publishingOf(runtime.store, runtime.store.refById(run.taskRef)?.repo ?? null).on ? "other" : "off",
|
|
1057
1062
|
ciFailing: publication !== null && publication.prNumber !== null && runtime.store.hasOpenCiEpisode(publication.githubRepo, publication.prNumber),
|
|
1058
1063
|
files,
|