@copilotkit/react-core 1.85.0 → 1.87.0

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 (69) hide show
  1. package/dist/MarkdownSurfaces-BCVdnDAk.cjs +161 -0
  2. package/dist/MarkdownSurfaces-BCVdnDAk.cjs.map +1 -0
  3. package/dist/MarkdownSurfaces-CjJduaJR.mjs +149 -0
  4. package/dist/MarkdownSurfaces-CjJduaJR.mjs.map +1 -0
  5. package/dist/{MarkdownSurfaces-3cGU5_0H.cjs → chat-BnsrQ0VS.cjs} +667 -320
  6. package/dist/chat-BnsrQ0VS.cjs.map +1 -0
  7. package/dist/{MarkdownSurfaces-D-W4f9Dy.mjs → chat-IWySXWXP.mjs} +647 -312
  8. package/dist/chat-IWySXWXP.mjs.map +1 -0
  9. package/dist/{copilotkit-Dn4PbHJV.d.mts → copilotkit-BNPEXnEE.d.mts} +11 -6
  10. package/dist/{copilotkit-Dn4PbHJV.d.mts.map → copilotkit-BNPEXnEE.d.mts.map} +1 -1
  11. package/dist/{copilotkit-CuTAoQF2.d.cts → copilotkit-Bop-sY6y.d.cts} +9 -4
  12. package/dist/{copilotkit-CuTAoQF2.d.cts.map → copilotkit-Bop-sY6y.d.cts.map} +1 -1
  13. package/dist/{copilotkit-BpKHgURs.cjs → copilotkit-CZ9tI_J1.cjs} +203 -452
  14. package/dist/copilotkit-CZ9tI_J1.cjs.map +1 -0
  15. package/dist/{copilotkit-D6mTCuNU.mjs → copilotkit-ChqQa52S.mjs} +131 -380
  16. package/dist/{copilotkit-BpKHgURs.cjs.map → copilotkit-ChqQa52S.mjs.map} +1 -1
  17. package/dist/hooks-CEFWIeKR.d.cts +89 -0
  18. package/dist/hooks-CEFWIeKR.d.cts.map +1 -0
  19. package/dist/hooks-DFgYRjj3.d.mts +89 -0
  20. package/dist/hooks-DFgYRjj3.d.mts.map +1 -0
  21. package/dist/index.cjs +8 -8
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +2 -2
  24. package/dist/index.d.mts +2 -2
  25. package/dist/index.mjs +2 -2
  26. package/dist/index.umd.js +769 -165
  27. package/dist/index.umd.js.map +1 -1
  28. package/dist/refs-DL7ITFFD.cjs +43 -0
  29. package/dist/refs-DL7ITFFD.cjs.map +1 -0
  30. package/dist/refs-DiZXJ63p.mjs +31 -0
  31. package/dist/refs-DiZXJ63p.mjs.map +1 -0
  32. package/dist/{runtime-context-Er5UIbZA.d.mts → runtime-context-B4fKyzo6.d.mts} +31 -9
  33. package/dist/runtime-context-B4fKyzo6.d.mts.map +1 -0
  34. package/dist/{runtime-context-DrVNUYLi.d.cts → runtime-context-Da7T5vy4.d.cts} +31 -9
  35. package/dist/runtime-context-Da7T5vy4.d.cts.map +1 -0
  36. package/dist/use-generative-ui-root-CaTyBFNR.cjs +390 -0
  37. package/dist/use-generative-ui-root-CaTyBFNR.cjs.map +1 -0
  38. package/dist/use-generative-ui-root-WI9ERMpo.mjs +385 -0
  39. package/dist/use-generative-ui-root-WI9ERMpo.mjs.map +1 -0
  40. package/dist/v2/generative-ui/native.cjs +66 -0
  41. package/dist/v2/generative-ui/native.cjs.map +1 -0
  42. package/dist/v2/generative-ui/native.d.cts +155 -0
  43. package/dist/v2/generative-ui/native.d.cts.map +1 -0
  44. package/dist/v2/generative-ui/native.d.mts +155 -0
  45. package/dist/v2/generative-ui/native.d.mts.map +1 -0
  46. package/dist/v2/generative-ui/native.mjs +24 -0
  47. package/dist/v2/generative-ui/native.mjs.map +1 -0
  48. package/dist/v2/generative-ui.cjs +45 -70
  49. package/dist/v2/generative-ui.cjs.map +1 -1
  50. package/dist/v2/generative-ui.d.cts +378 -457
  51. package/dist/v2/generative-ui.d.cts.map +1 -1
  52. package/dist/v2/generative-ui.d.mts +378 -457
  53. package/dist/v2/generative-ui.d.mts.map +1 -1
  54. package/dist/v2/generative-ui.mjs +4 -29
  55. package/dist/v2/generative-ui.mjs.map +1 -1
  56. package/dist/v2/headless.d.cts +185 -294
  57. package/dist/v2/headless.d.cts.map +1 -1
  58. package/dist/v2/index.cjs +5 -5
  59. package/dist/v2/index.d.cts +2 -2
  60. package/dist/v2/index.d.mts +2 -2
  61. package/dist/v2/index.mjs +2 -2
  62. package/dist/v2/index.umd.js +769 -165
  63. package/dist/v2/index.umd.js.map +1 -1
  64. package/package.json +14 -10
  65. package/dist/MarkdownSurfaces-3cGU5_0H.cjs.map +0 -1
  66. package/dist/MarkdownSurfaces-D-W4f9Dy.mjs.map +0 -1
  67. package/dist/copilotkit-D6mTCuNU.mjs.map +0 -1
  68. package/dist/runtime-context-DrVNUYLi.d.cts.map +0 -1
  69. package/dist/runtime-context-Er5UIbZA.d.mts.map +0 -1
