New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ai-sdk/ui-utils

Package Overview
Dependencies
Maintainers
2
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/ui-utils - npm Package Compare versions

Comparing version 1.1.11 to 1.1.12

6

CHANGELOG.md
# @ai-sdk/ui-utils
## 1.1.12
### Patch Changes
- 166e09e: feat (ai/ui): forward source parts to useChat
## 1.1.11

@@ -4,0 +10,0 @@

75

dist/index.d.ts

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

import { LanguageModelV1FinishReason, JSONValue as JSONValue$1 } from '@ai-sdk/provider';
import { LanguageModelV1Source, LanguageModelV1FinishReason, JSONValue as JSONValue$1 } from '@ai-sdk/provider';
import { FetchFunction, ToolCall, ToolResult, Validator } from '@ai-sdk/provider-utils';

@@ -153,3 +153,3 @@ export { generateId } from '@ai-sdk/provider-utils';

*/
parts?: Array<TextUIPart | ReasoningUIPart | ToolInvocationUIPart>;
parts?: Array<TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart>;
}

@@ -163,3 +163,3 @@ type UIMessage = Message & {

*/
parts: Array<TextUIPart | ReasoningUIPart | ToolInvocationUIPart>;
parts: Array<TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart>;
};

@@ -196,2 +196,12 @@ /**

};
/**
* A source part of a message.
*/
type SourceUIPart = {
type: 'source';
/**
* The source.
*/
source: LanguageModelV1Source;
};
type CreateMessage = Omit<Message, 'id'> & {

@@ -446,4 +456,4 @@ id?: Message['id'];

}
declare const textStreamPart$1: AssistantStreamPart<'0', 'text', string>;
declare const errorStreamPart$1: AssistantStreamPart<'3', 'error', string>;
declare const textStreamPart: AssistantStreamPart<'0', 'text', string>;
declare const errorStreamPart: AssistantStreamPart<'3', 'error', string>;
declare const assistantMessageStreamPart: AssistantStreamPart<'4', 'assistant_message', AssistantMessage>;

