@copilotkit/react-core 1.76.0 → 1.77.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.
- package/dist/{copilotkit-dHdNF7H5.cjs → copilotkit-BG1d4-qU.cjs} +326 -113
- package/dist/copilotkit-BG1d4-qU.cjs.map +1 -0
- package/dist/{copilotkit-W-bV_OSs.d.cts → copilotkit-BGHjMw0d.d.cts} +89 -3
- package/dist/copilotkit-BGHjMw0d.d.cts.map +1 -0
- package/dist/{copilotkit-B90cY0Zg.d.mts → copilotkit-BdH_CdBt.d.mts} +84 -3
- package/dist/copilotkit-BdH_CdBt.d.mts.map +1 -0
- package/dist/{copilotkit-LD7Gp2aV.mjs → copilotkit-C_Sy6Cc7.mjs} +315 -114
- package/dist/copilotkit-C_Sy6Cc7.mjs.map +1 -0
- package/dist/index.cjs +18 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +8 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +18 -8
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +88 -25
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/context.cjs.map +1 -1
- package/dist/v2/context.d.cts +5 -0
- package/dist/v2/context.d.cts.map +1 -1
- package/dist/v2/context.d.mts +5 -0
- package/dist/v2/context.d.mts.map +1 -1
- package/dist/v2/context.mjs.map +1 -1
- package/dist/v2/headless.cjs +19 -0
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +5 -0
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +20 -1
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +3 -1
- package/dist/v2/index.d.cts +2 -2
- package/dist/v2/index.d.mts +2 -2
- package/dist/v2/index.mjs +2 -2
- package/dist/v2/index.umd.js +315 -112
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +22 -11
- package/dist/copilotkit-B90cY0Zg.d.mts.map +0 -1
- package/dist/copilotkit-LD7Gp2aV.mjs.map +0 -1
- package/dist/copilotkit-W-bV_OSs.d.cts.map +0 -1
- package/dist/copilotkit-dHdNF7H5.cjs.map +0 -1
package/dist/index.umd.js
CHANGED
|
@@ -280,6 +280,25 @@ react_markdown = __toESM(react_markdown);
|
|
|
280
280
|
parentConfig?.threadId,
|
|
281
281
|
activeThreadOverride
|
|
282
282
|
]);
|
|
283
|
+
const copilotkit = (0, react.useContext)(CopilotKitContext)?.copilotkit;
|
|
284
|
+
const openThreadRef = (0, react.useRef)(null);
|
|
285
|
+
const latestThreadIdRef = (0, react.useRef)(resolvedThreadId);
|
|
286
|
+
latestThreadIdRef.current = resolvedThreadId;
|
|
287
|
+
(0, react.useEffect)(() => {
|
|
288
|
+
if (copilotkit === void 0) return;
|
|
289
|
+
const registration = copilotkit.registerOpenThread({
|
|
290
|
+
agentId: resolvedAgentId,
|
|
291
|
+
threadId: latestThreadIdRef.current
|
|
292
|
+
});
|
|
293
|
+
openThreadRef.current = registration;
|
|
294
|
+
return () => {
|
|
295
|
+
registration.unregister();
|
|
296
|
+
openThreadRef.current = null;
|
|
297
|
+
};
|
|
298
|
+
}, [copilotkit, resolvedAgentId]);
|
|
299
|
+
(0, react.useEffect)(() => {
|
|
300
|
+
openThreadRef.current?.update(resolvedThreadId);
|
|
301
|
+
}, [resolvedThreadId]);
|
|
283
302
|
const resolvedHasExplicitThreadId = (threadIdPropIsAuthoritative ? true : activeThreadOverride?.explicit ?? hasExplicitThreadId ?? false) || !!parentConfig?.hasExplicitThreadId;
|
|
284
303
|
const [internalModalOpen, setInternalModalOpen] = (0, react.useState)(isModalDefaultOpen ?? true);
|
|
285
304
|
const hasExplicitDefault = isModalDefaultOpen !== void 0;
|
|
@@ -583,7 +602,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
583
602
|
|
|
584
603
|
//#endregion
|
|
585
604
|
//#region package.json
|
|
586
|
-
var version = "1.
|
|
605
|
+
var version = "1.77.1";
|
|
587
606
|
|
|
588
607
|
//#endregion
|
|
589
608
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
@@ -787,12 +806,14 @@ react_markdown = __toESM(react_markdown);
|
|
|
787
806
|
* Fetches resource content on-demand via proxied MCP requests. The React shell
|
|
788
807
|
* owns the iframe; `bindMcpApp` owns the protocol.
|
|
789
808
|
*/
|
|
790
|
-
const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agent }) {
|
|
809
|
+
const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, message, agent }) {
|
|
791
810
|
const { copilotkit } = useCopilotKit();
|
|
811
|
+
const messageId = message?.id;
|
|
792
812
|
const containerRef = (0, react.useRef)(null);
|
|
793
813
|
const iframeRef = (0, react.useRef)(null);
|
|
794
814
|
const sessionRef = (0, react.useRef)(null);
|
|
795
815
|
const [error, setError] = (0, react.useState)(null);
|
|
816
|
+
const [contentError, setContentError] = (0, react.useState)(null);
|
|
796
817
|
const [isLoading, setIsLoading] = (0, react.useState)(true);
|
|
797
818
|
const [iframeSize, setIframeSize] = (0, react.useState)({});
|
|
798
819
|
const [fetchedResource, setFetchedResource] = (0, react.useState)(null);
|
|
@@ -811,6 +832,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
811
832
|
let mounted = true;
|
|
812
833
|
setIsLoading(true);
|
|
813
834
|
setError(null);
|
|
835
|
+
setContentError(null);
|
|
814
836
|
const iframe = document.createElement("iframe");
|
|
815
837
|
iframe.style.width = "100%";
|
|
816
838
|
iframe.style.height = "100px";
|
|
@@ -833,6 +855,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
833
855
|
getContent: () => contentRef.current,
|
|
834
856
|
getAgent: () => agentRef.current,
|
|
835
857
|
host: copilotkit,
|
|
858
|
+
messageId,
|
|
836
859
|
hooks: {
|
|
837
860
|
onResource: (resource) => {
|
|
838
861
|
if (!mounted) return;
|
|
@@ -842,6 +865,9 @@ react_markdown = __toESM(react_markdown);
|
|
|
842
865
|
onSizeChanged: (size) => {
|
|
843
866
|
if (mounted) setIframeSize(size);
|
|
844
867
|
},
|
|
868
|
+
onContentError: (err) => {
|
|
869
|
+
if (mounted) setContentError(err);
|
|
870
|
+
},
|
|
845
871
|
onError: (err) => {
|
|
846
872
|
if (!mounted) return;
|
|
847
873
|
setError(err);
|
|
@@ -850,9 +876,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
850
876
|
}
|
|
851
877
|
});
|
|
852
878
|
sessionRef.current = session;
|
|
853
|
-
|
|
854
|
-
if (current.toolInput) session.sendToolInput(current.toolInput);
|
|
855
|
-
if (current.result) session.sendToolResult(current.result);
|
|
879
|
+
session.syncContent(contentRef.current);
|
|
856
880
|
} catch (err) {
|
|
857
881
|
console.error("[MCPAppsRenderer] Setup error:", err);
|
|
858
882
|
if (mounted) {
|
|
@@ -872,6 +896,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
872
896
|
}, [
|
|
873
897
|
agent,
|
|
874
898
|
copilotkit,
|
|
899
|
+
messageId,
|
|
875
900
|
content.resourceUri,
|
|
876
901
|
content.serverHash,
|
|
877
902
|
content.serverId
|
|
@@ -886,11 +911,8 @@ react_markdown = __toESM(react_markdown);
|
|
|
886
911
|
}
|
|
887
912
|
}, [iframeSize]);
|
|
888
913
|
(0, react.useEffect)(() => {
|
|
889
|
-
|
|
890
|
-
}, [content.toolInput]);
|
|
891
|
-
(0, react.useEffect)(() => {
|
|
892
|
-
if (content.result) sessionRef.current?.sendToolResult(content.result);
|
|
893
|
-
}, [content.result]);
|
|
914
|
+
sessionRef.current?.syncContent(contentRef.current);
|
|
915
|
+
}, [content.toolInput, content.result]);
|
|
894
916
|
const borderStyle = fetchedResource?._meta?.ui?.prefersBorder === true ? {
|
|
895
917
|
borderRadius: "8px",
|
|
896
918
|
backgroundColor: "#f9f9f9",
|
|
@@ -912,12 +934,12 @@ react_markdown = __toESM(react_markdown);
|
|
|
912
934
|
color: "#666"
|
|
913
935
|
},
|
|
914
936
|
children: "Loading..."
|
|
915
|
-
}), error && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
937
|
+
}), (error ?? contentError) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
916
938
|
style: {
|
|
917
939
|
color: "red",
|
|
918
940
|
padding: "1rem"
|
|
919
941
|
},
|
|
920
|
-
children: ["Error: ", error.message]
|
|
942
|
+
children: ["Error: ", (error ?? contentError).message]
|
|
921
943
|
})]
|
|
922
944
|
});
|
|
923
945
|
};
|
|
@@ -2209,7 +2231,6 @@ react_markdown = __toESM(react_markdown);
|
|
|
2209
2231
|
- Use CSS Grid or Flexbox for layout. Ensure the UI looks good at any width.
|
|
2210
2232
|
- Minimal transitions (150ms) for hover/focus states only. No decorative animations.
|
|
2211
2233
|
- Keep the UI focused and dense — avoid excessive padding. Use compact spacing (8–12px gaps, 10–14px padding in controls).`;
|
|
2212
|
-
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)";
|
|
2213
2234
|
function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
|
|
2214
2235
|
const empty = (0, react.useMemo)(() => [], []);
|
|
2215
2236
|
const value = prop ?? empty;
|
|
@@ -2219,7 +2240,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
2219
2240
|
}, [value, warningMessage]);
|
|
2220
2241
|
return value;
|
|
2221
2242
|
}
|
|
2222
|
-
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, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug }) => {
|
|
2243
|
+
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 }) => {
|
|
2223
2244
|
const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
|
|
2224
2245
|
const [inspectorVisible, setInspectorVisible] = (0, react.useState)(false);
|
|
2225
2246
|
(0, react.useEffect)(() => {
|
|
@@ -2402,7 +2423,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
2402
2423
|
if (!openGenUIActive) return [];
|
|
2403
2424
|
return [{
|
|
2404
2425
|
name: "generateSandboxedUi",
|
|
2405
|
-
description: GENERATE_SANDBOXED_UI_DESCRIPTION,
|
|
2426
|
+
description: _copilotkit_shared.GENERATE_SANDBOXED_UI_DESCRIPTION,
|
|
2406
2427
|
parameters: GenerateSandboxedUiArgsSchema,
|
|
2407
2428
|
handler: async () => "UI generated",
|
|
2408
2429
|
followUp: true,
|
|
@@ -2454,7 +2475,8 @@ react_markdown = __toESM(react_markdown);
|
|
|
2454
2475
|
renderToolCalls: allRenderToolCalls,
|
|
2455
2476
|
renderActivityMessages: allActivityRenderers,
|
|
2456
2477
|
renderCustomMessages: renderCustomMessagesList,
|
|
2457
|
-
debug
|
|
2478
|
+
debug,
|
|
2479
|
+
learning
|
|
2458
2480
|
});
|
|
2459
2481
|
if (defaultThrottleMs !== void 0) copilotkitRef.current.setDefaultThrottleMs(defaultThrottleMs);
|
|
2460
2482
|
}
|
|
@@ -2559,6 +2581,32 @@ react_markdown = __toESM(react_markdown);
|
|
|
2559
2581
|
useSingleEndpoint,
|
|
2560
2582
|
debug
|
|
2561
2583
|
]);
|
|
2584
|
+
const learningEnabled = learning !== void 0;
|
|
2585
|
+
const trajectoryId = learning?.trajectoryId;
|
|
2586
|
+
const learningContainerIdsRef = (0, react.useRef)(learning?.learningContainerIds);
|
|
2587
|
+
(0, react.useEffect)(() => {
|
|
2588
|
+
copilotkit.setLearningConfig(learning);
|
|
2589
|
+
learningContainerIdsRef.current = learning?.learningContainerIds;
|
|
2590
|
+
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.");
|
|
2591
|
+
}, [copilotkit, learning]);
|
|
2592
|
+
(0, react.useEffect)(() => {
|
|
2593
|
+
if (!learningEnabled) return;
|
|
2594
|
+
let disposed = false;
|
|
2595
|
+
if (trajectoryId !== void 0) copilotkit.startTrajectory({
|
|
2596
|
+
trajectoryId,
|
|
2597
|
+
learningContainerIds: learningContainerIdsRef.current
|
|
2598
|
+
}).catch(() => {
|
|
2599
|
+
if (!disposed) console.warn("[CopilotKit] Failed to start interaction capture.");
|
|
2600
|
+
});
|
|
2601
|
+
return () => {
|
|
2602
|
+
disposed = true;
|
|
2603
|
+
copilotkit.stopTrajectory();
|
|
2604
|
+
};
|
|
2605
|
+
}, [
|
|
2606
|
+
copilotkit,
|
|
2607
|
+
learningEnabled,
|
|
2608
|
+
trajectoryId
|
|
2609
|
+
]);
|
|
2562
2610
|
const didMountRef = (0, react.useRef)(false);
|
|
2563
2611
|
(0, react.useEffect)(() => {
|
|
2564
2612
|
if (!didMountRef.current) return;
|
|
@@ -2621,8 +2669,13 @@ react_markdown = __toESM(react_markdown);
|
|
|
2621
2669
|
]);
|
|
2622
2670
|
const contextValue = (0, react.useMemo)(() => ({
|
|
2623
2671
|
copilotkit,
|
|
2624
|
-
executingToolCallIds
|
|
2625
|
-
|
|
2672
|
+
executingToolCallIds,
|
|
2673
|
+
showIntelligenceIndicator
|
|
2674
|
+
}), [
|
|
2675
|
+
copilotkit,
|
|
2676
|
+
executingToolCallIds,
|
|
2677
|
+
showIntelligenceIndicator
|
|
2678
|
+
]);
|
|
2626
2679
|
const retryableRuntimeEntitlementFailure = runtimeEntitlements?.status !== "ready" && runtimeEntitlements?.error.retryable === true;
|
|
2627
2680
|
const hasNonReadyRuntimeEntitlement = runtimeEntitlements !== void 0 && runtimeEntitlements.status !== "ready";
|
|
2628
2681
|
const hasLegacyRuntimeEntitlementFallback = runtimeLicenseStatus === "valid" || runtimeLicenseStatus === "expiring";
|
|
@@ -7056,7 +7109,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
7056
7109
|
* running, // A boolean indicating if the agent is currently running.
|
|
7057
7110
|
* start, // A function to start the agent.
|
|
7058
7111
|
* stop, // A function to stop the agent.
|
|
7059
|
-
* run, // A function to (re-)run the agent
|
|
7112
|
+
* run, // A function to (re-)run the agent through the v2 core (`copilotkit.runAgent`).
|
|
7060
7113
|
* } = agent;
|
|
7061
7114
|
* ```
|
|
7062
7115
|
*
|
|
@@ -7167,6 +7220,17 @@ react_markdown = __toESM(react_markdown);
|
|
|
7167
7220
|
handleStateUpdate,
|
|
7168
7221
|
hasStateValues
|
|
7169
7222
|
]);
|
|
7223
|
+
const runAgent = (0, react.useCallback)(async (parameters) => {
|
|
7224
|
+
if (!agent) return void 0;
|
|
7225
|
+
return copilotkit.runAgent({
|
|
7226
|
+
agent,
|
|
7227
|
+
forwardedProps: parameters?.forwardedProps,
|
|
7228
|
+
runId: parameters?.runId
|
|
7229
|
+
});
|
|
7230
|
+
}, [agent, copilotkit]);
|
|
7231
|
+
const stopAgent = (0, react.useCallback)(() => {
|
|
7232
|
+
if (agent) copilotkit.stopAgent({ agent });
|
|
7233
|
+
}, [agent, copilotkit]);
|
|
7170
7234
|
return (0, react.useMemo)(() => {
|
|
7171
7235
|
if (!agent) {
|
|
7172
7236
|
const noop = () => {};
|
|
@@ -7191,15 +7255,14 @@ react_markdown = __toESM(react_markdown);
|
|
|
7191
7255
|
running: agent.isRunning,
|
|
7192
7256
|
state: agent.state,
|
|
7193
7257
|
setState: handleStateUpdate,
|
|
7194
|
-
start:
|
|
7195
|
-
stop:
|
|
7196
|
-
run:
|
|
7258
|
+
start: runAgent,
|
|
7259
|
+
stop: stopAgent,
|
|
7260
|
+
run: runAgent
|
|
7197
7261
|
};
|
|
7198
7262
|
}, [
|
|
7199
7263
|
agent?.state,
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
agent?.runAgent,
|
|
7264
|
+
runAgent,
|
|
7265
|
+
stopAgent,
|
|
7203
7266
|
agent?.threadId,
|
|
7204
7267
|
agent?.isRunning,
|
|
7205
7268
|
agent?.agentId,
|