@copilotkit/react-core 1.70.3 → 1.71.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.
Files changed (60) hide show
  1. package/dist/{copilotkit-BU3OvveB.cjs → copilotkit-BkVEkUS0.cjs} +369 -154
  2. package/dist/copilotkit-BkVEkUS0.cjs.map +1 -0
  3. package/dist/{copilotkit-Bs98akp9.d.mts → copilotkit-ChjzWqn6.d.mts} +33 -8
  4. package/dist/copilotkit-ChjzWqn6.d.mts.map +1 -0
  5. package/dist/{copilotkit-Ap_yisA5.mjs → copilotkit-D5BTo0YG.mjs} +368 -153
  6. package/dist/copilotkit-D5BTo0YG.mjs.map +1 -0
  7. package/dist/{copilotkit-X2eGbOwf.d.cts → copilotkit-DCIXZawe.d.cts} +33 -8
  8. package/dist/copilotkit-DCIXZawe.d.cts.map +1 -0
  9. package/dist/index.cjs +3 -3
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +1 -1
  12. package/dist/index.d.mts +1 -1
  13. package/dist/index.mjs +4 -4
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/index.umd.js +180 -139
  16. package/dist/index.umd.js.map +1 -1
  17. package/dist/v2/context.cjs +4 -0
  18. package/dist/v2/context.cjs.map +1 -1
  19. package/dist/v2/context.d.cts +3 -1
  20. package/dist/v2/context.d.cts.map +1 -1
  21. package/dist/v2/context.d.mts +3 -1
  22. package/dist/v2/context.d.mts.map +1 -1
  23. package/dist/v2/context.mjs +3 -1
  24. package/dist/v2/context.mjs.map +1 -1
  25. package/dist/v2/headless.cjs +20 -5
  26. package/dist/v2/headless.cjs.map +1 -1
  27. package/dist/v2/headless.d.cts +9 -4
  28. package/dist/v2/headless.d.cts.map +1 -1
  29. package/dist/v2/headless.d.mts +9 -4
  30. package/dist/v2/headless.d.mts.map +1 -1
  31. package/dist/v2/headless.mjs +21 -6
  32. package/dist/v2/headless.mjs.map +1 -1
  33. package/dist/v2/index.cjs +1 -1
  34. package/dist/v2/index.css +1 -1
  35. package/dist/v2/index.d.cts +1 -1
  36. package/dist/v2/index.d.mts +1 -1
  37. package/dist/v2/index.mjs +1 -1
  38. package/dist/v2/index.umd.js +495 -278
  39. package/dist/v2/index.umd.js.map +1 -1
  40. package/package.json +8 -9
  41. package/dist/copilotkit-Ap_yisA5.mjs.map +0 -1
  42. package/dist/copilotkit-BU3OvveB.cjs.map +0 -1
  43. package/dist/copilotkit-Bs98akp9.d.mts.map +0 -1
  44. package/dist/copilotkit-X2eGbOwf.d.cts.map +0 -1
  45. package/skills/react-core/SKILL.md +0 -110
  46. package/skills/react-core/references/agent-access.md +0 -355
  47. package/skills/react-core/references/attachments.md +0 -311
  48. package/skills/react-core/references/capabilities.md +0 -138
  49. package/skills/react-core/references/chat-components.md +0 -229
  50. package/skills/react-core/references/client-side-tools.md +0 -358
  51. package/skills/react-core/references/custom-message-renderers.md +0 -223
  52. package/skills/react-core/references/debug-mode.md +0 -140
  53. package/skills/react-core/references/human-in-the-loop.md +0 -312
  54. package/skills/react-core/references/provider-setup.md +0 -358
  55. package/skills/react-core/references/rendering-activity-messages.md +0 -201
  56. package/skills/react-core/references/rendering-tool-calls.md +0 -319
  57. package/skills/react-core/references/suggestions.md +0 -211
  58. package/skills/react-core/references/switching-agents-recipes.md +0 -161
  59. package/skills/react-core/references/switching-agents.md +0 -240
  60. package/skills/react-core/references/threads.md +0 -289
package/dist/index.umd.js CHANGED
@@ -36,6 +36,133 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
36
36
  react = __toESM(react);
37
37
  react_markdown = __toESM(react_markdown);
38
38
 
