@ai4b-team/fsaos-gateway-sdk 5.7.0 → 5.8.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/README.md CHANGED
@@ -241,6 +241,7 @@ The typed surface of the membership doors (Agent System Master Spec D13–D21).
241
241
  | `useAsset(idOrPath)` | Resolve an asset URL |
242
242
  | `useComponent(path, { version }?)` | Dynamically load a component from the edge |
243
243
  | `usePublishedComponent(item)` | Load a component's published in-app version, read through the kernel |
244
+ | `useCompiledComponent(build)` | Load a component's compiled build (one an agent made during a reply), read through the kernel |
244
245
  | `useTheme()` | Read theme CSS custom properties |
245
246
 
246
247
  `useComponent` loads a component bundle and runs it on the host page's own
@@ -268,6 +269,21 @@ session is at most four kernel calls and two file reads; after that it is held
268
269
  until the session ends. `loadPublishedBundle(item)` gives the same script and
269
270
  stylesheet to a host that is not React.
270
271
 
272
+ `useCompiledComponent(build)` is the same loader for a build no release sealed:
273
+ a component an agent wrote and the Script Worker compiled during a reply. The
274
+ build is one `file` item under the component holding the JSON
275
+ `{ js, css, scope }`; pass `{ fileId, sha256 }` as the card that shows it names
276
+ them (and `scopePath` when the file is read in another scope). The file is read through the kernel as
277
+ the signed-in person, bytes that are not the ones named are never run, and the
278
+ script runs on the host page's own React and SDK: a `require('@fsaos/gateway')`
279
+ in it answers with this SDK, so the component can use every hook and call. It
280
+ returns `{ Component, scopeClass, status, error }`, where `status` is `loading`,
281
+ `ready` or `error`. Wrap the component in an element that carries `scopeClass`:
282
+ it is the class the compile scoped the stylesheet under, so the stylesheet
283
+ styles the component and nothing else on the page. One read serves every view
284
+ of a build. `loadCompiledBundle(build)`
285
+ gives the script and stylesheet to a host that is not React.
286
+
271
287
  `useInfiniteItems(filter, { realtime: true })` uses the existing WebSocket event
272
288
  dispatch and reconnect recovery. As with the other realtime hooks, the host
273
289
  must hold an SDK account or path subscription (directly or via SDK bootstrap).
@@ -528,3 +544,41 @@ relevant edge/message changes and releases its watcher on close. It never polls.
528
544
  `fetchNextPage()` is explicit, including when an authorization-filtered page is
529
545
  empty but has another cursor. Mounting one reader per closed message is unnecessary:
530
546
  use the already-loaded history's `reply_to` projection for summaries.
547
+
548
+ ## Native item permission checks
549
+
550
+ `usePermission(action, item)` and `usePermissions(item, actions)` call the existing
551
+ FSAOS `check-item-access` method as the authenticated SDK session. Supported native
552
+ actions are `view`, `edit`, `delete`, and `admin`. Prefer an already-resolved item
553
+ UUID; an absolute VFS path uses one shared `read` to resolve its UUID first.
554
+
555
+ ```tsx
556
+ const { data, loading, error, refetch } = usePermissions(item.id, ['view', 'edit']);
557
+ // Or: usePermission('edit', item.id).data.allowed
558
+ if (loading) return <span>Checking access…</span>;
559
+ if (error) return <button onClick={() => void refetch()}>Retry access check</button>;
560
+ return <button disabled={!data.edit}>Edit</button>;
561
+ ```
562
+
563
+ The host must initialize an authenticated SDK session and provide the shared
564
+ `QueryClientProvider`/`setQueryClient` instance. Missing/anonymous context, loading,
565
+ refreshing, errors and malformed responses never report allowed. Unsupported
566
+ actions or non-UUID/non-absolute-path targets report `PERMISSION_INPUT_INVALID`.
567
+ These hooks do not create an approval request or grant access. They check native
568
+ item access, not an action allowance, entitlement or every method-specific rule;
569
+ the actual kernel operation remains authoritative.
570
+
571
+ Each distinct visible item/action has one shared query. Identical consumers reuse
572
+ it, including consumers mixing the two hooks. There are no interval reads, retries,
573
+ focus reads or per-hook subscriptions. Existing workspace VFS/CCM events invalidate
574
+ matching checks; membership/sharing changes refresh the affected mounted scope.
575
+ Bursts coalesce, old grants disappear immediately, and stream resync refreshes
576
+ active checks. Closing the last observer discards the check, so reopening checks
577
+ again. A host using the SDK without workspace events must explicitly `refetch`
578
+ after its own permission changes. Calls are also eligible for the existing
579
+ `configureGatewayReads` concurrency and cancellation controls.
580
+
581
+ Tokenless `hostSession` frames do not have a seated identity of their own. Render
582
+ permission-dependent host controls in the authenticated host; these hooks remain
583
+ false in an unseated frame. Frame operations still use the host's governed gateway
584
+ calls. Do not invent a principal or copy a bearer into the frame to enable a UI.