@copilotkit/react-core 1.67.1 → 1.68.1

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.
@@ -41,6 +41,7 @@ _radix_ui_react_tooltip = __toESM(_radix_ui_react_tooltip);
41
41
  let _radix_ui_react_dropdown_menu = require("@radix-ui/react-dropdown-menu");
42
42
  _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
43
43
  let streamdown = require("streamdown");
44
+ let _copilotkit_react_core_v2_context = require("@copilotkit/react-core/v2/context");
44
45
  let zod = require("zod");
45
46
  let _lit_labs_react = require("@lit-labs/react");
46
47
  let _copilotkit_a2ui_renderer = require("@copilotkit/a2ui-renderer");
@@ -1451,132 +1452,6 @@ function useKatexStyles() {
1451
1452
  }, []);
1452
1453
  }
1453
1454
 
1454
- //#endregion
1455
- //#region src/v2/lib/react-core.ts
1456
- var CopilotKitCoreReact = class extends _copilotkit_core.CopilotKitCore {
1457
- constructor(config) {
1458
- super(config);
1459
- this._renderToolCalls = [];
1460
- this._hookRenderToolCalls = /* @__PURE__ */ new Map();
1461
- this._cachedMergedRenderToolCalls = null;
1462
- this._renderCustomMessages = [];
1463
- this._renderActivityMessages = [];
1464
- this._interruptElement = null;
1465
- this._renderToolCalls = config.renderToolCalls ?? [];
1466
- this._renderCustomMessages = config.renderCustomMessages ?? [];
1467
- this._renderActivityMessages = config.renderActivityMessages ?? [];
1468
- }
1469
- get renderCustomMessages() {
1470
- return this._renderCustomMessages;
1471
- }
1472
- get renderActivityMessages() {
1473
- return this._renderActivityMessages;
1474
- }
1475
- get renderToolCalls() {
1476
- if (this._hookRenderToolCalls.size === 0) return this._renderToolCalls;
1477
- if (this._cachedMergedRenderToolCalls) return this._cachedMergedRenderToolCalls;
1478
- const merged = /* @__PURE__ */ new Map();
1479
- for (const rc of this._renderToolCalls) merged.set(`${rc.agentId ?? ""}:${rc.name}`, rc);
1480
- for (const [key, rc] of this._hookRenderToolCalls) merged.set(key, rc);
1481
- this._cachedMergedRenderToolCalls = Array.from(merged.values());
1482
- return this._cachedMergedRenderToolCalls;
1483
- }
1484
- setRenderActivityMessages(renderers) {
1485
- this._renderActivityMessages = renderers;
1486
- }
1487
- setRenderCustomMessages(renderers) {
1488
- this._renderCustomMessages = renderers;
1489
- }
1490
- setRenderToolCalls(renderToolCalls) {
1491
- this._renderToolCalls = renderToolCalls;
1492
- this._cachedMergedRenderToolCalls = null;
1493
- this._notifyRenderToolCallsChanged();
1494
- }
1495
- addHookRenderToolCall(entry) {
1496
- const key = `${entry.agentId ?? ""}:${entry.name}`;
1497
- this._hookRenderToolCalls.set(key, entry);
1498
- this._cachedMergedRenderToolCalls = null;
1499
- this._notifyRenderToolCallsChanged();
1500
- }
1501
- removeHookRenderToolCall(name, agentId) {
1502
- const key = `${agentId ?? ""}:${name}`;
1503
- if (this._hookRenderToolCalls.delete(key)) {
1504
- this._cachedMergedRenderToolCalls = null;
1505
- this._notifyRenderToolCallsChanged();
1506
- }
1507
- }
1508
- _notifyRenderToolCallsChanged() {
1509
- this.notifySubscribers((subscriber) => {
1510
- const reactSubscriber = subscriber;
1511
- if (reactSubscriber.onRenderToolCallsChanged) reactSubscriber.onRenderToolCallsChanged({
1512
- copilotkit: this,
1513
- renderToolCalls: this.renderToolCalls
1514
- });
1515
- }, "Subscriber onRenderToolCallsChanged error:");
1516
- }
1517
- get interruptElement() {
1518
- return this._interruptElement;
1519
- }
1520
- setInterruptElement(element) {
1521
- this._interruptElement = element;
1522
- this.notifySubscribers((subscriber) => {
1523
- subscriber.onInterruptElementChanged?.({
1524
- copilotkit: this,
1525
- interruptElement: this._interruptElement
1526
- });
1527
- }, "Subscriber onInterruptElementChanged error:");
1528
- }
1529
- subscribe(subscriber) {
1530
- return super.subscribe(subscriber);
1531
- }
1532
- /**
1533
- * Wait for pending React state updates before the follow-up agent run.
1534
- *
1535
- * When a frontend tool handler calls setState(), React 18 batches the update
1536
- * and schedules a commit via its internal scheduler (MessageChannel). The
1537
- * useAgentContext hook registers context via useLayoutEffect, which runs
1538
- * synchronously after React commits that batch.
1539
- *
1540
- * Awaiting a zero-delay timeout yields to the macrotask queue. React's
1541
- * MessageChannel task runs first, committing the pending state and running
1542
- * useLayoutEffect (which updates the context store). The follow-up runAgent
1543
- * call then reads fresh context.
1544
- */
1545
- async waitForPendingFrameworkUpdates() {
1546
- await new Promise((resolve) => setTimeout(resolve, 0));
1547
- }
1548
- };
1549
-
1550
- //#endregion
1551
- //#region src/v2/context.ts
1552
- const CopilotKitContext = (0, react.createContext)(null);
1553
- const useCopilotKit = () => {
1554
- const context = (0, react.useContext)(CopilotKitContext);
1555
- const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
1556
- if (!context) throw new Error("useCopilotKit must be used within CopilotKitProvider");
1557
- (0, react.useEffect)(() => {
1558
- const subscription = context.copilotkit.subscribe({
1559
- onRuntimeConnectionStatusChanged: () => {
1560
- forceUpdate();
1561
- },
1562
- onHeadersChanged: () => {
1563
- forceUpdate();
1564
- }
1565
- });
1566
- return () => {
1567
- subscription.unsubscribe();
1568
- };
1569
- }, []);
1570
- return context;
1571
- };
1572
- const LicenseContext = (0, react.createContext)({
1573
- status: null,
1574
- license: null,
1575
- checkFeature: () => true,
1576
- getLimit: () => null
1577
- });
1578
- const useLicenseContext = () => (0, react.useContext)(LicenseContext);
1579
-
1580
1455
  //#endregion
