@copilotkit/react-core 1.70.1 → 1.70.2
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/{copilotkit-DsWuxPUQ.d.mts → copilotkit--Jyzm6hS.d.mts} +31 -1
- package/dist/{copilotkit-DsWuxPUQ.d.mts.map → copilotkit--Jyzm6hS.d.mts.map} +1 -1
- package/dist/{copilotkit-DiUK2Bhq.mjs → copilotkit-B1jSvZeb.mjs} +251 -81
- package/dist/copilotkit-B1jSvZeb.mjs.map +1 -0
- package/dist/{copilotkit-CtF2clxZ.d.cts → copilotkit-BLYaCGcz.d.cts} +31 -1
- package/dist/{copilotkit-CtF2clxZ.d.cts.map → copilotkit-BLYaCGcz.d.cts.map} +1 -1
- package/dist/{copilotkit-CxLT6zFx.cjs → copilotkit-DcFo270Y.cjs} +251 -81
- package/dist/copilotkit-DcFo270Y.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +56 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +56 -0
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.mjs +57 -1
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.css +1 -1
- package/dist/v2/index.d.cts +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +251 -81
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/skills/react-core/SKILL.md +1 -1
- package/skills/react-core/references/attachments.md +20 -0
- package/dist/copilotkit-CxLT6zFx.cjs.map +0 -1
- package/dist/copilotkit-DiUK2Bhq.mjs.map +0 -1
|
@@ -268,6 +268,62 @@ const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId,
|
|
|
268
268
|
const useCopilotChatConfiguration = () => {
|
|
269
269
|
return useContext(CopilotChatConfiguration);
|
|
270
270
|
};
|
|
271
|
+
/**
|
|
272
|
+
* Reports modal open/close requests to the host, and — when `open` is
|
|
273
|
+
* supplied — makes the modal state of an already-established chat
|
|
274
|
+
* configuration **controlled** for the subtree it wraps.
|
|
275
|
+
*
|
|
276
|
+
* This is deliberately a scope component rather than another mode inside
|
|
277
|
+
* {@link CopilotChatConfigurationProvider}. The provider resolves modal state
|
|
278
|
+
* across a nested chain (own state, parent sync, drawer mutual-exclusion, the
|
|
279
|
+
* modal-closer registry); a controlled branch inside that resolution would add
|
|
280
|
+
* a fourth interacting mode. Overriding the context for the subtree instead
|
|
281
|
+
* leaves every one of those paths untouched:
|
|
282
|
+
*
|
|
283
|
+
* - `isModalOpen` is replaced with the host's `open`, so the rendered surface
|
|
284
|
+
* follows the prop from the very first frame (no open-then-close flash).
|
|
285
|
+
* - `setModalOpen` still calls the underlying setter, so the existing
|
|
286
|
+
* parent-sync and drawer mutual-exclusion side effects continue to run, and
|
|
287
|
+
* *then* reports the request through `onOpenChange`.
|
|
288
|
+
* - The wrapped setter is registered as the modal closer, so the drawer's
|
|
289
|
+
* mobile mutual-exclusion reaches the host instead of silently flipping
|
|
290
|
+
* state that nothing displays.
|
|
291
|
+
*
|
|
292
|
+
* A host that supplies `open` and ignores `onOpenChange` gets a modal pinned
|
|
293
|
+
* to `open`, which is the standard controlled-component contract. A host that
|
|
294
|
+
* supplies only `onOpenChange` is notified while the modal keeps managing
|
|
295
|
+
* itself.
|
|
296
|
+
*
|
|
297
|
+
* Renders `children` unchanged when no chat configuration is in scope.
|
|
298
|
+
*/
|
|
299
|
+
const ControlledModalOpenScope = ({ children, open, onOpenChange }) => {
|
|
300
|
+
const parentConfig = useContext(CopilotChatConfiguration);
|
|
301
|
+
const parentSetModalOpen = parentConfig?.setModalOpen;
|
|
302
|
+
const registerModalCloser = parentConfig?.ɵregisterModalCloser;
|
|
303
|
+
const setModalOpen = useCallback((next) => {
|
|
304
|
+
parentSetModalOpen?.(next);
|
|
305
|
+
onOpenChange?.(next);
|
|
306
|
+
}, [parentSetModalOpen, onOpenChange]);
|
|
307
|
+
useEffect(() => {
|
|
308
|
+
if (!registerModalCloser) return;
|
|
309
|
+
return registerModalCloser(setModalOpen);
|
|
310
|
+
}, [registerModalCloser, setModalOpen]);
|
|
311
|
+
const configurationValue = useMemo(() => parentConfig ? {
|
|
312
|
+
...parentConfig,
|
|
313
|
+
isModalOpen: open ?? parentConfig.isModalOpen,
|
|
314
|
+
setModalOpen
|
|
315
|
+
} : null, [
|
|
316
|
+
parentConfig,
|
|
317
|
+
open,
|
|
318
|
+
setModalOpen
|
|
319
|
+
]);
|
|
320
|
+
if (!configurationValue) return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
321
|
+
return /* @__PURE__ */ jsx(CopilotChatConfiguration.Provider, {
|
|
322
|
+
value: configurationValue,
|
|
323
|
+
children
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
ControlledModalOpenScope.displayName = "ControlledModalOpenScope";
|
|
271
327
|
|
|
272
328
|
//#endregion
|
|
273
329
|
//#region src/v2/lib/utils.ts
|
|
@@ -5394,7 +5450,7 @@ function useMemories() {
|
|
|
5394
5450
|
* at the call site.
|
|
5395
5451
|
*/
|
|
5396
5452
|
async function recordAnnotation(args) {
|
|
5397
|
-
const { runtimeUrl, headers, type, payload, threadId, occurredAt } = args;
|
|
5453
|
+
const { runtimeUrl, headers, type, payload, threadId, occurredAt, fetch: fetchImplementation = globalThis.fetch } = args;
|
|
5398
5454
|
const body = {
|
|
5399
5455
|
type,
|
|
5400
5456
|
threadId,
|
|
@@ -5402,7 +5458,7 @@ async function recordAnnotation(args) {
|
|
|
5402
5458
|
...payload !== void 0 ? { payload } : {},
|
|
5403
5459
|
...occurredAt !== void 0 ? { occurredAt } : {}
|
|
5404
5460
|
};
|
|
5405
|
-
const response = await
|
|
5461
|
+
const response = await fetchImplementation(`${runtimeUrl}/annotate`, {
|
|
5406
5462
|
method: "POST",
|
|
5407
5463
|
headers: {
|
|
5408
5464
|
"Content-Type": "application/json",
|
|
@@ -5471,6 +5527,7 @@ function useLearnFromUserAction() {
|
|
|
5471
5527
|
...input.data !== void 0 ? { data: input.data } : {}
|
|
5472
5528
|
};
|
|
5473
5529
|
return recordAnnotation({
|
|
5530
|
+
fetch: copilotkit.ɵruntimeFetch,
|
|
5474
5531
|
runtimeUrl,
|
|
5475
5532
|
headers: copilotkit.headers ?? {},
|
|
5476
5533
|
type: "user_action",
|
|
@@ -5540,6 +5597,21 @@ function useLearnFromUserActionInCurrentThread() {
|
|
|
5540
5597
|
|
|
5541
5598
|
//#endregion
|
|
5542
5599
|
//#region src/v2/hooks/use-attachments.tsx
|
|
5600
|
+
const DEFAULT_MAX_SIZE = 20 * 1024 * 1024;
|
|
5601
|
+
/**
|
|
5602
|
+
* How many uploads run at once when `maxConcurrentUploads` is unset. One, because
|
|
5603
|
+
* `onUpload` is a public callback an app may have written expecting the previous
|
|
5604
|
+
* file to have finished — concurrency is something the app asks for.
|
|
5605
|
+
*/
|
|
5606
|
+
const DEFAULT_MAX_CONCURRENT_UPLOADS = 1;
|
|
5607
|
+
/**
|
|
5608
|
+
* At least one upload at a time, whole files only; `NaN` or a non-number falls back to the
|
|
5609
|
+
* default, and `Infinity` means "no limit" — bounded in practice by how many files are queued.
|
|
5610
|
+
*/
|
|
5611
|
+
function resolveMaxConcurrentUploads(configured) {
|
|
5612
|
+
if (typeof configured !== "number" || Number.isNaN(configured)) return DEFAULT_MAX_CONCURRENT_UPLOADS;
|
|
5613
|
+
return Math.max(1, Math.floor(configured));
|
|
5614
|
+
}
|
|
5543
5615
|
/**
|
|
5544
5616
|
* Hook that manages file attachment state — uploads, drag-and-drop, paste,
|
|
5545
5617
|
* and lifecycle. All returned callbacks are referentially stable across
|
|
@@ -5555,10 +5627,62 @@ function useAttachments({ config }) {
|
|
|
5555
5627
|
configRef.current = config;
|
|
5556
5628
|
const attachmentsRef = useRef([]);
|
|
5557
5629
|
attachmentsRef.current = attachments;
|
|
5630
|
+
const uploadQueueRef = useRef([]);
|
|
5631
|
+
const activeWorkersRef = useRef(0);
|
|
5632
|
+
const uploadFile = useCallback(async (file, placeholder, cfg) => {
|
|
5633
|
+
try {
|
|
5634
|
+
let source;
|
|
5635
|
+
let uploadMetadata;
|
|
5636
|
+
if (cfg?.onUpload) {
|
|
5637
|
+
const { metadata: meta, ...uploadSource } = await cfg.onUpload(file);
|
|
5638
|
+
source = uploadSource;
|
|
5639
|
+
uploadMetadata = meta;
|
|
5640
|
+
} else source = {
|
|
5641
|
+
type: "data",
|
|
5642
|
+
value: await readFileAsBase64(file),
|
|
5643
|
+
mimeType: file.type
|
|
5644
|
+
};
|
|
5645
|
+
let thumbnail;
|
|
5646
|
+
if (placeholder.type === "video") thumbnail = await generateVideoThumbnail(file);
|
|
5647
|
+
setAttachments((prev) => prev.map((att) => att.id === placeholder.id ? {
|
|
5648
|
+
...att,
|
|
5649
|
+
source,
|
|
5650
|
+
status: "ready",
|
|
5651
|
+
thumbnail,
|
|
5652
|
+
metadata: uploadMetadata
|
|
5653
|
+
} : att));
|
|
5654
|
+
} catch (error) {
|
|
5655
|
+
setAttachments((prev) => prev.filter((att) => att.id !== placeholder.id));
|
|
5656
|
+
console.error(`[CopilotKit] Failed to upload "${file.name}":`, error);
|
|
5657
|
+
cfg?.onUploadFailed?.({
|
|
5658
|
+
reason: "upload-failed",
|
|
5659
|
+
file,
|
|
5660
|
+
message: error instanceof Error ? error.message : `Failed to upload "${file.name}"`
|
|
5661
|
+
});
|
|
5662
|
+
}
|
|
5663
|
+
}, []);
|
|
5664
|
+
const drainUploadQueue = useCallback(async () => {
|
|
5665
|
+
activeWorkersRef.current++;
|
|
5666
|
+
try {
|
|
5667
|
+
for (;;) {
|
|
5668
|
+
const item = uploadQueueRef.current.shift();
|
|
5669
|
+
if (!item) return;
|
|
5670
|
+
try {
|
|
5671
|
+
await uploadFile(item.file, item.placeholder, item.cfg);
|
|
5672
|
+
} catch (error) {
|
|
5673
|
+
console.error("[CopilotKit] Upload worker error:", error);
|
|
5674
|
+
} finally {
|
|
5675
|
+
item.settle();
|
|
5676
|
+
}
|
|
5677
|
+
}
|
|
5678
|
+
} finally {
|
|
5679
|
+
activeWorkersRef.current--;
|
|
5680
|
+
}
|
|
5681
|
+
}, [uploadFile]);
|
|
5558
5682
|
const processFiles = useCallback(async (files) => {
|
|
5559
5683
|
const cfg = configRef.current;
|
|
5560
5684
|
const accept = cfg?.accept ?? "*/*";
|
|
5561
|
-
const maxSize = cfg?.maxSize ??
|
|
5685
|
+
const maxSize = cfg?.maxSize ?? DEFAULT_MAX_SIZE;
|
|
5562
5686
|
const rejectedFiles = files.filter((file) => !matchesAcceptFilter(file, accept));
|
|
5563
5687
|
for (const file of rejectedFiles) cfg?.onUploadFailed?.({
|
|
5564
5688
|
reason: "invalid-type",
|
|
@@ -5566,6 +5690,7 @@ function useAttachments({ config }) {
|
|
|
5566
5690
|
message: `File "${file.name}" is not accepted. Supported types: ${accept}`
|
|
5567
5691
|
});
|
|
5568
5692
|
const validFiles = files.filter((file) => matchesAcceptFilter(file, accept));
|
|
5693
|
+
const queued = [];
|
|
5569
5694
|
for (const file of validFiles) {
|
|
5570
5695
|
if (exceedsMaxSize(file, maxSize)) {
|
|
5571
5696
|
cfg?.onUploadFailed?.({
|
|
@@ -5575,53 +5700,37 @@ function useAttachments({ config }) {
|
|
|
5575
5700
|
});
|
|
5576
5701
|
continue;
|
|
5577
5702
|
}
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
try {
|
|
5594
|
-
let source;
|
|
5595
|
-
let uploadMetadata;
|
|
5596
|
-
if (cfg?.onUpload) {
|
|
5597
|
-
const { metadata: meta, ...uploadSource } = await cfg.onUpload(file);
|
|
5598
|
-
source = uploadSource;
|
|
5599
|
-
uploadMetadata = meta;
|
|
5600
|
-
} else source = {
|
|
5601
|
-
type: "data",
|
|
5602
|
-
value: await readFileAsBase64(file),
|
|
5603
|
-
mimeType: file.type
|
|
5604
|
-
};
|
|
5605
|
-
let thumbnail;
|
|
5606
|
-
if (modality === "video") thumbnail = await generateVideoThumbnail(file);
|
|
5607
|
-
setAttachments((prev) => prev.map((att) => att.id === placeholderId ? {
|
|
5608
|
-
...att,
|
|
5609
|
-
source,
|
|
5610
|
-
status: "ready",
|
|
5611
|
-
thumbnail,
|
|
5612
|
-
metadata: uploadMetadata
|
|
5613
|
-
} : att));
|
|
5614
|
-
} catch (error) {
|
|
5615
|
-
setAttachments((prev) => prev.filter((att) => att.id !== placeholderId));
|
|
5616
|
-
console.error(`[CopilotKit] Failed to upload "${file.name}":`, error);
|
|
5617
|
-
cfg?.onUploadFailed?.({
|
|
5618
|
-
reason: "upload-failed",
|
|
5619
|
-
file,
|
|
5620
|
-
message: error instanceof Error ? error.message : `Failed to upload "${file.name}"`
|
|
5621
|
-
});
|
|
5622
|
-
}
|
|
5703
|
+
queued.push({
|
|
5704
|
+
file,
|
|
5705
|
+
placeholder: {
|
|
5706
|
+
id: randomUUID$1(),
|
|
5707
|
+
type: getModalityFromMimeType(file.type),
|
|
5708
|
+
source: {
|
|
5709
|
+
type: "data",
|
|
5710
|
+
value: "",
|
|
5711
|
+
mimeType: file.type
|
|
5712
|
+
},
|
|
5713
|
+
filename: file.name,
|
|
5714
|
+
size: file.size,
|
|
5715
|
+
status: "uploading"
|
|
5716
|
+
}
|
|
5717
|
+
});
|
|
5623
5718
|
}
|
|
5624
|
-
|
|
5719
|
+
if (queued.length === 0) return;
|
|
5720
|
+
setAttachments((prev) => [...prev, ...queued.map((q) => q.placeholder)]);
|
|
5721
|
+
const settled = queued.map(({ file, placeholder }) => new Promise((resolve) => {
|
|
5722
|
+
uploadQueueRef.current.push({
|
|
5723
|
+
file,
|
|
5724
|
+
placeholder,
|
|
5725
|
+
cfg,
|
|
5726
|
+
settle: resolve
|
|
5727
|
+
});
|
|
5728
|
+
}));
|
|
5729
|
+
const limit = resolveMaxConcurrentUploads(cfg?.maxConcurrentUploads);
|
|
5730
|
+
const toSpawn = Math.min(uploadQueueRef.current.length, Math.max(0, limit - activeWorkersRef.current));
|
|
5731
|
+
for (let i = 0; i < toSpawn; i++) drainUploadQueue();
|
|
5732
|
+
await Promise.all(settled);
|
|
5733
|
+
}, [drainUploadQueue]);
|
|
5625
5734
|
const handleFileUpload = useCallback(async (e) => {
|
|
5626
5735
|
if (!e.target.files?.length) return;
|
|
5627
5736
|
try {
|
|
@@ -5749,8 +5858,10 @@ function useLearningContainers({ threadId, learningContainers }) {
|
|
|
5749
5858
|
const warnedMissingUrlRef = useRef(false);
|
|
5750
5859
|
const runtimeUrlRef = useRef(copilotkit.runtimeUrl);
|
|
5751
5860
|
const headersRef = useRef(copilotkit.headers ?? {});
|
|
5861
|
+
const runtimeFetchRef = useRef(copilotkit.ɵruntimeFetch);
|
|
5752
5862
|
runtimeUrlRef.current = copilotkit.runtimeUrl;
|
|
5753
5863
|
headersRef.current = copilotkit.headers ?? {};
|
|
5864
|
+
runtimeFetchRef.current = copilotkit.ɵruntimeFetch;
|
|
5754
5865
|
const key = JSON.stringify(learningContainers);
|
|
5755
5866
|
const defaultKey = JSON.stringify(DEFAULT_CONTAINERS);
|
|
5756
5867
|
useEffect(() => {
|
|
@@ -5770,6 +5881,7 @@ function useLearningContainers({ threadId, learningContainers }) {
|
|
|
5770
5881
|
return;
|
|
5771
5882
|
}
|
|
5772
5883
|
recordAnnotation({
|
|
5884
|
+
fetch: copilotkit.ɵruntimeFetch,
|
|
5773
5885
|
runtimeUrl,
|
|
5774
5886
|
headers,
|
|
5775
5887
|
type: "set_learning_containers",
|
|
@@ -5797,6 +5909,7 @@ function useLearningContainers({ threadId, learningContainers }) {
|
|
|
5797
5909
|
const capturedRuntimeUrl = runtimeUrlRef.current;
|
|
5798
5910
|
const capturedHeaders = headersRef.current;
|
|
5799
5911
|
if (capturedRuntimeUrl) recordAnnotation({
|
|
5912
|
+
fetch: runtimeFetchRef.current,
|
|
5800
5913
|
runtimeUrl: capturedRuntimeUrl,
|
|
5801
5914
|
headers: capturedHeaders,
|
|
5802
5915
|
type: "set_learning_containers",
|
|
@@ -9059,6 +9172,41 @@ const CopilotChatToggleButton = React.forwardRef(function CopilotChatToggleButto
|
|
|
9059
9172
|
});
|
|
9060
9173
|
CopilotChatToggleButton.displayName = "CopilotChatToggleButton";
|
|
9061
9174
|
|
|
9175
|
+
//#endregion
|
|
9176
|
+
//#region src/v2/components/chat/modal-open-control.tsx
|
|
9177
|
+
const ModalOpenControlContext = createContext({});
|
|
9178
|
+
/**
|
|
9179
|
+
* Carries `open` / `onOpenChange` from a prebuilt surface down to the view that
|
|
9180
|
+
* owns the modal state.
|
|
9181
|
+
*
|
|
9182
|
+
* A context is required rather than plain props because `<CopilotSidebar>`
|
|
9183
|
+
* hands its view to `<CopilotChat>` as a `chatView` **component**. Threading a
|
|
9184
|
+
* value that changes (like `open`) through that component's identity would mint
|
|
9185
|
+
* a new element type on every toggle, and React unmounts and remounts the whole
|
|
9186
|
+
* chat subtree when the element type changes. That is the remount class of bug
|
|
9187
|
+
* already fixed for `<CopilotPopup>` on resize. Context keeps the override
|
|
9188
|
+
* identity stable while still re-rendering the view when `open` changes.
|
|
9189
|
+
*/
|
|
9190
|
+
function ModalOpenControlProvider({ open, onOpenChange, children }) {
|
|
9191
|
+
const value = useMemo(() => ({
|
|
9192
|
+
open,
|
|
9193
|
+
onOpenChange
|
|
9194
|
+
}), [open, onOpenChange]);
|
|
9195
|
+
return /* @__PURE__ */ jsx(ModalOpenControlContext.Provider, {
|
|
9196
|
+
value,
|
|
9197
|
+
children
|
|
9198
|
+
});
|
|
9199
|
+
}
|
|
9200
|
+
/**
|
|
9201
|
+
* Reads the controlled open state supplied by the surrounding prebuilt
|
|
9202
|
+
* surface. Returns an empty control (uncontrolled) when there is none.
|
|
9203
|
+
*
|
|
9204
|
+
* @returns The host's `open` / `onOpenChange` pair.
|
|
9205
|
+
*/
|
|
9206
|
+
function useModalOpenControl() {
|
|
9207
|
+
return useContext(ModalOpenControlContext);
|
|
9208
|
+
}
|
|
9209
|
+
|
|
9062
9210
|
//#endregion
|
|
9063
9211
|
//#region src/v2/components/chat/CopilotModalHeader.tsx
|
|
9064
9212
|
/**
|
|
@@ -9168,15 +9316,22 @@ CopilotModalHeader.DrawerLauncher.displayName = "CopilotModalHeader.DrawerLaunch
|
|
|
9168
9316
|
const DEFAULT_SIDEBAR_WIDTH = 480;
|
|
9169
9317
|
const SIDEBAR_TRANSITION_MS = 260;
|
|
9170
9318
|
function CopilotSidebarView({ header, toggleButton, width, defaultOpen = true, position = "right", ...props }) {
|
|
9319
|
+
const { open, onOpenChange } = useModalOpenControl();
|
|
9320
|
+
const hasOpenControl = open !== void 0 || onOpenChange !== void 0;
|
|
9321
|
+
const internal = /* @__PURE__ */ jsx(CopilotSidebarViewInternal, {
|
|
9322
|
+
header,
|
|
9323
|
+
toggleButton,
|
|
9324
|
+
width,
|
|
9325
|
+
position,
|
|
9326
|
+
...props
|
|
9327
|
+
});
|
|
9171
9328
|
return /* @__PURE__ */ jsx(CopilotChatConfigurationProvider, {
|
|
9172
|
-
isModalDefaultOpen: defaultOpen,
|
|
9173
|
-
children: /* @__PURE__ */ jsx(
|
|
9174
|
-
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
...props
|
|
9179
|
-
})
|
|
9329
|
+
isModalDefaultOpen: open ?? defaultOpen,
|
|
9330
|
+
children: hasOpenControl ? /* @__PURE__ */ jsx(ControlledModalOpenScope, {
|
|
9331
|
+
open,
|
|
9332
|
+
onOpenChange,
|
|
9333
|
+
children: internal
|
|
9334
|
+
}) : internal
|
|
9180
9335
|
});
|
|
9181
9336
|
}
|
|
9182
9337
|
function CopilotSidebarViewInternal({ header, toggleButton, width, position = "right", ...props }) {
|
|
@@ -9240,7 +9395,7 @@ function CopilotSidebarViewInternal({ header, toggleButton, width, position = "r
|
|
|
9240
9395
|
"data-position": position,
|
|
9241
9396
|
className: cn("copilotKitSidebar copilotKitWindow", "cpk:fixed cpk:top-0 cpk:z-[1200] cpk:flex", position === "left" ? "cpk:left-0" : "cpk:right-0", "cpk:h-[100vh] cpk:h-[100dvh] cpk:max-h-screen", "cpk:w-full", position === "left" ? "cpk:border-r" : "cpk:border-l", "cpk:border-border cpk:bg-background cpk:text-foreground cpk:shadow-xl", "cpk:transition-transform cpk:duration-300 cpk:ease-out", isSidebarOpen ? "cpk:translate-x-0" : position === "left" ? "cpk:-translate-x-full cpk:pointer-events-none" : "cpk:translate-x-full cpk:pointer-events-none"),
|
|
9242
9397
|
style: {
|
|
9243
|
-
|
|
9398
|
+
"--sidebar-width": widthToCss(sidebarWidth),
|
|
9244
9399
|
paddingTop: "env(safe-area-inset-top)",
|
|
9245
9400
|
paddingBottom: "env(safe-area-inset-bottom)"
|
|
9246
9401
|
},
|
|
@@ -9302,17 +9457,24 @@ const dimensionToCss = (value, fallback) => {
|
|
|
9302
9457
|
return `${fallback}px`;
|
|
9303
9458
|
};
|
|
9304
9459
|
function CopilotPopupView({ header, toggleButton, width, height, clickOutsideToClose, defaultOpen = true, className, ...restProps }) {
|
|
9460
|
+
const { open, onOpenChange } = useModalOpenControl();
|
|
9461
|
+
const hasOpenControl = open !== void 0 || onOpenChange !== void 0;
|
|
9462
|
+
const internal = /* @__PURE__ */ jsx(CopilotPopupViewInternal, {
|
|
9463
|
+
header,
|
|
9464
|
+
toggleButton,
|
|
9465
|
+
width,
|
|
9466
|
+
height,
|
|
9467
|
+
clickOutsideToClose,
|
|
9468
|
+
className,
|
|
9469
|
+
...restProps
|
|
9470
|
+
});
|
|
9305
9471
|
return /* @__PURE__ */ jsx(CopilotChatConfigurationProvider, {
|
|
9306
|
-
isModalDefaultOpen: defaultOpen,
|
|
9307
|
-
children: /* @__PURE__ */ jsx(
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
clickOutsideToClose,
|
|
9313
|
-
className,
|
|
9314
|
-
...restProps
|
|
9315
|
-
})
|
|
9472
|
+
isModalDefaultOpen: open ?? defaultOpen,
|
|
9473
|
+
children: hasOpenControl ? /* @__PURE__ */ jsx(ControlledModalOpenScope, {
|
|
9474
|
+
open,
|
|
9475
|
+
onOpenChange,
|
|
9476
|
+
children: internal
|
|
9477
|
+
}) : internal
|
|
9316
9478
|
});
|
|
9317
9479
|
}
|
|
9318
9480
|
function CopilotPopupViewInternal({ header, toggleButton, width, height, clickOutsideToClose, className, ...restProps }) {
|
|
@@ -9445,7 +9607,7 @@ var CopilotPopupView_default = CopilotPopupView;
|
|
|
9445
9607
|
|
|
9446
9608
|
//#endregion
|
|
9447
9609
|
//#region src/v2/components/chat/CopilotSidebar.tsx
|
|
9448
|
-
function CopilotSidebar({ header, toggleButton, defaultOpen, width, position, ...chatProps }) {
|
|
9610
|
+
function CopilotSidebar({ header, toggleButton, defaultOpen, open, onOpenChange, width, position, ...chatProps }) {
|
|
9449
9611
|
const { checkFeature } = useLicenseContext$1();
|
|
9450
9612
|
const isSidebarLicensed = checkFeature("sidebar");
|
|
9451
9613
|
useEffect(() => {
|
|
@@ -9471,11 +9633,15 @@ function CopilotSidebar({ header, toggleButton, defaultOpen, width, position, ..
|
|
|
9471
9633
|
defaultOpen,
|
|
9472
9634
|
position
|
|
9473
9635
|
]);
|
|
9474
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [!isSidebarLicensed && /* @__PURE__ */ jsx(InlineFeatureWarning, { featureName: "Sidebar" }), /* @__PURE__ */ jsx(
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9478
|
-
|
|
9636
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [!isSidebarLicensed && /* @__PURE__ */ jsx(InlineFeatureWarning, { featureName: "Sidebar" }), /* @__PURE__ */ jsx(ModalOpenControlProvider, {
|
|
9637
|
+
open,
|
|
9638
|
+
onOpenChange,
|
|
9639
|
+
children: /* @__PURE__ */ jsx(CopilotChat, {
|
|
9640
|
+
welcomeScreen: CopilotSidebarView.WelcomeScreen,
|
|
9641
|
+
...chatProps,
|
|
9642
|
+
isModalDefaultOpen: defaultOpen,
|
|
9643
|
+
chatView: SidebarViewOverride
|
|
9644
|
+
})
|
|
9479
9645
|
})] });
|
|
9480
9646
|
}
|
|
9481
9647
|
CopilotSidebar.displayName = "CopilotSidebar";
|
|
@@ -9497,7 +9663,7 @@ const PopupViewOverride = (viewProps) => {
|
|
|
9497
9663
|
});
|
|
9498
9664
|
};
|
|
9499
9665
|
const PopupViewOverrideWithStatics = Object.assign(PopupViewOverride, CopilotChatView_default);
|
|
9500
|
-
function CopilotPopup({ header, toggleButton, defaultOpen, width, height, clickOutsideToClose, ...chatProps }) {
|
|
9666
|
+
function CopilotPopup({ header, toggleButton, defaultOpen, open, onOpenChange, width, height, clickOutsideToClose, ...chatProps }) {
|
|
9501
9667
|
const { checkFeature } = useLicenseContext$1();
|
|
9502
9668
|
const isPopupLicensed = checkFeature("popup");
|
|
9503
9669
|
useEffect(() => {
|
|
@@ -9520,11 +9686,15 @@ function CopilotPopup({ header, toggleButton, defaultOpen, width, height, clickO
|
|
|
9520
9686
|
]);
|
|
9521
9687
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [!isPopupLicensed && /* @__PURE__ */ jsx(InlineFeatureWarning, { featureName: "Popup" }), /* @__PURE__ */ jsx(PopupShellPropsContext.Provider, {
|
|
9522
9688
|
value: shellProps,
|
|
9523
|
-
children: /* @__PURE__ */ jsx(
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
|
|
9689
|
+
children: /* @__PURE__ */ jsx(ModalOpenControlProvider, {
|
|
9690
|
+
open,
|
|
9691
|
+
onOpenChange,
|
|
9692
|
+
children: /* @__PURE__ */ jsx(CopilotChat, {
|
|
9693
|
+
welcomeScreen: CopilotPopupView_default.WelcomeScreen,
|
|
9694
|
+
...chatProps,
|
|
9695
|
+
isModalDefaultOpen: defaultOpen,
|
|
9696
|
+
chatView: PopupViewOverrideWithStatics
|
|
9697
|
+
})
|
|
9528
9698
|
})
|
|
9529
9699
|
})] });
|
|
9530
9700
|
}
|
|
@@ -12078,4 +12248,4 @@ function validateProps(props) {
|
|
|
12078
12248
|
|
|
12079
12249
|
//#endregion
|
|
12080
12250
|
export { useAgentContext as $, CopilotChatMessageView as A, AudioRecorderError as At, CopilotChatAssistantMessage_default as B, CopilotModalHeader as C, MCPAppsActivityContentSchema as Ct, CopilotChat as D, CopilotKitInspector as Dt, DefaultOpenIcon as E, ɵrunMcpFollowUp as Et, CopilotChatSuggestionView as F, useLearnFromUserActionInCurrentThread as G, useLearningContainersInCurrentThread as H, CopilotChatSuggestionPill as I, useThreads$1 as J, useLearnFromUserAction as K, CopilotChatReasoningMessage_default as L, IntelligenceIndicator as M, CopilotChatConfigurationProvider as Mt, getIntelligenceTurnAnchors as N, useCopilotChatConfiguration as Nt, CopilotChatView_default as O, useRenderToolCall as Ot, IntelligenceIndicatorView as P, useSuggestions as Q, CopilotChatUserMessage_default as R, CopilotSidebarView as S, useSandboxFunctions as St, DefaultCloseIcon as T, MCPAppsActivityType as Tt, useLearningContainers as U, CopilotChatToolCallsView as V, useAttachments as W, INTERRUPT_EVENT_NAME as X, useInterrupt as Y, useConfigureSuggestions as Z, WildcardToolCallRender as _, OpenGenerativeUIActivityRenderer as _t, ThreadsProvider as a, useRenderTool as at, CopilotSidebar as b, OpenGenerativeUIToolRenderer as bt, CoAgentStateRendersProvider as c, useRenderActivityMessage as ct, shouldShowDevConsole as d, useCopilotKit$1 as dt, useCapabilities as et, useToast as f, useLicenseContext$1 as ft, useCopilotContext as g, GenerateSandboxedUiArgsSchema as gt, CopilotContext as h, createA2UIMessageRenderer as ht, ThreadsContext as i, useDefaultRenderTool as it, INTELLIGENCE_TURN_HEAD as j, CopilotChatAudioRecorder as jt, CopilotChatAttachmentQueue as k, CopilotChatInput_default as kt, useCoAgentStateRenders as l, useRenderCustomMessages as lt, useCopilotMessagesContext as m, defineToolCallRenderer as mt, defaultCopilotContextCategories as n, useAgent as nt, useThreads as o, useComponent as ot, CopilotMessagesContext as p, CopilotKitCoreReact as pt, useMemories as q, CoAgentStateRenderBridge as r, useHumanInTheLoop as rt, CoAgentStateRendersContext as s, useFrontendTool as st, CopilotKit as t, UseAgentUpdate as tt, useAsyncCallback as u, CopilotKitProvider as ut, CopilotThreadsDrawer as v, OpenGenerativeUIActivityType as vt, CopilotChatToggleButton as w, MCPAppsActivityRenderer as wt, CopilotPopupView as x, SandboxFunctionsContext as xt, CopilotPopup as y, OpenGenerativeUIContentSchema as yt, CopilotChatAttachmentRenderer as z };
|
|
12081
|
-
//# sourceMappingURL=copilotkit-
|
|
12251
|
+
//# sourceMappingURL=copilotkit-B1jSvZeb.mjs.map
|