@copilotkit/react-core 1.3.16-mme-reset-chat.11 → 1.4.0-alpha.18
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 +212 -35
- package/dist/{chunk-PHP2YMMH.mjs → chunk-27IPQFJP.mjs} +2 -2
- package/dist/{chunk-WBBL7MG6.mjs → chunk-2MPUQRAY.mjs} +2 -10
- package/dist/{chunk-WBBL7MG6.mjs.map → chunk-2MPUQRAY.mjs.map} +1 -1
- package/dist/{chunk-UFSLLJZY.mjs → chunk-6YEMNWKE.mjs} +3 -12
- package/dist/{chunk-UFSLLJZY.mjs.map → chunk-6YEMNWKE.mjs.map} +1 -1
- package/dist/{chunk-I7XLZC4D.mjs → chunk-7DFHFZJT.mjs} +2 -2
- package/dist/{chunk-ZDYUMEE5.mjs → chunk-ANOG3W5S.mjs} +2 -2
- package/dist/{chunk-24ALPG2R.mjs → chunk-G2K6T2QU.mjs} +8 -16
- package/dist/chunk-G2K6T2QU.mjs.map +1 -0
- package/dist/{chunk-KJ3U5SXS.mjs → chunk-MX2OYLRS.mjs} +6 -36
- package/dist/chunk-MX2OYLRS.mjs.map +1 -0
- package/dist/{chunk-FXT6XSUB.mjs → chunk-RYDEG77L.mjs} +2 -2
- package/dist/{chunk-N57PDRVX.mjs → chunk-TRXKPXDE.mjs} +2 -2
- package/dist/{chunk-FITKQ6YQ.mjs → chunk-XACBOJF5.mjs} +5 -23
- package/dist/{chunk-FITKQ6YQ.mjs.map → chunk-XACBOJF5.mjs.map} +1 -1
- package/dist/{chunk-A6THC3F6.mjs → chunk-ZM6HV22S.mjs} +2 -2
- package/dist/components/copilot-provider/copilotkit.js +2 -19
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +2 -2
- package/dist/components/copilot-provider/index.js +2 -19
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +2 -2
- package/dist/components/index.js +2 -19
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/context/copilot-context.d.ts +0 -6
- package/dist/context/copilot-context.js +1 -9
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/index.js +1 -9
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/hooks/index.d.ts +1 -2
- package/dist/hooks/index.js +11 -78
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +9 -15
- package/dist/hooks/use-chat.d.ts +0 -20
- package/dist/hooks/use-chat.js +7 -15
- 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 +1 -9
- 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 -14
- package/dist/hooks/use-coagent.js +11 -78
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +5 -11
- package/dist/hooks/use-copilot-action.js +1 -9
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +2 -2
- package/dist/hooks/use-copilot-chat.d.ts +0 -1
- package/dist/hooks/use-copilot-chat.js +10 -56
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +4 -4
- package/dist/hooks/use-copilot-readable.js +1 -9
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +2 -2
- package/dist/hooks/use-make-copilot-document-readable.js +1 -9
- 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 +1 -1
- package/dist/index.js +12 -88
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -17
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +3 -3
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +3 -3
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +3 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +3 -3
- package/package.json +5 -5
- package/src/components/copilot-provider/copilotkit.tsx +0 -10
- package/src/context/copilot-context.tsx +0 -21
- package/src/hooks/index.ts +1 -1
- package/src/hooks/use-chat.ts +7 -40
- package/src/hooks/use-coagent.ts +4 -21
- package/src/hooks/use-copilot-chat.ts +4 -35
- package/dist/chunk-24ALPG2R.mjs.map +0 -1
- package/dist/chunk-KJ3U5SXS.mjs.map +0 -1
- /package/dist/{chunk-PHP2YMMH.mjs.map → chunk-27IPQFJP.mjs.map} +0 -0
- /package/dist/{chunk-I7XLZC4D.mjs.map → chunk-7DFHFZJT.mjs.map} +0 -0
- /package/dist/{chunk-ZDYUMEE5.mjs.map → chunk-ANOG3W5S.mjs.map} +0 -0
- /package/dist/{chunk-FXT6XSUB.mjs.map → chunk-RYDEG77L.mjs.map} +0 -0
- /package/dist/{chunk-N57PDRVX.mjs.map → chunk-TRXKPXDE.mjs.map} +0 -0
- /package/dist/{chunk-A6THC3F6.mjs.map → chunk-ZM6HV22S.mjs.map} +0 -0
package/dist/context/index.mjs
CHANGED
package/dist/hooks/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { useCoAgentStateRender } from './use-coagent-state-render.js';
|
|
|
4
4
|
export { useMakeCopilotDocumentReadable } from './use-make-copilot-document-readable.js';
|
|
5
5
|
export { UseChatHelpers } from './use-chat.js';
|
|
6
6
|
export { useCopilotReadable } from './use-copilot-readable.js';
|
|
7
|
-
export {
|
|
7
|
+
export { useCoAgent } from './use-coagent.js';
|
|
8
8
|
import '@copilotkit/runtime-client-gql';
|
|
9
9
|
import '../types/system-message.js';
|
|
10
10
|
import '../types/frontend-action.js';
|
|
@@ -16,4 +16,3 @@ import '../context/copilot-context.js';
|
|
|
16
16
|
import './use-tree.js';
|
|
17
17
|
import '../types/chat-suggestion-configuration.js';
|
|
18
18
|
import '../types/coagent-state.js';
|
|
19
|
-
import '../context/copilot-messages-context.js';
|
package/dist/hooks/index.js
CHANGED
|
@@ -79,9 +79,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
79
79
|
// src/hooks/index.ts
|
|
80
80
|
var hooks_exports = {};
|
|
81
81
|
__export(hooks_exports, {
|
|
82
|
-
runAgent: () => runAgent,
|
|
83
|
-
startAgent: () => startAgent,
|
|
84
|
-
stopAgent: () => stopAgent,
|
|
85
82
|
useCoAgent: () => useCoAgent,
|
|
86
83
|
useCoAgentStateRender: () => useCoAgentStateRender,
|
|
87
84
|
useCopilotAction: () => useCopilotAction,
|
|
@@ -144,15 +141,7 @@ var emptyCopilotContext = {
|
|
|
144
141
|
},
|
|
145
142
|
agentSession: null,
|
|
146
143
|
setAgentSession: () => {
|
|
147
|
-
}
|
|
148
|
-
agentLock: null,
|
|
149
|
-
threadId: null,
|
|
150
|
-
setThreadId: () => {
|
|
151
|
-
},
|
|
152
|
-
runId: null,
|
|
153
|
-
setRunId: () => {
|
|
154
|
-
},
|
|
155
|
-
chatAbortControllerRef: { current: null }
|
|
144
|
+
}
|
|
156
145
|
};
|
|
157
146
|
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
158
147
|
function useCopilotContext() {
|
|
@@ -189,22 +178,16 @@ function useChat(options) {
|
|
|
189
178
|
setCoagentStates,
|
|
190
179
|
coagentStates,
|
|
191
180
|
agentSession,
|
|
192
|
-
setAgentSession
|
|
193
|
-
threadId,
|
|
194
|
-
setThreadId,
|
|
195
|
-
runId,
|
|
196
|
-
setRunId,
|
|
197
|
-
chatAbortControllerRef
|
|
181
|
+
setAgentSession
|
|
198
182
|
} = options;
|
|
183
|
+
const abortControllerRef = (0, import_react2.useRef)();
|
|
184
|
+
const threadIdRef = (0, import_react2.useRef)(null);
|
|
185
|
+
const runIdRef = (0, import_react2.useRef)(null);
|
|
199
186
|
const runChatCompletionRef = (0, import_react2.useRef)();
|
|
200
187
|
const coagentStatesRef = (0, import_react2.useRef)(coagentStates);
|
|
201
188
|
coagentStatesRef.current = coagentStates;
|
|
202
189
|
const agentSessionRef = (0, import_react2.useRef)(agentSession);
|
|
203
190
|
agentSessionRef.current = agentSession;
|
|
204
|
-
const threadIdRef = (0, import_react2.useRef)(threadId);
|
|
205
|
-
threadIdRef.current = threadId;
|
|
206
|
-
const runIdRef = (0, import_react2.useRef)(runId);
|
|
207
|
-
runIdRef.current = runId;
|
|
208
191
|
const publicApiKey = copilotConfig.publicApiKey;
|
|
209
192
|
const headers = __spreadValues(__spreadValues({}, copilotConfig.headers || {}), publicApiKey ? { [import_shared.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
|
|
210
193
|
const runtimeClient = new import_runtime_client_gql.CopilotRuntimeClient({
|
|
@@ -223,7 +206,7 @@ function useChat(options) {
|
|
|
223
206
|
})
|
|
224
207
|
];
|
|
225
208
|
const abortController = new AbortController();
|
|
226
|
-
|
|
209
|
+
abortControllerRef.current = abortController;
|
|
227
210
|
setMessages([...previousMessages, ...newMessages]);
|
|
228
211
|
const systemMessage = makeSystemMessageCallback();
|
|
229
212
|
const messagesWithContext = [systemMessage, ...initialMessages || [], ...previousMessages];
|
|
@@ -263,7 +246,7 @@ function useChat(options) {
|
|
|
263
246
|
}))
|
|
264
247
|
}),
|
|
265
248
|
properties: copilotConfig.properties,
|
|
266
|
-
signal: (_d =
|
|
249
|
+
signal: (_d = abortControllerRef.current) == null ? void 0 : _d.signal
|
|
267
250
|
})
|
|
268
251
|
);
|
|
269
252
|
const guardrailsEnabled = ((_g = (_f = (_e = copilotConfig.cloud) == null ? void 0 : _e.guardrails) == null ? void 0 : _f.input) == null ? void 0 : _g.restrictToTopic.enabled) || false;
|
|
@@ -282,8 +265,6 @@ function useChat(options) {
|
|
|
282
265
|
}
|
|
283
266
|
threadIdRef.current = value.generateCopilotResponse.threadId || null;
|
|
284
267
|
runIdRef.current = value.generateCopilotResponse.runId || null;
|
|
285
|
-
setThreadId(threadIdRef.current);
|
|
286
|
-
setRunId(runIdRef.current);
|
|
287
268
|
const messages2 = (0, import_runtime_client_gql.convertGqlOutputToMessages)(
|
|
288
269
|
(0, import_runtime_client_gql.filterAdjacentAgentStateMessages)(value.generateCopilotResponse.messages)
|
|
289
270
|
);
|
|
@@ -412,7 +393,7 @@ function useChat(options) {
|
|
|
412
393
|
});
|
|
413
394
|
const stop = () => {
|
|
414
395
|
var _a;
|
|
415
|
-
(_a =
|
|
396
|
+
(_a = abortControllerRef.current) == null ? void 0 : _a.abort();
|
|
416
397
|
};
|
|
417
398
|
return {
|
|
418
399
|
append,
|
|
@@ -466,13 +447,7 @@ function useCopilotChat(_a = {}) {
|
|
|
466
447
|
setCoagentStates,
|
|
467
448
|
coAgentStateRenders,
|
|
468
449
|
agentSession,
|
|
469
|
-
setAgentSession
|
|
470
|
-
agentLock,
|
|
471
|
-
threadId,
|
|
472
|
-
setThreadId,
|
|
473
|
-
runId,
|
|
474
|
-
setRunId,
|
|
475
|
-
chatAbortControllerRef
|
|
450
|
+
setAgentSession
|
|
476
451
|
} = useCopilotContext();
|
|
477
452
|
const { messages, setMessages } = useCopilotMessagesContext();
|
|
478
453
|
const latestGetContextString = useUpdatedRef(getContextString);
|
|
@@ -522,12 +497,7 @@ function useCopilotChat(_a = {}) {
|
|
|
522
497
|
coagentStates,
|
|
523
498
|
setCoagentStates,
|
|
524
499
|
agentSession,
|
|
525
|
-
setAgentSession
|
|
526
|
-
threadId,
|
|
527
|
-
setThreadId,
|
|
528
|
-
runId,
|
|
529
|
-
setRunId,
|
|
530
|
-
chatAbortControllerRef
|
|
500
|
+
setAgentSession
|
|
531
501
|
}));
|
|
532
502
|
const latestAppend = useUpdatedRef(append);
|
|
533
503
|
const latestAppendFunc = (0, import_react5.useCallback)(
|
|
@@ -558,24 +528,6 @@ function useCopilotChat(_a = {}) {
|
|
|
558
528
|
},
|
|
559
529
|
[latestSetMessages]
|
|
560
530
|
);
|
|
561
|
-
const reset = (0, import_react5.useCallback)(() => {
|
|
562
|
-
latestStopFunc();
|
|
563
|
-
setMessages([]);
|
|
564
|
-
setThreadId(null);
|
|
565
|
-
setRunId(null);
|
|
566
|
-
setCoagentStates({});
|
|
567
|
-
let initialAgentSession = null;
|
|
568
|
-
if (agentLock) {
|
|
569
|
-
initialAgentSession = {
|
|
570
|
-
agentName: agentLock
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
setAgentSession(initialAgentSession);
|
|
574
|
-
}, [latestStopFunc, setMessages, setThreadId, setCoagentStates, setAgentSession, agentLock]);
|
|
575
|
-
const latestReset = useUpdatedRef(reset);
|
|
576
|
-
const latestResetFunc = (0, import_react5.useCallback)(() => {
|
|
577
|
-
return latestReset.current();
|
|
578
|
-
}, [latestReset]);
|
|
579
531
|
return {
|
|
580
532
|
visibleMessages: messages,
|
|
581
533
|
appendMessage: latestAppendFunc,
|
|
@@ -583,7 +535,6 @@ function useCopilotChat(_a = {}) {
|
|
|
583
535
|
reloadMessages: latestReloadFunc,
|
|
584
536
|
stopGeneration: latestStopFunc,
|
|
585
537
|
deleteMessage: latestDeleteFunc,
|
|
586
|
-
reset: latestResetFunc,
|
|
587
538
|
isLoading
|
|
588
539
|
};
|
|
589
540
|
}
|
|
@@ -808,11 +759,7 @@ function useCoAgent(options) {
|
|
|
808
759
|
} else if (coagentStates[name] === void 0) {
|
|
809
760
|
setState(options.initialState === void 0 ? {} : options.initialState);
|
|
810
761
|
}
|
|
811
|
-
}, [
|
|
812
|
-
isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0,
|
|
813
|
-
// reset initial state on reset
|
|
814
|
-
coagentStates[name] === void 0
|
|
815
|
-
]);
|
|
762
|
+
}, [isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0]);
|
|
816
763
|
return {
|
|
817
764
|
name,
|
|
818
765
|
nodeName: coagentState.nodeName,
|
|
@@ -840,17 +787,6 @@ function stopAgent(name, context) {
|
|
|
840
787
|
const { agentSession, setAgentSession } = context;
|
|
841
788
|
if (agentSession && agentSession.agentName === name) {
|
|
842
789
|
setAgentSession(null);
|
|
843
|
-
context.setCoagentStates((prevAgentStates) => {
|
|
844
|
-
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
845
|
-
[name]: __spreadProps(__spreadValues({}, prevAgentStates[name]), {
|
|
846
|
-
running: false,
|
|
847
|
-
active: false,
|
|
848
|
-
threadId: void 0,
|
|
849
|
-
nodeName: void 0,
|
|
850
|
-
runId: void 0
|
|
851
|
-
})
|
|
852
|
-
});
|
|
853
|
-
});
|
|
854
790
|
} else {
|
|
855
791
|
console.warn(`No agent session found for ${name}`);
|
|
856
792
|
}
|
|
@@ -882,9 +818,6 @@ function runAgent(name, context, appendMessage, hint) {
|
|
|
882
818
|
}
|
|
883
819
|
// Annotate the CommonJS export names for ESM import in node:
|
|
884
820
|
0 && (module.exports = {
|
|
885
|
-
runAgent,
|
|
886
|
-
startAgent,
|
|
887
|
-
stopAgent,
|
|
888
821
|
useCoAgent,
|
|
889
822
|
useCoAgentStateRender,
|
|
890
823
|
useCopilotAction,
|