toolroll 0.9.119 → 0.9.122
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 +77 -0
- package/README.md +18 -31
- package/dist/agent-fence.js +57 -9
- package/dist/assignment.js +9 -7
- package/dist/batch-checks.js +2 -2
- package/dist/browser/workspace.js +23 -23
- package/dist/builder.js +12 -8
- package/dist/central-recovery-stage.js +3 -3
- package/dist/cli-help.js +1 -0
- package/dist/codex-limits.js +40 -22
- package/dist/coding-provider.js +3 -3
- package/dist/contracts/console-api.js +3 -0
- package/dist/direct-chat-fence.js +9 -3
- package/dist/direct-chat.js +82 -10
- package/dist/engine-reads.js +3 -1
- package/dist/flexible-agents.js +16 -2
- package/dist/flexible-import.js +38 -0
- package/dist/flexible-save.js +128 -0
- package/dist/flexible-session.js +11 -3
- package/dist/flexible-ship.js +3 -3
- package/dist/flexible-thread.js +7 -3
- package/dist/install-method.js +1 -3
- package/dist/invoke.js +11 -9
- package/dist/lead-tools.js +3 -2
- package/dist/live-terminal.js +24 -3
- package/dist/local-checks.js +32 -0
- package/dist/local-landing.js +321 -63
- package/dist/local-owner.js +3 -0
- package/dist/operate.js +25 -7
- package/dist/plan-limits-demand.js +48 -0
- package/dist/planner.js +2 -0
- package/dist/project-delete.js +1 -1
- package/dist/project-skills.js +105 -17
- package/dist/result-follow-ups.js +24 -10
- package/dist/review-context.js +2 -1
- package/dist/scout.js +2 -1
- package/dist/serve.js +8 -1
- package/dist/server/direct-chat.js +25 -3
- package/dist/server/engine-api.js +24 -3
- package/dist/server/render-release.js +27 -15
- package/dist/server/render-results.js +6 -4
- package/dist/server/route-table.js +8 -1
- package/dist/server/send-back-build.js +4 -0
- package/dist/server/settings.js +153 -3
- package/dist/server/task-views.js +8 -3
- package/dist/server/tasks.js +51 -9
- package/dist/server/terminals.js +3 -1
- package/dist/settings-groups-ui.js +1 -1
- package/dist/skill-library-schema.js +70 -0
- package/dist/skill-library.js +693 -0
- package/dist/skill-local-sync.js +334 -0
- package/dist/skills-manifest.js +6 -3
- package/dist/skills-ui.js +122 -1
- package/dist/store.js +22 -4
- 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 +2 -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
|
+
}
|
package/dist/planner.js
CHANGED
|
@@ -637,6 +637,7 @@ export async function plan(store, request) {
|
|
|
637
637
|
idleTimeoutMs: timeoutMs,
|
|
638
638
|
omitEnv: AGENT_ENV_DENYLIST,
|
|
639
639
|
skills: projectSkills,
|
|
640
|
+
evidenceRoot: root,
|
|
640
641
|
...(agent === undefined ? {} : { runner: agent }),
|
|
641
642
|
...(request.onProviderSpawn === undefined ? {} : { onSpawn: request.onProviderSpawn }),
|
|
642
643
|
clock,
|
|
@@ -783,6 +784,7 @@ export async function plan(store, request) {
|
|
|
783
784
|
timeoutMs: STRUCTURED_REPAIR_TIMEOUT_MS,
|
|
784
785
|
omitEnv: AGENT_ENV_DENYLIST,
|
|
785
786
|
skills: projectSkills,
|
|
787
|
+
evidenceRoot: root,
|
|
786
788
|
...(agent === undefined ? {} : { runner: agent }),
|
|
787
789
|
...(request.onProviderSpawn === undefined ? {} : { onSpawn: request.onProviderSpawn }),
|
|
788
790
|
clock,
|
package/dist/project-delete.js
CHANGED
|
@@ -302,7 +302,7 @@ function deleteRows(store, repo, d, now) {
|
|
|
302
302
|
del(table, `${column} = ?`, repo);
|
|
303
303
|
rows += forgetProjectModels(store, repo, now);
|
|
304
304
|
del("project_mute", "repo = ?", repo);
|
|
305
|
-
for (const table of ["knowledge_change", "project_identity_carry", "project_skill_change", "memory_gap", "memory_proposal", "memory_rejection", "memory_session", "memory_search", "mode_rail", "side_spend", "watch_episode", "worktree", "coordinator_proposal", "lead_commitment"])
|
|
305
|
+
for (const table of ["knowledge_change", "project_identity_carry", "project_skill_change", "skill_project_opt_out", "memory_gap", "memory_proposal", "memory_rejection", "memory_session", "memory_search", "mode_rail", "side_spend", "watch_episode", "worktree", "coordinator_proposal", "lead_commitment"])
|
|
306
306
|
del(table, "repo = ?", repo);
|
|
307
307
|
del("watch_lease", "repo = ? AND expires_at <= ?", repo, now.toISOString());
|
|
308
308
|
const flexibleThreads = `thread IN (SELECT id FROM flexible_thread WHERE repo = ? AND state IN ('removed', 'failed'))`;
|
package/dist/project-skills.js
CHANGED
|
@@ -9,6 +9,7 @@ import { fileTaskProposal } from "./proposal.js";
|
|
|
9
9
|
import { TEXT_LIMITS } from "./text-limits.js";
|
|
10
10
|
import { contractError } from "./contracts/contract.js";
|
|
11
11
|
import { SKILL_COUNTS, SKILL_LIMITS, readSkillsSnapshotPayload, savedSkillPackageSchema, savedSkillsSnapshotSchema, skillPackageSchema, skillSelectionSchema, } from "./contracts/project-skills.js";
|
|
12
|
+
import { LIBRARY_LIMITS, currentLibrary, enabledLibrarySkills, listSkillBundles, mergeProjectAndLibrarySkills, projectSkillOptOuts, } from "./skill-library.js";
|
|
12
13
|
export { SKILL_LIMITS };
|
|
13
14
|
export { checkSkillsManifest } from "./skills-manifest.js";
|
|
14
15
|
export const SKILLS_SCHEMA = `
|
|
@@ -208,10 +209,39 @@ export function skillsView(store, repo, actor) {
|
|
|
208
209
|
export function selectProjectSkills(store, repo, actor) {
|
|
209
210
|
const { identity, accepted } = admit(store, repo, actor);
|
|
210
211
|
const value = current(store, repo, accepted);
|
|
211
|
-
const
|
|
212
|
-
if (
|
|
212
|
+
const projectPackages = Object.values(value.selection).filter(choice => choice.enabled).map(choice => packageOf(store, choice.sha));
|
|
213
|
+
if (projectPackages.length > SKILL_LIMITS.enabled || Buffer.byteLength(JSON.stringify(projectPackages)) > SKILL_LIMITS.selectionBytes)
|
|
213
214
|
throw Error('Enable up to 8 skills, totaling at most 2 MB.');
|
|
214
|
-
|
|
215
|
+
const { libraryRevision, packages } = mergeProjectAndLibrarySkills(store, repo, value.selection);
|
|
216
|
+
if (packages.length > LIBRARY_LIMITS.maxSkills || Buffer.byteLength(JSON.stringify(packages)) > LIBRARY_LIMITS.maxBundleBytes)
|
|
217
|
+
throw Error('Too many enabled skills.');
|
|
218
|
+
return { version: 1, revision: Math.max(value.revision, libraryRevision), identity, inheritedFrom: null, test: false, packages };
|
|
219
|
+
}
|
|
220
|
+
export function effectiveSkillsForRepo(store, repo) {
|
|
221
|
+
if (!store.schemaCurrent()) {
|
|
222
|
+
return { version: 1, revision: 0, identity: "unconfigured", inheritedFrom: null, test: false, packages: [] };
|
|
223
|
+
}
|
|
224
|
+
let projectSelection = {};
|
|
225
|
+
let revision = 0;
|
|
226
|
+
let identity = "unconfigured";
|
|
227
|
+
try {
|
|
228
|
+
const saved = store.handle
|
|
229
|
+
.prepare("SELECT identity FROM project_skill_change WHERE repo=? ORDER BY revision DESC LIMIT 1")
|
|
230
|
+
.get(repo);
|
|
231
|
+
if (saved) {
|
|
232
|
+
const accepted = acceptedIdentities(store, repo);
|
|
233
|
+
if (accepted.has(String(saved["identity"]))) {
|
|
234
|
+
const value = current(store, repo, accepted);
|
|
235
|
+
revision = value.revision;
|
|
236
|
+
identity = learningIdentity(repo);
|
|
237
|
+
projectSelection = value.selection;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
}
|
|
243
|
+
const { libraryRevision, packages } = mergeProjectAndLibrarySkills(store, repo, projectSelection);
|
|
244
|
+
return { version: 1, revision: Math.max(revision, libraryRevision), identity, inheritedFrom: null, test: false, packages };
|
|
215
245
|
}
|
|
216
246
|
export function skillsVersion(store, repo, actor, revision) {
|
|
217
247
|
const { accepted } = admit(store, repo, actor);
|
|
@@ -287,21 +317,64 @@ export function changeSkills(store, args, now = new Date()) {
|
|
|
287
317
|
}
|
|
288
318
|
export function conversationSkills(store, repo, actor, sha) {
|
|
289
319
|
const v = skillsView(store, repo, actor);
|
|
290
|
-
const
|
|
291
|
-
|
|
320
|
+
const globalLib = currentLibrary(store);
|
|
321
|
+
const optOuts = projectSkillOptOuts(store, repo);
|
|
322
|
+
const globalEnabled = new Map(enabledLibrarySkills(store, repo).packages.map((p) => [p.sha, p]));
|
|
323
|
+
const combinedBySha = new Map();
|
|
324
|
+
for (const p of v.library) {
|
|
325
|
+
const enabled = v.selection[p.name]?.sha === p.sha &&
|
|
326
|
+
v.selection[p.name]?.enabled === true;
|
|
327
|
+
combinedBySha.set(p.sha, { pkg: p, scope: "project", enabled, optedOut: false });
|
|
328
|
+
}
|
|
329
|
+
for (const [name, choice] of Object.entries(globalLib.selection)) {
|
|
330
|
+
const existing = combinedBySha.get(choice.sha);
|
|
331
|
+
const isOptedOut = optOuts.all || optOuts.names.has(name);
|
|
332
|
+
const activeHere = globalEnabled.has(choice.sha);
|
|
333
|
+
if (existing) {
|
|
334
|
+
if (!v.selection[name] || v.selection[name]?.sha !== choice.sha) {
|
|
335
|
+
existing.scope = "global";
|
|
336
|
+
existing.optedOut = isOptedOut;
|
|
337
|
+
}
|
|
338
|
+
if (activeHere)
|
|
339
|
+
existing.enabled = true;
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
try {
|
|
343
|
+
const pkg = packageOf(store, choice.sha);
|
|
344
|
+
combinedBySha.set(choice.sha, { pkg, scope: "global", enabled: activeHere, optedOut: isOptedOut });
|
|
345
|
+
}
|
|
346
|
+
catch {
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
const entries = [...combinedBySha.values()]
|
|
351
|
+
.sort((a, b) => a.pkg.name.localeCompare(b.pkg.name))
|
|
352
|
+
.filter((entry) => !sha || entry.pkg.sha === sha);
|
|
353
|
+
if (sha && !entries.length)
|
|
292
354
|
throw Error("Choose a skill from the library.");
|
|
355
|
+
const bundles = listSkillBundles(store).map((b) => ({
|
|
356
|
+
id: b.id,
|
|
357
|
+
repo: `${b.owner}/${b.repoName}`,
|
|
358
|
+
commit: b.pinnedCommit.slice(0, 12),
|
|
359
|
+
skillCount: b.skillNames.length,
|
|
360
|
+
autoUpdate: b.autoUpdate,
|
|
361
|
+
heldUpdate: b.heldCommit ? { commit: b.heldCommit.slice(0, 12), reason: b.heldReason } : null,
|
|
362
|
+
}));
|
|
293
363
|
return {
|
|
294
|
-
revision: v.revision,
|
|
364
|
+
revision: Math.max(v.revision, globalLib.revision),
|
|
365
|
+
libraryOptedOut: optOuts.all,
|
|
366
|
+
bundles,
|
|
295
367
|
history: v.history.map(({ revision, enabled }) => ({ revision, enabled })),
|
|
296
|
-
skills:
|
|
368
|
+
skills: entries.map(({ pkg: p, scope, enabled, optedOut }) => ({
|
|
297
369
|
name: p.name,
|
|
298
370
|
description: p.description,
|
|
299
371
|
sha: p.sha,
|
|
300
372
|
source: p.source,
|
|
301
373
|
requirements: p.requirements,
|
|
302
374
|
warnings: p.warnings,
|
|
303
|
-
|
|
304
|
-
|
|
375
|
+
scope,
|
|
376
|
+
optedOut,
|
|
377
|
+
enabled,
|
|
305
378
|
...(sha
|
|
306
379
|
? {
|
|
307
380
|
instructions: Buffer.from(p.files.find((f) => f.path === "SKILL.md").base64, "base64").toString("utf8"),
|
|
@@ -309,7 +382,7 @@ export function conversationSkills(store, repo, actor, sha) {
|
|
|
309
382
|
}
|
|
310
383
|
: {}),
|
|
311
384
|
})),
|
|
312
|
-
notice: "Managed skills for future worker runs. Usage is not implied by enablement. Use shared action proposals
|
|
385
|
+
notice: "Managed skills for future worker runs, Direct Chat, threads, and terminals. Usage is not implied by enablement. Use shared action proposals or Settings → Skills to manage. Skills cannot grant tools or change approvals.",
|
|
313
386
|
};
|
|
314
387
|
}
|
|
315
388
|
export function readSkillsSnapshot(store, runId) {
|
|
@@ -391,15 +464,30 @@ export function freezeSkills(store, runId) {
|
|
|
391
464
|
inheritedFrom: null,
|
|
392
465
|
packages: [packageOf(store, String(test["package"]))],
|
|
393
466
|
};
|
|
394
|
-
else
|
|
395
|
-
|
|
467
|
+
else {
|
|
468
|
+
let projectSelection = {};
|
|
469
|
+
let revision = 0;
|
|
470
|
+
let identity = "unconfigured";
|
|
471
|
+
if (saved && accepted.has(String(saved["identity"]))) {
|
|
472
|
+
const value = current(store, ref.repo, accepted);
|
|
473
|
+
revision = value.revision;
|
|
474
|
+
identity = learningIdentity(ref.repo);
|
|
475
|
+
projectSelection = value.selection;
|
|
476
|
+
}
|
|
477
|
+
const { libraryRevision, packages: merged } = mergeProjectAndLibrarySkills(store, ref.repo, projectSelection);
|
|
478
|
+
if (merged.length > 0 && identity === "unconfigured") {
|
|
479
|
+
try {
|
|
480
|
+
identity = learningIdentity(ref.repo);
|
|
481
|
+
}
|
|
482
|
+
catch {
|
|
483
|
+
identity = "global-library";
|
|
484
|
+
}
|
|
485
|
+
}
|
|
396
486
|
snapshot = {
|
|
397
487
|
...snapshot,
|
|
398
|
-
revision:
|
|
399
|
-
identity
|
|
400
|
-
packages:
|
|
401
|
-
.filter((c) => c.enabled)
|
|
402
|
-
.map((c) => packageOf(store, c.sha)),
|
|
488
|
+
revision: Math.max(revision, libraryRevision),
|
|
489
|
+
identity,
|
|
490
|
+
packages: merged,
|
|
403
491
|
};
|
|
404
492
|
}
|
|
405
493
|
}
|
|
@@ -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) => {
|
|
@@ -252,7 +262,7 @@ export async function runFollowUpCheck(store, root, request, deps = {}) {
|
|
|
252
262
|
let ready = true;
|
|
253
263
|
if (setup !== null) {
|
|
254
264
|
const shell = approvedCommandShell(setup.command);
|
|
255
|
-
const prepared = await runWithIsolatedDatabase(launched(checkoutRunner(store, target.repo, checkout, guardedRunner, [runId], level => ranAt.push(level))), shell.file, shell.args, { cwd: checkout, timeoutMs: setup.timeoutMs, processGroup: true, envAllowlist: SETUP_ENV_ALLOWLIST, omitEnv: SETUP_ENV_DENYLIST });
|
|
265
|
+
const prepared = await runWithIsolatedDatabase(launched(checkoutRunner(store, target.repo, checkout, guardedRunner, [runId], level => ranAt.push(level), undefined, root)), shell.file, shell.args, { cwd: checkout, timeoutMs: setup.timeoutMs, processGroup: true, envAllowlist: SETUP_ENV_ALLOWLIST, omitEnv: SETUP_ENV_DENYLIST });
|
|
256
266
|
note("Approved project setup", setup.command, prepared);
|
|
257
267
|
proveLaunch();
|
|
258
268
|
if (prepared.code !== 0 || prepared.timedOut || prepared.notFound) {
|
|
@@ -267,7 +277,7 @@ export async function runFollowUpCheck(store, root, request, deps = {}) {
|
|
|
267
277
|
}
|
|
268
278
|
else {
|
|
269
279
|
const shell = approvedCommandShell(live.command);
|
|
270
|
-
const ran = await runWithIsolatedDatabase(launched(checkoutRunner(store, target.repo, checkout, guardedRunner, [runId], level => ranAt.push(level))), shell.file, shell.args, { cwd: checkout, timeoutMs: live.timeoutMs, processGroup: true, envAllowlist: SETUP_ENV_ALLOWLIST, omitEnv: SETUP_ENV_DENYLIST });
|
|
280
|
+
const ran = await runWithIsolatedDatabase(launched(checkoutRunner(store, target.repo, checkout, guardedRunner, [runId], level => ranAt.push(level), undefined, root)), shell.file, shell.args, { cwd: checkout, timeoutMs: live.timeoutMs, processGroup: true, envAllowlist: SETUP_ENV_ALLOWLIST, omitEnv: SETUP_ENV_DENYLIST });
|
|
271
281
|
note(`${CHECK_LEVEL_WORDS[target.level]} check`, live.command, ran);
|
|
272
282
|
proveLaunch();
|
|
273
283
|
if (!ran.timedOut && !ran.notFound) {
|
|
@@ -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);
|
package/dist/scout.js
CHANGED
|
@@ -310,6 +310,7 @@ async function scoutWith(store, request, outputDir) {
|
|
|
310
310
|
...(proxy === null ? {} : { env: proxyEnv }),
|
|
311
311
|
...(proxy === null ? {} : { network: { via: [portOf(proxy.url), ...(browserServer === null ? [] : [portOf(browserServer.url)])] } }),
|
|
312
312
|
skills: projectSkills,
|
|
313
|
+
evidenceRoot: root,
|
|
313
314
|
...(agent === undefined ? {} : { runner: agent }),
|
|
314
315
|
...(request.onProviderSpawn === undefined ? {} : { onSpawn: request.onProviderSpawn }),
|
|
315
316
|
clock,
|
|
@@ -467,7 +468,7 @@ async function scoutWith(store, request, outputDir) {
|
|
|
467
468
|
skipPermissions: false,
|
|
468
469
|
resumeSession: session,
|
|
469
470
|
...(structured ? { jsonSchema: SCOUT_OUTPUT_JSON_SCHEMA } : {}),
|
|
470
|
-
}, { cwd: worktree, timeoutMs: SHORTEN_TIMEOUT_MS, omitEnv: AGENT_ENV_DENYLIST, skills: projectSkills, ...(agent === undefined ? {} : { runner: agent }), clock });
|
|
471
|
+
}, { cwd: worktree, timeoutMs: SHORTEN_TIMEOUT_MS, omitEnv: AGENT_ENV_DENYLIST, skills: projectSkills, evidenceRoot: root, ...(agent === undefined ? {} : { runner: agent }), clock });
|
|
471
472
|
if (spoken.kind === "refused" || spoken.outcome.timedOut || spoken.outcome.code !== 0 || !heartbeat(store, request.leaseId, clock()).ok)
|
|
472
473
|
return null;
|
|
473
474
|
const head = await git(GIT, ["--no-optional-locks", "rev-parse", "HEAD"], { cwd: worktree });
|
package/dist/serve.js
CHANGED
|
@@ -118,6 +118,7 @@ import { createDirectChatHandlers } from './server/direct-chat.js';
|
|
|
118
118
|
import { declareSoloOnUpgrade, sessionStandsIn } from './install-mode.js';
|
|
119
119
|
import { keepTypedFields, openProjectFor, settingsCrumbs } from './settings-kit.js';
|
|
120
120
|
import { createSweepHandlers } from './server/sweeps.js';
|
|
121
|
+
import { sweepSkillBundleUpdates } from './skill-library.js';
|
|
121
122
|
import { createFlowsHandlers } from './server/flows.js';
|
|
122
123
|
import { createPagesHandlers } from './server/pages.js';
|
|
123
124
|
import { createPeopleHandlers } from './server/people-tokens.js';
|
|
@@ -203,7 +204,7 @@ function buildDecisionServer(options, leaveRehearsal) {
|
|
|
203
204
|
const database = store.handle.prepare('PRAGMA database_list').all().find(row => row['name'] === 'main')?.['file'];
|
|
204
205
|
if (typeof database === 'string' && database !== '') {
|
|
205
206
|
try {
|
|
206
|
-
coding = new CodingWorkspace({ database: `${database}.coding.sqlite`, worktreeRoot: join(dirname(database), 'coding-worktrees'), permissions: codingSessionPermissions(store, join(dirname(database), 'coding-worktrees')), admissionPaused: () => updateAdmissionPaused(store.raw()), authorize: (actor, repo) => codingActorAllowed(actor) && codingProjectAllowed(repo), context: input => prepareCodingContext(store, { ...input, root: join(dirname(database), 'coding-context') }) });
|
|
207
|
+
coding = new CodingWorkspace({ database: `${database}.coding.sqlite`, worktreeRoot: join(dirname(database), 'coding-worktrees'), permissions: codingSessionPermissions(store, join(dirname(database), 'coding-worktrees'), evidenceRoot ?? null), admissionPaused: () => updateAdmissionPaused(store.raw()), authorize: (actor, repo) => codingActorAllowed(actor) && codingProjectAllowed(repo), context: input => prepareCodingContext(store, { ...input, root: join(dirname(database), 'coding-context') }) });
|
|
207
208
|
}
|
|
208
209
|
catch (error) {
|
|
209
210
|
codingProblem = error instanceof Error ? error.message : 'The coding workspace could not open.';
|
|
@@ -1776,6 +1777,12 @@ function buildDecisionServer(options, leaveRehearsal) {
|
|
|
1776
1777
|
const last = lastChecks.known("release");
|
|
1777
1778
|
if (lastChecks.due("release", last !== null && "problem" in last.value ? 60_000 : 15 * 60_000))
|
|
1778
1779
|
waits.push(checkRelease());
|
|
1780
|
+
if (!store.isDemo() && store.schemaCurrent() && lastChecks.due("skill-bundles", 24 * 60 * 60_000)) {
|
|
1781
|
+
waits.push(lastChecks.run("skill-bundles", async () => {
|
|
1782
|
+
await sweepSkillBundleUpdates(store, { actor: "toolroll", now: clock() });
|
|
1783
|
+
return true;
|
|
1784
|
+
}));
|
|
1785
|
+
}
|
|
1779
1786
|
}
|
|
1780
1787
|
if (firstRunStepsNow(clock()) !== null && !store.hasAnyWork()) {
|
|
1781
1788
|
for (const repo of managedRepos()) {
|
|
@@ -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})$/;
|
|
@@ -25,6 +26,7 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
25
26
|
const stateRoot = deps.seams?.stateRoot ?? (dbFile && dbFile !== ":memory:" ? dirname(dbFile) : join(tmpdir(), "toolroll-direct-chat"));
|
|
26
27
|
const host = new DirectChatHost(store, {
|
|
27
28
|
stateRoot,
|
|
29
|
+
evidenceRoot: runtime.evidenceRoot ?? null,
|
|
28
30
|
...deps.seams,
|
|
29
31
|
onNotify: note => {
|
|
30
32
|
deps.seams?.onNotify?.(note);
|
|
@@ -564,7 +566,7 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
564
566
|
deps.bus.publish({ revision: `dc:${threadId}:ship-cancel:${Date.now()}` });
|
|
565
567
|
return checked(ctx, 200, "directChatMutated", { ok: true, said: "Auto-merge cancelled." });
|
|
566
568
|
}
|
|
567
|
-
const PAGE_PATH = /^\/direct-chats\/([a-f0-9]{32})(?:\/(ship-review|ship))?$/;
|
|
569
|
+
const PAGE_PATH = /^\/direct-chats\/([a-f0-9]{32})(?:\/(ship-review|ship|reply))?$/;
|
|
568
570
|
const STATUS_WORDS = { completed: "Finished", failed: "Failed", interrupted: "Stopped", running: "Working", queued: "Waiting" };
|
|
569
571
|
const DIFF_SHOWN = 200_000;
|
|
570
572
|
function pageRefusal(ctx, status, words) {
|
|
@@ -597,9 +599,28 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
597
599
|
const ships = listDirectChatShips(store, thread.id);
|
|
598
600
|
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
601
|
const shipAct = running || diff.changedFiles.length === 0 ? "" : postForm(`/direct-chats/${thread.id}/ship-review`, btn("Review Ship", { variant: "primary", type: "submit" }));
|
|
600
|
-
const
|
|
602
|
+
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>`
|
|
603
|
+
: running ? html `<p class="k-note">It's working on your last message. Reply when it finishes.</p>`
|
|
604
|
+
: 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") } });
|
|
605
|
+
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
606
|
return runtime.sendScreen(ctx.response, 200, screen(thread.title || "Direct Chat", body, { chrome: runtime.chromeFor(thread.repo, "tasks") }));
|
|
602
607
|
}
|
|
608
|
+
async function pageReply(ctx) {
|
|
609
|
+
const gate = admit(ctx, "direct-chat-send");
|
|
610
|
+
if (!gate.ok)
|
|
611
|
+
return pageRefusal(ctx, gate.status, gate.error);
|
|
612
|
+
const threadId = PAGE_PATH.exec(ctx.url.pathname)?.[1] ?? "";
|
|
613
|
+
const thread = host.getThreadRecord(gate.who.name, threadId);
|
|
614
|
+
if (thread === null || !canReachThread(gate.who.name, thread))
|
|
615
|
+
return pageRefusal(ctx, 404, "That Direct Chat isn't here.");
|
|
616
|
+
const prompt = ctx.posted.get("prompt") ?? "";
|
|
617
|
+
if (prompt.trim() === "")
|
|
618
|
+
return pageRefusal(ctx, 400, "Write a reply first. Nothing was sent.");
|
|
619
|
+
const res = await host.sendMessage({ owner: gate.who.name, threadId, requestId: ctx.posted.get("request") ?? "", prompt });
|
|
620
|
+
if (!res.ok)
|
|
621
|
+
return pageRefusal(ctx, res.status, res.error);
|
|
622
|
+
return redirect(ctx.response, `/direct-chats/${threadId}`);
|
|
623
|
+
}
|
|
603
624
|
async function pageShipReview(ctx) {
|
|
604
625
|
const gate = admit(ctx, "read");
|
|
605
626
|
if (!gate.ok)
|
|
@@ -646,6 +667,7 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
646
667
|
"direct-chat.page": pageDetail,
|
|
647
668
|
"direct-chat.page-ship-review": pageShipReview,
|
|
648
669
|
"direct-chat.page-ship": pageShip,
|
|
670
|
+
"direct-chat.page-reply": pageReply,
|
|
649
671
|
"direct-chat.list": list,
|
|
650
672
|
"direct-chat.detail": detail,
|
|
651
673
|
"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
|
],
|