unsys-canvas 0.1.1 → 0.2.0
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/README.md +14 -5
- package/dist/core.d.ts +367 -7
- package/dist/core.js +1587 -511
- package/dist/core.js.map +1 -1
- package/dist/index.d.ts +386 -14
- package/dist/index.js +2606 -618
- package/dist/index.js.map +1 -1
- package/dist/styles.css +106 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -146,6 +146,7 @@ interface PromptImpactLayer {
|
|
|
146
146
|
* Leaf module. Types from the scene module are erased at runtime.
|
|
147
147
|
*/
|
|
148
148
|
|
|
149
|
+
type UnsysCanvasWorkspaceInput = PromptWorkspaceContextInput;
|
|
149
150
|
declare function buildUnsysCanvasCommandUserMessage(input: {
|
|
150
151
|
kind?: UnsysCanvasAskKind | "compress" | null;
|
|
151
152
|
prompt?: string | null;
|
|
@@ -252,16 +253,20 @@ declare function unsysCanvasHasLiveElements(scene: UnsysCanvasScene | null | und
|
|
|
252
253
|
declare const UNSYS_CANVAS_COMMANDS: readonly [{
|
|
253
254
|
readonly id: "simplify";
|
|
254
255
|
readonly label: "Simplify";
|
|
255
|
-
readonly tooltip: "
|
|
256
|
+
readonly tooltip: "Keep the original marks and place a shorter, plainer rewrite next to them. If the selection is a term, make the meaning plain.";
|
|
256
257
|
readonly shortcut: "s";
|
|
258
|
+
readonly gesture: "question-mark";
|
|
259
|
+
readonly gestureHint: "Laser: question mark over a mark.";
|
|
257
260
|
readonly needsSelection: true;
|
|
258
261
|
readonly boardOnly: false;
|
|
259
|
-
readonly replacesSelection:
|
|
262
|
+
readonly replacesSelection: false;
|
|
260
263
|
}, {
|
|
261
264
|
readonly id: "breakdown";
|
|
262
265
|
readonly label: "Subdivide";
|
|
263
266
|
readonly tooltip: "Keep the original mark and fan its parts into smaller nodes, linked with arrows.";
|
|
264
267
|
readonly shortcut: "b";
|
|
268
|
+
readonly gesture: "double-line";
|
|
269
|
+
readonly gestureHint: "Laser: two quick lines from a mark into empty space.";
|
|
265
270
|
readonly needsSelection: true;
|
|
266
271
|
readonly boardOnly: false;
|
|
267
272
|
readonly replacesSelection: false;
|
|
@@ -270,6 +275,8 @@ declare const UNSYS_CANVAS_COMMANDS: readonly [{
|
|
|
270
275
|
readonly label: "Concepts";
|
|
271
276
|
readonly tooltip: "Keep the original and fan its named concepts into linked nodes.";
|
|
272
277
|
readonly shortcut: "c";
|
|
278
|
+
readonly gesture: "line";
|
|
279
|
+
readonly gestureHint: "Laser: line from a mark into empty space.";
|
|
273
280
|
readonly needsSelection: true;
|
|
274
281
|
readonly boardOnly: false;
|
|
275
282
|
readonly replacesSelection: false;
|
|
@@ -279,6 +286,8 @@ declare const UNSYS_CANVAS_COMMANDS: readonly [{
|
|
|
279
286
|
readonly slash: "run";
|
|
280
287
|
readonly tooltip: "Work the highlighted problem: carry it out, compute it, or show the result.";
|
|
281
288
|
readonly shortcut: "d";
|
|
289
|
+
readonly gesture: "loop";
|
|
290
|
+
readonly gestureHint: "Laser: circle or loop over a mark.";
|
|
282
291
|
readonly needsSelection: true;
|
|
283
292
|
readonly boardOnly: false;
|
|
284
293
|
readonly replacesSelection: false;
|
|
@@ -287,9 +296,21 @@ declare const UNSYS_CANVAS_COMMANDS: readonly [{
|
|
|
287
296
|
readonly label: "Refactor";
|
|
288
297
|
readonly tooltip: "Delete the selected marks and replace them with a clearer rewrite.";
|
|
289
298
|
readonly shortcut: "r";
|
|
299
|
+
readonly gesture: "zigzag";
|
|
300
|
+
readonly gestureHint: "Laser: zigzag over a mark.";
|
|
290
301
|
readonly needsSelection: true;
|
|
291
302
|
readonly boardOnly: false;
|
|
292
303
|
readonly replacesSelection: true;
|
|
304
|
+
}, {
|
|
305
|
+
readonly id: "pretty";
|
|
306
|
+
readonly label: "Pretty";
|
|
307
|
+
readonly tooltip: "Keep the original marks and place a tidied, well-formatted Excalidraw note next to them.";
|
|
308
|
+
readonly shortcut: "p";
|
|
309
|
+
readonly gesture: "check";
|
|
310
|
+
readonly gestureHint: "Laser: check mark over a mark.";
|
|
311
|
+
readonly needsSelection: true;
|
|
312
|
+
readonly boardOnly: false;
|
|
313
|
+
readonly replacesSelection: false;
|
|
293
314
|
}];
|
|
294
315
|
type UnsysCanvasCommandId = (typeof UNSYS_CANVAS_COMMANDS)[number]["id"] | (string & {});
|
|
295
316
|
type UnsysCanvasHostCommand = {
|
|
@@ -299,13 +320,19 @@ type UnsysCanvasHostCommand = {
|
|
|
299
320
|
shortcut?: string;
|
|
300
321
|
slash?: string;
|
|
301
322
|
needsSelection?: boolean;
|
|
323
|
+
/** Ignored. Only Refactor may replace the selection. */
|
|
302
324
|
replacesSelection?: boolean;
|
|
325
|
+
gesture?: string | null;
|
|
326
|
+
gestureHint?: string | null;
|
|
327
|
+
catalog?: boolean;
|
|
328
|
+
needsModel?: boolean;
|
|
329
|
+
placement?: "beside" | "replace";
|
|
303
330
|
run?: (ctx: {
|
|
304
331
|
selectedElements: UnsysCanvasElement[];
|
|
305
332
|
scene: UnsysCanvasScene;
|
|
306
333
|
}) => void | Promise<void>;
|
|
307
334
|
};
|
|
308
|
-
type UnsysCanvasAskKind = "ask" | "draw" | "simplify" | "concepts" | "check" | "selective-compress" | "refactor" | "suggest-insight" | "clear-overlaps" | "declutter";
|
|
335
|
+
type UnsysCanvasAskKind = "ask" | "draw" | "simplify" | "concepts" | "check" | "selective-compress" | "refactor" | "pretty" | "suggest-insight" | "clear-overlaps" | "declutter";
|
|
309
336
|
type UnsysCanvasCommandDef = {
|
|
310
337
|
id: string;
|
|
311
338
|
label: string;
|
|
@@ -315,6 +342,8 @@ type UnsysCanvasCommandDef = {
|
|
|
315
342
|
boardOnly: boolean;
|
|
316
343
|
replacesSelection: boolean;
|
|
317
344
|
slash?: string;
|
|
345
|
+
gesture?: string | null;
|
|
346
|
+
gestureHint?: string | null;
|
|
318
347
|
run?: UnsysCanvasHostCommand["run"];
|
|
319
348
|
};
|
|
320
349
|
/** Built-in catalog plus host-registered commands. */
|
|
@@ -334,8 +363,8 @@ type UnsysCanvasCommandRun = {
|
|
|
334
363
|
};
|
|
335
364
|
/**
|
|
336
365
|
* Local result of a sidebar/dock command click.
|
|
337
|
-
* Subdivide, Focus, and Next mutate now.
|
|
338
|
-
*
|
|
366
|
+
* Subdivide, Focus, and Next mutate now. Refactor drops the original marks
|
|
367
|
+
* immediately, then asks XAI. Simplify, Do/run, Concepts, and Pretty keep the
|
|
339
368
|
* original and ask. A click that cannot run returns a short board notice instead of going silent.
|
|
340
369
|
*/
|
|
341
370
|
declare function runUnsysCanvasCommand(input: {
|
|
@@ -348,12 +377,196 @@ declare function runUnsysCanvasCommand(input: {
|
|
|
348
377
|
nextHiddenStateId?: string | null;
|
|
349
378
|
}): UnsysCanvasCommandRun;
|
|
350
379
|
|
|
380
|
+
/**
|
|
381
|
+
* Command registry: source of truth for catalog chrome, context extraction,
|
|
382
|
+
* prompt construction, parse/validation, and board placement policy.
|
|
383
|
+
*
|
|
384
|
+
* Host extras use the same definition shape. A Pretty command, extra laser
|
|
385
|
+
* gestures, or a picker should add a row here (or via `commands`) rather than
|
|
386
|
+
* forking prompt files in the host.
|
|
387
|
+
*/
|
|
388
|
+
|
|
389
|
+
declare const UNSYS_CANVAS_COMMAND_SYSTEM_PROMPT: string;
|
|
390
|
+
type UnsysCanvasModelRole = "system" | "user" | "assistant";
|
|
391
|
+
type UnsysCanvasModelMessage = {
|
|
392
|
+
role: UnsysCanvasModelRole;
|
|
393
|
+
content: string;
|
|
394
|
+
};
|
|
395
|
+
type UnsysCanvasJsonSchema = {
|
|
396
|
+
name: string;
|
|
397
|
+
strict?: boolean;
|
|
398
|
+
schema: Record<string, unknown>;
|
|
399
|
+
};
|
|
400
|
+
type UnsysCanvasResponseFormat = "json" | "json_schema" | "text";
|
|
401
|
+
type UnsysCanvasPlacementMode = "beside" | "replace";
|
|
402
|
+
/** Compact, validated mark used to build prompts. Not an open prompt field. */
|
|
403
|
+
type UnsysCanvasContextElement = {
|
|
404
|
+
id: string;
|
|
405
|
+
type: string;
|
|
406
|
+
x: number;
|
|
407
|
+
y: number;
|
|
408
|
+
width?: number;
|
|
409
|
+
height?: number;
|
|
410
|
+
text?: string;
|
|
411
|
+
};
|
|
412
|
+
type UnsysCanvasCommandContextPayload = {
|
|
413
|
+
selectedElements: UnsysCanvasContextElement[];
|
|
414
|
+
liveElements?: UnsysCanvasContextElement[];
|
|
415
|
+
prompt?: string;
|
|
416
|
+
boardLabel?: string;
|
|
417
|
+
workspace?: UnsysCanvasWorkspaceInput | null;
|
|
418
|
+
};
|
|
419
|
+
type UnsysCanvasCommandPrompt = {
|
|
420
|
+
messages: UnsysCanvasModelMessage[];
|
|
421
|
+
responseFormat: UnsysCanvasResponseFormat;
|
|
422
|
+
jsonSchema?: UnsysCanvasJsonSchema;
|
|
423
|
+
maxTokens: number;
|
|
424
|
+
timeoutMs: number;
|
|
425
|
+
};
|
|
426
|
+
type UnsysCanvasParsedCommandReply = {
|
|
427
|
+
text: string;
|
|
428
|
+
elements: UnsysCanvasSkeleton[] | null;
|
|
429
|
+
origin: {
|
|
430
|
+
x?: number;
|
|
431
|
+
y?: number;
|
|
432
|
+
} | null;
|
|
433
|
+
raw: string;
|
|
434
|
+
};
|
|
435
|
+
/**
|
|
436
|
+
* One command. Built-ins and host extras share this shape.
|
|
437
|
+
* Optional fields keep today's thin host extras (`id` + `label` + `run`) working.
|
|
438
|
+
*/
|
|
439
|
+
type UnsysCanvasCommandDefinition = UnsysCanvasCommandDef & {
|
|
440
|
+
gesture?: string | null;
|
|
441
|
+
gestureHint?: string | null;
|
|
442
|
+
/** Sidebar / slash / picker. Hidden model kinds (ask, check, …) are false. */
|
|
443
|
+
catalog?: boolean;
|
|
444
|
+
needsModel?: boolean;
|
|
445
|
+
placement?: UnsysCanvasPlacementMode;
|
|
446
|
+
/** Laser / pointer classifier id. Pretty/new gestures add a new kind here. */
|
|
447
|
+
extractContext?: (input: {
|
|
448
|
+
scene: UnsysCanvasScene;
|
|
449
|
+
selectedElements: readonly UnsysCanvasElement[];
|
|
450
|
+
prompt?: string | null;
|
|
451
|
+
workspace?: UnsysCanvasWorkspaceInput | null;
|
|
452
|
+
}) => UnsysCanvasCommandContextPayload;
|
|
453
|
+
buildPrompt?: (context: UnsysCanvasCommandContextPayload) => UnsysCanvasCommandPrompt;
|
|
454
|
+
parseResponse?: (raw: string) => UnsysCanvasParsedCommandReply;
|
|
455
|
+
};
|
|
456
|
+
declare function extractUnsysCanvasCommandContext(input: {
|
|
457
|
+
commandId: string;
|
|
458
|
+
scene: UnsysCanvasScene | null | undefined;
|
|
459
|
+
selectedElements: readonly UnsysCanvasElement[] | null | undefined;
|
|
460
|
+
prompt?: string | null;
|
|
461
|
+
workspace?: UnsysCanvasWorkspaceInput | null;
|
|
462
|
+
}): UnsysCanvasCommandContextPayload;
|
|
463
|
+
type UnsysCanvasHostCommandSpec = UnsysCanvasHostCommand & Partial<Pick<UnsysCanvasCommandDefinition, "extractContext" | "buildPrompt" | "parseResponse">>;
|
|
464
|
+
declare function listUnsysCanvasCommandDefinitions(extras?: readonly UnsysCanvasHostCommandSpec[]): UnsysCanvasCommandDefinition[];
|
|
465
|
+
declare function getUnsysCanvasCommand(id: string | null | undefined, extras?: readonly UnsysCanvasHostCommandSpec[]): UnsysCanvasCommandDefinition | null;
|
|
466
|
+
declare function isUnsysCanvasKnownCommandId(id: string | null | undefined, extras?: readonly UnsysCanvasHostCommandSpec[]): boolean;
|
|
467
|
+
declare function buildUnsysCanvasCommandPrompt(commandId: string, context: UnsysCanvasCommandContextPayload, extras?: readonly UnsysCanvasHostCommandSpec[]): UnsysCanvasCommandPrompt;
|
|
468
|
+
declare function parseUnsysCanvasCommandResponse(commandId: string, raw: string, extras?: readonly UnsysCanvasHostCommandSpec[]): UnsysCanvasParsedCommandReply;
|
|
469
|
+
declare function unsysCanvasCommandPlacement(id: string | null | undefined): UnsysCanvasPlacementMode;
|
|
470
|
+
declare function unsysCanvasGestureCommandId(gesture: string | null | undefined): string | null;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Host LLM contract. The package builds prompts from the registry; the host
|
|
474
|
+
* only executes a model. Server routes must accept commandId + context, never
|
|
475
|
+
* caller-supplied messages.
|
|
476
|
+
*/
|
|
477
|
+
|
|
478
|
+
type UnsysCanvasModelRequest = {
|
|
479
|
+
commandId: string;
|
|
480
|
+
messages: UnsysCanvasModelMessage[];
|
|
481
|
+
responseFormat: UnsysCanvasResponseFormat;
|
|
482
|
+
jsonSchema?: UnsysCanvasJsonSchema;
|
|
483
|
+
maxTokens: number;
|
|
484
|
+
timeoutMs: number;
|
|
485
|
+
signal?: AbortSignal;
|
|
486
|
+
context: UnsysCanvasCommandContextPayload;
|
|
487
|
+
};
|
|
488
|
+
type UnsysCanvasModelResult = {
|
|
489
|
+
text: string;
|
|
490
|
+
};
|
|
491
|
+
type UnsysCanvasRunModel = (request: UnsysCanvasModelRequest) => Promise<UnsysCanvasModelResult>;
|
|
492
|
+
type UnsysCanvasModelHandlerOk = UnsysCanvasParsedCommandReply & {
|
|
493
|
+
ok: true;
|
|
494
|
+
};
|
|
495
|
+
type UnsysCanvasModelHandlerErr = {
|
|
496
|
+
ok: false;
|
|
497
|
+
status: number;
|
|
498
|
+
error: string;
|
|
499
|
+
};
|
|
500
|
+
type UnsysCanvasModelHandlerResult = UnsysCanvasModelHandlerOk | UnsysCanvasModelHandlerErr;
|
|
501
|
+
/**
|
|
502
|
+
* Parse a client POST body. Rejects unknown command ids and any attempt to
|
|
503
|
+
* supply model messages or system/user prompts at the top level.
|
|
504
|
+
*/
|
|
505
|
+
declare function parseUnsysCanvasModelClientBody(body: unknown, extras?: readonly UnsysCanvasHostCommandSpec[]): {
|
|
506
|
+
ok: true;
|
|
507
|
+
commandId: string;
|
|
508
|
+
context: UnsysCanvasCommandContextPayload;
|
|
509
|
+
} | UnsysCanvasModelHandlerErr;
|
|
510
|
+
declare function buildUnsysCanvasModelRequest(input: {
|
|
511
|
+
commandId: string;
|
|
512
|
+
scene?: UnsysCanvasScene | null;
|
|
513
|
+
selectedElements?: readonly UnsysCanvasElement[] | null;
|
|
514
|
+
prompt?: string | null;
|
|
515
|
+
workspace?: UnsysCanvasWorkspaceInput | null;
|
|
516
|
+
context?: UnsysCanvasCommandContextPayload;
|
|
517
|
+
extras?: readonly UnsysCanvasHostCommandSpec[];
|
|
518
|
+
signal?: AbortSignal;
|
|
519
|
+
}): UnsysCanvasModelRequest;
|
|
520
|
+
/**
|
|
521
|
+
* Server helper: build the prompt from the package registry, then call the
|
|
522
|
+
* host-provided model. Mount this in an API route. The API key stays on the server.
|
|
523
|
+
*/
|
|
524
|
+
declare function handleCanvasModelRequest(body: unknown, options: {
|
|
525
|
+
runModel: UnsysCanvasRunModel;
|
|
526
|
+
extras?: readonly UnsysCanvasHostCommandSpec[];
|
|
527
|
+
signal?: AbortSignal;
|
|
528
|
+
}): Promise<UnsysCanvasModelHandlerResult>;
|
|
529
|
+
declare function handleCanvasModelHttpRequest(req: Request, options: {
|
|
530
|
+
runModel: UnsysCanvasRunModel;
|
|
531
|
+
extras?: readonly UnsysCanvasHostCommandSpec[];
|
|
532
|
+
}): Promise<Response>;
|
|
533
|
+
type UnsysCanvasXaiRunnerOptions = {
|
|
534
|
+
getApiKey: () => string | null | Promise<string | null>;
|
|
535
|
+
getBaseUrl?: () => string | null | Promise<string | null>;
|
|
536
|
+
model?: string | ((commandId: string) => string);
|
|
537
|
+
reasoningEffort?: "low" | "medium" | "high";
|
|
538
|
+
fetch?: typeof fetch;
|
|
539
|
+
};
|
|
540
|
+
/**
|
|
541
|
+
* Browser (or Node) OpenAI-compatible Chat Completions runner. Default base URL
|
|
542
|
+
* is xAI. The host supplies the API key; the package never reads env secrets.
|
|
543
|
+
*/
|
|
544
|
+
declare function createUnsysCanvasXaiBrowserRunner(options: UnsysCanvasXaiRunnerOptions): UnsysCanvasRunModel;
|
|
545
|
+
/**
|
|
546
|
+
* Client runner that posts commandId + extracted context to a host API route
|
|
547
|
+
* which must call `handleCanvasModelRequest`. Messages are not sent.
|
|
548
|
+
*/
|
|
549
|
+
declare function createUnsysCanvasModelProxyRunner(options: {
|
|
550
|
+
url: string;
|
|
551
|
+
headers?: () => Record<string, string> | Promise<Record<string, string>>;
|
|
552
|
+
fetch?: typeof fetch;
|
|
553
|
+
}): UnsysCanvasRunModel;
|
|
554
|
+
declare function runUnsysCanvasModelAsk(runModel: UnsysCanvasRunModel, input: {
|
|
555
|
+
commandId: string;
|
|
556
|
+
scene: UnsysCanvasScene;
|
|
557
|
+
selectedElements: readonly UnsysCanvasElement[];
|
|
558
|
+
prompt?: string | null;
|
|
559
|
+
workspace?: UnsysCanvasWorkspaceInput | null;
|
|
560
|
+
extras?: readonly UnsysCanvasHostCommandSpec[];
|
|
561
|
+
signal?: AbortSignal;
|
|
562
|
+
}): Promise<UnsysCanvasParsedCommandReply>;
|
|
563
|
+
|
|
351
564
|
/**
|
|
352
565
|
* Verbose raw board event feed. No classification or proof-of-work semantics.
|
|
353
566
|
* High-frequency updates are batched by merging consecutive same-key events
|
|
354
567
|
* (first `from`, last `to`) so information is not dropped.
|
|
355
568
|
*/
|
|
356
|
-
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"];
|
|
569
|
+
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", "command:complete", "prompt:submit", "dictate:start", "dictate:stop", "dictate:text", "laser:gesture", "latex:render", "undo", "redo"];
|
|
357
570
|
type UnsysCanvasEventType = (typeof UNSYS_CANVAS_EVENT_TYPES)[number];
|
|
358
571
|
type UnsysCanvasEvent = {
|
|
359
572
|
seq: number;
|
|
@@ -375,6 +588,7 @@ declare class UnsysCanvasEventCollector {
|
|
|
375
588
|
private push;
|
|
376
589
|
observeScene(scene?: unknown, _opts?: unknown): UnsysCanvasEvent[];
|
|
377
590
|
command(id?: string, meta?: unknown): UnsysCanvasEvent[];
|
|
591
|
+
commandComplete(id?: string, meta?: unknown): UnsysCanvasEvent[];
|
|
378
592
|
dictate(meta?: unknown): UnsysCanvasEvent[];
|
|
379
593
|
prompt(text?: string, meta?: unknown): UnsysCanvasEvent[];
|
|
380
594
|
laser(meta?: unknown): UnsysCanvasEvent[];
|
|
@@ -454,6 +668,68 @@ declare function applyUnsysCanvasAskReply(input: {
|
|
|
454
668
|
}[] | null;
|
|
455
669
|
}): UnsysCanvasScene;
|
|
456
670
|
|
|
671
|
+
type UnsysCanvasCollabPointerTool = "pointer" | "laser";
|
|
672
|
+
type UnsysCanvasCollabPointer = {
|
|
673
|
+
x: number;
|
|
674
|
+
y: number;
|
|
675
|
+
tool: UnsysCanvasCollabPointerTool;
|
|
676
|
+
};
|
|
677
|
+
type UnsysCanvasCollabUserColor = {
|
|
678
|
+
background: string;
|
|
679
|
+
stroke: string;
|
|
680
|
+
};
|
|
681
|
+
type UnsysCanvasCollabUser = {
|
|
682
|
+
id: string;
|
|
683
|
+
name: string;
|
|
684
|
+
color: UnsysCanvasCollabUserColor;
|
|
685
|
+
};
|
|
686
|
+
type UnsysCanvasCollabScenePayload = {
|
|
687
|
+
elements: UnsysCanvasElement[];
|
|
688
|
+
files: UnsysCanvasFiles;
|
|
689
|
+
};
|
|
690
|
+
type UnsysCanvasCollabPointerPayload = {
|
|
691
|
+
pointer: UnsysCanvasCollabPointer;
|
|
692
|
+
button: "up" | "down";
|
|
693
|
+
selectedElementIds?: Record<string, boolean>;
|
|
694
|
+
};
|
|
695
|
+
type UnsysCanvasCollaborationHandlers = {
|
|
696
|
+
onMessage: (bytes: Uint8Array) => void;
|
|
697
|
+
onOpen?: () => void;
|
|
698
|
+
onClose?: () => void;
|
|
699
|
+
onError?: (error: unknown) => void;
|
|
700
|
+
};
|
|
701
|
+
type UnsysCanvasCollaborationSocket = {
|
|
702
|
+
send: (bytes: Uint8Array) => void;
|
|
703
|
+
close: () => void;
|
|
704
|
+
};
|
|
705
|
+
/**
|
|
706
|
+
* Byte pipe for one room. Ciphertext only — the library encrypts with the
|
|
707
|
+
* key from the URL fragment so a relay cannot read the board.
|
|
708
|
+
*/
|
|
709
|
+
type UnsysCanvasCollaborationTransport = {
|
|
710
|
+
open: (roomId: string, handlers: UnsysCanvasCollaborationHandlers) => UnsysCanvasCollaborationSocket;
|
|
711
|
+
};
|
|
712
|
+
/** Host-supplied collaboration adapter. Today this is a transport; session + reconcile stay in the package. */
|
|
713
|
+
type UnsysCanvasCollaborationAdapter = UnsysCanvasCollaborationTransport;
|
|
714
|
+
type UnsysCanvasCollaborator = {
|
|
715
|
+
pointer?: UnsysCanvasCollabPointer;
|
|
716
|
+
button?: "up" | "down";
|
|
717
|
+
selectedElementIds?: Record<string, boolean>;
|
|
718
|
+
username?: string | null;
|
|
719
|
+
userState?: "active" | "pending" | "idle" | "away";
|
|
720
|
+
color?: UnsysCanvasCollabUserColor;
|
|
721
|
+
avatarUrl?: string | null;
|
|
722
|
+
id?: string;
|
|
723
|
+
};
|
|
724
|
+
type UnsysCanvasCollabReconcileOptions = {
|
|
725
|
+
/** Local element ids currently being edited, resized, or created. Remote updates for these are ignored. */
|
|
726
|
+
editingIds?: Iterable<string> | null;
|
|
727
|
+
};
|
|
728
|
+
type UnsysCanvasCollabRoom = {
|
|
729
|
+
roomId: string;
|
|
730
|
+
key: string;
|
|
731
|
+
};
|
|
732
|
+
|
|
457
733
|
type UnsysCanvasSidebarTokens = {
|
|
458
734
|
background: string;
|
|
459
735
|
border: string;
|
|
@@ -510,7 +786,7 @@ interface ExcalidrawCanvasProps {
|
|
|
510
786
|
scrollAppliedElements?: boolean;
|
|
511
787
|
/** Classified Work-canvas event (draw/move/rotate/delete/Commands/board prompt). */
|
|
512
788
|
onEvent?: (events: UnsysCanvasEvent[]) => void;
|
|
513
|
-
onAsk
|
|
789
|
+
onAsk?: (input: {
|
|
514
790
|
prompt: string;
|
|
515
791
|
selectedElements: UnsysCanvasElement[];
|
|
516
792
|
scene: UnsysCanvasScene;
|
|
@@ -524,6 +800,7 @@ interface ExcalidrawCanvasProps {
|
|
|
524
800
|
} | null;
|
|
525
801
|
raw?: string | null;
|
|
526
802
|
}>;
|
|
803
|
+
runModel?: UnsysCanvasRunModel;
|
|
527
804
|
/** Remounts the board when this identity changes. */
|
|
528
805
|
boardId?: string | null;
|
|
529
806
|
/** Ask/XAI in-flight (Verify wait, Learn send) — same overlay chip as ask-about-selection. */
|
|
@@ -573,13 +850,22 @@ interface ExcalidrawCanvasProps {
|
|
|
573
850
|
/** Always apply fill, ink, zen, and grid (preview / authoring). */
|
|
574
851
|
liveCanvasChrome?: boolean;
|
|
575
852
|
extraCommands?: readonly UnsysCanvasHostCommand[];
|
|
853
|
+
/**
|
|
854
|
+
* Byte-pipe adapter for live collaboration. The package encrypts scene and
|
|
855
|
+
* pointer payloads with the room key from the URL fragment.
|
|
856
|
+
*/
|
|
857
|
+
collaboration?: UnsysCanvasCollaborationAdapter | null;
|
|
858
|
+
/** Show the Invite control. Hosts that render their own share UI can hide it. */
|
|
859
|
+
invite?: boolean;
|
|
860
|
+
/** Shown on a disabled Invite control when no adapter is configured. */
|
|
861
|
+
inviteHint?: string | null;
|
|
576
862
|
}
|
|
577
863
|
/**
|
|
578
864
|
* Shared Learn/Verify work board. Hosts must not fork this — both surfaces
|
|
579
865
|
* mount `WorkCanvas` so Commands, the board prompt, thinking overlay,
|
|
580
866
|
* XAI apply, and center-on-open stay one implementation.
|
|
581
867
|
*/
|
|
582
|
-
declare function ExcalidrawCanvas({ initialSceneData, onCanvasChange, onSceneChange, onSubmitBoard, canSubmitBoard, submitLabel, applyElements, applyElementsNonce, applyFiles, applyRemoveElementIds, openFocusRole, scrollAppliedElements, onEvent, onAsk, boardId, askBusy, onLearnerWaitChange, dictateTranscript, dictateListening, getLiveTranscript, onDictateActive, replaceScene, replaceSceneNonce, viewModeEnabled, markMode, markQuestions, markListKey, sidebarStyle: sidebarStyleProp, style: styleProp, liveCanvasChrome, extraCommands, }: ExcalidrawCanvasProps): react.JSX.Element;
|
|
868
|
+
declare function ExcalidrawCanvas({ initialSceneData, onCanvasChange, onSceneChange, onSubmitBoard, canSubmitBoard, submitLabel, applyElements, applyElementsNonce, applyFiles, applyRemoveElementIds, openFocusRole, scrollAppliedElements, onEvent, onAsk, runModel, boardId, askBusy, onLearnerWaitChange, dictateTranscript, dictateListening, getLiveTranscript, onDictateActive, replaceScene, replaceSceneNonce, viewModeEnabled, markMode, markQuestions, markListKey, sidebarStyle: sidebarStyleProp, style: styleProp, liveCanvasChrome, extraCommands, collaboration, invite, inviteHint, }: ExcalidrawCanvasProps): react.JSX.Element;
|
|
583
869
|
/**
|
|
584
870
|
* Learn/Verify work board — same component, same features. Required props
|
|
585
871
|
* keep Commands, the board prompt, Ask thinking, and XAI apply on.
|
|
@@ -587,7 +873,6 @@ declare function ExcalidrawCanvas({ initialSceneData, onCanvasChange, onSceneCha
|
|
|
587
873
|
type WorkCanvasProps = ExcalidrawCanvasProps & {
|
|
588
874
|
boardId: string;
|
|
589
875
|
onSceneChange: NonNullable<ExcalidrawCanvasProps["onSceneChange"]>;
|
|
590
|
-
onAsk: NonNullable<ExcalidrawCanvasProps["onAsk"]>;
|
|
591
876
|
};
|
|
592
877
|
declare function WorkCanvas(props: WorkCanvasProps): react.JSX.Element;
|
|
593
878
|
|
|
@@ -620,7 +905,10 @@ type UnsysCanvasProps = {
|
|
|
620
905
|
onSceneChange: (scene: UnsysCanvasScene) => void;
|
|
621
906
|
onEvent?: (events: UnsysCanvasEvent[]) => void;
|
|
622
907
|
onCanvasEvents?: (events: UnsysCanvasEvent[]) => void;
|
|
623
|
-
|
|
908
|
+
/** @deprecated Prefer `runModel`. Kept so existing hosts keep working. */
|
|
909
|
+
onAsk?: (input: UnsysCanvasAskInput) => Promise<UnsysCanvasAskResult>;
|
|
910
|
+
/** Thin LLM execution. The package builds prompts from the command registry. */
|
|
911
|
+
runModel?: UnsysCanvasRunModel;
|
|
624
912
|
style?: UnsysCanvasStyle | null;
|
|
625
913
|
slots?: UnsysCanvasSlots;
|
|
626
914
|
commands?: readonly UnsysCanvasHostCommand[];
|
|
@@ -633,8 +921,8 @@ type UnsysCanvasProps = {
|
|
|
633
921
|
getLiveTranscript?: () => string;
|
|
634
922
|
onDictateActive?: (active: boolean) => void;
|
|
635
923
|
className?: string;
|
|
636
|
-
} & Omit<ExcalidrawCanvasProps, "initialSceneData" | "onSceneChange" | "onAsk" | "onEvent" | "style" | "sidebarStyle" | "extraCommands" | "markMode">;
|
|
637
|
-
declare function UnsysCanvas({ scene, initialScene, onSceneChange, onEvent, onCanvasEvents, onAsk, style, slots, commands, railCollapsed, onRailCollapsedChange, boardId, className, ...boardProps }: UnsysCanvasProps): react.JSX.Element;
|
|
924
|
+
} & Omit<ExcalidrawCanvasProps, "initialSceneData" | "onSceneChange" | "onAsk" | "runModel" | "onEvent" | "style" | "sidebarStyle" | "extraCommands" | "markMode">;
|
|
925
|
+
declare function UnsysCanvas({ scene, initialScene, onSceneChange, onEvent, onCanvasEvents, onAsk, runModel, style, slots, commands, railCollapsed, onRailCollapsedChange, boardId, className, ...boardProps }: UnsysCanvasProps): react.JSX.Element;
|
|
638
926
|
|
|
639
927
|
/** Sidebar Commands tab: compact row. The topic still takes leftover rail height. */
|
|
640
928
|
declare const UNSYS_CANVAS_COMMAND_SIDEBAR_CLASS = "pointer-events-auto relative flex min-h-9 w-full min-w-0 flex-row items-center justify-start gap-1.5 overflow-hidden whitespace-nowrap rounded-none border border-white/35 bg-black px-1.5 py-1.5 text-left font-mono text-[11px] leading-tight text-white shadow-[inset_0_1px_0_rgba(255,255,255,0.2)] hover:border-white hover:bg-neutral-950 disabled:cursor-not-allowed disabled:border-neutral-800 disabled:bg-neutral-950 disabled:text-neutral-600 disabled:opacity-100 disabled:shadow-none disabled:hover:border-neutral-800 disabled:hover:bg-neutral-950 disabled:hover:text-neutral-600";
|
|
@@ -643,7 +931,7 @@ declare const UNSYS_CANVAS_COMMAND_SIDEBAR_MARK_CLASS = "h-3.5 w-3.5 shrink-0";
|
|
|
643
931
|
declare const UNSYS_CANVAS_COMMAND_STRIPE_CLASS = "pointer-events-auto relative flex h-10 w-10 shrink-0 items-center justify-center rounded-none border border-white/35 bg-black text-white shadow-[inset_0_1px_0_rgba(255,255,255,0.2)] hover:border-white hover:bg-neutral-950 disabled:cursor-not-allowed disabled:border-neutral-800 disabled:bg-neutral-950 disabled:text-neutral-600 disabled:opacity-100 disabled:shadow-none disabled:hover:border-neutral-800 disabled:hover:bg-neutral-950 disabled:hover:text-neutral-600";
|
|
644
932
|
declare const UNSYS_CANVAS_COMMAND_STRIPE_MARK_CLASS = "h-4 w-4 shrink-0";
|
|
645
933
|
declare function CommandMark({ id, className, }: {
|
|
646
|
-
id: UnsysCanvasCommandId | "dictate" | "pointer" | "commit" | "rail-expand" | "rail-collapse" | "boards" | "save";
|
|
934
|
+
id: UnsysCanvasCommandId | "dictate" | "pointer" | "commit" | "rail-expand" | "rail-collapse" | "boards" | "save" | "picker";
|
|
647
935
|
label?: string;
|
|
648
936
|
className?: string;
|
|
649
937
|
}): react.JSX.Element;
|
|
@@ -699,5 +987,89 @@ declare function readUnsysCanvasHashFromLocation(hash?: string | null | undefine
|
|
|
699
987
|
declare function replaceUnsysCanvasLocationHash(hash: string): void;
|
|
700
988
|
|
|
701
989
|
declare function assertOnAsk(onAsk: unknown): void;
|
|
990
|
+
/** Prefer `runModel`. `onAsk` remains for hosts that have not migrated. */
|
|
991
|
+
declare function assertCanvasModel(input: {
|
|
992
|
+
onAsk?: unknown;
|
|
993
|
+
runModel?: unknown;
|
|
994
|
+
}): void;
|
|
995
|
+
|
|
996
|
+
/** Live-collaboration fragment. Distinct from `#tc1.` scene snapshots. */
|
|
997
|
+
declare const UNSYS_CANVAS_COLLAB_HASH_PREFIX: "uc1.";
|
|
998
|
+
declare function generateUnsysCanvasCollabRoom(): UnsysCanvasCollabRoom;
|
|
999
|
+
declare function buildUnsysCanvasCollabHash(room: UnsysCanvasCollabRoom): string;
|
|
1000
|
+
declare function parseUnsysCanvasCollabHash(hash: string | null | undefined): UnsysCanvasCollabRoom | null;
|
|
1001
|
+
declare function isUnsysCanvasCollabHash(hash: string | null | undefined): boolean;
|
|
1002
|
+
declare function readUnsysCanvasCollabHashFromLocation(hash?: string | null | undefined): UnsysCanvasCollabRoom | null;
|
|
1003
|
+
declare function replaceUnsysCanvasCollabLocationHash(room: UnsysCanvasCollabRoom): string;
|
|
1004
|
+
/**
|
|
1005
|
+
* Shareable board URL. The encryption key stays in the fragment so it is
|
|
1006
|
+
* not sent to a relay or to HTTP access logs.
|
|
1007
|
+
*/
|
|
1008
|
+
declare function buildUnsysCanvasCollabShareUrl(room: UnsysCanvasCollabRoom, href?: string | null | undefined): string;
|
|
1009
|
+
|
|
1010
|
+
declare function reconcileUnsysCanvasElements(local: readonly UnsysCanvasElement[] | null | undefined, remote: readonly UnsysCanvasElement[] | null | undefined, options?: UnsysCanvasCollabReconcileOptions): UnsysCanvasElement[];
|
|
1011
|
+
declare function reconcileUnsysCanvasFiles(local: UnsysCanvasFiles | null | undefined, remote: UnsysCanvasFiles | null | undefined): UnsysCanvasFiles;
|
|
1012
|
+
declare function reconcileUnsysCanvasScene(local: Pick<UnsysCanvasScene, "elements" | "files"> | null | undefined, remote: UnsysCanvasCollabScenePayload | null | undefined, options?: UnsysCanvasCollabReconcileOptions): UnsysCanvasCollabScenePayload;
|
|
1013
|
+
|
|
1014
|
+
type UnsysCanvasCollabSessionHandlers = {
|
|
1015
|
+
onRemoteScene?: (scene: UnsysCanvasCollabScenePayload, from: UnsysCanvasCollabUser) => void;
|
|
1016
|
+
onCollaborators?: (collaborators: Map<string, UnsysCanvasCollaborator>) => void;
|
|
1017
|
+
onOpen?: () => void;
|
|
1018
|
+
onClose?: () => void;
|
|
1019
|
+
onError?: (error: unknown) => void;
|
|
1020
|
+
};
|
|
1021
|
+
type UnsysCanvasCollabSessionOptions = {
|
|
1022
|
+
roomId: string;
|
|
1023
|
+
key: string;
|
|
1024
|
+
user: UnsysCanvasCollabUser;
|
|
1025
|
+
transport: UnsysCanvasCollaborationTransport;
|
|
1026
|
+
handlers?: UnsysCanvasCollabSessionHandlers;
|
|
1027
|
+
getLocalScene?: () => UnsysCanvasCollabScenePayload | null;
|
|
1028
|
+
getEditingIds?: () => Iterable<string> | null;
|
|
1029
|
+
};
|
|
1030
|
+
declare class UnsysCanvasCollabSession {
|
|
1031
|
+
readonly roomId: string;
|
|
1032
|
+
readonly user: UnsysCanvasCollabUser;
|
|
1033
|
+
private readonly key;
|
|
1034
|
+
private readonly transport;
|
|
1035
|
+
private readonly handlers;
|
|
1036
|
+
private readonly getLocalScene?;
|
|
1037
|
+
private readonly getEditingIds?;
|
|
1038
|
+
private socket;
|
|
1039
|
+
private collaborators;
|
|
1040
|
+
private closed;
|
|
1041
|
+
constructor(options: UnsysCanvasCollabSessionOptions);
|
|
1042
|
+
start(): void;
|
|
1043
|
+
close(): void;
|
|
1044
|
+
broadcastScene(scene: UnsysCanvasCollabScenePayload): Promise<void>;
|
|
1045
|
+
broadcastPointer(pointer: UnsysCanvasCollabPointerPayload): Promise<void>;
|
|
1046
|
+
private sendHello;
|
|
1047
|
+
private send;
|
|
1048
|
+
private handleBytes;
|
|
1049
|
+
private touchCollaborator;
|
|
1050
|
+
private emitCollaborators;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* In-process relay for tests and same-runtime hosts. Ciphertext still
|
|
1055
|
+
* flows through so encryption can be exercised without a network.
|
|
1056
|
+
*/
|
|
1057
|
+
declare function createUnsysCanvasMemoryTransportHub(): {
|
|
1058
|
+
createTransport: () => UnsysCanvasCollaborationTransport;
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
type UnsysCanvasWebsocketTransportOptions = {
|
|
1062
|
+
/** `ws://` or `wss://` URL of a Unsys Canvas collab relay. */
|
|
1063
|
+
url: string;
|
|
1064
|
+
};
|
|
1065
|
+
/**
|
|
1066
|
+
* Reference transport: opaque encrypted frames over a WebSocket relay.
|
|
1067
|
+
* The relay only sees `roomId` plus ciphertext.
|
|
1068
|
+
*/
|
|
1069
|
+
declare function createUnsysCanvasWebsocketTransport(options: UnsysCanvasWebsocketTransportOptions): UnsysCanvasCollaborationTransport;
|
|
1070
|
+
declare function isUnsysCanvasRelayUrl(value: string | null | undefined): boolean;
|
|
1071
|
+
|
|
1072
|
+
declare function encryptUnsysCanvasCollabJson(keyB64: string, value: unknown): Promise<Uint8Array>;
|
|
1073
|
+
declare function decryptUnsysCanvasCollabJson(keyB64: string, packed: Uint8Array): Promise<unknown>;
|
|
702
1074
|
|
|
703
|
-
export { CanvasCommandRail, CanvasTopicCard, CommandMark, DEFAULT_UNSYS_CANVAS_BOARD_STYLE, DEFAULT_UNSYS_CANVAS_STYLE_TOKENS, EMPTY_UNSYS_CANVAS_STYLE, ExcalidrawCanvas, UNSYS_CANVAS_COMMANDS, UNSYS_CANVAS_COMMAND_SIDEBAR_CLASS, UNSYS_CANVAS_COMMAND_SIDEBAR_MARK_CLASS, UNSYS_CANVAS_COMMAND_STRIPE_CLASS, UNSYS_CANVAS_COMMAND_STRIPE_MARK_CLASS, UNSYS_CANVAS_EVENT_TYPES, UNSYS_CANVAS_HASH_PREFIX, UnsysCanvas, type UnsysCanvasAskInput, type UnsysCanvasAskKind, type UnsysCanvasAskResult, type UnsysCanvasBoardStyle, type UnsysCanvasCommandId, type UnsysCanvasElement, type UnsysCanvasEvent, UnsysCanvasEventCollector, type UnsysCanvasEventType, type UnsysCanvasHostCommand, type UnsysCanvasProps, type UnsysCanvasScene, type UnsysCanvasSidebarTokens, type UnsysCanvasSlots, type UnsysCanvasStyle, WorkCanvas, applyUnsysCanvasAskReply, assertOnAsk, buildUnsysCanvasCommandUserMessage, convertToExcalidrawElements, decodeUnsysCanvasHash, emptyUnsysCanvasScene, encodeUnsysCanvasHash, normalizeUnsysCanvasLinearElement, parseUnsysCanvasAskReply, parseUnsysCanvasStyle, readUnsysCanvasHashFromLocation, replaceUnsysCanvasLocationHash, runUnsysCanvasCommand, serializeUnsysCanvasScene, unsysCanvasAskFromSessionChat, unsysCanvasCommandsFor, unsysCanvasHasLiveElements, unsysCanvasSidebarStyleCssVars, unsysCanvasTurnContextMessage, unsysCanvasXaiFetchTimeout, unsysCanvasXaiMaxTokens, unsysCanvasXaiNeedsBoardContext };
|
|
1075
|
+
export { CanvasCommandRail, CanvasTopicCard, CommandMark, DEFAULT_UNSYS_CANVAS_BOARD_STYLE, DEFAULT_UNSYS_CANVAS_STYLE_TOKENS, EMPTY_UNSYS_CANVAS_STYLE, ExcalidrawCanvas, UNSYS_CANVAS_COLLAB_HASH_PREFIX, UNSYS_CANVAS_COMMANDS, UNSYS_CANVAS_COMMAND_SIDEBAR_CLASS, UNSYS_CANVAS_COMMAND_SIDEBAR_MARK_CLASS, UNSYS_CANVAS_COMMAND_STRIPE_CLASS, UNSYS_CANVAS_COMMAND_STRIPE_MARK_CLASS, UNSYS_CANVAS_COMMAND_SYSTEM_PROMPT, UNSYS_CANVAS_EVENT_TYPES, UNSYS_CANVAS_HASH_PREFIX, UnsysCanvas, type UnsysCanvasAskInput, type UnsysCanvasAskKind, type UnsysCanvasAskResult, type UnsysCanvasBoardStyle, type UnsysCanvasCollabRoom, UnsysCanvasCollabSession, type UnsysCanvasCollaborationAdapter, type UnsysCanvasCollaborationTransport, type UnsysCanvasCommandContextPayload, type UnsysCanvasCommandDefinition, type UnsysCanvasCommandId, type UnsysCanvasElement, type UnsysCanvasEvent, UnsysCanvasEventCollector, type UnsysCanvasEventType, type UnsysCanvasHostCommand, type UnsysCanvasHostCommandSpec, type UnsysCanvasModelRequest, type UnsysCanvasModelResult, type UnsysCanvasParsedCommandReply, type UnsysCanvasProps, type UnsysCanvasRunModel, type UnsysCanvasScene, type UnsysCanvasSidebarTokens, type UnsysCanvasSlots, type UnsysCanvasStyle, WorkCanvas, applyUnsysCanvasAskReply, assertCanvasModel, assertOnAsk, buildUnsysCanvasCollabHash, buildUnsysCanvasCollabShareUrl, buildUnsysCanvasCommandPrompt, buildUnsysCanvasCommandUserMessage, buildUnsysCanvasModelRequest, convertToExcalidrawElements, createUnsysCanvasMemoryTransportHub, createUnsysCanvasModelProxyRunner, createUnsysCanvasWebsocketTransport, createUnsysCanvasXaiBrowserRunner, decodeUnsysCanvasHash, decryptUnsysCanvasCollabJson, emptyUnsysCanvasScene, encodeUnsysCanvasHash, encryptUnsysCanvasCollabJson, extractUnsysCanvasCommandContext, generateUnsysCanvasCollabRoom, getUnsysCanvasCommand, handleCanvasModelHttpRequest, handleCanvasModelRequest, isUnsysCanvasCollabHash, isUnsysCanvasKnownCommandId, isUnsysCanvasRelayUrl, listUnsysCanvasCommandDefinitions, normalizeUnsysCanvasLinearElement, parseUnsysCanvasAskReply, parseUnsysCanvasCollabHash, parseUnsysCanvasCommandResponse, parseUnsysCanvasModelClientBody, parseUnsysCanvasStyle, readUnsysCanvasCollabHashFromLocation, readUnsysCanvasHashFromLocation, reconcileUnsysCanvasElements, reconcileUnsysCanvasFiles, reconcileUnsysCanvasScene, replaceUnsysCanvasCollabLocationHash, replaceUnsysCanvasLocationHash, runUnsysCanvasCommand, runUnsysCanvasModelAsk, serializeUnsysCanvasScene, unsysCanvasAskFromSessionChat, unsysCanvasCommandPlacement, unsysCanvasCommandsFor, unsysCanvasGestureCommandId, unsysCanvasHasLiveElements, unsysCanvasSidebarStyleCssVars, unsysCanvasTurnContextMessage, unsysCanvasXaiFetchTimeout, unsysCanvasXaiMaxTokens, unsysCanvasXaiNeedsBoardContext };
|