@ai4b-team/fsaos-gateway-sdk 3.26.2 → 3.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -2464,6 +2464,56 @@ declare function useArrangement(paramsOrPath: string | {
2464
2464
  fetchStatus: _tanstack_react_query.FetchStatus;
2465
2465
  promise: Promise<any>;
2466
2466
  };
2467
+ /** The honest life of a tool-produced file, as the system actually reports it. */
2468
+ type MintedAssetState = 'idle' | 'pending' | 'materializing' | 'ready' | 'failed';
2469
+ interface MintedAsset {
2470
+ state: MintedAssetState;
2471
+ /** Set when `asset.materialized` identifies the durable item. */
2472
+ itemId?: string;
2473
+ itemPath?: string;
2474
+ displayName?: string;
2475
+ /** The tool's transient provider URL. Correct immediately; may expire. */
2476
+ fallbackUrl?: string;
2477
+ error?: string;
2478
+ }
2479
+ /**
2480
+ * Follow a tool result's file from "the tool returned" to "safe to render".
2481
+ *
2482
+ * WHY THIS EXISTS. A media tool returns a provider URL AND mints a durable FSAOS
2483
+ * asset, but the mint completes *after* the reply — deliberately, because waiting
2484
+ * in-reply just delays the user's answer. So at card-render time the asset does
2485
+ * not exist yet. Cards that looked for it found nothing and showed a bare link;
2486
+ * cards that showed the provider URL displayed something that later expires.
2487
+ *
2488
+ * The producer announces completion instead of the consumer asking: `kernel_signal`
2489
+ * emits `asset.materialized` when an item lands, carrying `origin` (the message
2490
+ * path that produced it) and `has_bytes`. Byte fetch is a separate async step, so
2491
+ * `has_bytes:false` is normal on arrival — `content.written` follows. Those two
2492
+ * events are what separate "saving" from "ready", and why this hook never claims
2493
+ * a file is displayable before its bytes exist.
2494
+ *
2495
+ * Correlation is by ORIGIN (the producing message), not by path or name, so a
2496
+ * rename or a move cannot break the link.
2497
+ *
2498
+ * NOTE ON CONNECTIONS: subscribeToEvents is a local listener — it does not open a
2499
+ * socket by itself and silently receives nothing unless a scope/path subscription
2500
+ * exists. That failure is invisible (a skeleton that never resolves), so this hook
2501
+ * holds its own scope subscription for as long as it is waiting. An indexed,
2502
+ * account-scoped asset lookup closes the startup/history gap when the
2503
+ * materialization event arrived before this consumer subscribed.
2504
+ */
2505
+ declare function useMintedAsset(params: {
2506
+ /** `fsaos_origin_message_path` — the message that produced the file. */
2507
+ origin?: string | null;
2508
+ /** The tool's own URL, shown while the durable asset is still landing. */
2509
+ fallbackUrl?: string | null;
2510
+ /** The producer's mint error, if it reported one. */
2511
+ mintError?: string | null;
2512
+ /** Scope to subscribe under — required for the socket to be open. */
2513
+ scopeId?: string | null;
2514
+ /** Account scope path for indexed historical recovery. */
2515
+ scopePath?: string | null;
2516
+ }): MintedAsset;
2467
2517
 
2468
2518
  /**
2469
2519
  * @fsaos/gateway — Schema Interpretation Utilities
@@ -2971,4 +3021,4 @@ declare function fetchTimelineHistory(channelPath: string, options?: Pick<Timeli
2971
3021
  */
2972
3022
  declare function useTimelineHistory(channelPath: string | null | undefined, options?: TimelineHistoryOptions): UseTimelineHistoryReturn;
2973
3023
 
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 };
3024
+ 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 MintedAsset, type MintedAssetState, 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, useMintedAsset, 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
@@ -2464,6 +2464,56 @@ declare function useArrangement(paramsOrPath: string | {
2464
2464
  fetchStatus: _tanstack_react_query.FetchStatus;
2465
2465
  promise: Promise<any>;
2466
2466
  };
2467
+ /** The honest life of a tool-produced file, as the system actually reports it. */
2468
+ type MintedAssetState = 'idle' | 'pending' | 'materializing' | 'ready' | 'failed';
2469
+ interface MintedAsset {
2470
+ state: MintedAssetState;
2471
+ /** Set when `asset.materialized` identifies the durable item. */
2472
+ itemId?: string;
2473
+ itemPath?: string;
2474
+ displayName?: string;
2475
+ /** The tool's transient provider URL. Correct immediately; may expire. */
2476
+ fallbackUrl?: string;
2477
+ error?: string;
2478
+ }
2479
+ /**
2480
+ * Follow a tool result's file from "the tool returned" to "safe to render".
2481
+ *
2482
+ * WHY THIS EXISTS. A media tool returns a provider URL AND mints a durable FSAOS
2483
+ * asset, but the mint completes *after* the reply — deliberately, because waiting
2484
+ * in-reply just delays the user's answer. So at card-render time the asset does
2485
+ * not exist yet. Cards that looked for it found nothing and showed a bare link;
2486
+ * cards that showed the provider URL displayed something that later expires.
2487
+ *
2488
+ * The producer announces completion instead of the consumer asking: `kernel_signal`
2489
+ * emits `asset.materialized` when an item lands, carrying `origin` (the message
2490
+ * path that produced it) and `has_bytes`. Byte fetch is a separate async step, so
2491
+ * `has_bytes:false` is normal on arrival — `content.written` follows. Those two
2492
+ * events are what separate "saving" from "ready", and why this hook never claims
2493
+ * a file is displayable before its bytes exist.
2494
+ *
2495
+ * Correlation is by ORIGIN (the producing message), not by path or name, so a
2496
+ * rename or a move cannot break the link.
2497
+ *
2498
+ * NOTE ON CONNECTIONS: subscribeToEvents is a local listener — it does not open a
2499
+ * socket by itself and silently receives nothing unless a scope/path subscription
2500
+ * exists. That failure is invisible (a skeleton that never resolves), so this hook
2501
+ * holds its own scope subscription for as long as it is waiting. An indexed,
2502
+ * account-scoped asset lookup closes the startup/history gap when the
2503
+ * materialization event arrived before this consumer subscribed.
2504
+ */
2505
+ declare function useMintedAsset(params: {
2506
+ /** `fsaos_origin_message_path` — the message that produced the file. */
2507
+ origin?: string | null;
2508
+ /** The tool's own URL, shown while the durable asset is still landing. */
2509
+ fallbackUrl?: string | null;
2510
+ /** The producer's mint error, if it reported one. */
2511
+ mintError?: string | null;
2512
+ /** Scope to subscribe under — required for the socket to be open. */
2513
+ scopeId?: string | null;
2514
+ /** Account scope path for indexed historical recovery. */
2515
+ scopePath?: string | null;
2516
+ }): MintedAsset;
2467
2517
 
2468
2518
  /**
2469
2519
  * @fsaos/gateway — Schema Interpretation Utilities
@@ -2971,4 +3021,4 @@ declare function fetchTimelineHistory(channelPath: string, options?: Pick<Timeli
2971
3021
  */
2972
3022
  declare function useTimelineHistory(channelPath: string | null | undefined, options?: TimelineHistoryOptions): UseTimelineHistoryReturn;
2973
3023
 
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 };
3024
+ 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 MintedAsset, type MintedAssetState, 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, useMintedAsset, 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
@@ -1,7 +1,7 @@
1
1
  import { createClient } from '@supabase/supabase-js';
