@copilotkit/react-core 1.69.1 → 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-Dr0speVK.cjs → copilotkit-BPeh62mW.cjs} +104 -341
- package/dist/copilotkit-BPeh62mW.cjs.map +1 -0
- package/dist/{copilotkit-Hl1t9Y1v.d.cts → copilotkit-CrNUgJiq.d.cts} +18 -21
- package/dist/copilotkit-CrNUgJiq.d.cts.map +1 -0
- package/dist/{copilotkit-DYKpg4pD.d.mts → copilotkit-DgO31tBq.d.mts} +18 -21
- package/dist/copilotkit-DgO31tBq.d.mts.map +1 -0
- package/dist/{copilotkit-Dr6g885f.mjs → copilotkit-JdHy0xdu.mjs} +106 -343
- 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 +77 -100
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +1 -2
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +0 -1
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +0 -1
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +1 -2
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.css +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 +107 -343
- 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-DYKpg4pD.d.mts.map +0 -1
- package/dist/copilotkit-Dr0speVK.cjs.map +0 -1
- package/dist/copilotkit-Dr6g885f.mjs.map +0 -1
- package/dist/copilotkit-Hl1t9Y1v.d.cts.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,8 +90,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
90
90
|
assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
|
|
91
91
|
assistantMessageToolbarCopyMessageLabel: "Copy",
|
|
92
92
|
assistantMessageToolbarInspectorLabel: "View in Inspector",
|
|
93
|
-
assistantMessageToolbarInspectorLocalOnlyLabel: "
|
|
94
|
-
assistantMessageToolbarSaveSnippetLabel: "Save as snippet",
|
|
93
|
+
assistantMessageToolbarInspectorLocalOnlyLabel: "Development Only",
|
|
95
94
|
assistantMessageToolbarThumbsUpLabel: "Good response",
|
|
96
95
|
assistantMessageToolbarThumbsDownLabel: "Bad response",
|
|
97
96
|
assistantMessageToolbarReadAloudLabel: "Read aloud",
|
|
@@ -481,32 +480,43 @@ react_markdown = __toESM(react_markdown);
|
|
|
481
480
|
|
|
482
481
|
//#endregion
|
|
483
482
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
484
|
-
const CopilotKitInspector = ({ core, openRequest
|
|
485
|
-
const
|
|
483
|
+
const CopilotKitInspector = ({ core, openRequest }) => {
|
|
484
|
+
const mountRef = react.useRef(null);
|
|
486
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;
|
|
487
490
|
react.useEffect(() => {
|
|
488
491
|
let mounted = true;
|
|
492
|
+
let inspector = null;
|
|
489
493
|
import("@copilotkit/web-inspector").then((mod) => {
|
|
494
|
+
if (!mounted || !mountRef.current) return;
|
|
490
495
|
mod.defineWebInspector?.();
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
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);
|
|
497
504
|
});
|
|
498
505
|
return () => {
|
|
499
506
|
mounted = false;
|
|
507
|
+
inspector?.remove();
|
|
508
|
+
if (inspectorRef.current === inspector) inspectorRef.current = null;
|
|
500
509
|
};
|
|
501
510
|
}, []);
|
|
511
|
+
react.useEffect(() => {
|
|
512
|
+
if (inspectorRef.current) inspectorRef.current.core = core ?? null;
|
|
513
|
+
}, [core]);
|
|
502
514
|
react.useEffect(() => {
|
|
503
515
|
if (openRequest) inspectorRef.current?.openInspector("message_toolbar", openRequest);
|
|
504
|
-
}, [
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
...rest,
|
|
509
|
-
core: core ?? null
|
|
516
|
+
}, [openRequest]);
|
|
517
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
518
|
+
ref: mountRef,
|
|
519
|
+
style: { display: "contents" }
|
|
510
520
|
});
|
|
511
521
|
};
|
|
512
522
|
CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
@@ -514,9 +524,8 @@ react_markdown = __toESM(react_markdown);
|
|
|
514
524
|
//#endregion
|
|
515
525
|
//#region src/v2/components/CopilotKitInspectorContext.tsx
|
|
516
526
|
const CopilotKitInspectorContext = react.createContext({
|
|
517
|
-
|
|
518
|
-
openInspector: () => void 0
|
|
519
|
-
saveEventSnippet: async () => void 0
|
|
527
|
+
isInspectorEnabled: false,
|
|
528
|
+
openInspector: () => void 0
|
|
520
529
|
});
|
|
521
530
|
const CopilotKitInspectorContextProvider = CopilotKitInspectorContext.Provider;
|
|
522
531
|
|
|
@@ -1298,7 +1307,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
1298
1307
|
const OpenGenerativeUIActivityRendererInner = react.default.memo(function OpenGenerativeUIActivityRendererInner({ content }) {
|
|
1299
1308
|
const initialHeight = content.initialHeight ?? 200;
|
|
1300
1309
|
const [autoHeight, setAutoHeight] = (0, react.useState)(null);
|
|
1301
|
-
const [sandboxReady, setSandboxReady] = (0, react.useState)(false);
|
|
1302
1310
|
const sandboxFunctions = useSandboxFunctions();
|
|
1303
1311
|
const localApi = (0, react.useMemo)(() => {
|
|
1304
1312
|
const api = {};
|
|
@@ -1400,7 +1408,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
1400
1408
|
sandbox.promise.then(() => {
|
|
1401
1409
|
if (cancelled) return;
|
|
1402
1410
|
sandboxReadyRef.current = true;
|
|
1403
|
-
setSandboxReady(true);
|
|
1404
1411
|
sandbox.run(`
|
|
1405
1412
|
var s = document.createElement('style');
|
|
1406
1413
|
s.textContent = 'html, body { overflow: hidden !important; }';
|
|
@@ -1425,7 +1432,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
1425
1432
|
sandboxRef.current = null;
|
|
1426
1433
|
}
|
|
1427
1434
|
sandboxReadyRef.current = false;
|
|
1428
|
-
setSandboxReady(false);
|
|
1429
1435
|
setAutoHeight(null);
|
|
1430
1436
|
};
|
|
1431
1437
|
}, [
|
|
@@ -1456,7 +1462,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
1456
1462
|
const generationDone = content.generating === false;
|
|
1457
1463
|
(0, react.useEffect)(() => {
|
|
1458
1464
|
const sandbox = sandboxRef.current;
|
|
1459
|
-
if (!generationDone || !
|
|
1465
|
+
if (!generationDone || !sandbox) return;
|
|
1460
1466
|
let handled = false;
|
|
1461
1467
|
const onMessage = (e) => {
|
|
1462
1468
|
if (handled) return;
|
|
@@ -1485,7 +1491,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
1485
1491
|
return () => {
|
|
1486
1492
|
window.removeEventListener("message", onMessage);
|
|
1487
1493
|
};
|
|
1488
|
-
}, [generationDone
|
|
1494
|
+
}, [generationDone]);
|
|
1489
1495
|
const height = autoHeight ?? initialHeight;
|
|
1490
1496
|
const isGenerating = content.generating !== false;
|
|
1491
1497
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -2340,9 +2346,15 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2340
2346
|
}, [value, warningMessage]);
|
|
2341
2347
|
return value;
|
|
2342
2348
|
}
|
|
2343
|
-
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 }) => {
|
|
2344
2350
|
const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
|
|
2345
|
-
|
|
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]);
|
|
2346
2358
|
const [inspectorOpenRequest, setInspectorOpenRequest] = (0, react.useState)(null);
|
|
2347
2359
|
const [runtimeA2UIEnabled, setRuntimeA2UIEnabled] = (0, react.useState)(false);
|
|
2348
2360
|
const [runtimeOpenGenUIEnabled, setRuntimeOpenGenUIEnabled] = (0, react.useState)(false);
|
|
@@ -2351,68 +2363,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2351
2363
|
const a2uiCatalogProvided = !!a2ui?.catalog;
|
|
2352
2364
|
const a2uiActive = runtimeA2UIEnabled || a2uiCatalogProvided;
|
|
2353
2365
|
const [runtimeLicenseStatus, setRuntimeLicenseStatus] = (0, react.useState)(void 0);
|
|
2354
|
-
(0, react.useEffect)(() => {
|
|
2355
|
-
if (typeof window === "undefined") return;
|
|
2356
|
-
const isLocalhost = new Set(["localhost", "127.0.0.1"]).has(window.location?.hostname ?? "");
|
|
2357
|
-
const canShowLocalInspectorAction = process.env.NODE_ENV === "development" && isLocalhost;
|
|
2358
|
-
if (showDevConsole === true) {
|
|
2359
|
-
setShouldRenderInspector(true);
|
|
2360
|
-
setIsLocalInspectorEnabled(canShowLocalInspectorAction);
|
|
2361
|
-
} else if (showDevConsole === "auto") if (isLocalhost) {
|
|
2362
|
-
setShouldRenderInspector(true);
|
|
2363
|
-
setIsLocalInspectorEnabled(canShowLocalInspectorAction);
|
|
2364
|
-
} else {
|
|
2365
|
-
setShouldRenderInspector(false);
|
|
2366
|
-
setIsLocalInspectorEnabled(false);
|
|
2367
|
-
}
|
|
2368
|
-
else {
|
|
2369
|
-
setShouldRenderInspector(false);
|
|
2370
|
-
setIsLocalInspectorEnabled(false);
|
|
2371
|
-
}
|
|
2372
|
-
}, [showDevConsole]);
|
|
2373
2366
|
const requestInspectorOpen = (0, react.useCallback)((request) => {
|
|
2374
2367
|
setInspectorOpenRequest({ ...request });
|
|
2375
2368
|
}, []);
|
|
2376
|
-
const saveEventSnippet = (0, react.useCallback)(async (request) => {
|
|
2377
|
-
try {
|
|
2378
|
-
const mod = await import("@copilotkit/web-inspector");
|
|
2379
|
-
const threadId = request.threadId ?? "inspector-snippet";
|
|
2380
|
-
const runId = `inspector-snippet-${Date.now()}`;
|
|
2381
|
-
const compiled = mod.compileChatSnippet({
|
|
2382
|
-
...request,
|
|
2383
|
-
threadId,
|
|
2384
|
-
runId
|
|
2385
|
-
});
|
|
2386
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2387
|
-
const snippet = {
|
|
2388
|
-
id: crypto.randomUUID(),
|
|
2389
|
-
name: compiled.name,
|
|
2390
|
-
recipe: compiled.recipe,
|
|
2391
|
-
events: compiled.events,
|
|
2392
|
-
createdAt: now,
|
|
2393
|
-
updatedAt: now
|
|
2394
|
-
};
|
|
2395
|
-
mod.upsertEventSnippet(snippet);
|
|
2396
|
-
requestInspectorOpen({
|
|
2397
|
-
messageId: request.messageId,
|
|
2398
|
-
threadId: request.threadId,
|
|
2399
|
-
agentId: request.agentId,
|
|
2400
|
-
menu: "event-snippets",
|
|
2401
|
-
snippetId: snippet.id
|
|
2402
|
-
});
|
|
2403
|
-
} catch (error) {
|
|
2404
|
-
console.error("[CopilotKit] Could not save the event snippet.", error);
|
|
2405
|
-
}
|
|
2406
|
-
}, [requestInspectorOpen]);
|
|
2407
2369
|
const inspectorContextValue = (0, react.useMemo)(() => ({
|
|
2408
|
-
|
|
2409
|
-
openInspector: requestInspectorOpen
|
|
2410
|
-
|
|
2411
|
-
}), [
|
|
2412
|
-
isLocalInspectorEnabled,
|
|
2413
|
-
requestInspectorOpen,
|
|
2414
|
-
saveEventSnippet
|
|
2415
|
-
]);
|
|
2370
|
+
isInspectorEnabled: shouldRenderInspector,
|
|
2371
|
+
openInspector: requestInspectorOpen
|
|
2372
|
+
}), [shouldRenderInspector, requestInspectorOpen]);
|
|
2416
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) => {
|
|
2417
2374
|
const key = (rc) => `${rc?.agentId ?? ""}:${rc?.name ?? ""}`;
|
|
2418
2375
|
const setFrom = (arr) => new Set(arr.map(key));
|
|
@@ -2753,7 +2710,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2753
2710
|
value: inspectorContextValue,
|
|
2754
2711
|
children: [children, shouldRenderInspector ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInspector, {
|
|
2755
2712
|
core: copilotkit,
|
|
2756
|
-
defaultAnchor: inspectorDefaultAnchor,
|
|
2757
2713
|
openRequest: inspectorOpenRequest
|
|
2758
2714
|
}) : null]
|
|
2759
2715
|
}),
|
|
@@ -5204,20 +5160,42 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5204
5160
|
|
|
5205
5161
|
//#endregion
|
|
5206
5162
|
//#region src/v1-deprecated/components/CopilotListeners.tsx
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
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 {
|
|
5210
5180
|
onCustomEvent: ({ event }) => {
|
|
5211
|
-
if (event.name === "PredictState") predictStateToolsRef.current = event.value;
|
|
5181
|
+
if (event.name === "PredictState") predictStateToolsRef.current = Array.isArray(event.value) ? event.value.filter(isPredictStateTool) : [];
|
|
5212
5182
|
},
|
|
5213
5183
|
onToolCallArgsEvent: ({ partialToolCallArgs, toolCallName }) => {
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
const
|
|
5217
|
-
|
|
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
|
|
5218
5192
|
});
|
|
5219
5193
|
}
|
|
5220
|
-
}
|
|
5194
|
+
};
|
|
5195
|
+
}
|
|
5196
|
+
const usePredictStateSubscription = (agent) => {
|
|
5197
|
+
const predictStateToolsRef = (0, react.useRef)([]);
|
|
5198
|
+
const getSubscriber = (0, react.useCallback)((subscriptionAgent) => createPredictStateSubscriber(subscriptionAgent, predictStateToolsRef), []);
|
|
5221
5199
|
(0, react.useEffect)(() => {
|
|
5222
5200
|
if (!agent) return;
|
|
5223
5201
|
const subscriber = getSubscriber(agent);
|
|
@@ -5276,7 +5254,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5276
5254
|
//#region src/v1-deprecated/components/copilot-provider/copilotkit.tsx
|
|
5277
5255
|
function CopilotKit({ children, ...props }) {
|
|
5278
5256
|
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
5279
|
-
const showInspector = shouldShowDevConsole(props.enableInspector);
|
|
5280
5257
|
const publicApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
5281
5258
|
const renderArr = (0, react.useMemo)(() => [{ render: CoAgentStateRenderBridge }], []);
|
|
5282
5259
|
const { onError: _onError, ...v2Props } = props;
|
|
@@ -5289,7 +5266,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5289
5266
|
threadId: props.threadId,
|
|
5290
5267
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitProvider, {
|
|
5291
5268
|
...v2Props,
|
|
5292
|
-
|
|
5269
|
+
enableInspector: props.enableInspector,
|
|
5293
5270
|
renderCustomMessages: renderArr,
|
|
5294
5271
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInternal, {
|
|
5295
5272
|
...props,
|