@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
package/dist/v2/headless.d.cts
CHANGED
|
@@ -299,7 +299,74 @@ interface CopilotChatConfigurationValue {
|
|
|
299
299
|
threadId: string;
|
|
300
300
|
isModalOpen: boolean;
|
|
301
301
|
setModalOpen: (open: boolean) => void;
|
|
302
|
+
/**
|
|
303
|
+
* Whether the thread-list drawer is open. A sibling boolean to `isModalOpen`
|
|
304
|
+
* (deliberately NOT folded into a tri-state enum): on desktop the chat modal
|
|
305
|
+
* and the drawer coexist, so two independent booleans are required.
|
|
306
|
+
*/
|
|
307
|
+
drawerOpen: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Toggles the drawer open state. On mobile viewports (`<768px`) opening the
|
|
310
|
+
* drawer closes the chat modal (mutual exclusion); on desktop there is no
|
|
311
|
+
* constraint.
|
|
312
|
+
*/
|
|
313
|
+
setDrawerOpen: (open: boolean) => void;
|
|
314
|
+
/**
|
|
315
|
+
* True once a `<CopilotThreadsDrawer>` wrapper has registered itself with this chat
|
|
316
|
+
* configuration. The header thread-list launcher renders ONLY when this is
|
|
317
|
+
* set, so chats with no drawer stay byte-for-byte unchanged.
|
|
318
|
+
*/
|
|
319
|
+
drawerRegistered: boolean;
|
|
320
|
+
/**
|
|
321
|
+
* Called by the drawer wrapper on mount to announce its presence (and flip
|
|
322
|
+
* `drawerRegistered`). Returns a cleanup function that de-registers the
|
|
323
|
+
* drawer on unmount.
|
|
324
|
+
*
|
|
325
|
+
* @returns A cleanup callback that reverses the registration.
|
|
326
|
+
*/
|
|
327
|
+
registerDrawer: () => () => void;
|
|
328
|
+
/**
|
|
329
|
+
* Internal: registers the modal-close setter of the provider that actually
|
|
330
|
+
* owns the rendered modal (a descendant that supplied `isModalDefaultOpen`),
|
|
331
|
+
* so the drawer's mobile mutual-exclusion — owned by the top-most provider —
|
|
332
|
+
* closes the modal that is genuinely on screen rather than the top-most
|
|
333
|
+
* provider's own (possibly unrendered) modal state.
|
|
334
|
+
*
|
|
335
|
+
* @param closeModal - A setter the drawer may call to close the rendered modal.
|
|
336
|
+
* @returns A cleanup callback that de-registers the closer.
|
|
337
|
+
*/
|
|
338
|
+
ɵregisterModalCloser: (closeModal: (open: boolean) => void) => () => void;
|
|
302
339
|
hasExplicitThreadId: boolean;
|
|
340
|
+
/**
|
|
341
|
+
* Imperatively sets the active thread for this chat configuration.
|
|
342
|
+
*
|
|
343
|
+
* Use this to drive the rendered thread without a host callback — e.g. a
|
|
344
|
+
* `<CopilotThreadsDrawer>` selecting a thread row sets it explicitly so the chat
|
|
345
|
+
* connects to that backend thread.
|
|
346
|
+
*
|
|
347
|
+
* Guarded like the top-level `<CopilotKit>` provider's `setThreadId`: when
|
|
348
|
+
* the consumer controls the threadId via the `threadId` prop on this
|
|
349
|
+
* provider, this is a no-op (a warning is logged) so a prop-controlled
|
|
350
|
+
* threadId is never silently overridden.
|
|
351
|
+
*
|
|
352
|
+
* @param threadId - The thread id to make active.
|
|
353
|
+
* @param options.explicit - Whether the thread is a caller choice. Defaults
|
|
354
|
+
* to `true` (a picked thread). Pass `false` to set a non-explicit thread
|
|
355
|
+
* so the welcome screen shows (see {@link startNewThread}).
|
|
356
|
+
*/
|
|
357
|
+
setActiveThreadId: (threadId: string, options?: {
|
|
358
|
+
explicit?: boolean;
|
|
359
|
+
}) => void;
|
|
360
|
+
/**
|
|
361
|
+
* Resets the active thread to a fresh, non-explicit client-side thread: a
|
|
362
|
+
* newly minted UUID with `hasExplicitThreadId=false`, so the welcome screen
|
|
363
|
+
* shows. Pairs with the core `startNewThread()` to clear the conversation
|
|
364
|
+
* with no host wiring.
|
|
365
|
+
*
|
|
366
|
+
* Guarded identically to {@link setActiveThreadId}: a no-op when the
|
|
367
|
+
* threadId is prop-controlled.
|
|
368
|
+
*/
|
|
369
|
+
startNewThread: () => void;
|
|
303
370
|
}
|
|
304
371
|
interface CopilotChatConfigurationProviderProps {
|
|
305
372
|
children: ReactNode;
|
|
@@ -560,6 +627,16 @@ interface UseThreadsInput {
|
|
|
560
627
|
includeArchived?: boolean;
|
|
561
628
|
/** Maximum number of threads to fetch per page. When set, enables cursor-based pagination. */
|
|
562
629
|
limit?: number;
|
|
630
|
+
/**
|
|
631
|
+
* When `false`, the hook stays inert: no runtime context is dispatched, so
|
|
632
|
+
* NO thread-list fetch or realtime subscription is issued. Used by gated
|
|
633
|
+
* surfaces (e.g. an unlicensed `<CopilotThreadsDrawer>`) that must not touch the
|
|
634
|
+
* network until the gate opens. Defaults to `true`.
|
|
635
|
+
*
|
|
636
|
+
* Flipping `enabled` back to `true` resumes normal fetching on the next
|
|
637
|
+
* effect run; mutations are likewise short-circuited while disabled.
|
|
638
|
+
*/
|
|
639
|
+
enabled?: boolean;
|
|
563
640
|
}
|
|
564
641
|
/**
|
|
565
642
|
* Return value of the {@link useThreads} hook.
|
|
@@ -584,8 +661,21 @@ interface UseThreadsResult {
|
|
|
584
661
|
* The most recent error from fetching threads or executing a mutation,
|
|
585
662
|
* or `null` when there is no error. Reset to `null` on the next
|
|
586
663
|
* successful fetch.
|
|
664
|
+
*
|
|
665
|
+
* This channel folds together developer/config errors (missing runtime URL,
|
|
666
|
+
* runtime without thread endpoints) and genuine list-load/mutation failures.
|
|
667
|
+
* End-user surfaces that must not leak config errors should prefer
|
|
668
|
+
* {@link listError}, which excludes the config/runtime-setup errors.
|
|
587
669
|
*/
|
|
588
670
|
error: Error | null;
|
|
671
|
+
/**
|
|
672
|
+
* The most recent genuine list-load or mutation error from the platform, or
|
|
673
|
+
* `null`. Unlike {@link error}, this EXCLUDES developer/config errors (a
|
|
674
|
+
* missing runtime URL, or a runtime that does not advertise thread
|
|
675
|
+
* endpoints), so an end-user surface can render it directly without leaking
|
|
676
|
+
* a developer-facing configuration message into the UI.
|
|
677
|
+
*/
|
|
678
|
+
listError: Error | null;
|
|
589
679
|
/**
|
|
590
680
|
* `true` when there are more threads available to fetch via
|
|
591
681
|
* {@link fetchMoreThreads}. Only meaningful when `limit` is set.
|
|
@@ -595,11 +685,30 @@ interface UseThreadsResult {
|
|
|
595
685
|
* `true` while a subsequent page of threads is being fetched.
|
|
596
686
|
*/
|
|
597
687
|
isFetchingMoreThreads: boolean;
|
|
688
|
+
/**
|
|
689
|
+
* `true` while at least one thread mutation (rename, archive, unarchive,
|
|
690
|
+
* delete) is awaiting a server response. Mutations apply optimistically, so
|
|
691
|
+
* this is primarily useful for disabling controls or showing a subtle
|
|
692
|
+
* in-flight indicator.
|
|
693
|
+
*/
|
|
694
|
+
isMutating: boolean;
|
|
598
695
|
/**
|
|
599
696
|
* Fetch the next page of threads. No-op when {@link hasMoreThreads} is
|
|
600
697
|
* `false` or a fetch is already in progress.
|
|
601
698
|
*/
|
|
602
699
|
fetchMoreThreads: () => void;
|
|
700
|
+
/**
|
|
701
|
+
* Re-fetch the thread list from the platform without clearing the current
|
|
702
|
+
* list. Backs the drawer's error-state Retry and the Active/All filter
|
|
703
|
+
* refetch. No-op until the runtime is connected.
|
|
704
|
+
*/
|
|
705
|
+
refetchThreads: () => void;
|
|
706
|
+
/**
|
|
707
|
+
* Reset to a fresh, non-explicit client-side thread so the welcome screen
|
|
708
|
+
* shows. Lazy creation: no row appears in {@link threads} until the new
|
|
709
|
+
* thread's first run persists server-side.
|
|
710
|
+
*/
|
|
711
|
+
startNewThread: () => void;
|
|
603
712
|
/**
|
|
604
713
|
* Rename a thread on the platform.
|
|
605
714
|
* Resolves when the server confirms the update; rejects on failure.
|
|
@@ -668,7 +777,8 @@ interface UseThreadsResult {
|
|
|
668
777
|
declare function useThreads({
|
|
669
778
|
agentId,
|
|
670
779
|
includeArchived,
|
|
671
|
-
limit
|
|
780
|
+
limit,
|
|
781
|
+
enabled
|
|
672
782
|
}: UseThreadsInput): UseThreadsResult;
|
|
673
783
|
//#endregion
|
|
674
784
|
//#region src/v2/hooks/use-render-tool.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless.d.cts","names":[],"sources":["../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/react-activity-message-renderer.ts","../../src/v2/types/react-custom-message-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/types/human-in-the-loop.ts","../../src/v2/types/defineToolCallRenderer.ts","../../src/v2/types/interrupt.ts","../../src/v2/lib/react-core.ts","../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx","../../src/v2/hooks/use-render-tool.tsx","../../src/v2/hooks/use-capabilities.tsx"],"mappings":";;;;;;;UAGiB,qBAAA;EACf,IAAA;;;;AADF;EAME,IAAA,GAAO,gBAAA,MAAsB,CAAA;EANO;;;;EAWpC,OAAA;EACA,MAAA,EAAQ,KAAA,CAAM,aAAA;IAER,IAAA;IACA,UAAA;IACA,IAAA,EAAM,OAAA,CAAQ,CAAA;IACd,MAAA,EAAQ,cAAA,CAAe,UAAA;IACvB,MAAA;EAAA;IAGA,IAAA;IACA,UAAA;IACA,IAAA,EAAM,CAAA;IACN,MAAA,EAAQ,cAAA,CAAe,SAAA;IACvB,MAAA;EAAA;IAGA,IAAA;IACA,UAAA;IACA,IAAA,EAAM,CAAA;IACN,MAAA,EAAQ,cAAA,CAAe,QAAA;IACvB,MAAA;EAAA;AAAA;;;UC/BS,4BAAA;;;;EAIf,YAAA;EDLoC;;;ECSpC,OAAA;EDOoB;;;ECHpB,OAAA,EAAS,gBAAA,MAAsB,gBAAA;EDWjB;;;ECPd,MAAA,EAAQ,KAAA,CAAM,aAAA;IACZ,YAAA;IACA,OAAA,EAAS,gBAAA;IACT,OAAA,EAAS,eAAA;IACT,KAAA,EAAO,aAAA;EAAA;AAAA;;;KCtBC,kCAAA;AAAA,UAEK,0BAAA;EACf,OAAA;EACA,MAAA,EAAQ,KAAA,CAAM,aAAA;IAC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A,cAGF,mBAAA,SAA4B,cAAA;EAAA,QAC/B,gBAAA;EAAA,QACA,oBAAA;EAAA,QAEA,4BAAA;EAAA,QAEA,qBAAA;EAAA,QACA,uBAAA;EAAA,QACA,iBAAA;cAEI,MAAA,EAAQ,yBAAA;EAAA,IAOhB,oBAAA,CAAA,GAAwB,QAAA,CAAS,0BAAA;EAAA,IAIjC,sBAAA,CAAA,GAA0B,QAAA,CAAS,4BAAA;EAAA,IAInC,eAAA,CAAA,GAAmB,QAAA,CAAS,qBAAA;EAmBhC,yBAAA,CACE,SAAA,EAAW,4BAAA;EAKb,uBAAA,CAAwB,SAAA,EAAW,0BAAA;EAInC,kBAAA,CAAmB,eAAA,EAAiB,qBAAA;EAMpC,qBAAA,CAAsB,KAAA,EAAO,qBAAA;EAO7B,wBAAA,CAAyB,IAAA,UAAc,OAAA;EAAA,QAQ/B,6BAAA;EAAA,IAYJ,gBAAA,CAAA,GAAoB,OAAA,CAAM,YAAA;EAI9B,mBAAA,CAAoB,OAAA,EAAS,OAAA,CAAM,YAAA;EAYnC,SAAA,CACE,UAAA,EAAY,6BAAA,GACX,0BAAA;EPlHG;;;;;;;;;;;;;EOmIA,8BAAA,CAAA,GAAkC,OAAA;AAAA;;;cC1I7B,wBAAA;;;;;;;;;;;;;;;;;;;;;;KAwBD,iBAAA,UAA2B,wBAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"headless.d.cts","names":[],"sources":["../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/react-activity-message-renderer.ts","../../src/v2/types/react-custom-message-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/types/human-in-the-loop.ts","../../src/v2/types/defineToolCallRenderer.ts","../../src/v2/types/interrupt.ts","../../src/v2/lib/react-core.ts","../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx","../../src/v2/hooks/use-render-tool.tsx","../../src/v2/hooks/use-capabilities.tsx"],"mappings":";;;;;;;UAGiB,qBAAA;EACf,IAAA;;;;AADF;EAME,IAAA,GAAO,gBAAA,MAAsB,CAAA;EANO;;;;EAWpC,OAAA;EACA,MAAA,EAAQ,KAAA,CAAM,aAAA;IAER,IAAA;IACA,UAAA;IACA,IAAA,EAAM,OAAA,CAAQ,CAAA;IACd,MAAA,EAAQ,cAAA,CAAe,UAAA;IACvB,MAAA;EAAA;IAGA,IAAA;IACA,UAAA;IACA,IAAA,EAAM,CAAA;IACN,MAAA,EAAQ,cAAA,CAAe,SAAA;IACvB,MAAA;EAAA;IAGA,IAAA;IACA,UAAA;IACA,IAAA,EAAM,CAAA;IACN,MAAA,EAAQ,cAAA,CAAe,QAAA;IACvB,MAAA;EAAA;AAAA;;;UC/BS,4BAAA;;;;EAIf,YAAA;EDLoC;;;ECSpC,OAAA;EDOoB;;;ECHpB,OAAA,EAAS,gBAAA,MAAsB,gBAAA;EDWjB;;;ECPd,MAAA,EAAQ,KAAA,CAAM,aAAA;IACZ,YAAA;IACA,OAAA,EAAS,gBAAA;IACT,OAAA,EAAS,eAAA;IACT,KAAA,EAAO,aAAA;EAAA;AAAA;;;KCtBC,kCAAA;AAAA,UAEK,0BAAA;EACf,OAAA;EACA,MAAA,EAAQ,KAAA,CAAM,aAAA;IACZ,OAAA,EAAS,OAAA;IACT,QAAA,EAAU,kCAAA;IACV,KAAA;IACA,YAAA;IACA,iBAAA;IACA,qBAAA;IACA,OAAA;IACA,aAAA;EAAA;AAAA;;;KCXQ,iBAAA,WACA,MAAA,oBAA0B,MAAA,qBAClC,YAAA,CAAa,CAAA;EACf,MAAA,GAAS,qBAAA,CAAsB,CAAA;AAAA;;;KCHrB,mBAAA,WACA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uBAAA,WAAkC,gBAAA;EACjD,IAAA;EACA,UAAA;EACA,UAAA,EAAY,iBAAA,CAAkB,CAAA;EAC9B,MAAA;EACA,MAAA;AAAA;AAAA,KAGU,eAAA,WAA0B,gBAAA,IAClC,yBAAA,CAA0B,CAAA,IAC1B,wBAAA,CAAyB,CAAA,IACzB,uBAAA,CAAwB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;iBAiCZ,aAAA,CACd,MAAA;EACE,IAAA;EACA,MAAA,GAAS,KAAA,UAAe,KAAA,CAAM,YAAA;EAC9B,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA;;;;;;;;;;AjBtET;;;;;;;;;;;;;;;;;;iBiBoGgB,aAAA,WAAwB,gBAAA,CAAA,CACtC,MAAA;EACE,IAAA;EACA,UAAA,EAAY,CAAA;EACZ,MAAA,GAAS,KAAA,EAAO,eAAA,CAAgB,CAAA,MAAO,KAAA,CAAM,YAAA;EAC7C,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA;;;;;;;;;AlB5GT;;;;;iBmBWgB,eAAA,CACd,OAAA,YACC,iBAAA"}
|
package/dist/v2/headless.d.mts
CHANGED
|
@@ -35,7 +35,74 @@ interface CopilotChatConfigurationValue {
|
|
|
35
35
|
threadId: string;
|
|
36
36
|
isModalOpen: boolean;
|
|
37
37
|
setModalOpen: (open: boolean) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the thread-list drawer is open. A sibling boolean to `isModalOpen`
|
|
40
|
+
* (deliberately NOT folded into a tri-state enum): on desktop the chat modal
|
|
41
|
+
* and the drawer coexist, so two independent booleans are required.
|
|
42
|
+
*/
|
|
43
|
+
drawerOpen: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Toggles the drawer open state. On mobile viewports (`<768px`) opening the
|
|
46
|
+
* drawer closes the chat modal (mutual exclusion); on desktop there is no
|
|
47
|
+
* constraint.
|
|
48
|
+
*/
|
|
49
|
+
setDrawerOpen: (open: boolean) => void;
|
|
50
|
+
/**
|
|
51
|
+
* True once a `<CopilotThreadsDrawer>` wrapper has registered itself with this chat
|
|
52
|
+
* configuration. The header thread-list launcher renders ONLY when this is
|
|
53
|
+
* set, so chats with no drawer stay byte-for-byte unchanged.
|
|
54
|
+
*/
|
|
55
|
+
drawerRegistered: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Called by the drawer wrapper on mount to announce its presence (and flip
|
|
58
|
+
* `drawerRegistered`). Returns a cleanup function that de-registers the
|
|
59
|
+
* drawer on unmount.
|
|
60
|
+
*
|
|
61
|
+
* @returns A cleanup callback that reverses the registration.
|
|
62
|
+
*/
|
|
63
|
+
registerDrawer: () => () => void;
|
|
64
|
+
/**
|
|
65
|
+
* Internal: registers the modal-close setter of the provider that actually
|
|
66
|
+
* owns the rendered modal (a descendant that supplied `isModalDefaultOpen`),
|
|
67
|
+
* so the drawer's mobile mutual-exclusion — owned by the top-most provider —
|
|
68
|
+
* closes the modal that is genuinely on screen rather than the top-most
|
|
69
|
+
* provider's own (possibly unrendered) modal state.
|
|
70
|
+
*
|
|
71
|
+
* @param closeModal - A setter the drawer may call to close the rendered modal.
|
|
72
|
+
* @returns A cleanup callback that de-registers the closer.
|
|
73
|
+
*/
|
|
74
|
+
ɵregisterModalCloser: (closeModal: (open: boolean) => void) => () => void;
|
|
38
75
|
hasExplicitThreadId: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Imperatively sets the active thread for this chat configuration.
|
|
78
|
+
*
|
|
79
|
+
* Use this to drive the rendered thread without a host callback — e.g. a
|
|
80
|
+
* `<CopilotThreadsDrawer>` selecting a thread row sets it explicitly so the chat
|
|
81
|
+
* connects to that backend thread.
|
|
82
|
+
*
|
|
83
|
+
* Guarded like the top-level `<CopilotKit>` provider's `setThreadId`: when
|
|
84
|
+
* the consumer controls the threadId via the `threadId` prop on this
|
|
85
|
+
* provider, this is a no-op (a warning is logged) so a prop-controlled
|
|
86
|
+
* threadId is never silently overridden.
|
|
87
|
+
*
|
|
88
|
+
* @param threadId - The thread id to make active.
|
|
89
|
+
* @param options.explicit - Whether the thread is a caller choice. Defaults
|
|
90
|
+
* to `true` (a picked thread). Pass `false` to set a non-explicit thread
|
|
91
|
+
* so the welcome screen shows (see {@link startNewThread}).
|
|
92
|
+
*/
|
|
93
|
+
setActiveThreadId: (threadId: string, options?: {
|
|
94
|
+
explicit?: boolean;
|
|
95
|
+
}) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Resets the active thread to a fresh, non-explicit client-side thread: a
|
|
98
|
+
* newly minted UUID with `hasExplicitThreadId=false`, so the welcome screen
|
|
99
|
+
* shows. Pairs with the core `startNewThread()` to clear the conversation
|
|
100
|
+
* with no host wiring.
|
|
101
|
+
*
|
|
102
|
+
* Guarded identically to {@link setActiveThreadId}: a no-op when the
|
|
103
|
+
* threadId is prop-controlled.
|
|
104
|
+
*/
|
|
105
|
+
startNewThread: () => void;
|
|
39
106
|
}
|
|
40
107
|
interface CopilotChatConfigurationProviderProps {
|
|
41
108
|
children: ReactNode;
|
|
@@ -429,6 +496,16 @@ interface UseThreadsInput {
|
|
|
429
496
|
includeArchived?: boolean;
|
|
430
497
|
/** Maximum number of threads to fetch per page. When set, enables cursor-based pagination. */
|
|
431
498
|
limit?: number;
|
|
499
|
+
/**
|
|
500
|
+
* When `false`, the hook stays inert: no runtime context is dispatched, so
|
|
501
|
+
* NO thread-list fetch or realtime subscription is issued. Used by gated
|
|
502
|
+
* surfaces (e.g. an unlicensed `<CopilotThreadsDrawer>`) that must not touch the
|
|
503
|
+
* network until the gate opens. Defaults to `true`.
|
|
504
|
+
*
|
|
505
|
+
* Flipping `enabled` back to `true` resumes normal fetching on the next
|
|
506
|
+
* effect run; mutations are likewise short-circuited while disabled.
|
|
507
|
+
*/
|
|
508
|
+
enabled?: boolean;
|
|
432
509
|
}
|
|
433
510
|
/**
|
|
434
511
|
* Return value of the {@link useThreads} hook.
|
|
@@ -453,8 +530,21 @@ interface UseThreadsResult {
|
|
|
453
530
|
* The most recent error from fetching threads or executing a mutation,
|
|
454
531
|
* or `null` when there is no error. Reset to `null` on the next
|
|
455
532
|
* successful fetch.
|
|
533
|
+
*
|
|
534
|
+
* This channel folds together developer/config errors (missing runtime URL,
|
|
535
|
+
* runtime without thread endpoints) and genuine list-load/mutation failures.
|
|
536
|
+
* End-user surfaces that must not leak config errors should prefer
|
|
537
|
+
* {@link listError}, which excludes the config/runtime-setup errors.
|
|
456
538
|
*/
|
|
457
539
|
error: Error | null;
|
|
540
|
+
/**
|
|
541
|
+
* The most recent genuine list-load or mutation error from the platform, or
|
|
542
|
+
* `null`. Unlike {@link error}, this EXCLUDES developer/config errors (a
|
|
543
|
+
* missing runtime URL, or a runtime that does not advertise thread
|
|
544
|
+
* endpoints), so an end-user surface can render it directly without leaking
|
|
545
|
+
* a developer-facing configuration message into the UI.
|
|
546
|
+
*/
|
|
547
|
+
listError: Error | null;
|
|
458
548
|
/**
|
|
459
549
|
* `true` when there are more threads available to fetch via
|
|
460
550
|
* {@link fetchMoreThreads}. Only meaningful when `limit` is set.
|
|
@@ -464,11 +554,30 @@ interface UseThreadsResult {
|
|
|
464
554
|
* `true` while a subsequent page of threads is being fetched.
|
|
465
555
|
*/
|
|
466
556
|
isFetchingMoreThreads: boolean;
|
|
557
|
+
/**
|
|
558
|
+
* `true` while at least one thread mutation (rename, archive, unarchive,
|
|
559
|
+
* delete) is awaiting a server response. Mutations apply optimistically, so
|
|
560
|
+
* this is primarily useful for disabling controls or showing a subtle
|
|
561
|
+
* in-flight indicator.
|
|
562
|
+
*/
|
|
563
|
+
isMutating: boolean;
|
|
467
564
|
/**
|
|
468
565
|
* Fetch the next page of threads. No-op when {@link hasMoreThreads} is
|
|
469
566
|
* `false` or a fetch is already in progress.
|
|
470
567
|
*/
|
|
471
568
|
fetchMoreThreads: () => void;
|
|
569
|
+
/**
|
|
570
|
+
* Re-fetch the thread list from the platform without clearing the current
|
|
571
|
+
* list. Backs the drawer's error-state Retry and the Active/All filter
|
|
572
|
+
* refetch. No-op until the runtime is connected.
|
|
573
|
+
*/
|
|
574
|
+
refetchThreads: () => void;
|
|
575
|
+
/**
|
|
576
|
+
* Reset to a fresh, non-explicit client-side thread so the welcome screen
|
|
577
|
+
* shows. Lazy creation: no row appears in {@link threads} until the new
|
|
578
|
+
* thread's first run persists server-side.
|
|
579
|
+
*/
|
|
580
|
+
startNewThread: () => void;
|
|
472
581
|
/**
|
|
473
582
|
* Rename a thread on the platform.
|
|
474
583
|
* Resolves when the server confirms the update; rejects on failure.
|
|
@@ -537,7 +646,8 @@ interface UseThreadsResult {
|
|
|
537
646
|
declare function useThreads({
|
|
538
647
|
agentId,
|
|
539
648
|
includeArchived,
|
|
540
|
-
limit
|
|
649
|
+
limit,
|
|
650
|
+
enabled
|
|
541
651
|
}: UseThreadsInput): UseThreadsResult;
|
|
542
652
|
//#endregion
|
|
543
653
|
//#region src/v2/hooks/use-render-tool.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless.d.mts","names":[],"sources":["../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/types/human-in-the-loop.ts","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/types/interrupt.ts","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx","../../src/v2/hooks/use-render-tool.tsx","../../src/v2/types/defineToolCallRenderer.ts","../../src/v2/hooks/use-capabilities.tsx"],"mappings":";;;;;;;;cAca,wBAAA;;;;;;;;;;;;;;;;;;;;;;KAwBD,iBAAA,UAA2B,wBAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"headless.d.mts","names":[],"sources":["../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/types/human-in-the-loop.ts","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/types/interrupt.ts","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx","../../src/v2/hooks/use-render-tool.tsx","../../src/v2/types/defineToolCallRenderer.ts","../../src/v2/hooks/use-capabilities.tsx"],"mappings":";;;;;;;;cAca,wBAAA;;;;;;;;;;;;;;;;;;;;;;KAwBD,iBAAA,UAA2B,wBAAA;AAAA,UA6BtB,6BAAA;EACf,MAAA,EAAQ,iBAAA;EACR,OAAA;EACA,QAAA;EACA,WAAA;EACA,YAAA,GAAe,IAAA;;;;AAlCjB;;EAwCE,UAAA;EAxCqC;;AA6BvC;;;EAiBE,aAAA,GAAgB,IAAA;EAhBhB;;;;;EAsBA,gBAAA;EAlBe;;;;;;;EA0Bf,cAAA;EAWuB;;;;;;;;;AA4CzB;EA5CE,oBAAA,GAAuB,UAAA,GAAa,IAAA;EAKpC,mBAAA;EAwCU;;;;;;;;;;;;;;;;AAcZ;EApCE,iBAAA,GACE,QAAA,UACA,OAAA;IAAY,QAAA;EAAA;EAkC+B;;;;;AAoV/C;;;;EA3WE,cAAA;AAAA;AAAA,UAQe,qCAAA;EACf,QAAA,EAAU,SAAA;EACV,MAAA,GAAS,OAAA,CAAQ,iBAAA;EACjB,OAAA;EACA,QAAA;EAMA,mBAAA;EACA,kBAAA;AAAA;AAAA,cAIW,gCAAA,EAAkC,OAAA,CAAM,EAAA,CACnD,qCAAA;AAAA,cAmVW,2BAAA,QACP,6BAAA;;;aCjfM,cAAA;EACV,iBAAA;EACA,cAAA;EACA,kBAAA;AAAA;AAAA,UASe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A,CAAe,QAAA;EACvB,MAAA;AAAA;AAAA,iBAIU,sBAAA,CAAuB,GAAA;EACrC,IAAA;EACA,MAAA,GAAS,KAAA,EAAO,WAAA,UAAqB,OAAA,CAAM,YAAA;EAC3C,OAAA;AAAA,IACE,qBAAA;AAAA,iBAGY,sBAAA,WAAiC,gBAAA,CAAA,CAAkB,GAAA;EACjE,IAAA;EACA,IAAA,EAAM,CAAA;EACN,MAAA,GAAS,KAAA,EAAO,WAAA,CAAY,iBAAA,CAAkB,CAAA,OAAQ,OAAA,CAAM,YAAA;EAC5D,OAAA;AAAA,IACE,qBAAA,CAAsB,iBAAA,CAAkB,CAAA;;;;;;;;;;AfnC5C;;;;iBgBAgB,eAAA,CACd,OAAA,YACC,iBAAA"}
|
package/dist/v2/headless.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { DEFAULT_AGENT_ID, randomUUID } from "@copilotkit/shared";
|
|
|
4
4
|
import { twMerge } from "tailwind-merge";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { HttpAgent, buildResumeArray, isInterruptExpired, randomUUID as randomUUID$1 } from "@ag-ui/client";
|
|
7
|
-
import { CopilotKitCoreRuntimeConnectionStatus, ProxiedCopilotRuntimeAgent, ToolCallStatus, ɵcreateThreadStore, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading } from "@copilotkit/core";
|
|
7
|
+
import { CopilotKitCoreRuntimeConnectionStatus, ProxiedCopilotRuntimeAgent, ToolCallStatus, ɵcreateThreadStore, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading } from "@copilotkit/core";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
|
|
10
10
|
//#region src/v2/lib/slots.tsx
|
|
@@ -115,6 +115,25 @@ const CopilotChatDefaultLabels = {
|
|
|
115
115
|
modalHeaderTitle: "CopilotKit Chat",
|
|
116
116
|
welcomeMessageText: "How can I help you today?"
|
|
117
117
|
};
|
|
118
|
+
/**
|
|
119
|
+
* Mobile breakpoint below which the chat modal and the thread-list drawer are
|
|
120
|
+
* mutually exclusive. At or above this width both surfaces may coexist. This
|
|
121
|
+
* mirrors the `(max-width: 767px)` / `(min-width: 768px)` split already used by
|
|
122
|
+
* CopilotChatInput and CopilotSidebarView.
|
|
123
|
+
*/
|
|
124
|
+
const MOBILE_MAX_WIDTH_PX = 767;
|
|
125
|
+
/**
|
|
126
|
+
* Reports whether the current viewport is in the mobile range (`<768px`), where
|
|
127
|
+
* the chat modal and drawer must not be open simultaneously. SSR-safe and
|
|
128
|
+
* defensive against environments without `matchMedia` (treated as desktop, so
|
|
129
|
+
* no mutual-exclusion constraint is applied).
|
|
130
|
+
*
|
|
131
|
+
* @returns `true` when the viewport is mobile-width, `false` otherwise.
|
|
132
|
+
*/
|
|
133
|
+
function isMobileViewport() {
|
|
134
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return false;
|
|
135
|
+
return window.matchMedia(`(max-width: ${MOBILE_MAX_WIDTH_PX}px)`).matches;
|
|
136
|
+
}
|
|
118
137
|
const CopilotChatConfiguration = createContext(null);
|
|
119
138
|
const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId, hasExplicitThreadId, isModalDefaultOpen }) => {
|
|
120
139
|
const parentConfig = useContext(CopilotChatConfiguration);
|
|
@@ -125,12 +144,22 @@ const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId,
|
|
|
125
144
|
...stableLabels
|
|
126
145
|
}), [stableLabels, parentConfig?.labels]);
|
|
127
146
|
const resolvedAgentId = agentId ?? parentConfig?.agentId ?? DEFAULT_AGENT_ID;
|
|
147
|
+
const threadIdPropIsAuthoritative = threadId !== void 0 && hasExplicitThreadId !== false;
|
|
148
|
+
const isThreadIdControlled = threadIdPropIsAuthoritative;
|
|
149
|
+
const [activeThreadOverride, setActiveThreadOverride] = useState(null);
|
|
128
150
|
const resolvedThreadId = useMemo(() => {
|
|
129
|
-
if (
|
|
151
|
+
if (threadIdPropIsAuthoritative) return threadId;
|
|
152
|
+
if (activeThreadOverride) return activeThreadOverride.threadId;
|
|
130
153
|
if (parentConfig?.threadId) return parentConfig.threadId;
|
|
154
|
+
if (threadId) return threadId;
|
|
131
155
|
return randomUUID();
|
|
132
|
-
}, [
|
|
133
|
-
|
|
156
|
+
}, [
|
|
157
|
+
threadIdPropIsAuthoritative,
|
|
158
|
+
threadId,
|
|
159
|
+
parentConfig?.threadId,
|
|
160
|
+
activeThreadOverride
|
|
161
|
+
]);
|
|
162
|
+
const resolvedHasExplicitThreadId = (threadIdPropIsAuthoritative ? true : activeThreadOverride?.explicit ?? hasExplicitThreadId ?? false) || !!parentConfig?.hasExplicitThreadId;
|
|
134
163
|
const [internalModalOpen, setInternalModalOpen] = useState(isModalDefaultOpen ?? true);
|
|
135
164
|
const hasExplicitDefault = isModalDefaultOpen !== void 0;
|
|
136
165
|
const setAndSync = useCallback((open) => {
|
|
@@ -149,20 +178,113 @@ const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId,
|
|
|
149
178
|
}, [parentConfig?.isModalOpen, hasExplicitDefault]);
|
|
150
179
|
const resolvedIsModalOpen = hasExplicitDefault ? internalModalOpen : parentConfig?.isModalOpen ?? internalModalOpen;
|
|
151
180
|
const resolvedSetModalOpen = hasExplicitDefault ? setAndSync : parentConfig?.setModalOpen ?? setInternalModalOpen;
|
|
181
|
+
const [ownDrawerOpen, setOwnDrawerOpen] = useState(false);
|
|
182
|
+
const [ownDrawerCount, setOwnDrawerCount] = useState(0);
|
|
183
|
+
const modalCloseRef = useRef(() => {});
|
|
184
|
+
modalCloseRef.current = resolvedSetModalOpen;
|
|
185
|
+
const registeredModalClosersRef = useRef([]);
|
|
186
|
+
const ownRegisterModalCloser = useCallback((closeModal) => {
|
|
187
|
+
registeredModalClosersRef.current.push(closeModal);
|
|
188
|
+
return () => {
|
|
189
|
+
registeredModalClosersRef.current = registeredModalClosersRef.current.filter((entry) => entry !== closeModal);
|
|
190
|
+
};
|
|
191
|
+
}, []);
|
|
192
|
+
const ownSetDrawerOpen = useCallback((open) => {
|
|
193
|
+
setOwnDrawerOpen(open);
|
|
194
|
+
if (open && isMobileViewport()) {
|
|
195
|
+
const registered = registeredModalClosersRef.current;
|
|
196
|
+
(registered.length > 0 ? registered[registered.length - 1] : modalCloseRef.current)(false);
|
|
197
|
+
}
|
|
198
|
+
}, []);
|
|
199
|
+
const ownRegisterDrawer = useCallback(() => {
|
|
200
|
+
setOwnDrawerCount((count) => count + 1);
|
|
201
|
+
return () => {
|
|
202
|
+
setOwnDrawerCount((count) => Math.max(0, count - 1));
|
|
203
|
+
};
|
|
204
|
+
}, []);
|
|
205
|
+
const resolvedDrawerOpen = parentConfig ? parentConfig.drawerOpen : ownDrawerOpen;
|
|
206
|
+
const resolvedSetDrawerOpen = parentConfig ? parentConfig.setDrawerOpen : ownSetDrawerOpen;
|
|
207
|
+
const resolvedDrawerRegistered = parentConfig ? parentConfig.drawerRegistered : ownDrawerCount > 0;
|
|
208
|
+
const resolvedRegisterDrawer = parentConfig ? parentConfig.registerDrawer : ownRegisterDrawer;
|
|
209
|
+
const resolvedRegisterModalCloser = parentConfig ? parentConfig.ɵregisterModalCloser : ownRegisterModalCloser;
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
if (!hasExplicitDefault) return;
|
|
212
|
+
return resolvedRegisterModalCloser(resolvedSetModalOpen);
|
|
213
|
+
}, [
|
|
214
|
+
hasExplicitDefault,
|
|
215
|
+
resolvedRegisterModalCloser,
|
|
216
|
+
resolvedSetModalOpen
|
|
217
|
+
]);
|
|
218
|
+
const isThreadIdControlledRef = useRef(isThreadIdControlled);
|
|
219
|
+
isThreadIdControlledRef.current = isThreadIdControlled;
|
|
220
|
+
const ownSetActiveThreadId = useCallback((id, options) => {
|
|
221
|
+
setActiveThreadOverride({
|
|
222
|
+
threadId: id,
|
|
223
|
+
explicit: options?.explicit ?? true
|
|
224
|
+
});
|
|
225
|
+
}, []);
|
|
226
|
+
const ownStartNewThread = useCallback(() => {
|
|
227
|
+
setActiveThreadOverride({
|
|
228
|
+
threadId: randomUUID(),
|
|
229
|
+
explicit: false
|
|
230
|
+
});
|
|
231
|
+
}, []);
|
|
232
|
+
const parentSetActiveThreadId = parentConfig?.setActiveThreadId;
|
|
233
|
+
const parentStartNewThread = parentConfig?.startNewThread;
|
|
234
|
+
const resolvedSetActiveThreadId = useCallback((id, options) => {
|
|
235
|
+
if (isThreadIdControlledRef.current) {
|
|
236
|
+
console.warn("[CopilotKit] Ignoring setActiveThreadId(): threadId is controlled via the `threadId` prop on CopilotChatConfigurationProvider.");
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (parentSetActiveThreadId) {
|
|
240
|
+
parentSetActiveThreadId(id, options);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
ownSetActiveThreadId(id, options);
|
|
244
|
+
}, [parentSetActiveThreadId, ownSetActiveThreadId]);
|
|
245
|
+
const resolvedStartNewThread = useCallback(() => {
|
|
246
|
+
if (isThreadIdControlledRef.current) {
|
|
247
|
+
console.warn("[CopilotKit] Ignoring startNewThread(): threadId is controlled via the `threadId` prop on CopilotChatConfigurationProvider.");
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (parentStartNewThread) {
|
|
251
|
+
parentStartNewThread();
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
ownStartNewThread();
|
|
255
|
+
}, [parentStartNewThread, ownStartNewThread]);
|
|
256
|
+
const setModalOpenWithDrawerExclusion = useCallback((open) => {
|
|
257
|
+
if (open && isMobileViewport()) resolvedSetDrawerOpen(false);
|
|
258
|
+
resolvedSetModalOpen(open);
|
|
259
|
+
}, [resolvedSetModalOpen, resolvedSetDrawerOpen]);
|
|
152
260
|
const configurationValue = useMemo(() => ({
|
|
153
261
|
labels: mergedLabels,
|
|
154
262
|
agentId: resolvedAgentId,
|
|
155
263
|
threadId: resolvedThreadId,
|
|
156
264
|
hasExplicitThreadId: resolvedHasExplicitThreadId,
|
|
157
265
|
isModalOpen: resolvedIsModalOpen,
|
|
158
|
-
setModalOpen:
|
|
266
|
+
setModalOpen: setModalOpenWithDrawerExclusion,
|
|
267
|
+
drawerOpen: resolvedDrawerOpen,
|
|
268
|
+
setDrawerOpen: resolvedSetDrawerOpen,
|
|
269
|
+
drawerRegistered: resolvedDrawerRegistered,
|
|
270
|
+
registerDrawer: resolvedRegisterDrawer,
|
|
271
|
+
ɵregisterModalCloser: resolvedRegisterModalCloser,
|
|
272
|
+
setActiveThreadId: resolvedSetActiveThreadId,
|
|
273
|
+
startNewThread: resolvedStartNewThread
|
|
159
274
|
}), [
|
|
160
275
|
mergedLabels,
|
|
161
276
|
resolvedAgentId,
|
|
162
277
|
resolvedThreadId,
|
|
163
278
|
resolvedHasExplicitThreadId,
|
|
164
279
|
resolvedIsModalOpen,
|
|
165
|
-
|
|
280
|
+
setModalOpenWithDrawerExclusion,
|
|
281
|
+
resolvedDrawerOpen,
|
|
282
|
+
resolvedSetDrawerOpen,
|
|
283
|
+
resolvedDrawerRegistered,
|
|
284
|
+
resolvedRegisterDrawer,
|
|
285
|
+
resolvedRegisterModalCloser,
|
|
286
|
+
resolvedSetActiveThreadId,
|
|
287
|
+
resolvedStartNewThread
|
|
166
288
|
]);
|
|
167
289
|
return /* @__PURE__ */ jsx(CopilotChatConfiguration.Provider, {
|
|
168
290
|
value: configurationValue,
|
|
@@ -992,7 +1114,7 @@ function useThreadStoreSelector(store, selector) {
|
|
|
992
1114
|
return useSyncExternalStore(useCallback((onStoreChange) => {
|
|
993
1115
|
const subscription = store.select(selector).subscribe(onStoreChange);
|
|
994
1116
|
return () => subscription.unsubscribe();
|
|
995
|
-
}, [store, selector]), () => selector(store.getState()));
|
|
1117
|
+
}, [store, selector]), () => selector(store.getState()), () => selector(store.getServerState()));
|
|
996
1118
|
}
|
|
997
1119
|
/**
|
|
998
1120
|
* React hook for listing and managing Intelligence platform threads.
|
|
@@ -1035,7 +1157,7 @@ function useThreadStoreSelector(store, selector) {
|
|
|
1035
1157
|
* }
|
|
1036
1158
|
* ```
|
|
1037
1159
|
*/
|
|
1038
|
-
function useThreads({ agentId, includeArchived, limit }) {
|
|
1160
|
+
function useThreads({ agentId, includeArchived, limit, enabled = true }) {
|
|
1039
1161
|
const { copilotkit } = useCopilotKit();
|
|
1040
1162
|
const [store] = useState(() => ɵcreateThreadStore({ fetch: globalThis.fetch }));
|
|
1041
1163
|
const coreThreads = useThreadStoreSelector(store, ɵselectThreads);
|
|
@@ -1052,6 +1174,7 @@ function useThreads({ agentId, includeArchived, limit }) {
|
|
|
1052
1174
|
const storeError = useThreadStoreSelector(store, ɵselectThreadsError);
|
|
1053
1175
|
const hasMoreThreads = useThreadStoreSelector(store, ɵselectHasNextPage);
|
|
1054
1176
|
const isFetchingMoreThreads = useThreadStoreSelector(store, ɵselectIsFetchingNextPage);
|
|
1177
|
+
const isMutating = useThreadStoreSelector(store, ɵselectIsMutating);
|
|
1055
1178
|
const headersKey = useMemo(() => {
|
|
1056
1179
|
return JSON.stringify(Object.entries(copilotkit.headers ?? {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
1057
1180
|
}, [copilotkit.headers]);
|
|
@@ -1072,9 +1195,16 @@ function useThreads({ agentId, includeArchived, limit }) {
|
|
|
1072
1195
|
return /* @__PURE__ */ new Error("Thread mutations are not available on this CopilotKit runtime");
|
|
1073
1196
|
}, [threadMutationsSupported]);
|
|
1074
1197
|
const [hasDispatchedContext, setHasDispatchedContext] = useState(false);
|
|
1075
|
-
const preConnectLoading = !!copilotkit.runtimeUrl && !threadEndpointsUnavailable && !hasDispatchedContext;
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1198
|
+
const preConnectLoading = enabled && !!copilotkit.runtimeUrl && !threadEndpointsUnavailable && !hasDispatchedContext;
|
|
1199
|
+
const [configErrorDismissed, setConfigErrorDismissed] = useState(false);
|
|
1200
|
+
useEffect(() => {
|
|
1201
|
+
setConfigErrorDismissed(false);
|
|
1202
|
+
}, [runtimeError, threadEndpointsError]);
|
|
1203
|
+
const activeRuntimeError = configErrorDismissed ? null : runtimeError;
|
|
1204
|
+
const activeThreadEndpointsError = configErrorDismissed ? null : threadEndpointsError;
|
|
1205
|
+
const isLoading = activeRuntimeError || activeThreadEndpointsError ? false : preConnectLoading || storeIsLoading;
|
|
1206
|
+
const error = activeRuntimeError ?? activeThreadEndpointsError ?? storeError;
|
|
1207
|
+
const listError = storeError;
|
|
1078
1208
|
useEffect(() => {
|
|
1079
1209
|
store.start();
|
|
1080
1210
|
return () => {
|
|
@@ -1082,6 +1212,7 @@ function useThreads({ agentId, includeArchived, limit }) {
|
|
|
1082
1212
|
};
|
|
1083
1213
|
}, [store]);
|
|
1084
1214
|
useEffect(() => {
|
|
1215
|
+
if (!enabled) return;
|
|
1085
1216
|
copilotkit.registerThreadStore(agentId, store);
|
|
1086
1217
|
return () => {
|
|
1087
1218
|
copilotkit.unregisterThreadStore(agentId);
|
|
@@ -1089,9 +1220,15 @@ function useThreads({ agentId, includeArchived, limit }) {
|
|
|
1089
1220
|
}, [
|
|
1090
1221
|
copilotkit,
|
|
1091
1222
|
agentId,
|
|
1092
|
-
store
|
|
1223
|
+
store,
|
|
1224
|
+
enabled
|
|
1093
1225
|
]);
|
|
1094
1226
|
useEffect(() => {
|
|
1227
|
+
if (!enabled) {
|
|
1228
|
+
store.setContext(null);
|
|
1229
|
+
setHasDispatchedContext(false);
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1095
1232
|
if (!copilotkit.runtimeUrl) {
|
|
1096
1233
|
store.setContext(null);
|
|
1097
1234
|
setHasDispatchedContext(false);
|
|
@@ -1115,6 +1252,7 @@ function useThreads({ agentId, includeArchived, limit }) {
|
|
|
1115
1252
|
setHasDispatchedContext(true);
|
|
1116
1253
|
}, [
|
|
1117
1254
|
store,
|
|
1255
|
+
enabled,
|
|
1118
1256
|
copilotkit.runtimeUrl,
|
|
1119
1257
|
runtimeStatus,
|
|
1120
1258
|
headersKey,
|
|
@@ -1138,9 +1276,16 @@ function useThreads({ agentId, includeArchived, limit }) {
|
|
|
1138
1276
|
threads,
|
|
1139
1277
|
isLoading,
|
|
1140
1278
|
error,
|
|
1279
|
+
listError,
|
|
1141
1280
|
hasMoreThreads,
|
|
1142
1281
|
isFetchingMoreThreads,
|
|
1282
|
+
isMutating,
|
|
1143
1283
|
fetchMoreThreads: useCallback(() => store.fetchNextPage(), [store]),
|
|
1284
|
+
refetchThreads: useCallback(() => store.refetchThreads(), [store]),
|
|
1285
|
+
startNewThread: useCallback(() => {
|
|
1286
|
+
setConfigErrorDismissed(true);
|
|
1287
|
+
store.startNewThread();
|
|
1288
|
+
}, [store]),
|
|
1144
1289
|
renameThread,
|
|
1145
1290
|
archiveThread,
|
|
1146
1291
|
unarchiveThread,
|