@ai4b-team/fsaos-gateway-sdk 3.26.0 → 3.26.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/dist/index.d.cts CHANGED
@@ -519,6 +519,21 @@ declare const isScopeReady: typeof isAnchorReady;
519
519
  * (kernel_caller_confinement — mounts declaration narrows, never widens).
520
520
  */
521
521
 
522
+ declare class GatewayRequestError extends Error {
523
+ readonly name = "GatewayRequestError";
524
+ readonly method: string;
525
+ readonly status: number;
526
+ readonly statusText: string;
527
+ readonly payload: GatewayResponse | null;
528
+ readonly responseBody: string;
529
+ constructor(options: {
530
+ method: string;
531
+ status: number;
532
+ statusText: string;
533
+ payload: GatewayResponse | null;
534
+ responseBody: string;
535
+ });
536
+ }
522
537
  declare function gatewayCall(method: string, params?: GatewayParams): Promise<GatewayResponse>;
523
538
 
524
539
  /**
@@ -2956,4 +2971,4 @@ declare function fetchTimelineHistory(channelPath: string, options?: Pick<Timeli
2956
2971
  */
2957
2972
  declare function useTimelineHistory(channelPath: string | null | undefined, options?: TimelineHistoryOptions): UseTimelineHistoryReturn;
2958
2973
 