39
+ //#region src/v2/lib/react-core.ts
40
+ var CopilotKitCoreReact = class extends _copilotkit_core.CopilotKitCore {
41
+ constructor(config) {
42
+ super(config);
43
+ this._renderToolCalls = [];
44
+ this._hookRenderToolCalls = /* @__PURE__ */ new Map();
45
+ this._cachedMergedRenderToolCalls = null;
46
+ this._renderCustomMessages = [];
47
+ this._renderActivityMessages = [];
48
+ this._interruptElement = null;
49
+ this._renderToolCalls = config.renderToolCalls ?? [];
50
+ this._renderCustomMessages = config.renderCustomMessages ?? [];
51
+ this._renderActivityMessages = config.renderActivityMessages ?? [];
52
+ }
53
+ get renderCustomMessages() {
54
+ return this._renderCustomMessages;
55
+ }
56
+ get renderActivityMessages() {
57
+ return this._renderActivityMessages;
58
+ }
59
+ get renderToolCalls() {
60
+ if (this._hookRenderToolCalls.size === 0) return this._renderToolCalls;
61
+ if (this._cachedMergedRenderToolCalls) return this._cachedMergedRenderToolCalls;
62
+ const merged = /* @__PURE__ */ new Map();
63
+ for (const rc of this._renderToolCalls) merged.set(`${rc.agentId ?? ""}:${rc.name}`, rc);
64
+ for (const [key, rc] of this._hookRenderToolCalls) merged.set(key, rc);
65
+ this._cachedMergedRenderToolCalls = Array.from(merged.values());
66
+ return this._cachedMergedRenderToolCalls;
67
+ }
68
+ setRenderActivityMessages(renderers) {
69
+ this._renderActivityMessages = renderers;
70
+ }
71
+ setRenderCustomMessages(renderers) {
72
+ this._renderCustomMessages = renderers;
73
+ }
74
+ setRenderToolCalls(renderToolCalls) {
75
+ this._renderToolCalls = renderToolCalls;
76
+ this._cachedMergedRenderToolCalls = null;
77
+ this._notifyRenderToolCallsChanged();
78
+ }
79
+ addHookRenderToolCall(entry) {
80
+ const key = `${entry.agentId ?? ""}:${entry.name}`;
81
+ this._hookRenderToolCalls.set(key, entry);
82
+ this._cachedMergedRenderToolCalls = null;
83
+ this._notifyRenderToolCallsChanged();
84
+ }
85
+ removeHookRenderToolCall(name, agentId) {
86
+ const key = `${agentId ?? ""}:${name}`;
87
+ if (this._hookRenderToolCalls.delete(key)) {
88
+ this._cachedMergedRenderToolCalls = null;
89
+ this._notifyRenderToolCallsChanged();
90
+ }
91
+ }
92
+ _notifyRenderToolCallsChanged() {
93
+ this.notifySubscribers((subscriber) => {
94
+ const reactSubscriber = subscriber;
95
+ if (reactSubscriber.onRenderToolCallsChanged) reactSubscriber.onRenderToolCallsChanged({
96
+ copilotkit: this,
97
+ renderToolCalls: this.renderToolCalls
98
+ });
99
+ }, "Subscriber onRenderToolCallsChanged error:");
100
+ }
101
+ get interruptElement() {
102
+ return this._interruptElement;
103
+ }
104
+ setInterruptElement(element) {
105
+ this._interruptElement = element;
106
+ this.notifySubscribers((subscriber) => {
107
+ subscriber.onInterruptElementChanged?.({
108
+ copilotkit: this,
109
+ interruptElement: this._interruptElement
110
+ });
111
+ }, "Subscriber onInterruptElementChanged error:");
112
+ }
113
+ subscribe(subscriber) {
114
+ return super.subscribe(subscriber);
115
+ }
116
+ /**
117
+ * Wait for pending React state updates before the follow-up agent run.
118
+ *
119
+ * When a frontend tool handler calls setState(), React 18 batches the update
120
+ * and schedules a commit via its internal scheduler (MessageChannel). The
121
+ * useAgentContext hook registers context via useLayoutEffect, which runs
122
+ * synchronously after React commits that batch.
123
+ *
124
+ * Awaiting a zero-delay timeout yields to the macrotask queue. React's
125
+ * MessageChannel task runs first, committing the pending state and running
126
+ * useLayoutEffect (which updates the context store). The follow-up runAgent
127
+ * call then reads fresh context.
128
+ */
129
+ async waitForPendingFrameworkUpdates() {
130
+ await new Promise((resolve) => setTimeout(resolve, 0));
131
+ }
132
+ };
133
+
134
+ //#endregion
135
+ //#region src/v2/context.ts
136
+ const CopilotKitContext = (0, react.createContext)(null);
137
+ const useCopilotKit = () => {
138
+ const context = (0, react.useContext)(CopilotKitContext);
139
+ const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
140
+ if (!context) throw new Error("useCopilotKit must be used within CopilotKitProvider");
141
+ (0, react.useEffect)(() => {
142
+ const subscription = context.copilotkit.subscribe({
143
+ onRuntimeConnectionStatusChanged: () => {
144
+ forceUpdate();
145
+ },
146
+ onHeadersChanged: () => {
147
+ forceUpdate();
148
+ }
149
+ });
150
+ return () => {
151
+ subscription.unsubscribe();
152
+ };
153
+ }, []);
154
+ return context;
155
+ };
156
+ const LicenseContext = (0, react.createContext)({
157
+ status: null,
158
+ license: null,
159
+ checkFeature: () => true,
160
+ getLimit: () => null
161
+ });
162
+ const CopilotKitAgentIdContext = (0, react.createContext)(void 0);
163
+ const useDefaultAgentId = () => (0, react.useContext)(CopilotKitAgentIdContext);
164
+
165
+ //#endregion
39
166
  //#region src/v2/lib/shallow-stable-ref.ts
