@copilotkit/react-core 1.51.3-next.6 → 1.51.3-next.7
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 +10 -0
- package/dist/chunk-77IVITG3.mjs +158 -0
- package/dist/chunk-77IVITG3.mjs.map +1 -0
- package/dist/chunk-BKMJ4LC7.mjs +119 -0
- package/dist/chunk-BKMJ4LC7.mjs.map +1 -0
- package/dist/chunk-C3YJYDK4.mjs +189 -0
- package/dist/chunk-C3YJYDK4.mjs.map +1 -0
- package/dist/{chunk-GIU66J37.mjs → chunk-DQXCQWSG.mjs} +47 -5
- package/dist/chunk-DQXCQWSG.mjs.map +1 -0
- package/dist/{chunk-HBMPXNW2.mjs → chunk-LO4RRITI.mjs} +71 -18
- package/dist/chunk-LO4RRITI.mjs.map +1 -0
- package/dist/{chunk-3G4VFRVV.mjs → chunk-NXHQDCZF.mjs} +2 -2
- package/dist/{chunk-FDOMAPJY.mjs → chunk-QD7EID4N.mjs} +1 -1
- package/dist/chunk-QD7EID4N.mjs.map +1 -0
- package/dist/{chunk-YTQHRJUA.mjs → chunk-VKNLTZJE.mjs} +2 -2
- package/dist/{chunk-4RRUJHCI.mjs → chunk-VP43SLSZ.mjs} +2 -2
- package/dist/{chunk-MF2ZSLBV.mjs → chunk-XZFIJ7XF.mjs} +2 -2
- package/dist/components/copilot-provider/copilotkit.js +437 -150
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +5 -3
- package/dist/components/copilot-provider/index.js +437 -150
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +5 -3
- package/dist/components/index.js +437 -150
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +5 -3
- package/dist/context/coagent-state-renders-context.d.ts +1 -0
- package/dist/context/coagent-state-renders-context.js.map +1 -1
- package/dist/context/coagent-state-renders-context.mjs +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/hooks/index.js +512 -212
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +19 -17
- package/dist/hooks/use-coagent-state-render-bridge.helpers.d.ts +92 -0
- package/dist/hooks/use-coagent-state-render-bridge.helpers.js +231 -0
- package/dist/hooks/use-coagent-state-render-bridge.helpers.js.map +1 -0
- package/dist/hooks/use-coagent-state-render-bridge.helpers.mjs +24 -0
- package/dist/hooks/use-coagent-state-render-bridge.helpers.mjs.map +1 -0
- package/dist/hooks/use-coagent-state-render-bridge.js +334 -72
- package/dist/hooks/use-coagent-state-render-bridge.js.map +1 -1
- package/dist/hooks/use-coagent-state-render-bridge.mjs +4 -2
- package/dist/hooks/use-coagent-state-render-registry.d.ts +25 -0
- package/dist/hooks/use-coagent-state-render-registry.js +358 -0
- package/dist/hooks/use-coagent-state-render-registry.js.map +1 -0
- package/dist/hooks/use-coagent-state-render-registry.mjs +9 -0
- package/dist/hooks/use-coagent-state-render-registry.mjs.map +1 -0
- 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-copilot-chat-headless_c.js +414 -114
- package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
- package/dist/hooks/use-copilot-chat-headless_c.mjs +7 -5
- package/dist/hooks/use-copilot-chat.js +406 -106
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +7 -5
- package/dist/hooks/use-copilot-chat_internal.js +406 -106
- package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
- package/dist/hooks/use-copilot-chat_internal.mjs +6 -4
- package/dist/hooks/use-langgraph-interrupt-render.mjs +1 -1
- package/dist/index.js +651 -311
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -20
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +6 -4
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +6 -4
- package/dist/setupTests.js +1 -0
- package/dist/setupTests.js.map +1 -1
- package/dist/setupTests.mjs +1 -0
- package/dist/setupTests.mjs.map +1 -1
- package/dist/test-helpers/copilot-context.d.ts +14 -0
- package/dist/test-helpers/copilot-context.js +128 -0
- package/dist/test-helpers/copilot-context.js.map +1 -0
- package/dist/test-helpers/copilot-context.mjs +74 -0
- package/dist/test-helpers/copilot-context.mjs.map +1 -0
- package/dist/types/index.mjs +1 -1
- package/package.json +5 -5
- package/src/components/copilot-provider/copilotkit.tsx +56 -0
- package/src/context/coagent-state-renders-context.tsx +1 -0
- package/src/hooks/__tests__/use-coagent-state-render-bridge.helpers.test.ts +100 -0
- package/src/hooks/__tests__/use-coagent-state-render.e2e.test.tsx +892 -37
- package/src/hooks/__tests__/use-coagent-state-render.test.tsx +334 -0
- package/src/hooks/use-coagent-state-render-bridge.helpers.ts +311 -0
- package/src/hooks/use-coagent-state-render-bridge.tsx +25 -120
- package/src/hooks/use-coagent-state-render-registry.ts +215 -0
- package/src/hooks/use-copilot-chat_internal.ts +93 -34
- package/src/setupTests.ts +1 -0
- package/src/test-helpers/copilot-context.ts +91 -0
- package/dist/chunk-3X3I7OJV.mjs +0 -172
- package/dist/chunk-3X3I7OJV.mjs.map +0 -1
- package/dist/chunk-FDOMAPJY.mjs.map +0 -1
- package/dist/chunk-GIU66J37.mjs.map +0 -1
- package/dist/chunk-HBMPXNW2.mjs.map +0 -1
- /package/dist/{chunk-3G4VFRVV.mjs.map → chunk-NXHQDCZF.mjs.map} +0 -0
- /package/dist/{chunk-YTQHRJUA.mjs.map → chunk-VKNLTZJE.mjs.map} +0 -0
- /package/dist/{chunk-4RRUJHCI.mjs.map → chunk-VP43SLSZ.mjs.map} +0 -0
- /package/dist/{chunk-MF2ZSLBV.mjs.map → chunk-XZFIJ7XF.mjs.map} +0 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
23
|
+
};
|
|
24
|
+
var __copyProps = (to, from, except, desc) => {
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
26
|
+
for (let key of __getOwnPropNames(from))
|
|
27
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
28
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
29
|
+
}
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
+
var __async = (__this, __arguments, generator) => {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
var fulfilled = (value) => {
|
|
36
|
+
try {
|
|
37
|
+
step(generator.next(value));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
reject(e);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var rejected = (value) => {
|
|
43
|
+
try {
|
|
44
|
+
step(generator.throw(value));
|
|
45
|
+
} catch (e) {
|
|
46
|
+
reject(e);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
50
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/test-helpers/copilot-context.ts
|
|
55
|
+
var copilot_context_exports = {};
|
|
56
|
+
__export(copilot_context_exports, {
|
|
57
|
+
createTestCopilotContext: () => createTestCopilotContext
|
|
58
|
+
});
|
|
59
|
+
module.exports = __toCommonJS(copilot_context_exports);
|
|
60
|
+
var noop = () => {
|
|
61
|
+
};
|
|
62
|
+
var copilotApiConfig = {
|
|
63
|
+
chatApiEndpoint: "http://localhost",
|
|
64
|
+
headers: {}
|
|
65
|
+
};
|
|
66
|
+
function createTestCopilotContext(overrides = {}) {
|
|
67
|
+
return __spreadValues({
|
|
68
|
+
actions: {},
|
|
69
|
+
setAction: noop,
|
|
70
|
+
removeAction: noop,
|
|
71
|
+
setRegisteredActions: () => "action-id",
|
|
72
|
+
removeRegisteredAction: noop,
|
|
73
|
+
chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },
|
|
74
|
+
getFunctionCallHandler: () => () => __async(this, null, function* () {
|
|
75
|
+
}),
|
|
76
|
+
addContext: () => "context-id",
|
|
77
|
+
removeContext: noop,
|
|
78
|
+
getAllContext: () => [],
|
|
79
|
+
getContextString: () => "",
|
|
80
|
+
addDocumentContext: () => "document-id",
|
|
81
|
+
removeDocumentContext: noop,
|
|
82
|
+
getDocumentsContext: () => [],
|
|
83
|
+
isLoading: false,
|
|
84
|
+
setIsLoading: noop,
|
|
85
|
+
chatSuggestionConfiguration: {},
|
|
86
|
+
addChatSuggestionConfiguration: noop,
|
|
87
|
+
removeChatSuggestionConfiguration: noop,
|
|
88
|
+
chatInstructions: "",
|
|
89
|
+
setChatInstructions: noop,
|
|
90
|
+
additionalInstructions: [],
|
|
91
|
+
setAdditionalInstructions: noop,
|
|
92
|
+
copilotApiConfig,
|
|
93
|
+
showDevConsole: false,
|
|
94
|
+
coagentStates: {},
|
|
95
|
+
setCoagentStates: noop,
|
|
96
|
+
coagentStatesRef: { current: {} },
|
|
97
|
+
setCoagentStatesWithRef: noop,
|
|
98
|
+
agentSession: null,
|
|
99
|
+
setAgentSession: noop,
|
|
100
|
+
agentLock: null,
|
|
101
|
+
threadId: "",
|
|
102
|
+
setThreadId: noop,
|
|
103
|
+
runId: null,
|
|
104
|
+
setRunId: noop,
|
|
105
|
+
chatAbortControllerRef: { current: null },
|
|
106
|
+
forwardedParameters: {},
|
|
107
|
+
availableAgents: [],
|
|
108
|
+
extensions: {},
|
|
109
|
+
setExtensions: noop,
|
|
110
|
+
interruptActions: {},
|
|
111
|
+
setInterruptAction: noop,
|
|
112
|
+
removeInterruptAction: noop,
|
|
113
|
+
interruptEventQueue: {},
|
|
114
|
+
addInterruptEvent: noop,
|
|
115
|
+
resolveInterruptEvent: noop,
|
|
116
|
+
onError: noop,
|
|
117
|
+
bannerError: null,
|
|
118
|
+
setBannerError: noop,
|
|
119
|
+
internalErrorHandlers: {},
|
|
120
|
+
setInternalErrorHandler: noop,
|
|
121
|
+
removeInternalErrorHandler: noop
|
|
122
|
+
}, overrides);
|
|
123
|
+
}
|
|
124
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
125
|
+
0 && (module.exports = {
|
|
126
|
+
createTestCopilotContext
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=copilot-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/test-helpers/copilot-context.ts"],"sourcesContent":["import type { CopilotContextParams, CopilotApiConfig } from \"../context\";\n\nconst noop = () => {};\n\nconst copilotApiConfig: CopilotApiConfig = {\n chatApiEndpoint: \"http://localhost\",\n headers: {},\n};\n\nexport function createTestCopilotContext(\n overrides: Partial<CopilotContextParams> = {},\n): CopilotContextParams {\n return {\n actions: {},\n setAction: noop,\n removeAction: noop,\n\n setRegisteredActions: () => \"action-id\",\n removeRegisteredAction: noop,\n\n chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },\n getFunctionCallHandler: () => async () => {},\n\n addContext: () => \"context-id\",\n removeContext: noop,\n getAllContext: () => [],\n getContextString: () => \"\",\n\n addDocumentContext: () => \"document-id\",\n removeDocumentContext: noop,\n getDocumentsContext: () => [],\n\n isLoading: false,\n setIsLoading: noop,\n\n chatSuggestionConfiguration: {},\n addChatSuggestionConfiguration: noop,\n removeChatSuggestionConfiguration: noop,\n\n chatInstructions: \"\",\n setChatInstructions: noop,\n\n additionalInstructions: [],\n setAdditionalInstructions: noop,\n\n copilotApiConfig,\n\n showDevConsole: false,\n\n coagentStates: {},\n setCoagentStates: noop,\n coagentStatesRef: { current: {} },\n setCoagentStatesWithRef: noop,\n\n agentSession: null,\n setAgentSession: noop,\n\n agentLock: null,\n\n threadId: \"\",\n setThreadId: noop,\n\n runId: null,\n setRunId: noop,\n\n chatAbortControllerRef: { current: null },\n\n forwardedParameters: {},\n availableAgents: [],\n\n extensions: {},\n setExtensions: noop,\n\n interruptActions: {},\n setInterruptAction: noop,\n removeInterruptAction: noop,\n interruptEventQueue: {},\n addInterruptEvent: noop,\n resolveInterruptEvent: noop,\n\n onError: noop,\n\n bannerError: null,\n setBannerError: noop,\n internalErrorHandlers: {},\n setInternalErrorHandler: noop,\n removeInternalErrorHandler: noop,\n\n ...overrides,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAM,OAAO,MAAM;AAAC;AAEpB,IAAM,mBAAqC;AAAA,EACzC,iBAAiB;AAAA,EACjB,SAAS,CAAC;AACZ;AAEO,SAAS,yBACd,YAA2C,CAAC,GACtB;AACtB,SAAO;AAAA,IACL,SAAS,CAAC;AAAA,IACV,WAAW;AAAA,IACX,cAAc;AAAA,IAEd,sBAAsB,MAAM;AAAA,IAC5B,wBAAwB;AAAA,IAExB,qBAAqB,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,qBAAqB,CAAC,EAAE,EAAE;AAAA,IACzE,wBAAwB,MAAM,MAAY;AAAA,IAAC;AAAA,IAE3C,YAAY,MAAM;AAAA,IAClB,eAAe;AAAA,IACf,eAAe,MAAM,CAAC;AAAA,IACtB,kBAAkB,MAAM;AAAA,IAExB,oBAAoB,MAAM;AAAA,IAC1B,uBAAuB;AAAA,IACvB,qBAAqB,MAAM,CAAC;AAAA,IAE5B,WAAW;AAAA,IACX,cAAc;AAAA,IAEd,6BAA6B,CAAC;AAAA,IAC9B,gCAAgC;AAAA,IAChC,mCAAmC;AAAA,IAEnC,kBAAkB;AAAA,IAClB,qBAAqB;AAAA,IAErB,wBAAwB,CAAC;AAAA,IACzB,2BAA2B;AAAA,IAE3B;AAAA,IAEA,gBAAgB;AAAA,IAEhB,eAAe,CAAC;AAAA,IAChB,kBAAkB;AAAA,IAClB,kBAAkB,EAAE,SAAS,CAAC,EAAE;AAAA,IAChC,yBAAyB;AAAA,IAEzB,cAAc;AAAA,IACd,iBAAiB;AAAA,IAEjB,WAAW;AAAA,IAEX,UAAU;AAAA,IACV,aAAa;AAAA,IAEb,OAAO;AAAA,IACP,UAAU;AAAA,IAEV,wBAAwB,EAAE,SAAS,KAAK;AAAA,IAExC,qBAAqB,CAAC;AAAA,IACtB,iBAAiB,CAAC;AAAA,IAElB,YAAY,CAAC;AAAA,IACb,eAAe;AAAA,IAEf,kBAAkB,CAAC;AAAA,IACnB,oBAAoB;AAAA,IACpB,uBAAuB;AAAA,IACvB,qBAAqB,CAAC;AAAA,IACtB,mBAAmB;AAAA,IACnB,uBAAuB;AAAA,IAEvB,SAAS;AAAA,IAET,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB,uBAAuB,CAAC;AAAA,IACxB,yBAAyB;AAAA,IACzB,4BAA4B;AAAA,KAEzB;AAEP;","names":[]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__async,
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "../chunk-SKC7AJIV.mjs";
|
|
5
|
+
|
|
6
|
+
// src/test-helpers/copilot-context.ts
|
|
7
|
+
var noop = () => {
|
|
8
|
+
};
|
|
9
|
+
var copilotApiConfig = {
|
|
10
|
+
chatApiEndpoint: "http://localhost",
|
|
11
|
+
headers: {}
|
|
12
|
+
};
|
|
13
|
+
function createTestCopilotContext(overrides = {}) {
|
|
14
|
+
return __spreadValues({
|
|
15
|
+
actions: {},
|
|
16
|
+
setAction: noop,
|
|
17
|
+
removeAction: noop,
|
|
18
|
+
setRegisteredActions: () => "action-id",
|
|
19
|
+
removeRegisteredAction: noop,
|
|
20
|
+
chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },
|
|
21
|
+
getFunctionCallHandler: () => () => __async(this, null, function* () {
|
|
22
|
+
}),
|
|
23
|
+
addContext: () => "context-id",
|
|
24
|
+
removeContext: noop,
|
|
25
|
+
getAllContext: () => [],
|
|
26
|
+
getContextString: () => "",
|
|
27
|
+
addDocumentContext: () => "document-id",
|
|
28
|
+
removeDocumentContext: noop,
|
|
29
|
+
getDocumentsContext: () => [],
|
|
30
|
+
isLoading: false,
|
|
31
|
+
setIsLoading: noop,
|
|
32
|
+
chatSuggestionConfiguration: {},
|
|
33
|
+
addChatSuggestionConfiguration: noop,
|
|
34
|
+
removeChatSuggestionConfiguration: noop,
|
|
35
|
+
chatInstructions: "",
|
|
36
|
+
setChatInstructions: noop,
|
|
37
|
+
additionalInstructions: [],
|
|
38
|
+
setAdditionalInstructions: noop,
|
|
39
|
+
copilotApiConfig,
|
|
40
|
+
showDevConsole: false,
|
|
41
|
+
coagentStates: {},
|
|
42
|
+
setCoagentStates: noop,
|
|
43
|
+
coagentStatesRef: { current: {} },
|
|
44
|
+
setCoagentStatesWithRef: noop,
|
|
45
|
+
agentSession: null,
|
|
46
|
+
setAgentSession: noop,
|
|
47
|
+
agentLock: null,
|
|
48
|
+
threadId: "",
|
|
49
|
+
setThreadId: noop,
|
|
50
|
+
runId: null,
|
|
51
|
+
setRunId: noop,
|
|
52
|
+
chatAbortControllerRef: { current: null },
|
|
53
|
+
forwardedParameters: {},
|
|
54
|
+
availableAgents: [],
|
|
55
|
+
extensions: {},
|
|
56
|
+
setExtensions: noop,
|
|
57
|
+
interruptActions: {},
|
|
58
|
+
setInterruptAction: noop,
|
|
59
|
+
removeInterruptAction: noop,
|
|
60
|
+
interruptEventQueue: {},
|
|
61
|
+
addInterruptEvent: noop,
|
|
62
|
+
resolveInterruptEvent: noop,
|
|
63
|
+
onError: noop,
|
|
64
|
+
bannerError: null,
|
|
65
|
+
setBannerError: noop,
|
|
66
|
+
internalErrorHandlers: {},
|
|
67
|
+
setInternalErrorHandler: noop,
|
|
68
|
+
removeInternalErrorHandler: noop
|
|
69
|
+
}, overrides);
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
createTestCopilotContext
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=copilot-context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/test-helpers/copilot-context.ts"],"sourcesContent":["import type { CopilotContextParams, CopilotApiConfig } from \"../context\";\n\nconst noop = () => {};\n\nconst copilotApiConfig: CopilotApiConfig = {\n chatApiEndpoint: \"http://localhost\",\n headers: {},\n};\n\nexport function createTestCopilotContext(\n overrides: Partial<CopilotContextParams> = {},\n): CopilotContextParams {\n return {\n actions: {},\n setAction: noop,\n removeAction: noop,\n\n setRegisteredActions: () => \"action-id\",\n removeRegisteredAction: noop,\n\n chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },\n getFunctionCallHandler: () => async () => {},\n\n addContext: () => \"context-id\",\n removeContext: noop,\n getAllContext: () => [],\n getContextString: () => \"\",\n\n addDocumentContext: () => \"document-id\",\n removeDocumentContext: noop,\n getDocumentsContext: () => [],\n\n isLoading: false,\n setIsLoading: noop,\n\n chatSuggestionConfiguration: {},\n addChatSuggestionConfiguration: noop,\n removeChatSuggestionConfiguration: noop,\n\n chatInstructions: \"\",\n setChatInstructions: noop,\n\n additionalInstructions: [],\n setAdditionalInstructions: noop,\n\n copilotApiConfig,\n\n showDevConsole: false,\n\n coagentStates: {},\n setCoagentStates: noop,\n coagentStatesRef: { current: {} },\n setCoagentStatesWithRef: noop,\n\n agentSession: null,\n setAgentSession: noop,\n\n agentLock: null,\n\n threadId: \"\",\n setThreadId: noop,\n\n runId: null,\n setRunId: noop,\n\n chatAbortControllerRef: { current: null },\n\n forwardedParameters: {},\n availableAgents: [],\n\n extensions: {},\n setExtensions: noop,\n\n interruptActions: {},\n setInterruptAction: noop,\n removeInterruptAction: noop,\n interruptEventQueue: {},\n addInterruptEvent: noop,\n resolveInterruptEvent: noop,\n\n onError: noop,\n\n bannerError: null,\n setBannerError: noop,\n internalErrorHandlers: {},\n setInternalErrorHandler: noop,\n removeInternalErrorHandler: noop,\n\n ...overrides,\n };\n}\n"],"mappings":";;;;;;AAEA,IAAM,OAAO,MAAM;AAAC;AAEpB,IAAM,mBAAqC;AAAA,EACzC,iBAAiB;AAAA,EACjB,SAAS,CAAC;AACZ;AAEO,SAAS,yBACd,YAA2C,CAAC,GACtB;AACtB,SAAO;AAAA,IACL,SAAS,CAAC;AAAA,IACV,WAAW;AAAA,IACX,cAAc;AAAA,IAEd,sBAAsB,MAAM;AAAA,IAC5B,wBAAwB;AAAA,IAExB,qBAAqB,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,qBAAqB,CAAC,EAAE,EAAE;AAAA,IACzE,wBAAwB,MAAM,MAAY;AAAA,IAAC;AAAA,IAE3C,YAAY,MAAM;AAAA,IAClB,eAAe;AAAA,IACf,eAAe,MAAM,CAAC;AAAA,IACtB,kBAAkB,MAAM;AAAA,IAExB,oBAAoB,MAAM;AAAA,IAC1B,uBAAuB;AAAA,IACvB,qBAAqB,MAAM,CAAC;AAAA,IAE5B,WAAW;AAAA,IACX,cAAc;AAAA,IAEd,6BAA6B,CAAC;AAAA,IAC9B,gCAAgC;AAAA,IAChC,mCAAmC;AAAA,IAEnC,kBAAkB;AAAA,IAClB,qBAAqB;AAAA,IAErB,wBAAwB,CAAC;AAAA,IACzB,2BAA2B;AAAA,IAE3B;AAAA,IAEA,gBAAgB;AAAA,IAEhB,eAAe,CAAC;AAAA,IAChB,kBAAkB;AAAA,IAClB,kBAAkB,EAAE,SAAS,CAAC,EAAE;AAAA,IAChC,yBAAyB;AAAA,IAEzB,cAAc;AAAA,IACd,iBAAiB;AAAA,IAEjB,WAAW;AAAA,IAEX,UAAU;AAAA,IACV,aAAa;AAAA,IAEb,OAAO;AAAA,IACP,UAAU;AAAA,IAEV,wBAAwB,EAAE,SAAS,KAAK;AAAA,IAExC,qBAAqB,CAAC;AAAA,IACtB,iBAAiB,CAAC;AAAA,IAElB,YAAY,CAAC;AAAA,IACb,eAAe;AAAA,IAEf,kBAAkB,CAAC;AAAA,IACnB,oBAAoB;AAAA,IACpB,uBAAuB;AAAA,IACvB,qBAAqB,CAAC;AAAA,IACtB,mBAAmB;AAAA,IACnB,uBAAuB;AAAA,IAEvB,SAAS;AAAA,IAET,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB,uBAAuB,CAAC;AAAA,IACxB,yBAAyB;AAAA,IACzB,4BAA4B;AAAA,KAEzB;AAEP;","names":[]}
|
package/dist/types/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.51.3-next.
|
|
12
|
+
"version": "1.51.3-next.7",
|
|
13
13
|
"sideEffects": [
|
|
14
14
|
"**/*.css"
|
|
15
15
|
],
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
"@scarf/scarf": "^1.3.0",
|
|
60
60
|
"react-markdown": "^8.0.7",
|
|
61
61
|
"untruncate-json": "^0.0.1",
|
|
62
|
-
"@copilotkit/runtime-client-gql": "1.51.3-next.
|
|
63
|
-
"@copilotkit/shared": "1.51.3-next.
|
|
64
|
-
"@copilotkitnext/core": "1.51.3-next.
|
|
65
|
-
"@copilotkitnext/react": "1.51.3-next.
|
|
62
|
+
"@copilotkit/runtime-client-gql": "1.51.3-next.7",
|
|
63
|
+
"@copilotkit/shared": "1.51.3-next.7",
|
|
64
|
+
"@copilotkitnext/core": "1.51.3-next.7",
|
|
65
|
+
"@copilotkitnext/react": "1.51.3-next.7"
|
|
66
66
|
},
|
|
67
67
|
"keywords": [
|
|
68
68
|
"copilotkit",
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
CopilotChatConfigurationProvider,
|
|
20
20
|
CopilotKitInspector,
|
|
21
21
|
CopilotKitProvider as CopilotKitNextProvider,
|
|
22
|
+
useCopilotKit,
|
|
22
23
|
} from "@copilotkitnext/react";
|
|
23
24
|
import {
|
|
24
25
|
CopilotContext,
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
ChatComponentsCache,
|
|
27
28
|
AgentSession,
|
|
28
29
|
AuthState,
|
|
30
|
+
useCopilotContext,
|
|
29
31
|
} from "../../context/copilot-context";
|
|
30
32
|
import useTree from "../../hooks/use-tree";
|
|
31
33
|
import { CopilotChatSuggestionConfiguration, DocumentPointer } from "../../types";
|
|
@@ -89,6 +91,59 @@ export function CopilotKit({ children, ...props }: CopilotKitProps) {
|
|
|
89
91
|
);
|
|
90
92
|
}
|
|
91
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Bridge component that subscribes to v2.x copilotkit core error events
|
|
96
|
+
* and forwards them to v1.x error handling system.
|
|
97
|
+
* This ensures only ONE subscription exists regardless of how many times
|
|
98
|
+
* Chat components are rendered.
|
|
99
|
+
*/
|
|
100
|
+
function CopilotKitErrorBridge() {
|
|
101
|
+
const { copilotkit } = useCopilotKit();
|
|
102
|
+
const { onError, copilotApiConfig } = useCopilotContext();
|
|
103
|
+
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (!copilotkit) return;
|
|
106
|
+
|
|
107
|
+
const subscription = copilotkit.subscribe({
|
|
108
|
+
onError: async (event) => {
|
|
109
|
+
// Convert v2.x error event to v1.x CopilotErrorEvent format
|
|
110
|
+
const errorEvent: CopilotErrorEvent = {
|
|
111
|
+
type: "error",
|
|
112
|
+
timestamp: Date.now(),
|
|
113
|
+
context: {
|
|
114
|
+
source: "agent",
|
|
115
|
+
request: {
|
|
116
|
+
operation: event.code || "unknown",
|
|
117
|
+
url: copilotApiConfig?.chatApiEndpoint,
|
|
118
|
+
startTime: Date.now(),
|
|
119
|
+
},
|
|
120
|
+
technical: {
|
|
121
|
+
environment: "browser",
|
|
122
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : undefined,
|
|
123
|
+
stackTrace: event.error.stack,
|
|
124
|
+
},
|
|
125
|
+
// Add additional context from v2.x event
|
|
126
|
+
...event.context,
|
|
127
|
+
},
|
|
128
|
+
error: event.error,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
await onError(errorEvent);
|
|
133
|
+
} catch (handlerError) {
|
|
134
|
+
console.error("Error in onError handler:", handlerError);
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return () => {
|
|
140
|
+
subscription.unsubscribe();
|
|
141
|
+
};
|
|
142
|
+
}, [copilotkit, onError, copilotApiConfig]);
|
|
143
|
+
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
|
|
92
147
|
export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
93
148
|
const { children, ...props } = cpkProps;
|
|
94
149
|
|
|
@@ -592,6 +647,7 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
592
647
|
}}
|
|
593
648
|
>
|
|
594
649
|
<CopilotListeners />
|
|
650
|
+
<CopilotKitErrorBridge />
|
|
595
651
|
<CoAgentStateRendersProvider>
|
|
596
652
|
<MessagesTapProvider>
|
|
597
653
|
<CopilotMessages>
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClaimAction,
|
|
3
|
+
resolveClaim,
|
|
4
|
+
selectSnapshot,
|
|
5
|
+
type ClaimsByMessageId,
|
|
6
|
+
type SnapshotCaches,
|
|
7
|
+
type StateRenderContext,
|
|
8
|
+
} from "../use-coagent-state-render-bridge.helpers";
|
|
9
|
+
|
|
10
|
+
describe("useCoAgentStateRenderBridge helpers", () => {
|
|
11
|
+
describe("resolveClaim", () => {
|
|
12
|
+
it("updates runId for an existing claim", () => {
|
|
13
|
+
const claims: ClaimsByMessageId = {
|
|
14
|
+
msg1: { stateRenderId: "render-a", runId: "pending" },
|
|
15
|
+
};
|
|
16
|
+
const context: StateRenderContext = {
|
|
17
|
+
agentId: "agent-1",
|
|
18
|
+
stateRenderId: "render-a",
|
|
19
|
+
messageId: "msg1",
|
|
20
|
+
runId: "run-123",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const result = resolveClaim({ claims, context, stateSnapshot: { step: 1 } });
|
|
24
|
+
expect(result.action).toBe(ClaimAction.Existing);
|
|
25
|
+
expect(result.canRender).toBe(true);
|
|
26
|
+
expect(result.updateRunId).toBe("run-123");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("overrides when a newer message index arrives", () => {
|
|
30
|
+
const claims: ClaimsByMessageId = {
|
|
31
|
+
msg1: {
|
|
32
|
+
stateRenderId: "render-a",
|
|
33
|
+
runId: "run-1",
|
|
34
|
+
messageIndex: 0,
|
|
35
|
+
stateSnapshot: { step: 2 },
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
const context: StateRenderContext = {
|
|
39
|
+
agentId: "agent-1",
|
|
40
|
+
stateRenderId: "render-a",
|
|
41
|
+
messageId: "msg2",
|
|
42
|
+
runId: "run-1",
|
|
43
|
+
messageIndex: 1,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const result = resolveClaim({ claims, context, stateSnapshot: { step: 2 } });
|
|
47
|
+
expect(result.action).toBe(ClaimAction.Override);
|
|
48
|
+
expect(result.canRender).toBe(true);
|
|
49
|
+
expect(result.nextClaim).toMatchObject({
|
|
50
|
+
stateRenderId: "render-a",
|
|
51
|
+
runId: "run-1",
|
|
52
|
+
messageIndex: 1,
|
|
53
|
+
});
|
|
54
|
+
expect(result.lockOthers).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe("selectSnapshot", () => {
|
|
60
|
+
const caches: SnapshotCaches = {
|
|
61
|
+
byStateRenderAndRun: {},
|
|
62
|
+
byMessageId: {},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
it("prefers the explicit state snapshot prop", () => {
|
|
66
|
+
const result = selectSnapshot({
|
|
67
|
+
messageId: "msg1",
|
|
68
|
+
stateRenderId: "render-a",
|
|
69
|
+
effectiveRunId: "run-1",
|
|
70
|
+
stateSnapshotProp: "{\"phase\":\"planning\"}",
|
|
71
|
+
agentState: { phase: "ignored" },
|
|
72
|
+
agentMessages: [{ id: "assistant-1", role: "assistant" }],
|
|
73
|
+
caches,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
expect(result.snapshot).toEqual({ phase: "planning" });
|
|
77
|
+
expect(result.hasSnapshotKeys).toBe(true);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("falls back to cached snapshots for non-latest assistant messages", () => {
|
|
81
|
+
const result = selectSnapshot({
|
|
82
|
+
messageId: "msg-old",
|
|
83
|
+
stateRenderId: "render-a",
|
|
84
|
+
effectiveRunId: "run-1",
|
|
85
|
+
agentState: { phase: "live" },
|
|
86
|
+
agentMessages: [{ id: "assistant-latest", role: "assistant" }],
|
|
87
|
+
caches: {
|
|
88
|
+
byStateRenderAndRun: {
|
|
89
|
+
"render-a::run-1": { phase: "cached" },
|
|
90
|
+
},
|
|
91
|
+
byMessageId: {},
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
expect(result.snapshot).toBeUndefined();
|
|
96
|
+
expect(result.cachedSnapshot).toEqual({ phase: "cached" });
|
|
97
|
+
expect(result.snapshotForClaim).toEqual({ phase: "cached" });
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|