@copilotkit/react-core 1.9.2-next.9 → 1.9.3-next.0
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 +191 -0
- package/dist/{chunk-ERXWDCY6.mjs → chunk-36MGCCPZ.mjs} +2 -2
- package/dist/{chunk-UBNRUXEK.mjs → chunk-5BSUSFHM.mjs} +2 -2
- package/dist/{chunk-G7LYGERN.mjs → chunk-6ZLSC4KB.mjs} +124 -73
- package/dist/chunk-6ZLSC4KB.mjs.map +1 -0
- package/dist/{chunk-JDEWNLNP.mjs → chunk-BSAVFYRQ.mjs} +11 -11
- package/dist/{chunk-JDEWNLNP.mjs.map → chunk-BSAVFYRQ.mjs.map} +1 -1
- package/dist/{chunk-JPMIAGI6.mjs → chunk-BVK7PLK6.mjs} +2 -2
- package/dist/{chunk-FXK6RQIN.mjs → chunk-CUAFWKTQ.mjs} +4 -4
- package/dist/{chunk-XFOTNHYA.mjs → chunk-DKZTPL66.mjs} +2 -2
- package/dist/{chunk-XFOTNHYA.mjs.map → chunk-DKZTPL66.mjs.map} +1 -1
- package/dist/{chunk-EF5BNM34.mjs → chunk-FN3UA2ZE.mjs} +3 -3
- package/dist/{chunk-EXU7GWLC.mjs → chunk-GEE5AMYL.mjs} +9 -9
- package/dist/{chunk-WOGURSAL.mjs → chunk-GIMSRCVW.mjs} +64 -23
- package/dist/chunk-GIMSRCVW.mjs.map +1 -0
- package/dist/{chunk-55QZ2SVJ.mjs → chunk-JWAXDYOW.mjs} +8 -8
- package/dist/chunk-JWAXDYOW.mjs.map +1 -0
- package/dist/{chunk-3YHYWAHK.mjs → chunk-KIXKBJUV.mjs} +2 -2
- package/dist/{chunk-ADIITPD2.mjs → chunk-KLENTCQV.mjs} +34 -8
- package/dist/{chunk-ADIITPD2.mjs.map → chunk-KLENTCQV.mjs.map} +1 -1
- package/dist/{chunk-OF4SZTLL.mjs → chunk-NGQN3JRJ.mjs} +3 -3
- package/dist/{chunk-NQVCZQ5T.mjs → chunk-NJA5ZLAZ.mjs} +27 -8
- package/dist/chunk-NJA5ZLAZ.mjs.map +1 -0
- package/dist/{chunk-SJJNFYGQ.mjs → chunk-SGF6C7I6.mjs} +4 -4
- package/dist/{chunk-CMQV4XNY.mjs → chunk-VDADWRS3.mjs} +2 -2
- package/dist/components/copilot-provider/copilot-messages.js +7 -7
- 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 +14 -9
- 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 +70 -29
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +9 -9
- package/dist/components/copilot-provider/index.d.ts +1 -1
- package/dist/components/copilot-provider/index.js +70 -29
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +9 -9
- package/dist/components/error-boundary/error-boundary.mjs +2 -2
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +70 -29
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +9 -9
- package/dist/context/copilot-context.d.ts +1 -1
- package/dist/context/copilot-context.js +1 -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 +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +4 -4
- package/dist/{copilot-context-3da805ab.d.ts → copilot-context-3ab4fdf5.d.ts} +3 -3
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +179 -83
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +23 -23
- package/dist/hooks/use-chat.d.ts +1 -1
- package/dist/hooks/use-chat.js +220 -169
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +4 -4
- package/dist/hooks/use-coagent-state-render.js +1 -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 +154 -77
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +14 -14
- package/dist/hooks/use-copilot-action.js +26 -7
- 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 +1 -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 +26 -7
- 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.d.ts +1 -1
- package/dist/hooks/use-copilot-chat.js +128 -77
- 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 +1 -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 -2
- package/dist/hooks/use-copilot-runtime-client.js +7 -7
- 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 +1 -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 +128 -77
- 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 +1 -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 +240 -103
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -27
- 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/setupTests.d.ts +2 -0
- package/dist/setupTests.js +26 -0
- package/dist/setupTests.js.map +1 -0
- package/dist/setupTests.mjs +24 -0
- package/dist/setupTests.mjs.map +1 -0
- 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 +9 -9
- 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 +4 -0
- package/package.json +6 -3
- package/src/components/copilot-provider/__tests__/{copilotkit-trace.test.tsx → copilotkit-error.test.tsx} +17 -17
- package/src/components/copilot-provider/copilot-messages.tsx +7 -7
- package/src/components/copilot-provider/copilotkit-props.tsx +13 -8
- package/src/components/copilot-provider/copilotkit.tsx +61 -19
- package/src/context/copilot-context.tsx +4 -4
- package/src/hooks/__tests__/use-coagent-config.test.ts +284 -0
- package/src/hooks/use-chat.ts +149 -61
- package/src/hooks/use-coagent.ts +36 -0
- package/src/hooks/use-copilot-action.ts +51 -9
- package/src/hooks/use-copilot-runtime-client.ts +11 -12
- package/src/setupTests.ts +26 -0
- package/tsconfig.json +5 -2
- package/dist/chunk-55QZ2SVJ.mjs.map +0 -1
- package/dist/chunk-G7LYGERN.mjs.map +0 -1
- package/dist/chunk-NQVCZQ5T.mjs.map +0 -1
- package/dist/chunk-WOGURSAL.mjs.map +0 -1
- /package/dist/{chunk-ERXWDCY6.mjs.map → chunk-36MGCCPZ.mjs.map} +0 -0
- /package/dist/{chunk-UBNRUXEK.mjs.map → chunk-5BSUSFHM.mjs.map} +0 -0
- /package/dist/{chunk-JPMIAGI6.mjs.map → chunk-BVK7PLK6.mjs.map} +0 -0
- /package/dist/{chunk-FXK6RQIN.mjs.map → chunk-CUAFWKTQ.mjs.map} +0 -0
- /package/dist/{chunk-EF5BNM34.mjs.map → chunk-FN3UA2ZE.mjs.map} +0 -0
- /package/dist/{chunk-EXU7GWLC.mjs.map → chunk-GEE5AMYL.mjs.map} +0 -0
- /package/dist/{chunk-3YHYWAHK.mjs.map → chunk-KIXKBJUV.mjs.map} +0 -0
- /package/dist/{chunk-OF4SZTLL.mjs.map → chunk-NGQN3JRJ.mjs.map} +0 -0
- /package/dist/{chunk-SJJNFYGQ.mjs.map → chunk-SGF6C7I6.mjs.map} +0 -0
- /package/dist/{chunk-CMQV4XNY.mjs.map → chunk-VDADWRS3.mjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ForwardedParametersInput } from '@copilotkit/runtime-client-gql';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { f as AuthState } from '../../copilot-context-
|
|
4
|
-
import {
|
|
3
|
+
import { f as AuthState } from '../../copilot-context-3ab4fdf5.js';
|
|
4
|
+
import { CopilotErrorHandler } from '@copilotkit/shared';
|
|
5
5
|
import '../../types/frontend-action.js';
|
|
6
6
|
import '../../hooks/use-tree.js';
|
|
7
7
|
import '../../types/document-pointer.js';
|
|
@@ -63,11 +63,16 @@ interface CopilotKitProps {
|
|
|
63
63
|
*/
|
|
64
64
|
children: ReactNode;
|
|
65
65
|
/**
|
|
66
|
-
* Custom properties to be sent with the request
|
|
66
|
+
* Custom properties to be sent with the request.
|
|
67
|
+
* Can include threadMetadata for thread creation.
|
|
67
68
|
* For example:
|
|
68
69
|
* ```js
|
|
69
70
|
* {
|
|
70
71
|
* 'user_id': 'users_id',
|
|
72
|
+
* threadMetadata: {
|
|
73
|
+
* 'account_id': '123',
|
|
74
|
+
* 'user_type': 'premium'
|
|
75
|
+
* }
|
|
71
76
|
* }
|
|
72
77
|
* ```
|
|
73
78
|
*/
|
|
@@ -108,24 +113,24 @@ interface CopilotKitProps {
|
|
|
108
113
|
*/
|
|
109
114
|
threadId?: string;
|
|
110
115
|
/**
|
|
111
|
-
* Optional
|
|
116
|
+
* Optional error handler for comprehensive debugging and observability.
|
|
112
117
|
*
|
|
113
|
-
* **Requires publicApiKey**:
|
|
118
|
+
* **Requires publicApiKey**: Error handling only works when publicApiKey is provided.
|
|
114
119
|
* This is a premium CopilotKit Cloud feature.
|
|
115
120
|
*
|
|
116
|
-
* @param
|
|
121
|
+
* @param errorEvent - Structured error event with rich debugging context
|
|
117
122
|
*
|
|
118
123
|
* @example
|
|
119
124
|
* ```typescript
|
|
120
125
|
* <CopilotKit
|
|
121
126
|
* publicApiKey="ck_pub_your_key"
|
|
122
|
-
*
|
|
123
|
-
* debugDashboard.capture(
|
|
127
|
+
* onError={(errorEvent) => {
|
|
128
|
+
* debugDashboard.capture(errorEvent);
|
|
124
129
|
* }}
|
|
125
130
|
* >
|
|
126
131
|
* ```
|
|
127
132
|
*/
|
|
128
|
-
|
|
133
|
+
onError?: CopilotErrorHandler;
|
|
129
134
|
}
|
|
130
135
|
|
|
131
136
|
export { CopilotKitProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/copilot-provider/copilotkit-props.tsx"],"sourcesContent":["import { ForwardedParametersInput } from \"@copilotkit/runtime-client-gql\";\nimport { ReactNode } from \"react\";\nimport { AuthState } from \"../../context/copilot-context\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/copilot-provider/copilotkit-props.tsx"],"sourcesContent":["import { ForwardedParametersInput } from \"@copilotkit/runtime-client-gql\";\nimport { ReactNode } from \"react\";\nimport { AuthState } from \"../../context/copilot-context\";\nimport { CopilotErrorHandler } from \"@copilotkit/shared\";\n/**\n * Props for CopilotKit.\n */\n\nexport interface CopilotKitProps {\n /**\n * Your Copilot Cloud API key. Don't have it yet? Go to https://cloud.copilotkit.ai and get one for free.\n */\n publicApiKey?: string;\n\n /**\n * Restrict input to a specific topic.\n * @deprecated Use `guardrails_c` instead to control input restrictions\n */\n cloudRestrictToTopic?: {\n validTopics?: string[];\n invalidTopics?: string[];\n };\n\n /**\n * Restrict input to specific topics using guardrails.\n * @remarks\n *\n * This feature is only available when using CopilotKit's hosted cloud service. To use this feature, sign up at https://cloud.copilotkit.ai to get your publicApiKey. The feature allows restricting chat conversations to specific topics.\n */\n guardrails_c?: {\n validTopics?: string[];\n invalidTopics?: string[];\n };\n\n /**\n * The endpoint for the Copilot Runtime instance. [Click here for more information](/concepts/copilot-runtime).\n */\n runtimeUrl?: string;\n\n /**\n * The endpoint for the Copilot transcribe audio service.\n */\n transcribeAudioUrl?: string;\n\n /**\n * The endpoint for the Copilot text to speech service.\n */\n textToSpeechUrl?: string;\n\n /**\n * Additional headers to be sent with the request.\n *\n * For example:\n * ```json\n * {\n * \"Authorization\": \"Bearer X\"\n * }\n * ```\n */\n headers?: Record<string, string>;\n\n /**\n * The children to be rendered within the CopilotKit.\n */\n children: ReactNode;\n\n /**\n * Custom properties to be sent with the request.\n * Can include threadMetadata for thread creation.\n * For example:\n * ```js\n * {\n * 'user_id': 'users_id',\n * threadMetadata: {\n * 'account_id': '123',\n * 'user_type': 'premium'\n * }\n * }\n * ```\n */\n properties?: Record<string, any>;\n\n /**\n * Indicates whether the user agent should send or receive cookies from the other domain\n * in the case of cross-origin requests.\n */\n credentials?: RequestCredentials;\n\n /**\n * Whether to show the dev console.\n *\n * Set to `true` to show error banners and toasts, `false` to hide all error UI.\n * Defaults to `false` for production safety.\n */\n showDevConsole?: boolean;\n\n /**\n * The name of the agent to use.\n */\n agent?: string;\n\n /**\n * The forwarded parameters to use for the task.\n */\n forwardedParameters?: Pick<ForwardedParametersInput, \"temperature\">;\n\n /**\n * The auth config to use for the CopilotKit.\n * @remarks\n *\n * This feature is only available when using CopilotKit's hosted cloud service. To use this feature, sign up at https://cloud.copilotkit.ai to get your publicApiKey. The feature allows restricting chat conversations to specific topics.\n */\n authConfig_c?: {\n SignInComponent: React.ComponentType<{\n onSignInComplete: (authState: AuthState) => void;\n }>;\n };\n\n /**\n * The thread id to use for the CopilotKit.\n */\n threadId?: string;\n\n /**\n * Optional error handler for comprehensive debugging and observability.\n *\n * **Requires publicApiKey**: Error handling only works when publicApiKey is provided.\n * This is a premium CopilotKit Cloud feature.\n *\n * @param errorEvent - Structured error event with rich debugging context\n *\n * @example\n * ```typescript\n * <CopilotKit\n * publicApiKey=\"ck_pub_your_key\"\n * onError={(errorEvent) => {\n * debugDashboard.capture(errorEvent);\n * }}\n * >\n * ```\n */\n onError?: CopilotErrorHandler;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -2,7 +2,7 @@ import { CopilotKitProps } from './copilotkit-props.js';
|
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import '@copilotkit/runtime-client-gql';
|
|
4
4
|
import 'react';
|
|
5
|
-
import '../../copilot-context-
|
|
5
|
+
import '../../copilot-context-3ab4fdf5.js';
|
|
6
6
|
import '@copilotkit/shared';
|
|
7
7
|
import '../../types/frontend-action.js';
|
|
8
8
|
import '../../hooks/use-tree.js';
|
|
@@ -161,7 +161,7 @@ var emptyCopilotContext = {
|
|
|
161
161
|
langGraphInterruptAction: null,
|
|
162
162
|
setLangGraphInterruptAction: () => null,
|
|
163
163
|
removeLangGraphInterruptAction: () => null,
|
|
164
|
-
|
|
164
|
+
onError: void 0
|
|
165
165
|
};
|
|
166
166
|
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
167
167
|
function useCopilotContext() {
|
|
@@ -706,11 +706,11 @@ function CopilotMessages({ children }) {
|
|
|
706
706
|
const lastLoadedThreadId = (0, import_react6.useRef)();
|
|
707
707
|
const lastLoadedAgentName = (0, import_react6.useRef)();
|
|
708
708
|
const lastLoadedMessages = (0, import_react6.useRef)();
|
|
709
|
-
const { threadId, agentSession, runtimeClient, showDevConsole,
|
|
709
|
+
const { threadId, agentSession, runtimeClient, showDevConsole, onError, copilotApiConfig } = useCopilotContext();
|
|
710
710
|
const { setBannerError } = useToast();
|
|
711
711
|
const traceUIError = (0, import_react6.useCallback)(
|
|
712
712
|
(error, originalError) => __async(this, null, function* () {
|
|
713
|
-
if (!
|
|
713
|
+
if (!onError || !copilotApiConfig.publicApiKey)
|
|
714
714
|
return;
|
|
715
715
|
try {
|
|
716
716
|
const traceEvent = {
|
|
@@ -731,12 +731,12 @@ function CopilotMessages({ children }) {
|
|
|
731
731
|
},
|
|
732
732
|
error
|
|
733
733
|
};
|
|
734
|
-
yield
|
|
734
|
+
yield onError(traceEvent);
|
|
735
735
|
} catch (traceError) {
|
|
736
|
-
console.error("Error in CopilotMessages
|
|
736
|
+
console.error("Error in CopilotMessages onError handler:", traceError);
|
|
737
737
|
}
|
|
738
738
|
}),
|
|
739
|
-
[
|
|
739
|
+
[onError, copilotApiConfig.publicApiKey, copilotApiConfig.chatApiEndpoint]
|
|
740
740
|
);
|
|
741
741
|
const createStructuredError2 = (gqlError) => {
|
|
742
742
|
const extensions = gqlError.extensions;
|
|
@@ -841,7 +841,7 @@ function CopilotMessages({ children }) {
|
|
|
841
841
|
}
|
|
842
842
|
});
|
|
843
843
|
void fetchMessages();
|
|
844
|
-
}, [threadId, agentSession == null ? void 0 : agentSession.agentName
|
|
844
|
+
}, [threadId, agentSession == null ? void 0 : agentSession.agentName]);
|
|
845
845
|
const memoizedChildren = (0, import_react6.useMemo)(() => children, [children]);
|
|
846
846
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
847
847
|
CopilotMessagesContext.Provider,
|
|
@@ -861,13 +861,13 @@ var import_react7 = require("react");
|
|
|
861
861
|
var import_shared5 = require("@copilotkit/shared");
|
|
862
862
|
var useCopilotRuntimeClient = (options) => {
|
|
863
863
|
const { setBannerError } = useToast();
|
|
864
|
-
const _a = options, { showDevConsole,
|
|
864
|
+
const _a = options, { showDevConsole, onError } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onError"]);
|
|
865
865
|
const lastStructuredErrorRef = (0, import_react7.useRef)(null);
|
|
866
866
|
const traceUIError = (error, originalError) => __async(void 0, null, function* () {
|
|
867
|
-
if (!
|
|
867
|
+
if (!onError || !runtimeOptions.publicApiKey)
|
|
868
868
|
return;
|
|
869
869
|
try {
|
|
870
|
-
const
|
|
870
|
+
const errorEvent = {
|
|
871
871
|
type: "error",
|
|
872
872
|
timestamp: Date.now(),
|
|
873
873
|
context: {
|
|
@@ -885,9 +885,9 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
885
885
|
},
|
|
886
886
|
error
|
|
887
887
|
};
|
|
888
|
-
yield
|
|
889
|
-
} catch (
|
|
890
|
-
console.error("Error in
|
|
888
|
+
yield onError(errorEvent);
|
|
889
|
+
} catch (error2) {
|
|
890
|
+
console.error("Error in onError handler:", error2);
|
|
891
891
|
}
|
|
892
892
|
});
|
|
893
893
|
const runtimeClient = (0, import_react7.useMemo)(() => {
|
|
@@ -951,7 +951,7 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
951
951
|
setBannerError(warningError);
|
|
952
952
|
}
|
|
953
953
|
}));
|
|
954
|
-
}, [runtimeOptions, setBannerError, showDevConsole,
|
|
954
|
+
}, [runtimeOptions, setBannerError, showDevConsole, onError]);
|
|
955
955
|
return runtimeClient;
|
|
956
956
|
};
|
|
957
957
|
function createStructuredError(gqlError) {
|
|
@@ -1721,18 +1721,24 @@ ${nonDocumentStrings}`;
|
|
|
1721
1721
|
headers,
|
|
1722
1722
|
credentials: copilotApiConfig.credentials,
|
|
1723
1723
|
showDevConsole: (_b = props.showDevConsole) != null ? _b : false,
|
|
1724
|
-
|
|
1724
|
+
onError: props.onError
|
|
1725
1725
|
});
|
|
1726
1726
|
const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react10.useState)({});
|
|
1727
|
-
const addChatSuggestionConfiguration = (
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
setChatSuggestionConfiguration
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1727
|
+
const addChatSuggestionConfiguration = (0, import_react10.useCallback)(
|
|
1728
|
+
(id, suggestion) => {
|
|
1729
|
+
setChatSuggestionConfiguration((prev) => __spreadProps(__spreadValues({}, prev), { [id]: suggestion }));
|
|
1730
|
+
},
|
|
1731
|
+
[setChatSuggestionConfiguration]
|
|
1732
|
+
);
|
|
1733
|
+
const removeChatSuggestionConfiguration = (0, import_react10.useCallback)(
|
|
1734
|
+
(id) => {
|
|
1735
|
+
setChatSuggestionConfiguration((prev) => {
|
|
1736
|
+
const _a2 = prev, { [id]: _ } = _a2, rest = __objRest(_a2, [__restKey(id)]);
|
|
1737
|
+
return rest;
|
|
1738
|
+
});
|
|
1739
|
+
},
|
|
1740
|
+
[setChatSuggestionConfiguration]
|
|
1741
|
+
);
|
|
1736
1742
|
const [availableAgents, setAvailableAgents] = (0, import_react10.useState)([]);
|
|
1737
1743
|
const [coagentStates, setCoagentStates] = (0, import_react10.useState)({});
|
|
1738
1744
|
const coagentStatesRef = (0, import_react10.useRef)({});
|
|
@@ -1812,6 +1818,41 @@ ${nonDocumentStrings}`;
|
|
|
1812
1818
|
setLangGraphInterruptAction(null);
|
|
1813
1819
|
}, []);
|
|
1814
1820
|
const memoizedChildren = (0, import_react10.useMemo)(() => children, [children]);
|
|
1821
|
+
const agentLock = (0, import_react10.useMemo)(() => {
|
|
1822
|
+
var _a2;
|
|
1823
|
+
return (_a2 = props.agent) != null ? _a2 : null;
|
|
1824
|
+
}, [props.agent]);
|
|
1825
|
+
const forwardedParameters = (0, import_react10.useMemo)(
|
|
1826
|
+
() => {
|
|
1827
|
+
var _a2;
|
|
1828
|
+
return (_a2 = props.forwardedParameters) != null ? _a2 : {};
|
|
1829
|
+
},
|
|
1830
|
+
[props.forwardedParameters]
|
|
1831
|
+
);
|
|
1832
|
+
const updateExtensions = (0, import_react10.useCallback)(
|
|
1833
|
+
(newExtensions) => {
|
|
1834
|
+
setExtensions((prev) => {
|
|
1835
|
+
const resolved = typeof newExtensions === "function" ? newExtensions(prev) : newExtensions;
|
|
1836
|
+
const isSameLength = Object.keys(resolved).length === Object.keys(prev).length;
|
|
1837
|
+
const isEqual = isSameLength && // @ts-ignore
|
|
1838
|
+
Object.entries(resolved).every(([key, value]) => prev[key] === value);
|
|
1839
|
+
return isEqual ? prev : resolved;
|
|
1840
|
+
});
|
|
1841
|
+
},
|
|
1842
|
+
[setExtensions]
|
|
1843
|
+
);
|
|
1844
|
+
const updateAuthStates = (0, import_react10.useCallback)(
|
|
1845
|
+
(newAuthStates) => {
|
|
1846
|
+
setAuthStates((prev) => {
|
|
1847
|
+
const resolved = typeof newAuthStates === "function" ? newAuthStates(prev) : newAuthStates;
|
|
1848
|
+
const isSameLength = Object.keys(resolved).length === Object.keys(prev).length;
|
|
1849
|
+
const isEqual = isSameLength && // @ts-ignore
|
|
1850
|
+
Object.entries(resolved).every(([key, value]) => prev[key] === value);
|
|
1851
|
+
return isEqual ? prev : resolved;
|
|
1852
|
+
});
|
|
1853
|
+
},
|
|
1854
|
+
[setAuthStates]
|
|
1855
|
+
);
|
|
1815
1856
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1816
1857
|
CopilotContext.Provider,
|
|
1817
1858
|
{
|
|
@@ -1849,8 +1890,8 @@ ${nonDocumentStrings}`;
|
|
|
1849
1890
|
agentSession,
|
|
1850
1891
|
setAgentSession,
|
|
1851
1892
|
runtimeClient,
|
|
1852
|
-
forwardedParameters
|
|
1853
|
-
agentLock
|
|
1893
|
+
forwardedParameters,
|
|
1894
|
+
agentLock,
|
|
1854
1895
|
threadId: internalThreadId,
|
|
1855
1896
|
setThreadId,
|
|
1856
1897
|
runId,
|
|
@@ -1859,13 +1900,13 @@ ${nonDocumentStrings}`;
|
|
|
1859
1900
|
availableAgents,
|
|
1860
1901
|
authConfig_c: props.authConfig_c,
|
|
1861
1902
|
authStates_c: authStates,
|
|
1862
|
-
setAuthStates_c:
|
|
1903
|
+
setAuthStates_c: updateAuthStates,
|
|
1863
1904
|
extensions,
|
|
1864
|
-
setExtensions,
|
|
1905
|
+
setExtensions: updateExtensions,
|
|
1865
1906
|
langGraphInterruptAction,
|
|
1866
1907
|
setLangGraphInterruptAction,
|
|
1867
1908
|
removeLangGraphInterruptAction,
|
|
1868
|
-
|
|
1909
|
+
onError: props.onError
|
|
1869
1910
|
},
|
|
1870
1911
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children: memoizedChildren })
|
|
1871
1912
|
}
|