🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

ai

Package Overview
Dependencies
Maintainers
5
Versions
1321
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.11
to
7.0.12
+3
-3
package.json
{
"name": "ai",
"version": "7.0.11",
"version": "7.0.12",
"type": "module",

@@ -45,5 +45,5 @@ "description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",

"dependencies": {
"@ai-sdk/gateway": "4.0.8",
"@ai-sdk/gateway": "4.0.9",
"@ai-sdk/provider": "4.0.1",
"@ai-sdk/provider-utils": "5.0.3"
"@ai-sdk/provider-utils": "5.0.4"
},

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

@@ -22,2 +22,3 @@ import type {

const responseMessages: Array<AssistantModelMessage | ToolModelMessage> = [];
const toolCallOrder = new Map<string, number>();

@@ -83,2 +84,5 @@ const content: AssistantContent = [];

case 'tool-call':
if (!toolCallOrder.has(part.toolCallId)) {
toolCallOrder.set(part.toolCallId, toolCallOrder.size);
}
content.push({

@@ -209,3 +213,6 @@ type: 'tool-call',

role: 'tool',
content: toolResultContent,
content: sortToolResultContentByToolCallOrder({
toolResultContent,
toolCallOrder,
}),
});

@@ -216,1 +223,38 @@ }

}
function sortToolResultContentByToolCallOrder({
toolResultContent,
toolCallOrder,
}: {
toolResultContent: ToolContent;
toolCallOrder: Map<string, number>;
}): ToolContent {
const sortedToolResults = toolResultContent
.filter(part => part.type === 'tool-result')
.map((part, index) => ({ part, index }))
.sort((a, b) => {
const aOrder = toolCallOrder.get(a.part.toolCallId);
const bOrder = toolCallOrder.get(b.part.toolCallId);
if (aOrder == null && bOrder == null) {
return a.index - b.index;
}
if (aOrder == null) {
return 1;
}
if (bOrder == null) {
return -1;
}
return aOrder - bOrder || a.index - b.index;
})
.map(({ part }) => part);
let toolResultIndex = 0;
return toolResultContent.map(part =>
part.type === 'tool-result' ? sortedToolResults[toolResultIndex++] : part,
);
}

@@ -18,2 +18,6 @@ import type {

function stripMarkdownCodeFenceSuffix(text: string): string {
return text.replace(/\n?```\s*$/, '').trimEnd();
}
/**

@@ -173,6 +177,11 @@ * Middleware that extracts JSON from text content by stripping

// strip suffix since prefix already handled
remaining = remaining.replace(/\n?```\s*$/, '').trimEnd();
remaining = stripMarkdownCodeFenceSuffix(remaining);
} else if (block.phase === 'prefix') {
// No text has streamed yet, so the full transform is safe.
remaining = transform(remaining);
} else {
// Apply full transform (handles both prefix and suffix)
remaining = transform(remaining);
// Only strip the suffix. Since earlier text may already have
// streamed, trimming the remaining suffix would remove valid
// leading whitespace at the stream boundary.
remaining = stripMarkdownCodeFenceSuffix(remaining);
}

@@ -179,0 +188,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 not supported yet

Sorry, the diff of this file is not supported yet