40
167
  /**
41
168
  * Shallow equality comparison for objects.
@@ -90,7 +217,12 @@ react_markdown = __toESM(react_markdown);
90
217
  assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
91
218
  assistantMessageToolbarCopyMessageLabel: "Copy",
92
219
  assistantMessageToolbarInspectorLabel: "View in Inspector",
93
- assistantMessageToolbarInspectorLocalOnlyLabel: "Development Only",
220
+ assistantMessageToolbarInspectorDescription: "Open this message in the Inspector",
221
+ assistantMessageToolbarInspectorLocalOnlyLabel: "Local only",
222
+ assistantMessageToolbarInspectorLocalOnlyDescription: "Only visible on localhost or loopback hosts in development. Never shown in production.",
223
+ assistantMessageToolbarInspectorTitle: "CopilotKit Inspector",
224
+ assistantMessageToolbarInspectorHideLabel: "Hide this icon",
225
+ assistantMessageToolbarInspectorHideDescription: "Until you reload this page",
94
226
  assistantMessageToolbarThumbsUpLabel: "Good response",
95
227
  assistantMessageToolbarThumbsDownLabel: "Bad response",
96
228
  assistantMessageToolbarReadAloudLabel: "Read aloud",
@@ -131,7 +263,8 @@ react_markdown = __toESM(react_markdown);
131
263
  ...parentConfig?.labels,
132
264
  ...stableLabels
133
265
  }), [stableLabels, parentConfig?.labels]);
134
- const resolvedAgentId = agentId ?? parentConfig?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
266
+ const providerAgentId = useDefaultAgentId();
267
+ const resolvedAgentId = agentId ?? parentConfig?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
135
268
  const threadIdPropIsAuthoritative = threadId !== void 0 && hasExplicitThreadId !== false;
136
269
  const isThreadIdControlled = threadIdPropIsAuthoritative;
137
270
  const [activeThreadOverride, setActiveThreadOverride] = (0, react.useState)(null);
@@ -339,131 +472,6 @@ react_markdown = __toESM(react_markdown);
339
472
  };
340
473
  ControlledModalOpenScope.displayName = "ControlledModalOpenScope";
341
474
 
342
- //#endregion
343
- //#region src/v2/lib/react-core.ts
344
- var CopilotKitCoreReact = class extends _copilotkit_core.CopilotKitCore {
345
- constructor(config) {
346
- super(config);
347
- this._renderToolCalls = [];
348
- this._hookRenderToolCalls = /* @__PURE__ */ new Map();
349
- this._cachedMergedRenderToolCalls = null;
350
- this._renderCustomMessages = [];
351
- this._renderActivityMessages = [];
352
- this._interruptElement = null;
353
- this._renderToolCalls = config.renderToolCalls ?? [];
354
- this._renderCustomMessages = config.renderCustomMessages ?? [];
355
- this._renderActivityMessages = config.renderActivityMessages ?? [];
356
- }
357
- get renderCustomMessages() {
358
- return this._renderCustomMessages;
359
- }
360
- get renderActivityMessages() {
361
- return this._renderActivityMessages;
362
- }
363
- get renderToolCalls() {
364
- if (this._hookRenderToolCalls.size === 0) return this._renderToolCalls;
365
- if (this._cachedMergedRenderToolCalls) return this._cachedMergedRenderToolCalls;
366
- const merged = /* @__PURE__ */ new Map();
367
- for (const rc of this._renderToolCalls) merged.set(`${rc.agentId ?? ""}:${rc.name}`, rc);
368
- for (const [key, rc] of this._hookRenderToolCalls) merged.set(key, rc);
369
- this._cachedMergedRenderToolCalls = Array.from(merged.values());
370
- return this._cachedMergedRenderToolCalls;
371
- }
372
- setRenderActivityMessages(renderers) {
373
- this._renderActivityMessages = renderers;
374
- }
375
- setRenderCustomMessages(renderers) {
376
- this._renderCustomMessages = renderers;
377
- }
378
- setRenderToolCalls(renderToolCalls) {
379
- this._renderToolCalls = renderToolCalls;
380
- this._cachedMergedRenderToolCalls = null;
381
- this._notifyRenderToolCallsChanged();
382
- }
383
- addHookRenderToolCall(entry) {
384
- const key = `${entry.agentId ?? ""}:${entry.name}`;
385
- this._hookRenderToolCalls.set(key, entry);
386
- this._cachedMergedRenderToolCalls = null;
387
- this._notifyRenderToolCallsChanged();
388
- }
389
- removeHookRenderToolCall(name, agentId) {
390
- const key = `${agentId ?? ""}:${name}`;
391
- if (this._hookRenderToolCalls.delete(key)) {
392
- this._cachedMergedRenderToolCalls = null;
393
- this._notifyRenderToolCallsChanged();
394
- }
395
- }
396
- _notifyRenderToolCallsChanged() {
397
- this.notifySubscribers((subscriber) => {
398
- const reactSubscriber = subscriber;
399
- if (reactSubscriber.onRenderToolCallsChanged) reactSubscriber.onRenderToolCallsChanged({
400
- copilotkit: this,
401
- renderToolCalls: this.renderToolCalls
402
- });
403
- }, "Subscriber onRenderToolCallsChanged error:");
404
- }
405
- get interruptElement() {
406
- return this._interruptElement;
407
- }
408
- setInterruptElement(element) {
409
- this._interruptElement = element;
410
- this.notifySubscribers((subscriber) => {
411
- subscriber.onInterruptElementChanged?.({
412
- copilotkit: this,
413
- interruptElement: this._interruptElement
414
- });
415
- }, "Subscriber onInterruptElementChanged error:");
416
- }
417
- subscribe(subscriber) {
418
- return super.subscribe(subscriber);
419
- }
420
- /**
421
- * Wait for pending React state updates before the follow-up agent run.
422
- *
423
- * When a frontend tool handler calls setState(), React 18 batches the update
424
- * and schedules a commit via its internal scheduler (MessageChannel). The
425
- * useAgentContext hook registers context via useLayoutEffect, which runs
426
- * synchronously after React commits that batch.
427
- *
428
- * Awaiting a zero-delay timeout yields to the macrotask queue. React's
429
- * MessageChannel task runs first, committing the pending state and running
430
- * useLayoutEffect (which updates the context store). The follow-up runAgent
431
- * call then reads fresh context.
432
- */
433
- async waitForPendingFrameworkUpdates() {
434
- await new Promise((resolve) => setTimeout(resolve, 0));
435
- }
436
- };
437
-
438
- //#endregion
439
- //#region src/v2/context.ts
440
- const CopilotKitContext = (0, react.createContext)(null);
441
- const useCopilotKit = () => {
442
- const context = (0, react.useContext)(CopilotKitContext);
443
- const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
444
- if (!context) throw new Error("useCopilotKit must be used within CopilotKitProvider");
445
- (0, react.useEffect)(() => {
446
- const subscription = context.copilotkit.subscribe({
447
- onRuntimeConnectionStatusChanged: () => {
448
- forceUpdate();
449
- },
450
- onHeadersChanged: () => {
451
- forceUpdate();
452
- }
453
- });
454
- return () => {
455
- subscription.unsubscribe();
456
- };
457
- }, []);
458
- return context;
459
- };
460
- const LicenseContext = (0, react.createContext)({
461
- status: null,
462
- license: null,
463
- checkFeature: () => true,
464
- getLimit: () => null
465
- });
466
-
467
475
  //#endregion
