@copilotkitnext/react 1.53.1-next.2 → 1.54.0-next.4

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.
Files changed (53) hide show
  1. package/dist/hooks/use-component.cjs +4 -4
  2. package/dist/hooks/use-component.cjs.map +1 -1
  3. package/dist/hooks/use-component.d.cts +7 -7
  4. package/dist/hooks/use-component.d.cts.map +1 -1
  5. package/dist/hooks/use-component.d.mts +7 -7
  6. package/dist/hooks/use-component.d.mts.map +1 -1
  7. package/dist/hooks/use-component.mjs +4 -4
  8. package/dist/hooks/use-component.mjs.map +1 -1
  9. package/dist/hooks/use-frontend-tool.cjs +6 -14
  10. package/dist/hooks/use-frontend-tool.cjs.map +1 -1
  11. package/dist/hooks/use-frontend-tool.d.cts.map +1 -1
  12. package/dist/hooks/use-frontend-tool.d.mts.map +1 -1
  13. package/dist/hooks/use-frontend-tool.mjs +6 -14
  14. package/dist/hooks/use-frontend-tool.mjs.map +1 -1
  15. package/dist/hooks/use-human-in-the-loop.cjs +1 -6
  16. package/dist/hooks/use-human-in-the-loop.cjs.map +1 -1
  17. package/dist/hooks/use-human-in-the-loop.mjs +1 -6
  18. package/dist/hooks/use-human-in-the-loop.mjs.map +1 -1
  19. package/dist/hooks/use-render-tool.cjs +2 -7
  20. package/dist/hooks/use-render-tool.cjs.map +1 -1
  21. package/dist/hooks/use-render-tool.d.cts +13 -12
  22. package/dist/hooks/use-render-tool.d.cts.map +1 -1
  23. package/dist/hooks/use-render-tool.d.mts +13 -12
  24. package/dist/hooks/use-render-tool.d.mts.map +1 -1
  25. package/dist/hooks/use-render-tool.mjs +2 -7
  26. package/dist/hooks/use-render-tool.mjs.map +1 -1
  27. package/dist/hooks/useKatexStyles.cjs.map +1 -1
  28. package/dist/hooks/useKatexStyles.mjs.map +1 -1
  29. package/dist/index.umd.js +43 -41
  30. package/dist/index.umd.js.map +1 -1
  31. package/dist/lib/react-core.cjs +26 -1
  32. package/dist/lib/react-core.cjs.map +1 -1
  33. package/dist/lib/react-core.d.cts +5 -0
  34. package/dist/lib/react-core.d.cts.map +1 -1
  35. package/dist/lib/react-core.d.mts +5 -0
  36. package/dist/lib/react-core.d.mts.map +1 -1
  37. package/dist/lib/react-core.mjs +26 -1
  38. package/dist/lib/react-core.mjs.map +1 -1
  39. package/dist/types/defineToolCallRenderer.cjs.map +1 -1
  40. package/dist/types/defineToolCallRenderer.d.cts +5 -5
  41. package/dist/types/defineToolCallRenderer.d.cts.map +1 -1
  42. package/dist/types/defineToolCallRenderer.d.mts +5 -5
  43. package/dist/types/defineToolCallRenderer.d.mts.map +1 -1
  44. package/dist/types/defineToolCallRenderer.mjs.map +1 -1
  45. package/dist/types/react-activity-message-renderer.d.cts +2 -2
  46. package/dist/types/react-activity-message-renderer.d.cts.map +1 -1
  47. package/dist/types/react-activity-message-renderer.d.mts +2 -2
  48. package/dist/types/react-activity-message-renderer.d.mts.map +1 -1
  49. package/dist/types/react-tool-call-renderer.d.cts +2 -2
  50. package/dist/types/react-tool-call-renderer.d.cts.map +1 -1
  51. package/dist/types/react-tool-call-renderer.d.mts +2 -2
  52. package/dist/types/react-tool-call-renderer.d.mts.map +1 -1
  53. 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 Zod parameters,
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
- * via `z.infer`. When omitted, the render component may accept any props.
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 - Zod schema describing tool parameters, or `undefined` when no schema is given.
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 { z } from \"zod\";\nimport type { ComponentType } from \"react\";\nimport { useFrontendTool } from \"./use-frontend-tool\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype InferRenderProps<T> = T extends z.ZodTypeAny ? z.infer<T> : 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 Zod parameters,\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 * via `z.infer`. When omitted, the render component may accept any props.\n *\n * @typeParam TSchema - Zod 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 z.ZodTypeAny | 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,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
+ {"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 { z } from "zod";
2
+ import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkitnext/shared";
3
3
 
4
4
  //#region src/hooks/use-component.d.ts
5
- type InferRenderProps<T> = T extends z.ZodTypeAny ? z.infer<T> : any;
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 Zod parameters,
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
- * via `z.infer`. When omitted, the render component may accept any props.
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 - Zod schema describing tool parameters, or `undefined` when no schema is given.
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 z.ZodTypeAny | undefined = undefined>(config: {
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":";;;;KAKK,gBAAA,MAAsB,CAAA,SAAU,CAAA,CAAE,UAAA,GAAa,CAAA,CAAE,KAAA,CAAM,CAAA;;AAJjB;;;;;;;;;;;;;;;;;;AAwD3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,YAAA,iBACE,CAAA,CAAE,UAAA,yBAAA,CAElB,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
+ {"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 { z } from "zod";
2
+ import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkitnext/shared";
3
3
 
4
4
  //#region src/hooks/use-component.d.ts
5
- type InferRenderProps<T> = T extends z.ZodTypeAny ? z.infer<T> : any;
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 Zod parameters,
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
- * via `z.infer`. When omitted, the render component may accept any props.
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 - Zod schema describing tool parameters, or `undefined` when no schema is given.
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 z.ZodTypeAny | undefined = undefined>(config: {
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":";;;;KAKK,gBAAA,MAAsB,CAAA,SAAU,CAAA,CAAE,UAAA,GAAa,CAAA,CAAE,KAAA,CAAM,CAAA;;AAJjB;;;;;;;;;;;;;;;;;;AAwD3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,YAAA,iBACE,CAAA,CAAE,UAAA,yBAAA,CAElB,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
+ {"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 Zod parameters,
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
- * via `z.infer`. When omitted, the render component may accept any props.
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 - Zod schema describing tool parameters, or `undefined` when no schema is given.
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 { z } from \"zod\";\nimport type { ComponentType } from \"react\";\nimport { useFrontendTool } from \"./use-frontend-tool\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype InferRenderProps<T> = T extends z.ZodTypeAny ? z.infer<T> : 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 Zod parameters,\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 * via `z.infer`. When omitted, the render component may accept any props.\n *\n * @typeParam TSchema - Zod 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 z.ZodTypeAny | 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,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"}
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"}
@@ -17,20 +17,12 @@ function useFrontendTool(tool, deps) {
17
17
  copilotkit.removeTool(name, tool.agentId);
18
18
  }
19
19
  copilotkit.addTool(tool);
20
- if (tool.render) {
21
- const keyOf = (rc) => `${rc.agentId ?? ""}:${rc.name}`;
22
- const currentRenderToolCalls = copilotkit.renderToolCalls;
23
- const mergedMap = /* @__PURE__ */ new Map();
24
- for (const rc of currentRenderToolCalls) mergedMap.set(keyOf(rc), rc);
25
- const newEntry = {
26
- name,
27
- args: tool.parameters,
28
- agentId: tool.agentId,
29
- render: tool.render
30
- };
31
- mergedMap.set(keyOf(newEntry), newEntry);
32
- copilotkit.setRenderToolCalls(Array.from(mergedMap.values()));
33
- }
20
+ if (tool.render && tool.parameters) copilotkit.addHookRenderToolCall({
21
+ name,
22
+ args: tool.parameters,
23
+ agentId: tool.agentId,
24
+ render: tool.render
25
+ });
34
26
  return () => {
35
27
  copilotkit.removeTool(name, tool.agentId);
36
28
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-frontend-tool.cjs","names":["useCopilotKit"],"sources":["../../src/hooks/use-frontend-tool.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useCopilotKit } from \"../providers/CopilotKitProvider\";\nimport type { ReactFrontendTool } from \"../types/frontend-tool\";\nimport type { ReactToolCallRenderer } from \"../types/react-tool-call-renderer\";\n\nconst EMPTY_DEPS: ReadonlyArray<unknown> = [];\n\nexport function useFrontendTool<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(tool: ReactFrontendTool<T>, deps?: ReadonlyArray<unknown>) {\n const { copilotkit } = useCopilotKit();\n const extraDeps = deps ?? EMPTY_DEPS;\n\n useEffect(() => {\n const name = tool.name;\n\n // Always register/override the tool for this name on mount\n if (copilotkit.getTool({ toolName: name, agentId: tool.agentId })) {\n console.warn(\n `Tool '${name}' already exists for agent '${tool.agentId || \"global\"}'. Overriding with latest registration.`,\n );\n copilotkit.removeTool(name, tool.agentId);\n }\n copilotkit.addTool(tool);\n\n // Register/override renderer by name and agentId through core\n if (tool.render) {\n // Get current render tool calls and merge with new entry\n const keyOf = (rc: ReactToolCallRenderer) =>\n `${rc.agentId ?? \"\"}:${rc.name}`;\n const currentRenderToolCalls =\n copilotkit.renderToolCalls as ReactToolCallRenderer[];\n\n // Build map from existing entries\n const mergedMap = new Map<string, ReactToolCallRenderer>();\n for (const rc of currentRenderToolCalls) {\n mergedMap.set(keyOf(rc), rc);\n }\n\n // Add/overwrite with new entry\n const newEntry: ReactToolCallRenderer = {\n name,\n args: tool.parameters,\n agentId: tool.agentId,\n render: tool.render,\n } as ReactToolCallRenderer;\n mergedMap.set(keyOf(newEntry), newEntry);\n\n // Set the merged list back\n copilotkit.setRenderToolCalls(Array.from(mergedMap.values()));\n }\n\n return () => {\n copilotkit.removeTool(name, tool.agentId);\n // we are intentionally not removing the render here so that the tools can still render in the chat history\n };\n // Depend on stable keys by default and allow callers to opt into\n // additional dependencies for dynamic tool configuration.\n // tool.available is included so toggling availability re-registers the tool.\n }, [tool.name, tool.available, copilotkit, extraDeps.length, ...extraDeps]);\n}\n"],"mappings":";;;;;AAKA,MAAM,aAAqC,EAAE;AAE7C,SAAgB,gBAEd,MAA4B,MAA+B;CAC3D,MAAM,EAAE,eAAeA,0CAAe;CACtC,MAAM,YAAY,QAAQ;AAE1B,4BAAgB;EACd,MAAM,OAAO,KAAK;AAGlB,MAAI,WAAW,QAAQ;GAAE,UAAU;GAAM,SAAS,KAAK;GAAS,CAAC,EAAE;AACjE,WAAQ,KACN,SAAS,KAAK,8BAA8B,KAAK,WAAW,SAAS,yCACtE;AACD,cAAW,WAAW,MAAM,KAAK,QAAQ;;AAE3C,aAAW,QAAQ,KAAK;AAGxB,MAAI,KAAK,QAAQ;GAEf,MAAM,SAAS,OACb,GAAG,GAAG,WAAW,GAAG,GAAG,GAAG;GAC5B,MAAM,yBACJ,WAAW;GAGb,MAAM,4BAAY,IAAI,KAAoC;AAC1D,QAAK,MAAM,MAAM,uBACf,WAAU,IAAI,MAAM,GAAG,EAAE,GAAG;GAI9B,MAAM,WAAkC;IACtC;IACA,MAAM,KAAK;IACX,SAAS,KAAK;IACd,QAAQ,KAAK;IACd;AACD,aAAU,IAAI,MAAM,SAAS,EAAE,SAAS;AAGxC,cAAW,mBAAmB,MAAM,KAAK,UAAU,QAAQ,CAAC,CAAC;;AAG/D,eAAa;AACX,cAAW,WAAW,MAAM,KAAK,QAAQ;;IAM1C;EAAC,KAAK;EAAM,KAAK;EAAW;EAAY,UAAU;EAAQ,GAAG;EAAU,CAAC"}
1
+ {"version":3,"file":"use-frontend-tool.cjs","names":["useCopilotKit"],"sources":["../../src/hooks/use-frontend-tool.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useCopilotKit } from \"../providers/CopilotKitProvider\";\nimport type { ReactFrontendTool } from \"../types/frontend-tool\";\n\nconst EMPTY_DEPS: ReadonlyArray<unknown> = [];\n\nexport function useFrontendTool<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(tool: ReactFrontendTool<T>, deps?: ReadonlyArray<unknown>) {\n const { copilotkit } = useCopilotKit();\n const extraDeps = deps ?? EMPTY_DEPS;\n\n useEffect(() => {\n const name = tool.name;\n\n // Always register/override the tool for this name on mount\n if (copilotkit.getTool({ toolName: name, agentId: tool.agentId })) {\n console.warn(\n `Tool '${name}' already exists for agent '${tool.agentId || \"global\"}'. Overriding with latest registration.`,\n );\n copilotkit.removeTool(name, tool.agentId);\n }\n copilotkit.addTool(tool);\n\n // Register/override renderer by name and agentId through core\n if (tool.render && tool.parameters) {\n copilotkit.addHookRenderToolCall({\n name,\n args: tool.parameters,\n agentId: tool.agentId,\n render: tool.render,\n });\n }\n\n return () => {\n copilotkit.removeTool(name, tool.agentId);\n // we are intentionally not removing the render here so that the tools can still render in the chat history\n };\n // Depend on stable keys by default and allow callers to opt into\n // additional dependencies for dynamic tool configuration.\n // tool.available is included so toggling availability re-registers the tool.\n }, [tool.name, tool.available, copilotkit, extraDeps.length, ...extraDeps]);\n}\n"],"mappings":";;;;;AAIA,MAAM,aAAqC,EAAE;AAE7C,SAAgB,gBAEd,MAA4B,MAA+B;CAC3D,MAAM,EAAE,eAAeA,0CAAe;CACtC,MAAM,YAAY,QAAQ;AAE1B,4BAAgB;EACd,MAAM,OAAO,KAAK;AAGlB,MAAI,WAAW,QAAQ;GAAE,UAAU;GAAM,SAAS,KAAK;GAAS,CAAC,EAAE;AACjE,WAAQ,KACN,SAAS,KAAK,8BAA8B,KAAK,WAAW,SAAS,yCACtE;AACD,cAAW,WAAW,MAAM,KAAK,QAAQ;;AAE3C,aAAW,QAAQ,KAAK;AAGxB,MAAI,KAAK,UAAU,KAAK,WACtB,YAAW,sBAAsB;GAC/B;GACA,MAAM,KAAK;GACX,SAAS,KAAK;GACd,QAAQ,KAAK;GACd,CAAC;AAGJ,eAAa;AACX,cAAW,WAAW,MAAM,KAAK,QAAQ;;IAM1C;EAAC,KAAK;EAAM,KAAK;EAAW;EAAY,UAAU;EAAQ,GAAG;EAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-frontend-tool.d.cts","names":[],"sources":["../../src/hooks/use-frontend-tool.tsx"],"mappings":";;;iBAOgB,eAAA,WACJ,MAAA,oBAA0B,MAAA,kBAAA,CACpC,IAAA,EAAM,iBAAA,CAAkB,CAAA,GAAI,IAAA,GAAO,aAAA"}
1
+ {"version":3,"file":"use-frontend-tool.d.cts","names":[],"sources":["../../src/hooks/use-frontend-tool.tsx"],"mappings":";;;iBAMgB,eAAA,WACJ,MAAA,oBAA0B,MAAA,kBAAA,CACpC,IAAA,EAAM,iBAAA,CAAkB,CAAA,GAAI,IAAA,GAAO,aAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-frontend-tool.d.mts","names":[],"sources":["../../src/hooks/use-frontend-tool.tsx"],"mappings":";;;iBAOgB,eAAA,WACJ,MAAA,oBAA0B,MAAA,kBAAA,CACpC,IAAA,EAAM,iBAAA,CAAkB,CAAA,GAAI,IAAA,GAAO,aAAA"}
1
+ {"version":3,"file":"use-frontend-tool.d.mts","names":[],"sources":["../../src/hooks/use-frontend-tool.tsx"],"mappings":";;;iBAMgB,eAAA,WACJ,MAAA,oBAA0B,MAAA,kBAAA,CACpC,IAAA,EAAM,iBAAA,CAAkB,CAAA,GAAI,IAAA,GAAO,aAAA"}
@@ -16,20 +16,12 @@ function useFrontendTool(tool, deps) {
16
16
  copilotkit.removeTool(name, tool.agentId);
17
17
  }
18
18
  copilotkit.addTool(tool);
19
- if (tool.render) {
20
- const keyOf = (rc) => `${rc.agentId ?? ""}:${rc.name}`;
21
- const currentRenderToolCalls = copilotkit.renderToolCalls;
22
- const mergedMap = /* @__PURE__ */ new Map();
23
- for (const rc of currentRenderToolCalls) mergedMap.set(keyOf(rc), rc);
24
- const newEntry = {
25
- name,
26
- args: tool.parameters,
27
- agentId: tool.agentId,
28
- render: tool.render
29
- };
30
- mergedMap.set(keyOf(newEntry), newEntry);
31
- copilotkit.setRenderToolCalls(Array.from(mergedMap.values()));
32
- }
19
+ if (tool.render && tool.parameters) copilotkit.addHookRenderToolCall({
20
+ name,
21
+ args: tool.parameters,
22
+ agentId: tool.agentId,
23
+ render: tool.render
24
+ });
33
25
  return () => {
34
26
  copilotkit.removeTool(name, tool.agentId);
35
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-frontend-tool.mjs","names":[],"sources":["../../src/hooks/use-frontend-tool.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useCopilotKit } from \"../providers/CopilotKitProvider\";\nimport type { ReactFrontendTool } from \"../types/frontend-tool\";\nimport type { ReactToolCallRenderer } from \"../types/react-tool-call-renderer\";\n\nconst EMPTY_DEPS: ReadonlyArray<unknown> = [];\n\nexport function useFrontendTool<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(tool: ReactFrontendTool<T>, deps?: ReadonlyArray<unknown>) {\n const { copilotkit } = useCopilotKit();\n const extraDeps = deps ?? EMPTY_DEPS;\n\n useEffect(() => {\n const name = tool.name;\n\n // Always register/override the tool for this name on mount\n if (copilotkit.getTool({ toolName: name, agentId: tool.agentId })) {\n console.warn(\n `Tool '${name}' already exists for agent '${tool.agentId || \"global\"}'. Overriding with latest registration.`,\n );\n copilotkit.removeTool(name, tool.agentId);\n }\n copilotkit.addTool(tool);\n\n // Register/override renderer by name and agentId through core\n if (tool.render) {\n // Get current render tool calls and merge with new entry\n const keyOf = (rc: ReactToolCallRenderer) =>\n `${rc.agentId ?? \"\"}:${rc.name}`;\n const currentRenderToolCalls =\n copilotkit.renderToolCalls as ReactToolCallRenderer[];\n\n // Build map from existing entries\n const mergedMap = new Map<string, ReactToolCallRenderer>();\n for (const rc of currentRenderToolCalls) {\n mergedMap.set(keyOf(rc), rc);\n }\n\n // Add/overwrite with new entry\n const newEntry: ReactToolCallRenderer = {\n name,\n args: tool.parameters,\n agentId: tool.agentId,\n render: tool.render,\n } as ReactToolCallRenderer;\n mergedMap.set(keyOf(newEntry), newEntry);\n\n // Set the merged list back\n copilotkit.setRenderToolCalls(Array.from(mergedMap.values()));\n }\n\n return () => {\n copilotkit.removeTool(name, tool.agentId);\n // we are intentionally not removing the render here so that the tools can still render in the chat history\n };\n // Depend on stable keys by default and allow callers to opt into\n // additional dependencies for dynamic tool configuration.\n // tool.available is included so toggling availability re-registers the tool.\n }, [tool.name, tool.available, copilotkit, extraDeps.length, ...extraDeps]);\n}\n"],"mappings":";;;;AAKA,MAAM,aAAqC,EAAE;AAE7C,SAAgB,gBAEd,MAA4B,MAA+B;CAC3D,MAAM,EAAE,eAAe,eAAe;CACtC,MAAM,YAAY,QAAQ;AAE1B,iBAAgB;EACd,MAAM,OAAO,KAAK;AAGlB,MAAI,WAAW,QAAQ;GAAE,UAAU;GAAM,SAAS,KAAK;GAAS,CAAC,EAAE;AACjE,WAAQ,KACN,SAAS,KAAK,8BAA8B,KAAK,WAAW,SAAS,yCACtE;AACD,cAAW,WAAW,MAAM,KAAK,QAAQ;;AAE3C,aAAW,QAAQ,KAAK;AAGxB,MAAI,KAAK,QAAQ;GAEf,MAAM,SAAS,OACb,GAAG,GAAG,WAAW,GAAG,GAAG,GAAG;GAC5B,MAAM,yBACJ,WAAW;GAGb,MAAM,4BAAY,IAAI,KAAoC;AAC1D,QAAK,MAAM,MAAM,uBACf,WAAU,IAAI,MAAM,GAAG,EAAE,GAAG;GAI9B,MAAM,WAAkC;IACtC;IACA,MAAM,KAAK;IACX,SAAS,KAAK;IACd,QAAQ,KAAK;IACd;AACD,aAAU,IAAI,MAAM,SAAS,EAAE,SAAS;AAGxC,cAAW,mBAAmB,MAAM,KAAK,UAAU,QAAQ,CAAC,CAAC;;AAG/D,eAAa;AACX,cAAW,WAAW,MAAM,KAAK,QAAQ;;IAM1C;EAAC,KAAK;EAAM,KAAK;EAAW;EAAY,UAAU;EAAQ,GAAG;EAAU,CAAC"}
1
+ {"version":3,"file":"use-frontend-tool.mjs","names":[],"sources":["../../src/hooks/use-frontend-tool.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useCopilotKit } from \"../providers/CopilotKitProvider\";\nimport type { ReactFrontendTool } from \"../types/frontend-tool\";\n\nconst EMPTY_DEPS: ReadonlyArray<unknown> = [];\n\nexport function useFrontendTool<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(tool: ReactFrontendTool<T>, deps?: ReadonlyArray<unknown>) {\n const { copilotkit } = useCopilotKit();\n const extraDeps = deps ?? EMPTY_DEPS;\n\n useEffect(() => {\n const name = tool.name;\n\n // Always register/override the tool for this name on mount\n if (copilotkit.getTool({ toolName: name, agentId: tool.agentId })) {\n console.warn(\n `Tool '${name}' already exists for agent '${tool.agentId || \"global\"}'. Overriding with latest registration.`,\n );\n copilotkit.removeTool(name, tool.agentId);\n }\n copilotkit.addTool(tool);\n\n // Register/override renderer by name and agentId through core\n if (tool.render && tool.parameters) {\n copilotkit.addHookRenderToolCall({\n name,\n args: tool.parameters,\n agentId: tool.agentId,\n render: tool.render,\n });\n }\n\n return () => {\n copilotkit.removeTool(name, tool.agentId);\n // we are intentionally not removing the render here so that the tools can still render in the chat history\n };\n // Depend on stable keys by default and allow callers to opt into\n // additional dependencies for dynamic tool configuration.\n // tool.available is included so toggling availability re-registers the tool.\n }, [tool.name, tool.available, copilotkit, extraDeps.length, ...extraDeps]);\n}\n"],"mappings":";;;;AAIA,MAAM,aAAqC,EAAE;AAE7C,SAAgB,gBAEd,MAA4B,MAA+B;CAC3D,MAAM,EAAE,eAAe,eAAe;CACtC,MAAM,YAAY,QAAQ;AAE1B,iBAAgB;EACd,MAAM,OAAO,KAAK;AAGlB,MAAI,WAAW,QAAQ;GAAE,UAAU;GAAM,SAAS,KAAK;GAAS,CAAC,EAAE;AACjE,WAAQ,KACN,SAAS,KAAK,8BAA8B,KAAK,WAAW,SAAS,yCACtE;AACD,cAAW,WAAW,MAAM,KAAK,QAAQ;;AAE3C,aAAW,QAAQ,KAAK;AAGxB,MAAI,KAAK,UAAU,KAAK,WACtB,YAAW,sBAAsB;GAC/B;GACA,MAAM,KAAK;GACX,SAAS,KAAK;GACd,QAAQ,KAAK;GACd,CAAC;AAGJ,eAAa;AACX,cAAW,WAAW,MAAM,KAAK,QAAQ;;IAM1C;EAAC,KAAK;EAAM,KAAK;EAAW;EAAY,UAAU;EAAQ,GAAG;EAAU,CAAC"}
@@ -60,12 +60,7 @@ function useHumanInTheLoop(tool, deps) {
60
60
  }, deps);
61
61
  (0, react.useEffect)(() => {
62
62
  return () => {
63
- const keyOf = (rc) => `${rc.agentId ?? ""}:${rc.name}`;
64
- const filtered = copilotkit.renderToolCalls.filter((rc) => keyOf(rc) !== keyOf({
65
- name: tool.name,
66
- agentId: tool.agentId
67
- }));
68
- copilotkit.setRenderToolCalls(filtered);
63
+ copilotkit.removeHookRenderToolCall(tool.name, tool.agentId);
69
64
  };
70
65
  }, [
71
66
  copilotkit,
@@ -1 +1 @@
1
- {"version":3,"file":"use-human-in-the-loop.cjs","names":["useCopilotKit","React"],"sources":["../../src/hooks/use-human-in-the-loop.tsx"],"sourcesContent":["import { useCopilotKit } from \"@/providers/CopilotKitProvider\";\nimport type { ReactFrontendTool } from \"@/types/frontend-tool\";\nimport type { ReactHumanInTheLoop } from \"@/types/human-in-the-loop\";\nimport type { ReactToolCallRenderer } from \"@/types/react-tool-call-renderer\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport React from \"react\";\nimport { useFrontendTool } from \"./use-frontend-tool\";\n\nexport function useHumanInTheLoop<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(tool: ReactHumanInTheLoop<T>, deps?: ReadonlyArray<unknown>) {\n const { copilotkit } = useCopilotKit();\n const resolvePromiseRef = useRef<((result: unknown) => void) | null>(null);\n\n const respond = useCallback(async (result: unknown) => {\n if (resolvePromiseRef.current) {\n resolvePromiseRef.current(result);\n resolvePromiseRef.current = null;\n }\n }, []);\n\n const handler = useCallback(async () => {\n return new Promise((resolve) => {\n resolvePromiseRef.current = resolve;\n });\n }, []);\n\n const RenderComponent: ReactToolCallRenderer<T>[\"render\"] = useCallback(\n (props) => {\n const ToolComponent = tool.render;\n\n // Enhance props based on current status\n if (props.status === \"inProgress\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond: undefined,\n };\n return React.createElement(ToolComponent, enhancedProps);\n } else if (props.status === \"executing\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond,\n };\n return React.createElement(ToolComponent, enhancedProps);\n } else if (props.status === \"complete\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond: undefined,\n };\n return React.createElement(ToolComponent, enhancedProps);\n }\n\n // Fallback - just render with original props\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return React.createElement(ToolComponent, props as any);\n },\n [tool.render, tool.name, tool.description, respond],\n );\n\n const frontendTool: ReactFrontendTool<T> = {\n ...tool,\n handler,\n render: RenderComponent,\n };\n\n useFrontendTool(frontendTool, deps);\n\n // Human-in-the-loop tools should remove their renderer on unmount\n // since they can't respond to user interactions anymore\n useEffect(() => {\n return () => {\n const keyOf = (rc: ReactToolCallRenderer<any>) =>\n `${rc.agentId ?? \"\"}:${rc.name}`;\n const currentRenderToolCalls =\n copilotkit.renderToolCalls as ReactToolCallRenderer<any>[];\n const filtered = currentRenderToolCalls.filter(\n (rc) =>\n keyOf(rc) !==\n keyOf({ name: tool.name, agentId: tool.agentId } as any),\n );\n copilotkit.setRenderToolCalls(filtered);\n };\n }, [copilotkit, tool.name, tool.agentId]);\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,kBAEd,MAA8B,MAA+B;CAC7D,MAAM,EAAE,eAAeA,0CAAe;CACtC,MAAM,sCAA+D,KAAK;CAE1E,MAAM,iCAAsB,OAAO,WAAoB;AACrD,MAAI,kBAAkB,SAAS;AAC7B,qBAAkB,QAAQ,OAAO;AACjC,qBAAkB,UAAU;;IAE7B,EAAE,CAAC;CAEN,MAAM,iCAAsB,YAAY;AACtC,SAAO,IAAI,SAAS,YAAY;AAC9B,qBAAkB,UAAU;IAC5B;IACD,EAAE,CAAC;CAEN,MAAM,0CACH,UAAU;EACT,MAAM,gBAAgB,KAAK;AAG3B,MAAI,MAAM,WAAW,cAAc;GACjC,MAAM,gBAAgB;IACpB,GAAG;IACH,MAAM,KAAK;IACX,aAAa,KAAK,eAAe;IACjC,SAAS;IACV;AACD,UAAOC,cAAM,cAAc,eAAe,cAAc;aAC/C,MAAM,WAAW,aAAa;GACvC,MAAM,gBAAgB;IACpB,GAAG;IACH,MAAM,KAAK;IACX,aAAa,KAAK,eAAe;IACjC;IACD;AACD,UAAOA,cAAM,cAAc,eAAe,cAAc;aAC/C,MAAM,WAAW,YAAY;GACtC,MAAM,gBAAgB;IACpB,GAAG;IACH,MAAM,KAAK;IACX,aAAa,KAAK,eAAe;IACjC,SAAS;IACV;AACD,UAAOA,cAAM,cAAc,eAAe,cAAc;;AAK1D,SAAOA,cAAM,cAAc,eAAe,MAAa;IAEzD;EAAC,KAAK;EAAQ,KAAK;EAAM,KAAK;EAAa;EAAQ,CACpD;AAQD,2CAN2C;EACzC,GAAG;EACH;EACA,QAAQ;EACT,EAE6B,KAAK;AAInC,4BAAgB;AACd,eAAa;GACX,MAAM,SAAS,OACb,GAAG,GAAG,WAAW,GAAG,GAAG,GAAG;GAG5B,MAAM,WADJ,WAAW,gBAC2B,QACrC,OACC,MAAM,GAAG,KACT,MAAM;IAAE,MAAM,KAAK;IAAM,SAAS,KAAK;IAAS,CAAQ,CAC3D;AACD,cAAW,mBAAmB,SAAS;;IAExC;EAAC;EAAY,KAAK;EAAM,KAAK;EAAQ,CAAC"}
1
+ {"version":3,"file":"use-human-in-the-loop.cjs","names":["useCopilotKit","React"],"sources":["../../src/hooks/use-human-in-the-loop.tsx"],"sourcesContent":["import { useCopilotKit } from \"@/providers/CopilotKitProvider\";\nimport type { ReactFrontendTool } from \"@/types/frontend-tool\";\nimport type { ReactHumanInTheLoop } from \"@/types/human-in-the-loop\";\nimport type { ReactToolCallRenderer } from \"@/types/react-tool-call-renderer\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport React from \"react\";\nimport { useFrontendTool } from \"./use-frontend-tool\";\n\nexport function useHumanInTheLoop<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(tool: ReactHumanInTheLoop<T>, deps?: ReadonlyArray<unknown>) {\n const { copilotkit } = useCopilotKit();\n const resolvePromiseRef = useRef<((result: unknown) => void) | null>(null);\n\n const respond = useCallback(async (result: unknown) => {\n if (resolvePromiseRef.current) {\n resolvePromiseRef.current(result);\n resolvePromiseRef.current = null;\n }\n }, []);\n\n const handler = useCallback(async () => {\n return new Promise((resolve) => {\n resolvePromiseRef.current = resolve;\n });\n }, []);\n\n const RenderComponent: ReactToolCallRenderer<T>[\"render\"] = useCallback(\n (props) => {\n const ToolComponent = tool.render;\n\n // Enhance props based on current status\n if (props.status === \"inProgress\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond: undefined,\n };\n return React.createElement(ToolComponent, enhancedProps);\n } else if (props.status === \"executing\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond,\n };\n return React.createElement(ToolComponent, enhancedProps);\n } else if (props.status === \"complete\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond: undefined,\n };\n return React.createElement(ToolComponent, enhancedProps);\n }\n\n // Fallback - just render with original props\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return React.createElement(ToolComponent, props as any);\n },\n [tool.render, tool.name, tool.description, respond],\n );\n\n const frontendTool: ReactFrontendTool<T> = {\n ...tool,\n handler,\n render: RenderComponent,\n };\n\n useFrontendTool(frontendTool, deps);\n\n // Human-in-the-loop tools should remove their renderer on unmount\n // since they can't respond to user interactions anymore\n useEffect(() => {\n return () => {\n copilotkit.removeHookRenderToolCall(tool.name, tool.agentId);\n };\n }, [copilotkit, tool.name, tool.agentId]);\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,kBAEd,MAA8B,MAA+B;CAC7D,MAAM,EAAE,eAAeA,0CAAe;CACtC,MAAM,sCAA+D,KAAK;CAE1E,MAAM,iCAAsB,OAAO,WAAoB;AACrD,MAAI,kBAAkB,SAAS;AAC7B,qBAAkB,QAAQ,OAAO;AACjC,qBAAkB,UAAU;;IAE7B,EAAE,CAAC;CAEN,MAAM,iCAAsB,YAAY;AACtC,SAAO,IAAI,SAAS,YAAY;AAC9B,qBAAkB,UAAU;IAC5B;IACD,EAAE,CAAC;CAEN,MAAM,0CACH,UAAU;EACT,MAAM,gBAAgB,KAAK;AAG3B,MAAI,MAAM,WAAW,cAAc;GACjC,MAAM,gBAAgB;IACpB,GAAG;IACH,MAAM,KAAK;IACX,aAAa,KAAK,eAAe;IACjC,SAAS;IACV;AACD,UAAOC,cAAM,cAAc,eAAe,cAAc;aAC/C,MAAM,WAAW,aAAa;GACvC,MAAM,gBAAgB;IACpB,GAAG;IACH,MAAM,KAAK;IACX,aAAa,KAAK,eAAe;IACjC;IACD;AACD,UAAOA,cAAM,cAAc,eAAe,cAAc;aAC/C,MAAM,WAAW,YAAY;GACtC,MAAM,gBAAgB;IACpB,GAAG;IACH,MAAM,KAAK;IACX,aAAa,KAAK,eAAe;IACjC,SAAS;IACV;AACD,UAAOA,cAAM,cAAc,eAAe,cAAc;;AAK1D,SAAOA,cAAM,cAAc,eAAe,MAAa;IAEzD;EAAC,KAAK;EAAQ,KAAK;EAAM,KAAK;EAAa;EAAQ,CACpD;AAQD,2CAN2C;EACzC,GAAG;EACH;EACA,QAAQ;EACT,EAE6B,KAAK;AAInC,4BAAgB;AACd,eAAa;AACX,cAAW,yBAAyB,KAAK,MAAM,KAAK,QAAQ;;IAE7D;EAAC;EAAY,KAAK;EAAM,KAAK;EAAQ,CAAC"}
@@ -58,12 +58,7 @@ function useHumanInTheLoop(tool, deps) {
58
58
  }, deps);
59
59
  useEffect(() => {
60
60
  return () => {
61
- const keyOf = (rc) => `${rc.agentId ?? ""}:${rc.name}`;
62
- const filtered = copilotkit.renderToolCalls.filter((rc) => keyOf(rc) !== keyOf({
63
- name: tool.name,
64
- agentId: tool.agentId
65
- }));
66
- copilotkit.setRenderToolCalls(filtered);
61
+ copilotkit.removeHookRenderToolCall(tool.name, tool.agentId);
67
62
  };
68
63
  }, [
69
64
  copilotkit,
@@ -1 +1 @@
1
- {"version":3,"file":"use-human-in-the-loop.mjs","names":[],"sources":["../../src/hooks/use-human-in-the-loop.tsx"],"sourcesContent":["import { useCopilotKit } from \"@/providers/CopilotKitProvider\";\nimport type { ReactFrontendTool } from \"@/types/frontend-tool\";\nimport type { ReactHumanInTheLoop } from \"@/types/human-in-the-loop\";\nimport type { ReactToolCallRenderer } from \"@/types/react-tool-call-renderer\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport React from \"react\";\nimport { useFrontendTool } from \"./use-frontend-tool\";\n\nexport function useHumanInTheLoop<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(tool: ReactHumanInTheLoop<T>, deps?: ReadonlyArray<unknown>) {\n const { copilotkit } = useCopilotKit();\n const resolvePromiseRef = useRef<((result: unknown) => void) | null>(null);\n\n const respond = useCallback(async (result: unknown) => {\n if (resolvePromiseRef.current) {\n resolvePromiseRef.current(result);\n resolvePromiseRef.current = null;\n }\n }, []);\n\n const handler = useCallback(async () => {\n return new Promise((resolve) => {\n resolvePromiseRef.current = resolve;\n });\n }, []);\n\n const RenderComponent: ReactToolCallRenderer<T>[\"render\"] = useCallback(\n (props) => {\n const ToolComponent = tool.render;\n\n // Enhance props based on current status\n if (props.status === \"inProgress\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond: undefined,\n };\n return React.createElement(ToolComponent, enhancedProps);\n } else if (props.status === \"executing\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond,\n };\n return React.createElement(ToolComponent, enhancedProps);\n } else if (props.status === \"complete\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond: undefined,\n };\n return React.createElement(ToolComponent, enhancedProps);\n }\n\n // Fallback - just render with original props\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return React.createElement(ToolComponent, props as any);\n },\n [tool.render, tool.name, tool.description, respond],\n );\n\n const frontendTool: ReactFrontendTool<T> = {\n ...tool,\n handler,\n render: RenderComponent,\n };\n\n useFrontendTool(frontendTool, deps);\n\n // Human-in-the-loop tools should remove their renderer on unmount\n // since they can't respond to user interactions anymore\n useEffect(() => {\n return () => {\n const keyOf = (rc: ReactToolCallRenderer<any>) =>\n `${rc.agentId ?? \"\"}:${rc.name}`;\n const currentRenderToolCalls =\n copilotkit.renderToolCalls as ReactToolCallRenderer<any>[];\n const filtered = currentRenderToolCalls.filter(\n (rc) =>\n keyOf(rc) !==\n keyOf({ name: tool.name, agentId: tool.agentId } as any),\n );\n copilotkit.setRenderToolCalls(filtered);\n };\n }, [copilotkit, tool.name, tool.agentId]);\n}\n"],"mappings":";;;;;AAQA,SAAgB,kBAEd,MAA8B,MAA+B;CAC7D,MAAM,EAAE,eAAe,eAAe;CACtC,MAAM,oBAAoB,OAA2C,KAAK;CAE1E,MAAM,UAAU,YAAY,OAAO,WAAoB;AACrD,MAAI,kBAAkB,SAAS;AAC7B,qBAAkB,QAAQ,OAAO;AACjC,qBAAkB,UAAU;;IAE7B,EAAE,CAAC;CAEN,MAAM,UAAU,YAAY,YAAY;AACtC,SAAO,IAAI,SAAS,YAAY;AAC9B,qBAAkB,UAAU;IAC5B;IACD,EAAE,CAAC;CAEN,MAAM,kBAAsD,aACzD,UAAU;EACT,MAAM,gBAAgB,KAAK;AAG3B,MAAI,MAAM,WAAW,cAAc;GACjC,MAAM,gBAAgB;IACpB,GAAG;IACH,MAAM,KAAK;IACX,aAAa,KAAK,eAAe;IACjC,SAAS;IACV;AACD,UAAO,MAAM,cAAc,eAAe,cAAc;aAC/C,MAAM,WAAW,aAAa;GACvC,MAAM,gBAAgB;IACpB,GAAG;IACH,MAAM,KAAK;IACX,aAAa,KAAK,eAAe;IACjC;IACD;AACD,UAAO,MAAM,cAAc,eAAe,cAAc;aAC/C,MAAM,WAAW,YAAY;GACtC,MAAM,gBAAgB;IACpB,GAAG;IACH,MAAM,KAAK;IACX,aAAa,KAAK,eAAe;IACjC,SAAS;IACV;AACD,UAAO,MAAM,cAAc,eAAe,cAAc;;AAK1D,SAAO,MAAM,cAAc,eAAe,MAAa;IAEzD;EAAC,KAAK;EAAQ,KAAK;EAAM,KAAK;EAAa;EAAQ,CACpD;AAQD,iBAN2C;EACzC,GAAG;EACH;EACA,QAAQ;EACT,EAE6B,KAAK;AAInC,iBAAgB;AACd,eAAa;GACX,MAAM,SAAS,OACb,GAAG,GAAG,WAAW,GAAG,GAAG,GAAG;GAG5B,MAAM,WADJ,WAAW,gBAC2B,QACrC,OACC,MAAM,GAAG,KACT,MAAM;IAAE,MAAM,KAAK;IAAM,SAAS,KAAK;IAAS,CAAQ,CAC3D;AACD,cAAW,mBAAmB,SAAS;;IAExC;EAAC;EAAY,KAAK;EAAM,KAAK;EAAQ,CAAC"}
1
+ {"version":3,"file":"use-human-in-the-loop.mjs","names":[],"sources":["../../src/hooks/use-human-in-the-loop.tsx"],"sourcesContent":["import { useCopilotKit } from \"@/providers/CopilotKitProvider\";\nimport type { ReactFrontendTool } from \"@/types/frontend-tool\";\nimport type { ReactHumanInTheLoop } from \"@/types/human-in-the-loop\";\nimport type { ReactToolCallRenderer } from \"@/types/react-tool-call-renderer\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport React from \"react\";\nimport { useFrontendTool } from \"./use-frontend-tool\";\n\nexport function useHumanInTheLoop<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(tool: ReactHumanInTheLoop<T>, deps?: ReadonlyArray<unknown>) {\n const { copilotkit } = useCopilotKit();\n const resolvePromiseRef = useRef<((result: unknown) => void) | null>(null);\n\n const respond = useCallback(async (result: unknown) => {\n if (resolvePromiseRef.current) {\n resolvePromiseRef.current(result);\n resolvePromiseRef.current = null;\n }\n }, []);\n\n const handler = useCallback(async () => {\n return new Promise((resolve) => {\n resolvePromiseRef.current = resolve;\n });\n }, []);\n\n const RenderComponent: ReactToolCallRenderer<T>[\"render\"] = useCallback(\n (props) => {\n const ToolComponent = tool.render;\n\n // Enhance props based on current status\n if (props.status === \"inProgress\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond: undefined,\n };\n return React.createElement(ToolComponent, enhancedProps);\n } else if (props.status === \"executing\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond,\n };\n return React.createElement(ToolComponent, enhancedProps);\n } else if (props.status === \"complete\") {\n const enhancedProps = {\n ...props,\n name: tool.name,\n description: tool.description || \"\",\n respond: undefined,\n };\n return React.createElement(ToolComponent, enhancedProps);\n }\n\n // Fallback - just render with original props\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return React.createElement(ToolComponent, props as any);\n },\n [tool.render, tool.name, tool.description, respond],\n );\n\n const frontendTool: ReactFrontendTool<T> = {\n ...tool,\n handler,\n render: RenderComponent,\n };\n\n useFrontendTool(frontendTool, deps);\n\n // Human-in-the-loop tools should remove their renderer on unmount\n // since they can't respond to user interactions anymore\n useEffect(() => {\n return () => {\n copilotkit.removeHookRenderToolCall(tool.name, tool.agentId);\n };\n }, [copilotkit, tool.name, tool.agentId]);\n}\n"],"mappings":";;;;;AAQA,SAAgB,kBAEd,MAA8B,MAA+B;CAC7D,MAAM,EAAE,eAAe,eAAe;CACtC,MAAM,oBAAoB,OAA2C,KAAK;CAE1E,MAAM,UAAU,YAAY,OAAO,WAAoB;AACrD,MAAI,kBAAkB,SAAS;AAC7B,qBAAkB,QAAQ,OAAO;AACjC,qBAAkB,UAAU;;IAE7B,EAAE,CAAC;CAEN,MAAM,UAAU,YAAY,YAAY;AACtC,SAAO,IAAI,SAAS,YAAY;AAC9B,qBAAkB,UAAU;IAC5B;IACD,EAAE,CAAC;CAEN,MAAM,kBAAsD,aACzD,UAAU;EACT,MAAM,gBAAgB,KAAK;AAG3B,MAAI,MAAM,WAAW,cAAc;GACjC,MAAM,gBAAgB;IACpB,GAAG;IACH,MAAM,KAAK;IACX,aAAa,KAAK,eAAe;IACjC,SAAS;IACV;AACD,UAAO,MAAM,cAAc,eAAe,cAAc;aAC/C,MAAM,WAAW,aAAa;GACvC,MAAM,gBAAgB;IACpB,GAAG;IACH,MAAM,KAAK;IACX,aAAa,KAAK,eAAe;IACjC;IACD;AACD,UAAO,MAAM,cAAc,eAAe,cAAc;aAC/C,MAAM,WAAW,YAAY;GACtC,MAAM,gBAAgB;IACpB,GAAG;IACH,MAAM,KAAK;IACX,aAAa,KAAK,eAAe;IACjC,SAAS;IACV;AACD,UAAO,MAAM,cAAc,eAAe,cAAc;;AAK1D,SAAO,MAAM,cAAc,eAAe,MAAa;IAEzD;EAAC,KAAK;EAAQ,KAAK;EAAM,KAAK;EAAa;EAAQ,CACpD;AAQD,iBAN2C;EACzC,GAAG;EACH;EACA,QAAQ;EACT,EAE6B,KAAK;AAInC,iBAAgB;AACd,eAAa;AACX,cAAW,yBAAyB,KAAK,MAAM,KAAK,QAAQ;;IAE7D;EAAC;EAAY,KAAK;EAAM,KAAK;EAAQ,CAAC"}
@@ -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 - Zod schema type describing tool call parameters.
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
  *
@@ -66,12 +66,7 @@ function useRenderTool(config, deps) {
66
66
  }),
67
67
  ...config.agentId ? { agentId: config.agentId } : {}
68
68
  });
69
- const keyOf = (rc) => `${rc.agentId ?? ""}:${rc.name}`;
70
- const currentRenderToolCalls = copilotkit.renderToolCalls;
71
- const mergedMap = /* @__PURE__ */ new Map();
72
- for (const rc of currentRenderToolCalls) mergedMap.set(keyOf(rc), rc);
73
- mergedMap.set(keyOf(renderer), renderer);
74
- copilotkit.setRenderToolCalls(Array.from(mergedMap.values()));
69
+ copilotkit.addHookRenderToolCall(renderer);
75
70
  }, [
76
71
  config.name,
77
72
  copilotkit,
@@ -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 { z } from \"zod\";\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 z.ZodTypeAny> {\n name: string;\n parameters: Partial<z.infer<S>>;\n status: \"inProgress\";\n result: undefined;\n}\n\nexport interface RenderToolExecutingProps<S extends z.ZodTypeAny> {\n name: string;\n parameters: z.infer<S>;\n status: \"executing\";\n result: undefined;\n}\n\nexport interface RenderToolCompleteProps<S extends z.ZodTypeAny> {\n name: string;\n parameters: z.infer<S>;\n status: \"complete\";\n result: string;\n}\n\nexport type RenderToolProps<S extends z.ZodTypeAny> =\n | RenderToolInProgressProps<S>\n | RenderToolExecutingProps<S>\n | RenderToolCompleteProps<S>;\n\ntype RenderToolConfig<S extends z.ZodTypeAny> = {\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` Zod schema defines the typed shape of `props.parameters`\n * in `render` for `executing` and `complete` states.\n *\n * @typeParam S - Zod 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 z.ZodTypeAny>(\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 - Zod 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 z.ZodTypeAny>(\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":";;;;;;AAMA,MAAM,aAAqC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiJ7C,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
+ {"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\";\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 copilotkit.addHookRenderToolCall(renderer);\n\n // No cleanup removal — keeps renderer for chat history, same as useFrontendTool\n }, [config.name, copilotkit, extraDeps.length, ...extraDeps]);\n}\n"],"mappings":";;;;;;AAQA,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;AAER,aAAW,sBAAsB,SAAS;IAGzC;EAAC,OAAO;EAAM;EAAY,UAAU;EAAQ,GAAG;EAAU,CAAC"}
@@ -1,25 +1,25 @@
1
- import { z } from "zod";
1
+ import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkitnext/shared";
2
2
 
3
3
  //#region src/hooks/use-render-tool.d.ts
4
- interface RenderToolInProgressProps<S extends z.ZodTypeAny> {
4
+ interface RenderToolInProgressProps<S extends StandardSchemaV1> {
5
5
  name: string;
6
- parameters: Partial<z.infer<S>>;
6
+ parameters: Partial<InferSchemaOutput<S>>;
7
7
  status: "inProgress";
8
8
  result: undefined;
9
9
  }
10
- interface RenderToolExecutingProps<S extends z.ZodTypeAny> {
10
+ interface RenderToolExecutingProps<S extends StandardSchemaV1> {
11
11
  name: string;
12
- parameters: z.infer<S>;
12
+ parameters: InferSchemaOutput<S>;
13
13
  status: "executing";
14
14
  result: undefined;
15
15
  }
16
- interface RenderToolCompleteProps<S extends z.ZodTypeAny> {
16
+ interface RenderToolCompleteProps<S extends StandardSchemaV1> {
17
17
  name: string;
18
- parameters: z.infer<S>;
18
+ parameters: InferSchemaOutput<S>;
19
19
  status: "complete";
20
20
  result: string;
21
21
  }
22
- type RenderToolProps<S extends z.ZodTypeAny> = RenderToolInProgressProps<S> | RenderToolExecutingProps<S> | RenderToolCompleteProps<S>;
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` Zod schema defines the typed shape of `props.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 - Zod schema type describing tool call parameters.
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 z.ZodTypeAny>(config: {
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":";;;UAQiB,yBAAA,WAAoC,CAAA,CAAE,UAAA;EACrD,IAAA;EACA,UAAA,EAAY,OAAA,CAAQ,CAAA,CAAE,KAAA,CAAM,CAAA;EAC5B,MAAA;EACA,MAAA;AAAA;AAAA,UAGe,wBAAA,WAAmC,CAAA,CAAE,UAAA;EACpD,IAAA;EACA,UAAA,EAAY,CAAA,CAAE,KAAA,CAAM,CAAA;EACpB,MAAA;EACA,MAAA;AAAA;AAAA,UAGe,uBAAA,WAAkC,CAAA,CAAE,UAAA;EACnD,IAAA;EACA,UAAA,EAAY,CAAA,CAAE,KAAA,CAAM,CAAA;EACpB,MAAA;EACA,MAAA;AAAA;AAAA,KAGU,eAAA,WAA0B,CAAA,CAAE,UAAA,IACpC,yBAAA,CAA0B,CAAA,IAC1B,wBAAA,CAAyB,CAAA,IACzB,uBAAA,CAAwB,CAAA;;;;;;AAjB5B;;;;;;;;;;;;;;;;;;;iBAkDgB,aAAA,CACd,MAAA;EACE,IAAA;EACA,MAAA,GAAS,KAAA,UAAe,KAAA,CAAM,YAAA;EAC9B,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA;;;;;;;;;;;;;;;;;AA1CT;;;;;;;;;;iBAuEgB,aAAA,WAAwB,CAAA,CAAE,UAAA,CAAA,CACxC,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
+ {"version":3,"file":"use-render-tool.d.cts","names":[],"sources":["../../src/hooks/use-render-tool.tsx"],"mappings":";;;UAUiB,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 { z } from "zod";
1
+ import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkitnext/shared";
2
2
 
3
3
  //#region src/hooks/use-render-tool.d.ts
4
- interface RenderToolInProgressProps<S extends z.ZodTypeAny> {
4
+ interface RenderToolInProgressProps<S extends StandardSchemaV1> {
5
5
  name: string;
6
- parameters: Partial<z.infer<S>>;
6
+ parameters: Partial<InferSchemaOutput<S>>;
7
7
  status: "inProgress";
8
8
  result: undefined;
9
9
  }
10
- interface RenderToolExecutingProps<S extends z.ZodTypeAny> {
10
+ interface RenderToolExecutingProps<S extends StandardSchemaV1> {
11
11
  name: string;
12
- parameters: z.infer<S>;
12
+ parameters: InferSchemaOutput<S>;
13
13
  status: "executing";
14
14
  result: undefined;
15
15
  }
16
- interface RenderToolCompleteProps<S extends z.ZodTypeAny> {
16
+ interface RenderToolCompleteProps<S extends StandardSchemaV1> {
17
17
  name: string;
18
- parameters: z.infer<S>;
18
+ parameters: InferSchemaOutput<S>;
19
19
  status: "complete";
20
20
  result: string;
21
21
  }
22
- type RenderToolProps<S extends z.ZodTypeAny> = RenderToolInProgressProps<S> | RenderToolExecutingProps<S> | RenderToolCompleteProps<S>;
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` Zod schema defines the typed shape of `props.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 - Zod schema type describing tool call parameters.
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 z.ZodTypeAny>(config: {
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":";;;UAQiB,yBAAA,WAAoC,CAAA,CAAE,UAAA;EACrD,IAAA;EACA,UAAA,EAAY,OAAA,CAAQ,CAAA,CAAE,KAAA,CAAM,CAAA;EAC5B,MAAA;EACA,MAAA;AAAA;AAAA,UAGe,wBAAA,WAAmC,CAAA,CAAE,UAAA;EACpD,IAAA;EACA,UAAA,EAAY,CAAA,CAAE,KAAA,CAAM,CAAA;EACpB,MAAA;EACA,MAAA;AAAA;AAAA,UAGe,uBAAA,WAAkC,CAAA,CAAE,UAAA;EACnD,IAAA;EACA,UAAA,EAAY,CAAA,CAAE,KAAA,CAAM,CAAA;EACpB,MAAA;EACA,MAAA;AAAA;AAAA,KAGU,eAAA,WAA0B,CAAA,CAAE,UAAA,IACpC,yBAAA,CAA0B,CAAA,IAC1B,wBAAA,CAAyB,CAAA,IACzB,uBAAA,CAAwB,CAAA;;;;;;AAjB5B;;;;;;;;;;;;;;;;;;;iBAkDgB,aAAA,CACd,MAAA;EACE,IAAA;EACA,MAAA,GAAS,KAAA,UAAe,KAAA,CAAM,YAAA;EAC9B,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA;;;;;;;;;;;;;;;;;AA1CT;;;;;;;;;;iBAuEgB,aAAA,WAAwB,CAAA,CAAE,UAAA,CAAA,CACxC,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
+ {"version":3,"file":"use-render-tool.d.mts","names":[],"sources":["../../src/hooks/use-render-tool.tsx"],"mappings":";;;UAUiB,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 - Zod schema type describing tool call parameters.
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
  *
@@ -65,12 +65,7 @@ function useRenderTool(config, deps) {
65
65
  }),
66
66
  ...config.agentId ? { agentId: config.agentId } : {}
67
67
  });
68
- const keyOf = (rc) => `${rc.agentId ?? ""}:${rc.name}`;
69
- const currentRenderToolCalls = copilotkit.renderToolCalls;
70
- const mergedMap = /* @__PURE__ */ new Map();
71
- for (const rc of currentRenderToolCalls) mergedMap.set(keyOf(rc), rc);
72
- mergedMap.set(keyOf(renderer), renderer);
73
- copilotkit.setRenderToolCalls(Array.from(mergedMap.values()));
68
+ copilotkit.addHookRenderToolCall(renderer);
74
69
  }, [
75
70
  config.name,
76
71
  copilotkit,