ai 4.1.0 → 4.1.1
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 +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/dist/index.mjs
CHANGED
@@ -3856,6 +3856,7 @@ async function generateText({
|
|
3856
3856
|
const currentStepResult = {
|
3857
3857
|
stepType,
|
3858
3858
|
text: stepText,
|
3859
|
+
reasoning: currentModelResponse.reasoning,
|
3859
3860
|
toolCalls: currentToolCalls,
|
3860
3861
|
toolResults: currentToolResults,
|
3861
3862
|
finishReason: currentModelResponse.finishReason,
|
@@ -3894,6 +3895,7 @@ async function generateText({
|
|
3894
3895
|
);
|
3895
3896
|
return new DefaultGenerateTextResult({
|
3896
3897
|
text: text2,
|
3898
|
+
reasoning: currentModelResponse.reasoning,
|
3897
3899
|
outputResolver: () => {
|
3898
3900
|
if (output == null) {
|
3899
3901
|
throw new NoOutputSpecifiedError();
|
@@ -3999,6 +4001,7 @@ async function executeTools({
|
|
3999
4001
|
var DefaultGenerateTextResult = class {
|
4000
4002
|
constructor(options) {
|
4001
4003
|
this.text = options.text;
|
4004
|
+
this.reasoning = options.reasoning;
|
4002
4005
|
this.toolCalls = options.toolCalls;
|
4003
4006
|
this.toolResults = options.toolResults;
|
4004
4007
|
this.finishReason = options.finishReason;
|
@@ -4300,6 +4303,7 @@ function runToolsTransformation({
|
|
4300
4303
|
const chunkType = chunk.type;
|
4301
4304
|
switch (chunkType) {
|
4302
4305
|
case "text-delta":
|
4306
|
+
case "reasoning":
|
4303
4307
|
case "response-metadata":
|
4304
4308
|
case "error": {
|
4305
4309
|
controller.enqueue(chunk);
|
@@ -4607,6 +4611,7 @@ var DefaultStreamTextResult = class {
|
|
4607
4611
|
this.finishReasonPromise = new DelayedPromise();
|
4608
4612
|
this.providerMetadataPromise = new DelayedPromise();
|
4609
4613
|
this.textPromise = new DelayedPromise();
|
4614
|
+
this.reasoningPromise = new DelayedPromise();
|
4610
4615
|
this.toolCallsPromise = new DelayedPromise();
|
4611
4616
|
this.toolResultsPromise = new DelayedPromise();
|
4612
4617
|
this.requestPromise = new DelayedPromise();
|
@@ -4624,6 +4629,7 @@ var DefaultStreamTextResult = class {
|
|
4624
4629
|
let recordedStepText = "";
|
4625
4630
|
let recordedContinuationText = "";
|
4626
4631
|
let recordedFullText = "";
|
4632
|
+
let recordedReasoningText = void 0;
|
4627
4633
|
const recordedResponse = {
|
4628
4634
|
id: generateId3(),
|
4629
4635
|
timestamp: currentDate(),
|
@@ -4641,7 +4647,7 @@ var DefaultStreamTextResult = class {
|
|
4641
4647
|
async transform(chunk, controller) {
|
4642
4648
|
controller.enqueue(chunk);
|
4643
4649
|
const { part } = chunk;
|
4644
|
-
if (part.type === "text-delta" || part.type === "tool-call" || part.type === "tool-result" || part.type === "tool-call-streaming-start" || part.type === "tool-call-delta") {
|
4650
|
+
if (part.type === "text-delta" || part.type === "reasoning" || part.type === "tool-call" || part.type === "tool-result" || part.type === "tool-call-streaming-start" || part.type === "tool-call-delta") {
|
4645
4651
|
await (onChunk == null ? void 0 : onChunk({ chunk: part }));
|
4646
4652
|
}
|
4647
4653
|
if (part.type === "text-delta") {
|
@@ -4649,6 +4655,9 @@ var DefaultStreamTextResult = class {
|
|
4649
4655
|
recordedContinuationText += part.textDelta;
|
4650
4656
|
recordedFullText += part.textDelta;
|
4651
4657
|
}
|
4658
|
+
if (part.type === "reasoning") {
|
4659
|
+
recordedReasoningText = (recordedReasoningText != null ? recordedReasoningText : "") + part.textDelta;
|
4660
|
+
}
|
4652
4661
|
if (part.type === "tool-call") {
|
4653
4662
|
recordedToolCalls.push(part);
|
4654
4663
|
}
|
@@ -4681,6 +4690,7 @@ var DefaultStreamTextResult = class {
|
|
4681
4690
|
const currentStepResult = {
|
4682
4691
|
stepType,
|
4683
4692
|
text: recordedStepText,
|
4693
|
+
reasoning: recordedReasoningText,
|
4684
4694
|
toolCalls: recordedToolCalls,
|
4685
4695
|
toolResults: recordedToolResults,
|
4686
4696
|
finishReason: part.finishReason,
|
@@ -4741,12 +4751,14 @@ var DefaultStreamTextResult = class {
|
|
4741
4751
|
self.finishReasonPromise.resolve(finishReason);
|
4742
4752
|
self.usagePromise.resolve(usage);
|
4743
4753
|
self.textPromise.resolve(recordedFullText);
|
4754
|
+
self.reasoningPromise.resolve(recordedReasoningText);
|
4744
4755
|
self.stepsPromise.resolve(recordedSteps);
|
4745
4756
|
await (onFinish == null ? void 0 : onFinish({
|
4746
4757
|
finishReason,
|
4747
4758
|
logprobs: void 0,
|
4748
4759
|
usage,
|
4749
4760
|
text: recordedFullText,
|
4761
|
+
reasoning: recordedReasoningText,
|
4750
4762
|
toolCalls: lastStep.toolCalls,
|
4751
4763
|
toolResults: lastStep.toolResults,
|
4752
4764
|
request: (_a15 = lastStep.request) != null ? _a15 : {},
|
@@ -4943,6 +4955,7 @@ var DefaultStreamTextResult = class {
|
|
4943
4955
|
let stepProviderMetadata;
|
4944
4956
|
let stepFirstChunk = true;
|
4945
4957
|
let stepText = "";
|
4958
|
+
let stepReasoning = "";
|
4946
4959
|
let fullStepText = stepType2 === "continue" ? previousStepText : "";
|
4947
4960
|
let stepLogProbs;
|
4948
4961
|
let stepResponse = {
|
@@ -5014,6 +5027,11 @@ var DefaultStreamTextResult = class {
|
|
5014
5027
|
}
|
5015
5028
|
break;
|
5016
5029
|
}
|
5030
|
+
case "reasoning": {
|
5031
|
+
controller.enqueue(chunk);
|
5032
|
+
stepReasoning += chunk.textDelta;
|
5033
|
+
break;
|
5034
|
+
}
|
5017
5035
|
case "tool-call": {
|
5018
5036
|
controller.enqueue(chunk);
|
5019
5037
|
stepToolCalls.push(chunk);
|
@@ -5227,6 +5245,9 @@ var DefaultStreamTextResult = class {
|
|
5227
5245
|
get text() {
|
5228
5246
|
return this.textPromise.value;
|
5229
5247
|
}
|
5248
|
+
get reasoning() {
|
5249
|
+
return this.reasoningPromise.value;
|
5250
|
+
}
|
5230
5251
|
get toolCalls() {
|
5231
5252
|
return this.toolCallsPromise.value;
|
5232
5253
|
}
|
@@ -5319,6 +5340,12 @@ var DefaultStreamTextResult = class {
|
|
5319
5340
|
controller.enqueue(formatDataStreamPart2("text", chunk.textDelta));
|
5320
5341
|
break;
|
5321
5342
|
}
|
5343
|
+
case "reasoning": {
|
5344
|
+
controller.enqueue(
|
5345
|
+
formatDataStreamPart2("reasoning", chunk.textDelta)
|
5346
|
+
);
|
5347
|
+
break;
|
5348
|
+
}
|
5322
5349
|
case "tool-call-streaming-start": {
|
5323
5350
|
controller.enqueue(
|
5324
5351
|
formatDataStreamPart2("tool_call_streaming_start", {
|