toolroll 0.9.115 → 0.9.117

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 (145) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +43 -26
  3. package/dist/acp-agents.js +14 -1
  4. package/dist/acp-client.js +19 -1
  5. package/dist/agent-change-check.js +60 -0
  6. package/dist/agent-change-schema.js +19 -0
  7. package/dist/agent-detect.js +11 -1
  8. package/dist/agent-fence.js +39 -10
  9. package/dist/agent-network-request.js +108 -0
  10. package/dist/agent-requests.js +105 -0
  11. package/dist/approval-summary.js +3 -3
  12. package/dist/backup.js +17 -1
  13. package/dist/batch-checks.js +81 -18
  14. package/dist/browser/terminal.js +41 -41
  15. package/dist/browser/workspace.css +2 -2
  16. package/dist/browser/workspace.js +36 -36
  17. package/dist/builder.js +3 -1
  18. package/dist/candidate-materialize.js +119 -0
  19. package/dist/central-enrollment-contract.js +156 -0
  20. package/dist/central-recovery-stage.js +329 -0
  21. package/dist/chat-actions.js +101 -2
  22. package/dist/chat-channel.js +40 -0
  23. package/dist/check-only-standing.js +13 -0
  24. package/dist/check-only.js +25 -13
  25. package/dist/check-recovery-hold.js +199 -0
  26. package/dist/check-recovery-index-schema.js +3 -0
  27. package/dist/check-screenshots.js +83 -0
  28. package/dist/cli.js +125 -6
  29. package/dist/codex-limits.js +4 -0
  30. package/dist/connect-cli.js +257 -11
  31. package/dist/contracts/chat-actions.js +4 -0
  32. package/dist/contracts/console-api.js +15 -4
  33. package/dist/contracts/engine-api.js +344 -2
  34. package/dist/contracts/lead-tools.js +56 -2
  35. package/dist/contracts/provider.js +1 -1
  36. package/dist/contracts/route.js +1 -1
  37. package/dist/contracts/terminal-connection.js +50 -0
  38. package/dist/converse.js +80 -4
  39. package/dist/device-pair.js +280 -0
  40. package/dist/direct-chat-artifacts.js +347 -0
  41. package/dist/direct-chat-catalog.js +311 -0
  42. package/dist/direct-chat-fence.js +96 -0
  43. package/dist/direct-chat-git.js +343 -0
  44. package/dist/direct-chat-laptop.js +19 -0
  45. package/dist/direct-chat-schema.js +181 -0
  46. package/dist/direct-chat-ship.js +861 -0
  47. package/dist/direct-chat-workspace.js +389 -0
  48. package/dist/direct-chat.js +2107 -0
  49. package/dist/doctor.js +1 -1
  50. package/dist/easy-start.js +18 -0
  51. package/dist/egress.js +25 -4
  52. package/dist/engine-chat.js +454 -0
  53. package/dist/engine-reads.js +141 -13
  54. package/dist/exec.js +4 -3
  55. package/dist/flexible-agents.js +8 -16
  56. package/dist/flexible-authority-end.js +2 -0
  57. package/dist/flexible-interactive-schema.js +133 -0
  58. package/dist/flexible-interactive.js +94 -0
  59. package/dist/flexible-session.js +117 -49
  60. package/dist/flexible-ship.js +87 -7
  61. package/dist/flexible-sign-in.js +10 -0
  62. package/dist/flexible-start.js +21 -3
  63. package/dist/flexible-thread.js +2 -3
  64. package/dist/flexible-turns.js +26 -5
  65. package/dist/flexible.js +13 -0
  66. package/dist/flow-triggers.js +13 -4
  67. package/dist/flows-ui.js +54 -20
  68. package/dist/handoff-cli.js +630 -0
  69. package/dist/invoke.js +55 -13
  70. package/dist/lead-contract.js +5 -4
  71. package/dist/lead-doors.js +80 -1
  72. package/dist/lead-progress.js +9 -0
  73. package/dist/lead-tools.js +682 -10
  74. package/dist/lead.js +37 -9
  75. package/dist/live-bus.js +11 -0
  76. package/dist/live-terminal.js +132 -12
  77. package/dist/local-handoff.js +363 -0
  78. package/dist/local-owner-acts.js +264 -2
  79. package/dist/local-owner.js +16 -1
  80. package/dist/multiplayer-handoff.js +528 -0
  81. package/dist/multiplayer-presence.js +471 -0
  82. package/dist/names.js +17 -4
  83. package/dist/needs-you.js +10 -0
  84. package/dist/operate.js +280 -19
  85. package/dist/policy.js +2 -2
  86. package/dist/project-delete-ui.js +18 -11
  87. package/dist/project-delete.js +65 -4
  88. package/dist/project-tools.js +1 -1
  89. package/dist/prompt.js +1 -1
  90. package/dist/provider-connection.js +2 -0
  91. package/dist/provider-home.js +251 -8
  92. package/dist/provider.js +3 -2
  93. package/dist/publish.js +119 -64
  94. package/dist/pull-request-flow.js +35 -14
  95. package/dist/read-executor-worker.js +1 -1
  96. package/dist/read-executor.js +95 -1
  97. package/dist/restore-retirement.js +152 -0
  98. package/dist/result-follow-ups.js +116 -37
  99. package/dist/route-change.js +44 -4
  100. package/dist/scope.js +62 -5
  101. package/dist/serve.js +49 -5
  102. package/dist/server/chat.js +94 -13
  103. package/dist/server/console.css +9 -9
  104. package/dist/server/direct-chat.js +583 -0
  105. package/dist/server/engine-api.js +219 -21
  106. package/dist/server/flows.js +47 -13
  107. package/dist/server/found-repos.js +25 -0
  108. package/dist/server/guards.js +20 -6
  109. package/dist/server/live.js +81 -23
  110. package/dist/server/pages.js +67 -13
  111. package/dist/server/people-tokens.js +47 -6
  112. package/dist/server/remote.js +29 -0
  113. package/dist/server/render-results.js +6 -2
  114. package/dist/server/render-settings.js +4 -2
  115. package/dist/server/render-tasks.js +18 -17
  116. package/dist/server/route-table.js +69 -2
  117. package/dist/server/settings.js +22 -7
  118. package/dist/server/task-views.js +15 -3
  119. package/dist/server/tasks.js +39 -2
  120. package/dist/server/terminals.js +185 -11
  121. package/dist/settings-proofs.js +1 -1
  122. package/dist/spend-report.js +2 -2
  123. package/dist/spend.js +3 -3
  124. package/dist/store.js +600 -59
  125. package/dist/subagent-admin.js +23 -10
  126. package/dist/subagent-backup-schema.js +36 -0
  127. package/dist/subagent-backup.js +92 -0
  128. package/dist/subagent-week.js +2 -2
  129. package/dist/subagent-work.js +70 -47
  130. package/dist/subagents-ui.js +6 -2
  131. package/dist/subagents.js +5 -2
  132. package/dist/subscription-chat.js +36 -5
  133. package/dist/subscription-usage.js +233 -0
  134. package/dist/task-live.js +2 -1
  135. package/dist/teardown-git.js +34 -4
  136. package/dist/terminal-connection.js +159 -0
  137. package/dist/terminal-safety.js +114 -0
  138. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  139. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  140. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  141. package/dist/tui/linux-x64/toolroll-tui +0 -0
  142. package/dist/tui-contract.js +1 -1
  143. package/dist/tui-launch.js +32 -1
  144. package/dist/workspace-identity-schema.js +21 -0
  145. package/package.json +4 -2
