@songtonyli/dsh-cli 0.1.57 → 0.1.59

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 (139) hide show
  1. package/README.md +1 -1
  2. package/bin/dsh.mjs +1 -1
  3. package/node_modules/@deepseek-ai/dsh-agent-preset/skills/cordis-composition-reference/references/packages.md +1 -0
  4. package/node_modules/@deepseek-ai/dsh-api-session-controller/lib/client.js +1 -0
  5. package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +2 -2
  6. package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
  7. package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +2 -2
  8. package/node_modules/@deepseek-ai/dsh-sandbox/lib/index.js +59 -4
  9. package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.i18n.yaml +73 -0
  10. package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.md +166 -0
  11. package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.zh.md +166 -0
  12. package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/lib/exec-shim.js +227 -0
  13. package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/lib/index.js +704 -0
  14. package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/package.json +62 -0
  15. package/node_modules/@deepseek-ai/dsh-sandbox-policy/README.i18n.yaml +2 -2
  16. package/node_modules/@deepseek-ai/dsh-sandbox-policy/README.md +1 -1
  17. package/node_modules/@deepseek-ai/dsh-sandbox-policy/README.zh.md +1 -1
  18. package/node_modules/@deepseek-ai/dsh-sandbox-policy/lib/index.js +23 -0
  19. package/node_modules/@deepseek-ai/dsh-session/lib/index.js +1 -0
  20. package/node_modules/@deepseek-ai/dsh-session/lib/types/known-event-types.js +1 -0
  21. package/node_modules/@deepseek-ai/dsh-session-persistence-jsonl/lib/worker.cjs +1 -0
  22. package/node_modules/@deepseek-ai/dsh-system-prompt/lib/index.js +1 -0
  23. package/node_modules/@deepseek-ai/dsh-tool-cordis/lib/types/api-catalog.js +22 -0
  24. package/node_modules/@deepseek-ai/dsh-tool-fs/README.i18n.yaml +2 -2
  25. package/node_modules/@deepseek-ai/dsh-tool-fs/README.md +1 -1
  26. package/node_modules/@deepseek-ai/dsh-tool-fs/README.zh.md +1 -1
  27. package/node_modules/@deepseek-ai/dsh-tool-fs/lib/index.js +24 -0
  28. package/node_modules/@deepseek-ai/dsh-tool-fs-search/README.i18n.yaml +4 -4
  29. package/node_modules/@deepseek-ai/dsh-tool-fs-search/README.md +2 -2
  30. package/node_modules/@deepseek-ai/dsh-tool-fs-search/README.zh.md +2 -2
  31. package/node_modules/@deepseek-ai/dsh-tool-fs-search/lib/index.js +28 -3
  32. package/node_modules/@deepseek-ai/dsh-tool-fs-search/package.json +7 -2
  33. package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/README.i18n.yaml +2 -2
  34. package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/README.md +1 -1
  35. package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/README.zh.md +1 -1
  36. package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/lib/index.js +14 -6
  37. package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +6 -6
  38. package/node_modules/@deepseek-ai/dsh-tui-app/README.md +6 -5
  39. package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +6 -5
  40. package/node_modules/@deepseek-ai/dsh-tui-app/cordis.patch.yml +20 -0
  41. package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +42 -31
  42. package/node_modules/@deepseek-ai/dsh-tui-app/package.json +1 -0
  43. package/node_modules/@deepseek-ai/libreoffice-kit/README.md +20 -5
  44. package/node_modules/@deepseek-ai/libreoffice-kit/README.zh.md +21 -6
  45. package/node_modules/@deepseek-ai/libreoffice-kit/lib/cli.js +499 -253
  46. package/node_modules/@deepseek-ai/libreoffice-kit/lib/font-snapshot-worker.js +37 -26
  47. package/node_modules/@deepseek-ai/libreoffice-kit/lib/index.js +498 -252
  48. package/node_modules/@deepseek-ai/libreoffice-kit/lib/worker.js +39 -13
  49. package/node_modules/@deepseek-ai/libreoffice-kit/package.json +5 -3
  50. package/node_modules/@earendil-works/pi-ai/README.md +4 -3
  51. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +117 -18
  52. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -0
  53. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +19 -8
  54. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +1 -0
  55. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +1 -0
  56. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +1 -0
  57. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +2 -0
  58. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +5 -0
  59. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +24 -2
  60. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  61. package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  62. package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
  63. package/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
  64. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -1
  65. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  66. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  67. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  68. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  69. package/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
  70. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  71. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +2 -1
  72. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +3 -2
  73. package/node_modules/@earendil-works/pi-ai/package.json +6 -2
  74. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  75. package/node_modules/@shikijs/core/dist/index.mjs +15 -12
  76. package/node_modules/@shikijs/core/package.json +4 -4
  77. package/node_modules/@shikijs/engine-javascript/dist/engine-compile.mjs +2 -4
  78. package/node_modules/@shikijs/engine-javascript/dist/engine-raw.mjs +2 -4
  79. package/node_modules/@shikijs/engine-javascript/dist/index.mjs +1 -1
  80. package/node_modules/@shikijs/engine-javascript/dist/string-TLTPtCPs.mjs +115 -0
  81. package/node_modules/@shikijs/engine-javascript/package.json +3 -3
  82. package/node_modules/@shikijs/engine-oniguruma/package.json +3 -3
  83. package/node_modules/@shikijs/langs/dist/ada.mjs +1 -1
  84. package/node_modules/@shikijs/langs/dist/ahk.mjs +1 -1
  85. package/node_modules/@shikijs/langs/dist/beancount.mjs +1 -1
  86. package/node_modules/@shikijs/langs/dist/coq.mjs +1 -1
  87. package/node_modules/@shikijs/langs/dist/csharp.mjs +1 -1
  88. package/node_modules/@shikijs/langs/dist/css.mjs +1 -1
  89. package/node_modules/@shikijs/langs/dist/dart.mjs +1 -1
  90. package/node_modules/@shikijs/langs/dist/dotenv.mjs +1 -1
  91. package/node_modules/@shikijs/langs/dist/emacs-lisp.mjs +1 -1
  92. package/node_modules/@shikijs/langs/dist/gn.mjs +1 -1
  93. package/node_modules/@shikijs/langs/dist/handlebars.mjs +1 -1
  94. package/node_modules/@shikijs/langs/dist/julia.mjs +1 -1
  95. package/node_modules/@shikijs/langs/dist/latex.mjs +1 -1
  96. package/node_modules/@shikijs/langs/dist/luau.mjs +1 -1
  97. package/node_modules/@shikijs/langs/dist/marko.mjs +1 -1
  98. package/node_modules/@shikijs/langs/dist/moonbit.mjs +1 -1
  99. package/node_modules/@shikijs/langs/dist/nextflow-groovy.mjs +1 -1
  100. package/node_modules/@shikijs/langs/dist/nextflow.mjs +1 -1
  101. package/node_modules/@shikijs/langs/dist/nushell.mjs +1 -1
  102. package/node_modules/@shikijs/langs/dist/php.mjs +1 -1
  103. package/node_modules/@shikijs/langs/dist/powershell.mjs +1 -1
  104. package/node_modules/@shikijs/langs/dist/ruby.mjs +1 -1
  105. package/node_modules/@shikijs/langs/dist/rust.mjs +1 -1
  106. package/node_modules/@shikijs/langs/dist/sql.mjs +1 -1
  107. package/node_modules/@shikijs/langs/dist/svelte.mjs +1 -1
  108. package/node_modules/@shikijs/langs/dist/twig.mjs +3 -3
  109. package/node_modules/@shikijs/langs/dist/typespec.mjs +1 -1
  110. package/node_modules/@shikijs/langs/package.json +3 -3
  111. package/node_modules/@shikijs/primitive/dist/index.mjs +2 -1
  112. package/node_modules/@shikijs/primitive/package.json +3 -3
  113. package/node_modules/@shikijs/themes/dist/monokai.mjs +1 -1
  114. package/node_modules/@shikijs/themes/dist/one-dark-pro.mjs +1 -1
  115. package/node_modules/@shikijs/themes/dist/red.mjs +1 -1
  116. package/node_modules/@shikijs/themes/dist/solarized-dark.mjs +1 -1
  117. package/node_modules/@shikijs/themes/dist/solarized-light.mjs +1 -1
  118. package/node_modules/@shikijs/themes/package.json +3 -3
  119. package/node_modules/@shikijs/types/package.json +1 -1
  120. package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +33 -11
  121. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +3 -0
  122. package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/exceptions.js +33 -11
  123. package/node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js +3 -0
  124. package/node_modules/@smithy/core/package.json +1 -1
  125. package/node_modules/node-addon-native-custom-loader/lib/index.js +23 -10
  126. package/node_modules/node-addon-native-custom-loader/package.json +6 -1
  127. package/node_modules/node-addon-require-builtin/package.json +7 -2
  128. package/node_modules/powershell-utils/index.js +40 -19
  129. package/node_modules/powershell-utils/package.json +1 -1
  130. package/node_modules/powershell-utils/readme.md +69 -13
  131. package/node_modules/shiki/package.json +10 -10
  132. package/node_modules/wsl-utils/index.js +18 -37
  133. package/node_modules/wsl-utils/package.json +2 -2
  134. package/package.json +33 -29
  135. package/node_modules/@shikijs/engine-javascript/dist/scanner-DX8LRFGE.mjs +0 -77
  136. package/node_modules/open/node_modules/powershell-utils/index.js +0 -79
  137. package/node_modules/open/node_modules/powershell-utils/license +0 -9
  138. package/node_modules/open/node_modules/powershell-utils/package.json +0 -47
  139. package/node_modules/open/node_modules/powershell-utils/readme.md +0 -209
