@copilotkit/react-core 1.9.3-next.4 → 1.10.0-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 +38 -0
- package/dist/chunk-2IDV5OHF.mjs +11 -0
- package/dist/chunk-2IDV5OHF.mjs.map +1 -0
- package/dist/{chunk-36MGCCPZ.mjs → chunk-4CFY3CON.mjs} +2 -2
- package/dist/{chunk-BVK7PLK6.mjs → chunk-DF4YG4PF.mjs} +2 -2
- package/dist/{chunk-ELU3VLPJ.mjs → chunk-G35QHAQ6.mjs} +8 -8
- package/dist/chunk-G35QHAQ6.mjs.map +1 -0
- package/dist/{chunk-DNHCRVE6.mjs → chunk-LIGLZ53V.mjs} +98 -26
- package/dist/chunk-LIGLZ53V.mjs.map +1 -0
- package/dist/{chunk-5BSUSFHM.mjs → chunk-LNAQ7JG3.mjs} +2 -2
- package/dist/{chunk-NJA5ZLAZ.mjs → chunk-LU5JPZ24.mjs} +2 -2
- package/dist/{chunk-GIMSRCVW.mjs → chunk-NAM55D5I.mjs} +153 -14
- package/dist/chunk-NAM55D5I.mjs.map +1 -0
- package/dist/{chunk-CUAFWKTQ.mjs → chunk-O5KV32S5.mjs} +4 -4
- package/dist/{chunk-FN3UA2ZE.mjs → chunk-PZXTDFMX.mjs} +3 -3
- package/dist/{chunk-VDADWRS3.mjs → chunk-Q6FZZJ5A.mjs} +2 -2
- package/dist/{chunk-KIXKBJUV.mjs → chunk-RGKZCCPA.mjs} +2 -2
- package/dist/{chunk-SGF6C7I6.mjs → chunk-SJJNFYGQ.mjs} +4 -4
- package/dist/{chunk-DKZTPL66.mjs → chunk-XGRBCWK6.mjs} +5 -2
- package/dist/chunk-XGRBCWK6.mjs.map +1 -0
- package/dist/{chunk-BSAVFYRQ.mjs → chunk-YBDRISKO.mjs} +5 -5
- package/dist/{chunk-QPX2JKOR.mjs → chunk-YSQ5I2AE.mjs} +6 -6
- package/dist/chunk-YSQ5I2AE.mjs.map +1 -0
- package/dist/{chunk-5B3NSTQK.mjs → chunk-YVBDAURK.mjs} +3 -3
- package/dist/components/copilot-provider/copilot-messages.js +4 -1
- 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 +2 -1
- package/dist/components/copilot-provider/copilotkit.d.ts +2 -1
- package/dist/components/copilot-provider/copilotkit.js +8 -2
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +10 -9
- package/dist/components/copilot-provider/index.d.ts +2 -1
- package/dist/components/copilot-provider/index.js +8 -2
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +10 -9
- package/dist/components/error-boundary/error-boundary.mjs +2 -2
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +8 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +10 -9
- package/dist/context/copilot-context.d.ts +2 -1
- package/dist/context/copilot-context.js +4 -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 +4 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +4 -4
- package/dist/{copilot-context-3ab4fdf5.d.ts → copilot-context-bd88d30d.d.ts} +21 -1
- package/dist/hooks/index.d.ts +5 -5
- package/dist/hooks/index.js +493 -154
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +32 -31
- package/dist/hooks/use-chat.d.ts +6 -1
- package/dist/hooks/use-chat.js +5 -2
- 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 +4 -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 +3 -3
- package/dist/hooks/use-coagent.js +427 -45
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +16 -14
- package/dist/hooks/use-copilot-action.js +4 -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 +4 -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 +4 -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.d.ts +43 -6
- package/dist/hooks/use-copilot-chat.js +443 -65
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +15 -13
- package/dist/hooks/use-copilot-readable.js +4 -1
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +2 -2
- package/dist/hooks/use-langgraph-interrupt-render.js +4 -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 +4 -3
- package/dist/hooks/use-langgraph-interrupt.js +452 -72
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +16 -14
- package/dist/hooks/use-make-copilot-document-readable.js +4 -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 +2 -1
- package/dist/index.js +422 -201
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -36
- package/dist/lib/copilot-task.d.ts +2 -1
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +12 -11
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +12 -11
- package/dist/types/interrupt-action.d.ts +3 -2
- package/dist/utils/extract.d.ts +1 -1
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +10 -9
- package/dist/utils/index.d.ts +4 -3
- package/dist/utils/index.js +144 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +16 -10
- package/dist/utils/suggestions-constants.d.ts +9 -0
- package/dist/utils/suggestions-constants.js +35 -0
- package/dist/utils/suggestions-constants.js.map +1 -0
- package/dist/utils/suggestions-constants.mjs +8 -0
- package/dist/utils/suggestions-constants.mjs.map +1 -0
- package/dist/utils/suggestions.d.ts +11 -0
- package/dist/utils/suggestions.js +343 -0
- package/dist/utils/suggestions.js.map +1 -0
- package/dist/utils/suggestions.mjs +22 -0
- package/dist/utils/suggestions.mjs.map +1 -0
- package/package.json +3 -3
- package/src/components/copilot-provider/copilotkit.tsx +4 -0
- package/src/context/copilot-context.tsx +6 -0
- package/src/hooks/use-chat.ts +6 -2
- package/src/hooks/use-coagent.ts +1 -1
- package/src/hooks/use-copilot-chat.ts +197 -21
- package/src/utils/index.ts +3 -0
- package/src/utils/suggestions-constants.ts +8 -0
- package/src/utils/suggestions.ts +208 -0
- package/dist/chunk-DKZTPL66.mjs.map +0 -1
- package/dist/chunk-DNHCRVE6.mjs.map +0 -1
- package/dist/chunk-ELU3VLPJ.mjs.map +0 -1
- package/dist/chunk-GIMSRCVW.mjs.map +0 -1
- package/dist/chunk-QPX2JKOR.mjs.map +0 -1
- /package/dist/{chunk-36MGCCPZ.mjs.map → chunk-4CFY3CON.mjs.map} +0 -0
- /package/dist/{chunk-BVK7PLK6.mjs.map → chunk-DF4YG4PF.mjs.map} +0 -0
- /package/dist/{chunk-5BSUSFHM.mjs.map → chunk-LNAQ7JG3.mjs.map} +0 -0
- /package/dist/{chunk-NJA5ZLAZ.mjs.map → chunk-LU5JPZ24.mjs.map} +0 -0
- /package/dist/{chunk-CUAFWKTQ.mjs.map → chunk-O5KV32S5.mjs.map} +0 -0
- /package/dist/{chunk-FN3UA2ZE.mjs.map → chunk-PZXTDFMX.mjs.map} +0 -0
- /package/dist/{chunk-VDADWRS3.mjs.map → chunk-Q6FZZJ5A.mjs.map} +0 -0
- /package/dist/{chunk-KIXKBJUV.mjs.map → chunk-RGKZCCPA.mjs.map} +0 -0
- /package/dist/{chunk-SGF6C7I6.mjs.map → chunk-SJJNFYGQ.mjs.map} +0 -0
- /package/dist/{chunk-BSAVFYRQ.mjs.map → chunk-YBDRISKO.mjs.map} +0 -0
- /package/dist/{chunk-5B3NSTQK.mjs.map → chunk-YVBDAURK.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
+
## 1.10.0-next.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8674da1: - refactor(headless): completely overhaul headless ui to better support agentic features
|
|
8
|
+
|
|
9
|
+
Headless UI has been in a bad state for a bit now. When we added support for different
|
|
10
|
+
agentic runtimes we acquired tech-debt that, with this PR, is being alleviated.
|
|
11
|
+
|
|
12
|
+
As such, the following features have been updated to be completely functional with Headless UI.
|
|
13
|
+
|
|
14
|
+
- Generative UI
|
|
15
|
+
- Suggestions
|
|
16
|
+
- Agentic Generative UI
|
|
17
|
+
- Interrupts
|
|
18
|
+
|
|
19
|
+
In addition, a variety of QOL changes have been made.
|
|
20
|
+
|
|
21
|
+
- New AG-UI based message types
|
|
22
|
+
- Inline code rendering is fixed
|
|
23
|
+
|
|
24
|
+
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [8674da1]
|
|
29
|
+
- @copilotkit/shared@1.10.0-next.0
|
|
30
|
+
- @copilotkit/runtime-client-gql@1.10.0-next.0
|
|
31
|
+
|
|
32
|
+
## 1.9.3
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- f83bda0: Fix: remote actions should never be executed to avoid duplicate result messages
|
|
37
|
+
- Updated dependencies [1bda332]
|
|
38
|
+
- @copilotkit/shared@1.9.3
|
|
39
|
+
- @copilotkit/runtime-client-gql@1.9.3
|
|
40
|
+
|
|
3
41
|
## 1.9.3-next.4
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/suggestions-constants.ts"],"sourcesContent":["/**\n * Constants for suggestions retry logic\n */\n\nexport const SUGGESTION_RETRY_CONFIG = {\n MAX_RETRIES: 3,\n COOLDOWN_MS: 5000, // 5 seconds\n} as const;\n"],"mappings":";AAIO,IAAM,0BAA0B;AAAA,EACrC,aAAa;AAAA,EACb,aAAa;AAAA;AACf;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XGRBCWK6.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-4CFY3CON.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XGRBCWK6.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-DF4YG4PF.mjs.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotChat
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LIGLZ53V.mjs";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
useCopilotMessagesContext
|
|
6
|
+
} from "./chunk-DCTJZ742.mjs";
|
|
7
7
|
import {
|
|
8
8
|
useAsyncCallback
|
|
9
9
|
} from "./chunk-3OQM3NEK.mjs";
|
|
10
|
+
import {
|
|
11
|
+
useCopilotRuntimeClient
|
|
12
|
+
} from "./chunk-JWAXDYOW.mjs";
|
|
10
13
|
import {
|
|
11
14
|
useToast
|
|
12
15
|
} from "./chunk-YAF2LATQ.mjs";
|
|
13
16
|
import {
|
|
14
17
|
useCopilotContext
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import {
|
|
17
|
-
useCopilotMessagesContext
|
|
18
|
-
} from "./chunk-DCTJZ742.mjs";
|
|
18
|
+
} from "./chunk-XGRBCWK6.mjs";
|
|
19
19
|
import {
|
|
20
20
|
__async,
|
|
21
21
|
__spreadProps,
|
|
@@ -236,4 +236,4 @@ export {
|
|
|
236
236
|
stopAgent,
|
|
237
237
|
runAgent
|
|
238
238
|
};
|
|
239
|
-
//# sourceMappingURL=chunk-
|
|
239
|
+
//# sourceMappingURL=chunk-G35QHAQ6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-coagent.ts"],"sourcesContent":["/**\n * <Callout type=\"info\">\n * Usage of this hook assumes some additional setup in your application, for more information\n * on that see the CoAgents <span className=\"text-blue-500\">[getting started guide](/coagents/quickstart/langgraph)</span>.\n * </Callout>\n * <Frame className=\"my-12\">\n * <img\n * src=\"/images/coagents/SharedStateCoAgents.gif\"\n * alt=\"CoAgents demonstration\"\n * className=\"w-auto\"\n * />\n * </Frame>\n *\n * This hook is used to integrate an agent into your application. With its use, you can\n * render and update the state of an agent, allowing for a dynamic and interactive experience.\n * We call these shared state experiences agentic copilots, or CoAgents for short.\n *\n * ## Usage\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCoAgent } from \"@copilotkit/react-core\";\n *\n * type AgentState = {\n * count: number;\n * }\n *\n * const agent = useCoAgent<AgentState>({\n * name: \"my-agent\",\n * initialState: {\n * count: 0,\n * },\n * });\n *\n * ```\n *\n * `useCoAgent` returns an object with the following properties:\n *\n * ```tsx\n * const {\n * name, // The name of the agent currently being used.\n * nodeName, // The name of the current LangGraph node.\n * state, // The current state of the agent.\n * setState, // A function to update the state of the agent.\n * running, // A boolean indicating if the agent is currently running.\n * start, // A function to start the agent.\n * stop, // A function to stop the agent.\n * run, // A function to re-run the agent. Takes a HintFunction to inform the agent why it is being re-run.\n * } = agent;\n * ```\n *\n * Finally we can leverage these properties to create reactive experiences with the agent!\n *\n * ```tsx\n * const { state, setState } = useCoAgent<AgentState>({\n * name: \"my-agent\",\n * initialState: {\n * count: 0,\n * },\n * });\n *\n * return (\n * <div>\n * <p>Count: {state.count}</p>\n * <button onClick={() => setState({ count: state.count + 1 })}>Increment</button>\n * </div>\n * );\n * ```\n *\n * This reactivity is bidirectional, meaning that changes to the state from the agent will be reflected in the UI and vice versa.\n *\n * ## Parameters\n * <PropertyReference name=\"options\" type=\"UseCoagentOptions<T>\" required>\n * The options to use when creating the coagent.\n * <PropertyReference name=\"name\" type=\"string\" required>\n * The name of the agent to use.\n * </PropertyReference>\n * <PropertyReference name=\"initialState\" type=\"T | any\">\n * The initial state of the agent.\n * </PropertyReference>\n * <PropertyReference name=\"state\" type=\"T | any\">\n * State to manage externally if you are using this hook with external state management.\n * </PropertyReference>\n * <PropertyReference name=\"setState\" type=\"(newState: T | ((prevState: T | undefined) => T)) => void\">\n * A function to update the state of the agent if you are using this hook with external state management.\n * </PropertyReference>\n * </PropertyReference>\n */\n\nimport { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport {\n CopilotContextParams,\n CopilotMessagesContextParams,\n useCopilotContext,\n useCopilotMessagesContext,\n} from \"../context\";\nimport { CoagentState } from \"../types/coagent-state\";\nimport { useCopilotChat } from \"./use-copilot-chat\";\nimport { Message } from \"@copilotkit/shared\";\nimport { useAsyncCallback } from \"../components/error-boundary/error-utils\";\nimport { useToast } from \"../components/toast/toast-provider\";\nimport { useCopilotRuntimeClient } from \"./use-copilot-runtime-client\";\nimport { parseJson, CopilotKitAgentDiscoveryError } from \"@copilotkit/shared\";\n\ninterface UseCoagentOptionsBase {\n /**\n * The name of the agent being used.\n */\n name: string;\n /**\n * @deprecated - use \"config.configurable\"\n * Config to pass to a LangGraph Agent\n */\n configurable?: Record<string, any>;\n /**\n * Config to pass to a LangGraph Agent\n */\n config?: {\n configurable?: Record<string, any>;\n [key: string]: any;\n };\n}\n\ninterface WithInternalStateManagementAndInitial<T> extends UseCoagentOptionsBase {\n /**\n * The initial state of the agent.\n */\n initialState: T;\n}\n\ninterface WithInternalStateManagement extends UseCoagentOptionsBase {\n /**\n * Optional initialState with default type any\n */\n initialState?: any;\n}\n\ninterface WithExternalStateManagement<T> extends UseCoagentOptionsBase {\n /**\n * The current state of the agent.\n */\n state: T;\n /**\n * A function to update the state of the agent.\n */\n setState: (newState: T | ((prevState: T | undefined) => T)) => void;\n}\n\ntype UseCoagentOptions<T> =\n | WithInternalStateManagementAndInitial<T>\n | WithInternalStateManagement\n | WithExternalStateManagement<T>;\n\nexport interface UseCoagentReturnType<T> {\n /**\n * The name of the agent being used.\n */\n name: string;\n /**\n * The name of the current LangGraph node.\n */\n nodeName?: string;\n /**\n * The ID of the thread the agent is running in.\n */\n threadId?: string;\n /**\n * A boolean indicating if the agent is currently running.\n */\n running: boolean;\n /**\n * The current state of the agent.\n */\n state: T;\n /**\n * A function to update the state of the agent.\n */\n setState: (newState: T | ((prevState: T | undefined) => T)) => void;\n /**\n * A function to start the agent.\n */\n start: () => void;\n /**\n * A function to stop the agent.\n */\n stop: () => void;\n /**\n * A function to re-run the agent. The hint function can be used to provide a hint to the agent\n * about why it is being re-run again.\n */\n run: (hint?: HintFunction) => Promise<void>;\n}\n\nexport interface HintFunctionParams {\n /**\n * The previous state of the agent.\n */\n previousState: any;\n /**\n * The current state of the agent.\n */\n currentState: any;\n}\n\nexport type HintFunction = (params: HintFunctionParams) => Message | undefined;\n\n/**\n * This hook is used to integrate an agent into your application. With its use, you can\n * render and update the state of the agent, allowing for a dynamic and interactive experience.\n * We call these shared state experiences \"agentic copilots\". To get started using agentic copilots, which\n * we refer to as CoAgents, checkout the documentation at https://docs.copilotkit.ai/coagents/quickstart/langgraph.\n */\nexport function useCoAgent<T = any>(options: UseCoagentOptions<T>): UseCoagentReturnType<T> {\n const generalContext = useCopilotContext();\n const { availableAgents } = generalContext;\n const { setBannerError } = useToast();\n const lastLoadedThreadId = useRef<string>();\n const lastLoadedState = useRef<any>();\n\n const { name } = options;\n useEffect(() => {\n if (availableAgents?.length && !availableAgents.some((a) => a.name === name)) {\n const message = `(useCoAgent): Agent \"${name}\" not found. Make sure the agent exists and is properly configured.`;\n console.warn(message);\n\n // Route to banner instead of toast for consistency\n const agentError = new CopilotKitAgentDiscoveryError({\n agentName: name,\n availableAgents: availableAgents.map((a) => ({ name: a.name, id: a.id })),\n });\n setBannerError(agentError);\n }\n }, [availableAgents]);\n\n const messagesContext = useCopilotMessagesContext();\n const context = { ...generalContext, ...messagesContext };\n const { coagentStates, coagentStatesRef, setCoagentStatesWithRef, threadId, copilotApiConfig } =\n context;\n const { appendMessage, runChatCompletion } = useCopilotChat();\n const headers = {\n ...(copilotApiConfig.headers || {}),\n };\n\n const runtimeClient = useCopilotRuntimeClient({\n url: copilotApiConfig.chatApiEndpoint,\n publicApiKey: copilotApiConfig.publicApiKey,\n headers,\n credentials: copilotApiConfig.credentials,\n showDevConsole: context.showDevConsole,\n });\n\n // if we manage state internally, we need to provide a function to set the state\n const setState = useCallback(\n (newState: T | ((prevState: T | undefined) => T)) => {\n // coagentStatesRef.current || {}\n let coagentState: CoagentState = getCoagentState({ coagentStates, name, options });\n const updatedState =\n typeof newState === \"function\" ? (newState as Function)(coagentState.state) : newState;\n\n setCoagentStatesWithRef({\n ...coagentStatesRef.current,\n [name]: {\n ...coagentState,\n state: updatedState,\n },\n });\n },\n [coagentStates, name],\n );\n\n useEffect(() => {\n const fetchAgentState = async () => {\n if (!threadId || threadId === lastLoadedThreadId.current) return;\n\n const result = await runtimeClient.loadAgentState({\n threadId,\n agentName: name,\n });\n\n // Runtime client handles errors automatically via handleGQLErrors\n if (result.error) {\n return; // Don't process data on error\n }\n\n const newState = result.data?.loadAgentState?.state;\n if (newState === lastLoadedState.current) return;\n\n if (result.data?.loadAgentState?.threadExists && newState && newState != \"{}\") {\n lastLoadedState.current = newState;\n lastLoadedThreadId.current = threadId;\n const fetchedState = parseJson(newState, {});\n isExternalStateManagement(options)\n ? options.setState(fetchedState)\n : setState(fetchedState);\n }\n };\n void fetchAgentState();\n }, [threadId]);\n\n // Sync internal state with external state if state management is external\n useEffect(() => {\n if (isExternalStateManagement(options)) {\n setState(options.state);\n } else if (coagentStates[name] === undefined) {\n setState(options.initialState === undefined ? {} : options.initialState);\n }\n }, [\n isExternalStateManagement(options) ? JSON.stringify(options.state) : undefined,\n // reset initialstate on reset\n coagentStates[name] === undefined,\n ]);\n\n // Sync config when runtime configuration changes\n useEffect(() => {\n const newConfig = options.config\n ? options.config\n : options.configurable\n ? { configurable: options.configurable }\n : undefined;\n\n if (newConfig === undefined) return;\n\n setCoagentStatesWithRef((prev) => {\n const existing = prev[name] ?? {\n name,\n state: isInternalStateManagementWithInitial(options) ? options.initialState : {},\n config: {},\n running: false,\n active: false,\n threadId: undefined,\n nodeName: undefined,\n runId: undefined,\n };\n\n if (JSON.stringify(existing.config) === JSON.stringify(newConfig)) {\n return prev;\n }\n\n return {\n ...prev,\n [name]: {\n ...existing,\n config: newConfig,\n },\n };\n });\n }, [JSON.stringify(options.config), JSON.stringify(options.configurable)]);\n\n const runAgentCallback = useAsyncCallback(\n async (hint?: HintFunction) => {\n await runAgent(name, context, appendMessage, runChatCompletion, hint);\n },\n [name, context, appendMessage, runChatCompletion],\n );\n\n // Return the state and setState function\n return useMemo(() => {\n const coagentState = getCoagentState({ coagentStates, name, options });\n return {\n name,\n nodeName: coagentState.nodeName,\n threadId: coagentState.threadId,\n running: coagentState.running,\n state: coagentState.state,\n setState: isExternalStateManagement(options) ? options.setState : setState,\n start: () => startAgent(name, context),\n stop: () => stopAgent(name, context),\n run: runAgentCallback,\n };\n }, [name, coagentStates, options, setState, runAgentCallback]);\n}\n\nexport function startAgent(name: string, context: CopilotContextParams) {\n const { setAgentSession } = context;\n setAgentSession({\n agentName: name,\n });\n}\n\nexport function stopAgent(name: string, context: CopilotContextParams) {\n const { agentSession, setAgentSession } = context;\n if (agentSession && agentSession.agentName === name) {\n setAgentSession(null);\n context.setCoagentStates((prevAgentStates) => {\n return {\n ...prevAgentStates,\n [name]: {\n ...prevAgentStates[name],\n running: false,\n active: false,\n threadId: undefined,\n nodeName: undefined,\n runId: undefined,\n },\n };\n });\n } else {\n console.warn(`No agent session found for ${name}`);\n }\n}\n\nexport async function runAgent(\n name: string,\n context: CopilotContextParams & CopilotMessagesContextParams,\n appendMessage: (message: Message) => Promise<void>,\n runChatCompletion: () => Promise<Message[]>,\n hint?: HintFunction,\n) {\n const { agentSession, setAgentSession } = context;\n if (!agentSession || agentSession.agentName !== name) {\n setAgentSession({\n agentName: name,\n });\n }\n\n let previousState: any = null;\n for (let i = context.messages.length - 1; i >= 0; i--) {\n const message = context.messages[i];\n if (message.isAgentStateMessage() && message.agentName === name) {\n previousState = message.state;\n }\n }\n\n let state = context.coagentStatesRef.current?.[name]?.state || {};\n\n if (hint) {\n const hintMessage = hint({ previousState, currentState: state });\n if (hintMessage) {\n await appendMessage(hintMessage);\n } else {\n await runChatCompletion();\n }\n } else {\n await runChatCompletion();\n }\n}\n\nconst isExternalStateManagement = <T>(\n options: UseCoagentOptions<T>,\n): options is WithExternalStateManagement<T> => {\n return \"state\" in options && \"setState\" in options;\n};\n\nconst isInternalStateManagementWithInitial = <T>(\n options: UseCoagentOptions<T>,\n): options is WithInternalStateManagementAndInitial<T> => {\n return \"initialState\" in options;\n};\n\nconst getCoagentState = <T>({\n coagentStates,\n name,\n options,\n}: {\n coagentStates: Record<string, CoagentState>;\n name: string;\n options: UseCoagentOptions<T>;\n}) => {\n if (coagentStates[name]) {\n return coagentStates[name];\n } else {\n return {\n name,\n state: isInternalStateManagementWithInitial<T>(options) ? options.initialState : {},\n config: options.config\n ? options.config\n : options.configurable\n ? { configurable: options.configurable }\n : {},\n running: false,\n active: false,\n threadId: undefined,\n nodeName: undefined,\n runId: undefined,\n };\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0FA,SAAS,aAAa,WAAW,SAAS,cAAc;AAaxD,SAAS,WAAW,qCAAqC;AA8GlD,SAAS,WAAoB,SAAwD;AAC1F,QAAM,iBAAiB,kBAAkB;AACzC,QAAM,EAAE,gBAAgB,IAAI;AAC5B,QAAM,EAAE,eAAe,IAAI,SAAS;AACpC,QAAM,qBAAqB,OAAe;AAC1C,QAAM,kBAAkB,OAAY;AAEpC,QAAM,EAAE,KAAK,IAAI;AACjB,YAAU,MAAM;AACd,SAAI,mDAAiB,WAAU,CAAC,gBAAgB,KAAK,CAAC,MAAM,EAAE,SAAS,IAAI,GAAG;AAC5E,YAAM,UAAU,wBAAwB;AACxC,cAAQ,KAAK,OAAO;AAGpB,YAAM,aAAa,IAAI,8BAA8B;AAAA,QACnD,WAAW;AAAA,QACX,iBAAiB,gBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE,GAAG,EAAE;AAAA,MAC1E,CAAC;AACD,qBAAe,UAAU;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,eAAe,CAAC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InterruptRender
|
|
3
|
+
} from "./chunk-Q6FZZJ5A.mjs";
|
|
4
|
+
import {
|
|
5
|
+
defaultCopilotContextCategories,
|
|
6
|
+
reloadSuggestions
|
|
7
|
+
} from "./chunk-NAM55D5I.mjs";
|
|
8
|
+
import {
|
|
9
|
+
useCopilotMessagesContext
|
|
10
|
+
} from "./chunk-DCTJZ742.mjs";
|
|
4
11
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
12
|
+
useChat
|
|
13
|
+
} from "./chunk-YSQ5I2AE.mjs";
|
|
7
14
|
import {
|
|
8
15
|
useAsyncCallback
|
|
9
16
|
} from "./chunk-3OQM3NEK.mjs";
|
|
10
17
|
import {
|
|
11
18
|
useCopilotContext
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import {
|
|
14
|
-
useCopilotMessagesContext
|
|
15
|
-
} from "./chunk-DCTJZ742.mjs";
|
|
19
|
+
} from "./chunk-XGRBCWK6.mjs";
|
|
16
20
|
import {
|
|
17
21
|
__async,
|
|
18
|
-
__objRest,
|
|
19
22
|
__spreadProps,
|
|
20
23
|
__spreadValues
|
|
21
24
|
} from "./chunk-SKC7AJIV.mjs";
|
|
22
25
|
|
|
23
26
|
// src/hooks/use-copilot-chat.ts
|
|
24
|
-
import { useRef, useEffect, useCallback, useState } from "react";
|
|
25
|
-
import { Role, TextMessage } from "@copilotkit/runtime-client-gql";
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"makeSystemMessage"
|
|
31
|
-
]);
|
|
27
|
+
import { useRef, useEffect, useCallback, useState, useMemo } from "react";
|
|
28
|
+
import { Role as gqlRole, TextMessage, aguiToGQL, gqlToAGUI } from "@copilotkit/runtime-client-gql";
|
|
29
|
+
var globalSuggestionPromise = null;
|
|
30
|
+
function useCopilotChat(options = {}) {
|
|
31
|
+
var _a;
|
|
32
|
+
const makeSystemMessage = (_a = options.makeSystemMessage) != null ? _a : defaultSystemMessage;
|
|
32
33
|
const {
|
|
33
34
|
getContextString,
|
|
34
35
|
getFunctionCallHandler,
|
|
@@ -52,10 +53,71 @@ function useCopilotChat(_a = {}) {
|
|
|
52
53
|
extensions,
|
|
53
54
|
setExtensions,
|
|
54
55
|
langGraphInterruptAction,
|
|
55
|
-
setLangGraphInterruptAction
|
|
56
|
+
setLangGraphInterruptAction,
|
|
57
|
+
chatSuggestionConfiguration,
|
|
58
|
+
suggestions,
|
|
59
|
+
setSuggestions,
|
|
60
|
+
runtimeClient
|
|
56
61
|
} = useCopilotContext();
|
|
57
62
|
const { messages, setMessages } = useCopilotMessagesContext();
|
|
58
63
|
const [mcpServers, setLocalMcpServers] = useState([]);
|
|
64
|
+
const suggestionsAbortControllerRef = useRef(null);
|
|
65
|
+
const isLoadingSuggestionsRef = useRef(false);
|
|
66
|
+
const abortSuggestions = useCallback(
|
|
67
|
+
(clear = true) => {
|
|
68
|
+
var _a2;
|
|
69
|
+
(_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort("suggestions aborted by user");
|
|
70
|
+
suggestionsAbortControllerRef.current = null;
|
|
71
|
+
if (clear) {
|
|
72
|
+
setSuggestions([]);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
[setSuggestions]
|
|
76
|
+
);
|
|
77
|
+
const stableContext = useMemo(() => {
|
|
78
|
+
return {
|
|
79
|
+
actions,
|
|
80
|
+
copilotApiConfig,
|
|
81
|
+
chatSuggestionConfiguration,
|
|
82
|
+
messages,
|
|
83
|
+
setMessages,
|
|
84
|
+
getContextString,
|
|
85
|
+
runtimeClient
|
|
86
|
+
};
|
|
87
|
+
}, [
|
|
88
|
+
JSON.stringify(Object.keys(actions)),
|
|
89
|
+
copilotApiConfig.chatApiEndpoint,
|
|
90
|
+
messages.length,
|
|
91
|
+
Object.keys(chatSuggestionConfiguration).length
|
|
92
|
+
]);
|
|
93
|
+
const generateSuggestionsFunc = useCallback(() => __async(this, null, function* () {
|
|
94
|
+
if (globalSuggestionPromise) {
|
|
95
|
+
return globalSuggestionPromise;
|
|
96
|
+
}
|
|
97
|
+
globalSuggestionPromise = (() => __async(this, null, function* () {
|
|
98
|
+
try {
|
|
99
|
+
abortSuggestions();
|
|
100
|
+
isLoadingSuggestionsRef.current = true;
|
|
101
|
+
suggestionsAbortControllerRef.current = new AbortController();
|
|
102
|
+
setSuggestions([]);
|
|
103
|
+
yield reloadSuggestions(
|
|
104
|
+
stableContext,
|
|
105
|
+
chatSuggestionConfiguration,
|
|
106
|
+
setSuggestions,
|
|
107
|
+
suggestionsAbortControllerRef
|
|
108
|
+
);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
throw error;
|
|
111
|
+
} finally {
|
|
112
|
+
isLoadingSuggestionsRef.current = false;
|
|
113
|
+
globalSuggestionPromise = null;
|
|
114
|
+
}
|
|
115
|
+
}))();
|
|
116
|
+
return globalSuggestionPromise;
|
|
117
|
+
}), [stableContext, chatSuggestionConfiguration, setSuggestions, abortSuggestions]);
|
|
118
|
+
const resetSuggestions = useCallback(() => {
|
|
119
|
+
setSuggestions([]);
|
|
120
|
+
}, [setSuggestions]);
|
|
59
121
|
useEffect(() => {
|
|
60
122
|
if (mcpServers.length > 0) {
|
|
61
123
|
const serversCopy = [...mcpServers];
|
|
@@ -92,7 +154,7 @@ function useCopilotChat(_a = {}) {
|
|
|
92
154
|
const contextString = getContextString([], defaultCopilotContextCategories);
|
|
93
155
|
return new TextMessage({
|
|
94
156
|
content: systemMessageMaker(contextString, chatInstructions),
|
|
95
|
-
role:
|
|
157
|
+
role: gqlRole.System
|
|
96
158
|
});
|
|
97
159
|
}, [getContextString, makeSystemMessage, chatInstructions]);
|
|
98
160
|
const deleteMessage = useCallback(
|
|
@@ -104,7 +166,7 @@ function useCopilotChat(_a = {}) {
|
|
|
104
166
|
const { append, reload, stop, runChatCompletion } = useChat(__spreadProps(__spreadValues({}, options), {
|
|
105
167
|
actions: Object.values(actions),
|
|
106
168
|
copilotConfig: copilotApiConfig,
|
|
107
|
-
initialMessages: options.initialMessages || [],
|
|
169
|
+
initialMessages: aguiToGQL(options.initialMessages || []),
|
|
108
170
|
onFunctionCall: getFunctionCallHandler(),
|
|
109
171
|
onCoAgentStateRender,
|
|
110
172
|
messages,
|
|
@@ -131,7 +193,8 @@ function useCopilotChat(_a = {}) {
|
|
|
131
193
|
const latestAppend = useUpdatedRef(append);
|
|
132
194
|
const latestAppendFunc = useAsyncCallback(
|
|
133
195
|
(message, options2) => __async(this, null, function* () {
|
|
134
|
-
|
|
196
|
+
abortSuggestions(options2 == null ? void 0 : options2.clearSuggestions);
|
|
197
|
+
return yield latestAppend.current(aguiToGQL([message])[0], options2);
|
|
135
198
|
}),
|
|
136
199
|
[latestAppend]
|
|
137
200
|
);
|
|
@@ -156,7 +219,7 @@ function useCopilotChat(_a = {}) {
|
|
|
156
219
|
const latestSetMessages = useUpdatedRef(setMessages);
|
|
157
220
|
const latestSetMessagesFunc = useCallback(
|
|
158
221
|
(messages2) => {
|
|
159
|
-
return latestSetMessages.current(messages2);
|
|
222
|
+
return latestSetMessages.current(aguiToGQL(messages2));
|
|
160
223
|
},
|
|
161
224
|
[latestSetMessages]
|
|
162
225
|
);
|
|
@@ -176,20 +239,23 @@ function useCopilotChat(_a = {}) {
|
|
|
176
239
|
};
|
|
177
240
|
}
|
|
178
241
|
setAgentSession(initialAgentSession);
|
|
242
|
+
resetSuggestions();
|
|
179
243
|
}, [
|
|
180
244
|
latestStopFunc,
|
|
181
245
|
setMessages,
|
|
182
246
|
setThreadId,
|
|
183
247
|
setCoagentStatesWithRef,
|
|
184
248
|
setAgentSession,
|
|
185
|
-
agentLock
|
|
249
|
+
agentLock,
|
|
250
|
+
resetSuggestions
|
|
186
251
|
]);
|
|
187
252
|
const latestReset = useUpdatedRef(reset);
|
|
188
253
|
const latestResetFunc = useCallback(() => {
|
|
189
254
|
return latestReset.current();
|
|
190
255
|
}, [latestReset]);
|
|
256
|
+
const interrupt = useLangGraphInterruptRender();
|
|
191
257
|
return {
|
|
192
|
-
visibleMessages: messages,
|
|
258
|
+
visibleMessages: gqlToAGUI(messages, actions, coAgentStateRenders),
|
|
193
259
|
appendMessage: latestAppendFunc,
|
|
194
260
|
setMessages: latestSetMessagesFunc,
|
|
195
261
|
reloadMessages: latestReloadFunc,
|
|
@@ -199,7 +265,13 @@ function useCopilotChat(_a = {}) {
|
|
|
199
265
|
runChatCompletion: latestRunChatCompletionFunc,
|
|
200
266
|
isLoading,
|
|
201
267
|
mcpServers,
|
|
202
|
-
setMcpServers
|
|
268
|
+
setMcpServers,
|
|
269
|
+
suggestions,
|
|
270
|
+
setSuggestions,
|
|
271
|
+
generateSuggestions: generateSuggestionsFunc,
|
|
272
|
+
resetSuggestions,
|
|
273
|
+
isLoadingSuggestions: isLoadingSuggestionsRef.current,
|
|
274
|
+
interrupt
|
|
203
275
|
};
|
|
204
276
|
}
|
|
205
277
|
function useUpdatedRef(value) {
|
|
@@ -240,4 +312,4 @@ export {
|
|
|
240
312
|
useCopilotChat,
|
|
241
313
|
defaultSystemMessage
|
|
242
314
|
};
|
|
243
|
-
//# sourceMappingURL=chunk-
|
|
315
|
+
//# sourceMappingURL=chunk-LIGLZ53V.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-copilot-chat.ts"],"sourcesContent":["/**\n * `useCopilotChat` is a React hook that lets you directly interact with the\n * Copilot instance. Use to implement a fully custom UI (headless UI) or to\n * programmatically interact with the Copilot instance managed by the default\n * UI.\n *\n * ## Usage\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCopilotChat } from \"@copilotkit/react-core\";\n * import { Role, TextMessage } from \"@copilotkit/runtime-client-gql\";\n *\n * export function YourComponent() {\n * const { appendMessage } = useCopilotChat();\n *\n * appendMessage(\n * new TextMessage({\n * content: \"Hello World\",\n * role: Role.User,\n * }),\n * );\n *\n * // optionally, you can append a message without running chat completion\n * appendMessage(yourMessage, { followUp: false });\n * }\n * ```\n *\n * ### Working with Suggestions\n *\n * ```tsx\n * import { useCopilotChat, useCopilotChatSuggestions } from \"@copilotkit/react-core\";\n *\n * export function YourComponent() {\n * const {\n * suggestions,\n * setSuggestions,\n * generateSuggestions,\n * isLoadingSuggestions\n * } = useCopilotChat();\n *\n * // Configure AI suggestion generation\n * useCopilotChatSuggestions({\n * instructions: \"Suggest helpful actions based on the current context\",\n * maxSuggestions: 3\n * });\n *\n * // Manual suggestion control\n * const handleCustomSuggestion = () => {\n * setSuggestions([{ title: \"Custom Action\", message: \"Perform custom action\" }]);\n * };\n *\n * // Trigger AI generation\n * const handleGenerateSuggestions = async () => {\n * await generateSuggestions();\n * };\n * }\n * ```\n *\n * `useCopilotChat` returns an object with the following properties:\n *\n * ```tsx\n * const {\n * visibleMessages, // An array of messages that are currently visible in the chat.\n * appendMessage, // A function to append a message to the chat.\n * setMessages, // A function to set the messages in the chat.\n * deleteMessage, // A function to delete a message from the chat.\n * reloadMessages, // A function to reload the messages from the API.\n * stopGeneration, // A function to stop the generation of the next message.\n * reset, // A function to reset the chat.\n * isLoading, // A boolean indicating if the chat is loading.\n *\n * // Suggestion control (headless UI)\n * suggestions, // Current suggestions array\n * setSuggestions, // Manually set suggestions\n * generateSuggestions, // Trigger AI suggestion generation\n * resetSuggestions, // Clear all suggestions\n * isLoadingSuggestions, // Whether suggestions are being generated\n * } = useCopilotChat();\n * ```\n */\nimport { useRef, useEffect, useCallback, useState, useMemo } from \"react\";\nimport { AgentSession, useCopilotContext, CopilotContextParams } from \"../context/copilot-context\";\nimport { useCopilotMessagesContext, CopilotMessagesContextParams } from \"../context\";\nimport { SystemMessageFunction } from \"../types\";\nimport { useChat, AppendMessageOptions } from \"./use-chat\";\nimport { defaultCopilotContextCategories } from \"../components\";\nimport { CoAgentStateRenderHandlerArguments } from \"@copilotkit/shared\";\nimport { useAsyncCallback } from \"../components/error-boundary/error-utils\";\nimport { reloadSuggestions as generateSuggestions } from \"../utils\";\nimport type { SuggestionItem } from \"../utils\";\n\nimport { Message } from \"@copilotkit/shared\";\nimport { Role as gqlRole, TextMessage, aguiToGQL, gqlToAGUI } from \"@copilotkit/runtime-client-gql\";\nimport { useLangGraphInterruptRender } from \"./use-langgraph-interrupt-render\";\n\nexport interface UseCopilotChatOptions {\n /**\n * A unique identifier for the chat. If not provided, a random one will be\n * generated. When provided, the `useChat` hook with the same `id` will\n * have shared states across components.\n */\n id?: string;\n\n /**\n * HTTP headers to be sent with the API request.\n */\n headers?: Record<string, string> | Headers;\n\n /**\n * Initial messages to populate the chat with.\n */\n initialMessages?: Message[];\n\n /**\n * A function to generate the system message. Defaults to `defaultSystemMessage`.\n */\n makeSystemMessage?: SystemMessageFunction;\n}\n\nexport interface MCPServerConfig {\n endpoint: string;\n apiKey?: string;\n}\n\nexport interface UseCopilotChatReturn {\n /** Array of messages currently visible in the chat interface */\n visibleMessages: Message[];\n\n /** Send a new message to the chat */\n appendMessage: (message: Message, options?: AppendMessageOptions) => Promise<void>;\n\n /** Replace all messages in the chat */\n setMessages: (messages: Message[]) => void;\n\n /** Remove a specific message by ID */\n deleteMessage: (messageId: string) => void;\n\n /** Regenerate the response for a specific message */\n reloadMessages: (messageId: string) => Promise<void>;\n\n /** Stop the current message generation */\n stopGeneration: () => void;\n\n /** Clear all messages and reset chat state */\n reset: () => void;\n\n /** Whether the chat is currently generating a response */\n isLoading: boolean;\n\n /** Manually trigger chat completion (advanced usage) */\n runChatCompletion: () => Promise<Message[]>;\n\n /** MCP (Model Context Protocol) server configurations */\n mcpServers: MCPServerConfig[];\n\n /** Update MCP server configurations */\n setMcpServers: (mcpServers: MCPServerConfig[]) => void;\n\n /**\n * Current suggestions array\n * Use this to read the current suggestions or in conjunction with setSuggestions for manual control\n */\n suggestions: SuggestionItem[];\n\n /**\n * Manually set suggestions\n * Useful for manual mode or custom suggestion workflows\n */\n setSuggestions: (suggestions: SuggestionItem[]) => void;\n\n /**\n * Trigger AI-powered suggestion generation\n * Uses configurations from useCopilotChatSuggestions hooks\n * Respects global debouncing - only one generation can run at a time\n */\n generateSuggestions: () => Promise<void>;\n\n /**\n * Clear all current suggestions\n * Also resets suggestion generation state\n */\n resetSuggestions: () => void;\n\n /** Whether suggestions are currently being generated */\n isLoadingSuggestions: boolean;\n\n /** Interrupt content for human-in-the-loop workflows */\n interrupt: string | React.ReactElement | null;\n}\n\nlet globalSuggestionPromise: Promise<void> | null = null;\n\nexport function useCopilotChat(options: UseCopilotChatOptions = {}): UseCopilotChatReturn {\n const makeSystemMessage = options.makeSystemMessage ?? defaultSystemMessage;\n const {\n getContextString,\n getFunctionCallHandler,\n copilotApiConfig,\n isLoading,\n setIsLoading,\n chatInstructions,\n actions,\n coagentStatesRef,\n setCoagentStatesWithRef,\n coAgentStateRenders,\n agentSession,\n setAgentSession,\n forwardedParameters,\n agentLock,\n threadId,\n setThreadId,\n runId,\n setRunId,\n chatAbortControllerRef,\n extensions,\n setExtensions,\n langGraphInterruptAction,\n setLangGraphInterruptAction,\n chatSuggestionConfiguration,\n suggestions,\n setSuggestions,\n runtimeClient,\n } = useCopilotContext();\n const { messages, setMessages } = useCopilotMessagesContext();\n\n // Simple state for MCP servers (keep for interface compatibility)\n const [mcpServers, setLocalMcpServers] = useState<MCPServerConfig[]>([]);\n\n // Basic suggestion state for programmatic control\n const suggestionsAbortControllerRef = useRef<AbortController | null>(null);\n const isLoadingSuggestionsRef = useRef<boolean>(false);\n\n const abortSuggestions = useCallback(\n (clear: boolean = true) => {\n suggestionsAbortControllerRef.current?.abort(\"suggestions aborted by user\");\n suggestionsAbortControllerRef.current = null;\n if (clear) {\n setSuggestions([]);\n }\n },\n [setSuggestions],\n );\n\n // Memoize context with stable dependencies only\n const stableContext = useMemo(() => {\n return {\n actions,\n copilotApiConfig,\n chatSuggestionConfiguration,\n messages,\n setMessages,\n getContextString,\n runtimeClient,\n };\n }, [\n JSON.stringify(Object.keys(actions)),\n copilotApiConfig.chatApiEndpoint,\n messages.length,\n Object.keys(chatSuggestionConfiguration).length,\n ]);\n\n // Programmatic suggestion generation function\n const generateSuggestionsFunc = useCallback(async () => {\n // If a global suggestion is running, ignore this call\n if (globalSuggestionPromise) {\n return globalSuggestionPromise;\n }\n\n globalSuggestionPromise = (async () => {\n try {\n abortSuggestions();\n isLoadingSuggestionsRef.current = true;\n suggestionsAbortControllerRef.current = new AbortController();\n\n setSuggestions([]);\n\n await generateSuggestions(\n stableContext as CopilotContextParams & CopilotMessagesContextParams,\n chatSuggestionConfiguration,\n setSuggestions,\n suggestionsAbortControllerRef,\n );\n } catch (error) {\n // Re-throw to allow caller to handle the error\n throw error;\n } finally {\n isLoadingSuggestionsRef.current = false;\n globalSuggestionPromise = null;\n }\n })();\n\n return globalSuggestionPromise;\n }, [stableContext, chatSuggestionConfiguration, setSuggestions, abortSuggestions]);\n\n const resetSuggestions = useCallback(() => {\n setSuggestions([]);\n }, [setSuggestions]);\n\n // MCP servers logic\n useEffect(() => {\n if (mcpServers.length > 0) {\n const serversCopy = [...mcpServers];\n copilotApiConfig.mcpServers = serversCopy;\n if (!copilotApiConfig.properties) {\n copilotApiConfig.properties = {};\n }\n copilotApiConfig.properties.mcpServers = serversCopy;\n }\n }, [mcpServers, copilotApiConfig]);\n\n const setMcpServers = useCallback((servers: MCPServerConfig[]) => {\n setLocalMcpServers(servers);\n }, []);\n\n // Move these function declarations above the useChat call\n const onCoAgentStateRender = useAsyncCallback(\n async (args: CoAgentStateRenderHandlerArguments) => {\n const { name, nodeName, state } = args;\n let action = Object.values(coAgentStateRenders).find(\n (action) => action.name === name && action.nodeName === nodeName,\n );\n if (!action) {\n action = Object.values(coAgentStateRenders).find(\n (action) => action.name === name && !action.nodeName,\n );\n }\n if (action) {\n await action.handler?.({ state, nodeName });\n }\n },\n [coAgentStateRenders],\n );\n\n const makeSystemMessageCallback = useCallback(() => {\n const systemMessageMaker = makeSystemMessage || defaultSystemMessage;\n // this always gets the latest context string\n const contextString = getContextString([], defaultCopilotContextCategories); // TODO: make the context categories configurable\n\n return new TextMessage({\n content: systemMessageMaker(contextString, chatInstructions),\n role: gqlRole.System,\n });\n }, [getContextString, makeSystemMessage, chatInstructions]);\n\n const deleteMessage = useCallback(\n (messageId: string) => {\n setMessages((prev) => prev.filter((message) => message.id !== messageId));\n },\n [setMessages],\n );\n\n // Get chat helpers with updated config\n const { append, reload, stop, runChatCompletion } = useChat({\n ...options,\n actions: Object.values(actions),\n copilotConfig: copilotApiConfig,\n initialMessages: aguiToGQL(options.initialMessages || []),\n onFunctionCall: getFunctionCallHandler(),\n onCoAgentStateRender,\n messages,\n setMessages,\n makeSystemMessageCallback,\n isLoading,\n setIsLoading,\n coagentStatesRef,\n setCoagentStatesWithRef,\n agentSession,\n setAgentSession,\n forwardedParameters,\n threadId,\n setThreadId,\n runId,\n setRunId,\n chatAbortControllerRef,\n agentLock,\n extensions,\n setExtensions,\n langGraphInterruptAction,\n setLangGraphInterruptAction,\n });\n\n const latestAppend = useUpdatedRef(append);\n const latestAppendFunc = useAsyncCallback(\n async (message: Message, options?: AppendMessageOptions) => {\n abortSuggestions(options?.clearSuggestions);\n return await latestAppend.current(aguiToGQL([message])[0], options);\n },\n [latestAppend],\n );\n\n const latestReload = useUpdatedRef(reload);\n const latestReloadFunc = useAsyncCallback(\n async (messageId: string) => {\n return await latestReload.current(messageId);\n },\n [latestReload],\n );\n\n const latestStop = useUpdatedRef(stop);\n const latestStopFunc = useCallback(() => {\n return latestStop.current();\n }, [latestStop]);\n\n const latestDelete = useUpdatedRef(deleteMessage);\n const latestDeleteFunc = useCallback(\n (messageId: string) => {\n return latestDelete.current(messageId);\n },\n [latestDelete],\n );\n\n const latestSetMessages = useUpdatedRef(setMessages);\n const latestSetMessagesFunc = useCallback(\n (messages: Message[]) => {\n return latestSetMessages.current(aguiToGQL(messages));\n },\n [latestSetMessages],\n );\n\n const latestRunChatCompletion = useUpdatedRef(runChatCompletion);\n const latestRunChatCompletionFunc = useAsyncCallback(async () => {\n return await latestRunChatCompletion.current!();\n }, [latestRunChatCompletion]);\n\n const reset = useCallback(() => {\n latestStopFunc();\n setMessages([]);\n setRunId(null);\n setCoagentStatesWithRef({});\n let initialAgentSession: AgentSession | null = null;\n if (agentLock) {\n initialAgentSession = {\n agentName: agentLock,\n };\n }\n setAgentSession(initialAgentSession);\n // Reset suggestions when chat is reset\n resetSuggestions();\n }, [\n latestStopFunc,\n setMessages,\n setThreadId,\n setCoagentStatesWithRef,\n setAgentSession,\n agentLock,\n resetSuggestions,\n ]);\n\n const latestReset = useUpdatedRef(reset);\n const latestResetFunc = useCallback(() => {\n return latestReset.current();\n }, [latestReset]);\n\n const interrupt = useLangGraphInterruptRender();\n\n return {\n visibleMessages: gqlToAGUI(messages, actions, coAgentStateRenders),\n appendMessage: latestAppendFunc,\n setMessages: latestSetMessagesFunc,\n reloadMessages: latestReloadFunc,\n stopGeneration: latestStopFunc,\n reset: latestResetFunc,\n deleteMessage: latestDeleteFunc,\n runChatCompletion: latestRunChatCompletionFunc,\n isLoading,\n mcpServers,\n setMcpServers,\n suggestions,\n setSuggestions,\n generateSuggestions: generateSuggestionsFunc,\n resetSuggestions,\n isLoadingSuggestions: isLoadingSuggestionsRef.current,\n interrupt,\n };\n}\n\n// store `value` in a ref and update\n// it whenever it changes.\nfunction useUpdatedRef<T>(value: T) {\n const ref = useRef(value);\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref;\n}\n\nexport function defaultSystemMessage(\n contextString: string,\n additionalInstructions?: string,\n): string {\n return (\n `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.\n\nPlease assist them as best you can.\n\nYou can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.\n\nIf you would like to call a function, call it without saying anything else.\nIn case of a function error:\n- If this error stems from incorrect function parameters or syntax, you may retry with corrected arguments.\n- If the error's source is unclear or seems unrelated to your input, do not attempt further retries.\n` + (additionalInstructions ? `\\n\\n${additionalInstructions}` : \"\")\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,SAAS,QAAQ,WAAW,aAAa,UAAU,eAAe;AAYlE,SAAS,QAAQ,SAAS,aAAa,WAAW,iBAAiB;AAkGnE,IAAI,0BAAgD;AAE7C,SAAS,eAAe,UAAiC,CAAC,GAAyB;AAlM1F;AAmME,QAAM,qBAAoB,aAAQ,sBAAR,YAA6B;AACvD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,kBAAkB;AACtB,QAAM,EAAE,UAAU,YAAY,IAAI,0BAA0B;AAG5D,QAAM,CAAC,YAAY,kBAAkB,IAAI,SAA4B,CAAC,CAAC;AAGvE,QAAM,gCAAgC,OAA+B,IAAI;AACzE,QAAM,0BAA0B,OAAgB,KAAK;AAErD,QAAM,mBAAmB;AAAA,IACvB,CAAC,QAAiB,SAAS;AA3O/B,UAAAA;AA4OM,OAAAA,MAAA,8BAA8B,YAA9B,gBAAAA,IAAuC,MAAM;AAC7C,oCAA8B,UAAU;AACxC,UAAI,OAAO;AACT,uBAAe,CAAC,CAAC;AAAA,MACnB;AAAA,IACF;AAAA,IACA,CAAC,cAAc;AAAA,EACjB;AAGA,QAAM,gBAAgB,QAAQ,MAAM;AAClC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,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AA,QACpB,WAAW;AAAA,MACb;AAAA,IACF;AACA,oBAAgB,mBAAmB;AAEnC,qBAAiB;AAAA,EACnB,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,cAAc,cAAc,KAAK;AACvC,QAAM,kBAAkB,YAAY,MAAM;AACxC,WAAO,YAAY,QAAQ;AAAA,EAC7B,GAAG,CAAC,WAAW,CAAC;AAEhB,QAAM,YAAY,4BAA4B;AAE9C,SAAO;AAAA,IACL,iBAAiB,UAAU,UAAU,SAAS,mBAAmB;AAAA,IACjE,eAAe;AAAA,IACf,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,IACrB;AAAA,IACA,sBAAsB,wBAAwB;AAAA,IAC9C;AAAA,EACF;AACF;AAIA,SAAS,cAAiB,OAAU;AAClC,QAAM,MAAM,OAAO,KAAK;AAExB,YAAU,MAAM;AACd,QAAI,UAAU;AAAA,EAChB,GAAG,CAAC,KAAK,CAAC;AAEV,SAAO;AACT;AAEO,SAAS,qBACd,eACA,wBACQ;AACR,SACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAaG,yBAAyB;AAAA;AAAA,EAAO,2BAA2B;AAEhE;","names":["_a","action","options","messages"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XGRBCWK6.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-LNAQ7JG3.mjs.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-YAF2LATQ.mjs";
|
|
7
7
|
import {
|
|
8
8
|
useCopilotContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XGRBCWK6.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-LU5JPZ24.mjs.map
|