@@ -0,0 +1,89 @@
1
+ import { S as GenerativeUIStateOf, _ as GenerativeUIFunctionArgs, b as GenerativeUIFunctionName, d as GenerativeUI$1, h as GenerativeUIDefinitionsOf, i as GenerativeUIRuntime } from "./runtime-context-Da7T5vy4.cjs";
2
+ import { ReactNode } from "react";
3
+ import * as zod from "zod";
4
+ import { SchemaInput } from "@copilotkit/shared/generative-ui";
5
+
6
+ //#region src/v2/generative-ui/refs.d.ts
7
+ /**
8
+ * One component id. The component receives the rendered child. Pass the
9
+ * description here, not with `.describe()`, which would replace the mark.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const tabsSchema = z.object({
14
+ * tabs: z.array(z.object({ title: z.string(), child: child() })),
15
+ * });
16
+ * // The component gets `tabs: { title: string; child: ReactNode }[]`.
17
+ * ```
18
+ */
19
+ declare function child(description?: string): zod.ZodEffects<zod.ZodString, ReactNode, string>;
20
+ /**
21
+ * A list of component ids, or a template `{ componentId, path }` that
22
+ * repeats one component for each item of the list at `path`. The
23
+ * component receives the rendered children. Pass the description here,
24
+ * not with `.describe()`.
25
+ */
26
+ declare function childList(description?: string): zod.ZodEffects<zod.ZodUnion<[zod.ZodArray<zod.ZodString, "many">, zod.ZodObject<{
27
+ componentId: zod.ZodString;
28
+ path: zod.ZodString;
29
+ }, zod.UnknownKeysParam, zod.ZodTypeAny, {
30
+ componentId: string;
31
+ path: string;
32
+ }, {
33
+ componentId: string;
34
+ path: string;
35
+ }>]>, ReactNode, string[] | {
36
+ componentId: string;
37
+ path: string;
38
+ }>;
39
+ //#endregion
40
+ //#region src/v2/generative-ui/hooks.d.ts
41
+ /** Re-renders on any surface-manager change. */
42
+ declare function useManagerVersion(runtime: GenerativeUIRuntime | null): number;
43
+ /** What `useGenerativeUIState` takes for one key: the input of its schema. */
44
+ type StateInput<UI extends GenerativeUI$1<any>, Key extends keyof GenerativeUIStateOf<UI>> = SchemaInput<GenerativeUIDefinitionsOf<UI>["state"][Key]>;
45
+ /**
46
+ * Experimental. Gives one key of the app state declared in
47
+ * `createGenerativeUI({ state })` its value. Bound props of generated
48
+ * components read it. The model does not see it.
49
+ *
50
+ * The key is set on mount and when the value changes (compared as JSON). It
51
+ * is removed on unmount.
52
+ *
53
+ * @param ui - The object from `createGenerativeUI`. It gives the key and the
54
+ * value their types.
55
+ * @param key - A top-level key of `state`.
56
+ * @param value - The value of that key. It must fit the key's schema.
57
+ *
58
+ * @example
59
+ * ```tsx
60
+ * useGenerativeUIState(storeUI, "cart", { count, total, coupon, items });
61
+ * ```
62
+ */
63
+ declare function useGenerativeUIState<UI extends GenerativeUI$1<any>, Key extends keyof GenerativeUIStateOf<UI> & string>(ui: UI, key: Key, value: StateInput<UI, Key>): void;
64
+ /**
65
+ * Experimental. Mounts the handler of a function declared in
66
+ * `createGenerativeUI({ functions })`. Generated UI can call the function
67
+ * only while exactly one handler for it is mounted.
68
+ *
69
+ * The handler gets the parsed arguments: schema defaults are set. It can
70
+ * change on each render. The latest handler always runs, and the hook does
71
+ * not register again.
72
+ *
73
+ * @param ui - The object from `createGenerativeUI`. It gives the name and the
74
+ * handler arguments their types.
75
+ * @param name - A key of `functions`.
76
+ * @param handler - Runs when generated UI calls the function. Its return
77
+ * value goes back to the caller as `{ ok: true, result }`.
78
+ *
79
+ * @example
80
+ * ```tsx
81
+ * useGenerativeUIFunction(storeUI, "addToCart", ({ productId, quantity }) =>
82
+ * cart.addItem(productId, quantity),
83
+ * );
84
+ * ```
85
+ */
86
+ declare function useGenerativeUIFunction<UI extends GenerativeUI$1<any>, Name extends GenerativeUIFunctionName<UI>>(ui: UI, name: Name, handler: (args: GenerativeUIFunctionArgs<UI, Name>) => unknown): void;
87
+ //#endregion
88
+ export { childList as a, child as i, useGenerativeUIState as n, useManagerVersion as r, useGenerativeUIFunction as t };
89
+ //# sourceMappingURL=hooks-CEFWIeKR.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks-CEFWIeKR.d.cts","names":[],"sources":["../src/v2/generative-ui/refs.ts","../src/v2/generative-ui/hooks.ts"],"mappings":";;;;;;;;;;;AAkBA;;;;;;;iBAAgB,KAAA,CAAM,WAAA,YAAoB,GAAA,CAAA,UAAA,CAArB,GAAA,CAAqB,SAAA,EAAA,SAAA;;;;;;;iBAU1B,SAAA,CAAU,WAAA,gBAAoB,UAAA,CAAA,GAAA,CAAA,QAAA,EAAA,GAAA,CAAA,QAAA,CAArB,GAAA,CAAqB,SAAA,eAAA,SAAA;eAAA,GAAA,CAAA,SAAA;;;;;;;;;;;;;;;iBCR9B,iBAAA,CAAkB,OAAA,EAAS,mBAAA;;KAStC,UAAA,YACQ,cAAA,yBACO,mBAAA,CAAoB,EAAA,KACpC,WAAA,CAAY,yBAAA,CAA0B,EAAA,WAAa,GAAA;;;;;;;;;;;;;;ADJvD;;;;;iBCwBgB,oBAAA,YACH,cAAA,yBACO,mBAAA,CAAoB,EAAA,WAAA,CACtC,EAAA,EAAI,EAAA,EAAI,GAAA,EAAK,GAAA,EAAK,KAAA,EAAO,UAAA,CAAW,EAAA,EAAI,GAAA;;;;;;;;;;;;;;;;;;;;;;;iBA0D1B,uBAAA,YACH,cAAA,oBACE,wBAAA,CAAyB,EAAA,EAAA,CAEtC,EAAA,EAAI,EAAA,EACJ,IAAA,EAAM,IAAA,EACN,OAAA,GAAU,IAAA,EAAM,wBAAA,CAAyB,EAAA,EAAI,IAAA"}
@@ -0,0 +1,89 @@
1
+ import { S as GenerativeUIStateOf, _ as GenerativeUIFunctionArgs, b as GenerativeUIFunctionName, d as GenerativeUI$1, h as GenerativeUIDefinitionsOf, i as GenerativeUIRuntime } from "./runtime-context-B4fKyzo6.mjs";
2
+ import { ReactNode } from "react";
3
+ import * as zod from "zod";
4
+ import { SchemaInput } from "@copilotkit/shared/generative-ui";
5
+
6
+ //#region src/v2/generative-ui/refs.d.ts
7
+ /**
8
+ * One component id. The component receives the rendered child. Pass the
9
+ * description here, not with `.describe()`, which would replace the mark.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const tabsSchema = z.object({
14
+ * tabs: z.array(z.object({ title: z.string(), child: child() })),
15
+ * });
16
+ * // The component gets `tabs: { title: string; child: ReactNode }[]`.
17
+ * ```
18
+ */
19
+ declare function child$1(description?: string): zod.ZodEffects<zod.ZodString, ReactNode, string>;
20
+ /**
21
+ * A list of component ids, or a template `{ componentId, path }` that
22
+ * repeats one component for each item of the list at `path`. The
23
+ * component receives the rendered children. Pass the description here,
24
+ * not with `.describe()`.
25
+ */
26
+ declare function childList$1(description?: string): zod.ZodEffects<zod.ZodUnion<[zod.ZodArray<zod.ZodString, "many">, zod.ZodObject<{
27
+ componentId: zod.ZodString;
28
+ path: zod.ZodString;
29
+ }, zod.UnknownKeysParam, zod.ZodTypeAny, {
30
+ componentId: string;
31
+ path: string;
32
+ }, {
33
+ componentId: string;
34
+ path: string;
35
+ }>]>, ReactNode, string[] | {
36
+ componentId: string;
37
+ path: string;
38
+ }>;
39
+ //#endregion
40
+ //#region src/v2/generative-ui/hooks.d.ts
41
+ /** Re-renders on any surface-manager change. */
42
+ declare function useManagerVersion(runtime: GenerativeUIRuntime | null): number;
43
+ /** What `useGenerativeUIState` takes for one key: the input of its schema. */
44
+ type StateInput<UI extends GenerativeUI$1<any>, Key extends keyof GenerativeUIStateOf<UI>> = SchemaInput<GenerativeUIDefinitionsOf<UI>["state"][Key]>;
45
+ /**
46
+ * Experimental. Gives one key of the app state declared in
47
+ * `createGenerativeUI({ state })` its value. Bound props of generated
48
+ * components read it. The model does not see it.
49
+ *
50
+ * The key is set on mount and when the value changes (compared as JSON). It
51
+ * is removed on unmount.
52
+ *
53
+ * @param ui - The object from `createGenerativeUI`. It gives the key and the
54
+ * value their types.
55
+ * @param key - A top-level key of `state`.
56
+ * @param value - The value of that key. It must fit the key's schema.
57
+ *
58
+ * @example
59
+ * ```tsx
60
+ * useGenerativeUIState(storeUI, "cart", { count, total, coupon, items });
61
+ * ```
62
+ */
63
+ declare function useGenerativeUIState<UI extends GenerativeUI$1<any>, Key extends keyof GenerativeUIStateOf<UI> & string>(ui: UI, key: Key, value: StateInput<UI, Key>): void;
64
+ /**
65
+ * Experimental. Mounts the handler of a function declared in
66
+ * `createGenerativeUI({ functions })`. Generated UI can call the function
67
+ * only while exactly one handler for it is mounted.
68
+ *
69
+ * The handler gets the parsed arguments: schema defaults are set. It can
70
+ * change on each render. The latest handler always runs, and the hook does
71
+ * not register again.
72
+ *
73
+ * @param ui - The object from `createGenerativeUI`. It gives the name and the
74
+ * handler arguments their types.
75
+ * @param name - A key of `functions`.
76
+ * @param handler - Runs when generated UI calls the function. Its return
77
+ * value goes back to the caller as `{ ok: true, result }`.
78
+ *
79
+ * @example
80
+ * ```tsx
81
+ * useGenerativeUIFunction(storeUI, "addToCart", ({ productId, quantity }) =>
82
+ * cart.addItem(productId, quantity),
83
+ * );
84
+ * ```
85
+ */
86
+ declare function useGenerativeUIFunction<UI extends GenerativeUI$1<any>, Name extends GenerativeUIFunctionName<UI>>(ui: UI, name: Name, handler: (args: GenerativeUIFunctionArgs<UI, Name>) => unknown): void;
87
+ //#endregion
88
+ export { childList$1 as a, child$1 as i, useGenerativeUIState as n, useManagerVersion as r, useGenerativeUIFunction as t };
89
+ //# sourceMappingURL=hooks-DFgYRjj3.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks-DFgYRjj3.d.mts","names":[],"sources":["../src/v2/generative-ui/refs.ts","../src/v2/generative-ui/hooks.ts"],"mappings":";;;;;;;;;;;AAkBA;;;;;;;iBAAgB,OAAA,CAAM,WAAA,YAAoB,GAAA,CAAA,UAAA,CAArB,GAAA,CAAqB,SAAA,EAAA,SAAA;;;;;;;iBAU1B,WAAA,CAAU,WAAA,gBAAoB,UAAA,CAAA,GAAA,CAAA,QAAA,EAAA,GAAA,CAAA,QAAA,CAArB,GAAA,CAAqB,SAAA,eAAA,SAAA;eAAA,GAAA,CAAA,SAAA;;;;;;;;;;;;;;;iBCR9B,iBAAA,CAAkB,OAAA,EAAS,mBAAA;;KAStC,UAAA,YACQ,cAAA,yBACO,mBAAA,CAAoB,EAAA,KACpC,WAAA,CAAY,yBAAA,CAA0B,EAAA,WAAa,GAAA;;;;;;;;;;;;;;ADJvD;;;;;iBCwBgB,oBAAA,YACH,cAAA,yBACO,mBAAA,CAAoB,EAAA,WAAA,CACtC,EAAA,EAAI,EAAA,EAAI,GAAA,EAAK,GAAA,EAAK,KAAA,EAAO,UAAA,CAAW,EAAA,EAAI,GAAA;;;;;;;;;;;;;;;;;;;;;;;iBA0D1B,uBAAA,YACH,cAAA,oBACE,wBAAA,CAAyB,EAAA,EAAA,CAEtC,EAAA,EAAI,EAAA,EACJ,IAAA,EAAM,IAAA,EACN,OAAA,GAAU,IAAA,EAAM,wBAAA,CAAyB,EAAA,EAAI,IAAA"}
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_MarkdownSurfaces = require('./MarkdownSurfaces-3cGU5_0H.cjs');
5
- const require_copilotkit = require('./copilotkit-BpKHgURs.cjs');
4
+ const require_chat = require('./chat-BnsrQ0VS.cjs');
5
+ const require_copilotkit = require('./copilotkit-CZ9tI_J1.cjs');
6
6
  let react = require("react");
