@statelyai/sdk 0.15.0 → 0.16.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 +45 -8
- package/dist/bin.d.mts +1 -0
- package/dist/bin.mjs +35 -0
- package/dist/embed.mjs +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{inspect-DenVP7IE.d.mts → inspect-BScvqVcM.d.mts} +56 -64
- package/dist/{inspect-DWDTNMEc.mjs → inspect-C3Y_o_Np.mjs} +123 -73
- package/dist/inspect.d.mts +1 -1
- package/dist/inspect.mjs +1 -1
- package/dist/node-relay.d.mts +22 -0
- package/dist/node-relay.mjs +84 -0
- package/dist/protocol.d.mts +108 -118
- package/dist/protocol.mjs +33 -2
- package/dist/relay.d.mts +10 -11
- package/dist/relay.mjs +83 -62
- package/dist/studio.d.mts +1 -1
- package/dist/sync.d.mts +1 -1
- package/dist/{transport-D2Ud05yg.mjs → transport-B_ig9Znn.mjs} +56 -198
- package/package.json +15 -4
- /package/dist/{studio-Da5pyxv6.d.mts → studio-Bk_u41gu.d.mts} +0 -0
package/README.md
CHANGED
|
@@ -153,15 +153,14 @@ Resource operations always require a credential.
|
|
|
153
153
|
|
|
154
154
|
<!-- createInspector API from src/inspect.ts -->
|
|
155
155
|
|
|
156
|
-
Stream live actor-system state to the Stately inspector
|
|
156
|
+
Stream live actor-system state to the hosted Stately inspector. Zero-config
|
|
157
|
+
inspection needs no API key or local relay.
|
|
157
158
|
|
|
158
159
|
```ts
|
|
159
160
|
import { createActor } from 'xstate';
|
|
160
161
|
import { createInspector } from '@statelyai/sdk';
|
|
161
162
|
|
|
162
|
-
const inspector = createInspector(
|
|
163
|
-
url: 'ws://localhost:4242',
|
|
164
|
-
});
|
|
163
|
+
const inspector = createInspector();
|
|
165
164
|
const { inspect } = inspector;
|
|
166
165
|
|
|
167
166
|
const actor = createActor(machine, { inspect });
|
|
@@ -176,13 +175,35 @@ completed request-scoped runs stay available for inspection.
|
|
|
176
175
|
|
|
177
176
|
XState v5 and v6 inspection events normalize to independent actor, event,
|
|
178
177
|
snapshot, and stop observations before crossing the WebSocket protocol.
|
|
178
|
+
`actorId` is system-local; `sessionId` is globally unique.
|
|
179
179
|
Observations captured before the first transport registration replay in order
|
|
180
180
|
after the initial actor-tree baseline. Reconnects use the latest checkpoint.
|
|
181
181
|
In Node, the inspector opens in the default browser automatically. The SDK
|
|
182
|
-
generates a
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
connects to `wss://sky.stately.ai` and generates a UUID v4 `?r=` room bearer
|
|
183
|
+
capability. Multiple producers and viewers can share that room. Anyone with the
|
|
184
|
+
URL can inspect its data, so keep it private. Hosted replay expires after 24
|
|
185
|
+
hours without activity. Only actor checkpoints and observations are replayed;
|
|
186
|
+
export traffic is live-only, and auth/upload/embed-control messages are rejected.
|
|
187
|
+
AI-backed features remain separately authenticated.
|
|
188
|
+
|
|
189
|
+
After successful registration, hosted Sky records coarse connection analytics:
|
|
190
|
+
role, normalized browser origin or `unknown`, localhost status, runtime,
|
|
191
|
+
SDK/protocol versions, Cloudflare country, ASN organization, and colo, plus an
|
|
192
|
+
opaque room identifier. The analytics event excludes raw room capabilities, IP
|
|
193
|
+
addresses, actor/session ids, machine names, inspection messages, and payloads.
|
|
194
|
+
Cloudflare operational logs may separately contain the request URL, IP address,
|
|
195
|
+
and request metadata. A source origin can identify a site or customer, so this
|
|
196
|
+
is operational telemetry rather than anonymous data. Pass a self-hosted `url`
|
|
197
|
+
to opt out of Stately-hosted collection.
|
|
198
|
+
|
|
199
|
+
Set `autoOpen: false`, await `inspector.ready`, and navigate to
|
|
200
|
+
`inspector.inspectorUrl` when a test runner or another process owns the browser.
|
|
201
|
+
`inspectorBaseUrl` targets an inspector UI hosted separately from the WebSocket
|
|
202
|
+
relay. An explicit `url` wins over `STATELY_INSPECT_URL`, which wins over the
|
|
203
|
+
hosted default. See `@statelyai/sdk/protocol` for the versioned message and
|
|
204
|
+
`?r=` query contract. SDK producer registration also reports its SDK version
|
|
205
|
+
and coarse browser, Node, or unknown runtime; it never adds inspection payloads
|
|
206
|
+
to registration metadata.
|
|
186
207
|
|
|
187
208
|
### CLI and sync
|
|
188
209
|
|
|
@@ -231,6 +252,22 @@ const embed = createStatelyEmbed({
|
|
|
231
252
|
});
|
|
232
253
|
```
|
|
233
254
|
|
|
255
|
+
For inspection, run your own relay and pass its URL explicitly:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
npx @statelyai/sdk relay
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
const inspector = createInspector({
|
|
263
|
+
url: 'ws://localhost:4242',
|
|
264
|
+
inspectorBaseUrl: 'http://localhost:3000/inspect',
|
|
265
|
+
});
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
This repository's `packages/sky` is an optional Cloudflare Durable Object
|
|
269
|
+
reference deployment.
|
|
270
|
+
|
|
234
271
|
Key environment variables for self-hosted deployments:
|
|
235
272
|
|
|
236
273
|
| Variable | Purpose |
|
package/dist/bin.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/bin.mjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createNodeInspectionRelay } from "./node-relay.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/bin.ts
|
|
5
|
+
function readFlag(name, fallback) {
|
|
6
|
+
const index = process.argv.indexOf(`--${name}`);
|
|
7
|
+
return index >= 0 ? process.argv[index + 1] ?? fallback : fallback;
|
|
8
|
+
}
|
|
9
|
+
async function main() {
|
|
10
|
+
const command = process.argv[2];
|
|
11
|
+
if (command !== "relay") {
|
|
12
|
+
console.info("Usage: stately-sdk relay [--host 127.0.0.1] [--port 4242]");
|
|
13
|
+
process.exitCode = command ? 1 : 0;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const relay = createNodeInspectionRelay({
|
|
17
|
+
host: readFlag("host", process.env.STATELY_HOST ?? "127.0.0.1"),
|
|
18
|
+
port: Number(readFlag("port", process.env.STATELY_PORT ?? "4242")),
|
|
19
|
+
logger: console
|
|
20
|
+
});
|
|
21
|
+
await relay.start();
|
|
22
|
+
const shutdown = async () => {
|
|
23
|
+
await relay.stop();
|
|
24
|
+
process.exit(0);
|
|
25
|
+
};
|
|
26
|
+
process.on("SIGINT", () => void shutdown());
|
|
27
|
+
process.on("SIGTERM", () => void shutdown());
|
|
28
|
+
}
|
|
29
|
+
main().catch((error) => {
|
|
30
|
+
console.error(error);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { };
|
package/dist/embed.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as toInitMessage, i as createPendingExportManager, r as createEventRegistry, t as createPostMessageTransport } from "./transport-B_ig9Znn.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/embed.ts
|
|
4
4
|
function buildEmbedUrl(options) {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { StatelyApiClientOptions, StatelyApiError, StatelyApiUrlOptions, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
|
|
2
2
|
import { _ as serializeJS, c as MachineConfigOptions, d as contextSchemaToTSType, f as eventsSchemaToTSType, g as raw, h as jsonSchemaToTSType, i as CodeGenGraph, l as RawCode, m as graphToXStateTS, o as GraphPatch, p as graphToMachineConfig, t as ActionLocation, u as XStateTSOptions } from "./index-ag6K2iAS.mjs";
|
|
3
3
|
import { C as EventTypeData, S as DigraphNodeConfig, _ as studioMachineConverter, a as StatelyGraphData, b as DigraphConfig, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, o as StatelyGuard, r as StatelyEdgeData, t as StatelyAction, v as toStudioMachine, w as StateNodeJSONData, x as DigraphEdgeConfig, y as DigraphAction } from "./graph-DuOeLGvh.mjs";
|
|
4
|
-
import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, INSPECTION_PROTOCOL_VERSION, InitOptions, InspectionAction, InspectionSentEvent, InspectionTakenTransition, ProjectEmbedMachine, UploadResult } from "./protocol.mjs";
|
|
4
|
+
import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitOptions, InspectionAction, InspectionSentEvent, InspectionTakenTransition, ProjectEmbedMachine, UploadResult, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
|
|
5
5
|
import { AssetUploadAdapter, AssetUploadContext, AssetUploadRequest, CreateS3AssetUploadAdapterOptions, CreateSupabaseAssetUploadAdapterOptions, S3UploadTarget, SupabaseStorageClient, createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
|
|
6
6
|
import { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-2Thaw42j.mjs";
|
|
7
7
|
import { AssetConfig, StatelyEmbed, StatelyEmbedOptions, createStatelyEmbed } from "./embed.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { A as Machine, C as StudioMachineRecord, D as VerifyApiKeyResponse, E as UpdateProjectInput, F as ProjectVisibility, I as VerifyResult, L as XStateVersion, M as Project, N as ProjectMachineSummary, O as createStatelyClient, P as ProjectSummary, R as ResourceErrorCode, S as StudioClientOptions, T as UpdateMachineInput, _ as ProjectMachine, a as CreateMachineTemplate, b as StudioApiErrorOptions, c as EnsureProjectInput, d as ExtractedMachine, f as GetMachineOptions, g as ProjectData, h as LegacyUpdateMachineInput, i as CreateMachineInput, j as MachineVersion, k as ExtractedMachines, l as ExtractMachinesInput, m as LegacyProjectVisibility, n as CreateMachineFromDefinitionInput, o as CreateProjectInput, r as CreateMachineFromTemplateInput, s as DEFAULT_STATELY_BASE_URL, t as ConnectedRepo, u as ExtractMachinesResponse, v as RepoType, w as StudioRequestOptions, x as StudioClient, y as StudioApiError } from "./studio-
|
|
8
|
+
import { a as InspectedTransition, c as InspectorInspectionEvent, d as createStatelyInspector, f as Transport, h as createWebSocketTransport, i as InspectedSnapshot, l as ManualActorOptions, m as createPostMessageTransport, n as CreateInspectorOptions, o as Inspector, p as TransportFailure, r as InspectedEvent, s as InspectorEvents, t as AdoptedActor, u as createInspector } from "./inspect-BScvqVcM.mjs";
|
|
9
|
+
import { A as Machine, C as StudioMachineRecord, D as VerifyApiKeyResponse, E as UpdateProjectInput, F as ProjectVisibility, I as VerifyResult, L as XStateVersion, M as Project, N as ProjectMachineSummary, O as createStatelyClient, P as ProjectSummary, R as ResourceErrorCode, S as StudioClientOptions, T as UpdateMachineInput, _ as ProjectMachine, a as CreateMachineTemplate, b as StudioApiErrorOptions, c as EnsureProjectInput, d as ExtractedMachine, f as GetMachineOptions, g as ProjectData, h as LegacyUpdateMachineInput, i as CreateMachineInput, j as MachineVersion, k as ExtractedMachines, l as ExtractMachinesInput, m as LegacyProjectVisibility, n as CreateMachineFromDefinitionInput, o as CreateProjectInput, r as CreateMachineFromTemplateInput, s as DEFAULT_STATELY_BASE_URL, t as ConnectedRepo, u as ExtractMachinesResponse, v as RepoType, w as StudioRequestOptions, x as StudioClient, y as StudioApiError } from "./studio-Bk_u41gu.mjs";
|
|
10
10
|
import { OAuthAuthorizationServerMetadata, OAuthClientRegistrationResponse, OAuthProtectedResourceMetadata, OAuthTokenResponse, PkcePair, buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
|
|
11
11
|
import { PlanSyncOptions, PullSyncResult, PushLocalMachineLinksResult, PushSyncOptions, PushSyncProjectOptions, PushSyncResult, ResolvedSyncInput, SyncInputFormat, SyncPlan, SyncPlanSummary } from "./sync.mjs";
|
|
12
12
|
import { CreateInspectionRelayOptions, InspectionRelay, InspectionRelayEffect, InspectionRelayPeer, InspectionRelayRole, InspectionRelaySnapshot, createInspectionRelay } from "./relay.mjs";
|
|
@@ -32,4 +32,4 @@ declare function findStatelyPragmaAttachments(sourceText: string, fileName?: str
|
|
|
32
32
|
declare function getStatelyPragma(sourceText: string, fileName?: string, machineIndex?: number): StatelyPragma | undefined;
|
|
33
33
|
declare function upsertStatelyPragma(sourceText: string, id: string, options?: UpsertStatelyPragmaOptions): string;
|
|
34
34
|
//#endregion
|
|
35
|
-
export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CapabilityDeniedCapability, type CapabilityDeniedEvent, type CodeGenGraph, type CommentsConfig, type ConnectedRepo, type CreateInspectionRelayOptions, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, DEFAULT_STATELY_BASE_URL, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, type EditorCapabilities, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedMode, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesInput, type ExtractMachinesResponse, type ExtractedMachine, type ExtractedMachines, type GetMachineOptions, type GraphPatch, INSPECTION_PROTOCOL_VERSION, type InitOptions, type InspectedEvent, type InspectedSnapshot, type InspectedTransition, type InspectionAction, type InspectionRelay, type InspectionRelayEffect, type InspectionRelayPeer, type InspectionRelayRole, type InspectionRelaySnapshot, type InspectionSentEvent, type InspectionTakenTransition, type Inspector, type InspectorEvents, type InspectorInspectionEvent, type LegacyProjectVisibility, type LegacyUpdateMachineInput, type Machine, type MachineConfigOptions, type MachineVersion, type ManualActorOptions, type
|
|
35
|
+
export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CapabilityDeniedCapability, type CapabilityDeniedEvent, type CodeGenGraph, type CommentsConfig, type ConnectedRepo, type CreateInspectionRelayOptions, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, DEFAULT_STATELY_BASE_URL, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, type EditorCapabilities, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedMode, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesInput, type ExtractMachinesResponse, type ExtractedMachine, type ExtractedMachines, type GetMachineOptions, type GraphPatch, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, type InitOptions, type InspectedEvent, type InspectedSnapshot, type InspectedTransition, type InspectionAction, type InspectionRelay, type InspectionRelayEffect, type InspectionRelayPeer, type InspectionRelayRole, type InspectionRelaySnapshot, type InspectionSentEvent, type InspectionTakenTransition, type Inspector, type InspectorEvents, type InspectorInspectionEvent, type LegacyProjectVisibility, type LegacyUpdateMachineInput, type Machine, type MachineConfigOptions, type MachineVersion, type ManualActorOptions, type OAuthAuthorizationServerMetadata, type OAuthClientRegistrationResponse, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type PlanSyncOptions, type Project, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectMachineSummary, type ProjectSummary, type ProjectVisibility, type PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, type RepoType, type ResolvedSyncInput, type ResourceErrorCode, type S3UploadTarget, type StateNodeJSONData, type StatelyAction, type StatelyApiClientOptions, StatelyApiError, type StatelyApiUrlOptions, type StatelyAuthMode, type StatelyCredential, type StatelyEdgeData, type StatelyEmbed, type StatelyEmbedOptions, type StatelyGraph, type StatelyGraphData, type StatelyGuard, type StatelyInvoke, type StatelyNodeData, type StatelyPragma, type StatelyPragmaAttachment, type StudioAction, StudioApiError, type StudioApiErrorOptions, type StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type StudioRequestOptions, type SupabaseStorageClient, type SyncInputFormat, type SyncPlan, type SyncPlanSummary, type Transport, type TransportFailure, type UpdateMachineInput, type UpdateProjectInput, type UploadResult, type UpsertStatelyPragmaOptions, type VerifyApiKeyResponse, type VerifyResult, type XStateTSOptions, type XStateVersion, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { INSPECTION_PROTOCOL_VERSION } from "./protocol.mjs";
|
|
1
|
+
import { n as createWebSocketTransport, t as createPostMessageTransport } from "./transport-B_ig9Znn.mjs";
|
|
2
|
+
import { INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
|
|
3
3
|
import { createStatelyEmbed } from "./embed.mjs";
|
|
4
4
|
import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
|
|
5
|
-
import { n as createStatelyInspector, t as createInspector } from "./inspect-
|
|
5
|
+
import { n as createStatelyInspector, t as createInspector } from "./inspect-C3Y_o_Np.mjs";
|
|
6
6
|
import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-txdyJHD7.mjs";
|
|
7
7
|
import { a as RawCode, c as eventsSchemaToTSType, d as jsonSchemaToTSType, f as raw, l as graphToMachineConfig, n as getStatelyPragma, o as contextSchemaToTSType, p as serializeJS, r as upsertStatelyPragma, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-Bm9O4XV6.mjs";
|
|
8
8
|
import { createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
|
|
@@ -11,4 +11,4 @@ import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./
|
|
|
11
11
|
import { fromStudioMachine, studioMachineConverter, toStudioMachine } from "./graph.mjs";
|
|
12
12
|
import { createInspectionRelay } from "./relay.mjs";
|
|
13
13
|
|
|
14
|
-
export { DEFAULT_STATELY_BASE_URL, INSPECTION_PROTOCOL_VERSION, RawCode, StatelyApiError, StudioApiError, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionRelay,
|
|
14
|
+
export { DEFAULT_STATELY_BASE_URL, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, RawCode, StatelyApiError, StudioApiError, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { EditorCapabilities, EmbedEventMap, ExportCallOptions, ExportFormat, ExportFormatMap, InspectionAction, InspectionSentEvent, InspectionTakenTransition, ProtocolMessage } from "./protocol.mjs";
|
|
1
|
+
import { EditorCapabilities, EmbedEventMap, ExportCallOptions, ExportFormat, ExportFormatMap, InspectionAction, InspectionClientMetadata, InspectionSentEvent, InspectionTakenTransition, ProtocolMessage } from "./protocol.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/transport.d.ts
|
|
4
|
+
interface TransportFailure {
|
|
5
|
+
code: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
4
8
|
interface Transport {
|
|
5
9
|
send(msg: ProtocolMessage): void;
|
|
6
10
|
onMessage(handler: (msg: ProtocolMessage) => void): () => void;
|
|
7
11
|
destroy(): void;
|
|
8
12
|
readonly ready: boolean;
|
|
9
13
|
onReady(handler: () => void): () => void;
|
|
14
|
+
onError?(handler: (failure: TransportFailure) => void): () => void;
|
|
10
15
|
}
|
|
11
16
|
interface PostMessageTransportOptions {
|
|
12
17
|
iframe: HTMLIFrameElement;
|
|
@@ -17,51 +22,15 @@ interface PostMessageTransportOptions {
|
|
|
17
22
|
declare function createPostMessageTransport(options: PostMessageTransportOptions): Transport;
|
|
18
23
|
interface WebSocketTransportOptions {
|
|
19
24
|
url: string;
|
|
20
|
-
role: '
|
|
21
|
-
|
|
22
|
-
metadata?:
|
|
23
|
-
name?: string;
|
|
24
|
-
machineId?: string;
|
|
25
|
-
};
|
|
25
|
+
role: 'producer' | 'viewer';
|
|
26
|
+
producerId?: string;
|
|
27
|
+
metadata?: InspectionClientMetadata;
|
|
26
28
|
/** Reconnect on disconnect. Default true. */
|
|
27
29
|
reconnect?: boolean;
|
|
28
|
-
/** Max reconnect attempts. Default 10. */
|
|
30
|
+
/** Max reconnect attempts after the first connection. Default 10. */
|
|
29
31
|
maxReconnectAttempts?: number;
|
|
30
32
|
}
|
|
31
33
|
declare function createWebSocketTransport(options: WebSocketTransportOptions): Transport;
|
|
32
|
-
interface MultiplexedWebSocketConnectionOptions {
|
|
33
|
-
url: string;
|
|
34
|
-
role: 'client' | 'viz';
|
|
35
|
-
/** First (primary) session to register on connect. */
|
|
36
|
-
sessionId: string;
|
|
37
|
-
/** Metadata for the primary session. */
|
|
38
|
-
metadata?: {
|
|
39
|
-
name?: string;
|
|
40
|
-
machineId?: string;
|
|
41
|
-
};
|
|
42
|
-
reconnect?: boolean;
|
|
43
|
-
maxReconnectAttempts?: number;
|
|
44
|
-
}
|
|
45
|
-
interface MultiplexedChannelOptions {
|
|
46
|
-
/** Session id this channel targets. */
|
|
47
|
-
sessionId: string;
|
|
48
|
-
/** Optional metadata for this session. */
|
|
49
|
-
metadata?: {
|
|
50
|
-
name?: string;
|
|
51
|
-
machineId?: string;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
interface MultiplexedWebSocketConnection {
|
|
55
|
-
/** Open a channel for a sessionId. Re-opening an existing session returns the same channel. */
|
|
56
|
-
openChannel(options: MultiplexedChannelOptions): Transport;
|
|
57
|
-
/** Close the connection and all its channels. */
|
|
58
|
-
destroy(): void;
|
|
59
|
-
/** Whether the underlying WebSocket is connected + the primary session is registered. */
|
|
60
|
-
readonly ready: boolean;
|
|
61
|
-
/** Primary session id (first registered). */
|
|
62
|
-
readonly primarySessionId: string;
|
|
63
|
-
}
|
|
64
|
-
declare function createMultiplexedWebSocketConnection(options: MultiplexedWebSocketConnectionOptions): MultiplexedWebSocketConnection;
|
|
65
34
|
//#endregion
|
|
66
35
|
//#region src/inspect.d.ts
|
|
67
36
|
interface MinimalActorRef {
|
|
@@ -93,14 +62,14 @@ interface InspectorInspectionEvent {
|
|
|
93
62
|
readonly actorRef: unknown;
|
|
94
63
|
}
|
|
95
64
|
interface AdoptedActor {
|
|
96
|
-
/** `actor.sessionId` from xstate.
|
|
65
|
+
/** Globally unique `actor.sessionId` from xstate. */
|
|
66
|
+
sessionId: string;
|
|
67
|
+
/** System-local `actor.id`. */
|
|
97
68
|
actorId: string;
|
|
98
69
|
/** Parent actor's sessionId, or `null` for the root. */
|
|
99
|
-
|
|
100
|
-
/** Root actor's sessionId
|
|
101
|
-
|
|
102
|
-
/** `actor.id` — a human-facing local name. */
|
|
103
|
-
id: string;
|
|
70
|
+
parentSessionId: string | null;
|
|
71
|
+
/** Root actor's sessionId. */
|
|
72
|
+
rootSessionId: string;
|
|
104
73
|
/** `actor.systemId`, if registered under one. */
|
|
105
74
|
systemId: string | undefined;
|
|
106
75
|
/** Latest serialized snapshot streamed for this actor. */
|
|
@@ -112,8 +81,8 @@ interface AdoptedActor {
|
|
|
112
81
|
}
|
|
113
82
|
/** One observed snapshot, independent of the XState inspection version. */
|
|
114
83
|
interface InspectedSnapshot {
|
|
115
|
-
|
|
116
|
-
|
|
84
|
+
sessionId: string;
|
|
85
|
+
sourceSessionId: string | null;
|
|
117
86
|
/** Previously observed snapshot, which may not be the immediate predecessor. */
|
|
118
87
|
previousSnapshot: unknown | null;
|
|
119
88
|
snapshot: unknown;
|
|
@@ -127,8 +96,8 @@ interface InspectedSnapshot {
|
|
|
127
96
|
type InspectedTransition = InspectedSnapshot;
|
|
128
97
|
/** One observed event, independent of whether processing produced a snapshot. */
|
|
129
98
|
interface InspectedEvent {
|
|
130
|
-
|
|
131
|
-
|
|
99
|
+
sessionId: string;
|
|
100
|
+
sourceSessionId: string | null;
|
|
132
101
|
event: unknown;
|
|
133
102
|
}
|
|
134
103
|
interface InspectorEvents {
|
|
@@ -136,7 +105,7 @@ interface InspectorEvents {
|
|
|
136
105
|
event: InspectedEvent;
|
|
137
106
|
snapshot: InspectedSnapshot;
|
|
138
107
|
stop: {
|
|
139
|
-
|
|
108
|
+
sessionId: string;
|
|
140
109
|
};
|
|
141
110
|
/** @deprecated Use `actor`. */
|
|
142
111
|
register: AdoptedActor;
|
|
@@ -144,7 +113,7 @@ interface InspectorEvents {
|
|
|
144
113
|
transition: InspectedSnapshot;
|
|
145
114
|
/** @deprecated Use `stop`. */
|
|
146
115
|
stopped: {
|
|
147
|
-
|
|
116
|
+
sessionId: string;
|
|
148
117
|
};
|
|
149
118
|
error: EmbedEventMap['error'];
|
|
150
119
|
}
|
|
@@ -161,15 +130,27 @@ interface ManualActorOptions {
|
|
|
161
130
|
systemId?: string;
|
|
162
131
|
}
|
|
163
132
|
interface CreateInspectorOptions {
|
|
164
|
-
/**
|
|
133
|
+
/**
|
|
134
|
+
* WebSocket relay base URL. Defaults to `STATELY_INSPECT_URL`, then
|
|
135
|
+
* `wss://sky.stately.ai`. Passing this option always wins.
|
|
136
|
+
*/
|
|
165
137
|
url?: string;
|
|
138
|
+
/** Unguessable inspection room capability. Defaults to a random UUID. */
|
|
139
|
+
roomId?: string;
|
|
140
|
+
/** Stable identity for this producer connection. Defaults to a random UUID. */
|
|
141
|
+
producerId?: string;
|
|
142
|
+
/**
|
|
143
|
+
* Inspector UI base URL when hosted separately from the WebSocket relay. The
|
|
144
|
+
* inspector adds `ws` and `r` query parameters. When omitted, the URL
|
|
145
|
+
* is derived from the relay URL by replacing `ws` with `http`.
|
|
146
|
+
*/
|
|
147
|
+
inspectorBaseUrl?: string;
|
|
166
148
|
/** Auto-open browser to visualizer. Default: `true`. */
|
|
167
149
|
autoOpen?: boolean;
|
|
168
150
|
/**
|
|
169
|
-
*
|
|
170
|
-
* This is the `?session=<id>` value the visualizer connects with. Custom
|
|
171
|
-
* values used with a hosted relay must be unguessable.
|
|
151
|
+
* Legacy name for the unguessable room capability.
|
|
172
152
|
*/
|
|
153
|
+
/** @deprecated Use {@link roomId}. */
|
|
173
154
|
sessionId?: string;
|
|
174
155
|
/** Display name for this system in the visualizer. */
|
|
175
156
|
name?: string;
|
|
@@ -184,7 +165,9 @@ interface CreateInspectorOptions {
|
|
|
184
165
|
* `actor.logic.config`. Return `null` for non-machine actors.
|
|
185
166
|
*/
|
|
186
167
|
extractMachineConfig?: (actor: any, source?: unknown) => unknown;
|
|
187
|
-
/** Selected actor id to focus on first.
|
|
168
|
+
/** Selected actor session id to focus on first. */
|
|
169
|
+
selectedSessionId?: string;
|
|
170
|
+
/** @deprecated Use {@link selectedSessionId}. */
|
|
188
171
|
selectedActorId?: string;
|
|
189
172
|
/** Panel layout forwarded into the system init message. */
|
|
190
173
|
panels?: {
|
|
@@ -197,17 +180,26 @@ interface CreateInspectorOptions {
|
|
|
197
180
|
depth?: number;
|
|
198
181
|
capabilities?: EditorCapabilities;
|
|
199
182
|
/**
|
|
200
|
-
* Advanced: inject a pre-built transport
|
|
201
|
-
*
|
|
202
|
-
* inspector shares that transport instead of opening its own WebSocket.
|
|
183
|
+
* Advanced: inject a pre-built transport. When provided, `url`/`name` are
|
|
184
|
+
* ignored and no WebSocket or browser URL is created.
|
|
203
185
|
*/
|
|
204
186
|
transport?: Transport;
|
|
205
187
|
}
|
|
206
188
|
interface Inspector {
|
|
207
|
-
/** Snapshot of currently-adopted actors keyed by `
|
|
189
|
+
/** Snapshot of currently-adopted actors keyed by global `sessionId`. */
|
|
208
190
|
readonly actors: ReadonlyMap<string, AdoptedActor>;
|
|
209
|
-
/**
|
|
191
|
+
/** Unguessable inspection room capability. */
|
|
192
|
+
readonly roomId: string;
|
|
193
|
+
/** Complete WebSocket URL for this room. */
|
|
194
|
+
readonly relayUrl: string | null;
|
|
195
|
+
/** Identity stamped onto this producer's protocol messages. */
|
|
196
|
+
readonly producerId: string;
|
|
197
|
+
/** @deprecated Use {@link roomId}. */
|
|
210
198
|
readonly sessionId: string;
|
|
199
|
+
/** URL that opens the inspector UI for this live session. */
|
|
200
|
+
readonly inspectorUrl: string | null;
|
|
201
|
+
/** Resolves after the first relay registration and initial-state flush. */
|
|
202
|
+
readonly ready: Promise<void>;
|
|
211
203
|
/**
|
|
212
204
|
* XState `inspect` option callback. Pass directly to `createActor` or another
|
|
213
205
|
* host that creates actors internally.
|
|
@@ -251,4 +243,4 @@ declare function createInspector(options?: CreateInspectorOptions): Inspector;
|
|
|
251
243
|
/** @deprecated Use {@link createInspector}. */
|
|
252
244
|
declare const createStatelyInspector: typeof createInspector;
|
|
253
245
|
//#endregion
|
|
254
|
-
export {
|
|
246
|
+
export { InspectedTransition as a, InspectorInspectionEvent as c, createStatelyInspector as d, Transport as f, createWebSocketTransport as h, InspectedSnapshot as i, ManualActorOptions as l, createPostMessageTransport as m, CreateInspectorOptions as n, Inspector as o, TransportFailure as p, InspectedEvent as r, InspectorEvents as s, AdoptedActor as t, createInspector as u };
|