@crowdedkingdoms/crowdy-dsh 0.2.0-dev.1 → 0.2.0-dev.2

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 (105) hide show
  1. package/THIRD_PARTY_NOTICES.md +226 -0
  2. package/dist/dsh-web/BUILD.json +3 -3
  3. package/dist/dsh-web/preview/vfs-image.tar.gz +0 -0
  4. package/lib/attachments/crowdy-attachment-store.js +200 -0
  5. package/lib/attachments/crowdy-attachment-store.js.map +1 -0
  6. package/lib/bridge/client.js +161 -0
  7. package/lib/bridge/client.js.map +1 -0
  8. package/lib/bridge/index.js +155 -0
  9. package/lib/bridge/index.js.map +1 -0
  10. package/lib/bridge/protocol.js +30 -0
  11. package/lib/bridge/protocol.js.map +1 -0
  12. package/lib/crowdy/client.js +247 -0
  13. package/lib/crowdy/client.js.map +1 -0
  14. package/lib/crowdy/config.js +95 -0
  15. package/lib/crowdy/config.js.map +1 -0
  16. package/lib/crowdy/github-layout.js +97 -0
  17. package/lib/crowdy/github-layout.js.map +1 -0
  18. package/lib/crowdy/paths.js +145 -0
  19. package/lib/crowdy/paths.js.map +1 -0
  20. package/lib/crowdy/project-store.js +223 -0
  21. package/lib/crowdy/project-store.js.map +1 -0
  22. package/lib/fs/crowdy-file-system.js +621 -0
  23. package/lib/fs/crowdy-file-system.js.map +1 -0
  24. package/lib/fs/scratch-store.js +61 -0
  25. package/lib/fs/scratch-store.js.map +1 -0
  26. package/lib/index.js +15 -0
  27. package/lib/index.js.map +1 -0
  28. package/lib/persist/index.js +199 -0
  29. package/lib/persist/index.js.map +1 -0
  30. package/lib/scripts/probe.js +59 -0
  31. package/lib/scripts/probe.js.map +1 -0
  32. package/lib/sdk-index/catalog.js +237 -0
  33. package/lib/sdk-index/catalog.js.map +1 -0
  34. package/lib/sdk-index/index.js +10 -0
  35. package/lib/sdk-index/index.js.map +1 -0
  36. package/lib/sdk-index/parse-sdk.js +131 -0
  37. package/lib/sdk-index/parse-sdk.js.map +1 -0
  38. package/lib/sdk-index/plugin.js +90 -0
  39. package/lib/sdk-index/plugin.js.map +1 -0
  40. package/lib/sdk-index/snapshot.js +215 -0
  41. package/lib/sdk-index/snapshot.js.map +1 -0
  42. package/lib/search/glob-match.js +114 -0
  43. package/lib/search/glob-match.js.map +1 -0
  44. package/lib/search/search-tools.js +414 -0
  45. package/lib/search/search-tools.js.map +1 -0
  46. package/lib/tools/index.js +344 -0
  47. package/lib/tools/index.js.map +1 -0
  48. package/lib/types/attachments/crowdy-attachment-store.d.ts +45 -0
  49. package/lib/types/attachments/crowdy-attachment-store.d.ts.map +1 -0
  50. package/lib/types/attachments/crowdy-attachment-store.test.d.ts.map +1 -0
  51. package/lib/types/bridge/client.d.ts +57 -0
  52. package/lib/types/bridge/client.d.ts.map +1 -0
  53. package/lib/types/bridge/client.test.d.ts.map +1 -0
  54. package/lib/types/bridge/index.d.ts +66 -0
  55. package/lib/types/bridge/index.d.ts.map +1 -0
  56. package/lib/types/bridge/protocol.d.ts +242 -0
  57. package/lib/types/bridge/protocol.d.ts.map +1 -0
  58. package/lib/types/crowdy/client.d.ts +126 -0
  59. package/lib/types/crowdy/client.d.ts.map +1 -0
  60. package/lib/types/crowdy/client.test.d.ts.map +1 -0
  61. package/lib/types/crowdy/config.d.ts +60 -0
  62. package/lib/types/crowdy/config.d.ts.map +1 -0
  63. package/lib/types/crowdy/github-layout.d.ts +36 -0
  64. package/lib/types/crowdy/github-layout.d.ts.map +1 -0
  65. package/lib/types/crowdy/paths.d.ts +89 -0
  66. package/lib/types/crowdy/paths.d.ts.map +1 -0
  67. package/lib/types/crowdy/project-store.d.ts +84 -0
  68. package/lib/types/crowdy/project-store.d.ts.map +1 -0
  69. package/lib/types/crowdy/project-store.test.d.ts.map +1 -0
  70. package/lib/types/fs/crowdy-file-system.d.ts +173 -0
  71. package/lib/types/fs/crowdy-file-system.d.ts.map +1 -0
  72. package/lib/types/fs/crowdy-file-system.test.d.ts.map +1 -0
  73. package/lib/types/fs/scratch-store.d.ts +31 -0
  74. package/lib/types/fs/scratch-store.d.ts.map +1 -0
  75. package/lib/types/index.d.ts +19 -0
  76. package/lib/types/index.d.ts.map +1 -0
  77. package/lib/types/persist/index.d.ts +85 -0
  78. package/lib/types/persist/index.d.ts.map +1 -0
  79. package/lib/types/scripts/probe.d.ts +9 -0
  80. package/lib/types/scripts/probe.d.ts.map +1 -0
  81. package/lib/types/sdk-index/catalog.d.ts +39 -0
  82. package/lib/types/sdk-index/catalog.d.ts.map +1 -0
  83. package/lib/types/sdk-index/catalog.test.d.ts.map +1 -0
  84. package/lib/types/sdk-index/index.d.ts +13 -0
  85. package/lib/types/sdk-index/index.d.ts.map +1 -0
  86. package/lib/types/sdk-index/parse-sdk.d.ts +25 -0
  87. package/lib/types/sdk-index/parse-sdk.d.ts.map +1 -0
  88. package/lib/types/sdk-index/plugin.d.ts +26 -0
  89. package/lib/types/sdk-index/plugin.d.ts.map +1 -0
  90. package/lib/types/sdk-index/snapshot.d.ts +11 -0
  91. package/lib/types/sdk-index/snapshot.d.ts.map +1 -0
  92. package/lib/types/search/glob-match.d.ts +31 -0
  93. package/lib/types/search/glob-match.d.ts.map +1 -0
  94. package/lib/types/search/glob-match.test.d.ts.map +1 -0
  95. package/lib/types/search/search-tools.d.ts +81 -0
  96. package/lib/types/search/search-tools.d.ts.map +1 -0
  97. package/lib/types/search/search-tools.test.d.ts.map +1 -0
  98. package/lib/types/tools/index.d.ts +27 -0
  99. package/lib/types/tools/index.d.ts.map +1 -0
  100. package/lib/types/vendor/crowdyjs-sdk.d.ts +17 -0
  101. package/lib/types/vendor/crowdyjs-sdk.d.ts.map +1 -0
  102. package/lib/vendor/crowdyjs-sdk.js +18338 -0
  103. package/lib/vendor/crowdyjs-sdk.js.map +1 -0
  104. package/lib/vendor/crowdyjs-sdk.version.json +5 -0
  105. package/package.json +151 -38
