@truefoundry/assistant-ui-runtime 0.1.3-rc.2 → 0.1.4
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.js +15 -14
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/convertTurnMessages.test.ts +10 -10
- package/src/draftAgentConfig.test.ts +7 -7
- package/src/foldPeerThreads.test.ts +1 -1
- package/src/modelMessageImageContent.ts +3 -1
- package/src/private/truefoundryDraftThreadListAdapter.test.ts +1 -1
- package/src/streamTurn.test.ts +91 -3
- package/src/streamTurn.ts +29 -16
- package/src/useTrueFoundryAgentMessages.ts +10 -1
- package/src/useTrueFoundryAgentRuntime.ts +1 -4
package/dist/index.js
CHANGED
|
@@ -2809,7 +2809,6 @@ function findPausedAssistantMessage(messages) {
|
|
|
2809
2809
|
}
|
|
2810
2810
|
|
|
2811
2811
|
// src/streamTurn.ts
|
|
2812
|
-
import "truefoundry-gateway-sdk/agents";
|
|
2813
2812
|
function buildTurnInput(options) {
|
|
2814
2813
|
if (options.inputs != null) {
|
|
2815
2814
|
return options.inputs;
|
|
@@ -2831,17 +2830,23 @@ function bindAbort(session, abortSignal) {
|
|
|
2831
2830
|
return onAbort;
|
|
2832
2831
|
}
|
|
2833
2832
|
async function* streamTurnContent(session, foldState, options, abortSignal, groupRootBaseline, onTurnIdAvailable) {
|
|
2834
|
-
const previousTurnId = options.previousTurnId === null ?
|
|
2833
|
+
const previousTurnId = options.previousTurnId === null ? null : options.previousTurnId ?? "auto";
|
|
2835
2834
|
const turn = session.prepareTurn({
|
|
2836
2835
|
input: buildTurnInput(options),
|
|
2837
|
-
...previousTurnId
|
|
2836
|
+
...previousTurnId !== void 0 ? { previousTurnId } : {}
|
|
2838
2837
|
});
|
|
2839
2838
|
const onAbort = bindAbort(session, abortSignal);
|
|
2840
2839
|
if (abortSignal.aborted) {
|
|
2841
2840
|
return;
|
|
2842
2841
|
}
|
|
2842
|
+
let turnIdNotified = false;
|
|
2843
|
+
const notifyTurnIdIfAvailable = () => {
|
|
2844
|
+
if (!turnIdNotified && turn.id != null) {
|
|
2845
|
+
onTurnIdAvailable?.(turn.id);
|
|
2846
|
+
turnIdNotified = true;
|
|
2847
|
+
}
|
|
2848
|
+
};
|
|
2843
2849
|
try {
|
|
2844
|
-
let turnIdNotified = false;
|
|
2845
2850
|
for await (const update of streamTurnEvents(
|
|
2846
2851
|
turn.execute(
|
|
2847
2852
|
{ stream: true },
|
|
@@ -2853,16 +2858,12 @@ async function* streamTurnContent(session, foldState, options, abortSignal, grou
|
|
|
2853
2858
|
foldState,
|
|
2854
2859
|
groupRootBaseline
|
|
2855
2860
|
)) {
|
|
2856
|
-
|
|
2857
|
-
onTurnIdAvailable?.(turn.id);
|
|
2858
|
-
turnIdNotified = true;
|
|
2859
|
-
}
|
|
2861
|
+
notifyTurnIdIfAvailable();
|
|
2860
2862
|
yield update;
|
|
2861
2863
|
}
|
|
2862
|
-
|
|
2863
|
-
onTurnIdAvailable?.(turn.id);
|
|
2864
|
-
}
|
|
2864
|
+
notifyTurnIdIfAvailable();
|
|
2865
2865
|
} catch (error) {
|
|
2866
|
+
notifyTurnIdIfAvailable();
|
|
2866
2867
|
if (error instanceof Error && error.name === "AbortError") {
|
|
2867
2868
|
return;
|
|
2868
2869
|
}
|
|
@@ -3260,6 +3261,7 @@ function useTrueFoundryAgentMessages({
|
|
|
3260
3261
|
const isContinuation = "inputs" in options || "resumeMcpAuth" in options && options.resumeMcpAuth === true;
|
|
3261
3262
|
const continuationTurnId = snapshotRef.current.activeStream?.turnId;
|
|
3262
3263
|
const turnId = isContinuation && continuationTurnId != null ? continuationTurnId : generateId();
|
|
3264
|
+
const isFirstTurnInSession = "userMessage" in options && options.previousTurnId === void 0 && snapshotRef.current.turns.length === 0 && snapshotRef.current.pendingUser == null && snapshotRef.current.activeStream == null;
|
|
3263
3265
|
const turnIdRef = { current: turnId };
|
|
3264
3266
|
if ("inputs" in options) {
|
|
3265
3267
|
applyUserToolResponsesToFold(
|
|
@@ -3335,7 +3337,7 @@ function useTrueFoundryAgentMessages({
|
|
|
3335
3337
|
snapshotRef.current.fold,
|
|
3336
3338
|
{
|
|
3337
3339
|
userMessage: options.userMessage,
|
|
3338
|
-
...options.previousTurnId !== void 0 ? { previousTurnId: options.previousTurnId } : {},
|
|
3340
|
+
...options.previousTurnId !== void 0 ? { previousTurnId: options.previousTurnId } : isFirstTurnInSession ? { previousTurnId: null } : {},
|
|
3339
3341
|
...streamHeaders
|
|
3340
3342
|
},
|
|
3341
3343
|
signal,
|
|
@@ -3691,8 +3693,7 @@ function useTrueFoundryAgentRuntimeImpl(options, pendingAgentSpecRef) {
|
|
|
3691
3693
|
onError?.(error);
|
|
3692
3694
|
throw error;
|
|
3693
3695
|
}
|
|
3694
|
-
const
|
|
3695
|
-
const response = await gateway.agents.downloadSandboxFile(sandboxId, { path });
|
|
3696
|
+
const response = await privateClient.downloadSandboxFile(sandboxId, { path });
|
|
3696
3697
|
return await response.blob();
|
|
3697
3698
|
},
|
|
3698
3699
|
[privateClient, sandboxId, onError]
|