unsys-canvas 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +10 -2
- package/dist/core.d.ts +508 -0
- package/dist/core.js +3579 -0
- package/dist/core.js.map +1 -0
- package/dist/index.css +296 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +703 -0
- package/dist/index.js +8161 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +1419 -0
- package/package.json +67 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Unsys Canvas contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# unsys-canvas
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React package: think on an Excalidraw board with a **host-supplied** LLM (`onAsk`). See the repository README for the public API, event types, and install spec.
|
|
4
|
+
|
|
5
|
+
npm cannot install this folder via `github:…#ref:subdir` (that syntax is pnpm/yarn). From a clone:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install ./packages/unsys-canvas
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
or `npm pack` in this directory and install the `.tgz`.
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
interface WorkspaceFileContextItem {
|
|
2
|
+
name: string;
|
|
3
|
+
/** Optional body/excerpt; omitted when only the name is known. */
|
|
4
|
+
excerpt?: string | null;
|
|
5
|
+
mime_type?: string | null;
|
|
6
|
+
}
|
|
7
|
+
/** One block on the workspace map (inventory + layout). */
|
|
8
|
+
interface PromptBlockInventoryItem {
|
|
9
|
+
id?: string | null;
|
|
10
|
+
title: string;
|
|
11
|
+
description?: string | null;
|
|
12
|
+
status?: string | null;
|
|
13
|
+
/** Role on the map: start | checkpoint | etc. */
|
|
14
|
+
role?: string | null;
|
|
15
|
+
is_start?: boolean | null;
|
|
16
|
+
/** Grid placement (anchor). */
|
|
17
|
+
position_x?: number | null;
|
|
18
|
+
position_y?: number | null;
|
|
19
|
+
span_w?: number | null;
|
|
20
|
+
span_h?: number | null;
|
|
21
|
+
/** Freeform mask relative to anchor when present. */
|
|
22
|
+
shape_cells?: Array<{
|
|
23
|
+
dr: number;
|
|
24
|
+
dc: number;
|
|
25
|
+
}> | null;
|
|
26
|
+
/** Outgoing next-block links (ids or titles). */
|
|
27
|
+
next_block_ids?: string[] | null;
|
|
28
|
+
/** Next-block titles when ids are resolved by the caller. */
|
|
29
|
+
next_block_titles?: string[] | null;
|
|
30
|
+
/** Prerequisite lock-until block ids. */
|
|
31
|
+
lock_until_block_ids?: string[] | null;
|
|
32
|
+
/** Block-local materials (optional). */
|
|
33
|
+
local_context?: BlockLocalContextInput | null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Block-local context: local notes/files and/or references into workspace-global materials.
|
|
37
|
+
* Prefer global_file_refs over duplicating workspace file blobs.
|
|
38
|
+
*/
|
|
39
|
+
interface BlockLocalContextInput {
|
|
40
|
+
notes?: string | null;
|
|
41
|
+
/** Materials attached only to this block (name + optional excerpt). */
|
|
42
|
+
local_files?: WorkspaceFileContextItem[] | null;
|
|
43
|
+
/** Names of workspace-global files this block explicitly references. */
|
|
44
|
+
global_file_refs?: string[] | null;
|
|
45
|
+
/**
|
|
46
|
+
* Ids of workspace_external_resources this block references
|
|
47
|
+
* (generate-in-shape / local context attach).
|
|
48
|
+
*/
|
|
49
|
+
external_resource_ids?: string[] | null;
|
|
50
|
+
}
|
|
51
|
+
/** External resource / link row for prompt grounding (title/url/description). */
|
|
52
|
+
type PromptExternalResourceItem = {
|
|
53
|
+
id?: string | null;
|
|
54
|
+
title?: string | null;
|
|
55
|
+
url?: string | null;
|
|
56
|
+
description?: string | null;
|
|
57
|
+
};
|
|
58
|
+
interface PromptWorkspaceContextInput {
|
|
59
|
+
workspaceTitle?: string | null;
|
|
60
|
+
rootTopic?: string | null;
|
|
61
|
+
/** Workspace goal or description (learning outcome). */
|
|
62
|
+
workspaceGoal?: string | null;
|
|
63
|
+
workspaceDescription?: string | null;
|
|
64
|
+
notes?: string | null;
|
|
65
|
+
blockTitle?: string | null;
|
|
66
|
+
blockDescription?: string | null;
|
|
67
|
+
/** Learning use case chapter plan text / longer-horizon brief. */
|
|
68
|
+
chapterDescription?: string | null;
|
|
69
|
+
files?: WorkspaceFileContextItem[] | null;
|
|
70
|
+
/**
|
|
71
|
+
* Workspace (and block-referenced) external links — titles/URLs/descriptions.
|
|
72
|
+
* Included in the context block so simulation/practice is not title-only.
|
|
73
|
+
*/
|
|
74
|
+
externalResources?: PromptExternalResourceItem[] | null;
|
|
75
|
+
/** Full map inventory (kinds/roles + layout). When set, topology is assembled. */
|
|
76
|
+
blocks?: PromptBlockInventoryItem[] | null;
|
|
77
|
+
/** Focused block id — used to attach local context and mark inventory focus. */
|
|
78
|
+
focusedBlockId?: string | null;
|
|
79
|
+
/** Explicit block-local materials (overrides focused block.local_context when set). */
|
|
80
|
+
blockLocalContext?: BlockLocalContextInput | null;
|
|
81
|
+
/** Unusable ground cells that shape paths (topology cue). */
|
|
82
|
+
unusableCells?: Array<{
|
|
83
|
+
row: number;
|
|
84
|
+
col: number;
|
|
85
|
+
}> | null;
|
|
86
|
+
/** Extra free text already assembled by the caller. */
|
|
87
|
+
extra?: string | null;
|
|
88
|
+
/**
|
|
89
|
+
* Prior Scout session mind map (path + canvas text) for this block.
|
|
90
|
+
* Included in session context so a later Work session can use it.
|
|
91
|
+
*/
|
|
92
|
+
scoutArtifacts?: {
|
|
93
|
+
path?: readonly string[] | null;
|
|
94
|
+
canvasText?: string | null;
|
|
95
|
+
seedText?: string | null;
|
|
96
|
+
} | null;
|
|
97
|
+
}
|
|
98
|
+
interface PromptWorkspaceContext {
|
|
99
|
+
workspaceTitle: string | null;
|
|
100
|
+
rootTopic: string | null;
|
|
101
|
+
workspaceGoal: string | null;
|
|
102
|
+
workspaceDescription: string | null;
|
|
103
|
+
notes: string | null;
|
|
104
|
+
blockTitle: string | null;
|
|
105
|
+
blockDescription: string | null;
|
|
106
|
+
chapterDescription: string | null;
|
|
107
|
+
fileNames: string[];
|
|
108
|
+
fileExcerpts: Array<{
|
|
109
|
+
name: string;
|
|
110
|
+
excerpt: string;
|
|
111
|
+
}>;
|
|
112
|
+
/** Map inventory lines included in the context block. */
|
|
113
|
+
blockInventoryLines: string[];
|
|
114
|
+
/** Layout/topology cue lines (placement, spans, next links, unusable ground). */
|
|
115
|
+
topologyLines: string[];
|
|
116
|
+
/** Distinct local-context section lines when local materials exist. */
|
|
117
|
+
localContextLines: string[];
|
|
118
|
+
/** True when local materials (notes/files/refs) are present for the focused block. */
|
|
119
|
+
hasLocalContext: boolean;
|
|
120
|
+
/** True when description, notes, chapter, files, or topology provide domain substance beyond titles. */
|
|
121
|
+
hasDomainSubstance: boolean;
|
|
122
|
+
/** Human-readable block for LLM system/user prompts. */
|
|
123
|
+
contextBlock: string;
|
|
124
|
+
/** Compact domain cue string used by pure exercise framers. */
|
|
125
|
+
domainSubstanceSummary: string;
|
|
126
|
+
/** Creator/consumer-facing layers for prompt-impact UI. */
|
|
127
|
+
promptImpactLayers: PromptImpactLayer[];
|
|
128
|
+
}
|
|
129
|
+
/** One layer shown in the Context / prompt-impact readout. */
|
|
130
|
+
interface PromptImpactLayer {
|
|
131
|
+
id: "workspace_identity" | "workspace_notes" | "workspace_files" | "block_inventory" | "map_topology" | "focused_block" | "local_context" | "surfaces";
|
|
132
|
+
label: string;
|
|
133
|
+
summary: string;
|
|
134
|
+
/** Which product prompts this layer feeds. */
|
|
135
|
+
feeds: Array<"session" | "exercise">;
|
|
136
|
+
present: boolean;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
declare const UNSYS_CANVAS_COMMANDS: readonly [{
|
|
140
|
+
readonly id: "simplify";
|
|
141
|
+
readonly label: "Simplify";
|
|
142
|
+
readonly tooltip: "Replace the selected marks with a shorter, plainer rewrite. If the selection is a term, make the meaning plain.";
|
|
143
|
+
readonly shortcut: "s";
|
|
144
|
+
readonly needsSelection: true;
|
|
145
|
+
readonly boardOnly: false;
|
|
146
|
+
readonly replacesSelection: true;
|
|
147
|
+
}, {
|
|
148
|
+
readonly id: "breakdown";
|
|
149
|
+
readonly label: "Subdivide";
|
|
150
|
+
readonly tooltip: "Keep the original mark and fan its parts into smaller nodes, linked with arrows.";
|
|
151
|
+
readonly shortcut: "b";
|
|
152
|
+
readonly needsSelection: true;
|
|
153
|
+
readonly boardOnly: false;
|
|
154
|
+
readonly replacesSelection: false;
|
|
155
|
+
}, {
|
|
156
|
+
readonly id: "concepts";
|
|
157
|
+
readonly label: "Concepts";
|
|
158
|
+
readonly tooltip: "Keep the original and fan its named concepts into linked nodes.";
|
|
159
|
+
readonly shortcut: "c";
|
|
160
|
+
readonly needsSelection: true;
|
|
161
|
+
readonly boardOnly: false;
|
|
162
|
+
readonly replacesSelection: false;
|
|
163
|
+
}, {
|
|
164
|
+
readonly id: "draw";
|
|
165
|
+
readonly label: "Do/run";
|
|
166
|
+
readonly slash: "run";
|
|
167
|
+
readonly tooltip: "Work the highlighted problem: carry it out, compute it, or show the result.";
|
|
168
|
+
readonly shortcut: "d";
|
|
169
|
+
readonly needsSelection: true;
|
|
170
|
+
readonly boardOnly: false;
|
|
171
|
+
readonly replacesSelection: false;
|
|
172
|
+
}, {
|
|
173
|
+
readonly id: "refactor";
|
|
174
|
+
readonly label: "Refactor";
|
|
175
|
+
readonly tooltip: "Delete the selected marks and replace them with a clearer rewrite.";
|
|
176
|
+
readonly shortcut: "r";
|
|
177
|
+
readonly needsSelection: true;
|
|
178
|
+
readonly boardOnly: false;
|
|
179
|
+
readonly replacesSelection: true;
|
|
180
|
+
}];
|
|
181
|
+
type UnsysCanvasCommandId = (typeof UNSYS_CANVAS_COMMANDS)[number]["id"] | (string & {});
|
|
182
|
+
type UnsysCanvasHostCommand = {
|
|
183
|
+
id: string;
|
|
184
|
+
label: string;
|
|
185
|
+
tooltip?: string;
|
|
186
|
+
shortcut?: string;
|
|
187
|
+
slash?: string;
|
|
188
|
+
needsSelection?: boolean;
|
|
189
|
+
replacesSelection?: boolean;
|
|
190
|
+
run?: (ctx: {
|
|
191
|
+
selectedElements: UnsysCanvasElement[];
|
|
192
|
+
scene: UnsysCanvasScene;
|
|
193
|
+
}) => void | Promise<void>;
|
|
194
|
+
};
|
|
195
|
+
type UnsysCanvasAskKind = "ask" | "draw" | "simplify" | "concepts" | "check" | "selective-compress" | "refactor" | "suggest-insight" | "clear-overlaps" | "declutter";
|
|
196
|
+
type UnsysCanvasCommandDef = {
|
|
197
|
+
id: string;
|
|
198
|
+
label: string;
|
|
199
|
+
tooltip: string;
|
|
200
|
+
shortcut: string;
|
|
201
|
+
needsSelection: boolean;
|
|
202
|
+
boardOnly: boolean;
|
|
203
|
+
replacesSelection: boolean;
|
|
204
|
+
slash?: string;
|
|
205
|
+
run?: UnsysCanvasHostCommand["run"];
|
|
206
|
+
};
|
|
207
|
+
/** Built-in catalog plus host-registered commands. */
|
|
208
|
+
declare function unsysCanvasCommandsFor(_guide?: string | null, extras?: readonly UnsysCanvasHostCommand[]): UnsysCanvasCommandDef[];
|
|
209
|
+
type UnsysCanvasCommandAsk = {
|
|
210
|
+
kind: UnsysCanvasAskKind;
|
|
211
|
+
prompt: string;
|
|
212
|
+
};
|
|
213
|
+
type UnsysCanvasCommandRun = {
|
|
214
|
+
scene: UnsysCanvasScene;
|
|
215
|
+
changed: boolean;
|
|
216
|
+
parts: UnsysCanvasElement[];
|
|
217
|
+
selected: UnsysCanvasElement[];
|
|
218
|
+
prompt: string;
|
|
219
|
+
ask: UnsysCanvasCommandAsk | null;
|
|
220
|
+
notice: string | null;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Local result of a sidebar/dock command click.
|
|
224
|
+
* Subdivide, Focus, and Next mutate now. Simplify and Refactor drop the
|
|
225
|
+
* original marks immediately, then ask XAI. Do/run and Concepts keep the
|
|
226
|
+
* original and ask. A click that cannot run returns a short board notice instead of going silent.
|
|
227
|
+
*/
|
|
228
|
+
declare function runUnsysCanvasCommand(input: {
|
|
229
|
+
action: UnsysCanvasCommandId;
|
|
230
|
+
scene: UnsysCanvasScene | null | undefined;
|
|
231
|
+
selectedElements: readonly UnsysCanvasElement[] | null | undefined;
|
|
232
|
+
focusText?: string | null;
|
|
233
|
+
nextText?: string | null;
|
|
234
|
+
nextSameAsHere?: boolean;
|
|
235
|
+
nextHiddenStateId?: string | null;
|
|
236
|
+
}): UnsysCanvasCommandRun;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Work-canvas prompt text: drawing-tool instruction, domain prefix, and command user messages.
|
|
240
|
+
* Leaf module. Types from the scene module are erased at runtime.
|
|
241
|
+
*/
|
|
242
|
+
|
|
243
|
+
declare function buildUnsysCanvasCommandUserMessage(input: {
|
|
244
|
+
kind?: UnsysCanvasAskKind | "compress" | null;
|
|
245
|
+
prompt?: string | null;
|
|
246
|
+
selectedElements?: readonly UnsysCanvasElement[] | null;
|
|
247
|
+
scene?: UnsysCanvasScene | null;
|
|
248
|
+
workspace?: PromptWorkspaceContextInput | PromptWorkspaceContext | null;
|
|
249
|
+
}): string;
|
|
250
|
+
|
|
251
|
+
type UnsysCanvasAppState = Record<string, unknown>;
|
|
252
|
+
type UnsysCanvasFiles = Record<string, unknown>;
|
|
253
|
+
type UnsysCanvasElement = {
|
|
254
|
+
id: string;
|
|
255
|
+
type: string;
|
|
256
|
+
x: number;
|
|
257
|
+
y: number;
|
|
258
|
+
width: number;
|
|
259
|
+
height: number;
|
|
260
|
+
angle: number;
|
|
261
|
+
strokeColor: string;
|
|
262
|
+
backgroundColor: string;
|
|
263
|
+
fillStyle: string;
|
|
264
|
+
strokeWidth: number;
|
|
265
|
+
strokeStyle: string;
|
|
266
|
+
roughness: number;
|
|
267
|
+
opacity: number;
|
|
268
|
+
groupIds: string[];
|
|
269
|
+
frameId: string | null;
|
|
270
|
+
roundness: {
|
|
271
|
+
type: number;
|
|
272
|
+
value?: number;
|
|
273
|
+
} | null;
|
|
274
|
+
seed: number;
|
|
275
|
+
version: number;
|
|
276
|
+
versionNonce: number;
|
|
277
|
+
isDeleted: boolean;
|
|
278
|
+
boundElements: unknown[] | null;
|
|
279
|
+
updated: number;
|
|
280
|
+
link: string | null;
|
|
281
|
+
locked: boolean;
|
|
282
|
+
customData?: Record<string, unknown> | null;
|
|
283
|
+
text?: string;
|
|
284
|
+
originalText?: string;
|
|
285
|
+
fontSize?: number;
|
|
286
|
+
fontFamily?: number;
|
|
287
|
+
textAlign?: string;
|
|
288
|
+
verticalAlign?: string;
|
|
289
|
+
containerId?: string | null;
|
|
290
|
+
autoResize?: boolean;
|
|
291
|
+
lineHeight?: number;
|
|
292
|
+
points?: number[][];
|
|
293
|
+
fileId?: string;
|
|
294
|
+
scale?: [number, number];
|
|
295
|
+
[key: string]: unknown;
|
|
296
|
+
};
|
|
297
|
+
type UnsysCanvasScene = {
|
|
298
|
+
elements: UnsysCanvasElement[];
|
|
299
|
+
appState: UnsysCanvasAppState;
|
|
300
|
+
files: UnsysCanvasFiles;
|
|
301
|
+
};
|
|
302
|
+
/** Skeleton accepted by convertUnsysCanvasSkeletons (Excalidraw skeleton shape). */
|
|
303
|
+
type UnsysCanvasSkeleton = {
|
|
304
|
+
type: string;
|
|
305
|
+
id?: string;
|
|
306
|
+
x?: number;
|
|
307
|
+
y?: number;
|
|
308
|
+
width?: number;
|
|
309
|
+
height?: number;
|
|
310
|
+
text?: string;
|
|
311
|
+
fileId?: string;
|
|
312
|
+
strokeColor?: string;
|
|
313
|
+
backgroundColor?: string;
|
|
314
|
+
label?: {
|
|
315
|
+
text?: string;
|
|
316
|
+
};
|
|
317
|
+
customData?: Record<string, unknown> | null;
|
|
318
|
+
[key: string]: unknown;
|
|
319
|
+
};
|
|
320
|
+
declare function emptyUnsysCanvasScene(): UnsysCanvasScene;
|
|
321
|
+
/**
|
|
322
|
+
* Restorable board snapshot for an XAI turn: elements + appState + files,
|
|
323
|
+
* collaborators stripped (they do not survive JSON).
|
|
324
|
+
*/
|
|
325
|
+
declare function serializeUnsysCanvasScene(scene: {
|
|
326
|
+
elements?: unknown;
|
|
327
|
+
appState?: unknown;
|
|
328
|
+
files?: unknown;
|
|
329
|
+
} | null | undefined): UnsysCanvasScene;
|
|
330
|
+
/**
|
|
331
|
+
* Excalidraw's LinearElementEditor requires `points[0] === [0, 0]`.
|
|
332
|
+
* Shift x/y by the first point so the stroke stays on the board.
|
|
333
|
+
*/
|
|
334
|
+
declare function normalizeUnsysCanvasLinearElement(el: UnsysCanvasElement): UnsysCanvasElement;
|
|
335
|
+
/**
|
|
336
|
+
* Shipped wrapper around Excalidraw `convertToExcalidrawElements`.
|
|
337
|
+
* Turns skeletons into user-editable scene elements (`type: "text"` etc.).
|
|
338
|
+
*/
|
|
339
|
+
declare function convertUnsysCanvasSkeletons(skeletons: UnsysCanvasSkeleton[] | null | undefined, opts?: {
|
|
340
|
+
regenerateIds?: boolean;
|
|
341
|
+
}): UnsysCanvasElement[];
|
|
342
|
+
/** Alias matching Excalidraw's public skeleton converter name. */
|
|
343
|
+
declare const convertToExcalidrawElements: typeof convertUnsysCanvasSkeletons;
|
|
344
|
+
declare function unsysCanvasHasLiveElements(scene: UnsysCanvasScene | null | undefined): boolean;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Verbose raw board event feed. No classification or proof-of-work semantics.
|
|
348
|
+
* High-frequency updates are batched by merging consecutive same-key events
|
|
349
|
+
* (first `from`, last `to`) so information is not dropped.
|
|
350
|
+
*/
|
|
351
|
+
declare const UNSYS_CANVAS_EVENT_TYPES: readonly ["element:added", "element:updated", "element:deleted", "element:moved", "element:resized", "text:edited", "selection:changed", "tool:changed", "viewport:changed", "command:run", "prompt:submit", "dictate:start", "dictate:stop", "dictate:text", "laser:gesture", "latex:render", "undo", "redo"];
|
|
352
|
+
type UnsysCanvasEventType = (typeof UNSYS_CANVAS_EVENT_TYPES)[number];
|
|
353
|
+
type UnsysCanvasEvent = {
|
|
354
|
+
seq: number;
|
|
355
|
+
ts: number;
|
|
356
|
+
type: UnsysCanvasEventType;
|
|
357
|
+
payload: Record<string, unknown>;
|
|
358
|
+
};
|
|
359
|
+
declare class UnsysCanvasEventCollector {
|
|
360
|
+
private seq;
|
|
361
|
+
private prev;
|
|
362
|
+
private buffer;
|
|
363
|
+
private lastFlush;
|
|
364
|
+
private readonly batchMs;
|
|
365
|
+
constructor(options?: {
|
|
366
|
+
batchMs?: number;
|
|
367
|
+
});
|
|
368
|
+
reset(scene?: unknown): void;
|
|
369
|
+
syncWithoutEmit(scene?: unknown): void;
|
|
370
|
+
private push;
|
|
371
|
+
observeScene(scene?: unknown, _opts?: unknown): UnsysCanvasEvent[];
|
|
372
|
+
command(id?: string, meta?: unknown): UnsysCanvasEvent[];
|
|
373
|
+
dictate(meta?: unknown): UnsysCanvasEvent[];
|
|
374
|
+
prompt(text?: string, meta?: unknown): UnsysCanvasEvent[];
|
|
375
|
+
laser(meta?: unknown): UnsysCanvasEvent[];
|
|
376
|
+
latex(meta?: unknown): UnsysCanvasEvent[];
|
|
377
|
+
history(kind: "undo" | "redo", meta?: unknown): UnsysCanvasEvent[];
|
|
378
|
+
markGestureBusy(_busy?: boolean): void;
|
|
379
|
+
private batch;
|
|
380
|
+
flush(): UnsysCanvasEvent[];
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Session-chat body for one assistant string.
|
|
385
|
+
* `message` is the visible sentence. `raw` is that same assistant string, kept
|
|
386
|
+
* so layout JSON is not discarded when the sentence and typed shapes are empty.
|
|
387
|
+
*/
|
|
388
|
+
declare function parseUnsysCanvasAskReply(assistantText: string | null | undefined): {
|
|
389
|
+
message: string;
|
|
390
|
+
canvasElements: UnsysCanvasSkeleton[];
|
|
391
|
+
raw: string;
|
|
392
|
+
};
|
|
393
|
+
/**
|
|
394
|
+
* Canvas ask result from a session-chat response.
|
|
395
|
+
* A layout-only assistant string stays in `raw`. An empty visible sentence does
|
|
396
|
+
* not become the error string when that raw reply is present.
|
|
397
|
+
*/
|
|
398
|
+
declare function unsysCanvasAskFromSessionChat(input: {
|
|
399
|
+
ok: boolean;
|
|
400
|
+
message?: unknown;
|
|
401
|
+
canvasElements?: unknown;
|
|
402
|
+
raw?: unknown;
|
|
403
|
+
errorMessage?: string | null;
|
|
404
|
+
}): {
|
|
405
|
+
text: string;
|
|
406
|
+
elements: UnsysCanvasSkeleton[] | null;
|
|
407
|
+
origin: {
|
|
408
|
+
x?: number;
|
|
409
|
+
y?: number;
|
|
410
|
+
} | null;
|
|
411
|
+
raw: string;
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
declare function unsysCanvasXaiNeedsBoardContext(kind?: string | null): boolean;
|
|
415
|
+
declare function unsysCanvasXaiMaxTokens(kind?: string | null): number;
|
|
416
|
+
/** Per-request AbortSignal budget. Commands skip the board listing and should return sooner. */
|
|
417
|
+
declare function unsysCanvasXaiFetchTimeout(kind?: string | null): number;
|
|
418
|
+
/** User-message payload: compact live-board contents and drawing tools. */
|
|
419
|
+
declare function unsysCanvasTurnContextMessage(scene: UnsysCanvasScene | null | undefined, input?: {
|
|
420
|
+
boardLabel?: string;
|
|
421
|
+
workspace?: PromptWorkspaceContextInput | PromptWorkspaceContext | null;
|
|
422
|
+
kind?: UnsysCanvasAskKind | string | null;
|
|
423
|
+
}): string;
|
|
424
|
+
/**
|
|
425
|
+
* Apply an XAI command reply. Layout commands that cannot edit still place the
|
|
426
|
+
* coaching/fallback sentence so the click is never a silent no-op.
|
|
427
|
+
*/
|
|
428
|
+
declare function applyUnsysCanvasAskReply(input: {
|
|
429
|
+
kind?: UnsysCanvasAskKind | null;
|
|
430
|
+
live: UnsysCanvasScene | null | undefined;
|
|
431
|
+
selectedElements: readonly UnsysCanvasElement[] | null | undefined;
|
|
432
|
+
payload: {
|
|
433
|
+
text?: string | null;
|
|
434
|
+
raw?: string | null;
|
|
435
|
+
elements?: UnsysCanvasSkeleton[] | null;
|
|
436
|
+
origin?: {
|
|
437
|
+
x?: number;
|
|
438
|
+
y?: number;
|
|
439
|
+
} | null;
|
|
440
|
+
turnId?: string | null;
|
|
441
|
+
};
|
|
442
|
+
fallbackOrigin?: {
|
|
443
|
+
x?: number;
|
|
444
|
+
y?: number;
|
|
445
|
+
} | null;
|
|
446
|
+
reserved?: readonly {
|
|
447
|
+
x: number;
|
|
448
|
+
y: number;
|
|
449
|
+
}[] | null;
|
|
450
|
+
}): UnsysCanvasScene;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Encode a work-canvas scene into the page URL hash so a board can be
|
|
454
|
+
* bookmarked or shared. The hash never leaves the browser (not sent to the
|
|
455
|
+
* server). API keys are not part of the payload.
|
|
456
|
+
*/
|
|
457
|
+
|
|
458
|
+
declare const UNSYS_CANVAS_HASH_PREFIX: "tc1.";
|
|
459
|
+
type UnsysCanvasUrlKind = "empty" | "ok" | "omitted-files" | "too-large";
|
|
460
|
+
type UnsysCanvasUrlEncodeResult = {
|
|
461
|
+
kind: UnsysCanvasUrlKind;
|
|
462
|
+
/** Hash including `#`, or `""` when the URL should have no fragment. */
|
|
463
|
+
hash: string;
|
|
464
|
+
};
|
|
465
|
+
declare function encodeUnsysCanvasHash(scene: UnsysCanvasScene | null | undefined, options?: {
|
|
466
|
+
maxHashLength?: number;
|
|
467
|
+
}): Promise<UnsysCanvasUrlEncodeResult>;
|
|
468
|
+
declare function decodeUnsysCanvasHash(hash: string | null | undefined): Promise<UnsysCanvasScene | null>;
|
|
469
|
+
declare function readUnsysCanvasHashFromLocation(hash?: string | null | undefined): Promise<UnsysCanvasScene | null>;
|
|
470
|
+
declare function replaceUnsysCanvasLocationHash(hash: string): void;
|
|
471
|
+
|
|
472
|
+
type UnsysCanvasSidebarTokens = {
|
|
473
|
+
background: string;
|
|
474
|
+
border: string;
|
|
475
|
+
text: string;
|
|
476
|
+
muted: string;
|
|
477
|
+
panel: string;
|
|
478
|
+
accent: string;
|
|
479
|
+
overlay: string;
|
|
480
|
+
};
|
|
481
|
+
/** Visual colors the learner sees on the dark Excalidraw board. */
|
|
482
|
+
type UnsysCanvasBoardStyle = {
|
|
483
|
+
background: string;
|
|
484
|
+
stroke: string;
|
|
485
|
+
zenMode: boolean;
|
|
486
|
+
/** Excalidraw grid when a board opens. Default is on. */
|
|
487
|
+
gridMode: boolean;
|
|
488
|
+
};
|
|
489
|
+
type UnsysCanvasStyle = {
|
|
490
|
+
prompt: string;
|
|
491
|
+
generatedAt: string | null;
|
|
492
|
+
backgroundImage: string | null;
|
|
493
|
+
tokens: UnsysCanvasSidebarTokens;
|
|
494
|
+
canvas: UnsysCanvasBoardStyle;
|
|
495
|
+
};
|
|
496
|
+
declare const DEFAULT_UNSYS_CANVAS_STYLE_TOKENS: UnsysCanvasSidebarTokens;
|
|
497
|
+
/**
|
|
498
|
+
* Visual board: near-black fill, near-white ink (stored Excalidraw stroke
|
|
499
|
+
* `#1e1e1e` inverts to `#e1e1e1`), zen on, grid on.
|
|
500
|
+
*/
|
|
501
|
+
declare const DEFAULT_UNSYS_CANVAS_BOARD_STYLE: UnsysCanvasBoardStyle;
|
|
502
|
+
declare const EMPTY_UNSYS_CANVAS_STYLE: UnsysCanvasStyle;
|
|
503
|
+
declare function parseUnsysCanvasStyle(value: unknown): UnsysCanvasStyle;
|
|
504
|
+
declare function unsysCanvasSidebarStyleCssVars(style: UnsysCanvasStyle | null | undefined): Record<string, string>;
|
|
505
|
+
|
|
506
|
+
declare function assertOnAsk(onAsk: unknown): void;
|
|
507
|
+
|
|
508
|
+
export { DEFAULT_UNSYS_CANVAS_BOARD_STYLE, DEFAULT_UNSYS_CANVAS_STYLE_TOKENS, EMPTY_UNSYS_CANVAS_STYLE, UNSYS_CANVAS_COMMANDS, UNSYS_CANVAS_EVENT_TYPES, UNSYS_CANVAS_HASH_PREFIX, type UnsysCanvasAskKind, type UnsysCanvasBoardStyle, type UnsysCanvasCommandId, type UnsysCanvasElement, type UnsysCanvasEvent, UnsysCanvasEventCollector, type UnsysCanvasEventType, type UnsysCanvasHostCommand, type UnsysCanvasScene, type UnsysCanvasSidebarTokens, type UnsysCanvasStyle, applyUnsysCanvasAskReply, assertOnAsk, buildUnsysCanvasCommandUserMessage, convertToExcalidrawElements, decodeUnsysCanvasHash, emptyUnsysCanvasScene, encodeUnsysCanvasHash, normalizeUnsysCanvasLinearElement, parseUnsysCanvasAskReply, parseUnsysCanvasStyle, readUnsysCanvasHashFromLocation, replaceUnsysCanvasLocationHash, runUnsysCanvasCommand, serializeUnsysCanvasScene, unsysCanvasAskFromSessionChat, unsysCanvasCommandsFor, unsysCanvasHasLiveElements, unsysCanvasSidebarStyleCssVars, unsysCanvasTurnContextMessage, unsysCanvasXaiFetchTimeout, unsysCanvasXaiMaxTokens, unsysCanvasXaiNeedsBoardContext };
|