@copilotkitnext/react 0.0.22-alpha.3 → 0.0.22-alpha.4
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/{chunk-3TA5QBSZ.mjs → chunk-7HM7CU5A.mjs} +2 -2
- package/dist/{chunk-VUHFLJWI.mjs → chunk-BNT754Z2.mjs} +2 -2
- package/dist/{chunk-TKFOXPXF.mjs → chunk-CDSO65ZY.mjs} +5 -5
- package/dist/{chunk-IH5VFJ4L.mjs → chunk-GK4NXPLC.mjs} +4 -4
- package/dist/{chunk-F43IPGPA.mjs → chunk-N5HC66HU.mjs} +5 -5
- package/dist/{chunk-QFBM3ZT2.mjs → chunk-TBE7ZI5G.mjs} +4 -4
- package/dist/components/chat/CopilotChat.mjs +21 -21
- package/dist/components/chat/CopilotChatAssistantMessage.mjs +13 -13
- package/dist/components/chat/CopilotChatInput.mjs +3 -3
- package/dist/components/chat/CopilotChatMessageView.mjs +14 -14
- package/dist/components/chat/CopilotChatToolCallsView.mjs +12 -12
- package/dist/components/chat/CopilotChatView.d.mts +1 -1
- package/dist/components/chat/CopilotChatView.d.ts +1 -1
- package/dist/components/chat/CopilotChatView.mjs +20 -20
- package/dist/components/chat/CopilotModalHeader.d.mts +1 -1
- package/dist/components/chat/CopilotModalHeader.d.ts +1 -1
- package/dist/components/chat/CopilotPopup.mjs +24 -24
- package/dist/components/chat/CopilotPopupView.mjs +22 -22
- package/dist/components/chat/CopilotSidebar.mjs +24 -24
- package/dist/components/chat/CopilotSidebarView.mjs +22 -22
- package/dist/components/chat/index.mjs +37 -37
- package/dist/components/index.mjs +38 -38
- package/dist/components/ui/button.d.mts +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/hooks/index.mjs +20 -20
- package/dist/hooks/use-agent-context.mjs +3 -3
- package/dist/hooks/use-agent.mjs +3 -3
- package/dist/hooks/use-configure-suggestions.mjs +3 -3
- package/dist/hooks/use-frontend-tool.mjs +3 -3
- package/dist/hooks/use-human-in-the-loop.mjs +4 -4
- package/dist/hooks/use-render-activity-message.mjs +3 -3
- package/dist/hooks/use-render-custom-messages.mjs +3 -3
- package/dist/hooks/use-render-tool-call.mjs +3 -3
- package/dist/hooks/use-suggestions.mjs +3 -3
- package/dist/index.mjs +51 -51
- package/dist/providers/CopilotKitProvider.mjs +2 -2
- package/dist/providers/index.mjs +2 -2
- package/dist/types/index.mjs +2 -2
- package/package.json +6 -6
- package/dist/chunk-5AAT4Z3C.mjs +0 -107
- package/dist/chunk-5AAT4Z3C.mjs.map +0 -1
- package/dist/chunk-CSHBUHRW.mjs +0 -69
- package/dist/chunk-CSHBUHRW.mjs.map +0 -1
- package/dist/chunk-CZ3GI3IF.mjs +0 -283
- package/dist/chunk-CZ3GI3IF.mjs.map +0 -1
- package/dist/chunk-E4HD4M7R.mjs +0 -76
- package/dist/chunk-E4HD4M7R.mjs.map +0 -1
- package/dist/chunk-EJ5ZEAAN.mjs +0 -57
- package/dist/chunk-EJ5ZEAAN.mjs.map +0 -1
- package/dist/chunk-NASFZS3N.mjs +0 -43
- package/dist/chunk-NASFZS3N.mjs.map +0 -1
- package/dist/chunk-QJ6DZ645.mjs +0 -78
- package/dist/chunk-QJ6DZ645.mjs.map +0 -1
- package/dist/chunk-VE3SBLU7.mjs +0 -215
- package/dist/chunk-VE3SBLU7.mjs.map +0 -1
- package/dist/chunk-W5DUKRCI.mjs +0 -97
- package/dist/chunk-W5DUKRCI.mjs.map +0 -1
- package/dist/chunk-WNRDFAZ5.mjs +0 -22
- package/dist/chunk-WNRDFAZ5.mjs.map +0 -1
- package/dist/chunk-YVPPF62K.mjs +0 -32
- package/dist/chunk-YVPPF62K.mjs.map +0 -1
- package/dist/chunk-Z3OIGQCZ.mjs +0 -75
- package/dist/chunk-Z3OIGQCZ.mjs.map +0 -1
- package/dist/chunk-ZIDT52TM.mjs +0 -131
- package/dist/chunk-ZIDT52TM.mjs.map +0 -1
- /package/dist/{chunk-3TA5QBSZ.mjs.map → chunk-7HM7CU5A.mjs.map} +0 -0
- /package/dist/{chunk-VUHFLJWI.mjs.map → chunk-BNT754Z2.mjs.map} +0 -0
- /package/dist/{chunk-TKFOXPXF.mjs.map → chunk-CDSO65ZY.mjs.map} +0 -0
- /package/dist/{chunk-IH5VFJ4L.mjs.map → chunk-GK4NXPLC.mjs.map} +0 -0
- /package/dist/{chunk-F43IPGPA.mjs.map → chunk-N5HC66HU.mjs.map} +0 -0
- /package/dist/{chunk-QFBM3ZT2.mjs.map → chunk-TBE7ZI5G.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,66 +1,68 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "./chunk-N5EP5OD5.mjs";
|
|
3
|
-
import "./chunk-KPRUSQ3K.mjs";
|
|
4
|
-
import "./chunk-US4KNAAV.mjs";
|
|
5
3
|
import "./chunk-36HFWACS.mjs";
|
|
6
4
|
import "./chunk-DVUQO72Z.mjs";
|
|
7
5
|
import "./chunk-VBI6JXPC.mjs";
|
|
6
|
+
import "./chunk-KPRUSQ3K.mjs";
|
|
7
|
+
import "./chunk-US4KNAAV.mjs";
|
|
8
8
|
import "./chunk-MWC5OV7Z.mjs";
|
|
9
9
|
import "./chunk-6VUKDHOD.mjs";
|
|
10
10
|
import {
|
|
11
11
|
CopilotPopup
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-RRXDJCXI.mjs";
|
|
13
13
|
import {
|
|
14
14
|
CopilotPopupView
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-NB4DFAZH.mjs";
|
|
16
16
|
import {
|
|
17
17
|
CopilotSidebar
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-FVURPXQK.mjs";
|
|
19
19
|
import {
|
|
20
20
|
CopilotSidebarView
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import {
|
|
23
|
-
CopilotModalHeader
|
|
24
|
-
} from "./chunk-E56GYBP3.mjs";
|
|
21
|
+
} from "./chunk-OMPVTGXH.mjs";
|
|
25
22
|
import {
|
|
26
23
|
CopilotChatToggleButton,
|
|
27
24
|
DefaultCloseIcon,
|
|
28
25
|
DefaultOpenIcon
|
|
29
26
|
} from "./chunk-R5OLAA3L.mjs";
|
|
27
|
+
import {
|
|
28
|
+
CopilotModalHeader
|
|
29
|
+
} from "./chunk-E56GYBP3.mjs";
|
|
30
30
|
import {
|
|
31
31
|
CopilotChat
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-32YJ5VJ4.mjs";
|
|
33
33
|
import {
|
|
34
34
|
CopilotChatView_default
|
|
35
|
-
} from "./chunk-
|
|
36
|
-
import {
|
|
37
|
-
CopilotChatInput_default
|
|
38
|
-
} from "./chunk-KCVDFZJX.mjs";
|
|
39
|
-
import {
|
|
40
|
-
AudioRecorderError,
|
|
41
|
-
CopilotChatAudioRecorder
|
|
42
|
-
} from "./chunk-4UDBR75C.mjs";
|
|
35
|
+
} from "./chunk-JLVGSNAO.mjs";
|
|
43
36
|
import {
|
|
44
37
|
CopilotChatMessageView_default
|
|
45
|
-
} from "./chunk-
|
|
46
|
-
import {
|
|
47
|
-
CopilotChatUserMessage_default
|
|
48
|
-
} from "./chunk-BT6C5OPU.mjs";
|
|
49
|
-
import {
|
|
50
|
-
CopilotChatAssistantMessage_default
|
|
51
|
-
} from "./chunk-CZ3GI3IF.mjs";
|
|
38
|
+
} from "./chunk-AI3Z3CHN.mjs";
|
|
52
39
|
import {
|
|
53
40
|
CopilotChatSuggestionView_default
|
|
54
41
|
} from "./chunk-RGD2L3Z4.mjs";
|
|
55
42
|
import {
|
|
56
43
|
CopilotChatSuggestionPill_default
|
|
57
44
|
} from "./chunk-NNPKBGD6.mjs";
|
|
45
|
+
import {
|
|
46
|
+
CopilotChatUserMessage_default
|
|
47
|
+
} from "./chunk-BT6C5OPU.mjs";
|
|
48
|
+
import {
|
|
49
|
+
CopilotChatAssistantMessage_default
|
|
50
|
+
} from "./chunk-SPDE34WC.mjs";
|
|
58
51
|
import {
|
|
59
52
|
CopilotChatToolCallsView_default
|
|
60
|
-
} from "./chunk-
|
|
61
|
-
import
|
|
53
|
+
} from "./chunk-AEFM73CL.mjs";
|
|
54
|
+
import {
|
|
55
|
+
CopilotChatInput_default
|
|
56
|
+
} from "./chunk-UZB3CTOY.mjs";
|
|
62
57
|
import "./chunk-JWOIINVV.mjs";
|
|
58
|
+
import "./chunk-TAUOEJH2.mjs";
|
|
63
59
|
import "./chunk-VVAXSF3M.mjs";
|
|
60
|
+
import {
|
|
61
|
+
AudioRecorderError,
|
|
62
|
+
CopilotChatAudioRecorder
|
|
63
|
+
} from "./chunk-4UDBR75C.mjs";
|
|
64
|
+
import "./chunk-FIBK3DYE.mjs";
|
|
65
|
+
import "./chunk-XO4IRKSC.mjs";
|
|
64
66
|
import "./chunk-FZR2XQKR.mjs";
|
|
65
67
|
import {
|
|
66
68
|
WildcardToolCallRender
|
|
@@ -68,37 +70,35 @@ import {
|
|
|
68
70
|
import {
|
|
69
71
|
defineToolCallRenderer
|
|
70
72
|
} from "./chunk-46BZRXWT.mjs";
|
|
71
|
-
import "./chunk-FIBK3DYE.mjs";
|
|
72
|
-
import "./chunk-XO4IRKSC.mjs";
|
|
73
73
|
import "./chunk-ETWJDCGE.mjs";
|
|
74
|
+
import {
|
|
75
|
+
useHumanInTheLoop
|
|
76
|
+
} from "./chunk-CGLGXQAU.mjs";
|
|
77
|
+
import {
|
|
78
|
+
useFrontendTool
|
|
79
|
+
} from "./chunk-IICUCI5S.mjs";
|
|
80
|
+
import {
|
|
81
|
+
useRenderActivityMessage
|
|
82
|
+
} from "./chunk-RK5P2LG6.mjs";
|
|
83
|
+
import {
|
|
84
|
+
useRenderCustomMessages
|
|
85
|
+
} from "./chunk-5SC3CO5Q.mjs";
|
|
86
|
+
import "./chunk-YZUPVMHC.mjs";
|
|
74
87
|
import {
|
|
75
88
|
useRenderToolCall
|
|
76
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-AXFRCGH6.mjs";
|
|
77
90
|
import {
|
|
78
91
|
useSuggestions
|
|
79
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-XU5CEPYQ.mjs";
|
|
80
93
|
import {
|
|
81
94
|
useAgentContext
|
|
82
|
-
} from "./chunk-
|
|
95
|
+
} from "./chunk-UOX5D73C.mjs";
|
|
83
96
|
import {
|
|
84
97
|
useAgent
|
|
85
|
-
} from "./chunk-
|
|
98
|
+
} from "./chunk-IA4CLXDM.mjs";
|
|
86
99
|
import {
|
|
87
100
|
useConfigureSuggestions
|
|
88
|
-
} from "./chunk-
|
|
89
|
-
import {
|
|
90
|
-
useHumanInTheLoop
|
|
91
|
-
} from "./chunk-QJ6DZ645.mjs";
|
|
92
|
-
import {
|
|
93
|
-
useFrontendTool
|
|
94
|
-
} from "./chunk-NASFZS3N.mjs";
|
|
95
|
-
import {
|
|
96
|
-
useRenderActivityMessage
|
|
97
|
-
} from "./chunk-EJ5ZEAAN.mjs";
|
|
98
|
-
import {
|
|
99
|
-
useRenderCustomMessages
|
|
100
|
-
} from "./chunk-CSHBUHRW.mjs";
|
|
101
|
-
import "./chunk-YZUPVMHC.mjs";
|
|
101
|
+
} from "./chunk-NB2GZAKG.mjs";
|
|
102
102
|
import {
|
|
103
103
|
CopilotChatConfigurationProvider,
|
|
104
104
|
useCopilotChatConfiguration
|
|
@@ -106,13 +106,13 @@ import {
|
|
|
106
106
|
import {
|
|
107
107
|
CopilotKitProvider,
|
|
108
108
|
useCopilotKit
|
|
109
|
-
} from "./chunk-
|
|
110
|
-
import {
|
|
111
|
-
CopilotKitInspector
|
|
112
|
-
} from "./chunk-YPH4BHOY.mjs";
|
|
109
|
+
} from "./chunk-RF2CGPHQ.mjs";
|
|
113
110
|
import {
|
|
114
111
|
CopilotKitCoreReact
|
|
115
112
|
} from "./chunk-NNAYEAP2.mjs";
|
|
113
|
+
import {
|
|
114
|
+
CopilotKitInspector
|
|
115
|
+
} from "./chunk-YPH4BHOY.mjs";
|
|
116
116
|
export {
|
|
117
117
|
AudioRecorderError,
|
|
118
118
|
CopilotChat,
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
CopilotKitProvider,
|
|
4
4
|
useCopilotKit
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-YPH4BHOY.mjs";
|
|
5
|
+
} from "../chunk-RF2CGPHQ.mjs";
|
|
7
6
|
import "../chunk-NNAYEAP2.mjs";
|
|
7
|
+
import "../chunk-YPH4BHOY.mjs";
|
|
8
8
|
export {
|
|
9
9
|
CopilotKitProvider,
|
|
10
10
|
useCopilotKit
|
package/dist/providers/index.mjs
CHANGED
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
CopilotKitProvider,
|
|
8
8
|
useCopilotKit
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-YPH4BHOY.mjs";
|
|
9
|
+
} from "../chunk-RF2CGPHQ.mjs";
|
|
11
10
|
import "../chunk-NNAYEAP2.mjs";
|
|
11
|
+
import "../chunk-YPH4BHOY.mjs";
|
|
12
12
|
export {
|
|
13
13
|
CopilotChatConfigurationProvider,
|
|
14
14
|
CopilotKitProvider,
|
package/dist/types/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "../chunk-N5EP5OD5.mjs";
|
|
2
|
-
import "../chunk-KPRUSQ3K.mjs";
|
|
3
|
-
import "../chunk-US4KNAAV.mjs";
|
|
4
2
|
import "../chunk-36HFWACS.mjs";
|
|
5
3
|
import "../chunk-DVUQO72Z.mjs";
|
|
6
4
|
import "../chunk-VBI6JXPC.mjs";
|
|
5
|
+
import "../chunk-KPRUSQ3K.mjs";
|
|
6
|
+
import "../chunk-US4KNAAV.mjs";
|
|
7
7
|
import {
|
|
8
8
|
defineToolCallRenderer
|
|
9
9
|
} from "../chunk-46BZRXWT.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copilotkitnext/react",
|
|
3
|
-
"version": "0.0.22-alpha.
|
|
3
|
+
"version": "0.0.22-alpha.4",
|
|
4
4
|
"description": "React components for CopilotKit2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"tsup": "^8.5.0",
|
|
36
36
|
"typescript": "5.8.2",
|
|
37
37
|
"vitest": "^3.2.4",
|
|
38
|
-
"@copilotkitnext/
|
|
39
|
-
"@copilotkitnext/
|
|
38
|
+
"@copilotkitnext/typescript-config": "0.0.0",
|
|
39
|
+
"@copilotkitnext/eslint-config": "0.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@ag-ui/client": "0.0.41-alpha.0",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"tw-animate-css": "^1.3.5",
|
|
56
56
|
"use-stick-to-bottom": "^1.1.1",
|
|
57
57
|
"zod": "^3.25.75",
|
|
58
|
-
"@copilotkitnext/web-inspector": "0.0.22-alpha.
|
|
59
|
-
"@copilotkitnext/
|
|
60
|
-
"@copilotkitnext/
|
|
58
|
+
"@copilotkitnext/web-inspector": "0.0.22-alpha.4",
|
|
59
|
+
"@copilotkitnext/shared": "0.0.22-alpha.4",
|
|
60
|
+
"@copilotkitnext/core": "0.0.22-alpha.4"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"react": ">=16.8.0",
|
package/dist/chunk-5AAT4Z3C.mjs
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useCopilotChatConfiguration
|
|
3
|
-
} from "./chunk-4XJK5IVQ.mjs";
|
|
4
|
-
import {
|
|
5
|
-
useCopilotKit
|
|
6
|
-
} from "./chunk-VE3SBLU7.mjs";
|
|
7
|
-
|
|
8
|
-
// src/hooks/use-render-tool-call.tsx
|
|
9
|
-
import { useCallback, useEffect, useState, useSyncExternalStore } from "react";
|
|
10
|
-
import { ToolCallStatus } from "@copilotkitnext/core";
|
|
11
|
-
import { DEFAULT_AGENT_ID } from "@copilotkitnext/shared";
|
|
12
|
-
import { partialJSONParse } from "@copilotkitnext/shared";
|
|
13
|
-
import { jsx } from "react/jsx-runtime";
|
|
14
|
-
function useRenderToolCall() {
|
|
15
|
-
const { copilotkit } = useCopilotKit();
|
|
16
|
-
const config = useCopilotChatConfiguration();
|
|
17
|
-
const agentId = config?.agentId ?? DEFAULT_AGENT_ID;
|
|
18
|
-
const [executingToolCallIds, setExecutingToolCallIds] = useState(() => /* @__PURE__ */ new Set());
|
|
19
|
-
const renderToolCalls = useSyncExternalStore(
|
|
20
|
-
(callback) => {
|
|
21
|
-
return copilotkit.subscribe({
|
|
22
|
-
onRenderToolCallsChanged: callback
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
() => copilotkit.renderToolCalls,
|
|
26
|
-
() => copilotkit.renderToolCalls
|
|
27
|
-
);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const unsubscribe = copilotkit.subscribe({
|
|
30
|
-
onToolExecutionStart: ({ toolCallId }) => {
|
|
31
|
-
setExecutingToolCallIds((prev) => {
|
|
32
|
-
if (prev.has(toolCallId)) return prev;
|
|
33
|
-
const next = new Set(prev);
|
|
34
|
-
next.add(toolCallId);
|
|
35
|
-
return next;
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
onToolExecutionEnd: ({ toolCallId }) => {
|
|
39
|
-
setExecutingToolCallIds((prev) => {
|
|
40
|
-
if (!prev.has(toolCallId)) return prev;
|
|
41
|
-
const next = new Set(prev);
|
|
42
|
-
next.delete(toolCallId);
|
|
43
|
-
return next;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return () => unsubscribe();
|
|
48
|
-
}, [copilotkit]);
|
|
49
|
-
const renderToolCall = useCallback(
|
|
50
|
-
({
|
|
51
|
-
toolCall,
|
|
52
|
-
toolMessage
|
|
53
|
-
}) => {
|
|
54
|
-
const exactMatches = renderToolCalls.filter(
|
|
55
|
-
(rc) => rc.name === toolCall.function.name
|
|
56
|
-
);
|
|
57
|
-
const renderConfig = exactMatches.find((rc) => rc.agentId === agentId) || exactMatches.find((rc) => !rc.agentId) || exactMatches[0] || renderToolCalls.find((rc) => rc.name === "*");
|
|
58
|
-
if (!renderConfig) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
const RenderComponent = renderConfig.render;
|
|
62
|
-
const args = partialJSONParse(toolCall.function.arguments);
|
|
63
|
-
const toolName = toolCall.function.name;
|
|
64
|
-
if (toolMessage) {
|
|
65
|
-
return /* @__PURE__ */ jsx(
|
|
66
|
-
RenderComponent,
|
|
67
|
-
{
|
|
68
|
-
name: toolName,
|
|
69
|
-
args,
|
|
70
|
-
status: ToolCallStatus.Complete,
|
|
71
|
-
result: toolMessage.content
|
|
72
|
-
},
|
|
73
|
-
toolCall.id
|
|
74
|
-
);
|
|
75
|
-
} else if (executingToolCallIds.has(toolCall.id)) {
|
|
76
|
-
return /* @__PURE__ */ jsx(
|
|
77
|
-
RenderComponent,
|
|
78
|
-
{
|
|
79
|
-
name: toolName,
|
|
80
|
-
args,
|
|
81
|
-
status: ToolCallStatus.Executing,
|
|
82
|
-
result: void 0
|
|
83
|
-
},
|
|
84
|
-
toolCall.id
|
|
85
|
-
);
|
|
86
|
-
} else {
|
|
87
|
-
return /* @__PURE__ */ jsx(
|
|
88
|
-
RenderComponent,
|
|
89
|
-
{
|
|
90
|
-
name: toolName,
|
|
91
|
-
args,
|
|
92
|
-
status: ToolCallStatus.InProgress,
|
|
93
|
-
result: void 0
|
|
94
|
-
},
|
|
95
|
-
toolCall.id
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
[renderToolCalls, executingToolCallIds, agentId]
|
|
100
|
-
);
|
|
101
|
-
return renderToolCall;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export {
|
|
105
|
-
useRenderToolCall
|
|
106
|
-
};
|
|
107
|
-
//# sourceMappingURL=chunk-5AAT4Z3C.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-render-tool-call.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState, useSyncExternalStore } from \"react\";\nimport { ToolCall, ToolMessage } from \"@ag-ui/core\";\nimport { ToolCallStatus } from \"@copilotkitnext/core\";\nimport { useCopilotKit } from \"@/providers/CopilotKitProvider\";\nimport { useCopilotChatConfiguration } from \"@/providers/CopilotChatConfigurationProvider\";\nimport { DEFAULT_AGENT_ID } from \"@copilotkitnext/shared\";\nimport { partialJSONParse } from \"@copilotkitnext/shared\";\n\nexport interface UseRenderToolCallProps {\n toolCall: ToolCall;\n toolMessage?: ToolMessage;\n}\n\n/**\n * Hook that returns a function to render tool calls based on the render functions\n * defined in CopilotKitProvider.\n *\n * @returns A function that takes a tool call and optional tool message and returns the rendered component\n */\nexport function useRenderToolCall() {\n const { copilotkit } = useCopilotKit();\n const config = useCopilotChatConfiguration();\n const agentId = config?.agentId ?? DEFAULT_AGENT_ID;\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n // Subscribe to render tool calls changes using useSyncExternalStore\n // This ensures we always have the latest value, even if subscriptions run in any order\n const renderToolCalls = useSyncExternalStore(\n (callback) => {\n return copilotkit.subscribe({\n onRenderToolCallsChanged: callback,\n });\n },\n () => copilotkit.renderToolCalls,\n () => copilotkit.renderToolCalls\n );\n\n useEffect(() => {\n const unsubscribe = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n });\n return () => unsubscribe();\n }, [copilotkit]);\n\n const renderToolCall = useCallback(\n ({\n toolCall,\n toolMessage,\n }: UseRenderToolCallProps): React.ReactElement | null => {\n // Find the render config for this tool call by name\n // For rendering, we show all tool calls regardless of agentId\n // The agentId scoping only affects handler execution (in core)\n // Priority order:\n // 1. Exact match by name (prefer agent-specific if multiple exist)\n // 2. Wildcard (*) renderer\n const exactMatches = renderToolCalls.filter(\n (rc) => rc.name === toolCall.function.name\n );\n\n // If multiple renderers with same name exist, prefer the one matching our agentId\n const renderConfig =\n exactMatches.find((rc) => rc.agentId === agentId) ||\n exactMatches.find((rc) => !rc.agentId) ||\n exactMatches[0] ||\n renderToolCalls.find((rc) => rc.name === \"*\");\n\n if (!renderConfig) {\n return null;\n }\n\n const RenderComponent = renderConfig.render;\n\n // Parse the arguments if they're a string\n const args = partialJSONParse(toolCall.function.arguments);\n\n // Create props based on status with proper typing\n const toolName = toolCall.function.name;\n\n if (toolMessage) {\n // Complete status with result\n return (\n <RenderComponent\n key={toolCall.id}\n name={toolName}\n args={args}\n status={ToolCallStatus.Complete}\n result={toolMessage.content}\n />\n );\n } else if (executingToolCallIds.has(toolCall.id)) {\n // Tool is currently executing\n return (\n <RenderComponent\n key={toolCall.id}\n name={toolName}\n // args should be complete when executing; but pass whatever we have\n args={args}\n status={ToolCallStatus.Executing}\n result={undefined}\n />\n );\n } else {\n // In progress status - tool call exists but hasn't completed yet\n // This remains true even after agent stops running, until we get a result\n return (\n <RenderComponent\n key={toolCall.id}\n name={toolName}\n args={args}\n status={ToolCallStatus.InProgress}\n result={undefined}\n />\n );\n }\n },\n [renderToolCalls, executingToolCallIds, agentId]\n );\n\n return renderToolCall;\n}\n"],"mappings":";;;;;;;;AAAA,SAAgB,aAAa,WAAW,UAAU,4BAA4B;AAE9E,SAAS,sBAAsB;AAG/B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AA4FvB;AA/EH,SAAS,oBAAoB;AAClC,QAAM,EAAE,WAAW,IAAI,cAAc;AACrC,QAAM,SAAS,4BAA4B;AAC3C,QAAM,UAAU,QAAQ,WAAW;AACnC,QAAM,CAAC,sBAAsB,uBAAuB,IAAI,SAEtD,MAAM,oBAAI,IAAI,CAAC;AAIjB,QAAM,kBAAkB;AAAA,IACtB,CAAC,aAAa;AACZ,aAAO,WAAW,UAAU;AAAA,QAC1B,0BAA0B;AAAA,MAC5B,CAAC;AAAA,IACH;AAAA,IACA,MAAM,WAAW;AAAA,IACjB,MAAM,WAAW;AAAA,EACnB;AAEA,YAAU,MAAM;AACd,UAAM,cAAc,WAAW,UAAU;AAAA,MACvC,sBAAsB,CAAC,EAAE,WAAW,MAAM;AACxC,gCAAwB,CAAC,SAAS;AAChC,cAAI,KAAK,IAAI,UAAU,EAAG,QAAO;AACjC,gBAAM,OAAO,IAAI,IAAI,IAAI;AACzB,eAAK,IAAI,UAAU;AACnB,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,MACA,oBAAoB,CAAC,EAAE,WAAW,MAAM;AACtC,gCAAwB,CAAC,SAAS;AAChC,cAAI,CAAC,KAAK,IAAI,UAAU,EAAG,QAAO;AAClC,gBAAM,OAAO,IAAI,IAAI,IAAI;AACzB,eAAK,OAAO,UAAU;AACtB,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AACD,WAAO,MAAM,YAAY;AAAA,EAC3B,GAAG,CAAC,UAAU,CAAC;AAEf,QAAM,iBAAiB;AAAA,IACrB,CAAC;AAAA,MACC;AAAA,MACA;AAAA,IACF,MAAyD;AAOvD,YAAM,eAAe,gBAAgB;AAAA,QACnC,CAAC,OAAO,GAAG,SAAS,SAAS,SAAS;AAAA,MACxC;AAGA,YAAM,eACJ,aAAa,KAAK,CAAC,OAAO,GAAG,YAAY,OAAO,KAChD,aAAa,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO,KACrC,aAAa,CAAC,KACd,gBAAgB,KAAK,CAAC,OAAO,GAAG,SAAS,GAAG;AAE9C,UAAI,CAAC,cAAc;AACjB,eAAO;AAAA,MACT;AAEA,YAAM,kBAAkB,aAAa;AAGrC,YAAM,OAAO,iBAAiB,SAAS,SAAS,SAAS;AAGzD,YAAM,WAAW,SAAS,SAAS;AAEnC,UAAI,aAAa;AAEf,eACE;AAAA,UAAC;AAAA;AAAA,YAEC,MAAM;AAAA,YACN;AAAA,YACA,QAAQ,eAAe;AAAA,YACvB,QAAQ,YAAY;AAAA;AAAA,UAJf,SAAS;AAAA,QAKhB;AAAA,MAEJ,WAAW,qBAAqB,IAAI,SAAS,EAAE,GAAG;AAEhD,eACE;AAAA,UAAC;AAAA;AAAA,YAEC,MAAM;AAAA,YAEN;AAAA,YACA,QAAQ,eAAe;AAAA,YACvB,QAAQ;AAAA;AAAA,UALH,SAAS;AAAA,QAMhB;AAAA,MAEJ,OAAO;AAGL,eACE;AAAA,UAAC;AAAA;AAAA,YAEC,MAAM;AAAA,YACN;AAAA,YACA,QAAQ,eAAe;AAAA,YACvB,QAAQ;AAAA;AAAA,UAJH,SAAS;AAAA,QAKhB;AAAA,MAEJ;AAAA,IACF;AAAA,IACA,CAAC,iBAAiB,sBAAsB,OAAO;AAAA,EACjD;AAEA,SAAO;AACT;","names":[]}
|
package/dist/chunk-CSHBUHRW.mjs
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useCopilotChatConfiguration
|
|
3
|
-
} from "./chunk-4XJK5IVQ.mjs";
|
|
4
|
-
import {
|
|
5
|
-
useCopilotKit
|
|
6
|
-
} from "./chunk-VE3SBLU7.mjs";
|
|
7
|
-
|
|
8
|
-
// src/hooks/use-render-custom-messages.tsx
|
|
9
|
-
import { jsx } from "react/jsx-runtime";
|
|
10
|
-
function useRenderCustomMessages() {
|
|
11
|
-
const { copilotkit } = useCopilotKit();
|
|
12
|
-
const config = useCopilotChatConfiguration();
|
|
13
|
-
if (!config) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
const { agentId, threadId } = config;
|
|
17
|
-
const customMessageRenderers = copilotkit.renderCustomMessages.filter((renderer) => renderer.agentId === void 0 || renderer.agentId === agentId).sort((a, b) => {
|
|
18
|
-
const aHasAgent = a.agentId !== void 0;
|
|
19
|
-
const bHasAgent = b.agentId !== void 0;
|
|
20
|
-
if (aHasAgent === bHasAgent) return 0;
|
|
21
|
-
return aHasAgent ? -1 : 1;
|
|
22
|
-
});
|
|
23
|
-
return function(params) {
|
|
24
|
-
if (!customMessageRenderers.length) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
const { message, position } = params;
|
|
28
|
-
const runId = copilotkit.getRunIdForMessage(agentId, threadId, message.id);
|
|
29
|
-
const agent = copilotkit.getAgent(agentId);
|
|
30
|
-
if (!agent) {
|
|
31
|
-
throw new Error("Agent not found");
|
|
32
|
-
}
|
|
33
|
-
const messagesIdsInRun = agent.messages.filter((msg) => copilotkit.getRunIdForMessage(agentId, threadId, msg.id) === runId).map((msg) => msg.id);
|
|
34
|
-
const messageIndex = agent.messages.findIndex((msg) => msg.id === message.id) ?? 0;
|
|
35
|
-
const messageIndexInRun = Math.min(messagesIdsInRun.indexOf(message.id), 0);
|
|
36
|
-
const numberOfMessagesInRun = messagesIdsInRun.length;
|
|
37
|
-
const stateSnapshot = copilotkit.getStateByRun(agentId, threadId, runId);
|
|
38
|
-
let result = null;
|
|
39
|
-
for (const renderer of customMessageRenderers) {
|
|
40
|
-
if (!renderer.render) {
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
const Component = renderer.render;
|
|
44
|
-
result = /* @__PURE__ */ jsx(
|
|
45
|
-
Component,
|
|
46
|
-
{
|
|
47
|
-
message,
|
|
48
|
-
position,
|
|
49
|
-
runId,
|
|
50
|
-
messageIndex,
|
|
51
|
-
messageIndexInRun,
|
|
52
|
-
numberOfMessagesInRun,
|
|
53
|
-
agentId,
|
|
54
|
-
stateSnapshot
|
|
55
|
-
},
|
|
56
|
-
`${runId}-${message.id}-${position}`
|
|
57
|
-
);
|
|
58
|
-
if (result) {
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return result;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export {
|
|
67
|
-
useRenderCustomMessages
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=chunk-CSHBUHRW.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-render-custom-messages.tsx"],"sourcesContent":["import { useCopilotChatConfiguration, useCopilotKit } from \"@/providers\";\nimport { ReactCustomMessageRendererPosition } from \"@/types/react-custom-message-renderer\";\nimport { Message } from \"@ag-ui/core\";\n\ninterface UseRenderCustomMessagesParams {\n message: Message;\n position: ReactCustomMessageRendererPosition;\n}\n\nexport function useRenderCustomMessages() {\n const { copilotkit } = useCopilotKit();\n const config = useCopilotChatConfiguration();\n\n if (!config) {\n return null;\n }\n\n const { agentId, threadId } = config;\n\n const customMessageRenderers = copilotkit.renderCustomMessages\n .filter((renderer) => renderer.agentId === undefined || renderer.agentId === agentId)\n .sort((a, b) => {\n const aHasAgent = a.agentId !== undefined;\n const bHasAgent = b.agentId !== undefined;\n if (aHasAgent === bHasAgent) return 0;\n return aHasAgent ? -1 : 1;\n });\n\n return function (params: UseRenderCustomMessagesParams) {\n if (!customMessageRenderers.length) {\n return null;\n }\n const { message, position } = params;\n const runId = copilotkit.getRunIdForMessage(agentId, threadId, message.id)!;\n const agent = copilotkit.getAgent(agentId);\n if (!agent) {\n throw new Error(\"Agent not found\");\n }\n\n const messagesIdsInRun = agent.messages\n .filter((msg) => copilotkit.getRunIdForMessage(agentId, threadId, msg.id) === runId)\n .map((msg) => msg.id);\n\n const messageIndex = agent.messages.findIndex((msg) => msg.id === message.id) ?? 0;\n const messageIndexInRun = Math.min(messagesIdsInRun.indexOf(message.id), 0);\n const numberOfMessagesInRun = messagesIdsInRun.length;\n const stateSnapshot = copilotkit.getStateByRun(agentId, threadId, runId);\n\n let result = null;\n for (const renderer of customMessageRenderers) {\n if (!renderer.render) {\n continue;\n }\n const Component = renderer.render;\n result = (\n <Component\n key={`${runId}-${message.id}-${position}`}\n message={message}\n position={position}\n runId={runId}\n messageIndex={messageIndex}\n messageIndexInRun={messageIndexInRun}\n numberOfMessagesInRun={numberOfMessagesInRun}\n agentId={agentId}\n stateSnapshot={stateSnapshot}\n />\n );\n if (result) {\n break;\n }\n }\n return result;\n };\n}\n"],"mappings":";;;;;;;;AAuDQ;AA9CD,SAAS,0BAA0B;AACxC,QAAM,EAAE,WAAW,IAAI,cAAc;AACrC,QAAM,SAAS,4BAA4B;AAE3C,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AAEA,QAAM,EAAE,SAAS,SAAS,IAAI;AAE9B,QAAM,yBAAyB,WAAW,qBACvC,OAAO,CAAC,aAAa,SAAS,YAAY,UAAa,SAAS,YAAY,OAAO,EACnF,KAAK,CAAC,GAAG,MAAM;AACd,UAAM,YAAY,EAAE,YAAY;AAChC,UAAM,YAAY,EAAE,YAAY;AAChC,QAAI,cAAc,UAAW,QAAO;AACpC,WAAO,YAAY,KAAK;AAAA,EAC1B,CAAC;AAEH,SAAO,SAAU,QAAuC;AACtD,QAAI,CAAC,uBAAuB,QAAQ;AAClC,aAAO;AAAA,IACT;AACA,UAAM,EAAE,SAAS,SAAS,IAAI;AAC9B,UAAM,QAAQ,WAAW,mBAAmB,SAAS,UAAU,QAAQ,EAAE;AACzE,UAAM,QAAQ,WAAW,SAAS,OAAO;AACzC,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,iBAAiB;AAAA,IACnC;AAEA,UAAM,mBAAmB,MAAM,SAC5B,OAAO,CAAC,QAAQ,WAAW,mBAAmB,SAAS,UAAU,IAAI,EAAE,MAAM,KAAK,EAClF,IAAI,CAAC,QAAQ,IAAI,EAAE;AAEtB,UAAM,eAAe,MAAM,SAAS,UAAU,CAAC,QAAQ,IAAI,OAAO,QAAQ,EAAE,KAAK;AACjF,UAAM,oBAAoB,KAAK,IAAI,iBAAiB,QAAQ,QAAQ,EAAE,GAAG,CAAC;AAC1E,UAAM,wBAAwB,iBAAiB;AAC/C,UAAM,gBAAgB,WAAW,cAAc,SAAS,UAAU,KAAK;AAEvE,QAAI,SAAS;AACb,eAAW,YAAY,wBAAwB;AAC7C,UAAI,CAAC,SAAS,QAAQ;AACpB;AAAA,MACF;AACA,YAAM,YAAY,SAAS;AAC3B,eACE;AAAA,QAAC;AAAA;AAAA,UAEC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,QARK,GAAG,KAAK,IAAI,QAAQ,EAAE,IAAI,QAAQ;AAAA,MASzC;AAEF,UAAI,QAAQ;AACV;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
|