@copilotkit/react-core 0.0.0-mme-load-agent-state-20250117154700
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 +2017 -0
- package/README.md +48 -0
- package/dist/chunk-4IYWTPBR.mjs +61 -0
- package/dist/chunk-4IYWTPBR.mjs.map +1 -0
- package/dist/chunk-5FHSUKQL.mjs +70 -0
- package/dist/chunk-5FHSUKQL.mjs.map +1 -0
- package/dist/chunk-6BQVZFNO.mjs +35 -0
- package/dist/chunk-6BQVZFNO.mjs.map +1 -0
- package/dist/chunk-6U3UH3KO.mjs +140 -0
- package/dist/chunk-6U3UH3KO.mjs.map +1 -0
- package/dist/chunk-BHRJWCZT.mjs +423 -0
- package/dist/chunk-BHRJWCZT.mjs.map +1 -0
- package/dist/chunk-DCTJZ742.mjs +22 -0
- package/dist/chunk-DCTJZ742.mjs.map +1 -0
- package/dist/chunk-EFZPSZWO.mjs +1 -0
- package/dist/chunk-EFZPSZWO.mjs.map +1 -0
- package/dist/chunk-IFBUUIU7.mjs +53 -0
- package/dist/chunk-IFBUUIU7.mjs.map +1 -0
- package/dist/chunk-IJJTXITZ.mjs +59 -0
- package/dist/chunk-IJJTXITZ.mjs.map +1 -0
- package/dist/chunk-IPTELVUL.mjs +221 -0
- package/dist/chunk-IPTELVUL.mjs.map +1 -0
- package/dist/chunk-J6UBNKIR.mjs +23 -0
- package/dist/chunk-J6UBNKIR.mjs.map +1 -0
- package/dist/chunk-JFMOYUAX.mjs +120 -0
- package/dist/chunk-JFMOYUAX.mjs.map +1 -0
- package/dist/chunk-LNI2Z45S.mjs +242 -0
- package/dist/chunk-LNI2Z45S.mjs.map +1 -0
- package/dist/chunk-LUGEI4YQ.mjs +1 -0
- package/dist/chunk-LUGEI4YQ.mjs.map +1 -0
- package/dist/chunk-MLAS4QUR.mjs +18 -0
- package/dist/chunk-MLAS4QUR.mjs.map +1 -0
- package/dist/chunk-N37EFAUX.mjs +28 -0
- package/dist/chunk-N37EFAUX.mjs.map +1 -0
- package/dist/chunk-NR2BTA6Z.mjs +1 -0
- package/dist/chunk-NR2BTA6Z.mjs.map +1 -0
- package/dist/chunk-O7ARI5CV.mjs +31 -0
- package/dist/chunk-O7ARI5CV.mjs.map +1 -0
- package/dist/chunk-SKC7AJIV.mjs +61 -0
- package/dist/chunk-SKC7AJIV.mjs.map +1 -0
- package/dist/chunk-U6JOA64X.mjs +107 -0
- package/dist/chunk-U6JOA64X.mjs.map +1 -0
- package/dist/chunk-VNTDIJSG.mjs +37 -0
- package/dist/chunk-VNTDIJSG.mjs.map +1 -0
- package/dist/chunk-VRQFYEQF.mjs +181 -0
- package/dist/chunk-VRQFYEQF.mjs.map +1 -0
- package/dist/chunk-WZZEEFIX.mjs +500 -0
- package/dist/chunk-WZZEEFIX.mjs.map +1 -0
- package/dist/chunk-XERJQUHA.mjs +31 -0
- package/dist/chunk-XERJQUHA.mjs.map +1 -0
- package/dist/chunk-YPSGKPDA.mjs +1 -0
- package/dist/chunk-YPSGKPDA.mjs.map +1 -0
- package/dist/chunk-YVQNSJ4Z.mjs +90 -0
- package/dist/chunk-YVQNSJ4Z.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.d.ts +16 -0
- package/dist/components/copilot-provider/copilot-messages.js +203 -0
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.mjs +10 -0
- package/dist/components/copilot-provider/copilot-messages.mjs.map +1 -0
- package/dist/components/copilot-provider/copilotkit-props.d.ts +97 -0
- package/dist/components/copilot-provider/copilotkit-props.js +19 -0
- package/dist/components/copilot-provider/copilotkit-props.js.map +1 -0
- package/dist/components/copilot-provider/copilotkit-props.mjs +1 -0
- package/dist/components/copilot-provider/copilotkit-props.mjs.map +1 -0
- package/dist/components/copilot-provider/copilotkit.d.ts +18 -0
- package/dist/components/copilot-provider/copilotkit.js +1037 -0
- package/dist/components/copilot-provider/copilotkit.js.map +1 -0
- package/dist/components/copilot-provider/copilotkit.mjs +22 -0
- package/dist/components/copilot-provider/copilotkit.mjs.map +1 -0
- package/dist/components/copilot-provider/index.d.ts +13 -0
- package/dist/components/copilot-provider/index.js +1037 -0
- package/dist/components/copilot-provider/index.js.map +1 -0
- package/dist/components/copilot-provider/index.mjs +20 -0
- package/dist/components/copilot-provider/index.mjs.map +1 -0
- package/dist/components/error-boundary/error-boundary.d.ts +22 -0
- package/dist/components/error-boundary/error-boundary.js +183 -0
- package/dist/components/error-boundary/error-boundary.js.map +1 -0
- package/dist/components/error-boundary/error-boundary.mjs +12 -0
- package/dist/components/error-boundary/error-boundary.mjs.map +1 -0
- package/dist/components/error-boundary/error-utils.d.ts +11 -0
- package/dist/components/error-boundary/error-utils.js +177 -0
- package/dist/components/error-boundary/error-utils.js.map +1 -0
- package/dist/components/error-boundary/error-utils.mjs +13 -0
- package/dist/components/error-boundary/error-utils.mjs.map +1 -0
- package/dist/components/index.d.ts +13 -0
- package/dist/components/index.js +1037 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +20 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/components/toast/exclamation-mark-icon.d.ts +9 -0
- package/dist/components/toast/exclamation-mark-icon.js +55 -0
- package/dist/components/toast/exclamation-mark-icon.js.map +1 -0
- package/dist/components/toast/exclamation-mark-icon.mjs +8 -0
- package/dist/components/toast/exclamation-mark-icon.mjs.map +1 -0
- package/dist/components/toast/toast-provider.d.ts +30 -0
- package/dist/components/toast/toast-provider.js +269 -0
- package/dist/components/toast/toast-provider.js.map +1 -0
- package/dist/components/toast/toast-provider.mjs +11 -0
- package/dist/components/toast/toast-provider.mjs.map +1 -0
- package/dist/context/copilot-context.d.ts +144 -0
- package/dist/context/copilot-context.js +141 -0
- package/dist/context/copilot-context.js.map +1 -0
- package/dist/context/copilot-context.mjs +10 -0
- package/dist/context/copilot-context.mjs.map +1 -0
- package/dist/context/copilot-messages-context.d.ts +15 -0
- package/dist/context/copilot-messages-context.js +57 -0
- package/dist/context/copilot-messages-context.js.map +1 -0
- package/dist/context/copilot-messages-context.mjs +10 -0
- package/dist/context/copilot-messages-context.mjs.map +1 -0
- package/dist/context/index.d.ts +11 -0
- package/dist/context/index.js +164 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/index.mjs +17 -0
- package/dist/context/index.mjs.map +1 -0
- package/dist/hooks/index.d.ts +21 -0
- package/dist/hooks/index.js +1350 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +56 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/hooks/use-chat.d.ts +138 -0
- package/dist/hooks/use-chat.js +628 -0
- package/dist/hooks/use-chat.js.map +1 -0
- package/dist/hooks/use-chat.mjs +12 -0
- package/dist/hooks/use-chat.mjs.map +1 -0
- package/dist/hooks/use-coagent-state-render.d.ts +60 -0
- package/dist/hooks/use-coagent-state-render.js +198 -0
- package/dist/hooks/use-coagent-state-render.js.map +1 -0
- package/dist/hooks/use-coagent-state-render.mjs +11 -0
- package/dist/hooks/use-coagent-state-render.mjs.map +1 -0
- package/dist/hooks/use-coagent.d.ts +199 -0
- package/dist/hooks/use-coagent.js +1111 -0
- package/dist/hooks/use-coagent.js.map +1 -0
- package/dist/hooks/use-coagent.mjs +29 -0
- package/dist/hooks/use-coagent.mjs.map +1 -0
- package/dist/hooks/use-copilot-action.d.ts +140 -0
- package/dist/hooks/use-copilot-action.js +372 -0
- package/dist/hooks/use-copilot-action.js.map +1 -0
- package/dist/hooks/use-copilot-action.mjs +11 -0
- package/dist/hooks/use-copilot-action.mjs.map +1 -0
- package/dist/hooks/use-copilot-authenticated-action.d.ts +8 -0
- package/dist/hooks/use-copilot-authenticated-action.js +421 -0
- package/dist/hooks/use-copilot-authenticated-action.js.map +1 -0
- package/dist/hooks/use-copilot-authenticated-action.mjs +12 -0
- package/dist/hooks/use-copilot-authenticated-action.mjs.map +1 -0
- package/dist/hooks/use-copilot-chat.d.ts +48 -0
- package/dist/hooks/use-copilot-chat.js +957 -0
- package/dist/hooks/use-copilot-chat.js.map +1 -0
- package/dist/hooks/use-copilot-chat.mjs +24 -0
- package/dist/hooks/use-copilot-chat.mjs.map +1 -0
- package/dist/hooks/use-copilot-readable.d.ts +33 -0
- package/dist/hooks/use-copilot-readable.js +161 -0
- package/dist/hooks/use-copilot-readable.js.map +1 -0
- package/dist/hooks/use-copilot-readable.mjs +9 -0
- package/dist/hooks/use-copilot-readable.mjs.map +1 -0
- package/dist/hooks/use-copilot-runtime-client.d.ts +5 -0
- package/dist/hooks/use-copilot-runtime-client.js +182 -0
- package/dist/hooks/use-copilot-runtime-client.js.map +1 -0
- package/dist/hooks/use-copilot-runtime-client.mjs +10 -0
- package/dist/hooks/use-copilot-runtime-client.mjs.map +1 -0
- package/dist/hooks/use-flat-category-store.d.ts +9 -0
- package/dist/hooks/use-flat-category-store.js +90 -0
- package/dist/hooks/use-flat-category-store.js.map +1 -0
- package/dist/hooks/use-flat-category-store.mjs +8 -0
- package/dist/hooks/use-flat-category-store.mjs.map +1 -0
- package/dist/hooks/use-make-copilot-document-readable.d.ts +12 -0
- package/dist/hooks/use-make-copilot-document-readable.js +156 -0
- package/dist/hooks/use-make-copilot-document-readable.js.map +1 -0
- package/dist/hooks/use-make-copilot-document-readable.mjs +9 -0
- package/dist/hooks/use-make-copilot-document-readable.mjs.map +1 -0
- package/dist/hooks/use-tree.d.ts +18 -0
- package/dist/hooks/use-tree.js +172 -0
- package/dist/hooks/use-tree.js.map +1 -0
- package/dist/hooks/use-tree.mjs +8 -0
- package/dist/hooks/use-tree.mjs.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +2308 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +83 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/copilot-task.d.ts +97 -0
- package/dist/lib/copilot-task.js +195 -0
- package/dist/lib/copilot-task.js.map +1 -0
- package/dist/lib/copilot-task.mjs +20 -0
- package/dist/lib/copilot-task.mjs.map +1 -0
- package/dist/lib/index.d.ts +11 -0
- package/dist/lib/index.js +197 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/index.mjs +21 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/types/chat-suggestion-configuration.d.ts +22 -0
- package/dist/types/chat-suggestion-configuration.js +19 -0
- package/dist/types/chat-suggestion-configuration.js.map +1 -0
- package/dist/types/chat-suggestion-configuration.mjs +1 -0
- package/dist/types/chat-suggestion-configuration.mjs.map +1 -0
- package/dist/types/coagent-action.d.ts +29 -0
- package/dist/types/coagent-action.js +19 -0
- package/dist/types/coagent-action.js.map +1 -0
- package/dist/types/coagent-action.mjs +1 -0
- package/dist/types/coagent-action.mjs.map +1 -0
- package/dist/types/coagent-state.d.ts +11 -0
- package/dist/types/coagent-state.js +19 -0
- package/dist/types/coagent-state.js.map +1 -0
- package/dist/types/coagent-state.mjs +1 -0
- package/dist/types/coagent-state.mjs.map +1 -0
- package/dist/types/document-pointer.d.ts +9 -0
- package/dist/types/document-pointer.js +19 -0
- package/dist/types/document-pointer.js.map +1 -0
- package/dist/types/document-pointer.mjs +1 -0
- package/dist/types/document-pointer.mjs.map +1 -0
- package/dist/types/frontend-action.d.ts +126 -0
- package/dist/types/frontend-action.js +53 -0
- package/dist/types/frontend-action.js.map +1 -0
- package/dist/types/frontend-action.mjs +8 -0
- package/dist/types/frontend-action.mjs.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +2 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types/system-message.d.ts +3 -0
- package/dist/types/system-message.js +19 -0
- package/dist/types/system-message.js.map +1 -0
- package/dist/types/system-message.mjs +1 -0
- package/dist/types/system-message.mjs.map +1 -0
- package/dist/utils/dev-console.d.ts +3 -0
- package/dist/utils/dev-console.js +42 -0
- package/dist/utils/dev-console.js.map +1 -0
- package/dist/utils/dev-console.mjs +8 -0
- package/dist/utils/dev-console.mjs.map +1 -0
- package/dist/utils/extract.d.ts +43 -0
- package/dist/utils/extract.js +208 -0
- package/dist/utils/extract.js.map +1 -0
- package/dist/utils/extract.mjs +18 -0
- package/dist/utils/extract.mjs.map +1 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.js +226 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +21 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils/utils.d.ts +2 -0
- package/dist/utils/utils.js +19 -0
- package/dist/utils/utils.js.map +1 -0
- package/dist/utils/utils.mjs +1 -0
- package/dist/utils/utils.mjs.map +1 -0
- package/dist/utils/utils.test.d.ts +2 -0
- package/dist/utils/utils.test.js +9 -0
- package/dist/utils/utils.test.js.map +1 -0
- package/dist/utils/utils.test.mjs +7 -0
- package/dist/utils/utils.test.mjs.map +1 -0
- package/jest.config.js +5 -0
- package/package.json +69 -0
- package/src/components/copilot-provider/copilot-messages.tsx +45 -0
- package/src/components/copilot-provider/copilotkit-props.tsx +102 -0
- package/src/components/copilot-provider/copilotkit.tsx +427 -0
- package/src/components/copilot-provider/index.ts +3 -0
- package/src/components/error-boundary/error-boundary.tsx +42 -0
- package/src/components/error-boundary/error-utils.tsx +95 -0
- package/src/components/index.ts +1 -0
- package/src/components/toast/exclamation-mark-icon.tsx +27 -0
- package/src/components/toast/toast-provider.tsx +170 -0
- package/src/context/copilot-context.tsx +280 -0
- package/src/context/copilot-messages-context.tsx +29 -0
- package/src/context/index.ts +8 -0
- package/src/hooks/index.ts +12 -0
- package/src/hooks/use-chat.ts +682 -0
- package/src/hooks/use-coagent-state-render.ts +118 -0
- package/src/hooks/use-coagent.ts +394 -0
- package/src/hooks/use-copilot-action.ts +289 -0
- package/src/hooks/use-copilot-authenticated-action.ts +60 -0
- package/src/hooks/use-copilot-chat.ts +310 -0
- package/src/hooks/use-copilot-readable.ts +123 -0
- package/src/hooks/use-copilot-runtime-client.ts +28 -0
- package/src/hooks/use-flat-category-store.ts +104 -0
- package/src/hooks/use-make-copilot-document-readable.ts +30 -0
- package/src/hooks/use-tree.ts +202 -0
- package/src/index.tsx +7 -0
- package/src/lib/copilot-task.ts +201 -0
- package/src/lib/index.ts +1 -0
- package/src/types/chat-suggestion-configuration.ts +23 -0
- package/src/types/coagent-action.ts +31 -0
- package/src/types/coagent-state.ts +9 -0
- package/src/types/document-pointer.ts +7 -0
- package/src/types/frontend-action.ts +199 -0
- package/src/types/index.ts +8 -0
- package/src/types/system-message.ts +4 -0
- package/src/utils/dev-console.ts +18 -0
- package/src/utils/extract.ts +215 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/utils.test.ts +7 -0
- package/src/utils/utils.ts +1 -0
- package/tsconfig.json +12 -0
- package/tsup.config.ts +16 -0
- package/typedoc.json +4 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { CopilotContextParams } from '../context/copilot-context.js';
|
|
2
|
+
import { CopilotMessagesContextParams } from '../context/copilot-messages-context.js';
|
|
3
|
+
import { Message } from '@copilotkit/runtime-client-gql';
|
|
4
|
+
import '@copilotkit/shared';
|
|
5
|
+
import '../types/frontend-action.js';
|
|
6
|
+
import 'react';
|
|
7
|
+
import './use-tree.js';
|
|
8
|
+
import '../types/document-pointer.js';
|
|
9
|
+
import '../types/chat-suggestion-configuration.js';
|
|
10
|
+
import '../types/coagent-action.js';
|
|
11
|
+
import '../types/coagent-state.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* <Callout type="info">
|
|
15
|
+
* Usage of this hook assumes some additional setup in your application, for more information
|
|
16
|
+
* on that see the CoAgents <span className="text-blue-500">[getting started guide](/coagents/quickstart)</span>.
|
|
17
|
+
* </Callout>
|
|
18
|
+
* <Frame className="my-12">
|
|
19
|
+
* <img
|
|
20
|
+
* src="/images/coagents/SharedStateCoAgents.gif"
|
|
21
|
+
* alt="CoAgents demonstration"
|
|
22
|
+
* className="w-auto"
|
|
23
|
+
* />
|
|
24
|
+
* </Frame>
|
|
25
|
+
*
|
|
26
|
+
* This hook is used to integrate an agent into your application. With its use, you can
|
|
27
|
+
* render and update the state of an agent, allowing for a dynamic and interactive experience.
|
|
28
|
+
* We call these shared state experiences agentic copilots, or CoAgents for short.
|
|
29
|
+
*
|
|
30
|
+
* ## Usage
|
|
31
|
+
*
|
|
32
|
+
* ### Simple Usage
|
|
33
|
+
*
|
|
34
|
+
* ```tsx
|
|
35
|
+
* import { useCoAgent } from "@copilotkit/react-core";
|
|
36
|
+
*
|
|
37
|
+
* type AgentState = {
|
|
38
|
+
* count: number;
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* const agent = useCoAgent<AgentState>({
|
|
42
|
+
* name: "my-agent",
|
|
43
|
+
* initialState: {
|
|
44
|
+
* count: 0,
|
|
45
|
+
* },
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* `useCoAgent` returns an object with the following properties:
|
|
51
|
+
*
|
|
52
|
+
* ```tsx
|
|
53
|
+
* const {
|
|
54
|
+
* name, // The name of the agent currently being used.
|
|
55
|
+
* nodeName, // The name of the current LangGraph node.
|
|
56
|
+
* state, // The current state of the agent.
|
|
57
|
+
* setState, // A function to update the state of the agent.
|
|
58
|
+
* running, // A boolean indicating if the agent is currently running.
|
|
59
|
+
* start, // A function to start the agent.
|
|
60
|
+
* stop, // A function to stop the agent.
|
|
61
|
+
* run, // A function to re-run the agent. Takes a HintFunction to inform the agent why it is being re-run.
|
|
62
|
+
* } = agent;
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* Finally we can leverage these properties to create reactive experiences with the agent!
|
|
66
|
+
*
|
|
67
|
+
* ```tsx
|
|
68
|
+
* const { state, setState } = useCoAgent<AgentState>({
|
|
69
|
+
* name: "my-agent",
|
|
70
|
+
* initialState: {
|
|
71
|
+
* count: 0,
|
|
72
|
+
* },
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* return (
|
|
76
|
+
* <div>
|
|
77
|
+
* <p>Count: {state.count}</p>
|
|
78
|
+
* <button onClick={() => setState({ count: state.count + 1 })}>Increment</button>
|
|
79
|
+
* </div>
|
|
80
|
+
* );
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* This reactivity is bidirectional, meaning that changes to the state from the agent will be reflected in the UI and vice versa.
|
|
84
|
+
*
|
|
85
|
+
* ## Parameters
|
|
86
|
+
* <PropertyReference name="options" type="UseCoagentOptions<T>" required>
|
|
87
|
+
* The options to use when creating the coagent.
|
|
88
|
+
* <PropertyReference name="name" type="string" required>
|
|
89
|
+
* The name of the agent to use.
|
|
90
|
+
* </PropertyReference>
|
|
91
|
+
* <PropertyReference name="initialState" type="T | any">
|
|
92
|
+
* The initial state of the agent.
|
|
93
|
+
* </PropertyReference>
|
|
94
|
+
* <PropertyReference name="state" type="T | any">
|
|
95
|
+
* State to manage externally if you are using this hook with external state management.
|
|
96
|
+
* </PropertyReference>
|
|
97
|
+
* <PropertyReference name="setState" type="(newState: T | ((prevState: T | undefined) => T)) => void">
|
|
98
|
+
* A function to update the state of the agent if you are using this hook with external state management.
|
|
99
|
+
* </PropertyReference>
|
|
100
|
+
* </PropertyReference>
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
interface WithInternalStateManagementAndInitial<T> {
|
|
104
|
+
/**
|
|
105
|
+
* The name of the agent being used.
|
|
106
|
+
*/
|
|
107
|
+
name: string;
|
|
108
|
+
/**
|
|
109
|
+
* The initial state of the agent.
|
|
110
|
+
*/
|
|
111
|
+
initialState: T;
|
|
112
|
+
}
|
|
113
|
+
interface WithInternalStateManagement {
|
|
114
|
+
/**
|
|
115
|
+
* The name of the agent being used.
|
|
116
|
+
*/
|
|
117
|
+
name: string;
|
|
118
|
+
/**
|
|
119
|
+
* Optional initialState with default type any
|
|
120
|
+
*/
|
|
121
|
+
initialState?: any;
|
|
122
|
+
}
|
|
123
|
+
interface WithExternalStateManagement<T> {
|
|
124
|
+
/**
|
|
125
|
+
* The name of the agent being used.
|
|
126
|
+
*/
|
|
127
|
+
name: string;
|
|
128
|
+
/**
|
|
129
|
+
* The current state of the agent.
|
|
130
|
+
*/
|
|
131
|
+
state: T;
|
|
132
|
+
/**
|
|
133
|
+
* A function to update the state of the agent.
|
|
134
|
+
*/
|
|
135
|
+
setState: (newState: T | ((prevState: T | undefined) => T)) => void;
|
|
136
|
+
}
|
|
137
|
+
type UseCoagentOptions<T> = WithInternalStateManagementAndInitial<T> | WithInternalStateManagement | WithExternalStateManagement<T>;
|
|
138
|
+
interface UseCoagentReturnType<T> {
|
|
139
|
+
/**
|
|
140
|
+
* The name of the agent being used.
|
|
141
|
+
*/
|
|
142
|
+
name: string;
|
|
143
|
+
/**
|
|
144
|
+
* The name of the current LangGraph node.
|
|
145
|
+
*/
|
|
146
|
+
nodeName?: string;
|
|
147
|
+
/**
|
|
148
|
+
* The ID of the thread the agent is running in.
|
|
149
|
+
*/
|
|
150
|
+
threadId?: string;
|
|
151
|
+
/**
|
|
152
|
+
* A boolean indicating if the agent is currently running.
|
|
153
|
+
*/
|
|
154
|
+
running: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* The current state of the agent.
|
|
157
|
+
*/
|
|
158
|
+
state: T;
|
|
159
|
+
/**
|
|
160
|
+
* A function to update the state of the agent.
|
|
161
|
+
*/
|
|
162
|
+
setState: (newState: T | ((prevState: T | undefined) => T)) => void;
|
|
163
|
+
/**
|
|
164
|
+
* A function to start the agent.
|
|
165
|
+
*/
|
|
166
|
+
start: () => void;
|
|
167
|
+
/**
|
|
168
|
+
* A function to stop the agent.
|
|
169
|
+
*/
|
|
170
|
+
stop: () => void;
|
|
171
|
+
/**
|
|
172
|
+
* A function to re-run the agent. The hint function can be used to provide a hint to the agent
|
|
173
|
+
* about why it is being re-run again.
|
|
174
|
+
*/
|
|
175
|
+
run: (hint?: HintFunction) => Promise<void>;
|
|
176
|
+
}
|
|
177
|
+
interface HintFunctionParams {
|
|
178
|
+
/**
|
|
179
|
+
* The previous state of the agent.
|
|
180
|
+
*/
|
|
181
|
+
previousState: any;
|
|
182
|
+
/**
|
|
183
|
+
* The current state of the agent.
|
|
184
|
+
*/
|
|
185
|
+
currentState: any;
|
|
186
|
+
}
|
|
187
|
+
type HintFunction = (params: HintFunctionParams) => Message | undefined;
|
|
188
|
+
/**
|
|
189
|
+
* This hook is used to integrate an agent into your application. With its use, you can
|
|
190
|
+
* render and update the state of the agent, allowing for a dynamic and interactive experience.
|
|
191
|
+
* We call these shared state experiences "agentic copilots". To get started using agentic copilots, which
|
|
192
|
+
* we refer to as CoAgents, checkout the documentation at https://docs.copilotkit.ai/coagents/quickstart.
|
|
193
|
+
*/
|
|
194
|
+
declare function useCoAgent<T = any>(options: UseCoagentOptions<T>): UseCoagentReturnType<T>;
|
|
195
|
+
declare function startAgent(name: string, context: CopilotContextParams): void;
|
|
196
|
+
declare function stopAgent(name: string, context: CopilotContextParams): void;
|
|
197
|
+
declare function runAgent(name: string, context: CopilotContextParams & CopilotMessagesContextParams, appendMessage: (message: Message) => Promise<void>, runChatCompletion: () => Promise<Message[]>, hint?: HintFunction): Promise<void>;
|
|
198
|
+
|
|
199
|
+
export { HintFunction, HintFunctionParams, UseCoagentReturnType, runAgent, startAgent, stopAgent, useCoAgent };
|