@thready-web/dsh-bot-plugin 0.1.0-beta.1 → 0.1.0-beta.11

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 (160) hide show
  1. package/README.md +109 -1
  2. package/client.js +646 -621
  3. package/dist/approvals.js +160 -0
  4. package/dist/authorization.js +225 -0
  5. package/dist/canvas-http.js +248 -0
  6. package/dist/canvas-skills.js +56 -0
  7. package/dist/canvas-store.js +794 -0
  8. package/dist/canvas-tools.js +211 -0
  9. package/dist/cli.js +32 -12
  10. package/dist/context.js +60 -17
  11. package/dist/cron.js +1 -1
  12. package/dist/cua-access.js +79 -0
  13. package/dist/desk.js +314 -37
  14. package/dist/engine.js +178 -84
  15. package/dist/fs-safe.js +1 -1
  16. package/dist/host.js +1 -0
  17. package/dist/http-plugin.js +14 -4
  18. package/dist/http.js +402 -85
  19. package/dist/inbox.js +51 -40
  20. package/dist/index.js +201 -47
  21. package/dist/live-diff.js +3 -1
  22. package/dist/live-snapshot.js +2 -13
  23. package/dist/log/canonical.js +37 -0
  24. package/dist/log/plan.js +62 -0
  25. package/dist/log/routes.js +144 -0
  26. package/dist/log/snapshot-service.js +76 -0
  27. package/dist/log/source.js +173 -0
  28. package/dist/memory-catalog.js +798 -0
  29. package/dist/permissions.js +86 -0
  30. package/dist/provision.js +2 -0
  31. package/dist/questions.js +407 -0
  32. package/dist/runtime-registry.js +4 -4
  33. package/dist/session-files.js +2 -2
  34. package/dist/session-previews.js +5 -1
  35. package/dist/store.js +20 -5
  36. package/dist/tools.js +150 -32
  37. package/dist/triggers.js +83 -39
  38. package/dist/work-admit.js +222 -25
  39. package/dist/work-child.js +17 -9
  40. package/dist/work-http.js +52 -2
  41. package/dist/work-ledger.js +256 -16
  42. package/dist/work-mock-host.js +9 -6
  43. package/dist/work-mock.js +29 -19
  44. package/dist/work-tickets.js +423 -96
  45. package/dist/work-tools.js +43 -6
  46. package/dist/work-worker.js +1033 -207
  47. package/dist/workspace-files.js +319 -0
  48. package/dist/workspace-image.js +91 -0
  49. package/fixtures/mock-llm.mjs +17 -2
  50. package/package.json +16 -5
  51. package/public/assets/SourceEditor-CJwK846Z.css +1 -0
  52. package/public/assets/SourceEditor-uu0G7jsM.js +669 -0
  53. package/public/assets/abap-CRCWOmpq.js +1 -0
  54. package/public/assets/apex-DnsZk_dE.js +1 -0
  55. package/public/assets/azcli-1IWB1ccx.js +1 -0
  56. package/public/assets/bat-DPkNLes8.js +1 -0
  57. package/public/assets/bicep-Corcdgou.js +2 -0
  58. package/public/assets/cameligo-CGrWLZr3.js +1 -0
  59. package/public/assets/clojure-D9WOWImG.js +1 -0
  60. package/public/assets/codicon-DCmgc-ay.ttf +0 -0
  61. package/public/assets/coffee-B7EJu28W.js +1 -0
  62. package/public/assets/cpp-SEyurbux.js +1 -0
  63. package/public/assets/csharp-BoL64M5l.js +1 -0
  64. package/public/assets/csp-C46ZqvIl.js +1 -0
  65. package/public/assets/css-DQU6DXDx.js +3 -0
  66. package/public/assets/css.worker-DYpkewsP.js +79 -0
  67. package/public/assets/cssMode-C5DAFF5H.js +4 -0
  68. package/public/assets/cypher-D84EuPTj.js +1 -0
  69. package/public/assets/dart-D8lhlL1r.js +1 -0
  70. package/public/assets/dockerfile-DLk6rpji.js +1 -0
  71. package/public/assets/ecl-BO6FnfXk.js +1 -0
  72. package/public/assets/editor.worker-B4pQIWZD.js +12 -0
  73. package/public/assets/elixir-BRjLKONM.js +1 -0
  74. package/public/assets/flow9-Cac8vKd7.js +1 -0
  75. package/public/assets/freemarker2-DExNwSiZ.js +3 -0
  76. package/public/assets/fsharp-fd1GTHhf.js +1 -0
  77. package/public/assets/go-O9LJTZXk.js +1 -0
  78. package/public/assets/graphql-LQdxqEYJ.js +1 -0
  79. package/public/assets/handlebars-BK7YAvpQ.js +1 -0
  80. package/public/assets/hcl-DxDQ3s82.js +1 -0
  81. package/public/assets/html-CdDm_zae.js +1 -0
  82. package/public/assets/html.worker-tnXziJOq.js +456 -0
  83. package/public/assets/htmlMode-CLdn9oa1.js +4 -0
  84. package/public/assets/index-BB-QDSf2.css +1 -0
  85. package/public/assets/index-CsX-_qbo.js +62 -0
  86. package/public/assets/ini-BvajGCUy.js +1 -0
  87. package/public/assets/java-SYsfObOQ.js +1 -0
  88. package/public/assets/javascript-mLl83_3W.js +1 -0
  89. package/public/assets/json.worker-aFakAbRR.js +44 -0
  90. package/public/assets/jsonMode-B1-bihFd.js +10 -0
  91. package/public/assets/julia-DQXNmw_w.js +1 -0
  92. package/public/assets/kotlin-qQ0MG-9I.js +1 -0
  93. package/public/assets/less-GGFNNJHn.js +2 -0
  94. package/public/assets/lexon-Canl7DCW.js +1 -0
  95. package/public/assets/liquid-Cv8m0HUb.js +1 -0
  96. package/public/assets/lua-D28Ae8-K.js +1 -0
  97. package/public/assets/m3-DPitgjJI.js +1 -0
  98. package/public/assets/markdown-B811l8j2.js +1 -0
  99. package/public/assets/mdx-Q12b91rL.js +1 -0
  100. package/public/assets/mips-CdjsipkG.js +1 -0
  101. package/public/assets/msdax-CYqgjx_P.js +1 -0
  102. package/public/assets/mysql-BHd6q0vd.js +1 -0
  103. package/public/assets/objective-c-B1aVtJYH.js +1 -0
  104. package/public/assets/pascal-BhNW15KB.js +1 -0
  105. package/public/assets/pascaligo-5jv8CcQD.js +1 -0
  106. package/public/assets/perl-DlYyT36c.js +1 -0
  107. package/public/assets/pgsql-Dy0bjov7.js +1 -0
  108. package/public/assets/php-120yhfDK.js +1 -0
  109. package/public/assets/pla-CjnFlu4u.js +1 -0
  110. package/public/assets/postiats-CQpG440k.js +1 -0
  111. package/public/assets/powerquery-DdJtto1Z.js +1 -0
  112. package/public/assets/powershell-Bu_VLpJB.js +1 -0
  113. package/public/assets/protobuf-IBS6jZEB.js +2 -0
  114. package/public/assets/pug-kFxLfcjb.js +1 -0
  115. package/public/assets/python-Kda811W0.js +1 -0
  116. package/public/assets/qsharp-q7JyzKFN.js +1 -0
  117. package/public/assets/r-BIFz-_sK.js +1 -0
  118. package/public/assets/razor-CRuCpdOW.js +1 -0
  119. package/public/assets/redis-CHOsPHWR.js +1 -0
  120. package/public/assets/redshift-CBifECDb.js +1 -0
  121. package/public/assets/restructuredtext-CghPJEOS.js +1 -0
  122. package/public/assets/ruby-CYWGW-b1.js +1 -0
  123. package/public/assets/rust-DMDD0SHb.js +1 -0
  124. package/public/assets/sb-BYAiYHFx.js +1 -0
  125. package/public/assets/scala-Bqvq8jcR.js +1 -0
  126. package/public/assets/scheme-Dhb-2j9p.js +1 -0
  127. package/public/assets/scss-CTwUZ5N7.js +3 -0
  128. package/public/assets/shell-CsDZo4DB.js +1 -0
  129. package/public/assets/solidity-CME5AdoB.js +1 -0
  130. package/public/assets/sophia-RYC1BQQz.js +1 -0
  131. package/public/assets/sparql-KEyrF7De.js +1 -0
  132. package/public/assets/sql-BdTr02Mf.js +1 -0
  133. package/public/assets/st-C7iG7M4S.js +1 -0
  134. package/public/assets/swift-D7IUmUK8.js +1 -0
  135. package/public/assets/systemverilog-DgMryOEJ.js +1 -0
  136. package/public/assets/tcl-PloMZuKG.js +1 -0
  137. package/public/assets/ts.worker-Bij5J2kb.js +51316 -0
  138. package/public/assets/tsMode-BGHcz-M3.js +11 -0
  139. package/public/assets/twig-BfRIq3la.js +1 -0
  140. package/public/assets/typescript-Db1e0DCT.js +1 -0
  141. package/public/assets/typespec-CzxlYoT_.js +1 -0
  142. package/public/assets/vb-BwAE3J76.js +1 -0
  143. package/public/assets/wgsl-B_1kOXbF.js +298 -0
  144. package/public/assets/xml-H3zzFmnd.js +1 -0
  145. package/public/assets/yaml-BQrKvmTF.js +1 -0
  146. package/public/index.html +2 -2
  147. package/skills/ui/baseline-ui/SKILL.md +85 -0
  148. package/skills/ui/bencium-innovative-ux-designer/SKILL.md +227 -0
  149. package/skills/ui/better-ui/SKILL.md +133 -0
  150. package/skills/ui/design-lab/SKILL.md +920 -0
  151. package/skills/ui/frontend-design/SKILL.md +71 -0
  152. package/skills/ui/impeccable/SKILL.md +93 -0
  153. package/skills/ui/interface-design/SKILL.md +320 -0
  154. package/skills/ui/sources.json +66 -0
  155. package/skills/ui/ui-design/SKILL.md +35 -0
  156. package/skills/ui/ui-skills-root/SKILL.md +59 -0
  157. package/skills/ui/visual-design-foundations/SKILL.md +318 -0
  158. package/skills/ui/web-design-guidelines/SKILL.md +39 -0
  159. package/public/assets/index-Be82iGwe.css +0 -1
  160. package/public/assets/index-ByU9a3Lh.js +0 -61
