@copilotkit/react-core 1.77.0 → 1.77.2

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.
package/dist/index.umd.js CHANGED
@@ -602,7 +602,7 @@ react_markdown = __toESM(react_markdown);
602
602
 
603
603
  //#endregion
604
604
  //#region package.json
605
- var version = "1.77.0";
605
+ var version = "1.77.2";
606
606
 
607
607
  //#endregion
608
608
  //#region src/v2/components/CopilotKitInspector.tsx
@@ -2231,7 +2231,12 @@ react_markdown = __toESM(react_markdown);
2231
2231
  - Use CSS Grid or Flexbox for layout. Ensure the UI looks good at any width.
2232
2232
  - Minimal transitions (150ms) for hover/focus states only. No decorative animations.
2233
2233
  - Keep the UI focused and dense — avoid excessive padding. Use compact spacing (8–12px gaps, 10–14px padding in controls).`;
2234
- const GENERATE_SANDBOXED_UI_DESCRIPTION = "Generate sandboxed UI. IMPORTANT: The generated code runs in a sandboxed iframe WITHOUT same-origin access. Do NOT use localStorage, sessionStorage, document.cookie, IndexedDB, or fetch/XMLHttpRequest to same-origin URLs. To communicate with the host application, use Websandbox.connection.remote.<functionName>(args) which returns a Promise.\n\nYou CAN use external libraries from CDNs by including <script> or <link> tags in the HTML <head> (e.g., Chart.js, D3, Three.js, x-data-spreadsheet, etc.). CDN resources load normally inside the sandbox.\n\nPARAMETER ORDER IS CRITICAL — generate parameters in exactly this order:\n1. initialHeight + placeholderMessages (shown to user while generating)\n2. css (all styles FIRST — the user sees a placeholder until CSS is complete)\n3. html (streams in live — the user watches the UI build as HTML is generated)\n4. jsFunctions (reusable helper functions)\n5. jsExpressions (applied one-by-one — the user sees each expression take effect)";
2234
+ const DEFAULT_LEARNING = Object.freeze({});
2235
+ function toLearningConfig(learning) {
2236
+ if (learning === true) return DEFAULT_LEARNING;
2237
+ if (learning === false) return void 0;
2238
+ return learning;
2239
+ }
2235
2240
  function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
2236
2241
  const empty = (0, react.useMemo)(() => [], []);
2237
2242
  const value = prop ?? empty;
@@ -2242,6 +2247,7 @@ react_markdown = __toESM(react_markdown);
2242
2247
  return value;
2243
2248
  }
2244
2249
  const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, messageFilter, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, showIntelligenceIndicator = true, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug, learning }) => {
2250
+ const learningConfig = toLearningConfig(learning);
2245
2251
  const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
2246
2252
  const [inspectorVisible, setInspectorVisible] = (0, react.useState)(false);
2247
2253
  (0, react.useEffect)(() => {
@@ -2424,7 +2430,7 @@ react_markdown = __toESM(react_markdown);
2424
2430
  if (!openGenUIActive) return [];
2425
2431
  return [{
2426
2432
  name: "generateSandboxedUi",
2427
- description: GENERATE_SANDBOXED_UI_DESCRIPTION,
2433
+ description: _copilotkit_shared.GENERATE_SANDBOXED_UI_DESCRIPTION,
2428
2434
  parameters: GenerateSandboxedUiArgsSchema,
2429
2435
  handler: async () => "UI generated",
2430
2436
  followUp: true,
@@ -2477,7 +2483,7 @@ react_markdown = __toESM(react_markdown);
2477
2483
  renderActivityMessages: allActivityRenderers,
2478
2484
  renderCustomMessages: renderCustomMessagesList,
2479
2485
  debug,
2480
- learning
2486
+ learning: learningConfig
2481
2487
  });
2482
2488
  if (defaultThrottleMs !== void 0) copilotkitRef.current.setDefaultThrottleMs(defaultThrottleMs);
2483
2489
  }
@@ -2582,17 +2588,21 @@ react_markdown = __toESM(react_markdown);
2582
2588
  useSingleEndpoint,
2583
2589
  debug
2584
2590
  ]);
2585
- const learningEnabled = learning !== void 0;
2586
- const trajectoryId = learning?.trajectoryId;
2587
- const learningContainerIdsRef = (0, react.useRef)(learning?.learningContainerIds);
2591
+ const learningEnabled = learningConfig !== void 0;
2592
+ const generatesTrajectoryId = learning === true;
2593
+ const suppliedTrajectoryId = learningConfig?.trajectoryId;
2594
+ const learningContainerIdsRef = (0, react.useRef)(learningConfig?.learningContainerIds);
2595
+ const generatedTrajectoryIdRef = (0, react.useRef)(void 0);
2588
2596
  (0, react.useEffect)(() => {
2589
- copilotkit.setLearningConfig(learning);
2590
- learningContainerIdsRef.current = learning?.learningContainerIds;
2591
- if (learning?.sink === void 0 && learning?.trajectoryId === void 0 && learning?.learningContainerIds !== void 0) console.warn("[CopilotKit] learningContainerIds is supported only with a custom sink. Authenticated Trajectory capture does not assign Learning Containers; remove learningContainerIds from the capture options.");
2592
- }, [copilotkit, learning]);
2597
+ copilotkit.setLearningConfig(learningConfig);
2598
+ learningContainerIdsRef.current = learningConfig?.learningContainerIds;
2599
+ if (learningConfig?.sink === void 0 && learningConfig?.trajectoryId === void 0 && learningConfig?.learningContainerIds !== void 0) console.warn("[CopilotKit] learningContainerIds is supported only with a custom sink. Authenticated Trajectory capture does not assign Learning Containers; remove learningContainerIds from the capture options.");
2600
+ }, [copilotkit, learningConfig]);
2593
2601
  (0, react.useEffect)(() => {
2602
+ if (!generatesTrajectoryId) generatedTrajectoryIdRef.current = void 0;
2594
2603
  if (!learningEnabled) return;
2595
2604
  let disposed = false;
2605
+ const trajectoryId = generatesTrajectoryId ? generatedTrajectoryIdRef.current ?? (generatedTrajectoryIdRef.current = (0, _copilotkit_shared.randomUUID)()) : suppliedTrajectoryId;
2596
2606
  if (trajectoryId !== void 0) copilotkit.startTrajectory({
2597
2607
  trajectoryId,
2598
2608
  learningContainerIds: learningContainerIdsRef.current
@@ -2606,7 +2616,8 @@ react_markdown = __toESM(react_markdown);
2606
2616
  }, [
2607
2617
  copilotkit,
2608
2618
  learningEnabled,
2609
- trajectoryId
2619
+ generatesTrajectoryId,
2620
+ suppliedTrajectoryId
2610
2621
  ]);
2611
2622
  const didMountRef = (0, react.useRef)(false);
2612
2623
  (0, react.useEffect)(() => {
@@ -7110,7 +7121,7 @@ react_markdown = __toESM(react_markdown);
7110
7121
  * running, // A boolean indicating if the agent is currently running.
7111
7122
  * start, // A function to start the agent.
7112
7123
  * stop, // A function to stop the agent.
7113
- * run, // A function to (re-)run the agent. Maps to the v2 agent's `runAgent()`.
7124
+ * run, // A function to (re-)run the agent through the v2 core (`copilotkit.runAgent`).
7114
7125
  * } = agent;
7115
7126
  * ```
