toolroll 0.9.108 → 0.9.109

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/advanced-view.js +0 -1
  3. package/dist/agent-fence.js +35 -4
  4. package/dist/agent-state.js +5 -2
  5. package/dist/assignment-ui.js +5 -5
  6. package/dist/assignment.js +5 -2
  7. package/dist/browser/terminal.js +1 -1
  8. package/dist/browser/workspace.css +1 -1
  9. package/dist/browser/workspace.js +37 -34
  10. package/dist/browser-crew.js +4 -4
  11. package/dist/browser-workspace.js +4 -11
  12. package/dist/builder.js +9 -1
  13. package/dist/chat-controls.js +6 -5
  14. package/dist/chat-decide.js +1 -1
  15. package/dist/chat-quiet.js +3 -3
  16. package/dist/chat-voice.js +2 -2
  17. package/dist/cli-help.js +12 -13
  18. package/dist/cli.js +4 -3
  19. package/dist/console-chrome.js +10 -3
  20. package/dist/contracts/console-api.js +4 -3
  21. package/dist/contracts/handoff.js +4 -0
  22. package/dist/decision.js +17 -0
  23. package/dist/demo-chat.js +1 -1
  24. package/dist/demo.js +6 -0
  25. package/dist/design/kit.js +4 -3
  26. package/dist/dispatch.js +3 -8
  27. package/dist/flexible-available.js +1 -0
  28. package/dist/flexible-schema.js +32 -0
  29. package/dist/flexible-thread-schema.js +30 -0
  30. package/dist/flexible-thread.js +526 -0
  31. package/dist/flexible-ui.js +44 -0
  32. package/dist/flexible.js +359 -0
  33. package/dist/git-views.js +38 -38
  34. package/dist/guides.js +11 -10
  35. package/dist/keymap.js +1 -1
  36. package/dist/lead-context.js +1 -1
  37. package/dist/limits-ui.js +1 -1
  38. package/dist/live-bus.js +70 -13
  39. package/dist/needs-you.js +3 -3
  40. package/dist/nightly-github.js +2 -2
  41. package/dist/operate.js +111 -3
  42. package/dist/project-delete-ui.js +2 -1
  43. package/dist/project-delete.js +1 -0
  44. package/dist/provider-auth.js +1 -1
  45. package/dist/release.js +1 -0
  46. package/dist/result-actions.js +3 -0
  47. package/dist/result-evidence-readers.js +8 -2
  48. package/dist/result-review.js +20 -9
  49. package/dist/serve.js +32 -29
  50. package/dist/server/chat.js +9 -9
  51. package/dist/server/chrome.js +16 -16
  52. package/dist/server/guards.js +10 -4
  53. package/dist/server/home.js +37 -5
  54. package/dist/server/http.js +4 -2
  55. package/dist/server/in-place.js +5 -4
  56. package/dist/server/kit.js +2 -2
  57. package/dist/server/live.js +100 -10
  58. package/dist/server/pages.js +79 -53
  59. package/dist/server/render-chat.js +1 -1
  60. package/dist/server/render-history.js +18 -4
  61. package/dist/server/render-new-task.js +2 -2
  62. package/dist/server/render-pages.js +21 -39
  63. package/dist/server/render-people.js +2 -2
  64. package/dist/server/render-projects.js +5 -5
  65. package/dist/server/render-results.js +26 -10
  66. package/dist/server/render-tasks.js +26 -17
  67. package/dist/server/retired-routes.js +37 -4
  68. package/dist/server/route-policy.js +8 -0
  69. package/dist/server/route-table.js +13 -4
  70. package/dist/server/settings-computers.js +140 -0
  71. package/dist/server/settings-scripts.js +15 -0
  72. package/dist/server/settings-section-table.js +56 -0
  73. package/dist/server/settings-sections.js +258 -0
  74. package/dist/server/settings.js +164 -19
  75. package/dist/server/task-views.js +47 -13
  76. package/dist/server/tasks.js +143 -90
  77. package/dist/server/welcome.js +6 -5
  78. package/dist/settings-groups-ui.js +24 -105
  79. package/dist/settings-proofs.js +5 -2
  80. package/dist/sqlite-telemetry.js +70 -21
  81. package/dist/store.js +108 -9
  82. package/dist/task-link.js +64 -0
  83. package/dist/tui.js +1 -1
  84. package/dist/typed-words-schema.js +18 -0
  85. package/dist/welcome-facts.js +3 -2
  86. package/dist/work-index.js +126 -29
  87. package/dist/work-reads.js +279 -0
  88. package/package.json +4 -2
package/dist/live-bus.js CHANGED
@@ -99,6 +99,9 @@ export function followWorkspace(store, current, bus, options = {}) {
99
99
  },
100
100
  };
101
101
  }
102
+ export function liveOrderAfter(previous) {
103
+ return Math.max(previous + 1, Date.now() * 1_000);
104
+ }
102
105
  export const SAFETY_NET_MS = 30_000;
103
106
  export const KEEP_ALIVE_MS = 15_000;
104
107
  export const STREAM_LIMIT_BYTES = 32 * 1024;
