@copilotkit/react-core 1.5.1-next.1 → 1.5.1-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/{chunk-SFPANIOY.mjs → chunk-2KCEHGSI.mjs} +49 -99
  3. package/dist/chunk-2KCEHGSI.mjs.map +1 -0
  4. package/dist/{chunk-YL6V3QTN.mjs → chunk-6OR25P32.mjs} +15 -42
  5. package/dist/chunk-6OR25P32.mjs.map +1 -0
  6. package/dist/{chunk-VQDGBYWQ.mjs → chunk-DDVXFNYA.mjs} +31 -55
  7. package/dist/chunk-DDVXFNYA.mjs.map +1 -0
  8. package/dist/{chunk-NYBGR2NK.mjs → chunk-FXHKK52V.mjs} +13 -14
  9. package/dist/chunk-FXHKK52V.mjs.map +1 -0
  10. package/dist/{chunk-VPTC36RZ.mjs → chunk-H4VZMKR6.mjs} +2 -2
  11. package/dist/{chunk-OAF4ASJH.mjs → chunk-H7LSKIDK.mjs} +23 -70
  12. package/dist/chunk-H7LSKIDK.mjs.map +1 -0
  13. package/dist/chunk-JDQCJCAQ.mjs +295 -0
  14. package/dist/chunk-JDQCJCAQ.mjs.map +1 -0
  15. package/dist/{chunk-STZUYPHJ.mjs → chunk-LODRWFMB.mjs} +2 -14
  16. package/dist/chunk-LODRWFMB.mjs.map +1 -0
  17. package/dist/{chunk-MKEQ2MJG.mjs → chunk-MWZO6TUR.mjs} +13 -29
  18. package/dist/chunk-MWZO6TUR.mjs.map +1 -0
  19. package/dist/{chunk-7LRDVJH5.mjs → chunk-ODN4H66E.mjs} +2 -6
  20. package/dist/chunk-ODN4H66E.mjs.map +1 -0
  21. package/dist/{chunk-6KHA5W5R.mjs → chunk-QDGDXRRJ.mjs} +2 -2
  22. package/dist/{chunk-ODAH4HNG.mjs → chunk-XINZBP3J.mjs} +2 -2
  23. package/dist/{chunk-ODAH4HNG.mjs.map → chunk-XINZBP3J.mjs.map} +1 -1
  24. package/dist/components/copilot-provider/copilot-messages.d.ts +0 -1
  25. package/dist/components/copilot-provider/copilotkit-props.d.ts +0 -5
  26. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  27. package/dist/components/copilot-provider/copilotkit.d.ts +0 -1
  28. package/dist/components/copilot-provider/copilotkit.js +91 -191
  29. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  30. package/dist/components/copilot-provider/copilotkit.mjs +7 -8
  31. package/dist/components/copilot-provider/index.d.ts +0 -1
  32. package/dist/components/copilot-provider/index.js +91 -191
  33. package/dist/components/copilot-provider/index.js.map +1 -1
  34. package/dist/components/copilot-provider/index.mjs +7 -8
  35. package/dist/components/index.d.ts +0 -1
  36. package/dist/components/index.js +91 -191
  37. package/dist/components/index.js.map +1 -1
  38. package/dist/components/index.mjs +7 -8
  39. package/dist/components/toast/toast-provider.d.ts +1 -2
  40. package/dist/components/toast/toast-provider.js +62 -76
  41. package/dist/components/toast/toast-provider.js.map +1 -1
  42. package/dist/components/toast/toast-provider.mjs +1 -1
  43. package/dist/context/copilot-context.d.ts +3 -15
  44. package/dist/context/copilot-context.js +1 -13
  45. package/dist/context/copilot-context.js.map +1 -1
  46. package/dist/context/copilot-context.mjs +1 -1
  47. package/dist/context/index.d.ts +1 -1
  48. package/dist/context/index.js +1 -13
  49. package/dist/context/index.js.map +1 -1
  50. package/dist/context/index.mjs +4 -4
  51. package/dist/hooks/index.d.ts +1 -2
  52. package/dist/hooks/index.js +293 -624
  53. package/dist/hooks/index.js.map +1 -1
  54. package/dist/hooks/index.mjs +22 -30
  55. package/dist/hooks/use-chat.d.ts +3 -31
  56. package/dist/hooks/use-chat.js +205 -443
  57. package/dist/hooks/use-chat.js.map +1 -1
  58. package/dist/hooks/use-chat.mjs +3 -4
  59. package/dist/hooks/use-coagent-state-render.d.ts +2 -2
  60. package/dist/hooks/use-coagent-state-render.js +1 -13
  61. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  62. package/dist/hooks/use-coagent-state-render.mjs +2 -2
  63. package/dist/hooks/use-coagent.d.ts +1 -14
  64. package/dist/hooks/use-coagent.js +262 -580
  65. package/dist/hooks/use-coagent.js.map +1 -1
  66. package/dist/hooks/use-coagent.mjs +11 -19
  67. package/dist/hooks/use-copilot-action.d.ts +2 -12
  68. package/dist/hooks/use-copilot-action.js +17 -167
  69. package/dist/hooks/use-copilot-action.js.map +1 -1
  70. package/dist/hooks/use-copilot-action.mjs +2 -4
  71. package/dist/hooks/use-copilot-chat.d.ts +0 -2
  72. package/dist/hooks/use-copilot-chat.js +238 -532
  73. package/dist/hooks/use-copilot-chat.js.map +1 -1
  74. package/dist/hooks/use-copilot-chat.mjs +10 -12
  75. package/dist/hooks/use-copilot-readable.js +1 -13
  76. package/dist/hooks/use-copilot-readable.js.map +1 -1
  77. package/dist/hooks/use-copilot-readable.mjs +2 -2
  78. package/dist/hooks/use-copilot-runtime-client.js +4 -110
  79. package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
  80. package/dist/hooks/use-copilot-runtime-client.mjs +2 -2
  81. package/dist/hooks/use-make-copilot-document-readable.js +1 -13
  82. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  83. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  84. package/dist/index.d.ts +3 -3
  85. package/dist/index.js +391 -703
  86. package/dist/index.js.map +1 -1
  87. package/dist/index.mjs +30 -38
  88. package/dist/lib/copilot-task.d.ts +1 -6
  89. package/dist/lib/copilot-task.js +17 -55
  90. package/dist/lib/copilot-task.js.map +1 -1
  91. package/dist/lib/copilot-task.mjs +8 -10
  92. package/dist/lib/index.d.ts +1 -1
  93. package/dist/lib/index.js +17 -55
  94. package/dist/lib/index.js.map +1 -1
  95. package/dist/lib/index.mjs +8 -10
  96. package/dist/types/frontend-action.d.ts +2 -21
  97. package/dist/types/frontend-action.js +0 -34
  98. package/dist/types/frontend-action.js.map +1 -1
  99. package/dist/types/frontend-action.mjs +0 -7
  100. package/dist/types/index.d.ts +1 -2
  101. package/dist/types/index.js.map +1 -1
  102. package/dist/utils/extract.d.ts +2 -3
  103. package/dist/utils/extract.js +3 -21
  104. package/dist/utils/extract.js.map +1 -1
  105. package/dist/utils/extract.mjs +7 -8
  106. package/dist/utils/index.js +3 -21
  107. package/dist/utils/index.js.map +1 -1
  108. package/dist/utils/index.mjs +9 -10
  109. package/package.json +5 -5
  110. package/src/components/copilot-provider/copilotkit-props.tsx +10 -0
  111. package/src/components/copilot-provider/copilotkit.tsx +44 -7
  112. package/src/components/toast/toast-provider.tsx +1 -1
  113. package/src/context/copilot-context.tsx +28 -2
  114. package/src/hooks/index.ts +1 -0
  115. package/src/hooks/use-chat.ts +15 -5
  116. package/src/hooks/use-coagent-state-render.ts +11 -0
  117. package/src/hooks/use-coagent.ts +11 -1
  118. package/src/hooks/use-copilot-authenticated-action.ts +60 -0
  119. package/src/hooks/use-copilot-chat.ts +1 -0
  120. package/dist/chunk-7LRDVJH5.mjs.map +0 -1
  121. package/dist/chunk-M3SYKJ3W.mjs +0 -393
  122. package/dist/chunk-M3SYKJ3W.mjs.map +0 -1
  123. package/dist/chunk-MKEQ2MJG.mjs.map +0 -1
  124. package/dist/chunk-NYBGR2NK.mjs.map +0 -1
  125. package/dist/chunk-OAF4ASJH.mjs.map +0 -1
  126. package/dist/chunk-QCUP6HLK.mjs +0 -37
  127. package/dist/chunk-QCUP6HLK.mjs.map +0 -1
  128. package/dist/chunk-SFPANIOY.mjs.map +0 -1
  129. package/dist/chunk-STZUYPHJ.mjs.map +0 -1
  130. package/dist/chunk-VQDGBYWQ.mjs.map +0 -1
  131. package/dist/chunk-XERJQUHA.mjs +0 -31
  132. package/dist/chunk-XERJQUHA.mjs.map +0 -1
  133. package/dist/chunk-YL6V3QTN.mjs.map +0 -1
  134. package/dist/components/error-boundary/error-boundary.d.ts +0 -22
  135. package/dist/components/error-boundary/error-boundary.js +0 -183
  136. package/dist/components/error-boundary/error-boundary.js.map +0 -1
  137. package/dist/components/error-boundary/error-boundary.mjs +0 -12
  138. package/dist/components/error-boundary/error-boundary.mjs.map +0 -1
  139. package/dist/components/error-boundary/error-utils.d.ts +0 -11
  140. package/dist/components/error-boundary/error-utils.js +0 -177
  141. package/dist/components/error-boundary/error-utils.js.map +0 -1
  142. package/dist/components/error-boundary/error-utils.mjs +0 -13
  143. package/dist/components/error-boundary/error-utils.mjs.map +0 -1
  144. /package/dist/{chunk-VPTC36RZ.mjs.map → chunk-H4VZMKR6.mjs.map} +0 -0
  145. /package/dist/{chunk-6KHA5W5R.mjs.map → chunk-QDGDXRRJ.mjs.map} +0 -0
