@copilotkit/react-core 0.0.0-fix-runtime-reorder-and-validate-tool-20250812201140 → 0.0.0-fix-old-browser-support-code-block-20250923113406
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 +138 -3
- package/dist/{chunk-MUDXTKXE.mjs → chunk-2MGJO3FY.mjs} +4 -4
- package/dist/{chunk-MUDXTKXE.mjs.map → chunk-2MGJO3FY.mjs.map} +1 -1
- package/dist/{chunk-GEKWHETN.mjs → chunk-2QZSAQTX.mjs} +2 -2
- package/dist/{chunk-6EKLRL7B.mjs → chunk-36FJAVOF.mjs} +2 -2
- package/dist/{chunk-HD2TFFAT.mjs → chunk-5PIHZC7Z.mjs} +5 -5
- package/dist/{chunk-ACHZJNZF.mjs → chunk-6H3ADFAX.mjs} +3 -3
- package/dist/{chunk-CLMDRYEN.mjs → chunk-CXDK6XA5.mjs} +2 -2
- package/dist/{chunk-A2ORBLCP.mjs → chunk-DSDAZA3B.mjs} +2 -2
- package/dist/{chunk-QE7Z6LQR.mjs → chunk-FRXYSJGZ.mjs} +66 -5
- package/dist/chunk-FRXYSJGZ.mjs.map +1 -0
- package/dist/{chunk-OPRDTF4S.mjs → chunk-JEMBA7PE.mjs} +2 -2
- package/dist/{chunk-K4HXT453.mjs → chunk-KWS75AOU.mjs} +3 -3
- package/dist/{chunk-ZJYEXP6T.mjs → chunk-LINGATDU.mjs} +2 -2
- package/dist/{chunk-3RHHNUVV.mjs → chunk-MZ37BAAE.mjs} +2 -2
- package/dist/{chunk-ME7RQK67.mjs → chunk-NDD2NTFT.mjs} +8 -7
- package/dist/chunk-NDD2NTFT.mjs.map +1 -0
- package/dist/{chunk-HD3F6XVZ.mjs → chunk-NKT6I2FI.mjs} +26 -13
- package/dist/chunk-NKT6I2FI.mjs.map +1 -0
- package/dist/{chunk-KDE2GWEU.mjs → chunk-PQCI7AJL.mjs} +3 -3
- package/dist/{chunk-FAUNHSQU.mjs → chunk-Q3MCVRO3.mjs} +1 -3
- package/dist/chunk-Q3MCVRO3.mjs.map +1 -0
- package/dist/{chunk-IN7GE4NO.mjs → chunk-QF3Q5LUN.mjs} +2 -2
- package/dist/{chunk-AEAS6ZRO.mjs → chunk-UPQPBCUW.mjs} +2 -2
- package/dist/{chunk-TEMLWRRT.mjs → chunk-YHT6CWIY.mjs} +8 -2
- package/dist/{chunk-TEMLWRRT.mjs.map → chunk-YHT6CWIY.mjs.map} +1 -1
- package/dist/{chunk-WNMN2UNU.mjs → chunk-ZRDV3MVW.mjs} +49 -8
- package/dist/chunk-ZRDV3MVW.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.js +9 -3
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
- package/dist/components/copilot-provider/copilot-messages.mjs +2 -2
- package/dist/components/copilot-provider/copilotkit-props.d.ts +2 -2
- package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.d.ts +1 -1
- package/dist/components/copilot-provider/copilotkit.js +116 -10
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +6 -6
- package/dist/components/copilot-provider/index.d.ts +1 -1
- package/dist/components/copilot-provider/index.js +116 -10
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +6 -6
- package/dist/components/dev-console/console-trigger.js +70 -3
- package/dist/components/dev-console/console-trigger.js.map +1 -1
- package/dist/components/dev-console/console-trigger.mjs +3 -3
- package/dist/components/dev-console/developer-console-modal.js +7 -1
- package/dist/components/dev-console/developer-console-modal.js.map +1 -1
- package/dist/components/dev-console/developer-console-modal.mjs +2 -2
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +116 -10
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +6 -6
- package/dist/context/copilot-context.d.ts +1 -1
- package/dist/context/copilot-context.js +7 -1
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/copilot-messages-context.d.ts +2 -2
- package/dist/context/index.d.ts +2 -2
- package/dist/context/index.js +7 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/{copilot-context-256f9020.d.ts → copilot-context-59740e82.d.ts} +4 -1
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +32 -14
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +19 -19
- package/dist/hooks/use-chat.d.ts +1 -1
- package/dist/hooks/use-chat.js +29 -12
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +3 -3
- package/dist/hooks/use-coagent-state-render.js +7 -1
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +2 -2
- package/dist/hooks/use-coagent.d.ts +1 -1
- package/dist/hooks/use-coagent.js +32 -14
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +10 -10
- package/dist/hooks/use-copilot-action.js +7 -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-additional-instructions.js +7 -1
- package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
- package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
- package/dist/hooks/use-copilot-authenticated-action.js +7 -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-copilot-chat-headless_c.d.ts +2 -2
- package/dist/hooks/use-copilot-chat-headless_c.js +29 -12
- package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
- package/dist/hooks/use-copilot-chat-headless_c.mjs +10 -10
- package/dist/hooks/use-copilot-chat.d.ts +2 -2
- package/dist/hooks/use-copilot-chat.js +29 -12
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +10 -10
- package/dist/hooks/use-copilot-chat_internal.d.ts +2 -2
- package/dist/hooks/use-copilot-chat_internal.js +29 -12
- package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
- package/dist/hooks/use-copilot-chat_internal.mjs +9 -9
- package/dist/hooks/use-copilot-readable.js +7 -1
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +2 -2
- package/dist/hooks/use-copilot-runtime-client.d.ts +1 -1
- package/dist/hooks/use-copilot-runtime-client.js +0 -2
- package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
- package/dist/hooks/use-copilot-runtime-client.mjs +1 -1
- package/dist/hooks/use-langgraph-interrupt-render.js +7 -1
- package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt-render.mjs +2 -2
- package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
- package/dist/hooks/use-langgraph-interrupt.js +29 -12
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +10 -10
- package/dist/hooks/use-make-copilot-document-readable.js +7 -1
- package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
- package/dist/{index-08c43df1.d.ts → index-d1743abe.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +141 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -20
- package/dist/lib/copilot-task.d.ts +1 -1
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +7 -7
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +7 -7
- package/dist/types/interrupt-action.d.ts +1 -1
- package/dist/utils/extract.d.ts +2 -2
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +6 -6
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +6 -6
- package/dist/utils/suggestions.d.ts +2 -2
- package/dist/utils/suggestions.js.map +1 -1
- package/dist/utils/suggestions.mjs +6 -6
- package/package.json +5 -5
- package/src/components/copilot-provider/copilot-messages.tsx +1 -1
- package/src/components/copilot-provider/copilotkit-props.tsx +1 -1
- package/src/components/copilot-provider/copilotkit.tsx +55 -2
- package/src/components/dev-console/console-trigger.tsx +66 -2
- package/src/context/copilot-context.tsx +11 -2
- package/src/hooks/use-chat.ts +25 -9
- package/src/hooks/use-coagent.ts +2 -1
- package/src/hooks/use-copilot-runtime-client.ts +4 -4
- package/dist/chunk-FAUNHSQU.mjs.map +0 -1
- package/dist/chunk-HD3F6XVZ.mjs.map +0 -1
- package/dist/chunk-ME7RQK67.mjs.map +0 -1
- package/dist/chunk-QE7Z6LQR.mjs.map +0 -1
- package/dist/chunk-WNMN2UNU.mjs.map +0 -1
- /package/dist/{chunk-GEKWHETN.mjs.map → chunk-2QZSAQTX.mjs.map} +0 -0
- /package/dist/{chunk-6EKLRL7B.mjs.map → chunk-36FJAVOF.mjs.map} +0 -0
- /package/dist/{chunk-HD2TFFAT.mjs.map → chunk-5PIHZC7Z.mjs.map} +0 -0
- /package/dist/{chunk-ACHZJNZF.mjs.map → chunk-6H3ADFAX.mjs.map} +0 -0
- /package/dist/{chunk-CLMDRYEN.mjs.map → chunk-CXDK6XA5.mjs.map} +0 -0
- /package/dist/{chunk-A2ORBLCP.mjs.map → chunk-DSDAZA3B.mjs.map} +0 -0
- /package/dist/{chunk-OPRDTF4S.mjs.map → chunk-JEMBA7PE.mjs.map} +0 -0
- /package/dist/{chunk-K4HXT453.mjs.map → chunk-KWS75AOU.mjs.map} +0 -0
- /package/dist/{chunk-ZJYEXP6T.mjs.map → chunk-LINGATDU.mjs.map} +0 -0
- /package/dist/{chunk-3RHHNUVV.mjs.map → chunk-MZ37BAAE.mjs.map} +0 -0
- /package/dist/{chunk-KDE2GWEU.mjs.map → chunk-PQCI7AJL.mjs.map} +0 -0
- /package/dist/{chunk-IN7GE4NO.mjs.map → chunk-QF3Q5LUN.mjs.map} +0 -0
- /package/dist/{chunk-AEAS6ZRO.mjs.map → chunk-UPQPBCUW.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,148 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
-
## 0.0.0-fix-
|
|
3
|
+
## 0.0.0-fix-old-browser-support-code-block-20250923113406
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b7bc3a0: - feat: pass copilot readable context to agui agents
|
|
8
|
+
- 32c163e: - inspector visibility toggle in ConsoleTrigger component
|
|
9
|
+
- 6112a67: - fix: consider edge cases when regenerate button is used
|
|
10
|
+
- @copilotkit/runtime-client-gql@0.0.0-fix-old-browser-support-code-block-20250923113406
|
|
11
|
+
- @copilotkit/shared@0.0.0-fix-old-browser-support-code-block-20250923113406
|
|
12
|
+
|
|
13
|
+
## 1.10.5-next.5
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 6112a67: - fix: consider edge cases when regenerate button is used
|
|
18
|
+
- @copilotkit/runtime-client-gql@1.10.5-next.5
|
|
19
|
+
- @copilotkit/shared@1.10.5-next.5
|
|
20
|
+
|
|
21
|
+
## 1.10.5-next.4
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- @copilotkit/runtime-client-gql@1.10.5-next.4
|
|
26
|
+
- @copilotkit/shared@1.10.5-next.4
|
|
27
|
+
|
|
28
|
+
## 1.10.5-next.3
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- @copilotkit/runtime-client-gql@1.10.5-next.3
|
|
33
|
+
- @copilotkit/shared@1.10.5-next.3
|
|
34
|
+
|
|
35
|
+
## 1.10.5-next.2
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- @copilotkit/runtime-client-gql@1.10.5-next.2
|
|
40
|
+
- @copilotkit/shared@1.10.5-next.2
|
|
41
|
+
|
|
42
|
+
## 1.10.5-next.1
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- b7bc3a0: - feat: pass copilot readable context to agui agents
|
|
47
|
+
- @copilotkit/runtime-client-gql@1.10.5-next.1
|
|
48
|
+
- @copilotkit/shared@1.10.5-next.1
|
|
49
|
+
|
|
50
|
+
## 1.10.5-next.0
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- 32c163e: - inspector visibility toggle in ConsoleTrigger component
|
|
55
|
+
- @copilotkit/runtime-client-gql@1.10.5-next.0
|
|
56
|
+
- @copilotkit/shared@1.10.5-next.0
|
|
57
|
+
|
|
58
|
+
## 1.10.4
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- ef98963: - feat: add platform-wide error surfacing for custom error rendering
|
|
63
|
+
- feat: add error as a message option and a component level onError
|
|
64
|
+
- 052d54d: - fix: enable erasing chat state on new thread creation
|
|
65
|
+
- Updated dependencies [a640d8e]
|
|
66
|
+
- @copilotkit/shared@1.10.4
|
|
67
|
+
- @copilotkit/runtime-client-gql@1.10.4
|
|
68
|
+
|
|
69
|
+
## 1.10.4-next.3
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- @copilotkit/runtime-client-gql@1.10.4-next.3
|
|
74
|
+
- @copilotkit/shared@1.10.4-next.3
|
|
75
|
+
|
|
76
|
+
## 1.10.4-next.2
|
|
77
|
+
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- ef98963: - feat: add platform-wide error surfacing for custom error rendering
|
|
81
|
+
- feat: add error as a message option and a component level onError
|
|
82
|
+
- @copilotkit/runtime-client-gql@1.10.4-next.2
|
|
83
|
+
- @copilotkit/shared@1.10.4-next.2
|
|
84
|
+
|
|
85
|
+
## 1.10.4-next.1
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- Updated dependencies [a640d8e]
|
|
90
|
+
- @copilotkit/shared@1.10.4-next.1
|
|
91
|
+
- @copilotkit/runtime-client-gql@1.10.4-next.1
|
|
92
|
+
|
|
93
|
+
## 1.10.4-next.0
|
|
94
|
+
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- 052d54d: - fix: enable erasing chat state on new thread creation
|
|
98
|
+
- @copilotkit/runtime-client-gql@1.10.4-next.0
|
|
99
|
+
- @copilotkit/shared@1.10.4-next.0
|
|
100
|
+
|
|
101
|
+
## 1.10.3
|
|
102
|
+
|
|
103
|
+
### Patch Changes
|
|
104
|
+
|
|
105
|
+
- Updated dependencies [ea74047]
|
|
106
|
+
- @copilotkit/shared@1.10.3
|
|
107
|
+
- @copilotkit/runtime-client-gql@1.10.3
|
|
108
|
+
|
|
109
|
+
## 1.10.3-next.3
|
|
110
|
+
|
|
111
|
+
### Patch Changes
|
|
112
|
+
|
|
113
|
+
- @copilotkit/runtime-client-gql@1.10.3-next.3
|
|
114
|
+
- @copilotkit/shared@1.10.3-next.3
|
|
115
|
+
|
|
116
|
+
## 1.10.3-next.2
|
|
117
|
+
|
|
118
|
+
### Patch Changes
|
|
119
|
+
|
|
120
|
+
- @copilotkit/runtime-client-gql@1.10.3-next.2
|
|
121
|
+
- @copilotkit/shared@1.10.3-next.2
|
|
122
|
+
|
|
123
|
+
## 1.10.3-next.1
|
|
124
|
+
|
|
125
|
+
### Patch Changes
|
|
126
|
+
|
|
127
|
+
- @copilotkit/runtime-client-gql@1.10.3-next.1
|
|
128
|
+
- @copilotkit/shared@1.10.3-next.1
|
|
129
|
+
|
|
130
|
+
## 1.10.3-next.0
|
|
131
|
+
|
|
132
|
+
### Patch Changes
|
|
133
|
+
|
|
134
|
+
- Updated dependencies [ea74047]
|
|
135
|
+
- @copilotkit/shared@1.10.3-next.0
|
|
136
|
+
- @copilotkit/runtime-client-gql@1.10.3-next.0
|
|
137
|
+
|
|
138
|
+
## 1.10.2
|
|
4
139
|
|
|
5
140
|
### Patch Changes
|
|
6
141
|
|
|
7
142
|
- db5bbda: - fix: allow disabling of default cpk system message
|
|
8
143
|
- chore: set up direct fastapi usage on coagents starter poetry demo
|
|
9
|
-
- @copilotkit/runtime-client-gql@
|
|
10
|
-
- @copilotkit/shared@
|
|
144
|
+
- @copilotkit/runtime-client-gql@1.10.2
|
|
145
|
+
- @copilotkit/shared@1.10.2
|
|
11
146
|
|
|
12
147
|
## 1.10.2-next.0
|
|
13
148
|
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-EFL5OBKN.mjs";
|
|
7
7
|
import {
|
|
8
8
|
useCopilotContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YHT6CWIY.mjs";
|
|
10
10
|
import {
|
|
11
11
|
CopilotMessagesContext
|
|
12
12
|
} from "./chunk-ZLQVRPDS.mjs";
|
|
@@ -169,7 +169,7 @@ function CopilotMessages({ children }) {
|
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
171
|
const fetchMessages = () => __async(this, null, function* () {
|
|
172
|
-
var _a, _b, _c
|
|
172
|
+
var _a, _b, _c;
|
|
173
173
|
if (!(agentSession == null ? void 0 : agentSession.agentName))
|
|
174
174
|
return;
|
|
175
175
|
const result = yield runtimeClient.loadAgentState({
|
|
@@ -185,7 +185,7 @@ function CopilotMessages({ children }) {
|
|
|
185
185
|
const newMessages = (_b = (_a = result.data) == null ? void 0 : _a.loadAgentState) == null ? void 0 : _b.messages;
|
|
186
186
|
if (newMessages === lastLoadedMessages.current)
|
|
187
187
|
return;
|
|
188
|
-
if ((
|
|
188
|
+
if ((_c = result.data) == null ? void 0 : _c.loadAgentState) {
|
|
189
189
|
lastLoadedMessages.current = newMessages;
|
|
190
190
|
lastLoadedThreadId.current = threadId;
|
|
191
191
|
lastLoadedAgentName.current = agentSession == null ? void 0 : agentSession.agentName;
|
|
@@ -219,4 +219,4 @@ export {
|
|
|
219
219
|
MessagesTapProvider,
|
|
220
220
|
CopilotMessages
|
|
221
221
|
};
|
|
222
|
-
//# sourceMappingURL=chunk-
|
|
222
|
+
//# sourceMappingURL=chunk-2MGJO3FY.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/copilot-provider/copilot-messages.tsx"],"sourcesContent":["/**\n * An internal context to separate the messages state (which is constantly changing) from the rest of CopilotKit context\n */\n\nimport {\n ReactNode,\n useEffect,\n useState,\n useRef,\n useCallback,\n useMemo,\n createContext,\n useContext,\n} from \"react\";\nimport { CopilotMessagesContext } from \"../../context/copilot-messages-context\";\nimport {\n loadMessagesFromJsonRepresentation,\n Message,\n GraphQLError,\n} from \"@copilotkit/runtime-client-gql\";\nimport { useCopilotContext } from \"../../context/copilot-context\";\nimport { useToast } from \"../toast/toast-provider\";\nimport { shouldShowDevConsole } from \"../../utils/dev-console\";\nimport {\n ErrorVisibility,\n CopilotKitApiDiscoveryError,\n CopilotKitRemoteEndpointDiscoveryError,\n CopilotKitAgentDiscoveryError,\n CopilotKitError,\n CopilotKitErrorCode,\n} from \"@copilotkit/shared\";\nimport { SuggestionItem } from \"../../utils/suggestions\";\n\n// Helper to determine if error should show as banner based on visibility and legacy patterns\nfunction shouldShowAsBanner(gqlError: GraphQLError): boolean {\n const extensions = gqlError.extensions;\n if (!extensions) return false;\n\n // Priority 1: Check error code for discovery errors (these should always be banners)\n const code = extensions.code as CopilotKitErrorCode;\n if (\n code === CopilotKitErrorCode.AGENT_NOT_FOUND ||\n code === CopilotKitErrorCode.API_NOT_FOUND ||\n code === CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND ||\n code === CopilotKitErrorCode.CONFIGURATION_ERROR ||\n code === CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR ||\n code === CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR\n ) {\n return true;\n }\n\n // Priority 2: Check banner visibility\n if (extensions.visibility === ErrorVisibility.BANNER) {\n return true;\n }\n\n // Priority 3: Check for critical errors that should be banners regardless of formal classification\n const errorMessage = gqlError.message.toLowerCase();\n if (\n errorMessage.includes(\"api key\") ||\n errorMessage.includes(\"401\") ||\n errorMessage.includes(\"unauthorized\") ||\n errorMessage.includes(\"authentication\") ||\n errorMessage.includes(\"incorrect api key\")\n ) {\n return true;\n }\n\n // Priority 4: Legacy stack trace detection for discovery errors\n const originalError = extensions.originalError as any;\n if (originalError?.stack) {\n return (\n originalError.stack.includes(\"CopilotApiDiscoveryError\") ||\n originalError.stack.includes(\"CopilotKitRemoteEndpointDiscoveryError\") ||\n originalError.stack.includes(\"CopilotKitAgentDiscoveryError\")\n );\n }\n\n return false;\n}\n\n/**\n * MessagesTap is used to mitigate performance issues when we only need\n * a snapshot of the messages, not a continuously updating stream of messages.\n */\n\nexport type MessagesTap = {\n getMessagesFromTap: () => Message[];\n updateTapMessages: (messages: Message[]) => void;\n};\n\nconst MessagesTapContext = createContext<MessagesTap | null>(null);\n\nexport function useMessagesTap() {\n const tap = useContext(MessagesTapContext);\n if (!tap) throw new Error(\"useMessagesTap must be used inside <MessagesTapProvider>\");\n return tap;\n}\n\nexport function MessagesTapProvider({ children }: { children: React.ReactNode }) {\n const messagesRef = useRef<Message[]>([]);\n\n const tapRef = useRef<MessagesTap>({\n getMessagesFromTap: () => messagesRef.current,\n updateTapMessages: (messages: Message[]) => {\n messagesRef.current = messages;\n },\n });\n\n return (\n <MessagesTapContext.Provider value={tapRef.current}>{children}</MessagesTapContext.Provider>\n );\n}\n\n/**\n * CopilotKit messages context.\n */\n\nexport function CopilotMessages({ children }: { children: ReactNode }) {\n const [messages, setMessages] = useState<Message[]>([]);\n const lastLoadedThreadId = useRef<string>();\n const lastLoadedAgentName = useRef<string>();\n const lastLoadedMessages = useRef<string>();\n\n const { updateTapMessages } = useMessagesTap();\n\n const { threadId, agentSession, runtimeClient, showDevConsole, onError, copilotApiConfig } =\n useCopilotContext();\n const { setBannerError } = useToast();\n\n // Helper function to trace UI errors (similar to useCopilotRuntimeClient)\n const traceUIError = useCallback(\n async (error: CopilotKitError, originalError?: any) => {\n // Just check if onError and publicApiKey are defined\n if (!onError || !copilotApiConfig.publicApiKey) return;\n\n try {\n const traceEvent = {\n type: \"error\" as const,\n timestamp: Date.now(),\n context: {\n source: \"ui\" as const,\n request: {\n operation: \"loadAgentState\",\n url: copilotApiConfig.chatApiEndpoint,\n startTime: Date.now(),\n },\n technical: {\n environment: \"browser\",\n userAgent: typeof navigator !== \"undefined\" ? navigator.userAgent : undefined,\n stackTrace: originalError instanceof Error ? originalError.stack : undefined,\n },\n },\n error,\n };\n await onError(traceEvent);\n } catch (traceError) {\n console.error(\"Error in CopilotMessages onError handler:\", traceError);\n }\n },\n [onError, copilotApiConfig.publicApiKey, copilotApiConfig.chatApiEndpoint],\n );\n\n const createStructuredError = (gqlError: GraphQLError): CopilotKitError | null => {\n const extensions = gqlError.extensions;\n const originalError = extensions?.originalError as any;\n\n // Priority: Check stack trace for discovery errors first\n if (originalError?.stack) {\n if (originalError.stack.includes(\"CopilotApiDiscoveryError\")) {\n return new CopilotKitApiDiscoveryError({ message: originalError.message });\n }\n if (originalError.stack.includes(\"CopilotKitRemoteEndpointDiscoveryError\")) {\n return new CopilotKitRemoteEndpointDiscoveryError({ message: originalError.message });\n }\n if (originalError.stack.includes(\"CopilotKitAgentDiscoveryError\")) {\n return new CopilotKitAgentDiscoveryError({\n agentName: \"\",\n availableAgents: [],\n });\n }\n }\n\n // Fallback: Use the formal error code if available\n const message = originalError?.message || gqlError.message;\n const code = extensions?.code as CopilotKitErrorCode;\n\n if (code) {\n return new CopilotKitError({ message, code });\n }\n\n return null;\n };\n\n const handleGraphQLErrors = useCallback(\n (error: any) => {\n if (error.graphQLErrors?.length) {\n const graphQLErrors = error.graphQLErrors as GraphQLError[];\n\n // Route all errors to banners for consistent UI\n const routeError = (gqlError: GraphQLError) => {\n const extensions = gqlError.extensions;\n const visibility = extensions?.visibility as ErrorVisibility;\n const isDev = shouldShowDevConsole(showDevConsole);\n\n if (!isDev) {\n console.error(\"CopilotKit Error (hidden in production):\", gqlError.message);\n return;\n }\n\n // Silent errors - just log\n if (visibility === ErrorVisibility.SILENT) {\n console.error(\"CopilotKit Silent Error:\", gqlError.message);\n return;\n }\n\n // All other errors (including DEV_ONLY) show as banners for consistency\n const ckError = createStructuredError(gqlError);\n if (ckError) {\n setBannerError(ckError);\n // Trace the structured error\n traceUIError(ckError, gqlError);\n } else {\n // Fallback: create a generic error for unstructured GraphQL errors\n const fallbackError = new CopilotKitError({\n message: gqlError.message,\n code: CopilotKitErrorCode.UNKNOWN,\n });\n setBannerError(fallbackError);\n // Trace the fallback error\n traceUIError(fallbackError, gqlError);\n }\n };\n\n // Process all errors as banners\n graphQLErrors.forEach(routeError);\n } else {\n const isDev = shouldShowDevConsole(showDevConsole);\n if (!isDev) {\n console.error(\"CopilotKit Error (hidden in production):\", error);\n } else {\n // Route non-GraphQL errors to banner as well\n const fallbackError = new CopilotKitError({\n message: error?.message || String(error),\n code: CopilotKitErrorCode.UNKNOWN,\n });\n setBannerError(fallbackError);\n // Trace the non-GraphQL error\n traceUIError(fallbackError, error);\n }\n }\n },\n [setBannerError, showDevConsole, traceUIError],\n );\n\n useEffect(() => {\n if (!threadId || threadId === lastLoadedThreadId.current) return;\n if (\n threadId === lastLoadedThreadId.current &&\n agentSession?.agentName === lastLoadedAgentName.current\n ) {\n return;\n }\n\n const fetchMessages = async () => {\n if (!agentSession?.agentName) return;\n\n const result = await runtimeClient.loadAgentState({\n threadId,\n agentName: agentSession?.agentName,\n });\n\n // Check for GraphQL errors and manually trigger error handling\n if (result.error) {\n // Update refs to prevent infinite retries of the same failed request\n lastLoadedThreadId.current = threadId;\n lastLoadedAgentName.current = agentSession?.agentName;\n handleGraphQLErrors(result.error);\n return; // Don't try to process the data if there's an error\n }\n\n const newMessages = result.data?.loadAgentState?.messages;\n if (newMessages === lastLoadedMessages.current) return;\n\n if (result.data?.loadAgentState?.threadExists) {\n lastLoadedMessages.current = newMessages;\n lastLoadedThreadId.current = threadId;\n lastLoadedAgentName.current = agentSession?.agentName;\n\n const messages = loadMessagesFromJsonRepresentation(JSON.parse(newMessages || \"[]\"));\n setMessages(messages);\n }\n };\n void fetchMessages();\n }, [threadId, agentSession?.agentName]);\n\n useEffect(() => {\n updateTapMessages(messages);\n }, [messages, updateTapMessages]);\n\n const memoizedChildren = useMemo(() => children, [children]);\n const [suggestions, setSuggestions] = useState<SuggestionItem[]>([]);\n\n return (\n <CopilotMessagesContext.Provider\n value={{\n messages,\n setMessages,\n suggestions,\n setSuggestions,\n }}\n >\n {memoizedChildren}\n </CopilotMessagesContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,OAGK;AAIP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgFH;AAnBJ,IAAM,qBAAqB,cAAkC,IAAI;AAE1D,SAAS,iBAAiB;AAC/B,QAAM,MAAM,WAAW,kBAAkB;AACzC,MAAI,CAAC;AAAK,UAAM,IAAI,MAAM,0DAA0D;AACpF,SAAO;AACT;AAEO,SAAS,oBAAoB,EAAE,SAAS,GAAkC;AAC/E,QAAM,cAAc,OAAkB,CAAC,CAAC;AAExC,QAAM,SAAS,OAAoB;AAAA,IACjC,oBAAoB,MAAM,YAAY;AAAA,IACtC,mBAAmB,CAAC,aAAwB;AAC1C,kBAAY,UAAU;AAAA,IACxB;AAAA,EACF,CAAC;AAED,SACE,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,OAAO,SAAU,UAAS;AAElE;AAMO,SAAS,gBAAgB,EAAE,SAAS,GAA4B;AACrE,QAAM,CAAC,UAAU,WAAW,IAAI,SAAoB,CAAC,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;AAAA,IAAC,uBAAuB;AAAA,IAAvB;AAAA,MACC,OAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":["messages"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/copilot-provider/copilot-messages.tsx"],"sourcesContent":["/**\n * An internal context to separate the messages state (which is constantly changing) from the rest of CopilotKit context\n */\n\nimport {\n ReactNode,\n useEffect,\n useState,\n useRef,\n useCallback,\n useMemo,\n createContext,\n useContext,\n} from \"react\";\nimport { CopilotMessagesContext } from \"../../context/copilot-messages-context\";\nimport {\n loadMessagesFromJsonRepresentation,\n Message,\n GraphQLError,\n} from \"@copilotkit/runtime-client-gql\";\nimport { useCopilotContext } from \"../../context/copilot-context\";\nimport { useToast } from \"../toast/toast-provider\";\nimport { shouldShowDevConsole } from \"../../utils/dev-console\";\nimport {\n ErrorVisibility,\n CopilotKitApiDiscoveryError,\n CopilotKitRemoteEndpointDiscoveryError,\n CopilotKitAgentDiscoveryError,\n CopilotKitError,\n CopilotKitErrorCode,\n} from \"@copilotkit/shared\";\nimport { SuggestionItem } from \"../../utils/suggestions\";\n\n// Helper to determine if error should show as banner based on visibility and legacy patterns\nfunction shouldShowAsBanner(gqlError: GraphQLError): boolean {\n const extensions = gqlError.extensions;\n if (!extensions) return false;\n\n // Priority 1: Check error code for discovery errors (these should always be banners)\n const code = extensions.code as CopilotKitErrorCode;\n if (\n code === CopilotKitErrorCode.AGENT_NOT_FOUND ||\n code === CopilotKitErrorCode.API_NOT_FOUND ||\n code === CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND ||\n code === CopilotKitErrorCode.CONFIGURATION_ERROR ||\n code === CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR ||\n code === CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR\n ) {\n return true;\n }\n\n // Priority 2: Check banner visibility\n if (extensions.visibility === ErrorVisibility.BANNER) {\n return true;\n }\n\n // Priority 3: Check for critical errors that should be banners regardless of formal classification\n const errorMessage = gqlError.message.toLowerCase();\n if (\n errorMessage.includes(\"api key\") ||\n errorMessage.includes(\"401\") ||\n errorMessage.includes(\"unauthorized\") ||\n errorMessage.includes(\"authentication\") ||\n errorMessage.includes(\"incorrect api key\")\n ) {\n return true;\n }\n\n // Priority 4: Legacy stack trace detection for discovery errors\n const originalError = extensions.originalError as any;\n if (originalError?.stack) {\n return (\n originalError.stack.includes(\"CopilotApiDiscoveryError\") ||\n originalError.stack.includes(\"CopilotKitRemoteEndpointDiscoveryError\") ||\n originalError.stack.includes(\"CopilotKitAgentDiscoveryError\")\n );\n }\n\n return false;\n}\n\n/**\n * MessagesTap is used to mitigate performance issues when we only need\n * a snapshot of the messages, not a continuously updating stream of messages.\n */\n\nexport type MessagesTap = {\n getMessagesFromTap: () => Message[];\n updateTapMessages: (messages: Message[]) => void;\n};\n\nconst MessagesTapContext = createContext<MessagesTap | null>(null);\n\nexport function useMessagesTap() {\n const tap = useContext(MessagesTapContext);\n if (!tap) throw new Error(\"useMessagesTap must be used inside <MessagesTapProvider>\");\n return tap;\n}\n\nexport function MessagesTapProvider({ children }: { children: React.ReactNode }) {\n const messagesRef = useRef<Message[]>([]);\n\n const tapRef = useRef<MessagesTap>({\n getMessagesFromTap: () => messagesRef.current,\n updateTapMessages: (messages: Message[]) => {\n messagesRef.current = messages;\n },\n });\n\n return (\n <MessagesTapContext.Provider value={tapRef.current}>{children}</MessagesTapContext.Provider>\n );\n}\n\n/**\n * CopilotKit messages context.\n */\n\nexport function CopilotMessages({ children }: { children: ReactNode }) {\n const [messages, setMessages] = useState<Message[]>([]);\n const lastLoadedThreadId = useRef<string>();\n const lastLoadedAgentName = useRef<string>();\n const lastLoadedMessages = useRef<string>();\n\n const { updateTapMessages } = useMessagesTap();\n\n const { threadId, agentSession, runtimeClient, showDevConsole, onError, copilotApiConfig } =\n useCopilotContext();\n const { setBannerError } = useToast();\n\n // Helper function to trace UI errors (similar to useCopilotRuntimeClient)\n const traceUIError = useCallback(\n async (error: CopilotKitError, originalError?: any) => {\n // Just check if onError and publicApiKey are defined\n if (!onError || !copilotApiConfig.publicApiKey) return;\n\n try {\n const traceEvent = {\n type: \"error\" as const,\n timestamp: Date.now(),\n context: {\n source: \"ui\" as const,\n request: {\n operation: \"loadAgentState\",\n url: copilotApiConfig.chatApiEndpoint,\n startTime: Date.now(),\n },\n technical: {\n environment: \"browser\",\n userAgent: typeof navigator !== \"undefined\" ? navigator.userAgent : undefined,\n stackTrace: originalError instanceof Error ? originalError.stack : undefined,\n },\n },\n error,\n };\n await onError(traceEvent);\n } catch (traceError) {\n console.error(\"Error in CopilotMessages onError handler:\", traceError);\n }\n },\n [onError, copilotApiConfig.publicApiKey, copilotApiConfig.chatApiEndpoint],\n );\n\n const createStructuredError = (gqlError: GraphQLError): CopilotKitError | null => {\n const extensions = gqlError.extensions;\n const originalError = extensions?.originalError as any;\n\n // Priority: Check stack trace for discovery errors first\n if (originalError?.stack) {\n if (originalError.stack.includes(\"CopilotApiDiscoveryError\")) {\n return new CopilotKitApiDiscoveryError({ message: originalError.message });\n }\n if (originalError.stack.includes(\"CopilotKitRemoteEndpointDiscoveryError\")) {\n return new CopilotKitRemoteEndpointDiscoveryError({ message: originalError.message });\n }\n if (originalError.stack.includes(\"CopilotKitAgentDiscoveryError\")) {\n return new CopilotKitAgentDiscoveryError({\n agentName: \"\",\n availableAgents: [],\n });\n }\n }\n\n // Fallback: Use the formal error code if available\n const message = originalError?.message || gqlError.message;\n const code = extensions?.code as CopilotKitErrorCode;\n\n if (code) {\n return new CopilotKitError({ message, code });\n }\n\n return null;\n };\n\n const handleGraphQLErrors = useCallback(\n (error: any) => {\n if (error.graphQLErrors?.length) {\n const graphQLErrors = error.graphQLErrors as GraphQLError[];\n\n // Route all errors to banners for consistent UI\n const routeError = (gqlError: GraphQLError) => {\n const extensions = gqlError.extensions;\n const visibility = extensions?.visibility as ErrorVisibility;\n const isDev = shouldShowDevConsole(showDevConsole);\n\n if (!isDev) {\n console.error(\"CopilotKit Error (hidden in production):\", gqlError.message);\n return;\n }\n\n // Silent errors - just log\n if (visibility === ErrorVisibility.SILENT) {\n console.error(\"CopilotKit Silent Error:\", gqlError.message);\n return;\n }\n\n // All other errors (including DEV_ONLY) show as banners for consistency\n const ckError = createStructuredError(gqlError);\n if (ckError) {\n setBannerError(ckError);\n // Trace the structured error\n traceUIError(ckError, gqlError);\n } else {\n // Fallback: create a generic error for unstructured GraphQL errors\n const fallbackError = new CopilotKitError({\n message: gqlError.message,\n code: CopilotKitErrorCode.UNKNOWN,\n });\n setBannerError(fallbackError);\n // Trace the fallback error\n traceUIError(fallbackError, gqlError);\n }\n };\n\n // Process all errors as banners\n graphQLErrors.forEach(routeError);\n } else {\n const isDev = shouldShowDevConsole(showDevConsole);\n if (!isDev) {\n console.error(\"CopilotKit Error (hidden in production):\", error);\n } else {\n // Route non-GraphQL errors to banner as well\n const fallbackError = new CopilotKitError({\n message: error?.message || String(error),\n code: CopilotKitErrorCode.UNKNOWN,\n });\n setBannerError(fallbackError);\n // Trace the non-GraphQL error\n traceUIError(fallbackError, error);\n }\n }\n },\n [setBannerError, showDevConsole, traceUIError],\n );\n\n useEffect(() => {\n if (!threadId || threadId === lastLoadedThreadId.current) return;\n if (\n threadId === lastLoadedThreadId.current &&\n agentSession?.agentName === lastLoadedAgentName.current\n ) {\n return;\n }\n\n const fetchMessages = async () => {\n if (!agentSession?.agentName) return;\n\n const result = await runtimeClient.loadAgentState({\n threadId,\n agentName: agentSession?.agentName,\n });\n\n // Check for GraphQL errors and manually trigger error handling\n if (result.error) {\n // Update refs to prevent infinite retries of the same failed request\n lastLoadedThreadId.current = threadId;\n lastLoadedAgentName.current = agentSession?.agentName;\n handleGraphQLErrors(result.error);\n return; // Don't try to process the data if there's an error\n }\n\n const newMessages = result.data?.loadAgentState?.messages;\n if (newMessages === lastLoadedMessages.current) return;\n\n if (result.data?.loadAgentState) {\n lastLoadedMessages.current = newMessages;\n lastLoadedThreadId.current = threadId;\n lastLoadedAgentName.current = agentSession?.agentName;\n\n const messages = loadMessagesFromJsonRepresentation(JSON.parse(newMessages || \"[]\"));\n setMessages(messages);\n }\n };\n void fetchMessages();\n }, [threadId, agentSession?.agentName]);\n\n useEffect(() => {\n updateTapMessages(messages);\n }, [messages, updateTapMessages]);\n\n const memoizedChildren = useMemo(() => children, [children]);\n const [suggestions, setSuggestions] = useState<SuggestionItem[]>([]);\n\n return (\n <CopilotMessagesContext.Provider\n value={{\n messages,\n setMessages,\n suggestions,\n setSuggestions,\n }}\n >\n {memoizedChildren}\n </CopilotMessagesContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,OAGK;AAIP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgFH;AAnBJ,IAAM,qBAAqB,cAAkC,IAAI;AAE1D,SAAS,iBAAiB;AAC/B,QAAM,MAAM,WAAW,kBAAkB;AACzC,MAAI,CAAC;AAAK,UAAM,IAAI,MAAM,0DAA0D;AACpF,SAAO;AACT;AAEO,SAAS,oBAAoB,EAAE,SAAS,GAAkC;AAC/E,QAAM,cAAc,OAAkB,CAAC,CAAC;AAExC,QAAM,SAAS,OAAoB;AAAA,IACjC,oBAAoB,MAAM,YAAY;AAAA,IACtC,mBAAmB,CAAC,aAAwB;AAC1C,kBAAY,UAAU;AAAA,IACxB;AAAA,EACF,CAAC;AAED,SACE,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,OAAO,SAAU,UAAS;AAElE;AAMO,SAAS,gBAAgB,EAAE,SAAS,GAA4B;AACrE,QAAM,CAAC,UAAU,WAAW,IAAI,SAAoB,CAAC,CAAC;AACtD,QAAM,qBAAqB,OAAe;AAC1C,QAAM,sBA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AAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":["messages"]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-EFL5OBKN.mjs";
|
|
4
4
|
import {
|
|
5
5
|
CopilotContext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YHT6CWIY.mjs";
|
|
7
7
|
|
|
8
8
|
// src/hooks/use-coagent-state-render.ts
|
|
9
9
|
import { useRef, useContext, useEffect } from "react";
|
|
@@ -85,4 +85,4 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
85
85
|
export {
|
|
86
86
|
useCoAgentStateRender
|
|
87
87
|
};
|
|
88
|
-
//# sourceMappingURL=chunk-
|
|
88
|
+
//# sourceMappingURL=chunk-2QZSAQTX.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YHT6CWIY.mjs";
|
|
4
4
|
|
|
5
5
|
// src/hooks/use-copilot-readable.ts
|
|
6
6
|
import { useEffect, useRef } from "react";
|
|
@@ -34,4 +34,4 @@ function useCopilotReadable({
|
|
|
34
34
|
export {
|
|
35
35
|
useCopilotReadable
|
|
36
36
|
};
|
|
37
|
-
//# sourceMappingURL=chunk-
|
|
37
|
+
//# sourceMappingURL=chunk-36FJAVOF.mjs.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useLangGraphInterruptRender
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QF3Q5LUN.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useChat
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NKT6I2FI.mjs";
|
|
7
7
|
import {
|
|
8
8
|
defaultCopilotContextCategories,
|
|
9
9
|
reloadSuggestions
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ZRDV3MVW.mjs";
|
|
11
11
|
import {
|
|
12
12
|
useAsyncCallback
|
|
13
13
|
} from "./chunk-N4WEHORG.mjs";
|
|
14
14
|
import {
|
|
15
15
|
useCopilotContext
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-YHT6CWIY.mjs";
|
|
17
17
|
import {
|
|
18
18
|
useCopilotMessagesContext
|
|
19
19
|
} from "./chunk-ZLQVRPDS.mjs";
|
|
@@ -329,4 +329,4 @@ export {
|
|
|
329
329
|
useCopilotChat,
|
|
330
330
|
defaultSystemMessage
|
|
331
331
|
};
|
|
332
|
-
//# sourceMappingURL=chunk-
|
|
332
|
+
//# sourceMappingURL=chunk-5PIHZC7Z.mjs.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotChat
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5PIHZC7Z.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useCopilotContext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YHT6CWIY.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__async
|
|
9
9
|
} from "./chunk-SKC7AJIV.mjs";
|
|
@@ -82,4 +82,4 @@ function useCopilotChatHeadless_c(options = {}) {
|
|
|
82
82
|
export {
|
|
83
83
|
useCopilotChatHeadless_c
|
|
84
84
|
};
|
|
85
|
-
//# sourceMappingURL=chunk-
|
|
85
|
+
//# sourceMappingURL=chunk-6H3ADFAX.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YHT6CWIY.mjs";
|
|
4
4
|
|
|
5
5
|
// src/hooks/use-make-copilot-document-readable.ts
|
|
6
6
|
import { useEffect, useRef } from "react";
|
|
@@ -20,4 +20,4 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
|
|
|
20
20
|
export {
|
|
21
21
|
useMakeCopilotDocumentReadable
|
|
22
22
|
};
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
//# sourceMappingURL=chunk-CXDK6XA5.mjs.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-PIF5KJYI.mjs";
|
|
6
6
|
import {
|
|
7
7
|
useCopilotContext
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YHT6CWIY.mjs";
|
|
9
9
|
import {
|
|
10
10
|
useCopilotMessagesContext
|
|
11
11
|
} from "./chunk-ZLQVRPDS.mjs";
|
|
@@ -756,4 +756,4 @@ function ContextTab({ context }) {
|
|
|
756
756
|
export {
|
|
757
757
|
DeveloperConsoleModal
|
|
758
758
|
};
|
|
759
|
-
//# sourceMappingURL=chunk-
|
|
759
|
+
//# sourceMappingURL=chunk-DSDAZA3B.mjs.map
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DeveloperConsoleModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DSDAZA3B.mjs";
|
|
4
4
|
import {
|
|
5
5
|
CopilotKitIcon
|
|
6
6
|
} from "./chunk-PIF5KJYI.mjs";
|
|
7
7
|
import {
|
|
8
8
|
useCopilotContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YHT6CWIY.mjs";
|
|
10
10
|
|
|
11
11
|
// src/components/dev-console/console-trigger.tsx
|
|
12
12
|
import { useState, useEffect, useRef } from "react";
|
|
13
13
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
var INSPECTOR_HIDE_KEY = "cpk:inspector:hidden";
|
|
14
15
|
function ConsoleTrigger({ position = "bottom-right" }) {
|
|
15
16
|
const context = useCopilotContext();
|
|
16
17
|
const hasApiKey = Boolean(context.copilotApiConfig.publicApiKey);
|
|
@@ -19,10 +20,18 @@ function ConsoleTrigger({ position = "bottom-right" }) {
|
|
|
19
20
|
const [isDragging, setIsDragging] = useState(false);
|
|
20
21
|
const [buttonPosition, setButtonPosition] = useState(null);
|
|
21
22
|
const [mounted, setMounted] = useState(false);
|
|
23
|
+
const [isHidden, setIsHidden] = useState(false);
|
|
22
24
|
const dragRef = useRef(null);
|
|
23
25
|
const buttonRef = useRef(null);
|
|
24
26
|
useEffect(() => {
|
|
25
27
|
setMounted(true);
|
|
28
|
+
try {
|
|
29
|
+
const hidden = typeof window !== "undefined" ? localStorage.getItem(INSPECTOR_HIDE_KEY) : null;
|
|
30
|
+
if (hidden === "1" || hidden === "true") {
|
|
31
|
+
setIsHidden(true);
|
|
32
|
+
}
|
|
33
|
+
} catch (e) {
|
|
34
|
+
}
|
|
26
35
|
if (typeof window !== "undefined" && !buttonPosition) {
|
|
27
36
|
const buttonSize = 60;
|
|
28
37
|
const margin = 24;
|
|
@@ -74,7 +83,7 @@ function ConsoleTrigger({ position = "bottom-right" }) {
|
|
|
74
83
|
document.removeEventListener("mouseup", handleMouseUp, { capture: true });
|
|
75
84
|
};
|
|
76
85
|
}, [isDragging]);
|
|
77
|
-
if (!mounted || !buttonPosition) {
|
|
86
|
+
if (!mounted || !buttonPosition || isHidden) {
|
|
78
87
|
return null;
|
|
79
88
|
}
|
|
80
89
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -82,11 +91,27 @@ function ConsoleTrigger({ position = "bottom-right" }) {
|
|
|
82
91
|
"button",
|
|
83
92
|
{
|
|
84
93
|
ref: buttonRef,
|
|
85
|
-
onClick: () => {
|
|
94
|
+
onClick: (e) => {
|
|
86
95
|
if (!isDragging) {
|
|
96
|
+
if (e.metaKey || e.altKey) {
|
|
97
|
+
try {
|
|
98
|
+
localStorage.setItem(INSPECTOR_HIDE_KEY, "1");
|
|
99
|
+
} catch (e2) {
|
|
100
|
+
}
|
|
101
|
+
setIsHidden(true);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
87
104
|
setIsModalOpen(true);
|
|
88
105
|
}
|
|
89
106
|
},
|
|
107
|
+
onContextMenu: (e) => {
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
try {
|
|
110
|
+
localStorage.setItem(INSPECTOR_HIDE_KEY, "1");
|
|
111
|
+
} catch (e2) {
|
|
112
|
+
}
|
|
113
|
+
setIsHidden(true);
|
|
114
|
+
},
|
|
90
115
|
onMouseDown: handleMouseDown,
|
|
91
116
|
onMouseEnter: () => setIsHovered(true),
|
|
92
117
|
onMouseLeave: () => setIsHovered(false),
|
|
@@ -116,6 +141,42 @@ function ConsoleTrigger({ position = "bottom-right" }) {
|
|
|
116
141
|
},
|
|
117
142
|
title: hasApiKey ? "Open Inspector (Drag to move)" : "Inspector (License Key Required, Drag to move)",
|
|
118
143
|
children: [
|
|
144
|
+
/* @__PURE__ */ jsx(
|
|
145
|
+
"div",
|
|
146
|
+
{
|
|
147
|
+
onClick: (e) => {
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
e.stopPropagation();
|
|
150
|
+
try {
|
|
151
|
+
localStorage.setItem(INSPECTOR_HIDE_KEY, "1");
|
|
152
|
+
} catch (e2) {
|
|
153
|
+
}
|
|
154
|
+
setIsHidden(true);
|
|
155
|
+
},
|
|
156
|
+
style: {
|
|
157
|
+
position: "absolute",
|
|
158
|
+
bottom: "2px",
|
|
159
|
+
right: "2px",
|
|
160
|
+
width: "20px",
|
|
161
|
+
height: "20px",
|
|
162
|
+
borderRadius: "50%",
|
|
163
|
+
background: "#ffffff",
|
|
164
|
+
color: "#ef4444",
|
|
165
|
+
fontSize: "14px",
|
|
166
|
+
lineHeight: "18px",
|
|
167
|
+
textAlign: "center",
|
|
168
|
+
boxShadow: "0 2px 6px rgba(0,0,0,0.35)",
|
|
169
|
+
cursor: "pointer",
|
|
170
|
+
border: "1px solid #e5e7eb",
|
|
171
|
+
display: "flex",
|
|
172
|
+
alignItems: "center",
|
|
173
|
+
justifyContent: "center",
|
|
174
|
+
zIndex: 1
|
|
175
|
+
},
|
|
176
|
+
title: "Hide Inspector",
|
|
177
|
+
children: "\xD7"
|
|
178
|
+
}
|
|
179
|
+
),
|
|
119
180
|
/* @__PURE__ */ jsx(
|
|
120
181
|
"div",
|
|
121
182
|
{
|
|
@@ -167,4 +228,4 @@ function ConsoleTrigger({ position = "bottom-right" }) {
|
|
|
167
228
|
export {
|
|
168
229
|
ConsoleTrigger
|
|
169
230
|
};
|
|
170
|
-
//# sourceMappingURL=chunk-
|
|
231
|
+
//# sourceMappingURL=chunk-FRXYSJGZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/dev-console/console-trigger.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useState, useEffect, useRef } from \"react\";\nimport { useCopilotContext } from \"../../context/copilot-context\";\nimport { CopilotKitIcon } from \"./icons\";\nimport { DeveloperConsoleModal } from \"./developer-console-modal\";\n\n// Storage key for hiding the Inspector trigger/modal\nconst INSPECTOR_HIDE_KEY = \"cpk:inspector:hidden\";\n\ninterface ConsoleTriggerProps {\n position?: \"bottom-left\" | \"bottom-right\";\n}\n\nexport function ConsoleTrigger({ position = \"bottom-right\" }: ConsoleTriggerProps) {\n const context = useCopilotContext();\n const hasApiKey = Boolean(context.copilotApiConfig.publicApiKey);\n const [isModalOpen, setIsModalOpen] = useState(false);\n const [isHovered, setIsHovered] = useState(false);\n const [isDragging, setIsDragging] = useState(false);\n const [buttonPosition, setButtonPosition] = useState<{ x: number; y: number } | null>(null);\n const [mounted, setMounted] = useState(false);\n const [isHidden, setIsHidden] = useState(false);\n\n const dragRef = useRef<{\n startX: number;\n startY: number;\n buttonX: number;\n buttonY: number;\n } | null>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n // Initialize on client side only\n useEffect(() => {\n setMounted(true);\n try {\n const hidden =\n typeof window !== \"undefined\" ? localStorage.getItem(INSPECTOR_HIDE_KEY) : null;\n if (hidden === \"1\" || hidden === \"true\") {\n setIsHidden(true);\n }\n } catch {\n // ignore\n }\n if (typeof window !== \"undefined\" && !buttonPosition) {\n const buttonSize = 60;\n const margin = 24;\n\n const initialPosition = {\n x: margin,\n y: window.innerHeight - buttonSize - margin,\n };\n\n setButtonPosition(initialPosition);\n }\n }, [position]);\n\n const handleMouseDown = (e: React.MouseEvent) => {\n e.preventDefault();\n if (!buttonPosition) return;\n\n dragRef.current = {\n startX: e.clientX,\n startY: e.clientY,\n buttonX: buttonPosition.x,\n buttonY: buttonPosition.y,\n };\n setIsDragging(true);\n };\n\n useEffect(() => {\n if (!isDragging) return;\n\n const handleMouseMove = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n if (!dragRef.current) return;\n\n const deltaX = e.clientX - dragRef.current.startX;\n const deltaY = e.clientY - dragRef.current.startY;\n\n // Calculate new position\n let newX = dragRef.current.buttonX + deltaX;\n let newY = dragRef.current.buttonY + deltaY;\n\n // Keep button within viewport bounds\n newX = Math.max(0, Math.min(newX, window.innerWidth - 60));\n newY = Math.max(0, Math.min(newY, window.innerHeight - 60));\n\n setButtonPosition({ x: newX, y: newY });\n };\n\n const handleMouseUp = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n setIsDragging(false);\n dragRef.current = null;\n };\n\n // Use capture phase to intercept events before they reach other handlers\n document.addEventListener(\"mousemove\", handleMouseMove, { capture: true, passive: false });\n document.addEventListener(\"mouseup\", handleMouseUp, { capture: true, passive: false });\n\n return () => {\n document.removeEventListener(\"mousemove\", handleMouseMove, { capture: true });\n document.removeEventListener(\"mouseup\", handleMouseUp, { capture: true });\n };\n }, [isDragging]);\n\n // Don't render until mounted and position is initialized\n if (!mounted || !buttonPosition || isHidden) {\n return null;\n }\n\n return (\n <>\n <button\n ref={buttonRef}\n onClick={(e) => {\n if (!isDragging) {\n // Modifier-click hides\n if (e.metaKey || e.altKey) {\n try {\n localStorage.setItem(INSPECTOR_HIDE_KEY, \"1\");\n } catch {}\n setIsHidden(true);\n return;\n }\n setIsModalOpen(true);\n }\n }}\n onContextMenu={(e) => {\n e.preventDefault();\n try {\n localStorage.setItem(INSPECTOR_HIDE_KEY, \"1\");\n } catch {}\n setIsHidden(true);\n }}\n onMouseDown={handleMouseDown}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n style={{\n position: \"fixed\",\n left: `${buttonPosition.x}px`,\n top: `${buttonPosition.y}px`,\n zIndex: 2147483647,\n width: \"60px\",\n height: \"60px\",\n background: isDragging ? \"#000000\" : isHovered ? \"#111111\" : \"#000000\",\n color: \"white\",\n borderRadius: \"50%\",\n boxShadow: isDragging\n ? \"0 8px 32px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0, 0, 0, 0.4)\"\n : isHovered\n ? \"0 12px 40px rgba(0, 0, 0, 0.7), 0 6px 20px rgba(0, 0, 0, 0.5)\"\n : \"0 6px 20px rgba(0, 0, 0, 0.5), 0 3px 10px rgba(0, 0, 0, 0.3)\",\n transition: isDragging ? \"none\" : \"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n border: \"none\",\n cursor: isDragging ? \"grabbing\" : \"grab\",\n opacity: 1,\n userSelect: \"none\",\n transform: isDragging ? \"scale(1.05)\" : isHovered ? \"scale(1.1)\" : \"scale(1)\",\n backdropFilter: \"blur(10px)\",\n pointerEvents: \"auto\",\n isolation: \"isolate\",\n }}\n title={\n hasApiKey\n ? \"Open Inspector (Drag to move)\"\n : \"Inspector (License Key Required, Drag to move)\"\n }\n >\n {/* Close (hide) control */}\n <div\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n try {\n localStorage.setItem(INSPECTOR_HIDE_KEY, \"1\");\n } catch {\n // ignore\n }\n setIsHidden(true);\n }}\n style={{\n position: \"absolute\",\n bottom: \"2px\",\n right: \"2px\",\n width: \"20px\",\n height: \"20px\",\n borderRadius: \"50%\",\n background: \"#ffffff\",\n color: \"#ef4444\",\n fontSize: \"14px\",\n lineHeight: \"18px\",\n textAlign: \"center\",\n boxShadow: \"0 2px 6px rgba(0,0,0,0.35)\",\n cursor: \"pointer\",\n border: \"1px solid #e5e7eb\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n zIndex: 1,\n }}\n title=\"Hide Inspector\"\n >\n ×\n </div>\n <div\n style={{\n width: \"28px\",\n height: \"28px\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n filter: \"drop-shadow(0 2px 4px rgba(0,0,0,0.2))\",\n }}\n >\n <CopilotKitIcon />\n </div>\n {!hasApiKey && (\n <div\n style={{\n position: \"absolute\",\n top: \"-2px\",\n right: \"-2px\",\n width: \"18px\",\n height: \"18px\",\n background: \"linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%)\",\n borderRadius: \"50%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n boxShadow: \"0 2px 8px rgba(255, 107, 107, 0.4)\",\n border: \"2px solid white\",\n }}\n >\n <span style={{ fontSize: \"10px\", color: \"white\", fontWeight: \"bold\" }}>!</span>\n </div>\n )}\n </button>\n\n <DeveloperConsoleModal\n isOpen={isModalOpen}\n onClose={() => setIsModalOpen(false)}\n hasApiKey={hasApiKey}\n />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;AAEA,SAAgB,UAAU,WAAW,cAAc;AAkH/C,mBA6DI,KA5DF,YADF;AA5GJ,IAAM,qBAAqB;AAMpB,SAAS,eAAe,EAAE,WAAW,eAAe,GAAwB;AACjF,QAAM,UAAU,kBAAkB;AAClC,QAAM,YAAY,QAAQ,QAAQ,iBAAiB,YAAY;AAC/D,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AACpD,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAClD,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAA0C,IAAI;AAC1F,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,CAAC,UAAU,WAAW,IA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AgB;AAAA,gBAChB,QAAQ;AAAA,cACV;AAAA,cAEA,8BAAC,kBAAe;AAAA;AAAA,UAClB;AAAA,UACC,CAAC,aACA;AAAA,YAAC;AAAA;AAAA,cACC,OAAO;AAAA,gBACL,UAAU;AAAA,gBACV,KAAK;AAAA,gBACL,OAAO;AAAA,gBACP,OAAO;AAAA,gBACP,QAAQ;AAAA,gBACR,YAAY;AAAA,gBACZ,cAAc;AAAA,gBACd,SAAS;AAAA,gBACT,YAAY;AAAA,gBACZ,gBAAgB;AAAA,gBAChB,WAAW;AAAA,gBACX,QAAQ;AAAA,cACV;AAAA,cAEA,8BAAC,UAAK,OAAO,EAAE,UAAU,QAAQ,OAAO,SAAS,YAAY,OAAO,GAAG,eAAC;AAAA;AAAA,UAC1E;AAAA;AAAA;AAAA,IAEJ;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ;AAAA,QACR,SAAS,MAAM,eAAe,KAAK;AAAA,QACnC;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":["e"]}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-EFL5OBKN.mjs";
|
|
7
7
|
import {
|
|
8
8
|
useCopilotContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YHT6CWIY.mjs";
|
|
10
10
|
import {
|
|
11
11
|
__async,
|
|
12
12
|
__spreadValues
|
|
@@ -139,4 +139,4 @@ function isFrontendAction(action) {
|
|
|
139
139
|
export {
|
|
140
140
|
useCopilotAction
|
|
141
141
|
};
|
|
142
|
-
//# sourceMappingURL=chunk-
|
|
142
|
+
//# sourceMappingURL=chunk-JEMBA7PE.mjs.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotAction
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JEMBA7PE.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useCopilotContext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YHT6CWIY.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__spreadProps,
|
|
9
9
|
__spreadValues
|
|
@@ -56,4 +56,4 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
|
56
56
|
export {
|
|
57
57
|
useCopilotAuthenticatedAction_c
|
|
58
58
|
};
|
|
59
|
-
//# sourceMappingURL=chunk-
|
|
59
|
+
//# sourceMappingURL=chunk-KWS75AOU.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotChat
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5PIHZC7Z.mjs";
|
|
4
4
|
|
|
5
5
|
// src/hooks/use-copilot-chat.ts
|
|
6
6
|
function useCopilotChat2(options = {}) {
|
|
@@ -31,4 +31,4 @@ function useCopilotChat2(options = {}) {
|
|
|
31
31
|
export {
|
|
32
32
|
useCopilotChat2 as useCopilotChat
|
|
33
33
|
};
|
|
34
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-LINGATDU.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YHT6CWIY.mjs";
|
|
4
4
|
|
|
5
5
|
// src/hooks/use-copilot-additional-instructions.ts
|
|
6
6
|
import { useEffect } from "react";
|
|
@@ -21,4 +21,4 @@ function useCopilotAdditionalInstructions({ instructions, available = "enabled"
|
|
|
21
21
|
export {
|
|
22
22
|
useCopilotAdditionalInstructions
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-MZ37BAAE.mjs.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotChat
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5PIHZC7Z.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useMessagesTap
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-2MGJO3FY.mjs";
|
|
7
7
|
import {
|
|
8
8
|
useCopilotRuntimeClient
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-Q3MCVRO3.mjs";
|
|
10
10
|
import {
|
|
11
11
|
useAsyncCallback
|
|
12
12
|
} from "./chunk-N4WEHORG.mjs";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./chunk-EFL5OBKN.mjs";
|
|
16
16
|
import {
|
|
17
17
|
useCopilotContext
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-YHT6CWIY.mjs";
|
|
19
19
|
import {
|
|
20
20
|
__async,
|
|
21
21
|
__spreadProps,
|
|
@@ -27,7 +27,7 @@ import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
|
27
27
|
import { parseJson, CopilotKitAgentDiscoveryError } from "@copilotkit/shared";
|
|
28
28
|
function useCoAgent(options) {
|
|
29
29
|
const context = useCopilotContext();
|
|
30
|
-
const { availableAgents } = context;
|
|
30
|
+
const { availableAgents, onError } = context;
|
|
31
31
|
const { setBannerError } = useToast();
|
|
32
32
|
const lastLoadedThreadId = useRef();
|
|
33
33
|
const lastLoadedState = useRef();
|
|
@@ -52,7 +52,8 @@ function useCoAgent(options) {
|
|
|
52
52
|
publicApiKey: copilotApiConfig.publicApiKey,
|
|
53
53
|
headers,
|
|
54
54
|
credentials: copilotApiConfig.credentials,
|
|
55
|
-
showDevConsole: context.showDevConsole
|
|
55
|
+
showDevConsole: context.showDevConsole,
|
|
56
|
+
onError
|
|
56
57
|
});
|
|
57
58
|
const setState = useCallback(
|
|
58
59
|
(newState) => {
|
|
@@ -235,4 +236,4 @@ export {
|
|
|
235
236
|
stopAgent,
|
|
236
237
|
runAgent
|
|
237
238
|
};
|
|
238
|
-
//# sourceMappingURL=chunk-
|
|
239
|
+
//# sourceMappingURL=chunk-NDD2NTFT.mjs.map
|