You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

ai

Package Overview
Dependencies
Maintainers
5
Versions
1019
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ai - npm Package Compare versions

Comparing version
7.0.0-beta.18
to
7.0.0-beta.19
+19
-1
dist/internal/index.js

@@ -156,3 +156,3 @@ "use strict";

// src/version.ts
var VERSION = true ? "7.0.0-beta.18" : "0.0.0-test";
var VERSION = true ? "7.0.0-beta.19" : "0.0.0-test";

@@ -493,2 +493,13 @@ // src/util/download/download.ts

}
case "reasoning-file": {
const { data, mediaType } = convertToLanguageModelV4DataContent(
part.data
);
return {
type: "reasoning-file",
data,
mediaType: mediaType != null ? mediaType : part.mediaType,
providerOptions
};
}
case "text": {

@@ -797,2 +808,8 @@ return {

});
var reasoningFilePartSchema = import_v44.z.object({
type: import_v44.z.literal("reasoning-file"),
data: import_v44.z.union([dataContentSchema, import_v44.z.instanceof(URL)]),
mediaType: import_v44.z.string(),
providerOptions: providerMetadataSchema.optional()
});
var toolCallPartSchema = import_v44.z.object({

@@ -934,2 +951,3 @@ type: import_v44.z.literal("tool-call"),

reasoningPartSchema,
reasoningFilePartSchema,
toolCallPartSchema,

@@ -936,0 +954,0 @@ toolResultPartSchema,

@@ -136,3 +136,3 @@ // internal/index.ts

// src/version.ts
var VERSION = true ? "7.0.0-beta.18" : "0.0.0-test";
var VERSION = true ? "7.0.0-beta.19" : "0.0.0-test";

@@ -476,2 +476,13 @@ // src/util/download/download.ts

}
case "reasoning-file": {
const { data, mediaType } = convertToLanguageModelV4DataContent(
part.data
);
return {
type: "reasoning-file",
data,
mediaType: mediaType != null ? mediaType : part.mediaType,
providerOptions
};
}
case "text": {

@@ -782,2 +793,8 @@ return {

});
var reasoningFilePartSchema = z4.object({
type: z4.literal("reasoning-file"),
data: z4.union([dataContentSchema, z4.instanceof(URL)]),
mediaType: z4.string(),
providerOptions: providerMetadataSchema.optional()
});
var toolCallPartSchema = z4.object({

@@ -919,2 +936,3 @@ type: z4.literal("tool-call"),

reasoningPartSchema,
reasoningFilePartSchema,
toolCallPartSchema,

@@ -921,0 +939,0 @@ toolResultPartSchema,

+4
-4
{
"name": "ai",
"version": "7.0.0-beta.18",
"version": "7.0.0-beta.19",
"description": "AI SDK by Vercel - The AI Toolkit for TypeScript and JavaScript",

@@ -48,5 +48,5 @@ "license": "Apache-2.0",

"@opentelemetry/api": "1.9.0",
"@ai-sdk/gateway": "4.0.0-beta.11",
"@ai-sdk/provider": "4.0.0-beta.1",
"@ai-sdk/provider-utils": "5.0.0-beta.2"
"@ai-sdk/gateway": "4.0.0-beta.12",
"@ai-sdk/provider": "4.0.0-beta.2",
"@ai-sdk/provider-utils": "5.0.0-beta.3"
},

@@ -53,0 +53,0 @@ "devDependencies": {

@@ -5,3 +5,3 @@ import { ProviderMetadata } from '../types';

import { ToolApprovalRequestOutput } from './tool-approval-request-output';
import { ReasoningOutput } from './reasoning-output';
import { ReasoningOutput, ReasoningFileOutput } from './reasoning-output';
import { TypedToolCall } from './tool-call';

@@ -15,4 +15,5 @@ import { TypedToolError } from './tool-error';

| ReasoningOutput
| ReasoningFileOutput
| ({ type: 'source' } & Source)
| { type: 'file'; file: GeneratedFile; providerMetadata?: ProviderMetadata } // different because of GeneratedFile object
| { type: 'file'; file: GeneratedFile; providerMetadata?: ProviderMetadata }
| ({ type: 'tool-call' } & TypedToolCall<TOOLS> & {

@@ -19,0 +20,0 @@ providerMetadata?: ProviderMetadata;

@@ -10,3 +10,3 @@ import { CallWarning, FinishReason, ProviderMetadata } from '../types';

import { InferCompleteOutput } from './output-utils';
import { ReasoningOutput } from './reasoning-output';
import { ReasoningOutput, ReasoningFileOutput } from './reasoning-output';
import { ResponseMessage } from './response-message';

@@ -43,3 +43,3 @@ import { StepResult } from './step-result';

*/
readonly reasoning: Array<ReasoningOutput>;
readonly reasoning: Array<ReasoningOutput | ReasoningFileOutput>;

@@ -46,0 +46,0 @@ /**

@@ -66,2 +66,3 @@ import {

import { DefaultGeneratedFile } from './generated-file';
import { convertToReasoningOutputs } from './reasoning-output';
import { isApprovalNeeded } from './is-approval-needed';

@@ -1187,3 +1188,3 @@ import { Output, text } from './output';

get reasoning() {
return this.finalStep.reasoning;
return convertToReasoningOutputs(this.finalStep.reasoning);
}

@@ -1283,5 +1284,6 @@

case 'file': {
case 'file':
case 'reasoning-file': {
contentParts.push({
type: 'file' as const,
type: part.type as 'file' | 'reasoning-file',
file: new DefaultGeneratedFile(part),

@@ -1288,0 +1290,0 @@ ...(part.providerMetadata != null

@@ -24,3 +24,3 @@ export {

export { pruneMessages } from './prune-messages';
export type { ReasoningOutput } from './reasoning-output';
export type { ReasoningFileOutput, ReasoningOutput } from './reasoning-output';
export { smoothStream, type ChunkDetector } from './smooth-stream';

@@ -27,0 +27,0 @@ export type { StepResult } from './step-result';

@@ -0,2 +1,4 @@

import { ReasoningFilePart, ReasoningPart } from '@ai-sdk/provider-utils';
import { ProviderMetadata } from '../types/provider-metadata';
import { DefaultGeneratedFile, GeneratedFile } from './generated-file';

@@ -21,1 +23,78 @@ /**

}
/**
* Reasoning file output of a text generation.
* It contains a file generated as part of reasoning.
*/
export interface ReasoningFileOutput {
type: 'reasoning-file';
/**
* The generated file.
*/
file: GeneratedFile;
/**
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerMetadata?: ProviderMetadata;
}
export function convertFromReasoningOutputs(
parts: Array<ReasoningOutput | ReasoningFileOutput>,
): Array<ReasoningPart | ReasoningFilePart> {
return parts.map(part => {
if (part.type === 'reasoning') {
return {
type: 'reasoning' as const,
text: part.text,
...(part.providerMetadata != null
? { providerOptions: part.providerMetadata }
: {}),
};
}
return {
type: 'reasoning-file' as const,
data: part.file.base64,
mediaType: part.file.mediaType,
...(part.providerMetadata != null
? { providerOptions: part.providerMetadata }
: {}),
};
});
}
export function convertToReasoningOutputs(
parts: Array<ReasoningPart | ReasoningFilePart>,
): Array<ReasoningOutput | ReasoningFileOutput> {
return parts.map(part => {
if (part.type === 'reasoning') {
return {
type: 'reasoning' as const,
text: part.text,
...(part.providerOptions != null
? { providerMetadata: part.providerOptions as ProviderMetadata }
: {}),
};
}
return {
type: 'reasoning-file' as const,
file: new DefaultGeneratedFile({
data:
part.data instanceof ArrayBuffer
? new Uint8Array(part.data)
: part.data instanceof URL
? part.data.toString()
: part.data,
mediaType: part.mediaType,
}),
...(part.providerOptions != null
? { providerMetadata: part.providerOptions as ProviderMetadata }
: {}),
};
});
}

@@ -1,8 +0,10 @@

import { ReasoningPart } from '@ai-sdk/provider-utils';
import { ReasoningPart, ReasoningFilePart } from '@ai-sdk/provider-utils';
export function asReasoningText(
reasoningParts: Array<ReasoningPart>,
reasoningParts: Array<ReasoningPart | ReasoningFilePart>,
): string | undefined {
const reasoningText = reasoningParts.map(part => part.text).join('');
const reasoningText = reasoningParts
.map(part => ('text' in part ? part.text : ''))
.join('');
return reasoningText.length > 0 ? reasoningText : undefined;
}

@@ -90,3 +90,8 @@ import { LanguageModelV4StreamPart, SharedV4Warning } from '@ai-sdk/provider';

| ({ type: 'source' } & Source)
| { type: 'file'; file: GeneratedFile; providerMetadata?: ProviderMetadata } // different because of GeneratedFile object
| { type: 'file'; file: GeneratedFile; providerMetadata?: ProviderMetadata }
| {
type: 'reasoning-file';
file: GeneratedFile;
providerMetadata?: ProviderMetadata;
}
| ({ type: 'tool-call' } & TypedToolCall<TOOLS>)

@@ -222,5 +227,6 @@ | ({ type: 'tool-result' } & TypedToolResult<TOOLS>)

case 'file': {
case 'file':
case 'reasoning-file': {
controller.enqueue({
type: 'file',
type: chunk.type,
file: new DefaultGeneratedFileWithType({

@@ -227,0 +233,0 @@ data: chunk.data,

@@ -1,3 +0,9 @@

import { ReasoningPart } from '@ai-sdk/provider-utils';
import { ReasoningPart, ReasoningFilePart } from '@ai-sdk/provider-utils';
import { asReasoningText } from './reasoning';
import {
ReasoningOutput,
ReasoningFileOutput,
convertFromReasoningOutputs,
} from './reasoning-output';
import {
CallWarning,

@@ -76,3 +82,3 @@ FinishReason,

*/
readonly reasoning: Array<ReasoningPart>;
readonly reasoning: Array<ReasoningPart | ReasoningFilePart>;

@@ -246,10 +252,13 @@ /**

get reasoning() {
return this.content.filter(part => part.type === 'reasoning');
get reasoning(): Array<ReasoningPart | ReasoningFilePart> {
return convertFromReasoningOutputs(
this.content.filter(
(part): part is ReasoningOutput | ReasoningFileOutput =>
part.type === 'reasoning' || part.type === 'reasoning-file',
),
);
}
get reasoningText() {
return this.reasoning.length === 0
? undefined
: this.reasoning.map(part => part.text).join('');
return asReasoningText(this.reasoning);
}

@@ -256,0 +265,0 @@

@@ -26,3 +26,3 @@ import { IdGenerator } from '@ai-sdk/provider-utils';

} from './output-utils';
import { ReasoningOutput } from './reasoning-output';
import { ReasoningOutput, ReasoningFileOutput } from './reasoning-output';
import { ResponseMessage } from './response-message';

@@ -133,3 +133,3 @@ import { StepResult } from './step-result';

*/
readonly reasoning: PromiseLike<Array<ReasoningOutput>>;
readonly reasoning: PromiseLike<Array<ReasoningOutput | ReasoningFileOutput>>;

@@ -426,3 +426,8 @@ /**

| ({ type: 'source' } & Source)
| { type: 'file'; file: GeneratedFile; providerMetadata?: ProviderMetadata } // different because of GeneratedFile object
| { type: 'file'; file: GeneratedFile; providerMetadata?: ProviderMetadata }
| {
type: 'reasoning-file';
file: GeneratedFile;
providerMetadata?: ProviderMetadata;
}
| ({ type: 'tool-call' } & TypedToolCall<TOOLS>)

@@ -429,0 +434,0 @@ | ({ type: 'tool-result' } & TypedToolResult<TOOLS>)

@@ -66,2 +66,10 @@ import {

break;
case 'reasoning-file':
content.push({
type: 'reasoning-file',
data: part.file.base64,
mediaType: part.file.mediaType,
providerOptions: part.providerMetadata,
});
break;
case 'tool-call':

@@ -68,0 +76,0 @@ content.push({

@@ -5,2 +5,3 @@ import {

ProviderOptions,
ReasoningFilePart,
ReasoningPart,

@@ -58,2 +59,12 @@ TextPart,

/**
* @internal
*/
export const reasoningFilePartSchema: z.ZodType<ReasoningFilePart> = z.object({
type: z.literal('reasoning-file'),
data: z.union([dataContentSchema, z.instanceof(URL)]),
mediaType: z.string(),
providerOptions: providerMetadataSchema.optional(),
});
/**
* Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).

@@ -60,0 +71,0 @@ */

@@ -14,2 +14,3 @@ import {

ModelMessage,
ReasoningFilePart,
ReasoningPart,

@@ -239,2 +240,3 @@ TextPart,

| ReasoningPart
| ReasoningFilePart
| ToolCallPart

@@ -266,2 +268,13 @@ | ToolResultPart => part.type !== 'tool-approval-request',

}
case 'reasoning-file': {
const { data, mediaType } = convertToLanguageModelV4DataContent(
part.data,
);
return {
type: 'reasoning-file' as const,
data,
mediaType: mediaType ?? part.mediaType,
providerOptions,
};
}
case 'text': {

@@ -268,0 +281,0 @@ return {

@@ -13,2 +13,3 @@ import {

imagePartSchema,
reasoningFilePartSchema,
reasoningPartSchema,

@@ -49,2 +50,3 @@ textPartSchema,

reasoningPartSchema,
reasoningFilePartSchema,
toolCallPartSchema,

@@ -51,0 +53,0 @@ toolResultPartSchema,

@@ -366,3 +366,6 @@ import { LanguageModelV3Prompt } from '@ai-sdk/provider';

event.reasoning.length > 0
? event.reasoning.map(part => part.text).join('\n')
? event.reasoning
.filter(part => 'text' in part)
.map(part => part.text)
.join('\n')
: undefined,

@@ -433,3 +436,6 @@ },

event.reasoning.length > 0
? event.reasoning.map(part => part.text).join('\n')
? event.reasoning
.filter(part => 'text' in part)
.map(part => part.text)
.join('\n')
: undefined,

@@ -436,0 +442,0 @@ },

@@ -138,2 +138,8 @@ import { z } from 'zod/v4';

z.strictObject({
type: z.literal('reasoning-file'),
url: z.string(),
mediaType: z.string(),
providerMetadata: providerMetadataSchema.optional(),
}),
z.strictObject({
type: z.custom<`data-${string}`>(

@@ -316,2 +322,8 @@ (value): value is `data-${string}` =>

}
| {
type: 'reasoning-file';
url: string;
mediaType: string;
providerMetadata?: ProviderMetadata;
}
| DataUIMessageChunk<DATA_TYPES>

@@ -318,0 +330,0 @@ | {

@@ -22,3 +22,5 @@ import {

isFileUIPart,
isReasoningFileUIPart,
isReasoningUIPart,
ReasoningFileUIPart,
isTextUIPart,

@@ -140,2 +142,3 @@ isToolUIPart,

| FileUIPart
| ReasoningFileUIPart
| DynamicToolUIPart

@@ -171,2 +174,9 @@ | DataUIPart<InferUIMessageData<UI_MESSAGE>>

});
} else if (isReasoningFileUIPart(part)) {
content.push({
type: 'reasoning-file' as const,
data: part.url,
mediaType: part.mediaType,
providerOptions: part.providerMetadata,
});
} else if (isReasoningUIPart(part)) {

@@ -353,2 +363,3 @@ content.push({

isReasoningUIPart(part) ||
isReasoningFileUIPart(part) ||
isFileUIPart(part) ||

@@ -355,0 +366,0 @@ isToolUIPart(part) ||

@@ -41,2 +41,3 @@ export { callCompletionApi } from './call-completion-api';

isFileUIPart,
isReasoningFileUIPart,
isReasoningUIPart,

@@ -52,2 +53,3 @@ isStaticToolUIPart,

type InferUITools,
type ReasoningFileUIPart,
type ReasoningUIPart,

@@ -54,0 +56,0 @@ type SourceDocumentUIPart,

@@ -454,5 +454,6 @@ import { TypeValidationContext } from '@ai-sdk/provider';

case 'file': {
case 'file':
case 'reasoning-file': {
state.message.parts.push({
type: 'file',
type: chunk.type,
mediaType: chunk.mediaType,

@@ -459,0 +460,0 @@ url: chunk.url,

@@ -86,2 +86,3 @@ import {

| FileUIPart
| ReasoningFileUIPart
| DataUIPart<DATA_TYPES>

@@ -188,2 +189,27 @@ | StepStartUIPart;

/**
* A reasoning file part of a message.
*/
export type ReasoningFileUIPart = {
type: 'reasoning-file';
/**
* IANA media type of the file.
*
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
mediaType: string;
/**
* The URL of the file.
* It can either be a URL to a hosted file or a [Data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs).
*/
url: string;
/**
* The provider metadata.
*/
providerMetadata?: ProviderMetadata;
};
/**
* A step boundary part of a message.

@@ -440,2 +466,11 @@ */

/**
* Type guard to check if a message part is a reasoning file part.
*/
export function isReasoningFileUIPart(
part: UIMessagePart<UIDataTypes, UITools>,
): part is ReasoningFileUIPart {
return part.type === 'reasoning-file';
}
/**
* Type guard to check if a message part is a reasoning part.

@@ -442,0 +477,0 @@ */

@@ -67,2 +67,8 @@ import { TypeValidationContext, TypeValidationError } from '@ai-sdk/provider';

z.object({
type: z.literal('reasoning-file'),
mediaType: z.string(),
url: z.string(),
providerMetadata: providerMetadataSchema.optional(),
}),
z.object({
type: z.literal('step-start'),

@@ -69,0 +75,0 @@ }),

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display