@copilotkit/react-core 1.9.2-next.2 → 1.9.2-next.20
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 +154 -0
- package/dist/{chunk-UHQMV2CE.mjs → chunk-36MGCCPZ.mjs} +2 -2
- package/dist/{chunk-CCESTGAM.mjs → chunk-3OQM3NEK.mjs} +2 -2
- package/dist/{chunk-FRZZPPIV.mjs → chunk-3SLA7Q2N.mjs} +2 -2
- package/dist/chunk-57K2ZJ5F.mjs +348 -0
- package/dist/chunk-57K2ZJ5F.mjs.map +1 -0
- package/dist/{chunk-LZDDYZEY.mjs → chunk-5BSUSFHM.mjs} +2 -2
- package/dist/{chunk-C6F6EQNA.mjs → chunk-BVK7PLK6.mjs} +2 -2
- package/dist/{chunk-6KGEF242.mjs → chunk-DKZTPL66.mjs} +3 -2
- package/dist/chunk-DKZTPL66.mjs.map +1 -0
- package/dist/{chunk-LDACFA2B.mjs → chunk-FN3UA2ZE.mjs} +3 -3
- package/dist/{chunk-RUY6MLHA.mjs → chunk-JWAXDYOW.mjs} +36 -6
- package/dist/chunk-JWAXDYOW.mjs.map +1 -0
- package/dist/{chunk-4I7PLQF7.mjs → chunk-K42OD3J6.mjs} +5 -5
- package/dist/{chunk-2FW7HH6W.mjs → chunk-KIXKBJUV.mjs} +3 -3
- package/dist/{chunk-L6QAOAE4.mjs → chunk-KWQPQ4MM.mjs} +69 -25
- package/dist/chunk-KWQPQ4MM.mjs.map +1 -0
- package/dist/{chunk-MGIXEJWG.mjs → chunk-MTAJI7HV.mjs} +181 -68
- package/dist/chunk-MTAJI7HV.mjs.map +1 -0
- package/dist/{chunk-T42PN5VN.mjs → chunk-NJA5ZLAZ.mjs} +29 -10
- package/dist/chunk-NJA5ZLAZ.mjs.map +1 -0
- package/dist/{chunk-NNSXCFQO.mjs → chunk-R2LNRHJP.mjs} +41 -7
- package/dist/chunk-R2LNRHJP.mjs.map +1 -0
- package/dist/{chunk-QQZLIEXK.mjs → chunk-SJJNFYGQ.mjs} +3 -3
- package/dist/{chunk-OUSWPVDT.mjs → chunk-UGJGKBFB.mjs} +4 -4
- package/dist/{chunk-Q5D5XQFA.mjs → chunk-VDADWRS3.mjs} +2 -2
- package/dist/chunk-YAF2LATQ.mjs +310 -0
- package/dist/chunk-YAF2LATQ.mjs.map +1 -0
- package/dist/{chunk-CMKIDDQL.mjs → chunk-ZOMEQ3XC.mjs} +11 -8
- package/dist/{chunk-CMKIDDQL.mjs.map → chunk-ZOMEQ3XC.mjs.map} +1 -1
- package/dist/components/copilot-provider/copilot-messages.js +39 -4
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
- package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
- package/dist/components/copilot-provider/copilotkit-props.d.ts +27 -3
- 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 +384 -253
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +10 -10
- package/dist/components/copilot-provider/index.d.ts +1 -1
- package/dist/components/copilot-provider/index.js +384 -253
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +10 -10
- package/dist/components/error-boundary/error-boundary.js +135 -146
- package/dist/components/error-boundary/error-boundary.js.map +1 -1
- package/dist/components/error-boundary/error-boundary.mjs +4 -4
- package/dist/components/error-boundary/error-utils.js.map +1 -1
- package/dist/components/error-boundary/error-utils.mjs +2 -2
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +384 -253
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +10 -10
- package/dist/components/toast/toast-provider.js +118 -85
- package/dist/components/toast/toast-provider.js.map +1 -1
- package/dist/components/toast/toast-provider.mjs +1 -1
- package/dist/components/usage-banner.js +135 -146
- package/dist/components/usage-banner.js.map +1 -1
- package/dist/components/usage-banner.mjs +1 -1
- package/dist/context/copilot-context.d.ts +1 -1
- package/dist/context/copilot-context.js +2 -1
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.js +2 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/{copilot-context-f9b2b4c3.d.ts → copilot-context-3ab4fdf5.d.ts} +6 -2
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +232 -71
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +32 -32
- package/dist/hooks/use-chat.d.ts +1 -1
- package/dist/hooks/use-chat.js +295 -156
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +6 -6
- package/dist/hooks/use-coagent-state-render.js +2 -1
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +3 -3
- package/dist/hooks/use-coagent.d.ts +1 -1
- package/dist/hooks/use-coagent.js +207 -65
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +14 -14
- package/dist/hooks/use-copilot-action.js +27 -7
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +4 -4
- package/dist/hooks/use-copilot-additional-instructions.js +2 -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 +27 -7
- package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
- package/dist/hooks/use-copilot-authenticated-action.mjs +5 -5
- package/dist/hooks/use-copilot-chat.d.ts +1 -1
- package/dist/hooks/use-copilot-chat.js +204 -65
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +13 -13
- package/dist/hooks/use-copilot-readable.js +2 -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 +2 -0
- package/dist/hooks/use-copilot-runtime-client.js +52 -2
- package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
- package/dist/hooks/use-copilot-runtime-client.mjs +2 -2
- package/dist/hooks/use-langgraph-interrupt-render.js +2 -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 +204 -65
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +14 -14
- package/dist/hooks/use-make-copilot-document-readable.js +2 -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.d.ts +1 -1
- package/dist/index.js +581 -320
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -33
- package/dist/lib/copilot-task.d.ts +1 -1
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +11 -11
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +11 -11
- package/dist/types/interrupt-action.d.ts +1 -1
- package/dist/utils/extract.d.ts +1 -1
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +10 -10
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +10 -10
- package/jest.config.js +7 -3
- package/package.json +4 -3
- package/src/components/copilot-provider/__tests__/copilotkit-error.test.tsx +75 -0
- package/src/components/copilot-provider/copilot-messages.tsx +46 -5
- package/src/components/copilot-provider/copilotkit-props.tsx +27 -1
- package/src/components/copilot-provider/copilotkit.tsx +64 -18
- package/src/components/toast/toast-provider.tsx +49 -24
- package/src/components/usage-banner.tsx +144 -147
- package/src/context/copilot-context.tsx +8 -2
- package/src/hooks/use-chat.ts +247 -61
- package/src/hooks/use-coagent.ts +5 -0
- package/src/hooks/use-copilot-action.ts +51 -9
- package/src/hooks/use-copilot-runtime-client.ts +41 -40
- package/tsconfig.json +4 -8
- package/tsup.config.ts +6 -6
- package/dist/chunk-6KGEF242.mjs.map +0 -1
- package/dist/chunk-HD2GE3DK.mjs +0 -359
- package/dist/chunk-HD2GE3DK.mjs.map +0 -1
- package/dist/chunk-L6QAOAE4.mjs.map +0 -1
- package/dist/chunk-MGIXEJWG.mjs.map +0 -1
- package/dist/chunk-NNSXCFQO.mjs.map +0 -1
- package/dist/chunk-RUY6MLHA.mjs.map +0 -1
- package/dist/chunk-T42PN5VN.mjs.map +0 -1
- package/dist/chunk-VRXANACV.mjs +0 -277
- package/dist/chunk-VRXANACV.mjs.map +0 -1
- package/dist/utils/utils.test.d.ts +0 -2
- package/dist/utils/utils.test.js +0 -9
- package/dist/utils/utils.test.js.map +0 -1
- package/dist/utils/utils.test.mjs +0 -7
- package/dist/utils/utils.test.mjs.map +0 -1
- /package/dist/{chunk-UHQMV2CE.mjs.map → chunk-36MGCCPZ.mjs.map} +0 -0
- /package/dist/{chunk-CCESTGAM.mjs.map → chunk-3OQM3NEK.mjs.map} +0 -0
- /package/dist/{chunk-FRZZPPIV.mjs.map → chunk-3SLA7Q2N.mjs.map} +0 -0
- /package/dist/{chunk-LZDDYZEY.mjs.map → chunk-5BSUSFHM.mjs.map} +0 -0
- /package/dist/{chunk-C6F6EQNA.mjs.map → chunk-BVK7PLK6.mjs.map} +0 -0
- /package/dist/{chunk-LDACFA2B.mjs.map → chunk-FN3UA2ZE.mjs.map} +0 -0
- /package/dist/{chunk-4I7PLQF7.mjs.map → chunk-K42OD3J6.mjs.map} +0 -0
- /package/dist/{chunk-2FW7HH6W.mjs.map → chunk-KIXKBJUV.mjs.map} +0 -0
- /package/dist/{chunk-QQZLIEXK.mjs.map → chunk-SJJNFYGQ.mjs.map} +0 -0
- /package/dist/{chunk-OUSWPVDT.mjs.map → chunk-UGJGKBFB.mjs.map} +0 -0
- /package/dist/{chunk-Q5D5XQFA.mjs.map → chunk-VDADWRS3.mjs.map} +0 -0
|
@@ -6,16 +6,16 @@ import {
|
|
|
6
6
|
} from "./chunk-GFJW4RIM.mjs";
|
|
7
7
|
import {
|
|
8
8
|
useToast
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YAF2LATQ.mjs";
|
|
10
10
|
import {
|
|
11
11
|
useCopilotContext
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-DKZTPL66.mjs";
|
|
13
13
|
import {
|
|
14
14
|
__async
|
|
15
15
|
} from "./chunk-SKC7AJIV.mjs";
|
|
16
16
|
|
|
17
17
|
// src/components/copilot-provider/copilot-messages.tsx
|
|
18
|
-
import { useEffect, useState, useRef, useCallback } from "react";
|
|
18
|
+
import { useEffect, useState, useRef, useCallback, useMemo } from "react";
|
|
19
19
|
import {
|
|
20
20
|
loadMessagesFromJsonRepresentation
|
|
21
21
|
} from "@copilotkit/runtime-client-gql";
|
|
@@ -33,8 +33,38 @@ function CopilotMessages({ children }) {
|
|
|
33
33
|
const lastLoadedThreadId = useRef();
|
|
34
34
|
const lastLoadedAgentName = useRef();
|
|
35
35
|
const lastLoadedMessages = useRef();
|
|
36
|
-
const { threadId, agentSession, runtimeClient, showDevConsole } = useCopilotContext();
|
|
36
|
+
const { threadId, agentSession, runtimeClient, showDevConsole, onError, copilotApiConfig } = useCopilotContext();
|
|
37
37
|
const { setBannerError } = useToast();
|
|
38
|
+
const traceUIError = useCallback(
|
|
39
|
+
(error, originalError) => __async(this, null, function* () {
|
|
40
|
+
if (!onError || !copilotApiConfig.publicApiKey)
|
|
41
|
+
return;
|
|
42
|
+
try {
|
|
43
|
+
const traceEvent = {
|
|
44
|
+
type: "error",
|
|
45
|
+
timestamp: Date.now(),
|
|
46
|
+
context: {
|
|
47
|
+
source: "ui",
|
|
48
|
+
request: {
|
|
49
|
+
operation: "loadAgentState",
|
|
50
|
+
url: copilotApiConfig.chatApiEndpoint,
|
|
51
|
+
startTime: Date.now()
|
|
52
|
+
},
|
|
53
|
+
technical: {
|
|
54
|
+
environment: "browser",
|
|
55
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
56
|
+
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
error
|
|
60
|
+
};
|
|
61
|
+
yield onError(traceEvent);
|
|
62
|
+
} catch (traceError) {
|
|
63
|
+
console.error("Error in CopilotMessages onError handler:", traceError);
|
|
64
|
+
}
|
|
65
|
+
}),
|
|
66
|
+
[onError, copilotApiConfig.publicApiKey, copilotApiConfig.chatApiEndpoint]
|
|
67
|
+
);
|
|
38
68
|
const createStructuredError = (gqlError) => {
|
|
39
69
|
const extensions = gqlError.extensions;
|
|
40
70
|
const originalError = extensions == null ? void 0 : extensions.originalError;
|
|
@@ -79,12 +109,14 @@ function CopilotMessages({ children }) {
|
|
|
79
109
|
const ckError = createStructuredError(gqlError);
|
|
80
110
|
if (ckError) {
|
|
81
111
|
setBannerError(ckError);
|
|
112
|
+
traceUIError(ckError, gqlError);
|
|
82
113
|
} else {
|
|
83
114
|
const fallbackError = new CopilotKitError({
|
|
84
115
|
message: gqlError.message,
|
|
85
116
|
code: CopilotKitErrorCode.UNKNOWN
|
|
86
117
|
});
|
|
87
118
|
setBannerError(fallbackError);
|
|
119
|
+
traceUIError(fallbackError, gqlError);
|
|
88
120
|
}
|
|
89
121
|
};
|
|
90
122
|
graphQLErrors.forEach(routeError);
|
|
@@ -98,10 +130,11 @@ function CopilotMessages({ children }) {
|
|
|
98
130
|
code: CopilotKitErrorCode.UNKNOWN
|
|
99
131
|
});
|
|
100
132
|
setBannerError(fallbackError);
|
|
133
|
+
traceUIError(fallbackError, error);
|
|
101
134
|
}
|
|
102
135
|
}
|
|
103
136
|
},
|
|
104
|
-
[setBannerError, showDevConsole]
|
|
137
|
+
[setBannerError, showDevConsole, traceUIError]
|
|
105
138
|
);
|
|
106
139
|
useEffect(() => {
|
|
107
140
|
if (!threadId || threadId === lastLoadedThreadId.current)
|
|
@@ -136,6 +169,7 @@ function CopilotMessages({ children }) {
|
|
|
136
169
|
});
|
|
137
170
|
void fetchMessages();
|
|
138
171
|
}, [threadId, agentSession == null ? void 0 : agentSession.agentName, runtimeClient]);
|
|
172
|
+
const memoizedChildren = useMemo(() => children, [children]);
|
|
139
173
|
return /* @__PURE__ */ jsx(
|
|
140
174
|
CopilotMessagesContext.Provider,
|
|
141
175
|
{
|
|
@@ -143,7 +177,7 @@ function CopilotMessages({ children }) {
|
|
|
143
177
|
messages,
|
|
144
178
|
setMessages
|
|
145
179
|
},
|
|
146
|
-
children
|
|
180
|
+
children: memoizedChildren
|
|
147
181
|
}
|
|
148
182
|
);
|
|
149
183
|
}
|
|
@@ -151,4 +185,4 @@ function CopilotMessages({ children }) {
|
|
|
151
185
|
export {
|
|
152
186
|
CopilotMessages
|
|
153
187
|
};
|
|
154
|
-
//# sourceMappingURL=chunk-
|
|
188
|
+
//# sourceMappingURL=chunk-R2LNRHJP.mjs.map
|
|
@@ -0,0 +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 { ReactNode, useEffect, useState, useRef, useCallback, useMemo } 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\";\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\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 { 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, runtimeClient]); // handleGraphQLErrors should NOT be in deps - causes infinite loop\n\n const memoizedChildren = useMemo(() => children, [children]);\n\n return (\n <CopilotMessagesContext.Provider\n value={{\n messages,\n setMessages,\n }}\n >\n {memoizedChildren}\n </CopilotMessagesContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA,SAAoB,WAAW,UAAU,QAAQ,aAAa,eAAe;AAE7E;AAAA,EACE;AAAA,OAGK;AAIP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAqOH;AAnLG,SAAS,gBAAgB,EAAE,SAAS,GAA4B;AACrE,QAAM,CAAC,UAAU,WAAW,IAAI,SAAoB,CAAC,CAAC;AACtD,QAAM,qBAAqB,OAAe;AAC1C,QAAM,sBAAsB,OAAe;AAC3C,QAAM,qBAAqB,OAAe;AAE1C,QAAM,EAAE,UAAU,cAAc,eAAe,gBAAgB,SAAS,iBAAiB,IACvF,kBAAkB;AACpB,QAAM,EAAE,eAAe,IAAI,SAAS;AAGpC,QAAM,eAAe;AAAA,IACnB,CAAO,OAAwB,kBAAwB;AAErD,UAAI,CAAC,WAAW,CAAC,iBAAiB;AAAc;AAEhD,UAAI;AACF,cAAM,aAAa;AAAA,UACjB,MAAM;AAAA,UACN,WAAW,KAAK,IAAI;AAAA,UACpB,SAAS;AAAA,YACP,QAAQ;AAAA,YACR,SAAS;AAAA,cACP,WAAW;AAAA,cACX,KAAK,iBAAiB;AAAA,cACtB,WAAW,KAAK,IAAI;AAAA,YACtB;AAAA,YACA,WAAW;AAAA,cACT,aAAa;AAAA,cACb,WAAW,OAAO,cAAc,cAAc,UAAU,YAAY;AAAA,cACpE,YAAY,yBAAyB,QAAQ,cAAc,QAAQ;AAAA,YACr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AACjD,UAAI,gBAAgB,mBAAmB;AAAS;AAEhD,WAAI,kBAAO,SAAP,mBAAa,mBAAb,mBAA6B,cAAc;AAC7C,2BAAmB,UAAU;AAC7B,2BAAmB,UAAU;AAC7B,4BAAoB,UAAU,6CAAc;AAE5C,cAAMA,YAAW,mCAAmC,KAAK,MAAM,eAAe,IAAI,CAAC;AACnF,oBAAYA,SAAQ;AAAA,MACtB;AAAA,IACF;AACA,SAAK,cAAc;AAAA,EACrB,GAAG,CAAC,UAAU,6CAAc,WAAW,aAAa,CAAC;AAErD,QAAM,mBAAmB,QAAQ,MAAM,UAAU,CAAC,QAAQ,CAAC;AAE3D,SACE;AAAA,IAAC,uBAAuB;AAAA,IAAvB;AAAA,MACC,OAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":["messages"]}
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
UsageBanner,
|
|
6
6
|
renderCopilotKitUsage
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-57K2ZJ5F.mjs";
|
|
8
8
|
import {
|
|
9
9
|
useErrorToast
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3OQM3NEK.mjs";
|
|
11
11
|
|
|
12
12
|
// src/components/error-boundary/error-boundary.tsx
|
|
13
13
|
import React, { useEffect } from "react";
|
|
@@ -85,4 +85,4 @@ export {
|
|
|
85
85
|
CopilotErrorBoundary,
|
|
86
86
|
ErrorToast
|
|
87
87
|
};
|
|
88
|
-
//# sourceMappingURL=chunk-
|
|
88
|
+
//# sourceMappingURL=chunk-SJJNFYGQ.mjs.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotChat
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-K42OD3J6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useToast
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YAF2LATQ.mjs";
|
|
7
7
|
import {
|
|
8
8
|
CopilotContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DKZTPL66.mjs";
|
|
10
10
|
import {
|
|
11
11
|
__spreadProps,
|
|
12
12
|
__spreadValues
|
|
@@ -62,4 +62,4 @@ function useLangGraphInterrupt(action, dependencies) {
|
|
|
62
62
|
export {
|
|
63
63
|
useLangGraphInterrupt
|
|
64
64
|
};
|
|
65
|
-
//# sourceMappingURL=chunk-
|
|
65
|
+
//# sourceMappingURL=chunk-UGJGKBFB.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DKZTPL66.mjs";
|
|
4
4
|
|
|
5
5
|
// src/hooks/use-langgraph-interrupt-render.ts
|
|
6
6
|
import React, { useCallback } from "react";
|
|
@@ -44,4 +44,4 @@ function useLangGraphInterruptRender() {
|
|
|
44
44
|
export {
|
|
45
45
|
useLangGraphInterruptRender
|
|
46
46
|
};
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
47
|
+
//# sourceMappingURL=chunk-VDADWRS3.mjs.map
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadProps,
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "./chunk-SKC7AJIV.mjs";
|
|
5
|
+
|
|
6
|
+
// src/components/toast/toast-provider.tsx
|
|
7
|
+
import { createContext, useContext, useState, useCallback } from "react";
|
|
8
|
+
import { Severity } from "@copilotkit/shared";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
var ToastContext = createContext(void 0);
|
|
11
|
+
function getErrorSeverity(error) {
|
|
12
|
+
if (error.severity) {
|
|
13
|
+
switch (error.severity) {
|
|
14
|
+
case Severity.CRITICAL:
|
|
15
|
+
return "critical";
|
|
16
|
+
case Severity.WARNING:
|
|
17
|
+
return "warning";
|
|
18
|
+
case Severity.INFO:
|
|
19
|
+
return "info";
|
|
20
|
+
default:
|
|
21
|
+
return "info";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const message = error.message.toLowerCase();
|
|
25
|
+
if (message.includes("api key") || message.includes("401") || message.includes("unauthorized") || message.includes("authentication") || message.includes("incorrect api key")) {
|
|
26
|
+
return "critical";
|
|
27
|
+
}
|
|
28
|
+
return "info";
|
|
29
|
+
}
|
|
30
|
+
function getErrorColors(severity) {
|
|
31
|
+
switch (severity) {
|
|
32
|
+
case "critical":
|
|
33
|
+
return {
|
|
34
|
+
background: "#fee2e2",
|
|
35
|
+
border: "#dc2626",
|
|
36
|
+
text: "#7f1d1d",
|
|
37
|
+
icon: "#dc2626"
|
|
38
|
+
};
|
|
39
|
+
case "warning":
|
|
40
|
+
return {
|
|
41
|
+
background: "#fef3c7",
|
|
42
|
+
border: "#d97706",
|
|
43
|
+
text: "#78350f",
|
|
44
|
+
icon: "#d97706"
|
|
45
|
+
};
|
|
46
|
+
case "info":
|
|
47
|
+
return {
|
|
48
|
+
background: "#dbeafe",
|
|
49
|
+
border: "#2563eb",
|
|
50
|
+
text: "#1e3a8a",
|
|
51
|
+
icon: "#2563eb"
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function useToast() {
|
|
56
|
+
const context = useContext(ToastContext);
|
|
57
|
+
if (!context) {
|
|
58
|
+
throw new Error("useToast must be used within a ToastProvider");
|
|
59
|
+
}
|
|
60
|
+
return context;
|
|
61
|
+
}
|
|
62
|
+
function ToastProvider({
|
|
63
|
+
enabled,
|
|
64
|
+
children
|
|
65
|
+
}) {
|
|
66
|
+
const [toasts, setToasts] = useState([]);
|
|
67
|
+
const [bannerError, setBannerErrorState] = useState(null);
|
|
68
|
+
const removeToast = useCallback((id) => {
|
|
69
|
+
setToasts((prev) => prev.filter((toast) => toast.id !== id));
|
|
70
|
+
}, []);
|
|
71
|
+
const addToast = useCallback(
|
|
72
|
+
(toast) => {
|
|
73
|
+
var _a;
|
|
74
|
+
if (!enabled) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const id = (_a = toast.id) != null ? _a : Math.random().toString(36).substring(2, 9);
|
|
78
|
+
setToasts((currentToasts) => {
|
|
79
|
+
if (currentToasts.find((toast2) => toast2.id === id))
|
|
80
|
+
return currentToasts;
|
|
81
|
+
return [...currentToasts, __spreadProps(__spreadValues({}, toast), { id })];
|
|
82
|
+
});
|
|
83
|
+
if (toast.duration) {
|
|
84
|
+
setTimeout(() => {
|
|
85
|
+
removeToast(id);
|
|
86
|
+
}, toast.duration);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
[enabled, removeToast]
|
|
90
|
+
);
|
|
91
|
+
const setBannerError = useCallback(
|
|
92
|
+
(error) => {
|
|
93
|
+
if (!enabled && error !== null) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
setBannerErrorState(error);
|
|
97
|
+
},
|
|
98
|
+
[enabled]
|
|
99
|
+
);
|
|
100
|
+
const addGraphQLErrorsToast = useCallback((errors) => {
|
|
101
|
+
console.warn("addGraphQLErrorsToast is deprecated. All errors now show as banners.");
|
|
102
|
+
}, []);
|
|
103
|
+
const value = {
|
|
104
|
+
toasts,
|
|
105
|
+
addToast,
|
|
106
|
+
addGraphQLErrorsToast,
|
|
107
|
+
removeToast,
|
|
108
|
+
enabled,
|
|
109
|
+
bannerError,
|
|
110
|
+
setBannerError
|
|
111
|
+
};
|
|
112
|
+
return /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
|
|
113
|
+
bannerError && (() => {
|
|
114
|
+
const severity = getErrorSeverity(bannerError);
|
|
115
|
+
const colors = getErrorColors(severity);
|
|
116
|
+
return /* @__PURE__ */ jsx(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
style: {
|
|
120
|
+
position: "fixed",
|
|
121
|
+
bottom: "20px",
|
|
122
|
+
left: "50%",
|
|
123
|
+
transform: "translateX(-50%)",
|
|
124
|
+
zIndex: 9999,
|
|
125
|
+
backgroundColor: colors.background,
|
|
126
|
+
border: `1px solid ${colors.border}`,
|
|
127
|
+
borderLeft: `4px solid ${colors.border}`,
|
|
128
|
+
borderRadius: "8px",
|
|
129
|
+
padding: "12px 16px",
|
|
130
|
+
fontSize: "13px",
|
|
131
|
+
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
|
|
132
|
+
backdropFilter: "blur(8px)",
|
|
133
|
+
maxWidth: "min(90vw, 700px)",
|
|
134
|
+
width: "100%",
|
|
135
|
+
boxSizing: "border-box",
|
|
136
|
+
overflow: "hidden"
|
|
137
|
+
},
|
|
138
|
+
children: /* @__PURE__ */ jsxs(
|
|
139
|
+
"div",
|
|
140
|
+
{
|
|
141
|
+
style: {
|
|
142
|
+
display: "flex",
|
|
143
|
+
justifyContent: "space-between",
|
|
144
|
+
alignItems: "center",
|
|
145
|
+
gap: "10px"
|
|
146
|
+
},
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ jsxs(
|
|
149
|
+
"div",
|
|
150
|
+
{
|
|
151
|
+
style: {
|
|
152
|
+
display: "flex",
|
|
153
|
+
alignItems: "center",
|
|
154
|
+
gap: "8px",
|
|
155
|
+
flex: 1,
|
|
156
|
+
minWidth: 0
|
|
157
|
+
},
|
|
158
|
+
children: [
|
|
159
|
+
/* @__PURE__ */ jsx(
|
|
160
|
+
"div",
|
|
161
|
+
{
|
|
162
|
+
style: {
|
|
163
|
+
width: "12px",
|
|
164
|
+
height: "12px",
|
|
165
|
+
borderRadius: "50%",
|
|
166
|
+
backgroundColor: colors.border,
|
|
167
|
+
flexShrink: 0
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
),
|
|
171
|
+
/* @__PURE__ */ jsxs(
|
|
172
|
+
"div",
|
|
173
|
+
{
|
|
174
|
+
style: {
|
|
175
|
+
display: "flex",
|
|
176
|
+
alignItems: "center",
|
|
177
|
+
gap: "10px",
|
|
178
|
+
flex: 1,
|
|
179
|
+
minWidth: 0
|
|
180
|
+
},
|
|
181
|
+
children: [
|
|
182
|
+
/* @__PURE__ */ jsx(
|
|
183
|
+
"div",
|
|
184
|
+
{
|
|
185
|
+
style: {
|
|
186
|
+
color: colors.text,
|
|
187
|
+
lineHeight: "1.4",
|
|
188
|
+
fontWeight: "400",
|
|
189
|
+
fontSize: "13px",
|
|
190
|
+
flex: 1,
|
|
191
|
+
wordBreak: "break-all",
|
|
192
|
+
overflowWrap: "break-word",
|
|
193
|
+
maxWidth: "550px",
|
|
194
|
+
overflow: "hidden",
|
|
195
|
+
display: "-webkit-box",
|
|
196
|
+
WebkitLineClamp: 10,
|
|
197
|
+
WebkitBoxOrient: "vertical"
|
|
198
|
+
},
|
|
199
|
+
children: (() => {
|
|
200
|
+
let message = bannerError.message;
|
|
201
|
+
const jsonMatch = message.match(/'message':\s*'([^']+)'/);
|
|
202
|
+
if (jsonMatch) {
|
|
203
|
+
return jsonMatch[1];
|
|
204
|
+
}
|
|
205
|
+
message = message.split(" - ")[0];
|
|
206
|
+
message = message.split(": Error code")[0];
|
|
207
|
+
message = message.replace(/:\s*\d{3}$/, "");
|
|
208
|
+
message = message.replace(/See more:.*$/g, "");
|
|
209
|
+
message = message.trim();
|
|
210
|
+
return message || "Configuration error occurred.";
|
|
211
|
+
})()
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
(() => {
|
|
215
|
+
const message = bannerError.message;
|
|
216
|
+
const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
217
|
+
const plainUrlRegex = /(https?:\/\/[^\s)]+)/g;
|
|
218
|
+
let url = null;
|
|
219
|
+
let buttonText = "See More";
|
|
220
|
+
const markdownMatch = markdownLinkRegex.exec(message);
|
|
221
|
+
if (markdownMatch) {
|
|
222
|
+
url = markdownMatch[2];
|
|
223
|
+
buttonText = "See More";
|
|
224
|
+
} else {
|
|
225
|
+
const urlMatch = plainUrlRegex.exec(message);
|
|
226
|
+
if (urlMatch) {
|
|
227
|
+
url = urlMatch[0].replace(/[.,;:'"]*$/, "");
|
|
228
|
+
buttonText = "See More";
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (!url)
|
|
232
|
+
return null;
|
|
233
|
+
return /* @__PURE__ */ jsx(
|
|
234
|
+
"button",
|
|
235
|
+
{
|
|
236
|
+
onClick: () => window.open(url, "_blank", "noopener,noreferrer"),
|
|
237
|
+
style: {
|
|
238
|
+
background: colors.border,
|
|
239
|
+
color: "white",
|
|
240
|
+
border: "none",
|
|
241
|
+
borderRadius: "5px",
|
|
242
|
+
padding: "4px 10px",
|
|
243
|
+
fontSize: "11px",
|
|
244
|
+
fontWeight: "500",
|
|
245
|
+
cursor: "pointer",
|
|
246
|
+
transition: "all 0.2s ease",
|
|
247
|
+
flexShrink: 0
|
|
248
|
+
},
|
|
249
|
+
onMouseEnter: (e) => {
|
|
250
|
+
e.currentTarget.style.opacity = "0.9";
|
|
251
|
+
e.currentTarget.style.transform = "translateY(-1px)";
|
|
252
|
+
},
|
|
253
|
+
onMouseLeave: (e) => {
|
|
254
|
+
e.currentTarget.style.opacity = "1";
|
|
255
|
+
e.currentTarget.style.transform = "translateY(0)";
|
|
256
|
+
},
|
|
257
|
+
children: buttonText
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
})()
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
)
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
),
|
|
267
|
+
/* @__PURE__ */ jsx(
|
|
268
|
+
"button",
|
|
269
|
+
{
|
|
270
|
+
onClick: () => setBannerError(null),
|
|
271
|
+
style: {
|
|
272
|
+
background: "transparent",
|
|
273
|
+
border: "none",
|
|
274
|
+
color: colors.text,
|
|
275
|
+
cursor: "pointer",
|
|
276
|
+
padding: "2px",
|
|
277
|
+
borderRadius: "3px",
|
|
278
|
+
fontSize: "14px",
|
|
279
|
+
lineHeight: "1",
|
|
280
|
+
opacity: 0.6,
|
|
281
|
+
transition: "all 0.2s ease",
|
|
282
|
+
flexShrink: 0
|
|
283
|
+
},
|
|
284
|
+
title: "Dismiss",
|
|
285
|
+
onMouseEnter: (e) => {
|
|
286
|
+
e.currentTarget.style.opacity = "1";
|
|
287
|
+
e.currentTarget.style.background = "rgba(0, 0, 0, 0.05)";
|
|
288
|
+
},
|
|
289
|
+
onMouseLeave: (e) => {
|
|
290
|
+
e.currentTarget.style.opacity = "0.6";
|
|
291
|
+
e.currentTarget.style.background = "transparent";
|
|
292
|
+
},
|
|
293
|
+
children: "\xD7"
|
|
294
|
+
}
|
|
295
|
+
)
|
|
296
|
+
]
|
|
297
|
+
}
|
|
298
|
+
)
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
})(),
|
|
302
|
+
children
|
|
303
|
+
] });
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export {
|
|
307
|
+
useToast,
|
|
308
|
+
ToastProvider
|
|
309
|
+
};
|
|
310
|
+
//# sourceMappingURL=chunk-YAF2LATQ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/toast/toast-provider.tsx"],"sourcesContent":["import { GraphQLError } from \"@copilotkit/runtime-client-gql\";\nimport React, { createContext, useContext, useState, useCallback } from \"react\";\nimport { ErrorToast } from \"../error-boundary/error-utils\";\nimport { PartialBy, CopilotKitError, CopilotKitErrorCode, Severity } from \"@copilotkit/shared\";\nimport { renderCopilotKitUsage } from \"../usage-banner\";\n\ninterface Toast {\n id: string;\n message: string | React.ReactNode;\n type: \"info\" | \"success\" | \"warning\" | \"error\";\n duration?: number;\n}\n\ninterface ToastContextValue {\n toasts: Toast[];\n addToast: (toast: PartialBy<Toast, \"id\">) => void;\n addGraphQLErrorsToast: (errors: GraphQLError[]) => void;\n removeToast: (id: string) => void;\n enabled: boolean;\n // Banner management\n bannerError: CopilotKitError | null;\n setBannerError: (error: CopilotKitError | null) => void;\n}\n\nconst ToastContext = createContext<ToastContextValue | undefined>(undefined);\n\n// Helper functions for error banner styling\ntype ErrorSeverity = \"critical\" | \"warning\" | \"info\";\n\ninterface ErrorColors {\n background: string;\n border: string;\n text: string;\n icon: string;\n}\n\nfunction getErrorSeverity(error: CopilotKitError): ErrorSeverity {\n // Use structured error severity if available\n if (error.severity) {\n switch (error.severity) {\n case Severity.CRITICAL:\n return \"critical\";\n case Severity.WARNING:\n return \"warning\";\n case Severity.INFO:\n return \"info\";\n default:\n return \"info\";\n }\n }\n\n // Fallback: Check for API key errors which should always be critical\n const message = error.message.toLowerCase();\n if (\n message.includes(\"api key\") ||\n message.includes(\"401\") ||\n message.includes(\"unauthorized\") ||\n message.includes(\"authentication\") ||\n message.includes(\"incorrect api key\")\n ) {\n return \"critical\";\n }\n\n // Default to info level\n return \"info\";\n}\n\nfunction getErrorColors(severity: ErrorSeverity): ErrorColors {\n switch (severity) {\n case \"critical\":\n return {\n background: \"#fee2e2\",\n border: \"#dc2626\",\n text: \"#7f1d1d\",\n icon: \"#dc2626\",\n };\n case \"warning\":\n return {\n background: \"#fef3c7\",\n border: \"#d97706\",\n text: \"#78350f\",\n icon: \"#d97706\",\n };\n case \"info\":\n return {\n background: \"#dbeafe\",\n border: \"#2563eb\",\n text: \"#1e3a8a\",\n icon: \"#2563eb\",\n };\n }\n}\n\nexport function useToast() {\n const context = useContext(ToastContext);\n if (!context) {\n throw new Error(\"useToast must be used within a ToastProvider\");\n }\n return context;\n}\n\nexport function ToastProvider({\n enabled,\n children,\n}: {\n enabled: boolean;\n children: React.ReactNode;\n}) {\n const [toasts, setToasts] = useState<Toast[]>([]);\n const [bannerError, setBannerErrorState] = useState<CopilotKitError | null>(null);\n\n const removeToast = useCallback((id: string) => {\n setToasts((prev) => prev.filter((toast) => toast.id !== id));\n }, []);\n\n const addToast = useCallback(\n (toast: PartialBy<Toast, \"id\">) => {\n // Respect the enabled flag for ALL toasts\n if (!enabled) {\n return;\n }\n\n const id = toast.id ?? Math.random().toString(36).substring(2, 9);\n\n setToasts((currentToasts) => {\n if (currentToasts.find((toast) => toast.id === id)) return currentToasts;\n return [...currentToasts, { ...toast, id }];\n });\n\n if (toast.duration) {\n setTimeout(() => {\n removeToast(id);\n }, toast.duration);\n }\n },\n [enabled, removeToast],\n );\n\n const setBannerError = useCallback(\n (error: CopilotKitError | null) => {\n // Respect the enabled flag for ALL errors\n if (!enabled && error !== null) {\n return;\n }\n setBannerErrorState(error);\n },\n [enabled],\n );\n\n const addGraphQLErrorsToast = useCallback((errors: GraphQLError[]) => {\n // DEPRECATED: All errors now route to banners for consistency\n console.warn(\"addGraphQLErrorsToast is deprecated. All errors now show as banners.\");\n // Function kept for backward compatibility - does nothing\n }, []);\n\n const value = {\n toasts,\n addToast,\n addGraphQLErrorsToast,\n removeToast,\n enabled,\n bannerError,\n setBannerError,\n };\n\n return (\n <ToastContext.Provider value={value}>\n {/* Banner Error Display */}\n {bannerError &&\n (() => {\n const severity = getErrorSeverity(bannerError);\n const colors = getErrorColors(severity);\n\n return (\n <div\n style={{\n position: \"fixed\",\n bottom: \"20px\",\n left: \"50%\",\n transform: \"translateX(-50%)\",\n zIndex: 9999,\n backgroundColor: colors.background,\n border: `1px solid ${colors.border}`,\n borderLeft: `4px solid ${colors.border}`,\n borderRadius: \"8px\",\n padding: \"12px 16px\",\n fontSize: \"13px\",\n boxShadow: \"0 4px 12px rgba(0, 0, 0, 0.15)\",\n backdropFilter: \"blur(8px)\",\n maxWidth: \"min(90vw, 700px)\",\n width: \"100%\",\n boxSizing: \"border-box\",\n overflow: \"hidden\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n gap: \"10px\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: \"8px\",\n flex: 1,\n minWidth: 0,\n }}\n >\n <div\n style={{\n width: \"12px\",\n height: \"12px\",\n borderRadius: \"50%\",\n backgroundColor: colors.border,\n flexShrink: 0,\n }}\n />\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: \"10px\",\n flex: 1,\n minWidth: 0,\n }}\n >\n <div\n style={{\n color: colors.text,\n lineHeight: \"1.4\",\n fontWeight: \"400\",\n fontSize: \"13px\",\n flex: 1,\n wordBreak: \"break-all\",\n overflowWrap: \"break-word\",\n maxWidth: \"550px\",\n overflow: \"hidden\",\n display: \"-webkit-box\",\n WebkitLineClamp: 10,\n WebkitBoxOrient: \"vertical\",\n }}\n >\n {(() => {\n let message = bannerError.message;\n\n // Try to extract the useful message from JSON first\n const jsonMatch = message.match(/'message':\\s*'([^']+)'/);\n if (jsonMatch) {\n return jsonMatch[1]; // Return the actual error message\n }\n\n // Strip technical garbage but keep the meaningful message\n message = message.split(\" - \")[0]; // Remove everything after \" - {\"\n message = message.split(\": Error code\")[0]; // Remove \": Error code: 401\"\n message = message.replace(/:\\s*\\d{3}$/, \"\"); // Remove trailing \": 401\"\n message = message.replace(/See more:.*$/g, \"\"); // Remove \"See more\" links\n message = message.trim();\n\n // If it's still garbage (contains { or '), use fallback\n // if (message.includes(\"{\") || message.includes(\"'\")) {\n // return \"Configuration error.... Please check your setup.\";\n // }\n\n return message || \"Configuration error occurred.\";\n })()}\n </div>\n\n {(() => {\n const message = bannerError.message;\n const markdownLinkRegex = /\\[([^\\]]+)\\]\\(([^)]+)\\)/g;\n const plainUrlRegex = /(https?:\\/\\/[^\\s)]+)/g;\n\n // Extract the first URL found\n let url = null;\n let buttonText = \"See More\";\n\n // Check for markdown links first\n const markdownMatch = markdownLinkRegex.exec(message);\n if (markdownMatch) {\n url = markdownMatch[2];\n buttonText = \"See More\";\n } else {\n // Check for plain URLs\n const urlMatch = plainUrlRegex.exec(message);\n if (urlMatch) {\n url = urlMatch[0].replace(/[.,;:'\"]*$/, \"\"); // Remove trailing punctuation\n buttonText = \"See More\";\n }\n }\n\n if (!url) return null;\n\n return (\n <button\n onClick={() => window.open(url, \"_blank\", \"noopener,noreferrer\")}\n style={{\n background: colors.border,\n color: \"white\",\n border: \"none\",\n borderRadius: \"5px\",\n padding: \"4px 10px\",\n fontSize: \"11px\",\n fontWeight: \"500\",\n cursor: \"pointer\",\n transition: \"all 0.2s ease\",\n flexShrink: 0,\n }}\n onMouseEnter={(e) => {\n e.currentTarget.style.opacity = \"0.9\";\n e.currentTarget.style.transform = \"translateY(-1px)\";\n }}\n onMouseLeave={(e) => {\n e.currentTarget.style.opacity = \"1\";\n e.currentTarget.style.transform = \"translateY(0)\";\n }}\n >\n {buttonText}\n </button>\n );\n })()}\n </div>\n </div>\n <button\n onClick={() => setBannerError(null)}\n style={{\n background: \"transparent\",\n border: \"none\",\n color: colors.text,\n cursor: \"pointer\",\n padding: \"2px\",\n borderRadius: \"3px\",\n fontSize: \"14px\",\n lineHeight: \"1\",\n opacity: 0.6,\n transition: \"all 0.2s ease\",\n flexShrink: 0,\n }}\n title=\"Dismiss\"\n onMouseEnter={(e) => {\n e.currentTarget.style.opacity = \"1\";\n e.currentTarget.style.background = \"rgba(0, 0, 0, 0.05)\";\n }}\n onMouseLeave={(e) => {\n e.currentTarget.style.opacity = \"0.6\";\n e.currentTarget.style.background = \"transparent\";\n }}\n >\n ×\n </button>\n </div>\n </div>\n );\n })()}\n\n {/* Toast Display - Deprecated: All errors now show as banners */}\n {children}\n </ToastContext.Provider>\n );\n}\n\n// Toast component removed - all errors now show as banners for consistency\n"],"mappings":";;;;;;AACA,SAAgB,eAAe,YAAY,UAAU,mBAAmB;AAExE,SAA0D,gBAAgB;AAiNxD,cASA,YATA;AA5LlB,IAAM,eAAe,cAA6C,MAAS;AAY3E,SAAS,iBAAiB,OAAuC;AAE/D,MAAI,MAAM,UAAU;AAClB,YAAQ,MAAM,UAAU;AAAA,MACtB,KAAK,SAAS;AACZ,eAAO;AAAA,MACT,KAAK,SAAS;AACZ,eAAO;AAAA,MACT,KAAK,SAAS;AACZ,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF;AAGA,QAAM,UAAU,MAAM,QAAQ,YAAY;AAC1C,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BACR,OAAO,OAAO;AAAA,sBACd,QAAQ;AAAA,sBACR,SAAS;AAAA,sBACT,cAAc;AAAA,sBACd,UAAU;AAAA,sBACV,YAAY;AAAA,sBACZ,SAAS;AAAA,sBACT,YAAY;AAAA,sBACZ,YAAY;AAAA,oBACd;AAAA,oBACA,OAAM;AAAA,oBACN,cAAc,CAAC,MAAM;AACnB,wBAAE,cAAc,MAAM,UAAU;AAChC,wBAAE,cAAc,MAAM,aAAa;AAAA,oBACrC;AAAA,oBACA,cAAc,CAAC,MAAM;AACnB,wBAAE,cAAc,MAAM,UAAU;AAChC,wBAAE,cAAc,MAAM,aAAa;AAAA,oBACrC;AAAA,oBACD;AAAA;AAAA,gBAED;AAAA;AAAA;AAAA,UACF;AAAA;AAAA,MACF;AAAA,IAEJ,GAAG;AAAA,IAGJ;AAAA,KACH;AAEJ;","names":["toast"]}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotChat
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-K42OD3J6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useCopilotMessagesContext
|
|
6
6
|
} from "./chunk-DCTJZ742.mjs";
|
|
7
|
-
import {
|
|
8
|
-
useCopilotRuntimeClient
|
|
9
|
-
} from "./chunk-RUY6MLHA.mjs";
|
|
10
7
|
import {
|
|
11
8
|
useAsyncCallback
|
|
12
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3OQM3NEK.mjs";
|
|
10
|
+
import {
|
|
11
|
+
useCopilotRuntimeClient
|
|
12
|
+
} from "./chunk-JWAXDYOW.mjs";
|
|
13
13
|
import {
|
|
14
14
|
useToast
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-YAF2LATQ.mjs";
|
|
16
16
|
import {
|
|
17
17
|
useCopilotContext
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-DKZTPL66.mjs";
|
|
19
19
|
import {
|
|
20
20
|
__async,
|
|
21
21
|
__spreadProps,
|
|
@@ -76,6 +76,9 @@ function useCoAgent(options) {
|
|
|
76
76
|
threadId,
|
|
77
77
|
agentName: name
|
|
78
78
|
});
|
|
79
|
+
if (result.error) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
79
82
|
const newState = (_b = (_a = result.data) == null ? void 0 : _a.loadAgentState) == null ? void 0 : _b.state;
|
|
80
83
|
if (newState === lastLoadedState.current)
|
|
81
84
|
return;
|
|
@@ -207,4 +210,4 @@ export {
|
|
|
207
210
|
stopAgent,
|
|
208
211
|
runAgent
|
|
209
212
|
};
|
|
210
|
-
//# sourceMappingURL=chunk-
|
|
213
|
+
//# sourceMappingURL=chunk-ZOMEQ3XC.mjs.map
|