toolroll 0.9.120 → 0.9.123
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 +70 -0
- package/README.md +10 -23
- package/dist/agent-fence.js +57 -9
- package/dist/batch-checks.js +2 -2
- package/dist/builder.js +10 -7
- package/dist/central-recovery-stage.js +3 -3
- package/dist/codex-limits.js +2 -2
- package/dist/coding-provider.js +3 -3
- package/dist/contracts/console-api.js +1 -0
- package/dist/direct-chat-fence.js +9 -3
- package/dist/direct-chat.js +82 -10
- package/dist/first-run.js +1 -1
- package/dist/flexible-agents.js +16 -2
- package/dist/flexible-save.js +8 -8
- package/dist/flexible-session.js +2 -1
- package/dist/flexible-thread.js +5 -1
- 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-landing.js +48 -8
- package/dist/local-owner.js +1 -0
- package/dist/operate.js +40 -10
- package/dist/plan-limits-demand.js +32 -10
- 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 +2 -2
- package/dist/scout.js +2 -1
- package/dist/serve.js +8 -1
- package/dist/server/direct-chat.js +1 -0
- package/dist/server/engine-api.js +6 -5
- package/dist/server/render-release.js +27 -15
- package/dist/server/route-table.js +2 -0
- package/dist/server/settings.js +151 -3
- package/dist/server/task-views.js +4 -3
- package/dist/server/tasks.js +11 -10
- package/dist/server/terminals.js +3 -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/surface.js +1 -1
- package/dist/task-status.js +2 -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/work-index.js +5 -2
- package/dist/work-summary.js +77 -1
- package/dist/workspace-ui.js +12 -6
- package/package.json +2 -1
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
import { realCustodyIO } from "./flexible-custody.js";
|
|
2
|
+
function processesNow() {
|
|
3
|
+
let table;
|
|
4
|
+
return (pid, start) => {
|
|
5
|
+
if (table === undefined)
|
|
6
|
+
table = realCustodyIO(() => null).table();
|
|
7
|
+
return table?.some(row => row.pid === pid && !row.zombie && row.start === start) ?? false;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
const PROCESS_ROWS_AT_MOST = 500;
|
|
1
11
|
export const PLAN_LIMITS_VIEW_WINDOW_MS = 10 * 60_000;
|
|
2
|
-
const QUEUED_RECENTLY_MS = 60 * 60_000;
|
|
3
12
|
const RUNNING_AT_MOST_MS = 6 * 3_600_000;
|
|
4
13
|
const viewedAt = new WeakMap();
|
|
5
14
|
const listeners = new WeakMap();
|
|
@@ -26,20 +35,33 @@ function any(store, sql, ...values) {
|
|
|
26
35
|
return false;
|
|
27
36
|
}
|
|
28
37
|
}
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
function processesOf(store, sql, ...values) {
|
|
39
|
+
try {
|
|
40
|
+
return store.handle.prepare(sql).all(...values).flatMap(row => typeof row["pid"] === "number" && typeof row["start"] === "string" && row["start"] !== ""
|
|
41
|
+
? [{ pid: row["pid"], start: row["start"] }] : []);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function agentWorkActive(store, now, alive = processesNow()) {
|
|
48
|
+
const at = now.toISOString();
|
|
31
49
|
const runningSince = new Date(now.getTime() - RUNNING_AT_MOST_MS).toISOString();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|| any(store,
|
|
36
|
-
|
|
50
|
+
const living = (rows) => rows.some(one => alive(one.pid, one.start));
|
|
51
|
+
return any(store, `SELECT 1 FROM run r JOIN claim c ON c.lease_id = r.lease_id WHERE r.outcome IS NULL AND r.started_at > ?
|
|
52
|
+
AND c.released_at IS NULL AND c.expires_at > ? LIMIT 1`, runningSince, at)
|
|
53
|
+
|| any(store, `SELECT 1 FROM lead_queue q JOIN mate_turn m ON m.id = q.turn_id WHERE q.status = 'running' AND q.claimed_at > ?
|
|
54
|
+
AND m.state = 'running' AND m.deadline_at > ? LIMIT 1`, runningSince, at)
|
|
55
|
+
|| living(processesOf(store, `SELECT l.leader_pid AS pid, l.leader_start AS start FROM thread_turn t JOIN flexible_thread_launch l ON l.turn = t.id
|
|
56
|
+
WHERE t.status = 'running' AND t.started_at > ? AND l.state = 'live' LIMIT ${PROCESS_ROWS_AT_MOST}`, runningSince))
|
|
57
|
+
|| living(processesOf(store, `SELECT pid, start_identity AS start FROM direct_chat_turn WHERE status = 'running' AND created_at > ?
|
|
58
|
+
LIMIT ${PROCESS_ROWS_AT_MOST}`, runningSince));
|
|
37
59
|
}
|
|
38
|
-
export function planLimitsWanted(store, now) {
|
|
60
|
+
export function planLimitsWanted(store, now, alive) {
|
|
39
61
|
const viewed = viewedAt.get(store);
|
|
40
62
|
if (viewed !== undefined && now.getTime() - viewed >= 0 && now.getTime() - viewed < PLAN_LIMITS_VIEW_WINDOW_MS)
|
|
41
63
|
return true;
|
|
42
|
-
return agentWorkActive(store, now);
|
|
64
|
+
return agentWorkActive(store, now, alive);
|
|
43
65
|
}
|
|
44
66
|
export function directChatRunning(store, provider, now) {
|
|
45
67
|
const since = new Date(now.getTime() - RUNNING_AT_MOST_MS).toISOString();
|
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
|
}
|
|
@@ -262,7 +262,7 @@ export async function runFollowUpCheck(store, root, request, deps = {}) {
|
|
|
262
262
|
let ready = true;
|
|
263
263
|
if (setup !== null) {
|
|
264
264
|
const shell = approvedCommandShell(setup.command);
|
|
265
|
-
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 });
|
|
266
266
|
note("Approved project setup", setup.command, prepared);
|
|
267
267
|
proveLaunch();
|
|
268
268
|
if (prepared.code !== 0 || prepared.timedOut || prepared.notFound) {
|
|
@@ -277,7 +277,7 @@ export async function runFollowUpCheck(store, root, request, deps = {}) {
|
|
|
277
277
|
}
|
|
278
278
|
else {
|
|
279
279
|
const shell = approvedCommandShell(live.command);
|
|
280
|
-
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 });
|
|
281
281
|
note(`${CHECK_LEVEL_WORDS[target.level]} check`, live.command, ran);
|
|
282
282
|
proveLaunch();
|
|
283
283
|
if (!ran.timedOut && !ran.notFound) {
|
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()) {
|
|
@@ -26,6 +26,7 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
26
26
|
const stateRoot = deps.seams?.stateRoot ?? (dbFile && dbFile !== ":memory:" ? dirname(dbFile) : join(tmpdir(), "toolroll-direct-chat"));
|
|
27
27
|
const host = new DirectChatHost(store, {
|
|
28
28
|
stateRoot,
|
|
29
|
+
evidenceRoot: runtime.evidenceRoot ?? null,
|
|
29
30
|
...deps.seams,
|
|
30
31
|
onNotify: note => {
|
|
31
32
|
deps.seams?.onNotify?.(note);
|
|
@@ -11,7 +11,7 @@ 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
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
|
+
import { admitFlexibleThreadOwner, answerFlexibleRequest, cancelFlexibleThreadShip, closeFlexibleSessions, closeFlexibleThread, continueFlexibleThread, flexibleShipNeedsFor, 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";
|
|
15
15
|
import { createFlexibleLauncher } from "../flexible-launcher.js";
|
|
16
16
|
import { FLEXIBLE_NEXT_WORDS, flexibleReadiness, flexibleStartCard } from "../flexible-start.js";
|
|
17
17
|
import { summaryLines } from "../approval-summary.js";
|
|
@@ -171,7 +171,7 @@ export function createEngineHandlers(runtime) {
|
|
|
171
171
|
const admitted = admitFlexibleThreadOwner(store, sessions, { thread, viewer: { name: who.name }, canAccess: repo => store.accountCanAccess(who.name, repo) });
|
|
172
172
|
return admitted.ok ? admitted.repo : null;
|
|
173
173
|
};
|
|
174
|
-
const acted = (response, status, outcome, words, next) => json(response, status, next === undefined ? {
|
|
174
|
+
const acted = (response, status, outcome, words, next, command = null) => json(response, status, { outcome, words, ...(next === undefined ? {} : { next }), ...(command === null ? {} : { command }) });
|
|
175
175
|
async function liveThread(ctx) {
|
|
176
176
|
const { url, who, request, response } = ctx;
|
|
177
177
|
if (who.via !== "cookie")
|
|
@@ -577,7 +577,8 @@ export function createEngineHandlers(runtime) {
|
|
|
577
577
|
if (!done.ok)
|
|
578
578
|
return acted(response, 409, "refused", done.message);
|
|
579
579
|
const words = act === "end"
|
|
580
|
-
? done.already ? "This thread had already ended." : done.stopPending ? "Ended. Stopping its agent…"
|
|
580
|
+
? done.already ? "This thread had already ended." : done.stopPending ? "Ended. Stopping its agent…"
|
|
581
|
+
: flexibleShipNeedsFor(store, id) === null ? "Ended. You can still ship its work, or save it as a branch." : "Ended. You can still save its work as a branch (S on the thread)."
|
|
581
582
|
: done.stopPending ? "Stopping its agent…" : "Stopped. Reply to go on.";
|
|
582
583
|
return acted(response, 200, "done", words);
|
|
583
584
|
};
|
|
@@ -594,7 +595,7 @@ export function createEngineHandlers(runtime) {
|
|
|
594
595
|
const by = { name: who.name, generation: who.session.generation };
|
|
595
596
|
const shown = await flexibleThreadShipTerms(store, { thread: id, by });
|
|
596
597
|
if (!shown.ok)
|
|
597
|
-
return acted(response, 409, "refused", shown.message);
|
|
598
|
+
return acted(response, 409, "refused", shown.message, undefined, shown.reason === "no-check" || shown.reason === "no-publishing" ? `toolroll thread save ${id.slice(0, 8)}` : null);
|
|
598
599
|
const laptop = who.authority === "local-owner" && who.session.localGeneration !== null
|
|
599
600
|
&& laptopShipProblem(store, { owner: who.name, localGeneration: who.session.localGeneration }) === null;
|
|
600
601
|
const command = `toolroll thread ship ${id} --key ${shown.summary.key}`;
|
|
@@ -677,7 +678,7 @@ export function createEngineHandlers(runtime) {
|
|
|
677
678
|
const saved = await saveFlexibleBranch(store, { thread: id, by: { name: who.name, generation: who.session.generation }, now: new Date(), prove: held });
|
|
678
679
|
if (!saved.ok)
|
|
679
680
|
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
|
+
return acted(response, 200, "done", `${saved.already ? `Already saved as ${saved.branch}.` : `Saved as ${saved.branch} (commit ${saved.candidate.slice(0, 12)}).`} ${saved.next}`, undefined, saved.command);
|
|
681
682
|
}
|
|
682
683
|
async function leadChat(ctx) {
|
|
683
684
|
const { url, who, request, response, now } = ctx;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { html,
|
|
2
|
-
import { ciWords
|
|
1
|
+
import { html, postForm } from "../html.js";
|
|
2
|
+
import { ciWords } from "../release-approval.js";
|
|
3
|
+
import { releaseAccessWords } from "../release-card.js";
|
|
3
4
|
import { checkAccessWords } from "../check-access.js";
|
|
4
5
|
import { projectName } from "../project.js";
|
|
5
6
|
import { screen } from "./chrome.js";
|
|
@@ -15,23 +16,36 @@ function changesHtml(card) {
|
|
|
15
16
|
const head = changes.baseline === null ? `Pull request #${id.pr}'s commits` : `Since the last verified release (${changes.baseline.slice(0, 7)})`;
|
|
16
17
|
const list = changes.commits.length === 0 ? note("No commits.")
|
|
17
18
|
: html `<ul class="k-list">${changes.commits.map(one => html `<li><code class="k-mono">${one.sha.slice(0, 7)}</code> ${one.subject}</li>`)}</ul>`;
|
|
18
|
-
return disclose(`What changed: ${changes.commits.length} commit${changes.commits.length === 1 ? "" : "s"}`, html `<p class="k-note">${head}</p>${list}
|
|
19
|
+
return disclose(`What changed: ${changes.commits.length} commit${changes.commits.length === 1 ? "" : "s"}`, html `<p class="k-note">${head}</p>${list}`, changes.commits.length > 0 && changes.commits.length <= 5);
|
|
20
|
+
}
|
|
21
|
+
function releaseSummaryHtml(card) {
|
|
22
|
+
const id = card.seal.identity;
|
|
23
|
+
const carries = card.seal.kind === "terms" && card.seal.terms.policy.carry;
|
|
24
|
+
const checkKind = card.seal.kind === "check" && card.seal.purpose.check === "deploy"
|
|
25
|
+
? "Deploy check (~4 min)"
|
|
26
|
+
: checkAccessWords(id.access);
|
|
27
|
+
const accessWarning = releaseAccessWords(id.access);
|
|
28
|
+
const rows = [
|
|
29
|
+
["Commit", html `<code class="k-mono" title="${id.approvedSha}">${id.approvedSha.slice(0, 7)}</code> · <code class="k-mono">${id.branch}</code>`],
|
|
30
|
+
["Check", checkKind],
|
|
31
|
+
["On approve", `Runs the release check on ${id.approvedSha.slice(0, 7)}, then deploys, merges, tags and publishes once GitHub CI and the check pass.`],
|
|
32
|
+
["Later commits", carries ? "Later commits that only change tests, docs or the changelog carry this approval." : "Every later commit asks again."],
|
|
33
|
+
];
|
|
34
|
+
return html `${accessWarning === null ? "" : notice(accessWarning)}${facts(rows)}`;
|
|
19
35
|
}
|
|
20
36
|
function termsHtml(card) {
|
|
21
|
-
|
|
37
|
+
const isRelease = (key) => key.startsWith("release.") || key.startsWith("releaseCheck.");
|
|
38
|
+
const releaseTerms = card.terms.filter(line => isRelease(line.key));
|
|
39
|
+
const scopeTerms = card.terms.filter(line => !isRelease(line.key));
|
|
40
|
+
const renderRows = (lines) => facts(lines.map(line => [line.label, html `<span class="k-mono">${line.value}</span>`]));
|
|
41
|
+
const inner = html `${releaseTerms.length === 0 ? "" : html `<h3>Release</h3>${renderRows(releaseTerms)}`}${scopeTerms.length === 0 ? "" : html `<h3>Underlying scope & settings</h3>${renderRows(scopeTerms)}`}`;
|
|
42
|
+
return disclose(`Every term (${card.terms.length})`, inner, false);
|
|
22
43
|
}
|
|
23
44
|
export function releaseSheetPage(chrome, data) {
|
|
24
45
|
const card = data.card;
|
|
25
46
|
const id = card.seal.identity;
|
|
26
47
|
const title = `Release ${id.packageVersion}`;
|
|
27
|
-
const
|
|
28
|
-
["Pull request", `#${id.pr}`],
|
|
29
|
-
["Branch", html `<code class="k-mono">${id.branch}</code>`],
|
|
30
|
-
["Commit", html `<code class="k-mono">${id.approvedSha}</code>`],
|
|
31
|
-
["Project", projectName(id.repo)],
|
|
32
|
-
["Checks", checkAccessWords(id.access)],
|
|
33
|
-
]);
|
|
34
|
-
const consequence = releaseConsequence(card);
|
|
48
|
+
const summaryHtml = releaseSummaryHtml(card);
|
|
35
49
|
const ci = ciWords(card.ci, id.approvedSha);
|
|
36
50
|
const notRunning = card.stopped === null ? "" : infoLine(html `The release isn't running (it stopped at ${card.stopped.step}). After you approve, run <code class="k-mono">toolroll release ${id.branch}</code>.`);
|
|
37
51
|
let status, text, acts, terms, wait = false;
|
|
@@ -60,12 +74,10 @@ export function releaseSheetPage(chrome, data) {
|
|
|
60
74
|
text = ci;
|
|
61
75
|
acts = data.nonce === "" ? "" : approveForm({
|
|
62
76
|
action: `${taskHref(card.taskId)}/approve`, kind: "standard", facts: data.facts, label: "Approve release", primary: true,
|
|
63
|
-
before: html `<section class="k-sec"><h3>What approving does</h3>${joinHtml(consequence.map(line => html `<p class="k-note">${line}</p>`))}${termsHtml(card)}</section>`,
|
|
64
77
|
form: { hidden: { nonce: data.nonce, digest: card.digest, sheet: "release" }, attrs: { class: "k-form", "data-release-approve": card.digest } },
|
|
65
78
|
});
|
|
66
79
|
terms = approvalTerms("standard", data.facts);
|
|
67
80
|
}
|
|
68
|
-
const
|
|
69
|
-
const body = doc(docHeader({ title, back: [taskHref(card.taskId), "Task"], meta: `${projectName(id.repo)} · pull request #${id.pr}` }), data.problem === null ? "" : notice(data.problem), summary, changesHtml(card), slots({ wait, attrs: { "data-release-sheet": card.taskId }, status, text, acts, terms }), notRunning, data.held == null ? "" : html `<section class="k-sec" data-release-held><h3>Held after its merge</h3><p class="k-note">${data.held}.</p>${postForm(`${taskHref(card.taskId)}/release/go-on`, html `${field({ id: "go-on-password", label: "Your password", control: input({ id: "go-on-password", name: "password", type: "password", attrs: { required: true, autocomplete: "current-password" } }) })}${btn("Let it go on", { variant: "primary", type: "submit" })}`, { attrs: { class: "k-form" } })}</section>`, formShown ? "" : html `<section class="k-sec"><h3>What approving does</h3>${joinHtml(consequence.map(line => html `<p class="k-note">${line}</p>`))}</section>${termsHtml(card)}`);
|
|
81
|
+
const body = doc(docHeader({ title, back: [taskHref(card.taskId), "Task"], meta: `${projectName(id.repo)} · pull request #${id.pr}` }), data.problem === null ? "" : notice(data.problem), slots({ wait, attrs: { "data-release-sheet": card.taskId }, status, text, body: summaryHtml, acts, terms }), notRunning, data.held == null ? "" : html `<section class="k-sec" data-release-held><h3>Held after its merge</h3><p class="k-note">${data.held}.</p>${postForm(`${taskHref(card.taskId)}/release/go-on`, html `${field({ id: "go-on-password", label: "Your password", control: input({ id: "go-on-password", name: "password", type: "password", attrs: { required: true, autocomplete: "current-password" } }) })}${btn("Let it go on", { variant: "primary", type: "submit" })}`, { attrs: { class: "k-form" } })}</section>`, changesHtml(card), termsHtml(card));
|
|
70
82
|
return screen(title, body, { chrome });
|
|
71
83
|
}
|
|
@@ -98,6 +98,7 @@ const LOCAL_POSTS = Object.freeze({
|
|
|
98
98
|
"term.agent-install": "agent-install",
|
|
99
99
|
"engine.agents-check": "check-agents",
|
|
100
100
|
"settings.models-agent": "change-models",
|
|
101
|
+
"settings.skills-library": "skill-library",
|
|
101
102
|
"task.act.archive": "archive-task",
|
|
102
103
|
"task.act.restore": "archive-task",
|
|
103
104
|
"projects.open": "add-project",
|
|
@@ -462,6 +463,7 @@ post("tasks", "code.act-other", "^\\/code(\\/.*)?$", { ...CODING_ACT, sample: "/
|
|
|
462
463
|
post("settings", "settings.skills-revise", "/settings/skills/revise", { project: "form", limited: "unscoped", ...approver("Sign in to revise a test.", "/settings/skills") });
|
|
463
464
|
post("settings", "settings.skills-import", "/settings/skills/import", { project: "form", limited: "unscoped", bodyCap: 2 * 1024 * 1024, ...approver("Sign in as an approver to manage skills.", "/settings/skills") });
|
|
464
465
|
post("settings", "settings.skills-change", "/settings/skills/change", { project: "form", limited: "unscoped", ...approver("Sign in as an approver to manage skills.", "/settings/skills") });
|
|
466
|
+
post("settings", "settings.skills-library", "/settings/skills/library", { project: "none", limited: "unscoped", bodyCap: 2 * 1024 * 1024, ...approver("Sign in as an approver to manage the skill library.", "/settings/skills") });
|
|
465
467
|
for (const one of ["setup", "sample", "github"])
|
|
466
468
|
post("flows", `kit.${one}`, `^\\/kits\\/[a-z-]{1,40}\\/${one}$`, { project: "form", sample: `/kits/support/${one}`, ...approver("Sign in as an approver to set kits up.", "/kits") });
|
|
467
469
|
const SUBAGENTS = anyApprover("Sign in as an approver to look after subagents.", "/settings/lead/subagents");
|