@thready-web/dsh-bot-plugin 0.1.0-beta.10 → 0.1.0-beta.12

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 (67) hide show
  1. package/README.md +19 -2
  2. package/dist/approvals.js +19 -1
  3. package/dist/canvas-compose.js +73 -0
  4. package/dist/canvas-http.js +379 -0
  5. package/dist/canvas-skills.js +56 -0
  6. package/dist/canvas-store.js +1015 -0
  7. package/dist/canvas-tools.js +380 -0
  8. package/dist/card-log.js +216 -0
  9. package/dist/context.js +6 -3
  10. package/dist/deleting.js +54 -0
  11. package/dist/desk-ledger.js +18 -0
  12. package/dist/desk.js +30 -5
  13. package/dist/http-plugin.js +2 -1
  14. package/dist/http.js +218 -3
  15. package/dist/inbox.js +24 -2
  16. package/dist/index.js +75 -12
  17. package/dist/questions.js +10 -0
  18. package/dist/runtime-registry.js +20 -0
  19. package/dist/session-delete-job.js +77 -0
  20. package/dist/session-files.js +33 -1
  21. package/dist/session-wipe.js +204 -0
  22. package/dist/store.js +46 -3
  23. package/dist/triggers.js +8 -0
  24. package/dist/work-admit.js +9 -20
  25. package/dist/work-child.js +27 -10
  26. package/dist/work-http.js +19 -0
  27. package/dist/work-ledger.js +5 -1
  28. package/dist/work-mock.js +10 -0
  29. package/dist/work-tickets.js +5 -3
  30. package/dist/work-tools.js +11 -9
  31. package/dist/work-worker.js +245 -6
  32. package/dist/worker-handles.js +33 -0
  33. package/dist/workspace-files.js +98 -17
  34. package/package.json +2 -1
  35. package/public/assets/{SourceEditor-BEQaScgR.js → SourceEditor-BjtoMvcX.js} +3 -3
  36. package/public/assets/{cssMode-gpcjCFFS.js → cssMode--96PQtWh.js} +1 -1
  37. package/public/assets/{freemarker2-C1qemGIt.js → freemarker2-Bz-HlISL.js} +1 -1
  38. package/public/assets/{handlebars-sZqIfAlP.js → handlebars-D9ScJ8AM.js} +1 -1
  39. package/public/assets/{html-Bn1WXB8L.js → html-Czc0jojJ.js} +1 -1
  40. package/public/assets/{htmlMode-CvQyXnaW.js → htmlMode-CCww5Z1w.js} +1 -1
  41. package/public/assets/index-DRCgKxWk.css +1 -0
  42. package/public/assets/index-ztUdW074.js +72 -0
  43. package/public/assets/{javascript-Ox4Jg12j.js → javascript-B-yRZSiz.js} +1 -1
  44. package/public/assets/{jsonMode-DMR7R2dQ.js → jsonMode-ASWsY833.js} +1 -1
  45. package/public/assets/{liquid-B6HxtpBd.js → liquid-BGoox2vJ.js} +1 -1
  46. package/public/assets/{mdx--jDhmrXq.js → mdx-DHgvnl_U.js} +1 -1
  47. package/public/assets/{python-YjG50skX.js → python-BJvVD30_.js} +1 -1
  48. package/public/assets/{razor-CEcFE3UK.js → razor-0PwR35mu.js} +1 -1
  49. package/public/assets/{tsMode-g4kTQl09.js → tsMode-3ETp8Gdh.js} +1 -1
  50. package/public/assets/{typescript-CnHeFmPW.js → typescript-BT0iTK6K.js} +1 -1
  51. package/public/assets/{xml-BFXMY9nb.js → xml-BTaNc_uT.js} +1 -1
  52. package/public/assets/{yaml-DNm87nSf.js → yaml-Dr7LW3tK.js} +1 -1
  53. package/public/index.html +2 -2
  54. package/skills/ui/baseline-ui/SKILL.md +85 -0
  55. package/skills/ui/bencium-innovative-ux-designer/SKILL.md +227 -0
  56. package/skills/ui/better-ui/SKILL.md +133 -0
  57. package/skills/ui/design-lab/SKILL.md +920 -0
  58. package/skills/ui/frontend-design/SKILL.md +71 -0
  59. package/skills/ui/impeccable/SKILL.md +93 -0
  60. package/skills/ui/interface-design/SKILL.md +320 -0
  61. package/skills/ui/sources.json +66 -0
  62. package/skills/ui/ui-design/SKILL.md +41 -0
  63. package/skills/ui/ui-skills-root/SKILL.md +59 -0
  64. package/skills/ui/visual-design-foundations/SKILL.md +318 -0
  65. package/skills/ui/web-design-guidelines/SKILL.md +39 -0
  66. package/public/assets/index-DRNkUrer.css +0 -1
  67. package/public/assets/index-DhL5Kdlz.js +0 -63