@@ -0,0 +1,319 @@
1
+ /** Workbench file browser. Workspace and the process home are readable. DSH_HOME stays closed. */
2
+ import { randomBytes } from 'node:crypto';
3
+ import { closeSync, constants, createReadStream, createWriteStream, fstatSync, lstatSync, openSync, readdirSync, readSync, realpathSync, renameSync, unlinkSync, } from 'node:fs';
4
+ import { basename, join, resolve, sep } from 'node:path';
5
+ export const MAX_UPLOAD_BYTES = 50 * 1024 * 1024;
6
+ export const MAX_TEXT_BYTES = 1024 * 1024;
7
+ /**
8
+ * Real paths the browser may use. A workspace that is DSH_HOME, or that contains it, is unusable.
9
+ * The workspace directory itself stays allowed when it lives at <DSH_HOME>/workspace.
10
+ */
11
+ export function resolveFileRoots(input) {
12
+ const home = realDir(input.home);
13
+ const dshHome = realDir(input.dshHome);
14
+ const workspaceRaw = realDir(input.workspace);
15
+ let workspace = workspaceRaw;
16
+ let workspaceReason = workspaceRaw ? '' : 'missing';
17
+ if (workspaceRaw && dshHome && (workspaceRaw === dshHome || inside(workspaceRaw, dshHome))) {
18
+ workspace = null;
19
+ workspaceReason = 'overlap';
20
+ }
21
+ return { roots: { workspace, workspaceReason, home }, dshHome };
22
+ }
23
+ export function listDirectory(filePath, access) {
24
+ const located = locate(filePath, access);
25
+ if (!located.ok)
26
+ return located;
27
+ let stat;
28
+ try {
29
+ stat = lstatSync(located.value.path);
30
+ }
31
+ catch {
32
+ return { ok: false, error: 'missing' };
33
+ }
34
+ if (!stat.isDirectory())
35
+ return { ok: false, error: 'not_directory' };
36
+ let names;
37
+ try {
38
+ names = readdirSync(located.value.path);
39
+ }
40
+ catch {
41
+ return { ok: false, error: 'denied' };
42
+ }
43
+ const items = [];
44
+ for (const name of names) {
45
+ if (name.startsWith('.upload-') && name.endsWith('.tmp'))
46
+ continue;
47
+ const child = join(located.value.path, name);
48
+ let childStat;
49
+ try {
50
+ childStat = lstatSync(child);
51
+ }
52
+ catch {
53
+ continue;
54
+ }
55
+ let real;
56
+ try {
57
+ real = realpathSync(child);
58
+ }
59
+ catch {
60
+ continue;
61
+ }
62
+ if (!rootOf(real, access))
63
+ continue;
64
+ const mtime = new Date(childStat.mtimeMs).toISOString();
65
+ if (childStat.isSymbolicLink()) {
66
+ items.push({ name, kind: 'link', size: 0, mtime });
67
+ continue;
68
+ }
69
+ if (childStat.isDirectory()) {
70
+ items.push({ name, kind: 'dir', size: 0, mtime });
71
+ continue;
72
+ }
73
+ if (childStat.isFile())
74
+ items.push({ name, kind: 'file', size: childStat.size, mtime });
75
+ }
76
+ items.sort((a, b) => {
77
+ if (a.kind === 'dir' && b.kind !== 'dir')
78
+ return -1;
79
+ if (a.kind !== 'dir' && b.kind === 'dir')
80
+ return 1;
81
+ return a.name.localeCompare(b.name);
82
+ });
83
+ return { ok: true, value: { path: located.value.path, root: located.value.root, items } };
84
+ }
85
+ export function readFileText(filePath, access) {
86
+ const opened = openFile(filePath, access);
87
+ if (!opened.ok)
88
+ return opened;
89
+ try {
90
+ const size = opened.value.size;
91
+ if (size === 0)
92
+ return { ok: true, value: { text: '', eof: true } };
93
+ const bytes = readFd(opened.value.fd, Math.min(size, MAX_TEXT_BYTES));
94
+ if (bytes.includes(0))
95
+ return { ok: false, error: 'binary' };
96
+ return { ok: true, value: { text: bytes.toString('utf8'), eof: size <= MAX_TEXT_BYTES } };
97
+ }
98
+ finally {
99
+ closeSync(opened.value.fd);
100
+ }
101
+ }
102
+ export function openDownload(filePath, access) {
103
+ const opened = openFile(filePath, access);
104
+ if (!opened.ok)
105
+ return opened;
106
+ const stream = createReadStream('', { fd: opened.value.fd, autoClose: true, start: 0 });
107
+ return {
108
+ ok: true,
109
+ value: { name: basename(opened.value.path), size: opened.value.size, stream },
110
+ };
111
+ }
112
+ /**
113
+ * Write one file into an allowed directory. `maxBytes` stops the copy without destroying the request socket.
114
+ */
115
+ export function saveUploadFile(dir, name, source, access, options) {
116
+ const safe = safeFileName(name);
117
+ if (!safe)
118
+ return Promise.resolve({ ok: false, error: 'bad_name' });
119
+ const located = locate(dir, access);
120
+ if (!located.ok)
121
+ return Promise.resolve(located);
122
+ let dirStat;
123
+ try {
124
+ dirStat = lstatSync(located.value.path);
125
+ }
126
+ catch {
127
+ return Promise.resolve({ ok: false, error: 'missing' });
128
+ }
129
+ if (!dirStat.isDirectory())
130
+ return Promise.resolve({ ok: false, error: 'not_directory' });
131
+ const dest = join(located.value.path, safe);
132
+ let existing = null;
133
+ try {
134
+ existing = lstatSync(dest);
135
+ }
136
+ catch {
137
+ existing = null;
138
+ }
139
+ if (existing?.isSymbolicLink())
140
+ return Promise.resolve({ ok: false, error: 'denied' });
141
+ if (existing?.isDirectory())
142
+ return Promise.resolve({ ok: false, error: 'exists' });
143
+ if (existing && !options.overwrite)
144
+ return Promise.resolve({ ok: false, error: 'exists' });
145
+ const tmp = join(located.value.path, `.upload-${randomBytes(8).toString('hex')}.tmp`);
146
+ return writeBounded(source, tmp, options.maxBytes).then(written => {
147
+ if (!written.ok)
148
+ return written;
149
+ try {
150
+ renameSync(tmp, dest);
151
+ }
152
+ catch {
153
+ try {
154
+ unlinkSync(tmp);
155
+ }
156
+ catch {
157
+ /* the failed temp is hidden from listings */
158
+ }
159
+ return { ok: false, error: 'denied' };
160
+ }
161
+ return { ok: true, value: { path: dest, size: written.value } };
162
+ });
163
+ }
164
+ export function safeFileName(value) {
165
+ if (value.length === 0 || value.length > 255)
166
+ return null;
167
+ if (value === '.' || value === '..')
168
+ return null;
169
+ if (/[/\\\u0000]/.test(value))
170
+ return null;
171
+ if (basename(value) !== value)
172
+ return null;
173
+ return value;
174
+ }
175
+ function realDir(filePath) {
176
+ if (filePath.trim() === '')
177
+ return null;
178
+ try {
179
+ return realpathSync(resolve(filePath));
180
+ }
181
+ catch {
182
+ return null;
183
+ }
184
+ }
185
+ function inside(root, target) {
186
+ return target === root || target.startsWith(root + sep);
187
+ }
188
+ function rootOf(filePath, access) {
189
+ const inWorkspace = access.roots.workspace != null && inside(access.roots.workspace, filePath);
190
+ const inHome = access.roots.home != null && inside(access.roots.home, filePath);
191
+ if (!inWorkspace && !inHome)
192
+ return null;
193
+ if (access.dshHome && inside(access.dshHome, filePath) && !inWorkspace)
194
+ return null;
195
+ return inWorkspace ? 'workspace' : 'home';
196
+ }
197
+ function locate(filePath, access) {
198
+ if (filePath.length === 0 || filePath.length > 4096 || /[\u0000]/.test(filePath) || !filePath.startsWith('/')) {
199
+ return { ok: false, error: 'bad_path' };
200
+ }
201
+ let resolved;
202
+ try {
203
+ resolved = realpathSync(filePath);
204
+ }
205
+ catch (error) {
206
+ const code = error.code;
207
+ return { ok: false, error: code === 'ENOENT' ? 'missing' : 'denied' };
208
+ }
209
+ const root = rootOf(resolved, access);
210
+ if (!root)
211
+ return { ok: false, error: 'denied' };
212
+ return { ok: true, value: { path: resolved, root } };
213
+ }
214
+ function openFile(filePath, access) {
215
+ const located = locate(filePath, access);
216
+ if (!located.ok)
217
+ return located;
218
+ try {
219
+ if (!lstatSync(located.value.path).isFile())
220
+ return { ok: false, error: 'not_file' };
221
+ }
222
+ catch {
223
+ return { ok: false, error: 'missing' };
224
+ }
225
+ let fd;
226
+ try {
227
+ fd = openSync(located.value.path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
228
+ }
229
+ catch {
230
+ return { ok: false, error: 'denied' };
231
+ }
232
+ try {
233
+ const opened = process.platform === 'linux' ? realpathSync(`/proc/self/fd/${fd}`) : located.value.path;
234
+ const stat = fstatSync(fd);
235
+ if (!stat.isFile() || !rootOf(opened, access)) {
236
+ closeSync(fd);
237
+ return { ok: false, error: stat.isFile() ? 'denied' : 'not_file' };
238
+ }
239
+ return { ok: true, value: { fd, path: opened, size: stat.size } };
240
+ }
241
+ catch {
242
+ try {
243
+ closeSync(fd);
244
+ }
245
+ catch {
246
+ /* already closed */
247
+ }
248
+ return { ok: false, error: 'denied' };
249
+ }
250
+ }
251
+ function readFd(fd, size) {
252
+ const bytes = Buffer.alloc(size);
253
+ let offset = 0;
254
+ while (offset < size) {
255
+ const read = readSync(fd, bytes, offset, size - offset, offset);
256
+ if (read === 0)
257
+ break;
258
+ offset += read;
259
+ }
260
+ return bytes.subarray(0, offset);
261
+ }
262
+ function writeBounded(source, tmp, maxBytes) {
263
+ return new Promise(resolveWrite => {
264
+ const out = createWriteStream(tmp, { flags: 'wx', mode: 0o644 });
265
+ let size = 0;
266
+ let settled = false;
267
+ const fail = (error) => {
268
+ if (settled)
269
+ return;
270
+ settled = true;
271
+ source.pause();
272
+ source.removeListener('data', onData);
273
+ const done = () => {
274
+ try {
275
+ unlinkSync(tmp);
276
+ }
277
+ catch {
278
+ /* hidden temp, or the file was never created */
279
+ }
280
+ resolveWrite({ ok: false, error });
281
+ };
282
+ if (out.closed)
283
+ done();
284
+ else {
285
+ out.once('close', done);
286
+ out.destroy();
287
+ }
288
+ };
289
+ const onData = (chunk) => {
290
+ if (settled)
291
+ return;
292
+ size += chunk.length;
293
+ if (size > maxBytes) {
294
+ fail('too_large');
295
+ return;
296
+ }
297
+ if (!out.write(chunk))
298
+ source.pause();
299
+ };
300
+ out.on('drain', () => {
301
+ if (!settled)
302
+ source.resume();
303
+ });
304
+ out.on('error', () => fail('denied'));
305
+ source.on('data', onData);
306
+ source.on('end', () => {
307
+ if (settled)
308
+ return;
309
+ out.end(() => {
310
+ if (settled)
311
+ return;
312
+ settled = true;
313
+ resolveWrite({ ok: true, value: size });
314
+ });
315
+ });
316
+ source.on('error', () => fail('denied'));
317
+ source.resume();
318
+ });
319
+ }
@@ -0,0 +1,91 @@
1
+ import { closeSync, constants, createReadStream, fstatSync, openSync, readSync, realpathSync } from 'node:fs';
2
+ import { extname, relative, resolve, sep } from 'node:path';
3
+ const TYPES = new Map([
4
+ ['.jpg', 'image/jpeg'],
5
+ ['.jpeg', 'image/jpeg'],
6
+ ['.png', 'image/png'],
7
+ ['.gif', 'image/gif'],
8
+ ['.webp', 'image/webp'],
9
+ ]);
10
+ function matchesImage(header, type) {
11
+ if (type === 'image/jpeg')
12
+ return header[0] === 0xff && header[1] === 0xd8 && header[2] === 0xff;
13
+ if (type === 'image/png')
14
+ return header.subarray(0, 8).equals(Buffer.from('89504e470d0a1a0a', 'hex'));
15
+ if (type === 'image/gif')
16
+ return /^GIF8[79]a$/.test(header.toString('ascii', 0, 6));
17
+ return header.toString('ascii', 0, 4) === 'RIFF' && header.toString('ascii', 8, 12) === 'WEBP';
18
+ }
19
+ function artifactPath(path) {
20
+ const parts = path.split('/');
21
+ return (parts.length >= 3 &&
22
+ (parts[1] === 'preview' || parts[1] === 'artifacts') &&
23
+ parts.every(part => part !== '' && !part.startsWith('.')));
24
+ }
25
+ /**
26
+ * Called only AFTER the workbench authentication gate and bundled UI lookup.
27
+ * Generated raster images live in the configured session workspace, not public/.
28
+ * Only <project>/preview/ and <project>/artifacts/ are deliberate artifact scopes.
29
+ * Never fall back to process cwd, never serve arbitrary files or active HTML/SVG.
30
+ */
31
+ export function serveWorkspaceImage(req, res, pathname, workspace) {
32
+ if (!workspace || (req.method !== 'GET' && req.method !== 'HEAD') || !pathname.startsWith('/dsh-bot/'))
33
+ return false;
34
+ let decoded;
35
+ try {
36
+ decoded = decodeURIComponent(pathname.slice('/dsh-bot/'.length));
37
+ }
38
+ catch {
39
+ return false;
40
+ }
41
+ if (!artifactPath(decoded) || /[\\\u0000-\u001f\u007f]/.test(decoded))
42
+ return false;
43
+ const type = TYPES.get(extname(decoded).toLowerCase());
44
+ if (!type)
45
+ return false;
46
+ let fd;
47
+ try {
48
+ const root = realpathSync(workspace);
49
+ const file = realpathSync(resolve(root, decoded));
50
+ if (!file.startsWith(root + sep) || !artifactPath(relative(root, file).split(sep).join('/')))
51
+ return false;
52
+ fd = openSync(file, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
53
+ // On Linux, verify the opened descriptor as well, closing symlink-swap races.
54
+ if (process.platform === 'linux') {
55
+ const opened = realpathSync(`/proc/self/fd/${fd}`);
56
+ if (!opened.startsWith(root + sep) || !artifactPath(relative(root, opened).split(sep).join('/')))
57
+ return false;
58
+ }
59
+ const stat = fstatSync(fd);
60
+ if (!stat.isFile())
61
+ return false;
62
+ const header = Buffer.alloc(12);
63
+ readSync(fd, header, 0, header.length, 0);
64
+ if (!matchesImage(header, type))
65
+ return false;
66
+ res.writeHead(200, {
67
+ 'content-type': type,
68
+ 'content-length': stat.size,
69
+ 'cache-control': 'private, no-store',
70
+ 'x-content-type-options': 'nosniff',
71
+ 'content-security-policy': "default-src 'none'; sandbox",
72
+ });
73
+ if (req.method === 'HEAD')
74
+ res.end();
75
+ else {
76
+ const stream = createReadStream(file, { fd, autoClose: true, start: 0 });
77
+ fd = undefined;
78
+ stream.on('error', () => res.destroy());
79
+ res.on('close', () => stream.destroy());
80
+ stream.pipe(res);
81
+ }
82
+ return true;
83
+ }
84
+ catch {
85
+ return false;
86
+ }
87
+ finally {
88
+ if (fd != null)
89
+ closeSync(fd);
90
+ }
91
+ }
@@ -82,6 +82,20 @@ async function* generate(options) {
82
82
  yield { type: 'finish', reason: { kind: 'tool-calls' } }
83
83
  return
84
84
  }
85
+ // Deterministic quota-loop fixture: first request consumes 2k and reports
86
+ // progress; after the gate resumes the next request reports the result.
87
+ const quotaHistory = JSON.stringify(messages)
88
+ if (!directed && options.purpose == null && quotaHistory.includes('FOUNDATIONS_QUOTA_LOOP') && !quotaHistory.includes('quota-finished')) {
89
+ const first = !quotaHistory.includes('quota-progress')
90
+ const args = JSON.stringify({ kind: first ? 'progress' : 'result', text: first ? 'quota-progress' : 'quota-finished' })
91
+ const id = `call_mock_quota_${Date.now()}`
92
+ yield { type: 'block-start', index: 0, blockType: 'tool-call' }
93
+ yield { type: 'tool-call-delta', index: 0, id, name: 'foundations_report', argumentsDelta: args }
94
+ yield { type: 'block-end', index: 0, block: { type: 'tool-call', id, name: 'foundations_report', arguments: args } }
95
+ yield { type: 'usage', usage: { inputTokens: first ? 1992 : 8, outputTokens: 8, totalTokens: first ? 2000 : 16 } }
96
+ yield { type: 'finish', reason: { kind: 'tool-calls' } }
97
+ return
98
+ }
85
99
  const briefingArgs = !directed && options.purpose == null && briefingIsLatest(messages)
86
100
  ? briefingReport(plainUserText(messages))
87
101
  : null
@@ -118,7 +132,8 @@ async function* generate(options) {
118
132
  )
119
133
  if (directed) {
120
134
  const match = /^FOUNDATIONS_TOOL\s+(\S+)\s+(\{[\s\S]*\})\s*$/.exec(text.trim())
121
- const name = match?.[1]?.startsWith('foundations_') ? match[1] : `foundations_${match?.[1] ?? 'recall'}`
135
+ // Explicit native tools used by the activity API regression; all other directives keep the foundations prefix.
136
+ const name = ['bash', 'todo_write'].includes(match?.[1]) || match?.[1]?.startsWith('foundations_') ? match[1] : `foundations_${match?.[1] ?? 'recall'}`
122
137
  const args = match?.[2] ?? '{}'
123
138
  const id = `call_mock_${Date.now()}`
124
139
  yield { type: 'block-start', index: 0, blockType: 'tool-call' }
@@ -191,7 +206,7 @@ function nextHostTool(messages) {
191
206
  }
192
207
  })
193
208
  if (index < 0) return null
194
- const lines = [...text.matchAll(/^FOUNDATIONS_HOST_TOOL\s+(write|edit)\s+(\{[\s\S]*?\})\s*$/gm)]
209
+ const lines = [...text.matchAll(/^FOUNDATIONS_HOST_TOOL\s+(write|edit|bash)\s+(\{[\s\S]*?\})\s*$/gm)]
195
210
  if (lines.length === 0) return null
196
211
  const after = messages.slice(index + 1)
197
212
  const done = after.filter(message => message?.role === 'tool').length
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thready-web/dsh-bot-plugin",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0-beta.11",
4
4
  "type": "module",
5
5
  "description": "DSH bot plugin: session persona, memory, work, hash routing, and the workbench. Pinned to @deepseek-ai/dsh 0.2.2-rc.1.",
6
6
  "license": "MIT",
@@ -22,6 +22,7 @@
22
22
  "public",
23
23
  "client.js",
24
24
  "fixtures",
25
+ "skills",
25
26
  "README.md"
26
27
  ],