468
476
  //#region src/v2/hooks/use-render-tool-call.tsx
469
477
  /**
@@ -575,21 +583,28 @@ react_markdown = __toESM(react_markdown);
575
583
 
576
584
  //#endregion
577
585
  //#region src/v2/components/CopilotKitInspector.tsx
578
- const CopilotKitInspector = ({ core, openRequest }) => {
586
+ const CopilotKitInspector = ({ core, openRequest, onVisibilityChange }) => {
579
587
  const mountRef = react.useRef(null);
580
588
  const inspectorRef = react.useRef(null);
581
589
  const latestCoreRef = react.useRef(core ?? null);
582
590
  const latestOpenRequestRef = react.useRef(openRequest);
591
+ const visibilityCallbackRef = react.useRef(onVisibilityChange);
592
+ visibilityCallbackRef.current = onVisibilityChange;
583
593
  latestCoreRef.current = core ?? null;
584
594
  latestOpenRequestRef.current = openRequest;
585
595
  react.useEffect(() => {
586
596
  let mounted = true;
587
597
  let inspector = null;
598
+ const handleVisibilityChange = (event) => {
599
+ const visible = event.detail?.visible;
600
+ visibilityCallbackRef.current?.(visible === true);
601
+ };
588
602
  import("@copilotkit/web-inspector").then((mod) => {
589
603
  if (!mounted || !mountRef.current) return;
590
604
  mod.defineWebInspector?.();
591
605
  inspector = mountRef.current.ownerDocument.createElement(mod.WEB_INSPECTOR_TAG);
592
606
  mod.configureWebInspectorElement(inspector, latestCoreRef.current);
607
+ inspector.addEventListener("cpk-inspector-visibility-change", handleVisibilityChange);
593
608
  mountRef.current.appendChild(inspector);
594
609
  inspectorRef.current = inspector;
595
610
  const request = latestOpenRequestRef.current;
@@ -599,7 +614,9 @@ react_markdown = __toESM(react_markdown);
599
614
  });
600
615
  return () => {
601
616
  mounted = false;
617
+ inspector?.removeEventListener("cpk-inspector-visibility-change", handleVisibilityChange);
602
618
  inspector?.remove();
619
+ visibilityCallbackRef.current?.(false);
603
620
  if (inspectorRef.current === inspector) inspectorRef.current = null;
604
621
  };
605
622
  }, []);
@@ -2500,14 +2517,19 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2500
2517
  }, [value, warningMessage]);
2501
2518
  return value;
2502
2519
  }
2503
- const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug }) => {
2520
+ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug }) => {
2504
2521
  const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
2522
+ const [inspectorVisible, setInspectorVisible] = (0, react.useState)(false);
2505
2523
  (0, react.useEffect)(() => {
2506
2524
  setShouldRenderInspector((0, _copilotkit_shared.shouldEnableInspector)({
2507
2525
  enableInspector,
2508
2526
  isBrowser: true,
2509
2527
  isDevelopment: process.env.NODE_ENV === "development"
2510
- }));
2528
+ }) && [
2529
+ "localhost",
2530
+ "127.0.0.1",
2531
+ "[::1]"
2532
+ ].includes(window.location.hostname));
2511
2533
  }, [enableInspector]);
2512
2534
  const [inspectorOpenRequest, setInspectorOpenRequest] = (0, react.useState)(null);
2513
2535
  const [runtimeA2UIEnabled, setRuntimeA2UIEnabled] = (0, react.useState)(false);
@@ -2523,9 +2545,15 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2523
2545
  setInspectorOpenRequest({ ...request });
2524
2546
  }, []);
2525
2547
  const inspectorContextValue = (0, react.useMemo)(() => ({
2526
- isInspectorEnabled: shouldRenderInspector,
2548
+ providerEnableInspector: enableInspector,
2549
+ isInspectorEnabled: shouldRenderInspector && inspectorVisible,
2527
2550
  openInspector: requestInspectorOpen
2528
- }), [shouldRenderInspector, requestInspectorOpen]);
2551
+ }), [
2552
+ enableInspector,
2553
+ shouldRenderInspector,
2554
+ inspectorVisible,
2555
+ requestInspectorOpen
2556
+ ]);
2529
2557
  const renderToolCallsList = useStableArrayProp(renderToolCalls, "renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.", (initial, next) => {
2530
2558
  const key = (rc) => `${rc?.agentId ?? ""}:${rc?.name ?? ""}`;
2531
2559
  const setFrom = (arr) => new Set(arr.map(key));
@@ -2922,9 +2950,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2922
2950
  }),
2923
2951
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CopilotKitInspectorContextProvider, {
2924
2952
  value: inspectorContextValue,
2925
- children: [children, shouldRenderInspector ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInspector, {
2953
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitAgentIdContext.Provider, {
2954
+ value: agentId,
2955
+ children
2956
+ }), shouldRenderInspector ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInspector, {
2926
2957
  core: copilotkit,
2927
- openRequest: inspectorOpenRequest
2958
+ openRequest: inspectorOpenRequest,
2959
+ onVisibilityChange: setInspectorVisible
2928
2960
  }) : null]
2929
2961
  }),
2930
2962
  runtimeLicenseWarningStatus === "none" && !resolvedPublicKey && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "no_license" }),
@@ -3126,7 +3158,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
3126
3158
  if (runtimeAgentId != null && threadId == null) throw new Error(`useAgent: \`runtimeAgentId\` requires \`threadId\`. A proxied agent exists to scope a thread to a private instance; without a threadId it behaves like the shared agent while adding a registration and a local agentId to keep unique. Either pass the thread, e.g. useAgent({ agentId: "${agentId ?? "chat-1"}", runtimeAgentId: "${runtimeAgentId}", threadId }), or bind to the agent directly with useAgent({ agentId: "${runtimeAgentId}" }).`);
3127
3159
  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 }).`);
3128
3160
  const chatConfig = useCopilotChatConfiguration();
3129
- const resolvedAgentId = agentId ?? chatConfig?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
3161
+ const providerAgentId = useDefaultAgentId();
3162
+ const resolvedAgentId = agentId ?? chatConfig?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
3130
3163
  const { copilotkit } = useCopilotKit();
3131
3164
  const providerThrottleMs = copilotkit.defaultThrottleMs;
3132
3165
  const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
@@ -3309,7 +3342,12 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
3309
3342
  function useSuggestions({ agentId } = {}) {
3310
3343
  const { copilotkit } = useCopilotKit();
3311
3344
  const config = useCopilotChatConfiguration();
3312
- const resolvedAgentId = (0, react.useMemo)(() => agentId ?? config?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID, [agentId, config?.agentId]);
3345
+ const providerAgentId = useDefaultAgentId();
3346
+ const resolvedAgentId = (0, react.useMemo)(() => agentId ?? config?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID, [
3347
+ agentId,
3348
+ config?.agentId,
3349
+ providerAgentId
3350
+ ]);
3313
3351
  const [suggestions, setSuggestions] = (0, react.useState)(() => {
3314
3352
  return copilotkit.getSuggestions(resolvedAgentId).suggestions;
3315
3353
  });
@@ -3563,7 +3601,10 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
3563
3601
  */