@@ -19,9 +19,9 @@ export const DEFAULT_WORK_BUDGET = Object.freeze({
19
19
  holdMs: 15_000,
20
20
  workerMaxSteps: 8,
21
21
  /** One budget slice. A grant adds another slice; there is no cumulative ceiling. */
22
- workerWallMs: 30 * 60 * 1000,
22
+ workerWallMs: 60 * 60 * 1000,
23
23
  /** One budget slice. A grant adds another slice; there is no cumulative ceiling. */
24
- workerMaxTokens: 1_000_000,
24
+ workerMaxTokens: 2_000_000,
25
25
  perBot: 2,
26
26
  global: 4,
27
27
  perBotQueue: 8,
@@ -233,28 +233,17 @@ export function budgetTrip(input) {
233
233
  return null;
234
234
  }
235
235
  /**
236
- * Positive integer at or above `min`. A non-finite value is omitted.
237
- * @param {unknown} value
238
- * @param {number} min
239
- */
240
- function clampAtLeast(value, min) {
241
- const number = Number(value);
242
- if (!Number.isFinite(number))
243
- return null;
244
- return Math.max(min, Math.floor(number));
245
- }
246
- /**
247
- * Ticket budget chosen when the main bot dispatches.
248
- * An omitted field is one standard slice. An explicit estimate is kept, with a
249
- * floor of 1000. Later grants add on top and are not capped by this slice.
236
+ * Opening ticket budget. Dispatch does not choose it: a budget passed with the
237
+ * ticket is ignored, and every ticket starts on one host slice. Later grants
238
+ * add another slice and are not capped by this one.
250
239
  * @param {string} _briefing
251
- * @param {{ wallMs?: number, maxTokens?: number } | null | undefined} suggestion
240
+ * @param {{ wallMs?: number, maxTokens?: number } | null | undefined} _suggestion
252
241
  * @param {typeof DEFAULT_WORK_BUDGET} defaults
253
242
  */
254
- export function estimateWorkerBudget(_briefing, suggestion, defaults = DEFAULT_WORK_BUDGET) {
243
+ export function estimateWorkerBudget(_briefing, _suggestion, defaults = DEFAULT_WORK_BUDGET) {
255
244
  return {
256
- wallMs: clampAtLeast(suggestion?.wallMs, 1000) ?? defaults.workerWallMs,
257
- maxTokens: clampAtLeast(suggestion?.maxTokens, 1000) ?? defaults.workerMaxTokens,
245
+ wallMs: defaults.workerWallMs,
246
+ maxTokens: defaults.workerMaxTokens,
258
247
  perBot: defaults.perBot,
259
248
  global: defaults.global,
260
249
  perBotQueue: defaults.perBotQueue,
@@ -9,6 +9,12 @@
9
9
  * composed host bash-sandbox and approval policy.
10
10
  */
11
11
  export const WORKER_FILE_PRESET = 'foundations-files';
12
+ /**
13
+ * Canvas workers read workspace reference files and write the preview through
14
+ * canvas tools. They do not get write, edit, bash, or jobs. A workspace `write`
15
+ * is not a canvas revision, and models treat that tool as the deliverable.
16
+ */
17
+ export const CANVAS_WORKER_PRESET = 'foundations-canvas';
12
18
  /**
13
19
  * @param {import('@deepseek-ai/cordis').Context} ctx
14
20
  */
@@ -36,24 +42,35 @@ export function ensureWorkerFilePreset(ctx) {
36
42
  const presets = presetsOf(ctx);
37
43
  if (!presets?.register || !presets?.mount)
38
44
  return Promise.resolve(null);
39
- return presets
40
- .register({
45
+ const fileTools = {
46
+ id: 'tool-fs',
47
+ name: '@deepseek-ai/dsh-tool-fs',
48
+ config: { applyPatch: false, readImage: false },
49
+ };
50
+ const canvasFileTools = {
51
+ id: 'tool-fs',
52
+ name: '@deepseek-ai/dsh-tool-fs',
53
+ config: { applyPatch: false, readImage: false, write: false, edit: false },
54
+ };
55
+ return registerPreset(presets, {
41
56
  id: WORKER_FILE_PRESET,
42
57
  plugins: [
43
- {
44
- id: 'tool-fs',
45
- name: '@deepseek-ai/dsh-tool-fs',
46
- config: { applyPatch: false, readImage: false },
47
- },
58
+ fileTools,
48
59
  { id: 'tool-bash', name: '@deepseek-ai/dsh-tool-bash' },
49
60
  { id: 'tool-jobs', name: '@deepseek-ai/dsh-tool-jobs' },
50
61
  ],
51
62
  })
52
- .then(() => WORKER_FILE_PRESET)
53
- .catch((error) => {
63
+ .then(() => registerPreset(presets, {
64
+ id: CANVAS_WORKER_PRESET,
65
+ plugins: [canvasFileTools],
66
+ }))
67
+ .then(() => WORKER_FILE_PRESET);
68
+ }
69
+ function registerPreset(presets, spec) {
70
+ return presets.register(spec).catch((error) => {
54
71
  const message = error instanceof Error ? error.message : String(error);
55
72
  if (message.includes('Duplicate'))
56
- return WORKER_FILE_PRESET;
73
+ return spec;
57
74
  throw error;
58
75
  });
59
76
  }
package/dist/work-http.js CHANGED
@@ -144,6 +144,23 @@ export function openPageLive(req, res, source) {
144
144
  let interactionTimer = null;
145
145
  let lastInteractions = '';
146
146
  let interactionFailed = false;
147
+ let lastCanvas = '';
148
+ const pumpCanvas = () => {
149
+ if (stopped || !source.canvas)
150
+ return;
151
+ try {
152
+ const text = JSON.stringify(source.canvas());
153
+ if (text === lastCanvas)
154
+ return;
155
+ lastCanvas = text;
156
+ if (text === '{"ok":true,"events":[]}')
157
+ return;
158
+ res.write(`event: canvas\ndata: ${text}\n\n`);
159
+ }
160
+ catch {
161
+ // A canvas notice failure leaves the desk and ticket streams open.
162
+ }
163
+ };
147
164
  const pumpInteractions = () => {
148
165
  if (stopped || !source.interactions)
149
166
  return;
@@ -225,6 +242,7 @@ export function openPageLive(req, res, source) {
225
242
  busy = false;
226
243
  }
227
244
  };
245
+ pumpCanvas();
228
246
  pumpInteractions();
229
247
  if (source.interactions) {
230
248
  interactionTimer = setInterval(pumpInteractions, intervalMs);
@@ -232,6 +250,7 @@ export function openPageLive(req, res, source) {
232
250
  }
233
251
  void pump();
234
252
  timer = setInterval(() => {
253
+ pumpCanvas();
235
254
  void pump();
236
255
  }, intervalMs);
237
256
  timer.unref?.();
@@ -23,6 +23,9 @@ export function renderBriefing(input) {
23
23
  'You may read the main session. The host already queried it and attached the excerpt below. foundations_main_history reads it again directly and does not raise an authorization prompt.',
24
24
  'Report only with foundations_report. kind must be progress, question, artifact, result, or failure.',
25
25
  'This is not cross-bot mail and cannot raise permissions.',
26
+ ...(input.kind === 'steer'
27
+ ? ['This is steering. The previous turn was stopped. Do not continue that approach. Follow only the text below.']
28
+ : []),
26
29
  '---',
27
30
  input.text,
28
31
  ];
@@ -383,12 +386,13 @@ export async function pushInput(book, input, deps) {
383
386
  }
384
387
  }
385
388
  const body = renderBriefing({ text, revision: input.briefing_revision, budget, kind: input.kind, history });
389
+ const deliver = input.kind === 'steer' && deps.steer ? deps.steer : deps.push;
386
390
  deps.inflight.add(input.native_message_id);
387
391
  try {
388
392
  return await durableFollowup({
389
393
  attempts: input.flush_attempts,
390
394
  markFlushing: () => book.markInputFlush(input.id, 'flushing', deps.pid, '', null, true),
391
- push: () => deps.push(attempt.child_session_id, input.native_message_id, body),
395
+ push: () => deliver(attempt.child_session_id, input.native_message_id, body),
392
396
  markAccepted: seq => book.noteInputAccepted(input, seq),
393
397
  markAmbiguous: error => book.markInputFlush(input.id, 'ambiguous', deps.pid, error, null, false),
394
398
  markDead: error => book.markInputFlush(input.id, 'dead', deps.pid, error, null, false),
package/dist/work-mock.js CHANGED
@@ -9,6 +9,8 @@ export function createMockWorld() {
9
9
  const calls = [];
10
10
  const cancels = [];
11
11
  const pushes = [];
12
+ const steers = [];
13
+ const order = [];
12
14
  const state = {
13
15
  failCreate: false,
14
16
  flushMode: 'accepted',
@@ -17,6 +19,8 @@ export function createMockWorld() {
17
19
  calls,
18
20
  cancels,
19
21
  pushes,
22
+ steers,
23
+ order,
20
24
  state,
21
25
  session,
22
26
  pendingIds(sessionId) {
@@ -100,12 +104,18 @@ export function createMockWorld() {
100
104
  return true;
101
105
  },
102
106
  async cancel(sessionId, options) {
107
+ order.push('cancel');
103
108
  cancels.push({
104
109
  sessionId,
105
110
  keepInbox: options?.keepInbox === true,
106
111
  ...(typeof options?.reason === 'string' ? { reason: options.reason } : {}),
107
112
  });
108
113
  },
114
+ async steer(sessionId, messageId, text) {
115
+ order.push('steer');
116
+ steers.push({ sessionId, messageId, text });
117
+ return this.push(sessionId, messageId, text);
118
+ },
109
119
  async snapshot(sessionId) {
110
120
  return session(sessionId).events.map(event => ({ ...event, data: event.data }));
111
121
  },
@@ -337,7 +337,7 @@ export function createTicketBook(db, root, now = () => new Date()) {
337
337
  * ticketId: string,
338
338
  * attemptId: string,
339
339
  * revision: number,
340
- * kind: 'briefing' | 'supply' | 'redirect' | 'cancel_note',
340
+ * kind: 'briefing' | 'supply' | 'redirect' | 'steer' | 'cancel_note',
341
341
  * text: string,
342
342
  * }} input
343
343
  */
@@ -406,7 +406,7 @@ export function createTicketBook(db, root, now = () => new Date()) {
406
406
  * Ticket status stays until flush confirms. Returns null on CAS conflict.
407
407
  * @param {string} ticketId
408
408
  * @param {number | null} expectedRevision
409
- * @param {'supply' | 'redirect'} kind
409
+ * @param {'supply' | 'redirect' | 'steer'} kind
410
410
  * @param {string} text
411
411
  */
412
412
  function advanceGeneration(ticketId, expectedRevision, kind, text) {
@@ -423,7 +423,7 @@ export function createTicketBook(db, root, now = () => new Date()) {
423
423
  if (!allowed)
424
424
  return {
425
425
  error: 'VALIDATION',
426
- message: `Ticket status ${ticket.status} cannot ${kind === 'supply' ? 'supply' : 'redirect'}.`,
426
+ message: `Ticket status ${ticket.status} cannot ${kind}.`,
427
427
  };
428
428
  if (!ticket.child_session_id)
429
429
  return {
@@ -1359,6 +1359,8 @@ function hostFailureText(reason) {
1359
1359
  return 'The main session refused more budget and this round has stopped.';
1360
1360
  if (reason === 'lease')
1361
1361
  return 'The worker lease expired and this round has stopped.';
1362
+ if (reason === 'no-report')
1363
+ return 'The worker ended its turn without a report. The session was still running; this was not a lease or heartbeat timeout.';
1362
1364
  if (reason === 'enqueue-wall')
1363
1365
  return 'The task entered the queue and did not start before the time limit.';
1364
1366
  if (reason === 'reserve-wall')
@@ -19,19 +19,11 @@ const OUTPUT = {
19
19
  */
20
20
  export function workToolDefinitions(work, engine) {
21
21
  return [
22
- tool('foundations_dispatch', 'Hand a non-trivial job to a worker session. Prefer this over doing the work with bash, write, edit, or an official subagent in the main session. Available only on a bot. status=accepted means received, and may wait for an execution slot. status=enqueued means it entered the execution queue, not that it has started. queued=true means it is waiting for a slot and will start automatically when one is free. The return value is never started. A BUDGET error means both the slot cap and the queue cap are full; do not start the job in the main session. ownerSessionId is ignored.', {
22
+ tool('foundations_dispatch', `Hand a non-trivial job to a worker session. Prefer this over doing the work with bash, write, edit, or an official subagent in the main session. Available only on a bot. The host assigns the opening budget of one standard slice (${SLICE}). Do not pass a budget. status=accepted means received, and may wait for an execution slot. status=enqueued means it entered the execution queue, not that it has started. queued=true means it is waiting for a slot and will start automatically when one is free. The return value is never started. A BUDGET error means both the slot cap and the queue cap are full; do not start the job in the main session. ownerSessionId is ignored.`, {
23
23
  type: 'object',
24
24
  properties: {
25
25
  briefing: { type: 'string' },
26
26
  idempotencyKey: { type: 'string' },
27
- budget: {
28
- type: 'object',
29
- description: `Time and token budget for this ticket. When omitted, the host uses one standard slice (${SLICE}). Pass that slice. Do not estimate a smaller budget. Later grants add more slices with no cumulative ceiling.`,
30
- properties: {
31
- wallMs: { type: 'integer', description: 'Expected maximum runtime in milliseconds.' },
32
- maxTokens: { type: 'integer', description: 'Expected maximum tokens.' },
33
- },
34
- },
35
27
  correlationId: { type: 'string' },
36
28
  ownerSessionId: { type: 'string', description: 'Ignored. The host uses the current session.' },
37
29
  parentTicketId: { type: 'string', description: 'The MVP rejects a non-empty value.' },
@@ -58,6 +50,16 @@ export function workToolDefinitions(work, engine) {
58
50
  },
59
51
  required: ['text'],
60
52
  }, (args, hostId) => work.redirect(hostId, args), 'bot'),
53
+ tool('foundations_steer', 'Interrupt a running worker. The current turn stops and text is what the worker does next. Use this when the worker is on the wrong path. foundations_redirect does not stop the current turn. Old reports from the previous generation become stale.', {
54
+ type: 'object',
55
+ properties: {
56
+ text: { type: 'string', description: 'The correction. Say what to stop and what to do instead.' },
57
+ ticketId: { type: 'string' },
58
+ expectedRevision: { type: 'integer' },
59
+ ownerSessionId: { type: 'string', description: 'Ignored.' },
60
+ },
61
+ required: ['text'],
62
+ }, (args, hostId) => work.steer(hostId, args), 'bot'),
61
63
  tool('foundations_cancel', 'Cancel the ticket. Ticket notices that have not been claimed are removed from the inbox. It does not start again on its own.', {
62
64
  type: 'object',
63
65
  properties: {