@ai4b-team/fsaos-gateway-sdk 4.2.0 → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/iife/ui.js CHANGED
@@ -1,3 +1,3 @@
1
- /* @fsaos/ui v2.0.0 — FSAOS UI Primitives — 2026-10-31T01:05:49.771Z */
1
+ /* @fsaos/ui v2.0.0 — FSAOS UI Primitives — 2026-11-04T22:00:56.912Z */
2
2
  "use strict";var __FSAOS_UI__=(()=>{var m=Object.create;var r=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var y=(e,i)=>()=>(i||e((i={exports:{}}).exports,i),i.exports),N=(e,i)=>{for(var a in i)r(e,a,{get:i[a],enumerable:!0})},s=(e,i,a,l)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of u(i))!h.call(e,t)&&t!==a&&r(e,t,{get:()=>i[t],enumerable:!(l=g(i,t))||l.enumerable});return e};var x=(e,i,a)=>(a=e!=null?m(f(e)):{},s(i||!e||!e.__esModule?r(a,"default",{value:e,enumerable:!0}):a,e)),b=e=>s(r({},"__esModule",{value:!0}),e);var d=y((V,c)=>{c.exports=React});var P={};N(P,{Badge:()=>z,Breadcrumbs:()=>A,Button:()=>D,Card:()=>w,DataView:()=>R,Detail:()=>_,Empty:()=>I,FilePreview:()=>O,Form:()=>F,Grid:()=>k,Image:()=>G,Link:()=>E,Page:()=>v,Router:()=>T,Sidebar:()=>S,Spinner:()=>B,Stack:()=>C,Table:()=>j,Tabs:()=>W,Video:()=>H});var n=x(d(),1);function o(){return(typeof window<"u"&&window.__FSAOS_CONFIG__||{}).edgeBaseUrl||""}function v(e){return(0,n.createElement)("div",{style:{minHeight:"100vh",display:"flex",flexDirection:"column"},className:e.className||""},e.children)}function C(e){let i=e.direction||"vertical";return(0,n.createElement)("div",{style:{display:"flex",flexDirection:i==="horizontal"?"row":"column",gap:e.gap||"0.5rem",padding:e.padding||"0",alignItems:e.align||"stretch",justifyContent:e.justify||"flex-start",flex:e.flex||"initial"},className:e.className||""},e.children)}function k(e){return(0,n.createElement)("div",{style:{display:"grid",gridTemplateColumns:"repeat("+(e.columns||3)+", 1fr)",gap:e.gap||"1rem",padding:e.padding||"0"},className:e.className||""},e.children)}function S(e){return(0,n.createElement)("div",{style:{display:"flex",flexDirection:"row",minHeight:"100vh"},className:e.className||""},e.children)}function w(e){return(0,n.createElement)("div",{style:{border:"1px solid var(--color-border, #e5e7eb)",borderRadius:"var(--border-radius, 0.5rem)",padding:e.padding||"1rem",background:"var(--color-surface, #fff)"},className:e.className||"",onClick:e.onClick},e.children)}function z(e){return(0,n.createElement)("span",{style:{display:"inline-flex",alignItems:"center",padding:"0.125rem 0.5rem",fontSize:"0.75rem",fontWeight:"500",borderRadius:"9999px",background:e.color||"#e5e7eb",color:e.textColor||"#374151"},className:e.className||""},e.children||e.label)}function B(e){let i=e.size||"1.5rem";return(0,n.createElement)("div",{style:{width:i,height:i,border:"2px solid #e5e7eb",borderTopColor:"var(--color-primary, #3b82f6)",borderRadius:"50%",animation:"fsaos-spin 0.6s linear infinite"}})}function D(e){return(0,n.createElement)("button",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:"500",borderRadius:"var(--border-radius, 0.375rem)",border:e.variant==="outline"?"1px solid var(--color-border, #d1d5db)":"none",background:e.variant==="outline"||e.variant==="ghost"?"transparent":"var(--color-primary, #3b82f6)",color:e.variant==="outline"||e.variant==="ghost"?"var(--color-text, #1a1a1a)":"#fff",cursor:e.disabled?"not-allowed":"pointer",opacity:e.disabled?"0.5":"1",gap:"0.5rem"},className:e.className||"",onClick:e.onClick,disabled:e.disabled},e.children||e.label)}function I(e){return(0,n.createElement)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"3rem",color:"var(--color-text-secondary, #6b7280)",textAlign:"center"}},e.icon?(0,n.createElement)("div",{style:{fontSize:"2rem",marginBottom:"0.5rem"}},e.icon):null,(0,n.createElement)("div",{style:{fontWeight:500,marginBottom:"0.25rem"}},e.title||e.message||e.children||"No items"),e.description?(0,n.createElement)("div",{style:{fontSize:"0.875rem",opacity:.7}},e.description):null)}function R(e){return(0,n.createElement)("div",{className:e.className||""},e.children)}function j(e){return(0,n.createElement)("table",{className:e.className||""},e.children)}function F(e){return(0,n.createElement)("form",{className:e.className||"",onSubmit:e.onSubmit},e.children)}function _(e){return(0,n.createElement)("div",{className:e.className||""},e.children)}function T(e){return(0,n.createElement)("div",null,e.children)}function E(e){return(0,n.createElement)("a",{href:e.href||e.to,className:e.className||"",onClick:e.onClick},e.children)}function W(e){return(0,n.createElement)("div",{className:e.className||""},e.children)}function A(e){return(0,n.createElement)("nav",{className:e.className||""},e.children)}function G(e){return(0,n.createElement)("img",{src:e.src||(e.path?o()+e.path:""),alt:e.alt||"",className:e.className||"",style:e.style})}function H(e){return(0,n.createElement)("video",{src:e.src||(e.path?o()+e.path:""),controls:!0,className:e.className||""})}function O(e){return(0,n.createElement)("div",{className:e.className||""},e.children||"File preview")}return b(P);})();
