@copilotkitnext/react 1.54.1-next.5 → 1.54.1
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/dist/components/chat/CopilotChat.cjs +3 -2
- package/dist/components/chat/CopilotChat.cjs.map +1 -1
- package/dist/components/chat/CopilotChat.d.cts +2 -0
- package/dist/components/chat/CopilotChat.d.cts.map +1 -1
- package/dist/components/chat/CopilotChat.d.mts +2 -0
- package/dist/components/chat/CopilotChat.d.mts.map +1 -1
- package/dist/components/chat/CopilotChat.mjs +3 -2
- package/dist/components/chat/CopilotChat.mjs.map +1 -1
- package/dist/components/chat/CopilotPopup.cjs +1 -0
- package/dist/components/chat/CopilotPopup.cjs.map +1 -1
- package/dist/components/chat/CopilotPopup.mjs +1 -0
- package/dist/components/chat/CopilotPopup.mjs.map +1 -1
- package/dist/components/chat/CopilotSidebar.cjs +1 -0
- package/dist/components/chat/CopilotSidebar.cjs.map +1 -1
- package/dist/components/chat/CopilotSidebar.mjs +1 -0
- package/dist/components/chat/CopilotSidebar.mjs.map +1 -1
- package/dist/hooks/use-interrupt.cjs +6 -1
- package/dist/hooks/use-interrupt.cjs.map +1 -1
- package/dist/hooks/use-interrupt.d.cts.map +1 -1
- package/dist/hooks/use-interrupt.d.mts.map +1 -1
- package/dist/hooks/use-interrupt.mjs +7 -2
- package/dist/hooks/use-interrupt.mjs.map +1 -1
- package/dist/hooks/use-threads.cjs +24 -15
- package/dist/hooks/use-threads.cjs.map +1 -1
- package/dist/hooks/use-threads.d.cts +32 -16
- package/dist/hooks/use-threads.d.cts.map +1 -1
- package/dist/hooks/use-threads.d.mts +32 -16
- package/dist/hooks/use-threads.d.mts.map +1 -1
- package/dist/hooks/use-threads.mjs +25 -16
- package/dist/hooks/use-threads.mjs.map +1 -1
- package/dist/index.umd.js +53 -20
- package/dist/index.umd.js.map +1 -1
- package/dist/providers/CopilotChatConfigurationProvider.cjs +17 -2
- package/dist/providers/CopilotChatConfigurationProvider.cjs.map +1 -1
- package/dist/providers/CopilotChatConfigurationProvider.d.cts.map +1 -1
- package/dist/providers/CopilotChatConfigurationProvider.d.mts.map +1 -1
- package/dist/providers/CopilotChatConfigurationProvider.mjs +18 -3
- package/dist/providers/CopilotChatConfigurationProvider.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.umd.js
CHANGED
|
@@ -79,8 +79,23 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
79
79
|
return (0, _copilotkitnext_shared.randomUUID)();
|
|
80
80
|
}, [threadId, parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.threadId]);
|
|
81
81
|
const [internalModalOpen, setInternalModalOpen] = (0, react.useState)(isModalDefaultOpen !== null && isModalDefaultOpen !== void 0 ? isModalDefaultOpen : true);
|
|
82
|
-
const
|
|
83
|
-
const
|
|
82
|
+
const hasExplicitDefault = isModalDefaultOpen !== void 0;
|
|
83
|
+
const setAndSync = (0, react.useCallback)((open) => {
|
|
84
|
+
setInternalModalOpen(open);
|
|
85
|
+
parentConfig === null || parentConfig === void 0 || parentConfig.setModalOpen(open);
|
|
86
|
+
}, [parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.setModalOpen]);
|
|
87
|
+
const isMounted = (0, react.useRef)(false);
|
|
88
|
+
(0, react.useEffect)(() => {
|
|
89
|
+
if (!hasExplicitDefault) return;
|
|
90
|
+
if (!isMounted.current) {
|
|
91
|
+
isMounted.current = true;
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if ((parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.isModalOpen) === void 0) return;
|
|
95
|
+
setInternalModalOpen(parentConfig.isModalOpen);
|
|
96
|
+
}, [parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.isModalOpen, hasExplicitDefault]);
|
|
97
|
+
const resolvedIsModalOpen = hasExplicitDefault ? internalModalOpen : (_parentConfig$isModal = parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.isModalOpen) !== null && _parentConfig$isModal !== void 0 ? _parentConfig$isModal : internalModalOpen;
|
|
98
|
+
const resolvedSetModalOpen = hasExplicitDefault ? setAndSync : (_parentConfig$setModa = parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.setModalOpen) !== null && _parentConfig$setModa !== void 0 ? _parentConfig$setModa : setInternalModalOpen;
|
|
84
99
|
const configurationValue = (0, react.useMemo)(() => ({
|
|
85
100
|
labels: mergedLabels,
|
|
86
101
|
agentId: resolvedAgentId,
|
|
@@ -3287,6 +3302,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3287
3302
|
const { copilotkit } = useCopilotKit();
|
|
3288
3303
|
const { agent } = useAgent({ agentId: config.agentId });
|
|
3289
3304
|
const [pendingEvent, setPendingEvent] = (0, react.useState)(null);
|
|
3305
|
+
const pendingEventRef = (0, react.useRef)(pendingEvent);
|
|
3306
|
+
pendingEventRef.current = pendingEvent;
|
|
3290
3307
|
const [handlerResult, setHandlerResult] = (0, react.useState)(null);
|
|
3291
3308
|
(0, react.useEffect)(() => {
|
|
3292
3309
|
let localInterrupt = null;
|
|
@@ -3314,10 +3331,14 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3314
3331
|
return () => subscription.unsubscribe();
|
|
3315
3332
|
}, [agent]);
|
|
3316
3333
|
const resolve = (0, react.useCallback)((response) => {
|
|
3334
|
+
var _pendingEventRef$curr;
|
|
3317
3335
|
setPendingEvent(null);
|
|
3318
3336
|
copilotkit.runAgent({
|
|
3319
3337
|
agent,
|
|
3320
|
-
forwardedProps: { command: {
|
|
3338
|
+
forwardedProps: { command: {
|
|
3339
|
+
resume: response,
|
|
3340
|
+
interruptEvent: (_pendingEventRef$curr = pendingEventRef.current) === null || _pendingEventRef$curr === void 0 ? void 0 : _pendingEventRef$curr.value
|
|
3341
|
+
} }
|
|
3321
3342
|
});
|
|
3322
3343
|
}, [agent, copilotkit]);
|
|
3323
3344
|
(0, react.useEffect)(() => {
|
|
@@ -3392,17 +3413,17 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3392
3413
|
/**
|
|
3393
3414
|
* React hook for listing and managing Intelligence platform threads.
|
|
3394
3415
|
*
|
|
3395
|
-
* On mount the hook fetches the thread list for the
|
|
3396
|
-
*
|
|
3397
|
-
* a realtime subscription so the `threads` array stays
|
|
3398
|
-
* polling — thread creates, renames, archives, and deletes
|
|
3399
|
-
* are reflected immediately.
|
|
3416
|
+
* On mount the hook fetches the thread list for the runtime-authenticated user
|
|
3417
|
+
* and the given `agentId`. When the Intelligence platform exposes a WebSocket
|
|
3418
|
+
* URL, it also opens a realtime subscription so the `threads` array stays
|
|
3419
|
+
* current without polling — thread creates, renames, archives, and deletes
|
|
3420
|
+
* from any client are reflected immediately.
|
|
3400
3421
|
*
|
|
3401
3422
|
* Mutation methods (`renameThread`, `archiveThread`, `deleteThread`) return
|
|
3402
3423
|
* promises that resolve once the platform confirms the operation and reject
|
|
3403
3424
|
* with an `Error` on failure.
|
|
3404
3425
|
*
|
|
3405
|
-
* @param input -
|
|
3426
|
+
* @param input - Agent identifier and optional list controls.
|
|
3406
3427
|
* @returns Thread list state and stable mutation callbacks.
|
|
3407
3428
|
*
|
|
3408
3429
|
* @example
|
|
@@ -3411,7 +3432,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3411
3432
|
*
|
|
3412
3433
|
* function ThreadList() {
|
|
3413
3434
|
* const { threads, isLoading, renameThread, deleteThread } = useThreads({
|
|
3414
|
-
* userId: "user-1",
|
|
3415
3435
|
* agentId: "agent-1",
|
|
3416
3436
|
* });
|
|
3417
3437
|
*
|
|
@@ -3431,13 +3451,15 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3431
3451
|
* }
|
|
3432
3452
|
* ```
|
|
3433
3453
|
*/
|
|
3434
|
-
function useThreads({
|
|
3454
|
+
function useThreads({ agentId, includeArchived, limit }) {
|
|
3435
3455
|
var _copilotkit$intellige2;
|
|
3436
3456
|
const { copilotkit } = useCopilotKit();
|
|
3437
3457
|
const [store] = (0, react.useState)(() => (0, _copilotkitnext_core.ɵcreateThreadStore)({ fetch: globalThis.fetch }));
|
|
3438
3458
|
const threads = useThreadStoreSelector(store, _copilotkitnext_core.ɵselectThreads);
|
|
3439
3459
|
const storeIsLoading = useThreadStoreSelector(store, _copilotkitnext_core.ɵselectThreadsIsLoading);
|
|
3440
3460
|
const storeError = useThreadStoreSelector(store, _copilotkitnext_core.ɵselectThreadsError);
|
|
3461
|
+
const hasNextPage = useThreadStoreSelector(store, _copilotkitnext_core.ɵselectHasNextPage);
|
|
3462
|
+
const isFetchingNextPage = useThreadStoreSelector(store, _copilotkitnext_core.ɵselectIsFetchingNextPage);
|
|
3441
3463
|
const headersKey = (0, react.useMemo)(() => {
|
|
3442
3464
|
var _copilotkit$headers;
|
|
3443
3465
|
return JSON.stringify(Object.entries((_copilotkit$headers = copilotkit.headers) !== null && _copilotkit$headers !== void 0 ? _copilotkit$headers : {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
@@ -3460,8 +3482,9 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3460
3482
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
3461
3483
|
headers: { ...copilotkit.headers },
|
|
3462
3484
|
wsUrl: (_copilotkit$intellige = copilotkit.intelligence) === null || _copilotkit$intellige === void 0 ? void 0 : _copilotkit$intellige.wsUrl,
|
|
3463
|
-
|
|
3464
|
-
|
|
3485
|
+
agentId,
|
|
3486
|
+
includeArchived,
|
|
3487
|
+
limit
|
|
3465
3488
|
} : null;
|
|
3466
3489
|
store.setContext(context);
|
|
3467
3490
|
}, [
|
|
@@ -3469,17 +3492,24 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3469
3492
|
copilotkit.runtimeUrl,
|
|
3470
3493
|
headersKey,
|
|
3471
3494
|
(_copilotkit$intellige2 = copilotkit.intelligence) === null || _copilotkit$intellige2 === void 0 ? void 0 : _copilotkit$intellige2.wsUrl,
|
|
3472
|
-
userId,
|
|
3473
3495
|
agentId,
|
|
3474
|
-
copilotkit.headers
|
|
3496
|
+
copilotkit.headers,
|
|
3497
|
+
includeArchived,
|
|
3498
|
+
limit
|
|
3475
3499
|
]);
|
|
3500
|
+
const renameThread = (0, react.useCallback)((threadId, name) => store.renameThread(threadId, name), [store]);
|
|
3501
|
+
const archiveThread = (0, react.useCallback)((threadId) => store.archiveThread(threadId), [store]);
|
|
3502
|
+
const deleteThread = (0, react.useCallback)((threadId) => store.deleteThread(threadId), [store]);
|
|
3476
3503
|
return {
|
|
3477
3504
|
threads,
|
|
3478
3505
|
isLoading,
|
|
3479
3506
|
error,
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3507
|
+
hasNextPage,
|
|
3508
|
+
isFetchingNextPage,
|
|
3509
|
+
fetchNextPage: (0, react.useCallback)(() => store.fetchNextPage(), [store]),
|
|
3510
|
+
renameThread,
|
|
3511
|
+
archiveThread,
|
|
3512
|
+
deleteThread
|
|
3483
3513
|
};
|
|
3484
3514
|
}
|
|
3485
3515
|
|
|
@@ -4735,7 +4765,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4735
4765
|
|
|
4736
4766
|
//#endregion
|
|
4737
4767
|
//#region src/components/chat/CopilotChat.tsx
|
|
4738
|
-
function CopilotChat({ agentId, threadId, labels, chatView, onError, ...props }) {
|
|
4768
|
+
function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen, onError, ...props }) {
|
|
4739
4769
|
var _ref;
|
|
4740
4770
|
const existingConfig = useCopilotChatConfiguration();
|
|
4741
4771
|
const resolvedAgentId = (_ref = agentId !== null && agentId !== void 0 ? agentId : existingConfig === null || existingConfig === void 0 ? void 0 : existingConfig.agentId) !== null && _ref !== void 0 ? _ref : _copilotkitnext_shared.DEFAULT_AGENT_ID;
|
|
@@ -4791,7 +4821,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4791
4821
|
return () => {
|
|
4792
4822
|
detached = true;
|
|
4793
4823
|
connectAbortController.abort();
|
|
4794
|
-
agent.detachActiveRun();
|
|
4824
|
+
agent.detachActiveRun().catch(() => {});
|
|
4795
4825
|
};
|
|
4796
4826
|
}, [
|
|
4797
4827
|
resolvedThreadId,
|
|
@@ -4926,6 +4956,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4926
4956
|
agentId: resolvedAgentId,
|
|
4927
4957
|
threadId: resolvedThreadId,
|
|
4928
4958
|
labels,
|
|
4959
|
+
isModalDefaultOpen,
|
|
4929
4960
|
children: [transcriptionError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4930
4961
|
style: {
|
|
4931
4962
|
position: "absolute",
|
|
@@ -5395,6 +5426,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5395
5426
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChat, {
|
|
5396
5427
|
welcomeScreen: CopilotSidebarView.WelcomeScreen,
|
|
5397
5428
|
...chatProps,
|
|
5429
|
+
isModalDefaultOpen: defaultOpen,
|
|
5398
5430
|
chatView: SidebarViewOverride
|
|
5399
5431
|
});
|
|
5400
5432
|
}
|
|
@@ -5428,6 +5460,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5428
5460
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChat, {
|
|
5429
5461
|
welcomeScreen: CopilotPopupView_default.WelcomeScreen,
|
|
5430
5462
|
...chatProps,
|
|
5463
|
+
isModalDefaultOpen: defaultOpen,
|
|
5431
5464
|
chatView: PopupViewOverride
|
|
5432
5465
|
});
|
|
5433
5466
|
}
|