@thready-web/dsh-bot-plugin 0.1.0-beta.10 → 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.
- package/dist/canvas-http.js +248 -0
- package/dist/canvas-skills.js +56 -0
- package/dist/canvas-store.js +794 -0
- package/dist/canvas-tools.js +211 -0
- package/dist/context.js +1 -0
- package/dist/http.js +19 -0
- package/dist/index.js +11 -0
- package/dist/work-http.js +19 -0
- package/dist/work-worker.js +5 -0
- package/package.json +2 -1
- package/public/assets/{SourceEditor-BEQaScgR.js → SourceEditor-uu0G7jsM.js} +3 -3
- package/public/assets/{cssMode-gpcjCFFS.js → cssMode-C5DAFF5H.js} +1 -1
- package/public/assets/{freemarker2-C1qemGIt.js → freemarker2-DExNwSiZ.js} +1 -1
- package/public/assets/{handlebars-sZqIfAlP.js → handlebars-BK7YAvpQ.js} +1 -1
- package/public/assets/{html-Bn1WXB8L.js → html-CdDm_zae.js} +1 -1
- package/public/assets/{htmlMode-CvQyXnaW.js → htmlMode-CLdn9oa1.js} +1 -1
- package/public/assets/index-BB-QDSf2.css +1 -0
- package/public/assets/index-CsX-_qbo.js +62 -0
- package/public/assets/{javascript-Ox4Jg12j.js → javascript-mLl83_3W.js} +1 -1
- package/public/assets/{jsonMode-DMR7R2dQ.js → jsonMode-B1-bihFd.js} +1 -1
- package/public/assets/{liquid-B6HxtpBd.js → liquid-Cv8m0HUb.js} +1 -1
- package/public/assets/{mdx--jDhmrXq.js → mdx-Q12b91rL.js} +1 -1
- package/public/assets/{python-YjG50skX.js → python-Kda811W0.js} +1 -1
- package/public/assets/{razor-CEcFE3UK.js → razor-CRuCpdOW.js} +1 -1
- package/public/assets/{tsMode-g4kTQl09.js → tsMode-BGHcz-M3.js} +1 -1
- package/public/assets/{typescript-CnHeFmPW.js → typescript-Db1e0DCT.js} +1 -1
- package/public/assets/{xml-BFXMY9nb.js → xml-H3zzFmnd.js} +1 -1
- package/public/assets/{yaml-DNm87nSf.js → yaml-BQrKvmTF.js} +1 -1
- package/public/index.html +2 -2
- package/skills/ui/baseline-ui/SKILL.md +85 -0
- package/skills/ui/bencium-innovative-ux-designer/SKILL.md +227 -0
- package/skills/ui/better-ui/SKILL.md +133 -0
- package/skills/ui/design-lab/SKILL.md +920 -0
- package/skills/ui/frontend-design/SKILL.md +71 -0
- package/skills/ui/impeccable/SKILL.md +93 -0
- package/skills/ui/interface-design/SKILL.md +320 -0
- package/skills/ui/sources.json +66 -0
- package/skills/ui/ui-design/SKILL.md +35 -0
- package/skills/ui/ui-skills-root/SKILL.md +59 -0
- package/skills/ui/visual-design-foundations/SKILL.md +318 -0
- package/skills/ui/web-design-guidelines/SKILL.md +39 -0
- package/public/assets/index-DRNkUrer.css +0 -1
- package/public/assets/index-DhL5Kdlz.js +0 -63
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { bindCanvasSkills } from "./canvas-skills.js";
|
|
2
|
+
import { CANVAS_MAX_FILE_BYTES } from "./canvas-store.js";
|
|
3
|
+
import { toolError } from "./errors.js";
|
|
4
|
+
const BRIEFING_MAX = 16000;
|
|
5
|
+
const OUTPUT = {
|
|
6
|
+
schema: {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: { ok: { type: 'boolean' } },
|
|
9
|
+
required: ['ok'],
|
|
10
|
+
},
|
|
11
|
+
render(_args, value) {
|
|
12
|
+
return [{ type: 'text', text: JSON.stringify(value) }];
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Canvas generation tools. The host shows one tool list to every session;
|
|
17
|
+
* execute rejects the main bot and any worker that does not own this canvas.
|
|
18
|
+
* A budget wait never comes through these tools, and they do not mark a preview failed.
|
|
19
|
+
*/
|
|
20
|
+
export function canvasToolDefinitions(canvas, work, engine) {
|
|
21
|
+
return [
|
|
22
|
+
tool('foundations_dispatch_canvas', 'Open a canvas design worker for an HTML/CSS preview. Use this instead of foundations_dispatch, write, or edit when the user wants a visual design, page mock, or preview. The main session must not build the preview. A returned canvasId has no revision until the worker publishes. A budget pause is not a failed preview.', {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
briefing: { type: 'string', description: 'What to design. The host wraps this with the canvas contract.' },
|
|
26
|
+
idempotencyKey: { type: 'string' },
|
|
27
|
+
budget: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
wallMs: { type: 'integer' },
|
|
31
|
+
maxTokens: { type: 'integer' },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
correlationId: { type: 'string' },
|
|
35
|
+
},
|
|
36
|
+
required: ['briefing'],
|
|
37
|
+
}, (args, hostId) => dispatchCanvas(canvas, work, engine, hostId, args)),
|
|
38
|
+
tool('canvas_write', 'Stage HTML, CSS, images, or fonts for the canvas bound to this worker. The main bot and every other worker are rejected. text is for HTML and CSS. body is standard base64 for images and fonts. This does not publish and does not mark the preview failed.', {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
files: {
|
|
42
|
+
type: 'array',
|
|
43
|
+
items: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
path: { type: 'string' },
|
|
47
|
+
type: { type: 'string' },
|
|
48
|
+
text: { type: 'string' },
|
|
49
|
+
body: { type: 'string' },
|
|
50
|
+
},
|
|
51
|
+
required: ['path', 'type'],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
remove: { type: 'array', items: { type: 'string' } },
|
|
55
|
+
},
|
|
56
|
+
}, async (args, hostId) => {
|
|
57
|
+
const canvasId = ownedCanvas(canvas, work, engine, hostId);
|
|
58
|
+
if (typeof canvasId !== 'string')
|
|
59
|
+
return canvasId;
|
|
60
|
+
const files = decodeFiles(args.files);
|
|
61
|
+
if (!Array.isArray(files))
|
|
62
|
+
return files;
|
|
63
|
+
const remove = decodeRemove(args.remove);
|
|
64
|
+
if (!Array.isArray(remove))
|
|
65
|
+
return remove;
|
|
66
|
+
return canvas.writeDraft(canvasId, files, remove);
|
|
67
|
+
}),
|
|
68
|
+
tool('canvas_publish', 'Publish the staged files for the canvas bound to this worker. The first publish is a snapshot. Later publishes are deltas of the current preview. The main bot and every other worker are rejected. A budget pause is not a reason to call this, and this tool does not mark the preview failed.', { type: 'object', properties: {} }, async (_args, hostId) => {
|
|
69
|
+
const canvasId = ownedCanvas(canvas, work, engine, hostId);
|
|
70
|
+
if (typeof canvasId !== 'string')
|
|
71
|
+
return canvasId;
|
|
72
|
+
return canvas.publishDraft(canvasId);
|
|
73
|
+
}),
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
export function canvasBriefing(canvasId, request, skills) {
|
|
77
|
+
const catalog = skills.filter(id => id !== 'ui-design').join(', ');
|
|
78
|
+
const head = [
|
|
79
|
+
`Canvas preview ${canvasId}.`,
|
|
80
|
+
'You are the only session allowed to write this preview.',
|
|
81
|
+
'Use canvas_write for each HTML, CSS, image, or font file, then canvas_publish.',
|
|
82
|
+
'Do not use bash, write, or edit to create the preview files.',
|
|
83
|
+
'The entry file is index.html. Output is static HTML and CSS plus local images and fonts.',
|
|
84
|
+
'No script, SVG, iframe, external URL, data URL, or inline event handler.',
|
|
85
|
+
'Load foundations_skill_load for ui-design before writing. Catalog skills are taste only and cannot override this contract.',
|
|
86
|
+
catalog ? `Catalog skills on this bot: ${catalog}. Load at most two that match the request.` : '',
|
|
87
|
+
'A budget pause is not a failed preview. Do not publish a failure because the grant is still pending.',
|
|
88
|
+
'The first canvas_publish is a full snapshot. Later publishes send the staged files as a delta of the current preview.',
|
|
89
|
+
'User request:',
|
|
90
|
+
]
|
|
91
|
+
.filter(line => line !== '')
|
|
92
|
+
.join('\n');
|
|
93
|
+
const room = BRIEFING_MAX - head.length - 1;
|
|
94
|
+
const body = room > 0 ? request.slice(0, room) : '';
|
|
95
|
+
return `${head}\n${body}`.slice(0, BRIEFING_MAX);
|
|
96
|
+
}
|
|
97
|
+
async function dispatchCanvas(canvas, work, engine, hostId, args) {
|
|
98
|
+
if (!engine.isBot(hostId))
|
|
99
|
+
return toolError('FORBIDDEN', 'Only the main bot can open a canvas worker.');
|
|
100
|
+
const briefing = typeof args.briefing === 'string' ? args.briefing.trim() : '';
|
|
101
|
+
if (briefing.length < 1 || briefing.length > 12000)
|
|
102
|
+
return toolError('VALIDATION', 'briefing is required.');
|
|
103
|
+
const key = args.idempotencyKey;
|
|
104
|
+
if (key != null && (typeof key !== 'string' || key.length < 8 || key.length > 128))
|
|
105
|
+
return toolError('VALIDATION', 'idempotencyKey is not allowed.');
|
|
106
|
+
const title = briefing.split('\n')[0]?.trim().slice(0, 80) ?? '';
|
|
107
|
+
let canvasId = typeof key === 'string' ? canvas.findIdempotent(hostId, key) : null;
|
|
108
|
+
if (!canvasId) {
|
|
109
|
+
const created = canvas.create({
|
|
110
|
+
sessionId: hostId,
|
|
111
|
+
title,
|
|
112
|
+
createdBy: 'bot',
|
|
113
|
+
idempotencyKey: typeof key === 'string' ? key : null,
|
|
114
|
+
});
|
|
115
|
+
if (created.ok === false)
|
|
116
|
+
return created;
|
|
117
|
+
canvasId = created.canvas?.id;
|
|
118
|
+
}
|
|
119
|
+
if (typeof canvasId !== 'string')
|
|
120
|
+
return toolError('STORE_FAILURE', 'The canvas was not created.');
|
|
121
|
+
let skills = [];
|
|
122
|
+
try {
|
|
123
|
+
skills = bindCanvasSkills(engine, hostId).bound;
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
return toolError('STORE_FAILURE', error instanceof Error ? error.message : 'Canvas skills could not be bound.');
|
|
127
|
+
}
|
|
128
|
+
const forwarded = {
|
|
129
|
+
briefing: canvasBriefing(canvasId, briefing, skills),
|
|
130
|
+
};
|
|
131
|
+
if (typeof key === 'string')
|
|
132
|
+
forwarded.idempotencyKey = key;
|
|
133
|
+
if (args.budget != null)
|
|
134
|
+
forwarded.budget = args.budget;
|
|
135
|
+
if (typeof args.correlationId === 'string')
|
|
136
|
+
forwarded.correlationId = args.correlationId;
|
|
137
|
+
const dispatched = await work.dispatch(hostId, forwarded);
|
|
138
|
+
if (dispatched.ok === true && typeof dispatched.ticketId === 'string')
|
|
139
|
+
canvas.attachTicket(canvasId, dispatched.ticketId);
|
|
140
|
+
return { ...dispatched, canvasId };
|
|
141
|
+
}
|
|
142
|
+
function ownedCanvas(canvas, work, engine, hostId) {
|
|
143
|
+
if (engine.isBot(hostId))
|
|
144
|
+
return toolError('FORBIDDEN', 'The main bot cannot write a canvas preview.');
|
|
145
|
+
const canvasId = canvas.canvasIdForTicket(work.ticketIdOf(hostId));
|
|
146
|
+
if (!canvasId)
|
|
147
|
+
return toolError('FORBIDDEN', 'Only the canvas worker for this preview can write it.');
|
|
148
|
+
return canvasId;
|
|
149
|
+
}
|
|
150
|
+
function decodeFiles(input) {
|
|
151
|
+
if (input == null)
|
|
152
|
+
return [];
|
|
153
|
+
if (!Array.isArray(input))
|
|
154
|
+
return toolError('VALIDATION', 'files are not allowed.');
|
|
155
|
+
const files = [];
|
|
156
|
+
for (const item of input) {
|
|
157
|
+
if (!item || typeof item !== 'object')
|
|
158
|
+
return toolError('VALIDATION', 'A canvas file is not allowed.');
|
|
159
|
+
const record = item;
|
|
160
|
+
if (typeof record.path !== 'string' || typeof record.type !== 'string')
|
|
161
|
+
return toolError('VALIDATION', 'A canvas file is not allowed.');
|
|
162
|
+
const text = record.text;
|
|
163
|
+
const body = record.body;
|
|
164
|
+
if (typeof text === 'string' && typeof body === 'string')
|
|
165
|
+
return toolError('VALIDATION', 'A canvas file has both text and body.');
|
|
166
|
+
if (typeof text === 'string') {
|
|
167
|
+
if (record.type !== 'text/html' && record.type !== 'text/css')
|
|
168
|
+
return toolError('VALIDATION', 'text is only for HTML and CSS.');
|
|
169
|
+
const bytes = Buffer.from(text, 'utf8');
|
|
170
|
+
if (bytes.length > CANVAS_MAX_FILE_BYTES)
|
|
171
|
+
return toolError('VALIDATION', `${record.path} exceeds the 1.5 MiB file cap.`);
|
|
172
|
+
files.push({ path: record.path, type: record.type, bytes });
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (typeof body === 'string') {
|
|
176
|
+
const packed = body.replace(/\s/g, '');
|
|
177
|
+
if (packed.length === 0 || packed.length > CANVAS_MAX_FILE_BYTES * 2 || !/^[A-Za-z0-9+/=]+$/.test(packed))
|
|
178
|
+
return toolError('VALIDATION', `${record.path} body is not base64.`);
|
|
179
|
+
files.push({ path: record.path, type: record.type, bytes: Buffer.from(packed, 'base64') });
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
return toolError('VALIDATION', 'A canvas file needs text or body.');
|
|
183
|
+
}
|
|
184
|
+
return files;
|
|
185
|
+
}
|
|
186
|
+
function decodeRemove(input) {
|
|
187
|
+
if (input == null)
|
|
188
|
+
return [];
|
|
189
|
+
if (!Array.isArray(input) || input.some(item => typeof item !== 'string'))
|
|
190
|
+
return toolError('VALIDATION', 'remove is not allowed.');
|
|
191
|
+
return input;
|
|
192
|
+
}
|
|
193
|
+
function tool(name, description, parameters, run) {
|
|
194
|
+
return {
|
|
195
|
+
name,
|
|
196
|
+
description,
|
|
197
|
+
parameters,
|
|
198
|
+
output: OUTPUT,
|
|
199
|
+
async execute(args, exec) {
|
|
200
|
+
const hostId = exec?.agent?.id;
|
|
201
|
+
if (typeof hostId !== 'string' || hostId === '')
|
|
202
|
+
return toolError('UNAVAILABLE', 'The host did not bind a sessionId.');
|
|
203
|
+
try {
|
|
204
|
+
return await run(args ?? {}, hostId);
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
return toolError('STORE_FAILURE', error instanceof Error ? error.message : String(error));
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
}
|
package/dist/context.js
CHANGED
|
@@ -19,6 +19,7 @@ export const CHAT = [
|
|
|
19
19
|
'Example, same turn. Step 1 already delivered the recursive DNS path. The user then interjects: add the difference between recursive and iterative resolution, and do not drop the recursive path. Step 2 is only the difference: recursive resolution means you run the whole lookup for the client; iterative resolution means you say whom to ask next. A recursive resolver is recursive toward the client and iterative toward the root, the TLD, and the authoritative servers. Step 2 does not repeat the path.',
|
|
20
20
|
'When the user did not ask you to look something up, edit files, dispatch work, or contact another bot, do not call tools and do not mention steps or system state.',
|
|
21
21
|
'Default: hand every non-trivial task to a worker with foundations_dispatch. The main session plans, estimates budget, waits for ticket notices, reviews results, and replies to the user.',
|
|
22
|
+
'A visual design, HTML preview, or page mock goes to foundations_dispatch_canvas. Do not use foundations_dispatch, write, or edit in the main session to build that preview.',
|
|
22
23
|
'Direct execution is allowed only for a short reply that needs no tools; a tiny read-only check (one or two reads) needed to write a briefing or answer a simple question; or when the user clearly asked you to do the work yourself in this session and no worker owns that work. Do not run a multi-step shell, edit, or write chain in the main session without one of those exceptions. A task already handed to a worker stays with that worker.',
|
|
23
24
|
"Prefer foundations_dispatch over bash, write, edit, and any official subagent tool for this bot's work. Official subagent is not the ticket worker.",
|
|
24
25
|
'If an unfinished ticket can take the new work, call foundations_redirect and reuse that worker. Independent tasks may run in parallel up to the host slot cap. Dependent steps stay serial on the same ticket. Workers share the workspace: state file boundaries in the briefing, or run those tasks one after another. There is no filesystem isolation between workers.',
|
package/dist/http.js
CHANGED
|
@@ -14,6 +14,8 @@ import { createLogSource } from "./log/source.js";
|
|
|
14
14
|
import { createLogSnapshotService } from "./log/snapshot-service.js";
|
|
15
15
|
import { dispatchLogRequest, probeConnection, registerLogRoutes } from "./log/routes.js";
|
|
16
16
|
import { handleMemoryRoute } from "./memory-catalog.js";
|
|
17
|
+
import { handleCanvasApi, serveCanvasMedia } from "./canvas-http.js";
|
|
18
|
+
import { openCanvasStore } from "./canvas-store.js";
|
|
17
19
|
/**
|
|
18
20
|
* Local management routes. Model tools cannot confirm a persona or change revocation.
|
|
19
21
|
* @param {import('@deepseek-ai/cordis').Context} ctx
|
|
@@ -27,6 +29,7 @@ export function registerHttp(ctx, engine, getRuntime = () => null, getWork = ()
|
|
|
27
29
|
const webServer = ctx.webServer;
|
|
28
30
|
const storeDir = dataDir || (ctx.profileContext?.dir ? join(ctx.profileContext.dir, 'session-foundations') : '');
|
|
29
31
|
const profileDir = ctx.profileContext?.dir || (storeDir !== '' ? dirname(storeDir) : '');
|
|
32
|
+
const canvas = storeDir === '' ? null : openCanvasStore(join(storeDir, 'canvas.sqlite'));
|
|
30
33
|
const logService = createLogSnapshotService(createLogSource(ctx));
|
|
31
34
|
const logOnConnection = registerLogRoutes(ctx, logService);
|
|
32
35
|
const persistence = ctx.sessionPersistence;
|
|
@@ -89,6 +92,10 @@ export function registerHttp(ctx, engine, getRuntime = () => null, getWork = ()
|
|
|
89
92
|
};
|
|
90
93
|
}
|
|
91
94
|
const handler = async (req, res) => {
|
|
95
|
+
const requestTarget = req.url ?? '/';
|
|
96
|
+
if ((requestTarget.split('?')[0] ?? '').startsWith('/dsh-bot/canvas-media/')) {
|
|
97
|
+
return serveCanvasMedia(req, res, requestTarget, canvas);
|
|
98
|
+
}
|
|
92
99
|
const rejection = reject(ctx, req);
|
|
93
100
|
if (rejection)
|
|
94
101
|
return send(res, rejection, { ok: false, code: 'FORBIDDEN' });
|
|
@@ -409,6 +416,7 @@ export function registerHttp(ctx, engine, getRuntime = () => null, getWork = ()
|
|
|
409
416
|
workBoard: () => work.liveBoardAll(),
|
|
410
417
|
loadDesk: () => loadPageDesk(req),
|
|
411
418
|
interactions: () => interactionSnapshot(url.searchParams.get('sessionId') ?? '', true),
|
|
419
|
+
...(canvas ? { canvas: () => canvas.live(url.searchParams.get('sessionId') ?? '') } : {}),
|
|
412
420
|
});
|
|
413
421
|
}
|
|
414
422
|
if (req.method === 'GET' && path === '/session-foundations/api/work/live') {
|
|
@@ -417,6 +425,11 @@ export function registerHttp(ctx, engine, getRuntime = () => null, getWork = ()
|
|
|
417
425
|
return send(res, 503, toolError('UNAVAILABLE', 'The work host is not attached yet.'));
|
|
418
426
|
return openWorkLive(req, res, url.searchParams.get('sessionId') ?? '', work);
|
|
419
427
|
}
|
|
428
|
+
if (canvas &&
|
|
429
|
+
(path === '/session-foundations/api/canvas' || path.startsWith('/session-foundations/api/canvas/'))) {
|
|
430
|
+
const outcome = await handleCanvasApi(req, path, url, canvas);
|
|
431
|
+
return send(res, outcome.status, outcome.body);
|
|
432
|
+
}
|
|
420
433
|
if (path.startsWith('/session-foundations/api/work')) {
|
|
421
434
|
const workBody = req.method === 'GET' ? {} : await readJson(req);
|
|
422
435
|
const workHit = await handleWorkApi(req.method ?? 'GET', path, url, workBody, getWork());
|
|
@@ -469,6 +482,12 @@ export function registerHttp(ctx, engine, getRuntime = () => null, getWork = ()
|
|
|
469
482
|
disposeDesk();
|
|
470
483
|
if (typeof disposeLog === 'function')
|
|
471
484
|
disposeLog();
|
|
485
|
+
try {
|
|
486
|
+
canvas?.close();
|
|
487
|
+
}
|
|
488
|
+
catch {
|
|
489
|
+
/* closed */
|
|
490
|
+
}
|
|
472
491
|
};
|
|
473
492
|
});
|
|
474
493
|
}
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,8 @@ import { childCreateOptions, effectiveWorkLimits, pinMainReasoning, resolveWorkB
|
|
|
16
16
|
import { ensureWorkerFilePreset, WORKER_FILE_PRESET, workerFileSetup } from "./work-child.js";
|
|
17
17
|
import { BUDGET_NOTICE_PREFIX, createWorkRuntime } from "./work-worker.js";
|
|
18
18
|
import { workToolDefinitions } from "./work-tools.js";
|
|
19
|
+
import { openCanvasStore } from "./canvas-store.js";
|
|
20
|
+
import { canvasToolDefinitions } from "./canvas-tools.js";
|
|
19
21
|
export const name = 'session-foundations';
|
|
20
22
|
// Cordis throws if a plugin reads a service it did not inject. Crash recovery reads the session log through this one.
|
|
21
23
|
export const inject = [
|
|
@@ -37,6 +39,7 @@ export function apply(ctx, config = {}) {
|
|
|
37
39
|
if (dataDir === '')
|
|
38
40
|
throw new Error('session-foundations: pass dataDir or launch with dsh profileContext');
|
|
39
41
|
const store = openStore(dataDir);
|
|
42
|
+
const canvas = openCanvasStore(join(dataDir, 'canvas.sqlite'));
|
|
40
43
|
const engine = createEngine(store);
|
|
41
44
|
const recovery = engine.recover();
|
|
42
45
|
const ownerFile = join(dataDir, 'owner.json');
|
|
@@ -56,6 +59,12 @@ export function apply(ctx, config = {}) {
|
|
|
56
59
|
catch {
|
|
57
60
|
/* closed */
|
|
58
61
|
}
|
|
62
|
+
try {
|
|
63
|
+
canvas.close();
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
/* closed */
|
|
67
|
+
}
|
|
59
68
|
});
|
|
60
69
|
/** @type {ReturnType<typeof createTriggers> | null} */
|
|
61
70
|
let triggers = null;
|
|
@@ -221,6 +230,8 @@ export function apply(ctx, config = {}) {
|
|
|
221
230
|
if (work) {
|
|
222
231
|
for (const definition of workToolDefinitions(work, engine))
|
|
223
232
|
ctx.tools.register(definition);
|
|
233
|
+
for (const definition of canvasToolDefinitions(canvas, work, engine))
|
|
234
|
+
ctx.tools.register(definition);
|
|
224
235
|
const gate = work;
|
|
225
236
|
// Main-session step budget: refuse the next step instead of cancelling a
|
|
226
237
|
// step that already ended. A refused step ends the turn as `blocked`.
|
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?.();
|
package/dist/work-worker.js
CHANGED
|
@@ -93,6 +93,7 @@ export function createWorkRuntime(store, engine, options = {}) {
|
|
|
93
93
|
waitForBudget,
|
|
94
94
|
isWorkerSession,
|
|
95
95
|
ownerOf,
|
|
96
|
+
ticketIdOf,
|
|
96
97
|
summaries: (owner) => book.summaries(owner),
|
|
97
98
|
detail: (id) => book.detail(id),
|
|
98
99
|
liveStamp: () => book.liveStamp(),
|
|
@@ -117,6 +118,10 @@ export function createWorkRuntime(store, engine, options = {}) {
|
|
|
117
118
|
const owner = book.ticket(attempt.ticket_id)?.owner_session_id;
|
|
118
119
|
return typeof owner === 'string' && owner !== '' ? owner : null;
|
|
119
120
|
}
|
|
121
|
+
function ticketIdOf(sessionId) {
|
|
122
|
+
const ticketId = book.attemptForChild(sessionId)?.ticket_id;
|
|
123
|
+
return typeof ticketId === 'string' && ticketId !== '' ? ticketId : null;
|
|
124
|
+
}
|
|
120
125
|
/**
|
|
121
126
|
* Direct read of the main session that owns this worker. No authorization prompt.
|
|
122
127
|
* @param {string} sessionId
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thready-web/dsh-bot-plugin",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
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": {
|