2
2
  import { QueryClient, QueryClientProvider, useQuery, useInfiniteQuery, useQueryClient, useMutation as useMutation$1 } from '@tanstack/react-query';
3
3
  export { QueryClientProvider } from '@tanstack/react-query';
4
- import React, { createElement, useMemo, useState, useEffect, useRef, useSyncExternalStore, useCallback } from 'react';
4
+ import React, { createElement, useMemo, useState, useEffect, useRef, useSyncExternalStore, useCallback, useLayoutEffect } from 'react';
5
5
  import { createRoot } from 'react-dom/client';
6
6
  import * as ReactDOM from 'react-dom';
7
7
  import * as JsxRuntime from 'react/jsx-runtime';
@@ -148,6 +148,7 @@ __export(src_exports, {
148
148
  useLink: () => useLink,
149
149
  useList: () => useList,
150
150
  useMemberFocus: () => useMemberFocus,
151
+ useMintedAsset: () => useMintedAsset,
151
152
  useMounts: () => useMounts,
152
153
  useMove: () => useMove,
153
154
  useMutation: () => useMutation,
@@ -1750,7 +1751,29 @@ function pathSubscriptionMatches(subscribedPath, eventPath) {
1750
1751
  }
1751
1752
  var typedListeners = [];
1752
1753
  var activeScopes = /* @__PURE__ */ new Map();
1754
+ var scopeLeases = /* @__PURE__ */ new Map();
1753
1755
  var activePaths = /* @__PURE__ */ new Map();
1756
+ function scopeEventTypes(scopeId) {
1757
+ const leases = scopeLeases.get(scopeId);
1758
+ if (!leases) return [];
1759
+ return Array.from(
1760
+ new Set(Array.from(leases.values()).flatMap((lease) => lease.event_types))
1761
+ ).sort();
1762
+ }
1763
+ function sameEventTypes(a, b) {
1764
+ if (!a) return false;
1765
+ return a.length === b.length && a.every((eventType, index) => eventType === b[index]);
1766
+ }
1767
+ function refreshScopeSubscription(scopeId) {
1768
+ const eventTypes = scopeEventTypes(scopeId);
1769
+ if (eventTypes.length === 0) {
1770
+ activeScopes.delete(scopeId);
1771
+ return null;
1772
+ }
1773
+ const subscription = { scope_id: scopeId, event_types: eventTypes };
1774
+ activeScopes.set(scopeId, subscription);
1775
+ return subscription;
1776
+ }
1754
1777
  var pathStates = /* @__PURE__ */ new Map();
1755
1778
  var pathReadyWaiters = /* @__PURE__ */ new Map();
1756
1779
  var connectionState = "disconnected";
@@ -2010,15 +2033,47 @@ function subscribeToEvents(eventType, callback, filter) {
2010
2033
  };
2011
2034
  }
2012
2035
  function subscribeToScope(scopeId, eventTypes = ["vfs_change", "ccm_change"]) {
2013
- log("subscribeToScope:", scopeId, eventTypes);
2014
- activeScopes.set(scopeId, { scope_id: scopeId, event_types: eventTypes });
2015
- if (ws && ws.readyState === WebSocket.OPEN) {
2016
- sendMessage({ type: "subscribe", scope_id: scopeId, event_types: eventTypes });
2036
+ const leaseId = Symbol(scopeId);
2037
+ const normalizedEventTypes = Array.from(new Set(eventTypes)).sort();
2038
+ if (normalizedEventTypes.length === 0) return () => {
2039
+ };
2040
+ const leases = scopeLeases.get(scopeId) ?? /* @__PURE__ */ new Map();
2041
+ const previousEventTypes = activeScopes.get(scopeId)?.event_types;
2042
+ leases.set(leaseId, { event_types: normalizedEventTypes });
2043
+ scopeLeases.set(scopeId, leases);
2044
+ const subscription = refreshScopeSubscription(scopeId);
2045
+ if (!subscription) return () => {
2046
+ };
2047
+ log("subscribeToScope:", scopeId, subscription.event_types);
2048
+ if (ws && ws.readyState === WebSocket.OPEN && !sameEventTypes(previousEventTypes, subscription.event_types)) {
2049
+ sendMessage({
2050
+ type: "subscribe",
2051
+ scope_id: scopeId,
2052
+ event_types: subscription.event_types
2053
+ });
2017
2054
  }
2018
2055
  ensureConnection();
2056
+ let active = true;
2019
2057
  return () => {
2020
- activeScopes.delete(scopeId);
2021
- sendMessage({ type: "unsubscribe", scope_id: scopeId });
2058
+ if (!active) return;
2059
+ active = false;
2060
+ const currentLeases = scopeLeases.get(scopeId);
2061
+ if (!currentLeases?.delete(leaseId)) return;
2062
+ const previous = activeScopes.get(scopeId)?.event_types;
2063
+ if (currentLeases.size === 0) {
2064
+ scopeLeases.delete(scopeId);
2065
+ activeScopes.delete(scopeId);
2066
+ sendMessage({ type: "unsubscribe", scope_id: scopeId });
2067
+ } else {
2068
+ const next = refreshScopeSubscription(scopeId);
2069
+ if (next && ws && ws.readyState === WebSocket.OPEN && !sameEventTypes(previous, next.event_types)) {
2070
+ sendMessage({
2071
+ type: "subscribe",
2072
+ scope_id: scopeId,
2073
+ event_types: next.event_types
2074
+ });
2075
+ }
2076
+ }
2022
2077
  maybeDisconnect();
2023
2078
  };
2024
2079
  }
@@ -2045,6 +2100,7 @@ function disconnectSSE() {
2045
2100
  }
2046
2101
  typedListeners.length = 0;
2047
2102
  activeScopes.clear();
2103
+ scopeLeases.clear();
2048
2104
  activePaths.clear();
2049
2105
  pathStates.clear();
2050
2106
  pathReadyWaiters.clear();
@@ -4041,6 +4097,165 @@ function useArrangement(paramsOrPath) {
4041
4097
  applyTo
4042
4098
  };
4043
4099
  }
4100
+ function useMintedAsset(params) {
4101
+ const { origin, fallbackUrl, mintError, scopeId, scopePath } = params;
4102
+ const sdkGeneration = useScopeKey();
4103
+ const session = getSessionEntry();
4104
+ const resolvedScopeId = scopeId ?? session?.scope_id ?? null;
4105
+ const originAccountScope = useMemo(() => {
4106
+ if (!origin) return null;
4107
+ const marker = "/accounts/";
4108
+ const markerIndex = origin.indexOf(marker);
4109
+ if (markerIndex === -1) return null;
4110
+ const accountEnd = origin.indexOf("/", markerIndex + marker.length);
4111
+ return accountEnd === -1 ? origin : origin.slice(0, accountEnd);
4112
+ }, [origin]);
4113
+ const resolvedScopePath = scopePath ?? originAccountScope ?? session?.scope_path ?? null;
4114
+ const correlationKey = `${sdkGeneration}
4115
+ ${resolvedScopeId ?? ""}
4116
+ ${resolvedScopePath ?? ""}
4117
+ ${origin ?? ""}`;
4118
+ const [found, setFound] = useState(null);
4119
+ const activeRef = useRef({
4120
+ key: correlationKey,
4121
+ found: null,
4122
+ earlyContentPaths: /* @__PURE__ */ new Set()
4123
+ });
4124
+ const currentFound = found?.key === correlationKey ? found : null;
4125
+ useLayoutEffect(() => {
4126
+ activeRef.current = {
4127
+ key: correlationKey,
4128
+ found: currentFound,
4129
+ earlyContentPaths: /* @__PURE__ */ new Set()
4130
+ };
4131
+ }, [correlationKey]);
4132
+ const recovery = useQuery({
4133
+ queryKey: [
4134
+ "vfs",
4135
+ resolvedScopePath ?? "__unscoped__",
4136
+ "minted-asset",
4137
+ origin ?? ""
4138
+ ],
4139
+ queryFn: async () => {
4140
+ const response = await gatewayCall("query", {
4141
+ scope_path: resolvedScopePath,
4142
+ filters: { "field.fsaos_origin_message_path": origin },
4143
+ limit: 1
4144
+ });
4145
+ const rawItems = response.content?.items ?? response.items ?? [];
4146
+ const asset = rawItems[0] ? normalizeItem(rawItems[0]) : null;
4147
+ if (!asset) return null;
4148
+ const children = await fetchVfsChildren(asset.path);
4149
+ const hasBytes = children.some(
4150
+ (child) => child.item_type === "file" && Boolean(child.type_data?.file_ref)
4151
+ );
4152
+ return { asset, hasBytes };
4153
+ },
4154
+ enabled: Boolean(origin && resolvedScopePath && !mintError),
4155
+ refetchInterval: (query) => {
4156
+ if (activeRef.current.key === correlationKey && activeRef.current.found?.hasBytes) {
4157
+ return false;
4158
+ }
4159
+ return query.state.data?.hasBytes ? false : 1500;
4160
+ }
4161
+ });
4162
+ useEffect(() => {
4163
+ const recovered = recovery.data;
4164
+ if (!recovered || activeRef.current.key !== correlationKey) return;
4165
+ const previous = activeRef.current.found;
4166
+ const next = {
4167
+ key: correlationKey,
4168
+ itemId: recovered.asset.id,
4169
+ itemPath: recovered.asset.path,
4170
+ displayName: typeof recovered.asset.type_data?.display_name === "string" ? recovered.asset.type_data.display_name : recovered.asset.name,
4171
+ hasBytes: recovered.hasBytes || Boolean(previous?.itemId === recovered.asset.id && previous.hasBytes)
4172
+ };
4173
+ activeRef.current.found = next;
4174
+ setFound(next);
4175
+ }, [recovery.data, correlationKey]);
4176
+ const waiting = Boolean(origin && resolvedScopeId) && !mintError && !currentFound?.hasBytes;
4177
+ useEffect(() => {
4178
+ if (!waiting || !resolvedScopeId) return;
4179
+ return subscribeToScope(
4180
+ resolvedScopeId,
4181
+ ["asset.materialized", "content.written"]
4182
+ );
4183
+ }, [waiting, resolvedScopeId]);
4184
+ useEffect(() => {
4185
+ if (!waiting || !origin || !resolvedScopeId) return;
4186
+ const generationKey = correlationKey;
4187
+ const payload = (data) => data?.payload ?? data;
4188
+ const eventScope = (data) => {
4189
+ const p = payload(data);
4190
+ const value = p?.scope_id ?? data?.scope_id;
4191
+ return typeof value === "string" ? value : void 0;
4192
+ };
4193
+ const contentPath = (data) => {
4194
+ const p = payload(data);
4195
+ const value = p?.item_path ?? data?.item_path;
4196
+ return typeof value === "string" && value ? value : void 0;
4197
+ };
4198
+ const belongsToAsset = (itemPath, assetPath) => {
4199
+ const normalizedAssetPath = assetPath.replace(/\/+$/, "");
4200
+ return itemPath === normalizedAssetPath || itemPath.startsWith(`${normalizedAssetPath}/`);
4201
+ };
4202
+ const unsubscribes = [
4203
+ subscribeToEvents("asset.materialized", (data) => {
4204
+ if (activeRef.current.key !== generationKey) return;
4205
+ const p = payload(data);
4206
+ if (typeof p?.item_id !== "string" || !p.item_id) return;
4207
+ const previous = activeRef.current.found;
4208
+ const itemPath = typeof p.item_path === "string" ? p.item_path : void 0;
4209
+ const hasBytes = Boolean(p.has_bytes) || Boolean(
4210
+ itemPath && Array.from(activeRef.current.earlyContentPaths).some((path) => belongsToAsset(path, itemPath))
4211
+ ) || Boolean(previous && previous.itemId === p.item_id && previous.hasBytes);
4212
+ const next = {
4213
+ key: generationKey,
4214
+ itemId: p.item_id,
4215
+ itemPath,
4216
+ displayName: typeof p.display_name === "string" ? p.display_name : void 0,
4217
+ hasBytes
4218
+ };
4219
+ activeRef.current.found = next;
4220
+ setFound(next);
4221
+ }, (data) => {
4222
+ const scope = eventScope(data);
4223
+ return (!scope || scope === resolvedScopeId) && payload(data)?.origin === origin;
4224
+ }),
4225
+ subscribeToEvents("content.written", (data) => {
4226
+ if (activeRef.current.key !== generationKey) return;
4227
+ const itemPath = contentPath(data);
4228
+ if (!itemPath) return;
4229
+ const previous = activeRef.current.found;
4230
+ if (!previous?.itemPath || !belongsToAsset(itemPath, previous.itemPath)) {
4231
+ activeRef.current.earlyContentPaths.add(itemPath);
4232
+ if (activeRef.current.earlyContentPaths.size > 128) {
4233
+ const oldest = activeRef.current.earlyContentPaths.values().next().value;
4234
+ if (oldest) activeRef.current.earlyContentPaths.delete(oldest);
4235
+ }
4236
+ return;
4237
+ }
4238
+ if (previous.hasBytes) return;
4239
+ const next = { ...previous, hasBytes: true };
4240
+ activeRef.current.found = next;
4241
+ setFound(next);
4242
+ }, (data) => {
4243
+ const scope = eventScope(data);
4244
+ return (!scope || scope === resolvedScopeId) && Boolean(contentPath(data));
4245
+ })
4246
+ ];
4247
+ return () => unsubscribes.forEach((fn) => fn());
4248
+ }, [waiting, origin, resolvedScopeId, correlationKey]);
4249
+ const state = mintError ? "failed" : !origin ? "idle" : currentFound ? currentFound.hasBytes ? "ready" : "materializing" : "pending";
4250
+ return {
4251
+ state,
4252
+ itemId: currentFound?.itemId,
4253
+ itemPath: currentFound?.itemPath,
4254
+ displayName: currentFound?.displayName,
4255
+ fallbackUrl: fallbackUrl ?? void 0,
4256
+ error: mintError ?? void 0
4257
+ };
4258
+ }
4044
4259
 
4045
4260
  // src/schema-utils.ts
4046
4261
  function keyToLabel(key) {
@@ -4702,6 +4917,6 @@ function normalizeRow(row) {
4702
4917
  // src/index.ts
4703
4918
  __registerSdkExports(src_exports);
4704
4919
 
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 };
4920
+ 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, useMintedAsset, 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 };
4706
4921
  //# sourceMappingURL=index.js.map
4707
4922
  //# sourceMappingURL=index.js.map