7
- react = require_MarkdownSurfaces.__toESM(react);
7
+ react = require_chat.__toESM(react);
8
8
  let _copilotkit_core = require("@copilotkit/core");
9
9
  let _ag_ui_client = require("@ag-ui/client");
10
10
  let _copilotkit_shared = require("@copilotkit/shared");
@@ -47,7 +47,7 @@ function useLazyToolRenderer() {
47
47
  function useCopilotChatInternal({ suggestions, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages } = {}) {
48
48
  const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
49
49
  const { threadId, agentSession } = require_copilotkit.useCopilotContext();
50
- const existingConfig = require_MarkdownSurfaces.useCopilotChatConfiguration();
50
+ const existingConfig = require_chat.useCopilotChatConfiguration();
51
51
  const [agentAvailable, setAgentAvailable] = (0, react.useState)(false);
52
52
  const resolvedAgentId = existingConfig?.agentId ?? "default";
53
53
  const { agent } = require_copilotkit.useAgent({ agentId: resolvedAgentId });
@@ -668,7 +668,7 @@ function useRenderToolCall(tool, dependencies) {
668
668
  (0, react.useEffect)(() => {
669
669
  const { name, parameters, render } = tool;
670
670
  const zodParameters = (0, _copilotkit_shared.getZodParameters)(parameters);
671
- const renderToolCall = name === "*" ? require_MarkdownSurfaces.defineToolCallRenderer({
671
+ const renderToolCall = name === "*" ? require_chat.defineToolCallRenderer({
672
672
  name: "*",
673
673
  render: ((args) => {
674
674
  return render({
@@ -676,7 +676,7 @@ function useRenderToolCall(tool, dependencies) {
676
676
  result: args.result ? (0, _copilotkit_shared.parseJson)(args.result, args.result) : args.result
677
677
  });
678
678
  })
679
- }) : require_MarkdownSurfaces.defineToolCallRenderer({
679
+ }) : require_chat.defineToolCallRenderer({
680
680
  name,
681
681
  args: zodParameters,
682
682
  render: ((args) => {
@@ -1730,7 +1730,7 @@ function toV1Event(event) {
1730
1730
  function useLangGraphInterrupt(action, _dependencies) {
1731
1731
  const actionRef = (0, react.useRef)(action);
1732
1732
  actionRef.current = action;
1733
- const existingConfig = require_MarkdownSurfaces.useCopilotChatConfiguration();
1733
+ const existingConfig = require_chat.useCopilotChatConfiguration();
1734
1734
  const resolvedAgentId = action.agentId ?? existingConfig?.agentId ?? "default";
1735
1735
  const threadId = existingConfig?.threadId;
1736
1736
  const nodeName = useAgentNodeName(resolvedAgentId);
@@ -1904,7 +1904,7 @@ function useDefaultTool(tool, dependencies) {
1904
1904
  * removes it on unmount, ensuring a clean and efficient lifecycle management.
1905
1905
  */
1906
1906
  function useCopilotChatSuggestions(config, dependencies = []) {
1907
- const resolvedAgentId = require_MarkdownSurfaces.useCopilotChatConfiguration()?.agentId ?? "default";
1907
+ const resolvedAgentId = require_chat.useCopilotChatConfiguration()?.agentId ?? "default";
1908
1908
  const available = (config.available === "enabled" ? "always" : config.available) ?? "before-first-message";
1909
1909
  require_copilotkit.useConfigureSuggestions({
1910
1910
  ...config,