27
28
  "publishConfig": {
@@ -30,16 +31,26 @@
30
31
  },
31
32
  "scripts": {
32
33
  "build": "node build.mjs",
33
- "type-check": "tsc -p tsconfig.typecheck.json --noEmit && node type-check-tests.mjs",
34
- "test": "node --test test/store.test.ts test/skills.test.ts test/context.test.ts test/tools.test.ts test/triggers.test.ts test/provision.test.ts test/inbox-read.test.ts test/work.test.ts test/work-eval.test.ts test/router.test.ts test/desk.test.ts test/session-files.test.ts test/session-previews.test.ts test/cdc.test.ts test/live-diff.test.ts test/live-snapshot.test.ts ui/src/live.test.ts ui/src/follow.test.ts ui/src/work.test.ts ui/src/session-snapshot.test.ts",
35
- "test:host": "npm run build && node --test test/host-integration.test.ts && node --test test/triggers-host.test.ts"
34
+ "type-check": "tsc -p tsconfig.typecheck.json --noEmit && tsc -p tsconfig.client.json --noEmit",
35
+ "test": "node scripts/unit-tests.mjs",
36
+ "test:host": "npm run build && node --test test/host-integration.test.ts && node --test test/triggers-host.test.ts && node --test test/budget-host.test.ts && node --test test/activity-host.test.ts && node --test test/work-host.test.ts && node --test test/work-bash-host.test.ts",
37
+ "format": "biome format --write src test ui/src client.js scripts",
38
+ "format:check": "biome check src test ui/src client.js scripts"
36
39
  },
37
40
  "engines": {
38
- "node": ">=22.18.0"
41
+ "node": ">=22.18.0",
42
+ "dsh": ">=0.2.2-rc.1 <0.2.3-0"
39
43
  },
40
44
  "devDependencies": {
45
+ "@biomejs/biome": "^2.6.6",
46
+ "@deepseek-ai/cordis": "~4.1.0",
47
+ "@deepseek-ai/dsh-api-session-controller": "^0.2.2-rc.1",
48
+ "@deepseek-ai/dsh-client-connection": "^0.2.2-rc.1",
49
+ "@deepseek-ai/dsh-session": "^0.2.2-rc.1",
50
+ "@deepseek-ai/dsh-session-query": "^0.2.2-rc.1",
41
51
  "@types/node": "^24.10.0",
42
52
  "esbuild": "^0.25.0",
53
+ "linkedom": "^0.18.15",
43
54
  "typescript": "^5.9.3"
44
55
  },
45
56
  "dsh": {