@@ -10,16 +10,20 @@ import { loadPtySpawn, MAX_FRAME_BYTES, TerminalHost, MAX_VIEWERS, parseTerminal
10
10
  import { logEvent } from "../log.js";
11
11
  import { sessionStandsIn, soloNow } from "../install-mode.js";
12
12
  import { localOwnerStandsNow } from "../local-owner.js";
13
- import { resultRunsOf, SHELL_NO_COMMIT, SHELL_NO_RESULT } from "../engine-reads.js";
13
+ import { SHELL_NO_COMMIT, SHELL_NO_RESULT, takeOverRevisionOf, takeOverRunsOf } from "../engine-reads.js";
14
+ import { failedAttemptSentence } from "../needs-you.js";
14
15
  import { checkEngineResponse } from "../contracts/engine-api.js";
15
16
  import { projectName, rowVisible } from "../project.js";
16
17
  import { transportOf } from "../public-access.js";
18
+ import { agentSaidOf } from "../store.js";
17
19
  import { agentSetupOf } from "../agent-detect.js";
18
20
  import { excludedFolders, launchPath, resolveLaunch, statusEnvironment } from "../status-probe.js";
19
21
  import { boundedAcl } from "../trusted-path.js";
20
22
  import { handlersOf } from "./handler-registry.js";
21
23
  import { respond } from "./http.js";
22
24
  import { rereadBrowser } from "./live.js";
25
+ import { remoteAllows, reproveRemote } from "../operate-remote.js";
26
+ import { admitRemoteTerminalRequest, isRemoteTerminalRequest } from "../terminal-connection.js";
23
27
  const TERMINAL_ID = /^\/term\/([a-f0-9]{32})(?:\/(socket|close|remove))?$/;
24
28
  const BEHIND_BYTES = 4 * 1024 * 1024;
25
29
  const INPUT_BURST = 256 * 1024;
@@ -104,7 +108,7 @@ export function createTerminalHandlers(runtime, deps) {
104
108
  const who = operatorOf(ctx.who);
105
109
  if (who === null)
106
110
  return checked(ctx, 403, "refusal", { error: "operator" });
107
- const sessions = deps.host === null ? [] : deps.host.list(who.name).filter(one => one.agent === null && owned(who, one) && projectAllowed(who.name, one.repo));
111
+ const sessions = deps.host === null ? [] : deps.host.listAll().filter(one => one.agent === null && ((who.authority === "full" && one.localGeneration === null) || owned(who, one)) && projectAllowed(who.name, one.repo));
108
112
  return checked(ctx, 200, "termState", {
109
113
  available: deps.host !== null, problem: deps.host === null ? deps.problem ?? "Terminals aren't available on this install." : null,
110
114
  programs: [...TERMINAL_PROGRAMS],
@@ -117,16 +121,16 @@ export function createTerminalHandlers(runtime, deps) {
117
121
  const family = runtime.familyOf(taskId);
118
122
  if (family === null || family.problem !== null)
119
123
  return "No such task.";
120
- const run = resultRunsOf(store, family).filter(one => runtime.runVisible(one)).find(one => one.id === runId) ?? null;
124
+ const run = takeOverRunsOf(store, family).filter(one => runtime.runVisible(one)).find(one => one.id === runId) ?? null;
121
125
  if (run === null)
122
126
  return SHELL_NO_RESULT;
123
- const revision = run.headRevision;
124
- if (revision === null || !/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/.test(revision))
127
+ const revision = takeOverRevisionOf(run);
128
+ if (revision === null)
125
129
  return SHELL_NO_COMMIT;
126
130
  const repo = runtime.taskRepoOf(run.taskRef);
127
131
  if (repo === null)
128
132
  return "This build's project isn't known here.";
129
- return { repo, revision };
133
+ return { repo, revision, run, family };
130
134
  };
131
135
  async function start(ctx) {
132
136
  const answer = (status, value) => checked(ctx, status, "termStarted", value);
@@ -139,7 +143,7 @@ export function createTerminalHandlers(runtime, deps) {
139
143
  return answer(400, { ok: false, error: "Submit one value for each field." });
140
144
  const program = body.get("program") ?? "";
141
145
  if (!TERMINAL_PROGRAMS.includes(program))
142
- return answer(400, { ok: false, error: "Choose Claude Code, Codex or a shell." });
146
+ return answer(400, { ok: false, error: "Choose Claude Code, Codex, Antigravity or a shell." });
143
147
  const taskField = body.get("task"), runField = body.get("run");
144
148
  if ((taskField === null) !== (runField === null))
145
149
  return answer(400, { ok: false, error: "Name the task and its build." });
@@ -150,7 +154,12 @@ export function createTerminalHandlers(runtime, deps) {
150
154
  const found = takeOverOf(taskField, Number(runField));
151
155
  if (typeof found === "string")
152
156
  return answer(404, { ok: false, error: found });
153
- from = { revision: found.revision, task: taskField, run: Number(runField) };
157
+ from = {
158
+ revision: found.revision,
159
+ task: taskField,
160
+ run: Number(runField),
161
+ ...(program === "shell" ? {} : { prompt: takeOverPromptOf(store, found.family, found.run) }),
162
+ };
154
163
  repo = found.repo;
155
164
  }
156
165
  else
@@ -221,7 +230,7 @@ export function createTerminalHandlers(runtime, deps) {
221
230
  return answer(409, { ok: false, error: kind === "sign-in" ? "This agent signs in another way: its screen says how." : "Toolroll doesn't run this agent's installer: run the command shown in your own terminal." });
222
231
  if (kind === "install" && body.get("confirm") !== shown)
223
232
  return answer(409, { ok: false, error: "Confirm the exact install command first." });
224
- if (agentId === "claude" || agentId === "codex") {
233
+ if (agentId === "claude" || agentId === "codex" || agentId === "antigravity") {
225
234
  const stopped = store.sessionPolicyRefusal(agentId, null, "live terminals");
226
235
  if (stopped !== null)
227
236
  return answer(403, { ok: false, error: stopped });
@@ -304,6 +313,8 @@ export function createTerminalHandlers(runtime, deps) {
304
313
  catch { }
305
314
  socket.destroy();
306
315
  };
316
+ const attachable = (who, terminal, request) => (who.authority === "full" && terminal !== null && terminal.agent === null && terminal.localGeneration === null && projectAllowed(who.name, terminal.repo))
317
+ || reachable(who, terminal, request);
307
318
  function upgrade(request, socket, head) {
308
319
  let url;
309
320
  try {
@@ -335,6 +346,33 @@ export function createTerminalHandlers(runtime, deps) {
335
346
  refuseUpgrade(socket, 403, "Open the console over HTTPS to use a terminal from here.");
336
347
  return true;
337
348
  }
349
+ if (isRemoteTerminalRequest(request)) {
350
+ const identified = runtime.identify(request, false, true);
351
+ const principal = identified?.via === "bearer" ? identified.principal : undefined;
352
+ const admitted = admitRemoteTerminalRequest(request, store, principal, runtime.clock);
353
+ if (!admitted.ok) {
354
+ refuseUpgrade(socket, admitted.status, `Remote terminal rejected (${admitted.error}).`);
355
+ return true;
356
+ }
357
+ const account = store.accountOf(principal.account);
358
+ if (admitted.scope !== "act" || account === null || account.revokedAt !== null || account.role !== "approver"
359
+ || store.isDemo() || !codingActorAllowed({ name: principal.account, generation: principal.generation })) {
360
+ refuseUpgrade(socket, 403, "Attaching to a remote terminal requires an approver act API token.");
361
+ return true;
362
+ }
363
+ const terminal = deps.host?.get(id) ?? null;
364
+ if (terminal === null || terminal.agent !== null || terminal.localGeneration !== null
365
+ || !projectAllowed(principal.account, terminal.repo) || !remoteAllows(store, principal, terminal.repo)) {
366
+ refuseUpgrade(socket, 404, "No such terminal.");
367
+ return true;
368
+ }
369
+ if (deps.host.viewerCount(id) >= MAX_VIEWERS) {
370
+ refuseUpgrade(socket, 429, `This terminal is open in ${MAX_VIEWERS} places already.`);
371
+ return true;
372
+ }
373
+ wss.handleUpgrade(request, socket, head, ws => attachRemote(ws, request, principal, terminal));
374
+ return true;
375
+ }
338
376
  const expected = deps.publicOrigin !== null && host === deps.publicOrigin.host ? deps.publicOrigin.origin : `${transport.https ? "https" : "http"}://${host}`;
339
377
  if (request.headers.origin !== expected) {
340
378
  refuseUpgrade(socket, 403, "A terminal opens only from this console's own page.");
@@ -355,7 +393,7 @@ export function createTerminalHandlers(runtime, deps) {
355
393
  return true;
356
394
  }
357
395
  const terminal = deps.host?.get(id) ?? null;
358
- if (!reachable(who, terminal, request)) {
396
+ if (!attachable(who, terminal, request)) {
359
397
  refuseUpgrade(socket, 404, "No such terminal.");
360
398
  return true;
361
399
  }
@@ -387,7 +425,7 @@ export function createTerminalHandlers(runtime, deps) {
387
425
  };
388
426
  const prove = () => {
389
427
  const again = rereadBrowser(runtime, request, who);
390
- const ok = again !== null && operatorOf(again) !== null && reachable(again, host.get(terminal.id), request);
428
+ const ok = again !== null && operatorOf(again) !== null && attachable(again, host.get(terminal.id), request);
391
429
  if (ok)
392
430
  provedAt = Date.now();
393
431
  return ok;
@@ -396,6 +434,7 @@ export function createTerminalHandlers(runtime, deps) {
396
434
  shut(4401, "signed out"); };
397
435
  const stillProved = () => Date.now() - provedAt < REPROVE_MS || prove();
398
436
  const viewer = {
437
+ actor: who.name,
399
438
  output(data) {
400
439
  if (closed)
401
440
  return;
@@ -426,6 +465,17 @@ export function createTerminalHandlers(runtime, deps) {
426
465
  const frame = parseTerminalFrame(text);
427
466
  if (frame === null)
428
467
  return shut(1003, "not a terminal frame");
468
+ if (frame.t === "take-control") {
469
+ if (host.takeControl(terminal.id, viewer))
470
+ record("take-control", who.name, terminal);
471
+ return;
472
+ }
473
+ if (frame.t === "release-control") {
474
+ host.releaseControl(terminal.id, viewer);
475
+ return;
476
+ }
477
+ if (!host.isController(terminal.id, viewer))
478
+ return;
429
479
  if (frame.t === "resize")
430
480
  return host.resize(terminal.id, frame.cols, frame.rows);
431
481
  const now = Date.now();
@@ -451,6 +501,110 @@ export function createTerminalHandlers(runtime, deps) {
451
501
  reprovers.add(reprove);
452
502
  record("attach", who.name, terminal);
453
503
  }
504
+ function attachRemote(ws, request, principal, terminal) {
505
+ const host = deps.host;
506
+ sockets.add(ws);
507
+ let provedAt = 0, closed = false, detach = null;
508
+ let budget = INPUT_BURST, filledAt = Date.now();
509
+ const shut = (code, reason) => {
510
+ if (closed)
511
+ return;
512
+ closed = true;
513
+ detach?.();
514
+ reprovers.delete(reprove);
515
+ try {
516
+ ws.close(code, reason);
517
+ }
518
+ catch {
519
+ ws.terminate();
520
+ }
521
+ setTimeout(() => ws.terminate(), 2_000).unref?.();
522
+ };
523
+ const prove = () => {
524
+ const admitted = admitRemoteTerminalRequest(request, store, principal, runtime.clock);
525
+ const live = reproveRemote(store, principal, runtime.clock());
526
+ const account = store.accountOf(principal.account);
527
+ const current = host.get(terminal.id);
528
+ const ok = admitted.ok && admitted.scope === "act" && live.ok && live.scope === "act"
529
+ && account !== null && account.revokedAt === null && account.role === "approver"
530
+ && !store.isDemo() && codingActorAllowed({ name: principal.account, generation: principal.generation })
531
+ && current !== null && current.agent === null && current.localGeneration === null
532
+ && projectAllowed(principal.account, current.repo) && remoteAllows(store, principal, current.repo);
533
+ if (ok)
534
+ provedAt = Date.now();
535
+ return ok;
536
+ };
537
+ const reprove = () => { if (!closed && !prove())
538
+ shut(4401, "signed out"); };
539
+ const stillProved = () => Date.now() - provedAt < REPROVE_MS || prove();
540
+ const viewer = {
541
+ actor: principal.account,
542
+ output(data) {
543
+ if (closed)
544
+ return;
545
+ if (!stillProved())
546
+ return shut(4401, "signed out");
547
+ if (ws.bufferedAmount > BEHIND_BYTES)
548
+ return shut(4008, "fell behind");
549
+ ws.send(data, { binary: true });
550
+ },
551
+ control(message) {
552
+ if (closed)
553
+ return;
554
+ if (!stillProved())
555
+ return shut(4401, "signed out");
556
+ ws.send(JSON.stringify(message));
557
+ },
558
+ backlog: () => closed ? 0 : ws.bufferedAmount,
559
+ overflow: () => shut(4008, "fell behind"),
560
+ };
561
+ ws.on("message", (data, isBinary) => {
562
+ if (closed)
563
+ return;
564
+ if (isBinary)
565
+ return shut(1003, "text frames only");
566
+ if (!prove())
567
+ return shut(4401, "signed out");
568
+ const text = Array.isArray(data) ? Buffer.concat(data).toString("utf8") : Buffer.from(data).toString("utf8");
569
+ const frame = parseTerminalFrame(text);
570
+ if (frame === null)
571
+ return shut(1003, "not a terminal frame");
572
+ if (frame.t === "take-control") {
573
+ if (host.takeControl(terminal.id, viewer))
574
+ record("take-control", principal.account, terminal);
575
+ return;
576
+ }
577
+ if (frame.t === "release-control") {
578
+ host.releaseControl(terminal.id, viewer);
579
+ return;
580
+ }
581
+ if (!host.isController(terminal.id, viewer))
582
+ return;
583
+ if (frame.t === "resize")
584
+ return host.resize(terminal.id, frame.cols, frame.rows);
585
+ const now = Date.now();
586
+ budget = Math.min(INPUT_BURST, budget + ((now - filledAt) / 1000) * INPUT_PER_SECOND);
587
+ filledAt = now;
588
+ const size = Buffer.byteLength(frame.d);
589
+ if (size > budget)
590
+ return shut(1008, "typing faster than a terminal reads");
591
+ budget -= size;
592
+ if (!host.input(terminal.id, frame.d))
593
+ ws.send(JSON.stringify({ t: "input-full" }));
594
+ });
595
+ ws.on("close", () => { closed = true; detach?.(); reprovers.delete(reprove); sockets.delete(ws); });
596
+ ws.on("error", () => shut(1011, "socket error"));
597
+ if (!prove())
598
+ return shut(4401, "signed out");
599
+ try {
600
+ detach = host.attach(terminal.id, viewer);
601
+ }
602
+ catch (error) {
603
+ return shut(error instanceof TerminalError && /open in/.test(error.message) ? 4429 : 4404, "unavailable");
604
+ }
605
+ reprovers.add(reprove);
606
+ record("attach-remote", principal.account, terminal);
607
+ }
454
608
  deps.host?.alsoBuildWritable?.(runtime.consoleProjects);
455
609
  deps.server.on("upgrade", (request, socket, head) => {
456
610
  if (!upgrade(request, socket, head))
@@ -485,3 +639,23 @@ export function createTerminalHandlers(runtime, deps) {
485
639
  },
486
640
  };
487
641
  }
642
+ function takeOverPromptOf(store, family, run) {
643
+ const lines = [`Task: ${family.root.title}`];
644
+ const goal = store.getScope(family.current.id)?.goal?.trim() ?? "";
645
+ if (goal !== "" && goal !== family.root.title.trim())
646
+ lines.push(`Goal: ${goal.slice(0, 400)}`);
647
+ if (run.finishedAt === null) {
648
+ lines.push("Status: background build is still running; you are on an isolated copy of its commit.");
649
+ }
650
+ else if (run.outcome === "failed" || run.outcome === "refused") {
651
+ lines.push(`Last build failed: ${failedAttemptSentence(run.reason)}`);
652
+ const said = agentSaidOf(store, run.id);
653
+ if (said !== null && said.length > 0)
654
+ lines.push(`Last output:\n${said.slice(-4).join("\n")}`);
655
+ }
656
+ else if (run.headRevision !== null) {
657
+ lines.push("Status: inspecting saved build changes on an isolated copy of its commit.");
658
+ }
659
+ lines.push("Help inspect what happened and take it from here.");
660
+ return lines.join("\n").slice(0, 1200);
661
+ }
@@ -69,7 +69,7 @@ export const PROOF_INVENTORY = [
69
69
  { id: "sign-in", action: "Change sign-in (SSO)", routes: ["/settings/sign-in"], form: "signIn", field: "password", proof: "credential", when: "every action except Test", ...CREDENTIAL, role: "operator", secrets: ["client-secret"], terms: [] },
70
70
  { id: "project-flexible", action: "Turn on Flexible", routes: ["/settings/project/flexible"], form: "projectFlexible", field: "password", proof: "credential", when: "only to turn it on (lowering and turning off need nothing)", ...CREDENTIAL, role: "approver", handlerRole: "an approver of the project", secrets: [], terms: ["repo", "action", "digest"], note: "`digest` is the terms the page showed; the handler rebuilds them and refuses a difference" },
71
71
  { id: "release-approval", action: "Approve releases automatically", routes: ["/settings/release-approval"], form: "releaseApproval", field: "password", proof: "credential", when: "only to approve automatically (Ask me needs nothing)", ...CREDENTIAL, role: "approver", handlerRole: "an approver of the project", secrets: [], terms: ["repo"] },
72
- { id: "project-network", action: "Change what builds may reach", routes: ["/settings/project/network"], form: "projectNetwork", field: "password", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver of the project", secrets: [], terms: ["repo"] },
72
+ { id: "project-network", action: "Change what builds may reach", routes: ["/settings/project/network"], form: "projectNetwork", field: "password", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver of the project", secrets: [], terms: ["repo", "request", "digest"], note: "with `request`, an agent's request: `digest` is the terms the page showed; the handler rebuilds them from the setting now and refuses a difference" },
73
73
  { id: "project-fallback", action: "Change a project's fallback agents", routes: ["/settings/project/fallback"], form: "projectFallback", field: "password", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver of the project", secrets: [], terms: [] },
74
74
  { id: "project-writes", action: "Change where builds may write", routes: ["/settings/project/writes"], form: "projectWrites", field: "password", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver of the project", secrets: [], terms: ["repo"] },
75
75
  { id: "project-sandbox", action: "Change a project's sandbox", routes: ["/settings/project/sandbox"], form: "projectSandbox", field: "password", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver of the project", secrets: [], terms: ["repo"] },
@@ -109,11 +109,11 @@ export function spendRows(db, from, to) {
109
109
  rows.push({ ref: `mate_turn:${id}`, at: turn.at, source: "lead", role: "lead", project: turn.project, person: turn.person, subagent: null, taskId: null, runId: null,
110
110
  provider: turn.provider ?? "lead", modelChosen: turn.model, modelReported: null, billing: "api-key", amount, charge: { microusd: held, basis: "estimated" } });
111
111
  }
112
- for (const row of db.prepare(`SELECT t.id, t.at, t.subagent, t.model, t.cost_usd, m.repo FROM subagent_turn t JOIN subagent m ON m.id = t.subagent
112
+ for (const row of db.prepare(`SELECT t.id, t.at, t.subagent, t.model, t.provider, t.model_reported, t.cost_usd, m.repo FROM subagent_turn t JOIN subagent m ON m.id = t.subagent
113
113
  WHERE t.at >= ? AND t.at < ? ORDER BY t.id`).all(from, to)) {
114
114
  const amount = { kind: "unknown" };
115
115
  rows.push({ ref: `subagent_turn:${Number(row["id"])}`, at: String(row["at"]), source: "subagent", role: "subagent", project: text(row["repo"]), person: null,
116
- subagent: Number(row["subagent"]), taskId: null, runId: null, provider: "claude", modelChosen: text(row["model"]), modelReported: null, billing: "unproved",
116
+ subagent: Number(row["subagent"]), taskId: null, runId: null, provider: String(row["provider"]), modelChosen: text(row["model"]), modelReported: text(row["model_reported"]), billing: "unproved",
117
117
  amount, charge: chargeOf(amount, usdMicro(row["cost_usd"]), "estimated") });
118
118
  }
119
119
  for (const row of db.prepare("SELECT id, at, repo, provider, model, cost_usd FROM side_spend WHERE at >= ? AND at < ? ORDER BY id").all(from, to)) {
package/dist/spend.js CHANGED
@@ -221,12 +221,12 @@ export function spendItems(db, from, to, readMode = provider => billingOf(provid
221
221
  taskId: String(row["task"]), runId: Number(row["id"]), authMode: billing,
222
222
  };
223
223
  });
224
- for (const row of !any("subagent") ? [] : db.prepare(`SELECT t.at, t.subagent, t.model, t.cost_usd, t.tokens_in, t.tokens_out, t.billing, m.repo FROM subagent_turn t JOIN subagent m ON m.id = t.subagent
224
+ for (const row of !any("subagent") ? [] : db.prepare(`SELECT t.at, t.subagent, t.model, t.provider, t.cost_usd, t.tokens_in, t.tokens_out, t.billing, m.repo FROM subagent_turn t JOIN subagent m ON m.id = t.subagent
225
225
  WHERE t.at >= ? AND t.at < ? ORDER BY t.id`).all(from, to)) {
226
226
  const billing = row["billing"] === "api-key" ? "api-key" : "subscription";
227
- const priced = priceWork(db, { provider: "claude", model: text(row["model"]), costUsd: count(row["cost_usd"]), tokensIn: count(row["tokens_in"]), tokensOut: count(row["tokens_out"]), billing }, lookup);
227
+ const priced = priceWork(db, { provider: String(row["provider"]), model: text(row["model"]), costUsd: count(row["cost_usd"]), tokensIn: count(row["tokens_in"]), tokensOut: count(row["tokens_out"]), billing }, lookup);
228
228
  items.push({ at: String(row["at"]), kind: "subagent", microusd: priced.microusd, source: priced.source, project: String(row["repo"]), person: null,
229
- subagent: Number(row["subagent"]), provider: "claude", model: text(row["model"]),
229
+ subagent: Number(row["subagent"]), provider: String(row["provider"]), model: text(row["model"]),
230
230
  tokensIn: count(row["tokens_in"]), tokensOut: count(row["tokens_out"]), taskId: null, runId: null, authMode: billing });
231
231
  }
232
232
  for (const row of !any("chat") ? [] : db.prepare(`SELECT created_at AS at, approver, provider, model, settled_microusd, tokens_in, tokens_out, NULL AS project