@copilotkit/react-core 1.50.0-beta.7 → 1.50.0-beta.8
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/CHANGELOG.md +9 -4
- package/dist/chunk-RQ6LWR6S.mjs +37 -0
- package/dist/chunk-RQ6LWR6S.mjs.map +1 -0
- package/dist/{chunk-QSNZUI5G.mjs → chunk-Y2L7KDVW.mjs} +2 -2
- package/dist/{chunk-WV57GREG.mjs → chunk-ZU6ZBX4E.mjs} +4 -4
- package/dist/components/copilot-provider/copilotkit.mjs +5 -5
- package/dist/components/copilot-provider/index.mjs +5 -5
- package/dist/components/index.mjs +5 -5
- package/dist/hooks/index.js +58 -35
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/hooks/use-copilot-readable.d.ts +4 -3
- package/dist/hooks/use-copilot-readable.js +29 -6
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +1 -1
- package/dist/index.js +58 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -8
- package/dist/lib/copilot-task.mjs +6 -6
- package/dist/lib/index.mjs +6 -6
- package/package.json +7 -7
- package/src/hooks/use-copilot-readable.ts +34 -15
- package/dist/chunk-2CYJN455.mjs +0 -14
- package/dist/chunk-2CYJN455.mjs.map +0 -1
- /package/dist/{chunk-QSNZUI5G.mjs.map → chunk-Y2L7KDVW.mjs.map} +0 -0
- /package/dist/{chunk-WV57GREG.mjs.map → chunk-ZU6ZBX4E.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
-
## 1.50.0-beta.
|
|
3
|
+
## 1.50.0-beta.8
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- @copilotkit/runtime-client-gql@1.50.0-beta.8
|
|
8
|
+
- @copilotkit/shared@1.50.0-beta.8
|
|
9
|
+
|
|
10
|
+
## 1.50.0-beta.7
|
|
8
11
|
|
|
9
12
|
### Patch Changes
|
|
10
13
|
|
|
11
|
-
-
|
|
14
|
+
- 6ce0edc: - fix: refrain from re-setting context infinitely if it hasnt changed
|
|
15
|
+
- fix: pass only strings to context value
|
|
16
|
+
- fix: allow custom convert and availability setup
|
|
12
17
|
- @copilotkit/runtime-client-gql@1.50.0-beta.7
|
|
13
18
|
- @copilotkit/shared@1.50.0-beta.7
|
|
14
19
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/hooks/use-copilot-readable.ts
|
|
2
|
+
import { useCopilotKit } from "@copilotkitnext/react";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
function useCopilotReadable({ description, value, convert, available }, dependencies) {
|
|
5
|
+
const { copilotkit } = useCopilotKit();
|
|
6
|
+
const ctxIdRef = useRef(void 0);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (!copilotkit)
|
|
9
|
+
return;
|
|
10
|
+
const found = Object.entries(copilotkit.context).find(([id, ctxItem]) => {
|
|
11
|
+
return JSON.stringify({ description, value }) == JSON.stringify(ctxItem);
|
|
12
|
+
});
|
|
13
|
+
if (found) {
|
|
14
|
+
ctxIdRef.current = found[0];
|
|
15
|
+
if (available === "disabled")
|
|
16
|
+
copilotkit.removeContext(ctxIdRef.current);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (!found && available === "disabled")
|
|
20
|
+
return;
|
|
21
|
+
ctxIdRef.current = copilotkit.addContext({
|
|
22
|
+
description,
|
|
23
|
+
value: (convert != null ? convert : JSON.stringify)(value)
|
|
24
|
+
});
|
|
25
|
+
return () => {
|
|
26
|
+
if (!ctxIdRef.current)
|
|
27
|
+
return;
|
|
28
|
+
copilotkit.removeContext(ctxIdRef.current);
|
|
29
|
+
};
|
|
30
|
+
}, [description, value, convert]);
|
|
31
|
+
return ctxIdRef.current;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
useCopilotReadable
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=chunk-RQ6LWR6S.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-copilot-readable.ts"],"sourcesContent":["/**\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * ## Usage\n *\n * ### Simple Usage\n *\n * In its most basic usage, useCopilotReadable accepts a single string argument\n * representing any piece of app state, making it available for the Copilot to use\n * as context when responding to user input.\n *\n * ```tsx\n * import { useCopilotReadable } from \"@copilotkit/react-core\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotReadable({\n * description: \"The list of employees\",\n * value: employees,\n * });\n * }\n * ```\n *\n * ### Nested Components\n *\n * Optionally, you can maintain the hierarchical structure of information by passing\n * `parentId`. This allows you to use `useCopilotReadable` in nested components:\n *\n * ```tsx /employeeContextId/1 {17,23}\n * import { useCopilotReadable } from \"@copilotkit/react-core\";\n *\n * function Employee(props: EmployeeProps) {\n * const { employeeName, workProfile, metadata } = props;\n *\n * // propagate any information to copilot\n * const employeeContextId = useCopilotReadable({\n * description: \"Employee name\",\n * value: employeeName\n * });\n *\n * // Pass a parentID to maintain a hierarchical structure.\n * // Especially useful with child React components, list elements, etc.\n * useCopilotReadable({\n * description: \"Work profile\",\n * value: workProfile.description(),\n * parentId: employeeContextId\n * });\n *\n * useCopilotReadable({\n * description: \"Employee metadata\",\n * value: metadata.description(),\n * parentId: employeeContextId\n * });\n *\n * return (\n * // Render as usual...\n * );\n * }\n * ```\n */\nimport { useCopilotKit } from \"@copilotkitnext/react\";\nimport { useEffect, useRef } from \"react\";\n\ntype DataType = object | number | string | boolean | null | undefined;\n\n/**\n * Options for the useCopilotReadable hook.\n */\nexport interface UseCopilotReadableOptions {\n /**\n * The description of the information to be added to the Copilot context.\n */\n description: string;\n /**\n * The value to be added to the Copilot context. Object values are automatically stringified.\n */\n value: DataType | Record<string, any> | DataType[];\n /**\n * The ID of the parent context, if any.\n */\n parentId?: string;\n /**\n * An array of categories to control which context are visible where. Particularly useful\n * with CopilotTextarea (see `useMakeAutosuggestionFunction`)\n */\n categories?: string[];\n\n /**\n * Whether the context is available to the Copilot.\n */\n available?: \"enabled\" | \"disabled\";\n\n /**\n * A custom conversion function to use to serialize the value to a string. If not provided, the value\n * will be serialized using `JSON.stringify`.\n */\n convert?: (value: any) => string;\n}\n\n/**\n * Adds the given information to the Copilot context to make it readable by Copilot.\n */\nexport function useCopilotReadable(\n { description, value, convert, available }: UseCopilotReadableOptions,\n dependencies?: any[],\n): string | undefined {\n const { copilotkit } = useCopilotKit();\n const ctxIdRef = useRef<string | undefined>(undefined);\n useEffect(() => {\n if (!copilotkit) return;\n\n const found = Object.entries(copilotkit.context).find(([id, ctxItem]) => {\n return JSON.stringify({ description, value }) == JSON.stringify(ctxItem);\n });\n if (found) {\n ctxIdRef.current = found[0];\n if (available === \"disabled\") copilotkit.removeContext(ctxIdRef.current);\n return;\n }\n if (!found && available === \"disabled\") return;\n\n ctxIdRef.current = copilotkit.addContext({\n description,\n value: (convert ?? JSON.stringify)(value),\n });\n\n return () => {\n if (!ctxIdRef.current) return;\n copilotkit.removeContext(ctxIdRef.current);\n };\n }, [description, value, convert]);\n\n return ctxIdRef.current;\n}\n"],"mappings":";AA+DA,SAAS,qBAAqB;AAC9B,SAAS,WAAW,cAAc;AAyC3B,SAAS,mBACd,EAAE,aAAa,OAAO,SAAS,UAAU,GACzC,cACoB;AACpB,QAAM,EAAE,WAAW,IAAI,cAAc;AACrC,QAAM,WAAW,OAA2B,MAAS;AACrD,YAAU,MAAM;AACd,QAAI,CAAC;AAAY;AAEjB,UAAM,QAAQ,OAAO,QAAQ,WAAW,OAAO,EAAE,KAAK,CAAC,CAAC,IAAI,OAAO,MAAM;AACvE,aAAO,KAAK,UAAU,EAAE,aAAa,MAAM,CAAC,KAAK,KAAK,UAAU,OAAO;AAAA,IACzE,CAAC;AACD,QAAI,OAAO;AACT,eAAS,UAAU,MAAM,CAAC;AAC1B,UAAI,cAAc;AAAY,mBAAW,cAAc,SAAS,OAAO;AACvE;AAAA,IACF;AACA,QAAI,CAAC,SAAS,cAAc;AAAY;AAExC,aAAS,UAAU,WAAW,WAAW;AAAA,MACvC;AAAA,MACA,QAAQ,4BAAW,KAAK,WAAW,KAAK;AAAA,IAC1C,CAAC;AAED,WAAO,MAAM;AACX,UAAI,CAAC,SAAS;AAAS;AACvB,iBAAW,cAAc,SAAS,OAAO;AAAA,IAC3C;AAAA,EACF,GAAG,CAAC,aAAa,OAAO,OAAO,CAAC;AAEhC,SAAO,SAAS;AAClB;","names":[]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-4CEQJ2X6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
defaultCopilotContextCategories
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZU6ZBX4E.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__async,
|
|
9
9
|
__spreadValues
|
|
@@ -117,4 +117,4 @@ ${instructions}
|
|
|
117
117
|
export {
|
|
118
118
|
CopilotTask
|
|
119
119
|
};
|
|
120
|
-
//# sourceMappingURL=chunk-
|
|
120
|
+
//# sourceMappingURL=chunk-Y2L7KDVW.mjs.map
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ConsoleTrigger
|
|
3
|
-
} from "./chunk-PMWUKW3Z.mjs";
|
|
4
1
|
import {
|
|
5
2
|
CopilotErrorBoundary
|
|
6
3
|
} from "./chunk-LHERIF3L.mjs";
|
|
@@ -8,6 +5,9 @@ import {
|
|
|
8
5
|
CopilotMessages,
|
|
9
6
|
MessagesTapProvider
|
|
10
7
|
} from "./chunk-HE22TZMF.mjs";
|
|
8
|
+
import {
|
|
9
|
+
ConsoleTrigger
|
|
10
|
+
} from "./chunk-PMWUKW3Z.mjs";
|
|
11
11
|
import {
|
|
12
12
|
shouldShowDevConsole
|
|
13
13
|
} from "./chunk-ICIK2BSB.mjs";
|
|
@@ -540,4 +540,4 @@ export {
|
|
|
540
540
|
CopilotKitInternal,
|
|
541
541
|
defaultCopilotContextCategories
|
|
542
542
|
};
|
|
543
|
-
//# sourceMappingURL=chunk-
|
|
543
|
+
//# sourceMappingURL=chunk-ZU6ZBX4E.mjs.map
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
CopilotKit,
|
|
3
3
|
CopilotKitInternal,
|
|
4
4
|
defaultCopilotContextCategories
|
|
5
|
-
} from "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
5
|
+
} from "../../chunk-ZU6ZBX4E.mjs";
|
|
6
|
+
import "../../chunk-LHERIF3L.mjs";
|
|
7
|
+
import "../../chunk-HE22TZMF.mjs";
|
|
8
8
|
import "../../chunk-PMWUKW3Z.mjs";
|
|
9
9
|
import "../../chunk-YCG6SNAU.mjs";
|
|
10
10
|
import "../../chunk-PIF5KJYI.mjs";
|
|
11
|
-
import "../../chunk-
|
|
12
|
-
import "../../chunk-
|
|
11
|
+
import "../../chunk-CYDWEPFL.mjs";
|
|
12
|
+
import "../../chunk-2IDV5OHF.mjs";
|
|
13
13
|
import "../../chunk-ICIK2BSB.mjs";
|
|
14
14
|
import "../../chunk-RKTVJRK7.mjs";
|
|
15
15
|
import "../../chunk-PMAFHQ7P.mjs";
|
|
@@ -2,14 +2,14 @@ import "../../chunk-SPCZTZCY.mjs";
|
|
|
2
2
|
import {
|
|
3
3
|
CopilotKit,
|
|
4
4
|
defaultCopilotContextCategories
|
|
5
|
-
} from "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
5
|
+
} from "../../chunk-ZU6ZBX4E.mjs";
|
|
6
|
+
import "../../chunk-LHERIF3L.mjs";
|
|
7
|
+
import "../../chunk-HE22TZMF.mjs";
|
|
8
8
|
import "../../chunk-PMWUKW3Z.mjs";
|
|
9
9
|
import "../../chunk-YCG6SNAU.mjs";
|
|
10
10
|
import "../../chunk-PIF5KJYI.mjs";
|
|
11
|
-
import "../../chunk-
|
|
12
|
-
import "../../chunk-
|
|
11
|
+
import "../../chunk-CYDWEPFL.mjs";
|
|
12
|
+
import "../../chunk-2IDV5OHF.mjs";
|
|
13
13
|
import "../../chunk-ICIK2BSB.mjs";
|
|
14
14
|
import "../../chunk-RKTVJRK7.mjs";
|
|
15
15
|
import "../../chunk-PMAFHQ7P.mjs";
|
|
@@ -3,14 +3,14 @@ import "../chunk-SPCZTZCY.mjs";
|
|
|
3
3
|
import {
|
|
4
4
|
CopilotKit,
|
|
5
5
|
defaultCopilotContextCategories
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-ZU6ZBX4E.mjs";
|
|
7
|
+
import "../chunk-LHERIF3L.mjs";
|
|
8
|
+
import "../chunk-HE22TZMF.mjs";
|
|
9
9
|
import "../chunk-PMWUKW3Z.mjs";
|
|
10
10
|
import "../chunk-YCG6SNAU.mjs";
|
|
11
11
|
import "../chunk-PIF5KJYI.mjs";
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-CYDWEPFL.mjs";
|
|
13
|
+
import "../chunk-2IDV5OHF.mjs";
|
|
14
14
|
import "../chunk-ICIK2BSB.mjs";
|
|
15
15
|
import "../chunk-RKTVJRK7.mjs";
|
|
16
16
|
import "../chunk-PMAFHQ7P.mjs";
|
package/dist/hooks/index.js
CHANGED
|
@@ -1789,22 +1789,45 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
|
|
|
1789
1789
|
|
|
1790
1790
|
// src/hooks/use-copilot-readable.ts
|
|
1791
1791
|
var import_react27 = require("@copilotkitnext/react");
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1792
|
+
var import_react28 = require("react");
|
|
1793
|
+
function useCopilotReadable({ description, value, convert, available }, dependencies) {
|
|
1794
|
+
const { copilotkit } = (0, import_react27.useCopilotKit)();
|
|
1795
|
+
const ctxIdRef = (0, import_react28.useRef)(void 0);
|
|
1796
|
+
(0, import_react28.useEffect)(() => {
|
|
1797
|
+
if (!copilotkit)
|
|
1798
|
+
return;
|
|
1799
|
+
const found = Object.entries(copilotkit.context).find(([id, ctxItem]) => {
|
|
1800
|
+
return JSON.stringify({ description, value }) == JSON.stringify(ctxItem);
|
|
1801
|
+
});
|
|
1802
|
+
if (found) {
|
|
1803
|
+
ctxIdRef.current = found[0];
|
|
1804
|
+
if (available === "disabled")
|
|
1805
|
+
copilotkit.removeContext(ctxIdRef.current);
|
|
1806
|
+
return;
|
|
1807
|
+
}
|
|
1808
|
+
if (!found && available === "disabled")
|
|
1809
|
+
return;
|
|
1810
|
+
ctxIdRef.current = copilotkit.addContext({
|
|
1811
|
+
description,
|
|
1812
|
+
value: (convert != null ? convert : JSON.stringify)(value)
|
|
1813
|
+
});
|
|
1814
|
+
return () => {
|
|
1815
|
+
if (!ctxIdRef.current)
|
|
1816
|
+
return;
|
|
1817
|
+
copilotkit.removeContext(ctxIdRef.current);
|
|
1818
|
+
};
|
|
1819
|
+
}, [description, value, convert]);
|
|
1820
|
+
return ctxIdRef.current;
|
|
1798
1821
|
}
|
|
1799
1822
|
|
|
1800
1823
|
// src/hooks/use-coagent.ts
|
|
1801
|
-
var
|
|
1802
|
-
var
|
|
1824
|
+
var import_react29 = require("react");
|
|
1825
|
+
var import_react30 = require("@copilotkitnext/react");
|
|
1803
1826
|
function useCoAgent(options) {
|
|
1804
|
-
const { agent } = (0,
|
|
1805
|
-
const { copilotkit } = (0,
|
|
1827
|
+
const { agent } = (0, import_react30.useAgent)({ agentId: options.name });
|
|
1828
|
+
const { copilotkit } = (0, import_react30.useCopilotKit)();
|
|
1806
1829
|
const nodeName = useAgentNodeName(options.name);
|
|
1807
|
-
const handleStateUpdate = (0,
|
|
1830
|
+
const handleStateUpdate = (0, import_react29.useCallback)(
|
|
1808
1831
|
(newState) => {
|
|
1809
1832
|
if (!agent)
|
|
1810
1833
|
return;
|
|
@@ -1817,7 +1840,7 @@ function useCoAgent(options) {
|
|
|
1817
1840
|
},
|
|
1818
1841
|
[agent == null ? void 0 : agent.state, agent == null ? void 0 : agent.setState]
|
|
1819
1842
|
);
|
|
1820
|
-
(0,
|
|
1843
|
+
(0, import_react29.useEffect)(() => {
|
|
1821
1844
|
var _a;
|
|
1822
1845
|
if (!options.config && !options.configurable)
|
|
1823
1846
|
return;
|
|
@@ -1829,22 +1852,22 @@ function useCoAgent(options) {
|
|
|
1829
1852
|
}
|
|
1830
1853
|
copilotkit.setProperties(config);
|
|
1831
1854
|
}, [options.config, options.configurable]);
|
|
1832
|
-
const externalStateStr = (0,
|
|
1855
|
+
const externalStateStr = (0, import_react29.useMemo)(
|
|
1833
1856
|
() => isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0,
|
|
1834
1857
|
[isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0]
|
|
1835
1858
|
);
|
|
1836
|
-
(0,
|
|
1859
|
+
(0, import_react29.useEffect)(() => {
|
|
1837
1860
|
if ((agent == null ? void 0 : agent.state) && isExternalStateManagement(options) && JSON.stringify(options.state) !== JSON.stringify(agent.state)) {
|
|
1838
1861
|
handleStateUpdate(options.state);
|
|
1839
1862
|
}
|
|
1840
1863
|
}, [agent, externalStateStr, handleStateUpdate]);
|
|
1841
|
-
const hasStateValues = (0,
|
|
1864
|
+
const hasStateValues = (0, import_react29.useCallback)((value) => {
|
|
1842
1865
|
return Boolean(value && Object.keys(value).length);
|
|
1843
1866
|
}, []);
|
|
1844
|
-
const initialStateRef = (0,
|
|
1867
|
+
const initialStateRef = (0, import_react29.useRef)(
|
|
1845
1868
|
isExternalStateManagement(options) ? options.state : "initialState" in options ? options.initialState : void 0
|
|
1846
1869
|
);
|
|
1847
|
-
(0,
|
|
1870
|
+
(0, import_react29.useEffect)(() => {
|
|
1848
1871
|
if (isExternalStateManagement(options)) {
|
|
1849
1872
|
initialStateRef.current = options.state;
|
|
1850
1873
|
} else if ("initialState" in options) {
|
|
@@ -1853,7 +1876,7 @@ function useCoAgent(options) {
|
|
|
1853
1876
|
}, [
|
|
1854
1877
|
isExternalStateManagement(options) ? JSON.stringify(options.state) : "initialState" in options ? JSON.stringify(options.initialState) : void 0
|
|
1855
1878
|
]);
|
|
1856
|
-
(0,
|
|
1879
|
+
(0, import_react29.useEffect)(() => {
|
|
1857
1880
|
if (!agent)
|
|
1858
1881
|
return;
|
|
1859
1882
|
const subscriber = {
|
|
@@ -1881,7 +1904,7 @@ function useCoAgent(options) {
|
|
|
1881
1904
|
subscription.unsubscribe();
|
|
1882
1905
|
};
|
|
1883
1906
|
}, [agent, handleStateUpdate, hasStateValues]);
|
|
1884
|
-
return (0,
|
|
1907
|
+
return (0, import_react29.useMemo)(() => {
|
|
1885
1908
|
var _a, _b, _c;
|
|
1886
1909
|
if (!agent) {
|
|
1887
1910
|
const noop = () => {
|
|
@@ -1937,12 +1960,12 @@ var isExternalStateManagement = (options) => {
|
|
|
1937
1960
|
|
|
1938
1961
|
// src/hooks/use-copilot-runtime-client.ts
|
|
1939
1962
|
var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
|
|
1940
|
-
var
|
|
1963
|
+
var import_react31 = require("react");
|
|
1941
1964
|
var import_shared11 = require("@copilotkit/shared");
|
|
1942
1965
|
var useCopilotRuntimeClient = (options) => {
|
|
1943
1966
|
const { setBannerError } = useToast();
|
|
1944
1967
|
const _a = options, { showDevConsole, onError } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onError"]);
|
|
1945
|
-
const lastStructuredErrorRef = (0,
|
|
1968
|
+
const lastStructuredErrorRef = (0, import_react31.useRef)(null);
|
|
1946
1969
|
const traceUIError = (error, originalError) => __async(void 0, null, function* () {
|
|
1947
1970
|
try {
|
|
1948
1971
|
const errorEvent = {
|
|
@@ -1968,7 +1991,7 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
1968
1991
|
console.error("Error in onError handler:", error2);
|
|
1969
1992
|
}
|
|
1970
1993
|
});
|
|
1971
|
-
const runtimeClient = (0,
|
|
1994
|
+
const runtimeClient = (0, import_react31.useMemo)(() => {
|
|
1972
1995
|
return new import_runtime_client_gql3.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
|
|
1973
1996
|
handleGQLErrors: (error) => {
|
|
1974
1997
|
var _a2;
|
|
@@ -2047,28 +2070,28 @@ function createStructuredError(gqlError) {
|
|
|
2047
2070
|
}
|
|
2048
2071
|
|
|
2049
2072
|
// src/hooks/use-copilot-authenticated-action.ts
|
|
2050
|
-
var
|
|
2051
|
-
var
|
|
2073
|
+
var import_react32 = require("react");
|
|
2074
|
+
var import_react33 = __toESM(require("react"));
|
|
2052
2075
|
function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
2053
2076
|
const { authConfig_c, authStates_c, setAuthStates_c } = useCopilotContext();
|
|
2054
|
-
const pendingActionRef = (0,
|
|
2055
|
-
const executeAction = (0,
|
|
2077
|
+
const pendingActionRef = (0, import_react32.useRef)(null);
|
|
2078
|
+
const executeAction = (0, import_react32.useCallback)(
|
|
2056
2079
|
(props) => {
|
|
2057
2080
|
if (typeof action.render === "function") {
|
|
2058
2081
|
return action.render(props);
|
|
2059
2082
|
}
|
|
2060
|
-
return action.render ||
|
|
2083
|
+
return action.render || import_react33.default.createElement(import_react32.Fragment);
|
|
2061
2084
|
},
|
|
2062
2085
|
[action]
|
|
2063
2086
|
);
|
|
2064
|
-
const wrappedRender = (0,
|
|
2087
|
+
const wrappedRender = (0, import_react32.useCallback)(
|
|
2065
2088
|
(props) => {
|
|
2066
2089
|
const isAuthenticated = Object.values(authStates_c || {}).some(
|
|
2067
2090
|
(state) => state.status === "authenticated"
|
|
2068
2091
|
);
|
|
2069
2092
|
if (!isAuthenticated) {
|
|
2070
2093
|
pendingActionRef.current = props;
|
|
2071
|
-
return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ?
|
|
2094
|
+
return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ? import_react33.default.createElement(authConfig_c.SignInComponent, {
|
|
2072
2095
|
onSignInComplete: (authState) => {
|
|
2073
2096
|
setAuthStates_c == null ? void 0 : setAuthStates_c((prev) => __spreadProps(__spreadValues({}, prev), { [action.name]: authState }));
|
|
2074
2097
|
if (pendingActionRef.current) {
|
|
@@ -2076,7 +2099,7 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
|
2076
2099
|
pendingActionRef.current = null;
|
|
2077
2100
|
}
|
|
2078
2101
|
}
|
|
2079
|
-
}) :
|
|
2102
|
+
}) : import_react33.default.createElement(import_react32.Fragment);
|
|
2080
2103
|
}
|
|
2081
2104
|
return executeAction(props);
|
|
2082
2105
|
},
|
|
@@ -2091,13 +2114,13 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
|
2091
2114
|
}
|
|
2092
2115
|
|
|
2093
2116
|
// src/hooks/use-langgraph-interrupt.ts
|
|
2094
|
-
var
|
|
2117
|
+
var import_react34 = require("react");
|
|
2095
2118
|
var import_shared12 = require("@copilotkit/shared");
|
|
2096
2119
|
function useLangGraphInterrupt(action, dependencies) {
|
|
2097
|
-
const { setInterruptAction, removeInterruptAction, interruptActions, threadId } = (0,
|
|
2120
|
+
const { setInterruptAction, removeInterruptAction, interruptActions, threadId } = (0, import_react34.useContext)(CopilotContext);
|
|
2098
2121
|
const { addToast } = useToast();
|
|
2099
2122
|
const actionId = (0, import_shared12.dataToUUID)(action, "lgAction");
|
|
2100
|
-
(0,
|
|
2123
|
+
(0, import_react34.useEffect)(() => {
|
|
2101
2124
|
if (!action)
|
|
2102
2125
|
return;
|
|
2103
2126
|
setInterruptAction(__spreadProps(__spreadValues({}, action), { id: actionId }));
|
|
@@ -2108,10 +2131,10 @@ function useLangGraphInterrupt(action, dependencies) {
|
|
|
2108
2131
|
}
|
|
2109
2132
|
|
|
2110
2133
|
// src/hooks/use-copilot-additional-instructions.ts
|
|
2111
|
-
var
|
|
2134
|
+
var import_react35 = require("react");
|
|
2112
2135
|
function useCopilotAdditionalInstructions({ instructions, available = "enabled" }, dependencies) {
|
|
2113
2136
|
const { setAdditionalInstructions } = useCopilotContext();
|
|
2114
|
-
(0,
|
|
2137
|
+
(0, import_react35.useEffect)(() => {
|
|
2115
2138
|
if (available === "disabled")
|
|
2116
2139
|
return;
|
|
2117
2140
|
setAdditionalInstructions((prevInstructions) => [...prevInstructions || [], instructions]);
|