@songtonyli/dsh-cli 0.1.58 → 0.1.60

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 +1 -1
  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 +8 -8
  38. package/node_modules/@deepseek-ai/dsh-tui-app/README.md +13 -7
  39. package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +13 -7
  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 +2403 -2033
  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
@@ -0,0 +1,227 @@
1
+ import { execFile, spawn } from "node:child_process";
2
+ import { randomUUID } from "node:crypto";
3
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
4
+ import { constants, tmpdir } from "node:os";
5
+ import { join } from "node:path";
6
+ /** Prefix of the single stderr line the shim writes for {@link SHIM_FAILURE_EXIT}. */
7
+ const SHIM_FAILURE_PREFIX = "dsh-container-exec: ";
8
+ /**
9
+ * Decode the argument list produced by {@link encodeShimArgs}.
10
+ * @param args - the shim process arguments after the entry path.
11
+ * @returns the decoded invocation.
12
+ * @throws {Error} when the list is malformed or the argv is empty.
13
+ */
14
+ function parseShimArgs(args) {
15
+ const [executable, container, denylist, separator, ...argv] = args;
16
+ if (executable === void 0 || container === void 0 || denylist === void 0 || separator !== "--" || argv.length === 0) throw new Error("usage: exec-shim <executable> <container> <denylist> -- <argv...>");
17
+ return {
18
+ executable,
19
+ container,
20
+ denylist: denylist === "" ? [] : denylist.split(","),
21
+ argv
22
+ };
23
+ }
24
+ /**
25
+ * Whether the denylist withholds `key` from the guest.
26
+ * @param key - an environment variable name.
27
+ * @param denylist - name globs where `*` matches any run of characters; matching ignores case.
28
+ * @returns true when `key` is withheld.
29
+ */
30
+ function isDenied(key, denylist) {
31
+ return denylist.some((entry) => new RegExp(`^${entry.split("*").map((part) => part.replaceAll(/[.+?^${}()|[\]\\]/gu, String.raw`\$&`)).join(".*")}$`, "iu").test(key));
32
+ }
33
+ /** A URL carrying `user:password@` credentials, such as an authenticated proxy. */
34
+ const URL_CREDENTIALS = /:\/\/[^/\s@]*:[^/\s@]*@/u;
35
+ /**
36
+ * The `--env-file` text for `env`: one `KEY=value` line per forwarded
37
+ * variable. Denied keys and values embedding URL credentials are withheld;
38
+ * names outside POSIX identifier syntax and values containing a line break are
39
+ * omitted because the file format cannot carry them.
40
+ * @param env - the shim's environment.
41
+ * @param denylist - keys withheld from the guest.
42
+ * @returns the file contents.
43
+ */
44
+ function envFileText(env, denylist) {
45
+ let text = "";
46
+ for (const [key, value] of Object.entries(env)) {
47
+ if (value === void 0 || isDenied(key, denylist) || URL_CREDENTIALS.test(value)) continue;
48
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(key) || /[\r\n]/u.test(value)) continue;
49
+ text += `${key}=${value}\n`;
50
+ }
51
+ return text;
52
+ }
53
+ /** Guest paths of one run's process-group id file and start sentinel. */
54
+ function tokenPaths(token) {
55
+ return {
56
+ pid: `/run/dsh-${token}.pid`,
57
+ started: `/run/dsh-${token}.started`
58
+ };
59
+ }
60
+ /**
61
+ * The guest `sh -c` wrapper: records its process-group id and a start
62
+ * sentinel, runs the argv, and removes both files after a zero exit.
63
+ * @param token - the run's unique token.
64
+ * @returns the script text.
65
+ */
66
+ function wrapperScript(token) {
67
+ const { pid, started } = tokenPaths(token);
68
+ return `echo $$ > ${pid}; : > ${started}; "$@"; s=$?; if [ $s -eq 0 ]; then rm -f ${pid} ${started}; fi; exit $s`;
69
+ }
70
+ /**
71
+ * The `container exec` arguments that run the caller's argv in its own guest session.
72
+ * @param args - the shim invocation.
73
+ * @param run - the host working directory, environment file, TTY state, and run token.
74
+ * @returns the arguments after the `container` executable.
75
+ */
76
+ function execArgs(args, run) {
77
+ return [
78
+ "exec",
79
+ "-i",
80
+ ...run.tty ? ["-t"] : [],
81
+ "-w",
82
+ run.cwd,
83
+ "--env-file",
84
+ run.envFile,
85
+ args.container,
86
+ "setsid",
87
+ "-w",
88
+ "sh",
89
+ "-c",
90
+ wrapperScript(run.token),
91
+ "sh",
92
+ ...args.argv
93
+ ];
94
+ }
95
+ /**
96
+ * The `container exec` arguments that deliver `signal` to the run's guest process group.
97
+ * @param container - the container name.
98
+ * @param token - the run's token.
99
+ * @param signal - the host signal to deliver.
100
+ * @returns the arguments after the `container` executable.
101
+ */
102
+ function killArgs(container, token, signal) {
103
+ return [
104
+ "exec",
105
+ container,
106
+ "sh",
107
+ "-c",
108
+ `kill -${signal.slice(3)} -$(cat ${tokenPaths(token).pid}) 2>/dev/null; true`
109
+ ];
110
+ }
111
+ /**
112
+ * The `container exec` arguments that remove the run's token files and exit
113
+ * zero only when the start sentinel existed.
114
+ * @param container - the container name.
115
+ * @param token - the run's token.
116
+ * @returns the arguments after the `container` executable.
117
+ */
118
+ function settleArgs(container, token) {
119
+ const { pid, started } = tokenPaths(token);
120
+ return [
121
+ "exec",
122
+ container,
123
+ "sh",
124
+ "-c",
125
+ `test -e ${started}; s=$?; rm -f ${pid} ${started}; exit $s`
126
+ ];
127
+ }
128
+ /** The exit status a shell reports for a process killed by `signal`. */
129
+ function signalExit(signal) {
130
+ return 128 + constants.signals[signal];
131
+ }
132
+ /**
133
+ * Run the caller's argv in the guest and return the shim's exit status: the
134
+ * command's status, `128 + n` after a forwarded or terminating signal, or
135
+ * {@link SHIM_FAILURE_EXIT} when the runtime failed before the command started.
136
+ * @param args - the decoded invocation.
137
+ * @param deps - process facilities.
138
+ * @returns the exit status.
139
+ */
140
+ async function runShim(args, deps) {
141
+ const envFile = deps.writeEnvFile(envFileText(deps.env, args.denylist));
142
+ let forwarded;
143
+ const unsubscribe = deps.onSignal((signal) => {
144
+ forwarded ??= signal;
145
+ deps.run(args.executable, killArgs(args.container, deps.token, signal));
146
+ });
147
+ try {
148
+ const child = deps.spawn(args.executable, execArgs(args, {
149
+ cwd: deps.cwd,
150
+ envFile,
151
+ tty: deps.tty,
152
+ token: deps.token
153
+ }));
154
+ const exit = await new Promise((resolve, reject) => {
155
+ child.once("error", reject);
156
+ child.once("close", (code, signal) => {
157
+ resolve(code ?? signalExit(signal));
158
+ });
159
+ });
160
+ if (exit === 0 && forwarded === void 0) return 0;
161
+ const started = await deps.run(args.executable, settleArgs(args.container, deps.token));
162
+ if (forwarded !== void 0) return signalExit(forwarded);
163
+ if (started === 0) return exit;
164
+ deps.stderr(`${SHIM_FAILURE_PREFIX}the container runtime failed before the command started (container exec exited ${exit})\n`);
165
+ return 125;
166
+ } catch (error) {
167
+ deps.stderr(`${SHIM_FAILURE_PREFIX}${error.message}\n`);
168
+ return 125;
169
+ } finally {
170
+ unsubscribe();
171
+ deps.removeEnvFile(envFile);
172
+ }
173
+ }
174
+ //#endregion
175
+ //#region lib/types/exec-shim.js
176
+ /**
177
+ * Exec-shim process entry: binds {@link runShim} to Node's process, child
178
+ * process, and filesystem facilities. The provider's confined argv runs this
179
+ * file under plain Node (built `lib/`) or tsx (source checkout).
180
+ * @module @deepseek-ai/dsh-sandbox-apple-container/exec-shim
181
+ */
182
+ /* v8 ignore file -- a child-process entry; tests/shim.spec.ts covers runShim and the real-runtime e2e covers this binding. */
183
+ const SIGNALS = [
184
+ "SIGTERM",
185
+ "SIGINT",
186
+ "SIGHUP"
187
+ ];
188
+ try {
189
+ const args = parseShimArgs(process.argv.slice(2));
190
+ process.exitCode = await runShim(args, {
191
+ token: randomUUID(),
192
+ cwd: process.cwd(),
193
+ env: process.env,
194
+ tty: process.stdin.isTTY,
195
+ spawn: (executable, spawnArgs) => spawn(executable, spawnArgs, { stdio: "inherit" }),
196
+ run: (executable, runArgs) => new Promise((resolve) => {
197
+ execFile(executable, runArgs, (error) => {
198
+ resolve(error === null ? 0 : typeof error.code === "number" ? error.code : 125);
199
+ });
200
+ }),
201
+ writeEnvFile: (text) => {
202
+ const path = join(mkdtempSync(join(tmpdir(), "dsh-container-env-")), "env");
203
+ writeFileSync(path, text, { mode: 384 });
204
+ return path;
205
+ },
206
+ removeEnvFile: (path) => {
207
+ rmSync(join(path, ".."), {
208
+ recursive: true,
209
+ force: true
210
+ });
211
+ },
212
+ onSignal: (handler) => {
213
+ for (const signal of SIGNALS) process.on(signal, handler);
214
+ return () => {
215
+ for (const signal of SIGNALS) process.off(signal, handler);
216
+ };
217
+ },
218
+ stderr: (text) => {
219
+ process.stderr.write(text);
220
+ }
221
+ });
222
+ } catch (error) {
223
+ process.stderr.write(`${SHIM_FAILURE_PREFIX}${error instanceof Error ? error.message : String(error)}\n`);
224
+ process.exitCode = 125;
225
+ }
226
+ //#endregion
227
+ export {};