@@ -154,21 +157,30 @@ export class LiveConnection {
154
157
  closed = false;
155
158
  refusing = false;
156
159
  frames;
160
+ ends = new Set();
161
+ conn;
162
+ syncHolds = 0;
163
+ syncWanted = false;
164
+ syncSent = false;
157
165
  constructor(response, options = {}) {
158
166
  this.response = response;
159
167
  this.frames = options.frames === true;
168
+ this.conn = this.frames ? options.conn ?? null : null;
160
169
  this.stream = new LiveStream(response, options.limitBytes, () => this.close());
161
170
  this.timer = setInterval(() => this.keepAlive(), options.keepAliveMs ?? KEEP_ALIVE_MS);
162
171
  this.timer.unref();
163
172
  response.once("close", () => this.close());
164
173
  }
165
- keepAlive() {
174
+ prove() {
166
175
  for (const prove of [...this.proofs]) {
167
176
  if (!this.open)
168
- return;
177
+ return false;
169
178
  prove();
170
179
  }
171
- if (!this.open)
180
+ return this.open;
181
+ }
182
+ keepAlive() {
183
+ if (!this.prove())
172
184
  return;
173
185
  if (this.frames)
174
186
  this.stream.tick();
@@ -177,11 +189,46 @@ export class LiveConnection {
177
189
  }
178
190
  hello(data) {
179
191
  if (this.frames && this.open)
180
- this.stream.send("hello", data);
192
+ this.stream.send("hello", this.conn === null ? data : { ...data, conn: this.conn });
193
+ }
194
+ synced() {
195
+ if (!this.frames || this.syncWanted)
196
+ return;
197
+ this.syncWanted = true;
198
+ this.flushSynced();
199
+ }
200
+ holdSynced() {
201
+ if (!this.frames || this.syncSent)
202
+ return () => { };
203
+ this.syncHolds += 1;
204
+ let released = false;
205
+ return () => {
206
+ if (released)
207
+ return;
208
+ released = true;
209
+ this.syncHolds = Math.max(0, this.syncHolds - 1);
210
+ this.flushSynced();
211
+ };
212
+ }
213
+ flushSynced() {
214
+ if (!this.syncWanted || this.syncSent || this.syncHolds > 0)
215
+ return;
216
+ this.syncSent = true;
217
+ if (this.open)
218
+ this.stream.send("synced", {});
219
+ }
220
+ pong(n) {
221
+ if (!this.frames || !this.prove())
222
+ return false;
223
+ this.stream.send("pong", { n });
224
+ return this.open;
181
225
  }
226
+ onEnd(run) { this.ends.add(run); }
182
227
  onKeepAlive(prove) { this.proofs.add(prove); return () => { this.proofs.delete(prove); }; }
183
228
  get open() { return !this.closed && this.stream.open; }
184
- send(room, event, data = {}) { this.stream.send(event, { room, ...data }); }
229
+ send(room, event, data = {}, order) {
230
+ this.stream.send(event, this.frames ? { room, ...data, seq: order ?? liveOrderAfter(0) } : { room, ...data });
231
+ }
185
232
  refuse(leave) {
186
233
  const outer = this.refusing;
187
234
  this.refusing = true;
@@ -202,6 +249,13 @@ export class LiveConnection {
202
249
  leave();
203
250
  this.leaves.clear();
204
251
  this.proofs.clear();
252
+ for (const end of [...this.ends]) {
253
+ try {
254
+ end();
255
+ }
256
+ catch { }
257
+ }
258
+ this.ends.clear();
205
259
  if (this.refusing && this.stream.open) {
206
260
  this.response.end("event: ended\ndata: {}\n\n");
207
261
  return;
@@ -226,8 +280,9 @@ export function createLiveRooms(fingerprint, presence, options = {}) {
226
280
  clearTimeout(room.settling);
227
281
  room.settling = setTimeout(() => {
228
282
  room.settling = null;
283
+ const order = room.order = liveOrderAfter(room.order);
229
284
  for (const viewer of [...room.viewers.keys()])
230
- deliver(key, room, viewer, "here", { people: presence([...room.viewers.keys()], viewer.name) });
285
+ deliver(key, room, viewer, "here", { people: presence([...room.viewers.keys()], viewer.name) }, order);
231
286
  }, PRESENCE_SETTLE_MS);
232
287
  room.settling.unref();
233
288
  };
@@ -260,7 +315,7 @@ export function createLiveRooms(fingerprint, presence, options = {}) {
260
315
  unsubscribe = null;
261
316
  }
262
317
  };
263
- const deliver = (key, room, viewer, event, data = {}) => {
318
+ const deliver = (key, room, viewer, event, data = {}, order) => {
264
319
  if (rooms.get(key) !== room || !room.viewers.has(viewer))
265
320
  return false;
266
321
  if (!viewer.connection.open) {
@@ -285,7 +340,7 @@ export function createLiveRooms(fingerprint, presence, options = {}) {
285
340
  return false;
286
341
  }
287
342
  if (event !== undefined)
288
- viewer.connection.send(viewer.room, event, data);
343
+ viewer.connection.send(viewer.room, event, data, order);
289
344
  return viewer.connection.open && room.viewers.has(viewer);
290
345
  };
291
346
  const refresh = (key, room, revision) => {
@@ -313,6 +368,7 @@ export function createLiveRooms(fingerprint, presence, options = {}) {
313
368
  if (now === room.last)
314
369
  return;
315
370
  room.last = now;
371
+ room.lastOrder = room.order = liveOrderAfter(room.order);
316
372
  room.revision = revision ?? bus?.revision() ?? null;
317
373
  if (room.holding !== null)
318
374
  return;
@@ -328,7 +384,7 @@ export function createLiveRooms(fingerprint, presence, options = {}) {
328
384
  const say = (key, room) => {
329
385
  room.saidAt = Date.now();
330
386
  for (const viewer of [...room.viewers.keys()])
331
- deliver(key, room, viewer, "change", { at: room.last, revision: room.revision });
387
+ deliver(key, room, viewer, "change", { at: room.last, revision: room.revision }, room.lastOrder || undefined);
332
388
  };
333
389
  const heard = (change) => {
334
390
  for (const [key, room] of [...rooms]) {
@@ -349,12 +405,13 @@ export function createLiveRooms(fingerprint, presence, options = {}) {
349
405
  join(key, viewer) {
350
406
  let room = rooms.get(key);
351
407
  if (room === undefined) {
352
- let last = null;
408
+ let last = null, lastOrder = 0;
353
409
  try {
354
410
  last = fingerprint(key);
411
+ lastOrder = liveOrderAfter(0);
355
412
  }
356
413
  catch { }
357
- const created = { viewers: new Map(), last, timer: setInterval(() => refresh(key, created, null), safetyNetMs), settling: null, retry: null, saidAt: 0, holding: null, revision: null, reading: null };
414
+ const created = { viewers: new Map(), last, timer: setInterval(() => refresh(key, created, null), safetyNetMs), settling: null, retry: null, saidAt: 0, holding: null, revision: null, reading: null, lastOrder, order: lastOrder };
358
415
  created.timer.unref();
359
416
  room = created;
360
417
  rooms.set(key, room);
@@ -365,9 +422,9 @@ export function createLiveRooms(fingerprint, presence, options = {}) {
365
422
  const forget = viewer.connection.onClose(() => leave(key, viewer));
366
423
  const unprove = viewer.connection.onKeepAlive(() => { deliver(key, joined, viewer); });
367
424
  room.viewers.set(viewer, () => { forget(); unprove(); });
368
- if (!deliver(key, room, viewer, "change", { at: room.last, revision: bus?.revision() ?? null }) || presence === null)
425
+ if (!deliver(key, room, viewer, "change", { at: room.last, revision: bus?.revision() ?? null }, room.lastOrder || undefined) || presence === null)
369
426
  return;
370
- if (deliver(key, room, viewer, "here", { people: presence([...room.viewers.keys()], viewer.name) }))
427
+ if (deliver(key, room, viewer, "here", { people: presence([...room.viewers.keys()], viewer.name) }, room.order = liveOrderAfter(room.order)))
371
428
  announce(key, room);
372
429
  },
373
430
  close() {
package/dist/needs-you.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export const STORAGE_HOLD_PREFIX = "protected-storage — ";
2
- export const START_BUILDER_HREF = "/start-builder";
3
- export const startBuilderHref = (taskId) => taskId === null ? START_BUILDER_HREF : `${START_BUILDER_HREF}?task=${encodeURIComponent(taskId)}`;
2
+ export const START_BUILDER_HREF = "/settings/computers?section=start";
3
+ export const startBuilderHref = (taskId) => taskId === null ? START_BUILDER_HREF : `/settings/computers?task=${encodeURIComponent(taskId)}&section=start`;
4
4
  export const START_BUILDER_COMMAND = "toolroll up";
5
5
  const always = () => true;
6
6
  const build = (context) => context.build == null ? "the last build" : `build #${context.build}`;
@@ -14,7 +14,7 @@ export const NEEDS = {
14
14
  "stop-unproven": { sentence: context => `Toolroll can't prove ${build(context)} stopped from this computer, so the work is held. Close anything of yours that is using its folder, then check again.`, action: { code: "recheck-stopped", label: "Check again" } },
15
15
  hold: { sentence: () => "A hold is keeping this task from starting. Review it to release it.", action: { code: "inspect-hold", label: "Review hold" } },
16
16
  storage: { sentence: () => "Toolroll couldn't finish checking other apps' data before starting. Allow it in Privacy & Security, then try again.", action: { code: "unhold", label: "Try again" }, useReason: always },
17
- "choose-project": { sentence: () => "Choose a project so a builder can start.", action: { code: "place-task", label: "Choose a project" } },
17
+ "choose-project": { sentence: () => "Choose a project so it can start.", action: { code: "place-task", label: "Choose a project" } },
18
18
  "define-task": { sentence: () => "Say what the task should do so it can be planned.", action: { code: "write-scope", label: "Define the task" } },
19
19
  "fix-request": { sentence: () => "The request can't be planned as written. Edit it so the planner can start.", action: { code: "write-scope", label: "Edit the request" },
20
20
  useReason: reason => /the planner can carry at most/.test(reason) },
@@ -796,7 +796,7 @@ export function nightlyNeedsYou(store, shown) {
796
796
  for (const failure of openFailures(store, repo)) {
797
797
  needs.push({ key: `github-nightly-${failure.id}`, repo, title: `Nightly checks failed: ${laneName(store, repo, failure.laneId)}`,
798
798
  reason: `On main at ${failure.sha.slice(0, 7)}. Releases wait until it passes again.`,
799
- href: slug === null ? "/tasks?view=board" : `https://github.com/${slug}/actions/runs/${failure.ghRun}/job/${failure.jobId}`, since: failure.openedAt });
799
+ href: slug === null ? "/?view=board" : `https://github.com/${slug}/actions/runs/${failure.ghRun}/job/${failure.jobId}`, since: failure.openedAt });
800
800
  }
801
801
  }
802
802
  const rows = store.handle.prepare("SELECT repo, run, sha, MIN(opened_at) AS since, COUNT(*) AS n FROM main_check_failure WHERE cleared_at IS NULL GROUP BY repo, run, sha ORDER BY since").all();
@@ -809,7 +809,7 @@ export function nightlyNeedsYou(store, shown) {
809
809
  const items = store.handle.prepare("SELECT item FROM main_check_failure WHERE repo = ? AND run = ? AND cleared_at IS NULL ORDER BY item").all(repo, Number(row["run"])).map(one => String(one["item"]));
810
810
  needs.push({ key: `main-check-${Number(row["run"])}`, repo, title: `Nightly check of main failed: ${failureSummary(items)}`,
811
811
  reason: `On main at ${String(row["sha"]).slice(0, 7)}. Composed releases wait until a full check passes.`,
812
- href: task === null ? "/tasks?view=board" : `/t/${encodeURIComponent(task)}`, since: String(row["since"]) });
812
+ href: task === null ? "/?view=board" : `/t/${encodeURIComponent(task)}`, since: String(row["since"]) });
813
813
  }
814
814
  return needs.sort((a, b) => a.since.localeCompare(b.since));
815
815
  }
package/dist/operate.js CHANGED
@@ -166,7 +166,7 @@ function planContractLines(store, evidenceRoot, taskId) {
166
166
  }
167
167
  import { verdictWords as proofVerdictWords, matrixWords, plainReasonWords, semanticCoverage, coverageWords } from "./proof.js";
168
168
  import { probeRepo } from "./probe.js";
169
- import { agentlessFirstRun, diagnoseTaskDispatch, diagnosisIsDispatchable, NO_AGENT_TITLE, scopeApprovedForDispatch, } from "./dispatch.js";
169
+ import { agentlessFirstRun, buildersFor, diagnoseTaskDispatch, diagnosisIsDispatchable, NO_AGENT_TITLE, scopeApprovedForDispatch, } from "./dispatch.js";
170
170
  import { createDecisionServer, SIGN_IN_LINK_MS } from "./serve.js";
171
171
  import { readTailnetNames } from "./tailnet.js";
172
172
  import { daemonLaunchCommand, daemonStatus, installReplacingLegacy, installedLegacyDaemon, planDaemon, uninstallDaemon, awaitFreshHeartbeat, } from "./daemon.js";
@@ -263,6 +263,8 @@ import { latestRelease, newerRelease, notifySecurityRelease, notifyVersionLive,
263
263
  import { installMethod } from "./install-method.js";
264
264
  import { PACKAGE_VERSION } from "./version.js";
265
265
  import { machineActing } from "./scope.js";
266
+ import { FLEXIBLE_AVAILABLE } from "./flexible-available.js";
267
+ import { enableFlexible, FLEXIBLE_LAPSE_WORDS, FLEXIBLE_LEVEL_WORDS, FLEXIBLE_UNAVAILABLE, flexibleStanding, flexibleTermsWords, isFlexibleLevel, lowerFlexible, proposedFlexibleTerms, turnFlexibleOff } from "./flexible.js";
266
268
  import { reevaluateResultRecords } from "./route-results.js";
267
269
  import { holdRuleOff, routeRulesPass, taskEvidenceWords } from "./route-rules.js";
268
270
  import { ruleHoldOf } from "./route-store.js";
@@ -734,6 +736,7 @@ export const OPERATE_VALUE_FLAGS = new Set([
734
736
  "token-name",
735
737
  "request",
736
738
  "read-deny", "mach",
739
+ "default",
737
740
  "release",
738
741
  "despite",
739
742
  ]);
@@ -1160,6 +1163,8 @@ async function dispatch(command, positional, flags, context) {
1160
1163
  return projectCheckAccessCommand(positional, flags, context);
1161
1164
  if (positional[0] === "sandbox")
1162
1165
  return projectSandboxCommand(positional, flags, context);
1166
+ if (positional[0] === "flexible")
1167
+ return projectFlexibleCommand(positional, flags, context);
1163
1168
  if (positional[0] === "checks")
1164
1169
  return projectChecksCommand(positional, flags, context);
1165
1170
  if (positional[0] === "demo")
@@ -7671,13 +7676,32 @@ async function addTask(positional, flags, context) {
7671
7676
  return fail(write, json, "task add", "checks-fixed", chosen.message, EXIT.refused);
7672
7677
  }
7673
7678
  const link = consoleLinkFor(context, `/t/${encodeURIComponent(outcome.task.id)}`);
7679
+ let noAgent = null;
7680
+ const filedRef = placedIn === undefined || remote !== null ? null : store.lookupRef(outcome.task.id);
7681
+ if (filedRef !== null && filedRef.repo !== null) {
7682
+ try {
7683
+ const agentless = agentlessFirstRun(store, filedRef, true, buildersFor(store, filedRef.repo, now).alive.map(one => one.name));
7684
+ if (agentless !== null)
7685
+ noAgent = `${NO_AGENT_TITLE}. Run \`${agentless.command}\` so it can be planned.`;
7686
+ }
7687
+ catch {
7688
+ noAgent = null;
7689
+ }
7690
+ }
7691
+ const next = filedRef !== null && filedRef.repo !== null && filedRef.plan === null && !flags.has("report")
7692
+ ? "Next: open `toolroll` and press p on it to ask for its plan." : null;
7674
7693
  return succeed(write, json, "task add", {
7675
7694
  task: outcome.task,
7676
7695
  ...(replaces === undefined ? {} : { replaces }),
7677
7696
  repo: placedIn === undefined ? null : resolve(placedIn),
7678
7697
  ...(checks === undefined ? {} : { checks }),
7679
7698
  ...(link === null ? {} : { links: { task: link } }),
7680
- }, () => [`Queued ${outcome.task.id} — ${outcome.task.title}${flags.has("report") ? " (a scout task: it delivers a report)" : ""}${checks === undefined ? "" : ` · checks: ${CHECK_LEVEL_WORDS[checks]}`}`, ...(replaces === undefined ? [] : [` It replaces ${replaces}.`]), ...(link === null ? [] : [` ${link}`])]);
7699
+ ...(noAgent === null ? {} : { waiting: noAgent }),
7700
+ ...(next === null ? {} : { next }),
7701
+ }, () => [`Queued ${outcome.task.id} — ${outcome.task.title}${flags.has("report") ? " (a scout task: it delivers a report)" : ""}${checks === undefined ? "" : ` · checks: ${CHECK_LEVEL_WORDS[checks]}`}`, ...(replaces === undefined ? [] : [` It replaces ${replaces}.`]), ...(noAgent === null ? [] : [` ${noAgent}`]),
7702
+ ...(placedIn === undefined && remote === null ? [" It has no project yet: choose one on its page in Toolroll, or file it with `--repo <folder>`."] : []),
7703
+ ...(next === null ? [] : [` ${next}`]),
7704
+ ...(link === null ? [] : [` ${link}`])]);
7681
7705
  }
7682
7706
  function latestBuildResult(store, taskId) {
7683
7707
  const family = store.taskFamilyOf(taskId, null, true);
@@ -8040,7 +8064,7 @@ function showTask(positional, context) {
8040
8064
  : [` control: review #${detail.control.run} was stopped by ${detail.control.stop.requestedBy} — inspect its saved result and give feedback; separate model review has been removed`]),
8041
8065
  ...(detail.automaticReview === null ? reviewStatusLines(detail.review, latestFinished?.id ?? null) : buildReviewLines(detail.automaticReview)),
8042
8066
  ...(scope === null
8043
- ? [" no scope — nothing will build this until one is written and approved"]
8067
+ ? [" no plan yet — nothing is built until one is written and approved"]
8044
8068
  : describeScope(scope, readiness, taskEvidenceWords(store, task.id, now))),
8045
8069
  ...planContractLines(store, context.evidenceRoot, id),
8046
8070
  ...taskRouteStandingLines(id, routed, detail.dispatch?.summary === NO_AGENT_TITLE),
@@ -12491,3 +12515,87 @@ function shellCallerFacts(context) {
12491
12515
  terminal: context.easySeams?.terminal ?? (process.stdin.isTTY === true && process.stdout.isTTY === true),
12492
12516
  };
12493
12517
  }
12518
+ async function projectFlexibleCommand(positional, flags, context) {
12519
+ const action = positional[1] ?? "show";
12520
+ const command = `project flexible ${action}`;
12521
+ const { write, json } = context;
12522
+ if (!FLEXIBLE_AVAILABLE)
12523
+ return fail(write, json, command, "not-available", FLEXIBLE_UNAVAILABLE, EXIT.refused);
12524
+ const options = { show: [], enable: ["max", "default", "digest"], lower: ["max"], off: [] };
12525
+ const own = options[action];
12526
+ if (own === undefined || positional.length > 2)
12527
+ return fail(write, json, command, "usage", "Use project flexible [show | enable [--max <level>] [--default <level>] [--digest <d>] | lower --max <level> | off] --repo <project path>.", EXIT.usage);
12528
+ const allowed = new Set(["repo", "db", "json", ...own, ...(action === "show" ? [] : ["as", "token", "token-file", "token-env"])]);
12529
+ for (const name of flags.keys())
12530
+ if (!allowed.has(name))
12531
+ return fail(write, json, command, "usage", `--${name} is not a project flexible ${action} option.`, EXIT.usage);
12532
+ const repoFlag = text(flags, "repo");
12533
+ if (repoFlag === undefined)
12534
+ return fail(write, json, command, "usage", "Name the project with --repo <path>.", EXIT.usage);
12535
+ const level = (name) => { const value = text(flags, name); return value === undefined ? undefined : isFlexibleLevel(value) ? value : null; };
12536
+ const max = level("max"), chosenDefault = level("default");
12537
+ if (max === null || chosenDefault === null)
12538
+ return fail(write, json, command, "usage", "A level is supervised, auto or full.", EXIT.usage);
12539
+ const repo = await knownProject(context, repoFlag, { listed: true, canonical: true });
12540
+ if (repo === undefined)
12541
+ return fail(write, json, command, "not-found", "That isn't a project Toolroll knows.", EXIT.refused);
12542
+ const store = context.store;
12543
+ const termsLines = (terms, digest) => [...flexibleTermsWords(terms), `Terms ${digest}`];
12544
+ const shown = (standing) => {
12545
+ if (standing.state === "secure")
12546
+ return { data: { state: "secure" }, lines: [`${repo}: Secure. Work is planned and approved before it starts.`] };
12547
+ if (standing.state === "unreadable")
12548
+ return { data: { state: "unreadable" }, lines: [`${repo}: its Flexible terms can't be read, so they allow nothing. Turn Flexible off, then on again.`] };
12549
+ const data = { state: standing.state, digest: standing.digest, terms: standing.terms, signedBy: standing.signedBy, signedAt: standing.signedAt, ...(standing.state === "lapsed" ? { lapse: standing.reason } : {}) };
12550
+ if (standing.state === "lapsed")
12551
+ return { data, lines: [`${repo}: Flexible terms no longer count. ${FLEXIBLE_LAPSE_WORDS[standing.reason]} Turn it on again to sign new terms.`] };
12552
+ return { data, lines: [`${repo}: Flexible, turned on by ${standing.signedBy}.`, ...termsLines(standing.terms, standing.digest)] };
12553
+ };
12554
+ if (action === "show") {
12555
+ const now = shown(flexibleStanding(store, repo));
12556
+ return succeed(write, json, command, { repo, flexible: now.data }, () => now.lines);
12557
+ }
12558
+ const refused = (message) => fail(write, json, command, "person-only", message, EXIT.refused);
12559
+ if (machineActing() || process.env["TOOLROLL_LEAD_TOKEN"] !== undefined || process.env["TOOLROLL_REMOTE_TOKEN"] !== undefined)
12560
+ return refused("Only a person changes a project's Flexible terms, never the lead, a token or a chat app.");
12561
+ const acting = await askCredentials(flags, context);
12562
+ if (acting === null)
12563
+ return refused(`${action === "enable" ? "Turning on Flexible needs your password" : "This needs your sign-in"}: pass --as and --token.`);
12564
+ if (action === "enable") {
12565
+ const proved = credentialApprover(store, acting.name, acting.token, repo);
12566
+ if (!proved.ok)
12567
+ return refused("Only an approver of this project, with their password typed now, turns on Flexible.");
12568
+ const choice = { ...(max === undefined ? {} : { max }), ...(chosenDefault === undefined ? {} : { default: chosenDefault }) };
12569
+ const proposed = proposedFlexibleTerms(store, repo, acting.name, choice);
12570
+ if (!proposed.ok)
12571
+ return fail(write, json, command, proposed.reason, proposed.message, EXIT.refused);
12572
+ let digest = text(flags, "digest");
12573
+ if (digest === undefined) {
12574
+ if (!interactive() || json)
12575
+ return fail(write, json, command, "review-terms", [...termsLines(proposed.terms, proposed.digest), `Read these terms, then run again with --digest ${proposed.digest} to agree to them. Nothing changed.`].join("\n"), EXIT.refused, { digest: proposed.digest, terms: proposed.terms });
12576
+ write(termsLines(proposed.terms, proposed.digest).join("\n"));
12577
+ if (!(await confirm("Turn on Flexible with these terms? [y/N] ")))
12578
+ return fail(write, json, command, "declined", "Nothing changed.", EXIT.refused);
12579
+ digest = proposed.digest;
12580
+ }
12581
+ const done = enableFlexible(store, { repo, by: acting.name, proof: proved.method, choice, shownDigest: digest, now: context.clock() });
12582
+ if (!done.ok)
12583
+ return fail(write, json, command, done.reason, done.message, EXIT.refused);
12584
+ return succeed(write, json, command, { repo, flexible: shown(flexibleStanding(store, repo)).data, replaced: done.replaced }, () => [`${repo} is Flexible.`, ...termsLines(done.terms, done.digest)]);
12585
+ }
12586
+ const proved = authenticateApprover(store, acting.name, acting.token, repo);
12587
+ if (!proved.ok || !personProof(proved.method))
12588
+ return refused("Only an approver of this project, signed in as a person, changes its Flexible terms.");
12589
+ if (action === "lower") {
12590
+ if (max === undefined)
12591
+ return fail(write, json, command, "usage", "Name the highest level with --max supervised, auto or full.", EXIT.usage);
12592
+ const done = lowerFlexible(store, { repo, by: acting.name, max, now: context.clock() });
12593
+ if (!done.ok)
12594
+ return fail(write, json, command, done.reason, done.message, EXIT.refused);
12595
+ return succeed(write, json, command, { repo, changed: done.changed, flexible: shown(flexibleStanding(store, repo)).data }, () => [done.changed ? `Lowered: threads in ${repo} run at ${FLEXIBLE_LEVEL_WORDS[done.terms.max]} at most. New threads start under these terms only.` : "Nothing changed.", ...termsLines(done.terms, done.digest)]);
12596
+ }
12597
+ const done = turnFlexibleOff(store, { repo, by: acting.name, now: context.clock() });
12598
+ if (!done.ok)
12599
+ return fail(write, json, command, done.reason, done.message, EXIT.refused);
12600
+ return succeed(write, json, command, { repo, changed: done.changed, flexible: { state: "secure" } }, () => [done.changed ? `${repo} is Secure again. No new Flexible threads start.` : `${repo} is already Secure.`]);
12601
+ }
@@ -6,6 +6,7 @@ import { html, joinHtml, postForm } from "./html.js";
6
6
  import { holdingsWords } from "./project-delete.js";
7
7
  import { acts, btn, codeLine, disclose, formRow, infoLine, input, note, notice, radios, settingsSection, switchInput, textarea } from "./server/kit.js";
8
8
  import { kitSectionForm } from "./settings-kit.js";
9
+ import { flexibleSettingsHtml } from "./flexible-ui.js";
9
10
  export const PROJECT_DELETE_CSS = ".k-opt [data-check-access-warning]{display:none;color:var(--so-ink)}.k-opt:has(input:checked) [data-check-access-warning]{display:block}" +
10
11
  ".k-opt:has(input:disabled){cursor:default;opacity:.6}";
11
12
  const mono = (text) => html `<span class="k-mono">${text}</span>`;
@@ -199,7 +200,7 @@ export function projectSettingsHtml(view, said) {
199
200
  disclose("Change remote", joinHtml([note("An owner or instance operator can run:"), codeLine("toolroll repos add <project> --remote <url>")])),
200
201
  ]) });
201
202
  const advanced = advancedShownNow();
202
- const settings = joinHtml([buildsHtml(view), accessHtml(view), networkHtml(view), advanced || (view.fallback?.setting ?? null) !== null ? fallbackHtml(view) : "",
203
+ const settings = joinHtml([flexibleSettingsHtml(view.flexible), buildsHtml(view), accessHtml(view), networkHtml(view), advanced || (view.fallback?.setting ?? null) !== null ? fallbackHtml(view) : "",
203
204
  writesHtml(view), sandboxHtml(view), checkAccessHtml(view), advanced || view.liveView?.commands === true ? liveViewHtml(view) : "", advanced ? codeMapHtml(view) : ""]);
204
205
  if (!view.canDelete)
205
206
  return joinHtml([answer, project, settings, note("An instance operator can remove or delete a project.")]);
@@ -30,6 +30,7 @@ const SETTINGS = [
30
30
  ["learning_policy", "repo"], ["operating_mode", "repo"], ["project_knowledge", "repo"], ["live_detail_setting", "repo"],
31
31
  ["project_decision", "repo"], ["flow_script", "repo"], ["workflow_recipe", "repo"], ["team_lead_project", "project"],
32
32
  ["fallback_setting", "repo"],
33
+ ["flexible_terms", "repo"],
33
34
  ];
34
35
  export const MODEL_SETTINGS = Object.freeze([["phase_config", "scope"], ["phase_tier_config", "scope"], ["phase_tier_alternate", "scope"]]);
35
36
  export const PROJECT_SETTINGS = Object.freeze(SETTINGS.map(one => [...one]));
@@ -105,7 +105,7 @@ function notifyOperators(store, key, message, now) {
105
105
  dedupeKey: `${SIGN_IN_KEY_PREFIX}${key}:${recipient}`,
106
106
  kind: message.kind,
107
107
  pushClass: "attention",
108
- link: "/tasks",
108
+ link: "/",
109
109
  subject: message.subject,
110
110
  body: message.body,
111
111
  recipient,
package/dist/release.js CHANGED
@@ -36,6 +36,7 @@ export const ADVISORY_PR_CHECKS = {
36
36
  "upgrade path": ".github/workflows/upgrade-path.yml",
37
37
  "install smoke · ubuntu-24.04": ".github/workflows/install-smoke.yml",
38
38
  "install smoke · macos-latest": ".github/workflows/install-smoke.yml",
39
+ "wire budgets": ".github/workflows/wire-budgets.yml",
39
40
  };
40
41
  export const RELEASE_TAG_CHECKS = ["release proof", "publish"];
41
42
  export const RELEASE_TAG_WORKFLOW = ".github/workflows/publish.yml";
@@ -1,5 +1,6 @@
1
1
  import { verifyResultImage } from "./chat-evidence.js";
2
2
  import { createHash, randomBytes } from "node:crypto";
3
+ import { markTypedByPerson } from "./store.js";
3
4
  import { EVIDENCE_CAPS, readVerifiedArtifact, writeEvidenceFile } from "./evidence.js";
4
5
  import { parseFeedbackImage, sameFeedbackImage, isRevisionFeedback, parseRevisionBatch, revisionSourceOf, commentSourceKey, REQUEST_TOKEN } from "./result-review.js";
5
6
  import { validateNote, hasForbiddenControls } from "./decision.js";
@@ -68,6 +69,8 @@ export function requestResultChanges(store, evidenceRoot, input, now) {
68
69
  const noteId = earlier?.id ?? store.addDiffComment({ artifactId: artifact.id, runId: run.id, path, line, note: valid.note, author: input.actor, sourceKey, image: input.image ?? null }, now);
69
70
  if (noteId === null)
70
71
  return fail(409, "This feedback changed while saving. Your draft is unchanged; reopen the result.");
72
+ if (earlier === null)
73
+ markTypedByPerson(store, { comment: noteId }, input.actor, input.typedWords, now);
71
74
  const result = createResultRevision(store, evidenceRoot, { ...input, batch: [...new Set([...batch, noteId])].sort((a, b) => a - b).join(",") }, now);
72
75
  if (!result.ok)
73
76
  return fail(result.status, result.message);
@@ -1,5 +1,5 @@
1
1
  import { readVerifiedArtifact } from "./evidence.js";
2
- import { hasForbiddenControls } from "./decision.js";
2
+ import { HANDOFF_REPORT_CAP, hasDisguisedText, hasForbiddenControls } from "./decision.js";
3
3
  import { parseHandoffArtifact } from "./contracts/handoff.js";
4
4
  const CAPTURE_EXIT = /\(exit ([0-9]{1,4})\)\s*$/;
5
5
  export const SCREENSHOT_CAPTURE = /^agent-claimed screenshot at (.+) \(validated (?:png|jpeg)\)/;
@@ -25,7 +25,13 @@ export function structuredHandoffView(artifacts, root, displayText = text => tex
25
25
  .filter(one => one.trim() !== "" && !hasForbiddenControls(one))
26
26
  .slice(0, 8)
27
27
  .map(one => oneLineOf(one, 240));
28
- return { conclusion, changes: list(handoff.changes), verification: list(handoff.verification), followUps: list(handoff.followUps) };
28
+ const reported = (items) => (items ?? [])
29
+ .filter(one => one.trim() !== "" && !hasDisguisedText(one))
30
+ .slice(0, HANDOFF_REPORT_CAP)
31
+ .map(one => oneLineOf(displayText(one), 240))
32
+ .filter(one => one !== "" && !hasDisguisedText(one));
33
+ return { conclusion, changes: list(handoff.changes), verification: list(handoff.verification), followUps: list(handoff.followUps),
34
+ report: { decisions: reported(handoff.decisions), assumptions: reported(handoff.assumptions), notDone: reported(handoff.notDone), risks: reported(handoff.risks) } };
29
35
  }
30
36
  export function terminalDiffView(artifacts, root) {
31
37
  const patchArtifact = artifacts.find(one => one.kind === "terminal-diff");
@@ -145,8 +145,8 @@ export function resultReturnTarget(raw, runId, tasks = []) {
145
145
  return raw;
146
146
  if (tasks.some(task => raw === `/t/${encodeURIComponent(task)}`))
147
147
  return raw;
148
- const tab = /^\/t\/([A-Za-z0-9._~%-]{1,200})\?(?:version=[A-Za-z0-9._~%-]{1,200}&)?tab=result&run=([0-9]{1,15})(?:&section=(?:summary|changes|checks))?$/.exec(raw);
149
- if (tab !== null && Number(tab[2]) === runId && tasks.some(task => tab[1] === encodeURIComponent(task)))
148
+ const tab = /^\/t\/([A-Za-z0-9._~%-]{1,200})\?(?:version=[A-Za-z0-9._~%-]{1,200}&)?tab=result(?:&run=([0-9]{1,15}))?(?:&section=(?:summary|changes|checks))?$/.exec(raw);
149
+ if (tab !== null && (tab[2] === undefined || Number(tab[2]) === runId) && tasks.some(task => tab[1] === encodeURIComponent(task)))
150
150
  return raw;
151
151
  }
152
152
  return `/r/${runId}`;
@@ -236,6 +236,15 @@ export const RESULT_REVIEW_SCRIPT = String.raw `
236
236
  if(form){
237
237
  var noteBox=form.querySelector('[name=note]'),pathBox=form.querySelector('[name=path]'),lineBox=form.querySelector('[name=line]'),pin=form.querySelector('details.result-pin');
238
238
  var imageBox=form.querySelector('[name=image]'),imagePreview=form.querySelector('[data-feedback-image]');
239
+ // What the page fills in for the person (a reviewer's note to act on, a requirement marked Not right) is its own
240
+ // field, shown as sent with the note and never written into the person's own box: only what they type is theirs.
241
+ var contextBox=form.querySelector('[name=context]'),contextLine=form.querySelector('[data-request-context-line]');
242
+ // One item per line; each is shown, as text, in a list under "Sent with it".
243
+ function setContext(text){if(!contextBox)return;contextBox.value=text;if(contextLine){contextLine.textContent='';var items=text.split('\n').filter(function(one){return one.trim()!=='';});
244
+ if(items.length>0){contextLine.appendChild(document.createTextNode('Sent with it:'));var list=document.createElement('ul');items.forEach(function(one){var li=document.createElement('li');li.textContent=one;list.appendChild(li);});contextLine.appendChild(list);}
245
+ contextLine.hidden=items.length===0;}}
246
+ // A further item joins what is already there (the same one again changes nothing): earlier feedback is never lost.
247
+ function addContext(item){if(!contextBox||!item.trim())return;var items=contextBox.value.split('\n').filter(function(one){return one.trim()!=='';});if(items.indexOf(item)<0)items.push(item);setContext(items.join('\n'));}
239
248
  function showImage(){
240
249
  if(!imageBox||!imagePreview)return;
241
250
  imagePreview.hidden=!imageBox.value;
@@ -253,7 +262,7 @@ export const RESULT_REVIEW_SCRIPT = String.raw `
253
262
  });
254
263
  var limit=document.getElementById('comment-note-limit'),requestBox=form.querySelector('[name=request]');
255
264
  function updateActions(){
256
- var typed=!!(noteBox&&noteBox.value.trim()),batch=form.querySelector('[name=batch]');
265
+ var typed=!!(noteBox&&noteBox.value.trim())||!!(contextBox&&contextBox.value.trim()),batch=form.querySelector('[name=batch]');
257
266
  var requestAction=form.querySelector('[data-request-changes]'),saveAction=form.querySelector('[data-save-feedback]');
258
267
  if(requestAction)requestAction.disabled=!typed&&!(batch&&batch.value);
259
268
  if(saveAction)saveAction.disabled=!typed;
@@ -266,8 +275,7 @@ export const RESULT_REVIEW_SCRIPT = String.raw `
266
275
  document.addEventListener('click',function(ev){
267
276
  var button=ev.target&&ev.target.closest?ev.target.closest('button.pick-file,button.pick-line'):null;if(!button)return;
268
277
  var reviewNote=button.getAttribute('data-review-note');
269
- if(reviewNote!==null&&noteBox&&noteBox.value&&!window.confirm('Replace the feedback draft with this note?'))return;
270
- if(reviewNote!==null&&noteBox)noteBox.value=reviewNote;
278
+ if(reviewNote!==null){var at=button.getAttribute('data-path');addContext(reviewNote.replace(/\s+/g,' ')+(at?' ('+at+(button.getAttribute('data-line')?':'+button.getAttribute('data-line'):'')+')':''));}
271
279
  if(pathBox)pathBox.value=button.getAttribute('data-path')||'';
272
280
  if(lineBox)lineBox.value=button.getAttribute('data-line')||'';
273
281
  if(pin)pin.open=true;
@@ -285,7 +293,8 @@ export const RESULT_REVIEW_SCRIPT = String.raw `
285
293
  // A fresh request identity: 16 random bytes as hex, the server's own shape.
286
294
  function mint(){var bytes=new Uint8Array(16);try{crypto.getRandomValues(bytes);}catch(e){for(var i=0;i<16;i++)bytes[i]=Math.floor(Math.random()*256);}
287
295
  var hex='';for(var j=0;j<16;j++)hex+=(bytes[j]<16?'0':'')+bytes[j].toString(16);return hex;}
288
- function payload(){return JSON.stringify([noteBox?noteBox.value:'',pathBox?pathBox.value:'',lineBox?lineBox.value:'',imageBox?imageBox.value:'']);}
296
+ // The filled-in field joins the identity only when it holds something, so a draft sent before it existed keeps its own.
297
+ function payload(){var parts=[noteBox?noteBox.value:'',pathBox?pathBox.value:'',lineBox?lineBox.value:'',imageBox?imageBox.value:''];if(contextBox&&contextBox.value)parts.push(contextBox.value);return JSON.stringify(parts);}
289
298
  // What the current token was last submitted with; null = never sent.
290
299
  var sent=null,bound=null;
291
300
  // The server refused this token for a different note or another result:
@@ -308,8 +317,9 @@ export const RESULT_REVIEW_SCRIPT = String.raw `
308
317
  if(typeof saved.request==='string'&&/^[a-f0-9]{32}$/.test(saved.request)&&requestBox)requestBox.value=saved.request;
309
318
  if(typeof saved.sent==='string')sent=saved.sent;
310
319
  if(imageBox&&typeof saved.image==='string'&&saved.image.length<250)imageBox.value=saved.image;
320
+ if(contextBox&&!contextBox.value&&typeof saved.context==='string'&&saved.context.length<=4000)setContext(saved.context);
311
321
  showImage();
312
- bound=JSON.stringify([saved.note,saved.path||'',saved.line||'',saved.image||'']);
322
+ bound=JSON.stringify([saved.note,saved.path||'',saved.line||'',saved.image||''].concat(saved.context?[saved.context]:[]));
313
323
  if(noteBox)noteBox.dispatchEvent(new Event('input'));
314
324
  }
315
325
  function save(){
@@ -319,8 +329,9 @@ export const RESULT_REVIEW_SCRIPT = String.raw `
319
329
  var current=payload();
320
330
  if((bound!==null&&current!==bound)||(sent!==null&&current!==sent)){sent=null;if(requestBox)requestBox.value=mint();}
321
331
  bound=current;
322
- if(!note&&!path&&!line&&!(imageBox&&imageBox.value)){write(draftKey,null);return;}
323
- write(draftKey,{note:note,path:path,line:line,image:imageBox?imageBox.value:'',request:requestBox?requestBox.value:'',sent:sent,at:Date.now()});
332
+ var context=contextBox?contextBox.value:'';
333
+ if(!note&&!path&&!line&&!context&&!(imageBox&&imageBox.value)){write(draftKey,null);return;}
334
+ write(draftKey,{note:note,path:path,line:line,image:imageBox?imageBox.value:'',context:context,request:requestBox?requestBox.value:'',sent:sent,at:Date.now()});
324
335
  if(!storage&&limit)limit.textContent='Draft stays on this page only. Browser storage is unavailable.';
325
336
  }
326
337
  form.addEventListener('input',save);