@assistant-ui/react 0.7.79 → 0.7.80
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/model-context/ModelContextTypes.d.ts +1 -1
- package/dist/model-context/ModelContextTypes.d.ts.map +1 -1
- package/dist/model-context/ModelContextTypes.js.map +1 -1
- package/dist/model-context/ModelContextTypes.mjs.map +1 -1
- package/dist/model-context/makeAssistantTool.d.ts +1 -2
- package/dist/model-context/makeAssistantTool.d.ts.map +1 -1
- package/dist/model-context/makeAssistantTool.js.map +1 -1
- package/dist/model-context/makeAssistantTool.mjs.map +1 -1
- package/dist/model-context/makeAssistantToolUI.d.ts +1 -2
- package/dist/model-context/makeAssistantToolUI.d.ts.map +1 -1
- package/dist/model-context/makeAssistantToolUI.js.map +1 -1
- package/dist/model-context/makeAssistantToolUI.mjs.map +1 -1
- package/dist/model-context/useAssistantTool.d.ts +2 -3
- package/dist/model-context/useAssistantTool.d.ts.map +1 -1
- package/dist/model-context/useAssistantTool.js.map +1 -1
- package/dist/model-context/useAssistantTool.mjs.map +1 -1
- package/dist/model-context/useAssistantToolUI.d.ts +1 -2
- package/dist/model-context/useAssistantToolUI.d.ts.map +1 -1
- package/dist/model-context/useAssistantToolUI.js.map +1 -1
- package/dist/model-context/useAssistantToolUI.mjs.map +1 -1
- package/dist/model-context/useInlineRender.d.ts +1 -2
- package/dist/model-context/useInlineRender.d.ts.map +1 -1
- package/dist/model-context/useInlineRender.js.map +1 -1
- package/dist/model-context/useInlineRender.mjs.map +1 -1
- package/dist/runtimes/edge/streams/toolResultStream.d.ts +1 -1
- package/dist/runtimes/edge/streams/toolResultStream.d.ts.map +1 -1
- package/dist/runtimes/edge/streams/toolResultStream.js.map +1 -1
- package/dist/runtimes/edge/streams/toolResultStream.mjs.map +1 -1
- package/dist/types/AssistantTypes.d.ts +2 -2
- package/dist/types/AssistantTypes.d.ts.map +1 -1
- package/dist/types/AssistantTypes.js.map +1 -1
- package/dist/types/ContentPartComponentTypes.d.ts +2 -3
- package/dist/types/ContentPartComponentTypes.d.ts.map +1 -1
- package/dist/types/ContentPartComponentTypes.js.map +1 -1
- package/package.json +1 -1
- package/src/model-context/ModelContextTypes.ts +1 -4
- package/src/model-context/makeAssistantTool.tsx +1 -2
- package/src/model-context/makeAssistantToolUI.tsx +1 -2
- package/src/model-context/useAssistantTool.tsx +2 -6
- package/src/model-context/useAssistantToolUI.tsx +1 -2
- package/src/model-context/useInlineRender.tsx +1 -2
- package/src/runtimes/edge/streams/toolResultStream.ts +1 -1
- package/src/types/AssistantTypes.ts +2 -3
- package/src/types/ContentPartComponentTypes.tsx +4 -4
@@ -46,7 +46,7 @@ type ToolExecuteFunction<TArgs, TResult> = (args: TArgs, context: {
|
|
46
46
|
abortSignal: AbortSignal;
|
47
47
|
}) => TResult | Promise<TResult>;
|
48
48
|
type OnSchemaValidationErrorFunction<TResult> = ToolExecuteFunction<unknown, TResult>;
|
49
|
-
export type Tool<TArgs
|
49
|
+
export type Tool<TArgs = unknown, TResult = unknown> = {
|
50
50
|
description?: string | undefined;
|
51
51
|
parameters: z.ZodSchema<TArgs> | JSONSchema7;
|
52
52
|
execute?: ToolExecuteFunction<TArgs, TResult>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ModelContextTypes.d.ts","sourceRoot":"","sources":["../../src/model-context/ModelContextTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;EAQ5C,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,iCAAiC,CACzC,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;EAIpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC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AAO,IAAI;IACrD,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC;IAC7C,OAAO,CAAC,EAAE,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9C,oCAAoC,CAAC,EAAE,+BAA+B,CAAC,OAAO,CAAC,CAAC;CACjF,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC;IACnD,YAAY,CAAC,EAAE,2BAA2B,GAAG,SAAS,CAAC;IACvD,MAAM,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,eAAe,EAAE,MAAM,YAAY,CAAC;IACpC,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,WAAW,CAAC;CACnD,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAClB,GAAG,CAAC,oBAAoB,CAAC,KACnC,YAuCF,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/model-context/ModelContextTypes.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { JSONSchema7 } from \"json-schema\";\nimport { Unsubscribe } from \"../types/Unsubscribe\";\n\nexport const LanguageModelV1CallSettingsSchema = z.object({\n maxTokens: z.number().int().positive().optional(),\n temperature: z.number().optional(),\n topP: z.number().optional(),\n presencePenalty: z.number().optional(),\n frequencyPenalty: z.number().optional(),\n seed: z.number().int().optional(),\n headers: z.record(z.string().optional()).optional(),\n});\n\nexport type LanguageModelV1CallSettings = z.infer<\n typeof LanguageModelV1CallSettingsSchema\n>;\n\nexport const LanguageModelConfigSchema = z.object({\n apiKey: z.string().optional(),\n baseUrl: z.string().optional(),\n modelName: z.string().optional(),\n});\n\nexport type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;\n\ntype ToolExecuteFunction<TArgs, TResult> = (\n args: TArgs,\n context: {\n toolCallId: string;\n abortSignal: AbortSignal;\n },\n) => TResult | Promise<TResult>;\n\ntype OnSchemaValidationErrorFunction<TResult> = ToolExecuteFunction<\n unknown,\n TResult\n>;\n\nexport type Tool
|
1
|
+
{"version":3,"sources":["../../src/model-context/ModelContextTypes.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { JSONSchema7 } from \"json-schema\";\nimport { Unsubscribe } from \"../types/Unsubscribe\";\n\nexport const LanguageModelV1CallSettingsSchema = z.object({\n maxTokens: z.number().int().positive().optional(),\n temperature: z.number().optional(),\n topP: z.number().optional(),\n presencePenalty: z.number().optional(),\n frequencyPenalty: z.number().optional(),\n seed: z.number().int().optional(),\n headers: z.record(z.string().optional()).optional(),\n});\n\nexport type LanguageModelV1CallSettings = z.infer<\n typeof LanguageModelV1CallSettingsSchema\n>;\n\nexport const LanguageModelConfigSchema = z.object({\n apiKey: z.string().optional(),\n baseUrl: z.string().optional(),\n modelName: z.string().optional(),\n});\n\nexport type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;\n\ntype ToolExecuteFunction<TArgs, TResult> = (\n args: TArgs,\n context: {\n toolCallId: string;\n abortSignal: AbortSignal;\n },\n) => TResult | Promise<TResult>;\n\ntype OnSchemaValidationErrorFunction<TResult> = ToolExecuteFunction<\n unknown,\n TResult\n>;\n\nexport type Tool<TArgs = unknown, TResult = unknown> = {\n description?: string | undefined;\n parameters: z.ZodSchema<TArgs> | JSONSchema7;\n execute?: ToolExecuteFunction<TArgs, TResult>;\n experimental_onSchemaValidationError?: OnSchemaValidationErrorFunction<TResult>;\n};\n\nexport type ModelContext = {\n priority?: number | undefined;\n system?: string | undefined;\n tools?: Record<string, Tool<any, any>> | undefined;\n callSettings?: LanguageModelV1CallSettings | undefined;\n config?: LanguageModelConfig | undefined;\n};\n\nexport type ModelContextProvider = {\n getModelContext: () => ModelContext;\n subscribe?: (callback: () => void) => Unsubscribe;\n};\n\nexport const mergeModelContexts = (\n configSet: Set<ModelContextProvider>,\n): ModelContext => {\n const configs = Array.from(configSet)\n .map((c) => c.getModelContext())\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n\n return configs.reduce((acc, config) => {\n if (config.system) {\n if (acc.system) {\n // TODO should the separator be configurable?\n acc.system += `\\n\\n${config.system}`;\n } else {\n acc.system = config.system;\n }\n }\n if (config.tools) {\n for (const [name, tool] of Object.entries(config.tools)) {\n if (acc.tools?.[name]) {\n throw new Error(\n `You tried to define a tool with the name ${name}, but it already exists.`,\n );\n }\n if (!acc.tools) acc.tools = {};\n acc.tools[name] = tool;\n }\n }\n if (config.config) {\n acc.config = {\n ...acc.config,\n ...config.config,\n };\n }\n if (config.callSettings) {\n acc.callSettings = {\n ...acc.callSettings,\n ...config.callSettings,\n };\n }\n return acc;\n }, {} as ModelContext);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAIX,IAAM,oCAAoC,aAAE,OAAO;AAAA,EACxD,WAAW,aAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS;AAAA,EAChD,aAAa,aAAE,OAAO,EAAE,SAAS;AAAA,EACjC,MAAM,aAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,iBAAiB,aAAE,OAAO,EAAE,SAAS;AAAA,EACrC,kBAAkB,aAAE,OAAO,EAAE,SAAS;AAAA,EACtC,MAAM,aAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EAChC,SAAS,aAAE,OAAO,aAAE,OAAO,EAAE,SAAS,CAAC,EAAE,SAAS;AACpD,CAAC;AAMM,IAAM,4BAA4B,aAAE,OAAO;AAAA,EAChD,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,SAAS,aAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,WAAW,aAAE,OAAO,EAAE,SAAS;AACjC,CAAC;AAqCM,IAAM,qBAAqB,CAChC,cACiB;AACjB,QAAM,UAAU,MAAM,KAAK,SAAS,EACjC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAC9B,KAAK,CAAC,GAAG,OAAO,EAAE,YAAY,MAAM,EAAE,YAAY,EAAE;AAEvD,SAAO,QAAQ,OAAO,CAAC,KAAK,WAAW;AACrC,QAAI,OAAO,QAAQ;AACjB,UAAI,IAAI,QAAQ;AAEd,YAAI,UAAU;AAAA;AAAA,EAAO,OAAO,MAAM;AAAA,MACpC,OAAO;AACL,YAAI,SAAS,OAAO;AAAA,MACtB;AAAA,IACF;AACA,QAAI,OAAO,OAAO;AAChB,iBAAW,CAAC,MAAM,IAAI,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACvD,YAAI,IAAI,QAAQ,IAAI,GAAG;AACrB,gBAAM,IAAI;AAAA,YACR,4CAA4C,IAAI;AAAA,UAClD;AAAA,QACF;AACA,YAAI,CAAC,IAAI,MAAO,KAAI,QAAQ,CAAC;AAC7B,YAAI,MAAM,IAAI,IAAI;AAAA,MACpB;AAAA,IACF;AACA,QAAI,OAAO,QAAQ;AACjB,UAAI,SAAS;AAAA,QACX,GAAG,IAAI;AAAA,QACP,GAAG,OAAO;AAAA,MACZ;AAAA,IACF;AACA,QAAI,OAAO,cAAc;AACvB,UAAI,eAAe;AAAA,QACjB,GAAG,IAAI;AAAA,QACP,GAAG,OAAO;AAAA,MACZ;AAAA,IACF;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAiB;AACvB;","names":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/model-context/ModelContextTypes.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { JSONSchema7 } from \"json-schema\";\nimport { Unsubscribe } from \"../types/Unsubscribe\";\n\nexport const LanguageModelV1CallSettingsSchema = z.object({\n maxTokens: z.number().int().positive().optional(),\n temperature: z.number().optional(),\n topP: z.number().optional(),\n presencePenalty: z.number().optional(),\n frequencyPenalty: z.number().optional(),\n seed: z.number().int().optional(),\n headers: z.record(z.string().optional()).optional(),\n});\n\nexport type LanguageModelV1CallSettings = z.infer<\n typeof LanguageModelV1CallSettingsSchema\n>;\n\nexport const LanguageModelConfigSchema = z.object({\n apiKey: z.string().optional(),\n baseUrl: z.string().optional(),\n modelName: z.string().optional(),\n});\n\nexport type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;\n\ntype ToolExecuteFunction<TArgs, TResult> = (\n args: TArgs,\n context: {\n toolCallId: string;\n abortSignal: AbortSignal;\n },\n) => TResult | Promise<TResult>;\n\ntype OnSchemaValidationErrorFunction<TResult> = ToolExecuteFunction<\n unknown,\n TResult\n>;\n\nexport type Tool
|
1
|
+
{"version":3,"sources":["../../src/model-context/ModelContextTypes.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { JSONSchema7 } from \"json-schema\";\nimport { Unsubscribe } from \"../types/Unsubscribe\";\n\nexport const LanguageModelV1CallSettingsSchema = z.object({\n maxTokens: z.number().int().positive().optional(),\n temperature: z.number().optional(),\n topP: z.number().optional(),\n presencePenalty: z.number().optional(),\n frequencyPenalty: z.number().optional(),\n seed: z.number().int().optional(),\n headers: z.record(z.string().optional()).optional(),\n});\n\nexport type LanguageModelV1CallSettings = z.infer<\n typeof LanguageModelV1CallSettingsSchema\n>;\n\nexport const LanguageModelConfigSchema = z.object({\n apiKey: z.string().optional(),\n baseUrl: z.string().optional(),\n modelName: z.string().optional(),\n});\n\nexport type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;\n\ntype ToolExecuteFunction<TArgs, TResult> = (\n args: TArgs,\n context: {\n toolCallId: string;\n abortSignal: AbortSignal;\n },\n) => TResult | Promise<TResult>;\n\ntype OnSchemaValidationErrorFunction<TResult> = ToolExecuteFunction<\n unknown,\n TResult\n>;\n\nexport type Tool<TArgs = unknown, TResult = unknown> = {\n description?: string | undefined;\n parameters: z.ZodSchema<TArgs> | JSONSchema7;\n execute?: ToolExecuteFunction<TArgs, TResult>;\n experimental_onSchemaValidationError?: OnSchemaValidationErrorFunction<TResult>;\n};\n\nexport type ModelContext = {\n priority?: number | undefined;\n system?: string | undefined;\n tools?: Record<string, Tool<any, any>> | undefined;\n callSettings?: LanguageModelV1CallSettings | undefined;\n config?: LanguageModelConfig | undefined;\n};\n\nexport type ModelContextProvider = {\n getModelContext: () => ModelContext;\n subscribe?: (callback: () => void) => Unsubscribe;\n};\n\nexport const mergeModelContexts = (\n configSet: Set<ModelContextProvider>,\n): ModelContext => {\n const configs = Array.from(configSet)\n .map((c) => c.getModelContext())\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n\n return configs.reduce((acc, config) => {\n if (config.system) {\n if (acc.system) {\n // TODO should the separator be configurable?\n acc.system += `\\n\\n${config.system}`;\n } else {\n acc.system = config.system;\n }\n }\n if (config.tools) {\n for (const [name, tool] of Object.entries(config.tools)) {\n if (acc.tools?.[name]) {\n throw new Error(\n `You tried to define a tool with the name ${name}, but it already exists.`,\n );\n }\n if (!acc.tools) acc.tools = {};\n acc.tools[name] = tool;\n }\n }\n if (config.config) {\n acc.config = {\n ...acc.config,\n ...config.config,\n };\n }\n if (config.callSettings) {\n acc.callSettings = {\n ...acc.callSettings,\n ...config.callSettings,\n };\n }\n return acc;\n }, {} as ModelContext);\n};\n"],"mappings":";AAAA,SAAS,SAAS;AAIX,IAAM,oCAAoC,EAAE,OAAO;AAAA,EACxD,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS;AAAA,EAChD,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,E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AO;AAAA,MACZ;AAAA,IACF;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAiB;AACvB;","names":[]}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import { FC } from "react";
|
2
2
|
import { type AssistantToolProps } from "./useAssistantTool";
|
3
|
-
import { ReadonlyJSONObject } from "../utils/json/json-value";
|
4
3
|
export type AssistantTool = FC & {
|
5
4
|
unstable_tool: AssistantToolProps<any, any>;
|
6
5
|
};
|
7
|
-
export declare const makeAssistantTool: <TArgs
|
6
|
+
export declare const makeAssistantTool: <TArgs, TResult>(tool: AssistantToolProps<TArgs, TResult>) => AssistantTool;
|
8
7
|
//# sourceMappingURL=makeAssistantTool.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"makeAssistantTool.d.ts","sourceRoot":"","sources":["../../src/model-context/makeAssistantTool.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,KAAK,kBAAkB,EAAoB,MAAM,oBAAoB,CAAC;
|
1
|
+
{"version":3,"file":"makeAssistantTool.d.ts","sourceRoot":"","sources":["../../src/model-context/makeAssistantTool.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,KAAK,kBAAkB,EAAoB,MAAM,oBAAoB,CAAC;AAE/E,MAAM,MAAM,aAAa,GAAG,EAAE,GAAG;IAC/B,aAAa,EAAE,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,KAAK,EAAE,OAAO,QACxC,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,kBAQzC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/model-context/makeAssistantTool.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC } from \"react\";\nimport { type AssistantToolProps, useAssistantTool } from \"./useAssistantTool\";\
|
1
|
+
{"version":3,"sources":["../../src/model-context/makeAssistantTool.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC } from \"react\";\nimport { type AssistantToolProps, useAssistantTool } from \"./useAssistantTool\";\n\nexport type AssistantTool = FC & {\n unstable_tool: AssistantToolProps<any, any>;\n};\n\nexport const makeAssistantTool = <TArgs, TResult>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const Tool: AssistantTool = () => {\n useAssistantTool(tool);\n return null;\n };\n Tool.unstable_tool = tool;\n return Tool;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,8BAA0D;AAMnD,IAAM,oBAAoB,CAC/B,SACG;AACH,QAAM,OAAsB,MAAM;AAChC,kDAAiB,IAAI;AACrB,WAAO;AAAA,EACT;AACA,OAAK,gBAAgB;AACrB,SAAO;AACT;","names":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/model-context/makeAssistantTool.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC } from \"react\";\nimport { type AssistantToolProps, useAssistantTool } from \"./useAssistantTool\";\
|
1
|
+
{"version":3,"sources":["../../src/model-context/makeAssistantTool.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC } from \"react\";\nimport { type AssistantToolProps, useAssistantTool } from \"./useAssistantTool\";\n\nexport type AssistantTool = FC & {\n unstable_tool: AssistantToolProps<any, any>;\n};\n\nexport const makeAssistantTool = <TArgs, TResult>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const Tool: AssistantTool = () => {\n useAssistantTool(tool);\n return null;\n };\n Tool.unstable_tool = tool;\n return Tool;\n};\n"],"mappings":";;;AAGA,SAAkC,wBAAwB;AAMnD,IAAM,oBAAoB,CAC/B,SACG;AACH,QAAM,OAAsB,MAAM;AAChC,qBAAiB,IAAI;AACrB,WAAO;AAAA,EACT;AACA,OAAK,gBAAgB;AACrB,SAAO;AACT;","names":[]}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import { FC } from "react";
|
2
2
|
import { type AssistantToolUIProps } from "./useAssistantToolUI";
|
3
|
-
import { ReadonlyJSONObject } from "../utils/json/json-value";
|
4
3
|
export type AssistantToolUI = FC & {
|
5
4
|
unstable_tool: AssistantToolUIProps<any, any>;
|
6
5
|
};
|
7
|
-
export declare const makeAssistantToolUI: <TArgs
|
6
|
+
export declare const makeAssistantToolUI: <TArgs, TResult>(tool: AssistantToolUIProps<TArgs, TResult>) => AssistantToolUI;
|
8
7
|
//# sourceMappingURL=makeAssistantToolUI.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"makeAssistantToolUI.d.ts","sourceRoot":"","sources":["../../src/model-context/makeAssistantToolUI.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,sBAAsB,CAAC;
|
1
|
+
{"version":3,"file":"makeAssistantToolUI.d.ts","sourceRoot":"","sources":["../../src/model-context/makeAssistantToolUI.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,eAAe,GAAG,EAAE,GAAG;IACjC,aAAa,EAAE,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;CAC/C,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,KAAK,EAAE,OAAO,QAC1C,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,oBAQ3C,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/model-context/makeAssistantToolUI.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC } from \"react\";\nimport {\n type AssistantToolUIProps,\n useAssistantToolUI,\n} from \"./useAssistantToolUI\";\
|
1
|
+
{"version":3,"sources":["../../src/model-context/makeAssistantToolUI.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC } from \"react\";\nimport {\n type AssistantToolUIProps,\n useAssistantToolUI,\n} from \"./useAssistantToolUI\";\n\nexport type AssistantToolUI = FC & {\n unstable_tool: AssistantToolUIProps<any, any>;\n};\n\nexport const makeAssistantToolUI = <TArgs, TResult>(\n tool: AssistantToolUIProps<TArgs, TResult>,\n) => {\n const ToolUI: AssistantToolUI = () => {\n useAssistantToolUI(tool);\n return null;\n };\n ToolUI.unstable_tool = tool;\n return ToolUI;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gCAGO;AAMA,IAAM,sBAAsB,CACjC,SACG;AACH,QAAM,SAA0B,MAAM;AACpC,sDAAmB,IAAI;AACvB,WAAO;AAAA,EACT;AACA,SAAO,gBAAgB;AACvB,SAAO;AACT;","names":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/model-context/makeAssistantToolUI.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC } from \"react\";\nimport {\n type AssistantToolUIProps,\n useAssistantToolUI,\n} from \"./useAssistantToolUI\";\
|
1
|
+
{"version":3,"sources":["../../src/model-context/makeAssistantToolUI.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC } from \"react\";\nimport {\n type AssistantToolUIProps,\n useAssistantToolUI,\n} from \"./useAssistantToolUI\";\n\nexport type AssistantToolUI = FC & {\n unstable_tool: AssistantToolUIProps<any, any>;\n};\n\nexport const makeAssistantToolUI = <TArgs, TResult>(\n tool: AssistantToolUIProps<TArgs, TResult>,\n) => {\n const ToolUI: AssistantToolUI = () => {\n useAssistantToolUI(tool);\n return null;\n };\n ToolUI.unstable_tool = tool;\n return ToolUI;\n};\n"],"mappings":";;;AAGA;AAAA,EAEE;AAAA,OACK;AAMA,IAAM,sBAAsB,CACjC,SACG;AACH,QAAM,SAA0B,MAAM;AACpC,uBAAmB,IAAI;AACvB,WAAO;AAAA,EACT;AACA,SAAO,gBAAgB;AACvB,SAAO;AACT;","names":[]}
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import type { ToolCallContentPartComponent } from "../types/ContentPartComponentTypes";
|
2
2
|
import type { Tool } from "./ModelContextTypes";
|
3
|
-
|
4
|
-
export type AssistantToolProps<TArgs extends ReadonlyJSONObject, TResult> = Tool<TArgs, TResult> & {
|
3
|
+
export type AssistantToolProps<TArgs, TResult> = Tool<TArgs, TResult> & {
|
5
4
|
toolName: string;
|
6
5
|
render?: ToolCallContentPartComponent<TArgs, TResult> | undefined;
|
7
6
|
disabled?: boolean | undefined;
|
8
7
|
};
|
9
|
-
export declare const useAssistantTool: <TArgs
|
8
|
+
export declare const useAssistantTool: <TArgs, TResult>(tool: AssistantToolProps<TArgs, TResult>) => void;
|
10
9
|
//# sourceMappingURL=useAssistantTool.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useAssistantTool.d.ts","sourceRoot":"","sources":["../../src/model-context/useAssistantTool.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;
|
1
|
+
{"version":3,"file":"useAssistantTool.d.ts","sourceRoot":"","sources":["../../src/model-context/useAssistantTool.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,MAAM,kBAAkB,CAAC,KAAK,EAAE,OAAO,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG;IACtE,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,4BAA4B,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAClE,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,KAAK,EAAE,OAAO,QACvC,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,SAwBzC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/model-context/useAssistantTool.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport {\n useAssistantRuntime,\n useToolUIsStore,\n} from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../types/ContentPartComponentTypes\";\nimport type { Tool } from \"./ModelContextTypes\";\
|
1
|
+
{"version":3,"sources":["../../src/model-context/useAssistantTool.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport {\n useAssistantRuntime,\n useToolUIsStore,\n} from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../types/ContentPartComponentTypes\";\nimport type { Tool } from \"./ModelContextTypes\";\n\nexport type AssistantToolProps<TArgs, TResult> = Tool<TArgs, TResult> & {\n toolName: string;\n render?: ToolCallContentPartComponent<TArgs, TResult> | undefined;\n disabled?: boolean | undefined;\n};\n\nexport const useAssistantTool = <TArgs, TResult>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const assistantRuntime = useAssistantRuntime();\n const toolUIsStore = useToolUIsStore();\n\n useEffect(() => {\n return tool.render\n ? toolUIsStore.getState().setToolUI(tool.toolName, tool.render)\n : undefined;\n }, [toolUIsStore, tool.toolName, tool.render]);\n\n useEffect(() => {\n const { toolName, render, disabled, ...rest } = tool;\n if (disabled) return;\n\n const context = {\n tools: {\n [toolName]: rest,\n },\n };\n return assistantRuntime.registerModelContextProvider({\n getModelContext: () => context,\n });\n }, [assistantRuntime, tool]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA0B;AAC1B,8BAGO;AAUA,IAAM,mBAAmB,CAC9B,SACG;AACH,QAAM,uBAAmB,6CAAoB;AAC7C,QAAM,mBAAe,yCAAgB;AAErC,8BAAU,MAAM;AACd,WAAO,KAAK,SACR,aAAa,SAAS,EAAE,UAAU,KAAK,UAAU,KAAK,MAAM,IAC5D;AAAA,EACN,GAAG,CAAC,cAAc,KAAK,UAAU,KAAK,MAAM,CAAC;AAE7C,8BAAU,MAAM;AACd,UAAM,EAAE,UAAU,QAAQ,UAAU,GAAG,KAAK,IAAI;AAChD,QAAI,SAAU;AAEd,UAAM,UAAU;AAAA,MACd,OAAO;AAAA,QACL,CAAC,QAAQ,GAAG;AAAA,MACd;AAAA,IACF;AACA,WAAO,iBAAiB,6BAA6B;AAAA,MACnD,iBAAiB,MAAM;AAAA,IACzB,CAAC;AAAA,EACH,GAAG,CAAC,kBAAkB,IAAI,CAAC;AAC7B;","names":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/model-context/useAssistantTool.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport {\n useAssistantRuntime,\n useToolUIsStore,\n} from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../types/ContentPartComponentTypes\";\nimport type { Tool } from \"./ModelContextTypes\";\
|
1
|
+
{"version":3,"sources":["../../src/model-context/useAssistantTool.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport {\n useAssistantRuntime,\n useToolUIsStore,\n} from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../types/ContentPartComponentTypes\";\nimport type { Tool } from \"./ModelContextTypes\";\n\nexport type AssistantToolProps<TArgs, TResult> = Tool<TArgs, TResult> & {\n toolName: string;\n render?: ToolCallContentPartComponent<TArgs, TResult> | undefined;\n disabled?: boolean | undefined;\n};\n\nexport const useAssistantTool = <TArgs, TResult>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const assistantRuntime = useAssistantRuntime();\n const toolUIsStore = useToolUIsStore();\n\n useEffect(() => {\n return tool.render\n ? toolUIsStore.getState().setToolUI(tool.toolName, tool.render)\n : undefined;\n }, [toolUIsStore, tool.toolName, tool.render]);\n\n useEffect(() => {\n const { toolName, render, disabled, ...rest } = tool;\n if (disabled) return;\n\n const context = {\n tools: {\n [toolName]: rest,\n },\n };\n return assistantRuntime.registerModelContextProvider({\n getModelContext: () => context,\n });\n }, [assistantRuntime, tool]);\n};\n"],"mappings":";;;AAEA,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAUA,IAAM,mBAAmB,CAC9B,SACG;AACH,QAAM,mBAAmB,oBAAoB;AAC7C,QAAM,eAAe,gBAAgB;AAErC,YAAU,MAAM;AACd,WAAO,KAAK,SACR,aAAa,SAAS,EAAE,UAAU,KAAK,UAAU,KAAK,MAAM,IAC5D;AAAA,EACN,GAAG,CAAC,cAAc,KAAK,UAAU,KAAK,MAAM,CAAC;AAE7C,YAAU,MAAM;AACd,UAAM,EAAE,UAAU,QAAQ,UAAU,GAAG,KAAK,IAAI;AAChD,QAAI,SAAU;AAEd,UAAM,UAAU;AAAA,MACd,OAAO;AAAA,QACL,CAAC,QAAQ,GAAG;AAAA,MACd;AAAA,IACF;AACA,WAAO,iBAAiB,6BAA6B;AAAA,MACnD,iBAAiB,MAAM;AAAA,IACzB,CAAC;AAAA,EACH,GAAG,CAAC,kBAAkB,IAAI,CAAC;AAC7B;","names":[]}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import type { ToolCallContentPartComponent } from "../types/ContentPartComponentTypes";
|
2
|
-
|
3
|
-
export type AssistantToolUIProps<TArgs extends ReadonlyJSONObject, TResult> = {
|
2
|
+
export type AssistantToolUIProps<TArgs, TResult> = {
|
4
3
|
toolName: string;
|
5
4
|
render: ToolCallContentPartComponent<TArgs, TResult>;
|
6
5
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useAssistantToolUI.d.ts","sourceRoot":"","sources":["../../src/model-context/useAssistantToolUI.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;
|
1
|
+
{"version":3,"file":"useAssistantToolUI.d.ts","sourceRoot":"","sources":["../../src/model-context/useAssistantToolUI.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAEvF,MAAM,MAAM,oBAAoB,CAAC,KAAK,EAAE,OAAO,IAAI;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,4BAA4B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;CACtD,CAAC;AAEF,eAAO,MAAM,kBAAkB,SACvB,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,SAO5C,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/model-context/useAssistantToolUI.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useToolUIsStore } from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../types/ContentPartComponentTypes\";\
|
1
|
+
{"version":3,"sources":["../../src/model-context/useAssistantToolUI.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useToolUIsStore } from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../types/ContentPartComponentTypes\";\n\nexport type AssistantToolUIProps<TArgs, TResult> = {\n toolName: string;\n render: ToolCallContentPartComponent<TArgs, TResult>;\n};\n\nexport const useAssistantToolUI = (\n tool: AssistantToolUIProps<any, any> | null,\n) => {\n const toolUIsStore = useToolUIsStore();\n useEffect(() => {\n if (!tool) return;\n return toolUIsStore.getState().setToolUI(tool.toolName, tool.render);\n }, [toolUIsStore, tool?.toolName, tool?.render]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA0B;AAC1B,8BAAgC;AAQzB,IAAM,qBAAqB,CAChC,SACG;AACH,QAAM,mBAAe,yCAAgB;AACrC,8BAAU,MAAM;AACd,QAAI,CAAC,KAAM;AACX,WAAO,aAAa,SAAS,EAAE,UAAU,KAAK,UAAU,KAAK,MAAM;AAAA,EACrE,GAAG,CAAC,cAAc,MAAM,UAAU,MAAM,MAAM,CAAC;AACjD;","names":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/model-context/useAssistantToolUI.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useToolUIsStore } from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../types/ContentPartComponentTypes\";\
|
1
|
+
{"version":3,"sources":["../../src/model-context/useAssistantToolUI.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useToolUIsStore } from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../types/ContentPartComponentTypes\";\n\nexport type AssistantToolUIProps<TArgs, TResult> = {\n toolName: string;\n render: ToolCallContentPartComponent<TArgs, TResult>;\n};\n\nexport const useAssistantToolUI = (\n tool: AssistantToolUIProps<any, any> | null,\n) => {\n const toolUIsStore = useToolUIsStore();\n useEffect(() => {\n if (!tool) return;\n return toolUIsStore.getState().setToolUI(tool.toolName, tool.render);\n }, [toolUIsStore, tool?.toolName, tool?.render]);\n};\n"],"mappings":";;;AAEA,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAQzB,IAAM,qBAAqB,CAChC,SACG;AACH,QAAM,eAAe,gBAAgB;AACrC,YAAU,MAAM;AACd,QAAI,CAAC,KAAM;AACX,WAAO,aAAa,SAAS,EAAE,UAAU,KAAK,UAAU,KAAK,MAAM;AAAA,EACrE,GAAG,CAAC,cAAc,MAAM,UAAU,MAAM,MAAM,CAAC;AACjD;","names":[]}
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { FC } from "react";
|
2
2
|
import { ToolCallContentPartProps } from "../types";
|
3
|
-
|
4
|
-
export declare const useInlineRender: <TArgs extends ReadonlyJSONObject, TResult>(toolUI: FC<ToolCallContentPartProps<TArgs, TResult>>) => FC<ToolCallContentPartProps<TArgs, TResult>>;
|
3
|
+
export declare const useInlineRender: <TArgs, TResult>(toolUI: FC<ToolCallContentPartProps<TArgs, TResult>>) => FC<ToolCallContentPartProps<TArgs, TResult>>;
|
5
4
|
//# sourceMappingURL=useInlineRender.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useInlineRender.d.ts","sourceRoot":"","sources":["../../src/model-context/useInlineRender.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAoC,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;
|
1
|
+
{"version":3,"file":"useInlineRender.d.ts","sourceRoot":"","sources":["../../src/model-context/useInlineRender.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAoC,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAGpD,eAAO,MAAM,eAAe,GAAI,KAAK,EAAE,OAAO,UACpC,EAAE,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,KACnD,EAAE,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAC,CAW7C,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/model-context/useInlineRender.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC, useCallback, useEffect, useState } from \"react\";\nimport { ToolCallContentPartProps } from \"../types\";\nimport { create } from \"zustand\";\
|
1
|
+
{"version":3,"sources":["../../src/model-context/useInlineRender.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC, useCallback, useEffect, useState } from \"react\";\nimport { ToolCallContentPartProps } from \"../types\";\nimport { create } from \"zustand\";\n\nexport const useInlineRender = <TArgs, TResult>(\n toolUI: FC<ToolCallContentPartProps<TArgs, TResult>>,\n): FC<ToolCallContentPartProps<TArgs, TResult>> => {\n const [useToolUI] = useState(() => create(() => toolUI));\n\n useEffect(() => {\n useToolUI.setState(toolUI);\n });\n\n return useCallback((args) => {\n const toolUI = useToolUI();\n return toolUI(args);\n }, []);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAqD;AAErD,qBAAuB;AAEhB,IAAM,kBAAkB,CAC7B,WACiD;AACjD,QAAM,CAAC,SAAS,QAAI,uBAAS,UAAM,uBAAO,MAAM,MAAM,CAAC;AAEvD,8BAAU,MAAM;AACd,cAAU,SAAS,MAAM;AAAA,EAC3B,CAAC;AAED,aAAO,0BAAY,CAAC,SAAS;AAC3B,UAAMA,UAAS,UAAU;AACzB,WAAOA,QAAO,IAAI;AAAA,EACpB,GAAG,CAAC,CAAC;AACP;","names":["toolUI"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/model-context/useInlineRender.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC, useCallback, useEffect, useState } from \"react\";\nimport { ToolCallContentPartProps } from \"../types\";\nimport { create } from \"zustand\";\
|
1
|
+
{"version":3,"sources":["../../src/model-context/useInlineRender.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC, useCallback, useEffect, useState } from \"react\";\nimport { ToolCallContentPartProps } from \"../types\";\nimport { create } from \"zustand\";\n\nexport const useInlineRender = <TArgs, TResult>(\n toolUI: FC<ToolCallContentPartProps<TArgs, TResult>>,\n): FC<ToolCallContentPartProps<TArgs, TResult>> => {\n const [useToolUI] = useState(() => create(() => toolUI));\n\n useEffect(() => {\n useToolUI.setState(toolUI);\n });\n\n return useCallback((args) => {\n const toolUI = useToolUI();\n return toolUI(args);\n }, []);\n};\n"],"mappings":";;;AAEA,SAAa,aAAa,WAAW,gBAAgB;AAErD,SAAS,cAAc;AAEhB,IAAM,kBAAkB,CAC7B,WACiD;AACjD,QAAM,CAAC,SAAS,IAAI,SAAS,MAAM,OAAO,MAAM,MAAM,CAAC;AAEvD,YAAU,MAAM;AACd,cAAU,SAAS,MAAM;AAAA,EAC3B,CAAC;AAED,SAAO,YAAY,CAAC,SAAS;AAC3B,UAAMA,UAAS,UAAU;AACzB,WAAOA,QAAO,IAAI;AAAA,EACpB,GAAG,CAAC,CAAC;AACP;","names":["toolUI"]}
|
@@ -23,5 +23,5 @@ export type ToolResultStreamPart = LanguageModelV1StreamPart | {
|
|
23
23
|
};
|
24
24
|
isContinued: boolean;
|
25
25
|
};
|
26
|
-
export declare function toolResultStream(tools: Record<string, Tool
|
26
|
+
export declare function toolResultStream(tools: Record<string, Tool<any, any>> | undefined, abortSignal: AbortSignal): TransformStream<ToolResultStreamPart, ToolResultStreamPart>;
|
27
27
|
//# sourceMappingURL=toolResultStream.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"toolResultStream.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/edge/streams/toolResultStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,MAAM,MAAM,oBAAoB,GAC5B,yBAAyB,GACzB;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,WAAW,EAAE,iBAAiB,EAAE,CAAC;CAClC,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,iBAAiB,EAAE,CAAC;CAC3B,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,YAAY,EAAE,UAAU,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,YAAY,EACR,MAAM,GACN,QAAQ,GACR,gBAAgB,GAChB,YAAY,GACZ,OAAO,GACP,OAAO,GACP,SAAS,CAAC;IACd,KAAK,EAAE;QACL,YAAY,EAAE,MAAM,CAAC;QACrB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEN,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,SAAS,
|
1
|
+
{"version":3,"file":"toolResultStream.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/edge/streams/toolResultStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,MAAM,MAAM,oBAAoB,GAC5B,yBAAyB,GACzB;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,WAAW,EAAE,iBAAiB,EAAE,CAAC;CAClC,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,iBAAiB,EAAE,CAAC;CAC3B,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,YAAY,EAAE,UAAU,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,YAAY,EACR,MAAM,GACN,QAAQ,GACR,gBAAgB,GAChB,YAAY,GACZ,OAAO,GACP,OAAO,GACP,SAAS,CAAC;IACd,KAAK,EAAE;QACL,YAAY,EAAE,MAAM,CAAC;QACrB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEN,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,SAAS,EACjD,WAAW,EAAE,WAAW,+DA6GzB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/edge/streams/toolResultStream.ts"],"sourcesContent":["import { Tool } from \"../../../model-context/ModelContextTypes\";\nimport { LanguageModelV1StreamPart } from \"@ai-sdk/provider\";\nimport { z } from \"zod\";\nimport sjson from \"secure-json-parse\";\nimport { ReadonlyJSONValue } from \"../../../utils/json/json-value\";\n\nexport type ToolResultStreamPart =\n | LanguageModelV1StreamPart\n | {\n type: \"annotations\";\n annotations: ReadonlyJSONValue[];\n }\n | {\n type: \"data\";\n data: ReadonlyJSONValue[];\n }\n | {\n type: \"tool-result\";\n toolCallType: \"function\";\n toolCallId: string;\n toolName: string;\n result: unknown;\n isError?: boolean;\n }\n | {\n type: \"step-finish\";\n finishReason:\n | \"stop\"\n | \"length\"\n | \"content-filter\"\n | \"tool-calls\"\n | \"error\"\n | \"other\"\n | \"unknown\";\n usage: {\n promptTokens: number;\n completionTokens: number;\n };\n isContinued: boolean;\n };\n\nexport function toolResultStream(\n tools: Record<string, Tool
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/edge/streams/toolResultStream.ts"],"sourcesContent":["import { Tool } from \"../../../model-context/ModelContextTypes\";\nimport { LanguageModelV1StreamPart } from \"@ai-sdk/provider\";\nimport { z } from \"zod\";\nimport sjson from \"secure-json-parse\";\nimport { ReadonlyJSONValue } from \"../../../utils/json/json-value\";\n\nexport type ToolResultStreamPart =\n | LanguageModelV1StreamPart\n | {\n type: \"annotations\";\n annotations: ReadonlyJSONValue[];\n }\n | {\n type: \"data\";\n data: ReadonlyJSONValue[];\n }\n | {\n type: \"tool-result\";\n toolCallType: \"function\";\n toolCallId: string;\n toolName: string;\n result: unknown;\n isError?: boolean;\n }\n | {\n type: \"step-finish\";\n finishReason:\n | \"stop\"\n | \"length\"\n | \"content-filter\"\n | \"tool-calls\"\n | \"error\"\n | \"other\"\n | \"unknown\";\n usage: {\n promptTokens: number;\n completionTokens: number;\n };\n isContinued: boolean;\n };\n\nexport function toolResultStream(\n tools: Record<string, Tool<any, any>> | undefined,\n abortSignal: AbortSignal,\n) {\n const toolCallExecutions = new Map<string, Promise<any>>();\n\n return new TransformStream<ToolResultStreamPart, ToolResultStreamPart>({\n transform(chunk, controller) {\n // forward everything\n controller.enqueue(chunk);\n\n // handle tool calls\n const chunkType = chunk.type;\n switch (chunkType) {\n case \"tool-call\": {\n const { toolCallId, toolCallType, toolName, args: argsText } = chunk;\n const tool = tools?.[toolName];\n if (!tool || !tool.execute) return;\n\n let args;\n try {\n args = sjson.parse(argsText);\n } catch (e) {\n controller.enqueue({\n type: \"tool-result\",\n toolCallType,\n toolCallId,\n toolName,\n result:\n \"Function parameter parsing failed. \" +\n JSON.stringify((e as Error).message),\n isError: true,\n });\n return;\n }\n\n toolCallExecutions.set(\n toolCallId,\n (async () => {\n if (!tool.execute) return;\n\n let executeFn = tool.execute;\n\n if (tool.parameters instanceof z.ZodType) {\n const result = tool.parameters.safeParse(args);\n if (!result.success) {\n executeFn =\n tool.experimental_onSchemaValidationError ??\n (() => {\n throw (\n \"Function parameter validation failed. \" +\n JSON.stringify(result.error.issues)\n );\n });\n }\n }\n\n try {\n const result = await executeFn(args, {\n toolCallId,\n abortSignal,\n });\n\n controller.enqueue({\n type: \"tool-result\",\n toolCallType,\n toolCallId,\n toolName,\n result: result === undefined ? \"<no result>\" : result,\n });\n } catch (error) {\n controller.enqueue({\n type: \"tool-result\",\n toolCallType,\n toolCallId,\n toolName,\n result: \"Error: \" + error,\n isError: true,\n });\n } finally {\n toolCallExecutions.delete(toolCallId);\n }\n })(),\n );\n break;\n }\n\n // ignore other parts\n case \"text-delta\":\n case \"reasoning\":\n case \"tool-call-delta\":\n case \"tool-result\":\n case \"step-finish\":\n case \"finish\":\n case \"error\":\n case \"response-metadata\":\n case \"annotations\":\n case \"data\":\n break;\n\n default: {\n const unhandledType: never = chunkType;\n throw new Error(`Unhandled chunk type: ${unhandledType}`);\n }\n }\n },\n\n async flush() {\n await Promise.all(toolCallExecutions.values());\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAkB;AAClB,+BAAkB;AAsCX,SAAS,iBACd,OACA,aACA;AACA,QAAM,qBAAqB,oBAAI,IAA0B;AAEzD,SAAO,IAAI,gBAA4D;AAAA,IACrE,UAAU,OAAO,YAAY;AAE3B,iBAAW,QAAQ,KAAK;AAGxB,YAAM,YAAY,MAAM;AACxB,cAAQ,WAAW;AAAA,QACjB,KAAK,aAAa;AAChB,gBAAM,EAAE,YAAY,cAAc,UAAU,MAAM,SAAS,IAAI;AAC/D,gBAAM,OAAO,QAAQ,QAAQ;AAC7B,cAAI,CAAC,QAAQ,CAAC,KAAK,QAAS;AAE5B,cAAI;AACJ,cAAI;AACF,mBAAO,yBAAAA,QAAM,MAAM,QAAQ;AAAA,UAC7B,SAAS,GAAG;AACV,uBAAW,QAAQ;AAAA,cACjB,MAAM;AAAA,cACN;AAAA,cACA;AAAA,cACA;AAAA,cACA,QACE,wCACA,KAAK,UAAW,EAAY,OAAO;AAAA,cACrC,SAAS;AAAA,YACX,CAAC;AACD;AAAA,UACF;AAEA,6BAAmB;AAAA,YACjB;AAAA,aACC,YAAY;AACX,kBAAI,CAAC,KAAK,QAAS;AAEnB,kBAAI,YAAY,KAAK;AAErB,kBAAI,KAAK,sBAAsB,aAAE,SAAS;AACxC,sBAAM,SAAS,KAAK,WAAW,UAAU,IAAI;AAC7C,oBAAI,CAAC,OAAO,SAAS;AACnB,8BACE,KAAK,yCACJ,MAAM;AACL,0BACE,2CACA,KAAK,UAAU,OAAO,MAAM,MAAM;AAAA,kBAEtC;AAAA,gBACJ;AAAA,cACF;AAEA,kBAAI;AACF,sBAAM,SAAS,MAAM,UAAU,MAAM;AAAA,kBACnC;AAAA,kBACA;AAAA,gBACF,CAAC;AAED,2BAAW,QAAQ;AAAA,kBACjB,MAAM;AAAA,kBACN;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA,QAAQ,WAAW,SAAY,gBAAgB;AAAA,gBACjD,CAAC;AAAA,cACH,SAAS,OAAO;AACd,2BAAW,QAAQ;AAAA,kBACjB,MAAM;AAAA,kBACN;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA,QAAQ,YAAY;AAAA,kBACpB,SAAS;AAAA,gBACX,CAAC;AAAA,cACH,UAAE;AACA,mCAAmB,OAAO,UAAU;AAAA,cACtC;AAAA,YACF,GAAG;AAAA,UACL;AACA;AAAA,QACF;AAAA;AAAA,QAGA,KAAK;AAAA,QACL,KAAK;AAAA,QACL,KAAK;AAAA,QACL,KAAK;AAAA,QACL,KAAK;AAAA,QACL,KAAK;AAAA,QACL,KAAK;AAAA,QACL,KAAK;AAAA,QACL,KAAK;AAAA,QACL,KAAK;AACH;AAAA,QAEF,SAAS;AACP,gBAAM,gBAAuB;AAC7B,gBAAM,IAAI,MAAM,yBAAyB,aAAa,EAAE;AAAA,QAC1D;AAAA,MACF;AAAA,IACF;AAAA,IAEA,MAAM,QAAQ;AACZ,YAAM,QAAQ,IAAI,mBAAmB,OAAO,CAAC;AAAA,IAC/C;AAAA,EACF,CAAC;AACH;","names":["sjson"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/edge/streams/toolResultStream.ts"],"sourcesContent":["import { Tool } from \"../../../model-context/ModelContextTypes\";\nimport { LanguageModelV1StreamPart } from \"@ai-sdk/provider\";\nimport { z } from \"zod\";\nimport sjson from \"secure-json-parse\";\nimport { ReadonlyJSONValue } from \"../../../utils/json/json-value\";\n\nexport type ToolResultStreamPart =\n | LanguageModelV1StreamPart\n | {\n type: \"annotations\";\n annotations: ReadonlyJSONValue[];\n }\n | {\n type: \"data\";\n data: ReadonlyJSONValue[];\n }\n | {\n type: \"tool-result\";\n toolCallType: \"function\";\n toolCallId: string;\n toolName: string;\n result: unknown;\n isError?: boolean;\n }\n | {\n type: \"step-finish\";\n finishReason:\n | \"stop\"\n | \"length\"\n | \"content-filter\"\n | \"tool-calls\"\n | \"error\"\n | \"other\"\n | \"unknown\";\n usage: {\n promptTokens: number;\n completionTokens: number;\n };\n isContinued: boolean;\n };\n\nexport function toolResultStream(\n tools: Record<string, Tool
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/edge/streams/toolResultStream.ts"],"sourcesContent":["import { Tool } from \"../../../model-context/ModelContextTypes\";\nimport { LanguageModelV1StreamPart } from \"@ai-sdk/provider\";\nimport { z } from \"zod\";\nimport sjson from \"secure-json-parse\";\nimport { ReadonlyJSONValue } from \"../../../utils/json/json-value\";\n\nexport type ToolResultStreamPart =\n | LanguageModelV1StreamPart\n | {\n type: \"annotations\";\n annotations: ReadonlyJSONValue[];\n }\n | {\n type: \"data\";\n data: ReadonlyJSONValue[];\n }\n | {\n type: \"tool-result\";\n toolCallType: \"function\";\n toolCallId: string;\n toolName: string;\n result: unknown;\n isError?: boolean;\n }\n | {\n type: \"step-finish\";\n finishReason:\n | \"stop\"\n | \"length\"\n | \"content-filter\"\n | \"tool-calls\"\n | \"error\"\n | \"other\"\n | \"unknown\";\n usage: {\n promptTokens: number;\n completionTokens: number;\n };\n isContinued: boolean;\n };\n\nexport function toolResultStream(\n tools: Record<string, Tool<any, any>> | undefined,\n abortSignal: AbortSignal,\n) {\n const toolCallExecutions = new Map<string, Promise<any>>();\n\n return new TransformStream<ToolResultStreamPart, ToolResultStreamPart>({\n transform(chunk, controller) {\n // forward everything\n controller.enqueue(chunk);\n\n // handle tool calls\n const chunkType = chunk.type;\n switch (chunkType) {\n case \"tool-call\": {\n const { toolCallId, toolCallType, toolName, args: argsText } = chunk;\n const tool = tools?.[toolName];\n if (!tool || !tool.execute) return;\n\n let args;\n try {\n args = sjson.parse(argsText);\n } catch (e) {\n controller.enqueue({\n type: \"tool-result\",\n toolCallType,\n toolCallId,\n toolName,\n result:\n \"Function parameter parsing failed. \" +\n JSON.stringify((e as Error).message),\n isError: true,\n });\n return;\n }\n\n toolCallExecutions.set(\n toolCallId,\n (async () => {\n if (!tool.execute) return;\n\n let executeFn = tool.execute;\n\n if (tool.parameters instanceof z.ZodType) {\n const result = tool.parameters.safeParse(args);\n if (!result.success) {\n executeFn =\n tool.experimental_onSchemaValidationError ??\n (() => {\n throw (\n \"Function parameter validation failed. \" +\n JSON.stringify(result.error.issues)\n );\n });\n }\n }\n\n try {\n const result = await executeFn(args, {\n toolCallId,\n abortSignal,\n });\n\n controller.enqueue({\n type: \"tool-result\",\n toolCallType,\n toolCallId,\n toolName,\n result: result === undefined ? \"<no result>\" : result,\n });\n } catch (error) {\n controller.enqueue({\n type: \"tool-result\",\n toolCallType,\n toolCallId,\n toolName,\n result: \"Error: \" + error,\n isError: true,\n });\n } finally {\n toolCallExecutions.delete(toolCallId);\n }\n })(),\n );\n break;\n }\n\n // ignore other parts\n case \"text-delta\":\n case \"reasoning\":\n case \"tool-call-delta\":\n case \"tool-result\":\n case \"step-finish\":\n case \"finish\":\n case \"error\":\n case \"response-metadata\":\n case \"annotations\":\n case \"data\":\n break;\n\n default: {\n const unhandledType: never = chunkType;\n throw new Error(`Unhandled chunk type: ${unhandledType}`);\n }\n }\n },\n\n async flush() {\n await Promise.all(toolCallExecutions.values());\n },\n });\n}\n"],"mappings":";AAEA,SAAS,SAAS;AAClB,OAAO,WAAW;AAsCX,SAAS,iBACd,OACA,aACA;AACA,QAAM,qBAAqB,oBAAI,IAA0B;AAEzD,SAAO,IAAI,gBAA4D;AAAA,IACrE,UAAU,OAAO,YAAY;AAE3B,iBAAW,QAAQ,KAAK;AAGxB,YAAM,YAAY,MAAM;AACxB,cAAQ,WAAW;AAAA,QACjB,KAAK,aAAa;AAChB,gBAAM,EAAE,YAAY,cAAc,UAAU,MAAM,SAAS,IAAI;AAC/D,gBAAM,OAAO,QAAQ,QAAQ;AAC7B,cAAI,CAAC,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AAA,QACL,KAAK;AAAA,QACL,KAAK;AACH;AAAA,QAEF,SAAS;AACP,gBAAM,gBAAuB;AAC7B,gBAAM,IAAI,MAAM,yBAAyB,aAAa,EAAE;AAAA,QAC1D;AAAA,MACF;AAAA,IACF;AAAA,IAEA,MAAM,QAAQ;AACZ,YAAM,QAAQ,IAAI,mBAAmB,OAAO,CAAC;AAAA,IAC/C;AAAA,EACF,CAAC;AACH;","names":[]}
|
@@ -67,7 +67,7 @@ export type UIContentPart = {
|
|
67
67
|
readonly type: "ui";
|
68
68
|
readonly display: ReactNode;
|
69
69
|
};
|
70
|
-
export type CoreToolCallContentPart<TArgs
|
70
|
+
export type CoreToolCallContentPart<TArgs = ReadonlyJSONObject, TResult = unknown> = {
|
71
71
|
readonly type: "tool-call";
|
72
72
|
readonly toolCallId: string;
|
73
73
|
readonly toolName: string;
|
@@ -75,7 +75,7 @@ export type CoreToolCallContentPart<TArgs extends ReadonlyJSONObject = ReadonlyJ
|
|
75
75
|
readonly result?: TResult | undefined;
|
76
76
|
readonly isError?: boolean | undefined;
|
77
77
|
};
|
78
|
-
export type ToolCallContentPart<TArgs
|
78
|
+
export type ToolCallContentPart<TArgs = ReadonlyJSONObject, TResult = unknown> = CoreToolCallContentPart<TArgs, TResult> & {
|
79
79
|
readonly argsText: string;
|
80
80
|
};
|
81
81
|
export type ThreadUserContentPart = TextContentPart | ImageContentPart | FileContentPart | Unstable_AudioContentPart | UIContentPart;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AssistantTypes.d.ts","sourceRoot":"","sources":["../../src/types/AssistantTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,Q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AAE,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,SAAS,wBAAwB,EAAE,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB,iBAAiB,GACjB,eAAe,GACf,oBAAoB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/types/AssistantTypes.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { CompleteAttachment } from \"./AttachmentTypes\";\nimport {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"../utils/json/json-value\";\n\nexport type MessageRole = \"user\" | \"assistant\" | \"system\";\n\nexport type TextContentPart = {\n readonly type: \"text\";\n readonly text: string;\n};\n\nexport type ReasoningContentPart = {\n readonly type: \"reasoning\";\n readonly text: string;\n};\n\
|
1
|
+
{"version":3,"sources":["../../src/types/AssistantTypes.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { CompleteAttachment } from \"./AttachmentTypes\";\nimport {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"../utils/json/json-value\";\n\nexport type MessageRole = \"user\" | \"assistant\" | \"system\";\n\nexport type TextContentPart = {\n readonly type: \"text\";\n readonly text: string;\n};\n\nexport type ReasoningContentPart = {\n readonly type: \"reasoning\";\n readonly text: string;\n};\n\nexport type ImageContentPart = {\n readonly type: \"image\";\n readonly image: string;\n};\n\nexport type FileContentPart = {\n readonly type: \"file\";\n readonly data: string;\n readonly mimeType: string;\n};\n\nexport type Unstable_AudioContentPart = {\n readonly type: \"audio\";\n readonly audio: {\n readonly data: string;\n readonly format: \"mp3\" | \"wav\";\n };\n};\n\n/**\n * @deprecated UI content parts are deprecated and will be removed in v0.8.0.\n * Migration guide for external-store users using UI content parts:\n * If you must, store UI elements on your external store messages, update your\n * external store converter:\n * ```ts\n * const UI_PLACEHOLDER = Object.freeze({ type: \"text\", text: \"UI content placeholder\" });\n * const convertMessage = (message: TMessage): ThreadMessageLike => ({\n * content: [\n * // other content parts,\n * UI_PLACEHOLDER\n * ],\n * });\n * ```\n *\n * Then, define a custom `TextContentPartComponent`:\n *\n * ```tsx\n * const MyText: FC = () => {\n * const isUIPlaceholder = useContentPart(p => p === UI_PLACEHOLDER);\n *\n * // this assumes that you have a `display` field on your original message objects before conversion.\n * const ui = useMessage(m => isUIPlaceholder ? getExternalStoreMessage(m).display : undefined);\n * if (ui) {\n * return ui;\n * }\n *\n * return <MarkdownText />; // your default text component\n * }\n * ```\n *\n * Pass this component to your Thread:\n *\n * ```tsx\n * <Thread assistantMessage={{ components: { Text: MyText } }} userMessage={{ components: { Text: MyText } }} />\n * ```\n */\nexport type UIContentPart = {\n readonly type: \"ui\";\n readonly display: ReactNode;\n};\n\nexport type CoreToolCallContentPart<\n TArgs = ReadonlyJSONObject,\n TResult = unknown,\n> = {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly args: TArgs;\n readonly result?: TResult | undefined;\n readonly isError?: boolean | undefined;\n};\n\nexport type ToolCallContentPart<\n TArgs = ReadonlyJSONObject,\n TResult = unknown,\n> = CoreToolCallContentPart<TArgs, TResult> & {\n readonly argsText: string;\n};\n\nexport type ThreadUserContentPart =\n | TextContentPart\n | ImageContentPart\n | FileContentPart\n | Unstable_AudioContentPart\n | UIContentPart;\n\nexport type ThreadAssistantContentPart =\n | TextContentPart\n | ReasoningContentPart\n | ToolCallContentPart\n | UIContentPart;\n\ntype MessageCommonProps = {\n readonly id: string;\n readonly createdAt: Date;\n};\n\nexport type ThreadStep = {\n readonly usage?:\n | {\n readonly promptTokens: number;\n readonly completionTokens: number;\n }\n | undefined;\n};\n\nexport type ContentPartStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"complete\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ToolCallContentPartStatus =\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | ContentPartStatus;\n\nexport type MessageStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | {\n readonly type: \"complete\";\n readonly reason: \"stop\" | \"unknown\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"tool-calls\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: ReadonlyJSONValue;\n };\n\nexport type ThreadSystemMessage = MessageCommonProps & {\n readonly role: \"system\";\n readonly content: readonly [TextContentPart];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadUserMessage = MessageCommonProps & {\n readonly role: \"user\";\n readonly content: readonly ThreadUserContentPart[];\n readonly attachments: readonly CompleteAttachment[];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadAssistantMessage = MessageCommonProps & {\n readonly role: \"assistant\";\n readonly content: readonly ThreadAssistantContentPart[];\n readonly status: MessageStatus;\n readonly metadata: {\n readonly unstable_annotations: readonly ReadonlyJSONValue[];\n readonly unstable_data: readonly ReadonlyJSONValue[];\n readonly steps: readonly ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type RunConfig = {\n // TODO allow user customization via global type overrides\n readonly custom?: Record<string, unknown>;\n};\n\nexport type AppendMessage = CoreMessage & {\n parentId: string | null;\n\n /** The ID of the message that was edited or undefined. */\n sourceId: string | null;\n runConfig: RunConfig | undefined;\n\n attachments: readonly CompleteAttachment[];\n startRun?: boolean | undefined;\n};\n\ntype BaseThreadMessage = {\n readonly status?: ThreadAssistantMessage[\"status\"];\n readonly metadata: {\n readonly unstable_annotations?: readonly ReadonlyJSONValue[];\n readonly unstable_data?: readonly ReadonlyJSONValue[];\n readonly steps?: readonly ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n readonly attachments?: ThreadUserMessage[\"attachments\"];\n};\n\nexport type ThreadMessage = BaseThreadMessage &\n (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);\n\n/** Core Message Types (without UI content parts) */\n\nexport type CoreUserContentPart =\n | TextContentPart\n | ImageContentPart\n | FileContentPart\n | Unstable_AudioContentPart;\nexport type CoreAssistantContentPart =\n | TextContentPart\n | CoreToolCallContentPart;\n\nexport type CoreSystemMessage = {\n role: \"system\";\n content: readonly [TextContentPart];\n};\n\nexport type CoreUserMessage = {\n role: \"user\";\n content: readonly CoreUserContentPart[];\n};\n\nexport type CoreAssistantMessage = {\n role: \"assistant\";\n content: readonly CoreAssistantContentPart[];\n};\n\nexport type CoreMessage =\n | CoreSystemMessage\n | CoreUserMessage\n | CoreAssistantMessage;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import type { ComponentType } from "react";
|
2
2
|
import type { ContentPartStatus, FileContentPart, ImageContentPart, ReasoningContentPart, TextContentPart, ToolCallContentPart, UIContentPart, Unstable_AudioContentPart } from "./AssistantTypes";
|
3
3
|
import { ContentPartState } from "../api/ContentPartRuntime";
|
4
|
-
import { ReadonlyJSONObject } from "../utils/json/json-value";
|
5
4
|
export type EmptyContentPartProps = {
|
6
5
|
status: ContentPartStatus;
|
7
6
|
};
|
@@ -18,8 +17,8 @@ export type Unstable_AudioContentPartProps = ContentPartState & Unstable_AudioCo
|
|
18
17
|
export type Unstable_AudioContentPartComponent = ComponentType<Unstable_AudioContentPartProps>;
|
19
18
|
export type UIContentPartProps = ContentPartState & UIContentPart;
|
20
19
|
export type UIContentPartComponent = ComponentType<UIContentPartProps>;
|
21
|
-
export type ToolCallContentPartProps<TArgs
|
20
|
+
export type ToolCallContentPartProps<TArgs = any, TResult = unknown> = ContentPartState & ToolCallContentPart<TArgs, TResult> & {
|
22
21
|
addResult: (result: any) => void;
|
23
22
|
};
|
24
|
-
export type ToolCallContentPartComponent<TArgs
|
23
|
+
export type ToolCallContentPartComponent<TArgs = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
|
25
24
|
//# sourceMappingURL=ContentPartComponentTypes.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ContentPartComponentTypes.d.ts","sourceRoot":"","sources":["../../src/types/ContentPartComponentTypes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,yBAAyB,EAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;
|
1
|
+
{"version":3,"file":"ContentPartComponentTypes.d.ts","sourceRoot":"","sources":["../../src/types/ContentPartComponentTypes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,yBAAyB,EAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,iBAAiB,CAAC;CAC3B,CAAC;AACF,MAAM,MAAM,yBAAyB,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC;AAE7E,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG,eAAe,CAAC;AACtE,MAAM,MAAM,wBAAwB,GAAG,aAAa,CAAC,oBAAoB,CAAC,CAAC;AAE3E,MAAM,MAAM,yBAAyB,GAAG,gBAAgB,GAAG,oBAAoB,CAAC;AAChF,MAAM,MAAM,6BAA6B,GACvC,aAAa,CAAC,yBAAyB,CAAC,CAAC;AAE3C,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AACxE,MAAM,MAAM,yBAAyB,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC;AAE7E,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG,eAAe,CAAC;AACtE,MAAM,MAAM,wBAAwB,GAAG,aAAa,CAAC,oBAAoB,CAAC,CAAC;AAE3E,MAAM,MAAM,8BAA8B,GAAG,gBAAgB,GAC3D,yBAAyB,CAAC;AAC5B,MAAM,MAAM,kCAAkC,GAC5C,aAAa,CAAC,8BAA8B,CAAC,CAAC;AAEhD,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAClE,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAAC;AAEvE,MAAM,MAAM,wBAAwB,CAClC,KAAK,GAAG,GAAG,EACX,OAAO,GAAG,OAAO,IACf,gBAAgB,GAClB,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG;IACpC,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;CAClC,CAAC;AAEJ,MAAM,MAAM,4BAA4B,CACtC,KAAK,GAAG,GAAG,EACX,OAAO,GAAG,GAAG,IACX,aAAa,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/types/ContentPartComponentTypes.tsx"],"sourcesContent":["import type { ComponentType } from \"react\";\nimport type {\n ContentPartStatus,\n FileContentPart,\n ImageContentPart,\n ReasoningContentPart,\n TextContentPart,\n ToolCallContentPart,\n UIContentPart,\n Unstable_AudioContentPart,\n} from \"./AssistantTypes\";\nimport { ContentPartState } from \"../api/ContentPartRuntime\";\
|
1
|
+
{"version":3,"sources":["../../src/types/ContentPartComponentTypes.tsx"],"sourcesContent":["import type { ComponentType } from \"react\";\nimport type {\n ContentPartStatus,\n FileContentPart,\n ImageContentPart,\n ReasoningContentPart,\n TextContentPart,\n ToolCallContentPart,\n UIContentPart,\n Unstable_AudioContentPart,\n} from \"./AssistantTypes\";\nimport { ContentPartState } from \"../api/ContentPartRuntime\";\n\nexport type EmptyContentPartProps = {\n status: ContentPartStatus;\n};\nexport type EmptyContentPartComponent = ComponentType<EmptyContentPartProps>;\n\nexport type TextContentPartProps = ContentPartState & TextContentPart;\nexport type TextContentPartComponent = ComponentType<TextContentPartProps>;\n\nexport type ReasoningContentPartProps = ContentPartState & ReasoningContentPart;\nexport type ReasoningContentPartComponent =\n ComponentType<ReasoningContentPartProps>;\n\nexport type ImageContentPartProps = ContentPartState & ImageContentPart;\nexport type ImageContentPartComponent = ComponentType<ImageContentPartProps>;\n\nexport type FileContentPartProps = ContentPartState & FileContentPart;\nexport type FileContentPartComponent = ComponentType<FileContentPartProps>;\n\nexport type Unstable_AudioContentPartProps = ContentPartState &\n Unstable_AudioContentPart;\nexport type Unstable_AudioContentPartComponent =\n ComponentType<Unstable_AudioContentPartProps>;\n\nexport type UIContentPartProps = ContentPartState & UIContentPart;\nexport type UIContentPartComponent = ComponentType<UIContentPartProps>;\n\nexport type ToolCallContentPartProps<\n TArgs = any,\n TResult = unknown,\n> = ContentPartState &\n ToolCallContentPart<TArgs, TResult> & {\n addResult: (result: any) => void;\n };\n\nexport type ToolCallContentPartComponent<\n TArgs = any,\n TResult = any,\n> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/package.json
CHANGED
@@ -37,10 +37,7 @@ type OnSchemaValidationErrorFunction<TResult> = ToolExecuteFunction<
|
|
37
37
|
TResult
|
38
38
|
>;
|
39
39
|
|
40
|
-
export type Tool<
|
41
|
-
TArgs extends Record<string, unknown> = Record<string | number, unknown>,
|
42
|
-
TResult = unknown,
|
43
|
-
> = {
|
40
|
+
export type Tool<TArgs = unknown, TResult = unknown> = {
|
44
41
|
description?: string | undefined;
|
45
42
|
parameters: z.ZodSchema<TArgs> | JSONSchema7;
|
46
43
|
execute?: ToolExecuteFunction<TArgs, TResult>;
|
@@ -2,13 +2,12 @@
|
|
2
2
|
|
3
3
|
import { FC } from "react";
|
4
4
|
import { type AssistantToolProps, useAssistantTool } from "./useAssistantTool";
|
5
|
-
import { ReadonlyJSONObject } from "../utils/json/json-value";
|
6
5
|
|
7
6
|
export type AssistantTool = FC & {
|
8
7
|
unstable_tool: AssistantToolProps<any, any>;
|
9
8
|
};
|
10
9
|
|
11
|
-
export const makeAssistantTool = <TArgs
|
10
|
+
export const makeAssistantTool = <TArgs, TResult>(
|
12
11
|
tool: AssistantToolProps<TArgs, TResult>,
|
13
12
|
) => {
|
14
13
|
const Tool: AssistantTool = () => {
|
@@ -5,13 +5,12 @@ import {
|
|
5
5
|
type AssistantToolUIProps,
|
6
6
|
useAssistantToolUI,
|
7
7
|
} from "./useAssistantToolUI";
|
8
|
-
import { ReadonlyJSONObject } from "../utils/json/json-value";
|
9
8
|
|
10
9
|
export type AssistantToolUI = FC & {
|
11
10
|
unstable_tool: AssistantToolUIProps<any, any>;
|
12
11
|
};
|
13
12
|
|
14
|
-
export const makeAssistantToolUI = <TArgs
|
13
|
+
export const makeAssistantToolUI = <TArgs, TResult>(
|
15
14
|
tool: AssistantToolUIProps<TArgs, TResult>,
|
16
15
|
) => {
|
17
16
|
const ToolUI: AssistantToolUI = () => {
|
@@ -7,18 +7,14 @@ import {
|
|
7
7
|
} from "../context/react/AssistantContext";
|
8
8
|
import type { ToolCallContentPartComponent } from "../types/ContentPartComponentTypes";
|
9
9
|
import type { Tool } from "./ModelContextTypes";
|
10
|
-
import { ReadonlyJSONObject } from "../utils/json/json-value";
|
11
10
|
|
12
|
-
export type AssistantToolProps<
|
13
|
-
TArgs extends ReadonlyJSONObject,
|
14
|
-
TResult,
|
15
|
-
> = Tool<TArgs, TResult> & {
|
11
|
+
export type AssistantToolProps<TArgs, TResult> = Tool<TArgs, TResult> & {
|
16
12
|
toolName: string;
|
17
13
|
render?: ToolCallContentPartComponent<TArgs, TResult> | undefined;
|
18
14
|
disabled?: boolean | undefined;
|
19
15
|
};
|
20
16
|
|
21
|
-
export const useAssistantTool = <TArgs
|
17
|
+
export const useAssistantTool = <TArgs, TResult>(
|
22
18
|
tool: AssistantToolProps<TArgs, TResult>,
|
23
19
|
) => {
|
24
20
|
const assistantRuntime = useAssistantRuntime();
|
@@ -3,9 +3,8 @@
|
|
3
3
|
import { useEffect } from "react";
|
4
4
|
import { useToolUIsStore } from "../context/react/AssistantContext";
|
5
5
|
import type { ToolCallContentPartComponent } from "../types/ContentPartComponentTypes";
|
6
|
-
import { ReadonlyJSONObject } from "../utils/json/json-value";
|
7
6
|
|
8
|
-
export type AssistantToolUIProps<TArgs
|
7
|
+
export type AssistantToolUIProps<TArgs, TResult> = {
|
9
8
|
toolName: string;
|
10
9
|
render: ToolCallContentPartComponent<TArgs, TResult>;
|
11
10
|
};
|
@@ -3,9 +3,8 @@
|
|
3
3
|
import { FC, useCallback, useEffect, useState } from "react";
|
4
4
|
import { ToolCallContentPartProps } from "../types";
|
5
5
|
import { create } from "zustand";
|
6
|
-
import { ReadonlyJSONObject } from "../utils/json/json-value";
|
7
6
|
|
8
|
-
export const useInlineRender = <TArgs
|
7
|
+
export const useInlineRender = <TArgs, TResult>(
|
9
8
|
toolUI: FC<ToolCallContentPartProps<TArgs, TResult>>,
|
10
9
|
): FC<ToolCallContentPartProps<TArgs, TResult>> => {
|
11
10
|
const [useToolUI] = useState(() => create(() => toolUI));
|
@@ -40,7 +40,7 @@ export type ToolResultStreamPart =
|
|
40
40
|
};
|
41
41
|
|
42
42
|
export function toolResultStream(
|
43
|
-
tools: Record<string, Tool
|
43
|
+
tools: Record<string, Tool<any, any>> | undefined,
|
44
44
|
abortSignal: AbortSignal,
|
45
45
|
) {
|
46
46
|
const toolCallExecutions = new Map<string, Promise<any>>();
|
@@ -17,7 +17,6 @@ export type ReasoningContentPart = {
|
|
17
17
|
readonly text: string;
|
18
18
|
};
|
19
19
|
|
20
|
-
|
21
20
|
export type ImageContentPart = {
|
22
21
|
readonly type: "image";
|
23
22
|
readonly image: string;
|
@@ -80,7 +79,7 @@ export type UIContentPart = {
|
|
80
79
|
};
|
81
80
|
|
82
81
|
export type CoreToolCallContentPart<
|
83
|
-
TArgs
|
82
|
+
TArgs = ReadonlyJSONObject,
|
84
83
|
TResult = unknown,
|
85
84
|
> = {
|
86
85
|
readonly type: "tool-call";
|
@@ -92,7 +91,7 @@ export type CoreToolCallContentPart<
|
|
92
91
|
};
|
93
92
|
|
94
93
|
export type ToolCallContentPart<
|
95
|
-
TArgs
|
94
|
+
TArgs = ReadonlyJSONObject,
|
96
95
|
TResult = unknown,
|
97
96
|
> = CoreToolCallContentPart<TArgs, TResult> & {
|
98
97
|
readonly argsText: string;
|
@@ -10,7 +10,6 @@ import type {
|
|
10
10
|
Unstable_AudioContentPart,
|
11
11
|
} from "./AssistantTypes";
|
12
12
|
import { ContentPartState } from "../api/ContentPartRuntime";
|
13
|
-
import { ReadonlyJSONObject } from "../utils/json/json-value";
|
14
13
|
|
15
14
|
export type EmptyContentPartProps = {
|
16
15
|
status: ContentPartStatus;
|
@@ -21,7 +20,8 @@ export type TextContentPartProps = ContentPartState & TextContentPart;
|
|
21
20
|
export type TextContentPartComponent = ComponentType<TextContentPartProps>;
|
22
21
|
|
23
22
|
export type ReasoningContentPartProps = ContentPartState & ReasoningContentPart;
|
24
|
-
export type ReasoningContentPartComponent =
|
23
|
+
export type ReasoningContentPartComponent =
|
24
|
+
ComponentType<ReasoningContentPartProps>;
|
25
25
|
|
26
26
|
export type ImageContentPartProps = ContentPartState & ImageContentPart;
|
27
27
|
export type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
|
@@ -38,7 +38,7 @@ export type UIContentPartProps = ContentPartState & UIContentPart;
|
|
38
38
|
export type UIContentPartComponent = ComponentType<UIContentPartProps>;
|
39
39
|
|
40
40
|
export type ToolCallContentPartProps<
|
41
|
-
TArgs
|
41
|
+
TArgs = any,
|
42
42
|
TResult = unknown,
|
43
43
|
> = ContentPartState &
|
44
44
|
ToolCallContentPart<TArgs, TResult> & {
|
@@ -46,6 +46,6 @@ export type ToolCallContentPartProps<
|
|
46
46
|
};
|
47
47
|
|
48
48
|
export type ToolCallContentPartComponent<
|
49
|
-
TArgs
|
49
|
+
TArgs = any,
|
50
50
|
TResult = any,
|
51
51
|
> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
|