@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
|
@@ -4,7 +4,7 @@ import { CopilotKitCore, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectio
|
|
|
4
4
|
import { HttpAgent, randomUUID } from "@ag-ui/client";
|
|
5
5
|
import { extendTailwindMerge, twMerge } from "tailwind-merge";
|
|
6
6
|
import { ArrowUp, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronRightIcon, Copy, Edit, Loader2, MessageCircle, Mic, PanelLeftOpen, Play, Plus, RefreshCw, Square, ThumbsDown, ThumbsUp, Upload, Volume2, X } from "lucide-react";
|
|
7
|
-
import { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitRemoteEndpointDiscoveryError, DEFAULT_AGENT_ID, ErrorVisibility, MissingPublicApiKeyError, Severity, TranscriptionErrorCode, TranscriptionErrorCode as TranscriptionErrorCode$1, copyToClipboard, createLicenseContextValue, dataToUUID, exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, parseJson, partialJSONParse, randomId, randomUUID as randomUUID$1, readFileAsBase64, schemaToJsonSchema } from "@copilotkit/shared";
|
|
7
|
+
import { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitRemoteEndpointDiscoveryError, DEFAULT_AGENT_ID, ErrorVisibility, MissingPublicApiKeyError, Severity, TranscriptionErrorCode, TranscriptionErrorCode as TranscriptionErrorCode$1, copyToClipboard, createLicenseContextValue, dataToUUID, exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, parseJson, partialJSONParse, randomId, randomUUID as randomUUID$1, readFileAsBase64, schemaToJsonSchema, shouldEnableInspector } from "@copilotkit/shared";
|
|
8
8
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { Slot } from "@radix-ui/react-slot";
|
|
10
10
|
import { cva } from "class-variance-authority";
|
|
@@ -14,7 +14,6 @@ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
|
14
14
|
import { Streamdown } from "streamdown";
|
|
15
15
|
import { CopilotKitContext, LicenseContext, useCopilotKit, useCopilotKit as useCopilotKit$1, useLicenseContext, useLicenseContext as useLicenseContext$1 } from "@copilotkit/react-core/v2/context";
|
|
16
16
|
import { z } from "zod";
|
|
17
|
-
import { createComponent } from "@lit-labs/react";
|
|
18
17
|
import { A2UIProvider, A2UIRenderer, A2UI_SCHEMA_CONTEXT_DESCRIPTION, Catalog, DEFAULT_SURFACE_ID, buildCatalogContextValue, extractCatalogComponentSchemas, filterCatalog, initializeDefaultCatalog, injectStyles, useA2UIActions, useA2UIError, viewerTheme } from "@copilotkit/a2ui-renderer";
|
|
19
18
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
20
19
|
import { createPortal, flushSync } from "react-dom";
|
|
@@ -77,7 +76,7 @@ const CopilotChatDefaultLabels = {
|
|
|
77
76
|
assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
|
|
78
77
|
assistantMessageToolbarCopyMessageLabel: "Copy",
|
|
79
78
|
assistantMessageToolbarInspectorLabel: "View in Inspector",
|
|
80
|
-
assistantMessageToolbarInspectorLocalOnlyLabel: "
|
|
79
|
+
assistantMessageToolbarInspectorLocalOnlyLabel: "Development Only",
|
|
81
80
|
assistantMessageToolbarThumbsUpLabel: "Good response",
|
|
82
81
|
assistantMessageToolbarThumbsDownLabel: "Bad response",
|
|
83
82
|
assistantMessageToolbarReadAloudLabel: "Read aloud",
|
|
@@ -1353,7 +1352,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
1353
1352
|
side: "bottom",
|
|
1354
1353
|
children: /* @__PURE__ */ jsxs("p", {
|
|
1355
1354
|
className: "cpk:flex cpk:items-center cpk:gap-1 cpk:text-xs cpk:font-medium",
|
|
1356
|
-
children: [/* @__PURE__ */ jsx("span", { children:
|
|
1355
|
+
children: [/* @__PURE__ */ jsx("span", { children: labels.chatInputToolbarAddButtonLabel }), /* @__PURE__ */ jsx("code", {
|
|
1357
1356
|
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",
|
|
1358
1357
|
children: "/"
|
|
1359
1358
|
})]
|
|
@@ -1496,32 +1495,43 @@ function useRenderToolCall() {
|
|
|
1496
1495
|
|
|
1497
1496
|
//#endregion
|
|
1498
1497
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
1499
|
-
const CopilotKitInspector = ({ core, openRequest
|
|
1500
|
-
const
|
|
1498
|
+
const CopilotKitInspector = ({ core, openRequest }) => {
|
|
1499
|
+
const mountRef = React$1.useRef(null);
|
|
1501
1500
|
const inspectorRef = React$1.useRef(null);
|
|
1501
|
+
const latestCoreRef = React$1.useRef(core ?? null);
|
|
1502
|
+
const latestOpenRequestRef = React$1.useRef(openRequest);
|
|
1503
|
+
latestCoreRef.current = core ?? null;
|
|
1504
|
+
latestOpenRequestRef.current = openRequest;
|
|
1502
1505
|
React$1.useEffect(() => {
|
|
1503
1506
|
let mounted = true;
|
|
1507
|
+
let inspector = null;
|
|
1504
1508
|
import("@copilotkit/web-inspector").then((mod) => {
|
|
1509
|
+
if (!mounted || !mountRef.current) return;
|
|
1505
1510
|
mod.defineWebInspector?.();
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
if (
|
|
1511
|
+
inspector = mountRef.current.ownerDocument.createElement(mod.WEB_INSPECTOR_TAG);
|
|
1512
|
+
mod.configureWebInspectorElement(inspector, latestCoreRef.current);
|
|
1513
|
+
mountRef.current.appendChild(inspector);
|
|
1514
|
+
inspectorRef.current = inspector;
|
|
1515
|
+
const request = latestOpenRequestRef.current;
|
|
1516
|
+
if (request) inspector.openInspector("message_toolbar", request);
|
|
1517
|
+
}).catch((error) => {
|
|
1518
|
+
console.error("Failed to load CopilotKit inspector:", error);
|
|
1512
1519
|
});
|
|
1513
1520
|
return () => {
|
|
1514
1521
|
mounted = false;
|
|
1522
|
+
inspector?.remove();
|
|
1523
|
+
if (inspectorRef.current === inspector) inspectorRef.current = null;
|
|
1515
1524
|
};
|
|
1516
1525
|
}, []);
|
|
1526
|
+
React$1.useEffect(() => {
|
|
1527
|
+
if (inspectorRef.current) inspectorRef.current.core = core ?? null;
|
|
1528
|
+
}, [core]);
|
|
1517
1529
|
React$1.useEffect(() => {
|
|
1518
1530
|
if (openRequest) inspectorRef.current?.openInspector("message_toolbar", openRequest);
|
|
1519
|
-
}, [
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
...rest,
|
|
1524
|
-
core: core ?? null
|
|
1531
|
+
}, [openRequest]);
|
|
1532
|
+
return /* @__PURE__ */ jsx("span", {
|
|
1533
|
+
ref: mountRef,
|
|
1534
|
+
style: { display: "contents" }
|
|
1525
1535
|
});
|
|
1526
1536
|
};
|
|
1527
1537
|
CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
@@ -1529,7 +1539,7 @@ CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
|
1529
1539
|
//#endregion
|
|
1530
1540
|
//#region src/v2/components/CopilotKitInspectorContext.tsx
|
|
1531
1541
|
const CopilotKitInspectorContext = React$1.createContext({
|
|
1532
|
-
|
|
1542
|
+
isInspectorEnabled: false,
|
|
1533
1543
|
openInspector: () => void 0
|
|
1534
1544
|
});
|
|
1535
1545
|
const CopilotKitInspectorContextProvider = CopilotKitInspectorContext.Provider;
|
|
@@ -3479,9 +3489,15 @@ function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
|
|
|
3479
3489
|
}, [value, warningMessage]);
|
|
3480
3490
|
return value;
|
|
3481
3491
|
}
|
|
3482
|
-
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,
|
|
3492
|
+
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 }) => {
|
|
3483
3493
|
const [shouldRenderInspector, setShouldRenderInspector] = useState(false);
|
|
3484
|
-
|
|
3494
|
+
useEffect(() => {
|
|
3495
|
+
setShouldRenderInspector(shouldEnableInspector({
|
|
3496
|
+
enableInspector,
|
|
3497
|
+
isBrowser: true,
|
|
3498
|
+
isDevelopment: process.env.NODE_ENV === "development"
|
|
3499
|
+
}));
|
|
3500
|
+
}, [enableInspector]);
|
|
3485
3501
|
const [inspectorOpenRequest, setInspectorOpenRequest] = useState(null);
|
|
3486
3502
|
const [runtimeA2UIEnabled, setRuntimeA2UIEnabled] = useState(false);
|
|
3487
3503
|
const [runtimeOpenGenUIEnabled, setRuntimeOpenGenUIEnabled] = useState(false);
|
|
@@ -3490,32 +3506,15 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3490
3506
|
const a2uiCatalogProvided = !!a2ui?.catalog;
|
|
3491
3507
|
const a2uiActive = runtimeA2UIEnabled || a2uiCatalogProvided;
|
|
3492
3508
|
const [runtimeLicenseStatus, setRuntimeLicenseStatus] = useState(void 0);
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
const isLocalhost = new Set(["localhost", "127.0.0.1"]).has(window.location?.hostname ?? "");
|
|
3496
|
-
const canShowLocalInspectorAction = process.env.NODE_ENV === "development" && isLocalhost;
|
|
3497
|
-
if (showDevConsole === true) {
|
|
3498
|
-
setShouldRenderInspector(true);
|
|
3499
|
-
setIsLocalInspectorEnabled(canShowLocalInspectorAction);
|
|
3500
|
-
} else if (showDevConsole === "auto") if (isLocalhost) {
|
|
3501
|
-
setShouldRenderInspector(true);
|
|
3502
|
-
setIsLocalInspectorEnabled(canShowLocalInspectorAction);
|
|
3503
|
-
} else {
|
|
3504
|
-
setShouldRenderInspector(false);
|
|
3505
|
-
setIsLocalInspectorEnabled(false);
|
|
3506
|
-
}
|
|
3507
|
-
else {
|
|
3508
|
-
setShouldRenderInspector(false);
|
|
3509
|
-
setIsLocalInspectorEnabled(false);
|
|
3510
|
-
}
|
|
3511
|
-
}, [showDevConsole]);
|
|
3509
|
+
const [runtimeEntitlements, setRuntimeEntitlements] = useState(void 0);
|
|
3510
|
+
const [runtimeEntitlementRetryPending, setRuntimeEntitlementRetryPending] = useState(false);
|
|
3512
3511
|
const requestInspectorOpen = useCallback((request) => {
|
|
3513
3512
|
setInspectorOpenRequest({ ...request });
|
|
3514
3513
|
}, []);
|
|
3515
3514
|
const inspectorContextValue = useMemo(() => ({
|
|
3516
|
-
|
|
3515
|
+
isInspectorEnabled: shouldRenderInspector,
|
|
3517
3516
|
openInspector: requestInspectorOpen
|
|
3518
|
-
}), [
|
|
3517
|
+
}), [shouldRenderInspector, requestInspectorOpen]);
|
|
3519
3518
|
const renderToolCallsList = useStableArrayProp(renderToolCalls, "renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.", (initial, next) => {
|
|
3520
3519
|
const key = (rc) => `${rc?.agentId ?? ""}:${rc?.name ?? ""}`;
|
|
3521
3520
|
const setFrom = (arr) => new Set(arr.map(key));
|
|
@@ -3699,6 +3698,8 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3699
3698
|
setRuntimeA2UIEnabled(copilotkit.a2uiEnabled);
|
|
3700
3699
|
setRuntimeOpenGenUIEnabled(copilotkit.openGenerativeUIEnabled);
|
|
3701
3700
|
setRuntimeLicenseStatus(copilotkit.licenseStatus);
|
|
3701
|
+
setRuntimeEntitlements(copilotkit.runtimeEntitlements);
|
|
3702
|
+
setRuntimeEntitlementRetryPending(copilotkit.runtimeEntitlementRetryPending);
|
|
3702
3703
|
};
|
|
3703
3704
|
const subscription = copilotkit.subscribe({ onRuntimeConnectionStatusChanged: syncRuntimeInfo });
|
|
3704
3705
|
syncRuntimeInfo();
|
|
@@ -3839,7 +3840,26 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3839
3840
|
copilotkit,
|
|
3840
3841
|
executingToolCallIds
|
|
3841
3842
|
}), [copilotkit, executingToolCallIds]);
|
|
3842
|
-
const
|
|
3843
|
+
const retryableRuntimeEntitlementFailure = runtimeEntitlements?.status !== "ready" && runtimeEntitlements?.error.retryable === true;
|
|
3844
|
+
const hasNonReadyRuntimeEntitlement = runtimeEntitlements !== void 0 && runtimeEntitlements.status !== "ready";
|
|
3845
|
+
const hasLegacyRuntimeEntitlementFallback = runtimeLicenseStatus === "valid" || runtimeLicenseStatus === "expiring";
|
|
3846
|
+
const runtimeEntitlementRetryInProgress = retryableRuntimeEntitlementFailure && runtimeEntitlementRetryPending && !hasLegacyRuntimeEntitlementFallback;
|
|
3847
|
+
const runtimeEntitlementFailureSettled = hasNonReadyRuntimeEntitlement && !runtimeEntitlementRetryInProgress && !hasLegacyRuntimeEntitlementFallback;
|
|
3848
|
+
const licenseContextValue = useMemo(() => {
|
|
3849
|
+
const runtimeLicenseContext = createLicenseContextValue(runtimeEntitlementRetryInProgress ? void 0 : runtimeLicenseStatus, runtimeEntitlements);
|
|
3850
|
+
if (!runtimeEntitlementFailureSettled) return runtimeLicenseContext;
|
|
3851
|
+
return {
|
|
3852
|
+
...runtimeLicenseContext,
|
|
3853
|
+
checkFeature: () => false,
|
|
3854
|
+
getLimit: () => null
|
|
3855
|
+
};
|
|
3856
|
+
}, [
|
|
3857
|
+
runtimeEntitlementFailureSettled,
|
|
3858
|
+
runtimeEntitlementRetryInProgress,
|
|
3859
|
+
runtimeEntitlements,
|
|
3860
|
+
runtimeLicenseStatus
|
|
3861
|
+
]);
|
|
3862
|
+
const runtimeLicenseWarningStatus = runtimeEntitlementRetryInProgress ? void 0 : licenseContextValue.status ?? void 0;
|
|
3843
3863
|
return /* @__PURE__ */ jsx(SandboxFunctionsContext.Provider, {
|
|
3844
3864
|
value: sandboxFunctionsList,
|
|
3845
3865
|
children: /* @__PURE__ */ jsx(CopilotKitContext.Provider, {
|
|
@@ -3856,14 +3876,13 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3856
3876
|
value: inspectorContextValue,
|
|
3857
3877
|
children: [children, shouldRenderInspector ? /* @__PURE__ */ jsx(CopilotKitInspector, {
|
|
3858
3878
|
core: copilotkit,
|
|
3859
|
-
defaultAnchor: inspectorDefaultAnchor,
|
|
3860
3879
|
openRequest: inspectorOpenRequest
|
|
3861
3880
|
}) : null]
|
|
3862
3881
|
}),
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3882
|
+
runtimeLicenseWarningStatus === "none" && !resolvedPublicKey && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "no_license" }),
|
|
3883
|
+
runtimeLicenseWarningStatus === "expired" && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "expired" }),
|
|
3884
|
+
runtimeLicenseWarningStatus === "invalid" && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "invalid" }),
|
|
3885
|
+
runtimeLicenseWarningStatus === "expiring" && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "expiring" })
|
|
3867
3886
|
]
|
|
3868
3887
|
})
|
|
3869
3888
|
})
|
|
@@ -3963,7 +3982,7 @@ const EMPTY_DEPS$1 = [];
|
|
|
3963
3982
|
function useFrontendTool(tool, deps) {
|
|
3964
3983
|
const { copilotkit } = useCopilotKit();
|
|
3965
3984
|
const extraDeps = deps ?? EMPTY_DEPS$1;
|
|
3966
|
-
|
|
3985
|
+
useLayoutEffect(() => {
|
|
3967
3986
|
const name = tool.name;
|
|
3968
3987
|
if (copilotkit.getTool({
|
|
3969
3988
|
toolName: name,
|
|
@@ -4330,6 +4349,8 @@ function safeStringifyForAttr(value) {
|
|
|
4330
4349
|
|
|
4331
4350
|
//#endregion
|
|
4332
4351
|
//#region src/v2/hooks/use-human-in-the-loop.tsx
|
|
4352
|
+
/** Registration name of a catch-all tool: handles any otherwise-unhandled call. */
|
|
4353
|
+
const WILDCARD_TOOL_NAME = "*";
|
|
4333
4354
|
function useHumanInTheLoop(tool, deps) {
|
|
4334
4355
|
const { copilotkit } = useCopilotKit();
|
|
4335
4356
|
const resolvePromiseRef = useRef(null);
|
|
@@ -4365,10 +4386,11 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
4365
4386
|
}, []);
|
|
4366
4387
|
const RenderComponent = useCallback((props) => {
|
|
4367
4388
|
const ToolComponent = tool.render;
|
|
4389
|
+
const name = tool.name === WILDCARD_TOOL_NAME ? props.name : tool.name;
|
|
4368
4390
|
if (props.status === ToolCallStatus.InProgress) {
|
|
4369
4391
|
const enhancedProps = {
|
|
4370
4392
|
...props,
|
|
4371
|
-
name
|
|
4393
|
+
name,
|
|
4372
4394
|
description: tool.description || "",
|
|
4373
4395
|
agentId: tool.agentId,
|
|
4374
4396
|
respond: void 0
|
|
@@ -4377,7 +4399,7 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
4377
4399
|
} else if (props.status === ToolCallStatus.Executing) {
|
|
4378
4400
|
const enhancedProps = {
|
|
4379
4401
|
...props,
|
|
4380
|
-
name
|
|
4402
|
+
name,
|
|
4381
4403
|
description: tool.description || "",
|
|
4382
4404
|
agentId: tool.agentId,
|
|
4383
4405
|
respond
|
|
@@ -4386,7 +4408,7 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
4386
4408
|
} else if (props.status === ToolCallStatus.Complete) {
|
|
4387
4409
|
const enhancedProps = {
|
|
4388
4410
|
...props,
|
|
4389
|
-
name
|
|
4411
|
+
name,
|
|
4390
4412
|
description: tool.description || "",
|
|
4391
4413
|
agentId: tool.agentId,
|
|
4392
4414
|
respond: void 0
|
|
@@ -4406,7 +4428,7 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
4406
4428
|
handler,
|
|
4407
4429
|
render: RenderComponent
|
|
4408
4430
|
}, deps);
|
|
4409
|
-
|
|
4431
|
+
useLayoutEffect(() => {
|
|
4410
4432
|
return () => {
|
|
4411
4433
|
copilotkit.removeHookRenderToolCall(tool.name, tool.agentId);
|
|
4412
4434
|
};
|
|
@@ -4871,8 +4893,12 @@ function normalizeStaticSuggestions(suggestions) {
|
|
|
4871
4893
|
}
|
|
4872
4894
|
|
|
4873
4895
|
//#endregion
|
|
4874
|
-
//#region src/v2/
|
|
4896
|
+
//#region src/v2/types/interrupt.ts
|
|
4897
|
+
/** Name of the legacy custom event agents emit to signal an interrupt. */
|
|
4875
4898
|
const INTERRUPT_EVENT_NAME = "on_interrupt";
|
|
4899
|
+
|
|
4900
|
+
//#endregion
|
|
4901
|
+
//#region src/v2/hooks/use-interrupt.tsx
|
|
4876
4902
|
function isPromiseLike(value) {
|
|
4877
4903
|
return (typeof value === "object" || typeof value === "function") && value !== null && typeof Reflect.get(value, "then") === "function";
|
|
4878
4904
|
}
|
|
@@ -5209,7 +5235,7 @@ function useThreadStoreSelector(store, selector) {
|
|
|
5209
5235
|
*/
|
|
5210
5236
|
function useThreads$1({ agentId, includeArchived, limit, enabled = true }) {
|
|
5211
5237
|
const { copilotkit } = useCopilotKit();
|
|
5212
|
-
const [store] = useState(() => ɵcreateThreadStore({ fetch:
|
|
5238
|
+
const [store] = useState(() => ɵcreateThreadStore({ fetch: copilotkit.ɵruntimeFetch }));
|
|
5213
5239
|
const coreThreads = useThreadStoreSelector(store, ɵselectThreads);
|
|
5214
5240
|
const threads = useMemo(() => coreThreads.map(({ id, agentId, name, archived, createdAt, updatedAt, lastRunAt }) => ({
|
|
5215
5241
|
id,
|
|
@@ -5908,21 +5934,35 @@ function CopilotChatToolCallsView({ message, messages = [] }) {
|
|
|
5908
5934
|
|
|
5909
5935
|
//#endregion
|
|
5910
5936
|
//#region src/v2/components/chat/CopilotChatAssistantMessage.tsx
|
|
5937
|
+
/**
|
|
5938
|
+
* Binds the Inspector action to the active chat without making the full
|
|
5939
|
+
* assistant message subscribe to chat configuration changes.
|
|
5940
|
+
*/
|
|
5941
|
+
function BoundInspectorButton({ inspectorButton, messageId, openInspector, ...props }) {
|
|
5942
|
+
const chatConfiguration = useCopilotChatConfiguration();
|
|
5943
|
+
return renderSlot(inspectorButton, CopilotChatAssistantMessage.InspectorButton, {
|
|
5944
|
+
...props,
|
|
5945
|
+
onClick: () => openInspector({
|
|
5946
|
+
messageId,
|
|
5947
|
+
threadId: chatConfiguration?.threadId,
|
|
5948
|
+
agentId: chatConfiguration?.agentId
|
|
5949
|
+
})
|
|
5950
|
+
});
|
|
5951
|
+
}
|
|
5911
5952
|
function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible = true, markdownRenderer, toolbar, copyButton, inspectorButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }) {
|
|
5912
5953
|
useKatexStyles();
|
|
5913
|
-
const {
|
|
5914
|
-
const chatConfiguration = useCopilotChatConfiguration();
|
|
5954
|
+
const { isInspectorEnabled, openInspector } = useCopilotKitInspector();
|
|
5915
5955
|
const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
|
|
5916
5956
|
const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
|
|
5917
5957
|
if (message.content) return await copyToClipboard(message.content);
|
|
5918
5958
|
return false;
|
|
5919
5959
|
} });
|
|
5920
5960
|
const boundThumbsUpButton = renderSlot(thumbsUpButton, CopilotChatAssistantMessage.ThumbsUpButton, { onClick: onThumbsUp ? () => onThumbsUp(message) : void 0 });
|
|
5921
|
-
const boundInspectorButton =
|
|
5961
|
+
const boundInspectorButton = /* @__PURE__ */ jsx(BoundInspectorButton, {
|
|
5962
|
+
inspectorButton,
|
|
5922
5963
|
messageId: message.id,
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
}) });
|
|
5964
|
+
openInspector
|
|
5965
|
+
});
|
|
5926
5966
|
const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown ? () => onThumbsDown(message) : void 0 });
|
|
5927
5967
|
const boundReadAloudButton = renderSlot(readAloudButton, CopilotChatAssistantMessage.ReadAloudButton, { onClick: onReadAloud ? () => onReadAloud(message) : void 0 });
|
|
5928
5968
|
const boundRegenerateButton = renderSlot(regenerateButton, CopilotChatAssistantMessage.RegenerateButton, { onClick: onRegenerate ? () => onRegenerate(message) : void 0 });
|
|
@@ -5930,7 +5970,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
5930
5970
|
className: "cpk:flex cpk:items-center cpk:gap-1",
|
|
5931
5971
|
children: [
|
|
5932
5972
|
boundCopyButton,
|
|
5933
|
-
|
|
5973
|
+
isInspectorEnabled && boundInspectorButton,
|
|
5934
5974
|
(onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
|
|
5935
5975
|
(onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
|
|
5936
5976
|
(onReadAloud || readAloudButton) && boundReadAloudButton,
|
|
@@ -5944,7 +5984,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
5944
5984
|
});
|
|
5945
5985
|
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
5946
5986
|
const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
|
|
5947
|
-
const shouldShowToolbar = toolbarVisible && (hasContent ||
|
|
5987
|
+
const shouldShowToolbar = toolbarVisible && (hasContent || isInspectorEnabled) && !(isRunning && isLatestAssistantMessage);
|
|
5948
5988
|
if (children) return /* @__PURE__ */ jsx("div", {
|
|
5949
5989
|
"data-copilotkit": true,
|
|
5950
5990
|
style: { display: "contents" },
|
|
@@ -8502,7 +8542,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
8502
8542
|
const startRunActivityReconnectRef = useRef(null);
|
|
8503
8543
|
const runtimeStatus = copilotkit.runtimeConnectionStatus === CopilotKitCoreRuntimeConnectionStatus.Connected ? "Connected" : copilotkit.runtimeConnectionStatus;
|
|
8504
8544
|
const hasNativeIntelligenceRunActivity = hasExplicitThreadId && runtimeStatus === "Connected" && !!copilotkit.intelligence?.wsUrl && copilotkit.threadEndpoints?.realtimeMetadata === true;
|
|
8505
|
-
const [standaloneRunActivityStore] = useState(() => ɵcreateThreadStore({ fetch:
|
|
8545
|
+
const [standaloneRunActivityStore] = useState(() => ɵcreateThreadStore({ fetch: copilotkit.ɵruntimeFetch }));
|
|
8506
8546
|
const previousThreadRef = useRef(null);
|
|
8507
8547
|
const hasExplicitThreadIdRef = useRef(hasExplicitThreadId);
|
|
8508
8548
|
hasExplicitThreadIdRef.current = hasExplicitThreadId;
|
|
@@ -11515,20 +11555,42 @@ function CoAgentStateRenderBridge(props) {
|
|
|
11515
11555
|
|
|
11516
11556
|
//#endregion
|
|
11517
11557
|
//#region src/v1-deprecated/components/CopilotListeners.tsx
|
|
11518
|
-
|
|
11519
|
-
|
|
11520
|
-
const
|
|
11558
|
+
function isPredictStateTool(value) {
|
|
11559
|
+
if (value === null || typeof value !== "object") return false;
|
|
11560
|
+
const config = value;
|
|
11561
|
+
return typeof config.tool === "string" && typeof config.state_key === "string" && (config.tool_argument === void 0 || typeof config.tool_argument === "string");
|
|
11562
|
+
}
|
|
11563
|
+
function getPredictStateUpdate(config, toolCallName, partialToolCallArgs) {
|
|
11564
|
+
if (config.tool !== toolCallName) return void 0;
|
|
11565
|
+
const emittedState = typeof partialToolCallArgs === "string" ? partialJSONParse(partialToolCallArgs) : partialToolCallArgs;
|
|
11566
|
+
if (emittedState === null || typeof emittedState !== "object") return;
|
|
11567
|
+
if (config.tool_argument) {
|
|
11568
|
+
if (!(config.tool_argument in emittedState)) return void 0;
|
|
11569
|
+
return { [config.state_key]: emittedState[config.tool_argument] };
|
|
11570
|
+
}
|
|
11571
|
+
return { [config.state_key]: emittedState };
|
|
11572
|
+
}
|
|
11573
|
+
function createPredictStateSubscriber(agent, predictStateToolsRef) {
|
|
11574
|
+
return {
|
|
11521
11575
|
onCustomEvent: ({ event }) => {
|
|
11522
|
-
if (event.name === "PredictState") predictStateToolsRef.current = event.value;
|
|
11576
|
+
if (event.name === "PredictState") predictStateToolsRef.current = Array.isArray(event.value) ? event.value.filter(isPredictStateTool) : [];
|
|
11523
11577
|
},
|
|
11524
11578
|
onToolCallArgsEvent: ({ partialToolCallArgs, toolCallName }) => {
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
const
|
|
11528
|
-
|
|
11579
|
+
const updates = {};
|
|
11580
|
+
predictStateToolsRef.current.forEach((config) => {
|
|
11581
|
+
const update = getPredictStateUpdate(config, toolCallName, partialToolCallArgs);
|
|
11582
|
+
if (update) Object.assign(updates, update);
|
|
11583
|
+
});
|
|
11584
|
+
if (Object.keys(updates).length > 0) agent.setState({
|
|
11585
|
+
...agent.state,
|
|
11586
|
+
...updates
|
|
11529
11587
|
});
|
|
11530
11588
|
}
|
|
11531
|
-
}
|
|
11589
|
+
};
|
|
11590
|
+
}
|
|
11591
|
+
const usePredictStateSubscription = (agent) => {
|
|
11592
|
+
const predictStateToolsRef = useRef([]);
|
|
11593
|
+
const getSubscriber = useCallback((subscriptionAgent) => createPredictStateSubscriber(subscriptionAgent, predictStateToolsRef), []);
|
|
11532
11594
|
useEffect(() => {
|
|
11533
11595
|
if (!agent) return;
|
|
11534
11596
|
const subscriber = getSubscriber(agent);
|
|
@@ -11587,7 +11649,6 @@ function CopilotListeners() {
|
|
|
11587
11649
|
//#region src/v1-deprecated/components/copilot-provider/copilotkit.tsx
|
|
11588
11650
|
function CopilotKit({ children, ...props }) {
|
|
11589
11651
|
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
11590
|
-
const showInspector = shouldShowDevConsole(props.enableInspector);
|
|
11591
11652
|
const publicApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
11592
11653
|
const renderArr = useMemo(() => [{ render: CoAgentStateRenderBridge }], []);
|
|
11593
11654
|
const { onError: _onError, ...v2Props } = props;
|
|
@@ -11600,7 +11661,7 @@ function CopilotKit({ children, ...props }) {
|
|
|
11600
11661
|
threadId: props.threadId,
|
|
11601
11662
|
children: /* @__PURE__ */ jsx(CopilotKitProvider, {
|
|
11602
11663
|
...v2Props,
|
|
11603
|
-
|
|
11664
|
+
enableInspector: props.enableInspector,
|
|
11604
11665
|
renderCustomMessages: renderArr,
|
|
11605
11666
|
children: /* @__PURE__ */ jsx(CopilotKitInternal, {
|
|
11606
11667
|
...props,
|
|
@@ -12082,5 +12143,5 @@ function validateProps(props) {
|
|
|
12082
12143
|
}
|
|
12083
12144
|
|
|
12084
12145
|
//#endregion
|
|
12085
|
-
export {
|
|
12086
|
-
//# sourceMappingURL=copilotkit-
|
|
12146
|
+
export { useAgentContext as $, CopilotChatMessageView as A, AudioRecorderError as At, CopilotChatAssistantMessage_default as B, CopilotModalHeader as C, MCPAppsActivityContentSchema as Ct, CopilotChat as D, CopilotKitInspector as Dt, DefaultOpenIcon as E, ɵrunMcpFollowUp as Et, CopilotChatSuggestionView as F, useLearnFromUserActionInCurrentThread as G, useLearningContainersInCurrentThread as H, CopilotChatSuggestionPill as I, useThreads$1 as J, useLearnFromUserAction as K, CopilotChatReasoningMessage_default as L, IntelligenceIndicator as M, CopilotChatConfigurationProvider as Mt, getIntelligenceTurnAnchors as N, useCopilotChatConfiguration as Nt, CopilotChatView_default as O, useRenderToolCall as Ot, IntelligenceIndicatorView as P, useSuggestions as Q, CopilotChatUserMessage_default as R, CopilotSidebarView as S, useSandboxFunctions as St, DefaultCloseIcon as T, MCPAppsActivityType as Tt, useLearningContainers as U, CopilotChatToolCallsView as V, useAttachments as W, INTERRUPT_EVENT_NAME as X, useInterrupt as Y, useConfigureSuggestions as Z, WildcardToolCallRender as _, OpenGenerativeUIActivityRenderer as _t, ThreadsProvider as a, useRenderTool as at, CopilotSidebar as b, OpenGenerativeUIToolRenderer as bt, CoAgentStateRendersProvider as c, useRenderActivityMessage as ct, shouldShowDevConsole as d, useCopilotKit$1 as dt, useCapabilities as et, useToast as f, useLicenseContext$1 as ft, useCopilotContext as g, GenerateSandboxedUiArgsSchema as gt, CopilotContext as h, createA2UIMessageRenderer as ht, ThreadsContext as i, useDefaultRenderTool as it, INTELLIGENCE_TURN_HEAD as j, CopilotChatAudioRecorder as jt, CopilotChatAttachmentQueue as k, CopilotChatInput_default as kt, useCoAgentStateRenders as l, useRenderCustomMessages as lt, useCopilotMessagesContext as m, defineToolCallRenderer as mt, defaultCopilotContextCategories as n, useAgent as nt, useThreads as o, useComponent as ot, CopilotMessagesContext as p, CopilotKitCoreReact as pt, useMemories as q, CoAgentStateRenderBridge as r, useHumanInTheLoop as rt, CoAgentStateRendersContext as s, useFrontendTool as st, CopilotKit as t, UseAgentUpdate as tt, useAsyncCallback as u, CopilotKitProvider as ut, CopilotThreadsDrawer as v, OpenGenerativeUIActivityType as vt, CopilotChatToggleButton as w, MCPAppsActivityRenderer as wt, CopilotPopupView as x, SandboxFunctionsContext as xt, CopilotPopup as y, OpenGenerativeUIContentSchema as yt, CopilotChatAttachmentRenderer as z };
|
|
12147
|
+
//# sourceMappingURL=copilotkit-B7aFKfQR.mjs.map
|