@copilotkit/react-core 1.5.9 → 1.5.10-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/chunk-22XKTBPF.mjs +61 -0
- package/dist/chunk-22XKTBPF.mjs.map +1 -0
- package/dist/chunk-2KT73RVG.mjs +482 -0
- package/dist/chunk-2KT73RVG.mjs.map +1 -0
- package/dist/chunk-3GQPEN4M.mjs +160 -0
- package/dist/chunk-3GQPEN4M.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-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-EWKJMQOF.mjs +107 -0
- package/dist/chunk-EWKJMQOF.mjs.map +1 -0
- package/dist/chunk-FQ53HQYZ.mjs +28 -0
- package/dist/chunk-FQ53HQYZ.mjs.map +1 -0
- package/dist/chunk-HIUT2NLX.mjs +23 -0
- package/dist/chunk-HIUT2NLX.mjs.map +1 -0
- package/dist/chunk-LHKIIAUQ.mjs +59 -0
- package/dist/chunk-LHKIIAUQ.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-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-VGOFRULA.mjs +401 -0
- package/dist/chunk-VGOFRULA.mjs.map +1 -0
- package/dist/chunk-VNTDIJSG.mjs +37 -0
- package/dist/chunk-VNTDIJSG.mjs.map +1 -0
- package/dist/chunk-WXREY7UP.mjs +87 -0
- package/dist/chunk-WXREY7UP.mjs.map +1 -0
- package/dist/chunk-X36DNILG.mjs +215 -0
- package/dist/chunk-X36DNILG.mjs.map +1 -0
- package/dist/chunk-XERJQUHA.mjs +31 -0
- package/dist/chunk-XERJQUHA.mjs.map +1 -0
- package/dist/chunk-XOQMISG3.mjs +120 -0
- package/dist/chunk-XOQMISG3.mjs.map +1 -0
- package/dist/chunk-XXR4QFAQ.mjs +29 -0
- package/dist/chunk-XXR4QFAQ.mjs.map +1 -0
- package/dist/chunk-YPSGKPDA.mjs +1 -0
- package/dist/chunk-YPSGKPDA.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.d.ts +16 -0
- package/dist/components/copilot-provider/copilot-messages.js +80 -0
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.mjs +9 -0
- package/dist/components/copilot-provider/copilot-messages.mjs.map +1 -0
- package/dist/components/copilot-provider/copilotkit-props.d.ts +93 -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 +990 -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 +990 -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 +990 -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 +142 -0
- package/dist/context/copilot-context.js +138 -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 +161 -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 +1303 -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 +124 -0
- package/dist/hooks/use-chat.js +608 -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 +195 -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 +1064 -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 +369 -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 +418 -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 +38 -0
- package/dist/hooks/use-copilot-chat.js +928 -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 +158 -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 +153 -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 +2224 -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/package.json +3 -3
|
@@ -0,0 +1,990 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __restKey = (key) => typeof key === "symbol" ? key : key + "";
|
|
26
|
+
var __objRest = (source, exclude) => {
|
|
27
|
+
var target = {};
|
|
28
|
+
for (var prop in source)
|
|
29
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
30
|
+
target[prop] = source[prop];
|
|
31
|
+
if (source != null && __getOwnPropSymbols)
|
|
32
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
33
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
34
|
+
target[prop] = source[prop];
|
|
35
|
+
}
|
|
36
|
+
return target;
|
|
37
|
+
};
|
|
38
|
+
var __export = (target, all) => {
|
|
39
|
+
for (var name in all)
|
|
40
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
41
|
+
};
|
|
42
|
+
var __copyProps = (to, from, except, desc) => {
|
|
43
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
44
|
+
for (let key of __getOwnPropNames(from))
|
|
45
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
46
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
47
|
+
}
|
|
48
|
+
return to;
|
|
49
|
+
};
|
|
50
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
51
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
52
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
53
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
54
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
55
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
56
|
+
mod
|
|
57
|
+
));
|
|
58
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
59
|
+
var __async = (__this, __arguments, generator) => {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
var fulfilled = (value) => {
|
|
62
|
+
try {
|
|
63
|
+
step(generator.next(value));
|
|
64
|
+
} catch (e) {
|
|
65
|
+
reject(e);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var rejected = (value) => {
|
|
69
|
+
try {
|
|
70
|
+
step(generator.throw(value));
|
|
71
|
+
} catch (e) {
|
|
72
|
+
reject(e);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
76
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/components/copilot-provider/copilotkit.tsx
|
|
81
|
+
var copilotkit_exports = {};
|
|
82
|
+
__export(copilotkit_exports, {
|
|
83
|
+
CopilotKit: () => CopilotKit,
|
|
84
|
+
CopilotKitInternal: () => CopilotKitInternal,
|
|
85
|
+
defaultCopilotContextCategories: () => defaultCopilotContextCategories
|
|
86
|
+
});
|
|
87
|
+
module.exports = __toCommonJS(copilotkit_exports);
|
|
88
|
+
var import_react10 = require("react");
|
|
89
|
+
|
|
90
|
+
// src/context/copilot-context.tsx
|
|
91
|
+
var import_react = __toESM(require("react"));
|
|
92
|
+
var emptyCopilotContext = {
|
|
93
|
+
actions: {},
|
|
94
|
+
setAction: () => {
|
|
95
|
+
},
|
|
96
|
+
removeAction: () => {
|
|
97
|
+
},
|
|
98
|
+
coAgentStateRenders: {},
|
|
99
|
+
setCoAgentStateRender: () => {
|
|
100
|
+
},
|
|
101
|
+
removeCoAgentStateRender: () => {
|
|
102
|
+
},
|
|
103
|
+
chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },
|
|
104
|
+
getContextString: (documents, categories) => returnAndThrowInDebug(""),
|
|
105
|
+
addContext: () => "",
|
|
106
|
+
removeContext: () => {
|
|
107
|
+
},
|
|
108
|
+
getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
|
|
109
|
+
})),
|
|
110
|
+
isLoading: false,
|
|
111
|
+
setIsLoading: () => returnAndThrowInDebug(false),
|
|
112
|
+
chatInstructions: "",
|
|
113
|
+
setChatInstructions: () => returnAndThrowInDebug(""),
|
|
114
|
+
getDocumentsContext: (categories) => returnAndThrowInDebug([]),
|
|
115
|
+
addDocumentContext: () => returnAndThrowInDebug(""),
|
|
116
|
+
removeDocumentContext: () => {
|
|
117
|
+
},
|
|
118
|
+
runtimeClient: {},
|
|
119
|
+
copilotApiConfig: new class {
|
|
120
|
+
get chatApiEndpoint() {
|
|
121
|
+
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
122
|
+
}
|
|
123
|
+
get headers() {
|
|
124
|
+
return {};
|
|
125
|
+
}
|
|
126
|
+
get body() {
|
|
127
|
+
return {};
|
|
128
|
+
}
|
|
129
|
+
}(),
|
|
130
|
+
chatSuggestionConfiguration: {},
|
|
131
|
+
addChatSuggestionConfiguration: () => {
|
|
132
|
+
},
|
|
133
|
+
removeChatSuggestionConfiguration: () => {
|
|
134
|
+
},
|
|
135
|
+
showDevConsole: "auto",
|
|
136
|
+
coagentStates: {},
|
|
137
|
+
setCoagentStates: () => {
|
|
138
|
+
},
|
|
139
|
+
coagentStatesRef: { current: {} },
|
|
140
|
+
setCoagentStatesWithRef: () => {
|
|
141
|
+
},
|
|
142
|
+
agentSession: null,
|
|
143
|
+
setAgentSession: () => {
|
|
144
|
+
},
|
|
145
|
+
forwardedParameters: {},
|
|
146
|
+
agentLock: null,
|
|
147
|
+
threadId: null,
|
|
148
|
+
setThreadId: () => {
|
|
149
|
+
},
|
|
150
|
+
runId: null,
|
|
151
|
+
setRunId: () => {
|
|
152
|
+
},
|
|
153
|
+
chatAbortControllerRef: { current: null },
|
|
154
|
+
availableAgents: []
|
|
155
|
+
};
|
|
156
|
+
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
157
|
+
function returnAndThrowInDebug(_value) {
|
|
158
|
+
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// src/hooks/use-tree.ts
|
|
162
|
+
var import_shared = require("@copilotkit/shared");
|
|
163
|
+
var import_react2 = require("react");
|
|
164
|
+
var removeNode = (nodes, id) => {
|
|
165
|
+
return nodes.reduce((result, node) => {
|
|
166
|
+
if (node.id !== id) {
|
|
167
|
+
const newNode = __spreadProps(__spreadValues({}, node), { children: removeNode(node.children, id) });
|
|
168
|
+
result.push(newNode);
|
|
169
|
+
}
|
|
170
|
+
return result;
|
|
171
|
+
}, []);
|
|
172
|
+
};
|
|
173
|
+
var addNode = (nodes, newNode, parentId) => {
|
|
174
|
+
if (!parentId) {
|
|
175
|
+
return [...nodes, newNode];
|
|
176
|
+
}
|
|
177
|
+
return nodes.map((node) => {
|
|
178
|
+
if (node.id === parentId) {
|
|
179
|
+
return __spreadProps(__spreadValues({}, node), { children: [...node.children, newNode] });
|
|
180
|
+
} else if (node.children.length) {
|
|
181
|
+
return __spreadProps(__spreadValues({}, node), { children: addNode(node.children, newNode, parentId) });
|
|
182
|
+
}
|
|
183
|
+
return node;
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
var treeIndentationRepresentation = (index, indentLevel) => {
|
|
187
|
+
if (indentLevel === 0) {
|
|
188
|
+
return (index + 1).toString();
|
|
189
|
+
} else if (indentLevel === 1) {
|
|
190
|
+
return String.fromCharCode(65 + index);
|
|
191
|
+
} else if (indentLevel === 2) {
|
|
192
|
+
return String.fromCharCode(97 + index);
|
|
193
|
+
} else {
|
|
194
|
+
return "-";
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
var printNode = (node, prefix = "", indentLevel = 0) => {
|
|
198
|
+
const indent = " ".repeat(3).repeat(indentLevel);
|
|
199
|
+
const prefixPlusIndentLength = prefix.length + indent.length;
|
|
200
|
+
const subsequentLinesPrefix = " ".repeat(prefixPlusIndentLength);
|
|
201
|
+
const valueLines = node.value.split("\n");
|
|
202
|
+
const outputFirstLine = `${indent}${prefix}${valueLines[0]}`;
|
|
203
|
+
const outputSubsequentLines = valueLines.slice(1).map((line) => `${subsequentLinesPrefix}${line}`).join("\n");
|
|
204
|
+
let output = `${outputFirstLine}
|
|
205
|
+
`;
|
|
206
|
+
if (outputSubsequentLines) {
|
|
207
|
+
output += `${outputSubsequentLines}
|
|
208
|
+
`;
|
|
209
|
+
}
|
|
210
|
+
const childPrePrefix = " ".repeat(prefix.length);
|
|
211
|
+
node.children.forEach(
|
|
212
|
+
(child, index) => output += printNode(
|
|
213
|
+
child,
|
|
214
|
+
`${childPrePrefix}${treeIndentationRepresentation(index, indentLevel + 1)}. `,
|
|
215
|
+
indentLevel + 1
|
|
216
|
+
)
|
|
217
|
+
);
|
|
218
|
+
return output;
|
|
219
|
+
};
|
|
220
|
+
function treeReducer(state, action) {
|
|
221
|
+
switch (action.type) {
|
|
222
|
+
case "ADD_NODE": {
|
|
223
|
+
const { value, parentId, id: newNodeId } = action;
|
|
224
|
+
const newNode = {
|
|
225
|
+
id: newNodeId,
|
|
226
|
+
value,
|
|
227
|
+
children: [],
|
|
228
|
+
categories: new Set(action.categories)
|
|
229
|
+
};
|
|
230
|
+
try {
|
|
231
|
+
return addNode(state, newNode, parentId);
|
|
232
|
+
} catch (error) {
|
|
233
|
+
console.error(`Error while adding node with id ${newNodeId}: ${error}`);
|
|
234
|
+
return state;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
case "REMOVE_NODE":
|
|
238
|
+
return removeNode(state, action.id);
|
|
239
|
+
default:
|
|
240
|
+
return state;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
var useTree = () => {
|
|
244
|
+
const [tree, dispatch] = (0, import_react2.useReducer)(treeReducer, []);
|
|
245
|
+
const addElement = (0, import_react2.useCallback)(
|
|
246
|
+
(value, categories, parentId) => {
|
|
247
|
+
const newNodeId = (0, import_shared.randomId)();
|
|
248
|
+
dispatch({
|
|
249
|
+
type: "ADD_NODE",
|
|
250
|
+
value,
|
|
251
|
+
parentId,
|
|
252
|
+
id: newNodeId,
|
|
253
|
+
categories
|
|
254
|
+
});
|
|
255
|
+
return newNodeId;
|
|
256
|
+
},
|
|
257
|
+
[]
|
|
258
|
+
);
|
|
259
|
+
const removeElement = (0, import_react2.useCallback)((id) => {
|
|
260
|
+
dispatch({ type: "REMOVE_NODE", id });
|
|
261
|
+
}, []);
|
|
262
|
+
const printTree = (0, import_react2.useCallback)(
|
|
263
|
+
(categories) => {
|
|
264
|
+
const categoriesSet = new Set(categories);
|
|
265
|
+
let output = "";
|
|
266
|
+
tree.forEach((node, index) => {
|
|
267
|
+
if (!setsHaveIntersection(categoriesSet, node.categories)) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (index !== 0) {
|
|
271
|
+
output += "\n";
|
|
272
|
+
}
|
|
273
|
+
output += printNode(node, `${treeIndentationRepresentation(index, 0)}. `);
|
|
274
|
+
});
|
|
275
|
+
return output;
|
|
276
|
+
},
|
|
277
|
+
[tree]
|
|
278
|
+
);
|
|
279
|
+
return { tree, addElement, printTree, removeElement };
|
|
280
|
+
};
|
|
281
|
+
var use_tree_default = useTree;
|
|
282
|
+
function setsHaveIntersection(setA, setB) {
|
|
283
|
+
const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];
|
|
284
|
+
for (let item of smallerSet) {
|
|
285
|
+
if (largerSet.has(item)) {
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// src/components/copilot-provider/copilotkit.tsx
|
|
293
|
+
var import_react_dom = require("react-dom");
|
|
294
|
+
var import_shared3 = require("@copilotkit/shared");
|
|
295
|
+
|
|
296
|
+
// src/hooks/use-flat-category-store.ts
|
|
297
|
+
var import_react3 = require("react");
|
|
298
|
+
var import_shared2 = require("@copilotkit/shared");
|
|
299
|
+
var useFlatCategoryStore = () => {
|
|
300
|
+
const [elements, dispatch] = (0, import_react3.useReducer)(flatCategoryStoreReducer, /* @__PURE__ */ new Map());
|
|
301
|
+
const addElement = (0, import_react3.useCallback)((value, categories) => {
|
|
302
|
+
const newId = (0, import_shared2.randomId)();
|
|
303
|
+
dispatch({
|
|
304
|
+
type: "ADD_ELEMENT",
|
|
305
|
+
value,
|
|
306
|
+
id: newId,
|
|
307
|
+
categories
|
|
308
|
+
});
|
|
309
|
+
return newId;
|
|
310
|
+
}, []);
|
|
311
|
+
const removeElement = (0, import_react3.useCallback)((id) => {
|
|
312
|
+
dispatch({ type: "REMOVE_ELEMENT", id });
|
|
313
|
+
}, []);
|
|
314
|
+
const allElements = (0, import_react3.useCallback)(
|
|
315
|
+
(categories) => {
|
|
316
|
+
const categoriesSet = new Set(categories);
|
|
317
|
+
const result = [];
|
|
318
|
+
elements.forEach((element) => {
|
|
319
|
+
if (setsHaveIntersection2(categoriesSet, element.categories)) {
|
|
320
|
+
result.push(element.value);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
return result;
|
|
324
|
+
},
|
|
325
|
+
[elements]
|
|
326
|
+
);
|
|
327
|
+
return { addElement, removeElement, allElements };
|
|
328
|
+
};
|
|
329
|
+
var use_flat_category_store_default = useFlatCategoryStore;
|
|
330
|
+
function flatCategoryStoreReducer(state, action) {
|
|
331
|
+
switch (action.type) {
|
|
332
|
+
case "ADD_ELEMENT": {
|
|
333
|
+
const { value, id, categories } = action;
|
|
334
|
+
const newElement = {
|
|
335
|
+
id,
|
|
336
|
+
value,
|
|
337
|
+
categories: new Set(categories)
|
|
338
|
+
};
|
|
339
|
+
const newState = new Map(state);
|
|
340
|
+
newState.set(id, newElement);
|
|
341
|
+
return newState;
|
|
342
|
+
}
|
|
343
|
+
case "REMOVE_ELEMENT": {
|
|
344
|
+
const newState = new Map(state);
|
|
345
|
+
newState.delete(action.id);
|
|
346
|
+
return newState;
|
|
347
|
+
}
|
|
348
|
+
default:
|
|
349
|
+
return state;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function setsHaveIntersection2(setA, setB) {
|
|
353
|
+
const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];
|
|
354
|
+
for (let item of smallerSet) {
|
|
355
|
+
if (largerSet.has(item)) {
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// src/components/copilot-provider/copilot-messages.tsx
|
|
363
|
+
var import_react5 = require("react");
|
|
364
|
+
|
|
365
|
+
// src/context/copilot-messages-context.tsx
|
|
366
|
+
var import_react4 = __toESM(require("react"));
|
|
367
|
+
var emptyCopilotContext2 = {
|
|
368
|
+
messages: [],
|
|
369
|
+
setMessages: () => []
|
|
370
|
+
};
|
|
371
|
+
var CopilotMessagesContext = import_react4.default.createContext(emptyCopilotContext2);
|
|
372
|
+
|
|
373
|
+
// src/components/copilot-provider/copilot-messages.tsx
|
|
374
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
375
|
+
function CopilotMessages(_a) {
|
|
376
|
+
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
377
|
+
const [messages, setMessages] = (0, import_react5.useState)([]);
|
|
378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
379
|
+
CopilotMessagesContext.Provider,
|
|
380
|
+
{
|
|
381
|
+
value: {
|
|
382
|
+
messages,
|
|
383
|
+
setMessages
|
|
384
|
+
},
|
|
385
|
+
children
|
|
386
|
+
}
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// src/components/toast/toast-provider.tsx
|
|
391
|
+
var import_react7 = require("react");
|
|
392
|
+
|
|
393
|
+
// src/components/error-boundary/error-utils.tsx
|
|
394
|
+
var import_react6 = require("react");
|
|
395
|
+
|
|
396
|
+
// src/components/toast/exclamation-mark-icon.tsx
|
|
397
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
398
|
+
var ExclamationMarkIcon = ({
|
|
399
|
+
className,
|
|
400
|
+
style
|
|
401
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
402
|
+
"svg",
|
|
403
|
+
{
|
|
404
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
405
|
+
width: "24",
|
|
406
|
+
height: "24",
|
|
407
|
+
viewBox: "0 0 24 24",
|
|
408
|
+
fill: "none",
|
|
409
|
+
stroke: "currentColor",
|
|
410
|
+
strokeWidth: "2",
|
|
411
|
+
strokeLinecap: "round",
|
|
412
|
+
strokeLinejoin: "round",
|
|
413
|
+
className: `lucide lucide-circle-alert ${className ? className : ""}`,
|
|
414
|
+
style,
|
|
415
|
+
children: [
|
|
416
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
417
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
|
|
418
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
);
|
|
422
|
+
|
|
423
|
+
// src/components/error-boundary/error-utils.tsx
|
|
424
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
425
|
+
function ErrorToast({ errors }) {
|
|
426
|
+
const errorsToRender = errors.map((error, idx) => {
|
|
427
|
+
var _a, _b, _c;
|
|
428
|
+
const message = "extensions" in error ? (_b = (_a = error.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message : error.message;
|
|
429
|
+
const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
|
|
430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
431
|
+
"div",
|
|
432
|
+
{
|
|
433
|
+
style: {
|
|
434
|
+
marginTop: idx === 0 ? 0 : 10,
|
|
435
|
+
marginBottom: 14
|
|
436
|
+
},
|
|
437
|
+
children: [
|
|
438
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
|
|
439
|
+
code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
440
|
+
"div",
|
|
441
|
+
{
|
|
442
|
+
style: {
|
|
443
|
+
fontWeight: "600",
|
|
444
|
+
marginBottom: 4
|
|
445
|
+
},
|
|
446
|
+
children: [
|
|
447
|
+
"Copilot Cloud Error:",
|
|
448
|
+
" ",
|
|
449
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
|
|
450
|
+
]
|
|
451
|
+
}
|
|
452
|
+
),
|
|
453
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: message })
|
|
454
|
+
]
|
|
455
|
+
},
|
|
456
|
+
idx
|
|
457
|
+
);
|
|
458
|
+
});
|
|
459
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
460
|
+
"div",
|
|
461
|
+
{
|
|
462
|
+
style: {
|
|
463
|
+
fontSize: "13px",
|
|
464
|
+
maxWidth: "600px"
|
|
465
|
+
},
|
|
466
|
+
children: [
|
|
467
|
+
errorsToRender,
|
|
468
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
|
|
469
|
+
]
|
|
470
|
+
}
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
function useErrorToast() {
|
|
474
|
+
const { addToast } = useToast();
|
|
475
|
+
return (0, import_react6.useCallback)(
|
|
476
|
+
(error) => {
|
|
477
|
+
const errorId = error.map((err) => {
|
|
478
|
+
var _a, _b;
|
|
479
|
+
const message = "extensions" in err ? ((_b = (_a = err.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message) || err.message : err.message;
|
|
480
|
+
const stack = err.stack || "";
|
|
481
|
+
return btoa(message + stack).slice(0, 32);
|
|
482
|
+
}).join("|");
|
|
483
|
+
addToast({
|
|
484
|
+
type: "error",
|
|
485
|
+
id: errorId,
|
|
486
|
+
// Toast libraries typically dedupe by id
|
|
487
|
+
message: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorToast, { errors: error })
|
|
488
|
+
});
|
|
489
|
+
},
|
|
490
|
+
[addToast]
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// src/components/toast/toast-provider.tsx
|
|
495
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
496
|
+
var ToastContext = (0, import_react7.createContext)(void 0);
|
|
497
|
+
function useToast() {
|
|
498
|
+
const context = (0, import_react7.useContext)(ToastContext);
|
|
499
|
+
if (!context) {
|
|
500
|
+
throw new Error("useToast must be used within a ToastProvider");
|
|
501
|
+
}
|
|
502
|
+
return context;
|
|
503
|
+
}
|
|
504
|
+
function ToastProvider({
|
|
505
|
+
enabled,
|
|
506
|
+
children
|
|
507
|
+
}) {
|
|
508
|
+
const [toasts, setToasts] = (0, import_react7.useState)([]);
|
|
509
|
+
const addToast = (0, import_react7.useCallback)((toast) => {
|
|
510
|
+
var _a;
|
|
511
|
+
const id = (_a = toast.id) != null ? _a : Math.random().toString(36).substring(2, 9);
|
|
512
|
+
setToasts((currentToasts) => {
|
|
513
|
+
if (currentToasts.find((toast2) => toast2.id === id))
|
|
514
|
+
return currentToasts;
|
|
515
|
+
return [...currentToasts, __spreadProps(__spreadValues({}, toast), { id })];
|
|
516
|
+
});
|
|
517
|
+
if (toast.duration) {
|
|
518
|
+
setTimeout(() => {
|
|
519
|
+
removeToast(id);
|
|
520
|
+
}, toast.duration);
|
|
521
|
+
}
|
|
522
|
+
}, []);
|
|
523
|
+
const addGraphQLErrorsToast = (0, import_react7.useCallback)((errors) => {
|
|
524
|
+
addToast({
|
|
525
|
+
type: "error",
|
|
526
|
+
message: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorToast, { errors })
|
|
527
|
+
});
|
|
528
|
+
}, []);
|
|
529
|
+
const removeToast = (0, import_react7.useCallback)((id) => {
|
|
530
|
+
setToasts((currentToasts) => currentToasts.filter((toast) => toast.id !== id));
|
|
531
|
+
}, []);
|
|
532
|
+
const value = {
|
|
533
|
+
toasts,
|
|
534
|
+
addToast,
|
|
535
|
+
addGraphQLErrorsToast,
|
|
536
|
+
removeToast,
|
|
537
|
+
enabled
|
|
538
|
+
};
|
|
539
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(ToastContext.Provider, { value, children: [
|
|
540
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
541
|
+
"div",
|
|
542
|
+
{
|
|
543
|
+
style: {
|
|
544
|
+
position: "fixed",
|
|
545
|
+
bottom: "1rem",
|
|
546
|
+
left: "50%",
|
|
547
|
+
transform: "translateX(-50%)",
|
|
548
|
+
zIndex: 50,
|
|
549
|
+
display: "flex",
|
|
550
|
+
flexDirection: "column",
|
|
551
|
+
gap: "0.5rem"
|
|
552
|
+
},
|
|
553
|
+
children: [
|
|
554
|
+
toasts.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { textAlign: "right" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
555
|
+
"button",
|
|
556
|
+
{
|
|
557
|
+
onClick: () => setToasts([]),
|
|
558
|
+
style: {
|
|
559
|
+
padding: "4px 8px",
|
|
560
|
+
fontSize: "12px",
|
|
561
|
+
cursor: "pointer",
|
|
562
|
+
background: "white",
|
|
563
|
+
border: "1px solid rgba(0,0,0,0.2)",
|
|
564
|
+
borderRadius: "4px"
|
|
565
|
+
},
|
|
566
|
+
children: "Close All"
|
|
567
|
+
}
|
|
568
|
+
) }),
|
|
569
|
+
toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
570
|
+
Toast,
|
|
571
|
+
{
|
|
572
|
+
message: toast.message,
|
|
573
|
+
type: toast.type,
|
|
574
|
+
onClose: () => removeToast(toast.id)
|
|
575
|
+
},
|
|
576
|
+
toast.id
|
|
577
|
+
))
|
|
578
|
+
]
|
|
579
|
+
}
|
|
580
|
+
),
|
|
581
|
+
children
|
|
582
|
+
] });
|
|
583
|
+
}
|
|
584
|
+
function Toast({
|
|
585
|
+
message,
|
|
586
|
+
type = "info",
|
|
587
|
+
onClose
|
|
588
|
+
}) {
|
|
589
|
+
const bgColors = {
|
|
590
|
+
info: "#3b82f6",
|
|
591
|
+
success: "#22c55e",
|
|
592
|
+
warning: "#eab308",
|
|
593
|
+
error: "#ef4444"
|
|
594
|
+
};
|
|
595
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
596
|
+
"div",
|
|
597
|
+
{
|
|
598
|
+
style: {
|
|
599
|
+
backgroundColor: bgColors[type],
|
|
600
|
+
color: "white",
|
|
601
|
+
padding: "0.5rem 1.5rem",
|
|
602
|
+
borderRadius: "0.25rem",
|
|
603
|
+
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
|
|
604
|
+
position: "relative",
|
|
605
|
+
minWidth: "200px"
|
|
606
|
+
},
|
|
607
|
+
children: [
|
|
608
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: message }),
|
|
609
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
610
|
+
"button",
|
|
611
|
+
{
|
|
612
|
+
onClick: onClose,
|
|
613
|
+
style: {
|
|
614
|
+
position: "absolute",
|
|
615
|
+
top: "0",
|
|
616
|
+
right: "0",
|
|
617
|
+
background: "none",
|
|
618
|
+
border: "none",
|
|
619
|
+
color: "white",
|
|
620
|
+
cursor: "pointer",
|
|
621
|
+
padding: "0.5rem",
|
|
622
|
+
fontSize: "1rem"
|
|
623
|
+
},
|
|
624
|
+
children: "\u2715"
|
|
625
|
+
}
|
|
626
|
+
)
|
|
627
|
+
]
|
|
628
|
+
}
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// src/hooks/use-copilot-runtime-client.ts
|
|
633
|
+
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
634
|
+
var import_react8 = require("react");
|
|
635
|
+
var useCopilotRuntimeClient = (options) => {
|
|
636
|
+
const { addGraphQLErrorsToast } = useToast();
|
|
637
|
+
const addErrorToast = useErrorToast();
|
|
638
|
+
const runtimeClient = (0, import_react8.useMemo)(() => {
|
|
639
|
+
return new import_runtime_client_gql.CopilotRuntimeClient(__spreadProps(__spreadValues({}, options), {
|
|
640
|
+
handleGQLErrors: (error) => {
|
|
641
|
+
if (error.graphQLErrors.length) {
|
|
642
|
+
addGraphQLErrorsToast(error.graphQLErrors);
|
|
643
|
+
} else {
|
|
644
|
+
addErrorToast([error]);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}));
|
|
648
|
+
}, [options, addGraphQLErrorsToast]);
|
|
649
|
+
return runtimeClient;
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
// src/utils/dev-console.ts
|
|
653
|
+
function shouldShowDevConsole(showDevConsole) {
|
|
654
|
+
if (typeof showDevConsole === "boolean") {
|
|
655
|
+
return showDevConsole;
|
|
656
|
+
}
|
|
657
|
+
return getHostname() === "localhost" || getHostname() === "127.0.0.1" || getHostname() === "0.0.0.0" || getHostname() === "::1";
|
|
658
|
+
}
|
|
659
|
+
function getHostname() {
|
|
660
|
+
if (typeof window !== "undefined" && window.location) {
|
|
661
|
+
return window.location.hostname;
|
|
662
|
+
}
|
|
663
|
+
return "";
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// src/components/error-boundary/error-boundary.tsx
|
|
667
|
+
var import_react9 = __toESM(require("react"));
|
|
668
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
669
|
+
var CopilotErrorBoundary = class extends import_react9.default.Component {
|
|
670
|
+
constructor(props) {
|
|
671
|
+
super(props);
|
|
672
|
+
this.state = { hasError: false };
|
|
673
|
+
}
|
|
674
|
+
static getDerivedStateFromError(error) {
|
|
675
|
+
return { hasError: true, error };
|
|
676
|
+
}
|
|
677
|
+
componentDidCatch(error, errorInfo) {
|
|
678
|
+
console.error("CopilotKit Error:", error, errorInfo);
|
|
679
|
+
}
|
|
680
|
+
render() {
|
|
681
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ErrorToast2, { error: this.state.error, children: this.props.children });
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
function ErrorToast2({ error, children }) {
|
|
685
|
+
const addErrorToast = useErrorToast();
|
|
686
|
+
(0, import_react9.useEffect)(() => {
|
|
687
|
+
if (error) {
|
|
688
|
+
addErrorToast([error]);
|
|
689
|
+
}
|
|
690
|
+
}, [error, addErrorToast]);
|
|
691
|
+
return children;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
// src/components/copilot-provider/copilotkit.tsx
|
|
695
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
696
|
+
function CopilotKit(_a) {
|
|
697
|
+
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
698
|
+
const showDevConsole = props.showDevConsole === void 0 ? "auto" : props.showDevConsole;
|
|
699
|
+
const enabled = shouldShowDevConsole(showDevConsole);
|
|
700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ToastProvider, { enabled, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CopilotErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children })) }) });
|
|
701
|
+
}
|
|
702
|
+
function CopilotKitInternal(_a) {
|
|
703
|
+
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
704
|
+
if (!props.runtimeUrl && !props.publicApiKey) {
|
|
705
|
+
throw new Error(
|
|
706
|
+
"Please provide either a runtimeUrl or a publicApiKey to the CopilotKit component."
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
const chatApiEndpoint = props.runtimeUrl || import_shared3.COPILOT_CLOUD_CHAT_URL;
|
|
710
|
+
const [actions, setActions] = (0, import_react10.useState)({});
|
|
711
|
+
const [coAgentStateRenders, setCoAgentStateRenders] = (0, import_react10.useState)({});
|
|
712
|
+
const chatComponentsCache = (0, import_react10.useRef)({
|
|
713
|
+
actions: {},
|
|
714
|
+
coAgentStateRenders: {}
|
|
715
|
+
});
|
|
716
|
+
const { addElement, removeElement, printTree } = use_tree_default();
|
|
717
|
+
const [isLoading, setIsLoading] = (0, import_react10.useState)(false);
|
|
718
|
+
const [chatInstructions, setChatInstructions] = (0, import_react10.useState)("");
|
|
719
|
+
const [authStates, setAuthStates] = (0, import_react10.useState)({});
|
|
720
|
+
const {
|
|
721
|
+
addElement: addDocument,
|
|
722
|
+
removeElement: removeDocument,
|
|
723
|
+
allElements: allDocuments
|
|
724
|
+
} = use_flat_category_store_default();
|
|
725
|
+
const setAction = (0, import_react10.useCallback)((id, action) => {
|
|
726
|
+
setActions((prevPoints) => {
|
|
727
|
+
return __spreadProps(__spreadValues({}, prevPoints), {
|
|
728
|
+
[id]: action
|
|
729
|
+
});
|
|
730
|
+
});
|
|
731
|
+
}, []);
|
|
732
|
+
const removeAction = (0, import_react10.useCallback)((id) => {
|
|
733
|
+
setActions((prevPoints) => {
|
|
734
|
+
const newPoints = __spreadValues({}, prevPoints);
|
|
735
|
+
delete newPoints[id];
|
|
736
|
+
return newPoints;
|
|
737
|
+
});
|
|
738
|
+
}, []);
|
|
739
|
+
const setCoAgentStateRender = (0, import_react10.useCallback)((id, stateRender) => {
|
|
740
|
+
setCoAgentStateRenders((prevPoints) => {
|
|
741
|
+
return __spreadProps(__spreadValues({}, prevPoints), {
|
|
742
|
+
[id]: stateRender
|
|
743
|
+
});
|
|
744
|
+
});
|
|
745
|
+
}, []);
|
|
746
|
+
const removeCoAgentStateRender = (0, import_react10.useCallback)((id) => {
|
|
747
|
+
setCoAgentStateRenders((prevPoints) => {
|
|
748
|
+
const newPoints = __spreadValues({}, prevPoints);
|
|
749
|
+
delete newPoints[id];
|
|
750
|
+
return newPoints;
|
|
751
|
+
});
|
|
752
|
+
}, []);
|
|
753
|
+
const getContextString = (0, import_react10.useCallback)(
|
|
754
|
+
(documents, categories) => {
|
|
755
|
+
const documentsString = documents.map((document) => {
|
|
756
|
+
return `${document.name} (${document.sourceApplication}):
|
|
757
|
+
${document.getContents()}`;
|
|
758
|
+
}).join("\n\n");
|
|
759
|
+
const nonDocumentStrings = printTree(categories);
|
|
760
|
+
return `${documentsString}
|
|
761
|
+
|
|
762
|
+
${nonDocumentStrings}`;
|
|
763
|
+
},
|
|
764
|
+
[printTree]
|
|
765
|
+
);
|
|
766
|
+
const addContext = (0, import_react10.useCallback)(
|
|
767
|
+
(context, parentId, categories = defaultCopilotContextCategories) => {
|
|
768
|
+
return addElement(context, categories, parentId);
|
|
769
|
+
},
|
|
770
|
+
[addElement]
|
|
771
|
+
);
|
|
772
|
+
const removeContext = (0, import_react10.useCallback)(
|
|
773
|
+
(id) => {
|
|
774
|
+
removeElement(id);
|
|
775
|
+
},
|
|
776
|
+
[removeElement]
|
|
777
|
+
);
|
|
778
|
+
const getFunctionCallHandler = (0, import_react10.useCallback)(
|
|
779
|
+
(customEntryPoints) => {
|
|
780
|
+
return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || actions));
|
|
781
|
+
},
|
|
782
|
+
[actions]
|
|
783
|
+
);
|
|
784
|
+
const getDocumentsContext = (0, import_react10.useCallback)(
|
|
785
|
+
(categories) => {
|
|
786
|
+
return allDocuments(categories);
|
|
787
|
+
},
|
|
788
|
+
[allDocuments]
|
|
789
|
+
);
|
|
790
|
+
const addDocumentContext = (0, import_react10.useCallback)(
|
|
791
|
+
(documentPointer, categories = defaultCopilotContextCategories) => {
|
|
792
|
+
return addDocument(documentPointer, categories);
|
|
793
|
+
},
|
|
794
|
+
[addDocument]
|
|
795
|
+
);
|
|
796
|
+
const removeDocumentContext = (0, import_react10.useCallback)(
|
|
797
|
+
(documentId) => {
|
|
798
|
+
removeDocument(documentId);
|
|
799
|
+
},
|
|
800
|
+
[removeDocument]
|
|
801
|
+
);
|
|
802
|
+
if (!props.publicApiKey) {
|
|
803
|
+
if (props.cloudRestrictToTopic) {
|
|
804
|
+
throw new Error(
|
|
805
|
+
"To use the cloudRestrictToTopic feature, please sign up at https://copilotkit.ai and provide a publicApiKey."
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
const copilotApiConfig = (0, import_react10.useMemo)(() => {
|
|
810
|
+
var _a2, _b2;
|
|
811
|
+
let cloud = void 0;
|
|
812
|
+
if (props.publicApiKey) {
|
|
813
|
+
cloud = {
|
|
814
|
+
guardrails: {
|
|
815
|
+
input: {
|
|
816
|
+
restrictToTopic: {
|
|
817
|
+
enabled: props.cloudRestrictToTopic ? true : false,
|
|
818
|
+
validTopics: ((_a2 = props.cloudRestrictToTopic) == null ? void 0 : _a2.validTopics) || [],
|
|
819
|
+
invalidTopics: ((_b2 = props.cloudRestrictToTopic) == null ? void 0 : _b2.invalidTopics) || []
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
return __spreadProps(__spreadValues({
|
|
826
|
+
publicApiKey: props.publicApiKey
|
|
827
|
+
}, cloud ? { cloud } : {}), {
|
|
828
|
+
chatApiEndpoint,
|
|
829
|
+
headers: props.headers || {},
|
|
830
|
+
properties: props.properties || {},
|
|
831
|
+
transcribeAudioUrl: props.transcribeAudioUrl,
|
|
832
|
+
textToSpeechUrl: props.textToSpeechUrl,
|
|
833
|
+
credentials: props.credentials
|
|
834
|
+
});
|
|
835
|
+
}, [
|
|
836
|
+
props.publicApiKey,
|
|
837
|
+
props.headers,
|
|
838
|
+
props.properties,
|
|
839
|
+
props.transcribeAudioUrl,
|
|
840
|
+
props.textToSpeechUrl,
|
|
841
|
+
props.credentials,
|
|
842
|
+
props.cloudRestrictToTopic
|
|
843
|
+
]);
|
|
844
|
+
const headers = (0, import_react10.useMemo)(() => {
|
|
845
|
+
const authHeaders = Object.values(authStates || {}).reduce((acc, state) => {
|
|
846
|
+
if (state.status === "authenticated" && state.authHeaders) {
|
|
847
|
+
return __spreadValues(__spreadValues({}, acc), Object.entries(state.authHeaders).reduce(
|
|
848
|
+
(headers2, [key, value]) => __spreadProps(__spreadValues({}, headers2), {
|
|
849
|
+
[key.startsWith("X-Custom-") ? key : `X-Custom-${key}`]: value
|
|
850
|
+
}),
|
|
851
|
+
{}
|
|
852
|
+
));
|
|
853
|
+
}
|
|
854
|
+
return acc;
|
|
855
|
+
}, {});
|
|
856
|
+
return __spreadValues(__spreadValues(__spreadValues({}, copilotApiConfig.headers || {}), copilotApiConfig.publicApiKey ? { [import_shared3.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {}), authHeaders);
|
|
857
|
+
}, [copilotApiConfig.headers, copilotApiConfig.publicApiKey, authStates]);
|
|
858
|
+
const runtimeClient = useCopilotRuntimeClient({
|
|
859
|
+
url: copilotApiConfig.chatApiEndpoint,
|
|
860
|
+
publicApiKey: copilotApiConfig.publicApiKey,
|
|
861
|
+
headers,
|
|
862
|
+
credentials: copilotApiConfig.credentials
|
|
863
|
+
});
|
|
864
|
+
const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react10.useState)({});
|
|
865
|
+
const addChatSuggestionConfiguration = (id, suggestion) => {
|
|
866
|
+
setChatSuggestionConfiguration((prev) => __spreadProps(__spreadValues({}, prev), { [id]: suggestion }));
|
|
867
|
+
};
|
|
868
|
+
const removeChatSuggestionConfiguration = (id) => {
|
|
869
|
+
setChatSuggestionConfiguration((prev) => {
|
|
870
|
+
const _a2 = prev, { [id]: _ } = _a2, rest = __objRest(_a2, [__restKey(id)]);
|
|
871
|
+
return rest;
|
|
872
|
+
});
|
|
873
|
+
};
|
|
874
|
+
const [availableAgents, setAvailableAgents] = (0, import_react10.useState)([]);
|
|
875
|
+
const [coagentStates, setCoagentStates] = (0, import_react10.useState)({});
|
|
876
|
+
const coagentStatesRef = (0, import_react10.useRef)({});
|
|
877
|
+
const setCoagentStatesWithRef = (0, import_react10.useCallback)(
|
|
878
|
+
(value) => {
|
|
879
|
+
const newValue = typeof value === "function" ? value(coagentStatesRef.current) : value;
|
|
880
|
+
coagentStatesRef.current = newValue;
|
|
881
|
+
setCoagentStates((prev) => {
|
|
882
|
+
return newValue;
|
|
883
|
+
});
|
|
884
|
+
},
|
|
885
|
+
[]
|
|
886
|
+
);
|
|
887
|
+
(0, import_react10.useEffect)(() => {
|
|
888
|
+
const fetchData = () => __async(this, null, function* () {
|
|
889
|
+
var _a2;
|
|
890
|
+
const result = yield runtimeClient.availableAgents();
|
|
891
|
+
if ((_a2 = result.data) == null ? void 0 : _a2.availableAgents) {
|
|
892
|
+
setAvailableAgents(result.data.availableAgents.agents);
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
void fetchData();
|
|
896
|
+
}, []);
|
|
897
|
+
let initialAgentSession = null;
|
|
898
|
+
if (props.agent) {
|
|
899
|
+
initialAgentSession = {
|
|
900
|
+
agentName: props.agent
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
const [agentSession, setAgentSession] = (0, import_react10.useState)(initialAgentSession);
|
|
904
|
+
const [threadId, setThreadId] = (0, import_react10.useState)(null);
|
|
905
|
+
const [runId, setRunId] = (0, import_react10.useState)(null);
|
|
906
|
+
const chatAbortControllerRef = (0, import_react10.useRef)(null);
|
|
907
|
+
const showDevConsole = props.showDevConsole === void 0 ? "auto" : props.showDevConsole;
|
|
908
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
909
|
+
CopilotContext.Provider,
|
|
910
|
+
{
|
|
911
|
+
value: {
|
|
912
|
+
actions,
|
|
913
|
+
chatComponentsCache,
|
|
914
|
+
getFunctionCallHandler,
|
|
915
|
+
setAction,
|
|
916
|
+
removeAction,
|
|
917
|
+
coAgentStateRenders,
|
|
918
|
+
setCoAgentStateRender,
|
|
919
|
+
removeCoAgentStateRender,
|
|
920
|
+
getContextString,
|
|
921
|
+
addContext,
|
|
922
|
+
removeContext,
|
|
923
|
+
getDocumentsContext,
|
|
924
|
+
addDocumentContext,
|
|
925
|
+
removeDocumentContext,
|
|
926
|
+
copilotApiConfig,
|
|
927
|
+
isLoading,
|
|
928
|
+
setIsLoading,
|
|
929
|
+
chatSuggestionConfiguration,
|
|
930
|
+
addChatSuggestionConfiguration,
|
|
931
|
+
removeChatSuggestionConfiguration,
|
|
932
|
+
chatInstructions,
|
|
933
|
+
setChatInstructions,
|
|
934
|
+
showDevConsole,
|
|
935
|
+
coagentStates,
|
|
936
|
+
setCoagentStates,
|
|
937
|
+
coagentStatesRef,
|
|
938
|
+
setCoagentStatesWithRef,
|
|
939
|
+
agentSession,
|
|
940
|
+
setAgentSession,
|
|
941
|
+
runtimeClient,
|
|
942
|
+
forwardedParameters: props.forwardedParameters || {},
|
|
943
|
+
agentLock: props.agent || null,
|
|
944
|
+
threadId,
|
|
945
|
+
setThreadId,
|
|
946
|
+
runId,
|
|
947
|
+
setRunId,
|
|
948
|
+
chatAbortControllerRef,
|
|
949
|
+
availableAgents,
|
|
950
|
+
authConfig: props.authConfig,
|
|
951
|
+
authStates,
|
|
952
|
+
setAuthStates
|
|
953
|
+
},
|
|
954
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CopilotMessages, { children })
|
|
955
|
+
}
|
|
956
|
+
);
|
|
957
|
+
}
|
|
958
|
+
var defaultCopilotContextCategories = ["global"];
|
|
959
|
+
function entryPointsToFunctionCallHandler(actions) {
|
|
960
|
+
return (_0) => __async(this, [_0], function* ({ messages, name, args }) {
|
|
961
|
+
let actionsByFunctionName = {};
|
|
962
|
+
for (let action2 of actions) {
|
|
963
|
+
actionsByFunctionName[action2.name] = action2;
|
|
964
|
+
}
|
|
965
|
+
const action = actionsByFunctionName[name];
|
|
966
|
+
let result = void 0;
|
|
967
|
+
if (action) {
|
|
968
|
+
yield new Promise((resolve, reject) => {
|
|
969
|
+
(0, import_react_dom.flushSync)(() => __async(this, null, function* () {
|
|
970
|
+
var _a;
|
|
971
|
+
try {
|
|
972
|
+
result = yield (_a = action.handler) == null ? void 0 : _a.call(action, args);
|
|
973
|
+
resolve();
|
|
974
|
+
} catch (error) {
|
|
975
|
+
reject(error);
|
|
976
|
+
}
|
|
977
|
+
}));
|
|
978
|
+
});
|
|
979
|
+
yield new Promise((resolve) => setTimeout(resolve, 20));
|
|
980
|
+
}
|
|
981
|
+
return result;
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
985
|
+
0 && (module.exports = {
|
|
986
|
+
CopilotKit,
|
|
987
|
+
CopilotKitInternal,
|
|
988
|
+
defaultCopilotContextCategories
|
|
989
|
+
});
|
|
990
|
+
//# sourceMappingURL=copilotkit.js.map
|