@statelyai/sdk 0.29.1 → 0.31.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.
Files changed (34) hide show
  1. package/README.md +15 -0
  2. package/dist/assetStorage.d.mts +1 -1
  3. package/dist/auth.d.mts +1 -1
  4. package/dist/{statelyPragma-p1vu8PmH.mjs → dist-wbhkeGh6.mjs} +468 -204
  5. package/dist/{editor-sync-types-DB1N6QUK.d.mts → editor-sync-types-CPpzTSnT.d.mts} +4 -0
  6. package/dist/{editorHostSession-vSt07IJV.d.mts → editorHostSession-Bo-YhDEG.d.mts} +105 -6
  7. package/dist/{editorHostSession-DNpXPNAc.mjs → editorHostSession-CT8y0yzG.mjs} +380 -20
  8. package/dist/editorHostSession.d.mts +2 -2
  9. package/dist/editorHostSession.mjs +3 -2
  10. package/dist/embed.d.mts +3 -4
  11. package/dist/embed.mjs +5 -2
  12. package/dist/{graph-C8E1Exad.d.mts → graph-CR_g-mOq.d.mts} +1 -1
  13. package/dist/graph.d.mts +1 -1
  14. package/dist/{index-D4pdeDpT.d.mts → index-DlOZxzrW.d.mts} +92 -2
  15. package/dist/index.d.mts +8 -9
  16. package/dist/index.mjs +6 -5
  17. package/dist/{inspect-D61HS-t7.d.mts → inspect-BoWXrB-V.d.mts} +3 -2
  18. package/dist/{inspect-dmCvrIl1.mjs → inspect-DoDj7iWa.mjs} +25 -1
  19. package/dist/inspect.d.mts +2 -2
  20. package/dist/inspect.mjs +2 -2
  21. package/dist/patchTypes.d.mts +1 -1
  22. package/dist/protocol-2cvzJtGN.d.mts +846 -0
  23. package/dist/protocol.d.mts +2 -821
  24. package/dist/relay.d.mts +1 -1
  25. package/dist/statelyPragma-D46lczJR.mjs +102 -0
  26. package/dist/{studio-D-yqFd0u.d.mts → studio-DV5IIGhV.d.mts} +2 -2
  27. package/dist/studio.d.mts +1 -1
  28. package/dist/sync.d.mts +2 -2
  29. package/dist/sync.mjs +411 -30
  30. package/dist/{version-DC3yW9Dk.mjs → version-B6OHpDiz.mjs} +1 -1
  31. package/package.json +3 -3
  32. package/schemas/statelyai.schema.json +6 -0
  33. package/dist/embedPanel-Bpbq4sfJ.d.mts +0 -13
  34. /package/dist/{auth-BPyCCHYo.d.mts → auth-Dg7prjeL.d.mts} +0 -0
