@ai4b-team/fsaos-gateway-sdk 5.4.2 → 5.5.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/dist/index.d.cts CHANGED
@@ -372,7 +372,10 @@ type PersonalItemOrderKey = 'channel-order' | 'project-order';
372
372
  declare function usePersonalItemOrder<T extends {
373
373
  id: string;
374
374
  createdAt?: string;
375
- }>(key: PersonalItemOrderKey, items: readonly T[]): {
375
+ }>(key: PersonalItemOrderKey, items: readonly T[], space?: {
376
+ id: string;
377
+ path: string;
378
+ }): {
376
379
  items: T[];
377
380
  ready: boolean;
378
381
  supported: boolean;
@@ -1270,6 +1273,10 @@ interface ChannelMessage {
1270
1273
  principal_id?: string;
1271
1274
  /** The sender's member item id, when the kernel recorded one (agent replies carry it). */
1272
1275
  member_id?: string;
1276
+ /** Saved author identity; survives the sender leaving the current chat roster. */
1277
+ sender_display_name?: string;
1278
+ sender_is_ai?: boolean;
1279
+ sender_role_display_name?: string;
1273
1280
  /** Replies under this message. Above zero, a top-level message is a thread (a side conversation inside the chat). */
1274
1281
  reply_count: number;
1275
1282
  /**
@@ -2720,6 +2727,7 @@ declare function useArrangement(paramsOrPath: string | {
2720
2727
  path?: string;
2721
2728
  item_id?: string;
2722
2729
  scope_id?: string;
2730
+ _scope_path?: string;
2723
2731
  } | null | undefined): {
2724
2732
  arrangement: any;
2725
2733
  resolvedChildren: any[];
@@ -3760,7 +3768,7 @@ declare function serverMsUntil(deadlineIso: unknown): number | null;
3760
3768
  interface PinTarget {
3761
3769
  id: string;
3762
3770
  path?: string;
3763
- item_type: 'channel' | 'message' | 'folder';
3771
+ item_type: 'channel' | 'message' | 'folder' | 'project';
3764
3772
  name?: string;
3765
3773
  parent_id?: string;
3766
3774
  type_data?: Record<string, any>;
@@ -3778,7 +3786,10 @@ interface PinnedItem {
3778
3786
  * Provisioning and access decisions belong to FSAOS. This hook never creates a
3779
3787
  * missing arrangement and never falls back to another membership's collection.
3780
3788
  */
3781
- declare function usePinnedItems(): {
3789
+ declare function usePinnedItems(space?: {
3790
+ id: string;
3791
+ path: string;
3792
+ }): {
3782
3793
  entries: PinnedItem[];
3783
3794
  isLoading: boolean;
3784
3795
  error: Error | null;
package/dist/index.d.ts CHANGED
@@ -372,7 +372,10 @@ type PersonalItemOrderKey = 'channel-order' | 'project-order';
372
372
  declare function usePersonalItemOrder<T extends {
373
373
  id: string;
374
374
  createdAt?: string;
375
- }>(key: PersonalItemOrderKey, items: readonly T[]): {
375
+ }>(key: PersonalItemOrderKey, items: readonly T[], space?: {
376
+ id: string;
377
+ path: string;
378
+ }): {
376
379
  items: T[];
377
380
  ready: boolean;
378
381
  supported: boolean;
@@ -1270,6 +1273,10 @@ interface ChannelMessage {
1270
1273
  principal_id?: string;
1271
1274
  /** The sender's member item id, when the kernel recorded one (agent replies carry it). */
1272
1275
  member_id?: string;
1276
+ /** Saved author identity; survives the sender leaving the current chat roster. */
1277
+ sender_display_name?: string;
1278
+ sender_is_ai?: boolean;
1279
+ sender_role_display_name?: string;
1273
1280
  /** Replies under this message. Above zero, a top-level message is a thread (a side conversation inside the chat). */
1274
1281
  reply_count: number;
1275
1282
  /**
@@ -2720,6 +2727,7 @@ declare function useArrangement(paramsOrPath: string | {
2720
2727
  path?: string;
2721
2728
  item_id?: string;
2722
2729
  scope_id?: string;
2730
+ _scope_path?: string;
2723
2731
  } | null | undefined): {
2724
2732
  arrangement: any;
2725
2733
  resolvedChildren: any[];
@@ -3760,7 +3768,7 @@ declare function serverMsUntil(deadlineIso: unknown): number | null;
3760
3768
  interface PinTarget {
3761
3769
  id: string;
3762
3770
  path?: string;
3763
- item_type: 'channel' | 'message' | 'folder';
3771
+ item_type: 'channel' | 'message' | 'folder' | 'project';
3764
3772
  name?: string;
3765
3773
  parent_id?: string;
3766
3774
  type_data?: Record<string, any>;
@@ -3778,7 +3786,10 @@ interface PinnedItem {
3778
3786
  * Provisioning and access decisions belong to FSAOS. This hook never creates a
3779
3787
  * missing arrangement and never falls back to another membership's collection.
3780
3788
  */
3781
- declare function usePinnedItems(): {
3789
+ declare function usePinnedItems(space?: {
3790
+ id: string;
3791
+ path: string;
3792
+ }): {
3782
3793
  entries: PinnedItem[];
3783
3794
  isLoading: boolean;
3784
3795
  error: Error | null;
package/dist/index.js CHANGED
@@ -2201,6 +2201,9 @@ function parseChannelMessages(rawItems) {
2201
2201
  seq: td.seq || 0,
2202
2202
  principal_id: td.principal_id,
2203
2203
  member_id: typeof td.member_id === "string" ? td.member_id : void 0,
2204
+ sender_display_name: typeof td.sender_display_name === "string" ? td.sender_display_name : void 0,
2205
+ sender_is_ai: typeof td.sender_is_ai === "boolean" ? td.sender_is_ai : void 0,
2206
+ sender_role_display_name: typeof td.sender_role_display_name === "string" ? td.sender_role_display_name : void 0,
2204
2207
  reply_count: td.reply_count || 0,
2205
2208
  member_count: td.member_count || 0,
2206
2209
  parent_message_id: td.parent_message_id,
@@ -5007,13 +5010,14 @@ function useRealtimeQuery(options) {
5007
5010
  }
5008
5011
  function useArrangement(paramsOrPath) {
5009
5012
  useScopeKey();
5010
- const scopePath = getScope();
5013
+ const mountedScope = getScope();
5011
5014
  const resolvedParams = useMemo(() => {
5012
5015
  if (!paramsOrPath) return null;
5013
5016
  if (typeof paramsOrPath === "string") return { path: paramsOrPath };
5014
5017
  return paramsOrPath;
5015
5018
  }, [typeof paramsOrPath === "string" ? paramsOrPath : JSON.stringify(paramsOrPath)]);
5016
- const enabled2 = !!scopePath && !!resolvedParams && !!(resolvedParams.key || resolvedParams.path || resolvedParams.item_id);
5019
+ const scopePath = resolvedParams?._scope_path ?? mountedScope;
5020
+ const enabled2 = !!mountedScope && !!scopePath && !!resolvedParams && !!(resolvedParams.key || resolvedParams.path || resolvedParams.item_id);
5017
5021
  const cacheKey = resolvedParams?.key ?? resolvedParams?.path ?? resolvedParams?.item_id ?? "";
5018
5022
  const arrangementQueryKey = ["vfs", scopePath ?? "__unscoped__", "arrangement", cacheKey, resolvedParams?.scope_id ?? ""];
5019
5023
  const query = useQuery({
@@ -5236,12 +5240,17 @@ function retryRead(attempt, error) {
5236
5240
  }
5237
5241
 
5238
5242
  // src/personal-item-order.ts
5239
- function usePersonalItemOrder(key, items) {
5243
+ function usePersonalItemOrder(key, items, space) {
5240
5244
  const generation = useSyncExternalStore(subscribeScope, getScopeVersion, getScopeVersion);
5241
5245
  const anchor = getAnchorRef();
5242
- const scopePath = getScope();
5243
- const supported = anchor?.kind === "space";
5244
- const query = useArrangement(supported && scopePath ? { key, scope_id: anchor.id } : null);
5246
+ const mountedScope = getScope();
5247
+ const scopePath = space?.path ?? mountedScope;
5248
+ const scopeId = space?.id ?? anchor?.id;
5249
+ const supported = Boolean(space?.id && space.path) || anchor?.kind === "space";
5250
+ const identity = useMemo(() => ({}), [generation, mountedScope, scopePath, scopeId]);
5251
+ const activeIdentity = useRef(identity);
5252
+ activeIdentity.current = identity;
5253
+ const query = useArrangement(supported && scopePath ? { key, scope_id: scopeId, _scope_path: scopePath } : null);
5245
5254
  const orderedItems = useMemo(() => {
5246
5255
  const arranged = query.applyTo([...items]);
5247
5256
  if (key !== "channel-order") return arranged;
@@ -5267,7 +5276,7 @@ function usePersonalItemOrder(key, items) {
5267
5276
  onSettled: (_data, _error, change) => refreshArrangement(client2, change.queryKey)
5268
5277
  });
5269
5278
  async function reorder(ids) {
5270
- if (!ready || !scopePath || generation !== getScopeVersion() || getScope() !== scopePath) {
5279
+ if (!ready || !scopePath || identity !== activeIdentity.current || generation !== getScopeVersion() || getScope() !== mountedScope) {
5271
5280
  throw new Error("Personal order is not available in this Space");
5272
5281
  }
5273
5282
  if (pending4.current) throw new Error("An order change is already being saved");
@@ -6820,11 +6829,16 @@ function normalizeRow(row) {
6820
6829
  meta: row.meta != null ? row.meta : void 0
6821
6830
  };
6822
6831
  }
6823
- function usePinnedItems() {
6824
- useSyncExternalStore(subscribeScope, getScopeVersion, getScopeVersion);
6825
- const scopePath = getScope();
6832
+ function usePinnedItems(space) {
6833
+ const generation = useSyncExternalStore(subscribeScope, getScopeVersion, getScopeVersion);
6834
+ const mountedScope = getScope();
6835
+ const scopePath = space?.path ?? mountedScope;
6826
6836
  const anchor = getAnchorRef();
6827
- const query = useArrangement(scopePath ? { key: "pinned", ...anchor ? { scope_id: anchor.id } : {} } : null);
6837
+ const scopeId = space?.id ?? anchor?.id;
6838
+ const identity = useMemo(() => ({}), [generation, mountedScope, scopePath, scopeId]);
6839
+ const activeIdentity = useRef(identity);
6840
+ activeIdentity.current = identity;
6841
+ const query = useArrangement(scopePath ? { key: "pinned", scope_id: scopeId, _scope_path: scopePath } : null);
6828
6842
  const client2 = useQueryClient();
6829
6843
  const entries = query.resolvedChildren;
6830
6844
  const ready = Boolean(!query.error && query.arrangement?.item_id && query.resolutionLevel === "member" && query.arrangement.write_target_id === query.arrangement.item_id);
@@ -6851,7 +6865,7 @@ function usePinnedItems() {
6851
6865
  onSettled: (_data, _error, change2) => refreshArrangement(client2, change2.queryKey)
6852
6866
  });
6853
6867
  const change = useCallback((value) => {
6854
- if (!ready || !scopePath || getScope() !== scopePath) return Promise.reject(new Error("Personal pins are not available in this context"));
6868
+ if (!ready || !scopePath || activeIdentity.current !== identity || generation !== getScopeVersion() || getScope() !== mountedScope) return Promise.reject(new Error("Personal pins are not available in this context"));
6855
6869
  if (value.operation === "unpin" && !entries.some((entry) => entry.id === value.entry.id)) return Promise.reject(new Error("Pin is outside this arrangement"));
6856
6870
  if (value.operation === "reorder" && (new Set(value.ids).size !== entries.length || value.ids.length !== entries.length || entries.some((entry) => !value.ids.includes(entry.id)))) return Promise.reject(new Error("Order must include each pin exactly once"));
6857
6871
  if (value.operation === "pin" && entries.some((entry) => entry.symlink_type_data?.target_item_id === value.target.id)) return Promise.resolve(null);
@@ -6862,7 +6876,7 @@ function usePinnedItems() {
6862
6876
  arrangementPath: query.arrangement.item_path,
6863
6877
  queryKey: query.arrangementQueryKey
6864
6878
  });
6865
- }, [ready, scopePath, entries, query.arrangement, query.arrangementQueryKey, mutation.mutateAsync]);
6879
+ }, [ready, generation, mountedScope, scopePath, identity, entries, query.arrangement, query.arrangementQueryKey, mutation.mutateAsync]);
6866
6880
  return {
6867
6881
  entries,
6868
6882
  isLoading: query.isLoading,