ai 6.0.62 → 6.0.64
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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +39 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -14
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +1 -1
- package/src/middleware/extract-reasoning-middleware.ts +12 -1
- package/src/ui/chat.ts +34 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.64
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ce9daa3: Fixed 'reasoning part reasoning-0 not found' error by ensuring 'reasoning-start' event is emitted for empty thinking blocks (eg. <think></think>)
|
|
8
|
+
|
|
9
|
+
## 6.0.63
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- be95579: fix(ui): respect `Promise<false>` when returned by `sendAutomaticallyWhen`
|
|
14
|
+
|
|
3
15
|
## 6.0.62
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -3433,6 +3433,7 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
3433
3433
|
* Abort the current request immediately, keep the generated tokens if any.
|
|
3434
3434
|
*/
|
|
3435
3435
|
stop: () => Promise<void>;
|
|
3436
|
+
private shouldSendAutomatically;
|
|
3436
3437
|
private makeRequest;
|
|
3437
3438
|
}
|
|
3438
3439
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3433,6 +3433,7 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
3433
3433
|
* Abort the current request immediately, keep the generated tokens if any.
|
|
3434
3434
|
*/
|
|
3435
3435
|
stop: () => Promise<void>;
|
|
3436
|
+
private shouldSendAutomatically;
|
|
3436
3437
|
private makeRequest;
|
|
3437
3438
|
}
|
|
3438
3439
|
|
package/dist/index.js
CHANGED
|
@@ -1104,7 +1104,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
|
1104
1104
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
1105
1105
|
|
|
1106
1106
|
// src/version.ts
|
|
1107
|
-
var VERSION = true ? "6.0.
|
|
1107
|
+
var VERSION = true ? "6.0.64" : "0.0.0-test";
|
|
1108
1108
|
|
|
1109
1109
|
// src/util/download/download.ts
|
|
1110
1110
|
var download = async ({ url }) => {
|
|
@@ -10988,6 +10988,12 @@ function extractReasoningMiddleware({
|
|
|
10988
10988
|
startIndex + nextTag.length
|
|
10989
10989
|
);
|
|
10990
10990
|
if (activeExtraction.isReasoning) {
|
|
10991
|
+
if (activeExtraction.isFirstReasoning) {
|
|
10992
|
+
controller.enqueue({
|
|
10993
|
+
type: "reasoning-start",
|
|
10994
|
+
id: `reasoning-${activeExtraction.idCounter}`
|
|
10995
|
+
});
|
|
10996
|
+
}
|
|
10991
10997
|
controller.enqueue({
|
|
10992
10998
|
type: "reasoning-end",
|
|
10993
10999
|
id: `reasoning-${activeExtraction.idCounter++}`
|
|
@@ -12190,7 +12196,6 @@ var AbstractChat = class {
|
|
|
12190
12196
|
approved,
|
|
12191
12197
|
reason
|
|
12192
12198
|
}) => this.jobExecutor.run(async () => {
|
|
12193
|
-
var _a20, _b;
|
|
12194
12199
|
const messages = this.state.messages;
|
|
12195
12200
|
const lastMessage = messages[messages.length - 1];
|
|
12196
12201
|
const updatePart = (part) => isToolUIPart(part) && part.state === "approval-requested" && part.approval.id === id ? {
|
|
@@ -12205,10 +12210,15 @@ var AbstractChat = class {
|
|
|
12205
12210
|
if (this.activeResponse) {
|
|
12206
12211
|
this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(updatePart);
|
|
12207
12212
|
}
|
|
12208
|
-
if (this.status !== "streaming" && this.status !== "submitted" &&
|
|
12209
|
-
this.
|
|
12210
|
-
|
|
12211
|
-
|
|
12213
|
+
if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
|
|
12214
|
+
this.shouldSendAutomatically().then((shouldSend) => {
|
|
12215
|
+
var _a20;
|
|
12216
|
+
if (shouldSend) {
|
|
12217
|
+
this.makeRequest({
|
|
12218
|
+
trigger: "submit-message",
|
|
12219
|
+
messageId: (_a20 = this.lastMessage) == null ? void 0 : _a20.id
|
|
12220
|
+
});
|
|
12221
|
+
}
|
|
12212
12222
|
});
|
|
12213
12223
|
}
|
|
12214
12224
|
});
|
|
@@ -12219,7 +12229,6 @@ var AbstractChat = class {
|
|
|
12219
12229
|
output,
|
|
12220
12230
|
errorText
|
|
12221
12231
|
}) => this.jobExecutor.run(async () => {
|
|
12222
|
-
var _a20, _b;
|
|
12223
12232
|
const messages = this.state.messages;
|
|
12224
12233
|
const lastMessage = messages[messages.length - 1];
|
|
12225
12234
|
const updatePart = (part) => isToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state, output, errorText } : part;
|
|
@@ -12230,10 +12239,15 @@ var AbstractChat = class {
|
|
|
12230
12239
|
if (this.activeResponse) {
|
|
12231
12240
|
this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(updatePart);
|
|
12232
12241
|
}
|
|
12233
|
-
if (this.status !== "streaming" && this.status !== "submitted" &&
|
|
12234
|
-
this.
|
|
12235
|
-
|
|
12236
|
-
|
|
12242
|
+
if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
|
|
12243
|
+
this.shouldSendAutomatically().then((shouldSend) => {
|
|
12244
|
+
var _a20;
|
|
12245
|
+
if (shouldSend) {
|
|
12246
|
+
this.makeRequest({
|
|
12247
|
+
trigger: "submit-message",
|
|
12248
|
+
messageId: (_a20 = this.lastMessage) == null ? void 0 : _a20.id
|
|
12249
|
+
});
|
|
12250
|
+
}
|
|
12237
12251
|
});
|
|
12238
12252
|
}
|
|
12239
12253
|
});
|
|
@@ -12294,6 +12308,17 @@ var AbstractChat = class {
|
|
|
12294
12308
|
set messages(messages) {
|
|
12295
12309
|
this.state.messages = messages;
|
|
12296
12310
|
}
|
|
12311
|
+
async shouldSendAutomatically() {
|
|
12312
|
+
if (!this.sendAutomaticallyWhen)
|
|
12313
|
+
return false;
|
|
12314
|
+
const result = this.sendAutomaticallyWhen({
|
|
12315
|
+
messages: this.state.messages
|
|
12316
|
+
});
|
|
12317
|
+
if (result && typeof result === "object" && "then" in result) {
|
|
12318
|
+
return await result;
|
|
12319
|
+
}
|
|
12320
|
+
return result;
|
|
12321
|
+
}
|
|
12297
12322
|
async makeRequest({
|
|
12298
12323
|
trigger,
|
|
12299
12324
|
metadata,
|
|
@@ -12301,7 +12326,7 @@ var AbstractChat = class {
|
|
|
12301
12326
|
body,
|
|
12302
12327
|
messageId
|
|
12303
12328
|
}) {
|
|
12304
|
-
var _a20, _b, _c
|
|
12329
|
+
var _a20, _b, _c;
|
|
12305
12330
|
this.setStatus({ status: "submitted", error: void 0 });
|
|
12306
12331
|
const lastMessage = this.lastMessage;
|
|
12307
12332
|
let isAbort = false;
|
|
@@ -12411,10 +12436,10 @@ var AbstractChat = class {
|
|
|
12411
12436
|
}
|
|
12412
12437
|
this.activeResponse = void 0;
|
|
12413
12438
|
}
|
|
12414
|
-
if (
|
|
12439
|
+
if (!isError && await this.shouldSendAutomatically()) {
|
|
12415
12440
|
await this.makeRequest({
|
|
12416
12441
|
trigger: "submit-message",
|
|
12417
|
-
messageId: (
|
|
12442
|
+
messageId: (_c = this.lastMessage) == null ? void 0 : _c.id,
|
|
12418
12443
|
metadata,
|
|
12419
12444
|
headers,
|
|
12420
12445
|
body
|