onionskin-cli 0.0.0-stage → 0.0.1

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 (117) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/INSTALL.md +17 -0
  3. package/LICENSE +21 -0
  4. package/NOTICE +46 -0
  5. package/README.md +88 -2
  6. package/docs/contracts/batch.schema.json +839 -0
  7. package/docs/contracts/history.schema.json +126 -0
  8. package/docs/contracts/ops.schema.json +541 -0
  9. package/package.json +54 -4
  10. package/scripts/checker/check.py +411 -0
  11. package/scripts/checker/requirements.txt +5 -0
  12. package/scripts/install-check.mjs +9 -0
  13. package/scripts/requirements.txt +5 -0
  14. package/scripts/rewriter/apple/main.swift +135 -0
  15. package/scripts/rewriter/apple/onionskin-fm +0 -0
  16. package/scripts/rewriter/apple/onionskin-fm.json +6 -0
  17. package/skills/onionskin/SKILL.md +117 -0
  18. package/skills/onionskin/reference/batch.md +94 -0
  19. package/skills/onionskin/reference/formats.md +15 -0
  20. package/skills/onionskin/reference/ops.md +253 -0
  21. package/skills/onionskin/reference/troubleshooting.md +73 -0
  22. package/skills/onionskin/reference/voice-guide.md +86 -0
  23. package/skills/onionskin/voice.example.md +51 -0
  24. package/src/agent-detect.js +149 -0
  25. package/src/agent-events.js +159 -0
  26. package/src/agent-prompt.js +27 -0
  27. package/src/agent-runner.js +593 -0
  28. package/src/analyze.js +17 -0
  29. package/src/anchors.js +190 -0
  30. package/src/apply.js +387 -0
  31. package/src/auth.js +130 -0
  32. package/src/batch.js +322 -0
  33. package/src/check-worker.js +8 -0
  34. package/src/checker.js +293 -0
  35. package/src/cli.js +516 -0
  36. package/src/constants.js +20 -0
  37. package/src/diff.js +267 -0
  38. package/src/doctor.js +247 -0
  39. package/src/docx.js +438 -0
  40. package/src/fmt.js +30 -0
  41. package/src/fsutil.js +348 -0
  42. package/src/history-worker.js +16 -0
  43. package/src/history.js +576 -0
  44. package/src/lease.js +79 -0
  45. package/src/local.js +242 -0
  46. package/src/merge-pptx.js +198 -0
  47. package/src/merge-xlsx.js +453 -0
  48. package/src/merge.js +410 -0
  49. package/src/offload.js +34 -0
  50. package/src/ops/common.js +48 -0
  51. package/src/ops/docx-table.js +323 -0
  52. package/src/ops/docx.js +503 -0
  53. package/src/ops/engine.js +41 -0
  54. package/src/ops/pptx.js +336 -0
  55. package/src/ops/run.js +115 -0
  56. package/src/ops/runs.js +127 -0
  57. package/src/ops/schema.js +109 -0
  58. package/src/ops/xlsx.js +277 -0
  59. package/src/package.js +189 -0
  60. package/src/paths.js +64 -0
  61. package/src/person.js +66 -0
  62. package/src/pptx.js +194 -0
  63. package/src/question.js +47 -0
  64. package/src/quick-plan.js +107 -0
  65. package/src/quick.js +164 -0
  66. package/src/redline-check.js +251 -0
  67. package/src/redline-worker.js +29 -0
  68. package/src/redline.js +438 -0
  69. package/src/reply.js +410 -0
  70. package/src/review.js +274 -0
  71. package/src/rewrite-check.js +1014 -0
  72. package/src/rewriter-cleanup.js +105 -0
  73. package/src/rewriter-setup.js +104 -0
  74. package/src/rewriter.js +396 -0
  75. package/src/sanitize.js +42 -0
  76. package/src/sentence-span.js +25 -0
  77. package/src/server-entry.js +13 -0
  78. package/src/server.js +576 -0
  79. package/src/session.js +1910 -0
  80. package/src/settings.js +161 -0
  81. package/src/setup.js +160 -0
  82. package/src/stamp-words.js +10 -0
  83. package/src/stamps.js +59 -0
  84. package/src/style.js +110 -0
  85. package/src/suggest-reply.js +84 -0
  86. package/src/suggest.js +261 -0
  87. package/src/text.js +31 -0
  88. package/src/tracked-words.js +43 -0
  89. package/src/voice-guide.js +182 -0
  90. package/src/voice-learn.js +314 -0
  91. package/src/voice-sample-worker.js +95 -0
  92. package/src/voice-samples.js +329 -0
  93. package/src/voice-store.js +305 -0
  94. package/src/voice-worker.js +28 -0
  95. package/src/voice.js +297 -0
  96. package/src/xlsx.js +454 -0
  97. package/src/xml-tree.js +118 -0
  98. package/src/xml.js +127 -0
  99. package/src/zip-write.js +74 -0
  100. package/src/zip.js +88 -0
  101. package/vendor/engine/DocViewer-BZLXUcxJ.js +15137 -0
  102. package/vendor/engine/THIRD_PARTY_LICENSES.txt +79 -0
  103. package/vendor/engine/collab-BVynXMqc.js +2591 -0
  104. package/vendor/engine/collab.js +2 -0
  105. package/vendor/engine/core.js +4 -0
  106. package/vendor/engine/default-worker-DogNT09A.js +35625 -0
  107. package/vendor/engine/embed.js +107 -0
  108. package/vendor/engine/index.js +5 -0
  109. package/vendor/engine/office-engine.embed.js +184 -0
  110. package/vendor/engine/office-engine.worker.js +36030 -0
  111. package/vendor/engine/xlsx-ops-SYAv6V0f.js +939 -0
  112. package/vendor/engine-node/LICENSE +21 -0
  113. package/vendor/engine-node/engine-node.mjs +46618 -0
  114. package/vendor/engine.lock.json +26 -0
  115. package/web/dist/assets/index-CFISATkn.js +197 -0
  116. package/web/dist/assets/index-spXE4oTz.css +1 -0
  117. package/web/dist/index.html +14 -0
