@copilotkit/react-core 2.0.0-rc.2 → 2.0.0-rc.20

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 (47) hide show
  1. package/dist/{MarkdownRendererContext-B4Us6mwL.d.cts → MarkdownRendererContext-Bsl28Gmn.d.mts} +17 -33
  2. package/dist/MarkdownRendererContext-Bsl28Gmn.d.mts.map +1 -0
  3. package/dist/{MarkdownRendererContext-CRKFzsEB.d.mts → MarkdownRendererContext-CBppkb5j.d.cts} +17 -33
  4. package/dist/MarkdownRendererContext-CBppkb5j.d.cts.map +1 -0
  5. package/dist/{MarkdownSurfaces-Bd--93O1.mjs → MarkdownSurfaces-Bt7TD_U1.mjs} +177 -136
  6. package/dist/MarkdownSurfaces-Bt7TD_U1.mjs.map +1 -0
  7. package/dist/{MarkdownSurfaces-S4wfUl3J.cjs → MarkdownSurfaces-CoUoPhR9.cjs} +198 -156
  8. package/dist/MarkdownSurfaces-CoUoPhR9.cjs.map +1 -0
  9. package/dist/context.cjs +28 -26
  10. package/dist/context.cjs.map +1 -1
  11. package/dist/context.d.cts +38 -98
  12. package/dist/context.d.cts.map +1 -1
  13. package/dist/context.d.mts +38 -98
  14. package/dist/context.d.mts.map +1 -1
  15. package/dist/context.mjs +28 -26
  16. package/dist/context.mjs.map +1 -1
  17. package/dist/generative-ui.cjs +570 -567
  18. package/dist/generative-ui.cjs.map +1 -1
  19. package/dist/generative-ui.d.cts +2137 -4178
  20. package/dist/generative-ui.d.cts.map +1 -1
  21. package/dist/generative-ui.d.mts +2137 -4178
  22. package/dist/generative-ui.d.mts.map +1 -1
  23. package/dist/generative-ui.mjs +75 -73
  24. package/dist/generative-ui.mjs.map +1 -1
  25. package/dist/headless.cjs +55 -84
  26. package/dist/headless.cjs.map +1 -1
  27. package/dist/headless.d.cts +78 -253
  28. package/dist/headless.d.cts.map +1 -1
  29. package/dist/headless.d.mts +56 -202
  30. package/dist/headless.d.mts.map +1 -1
  31. package/dist/headless.mjs +48 -82
  32. package/dist/headless.mjs.map +1 -1
  33. package/dist/index.cjs +1628 -2398
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +203 -540
  36. package/dist/index.d.cts.map +1 -1
  37. package/dist/index.d.mts +202 -539
  38. package/dist/index.d.mts.map +1 -1
  39. package/dist/index.mjs +965 -2248
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/index.umd.js +1776 -2466
  42. package/dist/index.umd.js.map +1 -1
  43. package/package.json +17 -18
  44. package/dist/MarkdownRendererContext-B4Us6mwL.d.cts.map +0 -1
  45. package/dist/MarkdownRendererContext-CRKFzsEB.d.mts.map +0 -1
  46. package/dist/MarkdownSurfaces-Bd--93O1.mjs.map +0 -1
  47. package/dist/MarkdownSurfaces-S4wfUl3J.cjs.map +0 -1
@@ -28,16 +28,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  let _copilotkit_core = require("@copilotkit/core");
29
29
  let react = require("react");
30
30
  react = __toESM(react);
31
+ let _copilotkit_markdown_react = require("@copilotkit/markdown/react");
32
+ let _copilotkit_markdown = require("@copilotkit/markdown");
31
33
  let react_jsx_runtime = require("react/jsx-runtime");
32
- let _copilotkit_markdown_renderer_react = require("@copilotkit/markdown-renderer/react");
33
- let _copilotkit_markdown_renderer = require("@copilotkit/markdown-renderer");
34
34
  let _copilotkit_shared = require("@copilotkit/shared");
35
35
  let _copilotkit_react_core_context = require("@copilotkit/react-core/context");
36
36
  let zod = require("zod");
37
- let zod_to_json_schema = require("zod-to-json-schema");
37
+ zod = __toESM(zod);
38
38
 
39
39
  //#region src/components/chat/StreamingMarkdownDefaultRenderer.tsx
