@indigoai-us/hq-cli 5.345.214 → 5.345.215

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 (200) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/assets/scaffold/core/scripts/hq-delegate-verify.sh +5 -2
  3. package/dist/command-catalog.generated.d.ts +180 -13
  4. package/dist/command-catalog.generated.js +221 -13
  5. package/dist/commands/agents.d.ts +51 -1
  6. package/dist/commands/agents.js +154 -2
  7. package/dist/commands/bot-jobs.d.ts +2 -15
  8. package/dist/commands/bot-jobs.js +2 -94
  9. package/dist/commands/bot-runtime.d.ts +46 -5
  10. package/dist/commands/bot-runtime.js +228 -18
  11. package/dist/commands/bot.d.ts +16 -9
  12. package/dist/commands/bot.js +231 -55
  13. package/dist/commands/capacity.d.ts +4 -1
  14. package/dist/commands/capacity.js +46 -10
  15. package/dist/commands/cloud.d.ts +66 -13
  16. package/dist/commands/cloud.js +121 -40
  17. package/dist/commands/company-restore.d.ts +23 -0
  18. package/dist/commands/company-restore.js +128 -0
  19. package/dist/commands/company.js +2 -0
  20. package/dist/commands/core-delegate-w1b.js +15 -1
  21. package/dist/commands/core-policy.js +67 -8
  22. package/dist/commands/daemon.js +5 -0
  23. package/dist/commands/files-browse.d.ts +11 -4
  24. package/dist/commands/files-browse.js +21 -4
  25. package/dist/commands/files.d.ts +1 -1
  26. package/dist/commands/files.js +25 -11
  27. package/dist/commands/integrations-auth-rules.d.ts +27 -0
  28. package/dist/commands/integrations-auth-rules.js +79 -0
  29. package/dist/commands/integrations-connect.d.ts +10 -3
  30. package/dist/commands/integrations-connect.js +87 -13
  31. package/dist/commands/integrations-import.js +124 -12
  32. package/dist/commands/lanes.js +28 -11
  33. package/dist/commands/mesh.d.ts +2 -0
  34. package/dist/commands/mesh.js +60 -35
  35. package/dist/commands/sources.js +6 -0
  36. package/dist/commands/storage-offload.d.ts +12 -0
  37. package/dist/commands/storage-offload.js +41 -3
  38. package/dist/commands/sync-held.js +5 -2
  39. package/dist/commands/sync-mode.js +5 -0
  40. package/dist/commands/whoami.js +4 -0
  41. package/dist/lazy-commands.js +3 -5
  42. package/dist/lib/bot/config.d.ts +1 -0
  43. package/dist/lib/bot/config.js +10 -0
  44. package/dist/lib/bot/eventbridge-cron.d.ts +22 -0
  45. package/dist/lib/bot/eventbridge-cron.js +104 -0
  46. package/dist/lib/bot/fleet-cron.d.ts +8 -0
  47. package/dist/lib/bot/fleet-cron.js +35 -3
  48. package/dist/lib/bot/fleet-daemon.d.ts +46 -0
  49. package/dist/lib/bot/fleet-daemon.js +99 -1
  50. package/dist/lib/bot/fleet-local.d.ts +33 -1
  51. package/dist/lib/bot/fleet-local.js +215 -31
  52. package/dist/lib/bot/fleet-python.d.ts +3 -0
  53. package/dist/lib/bot/fleet-python.js +34 -4
  54. package/dist/lib/bot/fleet-runtime-sources.d.ts +15 -0
  55. package/dist/lib/bot/fleet-runtime-sources.js +30 -0
  56. package/dist/lib/bot/legacy-provider-login.d.ts +8 -0
  57. package/dist/lib/bot/legacy-provider-login.js +19 -2
  58. package/dist/lib/bot/probe.js +7 -1
  59. package/dist/lib/bot/prompt.js +1 -1
  60. package/dist/lib/bot/readiness.d.ts +8 -0
  61. package/dist/lib/bot/readiness.js +17 -3
  62. package/dist/lib/bot/run.js +20 -1
  63. package/dist/lib/bot/runtime/codex.js +1 -1
  64. package/dist/lib/bot/runtime/grok-acp.d.ts +5 -1
  65. package/dist/lib/bot/runtime/grok-acp.js +6 -3
  66. package/dist/lib/bot/runtime/index.js +19 -9
  67. package/dist/lib/bot/runtime/messages-stream.js +2 -2
  68. package/dist/lib/bot/runtime/types.d.ts +15 -0
  69. package/dist/lib/bot/runtime/types.js +9 -0
  70. package/dist/lib/bot/runtime-auth.d.ts +30 -0
  71. package/dist/lib/bot/runtime-auth.js +94 -3
  72. package/dist/lib/bot/runtime-failure.d.ts +23 -0
  73. package/dist/lib/bot/runtime-failure.js +43 -1
  74. package/dist/lib/bot/status.d.ts +2 -0
  75. package/dist/lib/capacity/accounts.d.ts +8 -0
  76. package/dist/lib/capacity/accounts.js +19 -0
  77. package/dist/lib/capacity/available.d.ts +154 -0
  78. package/dist/lib/capacity/available.js +905 -0
  79. package/dist/lib/capacity/codex-availability.d.ts +14 -1
  80. package/dist/lib/capacity/codex-availability.js +26 -1
  81. package/dist/lib/capacity/collectors/claude-oauth.d.ts +29 -2
  82. package/dist/lib/capacity/collectors/claude-oauth.js +104 -7
  83. package/dist/lib/capacity/collectors/codex.js +10 -7
  84. package/dist/lib/capacity/collectors/grok-refresh.d.ts +80 -0
  85. package/dist/lib/capacity/collectors/grok-refresh.js +189 -0
  86. package/dist/lib/capacity/collectors/grok.d.ts +5 -0
  87. package/dist/lib/capacity/collectors/grok.js +56 -5
  88. package/dist/lib/capacity/ledger.d.ts +37 -1
  89. package/dist/lib/capacity/ledger.js +207 -30
  90. package/dist/lib/capacity/project.d.ts +26 -0
  91. package/dist/lib/capacity/project.js +137 -8
  92. package/dist/lib/capacity/refusal-rows.d.ts +31 -0
  93. package/dist/lib/capacity/refusal-rows.js +61 -0
  94. package/dist/lib/capacity/refusal.d.ts +53 -2
  95. package/dist/lib/capacity/refusal.js +284 -65
  96. package/dist/lib/capacity/route.js +46 -11
  97. package/dist/lib/capacity/widget.d.ts +12 -1
  98. package/dist/lib/capacity/widget.js +91 -3
  99. package/dist/lib/daemon/catalog.js +11 -1
  100. package/dist/lib/daemon/resolver.d.ts +2 -0
  101. package/dist/lib/daemon/resolver.js +3 -0
  102. package/dist/lib/daemon/run.d.ts +9 -0
  103. package/dist/lib/daemon/run.js +54 -1
  104. package/dist/lib/daemon/server.d.ts +2 -0
  105. package/dist/lib/daemon/server.js +10 -1
  106. package/dist/lib/daemon/tcc-eperm.d.ts +153 -0
  107. package/dist/lib/daemon/tcc-eperm.js +310 -0
  108. package/dist/lib/db/sqlite-binding.d.ts +1 -0
  109. package/dist/lib/db/sqlite-binding.js +1 -1
  110. package/dist/lib/delivery/admission.d.ts +86 -0
  111. package/dist/lib/delivery/admission.js +148 -0
  112. package/dist/lib/delivery/artifacts.d.ts +105 -0
  113. package/dist/lib/delivery/artifacts.js +567 -0
  114. package/dist/lib/delivery/attempt-id.d.ts +13 -0
  115. package/dist/lib/delivery/attempt-id.js +16 -0
  116. package/dist/lib/delivery/backup.d.ts +78 -0
  117. package/dist/lib/delivery/backup.js +343 -0
  118. package/dist/lib/delivery/cache.d.ts +29 -0
  119. package/dist/lib/delivery/cache.js +33 -0
  120. package/dist/lib/delivery/contracts.d.ts +142 -0
  121. package/dist/lib/delivery/contracts.js +289 -0
  122. package/dist/lib/delivery/credentials.d.ts +54 -0
  123. package/dist/lib/delivery/credentials.js +119 -0
  124. package/dist/lib/delivery/disposable-target.d.ts +42 -0
  125. package/dist/lib/delivery/disposable-target.js +111 -0
  126. package/dist/lib/delivery/effects.d.ts +136 -0
  127. package/dist/lib/delivery/effects.js +541 -0
  128. package/dist/lib/delivery/enrollment.d.ts +146 -0
  129. package/dist/lib/delivery/enrollment.js +460 -0
  130. package/dist/lib/delivery/escalations.d.ts +51 -0
  131. package/dist/lib/delivery/escalations.js +60 -0
  132. package/dist/lib/delivery/identity.d.ts +25 -0
  133. package/dist/lib/delivery/identity.js +82 -0
  134. package/dist/lib/delivery/inbox.d.ts +116 -0
  135. package/dist/lib/delivery/inbox.js +260 -0
  136. package/dist/lib/delivery/lease.d.ts +80 -0
  137. package/dist/lib/delivery/lease.js +134 -0
  138. package/dist/lib/delivery/migrations.d.ts +255 -0
  139. package/dist/lib/delivery/migrations.js +823 -0
  140. package/dist/lib/delivery/mqtt-adapter.d.ts +50 -0
  141. package/dist/lib/delivery/mqtt-adapter.js +242 -0
  142. package/dist/lib/delivery/mqtt.d.ts +63 -0
  143. package/dist/lib/delivery/mqtt.js +119 -0
  144. package/dist/lib/delivery/outbox.d.ts +95 -0
  145. package/dist/lib/delivery/outbox.js +187 -0
  146. package/dist/lib/delivery/provenance.d.ts +129 -0
  147. package/dist/lib/delivery/provenance.js +93 -0
  148. package/dist/lib/delivery/reconciler.d.ts +215 -0
  149. package/dist/lib/delivery/reconciler.js +703 -0
  150. package/dist/lib/delivery/restore.d.ts +35 -0
  151. package/dist/lib/delivery/restore.js +134 -0
  152. package/dist/lib/delivery/rpc/client.d.ts +22 -0
  153. package/dist/lib/delivery/rpc/client.js +159 -0
  154. package/dist/lib/delivery/rpc/port.d.ts +40 -0
  155. package/dist/lib/delivery/rpc/port.js +16 -0
  156. package/dist/lib/delivery/rpc/server.d.ts +30 -0
  157. package/dist/lib/delivery/rpc/server.js +205 -0
  158. package/dist/lib/delivery/rpc/wire.d.ts +85 -0
  159. package/dist/lib/delivery/rpc/wire.js +143 -0
  160. package/dist/lib/delivery/store.d.ts +163 -0
  161. package/dist/lib/delivery/store.js +944 -0
  162. package/dist/lib/delivery/windows-service-install.d.ts +262 -0
  163. package/dist/lib/delivery/windows-service-install.js +892 -0
  164. package/dist/lib/delivery/workers/macos-job-helper.d.ts +103 -0
  165. package/dist/lib/delivery/workers/macos-job-helper.js +927 -0
  166. package/dist/lib/delivery/workers/macos.d.ts +191 -0
  167. package/dist/lib/delivery/workers/macos.js +943 -0
  168. package/dist/lib/delivery/workers/windows-job-helper.d.ts +35 -0
  169. package/dist/lib/delivery/workers/windows-job-helper.js +264 -0
  170. package/dist/lib/delivery/workers/windows-service-live.d.ts +121 -0
  171. package/dist/lib/delivery/workers/windows-service-live.js +711 -0
  172. package/dist/lib/delivery/workers/windows-service-runner.d.ts +33 -0
  173. package/dist/lib/delivery/workers/windows-service-runner.js +82 -0
  174. package/dist/lib/delivery/workers/windows-service.d.ts +140 -0
  175. package/dist/lib/delivery/workers/windows-service.js +584 -0
  176. package/dist/lib/delivery/workers/windows.d.ts +251 -0
  177. package/dist/lib/delivery/workers/windows.js +594 -0
  178. package/dist/lib/hot-channels/adapters/meetings.d.ts +15 -0
  179. package/dist/lib/hot-channels/adapters/meetings.js +36 -3
  180. package/dist/lib/hot-channels/signals-pass.d.ts +10 -0
  181. package/dist/lib/hot-channels/signals-pass.js +71 -2
  182. package/dist/lib/hot-channels/signals-redo.js +10 -2
  183. package/dist/lib/install/provider-wrappers.d.ts +2 -0
  184. package/dist/lib/install/provider-wrappers.js +68 -3
  185. package/dist/lib/lanes/watcher.js +35 -0
  186. package/dist/lib/signals/steps/extract.js +40 -4
  187. package/dist/schemas/hq-available-ai.v1.schema.json +76 -0
  188. package/dist/utils/catalog-runtime-paths.d.ts +34 -0
  189. package/dist/utils/catalog-runtime-paths.js +53 -0
  190. package/dist/utils/cognito-callback-port.d.ts +14 -0
  191. package/dist/utils/cognito-callback-port.js +24 -0
  192. package/dist/utils/cognito-session.js +3 -3
  193. package/dist/utils/deleted-company-notice.d.ts +59 -0
  194. package/dist/utils/deleted-company-notice.js +156 -0
  195. package/dist/utils/files-browse-acl.js +1 -1
  196. package/dist/utils/login-browser.d.ts +1 -1
  197. package/dist/utils/login-browser.js +7 -5
  198. package/dist/utils/resident-package-preload.js +30 -15
  199. package/dist/utils/vault-api.js +7 -0
  200. package/package.json +7 -7
