@copilotkit/react-core 1.69.2 → 1.70.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.
- package/dist/{copilotkit-BmW2sFH6.mjs → copilotkit-B7aFKfQR.mjs} +138 -77
- package/dist/copilotkit-B7aFKfQR.mjs.map +1 -0
- package/dist/{copilotkit-Ba7qwYt3.cjs → copilotkit-BE76j111.cjs} +142 -75
- package/dist/copilotkit-BE76j111.cjs.map +1 -0
- package/dist/{copilotkit-CF1Pm2VG.d.cts → copilotkit-BuzP0VeG.d.cts} +47 -18
- package/dist/copilotkit-BuzP0VeG.d.cts.map +1 -0
- package/dist/{copilotkit-TdM-5onZ.d.mts → copilotkit-CbZGwElm.d.mts} +47 -18
- package/dist/copilotkit-CbZGwElm.d.mts.map +1 -0
- package/dist/index.cjs +93 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +17 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +93 -21
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +206 -87
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +15 -8
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +15 -8
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +2 -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 +140 -77
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +9 -10
- package/skills/react-core/SKILL.md +5 -3
- package/skills/react-core/references/agent-access.md +68 -1
- package/skills/react-core/references/debug-mode.md +21 -34
- package/skills/react-core/references/switching-agents-recipes.md +1 -0
- package/skills/react-core/references/switching-agents.md +9 -0
- package/skills/react-core/references/threads.md +65 -0
- package/dist/copilotkit-Ba7qwYt3.cjs.map +0 -1
- package/dist/copilotkit-BmW2sFH6.mjs.map +0 -1
- package/dist/copilotkit-CF1Pm2VG.d.cts.map +0 -1
- package/dist/copilotkit-TdM-5onZ.d.mts.map +0 -1
|
@@ -43,7 +43,6 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
43
43
|
let streamdown = require("streamdown");
|
|
44
44
|
let _copilotkit_react_core_v2_context = require("@copilotkit/react-core/v2/context");
|
|
45
45
|
let zod = require("zod");
|
|
46
|
-
let _lit_labs_react = require("@lit-labs/react");
|
|
47
46
|
let _copilotkit_a2ui_renderer = require("@copilotkit/a2ui-renderer");
|
|
48
47
|
let zod_to_json_schema = require("zod-to-json-schema");
|
|
49
48
|
let react_dom = require("react-dom");
|
|
@@ -107,7 +106,7 @@ const CopilotChatDefaultLabels = {
|
|
|
107
106
|
assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
|
|
108
107
|
assistantMessageToolbarCopyMessageLabel: "Copy",
|
|
109
108
|
assistantMessageToolbarInspectorLabel: "View in Inspector",
|
|
110
|
-
assistantMessageToolbarInspectorLocalOnlyLabel: "
|
|
109
|
+
assistantMessageToolbarInspectorLocalOnlyLabel: "Development Only",
|
|
111
110
|
assistantMessageToolbarThumbsUpLabel: "Good response",
|
|
112
111
|
assistantMessageToolbarThumbsDownLabel: "Bad response",
|
|
113
112
|
assistantMessageToolbarReadAloudLabel: "Read aloud",
|
|
@@ -1383,7 +1382,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
1383
1382
|
side: "bottom",
|
|
1384
1383
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
1385
1384
|
className: "cpk:flex cpk:items-center cpk:gap-1 cpk:text-xs cpk:font-medium",
|
|
1386
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children:
|
|
1385
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: labels.chatInputToolbarAddButtonLabel }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
1387
1386
|
className: "cpk:rounded cpk:bg-[#4a4a4a] cpk:px-1 cpk:py-[1px] cpk:font-mono cpk:text-[11px] cpk:text-white cpk:dark:bg-[#e0e0e0] cpk:dark:text-black",
|
|
1388
1387
|
children: "/"
|
|
1389
1388
|
})]
|
|
@@ -1526,32 +1525,43 @@ function useRenderToolCall() {
|
|
|
1526
1525
|
|
|
1527
1526
|
//#endregion
|
|
1528
1527
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
1529
|
-
const CopilotKitInspector = ({ core, openRequest
|
|
1530
|
-
const
|
|
1528
|
+
const CopilotKitInspector = ({ core, openRequest }) => {
|
|
1529
|
+
const mountRef = react.useRef(null);
|
|
1531
1530
|
const inspectorRef = react.useRef(null);
|
|
1531
|
+
const latestCoreRef = react.useRef(core ?? null);
|
|
1532
|
+
const latestOpenRequestRef = react.useRef(openRequest);
|
|
1533
|
+
latestCoreRef.current = core ?? null;
|
|
1534
|
+
latestOpenRequestRef.current = openRequest;
|
|
1532
1535
|
react.useEffect(() => {
|
|
1533
1536
|
let mounted = true;
|
|
1537
|
+
let inspector = null;
|
|
1534
1538
|
import("@copilotkit/web-inspector").then((mod) => {
|
|
1539
|
+
if (!mounted || !mountRef.current) return;
|
|
1535
1540
|
mod.defineWebInspector?.();
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
if (
|
|
1541
|
+
inspector = mountRef.current.ownerDocument.createElement(mod.WEB_INSPECTOR_TAG);
|
|
1542
|
+
mod.configureWebInspectorElement(inspector, latestCoreRef.current);
|
|
1543
|
+
mountRef.current.appendChild(inspector);
|
|
1544
|
+
inspectorRef.current = inspector;
|
|
1545
|
+
const request = latestOpenRequestRef.current;
|
|
1546
|
+
if (request) inspector.openInspector("message_toolbar", request);
|
|
1547
|
+
}).catch((error) => {
|
|
1548
|
+
console.error("Failed to load CopilotKit inspector:", error);
|
|
1542
1549
|
});
|
|
1543
1550
|
return () => {
|
|
1544
1551
|
mounted = false;
|
|
1552
|
+
inspector?.remove();
|
|
1553
|
+
if (inspectorRef.current === inspector) inspectorRef.current = null;
|
|
1545
1554
|
};
|
|
1546
1555
|
}, []);
|
|
1556
|
+
react.useEffect(() => {
|
|
1557
|
+
if (inspectorRef.current) inspectorRef.current.core = core ?? null;
|
|
1558
|
+
}, [core]);
|
|
1547
1559
|
react.useEffect(() => {
|
|
1548
1560
|
if (openRequest) inspectorRef.current?.openInspector("message_toolbar", openRequest);
|
|
1549
|
-
}, [
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
...rest,
|
|
1554
|
-
core: core ?? null
|
|
1561
|
+
}, [openRequest]);
|
|
1562
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1563
|
+
ref: mountRef,
|
|
1564
|
+
style: { display: "contents" }
|
|
1555
1565
|
});
|
|
1556
1566
|
};
|
|
1557
1567
|
CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
@@ -1559,7 +1569,7 @@ CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
|
1559
1569
|
//#endregion
|
|
1560
1570
|
//#region src/v2/components/CopilotKitInspectorContext.tsx
|
|
1561
1571
|
const CopilotKitInspectorContext = react.createContext({
|
|
1562
|
-
|
|
1572
|
+
isInspectorEnabled: false,
|
|
1563
1573
|
openInspector: () => void 0
|
|
1564
1574
|
});
|
|
1565
1575
|
const CopilotKitInspectorContextProvider = CopilotKitInspectorContext.Provider;
|
|
@@ -3509,9 +3519,15 @@ function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
|
|
|
3509
3519
|
}, [value, warningMessage]);
|
|
3510
3520
|
return value;
|
|
3511
3521
|
}
|
|
3512
|
-
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,
|
|
3522
|
+
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 }) => {
|
|
3513
3523
|
const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
|
|
3514
|
-
|
|
3524
|
+
(0, react.useEffect)(() => {
|
|
3525
|
+
setShouldRenderInspector((0, _copilotkit_shared.shouldEnableInspector)({
|
|
3526
|
+
enableInspector,
|
|
3527
|
+
isBrowser: true,
|
|
3528
|
+
isDevelopment: process.env.NODE_ENV === "development"
|
|
3529
|
+
}));
|
|
3530
|
+
}, [enableInspector]);
|
|
3515
3531
|
const [inspectorOpenRequest, setInspectorOpenRequest] = (0, react.useState)(null);
|
|
3516
3532
|
const [runtimeA2UIEnabled, setRuntimeA2UIEnabled] = (0, react.useState)(false);
|
|
3517
3533
|
const [runtimeOpenGenUIEnabled, setRuntimeOpenGenUIEnabled] = (0, react.useState)(false);
|
|
@@ -3520,32 +3536,15 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3520
3536
|
const a2uiCatalogProvided = !!a2ui?.catalog;
|
|
3521
3537
|
const a2uiActive = runtimeA2UIEnabled || a2uiCatalogProvided;
|
|
3522
3538
|
const [runtimeLicenseStatus, setRuntimeLicenseStatus] = (0, react.useState)(void 0);
|
|
3523
|
-
(0, react.
|
|
3524
|
-
|
|
3525
|
-
const isLocalhost = new Set(["localhost", "127.0.0.1"]).has(window.location?.hostname ?? "");
|
|
3526
|
-
const canShowLocalInspectorAction = process.env.NODE_ENV === "development" && isLocalhost;
|
|
3527
|
-
if (showDevConsole === true) {
|
|
3528
|
-
setShouldRenderInspector(true);
|
|
3529
|
-
setIsLocalInspectorEnabled(canShowLocalInspectorAction);
|
|
3530
|
-
} else if (showDevConsole === "auto") if (isLocalhost) {
|
|
3531
|
-
setShouldRenderInspector(true);
|
|
3532
|
-
setIsLocalInspectorEnabled(canShowLocalInspectorAction);
|
|
3533
|
-
} else {
|
|
3534
|
-
setShouldRenderInspector(false);
|
|
3535
|
-
setIsLocalInspectorEnabled(false);
|
|
3536
|
-
}
|
|
3537
|
-
else {
|
|
3538
|
-
setShouldRenderInspector(false);
|
|
3539
|
-
setIsLocalInspectorEnabled(false);
|
|
3540
|
-
}
|
|
3541
|
-
}, [showDevConsole]);
|
|
3539
|
+
const [runtimeEntitlements, setRuntimeEntitlements] = (0, react.useState)(void 0);
|
|
3540
|
+
const [runtimeEntitlementRetryPending, setRuntimeEntitlementRetryPending] = (0, react.useState)(false);
|
|
3542
3541
|
const requestInspectorOpen = (0, react.useCallback)((request) => {
|
|
3543
3542
|
setInspectorOpenRequest({ ...request });
|
|
3544
3543
|
}, []);
|
|
3545
3544
|
const inspectorContextValue = (0, react.useMemo)(() => ({
|
|
3546
|
-
|
|
3545
|
+
isInspectorEnabled: shouldRenderInspector,
|
|
3547
3546
|
openInspector: requestInspectorOpen
|
|
3548
|
-
}), [
|
|
3547
|
+
}), [shouldRenderInspector, requestInspectorOpen]);
|
|
3549
3548
|
const renderToolCallsList = useStableArrayProp(renderToolCalls, "renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.", (initial, next) => {
|
|
3550
3549
|
const key = (rc) => `${rc?.agentId ?? ""}:${rc?.name ?? ""}`;
|
|
3551
3550
|
const setFrom = (arr) => new Set(arr.map(key));
|
|
@@ -3729,6 +3728,8 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3729
3728
|
setRuntimeA2UIEnabled(copilotkit.a2uiEnabled);
|
|
3730
3729
|
setRuntimeOpenGenUIEnabled(copilotkit.openGenerativeUIEnabled);
|
|
3731
3730
|
setRuntimeLicenseStatus(copilotkit.licenseStatus);
|
|
3731
|
+
setRuntimeEntitlements(copilotkit.runtimeEntitlements);
|
|
3732
|
+
setRuntimeEntitlementRetryPending(copilotkit.runtimeEntitlementRetryPending);
|
|
3732
3733
|
};
|
|
3733
3734
|
const subscription = copilotkit.subscribe({ onRuntimeConnectionStatusChanged: syncRuntimeInfo });
|
|
3734
3735
|
syncRuntimeInfo();
|
|
@@ -3869,7 +3870,26 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3869
3870
|
copilotkit,
|
|
3870
3871
|
executingToolCallIds
|
|
3871
3872
|
}), [copilotkit, executingToolCallIds]);
|
|
3872
|
-
const
|
|
3873
|
+
const retryableRuntimeEntitlementFailure = runtimeEntitlements?.status !== "ready" && runtimeEntitlements?.error.retryable === true;
|
|
3874
|
+
const hasNonReadyRuntimeEntitlement = runtimeEntitlements !== void 0 && runtimeEntitlements.status !== "ready";
|
|
3875
|
+
const hasLegacyRuntimeEntitlementFallback = runtimeLicenseStatus === "valid" || runtimeLicenseStatus === "expiring";
|
|
3876
|
+
const runtimeEntitlementRetryInProgress = retryableRuntimeEntitlementFailure && runtimeEntitlementRetryPending && !hasLegacyRuntimeEntitlementFallback;
|
|
3877
|
+
const runtimeEntitlementFailureSettled = hasNonReadyRuntimeEntitlement && !runtimeEntitlementRetryInProgress && !hasLegacyRuntimeEntitlementFallback;
|
|
3878
|
+
const licenseContextValue = (0, react.useMemo)(() => {
|
|
3879
|
+
const runtimeLicenseContext = (0, _copilotkit_shared.createLicenseContextValue)(runtimeEntitlementRetryInProgress ? void 0 : runtimeLicenseStatus, runtimeEntitlements);
|
|
3880
|
+
if (!runtimeEntitlementFailureSettled) return runtimeLicenseContext;
|
|
3881
|
+
return {
|
|
3882
|
+
...runtimeLicenseContext,
|
|
3883
|
+
checkFeature: () => false,
|
|
3884
|
+
getLimit: () => null
|
|
3885
|
+
};
|
|
3886
|
+
}, [
|
|
3887
|
+
runtimeEntitlementFailureSettled,
|
|
3888
|
+
runtimeEntitlementRetryInProgress,
|
|
3889
|
+
runtimeEntitlements,
|
|
3890
|
+
runtimeLicenseStatus
|
|
3891
|
+
]);
|
|
3892
|
+
const runtimeLicenseWarningStatus = runtimeEntitlementRetryInProgress ? void 0 : licenseContextValue.status ?? void 0;
|
|
3873
3893
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SandboxFunctionsContext.Provider, {
|
|
3874
3894
|
value: sandboxFunctionsList,
|
|
3875
3895
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_v2_context.CopilotKitContext.Provider, {
|
|
@@ -3886,14 +3906,13 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3886
3906
|
value: inspectorContextValue,
|
|
3887
3907
|
children: [children, shouldRenderInspector ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInspector, {
|
|
3888
3908
|
core: copilotkit,
|
|
3889
|
-
defaultAnchor: inspectorDefaultAnchor,
|
|
3890
3909
|
openRequest: inspectorOpenRequest
|
|
3891
3910
|
}) : null]
|
|
3892
3911
|
}),
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3912
|
+
runtimeLicenseWarningStatus === "none" && !resolvedPublicKey && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "no_license" }),
|
|
3913
|
+
runtimeLicenseWarningStatus === "expired" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "expired" }),
|
|
3914
|
+
runtimeLicenseWarningStatus === "invalid" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "invalid" }),
|
|
3915
|
+
runtimeLicenseWarningStatus === "expiring" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "expiring" })
|
|
3897
3916
|
]
|
|
3898
3917
|
})
|
|
3899
3918
|
})
|
|
@@ -3993,7 +4012,7 @@ const EMPTY_DEPS$1 = [];
|
|
|
3993
4012
|
function useFrontendTool(tool, deps) {
|
|
3994
4013
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
3995
4014
|
const extraDeps = deps ?? EMPTY_DEPS$1;
|
|
3996
|
-
(0, react.
|
|
4015
|
+
(0, react.useLayoutEffect)(() => {
|
|
3997
4016
|
const name = tool.name;
|
|
3998
4017
|
if (copilotkit.getTool({
|
|
3999
4018
|
toolName: name,
|
|
@@ -4360,6 +4379,8 @@ function safeStringifyForAttr(value) {
|
|
|
4360
4379
|
|
|
4361
4380
|
//#endregion
|
|
4362
4381
|
//#region src/v2/hooks/use-human-in-the-loop.tsx
|
|
4382
|
+
/** Registration name of a catch-all tool: handles any otherwise-unhandled call. */
|
|
4383
|
+
const WILDCARD_TOOL_NAME = "*";
|
|
4363
4384
|
function useHumanInTheLoop(tool, deps) {
|
|
4364
4385
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
4365
4386
|
const resolvePromiseRef = (0, react.useRef)(null);
|
|
@@ -4395,10 +4416,11 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
4395
4416
|
}, []);
|
|
4396
4417
|
const RenderComponent = (0, react.useCallback)((props) => {
|
|
4397
4418
|
const ToolComponent = tool.render;
|
|
4419
|
+
const name = tool.name === WILDCARD_TOOL_NAME ? props.name : tool.name;
|
|
4398
4420
|
if (props.status === _copilotkit_core.ToolCallStatus.InProgress) {
|
|
4399
4421
|
const enhancedProps = {
|
|
4400
4422
|
...props,
|
|
4401
|
-
name
|
|
4423
|
+
name,
|
|
4402
4424
|
description: tool.description || "",
|
|
4403
4425
|
agentId: tool.agentId,
|
|
4404
4426
|
respond: void 0
|
|
@@ -4407,7 +4429,7 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
4407
4429
|
} else if (props.status === _copilotkit_core.ToolCallStatus.Executing) {
|
|
4408
4430
|
const enhancedProps = {
|
|
4409
4431
|
...props,
|
|
4410
|
-
name
|
|
4432
|
+
name,
|
|
4411
4433
|
description: tool.description || "",
|
|
4412
4434
|
agentId: tool.agentId,
|
|
4413
4435
|
respond
|
|
@@ -4416,7 +4438,7 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
4416
4438
|
} else if (props.status === _copilotkit_core.ToolCallStatus.Complete) {
|
|
4417
4439
|
const enhancedProps = {
|
|
4418
4440
|
...props,
|
|
4419
|
-
name
|
|
4441
|
+
name,
|
|
4420
4442
|
description: tool.description || "",
|
|
4421
4443
|
agentId: tool.agentId,
|
|
4422
4444
|
respond: void 0
|
|
@@ -4436,7 +4458,7 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
4436
4458
|
handler,
|
|
4437
4459
|
render: RenderComponent
|
|
4438
4460
|
}, deps);
|
|
4439
|
-
(0, react.
|
|
4461
|
+
(0, react.useLayoutEffect)(() => {
|
|
4440
4462
|
return () => {
|
|
4441
4463
|
copilotkit.removeHookRenderToolCall(tool.name, tool.agentId);
|
|
4442
4464
|
};
|
|
@@ -4901,8 +4923,12 @@ function normalizeStaticSuggestions(suggestions) {
|
|
|
4901
4923
|
}
|
|
4902
4924
|
|
|
4903
4925
|
//#endregion
|
|
4904
|
-
//#region src/v2/
|
|
4926
|
+
//#region src/v2/types/interrupt.ts
|
|
4927
|
+
/** Name of the legacy custom event agents emit to signal an interrupt. */
|
|
4905
4928
|
const INTERRUPT_EVENT_NAME = "on_interrupt";
|
|
4929
|
+
|
|
4930
|
+
//#endregion
|
|
4931
|
+
//#region src/v2/hooks/use-interrupt.tsx
|
|
4906
4932
|
function isPromiseLike(value) {
|
|
4907
4933
|
return (typeof value === "object" || typeof value === "function") && value !== null && typeof Reflect.get(value, "then") === "function";
|
|
4908
4934
|
}
|
|
@@ -5239,7 +5265,7 @@ function useThreadStoreSelector(store, selector) {
|
|
|
5239
5265
|
*/
|
|
5240
5266
|
function useThreads$1({ agentId, includeArchived, limit, enabled = true }) {
|
|
5241
5267
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
5242
|
-
const [store] = (0, react.useState)(() => (0, _copilotkit_core.ɵcreateThreadStore)({ fetch:
|
|
5268
|
+
const [store] = (0, react.useState)(() => (0, _copilotkit_core.ɵcreateThreadStore)({ fetch: copilotkit.ɵruntimeFetch }));
|
|
5243
5269
|
const coreThreads = useThreadStoreSelector(store, _copilotkit_core.ɵselectThreads);
|
|
5244
5270
|
const threads = (0, react.useMemo)(() => coreThreads.map(({ id, agentId, name, archived, createdAt, updatedAt, lastRunAt }) => ({
|
|
5245
5271
|
id,
|
|
@@ -5938,21 +5964,35 @@ function CopilotChatToolCallsView({ message, messages = [] }) {
|
|
|
5938
5964
|
|
|
5939
5965
|
//#endregion
|
|
5940
5966
|
//#region src/v2/components/chat/CopilotChatAssistantMessage.tsx
|
|
5967
|
+
/**
|
|
5968
|
+
* Binds the Inspector action to the active chat without making the full
|
|
5969
|
+
* assistant message subscribe to chat configuration changes.
|
|
5970
|
+
*/
|
|
5971
|
+
function BoundInspectorButton({ inspectorButton, messageId, openInspector, ...props }) {
|
|
5972
|
+
const chatConfiguration = useCopilotChatConfiguration();
|
|
5973
|
+
return renderSlot(inspectorButton, CopilotChatAssistantMessage.InspectorButton, {
|
|
5974
|
+
...props,
|
|
5975
|
+
onClick: () => openInspector({
|
|
5976
|
+
messageId,
|
|
5977
|
+
threadId: chatConfiguration?.threadId,
|
|
5978
|
+
agentId: chatConfiguration?.agentId
|
|
5979
|
+
})
|
|
5980
|
+
});
|
|
5981
|
+
}
|
|
5941
5982
|
function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible = true, markdownRenderer, toolbar, copyButton, inspectorButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }) {
|
|
5942
5983
|
useKatexStyles();
|
|
5943
|
-
const {
|
|
5944
|
-
const chatConfiguration = useCopilotChatConfiguration();
|
|
5984
|
+
const { isInspectorEnabled, openInspector } = useCopilotKitInspector();
|
|
5945
5985
|
const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
|
|
5946
5986
|
const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
|
|
5947
5987
|
if (message.content) return await (0, _copilotkit_shared.copyToClipboard)(message.content);
|
|
5948
5988
|
return false;
|
|
5949
5989
|
} });
|
|
5950
5990
|
const boundThumbsUpButton = renderSlot(thumbsUpButton, CopilotChatAssistantMessage.ThumbsUpButton, { onClick: onThumbsUp ? () => onThumbsUp(message) : void 0 });
|
|
5951
|
-
const boundInspectorButton =
|
|
5991
|
+
const boundInspectorButton = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BoundInspectorButton, {
|
|
5992
|
+
inspectorButton,
|
|
5952
5993
|
messageId: message.id,
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
}) });
|
|
5994
|
+
openInspector
|
|
5995
|
+
});
|
|
5956
5996
|
const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown ? () => onThumbsDown(message) : void 0 });
|
|
5957
5997
|
const boundReadAloudButton = renderSlot(readAloudButton, CopilotChatAssistantMessage.ReadAloudButton, { onClick: onReadAloud ? () => onReadAloud(message) : void 0 });
|
|
5958
5998
|
const boundRegenerateButton = renderSlot(regenerateButton, CopilotChatAssistantMessage.RegenerateButton, { onClick: onRegenerate ? () => onRegenerate(message) : void 0 });
|
|
@@ -5960,7 +6000,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
5960
6000
|
className: "cpk:flex cpk:items-center cpk:gap-1",
|
|
5961
6001
|
children: [
|
|
5962
6002
|
boundCopyButton,
|
|
5963
|
-
|
|
6003
|
+
isInspectorEnabled && boundInspectorButton,
|
|
5964
6004
|
(onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
|
|
5965
6005
|
(onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
|
|
5966
6006
|
(onReadAloud || readAloudButton) && boundReadAloudButton,
|
|
@@ -5974,7 +6014,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
5974
6014
|
});
|
|
5975
6015
|
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
5976
6016
|
const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
|
|
5977
|
-
const shouldShowToolbar = toolbarVisible && (hasContent ||
|
|
6017
|
+
const shouldShowToolbar = toolbarVisible && (hasContent || isInspectorEnabled) && !(isRunning && isLatestAssistantMessage);
|
|
5978
6018
|
if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5979
6019
|
"data-copilotkit": true,
|
|
5980
6020
|
style: { display: "contents" },
|
|
@@ -8532,7 +8572,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
8532
8572
|
const startRunActivityReconnectRef = (0, react.useRef)(null);
|
|
8533
8573
|
const runtimeStatus = copilotkit.runtimeConnectionStatus === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connected ? "Connected" : copilotkit.runtimeConnectionStatus;
|
|
8534
8574
|
const hasNativeIntelligenceRunActivity = hasExplicitThreadId && runtimeStatus === "Connected" && !!copilotkit.intelligence?.wsUrl && copilotkit.threadEndpoints?.realtimeMetadata === true;
|
|
8535
|
-
const [standaloneRunActivityStore] = (0, react.useState)(() => (0, _copilotkit_core.ɵcreateThreadStore)({ fetch:
|
|
8575
|
+
const [standaloneRunActivityStore] = (0, react.useState)(() => (0, _copilotkit_core.ɵcreateThreadStore)({ fetch: copilotkit.ɵruntimeFetch }));
|
|
8536
8576
|
const previousThreadRef = (0, react.useRef)(null);
|
|
8537
8577
|
const hasExplicitThreadIdRef = (0, react.useRef)(hasExplicitThreadId);
|
|
8538
8578
|
hasExplicitThreadIdRef.current = hasExplicitThreadId;
|
|
@@ -11545,20 +11585,42 @@ function CoAgentStateRenderBridge(props) {
|
|
|
11545
11585
|
|
|
11546
11586
|
//#endregion
|
|
11547
11587
|
//#region src/v1-deprecated/components/CopilotListeners.tsx
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
const
|
|
11588
|
+
function isPredictStateTool(value) {
|
|
11589
|
+
if (value === null || typeof value !== "object") return false;
|
|
11590
|
+
const config = value;
|
|
11591
|
+
return typeof config.tool === "string" && typeof config.state_key === "string" && (config.tool_argument === void 0 || typeof config.tool_argument === "string");
|
|
11592
|
+
}
|
|
11593
|
+
function getPredictStateUpdate(config, toolCallName, partialToolCallArgs) {
|
|
11594
|
+
if (config.tool !== toolCallName) return void 0;
|
|
11595
|
+
const emittedState = typeof partialToolCallArgs === "string" ? (0, _copilotkit_shared.partialJSONParse)(partialToolCallArgs) : partialToolCallArgs;
|
|
11596
|
+
if (emittedState === null || typeof emittedState !== "object") return;
|
|
11597
|
+
if (config.tool_argument) {
|
|
11598
|
+
if (!(config.tool_argument in emittedState)) return void 0;
|
|
11599
|
+
return { [config.state_key]: emittedState[config.tool_argument] };
|
|
11600
|
+
}
|
|
11601
|
+
return { [config.state_key]: emittedState };
|
|
11602
|
+
}
|
|
11603
|
+
function createPredictStateSubscriber(agent, predictStateToolsRef) {
|
|
11604
|
+
return {
|
|
11551
11605
|
onCustomEvent: ({ event }) => {
|
|
11552
|
-
if (event.name === "PredictState") predictStateToolsRef.current = event.value;
|
|
11606
|
+
if (event.name === "PredictState") predictStateToolsRef.current = Array.isArray(event.value) ? event.value.filter(isPredictStateTool) : [];
|
|
11553
11607
|
},
|
|
11554
11608
|
onToolCallArgsEvent: ({ partialToolCallArgs, toolCallName }) => {
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
const
|
|
11558
|
-
|
|
11609
|
+
const updates = {};
|
|
11610
|
+
predictStateToolsRef.current.forEach((config) => {
|
|
11611
|
+
const update = getPredictStateUpdate(config, toolCallName, partialToolCallArgs);
|
|
11612
|
+
if (update) Object.assign(updates, update);
|
|
11613
|
+
});
|
|
11614
|
+
if (Object.keys(updates).length > 0) agent.setState({
|
|
11615
|
+
...agent.state,
|
|
11616
|
+
...updates
|
|
11559
11617
|
});
|
|
11560
11618
|
}
|
|
11561
|
-
}
|
|
11619
|
+
};
|
|
11620
|
+
}
|
|
11621
|
+
const usePredictStateSubscription = (agent) => {
|
|
11622
|
+
const predictStateToolsRef = (0, react.useRef)([]);
|
|
11623
|
+
const getSubscriber = (0, react.useCallback)((subscriptionAgent) => createPredictStateSubscriber(subscriptionAgent, predictStateToolsRef), []);
|
|
11562
11624
|
(0, react.useEffect)(() => {
|
|
11563
11625
|
if (!agent) return;
|
|
11564
11626
|
const subscriber = getSubscriber(agent);
|
|
@@ -11617,7 +11679,6 @@ function CopilotListeners() {
|
|
|
11617
11679
|
//#region src/v1-deprecated/components/copilot-provider/copilotkit.tsx
|
|
11618
11680
|
function CopilotKit({ children, ...props }) {
|
|
11619
11681
|
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
11620
|
-
const showInspector = shouldShowDevConsole(props.enableInspector);
|
|
11621
11682
|
const publicApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
11622
11683
|
const renderArr = (0, react.useMemo)(() => [{ render: CoAgentStateRenderBridge }], []);
|
|
11623
11684
|
const { onError: _onError, ...v2Props } = props;
|
|
@@ -11630,7 +11691,7 @@ function CopilotKit({ children, ...props }) {
|
|
|
11630
11691
|
threadId: props.threadId,
|
|
11631
11692
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitProvider, {
|
|
11632
11693
|
...v2Props,
|
|
11633
|
-
|
|
11694
|
+
enableInspector: props.enableInspector,
|
|
11634
11695
|
renderCustomMessages: renderArr,
|
|
11635
11696
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInternal, {
|
|
11636
11697
|
...props,
|
|
@@ -12322,6 +12383,12 @@ Object.defineProperty(exports, 'INTELLIGENCE_TURN_HEAD', {
|
|
|
12322
12383
|
return INTELLIGENCE_TURN_HEAD;
|
|
12323
12384
|
}
|
|
12324
12385
|
});
|
|
12386
|
+
Object.defineProperty(exports, 'INTERRUPT_EVENT_NAME', {
|
|
12387
|
+
enumerable: true,
|
|
12388
|
+
get: function () {
|
|
12389
|
+
return INTERRUPT_EVENT_NAME;
|
|
12390
|
+
}
|
|
12391
|
+
});
|
|
12325
12392
|
Object.defineProperty(exports, 'IntelligenceIndicator', {
|
|
12326
12393
|
enumerable: true,
|
|
12327
12394
|
get: function () {
|
|
@@ -12622,4 +12689,4 @@ Object.defineProperty(exports, 'ɵrunMcpFollowUp', {
|
|
|
12622
12689
|
return ɵrunMcpFollowUp;
|
|
12623
12690
|
}
|
|
12624
12691
|
});
|
|
12625
|
-
//# sourceMappingURL=copilotkit-
|
|
12692
|
+
//# sourceMappingURL=copilotkit-BE76j111.cjs.map
|