@copilotkitnext/react 1.53.1-next.2 → 1.54.0-next.3
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/hooks/use-component.cjs +4 -4
- package/dist/hooks/use-component.cjs.map +1 -1
- package/dist/hooks/use-component.d.cts +7 -7
- package/dist/hooks/use-component.d.cts.map +1 -1
- package/dist/hooks/use-component.d.mts +7 -7
- package/dist/hooks/use-component.d.mts.map +1 -1
- package/dist/hooks/use-component.mjs +4 -4
- package/dist/hooks/use-component.mjs.map +1 -1
- package/dist/hooks/use-render-tool.cjs +1 -1
- package/dist/hooks/use-render-tool.cjs.map +1 -1
- package/dist/hooks/use-render-tool.d.cts +13 -12
- package/dist/hooks/use-render-tool.d.cts.map +1 -1
- package/dist/hooks/use-render-tool.d.mts +13 -12
- package/dist/hooks/use-render-tool.d.mts.map +1 -1
- package/dist/hooks/use-render-tool.mjs +1 -1
- package/dist/hooks/use-render-tool.mjs.map +1 -1
- package/dist/hooks/useKatexStyles.cjs.map +1 -1
- package/dist/hooks/useKatexStyles.mjs.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/types/defineToolCallRenderer.cjs.map +1 -1
- package/dist/types/defineToolCallRenderer.d.cts +5 -5
- package/dist/types/defineToolCallRenderer.d.cts.map +1 -1
- package/dist/types/defineToolCallRenderer.d.mts +5 -5
- package/dist/types/defineToolCallRenderer.d.mts.map +1 -1
- package/dist/types/defineToolCallRenderer.mjs.map +1 -1
- package/dist/types/react-activity-message-renderer.d.cts +2 -2
- package/dist/types/react-activity-message-renderer.d.cts.map +1 -1
- package/dist/types/react-activity-message-renderer.d.mts +2 -2
- package/dist/types/react-activity-message-renderer.d.mts.map +1 -1
- package/dist/types/react-tool-call-renderer.d.cts +2 -2
- package/dist/types/react-tool-call-renderer.d.cts.map +1 -1
- package/dist/types/react-tool-call-renderer.d.mts +2 -2
- package/dist/types/react-tool-call-renderer.d.mts.map +1 -1
- package/package.json +10 -7
|
@@ -8,16 +8,16 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
8
8
|
*
|
|
9
9
|
* This hook is a convenience wrapper around `useFrontendTool` that:
|
|
10
10
|
* - builds a model-facing tool description,
|
|
11
|
-
* - forwards optional
|
|
11
|
+
* - forwards optional schema parameters (any Standard Schema V1 compatible library),
|
|
12
12
|
* - renders your component with tool call parameters.
|
|
13
13
|
*
|
|
14
14
|
* Use this when you want to display a typed visual component for a tool call
|
|
15
15
|
* without manually wiring a full frontend tool object.
|
|
16
16
|
*
|
|
17
|
-
* When `parameters` is provided, render props are inferred from the schema
|
|
18
|
-
*
|
|
17
|
+
* When `parameters` is provided, render props are inferred from the schema.
|
|
18
|
+
* When omitted, the render component may accept any props.
|
|
19
19
|
*
|
|
20
|
-
* @typeParam TSchema -
|
|
20
|
+
* @typeParam TSchema - Schema describing tool parameters, or `undefined` when no schema is given.
|
|
21
21
|
* @param config - Tool registration config.
|
|
22
22
|
* @param deps - Optional dependencies to refresh registration (same semantics as `useEffect`).
|
|
23
23
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-component.cjs","names":[],"sources":["../../src/hooks/use-component.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"use-component.cjs","names":[],"sources":["../../src/hooks/use-component.tsx"],"sourcesContent":["import type {\n StandardSchemaV1,\n InferSchemaOutput,\n} from \"@copilotkitnext/shared\";\nimport type { ComponentType } from \"react\";\nimport { useFrontendTool } from \"./use-frontend-tool\";\n\ntype InferRenderProps<T> = T extends StandardSchemaV1\n ? InferSchemaOutput<T>\n : any;\n\n/**\n * Registers a React component as a frontend tool renderer in chat.\n *\n * This hook is a convenience wrapper around `useFrontendTool` that:\n * - builds a model-facing tool description,\n * - forwards optional schema parameters (any Standard Schema V1 compatible library),\n * - renders your component with tool call parameters.\n *\n * Use this when you want to display a typed visual component for a tool call\n * without manually wiring a full frontend tool object.\n *\n * When `parameters` is provided, render props are inferred from the schema.\n * When omitted, the render component may accept any props.\n *\n * @typeParam TSchema - Schema describing tool parameters, or `undefined` when no schema is given.\n * @param config - Tool registration config.\n * @param deps - Optional dependencies to refresh registration (same semantics as `useEffect`).\n *\n * @example\n * ```tsx\n * // Without parameters — render accepts any props\n * useComponent({\n * name: \"showGreeting\",\n * render: ({ message }: { message: string }) => <div>{message}</div>,\n * });\n * ```\n *\n * @example\n * ```tsx\n * // With parameters — render props inferred from schema\n * useComponent({\n * name: \"showWeatherCard\",\n * parameters: z.object({ city: z.string() }),\n * render: ({ city }) => <div>{city}</div>,\n * });\n * ```\n *\n * @example\n * ```tsx\n * useComponent(\n * {\n * name: \"renderProfile\",\n * parameters: z.object({ userId: z.string() }),\n * render: ProfileCard,\n * agentId: \"support-agent\",\n * },\n * [selectedAgentId],\n * );\n * ```\n */\nexport function useComponent<\n TSchema extends StandardSchemaV1 | undefined = undefined,\n>(\n config: {\n name: string;\n description?: string;\n parameters?: TSchema;\n render: ComponentType<NoInfer<InferRenderProps<TSchema>>>;\n agentId?: string;\n },\n deps?: ReadonlyArray<unknown>,\n): void {\n const prefix = `Use this tool to display the \"${config.name}\" component in the chat. This tool renders a visual UI component for the user.`;\n const fullDescription = config.description\n ? `${prefix}\\n\\n${config.description}`\n : prefix;\n\n useFrontendTool(\n {\n name: config.name,\n description: fullDescription,\n parameters: config.parameters,\n render: ({ args }: { args: unknown }) => {\n const Component = config.render;\n return <Component {...(args as InferRenderProps<TSchema>)} />;\n },\n agentId: config.agentId,\n },\n deps,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAgB,aAGd,QAOA,MACM;CACN,MAAM,SAAS,iCAAiC,OAAO,KAAK;CAC5D,MAAM,kBAAkB,OAAO,cAC3B,GAAG,OAAO,MAAM,OAAO,gBACvB;AAEJ,2CACE;EACE,MAAM,OAAO;EACb,aAAa;EACb,YAAY,OAAO;EACnB,SAAS,EAAE,WAA8B;GACvC,MAAM,YAAY,OAAO;AACzB,UAAO,2CAAC,aAAU,GAAK,OAAsC;;EAE/D,SAAS,OAAO;EACjB,EACD,KACD"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { ComponentType } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkitnext/shared";
|
|
3
3
|
|
|
4
4
|
//#region src/hooks/use-component.d.ts
|
|
5
|
-
type InferRenderProps<T> = T extends
|
|
5
|
+
type InferRenderProps<T> = T extends StandardSchemaV1 ? InferSchemaOutput<T> : any;
|
|
6
6
|
/**
|
|
7
7
|
* Registers a React component as a frontend tool renderer in chat.
|
|
8
8
|
*
|
|
9
9
|
* This hook is a convenience wrapper around `useFrontendTool` that:
|
|
10
10
|
* - builds a model-facing tool description,
|
|
11
|
-
* - forwards optional
|
|
11
|
+
* - forwards optional schema parameters (any Standard Schema V1 compatible library),
|
|
12
12
|
* - renders your component with tool call parameters.
|
|
13
13
|
*
|
|
14
14
|
* Use this when you want to display a typed visual component for a tool call
|
|
15
15
|
* without manually wiring a full frontend tool object.
|
|
16
16
|
*
|
|
17
|
-
* When `parameters` is provided, render props are inferred from the schema
|
|
18
|
-
*
|
|
17
|
+
* When `parameters` is provided, render props are inferred from the schema.
|
|
18
|
+
* When omitted, the render component may accept any props.
|
|
19
19
|
*
|
|
20
|
-
* @typeParam TSchema -
|
|
20
|
+
* @typeParam TSchema - Schema describing tool parameters, or `undefined` when no schema is given.
|
|
21
21
|
* @param config - Tool registration config.
|
|
22
22
|
* @param deps - Optional dependencies to refresh registration (same semantics as `useEffect`).
|
|
23
23
|
*
|
|
@@ -53,7 +53,7 @@ type InferRenderProps<T> = T extends z.ZodTypeAny ? z.infer<T> : any;
|
|
|
53
53
|
* );
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
|
-
declare function useComponent<TSchema extends
|
|
56
|
+
declare function useComponent<TSchema extends StandardSchemaV1 | undefined = undefined>(config: {
|
|
57
57
|
name: string;
|
|
58
58
|
description?: string;
|
|
59
59
|
parameters?: TSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-component.d.cts","names":[],"sources":["../../src/hooks/use-component.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"use-component.d.cts","names":[],"sources":["../../src/hooks/use-component.tsx"],"mappings":";;;;KAOK,gBAAA,MAAsB,CAAA,SAAU,gBAAA,GACjC,iBAAA,CAAkB,CAAA;;AAJqB;;;;;;;;;;;;;;;;AAyD3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,YAAA,iBACE,gBAAA,yBAAA,CAEhB,MAAA;EACE,IAAA;EACA,WAAA;EACA,UAAA,GAAa,OAAA;EACb,MAAA,EAAQ,aAAA,CAAc,OAAA,CAAQ,gBAAA,CAAiB,OAAA;EAC/C,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { ComponentType } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkitnext/shared";
|
|
3
3
|
|
|
4
4
|
//#region src/hooks/use-component.d.ts
|
|
5
|
-
type InferRenderProps<T> = T extends
|
|
5
|
+
type InferRenderProps<T> = T extends StandardSchemaV1 ? InferSchemaOutput<T> : any;
|
|
6
6
|
/**
|
|
7
7
|
* Registers a React component as a frontend tool renderer in chat.
|
|
8
8
|
*
|
|
9
9
|
* This hook is a convenience wrapper around `useFrontendTool` that:
|
|
10
10
|
* - builds a model-facing tool description,
|
|
11
|
-
* - forwards optional
|
|
11
|
+
* - forwards optional schema parameters (any Standard Schema V1 compatible library),
|
|
12
12
|
* - renders your component with tool call parameters.
|
|
13
13
|
*
|
|
14
14
|
* Use this when you want to display a typed visual component for a tool call
|
|
15
15
|
* without manually wiring a full frontend tool object.
|
|
16
16
|
*
|
|
17
|
-
* When `parameters` is provided, render props are inferred from the schema
|
|
18
|
-
*
|
|
17
|
+
* When `parameters` is provided, render props are inferred from the schema.
|
|
18
|
+
* When omitted, the render component may accept any props.
|
|
19
19
|
*
|
|
20
|
-
* @typeParam TSchema -
|
|
20
|
+
* @typeParam TSchema - Schema describing tool parameters, or `undefined` when no schema is given.
|
|
21
21
|
* @param config - Tool registration config.
|
|
22
22
|
* @param deps - Optional dependencies to refresh registration (same semantics as `useEffect`).
|
|
23
23
|
*
|
|
@@ -53,7 +53,7 @@ type InferRenderProps<T> = T extends z.ZodTypeAny ? z.infer<T> : any;
|
|
|
53
53
|
* );
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
|
-
declare function useComponent<TSchema extends
|
|
56
|
+
declare function useComponent<TSchema extends StandardSchemaV1 | undefined = undefined>(config: {
|
|
57
57
|
name: string;
|
|
58
58
|
description?: string;
|
|
59
59
|
parameters?: TSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-component.d.mts","names":[],"sources":["../../src/hooks/use-component.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"use-component.d.mts","names":[],"sources":["../../src/hooks/use-component.tsx"],"mappings":";;;;KAOK,gBAAA,MAAsB,CAAA,SAAU,gBAAA,GACjC,iBAAA,CAAkB,CAAA;;AAJqB;;;;;;;;;;;;;;;;AAyD3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,YAAA,iBACE,gBAAA,yBAAA,CAEhB,MAAA;EACE,IAAA;EACA,WAAA;EACA,UAAA,GAAa,OAAA;EACb,MAAA,EAAQ,aAAA,CAAc,OAAA,CAAQ,gBAAA,CAAiB,OAAA;EAC/C,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA"}
|
|
@@ -7,16 +7,16 @@ import { jsx } from "react/jsx-runtime";
|
|
|
7
7
|
*
|
|
8
8
|
* This hook is a convenience wrapper around `useFrontendTool` that:
|
|
9
9
|
* - builds a model-facing tool description,
|
|
10
|
-
* - forwards optional
|
|
10
|
+
* - forwards optional schema parameters (any Standard Schema V1 compatible library),
|
|
11
11
|
* - renders your component with tool call parameters.
|
|
12
12
|
*
|
|
13
13
|
* Use this when you want to display a typed visual component for a tool call
|
|
14
14
|
* without manually wiring a full frontend tool object.
|
|
15
15
|
*
|
|
16
|
-
* When `parameters` is provided, render props are inferred from the schema
|
|
17
|
-
*
|
|
16
|
+
* When `parameters` is provided, render props are inferred from the schema.
|
|
17
|
+
* When omitted, the render component may accept any props.
|
|
18
18
|
*
|
|
19
|
-
* @typeParam TSchema -
|
|
19
|
+
* @typeParam TSchema - Schema describing tool parameters, or `undefined` when no schema is given.
|
|
20
20
|
* @param config - Tool registration config.
|
|
21
21
|
* @param deps - Optional dependencies to refresh registration (same semantics as `useEffect`).
|
|
22
22
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-component.mjs","names":[],"sources":["../../src/hooks/use-component.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"use-component.mjs","names":[],"sources":["../../src/hooks/use-component.tsx"],"sourcesContent":["import type {\n StandardSchemaV1,\n InferSchemaOutput,\n} from \"@copilotkitnext/shared\";\nimport type { ComponentType } from \"react\";\nimport { useFrontendTool } from \"./use-frontend-tool\";\n\ntype InferRenderProps<T> = T extends StandardSchemaV1\n ? InferSchemaOutput<T>\n : any;\n\n/**\n * Registers a React component as a frontend tool renderer in chat.\n *\n * This hook is a convenience wrapper around `useFrontendTool` that:\n * - builds a model-facing tool description,\n * - forwards optional schema parameters (any Standard Schema V1 compatible library),\n * - renders your component with tool call parameters.\n *\n * Use this when you want to display a typed visual component for a tool call\n * without manually wiring a full frontend tool object.\n *\n * When `parameters` is provided, render props are inferred from the schema.\n * When omitted, the render component may accept any props.\n *\n * @typeParam TSchema - Schema describing tool parameters, or `undefined` when no schema is given.\n * @param config - Tool registration config.\n * @param deps - Optional dependencies to refresh registration (same semantics as `useEffect`).\n *\n * @example\n * ```tsx\n * // Without parameters — render accepts any props\n * useComponent({\n * name: \"showGreeting\",\n * render: ({ message }: { message: string }) => <div>{message}</div>,\n * });\n * ```\n *\n * @example\n * ```tsx\n * // With parameters — render props inferred from schema\n * useComponent({\n * name: \"showWeatherCard\",\n * parameters: z.object({ city: z.string() }),\n * render: ({ city }) => <div>{city}</div>,\n * });\n * ```\n *\n * @example\n * ```tsx\n * useComponent(\n * {\n * name: \"renderProfile\",\n * parameters: z.object({ userId: z.string() }),\n * render: ProfileCard,\n * agentId: \"support-agent\",\n * },\n * [selectedAgentId],\n * );\n * ```\n */\nexport function useComponent<\n TSchema extends StandardSchemaV1 | undefined = undefined,\n>(\n config: {\n name: string;\n description?: string;\n parameters?: TSchema;\n render: ComponentType<NoInfer<InferRenderProps<TSchema>>>;\n agentId?: string;\n },\n deps?: ReadonlyArray<unknown>,\n): void {\n const prefix = `Use this tool to display the \"${config.name}\" component in the chat. This tool renders a visual UI component for the user.`;\n const fullDescription = config.description\n ? `${prefix}\\n\\n${config.description}`\n : prefix;\n\n useFrontendTool(\n {\n name: config.name,\n description: fullDescription,\n parameters: config.parameters,\n render: ({ args }: { args: unknown }) => {\n const Component = config.render;\n return <Component {...(args as InferRenderProps<TSchema>)} />;\n },\n agentId: config.agentId,\n },\n deps,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAgB,aAGd,QAOA,MACM;CACN,MAAM,SAAS,iCAAiC,OAAO,KAAK;CAC5D,MAAM,kBAAkB,OAAO,cAC3B,GAAG,OAAO,MAAM,OAAO,gBACvB;AAEJ,iBACE;EACE,MAAM,OAAO;EACb,aAAa;EACb,YAAY,OAAO;EACnB,SAAS,EAAE,WAA8B;GACvC,MAAM,YAAY,OAAO;AACzB,UAAO,oBAAC,aAAU,GAAK,OAAsC;;EAE/D,SAAS,OAAO;EACjB,EACD,KACD"}
|
|
@@ -13,7 +13,7 @@ const EMPTY_DEPS = [];
|
|
|
13
13
|
* - keeps renderer entries on cleanup so historical chat tool calls can still render,
|
|
14
14
|
* - refreshes registration when `deps` change.
|
|
15
15
|
*
|
|
16
|
-
* @typeParam S -
|
|
16
|
+
* @typeParam S - Schema type describing tool call parameters.
|
|
17
17
|
* @param config - Renderer config for wildcard or named tools.
|
|
18
18
|
* @param deps - Optional dependencies to refresh registration.
|
|
19
19
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-render-tool.cjs","names":["useCopilotKit","defineToolCallRenderer"],"sources":["../../src/hooks/use-render-tool.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport type {
|
|
1
|
+
{"version":3,"file":"use-render-tool.cjs","names":["useCopilotKit","defineToolCallRenderer"],"sources":["../../src/hooks/use-render-tool.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport type {\n StandardSchemaV1,\n InferSchemaOutput,\n} from \"@copilotkitnext/shared\";\nimport { useCopilotKit } from \"../providers/CopilotKitProvider\";\nimport { defineToolCallRenderer } from \"../types/defineToolCallRenderer\";\nimport type { ReactToolCallRenderer } from \"../types/react-tool-call-renderer\";\n\nconst EMPTY_DEPS: ReadonlyArray<unknown> = [];\n\nexport interface RenderToolInProgressProps<S extends StandardSchemaV1> {\n name: string;\n parameters: Partial<InferSchemaOutput<S>>;\n status: \"inProgress\";\n result: undefined;\n}\n\nexport interface RenderToolExecutingProps<S extends StandardSchemaV1> {\n name: string;\n parameters: InferSchemaOutput<S>;\n status: \"executing\";\n result: undefined;\n}\n\nexport interface RenderToolCompleteProps<S extends StandardSchemaV1> {\n name: string;\n parameters: InferSchemaOutput<S>;\n status: \"complete\";\n result: string;\n}\n\nexport type RenderToolProps<S extends StandardSchemaV1> =\n | RenderToolInProgressProps<S>\n | RenderToolExecutingProps<S>\n | RenderToolCompleteProps<S>;\n\ntype RenderToolConfig<S extends StandardSchemaV1> = {\n name: string;\n parameters?: S;\n render: (props: RenderToolProps<S>) => React.ReactElement;\n agentId?: string;\n};\n\n/**\n * Registers a wildcard (`\"*\"`) renderer for tool calls.\n *\n * The wildcard renderer is used as a fallback when no exact name-matched\n * renderer is registered for a tool call.\n *\n * @param config - Wildcard renderer configuration.\n * @param deps - Optional dependencies to refresh registration.\n *\n * @example\n * ```tsx\n * useRenderTool(\n * {\n * name: \"*\",\n * render: ({ name, status }) => (\n * <div>\n * {status === \"complete\" ? \"✓\" : \"⏳\"} {name}\n * </div>\n * ),\n * },\n * [],\n * );\n * ```\n */\nexport function useRenderTool(\n config: {\n name: \"*\";\n render: (props: any) => React.ReactElement;\n agentId?: string;\n },\n deps?: ReadonlyArray<unknown>,\n): void;\n\n/**\n * Registers a name-scoped renderer for tool calls.\n *\n * The provided `parameters` schema defines the typed shape of `props.parameters`\n * in `render` for `executing` and `complete` states. Accepts any Standard Schema V1\n * compatible library (Zod, Valibot, ArkType, etc.).\n *\n * @typeParam S - Schema type describing tool call parameters.\n * @param config - Named renderer configuration.\n * @param deps - Optional dependencies to refresh registration.\n *\n * @example\n * ```tsx\n * useRenderTool(\n * {\n * name: \"searchDocs\",\n * parameters: z.object({ query: z.string() }),\n * render: ({ status, parameters, result }) => {\n * if (status === \"inProgress\") return <div>Preparing...</div>;\n * if (status === \"executing\") return <div>Searching {parameters.query}</div>;\n * return <div>{result}</div>;\n * },\n * },\n * [],\n * );\n * ```\n */\nexport function useRenderTool<S extends StandardSchemaV1>(\n config: {\n name: string;\n parameters: S;\n render: (props: RenderToolProps<S>) => React.ReactElement;\n agentId?: string;\n },\n deps?: ReadonlyArray<unknown>,\n): void;\n\n/**\n * Registers a renderer entry in CopilotKit's `renderToolCalls` registry.\n *\n * Key behavior:\n * - deduplicates by `agentId:name` (latest registration wins),\n * - keeps renderer entries on cleanup so historical chat tool calls can still render,\n * - refreshes registration when `deps` change.\n *\n * @typeParam S - Schema type describing tool call parameters.\n * @param config - Renderer config for wildcard or named tools.\n * @param deps - Optional dependencies to refresh registration.\n *\n * @example\n * ```tsx\n * useRenderTool(\n * {\n * name: \"searchDocs\",\n * parameters: z.object({ query: z.string() }),\n * render: ({ status, parameters, result }) => {\n * if (status === \"executing\") return <div>Searching {parameters.query}</div>;\n * if (status === \"complete\") return <div>{result}</div>;\n * return <div>Preparing...</div>;\n * },\n * },\n * [],\n * );\n * ```\n *\n * @example\n * ```tsx\n * useRenderTool(\n * {\n * name: \"summarize\",\n * parameters: z.object({ text: z.string() }),\n * agentId: \"research-agent\",\n * render: ({ name, status }) => <div>{name}: {status}</div>,\n * },\n * [selectedAgentId],\n * );\n * ```\n */\nexport function useRenderTool<S extends StandardSchemaV1>(\n config: RenderToolConfig<S>,\n deps?: ReadonlyArray<unknown>,\n): void {\n const { copilotkit } = useCopilotKit();\n const extraDeps = deps ?? EMPTY_DEPS;\n\n useEffect(() => {\n // Build the ReactToolCallRenderer via defineToolCallRenderer\n const renderer =\n config.name === \"*\" && !config.parameters\n ? defineToolCallRenderer({\n name: \"*\",\n render: (props) =>\n config.render({ ...props, parameters: props.args }),\n ...(config.agentId ? { agentId: config.agentId } : {}),\n })\n : defineToolCallRenderer({\n name: config.name,\n args: config.parameters!,\n render: (props) =>\n config.render({ ...props, parameters: props.args }),\n ...(config.agentId ? { agentId: config.agentId } : {}),\n });\n\n // Dedupe by \"agentId:name\" key, same pattern as useFrontendTool\n const keyOf = (rc: ReactToolCallRenderer) =>\n `${rc.agentId ?? \"\"}:${rc.name}`;\n const currentRenderToolCalls =\n copilotkit.renderToolCalls as ReactToolCallRenderer[];\n\n const mergedMap = new Map<string, ReactToolCallRenderer>();\n for (const rc of currentRenderToolCalls) {\n mergedMap.set(keyOf(rc), rc);\n }\n\n mergedMap.set(keyOf(renderer), renderer);\n\n copilotkit.setRenderToolCalls(Array.from(mergedMap.values()));\n\n // No cleanup removal — keeps renderer for chat history, same as useFrontendTool\n }, [config.name, copilotkit, extraDeps.length, ...extraDeps]);\n}\n"],"mappings":";;;;;;AASA,MAAM,aAAqC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkJ7C,SAAgB,cACd,QACA,MACM;CACN,MAAM,EAAE,eAAeA,0CAAe;CACtC,MAAM,YAAY,QAAQ;AAE1B,4BAAgB;EAEd,MAAM,WACJ,OAAO,SAAS,OAAO,CAAC,OAAO,aAC3BC,sDAAuB;GACrB,MAAM;GACN,SAAS,UACP,OAAO,OAAO;IAAE,GAAG;IAAO,YAAY,MAAM;IAAM,CAAC;GACrD,GAAI,OAAO,UAAU,EAAE,SAAS,OAAO,SAAS,GAAG,EAAE;GACtD,CAAC,GACFA,sDAAuB;GACrB,MAAM,OAAO;GACb,MAAM,OAAO;GACb,SAAS,UACP,OAAO,OAAO;IAAE,GAAG;IAAO,YAAY,MAAM;IAAM,CAAC;GACrD,GAAI,OAAO,UAAU,EAAE,SAAS,OAAO,SAAS,GAAG,EAAE;GACtD,CAAC;EAGR,MAAM,SAAS,OACb,GAAG,GAAG,WAAW,GAAG,GAAG,GAAG;EAC5B,MAAM,yBACJ,WAAW;EAEb,MAAM,4BAAY,IAAI,KAAoC;AAC1D,OAAK,MAAM,MAAM,uBACf,WAAU,IAAI,MAAM,GAAG,EAAE,GAAG;AAG9B,YAAU,IAAI,MAAM,SAAS,EAAE,SAAS;AAExC,aAAW,mBAAmB,MAAM,KAAK,UAAU,QAAQ,CAAC,CAAC;IAG5D;EAAC,OAAO;EAAM;EAAY,UAAU;EAAQ,GAAG;EAAU,CAAC"}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkitnext/shared";
|
|
2
2
|
|
|
3
3
|
//#region src/hooks/use-render-tool.d.ts
|
|
4
|
-
interface RenderToolInProgressProps<S extends
|
|
4
|
+
interface RenderToolInProgressProps<S extends StandardSchemaV1> {
|
|
5
5
|
name: string;
|
|
6
|
-
parameters: Partial<
|
|
6
|
+
parameters: Partial<InferSchemaOutput<S>>;
|
|
7
7
|
status: "inProgress";
|
|
8
8
|
result: undefined;
|
|
9
9
|
}
|
|
10
|
-
interface RenderToolExecutingProps<S extends
|
|
10
|
+
interface RenderToolExecutingProps<S extends StandardSchemaV1> {
|
|
11
11
|
name: string;
|
|
12
|
-
parameters:
|
|
12
|
+
parameters: InferSchemaOutput<S>;
|
|
13
13
|
status: "executing";
|
|
14
14
|
result: undefined;
|
|
15
15
|
}
|
|
16
|
-
interface RenderToolCompleteProps<S extends
|
|
16
|
+
interface RenderToolCompleteProps<S extends StandardSchemaV1> {
|
|
17
17
|
name: string;
|
|
18
|
-
parameters:
|
|
18
|
+
parameters: InferSchemaOutput<S>;
|
|
19
19
|
status: "complete";
|
|
20
20
|
result: string;
|
|
21
21
|
}
|
|
22
|
-
type RenderToolProps<S extends
|
|
22
|
+
type RenderToolProps<S extends StandardSchemaV1> = RenderToolInProgressProps<S> | RenderToolExecutingProps<S> | RenderToolCompleteProps<S>;
|
|
23
23
|
/**
|
|
24
24
|
* Registers a wildcard (`"*"`) renderer for tool calls.
|
|
25
25
|
*
|
|
@@ -52,10 +52,11 @@ declare function useRenderTool(config: {
|
|
|
52
52
|
/**
|
|
53
53
|
* Registers a name-scoped renderer for tool calls.
|
|
54
54
|
*
|
|
55
|
-
* The provided `parameters`
|
|
56
|
-
* in `render` for `executing` and `complete` states.
|
|
55
|
+
* The provided `parameters` schema defines the typed shape of `props.parameters`
|
|
56
|
+
* in `render` for `executing` and `complete` states. Accepts any Standard Schema V1
|
|
57
|
+
* compatible library (Zod, Valibot, ArkType, etc.).
|
|
57
58
|
*
|
|
58
|
-
* @typeParam S -
|
|
59
|
+
* @typeParam S - Schema type describing tool call parameters.
|
|
59
60
|
* @param config - Named renderer configuration.
|
|
60
61
|
* @param deps - Optional dependencies to refresh registration.
|
|
61
62
|
*
|
|
@@ -75,7 +76,7 @@ declare function useRenderTool(config: {
|
|
|
75
76
|
* );
|
|
76
77
|
* ```
|
|
77
78
|
*/
|
|
78
|
-
declare function useRenderTool<S extends
|
|
79
|
+
declare function useRenderTool<S extends StandardSchemaV1>(config: {
|
|
79
80
|
name: string;
|
|
80
81
|
parameters: S;
|
|
81
82
|
render: (props: RenderToolProps<S>) => React.ReactElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-render-tool.d.cts","names":[],"sources":["../../src/hooks/use-render-tool.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"use-render-tool.d.cts","names":[],"sources":["../../src/hooks/use-render-tool.tsx"],"mappings":";;;UAWiB,yBAAA,WAAoC,gBAAA;EACnD,IAAA;EACA,UAAA,EAAY,OAAA,CAAQ,iBAAA,CAAkB,CAAA;EACtC,MAAA;EACA,MAAA;AAAA;AAAA,UAGe,wBAAA,WAAmC,gBAAA;EAClD,IAAA;EACA,UAAA,EAAY,iBAAA,CAAkB,CAAA;EAC9B,MAAA;EACA,MAAA;AAAA;AAAA,UAGe,uBAAA,WAAkC,gBAAA;EACjD,IAAA;EACA,UAAA,EAAY,iBAAA,CAAkB,CAAA;EAC9B,MAAA;EACA,MAAA;AAAA;AAAA,KAGU,eAAA,WAA0B,gBAAA,IAClC,yBAAA,CAA0B,CAAA,IAC1B,wBAAA,CAAyB,CAAA,IACzB,uBAAA,CAAwB,CAAA;;;;AAjB5B;;;;;;;;;;;;;;;;;;AAOA;;;iBA2CgB,aAAA,CACd,MAAA;EACE,IAAA;EACA,MAAA,GAAS,KAAA,UAAe,KAAA,CAAM,YAAA;EAC9B,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA;;;;;;;;;;;AA1CT;;;;;;;;;;;;;;;;;iBAwEgB,aAAA,WAAwB,gBAAA,CAAA,CACtC,MAAA;EACE,IAAA;EACA,UAAA,EAAY,CAAA;EACZ,MAAA,GAAS,KAAA,EAAO,eAAA,CAAgB,CAAA,MAAO,KAAA,CAAM,YAAA;EAC7C,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA"}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkitnext/shared";
|
|
2
2
|
|
|
3
3
|
//#region src/hooks/use-render-tool.d.ts
|
|
4
|
-
interface RenderToolInProgressProps<S extends
|
|
4
|
+
interface RenderToolInProgressProps<S extends StandardSchemaV1> {
|
|
5
5
|
name: string;
|
|
6
|
-
parameters: Partial<
|
|
6
|
+
parameters: Partial<InferSchemaOutput<S>>;
|
|
7
7
|
status: "inProgress";
|
|
8
8
|
result: undefined;
|
|
9
9
|
}
|
|
10
|
-
interface RenderToolExecutingProps<S extends
|
|
10
|
+
interface RenderToolExecutingProps<S extends StandardSchemaV1> {
|
|
11
11
|
name: string;
|
|
12
|
-
parameters:
|
|
12
|
+
parameters: InferSchemaOutput<S>;
|
|
13
13
|
status: "executing";
|
|
14
14
|
result: undefined;
|
|
15
15
|
}
|
|
16
|
-
interface RenderToolCompleteProps<S extends
|
|
16
|
+
interface RenderToolCompleteProps<S extends StandardSchemaV1> {
|
|
17
17
|
name: string;
|
|
18
|
-
parameters:
|
|
18
|
+
parameters: InferSchemaOutput<S>;
|
|
19
19
|
status: "complete";
|
|
20
20
|
result: string;
|
|
21
21
|
}
|
|
22
|
-
type RenderToolProps<S extends
|
|
22
|
+
type RenderToolProps<S extends StandardSchemaV1> = RenderToolInProgressProps<S> | RenderToolExecutingProps<S> | RenderToolCompleteProps<S>;
|
|
23
23
|
/**
|
|
24
24
|
* Registers a wildcard (`"*"`) renderer for tool calls.
|
|
25
25
|
*
|
|
@@ -52,10 +52,11 @@ declare function useRenderTool(config: {
|
|
|
52
52
|
/**
|
|
53
53
|
* Registers a name-scoped renderer for tool calls.
|
|
54
54
|
*
|
|
55
|
-
* The provided `parameters`
|
|
56
|
-
* in `render` for `executing` and `complete` states.
|
|
55
|
+
* The provided `parameters` schema defines the typed shape of `props.parameters`
|
|
56
|
+
* in `render` for `executing` and `complete` states. Accepts any Standard Schema V1
|
|
57
|
+
* compatible library (Zod, Valibot, ArkType, etc.).
|
|
57
58
|
*
|
|
58
|
-
* @typeParam S -
|
|
59
|
+
* @typeParam S - Schema type describing tool call parameters.
|
|
59
60
|
* @param config - Named renderer configuration.
|
|
60
61
|
* @param deps - Optional dependencies to refresh registration.
|
|
61
62
|
*
|
|
@@ -75,7 +76,7 @@ declare function useRenderTool(config: {
|
|
|
75
76
|
* );
|
|
76
77
|
* ```
|
|
77
78
|
*/
|
|
78
|
-
declare function useRenderTool<S extends
|
|
79
|
+
declare function useRenderTool<S extends StandardSchemaV1>(config: {
|
|
79
80
|
name: string;
|
|
80
81
|
parameters: S;
|
|
81
82
|
render: (props: RenderToolProps<S>) => React.ReactElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-render-tool.d.mts","names":[],"sources":["../../src/hooks/use-render-tool.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"use-render-tool.d.mts","names":[],"sources":["../../src/hooks/use-render-tool.tsx"],"mappings":";;;UAWiB,yBAAA,WAAoC,gBAAA;EACnD,IAAA;EACA,UAAA,EAAY,OAAA,CAAQ,iBAAA,CAAkB,CAAA;EACtC,MAAA;EACA,MAAA;AAAA;AAAA,UAGe,wBAAA,WAAmC,gBAAA;EAClD,IAAA;EACA,UAAA,EAAY,iBAAA,CAAkB,CAAA;EAC9B,MAAA;EACA,MAAA;AAAA;AAAA,UAGe,uBAAA,WAAkC,gBAAA;EACjD,IAAA;EACA,UAAA,EAAY,iBAAA,CAAkB,CAAA;EAC9B,MAAA;EACA,MAAA;AAAA;AAAA,KAGU,eAAA,WAA0B,gBAAA,IAClC,yBAAA,CAA0B,CAAA,IAC1B,wBAAA,CAAyB,CAAA,IACzB,uBAAA,CAAwB,CAAA;;;;AAjB5B;;;;;;;;;;;;;;;;;;AAOA;;;iBA2CgB,aAAA,CACd,MAAA;EACE,IAAA;EACA,MAAA,GAAS,KAAA,UAAe,KAAA,CAAM,YAAA;EAC9B,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA;;;;;;;;;;;AA1CT;;;;;;;;;;;;;;;;;iBAwEgB,aAAA,WAAwB,gBAAA,CAAA,CACtC,MAAA;EACE,IAAA;EACA,UAAA,EAAY,CAAA;EACZ,MAAA,GAAS,KAAA,EAAO,eAAA,CAAgB,CAAA,MAAO,KAAA,CAAM,YAAA;EAC7C,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA"}
|
|
@@ -12,7 +12,7 @@ const EMPTY_DEPS = [];
|
|
|
12
12
|
* - keeps renderer entries on cleanup so historical chat tool calls can still render,
|
|
13
13
|
* - refreshes registration when `deps` change.
|
|
14
14
|
*
|
|
15
|
-
* @typeParam S -
|
|
15
|
+
* @typeParam S - Schema type describing tool call parameters.
|
|
16
16
|
* @param config - Renderer config for wildcard or named tools.
|
|
17
17
|
* @param deps - Optional dependencies to refresh registration.
|
|
18
18
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-render-tool.mjs","names":[],"sources":["../../src/hooks/use-render-tool.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport type {
|
|
1
|
+
{"version":3,"file":"use-render-tool.mjs","names":[],"sources":["../../src/hooks/use-render-tool.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport type {\n StandardSchemaV1,\n InferSchemaOutput,\n} from \"@copilotkitnext/shared\";\nimport { useCopilotKit } from \"../providers/CopilotKitProvider\";\nimport { defineToolCallRenderer } from \"../types/defineToolCallRenderer\";\nimport type { ReactToolCallRenderer } from \"../types/react-tool-call-renderer\";\n\nconst EMPTY_DEPS: ReadonlyArray<unknown> = [];\n\nexport interface RenderToolInProgressProps<S extends StandardSchemaV1> {\n name: string;\n parameters: Partial<InferSchemaOutput<S>>;\n status: \"inProgress\";\n result: undefined;\n}\n\nexport interface RenderToolExecutingProps<S extends StandardSchemaV1> {\n name: string;\n parameters: InferSchemaOutput<S>;\n status: \"executing\";\n result: undefined;\n}\n\nexport interface RenderToolCompleteProps<S extends StandardSchemaV1> {\n name: string;\n parameters: InferSchemaOutput<S>;\n status: \"complete\";\n result: string;\n}\n\nexport type RenderToolProps<S extends StandardSchemaV1> =\n | RenderToolInProgressProps<S>\n | RenderToolExecutingProps<S>\n | RenderToolCompleteProps<S>;\n\ntype RenderToolConfig<S extends StandardSchemaV1> = {\n name: string;\n parameters?: S;\n render: (props: RenderToolProps<S>) => React.ReactElement;\n agentId?: string;\n};\n\n/**\n * Registers a wildcard (`\"*\"`) renderer for tool calls.\n *\n * The wildcard renderer is used as a fallback when no exact name-matched\n * renderer is registered for a tool call.\n *\n * @param config - Wildcard renderer configuration.\n * @param deps - Optional dependencies to refresh registration.\n *\n * @example\n * ```tsx\n * useRenderTool(\n * {\n * name: \"*\",\n * render: ({ name, status }) => (\n * <div>\n * {status === \"complete\" ? \"✓\" : \"⏳\"} {name}\n * </div>\n * ),\n * },\n * [],\n * );\n * ```\n */\nexport function useRenderTool(\n config: {\n name: \"*\";\n render: (props: any) => React.ReactElement;\n agentId?: string;\n },\n deps?: ReadonlyArray<unknown>,\n): void;\n\n/**\n * Registers a name-scoped renderer for tool calls.\n *\n * The provided `parameters` schema defines the typed shape of `props.parameters`\n * in `render` for `executing` and `complete` states. Accepts any Standard Schema V1\n * compatible library (Zod, Valibot, ArkType, etc.).\n *\n * @typeParam S - Schema type describing tool call parameters.\n * @param config - Named renderer configuration.\n * @param deps - Optional dependencies to refresh registration.\n *\n * @example\n * ```tsx\n * useRenderTool(\n * {\n * name: \"searchDocs\",\n * parameters: z.object({ query: z.string() }),\n * render: ({ status, parameters, result }) => {\n * if (status === \"inProgress\") return <div>Preparing...</div>;\n * if (status === \"executing\") return <div>Searching {parameters.query}</div>;\n * return <div>{result}</div>;\n * },\n * },\n * [],\n * );\n * ```\n */\nexport function useRenderTool<S extends StandardSchemaV1>(\n config: {\n name: string;\n parameters: S;\n render: (props: RenderToolProps<S>) => React.ReactElement;\n agentId?: string;\n },\n deps?: ReadonlyArray<unknown>,\n): void;\n\n/**\n * Registers a renderer entry in CopilotKit's `renderToolCalls` registry.\n *\n * Key behavior:\n * - deduplicates by `agentId:name` (latest registration wins),\n * - keeps renderer entries on cleanup so historical chat tool calls can still render,\n * - refreshes registration when `deps` change.\n *\n * @typeParam S - Schema type describing tool call parameters.\n * @param config - Renderer config for wildcard or named tools.\n * @param deps - Optional dependencies to refresh registration.\n *\n * @example\n * ```tsx\n * useRenderTool(\n * {\n * name: \"searchDocs\",\n * parameters: z.object({ query: z.string() }),\n * render: ({ status, parameters, result }) => {\n * if (status === \"executing\") return <div>Searching {parameters.query}</div>;\n * if (status === \"complete\") return <div>{result}</div>;\n * return <div>Preparing...</div>;\n * },\n * },\n * [],\n * );\n * ```\n *\n * @example\n * ```tsx\n * useRenderTool(\n * {\n * name: \"summarize\",\n * parameters: z.object({ text: z.string() }),\n * agentId: \"research-agent\",\n * render: ({ name, status }) => <div>{name}: {status}</div>,\n * },\n * [selectedAgentId],\n * );\n * ```\n */\nexport function useRenderTool<S extends StandardSchemaV1>(\n config: RenderToolConfig<S>,\n deps?: ReadonlyArray<unknown>,\n): void {\n const { copilotkit } = useCopilotKit();\n const extraDeps = deps ?? EMPTY_DEPS;\n\n useEffect(() => {\n // Build the ReactToolCallRenderer via defineToolCallRenderer\n const renderer =\n config.name === \"*\" && !config.parameters\n ? defineToolCallRenderer({\n name: \"*\",\n render: (props) =>\n config.render({ ...props, parameters: props.args }),\n ...(config.agentId ? { agentId: config.agentId } : {}),\n })\n : defineToolCallRenderer({\n name: config.name,\n args: config.parameters!,\n render: (props) =>\n config.render({ ...props, parameters: props.args }),\n ...(config.agentId ? { agentId: config.agentId } : {}),\n });\n\n // Dedupe by \"agentId:name\" key, same pattern as useFrontendTool\n const keyOf = (rc: ReactToolCallRenderer) =>\n `${rc.agentId ?? \"\"}:${rc.name}`;\n const currentRenderToolCalls =\n copilotkit.renderToolCalls as ReactToolCallRenderer[];\n\n const mergedMap = new Map<string, ReactToolCallRenderer>();\n for (const rc of currentRenderToolCalls) {\n mergedMap.set(keyOf(rc), rc);\n }\n\n mergedMap.set(keyOf(renderer), renderer);\n\n copilotkit.setRenderToolCalls(Array.from(mergedMap.values()));\n\n // No cleanup removal — keeps renderer for chat history, same as useFrontendTool\n }, [config.name, copilotkit, extraDeps.length, ...extraDeps]);\n}\n"],"mappings":";;;;;AASA,MAAM,aAAqC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkJ7C,SAAgB,cACd,QACA,MACM;CACN,MAAM,EAAE,eAAe,eAAe;CACtC,MAAM,YAAY,QAAQ;AAE1B,iBAAgB;EAEd,MAAM,WACJ,OAAO,SAAS,OAAO,CAAC,OAAO,aAC3B,uBAAuB;GACrB,MAAM;GACN,SAAS,UACP,OAAO,OAAO;IAAE,GAAG;IAAO,YAAY,MAAM;IAAM,CAAC;GACrD,GAAI,OAAO,UAAU,EAAE,SAAS,OAAO,SAAS,GAAG,EAAE;GACtD,CAAC,GACF,uBAAuB;GACrB,MAAM,OAAO;GACb,MAAM,OAAO;GACb,SAAS,UACP,OAAO,OAAO;IAAE,GAAG;IAAO,YAAY,MAAM;IAAM,CAAC;GACrD,GAAI,OAAO,UAAU,EAAE,SAAS,OAAO,SAAS,GAAG,EAAE;GACtD,CAAC;EAGR,MAAM,SAAS,OACb,GAAG,GAAG,WAAW,GAAG,GAAG,GAAG;EAC5B,MAAM,yBACJ,WAAW;EAEb,MAAM,4BAAY,IAAI,KAAoC;AAC1D,OAAK,MAAM,MAAM,uBACf,WAAU,IAAI,MAAM,GAAG,EAAE,GAAG;AAG9B,YAAU,IAAI,MAAM,SAAS,EAAE,SAAS;AAExC,aAAW,mBAAmB,MAAM,KAAK,UAAU,QAAQ,CAAC,CAAC;IAG5D;EAAC,OAAO;EAAM;EAAY,UAAU;EAAQ,GAAG;EAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKatexStyles.cjs","names":[],"sources":["../../src/hooks/useKatexStyles.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\n\nlet injected = false;\n\n/**\n * Dynamically injects KaTeX CSS at runtime to avoid the Next.js\n * \"Global CSS cannot be imported from within node_modules\" build error.\n *\n * Uses a singleton flag so the stylesheet is only injected once.\n */\nexport function useKatexStyles(): void {\n useEffect(() => {\n if (injected || typeof document === \"undefined\") return;\n injected = true;\n\n // Dynamic import defers CSS loading to runtime, bypassing\n // Next.js static analysis that rejects global CSS from node_modules.\n
|
|
1
|
+
{"version":3,"file":"useKatexStyles.cjs","names":[],"sources":["../../src/hooks/useKatexStyles.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\n\nlet injected = false;\n\n/**\n * Dynamically injects KaTeX CSS at runtime to avoid the Next.js\n * \"Global CSS cannot be imported from within node_modules\" build error.\n *\n * Uses a singleton flag so the stylesheet is only injected once.\n */\nexport function useKatexStyles(): void {\n useEffect(() => {\n if (injected || typeof document === \"undefined\") return;\n injected = true;\n\n // Dynamic import defers CSS loading to runtime, bypassing\n // Next.js static analysis that rejects global CSS from node_modules.\n\n void import(\"katex/dist/katex.min.css\").catch(() => {\n // Silently ignore — consumers can import KaTeX CSS manually\n });\n }, []);\n}\n"],"mappings":";;;;;;AAIA,IAAI,WAAW;;;;;;;AAQf,SAAgB,iBAAuB;AACrC,4BAAgB;AACd,MAAI,YAAY,OAAO,aAAa,YAAa;AACjD,aAAW;AAKX,EAAK,OAAO,4BAA4B,YAAY,GAElD;IACD,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKatexStyles.mjs","names":[],"sources":["../../src/hooks/useKatexStyles.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\n\nlet injected = false;\n\n/**\n * Dynamically injects KaTeX CSS at runtime to avoid the Next.js\n * \"Global CSS cannot be imported from within node_modules\" build error.\n *\n * Uses a singleton flag so the stylesheet is only injected once.\n */\nexport function useKatexStyles(): void {\n useEffect(() => {\n if (injected || typeof document === \"undefined\") return;\n injected = true;\n\n // Dynamic import defers CSS loading to runtime, bypassing\n // Next.js static analysis that rejects global CSS from node_modules.\n
|
|
1
|
+
{"version":3,"file":"useKatexStyles.mjs","names":[],"sources":["../../src/hooks/useKatexStyles.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\n\nlet injected = false;\n\n/**\n * Dynamically injects KaTeX CSS at runtime to avoid the Next.js\n * \"Global CSS cannot be imported from within node_modules\" build error.\n *\n * Uses a singleton flag so the stylesheet is only injected once.\n */\nexport function useKatexStyles(): void {\n useEffect(() => {\n if (injected || typeof document === \"undefined\") return;\n injected = true;\n\n // Dynamic import defers CSS loading to runtime, bypassing\n // Next.js static analysis that rejects global CSS from node_modules.\n\n void import(\"katex/dist/katex.min.css\").catch(() => {\n // Silently ignore — consumers can import KaTeX CSS manually\n });\n }, []);\n}\n"],"mappings":";;;;;AAIA,IAAI,WAAW;;;;;;;AAQf,SAAgB,iBAAuB;AACrC,iBAAgB;AACd,MAAI,YAAY,OAAO,aAAa,YAAa;AACjD,aAAW;AAKX,EAAK,OAAO,4BAA4B,YAAY,GAElD;IACD,EAAE,CAAC"}
|
package/dist/index.umd.js
CHANGED
|
@@ -2469,16 +2469,16 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2469
2469
|
*
|
|
2470
2470
|
* This hook is a convenience wrapper around `useFrontendTool` that:
|
|
2471
2471
|
* - builds a model-facing tool description,
|
|
2472
|
-
* - forwards optional
|
|
2472
|
+
* - forwards optional schema parameters (any Standard Schema V1 compatible library),
|
|
2473
2473
|
* - renders your component with tool call parameters.
|
|
2474
2474
|
*
|
|
2475
2475
|
* Use this when you want to display a typed visual component for a tool call
|
|
2476
2476
|
* without manually wiring a full frontend tool object.
|
|
2477
2477
|
*
|
|
2478
|
-
* When `parameters` is provided, render props are inferred from the schema
|
|
2479
|
-
*
|
|
2478
|
+
* When `parameters` is provided, render props are inferred from the schema.
|
|
2479
|
+
* When omitted, the render component may accept any props.
|
|
2480
2480
|
*
|
|
2481
|
-
* @typeParam TSchema -
|
|
2481
|
+
* @typeParam TSchema - Schema describing tool parameters, or `undefined` when no schema is given.
|
|
2482
2482
|
* @param config - Tool registration config.
|
|
2483
2483
|
* @param deps - Optional dependencies to refresh registration (same semantics as `useEffect`).
|
|
2484
2484
|
*
|
|
@@ -2552,7 +2552,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2552
2552
|
* - keeps renderer entries on cleanup so historical chat tool calls can still render,
|
|
2553
2553
|
* - refreshes registration when `deps` change.
|
|
2554
2554
|
*
|
|
2555
|
-
* @typeParam S -
|
|
2555
|
+
* @typeParam S - Schema type describing tool call parameters.
|
|
2556
2556
|
* @param config - Renderer config for wildcard or named tools.
|
|
2557
2557
|
* @param deps - Optional dependencies to refresh registration.
|
|
2558
2558
|
*
|