@@ -2,11 +2,14 @@
2
2
  import { createRequire } from "node:module";
3
3
  import { parseArgs } from "node:util";
4
4
  import { dirname, extname, isAbsolute, join, posix, relative, resolve, sep, win32 } from "node:path";
5
- import { constants, lstatSync, readdirSync } from "node:fs";
6
- import { lstat, mkdir, mkdtemp, open, readFile, rm, stat, unlink, writeFile } from "node:fs/promises";
5
+ import { closeSync, constants, createWriteStream, lstatSync, readSync, readdirSync } from "node:fs";
6
+ import { copyFile, lstat, mkdir, mkdtemp, open, readFile, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
7
7
  import { homedir, tmpdir } from "node:os";
8
8
  import { Worker } from "node:worker_threads";
9
9
  import { spawn } from "node:child_process";
10
+ import { EventEmitter } from "node:events";
11
+ import { Readable } from "node:stream";
12
+ import { finished } from "node:stream/promises";
10
13
  import { createHash, randomUUID } from "node:crypto";
11
14
  import { createInterface } from "node:readline";
12
15
  import { zlibSync } from "fflate";
@@ -137,7 +140,7 @@ function dimension(data, first, last, maximum, scale) {
137
140
  }
138
141
  return [start / scale, (position - start) / scale];
139
142
  }
140
- /** Logical columns advance from A; LOK itself mirrors RTL sheet painting. No manual x inversion. */
143
+ /** Logical columns advance from A; RTL uses the same coordinates and mirrored transport pixels. */
141
144
  function sheetRangeRectangle(geometry, range, scale) {
142
145
  if (!Number.isFinite(scale) || scale <= 0 || scale > 16) throw new TypeError("Invalid worksheet raster scale.");
143
146
  const [x, width] = dimension(geometry.columns, range.firstColumn, range.lastColumn, MAX_COLUMN, scale);
@@ -158,6 +161,17 @@ function sheetRangeRectangle(geometry, range, scale) {
158
161
  height
159
162
  };
160
163
  }
