@statelyai/sdk 0.9.1 → 0.10.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 CHANGED
@@ -21,6 +21,6 @@ The broader in-progress package documentation draft is kept in:
21
21
  Published schemas:
22
22
 
23
23
  - `@statelyai/sdk/statelyai.schema.json`
24
- - `@statelyai/sdk/xstate-json.schema.json`
24
+ - `@statelyai/sdk/xstate.schema.json`
25
25
 
26
- The CLI-facing `statelyai.json` schema now uses top-level `include` / `exclude` globs for local file discovery.
26
+ The CLI-facing `statelyai.json` schema now uses top-level `include` / `exclude` globs for local file discovery, plus `newMachineDir` for pulling remote-only project machines into new local files.
@@ -1,5 +1,5 @@
1
1
  //#region src/protocol.d.ts
2
- type EmbedMode = 'editing' | 'viewing' | 'simulating' | 'inspecting';
2
+ type EmbedMode = "editing" | "viewing" | "simulating" | "inspecting";
3
3
  interface CommentsConfig {
4
4
  roomId: string;
5
5
  userId?: string | null;
@@ -15,7 +15,7 @@ interface ProjectEmbedMachine {
15
15
  interface ValidationIssue {
16
16
  nodeIds: string[];
17
17
  edgeIds: string[];
18
- level: 'info' | 'warning' | 'error';
18
+ level: "info" | "warning" | "error";
19
19
  message: string;
20
20
  }
21
21
  interface SourceRange {
@@ -30,12 +30,12 @@ interface SourceLocation {
30
30
  }
31
31
  interface StateSourceLocation extends SourceLocation {
32
32
  path: string[];
33
- kind: 'inline' | 'objectReference' | 'createStateConfig';
33
+ kind: "inline" | "objectReference" | "createStateConfig";
34
34
  symbol?: string;
35
35
  keyRange?: SourceRange;
36
36
  referenceRange?: SourceRange;
37
37
  keySource?: {
38
- kind: 'const' | 'enumMember' | 'computedLiteral';
38
+ kind: "const" | "enumMember" | "computedLiteral";
39
39
  symbol?: string;
40
40
  valueRange?: SourceRange;
41
41
  machineLocal?: boolean;
@@ -60,7 +60,11 @@ interface ExportFormatMap {
60
60
  };
61
61
  result: string;
62
62
  };
63
- 'xstate-json': {
63
+ async: {
64
+ options: object;
65
+ result: string;
66
+ };
67
+ "xstate-json": {
64
68
  options: {
65
69
  version?: 4 | 5;
66
70
  };
@@ -86,11 +90,11 @@ interface ExportFormatMap {
86
90
  options: object;
87
91
  result: string;
88
92
  };
89
- 'asl-json': {
93
+ "asl-json": {
90
94
  options: object;
91
95
  result: string;
92
96
  };
93
- 'asl-yaml': {
97
+ "asl-yaml": {
94
98
  options: object;
95
99
  result: string;
96
100
  };
@@ -100,7 +104,7 @@ interface ExportFormatMap {
100
104
  };
101
105
  }
102
106
  type ExportFormat = keyof ExportFormatMap;
103
- type ExportCallOptions<F extends ExportFormat> = ExportFormatMap[F]['options'] & {
107
+ type ExportCallOptions<F extends ExportFormat> = ExportFormatMap[F]["options"] & {
104
108
  timeout?: number;
105
109
  };
106
110
  interface EmbedEventMap {
@@ -145,7 +149,7 @@ interface MachineInitOptions {
145
149
  machine: unknown;
146
150
  format?: string;
147
151
  mode?: EmbedMode;
148
- theme?: 'light' | 'dark';
152
+ theme?: "light" | "dark";
149
153
  readOnly?: boolean;
150
154
  depth?: number;
151
155
  panels?: {
@@ -169,14 +173,14 @@ interface MachineInitOptions {
169
173
  */
170
174
  unsavedIndicator?: {
171
175
  enabled?: boolean;
172
- mode?: 'structural' | 'all';
176
+ mode?: "structural" | "all";
173
177
  };
174
178
  }
175
179
  interface ProjectInitOptions {
176
180
  machines: ProjectEmbedMachine[];
177
181
  currentMachineId?: string;
178
182
  mode?: EmbedMode;
179
- theme?: 'light' | 'dark';
183
+ theme?: "light" | "dark";
180
184
  readOnly?: boolean;
181
185
  depth?: number;
182
186
  panels?: {
@@ -187,16 +191,16 @@ interface ProjectInitOptions {
187
191
  commentsByMachineId?: Record<string, CommentsConfig>;
188
192
  unsavedIndicator?: {
189
193
  enabled?: boolean;
190
- mode?: 'structural' | 'all';
194
+ mode?: "structural" | "all";
191
195
  };
192
196
  }
193
197
  type InitOptions = MachineInitOptions | ProjectInitOptions;
194
198
  interface InitMessage {
195
- type: '@statelyai.init';
199
+ type: "@statelyai.init";
196
200
  machine: unknown;
197
201
  format?: string;
198
202
  mode?: EmbedMode;
199
- theme?: 'light' | 'dark';
203
+ theme?: "light" | "dark";
200
204
  readOnly?: boolean;
201
205
  depth?: number;
202
206
  leftPanels?: string[];
@@ -207,17 +211,17 @@ interface InitMessage {
207
211
  /** Mirror of `InitOptions.unsavedIndicator`. */
208
212
  unsavedIndicator?: {
209
213
  enabled?: boolean;
210
- mode?: 'structural' | 'all';
214
+ mode?: "structural" | "all";
211
215
  };
212
216
  /** Optional session id override (multiplexed clients only). */
213
217
  sessionId?: string;
214
218
  }
215
219
  interface ProjectInitMessage {
216
- type: '@statelyai.project.init';
220
+ type: "@statelyai.project.init";
217
221
  machines: ProjectEmbedMachine[];
218
222
  currentMachineId?: string;
219
223
  mode?: EmbedMode;
220
- theme?: 'light' | 'dark';
224
+ theme?: "light" | "dark";
221
225
  readOnly?: boolean;
222
226
  depth?: number;
223
227
  leftPanels?: string[];
@@ -226,51 +230,51 @@ interface ProjectInitMessage {
226
230
  commentsByMachineId?: Record<string, CommentsConfig>;
227
231
  unsavedIndicator?: {
228
232
  enabled?: boolean;
229
- mode?: 'structural' | 'all';
233
+ mode?: "structural" | "all";
230
234
  };
231
235
  sessionId?: string;
232
236
  }
233
237
  interface ProjectUpdateMessage {
234
- type: '@statelyai.project.update';
238
+ type: "@statelyai.project.update";
235
239
  machines: ProjectEmbedMachine[];
236
240
  currentMachineId?: string;
237
241
  commentsByMachineId?: Record<string, CommentsConfig>;
238
242
  }
239
243
  interface ProjectSelectMachineMessage {
240
- type: '@statelyai.project.selectMachine';
244
+ type: "@statelyai.project.selectMachine";
241
245
  machineId: string;
242
246
  }
243
247
  interface UpdateMessage {
244
- type: '@statelyai.update';
248
+ type: "@statelyai.update";
245
249
  machine: unknown;
246
250
  format?: string;
247
251
  sourceLocations?: MachineSourceLocations;
248
252
  }
249
253
  interface SetModeMessage {
250
- type: '@statelyai.setMode';
254
+ type: "@statelyai.setMode";
251
255
  mode: EmbedMode;
252
256
  }
253
257
  interface SetThemeMessage {
254
- type: '@statelyai.setTheme';
255
- theme: 'light' | 'dark';
258
+ type: "@statelyai.setTheme";
259
+ theme: "light" | "dark";
256
260
  }
257
261
  interface SetSettingsMessage {
258
- type: '@statelyai.setSettings';
262
+ type: "@statelyai.setSettings";
259
263
  settings: Record<string, unknown>;
260
264
  }
261
265
  interface RetrieveMessage {
262
- type: '@statelyai.retrieve';
266
+ type: "@statelyai.retrieve";
263
267
  requestId: string;
264
268
  format: ExportFormat;
265
269
  options?: Record<string, unknown>;
266
270
  }
267
271
  interface ToastMessage {
268
- type: '@statelyai.toast';
272
+ type: "@statelyai.toast";
269
273
  message: string;
270
- toastType?: 'success' | 'error' | 'info' | 'warning';
274
+ toastType?: "success" | "error" | "info" | "warning";
271
275
  }
272
276
  interface InspectSnapshotMessage {
273
- type: '@statelyai.inspectSnapshot';
277
+ type: "@statelyai.inspectSnapshot";
274
278
  snapshot: unknown;
275
279
  event: unknown | null;
276
280
  /**
@@ -293,13 +297,13 @@ interface ActorSystemEntry {
293
297
  snapshot?: unknown;
294
298
  }
295
299
  interface SystemInitMessage {
296
- type: '@statelyai.system.init';
300
+ type: "@statelyai.system.init";
297
301
  /** All known actors at the moment the system is first streamed. */
298
302
  actors: ActorSystemEntry[];
299
303
  /** Actor id the viz should focus first. Defaults to the root. */
300
304
  selectedActorId?: string;
301
305
  mode?: EmbedMode;
302
- theme?: 'light' | 'dark';
306
+ theme?: "light" | "dark";
303
307
  readOnly?: boolean;
304
308
  depth?: number;
305
309
  leftPanels?: string[];
@@ -309,7 +313,7 @@ interface SystemInitMessage {
309
313
  }
310
314
  /** A new actor joined the system after init. */
311
315
  interface SystemActorRegisteredMessage {
312
- type: '@statelyai.system.actorRegistered';
316
+ type: "@statelyai.system.actorRegistered";
313
317
  actorId: string;
314
318
  parentActorId: string | null;
315
319
  id: string;
@@ -318,7 +322,7 @@ interface SystemActorRegisteredMessage {
318
322
  }
319
323
  /** An actor's snapshot updated. */
320
324
  interface SystemActorSnapshotMessage {
321
- type: '@statelyai.system.actorSnapshot';
325
+ type: "@statelyai.system.actorSnapshot";
322
326
  actorId: string;
323
327
  snapshot: unknown;
324
328
  event?: unknown | null;
@@ -327,21 +331,21 @@ interface SystemActorSnapshotMessage {
327
331
  }
328
332
  /** An actor reached a final state / was stopped. */
329
333
  interface SystemActorStoppedMessage {
330
- type: '@statelyai.system.actorStopped';
334
+ type: "@statelyai.system.actorStopped";
331
335
  actorId: string;
332
336
  }
333
337
  interface ReadyMessage {
334
- type: '@statelyai.ready';
338
+ type: "@statelyai.ready";
335
339
  version: string;
336
340
  }
337
341
  interface LoadedMessage {
338
- type: '@statelyai.loaded';
342
+ type: "@statelyai.loaded";
339
343
  graph: unknown;
340
344
  machineId?: string;
341
345
  sourceLocations?: MachineSourceLocations;
342
346
  }
343
347
  interface ChangeMessage {
344
- type: '@statelyai.change';
348
+ type: "@statelyai.change";
345
349
  graph: unknown;
346
350
  machineConfig: unknown;
347
351
  machineId?: string;
@@ -349,7 +353,7 @@ interface ChangeMessage {
349
353
  sourceLocations?: MachineSourceLocations;
350
354
  }
351
355
  interface SaveMessage {
352
- type: '@statelyai.save';
356
+ type: "@statelyai.save";
353
357
  graph: unknown;
354
358
  machineConfig: unknown;
355
359
  machineId?: string;
@@ -358,16 +362,16 @@ interface SaveMessage {
358
362
  sourceLocations?: MachineSourceLocations;
359
363
  }
360
364
  interface ProjectMachineSelectedMessage {
361
- type: '@statelyai.project.machineSelected';
365
+ type: "@statelyai.project.machineSelected";
362
366
  machineId: string;
363
367
  }
364
368
  interface RetrievedMessage {
365
- type: '@statelyai.retrieved';
369
+ type: "@statelyai.retrieved";
366
370
  requestId: string;
367
371
  data: unknown;
368
372
  }
369
373
  interface ErrorMessage {
370
- type: '@statelyai.error';
374
+ type: "@statelyai.error";
371
375
  code: string;
372
376
  message: string;
373
377
  requestId?: string;
@@ -394,21 +398,21 @@ interface UploadResult {
394
398
  }
395
399
  /** Viz requests the parent to upload a file. */
396
400
  interface UploadRequestMessage {
397
- type: '@statelyai.uploadRequest';
401
+ type: "@statelyai.uploadRequest";
398
402
  requestId: string;
399
403
  file: UploadFileInfo;
400
404
  stateNodeId: string;
401
405
  }
402
406
  /** Parent tells the viz the upload capabilities on init. */
403
407
  interface UploadCapabilitiesMessage {
404
- type: '@statelyai.uploadCapabilities';
408
+ type: "@statelyai.uploadCapabilities";
405
409
  enabled: boolean;
406
410
  accept?: string[];
407
411
  maxFileSize?: number;
408
412
  }
409
413
  /** Parent sends the upload result back to the viz. */
410
414
  interface UploadResponseMessage {
411
- type: '@statelyai.uploadResponse';
415
+ type: "@statelyai.uploadResponse";
412
416
  requestId: string;
413
417
  result: UploadResult;
414
418
  }
@@ -417,8 +421,8 @@ type ClientMessage = InitMessage | ProjectInitMessage | ProjectUpdateMessage | P
417
421
  /** All messages the viz can send back to a client. */
418
422
  type VizMessage = ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | ProjectMachineSelectedMessage | RetrievedMessage | ErrorMessage | UploadRequestMessage;
419
423
  interface RegisterMessage {
420
- type: '@statelyai.register';
421
- role: 'client' | 'viz';
424
+ type: "@statelyai.register";
425
+ role: "client" | "viz";
422
426
  sessionId: string;
423
427
  metadata?: {
424
428
  name?: string;
@@ -426,11 +430,11 @@ interface RegisterMessage {
426
430
  };
427
431
  }
428
432
  interface RegisteredMessage {
429
- type: '@statelyai.registered';
433
+ type: "@statelyai.registered";
430
434
  sessionId: string;
431
435
  }
432
436
  interface RequestOpenMessage {
433
- type: '@statelyai.requestOpen';
437
+ type: "@statelyai.requestOpen";
434
438
  sessionId: string;
435
439
  }
436
440
  /**
@@ -445,7 +449,7 @@ interface RequestOpenMessage {
445
449
  * the root to target a specific session (falls back to primary).
446
450
  */
447
451
  interface AddSessionMessage {
448
- type: '@statelyai.addSession';
452
+ type: "@statelyai.addSession";
449
453
  sessionId: string;
450
454
  metadata?: {
451
455
  name?: string;
@@ -454,7 +458,7 @@ interface AddSessionMessage {
454
458
  }
455
459
  /** Relay → client: acknowledgement that a session was added. */
456
460
  interface SessionAddedMessage {
457
- type: '@statelyai.sessionAdded';
461
+ type: "@statelyai.sessionAdded";
458
462
  sessionId: string;
459
463
  }
460
464
  /** All session-management messages for the WS relay. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statelyai/sdk",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist",
@@ -52,8 +52,10 @@
52
52
  },
53
53
  "./statelyai.schema.json": "./schemas/statelyai.schema.json",
54
54
  "./schemas/statelyai.schema.json": "./schemas/statelyai.schema.json",
55
- "./xstate-json.schema.json": "./schemas/xstate-json.schema.json",
56
- "./schemas/xstate-json.schema.json": "./schemas/xstate-json.schema.json"
55
+ "./xstate.schema.json": "./schemas/xstate.schema.json",
56
+ "./schemas/xstate.schema.json": "./schemas/xstate.schema.json",
57
+ "./xstate-json.schema.json": "./schemas/xstate.schema.json",
58
+ "./schemas/xstate-json.schema.json": "./schemas/xstate.schema.json"
57
59
  },
58
60
  "dependencies": {
59
61
  "@statelyai/graph": "^0.9.0",
@@ -46,6 +46,11 @@
46
46
  "items": {
47
47
  "$ref": "#/$defs/globPattern"
48
48
  }
49
+ },
50
+ "newMachineDir": {
51
+ "type": "string",
52
+ "minLength": 1,
53
+ "description": "Directory, relative to statelyai.json, where statelyai pull should create new local files for remote-only project machines."
49
54
  }
50
55
  },
51
56
  "$defs": {
@@ -63,7 +68,8 @@
63
68
  "studioUrl": "https://stately.ai",
64
69
  "defaultXStateVersion": 5,
65
70
  "include": ["src/**/*.ts", "src/**/*.tsx"],
66
- "exclude": ["**/*.test.ts", "**/*.spec.ts"]
71
+ "exclude": ["**/*.test.ts", "**/*.spec.ts"],
72
+ "newMachineDir": "src/machines"
67
73
  }
68
74
  ]
69
75
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://stately.ai/schemas/xstate-json.json",
3
+ "$id": "https://stately.ai/schemas/xstate.json",
4
4
  "title": "XState JSON machine config",
5
5
  "description": "Strict JSON subset of an XState machine config that can be passed to createMachine(config). Shorthand string forms are normalized to object and array forms.",
6
6
  "$ref": "#/$defs/machineConfig",