@statelyai/sdk 0.16.0 → 0.16.2

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
@@ -106,20 +106,20 @@ const extracted = await studio.code.extractMachines({
106
106
 
107
107
  The client namespaces map one-to-one onto the server-owned `/api/v1` contract:
108
108
 
109
- | Method | Operation |
110
- | -------------------------------------------------- | ------------------------------------------------------ |
111
- | `auth.verify()` | `GET /api/v1/auth/verify` |
112
- | `projects.list()` | `GET /api/v1/projects` |
113
- | `projects.create(input)` | `POST /api/v1/projects` |
114
- | `projects.get(projectId)` | `GET /api/v1/projects/:projectId` |
115
- | `projects.update(projectId, input)` | `PATCH /api/v1/projects/:projectId` |
116
- | `projects.delete(projectId)` | `DELETE /api/v1/projects/:projectId` |
117
- | `projects.listMachines(projectId)` | `GET /api/v1/projects/:projectId/machines` |
118
- | `machines.create(input)` | `POST /api/v1/machines` |
119
- | `machines.get(machineId)` | `GET /api/v1/machines/:machineId` |
120
- | `machines.getVersion(machineId, versionId)` | `GET /api/v1/machines/:machineId/versions/:versionId` |
121
- | `machines.update(machineId, input)` | `PATCH /api/v1/machines/:machineId` |
122
- | `code.extractMachines(input)` | `POST /api/v1/code/extract-machines` |
109
+ | Method | Operation |
110
+ | ------------------------------------------- | ----------------------------------------------------- |
111
+ | `auth.verify()` | `GET /api/v1/auth/verify` |
112
+ | `projects.list()` | `GET /api/v1/projects` |
113
+ | `projects.create(input)` | `POST /api/v1/projects` |
114
+ | `projects.get(projectId)` | `GET /api/v1/projects/:projectId` |
115
+ | `projects.update(projectId, input)` | `PATCH /api/v1/projects/:projectId` |
116
+ | `projects.delete(projectId)` | `DELETE /api/v1/projects/:projectId` |
117
+ | `projects.listMachines(projectId)` | `GET /api/v1/projects/:projectId/machines` |
118
+ | `machines.create(input)` | `POST /api/v1/machines` |
119
+ | `machines.get(machineId)` | `GET /api/v1/machines/:machineId` |
120
+ | `machines.getVersion(machineId, versionId)` | `GET /api/v1/machines/:machineId/versions/:versionId` |
121
+ | `machines.update(machineId, input)` | `PATCH /api/v1/machines/:machineId` |
122
+ | `code.extractMachines(input)` | `POST /api/v1/code/extract-machines` |
123
123
 
124
124
  `projects.ensure(input)` is a client workflow composed of `projects.list`,
125
125
  `projects.get`, and `projects.create`, not a route.
@@ -186,12 +186,24 @@ hours without activity. Only actor checkpoints and observations are replayed;
186
186
  export traffic is live-only, and auth/upload/embed-control messages are rejected.
187
187
  AI-backed features remain separately authenticated.
188
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
+
189
199
  Set `autoOpen: false`, await `inspector.ready`, and navigate to
190
200
  `inspector.inspectorUrl` when a test runner or another process owns the browser.
191
201
  `inspectorBaseUrl` targets an inspector UI hosted separately from the WebSocket
192
202
  relay. An explicit `url` wins over `STATELY_INSPECT_URL`, which wins over the
193
203
  hosted default. See `@statelyai/sdk/protocol` for the versioned message and
194
- `?r=` query contract.
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.
195
207
 
196
208
  ### CLI and sync
197
209
 
@@ -258,12 +270,12 @@ reference deployment.
258
270
 
259
271
  Key environment variables for self-hosted deployments:
260
272
 
261
- | Variable | Purpose |
262
- | --------------------------- | ------------------------------------------------- |
263
- | `AUTH_PROVIDER` | Auth strategy used by the editor host |
273
+ | Variable | Purpose |
274
+ | --------------------------- | -------------------------------------------------------------------------------------------------- |
275
+ | `AUTH_PROVIDER` | Auth strategy used by the editor host |
264
276
  | `RESOURCE_PROVIDER` | Set to `stately` to enable project and machine resource operations; `none` (default) disables them |
265
- | `EDITOR_SYNC_AUTH_REQUIRED` | Set to `false` to skip editor-sync API-key checks |
266
- | `NEXT_PUBLIC_BASE_URL` | Public-facing editor URL |
277
+ | `EDITOR_SYNC_AUTH_REQUIRED` | Set to `false` to skip editor-sync API-key checks |
278
+ | `NEXT_PUBLIC_BASE_URL` | Public-facing editor URL |
267
279
 
268
280
  For enterprise self-hosting options, [see pricing and contact
269
281
  us](https://stately.ai/pricing).
package/dist/index.d.mts CHANGED
@@ -5,7 +5,7 @@ import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, Edit
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 { 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-CduY_2Fa.mjs";
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
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";
package/dist/index.mjs CHANGED
@@ -2,9 +2,9 @@ import { n as createWebSocketTransport, t as createPostMessageTransport } from "
2
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-BwVdM4R8.mjs";
5
+ import { n as createStatelyInspector, t as createInspector } from "./inspect-DxOsKzlq.mjs";
6
6
  import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-txdyJHD7.mjs";
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-Th0gdXfx.mjs";
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";
9
9
  import { buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
10
10
  import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
@@ -1,4 +1,4 @@
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
4
  interface TransportFailure {
@@ -24,10 +24,7 @@ interface WebSocketTransportOptions {
24
24
  url: string;
25
25
  role: 'producer' | 'viewer';
26
26
  producerId?: string;
27
- metadata?: {
28
- name?: string;
29
- machineId?: string;
30
- };
27
+ metadata?: InspectionClientMetadata;
31
28
  /** Reconnect on disconnect. Default true. */
32
29
  reconnect?: boolean;
33
30
  /** Max reconnect attempts after the first connection. Default 10. */
@@ -26,6 +26,15 @@ async function openBrowser(url) {
26
26
  });
27
27
  }
28
28
 
29
+ //#endregion
30
+ //#region src/version.ts
31
+ const SDK_VERSION = "0.16.2";
32
+ function inspectionRuntime() {
33
+ if (typeof window !== "undefined") return "browser";
34
+ if (typeof process !== "undefined" && process.versions?.node) return "node";
35
+ return "unknown";
36
+ }
37
+
29
38
  //#endregion
30
39
  //#region src/inspect.ts
31
40
  const defaultSerializeSnapshot = (snapshot) => ({
@@ -76,7 +85,11 @@ function createInspector(options = {}) {
76
85
  url: relayUrl,
77
86
  role: "producer",
78
87
  producerId,
79
- metadata: { name: displayName }
88
+ metadata: {
89
+ name: displayName,
90
+ sdkVersion: SDK_VERSION,
91
+ runtime: inspectionRuntime()
92
+ }
80
93
  });
81
94
  const ownsTransport = !injectedTransport;
82
95
  const exportManager = createPendingExportManager((message) => send(message));
@@ -1,3 +1,3 @@
1
1
  import { EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InspectionAction, InspectionSentEvent, InspectionTakenTransition } from "./protocol.mjs";
2
- import { a as InspectedTransition, c as InspectorInspectionEvent, d as createStatelyInspector, f as Transport, i as InspectedSnapshot, l as ManualActorOptions, n as CreateInspectorOptions, o as Inspector, r as InspectedEvent, s as InspectorEvents, t as AdoptedActor, u as createInspector } from "./inspect-CduY_2Fa.mjs";
2
+ import { a as InspectedTransition, c as InspectorInspectionEvent, d as createStatelyInspector, f as Transport, i as InspectedSnapshot, l as ManualActorOptions, n as CreateInspectorOptions, o as Inspector, r as InspectedEvent, s as InspectorEvents, t as AdoptedActor, u as createInspector } from "./inspect-BScvqVcM.mjs";
3
3
  export { AdoptedActor, CreateInspectorOptions, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InspectedEvent, InspectedSnapshot, InspectedTransition, InspectionAction, InspectionSentEvent, InspectionTakenTransition, Inspector, InspectorEvents, InspectorInspectionEvent, ManualActorOptions, Transport, createInspector, createStatelyInspector };
package/dist/inspect.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { n as createStatelyInspector, t as createInspector } from "./inspect-BwVdM4R8.mjs";
1
+ import { n as createStatelyInspector, t as createInspector } from "./inspect-DxOsKzlq.mjs";
2
2
 
3
3
  export { createInspector, createStatelyInspector };
package/dist/oauth.mjs CHANGED
@@ -13,6 +13,24 @@ async function getOAuthResponseError(response) {
13
13
  const detail = (await response.text().catch(() => "")).trim();
14
14
  return detail ? `: ${detail}` : "";
15
15
  }
16
+ var OAuthTokenRequestError = class extends Error {
17
+ constructor(message, status, oauthError) {
18
+ super(message);
19
+ this.status = status;
20
+ this.oauthError = oauthError;
21
+ this.name = "OAuthTokenRequestError";
22
+ }
23
+ };
24
+ async function createOAuthTokenRequestError(response, message) {
25
+ const body = await response.text().catch(() => "");
26
+ let oauthError;
27
+ try {
28
+ const parsed = JSON.parse(body);
29
+ if (typeof parsed.error === "string") oauthError = parsed.error;
30
+ } catch {}
31
+ const detail = body.trim() ? `: ${body.trim()}` : "";
32
+ return new OAuthTokenRequestError(`${message} with HTTP ${response.status}${detail}`, response.status, oauthError);
33
+ }
16
34
  async function discoverProtectedResource(resourceUrl, options = {}) {
17
35
  const resource = new URL(String(resourceUrl));
18
36
  const pathParts = resource.pathname.split("/").filter(Boolean);
@@ -110,7 +128,7 @@ async function refreshToken(options) {
110
128
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
111
129
  body
112
130
  });
113
- if (!response.ok) throw new Error(`Token refresh failed with HTTP ${response.status}${await getOAuthResponseError(response)}`);
131
+ if (!response.ok) throw await createOAuthTokenRequestError(response, "Token refresh failed");
114
132
  return response.json();
115
133
  }
116
134
 
@@ -521,15 +521,18 @@ interface UploadResponseMessage {
521
521
  type ClientMessage = InitMessage | SetApiKeyMessage | ProjectInitMessage | ProjectUpdateMessage | ProjectSelectMachineMessage | UpdateMessage | SetModeMessage | SetThemeMessage | SetSettingsMessage | RetrieveMessage | ToastMessage | InspectSnapshotMessage | SystemInitMessage | SystemSelectActorMessage | SystemActorRegisteredMessage | SystemActorEventMessage | SystemActorSnapshotMessage | SystemActorStoppedMessage | UploadCapabilitiesMessage | UploadResponseMessage | ErrorMessage;
522
522
  /** All messages the viz can send back to a client. */
523
523
  type VizMessage = ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | ProjectMachineSelectedMessage | RetrievedMessage | ErrorMessage | CapabilityDeniedMessage | UploadRequestMessage;
524
+ interface InspectionClientMetadata {
525
+ name?: string;
526
+ machineId?: string;
527
+ sdkVersion?: string;
528
+ runtime?: 'browser' | 'node' | 'unknown';
529
+ }
524
530
  interface RegisterMessage {
525
531
  type: '@statelyai.register';
526
532
  protocolVersion: number;
527
533
  role: 'producer' | 'viewer';
528
534
  producerId?: string;
529
- metadata?: {
530
- name?: string;
531
- machineId?: string;
532
- };
535
+ metadata?: InspectionClientMetadata;
533
536
  }
534
537
  interface RegisteredMessage {
535
538
  type: '@statelyai.registered';
@@ -546,4 +549,4 @@ declare const PREFIX = "@statelyai.";
546
549
  /** Current WebSocket inspection protocol version. */
547
550
  declare const INSPECTION_PROTOCOL_VERSION = 2;
548
551
  //#endregion
549
- export { ActorSystemEntry, CapabilityDeniedCapability, CapabilityDeniedEvent, CapabilityDeniedMessage, ChangeMessage, ClientMessage, CommentsConfig, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ErrorMessage, ExportCallOptions, ExportFormat, ExportFormatMap, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitMessage, InitOptions, InspectSnapshotMessage, InspectionAction, InspectionRoomUrls, InspectionSentEvent, InspectionTakenTransition, LoadedMessage, MachineInitOptions, MachineSourceLocations, PREFIX, ProjectEmbedMachine, ProjectInitMessage, ProjectInitOptions, ProjectMachineSelectedMessage, ProjectSelectMachineMessage, ProjectUpdateMessage, ProtocolMessage, ReadOnlyReason, ReadyMessage, RegisterMessage, RegisteredMessage, RetrieveMessage, RetrievedMessage, SaveMessage, SessionMessage, SetApiKeyMessage, SetModeMessage, SetSettingsMessage, SetThemeMessage, SourceLocation, SourceRange, StateSourceLocation, SystemActorEventMessage, SystemActorRegisteredMessage, SystemActorSnapshotMessage, SystemActorStoppedMessage, SystemInitMessage, SystemSelectActorMessage, ToastMessage, UpdateMessage, UploadCapabilitiesMessage, UploadFileInfo, UploadRequestMessage, UploadResponseMessage, UploadResult, ValidationIssue, VizMessage, createInspectionRoomUrls, getInspectionRoomId };
552
+ export { ActorSystemEntry, CapabilityDeniedCapability, CapabilityDeniedEvent, CapabilityDeniedMessage, ChangeMessage, ClientMessage, CommentsConfig, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ErrorMessage, ExportCallOptions, ExportFormat, ExportFormatMap, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitMessage, InitOptions, InspectSnapshotMessage, InspectionAction, InspectionClientMetadata, InspectionRoomUrls, InspectionSentEvent, InspectionTakenTransition, LoadedMessage, MachineInitOptions, MachineSourceLocations, PREFIX, ProjectEmbedMachine, ProjectInitMessage, ProjectInitOptions, ProjectMachineSelectedMessage, ProjectSelectMachineMessage, ProjectUpdateMessage, ProtocolMessage, ReadOnlyReason, ReadyMessage, RegisterMessage, RegisteredMessage, RetrieveMessage, RetrievedMessage, SaveMessage, SessionMessage, SetApiKeyMessage, SetModeMessage, SetSettingsMessage, SetThemeMessage, SourceLocation, SourceRange, StateSourceLocation, SystemActorEventMessage, SystemActorRegisteredMessage, SystemActorSnapshotMessage, SystemActorStoppedMessage, SystemInitMessage, SystemSelectActorMessage, ToastMessage, UpdateMessage, UploadCapabilitiesMessage, UploadFileInfo, UploadRequestMessage, UploadResponseMessage, UploadResult, ValidationIssue, VizMessage, createInspectionRoomUrls, getInspectionRoomId };
@@ -1,5 +1,6 @@
1
1
  import { a as array, c as literal, d as record, f as string, i as _enum, l as number, m as unknown, o as boolean, p as union, s as discriminatedUnion, u as object } from "./studio-txdyJHD7.mjs";
2
2
  import ts from "typescript";
3
+ import "xstate";
3
4
  import "xstate/graph";
4
5
 
5
6
  //#region ../../node_modules/.pnpm/js-yaml@4.2.0/node_modules/js-yaml/dist/js-yaml.mjs
package/dist/sync.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { r as createStatelyClient } from "./studio-txdyJHD7.mjs";
2
- import { i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, m as xstateSourceToConfig, n as getStatelyPragma, p as serializeJS, r as upsertStatelyPragma, s as detectXStateSourceProfile, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-Th0gdXfx.mjs";
2
+ import { i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, m as xstateSourceToConfig, n as getStatelyPragma, p as serializeJS, r as upsertStatelyPragma, s as detectXStateSourceProfile, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-Bm9O4XV6.mjs";
3
3
  import { fromStudioMachine, toStudioMachine } from "./graph.mjs";
4
4
  import * as ts$1 from "typescript";
5
5
  import ts from "typescript";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statelyai/sdk",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "stately-sdk": "./dist/bin.mjs"
@@ -89,8 +89,8 @@
89
89
  "jsdom": "^27.4.0",
90
90
  "tsdown": "0.21.0-beta.2",
91
91
  "vitest": "^3.2.4",
92
- "@statelyai/api-contract": "0.0.1",
93
- "@statelyai/graph-tools": "0.0.7"
92
+ "@statelyai/api-contract": "0.0.2",
93
+ "@statelyai/graph-tools": "0.0.8"
94
94
  },
95
95
  "engines": {
96
96
  "node": ">=22.4"