7116
7127
  *
@@ -7221,6 +7232,17 @@ react_markdown = __toESM(react_markdown);
7221
7232
  handleStateUpdate,
7222
7233
  hasStateValues
7223
7234
  ]);
7235
+ const runAgent = (0, react.useCallback)(async (parameters) => {
7236
+ if (!agent) return void 0;
7237
+ return copilotkit.runAgent({
7238
+ agent,
7239
+ forwardedProps: parameters?.forwardedProps,
7240
+ runId: parameters?.runId
7241
+ });
7242
+ }, [agent, copilotkit]);
7243
+ const stopAgent = (0, react.useCallback)(() => {
7244
+ if (agent) copilotkit.stopAgent({ agent });
7245
+ }, [agent, copilotkit]);
7224
7246
  return (0, react.useMemo)(() => {
7225
7247
  if (!agent) {
7226
7248
  const noop = () => {};
@@ -7245,15 +7267,14 @@ react_markdown = __toESM(react_markdown);
7245
7267
  running: agent.isRunning,
7246
7268
  state: agent.state,
7247
7269
  setState: handleStateUpdate,
7248
- start: agent.runAgent,
7249
- stop: agent.abortRun,
7250
- run: agent.runAgent
7270
+ start: runAgent,
7271
+ stop: stopAgent,
7272
+ run: runAgent
7251
7273
  };
7252
7274
  }, [
7253
7275
  agent?.state,
7254
- agent?.runAgent,
7255
- agent?.abortRun,
7256
- agent?.runAgent,
7276
+ runAgent,
7277
+ stopAgent,
7257
7278
  agent?.threadId,
7258
7279
  agent?.isRunning,
7259
7280
  agent?.agentId,