2959
- export { type AccountInfo, type ArtifactDeltaEvent, type ArtifactDoneEvent, type ArtifactEvent, type ArtifactOpenedEvent, type ArtifactState, type ArtifactStatus, type ArtifactStreamState, type ArtifactSurfaceType, type CancelQueuedTurnOptions, type CancelQueuedTurnResponse, type CancelQueuedTurnState, type CancelTurnOptions, type CancelTurnResponse, type CancelTurnState, type Channel, type ChannelCard, type ChannelMessage, type ChannelMessagesOptions, type ChannelMessagesPage, type ChannelMessagesResponse, type ChannelsOptions, type ComponentOpener, ComponentRenderer, type ConnectionState, type CreateParams, type DeleteParams, EnforcementDeniedError, type EnforcementPayload, type FieldDescriptor, type FileRef, FormSubmissionError, type FormSubmissionReceipt, type FsaosRuntime, type GatewayParams, type GatewayResponse, type InfiniteChannelMessagesOptions, type InitializeFsaosOptions, type InteractionReceipt, InteractionTrackingError, type ItemVersionsOptions, type ItemVersionsResult, type ItemsFilter, KernelProvider, type LinkParams, type MountRef, type MoveParams, type Notification, type NotificationsOptions, type OpenEnvelope, type OpenOptions, type PathSubscriptionState, type PrincipalData, type PublicSourceConfig, type ResolveItemsResponse, type ResolveParams, type ResolveResponse, type ResolveResultItem, type ResolvedItem, type SessionEntry, type SourceCaptureAdapter, type SourceIdentityStorage, type StartTrackingOptions, type SteerTurnOptions, type SteerTurnResponse, type SteerTurnState, type SubmitFormOptions, type TimelineEvent, type TimelineHistoryEvent, type TimelineHistoryOptions, type TrackEventOptions, type TurnQueueEntry, type TurnQueueEntryState, type TypeDefinition, type TypeHelpers, type TypeSchema, type UnreadCountsOptions, type UpdateParams, type UpdatePrincipalParams, type UploadItem, type UploadOptions, type UploadResult, type UseArtifactStreamReturn, type UseFileUploadReturn, type UseTimelineHistoryReturn, type VFSEdge, type VFSItem, type WorkCorrelation, auth, awaitAnchorReady, awaitScopeReady, callTool, cancelQueuedTurn, cancelTurn, clearCachedToken, clearSession, createItem, disconnectSSE, disposeVfsRealtimeWs, electHomeAnchor, emitEvent, fetchChannelMessages, fetchChannelMessagesPage, fetchChannelMessagesWithCards, fetchEdgesForItem, fetchItemHistory, fetchItemVersions, fetchItems, fetchMemberFocus, fetchOpenEnvelope, fetchRecentActivity, fetchResolvedItems, fetchTimelineHistory, fetchTurnQueueEntries, fetchTypeDefinitions, fetchVfsChildren, fetchVfsChildrenPage, fetchVfsItem, fetchVfsItemById, fetchVfsTree, gatewayCall, getAccessToken, getAnchor, getAnchorRef, getAnchorVersion, getAssetUrl, getDefaultSort, getHomeAnchor, getMountVersion, getMounts, getPathSubscriptionState, getQueryClient, getRequiredFormFields, getScope, getScopeVersion, getSessionEntry, initSession, initVfsRealtimeWs, initializeFsaos, interpretSchema, invalidateAllVfs, invalidateChannelMessages, invalidateChildren, invalidateItem, invalidateOpenEnvelope, invalidatePathAndParent, invalidateSubtree, invalidateTypes, isAnchorReady, isScopeReady, listChildren, mount$1 as mount, mountRealtimeScope, normalizeItem, onConnectionStateChange, pathSubscriptionMatches, ping, pushChanges, queryClient, readItem, registerCleanup, resetAllSdkState, resolvePrincipalId, resubscribePath, setAnchor, setCachedToken, setQueryClient, setScope, setupRequireShim, signal, startTracking, steerTurn, submitForm, subscribeAnchor, subscribeArtifactStream, subscribeMounts, subscribeScope, subscribeToEvents, subscribeToPath, subscribeToScope, trackAction, trackEvent, trackPageView, unmountRealtimeScope, updateItem, uploadFile, useAccounts, useAgentTimeline, useAllChannels, useArrangement, useArtifactStream, useAsset, useAuth, useChannelMessages, useChannels, useChildren, useComponent, useCreate, useDelete, useDmChannels, useEdges, useEventStream, useFileUpload, useInfiniteChannelMessages, useInfiniteChildren, useInfiniteItems, useItem, useItemById, useItemHistory, useItemVersions, useItems, useLink, useList, useMemberFocus, useMounts, useMove, useMutation, useNotifications, useOpen, usePermission, usePermissions, usePrincipal, useRealtimeQuery, useRecentActivity, useResolve, useResolvedItems, useScope, useScopeReady, useSearch, useTheme, useTimelineHistory, useTool, useTree, useType, useTypeHelpers, useTypes, useUnreadCounts, useUpdate, useUpdatePrincipal, vfsKeys, waitForPathReady };
2974
+ export { type AccountInfo, type ArtifactDeltaEvent, type ArtifactDoneEvent, type ArtifactEvent, type ArtifactOpenedEvent, type ArtifactState, type ArtifactStatus, type ArtifactStreamState, type ArtifactSurfaceType, type CancelQueuedTurnOptions, type CancelQueuedTurnResponse, type CancelQueuedTurnState, type CancelTurnOptions, type CancelTurnResponse, type CancelTurnState, type Channel, type ChannelCard, type ChannelMessage, type ChannelMessagesOptions, type ChannelMessagesPage, type ChannelMessagesResponse, type ChannelsOptions, type ComponentOpener, ComponentRenderer, type ConnectionState, type CreateParams, type DeleteParams, EnforcementDeniedError, type EnforcementPayload, type FieldDescriptor, type FileRef, FormSubmissionError, type FormSubmissionReceipt, type FsaosRuntime, type GatewayParams, GatewayRequestError, type GatewayResponse, type InfiniteChannelMessagesOptions, type InitializeFsaosOptions, type InteractionReceipt, InteractionTrackingError, type ItemVersionsOptions, type ItemVersionsResult, type ItemsFilter, KernelProvider, type LinkParams, type MountRef, type MoveParams, type Notification, type NotificationsOptions, type OpenEnvelope, type OpenOptions, type PathSubscriptionState, type PrincipalData, type PublicSourceConfig, type ResolveItemsResponse, type ResolveParams, type ResolveResponse, type ResolveResultItem, type ResolvedItem, type SessionEntry, type SourceCaptureAdapter, type SourceIdentityStorage, type StartTrackingOptions, type SteerTurnOptions, type SteerTurnResponse, type SteerTurnState, type SubmitFormOptions, type TimelineEvent, type TimelineHistoryEvent, type TimelineHistoryOptions, type TrackEventOptions, type TurnQueueEntry, type TurnQueueEntryState, type TypeDefinition, type TypeHelpers, type TypeSchema, type UnreadCountsOptions, type UpdateParams, type UpdatePrincipalParams, type UploadItem, type UploadOptions, type UploadResult, type UseArtifactStreamReturn, type UseFileUploadReturn, type UseTimelineHistoryReturn, type VFSEdge, type VFSItem, type WorkCorrelation, auth, awaitAnchorReady, awaitScopeReady, callTool, cancelQueuedTurn, cancelTurn, clearCachedToken, clearSession, createItem, disconnectSSE, disposeVfsRealtimeWs, electHomeAnchor, emitEvent, fetchChannelMessages, fetchChannelMessagesPage, fetchChannelMessagesWithCards, fetchEdgesForItem, fetchItemHistory, fetchItemVersions, fetchItems, fetchMemberFocus, fetchOpenEnvelope, fetchRecentActivity, fetchResolvedItems, fetchTimelineHistory, fetchTurnQueueEntries, fetchTypeDefinitions, fetchVfsChildren, fetchVfsChildrenPage, fetchVfsItem, fetchVfsItemById, fetchVfsTree, gatewayCall, getAccessToken, getAnchor, getAnchorRef, getAnchorVersion, getAssetUrl, getDefaultSort, getHomeAnchor, getMountVersion, getMounts, getPathSubscriptionState, getQueryClient, getRequiredFormFields, getScope, getScopeVersion, getSessionEntry, initSession, initVfsRealtimeWs, initializeFsaos, interpretSchema, invalidateAllVfs, invalidateChannelMessages, invalidateChildren, invalidateItem, invalidateOpenEnvelope, invalidatePathAndParent, invalidateSubtree, invalidateTypes, isAnchorReady, isScopeReady, listChildren, mount$1 as mount, mountRealtimeScope, normalizeItem, onConnectionStateChange, pathSubscriptionMatches, ping, pushChanges, queryClient, readItem, registerCleanup, resetAllSdkState, resolvePrincipalId, resubscribePath, setAnchor, setCachedToken, setQueryClient, setScope, setupRequireShim, signal, startTracking, steerTurn, submitForm, subscribeAnchor, subscribeArtifactStream, subscribeMounts, subscribeScope, subscribeToEvents, subscribeToPath, subscribeToScope, trackAction, trackEvent, trackPageView, unmountRealtimeScope, updateItem, uploadFile, useAccounts, useAgentTimeline, useAllChannels, useArrangement, useArtifactStream, useAsset, useAuth, useChannelMessages, useChannels, useChildren, useComponent, useCreate, useDelete, useDmChannels, useEdges, useEventStream, useFileUpload, useInfiniteChannelMessages, useInfiniteChildren, useInfiniteItems, useItem, useItemById, useItemHistory, useItemVersions, useItems, useLink, useList, useMemberFocus, useMounts, useMove, useMutation, useNotifications, useOpen, usePermission, usePermissions, usePrincipal, useRealtimeQuery, useRecentActivity, useResolve, useResolvedItems, useScope, useScopeReady, useSearch, useTheme, useTimelineHistory, useTool, useTree, useType, useTypeHelpers, useTypes, useUnreadCounts, useUpdate, useUpdatePrincipal, vfsKeys, waitForPathReady };
package/dist/index.d.ts CHANGED
@@ -519,6 +519,21 @@ declare const isScopeReady: typeof isAnchorReady;
519
519
  * (kernel_caller_confinement — mounts declaration narrows, never widens).
