toolroll 0.9.128 → 0.9.130

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 (129) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/accent-colors.js +3 -1
  3. package/dist/agent-fence.js +0 -2
  4. package/dist/agents-board.js +0 -3
  5. package/dist/approval-authority.js +2 -1
  6. package/dist/assignment.js +56 -2
  7. package/dist/backup-ui.js +6 -3
  8. package/dist/backup.js +6 -0
  9. package/dist/bounded-spawn.js +0 -1
  10. package/dist/browser/manifest.json +57 -0
  11. package/dist/browser/terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js.br +0 -0
  12. package/dist/browser/terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js.gz +0 -0
  13. package/dist/browser/{terminal.css → terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css} +1 -1
  14. package/dist/browser/terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css.br +0 -0
  15. package/dist/browser/terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css.gz +0 -0
  16. package/dist/browser/{workspace.js → workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js} +25 -25
  17. package/dist/browser/workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js.br +0 -0
  18. package/dist/browser/workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js.gz +0 -0
  19. package/dist/browser/{workspace.css → workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css} +1 -1
  20. package/dist/browser/workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css.br +0 -0
  21. package/dist/browser/workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css.gz +0 -0
  22. package/dist/browser-shell.js +271 -25
  23. package/dist/canvas-freshness.js +122 -0
  24. package/dist/canvas-fs.js +273 -0
  25. package/dist/canvas-reads.js +747 -0
  26. package/dist/canvas-state-key.js +45 -0
  27. package/dist/canvas-state-worker.js +12 -0
  28. package/dist/central-recovery-stage.js +3 -3
  29. package/dist/chat-actions.js +26 -0
  30. package/dist/chat-channel.js +4 -3
  31. package/dist/chat-task-actions.js +1 -1
  32. package/dist/chat-warmth.js +0 -1
  33. package/dist/check-report.js +0 -6
  34. package/dist/commit-extract.js +79 -40
  35. package/dist/companion/access.js +162 -0
  36. package/dist/companion/actions.js +622 -0
  37. package/dist/companion/bonjour.js +45 -0
  38. package/dist/companion/canvas.js +141 -0
  39. package/dist/companion/chat-origin.js +92 -0
  40. package/dist/companion/chat.js +571 -0
  41. package/dist/companion/daemon.js +1387 -0
  42. package/dist/companion/direct-server.js +177 -0
  43. package/dist/companion/finish.js +51 -0
  44. package/dist/companion/framing.js +498 -0
  45. package/dist/companion/noise.js +461 -0
  46. package/dist/companion/passkey-gate.js +287 -0
  47. package/dist/companion/paths.js +90 -0
  48. package/dist/companion/reads.js +283 -0
  49. package/dist/companion/relay-auth.js +265 -0
  50. package/dist/companion/relay-server.js +870 -0
  51. package/dist/companion/schema.js +289 -0
  52. package/dist/companion/service.js +581 -0
  53. package/dist/companion/store.js +325 -0
  54. package/dist/companion/webauthn.js +407 -0
  55. package/dist/console-instance.js +0 -4
  56. package/dist/contracts/console-api.js +18 -0
  57. package/dist/converse.js +0 -1
  58. package/dist/coordinator.js +1 -1
  59. package/dist/design/kit.css +30 -0
  60. package/dist/desktop-config.js +156 -0
  61. package/dist/desktop-host.js +6 -152
  62. package/dist/desktop-update.js +1 -1
  63. package/dist/finished-task-sql.js +14 -0
  64. package/dist/flexible-answers.js +0 -1
  65. package/dist/github-read.js +41 -0
  66. package/dist/guides.js +4 -3
  67. package/dist/lead-doors.js +50 -3
  68. package/dist/lead-queue-runtime.js +11 -2
  69. package/dist/lead-queue.js +25 -0
  70. package/dist/live-backup-change.js +93 -0
  71. package/dist/live-backup.js +75 -31
  72. package/dist/live-bus.js +3 -2
  73. package/dist/live-records.js +0 -1
  74. package/dist/local-landing.js +47 -0
  75. package/dist/local-owner.js +0 -1
  76. package/dist/model-choices.js +0 -11
  77. package/dist/nightly-check.js +0 -3
  78. package/dist/nightly-github.js +1 -2
  79. package/dist/notification-retention.js +119 -0
  80. package/dist/observations.js +0 -1
  81. package/dist/operate.js +17 -4
  82. package/dist/person-proof.js +5 -1
  83. package/dist/pull-request-flow.js +116 -2
  84. package/dist/qr.js +360 -0
  85. package/dist/release-adapters.js +14 -43
  86. package/dist/release-auto.js +17 -13
  87. package/dist/release-card.js +0 -4
  88. package/dist/release-cli.js +37 -2
  89. package/dist/release.js +13 -2
  90. package/dist/restore-retirement.js +6 -1
  91. package/dist/result-review.js +0 -3
  92. package/dist/retention-ui.js +1 -1
  93. package/dist/retention.js +14 -21
  94. package/dist/review-context.js +0 -5
  95. package/dist/route-rules.js +1 -5
  96. package/dist/sandbox-runtime.js +0 -1
  97. package/dist/scope.js +68 -17
  98. package/dist/scout.js +0 -6
  99. package/dist/serve.js +60 -9
  100. package/dist/server/kit.js +1 -0
  101. package/dist/server/live.js +9 -2
  102. package/dist/server/pages.js +12 -4
  103. package/dist/server/phone-engine-api.js +79 -0
  104. package/dist/server/render-pages.js +1 -11
  105. package/dist/server/render-results.js +0 -1
  106. package/dist/server/render-tasks.js +0 -68
  107. package/dist/server/route-table.js +12 -1
  108. package/dist/server/settings-phone.js +515 -0
  109. package/dist/server/settings-scripts.js +2 -0
  110. package/dist/server/settings-section-table.js +0 -3
  111. package/dist/server/settings-sections.js +10 -4
  112. package/dist/server/settings.js +20 -5
  113. package/dist/server/terminals.js +2 -1
  114. package/dist/settings-groups-ui.js +2 -1
  115. package/dist/settings-proofs.js +6 -0
  116. package/dist/store.js +52 -4
  117. package/dist/structured-output.js +0 -1
  118. package/dist/style-asset.js +20 -7
  119. package/dist/tailnet.js +39 -0
  120. package/dist/task-control.js +5 -0
  121. package/dist/task-sizing.js +0 -1
  122. package/dist/toolroll-update-cli.js +19 -3
  123. package/dist/toolroll-update-ui.js +2 -2
  124. package/dist/toolroll-update.js +98 -16
  125. package/dist/youiyoux-intake.js +8 -0
  126. package/package.json +7 -2
  127. package/dist/contracts/contract-test.js +0 -55
  128. package/dist/unfenced-test-support.js +0 -6
  129. /package/dist/browser/{terminal.js → terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js} +0 -0