@@ -0,0 +1,846 @@
1
+ import { i as ProfileManifest } from "./index-DlOZxzrW.mjs";
2
+ import { i as StatelyGraph } from "./graph-CR_g-mOq.mjs";
3
+ import { c as EditorSyncSourceLocation, f as MachineSourceLocations$1, l as EditorSyncSourceRange, t as EditorCapabilities$1, u as EditorSyncStateSourceLocation } from "./editor-sync-types-CPpzTSnT.mjs";
4
+
5
+ //#region src/embedPanel.d.ts
6
+ type EmbedPanelPosition = 'left' | 'right' | 'bottom';
7
+ interface EmbedPanelConfig {
8
+ id: string;
9
+ /** Restrict the panel to one side. Omit to allow any side. */
10
+ position?: EmbedPanelPosition;
11
+ /** Keep a one-click tab visible on its positioned or preferred side. */
12
+ tab?: boolean;
13
+ /** Open the panel when the embed is initialized. */
14
+ initiallyOpen?: boolean;
15
+ }
16
+ //#endregion
17
+ //#region src/protocol.d.ts
18
+ /** Query parameter carrying the unguessable inspection room capability. */
19
+ declare const INSPECTION_ROOM_QUERY_PARAM = "r";
20
+ /**
21
+ * Create the room-global identity for one producer-local actor session.
22
+ * Runtime and producer-resolved session ids may use different uniqueness
23
+ * domains; the producer id supplies a stable room namespace.
24
+ */
25
+ declare function createInspectionActorId(producerId: string, sessionId: string): string;
26
+ interface InspectionRoomUrls {
27
+ roomId: string;
28
+ relayUrl: string;
29
+ inspectorUrl: string;
30
+ }
31
+ /** Resolve the transport and browser URLs required by the inspection protocol. */
32
+ declare function createInspectionRoomUrls(options: {
33
+ url: string;
34
+ roomId: string;
35
+ inspectorBaseUrl?: string;
36
+ }): InspectionRoomUrls;
37
+ /** Read a room capability from a conforming relay or inspector URL. */
38
+ declare function getInspectionRoomId(value: string | URL): string | null;
39
+ type EmbedMode = 'editing' | 'viewing' | 'simulating' | 'inspecting';
40
+ interface CommentsConfig {
41
+ roomId: string;
42
+ userId?: string | null;
43
+ publicApiKey?: string;
44
+ authEndpoint?: string;
45
+ baseUrl?: string;
46
+ }
47
+ interface ProjectEmbedMachine {
48
+ id: string;
49
+ name?: string;
50
+ /** Source identifier used when another machine invokes this machine. */
51
+ sourceReference?: string;
52
+ /** Source document used to scope references that do not carry imports. */
53
+ sourceUri?: string;
54
+ /** Optional host project scope for machine-to-machine references. */
55
+ projectId?: string;
56
+ createdAt?: number;
57
+ updatedAt?: number;
58
+ origin?: ProjectWorkspaceMachineOrigin;
59
+ machine: unknown;
60
+ /** Source format used by source-backed project hosts. */
61
+ format?: string;
62
+ /** Per-machine writeback locations used by source-backed project hosts. */
63
+ sourceLocations?: MachineSourceLocations;
64
+ }
65
+ type ProjectWorkspaceActionIcon = 'arrow-left' | 'copy' | 'fork' | 'history';
66
+ interface ProjectWorkspaceAction {
67
+ id: string;
68
+ label: string;
69
+ icon?: ProjectWorkspaceActionIcon;
70
+ disabled?: boolean;
71
+ }
72
+ interface ProjectWorkspaceMachineOrigin {
73
+ parentMachineId: string;
74
+ type: 'version' | 'fork';
75
+ createdBy?: {
76
+ type: string;
77
+ id?: string;
78
+ name?: string;
79
+ };
80
+ captureType?: string;
81
+ }
82
+ /** Opt-in host-facing automatic version capture policy. */
83
+ interface MachineVersionAutoSaveOptions {
84
+ /** Minimum time between automatic versions, in milliseconds. */
85
+ intervalMs: number;
86
+ createdBy?: {
87
+ type: string;
88
+ id?: string;
89
+ name?: string;
90
+ };
91
+ captureType?: string;
92
+ }
93
+ interface ProjectWorkspaceMachine {
94
+ id: string;
95
+ name?: string;
96
+ createdAt?: number;
97
+ updatedAt?: number;
98
+ origin?: ProjectWorkspaceMachineOrigin;
99
+ /** Optional editor target supplied by a hosted workspace. */
100
+ editor?: 'legacy' | 'beta';
101
+ /** Action emitted instead of selecting the machine when it is clicked. */
102
+ openAction?: ProjectWorkspaceAction;
103
+ }
104
+ interface ProjectWorkspaceProject {
105
+ id: string;
106
+ name: string;
107
+ machines: ProjectWorkspaceMachine[];
108
+ rootMachineId?: string;
109
+ }
110
+ /** Host-backed operations for the built-in workspace controls. */
111
+ interface ProjectWorkspaceCapabilities {
112
+ renameProject?: ProjectWorkspaceAction;
113
+ createMachine?: ProjectWorkspaceAction;
114
+ createMachineVersion?: ProjectWorkspaceAction;
115
+ restoreMachineVersion?: ProjectWorkspaceAction;
116
+ renameMachine?: ProjectWorkspaceAction;
117
+ copyMachine?: ProjectWorkspaceAction;
118
+ deleteMachine?: ProjectWorkspaceAction;
119
+ setRootMachine?: ProjectWorkspaceAction;
120
+ }
121
+ interface ProjectWorkspaceConfigBase {
122
+ defaultProjectId?: string;
123
+ /** Optional navigation action shown above the workspace. Set to null to hide it. */
124
+ backAction?: ProjectWorkspaceAction | null;
125
+ userAvatarUrl?: string;
126
+ machineSelectionDisabled?: boolean;
127
+ /** Optional host-backed operations for the built-in workspace controls. */
128
+ workspaceCapabilities?: ProjectWorkspaceCapabilities;
129
+ /** Actions rendered from the workspace options menu. */
130
+ workspaceActions?: ProjectWorkspaceAction[];
131
+ /** Optional actions keyed by project or machine id. */
132
+ projectActions?: Record<string, ProjectWorkspaceAction[]>;
133
+ machineActions?: Record<string, ProjectWorkspaceAction[]>;
134
+ }
135
+ /** Serializable workspace tree rendered by project-mode embeds. */
136
+ type ProjectWorkspaceConfig = (ProjectWorkspaceConfigBase & {
137
+ /** Single-project mode: hides project CRUD for this project. */project: ProjectWorkspaceProject;
138
+ projects?: never;
139
+ }) | (ProjectWorkspaceConfigBase & {
140
+ /** Multi-project mode: renders a collapsible project tree. */projects: ProjectWorkspaceProject[];
141
+ project?: never;
142
+ });
143
+ declare const EMBED_DOCUMENT_LANGUAGES: readonly ["markdown", "typescript", "javascript", "json", "xml", "mermaid", "text"];
144
+ type EmbedDocumentLanguage = (typeof EMBED_DOCUMENT_LANGUAGES)[number];
145
+ declare const EMBED_DOCUMENT_LIMITS: {
146
+ readonly maxDocuments: 100;
147
+ readonly maxDocumentLength: number;
148
+ readonly maxTotalLength: number;
149
+ };
150
+ /** Read-only text supplied by an embed host for display beside a machine. */
151
+ interface EmbedDocument {
152
+ /** Relative POSIX path used as the document's stable identity. */
153
+ path: string;
154
+ content: string;
155
+ /** Overrides renderer detection from the path's file extension. */
156
+ language?: EmbedDocumentLanguage;
157
+ }
158
+ interface ValidationIssue {
159
+ nodeIds: string[];
160
+ edgeIds: string[];
161
+ level: 'info' | 'warning' | 'error';
162
+ message: string;
163
+ }
164
+ type EditorCapabilities = EditorCapabilities$1;
165
+ type ReadOnlyReason = 'free-plan' | 'access-unverified';
166
+ type CapabilityDeniedCapability = 'edit' | 'export' | 'ai' | 'simulate' | 'inspect' | 'panel' | 'mode';
167
+ interface CapabilityDeniedEvent {
168
+ capability: CapabilityDeniedCapability;
169
+ action: 'openPanel' | 'openDialog' | 'editSource' | 'setMode' | 'simulationStart' | 'inspectStart' | 'retrieve';
170
+ requested?: string;
171
+ message: string;
172
+ dedupeKey: string;
173
+ }
174
+ type SourceRange = EditorSyncSourceRange;
175
+ type SourceLocation = EditorSyncSourceLocation;
176
+ type StateSourceLocation = EditorSyncStateSourceLocation;
177
+ type MachineSourceLocations = MachineSourceLocations$1;
178
+ interface ExportFormatMap {
179
+ xstate: {
180
+ options: {
181
+ version?: 4 | 5;
182
+ addTSTypes?: boolean;
183
+ showIds?: boolean;
184
+ showDescriptions?: boolean;
185
+ };
186
+ result: string;
187
+ };
188
+ async: {
189
+ options: object;
190
+ result: string;
191
+ };
192
+ 'xstate-json': {
193
+ options: {
194
+ version?: 4 | 5;
195
+ };
196
+ result: Record<string, unknown>;
197
+ };
198
+ xgraph: {
199
+ options: object;
200
+ result: Record<string, unknown>;
201
+ };
202
+ digraph: {
203
+ options: object;
204
+ result: Record<string, unknown>;
205
+ };
206
+ d2: {
207
+ options: {
208
+ includeLayout?: boolean;
209
+ };
210
+ result: string;
211
+ };
212
+ mermaid: {
213
+ options: object;
214
+ result: string;
215
+ };
216
+ redux: {
217
+ options: object;
218
+ result: string;
219
+ };
220
+ zustand: {
221
+ options: object;
222
+ result: string;
223
+ };
224
+ 'asl-json': {
225
+ options: object;
226
+ result: string;
227
+ };
228
+ 'asl-yaml': {
229
+ options: object;
230
+ result: string;
231
+ };
232
+ scxml: {
233
+ options: object;
234
+ result: string;
235
+ };
236
+ }
237
+ type ExportFormat = keyof ExportFormatMap;
238
+ type ExportCallOptions<F extends ExportFormat> = ExportFormatMap[F]['options'] & {
239
+ timeout?: number;
240
+ };
241
+ interface EmbedEventMap {
242
+ ready: {
243
+ version: string;
244
+ };
245
+ loaded: {
246
+ graph: StatelyGraph;
247
+ machineId?: string;
248
+ sourceLocations?: MachineSourceLocations;
249
+ };
250
+ change: {
251
+ graph: StatelyGraph;
252
+ machineConfig: unknown;
253
+ machineId?: string;
254
+ patches?: unknown[];
255
+ sourceLocations?: MachineSourceLocations;
256
+ };
257
+ save: {
258
+ requestId?: string;
259
+ graph: StatelyGraph;
260
+ machineConfig: unknown;
261
+ machineId?: string;
262
+ patches?: unknown[];
263
+ validations?: ValidationIssue[];
264
+ sourceLocations?: MachineSourceLocations;
265
+ sourceUpdateStrategy?: 'preserve' | 'rewrite';
266
+ };
267
+ versionSaveRequested: {
268
+ graph: StatelyGraph;
269
+ machineConfig: unknown;
270
+ machineId?: string;
271
+ patches?: unknown[];
272
+ createdBy: NonNullable<MachineVersionAutoSaveOptions['createdBy']>;
273
+ captureType: string;
274
+ sourceLocations?: MachineSourceLocations;
275
+ };
276
+ error: {
277
+ code: ErrorCode;
278
+ message: string;
279
+ machineId?: string;
280
+ details?: string[];
281
+ };
282
+ capabilityDenied: CapabilityDeniedEvent;
283
+ snapshot: {
284
+ snapshot: unknown;
285
+ event: unknown | null;
286
+ };
287
+ machineSelected: {
288
+ machineId: string;
289
+ };
290
+ projectWorkspaceAction: {
291
+ actionId: string;
292
+ projectId?: string;
293
+ machineId?: string;
294
+ data?: unknown;
295
+ };
296
+ projectWorkspaceOpenChanged: {
297
+ open: boolean;
298
+ };
299
+ viewModeChanged: {
300
+ viewMode: 'graph' | 'list';
301
+ machineId?: string;
302
+ };
303
+ panelChanged: {
304
+ side: 'left' | 'right' | 'bottom';
305
+ id: string | null;
306
+ activePanels: string[];
307
+ machineId?: string;
308
+ };
309
+ modeChanged: {
310
+ mode: EmbedMode;
311
+ machineId?: string;
312
+ };
313
+ }
314
+ type EmbedEventName = keyof EmbedEventMap;
315
+ type EmbedEventHandler<K extends EmbedEventName> = (data: EmbedEventMap[K]) => void;
316
+ interface EmbedFormatManifest {
317
+ id: string;
318
+ name: string;
319
+ file?: {
320
+ extension?: string;
321
+ mediaType?: string;
322
+ };
323
+ editorLanguage?: string;
324
+ detect?: boolean;
325
+ import?: boolean;
326
+ export?: boolean;
327
+ }
328
+ interface EmbedExtensionsManifest {
329
+ profiles: ProfileManifest[];
330
+ formats: EmbedFormatManifest[];
331
+ defaultProfile?: string;
332
+ defaultFormat?: string;
333
+ }
334
+ /** Host-provided examples shown in the editor's Get started launchpad. */
335
+ interface EmbedExample {
336
+ id: string;
337
+ title: string;
338
+ description: string;
339
+ category: string;
340
+ machine: unknown;
341
+ }
342
+ /** Check whether an example machine has a shape supported by the editor. */
343
+ declare function isEmbedExampleMachine(value: unknown): value is Record<string, unknown>;
344
+ /** Check whether an unknown value is a valid serialized embed example. */
345
+ declare function isEmbedExample(value: unknown): value is EmbedExample;
346
+ /** Reject malformed host-provided examples before creating an init message. */
347
+ declare function assertEmbedExamples(examples: readonly EmbedExample[] | undefined): void;
348
+ interface MachineInitOptions {
349
+ machine: unknown;
350
+ /** Ephemeral, read-only reference documents owned by the embed host. */
351
+ documents?: EmbedDocument[];
352
+ format?: string;
353
+ extensions?: EmbedExtensionsManifest;
354
+ mode?: EmbedMode;
355
+ theme?: 'light' | 'dark';
356
+ readOnly?: boolean;
357
+ readOnlyReason?: ReadOnlyReason;
358
+ depth?: number;
359
+ capabilities?: EditorCapabilities;
360
+ examples?: readonly EmbedExample[];
361
+ panels?: EmbedPanelConfig[];
362
+ comments?: CommentsConfig;
363
+ sourceLocations?: MachineSourceLocations;
364
+ settings?: Record<string, unknown>;
365
+ /**
366
+ * Show a persistent "Save to apply" pill in the embed whenever Viz has
367
+ * local edits that have not yet been saved. Intended for contexts like
368
+ * editor extensions where Viz edits don't reach the source until the user
369
+ * saves.
370
+ *
371
+ * - `enabled` — whether to show the pill at all. Defaults to `false`.
372
+ * - `mode` — `'structural'` (default) only triggers on graph-structural
373
+ * changes (state/transition/action/invoke/schema edits). Pure visual
374
+ * changes like drag-to-position, color, and layout are ignored.
375
+ * `'all'` triggers on any graph change.
376
+ */
377
+ unsavedIndicator?: {
378
+ enabled?: boolean;
379
+ mode?: 'structural' | 'all';
380
+ };
381
+ /** Omit to disable automatic version requests. */
382
+ versionAutoSave?: MachineVersionAutoSaveOptions;
383
+ }
384
+ interface ProjectInitOptions {
385
+ machines: ProjectEmbedMachine[];
386
+ /** Ephemeral, read-only reference documents shared across the project. */
387
+ documents?: EmbedDocument[];
388
+ currentMachineId?: string;
389
+ mode?: EmbedMode;
390
+ theme?: 'light' | 'dark';
391
+ readOnly?: boolean;
392
+ readOnlyReason?: ReadOnlyReason;
393
+ depth?: number;
394
+ capabilities?: EditorCapabilities;
395
+ examples?: readonly EmbedExample[];
396
+ panels?: EmbedPanelConfig[];
397
+ commentsByMachineId?: Record<string, CommentsConfig>;
398
+ projectWorkspace?: ProjectWorkspaceConfig;
399
+ projectWorkspaceOpen?: boolean;
400
+ settings?: Record<string, unknown>;
401
+ unsavedIndicator?: {
402
+ enabled?: boolean;
403
+ mode?: 'structural' | 'all';
404
+ };
405
+ /** Omit to disable automatic version requests. */
406
+ versionAutoSave?: MachineVersionAutoSaveOptions;
407
+ }
408
+ type InitOptions = MachineInitOptions | ProjectInitOptions;
409
+ interface InitMessage {
410
+ type: '@statelyai.init';
411
+ machine: unknown;
412
+ documents?: EmbedDocument[];
413
+ format?: string;
414
+ extensions?: EmbedExtensionsManifest;
415
+ mode?: EmbedMode;
416
+ theme?: 'light' | 'dark';
417
+ readOnly?: boolean;
418
+ readOnlyReason?: ReadOnlyReason;
419
+ depth?: number;
420
+ capabilities?: EditorCapabilities;
421
+ examples?: readonly EmbedExample[];
422
+ panels?: EmbedPanelConfig[];
423
+ /** @deprecated Use `panels`. */
424
+ leftPanels?: string[];
425
+ /** @deprecated Use `panels`. */
426
+ rightPanels?: string[];
427
+ /** @deprecated Use `panels[].initiallyOpen`. */
428
+ activePanels?: string[];
429
+ comments?: CommentsConfig;
430
+ sourceLocations?: MachineSourceLocations;
431
+ settings?: Record<string, unknown>;
432
+ /** Mirror of `InitOptions.unsavedIndicator`. */
433
+ unsavedIndicator?: {
434
+ enabled?: boolean;
435
+ mode?: 'structural' | 'all';
436
+ };
437
+ versionAutoSave?: MachineVersionAutoSaveOptions;
438
+ }
439
+ interface SetApiKeyMessage {
440
+ type: '@statelyai.setApiKey';
441
+ apiKey: string;
442
+ }
443
+ interface SavedMessage {
444
+ type: '@statelyai.saved';
445
+ requestId?: string;
446
+ graph: unknown;
447
+ }
448
+ interface ClipboardReadResponseMessage {
449
+ type: '@statelyai.clipboardReadResponse';
450
+ requestId: string;
451
+ text: string;
452
+ }
453
+ interface ClipboardWriteResponseMessage {
454
+ type: '@statelyai.clipboardWriteResponse';
455
+ requestId: string;
456
+ ok: boolean;
457
+ }
458
+ interface ClipboardReadMessage {
459
+ type: '@statelyai.clipboardRead';
460
+ requestId: string;
461
+ }
462
+ interface ClipboardWriteMessage {
463
+ type: '@statelyai.clipboardWrite';
464
+ requestId: string;
465
+ text: string;
466
+ }
467
+ interface ProjectInitMessage {
468
+ type: '@statelyai.project.init';
469
+ machines: ProjectEmbedMachine[];
470
+ documents?: EmbedDocument[];
471
+ currentMachineId?: string;
472
+ mode?: EmbedMode;
473
+ theme?: 'light' | 'dark';
474
+ readOnly?: boolean;
475
+ readOnlyReason?: ReadOnlyReason;
476
+ depth?: number;
477
+ capabilities?: EditorCapabilities;
478
+ examples?: readonly EmbedExample[];
479
+ panels?: EmbedPanelConfig[];
480
+ /** @deprecated Use `panels`. */
481
+ leftPanels?: string[];
482
+ /** @deprecated Use `panels`. */
483
+ rightPanels?: string[];
484
+ /** @deprecated Use `panels[].initiallyOpen`. */
485
+ activePanels?: string[];
486
+ commentsByMachineId?: Record<string, CommentsConfig>;
487
+ projectWorkspace?: ProjectWorkspaceConfig;
488
+ projectWorkspaceOpen?: boolean;
489
+ settings?: Record<string, unknown>;
490
+ unsavedIndicator?: {
491
+ enabled?: boolean;
492
+ mode?: 'structural' | 'all';
493
+ };
494
+ versionAutoSave?: MachineVersionAutoSaveOptions;
495
+ sessionId?: string;
496
+ }
497
+ interface ProjectUpdateMessage {
498
+ type: '@statelyai.project.update';
499
+ machines: ProjectEmbedMachine[];
500
+ currentMachineId?: string;
501
+ commentsByMachineId?: Record<string, CommentsConfig>;
502
+ projectWorkspace?: ProjectWorkspaceConfig;
503
+ projectWorkspaceOpen?: boolean;
504
+ }
505
+ interface ProjectSelectMachineMessage {
506
+ type: '@statelyai.project.selectMachine';
507
+ machineId: string;
508
+ }
509
+ interface ProjectSetWorkspaceOpenMessage {
510
+ type: '@statelyai.project.setWorkspaceOpen';
511
+ open: boolean;
512
+ }
513
+ interface UpdateMessage {
514
+ type: '@statelyai.update';
515
+ machine: unknown;
516
+ format?: string;
517
+ sourceLocations?: MachineSourceLocations;
518
+ }
519
+ interface SetModeMessage {
520
+ type: '@statelyai.setMode';
521
+ mode: EmbedMode;
522
+ }
523
+ interface SetThemeMessage {
524
+ type: '@statelyai.setTheme';
525
+ theme: 'light' | 'dark';
526
+ }
527
+ interface SetSettingsMessage {
528
+ type: '@statelyai.setSettings';
529
+ settings: Record<string, unknown>;
530
+ }
531
+ interface RetrieveMessage {
532
+ type: '@statelyai.retrieve';
533
+ requestId: string;
534
+ format: ExportFormat;
535
+ options?: Record<string, unknown>;
536
+ }
537
+ interface ToastMessage {
538
+ type: '@statelyai.toast';
539
+ message: string;
540
+ toastType?: 'success' | 'error' | 'info' | 'warning';
541
+ }
542
+ interface InspectSnapshotMessage {
543
+ type: '@statelyai.inspectSnapshot';
544
+ snapshot: unknown;
545
+ event: unknown | null;
546
+ /** Producer-local actor session id, when this snapshot belongs to an actor. */
547
+ sessionId?: string;
548
+ }
549
+ interface ActorSystemEntry {
550
+ /** XState process-local `actor.sessionId`; pair with relay `producerId`. */
551
+ sessionId: string;
552
+ /** System-local xstate `actor.id`. */
553
+ actorId: string;
554
+ /** Optional readable label; never replaces the runtime actor ID. */
555
+ displayName?: string;
556
+ /** Parent actor's sessionId, or `null` for the root. */
557
+ parentSessionId: string | null;
558
+ /** Machine configuration used to render the state chart. */
559
+ machine: unknown;
560
+ /** Optional current snapshot (`{value, status, ...}`). */
561
+ snapshot?: unknown;
562
+ /** Whether this actor stopped before this checkpoint was sent. */
563
+ stopped?: boolean;
564
+ }
565
+ /** JSON-safe record of an action executed during an inspected transition. */
566
+ interface InspectionAction {
567
+ type: string;
568
+ params?: unknown;
569
+ }
570
+ /** JSON-safe identity of a state transition taken during a macrostep. */
571
+ interface InspectionTakenTransition {
572
+ sourceStateId: string | null;
573
+ targetStateIds: string[];
574
+ eventType?: string;
575
+ reenter?: boolean;
576
+ }
577
+ /** JSON-safe record of an event sent or scheduled during a transition. */
578
+ interface InspectionSentEvent {
579
+ targetSessionId?: string;
580
+ targetId: string;
581
+ event: unknown;
582
+ delay?: number;
583
+ id?: string;
584
+ }
585
+ interface SystemInitMessage {
586
+ type: '@statelyai.system.init';
587
+ protocolVersion: number;
588
+ /** All known actors at the moment the system is first streamed. */
589
+ actors: ActorSystemEntry[];
590
+ /** Actor session id the viz should focus first. Defaults to the root. */
591
+ selectedSessionId?: string;
592
+ documents?: EmbedDocument[];
593
+ mode?: EmbedMode;
594
+ theme?: 'light' | 'dark';
595
+ readOnly?: boolean;
596
+ depth?: number;
597
+ capabilities?: EditorCapabilities;
598
+ panels?: EmbedPanelConfig[];
599
+ /** @deprecated Use `panels`. */
600
+ leftPanels?: string[];
601
+ /** @deprecated Use `panels`. */
602
+ rightPanels?: string[];
603
+ /** @deprecated Use `panels[].initiallyOpen`. */
604
+ activePanels?: string[];
605
+ comments?: CommentsConfig;
606
+ }
607
+ /** Change the focused actor without re-initializing the system. */
608
+ interface SystemSelectActorMessage {
609
+ type: '@statelyai.system.selectActor';
610
+ sessionId: string;
611
+ }
612
+ /** A new actor joined the system after init. */
613
+ interface SystemActorRegisteredMessage {
614
+ type: '@statelyai.system.actorRegistered';
615
+ sessionId: string;
616
+ actorId: string;
617
+ /** Optional readable label; never replaces the runtime actor ID. */
618
+ displayName?: string;
619
+ parentSessionId: string | null;
620
+ machine: unknown;
621
+ snapshot?: unknown;
622
+ }
623
+ /** An event was observed targeting an actor, before processing completed. */
624
+ interface SystemActorEventMessage {
625
+ type: '@statelyai.system.actorEvent';
626
+ sessionId: string;
627
+ event: unknown;
628
+ /** Global session id of the actor that sent the event, if known. */
629
+ sourceSessionId?: string | null;
630
+ }
631
+ /** An actor's snapshot updated. */
632
+ interface SystemActorSnapshotMessage {
633
+ type: '@statelyai.system.actorSnapshot';
634
+ sessionId: string;
635
+ /** Snapshot before the event was processed. */
636
+ previousSnapshot?: unknown | null;
637
+ snapshot: unknown;
638
+ event?: unknown | null;
639
+ /** Global session id of the actor that sent the triggering event, if known. */
640
+ sourceSessionId?: string | null;
641
+ /** Actions executed while processing the event. */
642
+ actions?: InspectionAction[];
643
+ /** State transitions taken across every microstep. */
644
+ transitions?: InspectionTakenTransition[];
645
+ /** Events sent or scheduled while processing the event. */
646
+ sent?: InspectionSentEvent[];
647
+ }
648
+ /** An actor reached a final state / was stopped. */
649
+ interface SystemActorStoppedMessage {
650
+ type: '@statelyai.system.actorStopped';
651
+ sessionId: string;
652
+ }
653
+ interface ReadyMessage {
654
+ type: '@statelyai.ready';
655
+ version: string;
656
+ protocolVersion?: number;
657
+ }
658
+ interface EditorHandshakeMessage {
659
+ type: '@statelyai.handshake';
660
+ protocolVersion: number;
661
+ client?: {
662
+ name: string;
663
+ version: string;
664
+ };
665
+ }
666
+ interface LoadedMessage {
667
+ type: '@statelyai.loaded';
668
+ graph: StatelyGraph;
669
+ machineId?: string;
670
+ sourceLocations?: MachineSourceLocations;
671
+ }
672
+ interface ChangeMessage {
673
+ type: '@statelyai.change';
674
+ graph: StatelyGraph;
675
+ machineConfig: unknown;
676
+ machineId?: string;
677
+ patches?: unknown[];
678
+ sourceLocations?: MachineSourceLocations;
679
+ }
680
+ interface SaveMessage {
681
+ type: '@statelyai.save';
682
+ requestId?: string;
683
+ graph: StatelyGraph;
684
+ machineConfig: unknown;
685
+ machineId?: string;
686
+ patches?: unknown[];
687
+ validations?: ValidationIssue[];
688
+ sourceLocations?: MachineSourceLocations;
689
+ sourceUpdateStrategy?: 'preserve' | 'rewrite';
690
+ }
691
+ interface VersionSaveRequestedMessage {
692
+ type: '@statelyai.versionSaveRequested';
693
+ graph: StatelyGraph;
694
+ machineConfig: unknown;
695
+ machineId?: string;
696
+ patches?: unknown[];
697
+ createdBy: NonNullable<MachineVersionAutoSaveOptions['createdBy']>;
698
+ captureType: string;
699
+ sourceLocations?: MachineSourceLocations;
700
+ }
701
+ interface ProjectMachineSelectedMessage {
702
+ type: '@statelyai.project.machineSelected';
703
+ machineId: string;
704
+ }
705
+ interface ProjectWorkspaceActionMessage {
706
+ type: '@statelyai.project.workspaceAction';
707
+ actionId: string;
708
+ projectId?: string;
709
+ machineId?: string;
710
+ data?: unknown;
711
+ }
712
+ interface ProjectWorkspaceOpenChangedMessage {
713
+ type: '@statelyai.project.workspaceOpenChanged';
714
+ open: boolean;
715
+ }
716
+ interface ViewModeChangedMessage {
717
+ type: '@statelyai.viewModeChanged';
718
+ viewMode: 'graph' | 'list';
719
+ machineId?: string;
720
+ }
721
+ interface PanelChangedMessage {
722
+ type: '@statelyai.panelChanged';
723
+ side: 'left' | 'right' | 'bottom';
724
+ id: string | null;
725
+ activePanels: string[];
726
+ machineId?: string;
727
+ }
728
+ interface ModeChangedMessage {
729
+ type: '@statelyai.modeChanged';
730
+ mode: EmbedMode;
731
+ machineId?: string;
732
+ }
733
+ interface RetrievedMessage {
734
+ type: '@statelyai.retrieved';
735
+ requestId: string;
736
+ data: unknown;
737
+ }
738
+ /**
739
+ * Error codes the editor emits. Open-ended (`string`) so an older SDK keeps
740
+ * forwarding codes a newer editor adds.
741
+ *
742
+ * - `unsupported_protocol` — editor/SDK protocol versions disagree.
743
+ * - `conversion_failed` — a machine source could not be converted to a graph.
744
+ * - `invalid_graph` — a host-supplied graph is structurally invalid; see `details`.
745
+ * - `render_failed` — the editor threw while rendering a machine.
746
+ */
747
+ type ErrorCode = 'unsupported_protocol' | 'conversion_failed' | 'invalid_graph' | 'render_failed' | (string & {});
748
+ interface ErrorMessage {
749
+ type: '@statelyai.error';
750
+ code: ErrorCode;
751
+ message: string;
752
+ /** Machine the error belongs to, when the editor knows which one failed. */
753
+ machineId?: string;
754
+ /** Per-problem explanations, e.g. one line per structural graph error. */
755
+ details?: string[];
756
+ requestId?: string;
757
+ }
758
+ interface CapabilityDeniedMessage extends CapabilityDeniedEvent {
759
+ type: '@statelyai.capabilityDenied';
760
+ }
761
+ /** File metadata sent from viz to SDK when a file needs uploading. */
762
+ interface UploadFileInfo {
763
+ /** Original filename (e.g. "screenshot.png") */
764
+ name: string;
765
+ /** MIME type (e.g. "image/png") */
766
+ mimeType: string;
767
+ /** File size in bytes */
768
+ size: number;
769
+ /** File content as base64-encoded string */
770
+ data: string;
771
+ }
772
+ /** The result the consumer returns after uploading. */
773
+ interface UploadResult {
774
+ /** The publicly accessible URL of the uploaded file */
775
+ url: string;
776
+ /** Optional display name (defaults to original filename) */
777
+ name?: string;
778
+ /** Optional metadata stored on the asset */
779
+ metadata?: Record<string, unknown>;
780
+ }
781
+ /** Viz requests the parent to upload a file. */
782
+ interface UploadRequestMessage {
783
+ type: '@statelyai.uploadRequest';
784
+ requestId: string;
785
+ file: UploadFileInfo;
786
+ stateNodeId: string;
787
+ }
788
+ /** Parent tells the viz the upload capabilities on init. */
789
+ interface UploadCapabilitiesMessage {
790
+ type: '@statelyai.uploadCapabilities';
791
+ enabled: boolean;
792
+ accept?: string[];
793
+ maxFileSize?: number;
794
+ }
795
+ /** Parent sends the upload result back to the viz. */
796
+ interface UploadResponseMessage {
797
+ type: '@statelyai.uploadResponse';
798
+ requestId: string;
799
+ result: UploadResult;
800
+ }
801
+ interface ExtensionCallMessage {
802
+ type: '@statelyai.extension.call';
803
+ requestId: string;
804
+ extensionId: string;
805
+ method: 'detect' | 'import' | 'export' | 'validate';
806
+ payload: unknown;
807
+ }
808
+ interface ExtensionResultMessage {
809
+ type: '@statelyai.extension.result';
810
+ requestId: string;
811
+ result?: unknown;
812
+ error?: string;
813
+ }
814
+ /** All messages a client (embed/inspector) can send to the viz. */
815
+ type ClientMessage = InitMessage | SetApiKeyMessage | EditorHandshakeMessage | SavedMessage | ClipboardReadResponseMessage | ClipboardWriteResponseMessage | ProjectInitMessage | ProjectUpdateMessage | ProjectSelectMachineMessage | ProjectSetWorkspaceOpenMessage | UpdateMessage | SetModeMessage | SetThemeMessage | SetSettingsMessage | RetrieveMessage | ToastMessage | InspectSnapshotMessage | SystemInitMessage | SystemSelectActorMessage | SystemActorRegisteredMessage | SystemActorEventMessage | SystemActorSnapshotMessage | SystemActorStoppedMessage | UploadCapabilitiesMessage | UploadResponseMessage | ExtensionResultMessage | ErrorMessage;
816
+ /** All messages the viz can send back to a client. */
817
+ type VizMessage = ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | VersionSaveRequestedMessage | ProjectMachineSelectedMessage | ProjectWorkspaceActionMessage | ProjectWorkspaceOpenChangedMessage | ViewModeChangedMessage | PanelChangedMessage | ModeChangedMessage | RetrievedMessage | ErrorMessage | CapabilityDeniedMessage | ClipboardReadMessage | ClipboardWriteMessage | UploadRequestMessage | ExtensionCallMessage;
818
+ interface InspectionClientMetadata {
819
+ name?: string;
820
+ machineId?: string;
821
+ sdkVersion?: string;
822
+ runtime?: 'browser' | 'node' | 'unknown';
823
+ }
824
+ interface RegisterMessage {
825
+ type: '@statelyai.register';
826
+ protocolVersion: number;
827
+ role: 'producer' | 'viewer';
828
+ producerId?: string;
829
+ metadata?: InspectionClientMetadata;
830
+ }
831
+ interface RegisteredMessage {
832
+ type: '@statelyai.registered';
833
+ protocolVersion: number;
834
+ producerId?: string;
835
+ }
836
+ /** All registration messages for the WebSocket relay. */
837
+ type SessionMessage = RegisterMessage | RegisteredMessage;
838
+ /** Any valid protocol message. Relays add/consume `producerId` as an envelope. */
839
+ type ProtocolMessage = (ClientMessage | VizMessage | SessionMessage) & {
840
+ producerId?: string;
841
+ };
842
+ declare const PREFIX = "@statelyai.";
843
+ /** Current WebSocket inspection protocol version. */
844
+ declare const INSPECTION_PROTOCOL_VERSION = 2;
845
+ //#endregion
846
+ export { ProjectSelectMachineMessage as $, ExtensionCallMessage as A, SystemActorSnapshotMessage as At, InspectionSentEvent as B, UploadResult as Bt, EmbedFormatManifest as C, SetSettingsMessage as Ct, ExportCallOptions as D, StateSourceLocation as Dt, ErrorMessage as E, SourceRange as Et, InitOptions as F, UpdateMessage as Ft, MachineVersionAutoSaveOptions as G, assertEmbedExamples as Gt, LoadedMessage as H, VersionSaveRequestedMessage as Ht, InspectSnapshotMessage as I, UploadCapabilitiesMessage as It, PanelChangedMessage as J, getInspectionRoomId as Jt, ModeChangedMessage as K, createInspectionActorId as Kt, InspectionAction as L, UploadFileInfo as Lt, INSPECTION_PROTOCOL_VERSION as M, SystemInitMessage as Mt, INSPECTION_ROOM_QUERY_PARAM as N, SystemSelectActorMessage as Nt, ExportFormat as O, SystemActorEventMessage as Ot, InitMessage as P, ToastMessage as Pt, ProjectMachineSelectedMessage as Q, EmbedPanelPosition as Qt, InspectionClientMetadata as R, UploadRequestMessage as Rt, EmbedExtensionsManifest as S, SetModeMessage as St, ErrorCode as T, SourceLocation as Tt, MachineInitOptions as U, ViewModeChangedMessage as Ut, InspectionTakenTransition as V, ValidationIssue as Vt, MachineSourceLocations as W, VizMessage as Wt, ProjectInitMessage as X, isEmbedExampleMachine as Xt, ProjectEmbedMachine as Y, isEmbedExample as Yt, ProjectInitOptions as Z, EmbedPanelConfig as Zt, EmbedDocumentLanguage as _, RetrievedMessage as _t, ChangeMessage as a, ProjectWorkspaceCapabilities as at, EmbedEventName as b, SessionMessage as bt, ClipboardReadResponseMessage as c, ProjectWorkspaceMachineOrigin as ct, CommentsConfig as d, ProtocolMessage as dt, ProjectSetWorkspaceOpenMessage as et, EMBED_DOCUMENT_LANGUAGES as f, ReadOnlyReason as ft, EmbedDocument as g, RetrieveMessage as gt, EditorHandshakeMessage as h, RegisteredMessage as ht, CapabilityDeniedMessage as i, ProjectWorkspaceActionMessage as it, ExtensionResultMessage as j, SystemActorStoppedMessage as jt, ExportFormatMap as k, SystemActorRegisteredMessage as kt, ClipboardWriteMessage as l, ProjectWorkspaceOpenChangedMessage as lt, EditorCapabilities as m, RegisterMessage as mt, CapabilityDeniedCapability as n, ProjectWorkspaceAction as nt, ClientMessage as o, ProjectWorkspaceConfig as ot, EMBED_DOCUMENT_LIMITS as p, ReadyMessage as pt, PREFIX as q, createInspectionRoomUrls as qt, CapabilityDeniedEvent as r, ProjectWorkspaceActionIcon as rt, ClipboardReadMessage as s, ProjectWorkspaceMachine as st, ActorSystemEntry as t, ProjectUpdateMessage as tt, ClipboardWriteResponseMessage as u, ProjectWorkspaceProject as ut, EmbedEventHandler as v, SaveMessage as vt, EmbedMode as w, SetThemeMessage as wt, EmbedExample as x, SetApiKeyMessage as xt, EmbedEventMap as y, SavedMessage as yt, InspectionRoomUrls as z, UploadResponseMessage as zt };