520
520
  */
521
521
 
522
+ declare class GatewayRequestError extends Error {
523
+ readonly name = "GatewayRequestError";
524
+ readonly method: string;
525
+ readonly status: number;
526
+ readonly statusText: string;
527
+ readonly payload: GatewayResponse | null;
528
+ readonly responseBody: string;
529
+ constructor(options: {
530
+ method: string;
531
+ status: number;
532
+ statusText: string;
533
+ payload: GatewayResponse | null;
534
+ responseBody: string;
535
+ });
536
+ }
522
537
  declare function gatewayCall(method: string, params?: GatewayParams): Promise<GatewayResponse>;
523
538
 
524
539
  /**
@@ -2956,4 +2971,4 @@ declare function fetchTimelineHistory(channelPath: string, options?: Pick<Timeli
2956
2971
  */
2957
2972
  declare function useTimelineHistory(channelPath: string | null | undefined, options?: TimelineHistoryOptions): UseTimelineHistoryReturn;
2958
2973
 
2959
- export { type AccountInfo, type ArtifactDeltaEvent, type ArtifactDoneEvent, type ArtifactEvent, type ArtifactOpenedEvent, type ArtifactState, type ArtifactStatus, type ArtifactStreamState, type ArtifactSurfaceType, type CancelQueuedTurnOptions, type CancelQueuedTurnResponse, type CancelQueuedTurnState, type CancelTurnOptions, type CancelTurnResponse, type CancelTurnState, type Channel, type ChannelCard, type ChannelMessage, type ChannelMessagesOptions, type ChannelMessagesPage, type ChannelMessagesResponse, type ChannelsOptions, type ComponentOpener, ComponentRenderer, type ConnectionState, type CreateParams, type DeleteParams, EnforcementDeniedError, type EnforcementPayload, type FieldDescriptor, type FileRef, FormSubmissionError, type FormSubmissionReceipt, type FsaosRuntime, type GatewayParams, type GatewayResponse, type InfiniteChannelMessagesOptions, type InitializeFsaosOptions, type InteractionReceipt, InteractionTrackingError, type ItemVersionsOptions, type ItemVersionsResult, type ItemsFilter, KernelProvider, type LinkParams, type MountRef, type MoveParams, type Notification, type NotificationsOptions, type OpenEnvelope, type OpenOptions, type PathSubscriptionState, type PrincipalData, type PublicSourceConfig, type ResolveItemsResponse, type ResolveParams, type ResolveResponse, type ResolveResultItem, type ResolvedItem, type SessionEntry, type SourceCaptureAdapter, type SourceIdentityStorage, type StartTrackingOptions, type SteerTurnOptions, type SteerTurnResponse, type SteerTurnState, type SubmitFormOptions, type TimelineEvent, type TimelineHistoryEvent, type TimelineHistoryOptions, type TrackEventOptions, type TurnQueueEntry, type TurnQueueEntryState, type TypeDefinition, type TypeHelpers, type TypeSchema, type UnreadCountsOptions, type UpdateParams, type UpdatePrincipalParams, type UploadItem, type UploadOptions, type UploadResult, type UseArtifactStreamReturn, type UseFileUploadReturn, type UseTimelineHistoryReturn, type VFSEdge, type VFSItem, type WorkCorrelation, auth, awaitAnchorReady, awaitScopeReady, callTool, cancelQueuedTurn, cancelTurn, clearCachedToken, clearSession, createItem, disconnectSSE, disposeVfsRealtimeWs, electHomeAnchor, emitEvent, fetchChannelMessages, fetchChannelMessagesPage, fetchChannelMessagesWithCards, fetchEdgesForItem, fetchItemHistory, fetchItemVersions, fetchItems, fetchMemberFocus, fetchOpenEnvelope, fetchRecentActivity, fetchResolvedItems, fetchTimelineHistory, fetchTurnQueueEntries, fetchTypeDefinitions, fetchVfsChildren, fetchVfsChildrenPage, fetchVfsItem, fetchVfsItemById, fetchVfsTree, gatewayCall, getAccessToken, getAnchor, getAnchorRef, getAnchorVersion, getAssetUrl, getDefaultSort, getHomeAnchor, getMountVersion, getMounts, getPathSubscriptionState, getQueryClient, getRequiredFormFields, getScope, getScopeVersion, getSessionEntry, initSession, initVfsRealtimeWs, initializeFsaos, interpretSchema, invalidateAllVfs, invalidateChannelMessages, invalidateChildren, invalidateItem, invalidateOpenEnvelope, invalidatePathAndParent, invalidateSubtree, invalidateTypes, isAnchorReady, isScopeReady, listChildren, mount$1 as mount, mountRealtimeScope, normalizeItem, onConnectionStateChange, pathSubscriptionMatches, ping, pushChanges, queryClient, readItem, registerCleanup, resetAllSdkState, resolvePrincipalId, resubscribePath, setAnchor, setCachedToken, setQueryClient, setScope, setupRequireShim, signal, startTracking, steerTurn, submitForm, subscribeAnchor, subscribeArtifactStream, subscribeMounts, subscribeScope, subscribeToEvents, subscribeToPath, subscribeToScope, trackAction, trackEvent, trackPageView, unmountRealtimeScope, updateItem, uploadFile, useAccounts, useAgentTimeline, useAllChannels, useArrangement, useArtifactStream, useAsset, useAuth, useChannelMessages, useChannels, useChildren, useComponent, useCreate, useDelete, useDmChannels, useEdges, useEventStream, useFileUpload, useInfiniteChannelMessages, useInfiniteChildren, useInfiniteItems, useItem, useItemById, useItemHistory, useItemVersions, useItems, useLink, useList, useMemberFocus, useMounts, useMove, useMutation, useNotifications, useOpen, usePermission, usePermissions, usePrincipal, useRealtimeQuery, useRecentActivity, useResolve, useResolvedItems, useScope, useScopeReady, useSearch, useTheme, useTimelineHistory, useTool, useTree, useType, useTypeHelpers, useTypes, useUnreadCounts, useUpdate, useUpdatePrincipal, vfsKeys, waitForPathReady };
2974
+ export { type AccountInfo, type ArtifactDeltaEvent, type ArtifactDoneEvent, type ArtifactEvent, type ArtifactOpenedEvent, type ArtifactState, type ArtifactStatus, type ArtifactStreamState, type ArtifactSurfaceType, type CancelQueuedTurnOptions, type CancelQueuedTurnResponse, type CancelQueuedTurnState, type CancelTurnOptions, type CancelTurnResponse, type CancelTurnState, type Channel, type ChannelCard, type ChannelMessage, type ChannelMessagesOptions, type ChannelMessagesPage, type ChannelMessagesResponse, type ChannelsOptions, type ComponentOpener, ComponentRenderer, type ConnectionState, type CreateParams, type DeleteParams, EnforcementDeniedError, type EnforcementPayload, type FieldDescriptor, type FileRef, FormSubmissionError, type FormSubmissionReceipt, type FsaosRuntime, type GatewayParams, GatewayRequestError, type GatewayResponse, type InfiniteChannelMessagesOptions, type InitializeFsaosOptions, type InteractionReceipt, InteractionTrackingError, type ItemVersionsOptions, type ItemVersionsResult, type ItemsFilter, KernelProvider, type LinkParams, type MountRef, type MoveParams, type Notification, type NotificationsOptions, type OpenEnvelope, type OpenOptions, type PathSubscriptionState, type PrincipalData, type PublicSourceConfig, type ResolveItemsResponse, type ResolveParams, type ResolveResponse, type ResolveResultItem, type ResolvedItem, type SessionEntry, type SourceCaptureAdapter, type SourceIdentityStorage, type StartTrackingOptions, type SteerTurnOptions, type SteerTurnResponse, type SteerTurnState, type SubmitFormOptions, type TimelineEvent, type TimelineHistoryEvent, type TimelineHistoryOptions, type TrackEventOptions, type TurnQueueEntry, type TurnQueueEntryState, type TypeDefinition, type TypeHelpers, type TypeSchema, type UnreadCountsOptions, type UpdateParams, type UpdatePrincipalParams, type UploadItem, type UploadOptions, type UploadResult, type UseArtifactStreamReturn, type UseFileUploadReturn, type UseTimelineHistoryReturn, type VFSEdge, type VFSItem, type WorkCorrelation, auth, awaitAnchorReady, awaitScopeReady, callTool, cancelQueuedTurn, cancelTurn, clearCachedToken, clearSession, createItem, disconnectSSE, disposeVfsRealtimeWs, electHomeAnchor, emitEvent, fetchChannelMessages, fetchChannelMessagesPage, fetchChannelMessagesWithCards, fetchEdgesForItem, fetchItemHistory, fetchItemVersions, fetchItems, fetchMemberFocus, fetchOpenEnvelope, fetchRecentActivity, fetchResolvedItems, fetchTimelineHistory, fetchTurnQueueEntries, fetchTypeDefinitions, fetchVfsChildren, fetchVfsChildrenPage, fetchVfsItem, fetchVfsItemById, fetchVfsTree, gatewayCall, getAccessToken, getAnchor, getAnchorRef, getAnchorVersion, getAssetUrl, getDefaultSort, getHomeAnchor, getMountVersion, getMounts, getPathSubscriptionState, getQueryClient, getRequiredFormFields, getScope, getScopeVersion, getSessionEntry, initSession, initVfsRealtimeWs, initializeFsaos, interpretSchema, invalidateAllVfs, invalidateChannelMessages, invalidateChildren, invalidateItem, invalidateOpenEnvelope, invalidatePathAndParent, invalidateSubtree, invalidateTypes, isAnchorReady, isScopeReady, listChildren, mount$1 as mount, mountRealtimeScope, normalizeItem, onConnectionStateChange, pathSubscriptionMatches, ping, pushChanges, queryClient, readItem, registerCleanup, resetAllSdkState, resolvePrincipalId, resubscribePath, setAnchor, setCachedToken, setQueryClient, setScope, setupRequireShim, signal, startTracking, steerTurn, submitForm, subscribeAnchor, subscribeArtifactStream, subscribeMounts, subscribeScope, subscribeToEvents, subscribeToPath, subscribeToScope, trackAction, trackEvent, trackPageView, unmountRealtimeScope, updateItem, uploadFile, useAccounts, useAgentTimeline, useAllChannels, useArrangement, useArtifactStream, useAsset, useAuth, useChannelMessages, useChannels, useChildren, useComponent, useCreate, useDelete, useDmChannels, useEdges, useEventStream, useFileUpload, useInfiniteChannelMessages, useInfiniteChildren, useInfiniteItems, useItem, useItemById, useItemHistory, useItemVersions, useItems, useLink, useList, useMemberFocus, useMounts, useMove, useMutation, useNotifications, useOpen, usePermission, usePermissions, usePrincipal, useRealtimeQuery, useRecentActivity, useResolve, useResolvedItems, useScope, useScopeReady, useSearch, useTheme, useTimelineHistory, useTool, useTree, useType, useTypeHelpers, useTypes, useUnreadCounts, useUpdate, useUpdatePrincipal, vfsKeys, waitForPathReady };
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ __export(src_exports, {
18
18
  ComponentRenderer: () => ComponentRenderer,
19
19
  EnforcementDeniedError: () => EnforcementDeniedError,
20
20
  FormSubmissionError: () => FormSubmissionError,
21
+ GatewayRequestError: () => GatewayRequestError,
21
22
  InteractionTrackingError: () => InteractionTrackingError,
22
23
  KernelProvider: () => KernelProvider,
23
24
  QueryClientProvider: () => QueryClientProvider,
@@ -654,6 +655,15 @@ function trackAction(actionId, properties = {}, options = {}) {
654
655
  const adapterProperties = adapter.id_property ? { [adapter.id_property]: actionId } : {};
655
656
  return trackEvent(adapter.observation, { ...properties, ...adapterProperties }, { ...options, source: source.id });
656
657
  }
658
+ function formAttribution() {
659
+ try {
660
+ const source = publicSource();
661
+ adapterFor("form_receipt", source);
662
+ return { visitor_id: visitorId(source), session_id: sessionId(source), source: source.id };
663
+ } catch {
664
+ return void 0;
665
+ }
666
+ }
657
667
  function trackFormReceipt(properties, options = {}) {
658
668
  const source = publicSource(options.source);
659
669
  const adapter = adapterFor("form_receipt", source);
@@ -768,6 +778,26 @@ var ANCHOR_INDEPENDENT_METHODS = /* @__PURE__ */ new Set([
768
778
  "list-memberships",
769
779
  "init"
770
780
  ]);
781
+ var GatewayRequestError = class extends Error {
782
+ name = "GatewayRequestError";
783
+ method;
784
+ status;
785
+ statusText;
786
+ payload;
787
+ responseBody;
788
+ constructor(options) {
789
+ const code = typeof options.payload?.error === "string" ? options.payload.error.trim() : "";
790
+ const detail = typeof options.payload?.message === "string" ? options.payload.message.trim() : "";
791
+ const fallback = options.responseBody.trim() || `Gateway HTTP error: ${options.status} ${options.statusText}`.trim();
792
+ const message = code && detail ? `${code}: ${detail}` : detail || code || fallback;
793
+ super(message);
794
+ this.method = options.method;
795
+ this.status = options.status;
796
+ this.statusText = options.statusText;
797
+ this.payload = options.payload;
798
+ this.responseBody = options.responseBody;
799
+ }
800
+ };
771
801
  async function gatewayCall(method, params = {}) {
772
802
  const hostname = getHostname();
773
803
  const url = `${GATEWAY_URL}/d/${hostname}`;
@@ -795,24 +825,52 @@ async function gatewayCall(method, params = {}) {
795
825
  headers,
796
826
  body: JSON.stringify({ method, params: enrichedParams })
797
827
  });
798
- if (!response.ok) {
799
- throw new Error(`Gateway HTTP error: ${response.status} ${response.statusText}`);
828
+ const responseBody = await response.text();
829
+ let json = null;
830
+ if (responseBody) {
831
+ try {
832
+ json = JSON.parse(responseBody);
833
+ } catch {
834
+ }
835
+ }
836
+ if (!response.ok || !json) {
837
+ throw new GatewayRequestError({
838
+ method,
839
+ status: response.status,
840
+ statusText: response.statusText,
841
+ payload: json,
842
+ responseBody
843
+ });
800
844
  }
801
- const json = await response.json();
802
845
  if (json.success === false) {
803
846
  const err = json.error || "";
804
847
  const deniedBy = json.denied_by || json.error_type || "";
805
848
  if (deniedBy === "rule" || deniedBy === "access" || deniedBy === "entitlement" || err === "RULE_DENIED" || err === "ACCESS_DENIED" || err === "PERMISSION_DENIED" || err === "ENTITLEMENT_REQUIRED") {
806
849
  throw new EnforcementDeniedError(json);
807
850
  }
808
- throw new Error(
809
- json.message || json.error || `Gateway call ${method} failed`
810
- );
851
+ throw new GatewayRequestError({
852
+ method,
853
+ status: response.status,
854
+ statusText: response.statusText,
855
+ payload: json,
856
+ responseBody
857
+ });
811
858
  }
812
859
  return json;
813
860
  }
814
861
 
815
862
  // src/execution-control.ts
863
+ async function executionControlCall(params) {
864
+ try {
865
+ return await gatewayCall("execution-control-transition", params);
866
+ } catch (error) {
867
+ if (!(error instanceof GatewayRequestError) || error.status < 500) {
868
+ throw error;
869
+ }
870
+ await new Promise((resolve) => setTimeout(resolve, 250));
871
+ return gatewayCall("execution-control-transition", params);
872
+ }
873
+ }
816
874
  function withConversationAnchor(response) {
817
875
  const anchor = response.conversation_anchor_item_id ?? response.conversation_root_id;
818
876
  if (!anchor) return response;
@@ -835,7 +893,7 @@ async function cancelTurn(requestMessageId, options = {}) {
835
893
  if (idempotencyKey.length > 128) {
836
894
  throw new TypeError("cancelTurn idempotency key must be 128 characters or fewer");
837
895
  }
838
- const response = await gatewayCall("execution-control-transition", {
896
+ const response = await executionControlCall({
839
897
  op: "request",
840
898
  command: "cancel",
841
899
  delivery: "immediate",
@@ -865,7 +923,7 @@ async function steerTurn(requestMessageId, selectedQueueEntryId, options = {}) {
865
923
  if (idempotencyKey.length > 128) {
866
924
  throw new TypeError("steerTurn idempotency key must be 128 characters or fewer");
867
925
  }
868
- const response = await gatewayCall("execution-control-transition", {
926
+ const response = await executionControlCall({
869
927
  op: "request",
870
928
  command: "steer",
871
929
  delivery: "immediate",
@@ -889,7 +947,7 @@ async function cancelQueuedTurn(queueEntryId, options = {}) {
889
947
  if (idempotencyKey.length > 128) {
890
948
  throw new TypeError("cancelQueuedTurn idempotency key must be 128 characters or fewer");
891
949
  }
892
- const response = await gatewayCall("execution-control-transition", {
950
+ const response = await executionControlCall({
893
951
  op: "cancel_queue_entry",
894
952
  queue_entry_id: target,
895
953
  idempotency_key: idempotencyKey,
@@ -934,6 +992,8 @@ async function submitForm(capabilityId, fields, options = {}) {
934
992
  throw new TypeError("pageUrl is required outside a browser");
935
993
  }
936
994
  const endpoint = `${GATEWAY_URL.replace(/\/+$/, "")}/d/${encodeURIComponent(hostname)}/actions/${encodeURIComponent(capabilityId)}`;
995
+ const identity = formAttribution();
996
+ const attribution = identity ? { visitor_id: identity.visitor_id, session_id: identity.session_id } : void 0;
937
997
  let response;
938
998
  try {
939
999
  response = await fetch(endpoint, {
@@ -942,7 +1002,7 @@ async function submitForm(capabilityId, fields, options = {}) {
942
1002
  "Content-Type": "application/json",
943
1003
  "Accept": "application/json"
944
1004
  },
945
- body: JSON.stringify({ fill_id: fillId, page_url: pageUrl, fields }),
1005
+ body: JSON.stringify({ fill_id: fillId, page_url: pageUrl, fields, ...attribution ? { attribution } : {} }),
946
1006
  signal: options.signal,
947
1007
  credentials: "omit"
948
1008
  });
@@ -973,7 +1033,7 @@ async function submitForm(capabilityId, fields, options = {}) {
973
1033
  fill_id: fillId,
974
1034
  action_id: capabilityId,
975
1035
  release_id: payload.release_id
976
- }, { eventId: fillId, pageUrl, signal: options.signal, keepalive: true });
1036
+ }, { eventId: fillId, pageUrl, signal: options.signal, keepalive: true, ...identity ? { source: identity.source, visitorId: identity.visitor_id, sessionId: identity.session_id } : {} });
977
1037
  } catch {
978
1038
  }
979
1039
  return payload;
@@ -4642,6 +4702,6 @@ function normalizeRow(row) {
4642
4702
  // src/index.ts
4643
4703
  __registerSdkExports(src_exports);
4644
4704
 
4645
- export { ComponentRenderer, EnforcementDeniedError, FormSubmissionError, InteractionTrackingError, KernelProvider, auth, awaitAnchorReady, awaitScopeReady, callTool, cancelQueuedTurn, cancelTurn, clearCachedToken, clearSession, createItem, disconnectSSE, disposeVfsRealtimeWs, electHomeAnchor, emitEvent, fetchChannelMessages, fetchChannelMessagesPage, fetchChannelMessagesWithCards, fetchEdgesForItem, fetchItemHistory, fetchItemVersions, fetchItems, fetchMemberFocus, fetchOpenEnvelope, fetchRecentActivity, fetchResolvedItems, fetchTimelineHistory, fetchTurnQueueEntries, fetchTypeDefinitions, fetchVfsChildren, fetchVfsChildrenPage, fetchVfsItem, fetchVfsItemById, fetchVfsTree, gatewayCall, getAccessToken, getAnchor, getAnchorRef, getAnchorVersion, getAssetUrl, getDefaultSort, getHomeAnchor, getMountVersion, getMounts, getPathSubscriptionState, getQueryClient, getRequiredFormFields, getScope, getScopeVersion, getSessionEntry, initSession, initVfsRealtimeWs, initializeFsaos, interpretSchema, invalidateAllVfs, invalidateChannelMessages, invalidateChildren, invalidateItem, invalidateOpenEnvelope, invalidatePathAndParent, invalidateSubtree, invalidateTypes, isAnchorReady, isScopeReady, listChildren, mount, mountRealtimeScope, normalizeItem, onConnectionStateChange, pathSubscriptionMatches, ping, pushChanges, queryClient, readItem, registerCleanup, resetAllSdkState, resolvePrincipalId, resubscribePath, setAnchor, setCachedToken, setQueryClient, setScope, setupRequireShim, signal, startTracking, steerTurn, submitForm, subscribeAnchor, subscribeArtifactStream, subscribeMounts, subscribeScope, subscribeToEvents, subscribeToPath, subscribeToScope, trackAction, trackEvent, trackPageView, unmountRealtimeScope, updateItem, uploadFile, useAccounts, useAgentTimeline, useAllChannels, useArrangement, useArtifactStream, useAsset, useAuth, useChannelMessages, useChannels, useChildren, useComponent, useCreate, useDelete, useDmChannels, useEdges, useEventStream, useFileUpload, useInfiniteChannelMessages, useInfiniteChildren, useInfiniteItems, useItem, useItemById, useItemHistory, useItemVersions, useItems, useLink, useList, useMemberFocus, useMounts, useMove, useMutation, useNotifications, useOpen, usePermission, usePermissions, usePrincipal, useRealtimeQuery, useRecentActivity, useResolve, useResolvedItems, useScope, useScopeReady, useSearch, useTheme, useTimelineHistory, useTool, useTree, useType, useTypeHelpers, useTypes, useUnreadCounts, useUpdate, useUpdatePrincipal, vfsKeys, waitForPathReady };
4705
+ export { ComponentRenderer, EnforcementDeniedError, FormSubmissionError, GatewayRequestError, InteractionTrackingError, KernelProvider, auth, awaitAnchorReady, awaitScopeReady, callTool, cancelQueuedTurn, cancelTurn, clearCachedToken, clearSession, createItem, disconnectSSE, disposeVfsRealtimeWs, electHomeAnchor, emitEvent, fetchChannelMessages, fetchChannelMessagesPage, fetchChannelMessagesWithCards, fetchEdgesForItem, fetchItemHistory, fetchItemVersions, fetchItems, fetchMemberFocus, fetchOpenEnvelope, fetchRecentActivity, fetchResolvedItems, fetchTimelineHistory, fetchTurnQueueEntries, fetchTypeDefinitions, fetchVfsChildren, fetchVfsChildrenPage, fetchVfsItem, fetchVfsItemById, fetchVfsTree, gatewayCall, getAccessToken, getAnchor, getAnchorRef, getAnchorVersion, getAssetUrl, getDefaultSort, getHomeAnchor, getMountVersion, getMounts, getPathSubscriptionState, getQueryClient, getRequiredFormFields, getScope, getScopeVersion, getSessionEntry, initSession, initVfsRealtimeWs, initializeFsaos, interpretSchema, invalidateAllVfs, invalidateChannelMessages, invalidateChildren, invalidateItem, invalidateOpenEnvelope, invalidatePathAndParent, invalidateSubtree, invalidateTypes, isAnchorReady, isScopeReady, listChildren, mount, mountRealtimeScope, normalizeItem, onConnectionStateChange, pathSubscriptionMatches, ping, pushChanges, queryClient, readItem, registerCleanup, resetAllSdkState, resolvePrincipalId, resubscribePath, setAnchor, setCachedToken, setQueryClient, setScope, setupRequireShim, signal, startTracking, steerTurn, submitForm, subscribeAnchor, subscribeArtifactStream, subscribeMounts, subscribeScope, subscribeToEvents, subscribeToPath, subscribeToScope, trackAction, trackEvent, trackPageView, unmountRealtimeScope, updateItem, uploadFile, useAccounts, useAgentTimeline, useAllChannels, useArrangement, useArtifactStream, useAsset, useAuth, useChannelMessages, useChannels, useChildren, useComponent, useCreate, useDelete, useDmChannels, useEdges, useEventStream, useFileUpload, useInfiniteChannelMessages, useInfiniteChildren, useInfiniteItems, useItem, useItemById, useItemHistory, useItemVersions, useItems, useLink, useList, useMemberFocus, useMounts, useMove, useMutation, useNotifications, useOpen, usePermission, usePermissions, usePrincipal, useRealtimeQuery, useRecentActivity, useResolve, useResolvedItems, useScope, useScopeReady, useSearch, useTheme, useTimelineHistory, useTool, useTree, useType, useTypeHelpers, useTypes, useUnreadCounts, useUpdate, useUpdatePrincipal, vfsKeys, waitForPathReady };
4646
4706
  //# sourceMappingURL=index.js.map
4647
4707
  //# sourceMappingURL=index.js.map