3564
3602
  function useInterrupt(config) {
3565
3603
  const { copilotkit } = useCopilotKit();
3566
- const { agent } = useAgent({ agentId: config.agentId });
3604
+ const { agent } = useAgent({
3605
+ agentId: config.agentId,
3606
+ updates: []
3607
+ });
3567
3608
  const [pending, setPending] = (0, react.useState)(null);
3568
3609
  const pendingRef = (0, react.useRef)(pending);
3569
3610
  pendingRef.current = pending;
@@ -6971,7 +7012,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
6971
7012
  *
6972
7013
  * ### Example
6973
7014
  * A great example of this is in our Perplexity Clone where we render the progress of an agent's internet search as it is happening.
6974
- * You can play around with it below or learn how to build it with its [demo](/coagents/videos/perplexity-clone).
7015
+ * You can play around with it below or learn how to build it with the [state rendering guide](/generative-ui/state-rendering).
6975
7016
  *
6976
7017
  * <Callout type="info">
6977
7018
  * This example is hosted on Vercel and may take a few seconds to load.
@@ -7159,7 +7200,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
7159
7200
  function useCopilotReadable({ description, value, convert, available = "enabled" }, dependencies) {
7160
7201
  const { copilotkit } = useCopilotKit();
7161
7202
  const ctxIdRef = (0, react.useRef)(void 0);
7162
- (0, react.useEffect)(() => {
7203
+ (0, react.useLayoutEffect)(() => {
7163
7204
  if (!copilotkit) return;
7164
7205
  if (available === "disabled") return;
7165
7206
  const id = copilotkit.addContext({