3
3
  //# sourceMappingURL=ui.js.map
package/dist/index.cjs CHANGED
@@ -2111,7 +2111,7 @@ async function fetchChannelMessages(channelPath, parentMessageId) {
2111
2111
  `[gateway] Failed to fetch channel messages for ${channelPath}:`,
2112
2112
  err
2113
2113
  );
2114
- return [];
2114
+ throw err;
2115
2115
  }
2116
2116
  }
2117
2117
  async function fetchChannelMessagesWithCards(channelPath, parentMessageId) {
@@ -2146,18 +2146,26 @@ async function fetchChannelMessagesWithCards(channelPath, parentMessageId) {
2146
2146
  `[gateway] Failed to fetch channel messages with cards for ${channelPath}:`,
2147
2147
  err
2148
2148
  );
2149
- return { messages: [], messageCards: /* @__PURE__ */ new Map(), siblingCards: [], mode: "top_level" };
2149
+ throw err;
2150
2150
  }
2151
2151
  }
2152
2152
  async function fetchChannelMessagesPage(channelPath, options) {
2153
2153
  try {
2154
2154
  const params = { channel_path: channelPath };
2155
2155
  if (options?.parentMessageId) params.parent_message_id = options.parentMessageId;
2156
+ if (options?.conversationsOnly) params.conversations_only = true;
2157
+ if (options?.transcriptOnly) params.transcript_only = true;
2156
2158
  if (options?.limit) params.limit = options.limit;
2157
2159
  if (options?.before_seq != null) params.before_seq = options.before_seq;
2158
2160
  if (options?.after_seq != null) params.after_seq = options.after_seq;
2159
2161
  const response = await gatewayCall("get-channel-messages", params);
2160
2162
  const raw = response;
2163
+ if (options?.conversationsOnly && raw.conversations_only !== true) {
2164
+ throw new Error("This server does not support conversation history lists yet. Update the message reader.");
2165
+ }
2166
+ if (options?.transcriptOnly && raw.transcript_only !== true) {
2167
+ throw new Error("This server does not support channel transcript pages yet. Update the message reader.");
2168
+ }
2161
2169
  const items = raw.messages || [];
2162
2170
  const cards = parseChannelCards(items);
2163
2171
  const messageCards = /* @__PURE__ */ new Map();
@@ -2183,7 +2191,7 @@ async function fetchChannelMessagesPage(channelPath, options) {
2183
2191
  `[gateway] Failed to fetch channel messages page for ${channelPath}:`,
2184
2192
  err
2185
2193
  );
2186
- return { messages: [], messageCards: /* @__PURE__ */ new Map(), siblingCards: [], mode: "top_level" };
2194
+ throw err;
2187
2195
  }
2188
2196
  }
