@assistant-ui/react-ai-sdk 1.3.26 → 1.3.27
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/dist/frontendTools.d.ts +9 -5
- package/dist/frontendTools.d.ts.map +1 -1
- package/dist/frontendTools.js +36 -35
- package/dist/frontendTools.js.map +1 -1
- package/dist/index.d.ts +9 -11
- package/dist/index.js +9 -10
- package/dist/injectQuoteContext.d.ts +6 -2
- package/dist/injectQuoteContext.d.ts.map +1 -1
- package/dist/injectQuoteContext.js +46 -53
- package/dist/injectQuoteContext.js.map +1 -1
- package/dist/modelContentEnvelope.d.ts +12 -10
- package/dist/modelContentEnvelope.d.ts.map +1 -1
- package/dist/modelContentEnvelope.js +17 -15
- package/dist/modelContentEnvelope.js.map +1 -1
- package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts +141 -0
- package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts.map +1 -0
- package/dist/packages/assistant-stream/dist/core/AssistantStream.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/AssistantStreamChunk.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/accumulators/AssistantMessageStream.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/accumulators/assistant-message-accumulator.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/modules/assistant-stream.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/modules/text.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/modules/tool-call.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/serialization/PlainText.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/serialization/assistant-transport/AssistantTransport.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/serialization/data-stream/DataStream.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/serialization/ui-message-stream/UIMessageStream.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/tool/ToolExecutionStream.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/tool/schema-utils.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/tool/schema-utils.js +50 -0
- package/dist/packages/assistant-stream/dist/core/tool/schema-utils.js.map +1 -0
- package/dist/packages/assistant-stream/dist/core/tool/tool-types.d.ts +43 -0
- package/dist/packages/assistant-stream/dist/core/tool/tool-types.d.ts.map +1 -0
- package/dist/packages/assistant-stream/dist/core/tool/toolResultStream.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/utils/stream/AssistantMetaTransformStream.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/utils/stream/AssistantTransformStream.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/core/utils/types.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/index.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/resumable/createResumableAssistantStreamResponse.d.ts +6 -0
- package/dist/packages/assistant-stream/dist/resumable/createResumableAssistantStreamResponse.d.ts.map +1 -0
- package/dist/packages/assistant-stream/dist/resumable/createResumableAssistantStreamResponse.js +6 -0
- package/dist/packages/assistant-stream/dist/resumable/createResumableAssistantStreamResponse.js.map +1 -0
- package/dist/packages/assistant-stream/dist/resumable/index.d.ts +1 -0
- package/dist/packages/assistant-stream/dist/utils/json/json-value.d.ts +10 -0
- package/dist/packages/assistant-stream/dist/utils/json/json-value.d.ts.map +1 -0
- package/dist/packages/assistant-stream/dist/utils.d.ts +1 -0
- package/dist/ui/adapters/aiSDKFormatAdapter.d.ts +8 -4
- package/dist/ui/adapters/aiSDKFormatAdapter.d.ts.map +1 -1
- package/dist/ui/adapters/aiSDKFormatAdapter.js +24 -20
- package/dist/ui/adapters/aiSDKFormatAdapter.js.map +1 -1
- package/dist/ui/getVercelAIMessages.d.ts +7 -3
- package/dist/ui/getVercelAIMessages.d.ts.map +1 -1
- package/dist/ui/getVercelAIMessages.js +7 -3
- package/dist/ui/getVercelAIMessages.js.map +1 -1
- package/dist/ui/resumable.d.ts +18 -15
- package/dist/ui/resumable.d.ts.map +1 -1
- package/dist/ui/resumable.js +21 -20
- package/dist/ui/resumable.js.map +1 -1
- package/dist/ui/use-chat/AssistantChatTransport.d.ts +17 -14
- package/dist/ui/use-chat/AssistantChatTransport.d.ts.map +1 -1
- package/dist/ui/use-chat/AssistantChatTransport.js +98 -108
- package/dist/ui/use-chat/AssistantChatTransport.js.map +1 -1
- package/dist/ui/use-chat/useAISDKRuntime.d.ts +43 -33
- package/dist/ui/use-chat/useAISDKRuntime.d.ts.map +1 -1
- package/dist/ui/use-chat/useAISDKRuntime.js +176 -204
- package/dist/ui/use-chat/useAISDKRuntime.js.map +1 -1
- package/dist/ui/use-chat/useChatRuntime.d.ts +19 -12
- package/dist/ui/use-chat/useChatRuntime.d.ts.map +1 -1
- package/dist/ui/use-chat/useChatRuntime.js +60 -81
- package/dist/ui/use-chat/useChatRuntime.js.map +1 -1
- package/dist/ui/use-chat/useExternalHistory.d.ts +8 -4
- package/dist/ui/use-chat/useExternalHistory.d.ts.map +1 -1
- package/dist/ui/use-chat/useExternalHistory.js +178 -200
- package/dist/ui/use-chat/useExternalHistory.js.map +1 -1
- package/dist/ui/use-chat/useStreamingTiming.d.ts +7 -3
- package/dist/ui/use-chat/useStreamingTiming.d.ts.map +1 -1
- package/dist/ui/use-chat/useStreamingTiming.js +60 -75
- package/dist/ui/use-chat/useStreamingTiming.js.map +1 -1
- package/dist/ui/utils/convertMessage.d.ts +29 -20
- package/dist/ui/utils/convertMessage.d.ts.map +1 -1
- package/dist/ui/utils/convertMessage.js +219 -299
- package/dist/ui/utils/convertMessage.js.map +1 -1
- package/dist/ui/utils/sliceMessagesUntil.d.ts +6 -2
- package/dist/ui/utils/sliceMessagesUntil.d.ts.map +1 -1
- package/dist/ui/utils/sliceMessagesUntil.js +10 -10
- package/dist/ui/utils/sliceMessagesUntil.js.map +1 -1
- package/dist/ui/utils/toCreateMessage.d.ts +7 -3
- package/dist/ui/utils/toCreateMessage.d.ts.map +1 -1
- package/dist/ui/utils/toCreateMessage.js +34 -38
- package/dist/ui/utils/toCreateMessage.js.map +1 -1
- package/dist/ui/utils/vercelAttachmentAdapter.d.ts +6 -2
- package/dist/ui/utils/vercelAttachmentAdapter.d.ts.map +1 -1
- package/dist/ui/utils/vercelAttachmentAdapter.js +37 -35
- package/dist/ui/utils/vercelAttachmentAdapter.js.map +1 -1
- package/dist/usage.d.ts +15 -12
- package/dist/usage.d.ts.map +1 -1
- package/dist/usage.js +80 -99
- package/dist/usage.js.map +1 -1
- package/package.json +11 -11
- package/src/ui/use-chat/useAISDKRuntime.test.ts +2 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region ../assistant-stream/dist/core/tool/schema-utils.js
|
|
2
|
+
function isStandardSchema(schema) {
|
|
3
|
+
return typeof schema === "object" && schema !== null && "~standard" in schema && typeof schema["~standard"] === "object";
|
|
4
|
+
}
|
|
5
|
+
function hasToJSONSchemaMethod(schema) {
|
|
6
|
+
return typeof schema === "object" && schema !== null && "toJSONSchema" in schema && typeof schema.toJSONSchema === "function";
|
|
7
|
+
}
|
|
8
|
+
function hasToJSONMethod(schema) {
|
|
9
|
+
return typeof schema === "object" && schema !== null && "toJSON" in schema && typeof schema.toJSON === "function";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Converts a schema to JSONSchema7.
|
|
13
|
+
* Supports:
|
|
14
|
+
* - StandardSchemaV1 with ~standard.toJSONSchema (e.g., Zod v4)
|
|
15
|
+
* - StandardSchemaV1 with ~standard.jsonSchema.input() (e.g., Zod v4)
|
|
16
|
+
* - Objects with toJSONSchema() method (e.g., Zod v4)
|
|
17
|
+
* - Objects with toJSON() method
|
|
18
|
+
* - Plain JSONSchema7 objects (must have a "type" property)
|
|
19
|
+
*/
|
|
20
|
+
function toJSONSchema(schema) {
|
|
21
|
+
if (isStandardSchema(schema)) {
|
|
22
|
+
const toJSONSchemaMethod = schema["~standard"].toJSONSchema;
|
|
23
|
+
if (typeof toJSONSchemaMethod === "function") return toJSONSchemaMethod();
|
|
24
|
+
const jsonSchema = schema["~standard"].jsonSchema;
|
|
25
|
+
if (typeof jsonSchema === "object" && jsonSchema !== null && typeof jsonSchema.input === "function") return jsonSchema.input();
|
|
26
|
+
}
|
|
27
|
+
if (hasToJSONSchemaMethod(schema)) return schema.toJSONSchema();
|
|
28
|
+
if (hasToJSONMethod(schema)) return schema.toJSON();
|
|
29
|
+
if (isStandardSchema(schema)) throw new Error("Could not convert schema to JSON Schema. The schema implements Standard Schema but does not support JSON Schema conversion. If you are using Zod, please upgrade to Zod v4 (npm install zod@latest). Alternatively, pass a plain JSON Schema object instead.");
|
|
30
|
+
return schema;
|
|
31
|
+
}
|
|
32
|
+
function defaultToolFilter(_name, tool) {
|
|
33
|
+
return !tool.disabled && tool.type !== "backend";
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Converts a record of tools to a record of tool definitions with JSON Schema parameters.
|
|
37
|
+
* By default, filters out disabled tools and backend tools.
|
|
38
|
+
*/
|
|
39
|
+
function toToolsJSONSchema(tools, options = {}) {
|
|
40
|
+
if (!tools) return {};
|
|
41
|
+
const filter = options.filter ?? defaultToolFilter;
|
|
42
|
+
return Object.fromEntries(Object.entries(tools).filter(([name, tool]) => filter(name, tool) && tool.parameters).map(([name, tool]) => [name, {
|
|
43
|
+
...tool.description && { description: tool.description },
|
|
44
|
+
parameters: toJSONSchema(tool.parameters)
|
|
45
|
+
}]));
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { toToolsJSONSchema };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=schema-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-utils.js","names":[],"sources":["../../../../../../../assistant-stream/dist/core/tool/schema-utils.js"],"sourcesContent":["//#region src/core/tool/schema-utils.ts\nfunction isStandardSchema(schema) {\n\treturn typeof schema === \"object\" && schema !== null && \"~standard\" in schema && typeof schema[\"~standard\"] === \"object\";\n}\nfunction hasToJSONSchemaMethod(schema) {\n\treturn typeof schema === \"object\" && schema !== null && \"toJSONSchema\" in schema && typeof schema.toJSONSchema === \"function\";\n}\nfunction hasToJSONMethod(schema) {\n\treturn typeof schema === \"object\" && schema !== null && \"toJSON\" in schema && typeof schema.toJSON === \"function\";\n}\n/**\n* Converts a schema to JSONSchema7.\n* Supports:\n* - StandardSchemaV1 with ~standard.toJSONSchema (e.g., Zod v4)\n* - StandardSchemaV1 with ~standard.jsonSchema.input() (e.g., Zod v4)\n* - Objects with toJSONSchema() method (e.g., Zod v4)\n* - Objects with toJSON() method\n* - Plain JSONSchema7 objects (must have a \"type\" property)\n*/\nfunction toJSONSchema(schema) {\n\tif (isStandardSchema(schema)) {\n\t\tconst toJSONSchemaMethod = schema[\"~standard\"].toJSONSchema;\n\t\tif (typeof toJSONSchemaMethod === \"function\") return toJSONSchemaMethod();\n\t\tconst jsonSchema = schema[\"~standard\"].jsonSchema;\n\t\tif (typeof jsonSchema === \"object\" && jsonSchema !== null && typeof jsonSchema.input === \"function\") return jsonSchema.input();\n\t}\n\tif (hasToJSONSchemaMethod(schema)) return schema.toJSONSchema();\n\tif (hasToJSONMethod(schema)) return schema.toJSON();\n\tif (isStandardSchema(schema)) throw new Error(\"Could not convert schema to JSON Schema. The schema implements Standard Schema but does not support JSON Schema conversion. If you are using Zod, please upgrade to Zod v4 (npm install zod@latest). Alternatively, pass a plain JSON Schema object instead.\");\n\treturn schema;\n}\n/**\n* Returns a copy of the JSON Schema with `required` removed recursively,\n* making every property optional. Array item schemas are left unchanged.\n*/\nfunction toPartialJSONSchema(schema) {\n\tconst { required: _, ...result } = schema;\n\tif (result.properties) result.properties = Object.fromEntries(Object.entries(result.properties).map(([key, prop]) => {\n\t\tif (typeof prop === \"object\" && prop !== null && !Array.isArray(prop)) {\n\t\t\tconst p = prop;\n\t\t\treturn [key, p.properties != null ? toPartialJSONSchema(p) : prop];\n\t\t}\n\t\treturn [key, prop];\n\t}));\n\treturn result;\n}\nfunction defaultToolFilter(_name, tool) {\n\treturn !tool.disabled && tool.type !== \"backend\";\n}\n/**\n* Converts a record of tools to a record of tool definitions with JSON Schema parameters.\n* By default, filters out disabled tools and backend tools.\n*/\nfunction toToolsJSONSchema(tools, options = {}) {\n\tif (!tools) return {};\n\tconst filter = options.filter ?? defaultToolFilter;\n\treturn Object.fromEntries(Object.entries(tools).filter(([name, tool]) => filter(name, tool) && tool.parameters).map(([name, tool]) => [name, {\n\t\t...tool.description && { description: tool.description },\n\t\tparameters: toJSONSchema(tool.parameters)\n\t}]));\n}\n//#endregion\nexport { toJSONSchema, toPartialJSONSchema, toToolsJSONSchema };\n\n//# sourceMappingURL=schema-utils.js.map"],"mappings":";AACA,SAAS,iBAAiB,QAAQ;CACjC,OAAO,OAAO,WAAW,YAAY,WAAW,QAAQ,eAAe,UAAU,OAAO,OAAO,iBAAiB;AACjH;AACA,SAAS,sBAAsB,QAAQ;CACtC,OAAO,OAAO,WAAW,YAAY,WAAW,QAAQ,kBAAkB,UAAU,OAAO,OAAO,iBAAiB;AACpH;AACA,SAAS,gBAAgB,QAAQ;CAChC,OAAO,OAAO,WAAW,YAAY,WAAW,QAAQ,YAAY,UAAU,OAAO,OAAO,WAAW;AACxG;;;;;;;;;;AAUA,SAAS,aAAa,QAAQ;CAC7B,IAAI,iBAAiB,MAAM,GAAG;EAC7B,MAAM,qBAAqB,OAAO,aAAa;EAC/C,IAAI,OAAO,uBAAuB,YAAY,OAAO,mBAAmB;EACxE,MAAM,aAAa,OAAO,aAAa;EACvC,IAAI,OAAO,eAAe,YAAY,eAAe,QAAQ,OAAO,WAAW,UAAU,YAAY,OAAO,WAAW,MAAM;CAC9H;CACA,IAAI,sBAAsB,MAAM,GAAG,OAAO,OAAO,aAAa;CAC9D,IAAI,gBAAgB,MAAM,GAAG,OAAO,OAAO,OAAO;CAClD,IAAI,iBAAiB,MAAM,GAAG,MAAM,IAAI,MAAM,8PAA8P;CAC5S,OAAO;AACR;AAgBA,SAAS,kBAAkB,OAAO,MAAM;CACvC,OAAO,CAAC,KAAK,YAAY,KAAK,SAAS;AACxC;;;;;AAKA,SAAS,kBAAkB,OAAO,UAAU,CAAC,GAAG;CAC/C,IAAI,CAAC,OAAO,OAAO,CAAC;CACpB,MAAM,SAAS,QAAQ,UAAU;CACjC,OAAO,OAAO,YAAY,OAAO,QAAQ,KAAK,EAAE,QAAQ,CAAC,MAAM,UAAU,OAAO,MAAM,IAAI,KAAK,KAAK,UAAU,EAAE,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM;EAC5I,GAAG,KAAK,eAAe,EAAE,aAAa,KAAK,YAAY;EACvD,YAAY,aAAa,KAAK,UAAU;CACzC,CAAC,CAAC,CAAC;AACJ"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region ../assistant-stream/dist/core/tool/tool-types.d.ts
|
|
2
|
+
//#region src/core/tool/tool-types.d.ts
|
|
3
|
+
type ToolModelContentPart = {
|
|
4
|
+
/** A text content part returned to the model after a tool call. */readonly type: "text"; /** Text that should be included in the model-visible tool result. */
|
|
5
|
+
readonly text: string;
|
|
6
|
+
} | {
|
|
7
|
+
/** A file content part returned to the model after a tool call. */readonly type: "file";
|
|
8
|
+
/**
|
|
9
|
+
* File payload encoded as a provider-compatible string, commonly base64
|
|
10
|
+
* for binary data.
|
|
11
|
+
*/
|
|
12
|
+
readonly data: string; /** MIME type for the file payload. */
|
|
13
|
+
readonly mediaType: string; /** Optional display filename for the file payload. */
|
|
14
|
+
readonly filename?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Converts a tool's runtime result into content that is sent back to the
|
|
18
|
+
* model.
|
|
19
|
+
*
|
|
20
|
+
* Return this when the value shown in the UI or stored as the tool result
|
|
21
|
+
* should differ from the model-visible response. When omitted, the successful
|
|
22
|
+
* tool result is sent back to the model as-is. If a tool returns a
|
|
23
|
+
* `ToolResponse` with `modelContent`, that explicit content is used instead
|
|
24
|
+
* of calling this function.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const toModelOutput: ToolModelOutputFunction<
|
|
29
|
+
* { documentId: string },
|
|
30
|
+
* { summary: string; pdfBase64: string }
|
|
31
|
+
* > = ({ output }) => [
|
|
32
|
+
* { type: "text", text: output.summary },
|
|
33
|
+
* {
|
|
34
|
+
* type: "file",
|
|
35
|
+
* data: output.pdfBase64,
|
|
36
|
+
* mediaType: "application/pdf",
|
|
37
|
+
* },
|
|
38
|
+
* ];
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
//#endregion
|
|
42
|
+
export { ToolModelContentPart };
|
|
43
|
+
//# sourceMappingURL=tool-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-types.d.ts","names":["AsyncIterableStream","JSONSchema7","DeepPartial","TypeAtPath","TypePath","ToolResponse","StandardSchemaV1","ToolModelContentPart","type","text","data","mediaType","filename","ToolModelOutputFunction","TArgs","TResult","Promise","toolCallId","input","output","options","ToolCallArgsReader","PathT","Record","U","Array","get","fieldPath","streamValues","streamText","forEach","ToolCallResponseReader","ToolCallReader","args","response","result","ToolExecutionContext","AbortSignal","abortSignal","human","payload","ToolExecuteFunction","context","ToolStreamCallFunction","reader","OnSchemaValidationErrorFunction","ToolBase","streamCall","BackendTool","description","parameters","disabled","execute","toModelOutput","experimental_onSchemaValidationError","FrontendTool","HumanTool","Tool","ToolWithoutType","Omit"],"sources":["../../../../../../../assistant-stream/dist/core/tool/tool-types.d.ts"],"mappings":";;KAOKO,oBAAAA;EAEME,4EADmED,IAAAA,UACnEC;EAAAA,SAAAA,IAAAA;AAAAA;EAQAE,4EANmEH,IAAAA;EAOnEI;;AAAQ;;EAARA,SAFAF,IAAAA;WACAC,SAAAA;WACAC,QAAAA;AAAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/packages/assistant-stream/dist/core/utils/stream/AssistantMetaTransformStream.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { ToolModelContentPart } from "./core/tool/tool-types.js";
|
package/dist/packages/assistant-stream/dist/resumable/createResumableAssistantStreamResponse.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region ../assistant-stream/dist/resumable/createResumableAssistantStreamResponse.d.ts
|
|
2
|
+
//#region src/resumable/createResumableAssistantStreamResponse.d.ts
|
|
3
|
+
declare const RESUMABLE_STREAM_ID_HEADER = "x-resumable-stream-id";
|
|
4
|
+
//#endregion
|
|
5
|
+
export { RESUMABLE_STREAM_ID_HEADER };
|
|
6
|
+
//# sourceMappingURL=createResumableAssistantStreamResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createResumableAssistantStreamResponse.d.ts","names":["AssistantStreamController","AssistantStreamEncoder","ResumableStreamContext","RESUMABLE_STREAM_ID_HEADER","CreateResumableAssistantStreamResponseOptions","PromiseLike","HeadersInit","context","streamId","callback","controller","encoder","headers","createResumableAssistantStreamResponse","Response","Promise","options","CreateResumeAssistantStreamResponseOptions","missingResponse","createResumeAssistantStreamResponse"],"sources":["../../../../../../assistant-stream/dist/resumable/createResumableAssistantStreamResponse.d.ts"],"mappings":";;cAKcG,0BAAAA"}
|
package/dist/packages/assistant-stream/dist/resumable/createResumableAssistantStreamResponse.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region ../assistant-stream/dist/resumable/createResumableAssistantStreamResponse.js
|
|
2
|
+
const RESUMABLE_STREAM_ID_HEADER = "x-resumable-stream-id";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { RESUMABLE_STREAM_ID_HEADER };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=createResumableAssistantStreamResponse.js.map
|
package/dist/packages/assistant-stream/dist/resumable/createResumableAssistantStreamResponse.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createResumableAssistantStreamResponse.js","names":[],"sources":["../../../../../../assistant-stream/dist/resumable/createResumableAssistantStreamResponse.js"],"sourcesContent":["import { DataStreamEncoder } from \"../core/serialization/data-stream/DataStream.js\";\nimport { createAssistantStream } from \"../core/modules/assistant-stream.js\";\n//#region src/resumable/createResumableAssistantStreamResponse.ts\nconst RESUMABLE_STREAM_ID_HEADER = \"x-resumable-stream-id\";\nasync function createResumableAssistantStreamResponse(options) {\n\tconst encoder = (options.encoder ?? (() => new DataStreamEncoder()))();\n\tconst stream = await options.context.run(options.streamId, () => {\n\t\treturn createAssistantStream(options.callback).pipeThrough(encoder);\n\t});\n\treturn new Response(stream, { headers: mergeHeaders(encoder.headers, options.headers, options.streamId) });\n}\nasync function createResumeAssistantStreamResponse(options) {\n\tconst stream = await options.context.resume(options.streamId);\n\tif (!stream) return options.missingResponse?.() ?? defaultMissingResponse();\n\tconst encoder = (options.encoder ?? (() => new DataStreamEncoder()))();\n\treturn new Response(stream, { headers: mergeHeaders(encoder.headers, options.headers, options.streamId) });\n}\nfunction defaultMissingResponse() {\n\treturn new Response(JSON.stringify({ error: \"stream not found\" }), {\n\t\tstatus: 404,\n\t\theaders: { \"Content-Type\": \"application/json\" }\n\t});\n}\nfunction mergeHeaders(encoderHeaders, extra, streamId) {\n\tconst merged = new Headers(encoderHeaders ?? {});\n\tif (extra) for (const [key, value] of new Headers(extra)) merged.set(key, value);\n\tmerged.set(RESUMABLE_STREAM_ID_HEADER, streamId);\n\treturn merged;\n}\n//#endregion\nexport { RESUMABLE_STREAM_ID_HEADER, createResumableAssistantStreamResponse, createResumeAssistantStreamResponse };\n\n//# sourceMappingURL=createResumableAssistantStreamResponse.js.map"],"mappings":";AAGA,MAAM,6BAA6B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { RESUMABLE_STREAM_ID_HEADER } from "./createResumableAssistantStreamResponse.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region ../assistant-stream/dist/utils/json/json-value.d.ts
|
|
2
|
+
//#region src/utils/json/json-value.d.ts
|
|
3
|
+
type ReadonlyJSONValue = null | string | number | boolean | ReadonlyJSONObject | ReadonlyJSONArray;
|
|
4
|
+
type ReadonlyJSONObject = {
|
|
5
|
+
readonly [key: string]: ReadonlyJSONValue;
|
|
6
|
+
};
|
|
7
|
+
type ReadonlyJSONArray = readonly ReadonlyJSONValue[]; //#endregion
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ReadonlyJSONArray, ReadonlyJSONObject, ReadonlyJSONValue };
|
|
10
|
+
//# sourceMappingURL=json-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-value.d.ts","names":["ReadonlyJSONValue","ReadonlyJSONObject","ReadonlyJSONArray","key"],"sources":["../../../../../../../assistant-stream/dist/utils/json/json-value.d.ts"],"mappings":";;KACKA,iBAAAA,sCAAuDC,kBAAAA,GAAqBC,iBAAiB;AAAA,KAC7FD,kBAAAA;EAAAA,UACOE,GAAAA,WAAcH,iBAAiB;AAAA;AAAA,KAEtCE,iBAAAA,YAA6BF,iBAAiB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { ReadonlyJSONArray, ReadonlyJSONObject, ReadonlyJSONValue } from "./utils/json/json-value.js";
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { UIMessage } from "ai";
|
|
2
|
+
import { MessageFormatAdapter } from "@assistant-ui/core";
|
|
3
|
+
|
|
4
|
+
//#region src/ui/adapters/aiSDKFormatAdapter.d.ts
|
|
5
|
+
type AISDKStorageFormat = Omit<UIMessage, "id">;
|
|
6
|
+
declare const aiSDKV6FormatAdapter: MessageFormatAdapter<UIMessage, AISDKStorageFormat>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { AISDKStorageFormat, aiSDKV6FormatAdapter };
|
|
5
9
|
//# sourceMappingURL=aiSDKFormatAdapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aiSDKFormatAdapter.d.ts","
|
|
1
|
+
{"version":3,"file":"aiSDKFormatAdapter.d.ts","names":[],"sources":["../../../src/ui/adapters/aiSDKFormatAdapter.ts"],"mappings":";;;;KAQY,kBAAA,GAAqB,IAAI,CAAC,SAAA;AAAA,cAEzB,oBAAA,EAAsB,oBAAA,CACjC,SAAA,EACA,kBAAA"}
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
//#region src/ui/adapters/aiSDKFormatAdapter.ts
|
|
2
|
+
const aiSDKV6FormatAdapter = {
|
|
3
|
+
format: "ai-sdk/v6",
|
|
4
|
+
encode({ message: { id, parts, ...message } }) {
|
|
5
|
+
return {
|
|
6
|
+
...message,
|
|
7
|
+
parts
|
|
8
|
+
};
|
|
9
|
+
},
|
|
10
|
+
decode(stored) {
|
|
11
|
+
return {
|
|
12
|
+
parentId: stored.parent_id,
|
|
13
|
+
message: {
|
|
14
|
+
id: stored.id,
|
|
15
|
+
...stored.content
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
getId(message) {
|
|
20
|
+
return message.id;
|
|
21
|
+
}
|
|
21
22
|
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { aiSDKV6FormatAdapter };
|
|
25
|
+
|
|
22
26
|
//# sourceMappingURL=aiSDKFormatAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aiSDKFormatAdapter.js","
|
|
1
|
+
{"version":3,"file":"aiSDKFormatAdapter.js","names":[],"sources":["../../../src/ui/adapters/aiSDKFormatAdapter.ts"],"sourcesContent":["import type { UIMessage } from \"ai\";\nimport type {\n MessageFormatAdapter,\n MessageFormatItem,\n MessageStorageEntry,\n} from \"@assistant-ui/core\";\n\n// Storage format for AI SDK messages - just the UIMessage\nexport type AISDKStorageFormat = Omit<UIMessage, \"id\">;\n\nexport const aiSDKV6FormatAdapter: MessageFormatAdapter<\n UIMessage,\n AISDKStorageFormat\n> = {\n format: \"ai-sdk/v6\",\n\n encode({\n message: { id, parts, ...message },\n }: MessageFormatItem<UIMessage>): AISDKStorageFormat {\n return {\n ...message,\n parts,\n };\n },\n\n decode(\n stored: MessageStorageEntry<AISDKStorageFormat>,\n ): MessageFormatItem<UIMessage> {\n return {\n parentId: stored.parent_id,\n message: {\n id: stored.id,\n ...stored.content,\n },\n };\n },\n\n getId(message: UIMessage): string {\n return message.id;\n },\n};\n"],"mappings":";AAUA,MAAa,uBAGT;CACF,QAAQ;CAER,OAAO,EACL,SAAS,EAAE,IAAI,OAAO,GAAG,aAC0B;EACnD,OAAO;GACL,GAAG;GACH;EACF;CACF;CAEA,OACE,QAC8B;EAC9B,OAAO;GACL,UAAU,OAAO;GACjB,SAAS;IACP,IAAI,OAAO;IACX,GAAG,OAAO;GACZ;EACF;CACF;CAEA,MAAM,SAA4B;EAChC,OAAO,QAAQ;CACjB;AACF"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { UIMessage } from "ai";
|
|
2
|
+
import { ThreadMessage } from "@assistant-ui/core";
|
|
3
|
+
|
|
4
|
+
//#region src/ui/getVercelAIMessages.d.ts
|
|
5
|
+
declare const getVercelAIMessages: <UI_MESSAGE extends UIMessage = UIMessage>(message: ThreadMessage) => UI_MESSAGE[];
|
|
6
|
+
//#endregion
|
|
7
|
+
export { getVercelAIMessages };
|
|
4
8
|
//# sourceMappingURL=getVercelAIMessages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVercelAIMessages.d.ts","
|
|
1
|
+
{"version":3,"file":"getVercelAIMessages.d.ts","names":[],"sources":["../../src/ui/getVercelAIMessages.ts"],"mappings":";;;;cAMa,mBAAA,sBAA0C,SAAA,GAAY,SAAA,EACjE,OAAA,EAAS,aAAA,KAEmC,UAAA"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { getExternalStoreMessages
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { getExternalStoreMessages } from "@assistant-ui/core";
|
|
2
|
+
//#region src/ui/getVercelAIMessages.ts
|
|
3
|
+
const getVercelAIMessages = (message) => {
|
|
4
|
+
return getExternalStoreMessages(message);
|
|
4
5
|
};
|
|
6
|
+
//#endregion
|
|
7
|
+
export { getVercelAIMessages };
|
|
8
|
+
|
|
5
9
|
//# sourceMappingURL=getVercelAIMessages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVercelAIMessages.js","
|
|
1
|
+
{"version":3,"file":"getVercelAIMessages.js","names":[],"sources":["../../src/ui/getVercelAIMessages.ts"],"sourcesContent":["import {\n getExternalStoreMessages,\n type ThreadMessage,\n} from \"@assistant-ui/core\";\nimport type { UIMessage } from \"ai\";\n\nexport const getVercelAIMessages = <UI_MESSAGE extends UIMessage = UIMessage>(\n message: ThreadMessage,\n) => {\n return getExternalStoreMessages(message) as UI_MESSAGE[];\n};\n"],"mappings":";;AAMA,MAAa,uBACX,YACG;CACH,OAAO,yBAAyB,OAAO;AACzC"}
|
package/dist/ui/resumable.d.ts
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { RESUMABLE_STREAM_ID_HEADER } from "../packages/assistant-stream/dist/resumable/createResumableAssistantStreamResponse.js";
|
|
2
|
+
//#region src/ui/resumable.d.ts
|
|
3
|
+
type ResumableClientStorage = {
|
|
4
|
+
getStreamId(): string | null;
|
|
5
|
+
setStreamId(id: string): void;
|
|
6
|
+
clear(): void;
|
|
6
7
|
};
|
|
7
8
|
/** `sessionStorage`-backed storage for the pending resumable stream id. */
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
declare function createResumableSessionStorage(options?: {
|
|
10
|
+
key?: string;
|
|
10
11
|
}): ResumableClientStorage;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
type AssistantChatResumableOptions = {
|
|
13
|
+
storage: ResumableClientStorage;
|
|
14
|
+
resumeApi: string | ((streamId: string) => string);
|
|
15
|
+
/**
|
|
16
|
+
* Defaults to scanning for the AI SDK UIMessageStream `finish` marker.
|
|
17
|
+
* Cancellation never invokes this callback, only natural completion does.
|
|
18
|
+
*/
|
|
19
|
+
isFinishEvent?: (chunk: Uint8Array, accumulator: string) => boolean;
|
|
19
20
|
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { AssistantChatResumableOptions, RESUMABLE_STREAM_ID_HEADER, ResumableClientStorage, createResumableSessionStorage };
|
|
20
23
|
//# sourceMappingURL=resumable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resumable.d.ts","
|
|
1
|
+
{"version":3,"file":"resumable.d.ts","names":[],"sources":["../../src/ui/resumable.ts"],"mappings":";;KAMY,sBAAA;EACV,WAAA;EACA,WAAA,CAAY,EAAA;EACZ,KAAA;AAAA;;iBAIc,6BAAA,CAA8B,OAAA;EAC5C,GAAA;AAAA,IACE,sBAAsB;AAAA,KAkBd,6BAAA;EACV,OAAA,EAAS,sBAAA;EACT,SAAA,aAAsB,QAAA;EA1BjB;AAIP;;;EA2BE,aAAA,IAAiB,KAAA,EAAO,UAAU,EAAE,WAAA;AAAA"}
|
package/dist/ui/resumable.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
2
|
+
import { RESUMABLE_STREAM_ID_HEADER } from "../packages/assistant-stream/dist/resumable/createResumableAssistantStreamResponse.js";
|
|
3
|
+
//#region src/ui/resumable.ts
|
|
3
4
|
const DEFAULT_STORAGE_KEY = "aui-resumable-stream-id";
|
|
4
5
|
/** `sessionStorage`-backed storage for the pending resumable stream id. */
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
window.sessionStorage.removeItem(key);
|
|
22
|
-
},
|
|
23
|
-
};
|
|
6
|
+
function createResumableSessionStorage(options) {
|
|
7
|
+
const key = options?.key ?? DEFAULT_STORAGE_KEY;
|
|
8
|
+
return {
|
|
9
|
+
getStreamId() {
|
|
10
|
+
if (typeof window === "undefined") return null;
|
|
11
|
+
return window.sessionStorage.getItem(key);
|
|
12
|
+
},
|
|
13
|
+
setStreamId(id) {
|
|
14
|
+
if (typeof window === "undefined") return;
|
|
15
|
+
window.sessionStorage.setItem(key, id);
|
|
16
|
+
},
|
|
17
|
+
clear() {
|
|
18
|
+
if (typeof window === "undefined") return;
|
|
19
|
+
window.sessionStorage.removeItem(key);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
24
22
|
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { RESUMABLE_STREAM_ID_HEADER, createResumableSessionStorage };
|
|
25
|
+
|
|
25
26
|
//# sourceMappingURL=resumable.js.map
|
package/dist/ui/resumable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resumable.js","
|
|
1
|
+
{"version":3,"file":"resumable.js","names":[],"sources":["../../src/ui/resumable.ts"],"sourcesContent":["\"use client\";\n\nexport { RESUMABLE_STREAM_ID_HEADER } from \"assistant-stream/resumable\";\n\nconst DEFAULT_STORAGE_KEY = \"aui-resumable-stream-id\";\n\nexport type ResumableClientStorage = {\n getStreamId(): string | null;\n setStreamId(id: string): void;\n clear(): void;\n};\n\n/** `sessionStorage`-backed storage for the pending resumable stream id. */\nexport function createResumableSessionStorage(options?: {\n key?: string;\n}): ResumableClientStorage {\n const key = options?.key ?? DEFAULT_STORAGE_KEY;\n return {\n getStreamId() {\n if (typeof window === \"undefined\") return null;\n return window.sessionStorage.getItem(key);\n },\n setStreamId(id) {\n if (typeof window === \"undefined\") return;\n window.sessionStorage.setItem(key, id);\n },\n clear() {\n if (typeof window === \"undefined\") return;\n window.sessionStorage.removeItem(key);\n },\n };\n}\n\nexport type AssistantChatResumableOptions = {\n storage: ResumableClientStorage;\n resumeApi: string | ((streamId: string) => string);\n /**\n * Defaults to scanning for the AI SDK UIMessageStream `finish` marker.\n * Cancellation never invokes this callback, only natural completion does.\n */\n isFinishEvent?: (chunk: Uint8Array, accumulator: string) => boolean;\n};\n"],"mappings":";;;AAIA,MAAM,sBAAsB;;AAS5B,SAAgB,8BAA8B,SAEnB;CACzB,MAAM,MAAM,SAAS,OAAO;CAC5B,OAAO;EACL,cAAc;GACZ,IAAI,OAAO,WAAW,aAAa,OAAO;GAC1C,OAAO,OAAO,eAAe,QAAQ,GAAG;EAC1C;EACA,YAAY,IAAI;GACd,IAAI,OAAO,WAAW,aAAa;GACnC,OAAO,eAAe,QAAQ,KAAK,EAAE;EACvC;EACA,QAAQ;GACN,IAAI,OAAO,WAAW,aAAa;GACnC,OAAO,eAAe,WAAW,GAAG;EACtC;CACF;AACF"}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DefaultChatTransport,
|
|
3
|
-
import {
|
|
1
|
+
import { AssistantChatResumableOptions } from "../resumable.js";
|
|
2
|
+
import { DefaultChatTransport, HttpChatTransportInitOptions, UIMessage } from "ai";
|
|
3
|
+
import { AssistantRuntime, ThreadListItemRuntime } from "@assistant-ui/core";
|
|
4
|
+
|
|
5
|
+
//#region src/ui/use-chat/AssistantChatTransport.d.ts
|
|
4
6
|
type InitializableThreadListItem = Pick<ThreadListItemRuntime, "initialize">;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
type AssistantChatTransportInitOptions<UI_MESSAGE extends UIMessage> = HttpChatTransportInitOptions<UI_MESSAGE> & {
|
|
8
|
+
resumable?: AssistantChatResumableOptions;
|
|
7
9
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
declare class AssistantChatTransport<UI_MESSAGE extends UIMessage> extends DefaultChatTransport<UI_MESSAGE> {
|
|
11
|
+
private runtime;
|
|
12
|
+
private getThreadListItem;
|
|
13
|
+
private readonly resumable;
|
|
14
|
+
constructor(initOptions?: AssistantChatTransportInitOptions<UI_MESSAGE>);
|
|
15
|
+
setRuntime(runtime: AssistantRuntime): void;
|
|
16
|
+
getResumableAdapter(): AssistantChatResumableOptions | undefined;
|
|
17
|
+
__internal_setGetThreadListItem(getter: () => InitializableThreadListItem | undefined): void;
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
//#endregion
|
|
20
|
+
export { AssistantChatTransport, AssistantChatTransportInitOptions };
|
|
18
21
|
//# sourceMappingURL=AssistantChatTransport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantChatTransport.d.ts","
|
|
1
|
+
{"version":3,"file":"AssistantChatTransport.d.ts","names":[],"sources":["../../../src/ui/use-chat/AssistantChatTransport.ts"],"mappings":";;;;;KAeK,2BAAA,GAA8B,IAAI,CAAC,qBAAA;AAAA,KAM5B,iCAAA,oBAAqD,SAAA,IAC/D,4BAAA,CAA6B,UAAA;EAC3B,SAAA,GAAY,6BAAA;AAAA;AAAA,cAGH,sBAAA,oBACQ,SAAA,UACX,oBAAA,CAAqB,UAAA;EAAA,QACrB,OAAA;EAAA,QACA,iBAAA;EAAA,iBAGS,SAAA;cAEL,WAAA,GAAc,iCAAA,CAAkC,UAAA;EAkD5D,UAAA,CAAW,OAAA,EAAS,gBAAA;EAIpB,mBAAA,CAAA,GAAuB,6BAAA;EAIvB,+BAAA,CACE,MAAA,QAAc,2BAAA;AAAA"}
|