toolroll 0.9.108 → 0.9.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/dist/advanced-view.js +0 -1
- package/dist/agent-detect.js +244 -0
- package/dist/agent-fence.js +47 -5
- package/dist/agent-state.js +5 -2
- package/dist/agentconfig.js +2 -2
- package/dist/approval-summary.js +344 -0
- package/dist/assignment-ui.js +5 -5
- package/dist/assignment.js +5 -2
- package/dist/attest.js +2 -2
- package/dist/browser/terminal.js +1 -1
- package/dist/browser/workspace.css +2 -2
- package/dist/browser/workspace.js +37 -34
- package/dist/browser-crew.js +4 -4
- package/dist/browser-workspace.js +4 -11
- package/dist/builder.js +45 -3
- package/dist/chat-actions.js +24 -17
- package/dist/chat-controls.js +6 -5
- package/dist/chat-core.js +3 -1
- package/dist/chat-decide.js +102 -47
- package/dist/chat-delivery-state.js +2 -0
- package/dist/chat-delivery.js +3 -2
- package/dist/chat-live.js +2 -1
- package/dist/chat-quiet.js +3 -3
- package/dist/chat-task-actions.js +6 -0
- package/dist/chat-voice.js +2 -2
- package/dist/check-report.js +1 -1
- package/dist/cli-help.js +12 -13
- package/dist/cli.js +6 -3
- package/dist/console-chrome.js +10 -3
- package/dist/console-instance.js +10 -1
- package/dist/contracts/console-api.js +14 -8
- package/dist/contracts/engine-api.js +271 -0
- package/dist/contracts/handoff.js +4 -0
- package/dist/coordinator.js +2 -2
- package/dist/decision.js +17 -0
- package/dist/demo-chat.js +1 -1
- package/dist/demo.js +6 -0
- package/dist/design/kit.js +4 -3
- package/dist/discord-api.js +4 -3
- package/dist/discord-chat.js +3 -1
- package/dist/dispatch.js +3 -8
- package/dist/easy-start-args.js +7 -3
- package/dist/easy-start.js +25 -0
- package/dist/egress.js +72 -10
- package/dist/engine-handoff.js +34 -0
- package/dist/engine-reads.js +261 -0
- package/dist/eval-world.js +3 -2
- package/dist/evidence.js +2 -0
- package/dist/fast-start.js +55 -14
- package/dist/fast-terms.js +2 -2
- package/dist/first-run.js +10 -2
- package/dist/flexible-agents.js +234 -0
- package/dist/flexible-answers-schema.js +61 -0
- package/dist/flexible-answers.js +889 -0
- package/dist/flexible-available.js +1 -0
- package/dist/flexible-custody.js +494 -0
- package/dist/flexible-import.js +782 -0
- package/dist/flexible-launch-schema.js +72 -0
- package/dist/flexible-launch.js +331 -0
- package/dist/flexible-launcher.js +88 -0
- package/dist/flexible-levels.js +34 -0
- package/dist/flexible-merge-guard.js +47 -0
- package/dist/flexible-refs.js +47 -0
- package/dist/flexible-relay-cancel.js +19 -0
- package/dist/flexible-relay-schema.js +55 -0
- package/dist/flexible-relay-upstreams.js +36 -0
- package/dist/flexible-relay.js +1032 -0
- package/dist/flexible-schema.js +32 -0
- package/dist/flexible-session.js +732 -0
- package/dist/flexible-ship-schema.js +81 -0
- package/dist/flexible-ship.js +694 -0
- package/dist/flexible-start.js +80 -0
- package/dist/flexible-thread-schema.js +30 -0
- package/dist/flexible-thread.js +676 -0
- package/dist/flexible-turns-schema.js +69 -0
- package/dist/flexible-turns.js +490 -0
- package/dist/flexible-ui.js +44 -0
- package/dist/flexible.js +368 -0
- package/dist/flow-actions.js +6 -4
- package/dist/flow-steps.js +1 -1
- package/dist/flows-cli.js +2 -1
- package/dist/git-views.js +44 -41
- package/dist/guides.js +11 -10
- package/dist/install-mode.js +225 -0
- package/dist/keymap.js +1 -1
- package/dist/lead-context.js +1 -1
- package/dist/lead-doors.js +7 -1
- package/dist/limits-ui.js +8 -1
- package/dist/live-bus.js +70 -13
- package/dist/live-reply.js +6 -0
- package/dist/live-terminal.js +425 -29
- package/dist/local-owner.js +6 -0
- package/dist/model-choices.js +12 -6
- package/dist/needs-you.js +3 -3
- package/dist/nightly-github.js +2 -2
- package/dist/notification-delivery.js +11 -0
- package/dist/operate.js +185 -33
- package/dist/outbound-privacy.js +204 -0
- package/dist/passwordless.js +2 -1
- package/dist/project-delete-ui.js +2 -1
- package/dist/project-delete.js +15 -0
- package/dist/provider-auth.js +1 -1
- package/dist/provider-connection.js +5 -3
- package/dist/publish.js +5 -0
- package/dist/pull-request-flow.js +26 -7
- package/dist/push.js +5 -1
- package/dist/release-card.js +11 -3
- package/dist/release.js +11 -1
- package/dist/result-actions.js +3 -0
- package/dist/result-evidence-readers.js +8 -2
- package/dist/result-review.js +20 -9
- package/dist/route-store.js +2 -2
- package/dist/sandbox-launch.js +32 -8
- package/dist/sandbox-runtime.js +16 -7
- package/dist/sandbox-tools.js +176 -0
- package/dist/scope.js +12 -36
- package/dist/scout-net.js +7 -2
- package/dist/serve.js +90 -40
- package/dist/server/chat.js +9 -9
- package/dist/server/chrome.js +19 -17
- package/dist/server/console.css +33 -6
- package/dist/server/engine-api.js +378 -0
- package/dist/server/flows.js +2 -2
- package/dist/server/guards.js +10 -4
- package/dist/server/home.js +37 -5
- package/dist/server/http.js +11 -2
- package/dist/server/in-place.js +5 -4
- package/dist/server/kit.js +2 -2
- package/dist/server/link-redemption.js +52 -0
- package/dist/server/live.js +100 -10
- package/dist/server/mutation-key.js +21 -7
- package/dist/server/pages.js +129 -74
- package/dist/server/people-tokens.js +17 -41
- package/dist/server/render-chat.js +2 -1
- package/dist/server/render-history.js +18 -4
- package/dist/server/render-new-task.js +4 -4
- package/dist/server/render-pages.js +21 -39
- package/dist/server/render-people.js +2 -2
- package/dist/server/render-projects.js +5 -5
- package/dist/server/render-results.js +30 -14
- package/dist/server/render-tasks.js +155 -155
- package/dist/server/retired-routes.js +37 -4
- package/dist/server/route-policy.js +8 -0
- package/dist/server/route-table.js +43 -5
- package/dist/server/settings-computers.js +140 -0
- package/dist/server/settings-scripts.js +15 -0
- package/dist/server/settings-section-table.js +59 -0
- package/dist/server/settings-sections.js +291 -0
- package/dist/server/settings.js +247 -28
- package/dist/server/task-views.js +55 -15
- package/dist/server/tasks.js +168 -98
- package/dist/server/terminals.js +181 -28
- package/dist/server/welcome.js +40 -14
- package/dist/settings-groups-ui.js +26 -107
- package/dist/settings-proofs.js +18 -11
- package/dist/slack-api.js +4 -3
- package/dist/slack-chat.js +5 -3
- package/dist/spend.js +46 -12
- package/dist/sqlite-telemetry.js +70 -21
- package/dist/status-probe.js +343 -0
- package/dist/store.js +206 -10
- package/dist/task-link.js +64 -0
- package/dist/teams-api.js +4 -3
- package/dist/teams-chat.js +4 -2
- package/dist/telegram-lead.js +2 -1
- package/dist/telegram-live.js +2 -1
- package/dist/telegram-team.js +2 -1
- package/dist/telegram.js +17 -5
- package/dist/trusted-path.js +162 -0
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/dist/tui-launch.js +282 -0
- package/dist/tui-source.js +5 -3
- package/dist/tui.js +2 -2
- package/dist/typed-words-schema.js +18 -0
- package/dist/webhooks.js +8 -4
- package/dist/welcome-facts.js +25 -17
- package/dist/work-index.js +126 -29
- package/dist/work-reads.js +279 -0
- package/dist/workspace-ui.js +5 -0
- package/package.json +4 -2
- package/scripts/crash-canary.mjs +1 -1
- package/scripts/pilot.mjs +1 -1
- package/scripts/provider-canary.mjs +5 -3
package/dist/browser-crew.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { chatControlHref, chatResultHref } from './chat-controls.js';
|
|
2
2
|
import { startBuilderHref } from './needs-you.js';
|
|
3
|
+
import { taskLinkOf } from './task-link.js';
|
|
3
4
|
export function browserWorkActionHref(item) {
|
|
4
5
|
const action = item.primaryAction;
|
|
5
6
|
if (action === null)
|
|
6
7
|
return null;
|
|
7
8
|
const { taskId, runId, decisionId } = action.target;
|
|
8
9
|
if (action.code === 'inspect-findings')
|
|
9
|
-
return
|
|
10
|
+
return taskLinkOf({ task: taskId, anchor: 'findings' });
|
|
10
11
|
if (decisionId !== null)
|
|
11
12
|
return `/d/${decisionId}`;
|
|
12
13
|
if (action.code === 'inspect-decisions')
|
|
@@ -21,9 +22,8 @@ export function browserWorkActionHref(item) {
|
|
|
21
22
|
return chatResultHref(taskId, runId);
|
|
22
23
|
if (action.code === 'open-pr' && /^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/\d+$/.test(item.publicationUrl ?? ''))
|
|
23
24
|
return item.publicationUrl;
|
|
24
|
-
if (runId !== null && (action.code === 'open-pr' || action.code === 'retry-review'))
|
|
25
|
-
return
|
|
26
|
-
}
|
|
25
|
+
if (runId !== null && (action.code === 'open-pr' || action.code === 'retry-review'))
|
|
26
|
+
return taskLinkOf({ task: taskId, run: runId });
|
|
27
27
|
if (runId !== null && (action.code === 'inspect-run' || action.code === 'reconcile-run'))
|
|
28
28
|
return `/r/${runId}`;
|
|
29
29
|
if (action.code === 'start-worker')
|
|
@@ -67,24 +67,17 @@ export function browserProjectsOf(projects) {
|
|
|
67
67
|
if (seen.has(project.path))
|
|
68
68
|
return [];
|
|
69
69
|
seen.add(project.path);
|
|
70
|
-
return [{ name: project.name, path: project.path, href:
|
|
70
|
+
return [{ name: project.name, path: project.path, href: `/?project=${encodeURIComponent(project.path)}`,
|
|
71
71
|
knowledgeHref: `/settings/knowledge?repo=${encodeURIComponent(project.path)}` }];
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
|
-
export function browserNavigationOf(path,
|
|
74
|
+
export function browserNavigationOf(path, needsYou = 0, needsYouLabel) {
|
|
75
75
|
const pathname = path.split('?')[0].split('#')[0];
|
|
76
76
|
const under = (...roots) => roots.some(root => pathname === root || pathname.startsWith(`${root}/`));
|
|
77
77
|
return [
|
|
78
|
-
{ label: '
|
|
78
|
+
{ label: 'Work', href: '/', active: pathname === '/' || under('/tasks', '/t', '/r', '/review', '/d', '/activity', '/morning'),
|
|
79
79
|
...(needsYou > 0 ? { count: needsYou, ...(needsYouLabel === undefined ? {} : { countLabel: needsYouLabel }) } : {}) },
|
|
80
80
|
{ label: 'Chat', href: '/chat', active: under('/chat') },
|
|
81
|
-
{ label: '
|
|
82
|
-
active: under('/tasks', '/t', '/r', '/review') },
|
|
83
|
-
...(advanced ? [
|
|
84
|
-
{ label: 'Flows', href: '/flows', active: under('/flows', '/recipes', '/kits', '/routines') },
|
|
85
|
-
{ label: 'Agents', href: '/agents', active: under('/agents', '/peek', '/term', '/fleet', '/system', '/runs') },
|
|
86
|
-
] : []),
|
|
87
|
-
{ label: 'Projects', href: '/projects', active: under('/projects') },
|
|
88
|
-
{ label: 'Settings', href: '/settings', active: under('/settings', '/spend', '/mode', '/people', '/ledger', '/menu', ...(advanced ? [] : ['/flows', '/recipes', '/kits', '/routines', '/agents', '/peek', '/term', '/fleet', '/system', '/runs'])) },
|
|
81
|
+
{ label: 'Settings', href: '/settings', active: under('/settings', '/spend', '/mode', '/people', '/ledger', '/menu', '/flows', '/recipes', '/kits', '/routines', '/agents', '/peek', '/term', '/fleet', '/system', '/runs') },
|
|
89
82
|
];
|
|
90
83
|
}
|
package/dist/builder.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { legacyNetwork, repositoryEcosystems } from "./egress.js";
|
|
2
|
+
import { flexibleAdoption } from "./flexible-merge-guard.js";
|
|
2
3
|
import { CHECK_ACCESS_DEFAULT, checkAccessHere, checkNetworkOf, localModeCap } from "./check-access.js";
|
|
3
4
|
import { localModeOn } from "./local-owner.js";
|
|
4
5
|
import { checkoutGit, refusal as gitRefusal } from "./teardown-git.js";
|
|
@@ -38,7 +39,7 @@ import { missingCapability } from "./dispatch.js";
|
|
|
38
39
|
import { heartbeat as runnerHeartbeat, RUNNER_HEARTBEAT_MS } from "./runner.js";
|
|
39
40
|
import { keepCheckTimeline } from "./latency-timeline.js";
|
|
40
41
|
import { MARKER as LEASE_MARKER } from "./worktree.js";
|
|
41
|
-
import { parseDecision, parseHandoff, repairPrompt, HEADLESS_RULE, HANDOFF_CONCLUSION_CAP, HANDOFF_ITEM_CAP, HANDOFF_LIST_CAP, HANDOFF_PAYLOAD_CAP } from "./decision.js";
|
|
42
|
+
import { parseDecision, parseHandoff, repairPrompt, HEADLESS_RULE, HANDOFF_CONCLUSION_CAP, HANDOFF_ITEM_CAP, HANDOFF_LIST_CAP, HANDOFF_REPORT_CAP, handoffReportOf, HANDOFF_PAYLOAD_CAP } from "./decision.js";
|
|
42
43
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
43
44
|
import { fencedCommands, invokeAgent } from "./invoke.js";
|
|
44
45
|
import { TELEGRAM_TOKEN_ENVS } from "./names.js";
|
|
@@ -1309,6 +1310,7 @@ export async function settleProviderOutcome(captured, result) {
|
|
|
1309
1310
|
changes: handoff.changes,
|
|
1310
1311
|
verification: handoff.verification,
|
|
1311
1312
|
followUps: handoff.followUps,
|
|
1313
|
+
...handoffReportOf(handoff),
|
|
1312
1314
|
freshness: { stampedAt: clock().toISOString(), currentAsOf: baseRevision },
|
|
1313
1315
|
}, clock());
|
|
1314
1316
|
if (observation) {
|
|
@@ -1357,9 +1359,13 @@ export async function settleProviderOutcome(captured, result) {
|
|
|
1357
1359
|
return { ok: false, reason: "stopped", message: await stoppedWords(captured) };
|
|
1358
1360
|
}
|
|
1359
1361
|
store.setRunPhase(request.runId, "committing");
|
|
1362
|
+
const flexibleAdopt = flexibleAdoption(store, taskId, scope?.candidate ?? null, scope?.digest ?? null);
|
|
1363
|
+
if (flexibleAdopt !== null && ("refuse" in flexibleAdopt || finishesKeptWork)) {
|
|
1364
|
+
return { ok: false, reason: "commit-failure", message: "refuse" in flexibleAdopt ? flexibleAdopt.refuse : "This task came from a Flexible thread; it takes only its Ship's imported commit. Nothing was committed." };
|
|
1365
|
+
}
|
|
1360
1366
|
const made = finishesKeptWork
|
|
1361
1367
|
? await keptWorkResult(captured, baseRevision, handoff.conclusion)
|
|
1362
|
-
: await commit(git, worktree, branch, taskId, scope, handoff.conclusion, scope?.candidate ?? null, words => store.addRunNote(request.runId, "Toolroll", words, clock()));
|
|
1368
|
+
: await commit(git, worktree, branch, taskId, scope, handoff.conclusion, scope?.candidate ?? null, words => store.addRunNote(request.runId, "Toolroll", words, clock()), flexibleAdopt === null ? null : flexibleAdopt.adopt);
|
|
1363
1369
|
if (made.ok && made.parked === undefined && made.committed) {
|
|
1364
1370
|
const newHead = await git(GIT, ["--no-optional-locks", "rev-parse", "HEAD"], { cwd: worktree });
|
|
1365
1371
|
if (newHead.code === 0) {
|
|
@@ -1388,6 +1394,7 @@ export async function settleProviderOutcome(captured, result) {
|
|
|
1388
1394
|
changes: handoff.changes,
|
|
1389
1395
|
verification: handoff.verification,
|
|
1390
1396
|
followUps: handoff.followUps,
|
|
1397
|
+
...handoffReportOf(handoff),
|
|
1391
1398
|
freshness: { stampedAt: clock().toISOString(), currentAsOf: head },
|
|
1392
1399
|
}, clock());
|
|
1393
1400
|
try {
|
|
@@ -2676,6 +2683,12 @@ function brief(scope, branch, mailbox, done, proof, answers = [], planDocument =
|
|
|
2676
2683
|
` at most ${HANDOFF_LIST_CAP} items each, ${HANDOFF_ITEM_CAP} characters per item. The conclusion is the operator's`,
|
|
2677
2684
|
" compact result, not a transcript: never include a preamble, file dump,",
|
|
2678
2685
|
" or repeated explanation. The machine stores full diffs separately.",
|
|
2686
|
+
" Also tell the person who reviews this what they can't see in the diff,",
|
|
2687
|
+
` in four optional lists of at most ${HANDOFF_REPORT_CAP} short lines each: "decisions" (choices`,
|
|
2688
|
+
' you made that they might have made differently), "assumptions" (what you',
|
|
2689
|
+
' took as true without checking), "notDone" (what the goal asked for that',
|
|
2690
|
+
' you left out) and "risks" (what could go wrong). Leave a list out rather',
|
|
2691
|
+
" than pad it; the person sees these before deciding, labelled as yours.",
|
|
2679
2692
|
` The whole file must be under ${HANDOFF_PAYLOAD_CAP} bytes, and the conclusion and every`,
|
|
2680
2693
|
" list item is ONE line of plain text — a newline or other control",
|
|
2681
2694
|
" character in any of them refuses the whole file, not just that field.",
|
|
@@ -2799,7 +2812,7 @@ function brief(scope, branch, mailbox, done, proof, answers = [], planDocument =
|
|
|
2799
2812
|
" else.",
|
|
2800
2813
|
].join("\n");
|
|
2801
2814
|
}
|
|
2802
|
-
async function commit(git, worktree, branch, taskId, scope, summary, preparedCandidate = null, notice) {
|
|
2815
|
+
async function commit(git, worktree, branch, taskId, scope, summary, preparedCandidate = null, notice, adopt = null) {
|
|
2803
2816
|
const status = await git(GIT, ["--no-optional-locks", "status", "--porcelain"], { cwd: worktree });
|
|
2804
2817
|
if (status.code !== 0) {
|
|
2805
2818
|
return { ok: false, reason: "commit-failure", message: firstLine(status.stderr) };
|
|
@@ -2848,6 +2861,12 @@ async function commit(git, worktree, branch, taskId, scope, summary, preparedCan
|
|
|
2848
2861
|
? "The staged files no longer match the approved prepared candidate. The checkout is preserved; nothing was committed."
|
|
2849
2862
|
: "The staged prepared candidate could not be verified. The checkout is preserved; nothing was committed." };
|
|
2850
2863
|
}
|
|
2864
|
+
if (adopt !== null) {
|
|
2865
|
+
if (preparedCandidate !== adopt.candidate)
|
|
2866
|
+
return { ok: false, reason: "commit-failure", message: "The prepared commit isn't the Ship's imported commit. Nothing was committed." };
|
|
2867
|
+
const adopted = await adoptPreparedCommit(git, worktree, adopt.candidate, adopt.importRef);
|
|
2868
|
+
return adopted.ok ? { ok: true, committed: true, branch, summary } : { ok: false, reason: "commit-failure", message: adopted.message };
|
|
2869
|
+
}
|
|
2851
2870
|
const message = [`${taskId}: ${firstSentence(scope.goal, 68)}`, "", summary].join("\n");
|
|
2852
2871
|
const made = await git(GIT, ["commit", "--no-verify", "-m", message], { cwd: worktree });
|
|
2853
2872
|
if (made.code !== 0) {
|
|
@@ -2907,3 +2926,26 @@ function firstSentence(goal, limit) {
|
|
|
2907
2926
|
const lastSpace = cut.lastIndexOf(" ");
|
|
2908
2927
|
return `${lastSpace > 20 ? cut.slice(0, lastSpace) : cut}…`;
|
|
2909
2928
|
}
|
|
2929
|
+
export async function adoptPreparedCommit(git, worktree, candidate, importRef) {
|
|
2930
|
+
if (!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(candidate))
|
|
2931
|
+
return { ok: false, message: "The shipped commit isn't an exact commit id. Nothing was committed." };
|
|
2932
|
+
if (!/^refs\/toolroll\/import\/[0-9a-f]{32}\/[1-9]\d{0,6}$/.test(importRef))
|
|
2933
|
+
return { ok: false, message: "The Ship's import isn't one Toolroll made. Nothing was committed." };
|
|
2934
|
+
const imported = await git(GIT, ["--no-optional-locks", "rev-parse", "--verify", "--quiet", "--end-of-options", `${importRef}^{commit}`], { cwd: worktree });
|
|
2935
|
+
if (imported.code !== 0 || imported.stdout.trim() !== candidate)
|
|
2936
|
+
return { ok: false, message: "The prepared commit isn't the one the Ship's import checked. The checkout is preserved; nothing was committed." };
|
|
2937
|
+
const descends = await git(GIT, ["--no-optional-locks", "merge-base", "--is-ancestor", "HEAD", candidate], { cwd: worktree });
|
|
2938
|
+
if (descends.code !== 0)
|
|
2939
|
+
return { ok: false, message: "The shipped commit doesn't build on this branch's commit. The checkout is preserved; nothing was committed." };
|
|
2940
|
+
const staged = await git(GIT, ["--no-optional-locks", "diff", "--cached", "--quiet", candidate, "--"], { cwd: worktree });
|
|
2941
|
+
if (staged.code !== 0)
|
|
2942
|
+
return { ok: false, message: "The staged files aren't exactly the shipped commit's. The checkout is preserved; nothing was committed." };
|
|
2943
|
+
const moved = await git(GIT, ["reset", "--soft", "-q", candidate], { cwd: worktree });
|
|
2944
|
+
if (moved.code !== 0)
|
|
2945
|
+
return { ok: false, message: `${firstLine(moved.stderr) || "The branch couldn't be moved to the shipped commit"}. The checkout is preserved.` };
|
|
2946
|
+
const head = await git(GIT, ["--no-optional-locks", "rev-parse", "HEAD"], { cwd: worktree });
|
|
2947
|
+
const clean = await git(GIT, ["--no-optional-locks", "diff", "--cached", "--quiet", "HEAD", "--"], { cwd: worktree });
|
|
2948
|
+
if (head.code !== 0 || head.stdout.trim() !== candidate || clean.code !== 0)
|
|
2949
|
+
return { ok: false, message: "The branch didn't land exactly on the shipped commit. The checkout is preserved." };
|
|
2950
|
+
return { ok: true };
|
|
2951
|
+
}
|
package/dist/chat-actions.js
CHANGED
|
@@ -22,6 +22,7 @@ import { isProviderId } from "./provider.js";
|
|
|
22
22
|
import { approverStandsNow, familyRepoOf } from "./tidy.js";
|
|
23
23
|
import { chatApproveMode, effectiveChatApproval } from "./chat-approval.js";
|
|
24
24
|
import { cardTermsDigest, chatLimitProblem, scopeTermsText, shownAsWritten } from "./chat-terms.js";
|
|
25
|
+
import { approvalSummaryOf, describeScope, summaryContextOf, summaryText } from "./approval-summary.js";
|
|
25
26
|
import { chatStartDryRun, chatStartPreview, fastRefusalWords, fastStartBuild, FAST_MAX_FILES, FAST_MAX_LINES } from "./fast-start.js";
|
|
26
27
|
import { fastTermsLines } from "./fast-terms.js";
|
|
27
28
|
import { TYPED_START_REFUSED, typedStartNames } from "./typed-start.js";
|
|
@@ -30,7 +31,7 @@ import { archiveTaskFamily, leadTurnKeepsProposals, restoreTaskFamily, verifiedA
|
|
|
30
31
|
import { isVerifiedApprover, reproveApprover, } from "./principal.js";
|
|
31
32
|
import { changeSkills, importSkill, skillsView, skillsVersion, testSkill, validateSkill, } from "./project-skills.js";
|
|
32
33
|
import { changeKnowledge, knowledgeVersion, knowledgeView, } from "./project-knowledge.js";
|
|
33
|
-
import { passwordlessSessionFor, approve, authenticateApprover,
|
|
34
|
+
import { passwordlessSessionFor, approve, authenticateApprover, proveCredential, scopeAuthorityOf, machineActing, freshnessFor, localApprovalEligible, spendingOnlyOnSuccess, ssoNowAvailable, withFreshness, } from "./scope.js";
|
|
34
35
|
import { readVerifiedArtifact, scanForSecrets } from "./evidence.js";
|
|
35
36
|
import { readAuthModeStrict } from "./keys.js";
|
|
36
37
|
import { acceptAndCompleteAsOperator, assignmentOf } from "./assignment.js";
|
|
@@ -57,6 +58,7 @@ import { answerSubagentQuestion } from "./subagent-work.js";
|
|
|
57
58
|
import { callWords, checkRule, defaultRule, grantListed, revokeTool, ruleLoosens, ruleWords, setToolRules } from "./subagent-tools.js";
|
|
58
59
|
import { aboutYouOf, checkAboutYouLine, saveAboutYou, withAboutYouLine } from "./lead-about.js";
|
|
59
60
|
import { CHAT_ACTION_FIELDS, readChatActionRequest, readSharedAction, SHARED_ACTION_VERSION } from "./contracts/chat-actions.js";
|
|
61
|
+
import { soloChatSeatRefusal } from "./install-mode.js";
|
|
60
62
|
export { CHAT_ACTION_FIELDS };
|
|
61
63
|
function toolSpecFromRequest(input) {
|
|
62
64
|
if (input["catalog"] !== undefined) {
|
|
@@ -162,6 +164,7 @@ export const CHAT_ACTIONS = {
|
|
|
162
164
|
task_resume: { label: "Resume task", protected: true, password: false },
|
|
163
165
|
task_start: { label: "Start work", protected: true, password: false },
|
|
164
166
|
};
|
|
167
|
+
const CREDENTIAL_ACTIONS = new Set(["tool_add", "flow_browser"]);
|
|
165
168
|
const SAME_ACTIONS = true;
|
|
166
169
|
void SAME_ACTIONS;
|
|
167
170
|
export const APPROVAL_ACTIONS = new Set(["scope_approve", "task_resume", "sweep_file", "flow_browser", "task_reopen", "revision_accept", "revision_reject", "flow_unattended", "task_start"]);
|
|
@@ -993,14 +996,8 @@ export function prepareSharedAction(store, who, operation, input, root, now = ne
|
|
|
993
996
|
if (!authority.ok)
|
|
994
997
|
throw Error(authority.problem);
|
|
995
998
|
state["authMode"] = authority.authMode;
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
.map((line) => line
|
|
999
|
-
.trimStart()
|
|
1000
|
-
.replace(/^why model\s+/, "Why this model: ")
|
|
1001
|
-
.replace(/^goal\s+/, "Work: ")
|
|
1002
|
-
.replace(/^not this\s+/, "Excluded: ")
|
|
1003
|
-
.replace(/^touches\s+/, "Allowed files: ")), `Agent permissions and limits\n${runtimeTerms(authority.profile)}\n${authority.authMode === "api-key" ? "Uses your API key; spend is charged to that account." : authority.authMode === "subscription" ? "Uses your subscription login." : ""}`);
|
|
999
|
+
const summary = approvalSummaryOf(scope, summaryContextOf(store, scope.taskId, scope, now, taskEvidenceWords(store, scope.taskId, now)));
|
|
1000
|
+
terms.push(scopeTermsText(scope), summaryText(summary, one => one.fields.includes("goal") || one.fields.includes("outOfScope") || one.fields.includes("acceptance")), `Agent permissions and limits\n${runtimeTerms(authority.profile)}\n${authority.authMode === "api-key" ? "Uses your API key; spend is charged to that account." : authority.authMode === "subscription" ? "Uses your subscription login." : ""}`);
|
|
1004
1001
|
const plan = store.latestPlanArtifact(ref.id), revision = ref.revisionBriefArtifact === null
|
|
1005
1002
|
? null
|
|
1006
1003
|
: store.getArtifact(ref.revisionBriefArtifact);
|
|
@@ -1187,13 +1184,20 @@ export function executeSharedAction(store, who, id, payload, now, options) {
|
|
|
1187
1184
|
return refuse("needs-confirm", "Only a person approves this.");
|
|
1188
1185
|
if (APPROVAL_ACTIONS.has(live.operation) && options.via === "web" && options.authority !== "local-owner" && options.person !== true)
|
|
1189
1186
|
return refuse("needs-confirm", "Approve this yourself, in your signed-in chat.");
|
|
1187
|
+
let reviewProof = null;
|
|
1188
|
+
if (CREDENTIAL_ACTIONS.has(live.operation) && (challenged || options.via !== "web" || !options.review || options.confirm !== true))
|
|
1189
|
+
return refuse("needs-confirm", "Confirm with your password in the secure screen.");
|
|
1190
1190
|
if (sharedActionNeedsReview(payload) && !challenged) {
|
|
1191
1191
|
if (options.via !== "web" || !options.review || options.confirm !== true)
|
|
1192
1192
|
return refuse("needs-confirm", "Review the complete action in the secure confirmation screen.");
|
|
1193
1193
|
if (!store.consumeCeremonyNonce(nonceHash(options.review.nonce), who.name, "chat-action", id, savedStamp, now))
|
|
1194
1194
|
return refuse("needs-confirm", "This confirmation expired or was already used. Open the review again.");
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1195
|
+
const credential = CREDENTIAL_ACTIONS.has(live.operation);
|
|
1196
|
+
const proved = credential ? proveCredential(store, who.name, options.review.password, payload.repo)
|
|
1197
|
+
: config.password ? authenticateApprover(store, who.name, options.review.password, payload.repo) : null;
|
|
1198
|
+
if (proved?.ok === true)
|
|
1199
|
+
reviewProof = proved.method;
|
|
1200
|
+
if ((credential || config.password) && proved?.ok !== true)
|
|
1197
1201
|
return refuse("needs-confirm", "Confirm with your password in the secure screen.");
|
|
1198
1202
|
}
|
|
1199
1203
|
try {
|
|
@@ -1240,7 +1244,7 @@ export function executeSharedAction(store, who, id, payload, now, options) {
|
|
|
1240
1244
|
const by = approvalBy(store, who, repo, now, options, drafted);
|
|
1241
1245
|
if (by.ok === false)
|
|
1242
1246
|
throw Error(by.why);
|
|
1243
|
-
const signed = signFlowBrowser(store, { flow, signer: actor, proof:
|
|
1247
|
+
const signed = signFlowBrowser(store, { flow, signer: actor, proof: reviewProof, sawDigest: String(payload.state["digest"] ?? ""), console: { generation: who.generation } }, now);
|
|
1244
1248
|
if (!signed.ok)
|
|
1245
1249
|
throw Error(signed.message);
|
|
1246
1250
|
return { ok: true, taskId: null, said: "Browser allowed. Its browser zones can start Chromium now.", href: `/flows/${flow}` };
|
|
@@ -1425,14 +1429,14 @@ function fileSweepChild(store, who, repo, brief, one, acceptance, now) {
|
|
|
1425
1429
|
filedVia: "mate", filedBy: { name: who.name, kind: "person" }, proposedVia: "mate", admittedRepos: [...who.repos],
|
|
1426
1430
|
}, now);
|
|
1427
1431
|
}
|
|
1428
|
-
function sweepChildScopeOf(store, taskId) {
|
|
1432
|
+
function sweepChildScopeOf(store, taskId, now) {
|
|
1429
1433
|
const scope = store.getScope(taskId);
|
|
1430
1434
|
if (scope === null)
|
|
1431
1435
|
throw Error("A sweep item has no scope to show.");
|
|
1432
1436
|
const authority = scopeAuthorityOf(scope, { authMode: readAuthModeStrict });
|
|
1433
1437
|
if (!authority.ok)
|
|
1434
1438
|
throw Error(authority.problem);
|
|
1435
|
-
const words = describeScope(scope).filter(line => !/^\s*(reference|approved)\s/.test(line)).map(line => line.trim());
|
|
1439
|
+
const words = describeScope(scope, undefined, null, summaryContextOf(store, taskId, scope, now)).filter(line => !/^\s*(reference|approved)\s/.test(line)).map(line => line.trim());
|
|
1436
1440
|
const runtime = `Agent permissions and limits: ${runtimeTerms(authority.profile)} ${authority.authMode === "api-key" ? "Uses your API key; spend is charged to that account." : authority.authMode === "subscription" ? "Uses your subscription login." : ""}`.trim();
|
|
1437
1441
|
const { taskId: _task, digest: _digest, approvedDigest: _approved, approvedBy: _by, approvedAt: _at, proposedAt: _proposed, approvalBasis: _basis, modeDigest: _mode, approvedProfile: _approvedProfile, approvedProfileJson: _approvedProfileJson, approvedChainJson: _approvedChain, ...terms } = scope;
|
|
1438
1442
|
return { fingerprint: hash({ words, runtime, authMode: authority.authMode, profile: authority.profile, terms }), runtime, words, terms: scopeTermsText(scope) };
|
|
@@ -1447,7 +1451,7 @@ function sweepChildScopes(store, who, repo, brief, items, acceptance, now) {
|
|
|
1447
1451
|
const made = fileSweepChild(store, who, repo, brief, one, acceptance, now);
|
|
1448
1452
|
if (!made.ok)
|
|
1449
1453
|
throw Error(`Item ${index + 1} (${one.title}) can't be filed: ${made.message}`);
|
|
1450
|
-
return sweepChildScopeOf(store, made.id);
|
|
1454
|
+
return sweepChildScopeOf(store, made.id, now);
|
|
1451
1455
|
});
|
|
1452
1456
|
throw dryRun;
|
|
1453
1457
|
});
|
|
@@ -1470,7 +1474,7 @@ function startFromCard(store, who, proposal, drafted, options, now) {
|
|
|
1470
1474
|
const chat = by.chat;
|
|
1471
1475
|
proof = { chat: by.limits };
|
|
1472
1476
|
const typed = options.typedStart;
|
|
1473
|
-
approveNow = (taskId, saw, fast) => approve(store, taskId, who.name, now, saw, "", {}, typed === undefined ? fast : { ...fast, typed: { provider: typed.provider, event: typed.event } }, chat);
|
|
1477
|
+
approveNow = (taskId, saw, fast) => approve(store, taskId, who.name, now, saw, "", {}, typed === undefined || fast === undefined ? fast : { ...fast, typed: { provider: typed.provider, event: typed.event } }, chat);
|
|
1474
1478
|
}
|
|
1475
1479
|
else if (options.authority === "local-owner" && currentLocalOwner() !== null) {
|
|
1476
1480
|
proof = { password: { localOwner: true, passwordless: false, freshAt: null, returnTo: "/chat" } };
|
|
@@ -1508,6 +1512,9 @@ function approvalBy(store, who, repo, now, options, drafted) {
|
|
|
1508
1512
|
const allowed = effectiveChatApproval(store, repo, who.name);
|
|
1509
1513
|
return allowed.ok ? { ok: true, limits: allowed.limits, chat: { modeDigest: allowed.setting.digest, shown } } : { ok: false, why: allowed.why };
|
|
1510
1514
|
}
|
|
1515
|
+
const solo = soloChatSeatRefusal(store, { provider: options.via, binding: options.binding, approver: who.name });
|
|
1516
|
+
if (solo !== null)
|
|
1517
|
+
return { ok: false, why: solo };
|
|
1511
1518
|
const allowed = chatApproveMode(store, repo, who.name, now, options.via);
|
|
1512
1519
|
return allowed.ok ? { ok: true, limits: allowed.limits, chat: { modeDigest: allowed.digest, shown } } : allowed;
|
|
1513
1520
|
}
|
|
@@ -1527,7 +1534,7 @@ function fileSweep(store, who, proposal, payload, by, now) {
|
|
|
1527
1534
|
const made = fileSweepChild(store, who, payload.repo, brief, one, req["acceptance"], now);
|
|
1528
1535
|
if (!made.ok)
|
|
1529
1536
|
throw Error(`Item ${index + 1} (${one.title}) couldn't be filed: ${made.message}. Nothing was filed.`);
|
|
1530
|
-
if (sweepChildScopeOf(store, made.id).fingerprint !== payload.state["children"]?.[index])
|
|
1537
|
+
if (sweepChildScopeOf(store, made.id, now).fingerprint !== payload.state["children"]?.[index])
|
|
1531
1538
|
throw Error(`Item ${index + 1} (${one.title}) no longer matches what you reviewed (a project default changed). Nothing was filed; ask for a fresh card.`);
|
|
1532
1539
|
store.addSweepTask(sweep, made.id, index, one.title);
|
|
1533
1540
|
filed.push({ id: made.id, title: one.title });
|
package/dist/chat-controls.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { taskLinkOf } from "./task-link.js";
|
|
1
2
|
export const CHAT_CONTROLS = {
|
|
2
3
|
task: { label: "Open task", target: "task" },
|
|
3
4
|
approval: { label: "Review & start", target: "task" },
|
|
@@ -11,7 +12,7 @@ export const CHAT_CONTROLS = {
|
|
|
11
12
|
projects: { label: "Manage projects", href: "/projects" },
|
|
12
13
|
flows: { label: "Open flows", href: "/flows" },
|
|
13
14
|
recipes: { label: "Browse workflows", href: "/recipes" },
|
|
14
|
-
workers: { label: "Manage
|
|
15
|
+
workers: { label: "Manage computers", href: "/settings/computers?section=builders" },
|
|
15
16
|
slack: { label: "Manage Slack", href: "/settings/slack" },
|
|
16
17
|
discord: { label: "Manage Discord", href: "/settings/discord" },
|
|
17
18
|
lead: { label: "Name your lead", href: "/settings/lead" },
|
|
@@ -30,7 +31,7 @@ export function isChatControl(value) {
|
|
|
30
31
|
return typeof value === "string" && Object.hasOwn(CHAT_CONTROLS, value);
|
|
31
32
|
}
|
|
32
33
|
export function chatResultHref(task, run, tab = "summary") {
|
|
33
|
-
return
|
|
34
|
+
return taskLinkOf({ task, run, section: tab });
|
|
34
35
|
}
|
|
35
36
|
export function chatControlHref(control, task, run, project) {
|
|
36
37
|
const entry = CHAT_CONTROLS[control];
|
|
@@ -39,13 +40,13 @@ export function chatControlHref(control, task, run, project) {
|
|
|
39
40
|
if ("href" in entry)
|
|
40
41
|
return entry.href;
|
|
41
42
|
if (control === "acceptance")
|
|
42
|
-
return
|
|
43
|
+
return taskLinkOf({ task, run: Number.isSafeInteger(run) && Number(run) > 0 ? Number(run) : null, section: "checks", anchor: "result-decision" });
|
|
43
44
|
if (control === "result" && Number.isSafeInteger(run) && Number(run) > 0)
|
|
44
45
|
return chatResultHref(task, Number(run));
|
|
45
46
|
const base = "/chat?task=" + encodeURIComponent(task);
|
|
46
47
|
if (control === "cancel" || control === "recovery" || control === "publish")
|
|
47
|
-
return
|
|
48
|
+
return taskLinkOf({ task });
|
|
48
49
|
if (control === "findings")
|
|
49
|
-
return
|
|
50
|
+
return taskLinkOf({ task, anchor: "findings" });
|
|
50
51
|
return base + (control === "approval" || control === "planning" ? "#task-chat-action" : "");
|
|
51
52
|
}
|
package/dist/chat-core.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { soloChatSeatRefusal } from "./install-mode.js";
|
|
2
3
|
const REVOKED = "revoked";
|
|
3
4
|
export const chatHash = (text) => createHash("sha256").update(text).digest("hex");
|
|
4
5
|
export const PAIRING_CODE_TTL_MS = 10 * 60_000;
|
|
@@ -57,7 +58,8 @@ export class ChatCore {
|
|
|
57
58
|
const current = this.bindingById(binding.id);
|
|
58
59
|
const account = this.store.accountOf(binding.approver);
|
|
59
60
|
return current !== null && current.approver === binding.approver && current.generation === binding.generation &&
|
|
60
|
-
account?.role === "approver" && account.revokedAt === null && account.generation === binding.generation
|
|
61
|
+
account?.role === "approver" && account.revokedAt === null && account.generation === binding.generation
|
|
62
|
+
&& soloChatSeatRefusal(this.store, { provider: this.provider, binding: binding.id, approver: binding.approver }) === null;
|
|
61
63
|
}
|
|
62
64
|
liveBindings(installation) {
|
|
63
65
|
return this.bindings(installation).filter(binding => this.live(binding));
|