@@ -0,0 +1,177 @@
1
+ import { createServer } from "node:http";
2
+ import { createServer as createTcpServer } from "node:net";
3
+ import { WebSocketServer, WebSocket } from "ws";
4
+ export const DIRECT_MAX_PAYLOAD = 70_000;
5
+ const DEFAULT_LIMITS = { sockets: 32, socketsPerAddress: 8, upgradesPerMinute: 30, connectsPerMinute: 120 };
6
+ const RATE_ENTRIES = 512;
7
+ const HEADER_DEADLINE_MS = 5_000;
8
+ const DIRECT_BACKLOG_LIMIT = 1024 * 1024;
9
+ const ID = /^[A-Za-z0-9_-]{1,64}$/;
10
+ function ipv4Of(address) {
11
+ const m = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(address);
12
+ if (m === null)
13
+ return null;
14
+ const parts = m.slice(1).map(Number);
15
+ return parts.every(p => p <= 255) ? parts : null;
16
+ }
17
+ export function directPeerAllowed(address) {
18
+ if (address === undefined)
19
+ return false;
20
+ const bare = address.replace(/^::ffff:/i, "").toLowerCase();
21
+ const v4 = ipv4Of(bare);
22
+ if (v4 !== null) {
23
+ const [a, b] = v4;
24
+ return a === 127 || a === 10 || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168) || (a === 100 && b >= 64 && b <= 127);
25
+ }
26
+ return bare === "::1";
27
+ }
28
+ export function startDirectServer(opts) {
29
+ const limits = { ...DEFAULT_LIMITS, ...opts.limits };
30
+ const log = opts.log ?? (() => { });
31
+ const addressOf = opts.peerAddressOf ?? ((socket) => socket.remoteAddress);
32
+ const perAddress = new Map();
33
+ const upgrades = new Map();
34
+ const connects = new Map();
35
+ let open = 0;
36
+ let linkSeq = 0;
37
+ const withinRate = (table, address, perMinute) => {
38
+ const now = Date.now();
39
+ const entry = table.get(address);
40
+ if (entry === undefined || now - entry.windowStart >= 60_000) {
41
+ table.delete(address);
42
+ if (table.size >= RATE_ENTRIES)
43
+ table.delete(table.keys().next().value);
44
+ table.set(address, { windowStart: now, count: 1 });
45
+ return true;
46
+ }
47
+ entry.count += 1;
48
+ return entry.count <= perMinute;
49
+ };
50
+ const allowUpgrade = (address) => withinRate(upgrades, address, limits.upgradesPerMinute);
51
+ const handleHttp = (req, res) => {
52
+ let pathname = "";
53
+ try {
54
+ pathname = new URL(req.url ?? "/", "http://direct.invalid").pathname;
55
+ }
56
+ catch { }
57
+ if (req.method === "GET" && pathname === "/v1/health") {
58
+ const body = JSON.stringify({ ok: true, machineId: opts.engine.hostKeys.machineId });
59
+ res.writeHead(200, { "content-type": "application/json", "cache-control": "no-store", "content-length": Buffer.byteLength(body) });
60
+ res.end(body);
61
+ return;
62
+ }
63
+ res.writeHead(404, { "content-type": "application/json" });
64
+ res.end(JSON.stringify({ error: "not_found" }));
65
+ };
66
+ const server = createServer(handleHttp);
67
+ server.headersTimeout = HEADER_DEADLINE_MS;
68
+ server.requestTimeout = 10_000;
69
+ server.keepAliveTimeout = 2_000;
70
+ const wss = new WebSocketServer({ noServer: true, maxPayload: DIRECT_MAX_PAYLOAD });
71
+ const headerDeadlines = new WeakMap();
72
+ const headersDone = (socket) => { const timer = headerDeadlines.get(socket); if (timer !== undefined)
73
+ clearTimeout(timer); headerDeadlines.delete(socket); };
74
+ server.on("request", (req) => headersDone(req.socket));
75
+ const tcp = createTcpServer({ pauseOnConnect: true }, (socket) => {
76
+ const address = addressOf(socket);
77
+ if (!directPeerAllowed(address) || open >= limits.sockets || (perAddress.get(address) ?? 0) >= limits.socketsPerAddress
78
+ || !withinRate(connects, address, limits.connectsPerMinute)) {
79
+ socket.destroy();
80
+ return;
81
+ }
82
+ open += 1;
83
+ perAddress.set(address, (perAddress.get(address) ?? 0) + 1);
84
+ const deadline = setTimeout(() => socket.destroy(), HEADER_DEADLINE_MS);
85
+ deadline.unref?.();
86
+ headerDeadlines.set(socket, deadline);
87
+ socket.once("close", () => {
88
+ headersDone(socket);
89
+ open -= 1;
90
+ const left = (perAddress.get(address) ?? 1) - 1;
91
+ if (left <= 0)
92
+ perAddress.delete(address);
93
+ else
94
+ perAddress.set(address, left);
95
+ });
96
+ server.emit("connection", socket);
97
+ socket.resume();
98
+ });
99
+ const attach = (ws, role, id) => {
100
+ linkSeq += 1;
101
+ const link = {
102
+ id: `direct#${linkSeq}`,
103
+ send: (_connId, payload) => { if (ws.readyState === WebSocket.OPEN)
104
+ ws.send(payload, { binary: true }); },
105
+ close: (_connId, reason, code) => { if (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING)
106
+ ws.close(code ?? 4000, reason.slice(0, 100)); },
107
+ backlog: () => ws.bufferedAmount,
108
+ backlogLimit: DIRECT_BACKLOG_LIMIT,
109
+ };
110
+ let alive = true;
111
+ const liveness = setInterval(() => {
112
+ if (!alive) {
113
+ ws.terminate();
114
+ return;
115
+ }
116
+ alive = false;
117
+ if (ws.readyState === WebSocket.OPEN)
118
+ ws.ping();
119
+ }, 25_000);
120
+ liveness.unref?.();
121
+ ws.on("pong", () => { alive = true; });
122
+ ws.on("message", (raw, isBinary) => {
123
+ if (!isBinary) {
124
+ ws.close(4000, "binary_only");
125
+ return;
126
+ }
127
+ const buf = Buffer.isBuffer(raw) ? raw : Array.isArray(raw) ? Buffer.concat(raw) : Buffer.from(raw);
128
+ opts.engine.peerData(link, 1, buf).catch(error => log(`phone access: direct message failed: ${error instanceof Error ? error.message : String(error)}`));
129
+ });
130
+ ws.on("close", () => {
131
+ clearInterval(liveness);
132
+ opts.engine.handleRelayDisconnected(link);
133
+ });
134
+ ws.on("error", () => { });
135
+ opts.engine.openPeer(link, 1, role, id);
136
+ };
137
+ server.on("upgrade", (req, socket, head) => {
138
+ headersDone(socket);
139
+ try {
140
+ const address = addressOf(socket);
141
+ if (!directPeerAllowed(address) || !allowUpgrade(address)) {
142
+ socket.destroy();
143
+ return;
144
+ }
145
+ const url = new URL(req.url ?? "/", "http://direct.invalid");
146
+ const role = url.searchParams.get("role"), id = url.searchParams.get("id");
147
+ if (url.pathname !== "/v1/direct" || (role !== "pair" && role !== "device") || id === null || !ID.test(id)
148
+ || req.headers.authorization !== undefined || req.headers.origin !== undefined) {
149
+ socket.end("HTTP/1.1 404 Not Found\r\nConnection: close\r\nContent-Length: 0\r\n\r\n");
150
+ return;
151
+ }
152
+ wss.handleUpgrade(req, socket, head, ws => attach(ws, role, id));
153
+ }
154
+ catch {
155
+ socket.destroy();
156
+ }
157
+ });
158
+ server.on("clientError", (_error, socket) => { socket.destroy(); });
159
+ return new Promise((resolve, reject) => {
160
+ tcp.once("error", reject);
161
+ tcp.listen(opts.port, opts.host ?? "0.0.0.0", () => {
162
+ tcp.off("error", reject);
163
+ tcp.on("error", error => log(`phone access: direct listener error: ${error.message}`));
164
+ const bound = tcp.address();
165
+ resolve({
166
+ port: typeof bound === "object" && bound !== null ? bound.port : opts.port,
167
+ close: () => new Promise(done => {
168
+ for (const client of wss.clients)
169
+ client.terminate();
170
+ wss.close();
171
+ server.closeAllConnections();
172
+ tcp.close(() => done());
173
+ }),
174
+ });
175
+ });
176
+ });
177
+ }
@@ -0,0 +1,51 @@
1
+ import { assignmentOf } from "../assignment.js";
2
+ import { broughtInOnBranch, keptHandoffOf, landingBranchOf, landingHistoryOf, landingOf, publishesThroughPullRequests } from "../local-landing.js";
3
+ import { newestPullRequestOf, publishingOf, pullRequestBlocker } from "../pull-request-flow.js";
4
+ export function phoneFinishOf(store, family, viewer, input) {
5
+ const taskId = family.current.id;
6
+ const repo = store.lookupRef(taskId)?.repo ?? null;
7
+ if (repo === null)
8
+ return null;
9
+ const account = store.accountOf(viewer);
10
+ const canAct = account !== null && account.revokedAt === null && account.role === "approver" && store.accountCanAccess(viewer, repo);
11
+ const publishing = publishingOf(store, repo);
12
+ const view = newestPullRequestOf(store, family.versions.map(one => one.id));
13
+ if (view !== null) {
14
+ return { step: "merge", run: view.runId, pr: view.prNumber, url: view.prUrl, state: view.state, label: view.label, detail: view.detail,
15
+ method: view.mergeMethod, base: store.publicationForRun(view.runId)?.base ?? null, canMerge: canAct && view.canMerge && view.prNumber !== null,
16
+ anyway: view.fullCheck === null ? null : view.fullCheck.message, mergeCommit: view.mergeCommit, canAct };
17
+ }
18
+ const assignment = assignmentOf(store, taskId, input.now, input.access, input.evidenceRoot);
19
+ const receipt = assignment?.receipt ?? null;
20
+ if (publishing.on) {
21
+ if (assignment === null || receipt === null || store.publicationForRun(receipt.runId) !== null || pullRequestBlocker(store, receipt.runId) !== null)
22
+ return null;
23
+ const target = `${publishing.githubRepo} into ${publishing.base}`;
24
+ if (assignment.state === "complete")
25
+ return { step: "open-pr", accepted: true, run: receipt.runId, receipt: receipt.digest, target, canAct };
26
+ if (assignment.state === "ready-to-check" && !publishing.legacy && receipt.taskId === taskId) {
27
+ return { step: "open-pr", accepted: false, run: receipt.runId, receipt: receipt.digest, target, canAct };
28
+ }
29
+ return null;
30
+ }
31
+ if (publishesThroughPullRequests(store, repo))
32
+ return null;
33
+ const rootId = family.root.id;
34
+ const record = landingOf(store, rootId);
35
+ const complete = assignment?.state === "complete";
36
+ if (!complete && record === null)
37
+ return null;
38
+ const branch = landingBranchOf(store, repo, null);
39
+ const history = landingHistoryOf(store, repo, rootId, complete ? receipt?.head ?? null : null, input.git);
40
+ if (history !== null && !history.recorded) {
41
+ return { step: "land", branch, landed: history.words, canLand: false, canUndo: canAct && !history.reverted && broughtInOnBranch(store, repo, rootId, input.git), kept: null, canAct };
42
+ }
43
+ const kept = complete && (record === null || record.undone) ? keptHandoffOf(store, repo, rootId, receipt?.head ?? null) : null;
44
+ return {
45
+ step: "land", branch, landed: history?.words ?? null,
46
+ canLand: canAct && complete && (record === null || record.undone) && kept === null,
47
+ canUndo: canAct && record !== null && !record.undone && history?.reverted !== true,
48
+ kept: kept === null ? null : { commit: kept.commit, branch: kept.branch, command: kept.command },
49
+ canAct,
50
+ };
51
+ }