164
+ /** Undo Calc's RTL transport mirroring so saved pixels contain readable text and right-to-left columns. */
165
+ function unmirrorRtlTile({ width, height, rgba }) {
166
+ for (let y = 0; y < height; y++) for (let x = 0; x < Math.floor(width / 2); x++) {
167
+ const left = (y * width + x) * 4, right = (y * width + width - 1 - x) * 4;
168
+ for (let channel = 0; channel < 4; channel++) {
169
+ const value = rgba[left + channel];
170
+ rgba[left + channel] = rgba[right + channel];
171
+ rgba[right + channel] = value;
172
+ }
173
+ }
174
+ }
161
175
  /** Split a region on its output-pixel grid, bounding the plan before allocating it. */
162
176
  function splitRasterRectangle(rectangle, scale, limits) {
163
177
  const { x, y, width, height } = rectangle;
@@ -317,6 +331,184 @@ function selectedPages(pages, count, limit) {
317
331
  return result;
318
332
  }
319
333
  //#endregion
334
+ //#region lib/types/native-process.js
335
+ /** Native helper stdio; Windows pipe handles permit read/write access under restricted tokens. */
336
+ let pipeAttributes;
337
+ function windowsPipes() {
338
+ const koffi = createRequire(import.meta.url)("koffi");
339
+ const kernel = koffi.load("kernel32.dll"), advapi = koffi.load("advapi32.dll"), node = koffi.load(null);
340
+ const attributes = pipeAttributes ??= koffi.struct("KIT_SECURITY_ATTRIBUTES", {
341
+ nLength: "uint32",
342
+ lpSecurityDescriptor: "void *",
343
+ bInheritHandle: "int"
344
+ });
345
+ const createPipe = kernel.func("int __stdcall CreatePipe(_Out_ void **read, _Out_ void **write, KIT_SECURITY_ATTRIBUTES *attributes, uint32 size)");
346
+ const closeHandle = kernel.func("int __stdcall CloseHandle(void *handle)");
347
+ const localFree = kernel.func("void * __stdcall LocalFree(void *memory)");
348
+ const peek = kernel.func("int __stdcall PeekNamedPipe(void *pipe, void *buffer, uint32 size, void *read, _Out_ uint32 *available, void *remaining)");
349
+ const lastError = kernel.func("uint32 __stdcall GetLastError()");
350
+ const convertSecurityDescriptor = advapi.func("int __stdcall ConvertStringSecurityDescriptorToSecurityDescriptorW(void *sddl, uint32 revision, _Out_ void **descriptor, void *size)");
351
+ const openFd = node.func("int uv_open_osfhandle(void *handle)");
352
+ function pipe() {
353
+ const reads = [null], writes = [null];
354
+ const descriptor = [null];
355
+ if (!convertSecurityDescriptor(Buffer.from("D:(A;;GRGW;;;WD)\0", "utf16le"), 1, descriptor, null)) throw new Error(`Pipe security descriptor failed: ${lastError()}`);
356
+ try {
357
+ if (!createPipe(reads, writes, {
358
+ nLength: attributes.size,
359
+ lpSecurityDescriptor: descriptor[0],
360
+ bInheritHandle: 0
361
+ }, 0)) throw new Error(`CreatePipe failed: ${lastError()}`);
362
+ } finally {
363
+ localFree(descriptor[0]);
364
+ }
365
+ const read = openFd(reads[0]);
366
+ if (read < 0) {
367
+ closeHandle(reads[0]);
368
+ closeHandle(writes[0]);
369
+ throw new Error("Cannot open anonymous input descriptor");
370
+ }
371
+ const write = openFd(writes[0]);
372
+ if (write < 0) {
373
+ closeSync(read);
374
+ closeHandle(writes[0]);
375
+ throw new Error("Cannot open anonymous output descriptor");
376
+ }
377
+ let timer;
378
+ let ended = false;
379
+ const readable = new Readable({
380
+ read() {
381
+ if (timer === void 0 && !ended) poll();
382
+ },
383
+ destroy(error, callback) {
384
+ ended = true;
385
+ clearTimeout(timer);
386
+ try {
387
+ closeSync(read);
388
+ callback(error);
389
+ } catch (cause) {
390
+ callback(error ?? cause);
391
+ }
392
+ }
393
+ });
394
+ function poll() {
395
+ timer = void 0;
396
+ try {
397
+ const available = [0];
398
+ if (!peek(reads[0], null, 0, null, available, null)) {
399
+ const code = lastError();
400
+ if (code !== 109) throw new Error(`PeekNamedPipe failed: ${code}`);
401
+ ended = true;
402
+ readable.push(null);
403
+ return;
404
+ }
405
+ if (available[0] > 0) {
406
+ const buffer = Buffer.allocUnsafe(Math.min(available[0], 65536));
407
+ const count = readSync(read, buffer, 0, buffer.length, null);
408
+ if (!readable.push(buffer.subarray(0, count))) return;
409
+ }
410
+ timer = setTimeout(poll, 5);
411
+ } catch (error) {
412
+ readable.destroy(error);
413
+ }
414
+ }
415
+ return {
416
+ read,
417
+ write,
418
+ readable
419
+ };
420
+ }
421
+ return { pipe };
422
+ }
423
+ /**
424
+ * Spawn with inherited token and Job restrictions; pipe creation never requests a new sandbox policy.
425
+ * @param executable - Verified native helper executable.
426
+ * @param args - Helper protocol arguments.
427
+ * @param env - Filtered operation environment.
428
+ * @returns Helper streams and process lifetime, with output drained before close.
429
+ */
430
+ function spawnNative(executable, args, env) {
431
+ if (process.platform !== "win32") return spawn(executable, args, {
432
+ stdio: "pipe",
433
+ windowsHide: true,
434
+ env
435
+ });
436
+ const { pipe } = windowsPipes();
437
+ const owned = [];
438
+ let child;
439
+ try {
440
+ const input = pipe();
441
+ owned.push(input);
442
+ const output = pipe();
443
+ owned.push(output);
444
+ const error = pipe();
445
+ owned.push(error);
446
+ child = spawn(executable, args, {
447
+ stdio: [
448
+ input.read,
449
+ output.write,
450
+ error.write
451
+ ],
452
+ windowsHide: true,
453
+ env
454
+ });
455
+ } catch (error) {
456
+ for (const entry of owned) {
457
+ entry.readable.destroy();
458
+ closeSync(entry.write);
459
+ }
460
+ throw error;
461
+ }
462
+ const [input, output, error] = owned;
463
+ input.readable.destroy();
464
+ closeSync(output.write);
465
+ closeSync(error.write);
466
+ const stdin = createWriteStream("", {
467
+ fd: input.write,
468
+ autoClose: true
469
+ });
470
+ const helper = new class extends EventEmitter {
471
+ stdin = stdin;
472
+ stdout = output.readable;
473
+ stderr = error.readable;
474
+ get exitCode() {
475
+ return child.exitCode;
476
+ }
477
+ get signalCode() {
478
+ return child.signalCode;
479
+ }
480
+ kill(signal) {
481
+ return child.kill(signal);
482
+ }
483
+ }();
484
+ let failure;
485
+ const fail = (cause) => {
486
+ failure ??= cause;
487
+ child.kill("SIGKILL");
488
+ };
489
+ stdin.on("error", fail);
490
+ output.readable.on("error", fail);
491
+ error.readable.on("error", fail);
492
+ const drained = Promise.allSettled([
493
+ finished(stdin),
494
+ finished(output.readable),
495
+ finished(error.readable)
496
+ ]);
497
+ child.once("error", (cause) => {
498
+ failure ??= cause;
499
+ });
500
+ child.once("close", (code, signal) => {
501
+ stdin.destroy();
502
+ output.readable.resume();
503
+ error.readable.resume();
504
+ drained.then(() => {
505
+ if (failure !== void 0) helper.emit("error", failure);
506
+ helper.emit("close", code, signal);
507
+ });
508
+ });
509
+ return helper;
510
+ }
511
+ //#endregion
320
512
  //#region lib/types/profile.js
321
513
  /** Private headless profile used by both native and WASM conversions. */
322
514
  /**
@@ -538,6 +730,7 @@ async function prepareNativeFontProfile(profile, substitutions) {
538
730
  });
539
731
  }
540
732
  /**
733
+ * Native conversion and rendering disable printer discovery to avoid driver UI and network waits.
541
734
  * Linux searches the verified program directory; ambient loader overrides and credentials are excluded.
542
735
  * @param profile - Conversion-owned profile directory the helper treats as home.
543
736
  * @param programDirectory - Verified engine program directory.
@@ -557,10 +750,36 @@ function nativeEnvironment(profile, programDirectory, source = process.env, plat
557
750
  USERPROFILE: profile,
558
751
  TMPDIR: profile,
559
752
  TMP: profile,
560
- TEMP: profile
753
+ TEMP: profile,
754
+ SAL_DISABLE_PRINTERLIST: "1",
755
+ SAL_DISABLE_DEFAULTPRINTER: "1"
561
756
  });
562
757
  }
563
758
  /**
759
+ * Keep Windows engine resources reachable through a short profile-owned path until the helper exits.
760
+ * @param engine - Verified engine installation; its resources remain in place.
761
+ * @param profile - Private operation directory that owns the temporary executable and junction.
762
+ * @param run - Operation that settles only after its helper closes.
763
+ * @returns The operation result after removing the resource junction.
764
+ */
765
+ async function withNativeEngine(engine, profile, run) {
766
+ if (process.platform !== "win32" || engine.executable.length < 260 && engine.programDirectory.length < 260) return run(engine);
767
+ const root = join(profile, "engine");
768
+ await symlink(engine.root, root, "junction");
769
+ try {
770
+ const executable = join(profile, "libreoffice-kit.exe");
771
+ await copyFile(engine.executable, executable, constants.COPYFILE_EXCL);
772
+ return await run({
773
+ ...engine,
774
+ root,
775
+ executable,
776
+ programDirectory: join(root, relative(engine.root, engine.programDirectory))
777
+ });
778
+ } finally {
779
+ await unlink(root);
780
+ }
781
+ }
782
+ /**
564
783
  * Run one native conversion and await bounded result transport.
565
784
  * @param engine - Resolved native engine installation.
566
785
  * @param options - Validated conversion limits.
@@ -580,77 +799,73 @@ async function runNative(engine, options, input, output, profile, fonts, substit
580
799
  signal.throwIfAborted();
581
800
  await prepareNativeFontProfile(profile, substitutions);
582
801
  signal.throwIfAborted();
583
- const env = nativeEnvironment(profile, engine.programDirectory);
584
- const child = spawn(engine.executable, [
585
- "--program-directory",
586
- engine.programDirectory,
587
- "--input-path",
588
- input,
589
- "--output-path",
590
- output,
591
- "--profile-directory",
592
- profile,
593
- "--max-output-bytes",
594
- String(options.maxOutputBytes),
595
- "--max-image-resolution",
596
- String(options.maxImageResolution),
597
- "--format",
598
- operation.format,
599
- "--recalculate",
600
- String(operation.recalculate),
601
- ...operation.sheet === void 0 ? [] : ["--sheet", operation.sheet],
602
- ...fonts.flatMap((path) => ["--font-file", path])
603
- ], {
604
- stdio: [
605
- "ignore",
606
- "pipe",
607
- "pipe"
608
- ],
609
- windowsHide: true,
610
- env
611
- });
612
- let stdout = "";
613
- let stderr = "";
614
- let failure;
615
- const abort = () => {
616
- failure ??= signal.reason;
617
- child.kill("SIGKILL");
618
- };
619
- signal.addEventListener("abort", abort, { once: true });
620
- child.stdout.setEncoding("utf8");
621
- child.stderr.setEncoding("utf8");
622
- child.stdout.on("data", (chunk) => {
623
- stdout += chunk;
624
- if (stdout.length > 65536) {
625
- failure ??= /* @__PURE__ */ new Error("LibreOffice helper exceeded its response limit.");
802
+ return withNativeEngine(engine, profile, async (engine) => {
803
+ signal.throwIfAborted();
804
+ const env = nativeEnvironment(profile, engine.programDirectory);
805
+ const child = spawnNative(engine.executable, [
806
+ "--program-directory",
807
+ engine.programDirectory,
808
+ "--input-path",
809
+ input,
810
+ "--output-path",
811
+ output,
812
+ "--profile-directory",
813
+ profile,
814
+ "--max-output-bytes",
815
+ String(options.maxOutputBytes),
816
+ "--max-image-resolution",
817
+ String(options.maxImageResolution),
818
+ "--format",
819
+ operation.format,
820
+ "--recalculate",
821
+ String(operation.recalculate),
822
+ ...operation.sheet === void 0 ? [] : ["--sheet", operation.sheet],
823
+ ...fonts.flatMap((path) => ["--font-file", path])
824
+ ], env);
825
+ child.stdin.end();
826
+ let stdout = "";
827
+ let stderr = "";
828
+ let failure;
829
+ const abort = () => {
830
+ failure ??= signal.reason;
626
831
  child.kill("SIGKILL");
627
- }
628
- });
629
- child.stderr.on("data", (chunk) => {
630
- stderr = (stderr + chunk).slice(-65536);
631
- });
632
- try {
633
- const code = await new Promise((resolve, reject) => {
634
- child.once("error", (error) => {
635
- failure ??= error;
636
- });
637
- child.once("close", (code, signal) => {
638
- if (signal === "SIGXFSZ") failure ??= new ConversionError("output-too-large", "LibreOffice exceeded its output file-size limit.");
639
- if (failure) reject(failure);
640
- else resolve(code);
641
- });
832
+ };
833
+ signal.addEventListener("abort", abort, { once: true });
834
+ child.stdout.setEncoding("utf8");
835
+ child.stderr.setEncoding("utf8");
836
+ child.stdout.on("data", (chunk) => {
837
+ stdout += chunk;
838
+ if (stdout.length > 65536) {
839
+ failure ??= /* @__PURE__ */ new Error("LibreOffice helper exceeded its response limit.");
840
+ child.kill("SIGKILL");
841
+ }
842
+ });
843
+ child.stderr.on("data", (chunk) => {
844
+ stderr = (stderr + chunk).slice(-65536);
642
845
  });
643
- signal.throwIfAborted();
644
- let result;
645
846
  try {
646
- result = JSON.parse(stdout);
647
- } catch (cause) {
648
- throw new Error(`LibreOffice helper returned an invalid response (exit ${code}). ${stderr}`, { cause });
847
+ const code = await new Promise((resolve, reject) => {
848
+ child.once("error", (error) => {
849
+ failure ??= error;
850
+ });
851
+ child.once("close", (code, signal) => {
852
+ if (signal === "SIGXFSZ") failure ??= new ConversionError("output-too-large", "LibreOffice exceeded its output file-size limit.");
853
+ if (failure) reject(failure);
854
+ else resolve(code);
855
+ });
856
+ });
857
+ signal.throwIfAborted();
858
+ let result;
859
+ try {
860
+ result = JSON.parse(stdout);
861
+ } catch (cause) {
862
+ throw new Error(`LibreOffice helper returned an invalid response (exit ${code}). ${stderr}`, { cause });
863
+ }
864
+ if (code !== 0 || result.ok !== true) throw new ConversionError(failureCode(result), `LibreOffice native conversion failed: ${result.error ?? stderr}`);
865
+ } finally {
866
+ signal.removeEventListener("abort", abort);
649
867
  }
650
- if (code !== 0 || result.ok !== true) throw new ConversionError(failureCode(result), `LibreOffice native conversion failed: ${result.error ?? stderr}`);
651
- } finally {
652
- signal.removeEventListener("abort", abort);
653
- }
868
+ });
654
869
  }