1581
1456
  //#region src/v2/hooks/use-render-tool-call.tsx
1582
1457
  /**
@@ -1624,7 +1499,7 @@ const ToolCallRenderer = react.default.memo(function ToolCallRenderer({ toolCall
1624
1499
  * @returns A function that takes a tool call and optional tool message and returns the rendered component
1625
1500
  */
1626
1501
  function useRenderToolCall() {
1627
- const { copilotkit, executingToolCallIds } = useCopilotKit();
1502
+ const { copilotkit, executingToolCallIds } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
1628
1503
  const agentId = useCopilotChatConfiguration()?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
1629
1504
  const renderToolCalls = (0, react.useSyncExternalStore)((callback) => {
1630
1505
  return copilotkit.subscribe({ onRenderToolCallsChanged: callback }).unsubscribe;
@@ -2002,7 +1877,7 @@ function isNotification(msg) {
2002
1877
  * Fetches resource content on-demand via proxied MCP requests.
2003
1878
  */
2004
1879
  const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agent }) {
2005
- const { copilotkit } = useCopilotKit();
1880
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
2006
1881
  const containerRef = (0, react.useRef)(null);
2007
1882
  const iframeRef = (0, react.useRef)(null);
2008
1883
  const [iframeReady, setIframeReady] = (0, react.useState)(false);
@@ -3174,7 +3049,7 @@ function createA2UIMessageRenderer(options) {
3174
3049
  render: ({ content, agent }) => {
3175
3050
  ensureInitialized();
3176
3051
  const [operations, setOperations] = (0, react.useState)([]);
3177
- const { copilotkit } = useCopilotKit();
3052
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
3178
3053
  const lastContentRef = (0, react.useRef)(null);
3179
3054
  (0, react.useEffect)(() => {
3180
3055
  if (content === lastContentRef.current) return;
@@ -3418,7 +3293,7 @@ const RENDER_A2UI_TOOL_NAME = "render_a2ui";
3418
3293
  * (hook-based entries take priority over this prop-based registration).
3419
3294
  */
3420
3295
  function A2UIBuiltInToolCallRenderer() {
3421
- const { copilotkit } = useCopilotKit();
3296
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
3422
3297
  (0, react.useEffect)(() => {
3423
3298
  const renderer = defineToolCallRenderer({
3424
3299
  name: RENDER_A2UI_TOOL_NAME,
@@ -3446,7 +3321,7 @@ function A2UIBuiltInToolCallRenderer() {
3446
3321
  * middleware can optionally overwrite it with a server-side schema.
3447
3322
  */
3448
3323
  function A2UICatalogContext({ catalog, includeSchema }) {
3449
- const { copilotkit } = useCopilotKit();
3324
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
3450
3325
  const capabilitiesValue = (0, react.useMemo)(() => (0, _copilotkit_a2ui_renderer.buildCatalogContextValue)(catalog), [catalog]);
3451
3326
  const schemaValue = (0, react.useMemo)(() => includeSchema !== false ? JSON.stringify((0, _copilotkit_a2ui_renderer.extractCatalogComponentSchemas)(catalog)) : null, [catalog, includeSchema]);
3452
3327
  const a2uiAgentsKey = copilotkit?.a2uiAgents?.join(",");
@@ -3489,6 +3364,102 @@ function A2UICatalogContext({ catalog, includeSchema }) {
3489
3364
  return null;
3490
3365
  }
3491
3366
 
3367
+ //#endregion
3368
+ //#region src/v2/lib/react-core.ts
3369
+ var CopilotKitCoreReact = class extends _copilotkit_core.CopilotKitCore {
3370
+ constructor(config) {
3371
+ super(config);
3372
+ this._renderToolCalls = [];
3373
+ this._hookRenderToolCalls = /* @__PURE__ */ new Map();
3374
+ this._cachedMergedRenderToolCalls = null;
3375
+ this._renderCustomMessages = [];
3376
+ this._renderActivityMessages = [];
3377
+ this._interruptElement = null;
3378
+ this._renderToolCalls = config.renderToolCalls ?? [];
3379
+ this._renderCustomMessages = config.renderCustomMessages ?? [];
3380
+ this._renderActivityMessages = config.renderActivityMessages ?? [];
3381
+ }
3382
+ get renderCustomMessages() {
3383
+ return this._renderCustomMessages;
3384
+ }
3385
+ get renderActivityMessages() {
3386
+ return this._renderActivityMessages;
3387
+ }
3388
+ get renderToolCalls() {
3389
+ if (this._hookRenderToolCalls.size === 0) return this._renderToolCalls;
3390
+ if (this._cachedMergedRenderToolCalls) return this._cachedMergedRenderToolCalls;
3391
+ const merged = /* @__PURE__ */ new Map();
3392
+ for (const rc of this._renderToolCalls) merged.set(`${rc.agentId ?? ""}:${rc.name}`, rc);
3393
+ for (const [key, rc] of this._hookRenderToolCalls) merged.set(key, rc);
3394
+ this._cachedMergedRenderToolCalls = Array.from(merged.values());
3395
+ return this._cachedMergedRenderToolCalls;
3396
+ }
3397
+ setRenderActivityMessages(renderers) {
3398
+ this._renderActivityMessages = renderers;
3399
+ }
3400
+ setRenderCustomMessages(renderers) {
3401
+ this._renderCustomMessages = renderers;
3402
+ }
3403
+ setRenderToolCalls(renderToolCalls) {
3404
+ this._renderToolCalls = renderToolCalls;
3405
+ this._cachedMergedRenderToolCalls = null;
3406
+ this._notifyRenderToolCallsChanged();
3407
+ }
3408
+ addHookRenderToolCall(entry) {
3409
+ const key = `${entry.agentId ?? ""}:${entry.name}`;
3410
+ this._hookRenderToolCalls.set(key, entry);
3411
+ this._cachedMergedRenderToolCalls = null;
3412
+ this._notifyRenderToolCallsChanged();
3413
+ }
3414
+ removeHookRenderToolCall(name, agentId) {
3415
+ const key = `${agentId ?? ""}:${name}`;
3416
+ if (this._hookRenderToolCalls.delete(key)) {
3417
+ this._cachedMergedRenderToolCalls = null;
3418
+ this._notifyRenderToolCallsChanged();
3419
+ }
3420
+ }
3421
+ _notifyRenderToolCallsChanged() {
3422
+ this.notifySubscribers((subscriber) => {
3423
+ const reactSubscriber = subscriber;
3424
+ if (reactSubscriber.onRenderToolCallsChanged) reactSubscriber.onRenderToolCallsChanged({
3425
+ copilotkit: this,
3426
+ renderToolCalls: this.renderToolCalls
3427
+ });
3428
+ }, "Subscriber onRenderToolCallsChanged error:");
3429
+ }
3430
+ get interruptElement() {
3431
+ return this._interruptElement;
3432
+ }
3433
+ setInterruptElement(element) {
3434
+ this._interruptElement = element;
3435
+ this.notifySubscribers((subscriber) => {
3436
+ subscriber.onInterruptElementChanged?.({
3437
+ copilotkit: this,
3438
+ interruptElement: this._interruptElement
3439
+ });
3440
+ }, "Subscriber onInterruptElementChanged error:");
3441
+ }
3442
+ subscribe(subscriber) {
3443
+ return super.subscribe(subscriber);
3444
+ }
3445
+ /**
3446
+ * Wait for pending React state updates before the follow-up agent run.
3447
+ *
3448
+ * When a frontend tool handler calls setState(), React 18 batches the update
3449
+ * and schedules a commit via its internal scheduler (MessageChannel). The
3450
+ * useAgentContext hook registers context via useLayoutEffect, which runs
3451
+ * synchronously after React commits that batch.
3452
+ *
3453
+ * Awaiting a zero-delay timeout yields to the macrotask queue. React's
3454
+ * MessageChannel task runs first, committing the pending state and running
3455
+ * useLayoutEffect (which updates the context store). The follow-up runAgent
3456
+ * call then reads fresh context.
3457
+ */
3458
+ async waitForPendingFrameworkUpdates() {
3459
+ await new Promise((resolve) => setTimeout(resolve, 0));
3460
+ }
3461
+ };
3462
+
3492
3463
  //#endregion
3493
3464
  //#region src/v2/providers/CopilotKitProvider.tsx
3494
3465
  const zodToJsonSchemaAdapter = (schema, options) => {
@@ -3862,9 +3833,9 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3862
3833
  const licenseContextValue = (0, react.useMemo)(() => (0, _copilotkit_shared.createLicenseContextValue)(runtimeLicenseStatus), [runtimeLicenseStatus]);
3863
3834
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SandboxFunctionsContext.Provider, {
3864
3835
  value: sandboxFunctionsList,
3865
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitContext.Provider, {
3836
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_v2_context.CopilotKitContext.Provider, {
3866
3837
  value: contextValue,
3867
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(LicenseContext.Provider, {
3838
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_copilotkit_react_core_v2_context.LicenseContext.Provider, {
3868
3839
  value: licenseContextValue,
3869
3840
  children: [
3870
3841
  a2uiActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(A2UIBuiltInToolCallRenderer, {}),
@@ -3890,7 +3861,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3890
3861
  //#endregion
3891
3862
  //#region src/v2/hooks/use-render-custom-messages.tsx
3892
3863
  function useRenderCustomMessages() {
3893
- const { copilotkit } = useCopilotKit();
3864
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
3894
3865
  const config = useCopilotChatConfiguration();
3895
3866
  if (!config) return null;
3896
3867
  const { agentId, threadId } = config;
@@ -3935,7 +3906,7 @@ function useRenderCustomMessages() {
3935
3906
  //#endregion
3936
3907
  //#region src/v2/hooks/use-render-activity-message.tsx
3937
3908
  function useRenderActivityMessage() {
3938
- const { copilotkit } = useCopilotKit();
3909
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
3939
3910
  const agentId = useCopilotChatConfiguration()?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
3940
3911
  const renderers = copilotkit.renderActivityMessages;
3941
3912
  const findRenderer = (0, react.useCallback)((activityType) => {
@@ -3978,7 +3949,7 @@ function useRenderActivityMessage() {
3978
3949
  //#region src/v2/hooks/use-frontend-tool.tsx
3979
3950
  const EMPTY_DEPS$1 = [];
3980
3951
  function useFrontendTool(tool, deps) {
3981
- const { copilotkit } = useCopilotKit();
3952
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
3982
3953
  const extraDeps = deps ?? EMPTY_DEPS$1;
3983
3954
  (0, react.useEffect)(() => {
3984
3955
  const name = tool.name;
@@ -4120,7 +4091,7 @@ const EMPTY_DEPS = [];
4120
4091
  * ```
4121
4092
  */
4122
4093
  function useRenderTool(config, deps) {
4123
- const { copilotkit } = useCopilotKit();
4094
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
4124
4095
  const extraDeps = deps ?? EMPTY_DEPS;
4125
4096
  (0, react.useEffect)(() => {
4126
4097
  const renderer = config.name === "*" && !config.parameters ? defineToolCallRenderer({
@@ -4348,7 +4319,7 @@ function safeStringifyForAttr(value) {
4348
4319
  //#endregion
4349
4320
  //#region src/v2/hooks/use-human-in-the-loop.tsx
4350
4321
  function useHumanInTheLoop(tool, deps) {
4351
- const { copilotkit } = useCopilotKit();
4322
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
4352
4323
  const resolvePromiseRef = (0, react.useRef)(null);
4353
4324
  const cleanupAbortRef = (0, react.useRef)(null);
4354
4325
  const respond = (0, react.useCallback)(async (result) => {
@@ -4453,7 +4424,7 @@ function useAgent({ agentId, threadId, runtimeAgentId, updates, throttleMs } = {
4453
4424
  if (runtimeAgentId != null && agentId == null) throw new Error(`useAgent: \`runtimeAgentId\` requires an explicit \`agentId\`. The proxied agent is registered under \`agentId\`, and the usual fallbacks (chat configuration, then "${_copilotkit_shared.DEFAULT_AGENT_ID}") name agents that already exist — registering over one throws or shadows it. Pick a local id for this hook, e.g. useAgent({ agentId: "chat-1", runtimeAgentId: "${runtimeAgentId}", threadId }).`);
4454
4425
  const chatConfig = useCopilotChatConfiguration();
4455
4426
  const resolvedAgentId = agentId ?? chatConfig?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
4456
- const { copilotkit } = useCopilotKit();
4427
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
4457
4428
  const providerThrottleMs = copilotkit.defaultThrottleMs;
4458
4429
  const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
4459
4430
  const updateFlags = (0, react.useMemo)(() => updates ?? ALL_UPDATES, [JSON.stringify(updates)]);
@@ -4654,7 +4625,7 @@ function useCapabilities(agentId) {
4654
4625
  //#region src/v2/hooks/use-agent-context.tsx
4655
4626
  function useAgentContext(context) {
4656
4627
  const { description, value } = context;
4657
- const { copilotkit } = useCopilotKit();
4628
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
4658
4629
  const stringValue = (0, react.useMemo)(() => {
4659
4630
  if (typeof value === "string") return value;
4660
4631
  return JSON.stringify(value);
@@ -4678,7 +4649,7 @@ function useAgentContext(context) {
4678
4649
  //#endregion
4679
4650
  //#region src/v2/hooks/use-suggestions.tsx
4680
4651
  function useSuggestions({ agentId } = {}) {
4681
- const { copilotkit } = useCopilotKit();
4652
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
4682
4653
  const config = useCopilotChatConfiguration();
4683
4654
  const resolvedAgentId = (0, react.useMemo)(() => agentId ?? config?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID, [agentId, config?.agentId]);
4684
4655
  const [suggestions, setSuggestions] = (0, react.useState)(() => {
@@ -4731,7 +4702,7 @@ function useSuggestions({ agentId } = {}) {
4731
4702
  //#endregion
4732
4703
  //#region src/v2/hooks/use-configure-suggestions.tsx
4733
4704
  function useConfigureSuggestions(config, deps) {
4734
- const { copilotkit } = useCopilotKit();
4705
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
4735
4706
  const chatConfig = useCopilotChatConfiguration();
4736
4707
  const extraDeps = deps ?? [];
4737
4708
  const resolvedConsumerAgentId = (0, react.useMemo)(() => chatConfig?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID, [chatConfig?.agentId]);
@@ -4929,7 +4900,7 @@ function toLegacyEvent(pending) {
4929
4900
  * ```
4930
4901
  */
4931
4902
  function useInterrupt(config) {
4932
- const { copilotkit } = useCopilotKit();
4903
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
4933
4904
  const { agent } = useAgent({ agentId: config.agentId });
4934
4905
  const [pending, setPending] = (0, react.useState)(null);
4935
4906
  const pendingRef = (0, react.useRef)(pending);
@@ -5225,7 +5196,7 @@ function useThreadStoreSelector(store, selector) {
5225
5196
  * ```
5226
5197
  */
5227
5198
  function useThreads$1({ agentId, includeArchived, limit, enabled = true }) {
5228
- const { copilotkit } = useCopilotKit();
5199
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
5229
5200
  const [store] = (0, react.useState)(() => (0, _copilotkit_core.ɵcreateThreadStore)({ fetch: globalThis.fetch }));
5230
5201
  const coreThreads = useThreadStoreSelector(store, _copilotkit_core.ɵselectThreads);
5231
5202
  const threads = (0, react.useMemo)(() => coreThreads.map(({ id, agentId, name, archived, createdAt, updatedAt, lastRunAt }) => ({
@@ -5411,7 +5382,7 @@ function useMemoryStoreSelector(store, selector) {
5411
5382
  * ```
5412
5383
  */
5413
5384
  function useMemories() {
5414
- const { copilotkit } = useCopilotKit();
5385
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
5415
5386
  const store = copilotkit.getMemoryStore();
5416
5387
  return {
5417
5388
  memories: useMemoryStoreSelector(store, _copilotkit_core.ɵselectMemories),
@@ -5432,8 +5403,8 @@ function useMemories() {
5432
5403
  * Low-level function that posts an arbitrary annotation to the CopilotKit
5433
5404
  * runtime's general annotation endpoint (`POST /annotate`).
5434
5405
  *
5435
- * This is the single transport entry point for all annotation types. Higher-
5436
- * level hooks (e.g. `useLearnFromUserAction`) build the `type`/`payload` pair
5406
+ * This is the single transport entry point for annotations. Higher-level
5407
+ * hooks such as `useLearnFromUserAction` build the `type`/`payload` pair
5437
5408
  * for their specific annotation shape and delegate the HTTP call here.
5438
5409
  *
5439
5410
  * The function uses the same transport as `useLearnFromUserAction`:
@@ -5518,7 +5489,7 @@ async function recordAnnotation(args) {
5518
5489
  * ```
5519
5490
  */
5520
5491
  function useLearnFromUserAction() {
5521
- const { copilotkit } = useCopilotKit();
5492
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
5522
5493
  return (0, react.useCallback)(async (input) => {
5523
5494
  const runtimeUrl = copilotkit.runtimeUrl;
5524
5495
  if (!runtimeUrl) throw new Error("useLearnFromUserAction: runtimeUrl is not configured. Set it on <CopilotKitProvider runtimeUrl=...>.");
@@ -5758,7 +5729,8 @@ function useAttachments({ config }) {
5758
5729
  /** The default learning containers value. Matches the backend default. */
5759
5730
  const DEFAULT_CONTAINERS = ["project"];
5760
5731
  /**
5761
- * Declaratively keeps a thread's learning containers in sync by emitting
5732
+ * Legacy compatibility hook that keeps a thread's plural learning-container
5733
+ * annotation in sync by emitting
5762
5734
  * `set_learning_containers` annotations via the CopilotKit runtime annotate
5763
5735
  * endpoint (`POST ${runtimeUrl}/annotate`).
5764
5736
  *
@@ -5788,9 +5760,13 @@ const DEFAULT_CONTAINERS = ["project"];
5788
5760
  * // ...
5789
5761
  * }
5790
5762
  * ```
5763
+ *
5764
+ * @deprecated Legacy plural-container annotation compatibility only. New
5765
+ * Intelligence runtimes assign one container with `ɵlearning.containerId` on
5766
+ * `CopilotRuntime`.
5791
5767
  */
5792
5768
  function useLearningContainers({ threadId, learningContainers }) {
5793
- const { copilotkit } = useCopilotKit();
5769
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
5794
5770
  /**
5795
5771
  * Tracks the last-synced container list so content-identical rerenders
5796
5772
  * (fresh array, same values) do not fire a redundant emit.
@@ -5865,8 +5841,8 @@ function useLearningContainers({ threadId, learningContainers }) {
5865
5841
  //#endregion
5866
5842
  //#region src/v2/hooks/use-learning-containers-in-current-thread.tsx
5867
5843
  /**
5868
- * Declaratively keeps the **current chat thread's** learning containers in
5869
- * sync. The `threadId` is sourced from the surrounding
5844
+ * Legacy compatibility hook that keeps the **current chat thread's** plural
5845
+ * learning-container annotation in sync. The `threadId` is sourced from the surrounding
5870
5846
  * `<CopilotChatConfigurationProvider>` (the same provider `<CopilotChat>`,
5871
5847
  * `<CopilotSidebar>`, and friends set up), so callers in a chat-aware
5872
5848
  * subtree don't need to thread an id through manually.
@@ -5890,6 +5866,10 @@ function useLearningContainers({ threadId, learningContainers }) {
5890
5866
  * // ...
5891
5867
  * }
5892
5868
  * ```
5869
+ *
5870
+ * @deprecated Legacy plural-container annotation compatibility only. New
5871
+ * Intelligence runtimes assign one container with `ɵlearning.containerId` on
5872
+ * `CopilotRuntime`.
5893
5873
  */
5894
5874
  function useLearningContainersInCurrentThread({ learningContainers }) {
5895
5875
  const threadId = useCopilotChatConfiguration()?.threadId;
@@ -6899,7 +6879,7 @@ const isToolCallLikeMessage = (m) => {
6899
6879
  */
6900
6880
  function IntelligenceIndicator(props) {
6901
6881
  const { message, agentId, label = "CopilotKit Intelligence", intelligenceIndicator } = props;
6902
- const { copilotkit } = useCopilotKit();
6882
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
6903
6883
  const config = useCopilotChatConfiguration();
6904
6884
  const { agent } = useAgent({
6905
6885
  agentId,
@@ -7139,7 +7119,7 @@ const VIRTUALIZE_THRESHOLD = 50;
7139
7119
  function CopilotChatMessageView({ messages = [], assistantMessage, userMessage, reasoningMessage, cursor, intelligenceIndicator, isRunning = false, children, className, ...props }) {
7140
7120
  const renderCustomMessage = useRenderCustomMessages();
7141
7121
  const { renderActivityMessage } = useRenderActivityMessage();
7142
- const { copilotkit } = useCopilotKit();
7122
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
7143
7123
  const config = useCopilotChatConfiguration();
7144
7124
  const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
7145
7125
  (0, react.useEffect)(() => {
@@ -8185,9 +8165,9 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
8185
8165
  agentId: resolvedAgentId,
8186
8166
  throttleMs
8187
8167
  });
8188
- const { copilotkit } = useCopilotKit();
8168
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
8189
8169
  const { suggestions: autoSuggestions } = useSuggestions({ agentId: resolvedAgentId });
8190
- const { checkFeature } = useLicenseContext();
8170
+ const { checkFeature } = (0, _copilotkit_react_core_v2_context.useLicenseContext)();
8191
8171
  const isChatLicensed = checkFeature("chat");
8192
8172
  (0, react.useEffect)(() => {
8193
8173
  if (!isChatLicensed) console.warn("[CopilotKit] Warning: \"chat\" feature is not licensed. Visit copilotkit.ai/pricing");
@@ -9194,7 +9174,7 @@ var CopilotPopupView_default = CopilotPopupView;
9194
9174
  //#endregion
9195
9175
  //#region src/v2/components/chat/CopilotSidebar.tsx
9196
9176
  function CopilotSidebar({ header, toggleButton, defaultOpen, width, position, ...chatProps }) {
9197
- const { checkFeature } = useLicenseContext();
9177
+ const { checkFeature } = (0, _copilotkit_react_core_v2_context.useLicenseContext)();
9198
9178
  const isSidebarLicensed = checkFeature("sidebar");
9199
9179
  (0, react.useEffect)(() => {
9200
9180
  if (!isSidebarLicensed) console.warn("[CopilotKit] Warning: \"sidebar\" feature is not licensed. Visit copilotkit.ai/pricing");
@@ -9246,7 +9226,7 @@ const PopupViewOverride = (viewProps) => {
9246
9226
  };
9247
9227
  const PopupViewOverrideWithStatics = Object.assign(PopupViewOverride, CopilotChatView_default);
9248
9228
  function CopilotPopup({ header, toggleButton, defaultOpen, width, height, clickOutsideToClose, ...chatProps }) {
9249
- const { checkFeature } = useLicenseContext();
9229
+ const { checkFeature } = (0, _copilotkit_react_core_v2_context.useLicenseContext)();
9250
9230
  const isPopupLicensed = checkFeature("popup");
9251
9231
  (0, react.useEffect)(() => {
9252
9232
  if (!isPopupLicensed) console.warn("[CopilotKit] Warning: \"popup\" feature is not licensed. Visit copilotkit.ai/pricing");
@@ -9362,7 +9342,7 @@ function findChatInput(origin) {
9362
9342
  */
9363
9343
  function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed, licenseUrl, renderRow, label, recentLabel, collapsible, onCollapseChange, limit, "data-testid": dataTestId = "copilot-threads-drawer" }) {
9364
9344
  const configuration = useCopilotChatConfiguration();
9365
- const { status, checkFeature } = useLicenseContext();
9345
+ const { status, checkFeature } = (0, _copilotkit_react_core_v2_context.useLicenseContext)();
9366
9346
  const licensePresent = status === "valid" || status === "expiring";
9367
9347
  const featureLicensed = checkFeature("threads");
9368
9348
  const licensed = licensePresent && featureLicensed;
@@ -11261,7 +11241,7 @@ const usePredictStateSubscription = (agent) => {
11261
11241
  }, [agent, getSubscriber]);
11262
11242
  };
11263
11243
  function CopilotListenersAgentSubscription() {
11264
- const { copilotkit } = useCopilotKit();
11244
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
11265
11245
  const configAgentId = useCopilotChatConfiguration()?.agentId;
11266
11246
  const { agent } = useAgent({ agentId: (0, react.useMemo)(() => {
11267
11247
  const requested = configAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
@@ -11277,7 +11257,7 @@ function CopilotListenersAgentSubscription() {
11277
11257
  return null;
11278
11258
  }
11279
11259
  function CopilotListeners() {
11280
- const { copilotkit } = useCopilotKit();
11260
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
11281
11261
  const { setBannerError } = useToast();
11282
11262
  const hasAgents = Object.keys(copilotkit.agents ?? {}).length > 0;
11283
11263
  const hasRuntime = copilotkit.runtimeUrl !== void 0;
@@ -11341,7 +11321,7 @@ function CopilotKit({ children, ...props }) {
11341
11321
  * Chat components are rendered.
11342
11322
  */
11343
11323
  function CopilotKitErrorBridge() {
11344
- const { copilotkit } = useCopilotKit();
11324
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
11345
11325
  const { onError, copilotApiConfig } = useCopilotContext();
11346
11326
  (0, react.useEffect)(() => {
11347
11327
  if (!copilotkit) return;
@@ -12195,12 +12175,6 @@ Object.defineProperty(exports, 'useCopilotContext', {
12195
12175
  return useCopilotContext;
12196
12176
  }
12197
12177
  });
12198
- Object.defineProperty(exports, 'useCopilotKit', {
12199
- enumerable: true,
12200
- get: function () {
12201
- return useCopilotKit;
12202
- }
12203
- });
12204
12178
  Object.defineProperty(exports, 'useCopilotMessagesContext', {
12205
12179
  enumerable: true,
12206
12180
  get: function () {
@@ -12321,4 +12295,4 @@ Object.defineProperty(exports, 'ɵrunMcpFollowUp', {
12321
12295
  return ɵrunMcpFollowUp;
12322
12296
  }
12323
12297
  });
12324
- //# sourceMappingURL=copilotkit-CmMYFfLV.cjs.map
12298
+ //# sourceMappingURL=copilotkit-8KSSmCH_.cjs.map