toolroll 0.9.116 → 0.9.118
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 +46 -0
- package/README.md +43 -26
- package/dist/acp-agents.js +14 -1
- package/dist/acp-client.js +19 -1
- package/dist/agent-change-check.js +60 -0
- package/dist/agent-change-schema.js +19 -0
- package/dist/agent-detect.js +11 -1
- package/dist/agent-fence.js +93 -16
- package/dist/agent-network-request.js +108 -0
- package/dist/agent-requests.js +105 -0
- package/dist/approval-summary.js +3 -3
- package/dist/backup.js +17 -1
- package/dist/batch-checks.js +81 -18
- package/dist/browser/terminal.js +41 -41
- package/dist/browser/workspace.css +2 -2
- package/dist/browser/workspace.js +36 -36
- package/dist/builder.js +12 -2
- package/dist/candidate-materialize.js +119 -0
- package/dist/central-enrollment-contract.js +156 -0
- package/dist/central-recovery-stage.js +329 -0
- package/dist/chat-actions.js +101 -2
- package/dist/chat-channel.js +40 -0
- package/dist/check-only-standing.js +13 -0
- package/dist/check-only.js +25 -13
- package/dist/check-recovery-hold.js +199 -0
- package/dist/check-recovery-index-schema.js +3 -0
- package/dist/check-screenshots.js +83 -0
- package/dist/cli.js +125 -6
- package/dist/codex-limits.js +4 -0
- package/dist/coding-context.js +16 -2
- package/dist/coding-provider.js +7 -3
- package/dist/coding-workspace.js +5 -5
- package/dist/connect-cli.js +257 -11
- package/dist/contracts/chat-actions.js +4 -0
- package/dist/contracts/console-api.js +14 -3
- package/dist/contracts/engine-api.js +331 -2
- package/dist/contracts/lead-tools.js +56 -2
- package/dist/contracts/provider.js +1 -1
- package/dist/contracts/route.js +1 -1
- package/dist/contracts/terminal-connection.js +50 -0
- package/dist/converse.js +80 -4
- package/dist/device-pair.js +280 -0
- package/dist/direct-chat-artifacts.js +347 -0
- package/dist/direct-chat-catalog.js +311 -0
- package/dist/direct-chat-fence.js +96 -0
- package/dist/direct-chat-git.js +343 -0
- package/dist/direct-chat-laptop.js +19 -0
- package/dist/direct-chat-schema.js +181 -0
- package/dist/direct-chat-ship.js +861 -0
- package/dist/direct-chat-workspace.js +389 -0
- package/dist/direct-chat.js +2107 -0
- package/dist/doctor.js +1 -1
- package/dist/easy-start.js +18 -0
- package/dist/egress.js +25 -4
- package/dist/engine-chat.js +454 -0
- package/dist/engine-reads.js +141 -13
- package/dist/exec.js +4 -3
- package/dist/flexible-agents.js +8 -16
- package/dist/flexible-session.js +91 -47
- package/dist/flexible-ship.js +87 -7
- package/dist/flexible-start.js +4 -1
- package/dist/flexible-thread.js +2 -3
- package/dist/flexible-turns.js +26 -5
- package/dist/flow-triggers.js +13 -4
- package/dist/flows-ui.js +54 -20
- package/dist/handoff-cli.js +630 -0
- package/dist/invoke.js +71 -17
- package/dist/lead-contract.js +5 -4
- package/dist/lead-doors.js +80 -1
- package/dist/lead-progress.js +9 -0
- package/dist/lead-tools.js +681 -10
- package/dist/lead.js +37 -9
- package/dist/live-bus.js +11 -0
- package/dist/live-terminal.js +132 -12
- package/dist/local-handoff.js +363 -0
- package/dist/local-owner-acts.js +264 -2
- package/dist/local-owner.js +16 -1
- package/dist/multiplayer-handoff.js +528 -0
- package/dist/multiplayer-presence.js +471 -0
- package/dist/names.js +17 -4
- package/dist/needs-you.js +10 -0
- package/dist/operate.js +280 -19
- package/dist/planner.js +6 -1
- package/dist/policy.js +2 -2
- package/dist/project-delete-ui.js +18 -11
- package/dist/project-delete.js +65 -4
- package/dist/project-skills.js +28 -13
- package/dist/project-tools.js +1 -1
- package/dist/prompt.js +1 -1
- package/dist/provider-connection.js +2 -0
- package/dist/provider-home.js +251 -8
- package/dist/provider.js +3 -2
- package/dist/publish.js +119 -64
- package/dist/pull-request-flow.js +35 -14
- package/dist/read-executor-worker.js +1 -1
- package/dist/read-executor.js +95 -1
- package/dist/restore-retirement.js +152 -0
- package/dist/result-follow-ups.js +116 -37
- package/dist/route-change.js +44 -4
- package/dist/scope.js +62 -5
- package/dist/scout.js +6 -2
- package/dist/serve.js +49 -5
- package/dist/server/chat.js +94 -13
- package/dist/server/direct-chat.js +583 -0
- package/dist/server/engine-api.js +219 -21
- package/dist/server/flows.js +43 -10
- package/dist/server/found-repos.js +25 -0
- package/dist/server/guards.js +20 -6
- package/dist/server/live.js +81 -23
- package/dist/server/pages.js +67 -13
- package/dist/server/people-tokens.js +47 -6
- package/dist/server/remote.js +29 -0
- package/dist/server/render-results.js +6 -2
- package/dist/server/render-settings.js +4 -2
- package/dist/server/render-tasks.js +18 -17
- package/dist/server/route-table.js +69 -2
- package/dist/server/settings.js +22 -7
- package/dist/server/task-views.js +15 -3
- package/dist/server/tasks.js +39 -2
- package/dist/server/terminals.js +185 -11
- package/dist/settings-proofs.js +1 -1
- package/dist/skills-manifest.js +57 -0
- package/dist/store.js +499 -56
- package/dist/subscription-chat.js +33 -6
- package/dist/subscription-usage.js +233 -0
- package/dist/task-live.js +2 -1
- package/dist/teardown-git.js +34 -4
- package/dist/terminal-connection.js +159 -0
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/dist/tui-contract.js +1 -1
- package/dist/tui-launch.js +32 -1
- package/dist/workspace-identity-schema.js +21 -0
- package/package.json +4 -2
package/dist/flexible-ship.js
CHANGED
|
@@ -18,6 +18,7 @@ import { localActNow } from "./local-owner.js";
|
|
|
18
18
|
import { assignmentOf } from "./assignment.js";
|
|
19
19
|
import { completeAndOpenPullRequest, mergePullRequest } from "./pull-request-flow.js";
|
|
20
20
|
import { fullCheckGate } from "./result-follow-ups.js";
|
|
21
|
+
import { CHECK_RECOVERY_HELD, readCheckRecoveryHoldsForRun } from "./check-recovery-hold.js";
|
|
21
22
|
import { runCheckLevel } from "./check-levels.js";
|
|
22
23
|
import { FLEXIBLE_FILED_PREFIX } from "./flexible-merge-guard.js";
|
|
23
24
|
import { run } from "./exec.js";
|
|
@@ -70,6 +71,7 @@ const WORDS = Object.freeze({
|
|
|
70
71
|
"proof-refused": "That didn't prove it's you, or you can't approve work in this project. Nothing changed.",
|
|
71
72
|
"handoff-failed": "The changes were imported, but their check task couldn't be made. The import is kept: ship again, or remove it.",
|
|
72
73
|
"approval-refused": "The changes were imported, but their check task couldn't be approved. The import is kept: ship again, or remove it.",
|
|
74
|
+
"recovery-held": "Checks are on hold after recovery. Earlier execution is unverified.",
|
|
73
75
|
"not-found": "There's no such Ship.",
|
|
74
76
|
"wrong-state": "This Ship can't do that now.",
|
|
75
77
|
"cancelled": "The merge was stopped for good.",
|
|
@@ -128,6 +130,23 @@ function destinationOf(store, repo) {
|
|
|
128
130
|
return null;
|
|
129
131
|
return { repo: grant.githubRepo, remote: grant.remote, base: grant.base, method: grant.mergeMethod ?? "squash", capabilities: [...grant.capabilities].sort(), draft: grant.draft };
|
|
130
132
|
}
|
|
133
|
+
const shellWord = (text) => /^[A-Za-z0-9_./~+@%=:,-]+$/.test(text) ? text : `'${text.replace(/'/g, "'\\''")}'`;
|
|
134
|
+
export function flexibleShipNeeds(store, repo) {
|
|
135
|
+
const noCheck = store.liveVerifyCommand(repo) === null;
|
|
136
|
+
const noPullRequests = destinationOf(store, repo) === null;
|
|
137
|
+
if (!noCheck && !noPullRequests)
|
|
138
|
+
return null;
|
|
139
|
+
const setCheck = `toolroll verify set --repo ${shellWord(repo)} --command "<your test command>"`;
|
|
140
|
+
const setPullRequests = `toolroll publish setup --repo ${shellWord(repo)} --yes`;
|
|
141
|
+
if (noCheck && noPullRequests)
|
|
142
|
+
return { reason: "no-check", short: "Needs a check command and pull requests, which this project doesn't have yet.",
|
|
143
|
+
message: `This project has no check command and can't open pull requests yet, and Ship needs both. Set a check with \`${setCheck}\`, then turn on pull requests with \`${setPullRequests}\` (or both in Settings → Projects). Nothing was shipped.` };
|
|
144
|
+
if (noCheck)
|
|
145
|
+
return { reason: "no-check", short: "Needs a check command, which this project doesn't have yet.",
|
|
146
|
+
message: `This project has no check command yet, and Ship needs one: Toolroll merges only once it passes. Set one with \`${setCheck}\` (or in Settings → Projects). Nothing was shipped.` };
|
|
147
|
+
return { reason: "no-publishing", short: "Needs pull requests, which this project can't open yet.",
|
|
148
|
+
message: `This project can't open pull requests yet, and Ship needs them: the merge goes through one. Turn them on with \`${setPullRequests}\` (or in Settings → Projects). Nothing was shipped.` };
|
|
149
|
+
}
|
|
131
150
|
export async function flexibleShipTerms(store, input) {
|
|
132
151
|
const thread = flexibleThread(store, input.thread);
|
|
133
152
|
if (thread === null)
|
|
@@ -352,8 +371,10 @@ function shipOfTask(store, taskId) {
|
|
|
352
371
|
}
|
|
353
372
|
const inFlight = new Set();
|
|
354
373
|
export const FLEXIBLE_STALE_MERGE_MS = 15 * 60_000;
|
|
355
|
-
function cancelArmed(store, ship, why, now, actor = "toolroll") {
|
|
374
|
+
function cancelArmed(store, ship, why, now, actor = "toolroll", recoveryGuard = false) {
|
|
356
375
|
return store.transact(() => {
|
|
376
|
+
if (recoveryGuard)
|
|
377
|
+
proveShipCheckRecovery(store, ship.taskId);
|
|
357
378
|
const moved = store.handle.prepare("UPDATE flexible_ship SET state = 'cancelled', detail = ?, state_at = ? WHERE id = ? AND state IN ('armed', 'completed')").run(why.slice(0, 2000), now.toISOString(), ship.id);
|
|
358
379
|
if (Number(moved.changes) !== 1)
|
|
359
380
|
return false;
|
|
@@ -419,7 +440,19 @@ export async function mergeArmedFlexible(store, input) {
|
|
|
419
440
|
return { ok: true, state: "waiting", why: "its merge is under way; its outcome is read back from GitHub" };
|
|
420
441
|
if (found.state !== "armed" && found.state !== "completed")
|
|
421
442
|
return refuse("wrong-state", found.state);
|
|
422
|
-
|
|
443
|
+
if (shipCheckRecoveryHeld(store, found.taskId))
|
|
444
|
+
return refuse("recovery-held");
|
|
445
|
+
const stop = (why) => {
|
|
446
|
+
try {
|
|
447
|
+
cancelArmed(store, found, why, clock(), "toolroll", true);
|
|
448
|
+
}
|
|
449
|
+
catch (error) {
|
|
450
|
+
if (error instanceof ShipStop)
|
|
451
|
+
return error.refusal;
|
|
452
|
+
throw error;
|
|
453
|
+
}
|
|
454
|
+
return refuse("cancelled", why);
|
|
455
|
+
};
|
|
423
456
|
const lapsed = authorityProblem(store, found);
|
|
424
457
|
if (lapsed !== null)
|
|
425
458
|
return stop(lapsed);
|
|
@@ -430,8 +463,18 @@ export async function mergeArmedFlexible(store, input) {
|
|
|
430
463
|
catch {
|
|
431
464
|
return { ok: true, state: "waiting", why: "the project can't be read" };
|
|
432
465
|
}
|
|
433
|
-
const read = hardenedGit(input.runner ?? run, "read", { repo: project });
|
|
434
|
-
|
|
466
|
+
const read = hardenedGit((file, args, options) => { proveShipCheckRecovery(store, found.taskId); return (input.runner ?? run)(file, args, options); }, "read", { repo: project });
|
|
467
|
+
let based;
|
|
468
|
+
try {
|
|
469
|
+
based = await read("git", ["--no-replace-objects", "merge-base", "--is-ancestor", found.base, `refs/heads/${found.terms.github.base}`], { cwd: project, timeoutMs: 30_000 });
|
|
470
|
+
}
|
|
471
|
+
catch (error) {
|
|
472
|
+
if (error instanceof ShipStop)
|
|
473
|
+
return error.refusal;
|
|
474
|
+
throw error;
|
|
475
|
+
}
|
|
476
|
+
if (shipCheckRecoveryHeld(store, found.taskId))
|
|
477
|
+
return refuse("recovery-held");
|
|
435
478
|
if (based.code === 1)
|
|
436
479
|
return stop(`its starting commit is no longer on ${found.terms.github.base}`);
|
|
437
480
|
if (based.code !== 0)
|
|
@@ -457,15 +500,17 @@ export async function mergeArmedFlexible(store, input) {
|
|
|
457
500
|
const again = rowOfTask(store, input.taskId);
|
|
458
501
|
if (again === null || again.state !== "armed")
|
|
459
502
|
throw new ShipStop(refuse("wrong-state"));
|
|
503
|
+
proveShipCheckRecovery(store, again.taskId);
|
|
460
504
|
const problem = authorityProblem(store, again);
|
|
461
505
|
if (problem !== null) {
|
|
462
|
-
cancelArmed(store, again, problem, clock());
|
|
506
|
+
cancelArmed(store, again, problem, clock(), "toolroll", true);
|
|
463
507
|
cancelled = refuse("cancelled", problem);
|
|
464
508
|
return;
|
|
465
509
|
}
|
|
466
510
|
const who = verifyApproverStanding(store, again.approvedBy, again.approvedGeneration, [again.repo]);
|
|
467
511
|
if (!who.ok)
|
|
468
512
|
throw new ShipStop(refuse("not-an-approver"));
|
|
513
|
+
proveShipCheckRecovery(store, again.taskId);
|
|
469
514
|
const opened = completeAndOpenPullRequest(store, { taskId: input.taskId, digest: receipt.digest, runId: newest.id, who: who.who, root: input.root }, clock());
|
|
470
515
|
if (!opened.ok)
|
|
471
516
|
throw new ShipStop(refuse("wrong-state", opened.message));
|
|
@@ -473,6 +518,7 @@ export async function mergeArmedFlexible(store, input) {
|
|
|
473
518
|
throw new ShipStop(refuse("wrong-state", "its pull request would go somewhere other than the shipped commit and destination"));
|
|
474
519
|
}
|
|
475
520
|
const at = clock().toISOString();
|
|
521
|
+
proveShipCheckRecovery(store, again.taskId);
|
|
476
522
|
store.handle.prepare("UPDATE flexible_ship SET state = 'completed', merge_head = ?, merge_at = ?, check_receipt = ?, state_at = ? WHERE id = ? AND state = 'armed'").run(head, at, check, at, again.id);
|
|
477
523
|
store.recordAction({ at, actor: again.approvedBy, repo: again.repo, taskId: input.taskId, runId: newest.id, source: "work", action: "flexible ship completed", outcome: head,
|
|
478
524
|
detail: `ship ${again.id} · checked head ${head} · check receipt ${check} · pull request owed to ${again.terms.github.repo} ${again.terms.github.base}` });
|
|
@@ -480,7 +526,7 @@ export async function mergeArmedFlexible(store, input) {
|
|
|
480
526
|
}
|
|
481
527
|
catch (error) {
|
|
482
528
|
if (error instanceof ShipStop)
|
|
483
|
-
return error.refusal.reason === "cancelled" ? error.refusal : { ok: true, state: "waiting", why: error.refusal.message };
|
|
529
|
+
return error.refusal.reason === "cancelled" || error.refusal.reason === "recovery-held" ? error.refusal : { ok: true, state: "waiting", why: error.refusal.message };
|
|
484
530
|
throw error;
|
|
485
531
|
}
|
|
486
532
|
if (cancelled !== null)
|
|
@@ -499,24 +545,38 @@ export async function mergeArmedFlexible(store, input) {
|
|
|
499
545
|
const prNumber = publication.prNumber;
|
|
500
546
|
const token = randomBytes(16).toString("hex");
|
|
501
547
|
const destination = (seen) => pullRequestElsewhere(found, seen, prNumber) ?? (seen.head !== found.mergeHead ? "its pull request on GitHub shows another commit than the one whose check passed" : null);
|
|
548
|
+
if (shipCheckRecoveryHeld(store, found.taskId))
|
|
549
|
+
return refuse("recovery-held");
|
|
502
550
|
inFlight.add(token);
|
|
503
551
|
let merged;
|
|
504
552
|
try {
|
|
505
553
|
merged = await mergePullRequest(store, { runId: newest.id, by: found.approvedBy, flexibleShip: found.id, flexibleToken: token, clock, destination, ...(input.exec === undefined ? {} : { exec: input.exec }),
|
|
506
554
|
proceed: seen => reserveMerge(store, { ship: found.id, token, runId: newest.id, root: input.root, now: clock(), seen, prNumber }) });
|
|
507
555
|
}
|
|
556
|
+
catch (error) {
|
|
557
|
+
if (error instanceof ShipStop)
|
|
558
|
+
return error.refusal;
|
|
559
|
+
throw error;
|
|
560
|
+
}
|
|
508
561
|
finally {
|
|
509
562
|
inFlight.delete(token);
|
|
510
563
|
}
|
|
511
564
|
const landedElsewhere = merged.ok ? (merged.seen === undefined ? "GitHub didn't say where it merged" : destination(merged.seen)) : merged.reason === "elsewhere" ? merged.message : null;
|
|
512
565
|
if (landedElsewhere !== null) {
|
|
566
|
+
let held = false;
|
|
513
567
|
store.transact(() => {
|
|
568
|
+
if (shipCheckRecoveryHeld(store, found.taskId)) {
|
|
569
|
+
held = true;
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
514
572
|
const moved = store.handle.prepare("UPDATE flexible_ship SET state = 'cancelled', merge_token = NULL, merge_reserved_at = NULL, detail = ?, state_at = ? WHERE id = ? AND state IN ('completed', 'merging')")
|
|
515
573
|
.run(`${landedElsewhere} (GitHub reports it merged there, not as this Ship's merge)`.slice(0, 2000), clock().toISOString(), found.id);
|
|
516
574
|
if (Number(moved.changes) === 1)
|
|
517
575
|
store.recordAction({ at: clock().toISOString(), actor: "toolroll", repo: found.repo, taskId: input.taskId, runId: newest.id, source: "policy",
|
|
518
576
|
action: "flexible merge cancelled", outcome: "merged-elsewhere", detail: `ship ${found.id} · ${landedElsewhere}`.slice(0, 2000) });
|
|
519
577
|
});
|
|
578
|
+
if (held)
|
|
579
|
+
return { ok: true, state: "waiting", why: WORDS["recovery-held"] };
|
|
520
580
|
return refuse("cancelled", landedElsewhere);
|
|
521
581
|
}
|
|
522
582
|
const after = rowOfTask(store, input.taskId);
|
|
@@ -540,10 +600,11 @@ function reserveMerge(store, input) {
|
|
|
540
600
|
const ship = readRow(store.handle.prepare("SELECT * FROM flexible_ship WHERE id = ?").get(input.ship));
|
|
541
601
|
if (ship === null || ship.state !== "completed" || ship.taskId === null)
|
|
542
602
|
return false;
|
|
603
|
+
proveShipCheckRecovery(store, ship.taskId);
|
|
543
604
|
const elsewhere = pullRequestElsewhere(ship, input.seen, input.prNumber);
|
|
544
605
|
const problem = elsewhere ?? authorityProblem(store, ship);
|
|
545
606
|
if (problem !== null) {
|
|
546
|
-
cancelArmed(store, ship, problem, input.now);
|
|
607
|
+
cancelArmed(store, ship, problem, input.now, "toolroll", true);
|
|
547
608
|
return false;
|
|
548
609
|
}
|
|
549
610
|
const newest = newestRun(store, ship.taskId);
|
|
@@ -552,6 +613,7 @@ function reserveMerge(store, input) {
|
|
|
552
613
|
if (passingCheck(store, input.root, newest.id, ship, input.now) !== ship.checkReceipt)
|
|
553
614
|
return false;
|
|
554
615
|
const at = input.now.toISOString();
|
|
616
|
+
proveShipCheckRecovery(store, ship.taskId);
|
|
555
617
|
const moved = store.handle.prepare("UPDATE flexible_ship SET state = 'merging', merge_token = ?, merge_reserved_at = ?, state_at = ? WHERE id = ? AND state = 'completed'").run(input.token, at, at, ship.id);
|
|
556
618
|
if (Number(moved.changes) !== 1)
|
|
557
619
|
return false;
|
|
@@ -582,7 +644,12 @@ async function settleMerging(store, ship, exec, clock) {
|
|
|
582
644
|
const elsewhere = pullRequestElsewhere(ship, { base, url }, publication.prNumber);
|
|
583
645
|
const outcome = elsewhere !== null ? "cancelled" : state === "MERGED" ? "merged" : state === "OPEN" && headOid === ship.mergeHead ? "completed" : "cancelled";
|
|
584
646
|
const why = elsewhere !== null ? `${elsewhere}${state === "MERGED" ? " (GitHub merged it there)" : ""}` : `its pull request is ${state.toLowerCase()} on GitHub${headOid !== ship.mergeHead ? " on another commit" : ""}`;
|
|
647
|
+
let held = false;
|
|
585
648
|
store.transact(() => {
|
|
649
|
+
if (shipCheckRecoveryHeld(store, ship.taskId) && !(state === "MERGED" && elsewhere === null && headOid === ship.mergeHead)) {
|
|
650
|
+
held = true;
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
586
653
|
const moved = store.handle.prepare(`UPDATE flexible_ship SET state = ?, merge_token = NULL, merge_reserved_at = NULL, state_at = ?${outcome === "cancelled" ? ", detail = ?" : ""} WHERE id = ? AND state = 'merging' AND merge_token = ?`)
|
|
587
654
|
.run(...(outcome === "cancelled" ? [outcome, at, why.slice(0, 2000), ship.id, ship.mergeToken] : [outcome, at, ship.id, ship.mergeToken]));
|
|
588
655
|
if (Number(moved.changes) !== 1)
|
|
@@ -590,6 +657,8 @@ async function settleMerging(store, ship, exec, clock) {
|
|
|
590
657
|
store.recordAction({ at, actor: "toolroll", repo: ship.repo, taskId: ship.taskId, runId: newest?.id ?? null, source: "policy", action: outcome === "merged" ? "flexible merged" : outcome === "completed" ? "flexible merge released" : "flexible merge cancelled",
|
|
591
658
|
outcome: outcome === "merged" ? commit ?? "merged" : outcome, detail: `ship ${ship.id} · read back from GitHub: ${state.toLowerCase()}` });
|
|
592
659
|
});
|
|
660
|
+
if (held)
|
|
661
|
+
return { ok: true, state: "waiting", why: WORDS["recovery-held"] };
|
|
593
662
|
if (outcome === "merged")
|
|
594
663
|
return { ok: true, state: "merged" };
|
|
595
664
|
if (outcome === "completed")
|
|
@@ -747,3 +816,14 @@ export async function removeFlexibleImport(store, input) {
|
|
|
747
816
|
});
|
|
748
817
|
return { ok: true };
|
|
749
818
|
}
|
|
819
|
+
function shipCheckRecoveryHeld(store, taskId) {
|
|
820
|
+
if (taskId === null || store.handle.prepare("SELECT 1 FROM action_ledger WHERE action = ? LIMIT 1").get(CHECK_RECOVERY_HELD) === undefined)
|
|
821
|
+
return false;
|
|
822
|
+
const ref = store.lookupRef(taskId);
|
|
823
|
+
const seed = ref === null ? undefined : store.handle.prepare("SELECT id FROM run WHERE task_ref = ? ORDER BY id DESC LIMIT 1").get(ref.id);
|
|
824
|
+
return seed === undefined || readCheckRecoveryHoldsForRun(store, Number(seed["id"])).kind !== "no-evidence";
|
|
825
|
+
}
|
|
826
|
+
function proveShipCheckRecovery(store, taskId) {
|
|
827
|
+
if (shipCheckRecoveryHeld(store, taskId))
|
|
828
|
+
throw new ShipStop(refuse("recovery-held"));
|
|
829
|
+
}
|
package/dist/flexible-start.js
CHANGED
|
@@ -4,6 +4,7 @@ import { FLEXIBLE_LAPSE_WORDS, FLEXIBLE_LEVEL_WORDS, FLEXIBLE_UNAVAILABLE, flexi
|
|
|
4
4
|
import { flexibleNetworkDigest, flexibleThreadNetwork } from "./flexible-launcher.js";
|
|
5
5
|
import { FLEXIBLE_RELAY_UPSTREAMS } from "./flexible-relay-upstreams.js";
|
|
6
6
|
import { flexibleSignInBilling, flexibleSignInStatus } from "./flexible-sign-in.js";
|
|
7
|
+
import { flexibleShipNeeds } from "./flexible-ship.js";
|
|
7
8
|
import { networkWords } from "./egress.js";
|
|
8
9
|
import { agentModelName } from "./model-names.js";
|
|
9
10
|
import { CLAUDE_EXACT } from "./model-catalog.js";
|
|
@@ -61,6 +62,7 @@ export function flexibleStartCard(store, input) {
|
|
|
61
62
|
const open = network.mode === "open";
|
|
62
63
|
const project = store.handle.prepare("SELECT name FROM project WHERE path = ?").get(input.repo)?.["name"];
|
|
63
64
|
const caps = terms.caps;
|
|
65
|
+
const shipNeeds = flexibleShipNeeds(store, input.repo);
|
|
64
66
|
const decisions = [
|
|
65
67
|
{ label: "Project", words: typeof project === "string" ? project : input.repo, lines: typeof project === "string" ? [input.repo] : [], fields: ["flexible.repo"] },
|
|
66
68
|
{ label: "Level", words: `${FLEXIBLE_LEVEL_WORDS.full}: no permission prompts inside the sandbox`, lines: [FULL_ACCESS_WORDS], fields: ["flexible.level"], risky: true },
|
|
@@ -75,7 +77,8 @@ export function flexibleStartCard(store, input) {
|
|
|
75
77
|
caps.measuredMicrousdPerDay === null ? "No dollar limit: a turn runs until it finishes." : `New turns stop once today's measured spend reaches ${money(caps.measuredMicrousdPerDay)}; a turn already running may go past it.`,
|
|
76
78
|
FLEXIBLE_UNKNOWN_COST_WORDS,
|
|
77
79
|
], fields: ["flexible.caps"], ...(caps.measuredMicrousdPerDay === null ? { risky: true } : {}) },
|
|
78
|
-
{ label: "Ship", words: FLEXIBLE_SHIP_WORDS, fields: ["flexible.ship"] }
|
|
80
|
+
shipNeeds === null ? { label: "Ship", words: FLEXIBLE_SHIP_WORDS, fields: ["flexible.ship"] }
|
|
81
|
+
: { label: "Ship", words: shipNeeds.short, lines: [`After that: ${lowerFirst(FLEXIBLE_SHIP_WORDS)}`], fields: ["flexible.ship"] },
|
|
79
82
|
{ label: "Terms", words: `this project's Flexible terms, turned on by ${terms.signer}`, lines: [`They last until someone turns them off or lowers them, or ${terms.signer}'s account or access changes.`], fields: ["flexible.terms"] },
|
|
80
83
|
];
|
|
81
84
|
if (runtime === "interactive") {
|
package/dist/flexible-thread.js
CHANGED
|
@@ -5,7 +5,7 @@ import { homedir, tmpdir } from "node:os";
|
|
|
5
5
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
6
6
|
import { flexibleAvailable } from "./flexible-available.js";
|
|
7
7
|
import { FLEXIBLE_UNAVAILABLE } from "./flexible.js";
|
|
8
|
-
import { buildCacheEnv, fenceFor, FLEXIBLE_THREADS_DIR, grantFolder, PROTECTED_DIRS, PROTECTED_FILES, runFolders, srtTermsOf } from "./agent-fence.js";
|
|
8
|
+
import { buildCacheEnv, fenceFor, FLEXIBLE_THREADS_DIR, grantFolder, plainAgentEnv, PROTECTED_DIRS, PROTECTED_FILES, runFolders, srtTermsOf } from "./agent-fence.js";
|
|
9
9
|
import { ACP_AGENTS, ACP_PROVIDER_IDS } from "./acp-agents.js";
|
|
10
10
|
import { confined, ContainmentRefusal, run } from "./exec.js";
|
|
11
11
|
import { SANDBOX_LAUNCH_SPEC, SEATBELT_NO_KEYCHAIN } from "./sandbox-runtime.js";
|
|
@@ -437,9 +437,8 @@ export function flexibleThreadFence(store, input) {
|
|
|
437
437
|
return { ok: true, launch: { ...made, fenceGrants: grants }, paths, thread };
|
|
438
438
|
}
|
|
439
439
|
export function flexibleThreadEnv(paths, proxy, base = process.env) {
|
|
440
|
-
const kept = ["PATH", "LANG", "LC_ALL", "LC_CTYPE", "LC_MESSAGES", "TERM", "TZ", "USER", "LOGNAME", "SHELL", "COLORTERM"];
|
|
441
440
|
return {
|
|
442
|
-
...
|
|
441
|
+
...plainAgentEnv(base),
|
|
443
442
|
HOME: real(homedir()), TMPDIR: paths.tmp, ...buildCacheEnv(paths.cache),
|
|
444
443
|
GIT_TERMINAL_PROMPT: "0", GIT_CONFIG_NOSYSTEM: "1",
|
|
445
444
|
...proxy,
|
package/dist/flexible-turns.js
CHANGED
|
@@ -173,10 +173,22 @@ export function admitFlexibleTurn(store, input) {
|
|
|
173
173
|
const delegation = flexibleDelegationAtUse(store, { repo, starter: input.starter, digest: input.digest, level: input.level, freshProof: input.freshProof });
|
|
174
174
|
if (!delegation.ok)
|
|
175
175
|
return delegation;
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
const attempts = store.handle.prepare(`SELECT * FROM thread_turn WHERE thread = ? AND (request_key = ? OR substr(request_key, 1, ?) = ?) AND status <> 'withdrawn' ORDER BY seq DESC`)
|
|
177
|
+
.all(input.thread, input.requestKey, input.requestKey.length + AGAIN.length, `${input.requestKey}${AGAIN}`);
|
|
178
|
+
let same = readTurn(attempts[0]);
|
|
179
|
+
let requestKey = input.requestKey;
|
|
180
|
+
let resent;
|
|
181
|
+
if (same !== null && same.status !== "admitted") {
|
|
182
|
+
const detail = text(attempts[0]["end_detail"]);
|
|
183
|
+
if (same.status === "running" || turnLaunched(store, same.id))
|
|
184
|
+
return { ok: false, reason: "already-sent", message: deliveredWords(same, detail) };
|
|
185
|
+
requestKey = `${input.requestKey}${AGAIN}${attempts.length}`;
|
|
186
|
+
if (requestKey.length > 128)
|
|
179
187
|
return refuse("already-sent");
|
|
188
|
+
resent = { seq: same.seq, detail };
|
|
189
|
+
same = null;
|
|
190
|
+
}
|
|
191
|
+
if (same !== null) {
|
|
180
192
|
if (same.termsId !== delegation.termsId) {
|
|
181
193
|
withdrawTurn(store, same, "admitted under terms that have since ended", now.toISOString());
|
|
182
194
|
}
|
|
@@ -219,13 +231,13 @@ export function admitFlexibleTurn(store, input) {
|
|
|
219
231
|
const seq = Number(store.handle.prepare("SELECT COALESCE(MAX(seq), 0) + 1 AS n FROM thread_turn WHERE thread = ?").get(input.thread)["n"]);
|
|
220
232
|
const at = now.toISOString();
|
|
221
233
|
store.handle.prepare(`INSERT INTO thread_turn (id, thread, seq, repo, owner, owner_generation, terms_id, terms_digest, level, provider, model, billing, request_key, holder, admitted_at, utc_day, rail_reserved, status)
|
|
222
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'admitted')`).run(id, input.thread, seq, repo, input.starter.name, input.starter.generation, delegation.termsId, delegation.digest, input.level, input.provider, input.model, input.billing,
|
|
234
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'admitted')`).run(id, input.thread, seq, repo, input.starter.name, input.starter.generation, delegation.termsId, delegation.digest, input.level, input.provider, input.model, input.billing, requestKey, input.holder, at, day, railReserved);
|
|
223
235
|
if (chosenLevel !== null && FLEXIBLE_LEVELS.indexOf(input.level) > FLEXIBLE_LEVELS.indexOf(chosenLevel)) {
|
|
224
236
|
store.handle.prepare("UPDATE flexible_thread_level SET level = ?, set_by = ?, set_at = ? WHERE thread = ?").run(input.level, input.starter.name, at, input.thread);
|
|
225
237
|
}
|
|
226
238
|
store.recordAction({ at, actor: input.starter.name, repo, taskId: null, runId: null, source: "policy", action: "flexible turn admitted", outcome: "admitted",
|
|
227
239
|
detail: `thread ${input.thread} · turn ${seq} · ${input.level} · ${input.provider} ${input.model} · ${input.billing} · terms ${delegation.digest}` });
|
|
228
|
-
return { ok: true, turn: id, seq, replayed: false };
|
|
240
|
+
return { ok: true, turn: id, seq, replayed: false, ...(resent === undefined ? {} : { resent }) };
|
|
229
241
|
});
|
|
230
242
|
}
|
|
231
243
|
function countsRefusal(store, repo, person, terms, now) {
|
|
@@ -502,3 +514,12 @@ export function interruptFlexibleTurnSignIn(store, input) {
|
|
|
502
514
|
return { ok: true, interrupted: done };
|
|
503
515
|
});
|
|
504
516
|
}
|
|
517
|
+
const AGAIN = ":again-";
|
|
518
|
+
function turnLaunched(store, turn) {
|
|
519
|
+
return store.handle.prepare("SELECT 1 AS hit FROM action_ledger WHERE action = 'flexible agent launched' AND detail LIKE ? LIMIT 1").get(`turn ${turn} · %`) !== undefined;
|
|
520
|
+
}
|
|
521
|
+
function deliveredWords(turn, detail) {
|
|
522
|
+
const state = turn.status === "running" ? "it is still working" : turn.status === "finished" ? "it finished" : turn.status === "interrupted" ? "it was stopped" : "its outcome is unknown";
|
|
523
|
+
const why = detail === null || detail.trim() === "" || turn.status === "running" || turn.status === "finished" ? "" : ` (${detail.trim().slice(0, 300)})`;
|
|
524
|
+
return `That message already reached the agent in turn ${turn.seq}, and ${state}${why}. Nothing new was started.`;
|
|
525
|
+
}
|
package/dist/flow-triggers.js
CHANGED
|
@@ -479,6 +479,12 @@ export function removeFlowTrigger(store, trigger, now, dir, by) {
|
|
|
479
479
|
function polled(config) {
|
|
480
480
|
return config.kind === "email" || ((config.kind === "github" || config.kind === "linear") && config.delivery === "poll");
|
|
481
481
|
}
|
|
482
|
+
export function canCheckTrigger(config) {
|
|
483
|
+
return polled(config) || (config.kind === "schedule" && config.script !== undefined) || config.kind === "plane-review";
|
|
484
|
+
}
|
|
485
|
+
export function canPressTrigger(trigger) {
|
|
486
|
+
return trigger.state === "active" && triggerConfigOf(trigger)?.kind === "button";
|
|
487
|
+
}
|
|
482
488
|
function startZone(config, definition) {
|
|
483
489
|
return config.zone !== null && definition.stages.some(one => one.id === config.zone) ? config.zone : definition.start;
|
|
484
490
|
}
|
|
@@ -620,16 +626,19 @@ export async function runFlowTriggers(store, repo, now, io) {
|
|
|
620
626
|
}
|
|
621
627
|
export async function checkFlowTriggerNow(store, trigger, now, io) {
|
|
622
628
|
const config = triggerConfigOf(trigger);
|
|
623
|
-
|
|
629
|
+
const refused = { ok: false, said: "Only GitHub, Linear and email triggers that are checked, schedules that run a script, and plane reviews can be run now." };
|
|
630
|
+
if (config === null || !canCheckTrigger(config))
|
|
631
|
+
return refused;
|
|
632
|
+
if (config.kind === "schedule" && config.script !== undefined) {
|
|
624
633
|
const fired = await fireScript(store, trigger, config, now, io, false);
|
|
625
634
|
return { ok: fired.ok, said: fired.said };
|
|
626
635
|
}
|
|
627
|
-
if (config
|
|
636
|
+
if (config.kind === "plane-review") {
|
|
628
637
|
const fired = await firePlaneReview(store, trigger, config, now, false);
|
|
629
638
|
return { ok: true, said: fired.said };
|
|
630
639
|
}
|
|
631
|
-
if (
|
|
632
|
-
return
|
|
640
|
+
if (!polled(config))
|
|
641
|
+
return refused;
|
|
633
642
|
const checked = await checkTrigger(store, trigger, config, now, io);
|
|
634
643
|
return { ok: checked.ok, said: checked.said };
|
|
635
644
|
}
|
package/dist/flows-ui.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { liveAttemptOf, steerControlsFor } from "./steer-controls.js";
|
|
2
2
|
import { draftFor, flowDefinitionOf, NO_REPLY_MOVE_ON } from "./flow-engine.js";
|
|
3
3
|
import { describeStandingOrder } from "./flow-schedule.js";
|
|
4
|
-
import { describeTrigger, triggerHeadline, FLOW_TRIGGER_KINDS, FLOW_TRIGGER_WORDS, githubRepoOf, HOOK_PATH, hookReady, planeStatusLink, readHooksBase, readLinearKey, senderOf, takesDeliveries, triggerConfigOf } from "./flow-triggers.js";
|
|
4
|
+
import { canCheckTrigger, canPressTrigger, describeTrigger, triggerHeadline, FLOW_TRIGGER_KINDS, FLOW_TRIGGER_WORDS, githubRepoOf, HOOK_PATH, hookReady, planeStatusLink, readHooksBase, readLinearKey, senderOf, takesDeliveries, triggerConfigOf } from "./flow-triggers.js";
|
|
5
5
|
import { SENDER_WORDS } from "./webhook-signing.js";
|
|
6
6
|
import { READER_CAPTURED } from "./webhook-readers.js";
|
|
7
7
|
import { hostOf, linkWords, provedWords, snapshotOf } from "./task-source.js";
|
|
@@ -21,7 +21,7 @@ import { labelOf, nameOf } from "./subagent-admin.js";
|
|
|
21
21
|
import { callWords, receiptWords } from "./subagent-tools.js";
|
|
22
22
|
import { undoFor } from "./subagent-week.js";
|
|
23
23
|
import { flowCardTaskLine } from "./flow-card-task.js";
|
|
24
|
-
import { unattendedViewOf } from "./flow-unattended.js";
|
|
24
|
+
import { activeUnattendedGrant, unattendedViewOf } from "./flow-unattended.js";
|
|
25
25
|
import { browserViewOf } from "./flow-browser.js";
|
|
26
26
|
import { readFlowSecrets } from "./flow-secrets.js";
|
|
27
27
|
import { html, htmlString, joinHtml, postForm } from "./html.js";
|
|
@@ -73,21 +73,28 @@ function nextWords(at, now) {
|
|
|
73
73
|
const hours = Math.round(minutes / 60);
|
|
74
74
|
return hours < 24 ? `in ${hours} h` : `in ${Math.round(hours / 24)} day${Math.round(hours / 24) === 1 ? "" : "s"}`;
|
|
75
75
|
}
|
|
76
|
+
function oneTriggerWords(store, trigger) {
|
|
77
|
+
const config = triggerConfigOf(trigger);
|
|
78
|
+
if (config === null)
|
|
79
|
+
return null;
|
|
80
|
+
return config.kind === "button" ? `When someone presses ${config.label}` : triggerHeadline(config, store).name;
|
|
81
|
+
}
|
|
76
82
|
function triggerWords(store, triggers) {
|
|
77
83
|
const shown = triggers.filter(one => one.state === "active");
|
|
78
84
|
const pick = shown.length > 0 ? shown : triggers.filter(one => one.state === "paused");
|
|
79
|
-
const words = pick.flatMap(one => {
|
|
80
|
-
const config = triggerConfigOf(one);
|
|
81
|
-
if (config === null)
|
|
82
|
-
return [];
|
|
83
|
-
return [config.kind === "button" ? `When someone presses ${config.label}` : triggerHeadline(config, store).name];
|
|
84
|
-
});
|
|
85
|
+
const words = pick.flatMap(one => { const said = oneTriggerWords(store, one); return said === null ? [] : [said]; });
|
|
85
86
|
if (words.length === 0)
|
|
86
87
|
return "Cards added by hand";
|
|
87
88
|
return words.length === 1 ? words[0] : `${words[0]} and ${words.length - 1} more`;
|
|
88
89
|
}
|
|
89
90
|
const FLOW_LIST_GROUPS = [["needs", "Needs you"], ["running", "Running"], ["on", "Turned on"], ["paused", "Paused"]];
|
|
90
|
-
|
|
91
|
+
export const AUTOMATIONS_MAX = 100;
|
|
92
|
+
export const AUTOMATION_OUTCOME_MAX = 200;
|
|
93
|
+
const isoOrNull = (at) => {
|
|
94
|
+
const ms = at === null ? NaN : Date.parse(at);
|
|
95
|
+
return Number.isFinite(ms) ? new Date(ms).toISOString() : null;
|
|
96
|
+
};
|
|
97
|
+
function automationFacts(store, flow, now) {
|
|
91
98
|
const cards = store.flowCards(flow.id, false);
|
|
92
99
|
const definition = flowDefinitionOf(flow);
|
|
93
100
|
const kindOf = (card) => definition?.stages.find(one => one.id === card.stage)?.kind ?? "";
|
|
@@ -96,23 +103,50 @@ function flowListRow(store, flow, now, options) {
|
|
|
96
103
|
const active = triggers.filter(one => one.state === "active");
|
|
97
104
|
const button = active.flatMap(one => { const config = triggerConfigOf(one); return config?.kind === "button" ? [{ id: one.id, label: config.label }] : []; })[0];
|
|
98
105
|
const trouble = troubleWords(flowInsights(store, flow, now, 7)) ?? nightlyHealthOf(store, flow);
|
|
99
|
-
const starts = triggerWords(store, triggers);
|
|
100
106
|
const next = active.map(one => one.nextAt).filter((one) => one !== null).sort()[0];
|
|
101
|
-
const
|
|
107
|
+
const group = waiting.length > 0 ? "needs" : cards.length > 0 ? "running" : active.length > 0 ? "on" : "paused";
|
|
108
|
+
const grant = triggers.some(one => one.state === "paused") ? activeUnattendedGrant(store, flow.id, now) : null;
|
|
109
|
+
const covered = new Set(grant?.terms.triggers.map(one => one.id) ?? []);
|
|
110
|
+
const wire = triggers.map(one => {
|
|
111
|
+
const config = triggerConfigOf(one);
|
|
112
|
+
const state = one.state === "active" ? "active" : "paused";
|
|
113
|
+
const nextAt = isoOrNull(one.nextAt);
|
|
114
|
+
return {
|
|
115
|
+
id: one.id, kind: one.kind, words: oneTriggerWords(store, one) ?? one.kind, state, nextAt, lastAt: isoOrNull(one.lastAt),
|
|
116
|
+
lastOutcome: one.lastOutcome === null ? null : one.lastOutcome.slice(0, AUTOMATION_OUTCOME_MAX), failures: one.failures,
|
|
117
|
+
canPress: canPressTrigger(one), canCheck: state === "active" && config !== null && canCheckTrigger(config),
|
|
118
|
+
label: config?.kind === "button" ? config.label : null, questions: config?.kind === "button" ? [...config.questions] : null,
|
|
119
|
+
resumeRunsNow: state === "paused" && nextAt !== null && Date.parse(nextAt) <= now.getTime() && covered.has(one.id),
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
const automation = {
|
|
123
|
+
id: flow.id, name: flow.name, project: projectName(flow.repo) || null, group, starts: triggerWords(store, triggers), nextAt: next === undefined ? null : isoOrNull(next),
|
|
124
|
+
waiting: waiting.length, inProgress: cards.length, trouble, triggers: wire,
|
|
125
|
+
};
|
|
126
|
+
return { automation, firstWaiting: waiting[0] === undefined ? null : { card: waiting[0], choose: kindOf(waiting[0]) === "choose" }, button, active };
|
|
127
|
+
}
|
|
128
|
+
export function automationsOf(store, flows, now) {
|
|
129
|
+
return flows.slice(0, AUTOMATIONS_MAX).map(flow => automationFacts(store, flow, now).automation);
|
|
130
|
+
}
|
|
131
|
+
function flowListRow(store, flow, now, options) {
|
|
132
|
+
const { automation: facts, firstWaiting, button, active } = automationFacts(store, flow, now);
|
|
133
|
+
const { trouble, starts, waiting } = facts;
|
|
134
|
+
const next = active.map(one => one.nextAt).filter((one) => one !== null).sort()[0];
|
|
135
|
+
const meta = html `${options.showProject ? html `<span>${projectName(flow.repo)}</span>` : ""}${next !== undefined && active.length > 0 && waiting === 0 ? html `<span class="k-num">Next ${nextWords(next, now)}</span>` : ""}`;
|
|
102
136
|
const start = button !== undefined && options.canAct ? btn(button.label, { sm: true, href: `/flows/${flow.id}?start=${button.id}` }) : html ``;
|
|
103
137
|
const plural = (n, one) => `${n} ${one}${n === 1 ? "" : "s"}`;
|
|
104
138
|
const tail = trouble === null ? "" : ` · ${trouble}`;
|
|
105
|
-
if (
|
|
106
|
-
const first =
|
|
107
|
-
const ask =
|
|
108
|
-
const said = waiting
|
|
139
|
+
if (facts.group === "needs" && firstWaiting !== null) {
|
|
140
|
+
const first = firstWaiting.card;
|
|
141
|
+
const ask = firstWaiting.choose ? chip("Choose", "ask") : chip("Approve", "ask");
|
|
142
|
+
const said = waiting === 1 ? `${first.title} waits for your decision` : `${plural(waiting, "card")} wait for your decision`;
|
|
109
143
|
return { group: "needs", row: row({ href: `/flows/${flow.id}`, chip: ask, title: flow.name, desc: `${starts} · ${said}${tail}`, meta, wait: true,
|
|
110
144
|
action: btn("Review", { sm: true, href: `/flows/${flow.id}?card=${first.id}`, attrs: { "aria-label": `Review ${first.title}` } }), attrs: { "data-flow": flow.id } }) };
|
|
111
145
|
}
|
|
112
|
-
if (
|
|
113
|
-
return { group: "running", row: row({ href: `/flows/${flow.id}`, chip: status("running"), title: flow.name, desc: `${starts} · ${plural(
|
|
146
|
+
if (facts.group === "running") {
|
|
147
|
+
return { group: "running", row: row({ href: `/flows/${flow.id}`, chip: status("running"), title: flow.name, desc: `${starts} · ${plural(facts.inProgress, "card")} in progress${tail}`, meta, action: start, attrs: { "data-flow": flow.id } }) };
|
|
114
148
|
}
|
|
115
|
-
if (
|
|
149
|
+
if (facts.group === "on") {
|
|
116
150
|
const failing = active.find(one => one.failures > 0);
|
|
117
151
|
const last = active.filter(one => one.lastAt !== null).sort((a, b) => (b.lastAt ?? "").localeCompare(a.lastAt ?? ""))[0];
|
|
118
152
|
const chipNow = failing !== undefined || trouble !== null ? status("failed") : last === undefined ? chip("Not run yet", "", { dot: false }) : status("finished");
|
|
@@ -120,7 +154,7 @@ function flowListRow(store, flow, now, options) {
|
|
|
120
154
|
: last === undefined ? "not run yet" : `last ran ${agoWords(last.lastAt, now)}${last.lastOutcome ? `: ${last.lastOutcome}` : ""}`;
|
|
121
155
|
return { group: "on", row: row({ href: `/flows/${flow.id}`, chip: chipNow, title: flow.name, desc: `${starts} · ${lastWords}${tail}`, meta, action: start, attrs: { "data-flow": flow.id } }) };
|
|
122
156
|
}
|
|
123
|
-
const paused = triggers.length > 0;
|
|
157
|
+
const paused = facts.triggers.length > 0;
|
|
124
158
|
return { group: "paused", row: row({ href: `/flows/${flow.id}`, chip: chip(paused ? "Paused" : "Off", "", { dot: false }), title: flow.name,
|
|
125
159
|
desc: paused ? `${starts} · paused${tail}` : `${starts} · nothing starts it on its own${tail}`, meta, attrs: { "data-flow": flow.id } }) };
|
|
126
160
|
}
|
|
@@ -334,7 +368,7 @@ export function flowView(store, flow, viewer, selectedCard, setup = { dir: null,
|
|
|
334
368
|
zone: title(config?.zone ?? definition?.start ?? ""), zoneId: config?.zone ?? definition?.start ?? "", state: trigger.state, status: trigger.lastOutcome, statusLink: planeStatusLink(config, trigger.lastOutcome), statusAt: trigger.lastAt, failing: trigger.failures > 0,
|
|
335
369
|
button: config?.kind === "button" ? { label: config.label, questions: config.questions } : null,
|
|
336
370
|
hook: config !== null && takesDeliveries(config) ? hookView(trigger, config, setup.dir) : null,
|
|
337
|
-
checkable:
|
|
371
|
+
checkable: config !== null && canCheckTrigger(config),
|
|
338
372
|
shared: config?.kind === "button" && trigger.hookHash !== null,
|
|
339
373
|
...(config?.kind === "schedule" && config.order !== undefined ? { order: describeStandingOrder(config.order, flow.repo, config.schedule) } : {}),
|
|
340
374
|
};
|