@ai4b-team/fsaos-gateway-sdk 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/README.md +157 -0
- package/dist/iife/gateway.js +12 -0
- package/dist/iife/gateway.js.map +7 -0
- package/dist/iife/ui.js +3 -0
- package/dist/iife/ui.js.map +7 -0
- package/dist/index.cjs +3220 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1806 -0
- package/dist/index.d.ts +1806 -0
- package/dist/index.js +3079 -0
- package/dist/index.js.map +1 -0
- package/dist/ui.cjs +201 -0
- package/dist/ui.cjs.map +1 -0
- package/dist/ui.d.cts +243 -0
- package/dist/ui.d.ts +243 -0
- package/dist/ui.js +180 -0
- package/dist/ui.js.map +1 -0
- package/package.json +92 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1806 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
export { QueryClientProvider } from '@tanstack/react-query';
|
|
4
|
+
import * as _supabase_supabase_js from '@supabase/supabase-js';
|
|
5
|
+
import react__default from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @fsaos/gateway — Type Definitions
|
|
9
|
+
*
|
|
10
|
+
* All types used by the gateway SDK. These are inferred from the deployed
|
|
11
|
+
* gateway.js bundle and the VFS data structures it operates on.
|
|
12
|
+
*/
|
|
13
|
+
/** A normalized VFS item as returned by all gateway read operations. */
|
|
14
|
+
interface VFSItem {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
item_type: string;
|
|
18
|
+
path: string;
|
|
19
|
+
parent_path: string;
|
|
20
|
+
is_active: boolean;
|
|
21
|
+
has_children: boolean;
|
|
22
|
+
created_at: string;
|
|
23
|
+
updated_at: string;
|
|
24
|
+
visibility?: string;
|
|
25
|
+
type_data: Record<string, any>;
|
|
26
|
+
scope_item_id?: string;
|
|
27
|
+
fractal_id?: string;
|
|
28
|
+
parent_instance_id?: string;
|
|
29
|
+
owner_principal_id?: string;
|
|
30
|
+
created_by_principal_id?: string;
|
|
31
|
+
parent_id?: string;
|
|
32
|
+
}
|
|
33
|
+
/** A type definition from the os_item_types registry. */
|
|
34
|
+
interface TypeDefinition {
|
|
35
|
+
type_key: string;
|
|
36
|
+
display_name: string;
|
|
37
|
+
display_name_plural: string;
|
|
38
|
+
icon: string;
|
|
39
|
+
color: string;
|
|
40
|
+
description: string;
|
|
41
|
+
/** User-editable fields schema (JSON Schema). */
|
|
42
|
+
input_schema: Record<string, any>;
|
|
43
|
+
/** System-managed fields schema (JSON Schema). */
|
|
44
|
+
system_schema: Record<string, any>;
|
|
45
|
+
/** @deprecated Use input_schema/system_schema instead. */
|
|
46
|
+
json_schema: Record<string, any>;
|
|
47
|
+
default_data: Record<string, any>;
|
|
48
|
+
field_defaults: Record<string, any>;
|
|
49
|
+
renderer_config: Record<string, any>;
|
|
50
|
+
is_system: boolean;
|
|
51
|
+
is_active: boolean;
|
|
52
|
+
is_container: boolean;
|
|
53
|
+
is_scope: boolean;
|
|
54
|
+
render_mode: string;
|
|
55
|
+
placement_mode?: string;
|
|
56
|
+
direct_parent_types?: string[];
|
|
57
|
+
allowed_parent_types?: string[];
|
|
58
|
+
governed_create?: boolean;
|
|
59
|
+
create_method?: string;
|
|
60
|
+
dedup?: Record<string, any>;
|
|
61
|
+
edges?: any[];
|
|
62
|
+
events?: Record<string, any>;
|
|
63
|
+
}
|
|
64
|
+
/** A VFS edge (relationship between two items). */
|
|
65
|
+
interface VFSEdge {
|
|
66
|
+
id: string;
|
|
67
|
+
source_item_id: string;
|
|
68
|
+
target_item_id: string;
|
|
69
|
+
edge_type: string;
|
|
70
|
+
weight: number;
|
|
71
|
+
context: Record<string, any>;
|
|
72
|
+
is_active: boolean;
|
|
73
|
+
is_bidirectional?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/** The session entry returned by initSession (domain-scoped). */
|
|
76
|
+
interface SessionEntry {
|
|
77
|
+
scope_id: string;
|
|
78
|
+
scope_path: string;
|
|
79
|
+
instance_path: string;
|
|
80
|
+
fractal_id: string | null;
|
|
81
|
+
instance_name: string | null;
|
|
82
|
+
display_name: string | null;
|
|
83
|
+
}
|
|
84
|
+
/** Raw error payload from the gateway when enforcement denies a request. */
|
|
85
|
+
interface EnforcementPayload {
|
|
86
|
+
success: false;
|
|
87
|
+
error?: string;
|
|
88
|
+
message?: string;
|
|
89
|
+
denied_by?: string;
|
|
90
|
+
error_type?: string;
|
|
91
|
+
enforcement?: {
|
|
92
|
+
rule_key?: string;
|
|
93
|
+
display_name?: string;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** Parameters for a gateway RPC call. */
|
|
97
|
+
type GatewayParams = Record<string, unknown>;
|
|
98
|
+
/** Raw response from the gateway (success path). */
|
|
99
|
+
interface GatewayResponse {
|
|
100
|
+
success?: boolean;
|
|
101
|
+
content?: {
|
|
102
|
+
items?: any[];
|
|
103
|
+
type_data?: Record<string, any>;
|
|
104
|
+
[key: string]: any;
|
|
105
|
+
};
|
|
106
|
+
items?: any[];
|
|
107
|
+
item?: any;
|
|
108
|
+
outgoing?: any[];
|
|
109
|
+
incoming?: any[];
|
|
110
|
+
[key: string]: any;
|
|
111
|
+
}
|
|
112
|
+
interface CreateParams {
|
|
113
|
+
parent_path: string;
|
|
114
|
+
name?: string;
|
|
115
|
+
item_type?: string;
|
|
116
|
+
type_data?: Record<string, any>;
|
|
117
|
+
[key: string]: unknown;
|
|
118
|
+
}
|
|
119
|
+
interface UpdateParams {
|
|
120
|
+
path: string;
|
|
121
|
+
name?: string;
|
|
122
|
+
type_data?: Record<string, any>;
|
|
123
|
+
[key: string]: unknown;
|
|
124
|
+
}
|
|
125
|
+
interface DeleteParams {
|
|
126
|
+
path: string;
|
|
127
|
+
[key: string]: unknown;
|
|
128
|
+
}
|
|
129
|
+
interface MoveParams {
|
|
130
|
+
path: string;
|
|
131
|
+
new_parent_path: string;
|
|
132
|
+
[key: string]: unknown;
|
|
133
|
+
}
|
|
134
|
+
interface LinkParams {
|
|
135
|
+
/** Optional — if omitted, the kernel auto-resolves the caller's member item in the current scope. */
|
|
136
|
+
source_id?: string;
|
|
137
|
+
target_id: string;
|
|
138
|
+
edge_type?: string;
|
|
139
|
+
weight?: number;
|
|
140
|
+
context?: Record<string, any>;
|
|
141
|
+
[key: string]: unknown;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* A compatible component opener returned by the CCM resolution pipeline.
|
|
145
|
+
*
|
|
146
|
+
* Each entry represents a component that has registered an `opens` edge
|
|
147
|
+
* targeting the item's type. The array is sorted by priority (highest first).
|
|
148
|
+
* The first entry with `is_default: true` is the one the kernel selected as
|
|
149
|
+
* the primary opener (reflected in `render.view_component_id`).
|
|
150
|
+
*/
|
|
151
|
+
interface ComponentOpener {
|
|
152
|
+
/** UUID of the component item in the VFS. */
|
|
153
|
+
component_id: string;
|
|
154
|
+
/** Short name of the component (e.g. "asset-viewer", "chat", "folder"). */
|
|
155
|
+
name: string;
|
|
156
|
+
/** VFS path of the component item. */
|
|
157
|
+
path: string;
|
|
158
|
+
/** Human-readable label for UI display (e.g. "Asset Viewer"). */
|
|
159
|
+
display_name: string;
|
|
160
|
+
/** Whether this is the default opener for the target type. */
|
|
161
|
+
is_default: boolean;
|
|
162
|
+
/** Priority weight (higher = preferred). */
|
|
163
|
+
priority: number;
|
|
164
|
+
/** UI framework the component is built with (e.g. "react"). */
|
|
165
|
+
framework: string;
|
|
166
|
+
/** Where the component runs: "client" (bundled) or "remote" (URL-loaded). */
|
|
167
|
+
host: string;
|
|
168
|
+
/** Remote bundle URL (null for client-hosted components). */
|
|
169
|
+
url: string | null;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The kernel's `open` syscall response — the unified envelope for rendering
|
|
173
|
+
* and content extraction.
|
|
174
|
+
*
|
|
175
|
+
* This is the primary interface between the kernel and any client that wants
|
|
176
|
+
* to display or process an item. The envelope carries:
|
|
177
|
+
*
|
|
178
|
+
* 1. **Item identity** — id, path, name, type (always present).
|
|
179
|
+
* 2. **CCM render block** — which component should render this item, resolved
|
|
180
|
+
* via the Compatible Component Model (opens graph + entitlements).
|
|
181
|
+
* 3. **Compatible components** — all registered openers for "Open With" UX.
|
|
182
|
+
* 4. **Content** — extracted content for AI/programmatic consumers.
|
|
183
|
+
* 5. **Metadata** — additional item metadata when requested.
|
|
184
|
+
*
|
|
185
|
+
* The gateway processes `read_url_instructions` before returning, so
|
|
186
|
+
* storage-backed items arrive with `render.props.url` already populated.
|
|
187
|
+
*
|
|
188
|
+
* When `render.view_component_id` is null, no CCM opener is registered for
|
|
189
|
+
* this item type — the client should fall back to a system action (e.g.
|
|
190
|
+
* item-detail / inspector). This is a valid state, not an error.
|
|
191
|
+
*/
|
|
192
|
+
interface OpenEnvelope {
|
|
193
|
+
/** UUID of the opened item. */
|
|
194
|
+
item_id: string;
|
|
195
|
+
/** Full VFS path of the opened item. */
|
|
196
|
+
item_path: string;
|
|
197
|
+
/** Display name of the opened item. */
|
|
198
|
+
item_name: string;
|
|
199
|
+
/** Type key of the opened item (e.g. "file", "channel", "task"). */
|
|
200
|
+
item_type: string;
|
|
201
|
+
/** Render directives from the CCM resolution pipeline. */
|
|
202
|
+
render?: {
|
|
203
|
+
/** Always "ccm" when the open pipeline runs. */
|
|
204
|
+
render_mode: string;
|
|
205
|
+
/** UUID of the resolved component (null = no CCM opener registered). */
|
|
206
|
+
view_component_id: string | null;
|
|
207
|
+
/** VFS path of the resolved component (null = no CCM opener registered). */
|
|
208
|
+
view_component_path: string | null;
|
|
209
|
+
/** UI framework (e.g. "react"). Null when no opener. */
|
|
210
|
+
framework: string | null;
|
|
211
|
+
/** Execution host: "client" or "remote". Null when no opener. */
|
|
212
|
+
host: string | null;
|
|
213
|
+
/** Remote bundle URL (populated by gateway for storage-backed items). */
|
|
214
|
+
url: string | null;
|
|
215
|
+
/** Render props passed to the component (label, path, url, mime, etc.). */
|
|
216
|
+
props?: Record<string, unknown>;
|
|
217
|
+
};
|
|
218
|
+
/** All registered openers for this item's type, sorted by priority desc. */
|
|
219
|
+
compatible_components: ComponentOpener[];
|
|
220
|
+
/** Extracted content payload (type_data, inline text, structured data). */
|
|
221
|
+
content?: Record<string, unknown>;
|
|
222
|
+
/** Additional item metadata when requested. */
|
|
223
|
+
metadata?: Record<string, unknown>;
|
|
224
|
+
/** @internal Raw instructions — usually already processed by the gateway. */
|
|
225
|
+
instructions?: Array<Record<string, unknown>>;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Options for the `open` syscall.
|
|
229
|
+
*
|
|
230
|
+
* Controls what the kernel returns in the envelope:
|
|
231
|
+
* - `mode` determines whether to run the CCM render pipeline, content
|
|
232
|
+
* extraction, or both.
|
|
233
|
+
* - `strategy` selects a non-default extraction strategy (e.g. "rows",
|
|
234
|
+
* "symbol", "heading" for files).
|
|
235
|
+
* - `arguments` passes strategy-specific parameters.
|
|
236
|
+
*
|
|
237
|
+
* When omitted, defaults to `mode: "render"` for human callers.
|
|
238
|
+
*/
|
|
239
|
+
interface OpenOptions {
|
|
240
|
+
/**
|
|
241
|
+
* What to include in the envelope.
|
|
242
|
+
* - "render" — CCM resolution + render props (default for UI).
|
|
243
|
+
* - "extract" — Content extraction only (for AI/scripts).
|
|
244
|
+
* - "both" — Full envelope with render + content.
|
|
245
|
+
*/
|
|
246
|
+
mode?: 'render' | 'extract' | 'both';
|
|
247
|
+
/** Strategy name from the type's open_config.strategies list. */
|
|
248
|
+
strategy?: string;
|
|
249
|
+
/** Strategy-specific arguments (e.g. { start: 0, end: 100 } for `rows`). */
|
|
250
|
+
arguments?: Record<string, unknown>;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @fsaos/gateway — Enforcement Error
|
|
255
|
+
*
|
|
256
|
+
* Thrown when a gateway call is denied by the enforcement layer
|
|
257
|
+
* (rules, access control, or entitlement checks).
|
|
258
|
+
*/
|
|
259
|
+
|
|
260
|
+
declare class EnforcementDeniedError extends Error {
|
|
261
|
+
readonly name = "EnforcementDeniedError";
|
|
262
|
+
readonly deniedBy: string;
|
|
263
|
+
readonly ruleKey?: string;
|
|
264
|
+
readonly displayName?: string;
|
|
265
|
+
constructor(payload: EnforcementPayload);
|
|
266
|
+
static fallbackMessage(payload: EnforcementPayload): string;
|
|
267
|
+
get isRuleDenial(): boolean;
|
|
268
|
+
get isAccessDenial(): boolean;
|
|
269
|
+
get isEntitlementDenial(): boolean;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* @fsaos/gateway — Session Management
|
|
274
|
+
*
|
|
275
|
+
* Manages the auth token lifecycle, reactive scope state, and domain-scoped
|
|
276
|
+
* session initialization.
|
|
277
|
+
*
|
|
278
|
+
* Token flow:
|
|
279
|
+
* 1. Supabase auth fires onAuthStateChange → we cache the access_token
|
|
280
|
+
* 2. A one-shot Promise (`tokenReady`) gates all gateway calls until the
|
|
281
|
+
* first auth event fires (or a 5 s timeout elapses)
|
|
282
|
+
* 3. initSession() calls GET /d/{hostname}/init to resolve the domain's
|
|
283
|
+
* scope, fractal, and instance metadata
|
|
284
|
+
*
|
|
285
|
+
* Scope flow:
|
|
286
|
+
* 1. useAccounts() fetches memberships → auto-selects or user picks an account
|
|
287
|
+
* 2. setScope(accountPath) is called → sets the active scope path
|
|
288
|
+
* 3. `scopeReady` promise resolves → all gated queries begin executing
|
|
289
|
+
* 4. Scope subscribers are notified → React hooks re-render with new scope key
|
|
290
|
+
* 5. On account switch, setScope(newPath) fires subscribers again →
|
|
291
|
+
* query keys change → React Query renders from new namespace (old cache stays warm)
|
|
292
|
+
*/
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Manually set the cached access token.
|
|
296
|
+
* Useful when the token is obtained out-of-band (e.g. embed token injection).
|
|
297
|
+
*/
|
|
298
|
+
declare function setCachedToken(token: string, expiresAt?: number): void;
|
|
299
|
+
/**
|
|
300
|
+
* Clear the cached access token.
|
|
301
|
+
* Called during sign-out to prevent stale tokens from leaking to the next session.
|
|
302
|
+
*/
|
|
303
|
+
declare function clearCachedToken(): void;
|
|
304
|
+
/**
|
|
305
|
+
* Returns the current access token, waiting for the first auth event if needed.
|
|
306
|
+
*/
|
|
307
|
+
declare function getAccessToken(): Promise<string | null>;
|
|
308
|
+
/** Subscriber set for reactive scope updates. */
|
|
309
|
+
type ScopeListener = () => void;
|
|
310
|
+
/**
|
|
311
|
+
* Set the active scope path (e.g. after account selection or account switch).
|
|
312
|
+
*
|
|
313
|
+
* Once set, every gatewayCall() automatically injects `_scope_path` into
|
|
314
|
+
* the request params so kernel_auth can validate membership at the correct
|
|
315
|
+
* account scope instead of falling back to the domain root.
|
|
316
|
+
*
|
|
317
|
+
* Setting scope also:
|
|
318
|
+
* - Resolves the `scopeReady` gate (unblocking all scope-dependent queries)
|
|
319
|
+
* - Increments the scope version counter
|
|
320
|
+
* - Notifies all scope subscribers (triggering React hook re-renders)
|
|
321
|
+
*
|
|
322
|
+
* @param scopePath The VFS path of the selected account/scope
|
|
323
|
+
* (e.g. "/root/accounts/joel-rowland")
|
|
324
|
+
*/
|
|
325
|
+
declare function setScope(scopePath: string): void;
|
|
326
|
+
/**
|
|
327
|
+
* Returns the currently active scope path, or null if not yet set.
|
|
328
|
+
*/
|
|
329
|
+
declare function getScope(): string | null;
|
|
330
|
+
/**
|
|
331
|
+
* Returns the current scope version (monotonically increasing on each scope change).
|
|
332
|
+
* Used by useSyncExternalStore in React hooks.
|
|
333
|
+
*/
|
|
334
|
+
declare function getScopeVersion(): number;
|
|
335
|
+
/**
|
|
336
|
+
* Subscribe to scope changes. Returns an unsubscribe function.
|
|
337
|
+
* Compatible with React's useSyncExternalStore pattern.
|
|
338
|
+
*/
|
|
339
|
+
declare function subscribeScope(listener: ScopeListener): () => void;
|
|
340
|
+
/**
|
|
341
|
+
* Returns a promise that resolves when scope is first set.
|
|
342
|
+
* Used by gatewayCall to gate scope-dependent requests.
|
|
343
|
+
*/
|
|
344
|
+
declare function awaitScopeReady(): Promise<void>;
|
|
345
|
+
/**
|
|
346
|
+
* Returns whether scope has been set at least once.
|
|
347
|
+
*/
|
|
348
|
+
declare function isScopeReady(): boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Initialize the domain-scoped session by calling the gateway's /init endpoint.
|
|
351
|
+
* Returns the cached session if already initialized.
|
|
352
|
+
*
|
|
353
|
+
* The gateway resolves the hostname → scope mapping and returns metadata about
|
|
354
|
+
* the fractal instance, scope path, and display name.
|
|
355
|
+
*/
|
|
356
|
+
declare function initSession(): Promise<SessionEntry>;
|
|
357
|
+
/**
|
|
358
|
+
* Returns the current session entry, or null if not yet initialized.
|
|
359
|
+
*/
|
|
360
|
+
declare function getSessionEntry(): SessionEntry | null;
|
|
361
|
+
/**
|
|
362
|
+
* Clears the cached session, forcing a fresh /init call on next access.
|
|
363
|
+
*/
|
|
364
|
+
declare function clearSession(): void;
|
|
365
|
+
type CleanupFn = () => void;
|
|
366
|
+
/**
|
|
367
|
+
* Register a cleanup function to be called during resetAllSdkState().
|
|
368
|
+
* Modules call this at import time to register their own cache-clearing logic.
|
|
369
|
+
*/
|
|
370
|
+
declare function registerCleanup(fn: CleanupFn): void;
|
|
371
|
+
/**
|
|
372
|
+
* Reset ALL SDK module-level state.
|
|
373
|
+
*
|
|
374
|
+
* Called by signOut() to ensure no cached identity, session, scope, principal,
|
|
375
|
+
* query data, SSE connections, or realtime channels leak between user sessions.
|
|
376
|
+
*
|
|
377
|
+
* This is the single source of truth for auth cleanup. After this call,
|
|
378
|
+
* the SDK is in the same state as a fresh page load (minus the Supabase
|
|
379
|
+
* onAuthStateChange listener, which will re-populate the token on next sign-in).
|
|
380
|
+
*/
|
|
381
|
+
declare function resetAllSdkState(): void;
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* @fsaos/gateway — Gateway Call (RPC Dispatcher)
|
|
385
|
+
*
|
|
386
|
+
* The single function that all VFS operations go through.
|
|
387
|
+
*
|
|
388
|
+
* Protocol:
|
|
389
|
+
* POST https://{gatewayUrl}/d/{hostname}
|
|
390
|
+
* Body: { method: string, params: Record<string, unknown> }
|
|
391
|
+
*
|
|
392
|
+
* The gateway resolves the hostname to a domain scope, authenticates via
|
|
393
|
+
* the Bearer token, and dispatches the method to the appropriate handler.
|
|
394
|
+
*
|
|
395
|
+
* If the domain scope is already known (from initSession), it is injected
|
|
396
|
+
* as `domain_scope_id` into the params automatically.
|
|
397
|
+
*
|
|
398
|
+
* SCOPE GATING:
|
|
399
|
+
* gatewayCall awaits `scopeReady` before sending any request that doesn't
|
|
400
|
+
* already have an explicit `_scope_path`. This prevents race conditions where
|
|
401
|
+
* hooks fire before account selection completes, sending relative paths that
|
|
402
|
+
* the kernel can't resolve.
|
|
403
|
+
*
|
|
404
|
+
* Methods that are inherently scope-independent (list-memberships, auth-related)
|
|
405
|
+
* bypass the scope gate because they're needed BEFORE scope is established.
|
|
406
|
+
*/
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Call a gateway method.
|
|
410
|
+
*
|
|
411
|
+
* @param method The RPC method name (e.g. "read", "list", "create", "update",
|
|
412
|
+
* "delete", "tree", "search", "edges", "move", "link",
|
|
413
|
+
* "types-list", "member-focus")
|
|
414
|
+
* @param params Method-specific parameters
|
|
415
|
+
* @returns The raw gateway response
|
|
416
|
+
*
|
|
417
|
+
* @throws {EnforcementDeniedError} When denied by rules, access, or entitlement
|
|
418
|
+
* @throws {Error} On HTTP errors or gateway-level failures
|
|
419
|
+
*/
|
|
420
|
+
declare function gatewayCall(method: string, params?: GatewayParams): Promise<GatewayResponse>;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* @fsaos/gateway — Query Client
|
|
424
|
+
*
|
|
425
|
+
* Creates and exports the shared TanStack QueryClient instance used by all
|
|
426
|
+
* VFS hooks. The default options are tuned for VFS data:
|
|
427
|
+
*
|
|
428
|
+
* - staleTime: 2 minutes (VFS data doesn't change that often)
|
|
429
|
+
* - gcTime: 10 minutes (keep unused data around for a while)
|
|
430
|
+
* - refetchOnWindowFocus: false (we use Supabase Realtime instead)
|
|
431
|
+
* - retry: 1 (one retry on failure)
|
|
432
|
+
*/
|
|
433
|
+
|
|
434
|
+
declare const queryClient: QueryClient;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* @fsaos/gateway — VFS Query Key Factory
|
|
438
|
+
*
|
|
439
|
+
* Deterministic query key factory used by TanStack Query for all VFS data.
|
|
440
|
+
* Every hook and cache invalidation function references these keys to ensure
|
|
441
|
+
* consistent cache identity.
|
|
442
|
+
*
|
|
443
|
+
* SCOPE-KEYED CACHING:
|
|
444
|
+
* All scope-dependent queries include the current scope path in their key.
|
|
445
|
+
* This means switching accounts creates a new cache namespace automatically —
|
|
446
|
+
* the old account's data stays warm for instant switch-back, while the new
|
|
447
|
+
* account's data is fetched fresh (or served from its own warm cache).
|
|
448
|
+
*
|
|
449
|
+
* Queries that are NOT scope-dependent (memberships, item-by-id) use keys
|
|
450
|
+
* without the scope prefix.
|
|
451
|
+
*/
|
|
452
|
+
declare const vfsKeys: {
|
|
453
|
+
/** Root key for all VFS queries (scope-aware). */
|
|
454
|
+
all: () => readonly ["vfs", string];
|
|
455
|
+
/** Single item by path (scope-aware — relative paths resolve per-scope). */
|
|
456
|
+
item: (path: string) => readonly ["vfs", string, "item", string];
|
|
457
|
+
/** Single item by UUID (scope-independent — UUIDs are globally unique). */
|
|
458
|
+
itemById: (id: string) => readonly ["vfs", "item-by-id", string];
|
|
459
|
+
/** Children of a path (scope-aware). */
|
|
460
|
+
children: (path: string) => readonly ["vfs", string, "children", string];
|
|
461
|
+
/** All children queries for current scope (for broad invalidation). */
|
|
462
|
+
allChildren: () => readonly ["vfs", string, "children"];
|
|
463
|
+
/** Type definitions for a scope (or default). */
|
|
464
|
+
types: (scopeId?: string) => readonly ["vfs", "types", string];
|
|
465
|
+
/** Edges for an item (scope-independent — edges are by item UUID). */
|
|
466
|
+
edges: (itemId: string) => readonly ["vfs", "edges", string];
|
|
467
|
+
/** Search results (scope-aware — search is scoped). */
|
|
468
|
+
search: (query: string, types?: string[]) => readonly ["vfs", string, "search", string, ...string[]];
|
|
469
|
+
/** Items query (type-based listing with filters, scope-aware). */
|
|
470
|
+
items: (type: string, filters?: Record<string, unknown>) => readonly ["vfs", string, "items", string, string];
|
|
471
|
+
/** All items queries for current scope (for broad invalidation). */
|
|
472
|
+
allItems: () => readonly ["vfs", string, "items"];
|
|
473
|
+
/** Recursive tree at a path + depth (scope-aware). */
|
|
474
|
+
tree: (path: string, depth?: number) => readonly ["vfs", string, "tree", string, number];
|
|
475
|
+
/** Open envelope for a path (scope-aware). */
|
|
476
|
+
openEnvelope: (path: string, strategy?: string) => readonly ["vfs", string, "open", string, string];
|
|
477
|
+
/** All open-envelope queries for current scope (for broad invalidation). */
|
|
478
|
+
allOpenEnvelopes: () => readonly ["vfs", string, "open"];
|
|
479
|
+
/** Member focus for a scope. */
|
|
480
|
+
memberFocus: (scopeId: string) => readonly ["vfs", "member-focus", string];
|
|
481
|
+
/** Fractal instances (scope-independent). */
|
|
482
|
+
fractalInstances: () => readonly ["vfs", "fractal-instances"];
|
|
483
|
+
/** Recent activity (scope-aware). */
|
|
484
|
+
recentActivity: (a: string, b: string, c: string) => readonly ["vfs", string, "recent-activity", string, string, string];
|
|
485
|
+
/** Item history (scope-independent — by item UUID). */
|
|
486
|
+
itemHistory: (a: string, b: string, c: string) => readonly ["vfs", "item-history", string, string, string];
|
|
487
|
+
/** Channel messages (scope-aware — channels are scoped). */
|
|
488
|
+
channelMessages: (channelPath: string, parentMessageId?: string) => readonly ["vfs", string, "channel-messages", string, string];
|
|
489
|
+
/** All channel-messages queries for current scope (for broad invalidation). */
|
|
490
|
+
allChannelMessages: () => readonly ["vfs", string, "channel-messages"];
|
|
491
|
+
/** Channels listing (scope-aware). */
|
|
492
|
+
channels: (filter?: string) => readonly ["vfs", string, "channels", string];
|
|
493
|
+
/** All channels queries for current scope (for broad invalidation). */
|
|
494
|
+
allChannels: () => readonly ["vfs", string, "channels"];
|
|
495
|
+
/** Notifications listing (scope-aware). */
|
|
496
|
+
notifications: (filter?: string, limit?: number) => readonly ["vfs", string, "notifications", string, number];
|
|
497
|
+
/** All notification queries for current scope (for broad invalidation). */
|
|
498
|
+
allNotifications: () => readonly ["vfs", string, "notifications"];
|
|
499
|
+
/** Unread counts (scope-aware). */
|
|
500
|
+
unreadCounts: () => readonly ["vfs", string, "unread-counts"];
|
|
501
|
+
/** Membership graph for a principal (scope-independent). */
|
|
502
|
+
memberships: (principalId: string) => readonly ["memberships", string];
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* @fsaos/gateway — VFS Operations
|
|
507
|
+
*
|
|
508
|
+
* Pure async functions that call the gateway and return normalized VFS data.
|
|
509
|
+
* These are the building blocks used by the React hooks — they can also be
|
|
510
|
+
* called directly for non-React use cases.
|
|
511
|
+
*/
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Normalize a raw gateway item response into a clean VFSItem.
|
|
515
|
+
* Handles the various shapes the gateway can return (flat fields, nested
|
|
516
|
+
* content.type_data, etc.).
|
|
517
|
+
*/
|
|
518
|
+
declare function normalizeItem(raw: any): VFSItem;
|
|
519
|
+
declare function fetchVfsItemById(id: string): Promise<VFSItem | null>;
|
|
520
|
+
declare function fetchVfsItem(path: string): Promise<VFSItem | null>;
|
|
521
|
+
declare function fetchVfsChildren(path: string): Promise<VFSItem[]>;
|
|
522
|
+
/**
|
|
523
|
+
* Paginated directory listing. Returns a page of children at `path`
|
|
524
|
+
* with the given `limit` and `offset`. Used by `useInfiniteChildren`.
|
|
525
|
+
*/
|
|
526
|
+
declare function fetchVfsChildrenPage(path: string, limit: number, offset: number): Promise<{
|
|
527
|
+
items: VFSItem[];
|
|
528
|
+
total_hint: number;
|
|
529
|
+
}>;
|
|
530
|
+
declare function fetchTypeDefinitions(scopeId?: string): Promise<Map<string, TypeDefinition>>;
|
|
531
|
+
declare function fetchEdgesForItem(itemId: string): Promise<VFSEdge[]>;
|
|
532
|
+
declare function fetchVfsTree(path: string, maxDepth?: number, itemTypes?: string[], limit?: number): Promise<VFSItem[]>;
|
|
533
|
+
declare function fetchRecentActivity(scopePath: string, limit?: number, offset?: number): Promise<any[]>;
|
|
534
|
+
declare function fetchItemHistory(itemId: string, limit?: number, offset?: number): Promise<any>;
|
|
535
|
+
declare function fetchMemberFocus(scopeId: string, itemTypes?: string[], limit?: number): Promise<VFSItem[]>;
|
|
536
|
+
/**
|
|
537
|
+
* Fetch the kernel's open envelope for an item.
|
|
538
|
+
*
|
|
539
|
+
* This is the primary way to open an item — it invokes the kernel's `open`
|
|
540
|
+
* syscall which runs the CCM resolution pipeline and returns:
|
|
541
|
+
* - Item identity (id, path, name, type)
|
|
542
|
+
* - Render directives (which component to mount, with what props)
|
|
543
|
+
* - Compatible components list (for "Open With" UX)
|
|
544
|
+
* - Content extraction (for AI/programmatic consumers)
|
|
545
|
+
*
|
|
546
|
+
* The gateway processes `read_url_instructions` before returning, so
|
|
547
|
+
* storage-backed items arrive with `render.props.url` already populated.
|
|
548
|
+
*
|
|
549
|
+
* Most consumers should use the `useOpen` hook instead. This function
|
|
550
|
+
* exists for non-React contexts (Fractals, scripts, imperative code).
|
|
551
|
+
*
|
|
552
|
+
* @param path VFS path of the item to open.
|
|
553
|
+
* @param options Optional mode, strategy, and arguments.
|
|
554
|
+
*/
|
|
555
|
+
declare function fetchOpenEnvelope(path: string, options?: OpenOptions): Promise<OpenEnvelope>;
|
|
556
|
+
/** Filters for useItems / fetchItems. */
|
|
557
|
+
interface ItemsFilter {
|
|
558
|
+
/** Item type to query (required). */
|
|
559
|
+
type: string;
|
|
560
|
+
/** Scope path boundary. Defaults to session scope. */
|
|
561
|
+
scope?: string;
|
|
562
|
+
/** Direct parent_id filter. */
|
|
563
|
+
parent_id?: string;
|
|
564
|
+
/** Name ILIKE filter (partial match). */
|
|
565
|
+
name?: string;
|
|
566
|
+
/** Tag containment filter. */
|
|
567
|
+
tag?: string;
|
|
568
|
+
/** type_data field filters. Keys are field names, values are exact match. */
|
|
569
|
+
fields?: Record<string, string | number | boolean>;
|
|
570
|
+
/** Sort field. Default: 'updated_at'. */
|
|
571
|
+
sort_by?: string;
|
|
572
|
+
/** Sort direction. Default: 'desc'. */
|
|
573
|
+
sort_dir?: 'asc' | 'desc';
|
|
574
|
+
/** Max items to return. Default: 50. */
|
|
575
|
+
limit?: number;
|
|
576
|
+
/** Offset for pagination. Default: 0. */
|
|
577
|
+
offset?: number;
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Fetch items by type with structured filters.
|
|
581
|
+
* Calls kernel_query (gateway 'search' method) with the extended filter support.
|
|
582
|
+
*/
|
|
583
|
+
declare function fetchItems(filter: ItemsFilter): Promise<{
|
|
584
|
+
items: VFSItem[];
|
|
585
|
+
total_hint?: number;
|
|
586
|
+
}>;
|
|
587
|
+
/** A parsed channel message with computed thread metadata from the kernel. */
|
|
588
|
+
interface ChannelMessage {
|
|
589
|
+
id: string;
|
|
590
|
+
path: string;
|
|
591
|
+
content: string;
|
|
592
|
+
created_at: string;
|
|
593
|
+
role: 'user' | 'assistant' | 'system';
|
|
594
|
+
seq: number;
|
|
595
|
+
principal_id?: string;
|
|
596
|
+
reply_count: number;
|
|
597
|
+
parent_message_id?: string;
|
|
598
|
+
intent_card?: Record<string, unknown>;
|
|
599
|
+
thread_summary?: Array<Record<string, unknown>>;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Fetch channel messages via the kernel's `get-channel-messages` method.
|
|
603
|
+
*
|
|
604
|
+
* Unlike `fetchVfsChildren` (which returns raw VFS items without computed
|
|
605
|
+
* fields), this calls the kernel method that computes `reply_count` and
|
|
606
|
+
* `thread_summary` on each message — the metadata needed for thread UX.
|
|
607
|
+
*
|
|
608
|
+
* @param channelPath VFS path of the channel
|
|
609
|
+
* @param parentMessageId If set, returns thread replies for that parent.
|
|
610
|
+
* If omitted, returns top-level messages.
|
|
611
|
+
*/
|
|
612
|
+
declare function fetchChannelMessages(channelPath: string, parentMessageId?: string): Promise<ChannelMessage[]>;
|
|
613
|
+
/** Response shape from fetchChannelMessagesPage. */
|
|
614
|
+
interface ChannelMessagesPage {
|
|
615
|
+
messages: ChannelMessage[];
|
|
616
|
+
/** Mode returned by kernel: 'top_level' or 'thread'. */
|
|
617
|
+
mode: 'top_level' | 'thread';
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Fetch a single page of channel messages with cursor-based pagination.
|
|
621
|
+
*
|
|
622
|
+
* Calls `get-channel-messages` which dispatches to `kernel_get_channel_messages_v2`.
|
|
623
|
+
* The kernel supports:
|
|
624
|
+
* - `limit` (default 50, max 200)
|
|
625
|
+
* - `before_seq` — fetch messages with seq < value (for backward/older pagination)
|
|
626
|
+
* - `after_seq` — fetch messages with seq > value (for forward/newer pagination)
|
|
627
|
+
*
|
|
628
|
+
* @param channelPath VFS path of the channel
|
|
629
|
+
* @param parentMessageId If set, fetches thread replies (uses after_seq for forward paging)
|
|
630
|
+
* @param limit Number of messages per page (default 50)
|
|
631
|
+
* @param before_seq Cursor for backward pagination (top-level: load older)
|
|
632
|
+
* @param after_seq Cursor for forward pagination (thread: load newer)
|
|
633
|
+
*/
|
|
634
|
+
declare function fetchChannelMessagesPage(channelPath: string, options?: {
|
|
635
|
+
parentMessageId?: string;
|
|
636
|
+
limit?: number;
|
|
637
|
+
before_seq?: number;
|
|
638
|
+
after_seq?: number;
|
|
639
|
+
}): Promise<ChannelMessagesPage>;
|
|
640
|
+
declare function invalidateChildren(path: string): void;
|
|
641
|
+
declare function invalidateItem(path: string): void;
|
|
642
|
+
declare function invalidatePathAndParent(path: string, fallbackParent?: string): void;
|
|
643
|
+
declare function invalidateSubtree(path: string): void;
|
|
644
|
+
declare function invalidateAllVfs(): void;
|
|
645
|
+
declare function invalidateTypes(scopeId?: string): void;
|
|
646
|
+
/**
|
|
647
|
+
* Invalidate cached channel messages.
|
|
648
|
+
* If channelPath is provided, invalidates that channel's messages.
|
|
649
|
+
* If not, invalidates all channel-messages queries.
|
|
650
|
+
*/
|
|
651
|
+
declare function invalidateChannelMessages(channelPath?: string, parentMessageId?: string): void;
|
|
652
|
+
/**
|
|
653
|
+
* Invalidate cached open envelopes.
|
|
654
|
+
* If path is provided, invalidates that path's envelope (all strategies).
|
|
655
|
+
* If not, invalidates all open-envelope queries.
|
|
656
|
+
*/
|
|
657
|
+
declare function invalidateOpenEnvelope(path?: string, strategy?: string): void;
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* @fsaos/gateway — VFS Realtime (WebSocket Transport)
|
|
661
|
+
*
|
|
662
|
+
* Subscribes to VFS change events via the gateway WebSocket and invalidates
|
|
663
|
+
* the corresponding TanStack Query caches.
|
|
664
|
+
*
|
|
665
|
+
* Subscription model:
|
|
666
|
+
* - At login: subscribe to the logged-in account's item ID
|
|
667
|
+
* - On mount: subscribe to additional account/space item IDs
|
|
668
|
+
* - On unmount: unsubscribe from those IDs
|
|
669
|
+
*
|
|
670
|
+
* The gateway routes vfs_change events by account_item_id and space_item_id.
|
|
671
|
+
* The client subscribes to account IDs and receives all VFS changes for items
|
|
672
|
+
* belonging to those accounts.
|
|
673
|
+
*
|
|
674
|
+
* Lifecycle:
|
|
675
|
+
* 1. initVfsRealtimeWs(accountId) — subscribe to account's vfs_change events
|
|
676
|
+
* 2. mountRealtimeScope(id) — subscribe to an additional account/space
|
|
677
|
+
* 3. unmountRealtimeScope(id) — unsubscribe from a mounted scope
|
|
678
|
+
* 4. disposeVfsRealtimeWs() — unsubscribe all and clear timers
|
|
679
|
+
*
|
|
680
|
+
* Invalidation strategy:
|
|
681
|
+
* - INSERT/UPDATE: set item data directly + invalidate parent's children list
|
|
682
|
+
* - DELETE: remove item queries + invalidate parent's children list
|
|
683
|
+
* - Tree queries: invalidate any tree whose root is an ancestor of the changed path
|
|
684
|
+
*/
|
|
685
|
+
/**
|
|
686
|
+
* Subscribe to VFS realtime events for the primary account via the gateway WebSocket.
|
|
687
|
+
* Automatically invalidates TanStack Query caches when items change.
|
|
688
|
+
*
|
|
689
|
+
* @param accountId - The account_item_id (primary logged-in account UUID)
|
|
690
|
+
*/
|
|
691
|
+
declare function initVfsRealtimeWs(accountId: string): void;
|
|
692
|
+
/**
|
|
693
|
+
* Mount an additional scope (account or space) for realtime events.
|
|
694
|
+
* Call this when the user mounts a new account or space.
|
|
695
|
+
*
|
|
696
|
+
* @param scopeId - The account_item_id or space_item_id to subscribe to
|
|
697
|
+
*/
|
|
698
|
+
declare function mountRealtimeScope(scopeId: string): void;
|
|
699
|
+
/**
|
|
700
|
+
* Unmount a scope (account or space) from realtime events.
|
|
701
|
+
* Call this when the user unmounts an account or space.
|
|
702
|
+
*
|
|
703
|
+
* @param scopeId - The account_item_id or space_item_id to unsubscribe from
|
|
704
|
+
*/
|
|
705
|
+
declare function unmountRealtimeScope(scopeId: string): void;
|
|
706
|
+
/**
|
|
707
|
+
* Tear down all VFS realtime WebSocket subscriptions.
|
|
708
|
+
*/
|
|
709
|
+
declare function disposeVfsRealtimeWs(): void;
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* @fsaos/gateway — WebSocket Transport Layer
|
|
713
|
+
*
|
|
714
|
+
* Replaces the SSE transport with a bidirectional WebSocket connection.
|
|
715
|
+
* Provides per-scope subscription routing (fixing the cross-account data leak)
|
|
716
|
+
* and supports upstream events (presence, typing, edits).
|
|
717
|
+
*
|
|
718
|
+
* Public API:
|
|
719
|
+
* - subscribeToPath(path, callback) → unsubscribe
|
|
720
|
+
* - subscribeToEvents(eventType, callback, filter?) → unsubscribe
|
|
721
|
+
* - disconnectSSE() — tear down connection and clear all state
|
|
722
|
+
*
|
|
723
|
+
* Additionally exposes:
|
|
724
|
+
* - emitEvent(scopeId, eventType, payload) — upstream events
|
|
725
|
+
* - subscribeToScope(scopeId, eventTypes) — explicit scope subscription
|
|
726
|
+
*
|
|
727
|
+
* Lifecycle:
|
|
728
|
+
* - Connection is only opened when there are active scope or path subscriptions
|
|
729
|
+
* - While the browser tab is visible, a 30s ping keeps the connection alive
|
|
730
|
+
* - When the tab is hidden, pings stop and the connection is allowed to die
|
|
731
|
+
* - When the tab becomes visible again, the connection is re-established
|
|
732
|
+
* - Connection attempts have a 10s timeout to prevent stuck promises
|
|
733
|
+
*/
|
|
734
|
+
/**
|
|
735
|
+
* Subscribe to events for a specific VFS path (token_stream routing).
|
|
736
|
+
* Lazily connects to the gateway's /ws endpoint on first subscription.
|
|
737
|
+
* Returns an unsubscribe function.
|
|
738
|
+
*/
|
|
739
|
+
declare function subscribeToPath(path: string, callback: (data: any) => void): () => void;
|
|
740
|
+
/**
|
|
741
|
+
* Subscribe to events by type with optional filter predicate.
|
|
742
|
+
* The WebSocket connection is shared — one connection, many consumers.
|
|
743
|
+
*
|
|
744
|
+
* NOTE: This does NOT open a connection by itself. A scope or path subscription
|
|
745
|
+
* must exist for the connection to be established.
|
|
746
|
+
*/
|
|
747
|
+
declare function subscribeToEvents(eventType: string | string[], callback: (data: any) => void, filter?: (data: any) => boolean): () => void;
|
|
748
|
+
/**
|
|
749
|
+
* Subscribe to a scope for VFS/CCM change events.
|
|
750
|
+
* This is the primary subscription mechanism for per-account isolation.
|
|
751
|
+
* Opening a scope subscription is what triggers the WebSocket connection.
|
|
752
|
+
*/
|
|
753
|
+
declare function subscribeToScope(scopeId: string, eventTypes?: string[]): () => void;
|
|
754
|
+
/**
|
|
755
|
+
* Emit an upstream event to other clients subscribed to the same scope.
|
|
756
|
+
* Used for presence, typing indicators, cursor positions, etc.
|
|
757
|
+
*/
|
|
758
|
+
declare function emitEvent(scopeId: string, eventType: string, payload?: Record<string, unknown>): void;
|
|
759
|
+
/**
|
|
760
|
+
* Disconnect the WebSocket and clear all listeners.
|
|
761
|
+
* Backward-compatible name with sse.ts.
|
|
762
|
+
*/
|
|
763
|
+
declare function disconnectSSE(): void;
|
|
764
|
+
/**
|
|
765
|
+
* Send a ping to keep the connection alive.
|
|
766
|
+
* Normally handled automatically by the visibility-aware lifecycle,
|
|
767
|
+
* but exposed for manual use if needed.
|
|
768
|
+
*/
|
|
769
|
+
declare function ping(): void;
|
|
770
|
+
|
|
771
|
+
declare function readItem(path: string): Promise<GatewayResponse>;
|
|
772
|
+
declare function listChildren(path: string, options?: Record<string, unknown>): Promise<GatewayResponse>;
|
|
773
|
+
declare function createItem(params: Record<string, unknown>): Promise<GatewayResponse>;
|
|
774
|
+
declare function updateItem(params: Record<string, unknown>): Promise<GatewayResponse>;
|
|
775
|
+
declare function pushChanges(params: Record<string, unknown>): Promise<GatewayResponse>;
|
|
776
|
+
declare function callTool(toolName: string, params?: Record<string, unknown>): Promise<GatewayResponse>;
|
|
777
|
+
declare function signal(targetId: string, eventName: string, payload?: Record<string, unknown>): Promise<GatewayResponse>;
|
|
778
|
+
declare function getAssetUrl(path: string): string;
|
|
779
|
+
declare const auth: {
|
|
780
|
+
signIn: (opts: any) => Promise<_supabase_supabase_js.OAuthResponse> | Promise<_supabase_supabase_js.AuthTokenResponsePassword>;
|
|
781
|
+
signUp: (opts: any) => Promise<_supabase_supabase_js.AuthResponse>;
|
|
782
|
+
signOut: () => Promise<void>;
|
|
783
|
+
getSession: () => Promise<any>;
|
|
784
|
+
getUser: () => Promise<any>;
|
|
785
|
+
onAuthStateChange: (callback: (data: any) => void) => () => void;
|
|
786
|
+
resetPassword: (email: string) => Promise<{
|
|
787
|
+
data: {};
|
|
788
|
+
error: null;
|
|
789
|
+
} | {
|
|
790
|
+
data: null;
|
|
791
|
+
error: _supabase_supabase_js.AuthError;
|
|
792
|
+
}>;
|
|
793
|
+
signInWithMagicLink: (email: string, redirectTo?: string) => Promise<_supabase_supabase_js.AuthOtpResponse>;
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Mount the root component into #root.
|
|
798
|
+
* Reads window.__FSAOS_COMPONENT__, wraps in QueryClientProvider,
|
|
799
|
+
* and renders via React 18+ createRoot.
|
|
800
|
+
*/
|
|
801
|
+
declare function mount(): void;
|
|
802
|
+
/**
|
|
803
|
+
* Set up the require() shim and window globals.
|
|
804
|
+
* Called by the build script's footer after the IIFE assigns window.__FSAOS_GATEWAY__.
|
|
805
|
+
*/
|
|
806
|
+
declare function setupRequireShim(): void;
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* Returns whether scope has been established. Useful for gating UI that
|
|
810
|
+
* depends on scope-aware data.
|
|
811
|
+
*/
|
|
812
|
+
declare function useScopeReady(): boolean;
|
|
813
|
+
/** Fetch a single VFS item by path. Disabled when path is falsy. */
|
|
814
|
+
declare function useItem(path: string | undefined | null): _tanstack_react_query.UseQueryResult<VFSItem | null, Error>;
|
|
815
|
+
/** Fetch a single VFS item by its UUID. Disabled when id is falsy. */
|
|
816
|
+
declare function useItemById(id: string | undefined | null): _tanstack_react_query.UseQueryResult<VFSItem | null, Error>;
|
|
817
|
+
/** Fetch children of a VFS path. Disabled when path is falsy. */
|
|
818
|
+
declare function useList(path: string | undefined | null): _tanstack_react_query.UseQueryResult<VFSItem[], Error>;
|
|
819
|
+
/**
|
|
820
|
+
* Fetch children of a VFS path. Returns { children, ...queryResult }.
|
|
821
|
+
* Convenience wrapper around useList that renames `data` to `children`.
|
|
822
|
+
*/
|
|
823
|
+
declare function useChildren(path: string | undefined | null): {
|
|
824
|
+
children: VFSItem[];
|
|
825
|
+
data: VFSItem[];
|
|
826
|
+
error: Error;
|
|
827
|
+
isError: true;
|
|
828
|
+
isPending: false;
|
|
829
|
+
isLoading: false;
|
|
830
|
+
isLoadingError: false;
|
|
831
|
+
isRefetchError: true;
|
|
832
|
+
isSuccess: false;
|
|
833
|
+
isPlaceholderData: false;
|
|
834
|
+
status: "error";
|
|
835
|
+
dataUpdatedAt: number;
|
|
836
|
+
errorUpdatedAt: number;
|
|
837
|
+
failureCount: number;
|
|
838
|
+
failureReason: Error | null;
|
|
839
|
+
errorUpdateCount: number;
|
|
840
|
+
isFetched: boolean;
|
|
841
|
+
isFetchedAfterMount: boolean;
|
|
842
|
+
isFetching: boolean;
|
|
843
|
+
isInitialLoading: boolean;
|
|
844
|
+
isPaused: boolean;
|
|
845
|
+
isRefetching: boolean;
|
|
846
|
+
isStale: boolean;
|
|
847
|
+
isEnabled: boolean;
|
|
848
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<VFSItem[], Error>>;
|
|
849
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
850
|
+
promise: Promise<VFSItem[]>;
|
|
851
|
+
} | {
|
|
852
|
+
children: VFSItem[];
|
|
853
|
+
data: VFSItem[];
|
|
854
|
+
error: null;
|
|
855
|
+
isError: false;
|
|
856
|
+
isPending: false;
|
|
857
|
+
isLoading: false;
|
|
858
|
+
isLoadingError: false;
|
|
859
|
+
isRefetchError: false;
|
|
860
|
+
isSuccess: true;
|
|
861
|
+
isPlaceholderData: false;
|
|
862
|
+
status: "success";
|
|
863
|
+
dataUpdatedAt: number;
|
|
864
|
+
errorUpdatedAt: number;
|
|
865
|
+
failureCount: number;
|
|
866
|
+
failureReason: Error | null;
|
|
867
|
+
errorUpdateCount: number;
|
|
868
|
+
isFetched: boolean;
|
|
869
|
+
isFetchedAfterMount: boolean;
|
|
870
|
+
isFetching: boolean;
|
|
871
|
+
isInitialLoading: boolean;
|
|
872
|
+
isPaused: boolean;
|
|
873
|
+
isRefetching: boolean;
|
|
874
|
+
isStale: boolean;
|
|
875
|
+
isEnabled: boolean;
|
|
876
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<VFSItem[], Error>>;
|
|
877
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
878
|
+
promise: Promise<VFSItem[]>;
|
|
879
|
+
} | {
|
|
880
|
+
children: VFSItem[];
|
|
881
|
+
data: undefined;
|
|
882
|
+
error: Error;
|
|
883
|
+
isError: true;
|
|
884
|
+
isPending: false;
|
|
885
|
+
isLoading: false;
|
|
886
|
+
isLoadingError: true;
|
|
887
|
+
isRefetchError: false;
|
|
888
|
+
isSuccess: false;
|
|
889
|
+
isPlaceholderData: false;
|
|
890
|
+
status: "error";
|
|
891
|
+
dataUpdatedAt: number;
|
|
892
|
+
errorUpdatedAt: number;
|
|
893
|
+
failureCount: number;
|
|
894
|
+
failureReason: Error | null;
|
|
895
|
+
errorUpdateCount: number;
|
|
896
|
+
isFetched: boolean;
|
|
897
|
+
isFetchedAfterMount: boolean;
|
|
898
|
+
isFetching: boolean;
|
|
899
|
+
isInitialLoading: boolean;
|
|
900
|
+
isPaused: boolean;
|
|
901
|
+
isRefetching: boolean;
|
|
902
|
+
isStale: boolean;
|
|
903
|
+
isEnabled: boolean;
|
|
904
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<VFSItem[], Error>>;
|
|
905
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
906
|
+
promise: Promise<VFSItem[]>;
|
|
907
|
+
} | {
|
|
908
|
+
children: VFSItem[];
|
|
909
|
+
data: undefined;
|
|
910
|
+
error: null;
|
|
911
|
+
isError: false;
|
|
912
|
+
isPending: true;
|
|
913
|
+
isLoading: true;
|
|
914
|
+
isLoadingError: false;
|
|
915
|
+
isRefetchError: false;
|
|
916
|
+
isSuccess: false;
|
|
917
|
+
isPlaceholderData: false;
|
|
918
|
+
status: "pending";
|
|
919
|
+
dataUpdatedAt: number;
|
|
920
|
+
errorUpdatedAt: number;
|
|
921
|
+
failureCount: number;
|
|
922
|
+
failureReason: Error | null;
|
|
923
|
+
errorUpdateCount: number;
|
|
924
|
+
isFetched: boolean;
|
|
925
|
+
isFetchedAfterMount: boolean;
|
|
926
|
+
isFetching: boolean;
|
|
927
|
+
isInitialLoading: boolean;
|
|
928
|
+
isPaused: boolean;
|
|
929
|
+
isRefetching: boolean;
|
|
930
|
+
isStale: boolean;
|
|
931
|
+
isEnabled: boolean;
|
|
932
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<VFSItem[], Error>>;
|
|
933
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
934
|
+
promise: Promise<VFSItem[]>;
|
|
935
|
+
} | {
|
|
936
|
+
children: VFSItem[];
|
|
937
|
+
data: undefined;
|
|
938
|
+
error: null;
|
|
939
|
+
isError: false;
|
|
940
|
+
isPending: true;
|
|
941
|
+
isLoadingError: false;
|
|
942
|
+
isRefetchError: false;
|
|
943
|
+
isSuccess: false;
|
|
944
|
+
isPlaceholderData: false;
|
|
945
|
+
status: "pending";
|
|
946
|
+
dataUpdatedAt: number;
|
|
947
|
+
errorUpdatedAt: number;
|
|
948
|
+
failureCount: number;
|
|
949
|
+
failureReason: Error | null;
|
|
950
|
+
errorUpdateCount: number;
|
|
951
|
+
isFetched: boolean;
|
|
952
|
+
isFetchedAfterMount: boolean;
|
|
953
|
+
isFetching: boolean;
|
|
954
|
+
isLoading: boolean;
|
|
955
|
+
isInitialLoading: boolean;
|
|
956
|
+
isPaused: boolean;
|
|
957
|
+
isRefetching: boolean;
|
|
958
|
+
isStale: boolean;
|
|
959
|
+
isEnabled: boolean;
|
|
960
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<VFSItem[], Error>>;
|
|
961
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
962
|
+
promise: Promise<VFSItem[]>;
|
|
963
|
+
} | {
|
|
964
|
+
children: VFSItem[];
|
|
965
|
+
data: VFSItem[];
|
|
966
|
+
isError: false;
|
|
967
|
+
error: null;
|
|
968
|
+
isPending: false;
|
|
969
|
+
isLoading: false;
|
|
970
|
+
isLoadingError: false;
|
|
971
|
+
isRefetchError: false;
|
|
972
|
+
isSuccess: true;
|
|
973
|
+
isPlaceholderData: true;
|
|
974
|
+
status: "success";
|
|
975
|
+
dataUpdatedAt: number;
|
|
976
|
+
errorUpdatedAt: number;
|
|
977
|
+
failureCount: number;
|
|
978
|
+
failureReason: Error | null;
|
|
979
|
+
errorUpdateCount: number;
|
|
980
|
+
isFetched: boolean;
|
|
981
|
+
isFetchedAfterMount: boolean;
|
|
982
|
+
isFetching: boolean;
|
|
983
|
+
isInitialLoading: boolean;
|
|
984
|
+
isPaused: boolean;
|
|
985
|
+
isRefetching: boolean;
|
|
986
|
+
isStale: boolean;
|
|
987
|
+
isEnabled: boolean;
|
|
988
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<VFSItem[], Error>>;
|
|
989
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
990
|
+
promise: Promise<VFSItem[]>;
|
|
991
|
+
};
|
|
992
|
+
/** Fetch a recursive tree starting at a path. */
|
|
993
|
+
declare function useTree(path: string | undefined | null, depth?: number): _tanstack_react_query.UseQueryResult<VFSItem[], Error>;
|
|
994
|
+
/** Search VFS items by query string, optionally filtered by item types. */
|
|
995
|
+
declare function useSearch(query: string | undefined | null, itemTypes?: string[]): _tanstack_react_query.UseQueryResult<VFSItem[], Error>;
|
|
996
|
+
/** Fetch items by type with structured filters. */
|
|
997
|
+
declare function useItems(filter: ItemsFilter | null | undefined): _tanstack_react_query.UseQueryResult<VFSItem[], Error>;
|
|
998
|
+
/** Infinite-scroll item fetching by type. */
|
|
999
|
+
declare function useInfiniteItems(filter: ItemsFilter | null | undefined): {
|
|
1000
|
+
allItems: VFSItem[];
|
|
1001
|
+
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<{
|
|
1002
|
+
items: VFSItem[];
|
|
1003
|
+
total_hint?: number;
|
|
1004
|
+
}, unknown>, Error>>;
|
|
1005
|
+
isFetchingNextPage: boolean;
|
|
1006
|
+
isExhausted: boolean;
|
|
1007
|
+
isLoading: boolean;
|
|
1008
|
+
isFetching: boolean;
|
|
1009
|
+
error: Error | null;
|
|
1010
|
+
totalHint: number | undefined;
|
|
1011
|
+
};
|
|
1012
|
+
/** Infinite-scroll directory listing (children of a path). */
|
|
1013
|
+
declare function useInfiniteChildren(path: string | undefined | null): {
|
|
1014
|
+
allItems: VFSItem[];
|
|
1015
|
+
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<{
|
|
1016
|
+
items: VFSItem[];
|
|
1017
|
+
total_hint: number;
|
|
1018
|
+
}, unknown>, Error>>;
|
|
1019
|
+
isFetchingNextPage: boolean;
|
|
1020
|
+
isExhausted: boolean;
|
|
1021
|
+
isLoading: boolean;
|
|
1022
|
+
isFetching: boolean;
|
|
1023
|
+
error: Error | null;
|
|
1024
|
+
totalHint: number | undefined;
|
|
1025
|
+
};
|
|
1026
|
+
/** Fetch edges for an item by its ID. */
|
|
1027
|
+
declare function useEdges(itemId: string | undefined | null): _tanstack_react_query.UseQueryResult<VFSEdge[], Error>;
|
|
1028
|
+
/** Fetch all type definitions for a scope. */
|
|
1029
|
+
declare function useTypes(scopeId?: string): _tanstack_react_query.UseQueryResult<Map<string, TypeDefinition>, Error>;
|
|
1030
|
+
/** Fetch a single type definition by type_key. */
|
|
1031
|
+
declare function useType(typeKey: string, scopeId?: string): {
|
|
1032
|
+
data: TypeDefinition | undefined;
|
|
1033
|
+
error: Error;
|
|
1034
|
+
isError: true;
|
|
1035
|
+
isPending: false;
|
|
1036
|
+
isLoading: false;
|
|
1037
|
+
isLoadingError: false;
|
|
1038
|
+
isRefetchError: true;
|
|
1039
|
+
isSuccess: false;
|
|
1040
|
+
isPlaceholderData: false;
|
|
1041
|
+
status: "error";
|
|
1042
|
+
dataUpdatedAt: number;
|
|
1043
|
+
errorUpdatedAt: number;
|
|
1044
|
+
failureCount: number;
|
|
1045
|
+
failureReason: Error | null;
|
|
1046
|
+
errorUpdateCount: number;
|
|
1047
|
+
isFetched: boolean;
|
|
1048
|
+
isFetchedAfterMount: boolean;
|
|
1049
|
+
isFetching: boolean;
|
|
1050
|
+
isInitialLoading: boolean;
|
|
1051
|
+
isPaused: boolean;
|
|
1052
|
+
isRefetching: boolean;
|
|
1053
|
+
isStale: boolean;
|
|
1054
|
+
isEnabled: boolean;
|
|
1055
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Map<string, TypeDefinition>, Error>>;
|
|
1056
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1057
|
+
promise: Promise<Map<string, TypeDefinition>>;
|
|
1058
|
+
} | {
|
|
1059
|
+
data: TypeDefinition | undefined;
|
|
1060
|
+
error: null;
|
|
1061
|
+
isError: false;
|
|
1062
|
+
isPending: false;
|
|
1063
|
+
isLoading: false;
|
|
1064
|
+
isLoadingError: false;
|
|
1065
|
+
isRefetchError: false;
|
|
1066
|
+
isSuccess: true;
|
|
1067
|
+
isPlaceholderData: false;
|
|
1068
|
+
status: "success";
|
|
1069
|
+
dataUpdatedAt: number;
|
|
1070
|
+
errorUpdatedAt: number;
|
|
1071
|
+
failureCount: number;
|
|
1072
|
+
failureReason: Error | null;
|
|
1073
|
+
errorUpdateCount: number;
|
|
1074
|
+
isFetched: boolean;
|
|
1075
|
+
isFetchedAfterMount: boolean;
|
|
1076
|
+
isFetching: boolean;
|
|
1077
|
+
isInitialLoading: boolean;
|
|
1078
|
+
isPaused: boolean;
|
|
1079
|
+
isRefetching: boolean;
|
|
1080
|
+
isStale: boolean;
|
|
1081
|
+
isEnabled: boolean;
|
|
1082
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Map<string, TypeDefinition>, Error>>;
|
|
1083
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1084
|
+
promise: Promise<Map<string, TypeDefinition>>;
|
|
1085
|
+
} | {
|
|
1086
|
+
data: TypeDefinition | undefined;
|
|
1087
|
+
error: Error;
|
|
1088
|
+
isError: true;
|
|
1089
|
+
isPending: false;
|
|
1090
|
+
isLoading: false;
|
|
1091
|
+
isLoadingError: true;
|
|
1092
|
+
isRefetchError: false;
|
|
1093
|
+
isSuccess: false;
|
|
1094
|
+
isPlaceholderData: false;
|
|
1095
|
+
status: "error";
|
|
1096
|
+
dataUpdatedAt: number;
|
|
1097
|
+
errorUpdatedAt: number;
|
|
1098
|
+
failureCount: number;
|
|
1099
|
+
failureReason: Error | null;
|
|
1100
|
+
errorUpdateCount: number;
|
|
1101
|
+
isFetched: boolean;
|
|
1102
|
+
isFetchedAfterMount: boolean;
|
|
1103
|
+
isFetching: boolean;
|
|
1104
|
+
isInitialLoading: boolean;
|
|
1105
|
+
isPaused: boolean;
|
|
1106
|
+
isRefetching: boolean;
|
|
1107
|
+
isStale: boolean;
|
|
1108
|
+
isEnabled: boolean;
|
|
1109
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Map<string, TypeDefinition>, Error>>;
|
|
1110
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1111
|
+
promise: Promise<Map<string, TypeDefinition>>;
|
|
1112
|
+
} | {
|
|
1113
|
+
data: TypeDefinition | undefined;
|
|
1114
|
+
error: null;
|
|
1115
|
+
isError: false;
|
|
1116
|
+
isPending: true;
|
|
1117
|
+
isLoading: true;
|
|
1118
|
+
isLoadingError: false;
|
|
1119
|
+
isRefetchError: false;
|
|
1120
|
+
isSuccess: false;
|
|
1121
|
+
isPlaceholderData: false;
|
|
1122
|
+
status: "pending";
|
|
1123
|
+
dataUpdatedAt: number;
|
|
1124
|
+
errorUpdatedAt: number;
|
|
1125
|
+
failureCount: number;
|
|
1126
|
+
failureReason: Error | null;
|
|
1127
|
+
errorUpdateCount: number;
|
|
1128
|
+
isFetched: boolean;
|
|
1129
|
+
isFetchedAfterMount: boolean;
|
|
1130
|
+
isFetching: boolean;
|
|
1131
|
+
isInitialLoading: boolean;
|
|
1132
|
+
isPaused: boolean;
|
|
1133
|
+
isRefetching: boolean;
|
|
1134
|
+
isStale: boolean;
|
|
1135
|
+
isEnabled: boolean;
|
|
1136
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Map<string, TypeDefinition>, Error>>;
|
|
1137
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1138
|
+
promise: Promise<Map<string, TypeDefinition>>;
|
|
1139
|
+
} | {
|
|
1140
|
+
data: TypeDefinition | undefined;
|
|
1141
|
+
error: null;
|
|
1142
|
+
isError: false;
|
|
1143
|
+
isPending: true;
|
|
1144
|
+
isLoadingError: false;
|
|
1145
|
+
isRefetchError: false;
|
|
1146
|
+
isSuccess: false;
|
|
1147
|
+
isPlaceholderData: false;
|
|
1148
|
+
status: "pending";
|
|
1149
|
+
dataUpdatedAt: number;
|
|
1150
|
+
errorUpdatedAt: number;
|
|
1151
|
+
failureCount: number;
|
|
1152
|
+
failureReason: Error | null;
|
|
1153
|
+
errorUpdateCount: number;
|
|
1154
|
+
isFetched: boolean;
|
|
1155
|
+
isFetchedAfterMount: boolean;
|
|
1156
|
+
isFetching: boolean;
|
|
1157
|
+
isLoading: boolean;
|
|
1158
|
+
isInitialLoading: boolean;
|
|
1159
|
+
isPaused: boolean;
|
|
1160
|
+
isRefetching: boolean;
|
|
1161
|
+
isStale: boolean;
|
|
1162
|
+
isEnabled: boolean;
|
|
1163
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Map<string, TypeDefinition>, Error>>;
|
|
1164
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1165
|
+
promise: Promise<Map<string, TypeDefinition>>;
|
|
1166
|
+
} | {
|
|
1167
|
+
data: TypeDefinition | undefined;
|
|
1168
|
+
isError: false;
|
|
1169
|
+
error: null;
|
|
1170
|
+
isPending: false;
|
|
1171
|
+
isLoading: false;
|
|
1172
|
+
isLoadingError: false;
|
|
1173
|
+
isRefetchError: false;
|
|
1174
|
+
isSuccess: true;
|
|
1175
|
+
isPlaceholderData: true;
|
|
1176
|
+
status: "success";
|
|
1177
|
+
dataUpdatedAt: number;
|
|
1178
|
+
errorUpdatedAt: number;
|
|
1179
|
+
failureCount: number;
|
|
1180
|
+
failureReason: Error | null;
|
|
1181
|
+
errorUpdateCount: number;
|
|
1182
|
+
isFetched: boolean;
|
|
1183
|
+
isFetchedAfterMount: boolean;
|
|
1184
|
+
isFetching: boolean;
|
|
1185
|
+
isInitialLoading: boolean;
|
|
1186
|
+
isPaused: boolean;
|
|
1187
|
+
isRefetching: boolean;
|
|
1188
|
+
isStale: boolean;
|
|
1189
|
+
isEnabled: boolean;
|
|
1190
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Map<string, TypeDefinition>, Error>>;
|
|
1191
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1192
|
+
promise: Promise<Map<string, TypeDefinition>>;
|
|
1193
|
+
};
|
|
1194
|
+
/**
|
|
1195
|
+
* Open a VFS item — the primary hook for rendering any item.
|
|
1196
|
+
*
|
|
1197
|
+
* Calls the kernel's `open` syscall which runs the CCM resolution pipeline
|
|
1198
|
+
* and returns the full OpenEnvelope:
|
|
1199
|
+
* - Item identity (id, path, name, type)
|
|
1200
|
+
* - Render directives (view_component_id, props, url)
|
|
1201
|
+
* - Compatible components (for "Open With" menus)
|
|
1202
|
+
* - Content extraction (for AI/programmatic consumers)
|
|
1203
|
+
*
|
|
1204
|
+
* The gateway mints signed URLs for storage-backed items before returning,
|
|
1205
|
+
* so `render.props.url` is ready to use immediately.
|
|
1206
|
+
*
|
|
1207
|
+
* When `render.view_component_id` is null, no CCM opener is registered —
|
|
1208
|
+
* the client should fall back to a system action (item-detail/inspector).
|
|
1209
|
+
*
|
|
1210
|
+
* @example
|
|
1211
|
+
* // Default open — render mode, kernel resolves the component.
|
|
1212
|
+
* const { data: envelope, isLoading } = useOpen(path);
|
|
1213
|
+
* if (!envelope?.render?.view_component_id) {
|
|
1214
|
+
* return <ItemDetailView />; // system action fallback
|
|
1215
|
+
* }
|
|
1216
|
+
* // Mount the resolved component...
|
|
1217
|
+
*
|
|
1218
|
+
* @example
|
|
1219
|
+
* // Open with content extraction for AI
|
|
1220
|
+
* const { data } = useOpen(path, { mode: 'extract' });
|
|
1221
|
+
* // data.content contains extracted text/structured data
|
|
1222
|
+
*
|
|
1223
|
+
* @example
|
|
1224
|
+
* // "Open With" menu — read compatible_components
|
|
1225
|
+
* const { data } = useOpen(path);
|
|
1226
|
+
* data?.compatible_components.map(c => c.display_name);
|
|
1227
|
+
*/
|
|
1228
|
+
declare function useOpen(path: string | undefined | null, options?: OpenOptions): _tanstack_react_query.UseQueryResult<OpenEnvelope, Error>;
|
|
1229
|
+
interface TypeHelpers {
|
|
1230
|
+
canHaveChildren: (item: VFSItem) => boolean;
|
|
1231
|
+
isScope: (item: VFSItem) => boolean;
|
|
1232
|
+
isScopeType: (typeKey: string) => boolean;
|
|
1233
|
+
isContainerType: (typeKey: string) => boolean;
|
|
1234
|
+
getTypeDefinition: (typeKey: string) => TypeDefinition | undefined;
|
|
1235
|
+
getTypeColor: (typeKey: string) => string;
|
|
1236
|
+
getTypeIcon: (typeKey: string) => string;
|
|
1237
|
+
getTypeDisplayName: (typeKey: string) => string;
|
|
1238
|
+
getKnownEdgeTypes: () => {
|
|
1239
|
+
key: string;
|
|
1240
|
+
label: string;
|
|
1241
|
+
}[];
|
|
1242
|
+
getEdgeTypeLabel: (edgeType: string) => string;
|
|
1243
|
+
allTypes: Map<string, TypeDefinition>;
|
|
1244
|
+
loading: boolean;
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* Convenience hook that derives type-system helper functions from useTypes().
|
|
1248
|
+
*/
|
|
1249
|
+
declare function useTypeHelpers(scopeId?: string): TypeHelpers;
|
|
1250
|
+
/** Fetch items assigned/relevant to the current user within a scope. */
|
|
1251
|
+
declare function useMemberFocus(scopeId: string | undefined | null, itemTypes?: string[], limit?: number): _tanstack_react_query.UseQueryResult<VFSItem[], Error>;
|
|
1252
|
+
/** Fetch the version history of a VFS item. */
|
|
1253
|
+
declare function useItemHistory(itemId: string | undefined | null, limit?: number, offset?: number): _tanstack_react_query.UseQueryResult<any, Error>;
|
|
1254
|
+
/** Fetch recent activity (audit log) for a scope. */
|
|
1255
|
+
declare function useRecentActivity(scopePath: string | undefined | null, limit?: number, offset?: number): _tanstack_react_query.UseQueryResult<any[], Error>;
|
|
1256
|
+
interface ScopeData {
|
|
1257
|
+
path: string;
|
|
1258
|
+
scope_id: string;
|
|
1259
|
+
fractal_id: string | null;
|
|
1260
|
+
instance_name: string | null;
|
|
1261
|
+
display_name: string | null;
|
|
1262
|
+
componentPath?: string;
|
|
1263
|
+
isEmbed?: boolean;
|
|
1264
|
+
}
|
|
1265
|
+
interface ScopeResult {
|
|
1266
|
+
data: ScopeData | null;
|
|
1267
|
+
loading: boolean;
|
|
1268
|
+
error: Error | null;
|
|
1269
|
+
}
|
|
1270
|
+
/** Returns the current scope session via initSession(). */
|
|
1271
|
+
declare function useScope(): ScopeResult;
|
|
1272
|
+
interface AccountInfo {
|
|
1273
|
+
accountId: string;
|
|
1274
|
+
path: string;
|
|
1275
|
+
name: string;
|
|
1276
|
+
role: string;
|
|
1277
|
+
typeData: Record<string, unknown>;
|
|
1278
|
+
joinedAt: string;
|
|
1279
|
+
via?: 'direct' | 'cascade';
|
|
1280
|
+
placement?: 'switcher_entry' | 'mount_only';
|
|
1281
|
+
subordinateTo?: string | null;
|
|
1282
|
+
cascadeAnchorId?: string | null;
|
|
1283
|
+
isAccount?: boolean;
|
|
1284
|
+
isSpace?: boolean;
|
|
1285
|
+
isOwner?: boolean;
|
|
1286
|
+
billingResponsible?: boolean;
|
|
1287
|
+
grantedVia?: 'self_provisioned' | 'invitation' | 'purchase' | 'seat_assignment' | null;
|
|
1288
|
+
grantedUnderAccountId?: string | null;
|
|
1289
|
+
personalSpaceId?: string | null;
|
|
1290
|
+
personalSpacePath?: string | null;
|
|
1291
|
+
}
|
|
1292
|
+
interface AccountsState {
|
|
1293
|
+
/** Switcher-eligible accounts — billing-responsible accounts the user can operate AS. */
|
|
1294
|
+
accounts: AccountInfo[];
|
|
1295
|
+
/** Full membership list including mounts, spaces, cascade entries. Used for sidebar mount tree. */
|
|
1296
|
+
allMemberships: AccountInfo[];
|
|
1297
|
+
/** Currently active billing-responsible account (auto-selected if single, or after switchAccount). */
|
|
1298
|
+
currentAccount: AccountInfo | null;
|
|
1299
|
+
/** The currently mounted scope path (may differ from currentAccount.path when navigating subaccounts). */
|
|
1300
|
+
mountedScope: string | null;
|
|
1301
|
+
/** Switch the billing-responsible account context. Only for switcher entries. */
|
|
1302
|
+
switchAccount: (accountPath: string) => void;
|
|
1303
|
+
/** Mount a scope within the current billing context (e.g., navigate into a subaccount). Does NOT change currentAccount. */
|
|
1304
|
+
mountScope: (scopePath: string) => void;
|
|
1305
|
+
loading: boolean;
|
|
1306
|
+
error: Error | null;
|
|
1307
|
+
}
|
|
1308
|
+
/** Returns the user's account memberships and provides account switching. */
|
|
1309
|
+
declare function useAccounts(): AccountsState;
|
|
1310
|
+
interface AuthState {
|
|
1311
|
+
user: any | null;
|
|
1312
|
+
session: any | null;
|
|
1313
|
+
loading: boolean;
|
|
1314
|
+
signIn: (params: {
|
|
1315
|
+
email?: string;
|
|
1316
|
+
password?: string;
|
|
1317
|
+
provider?: string;
|
|
1318
|
+
redirectTo?: string;
|
|
1319
|
+
}) => Promise<any>;
|
|
1320
|
+
signUp: (params: {
|
|
1321
|
+
email: string;
|
|
1322
|
+
password: string;
|
|
1323
|
+
metadata?: Record<string, any>;
|
|
1324
|
+
}) => Promise<any>;
|
|
1325
|
+
signOut: () => Promise<void>;
|
|
1326
|
+
resetPassword: (email: string) => Promise<void>;
|
|
1327
|
+
signInWithMagicLink: (email: string, redirectTo?: string) => Promise<void>;
|
|
1328
|
+
}
|
|
1329
|
+
/** Reactive auth hook backed by Supabase auth. */
|
|
1330
|
+
declare function useAuth(): AuthState;
|
|
1331
|
+
interface AssetData {
|
|
1332
|
+
url: string;
|
|
1333
|
+
id?: string;
|
|
1334
|
+
name?: string;
|
|
1335
|
+
mimeType?: string;
|
|
1336
|
+
width?: number;
|
|
1337
|
+
height?: number;
|
|
1338
|
+
sizeBytes?: number;
|
|
1339
|
+
}
|
|
1340
|
+
/** Resolve an asset by UUID or path. */
|
|
1341
|
+
declare function useAsset(idOrPath: string | undefined | null): {
|
|
1342
|
+
data: AssetData | null;
|
|
1343
|
+
loading: boolean;
|
|
1344
|
+
error: Error | null;
|
|
1345
|
+
};
|
|
1346
|
+
/** Dynamically load a component from the edge. */
|
|
1347
|
+
declare function useComponent(path: string | undefined | null): {
|
|
1348
|
+
Component: any;
|
|
1349
|
+
loading: boolean;
|
|
1350
|
+
error: Error | null;
|
|
1351
|
+
};
|
|
1352
|
+
/** Read CSS custom properties from the document root. */
|
|
1353
|
+
declare function useTheme(): {
|
|
1354
|
+
data: {
|
|
1355
|
+
tokens: Record<string, string>;
|
|
1356
|
+
};
|
|
1357
|
+
loading: boolean;
|
|
1358
|
+
error: null;
|
|
1359
|
+
};
|
|
1360
|
+
/** Check permission for an action on a path. */
|
|
1361
|
+
declare function usePermission(_action?: string, _path?: string): {
|
|
1362
|
+
data: {
|
|
1363
|
+
allowed: boolean;
|
|
1364
|
+
};
|
|
1365
|
+
loading: boolean;
|
|
1366
|
+
error: null;
|
|
1367
|
+
};
|
|
1368
|
+
/** Check multiple permissions at once. */
|
|
1369
|
+
declare function usePermissions(_path?: string, actions?: string[]): {
|
|
1370
|
+
data: Record<string, boolean>;
|
|
1371
|
+
loading: boolean;
|
|
1372
|
+
error: null;
|
|
1373
|
+
};
|
|
1374
|
+
interface PrincipalData {
|
|
1375
|
+
id: string;
|
|
1376
|
+
principalId: string | null;
|
|
1377
|
+
email?: string;
|
|
1378
|
+
role: string;
|
|
1379
|
+
authenticated: boolean;
|
|
1380
|
+
metadata?: Record<string, any>;
|
|
1381
|
+
}
|
|
1382
|
+
/** Resolve current user's FSAOS os_principals.id from auth ID. */
|
|
1383
|
+
declare function resolvePrincipalId(authUserId?: string): Promise<string | null>;
|
|
1384
|
+
/** Returns the current principal (user identity). */
|
|
1385
|
+
declare function usePrincipal(): {
|
|
1386
|
+
data: PrincipalData | null;
|
|
1387
|
+
loading: boolean;
|
|
1388
|
+
error: null;
|
|
1389
|
+
};
|
|
1390
|
+
/** Stub: useTool — returns null tool data. */
|
|
1391
|
+
declare function useTool(): {
|
|
1392
|
+
data: null;
|
|
1393
|
+
loading: boolean;
|
|
1394
|
+
error: null;
|
|
1395
|
+
};
|
|
1396
|
+
/** <ComponentRenderer path="..." /> — runtime composition primitive. */
|
|
1397
|
+
declare function ComponentRenderer(props: {
|
|
1398
|
+
path: string;
|
|
1399
|
+
[key: string]: any;
|
|
1400
|
+
}): react__default.DetailedReactHTMLElement<{
|
|
1401
|
+
className: string;
|
|
1402
|
+
}, HTMLElement> | react__default.DetailedReactHTMLElement<react__default.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> | null;
|
|
1403
|
+
/** Passthrough wrapper for backward compatibility. */
|
|
1404
|
+
declare function KernelProvider(props: {
|
|
1405
|
+
children: any;
|
|
1406
|
+
}): any;
|
|
1407
|
+
interface ChannelMessagesOptions {
|
|
1408
|
+
channelPath: string | undefined | null;
|
|
1409
|
+
parentMessageId?: string;
|
|
1410
|
+
realtime?: boolean;
|
|
1411
|
+
enabled?: boolean;
|
|
1412
|
+
}
|
|
1413
|
+
/** Fetch channel messages via the kernel's `get-channel-messages` method. */
|
|
1414
|
+
declare function useChannelMessages(options: ChannelMessagesOptions): {
|
|
1415
|
+
messages: ChannelMessage[];
|
|
1416
|
+
threads: ChannelMessage[];
|
|
1417
|
+
isLoading: boolean;
|
|
1418
|
+
isFetching: boolean;
|
|
1419
|
+
error: Error | null;
|
|
1420
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<ChannelMessage[], Error>>;
|
|
1421
|
+
};
|
|
1422
|
+
/** Options for useInfiniteChannelMessages. */
|
|
1423
|
+
interface InfiniteChannelMessagesOptions {
|
|
1424
|
+
/** VFS path of the channel. Required. */
|
|
1425
|
+
channelPath: string | undefined | null;
|
|
1426
|
+
/**
|
|
1427
|
+
* If set, fetches thread replies (forward pagination with after_seq).
|
|
1428
|
+
* If omitted, fetches top-level messages (backward pagination with before_seq).
|
|
1429
|
+
*/
|
|
1430
|
+
parentMessageId?: string;
|
|
1431
|
+
/** Messages per page. Default 50, max 200. */
|
|
1432
|
+
limit?: number;
|
|
1433
|
+
/** Enable SSE-driven auto-refresh. Default: true. */
|
|
1434
|
+
realtime?: boolean;
|
|
1435
|
+
/** Standard useQuery enabled flag. Default: true (when channelPath is truthy). */
|
|
1436
|
+
enabled?: boolean;
|
|
1437
|
+
}
|
|
1438
|
+
/**
|
|
1439
|
+
* Infinite-scroll hook for channel messages.
|
|
1440
|
+
*
|
|
1441
|
+
* - **Top-level mode** (no parentMessageId): backward pagination.
|
|
1442
|
+
* Initial fetch returns the N most recent messages. `fetchPreviousPage`
|
|
1443
|
+
* loads older messages using `before_seq` = lowest seq in current data.
|
|
1444
|
+
*
|
|
1445
|
+
* - **Thread mode** (parentMessageId set): forward pagination.
|
|
1446
|
+
* Initial fetch returns the first N replies. `fetchNextPage` loads newer
|
|
1447
|
+
* replies using `after_seq` = highest seq in current data.
|
|
1448
|
+
*
|
|
1449
|
+
* Returns a flat `messages` array (deduped, sorted by seq ASC) plus
|
|
1450
|
+
* pagination state for scroll-triggered loading.
|
|
1451
|
+
*/
|
|
1452
|
+
declare function useInfiniteChannelMessages(options: InfiniteChannelMessagesOptions): {
|
|
1453
|
+
messages: ChannelMessage[];
|
|
1454
|
+
threads: ChannelMessage[];
|
|
1455
|
+
isLoading: boolean;
|
|
1456
|
+
isFetching: boolean;
|
|
1457
|
+
error: Error | null;
|
|
1458
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.InfiniteData<ChannelMessagesPage, unknown>, Error>>;
|
|
1459
|
+
hasPreviousPage: boolean;
|
|
1460
|
+
fetchPreviousPage: (options?: _tanstack_react_query.FetchPreviousPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<ChannelMessagesPage, unknown>, Error>>;
|
|
1461
|
+
isFetchingPreviousPage: boolean;
|
|
1462
|
+
hasNextPage: boolean;
|
|
1463
|
+
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<ChannelMessagesPage, unknown>, Error>>;
|
|
1464
|
+
isFetchingNextPage: boolean;
|
|
1465
|
+
};
|
|
1466
|
+
type ChannelAiMode = 'on' | 'off';
|
|
1467
|
+
interface Channel {
|
|
1468
|
+
id: string;
|
|
1469
|
+
path: string;
|
|
1470
|
+
name: string;
|
|
1471
|
+
displayName: string;
|
|
1472
|
+
/** Controls AI auto-response only: 'on' auto-responds, 'off' requires explicit invocation/member addressing. */
|
|
1473
|
+
aiMode: ChannelAiMode;
|
|
1474
|
+
isPrivate: boolean;
|
|
1475
|
+
isDm: boolean;
|
|
1476
|
+
messageCount: number;
|
|
1477
|
+
updatedAt: string;
|
|
1478
|
+
chatScopePath: string;
|
|
1479
|
+
contextId: string;
|
|
1480
|
+
contextPath: string;
|
|
1481
|
+
contextType: string;
|
|
1482
|
+
contextName: string;
|
|
1483
|
+
contextDisplayName: string;
|
|
1484
|
+
contextPrincipalId?: string;
|
|
1485
|
+
accountId: string;
|
|
1486
|
+
accountPath: string;
|
|
1487
|
+
accountDisplayName: string;
|
|
1488
|
+
memberRole: string;
|
|
1489
|
+
memberPath: string;
|
|
1490
|
+
modePath: string;
|
|
1491
|
+
autoPilot: boolean;
|
|
1492
|
+
}
|
|
1493
|
+
interface ChannelsOptions {
|
|
1494
|
+
realtime?: boolean;
|
|
1495
|
+
enabled?: boolean;
|
|
1496
|
+
}
|
|
1497
|
+
/** Fetch all channels (DMs + public) via `list-channels`. */
|
|
1498
|
+
declare function useAllChannels(options?: ChannelsOptions): {
|
|
1499
|
+
channels: Channel[];
|
|
1500
|
+
isLoading: boolean;
|
|
1501
|
+
isFetching: boolean;
|
|
1502
|
+
error: Error | null;
|
|
1503
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Channel[], Error>>;
|
|
1504
|
+
};
|
|
1505
|
+
/** Fetch public (non-DM) channels only. */
|
|
1506
|
+
declare function useChannels(options?: ChannelsOptions): {
|
|
1507
|
+
channels: Channel[];
|
|
1508
|
+
isLoading: boolean;
|
|
1509
|
+
isFetching: boolean;
|
|
1510
|
+
error: Error | null;
|
|
1511
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Channel[], Error>>;
|
|
1512
|
+
};
|
|
1513
|
+
/** Fetch DM channels only. */
|
|
1514
|
+
declare function useDmChannels(options?: ChannelsOptions): {
|
|
1515
|
+
channels: Channel[];
|
|
1516
|
+
isLoading: boolean;
|
|
1517
|
+
isFetching: boolean;
|
|
1518
|
+
error: Error | null;
|
|
1519
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Channel[], Error>>;
|
|
1520
|
+
};
|
|
1521
|
+
interface Notification {
|
|
1522
|
+
type: 'mention' | 'reply' | string;
|
|
1523
|
+
message_id: string;
|
|
1524
|
+
channel_id: string;
|
|
1525
|
+
channel_path: string;
|
|
1526
|
+
is_unread: boolean;
|
|
1527
|
+
}
|
|
1528
|
+
interface NotificationsOptions {
|
|
1529
|
+
filter?: 'unread' | 'all';
|
|
1530
|
+
limit?: number;
|
|
1531
|
+
realtime?: boolean;
|
|
1532
|
+
enabled?: boolean;
|
|
1533
|
+
}
|
|
1534
|
+
/** Fetch notifications via `get-notifications`. */
|
|
1535
|
+
declare function useNotifications(options?: NotificationsOptions): {
|
|
1536
|
+
notifications: Notification[];
|
|
1537
|
+
isLoading: boolean;
|
|
1538
|
+
isFetching: boolean;
|
|
1539
|
+
error: Error | null;
|
|
1540
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Notification[], Error>>;
|
|
1541
|
+
};
|
|
1542
|
+
interface UnreadCountsOptions {
|
|
1543
|
+
channels?: Channel[];
|
|
1544
|
+
realtime?: boolean;
|
|
1545
|
+
enabled?: boolean;
|
|
1546
|
+
}
|
|
1547
|
+
/** Aggregated unread counts per channel. */
|
|
1548
|
+
declare function useUnreadCounts(options?: UnreadCountsOptions): {
|
|
1549
|
+
unreadByChannel: Map<string, number>;
|
|
1550
|
+
totalUnread: number;
|
|
1551
|
+
dmUnread: number;
|
|
1552
|
+
channelUnread: number;
|
|
1553
|
+
isLoading: boolean;
|
|
1554
|
+
isFetching: boolean;
|
|
1555
|
+
error: Error | null;
|
|
1556
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Notification[], Error>>;
|
|
1557
|
+
};
|
|
1558
|
+
/** Create a new VFS item. Invalidates parent's children on success. */
|
|
1559
|
+
declare function useCreate(): _tanstack_react_query.UseMutationResult<any, Error, CreateParams, unknown>;
|
|
1560
|
+
/** Update an existing VFS item. */
|
|
1561
|
+
declare function useUpdate(): _tanstack_react_query.UseMutationResult<any, Error, UpdateParams, unknown>;
|
|
1562
|
+
/** Delete a VFS item. */
|
|
1563
|
+
declare function useDelete(): _tanstack_react_query.UseMutationResult<any, Error, DeleteParams, unknown>;
|
|
1564
|
+
/** Move a VFS item. */
|
|
1565
|
+
declare function useMove(): _tanstack_react_query.UseMutationResult<any, Error, MoveParams, unknown>;
|
|
1566
|
+
/** Create an edge between two items. Invalidates edges for both. */
|
|
1567
|
+
declare function useLink(): _tanstack_react_query.UseMutationResult<any, Error, LinkParams, unknown>;
|
|
1568
|
+
/**
|
|
1569
|
+
* Generic mutation hook for arbitrary kernel methods.
|
|
1570
|
+
* For methods not covered by useCreate/useUpdate/useDelete/useMove/useLink.
|
|
1571
|
+
*
|
|
1572
|
+
* @example
|
|
1573
|
+
* const archiveTask = useMutation('archive-task');
|
|
1574
|
+
* await archiveTask.mutateAsync({ task_id: '...' });
|
|
1575
|
+
*/
|
|
1576
|
+
declare function useMutation(method: string, options?: {
|
|
1577
|
+
onSuccess?: (data: any) => void;
|
|
1578
|
+
onError?: (error: any) => void;
|
|
1579
|
+
optimistic?: {
|
|
1580
|
+
queryKey: readonly unknown[];
|
|
1581
|
+
update: (old: any, params: Record<string, unknown>) => any;
|
|
1582
|
+
};
|
|
1583
|
+
}): _tanstack_react_query.UseMutationResult<GatewayResponse, any, Record<string, unknown>, any>;
|
|
1584
|
+
/**
|
|
1585
|
+
* Subscribe to SSE events of a given type.
|
|
1586
|
+
* Calls the handler whenever an event arrives, optionally filtered by predicate.
|
|
1587
|
+
*
|
|
1588
|
+
* @example
|
|
1589
|
+
* useEventStream('vfs_change', (event) => {
|
|
1590
|
+
* console.log('VFS changed:', event);
|
|
1591
|
+
* });
|
|
1592
|
+
*/
|
|
1593
|
+
declare function useEventStream(handlerOrEventType: string | ((data: any) => void), handlerOrOptions?: ((data: any) => void) | {
|
|
1594
|
+
eventType: string;
|
|
1595
|
+
filter?: (data: any) => boolean;
|
|
1596
|
+
enabled?: boolean;
|
|
1597
|
+
}, filter?: (data: any) => boolean): void;
|
|
1598
|
+
/**
|
|
1599
|
+
* A useQuery wrapper that auto-refetches on matching SSE events.
|
|
1600
|
+
*
|
|
1601
|
+
* @example
|
|
1602
|
+
* const { data } = useRealtimeQuery({
|
|
1603
|
+
* queryKey: ['my-data'],
|
|
1604
|
+
* queryFn: () => fetchMyData(),
|
|
1605
|
+
* eventType: 'vfs_change',
|
|
1606
|
+
* filter: (data) => data.path.startsWith('/root/foo'),
|
|
1607
|
+
* });
|
|
1608
|
+
*/
|
|
1609
|
+
declare function useRealtimeQuery<T>(options: {
|
|
1610
|
+
queryKey: readonly unknown[];
|
|
1611
|
+
queryFn: () => Promise<T>;
|
|
1612
|
+
eventType: string | string[];
|
|
1613
|
+
filter?: (data: any) => boolean;
|
|
1614
|
+
enabled?: boolean;
|
|
1615
|
+
debounceMs?: number;
|
|
1616
|
+
}): _tanstack_react_query.UseQueryResult<_tanstack_react_query.NoInfer<T>, Error>;
|
|
1617
|
+
|
|
1618
|
+
/**
|
|
1619
|
+
* @fsaos/gateway — Schema Interpretation Utilities
|
|
1620
|
+
*
|
|
1621
|
+
* Derives UI capabilities (filterable fields, sortable fields, table columns,
|
|
1622
|
+
* form fields) from a type definition's input_schema and system_schema.
|
|
1623
|
+
*
|
|
1624
|
+
* The type definition IS the contract. These utilities read it and return
|
|
1625
|
+
* structured metadata that UI components use to render generically.
|
|
1626
|
+
*/
|
|
1627
|
+
|
|
1628
|
+
/** A field descriptor derived from the type's JSON Schema. */
|
|
1629
|
+
interface FieldDescriptor {
|
|
1630
|
+
/** Field key (property name in type_data). */
|
|
1631
|
+
key: string;
|
|
1632
|
+
/** Human-readable label derived from schema title or key. */
|
|
1633
|
+
label: string;
|
|
1634
|
+
/** JSON Schema type (string, number, integer, boolean, array, object). */
|
|
1635
|
+
type: string;
|
|
1636
|
+
/** Description from schema. */
|
|
1637
|
+
description?: string;
|
|
1638
|
+
/** Enum values if constrained. */
|
|
1639
|
+
enum_values?: string[];
|
|
1640
|
+
/** Default value from default_data or field_defaults. */
|
|
1641
|
+
default_value?: any;
|
|
1642
|
+
/** Whether this field is user-editable (from input_schema) or system-managed. */
|
|
1643
|
+
editable: boolean;
|
|
1644
|
+
/** Whether this field can be used as a filter. */
|
|
1645
|
+
filterable: boolean;
|
|
1646
|
+
/** Whether this field can be sorted on. */
|
|
1647
|
+
sortable: boolean;
|
|
1648
|
+
/** Suggested filter widget type. */
|
|
1649
|
+
filter_widget: 'select' | 'text' | 'toggle' | 'range' | 'date' | 'none';
|
|
1650
|
+
}
|
|
1651
|
+
/** Complete schema interpretation result for a type. */
|
|
1652
|
+
interface TypeSchema {
|
|
1653
|
+
/** All fields (input + system), ordered as declared. */
|
|
1654
|
+
fields: FieldDescriptor[];
|
|
1655
|
+
/** Fields suitable for table columns (non-object, non-array). */
|
|
1656
|
+
columns: FieldDescriptor[];
|
|
1657
|
+
/** Fields that can be filtered on. */
|
|
1658
|
+
filterable: FieldDescriptor[];
|
|
1659
|
+
/** Fields that can be sorted on. */
|
|
1660
|
+
sortable: FieldDescriptor[];
|
|
1661
|
+
/** Fields for creation/edit forms (input_schema only). */
|
|
1662
|
+
form_fields: FieldDescriptor[];
|
|
1663
|
+
/** Fields that are system-managed (read-only display). */
|
|
1664
|
+
system_fields: FieldDescriptor[];
|
|
1665
|
+
}
|
|
1666
|
+
/**
|
|
1667
|
+
* Interpret a type definition's schemas and return structured field metadata.
|
|
1668
|
+
*
|
|
1669
|
+
* @example
|
|
1670
|
+
* const typeDef = useType('project');
|
|
1671
|
+
* const schema = interpretSchema(typeDef);
|
|
1672
|
+
* // schema.columns → fields to show in table
|
|
1673
|
+
* // schema.filterable → fields to offer as filters
|
|
1674
|
+
* // schema.form_fields → fields for create/edit form
|
|
1675
|
+
*/
|
|
1676
|
+
declare function interpretSchema(typeDef: TypeDefinition): TypeSchema;
|
|
1677
|
+
/**
|
|
1678
|
+
* Get the default sort field for a type.
|
|
1679
|
+
* Returns 'updated_at' as the universal default (column on os_items).
|
|
1680
|
+
*/
|
|
1681
|
+
declare function getDefaultSort(_typeDef: TypeDefinition): {
|
|
1682
|
+
field: string;
|
|
1683
|
+
direction: 'asc' | 'desc';
|
|
1684
|
+
};
|
|
1685
|
+
/**
|
|
1686
|
+
* Get the creation form schema for a type — only editable fields
|
|
1687
|
+
* that don't have defaults (i.e., the user must provide them).
|
|
1688
|
+
*/
|
|
1689
|
+
declare function getRequiredFormFields(typeDef: TypeDefinition): FieldDescriptor[];
|
|
1690
|
+
|
|
1691
|
+
/**
|
|
1692
|
+
* @fsaos/gateway — File Upload
|
|
1693
|
+
*
|
|
1694
|
+
* Two exports:
|
|
1695
|
+
* - uploadFile() — imperative, returns a Promise. Use from Fractals, scripts,
|
|
1696
|
+
* non-React contexts, or anywhere you just need the result.
|
|
1697
|
+
* - useFileUpload() — React hook wrapping uploadFile() with reactive state
|
|
1698
|
+
* (progress tracking, retry, cancel, uploads list).
|
|
1699
|
+
*
|
|
1700
|
+
* Both orchestrate the same three-step dance:
|
|
1701
|
+
* 1. gatewayCall('create', { file_source }) → VFS item + storage instruction
|
|
1702
|
+
* 2. PUT binary → storage worker (direct upload, no gateway proxy)
|
|
1703
|
+
* 3. POST /storage/upload-complete → gateway verifies + commits file_ref
|
|
1704
|
+
*
|
|
1705
|
+
* The consumer never sees storage_instruction, upload_token, or the
|
|
1706
|
+
* upload-complete endpoint. They call upload(file, opts) and get a result.
|
|
1707
|
+
*/
|
|
1708
|
+
interface FileRef {
|
|
1709
|
+
storage_key: string;
|
|
1710
|
+
provider: string;
|
|
1711
|
+
content_type: string;
|
|
1712
|
+
size_bytes: number;
|
|
1713
|
+
version: number;
|
|
1714
|
+
etag?: string;
|
|
1715
|
+
}
|
|
1716
|
+
interface UploadOptions {
|
|
1717
|
+
/** VFS path where the file item will be created (required). */
|
|
1718
|
+
parentPath: string;
|
|
1719
|
+
/** Override the file name (defaults to File.name). */
|
|
1720
|
+
name?: string;
|
|
1721
|
+
/** Override item_type (defaults to 'file'). */
|
|
1722
|
+
itemType?: string;
|
|
1723
|
+
/** Additional type_data fields to merge onto the created item. */
|
|
1724
|
+
typeData?: Record<string, unknown>;
|
|
1725
|
+
}
|
|
1726
|
+
interface UploadResult {
|
|
1727
|
+
itemId: string;
|
|
1728
|
+
itemPath: string;
|
|
1729
|
+
fileRef: FileRef;
|
|
1730
|
+
}
|
|
1731
|
+
interface UploadItem {
|
|
1732
|
+
/** Client-generated tracking ID. */
|
|
1733
|
+
id: string;
|
|
1734
|
+
/** The original File object. */
|
|
1735
|
+
file: File;
|
|
1736
|
+
/** Current status in the three-step dance. */
|
|
1737
|
+
status: 'creating' | 'uploading' | 'confirming' | 'complete' | 'error';
|
|
1738
|
+
/** Upload progress 0–100 (only meaningful during 'uploading'). */
|
|
1739
|
+
progress: number;
|
|
1740
|
+
/** Error message if status is 'error'. */
|
|
1741
|
+
error: string | null;
|
|
1742
|
+
/** VFS item ID (available after 'creating' succeeds). */
|
|
1743
|
+
itemId: string | null;
|
|
1744
|
+
/** VFS item path. */
|
|
1745
|
+
itemPath: string | null;
|
|
1746
|
+
/** Completed file_ref (available when status is 'complete'). */
|
|
1747
|
+
fileRef: FileRef | null;
|
|
1748
|
+
/** The options that were passed to upload(). */
|
|
1749
|
+
options: UploadOptions;
|
|
1750
|
+
}
|
|
1751
|
+
interface UseFileUploadReturn {
|
|
1752
|
+
/** Upload a single file. */
|
|
1753
|
+
upload: (file: File, options: UploadOptions) => void;
|
|
1754
|
+
/** Upload multiple files to the same destination. */
|
|
1755
|
+
uploadMultiple: (files: File[], options: UploadOptions) => void;
|
|
1756
|
+
/** Reactive list of all uploads (in-progress, completed, failed). */
|
|
1757
|
+
uploads: UploadItem[];
|
|
1758
|
+
/** Retry a failed upload from the step it failed at. */
|
|
1759
|
+
retryUpload: (uploadId: string) => void;
|
|
1760
|
+
/** Cancel an in-progress upload (aborts XHR if uploading). */
|
|
1761
|
+
cancelUpload: (uploadId: string) => void;
|
|
1762
|
+
/** Remove a completed or failed upload from the list. */
|
|
1763
|
+
removeUpload: (uploadId: string) => void;
|
|
1764
|
+
/** Remove all completed uploads from the list. */
|
|
1765
|
+
clearCompleted: () => void;
|
|
1766
|
+
/** True if any upload is currently in progress. */
|
|
1767
|
+
isUploading: boolean;
|
|
1768
|
+
}
|
|
1769
|
+
/**
|
|
1770
|
+
* Upload a file to the VFS. Handles the full three-step dance:
|
|
1771
|
+
* create → upload binary → confirm.
|
|
1772
|
+
*
|
|
1773
|
+
* @param file The File or Blob to upload.
|
|
1774
|
+
* @param options Where to put it and what to call it.
|
|
1775
|
+
* @param onProgress Optional callback for upload progress (0–100).
|
|
1776
|
+
* @param signal Optional AbortSignal for cancellation.
|
|
1777
|
+
* @returns The created item's ID, path, and committed file_ref.
|
|
1778
|
+
*/
|
|
1779
|
+
declare function uploadFile(file: File | Blob, options: UploadOptions, onProgress?: (percent: number) => void, signal?: AbortSignal): Promise<UploadResult>;
|
|
1780
|
+
/**
|
|
1781
|
+
* React hook for file uploads. Wraps uploadFile() with reactive state:
|
|
1782
|
+
* tracks progress, supports retry from the failed step, cancel, and
|
|
1783
|
+
* manages a list of concurrent uploads.
|
|
1784
|
+
*
|
|
1785
|
+
* @example
|
|
1786
|
+
* ```tsx
|
|
1787
|
+
* const { upload, uploads, isUploading } = useFileUpload();
|
|
1788
|
+
*
|
|
1789
|
+
* const handleDrop = (files: File[]) => {
|
|
1790
|
+
* for (const file of files) {
|
|
1791
|
+
* upload(file, { parentPath: '/root/accounts/.../drive' });
|
|
1792
|
+
* }
|
|
1793
|
+
* };
|
|
1794
|
+
*
|
|
1795
|
+
* return (
|
|
1796
|
+
* <div onDrop={handleDrop}>
|
|
1797
|
+
* {uploads.map(u => (
|
|
1798
|
+
* <div key={u.id}>{u.file.name} — {u.status} — {u.progress}%</div>
|
|
1799
|
+
* ))}
|
|
1800
|
+
* </div>
|
|
1801
|
+
* );
|
|
1802
|
+
* ```
|
|
1803
|
+
*/
|
|
1804
|
+
declare function useFileUpload(): UseFileUploadReturn;
|
|
1805
|
+
|
|
1806
|
+
export { type AccountInfo, type Channel, type ChannelMessage, type ChannelMessagesOptions, type ChannelMessagesPage, type ChannelsOptions, type ComponentOpener, ComponentRenderer, type CreateParams, type DeleteParams, EnforcementDeniedError, type EnforcementPayload, type FieldDescriptor, type FileRef, type GatewayParams, type GatewayResponse, type InfiniteChannelMessagesOptions, type ItemsFilter, KernelProvider, type LinkParams, type MoveParams, type Notification, type NotificationsOptions, type OpenEnvelope, type OpenOptions, type PrincipalData, type SessionEntry, type TypeDefinition, type TypeHelpers, type TypeSchema, type UnreadCountsOptions, type UpdateParams, type UploadItem, type UploadOptions, type UploadResult, type UseFileUploadReturn, type VFSEdge, type VFSItem, auth, awaitScopeReady, callTool, clearCachedToken, clearSession, createItem, disconnectSSE, disposeVfsRealtimeWs, emitEvent, fetchChannelMessages, fetchChannelMessagesPage, fetchEdgesForItem, fetchItemHistory, fetchItems, fetchMemberFocus, fetchOpenEnvelope, fetchRecentActivity, fetchTypeDefinitions, fetchVfsChildren, fetchVfsChildrenPage, fetchVfsItem, fetchVfsItemById, fetchVfsTree, gatewayCall, getAccessToken, getAssetUrl, getDefaultSort, getRequiredFormFields, getScope, getScopeVersion, getSessionEntry, initSession, initVfsRealtimeWs, interpretSchema, invalidateAllVfs, invalidateChannelMessages, invalidateChildren, invalidateItem, invalidateOpenEnvelope, invalidatePathAndParent, invalidateSubtree, invalidateTypes, isScopeReady, listChildren, mount, mountRealtimeScope, normalizeItem, ping, pushChanges, queryClient, readItem, registerCleanup, resetAllSdkState, resolvePrincipalId, setCachedToken, setScope, setupRequireShim, signal, subscribeScope, subscribeToEvents, subscribeToPath, subscribeToScope, unmountRealtimeScope, updateItem, uploadFile, useAccounts, useAllChannels, useAsset, useAuth, useChannelMessages, useChannels, useChildren, useComponent, useCreate, useDelete, useDmChannels, useEdges, useEventStream, useFileUpload, useInfiniteChannelMessages, useInfiniteChildren, useInfiniteItems, useItem, useItemById, useItemHistory, useItems, useLink, useList, useMemberFocus, useMove, useMutation, useNotifications, useOpen, usePermission, usePermissions, usePrincipal, useRealtimeQuery, useRecentActivity, useScope, useScopeReady, useSearch, useTheme, useTool, useTree, useType, useTypeHelpers, useTypes, useUnreadCounts, useUpdate, vfsKeys };
|