package/src/checker.js ADDED
@@ -0,0 +1,293 @@
1
+ import { spawn, spawnSync } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { PRODUCT, env } from "./constants.js";
7
+ import { stateDir } from "./paths.js";
8
+
9
+ const here = path.dirname(fileURLToPath(import.meta.url));
10
+ const CHECK_SCRIPT = path.join(here, "..", "scripts", "checker", "check.py");
11
+ const CHECKER_REQUIREMENTS = path.join(here, "..", "scripts", "checker", "requirements.txt");
12
+ // The deep check blocks its own thread for up to this long (default 3 minutes; LibreOffice is the slow part). The server runs it in a worker
13
+ // thread (src/offload.js), so it keeps answering meanwhile; Sessions.done called directly (tests) still runs it inline.
14
+ const CHECK_TIMEOUT_MS = () => Number(env("CHECK_TIMEOUT_MS", 180_000));
15
+
16
+ const venvDir = () => path.join(stateDir(), "venv");
17
+ const venvPython = () => path.join(venvDir(), process.platform === "win32" ? "Scripts" : "bin", process.platform === "win32" ? "python.exe" : "python");
18
+
19
+ /** ONIONSKIN_PYTHON, else the venv that `setup-checker` creates in the state dir. null when neither exists. */
20
+ export function findPython() {
21
+ const p = env("PYTHON", "") || venvPython();
22
+ return fs.existsSync(p) ? p : null;
23
+ }
24
+
25
+ /**
26
+ * Runs scripts/checker/check.py on the two package versions. Never returns "clean" for a check that did not run:
27
+ * {ran:false, reason} when Python or its libraries are missing, and a `deep_check_failed` flag when it ran but broke.
28
+ * `deferSoffice` leaves the LibreOffice conversion out (check.py --no-soffice): `soffice` is then "pending" when it would run (see
29
+ * startLateSoffice) and the result never says it passed.
30
+ */
31
+ export function runDeepCheck(preBytes, postBytes, format, { deferSoffice = false } = {}) {
32
+ const py = findPython();
33
+ if (!py) return { ran: false, flags: [], code: "not_set_up", reason: `no Python with lxml found: set ${PRODUCT.envPrefix}_PYTHON or run \`${PRODUCT.bin} setup-checker\`` };
34
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "onionskin-check-"));
35
+ try {
36
+ const pre = path.join(dir, `pre.${format}`);
37
+ const post = path.join(dir, `post.${format}`);
38
+ fs.writeFileSync(pre, preBytes);
39
+ fs.writeFileSync(post, postBytes);
40
+ const r = spawnSync(py, ["-I", CHECK_SCRIPT, pre, post, format, ...(deferSoffice ? ["--no-soffice"] : [])], { encoding: "utf8", timeout: CHECK_TIMEOUT_MS(), maxBuffer: 16 * 1024 * 1024, env: process.env, killSignal: "SIGKILL" });
41
+ if (r.error?.code === "ETIMEDOUT") return { ran: false, code: "timed_out", flags: [{ code: "deep_check_failed", severity: "warn", detail: `timed out after ${CHECK_TIMEOUT_MS() / 1000}s` }], reason: "the deeper check timed out" };
42
+ if (r.error) return { ran: false, code: "failed", flags: [{ code: "deep_check_failed", severity: "warn", detail: r.error.message }], reason: "the deeper check could not start" };
43
+ let j;
44
+ try {
45
+ j = JSON.parse(r.stdout);
46
+ } catch {
47
+ j = null;
48
+ }
49
+ if (r.status === 3) return { ran: false, flags: [], code: "libraries_missing", reason: `${py} lacks lxml/defusedxml: run \`${PRODUCT.bin} setup-checker\`` };
50
+ if (r.status !== 0 || !j || !Array.isArray(j.flags)) {
51
+ const why = (j?.error || r.stderr || `exit ${r.status}`).toString().slice(0, 300);
52
+ return { ran: false, code: "failed", flags: [{ code: "deep_check_failed", severity: "warn", detail: why }], reason: "the deeper check failed to run" };
53
+ }
54
+ const skipped = j.skipped || [];
55
+ const pending = skipped.some((x) => x.check === "soffice-convert" && x.pending);
56
+ return { ran: true, flags: j.flags, checksRun: j.ran, skipped: pending ? skipped.filter((x) => !x.pending) : skipped, sofficePending: pending, python: py };
57
+ } finally {
58
+ fs.rmSync(dir, { recursive: true, force: true });
59
+ }
60
+ }
61
+
62
+ // One LibreOffice at a time for the whole server: each run is a full office process (hundreds of MB, a second or more of CPU), so a burst of
63
+ // `done` calls waits in line (first in, first out) rather than starting one each. Ceiling: at most LATE_WAITING checks wait; one more is
64
+ // recorded as not run, with the reason. Raise the limits here if a machine can carry more.
65
+ const LATE_WAITING = 8;
66
+ const lateQueue = []; // start functions of checks that wait their turn
67
+ let lateRunning = false;
68
+ const lateNext = () => {
69
+ lateRunning = false;
70
+ const start = lateQueue.shift();
71
+ if (start) start();
72
+ };
73
+
74
+ /**
75
+ * The LibreOffice conversion check for a version `done` already accepted, run in the background (check.py --soffice-only). Never blocks:
76
+ * `onDone({ran, flags, skipped, reason})` is called exactly once, also when the check fails, times out, is cancelled or never got its turn
77
+ * (then ran:false and a reason, never a clean result). One check runs at a time; the time limit counts from its own start, not from the
78
+ * wait. `cancel()` ends it now, running or waiting: SIGTERM makes check.py kill its soffice process group; check.py also exits on its own
79
+ * when this process is gone, so no soffice outlives the server. Returns {cancel}.
80
+ */
81
+ export function startLateSoffice(preBytes, postBytes, format, onDone) {
82
+ const py = findPython();
83
+ let settled = false;
84
+ let started = false;
85
+ let child = null;
86
+ let timer = null;
87
+ let dir = null;
88
+ const finish = (r) => {
89
+ if (settled) return;
90
+ settled = true;
91
+ clearTimeout(timer);
92
+ if (dir) fs.rmSync(dir, { recursive: true, force: true });
93
+ // the next one starts only when this one's process is really gone (a cancelled or timed-out check takes a moment to die)
94
+ if (started && child?.pid && child.exitCode === null && child.signalCode === null) child.once("close", lateNext);
95
+ else if (started) lateNext();
96
+ else {
97
+ const at = lateQueue.indexOf(start);
98
+ if (at >= 0) lateQueue.splice(at, 1);
99
+ }
100
+ try {
101
+ onDone(r);
102
+ } catch {}
103
+ };
104
+ const cancel = (reason = "the check was cancelled") => {
105
+ if (settled) return;
106
+ if (child && child.exitCode === null) child.kill("SIGTERM");
107
+ finish({ ran: false, flags: [], skipped: [], reason });
108
+ };
109
+ function start() {
110
+ started = true;
111
+ lateRunning = true;
112
+ try {
113
+ dir = fs.mkdtempSync(path.join(os.tmpdir(), "onionskin-late-"));
114
+ const pre = path.join(dir, `pre.${format}`);
115
+ const post = path.join(dir, `post.${format}`);
116
+ fs.writeFileSync(pre, preBytes);
117
+ fs.writeFileSync(post, postBytes);
118
+ child = spawn(py, ["-I", CHECK_SCRIPT, pre, post, format, "--soffice-only"], { env: process.env, stdio: ["ignore", "pipe", "pipe"] });
119
+ } catch (err) {
120
+ return finish({ ran: false, flags: [], skipped: [], reason: `could not start: ${err.message}` });
121
+ }
122
+ let out = "";
123
+ child.stdout.on("data", (d) => (out = (out + d).slice(0, 16 * 1024 * 1024)));
124
+ child.stderr.resume();
125
+ child.once("error", (err) => finish({ ran: false, flags: [], skipped: [], reason: `could not start: ${err.message}` }));
126
+ child.once("close", (code) => {
127
+ let j = null;
128
+ try {
129
+ j = JSON.parse(out);
130
+ } catch {}
131
+ if (code === 0 && j && Array.isArray(j.flags)) finish({ ran: (j.ran || []).includes("soffice-convert"), flags: j.flags, skipped: j.skipped || [], reason: (j.skipped || [])[0]?.reason });
132
+ else finish({ ran: false, flags: [], skipped: [], reason: (j?.error || `exit ${code}`).toString().slice(0, 200) });
133
+ });
134
+ timer = setTimeout(() => {
135
+ if (child.exitCode === null) child.kill("SIGTERM");
136
+ finish({ ran: false, flags: [], skipped: [], reason: `timed out after ${CHECK_TIMEOUT_MS() / 1000}s` });
137
+ }, CHECK_TIMEOUT_MS());
138
+ }
139
+ if (!py) finish({ ran: false, flags: [], skipped: [], reason: "no Python for the check" });
140
+ else if (!lateRunning) start();
141
+ else if (lateQueue.length >= LATE_WAITING) finish({ ran: false, flags: [], skipped: [], reason: `not run: ${LATE_WAITING} LibreOffice checks were already waiting` });
142
+ else lateQueue.push(start);
143
+ return { cancel };
144
+ }
145
+
146
+ /** `onionskin setup-checker`: the one place that uses the network (pip). Creates <state dir>/venv. */
147
+ export function setupChecker(log = (s) => process.stderr.write(s + "\n")) {
148
+ const base = process.env[`${PRODUCT.envPrefix}_BASE_PYTHON`] || "python3";
149
+ fs.mkdirSync(stateDir(), { recursive: true, mode: 0o700 });
150
+ const steps = [
151
+ [base, ["-m", "venv", venvDir()]],
152
+ [venvPython(), ["-m", "pip", "install", "--disable-pip-version-check", "--quiet", "-r", CHECKER_REQUIREMENTS]],
153
+ ];
154
+ for (const [cmd, args] of steps) {
155
+ log(`$ ${path.basename(cmd)} ${args.slice(0, 3).join(" ")} ...`);
156
+ const r = spawnSync(cmd, args, { stdio: ["ignore", "inherit", "inherit"] });
157
+ if (r.status !== 0) throw new Error(`${cmd} ${args.slice(0, 2).join(" ")} failed (${r.error?.message || `exit ${r.status}`})`);
158
+ }
159
+ const probe = spawnSync(venvPython(), ["-c", "import lxml, docx, openpyxl, pptx, defusedxml"], { encoding: "utf8" });
160
+ if (probe.status !== 0) throw new Error(`the venv was created but the libraries do not import: ${probe.stderr}`);
161
+ return venvPython();
162
+ }
163
+
164
+ // ---- the same setup, for the browser (POST /api/setup-checker) -----------------------------------------------------
165
+ // The server must keep answering while pip runs (about a minute), so this variant spawns instead of spawnSync. One job at a time for the
166
+ // whole server: a second start while one runs gets the same promise. The job's outcome is kept until the next start so the page can poll it.
167
+ const SETUP_TIMEOUT_MS = () => Number(env("SETUP_TIMEOUT_MS", 10 * 60_000));
168
+ export const NETWORK_WORDS = /could not resolve|name or service not known|nodename nor servname|temporary failure in name resolution|failed to establish a new connection|connection (?:error|refused|reset|timed out)|network is unreachable|no matching distribution|max retries exceeded|read timed out|ssl|proxy/i;
169
+ let job = null; // {promise} while running; {outcome: {reason, detail}} after a failure; null when idle or after a success
170
+
171
+ /** One command, async. Resolves {status, stderr (last 4000 bytes), error}; never rejects, never inherits the server's stdio. */
172
+ export function run(cmd, args, timeoutMs) {
173
+ return new Promise((resolve) => {
174
+ let stderr = "";
175
+ let settled = false;
176
+ const done = (r) => {
177
+ if (settled) return;
178
+ settled = true;
179
+ clearTimeout(timer);
180
+ resolve({ stderr: stderr.slice(-4000), ...r });
181
+ };
182
+ let child;
183
+ try {
184
+ child = spawn(cmd, args, { stdio: ["ignore", "ignore", "pipe"], env: process.env });
185
+ } catch (error) {
186
+ return resolve({ status: null, stderr: "", error });
187
+ }
188
+ const timer = setTimeout(() => (child.kill("SIGKILL"), done({ status: null, error: new Error(`took longer than ${Math.round(timeoutMs / 1000)}s`) })), timeoutMs);
189
+ child.stderr.on("data", (d) => (stderr += d));
190
+ child.once("error", (error) => done({ status: null, error }));
191
+ child.once("close", (status) => done({ status }));
192
+ });
193
+ }
194
+
195
+ /** Do the venv's libraries import? (The one probe both setup and the status use: a venv whose pip said ok but whose libraries do not import is not ready.) */
196
+ async function librariesImport(py) {
197
+ return (await run(py, ["-c", "import lxml, docx, openpyxl, pptx, defusedxml"], 30_000)).status === 0;
198
+ }
199
+
200
+ async function setupSteps() {
201
+ const base = process.env[`${PRODUCT.envPrefix}_BASE_PYTHON`] || "python3";
202
+ // A Mac without the developer tools: /usr/bin/python3 is a stub that opens Apple's installer window. Never start that from a button.
203
+ if (base === "python3" && process.platform === "darwin") {
204
+ const first = (process.env.PATH || "").split(":").map((d) => path.join(d, "python3")).find((f) => fs.existsSync(f));
205
+ if (first === "/usr/bin/python3" && (await run("/usr/bin/xcode-select", ["-p"], 5000)).status !== 0) throw Object.assign(new Error("/usr/bin/python3 needs the macOS developer tools, which are not installed"), { reason: "no_python" });
206
+ }
207
+ fs.mkdirSync(stateDir(), { recursive: true, mode: 0o700 });
208
+ const venv = await run(base, ["-m", "venv", venvDir()], SETUP_TIMEOUT_MS());
209
+ if (venv.status !== 0) {
210
+ const missing = venv.error?.code === "ENOENT";
211
+ throw Object.assign(new Error(`${base} -m venv failed (${venv.error?.message || `exit ${venv.status}`}) ${venv.stderr}`.trim()), { reason: missing ? "no_python" : "failed" });
212
+ }
213
+ const pip = await run(venvPython(), ["-m", "pip", "install", "--disable-pip-version-check", "--quiet", "-r", CHECKER_REQUIREMENTS], SETUP_TIMEOUT_MS());
214
+ if (pip.status !== 0) {
215
+ const text = `pip install failed (${pip.error?.message || `exit ${pip.status}`}) ${pip.stderr}`.trim();
216
+ throw Object.assign(new Error(text), { reason: NETWORK_WORDS.test(text) ? "no_network" : "failed" });
217
+ }
218
+ if (!(await librariesImport(venvPython()))) throw Object.assign(new Error("the venv was created but the libraries do not import"), { reason: "failed" });
219
+ // runs use findPython(): an ONIONSKIN_PYTHON that points elsewhere would keep the checker off after a "successful" setup
220
+ const used = findPython();
221
+ if (used !== venvPython() && !(await librariesImport(used))) throw Object.assign(new Error(`the venv is ready, but ${PRODUCT.envPrefix}_PYTHON points at ${used}, which lacks the libraries: unset it`), { reason: "failed" });
222
+ return venvPython();
223
+ }
224
+
225
+ /**
226
+ * Starts the setup (or joins the one that is running) and returns its promise. It resolves to the venv's python, or rejects with an error that
227
+ * carries `reason`: no_python | no_network | failed. The caller does not need to await it; setupCheckerStatus() reports it.
228
+ */
229
+ export function startSetupChecker() {
230
+ if (job?.promise) return job.promise;
231
+ const mine = {};
232
+ mine.promise = setupSteps().then(
233
+ (py) => ((job = null), py),
234
+ (err) => {
235
+ job = { outcome: { reason: err.reason || "failed", detail: String(err.message).slice(0, 2000) } };
236
+ throw err;
237
+ },
238
+ );
239
+ mine.promise.catch(() => {}); // a click nobody awaits must not become an unhandled rejection
240
+ job = mine;
241
+ return mine.promise;
242
+ }
243
+
244
+ /** {state: "off"|"working"|"on"|"failed", reason?, detail?} for the page. "on" means the libraries import right now, whoever set them up. */
245
+ export async function setupCheckerStatus() {
246
+ if (job?.promise) return { state: "working" };
247
+ const py = findPython();
248
+ if (py && (await librariesImport(py))) return { state: "on" };
249
+ if (job?.outcome) return { state: "failed", ...job.outcome };
250
+ return { state: "off" };
251
+ }
252
+
253
+ export const resetSetupCheckerForTests = () => {
254
+ job = null;
255
+ };
256
+
257
+ /**
258
+ * The deeper check of a tracked-changes copy (check.py --redline): a second resolver in Python (lxml), a reopen with python-docx, and a
259
+ * LibreOffice conversion to ODT in a private profile when LibreOffice is there. Async (the server keeps answering). Resolves to
260
+ * {ran: false, reason} when the checker is not set up, else {ran: true, ok, why, skipped}. A check that breaks or times out is a failed
261
+ * check (ran: true, ok: false), never a pass.
262
+ */
263
+ export function deepRedline(preBytes, postBytes, outBytes) {
264
+ const py = findPython();
265
+ if (!py) return Promise.resolve({ ran: false, reason: "not_set_up" });
266
+ return new Promise((resolve) => {
267
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "onionskin-redline-"));
268
+ const files = ["pre", "post", "out"].map((n) => path.join(dir, `${n}.docx`));
269
+ [preBytes, postBytes, outBytes].forEach((b, k) => fs.writeFileSync(files[k], b));
270
+ let out = "";
271
+ let settled = false;
272
+ const finish = (r) => {
273
+ if (settled) return;
274
+ settled = true;
275
+ clearTimeout(timer);
276
+ fs.rmSync(dir, { recursive: true, force: true });
277
+ resolve(r);
278
+ };
279
+ const child = spawn(py, ["-I", CHECK_SCRIPT, "--redline", ...files], { env: process.env, stdio: ["ignore", "pipe", "ignore"] });
280
+ const timer = setTimeout(() => (child.kill("SIGTERM"), finish({ ran: true, ok: false, why: "the deeper check timed out" })), CHECK_TIMEOUT_MS());
281
+ child.stdout.on("data", (c) => (out += c).length > 1e6 && child.kill("SIGTERM"));
282
+ child.on("error", () => finish({ ran: true, ok: false, why: "the deeper check could not start" }));
283
+ child.on("close", (code) => {
284
+ if (code === 3) return finish({ ran: false, reason: "libraries_missing" });
285
+ let j = null;
286
+ try {
287
+ j = JSON.parse(out);
288
+ } catch {}
289
+ if (code !== 0 || !j || typeof j.ok !== "boolean") return finish({ ran: true, ok: false, why: "the deeper check failed to run" });
290
+ finish({ ran: true, ok: j.ok, why: String(j.why || "").slice(0, 200), skipped: Array.isArray(j.skipped) ? j.skipped : [] });
291
+ });
292
+ });
293
+ }