2189
2197
  function invalidateChildren(path) {
@@ -3890,31 +3898,32 @@ function useChannelMessages(options) {
3890
3898
  }
3891
3899
  function useInfiniteChannelMessages(options) {
3892
3900
  useScopeKey();
3893
- const { channelPath, parentMessageId, limit = 50, realtime = true, enabled: enabled2 = true } = options;
3901
+ const { channelPath, parentMessageId, limit = 50, realtime = true, enabled: enabled2 = true, conversationsOnly = false, transcriptOnly = false } = options;
3894
3902
  const isThread = !!parentMessageId;
3895
3903
  const queryEnabled = enabled2 && !!channelPath;
3896
3904
  const query = reactQuery.useInfiniteQuery({
3897
- queryKey: [...vfsKeys.channelMessages(channelPath || "", parentMessageId), "infinite", limit],
3905
+ queryKey: [...vfsKeys.channelMessages(channelPath || "", parentMessageId), "infinite", limit, "latest-first", ...conversationsOnly ? ["conversations"] : [], ...transcriptOnly ? ["transcript"] : []],
3898
3906
  queryFn: async ({ pageParam }) => {
3899
3907
  return fetchChannelMessagesPage(channelPath, {
3900
3908
  parentMessageId,
3901
3909
  limit,
3902
- before_seq: isThread ? void 0 : pageParam,
3903
- after_seq: isThread ? pageParam : void 0
3910
+ conversationsOnly,
3911
+ transcriptOnly,
3912
+ before_seq: pageParam?.before_seq,
3913
+ after_seq: pageParam?.after_seq
3904
3914
  });
3905
3915
  },
3906
3916
  initialPageParam: void 0,
3907
- getNextPageParam: (lastPage) => {
3917
+ getPreviousPageParam: (lastPage) => {
3908
3918
  if (!isThread) return void 0;
3909
3919
  if (lastPage.messages.length < limit) return void 0;
3910
3920
  const maxSeq = lastPage.messages[lastPage.messages.length - 1]?.seq;
3911
- return maxSeq;
3921
+ return maxSeq == null ? void 0 : { after_seq: maxSeq };
3912
3922
  },
3913
- getPreviousPageParam: (firstPage) => {
3914
- if (isThread) return void 0;
3923
+ getNextPageParam: (firstPage) => {
3915
3924
  if (firstPage.messages.length < limit) return void 0;
3916
3925
  const minSeq = firstPage.messages[0]?.seq;
3917
- return minSeq;
3926
+ return minSeq == null ? void 0 : { before_seq: minSeq };
3918
3927
  },
3919
3928
  enabled: queryEnabled
3920
3929
  });
@@ -3958,8 +3967,8 @@ function useInfiniteChannelMessages(options) {
3958
3967
  const qc = reactQuery.useQueryClient();
3959
3968
  const debounceRef = React.useRef(null);
3960
3969
  const stableKey = React.useMemo(
3961
- () => [...vfsKeys.channelMessages(channelPath || "", parentMessageId), "infinite", limit],
3962
- [channelPath, parentMessageId, limit]
3970
+ () => [...vfsKeys.channelMessages(channelPath || "", parentMessageId), "infinite", limit, "latest-first", ...conversationsOnly ? ["conversations"] : [], ...transcriptOnly ? ["transcript"] : []],
3971
+ [channelPath, parentMessageId, limit, conversationsOnly, transcriptOnly]
3963
3972
  );
3964
3973
  React.useEffect(() => {
3965
3974
  if (!realtime || !channelPath || !queryEnabled) return;
@@ -3968,6 +3977,10 @@ function useInfiniteChannelMessages(options) {
3968
3977
  let tailAgain = false;
3969
3978
  let disposed = false;
3970
3979
  const tailOnce = async () => {
3980
+ if (conversationsOnly || transcriptOnly) {
3981
+ reload();
3982
+ return;
3983
+ }
3971
3984
  const currentData = qc.getQueryData(stableKey);
3972
3985
  if (!currentData?.pages?.length) {
3973
3986
  reload();
@@ -4006,7 +4019,7 @@ function useInfiniteChannelMessages(options) {
4006
4019
  qc.setQueryData(stableKey, (old) => {
4007
4020
  if (!old) return old;
4008
4021
  const pages = [...old.pages];
4009
- const lastIdx = pages.length - 1;
4022
+ const lastIdx = 0;
4010
4023
  const lastPage = pages[lastIdx];
4011
4024
  const existingIds = new Set(lastPage.messages.map((m) => m.id));
4012
4025
  const uniqueNew = newPage.messages.filter((m) => !existingIds.has(m.id));
@@ -4058,7 +4071,7 @@ function useInfiniteChannelMessages(options) {
4058
4071
  void tail();
4059
4072
  }, 500);
4060
4073
  },
4061
- (data) => channelMessageChange(
4074
+ (data) => (conversationsOnly || transcriptOnly) && data?.item_type === "message" && (qc.getQueryData(stableKey)?.pages ?? []).some((page) => page.messages.some((root) => root.id === data.parent_id)) || channelMessageChange(
4062
4075
  data,
4063
4076
  channelPath,
4064
4077
  parentMessageId,
@@ -4070,11 +4083,11 @@ function useInfiniteChannelMessages(options) {
4070
4083
  unsub();
4071
4084
  if (debounceRef.current) clearTimeout(debounceRef.current);
4072
4085
  };
4073
- }, [realtime, channelPath, queryEnabled, stableKey, qc, parentMessageId, limit]);
4086
+ }, [realtime, channelPath, queryEnabled, stableKey, qc, parentMessageId, limit, conversationsOnly, transcriptOnly]);
4074
4087
  return {
4075
4088
  messages,
4076
- // Activity is a current thread snapshot, not another reply page.
4077
- activityMessages: query.data?.pages.at(-1)?.activityMessages ?? [],
4089
+ // Activity is a current snapshot, independent of transcript/reply pages.
4090
+ activityMessages: query.data?.pages[0]?.activityMessages ?? [],
4078
4091
  /** Cards grouped by parent message path (child cards of messages). */
4079
4092
  messageCards,
4080
4093
  /** Cards that are direct siblings of the channel (not nested under a message). */
@@ -4086,14 +4099,14 @@ function useInfiniteChannelMessages(options) {
4086
4099
  isFetching: query.isFetching,
4087
4100
  error: query.error,
4088
4101
  refetch: query.refetch,
4089
- // Backward pagination (top-level: load older)
4090
- hasPreviousPage: query.hasPreviousPage ?? false,
4091
- fetchPreviousPage: query.fetchPreviousPage,
4092
- isFetchingPreviousPage: query.isFetchingPreviousPage ?? false,
4102
+ // Backward pagination (channels and threads: load older)
4103
+ hasPreviousPage: query.hasNextPage ?? false,
4104
+ fetchPreviousPage: query.fetchNextPage,
4105
+ isFetchingPreviousPage: query.isFetchingNextPage ?? false,
4093
4106
  // Forward pagination (thread: load newer)
4094
- hasNextPage: query.hasNextPage ?? false,
4095
- fetchNextPage: query.fetchNextPage,
4096
- isFetchingNextPage: query.isFetchingNextPage ?? false
4107
+ hasNextPage: query.hasPreviousPage ?? false,
4108
+ fetchNextPage: query.fetchPreviousPage,
4109
+ isFetchingNextPage: query.isFetchingPreviousPage ?? false
4097
4110
  };
4098
4111
  }
4099
4112
  var CHANNEL_AI_MODES = ["open", "active", "strict", "hand_raise"];