@yourgpt/copilot-sdk 0.1.0 → 1.0.0
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/README.md +25 -23
- package/dist/ThreadManager-BCVt-_k_.d.cts +863 -0
- package/dist/ThreadManager-BjC15mh8.d.ts +863 -0
- package/dist/{chunk-2ZCWVAAK.cjs → chunk-42YQ4ATO.cjs} +889 -2
- package/dist/chunk-42YQ4ATO.cjs.map +1 -0
- package/dist/{chunk-W6KQT7YZ.cjs → chunk-BN75ZW24.cjs} +482 -46
- package/dist/chunk-BN75ZW24.cjs.map +1 -0
- package/dist/{chunk-N4OA2J32.js → chunk-QSEGNATZ.js} +882 -3
- package/dist/chunk-QSEGNATZ.js.map +1 -0
- package/dist/{chunk-QUGTRQSS.js → chunk-XAVZZVUL.js} +455 -24
- package/dist/chunk-XAVZZVUL.js.map +1 -0
- package/dist/core/index.cjs +99 -71
- package/dist/core/index.d.cts +13 -4
- package/dist/core/index.d.ts +13 -4
- package/dist/core/index.js +1 -1
- package/dist/react/index.cjs +66 -34
- package/dist/react/index.d.cts +395 -7
- package/dist/react/index.d.ts +395 -7
- package/dist/react/index.js +2 -2
- package/dist/{thread-C2FjuGLb.d.cts → types-BtAaOV07.d.cts} +214 -478
- package/dist/{thread-C2FjuGLb.d.ts → types-BtAaOV07.d.ts} +214 -478
- package/dist/ui/index.cjs +1710 -384
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +399 -42
- package/dist/ui/index.d.ts +399 -42
- package/dist/ui/index.js +1706 -384
- package/dist/ui/index.js.map +1 -1
- package/package.json +9 -8
- package/dist/chunk-2ZCWVAAK.cjs.map +0 -1
- package/dist/chunk-N4OA2J32.js.map +0 -1
- package/dist/chunk-QUGTRQSS.js.map +0 -1
- package/dist/chunk-W6KQT7YZ.cjs.map +0 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -1,7 +1,52 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { q as LLMConfig, s as CopilotConfig, l as ToolsConfig, t as ActionDefinition, o as CapturedContext, m as ToolConsentRequest, T as ToolType, n as ToolConsentResponse, S as ScreenshotOptions, C as ConsoleLogOptions, N as NetworkRequestOptions, I as IntentDetectionResult, z as InternalKnowledgeBaseConfig, D as InternalKnowledgeBaseSearchResponse, B as InternalKnowledgeBaseResult, $ as ThreadManagerState, a0 as LoadStatus, X as ThreadManagerConfig, M as ThreadManager, Y as ThreadManagerCallbacks, Z as CreateThreadOptions, _ as UpdateThreadOptions } from '../ThreadManager-BjC15mh8.js';
|
|
4
|
+
export { A as ActionParameter, r as CloudConfig, a1 as LocalStorageAdapterConfig, Q as createLocalStorageAdapter, U as createMemoryAdapter, i as generateSuggestionReason } from '../ThreadManager-BjC15mh8.js';
|
|
5
|
+
import { X as AsyncThreadStorageAdapter, M as MessageAttachment, i as ToolCall, S as Source, T as ToolDefinition, x as PermissionLevel, c as ToolInputSchema, g as Message, s as ToolExecution$1, e as ToolContext, b as ToolResponse$1, n as ToolRenderProps, p as ToolSet, U as UnifiedToolCall, k as Thread, l as ThreadData, _ as ThreadStorageAdapter, z as PermissionStorageConfig, B as PermissionStorageAdapter } from '../types-BtAaOV07.js';
|
|
6
|
+
export { t as AgentLoopConfig, P as PersistenceConfig, m as ThreadStorageAdapter, a as ToolExecutionStatus, y as ToolPermission } from '../types-BtAaOV07.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Server Thread Storage Adapter
|
|
10
|
+
*
|
|
11
|
+
* Fetches threads from a user-provided API endpoint.
|
|
12
|
+
* Implements AsyncThreadStorageAdapter for optimized single-thread operations.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Configuration for server adapter
|
|
17
|
+
*/
|
|
18
|
+
interface ServerAdapterConfig {
|
|
19
|
+
/**
|
|
20
|
+
* Endpoint URL for thread API
|
|
21
|
+
* @example "/api/threads"
|
|
22
|
+
*/
|
|
23
|
+
endpoint: string;
|
|
24
|
+
/**
|
|
25
|
+
* Additional headers to include in requests (e.g., auth tokens)
|
|
26
|
+
*/
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* Custom fetch function (useful for testing or adding interceptors)
|
|
30
|
+
* @default globalThis.fetch
|
|
31
|
+
*/
|
|
32
|
+
fetch?: typeof fetch;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a server-based thread storage adapter
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const adapter = createServerAdapter({
|
|
40
|
+
* threadsUrl: "/api/threads",
|
|
41
|
+
* headers: {
|
|
42
|
+
* Authorization: `Bearer ${token}`,
|
|
43
|
+
* },
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* const { threads } = useThreadManager({ adapter });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
declare function createServerAdapter(config: ServerAdapterConfig): AsyncThreadStorageAdapter;
|
|
5
50
|
|
|
6
51
|
/**
|
|
7
52
|
* Message Types
|
|
@@ -339,6 +384,10 @@ interface ToolExecution {
|
|
|
339
384
|
error?: string;
|
|
340
385
|
startedAt?: Date;
|
|
341
386
|
completedAt?: Date;
|
|
387
|
+
/** Custom approval message from tool definition */
|
|
388
|
+
approvalMessage?: string;
|
|
389
|
+
/** Data passed from user's approval action (e.g., selected supervisor) */
|
|
390
|
+
approvalData?: Record<string, unknown>;
|
|
342
391
|
}
|
|
343
392
|
/**
|
|
344
393
|
* Tool response
|
|
@@ -393,7 +442,22 @@ interface AgentLoopState$1 {
|
|
|
393
442
|
* Agent loop actions interface
|
|
394
443
|
*/
|
|
395
444
|
interface AgentLoopActions {
|
|
396
|
-
|
|
445
|
+
/**
|
|
446
|
+
* Approve a tool execution with optional extra data.
|
|
447
|
+
* The extraData is passed to the tool handler via context.approvalData.
|
|
448
|
+
*
|
|
449
|
+
* @param executionId - The tool execution ID
|
|
450
|
+
* @param extraData - Optional data from user's approval action (e.g., selected item)
|
|
451
|
+
* @param permissionLevel - Optional permission level for persistence
|
|
452
|
+
*/
|
|
453
|
+
approveToolExecution: (executionId: string, extraData?: Record<string, unknown>, permissionLevel?: PermissionLevel) => void;
|
|
454
|
+
/**
|
|
455
|
+
* Reject a tool execution.
|
|
456
|
+
*
|
|
457
|
+
* @param executionId - The tool execution ID
|
|
458
|
+
* @param reason - Optional rejection reason
|
|
459
|
+
* @param permissionLevel - Optional permission level for persistence
|
|
460
|
+
*/
|
|
397
461
|
rejectToolExecution: (executionId: string, reason?: string, permissionLevel?: PermissionLevel) => void;
|
|
398
462
|
clearToolExecutions: () => void;
|
|
399
463
|
}
|
|
@@ -639,12 +703,13 @@ declare class AbstractAgentLoop implements AgentLoopActions {
|
|
|
639
703
|
private executeSingleTool;
|
|
640
704
|
/**
|
|
641
705
|
* Wait for user approval
|
|
706
|
+
* Returns approval result with optional extraData from user's action
|
|
642
707
|
*/
|
|
643
708
|
private waitForApproval;
|
|
644
709
|
/**
|
|
645
|
-
* Approve a tool execution
|
|
710
|
+
* Approve a tool execution with optional extra data
|
|
646
711
|
*/
|
|
647
|
-
approveToolExecution(executionId: string, _permissionLevel?: PermissionLevel): void;
|
|
712
|
+
approveToolExecution(executionId: string, extraData?: Record<string, unknown>, _permissionLevel?: PermissionLevel): void;
|
|
648
713
|
/**
|
|
649
714
|
* Reject a tool execution
|
|
650
715
|
*/
|
|
@@ -695,13 +760,14 @@ interface CopilotContextValue {
|
|
|
695
760
|
sendMessage: (content: string, attachments?: MessageAttachment[]) => Promise<void>;
|
|
696
761
|
stop: () => void;
|
|
697
762
|
clearMessages: () => void;
|
|
763
|
+
setMessages: (messages: UIMessage[]) => void;
|
|
698
764
|
regenerate: (messageId?: string) => Promise<void>;
|
|
699
765
|
registerTool: (tool: ToolDefinition) => void;
|
|
700
766
|
unregisterTool: (name: string) => void;
|
|
701
767
|
registeredTools: ToolDefinition[];
|
|
702
768
|
toolExecutions: ToolExecution[];
|
|
703
769
|
pendingApprovals: ToolExecution[];
|
|
704
|
-
approveToolExecution: (id: string, permissionLevel?: PermissionLevel) => void;
|
|
770
|
+
approveToolExecution: (id: string, extraData?: Record<string, unknown>, permissionLevel?: PermissionLevel) => void;
|
|
705
771
|
rejectToolExecution: (id: string, reason?: string, permissionLevel?: PermissionLevel) => void;
|
|
706
772
|
registerAction: (action: ActionDefinition) => void;
|
|
707
773
|
unregisterAction: (name: string) => void;
|
|
@@ -1588,6 +1654,328 @@ interface DevLoggerState {
|
|
|
1588
1654
|
*/
|
|
1589
1655
|
declare function useDevLogger(): DevLoggerState;
|
|
1590
1656
|
|
|
1657
|
+
/**
|
|
1658
|
+
* ReactThreadManagerState - React-specific implementation of ThreadManagerState
|
|
1659
|
+
*
|
|
1660
|
+
* This class implements the ThreadManagerState interface with callback-based
|
|
1661
|
+
* reactivity for use with React's useSyncExternalStore.
|
|
1662
|
+
*
|
|
1663
|
+
* Pattern follows ReactChatState for consistency.
|
|
1664
|
+
*/
|
|
1665
|
+
|
|
1666
|
+
/**
|
|
1667
|
+
* ReactThreadManagerState implements ThreadManagerState with callback-based reactivity
|
|
1668
|
+
*
|
|
1669
|
+
* @example
|
|
1670
|
+
* ```tsx
|
|
1671
|
+
* const state = new ReactThreadManagerState();
|
|
1672
|
+
*
|
|
1673
|
+
* // Subscribe to changes (for useSyncExternalStore)
|
|
1674
|
+
* const unsubscribe = state.subscribe(() => {
|
|
1675
|
+
* console.log('State changed');
|
|
1676
|
+
* });
|
|
1677
|
+
*
|
|
1678
|
+
* // Get snapshot (for useSyncExternalStore)
|
|
1679
|
+
* const threads = state.threads;
|
|
1680
|
+
* ```
|
|
1681
|
+
*/
|
|
1682
|
+
declare class ReactThreadManagerState implements ThreadManagerState {
|
|
1683
|
+
private _threads;
|
|
1684
|
+
private _currentThreadId;
|
|
1685
|
+
private _currentThread;
|
|
1686
|
+
private _loadStatus;
|
|
1687
|
+
private _error;
|
|
1688
|
+
private subscribers;
|
|
1689
|
+
constructor(initialThreads?: Thread[]);
|
|
1690
|
+
get threads(): Thread[];
|
|
1691
|
+
get currentThreadId(): string | null;
|
|
1692
|
+
get currentThread(): ThreadData | null;
|
|
1693
|
+
get loadStatus(): LoadStatus;
|
|
1694
|
+
get error(): Error | undefined;
|
|
1695
|
+
set threads(value: Thread[]);
|
|
1696
|
+
setThreads(threads: Thread[]): void;
|
|
1697
|
+
setCurrentThread(thread: ThreadData | null): void;
|
|
1698
|
+
setCurrentThreadId(id: string | null): void;
|
|
1699
|
+
addThread(thread: Thread): void;
|
|
1700
|
+
updateThread(id: string, updates: Partial<Thread>): void;
|
|
1701
|
+
removeThread(id: string): void;
|
|
1702
|
+
setLoadStatus(status: LoadStatus): void;
|
|
1703
|
+
setError(error: Error | undefined): void;
|
|
1704
|
+
/**
|
|
1705
|
+
* Subscribe to state changes.
|
|
1706
|
+
* Returns an unsubscribe function.
|
|
1707
|
+
*
|
|
1708
|
+
* @example
|
|
1709
|
+
* ```tsx
|
|
1710
|
+
* const threads = useSyncExternalStore(
|
|
1711
|
+
* state.subscribe,
|
|
1712
|
+
* () => state.threads
|
|
1713
|
+
* );
|
|
1714
|
+
* ```
|
|
1715
|
+
*/
|
|
1716
|
+
subscribe: (callback: () => void) => (() => void);
|
|
1717
|
+
getThreadsSnapshot(): Thread[];
|
|
1718
|
+
getCurrentThreadSnapshot(): ThreadData | null;
|
|
1719
|
+
getLoadStatusSnapshot(): LoadStatus;
|
|
1720
|
+
getErrorSnapshot(): Error | undefined;
|
|
1721
|
+
private notify;
|
|
1722
|
+
/**
|
|
1723
|
+
* Cleanup subscriptions
|
|
1724
|
+
*/
|
|
1725
|
+
dispose(): void;
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Create a ReactThreadManagerState instance
|
|
1729
|
+
*/
|
|
1730
|
+
declare function createReactThreadManagerState(initialThreads?: Thread[]): ReactThreadManagerState;
|
|
1731
|
+
|
|
1732
|
+
/**
|
|
1733
|
+
* ReactThreadManager - React adapter for ThreadManager
|
|
1734
|
+
*
|
|
1735
|
+
* Extends ThreadManager with React-specific state management.
|
|
1736
|
+
*/
|
|
1737
|
+
|
|
1738
|
+
/**
|
|
1739
|
+
* Configuration for ReactThreadManager
|
|
1740
|
+
*/
|
|
1741
|
+
interface ReactThreadManagerConfig extends Omit<ThreadManagerConfig, "state"> {
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* ReactThreadManager - React adapter for ThreadManager
|
|
1745
|
+
*
|
|
1746
|
+
* Uses ReactThreadManagerState for React's useSyncExternalStore compatibility.
|
|
1747
|
+
*
|
|
1748
|
+
* @example
|
|
1749
|
+
* ```tsx
|
|
1750
|
+
* const manager = createReactThreadManager();
|
|
1751
|
+
*
|
|
1752
|
+
* // In a component using useSyncExternalStore
|
|
1753
|
+
* const threads = useSyncExternalStore(
|
|
1754
|
+
* manager.subscribe,
|
|
1755
|
+
* manager.getThreadsSnapshot
|
|
1756
|
+
* );
|
|
1757
|
+
* ```
|
|
1758
|
+
*/
|
|
1759
|
+
declare class ReactThreadManager extends ThreadManager {
|
|
1760
|
+
protected state: ReactThreadManagerState;
|
|
1761
|
+
constructor(config?: ReactThreadManagerConfig, callbacks?: ThreadManagerCallbacks);
|
|
1762
|
+
/**
|
|
1763
|
+
* Subscribe to state changes
|
|
1764
|
+
* Use with useSyncExternalStore
|
|
1765
|
+
*/
|
|
1766
|
+
subscribe: (callback: () => void) => (() => void);
|
|
1767
|
+
/**
|
|
1768
|
+
* Get threads snapshot
|
|
1769
|
+
*/
|
|
1770
|
+
getThreadsSnapshot: () => typeof this.threads;
|
|
1771
|
+
/**
|
|
1772
|
+
* Get current thread snapshot
|
|
1773
|
+
*/
|
|
1774
|
+
getCurrentThreadSnapshot: () => typeof this.currentThread;
|
|
1775
|
+
/**
|
|
1776
|
+
* Get current thread ID snapshot
|
|
1777
|
+
*/
|
|
1778
|
+
getCurrentThreadIdSnapshot: () => string | null;
|
|
1779
|
+
/**
|
|
1780
|
+
* Get load status snapshot
|
|
1781
|
+
*/
|
|
1782
|
+
getLoadStatusSnapshot: () => typeof this.loadStatus;
|
|
1783
|
+
/**
|
|
1784
|
+
* Get error snapshot
|
|
1785
|
+
*/
|
|
1786
|
+
getErrorSnapshot: () => typeof this.error;
|
|
1787
|
+
/**
|
|
1788
|
+
* Get isLoading snapshot
|
|
1789
|
+
*/
|
|
1790
|
+
getIsLoadingSnapshot: () => boolean;
|
|
1791
|
+
private static readonly EMPTY_THREADS;
|
|
1792
|
+
private static readonly IDLE_STATUS;
|
|
1793
|
+
/**
|
|
1794
|
+
* Get threads snapshot for server (always empty for hydration consistency)
|
|
1795
|
+
*/
|
|
1796
|
+
getThreadsServerSnapshot: () => Thread[];
|
|
1797
|
+
/**
|
|
1798
|
+
* Get current thread snapshot for server (always null)
|
|
1799
|
+
*/
|
|
1800
|
+
getCurrentThreadServerSnapshot: () => typeof this.currentThread;
|
|
1801
|
+
/**
|
|
1802
|
+
* Get current thread ID snapshot for server (always null)
|
|
1803
|
+
*/
|
|
1804
|
+
getCurrentThreadIdServerSnapshot: () => string | null;
|
|
1805
|
+
/**
|
|
1806
|
+
* Get load status snapshot for server (always "idle")
|
|
1807
|
+
*/
|
|
1808
|
+
getLoadStatusServerSnapshot: () => typeof this.loadStatus;
|
|
1809
|
+
/**
|
|
1810
|
+
* Get error snapshot for server (always undefined)
|
|
1811
|
+
*/
|
|
1812
|
+
getErrorServerSnapshot: () => typeof this.error;
|
|
1813
|
+
/**
|
|
1814
|
+
* Get isLoading snapshot for server (always false)
|
|
1815
|
+
*/
|
|
1816
|
+
getIsLoadingServerSnapshot: () => boolean;
|
|
1817
|
+
/**
|
|
1818
|
+
* Dispose of the manager
|
|
1819
|
+
*/
|
|
1820
|
+
dispose(): Promise<void>;
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* Create a ReactThreadManager instance
|
|
1824
|
+
*/
|
|
1825
|
+
declare function createReactThreadManager(config?: ReactThreadManagerConfig, callbacks?: ThreadManagerCallbacks): ReactThreadManager;
|
|
1826
|
+
|
|
1827
|
+
/**
|
|
1828
|
+
* useThreadManager - React hook for thread management
|
|
1829
|
+
*
|
|
1830
|
+
* Provides thread CRUD operations with localStorage persistence by default.
|
|
1831
|
+
* Uses useSyncExternalStore for optimal React integration.
|
|
1832
|
+
*/
|
|
1833
|
+
|
|
1834
|
+
/**
|
|
1835
|
+
* Configuration for useThreadManager hook
|
|
1836
|
+
*/
|
|
1837
|
+
interface UseThreadManagerConfig extends ReactThreadManagerConfig {
|
|
1838
|
+
/**
|
|
1839
|
+
* Storage adapter for persistence
|
|
1840
|
+
* @default localStorage adapter
|
|
1841
|
+
*/
|
|
1842
|
+
adapter?: ThreadStorageAdapter | AsyncThreadStorageAdapter;
|
|
1843
|
+
/**
|
|
1844
|
+
* Debounce delay for auto-save (ms)
|
|
1845
|
+
* @default 1000
|
|
1846
|
+
*/
|
|
1847
|
+
saveDebounce?: number;
|
|
1848
|
+
/**
|
|
1849
|
+
* Whether to auto-load threads on mount
|
|
1850
|
+
* @default true
|
|
1851
|
+
*/
|
|
1852
|
+
autoLoad?: boolean;
|
|
1853
|
+
/**
|
|
1854
|
+
* Whether to auto-restore the last active thread on load
|
|
1855
|
+
* Requires adapter to support getLastActiveThreadId/setLastActiveThreadId
|
|
1856
|
+
* @default true
|
|
1857
|
+
*/
|
|
1858
|
+
autoRestoreLastThread?: boolean;
|
|
1859
|
+
/**
|
|
1860
|
+
* Callbacks for thread events
|
|
1861
|
+
*/
|
|
1862
|
+
callbacks?: ThreadManagerCallbacks;
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
* Return type for useThreadManager hook
|
|
1866
|
+
*/
|
|
1867
|
+
interface UseThreadManagerReturn {
|
|
1868
|
+
/** All threads (metadata only) */
|
|
1869
|
+
threads: Thread[];
|
|
1870
|
+
/** Currently loaded thread (with messages) */
|
|
1871
|
+
currentThread: ThreadData | null;
|
|
1872
|
+
/** Currently selected thread ID */
|
|
1873
|
+
currentThreadId: string | null;
|
|
1874
|
+
/** Whether threads are currently loading */
|
|
1875
|
+
isLoading: boolean;
|
|
1876
|
+
/** Current load status */
|
|
1877
|
+
loadStatus: LoadStatus;
|
|
1878
|
+
/** Current error */
|
|
1879
|
+
error: Error | undefined;
|
|
1880
|
+
/**
|
|
1881
|
+
* Create a new thread
|
|
1882
|
+
*/
|
|
1883
|
+
createThread: (options?: CreateThreadOptions) => Promise<ThreadData>;
|
|
1884
|
+
/**
|
|
1885
|
+
* Switch to a different thread
|
|
1886
|
+
*/
|
|
1887
|
+
switchThread: (id: string) => Promise<ThreadData | null>;
|
|
1888
|
+
/**
|
|
1889
|
+
* Update the current thread
|
|
1890
|
+
*/
|
|
1891
|
+
updateCurrentThread: (updates: UpdateThreadOptions) => Promise<void>;
|
|
1892
|
+
/**
|
|
1893
|
+
* Delete a thread
|
|
1894
|
+
*/
|
|
1895
|
+
deleteThread: (id: string) => Promise<void>;
|
|
1896
|
+
/**
|
|
1897
|
+
* Clear the current thread selection
|
|
1898
|
+
*/
|
|
1899
|
+
clearCurrentThread: () => void;
|
|
1900
|
+
/**
|
|
1901
|
+
* Refresh threads from storage
|
|
1902
|
+
*/
|
|
1903
|
+
refreshThreads: () => Promise<void>;
|
|
1904
|
+
/**
|
|
1905
|
+
* Save changes immediately (bypass debounce)
|
|
1906
|
+
*/
|
|
1907
|
+
saveNow: () => Promise<void>;
|
|
1908
|
+
/**
|
|
1909
|
+
* Clear all threads
|
|
1910
|
+
*/
|
|
1911
|
+
clearAllThreads: () => Promise<void>;
|
|
1912
|
+
/**
|
|
1913
|
+
* Whether there are pending changes waiting to be saved
|
|
1914
|
+
*/
|
|
1915
|
+
hasPendingChanges: boolean;
|
|
1916
|
+
/**
|
|
1917
|
+
* Get messages for the current thread (convenience getter)
|
|
1918
|
+
*/
|
|
1919
|
+
messages: Message[];
|
|
1920
|
+
/**
|
|
1921
|
+
* Update messages for the current thread (convenience setter)
|
|
1922
|
+
*/
|
|
1923
|
+
setMessages: (messages: Message[]) => Promise<void>;
|
|
1924
|
+
}
|
|
1925
|
+
/**
|
|
1926
|
+
* useThreadManager - React hook for thread management
|
|
1927
|
+
*
|
|
1928
|
+
* Provides thread CRUD operations with localStorage persistence by default.
|
|
1929
|
+
*
|
|
1930
|
+
* @example Basic usage (localStorage by default)
|
|
1931
|
+
* ```tsx
|
|
1932
|
+
* function App() {
|
|
1933
|
+
* const {
|
|
1934
|
+
* threads,
|
|
1935
|
+
* currentThread,
|
|
1936
|
+
* createThread,
|
|
1937
|
+
* switchThread,
|
|
1938
|
+
* updateCurrentThread,
|
|
1939
|
+
* } = useThreadManager();
|
|
1940
|
+
*
|
|
1941
|
+
* return (
|
|
1942
|
+
* <CopilotProvider
|
|
1943
|
+
* runtimeUrl="/api/chat"
|
|
1944
|
+
* threadId={currentThread?.id}
|
|
1945
|
+
* initialMessages={currentThread?.messages}
|
|
1946
|
+
* onMessagesChange={(msgs) => updateCurrentThread({ messages: msgs })}
|
|
1947
|
+
* >
|
|
1948
|
+
* <ThreadPicker
|
|
1949
|
+
* value={currentThread?.id}
|
|
1950
|
+
* threads={threads}
|
|
1951
|
+
* onSelect={switchThread}
|
|
1952
|
+
* onNewThread={() => createThread()}
|
|
1953
|
+
* />
|
|
1954
|
+
* <Chat />
|
|
1955
|
+
* </CopilotProvider>
|
|
1956
|
+
* );
|
|
1957
|
+
* }
|
|
1958
|
+
* ```
|
|
1959
|
+
*
|
|
1960
|
+
* @example With custom adapter
|
|
1961
|
+
* ```tsx
|
|
1962
|
+
* const { threads } = useThreadManager({
|
|
1963
|
+
* adapter: myDatabaseAdapter,
|
|
1964
|
+
* });
|
|
1965
|
+
* ```
|
|
1966
|
+
*
|
|
1967
|
+
* @example With callbacks
|
|
1968
|
+
* ```tsx
|
|
1969
|
+
* const { threads } = useThreadManager({
|
|
1970
|
+
* callbacks: {
|
|
1971
|
+
* onThreadCreated: (thread) => console.log('Created:', thread.id),
|
|
1972
|
+
* onError: (error) => console.error('Error:', error),
|
|
1973
|
+
* },
|
|
1974
|
+
* });
|
|
1975
|
+
* ```
|
|
1976
|
+
*/
|
|
1977
|
+
declare function useThreadManager(config?: UseThreadManagerConfig): UseThreadManagerReturn;
|
|
1978
|
+
|
|
1591
1979
|
/**
|
|
1592
1980
|
* Create a permission storage adapter based on config
|
|
1593
1981
|
*/
|
|
@@ -1821,4 +2209,4 @@ interface UseChatReturn {
|
|
|
1821
2209
|
*/
|
|
1822
2210
|
declare function useChat(config: UseChatConfig): UseChatReturn;
|
|
1823
2211
|
|
|
1824
|
-
export { type AIContextItem, AbstractAgentLoop, AbstractChat, ActionDefinition, type AgentLoopActions, type AgentLoopCallbacks, type AgentLoopState, type CapabilitiesResponse, CapturedContext, type ChatActions, type ChatCallbacks, type ChatConfig, type ChatState, type ChatStatus, type ToolExecution as ChatToolExecution, type ToolResponse as ChatToolResponse, type CombinedChatState, CopilotConfig, type CopilotContextValue, CopilotProvider, type CopilotProviderProps, type AgentLoopState$1 as CoreAgentLoopState, type ChatState$1 as CoreChatState, type DevLoggerState, IntentDetectionResult, type KnowledgeBaseConfig, type KnowledgeBaseResult, type KnowledgeBaseSearchResponse, LLMConfig, Message, PermissionLevel, PermissionStorageAdapter, PermissionStorageConfig, type ProviderCapabilities, ReactChat, type ReactChatConfig, ReactChatState, Source, type Suggestion, ToolConsentRequest, ToolConsentResponse, ToolContext, ToolDefinition, ToolExecution$1 as ToolExecution, ToolResponse$1 as ToolResponse, ToolType, type ToolsActions, ToolsConfig, type ToolsState, type UIMessage, UnifiedToolCall, type UseAIToolsOptions, type UseAIToolsReturn, type UseAgentOptions, type UseAgentReturn, type UseChatConfig, type UseChatReturn, type UseKnowledgeBaseConfig, type UseSuggestionsOptions, type UseSuggestionsReturn, type UseToolConfig, type UseToolExecutorReturn, type UseToolWithSchemaConfig, createPermissionStorage, createReactChat, createReactChatState, createSessionPermissionCache, formatKnowledgeResultsForAI, initialAgentLoopState, searchKnowledgeBase, useAIAction, useAIActions, useAIContext, useAIContexts, useAITools, useAgent, useCapabilities, useChat, useCopilot, useDevLogger, useFeatureSupport, useKnowledgeBase, useSuggestions, useSupportedMediaTypes, useTool, useToolExecutor, useToolWithSchema, useTools, useToolsWithSchema };
|
|
2212
|
+
export { type AIContextItem, AbstractAgentLoop, AbstractChat, ActionDefinition, type AgentLoopActions, type AgentLoopCallbacks, type AgentLoopState, AsyncThreadStorageAdapter, type CapabilitiesResponse, CapturedContext, type ChatActions, type ChatCallbacks, type ChatConfig, type ChatState, type ChatStatus, type ToolExecution as ChatToolExecution, type ToolResponse as ChatToolResponse, type CombinedChatState, CopilotConfig, type CopilotContextValue, CopilotProvider, type CopilotProviderProps, type AgentLoopState$1 as CoreAgentLoopState, type ChatState$1 as CoreChatState, type DevLoggerState, IntentDetectionResult, type KnowledgeBaseConfig, type KnowledgeBaseResult, type KnowledgeBaseSearchResponse, LLMConfig, Message, PermissionLevel, PermissionStorageAdapter, PermissionStorageConfig, type ProviderCapabilities, ReactChat, type ReactChatConfig, ReactChatState, ReactThreadManager, type ReactThreadManagerConfig, ReactThreadManagerState, type ServerAdapterConfig, Source, type Suggestion, Thread, ThreadData, ToolConsentRequest, ToolConsentResponse, ToolContext, ToolDefinition, ToolExecution$1 as ToolExecution, ToolResponse$1 as ToolResponse, ToolType, type ToolsActions, ToolsConfig, type ToolsState, type UIMessage, UnifiedToolCall, type UseAIToolsOptions, type UseAIToolsReturn, type UseAgentOptions, type UseAgentReturn, type UseChatConfig, type UseChatReturn, type UseKnowledgeBaseConfig, type UseSuggestionsOptions, type UseSuggestionsReturn, type UseThreadManagerConfig, type UseThreadManagerReturn, type UseToolConfig, type UseToolExecutorReturn, type UseToolWithSchemaConfig, createPermissionStorage, createReactChat, createReactChatState, createReactThreadManager, createReactThreadManagerState, createServerAdapter, createSessionPermissionCache, formatKnowledgeResultsForAI, initialAgentLoopState, searchKnowledgeBase, useAIAction, useAIActions, useAIContext, useAIContexts, useAITools, useAgent, useCapabilities, useChat, useCopilot, useDevLogger, useFeatureSupport, useKnowledgeBase, useSuggestions, useSupportedMediaTypes, useThreadManager, useTool, useToolExecutor, useToolWithSchema, useTools, useToolsWithSchema };
|
package/dist/react/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AbstractAgentLoop, AbstractChat, CopilotProvider, ReactChat, ReactChatState, createPermissionStorage, createReactChat, createReactChatState, createSessionPermissionCache, formatKnowledgeResultsForAI, initialAgentLoopState, searchKnowledgeBase, useAIAction, useAIActions, useAIContext, useAIContexts, useAITools, useAgent, useCapabilities, useChat, useCopilot, useDevLogger, useFeatureSupport, useKnowledgeBase, useSuggestions, useSupportedMediaTypes, useTool, useToolExecutor, useToolWithSchema, useTools, useToolsWithSchema } from '../chunk-
|
|
2
|
-
export { generateSuggestionReason } from '../chunk-
|
|
1
|
+
export { AbstractAgentLoop, AbstractChat, CopilotProvider, ReactChat, ReactChatState, ReactThreadManager, ReactThreadManagerState, createPermissionStorage, createReactChat, createReactChatState, createReactThreadManager, createReactThreadManagerState, createSessionPermissionCache, formatKnowledgeResultsForAI, initialAgentLoopState, searchKnowledgeBase, useAIAction, useAIActions, useAIContext, useAIContexts, useAITools, useAgent, useCapabilities, useChat, useCopilot, useDevLogger, useFeatureSupport, useKnowledgeBase, useSuggestions, useSupportedMediaTypes, useThreadManager, useTool, useToolExecutor, useToolWithSchema, useTools, useToolsWithSchema } from '../chunk-XAVZZVUL.js';
|
|
2
|
+
export { createLocalStorageAdapter, createMemoryAdapter, createServerAdapter, generateSuggestionReason } from '../chunk-QSEGNATZ.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|