@copilotkit/react-core 1.50.0 → 1.50.1-next.1
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 +17 -0
- package/dist/{chunk-CO6V4G7P.mjs → chunk-4YZA2BZC.mjs} +4 -4
- package/dist/{chunk-U2ZRVVKT.mjs → chunk-BUSWSDYO.mjs} +2 -2
- package/dist/{chunk-T2VBHAAP.mjs → chunk-CDUIA2WM.mjs} +11 -3
- package/dist/chunk-CDUIA2WM.mjs.map +1 -0
- package/dist/{chunk-4HRUQH6U.mjs → chunk-E7SE25ZU.mjs} +2 -2
- package/dist/{chunk-EG56H77V.mjs → chunk-GPEJNVE5.mjs} +2 -2
- package/dist/{chunk-HQTDDA6V.mjs → chunk-LCZZ7YGZ.mjs} +2 -2
- package/dist/components/copilot-provider/copilotkit.mjs +3 -3
- package/dist/components/copilot-provider/index.mjs +3 -3
- package/dist/components/index.mjs +3 -3
- package/dist/hooks/index.js +9 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +4 -4
- package/dist/hooks/use-copilot-action.js +9 -1
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +2 -2
- package/dist/hooks/use-copilot-authenticated-action.js +9 -1
- package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
- package/dist/hooks/use-copilot-authenticated-action.mjs +3 -3
- package/dist/hooks/use-default-tool.js +9 -1
- package/dist/hooks/use-default-tool.js.map +1 -1
- package/dist/hooks/use-default-tool.mjs +3 -3
- package/dist/hooks/use-frontend-tool.js +9 -1
- package/dist/hooks/use-frontend-tool.js.map +1 -1
- package/dist/hooks/use-frontend-tool.mjs +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -9
- package/dist/lib/copilot-task.mjs +4 -4
- package/dist/lib/index.mjs +4 -4
- package/dist/types/index.mjs +1 -1
- package/package.json +3 -3
- package/src/hooks/use-frontend-tool.ts +13 -2
- package/dist/chunk-T2VBHAAP.mjs.map +0 -1
- /package/dist/{chunk-CO6V4G7P.mjs.map → chunk-4YZA2BZC.mjs.map} +0 -0
- /package/dist/{chunk-U2ZRVVKT.mjs.map → chunk-BUSWSDYO.mjs.map} +0 -0
- /package/dist/{chunk-4HRUQH6U.mjs.map → chunk-E7SE25ZU.mjs.map} +0 -0
- /package/dist/{chunk-EG56H77V.mjs.map → chunk-GPEJNVE5.mjs.map} +0 -0
- /package/dist/{chunk-HQTDDA6V.mjs.map → chunk-LCZZ7YGZ.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
+
## 1.50.1-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cfa4185: - fix: fix stale state in handler
|
|
8
|
+
- @copilotkit/runtime-client-gql@1.50.1-next.1
|
|
9
|
+
- @copilotkit/shared@1.50.1-next.1
|
|
10
|
+
|
|
11
|
+
## 1.50.1-next.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated the default model and API version for the Google GenAI adapter
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- @copilotkit/runtime-client-gql@1.50.1-next.0
|
|
18
|
+
- @copilotkit/shared@1.50.1-next.0
|
|
19
|
+
|
|
3
20
|
## 1.50.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
CopilotMessages,
|
|
6
6
|
MessagesTapProvider
|
|
7
7
|
} from "./chunk-HE22TZMF.mjs";
|
|
8
|
-
import {
|
|
9
|
-
use_tree_default
|
|
10
|
-
} from "./chunk-RKTVJRK7.mjs";
|
|
11
8
|
import {
|
|
12
9
|
shouldShowDevConsole
|
|
13
10
|
} from "./chunk-ICIK2BSB.mjs";
|
|
11
|
+
import {
|
|
12
|
+
use_tree_default
|
|
13
|
+
} from "./chunk-RKTVJRK7.mjs";
|
|
14
14
|
import {
|
|
15
15
|
use_flat_category_store_default
|
|
16
16
|
} from "./chunk-YYN33GSG.mjs";
|
|
@@ -548,4 +548,4 @@ export {
|
|
|
548
548
|
CopilotKitInternal,
|
|
549
549
|
defaultCopilotContextCategories
|
|
550
550
|
};
|
|
551
|
-
//# sourceMappingURL=chunk-
|
|
551
|
+
//# sourceMappingURL=chunk-4YZA2BZC.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotAction
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GPEJNVE5.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__spreadProps,
|
|
6
6
|
__spreadValues
|
|
@@ -14,4 +14,4 @@ function useDefaultTool(tool, dependencies) {
|
|
|
14
14
|
export {
|
|
15
15
|
useDefaultTool
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
17
|
+
//# sourceMappingURL=chunk-BUSWSDYO.mjs.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-SKC7AJIV.mjs";
|
|
5
5
|
|
|
6
6
|
// src/hooks/use-frontend-tool.ts
|
|
7
|
-
import React from "react";
|
|
7
|
+
import React, { useEffect, useRef } from "react";
|
|
8
8
|
import { getZodParameters } from "@copilotkit/shared";
|
|
9
9
|
import { parseJson } from "@copilotkit/shared";
|
|
10
10
|
import {
|
|
@@ -36,11 +36,19 @@ function useFrontendTool(tool, dependencies) {
|
|
|
36
36
|
return rendered != null ? rendered : null;
|
|
37
37
|
};
|
|
38
38
|
})();
|
|
39
|
+
const handlerRef = useRef(tool.handler);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
handlerRef.current = tool.handler;
|
|
42
|
+
}, [tool.handler, ...dependencies != null ? dependencies : []]);
|
|
43
|
+
const normalizedHandler = tool.handler ? (args) => {
|
|
44
|
+
var _a;
|
|
45
|
+
return (_a = handlerRef.current) == null ? void 0 : _a.call(handlerRef, args);
|
|
46
|
+
} : void 0;
|
|
39
47
|
useFrontendToolVNext({
|
|
40
48
|
name,
|
|
41
49
|
description,
|
|
42
50
|
parameters: zodParameters,
|
|
43
|
-
handler:
|
|
51
|
+
handler: normalizedHandler,
|
|
44
52
|
followUp,
|
|
45
53
|
render: normalizedRender
|
|
46
54
|
});
|
|
@@ -49,4 +57,4 @@ function useFrontendTool(tool, dependencies) {
|
|
|
49
57
|
export {
|
|
50
58
|
useFrontendTool
|
|
51
59
|
};
|
|
52
|
-
//# sourceMappingURL=chunk-
|
|
60
|
+
//# sourceMappingURL=chunk-CDUIA2WM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-frontend-tool.ts"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { ActionRenderProps, FrontendAction } from \"../types/frontend-action\";\nimport { Parameter, getZodParameters, MappedParameterTypes } from \"@copilotkit/shared\";\nimport { parseJson } from \"@copilotkit/shared\";\nimport { ToolCallStatus } from \"@copilotkitnext/core\";\nimport {\n type ReactFrontendTool,\n useFrontendTool as useFrontendToolVNext,\n} from \"@copilotkitnext/react\";\n\ntype FrontendToolOptions<T extends Parameter[] | []> = ReactFrontendTool<MappedParameterTypes<T>>;\ntype FrontendToolRenderArgs<T extends Parameter[] | []> =\n | {\n name: string;\n args: Partial<MappedParameterTypes<T>>;\n status: ToolCallStatus.InProgress;\n result: undefined;\n }\n | {\n name: string;\n args: MappedParameterTypes<T>;\n status: ToolCallStatus.Executing;\n result: undefined;\n }\n | {\n name: string;\n args: MappedParameterTypes<T>;\n status: ToolCallStatus.Complete;\n result: string;\n };\n\nexport type UseFrontendToolArgs<T extends Parameter[] | [] = []> = {\n available?: \"disabled\" | \"enabled\";\n} & Pick<\n FrontendAction<T>,\n \"name\" | \"description\" | \"parameters\" | \"handler\" | \"followUp\" | \"render\"\n>;\n\nexport function useFrontendTool<const T extends Parameter[] = []>(\n tool: UseFrontendToolArgs<T>,\n dependencies?: any[],\n) {\n const { name, description, parameters, render, followUp } = tool;\n const zodParameters = getZodParameters(parameters);\n\n const normalizedRender: FrontendToolOptions<T>[\"render\"] | undefined = (() => {\n if (typeof render === \"undefined\") {\n return undefined;\n }\n\n if (typeof render === \"string\") {\n const staticRender = render;\n return (() =>\n React.createElement(\n React.Fragment,\n null,\n staticRender,\n )) as FrontendToolOptions<T>[\"render\"];\n }\n\n return ((args: FrontendToolRenderArgs<T>) => {\n const renderArgs = {\n ...args,\n result: typeof args.result === \"string\" ? parseJson(args.result, args.result) : args.result,\n } as ActionRenderProps<T>;\n\n const rendered = render(renderArgs);\n\n if (typeof rendered === \"string\") {\n return React.createElement(React.Fragment, null, rendered);\n }\n\n return rendered ?? null;\n }) as FrontendToolOptions<T>[\"render\"];\n })();\n\n // Handler ref to avoid stale closures\n const handlerRef = useRef<typeof tool.handler>(tool.handler);\n\n useEffect(() => {\n handlerRef.current = tool.handler;\n }, [tool.handler, ...(dependencies ?? [])]);\n\n const normalizedHandler = tool.handler\n ? (args: MappedParameterTypes<T>) => handlerRef.current?.(args)\n : undefined;\n\n useFrontendToolVNext<MappedParameterTypes<T>>({\n name,\n description,\n parameters: zodParameters,\n handler: normalizedHandler,\n followUp,\n render: normalizedRender,\n });\n}\n"],"mappings":";;;;;;AAAA,OAAO,SAAS,WAAW,cAAc;AAEzC,SAAoB,wBAA8C;AAClE,SAAS,iBAAiB;AAE1B;AAAA,EAEE,mBAAmB;AAAA,OACd;AA8BA,SAAS,gBACd,MACA,cACA;AACA,QAAM,EAAE,MAAM,aAAa,YAAY,QAAQ,SAAS,IAAI;AAC5D,QAAM,gBAAgB,iBAAiB,UAAU;AAEjD,QAAM,oBAAkE,MAAM;AAC5E,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACT;AAEA,QAAI,OAAO,WAAW,UAAU;AAC9B,YAAM,eAAe;AACrB,aAAQ,MACN,MAAM;AAAA,QACJ,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MACF;AAAA,IACJ;AAEA,WAAQ,CAAC,SAAoC;AAC3C,YAAM,aAAa,iCACd,OADc;AAAA,QAEjB,QAAQ,OAAO,KAAK,WAAW,WAAW,UAAU,KAAK,QAAQ,KAAK,MAAM,IAAI,KAAK;AAAA,MACvF;AAEA,YAAM,WAAW,OAAO,UAAU;AAElC,UAAI,OAAO,aAAa,UAAU;AAChC,eAAO,MAAM,cAAc,MAAM,UAAU,MAAM,QAAQ;AAAA,MAC3D;AAEA,aAAO,8BAAY;AAAA,IACrB;AAAA,EACF,GAAG;AAGH,QAAM,aAAa,OAA4B,KAAK,OAAO;AAE3D,YAAU,MAAM;AACd,eAAW,UAAU,KAAK;AAAA,EAC5B,GAAG,CAAC,KAAK,SAAS,GAAI,sCAAgB,CAAC,CAAE,CAAC;AAE1C,QAAM,oBAAoB,KAAK,UAC3B,CAAC,SAA+B;AApFtC;AAoFyC,4BAAW,YAAX,oCAAqB;AAAA,MACxD;AAEJ,uBAA8C;AAAA,IAC5C;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,SAAS;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,EACV,CAAC;AACH;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotAction
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GPEJNVE5.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useCopilotContext
|
|
6
6
|
} from "./chunk-AFNWX62Q.mjs";
|
|
@@ -56,4 +56,4 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
|
56
56
|
export {
|
|
57
57
|
useCopilotAuthenticatedAction_c
|
|
58
58
|
};
|
|
59
|
-
//# sourceMappingURL=chunk-
|
|
59
|
+
//# sourceMappingURL=chunk-E7SE25ZU.mjs.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-NBK4KBLX.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useFrontendTool
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-CDUIA2WM.mjs";
|
|
7
7
|
import {
|
|
8
8
|
useHumanInTheLoop
|
|
9
9
|
} from "./chunk-7DTB7S5V.mjs";
|
|
@@ -77,4 +77,4 @@ function useCopilotAction(action, dependencies) {
|
|
|
77
77
|
export {
|
|
78
78
|
useCopilotAction
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-GPEJNVE5.mjs.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-4CEQJ2X6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
defaultCopilotContextCategories
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4YZA2BZC.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-LCZZ7YGZ.mjs.map
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
CopilotKit,
|
|
3
3
|
CopilotKitInternal,
|
|
4
4
|
defaultCopilotContextCategories
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-4YZA2BZC.mjs";
|
|
6
6
|
import "../../chunk-LHERIF3L.mjs";
|
|
7
7
|
import "../../chunk-HE22TZMF.mjs";
|
|
8
|
-
import "../../chunk-RKTVJRK7.mjs";
|
|
9
|
-
import "../../chunk-PMAFHQ7P.mjs";
|
|
10
8
|
import "../../chunk-CYDWEPFL.mjs";
|
|
11
9
|
import "../../chunk-2IDV5OHF.mjs";
|
|
12
10
|
import "../../chunk-ICIK2BSB.mjs";
|
|
11
|
+
import "../../chunk-RKTVJRK7.mjs";
|
|
12
|
+
import "../../chunk-PMAFHQ7P.mjs";
|
|
13
13
|
import "../../chunk-YYN33GSG.mjs";
|
|
14
14
|
import "../../chunk-6PUNP7CD.mjs";
|
|
15
15
|
import "../../chunk-O7ARI5CV.mjs";
|
|
@@ -2,14 +2,14 @@ import "../../chunk-SPCZTZCY.mjs";
|
|
|
2
2
|
import {
|
|
3
3
|
CopilotKit,
|
|
4
4
|
defaultCopilotContextCategories
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-4YZA2BZC.mjs";
|
|
6
6
|
import "../../chunk-LHERIF3L.mjs";
|
|
7
7
|
import "../../chunk-HE22TZMF.mjs";
|
|
8
|
-
import "../../chunk-RKTVJRK7.mjs";
|
|
9
|
-
import "../../chunk-PMAFHQ7P.mjs";
|
|
10
8
|
import "../../chunk-CYDWEPFL.mjs";
|
|
11
9
|
import "../../chunk-2IDV5OHF.mjs";
|
|
12
10
|
import "../../chunk-ICIK2BSB.mjs";
|
|
11
|
+
import "../../chunk-RKTVJRK7.mjs";
|
|
12
|
+
import "../../chunk-PMAFHQ7P.mjs";
|
|
13
13
|
import "../../chunk-YYN33GSG.mjs";
|
|
14
14
|
import "../../chunk-6PUNP7CD.mjs";
|
|
15
15
|
import "../../chunk-O7ARI5CV.mjs";
|
|
@@ -3,14 +3,14 @@ import "../chunk-SPCZTZCY.mjs";
|
|
|
3
3
|
import {
|
|
4
4
|
CopilotKit,
|
|
5
5
|
defaultCopilotContextCategories
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-4YZA2BZC.mjs";
|
|
7
7
|
import "../chunk-LHERIF3L.mjs";
|
|
8
8
|
import "../chunk-HE22TZMF.mjs";
|
|
9
|
-
import "../chunk-RKTVJRK7.mjs";
|
|
10
|
-
import "../chunk-PMAFHQ7P.mjs";
|
|
11
9
|
import "../chunk-CYDWEPFL.mjs";
|
|
12
10
|
import "../chunk-2IDV5OHF.mjs";
|
|
13
11
|
import "../chunk-ICIK2BSB.mjs";
|
|
12
|
+
import "../chunk-RKTVJRK7.mjs";
|
|
13
|
+
import "../chunk-PMAFHQ7P.mjs";
|
|
14
14
|
import "../chunk-YYN33GSG.mjs";
|
|
15
15
|
import "../chunk-6PUNP7CD.mjs";
|
|
16
16
|
import "../chunk-O7ARI5CV.mjs";
|
package/dist/hooks/index.js
CHANGED
|
@@ -1069,11 +1069,19 @@ function useFrontendTool(tool, dependencies) {
|
|
|
1069
1069
|
return rendered != null ? rendered : null;
|
|
1070
1070
|
};
|
|
1071
1071
|
})();
|
|
1072
|
+
const handlerRef = (0, import_react16.useRef)(tool.handler);
|
|
1073
|
+
(0, import_react16.useEffect)(() => {
|
|
1074
|
+
handlerRef.current = tool.handler;
|
|
1075
|
+
}, [tool.handler, ...dependencies != null ? dependencies : []]);
|
|
1076
|
+
const normalizedHandler = tool.handler ? (args) => {
|
|
1077
|
+
var _a;
|
|
1078
|
+
return (_a = handlerRef.current) == null ? void 0 : _a.call(handlerRef, args);
|
|
1079
|
+
} : void 0;
|
|
1072
1080
|
(0, import_react17.useFrontendTool)({
|
|
1073
1081
|
name,
|
|
1074
1082
|
description,
|
|
1075
1083
|
parameters: zodParameters,
|
|
1076
|
-
handler:
|
|
1084
|
+
handler: normalizedHandler,
|
|
1077
1085
|
followUp,
|
|
1078
1086
|
render: normalizedRender
|
|
1079
1087
|
});
|