@copilotkit/react-core 1.5.15-next.2 → 1.5.15-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 +18 -0
- package/dist/{chunk-DZCTHC4G.mjs → chunk-5SGZKEPX.mjs} +3 -3
- package/dist/chunk-6PNZ77RB.mjs +66 -0
- package/dist/chunk-6PNZ77RB.mjs.map +1 -0
- package/dist/{chunk-7QGQVBD7.mjs → chunk-7HWSAEOY.mjs} +2 -2
- package/dist/{chunk-YJT6IYNV.mjs → chunk-AL3MOOKF.mjs} +2 -2
- package/dist/{chunk-67W2A4DM.mjs → chunk-DEPX7JPX.mjs} +10 -6
- package/dist/chunk-DEPX7JPX.mjs.map +1 -0
- package/dist/{chunk-KGCYVAIN.mjs → chunk-FMROB4TE.mjs} +49 -10
- package/dist/chunk-FMROB4TE.mjs.map +1 -0
- package/dist/{chunk-PMHLIIAI.mjs → chunk-GANI4ZZM.mjs} +3 -3
- package/dist/{chunk-VEQGQAGN.mjs → chunk-H2OR7FUU.mjs} +2 -2
- package/dist/chunk-IGLITGLC.mjs +1 -0
- package/dist/{chunk-V74U56PX.mjs → chunk-IHWTLSHY.mjs} +2 -2
- package/dist/{chunk-TJTOQRGB.mjs → chunk-IU7OLWWW.mjs} +26 -6
- package/dist/chunk-IU7OLWWW.mjs.map +1 -0
- package/dist/{chunk-GPWNMXSU.mjs → chunk-WU53OU3E.mjs} +2 -2
- package/dist/{chunk-S5MSFDGS.mjs → chunk-XOHLZIZK.mjs} +2 -2
- package/dist/chunk-ZAU4EMBM.mjs +48 -0
- package/dist/chunk-ZAU4EMBM.mjs.map +1 -0
- package/dist/{chunk-RKYHRYN3.mjs → chunk-ZM56S3LJ.mjs} +5 -2
- package/dist/chunk-ZM56S3LJ.mjs.map +1 -0
- 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 +2 -2
- package/dist/components/copilot-provider/copilotkit-props.d.ts +1 -0
- package/dist/components/copilot-provider/copilotkit.d.ts +1 -0
- package/dist/components/copilot-provider/copilotkit.js +25 -2
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +3 -3
- package/dist/components/copilot-provider/index.d.ts +1 -0
- package/dist/components/copilot-provider/index.js +25 -2
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +3 -3
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +25 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +3 -3
- package/dist/context/copilot-context.d.ts +5 -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 -0
- package/dist/context/index.js +4 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +150 -13
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +20 -12
- package/dist/hooks/use-chat.d.ts +4 -1
- package/dist/hooks/use-chat.js +45 -7
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +1 -1
- 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 +1 -0
- package/dist/hooks/use-coagent.js +58 -13
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +6 -6
- 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-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 +2 -1
- package/dist/hooks/use-copilot-chat.js +58 -13
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +5 -5
- 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.d.ts +5 -0
- package/dist/hooks/use-langgraph-interrupt-render.js +184 -0
- package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -0
- package/dist/hooks/use-langgraph-interrupt-render.mjs +11 -0
- package/dist/hooks/use-langgraph-interrupt-render.mjs.map +1 -0
- package/dist/hooks/use-langgraph-interrupt.d.ts +7 -0
- package/dist/hooks/use-langgraph-interrupt.js +1050 -0
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -0
- package/dist/hooks/use-langgraph-interrupt.mjs +25 -0
- package/dist/hooks/use-langgraph-interrupt.mjs.map +1 -0
- 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 +3 -0
- package/dist/index.js +178 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -13
- package/dist/lib/copilot-task.d.ts +1 -0
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +4 -4
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +4 -4
- package/dist/types/interrupt-action.d.ts +35 -0
- package/dist/types/interrupt-action.js +19 -0
- package/dist/types/interrupt-action.js.map +1 -0
- package/dist/types/interrupt-action.mjs +1 -0
- package/dist/types/interrupt-action.mjs.map +1 -0
- package/dist/utils/extract.d.ts +1 -0
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +3 -3
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +3 -3
- package/package.json +3 -3
- package/src/components/copilot-provider/copilotkit.tsx +25 -0
- package/src/context/copilot-context.tsx +12 -3
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-chat.ts +52 -1
- package/src/hooks/use-copilot-chat.ts +4 -0
- package/src/hooks/use-langgraph-interrupt-render.ts +63 -0
- package/src/hooks/use-langgraph-interrupt.ts +62 -0
- package/src/types/interrupt-action.ts +35 -0
- package/dist/chunk-67W2A4DM.mjs.map +0 -1
- package/dist/chunk-KGCYVAIN.mjs.map +0 -1
- package/dist/chunk-NR2BTA6Z.mjs +0 -1
- package/dist/chunk-RKYHRYN3.mjs.map +0 -1
- package/dist/chunk-TJTOQRGB.mjs.map +0 -1
- /package/dist/{chunk-DZCTHC4G.mjs.map → chunk-5SGZKEPX.mjs.map} +0 -0
- /package/dist/{chunk-7QGQVBD7.mjs.map → chunk-7HWSAEOY.mjs.map} +0 -0
- /package/dist/{chunk-YJT6IYNV.mjs.map → chunk-AL3MOOKF.mjs.map} +0 -0
- /package/dist/{chunk-PMHLIIAI.mjs.map → chunk-GANI4ZZM.mjs.map} +0 -0
- /package/dist/{chunk-VEQGQAGN.mjs.map → chunk-H2OR7FUU.mjs.map} +0 -0
- /package/dist/{chunk-NR2BTA6Z.mjs.map → chunk-IGLITGLC.mjs.map} +0 -0
- /package/dist/{chunk-V74U56PX.mjs.map → chunk-IHWTLSHY.mjs.map} +0 -0
- /package/dist/{chunk-GPWNMXSU.mjs.map → chunk-WU53OU3E.mjs.map} +0 -0
- /package/dist/{chunk-S5MSFDGS.mjs.map → chunk-XOHLZIZK.mjs.map} +0 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var __async = (__this, __arguments, generator) => {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
var fulfilled = (value) => {
|
|
32
|
+
try {
|
|
33
|
+
step(generator.next(value));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
reject(e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var rejected = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.throw(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
46
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/hooks/use-langgraph-interrupt-render.ts
|
|
51
|
+
var use_langgraph_interrupt_render_exports = {};
|
|
52
|
+
__export(use_langgraph_interrupt_render_exports, {
|
|
53
|
+
useLangGraphInterruptRender: () => useLangGraphInterruptRender
|
|
54
|
+
});
|
|
55
|
+
module.exports = __toCommonJS(use_langgraph_interrupt_render_exports);
|
|
56
|
+
|
|
57
|
+
// src/context/copilot-context.tsx
|
|
58
|
+
var import_react = __toESM(require("react"));
|
|
59
|
+
var emptyCopilotContext = {
|
|
60
|
+
actions: {},
|
|
61
|
+
setAction: () => {
|
|
62
|
+
},
|
|
63
|
+
removeAction: () => {
|
|
64
|
+
},
|
|
65
|
+
coAgentStateRenders: {},
|
|
66
|
+
setCoAgentStateRender: () => {
|
|
67
|
+
},
|
|
68
|
+
removeCoAgentStateRender: () => {
|
|
69
|
+
},
|
|
70
|
+
chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },
|
|
71
|
+
getContextString: (documents, categories) => returnAndThrowInDebug(""),
|
|
72
|
+
addContext: () => "",
|
|
73
|
+
removeContext: () => {
|
|
74
|
+
},
|
|
75
|
+
getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
|
|
76
|
+
})),
|
|
77
|
+
isLoading: false,
|
|
78
|
+
setIsLoading: () => returnAndThrowInDebug(false),
|
|
79
|
+
chatInstructions: "",
|
|
80
|
+
setChatInstructions: () => returnAndThrowInDebug(""),
|
|
81
|
+
getDocumentsContext: (categories) => returnAndThrowInDebug([]),
|
|
82
|
+
addDocumentContext: () => returnAndThrowInDebug(""),
|
|
83
|
+
removeDocumentContext: () => {
|
|
84
|
+
},
|
|
85
|
+
runtimeClient: {},
|
|
86
|
+
copilotApiConfig: new class {
|
|
87
|
+
get chatApiEndpoint() {
|
|
88
|
+
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
89
|
+
}
|
|
90
|
+
get headers() {
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
93
|
+
get body() {
|
|
94
|
+
return {};
|
|
95
|
+
}
|
|
96
|
+
}(),
|
|
97
|
+
chatSuggestionConfiguration: {},
|
|
98
|
+
addChatSuggestionConfiguration: () => {
|
|
99
|
+
},
|
|
100
|
+
removeChatSuggestionConfiguration: () => {
|
|
101
|
+
},
|
|
102
|
+
showDevConsole: "auto",
|
|
103
|
+
coagentStates: {},
|
|
104
|
+
setCoagentStates: () => {
|
|
105
|
+
},
|
|
106
|
+
coagentStatesRef: { current: {} },
|
|
107
|
+
setCoagentStatesWithRef: () => {
|
|
108
|
+
},
|
|
109
|
+
agentSession: null,
|
|
110
|
+
setAgentSession: () => {
|
|
111
|
+
},
|
|
112
|
+
forwardedParameters: {},
|
|
113
|
+
agentLock: null,
|
|
114
|
+
threadId: "",
|
|
115
|
+
setThreadId: () => {
|
|
116
|
+
},
|
|
117
|
+
runId: null,
|
|
118
|
+
setRunId: () => {
|
|
119
|
+
},
|
|
120
|
+
chatAbortControllerRef: { current: null },
|
|
121
|
+
availableAgents: [],
|
|
122
|
+
extensions: {},
|
|
123
|
+
setExtensions: () => {
|
|
124
|
+
},
|
|
125
|
+
langGraphInterruptAction: null,
|
|
126
|
+
setLangGraphInterruptAction: () => null,
|
|
127
|
+
removeLangGraphInterruptAction: () => null
|
|
128
|
+
};
|
|
129
|
+
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
130
|
+
function useCopilotContext() {
|
|
131
|
+
const context = import_react.default.useContext(CopilotContext);
|
|
132
|
+
if (context === emptyCopilotContext) {
|
|
133
|
+
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
134
|
+
}
|
|
135
|
+
return context;
|
|
136
|
+
}
|
|
137
|
+
function returnAndThrowInDebug(_value) {
|
|
138
|
+
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// src/hooks/use-langgraph-interrupt-render.ts
|
|
142
|
+
var import_react2 = __toESM(require("react"));
|
|
143
|
+
var import_shared = require("@copilotkit/shared");
|
|
144
|
+
var InterruptRenderer = ({ event, result, render, resolve }) => {
|
|
145
|
+
return render({ event, result, resolve });
|
|
146
|
+
};
|
|
147
|
+
function useLangGraphInterruptRender() {
|
|
148
|
+
const { langGraphInterruptAction, setLangGraphInterruptAction } = useCopilotContext();
|
|
149
|
+
const responseRef = import_react2.default.useRef();
|
|
150
|
+
const resolveInterrupt = (0, import_react2.useCallback)(
|
|
151
|
+
(response) => {
|
|
152
|
+
responseRef.current = response;
|
|
153
|
+
setTimeout(() => {
|
|
154
|
+
setLangGraphInterruptAction({ event: { response } });
|
|
155
|
+
}, 0);
|
|
156
|
+
},
|
|
157
|
+
[setLangGraphInterruptAction]
|
|
158
|
+
);
|
|
159
|
+
if (!langGraphInterruptAction || !langGraphInterruptAction.event || !langGraphInterruptAction.render)
|
|
160
|
+
return null;
|
|
161
|
+
const { render, handler, event, conditions } = langGraphInterruptAction;
|
|
162
|
+
const conditionsMet = (0, import_shared.executeConditions)({ conditions, value: event.value });
|
|
163
|
+
if (!conditionsMet) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
let result = null;
|
|
167
|
+
if (handler) {
|
|
168
|
+
result = handler({
|
|
169
|
+
event,
|
|
170
|
+
resolve: resolveInterrupt
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return import_react2.default.createElement(InterruptRenderer, {
|
|
174
|
+
event,
|
|
175
|
+
result,
|
|
176
|
+
render,
|
|
177
|
+
resolve: resolveInterrupt
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
181
|
+
0 && (module.exports = {
|
|
182
|
+
useLangGraphInterruptRender
|
|
183
|
+
});
|
|
184
|
+
//# sourceMappingURL=use-langgraph-interrupt-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-langgraph-interrupt-render.ts","../../src/context/copilot-context.tsx"],"sourcesContent":["import { useCopilotContext } from \"../context\";\nimport React, { useCallback } from \"react\";\nimport { executeConditions } from \"@copilotkit/shared\";\n\ntype InterruptProps = {\n event: any;\n result: any;\n render: (props: {\n event: any;\n result: any;\n resolve: (response: string) => void;\n }) => string | React.ReactElement;\n resolve: (response: string) => void;\n};\n\nconst InterruptRenderer: React.FC<InterruptProps> = ({ event, result, render, resolve }) => {\n return render({ event, result, resolve });\n};\n\nexport function useLangGraphInterruptRender(): string | React.ReactElement | null {\n const { langGraphInterruptAction, setLangGraphInterruptAction } = useCopilotContext();\n\n const responseRef = React.useRef<string>();\n const resolveInterrupt = useCallback(\n (response: string) => {\n responseRef.current = response;\n // Use setTimeout to defer the state update to next tick\n setTimeout(() => {\n setLangGraphInterruptAction({ event: { response } });\n }, 0);\n },\n [setLangGraphInterruptAction],\n );\n\n if (\n !langGraphInterruptAction ||\n !langGraphInterruptAction.event ||\n !langGraphInterruptAction.render\n )\n return null;\n\n const { render, handler, event, conditions } = langGraphInterruptAction;\n\n const conditionsMet = executeConditions({ conditions, value: event.value });\n if (!conditionsMet) {\n return null;\n }\n\n let result = null;\n if (handler) {\n result = handler({\n event,\n resolve: resolveInterrupt,\n });\n }\n\n return React.createElement(InterruptRenderer, {\n event,\n result,\n render,\n resolve: resolveInterrupt,\n });\n}\n","import { CopilotCloudConfig, FunctionCallHandler } from \"@copilotkit/shared\";\nimport {\n ActionRenderProps,\n CatchAllActionRenderProps,\n FrontendAction,\n} from \"../types/frontend-action\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { DocumentPointer } from \"../types\";\nimport { CopilotChatSuggestionConfiguration } from \"../types/chat-suggestion-configuration\";\nimport { CoAgentStateRender, CoAgentStateRenderProps } from \"../types/coagent-action\";\nimport { CoagentState } from \"../types/coagent-state\";\nimport {\n CopilotRuntimeClient,\n ExtensionsInput,\n ForwardedParametersInput,\n} from \"@copilotkit/runtime-client-gql\";\nimport { Agent } from \"@copilotkit/runtime-client-gql\";\nimport {\n LangGraphInterruptAction,\n LangGraphInterruptActionSetter,\n} from \"../types/interrupt-action\";\n\n/**\n * Interface for the configuration of the Copilot API.\n */\nexport interface CopilotApiConfig {\n /**\n * The public API key for Copilot Cloud.\n */\n publicApiKey?: string;\n\n /**\n * The configuration for Copilot Cloud.\n */\n cloud?: CopilotCloudConfig;\n\n /**\n * The endpoint for the chat API.\n */\n chatApiEndpoint: string;\n\n /**\n * The endpoint for the Copilot transcribe audio service.\n */\n transcribeAudioUrl?: string;\n\n /**\n * The endpoint for the Copilot text to speech service.\n */\n textToSpeechUrl?: string;\n\n /**\n * additional headers to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'Authorization': 'Bearer your_token_here'\n * }\n * ```\n */\n headers: Record<string, string>;\n\n /**\n * Custom properties to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'user_id': 'user_id'\n * }\n * ```\n */\n properties?: Record<string, any>;\n\n /**\n * Indicates whether the user agent should send or receive cookies from the other domain\n * in the case of cross-origin requests.\n */\n credentials?: RequestCredentials;\n}\n\nexport type InChatRenderFunction<TProps = ActionRenderProps<any> | CatchAllActionRenderProps<any>> =\n (props: TProps) => string | JSX.Element;\nexport type CoagentInChatRenderFunction = (\n props: CoAgentStateRenderProps<any>,\n) => string | JSX.Element | undefined | null;\n\nexport interface ChatComponentsCache {\n actions: Record<string, InChatRenderFunction | string>;\n coAgentStateRenders: Record<string, CoagentInChatRenderFunction | string>;\n}\n\nexport interface AgentSession {\n agentName: string;\n threadId?: string;\n nodeName?: string;\n}\n\nexport interface AuthState {\n status: \"authenticated\" | \"unauthenticated\";\n authHeaders: Record<string, string>;\n userId?: string;\n metadata?: Record<string, any>;\n}\n\nexport type ActionName = string;\n\nexport interface CopilotContextParams {\n // function-calling\n actions: Record<string, FrontendAction<any>>;\n setAction: (id: string, action: FrontendAction<any>) => void;\n removeAction: (id: string) => void;\n\n // coagent actions\n coAgentStateRenders: Record<string, CoAgentStateRender<any>>;\n setCoAgentStateRender: (id: string, stateRender: CoAgentStateRender<any>) => void;\n removeCoAgentStateRender: (id: string) => void;\n\n chatComponentsCache: React.RefObject<ChatComponentsCache>;\n\n getFunctionCallHandler: (\n customEntryPoints?: Record<string, FrontendAction<any>>,\n ) => FunctionCallHandler;\n\n // text context\n addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n getContextString: (documents: DocumentPointer[], categories: string[]) => string;\n\n // document context\n addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n getDocumentsContext: (categories: string[]) => DocumentPointer[];\n\n isLoading: boolean;\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;\n\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration };\n addChatSuggestionConfiguration: (\n id: string,\n suggestion: CopilotChatSuggestionConfiguration,\n ) => void;\n removeChatSuggestionConfiguration: (id: string) => void;\n\n chatInstructions: string;\n setChatInstructions: React.Dispatch<React.SetStateAction<string>>;\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n\n showDevConsole: boolean | \"auto\";\n\n // agents\n coagentStates: Record<string, CoagentState>;\n setCoagentStates: React.Dispatch<React.SetStateAction<Record<string, CoagentState>>>;\n coagentStatesRef: React.RefObject<Record<string, CoagentState>>;\n setCoagentStatesWithRef: (\n value:\n | Record<string, CoagentState>\n | ((prev: Record<string, CoagentState>) => Record<string, CoagentState>),\n ) => void;\n\n agentSession: AgentSession | null;\n setAgentSession: React.Dispatch<React.SetStateAction<AgentSession | null>>;\n\n agentLock: string | null;\n\n threadId: string;\n setThreadId: React.Dispatch<React.SetStateAction<string>>;\n\n runId: string | null;\n setRunId: React.Dispatch<React.SetStateAction<string | null>>;\n\n // The chat abort controller can be used to stop generation globally,\n // i.e. when using `stop()` from `useChat`\n chatAbortControllerRef: React.MutableRefObject<AbortController | null>;\n\n // runtime\n runtimeClient: CopilotRuntimeClient;\n\n /**\n * The forwarded parameters to use for the task.\n */\n forwardedParameters?: Pick<ForwardedParametersInput, \"temperature\">;\n availableAgents: Agent[];\n\n /**\n * The auth states for the CopilotKit.\n */\n authStates_c?: Record<ActionName, AuthState>;\n setAuthStates_c?: React.Dispatch<React.SetStateAction<Record<ActionName, AuthState>>>;\n\n /**\n * The auth config for the CopilotKit.\n */\n authConfig_c?: {\n SignInComponent: React.ComponentType<{\n onSignInComplete: (authState: AuthState) => void;\n }>;\n };\n\n extensions: ExtensionsInput;\n setExtensions: React.Dispatch<React.SetStateAction<ExtensionsInput>>;\n langGraphInterruptAction: LangGraphInterruptAction | null;\n setLangGraphInterruptAction: LangGraphInterruptActionSetter;\n removeLangGraphInterruptAction: () => void;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n actions: {},\n setAction: () => {},\n removeAction: () => {},\n\n coAgentStateRenders: {},\n setCoAgentStateRender: () => {},\n removeCoAgentStateRender: () => {},\n\n chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },\n getContextString: (documents: DocumentPointer[], categories: string[]) =>\n returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n isLoading: false,\n setIsLoading: () => returnAndThrowInDebug(false),\n\n chatInstructions: \"\",\n setChatInstructions: () => returnAndThrowInDebug(\"\"),\n\n getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\n runtimeClient: {} as any,\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n\n get headers(): Record<string, string> {\n return {};\n }\n get body(): Record<string, any> {\n return {};\n }\n })(),\n\n chatSuggestionConfiguration: {},\n addChatSuggestionConfiguration: () => {},\n removeChatSuggestionConfiguration: () => {},\n showDevConsole: \"auto\",\n coagentStates: {},\n setCoagentStates: () => {},\n coagentStatesRef: { current: {} },\n setCoagentStatesWithRef: () => {},\n agentSession: null,\n setAgentSession: () => {},\n forwardedParameters: {},\n agentLock: null,\n threadId: \"\",\n setThreadId: () => {},\n runId: null,\n setRunId: () => {},\n chatAbortControllerRef: { current: null },\n availableAgents: [],\n extensions: {},\n setExtensions: () => {},\n langGraphInterruptAction: null,\n setLangGraphInterruptAction: () => null,\n removeLangGraphInterruptAction: () => null,\n};\n\nexport const CopilotContext = React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nexport function useCopilotContext(): CopilotContextParams {\n const context = React.useContext(CopilotContext);\n if (context === emptyCopilotContext) {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n return context;\n}\n\nfunction returnAndThrowInDebug<T>(_value: T): T {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,mBAAkB;AA4MlB,IAAM,sBAA4C;AAAA,EAChD,SAAS,CAAC;AAAA,EACV,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB,cAAc,MAAM;AAAA,EAAC;AAAA,EAErB,qBAAqB,CAAC;AAAA,EACtB,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAC9B,0BAA0B,MAAM;AAAA,EAAC;AAAA,EAEjC,qBAAqB,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,qBAAqB,CAAC,EAAE,EAAE;AAAA,EACzE,kBAAkB,CAAC,WAA8B,eAC/C,sBAAsB,EAAE;AA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A;AAAA,IACA;AAAA,IACA,SAAS;AAAA,EACX,CAAC;AACH;","names":["React","import_react","React"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useLangGraphInterruptRender
|
|
3
|
+
} from "../chunk-ZAU4EMBM.mjs";
|
|
4
|
+
import "../chunk-YPSGKPDA.mjs";
|
|
5
|
+
import "../chunk-ZM56S3LJ.mjs";
|
|
6
|
+
import "../chunk-DCTJZ742.mjs";
|
|
7
|
+
import "../chunk-SKC7AJIV.mjs";
|
|
8
|
+
export {
|
|
9
|
+
useLangGraphInterruptRender
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=use-langgraph-interrupt-render.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LangGraphInterruptRender } from '../types/interrupt-action.js';
|
|
2
|
+
import '@copilotkit/runtime-client-gql';
|
|
3
|
+
import '@copilotkit/shared';
|
|
4
|
+
|
|
5
|
+
declare function useLangGraphInterrupt(action: Omit<LangGraphInterruptRender, "id">, dependencies?: any[]): void;
|
|
6
|
+
|
|
7
|
+
export { useLangGraphInterrupt };
|