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

ai

Package Overview
Dependencies
Maintainers
5
Versions
1315
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
6.0.214
to
6.0.215
+1
-1
dist/internal/index.js

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

// src/version.ts
var VERSION = true ? "6.0.214" : "0.0.0-test";
var VERSION = true ? "6.0.215" : "0.0.0-test";

@@ -158,0 +158,0 @@ // src/util/download/download.ts

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

// src/version.ts
var VERSION = true ? "6.0.214" : "0.0.0-test";
var VERSION = true ? "6.0.215" : "0.0.0-test";

@@ -138,0 +138,0 @@ // src/util/download/download.ts

{
"name": "ai",
"version": "6.0.214",
"version": "6.0.215",
"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.",

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

@@ -103,2 +103,40 @@ import type {

// Build global maps from tool call id and approval id to tool name.
// These must be global (not per-message) because a `tool-approval-response`
// lives in a separate `tool` message from its `tool-approval-request`
// (assistant message), so the tool name of a response can only be resolved
// by looking across messages. Resolving names per-message left responses
// unresolved, which caused them to be kept while their request was pruned,
// producing orphaned approval responses.
const toolCallIdToToolName = new Map<string, string>();
for (const message of messages) {
if (
(message.role === 'assistant' || message.role === 'tool') &&
typeof message.content !== 'string'
) {
for (const part of message.content) {
if (part.type === 'tool-call' || part.type === 'tool-result') {
toolCallIdToToolName.set(part.toolCallId, part.toolName);
}
}
}
}
const approvalIdToToolName = new Map<string, string>();
for (const message of messages) {
if (
(message.role === 'assistant' || message.role === 'tool') &&
typeof message.content !== 'string'
) {
for (const part of message.content) {
if (part.type === 'tool-approval-request') {
const toolName = toolCallIdToToolName.get(part.toolCallId);
if (toolName != null) {
approvalIdToToolName.set(part.approvalId, toolName);
}
}
}
}
}
messages = messages.map((message, messageIndex) => {

@@ -114,5 +152,2 @@ if (

const toolCallIdToToolName: Record<string, string> = {};
const approvalIdToToolName: Record<string, string> = {};
return {

@@ -131,10 +166,2 @@ ...message,

// track tool calls and approvals:
if (part.type === 'tool-call') {
toolCallIdToToolName[part.toolCallId] = part.toolName;
} else if (part.type === 'tool-approval-request') {
approvalIdToToolName[part.approvalId] =
toolCallIdToToolName[part.toolCallId];
}
// keep parts that are associated with a tool call or approval that needs to be kept:

@@ -152,9 +179,11 @@ if (

// keep parts that are not associated with a tool that should be removed:
const partToolName =
part.type === 'tool-call' || part.type === 'tool-result'
? part.toolName
: approvalIdToToolName.get(part.approvalId);
return (
toolCall.tools != null &&
!toolCall.tools.includes(
part.type === 'tool-call' || part.type === 'tool-result'
? part.toolName
: approvalIdToToolName[part.approvalId],
)
partToolName != null &&
!toolCall.tools.includes(partToolName)
);

@@ -161,0 +190,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