@truefoundry/assistant-ui-runtime 0.1.15 → 0.1.16
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.ts +0 -1
- package/dist/index.js +10 -56
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/convertTurnMessages.test.ts +211 -43
- package/src/convertTurnMessages.ts +17 -72
- package/src/types.ts +0 -1
- package/src/useTrueFoundryAgentMessages.test.tsx +30 -26
- package/src/useTrueFoundryAgentMessages.ts +6 -13
- package/src/useTrueFoundryAgentRuntime.ts +0 -2
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,6 @@ type TrueFoundryAgentRuntimeBaseOptions = ExternalStoreSharedOptions & {
|
|
|
25
25
|
threadId?: string | undefined;
|
|
26
26
|
onThreadIdChange?: ((threadId: string | undefined) => void) | undefined;
|
|
27
27
|
onError?: ((error: unknown) => void) | undefined;
|
|
28
|
-
listEventsConcurrency?: number | undefined;
|
|
29
28
|
/**
|
|
30
29
|
* Optional filter forwarded to `listSessions({ agentId })`.
|
|
31
30
|
* Omit for all chats; hosts that key agents by name pass that name as the id.
|
package/dist/index.js
CHANGED
|
@@ -2140,56 +2140,20 @@ async function buildSnapshotFromSession(server, sessionId, concurrency = DEFAULT
|
|
|
2140
2140
|
pendingUser: void 0
|
|
2141
2141
|
});
|
|
2142
2142
|
}
|
|
2143
|
-
async function
|
|
2144
|
-
|
|
2145
|
-
const beforeIndex = turns.findIndex((turn) => turn.id === beforeTurnId);
|
|
2146
|
-
if (beforeIndex === -1) {
|
|
2147
|
-
throw new Error(`Turn ${beforeTurnId} not found in session`);
|
|
2148
|
-
}
|
|
2149
|
-
return buildSnapshotBeforeTurnIndex(
|
|
2150
|
-
server,
|
|
2151
|
-
sessionId,
|
|
2152
|
-
beforeIndex,
|
|
2153
|
-
concurrency,
|
|
2154
|
-
turns
|
|
2155
|
-
);
|
|
2156
|
-
}
|
|
2157
|
-
async function buildSnapshotBeforeTurnIndex(server, sessionId, turnIndex, _concurrency = DEFAULT_LIST_EVENTS_CONCURRENCY, orderedTurns) {
|
|
2158
|
-
if (turnIndex <= 0) {
|
|
2143
|
+
async function buildSnapshotThroughTurn(server, sessionId, anchorTurnId) {
|
|
2144
|
+
if (anchorTurnId == null) {
|
|
2159
2145
|
return createEmptySessionSnapshot();
|
|
2160
2146
|
}
|
|
2161
|
-
const
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
if (lastTurnId == null) {
|
|
2165
|
-
return createEmptySessionSnapshot();
|
|
2166
|
-
}
|
|
2167
|
-
const items = await fetchAllSessionEvents(server, sessionId, { lastTurnId });
|
|
2147
|
+
const items = await fetchAllSessionEvents(server, sessionId, {
|
|
2148
|
+
lastTurnId: anchorTurnId
|
|
2149
|
+
});
|
|
2168
2150
|
const snapshot = createEmptySessionSnapshot();
|
|
2169
2151
|
ingestSessionEventsIntoSnapshot(snapshot, items);
|
|
2170
2152
|
return snapshot;
|
|
2171
2153
|
}
|
|
2172
|
-
async function resolveGatewayBranchPreviousTurnId(server, sessionId, turnIndex, orderedTurns) {
|
|
2173
|
-
if (turnIndex <= 0) {
|
|
2174
|
-
return "none";
|
|
2175
|
-
}
|
|
2176
|
-
const turns = orderedTurns ?? await listSessionTurnsOrdered(server, sessionId);
|
|
2177
|
-
return turns[turnIndex - 1]?.id ?? "none";
|
|
2178
|
-
}
|
|
2179
2154
|
async function resolveGatewayBranchPreviousTurnIdForTurn(server, sessionId, turnId) {
|
|
2180
|
-
const
|
|
2181
|
-
|
|
2182
|
-
return resolveGatewayBranchPreviousTurnId(server, sessionId, turnIndex, turns);
|
|
2183
|
-
}
|
|
2184
|
-
async function listSessionTurnsOrdered(server, sessionId) {
|
|
2185
|
-
const turns = await drainListPages(
|
|
2186
|
-
(pageToken) => server.listTurns({
|
|
2187
|
-
sessionId,
|
|
2188
|
-
...pageToken != null ? { pageToken } : {}
|
|
2189
|
-
})
|
|
2190
|
-
);
|
|
2191
|
-
turns.reverse();
|
|
2192
|
-
return turns;
|
|
2155
|
+
const turn = await server.getTurn({ sessionId, turnId });
|
|
2156
|
+
return turn.previousTurnId ?? "none";
|
|
2193
2157
|
}
|
|
2194
2158
|
async function buildTurnAssistantContent(server, sessionId, turn, foldState) {
|
|
2195
2159
|
const state = foldState ?? new PeerThreadFoldState();
|
|
@@ -3185,7 +3149,6 @@ function useTrueFoundryAgentMessages({
|
|
|
3185
3149
|
sessionId,
|
|
3186
3150
|
isMain,
|
|
3187
3151
|
isInitialSession,
|
|
3188
|
-
listEventsConcurrency,
|
|
3189
3152
|
onError,
|
|
3190
3153
|
initializeSession,
|
|
3191
3154
|
resolveConversationSessionId,
|
|
@@ -3716,11 +3679,10 @@ function useTrueFoundryAgentMessages({
|
|
|
3716
3679
|
conversationSessionId,
|
|
3717
3680
|
turnId
|
|
3718
3681
|
);
|
|
3719
|
-
rewound = await
|
|
3682
|
+
rewound = await buildSnapshotThroughTurn(
|
|
3720
3683
|
server,
|
|
3721
3684
|
conversationSessionId,
|
|
3722
|
-
|
|
3723
|
-
listEventsConcurrency
|
|
3685
|
+
previousTurnId === "none" ? null : previousTurnId
|
|
3724
3686
|
);
|
|
3725
3687
|
createdAtByMessageIdRef.current = /* @__PURE__ */ new Map();
|
|
3726
3688
|
snapshotRef.current = rewound;
|
|
@@ -3736,13 +3698,7 @@ function useTrueFoundryAgentMessages({
|
|
|
3736
3698
|
branchRollbackSnapshot: committed
|
|
3737
3699
|
});
|
|
3738
3700
|
},
|
|
3739
|
-
[
|
|
3740
|
-
cancel,
|
|
3741
|
-
server,
|
|
3742
|
-
listEventsConcurrency,
|
|
3743
|
-
sendTurn,
|
|
3744
|
-
sessionId
|
|
3745
|
-
]
|
|
3701
|
+
[cancel, server, sendTurn, sessionId]
|
|
3746
3702
|
);
|
|
3747
3703
|
const resetFromTurn = useCallback2(
|
|
3748
3704
|
async (turnId) => {
|
|
@@ -3852,7 +3808,6 @@ function useTrueFoundryAgentRuntimeImpl(options, pendingAgentSpecRef) {
|
|
|
3852
3808
|
agent,
|
|
3853
3809
|
adapters,
|
|
3854
3810
|
onError,
|
|
3855
|
-
listEventsConcurrency,
|
|
3856
3811
|
...sharedOptions
|
|
3857
3812
|
} = options;
|
|
3858
3813
|
const draftBridgeRef = useRef3(
|
|
@@ -3913,7 +3868,6 @@ function useTrueFoundryAgentRuntimeImpl(options, pendingAgentSpecRef) {
|
|
|
3913
3868
|
sessionId,
|
|
3914
3869
|
isMain,
|
|
3915
3870
|
isInitialSession,
|
|
3916
|
-
listEventsConcurrency,
|
|
3917
3871
|
onError,
|
|
3918
3872
|
initializeSession,
|
|
3919
3873
|
getTurnHeaders: agent.mode === "draft" ? getTurnHeaders : void 0
|