655
870
  //#endregion
656
871
  //#region lib/types/png.js
@@ -787,179 +1002,216 @@ async function renderImagesWithNative(request) {
787
1002
  signal.throwIfAborted();
788
1003
  await mkdir(profile, { mode: 448 });
789
1004
  await prepareNativeFontProfile(profile, substitutions);
790
- const child = spawn(engine.executable, [
791
- "--operation",
792
- "render-images",
793
- "--program-directory",
794
- engine.programDirectory,
795
- "--input-path",
796
- inputPath,
797
- "--scratch-directory",
798
- scratch,
799
- "--profile-directory",
800
- profile,
801
- "--max-output-bytes",
802
- String(options.maxOutputBytes),
803
- "--max-image-resolution",
804
- String(options.maxImageResolution),
805
- ...fonts.flatMap((path) => ["--font-file", path])
806
- ], {
807
- stdio: [
808
- "pipe",
809
- "pipe",
810
- "pipe"
811
- ],
812
- windowsHide: true,
813
- env: nativeEnvironment(profile, engine.programDirectory)
814
- });
815
- const lines = [];
816
- const waiters = [];
817
- const output = createInterface({ input: child.stdout });
818
- output.on("line", (line) => {
819
- const waiter = waiters.shift();
820
- if (waiter) waiter(line);
821
- else lines.push(line);
822
- });
823
- let stderr = "";
824
- let stopped;
825
- child.stderr.setEncoding("utf8");
826
- child.stderr.on("data", (chunk) => {
827
- stderr = (stderr + chunk).slice(-65536);
828
- });
829
- const closed = new Promise((resolve, reject) => {
830
- child.once("error", reject);
831
- child.once("close", resolve);
832
- });
833
- const abort = () => {
834
- stopped ??= signal.reason;
835
- child.kill("SIGKILL");
836
- };
837
- signal.addEventListener("abort", abort, { once: true });
838
- const next = async () => {
1005
+ return withNativeEngine(engine, profile, async (engine) => {
839
1006
  signal.throwIfAborted();
840
- if (lines.length > 0) return lines.shift();
841
- return new Promise((resolve, reject) => {
842
- const done = (line) => {
843
- signal.removeEventListener("abort", cancel);
844
- resolve(line);
845
- };
846
- const cancel = () => {
847
- const index = waiters.indexOf(done);
848
- if (index >= 0) waiters.splice(index, 1);
849
- reject(signal.reason);
850
- };
851
- signal.addEventListener("abort", cancel, { once: true });
852
- waiters.push(done);
1007
+ const child = spawnNative(engine.executable, [
1008
+ "--operation",
1009
+ "render-images",
1010
+ "--program-directory",
1011
+ engine.programDirectory,
1012
+ "--input-path",
1013
+ inputPath,
1014
+ "--scratch-directory",
1015
+ scratch,
1016
+ "--profile-directory",
1017
+ profile,
1018
+ "--max-output-bytes",
1019
+ String(options.maxOutputBytes),
1020
+ "--max-image-resolution",
1021
+ String(options.maxImageResolution),
1022
+ ...fonts.flatMap((path) => ["--font-file", path])
1023
+ ], nativeEnvironment(profile, engine.programDirectory));
1024
+ const lines = [];
1025
+ const waiters = [];
1026
+ const output = createInterface({ input: child.stdout });
1027
+ output.on("line", (line) => {
1028
+ const waiter = waiters.shift();
1029
+ if (waiter) waiter(line);
1030
+ else lines.push(line);
853
1031
  });
854
- };
855
- const response = async () => {
856
- const line = await next();
857
- let value;
858
- try {
859
- value = JSON.parse(line);
860
- } catch (cause) {
861
- throw new Error(`LibreOffice native renderer returned invalid JSON. ${stderr}`, { cause });
862
- }
863
- if (!value.ok) throw failure(value, stderr);
864
- return value;
865
- };
866
- try {
867
- const ready = await response();
868
- if (ready.kind !== "ready") throw new Error("LibreOffice native renderer did not initialize.");
869
- const planned = plan(ready, operation);
870
- const scale = operation.dpi / 96;
871
- const selected = [];
872
- for (const region of planned.regions) if (region.sheet === void 0) selected.push(region);
873
- else {
874
- let rectangles;
1032
+ let stderr = "";
1033
+ let stopped;
1034
+ child.stderr.setEncoding("utf8");
1035
+ child.stderr.on("data", (chunk) => {
1036
+ stderr = (stderr + chunk).slice(-65536);
1037
+ });
1038
+ const closed = new Promise((resolve, reject) => {
1039
+ let failure;
1040
+ child.once("error", (error) => {
1041
+ failure = error;
1042
+ });
1043
+ child.once("close", (code) => {
1044
+ if (failure) reject(failure);
1045
+ else resolve(code);
1046
+ });
1047
+ });
1048
+ const abort = () => {
1049
+ stopped ??= signal.reason;
1050
+ child.kill("SIGKILL");
1051
+ };
1052
+ signal.addEventListener("abort", abort, { once: true });
1053
+ const next = async () => {
1054
+ signal.throwIfAborted();
1055
+ if (lines.length > 0) return lines.shift();
1056
+ return new Promise((resolve, reject) => {
1057
+ const done = (line) => {
1058
+ signal.removeEventListener("abort", cancel);
1059
+ resolve(line);
1060
+ };
1061
+ const fail = (error) => {
1062
+ const index = waiters.indexOf(done);
1063
+ if (index >= 0) waiters.splice(index, 1);
1064
+ signal.removeEventListener("abort", cancel);
1065
+ reject(error);
1066
+ };
1067
+ const cancel = () => {
1068
+ fail(signal.reason);
1069
+ };
1070
+ signal.addEventListener("abort", cancel, { once: true });
1071
+ waiters.push(done);
1072
+ closed.then((code) => {
1073
+ fail(/* @__PURE__ */ new Error(`LibreOffice native renderer exited ${code ?? child.signalCode} before responding. ${stderr}`));
1074
+ }, fail);
1075
+ });
1076
+ };
1077
+ const response = async () => {
1078
+ const line = await next();
1079
+ let value;
875
1080
  try {
876
- rectangles = splitRasterRectangle(region.rectangle, scale, {
877
- maxPixels: operation.maxPixels,
878
- maxDimension: operation.maxDimension,
879
- maxTiles: operation.maxPages - selected.length
880
- });
1081
+ value = JSON.parse(line);
881
1082
  } catch (cause) {
882
- throw new ConversionError("output-too-large", String(cause), { cause });
1083
+ throw new Error(`LibreOffice native renderer returned invalid JSON. ${stderr}`, { cause });
883
1084
  }
884
- selected.push(...rectangles.map((rectangle) => ({
885
- ...region,
886
- rectangle
887
- })));
888
- }
889
- for (const { page, rectangle } of selected) {
890
- const { width, height } = tileDimensions({
891
- pageIndex: 0,
892
- ...rectangle,
893
- scale
894
- }, [page]);
895
- if (width > operation.maxDimension || height > operation.maxDimension || width * height > operation.maxPixels) throw new ConversionError("output-too-large", "Selected page exceeds maxPixels or maxDimension; reduce DPI or raise the image limits.");
896
- }
897
- const images = [];
898
- let total = 0;
899
- for (const region of selected) {
900
- signal.throwIfAborted();
901
- const { width, height } = tileDimensions({
902
- pageIndex: 0,
903
- ...region.rectangle,
904
- scale
905
- }, [region.page]);
906
- const x = region.page.x + Math.round(region.rectangle.x * 15);
907
- const y = region.page.y + Math.round(region.rectangle.y * 15);
908
- const twipsWidth = Math.max(1, Math.round(region.rectangle.width * 15));
909
- const twipsHeight = Math.max(1, Math.round(region.rectangle.height * 15));
910
- const index = images.length + 1;
911
- child.stdin.write(`P ${index} ${region.page.part} ${width} ${height} ${x} ${y} ${twipsWidth} ${twipsHeight}\n`);
912
- const painted = await response();
913
- if (painted.kind !== "paint" || painted.index !== index || painted.width !== width || painted.height !== height) throw new Error("LibreOffice native renderer returned inconsistent tile metadata.");
914
- if (resolve(painted.path) !== resolve(scratch, `tile-${index}.rgba`)) throw new Error("LibreOffice native renderer returned a tile outside its scratch directory.");
915
- const raw = await readFile(painted.path);
916
- if (raw.byteLength !== width * height * 4) throw new Error("LibreOffice native renderer returned incomplete pixels.");
917
- const png = encodePng(width, height, ready.documentType === "pdf" ? new Uint8ClampedArray(raw) : rgbaPixels(raw, ready.tileMode));
918
- total += png.byteLength;
919
- if (total > options.maxOutputBytes) throw new ConversionError("output-too-large", "PNG batch exceeds maxOutputBytes.");
920
- const path = join(operation.outputDir, `page-${String(index).padStart(4, "0")}.png`);
921
- await writeFile(path, png, {
922
- flag: "wx",
923
- mode: 384
924
- });
925
- images.push({
926
- index,
927
- ...region.number === void 0 ? {} : { page: region.number },
928
- ...region.sheet === void 0 ? {} : {
929
- sheet: region.sheet,
930
- range: region.range,
931
- rtl: region.rtl
932
- },
933
- path,
934
- width,
935
- height,
936
- rectangle: region.rectangle,
937
- byteLength: png.byteLength
938
- });
939
- }
940
- child.stdin.end("DONE\n");
941
- if ((await response()).kind !== "done") throw new Error("LibreOffice native renderer did not finish.");
942
- const code = await closed;
943
- if (code !== 0) throw new Error(`LibreOffice native renderer exited ${code}. ${stderr}`);
944
- return {
945
- schemaVersion: 1,
946
- backend: "native",
947
- rasterEngine: ready.documentType === "pdf" ? "pdfium" : "libreoffice",
948
- source: "saved",
949
- inputPath: operation.inputPath,
950
- sourceSha256: createHash("sha256").update(source).digest("hex"),
951
- dpi: operation.dpi,
952
- pageCount: planned.count,
953
- images,
954
- missingFonts: [...missingFonts]
1085
+ if (!value.ok) throw failure(value, stderr);
1086
+ return value;
955
1087
  };
956
- } finally {
957
- signal.removeEventListener("abort", abort);
958
- output.close();
959
- if (child.exitCode === null) child.kill("SIGKILL");
960
- await closed.catch(() => {});
961
- if (stopped !== void 0) throw stopped;
962
- }
1088
+ try {
1089
+ const ready = await response();
1090
+ if (ready.kind !== "ready") throw new Error("LibreOffice native renderer did not initialize.");
1091
+ const planned = plan(ready, operation);
1092
+ const scale = operation.dpi / 96;
1093
+ const selected = [];
1094
+ for (const region of planned.regions) if (region.sheet === void 0) selected.push(region);
1095
+ else {
1096
+ let rectangles;
1097
+ try {
1098
+ rectangles = splitRasterRectangle(region.rectangle, scale, {
1099
+ maxPixels: operation.maxPixels,
1100
+ maxDimension: operation.maxDimension,
1101
+ maxTiles: operation.maxPages - selected.length
1102
+ });
1103
+ } catch (cause) {
1104
+ throw new ConversionError("output-too-large", String(cause), { cause });
1105
+ }
1106
+ selected.push(...rectangles.map((rectangle) => ({
1107
+ ...region,
1108
+ rectangle
1109
+ })));
1110
+ }
1111
+ for (const { page, rectangle } of selected) {
1112
+ const { width, height } = tileDimensions({
1113
+ pageIndex: 0,
1114
+ ...rectangle,
1115
+ scale
1116
+ }, [page]);
1117
+ if (width > operation.maxDimension || height > operation.maxDimension || width * height > operation.maxPixels) throw new ConversionError("output-too-large", "Selected page exceeds maxPixels or maxDimension; reduce DPI or raise the image limits.");
1118
+ }
1119
+ const images = [];
1120
+ let total = 0;
1121
+ for (const region of selected) {
1122
+ signal.throwIfAborted();
1123
+ const { width, height } = tileDimensions({
1124
+ pageIndex: 0,
1125
+ ...region.rectangle,
1126
+ scale
1127
+ }, [region.page]);
1128
+ const x = region.page.x + Math.round(region.rectangle.x * 15);
1129
+ const y = region.page.y + Math.round(region.rectangle.y * 15);
1130
+ const twipsWidth = Math.max(1, Math.round(region.rectangle.width * 15));
1131
+ const twipsHeight = Math.max(1, Math.round(region.rectangle.height * 15));
1132
+ const index = images.length + 1;
1133
+ child.stdin.write(`P ${index} ${region.page.part} ${width} ${height} ${x} ${y} ${twipsWidth} ${twipsHeight}\n`);
1134
+ const painted = await response();
1135
+ if (painted.kind !== "paint" || painted.index !== index || painted.width !== width || painted.height !== height) throw new Error("LibreOffice native renderer returned inconsistent tile metadata.");
1136
+ if (resolve(painted.path) !== resolve(scratch, `tile-${index}.rgba`)) throw new Error("LibreOffice native renderer returned a tile outside its scratch directory.");
1137
+ const raw = await readFile(painted.path);
1138
+ if (raw.byteLength !== width * height * 4) throw new Error("LibreOffice native renderer returned incomplete pixels.");
1139
+ const rgba = ready.documentType === "pdf" ? new Uint8ClampedArray(raw) : rgbaPixels(raw, ready.tileMode);
1140
+ if (region.rtl) unmirrorRtlTile({
1141
+ width,
1142
+ height,
1143
+ rgba
1144
+ });
1145
+ const png = encodePng(width, height, rgba);
1146
+ total += png.byteLength;
1147
+ if (total > options.maxOutputBytes) throw new ConversionError("output-too-large", "PNG batch exceeds maxOutputBytes.");
1148
+ const path = join(operation.outputDir, `page-${String(index).padStart(4, "0")}.png`);
1149
+ await writeFile(path, png, {
1150
+ flag: "wx",
1151
+ mode: 384
1152
+ });
1153
+ images.push({
1154
+ index,
1155
+ ...region.number === void 0 ? {} : { page: region.number },
1156
+ ...region.sheet === void 0 ? {} : {
1157
+ sheet: region.sheet,
1158
+ range: region.range,
1159
+ rtl: region.rtl
1160
+ },
1161
+ path,
1162
+ width,
1163
+ height,
1164
+ rectangle: region.rectangle,
1165
+ byteLength: png.byteLength
1166
+ });
1167
+ }
1168
+ child.stdin.end("DONE\n");
1169
+ if ((await response()).kind !== "done") throw new Error("LibreOffice native renderer did not finish.");
1170
+ const code = await closed;
1171
+ if (code !== 0) throw new Error(`LibreOffice native renderer exited ${code}. ${stderr}`);
1172
+ return {
1173
+ schemaVersion: 1,
1174
+ backend: "native",
1175
+ rasterEngine: ready.documentType === "pdf" ? "pdfium" : "libreoffice",
1176
+ source: "saved",
1177
+ inputPath: operation.inputPath,
1178
+ sourceSha256: createHash("sha256").update(source).digest("hex"),
1179
+ dpi: operation.dpi,
1180
+ pageCount: planned.count,
1181
+ images,
1182
+ missingFonts: [...missingFonts]
1183
+ };
1184
+ } finally {
1185
+ signal.removeEventListener("abort", abort);
1186
+ output.close();
1187
+ if (child.exitCode === null) child.kill("SIGKILL");
1188
+ await closed.catch(() => {});
1189
+ if (stopped !== void 0) throw stopped;
1190
+ }
1191
+ });
1192
+ }
1193
+ //#endregion
1194
+ //#region lib/types/font-file-identity.js
1195
+ /** Preserve 64-bit device and inode values without JavaScript integer rounding. */
1196
+ function fontFileIdentity(status) {
1197
+ return {
1198
+ dev: status.dev.toString(),
1199
+ ino: status.ino.toString(),
1200
+ size: Number(status.size),
1201
+ mtimeMs: Number(status.mtimeNs) / 1e6,
1202
+ ctimeMs: Number(status.ctimeNs) / 1e6
1203
+ };
1204
+ }
1205
+ /** Compare a source descriptor's exact identity with its indexed font metadata. */
1206
+ function matchesFontFile(status, expected) {
1207
+ const current = fontFileIdentity(status);
1208
+ return [
1209
+ "dev",
1210
+ "ino",
1211
+ "size",
1212
+ "mtimeMs",
1213
+ "ctimeMs"
1214
+ ].every((key) => current[key] === expected[key]);
963
1215
  }
964
1216
  //#endregion
965
1217
  //#region lib/types/fonts.js
@@ -1212,16 +1464,16 @@ function resolveOptions(input = {}) {
1212
1464
  /** Resolve installed, version-matched engine packages without downloads or compilation. */
1213
1465
  const require = createRequire(import.meta.url);
1214
1466
  /** Node API release version returned by runtime discovery. */
1215
- const ENGINE_VERSION = "0.1.2";
1467
+ const ENGINE_VERSION = "0.1.5";
1216
1468
  /** Exact compatible engine versions; unchanged platforms retain their published packages. */
1217
1469
  const ENGINE_VERSIONS = Object.freeze({
1218
- "darwin-arm64": "0.1.1",
1219
- "darwin-x64": "0.1.1",
1470
+ "darwin-arm64": "0.1.5",
1471
+ "darwin-x64": "0.1.5",
1220
1472
  "linux-arm64-glibc": "0.1.1",
1221
1473
  "linux-x64-glibc": "0.1.1",
1222
- "win32-arm64": "0.1.2",
1223
- "win32-x64": "0.1.2",
1224
- wasm: "0.1.1"
1474
+ "win32-arm64": "0.1.5",
1475
+ "win32-x64": "0.1.5",
1476
+ wasm: "0.1.5"
1225
1477
  });
1226
1478
  /** npm scope and name prefix shared by the engine packages this adapter installs. */
1227
1479
  const ENGINE_PREFIX = "@deepseek-ai/libreoffice-kit";
@@ -1528,14 +1780,8 @@ var FontSnapshotState = class {
1528
1780
  async function validateFontSnapshot(snapshot) {
1529
1781
  await Promise.all(snapshot.records.map(async (record) => {
1530
1782
  try {
1531
- const current = await lstat(record.path);
1532
- if (current.isFile() && [
1533
- "dev",
1534
- "ino",
1535
- "size",
1536
- "mtimeMs",
1537
- "ctimeMs"
1538
- ].every((key) => current[key] === record[key])) return;
1783
+ const current = await lstat(record.path, { bigint: true });
1784
+ if (current.isFile() && matchesFontFile(current, record)) return;
1539
1785
  } catch {}
1540
1786
  throw new ConversionError("failed", "A system font changed during conversion; retry the operation.");
1541
1787
  }));
@@ -1942,7 +2188,7 @@ async function main() {
1942
2188
  "convert",
1943
2189
  "recalculate",
1944
2190
  "render"
1945
- ].includes(command)) throw new TypeError("Usage: libreoffice-kit capabilities --json | render --input <file> --output-dir <fresh-directory> [--pages all|1,3] [--sheet <name> --range A1:D20] [--dpi 144] | convert --input <file> --output <file> [--sheet <name>] | recalculate --input <workbook> --output <xlsx|ods>");
2191
+ ].includes(command)) throw new TypeError("Usage: dsoffice capabilities --json | render --input <file> --output-dir <fresh-directory> [--pages all|1,3] [--sheet <name> --range A1:D20] [--dpi 144] | convert --input <file> --output <file> [--sheet <name>] | recalculate --input <workbook> --output <xlsx|ods>");
1946
2192
  if (command === "capabilities") {
1947
2193
  if (Object.keys(values).some((key) => key !== "json")) throw new TypeError("capabilities accepts only --json.");
1948
2194
  process.stdout.write(`${JSON.stringify({