@copilotkit/react-core 1.69.2 → 1.69.3
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-Ba7qwYt3.cjs → copilotkit-BPeh62mW.cjs} +73 -56
- package/dist/copilotkit-BPeh62mW.cjs.map +1 -0
- package/dist/{copilotkit-CF1Pm2VG.d.cts → copilotkit-CrNUgJiq.d.cts} +17 -15
- package/dist/{copilotkit-CF1Pm2VG.d.cts.map → copilotkit-CrNUgJiq.d.cts.map} +1 -1
- package/dist/{copilotkit-TdM-5onZ.d.mts → copilotkit-DgO31tBq.d.mts} +17 -15
- package/dist/{copilotkit-TdM-5onZ.d.mts.map → copilotkit-DgO31tBq.d.mts.map} +1 -1
- package/dist/{copilotkit-BmW2sFH6.mjs → copilotkit-JdHy0xdu.mjs} +74 -57
- package/dist/copilotkit-JdHy0xdu.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +73 -55
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +1 -1
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.mjs +1 -1
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +76 -58
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -8
- 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/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_copilotkit = require('./copilotkit-
|
|
4
|
+
const require_copilotkit = require('./copilotkit-BPeh62mW.cjs');
|
|
5
5
|
let react = require("react");
|
|
6
6
|
react = require_copilotkit.__toESM(react);
|
|
7
7
|
let _copilotkit_core = require("@copilotkit/core");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $n as LangGraphInterruptActionSetter, Cr as FrontendActionAvailability, Jn as CopilotContext, Kn as CoagentInChatRenderFunction, Qn as LangGraphInterruptAction, Sr as FrontendAction, X as useAgent, Xn as useCopilotContext, Yn as CopilotContextParams, Zn as CoAgentStateRender, _r as ActionRenderPropsNoArgs, ar as CrewsAgentState, br as CatchAllActionRenderProps, cr as CrewsStateItem, dr as CopilotChatSuggestionConfiguration, er as LangGraphInterruptActionSetterArgs, fr as SystemMessageFunction, gr as ActionRenderProps, hr as TreeNode, ir as QueuedInterruptEvent, lr as CrewsTaskStateItem, mr as Tree, n as defaultCopilotContextCategories, nr as LangGraphInterruptRenderHandlerProps, or as CrewsResponse, pr as DocumentPointer, qn as CopilotApiConfig, r as CopilotKitProps, rr as LangGraphInterruptRenderProps, sr as CrewsResponseStatus, t as CopilotKit, tr as LangGraphInterruptRender, ur as CrewsToolStateItem, vr as ActionRenderPropsNoArgsWait, wr as RenderFunctionStatus, xr as CatchAllFrontendAction, yr as ActionRenderPropsWait, yt as useRenderToolCall$1 } from "./copilotkit-
|
|
1
|
+
import { $n as LangGraphInterruptActionSetter, Cr as FrontendActionAvailability, Jn as CopilotContext, Kn as CoagentInChatRenderFunction, Qn as LangGraphInterruptAction, Sr as FrontendAction, X as useAgent, Xn as useCopilotContext, Yn as CopilotContextParams, Zn as CoAgentStateRender, _r as ActionRenderPropsNoArgs, ar as CrewsAgentState, br as CatchAllActionRenderProps, cr as CrewsStateItem, dr as CopilotChatSuggestionConfiguration, er as LangGraphInterruptActionSetterArgs, fr as SystemMessageFunction, gr as ActionRenderProps, hr as TreeNode, ir as QueuedInterruptEvent, lr as CrewsTaskStateItem, mr as Tree, n as defaultCopilotContextCategories, nr as LangGraphInterruptRenderHandlerProps, or as CrewsResponse, pr as DocumentPointer, qn as CopilotApiConfig, r as CopilotKitProps, rr as LangGraphInterruptRenderProps, sr as CrewsResponseStatus, t as CopilotKit, tr as LangGraphInterruptRender, ur as CrewsToolStateItem, vr as ActionRenderPropsNoArgsWait, wr as RenderFunctionStatus, xr as CatchAllFrontendAction, yr as ActionRenderPropsWait, yt as useRenderToolCall$1 } from "./copilotkit-CrNUgJiq.cjs";
|
|
2
2
|
import "./v2/index.cjs";
|
|
3
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
import { CopilotRuntimeClient, CopilotRuntimeClientOptions, ForwardedParametersInput, Message } from "@copilotkit/runtime-client-gql";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $n as LangGraphInterruptActionSetter, Cr as FrontendActionAvailability, Jn as CopilotContext, Kn as CoagentInChatRenderFunction, Qn as LangGraphInterruptAction, Sr as FrontendAction, X as useAgent, Xn as useCopilotContext, Yn as CopilotContextParams, Zn as CoAgentStateRender, _r as ActionRenderPropsNoArgs, ar as CrewsAgentState, br as CatchAllActionRenderProps, cr as CrewsStateItem, dr as CopilotChatSuggestionConfiguration, er as LangGraphInterruptActionSetterArgs, fr as SystemMessageFunction, gr as ActionRenderProps, hr as TreeNode, ir as QueuedInterruptEvent, lr as CrewsTaskStateItem, mr as Tree, n as defaultCopilotContextCategories, nr as LangGraphInterruptRenderHandlerProps, or as CrewsResponse, pr as DocumentPointer, qn as CopilotApiConfig, r as CopilotKitProps, rr as LangGraphInterruptRenderProps, sr as CrewsResponseStatus, t as CopilotKit, tr as LangGraphInterruptRender, ur as CrewsToolStateItem, vr as ActionRenderPropsNoArgsWait, wr as RenderFunctionStatus, xr as CatchAllFrontendAction, yr as ActionRenderPropsWait, yt as useRenderToolCall$1 } from "./copilotkit-
|
|
1
|
+
import { $n as LangGraphInterruptActionSetter, Cr as FrontendActionAvailability, Jn as CopilotContext, Kn as CoagentInChatRenderFunction, Qn as LangGraphInterruptAction, Sr as FrontendAction, X as useAgent, Xn as useCopilotContext, Yn as CopilotContextParams, Zn as CoAgentStateRender, _r as ActionRenderPropsNoArgs, ar as CrewsAgentState, br as CatchAllActionRenderProps, cr as CrewsStateItem, dr as CopilotChatSuggestionConfiguration, er as LangGraphInterruptActionSetterArgs, fr as SystemMessageFunction, gr as ActionRenderProps, hr as TreeNode, ir as QueuedInterruptEvent, lr as CrewsTaskStateItem, mr as Tree, n as defaultCopilotContextCategories, nr as LangGraphInterruptRenderHandlerProps, or as CrewsResponse, pr as DocumentPointer, qn as CopilotApiConfig, r as CopilotKitProps, rr as LangGraphInterruptRenderProps, sr as CrewsResponseStatus, t as CopilotKit, tr as LangGraphInterruptRender, ur as CrewsToolStateItem, vr as ActionRenderPropsNoArgsWait, wr as RenderFunctionStatus, xr as CatchAllFrontendAction, yr as ActionRenderPropsWait, yt as useRenderToolCall$1 } from "./copilotkit-DgO31tBq.mjs";
|
|
2
2
|
import "./v2/index.mjs";
|
|
3
3
|
import React, { ReactNode, RefObject, SetStateAction } from "react";
|
|
4
4
|
import { StaticSuggestionsConfig, Suggestion } from "@copilotkit/core";
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { Dt as useRenderToolCall$1, Mt as useCopilotChatConfiguration, X as useConfigureSuggestions, Y as useInterrupt, Z as useSuggestions, a as ThreadsProvider, c as CoAgentStateRendersProvider, ct as useRenderCustomMessages, d as shouldShowDevConsole, f as useToast, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, nt as useHumanInTheLoop$1, o as useThreads, ot as useFrontendTool$1, p as CopilotMessagesContext, pt as defineToolCallRenderer, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, tt as useAgent, u as useAsyncCallback, ut as useCopilotKit } from "./copilotkit-
|
|
3
|
+
import { Dt as useRenderToolCall$1, Mt as useCopilotChatConfiguration, X as useConfigureSuggestions, Y as useInterrupt, Z as useSuggestions, a as ThreadsProvider, c as CoAgentStateRendersProvider, ct as useRenderCustomMessages, d as shouldShowDevConsole, f as useToast, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, nt as useHumanInTheLoop$1, o as useThreads, ot as useFrontendTool$1, p as CopilotMessagesContext, pt as defineToolCallRenderer, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, tt as useAgent, u as useAsyncCallback, ut as useCopilotKit } from "./copilotkit-JdHy0xdu.mjs";
|
|
4
4
|
import React, { Fragment, createElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus } from "@copilotkit/core";
|
|
6
6
|
import { AGUIConnectNotImplementedError, HttpAgent } from "@ag-ui/client";
|
package/dist/index.umd.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
(function(global, factory) {
|
|
4
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@copilotkit/core'), require('@ag-ui/client'), require('@copilotkit/shared'), require('react/jsx-runtime'), require('zod'), require('@
|
|
5
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@copilotkit/core', '@ag-ui/client', '@copilotkit/shared', 'react/jsx-runtime', 'zod', '@
|
|
6
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitReactCore = {}), global.React,global.CopilotKitCore,global.AgUIClient,global.CopilotKitShared,global.ReactJsxRuntime,global.Zod,global.
|
|
7
|
-
})(this, function(exports, react, _copilotkit_core, _ag_ui_client, _copilotkit_shared, react_jsx_runtime, zod,
|
|
4
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@copilotkit/core'), require('@ag-ui/client'), require('@copilotkit/shared'), require('react/jsx-runtime'), require('zod'), require('@copilotkit/a2ui-renderer'), require('zod-to-json-schema'), require('react-dom'), require('react-markdown'), require('@copilotkit/runtime-client-gql')) :
|
|
5
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@copilotkit/core', '@ag-ui/client', '@copilotkit/shared', 'react/jsx-runtime', 'zod', '@copilotkit/a2ui-renderer', 'zod-to-json-schema', 'react-dom', 'react-markdown', '@copilotkit/runtime-client-gql'], factory) :
|
|
6
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitReactCore = {}), global.React,global.CopilotKitCore,global.AgUIClient,global.CopilotKitShared,global.ReactJsxRuntime,global.Zod,global.CopilotKitA2UIRenderer,global.zod_to_json_schema,global.ReactDOM,global.ReactMarkdown,global.CopilotKitRuntimeClientGQL));
|
|
7
|
+
})(this, function(exports, react, _copilotkit_core, _ag_ui_client, _copilotkit_shared, react_jsx_runtime, zod, _copilotkit_a2ui_renderer, zod_to_json_schema, react_dom, react_markdown, _copilotkit_runtime_client_gql) {
|
|
8
8
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
9
9
|
//#region \0rolldown/runtime.js
|
|
10
10
|
var __create = Object.create;
|
|
@@ -90,7 +90,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
90
90
|
assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
|
|
91
91
|
assistantMessageToolbarCopyMessageLabel: "Copy",
|
|
92
92
|
assistantMessageToolbarInspectorLabel: "View in Inspector",
|
|
93
|
-
assistantMessageToolbarInspectorLocalOnlyLabel: "
|
|
93
|
+
assistantMessageToolbarInspectorLocalOnlyLabel: "Development Only",
|
|
94
94
|
assistantMessageToolbarThumbsUpLabel: "Good response",
|
|
95
95
|
assistantMessageToolbarThumbsDownLabel: "Bad response",
|
|
96
96
|
assistantMessageToolbarReadAloudLabel: "Read aloud",
|
|
@@ -480,32 +480,43 @@ react_markdown = __toESM(react_markdown);
|
|
|
480
480
|
|
|
481
481
|
//#endregion
|
|
482
482
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
483
|
-
const CopilotKitInspector = ({ core, openRequest
|
|
484
|
-
const
|
|
483
|
+
const CopilotKitInspector = ({ core, openRequest }) => {
|
|
484
|
+
const mountRef = react.useRef(null);
|
|
485
485
|
const inspectorRef = react.useRef(null);
|
|
486
|
+
const latestCoreRef = react.useRef(core ?? null);
|
|
487
|
+
const latestOpenRequestRef = react.useRef(openRequest);
|
|
488
|
+
latestCoreRef.current = core ?? null;
|
|
489
|
+
latestOpenRequestRef.current = openRequest;
|
|
486
490
|
react.useEffect(() => {
|
|
487
491
|
let mounted = true;
|
|
492
|
+
let inspector = null;
|
|
488
493
|
import("@copilotkit/web-inspector").then((mod) => {
|
|
494
|
+
if (!mounted || !mountRef.current) return;
|
|
489
495
|
mod.defineWebInspector?.();
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
if (
|
|
496
|
+
inspector = mountRef.current.ownerDocument.createElement(mod.WEB_INSPECTOR_TAG);
|
|
497
|
+
mod.configureWebInspectorElement(inspector, latestCoreRef.current);
|
|
498
|
+
mountRef.current.appendChild(inspector);
|
|
499
|
+
inspectorRef.current = inspector;
|
|
500
|
+
const request = latestOpenRequestRef.current;
|
|
501
|
+
if (request) inspector.openInspector("message_toolbar", request);
|
|
502
|
+
}).catch((error) => {
|
|
503
|
+
console.error("Failed to load CopilotKit inspector:", error);
|
|
496
504
|
});
|
|
497
505
|
return () => {
|
|
498
506
|
mounted = false;
|
|
507
|
+
inspector?.remove();
|
|
508
|
+
if (inspectorRef.current === inspector) inspectorRef.current = null;
|
|
499
509
|
};
|
|
500
510
|
}, []);
|
|
511
|
+
react.useEffect(() => {
|
|
512
|
+
if (inspectorRef.current) inspectorRef.current.core = core ?? null;
|
|
513
|
+
}, [core]);
|
|
501
514
|
react.useEffect(() => {
|
|
502
515
|
if (openRequest) inspectorRef.current?.openInspector("message_toolbar", openRequest);
|
|
503
|
-
}, [
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
...rest,
|
|
508
|
-
core: core ?? null
|
|
516
|
+
}, [openRequest]);
|
|
517
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
518
|
+
ref: mountRef,
|
|
519
|
+
style: { display: "contents" }
|
|
509
520
|
});
|
|
510
521
|
};
|
|
511
522
|
CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
@@ -513,7 +524,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
513
524
|
//#endregion
|
|
514
525
|
//#region src/v2/components/CopilotKitInspectorContext.tsx
|
|
515
526
|
const CopilotKitInspectorContext = react.createContext({
|
|
516
|
-
|
|
527
|
+
isInspectorEnabled: false,
|
|
517
528
|
openInspector: () => void 0
|
|
518
529
|
});
|
|
519
530
|
const CopilotKitInspectorContextProvider = CopilotKitInspectorContext.Provider;
|
|
@@ -2335,9 +2346,15 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2335
2346
|
}, [value, warningMessage]);
|
|
2336
2347
|
return value;
|
|
2337
2348
|
}
|
|
2338
|
-
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,
|
|
2349
|
+
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 }) => {
|
|
2339
2350
|
const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
|
|
2340
|
-
|
|
2351
|
+
(0, react.useEffect)(() => {
|
|
2352
|
+
setShouldRenderInspector((0, _copilotkit_shared.shouldEnableInspector)({
|
|
2353
|
+
enableInspector,
|
|
2354
|
+
isBrowser: true,
|
|
2355
|
+
isDevelopment: process.env.NODE_ENV === "development"
|
|
2356
|
+
}));
|
|
2357
|
+
}, [enableInspector]);
|
|
2341
2358
|
const [inspectorOpenRequest, setInspectorOpenRequest] = (0, react.useState)(null);
|
|
2342
2359
|
const [runtimeA2UIEnabled, setRuntimeA2UIEnabled] = (0, react.useState)(false);
|
|
2343
2360
|
const [runtimeOpenGenUIEnabled, setRuntimeOpenGenUIEnabled] = (0, react.useState)(false);
|
|
@@ -2346,32 +2363,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2346
2363
|
const a2uiCatalogProvided = !!a2ui?.catalog;
|
|
2347
2364
|
const a2uiActive = runtimeA2UIEnabled || a2uiCatalogProvided;
|
|
2348
2365
|
const [runtimeLicenseStatus, setRuntimeLicenseStatus] = (0, react.useState)(void 0);
|
|
2349
|
-
(0, react.useEffect)(() => {
|
|
2350
|
-
if (typeof window === "undefined") return;
|
|
2351
|
-
const isLocalhost = new Set(["localhost", "127.0.0.1"]).has(window.location?.hostname ?? "");
|
|
2352
|
-
const canShowLocalInspectorAction = process.env.NODE_ENV === "development" && isLocalhost;
|
|
2353
|
-
if (showDevConsole === true) {
|
|
2354
|
-
setShouldRenderInspector(true);
|
|
2355
|
-
setIsLocalInspectorEnabled(canShowLocalInspectorAction);
|
|
2356
|
-
} else if (showDevConsole === "auto") if (isLocalhost) {
|
|
2357
|
-
setShouldRenderInspector(true);
|
|
2358
|
-
setIsLocalInspectorEnabled(canShowLocalInspectorAction);
|
|
2359
|
-
} else {
|
|
2360
|
-
setShouldRenderInspector(false);
|
|
2361
|
-
setIsLocalInspectorEnabled(false);
|
|
2362
|
-
}
|
|
2363
|
-
else {
|
|
2364
|
-
setShouldRenderInspector(false);
|
|
2365
|
-
setIsLocalInspectorEnabled(false);
|
|
2366
|
-
}
|
|
2367
|
-
}, [showDevConsole]);
|
|
2368
2366
|
const requestInspectorOpen = (0, react.useCallback)((request) => {
|
|
2369
2367
|
setInspectorOpenRequest({ ...request });
|
|
2370
2368
|
}, []);
|
|
2371
2369
|
const inspectorContextValue = (0, react.useMemo)(() => ({
|
|
2372
|
-
|
|
2370
|
+
isInspectorEnabled: shouldRenderInspector,
|
|
2373
2371
|
openInspector: requestInspectorOpen
|
|
2374
|
-
}), [
|
|
2372
|
+
}), [shouldRenderInspector, requestInspectorOpen]);
|
|
2375
2373
|
const renderToolCallsList = useStableArrayProp(renderToolCalls, "renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.", (initial, next) => {
|
|
2376
2374
|
const key = (rc) => `${rc?.agentId ?? ""}:${rc?.name ?? ""}`;
|
|
2377
2375
|
const setFrom = (arr) => new Set(arr.map(key));
|
|
@@ -2712,7 +2710,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2712
2710
|
value: inspectorContextValue,
|
|
2713
2711
|
children: [children, shouldRenderInspector ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInspector, {
|
|
2714
2712
|
core: copilotkit,
|
|
2715
|
-
defaultAnchor: inspectorDefaultAnchor,
|
|
2716
2713
|
openRequest: inspectorOpenRequest
|
|
2717
2714
|
}) : null]
|
|
2718
2715
|
}),
|
|
@@ -5163,20 +5160,42 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5163
5160
|
|
|
5164
5161
|
//#endregion
|
|
5165
5162
|
//#region src/v1-deprecated/components/CopilotListeners.tsx
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
const
|
|
5163
|
+
function isPredictStateTool(value) {
|
|
5164
|
+
if (value === null || typeof value !== "object") return false;
|
|
5165
|
+
const config = value;
|
|
5166
|
+
return typeof config.tool === "string" && typeof config.state_key === "string" && (config.tool_argument === void 0 || typeof config.tool_argument === "string");
|
|
5167
|
+
}
|
|
5168
|
+
function getPredictStateUpdate(config, toolCallName, partialToolCallArgs) {
|
|
5169
|
+
if (config.tool !== toolCallName) return void 0;
|
|
5170
|
+
const emittedState = typeof partialToolCallArgs === "string" ? (0, _copilotkit_shared.partialJSONParse)(partialToolCallArgs) : partialToolCallArgs;
|
|
5171
|
+
if (emittedState === null || typeof emittedState !== "object") return;
|
|
5172
|
+
if (config.tool_argument) {
|
|
5173
|
+
if (!(config.tool_argument in emittedState)) return void 0;
|
|
5174
|
+
return { [config.state_key]: emittedState[config.tool_argument] };
|
|
5175
|
+
}
|
|
5176
|
+
return { [config.state_key]: emittedState };
|
|
5177
|
+
}
|
|
5178
|
+
function createPredictStateSubscriber(agent, predictStateToolsRef) {
|
|
5179
|
+
return {
|
|
5169
5180
|
onCustomEvent: ({ event }) => {
|
|
5170
|
-
if (event.name === "PredictState") predictStateToolsRef.current = event.value;
|
|
5181
|
+
if (event.name === "PredictState") predictStateToolsRef.current = Array.isArray(event.value) ? event.value.filter(isPredictStateTool) : [];
|
|
5171
5182
|
},
|
|
5172
5183
|
onToolCallArgsEvent: ({ partialToolCallArgs, toolCallName }) => {
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
const
|
|
5176
|
-
|
|
5184
|
+
const updates = {};
|
|
5185
|
+
predictStateToolsRef.current.forEach((config) => {
|
|
5186
|
+
const update = getPredictStateUpdate(config, toolCallName, partialToolCallArgs);
|
|
5187
|
+
if (update) Object.assign(updates, update);
|
|
5188
|
+
});
|
|
5189
|
+
if (Object.keys(updates).length > 0) agent.setState({
|
|
5190
|
+
...agent.state,
|
|
5191
|
+
...updates
|
|
5177
5192
|
});
|
|
5178
5193
|
}
|
|
5179
|
-
}
|
|
5194
|
+
};
|
|
5195
|
+
}
|
|
5196
|
+
const usePredictStateSubscription = (agent) => {
|
|
5197
|
+
const predictStateToolsRef = (0, react.useRef)([]);
|
|
5198
|
+
const getSubscriber = (0, react.useCallback)((subscriptionAgent) => createPredictStateSubscriber(subscriptionAgent, predictStateToolsRef), []);
|
|
5180
5199
|
(0, react.useEffect)(() => {
|
|
5181
5200
|
if (!agent) return;
|
|
5182
5201
|
const subscriber = getSubscriber(agent);
|
|
@@ -5235,7 +5254,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5235
5254
|
//#region src/v1-deprecated/components/copilot-provider/copilotkit.tsx
|
|
5236
5255
|
function CopilotKit({ children, ...props }) {
|
|
5237
5256
|
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
5238
|
-
const showInspector = shouldShowDevConsole(props.enableInspector);
|
|
5239
5257
|
const publicApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
5240
5258
|
const renderArr = (0, react.useMemo)(() => [{ render: CoAgentStateRenderBridge }], []);
|
|
5241
5259
|
const { onError: _onError, ...v2Props } = props;
|
|
@@ -5248,7 +5266,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5248
5266
|
threadId: props.threadId,
|
|
5249
5267
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitProvider, {
|
|
5250
5268
|
...v2Props,
|
|
5251
|
-
|
|
5269
|
+
enableInspector: props.enableInspector,
|
|
5252
5270
|
renderCustomMessages: renderArr,
|
|
5253
5271
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInternal, {
|
|
5254
5272
|
...props,
|