unsys-canvas 0.1.2 → 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 +2 -2
- package/dist/core.d.ts +364 -5
- package/dist/core.js +1571 -508
- package/dist/core.js.map +1 -1
- package/dist/index.d.ts +383 -12
- package/dist/index.js +2587 -612
- 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;
|
|
@@ -254,6 +255,8 @@ declare const UNSYS_CANVAS_COMMANDS: readonly [{
|
|
|
254
255
|
readonly label: "Simplify";
|
|
255
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
262
|
readonly replacesSelection: false;
|
|
@@ -262,6 +265,8 @@ declare const UNSYS_CANVAS_COMMANDS: readonly [{
|
|
|
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 = {
|
|
@@ -301,12 +322,17 @@ type UnsysCanvasHostCommand = {
|
|
|
301
322
|
needsSelection?: boolean;
|
|
302
323
|
/** Ignored. Only Refactor may replace the selection. */
|
|
303
324
|
replacesSelection?: boolean;
|
|
325
|
+
gesture?: string | null;
|
|
326
|
+
gestureHint?: string | null;
|
|
327
|
+
catalog?: boolean;
|
|
328
|
+
needsModel?: boolean;
|
|
329
|
+
placement?: "beside" | "replace";
|
|
304
330
|
run?: (ctx: {
|
|
305
331
|
selectedElements: UnsysCanvasElement[];
|
|
306
332
|
scene: UnsysCanvasScene;
|
|
307
333
|
}) => void | Promise<void>;
|
|
308
334
|
};
|
|
309
|
-
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";
|
|
310
336
|
type UnsysCanvasCommandDef = {
|
|
311
337
|
id: string;
|
|
312
338
|
label: string;
|
|
@@ -316,6 +342,8 @@ type UnsysCanvasCommandDef = {
|
|
|
316
342
|
boardOnly: boolean;
|
|
317
343
|
replacesSelection: boolean;
|
|
318
344
|
slash?: string;
|
|
345
|
+
gesture?: string | null;
|
|
346
|
+
gestureHint?: string | null;
|
|
319
347
|
run?: UnsysCanvasHostCommand["run"];
|
|
320
348
|
};
|
|
321
349
|
/** Built-in catalog plus host-registered commands. */
|
|
@@ -336,8 +364,8 @@ type UnsysCanvasCommandRun = {
|
|
|
336
364
|
/**
|
|
337
365
|
* Local result of a sidebar/dock command click.
|
|
338
366
|
* Subdivide, Focus, and Next mutate now. Refactor drops the original marks
|
|
339
|
-
* immediately, then asks XAI. Simplify, Do/run, and
|
|
340
|
-
* and ask. A click that cannot run returns a short board notice instead of going silent.
|
|
367
|
+
* immediately, then asks XAI. Simplify, Do/run, Concepts, and Pretty keep the
|
|
368
|
+
* original and ask. A click that cannot run returns a short board notice instead of going silent.
|
|
341
369
|
*/
|
|
342
370
|
declare function runUnsysCanvasCommand(input: {
|
|
343
371
|
action: UnsysCanvasCommandId;
|
|
@@ -349,12 +377,196 @@ declare function runUnsysCanvasCommand(input: {
|
|
|
349
377
|
nextHiddenStateId?: string | null;
|
|
350
378
|
}): UnsysCanvasCommandRun;
|
|
351
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
|
+
|
|
352
564
|
/**
|
|
353
565
|
* Verbose raw board event feed. No classification or proof-of-work semantics.
|
|
354
566
|
* High-frequency updates are batched by merging consecutive same-key events
|
|
355
567
|
* (first `from`, last `to`) so information is not dropped.
|
|
356
568
|
*/
|
|
357
|
-
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"];
|
|
358
570
|
type UnsysCanvasEventType = (typeof UNSYS_CANVAS_EVENT_TYPES)[number];
|
|
359
571
|
type UnsysCanvasEvent = {
|
|
360
572
|
seq: number;
|
|
@@ -376,6 +588,7 @@ declare class UnsysCanvasEventCollector {
|
|
|
376
588
|
private push;
|
|
377
589
|
observeScene(scene?: unknown, _opts?: unknown): UnsysCanvasEvent[];
|
|
378
590
|
command(id?: string, meta?: unknown): UnsysCanvasEvent[];
|
|
591
|
+
commandComplete(id?: string, meta?: unknown): UnsysCanvasEvent[];
|
|
379
592
|
dictate(meta?: unknown): UnsysCanvasEvent[];
|
|
380
593
|
prompt(text?: string, meta?: unknown): UnsysCanvasEvent[];
|
|
381
594
|
laser(meta?: unknown): UnsysCanvasEvent[];
|
|
@@ -455,6 +668,68 @@ declare function applyUnsysCanvasAskReply(input: {
|
|
|
455
668
|
}[] | null;
|
|
456
669
|
}): UnsysCanvasScene;
|
|
457
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
|
+
|
|
458
733
|
type UnsysCanvasSidebarTokens = {
|
|
459
734
|
background: string;
|
|
460
735
|
border: string;
|
|
@@ -511,7 +786,7 @@ interface ExcalidrawCanvasProps {
|
|
|
511
786
|
scrollAppliedElements?: boolean;
|
|
512
787
|
/** Classified Work-canvas event (draw/move/rotate/delete/Commands/board prompt). */
|
|
513
788
|
onEvent?: (events: UnsysCanvasEvent[]) => void;
|
|
514
|
-
onAsk
|
|
789
|
+
onAsk?: (input: {
|
|
515
790
|
prompt: string;
|
|
516
791
|
selectedElements: UnsysCanvasElement[];
|
|
517
792
|
scene: UnsysCanvasScene;
|
|
@@ -525,6 +800,7 @@ interface ExcalidrawCanvasProps {
|
|
|
525
800
|
} | null;
|
|
526
801
|
raw?: string | null;
|
|
527
802
|
}>;
|
|
803
|
+
runModel?: UnsysCanvasRunModel;
|
|
528
804
|
/** Remounts the board when this identity changes. */
|
|
529
805
|
boardId?: string | null;
|
|
530
806
|
/** Ask/XAI in-flight (Verify wait, Learn send) — same overlay chip as ask-about-selection. */
|
|
@@ -574,13 +850,22 @@ interface ExcalidrawCanvasProps {
|
|
|
574
850
|
/** Always apply fill, ink, zen, and grid (preview / authoring). */
|
|
575
851
|
liveCanvasChrome?: boolean;
|
|
576
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;
|
|
577
862
|
}
|
|
578
863
|
/**
|
|
579
864
|
* Shared Learn/Verify work board. Hosts must not fork this — both surfaces
|
|
580
865
|
* mount `WorkCanvas` so Commands, the board prompt, thinking overlay,
|
|
581
866
|
* XAI apply, and center-on-open stay one implementation.
|
|
582
867
|
*/
|
|
583
|
-
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;
|
|
584
869
|
/**
|
|
585
870
|
* Learn/Verify work board — same component, same features. Required props
|
|
586
871
|
* keep Commands, the board prompt, Ask thinking, and XAI apply on.
|
|
@@ -588,7 +873,6 @@ declare function ExcalidrawCanvas({ initialSceneData, onCanvasChange, onSceneCha
|
|
|
588
873
|
type WorkCanvasProps = ExcalidrawCanvasProps & {
|
|
589
874
|
boardId: string;
|
|
590
875
|
onSceneChange: NonNullable<ExcalidrawCanvasProps["onSceneChange"]>;
|
|
591
|
-
onAsk: NonNullable<ExcalidrawCanvasProps["onAsk"]>;
|
|
592
876
|
};
|
|
593
877
|
declare function WorkCanvas(props: WorkCanvasProps): react.JSX.Element;
|
|
594
878
|
|
|
@@ -621,7 +905,10 @@ type UnsysCanvasProps = {
|
|
|
621
905
|
onSceneChange: (scene: UnsysCanvasScene) => void;
|
|
622
906
|
onEvent?: (events: UnsysCanvasEvent[]) => void;
|
|
623
907
|
onCanvasEvents?: (events: UnsysCanvasEvent[]) => void;
|
|
624
|
-
|
|
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;
|
|
625
912
|
style?: UnsysCanvasStyle | null;
|
|
626
913
|
slots?: UnsysCanvasSlots;
|
|
627
914
|
commands?: readonly UnsysCanvasHostCommand[];
|
|
@@ -634,8 +921,8 @@ type UnsysCanvasProps = {
|
|
|
634
921
|
getLiveTranscript?: () => string;
|
|
635
922
|
onDictateActive?: (active: boolean) => void;
|
|
636
923
|
className?: string;
|
|
637
|
-
} & Omit<ExcalidrawCanvasProps, "initialSceneData" | "onSceneChange" | "onAsk" | "onEvent" | "style" | "sidebarStyle" | "extraCommands" | "markMode">;
|
|
638
|
-
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;
|
|
639
926
|
|
|
640
927
|
/** Sidebar Commands tab: compact row. The topic still takes leftover rail height. */
|
|
641
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";
|
|
@@ -644,7 +931,7 @@ declare const UNSYS_CANVAS_COMMAND_SIDEBAR_MARK_CLASS = "h-3.5 w-3.5 shrink-0";
|
|
|
644
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";
|
|
645
932
|
declare const UNSYS_CANVAS_COMMAND_STRIPE_MARK_CLASS = "h-4 w-4 shrink-0";
|
|
646
933
|
declare function CommandMark({ id, className, }: {
|
|
647
|
-
id: UnsysCanvasCommandId | "dictate" | "pointer" | "commit" | "rail-expand" | "rail-collapse" | "boards" | "save";
|
|
934
|
+
id: UnsysCanvasCommandId | "dictate" | "pointer" | "commit" | "rail-expand" | "rail-collapse" | "boards" | "save" | "picker";
|
|
648
935
|
label?: string;
|
|
649
936
|
className?: string;
|
|
650
937
|
}): react.JSX.Element;
|
|
@@ -700,5 +987,89 @@ declare function readUnsysCanvasHashFromLocation(hash?: string | null | undefine
|
|
|
700
987
|
declare function replaceUnsysCanvasLocationHash(hash: string): void;
|
|
701
988
|
|
|
702
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>;
|
|
703
1074
|
|
|
704
|
-
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 };
|