@@ -0,0 +1,594 @@
1
+ /**
2
+ * Run and contain jobs on a Windows worker (US-006).
3
+ *
4
+ * A job arrives as an ExecutionSpec: the command, the content-addressed
5
+ * inputs it may read, the exact environment it gets, the platform, toolchains
6
+ * and capabilities it needs, and its resource limits. WindowsWorker.start
7
+ * checks all of that before it claims the job or starts any process:
8
+ * 1. the spec is well formed (INVALID_SPEC),
9
+ * 2. the run and job exist for the spec's tenant (UNKNOWN_JOB, store codes),
10
+ * 3. the worker profile matches the requirements (PLATFORM_MISMATCH,
11
+ * TOOLCHAIN_MISMATCH, UNKNOWN_CAPABILITY, CAPABILITY_MISSING),
12
+ * 4. every input is admitted and unchanged (INPUT_MISSING, INPUT_CHANGED),
13
+ * 5. the launcher can contain the job (CONTAINMENT_UNAVAILABLE).
14
+ * A refusal claims nothing, so the job stays ready for a matching worker, and
15
+ * is recorded as exactly one terminal result.
16
+ *
17
+ * After the claim the inputs are copied read-only into a fresh attempt
18
+ * directory and the command runs there with only the declared environment.
19
+ * The terminal outcome is reported to the ledger through the access layer
20
+ * (passed or failed) and appended once to the result log. Nothing in the
21
+ * store is deleted. Results hold environment keys only, never values.
22
+ *
23
+ * Containment on Windows is the proposal 040 service host: the launcher in
24
+ * windows-service.ts submits to the runner over the spool and fails closed
25
+ * when the runner is not live. This module has no compile and no spawn path
26
+ * of its own, and imports only node built-ins at runtime.
27
+ */
28
+ import { execFileSync } from "node:child_process";
29
+ import { createHash, randomBytes } from "node:crypto";
30
+ import { chmodSync, closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, writeFileSync, writeSync } from "node:fs";
31
+ import { isAbsolute, join } from "node:path";
32
+ export const EXECUTION_SPEC_VERSION = "hq-delivery.execution.v1";
33
+ export const WORKER_RESULT_VERSION = "hq-delivery.worker-result.v1";
34
+ /**
35
+ * Owner decision 2026-10-28 ("Mark Windows untrusted"). Why Windows results
36
+ * are untrusted, as advertised in the profile and the docs.
37
+ */
38
+ export const WINDOWS_TRUST_NOTE = "Windows results are not trusted against a hostile job: under proposal 040 the job runs as the shared runner identity (the service's virtual account), so a job can write its own or another job's events and results. Workers are capped at standard trust and their results are never release-eligible. Closing this needs a separate job account (future work).";
39
+ /** The highest trust a Windows worker may hold. */
40
+ export const WINDOWS_MAX_TRUST = "standard";
41
+ function trustCapped(asked) {
42
+ return new WorkerRefusal("WINDOWS_TRUST_CAPPED", `a Windows worker may not hold ${asked} trust; it is capped at ${WINDOWS_MAX_TRUST} because jobs share the runner identity (shared runner identity). ${WINDOWS_TRUST_NOTE}`);
43
+ }
44
+ /** Issue an enrollment ticket for a Windows worker. Release trust is refused with WINDOWS_TRUST_CAPPED; nothing is issued. */
45
+ export function issueWindowsEnrollment(access, scope, request) {
46
+ if (request?.trust !== WINDOWS_MAX_TRUST)
47
+ throw trustCapped(String(request?.trust));
48
+ return access.issueEnrollment(scope, request);
49
+ }
50
+ /** Redeem a Windows enrollment. Release trust is refused with WINDOWS_TRUST_CAPPED, whatever the ticket allows. */
51
+ export function enrollWindowsWorker(access, input) {
52
+ if (input?.trust !== WINDOWS_MAX_TRUST)
53
+ throw trustCapped(String(input?.trust));
54
+ return access.enroll(input);
55
+ }
56
+ /**
57
+ * The promotion gate for Windows results. Every Windows result is untrusted,
58
+ * so this always refuses with WINDOWS_RESULT_UNTRUSTED. Merge point: US-008's
59
+ * shared release-eligibility check (assertJobTrust on the integration branch)
60
+ * should call this for Windows results; this base does not have it.
61
+ */
62
+ export function assertReleaseEligible(result) {
63
+ throw new WorkerRefusal("WINDOWS_RESULT_UNTRUSTED", `result for job ${result.jobId} (${result.kind}) came from a Windows worker and is ${result.resultTrust ?? "untrusted"}; it cannot be promoted. ${WINDOWS_TRUST_NOTE}`);
64
+ }
65
+ /** What the native launcher contains. A job may require any of these. */
66
+ export const CONTAINMENT_CAPABILITIES = ["job-object-containment", "process-tree-kill", "memory-limit", "process-limit", "cpu-time-limit"];
67
+ export const KNOWN_CAPABILITIES = [...CONTAINMENT_CAPABILITIES, "posix-signals", "git"];
68
+ // ---------------------------------------------------------------------------
69
+ // Worker profile
70
+ let gitVersion;
71
+ function detectGit() {
72
+ if (gitVersion !== undefined)
73
+ return gitVersion;
74
+ try {
75
+ const out = execFileSync("git", ["--version"], { encoding: "utf8", timeout: 10_000, stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
76
+ gitVersion = /(\d+\.\d+\.\d+)/.exec(out)?.[1] ?? null;
77
+ }
78
+ catch {
79
+ gitVersion = null;
80
+ }
81
+ return gitVersion;
82
+ }
83
+ let cachedProfile;
84
+ /** The profile of the host this process runs on. */
85
+ export function detectProfile() {
86
+ if (cachedProfile)
87
+ return cachedProfile;
88
+ const platform = process.platform === "win32" ? "windows" : process.platform === "darwin" ? "macos" : process.platform === "linux" ? "linux" : process.platform;
89
+ const toolchains = { node: process.versions.node };
90
+ const git = detectGit();
91
+ if (git)
92
+ toolchains.git = git;
93
+ const capabilities = platform === "windows" ? [...CONTAINMENT_CAPABILITIES] : ["posix-signals"];
94
+ if (git)
95
+ capabilities.push("git");
96
+ cachedProfile = { platform, arch: process.arch, toolchains, capabilities };
97
+ if (platform === "windows")
98
+ cachedProfile.resultTrust = "untrusted";
99
+ return cachedProfile;
100
+ }
101
+ const COMPARATOR = /^(>=|<=|>|<|=|\^|~)?v?(\d+|[xX*])(?:\.(\d+|[xX*]))?(?:\.(\d+|[xX*]))?(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
102
+ function cmp(a, b) {
103
+ return a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
104
+ }
105
+ function parseVersion(text) {
106
+ const m = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/.exec(text.trim());
107
+ return m ? [Number(m[1]), Number(m[2] ?? 0), Number(m[3] ?? 0)] : null;
108
+ }
109
+ /** One comparator as lower and upper bounds. null means invalid; [] means any. */
110
+ function comparatorBounds(token) {
111
+ if (token === "*" || token.toLowerCase() === "x")
112
+ return [];
113
+ const m = COMPARATOR.exec(token);
114
+ if (!m)
115
+ return null;
116
+ const op = m[1] ?? "";
117
+ const raw = [m[2], m[3], m[4]];
118
+ const parts = [];
119
+ for (const p of raw) {
120
+ if (p === undefined || /^[xX*]$/.test(p))
121
+ break;
122
+ parts.push(Number(p));
123
+ }
124
+ if (parts.length === 0)
125
+ return [];
126
+ const full = parts.length === 3;
127
+ const [M, m1 = 0, p1 = 0] = parts;
128
+ const lo = [M, m1, p1];
129
+ const next = parts.length === 1 ? [M + 1, 0, 0] : parts.length === 2 ? [M, m1 + 1, 0] : [M, m1, p1 + 1];
130
+ switch (op) {
131
+ case "":
132
+ case "=":
133
+ return full ? [{ op: "=", v: lo }] : [{ op: ">=", v: lo }, { op: "<", v: next }];
134
+ case ">=":
135
+ return [{ op: ">=", v: lo }];
136
+ case ">":
137
+ return full ? [{ op: ">", v: lo }] : [{ op: ">=", v: next }];
138
+ case "<":
139
+ return [{ op: "<", v: lo }];
140
+ case "<=":
141
+ return full ? [{ op: "<=", v: lo }] : [{ op: "<", v: next }];
142
+ case "~":
143
+ return [{ op: ">=", v: lo }, { op: "<", v: parts.length === 1 ? [M + 1, 0, 0] : [M, m1 + 1, 0] }];
144
+ case "^": {
145
+ let hi;
146
+ if (M > 0 || parts.length === 1)
147
+ hi = [M + 1, 0, 0];
148
+ else if (m1 > 0 || parts.length === 2)
149
+ hi = [0, m1 + 1, 0];
150
+ else
151
+ hi = [0, 0, p1 + 1];
152
+ return [{ op: ">=", v: lo }, { op: "<", v: hi }];
153
+ }
154
+ default:
155
+ return null;
156
+ }
157
+ }
158
+ /** A range as alternatives of bound sets, or null when it does not parse. */
159
+ function parseRange(range) {
160
+ const alternatives = range.split("||").map((s) => s.trim().replace(/(>=|<=|>|<|=|\^|~)\s+/g, "$1"));
161
+ const out = [];
162
+ for (const alt of alternatives) {
163
+ const bounds = [];
164
+ for (const token of alt === "" ? [] : alt.split(/\s+/)) {
165
+ const b = comparatorBounds(token);
166
+ if (!b)
167
+ return null;
168
+ bounds.push(...b);
169
+ }
170
+ out.push(bounds);
171
+ }
172
+ return out;
173
+ }
174
+ function satisfies(version, range) {
175
+ const v = parseVersion(version);
176
+ const alts = parseRange(range);
177
+ if (!v || !alts)
178
+ return false;
179
+ return alts.some((bounds) => bounds.every(({ op, v: b }) => {
180
+ const c = cmp(v, b);
181
+ return op === ">=" ? c >= 0 : op === ">" ? c > 0 : op === "<" ? c < 0 : op === "<=" ? c <= 0 : c === 0;
182
+ }));
183
+ }
184
+ // ---------------------------------------------------------------------------
185
+ // Matching and validation
186
+ /** Check a worker profile against a job's requirements. Platform first, then toolchains, then capabilities. */
187
+ export function matchCapabilities(profile, req) {
188
+ if (!req.platforms.includes(profile.platform)) {
189
+ return { ok: false, code: "PLATFORM_MISMATCH", detail: `job runs on ${req.platforms.join(", ")}; worker is ${profile.platform}` };
190
+ }
191
+ for (const [name, range] of Object.entries(req.toolchains ?? {})) {
192
+ const installed = profile.toolchains[name];
193
+ if (installed === undefined)
194
+ return { ok: false, code: "TOOLCHAIN_MISMATCH", detail: `job needs ${name} ${range}; worker has no ${name}` };
195
+ if (!satisfies(installed, range))
196
+ return { ok: false, code: "TOOLCHAIN_MISMATCH", detail: `job needs ${name} ${range}; worker has ${name} ${installed}` };
197
+ }
198
+ const caps = req.capabilities ?? [];
199
+ const unknown = caps.filter((c) => !KNOWN_CAPABILITIES.includes(c));
200
+ if (unknown.length > 0)
201
+ return { ok: false, code: "UNKNOWN_CAPABILITY", detail: `unknown capability ${unknown.join(", ")}` };
202
+ const missing = caps.filter((c) => !profile.capabilities.includes(c));
203
+ if (missing.length > 0)
204
+ return { ok: false, code: "CAPABILITY_MISSING", detail: `worker lacks ${missing.join(", ")}` };
205
+ return { ok: true };
206
+ }
207
+ const INPUT_NAME = /^[A-Za-z0-9._-]+$/;
208
+ const SHA256 = /^[0-9a-f]{64}$/;
209
+ function isRecord(x) {
210
+ return typeof x === "object" && x !== null && !Array.isArray(x);
211
+ }
212
+ function isStringArray(x) {
213
+ return Array.isArray(x) && x.every((s) => typeof s === "string");
214
+ }
215
+ function positiveInt(x) {
216
+ return typeof x === "number" && Number.isSafeInteger(x) && x > 0;
217
+ }
218
+ /** The first problem with a spec, or null when it is well formed. */
219
+ export function validateSpec(spec) {
220
+ const s = spec;
221
+ if (!isRecord(s))
222
+ return "spec is not an object";
223
+ if (s.schemaVersion !== EXECUTION_SPEC_VERSION)
224
+ return `schemaVersion must be ${EXECUTION_SPEC_VERSION}`;
225
+ for (const k of ["tenantId", "runId", "jobId"]) {
226
+ if (typeof s[k] !== "string" || s[k] === "")
227
+ return `${k} must be a non-empty string`;
228
+ }
229
+ const req = s.requires;
230
+ if (!isRecord(req))
231
+ return "requires must be an object";
232
+ if (!isStringArray(req.platforms) || req.platforms.length === 0)
233
+ return "requires.platforms must be a non-empty list of strings";
234
+ if (req.toolchains !== undefined) {
235
+ if (!isRecord(req.toolchains))
236
+ return "requires.toolchains must be an object";
237
+ for (const [name, range] of Object.entries(req.toolchains)) {
238
+ if (typeof range !== "string" || parseRange(range) === null)
239
+ return `requires.toolchains.${name} is not a valid version range`;
240
+ }
241
+ }
242
+ if (req.capabilities !== undefined && !isStringArray(req.capabilities))
243
+ return "requires.capabilities must be a list of strings";
244
+ const cmd = s.command;
245
+ if (!isRecord(cmd) || typeof cmd.file !== "string" || !isAbsolute(cmd.file) || cmd.file.includes("\0"))
246
+ return "command.file must be an absolute path";
247
+ if (!isStringArray(cmd.args) || cmd.args.some((a) => a.includes("\0")))
248
+ return "command.args must be a list of strings without NUL";
249
+ if (!Array.isArray(s.inputs))
250
+ return "inputs must be a list";
251
+ const names = new Set();
252
+ for (const i of s.inputs) {
253
+ if (!isRecord(i) || typeof i.name !== "string" || typeof i.sha256 !== "string")
254
+ return "each input needs a name and a sha256";
255
+ if (!INPUT_NAME.test(i.name) || i.name === "." || i.name === "..")
256
+ return `input name ${i.name} is not a plain file name`;
257
+ if (names.has(i.name))
258
+ return `input name ${i.name} is repeated`;
259
+ if (!SHA256.test(i.sha256))
260
+ return `input ${i.name} sha256 must be 64 lowercase hex characters`;
261
+ names.add(i.name);
262
+ }
263
+ if (!isRecord(s.env))
264
+ return "env must be an object";
265
+ for (const [k, v] of Object.entries(s.env)) {
266
+ if (k === "" || k.includes("=") || k.includes("\0"))
267
+ return "env keys must be non-empty and contain no = or NUL";
268
+ if (typeof v !== "string" || v.includes("\0"))
269
+ return `env ${k} must be a string without NUL`;
270
+ }
271
+ const lim = s.limits;
272
+ if (!isRecord(lim) || !positiveInt(lim.memoryBytes) || !positiveInt(lim.maxProcesses) || !positiveInt(lim.cpuTimeMs)) {
273
+ return "limits.memoryBytes, limits.maxProcesses and limits.cpuTimeMs must be positive integers";
274
+ }
275
+ return null;
276
+ }
277
+ // ---------------------------------------------------------------------------
278
+ // Immutable inputs
279
+ function sha256(bytes) {
280
+ return createHash("sha256").update(bytes).digest("hex");
281
+ }
282
+ /**
283
+ * Content-addressed input blobs. An admitted input is stored under its hash,
284
+ * read-only; a job names the hash, and the bytes are checked again before the
285
+ * claim and when they are copied into the attempt.
286
+ */
287
+ export class InputStore {
288
+ dir;
289
+ constructor(dir) {
290
+ this.dir = dir;
291
+ }
292
+ static open(dir) {
293
+ mkdirSync(join(dir, "blobs"), { recursive: true });
294
+ return new InputStore(dir);
295
+ }
296
+ admit(name, path) {
297
+ if (!INPUT_NAME.test(name) || name === "." || name === "..")
298
+ throw new Error(`input name ${name} is not a plain file name`);
299
+ const bytes = readFileSync(path);
300
+ const hash = sha256(bytes);
301
+ const dest = this.blobPath(hash);
302
+ if (!existsSync(dest)) {
303
+ const tmp = `${dest}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
304
+ writeFileSync(tmp, bytes);
305
+ chmodSync(tmp, 0o444);
306
+ renameSync(tmp, dest);
307
+ }
308
+ return { name, sha256: hash };
309
+ }
310
+ blobPath(hash) {
311
+ return join(this.dir, "blobs", hash);
312
+ }
313
+ /** null when the blob is present and unchanged. */
314
+ verify(ref) {
315
+ const path = this.blobPath(ref.sha256);
316
+ if (!existsSync(path))
317
+ return "INPUT_MISSING";
318
+ return sha256(readFileSync(path)) === ref.sha256 ? null : "INPUT_CHANGED";
319
+ }
320
+ /** Copy a verified blob to destDir/name, read-only. */
321
+ materialize(ref, destDir) {
322
+ const path = this.blobPath(ref.sha256);
323
+ if (!existsSync(path))
324
+ throw new WorkerRefusal("INPUT_MISSING", `input ${ref.name} is not admitted`);
325
+ const bytes = readFileSync(path);
326
+ if (sha256(bytes) !== ref.sha256)
327
+ throw new WorkerRefusal("INPUT_CHANGED", `input ${ref.name} changed after admission`);
328
+ const dest = join(destDir, ref.name);
329
+ writeFileSync(dest, bytes);
330
+ chmodSync(dest, 0o444);
331
+ return dest;
332
+ }
333
+ }
334
+ /** Append-only JSON lines of terminal results. One result per attempt. */
335
+ export class ResultLog {
336
+ path;
337
+ lines;
338
+ constructor(path) {
339
+ this.path = path;
340
+ this.lines = existsSync(path)
341
+ ? readFileSync(path, "utf8")
342
+ .split("\n")
343
+ .filter((l) => l.trim() !== "")
344
+ .map((l) => JSON.parse(l))
345
+ : [];
346
+ }
347
+ static open(path) {
348
+ return new ResultLog(path);
349
+ }
350
+ /** Append a result. A second result for the same attempt is not written; the first is returned. */
351
+ append(result) {
352
+ if (result.attemptId !== null) {
353
+ const existing = this.lines.find((r) => r.attemptId === result.attemptId);
354
+ if (existing)
355
+ return existing;
356
+ }
357
+ const line = JSON.stringify(result);
358
+ const fd = openSync(this.path, "a");
359
+ try {
360
+ writeSync(fd, line + "\n");
361
+ fsyncSync(fd);
362
+ }
363
+ finally {
364
+ closeSync(fd);
365
+ }
366
+ const copy = JSON.parse(line);
367
+ this.lines.push(copy);
368
+ return copy;
369
+ }
370
+ all() {
371
+ return this.lines.map((r) => ({ ...r, envKeys: [...r.envKeys] }));
372
+ }
373
+ forJob(jobId) {
374
+ return this.all().filter((r) => r.jobId === jobId);
375
+ }
376
+ }
377
+ export class WorkerRefusal extends Error {
378
+ code;
379
+ detail;
380
+ constructor(code, detail) {
381
+ super(`${code}: ${detail}`);
382
+ this.code = code;
383
+ this.detail = detail;
384
+ this.name = "WorkerRefusal";
385
+ }
386
+ }
387
+ /** Quote one argument for a Windows command line, following the CommandLineToArgvW rules. */
388
+ export function quoteWindowsArg(arg) {
389
+ if (arg !== "" && !/[\s"]/.test(arg))
390
+ return arg;
391
+ let out = '"';
392
+ let slashes = 0;
393
+ for (const ch of arg) {
394
+ if (ch === "\\") {
395
+ slashes += 1;
396
+ continue;
397
+ }
398
+ out += ch === '"' ? "\\".repeat(slashes * 2 + 1) + '"' : "\\".repeat(slashes) + ch;
399
+ slashes = 0;
400
+ }
401
+ return out + "\\".repeat(slashes * 2) + '"';
402
+ }
403
+ const LIMIT_REASONS = { memory_limit: "memory", process_limit: "processes", cpu_limit: "cpu" };
404
+ /**
405
+ * Map what the job helper reported to a launch outcome. An error line before
406
+ * any "started" line (for example "error resume <code>", sent after the helper
407
+ * has terminated the job) is a spawn failure.
408
+ */
409
+ export function helperOutcome(h) {
410
+ if (h.exitLine) {
411
+ const [, why, rawCode] = h.exitLine.split(" ");
412
+ const exitCode = Number(rawCode);
413
+ if (why === "exited")
414
+ return { reason: "exited", exitCode };
415
+ if (why === "cancelled")
416
+ return { reason: "cancelled", exitCode };
417
+ if (LIMIT_REASONS[why])
418
+ return { reason: "limit", limit: LIMIT_REASONS[why], exitCode };
419
+ return { reason: "supervisor_lost", detail: `job helper reported ${h.exitLine}` };
420
+ }
421
+ if (h.rootPid < 0) {
422
+ return { reason: "spawn_failed", detail: h.errorLine ?? h.spawnError ?? `job helper exited ${h.code} before starting the job${h.stderr ? `: ${h.stderr.trim().split("\n")[0]}` : ""}` };
423
+ }
424
+ return { reason: "supervisor_lost", detail: `job helper exited ${h.code} without a result` };
425
+ }
426
+ /** A store error carries a string code; checked by shape so no runtime import is needed. */
427
+ function storeCode(err) {
428
+ const code = err?.code;
429
+ return err instanceof Error && typeof code === "string" ? code : null;
430
+ }
431
+ function message(err) {
432
+ return (err instanceof Error ? err.message : String(err)).split("\n")[0];
433
+ }
434
+ export class WindowsWorker {
435
+ opts;
436
+ clock;
437
+ constructor(opts) {
438
+ this.opts = opts;
439
+ this.clock = opts.clock ?? (() => new Date());
440
+ }
441
+ now() {
442
+ return this.clock().toISOString();
443
+ }
444
+ result(spec, fields) {
445
+ const env = isRecord(spec?.env) ? spec.env : {};
446
+ return {
447
+ schemaVersion: WORKER_RESULT_VERSION,
448
+ tenantId: String(spec?.tenantId ?? ""),
449
+ runId: String(spec?.runId ?? ""),
450
+ jobId: String(spec?.jobId ?? ""),
451
+ attemptId: null,
452
+ pid: null,
453
+ exitCode: null,
454
+ envKeys: Object.keys(env).sort(),
455
+ startedAt: null,
456
+ finishedAt: this.now(),
457
+ ...fields,
458
+ resultTrust: "untrusted",
459
+ releaseEligible: false,
460
+ };
461
+ }
462
+ refuse(spec, code, detail) {
463
+ const result = this.result(spec, { kind: "refused", code, detail });
464
+ try {
465
+ return { kind: "refused", result: this.opts.results.append(result) };
466
+ }
467
+ catch (err) {
468
+ return { kind: "refused", result: { ...result, detail: `${detail}; result not recorded: ${storeCode(err) ?? message(err)}` } };
469
+ }
470
+ }
471
+ /** Report the ledger outcome, then append the one terminal result. A ledger or result-log failure is reported, never thrown. */
472
+ finish(result) {
473
+ let detail = result.detail;
474
+ if (result.attemptId !== null) {
475
+ try {
476
+ this.opts.access.recordOutcome(this.opts.identity, result.attemptId, result.kind === "succeeded" ? "passed" : "failed");
477
+ }
478
+ catch (err) {
479
+ detail += `; ledger outcome not recorded: ${storeCode(err) ?? message(err)}`;
480
+ }
481
+ }
482
+ try {
483
+ return this.opts.results.append({ ...result, detail });
484
+ }
485
+ catch (err) {
486
+ // The job ran, but its one terminal result could not be written. Report
487
+ // that as the outcome rather than reject the result promise.
488
+ return { ...result, kind: "failed", code: "RESULT_NOT_RECORDED", detail: `${result.kind} ${result.code}: ${detail}; result not recorded: ${storeCode(err) ?? message(err)}` };
489
+ }
490
+ }
491
+ async start(spec) {
492
+ const invalid = validateSpec(spec);
493
+ if (invalid)
494
+ return this.refuse(spec, "INVALID_SPEC", invalid);
495
+ // Owner decision 2026-10-28: a Windows worker never runs with release trust.
496
+ try {
497
+ const trust = this.opts.access.workerTrust(this.opts.identity);
498
+ if (trust !== WINDOWS_MAX_TRUST) {
499
+ const e = trustCapped(trust);
500
+ return this.refuse(spec, e.code, e.detail);
501
+ }
502
+ }
503
+ catch (err) {
504
+ return this.refuse(spec, storeCode(err) ?? "UNKNOWN_JOB", message(err));
505
+ }
506
+ try {
507
+ const { run, jobs } = this.opts.access.readRun(this.opts.identity, spec.runId);
508
+ if (run.tenantId !== spec.tenantId)
509
+ return this.refuse(spec, "INVALID_SPEC", `run ${spec.runId} belongs to another tenant`);
510
+ if (!jobs.some((j) => j.job.jobId === spec.jobId))
511
+ return this.refuse(spec, "UNKNOWN_JOB", `run ${spec.runId} has no job ${spec.jobId}`);
512
+ }
513
+ catch (err) {
514
+ return this.refuse(spec, storeCode(err) ?? "UNKNOWN_JOB", message(err));
515
+ }
516
+ const match = matchCapabilities(this.opts.profile, spec.requires);
517
+ if (!match.ok)
518
+ return this.refuse(spec, match.code, match.detail);
519
+ for (const ref of spec.inputs) {
520
+ const problem = this.opts.inputs.verify(ref);
521
+ if (problem)
522
+ return this.refuse(spec, problem, problem === "INPUT_MISSING" ? `input ${ref.name} is not admitted` : `input ${ref.name} changed after admission`);
523
+ }
524
+ const launchRun = { tenantId: spec.tenantId, runId: spec.runId, jobId: spec.jobId };
525
+ try {
526
+ this.opts.launcher.prepare?.(launchRun);
527
+ }
528
+ catch (err) {
529
+ return err instanceof WorkerRefusal ? this.refuse(spec, err.code, err.detail) : this.refuse(spec, "CONTAINMENT_UNAVAILABLE", message(err));
530
+ }
531
+ let attemptId;
532
+ try {
533
+ attemptId = this.opts.access.claim(this.opts.identity, spec.jobId).attempt.attemptId;
534
+ }
535
+ catch (err) {
536
+ return this.refuse(spec, storeCode(err) ?? "CLAIM_FAILED", message(err));
537
+ }
538
+ const attemptDir = join(this.opts.workDir, attemptId);
539
+ const logPath = join(attemptDir, "output.log");
540
+ try {
541
+ mkdirSync(join(attemptDir, "inputs"), { recursive: true });
542
+ for (const ref of spec.inputs)
543
+ this.opts.inputs.materialize(ref, join(attemptDir, "inputs"));
544
+ }
545
+ catch (err) {
546
+ const code = err instanceof WorkerRefusal ? err.code : "INPUT_FAILED";
547
+ return { kind: "failed", result: this.finish(this.result(spec, { kind: "failed", code, detail: message(err), attemptId })) };
548
+ }
549
+ const startedAt = this.now();
550
+ let proc;
551
+ try {
552
+ proc = this.opts.launcher.launch({ file: spec.command.file, args: [...spec.command.args], cwd: attemptDir, env: { ...spec.env }, logPath, limits: { ...spec.limits } }, launchRun);
553
+ }
554
+ catch (err) {
555
+ return { kind: "failed", result: this.finish(this.result(spec, { kind: "failed", code: "SPAWN_FAILED", detail: message(err), attemptId, startedAt })) };
556
+ }
557
+ let cancelRequested = false;
558
+ // The result reads the root pid from ready itself, so a process that ends
559
+ // before this method resumes still reports its pid.
560
+ const rootPid = proc.ready.then((p) => (p > 0 ? p : null), () => null);
561
+ const result = proc.done.then(async (outcome) => this.finish(this.result(spec, { ...this.mapOutcome(outcome, cancelRequested), attemptId, pid: await rootPid, startedAt })), async (err) => this.finish(this.result(spec, { kind: "failed", code: "SUPERVISOR_LOST", detail: message(err), attemptId, pid: await rootPid, startedAt })));
562
+ const pid = await proc.ready;
563
+ if (pid <= 0)
564
+ return { kind: "failed", result: await result };
565
+ const cancel = () => {
566
+ if (cancelRequested)
567
+ return;
568
+ cancelRequested = true;
569
+ proc.cancel();
570
+ };
571
+ return { kind: "started", attemptId, pid, process: proc, logPath, cancel, result };
572
+ }
573
+ mapOutcome(o, cancelRequested) {
574
+ switch (o.reason) {
575
+ case "cancelled":
576
+ return { kind: "cancelled", code: "CANCELLED", detail: "cancelled; the contained tree was terminated", exitCode: o.exitCode ?? null };
577
+ case "limit": {
578
+ const code = o.limit === "memory" ? "MEMORY_LIMIT" : o.limit === "processes" ? "PROCESS_LIMIT" : "CPU_LIMIT";
579
+ return { kind: "limit_exceeded", code, detail: `${o.limit} limit exceeded; the contained tree was terminated`, exitCode: o.exitCode ?? null };
580
+ }
581
+ case "exited":
582
+ if (cancelRequested)
583
+ return { kind: "cancelled", code: "CANCELLED", detail: "cancelled; the job exited", exitCode: o.exitCode };
584
+ return o.exitCode === 0
585
+ ? { kind: "succeeded", code: "EXITED", detail: "exited 0", exitCode: 0 }
586
+ : { kind: "failed", code: "EXIT_NONZERO", detail: `exited ${o.exitCode}`, exitCode: o.exitCode };
587
+ case "supervisor_lost":
588
+ return { kind: "failed", code: "SUPERVISOR_LOST", detail: o.detail, exitCode: null };
589
+ case "spawn_failed":
590
+ return { kind: "failed", code: "SPAWN_FAILED", detail: o.detail, exitCode: null };
591
+ }
592
+ }
593
+ }
594
+ //# sourceMappingURL=windows.js.map
@@ -72,6 +72,21 @@ export interface MeetingsAdapterOptions {
72
72
  /** Where a failing provider is reported. Default: a line on stderr. */
73
73
  warn?: (message: string) => void;
74
74
  }
75
+ /**
76
+ * The `signal_source_ref` alias for a bot transcript, or undefined when the
77
+ * transcript carries no id that is a safe path segment.
78
+ *
79
+ * Transcripts without `recall_bot_id` or `transcript_id` (Recall desktop-SDK
80
+ * recordings, legacy exports) fall back to the document `id`, which the
81
+ * meeting pipeline writes as `meeting:<id>`. A leading `meeting:` is stripped
82
+ * once from whichever id is used, so the alias is `meeting:<id>`, not
83
+ * `meeting:meeting:<id>`. An unsafe `recall_bot_id` does not fall back to
84
+ * another field: it names the bot, so a different id would split the
85
+ * transcript's signals from the live rider's. Anything still unsafe
86
+ * (a slash, `..`, another colon) gets no alias: the signals pass then keys the
87
+ * document by its file, and one odd record never fails the whole adapter.
88
+ */
89
+ export declare function transcriptSignalSourceRef(frontmatter: Record<string, unknown>, transcriptId: string): string | undefined;
75
90
  /** The adapter cursor: see the file comment. */
76
91
  export interface MeetingsCursor {
77
92
  vault: string | null;
@@ -193,7 +193,32 @@ async function readTranscript(dir, file, names) {
193
193
  },
194
194
  };
195
195
  }
196
- function toEvent(t) {
196
+ const MEETING_DOC_ID_PREFIX = "meeting:";
197
+ /**
198
+ * The `signal_source_ref` alias for a bot transcript, or undefined when the
199
+ * transcript carries no id that is a safe path segment.
200
+ *
201
+ * Transcripts without `recall_bot_id` or `transcript_id` (Recall desktop-SDK
202
+ * recordings, legacy exports) fall back to the document `id`, which the
203
+ * meeting pipeline writes as `meeting:<id>`. A leading `meeting:` is stripped
204
+ * once from whichever id is used, so the alias is `meeting:<id>`, not
205
+ * `meeting:meeting:<id>`. An unsafe `recall_bot_id` does not fall back to
206
+ * another field: it names the bot, so a different id would split the
207
+ * transcript's signals from the live rider's. Anything still unsafe
208
+ * (a slash, `..`, another colon) gets no alias: the signals pass then keys the
209
+ * document by its file, and one odd record never fails the whole adapter.
210
+ */
211
+ export function transcriptSignalSourceRef(frontmatter, transcriptId) {
212
+ const raw = nonEmptyString(frontmatter.recall_bot_id) ?? transcriptId;
213
+ const id = raw.startsWith(MEETING_DOC_ID_PREFIX) ? raw.slice(MEETING_DOC_ID_PREFIX.length) : raw;
214
+ try {
215
+ return meetingSignalSourceRef(id);
216
+ }
217
+ catch {
218
+ return undefined;
219
+ }
220
+ }
221
+ function toEvent(t, warn) {
197
222
  const when = new Date(t.tsMs).toISOString();
198
223
  const who = nonEmptyString(t.frontmatter.person_uid) ?? "unknown";
199
224
  const where = nonEmptyString(t.frontmatter.meeting_platform) ?? "meeting";
@@ -208,6 +233,10 @@ function toEvent(t) {
208
233
  `- Transcript: ${payloadRef}`,
209
234
  "",
210
235
  ].join("\n");
236
+ const signalSourceRef = transcriptSignalSourceRef(t.frontmatter, t.transcriptId);
237
+ if (signalSourceRef === undefined) {
238
+ warn(`meetings: ${t.file} has no meeting id that is a safe path segment; landing it without a signal_source_ref`);
239
+ }
211
240
  return {
212
241
  providerId: t.transcriptId,
213
242
  version: `${t.audienceVersion}.${t.bodyDigest}`,
@@ -219,7 +248,11 @@ function toEvent(t) {
219
248
  title: t.title,
220
249
  body,
221
250
  payloadRef,
222
- frontmatter: { audience_source: t.audienceSource, provider: MEETINGS_VAULT_SOURCE, signal_source_ref: meetingSignalSourceRef(nonEmptyString(t.frontmatter.recall_bot_id) ?? t.transcriptId) },
251
+ frontmatter: {
252
+ audience_source: t.audienceSource,
253
+ provider: MEETINGS_VAULT_SOURCE,
254
+ ...(signalSourceRef !== undefined ? { signal_source_ref: signalSourceRef } : {}),
255
+ },
223
256
  raw: { transcript: payloadRef, frontmatter: t.frontmatter, audience: [...t.audience], audience_source: t.audienceSource },
224
257
  };
225
258
  }
@@ -350,7 +383,7 @@ export function createMeetingsAdapter(options) {
350
383
  const page = newer.slice(0, end);
351
384
  const last = page[page.length - 1];
352
385
  return {
353
- events: [...atCursor, ...page].map(toEvent),
386
+ events: [...atCursor, ...page].map((t) => toEvent(t, warn)),
354
387
  cursor: last ? new Date(last.tsMs).toISOString() : cursor,
355
388
  hasMore: end < newer.length,
356
389
  all,