@copilotkit/react-core 2.0.0-rc.14 → 2.0.0-rc.16

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.
@@ -834,6 +834,7 @@ function toManifest(definition, modelProps, modelEvents) {
834
834
  //#endregion
835
835
  //#region src/generative-ui/errors.ts
836
836
  var GenerativeUIError = class extends Error {
837
+ code;
837
838
  constructor(code, message) {
838
839
  super(message);
839
840
  this.name = "GenerativeUIError";
@@ -1050,10 +1051,8 @@ function isRecord(value) {
1050
1051
  * is dropped at the end of that build, so the cache does not grow.
1051
1052
  */
1052
1053
  var BuildMemo = class {
1053
- constructor() {
1054
- this.previous = /* @__PURE__ */ new Map();
1055
- this.current = /* @__PURE__ */ new Map();
1056
- }
1054
+ previous = /* @__PURE__ */ new Map();
1055
+ current = /* @__PURE__ */ new Map();
1057
1056
  /**
1058
1057
  * The value of `key`. It is computed when no earlier value is there, or
1059
1058
  * when `isFresh` says that the earlier value is out of date.
@@ -1071,12 +1070,11 @@ var BuildMemo = class {
1071
1070
  };
1072
1071
  /** The results of the builds of one thread. See `BuildMarkdownSurfacesOptions.cache`. */
1073
1072
  var MarkdownBuildCache = class {
1074
- constructor() {
1075
- this.segments = new BuildMemo();
1076
- this.fences = new BuildMemo();
1077
- this.drafts = new BuildMemo();
1078
- this.readdressed = /* @__PURE__ */ new WeakMap();
1079
- }
1073
+ segments = new BuildMemo();
1074
+ fences = new BuildMemo();
1075
+ drafts = new BuildMemo();
1076
+ /** The copies of an operation for other surface ids, by operation. */
1077
+ readdressed = /* @__PURE__ */ new WeakMap();
1080
1078
  endBuild() {
1081
1079
  this.segments.endBuild();
1082
1080
  this.fences.endBuild();
@@ -1587,13 +1585,18 @@ function removalContent(surfaceId, catalogId) {
1587
1585
  * that each fence renders.
1588
1586
  */
1589
1587
  var MarkdownSurfaceSource = class {
1588
+ functions;
1589
+ /** By thread: the blocks of each fence, from the latest sync. */
1590
+ fences = /* @__PURE__ */ new Map();
1591
+ /** By thread, then surface: the operations last ingested, as JSON. */
1592
+ ingested = /* @__PURE__ */ new Map();
1593
+ /** By thread, then surface: the content last ingested. */
1594
+ contents = /* @__PURE__ */ new Map();
1595
+ /** By thread: the results of the earlier builds. */
1596
+ caches = /* @__PURE__ */ new Map();
1590
1597
  constructor(manager, ui) {
1591
1598
  this.manager = manager;
1592
1599
  this.ui = ui;
1593
- this.fences = /* @__PURE__ */ new Map();
1594
- this.ingested = /* @__PURE__ */ new Map();
1595
- this.contents = /* @__PURE__ */ new Map();
1596
- this.caches = /* @__PURE__ */ new Map();
1597
1600
  this.functions = declaredFunctions(ui);
1598
1601
  }
1599
1602
  /**
@@ -1772,18 +1775,18 @@ function describe(value) {
1772
1775
  const MATH = {
1773
1776
  min: (args) => Math.min(...args),
1774
1777
  max: (args) => Math.max(...args),
1775
- abs: ([x]) => Math.abs(x),
1776
- floor: ([x]) => Math.floor(x),
1777
- ceil: ([x]) => Math.ceil(x),
1778
- round: ([x, decimals = 0]) => {
1778
+ abs: ([x = NaN]) => Math.abs(x),
1779
+ floor: ([x = NaN]) => Math.floor(x),
1780
+ ceil: ([x = NaN]) => Math.ceil(x),
1781
+ round: ([x = NaN, decimals = 0]) => {
1779
1782
  const factor = 10 ** Math.trunc(decimals);
1780
1783
  return Math.round(x * factor) / factor;
1781
1784
  },
1782
- pow: ([x, y]) => x ** y,
1783
- sqrt: ([x]) => Math.sqrt(x),
1784
- exp: ([x]) => Math.exp(x),
1785
- ln: ([x]) => Math.log(x),
1786
- log10: ([x]) => Math.log10(x)
1785
+ pow: ([x = NaN, y = NaN]) => x ** y,
1786
+ sqrt: ([x = NaN]) => Math.sqrt(x),
1787
+ exp: ([x = NaN]) => Math.exp(x),
1788
+ ln: ([x = NaN]) => Math.log(x),
1789
+ log10: ([x = NaN]) => Math.log10(x)
1787
1790
  };
1788
1791
  /** How many args a function takes, at least and at most; min and max take any. */
1789
1792
  const ARITY = {
@@ -1803,18 +1806,27 @@ const CONSTANTS = {
1803
1806
  e: Math.E
1804
1807
  };
1805
1808
  var CalcParser = class {
1809
+ pos = 0;
1806
1810
  constructor(tokens, scope, source) {
1807
1811
  this.tokens = tokens;
1808
1812
  this.scope = scope;
1809
1813
  this.source = source;
1810
- this.pos = 0;
1811
- this.skipDepth = 0;
1812
1814
  }
1813
1815
  parse() {
1814
1816
  const value = this.ternary();
1815
- if (this.tokens[this.pos].kind !== "end") this.fail(`unexpected "${this.text(this.tokens[this.pos])}"`);
1817
+ const token = this.peek();
1818
+ if (token.kind !== "end") this.fail(`unexpected "${this.text(token)}"`);
1816
1819
  return value;
1817
1820
  }
1821
+ /**
1822
+ * The token at `pos`. The parser never moves past the "end" token, which
1823
+ * `tokenize` always adds last, so there is always one.
1824
+ */
1825
+ peek() {
1826
+ const token = this.tokens[this.pos];
1827
+ if (token === void 0) throw new Error(`calc: no token at ${this.pos} in "${this.source}"`);
1828
+ return token;
1829
+ }
1818
1830
  fail(what) {
1819
1831
  throw new ExpressionError(`calc: ${what} in "${this.source}"`);
1820
1832
  }
@@ -1822,11 +1834,11 @@ var CalcParser = class {
1822
1834
  return token.kind === "end" ? "end" : String(token.value);
1823
1835
  }
1824
1836
  peekOp(...ops) {
1825
- const token = this.tokens[this.pos];
1837
+ const token = this.peek();
1826
1838
  return token.kind === "op" && ops.includes(token.value) ? token.value : void 0;
1827
1839
  }
1828
1840
  expectOp(op) {
1829
- if (this.peekOp(op) === void 0) this.fail(`expected "${op}" but found "${this.text(this.tokens[this.pos])}"`);
1841
+ if (this.peekOp(op) === void 0) this.fail(`expected "${op}" but found "${this.text(this.peek())}"`);
1830
1842
  this.pos++;
1831
1843
  }
1832
1844
  /**
@@ -1845,6 +1857,8 @@ var CalcParser = class {
1845
1857
  }
1846
1858
  return null;
1847
1859
  }
1860
+ /** Above 0 while parsing a part whose value is not needed. */
1861
+ skipDepth = 0;
1848
1862
  /** The number of a value, or 0 while skipping. */
1849
1863
  num(value, what) {
1850
1864
  return this.skipDepth > 0 ? 0 : numberOf(value, what);
@@ -1951,7 +1965,8 @@ var CalcParser = class {
1951
1965
  return value;
1952
1966
  }
1953
1967
  primary() {
1954
- const token = this.tokens[this.pos++];
1968
+ const token = this.peek();
1969
+ this.pos++;
1955
1970
  switch (token.kind) {
1956
1971
  case "number": return token.value;
1957
1972
  case "string": return token.value;
@@ -2231,10 +2246,10 @@ const IDENTIFIER = /@?[A-Za-z_][A-Za-z0-9_-]*/y;
2231
2246
  const NUMBER = /-?\d+(?:\.\d+)?/y;
2232
2247
  const PATH_SEGMENT = /[^\s,():'"]+/y;
2233
2248
  var ExpressionParser = class {
2249
+ pos = 0;
2234
2250
  constructor(source, state) {
2235
2251
  this.source = source;
2236
2252
  this.state = state;
2237
- this.pos = 0;
2238
2253
  }
2239
2254
  parse() {
2240
2255
  const value = this.expression();
@@ -2536,14 +2551,10 @@ function NodePlaceholder(_props) {
2536
2551
  }
2537
2552
  /** Per-node boundary. Resets on retry or a new agent revision, not on data ticks. */
2538
2553
  var NodeBoundary = class extends Component {
2539
- constructor(..._args) {
2540
- super(..._args);
2541
- this.state = {
2542
- error: null,
2543
- revision: this.props.revision
2544
- };
2545
- this.retry = () => this.setState({ error: null });
2546
- }
2554
+ state = {
2555
+ error: null,
2556
+ revision: this.props.revision
2557
+ };
2547
2558
  static getDerivedStateFromError(error) {
2548
2559
  return { error };
2549
2560
  }
@@ -2562,6 +2573,7 @@ var NodeBoundary = class extends Component {
2562
2573
  error
2563
2574
  });
2564
2575
  }
2576
+ retry = () => this.setState({ error: null });
2565
2577
  render() {
2566
2578
  const { error } = this.state;
2567
2579
  if (!error) return this.props.children;
@@ -2581,10 +2593,7 @@ var NodeBoundary = class extends Component {
2581
2593
  };
2582
2594
  /** Outer boundary: a failure here must not reach the chat or the host page. */
2583
2595
  var SurfaceBoundary = class extends Component {
2584
- constructor(..._args2) {
2585
- super(..._args2);
2586
- this.state = { error: null };
2587
- }
2596
+ state = { error: null };
2588
2597
  static getDerivedStateFromError(error) {
2589
2598
  return { error };
2590
2599
  }
@@ -3729,4 +3738,4 @@ function MarkdownSurfaces({ content, messageId, isStreaming = false, ...markdown
3729
3738
 
3730
3739
  //#endregion
3731
3740
  export { ExpressionError as A, renderSlot as B, issueKey as C, getMarkdownSurfaceSource as D, containsDynamicValue as E, toJsonSchema as F, CopilotIcon as G, CopilotChatConfigurationProvider as H, defineToolCallRenderer as I, StreamingMarkdownDefaultRenderer as J, IconSvg as K, MarkdownRendererProvider as L, catalogIdsOf as M, componentCatalogIds as N, isRecord as O, createGenerativeUI as P, useMarkdownRenderer as R, isAsyncIssue as S, withoutRejectedNulls as T, useCopilotChatConfiguration as U, ControlledModalOpenScope as V, useShallowStableRef as W, GenerativeUINodeContext as _, GenerativeUIToolCallRenderer as a, useRequiredGenerativeUIRuntime as b, SurfaceView as c, namedRole as d, useGenerativeUIAccessibility as f, useManagerVersion as g, useGenerativeUIState as h, GenerativeUIChatSlotContext as i, GenerativeUIError as j, BASIC_FUNCTIONS as k, DARK_THEME_CSS as l, useGenerativeUIFunction as m, ProviderMarkdown as n, createGenerativeUIActivityRenderer as o, wrapperAria as p, cn as q, DefaultGenerativeUIChatCard as r, createGenerativeUIFunctionCallActivityRenderer as s, MarkdownSurfaces as t, controlAria as u, GenerativeUIRuntimeContext as v, validateSchemaSync as w, formatIssues as x, useGenerativeUIRuntime as y, isReactComponentType as z };
3732
- //# sourceMappingURL=MarkdownSurfaces-DKC9Eg_a.mjs.map
3741
+ //# sourceMappingURL=MarkdownSurfaces-DAEqIF5v.mjs.map