@trigger.dev/sdk 0.0.0-prerelease-20260909121655 → 0.0.0-prerelease-20260911153544
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/commonjs/v3/ai.d.ts +36 -0
- package/dist/commonjs/v3/ai.js +260 -55
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/auth.d.ts +10 -4
- package/dist/commonjs/v3/auth.js.map +1 -1
- package/dist/commonjs/v3/chatSnapshotIo.js +6 -7
- package/dist/commonjs/v3/chatSnapshotIo.js.map +1 -1
- package/dist/commonjs/v3/retry.d.ts +4 -0
- package/dist/commonjs/v3/retry.js +22 -13
- package/dist/commonjs/v3/retry.js.map +1 -1
- package/dist/commonjs/v3/test/transcript-storage-tests.js.map +1 -1
- package/dist/commonjs/v3/transcriptStorage.d.ts +43 -6
- package/dist/commonjs/v3/transcriptStorage.js +87 -8
- package/dist/commonjs/v3/transcriptStorage.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/ai.d.ts +36 -0
- package/dist/esm/v3/ai.js +260 -55
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/auth.d.ts +10 -4
- package/dist/esm/v3/auth.js.map +1 -1
- package/dist/esm/v3/chatSnapshotIo.js +7 -8
- package/dist/esm/v3/chatSnapshotIo.js.map +1 -1
- package/dist/esm/v3/retry.d.ts +4 -0
- package/dist/esm/v3/retry.js +14 -8
- package/dist/esm/v3/retry.js.map +1 -1
- package/dist/esm/v3/test/transcript-storage-tests.js.map +1 -1
- package/dist/esm/v3/transcriptStorage.d.ts +43 -6
- package/dist/esm/v3/transcriptStorage.js +85 -8
- package/dist/esm/v3/transcriptStorage.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai-chat/background-injection.mdx +54 -1
- package/docs/ai-chat/how-it-works.mdx +1 -1
- package/docs/ai-chat/migrating-from-hydrate-messages.mdx +299 -0
- package/docs/ai-chat/patterns/database-persistence.mdx +18 -7
- package/docs/ai-chat/reference.mdx +2 -1
- package/docs/ai-chat/side-channels.mdx +1 -1
- package/docs/ai-chat/transcript-storage.mdx +21 -7
- package/docs/self-hosting/security.mdx +12 -0
- package/package.json +2 -2
- package/skills/trigger-chat-agent-advanced/SKILL.md +31 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transcriptStorage.js","sourceRoot":"","sources":["../../../src/v3/transcriptStorage.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6CAK8B;AAE9B,2DAA0E;AAgI1E;IAGE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACtC,CAAC;AAED;;;;GAIG;AACH,iCACE,IAAiC,EACjC,OAAoC;IAEpC,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACnC,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IACvB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,QAAQ,MAAM,CAAC,EAAE,EAAE,CAAC;YAClB,KAAK,KAAK,EAAE,CAAC;gBACX,MAAM,OAAO,GAAG,MAAM,CAAC,OAAqB,CAAC;gBAC7C,MAAM,KAAK,GAAG,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,IAAI,EAAE,OAAO,EAAE,CAAC;gBACvE,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,CAAC,CAAC;gBAC1D,IAAI,GAAG,KAAK,CAAC,CAAC;oBAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;;oBAC/B,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBAC1B,MAAM;YACR,CAAC;YACD,KAAK,QAAQ,EAAE,CA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nB,KAAK,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC;QACpC,IAAI,GAAG,GAAG,CAAC,GAAG,MAAM,EAAE,CAAC;YACrB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/D,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC7B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;AACnF,CAAC"}
|
package/dist/commonjs/version.js
CHANGED
package/dist/esm/v3/ai.d.ts
CHANGED
|
@@ -149,6 +149,41 @@ export declare const ai: {
|
|
|
149
149
|
* ```
|
|
150
150
|
*/
|
|
151
151
|
declare function createChatAccessToken<TTask extends AnyTask>(taskId: TaskIdentifier<TTask>): Promise<string>;
|
|
152
|
+
/**
|
|
153
|
+
* Register work that must land before anything from this turn reaches the
|
|
154
|
+
* frontend.
|
|
155
|
+
*
|
|
156
|
+
* Like {@link chatDefer} the work starts immediately and is never awaited by
|
|
157
|
+
* the hook that registered it, so it runs alongside the model and costs no
|
|
158
|
+
* time to first token. Unlike `chat.defer`, the output stream waits for it:
|
|
159
|
+
* no chunk of the answer is written to the session until it settles. That
|
|
160
|
+
* makes it the right home for a write the next page load has to see (a
|
|
161
|
+
* conversation row, a message insert), because a reader that can see the
|
|
162
|
+
* answer can also see what the write persisted.
|
|
163
|
+
*
|
|
164
|
+
* Reach for `chat.defer` instead when the timing does not matter for a
|
|
165
|
+
* reload: analytics, audit logs, search-index updates.
|
|
166
|
+
*
|
|
167
|
+
* This is not a consistency barrier for the turn. The work is still in flight
|
|
168
|
+
* while the model runs, so a tool, a `prepareStep`, or anything else executing
|
|
169
|
+
* during the turn can still read the state as it was before the write. It
|
|
170
|
+
* orders the write against what the frontend can see, nothing more. When the
|
|
171
|
+
* turn's own code has to read the write back, `await` it instead and accept
|
|
172
|
+
* the cost.
|
|
173
|
+
*
|
|
174
|
+
* A write registered here that fails, or outlasts the internal timeout, lets
|
|
175
|
+
* the stream through rather than stalling the conversation.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* onTurnStart: async ({ chatId, uiMessages }) => {
|
|
180
|
+
* chat.deferBeforeOutput(
|
|
181
|
+
* db.chat.update({ where: { id: chatId }, data: { messages: uiMessages } })
|
|
182
|
+
* );
|
|
183
|
+
* },
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
declare function chatDeferBeforeOutput(promiseOrFn: Promise<unknown> | (() => Promise<unknown>)): void;
|
|
152
187
|
/**
|
|
153
188
|
* A stream writer passed to chat lifecycle callbacks (`onPreload`, `onChatStart`,
|
|
154
189
|
* `onTurnStart`, `onTurnComplete`, `onCompacted`).
|
|
@@ -3382,6 +3417,7 @@ export declare const chat: {
|
|
|
3382
3417
|
cleanupAbortedParts: typeof cleanupAbortedParts;
|
|
3383
3418
|
/** Register background work that runs in parallel with streaming. See {@link chatDefer}. */
|
|
3384
3419
|
defer: typeof chatDefer;
|
|
3420
|
+
deferBeforeOutput: typeof chatDeferBeforeOutput;
|
|
3385
3421
|
/** Queue model messages for injection at the next `prepareStep` boundary. See {@link injectBackgroundContext}. */
|
|
3386
3422
|
inject: typeof injectBackgroundContext;
|
|
3387
3423
|
/** Typed chat output stream for writing custom chunks or piping from subtasks. */
|
package/dist/esm/v3/ai.js
CHANGED
|
@@ -660,31 +660,143 @@ export const ai = {
|
|
|
660
660
|
function createChatAccessToken(taskId) {
|
|
661
661
|
return auth.createTriggerPublicToken(taskId, { expirationTime: "24h" });
|
|
662
662
|
}
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
663
|
+
function createChatOutGate() {
|
|
664
|
+
let resolveOpened;
|
|
665
|
+
const opened = new Promise((resolve) => {
|
|
666
|
+
resolveOpened = resolve;
|
|
667
|
+
});
|
|
668
|
+
const gate = {
|
|
669
|
+
pending: new Set(),
|
|
670
|
+
open: false,
|
|
671
|
+
opened,
|
|
672
|
+
failOpen() {
|
|
673
|
+
if (gate.open)
|
|
674
|
+
return;
|
|
675
|
+
gate.open = true;
|
|
676
|
+
resolveOpened();
|
|
677
|
+
},
|
|
678
|
+
};
|
|
679
|
+
return gate;
|
|
680
|
+
}
|
|
681
|
+
const chatOutGateKey = locals.create("chat.outGate");
|
|
682
|
+
/**
|
|
683
|
+
* How long a write waits on the gate before giving up. A storage that hangs
|
|
684
|
+
* degrades to an ungated write rather than stalling the conversation.
|
|
685
|
+
* @internal
|
|
686
|
+
*/
|
|
687
|
+
const CHAT_OUT_GATE_TIMEOUT_MS = 10_000;
|
|
688
|
+
async function awaitChatOutGate() {
|
|
689
|
+
const gate = locals.get(chatOutGateKey);
|
|
690
|
+
if (!gate || gate.open)
|
|
691
|
+
return;
|
|
692
|
+
const deadline = Date.now() + CHAT_OUT_GATE_TIMEOUT_MS;
|
|
693
|
+
while (gate.pending.size > 0) {
|
|
694
|
+
const remaining = deadline - Date.now();
|
|
695
|
+
if (remaining <= 0) {
|
|
696
|
+
gate.failOpen();
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
const waitingOn = [...gate.pending];
|
|
700
|
+
let timedOut = false;
|
|
701
|
+
let timer;
|
|
702
|
+
try {
|
|
703
|
+
await Promise.race([
|
|
704
|
+
Promise.allSettled(waitingOn),
|
|
705
|
+
gate.opened,
|
|
706
|
+
new Promise((resolve) => {
|
|
707
|
+
timer = setTimeout(() => {
|
|
708
|
+
timedOut = true;
|
|
709
|
+
resolve();
|
|
710
|
+
}, remaining);
|
|
711
|
+
}),
|
|
712
|
+
]);
|
|
713
|
+
}
|
|
714
|
+
finally {
|
|
715
|
+
if (timer)
|
|
716
|
+
clearTimeout(timer);
|
|
717
|
+
}
|
|
718
|
+
if (gate.open)
|
|
719
|
+
return;
|
|
720
|
+
if (timedOut) {
|
|
721
|
+
gate.failOpen();
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
for (const settled of waitingOn)
|
|
725
|
+
gate.pending.delete(settled);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
666
728
|
/**
|
|
667
|
-
*
|
|
668
|
-
*
|
|
669
|
-
*
|
|
729
|
+
* Register work that must land before anything from this turn reaches the
|
|
730
|
+
* frontend.
|
|
731
|
+
*
|
|
732
|
+
* Like {@link chatDefer} the work starts immediately and is never awaited by
|
|
733
|
+
* the hook that registered it, so it runs alongside the model and costs no
|
|
734
|
+
* time to first token. Unlike `chat.defer`, the output stream waits for it:
|
|
735
|
+
* no chunk of the answer is written to the session until it settles. That
|
|
736
|
+
* makes it the right home for a write the next page load has to see (a
|
|
737
|
+
* conversation row, a message insert), because a reader that can see the
|
|
738
|
+
* answer can also see what the write persisted.
|
|
739
|
+
*
|
|
740
|
+
* Reach for `chat.defer` instead when the timing does not matter for a
|
|
741
|
+
* reload: analytics, audit logs, search-index updates.
|
|
670
742
|
*
|
|
671
|
-
*
|
|
743
|
+
* This is not a consistency barrier for the turn. The work is still in flight
|
|
744
|
+
* while the model runs, so a tool, a `prepareStep`, or anything else executing
|
|
745
|
+
* during the turn can still read the state as it was before the write. It
|
|
746
|
+
* orders the write against what the frontend can see, nothing more. When the
|
|
747
|
+
* turn's own code has to read the write back, `await` it instead and accept
|
|
748
|
+
* the cost.
|
|
749
|
+
*
|
|
750
|
+
* A write registered here that fails, or outlasts the internal timeout, lets
|
|
751
|
+
* the stream through rather than stalling the conversation.
|
|
752
|
+
*
|
|
753
|
+
* @example
|
|
672
754
|
* ```ts
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
* },
|
|
679
|
-
* });
|
|
680
|
-
* await waitUntilComplete();
|
|
755
|
+
* onTurnStart: async ({ chatId, uiMessages }) => {
|
|
756
|
+
* chat.deferBeforeOutput(
|
|
757
|
+
* db.chat.update({ where: { id: chatId }, data: { messages: uiMessages } })
|
|
758
|
+
* );
|
|
759
|
+
* },
|
|
681
760
|
* ```
|
|
682
|
-
*
|
|
683
|
-
* Backed by the Session primitive so a chat's output outlives any single
|
|
684
|
-
* run — subscribers (browser transport, server-side `ChatStream`) read
|
|
685
|
-
* the session's `.out`, not a per-run stream. Run-scoped `target`
|
|
686
|
-
* options on `.pipe()` are honoured as no-ops; the session is the target.
|
|
687
761
|
*/
|
|
762
|
+
function chatDeferBeforeOutput(promiseOrFn) {
|
|
763
|
+
const gate = locals.get(chatOutGateKey);
|
|
764
|
+
const work = typeof promiseOrFn === "function" ? promiseOrFn() : promiseOrFn;
|
|
765
|
+
if (!gate || gate.open)
|
|
766
|
+
return;
|
|
767
|
+
gate.pending.add(work);
|
|
768
|
+
}
|
|
769
|
+
function gateWriterOptions(options) {
|
|
770
|
+
return {
|
|
771
|
+
...options,
|
|
772
|
+
execute: async (api) => {
|
|
773
|
+
await awaitChatOutGate();
|
|
774
|
+
return await options.execute(api);
|
|
775
|
+
},
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
function gateOutStream(value) {
|
|
779
|
+
return (async function* () {
|
|
780
|
+
await awaitChatOutGate();
|
|
781
|
+
if (isReadableStream(value)) {
|
|
782
|
+
const reader = value.getReader();
|
|
783
|
+
try {
|
|
784
|
+
while (true) {
|
|
785
|
+
const { done, value: chunk } = await reader.read();
|
|
786
|
+
if (done)
|
|
787
|
+
break;
|
|
788
|
+
yield chunk;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
finally {
|
|
792
|
+
reader.releaseLock();
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
else {
|
|
796
|
+
yield* value;
|
|
797
|
+
}
|
|
798
|
+
})();
|
|
799
|
+
}
|
|
688
800
|
const chatStream = {
|
|
689
801
|
// Stable opaque label for the run-scoped `RealtimeDefinedStream` shape.
|
|
690
802
|
// `chatStream` is backed by the Session's `.out` channel — this id is
|
|
@@ -694,7 +806,7 @@ const chatStream = {
|
|
|
694
806
|
id: "chat",
|
|
695
807
|
pipe(value, options) {
|
|
696
808
|
const { target: _target, ...sessionOptions } = (options ?? {});
|
|
697
|
-
return getChatSession().out.pipe(value, sessionOptions);
|
|
809
|
+
return getChatSession().out.pipe(gateOutStream(value), sessionOptions);
|
|
698
810
|
},
|
|
699
811
|
async read(_runId, options) {
|
|
700
812
|
// Session channels don't need a runId — the session is the address.
|
|
@@ -704,10 +816,11 @@ const chatStream = {
|
|
|
704
816
|
},
|
|
705
817
|
async append(value, options) {
|
|
706
818
|
const { target: _target, ...sessionOptions } = (options ?? {});
|
|
819
|
+
await awaitChatOutGate();
|
|
707
820
|
return getChatSession().out.append(value, sessionOptions);
|
|
708
821
|
},
|
|
709
822
|
writer(options) {
|
|
710
|
-
return getChatSession().out.writer(options);
|
|
823
|
+
return getChatSession().out.writer(gateWriterOptions(options));
|
|
711
824
|
},
|
|
712
825
|
};
|
|
713
826
|
// ---------------------------------------------------------------------------
|
|
@@ -757,9 +870,13 @@ function createLazyChatWriter() {
|
|
|
757
870
|
let mergeImpl = null;
|
|
758
871
|
let waitPromise = null;
|
|
759
872
|
let resolveExecute = null;
|
|
873
|
+
let started = false;
|
|
874
|
+
const bufferedParts = [];
|
|
875
|
+
const bufferedStreams = [];
|
|
760
876
|
function ensureInitialized() {
|
|
761
|
-
if (
|
|
877
|
+
if (started)
|
|
762
878
|
return;
|
|
879
|
+
started = true;
|
|
763
880
|
const executePromise = new Promise((resolve) => {
|
|
764
881
|
resolveExecute = resolve;
|
|
765
882
|
});
|
|
@@ -769,7 +886,11 @@ function createLazyChatWriter() {
|
|
|
769
886
|
execute: ({ write, merge }) => {
|
|
770
887
|
writeImpl = write;
|
|
771
888
|
mergeImpl = merge;
|
|
772
|
-
|
|
889
|
+
for (const part of bufferedParts.splice(0))
|
|
890
|
+
write(part);
|
|
891
|
+
for (const stream of bufferedStreams.splice(0))
|
|
892
|
+
merge(stream);
|
|
893
|
+
return executePromise;
|
|
773
894
|
},
|
|
774
895
|
});
|
|
775
896
|
waitPromise = waitUntilComplete;
|
|
@@ -779,11 +900,17 @@ function createLazyChatWriter() {
|
|
|
779
900
|
write(part) {
|
|
780
901
|
ensureInitialized();
|
|
781
902
|
queueResponsePart(part);
|
|
782
|
-
writeImpl
|
|
903
|
+
if (writeImpl)
|
|
904
|
+
writeImpl(part);
|
|
905
|
+
else
|
|
906
|
+
bufferedParts.push(part);
|
|
783
907
|
},
|
|
784
908
|
merge(stream) {
|
|
785
909
|
ensureInitialized();
|
|
786
|
-
mergeImpl
|
|
910
|
+
if (mergeImpl)
|
|
911
|
+
mergeImpl(stream);
|
|
912
|
+
else
|
|
913
|
+
bufferedStreams.push(stream);
|
|
787
914
|
},
|
|
788
915
|
},
|
|
789
916
|
async flush() {
|
|
@@ -1592,15 +1719,11 @@ async function installChatInputRouter(chatId, options) {
|
|
|
1592
1719
|
checkpoint.appliedThrough = Math.max(checkpoint.appliedThrough ?? replayWindowEnd, replayWindowEnd);
|
|
1593
1720
|
}
|
|
1594
1721
|
}
|
|
1595
|
-
// A boot that replayed `.in` itself has already answered everything up to
|
|
1596
|
-
// `recoveredThrough`, so the floor has to cover it before the tail opens.
|
|
1597
|
-
if (options?.recoveredThrough !== undefined) {
|
|
1598
|
-
const recovered = options.recoveredThrough;
|
|
1599
|
-
checkpoint.resumeFrom = Math.max(checkpoint.resumeFrom ?? recovered, recovered);
|
|
1600
|
-
checkpoint.appliedThrough = Math.max(checkpoint.appliedThrough ?? checkpoint.resumeFrom, checkpoint.resumeFrom);
|
|
1601
|
-
}
|
|
1602
1722
|
const router = entry.router;
|
|
1603
1723
|
router.restore(checkpoint);
|
|
1724
|
+
if (options?.recoveredSeqNums && options.recoveredSeqNums.length > 0) {
|
|
1725
|
+
router.markRecovered(options.recoveredSeqNums);
|
|
1726
|
+
}
|
|
1604
1727
|
const floor = router.resumeFrom();
|
|
1605
1728
|
if (floor !== undefined) {
|
|
1606
1729
|
sessionStreams.setLastSeqNum(chatId, "in", floor);
|
|
@@ -3946,6 +4069,17 @@ function chatAgent(options) {
|
|
|
3946
4069
|
* keeps an action's write cursor-neutral.
|
|
3947
4070
|
*/
|
|
3948
4071
|
let lastSnapshotOutEventId;
|
|
4072
|
+
/**
|
|
4073
|
+
* The `lastInEventId` the most recent snapshot carried.
|
|
4074
|
+
*
|
|
4075
|
+
* A turn-start save happens after the incoming message has been handed to
|
|
4076
|
+
* the turn loop, so the router's live resume floor has already advanced
|
|
4077
|
+
* past it. Persisting that floor before the turn runs would let the next
|
|
4078
|
+
* boot resume past a message this run never answered, which is exactly
|
|
4079
|
+
* what a deferred or recovered message depends on. Turn-start carries
|
|
4080
|
+
* this instead.
|
|
4081
|
+
*/
|
|
4082
|
+
let lastSnapshotInEventId;
|
|
3949
4083
|
const storageTrigger = (trigger) => trigger === "regenerate-message"
|
|
3950
4084
|
? "regenerate-message"
|
|
3951
4085
|
: trigger === "action" || trigger === "action-turn"
|
|
@@ -3959,7 +4093,8 @@ function chatAgent(options) {
|
|
|
3959
4093
|
*/
|
|
3960
4094
|
/** The runtime's opaque state as of the last save; carried on every changeset's transcript. */
|
|
3961
4095
|
let transcriptState = null;
|
|
3962
|
-
|
|
4096
|
+
let transcriptSaveChain = Promise.resolve();
|
|
4097
|
+
const runSaveTranscript = async (opts) => {
|
|
3963
4098
|
const { changes, shadow } = diffTranscript(transcriptShadow, opts.messages, {
|
|
3964
4099
|
nonFinalIds: opts.nonFinalIds,
|
|
3965
4100
|
});
|
|
@@ -3983,8 +4118,15 @@ function chatAgent(options) {
|
|
|
3983
4118
|
if (runtimeState !== null || persistedStateSet) {
|
|
3984
4119
|
changes.push({ op: "state", value: runtimeState });
|
|
3985
4120
|
}
|
|
4121
|
+
if (opts.skipIfUnchanged && changes.length === 0)
|
|
4122
|
+
return;
|
|
3986
4123
|
transcriptState = runtimeState;
|
|
3987
|
-
const
|
|
4124
|
+
const liveInCursor = chatInputRouter().resumeFloor();
|
|
4125
|
+
const inCursor = opts.carryInCursor
|
|
4126
|
+
? lastSnapshotInEventId
|
|
4127
|
+
: liveInCursor !== undefined
|
|
4128
|
+
? String(liveInCursor)
|
|
4129
|
+
: undefined;
|
|
3988
4130
|
await transcriptStorage.save({
|
|
3989
4131
|
chatId: payload.chatId,
|
|
3990
4132
|
clientData: opts.clientData,
|
|
@@ -4005,12 +4147,28 @@ function chatAgent(options) {
|
|
|
4005
4147
|
},
|
|
4006
4148
|
cursors: {
|
|
4007
4149
|
lastOutEventId: opts.lastOutEventId,
|
|
4008
|
-
lastInEventId: inCursor
|
|
4150
|
+
lastInEventId: inCursor,
|
|
4009
4151
|
},
|
|
4010
4152
|
});
|
|
4011
4153
|
transcriptShadow = shadow;
|
|
4154
|
+
lastSnapshotInEventId = inCursor;
|
|
4012
4155
|
persistedStateSet = runtimeState !== null;
|
|
4013
4156
|
};
|
|
4157
|
+
/**
|
|
4158
|
+
* Serialise every save onto one chain. `runSaveTranscript` derives its
|
|
4159
|
+
* changeset from `transcriptShadow` and only advances it once the write
|
|
4160
|
+
* lands, so two overlapping saves would diff against stale state. The
|
|
4161
|
+
* message list is copied on the way in because the accumulator keeps
|
|
4162
|
+
* mutating while a queued save waits its turn. A rejection is handed to
|
|
4163
|
+
* the caller but never poisons the chain.
|
|
4164
|
+
*/
|
|
4165
|
+
const saveTranscript = (opts) => {
|
|
4166
|
+
const queued = { ...opts, messages: [...opts.messages] };
|
|
4167
|
+
const run = () => runSaveTranscript(queued);
|
|
4168
|
+
const next = transcriptSaveChain.then(run, run);
|
|
4169
|
+
transcriptSaveChain = next.then(() => undefined, () => undefined);
|
|
4170
|
+
return next;
|
|
4171
|
+
};
|
|
4014
4172
|
/**
|
|
4015
4173
|
* Persist the accumulator outside a turn.
|
|
4016
4174
|
*
|
|
@@ -4061,6 +4219,13 @@ function chatAgent(options) {
|
|
|
4061
4219
|
// default, `inFlightUsers`). The turn-loop checks this queue ahead of
|
|
4062
4220
|
// `messagesInput.waitWithIdleTimeout` so recovered turns fire first.
|
|
4063
4221
|
const bootInjectedQueue = [];
|
|
4222
|
+
const recoveredSeqByPayload = new WeakMap();
|
|
4223
|
+
const dispatchBootInjected = () => bootInjectedQueue.shift();
|
|
4224
|
+
const settleRecoveredTurn = (wirePayload) => {
|
|
4225
|
+
const settledSeq = recoveredSeqByPayload.get(wirePayload);
|
|
4226
|
+
if (settledSeq !== undefined)
|
|
4227
|
+
chatInputRouter().settleRecovered(settledSeq);
|
|
4228
|
+
};
|
|
4064
4229
|
const couldHavePriorState = payload.continuation === true || ctx.attempt.number > 1;
|
|
4065
4230
|
// `.in` resume cursor, computed at most once per boot. The boot
|
|
4066
4231
|
// block below resolves it (snapshot field or records scan) and the
|
|
@@ -4110,6 +4275,7 @@ function chatAgent(options) {
|
|
|
4110
4275
|
// turn (chain self-bootstraps from turn 2), so this is purely an
|
|
4111
4276
|
// optimization to keep continuation runs bounded from the first turn.
|
|
4112
4277
|
lastSnapshotOutEventId = bootSnapshot?.lastOutEventId;
|
|
4278
|
+
lastSnapshotInEventId = bootSnapshot?.lastInEventId;
|
|
4113
4279
|
if (bootSnapshot?.lastOutEventId !== undefined) {
|
|
4114
4280
|
const seeded = Number.parseInt(bootSnapshot.lastOutEventId, 10);
|
|
4115
4281
|
if (Number.isFinite(seeded)) {
|
|
@@ -4201,16 +4367,10 @@ function chatAgent(options) {
|
|
|
4201
4367
|
}
|
|
4202
4368
|
// ── session.in router ──────────────────────────────────────────
|
|
4203
4369
|
//
|
|
4204
|
-
|
|
4205
|
-
// only a fallback: the boot block above may already have resolved a
|
|
4206
|
-
// cursor from the snapshot, which is used when the boundary itself
|
|
4207
|
-
// carries none. Everything the boot replayed off `.in` is dispatched from
|
|
4208
|
-
// `bootInjectedQueue` below, so it goes into the floor here — folded in
|
|
4209
|
-
// after the subscription opens, the live tail re-delivers it as a turn.
|
|
4210
|
-
const lastRecoveredInSeq = replayedInTail.length > 0 ? replayedInTail[replayedInTail.length - 1].seqNum : undefined;
|
|
4370
|
+
const recoveredSeqNums = replayedInTail.map((r) => r.seqNum);
|
|
4211
4371
|
await installChatInputRouter(payload.chatId, {
|
|
4212
4372
|
fallbackResumeFrom: bootInCursorResolved ? bootInCursor : undefined,
|
|
4213
|
-
|
|
4373
|
+
recoveredSeqNums,
|
|
4214
4374
|
resuming: Boolean(payload.continuation) || ctx.attempt.number > 1,
|
|
4215
4375
|
});
|
|
4216
4376
|
// ── Recovery boot + chain reconstruction ────────────────────────
|
|
@@ -4293,7 +4453,7 @@ function chatAgent(options) {
|
|
|
4293
4453
|
// branches: at n=1 the orphan partial is dropped and the interrupted
|
|
4294
4454
|
// user is re-dispatched as a fresh turn instead.
|
|
4295
4455
|
let seedChain;
|
|
4296
|
-
let
|
|
4456
|
+
let recoveredEntries;
|
|
4297
4457
|
if (hookChain !== undefined) {
|
|
4298
4458
|
seedChain = hookChain;
|
|
4299
4459
|
}
|
|
@@ -4304,13 +4464,26 @@ function chatAgent(options) {
|
|
|
4304
4464
|
seedChain = settledMessages;
|
|
4305
4465
|
}
|
|
4306
4466
|
if (hookRecoveredTurns !== undefined) {
|
|
4307
|
-
|
|
4467
|
+
const seqNumsByRecoveredId = new Map();
|
|
4468
|
+
for (const entry of replayedInTail) {
|
|
4469
|
+
const existing = seqNumsByRecoveredId.get(entry.message.id);
|
|
4470
|
+
if (existing)
|
|
4471
|
+
existing.push(entry.seqNum);
|
|
4472
|
+
else
|
|
4473
|
+
seqNumsByRecoveredId.set(entry.message.id, [entry.seqNum]);
|
|
4474
|
+
}
|
|
4475
|
+
recoveredEntries = hookRecoveredTurns.map((message) => ({
|
|
4476
|
+
message,
|
|
4477
|
+
seqNum: seqNumsByRecoveredId.get(message.id)?.shift(),
|
|
4478
|
+
}));
|
|
4308
4479
|
}
|
|
4309
4480
|
else if (partialAssistant !== undefined && inFlightUsers.length > 1) {
|
|
4310
|
-
|
|
4481
|
+
recoveredEntries = replayedInTail
|
|
4482
|
+
.slice(1)
|
|
4483
|
+
.map((r) => ({ message: r.message, seqNum: r.seqNum }));
|
|
4311
4484
|
}
|
|
4312
4485
|
else {
|
|
4313
|
-
|
|
4486
|
+
recoveredEntries = replayedInTail.map((r) => ({ message: r.message, seqNum: r.seqNum }));
|
|
4314
4487
|
}
|
|
4315
4488
|
// `beforeBoot` errors bubble — the customer opted into blocking
|
|
4316
4489
|
// persistence and a failure there should fail the run rather than
|
|
@@ -4340,13 +4513,14 @@ function chatAgent(options) {
|
|
|
4340
4513
|
for (const entry of replayedInTail) {
|
|
4341
4514
|
metadataById.set(entry.message.id, entry.metadata);
|
|
4342
4515
|
}
|
|
4343
|
-
|
|
4516
|
+
const dispatchedRecoveredSeqs = new Set();
|
|
4517
|
+
for (const { message: msg, seqNum } of recoveredEntries) {
|
|
4344
4518
|
if (wireMessageId && msg.id === wireMessageId)
|
|
4345
4519
|
continue;
|
|
4346
4520
|
const recoveredMetadata = metadataById.has(msg.id)
|
|
4347
4521
|
? metadataById.get(msg.id)
|
|
4348
4522
|
: payload.metadata;
|
|
4349
|
-
|
|
4523
|
+
const injectedPayload = {
|
|
4350
4524
|
chatId: payload.chatId,
|
|
4351
4525
|
sessionId: payload.sessionId,
|
|
4352
4526
|
metadata: recoveredMetadata,
|
|
@@ -4355,7 +4529,17 @@ function chatAgent(options) {
|
|
|
4355
4529
|
messageId: msg.id,
|
|
4356
4530
|
continuation: payload.continuation,
|
|
4357
4531
|
previousRunId: payload.previousRunId,
|
|
4358
|
-
}
|
|
4532
|
+
};
|
|
4533
|
+
bootInjectedQueue.push(injectedPayload);
|
|
4534
|
+
if (seqNum !== undefined) {
|
|
4535
|
+
recoveredSeqByPayload.set(injectedPayload, seqNum);
|
|
4536
|
+
dispatchedRecoveredSeqs.add(seqNum);
|
|
4537
|
+
}
|
|
4538
|
+
}
|
|
4539
|
+
for (const entry of replayedInTail) {
|
|
4540
|
+
if (!dispatchedRecoveredSeqs.has(entry.seqNum)) {
|
|
4541
|
+
chatInputRouter().settleRecovered(entry.seqNum);
|
|
4542
|
+
}
|
|
4359
4543
|
}
|
|
4360
4544
|
accumulatedUIMessages = seedChain;
|
|
4361
4545
|
// ── Head-start bootstrap ─────────────────────────────────────
|
|
@@ -4515,7 +4699,7 @@ function chatAgent(options) {
|
|
|
4515
4699
|
*/
|
|
4516
4700
|
let dispatchedRecoveredFirstTurn = false;
|
|
4517
4701
|
if (preloaded && bootInjectedQueue.length > 0) {
|
|
4518
|
-
currentWirePayload =
|
|
4702
|
+
currentWirePayload = dispatchBootInjected();
|
|
4519
4703
|
dispatchedRecoveredFirstTurn = true;
|
|
4520
4704
|
}
|
|
4521
4705
|
// Handle preloaded runs — fire onPreload, then wait for the first real message
|
|
@@ -4723,7 +4907,7 @@ function chatAgent(options) {
|
|
|
4723
4907
|
// waiting on the live session.in. Subsequent recovered turns
|
|
4724
4908
|
// get drained by the end-of-turn picker below.
|
|
4725
4909
|
if (bootInjectedQueue.length > 0) {
|
|
4726
|
-
currentWirePayload =
|
|
4910
|
+
currentWirePayload = dispatchBootInjected();
|
|
4727
4911
|
}
|
|
4728
4912
|
else {
|
|
4729
4913
|
const effectiveIdleTimeout = idleTimeoutInSeconds ?? payload.idleTimeoutInSeconds;
|
|
@@ -4841,6 +5025,7 @@ function chatAgent(options) {
|
|
|
4841
5025
|
// (errors are caught by the outer try/catch which writes an error chunk)
|
|
4842
5026
|
locals.set(chatPipeCountKey, 0);
|
|
4843
5027
|
locals.set(chatDeferKey, new Set());
|
|
5028
|
+
locals.set(chatOutGateKey, createChatOutGate());
|
|
4844
5029
|
locals.set(chatCompactionStateKey, undefined);
|
|
4845
5030
|
locals.set(chatSteeringQueueKey, []);
|
|
4846
5031
|
locals.set(chatPendingBackgroundKey, []);
|
|
@@ -5287,6 +5472,7 @@ function chatAgent(options) {
|
|
|
5287
5472
|
chatId: currentWirePayload.chatId,
|
|
5288
5473
|
messageId: currentWirePayload.messageId,
|
|
5289
5474
|
});
|
|
5475
|
+
settleRecoveredTurn(currentWirePayload);
|
|
5290
5476
|
await writeTurnCompleteChunk(currentWirePayload.chatId);
|
|
5291
5477
|
// Not a turn — don't consume an iteration.
|
|
5292
5478
|
turn--;
|
|
@@ -5328,6 +5514,23 @@ function chatAgent(options) {
|
|
|
5328
5514
|
// A no-op turn skips this block, and with it `followSessionPin`:
|
|
5329
5515
|
// there is nothing to answer, so nothing to hand over.
|
|
5330
5516
|
if ((!isAction || actionTurn) && !isNoOpTurn) {
|
|
5517
|
+
if (!hydrateMessages) {
|
|
5518
|
+
chatDeferBeforeOutput(saveTranscript({
|
|
5519
|
+
reason: "turn-start",
|
|
5520
|
+
messages: accumulatedUIMessages,
|
|
5521
|
+
turn,
|
|
5522
|
+
trigger: storageTrigger(currentWirePayload.trigger),
|
|
5523
|
+
clientData,
|
|
5524
|
+
lastOutEventId: lastSnapshotOutEventId,
|
|
5525
|
+
skipIfUnchanged: true,
|
|
5526
|
+
carryInCursor: true,
|
|
5527
|
+
}).catch((error) => {
|
|
5528
|
+
logger.warn("chat.agent: turn-start transcript write failed; a reload mid-answer may not show the message being answered", {
|
|
5529
|
+
error: error instanceof Error ? error.message : String(error),
|
|
5530
|
+
sessionId: sessionIdForSnapshot,
|
|
5531
|
+
});
|
|
5532
|
+
}));
|
|
5533
|
+
}
|
|
5331
5534
|
// Mint a scoped public access token once per turn, reused for
|
|
5332
5535
|
// onChatStart, onTurnStart, onTurnComplete, and the turn-complete chunk.
|
|
5333
5536
|
const currentRunId = ctx.run.id;
|
|
@@ -6002,6 +6205,7 @@ function chatAgent(options) {
|
|
|
6002
6205
|
}
|
|
6003
6206
|
locals.set(chatResponsePartsKey, []);
|
|
6004
6207
|
}
|
|
6208
|
+
settleRecoveredTurn(currentWirePayload);
|
|
6005
6209
|
// Write turn-complete control chunk — closes the frontend stream.
|
|
6006
6210
|
const turnCompleteResult = await writeTurnCompleteChunk(currentWirePayload.chatId, turnAccessToken);
|
|
6007
6211
|
// Fire onTurnComplete — stream is closed, use for persistence.
|
|
@@ -6113,7 +6317,7 @@ function chatAgent(options) {
|
|
|
6113
6317
|
// produced these from in-flight user messages on session.in
|
|
6114
6318
|
// that the dead predecessor never acknowledged.
|
|
6115
6319
|
if (bootInjectedQueue.length > 0) {
|
|
6116
|
-
currentWirePayload =
|
|
6320
|
+
currentWirePayload = dispatchBootInjected();
|
|
6117
6321
|
return "continue";
|
|
6118
6322
|
}
|
|
6119
6323
|
// chat.requestUpgrade() was called — exit the loop; the handover
|
|
@@ -6433,7 +6637,7 @@ function chatAgent(options) {
|
|
|
6433
6637
|
// recovered turn shouldn't strand the rest of the boot queue
|
|
6434
6638
|
// until an unrelated live message arrives.
|
|
6435
6639
|
if (bootInjectedQueue.length > 0) {
|
|
6436
|
-
currentWirePayload =
|
|
6640
|
+
currentWirePayload = dispatchBootInjected();
|
|
6437
6641
|
continue;
|
|
6438
6642
|
}
|
|
6439
6643
|
// Wait for the next message — same as after a successful turn
|
|
@@ -8803,6 +9007,7 @@ export const chat = {
|
|
|
8803
9007
|
cleanupAbortedParts,
|
|
8804
9008
|
/** Register background work that runs in parallel with streaming. See {@link chatDefer}. */
|
|
8805
9009
|
defer: chatDefer,
|
|
9010
|
+
deferBeforeOutput: chatDeferBeforeOutput,
|
|
8806
9011
|
/** Queue model messages for injection at the next `prepareStep` boundary. See {@link injectBackgroundContext}. */
|
|
8807
9012
|
inject: injectBackgroundContext,
|
|
8808
9013
|
/** Typed chat output stream for writing custom chunks or piping from subtasks. */
|