@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/dist/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "./chunk-FD6FGKYY.mjs";
|
|
3
|
-
import "./chunk-36KQV2NA.mjs";
|
|
4
3
|
import "./chunk-6YOKPWQ7.mjs";
|
|
4
|
+
import "./chunk-36KQV2NA.mjs";
|
|
5
5
|
import "./chunk-LUGEI4YQ.mjs";
|
|
6
6
|
import {
|
|
7
7
|
CopilotTask
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-LCZZ7YGZ.mjs";
|
|
9
9
|
import "./chunk-4CEQJ2X6.mjs";
|
|
10
10
|
import "./chunk-A6NKSGH3.mjs";
|
|
11
11
|
import {
|
|
12
12
|
useDefaultTool
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BUSWSDYO.mjs";
|
|
14
14
|
import {
|
|
15
15
|
useLangGraphInterrupt
|
|
16
16
|
} from "./chunk-4RRMC7L2.mjs";
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./chunk-ABWT4DRT.mjs";
|
|
23
23
|
import {
|
|
24
24
|
useCopilotAuthenticatedAction_c
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-E7SE25ZU.mjs";
|
|
26
26
|
import {
|
|
27
27
|
useCopilotChatHeadless_c
|
|
28
28
|
} from "./chunk-5J7RRLRO.mjs";
|
|
@@ -56,13 +56,13 @@ import {
|
|
|
56
56
|
import "./chunk-I76HKHPJ.mjs";
|
|
57
57
|
import {
|
|
58
58
|
useCopilotAction
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-GPEJNVE5.mjs";
|
|
60
60
|
import {
|
|
61
61
|
useRenderToolCall
|
|
62
62
|
} from "./chunk-NBK4KBLX.mjs";
|
|
63
63
|
import {
|
|
64
64
|
useFrontendTool
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-CDUIA2WM.mjs";
|
|
66
66
|
import {
|
|
67
67
|
useHumanInTheLoop
|
|
68
68
|
} from "./chunk-7DTB7S5V.mjs";
|
|
@@ -71,11 +71,9 @@ import "./chunk-SPCZTZCY.mjs";
|
|
|
71
71
|
import {
|
|
72
72
|
CopilotKit,
|
|
73
73
|
defaultCopilotContextCategories
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-4YZA2BZC.mjs";
|
|
75
75
|
import "./chunk-LHERIF3L.mjs";
|
|
76
76
|
import "./chunk-HE22TZMF.mjs";
|
|
77
|
-
import "./chunk-RKTVJRK7.mjs";
|
|
78
|
-
import "./chunk-PMAFHQ7P.mjs";
|
|
79
77
|
import "./chunk-CYDWEPFL.mjs";
|
|
80
78
|
import {
|
|
81
79
|
SUGGESTION_RETRY_CONFIG
|
|
@@ -83,6 +81,8 @@ import {
|
|
|
83
81
|
import {
|
|
84
82
|
shouldShowDevConsole
|
|
85
83
|
} from "./chunk-ICIK2BSB.mjs";
|
|
84
|
+
import "./chunk-RKTVJRK7.mjs";
|
|
85
|
+
import "./chunk-PMAFHQ7P.mjs";
|
|
86
86
|
import "./chunk-YYN33GSG.mjs";
|
|
87
87
|
import "./chunk-6PUNP7CD.mjs";
|
|
88
88
|
import "./chunk-O7ARI5CV.mjs";
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotTask
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-LCZZ7YGZ.mjs";
|
|
4
4
|
import "../chunk-4CEQJ2X6.mjs";
|
|
5
5
|
import "../chunk-JD7BAH7U.mjs";
|
|
6
6
|
import "../chunk-SPCZTZCY.mjs";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-4YZA2BZC.mjs";
|
|
8
8
|
import "../chunk-LHERIF3L.mjs";
|
|
9
9
|
import "../chunk-HE22TZMF.mjs";
|
|
10
|
-
import "../chunk-RKTVJRK7.mjs";
|
|
11
|
-
import "../chunk-PMAFHQ7P.mjs";
|
|
12
10
|
import "../chunk-CYDWEPFL.mjs";
|
|
13
11
|
import "../chunk-2IDV5OHF.mjs";
|
|
14
12
|
import "../chunk-ICIK2BSB.mjs";
|
|
13
|
+
import "../chunk-RKTVJRK7.mjs";
|
|
14
|
+
import "../chunk-PMAFHQ7P.mjs";
|
|
15
15
|
import "../chunk-YYN33GSG.mjs";
|
|
16
16
|
import "../chunk-6PUNP7CD.mjs";
|
|
17
17
|
import "../chunk-O7ARI5CV.mjs";
|
package/dist/lib/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import "../chunk-LUGEI4YQ.mjs";
|
|
2
2
|
import {
|
|
3
3
|
CopilotTask
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-LCZZ7YGZ.mjs";
|
|
5
5
|
import "../chunk-4CEQJ2X6.mjs";
|
|
6
6
|
import "../chunk-JD7BAH7U.mjs";
|
|
7
7
|
import "../chunk-SPCZTZCY.mjs";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-4YZA2BZC.mjs";
|
|
9
9
|
import "../chunk-LHERIF3L.mjs";
|
|
10
10
|
import "../chunk-HE22TZMF.mjs";
|
|
11
|
-
import "../chunk-RKTVJRK7.mjs";
|
|
12
|
-
import "../chunk-PMAFHQ7P.mjs";
|
|
13
11
|
import "../chunk-CYDWEPFL.mjs";
|
|
14
12
|
import "../chunk-2IDV5OHF.mjs";
|
|
15
13
|
import "../chunk-ICIK2BSB.mjs";
|
|
14
|
+
import "../chunk-RKTVJRK7.mjs";
|
|
15
|
+
import "../chunk-PMAFHQ7P.mjs";
|
|
16
16
|
import "../chunk-YYN33GSG.mjs";
|
|
17
17
|
import "../chunk-6PUNP7CD.mjs";
|
|
18
18
|
import "../chunk-O7ARI5CV.mjs";
|
package/dist/types/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.50.
|
|
12
|
+
"version": "1.50.1-next.1",
|
|
13
13
|
"sideEffects": [
|
|
14
14
|
"**/*.css"
|
|
15
15
|
],
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"@scarf/scarf": "^1.3.0",
|
|
62
62
|
"react-markdown": "^8.0.7",
|
|
63
63
|
"untruncate-json": "^0.0.1",
|
|
64
|
-
"@copilotkit/
|
|
65
|
-
"@copilotkit/
|
|
64
|
+
"@copilotkit/shared": "1.50.1-next.1",
|
|
65
|
+
"@copilotkit/runtime-client-gql": "1.50.1-next.1"
|
|
66
66
|
},
|
|
67
67
|
"keywords": [
|
|
68
68
|
"copilotkit",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
2
|
import { ActionRenderProps, FrontendAction } from "../types/frontend-action";
|
|
3
3
|
import { Parameter, getZodParameters, MappedParameterTypes } from "@copilotkit/shared";
|
|
4
4
|
import { parseJson } from "@copilotkit/shared";
|
|
@@ -74,11 +74,22 @@ export function useFrontendTool<const T extends Parameter[] = []>(
|
|
|
74
74
|
}) as FrontendToolOptions<T>["render"];
|
|
75
75
|
})();
|
|
76
76
|
|
|
77
|
+
// Handler ref to avoid stale closures
|
|
78
|
+
const handlerRef = useRef<typeof tool.handler>(tool.handler);
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
handlerRef.current = tool.handler;
|
|
82
|
+
}, [tool.handler, ...(dependencies ?? [])]);
|
|
83
|
+
|
|
84
|
+
const normalizedHandler = tool.handler
|
|
85
|
+
? (args: MappedParameterTypes<T>) => handlerRef.current?.(args)
|
|
86
|
+
: undefined;
|
|
87
|
+
|
|
77
88
|
useFrontendToolVNext<MappedParameterTypes<T>>({
|
|
78
89
|
name,
|
|
79
90
|
description,
|
|
80
91
|
parameters: zodParameters,
|
|
81
|
-
handler:
|
|
92
|
+
handler: normalizedHandler,
|
|
82
93
|
followUp,
|
|
83
94
|
render: normalizedRender,
|
|
84
95
|
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-frontend-tool.ts"],"sourcesContent":["import React 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 useFrontendToolVNext<MappedParameterTypes<T>>({\n name,\n description,\n parameters: zodParameters,\n handler: tool.handler,\n followUp,\n render: normalizedRender,\n });\n}\n"],"mappings":";;;;;;AAAA,OAAO,WAAW;AAElB,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;AAEH,uBAA8C;AAAA,IAC5C;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,SAAS,KAAK;AAAA,IACd;AAAA,IACA,QAAQ;AAAA,EACV,CAAC;AACH;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|