@trigger.dev/sdk 4.7.1 → 4.7.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/commonjs/imports/ai-runtime-cjs.cjs.map +1 -1
- package/dist/commonjs/imports/ai-runtime.js +2 -0
- package/dist/commonjs/v3/ai.js +19 -33
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/managedChatResponse.js +3 -15
- package/dist/commonjs/v3/managedChatResponse.js.map +1 -1
- package/dist/commonjs/v3/test/mock-chat-agent.js +4 -15
- package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/commonjs/v3/toolResultOrder.d.ts +15 -0
- package/dist/commonjs/v3/toolResultOrder.js +58 -0
- package/dist/commonjs/v3/toolResultOrder.js.map +1 -0
- package/dist/commonjs/v3/uiMessageChunks.d.ts +1 -0
- package/dist/commonjs/v3/uiMessageChunks.js +119 -0
- package/dist/commonjs/v3/uiMessageChunks.js.map +1 -0
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/imports/ai-runtime.d.ts +2 -2
- package/dist/esm/imports/ai-runtime.js +2 -2
- package/dist/esm/imports/ai-runtime.js.map +1 -1
- package/dist/esm/v3/ai.js +20 -34
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/managedChatResponse.js +4 -16
- package/dist/esm/v3/managedChatResponse.js.map +1 -1
- package/dist/esm/v3/test/mock-chat-agent.js +4 -15
- package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/esm/v3/toolResultOrder.d.ts +15 -0
- package/dist/esm/v3/toolResultOrder.js +55 -0
- package/dist/esm/v3/toolResultOrder.js.map +1 -0
- package/dist/esm/v3/uiMessageChunks.d.ts +1 -0
- package/dist/esm/v3/uiMessageChunks.js +116 -0
- package/dist/esm/v3/uiMessageChunks.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-runtime-cjs.cjs","sourceRoot":"","sources":["../../../src/imports/ai-runtime-cjs.cts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,iFAAiF;;AAEjF,aAAa;AACb,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzB,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,sBAAsB,GAAG,EAAE,CAAC,sBAAsB,CAAC;AAClE,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;AAC5C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;AAC1C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;AAC5C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC;AAC9C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;AAC1C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,mBAAmB,GAAG,EAAE,CAAC,mBAAmB,CAAC;AAC5D,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;AAC5C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;AAC1C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;AAC9B,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"ai-runtime-cjs.cjs","sourceRoot":"","sources":["../../../src/imports/ai-runtime-cjs.cts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,iFAAiF;;AAEjF,aAAa;AACb,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzB,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,sBAAsB,GAAG,EAAE,CAAC,sBAAsB,CAAC;AAClE,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,qBAAqB,GAAG,EAAE,CAAC,qBAAqB,CAAC;AAChE,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;AAC5C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;AAC1C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;AAC5C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC;AAC9C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;AAC1C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,mBAAmB,GAAG,EAAE,CAAC,mBAAmB,CAAC;AAC5D,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;AAC5C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;AAC1C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;AAC9B,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,CAAC"}
|
|
@@ -7,6 +7,8 @@ const ai = require("ai");
|
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
module.exports.convertToModelMessages = ai.convertToModelMessages;
|
|
9
9
|
// @ts-ignore
|
|
10
|
+
module.exports.createUIMessageStream = ai.createUIMessageStream;
|
|
11
|
+
// @ts-ignore
|
|
10
12
|
module.exports.dynamicTool = ai.dynamicTool;
|
|
11
13
|
// @ts-ignore
|
|
12
14
|
module.exports.generateId = ai.generateId;
|
package/dist/commonjs/v3/ai.js
CHANGED
|
@@ -20,7 +20,9 @@ const chatRouteWait_js_1 = require("./chatRouteWait.js");
|
|
|
20
20
|
const ai_runtime_js_1 = require("../imports/ai-runtime.js");
|
|
21
21
|
const transcriptStorage_js_1 = require("./transcriptStorage.js");
|
|
22
22
|
const compactionResponse_js_1 = require("./compactionResponse.js");
|
|
23
|
+
const toolResultOrder_js_1 = require("./toolResultOrder.js");
|
|
23
24
|
const managedChatResponse_js_1 = require("./managedChatResponse.js");
|
|
25
|
+
const uiMessageChunks_js_1 = require("./uiMessageChunks.js");
|
|
24
26
|
const steeringContext_js_1 = require("./steeringContext.js");
|
|
25
27
|
let transcriptStorageOverride;
|
|
26
28
|
/**
|
|
@@ -219,9 +221,9 @@ function __setReplaySessionOutTailImplForTests(impl) {
|
|
|
219
221
|
* 2. Filter out the agent's control chunks (`type: "trigger:*"`) — they
|
|
220
222
|
* ride on the same stream as the user-visible UIMessageChunks.
|
|
221
223
|
* 3. Split chunks at `start`/`finish` boundaries so each segment is a
|
|
222
|
-
* single message, then
|
|
223
|
-
*
|
|
224
|
-
*
|
|
224
|
+
* single message, then reduce each segment with the AI SDK's reducer
|
|
225
|
+
* (the same one `useChat` uses on the browser side) via
|
|
226
|
+
* {@link reduceUIMessageChunks}, which builds only the final state.
|
|
225
227
|
* 4. The trailing message — if it never received a `finish` chunk —
|
|
226
228
|
* goes through `cleanupAbortedParts` so partial in-flight parts
|
|
227
229
|
* don't leak into the next turn's accumulator. Drop it entirely
|
|
@@ -272,8 +274,8 @@ async function replaySessionOutTail(sessionId, options) {
|
|
|
272
274
|
}
|
|
273
275
|
if (!current) {
|
|
274
276
|
// Chunk arrived before any `start`. Synthesize a segment so the reducer
|
|
275
|
-
// has something to work with
|
|
276
|
-
//
|
|
277
|
+
// has something to work with. The reducer tolerates a missing `start`
|
|
278
|
+
// and leaves the message ID empty.
|
|
277
279
|
current = { chunks: [], closed: false };
|
|
278
280
|
segments.push(current);
|
|
279
281
|
}
|
|
@@ -289,18 +291,9 @@ async function replaySessionOutTail(sessionId, options) {
|
|
|
289
291
|
for (let i = 0; i < segments.length; i++) {
|
|
290
292
|
const seg = segments[i];
|
|
291
293
|
const isTrailing = i === segments.length - 1 && !seg.closed;
|
|
292
|
-
const segmentStream = new ReadableStream({
|
|
293
|
-
start(controller) {
|
|
294
|
-
for (const c of seg.chunks)
|
|
295
|
-
controller.enqueue(c);
|
|
296
|
-
controller.close();
|
|
297
|
-
},
|
|
298
|
-
});
|
|
299
294
|
let last;
|
|
300
295
|
try {
|
|
301
|
-
|
|
302
|
-
last = snapshot;
|
|
303
|
-
}
|
|
296
|
+
last = await (0, uiMessageChunks_js_1.reduceUIMessageChunks)(seg.chunks);
|
|
304
297
|
}
|
|
305
298
|
catch (error) {
|
|
306
299
|
// Reducer error — the segment is malformed. Skip it and keep going so a
|
|
@@ -333,15 +326,15 @@ async function replaySessionOutTail(sessionId, options) {
|
|
|
333
326
|
}
|
|
334
327
|
/**
|
|
335
328
|
* Test-only entry point that bypasses `__setReplaySessionOutTailImplForTests`
|
|
336
|
-
* and reaches the real `apiClient.
|
|
337
|
-
* splitter +
|
|
329
|
+
* and reaches the real `apiClient.readSessionStreamRecords` + chunk-segment
|
|
330
|
+
* splitter + {@link reduceUIMessageChunks} reducer. Pairs with the snapshot
|
|
338
331
|
* production-path wrappers above. Lets `replay-session-out.test.ts` drive
|
|
339
332
|
* synthetic chunk sequences through the real reducer to lock down chunk-
|
|
340
333
|
* stream → `UIMessage[]` correctness — if the AI SDK's chunk semantics
|
|
341
334
|
* shift in a future version, the test catches it before customers do.
|
|
342
335
|
*
|
|
343
|
-
* Tests should
|
|
344
|
-
*
|
|
336
|
+
* Tests should stub `apiClient.readSessionStreamRecords` to return the
|
|
337
|
+
* recorded chunks as session stream records.
|
|
345
338
|
*
|
|
346
339
|
* Not part of the public API.
|
|
347
340
|
* @internal
|
|
@@ -3553,7 +3546,11 @@ function toStreamTextOptions(options, retain = true) {
|
|
|
3553
3546
|
});
|
|
3554
3547
|
locals_js_1.locals.set(chatPendingBackgroundKey, pendingBackground);
|
|
3555
3548
|
}
|
|
3556
|
-
|
|
3549
|
+
// 4. Parallel tool results in call order, the order the next turn's history
|
|
3550
|
+
// will list them in. See `withToolResultsInCallOrder`.
|
|
3551
|
+
const base = resultMessages ?? messages;
|
|
3552
|
+
const ordered = (0, toolResultOrder_js_1.withToolResultsInCallOrder)(base);
|
|
3553
|
+
return resultMessages || ordered !== base ? { messages: ordered } : undefined;
|
|
3557
3554
|
};
|
|
3558
3555
|
}
|
|
3559
3556
|
if (retain && typeof result.prepareStep === "function") {
|
|
@@ -7595,7 +7592,7 @@ function tapUIMessageChunks(source, buffer) {
|
|
|
7595
7592
|
* Reconstruct a partial assistant `UIMessage` from the raw chunks that
|
|
7596
7593
|
* streamed before a failure — the fallback for {@link pipeChatAndCapture}
|
|
7597
7594
|
* when a transport error abandons the stream before `onFinish` runs. Uses the
|
|
7598
|
-
* same
|
|
7595
|
+
* same {@link reduceUIMessageChunks} reducer as the boot-time replay path. Returns
|
|
7599
7596
|
* `undefined` if there's nothing to assemble or the reducer throws.
|
|
7600
7597
|
*/
|
|
7601
7598
|
async function assemblePartialFromChunks(chunks) {
|
|
@@ -7606,18 +7603,7 @@ async function assemblePartialFromChunks(chunks) {
|
|
|
7606
7603
|
if (relevant.length === 0)
|
|
7607
7604
|
return undefined;
|
|
7608
7605
|
try {
|
|
7609
|
-
|
|
7610
|
-
start(controller) {
|
|
7611
|
-
for (const chunk of relevant)
|
|
7612
|
-
controller.enqueue(chunk);
|
|
7613
|
-
controller.close();
|
|
7614
|
-
},
|
|
7615
|
-
});
|
|
7616
|
-
let last;
|
|
7617
|
-
for await (const message of (0, ai_runtime_js_1.readUIMessageStream)({ stream })) {
|
|
7618
|
-
last = message;
|
|
7619
|
-
}
|
|
7620
|
-
return last;
|
|
7606
|
+
return await (0, uiMessageChunks_js_1.reduceUIMessageChunks)(relevant);
|
|
7621
7607
|
}
|
|
7622
7608
|
catch {
|
|
7623
7609
|
return undefined;
|