@statelyai/sdk 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -7
- package/dist/embed.d.mts +43 -0
- package/dist/embed.mjs +175 -0
- package/dist/graph-BTUkUCsl.d.mts +393 -0
- package/dist/graph.d.mts +2 -0
- package/dist/graph.mjs +344 -0
- package/dist/index.d.mts +7 -42
- package/dist/index.mjs +6 -162
- package/dist/inspect.d.mts +45 -2
- package/dist/inspect.mjs +121 -2
- package/dist/{inspect-Bt5Ohkrp.d.mts → protocol-DTIQmjHH.d.mts} +4 -46
- package/dist/studio.d.mts +54 -0
- package/dist/studio.mjs +62 -0
- package/dist/sync.d.mts +43 -0
- package/dist/sync.mjs +558 -0
- package/dist/{inspect-C3Rjgn1o.mjs → transport-D352iKKa.mjs} +1 -120
- package/package.json +21 -1
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import * as _statelyai_graph0 from "@statelyai/graph";
|
|
2
|
+
import { Graph } from "@statelyai/graph";
|
|
3
|
+
|
|
4
|
+
//#region src/digraphTypes.d.ts
|
|
5
|
+
type CanvasColor = undefined | 'green' | 'red' | 'purple' | 'blue' | 'orange' | 'yellow' | 'pink' | 'teal';
|
|
6
|
+
type ExtractorGuard = {
|
|
7
|
+
kind: 'inline' | 'named';
|
|
8
|
+
type: string;
|
|
9
|
+
params: JsonObject;
|
|
10
|
+
};
|
|
11
|
+
interface DigraphNodeInvokeData {
|
|
12
|
+
src: string;
|
|
13
|
+
id: string;
|
|
14
|
+
input: Record<string, any> | undefined;
|
|
15
|
+
settings: Record<string, any>;
|
|
16
|
+
kind: 'inline' | 'named';
|
|
17
|
+
}
|
|
18
|
+
interface DigraphEdgeData {
|
|
19
|
+
eventTypeData: EventTypeData;
|
|
20
|
+
guard?: ExtractorGuard;
|
|
21
|
+
transitions?: DigraphEdgeTransition[];
|
|
22
|
+
actions: DigraphAction[];
|
|
23
|
+
description?: string;
|
|
24
|
+
internal?: boolean | undefined;
|
|
25
|
+
metaEntries?: [key: string, value: any][] | undefined;
|
|
26
|
+
color?: CanvasColor;
|
|
27
|
+
}
|
|
28
|
+
type InvocationEventTypeData = {
|
|
29
|
+
type: 'invocation.done';
|
|
30
|
+
invocationId: string;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'invocation.error';
|
|
33
|
+
invocationId: string;
|
|
34
|
+
};
|
|
35
|
+
type EventTypeData = {
|
|
36
|
+
type: 'after';
|
|
37
|
+
delay: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: 'named';
|
|
40
|
+
eventType: string;
|
|
41
|
+
} | InvocationEventTypeData | {
|
|
42
|
+
type: 'state.done';
|
|
43
|
+
} | {
|
|
44
|
+
type: 'always';
|
|
45
|
+
} | {
|
|
46
|
+
type: 'wildcard';
|
|
47
|
+
} | {
|
|
48
|
+
type: 'init';
|
|
49
|
+
};
|
|
50
|
+
interface DigraphEdgeTransition {
|
|
51
|
+
internal: boolean | undefined;
|
|
52
|
+
actions: Array<DigraphAction>;
|
|
53
|
+
cond?: ExtractorGuard;
|
|
54
|
+
description?: string;
|
|
55
|
+
target: string;
|
|
56
|
+
color?: CanvasColor;
|
|
57
|
+
size?: {
|
|
58
|
+
width: number;
|
|
59
|
+
height: number;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
interface Point {
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
}
|
|
66
|
+
interface DigraphEdgeConfig {
|
|
67
|
+
id: string;
|
|
68
|
+
uniqueId?: string;
|
|
69
|
+
data: DigraphEdgeData;
|
|
70
|
+
source: string;
|
|
71
|
+
target: string | undefined;
|
|
72
|
+
position?: Point;
|
|
73
|
+
size?: {
|
|
74
|
+
height: number;
|
|
75
|
+
width: number;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
interface DigraphNodeConfig {
|
|
79
|
+
id: string;
|
|
80
|
+
uniqueId?: string;
|
|
81
|
+
position?: Point;
|
|
82
|
+
size?: {
|
|
83
|
+
height: number;
|
|
84
|
+
width: number;
|
|
85
|
+
};
|
|
86
|
+
data: StateNodeJSONData;
|
|
87
|
+
nodes: DigraphNodeConfig[];
|
|
88
|
+
}
|
|
89
|
+
type JsonObject = {
|
|
90
|
+
[key: string]: JsonItem;
|
|
91
|
+
};
|
|
92
|
+
type JsonItem = string | number | boolean | null | JsonObject | JsonItem[];
|
|
93
|
+
type JsonExpressionString = `{{${string}}}`;
|
|
94
|
+
type SimpleJsonSchemaObject = {
|
|
95
|
+
type: 'object';
|
|
96
|
+
properties: Record<string, SimpleJsonSchema>;
|
|
97
|
+
required?: string[];
|
|
98
|
+
additionalProperties?: boolean;
|
|
99
|
+
description?: string;
|
|
100
|
+
};
|
|
101
|
+
type SimpleJsonSchemaArray = {
|
|
102
|
+
type: 'array';
|
|
103
|
+
items?: SimpleJsonSchema;
|
|
104
|
+
additionalProperties?: boolean;
|
|
105
|
+
description?: string;
|
|
106
|
+
};
|
|
107
|
+
type SimpleJsonSchema = ({
|
|
108
|
+
type: 'string';
|
|
109
|
+
const?: string;
|
|
110
|
+
} | {
|
|
111
|
+
type: 'number';
|
|
112
|
+
const?: number;
|
|
113
|
+
} | {
|
|
114
|
+
type: 'boolean';
|
|
115
|
+
const?: boolean;
|
|
116
|
+
} | {
|
|
117
|
+
type: 'null';
|
|
118
|
+
const?: null;
|
|
119
|
+
} | SimpleJsonSchemaArray | SimpleJsonSchemaObject) & {
|
|
120
|
+
description?: string;
|
|
121
|
+
};
|
|
122
|
+
interface ActionSource {
|
|
123
|
+
type: 'action';
|
|
124
|
+
id: string;
|
|
125
|
+
name: string;
|
|
126
|
+
description?: string;
|
|
127
|
+
icon?: string;
|
|
128
|
+
lang?: 'js';
|
|
129
|
+
imports: {
|
|
130
|
+
modulePath: string;
|
|
131
|
+
variables: string[];
|
|
132
|
+
defaultVariable?: string;
|
|
133
|
+
}[];
|
|
134
|
+
code: string | undefined;
|
|
135
|
+
paramsSchema?: {
|
|
136
|
+
type: 'object';
|
|
137
|
+
properties: Record<string, any>;
|
|
138
|
+
} | undefined;
|
|
139
|
+
}
|
|
140
|
+
interface ActorSource {
|
|
141
|
+
type: 'actor';
|
|
142
|
+
id: string;
|
|
143
|
+
name: string;
|
|
144
|
+
description?: string;
|
|
145
|
+
icon?: string;
|
|
146
|
+
lang?: 'js';
|
|
147
|
+
imports: {
|
|
148
|
+
modulePath: string;
|
|
149
|
+
variables: string[];
|
|
150
|
+
defaultVariable?: string;
|
|
151
|
+
}[];
|
|
152
|
+
code: string | undefined;
|
|
153
|
+
machineId?: string;
|
|
154
|
+
kind: DigraphNodeInvokeData['kind'];
|
|
155
|
+
inputSchema?: {
|
|
156
|
+
type: 'object';
|
|
157
|
+
properties: Record<string, any>;
|
|
158
|
+
required?: string[];
|
|
159
|
+
};
|
|
160
|
+
outputSchema?: {
|
|
161
|
+
type: 'object';
|
|
162
|
+
properties: Record<string, any>;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
interface GuardSource {
|
|
166
|
+
type: 'guard';
|
|
167
|
+
id: string;
|
|
168
|
+
name: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
icon?: string;
|
|
171
|
+
lang?: 'js';
|
|
172
|
+
imports: {
|
|
173
|
+
modulePath: string;
|
|
174
|
+
variables: string[];
|
|
175
|
+
defaultVariable?: string;
|
|
176
|
+
}[];
|
|
177
|
+
code: string | undefined;
|
|
178
|
+
paramsSchema?: {
|
|
179
|
+
type: 'object';
|
|
180
|
+
properties: Record<string, any>;
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
interface DigraphData {
|
|
184
|
+
name: string;
|
|
185
|
+
context: Record<string, JsonItem> | JsonExpressionString;
|
|
186
|
+
schemas: {
|
|
187
|
+
input: SimpleJsonSchema | null;
|
|
188
|
+
output: SimpleJsonSchema | null;
|
|
189
|
+
context: Record<string, SimpleJsonSchema>;
|
|
190
|
+
events: Record<string, SimpleJsonSchemaObject>;
|
|
191
|
+
actions: Record<string, SimpleJsonSchemaObject>;
|
|
192
|
+
guards: Record<string, SimpleJsonSchemaObject>;
|
|
193
|
+
actors: Record<string, SimpleJsonSchemaObject>;
|
|
194
|
+
tags: Record<string, SimpleJsonSchema>;
|
|
195
|
+
delays: Record<string, SimpleJsonSchema>;
|
|
196
|
+
};
|
|
197
|
+
implementations: {
|
|
198
|
+
actions: Record<string, ActionSource>;
|
|
199
|
+
actors: Record<string, ActorSource>;
|
|
200
|
+
guards: Record<string, GuardSource>;
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
interface DigraphConfig {
|
|
204
|
+
id: string;
|
|
205
|
+
rootNode: DigraphNodeConfig;
|
|
206
|
+
edges: DigraphEdgeConfig[];
|
|
207
|
+
context: Record<string, JsonItem> | JsonExpressionString;
|
|
208
|
+
schemas?: DigraphData['schemas'];
|
|
209
|
+
originalCode?: string;
|
|
210
|
+
implementations?: DigraphData['implementations'];
|
|
211
|
+
}
|
|
212
|
+
type BaseBuiltinAction<P extends object> = {
|
|
213
|
+
kind: 'builtin';
|
|
214
|
+
action: {
|
|
215
|
+
type: string;
|
|
216
|
+
} & P;
|
|
217
|
+
};
|
|
218
|
+
type DigraphAssignAction = BaseBuiltinAction<{
|
|
219
|
+
assignment: Record<string, JsonItem | JsonExpressionString> | JsonExpressionString;
|
|
220
|
+
}>;
|
|
221
|
+
type DigraphRaiseAction = BaseBuiltinAction<{
|
|
222
|
+
event: Record<string, JsonItem> | JsonExpressionString;
|
|
223
|
+
}>;
|
|
224
|
+
type DigraphLogAction = BaseBuiltinAction<{
|
|
225
|
+
expr: string | JsonExpressionString;
|
|
226
|
+
label?: string;
|
|
227
|
+
}>;
|
|
228
|
+
type DigraphSendToAction = BaseBuiltinAction<{
|
|
229
|
+
event: JsonExpressionString | Record<string, JsonItem>;
|
|
230
|
+
to: string | JsonExpressionString;
|
|
231
|
+
id?: string | JsonExpressionString;
|
|
232
|
+
delay?: string | number | JsonExpressionString;
|
|
233
|
+
}>;
|
|
234
|
+
type DigraphStopAction = BaseBuiltinAction<{
|
|
235
|
+
id: string | JsonExpressionString;
|
|
236
|
+
}>;
|
|
237
|
+
type DigraphNamedAction = {
|
|
238
|
+
kind: 'named';
|
|
239
|
+
action: {
|
|
240
|
+
type: string;
|
|
241
|
+
params?: JsonObject;
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
type DigraphInlineAction = {
|
|
245
|
+
kind: 'inline';
|
|
246
|
+
action: {
|
|
247
|
+
expr: JsonExpressionString;
|
|
248
|
+
__tempStatelyChooseConds?: {
|
|
249
|
+
actions: any[];
|
|
250
|
+
cond?: string;
|
|
251
|
+
}[];
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
type DigraphBuiltinAction = DigraphAssignAction | DigraphRaiseAction | DigraphLogAction | DigraphSendToAction | DigraphStopAction;
|
|
255
|
+
type DigraphAction = DigraphNamedAction | DigraphInlineAction | DigraphBuiltinAction;
|
|
256
|
+
type AssetTemplate = '@stately.image' | '@figma.link' | '@stately.video' | '@stately.pdf' | '@stately.text' | '@stately.unknown';
|
|
257
|
+
type AssetSize = 'sm' | 'md' | 'lg' | 'xl';
|
|
258
|
+
interface AssetProperties {
|
|
259
|
+
uuid: string;
|
|
260
|
+
url: string;
|
|
261
|
+
}
|
|
262
|
+
type DigraphAssetProperties<T extends AssetTemplate> = T extends '@stately.image' ? AssetProperties & {
|
|
263
|
+
size: AssetSize;
|
|
264
|
+
path: string;
|
|
265
|
+
} : T extends '@figma.link' ? AssetProperties & {
|
|
266
|
+
size: AssetSize;
|
|
267
|
+
fileId: string;
|
|
268
|
+
nodeId: string;
|
|
269
|
+
lastRefreshed: number;
|
|
270
|
+
} : AssetProperties;
|
|
271
|
+
type DigraphAssetInternal<T extends AssetTemplate> = {
|
|
272
|
+
name: string;
|
|
273
|
+
template: T;
|
|
274
|
+
properties: DigraphAssetProperties<T>;
|
|
275
|
+
};
|
|
276
|
+
type DigraphAsset = AssetTemplate extends infer Template ? Template extends AssetTemplate ? DigraphAssetInternal<Template> : never : never;
|
|
277
|
+
interface StateNodeJSONData {
|
|
278
|
+
key: string;
|
|
279
|
+
type?: 'parallel' | 'final' | 'history' | 'annotation';
|
|
280
|
+
history?: 'shallow' | 'deep';
|
|
281
|
+
order?: number;
|
|
282
|
+
meta?: any;
|
|
283
|
+
metaEntries?: [key: string, value: any][];
|
|
284
|
+
entry: DigraphAction[];
|
|
285
|
+
exit: DigraphAction[];
|
|
286
|
+
invoke: DigraphNodeInvokeData[];
|
|
287
|
+
initial?: string;
|
|
288
|
+
data?: any;
|
|
289
|
+
tags: string[];
|
|
290
|
+
description?: string;
|
|
291
|
+
color?: CanvasColor;
|
|
292
|
+
blockFlowDirection?: 'horizontal' | undefined;
|
|
293
|
+
assets?: DigraphAsset[];
|
|
294
|
+
}
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region src/graph.d.ts
|
|
297
|
+
interface StatelyAction {
|
|
298
|
+
type: string;
|
|
299
|
+
params?: Record<string, unknown>;
|
|
300
|
+
}
|
|
301
|
+
interface StatelyGuard {
|
|
302
|
+
type: string;
|
|
303
|
+
params?: Record<string, unknown>;
|
|
304
|
+
code?: string;
|
|
305
|
+
}
|
|
306
|
+
interface StatelyInvoke {
|
|
307
|
+
src: string;
|
|
308
|
+
id: string;
|
|
309
|
+
input?: Record<string, unknown>;
|
|
310
|
+
}
|
|
311
|
+
interface StatelyNodeData {
|
|
312
|
+
key: string;
|
|
313
|
+
type?: 'parallel' | 'final' | 'history';
|
|
314
|
+
initialId?: string | null;
|
|
315
|
+
history?: 'shallow' | 'deep' | boolean;
|
|
316
|
+
entry?: StatelyAction[];
|
|
317
|
+
exit?: StatelyAction[];
|
|
318
|
+
invokes?: StatelyInvoke[];
|
|
319
|
+
tags?: string[];
|
|
320
|
+
description?: string;
|
|
321
|
+
color?: string;
|
|
322
|
+
meta?: Record<string, unknown>;
|
|
323
|
+
}
|
|
324
|
+
interface StatelyEdgeData {
|
|
325
|
+
eventType: string;
|
|
326
|
+
transitionType?: 'normal' | 'targetless' | 'reenter';
|
|
327
|
+
guard?: StatelyGuard | null;
|
|
328
|
+
actions?: StatelyAction[];
|
|
329
|
+
description?: string | null;
|
|
330
|
+
color?: string;
|
|
331
|
+
meta?: Record<string, unknown> | null;
|
|
332
|
+
}
|
|
333
|
+
interface StatelyGraphData {
|
|
334
|
+
schemas?: {
|
|
335
|
+
context?: Record<string, SimpleJsonSchema> | null;
|
|
336
|
+
events?: Record<string, SimpleJsonSchemaObject> | null;
|
|
337
|
+
input?: SimpleJsonSchema | null;
|
|
338
|
+
output?: SimpleJsonSchema | null;
|
|
339
|
+
actions?: Record<string, SimpleJsonSchemaObject> | null;
|
|
340
|
+
guards?: Record<string, SimpleJsonSchemaObject> | null;
|
|
341
|
+
actors?: Record<string, SimpleJsonSchemaObject> | null;
|
|
342
|
+
tags?: Record<string, SimpleJsonSchema> | null;
|
|
343
|
+
delays?: Record<string, SimpleJsonSchema> | null;
|
|
344
|
+
};
|
|
345
|
+
implementations?: {
|
|
346
|
+
actions: StatelyImplementation[];
|
|
347
|
+
guards: StatelyImplementation[];
|
|
348
|
+
actors: StatelyActorImplementation[];
|
|
349
|
+
delays: StatelyImplementation[];
|
|
350
|
+
tags: StatelyTagImplementation[];
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
interface StatelyImplementation {
|
|
354
|
+
id: string;
|
|
355
|
+
name: string;
|
|
356
|
+
description?: string | null;
|
|
357
|
+
icon?: string;
|
|
358
|
+
paramsSchema?: SimpleJsonSchemaObject | null;
|
|
359
|
+
code?: {
|
|
360
|
+
body: string;
|
|
361
|
+
lang?: 'js';
|
|
362
|
+
} | null;
|
|
363
|
+
}
|
|
364
|
+
interface StatelyActorImplementation {
|
|
365
|
+
id: string;
|
|
366
|
+
name: string;
|
|
367
|
+
description?: string | null;
|
|
368
|
+
icon?: string;
|
|
369
|
+
inputSchema?: SimpleJsonSchemaObject | null;
|
|
370
|
+
outputSchema?: SimpleJsonSchemaObject | null;
|
|
371
|
+
code?: {
|
|
372
|
+
body: string;
|
|
373
|
+
lang?: 'js';
|
|
374
|
+
} | null;
|
|
375
|
+
}
|
|
376
|
+
interface StatelyTagImplementation {
|
|
377
|
+
id: string;
|
|
378
|
+
name: string;
|
|
379
|
+
description?: string | null;
|
|
380
|
+
icon?: string;
|
|
381
|
+
color?: string;
|
|
382
|
+
}
|
|
383
|
+
type StatelyGraph = Graph<StatelyNodeData, StatelyEdgeData, StatelyGraphData>;
|
|
384
|
+
type StudioMachine = DigraphConfig;
|
|
385
|
+
type StudioNode = DigraphNodeConfig;
|
|
386
|
+
type StudioEdge = DigraphEdgeConfig;
|
|
387
|
+
type StudioAction = DigraphAction;
|
|
388
|
+
type StudioEventTypeData = EventTypeData;
|
|
389
|
+
declare function toStudioMachine(graph: StatelyGraph): StudioMachine;
|
|
390
|
+
declare function fromStudioMachine(studioMachine: StudioMachine): StatelyGraph;
|
|
391
|
+
declare const studioMachineConverter: _statelyai_graph0.GraphFormatConverter<DigraphConfig>;
|
|
392
|
+
//#endregion
|
|
393
|
+
export { EventTypeData as C, DigraphNodeConfig as S, studioMachineConverter as _, StatelyGraphData as a, DigraphConfig as b, StatelyInvoke as c, StudioAction as d, StudioEdge as f, fromStudioMachine as g, StudioNode as h, StatelyGraph as i, StatelyNodeData as l, StudioMachine as m, StatelyActorImplementation as n, StatelyGuard as o, StudioEventTypeData as p, StatelyEdgeData as r, StatelyImplementation as s, StatelyAction as t, StatelyTagImplementation as u, toStudioMachine as v, StateNodeJSONData as w, DigraphEdgeConfig as x, DigraphAction as y };
|
package/dist/graph.d.mts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as studioMachineConverter, a as StatelyGraphData, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, n as StatelyActorImplementation, o as StatelyGuard, p as StudioEventTypeData, r as StatelyEdgeData, s as StatelyImplementation, t as StatelyAction, u as StatelyTagImplementation, v as toStudioMachine } from "./graph-BTUkUCsl.mjs";
|
|
2
|
+
export { StatelyAction, StatelyActorImplementation, StatelyEdgeData, StatelyGraph, StatelyGraphData, StatelyGuard, StatelyImplementation, StatelyInvoke, StatelyNodeData, StatelyTagImplementation, StudioAction, StudioEdge, StudioEventTypeData, StudioMachine, StudioNode, fromStudioMachine, studioMachineConverter, toStudioMachine };
|