@copilotkit/react-core 1.5.1-next.3 → 1.5.1-next.4
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 +11 -2
- package/package.json +5 -5
- package/dist/chunk-2KCEHGSI.mjs +0 -192
- package/dist/chunk-2KCEHGSI.mjs.map +0 -1
- package/dist/chunk-5FHSUKQL.mjs +0 -70
- package/dist/chunk-5FHSUKQL.mjs.map +0 -1
- package/dist/chunk-6OR25P32.mjs +0 -426
- package/dist/chunk-6OR25P32.mjs.map +0 -1
- package/dist/chunk-6U3UH3KO.mjs +0 -140
- package/dist/chunk-6U3UH3KO.mjs.map +0 -1
- package/dist/chunk-DCTJZ742.mjs +0 -22
- package/dist/chunk-DCTJZ742.mjs.map +0 -1
- package/dist/chunk-DDVXFNYA.mjs +0 -126
- package/dist/chunk-DDVXFNYA.mjs.map +0 -1
- package/dist/chunk-EFZPSZWO.mjs +0 -1
- package/dist/chunk-EFZPSZWO.mjs.map +0 -1
- package/dist/chunk-FXHKK52V.mjs +0 -119
- package/dist/chunk-FXHKK52V.mjs.map +0 -1
- package/dist/chunk-H4VZMKR6.mjs +0 -23
- package/dist/chunk-H4VZMKR6.mjs.map +0 -1
- package/dist/chunk-H7LSKIDK.mjs +0 -167
- package/dist/chunk-H7LSKIDK.mjs.map +0 -1
- package/dist/chunk-JDQCJCAQ.mjs +0 -295
- package/dist/chunk-JDQCJCAQ.mjs.map +0 -1
- package/dist/chunk-L34MHAXR.mjs +0 -1
- package/dist/chunk-L34MHAXR.mjs.map +0 -1
- package/dist/chunk-LODRWFMB.mjs +0 -75
- package/dist/chunk-LODRWFMB.mjs.map +0 -1
- package/dist/chunk-LUGEI4YQ.mjs +0 -1
- package/dist/chunk-LUGEI4YQ.mjs.map +0 -1
- package/dist/chunk-MLAS4QUR.mjs +0 -18
- package/dist/chunk-MLAS4QUR.mjs.map +0 -1
- package/dist/chunk-MWZO6TUR.mjs +0 -91
- package/dist/chunk-MWZO6TUR.mjs.map +0 -1
- package/dist/chunk-O7ARI5CV.mjs +0 -31
- package/dist/chunk-O7ARI5CV.mjs.map +0 -1
- package/dist/chunk-ODN4H66E.mjs +0 -31
- package/dist/chunk-ODN4H66E.mjs.map +0 -1
- package/dist/chunk-QDGDXRRJ.mjs +0 -28
- package/dist/chunk-QDGDXRRJ.mjs.map +0 -1
- package/dist/chunk-SKC7AJIV.mjs +0 -61
- package/dist/chunk-SKC7AJIV.mjs.map +0 -1
- package/dist/chunk-XINZBP3J.mjs +0 -49
- package/dist/chunk-XINZBP3J.mjs.map +0 -1
- package/dist/chunk-XXR4QFAQ.mjs +0 -29
- package/dist/chunk-XXR4QFAQ.mjs.map +0 -1
- package/dist/chunk-YPSGKPDA.mjs +0 -1
- package/dist/chunk-YPSGKPDA.mjs.map +0 -1
- package/dist/components/copilot-provider/copilot-messages.d.ts +0 -7
- package/dist/components/copilot-provider/copilot-messages.js +0 -80
- package/dist/components/copilot-provider/copilot-messages.js.map +0 -1
- package/dist/components/copilot-provider/copilot-messages.mjs +0 -9
- package/dist/components/copilot-provider/copilot-messages.mjs.map +0 -1
- package/dist/components/copilot-provider/copilotkit-props.d.ts +0 -72
- package/dist/components/copilot-provider/copilotkit-props.js +0 -19
- package/dist/components/copilot-provider/copilotkit-props.js.map +0 -1
- package/dist/components/copilot-provider/copilotkit-props.mjs +0 -1
- package/dist/components/copilot-provider/copilotkit-props.mjs.map +0 -1
- package/dist/components/copilot-provider/copilotkit.d.ts +0 -9
- package/dist/components/copilot-provider/copilotkit.js +0 -861
- package/dist/components/copilot-provider/copilotkit.js.map +0 -1
- package/dist/components/copilot-provider/copilotkit.mjs +0 -21
- package/dist/components/copilot-provider/copilotkit.mjs.map +0 -1
- package/dist/components/copilot-provider/index.d.ts +0 -4
- package/dist/components/copilot-provider/index.js +0 -861
- package/dist/components/copilot-provider/index.js.map +0 -1
- package/dist/components/copilot-provider/index.mjs +0 -19
- package/dist/components/copilot-provider/index.mjs.map +0 -1
- package/dist/components/index.d.ts +0 -4
- package/dist/components/index.js +0 -861
- package/dist/components/index.js.map +0 -1
- package/dist/components/index.mjs +0 -19
- package/dist/components/index.mjs.map +0 -1
- package/dist/components/toast/exclamation-mark-icon.d.ts +0 -9
- package/dist/components/toast/exclamation-mark-icon.js +0 -55
- package/dist/components/toast/exclamation-mark-icon.js.map +0 -1
- package/dist/components/toast/exclamation-mark-icon.mjs +0 -8
- package/dist/components/toast/exclamation-mark-icon.mjs.map +0 -1
- package/dist/components/toast/toast-provider.d.ts +0 -29
- package/dist/components/toast/toast-provider.js +0 -255
- package/dist/components/toast/toast-provider.js.map +0 -1
- package/dist/components/toast/toast-provider.mjs +0 -11
- package/dist/components/toast/toast-provider.mjs.map +0 -1
- package/dist/context/copilot-context.d.ts +0 -109
- package/dist/context/copilot-context.js +0 -126
- package/dist/context/copilot-context.js.map +0 -1
- package/dist/context/copilot-context.mjs +0 -10
- package/dist/context/copilot-context.mjs.map +0 -1
- package/dist/context/copilot-messages-context.d.ts +0 -15
- package/dist/context/copilot-messages-context.js +0 -57
- package/dist/context/copilot-messages-context.js.map +0 -1
- package/dist/context/copilot-messages-context.mjs +0 -10
- package/dist/context/copilot-messages-context.mjs.map +0 -1
- package/dist/context/index.d.ts +0 -11
- package/dist/context/index.js +0 -149
- package/dist/context/index.js.map +0 -1
- package/dist/context/index.mjs +0 -17
- package/dist/context/index.mjs.map +0 -1
- package/dist/hooks/index.d.ts +0 -19
- package/dist/hooks/index.js +0 -897
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/index.mjs +0 -44
- package/dist/hooks/index.mjs.map +0 -1
- package/dist/hooks/use-chat.d.ts +0 -92
- package/dist/hooks/use-chat.js +0 -360
- package/dist/hooks/use-chat.js.map +0 -1
- package/dist/hooks/use-chat.mjs +0 -11
- package/dist/hooks/use-chat.mjs.map +0 -1
- package/dist/hooks/use-coagent-state-render.d.ts +0 -60
- package/dist/hooks/use-coagent-state-render.js +0 -160
- package/dist/hooks/use-coagent-state-render.js.map +0 -1
- package/dist/hooks/use-coagent-state-render.mjs +0 -9
- package/dist/hooks/use-coagent-state-render.mjs.map +0 -1
- package/dist/hooks/use-coagent.d.ts +0 -186
- package/dist/hooks/use-coagent.js +0 -726
- package/dist/hooks/use-coagent.js.map +0 -1
- package/dist/hooks/use-coagent.mjs +0 -21
- package/dist/hooks/use-coagent.mjs.map +0 -1
- package/dist/hooks/use-copilot-action.d.ts +0 -130
- package/dist/hooks/use-copilot-action.js +0 -219
- package/dist/hooks/use-copilot-action.js.map +0 -1
- package/dist/hooks/use-copilot-action.mjs +0 -9
- package/dist/hooks/use-copilot-action.mjs.map +0 -1
- package/dist/hooks/use-copilot-chat.d.ts +0 -36
- package/dist/hooks/use-copilot-chat.js +0 -623
- package/dist/hooks/use-copilot-chat.js.map +0 -1
- package/dist/hooks/use-copilot-chat.mjs +0 -22
- package/dist/hooks/use-copilot-chat.mjs.map +0 -1
- package/dist/hooks/use-copilot-readable.d.ts +0 -33
- package/dist/hooks/use-copilot-readable.js +0 -146
- package/dist/hooks/use-copilot-readable.js.map +0 -1
- package/dist/hooks/use-copilot-readable.mjs +0 -9
- package/dist/hooks/use-copilot-readable.mjs.map +0 -1
- package/dist/hooks/use-copilot-runtime-client.d.ts +0 -5
- package/dist/hooks/use-copilot-runtime-client.js +0 -76
- package/dist/hooks/use-copilot-runtime-client.js.map +0 -1
- package/dist/hooks/use-copilot-runtime-client.mjs +0 -10
- package/dist/hooks/use-copilot-runtime-client.mjs.map +0 -1
- package/dist/hooks/use-flat-category-store.d.ts +0 -9
- package/dist/hooks/use-flat-category-store.js +0 -90
- package/dist/hooks/use-flat-category-store.js.map +0 -1
- package/dist/hooks/use-flat-category-store.mjs +0 -8
- package/dist/hooks/use-flat-category-store.mjs.map +0 -1
- package/dist/hooks/use-make-copilot-document-readable.d.ts +0 -12
- package/dist/hooks/use-make-copilot-document-readable.js +0 -141
- package/dist/hooks/use-make-copilot-document-readable.js.map +0 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs +0 -9
- package/dist/hooks/use-make-copilot-document-readable.mjs.map +0 -1
- package/dist/hooks/use-tree.d.ts +0 -18
- package/dist/hooks/use-tree.js +0 -172
- package/dist/hooks/use-tree.js.map +0 -1
- package/dist/hooks/use-tree.mjs +0 -8
- package/dist/hooks/use-tree.mjs.map +0 -1
- package/dist/index.d.ts +0 -26
- package/dist/index.js +0 -1810
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -71
- package/dist/index.mjs.map +0 -1
- package/dist/lib/copilot-task.d.ts +0 -92
- package/dist/lib/copilot-task.js +0 -157
- package/dist/lib/copilot-task.js.map +0 -1
- package/dist/lib/copilot-task.mjs +0 -18
- package/dist/lib/copilot-task.mjs.map +0 -1
- package/dist/lib/index.d.ts +0 -11
- package/dist/lib/index.js +0 -159
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/index.mjs +0 -19
- package/dist/lib/index.mjs.map +0 -1
- package/dist/types/chat-suggestion-configuration.d.ts +0 -22
- package/dist/types/chat-suggestion-configuration.js +0 -19
- package/dist/types/chat-suggestion-configuration.js.map +0 -1
- package/dist/types/chat-suggestion-configuration.mjs +0 -1
- package/dist/types/chat-suggestion-configuration.mjs.map +0 -1
- package/dist/types/coagent-action.d.ts +0 -29
- package/dist/types/coagent-action.js +0 -19
- package/dist/types/coagent-action.js.map +0 -1
- package/dist/types/coagent-action.mjs +0 -1
- package/dist/types/coagent-action.mjs.map +0 -1
- package/dist/types/coagent-state.d.ts +0 -11
- package/dist/types/coagent-state.js +0 -19
- package/dist/types/coagent-state.js.map +0 -1
- package/dist/types/coagent-state.mjs +0 -1
- package/dist/types/coagent-state.mjs.map +0 -1
- package/dist/types/document-pointer.d.ts +0 -9
- package/dist/types/document-pointer.js +0 -19
- package/dist/types/document-pointer.js.map +0 -1
- package/dist/types/document-pointer.mjs +0 -1
- package/dist/types/document-pointer.mjs.map +0 -1
- package/dist/types/frontend-action.d.ts +0 -107
- package/dist/types/frontend-action.js +0 -19
- package/dist/types/frontend-action.js.map +0 -1
- package/dist/types/frontend-action.mjs +0 -1
- package/dist/types/frontend-action.mjs.map +0 -1
- package/dist/types/index.d.ts +0 -6
- package/dist/types/index.js +0 -19
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -2
- package/dist/types/index.mjs.map +0 -1
- package/dist/types/system-message.d.ts +0 -3
- package/dist/types/system-message.js +0 -19
- package/dist/types/system-message.js.map +0 -1
- package/dist/types/system-message.mjs +0 -1
- package/dist/types/system-message.mjs.map +0 -1
- package/dist/utils/dev-console.d.ts +0 -3
- package/dist/utils/dev-console.js +0 -42
- package/dist/utils/dev-console.js.map +0 -1
- package/dist/utils/dev-console.mjs +0 -8
- package/dist/utils/dev-console.mjs.map +0 -1
- package/dist/utils/extract.d.ts +0 -42
- package/dist/utils/extract.js +0 -190
- package/dist/utils/extract.js.map +0 -1
- package/dist/utils/extract.mjs +0 -17
- package/dist/utils/extract.mjs.map +0 -1
- package/dist/utils/index.d.ts +0 -13
- package/dist/utils/index.js +0 -208
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/index.mjs +0 -20
- package/dist/utils/index.mjs.map +0 -1
- package/dist/utils/utils.d.ts +0 -2
- package/dist/utils/utils.js +0 -19
- package/dist/utils/utils.js.map +0 -1
- package/dist/utils/utils.mjs +0 -1
- package/dist/utils/utils.mjs.map +0 -1
- package/dist/utils/utils.test.d.ts +0 -2
- package/dist/utils/utils.test.js +0 -9
- package/dist/utils/utils.test.js.map +0 -1
- package/dist/utils/utils.test.mjs +0 -7
- package/dist/utils/utils.test.mjs.map +0 -1
package/dist/chunk-DDVXFNYA.mjs
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useCopilotChat
|
|
3
|
-
} from "./chunk-H7LSKIDK.mjs";
|
|
4
|
-
import {
|
|
5
|
-
useCopilotContext
|
|
6
|
-
} from "./chunk-LODRWFMB.mjs";
|
|
7
|
-
import {
|
|
8
|
-
useCopilotMessagesContext
|
|
9
|
-
} from "./chunk-DCTJZ742.mjs";
|
|
10
|
-
import {
|
|
11
|
-
__async,
|
|
12
|
-
__spreadProps,
|
|
13
|
-
__spreadValues
|
|
14
|
-
} from "./chunk-SKC7AJIV.mjs";
|
|
15
|
-
|
|
16
|
-
// src/hooks/use-coagent.ts
|
|
17
|
-
import { useEffect } from "react";
|
|
18
|
-
function useCoAgent(options) {
|
|
19
|
-
const isExternalStateManagement = (options2) => {
|
|
20
|
-
return "state" in options2 && "setState" in options2;
|
|
21
|
-
};
|
|
22
|
-
const { name } = options;
|
|
23
|
-
const isInternalStateManagementWithInitial = (options2) => {
|
|
24
|
-
return "initialState" in options2;
|
|
25
|
-
};
|
|
26
|
-
const generalContext = useCopilotContext();
|
|
27
|
-
const messagesContext = useCopilotMessagesContext();
|
|
28
|
-
const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
|
|
29
|
-
const { coagentStates, setCoagentStates } = context;
|
|
30
|
-
const { appendMessage } = useCopilotChat();
|
|
31
|
-
const getCoagentState = (coagentStates2, name2) => {
|
|
32
|
-
if (coagentStates2[name2]) {
|
|
33
|
-
return coagentStates2[name2];
|
|
34
|
-
} else {
|
|
35
|
-
return {
|
|
36
|
-
name: name2,
|
|
37
|
-
state: isInternalStateManagementWithInitial(options) ? options.initialState : {},
|
|
38
|
-
running: false,
|
|
39
|
-
active: false,
|
|
40
|
-
threadId: void 0,
|
|
41
|
-
nodeName: void 0,
|
|
42
|
-
runId: void 0
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const setState = (newState) => {
|
|
47
|
-
setCoagentStates((prevAgentStates) => {
|
|
48
|
-
let coagentState2 = getCoagentState(prevAgentStates, name);
|
|
49
|
-
const updatedState = typeof newState === "function" ? newState(coagentState2.state) : newState;
|
|
50
|
-
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
51
|
-
[name]: __spreadProps(__spreadValues({}, coagentState2), {
|
|
52
|
-
state: updatedState
|
|
53
|
-
})
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
const coagentState = getCoagentState(coagentStates, name);
|
|
58
|
-
const state = isExternalStateManagement(options) ? options.state : coagentState.state;
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
if (isExternalStateManagement(options)) {
|
|
61
|
-
setState(options.state);
|
|
62
|
-
} else if (coagentStates[name] === void 0) {
|
|
63
|
-
setState(options.initialState === void 0 ? {} : options.initialState);
|
|
64
|
-
}
|
|
65
|
-
}, [isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0]);
|
|
66
|
-
return {
|
|
67
|
-
name,
|
|
68
|
-
nodeName: coagentState.nodeName,
|
|
69
|
-
state,
|
|
70
|
-
setState,
|
|
71
|
-
running: coagentState.running,
|
|
72
|
-
start: () => {
|
|
73
|
-
startAgent(name, context);
|
|
74
|
-
},
|
|
75
|
-
stop: () => {
|
|
76
|
-
stopAgent(name, context);
|
|
77
|
-
},
|
|
78
|
-
run: (hint) => {
|
|
79
|
-
return runAgent(name, context, appendMessage, hint);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function startAgent(name, context) {
|
|
84
|
-
const { setAgentSession } = context;
|
|
85
|
-
setAgentSession({
|
|
86
|
-
agentName: name
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
function stopAgent(name, context) {
|
|
90
|
-
const { agentSession, setAgentSession } = context;
|
|
91
|
-
if (agentSession && agentSession.agentName === name) {
|
|
92
|
-
setAgentSession(null);
|
|
93
|
-
} else {
|
|
94
|
-
console.warn(`No agent session found for ${name}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function runAgent(name, context, appendMessage, hint) {
|
|
98
|
-
return __async(this, null, function* () {
|
|
99
|
-
var _a, _b;
|
|
100
|
-
const { agentSession, setAgentSession } = context;
|
|
101
|
-
if (!agentSession || agentSession.agentName !== name) {
|
|
102
|
-
setAgentSession({
|
|
103
|
-
agentName: name
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
let previousState = null;
|
|
107
|
-
for (let i = context.messages.length - 1; i >= 0; i--) {
|
|
108
|
-
const message = context.messages[i];
|
|
109
|
-
if (message.isAgentStateMessage() && message.agentName === name) {
|
|
110
|
-
previousState = message.state;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
let state = ((_b = (_a = context.coagentStates) == null ? void 0 : _a[name]) == null ? void 0 : _b.state) || {};
|
|
114
|
-
if (hint) {
|
|
115
|
-
const hintMessage = hint({ previousState, currentState: state });
|
|
116
|
-
if (hintMessage) {
|
|
117
|
-
yield appendMessage(hintMessage);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export {
|
|
124
|
-
useCoAgent
|
|
125
|
-
};
|
|
126
|
-
//# sourceMappingURL=chunk-DDVXFNYA.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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)</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 { useEffect } 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 { AgentStateMessage, Message, Role, TextMessage } from \"@copilotkit/runtime-client-gql\";\n\ninterface WithInternalStateManagementAndInitial<T> {\n /**\n * The name of the agent being used.\n */\n name: string;\n /**\n * The initial state of the agent.\n */\n initialState: T;\n}\n\ninterface WithInternalStateManagement {\n /**\n * The name of the agent being used.\n */\n name: string;\n /**\n * Optional initialState with default type any\n */\n initialState?: any;\n}\n\ninterface WithExternalStateManagement<T> {\n /**\n * The name of the agent being used.\n */\n name: string;\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.\n */\nexport function useCoAgent<T = any>(options: UseCoagentOptions<T>): UseCoagentReturnType<T> {\n const isExternalStateManagement = (\n options: UseCoagentOptions<T>,\n ): options is WithExternalStateManagement<T> => {\n return \"state\" in options && \"setState\" in options;\n };\n\n const { name } = options;\n\n const isInternalStateManagementWithInitial = (\n options: UseCoagentOptions<T>,\n ): options is WithInternalStateManagementAndInitial<T> => {\n return \"initialState\" in options;\n };\n\n const generalContext = useCopilotContext();\n const messagesContext = useCopilotMessagesContext();\n const context = { ...generalContext, ...messagesContext };\n const { coagentStates, setCoagentStates } = context;\n const { appendMessage } = useCopilotChat();\n\n const getCoagentState = (coagentStates: Record<string, CoagentState>, name: string) => {\n if (coagentStates[name]) {\n return coagentStates[name];\n } else {\n return {\n name,\n state: isInternalStateManagementWithInitial(options) ? options.initialState : {},\n running: false,\n active: false,\n threadId: undefined,\n nodeName: undefined,\n runId: undefined,\n };\n }\n };\n\n // if we manage state internally, we need to provide a function to set the state\n const setState = (newState: T | ((prevState: T | undefined) => T)) => {\n setCoagentStates((prevAgentStates) => {\n let coagentState: CoagentState = getCoagentState(prevAgentStates, name);\n\n const updatedState =\n typeof newState === \"function\" ? (newState as Function)(coagentState.state) : newState;\n\n return {\n ...prevAgentStates,\n [name]: {\n ...coagentState,\n state: updatedState,\n },\n };\n });\n };\n\n const coagentState = getCoagentState(coagentStates, name);\n\n const state = isExternalStateManagement(options) ? options.state : coagentState.state;\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 }, [isExternalStateManagement(options) ? JSON.stringify(options.state) : undefined]);\n\n // Return the state and setState function\n return {\n name,\n nodeName: coagentState.nodeName,\n state,\n setState,\n running: coagentState.running,\n start: () => {\n startAgent(name, context);\n },\n stop: () => {\n stopAgent(name, context);\n },\n run: (hint?: HintFunction) => {\n return runAgent(name, context, appendMessage, hint);\n },\n };\n}\n\nfunction startAgent(name: string, context: CopilotContextParams) {\n const { setAgentSession } = context;\n setAgentSession({\n agentName: name,\n });\n}\n\nfunction stopAgent(name: string, context: CopilotContextParams) {\n const { agentSession, setAgentSession } = context;\n if (agentSession && agentSession.agentName === name) {\n setAgentSession(null);\n } else {\n console.warn(`No agent session found for ${name}`);\n }\n}\n\nasync function runAgent(\n name: string,\n context: CopilotContextParams & CopilotMessagesContextParams,\n appendMessage: (message: Message) => Promise<void>,\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.coagentStates?.[name]?.state || {};\n\n if (hint) {\n const hintMessage = hint({ previousState, currentState: state });\n if (hintMessage) {\n await appendMessage(hintMessage);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0FA,SAAS,iBAAiB;AAgHnB,SAAS,WAAoB,SAAwD;AAC1F,QAAM,4BAA4B,CAChCA,aAC8C;AAC9C,WAAO,WAAWA,YAAW,cAAcA;AAAA,EAC7C;AAEA,QAAM,EAAE,KAAK,IAAI;AAEjB,QAAM,uCAAuC,CAC3CA,aACwD;AACxD,WAAO,kBAAkBA;AAAA,EAC3B;AAEA,QAAM,iBAAiB,kBAAkB;AACzC,QAAM,kBAAkB,0BAA0B;AAClD,QAAM,UAAU,kCAAK,iBAAmB;AACxC,QAAM,EAAE,eAAe,iBAAiB,IAAI;AAC5C,QAAM,EAAE,cAAc,IAAI,eAAe;AAEzC,QAAM,kBAAkB,CAACC,gBAA6CC,UAAiB;AACrF,QAAID,eAAcC,KAAI,GAAG;AACvB,aAAOD,eAAcC,KAAI;AAAA,IAC3B,OAAO;AACL,aAAO;AAAA,QACL,MAAAA;AAAA,QACA,OAAO,qCAAqC,OAAO,IAAI,QAAQ,eAAe,CAAC;AAAA,QAC/E,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,UAAU;AAAA,QACV,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAGA,QAAM,WAAW,CAAC,aAAoD;AACpE,qBAAiB,CAAC,oBAAoB;AACpC,UAAIC,gBAA6B,gBAAgB,iBAAiB,IAAI;AAEtE,YAAM,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AA;AAtTF;AAuTE,UAAM,EAAE,cAAc,gBAAgB,IAAI;AAC1C,QAAI,CAAC,gBAAgB,aAAa,cAAc,MAAM;AACpD,sBAAgB;AAAA,QACd,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAEA,QAAI,gBAAqB;AACzB,aAAS,IAAI,QAAQ,SAAS,SAAS,GAAG,KAAK,GAAG,KAAK;AACrD,YAAM,UAAU,QAAQ,SAAS,CAAC;AAClC,UAAI,QAAQ,oBAAoB,KAAK,QAAQ,cAAc,MAAM;AAC/D,wBAAgB,QAAQ;AAAA,MAC1B;AAAA,IACF;AAEA,QAAI,UAAQ,mBAAQ,kBAAR,mBAAwB,UAAxB,mBAA+B,UAAS,CAAC;AAErD,QAAI,MAAM;AACR,YAAM,cAAc,KAAK,EAAE,eAAe,cAAc,MAAM,CAAC;AAC/D,UAAI,aAAa;AACf,cAAM,cAAc,WAAW;AAAA,MACjC;AAAA,IACF;AAAA,EACF;AAAA;","names":["options","coagentStates","name","coagentState"]}
|
package/dist/chunk-EFZPSZWO.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-EFZPSZWO.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/chunk-FXHKK52V.mjs
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defaultCopilotContextCategories
|
|
3
|
-
} from "./chunk-6OR25P32.mjs";
|
|
4
|
-
import {
|
|
5
|
-
__async
|
|
6
|
-
} from "./chunk-SKC7AJIV.mjs";
|
|
7
|
-
|
|
8
|
-
// src/lib/copilot-task.ts
|
|
9
|
-
import {
|
|
10
|
-
CopilotRuntimeClient,
|
|
11
|
-
Role,
|
|
12
|
-
TextMessage,
|
|
13
|
-
convertGqlOutputToMessages,
|
|
14
|
-
convertMessagesToGqlInput,
|
|
15
|
-
filterAgentStateMessages,
|
|
16
|
-
CopilotRequestType
|
|
17
|
-
} from "@copilotkit/runtime-client-gql";
|
|
18
|
-
import { actionParametersToJsonSchema } from "@copilotkit/shared";
|
|
19
|
-
var CopilotTask = class {
|
|
20
|
-
constructor(config) {
|
|
21
|
-
this.instructions = config.instructions;
|
|
22
|
-
this.actions = config.actions || [];
|
|
23
|
-
this.includeCopilotReadable = config.includeCopilotReadable !== false;
|
|
24
|
-
this.includeCopilotActions = config.includeCopilotActions !== false;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Run the task.
|
|
28
|
-
* @param context The CopilotContext to use for the task. Use `useCopilotContext` to obtain the current context.
|
|
29
|
-
* @param data The data to use for the task.
|
|
30
|
-
*/
|
|
31
|
-
run(context, data) {
|
|
32
|
-
return __async(this, null, function* () {
|
|
33
|
-
var _a, _b;
|
|
34
|
-
const actions = this.includeCopilotActions ? Object.assign({}, context.actions) : {};
|
|
35
|
-
for (const fn of this.actions) {
|
|
36
|
-
actions[fn.name] = fn;
|
|
37
|
-
}
|
|
38
|
-
let contextString = "";
|
|
39
|
-
if (data) {
|
|
40
|
-
contextString = (typeof data === "string" ? data : JSON.stringify(data)) + "\n\n";
|
|
41
|
-
}
|
|
42
|
-
if (this.includeCopilotReadable) {
|
|
43
|
-
contextString += context.getContextString([], defaultCopilotContextCategories);
|
|
44
|
-
}
|
|
45
|
-
const systemMessage = new TextMessage({
|
|
46
|
-
content: taskSystemMessage(contextString, this.instructions),
|
|
47
|
-
role: Role.System
|
|
48
|
-
});
|
|
49
|
-
const messages = [systemMessage];
|
|
50
|
-
const runtimeClient = new CopilotRuntimeClient({
|
|
51
|
-
url: context.copilotApiConfig.chatApiEndpoint,
|
|
52
|
-
publicApiKey: context.copilotApiConfig.publicApiKey,
|
|
53
|
-
headers: context.copilotApiConfig.headers,
|
|
54
|
-
credentials: context.copilotApiConfig.credentials
|
|
55
|
-
});
|
|
56
|
-
const response = yield runtimeClient.generateCopilotResponse({
|
|
57
|
-
data: {
|
|
58
|
-
frontend: {
|
|
59
|
-
actions: Object.values(actions).map((action) => ({
|
|
60
|
-
name: action.name,
|
|
61
|
-
description: action.description || "",
|
|
62
|
-
jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters || []))
|
|
63
|
-
})),
|
|
64
|
-
url: window.location.href
|
|
65
|
-
},
|
|
66
|
-
messages: convertMessagesToGqlInput(filterAgentStateMessages(messages)),
|
|
67
|
-
metadata: {
|
|
68
|
-
requestType: CopilotRequestType.Task
|
|
69
|
-
},
|
|
70
|
-
forwardedParameters: {
|
|
71
|
-
toolChoice: "required"
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
properties: context.copilotApiConfig.properties
|
|
75
|
-
}).toPromise();
|
|
76
|
-
const functionCallHandler = context.getFunctionCallHandler(actions);
|
|
77
|
-
const functionCalls = convertGqlOutputToMessages(
|
|
78
|
-
((_b = (_a = response.data) == null ? void 0 : _a.generateCopilotResponse) == null ? void 0 : _b.messages) || []
|
|
79
|
-
).filter((m) => m.isActionExecutionMessage());
|
|
80
|
-
for (const functionCall of functionCalls) {
|
|
81
|
-
yield functionCallHandler({
|
|
82
|
-
messages,
|
|
83
|
-
name: functionCall.name,
|
|
84
|
-
args: functionCall.arguments
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
function taskSystemMessage(contextString, instructions) {
|
|
91
|
-
return `
|
|
92
|
-
Please act as an efficient, competent, conscientious, and industrious professional assistant.
|
|
93
|
-
|
|
94
|
-
Help 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.
|
|
95
|
-
Always be polite and respectful, and prefer brevity over verbosity.
|
|
96
|
-
|
|
97
|
-
The user has provided you with the following context:
|
|
98
|
-
\`\`\`
|
|
99
|
-
${contextString}
|
|
100
|
-
\`\`\`
|
|
101
|
-
|
|
102
|
-
They have also provided you with functions you can call to initiate actions on their behalf.
|
|
103
|
-
|
|
104
|
-
Please assist them as best you can.
|
|
105
|
-
|
|
106
|
-
This is not a conversation, so please do not ask questions. Just call a function without saying anything else.
|
|
107
|
-
|
|
108
|
-
The user has given you the following task to complete:
|
|
109
|
-
|
|
110
|
-
\`\`\`
|
|
111
|
-
${instructions}
|
|
112
|
-
\`\`\`
|
|
113
|
-
`;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export {
|
|
117
|
-
CopilotTask
|
|
118
|
-
};
|
|
119
|
-
//# sourceMappingURL=chunk-FXHKK52V.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/copilot-task.ts"],"sourcesContent":["/**\n * This class is used to execute one-off tasks, for example on button press. It can use the context available via [useCopilotReadable](/reference/hooks/useCopilotReadable) and the actions provided by [useCopilotAction](/reference/hooks/useCopilotAction), or you can provide your own context and actions.\n *\n * ## Example\n * In the simplest case, use CopilotTask in the context of your app by giving it instructions on what to do.\n *\n * ```tsx\n * import { CopilotTask, useCopilotContext } from \"@copilotkit/react-core\";\n *\n * export function MyComponent() {\n * const context = useCopilotContext();\n *\n * const task = new CopilotTask({\n * instructions: \"Set a random message\",\n * actions: [\n * {\n * name: \"setMessage\",\n * description: \"Set the message.\",\n * argumentAnnotations: [\n * {\n * name: \"message\",\n * type: \"string\",\n * description:\n * \"A message to display.\",\n * required: true,\n * },\n * ],\n * }\n * ]\n * });\n *\n * const executeTask = async () => {\n * await task.run(context, action);\n * }\n *\n * return (\n * <>\n * <button onClick={executeTask}>\n * Execute task\n * </button>\n * </>\n * )\n * }\n * ```\n *\n * Have a look at the [Presentation Example App](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/examples/next-openai/src/app/presentation/page.tsx) for a more complete example.\n */\n\nimport {\n ActionExecutionMessage,\n CopilotRuntimeClient,\n Message,\n Role,\n TextMessage,\n convertGqlOutputToMessages,\n convertMessagesToGqlInput,\n filterAgentStateMessages,\n CopilotRequestType,\n} from \"@copilotkit/runtime-client-gql\";\nimport { FrontendAction } from \"../types/frontend-action\";\nimport { CopilotContextParams } from \"../context\";\nimport { defaultCopilotContextCategories } from \"../components\";\nimport { MessageStatusCode } from \"@copilotkit/runtime-client-gql\";\nimport { actionParametersToJsonSchema } from \"@copilotkit/shared\";\n\nexport interface CopilotTaskConfig {\n /**\n * The instructions to be given to the assistant.\n */\n instructions: string;\n /**\n * An array of action definitions that can be called.\n */\n actions?: FrontendAction<any>[];\n /**\n * Whether to include the copilot readable context in the task.\n */\n includeCopilotReadable?: boolean;\n\n /**\n * Whether to include actions defined via useCopilotAction in the task.\n */\n includeCopilotActions?: boolean;\n}\n\nexport class CopilotTask<T = any> {\n private instructions: string;\n private actions: FrontendAction<any>[];\n private includeCopilotReadable: boolean;\n private includeCopilotActions: boolean;\n\n constructor(config: CopilotTaskConfig) {\n this.instructions = config.instructions;\n this.actions = config.actions || [];\n this.includeCopilotReadable = config.includeCopilotReadable !== false;\n this.includeCopilotActions = config.includeCopilotActions !== false;\n }\n\n /**\n * Run the task.\n * @param context The CopilotContext to use for the task. Use `useCopilotContext` to obtain the current context.\n * @param data The data to use for the task.\n */\n async run(context: CopilotContextParams, data?: T): Promise<void> {\n const actions = this.includeCopilotActions ? Object.assign({}, context.actions) : {};\n\n // merge functions into entry points\n for (const fn of this.actions) {\n actions[fn.name] = fn;\n }\n\n let contextString = \"\";\n\n if (data) {\n contextString = (typeof data === \"string\" ? data : JSON.stringify(data)) + \"\\n\\n\";\n }\n\n if (this.includeCopilotReadable) {\n contextString += context.getContextString([], defaultCopilotContextCategories);\n }\n\n const systemMessage = new TextMessage({\n content: taskSystemMessage(contextString, this.instructions),\n role: Role.System,\n });\n\n const messages: Message[] = [systemMessage];\n\n const runtimeClient = new CopilotRuntimeClient({\n url: context.copilotApiConfig.chatApiEndpoint,\n publicApiKey: context.copilotApiConfig.publicApiKey,\n headers: context.copilotApiConfig.headers,\n credentials: context.copilotApiConfig.credentials,\n });\n\n const response = await runtimeClient\n .generateCopilotResponse({\n data: {\n frontend: {\n actions: Object.values(actions).map((action) => ({\n name: action.name,\n description: action.description || \"\",\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters || [])),\n })),\n url: window.location.href,\n },\n messages: convertMessagesToGqlInput(filterAgentStateMessages(messages)),\n metadata: {\n requestType: CopilotRequestType.Task,\n },\n forwardedParameters: {\n toolChoice: \"required\",\n },\n },\n properties: context.copilotApiConfig.properties,\n })\n .toPromise();\n\n const functionCallHandler = context.getFunctionCallHandler(actions);\n const functionCalls = convertGqlOutputToMessages(\n response.data?.generateCopilotResponse?.messages || [],\n ).filter((m): m is ActionExecutionMessage => m.isActionExecutionMessage());\n\n for (const functionCall of functionCalls) {\n await functionCallHandler({\n messages,\n name: functionCall.name,\n args: functionCall.arguments,\n });\n }\n }\n}\n\nfunction taskSystemMessage(contextString: string, instructions: string): string {\n return `\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.\n\nPlease assist them as best you can.\n\nThis is not a conversation, so please do not ask questions. Just call a function without saying anything else.\n\nThe user has given you the following task to complete:\n\n\\`\\`\\`\n${instructions}\n\\`\\`\\`\n`;\n}\n"],"mappings":";;;;;;;;AAgDA;AAAA,EAEE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKP,SAAS,oCAAoC;AAsBtC,IAAM,cAAN,MAA2B;AAAA,EAMhC,YAAY,QAA2B;AACrC,SAAK,eAAe,OAAO;AAC3B,SAAK,UAAU,OAAO,WAAW,CAAC;AAClC,SAAK,yBAAyB,OAAO,2BAA2B;AAChE,SAAK,wBAAwB,OAAO,0BAA0B;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA;AAAA;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AA,QACA,YAAY,QAAQ,iBAAiB;AAAA,MACvC,CAAC,EACA,UAAU;AAEb,YAAM,sBAAsB,QAAQ,uBAAuB,OAAO;AAClE,YAAM,gBAAgB;AAAA,UACpB,oBAAS,SAAT,mBAAe,4BAAf,mBAAwC,aAAY,CAAC;AAAA,MACvD,EAAE,OAAO,CAAC,MAAmC,EAAE,yBAAyB,CAAC;AAEzE,iBAAW,gBAAgB,eAAe;AACxC,cAAM,oBAAoB;AAAA,UACxB;AAAA,UACA,MAAM,aAAa;AAAA,UACnB,MAAM,aAAa;AAAA,QACrB,CAAC;AAAA,MACH;AAAA,IACF;AAAA;AACF;AAEA,SAAS,kBAAkB,eAAuB,cAA8B;AAC9E,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA;AAAA;AAAA;AAGF;","names":[]}
|
package/dist/chunk-H4VZMKR6.mjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useCopilotContext
|
|
3
|
-
} from "./chunk-LODRWFMB.mjs";
|
|
4
|
-
|
|
5
|
-
// src/hooks/use-make-copilot-document-readable.ts
|
|
6
|
-
import { useEffect, useRef } from "react";
|
|
7
|
-
function useMakeCopilotDocumentReadable(document, categories, dependencies = []) {
|
|
8
|
-
const { addDocumentContext, removeDocumentContext } = useCopilotContext();
|
|
9
|
-
const idRef = useRef();
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
const id = addDocumentContext(document, categories);
|
|
12
|
-
idRef.current = id;
|
|
13
|
-
return () => {
|
|
14
|
-
removeDocumentContext(id);
|
|
15
|
-
};
|
|
16
|
-
}, [addDocumentContext, removeDocumentContext, ...dependencies]);
|
|
17
|
-
return idRef.current;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
useMakeCopilotDocumentReadable
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=chunk-H4VZMKR6.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-make-copilot-document-readable.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { useCopilotContext } from \"../context/copilot-context\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Makes a document readable by Copilot.\n * @param document The document to make readable.\n * @param categories The categories to associate with the document.\n * @param dependencies The dependencies to use for the effect.\n * @returns The id of the document.\n */\nexport function useMakeCopilotDocumentReadable(\n document: DocumentPointer,\n categories?: string[],\n dependencies: any[] = [],\n): string | undefined {\n const { addDocumentContext, removeDocumentContext } = useCopilotContext();\n const idRef = useRef<string>();\n\n useEffect(() => {\n const id = addDocumentContext(document, categories);\n idRef.current = id;\n\n return () => {\n removeDocumentContext(id);\n };\n }, [addDocumentContext, removeDocumentContext, ...dependencies]);\n\n return idRef.current;\n}\n"],"mappings":";;;;;AAAA,SAAS,WAAW,cAAc;AAW3B,SAAS,+BACd,UACA,YACA,eAAsB,CAAC,GACH;AACpB,QAAM,EAAE,oBAAoB,sBAAsB,IAAI,kBAAkB;AACxE,QAAM,QAAQ,OAAe;AAE7B,YAAU,MAAM;AACd,UAAM,KAAK,mBAAmB,UAAU,UAAU;AAClD,UAAM,UAAU;AAEhB,WAAO,MAAM;AACX,4BAAsB,EAAE;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,oBAAoB,uBAAuB,GAAG,YAAY,CAAC;AAE/D,SAAO,MAAM;AACf;","names":[]}
|
package/dist/chunk-H7LSKIDK.mjs
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useChat
|
|
3
|
-
} from "./chunk-JDQCJCAQ.mjs";
|
|
4
|
-
import {
|
|
5
|
-
defaultCopilotContextCategories
|
|
6
|
-
} from "./chunk-6OR25P32.mjs";
|
|
7
|
-
import {
|
|
8
|
-
useCopilotContext
|
|
9
|
-
} from "./chunk-LODRWFMB.mjs";
|
|
10
|
-
import {
|
|
11
|
-
useCopilotMessagesContext
|
|
12
|
-
} from "./chunk-DCTJZ742.mjs";
|
|
13
|
-
import {
|
|
14
|
-
__async,
|
|
15
|
-
__objRest,
|
|
16
|
-
__spreadProps,
|
|
17
|
-
__spreadValues
|
|
18
|
-
} from "./chunk-SKC7AJIV.mjs";
|
|
19
|
-
|
|
20
|
-
// src/hooks/use-copilot-chat.ts
|
|
21
|
-
import { useRef, useEffect, useCallback } from "react";
|
|
22
|
-
import { Role, TextMessage } from "@copilotkit/runtime-client-gql";
|
|
23
|
-
function useCopilotChat(_a = {}) {
|
|
24
|
-
var _b = _a, {
|
|
25
|
-
makeSystemMessage
|
|
26
|
-
} = _b, options = __objRest(_b, [
|
|
27
|
-
"makeSystemMessage"
|
|
28
|
-
]);
|
|
29
|
-
const {
|
|
30
|
-
getContextString,
|
|
31
|
-
getFunctionCallHandler,
|
|
32
|
-
copilotApiConfig,
|
|
33
|
-
isLoading,
|
|
34
|
-
setIsLoading,
|
|
35
|
-
chatInstructions,
|
|
36
|
-
actions,
|
|
37
|
-
coagentStates,
|
|
38
|
-
setCoagentStates,
|
|
39
|
-
coAgentStateRenders,
|
|
40
|
-
agentSession,
|
|
41
|
-
setAgentSession
|
|
42
|
-
} = useCopilotContext();
|
|
43
|
-
const { messages, setMessages } = useCopilotMessagesContext();
|
|
44
|
-
const latestGetContextString = useUpdatedRef(getContextString);
|
|
45
|
-
const deleteMessage = useCallback(
|
|
46
|
-
(messageId) => {
|
|
47
|
-
setMessages((prev) => prev.filter((message) => message.id !== messageId));
|
|
48
|
-
},
|
|
49
|
-
[setMessages]
|
|
50
|
-
);
|
|
51
|
-
const makeSystemMessageCallback = useCallback(() => {
|
|
52
|
-
const systemMessageMaker = makeSystemMessage || defaultSystemMessage;
|
|
53
|
-
const contextString = latestGetContextString.current([], defaultCopilotContextCategories);
|
|
54
|
-
return new TextMessage({
|
|
55
|
-
content: systemMessageMaker(contextString, chatInstructions),
|
|
56
|
-
role: Role.System
|
|
57
|
-
});
|
|
58
|
-
}, [getContextString, makeSystemMessage, chatInstructions]);
|
|
59
|
-
const onCoAgentStateRender = useCallback(
|
|
60
|
-
(args) => __async(this, null, function* () {
|
|
61
|
-
var _a2;
|
|
62
|
-
const { name, nodeName, state } = args;
|
|
63
|
-
let action = Object.values(coAgentStateRenders).find(
|
|
64
|
-
(action2) => action2.name === name && action2.nodeName === nodeName
|
|
65
|
-
);
|
|
66
|
-
if (!action) {
|
|
67
|
-
action = Object.values(coAgentStateRenders).find(
|
|
68
|
-
(action2) => action2.name === name && !action2.nodeName
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
if (action) {
|
|
72
|
-
yield (_a2 = action.handler) == null ? void 0 : _a2.call(action, { state, nodeName });
|
|
73
|
-
}
|
|
74
|
-
}),
|
|
75
|
-
[coAgentStateRenders]
|
|
76
|
-
);
|
|
77
|
-
const { append, reload, stop } = useChat(__spreadProps(__spreadValues({}, options), {
|
|
78
|
-
actions: Object.values(actions),
|
|
79
|
-
copilotConfig: copilotApiConfig,
|
|
80
|
-
initialMessages: options.initialMessages || [],
|
|
81
|
-
onFunctionCall: getFunctionCallHandler(),
|
|
82
|
-
onCoAgentStateRender,
|
|
83
|
-
messages,
|
|
84
|
-
setMessages,
|
|
85
|
-
makeSystemMessageCallback,
|
|
86
|
-
isLoading,
|
|
87
|
-
setIsLoading,
|
|
88
|
-
coagentStates,
|
|
89
|
-
setCoagentStates,
|
|
90
|
-
agentSession,
|
|
91
|
-
setAgentSession
|
|
92
|
-
}));
|
|
93
|
-
const latestAppend = useUpdatedRef(append);
|
|
94
|
-
const latestAppendFunc = useCallback(
|
|
95
|
-
(message) => {
|
|
96
|
-
return latestAppend.current(message);
|
|
97
|
-
},
|
|
98
|
-
[latestAppend]
|
|
99
|
-
);
|
|
100
|
-
const latestReload = useUpdatedRef(reload);
|
|
101
|
-
const latestReloadFunc = useCallback(() => {
|
|
102
|
-
return latestReload.current();
|
|
103
|
-
}, [latestReload]);
|
|
104
|
-
const latestStop = useUpdatedRef(stop);
|
|
105
|
-
const latestStopFunc = useCallback(() => {
|
|
106
|
-
return latestStop.current();
|
|
107
|
-
}, [latestStop]);
|
|
108
|
-
const latestDelete = useUpdatedRef(deleteMessage);
|
|
109
|
-
const latestDeleteFunc = useCallback(
|
|
110
|
-
(messageId) => {
|
|
111
|
-
return latestDelete.current(messageId);
|
|
112
|
-
},
|
|
113
|
-
[latestDelete]
|
|
114
|
-
);
|
|
115
|
-
const latestSetMessages = useUpdatedRef(setMessages);
|
|
116
|
-
const latestSetMessagesFunc = useCallback(
|
|
117
|
-
(messages2) => {
|
|
118
|
-
return latestSetMessages.current(messages2);
|
|
119
|
-
},
|
|
120
|
-
[latestSetMessages]
|
|
121
|
-
);
|
|
122
|
-
return {
|
|
123
|
-
visibleMessages: messages,
|
|
124
|
-
appendMessage: latestAppendFunc,
|
|
125
|
-
setMessages: latestSetMessagesFunc,
|
|
126
|
-
reloadMessages: latestReloadFunc,
|
|
127
|
-
stopGeneration: latestStopFunc,
|
|
128
|
-
deleteMessage: latestDeleteFunc,
|
|
129
|
-
isLoading
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
function useUpdatedRef(value) {
|
|
133
|
-
const ref = useRef(value);
|
|
134
|
-
useEffect(() => {
|
|
135
|
-
ref.current = value;
|
|
136
|
-
}, [value]);
|
|
137
|
-
return ref;
|
|
138
|
-
}
|
|
139
|
-
function defaultSystemMessage(contextString, additionalInstructions) {
|
|
140
|
-
return `
|
|
141
|
-
Please act as an efficient, competent, conscientious, and industrious professional assistant.
|
|
142
|
-
|
|
143
|
-
Help 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.
|
|
144
|
-
Always be polite and respectful, and prefer brevity over verbosity.
|
|
145
|
-
|
|
146
|
-
The user has provided you with the following context:
|
|
147
|
-
\`\`\`
|
|
148
|
-
${contextString}
|
|
149
|
-
\`\`\`
|
|
150
|
-
|
|
151
|
-
They have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.
|
|
152
|
-
|
|
153
|
-
Please assist them as best you can.
|
|
154
|
-
|
|
155
|
-
You 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.
|
|
156
|
-
|
|
157
|
-
If you would like to call a function, call it without saying anything else.
|
|
158
|
-
` + (additionalInstructions ? `
|
|
159
|
-
|
|
160
|
-
${additionalInstructions}` : "");
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export {
|
|
164
|
-
useCopilotChat,
|
|
165
|
-
defaultSystemMessage
|
|
166
|
-
};
|
|
167
|
-
//# sourceMappingURL=chunk-H7LSKIDK.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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 * ```\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 * isLoading, // A boolean indicating if the chat is loading.\n * } = useCopilotChat();\n * ```\n */\nimport { useRef, useEffect, useCallback } from \"react\";\nimport { useCopilotContext } from \"../context/copilot-context\";\nimport { Message, Role, TextMessage } from \"@copilotkit/runtime-client-gql\";\nimport { SystemMessageFunction } from \"../types\";\nimport { useChat } from \"./use-chat\";\nimport { defaultCopilotContextCategories } from \"../components\";\nimport { MessageStatusCode } from \"@copilotkit/runtime-client-gql\";\nimport { CoAgentStateRenderHandlerArguments } from \"@copilotkit/shared\";\nimport { useCopilotMessagesContext } from \"../context\";\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 * System messages of the chat. Defaults to an empty array.\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 UseCopilotChatReturn {\n visibleMessages: Message[];\n appendMessage: (message: Message) => Promise<void>;\n setMessages: (messages: Message[]) => void;\n deleteMessage: (messageId: string) => void;\n reloadMessages: () => Promise<void>;\n stopGeneration: () => void;\n isLoading: boolean;\n}\n\nexport function useCopilotChat({\n makeSystemMessage,\n ...options\n}: UseCopilotChatOptions = {}): UseCopilotChatReturn {\n const {\n getContextString,\n getFunctionCallHandler,\n copilotApiConfig,\n isLoading,\n setIsLoading,\n chatInstructions,\n actions,\n\n coagentStates,\n setCoagentStates,\n coAgentStateRenders,\n agentSession,\n setAgentSession,\n } = useCopilotContext();\n const { messages, setMessages } = useCopilotMessagesContext();\n\n // We need to ensure that makeSystemMessageCallback always uses the latest\n // useCopilotReadable data.\n const latestGetContextString = useUpdatedRef(getContextString);\n const deleteMessage = useCallback(\n (messageId: string) => {\n setMessages((prev) => prev.filter((message) => message.id !== messageId));\n },\n [setMessages],\n );\n\n const makeSystemMessageCallback = useCallback(() => {\n const systemMessageMaker = makeSystemMessage || defaultSystemMessage;\n // this always gets the latest context string\n const contextString = latestGetContextString.current([], defaultCopilotContextCategories); // TODO: make the context categories configurable\n\n return new TextMessage({\n content: systemMessageMaker(contextString, chatInstructions),\n role: Role.System,\n });\n }, [getContextString, makeSystemMessage, chatInstructions]);\n\n const onCoAgentStateRender = useCallback(\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 { append, reload, stop } = useChat({\n ...options,\n actions: Object.values(actions),\n copilotConfig: copilotApiConfig,\n initialMessages: options.initialMessages || [],\n onFunctionCall: getFunctionCallHandler(),\n onCoAgentStateRender,\n messages,\n setMessages,\n makeSystemMessageCallback,\n isLoading,\n setIsLoading,\n coagentStates,\n setCoagentStates,\n agentSession,\n setAgentSession,\n });\n\n // this is a workaround born out of a bug that Athena insessently ran into.\n // We could not find the origin of the bug, however, it was clear that an outdated version of the append function was being used somehow --\n // it referecned the old state of the messages array, and not the latest one.\n //\n // We want to make copilotkit as abuse-proof as possible, so we are adding this workaround to ensure that the latest version of the append function is always used.\n //\n // How does this work?\n // we store the relevant function in a ref that is always up-to-date, and then we use that ref in the callback.\n const latestAppend = useUpdatedRef(append);\n const latestAppendFunc = useCallback(\n (message: Message) => {\n return latestAppend.current(message);\n },\n [latestAppend],\n );\n\n const latestReload = useUpdatedRef(reload);\n const latestReloadFunc = useCallback(() => {\n return latestReload.current();\n }, [latestReload]);\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(messages);\n },\n [latestSetMessages],\n );\n\n return {\n visibleMessages: messages,\n appendMessage: latestAppendFunc,\n setMessages: latestSetMessagesFunc,\n reloadMessages: latestReloadFunc,\n stopGeneration: latestStopFunc,\n deleteMessage: latestDeleteFunc,\n isLoading,\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.\n` + (additionalInstructions ? `\\n\\n${additionalInstructions}` : \"\")\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,SAAS,QAAQ,WAAW,mBAAmB;AAE/C,SAAkB,MAAM,mBAAmB;AAyCpC,SAAS,eAAe,KAGJ,CAAC,GAAyB;AAHtB,eAC7B;AAAA;AAAA,EApFF,IAmF+B,IAE1B,oBAF0B,IAE1B;AAAA,IADH;AAAA;AAGA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,kBAAkB;AACtB,QAAM,EAAE,UAAU,YAAY,IAAI,0BAA0B;AAI5D,QAAM,yBAAyB,cAAc,gBAAgB;AAC7D,QAAM,gBAAgB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