40
- const defaultNodeRenderers = (0, _copilotkit_markdown_renderer_react.createStreamingMarkdownNodeRenderers)({ codeBlock: ({ node }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
40
+ const defaultNodeRenderers = (0, _copilotkit_markdown_react.createStreamingMarkdownNodeRenderers)({ codeBlock: ({ node }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
41
41
  className: "cpk-markdown-code-block",
42
42
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
43
43
  "data-code-info": node.info ?? void 0,
@@ -46,19 +46,19 @@ const defaultNodeRenderers = (0, _copilotkit_markdown_renderer_react.createStrea
46
46
  }) });
47
47
  /**
48
48
  * react-core's built-in default markdown renderer — a thin adapter over
49
- * `@copilotkit/markdown-renderer`'s streaming renderer. Maps the pluggable
49
+ * `@copilotkit/markdown`'s streaming renderer. Maps the pluggable
50
50
  * renderer contract (`{ content, isStreaming, className }`) onto the streaming
51
51
  * renderer for streaming-safe incremental rendering + per-token animation.
52
52
  * Still overridable via the slot/provider pluggable interface.
53
53
  */
54
54
  function StreamingMarkdownDefaultRenderer({ content, isStreaming, className, nodeRenderers, caret, options, onLinkClick, onCitationClick }) {
55
- const mergedNodeRenderers = (0, react.useMemo)(() => nodeRenderers ? (0, _copilotkit_markdown_renderer_react.createStreamingMarkdownNodeRenderers)({
55
+ const mergedNodeRenderers = (0, react.useMemo)(() => nodeRenderers ? (0, _copilotkit_markdown_react.createStreamingMarkdownNodeRenderers)({
56
56
  ...defaultNodeRenderers,
57
57
  ...nodeRenderers
58
58
  }) : defaultNodeRenderers, [nodeRenderers]);
59
59
  if (!content) return null;
60
- (0, _copilotkit_markdown_renderer.warnUnsupportedRichSyntaxOnce)(content);
61
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_markdown_renderer_react.StreamingMarkdownRenderer, {
60
+ (0, _copilotkit_markdown.warnUnsupportedRichSyntaxOnce)(content);
61
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_markdown_react.StreamingMarkdownRenderer, {
62
62
  className,
63
63
  isComplete: !isStreaming,
64
64
  caret: caret ?? !!isStreaming,
@@ -71,17 +71,76 @@ function StreamingMarkdownDefaultRenderer({ content, isStreaming, className, nod
71
71
  }
72
72
  StreamingMarkdownDefaultRenderer.displayName = "StreamingMarkdownDefaultRenderer";
73
73
 
74
+ //#endregion
75
+ //#region src/components/icons/CopilotIcon.tsx
76
+ /** Turns SVG attribute names such as `stroke-width` into React's `strokeWidth`. */
77
+ function toReactAttributes(attributes) {
78
+ return Object.fromEntries(Object.entries(attributes).map(([key, value]) => [key.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase()), value]));
79
+ }
80
+ const svgDefaults = toReactAttributes(_copilotkit_core.ɵcopilotIconSvgAttributes);
81
+ /** True when the props give the icon an accessible name or role. */
82
+ function hasAccessibleProp(props) {
83
+ return Object.keys(props).some((key) => key.startsWith("aria-") || key === "role" || key === "title");
84
+ }
85
+ /**
86
+ * Internal. Draws a Lucide icon from its node data, the way Lucide's React package
87
+ * does: Lucide's default SVG attributes, the `lucide lucide-<name>` classes,
88
+ * and `aria-hidden="true"` when no `aria-*`, `role` or `title` prop names it.
89
+ */
90
+ const IconSvg = (0, react.forwardRef)(function IconSvg({ lucideName, nodes, size = 24, color = "currentColor", strokeWidth = 2, className, children, ...props }, ref) {
91
+ const isDecorative = !children && !hasAccessibleProp(props);
92
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
93
+ ref,
94
+ ...svgDefaults,
95
+ width: size,
96
+ height: size,
97
+ stroke: color,
98
+ strokeWidth,
99
+ className: (0, _copilotkit_core.ɵcn)("lucide", `lucide-${lucideName}`, className),
100
+ "aria-hidden": isDecorative || void 0,
101
+ ...props,
102
+ children: [nodes.map((node, index) => (0, react.createElement)(node.tag, {
103
+ key: index,
104
+ ...node.attributes
105
+ })), children]
106
+ });
107
+ });
108
+ /**
109
+ * Draws one of the chat icons as an inline `<svg>`.
110
+ *
111
+ * The `<svg>` has the classes `lucide lucide-<icon name>`, so CSS that selects
112
+ * them (for example `svg.lucide-arrow-up`) keeps working. The icon is hidden
113
+ * from screen readers unless you give it an `aria-label`, `role` or `title`.
114
+ *
115
+ * @param props.name - The chat icon, for example `"ArrowUp"` or `"X"`.
116
+ * @param props.size - Width and height. Defaults to `24`.
117
+ * @param props.strokeWidth - Line width. Defaults to `2`.
118
+ * @param props.color - Line color. Defaults to `currentColor`.
119
+ *
120
+ * @example
121
+ * ```tsx
122
+ * <CopilotIcon name="ArrowUp" className="cpk-chat-input-send-icon" />
123
+ * <CopilotIcon name="X" aria-label="Close" />
124
+ * ```
125
+ */
126
+ const CopilotIcon = (0, react.forwardRef)(function CopilotIcon({ name, ...props }, ref) {
127
+ const icon = _copilotkit_core.ɵcopilotIcons[name];
128
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconSvg, {
129
+ ref,
130
+ lucideName: icon.name,
131
+ nodes: icon.nodes,
132
+ ...props
133
+ });
134
+ });
135
+
74
136
  //#endregion
75
137
  //#region src/lib/shallow-stable-ref.ts
76
138
  /**
77
- * Shallow equality comparison for objects.
139
+ * Shallow equality comparison for objects: same own keys, each holding the
140
+ * same value (`Object.is`). Core's `ɵshallowEqualRecord` holds the rule.
78
141
  */
79
142
  function shallowEqual(obj1, obj2) {
80
- const keys1 = Object.keys(obj1);
81
- const keys2 = Object.keys(obj2);
82
- if (keys1.length !== keys2.length) return false;
83
- for (const key of keys1) if (obj1[key] !== obj2[key]) return false;
84
- return true;
143
+ return (0, _copilotkit_core.ɵshallowEqualRecord)(obj1, obj2);
85
144
  }
86
145
  /**
87
146
  * Returns true only for plain JS objects (`{}`), excluding arrays, Dates,
@@ -115,51 +174,6 @@ function useShallowStableRef(value) {
115
174
 
116
175
  //#endregion
117
176
  //#region src/providers/CopilotChatConfigurationProvider.tsx
118
- const CopilotChatDefaultLabels = {
119
- chatInputPlaceholder: "Type a message...",
120
- chatInputToolbarStartTranscribeButtonLabel: "Transcribe",
121
- chatInputToolbarCancelTranscribeButtonLabel: "Cancel",
122
- chatInputToolbarFinishTranscribeButtonLabel: "Finish",
123
- chatInputToolbarAddButtonLabel: "Add attachments",
124
- chatInputToolbarToolsButtonLabel: "Tools",
125
- chatInputToolbarSendButtonLabel: "Send message",
126
- chatInputToolbarStopButtonLabel: "Stop",
127
- assistantMessageToolbarCopyCodeLabel: "Copy",
128
- assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
129
- assistantMessageToolbarCopyMessageLabel: "Copy",
130
- assistantMessageToolbarInspectorLabel: "View in Inspector",
131
- assistantMessageToolbarInspectorDescription: "Open this message in the Inspector",
132
- assistantMessageToolbarInspectorLocalOnlyLabel: "Local only",
133
- assistantMessageToolbarInspectorLocalOnlyDescription: "Only visible on localhost or loopback hosts in development. Never shown in production.",
134
- assistantMessageToolbarInspectorTitle: "CopilotKit Inspector",
135
- assistantMessageToolbarInspectorHideLabel: "Hide this icon",
136
- assistantMessageToolbarInspectorHideDescription: "Until you reload this page",
137
- assistantMessageToolbarThumbsUpLabel: "Good response",
138
- assistantMessageToolbarThumbsDownLabel: "Bad response",
139
- assistantMessageFeedbackCommentPlaceholder: "Add a comment (optional)",
140
- assistantMessageFeedbackCommentSubmitLabel: "Send comment",
141
- assistantMessageToolbarReadAloudLabel: "Read aloud",
142
- assistantMessageToolbarRegenerateLabel: "Regenerate",
143
- userMessageToolbarCopyMessageLabel: "Copy",
144
- userMessageToolbarEditMessageLabel: "Edit",
145
- userMessageToolbarPreviousBranchLabel: "Previous branch",
146
- userMessageToolbarNextBranchLabel: "Next branch",
147
- chatDisclaimerText: "AI can make mistakes. Please verify important information.",
148
- chatToggleOpenLabel: "Open chat",
149
- chatToggleCloseLabel: "Close chat",
150
- chatScrollToBottomLabel: "Scroll to bottom",
151
- modalHeaderTitle: "CopilotKit Chat",
152
- welcomeMessageText: "How can I help you today?",
153
- reasoningMessageThinkingLabel: "Thinking…",
154
- chatInputSlashMenuLabel: "Slash commands",
155
- chatInputSlashMenuEmptyText: "No commands found",
156
- attachmentRemoveButtonLabel: "Remove attachment",
157
- attachmentPlayVideoButtonLabel: "Play video",
158
- attachmentPreviewCloseButtonLabel: "Close preview",
159
- modalHeaderCloseButtonLabel: "Close",
160
- modalHeaderThreadsButtonLabel: "Open threads",
161
- sidebarLabel: "Copilot chat sidebar"
162
- };
163
177
  /**
164
178
  * Mobile breakpoint below which the chat modal and the thread-list drawer are
165
179
  * mutually exclusive. At or above this width both surfaces may coexist. This
@@ -184,7 +198,7 @@ const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId,
184
198
  const parentConfig = (0, react.useContext)(CopilotChatConfiguration);
185
199
  const stableLabels = useShallowStableRef(labels);
186
200
  const mergedLabels = (0, react.useMemo)(() => ({
187
- ...CopilotChatDefaultLabels,
201
+ ..._copilotkit_core.CopilotChatDefaultLabels,
188
202
  ...parentConfig?.labels,
189
203
  ...stableLabels
190
204
  }), [stableLabels, parentConfig?.labels]);
@@ -416,28 +430,6 @@ const ControlledModalOpenScope = ({ children, open, onOpenChange }) => {
416
430
  };
417
431
  ControlledModalOpenScope.displayName = "ControlledModalOpenScope";
418
432
 
419
- //#endregion
420
- //#region src/lib/utils.ts
421
- /**
422
- * Joins class names, skipping falsy values. Takes the same inputs as `clsx`.
423
- * Classes are not merged: every rule CopilotKit ships sits in `:where()`, so a
424
- * class the app adds wins without removing ours.
425
- */
426
- function cn(...inputs) {
427
- const out = [];
428
- for (const input of inputs) {
429
- if (!input) continue;
430
- if (typeof input === "string" || typeof input === "number" || typeof input === "bigint") out.push(String(input));
431
- else if (Array.isArray(input)) {
432
- const nested = cn(...input);
433
- if (nested) out.push(nested);
434
- } else if (typeof input === "object") {
435
- for (const key in input) if (input[key]) out.push(key);
436
- }
437
- }
438
- return out.join(" ");
439
- }
440
-
441
433
  //#endregion
442
434
  //#region src/lib/slots.tsx
443
435
  /**
@@ -456,7 +448,7 @@ function renderSlotElement(slot, DefaultComponent, props) {
456
448
  const existingClassName = props.className;
457
449
  return react.default.createElement(DefaultComponent, {
458
450
  ...props,
459
- className: cn(existingClassName, slot)
451
+ className: (0, _copilotkit_core.ɵcn)(existingClassName, slot)
460
452
  });
461
453
  }
462
454
  if (isReactComponentType(slot)) return react.default.createElement(slot, props);
@@ -519,7 +511,7 @@ function useMarkdownRenderer() {
519
511
  //#endregion
520
512
  //#region src/types/defineToolCallRenderer.ts
521
513
  function defineToolCallRenderer(def) {
522
- const argsSchema = def.name === "*" && !def.args ? zod.z.any() : def.args;
514
+ const argsSchema = def.name === "*" && !def.args ? _copilotkit_shared.ɵanySchema : def.args;
523
515
  return {
524
516
  name: def.name,
525
517
  args: argsSchema,
@@ -532,12 +524,11 @@ function defineToolCallRenderer(def) {
532
524
  //#endregion
533
525
  //#region src/generative-ui/json-schema.ts
534
526
  /**
535
- * JSON Schema for a Standard Schema (zod v3 via zod-to-json-schema),
536
- * inlined, no `$schema`. A prop marked by `child()` or `childList()`
527
+ * JSON Schema for a Standard Schema, without `$schema`. A prop marked by `child()` or `childList()`
537
528
  * becomes an A2UI `$ref` to `ComponentId` or `ChildList`.
538
529
  */
539
530
  function toJsonSchema(schema) {
540
- const { $schema: _omit, ...rest } = (0, _copilotkit_shared.schemaToJsonSchema)(schema, { zodToJsonSchema: (s) => (0, zod_to_json_schema.zodToJsonSchema)(s, { $refStrategy: "none" }) });
531
+ const { $schema: _omit, ...rest } = (0, _copilotkit_shared.schemaToJsonSchema)(schema);
541
532
  return (0, _copilotkit_shared.applyChildRefMarks)(rest);
542
533
  }
543
534
 
@@ -844,16 +835,10 @@ function toManifest(definition, modelProps, modelEvents) {
844
835
  return manifest;
845
836
  }
846
837
 
847
- //#endregion
848
- //#region src/generative-ui/is-record.ts
849
- /** True for a plain object: not null, not an array. Internal, not exported. */
850
- function isRecord(value) {
851
- return typeof value === "object" && value !== null && !Array.isArray(value);
852
- }
853
-
854
838
  //#endregion
855
839
  //#region src/generative-ui/errors.ts
856
840
  var GenerativeUIError = class extends Error {
841
+ code;
857
842
  constructor(code, message) {
858
843
  super(message);
859
844
  this.name = "GenerativeUIError";
@@ -953,6 +938,7 @@ function formatDatePattern(date, pattern) {
953
938
  case "m": return pad(date.getMinutes(), 2);
954
939
  case "s": return pad(date.getSeconds(), 2);
955
940
  case "a": return date.getHours() < 12 ? "AM" : "PM";
941
+ case void 0:
956
942
  default: return token;
957
943
  }
958
944
  });
@@ -1056,6 +1042,13 @@ function givesValidationResult(name) {
1056
1042
  return _copilotkit_shared.GENERATIVE_UI_FUNCTIONS[name]?.returnType === "validationResult";
1057
1043
  }
1058
1044
 
1045
+ //#endregion
1046
+ //#region src/generative-ui/is-record.ts
1047
+ /** True for a plain object: not null, not an array. Internal, not exported. */
1048
+ function isRecord(value) {
1049
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1050
+ }
1051
+
1059
1052
  //#endregion
1060
1053
  //#region src/generative-ui/markdown/source.ts
1061
1054
  /**
@@ -1063,10 +1056,8 @@ function givesValidationResult(name) {
1063
1056
  * is dropped at the end of that build, so the cache does not grow.
1064
1057
  */
1065
1058
  var BuildMemo = class {
1066
- constructor() {
1067
- this.previous = /* @__PURE__ */ new Map();
1068
- this.current = /* @__PURE__ */ new Map();
1069
- }
1059
+ previous = /* @__PURE__ */ new Map();
1060
+ current = /* @__PURE__ */ new Map();
1070
1061
  /**
1071
1062
  * The value of `key`. It is computed when no earlier value is there, or
1072
1063
  * when `isFresh` says that the earlier value is out of date.
@@ -1084,12 +1075,11 @@ var BuildMemo = class {
1084
1075
  };
1085
1076
  /** The results of the builds of one thread. See `BuildMarkdownSurfacesOptions.cache`. */
1086
1077
  var MarkdownBuildCache = class {
1087
- constructor() {
1088
- this.segments = new BuildMemo();
1089
- this.fences = new BuildMemo();
1090
- this.drafts = new BuildMemo();
1091
- this.readdressed = /* @__PURE__ */ new WeakMap();
1092
- }
1078
+ segments = new BuildMemo();
1079
+ fences = new BuildMemo();
1080
+ drafts = new BuildMemo();
1081
+ /** The copies of an operation for other surface ids, by operation. */
1082
+ readdressed = /* @__PURE__ */ new WeakMap();
1093
1083
  endBuild() {
1094
1084
  this.segments.endBuild();
1095
1085
  this.fences.endBuild();
@@ -1600,13 +1590,18 @@ function removalContent(surfaceId, catalogId) {
1600
1590
  * that each fence renders.
1601
1591
  */
1602
1592
  var MarkdownSurfaceSource = class {
1593
+ functions;
1594
+ /** By thread: the blocks of each fence, from the latest sync. */
1595
+ fences = /* @__PURE__ */ new Map();
1596
+ /** By thread, then surface: the operations last ingested, as JSON. */
1597
+ ingested = /* @__PURE__ */ new Map();
1598
+ /** By thread, then surface: the content last ingested. */
1599
+ contents = /* @__PURE__ */ new Map();
1600
+ /** By thread: the results of the earlier builds. */
1601
+ caches = /* @__PURE__ */ new Map();
1603
1602
  constructor(manager, ui) {
1604
1603
  this.manager = manager;
1605
1604
  this.ui = ui;
1606
- this.fences = /* @__PURE__ */ new Map();
1607
- this.ingested = /* @__PURE__ */ new Map();
1608
- this.contents = /* @__PURE__ */ new Map();
1609
- this.caches = /* @__PURE__ */ new Map();
1610
1605
  this.functions = declaredFunctions(ui);
1611
1606
  }
1612
1607
  /**
@@ -1704,6 +1699,7 @@ const OPERATORS = [
1704
1699
  "*",
1705
1700
  "/",
1706
1701
  "%",
1702
+ "^",
1707
1703
  "(",
1708
1704
  ")",
1709
1705
  ",",
@@ -1784,27 +1780,58 @@ function describe(value) {
1784
1780
  const MATH = {
1785
1781
  min: (args) => Math.min(...args),
1786
1782
  max: (args) => Math.max(...args),
1787
- abs: ([x]) => Math.abs(x),
1788
- floor: ([x]) => Math.floor(x),
1789
- ceil: ([x]) => Math.ceil(x),
1790
- round: ([x, decimals = 0]) => {
1783
+ abs: ([x = NaN]) => Math.abs(x),
1784
+ floor: ([x = NaN]) => Math.floor(x),
1785
+ ceil: ([x = NaN]) => Math.ceil(x),
1786
+ round: ([x = NaN, decimals = 0]) => {
1791
1787
  const factor = 10 ** Math.trunc(decimals);
1792
1788
  return Math.round(x * factor) / factor;
1793
- }
1789
+ },
1790
+ pow: ([x = NaN, y = NaN]) => x ** y,
1791
+ sqrt: ([x = NaN]) => Math.sqrt(x),
1792
+ exp: ([x = NaN]) => Math.exp(x),
1793
+ ln: ([x = NaN]) => Math.log(x),
1794
+ log10: ([x = NaN]) => Math.log10(x)
1795
+ };
1796
+ /** How many args a function takes, at least and at most; min and max take any. */
1797
+ const ARITY = {
1798
+ abs: [1, 1],
1799
+ floor: [1, 1],
1800
+ ceil: [1, 1],
1801
+ round: [1, 2],
1802
+ pow: [2, 2],
1803
+ sqrt: [1, 1],
1804
+ exp: [1, 1],
1805
+ ln: [1, 1],
1806
+ log10: [1, 1]
1807
+ };
1808
+ /** Named constants, when no arg of the same name is passed. */
1809
+ const CONSTANTS = {
1810
+ pi: Math.PI,
1811
+ e: Math.E
1794
1812
  };
1795
1813
  var CalcParser = class {
1814
+ pos = 0;
1796
1815
  constructor(tokens, scope, source) {
1797
1816
  this.tokens = tokens;
1798
1817
  this.scope = scope;
1799
1818
  this.source = source;
1800
- this.pos = 0;
1801
- this.skipDepth = 0;
1802
1819
  }
1803
1820
  parse() {
1804
1821
  const value = this.ternary();
1805
- if (this.tokens[this.pos].kind !== "end") this.fail(`unexpected "${this.text(this.tokens[this.pos])}"`);
1822
+ const token = this.peek();
1823
+ if (token.kind !== "end") this.fail(`unexpected "${this.text(token)}"`);
1806
1824
  return value;
1807
1825
  }
1826
+ /**
1827
+ * The token at `pos`. The parser never moves past the "end" token, which
1828
+ * `tokenize` always adds last, so there is always one.
1829
+ */
1830
+ peek() {
1831
+ const token = this.tokens[this.pos];
1832
+ if (token === void 0) throw new Error(`calc: no token at ${this.pos} in "${this.source}"`);
1833
+ return token;
1834
+ }
1808
1835
  fail(what) {
1809
1836
  throw new ExpressionError(`calc: ${what} in "${this.source}"`);
1810
1837
  }
@@ -1812,11 +1839,11 @@ var CalcParser = class {
1812
1839
  return token.kind === "end" ? "end" : String(token.value);
1813
1840
  }
1814
1841
  peekOp(...ops) {
1815
- const token = this.tokens[this.pos];
1842
+ const token = this.peek();
1816
1843
  return token.kind === "op" && ops.includes(token.value) ? token.value : void 0;
1817
1844
  }
1818
1845
  expectOp(op) {
1819
- if (this.peekOp(op) === void 0) this.fail(`expected "${op}" but found "${this.text(this.tokens[this.pos])}"`);
1846
+ if (this.peekOp(op) === void 0) this.fail(`expected "${op}" but found "${this.text(this.peek())}"`);
1820
1847
  this.pos++;
1821
1848
  }
1822
1849
  /**
@@ -1835,6 +1862,8 @@ var CalcParser = class {
1835
1862
  }
1836
1863
  return null;
1837
1864
  }
1865
+ /** Above 0 while parsing a part whose value is not needed. */
1866
+ skipDepth = 0;
1838
1867
  /** The number of a value, or 0 while skipping. */
1839
1868
  num(value, what) {
1840
1869
  return this.skipDepth > 0 ? 0 : numberOf(value, what);
@@ -1925,10 +1954,24 @@ var CalcParser = class {
1925
1954
  this.pos++;
1926
1955
  return !truthOf(this.unary());
1927
1956
  }
1928
- return this.primary();
1957
+ return this.power();
1958
+ }
1959
+ /** `a ^ b`: binds tighter than `*` and unary minus, right to left. */
1960
+ power() {
1961
+ const base = this.primary();
1962
+ if (!this.peekOp("^")) return base;
1963
+ this.pos++;
1964
+ const exponent = this.unary();
1965
+ if (this.skipDepth > 0) return null;
1966
+ return this.finite(this.num(base, "the left side of ^") ** this.num(exponent, "the right side of ^"), "^");
1967
+ }
1968
+ finite(value, what) {
1969
+ if (!Number.isFinite(value)) this.fail(`${what} has no finite result`);
1970
+ return value;
1929
1971
  }
1930
1972
  primary() {
1931
- const token = this.tokens[this.pos++];
1973
+ const token = this.peek();
1974
+ this.pos++;
1932
1975
  switch (token.kind) {
1933
1976
  case "number": return token.value;
1934
1977
  case "string": return token.value;
@@ -1960,10 +2003,15 @@ var CalcParser = class {
1960
2003
  const fn = Object.prototype.hasOwnProperty.call(MATH, name) ? MATH[name] : void 0;
1961
2004
  if (!fn) this.fail(`unknown function ${name}`);
1962
2005
  if (args.length === 0) this.fail(`${name} needs an argument`);
1963
- return fn(args);
2006
+ const [least, most] = ARITY[name] ?? [1, Infinity];
2007
+ if (args.length < least || args.length > most) this.fail(`${name} takes ${least === most ? least : `${least} or ${most}`} argument${most === 1 ? "" : "s"}`);
2008
+ return this.finite(fn(args), name);
1964
2009
  }
1965
2010
  if (this.skipDepth > 0) return null;
1966
- if (!Object.prototype.hasOwnProperty.call(this.scope, name)) this.fail(`unknown name ${name}; pass it as an arg`);
2011
+ if (!Object.prototype.hasOwnProperty.call(this.scope, name)) {
2012
+ if (Object.prototype.hasOwnProperty.call(CONSTANTS, name)) return CONSTANTS[name];
2013
+ this.fail(`unknown name ${name}; pass it as an arg`);
2014
+ }
1967
2015
  const value = this.scope[name];
1968
2016
  if (value !== null && typeof value !== "number" && typeof value !== "string" && typeof value !== "boolean") this.fail(`${name} is not a number, text or boolean (${describe(value)})`);
1969
2017
  return value;
@@ -2203,10 +2251,10 @@ const IDENTIFIER = /@?[A-Za-z_][A-Za-z0-9_-]*/y;
2203
2251
  const NUMBER = /-?\d+(?:\.\d+)?/y;
2204
2252
  const PATH_SEGMENT = /[^\s,():'"]+/y;
2205
2253
  var ExpressionParser = class {
2254
+ pos = 0;
2206
2255
  constructor(source, state) {
2207
2256
  this.source = source;
2208
2257
  this.state = state;
2209
- this.pos = 0;
2210
2258
  }
2211
2259
  parse() {
2212
2260
  const value = this.expression();
@@ -2508,14 +2556,10 @@ function NodePlaceholder(_props) {
2508
2556
  }
2509
2557
  /** Per-node boundary. Resets on retry or a new agent revision, not on data ticks. */
2510
2558
  var NodeBoundary = class extends react.Component {
2511
- constructor(..._args) {
2512
- super(..._args);
2513
- this.state = {
2514
- error: null,
2515
- revision: this.props.revision
2516
- };
2517
- this.retry = () => this.setState({ error: null });
2518
- }
2559
+ state = {
2560
+ error: null,
2561
+ revision: this.props.revision
2562
+ };
2519
2563
  static getDerivedStateFromError(error) {
2520
2564
  return { error };
2521
2565
  }
@@ -2534,6 +2578,7 @@ var NodeBoundary = class extends react.Component {
2534
2578
  error
2535
2579
  });
2536
2580
  }
2581
+ retry = () => this.setState({ error: null });
2537
2582
  render() {
2538
2583
  const { error } = this.state;
2539
2584
  if (!error) return this.props.children;
@@ -2553,10 +2598,7 @@ var NodeBoundary = class extends react.Component {
2553
2598
  };
2554
2599
  /** Outer boundary: a failure here must not reach the chat or the host page. */
2555
2600
  var SurfaceBoundary = class extends react.Component {
2556
- constructor(..._args2) {
2557
- super(..._args2);
2558
- this.state = { error: null };
2559
- }
2601
+ state = { error: null };
2560
2602
  static getDerivedStateFromError(error) {
2561
2603
  return { error };
2562
2604
  }
@@ -3477,21 +3519,21 @@ function DefaultGenerativeUIChatCard({ surfaceId, isStreaming, error, children }
3477
3519
  })]
3478
3520
  });
3479
3521
  }
3480
- const ContentSchema = zod.z.object({
3481
- surfaceId: zod.z.string(),
3482
- target: zod.z.string(),
3483
- catalogId: zod.z.string(),
3484
- operations: zod.z.array(zod.z.any()),
3485
- status: zod.z.enum([
3522
+ const ContentSchema = zod.object({
3523
+ surfaceId: zod.string(),
3524
+ target: zod.string(),
3525
+ catalogId: zod.string(),
3526
+ operations: zod.array(zod.any()),
3527
+ status: zod.enum([
3486
3528
  "streaming",
3487
3529
  "ready",
3488
3530
  "error"
3489
3531
  ]),
3490
- rejected: zod.z.array(zod.z.object({
3491
- index: zod.z.number(),
3492
- reason: zod.z.string()
3532
+ rejected: zod.array(zod.object({
3533
+ index: zod.number(),
3534
+ reason: zod.string()
3493
3535
  })).default([])
3494
- }).passthrough();
3536
+ }).loose();
3495
3537
  function GenerativeUIChatActivity({ content, agent }) {
3496
3538
  const runtime = useGenerativeUIRuntime();
3497
3539
  const threadId = useCopilotChatConfiguration()?.threadId ?? agent?.threadId;
@@ -3533,7 +3575,7 @@ function createGenerativeUIActivityRenderer() {
3533
3575
  function createGenerativeUIFunctionCallActivityRenderer() {
3534
3576
  return {
3535
3577
  activityType: _copilotkit_shared.GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE,
3536
- content: zod.z.unknown(),
3578
+ content: zod.unknown(),
3537
3579
  render: () => null
3538
3580
  };
3539
3581
  }
@@ -3543,7 +3585,7 @@ function GenerativeUIToolCallRenderer() {
3543
3585
  (0, react.useEffect)(() => {
3544
3586
  const renderer = defineToolCallRenderer({
3545
3587
  name: _copilotkit_shared.GENERATIVE_UI_RENDER_TOOL,
3546
- args: zod.z.any(),
3588
+ args: zod.any(),
3547
3589
  render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {})
3548
3590
  });
3549
3591
  const existing = copilotkit._renderToolCalls ?? [];
@@ -3718,10 +3760,10 @@ Object.defineProperty(exports, 'CopilotChatConfigurationProvider', {
3718
3760
  return CopilotChatConfigurationProvider;
3719
3761
  }
3720
3762
  });
3721
- Object.defineProperty(exports, 'CopilotChatDefaultLabels', {
3763
+ Object.defineProperty(exports, 'CopilotIcon', {
3722
3764
  enumerable: true,
3723
3765
  get: function () {
3724
- return CopilotChatDefaultLabels;
3766
+ return CopilotIcon;
3725
3767
  }
3726
3768
  });
3727
3769
  Object.defineProperty(exports, 'DARK_THEME_CSS', {
@@ -3772,6 +3814,12 @@ Object.defineProperty(exports, 'GenerativeUIToolCallRenderer', {
3772
3814
  return GenerativeUIToolCallRenderer;
3773
3815
  }
3774
3816
  });
3817
+ Object.defineProperty(exports, 'IconSvg', {
3818
+ enumerable: true,
3819
+ get: function () {
3820
+ return IconSvg;
3821
+ }
3822
+ });
3775
3823
  Object.defineProperty(exports, 'MarkdownRendererProvider', {
3776
3824
  enumerable: true,
3777
3825
  get: function () {
@@ -3814,12 +3862,6 @@ Object.defineProperty(exports, 'catalogIdsOf', {
3814
3862
  return catalogIdsOf;
3815
3863
  }
3816
3864
  });
3817
- Object.defineProperty(exports, 'cn', {
3818
- enumerable: true,
3819
- get: function () {
3820
- return cn;
3821
- }
3822
- });
3823
3865
  Object.defineProperty(exports, 'componentCatalogIds', {
3824
3866
  enumerable: true,
3825
3867
  get: function () {
@@ -3988,4 +4030,4 @@ Object.defineProperty(exports, 'wrapperAria', {
3988
4030
  return wrapperAria;
3989
4031
  }
3990
4032
  });
3991
- //# sourceMappingURL=MarkdownSurfaces-S4wfUl3J.cjs.map
4033
+ //# sourceMappingURL=MarkdownSurfaces-CoUoPhR9.cjs.map