@@ -0,0 +1,344 @@
1
+ /**
2
+ * Crowdy Studio tools: what the model can do beyond editing files.
3
+ *
4
+ * Every tool here either reads the project through the filesystem backend or
5
+ * asks the Studio page (over `ctx.crowdyBridge`) to do something only the page
6
+ * can: compile and run a draft, deploy live, take a screenshot of the game,
7
+ * switch projects, observe the world. The model never receives a token, a
8
+ * shell, or the network; the page keeps the same authority it has for a human.
9
+ *
10
+ * @module @crowdedkingdoms/crowdy-dsh/tools
11
+ */
12
+ import z from '@deepseek-ai/schemastery';
13
+ import { defineTool } from '@deepseek-ai/dsh-tools';
14
+ import { BridgeError } from '../bridge/client.js';
15
+ /** Cordis plugin name used by loader diagnostics. */
16
+ export const name = 'crowdy-tools';
17
+ export const inject = ['tools', 'fs', 'crowdyBridge'];
18
+ export const Config = z.object({
19
+ buildTimeoutMs: z.number().default(180_000),
20
+ screenshotTimeoutMs: z.number().default(15_000),
21
+ autoScreenshot: z.boolean().default(true),
22
+ });
23
+ const TEXT_OUTPUT = {
24
+ schema: {
25
+ type: 'object',
26
+ additionalProperties: false,
27
+ properties: { text: { type: 'string', required: true } },
28
+ },
29
+ render: (_args, value) => [{ type: 'text', text: value.text }],
30
+ };
31
+ function bridgeFailure(error) {
32
+ if (error instanceof BridgeError)
33
+ throw new Error(error.message);
34
+ throw error instanceof Error ? error : new Error(String(error));
35
+ }
36
+ function formatDiagnostics(diagnostics) {
37
+ if (diagnostics.length === 0)
38
+ return 'No diagnostics.';
39
+ return diagnostics
40
+ .slice(0, 40)
41
+ .map((d) => {
42
+ const where = `${d.target.toLowerCase()}/${d.path}${d.line ? `:${d.line}${d.column ? `:${d.column}` : ''}` : ''}`;
43
+ return `${d.severity.toUpperCase()} ${where} — ${d.message}`;
44
+ })
45
+ .join('\n');
46
+ }
47
+ function formatBuild(result, root) {
48
+ const lines = [
49
+ `${result.mode === 'draft' ? 'Draft test' : 'Live deploy'}: ${result.ok ? 'OK' : 'FAILED'} — ${result.summary}`,
50
+ '',
51
+ 'Diagnostics:',
52
+ formatDiagnostics(result.diagnostics),
53
+ ];
54
+ if (result.runtime.length > 0) {
55
+ lines.push('', 'Runtime:');
56
+ for (const status of result.runtime) {
57
+ lines.push(`- ${status.target}: ${status.phase}${status.moduleName ? ` (${status.moduleName})` : ''}${status.message ? ` — ${status.message}` : ''}`);
58
+ }
59
+ }
60
+ if (result.buildLog.trim()) {
61
+ lines.push('', 'Build log (tail):', result.buildLog.trim().split('\n').slice(-60).join('\n'));
62
+ }
63
+ lines.push('', `Diagnostics were also written to ${root}/context/diagnostics.json. Fix errors in the files they name (server/ or client/ under ${root}), then run draft_test again.`);
64
+ return lines.join('\n');
65
+ }
66
+ export async function apply(ctx, config = {}) {
67
+ const bridge = ctx.crowdyBridge;
68
+ const fs = bridge.fs;
69
+ const buildTimeout = config.buildTimeoutMs ?? 180_000;
70
+ const screenshotTimeout = config.screenshotTimeoutMs ?? 15_000;
71
+ const autoScreenshot = config.autoScreenshot ?? true;
72
+ /** Persist a capture under `captures/` and turn it into an image block when a store exists. */
73
+ async function attachCapture(shot) {
74
+ const { path } = bridge.putCapture(shot);
75
+ const attachments = ctx.get('attachments');
76
+ if (!attachments) {
77
+ return { path, blocks: [], note: `Saved to ${path}; read it with read_image.` };
78
+ }
79
+ try {
80
+ const ref = await attachments.saveImage({
81
+ data: new Uint8Array(shot.bytes),
82
+ mediaType: shot.mediaType,
83
+ name: path.slice(path.lastIndexOf('/') + 1),
84
+ });
85
+ return {
86
+ path,
87
+ blocks: [{ type: 'image', attachment: ref }],
88
+ note: `Screenshot ${ref.width}x${ref.height} attached (also at ${path}).${shot.caption ? ` ${shot.caption}` : ''}`,
89
+ };
90
+ }
91
+ catch (error) {
92
+ return {
93
+ path,
94
+ blocks: [],
95
+ note: `Saved to ${path} but it could not be attached: ${error instanceof Error ? error.message : String(error)}`,
96
+ };
97
+ }
98
+ }
99
+ async function runBuild(mode, exec) {
100
+ let result;
101
+ try {
102
+ result = await bridge.client.request(mode === 'draft' ? 'studio.draftTest' : 'studio.deployLive', {}, { signal: exec.signal, timeoutMs: buildTimeout });
103
+ }
104
+ catch (error) {
105
+ bridgeFailure(error);
106
+ }
107
+ bridge.putContext({ diagnostics: result.diagnostics, runtime: result.runtime });
108
+ fs.invalidate();
109
+ let text = formatBuild(result, fs.mountRoot);
110
+ let imagePath;
111
+ const clientRan = result.ok && result.runtime.some((status) => status.target === 'CLIENT' && /run|live|draft/i.test(status.phase));
112
+ const shot = result.screenshot ?? (autoScreenshot && clientRan ? await tryScreenshot(exec, 'after draft test') : undefined);
113
+ if (shot) {
114
+ const saved = bridge.putCapture(shot);
115
+ imagePath = saved.path;
116
+ text += `\n\nA screenshot of the game after the run is at ${imagePath}; call read_image on it to see the result.`;
117
+ }
118
+ return imagePath ? { text, imagePath } : { text };
119
+ }
120
+ async function tryScreenshot(exec, label) {
121
+ try {
122
+ return await bridge.client.request('studio.screenshot', { label }, { signal: exec.signal, timeoutMs: screenshotTimeout });
123
+ }
124
+ catch {
125
+ return undefined;
126
+ }
127
+ }
128
+ const buildOutput = {
129
+ schema: {
130
+ type: 'object',
131
+ additionalProperties: false,
132
+ properties: { text: { type: 'string', required: true }, imagePath: { type: 'string' } },
133
+ },
134
+ render: (_args, value) => [{ type: 'text', text: value.text }],
135
+ };
136
+ ctx.tools.register(defineTool({
137
+ name: 'draft_test',
138
+ description: 'Compile the current Crowdy Studio project and run it as a DRAFT on the player\'s own grid (server target) and browser (client target). ' +
139
+ 'Returns compiler diagnostics, the build log tail and runtime status; a screenshot of the game is captured when the client target ran. ' +
140
+ 'Use this after every meaningful edit. Nothing here is visible to other players.',
141
+ parameters: {},
142
+ output: buildOutput,
143
+ timeoutMs: buildTimeout + 5_000,
144
+ execute: (_args, exec) => runBuild('draft', exec),
145
+ presentCall: () => ({ card: 'generic', title: 'Draft test', kind: 'execute' }),
146
+ }));
147
+ ctx.tools.register(defineTool({
148
+ name: 'deploy_live',
149
+ description: 'Deploy the current project LIVE so other players on the grid run it. Requires the player\'s explicit approval every time; ' +
150
+ 'run draft_test first and only deploy when it passed and the player asked for a live deploy.',
151
+ parameters: {
152
+ reason: { type: 'string', required: true, description: 'One sentence the player will read when asked to approve the deploy.' },
153
+ },
154
+ output: buildOutput,
155
+ timeoutMs: buildTimeout + 60_000,
156
+ async execute(args, exec) {
157
+ const approval = ctx.get('approval');
158
+ if (!approval || !exec.agent) {
159
+ throw new Error('Live deploys need the approval service, which this composition does not mount. Ask the player to deploy from the Studio panel.');
160
+ }
161
+ const outcome = await approval.request({
162
+ agent: exec.agent,
163
+ toolName: 'deploy_live',
164
+ callId: exec.callId,
165
+ reason: `Deploy the project live for other players: ${args.reason}`,
166
+ signal: exec.signal,
167
+ });
168
+ if (outcome !== 'allowed-once') {
169
+ throw new Error(outcome === 'rejected'
170
+ ? 'The player declined the live deploy. Keep working in draft mode.'
171
+ : outcome === 'cancelled'
172
+ ? 'The deploy approval was cancelled.'
173
+ : 'No one could approve the deploy right now; ask the player to deploy from the Studio panel.');
174
+ }
175
+ return runBuild('live', exec);
176
+ },
177
+ presentCall: (args) => ({ card: 'generic', title: 'Deploy live', kind: 'execute', rawInput: args.reason }),
178
+ }));
179
+ ctx.tools.register(defineTool({
180
+ name: 'screenshot',
181
+ description: 'Capture what the player currently sees in the game (the 3D view, HUD text and any overlay a CLIENT mod drew) and attach it as an image. ' +
182
+ 'Use it to check a visual change, or when the player refers to something on screen. Requires a model that accepts images.',
183
+ parameters: {
184
+ label: { type: 'string', description: 'Short note on why the capture was taken; stored beside the image.' },
185
+ },
186
+ output: {
187
+ schema: {
188
+ type: 'object',
189
+ additionalProperties: false,
190
+ properties: {
191
+ path: { type: 'string', required: true },
192
+ note: { type: 'string', required: true },
193
+ attachment: { type: 'json' },
194
+ },
195
+ },
196
+ render: (_args, value) => {
197
+ const blocks = [{ type: 'text', text: value.note }];
198
+ if (value.attachment && typeof value.attachment === 'object') {
199
+ blocks.push({ type: 'image', attachment: value.attachment });
200
+ }
201
+ return blocks;
202
+ },
203
+ presentationMeta: (_args, value) => ({ path: value.path }),
204
+ },
205
+ timeoutMs: screenshotTimeout + 5_000,
206
+ async execute(args, exec) {
207
+ let shot;
208
+ try {
209
+ shot = await bridge.client.request('studio.screenshot', { label: args.label }, { signal: exec.signal, timeoutMs: screenshotTimeout });
210
+ }
211
+ catch (error) {
212
+ bridgeFailure(error);
213
+ }
214
+ const saved = await attachCapture(shot);
215
+ const attachment = saved.blocks.find((block) => block.type === 'image');
216
+ return {
217
+ path: saved.path,
218
+ note: saved.note,
219
+ ...(attachment && attachment.type === 'image' ? { attachment: JSON.parse(JSON.stringify(attachment.attachment)) } : {}),
220
+ };
221
+ },
222
+ presentCall: (args) => ({ card: 'generic', title: 'Screenshot', kind: 'read', rawInput: args.label ?? '' }),
223
+ }));
224
+ ctx.tools.register(defineTool({
225
+ name: 'runtime_status',
226
+ description: 'Current status of the project\'s SERVER and CLIENT modules: saved vs running revision, phase, and the latest runtime logs.',
227
+ parameters: {
228
+ log_lines: { type: 'integer', description: 'How many recent runtime log lines to include (default 40).' },
229
+ },
230
+ output: TEXT_OUTPUT,
231
+ async execute(args, exec) {
232
+ try {
233
+ const [status, logs] = await Promise.all([
234
+ bridge.client.request('studio.runtimeStatus', {}, { signal: exec.signal }),
235
+ bridge.client.request('studio.runtimeLogs', { limit: args.log_lines ?? 40 }, { signal: exec.signal }),
236
+ ]);
237
+ bridge.putContext({ runtime: status.runtime });
238
+ const lines = status.runtime.map((s) => `- ${s.target}: ${s.phase}${s.moduleName ? ` (${s.moduleName})` : ''}${s.runningRevision ? ` running r${s.runningRevision}` : ''}${s.savedRevision ? ` saved r${s.savedRevision}` : ''}${s.message ? ` — ${s.message}` : ''}`);
239
+ return {
240
+ text: `Runtime:\n${lines.join('\n') || '- (nothing running)'}\n\nRecent logs${logs.truncated ? ' (truncated)' : ''}:\n${logs.lines.join('\n') || '(none)'}`,
241
+ };
242
+ }
243
+ catch (error) {
244
+ bridgeFailure(error);
245
+ }
246
+ },
247
+ presentCall: () => ({ card: 'generic', title: 'Runtime status', kind: 'read' }),
248
+ }));
249
+ ctx.tools.register(defineTool({
250
+ name: 'client_logs',
251
+ description: 'Recent `crowdy::log` output from the CLIENT module running in the player\'s browser, plus browser-side runtime errors.',
252
+ parameters: {
253
+ limit: { type: 'integer', description: 'Maximum lines (default 80).' },
254
+ },
255
+ output: TEXT_OUTPUT,
256
+ async execute(args, exec) {
257
+ try {
258
+ const logs = await bridge.client.request('studio.clientLogs', { limit: args.limit ?? 80 }, { signal: exec.signal });
259
+ bridge.putContext({ clientLogs: logs.lines });
260
+ return { text: logs.lines.length ? logs.lines.join('\n') : 'No client log lines yet.' };
261
+ }
262
+ catch (error) {
263
+ bridgeFailure(error);
264
+ }
265
+ },
266
+ presentCall: () => ({ card: 'generic', title: 'Client logs', kind: 'read' }),
267
+ }));
268
+ ctx.tools.register(defineTool({
269
+ name: 'game_observe',
270
+ description: 'A structured snapshot of the player\'s surroundings from the game: position, grid and chunk, nearby actors and blocks, as the game reports them. ' +
271
+ 'Cheaper than a screenshot and exact; use it to ground world coordinates before writing code that touches voxels or actors.',
272
+ parameters: {},
273
+ output: TEXT_OUTPUT,
274
+ async execute(_args, exec) {
275
+ try {
276
+ const result = await bridge.client.request('game.observe', {}, { signal: exec.signal });
277
+ bridge.putContext({ observation: result.observation });
278
+ return { text: `Observed at ${result.capturedAt}:\n${JSON.stringify(result.observation, null, 2).slice(0, 12_000)}` };
279
+ }
280
+ catch (error) {
281
+ bridgeFailure(error);
282
+ }
283
+ },
284
+ presentCall: () => ({ card: 'generic', title: 'Observe game', kind: 'read' }),
285
+ }));
286
+ ctx.tools.register(defineTool({
287
+ name: 'project_list',
288
+ description: 'List the player\'s Crowdy Studio projects in this app and which one is open in the editor (and mounted here).',
289
+ parameters: {},
290
+ output: TEXT_OUTPUT,
291
+ async execute(_args, exec) {
292
+ try {
293
+ const result = await bridge.client.request('studio.projectList', {}, { signal: exec.signal });
294
+ const lines = result.projects.map((p) => `- ${p.projectId === result.currentProjectId ? '* ' : ''}${p.name} [${p.kind}] id=${p.projectId}${p.github ? ` github=${p.github}` : ''} updated ${p.updatedAt}`);
295
+ return { text: lines.length ? `Projects (* = open):\n${lines.join('\n')}` : 'No projects yet; use project_create.' };
296
+ }
297
+ catch (error) {
298
+ bridgeFailure(error);
299
+ }
300
+ },
301
+ presentCall: () => ({ card: 'generic', title: 'List projects', kind: 'read' }),
302
+ }));
303
+ ctx.tools.register(defineTool({
304
+ name: 'project_open',
305
+ description: 'Open another of the player\'s projects in Crowdy Studio and mount it here; subsequent file tools read and write that project.',
306
+ parameters: {
307
+ project_id: { type: 'string', required: true, description: 'Project id from project_list.' },
308
+ },
309
+ output: TEXT_OUTPUT,
310
+ async execute(args, exec) {
311
+ try {
312
+ const result = await bridge.client.request('studio.projectOpen', { projectId: args.project_id }, { signal: exec.signal });
313
+ fs.setProject(result.project.projectId);
314
+ return { text: `Opened "${result.project.name}" (${result.project.projectId}). The mount at ${fs.mountRoot} now shows its files.` };
315
+ }
316
+ catch (error) {
317
+ bridgeFailure(error);
318
+ }
319
+ },
320
+ presentCall: (args) => ({ card: 'generic', title: `Open project ${args.project_id}`, kind: 'other' }),
321
+ }));
322
+ ctx.tools.register(defineTool({
323
+ name: 'project_create',
324
+ description: 'Create a new Crowdy Studio project from a starter template, open it in the editor and mount it here. ' +
325
+ 'Templates come from the Studio starter catalog; omit `template` for the blank full-stack project.',
326
+ parameters: {
327
+ name: { type: 'string', required: true, description: 'Project name shown in Studio.' },
328
+ template: { type: 'string', description: 'Starter template id, e.g. "blank", "hello-voxel".' },
329
+ },
330
+ output: TEXT_OUTPUT,
331
+ async execute(args, exec) {
332
+ try {
333
+ const result = await bridge.client.request('studio.projectCreate', { name: args.name, ...(args.template ? { template: args.template } : {}) }, { signal: exec.signal, timeoutMs: 60_000 });
334
+ fs.setProject(result.project.projectId);
335
+ return { text: `Created "${result.project.name}" (${result.project.projectId}) and mounted it at ${fs.mountRoot}. List the directory to see the starter files.` };
336
+ }
337
+ catch (error) {
338
+ bridgeFailure(error);
339
+ }
340
+ },
341
+ presentCall: (args) => ({ card: 'generic', title: `Create project "${args.name}"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,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CACxC,sBAAsB,EACtB,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAC1E,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAC3C,CAAA;gBACD,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;gBACvC,OAAO,EAAE,IAAI,EAAE,YAAY,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,uBAAuB,EAAE,CAAC,SAAS,gDAAgD,EAAE,CAAA;YACnK,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,aAAa,CAAC,KAAK,CAAC,CAAA;YACtB,CAAC;QACH,CAAC;QACD,WAAW,EAAE,CAAC,IAAI,EAAgB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,mBAAmB,IAAI,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KAClH,CAAC,CACH,CAAA;AACH,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * An in-memory `ctx.attachments` provider for the browser worker.
3
+ *
4
+ * The stock `@deepseek-ai/dsh-attachment-local` decodes and normalizes images
5
+ * with `sharp`, a native module the browser worker replaces with a stub that
6
+ * refuses every call — so in the worker neither `read_image` nor a pasted
7
+ * screenshot could ever produce an image block. This store keeps the bytes it
8
+ * is handed, reads intrinsic dimensions from the container header (PNG, JPEG,
9
+ * WebP, GIF), and serves model requests verbatim. The Studio page already
10
+ * downscales captures before sharing them, and the byte caps here bound what a
11
+ * pasted image can cost.
12
+ *
13
+ * Attachments live for the life of the harness only: reloading the page drops
14
+ * the bytes, and a replayed session shows the image envelope without pixels.
15
+ *
16
+ * @module @crowdedkingdoms/crowdy-dsh/attachments
17
+ */
18
+ import type { Context } from '@deepseek-ai/cordis';
19
+ import z from '@deepseek-ai/schemastery';
20
+ import { AttachmentStore } from '@deepseek-ai/dsh-attachment';
21
+ import type { ImageAttachmentLimits, ImageAttachmentRef, ImageMediaType, ImageRequestPolicy, RequestImageAttachment, SaveImageAttachment, StoredImageAttachment } from '@deepseek-ai/dsh-attachment';
22
+ export interface Config {
23
+ /** Largest encoded image accepted, in bytes. */
24
+ maxImageBytes?: number;
25
+ /** Largest intrinsic side accepted, in pixels. */
26
+ maxImageDimension?: number;
27
+ }
28
+ /** Intrinsic dimensions read from the container header, or undefined when the bytes are not that format. */
29
+ export declare function imageDimensions(data: Uint8Array, mediaType: ImageMediaType): {
30
+ width: number;
31
+ height: number;
32
+ } | undefined;
33
+ export declare class CrowdyAttachmentStore extends AttachmentStore {
34
+ static Config: z<Config>;
35
+ readonly imageLimits: ImageAttachmentLimits;
36
+ private readonly images;
37
+ constructor(ctx: Context, config?: Config);
38
+ private inspect;
39
+ validateImage(input: SaveImageAttachment): Promise<void>;
40
+ saveImage(input: SaveImageAttachment): Promise<ImageAttachmentRef>;
41
+ readImage(ref: ImageAttachmentRef, signal?: AbortSignal): Promise<StoredImageAttachment>;
42
+ readImageRequest(ref: ImageAttachmentRef, policy: ImageRequestPolicy, signal?: AbortSignal): Promise<RequestImageAttachment>;
43
+ }
44
+ export default CrowdyAttachmentStore;
45
+ //# sourceMappingURL=crowdy-attachment-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crowdy-attachment-store.d.ts","sourceRoot":"","sources":["../../../src/attachments/crowdy-attachment-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OA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sourceRoot":"","sources":["../../../src/attachments/crowdy-attachment-store.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Worker-side half of the page bridge: a request/response and event layer
3
+ * over one `BroadcastChannel`.
4
+ *
5
+ * `BroadcastChannel` is the one same-origin primitive a dedicated worker, the
6
+ * iframe that spawned it, and the embedding Studio page all share without the
7
+ * worker knowing its own port topology. The harness's own tunnel to the iframe
8
+ * is untouched; this channel is separate and ignores frames it did not define.
9
+ *
10
+ * @module @crowdedkingdoms/crowdy-dsh/bridge/client
11
+ */
12
+ import { type BridgeMethod, type BridgeRequestMap, type PageEvent, type PageEventMap, type WorkerEvent, type WorkerEventMap } from './protocol.js';
13
+ export declare class BridgeError extends Error {
14
+ readonly code: string;
15
+ constructor(message: string, code: string);
16
+ }
17
+ interface ChannelLike {
18
+ postMessage(message: unknown): void;
19
+ close(): void;
20
+ addEventListener(type: 'message', listener: (event: {
21
+ data: unknown;
22
+ }) => void): void;
23
+ }
24
+ type ChannelFactory = (name: string) => ChannelLike;
25
+ export interface BridgeClientOptions {
26
+ /** Channel name the page chose; absent means no page (developer cockpit). */
27
+ channel?: string;
28
+ /** Boot nonce from the page; frames without it are dropped, frames sent carry it. */
29
+ nonce?: string;
30
+ /** Default per-request deadline. Draft tests are slow, so tools pass their own. */
31
+ timeoutMs?: number;
32
+ /** Test seam. */
33
+ channelFactory?: ChannelFactory;
34
+ }
35
+ export declare class BridgeClient {
36
+ private readonly channel;
37
+ private readonly pending;
38
+ private readonly listeners;
39
+ private readonly timeoutMs;
40
+ private readonly nonce;
41
+ private sequence;
42
+ /** Whether a page has said hello since the channel opened. */
43
+ pagePresent: boolean;
44
+ constructor(options?: BridgeClientOptions);
45
+ /** True when a channel exists (a page may or may not be listening yet). */
46
+ get available(): boolean;
47
+ on<E extends PageEvent>(event: E, listener: (payload: PageEventMap[E]) => void): () => void;
48
+ emit<E extends WorkerEvent>(event: E, payload: WorkerEventMap[E]): void;
49
+ request<M extends BridgeMethod>(method: M, params: BridgeRequestMap[M]['params'], options?: {
50
+ signal?: AbortSignal;
51
+ timeoutMs?: number;
52
+ }): Promise<BridgeRequestMap[M]['result']>;
53
+ close(): void;
54
+ private handle;
55
+ }
56
+ export {};
57
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/bridge/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,cAAc,EACpB,MAAM,eAAe,CAAA;AAEtB,qBAAa,WAAY,SAAQ,KAAK;IAGlC,QAAQ,CAAC,IAAI,EAAE,MAAM;gBADrB,OAAO,EAAE,MAAM,EACN,IAAI,EAAE,MAAM;CAKxB;AAED,UAAU,WAAW;IACnB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;IACnC,KAAK,IAAI,IAAI,CAAA;IACb,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,GAAG,IAAI,CAAA;CACtF;AAED,KAAK,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,CAAA;AASnD,MAAM,WAAW,mBAAmB;IAClC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iBAAiB;IACjB,cAAc,CAAC,EAAE,cAAc,CAAA;CAChC;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAGrB;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqD;IAC/E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAI;IACpB,8DAA8D;IAC9D,WAAW,UAAQ;gBAEP,OAAO,GAAE,mBAAwB;IAe7C,2EAA2E;IAC3E,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,EAAE,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;IAY3F,IAAI,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI;IAMjE,OAAO,CAAC,CAAC,SAAS,YAAY,EAClC,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EACrC,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACzD,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IA8CzC,KAAK,IAAI,IAAI;IAQb,OAAO,CAAC,MAAM;CAmCf"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../../../src/bridge/client.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Cordis service `ctx.crowdyBridge`: the harness's link to the Crowdy Studio
3
+ * page. It joins the page's `BroadcastChannel`, keeps the filesystem backend's
4
+ * token and project in step with the page, mirrors page-shared context into
5
+ * the `context/` and `captures/` scratch directories, and lets tools ask the
6
+ * page to run a draft test, take a screenshot, or switch projects.
7
+ *
8
+ * @module @crowdedkingdoms/crowdy-dsh/bridge
9
+ */
10
+ import { Context, Service } from '@deepseek-ai/cordis';
11
+ import z from '@deepseek-ai/schemastery';
12
+ import { CrowdyFileSystem } from '../fs/crowdy-file-system.js';
13
+ import type { ScratchFile } from '../fs/scratch-store.js';
14
+ import { BridgeClient } from './client.js';
15
+ import type { ScreenshotResult, StudioDiagnostic, RuntimeStatus } from './protocol.js';
16
+ export { BridgeClient, BridgeError } from './client.js';
17
+ export * from './protocol.js';
18
+ declare module '@deepseek-ai/cordis' {
19
+ interface Context {
20
+ crowdyBridge: CrowdyBridge;
21
+ }
22
+ }
23
+ export interface Config {
24
+ /** Override the channel name from `crowdy.json` (tests). */
25
+ channel?: string;
26
+ /** Override the boot nonce from `crowdy.json` (tests). */
27
+ nonce?: string;
28
+ /** Default request deadline in milliseconds. */
29
+ timeoutMs?: number;
30
+ }
31
+ /** Cordis plugin name used by loader diagnostics. */
32
+ export declare const name = "crowdy-bridge";
33
+ export declare class CrowdyBridge extends Service {
34
+ static inject: string[];
35
+ static Config: z<Config>;
36
+ readonly client: BridgeClient;
37
+ readonly fs: CrowdyFileSystem;
38
+ private captureCounter;
39
+ private readonly disposers;
40
+ constructor(ctx: Context, config?: Config);
41
+ /** Whether a Studio page is attached (page-executed tools can work). */
42
+ get pageConnected(): boolean;
43
+ /** Store a capture under `captures/` and return its virtual path. */
44
+ putCapture(shot: ScreenshotResult): {
45
+ path: string;
46
+ file: ScratchFile;
47
+ };
48
+ /** Store page-shared context as readable files under `context/`. */
49
+ putContext(payload: {
50
+ observation?: unknown;
51
+ clientLogs?: string[];
52
+ diagnostics?: StudioDiagnostic[];
53
+ runtime?: RuntimeStatus[];
54
+ note?: string;
55
+ }): string[];
56
+ /**
57
+ * Queue text into the player's current session: the most recently created
58
+ * live agent, or a fresh session in the project mount when none is live.
59
+ * Uses the same host controller the web client's composer goes through, so
60
+ * the message shows up in the pane like a typed one.
61
+ */
62
+ promptAgent(text: string, mode: 'queue' | 'steer'): Promise<void>;
63
+ private wire;
64
+ }
65
+ export default CrowdyBridge;
66
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bridge/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAKxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAA;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAEtF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACvD,cAAc,eAAe,CAAA;AAE7B,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf,YAAY,EAAE,YAAY,CAAA;KAC3B;CACF;AAED,MAAM,WAAW,MAAM;IACrB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,qDAAqD;AACrD,eAAO,MAAM,IAAI,kBAAkB,CAAA;AAEnC,qBAAa,YAAa,SAAQ,OAAO;IACvC,MAAM,CAAC,MAAM,WAAS;IACtB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAIE;IAE1B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;IAC7B,QAAQ,CAAC,EAAE,EAAE,gBAAgB,CAAA;IAC7B,OAAO,CAAC,cAAc,CAAI;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwB;gBAEtC,GAAG,E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