toolroll 0.9.110 → 0.9.112
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 +66 -0
- package/README.md +5 -1
- package/THIRD_PARTY_NOTICES.md +30 -0
- package/dist/action-ledger.js +13 -0
- package/dist/agent-detect.js +1 -1
- package/dist/agent-said-schema.js +4 -0
- package/dist/agent-said.js +77 -0
- package/dist/approval-summary.js +39 -8
- package/dist/bin.js +5 -1
- package/dist/browser/THIRD_PARTY_NOTICES.txt +30 -0
- package/dist/browser/terminal.js +1 -1
- package/dist/browser/workspace.js +1 -1
- package/dist/builder.js +6 -1
- package/dist/chat-channel.js +10 -0
- package/dist/claim.js +28 -13
- package/dist/cli-help.js +7 -1
- package/dist/cli.js +2 -0
- package/dist/codex-limits.js +21 -8
- package/dist/console-instance.js +2 -1
- package/dist/contracts/console-api.js +3 -2
- package/dist/contracts/engine-api.js +15 -3
- package/dist/contracts/lead-tools.js +28 -0
- package/dist/contracts/route.js +1 -0
- package/dist/dispatch.js +1 -1
- package/dist/dispose.js +15 -9
- package/dist/easy-start.js +19 -3
- package/dist/engine-reads.js +79 -2
- package/dist/evidence.js +6 -6
- package/dist/fast-start.js +20 -11
- package/dist/flexible-start.js +1 -1
- package/dist/integrations.js +6 -1
- package/dist/lead-tools.js +107 -1
- package/dist/lead.js +1 -1
- package/dist/ledger-view.js +2 -1
- package/dist/local-owner.js +1 -0
- package/dist/needs-you.js +12 -2
- package/dist/operate.js +57 -9
- package/dist/outbound-privacy.js +6 -1
- package/dist/phase-routing.js +3 -1
- package/dist/plain-words.js +1 -1
- package/dist/plane-review.js +1 -1
- package/dist/proposal.js +2 -2
- package/dist/provider-connection.js +14 -2
- package/dist/release.js +1 -0
- package/dist/route-store.js +1 -1
- package/dist/serve.js +6 -4
- package/dist/server/chat.js +6 -1
- package/dist/server/pages.js +4 -1
- package/dist/server/render-history.js +2 -1
- package/dist/server/render-tasks.js +5 -2
- package/dist/server/route-table.js +2 -0
- package/dist/server/settings-section-table.js +3 -0
- package/dist/server/settings-sections.js +36 -0
- package/dist/server/settings.js +36 -0
- package/dist/server/tasks.js +31 -4
- package/dist/settings-proofs.js +1 -0
- package/dist/store.js +83 -11
- package/dist/task-sizing-schema.js +14 -0
- package/dist/task-sizing.js +76 -10
- package/dist/toolroll-update.js +3 -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/view-tools.js +94 -0
- package/dist/webhooks.js +8 -2
- package/dist/work-index.js +4 -4
- package/package.json +2 -1
package/dist/server/tasks.js
CHANGED
|
@@ -1604,7 +1604,16 @@ export function createTasksHandlers(runtime) {
|
|
|
1604
1604
|
return redirect(response, taskHref(taskId));
|
|
1605
1605
|
}
|
|
1606
1606
|
case "unhold": {
|
|
1607
|
-
|
|
1607
|
+
const shown = readForm(posted, CONSOLE_FORMS.taskUnhold).get("hold");
|
|
1608
|
+
if (shown !== null && !/^[1-9][0-9]{0,15}$/.test(shown))
|
|
1609
|
+
return taskScreen(response, who, taskId, "not resumed: name the hold that was shown", 400);
|
|
1610
|
+
const ended = store.getTask(taskId)?.state;
|
|
1611
|
+
if (ended === "cancelled" || ended === "done") {
|
|
1612
|
+
return taskScreen(response, who, taskId, ended === "cancelled" ? "This task was cancelled, so there is nothing to resume." : "This task is finished, so there is nothing to resume.", 409);
|
|
1613
|
+
}
|
|
1614
|
+
const released = store.unhold(ref.id, {}, now, shown === null ? undefined : Number(shown));
|
|
1615
|
+
if (shown !== null && !released)
|
|
1616
|
+
return taskScreen(response, who, taskId, "This task's hold changed since it was shown — look again before resuming.", 409);
|
|
1608
1617
|
return redirect(response, taskHref(taskId));
|
|
1609
1618
|
}
|
|
1610
1619
|
case "stop-carrying": {
|
|
@@ -1632,9 +1641,16 @@ export function createTasksHandlers(runtime) {
|
|
|
1632
1641
|
replayed = retried.replayed;
|
|
1633
1642
|
}
|
|
1634
1643
|
else {
|
|
1635
|
-
const
|
|
1644
|
+
const sentRun = body.get("run") ?? null, sentDigest = body.get("digest") ?? null;
|
|
1645
|
+
let pins;
|
|
1646
|
+
if (sentRun !== null || sentDigest !== null) {
|
|
1647
|
+
if (sentRun === null || !/^[1-9][0-9]{0,14}$/.test(sentRun) || sentDigest === null || !/^[a-f0-9]{32}$/.test(sentDigest))
|
|
1648
|
+
return taskScreen(response, who, taskId, TASK_CHANGED_SINCE, 409);
|
|
1649
|
+
pins = { run: Number(sentRun), digest: sentDigest };
|
|
1650
|
+
}
|
|
1651
|
+
const requeued = store.requeueTask(taskId, who.name, now, undefined, pins);
|
|
1636
1652
|
if (!requeued.ok) {
|
|
1637
|
-
return taskScreen(response, who, taskId, `not requeued: ${requeued.reason}`, 409);
|
|
1653
|
+
return taskScreen(response, who, taskId, requeued.reason === "stale" ? TASK_CHANGED_SINCE : `not requeued: ${requeued.reason}`, 409);
|
|
1638
1654
|
}
|
|
1639
1655
|
}
|
|
1640
1656
|
if (note !== "" && !replayed) {
|
|
@@ -1777,7 +1793,17 @@ export function createTasksHandlers(runtime) {
|
|
|
1777
1793
|
case "cancel": {
|
|
1778
1794
|
const body = readForm(posted, CONSOLE_FORMS.taskCancel);
|
|
1779
1795
|
const reason = body.get("reason") ?? undefined;
|
|
1780
|
-
const
|
|
1796
|
+
const seenState = body.get("state"), seenRun = body.get("run");
|
|
1797
|
+
if ((seenState === null) !== (seenRun === null) || (seenRun !== null && !/^(?:none|[1-9][0-9]{0,15})$/.test(seenRun))) {
|
|
1798
|
+
return taskScreen(response, who, taskId, "not cancelled: name both the state and the build that were shown", 400);
|
|
1799
|
+
}
|
|
1800
|
+
if (who.via === "cookie" && seenState === null)
|
|
1801
|
+
return taskScreen(response, who, taskId, "not cancelled: name both the state and the build that were shown", 400);
|
|
1802
|
+
const seen = seenState === null || seenRun === null ? undefined : { state: seenState, run: seenRun === "none" ? null : Number(seenRun) };
|
|
1803
|
+
const cancelled = withActor({ account: who.name, lead: false }, () => store.cancelTask(taskId, now, reason, seen));
|
|
1804
|
+
if (!cancelled.ok && cancelled.reason === "changed") {
|
|
1805
|
+
return taskScreen(response, who, taskId, "This task changed since it was shown — look again before cancelling.", 409);
|
|
1806
|
+
}
|
|
1781
1807
|
if (!cancelled.ok) {
|
|
1782
1808
|
if (cancelled.reason === "reason-required" || cancelled.reason === "bad-reason") {
|
|
1783
1809
|
return taskScreen(response, who, taskId, cancelled.reason === "reason-required"
|
|
@@ -2915,3 +2941,4 @@ export const YOU_SAID_CAP = 8;
|
|
|
2915
2941
|
export function answerTermsInPlace(response, offer) {
|
|
2916
2942
|
respond(response, 200, "application/json; charset=utf-8", JSON.stringify({ outcome: "terms", preview: offer.preview, digest: offer.digest, terms: offer.terms.map(([label, words]) => ({ label, words })) }));
|
|
2917
2943
|
}
|
|
2944
|
+
export const TASK_CHANGED_SINCE = "This task changed since you looked. Review it again.";
|
package/dist/settings-proofs.js
CHANGED
|
@@ -55,6 +55,7 @@ export const PROOF_INVENTORY = [
|
|
|
55
55
|
{ id: "mode-sign-chat-approve", action: "Sign an operating mode that lets your chat app approve", routes: ["/mode/sign"], select: { field: "chat-approve", value: "1" }, form: "mode", field: "token", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver of the project", secrets: [], terms: MODE_TERMS },
|
|
56
56
|
{ id: "mode-sign-repair", action: "Sign an operating mode that repairs failed checks by itself", routes: ["/mode/sign"], select: { field: "repair-auto", value: "1" }, form: "mode", field: "token", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver of the project", secrets: [], terms: MODE_TERMS },
|
|
57
57
|
{ id: "install-solo", action: "Say it's just you", routes: ["/settings/install-mode/solo"], form: "justMe", field: "password", proof: "credential", ...CREDENTIAL, role: "operator", handlerRole: "a full session (never the local owner)", secrets: [], terms: [] },
|
|
58
|
+
{ id: "task-sizing", action: "Turn task sizing by a quick model call on or off", routes: ["/settings/task-sizing"], form: "taskSizing", field: "password", proof: "step-up", ...ACCEPT, role: "operator", secrets: [], terms: ["enabled", "sizer"] },
|
|
58
59
|
{ id: "provider-key", action: "Save an AI provider key", routes: ["/settings/provider-key"], form: "providerKey", field: "password", proof: "credential", ...CREDENTIAL, role: "any", secrets: ["value"], terms: [] },
|
|
59
60
|
{ id: "telegram-token", action: "Save the Telegram bot token", routes: ["/settings/telegram-token"], form: "telegramToken", field: "password", proof: "credential", ...CREDENTIAL, role: "any", secrets: ["token"], notProof: ["token"], terms: [] },
|
|
60
61
|
{ id: "email", action: "Set up email", routes: ["/settings/email"], form: "email", field: "token", proof: "credential", ...CREDENTIAL, role: "any", secrets: ["password"], notProof: ["password"], terms: [] },
|
package/dist/store.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { verifyResultImage } from "./chat-evidence.js";
|
|
2
2
|
import { parseFeedbackImage } from "./result-review.js";
|
|
3
|
+
import { agentSaidTail } from "./agent-said.js";
|
|
3
4
|
import { mintSecret } from "./secret-mint.js";
|
|
4
5
|
import { WRITES_DEFAULT } from "./writes-mode.js";
|
|
5
6
|
import { checkAccessOf, widerThan } from "./check-access.js";
|
|
@@ -25,6 +26,8 @@ import { V165_OBJECTS, V165_SCHEMA, V165_STEPS } from "./flexible-launch-schema.
|
|
|
25
26
|
import { V166_OBJECTS, V166_SCHEMA, V166_STEPS } from "./flexible-relay-schema.js";
|
|
26
27
|
import { V167_OBJECTS, V167_SCHEMA, V167_STEPS } from "./flexible-answers-schema.js";
|
|
27
28
|
import { V168_OBJECTS, V168_SCHEMA, V168_STEPS } from "./flexible-ship-schema.js";
|
|
29
|
+
import { V169_ADDED_COLUMNS, V169_SCHEMA, V169_STEPS } from "./task-sizing-schema.js";
|
|
30
|
+
import { V170_ADDED_COLUMNS, V170_STEPS } from "./agent-said-schema.js";
|
|
28
31
|
import { endLapsedFlexible } from "./flexible.js";
|
|
29
32
|
import { refArchived, taskArchived, taskCancelled } from "./task-archive.js";
|
|
30
33
|
export { refArchived, taskArchived } from "./task-archive.js";
|
|
@@ -829,7 +832,7 @@ export function checkSuitesOf(value) {
|
|
|
829
832
|
}
|
|
830
833
|
}
|
|
831
834
|
const REGISTERED_AT_FILING = "again, as it was filed";
|
|
832
|
-
export const SCHEMA_VERSION =
|
|
835
|
+
export const SCHEMA_VERSION = 170;
|
|
833
836
|
export const V118_MERGED_TABLES = Object.freeze({ api_token: "person", coordinator_credential: "coordinator", lead_credential: "lead" });
|
|
834
837
|
const V118_REFERENCES = /REFERENCES (?:coordinator_credential\(cid\)|api_token\(id\))/g;
|
|
835
838
|
const V118_COORDINATOR_COLUMNS = [["task_ref", "coordinator_cid"], ["coordinator_event", "cid"], ["mcp_idempotency", "cid"], ["coordinator_proposal", "cid"]];
|
|
@@ -894,7 +897,7 @@ export const V115_DROPPED_TABLES = Object.freeze([
|
|
|
894
897
|
"fallback_config", "fallback_cycle", "fallback_transition",
|
|
895
898
|
]);
|
|
896
899
|
const V115_DROPPED_REFERENCES = /\s+REFERENCES (?:contestant|contest|tournament_terms|session_turn|attended_authorization|held_session|fallback_cycle|fallback_config|fallback_transition|routine|routine_fire)\(id\)(?: ON DELETE CASCADE)?/g;
|
|
897
|
-
export const UPDATE_SAFE_MIGRATIONS = Object.freeze([108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168]);
|
|
900
|
+
export const UPDATE_SAFE_MIGRATIONS = Object.freeze([108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170]);
|
|
898
901
|
export const V119_ADDED_COLUMNS = Object.freeze({
|
|
899
902
|
task_ref: { planning_generation: { definition: "INTEGER NOT NULL DEFAULT 0", saved: "0" } },
|
|
900
903
|
run: { planning_generation: { definition: "INTEGER NOT NULL DEFAULT 0", saved: "0" } },
|
|
@@ -1437,7 +1440,7 @@ export { V156_STEPS };
|
|
|
1437
1440
|
export { V157_STEPS };
|
|
1438
1441
|
export { V158_STEPS };
|
|
1439
1442
|
export { V159_STEPS };
|
|
1440
|
-
export { V160_STEPS, V161_STEPS, V162_STEPS, V163_STEPS, V164_STEPS, V165_STEPS, V166_STEPS, V167_STEPS, V168_STEPS };
|
|
1443
|
+
export { V160_STEPS, V161_STEPS, V162_STEPS, V163_STEPS, V164_STEPS, V165_STEPS, V166_STEPS, V167_STEPS, V168_STEPS, V169_STEPS, V170_STEPS };
|
|
1441
1444
|
export const RELEASE_ONCE_SCHEMA = `
|
|
1442
1445
|
CREATE TABLE IF NOT EXISTS release_authority (
|
|
1443
1446
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -4215,7 +4218,7 @@ function initializeStore(db, file, options = {}) {
|
|
|
4215
4218
|
throw new Error(`${file}: ${problem}; refusing to move chat history it cannot name`);
|
|
4216
4219
|
}
|
|
4217
4220
|
if (preflight === SCHEMA_VERSION && !findingSourcesStale(db)) {
|
|
4218
|
-
const missing = codeMapShapeProblem(db) ?? viewPreferenceShapeProblem(db) ?? flexibleTermsShapeProblem(db) ?? flexibleThreadShapeProblem(db) ?? typedByPersonShapeProblem(db) ?? flexibleTurnsShapeProblem(db) ?? flexibleLaunchShapeProblem(db) ?? flexibleRelayShapeProblem(db) ?? flexibleAnswersShapeProblem(db) ?? flexibleShipShapeProblem(db);
|
|
4221
|
+
const missing = codeMapShapeProblem(db) ?? viewPreferenceShapeProblem(db) ?? flexibleTermsShapeProblem(db) ?? flexibleThreadShapeProblem(db) ?? typedByPersonShapeProblem(db) ?? flexibleTurnsShapeProblem(db) ?? flexibleLaunchShapeProblem(db) ?? flexibleRelayShapeProblem(db) ?? flexibleAnswersShapeProblem(db) ?? flexibleShipShapeProblem(db) ?? taskSizingShapeProblem(db) ?? agentSaidShapeProblem(db);
|
|
4219
4222
|
if (missing !== null)
|
|
4220
4223
|
throw new Error(`${file}: refusing to open — ${missing}, though the schema says v${SCHEMA_VERSION}`);
|
|
4221
4224
|
db.exec("PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON;");
|
|
@@ -4597,6 +4600,19 @@ CREATE INDEX IF NOT EXISTS run_checkpoint_by_task ON run_checkpoint (task_ref, i
|
|
|
4597
4600
|
if (shipDamaged !== null)
|
|
4598
4601
|
throw new Error(`${file}: refusing to open — ${shipDamaged}`);
|
|
4599
4602
|
step("flexible-ship");
|
|
4603
|
+
db.exec(V169_SCHEMA);
|
|
4604
|
+
for (const [table, columns] of Object.entries(V169_ADDED_COLUMNS))
|
|
4605
|
+
for (const [column, { definition }] of Object.entries(columns))
|
|
4606
|
+
addColumn(db, table, column, definition);
|
|
4607
|
+
const sizingDamaged = taskSizingShapeProblem(db);
|
|
4608
|
+
if (sizingDamaged !== null)
|
|
4609
|
+
throw new Error(`${file}: refusing to open — ${sizingDamaged}`);
|
|
4610
|
+
step("task-sizing-setting");
|
|
4611
|
+
step("task-sizing-columns");
|
|
4612
|
+
for (const [table, columns] of Object.entries(V170_ADDED_COLUMNS))
|
|
4613
|
+
for (const [column, { definition }] of Object.entries(columns))
|
|
4614
|
+
addColumn(db, table, column, definition);
|
|
4615
|
+
step("agent-said-column");
|
|
4600
4616
|
if (!fresh)
|
|
4601
4617
|
reclaimDatabase(db, "migration");
|
|
4602
4618
|
const expectedMarker = preflight < 0 ? preflight : -preflight;
|
|
@@ -5458,7 +5474,9 @@ function sizingOfRow(row) {
|
|
|
5458
5474
|
const source = row["size_source"];
|
|
5459
5475
|
if (source !== "classifier" && source !== "heuristic" && source !== "person")
|
|
5460
5476
|
return null;
|
|
5461
|
-
|
|
5477
|
+
const by = row["size_by"];
|
|
5478
|
+
return { size: row["size"], risky: Number(row["size_risky"] ?? 0) === 1, source, reason: row["size_reason"] == null ? "" : String(row["size_reason"]),
|
|
5479
|
+
...(source === "classifier" && typeof by === "string" && /^[A-Za-z0-9][A-Za-z0-9 .:/~()_-]{0,79}$/.test(by) ? { by } : {}) };
|
|
5462
5480
|
}
|
|
5463
5481
|
function addColumn(db, table, column, definition) {
|
|
5464
5482
|
if (hasColumn(db, table, column))
|
|
@@ -6140,8 +6158,11 @@ export class Store {
|
|
|
6140
6158
|
link: chatControlHref("recovery", taskId),
|
|
6141
6159
|
}, now);
|
|
6142
6160
|
}
|
|
6143
|
-
unhold(taskRef, mutation = {}, now) {
|
|
6161
|
+
unhold(taskRef, mutation = {}, now, seenHold) {
|
|
6144
6162
|
return this.once(mutation, "unhold", () => this.transact(() => {
|
|
6163
|
+
if (seenHold !== undefined && this.db.prepare("SELECT 1 AS hit FROM hold WHERE id = ? AND task_ref = ? AND owner_kind = 'operator'")
|
|
6164
|
+
.get(seenHold, taskRef) === undefined)
|
|
6165
|
+
return false;
|
|
6145
6166
|
const { changes } = this.db
|
|
6146
6167
|
.prepare("DELETE FROM hold WHERE task_ref = ? AND (owner_kind = 'operator' OR (owner_kind = 'backoff' AND owner_id = 'storage:' || task_ref))")
|
|
6147
6168
|
.run(taskRef);
|
|
@@ -9582,7 +9603,7 @@ export class Store {
|
|
|
9582
9603
|
return "published";
|
|
9583
9604
|
return null;
|
|
9584
9605
|
}
|
|
9585
|
-
requeueTask(taskId, by, now, expect) {
|
|
9606
|
+
requeueTask(taskId, by, now, expect, pins) {
|
|
9586
9607
|
return this.transact(() => {
|
|
9587
9608
|
const eligible = requeueEligibility(this, taskId, now);
|
|
9588
9609
|
if (!eligible.ok)
|
|
@@ -9594,6 +9615,13 @@ export class Store {
|
|
|
9594
9615
|
scope["approved_digest"] !== scope["digest"])
|
|
9595
9616
|
return { ok: false, reason: "moved" };
|
|
9596
9617
|
}
|
|
9618
|
+
if (pins !== undefined) {
|
|
9619
|
+
const latest = this.lastBuilderRun(taskRef);
|
|
9620
|
+
const scope = this.db.prepare("SELECT digest FROM task_scope WHERE task_id = ?").get(taskId);
|
|
9621
|
+
if (latest === null || latest.id !== pins.run || scope === undefined || String(scope["digest"]) !== pins.digest ||
|
|
9622
|
+
this.db.prepare("SELECT 1 AS hit FROM run WHERE task_ref = ? AND id > ? LIMIT 1").get(taskRef, pins.run) !== undefined)
|
|
9623
|
+
return { ok: false, reason: "stale" };
|
|
9624
|
+
}
|
|
9597
9625
|
for (const incident of incidents)
|
|
9598
9626
|
this.resolveIncidentLocked(incident, by, now);
|
|
9599
9627
|
this.resetStrikes(taskRef);
|
|
@@ -9614,13 +9642,20 @@ export class Store {
|
|
|
9614
9642
|
return { ok: true, resolvedIncidents: incidents.length, rejectedRun };
|
|
9615
9643
|
});
|
|
9616
9644
|
}
|
|
9617
|
-
cancelTask(taskId, now, reason) {
|
|
9645
|
+
cancelTask(taskId, now, reason, seen) {
|
|
9618
9646
|
return this.transact(() => {
|
|
9619
9647
|
const ref = this.db
|
|
9620
9648
|
.prepare("SELECT id FROM task_ref WHERE backend = ? AND external_id = ?")
|
|
9621
9649
|
.get(BUILT_IN, taskId);
|
|
9622
9650
|
if (ref === undefined)
|
|
9623
9651
|
return { ok: false, reason: "unknown-task" };
|
|
9652
|
+
if (seen !== undefined) {
|
|
9653
|
+
const state = this.db.prepare("SELECT state FROM task WHERE id = ?").get(taskId)?.["state"];
|
|
9654
|
+
const last = this.db.prepare("SELECT MAX(id) AS id FROM run WHERE task_ref = ?").get(Number(ref["id"]))?.["id"];
|
|
9655
|
+
const run = last === null || last === undefined ? null : Number(last);
|
|
9656
|
+
if (String(state) !== seen.state || run !== seen.run)
|
|
9657
|
+
return { ok: false, reason: "changed" };
|
|
9658
|
+
}
|
|
9624
9659
|
if (this.hasLiveClaim(Number(ref["id"]), now))
|
|
9625
9660
|
return { ok: false, reason: "claimed" };
|
|
9626
9661
|
const done = this.applyCancellation(taskId, { kind: "operator", text: reason ?? null }, now, ["queued", "failed", "running"]);
|
|
@@ -10127,8 +10162,8 @@ export class Store {
|
|
|
10127
10162
|
}
|
|
10128
10163
|
writeSizing(taskRef, sizing) {
|
|
10129
10164
|
this.db
|
|
10130
|
-
.prepare("UPDATE task_ref SET size = ?, size_risky = ?, size_source = ?, size_reason = ? WHERE id = ?")
|
|
10131
|
-
.run(sizing.size, sizing.risky ? 1 : 0, sizing.source, sizing.reason.slice(0, 300), taskRef);
|
|
10165
|
+
.prepare("UPDATE task_ref SET size = ?, size_risky = ?, size_source = ?, size_reason = ?, size_by = ? WHERE id = ?")
|
|
10166
|
+
.run(sizing.size, sizing.risky ? 1 : 0, sizing.source, sizing.reason.slice(0, 300), sizing.by ?? null, taskRef);
|
|
10132
10167
|
}
|
|
10133
10168
|
planToSizing(taskRef, now) {
|
|
10134
10169
|
const ref = this.refForId(taskRef);
|
|
@@ -10159,7 +10194,7 @@ export class Store {
|
|
|
10159
10194
|
if (scope !== null && scope.approvedAt !== null && scope.approvedDigest === scope.digest)
|
|
10160
10195
|
return { ok: false, reason: "approved" };
|
|
10161
10196
|
const before = ref.sizing ?? null;
|
|
10162
|
-
if (before !== null && before.size === sizing.size && before.risky === sizing.risky && before.source === sizing.source && before.reason === sizing.reason) {
|
|
10197
|
+
if (before !== null && before.size === sizing.size && before.risky === sizing.risky && before.source === sizing.source && before.reason === sizing.reason && before.by === sizing.by) {
|
|
10163
10198
|
return { ok: true, changed: false, planning: null };
|
|
10164
10199
|
}
|
|
10165
10200
|
this.writeSizing(ref.id, sizing);
|
|
@@ -18889,3 +18924,40 @@ function flexibleShipShapeProblem(db) {
|
|
|
18889
18924
|
}
|
|
18890
18925
|
return null;
|
|
18891
18926
|
}
|
|
18927
|
+
function taskSizingShapeProblem(db) {
|
|
18928
|
+
const row = db.prepare("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'task_sizing_setting'").get();
|
|
18929
|
+
if (row === undefined)
|
|
18930
|
+
return "the task sizing table is missing";
|
|
18931
|
+
if (canonicalDdl(String(row["sql"]).replace(/;$/, "")).trim() !== canonicalDdl(V169_SCHEMA.trim().replace(/;$/, "")).trim())
|
|
18932
|
+
return "the task sizing table has an unknown shape";
|
|
18933
|
+
if (!hasColumn(db, "task_ref", "size_by"))
|
|
18934
|
+
return "task_ref.size_by is missing";
|
|
18935
|
+
return null;
|
|
18936
|
+
}
|
|
18937
|
+
function agentSaidShapeProblem(db) {
|
|
18938
|
+
return hasColumn(db, "run", "agent_said_json") ? null : "run.agent_said_json is missing";
|
|
18939
|
+
}
|
|
18940
|
+
export function recordAgentSaid(store, runId, lines) {
|
|
18941
|
+
const kept = agentSaidTail(lines.join("\n"));
|
|
18942
|
+
while (kept.length > 0 && JSON.stringify(kept).length > 4096)
|
|
18943
|
+
kept.shift();
|
|
18944
|
+
if (kept.length === 0)
|
|
18945
|
+
return;
|
|
18946
|
+
store.handle.prepare("UPDATE run SET agent_said_json = ? WHERE id = ? AND agent_said_json IS NULL").run(JSON.stringify(kept), runId);
|
|
18947
|
+
}
|
|
18948
|
+
export function agentSaidOf(store, runId) {
|
|
18949
|
+
const row = store.handle.prepare("SELECT agent_said_json FROM run WHERE id = ?").get(runId);
|
|
18950
|
+
const raw = row?.["agent_said_json"];
|
|
18951
|
+
if (typeof raw !== "string")
|
|
18952
|
+
return null;
|
|
18953
|
+
try {
|
|
18954
|
+
const value = JSON.parse(raw);
|
|
18955
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
18956
|
+
return null;
|
|
18957
|
+
const lines = agentSaidTail(value.filter((one) => typeof one === "string").join("\n"));
|
|
18958
|
+
return lines.length === 0 ? null : lines;
|
|
18959
|
+
}
|
|
18960
|
+
catch {
|
|
18961
|
+
return null;
|
|
18962
|
+
}
|
|
18963
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const V169_SCHEMA = `
|
|
2
|
+
CREATE TABLE IF NOT EXISTS task_sizing_setting (
|
|
3
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
4
|
+
enabled INTEGER NOT NULL CHECK (enabled IN (0,1)),
|
|
5
|
+
sizer TEXT CHECK (sizer IN ('claude','jev')),
|
|
6
|
+
updated_by TEXT NOT NULL,
|
|
7
|
+
updated_at TEXT NOT NULL
|
|
8
|
+
);
|
|
9
|
+
`;
|
|
10
|
+
export const V169_ADDED_COLUMNS = Object.freeze({
|
|
11
|
+
task_ref: { size_by: { definition: "TEXT", saved: "NULL" } },
|
|
12
|
+
});
|
|
13
|
+
export const V169_TABLES = Object.freeze(["task_sizing_setting"]);
|
|
14
|
+
export const V169_STEPS = Object.freeze(["task-sizing-setting", "task-sizing-columns"]);
|
package/dist/task-sizing.js
CHANGED
|
@@ -9,10 +9,13 @@ import { run, terminateOwnedProcesses } from "./exec.js";
|
|
|
9
9
|
import { CLAUDE_NO_TOOLS_ARGS, claudeJsonBody } from "./claude-print.js";
|
|
10
10
|
import { JEV_MODEL, JEV_URL } from "./flow-sort.js";
|
|
11
11
|
import { readProviderKey } from "./keys.js";
|
|
12
|
-
import {} from "./phase-routing.js";
|
|
12
|
+
import { PLANNED_FIRST_REASON, SIZING_OFF_REASON } from "./phase-routing.js";
|
|
13
|
+
import { envValue } from "./names.js";
|
|
13
14
|
import { ALL_CREDENTIAL_ENV } from "./provider.js";
|
|
14
15
|
export const SIZING_BUDGET_MS = 5_000;
|
|
15
16
|
export const SIZING_CLAUDE_MODEL = "claude-haiku-5-5";
|
|
17
|
+
export const CLAUDE_SIZER_NAME = "Claude Haiku 5.5";
|
|
18
|
+
export const JEV_SIZER_NAME = "Jev (OpenRouter)";
|
|
16
19
|
export const SUBSTANTIAL_WORK = /\b(?:architecture|end[- ]to[- ]end|migrat(?:e|ion)|moderni[sz]e|redesign|refactor|rework|workflow|navigation|accessibility|responsive|performance|security|unif(?:y|ied)|multi[- ](?:step|project|service))\b/i;
|
|
17
20
|
export function planningSignals(input) {
|
|
18
21
|
const goal = input.goal ?? "";
|
|
@@ -74,7 +77,8 @@ export function claudeSizer(runner = run, model = SIZING_CLAUDE_MODEL, budgetMs
|
|
|
74
77
|
const body = claudeJsonBody(result.stdout, 256 * 1024);
|
|
75
78
|
if (body === null || body["is_error"] === true || body["subtype"] !== "success")
|
|
76
79
|
return null;
|
|
77
|
-
|
|
80
|
+
const answer = answerOf(body["structured_output"]);
|
|
81
|
+
return answer === null ? null : { ...answer, by: model === SIZING_CLAUDE_MODEL ? CLAUDE_SIZER_NAME : `Claude ${model}` };
|
|
78
82
|
}
|
|
79
83
|
finally {
|
|
80
84
|
signal.removeEventListener("abort", stop);
|
|
@@ -108,16 +112,24 @@ export function jevSizer(fetcher, key) {
|
|
|
108
112
|
if (typeof risky !== "number" || !Number.isFinite(risky))
|
|
109
113
|
return null;
|
|
110
114
|
const sure = answers["size"]?.["confidence"];
|
|
111
|
-
|
|
115
|
+
const answer = answerOf({ size, risky: risky >= 0.5, reason: typeof sure === "number" && Number.isFinite(sure) ? `Jev is ${Math.round(Math.min(1, Math.max(0, sure)) * 100)}% sure` : "" });
|
|
116
|
+
return answer === null ? null : { ...answer, by: JEV_SIZER_NAME };
|
|
112
117
|
};
|
|
113
118
|
}
|
|
114
|
-
export function ownerSizer(fetcher = fetch, keyOf = () => readProviderKey("openrouter")) {
|
|
115
|
-
|
|
116
|
-
return (input, signal) => {
|
|
119
|
+
export function ownerSizer(fetcher = fetch, keyOf = () => readProviderKey("openrouter"), claude = claudeSizer()) {
|
|
120
|
+
return (input, signal, only) => {
|
|
117
121
|
const key = keyOf();
|
|
122
|
+
if (only === "claude")
|
|
123
|
+
return claude(input, signal);
|
|
124
|
+
if (only === "jev")
|
|
125
|
+
return key === null ? Promise.resolve(null) : jevSizer(fetcher, key)(input, signal);
|
|
118
126
|
return key === null ? claude(input, signal) : jevSizer(fetcher, key)(input, signal);
|
|
119
127
|
};
|
|
120
128
|
}
|
|
129
|
+
export function availableSizer(keyOf = () => readProviderKey("openrouter")) {
|
|
130
|
+
return keyOf() === null ? "claude" : "jev";
|
|
131
|
+
}
|
|
132
|
+
export const SIZER_WORDS = { claude: "Claude Haiku, on your plan", jev: "Jev via OpenRouter, your credit" };
|
|
121
133
|
export async function classifyTask(input, sizer, budgetMs = SIZING_BUDGET_MS) {
|
|
122
134
|
if (sizer === null)
|
|
123
135
|
return heuristicSizing(input);
|
|
@@ -130,7 +142,7 @@ export async function classifyTask(input, sizer, budgetMs = SIZING_BUDGET_MS) {
|
|
|
130
142
|
return heuristicSizing(input, `no classifier answer within ${Math.round(budgetMs / 1000)}s`);
|
|
131
143
|
if (answer === null)
|
|
132
144
|
return heuristicSizing(input, "the classifier could not answer");
|
|
133
|
-
return { size: answer.size, risky: answer.risky, source: "classifier", reason: answer.reason };
|
|
145
|
+
return { size: answer.size, risky: answer.risky, source: "classifier", reason: answer.reason, ...(typeof answer.by === "string" ? { by: answer.by } : {}) };
|
|
134
146
|
}
|
|
135
147
|
finally {
|
|
136
148
|
clearTimeout(timer);
|
|
@@ -146,11 +158,18 @@ export function installFilingSizer(sizer, budgetMs = SIZING_BUDGET_MS) {
|
|
|
146
158
|
return () => { installed = previous; budget = previousBudget; };
|
|
147
159
|
}
|
|
148
160
|
let budget = SIZING_BUDGET_MS;
|
|
149
|
-
export const filingSizer = () =>
|
|
150
|
-
|
|
161
|
+
export const filingSizer = (store, keyOf) => {
|
|
162
|
+
const read = taskSizingSetting(store, keyOf);
|
|
151
163
|
const sizer = installed;
|
|
152
|
-
|
|
164
|
+
return { sizer: read.on && sizer !== null && read.sizer !== null ? ((input, signal) => sizer(input, signal, read.sizer)) : null, budget, off: !read.on };
|
|
165
|
+
};
|
|
166
|
+
export function refineFiledSizing(store, taskId, input, followPlanning, clock = () => new Date()) {
|
|
167
|
+
const read = taskSizingSetting(store);
|
|
168
|
+
const installedSizer = installed;
|
|
169
|
+
if (installedSizer === null || !read.on || read.sizer === null)
|
|
153
170
|
return null;
|
|
171
|
+
const consented = read.sizer;
|
|
172
|
+
const sizer = (asked, signal) => installedSizer(asked, signal, consented);
|
|
154
173
|
const work = classifyTask(input, sizer, budget)
|
|
155
174
|
.then(sizing => { if (sizing.source === "classifier")
|
|
156
175
|
store.applySizing(taskId, sizing, { followPlanning }, clock()); })
|
|
@@ -163,3 +182,50 @@ export async function settleSizings() {
|
|
|
163
182
|
while (pending.size > 0)
|
|
164
183
|
await Promise.allSettled([...pending]);
|
|
165
184
|
}
|
|
185
|
+
export { SIZING_OFF_REASON } from "./phase-routing.js";
|
|
186
|
+
export function taskSizingSetting(store, keyOf) {
|
|
187
|
+
const byEnv = envValue(process.env, "NO_TASK_CLASSIFIER") !== undefined;
|
|
188
|
+
const available = availableSizer(keyOf);
|
|
189
|
+
let row;
|
|
190
|
+
try {
|
|
191
|
+
row = store.handle.prepare("SELECT enabled, sizer, updated_by, updated_at FROM task_sizing_setting WHERE id = 1").get();
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
row = undefined;
|
|
195
|
+
}
|
|
196
|
+
if (row === undefined)
|
|
197
|
+
return { on: false, chosen: false, sizer: null, available, by: null, at: null, byEnv };
|
|
198
|
+
const chosen = Number(row["enabled"]) === 1;
|
|
199
|
+
const sizer = row["sizer"] === "claude" || row["sizer"] === "jev" ? row["sizer"] : null;
|
|
200
|
+
return { on: chosen && sizer !== null && sizer === available, chosen, sizer: chosen ? sizer : null, available, by: String(row["updated_by"]), at: String(row["updated_at"]), byEnv };
|
|
201
|
+
}
|
|
202
|
+
export const taskSizingOn = (store) => taskSizingSetting(store).on;
|
|
203
|
+
export function setTaskSizing(store, on, by, now) {
|
|
204
|
+
store.handle.prepare(`INSERT INTO task_sizing_setting (id, enabled, sizer, updated_by, updated_at) VALUES (1, ?, ?, ?, ?)
|
|
205
|
+
ON CONFLICT(id) DO UPDATE SET enabled = excluded.enabled, sizer = excluded.sizer, updated_by = excluded.updated_by, updated_at = excluded.updated_at`)
|
|
206
|
+
.run(on === false ? 0 : 1, on === false ? null : on, by, now.toISOString());
|
|
207
|
+
store.recordAction({ at: now.toISOString(), actor: by, repo: null, taskId: null, runId: null, action: "task sizing by a quick model call", outcome: on === false ? "off" : `on: ${on}`, source: "policy", detail: null });
|
|
208
|
+
}
|
|
209
|
+
export const RISKY_WORDS = /\b(?:auth\w*|payments?|billing|delet\w*|migrat\w*|secur\w*|deploy\w*)\b/i;
|
|
210
|
+
const TINY_WORDING = /\b(?:typos?|misspell\w*|spelling|renam\w*)\b/i;
|
|
211
|
+
const NAMED_FILE = /(?:^|[\s`'"(])((?:[\w.-]+\/)*[\w-]{2,}\.[A-Za-z][A-Za-z0-9]{0,7})(?=$|[\s`'"),:;!?]|\.(?:\s|$))/g;
|
|
212
|
+
export const TINY_TEXT_MAX = 140;
|
|
213
|
+
export function tinyTask(input) {
|
|
214
|
+
const goal = input.goal ?? "";
|
|
215
|
+
const text = goal.trim() === "" || goal.trim() === input.title.trim() ? input.title : `${input.title}\n${goal}`;
|
|
216
|
+
if (text.length > TINY_TEXT_MAX || (input.outOfScope ?? "").trim() !== "" || (input.touches?.length ?? 0) > 1)
|
|
217
|
+
return false;
|
|
218
|
+
if (RISKY_WORDS.test(text) || planningSignals(input))
|
|
219
|
+
return false;
|
|
220
|
+
const files = new Set([...text.matchAll(NAMED_FILE)].map(one => one[1]));
|
|
221
|
+
const named = (input.touches?.length ?? 0) === 1 ? files.size <= 1 : files.size === 1;
|
|
222
|
+
return named || (files.size === 0 && TINY_WORDING.test(text));
|
|
223
|
+
}
|
|
224
|
+
export function cautiousSizing(input) {
|
|
225
|
+
return tinyTask(input)
|
|
226
|
+
? { size: "small", risky: false, source: "heuristic", reason: `${SIZING_OFF_REASON}; a tiny change` }
|
|
227
|
+
: { size: "medium", risky: false, source: "heuristic", reason: PLANNED_FIRST_REASON };
|
|
228
|
+
}
|
|
229
|
+
export function filingSizing(store, input) {
|
|
230
|
+
return taskSizingOn(store) ? heuristicSizing(input) : cautiousSizing(input);
|
|
231
|
+
}
|
package/dist/toolroll-update.js
CHANGED
|
@@ -20,6 +20,8 @@ import { orphanKey, updateSafeSchema, V117_RENAMED_COLUMNS, V117_RENAMED_TABLES,
|
|
|
20
20
|
import { V152_ADDED_COLUMNS } from "./code-map-store.js";
|
|
21
21
|
import { V153_ADDED_COLUMNS } from "./plain-schema.js";
|
|
22
22
|
import { V158_ADDED_COLUMNS } from "./lead-latency-schema.js";
|
|
23
|
+
import { V169_ADDED_COLUMNS } from "./task-sizing-schema.js";
|
|
24
|
+
import { V170_ADDED_COLUMNS } from "./agent-said-schema.js";
|
|
23
25
|
import { V159_ADDED_COLUMNS } from "./one-step-chat-schema.js";
|
|
24
26
|
import { isNewer, REGISTRY } from "./releases.js";
|
|
25
27
|
import { markNeverIndex } from "./never-index.js";
|
|
@@ -324,7 +326,7 @@ const HISTORY_RULES = {
|
|
|
324
326
|
...Object.fromEntries(Object.entries(V117_RENAMED_TABLES).map(([old, now]) => [old, { moved: { into: now, where: "1" } }])),
|
|
325
327
|
...Object.fromEntries(V117_RENAMED_COLUMNS.filter(([table]) => !Object.values(V117_RENAMED_TABLES).includes(table)).map(([table, from, to]) => [table, { renamed: { [from]: to } }])),
|
|
326
328
|
...Object.fromEntries(Object.entries(V118_MERGED_TABLES).map(([table, kind]) => [table, { moved: { into: "credential", where: `kind = '${kind}'` } }])),
|
|
327
|
-
...Object.fromEntries(Object.entries(addedColumns(V119_ADDED_COLUMNS, V120_ADDED_COLUMNS, V121_ADDED_COLUMNS, V122_ADDED_COLUMNS, V123_ADDED_COLUMNS, V125_ADDED_COLUMNS, V126_ADDED_COLUMNS, V128_ADDED_COLUMNS, V129_ADDED_COLUMNS, V134_ADDED_COLUMNS, V135_ADDED_COLUMNS, V138_ADDED_COLUMNS, V143_ADDED_COLUMNS, V147_ADDED_COLUMNS, V148_ADDED_COLUMNS, V150_ADDED_COLUMNS, V151_ADDED_COLUMNS, V152_ADDED_COLUMNS, V153_ADDED_COLUMNS, V158_ADDED_COLUMNS, V159_ADDED_COLUMNS))
|
|
329
|
+
...Object.fromEntries(Object.entries(addedColumns(V119_ADDED_COLUMNS, V120_ADDED_COLUMNS, V121_ADDED_COLUMNS, V122_ADDED_COLUMNS, V123_ADDED_COLUMNS, V125_ADDED_COLUMNS, V126_ADDED_COLUMNS, V128_ADDED_COLUMNS, V129_ADDED_COLUMNS, V134_ADDED_COLUMNS, V135_ADDED_COLUMNS, V138_ADDED_COLUMNS, V143_ADDED_COLUMNS, V147_ADDED_COLUMNS, V148_ADDED_COLUMNS, V150_ADDED_COLUMNS, V151_ADDED_COLUMNS, V152_ADDED_COLUMNS, V153_ADDED_COLUMNS, V158_ADDED_COLUMNS, V159_ADDED_COLUMNS, V169_ADDED_COLUMNS, V170_ADDED_COLUMNS))
|
|
328
330
|
.map(([table, rule]) => [table, { ...EARLIER_RULES[table], ...rule }])),
|
|
329
331
|
};
|
|
330
332
|
export const RETIRED_TABLES = Object.freeze(Object.keys(HISTORY_RULES).filter(name => HISTORY_RULES[name].retired));
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { chooseTuiBinary, identityOf } from "./tui-launch.js";
|
|
3
|
+
import { engineContractDigest } from "./contracts/engine-api.js";
|
|
4
|
+
const VIEW_TIMEOUT_MS = 5_000;
|
|
5
|
+
const VIEW_MAX_OUTPUT = 256 * 1024;
|
|
6
|
+
const same = (a, b) => a !== null && a.dev === b.dev && a.ino === b.ino && a.size === b.size && a.mtimeNs === b.mtimeNs;
|
|
7
|
+
function viewEnv(env) {
|
|
8
|
+
const out = { PATH: "/usr/bin:/bin" };
|
|
9
|
+
for (const key of ["HOME", "XDG_CONFIG_HOME", "XDG_STATE_HOME"])
|
|
10
|
+
if (env[key] !== undefined)
|
|
11
|
+
out[key] = env[key];
|
|
12
|
+
return out;
|
|
13
|
+
}
|
|
14
|
+
export function viewAnswerOf(stdout) {
|
|
15
|
+
let parsed;
|
|
16
|
+
try {
|
|
17
|
+
parsed = JSON.parse(stdout.trim().split("\n").pop() ?? "");
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return { ok: false, why: "the workbench answered something unreadable", unsure: true };
|
|
21
|
+
}
|
|
22
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
23
|
+
return { ok: false, why: "the workbench answered something unreadable", unsure: true };
|
|
24
|
+
const body = parsed;
|
|
25
|
+
if (body["ok"] === false)
|
|
26
|
+
return { ok: false, why: typeof body["why"] === "string" ? body["why"].slice(0, 400) : "the workbench refused it" };
|
|
27
|
+
return { ok: true, body };
|
|
28
|
+
}
|
|
29
|
+
export function binaryViewRunner(env = process.env) {
|
|
30
|
+
return (verb, input) => {
|
|
31
|
+
const choice = chooseTuiBinary({ env, screenReader: false, platform: process.platform, arch: process.arch, contract: engineContractDigest() });
|
|
32
|
+
if (!choice.ok)
|
|
33
|
+
return { ok: false, why: `the terminal workbench isn't available here (${choice.why})` };
|
|
34
|
+
if (!same(identityOf(choice.binary), choice.identity))
|
|
35
|
+
return { ok: false, why: "the terminal workbench changed while it was being checked" };
|
|
36
|
+
try {
|
|
37
|
+
const stdout = execFileSync(choice.binary, ["view", verb], {
|
|
38
|
+
input: input ?? "", encoding: "utf8", timeout: VIEW_TIMEOUT_MS, maxBuffer: VIEW_MAX_OUTPUT, env: viewEnv(env), stdio: ["pipe", "pipe", "ignore"],
|
|
39
|
+
});
|
|
40
|
+
return viewAnswerOf(stdout);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
const out = error.stdout;
|
|
44
|
+
if (typeof out === "string" && out.trim() !== "")
|
|
45
|
+
return viewAnswerOf(out);
|
|
46
|
+
return { ok: false, why: "the terminal workbench didn't answer", unsure: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export const THEME_NAME = /^[a-z][a-z0-9-]{0,31}$/;
|
|
51
|
+
export const BUILT_IN_THEMES = ["terminal", "light", "dark", "high-contrast"];
|
|
52
|
+
export const VIEW_CHANGES_PER_MINUTE = 10;
|
|
53
|
+
export const VIEW_LEDGER_ACTION = "workbench look changed";
|
|
54
|
+
export async function runViewCommand(argv, write, runner = binaryViewRunner()) {
|
|
55
|
+
const [verb, ...rest] = argv;
|
|
56
|
+
const say = (answer, words) => {
|
|
57
|
+
if (!answer.ok) {
|
|
58
|
+
write(`toolroll view: ${answer.why}`);
|
|
59
|
+
return 1;
|
|
60
|
+
}
|
|
61
|
+
write(words(answer.body));
|
|
62
|
+
return 0;
|
|
63
|
+
};
|
|
64
|
+
if (verb === undefined || verb === "show") {
|
|
65
|
+
return say(runner("read"), body => {
|
|
66
|
+
const settings = (body["settings"] ?? {});
|
|
67
|
+
const saved = (body["themes"]?.["saved"] ?? []);
|
|
68
|
+
return [`theme: ${String(settings["theme"] ?? "terminal")}`, `density: ${String(settings["density"] ?? "compact")}`,
|
|
69
|
+
`saved themes: ${saved.length === 0 ? "none" : saved.map(one => String(one.name)).join(", ")}`].join("\n");
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (verb === "theme" && rest[0] === "set" && rest.length === 2) {
|
|
73
|
+
const name = rest[1];
|
|
74
|
+
if (!BUILT_IN_THEMES.includes(name) && !THEME_NAME.test(name)) {
|
|
75
|
+
write("toolroll view: a theme is terminal, light, dark, high-contrast or a saved theme's name (lowercase letters, digits and dashes)");
|
|
76
|
+
return 2;
|
|
77
|
+
}
|
|
78
|
+
return say(runner("set", JSON.stringify({ theme: name })), body => {
|
|
79
|
+
const changed = Array.isArray(body["changed"]) ? body["changed"].map(String) : [];
|
|
80
|
+
return changed.length === 0 ? `Theme: ${name}.` : changed.join("\n");
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (verb === "reset" && rest.length === 0)
|
|
84
|
+
return say(runner("reset"), body => String(body["said"] ?? "Your workbench settings are back to the defaults."));
|
|
85
|
+
write("usage: toolroll view [show] | toolroll view theme set <name> | toolroll view reset");
|
|
86
|
+
return 2;
|
|
87
|
+
}
|
|
88
|
+
export function viewAllowedFor(facts) {
|
|
89
|
+
if (facts.via !== "cookie" || !facts.fromThisComputer)
|
|
90
|
+
return false;
|
|
91
|
+
if (facts.authority === "local-owner")
|
|
92
|
+
return true;
|
|
93
|
+
return facts.approvers.length === 1 && facts.approvers[0] === facts.name;
|
|
94
|
+
}
|
package/dist/webhooks.js
CHANGED
|
@@ -163,8 +163,9 @@ export function linkFor(consoleUrl, notification) {
|
|
|
163
163
|
}
|
|
164
164
|
export async function postWebhook(target, notification, link, fetcher = fetch) {
|
|
165
165
|
const withheld = outboundPrivate([notification.subject, notification.body]);
|
|
166
|
-
const
|
|
167
|
-
const
|
|
166
|
+
const escape = (text) => escapeFor(target.kind, text);
|
|
167
|
+
const subject = escape(withheld ? safeWords({ project: notification.project }) : notification.subject);
|
|
168
|
+
const said = withheld ? [] : [escape(notification.body)];
|
|
168
169
|
const body = target.kind === "slack"
|
|
169
170
|
? {
|
|
170
171
|
text: [
|
|
@@ -222,3 +223,8 @@ export async function webhookPass(store, options) {
|
|
|
222
223
|
}
|
|
223
224
|
return report;
|
|
224
225
|
}
|
|
226
|
+
export function escapeFor(kind, text) {
|
|
227
|
+
if (kind === "slack")
|
|
228
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
229
|
+
return text.replace(/([\\`*_~|>#[\]()-])/g, "\\$1").replace(/@(everyone|here)\b/gi, "@\u200b$1");
|
|
230
|
+
}
|
package/dist/work-index.js
CHANGED
|
@@ -93,7 +93,7 @@ const PROJECTION = `WITH RECURSIVE admitted AS MATERIALIZED (
|
|
|
93
93
|
AND lease_generation=(SELECT MAX(lease_generation) FROM claim WHERE task_ref=a.ref_id)) live_lease,
|
|
94
94
|
(SELECT id FROM run WHERE task_ref=a.ref_id AND outcome IS NULL ORDER BY id DESC LIMIT 1) unfinished,
|
|
95
95
|
CASE WHEN a.state='done' THEN (SELECT id FROM run WHERE task_ref=a.ref_id AND finished_at IS NOT NULL AND role IN ('builder','scout') ORDER BY id DESC LIMIT 1) END result_id,
|
|
96
|
-
(SELECT h.id FROM hold h WHERE h.task_ref=a.ref_id AND (h.until IS NULL OR h.until>$now) ORDER BY h.held_at,h.id LIMIT 1) hold_id,
|
|
96
|
+
(SELECT h.id FROM hold h WHERE h.task_ref=a.ref_id AND (h.until IS NULL OR h.until>$now) ORDER BY h.owner_kind='backoff',h.held_at,h.id LIMIT 1) hold_id,
|
|
97
97
|
q.decision_id,${AGENT_ASK} agent_ask,EXISTS(SELECT 1 FROM task_archive ta WHERE ta.task_ref=a.ref_id) member_archived,(cu.task_ref IS NOT NULL OR a.ref_id IN (SELECT value FROM json_each($workspaceCustody)))
|
|
98
98
|
AND a.ref_id NOT IN (SELECT value FROM json_each($settledCustody)) custody_unresolved
|
|
99
99
|
FROM admitted a LEFT JOIN lineage l ON l.ref_id=a.ref_id
|
|
@@ -479,7 +479,7 @@ function readWorkIndexPage(store, now, access, options, taskId = null) {
|
|
|
479
479
|
'proof_verdict',(SELECT COALESCE(machine_verdict,verdict) FROM proof_verdict WHERE run=page_result_id),
|
|
480
480
|
'proof_failed_check',(SELECT verdict='refuted' AND reasons_json LIKE '%approved verification command exited%' FROM proof_verdict WHERE run=page_result_id),'code',code,'ask_group',ask_group,'needs',needs,'person_need',person_need,'lead_claim',lead_claim,'family_running',family_running,'rank',rank,'ask_rank',ask_rank,'list_order',${ORDER},'sort_at',sort_at,
|
|
481
481
|
'checked_actor',checked_actor,'checked_at',checked_at,'checked_digest',checked_digest,'checked_detail',checked_detail,'question_id',question_id,
|
|
482
|
-
'dependency_id',dependency_id,'dependency_state',dependency_state,'hold_until',hold_until,'attempt_run',(SELECT id FROM run WHERE task_ref IN (SELECT value FROM json_each(page.fam_refs)) AND (finished_at IS NOT NULL OR outcome IS NOT NULL) AND role NOT IN ('planner','reviewer') ORDER BY id DESC LIMIT 1),'custody_unresolved',custody_unresolved,'hold_kind',hold_kind,'hold_reason',substr(hold_reason,1,600),'hold_id',hold_id,'live_lease',live_lease IS NOT NULL,'approved',COALESCE(approved,0),
|
|
482
|
+
'dependency_id',dependency_id,'dependency_state',dependency_state,'hold_until',hold_until,'attempt_run',(SELECT id FROM run WHERE task_ref IN (SELECT value FROM json_each(page.fam_refs)) AND (finished_at IS NOT NULL OR outcome IS NOT NULL) AND role NOT IN ('planner','reviewer') ORDER BY id DESC LIMIT 1),'attempt_no',CASE WHEN code='retry-scheduled' THEN (SELECT count(*) FROM run WHERE task_ref IN (SELECT value FROM json_each(page.fam_refs)) AND (finished_at IS NOT NULL OR outcome IS NOT NULL) AND role NOT IN ('planner','reviewer')) END,'custody_unresolved',custody_unresolved,'hold_kind',hold_kind,'hold_reason',substr(hold_reason,1,600),'hold_id',hold_id,'live_lease',live_lease IS NOT NULL,'approved',COALESCE(approved,0),
|
|
483
483
|
'plan_changed',scope_digest IS NOT NULL AND digest IS NOT scope_digest,'head_ok',length(head_revision)=40 AND head_revision NOT GLOB '*[^a-f0-9]*','stop_run',stop_run,'unfinished',unfinished,'signed_out',signed_out,'no_agent',no_agent,'models_cleared',models_cleared,
|
|
484
484
|
'question_run',(SELECT run FROM decision WHERE id=page.question_id),'agent_ask',page.agent_ask,
|
|
485
485
|
'agent_ask_run',(SELECT run FROM agent_question WHERE id=page.agent_ask),'agent_ask_text',(SELECT substr(question,1,300) FROM agent_question WHERE id=page.agent_ask),'replaced_by',(SELECT successor FROM task_replacement WHERE task_ref=page.ref_id),
|
|
@@ -706,7 +706,7 @@ function itemOf(row, principal, probe, leadName, readiness, readable = false, no
|
|
|
706
706
|
if (code === 'waiting-incident')
|
|
707
707
|
detail = `The last attempts failed the same way (${failedAttemptSentence(s(row, 'attempt_reason')).replace(/[.\s]+$/, '').replace(/^./, first => first.toLowerCase())}). Retry, or change the plan.`;
|
|
708
708
|
const context = code === 'stopping' ? { build: n(row, 'stop_run') || null }
|
|
709
|
-
: code === 'retry-scheduled' ? { build: n(row, 'attempt_run') || null, retry: s(row, 'hold_until') === null ? null : retryWhenWords(s(row, 'hold_until'), now) }
|
|
709
|
+
: code === 'retry-scheduled' ? { build: n(row, 'attempt_run') || null, attempt: n(row, 'attempt_no') || null, retry: s(row, 'hold_until') === null ? null : retryWhenWords(s(row, 'hold_until'), now) }
|
|
710
710
|
: code === 'vanished-run' ? { build: n(row, 'unfinished') || null }
|
|
711
711
|
: code === 'earlier-active' ? { task: s(row, 'earlier_id') }
|
|
712
712
|
: code === 'waiting-dependency' ? { task: s(row, 'dependency_id') } : {};
|
|
@@ -788,7 +788,7 @@ function itemOf(row, principal, probe, leadName, readiness, readable = false, no
|
|
|
788
788
|
completedBy: code !== 'complete' || landed !== null ? null : n(row, 'completed_by_lead') === 1 ? 'the lead' : String(row['checked_actor']).replace(/^(?:operator|coordinator|lead):/, ''),
|
|
789
789
|
...(landed === null ? {} : { landed }),
|
|
790
790
|
...(lead === null ? {} : { lead, ...(leadName === undefined ? {} : { leadName }) }) });
|
|
791
|
-
label = shared.headline;
|
|
791
|
+
label = code === 'cancelled' && shared.headline === 'Stopped' && !shared.sentence.startsWith('Replaced by ') ? 'Cancelled' : shared.headline;
|
|
792
792
|
detail = shared.sentence;
|
|
793
793
|
const firstSignIn = code === 'signed-out' && n(row, 'no_agent') > 0 && s(row, 'signed_out') === null;
|
|
794
794
|
if (shared.need != null && shared.need.key !== 'other' && shared.need.key !== 'review-result' && primaryAction !== null && !firstSignIn) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolroll",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.112",
|
|
4
4
|
"description": "Your agents build. You decide. A control plane for coding agents — Claude Code, Codex, Gemini: approve the exact scope once, get results back Ready with the diff, the passing check and screenshots. Runs on your machine.",
|
|
5
5
|
"directories": {
|
|
6
6
|
"doc": "docs"
|
|
@@ -94,6 +94,7 @@
|
|
|
94
94
|
"class-variance-authority": "0.7.1",
|
|
95
95
|
"clsx": "2.1.1",
|
|
96
96
|
"esbuild": "0.28.2",
|
|
97
|
+
"fast-check": "4.10.2",
|
|
97
98
|
"happy-dom": "20.14.5",
|
|
98
99
|
"ink": "6.8.0",
|
|
99
100
|
"ink-testing-library": "4.0.0",
|