@@ -455,7 +465,7 @@ declare const assistantControlDataStreamPart: AssistantStreamPart<'5', 'assistant_control_data', {

declare const dataMessageStreamPart: AssistantStreamPart<'6', 'data_message', DataMessage>;
type AssistantStreamParts = typeof textStreamPart$1 | typeof errorStreamPart$1 | typeof assistantMessageStreamPart | typeof assistantControlDataStreamPart | typeof dataMessageStreamPart;
type AssistantStreamParts = typeof textStreamPart | typeof errorStreamPart | typeof assistantMessageStreamPart | typeof assistantControlDataStreamPart | typeof dataMessageStreamPart;
type AssistantStreamPartValueType = {
[P in AssistantStreamParts as P['name']]: ReturnType<P['parse']>['value'];
};
type AssistantStreamPartType = ReturnType<typeof textStreamPart$1.parse> | ReturnType<typeof errorStreamPart$1.parse> | ReturnType<typeof assistantMessageStreamPart.parse> | ReturnType<typeof assistantControlDataStreamPart.parse> | ReturnType<typeof dataMessageStreamPart.parse>;
type AssistantStreamPartType = ReturnType<typeof textStreamPart.parse> | ReturnType<typeof errorStreamPart.parse> | ReturnType<typeof assistantMessageStreamPart.parse> | ReturnType<typeof assistantControlDataStreamPart.parse> | ReturnType<typeof dataMessageStreamPart.parse>;
declare const StreamStringPrefixes: {

@@ -521,17 +531,9 @@ readonly text: "0";

}
declare const textStreamPart: DataStreamPart<'0', 'text', string>;
declare const dataStreamPart: DataStreamPart<'2', 'data', Array<JSONValue>>;
declare const errorStreamPart: DataStreamPart<'3', 'error', string>;
declare const messageAnnotationsStreamPart: DataStreamPart<'8', 'message_annotations', Array<JSONValue>>;
declare const toolCallStreamPart: DataStreamPart<'9', 'tool_call', ToolCall<string, any>>;
declare const toolResultStreamPart: DataStreamPart<'a', 'tool_result', Omit<ToolResult<string, any, any>, 'args' | 'toolName'>>;
declare const toolCallStreamingStartStreamPart: DataStreamPart<'b', 'tool_call_streaming_start', {
declare const dataStreamParts: readonly [DataStreamPart<"0", "text", string>, DataStreamPart<"2", "data", JSONValue[]>, DataStreamPart<"3", "error", string>, DataStreamPart<"8", "message_annotations", JSONValue[]>, DataStreamPart<"9", "tool_call", ToolCall<string, any>>, DataStreamPart<"a", "tool_result", Omit<ToolResult<string, any, any>, "args" | "toolName">>, DataStreamPart<"b", "tool_call_streaming_start", {
toolCallId: string;
toolName: string;
}>;
declare const toolCallDeltaStreamPart: DataStreamPart<'c', 'tool_call_delta', {
}>, DataStreamPart<"c", "tool_call_delta", {
toolCallId: string;
argsTextDelta: string;
}>;
declare const finishMessageStreamPart: DataStreamPart<'d', 'finish_message', {
}>, DataStreamPart<"d", "finish_message", {
finishReason: LanguageModelV1FinishReason;

@@ -542,4 +544,3 @@ usage?: {

};
}>;
declare const finishStepStreamPart: DataStreamPart<'e', 'finish_step', {
}>, DataStreamPart<"e", "finish_step", {
isContinued: boolean;

@@ -551,8 +552,6 @@ finishReason: LanguageModelV1FinishReason;

};
}>;
declare const startStepStreamPart: DataStreamPart<'f', 'start_step', {
}>, DataStreamPart<"f", "start_step", {
messageId: string;
}>;
declare const reasoningStreamPart: DataStreamPart<'g', 'reasoning', string>;
type DataStreamParts = typeof textStreamPart | typeof dataStreamPart | typeof errorStreamPart | typeof messageAnnotationsStreamPart | typeof toolCallStreamPart | typeof toolResultStreamPart | typeof toolCallStreamingStartStreamPart | typeof toolCallDeltaStreamPart | typeof finishMessageStreamPart | typeof finishStepStreamPart | typeof startStepStreamPart | typeof reasoningStreamPart;
}>, DataStreamPart<"g", "reasoning", string>, DataStreamPart<"h", "source", LanguageModelV1Source>];
type DataStreamParts = (typeof dataStreamParts)[number];
/**

@@ -564,3 +563,3 @@ * Maps the type of a stream part to its value type.

};
type DataStreamPartType = ReturnType<typeof textStreamPart.parse> | ReturnType<typeof dataStreamPart.parse> | ReturnType<typeof errorStreamPart.parse> | ReturnType<typeof messageAnnotationsStreamPart.parse> | ReturnType<typeof toolCallStreamPart.parse> | ReturnType<typeof toolResultStreamPart.parse> | ReturnType<typeof toolCallStreamingStartStreamPart.parse> | ReturnType<typeof toolCallDeltaStreamPart.parse> | ReturnType<typeof finishMessageStreamPart.parse> | ReturnType<typeof finishStepStreamPart.parse> | ReturnType<typeof startStepStreamPart.parse> | ReturnType<typeof reasoningStreamPart.parse>;
type DataStreamPartType = ReturnType<DataStreamParts['parse']>;
/**

@@ -588,16 +587,3 @@ * The map of prefixes for data in the stream

*/
declare const DataStreamStringPrefixes: {
readonly text: "0";
readonly data: "2";
readonly error: "3";
readonly message_annotations: "8";
readonly tool_call: "9";
readonly tool_result: "a";
readonly tool_call_streaming_start: "b";
readonly tool_call_delta: "c";
readonly finish_message: "d";
readonly finish_step: "e";
readonly start_step: "f";
readonly reasoning: "g";
};
declare const DataStreamStringPrefixes: { [K in DataStreamParts["name"]]: (typeof dataStreamParts)[number]["code"]; };
/**

@@ -645,3 +631,3 @@ Parses a stream part from a string.

declare function getMessageParts(message: Message | CreateMessage | UIMessage): (TextUIPart | ReasoningUIPart | ToolInvocationUIPart)[];
declare function getMessageParts(message: Message | CreateMessage | UIMessage): (TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart)[];

@@ -683,3 +669,3 @@ /**

declare function processDataStream({ stream, onTextPart, onReasoningPart, onDataPart, onErrorPart, onToolCallStreamingStartPart, onToolCallDeltaPart, onToolCallPart, onToolResultPart, onMessageAnnotationsPart, onFinishMessagePart, onFinishStepPart, onStartStepPart, }: {
declare function processDataStream({ stream, onTextPart, onReasoningPart, onSourcePart, onDataPart, onErrorPart, onToolCallStreamingStartPart, onToolCallDeltaPart, onToolCallPart, onToolResultPart, onMessageAnnotationsPart, onFinishMessagePart, onFinishStepPart, onStartStepPart, }: {
stream: ReadableStream<Uint8Array>;

@@ -692,2 +678,5 @@ onTextPart?: (streamPart: (DataStreamPartType & {

})['value']) => Promise<void> | void;
onSourcePart?: (streamPart: (DataStreamPartType & {
type: 'source';
})['value']) => Promise<void> | void;
onDataPart?: (streamPart: (DataStreamPartType & {

@@ -805,2 +794,2 @@ type: 'data';

export { type AssistantMessage, type AssistantStatus, type AssistantStreamPart, type AssistantStreamString, type Attachment, type ChatRequest, type ChatRequestOptions, type CreateMessage, type DataMessage, type DataStreamPart, type DataStreamString, type DeepPartial, type IdGenerator, type JSONValue, type Message, type ReasoningUIPart, type RequestOptions, type Schema, type TextUIPart, type ToolInvocation, type ToolInvocationUIPart, type UIMessage, type UseAssistantOptions, type UseChatOptions, type UseCompletionOptions, asSchema, callChatApi, callCompletionApi, extractMaxToolInvocationStep, fillMessageParts, formatAssistantStreamPart, formatDataStreamPart, getMessageParts, getTextFromDataUrl, isAssistantMessageWithCompletedToolCalls, isDeepEqualData, jsonSchema, parseAssistantStreamPart, parseDataStreamPart, parsePartialJson, prepareAttachmentsForRequest, processAssistantStream, processDataStream, processTextStream, shouldResubmitMessages, updateToolCallResult, zodSchema };
export { type AssistantMessage, type AssistantStatus, type AssistantStreamPart, type AssistantStreamString, type Attachment, type ChatRequest, type ChatRequestOptions, type CreateMessage, type DataMessage, type DataStreamPart, type DataStreamString, type DeepPartial, type IdGenerator, type JSONValue, type Message, type ReasoningUIPart, type RequestOptions, type Schema, type SourceUIPart, type TextUIPart, type ToolInvocation, type ToolInvocationUIPart, type UIMessage, type UseAssistantOptions, type UseChatOptions, type UseCompletionOptions, asSchema, callChatApi, callCompletionApi, extractMaxToolInvocationStep, fillMessageParts, formatAssistantStreamPart, formatDataStreamPart, getMessageParts, getTextFromDataUrl, isAssistantMessageWithCompletedToolCalls, isDeepEqualData, jsonSchema, parseAssistantStreamPart, parseDataStreamPart, parsePartialJson, prepareAttachmentsForRequest, processAssistantStream, processDataStream, processTextStream, shouldResubmitMessages, updateToolCallResult, zodSchema };

@@ -708,2 +708,15 @@ "use strict";

};
var sourcePart = {
code: "h",
name: "source",
parse: (value) => {
if (value == null || typeof value !== "object") {
throw new Error('"source" parts expect a Source object.');
}
return {
type: "source",
value
};
}
};
var dataStreamParts = [

@@ -721,32 +734,11 @@ textStreamPart2,

startStepStreamPart,
reasoningStreamPart
reasoningStreamPart,
sourcePart
];
var dataStreamPartsByCode = {
[textStreamPart2.code]: textStreamPart2,
[dataStreamPart.code]: dataStreamPart,
[errorStreamPart2.code]: errorStreamPart2,
[messageAnnotationsStreamPart.code]: messageAnnotationsStreamPart,
[toolCallStreamPart.code]: toolCallStreamPart,
[toolResultStreamPart.code]: toolResultStreamPart,
[toolCallStreamingStartStreamPart.code]: toolCallStreamingStartStreamPart,
[toolCallDeltaStreamPart.code]: toolCallDeltaStreamPart,
[finishMessageStreamPart.code]: finishMessageStreamPart,
[finishStepStreamPart.code]: finishStepStreamPart,
[startStepStreamPart.code]: startStepStreamPart,
[reasoningStreamPart.code]: reasoningStreamPart
};
var DataStreamStringPrefixes = {
[textStreamPart2.name]: textStreamPart2.code,
[dataStreamPart.name]: dataStreamPart.code,
[errorStreamPart2.name]: errorStreamPart2.code,
[messageAnnotationsStreamPart.name]: messageAnnotationsStreamPart.code,
[toolCallStreamPart.name]: toolCallStreamPart.code,
[toolResultStreamPart.name]: toolResultStreamPart.code,
[toolCallStreamingStartStreamPart.name]: toolCallStreamingStartStreamPart.code,
[toolCallDeltaStreamPart.name]: toolCallDeltaStreamPart.code,
[finishMessageStreamPart.name]: finishMessageStreamPart.code,
[finishStepStreamPart.name]: finishStepStreamPart.code,
[startStepStreamPart.name]: startStepStreamPart.code,
[reasoningStreamPart.name]: reasoningStreamPart.code
};
var dataStreamPartsByCode = Object.fromEntries(
dataStreamParts.map((part) => [part.code, part])
);
var DataStreamStringPrefixes = Object.fromEntries(
dataStreamParts.map((part) => [part.name, part.code])
);
var validCodes2 = dataStreamParts.map((part) => part.code);

@@ -792,2 +784,3 @@ var parseDataStreamPart = (line) => {

onReasoningPart,
onSourcePart,
onDataPart,

@@ -831,2 +824,5 @@ onErrorPart,

break;
case "source":
await (onSourcePart == null ? void 0 : onSourcePart(value2));
break;
case "data":

@@ -970,2 +966,9 @@ await (onDataPart == null ? void 0 : onDataPart(value2));

},
onSourcePart(value) {
message.parts.push({
type: "source",
source: value
});
execUpdate();
},
onToolCallStreamingStartPart(value) {

@@ -972,0 +975,0 @@ if (message.toolInvocations == null) {

{
"name": "@ai-sdk/ui-utils",
"version": "1.1.11",
"version": "1.1.12",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "sideEffects": false,

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc