@copilotkit/react-core 1.75.1 → 1.76.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 (36) hide show
  1. package/dist/{copilotkit-CGlSOKHM.d.mts → copilotkit-B90cY0Zg.d.mts} +18 -17
  2. package/dist/copilotkit-B90cY0Zg.d.mts.map +1 -0
  3. package/dist/{copilotkit-DfsHZUuo.mjs → copilotkit-LD7Gp2aV.mjs} +75 -49
  4. package/dist/copilotkit-LD7Gp2aV.mjs.map +1 -0
  5. package/dist/{copilotkit-Cjj9wDI8.d.cts → copilotkit-W-bV_OSs.d.cts} +5 -4
  6. package/dist/copilotkit-W-bV_OSs.d.cts.map +1 -0
  7. package/dist/{copilotkit-DIudpHkM.cjs → copilotkit-dHdNF7H5.cjs} +71 -46
  8. package/dist/copilotkit-dHdNF7H5.cjs.map +1 -0
  9. package/dist/index.cjs +2 -2
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +1 -1
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.mts +1 -1
  14. package/dist/index.d.mts.map +1 -1
  15. package/dist/index.mjs +4 -4
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/index.umd.js +24 -43
  18. package/dist/index.umd.js.map +1 -1
  19. package/dist/v2/headless.cjs +20 -38
  20. package/dist/v2/headless.cjs.map +1 -1
  21. package/dist/v2/headless.d.cts.map +1 -1
  22. package/dist/v2/headless.d.mts +2 -2
  23. package/dist/v2/headless.d.mts.map +1 -1
  24. package/dist/v2/headless.mjs +21 -39
  25. package/dist/v2/headless.mjs.map +1 -1
  26. package/dist/v2/index.cjs +302 -121
  27. package/dist/v2/index.d.cts +2 -2
  28. package/dist/v2/index.d.mts +2 -2
  29. package/dist/v2/index.mjs +2 -2
  30. package/dist/v2/index.umd.js +373 -169
  31. package/dist/v2/index.umd.js.map +1 -1
  32. package/package.json +10 -10
  33. package/dist/copilotkit-CGlSOKHM.d.mts.map +0 -1
  34. package/dist/copilotkit-Cjj9wDI8.d.cts.map +0 -1
  35. package/dist/copilotkit-DIudpHkM.cjs.map +0 -1
  36. package/dist/copilotkit-DfsHZUuo.mjs.map +0 -1
package/dist/index.umd.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
 
3
3
  (function(global, factory) {
4
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@copilotkit/core'), require('@ag-ui/client'), require('@copilotkit/shared'), require('react/jsx-runtime'), require('zod'), require('@copilotkit/mcp-apps-renderer/activity'), require('@copilotkit/a2ui-renderer'), require('zod-to-json-schema'), require('react-dom'), require('react-markdown'), require('@copilotkit/runtime-client-gql')) :
5
- typeof define === 'function' && define.amd ? define(['exports', 'react', '@copilotkit/core', '@ag-ui/client', '@copilotkit/shared', 'react/jsx-runtime', 'zod', '@copilotkit/mcp-apps-renderer/activity', '@copilotkit/a2ui-renderer', 'zod-to-json-schema', 'react-dom', 'react-markdown', '@copilotkit/runtime-client-gql'], factory) :
6
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitReactCore = {}), global.React,global.CopilotKitCore,global.AgUIClient,global.CopilotKitShared,global.ReactJsxRuntime,global.Zod,global.CopilotKitMcpAppsRendererActivity,global.CopilotKitA2UIRenderer,global.zod_to_json_schema,global.ReactDOM,global.ReactMarkdown,global.CopilotKitRuntimeClientGQL));
7
- })(this, function(exports, react, _copilotkit_core, _ag_ui_client, _copilotkit_shared, react_jsx_runtime, zod, _copilotkit_mcp_apps_renderer_activity, _copilotkit_a2ui_renderer, zod_to_json_schema, react_dom, react_markdown, _copilotkit_runtime_client_gql) {
4
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@copilotkit/core'), require('@ag-ui/client'), require('@copilotkit/shared'), require('react/jsx-runtime'), require('@ag-ui/core'), require('zod'), require('@copilotkit/mcp-apps-renderer/activity'), require('@copilotkit/a2ui-renderer'), require('zod-to-json-schema'), require('react-dom'), require('react-markdown'), require('@copilotkit/runtime-client-gql')) :
5
+ typeof define === 'function' && define.amd ? define(['exports', 'react', '@copilotkit/core', '@ag-ui/client', '@copilotkit/shared', 'react/jsx-runtime', '@ag-ui/core', 'zod', '@copilotkit/mcp-apps-renderer/activity', '@copilotkit/a2ui-renderer', 'zod-to-json-schema', 'react-dom', 'react-markdown', '@copilotkit/runtime-client-gql'], factory) :
6
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitReactCore = {}), global.React,global.CopilotKitCore,global.AgUIClient,global.CopilotKitShared,global.ReactJsxRuntime,global._ag_ui_core,global.Zod,global.CopilotKitMcpAppsRendererActivity,global.CopilotKitA2UIRenderer,global.zod_to_json_schema,global.ReactDOM,global.ReactMarkdown,global.CopilotKitRuntimeClientGQL));
7
+ })(this, function(exports, react, _copilotkit_core, _ag_ui_client, _copilotkit_shared, react_jsx_runtime, _ag_ui_core, zod, _copilotkit_mcp_apps_renderer_activity, _copilotkit_a2ui_renderer, zod_to_json_schema, react_dom, react_markdown, _copilotkit_runtime_client_gql) {
8
8
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
9
9
  //#region \0rolldown/runtime.js
10
10
  var __create = Object.create;
@@ -487,7 +487,7 @@ react_markdown = __toESM(react_markdown);
487
487
  toolCallId: toolCall.id,
488
488
  args,
489
489
  status: _copilotkit_core.ToolCallStatus.Complete,
490
- result: toolMessage.content
490
+ result: (0, _ag_ui_core.contentToText)(toolMessage.content)
491
491
  });
