@ai4b-team/fsaos-gateway-sdk 4.2.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/iife/gateway.js +6 -6
- package/dist/iife/gateway.js.map +3 -3
- package/dist/iife/ui.js +1 -1
- package/dist/index.cjs +22 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +22 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1326,6 +1326,8 @@ declare function fetchChannelMessagesPage(channelPath: string, options?: {
|
|
|
1326
1326
|
parentMessageId?: string;
|
|
1327
1327
|
/** List conversation roots before pagination, using the chat audience rules. */
|
|
1328
1328
|
conversationsOnly?: boolean;
|
|
1329
|
+
/** Page human channel messages; receive system activity separately. */
|
|
1330
|
+
transcriptOnly?: boolean;
|
|
1329
1331
|
limit?: number;
|
|
1330
1332
|
before_seq?: number;
|
|
1331
1333
|
after_seq?: number;
|
|
@@ -2320,6 +2322,8 @@ interface InfiniteChannelMessagesOptions {
|
|
|
2320
2322
|
parentMessageId?: string;
|
|
2321
2323
|
/** Return conversation roots, excluding activity before the page limit. */
|
|
2322
2324
|
conversationsOnly?: boolean;
|
|
2325
|
+
/** Page top-level human messages with a separate, bounded activity snapshot. */
|
|
2326
|
+
transcriptOnly?: boolean;
|
|
2323
2327
|
/** Messages per page. Default 50, max 200. */
|
|
2324
2328
|
limit?: number;
|
|
2325
2329
|
/** Enable SSE-driven auto-refresh. Default: true. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1326,6 +1326,8 @@ declare function fetchChannelMessagesPage(channelPath: string, options?: {
|
|
|
1326
1326
|
parentMessageId?: string;
|
|
1327
1327
|
/** List conversation roots before pagination, using the chat audience rules. */
|
|
1328
1328
|
conversationsOnly?: boolean;
|
|
1329
|
+
/** Page human channel messages; receive system activity separately. */
|
|
1330
|
+
transcriptOnly?: boolean;
|
|
1329
1331
|
limit?: number;
|
|
1330
1332
|
before_seq?: number;
|
|
1331
1333
|
after_seq?: number;
|
|
@@ -2320,6 +2322,8 @@ interface InfiniteChannelMessagesOptions {
|
|
|
2320
2322
|
parentMessageId?: string;
|
|
2321
2323
|
/** Return conversation roots, excluding activity before the page limit. */
|
|
2322
2324
|
conversationsOnly?: boolean;
|
|
2325
|
+
/** Page top-level human messages with a separate, bounded activity snapshot. */
|
|
2326
|
+
transcriptOnly?: boolean;
|
|
2323
2327
|
/** Messages per page. Default 50, max 200. */
|
|
2324
2328
|
limit?: number;
|
|
2325
2329
|
/** Enable SSE-driven auto-refresh. Default: true. */
|
package/dist/index.js
CHANGED
|
@@ -1339,6 +1339,9 @@ function resubscribeAll(isReconnect = false) {
|
|
|
1339
1339
|
sendPathSubscribe(sub.path, sub.event_types);
|
|
1340
1340
|
}
|
|
1341
1341
|
if (!isReconnect) return;
|
|
1342
|
+
catchUpAfterGap("reconnect");
|
|
1343
|
+
}
|
|
1344
|
+
function catchUpAfterGap(reason) {
|
|
1342
1345
|
try {
|
|
1343
1346
|
const qc = getQueryClient();
|
|
1344
1347
|
refreshInfiniteItemsAfterReconnect(qc);
|
|
@@ -1347,9 +1350,9 @@ function resubscribeAll(isReconnect = false) {
|
|
|
1347
1350
|
void qc.invalidateQueries({ queryKey: vfsKeys.item(sub.path) });
|
|
1348
1351
|
void qc.invalidateQueries({ queryKey: vfsKeys.children(sub.path) });
|
|
1349
1352
|
}
|
|
1350
|
-
log("
|
|
1353
|
+
log("catchUpAfterGap:", reason, "- invalidated", activePaths.size, "paths");
|
|
1351
1354
|
} catch (err) {
|
|
1352
|
-
log("
|
|
1355
|
+
log("catchUpAfterGap: cache invalidation skipped", err);
|
|
1353
1356
|
}
|
|
1354
1357
|
}
|
|
1355
1358
|
function sendMessage(msg) {
|
|
@@ -1372,6 +1375,10 @@ function handleMessage(raw) {
|
|
|
1372
1375
|
console.warn("[WS] Server error:", msg.message);
|
|
1373
1376
|
return;
|
|
1374
1377
|
}
|
|
1378
|
+
if (msg.type === "resync") {
|
|
1379
|
+
catchUpAfterGap(typeof msg.reason === "string" ? msg.reason : "resync");
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1375
1382
|
if (msg.type === "event" || msg.event_type) {
|
|
1376
1383
|
const eventType = msg.event_type || "message";
|
|
1377
1384
|
const data = msg.data || msg;
|
|
@@ -2129,6 +2136,7 @@ async function fetchChannelMessagesPage(channelPath, options) {
|
|
|
2129
2136
|
const params = { channel_path: channelPath };
|
|
2130
2137
|
if (options?.parentMessageId) params.parent_message_id = options.parentMessageId;
|
|
2131
2138
|
if (options?.conversationsOnly) params.conversations_only = true;
|
|
2139
|
+
if (options?.transcriptOnly) params.transcript_only = true;
|
|
2132
2140
|
if (options?.limit) params.limit = options.limit;
|
|
2133
2141
|
if (options?.before_seq != null) params.before_seq = options.before_seq;
|
|
2134
2142
|
if (options?.after_seq != null) params.after_seq = options.after_seq;
|
|
@@ -2137,6 +2145,9 @@ async function fetchChannelMessagesPage(channelPath, options) {
|
|
|
2137
2145
|
if (options?.conversationsOnly && raw.conversations_only !== true) {
|
|
2138
2146
|
throw new Error("This server does not support conversation history lists yet. Update the message reader.");
|
|
2139
2147
|
}
|
|
2148
|
+
if (options?.transcriptOnly && raw.transcript_only !== true) {
|
|
2149
|
+
throw new Error("This server does not support channel transcript pages yet. Update the message reader.");
|
|
2150
|
+
}
|
|
2140
2151
|
const items = raw.messages || [];
|
|
2141
2152
|
const cards = parseChannelCards(items);
|
|
2142
2153
|
const messageCards = /* @__PURE__ */ new Map();
|
|
@@ -3869,16 +3880,17 @@ function useChannelMessages(options) {
|
|
|
3869
3880
|
}
|
|
3870
3881
|
function useInfiniteChannelMessages(options) {
|
|
3871
3882
|
useScopeKey();
|
|
3872
|
-
const { channelPath, parentMessageId, limit = 50, realtime = true, enabled: enabled2 = true, conversationsOnly = false } = options;
|
|
3883
|
+
const { channelPath, parentMessageId, limit = 50, realtime = true, enabled: enabled2 = true, conversationsOnly = false, transcriptOnly = false } = options;
|
|
3873
3884
|
const isThread = !!parentMessageId;
|
|
3874
3885
|
const queryEnabled = enabled2 && !!channelPath;
|
|
3875
3886
|
const query = useInfiniteQuery({
|
|
3876
|
-
queryKey: [...vfsKeys.channelMessages(channelPath || "", parentMessageId), "infinite", limit, "latest-first", ...conversationsOnly ? ["conversations"] : []],
|
|
3887
|
+
queryKey: [...vfsKeys.channelMessages(channelPath || "", parentMessageId), "infinite", limit, "latest-first", ...conversationsOnly ? ["conversations"] : [], ...transcriptOnly ? ["transcript"] : []],
|
|
3877
3888
|
queryFn: async ({ pageParam }) => {
|
|
3878
3889
|
return fetchChannelMessagesPage(channelPath, {
|
|
3879
3890
|
parentMessageId,
|
|
3880
3891
|
limit,
|
|
3881
3892
|
conversationsOnly,
|
|
3893
|
+
transcriptOnly,
|
|
3882
3894
|
before_seq: pageParam?.before_seq,
|
|
3883
3895
|
after_seq: pageParam?.after_seq
|
|
3884
3896
|
});
|
|
@@ -3937,8 +3949,8 @@ function useInfiniteChannelMessages(options) {
|
|
|
3937
3949
|
const qc = useQueryClient();
|
|
3938
3950
|
const debounceRef = useRef(null);
|
|
3939
3951
|
const stableKey = useMemo(
|
|
3940
|
-
() => [...vfsKeys.channelMessages(channelPath || "", parentMessageId), "infinite", limit, "latest-first", ...conversationsOnly ? ["conversations"] : []],
|
|
3941
|
-
[channelPath, parentMessageId, limit, conversationsOnly]
|
|
3952
|
+
() => [...vfsKeys.channelMessages(channelPath || "", parentMessageId), "infinite", limit, "latest-first", ...conversationsOnly ? ["conversations"] : [], ...transcriptOnly ? ["transcript"] : []],
|
|
3953
|
+
[channelPath, parentMessageId, limit, conversationsOnly, transcriptOnly]
|
|
3942
3954
|
);
|
|
3943
3955
|
useEffect(() => {
|
|
3944
3956
|
if (!realtime || !channelPath || !queryEnabled) return;
|
|
@@ -3947,7 +3959,7 @@ function useInfiniteChannelMessages(options) {
|
|
|
3947
3959
|
let tailAgain = false;
|
|
3948
3960
|
let disposed = false;
|
|
3949
3961
|
const tailOnce = async () => {
|
|
3950
|
-
if (conversationsOnly) {
|
|
3962
|
+
if (conversationsOnly || transcriptOnly) {
|
|
3951
3963
|
reload();
|
|
3952
3964
|
return;
|
|
3953
3965
|
}
|
|
@@ -4041,7 +4053,7 @@ function useInfiniteChannelMessages(options) {
|
|
|
4041
4053
|
void tail();
|
|
4042
4054
|
}, 500);
|
|
4043
4055
|
},
|
|
4044
|
-
(data) => conversationsOnly && data?.item_type === "message" && (qc.getQueryData(stableKey)?.pages ?? []).some((page) => page.messages.some((root) => root.id === data.parent_id)) || channelMessageChange(
|
|
4056
|
+
(data) => (conversationsOnly || transcriptOnly) && data?.item_type === "message" && (qc.getQueryData(stableKey)?.pages ?? []).some((page) => page.messages.some((root) => root.id === data.parent_id)) || channelMessageChange(
|
|
4045
4057
|
data,
|
|
4046
4058
|
channelPath,
|
|
4047
4059
|
parentMessageId,
|
|
@@ -4053,10 +4065,10 @@ function useInfiniteChannelMessages(options) {
|
|
|
4053
4065
|
unsub();
|
|
4054
4066
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
4055
4067
|
};
|
|
4056
|
-
}, [realtime, channelPath, queryEnabled, stableKey, qc, parentMessageId, limit, conversationsOnly]);
|
|
4068
|
+
}, [realtime, channelPath, queryEnabled, stableKey, qc, parentMessageId, limit, conversationsOnly, transcriptOnly]);
|
|
4057
4069
|
return {
|
|
4058
4070
|
messages,
|
|
4059
|
-
// Activity is a current
|
|
4071
|
+
// Activity is a current snapshot, independent of transcript/reply pages.
|
|
4060
4072
|
activityMessages: query.data?.pages[0]?.activityMessages ?? [],
|
|
4061
4073
|
/** Cards grouped by parent message path (child cards of messages). */
|
|
4062
4074
|
messageCards,
|