@@ -85,7 +85,7 @@ __export(copilotkit_exports, {
85
85
  defaultCopilotContextCategories: () => defaultCopilotContextCategories
86
86
  });
87
87
  module.exports = __toCommonJS(copilotkit_exports);
88
- var import_react10 = require("react");
88
+ var import_react8 = require("react");
89
89
 
90
90
  // src/context/copilot-context.tsx
91
91
  var import_react = __toESM(require("react"));
@@ -136,21 +136,9 @@ var emptyCopilotContext = {
136
136
  coagentStates: {},
137
137
  setCoagentStates: () => {
138
138
  },
139
- coagentStatesRef: { current: {} },
140
- setCoagentStatesWithRef: () => {
141
- },
142
139
  agentSession: null,
143
140
  setAgentSession: () => {
144
- },
145
- forwardedParameters: {},
146
- agentLock: null,
147
- threadId: null,
148
- setThreadId: () => {
149
- },
150
- runId: null,
151
- setRunId: () => {
152
- },
153
- chatAbortControllerRef: { current: null }
141
+ }
154
142
  };
155
143
  var CopilotContext = import_react.default.createContext(emptyCopilotContext);
156
144
  function returnAndThrowInDebug(value) {
@@ -388,9 +376,6 @@ function CopilotMessages(_a) {
388
376
  }
389
377
 
390
378
  // src/components/toast/toast-provider.tsx
391
- var import_react7 = require("react");
392
-
393
- // src/components/error-boundary/error-utils.tsx
394
379
  var import_react6 = require("react");
395
380
 
396
381
  // src/components/toast/exclamation-mark-icon.tsx
@@ -420,82 +405,11 @@ var ExclamationMarkIcon = ({
420
405
  }
421
406
  );
422
407
 
423
- // src/components/error-boundary/error-utils.tsx
424
- var import_jsx_runtime3 = require("react/jsx-runtime");
425
- function ErrorToast({ errors }) {
426
- const errorsToRender = errors.map((error, idx) => {
427
- var _a, _b, _c;
428
- const message = "extensions" in error ? (_b = (_a = error.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message : error.message;
429
- const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
430
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
431
- "div",
432
- {
433
- style: {
434
- marginTop: idx === 0 ? 0 : 10,
435
- marginBottom: 14
436
- },
437
- children: [
438
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
439
- code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
440
- "div",
441
- {
442
- style: {
443
- fontWeight: "600",
444
- marginBottom: 4
445
- },
446
- children: [
447
- "Copilot Cloud Error:",
448
- " ",
449
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
450
- ]
451
- }
452
- ),
453
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: message })
454
- ]
455
- },
456
- idx
457
- );
458
- });
459
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
460
- "div",
461
- {
462
- style: {
463
- fontSize: "13px",
464
- maxWidth: "600px"
465
- },
466
- children: [
467
- errorsToRender,
468
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
469
- ]
470
- }
471
- );
472
- }
473
- function useErrorToast() {
474
- const { addToast } = useToast();
475
- return (0, import_react6.useCallback)(
476
- (error) => {
477
- const errorId = error.map((err) => {
478
- var _a, _b;
479
- const message = "extensions" in err ? ((_b = (_a = err.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message) || err.message : err.message;
480
- const stack = err.stack || "";
481
- return btoa(message + stack).slice(0, 32);
482
- }).join("|");
483
- addToast({
484
- type: "error",
485
- id: errorId,
486
- // Toast libraries typically dedupe by id
487
- message: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorToast, { errors: error })
488
- });
489
- },
490
- [addToast]
491
- );
492
- }
493
-
494
408
  // src/components/toast/toast-provider.tsx
495
- var import_jsx_runtime4 = require("react/jsx-runtime");
496
- var ToastContext = (0, import_react7.createContext)(void 0);
409
+ var import_jsx_runtime3 = require("react/jsx-runtime");
410
+ var ToastContext = (0, import_react6.createContext)(void 0);
497
411
  function useToast() {
498
- const context = (0, import_react7.useContext)(ToastContext);
412
+ const context = (0, import_react6.useContext)(ToastContext);
499
413
  if (!context) {
500
414
  throw new Error("useToast must be used within a ToastProvider");
501
415
  }
@@ -505,28 +419,68 @@ function ToastProvider({
505
419
  enabled,
506
420
  children
507
421
  }) {
508
- const [toasts, setToasts] = (0, import_react7.useState)([]);
509
- const addToast = (0, import_react7.useCallback)((toast) => {
510
- var _a;
511
- const id = (_a = toast.id) != null ? _a : Math.random().toString(36).substring(2, 9);
512
- setToasts((currentToasts) => {
513
- if (currentToasts.find((toast2) => toast2.id === id))
514
- return currentToasts;
515
- return [...currentToasts, __spreadProps(__spreadValues({}, toast), { id })];
516
- });
422
+ const [toasts, setToasts] = (0, import_react6.useState)([]);
423
+ const addToast = (0, import_react6.useCallback)((toast) => {
424
+ const id = Math.random().toString(36).substring(2, 9);
425
+ setToasts((currentToasts) => [...currentToasts, __spreadProps(__spreadValues({}, toast), { id })]);
517
426
  if (toast.duration) {
518
427
  setTimeout(() => {
519
428
  removeToast(id);
520
429
  }, toast.duration);
521
430
  }
522
431
  }, []);
523
- const addGraphQLErrorsToast = (0, import_react7.useCallback)((errors) => {
432
+ const addGraphQLErrorsToast = (0, import_react6.useCallback)((errors) => {
433
+ const errorsToRender = errors.map((error, idx) => {
434
+ var _a;
435
+ const message = error.message;
436
+ const code = (_a = error.extensions) == null ? void 0 : _a.code;
437
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
438
+ "div",
439
+ {
440
+ style: {
441
+ marginTop: idx === 0 ? 0 : 10,
442
+ marginBottom: 14
443
+ },
444
+ children: [
445
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
446
+ code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
447
+ "div",
448
+ {
449
+ style: {
450
+ fontWeight: "600",
451
+ marginBottom: 4
452
+ },
453
+ children: [
454
+ "Copilot Cloud Error:",
455
+ " ",
456
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
457
+ ]
458
+ }
459
+ ),
460
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: message })
461
+ ]
462
+ },
463
+ idx
464
+ );
465
+ });
524
466
  addToast({
525
467
  type: "error",
526
- message: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorToast, { errors })
468
+ message: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
469
+ "div",
470
+ {
471
+ style: {
472
+ fontSize: "13px",
473
+ maxWidth: "600px"
474
+ },
475
+ children: [
476
+ errorsToRender,
477
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This is a Copilot Cloud error, and it only displays during local development." })
478
+ ]
479
+ }
480
+ )
527
481
  });
528
482
  }, []);
529
- const removeToast = (0, import_react7.useCallback)((id) => {
483
+ const removeToast = (0, import_react6.useCallback)((id) => {
530
484
  setToasts((currentToasts) => currentToasts.filter((toast) => toast.id !== id));
531
485
  }, []);
532
486
  const value = {
@@ -536,8 +490,8 @@ function ToastProvider({
536
490
  removeToast,
537
491
  enabled
538
492
  };
539
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(ToastContext.Provider, { value, children: [
540
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
493
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(ToastContext.Provider, { value, children: [
494
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
541
495
  "div",
542
496
  {
543
497
  style: {
@@ -551,7 +505,7 @@ function ToastProvider({
551
505
  gap: "0.5rem"
552
506
  },
553
507
  children: [
554
- toasts.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { textAlign: "right" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
508
+ toasts.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { textAlign: "right" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
555
509
  "button",
556
510
  {
557
511
  onClick: () => setToasts([]),
@@ -566,7 +520,7 @@ function ToastProvider({
566
520
  children: "Close All"
567
521
  }
568
522
  ) }),
569
- toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
523
+ toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
570
524
  Toast,
571
525
  {
572
526
  message: toast.message,
@@ -592,7 +546,7 @@ function Toast({
592
546
  warning: "#eab308",
593
547
  error: "#ef4444"
594
548
  };
595
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
549
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
596
550
  "div",
597
551
  {
598
552
  style: {
@@ -605,8 +559,8 @@ function Toast({
605
559
  minWidth: "200px"
606
560
  },
607
561
  children: [
608
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: message }),
609
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
562
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: message }),
563
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
610
564
  "button",
611
565
  {
612
566
  onClick: onClose,
@@ -631,17 +585,14 @@ function Toast({
631
585
 
632
586
  // src/hooks/use-copilot-runtime-client.ts
633
587
  var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
634
- var import_react8 = require("react");
588
+ var import_react7 = require("react");
635
589
  var useCopilotRuntimeClient = (options) => {
636
590
  const { addGraphQLErrorsToast } = useToast();
637
- const addErrorToast = useErrorToast();
638
- const runtimeClient = (0, import_react8.useMemo)(() => {
591
+ const runtimeClient = (0, import_react7.useMemo)(() => {
639
592
  return new import_runtime_client_gql.CopilotRuntimeClient(__spreadProps(__spreadValues({}, options), {
640
593
  handleGQLErrors: (error) => {
641
594
  if (error.graphQLErrors.length) {
642
595
  addGraphQLErrorsToast(error.graphQLErrors);
643
- } else {
644
- addErrorToast([error]);
645
596
  }
646
597
  }
647
598
  }));
@@ -663,41 +614,13 @@ function getHostname() {
663
614
  return "";
664
615
  }
665
616
 
666
- // src/components/error-boundary/error-boundary.tsx
667
- var import_react9 = __toESM(require("react"));
668
- var import_jsx_runtime5 = require("react/jsx-runtime");
669
- var CopilotErrorBoundary = class extends import_react9.default.Component {
670
- constructor(props) {
671
- super(props);
672
- this.state = { hasError: false };
673
- }
674
- static getDerivedStateFromError(error) {
675
- return { hasError: true, error };
676
- }
677
- componentDidCatch(error, errorInfo) {
678
- console.error("CopilotKit Error:", error, errorInfo);
679
- }
680
- render() {
681
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ErrorToast2, { error: this.state.error, children: this.props.children });
682
- }
683
- };
684
- function ErrorToast2({ error, children }) {
685
- const addErrorToast = useErrorToast();
686
- (0, import_react9.useEffect)(() => {
687
- if (error) {
688
- addErrorToast([error]);
689
- }
690
- }, [error, addErrorToast]);
691
- return children;
692
- }
693
-
694
617
  // src/components/copilot-provider/copilotkit.tsx
695
- var import_jsx_runtime6 = require("react/jsx-runtime");
618
+ var import_jsx_runtime4 = require("react/jsx-runtime");
696
619
  function CopilotKit(_a) {
697
620
  var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
698
621
  const showDevConsole = props.showDevConsole === void 0 ? "auto" : props.showDevConsole;
699
622
  const enabled = shouldShowDevConsole(showDevConsole);
700
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ToastProvider, { enabled, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CopilotErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children })) }) });
623
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ToastProvider, { enabled, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children })) });
701
624
  }
702
625
  function CopilotKitInternal(_a) {
703
626
  var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
@@ -707,49 +630,49 @@ function CopilotKitInternal(_a) {
707
630
  );
708
631
  }
709
632
  const chatApiEndpoint = props.runtimeUrl || import_shared3.COPILOT_CLOUD_CHAT_URL;
710
- const [actions, setActions] = (0, import_react10.useState)({});
711
- const [coAgentStateRenders, setCoAgentStateRenders] = (0, import_react10.useState)({});
712
- const chatComponentsCache = (0, import_react10.useRef)({
633
+ const [actions, setActions] = (0, import_react8.useState)({});
634
+ const [coAgentStateRenders, setCoAgentStateRenders] = (0, import_react8.useState)({});
635
+ const chatComponentsCache = (0, import_react8.useRef)({
713
636
  actions: {},
714
637
  coAgentStateRenders: {}
715
638
  });
716
639
  const { addElement, removeElement, printTree } = use_tree_default();
717
- const [isLoading, setIsLoading] = (0, import_react10.useState)(false);
718
- const [chatInstructions, setChatInstructions] = (0, import_react10.useState)("");
640
+ const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
641
+ const [chatInstructions, setChatInstructions] = (0, import_react8.useState)("");
719
642
  const {
720
643
  addElement: addDocument,
721
644
  removeElement: removeDocument,
722
645
  allElements: allDocuments
723
646
  } = use_flat_category_store_default();
724
- const setAction = (0, import_react10.useCallback)((id, action) => {
647
+ const setAction = (0, import_react8.useCallback)((id, action) => {
725
648
  setActions((prevPoints) => {
726
649
  return __spreadProps(__spreadValues({}, prevPoints), {
727
650
  [id]: action
728
651
  });
729
652
  });
730
653
  }, []);
731
- const removeAction = (0, import_react10.useCallback)((id) => {
654
+ const removeAction = (0, import_react8.useCallback)((id) => {
732
655
  setActions((prevPoints) => {
733
656
  const newPoints = __spreadValues({}, prevPoints);
734
657
  delete newPoints[id];
735
658
  return newPoints;
736
659
  });
737
660
  }, []);
738
- const setCoAgentStateRender = (0, import_react10.useCallback)((id, stateRender) => {
661
+ const setCoAgentStateRender = (0, import_react8.useCallback)((id, stateRender) => {
739
662
  setCoAgentStateRenders((prevPoints) => {
740
663
  return __spreadProps(__spreadValues({}, prevPoints), {
741
664
  [id]: stateRender
742
665
  });
743
666
  });
744
667
  }, []);
745
- const removeCoAgentStateRender = (0, import_react10.useCallback)((id) => {
668
+ const removeCoAgentStateRender = (0, import_react8.useCallback)((id) => {
746
669
  setCoAgentStateRenders((prevPoints) => {
747
670
  const newPoints = __spreadValues({}, prevPoints);
748
671
  delete newPoints[id];
749
672
  return newPoints;
750
673
  });
751
674
  }, []);
752
- const getContextString = (0, import_react10.useCallback)(
675
+ const getContextString = (0, import_react8.useCallback)(
753
676
  (documents, categories) => {
754
677
  const documentsString = documents.map((document) => {
755
678
  return `${document.name} (${document.sourceApplication}):
@@ -762,37 +685,37 @@ ${nonDocumentStrings}`;
762
685
  },
763
686
  [printTree]
764
687
  );
765
- const addContext = (0, import_react10.useCallback)(
688
+ const addContext = (0, import_react8.useCallback)(
766
689
  (context, parentId, categories = defaultCopilotContextCategories) => {
767
690
  return addElement(context, categories, parentId);
768
691
  },
769
692
  [addElement]
770
693
  );
771
- const removeContext = (0, import_react10.useCallback)(
694
+ const removeContext = (0, import_react8.useCallback)(
772
695
  (id) => {
773
696
  removeElement(id);
774
697
  },
775
698
  [removeElement]
776
699
  );
777
- const getFunctionCallHandler = (0, import_react10.useCallback)(
700
+ const getFunctionCallHandler = (0, import_react8.useCallback)(
778
701
  (customEntryPoints) => {
779
702
  return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || actions));
780
703
  },
781
704
  [actions]
782
705
  );
783
- const getDocumentsContext = (0, import_react10.useCallback)(
706
+ const getDocumentsContext = (0, import_react8.useCallback)(
784
707
  (categories) => {
785
708
  return allDocuments(categories);
786
709
  },
787
710
  [allDocuments]
788
711
  );
789
- const addDocumentContext = (0, import_react10.useCallback)(
712
+ const addDocumentContext = (0, import_react8.useCallback)(
790
713
  (documentPointer, categories = defaultCopilotContextCategories) => {
791
714
  return addDocument(documentPointer, categories);
792
715
  },
793
716
  [addDocument]
794
717
  );
795
- const removeDocumentContext = (0, import_react10.useCallback)(
718
+ const removeDocumentContext = (0, import_react8.useCallback)(
796
719
  (documentId) => {
797
720
  removeDocument(documentId);
798
721
  },
@@ -805,7 +728,7 @@ ${nonDocumentStrings}`;
805
728
  );
806
729
  }
807
730
  }
808
- const copilotApiConfig = (0, import_react10.useMemo)(() => {
731
+ const copilotApiConfig = (0, import_react8.useMemo)(() => {
809
732
  var _a2, _b2;
810
733
  let cloud = void 0;
811
734
  if (props.publicApiKey) {
@@ -847,7 +770,7 @@ ${nonDocumentStrings}`;
847
770
  headers,
848
771
  credentials: copilotApiConfig.credentials
849
772
  });
850
- const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react10.useState)({});
773
+ const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react8.useState)({});
851
774
  const addChatSuggestionConfiguration = (id, suggestion) => {
852
775
  setChatSuggestionConfiguration((prev) => __spreadProps(__spreadValues({}, prev), { [id]: suggestion }));
853
776
  };
@@ -857,30 +780,16 @@ ${nonDocumentStrings}`;
857
780
  return rest;
858
781
  });
859
782
  };
860
- const [coagentStates, setCoagentStates] = (0, import_react10.useState)({});
861
- const coagentStatesRef = (0, import_react10.useRef)({});
862
- const setCoagentStatesWithRef = (0, import_react10.useCallback)(
863
- (value) => {
864
- const newValue = typeof value === "function" ? value(coagentStatesRef.current) : value;
865
- coagentStatesRef.current = newValue;
866
- setCoagentStates((prev) => {
867
- return newValue;
868
- });
869
- },
870
- []
871
- );
783
+ const [coagentStates, setCoagentStates] = (0, import_react8.useState)({});
872
784
  let initialAgentSession = null;
873
785
  if (props.agent) {
874
786
  initialAgentSession = {
875
787
  agentName: props.agent
876
788
  };
877
789
  }
878
- const [agentSession, setAgentSession] = (0, import_react10.useState)(initialAgentSession);
879
- const [threadId, setThreadId] = (0, import_react10.useState)(null);
880
- const [runId, setRunId] = (0, import_react10.useState)(null);
881
- const chatAbortControllerRef = (0, import_react10.useRef)(null);
790
+ const [agentSession, setAgentSession] = (0, import_react8.useState)(initialAgentSession);
882
791
  const showDevConsole = props.showDevConsole === void 0 ? "auto" : props.showDevConsole;
883
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
792
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
884
793
  CopilotContext.Provider,
885
794
  {
886
795
  value: {
@@ -909,20 +818,11 @@ ${nonDocumentStrings}`;
909
818
  showDevConsole,
910
819
  coagentStates,
911
820
  setCoagentStates,
912
- coagentStatesRef,
913
- setCoagentStatesWithRef,
914
821
  agentSession,
915
822
  setAgentSession,
916
- runtimeClient,
917
- forwardedParameters: props.forwardedParameters || {},
918
- agentLock: props.agent || null,
919
- threadId,
920
- setThreadId,
921
- runId,
922
- setRunId,
923
- chatAbortControllerRef
823
+ runtimeClient
924
824
  },
925
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CopilotMessages, { children })
825
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CopilotMessages, { children })
926
826
  }
927
827
  );
928
828
  }