492
492
  else if (isExecuting) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderComponent, {
493
493
  name: toolName,
@@ -583,7 +583,7 @@ react_markdown = __toESM(react_markdown);
583
583
 
584
584
  //#endregion
585
585
  //#region package.json
586
- var version = "1.75.1";
586
+ var version = "1.76.0";
587
587
 
588
588
  //#endregion
589
589
  //#region src/v2/components/CopilotKitInspector.tsx
@@ -3026,7 +3026,7 @@ react_markdown = __toESM(react_markdown);
3026
3026
  updateFlags
3027
3027
  ]);
3028
3028
  (0, react.useEffect)(() => {
3029
- if (agent instanceof _ag_ui_client.HttpAgent) copilotkit.applyHeadersToAgent(agent);
3029
+ if ((0, _copilotkit_core.ɵisHttpAgent)(agent)) copilotkit.applyHeadersToAgent(agent);
3030
3030
  if (agent instanceof _copilotkit_core.ProxiedCopilotRuntimeAgent) agent.credentials = copilotkit.credentials;
3031
3031
  }, [
3032
3032
  agent,
@@ -3319,8 +3319,6 @@ react_markdown = __toESM(react_markdown);
3319
3319
  pendingRef.current = pending;
3320
3320
  const [handlerResult, setHandlerResult] = (0, react.useState)(null);
3321
3321
  const interruptStateRef = (0, react.useRef)(new _copilotkit_core.ɵInterruptState());
3322
- const interruptRunIdsRef = (0, react.useRef)(/* @__PURE__ */ new Map());
3323
- const legacyRunIdRef = (0, react.useRef)(void 0);
3324
3322
  (0, react.useEffect)(() => {
3325
3323
  const interruptState = interruptStateRef.current;
3326
3324
  let localLegacy = null;
@@ -3333,26 +3331,19 @@ react_markdown = __toESM(react_markdown);
3333
3331
  };
3334
3332
  },
3335
3333
  onRunFinishedEvent: (params) => {
3336
- if (params.outcome === "interrupt") {
3337
- const runId = params.input.runId;
3338
- for (const interrupt of params.interrupts) interruptRunIdsRef.current.set(interrupt.id, runId);
3339
- localStandard = params.interrupts;
3340
- }
3334
+ if (params.outcome === "interrupt") localStandard = params.interrupts;
3341
3335
  },
3342
3336
  onRunStartedEvent: () => {
3343
3337
  localLegacy = null;
3344
3338
  localStandard = null;
3345
- interruptRunIdsRef.current.clear();
3346
- legacyRunIdRef.current = void 0;
3347
3339
  interruptState.clear();
3348
3340
  setPending(null);
3349
3341
  },
3350
- onRunFinalized: (params) => {
3342
+ onRunFinalized: () => {
3351
3343
  if (localStandard && localStandard.length > 0) {
3352
3344
  interruptState.setStandard(localStandard);
3353
3345
  setPending(interruptState.pending);
3354
3346
  } else if (localLegacy) {
3355
- legacyRunIdRef.current = params.input.runId;
3356
3347
  interruptState.setLegacy(localLegacy);
3357
3348
  setPending(interruptState.pending);
3358
3349
  }
@@ -3362,8 +3353,6 @@ react_markdown = __toESM(react_markdown);
3362
3353
  onRunFailed: () => {
3363
3354
  localLegacy = null;
3364
3355
  localStandard = null;
3365
- interruptRunIdsRef.current.clear();
3366
- legacyRunIdRef.current = void 0;
3367
3356
  interruptState.clear();
3368
3357
  setPending(null);
3369
3358
  }
@@ -3378,22 +3367,18 @@ react_markdown = __toESM(react_markdown);
3378
3367
  if (!current) return;
3379
3368
  if (current.kind === "standard" && current.interrupts.length > 1 && interruptId === void 0) console.warn(`[CopilotKit] useInterrupt: resolve()/cancel() called without an interruptId while ${current.interrupts.length} interrupts are open; defaulting to the first. Pass an interruptId to address a specific interrupt.`);
3380
3369
  const decision = interruptStateRef.current.resolve(payload, interruptId);
3381
- if (decision.kind === "legacy-resume") {
3382
- const runId = legacyRunIdRef.current;
3383
- try {
3384
- return await copilotkit.runAgent({
3385
- agent,
3386
- ...runId !== void 0 ? { runId } : {},
3387
- forwardedProps: { command: {
3388
- resume: decision.payload,
3389
- interruptEvent: decision.interruptValue
3390
- } }
3391
- });
3392
- } catch (err) {
3393
- console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
3394
- setPending(null);
3395
- throw err;
3396
- }
3370
+ if (decision.kind === "legacy-resume") try {
3371
+ return await copilotkit.runAgent({
3372
+ agent,
3373
+ forwardedProps: { command: {
3374
+ resume: decision.payload,
3375
+ interruptEvent: decision.interruptValue
3376
+ } }
3377
+ });
3378
+ } catch (err) {
3379
+ console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
3380
+ setPending(null);
3381
+ throw err;
3397
3382
  }
3398
3383
  if (decision.kind === "expired") {
3399
3384
  console.error(`[CopilotKit] useInterrupt: interrupt ${decision.interrupt.id} expired at ${decision.interrupt.expiresAt}; not resuming.`);
@@ -3402,7 +3387,6 @@ react_markdown = __toESM(react_markdown);
3402
3387
  return;
3403
3388
  }
3404
3389
  if (decision.kind !== "resume") return;
3405
- const runId = decision.resume.map((entry) => interruptRunIdsRef.current.get(entry.interruptId)).find((candidate) => candidate !== void 0);
3406
3390
  for (const toolResult of decision.toolResults) agent.addMessage({
3407
3391
  id: (0, _ag_ui_client.randomUUID)(),
3408
3392
  role: "tool",
@@ -3412,8 +3396,7 @@ react_markdown = __toESM(react_markdown);
3412
3396
  try {
3413
3397
  return await copilotkit.runAgent({
3414
3398
  agent,
3415
- resume: decision.resume,
3416
- ...runId !== void 0 ? { runId } : {}
3399
+ resume: decision.resume
3417
3400
  });
3418
3401
  } catch (err) {
3419
3402
  console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
@@ -3440,7 +3423,6 @@ react_markdown = __toESM(react_markdown);
3440
3423
  return;
3441
3424
  }
3442
3425
  if (decision.kind !== "resume") return;
3443
- const runId = decision.resume.map((entry) => interruptRunIdsRef.current.get(entry.interruptId)).find((candidate) => candidate !== void 0);
3444
3426
  for (const toolResult of decision.toolResults) agent.addMessage({
3445
3427
  id: (0, _ag_ui_client.randomUUID)(),
3446
3428
  role: "tool",
@@ -3450,8 +3432,7 @@ react_markdown = __toESM(react_markdown);
3450
3432
  try {
3451
3433
  return await copilotkit.runAgent({
3452
3434
  agent,
3453
- resume: decision.resume,
3454
- ...runId !== void 0 ? { runId } : {}
3435
+ resume: decision.resume
3455
3436
  });
3456
3437
  } catch (err) {
3457
3438
  console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
@@ -5758,7 +5739,7 @@ react_markdown = __toESM(react_markdown);
5758
5739
  (0, react.useEffect)(() => {
5759
5740
  let detached = false;
5760
5741
  const connectAbortController = new AbortController();
5761
- if (agent instanceof _ag_ui_client.HttpAgent) agent.abortController = connectAbortController;
5742
+ if ((0, _copilotkit_core.ɵisHttpAgent)(agent)) agent.abortController = connectAbortController;
5762
5743
  const connect = async (agent) => {
5763
5744
  setAgentAvailable(false);
5764
5745
  try {