@copilotkit/react-core 1.61.2 → 1.62.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/{copilotkit-Be-o2UaU.mjs → copilotkit-BtRkFsNR.mjs} +941 -404
- package/dist/copilotkit-BtRkFsNR.mjs.map +1 -0
- package/dist/{copilotkit-CTCjVxkH.cjs → copilotkit-CdpDZi3i.cjs} +943 -400
- package/dist/copilotkit-CdpDZi3i.cjs.map +1 -0
- package/dist/{copilotkit-ClqbUuGX.d.cts → copilotkit-Cga6AHO0.d.cts} +429 -149
- package/dist/copilotkit-Cga6AHO0.d.cts.map +1 -0
- package/dist/{copilotkit-Bpt1c_-q.d.mts → copilotkit-DnLpJ2Cl.d.mts} +429 -149
- package/dist/copilotkit-DnLpJ2Cl.d.mts.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 +193 -176
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +156 -11
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +111 -1
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +111 -1
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +157 -12
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +2 -1
- package/dist/v2/index.css +1 -1
- package/dist/v2/index.d.cts +2 -2
- package/dist/v2/index.d.mts +2 -2
- package/dist/v2/index.mjs +2 -2
- package/dist/v2/index.umd.js +949 -412
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +8 -6
- package/dist/copilotkit-Be-o2UaU.mjs.map +0 -1
- package/dist/copilotkit-Bpt1c_-q.d.mts.map +0 -1
- package/dist/copilotkit-CTCjVxkH.cjs.map +0 -1
- package/dist/copilotkit-ClqbUuGX.d.cts.map +0 -1
|
@@ -543,7 +543,74 @@ interface CopilotChatConfigurationValue {
|
|
|
543
543
|
threadId: string;
|
|
544
544
|
isModalOpen: boolean;
|
|
545
545
|
setModalOpen: (open: boolean) => void;
|
|
546
|
+
/**
|
|
547
|
+
* Whether the thread-list drawer is open. A sibling boolean to `isModalOpen`
|
|
548
|
+
* (deliberately NOT folded into a tri-state enum): on desktop the chat modal
|
|
549
|
+
* and the drawer coexist, so two independent booleans are required.
|
|
550
|
+
*/
|
|
551
|
+
drawerOpen: boolean;
|
|
552
|
+
/**
|
|
553
|
+
* Toggles the drawer open state. On mobile viewports (`<768px`) opening the
|
|
554
|
+
* drawer closes the chat modal (mutual exclusion); on desktop there is no
|
|
555
|
+
* constraint.
|
|
556
|
+
*/
|
|
557
|
+
setDrawerOpen: (open: boolean) => void;
|
|
558
|
+
/**
|
|
559
|
+
* True once a `<CopilotThreadsDrawer>` wrapper has registered itself with this chat
|
|
560
|
+
* configuration. The header thread-list launcher renders ONLY when this is
|
|
561
|
+
* set, so chats with no drawer stay byte-for-byte unchanged.
|
|
562
|
+
*/
|
|
563
|
+
drawerRegistered: boolean;
|
|
564
|
+
/**
|
|
565
|
+
* Called by the drawer wrapper on mount to announce its presence (and flip
|
|
566
|
+
* `drawerRegistered`). Returns a cleanup function that de-registers the
|
|
567
|
+
* drawer on unmount.
|
|
568
|
+
*
|
|
569
|
+
* @returns A cleanup callback that reverses the registration.
|
|
570
|
+
*/
|
|
571
|
+
registerDrawer: () => () => void;
|
|
572
|
+
/**
|
|
573
|
+
* Internal: registers the modal-close setter of the provider that actually
|
|
574
|
+
* owns the rendered modal (a descendant that supplied `isModalDefaultOpen`),
|
|
575
|
+
* so the drawer's mobile mutual-exclusion — owned by the top-most provider —
|
|
576
|
+
* closes the modal that is genuinely on screen rather than the top-most
|
|
577
|
+
* provider's own (possibly unrendered) modal state.
|
|
578
|
+
*
|
|
579
|
+
* @param closeModal - A setter the drawer may call to close the rendered modal.
|
|
580
|
+
* @returns A cleanup callback that de-registers the closer.
|
|
581
|
+
*/
|
|
582
|
+
ɵregisterModalCloser: (closeModal: (open: boolean) => void) => () => void;
|
|
546
583
|
hasExplicitThreadId: boolean;
|
|
584
|
+
/**
|
|
585
|
+
* Imperatively sets the active thread for this chat configuration.
|
|
586
|
+
*
|
|
587
|
+
* Use this to drive the rendered thread without a host callback — e.g. a
|
|
588
|
+
* `<CopilotThreadsDrawer>` selecting a thread row sets it explicitly so the chat
|
|
589
|
+
* connects to that backend thread.
|
|
590
|
+
*
|
|
591
|
+
* Guarded like the top-level `<CopilotKit>` provider's `setThreadId`: when
|
|
592
|
+
* the consumer controls the threadId via the `threadId` prop on this
|
|
593
|
+
* provider, this is a no-op (a warning is logged) so a prop-controlled
|
|
594
|
+
* threadId is never silently overridden.
|
|
595
|
+
*
|
|
596
|
+
* @param threadId - The thread id to make active.
|
|
597
|
+
* @param options.explicit - Whether the thread is a caller choice. Defaults
|
|
598
|
+
* to `true` (a picked thread). Pass `false` to set a non-explicit thread
|
|
599
|
+
* so the welcome screen shows (see {@link startNewThread}).
|
|
600
|
+
*/
|
|
601
|
+
setActiveThreadId: (threadId: string, options?: {
|
|
602
|
+
explicit?: boolean;
|
|
603
|
+
}) => void;
|
|
604
|
+
/**
|
|
605
|
+
* Resets the active thread to a fresh, non-explicit client-side thread: a
|
|
606
|
+
* newly minted UUID with `hasExplicitThreadId=false`, so the welcome screen
|
|
607
|
+
* shows. Pairs with the core `startNewThread()` to clear the conversation
|
|
608
|
+
* with no host wiring.
|
|
609
|
+
*
|
|
610
|
+
* Guarded identically to {@link setActiveThreadId}: a no-op when the
|
|
611
|
+
* threadId is prop-controlled.
|
|
612
|
+
*/
|
|
613
|
+
startNewThread: () => void;
|
|
547
614
|
}
|
|
548
615
|
interface CopilotChatConfigurationProviderProps {
|
|
549
616
|
children: ReactNode;
|
|
@@ -1242,15 +1309,31 @@ declare const CopilotChatToggleButton: React$1.ForwardRefExoticComponent<Copilot
|
|
|
1242
1309
|
type HeaderSlots = {
|
|
1243
1310
|
titleContent: typeof CopilotModalHeader.Title;
|
|
1244
1311
|
closeButton: typeof CopilotModalHeader.CloseButton;
|
|
1312
|
+
drawerLauncher: typeof CopilotModalHeader.DrawerLauncher;
|
|
1245
1313
|
};
|
|
1246
1314
|
type HeaderRestProps = {
|
|
1247
1315
|
title?: string;
|
|
1248
1316
|
} & Omit<React$1.HTMLAttributes<HTMLDivElement>, "children">;
|
|
1249
|
-
|
|
1317
|
+
/**
|
|
1318
|
+
* Payload handed to the optional `children` render function. `drawerLauncher`
|
|
1319
|
+
* is nullable because the launcher is rendered only when a drawer has
|
|
1320
|
+
* registered — when none is present, custom layouts receive `null` and can omit
|
|
1321
|
+
* the launcher slot entirely.
|
|
1322
|
+
*/
|
|
1323
|
+
type HeaderChildrenPayload = {
|
|
1324
|
+
titleContent: React$1.ReactElement;
|
|
1325
|
+
closeButton: React$1.ReactElement;
|
|
1326
|
+
drawerLauncher: React$1.ReactElement | null;
|
|
1327
|
+
title?: string;
|
|
1328
|
+
} & Omit<HeaderRestProps, "title">;
|
|
1329
|
+
type CopilotModalHeaderProps = Omit<WithSlots<HeaderSlots, HeaderRestProps>, "children"> & {
|
|
1330
|
+
children?: (props: HeaderChildrenPayload) => React$1.ReactNode;
|
|
1331
|
+
};
|
|
1250
1332
|
declare function CopilotModalHeader({
|
|
1251
1333
|
title,
|
|
1252
1334
|
titleContent,
|
|
1253
1335
|
closeButton,
|
|
1336
|
+
drawerLauncher,
|
|
1254
1337
|
children,
|
|
1255
1338
|
className,
|
|
1256
1339
|
...rest
|
|
@@ -1261,6 +1344,13 @@ declare namespace CopilotModalHeader {
|
|
|
1261
1344
|
declare namespace CopilotModalHeader {
|
|
1262
1345
|
const Title: React$1.FC<React$1.HTMLAttributes<HTMLDivElement>>;
|
|
1263
1346
|
const CloseButton: React$1.FC<React$1.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
1347
|
+
/**
|
|
1348
|
+
* The thread-list launcher button. Rendered in the header ONLY when a
|
|
1349
|
+
* `<CopilotThreadsDrawer>` wrapper has registered with the chat configuration; it
|
|
1350
|
+
* toggles the drawer open state. The stable `data-testid` is the focus-return
|
|
1351
|
+
* target for the drawer wrapper on cancel/back/backdrop/Escape.
|
|
1352
|
+
*/
|
|
1353
|
+
const DrawerLauncher: React$1.FC<React$1.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
1264
1354
|
}
|
|
1265
1355
|
//#endregion
|
|
1266
1356
|
//#region src/v2/components/chat/CopilotSidebarView.d.ts
|
|
@@ -1366,6 +1456,320 @@ declare namespace CopilotPopup {
|
|
|
1366
1456
|
var displayName: string;
|
|
1367
1457
|
}
|
|
1368
1458
|
//#endregion
|
|
1459
|
+
//#region src/v2/hooks/use-threads.d.ts
|
|
1460
|
+
/**
|
|
1461
|
+
* A conversation thread managed by the Intelligence platform.
|
|
1462
|
+
*
|
|
1463
|
+
* Each thread has a unique `id`, an optional human-readable `name`, and
|
|
1464
|
+
* timestamp fields tracking creation and update times.
|
|
1465
|
+
*/
|
|
1466
|
+
interface Thread {
|
|
1467
|
+
id: string;
|
|
1468
|
+
agentId: string;
|
|
1469
|
+
name: string | null;
|
|
1470
|
+
archived: boolean;
|
|
1471
|
+
createdAt: string;
|
|
1472
|
+
updatedAt: string;
|
|
1473
|
+
/**
|
|
1474
|
+
* ISO-8601 timestamp of the most recent agent run on this thread. Absent
|
|
1475
|
+
* when the thread has never been run. Prefer this over `updatedAt` for
|
|
1476
|
+
* user-facing "last activity" displays — it is not bumped by metadata-only
|
|
1477
|
+
* actions like rename or archive.
|
|
1478
|
+
*/
|
|
1479
|
+
lastRunAt?: string;
|
|
1480
|
+
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Configuration for the {@link useThreads} hook.
|
|
1483
|
+
*
|
|
1484
|
+
* Thread operations are scoped to the runtime-authenticated user and the
|
|
1485
|
+
* provided agent on the Intelligence platform.
|
|
1486
|
+
*/
|
|
1487
|
+
interface UseThreadsInput {
|
|
1488
|
+
/** The ID of the agent whose threads to list and manage. */
|
|
1489
|
+
agentId: string;
|
|
1490
|
+
/** When `true`, archived threads are included in the list. Defaults to `false`. */
|
|
1491
|
+
includeArchived?: boolean;
|
|
1492
|
+
/** Maximum number of threads to fetch per page. When set, enables cursor-based pagination. */
|
|
1493
|
+
limit?: number;
|
|
1494
|
+
/**
|
|
1495
|
+
* When `false`, the hook stays inert: no runtime context is dispatched, so
|
|
1496
|
+
* NO thread-list fetch or realtime subscription is issued. Used by gated
|
|
1497
|
+
* surfaces (e.g. an unlicensed `<CopilotThreadsDrawer>`) that must not touch the
|
|
1498
|
+
* network until the gate opens. Defaults to `true`.
|
|
1499
|
+
*
|
|
1500
|
+
* Flipping `enabled` back to `true` resumes normal fetching on the next
|
|
1501
|
+
* effect run; mutations are likewise short-circuited while disabled.
|
|
1502
|
+
*/
|
|
1503
|
+
enabled?: boolean;
|
|
1504
|
+
}
|
|
1505
|
+
/**
|
|
1506
|
+
* Return value of the {@link useThreads} hook.
|
|
1507
|
+
*
|
|
1508
|
+
* The `threads` array is kept in sync with the platform via a realtime
|
|
1509
|
+
* WebSocket subscription (when available) and is sorted most-recently-updated
|
|
1510
|
+
* first. Mutations reject with an `Error` if the platform request fails.
|
|
1511
|
+
*/
|
|
1512
|
+
interface UseThreadsResult {
|
|
1513
|
+
/**
|
|
1514
|
+
* Threads for the current user/agent pair, sorted by most recently
|
|
1515
|
+
* updated first. Updated in realtime when the platform pushes metadata
|
|
1516
|
+
* events. Includes archived threads only when `includeArchived` is set.
|
|
1517
|
+
*/
|
|
1518
|
+
threads: Thread[];
|
|
1519
|
+
/**
|
|
1520
|
+
* `true` while the initial thread list is being fetched from the platform.
|
|
1521
|
+
* Subsequent realtime updates do not re-enter the loading state.
|
|
1522
|
+
*/
|
|
1523
|
+
isLoading: boolean;
|
|
1524
|
+
/**
|
|
1525
|
+
* The most recent error from fetching threads or executing a mutation,
|
|
1526
|
+
* or `null` when there is no error. Reset to `null` on the next
|
|
1527
|
+
* successful fetch.
|
|
1528
|
+
*
|
|
1529
|
+
* This channel folds together developer/config errors (missing runtime URL,
|
|
1530
|
+
* runtime without thread endpoints) and genuine list-load/mutation failures.
|
|
1531
|
+
* End-user surfaces that must not leak config errors should prefer
|
|
1532
|
+
* {@link listError}, which excludes the config/runtime-setup errors.
|
|
1533
|
+
*/
|
|
1534
|
+
error: Error | null;
|
|
1535
|
+
/**
|
|
1536
|
+
* The most recent genuine list-load or mutation error from the platform, or
|
|
1537
|
+
* `null`. Unlike {@link error}, this EXCLUDES developer/config errors (a
|
|
1538
|
+
* missing runtime URL, or a runtime that does not advertise thread
|
|
1539
|
+
* endpoints), so an end-user surface can render it directly without leaking
|
|
1540
|
+
* a developer-facing configuration message into the UI.
|
|
1541
|
+
*/
|
|
1542
|
+
listError: Error | null;
|
|
1543
|
+
/**
|
|
1544
|
+
* `true` when there are more threads available to fetch via
|
|
1545
|
+
* {@link fetchMoreThreads}. Only meaningful when `limit` is set.
|
|
1546
|
+
*/
|
|
1547
|
+
hasMoreThreads: boolean;
|
|
1548
|
+
/**
|
|
1549
|
+
* `true` while a subsequent page of threads is being fetched.
|
|
1550
|
+
*/
|
|
1551
|
+
isFetchingMoreThreads: boolean;
|
|
1552
|
+
/**
|
|
1553
|
+
* `true` while at least one thread mutation (rename, archive, unarchive,
|
|
1554
|
+
* delete) is awaiting a server response. Mutations apply optimistically, so
|
|
1555
|
+
* this is primarily useful for disabling controls or showing a subtle
|
|
1556
|
+
* in-flight indicator.
|
|
1557
|
+
*/
|
|
1558
|
+
isMutating: boolean;
|
|
1559
|
+
/**
|
|
1560
|
+
* Fetch the next page of threads. No-op when {@link hasMoreThreads} is
|
|
1561
|
+
* `false` or a fetch is already in progress.
|
|
1562
|
+
*/
|
|
1563
|
+
fetchMoreThreads: () => void;
|
|
1564
|
+
/**
|
|
1565
|
+
* Re-fetch the thread list from the platform without clearing the current
|
|
1566
|
+
* list. Backs the drawer's error-state Retry and the Active/All filter
|
|
1567
|
+
* refetch. No-op until the runtime is connected.
|
|
1568
|
+
*/
|
|
1569
|
+
refetchThreads: () => void;
|
|
1570
|
+
/**
|
|
1571
|
+
* Reset to a fresh, non-explicit client-side thread so the welcome screen
|
|
1572
|
+
* shows. Lazy creation: no row appears in {@link threads} until the new
|
|
1573
|
+
* thread's first run persists server-side.
|
|
1574
|
+
*/
|
|
1575
|
+
startNewThread: () => void;
|
|
1576
|
+
/**
|
|
1577
|
+
* Rename a thread on the platform.
|
|
1578
|
+
* Resolves when the server confirms the update; rejects on failure.
|
|
1579
|
+
*/
|
|
1580
|
+
renameThread: (threadId: string, name: string) => Promise<void>;
|
|
1581
|
+
/**
|
|
1582
|
+
* Archive a thread on the platform.
|
|
1583
|
+
* Archived threads are excluded from subsequent list results.
|
|
1584
|
+
* Resolves when the server confirms the update; rejects on failure.
|
|
1585
|
+
*/
|
|
1586
|
+
archiveThread: (threadId: string) => Promise<void>;
|
|
1587
|
+
/**
|
|
1588
|
+
* Restore a previously archived thread on the platform.
|
|
1589
|
+
* The thread re-appears in default (non-archived) list results.
|
|
1590
|
+
* Resolves when the server confirms the update; rejects on failure.
|
|
1591
|
+
*/
|
|
1592
|
+
unarchiveThread: (threadId: string) => Promise<void>;
|
|
1593
|
+
/**
|
|
1594
|
+
* Permanently delete a thread from the platform.
|
|
1595
|
+
* This is irreversible. Resolves when the server confirms deletion;
|
|
1596
|
+
* rejects on failure.
|
|
1597
|
+
*/
|
|
1598
|
+
deleteThread: (threadId: string) => Promise<void>;
|
|
1599
|
+
}
|
|
1600
|
+
/**
|
|
1601
|
+
* React hook for listing and managing Intelligence platform threads.
|
|
1602
|
+
*
|
|
1603
|
+
* On mount the hook fetches the thread list for the runtime-authenticated user
|
|
1604
|
+
* and the given `agentId`. When the Intelligence platform exposes a WebSocket
|
|
1605
|
+
* URL, it also opens a realtime subscription so the `threads` array stays
|
|
1606
|
+
* current without polling — thread creates, renames, archives, and deletes
|
|
1607
|
+
* from any client are reflected immediately.
|
|
1608
|
+
*
|
|
1609
|
+
* Mutation methods (`renameThread`, `archiveThread`, `unarchiveThread`,
|
|
1610
|
+
* `deleteThread`) return promises that resolve once the platform confirms the
|
|
1611
|
+
* operation and reject with an `Error` on failure.
|
|
1612
|
+
*
|
|
1613
|
+
* @param input - Agent identifier and optional list controls.
|
|
1614
|
+
* @returns Thread list state and stable mutation callbacks.
|
|
1615
|
+
*
|
|
1616
|
+
* @example
|
|
1617
|
+
* ```tsx
|
|
1618
|
+
* import { useThreads } from "@copilotkit/react-core";
|
|
1619
|
+
*
|
|
1620
|
+
* function ThreadList() {
|
|
1621
|
+
* const { threads, isLoading, renameThread, deleteThread } = useThreads({
|
|
1622
|
+
* agentId: "agent-1",
|
|
1623
|
+
* });
|
|
1624
|
+
*
|
|
1625
|
+
* if (isLoading) return <p>Loading…</p>;
|
|
1626
|
+
*
|
|
1627
|
+
* return (
|
|
1628
|
+
* <ul>
|
|
1629
|
+
* {threads.map((t) => (
|
|
1630
|
+
* <li key={t.id}>
|
|
1631
|
+
* {t.name ?? "Untitled"}
|
|
1632
|
+
* <button onClick={() => renameThread(t.id, "New name")}>Rename</button>
|
|
1633
|
+
* <button onClick={() => deleteThread(t.id)}>Delete</button>
|
|
1634
|
+
* </li>
|
|
1635
|
+
* ))}
|
|
1636
|
+
* </ul>
|
|
1637
|
+
* );
|
|
1638
|
+
* }
|
|
1639
|
+
* ```
|
|
1640
|
+
*/
|
|
1641
|
+
declare function useThreads({
|
|
1642
|
+
agentId,
|
|
1643
|
+
includeArchived,
|
|
1644
|
+
limit,
|
|
1645
|
+
enabled
|
|
1646
|
+
}: UseThreadsInput): UseThreadsResult;
|
|
1647
|
+
//#endregion
|
|
1648
|
+
//#region src/v2/components/chat/CopilotThreadsDrawer.d.ts
|
|
1649
|
+
/**
|
|
1650
|
+
* Per-row content render function. Receives a thread and returns the React
|
|
1651
|
+
* node to project into the element's `slot="row:{id}"`. Returning `null`
|
|
1652
|
+
* (or omitting the prop) falls back to the element's built-in row name.
|
|
1653
|
+
*/
|
|
1654
|
+
type CopilotThreadsDrawerRowRenderer = (thread: Thread) => React$1.ReactNode;
|
|
1655
|
+
/**
|
|
1656
|
+
* Props for {@link CopilotThreadsDrawer}.
|
|
1657
|
+
*
|
|
1658
|
+
* The drawer is a thin controller around the framework-agnostic
|
|
1659
|
+
* `<copilotkit-threads-drawer>` custom element. It feeds the element domain data
|
|
1660
|
+
* (threads/loading/error from {@link useThreads}, the active thread from the
|
|
1661
|
+
* chat configuration) and routes the element's outbound DOM events back into
|
|
1662
|
+
* core thread operations and chat-configuration changes.
|
|
1663
|
+
*/
|
|
1664
|
+
interface CopilotThreadsDrawerProps {
|
|
1665
|
+
/**
|
|
1666
|
+
* The agent whose threads to list and manage. Defaults to the agent of the
|
|
1667
|
+
* surrounding chat configuration, or the platform default when none is set.
|
|
1668
|
+
*/
|
|
1669
|
+
agentId?: string;
|
|
1670
|
+
/**
|
|
1671
|
+
* Optional escape-hatch called when the user picks a thread row. The wrapper
|
|
1672
|
+
* additionally focuses the chat input. When omitted, the wrapper drives the
|
|
1673
|
+
* surrounding chat configuration directly (`setActiveThreadId`), so a bare
|
|
1674
|
+
* `<CopilotThreadsDrawer>` switches the rendered thread with no host wiring. Provide
|
|
1675
|
+
* this only to take control of the active thread yourself (e.g. a v1
|
|
1676
|
+
* `setThreadId`); when provided it is preferred over the provider.
|
|
1677
|
+
*/
|
|
1678
|
+
onThreadSelect?: (threadId: string) => void;
|
|
1679
|
+
/**
|
|
1680
|
+
* Optional escape-hatch called when the user starts a new thread (the
|
|
1681
|
+
* element's "+ New" button). The wrapper always resets the core thread store
|
|
1682
|
+
* to a fresh, non-explicit client-side thread (`startNewThread`). When this
|
|
1683
|
+
* is omitted, the wrapper also resets the surrounding chat configuration to a
|
|
1684
|
+
* fresh non-explicit thread (`startNewThread`) so the welcome screen shows
|
|
1685
|
+
* with no host wiring. Provide this only to clear your own active thread;
|
|
1686
|
+
* when provided it is preferred over the provider.
|
|
1687
|
+
*/
|
|
1688
|
+
onNewThread?: () => void;
|
|
1689
|
+
/** Called when the Upgrade CTA is clicked. */
|
|
1690
|
+
onLicensed?: () => void;
|
|
1691
|
+
/**
|
|
1692
|
+
* Destination the locked view's Upgrade CTA opens in a new tab. Defaults to
|
|
1693
|
+
* the element's built-in CopilotKit Intelligence docs URL when omitted. Set
|
|
1694
|
+
* to an empty string to suppress the default navigation and handle the click
|
|
1695
|
+
* yourself via `onLicensed`.
|
|
1696
|
+
*/
|
|
1697
|
+
licenseUrl?: string;
|
|
1698
|
+
/**
|
|
1699
|
+
* Optional per-row content. Rendered as light-DOM children with
|
|
1700
|
+
* `slot="row:{id}"` so the element projects them in place of the default
|
|
1701
|
+
* row name. Return `null` for a given row to keep the element's default.
|
|
1702
|
+
*/
|
|
1703
|
+
renderRow?: CopilotThreadsDrawerRowRenderer;
|
|
1704
|
+
/**
|
|
1705
|
+
* Accessible + default-header label for the drawer region. Sets the custom
|
|
1706
|
+
* element's `aria-label` and the default header text (shown when no
|
|
1707
|
+
* `slot="header"` content is projected). Defaults to the element's built-in
|
|
1708
|
+
* `"Threads"` when omitted.
|
|
1709
|
+
*/
|
|
1710
|
+
label?: string;
|
|
1711
|
+
/**
|
|
1712
|
+
* Page size for thread pagination. When set, threads are fetched in pages of
|
|
1713
|
+
* this size and the drawer shows a "Load more" control while more remain.
|
|
1714
|
+
* When omitted, the full list loads at once and no pagination control shows.
|
|
1715
|
+
*/
|
|
1716
|
+
limit?: number;
|
|
1717
|
+
/**
|
|
1718
|
+
* `data-testid` set on the underlying custom element (handy in tests and for
|
|
1719
|
+
* targeting from a host page). Defaults to `"copilot-threads-drawer"`.
|
|
1720
|
+
*/
|
|
1721
|
+
"data-testid"?: string;
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* React wrapper for the shadow-DOM `<copilotkit-threads-drawer>` threads drawer.
|
|
1725
|
+
*
|
|
1726
|
+
* Responsibilities:
|
|
1727
|
+
* - Registers the custom element on the client (SSR-safe; nothing renders
|
|
1728
|
+
* during prerender to avoid hydration mismatch).
|
|
1729
|
+
* - Feeds the element domain data: `threads`, `loading`, `error`,
|
|
1730
|
+
* `activeThreadId`, `licensed`, fetch-more state.
|
|
1731
|
+
* - Routes the element's nine outbound events to core thread operations
|
|
1732
|
+
* ({@link useThreads}) and chat-configuration changes.
|
|
1733
|
+
* - Registers with the surrounding chat configuration so the header
|
|
1734
|
+
* thread-list launcher appears, and binds the element `open` state to the
|
|
1735
|
+
* configuration's `drawerOpen`.
|
|
1736
|
+
*
|
|
1737
|
+
* License gating is two-pronged: the locked view shows when no license is configured
|
|
1738
|
+
* (the runtime reported no license status) OR the `threads` feature is
|
|
1739
|
+
* explicitly unlicensed. While unlicensed, the thread fetch is skipped entirely
|
|
1740
|
+
* so an unlicensed drawer issues no network requests.
|
|
1741
|
+
*
|
|
1742
|
+
* Thread switching needs no host wiring: when `onThreadSelect`/`onNewThread`
|
|
1743
|
+
* are omitted, the wrapper drives the surrounding chat configuration directly
|
|
1744
|
+
* ({@link CopilotChatConfigurationValue.setActiveThreadId} /
|
|
1745
|
+
* {@link CopilotChatConfigurationValue.startNewThread}), so a bare drawer
|
|
1746
|
+
* connects to the picked thread and shows the welcome screen on "+ New". Pass
|
|
1747
|
+
* the callbacks only to take control yourself.
|
|
1748
|
+
*
|
|
1749
|
+
* @example
|
|
1750
|
+
* ```tsx
|
|
1751
|
+
* // Callback-free: the drawer drives the chat configuration itself.
|
|
1752
|
+
* <CopilotKitProvider runtimeUrl="/api/copilotkit" publicLicenseKey="ck_pub_...">
|
|
1753
|
+
* <CopilotChat />
|
|
1754
|
+
* <CopilotThreadsDrawer />
|
|
1755
|
+
* </CopilotKitProvider>
|
|
1756
|
+
* ```
|
|
1757
|
+
*/
|
|
1758
|
+
declare function CopilotThreadsDrawer({
|
|
1759
|
+
agentId,
|
|
1760
|
+
onThreadSelect,
|
|
1761
|
+
onNewThread,
|
|
1762
|
+
onLicensed,
|
|
1763
|
+
licenseUrl,
|
|
1764
|
+
renderRow,
|
|
1765
|
+
label,
|
|
1766
|
+
limit,
|
|
1767
|
+
"data-testid": dataTestId
|
|
1768
|
+
}: CopilotThreadsDrawerProps): React$1.ReactElement | null;
|
|
1769
|
+
declare namespace CopilotThreadsDrawer {
|
|
1770
|
+
var displayName: string;
|
|
1771
|
+
}
|
|
1772
|
+
//#endregion
|
|
1369
1773
|
//#region src/v2/components/chat/CopilotChatAttachmentQueue.d.ts
|
|
1370
1774
|
interface CopilotChatAttachmentQueueProps {
|
|
1371
1775
|
attachments: Attachment[];
|
|
@@ -2068,152 +2472,6 @@ type UseInterruptConfig<TValue = unknown, TResult = never, TRenderInChat extends
|
|
|
2068
2472
|
*/
|
|
2069
2473
|
declare function useInterrupt<TResult = never, TRenderInChat extends InterruptRenderInChat = undefined>(config: UseInterruptConfig<any, TResult, TRenderInChat>): UseInterruptReturn<TRenderInChat>;
|
|
2070
2474
|
//#endregion
|
|
2071
|
-
//#region src/v2/hooks/use-threads.d.ts
|
|
2072
|
-
/**
|
|
2073
|
-
* A conversation thread managed by the Intelligence platform.
|
|
2074
|
-
*
|
|
2075
|
-
* Each thread has a unique `id`, an optional human-readable `name`, and
|
|
2076
|
-
* timestamp fields tracking creation and update times.
|
|
2077
|
-
*/
|
|
2078
|
-
interface Thread {
|
|
2079
|
-
id: string;
|
|
2080
|
-
agentId: string;
|
|
2081
|
-
name: string | null;
|
|
2082
|
-
archived: boolean;
|
|
2083
|
-
createdAt: string;
|
|
2084
|
-
updatedAt: string;
|
|
2085
|
-
/**
|
|
2086
|
-
* ISO-8601 timestamp of the most recent agent run on this thread. Absent
|
|
2087
|
-
* when the thread has never been run. Prefer this over `updatedAt` for
|
|
2088
|
-
* user-facing "last activity" displays — it is not bumped by metadata-only
|
|
2089
|
-
* actions like rename or archive.
|
|
2090
|
-
*/
|
|
2091
|
-
lastRunAt?: string;
|
|
2092
|
-
}
|
|
2093
|
-
/**
|
|
2094
|
-
* Configuration for the {@link useThreads} hook.
|
|
2095
|
-
*
|
|
2096
|
-
* Thread operations are scoped to the runtime-authenticated user and the
|
|
2097
|
-
* provided agent on the Intelligence platform.
|
|
2098
|
-
*/
|
|
2099
|
-
interface UseThreadsInput {
|
|
2100
|
-
/** The ID of the agent whose threads to list and manage. */
|
|
2101
|
-
agentId: string;
|
|
2102
|
-
/** When `true`, archived threads are included in the list. Defaults to `false`. */
|
|
2103
|
-
includeArchived?: boolean;
|
|
2104
|
-
/** Maximum number of threads to fetch per page. When set, enables cursor-based pagination. */
|
|
2105
|
-
limit?: number;
|
|
2106
|
-
}
|
|
2107
|
-
/**
|
|
2108
|
-
* Return value of the {@link useThreads} hook.
|
|
2109
|
-
*
|
|
2110
|
-
* The `threads` array is kept in sync with the platform via a realtime
|
|
2111
|
-
* WebSocket subscription (when available) and is sorted most-recently-updated
|
|
2112
|
-
* first. Mutations reject with an `Error` if the platform request fails.
|
|
2113
|
-
*/
|
|
2114
|
-
interface UseThreadsResult {
|
|
2115
|
-
/**
|
|
2116
|
-
* Threads for the current user/agent pair, sorted by most recently
|
|
2117
|
-
* updated first. Updated in realtime when the platform pushes metadata
|
|
2118
|
-
* events. Includes archived threads only when `includeArchived` is set.
|
|
2119
|
-
*/
|
|
2120
|
-
threads: Thread[];
|
|
2121
|
-
/**
|
|
2122
|
-
* `true` while the initial thread list is being fetched from the platform.
|
|
2123
|
-
* Subsequent realtime updates do not re-enter the loading state.
|
|
2124
|
-
*/
|
|
2125
|
-
isLoading: boolean;
|
|
2126
|
-
/**
|
|
2127
|
-
* The most recent error from fetching threads or executing a mutation,
|
|
2128
|
-
* or `null` when there is no error. Reset to `null` on the next
|
|
2129
|
-
* successful fetch.
|
|
2130
|
-
*/
|
|
2131
|
-
error: Error | null;
|
|
2132
|
-
/**
|
|
2133
|
-
* `true` when there are more threads available to fetch via
|
|
2134
|
-
* {@link fetchMoreThreads}. Only meaningful when `limit` is set.
|
|
2135
|
-
*/
|
|
2136
|
-
hasMoreThreads: boolean;
|
|
2137
|
-
/**
|
|
2138
|
-
* `true` while a subsequent page of threads is being fetched.
|
|
2139
|
-
*/
|
|
2140
|
-
isFetchingMoreThreads: boolean;
|
|
2141
|
-
/**
|
|
2142
|
-
* Fetch the next page of threads. No-op when {@link hasMoreThreads} is
|
|
2143
|
-
* `false` or a fetch is already in progress.
|
|
2144
|
-
*/
|
|
2145
|
-
fetchMoreThreads: () => void;
|
|
2146
|
-
/**
|
|
2147
|
-
* Rename a thread on the platform.
|
|
2148
|
-
* Resolves when the server confirms the update; rejects on failure.
|
|
2149
|
-
*/
|
|
2150
|
-
renameThread: (threadId: string, name: string) => Promise<void>;
|
|
2151
|
-
/**
|
|
2152
|
-
* Archive a thread on the platform.
|
|
2153
|
-
* Archived threads are excluded from subsequent list results.
|
|
2154
|
-
* Resolves when the server confirms the update; rejects on failure.
|
|
2155
|
-
*/
|
|
2156
|
-
archiveThread: (threadId: string) => Promise<void>;
|
|
2157
|
-
/**
|
|
2158
|
-
* Restore a previously archived thread on the platform.
|
|
2159
|
-
* The thread re-appears in default (non-archived) list results.
|
|
2160
|
-
* Resolves when the server confirms the update; rejects on failure.
|
|
2161
|
-
*/
|
|
2162
|
-
unarchiveThread: (threadId: string) => Promise<void>;
|
|
2163
|
-
/**
|
|
2164
|
-
* Permanently delete a thread from the platform.
|
|
2165
|
-
* This is irreversible. Resolves when the server confirms deletion;
|
|
2166
|
-
* rejects on failure.
|
|
2167
|
-
*/
|
|
2168
|
-
deleteThread: (threadId: string) => Promise<void>;
|
|
2169
|
-
}
|
|
2170
|
-
/**
|
|
2171
|
-
* React hook for listing and managing Intelligence platform threads.
|
|
2172
|
-
*
|
|
2173
|
-
* On mount the hook fetches the thread list for the runtime-authenticated user
|
|
2174
|
-
* and the given `agentId`. When the Intelligence platform exposes a WebSocket
|
|
2175
|
-
* URL, it also opens a realtime subscription so the `threads` array stays
|
|
2176
|
-
* current without polling — thread creates, renames, archives, and deletes
|
|
2177
|
-
* from any client are reflected immediately.
|
|
2178
|
-
*
|
|
2179
|
-
* Mutation methods (`renameThread`, `archiveThread`, `unarchiveThread`,
|
|
2180
|
-
* `deleteThread`) return promises that resolve once the platform confirms the
|
|
2181
|
-
* operation and reject with an `Error` on failure.
|
|
2182
|
-
*
|
|
2183
|
-
* @param input - Agent identifier and optional list controls.
|
|
2184
|
-
* @returns Thread list state and stable mutation callbacks.
|
|
2185
|
-
*
|
|
2186
|
-
* @example
|
|
2187
|
-
* ```tsx
|
|
2188
|
-
* import { useThreads } from "@copilotkit/react-core";
|
|
2189
|
-
*
|
|
2190
|
-
* function ThreadList() {
|
|
2191
|
-
* const { threads, isLoading, renameThread, deleteThread } = useThreads({
|
|
2192
|
-
* agentId: "agent-1",
|
|
2193
|
-
* });
|
|
2194
|
-
*
|
|
2195
|
-
* if (isLoading) return <p>Loading…</p>;
|
|
2196
|
-
*
|
|
2197
|
-
* return (
|
|
2198
|
-
* <ul>
|
|
2199
|
-
* {threads.map((t) => (
|
|
2200
|
-
* <li key={t.id}>
|
|
2201
|
-
* {t.name ?? "Untitled"}
|
|
2202
|
-
* <button onClick={() => renameThread(t.id, "New name")}>Rename</button>
|
|
2203
|
-
* <button onClick={() => deleteThread(t.id)}>Delete</button>
|
|
2204
|
-
* </li>
|
|
2205
|
-
* ))}
|
|
2206
|
-
* </ul>
|
|
2207
|
-
* );
|
|
2208
|
-
* }
|
|
2209
|
-
* ```
|
|
2210
|
-
*/
|
|
2211
|
-
declare function useThreads({
|
|
2212
|
-
agentId,
|
|
2213
|
-
includeArchived,
|
|
2214
|
-
limit
|
|
2215
|
-
}: UseThreadsInput): UseThreadsResult;
|
|
2216
|
-
//#endregion
|
|
2217
2475
|
//#region src/v2/hooks/use-learn-from-user-action.d.ts
|
|
2218
2476
|
/**
|
|
2219
2477
|
* Input to {@link UseLearnFromUserActionRecorder}, the function returned
|
|
@@ -2711,6 +2969,22 @@ type A2UIUserAction = {
|
|
|
2711
2969
|
context?: Record<string, unknown>;
|
|
2712
2970
|
dataContextPath?: string;
|
|
2713
2971
|
};
|
|
2972
|
+
/**
|
|
2973
|
+
* Intercept an A2UI user action before it reaches the agent.
|
|
2974
|
+
*
|
|
2975
|
+
* Called with the dispatched action and a `forward` helper that runs the agent
|
|
2976
|
+
* with the (optionally modified) action. The return value drives the default
|
|
2977
|
+
* forwarding:
|
|
2978
|
+
* - return `null` → the app handled it client-side (e.g. a `navigate` event);
|
|
2979
|
+
* the action is NOT forwarded to the agent.
|
|
2980
|
+
* - return an `A2UIUserAction` → that (possibly modified) action is forwarded.
|
|
2981
|
+
* - return `undefined` / `void` → the original action is forwarded unchanged.
|
|
2982
|
+
*
|
|
2983
|
+
* `forward` is provided for advanced cases where you want to do async work and
|
|
2984
|
+
* forward manually; if you call it yourself, return `null` to suppress the
|
|
2985
|
+
* default forward and avoid running the agent twice.
|
|
2986
|
+
*/
|
|
2987
|
+
type A2UIActionInterceptor = (action: A2UIUserAction, forward: (action?: A2UIUserAction) => Promise<void>) => void | A2UIUserAction | null | Promise<void | A2UIUserAction | null>;
|
|
2714
2988
|
type A2UIMessageRendererOptions = {
|
|
2715
2989
|
theme: Theme; /** Optional component catalog to pass to A2UIProvider */
|
|
2716
2990
|
catalog?: any; /** Optional custom loading component shown while the A2UI surface is building. */
|
|
@@ -2720,6 +2994,12 @@ type A2UIMessageRendererOptions = {
|
|
|
2720
2994
|
* "Retrying…" sub-label appears + how much retry/debug detail to surface.
|
|
2721
2995
|
*/
|
|
2722
2996
|
recovery?: A2UIRecoveryRendererOptions;
|
|
2997
|
+
/**
|
|
2998
|
+
* Intercept actions before they reach the agent. Lets an app handle an action
|
|
2999
|
+
* client-side (e.g. `navigate`) instead of forwarding every action. See
|
|
3000
|
+
* {@link A2UIActionInterceptor}.
|
|
3001
|
+
*/
|
|
3002
|
+
onAction?: A2UIActionInterceptor;
|
|
2723
3003
|
};
|
|
2724
3004
|
declare function createA2UIMessageRenderer(options: A2UIMessageRendererOptions): ReactActivityMessageRenderer<any>;
|
|
2725
3005
|
//#endregion
|
|
@@ -2897,5 +3177,5 @@ declare function CopilotKit({
|
|
|
2897
3177
|
}: CopilotKitProps): react_jsx_runtime0.JSX.Element;
|
|
2898
3178
|
declare const defaultCopilotContextCategories: string[];
|
|
2899
3179
|
//#endregion
|
|
2900
|
-
export {
|
|
2901
|
-
//# sourceMappingURL=copilotkit-
|
|
3180
|
+
export { InterruptHandlerProps as $, ActionRenderPropsNoArgs as $n, IntelligenceIndicator as $t, LearnFromUserActionResult as A, CopilotContext as An, useThreads as At, useCapabilities as B, QueuedInterruptEvent as Bn, CopilotModalHeaderProps as Bt, UseAttachmentsProps as C, CopilotChatLabels as Cn, CopilotChatAttachmentQueue as Ct, UseLearnFromUserActionInCurrentThreadRecorder as D, CopilotChatAudioRecorder as Dn, Thread as Dt, LearnFromUserActionInCurrentThreadInput as E, AudioRecorderState as En, CopilotThreadsDrawerRowRenderer as Et, useConfigureSuggestions as F, LangGraphInterruptActionSetter as Fn, CopilotPopupView as Ft, useRenderTool as G, CrewsTaskStateItem as Gn, CopilotChat as Gt, useAgent as H, CrewsResponse as Hn, CopilotChatToggleButtonProps as Ht, useSuggestions as I, LangGraphInterruptActionSetterArgs as In, CopilotPopupViewProps as It, useRenderActivityMessage as J, SystemMessageFunction as Jn, CopilotChatViewProps as Jt, useComponent as K, CrewsToolStateItem as Kn, CopilotChatProps as Kt, AgentContextInput as L, LangGraphInterruptRender as Ln, CopilotSidebarView as Lt, useLearnFromUserAction as M, useCopilotContext as Mn, CopilotPopupProps as Mt, UseInterruptConfig as N, CoAgentStateRender as Nn, CopilotSidebar as Nt, useLearnFromUserActionInCurrentThread as O, CoagentInChatRenderFunction as On, UseThreadsInput as Ot, useInterrupt as P, LangGraphInterruptAction as Pn, CopilotSidebarProps as Pt, InterruptEvent as Q, ActionRenderProps as Qn, INTELLIGENCE_TURN_HEAD as Qt, JsonSerializable as R, LangGraphInterruptRenderHandlerProps as Rn, CopilotSidebarViewProps as Rt, useLearningContainers as S, CopilotChatConfigurationValue as Sn, CopilotChatAttachmentRenderer as St, useAttachments as T, AudioRecorderError as Tn, CopilotThreadsDrawerProps as Tt, useHumanInTheLoop as U, CrewsResponseStatus as Un, DefaultCloseIcon as Ut, UseAgentUpdate as V, CrewsAgentState as Vn, CopilotChatToggleButton as Vt, useDefaultRenderTool as W, CrewsStateItem as Wn, DefaultOpenIcon as Wt, Interrupt as X, Tree as Xn, CopilotChatMessageView as Xt, SandboxFunction as Y, DocumentPointer as Yn, AutoScrollMode as Yt, InterruptCancelFn as Z, TreeNode as Zn, CopilotChatMessageViewProps as Zt, CopilotKitCoreReactConfig as _, CopilotChatInput as _n, CopilotKitInspectorProps as _t, A2UIMessageRendererOptions as a, CopilotChatSuggestionView as an, FrontendActionAvailability as ar, ReactFrontendTool as at, useLearningContainersInCurrentThread as b, CopilotChatConfigurationProvider as bn, AttachmentModality as bt, InspectorAnchor as c, CopilotChatSuggestionPillProps as cn, useRenderCustomMessages as ct, CopilotKitProvider as d, CopilotChatUserMessage as dn, useRenderToolCall as dt, IntelligenceIndicatorProps as en, ActionRenderPropsNoArgsWait as er, InterruptRenderProps as et, CopilotKitProviderProps as f, CopilotChatUserMessageProps as fn, MCPAppsActivityContent as ft, CopilotKitCoreReact as g, CopilotChatToolCallsViewProps as gn, CopilotKitInspector as gt, useCopilotKit as h, CopilotChatToolCallsView as hn, MCPAppsActivityType as ht, A2UIActionInterceptor as i, IntelligenceIndicatorViewProps as in, FrontendAction as ir, ReactHumanInTheLoop as it, UseLearnFromUserActionRecorder as j, CopilotContextParams as jn, CopilotPopup as jt, LearnFromUserActionInput as k, CopilotApiConfig as kn, UseThreadsResult as kt, SandboxFunctionsContext as l, CopilotChatReasoningMessage as ln, ReactCustomMessageRenderer as lt, CopilotKitContextValue as m, CopilotChatAssistantMessageProps as mn, MCPAppsActivityRenderer as mt, defaultCopilotContextCategories as n, IntelligenceIndicatorStatus as nn, CatchAllActionRenderProps as nr, ResumeEntry as nt, A2UIUserAction as o, CopilotChatSuggestionViewProps as on, RenderFunctionStatus as or, ReactActivityMessageRenderer as ot, A2UIRecoveryRendererOptions as p, CopilotChatAssistantMessage as pn, MCPAppsActivityContentSchema as pt, useFrontendTool as q, CopilotChatSuggestionConfiguration as qn, CopilotChatView as qt, CopilotKitProps as r, IntelligenceIndicatorView as rn, CatchAllFrontendAction as rr, defineToolCallRenderer as rt, createA2UIMessageRenderer as s, CopilotChatSuggestionPill as sn, ReactToolCallRenderer as st, CopilotKit as t, getIntelligenceTurnAnchors as tn, ActionRenderPropsWait as tr, InterruptResolveFn as tt, useSandboxFunctions as u, CopilotChatReasoningMessageProps as un, ReactCustomMessageRendererPosition as ut, CopilotKitCoreReactSubscriber as v, CopilotChatInputProps as vn, WildcardToolCallRender as vt, UseAttachmentsReturn as w, useCopilotChatConfiguration as wn, CopilotThreadsDrawer as wt, UseLearningContainersArgs as x, CopilotChatConfigurationProviderProps as xn, AttachmentsConfig$1 as xt, UseLearningContainersInCurrentThreadArgs as y, ToolsMenuItem as yn, Attachment$1 as yt, useAgentContext as z, LangGraphInterruptRenderProps as zn, CopilotModalHeader as zt };
|
|
3181
|
+
//# sourceMappingURL=copilotkit-DnLpJ2Cl.d.mts.map
|