@yourgpt/copilot-sdk 2.5.1-beta.0 → 2.5.2-alpha.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.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunk5EGBIQYS_cjs = require('../chunk-5EGBIQYS.cjs');
4
- var chunkZYLHGNIG_cjs = require('../chunk-ZYLHGNIG.cjs');
4
+ var chunkGW5ZZHJ7_cjs = require('../chunk-GW5ZZHJ7.cjs');
5
5
  require('../chunk-7GWEW2DU.cjs');
6
6
  require('../chunk-JGPDQDY4.cjs');
7
7
  require('../chunk-BJYA5NDL.cjs');
@@ -530,7 +530,7 @@ function useGenerativeUI(config = {}) {
530
530
  const toolName = config.name ?? "render_ui";
531
531
  const configRef = React__namespace.useRef(config);
532
532
  configRef.current = config;
533
- chunkZYLHGNIG_cjs.useTool({
533
+ chunkGW5ZZHJ7_cjs.useTool({
534
534
  name: toolName,
535
535
  description: "Renders a rich UI component inline in the chat. Handled automatically by the SDK.",
536
536
  inputSchema: RENDER_UI_SCHEMA,
@@ -1,5 +1,5 @@
1
1
  import { cn, DotsLoader } from '../chunk-TXQ37MAO.js';
2
- import { useTool } from '../chunk-JPUKXFR4.js';
2
+ import { useTool } from '../chunk-37HN4F6S.js';
3
3
  import '../chunk-J5D3AZF6.js';
4
4
  import '../chunk-EWVQWTNV.js';
5
5
  import '../chunk-VNLLW3ZI.js';
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk6R63NBNP_cjs = require('../chunk-6R63NBNP.cjs');
4
- var chunkZYLHGNIG_cjs = require('../chunk-ZYLHGNIG.cjs');
3
+ var chunk4PL7TK42_cjs = require('../chunk-4PL7TK42.cjs');
4
+ var chunkGW5ZZHJ7_cjs = require('../chunk-GW5ZZHJ7.cjs');
5
5
  var chunk7GWEW2DU_cjs = require('../chunk-7GWEW2DU.cjs');
6
6
  require('../chunk-JGPDQDY4.cjs');
7
7
  require('../chunk-BJYA5NDL.cjs');
@@ -22,243 +22,243 @@ require('../chunk-JEQ2X3Z6.cjs');
22
22
 
23
23
  Object.defineProperty(exports, "ReactChat", {
24
24
  enumerable: true,
25
- get: function () { return chunk6R63NBNP_cjs.ReactChat; }
25
+ get: function () { return chunk4PL7TK42_cjs.ReactChat; }
26
26
  });
27
27
  Object.defineProperty(exports, "ReactThreadManager", {
28
28
  enumerable: true,
29
- get: function () { return chunk6R63NBNP_cjs.ReactThreadManager; }
29
+ get: function () { return chunk4PL7TK42_cjs.ReactThreadManager; }
30
30
  });
31
31
  Object.defineProperty(exports, "ReactThreadManagerState", {
32
32
  enumerable: true,
33
- get: function () { return chunk6R63NBNP_cjs.ReactThreadManagerState; }
33
+ get: function () { return chunk4PL7TK42_cjs.ReactThreadManagerState; }
34
34
  });
35
35
  Object.defineProperty(exports, "createMessageIntentHandler", {
36
36
  enumerable: true,
37
- get: function () { return chunk6R63NBNP_cjs.createMessageIntentHandler; }
37
+ get: function () { return chunk4PL7TK42_cjs.createMessageIntentHandler; }
38
38
  });
39
39
  Object.defineProperty(exports, "createPermissionStorage", {
40
40
  enumerable: true,
41
- get: function () { return chunk6R63NBNP_cjs.createPermissionStorage; }
41
+ get: function () { return chunk4PL7TK42_cjs.createPermissionStorage; }
42
42
  });
43
43
  Object.defineProperty(exports, "createReactChat", {
44
44
  enumerable: true,
45
- get: function () { return chunk6R63NBNP_cjs.createReactChat; }
45
+ get: function () { return chunk4PL7TK42_cjs.createReactChat; }
46
46
  });
47
47
  Object.defineProperty(exports, "createReactThreadManager", {
48
48
  enumerable: true,
49
- get: function () { return chunk6R63NBNP_cjs.createReactThreadManager; }
49
+ get: function () { return chunk4PL7TK42_cjs.createReactThreadManager; }
50
50
  });
51
51
  Object.defineProperty(exports, "createReactThreadManagerState", {
52
52
  enumerable: true,
53
- get: function () { return chunk6R63NBNP_cjs.createReactThreadManagerState; }
53
+ get: function () { return chunk4PL7TK42_cjs.createReactThreadManagerState; }
54
54
  });
55
55
  Object.defineProperty(exports, "createSessionPermissionCache", {
56
56
  enumerable: true,
57
- get: function () { return chunk6R63NBNP_cjs.createSessionPermissionCache; }
57
+ get: function () { return chunk4PL7TK42_cjs.createSessionPermissionCache; }
58
58
  });
59
59
  Object.defineProperty(exports, "createToolIntentHandler", {
60
60
  enumerable: true,
61
- get: function () { return chunk6R63NBNP_cjs.createToolIntentHandler; }
61
+ get: function () { return chunk4PL7TK42_cjs.createToolIntentHandler; }
62
62
  });
63
63
  Object.defineProperty(exports, "defineSkill", {
64
64
  enumerable: true,
65
- get: function () { return chunk6R63NBNP_cjs.defineSkill; }
65
+ get: function () { return chunk4PL7TK42_cjs.defineSkill; }
66
66
  });
67
67
  Object.defineProperty(exports, "formatKnowledgeResultsForAI", {
68
68
  enumerable: true,
69
- get: function () { return chunk6R63NBNP_cjs.formatKnowledgeResultsForAI; }
69
+ get: function () { return chunk4PL7TK42_cjs.formatKnowledgeResultsForAI; }
70
70
  });
71
71
  Object.defineProperty(exports, "searchKnowledgeBase", {
72
72
  enumerable: true,
73
- get: function () { return chunk6R63NBNP_cjs.searchKnowledgeBase; }
73
+ get: function () { return chunk4PL7TK42_cjs.searchKnowledgeBase; }
74
74
  });
75
75
  Object.defineProperty(exports, "useAIAction", {
76
76
  enumerable: true,
77
- get: function () { return chunk6R63NBNP_cjs.useAIAction; }
77
+ get: function () { return chunk4PL7TK42_cjs.useAIAction; }
78
78
  });
79
79
  Object.defineProperty(exports, "useAIActions", {
80
80
  enumerable: true,
81
- get: function () { return chunk6R63NBNP_cjs.useAIActions; }
81
+ get: function () { return chunk4PL7TK42_cjs.useAIActions; }
82
82
  });
83
83
  Object.defineProperty(exports, "useAITools", {
84
84
  enumerable: true,
85
- get: function () { return chunk6R63NBNP_cjs.useAITools; }
85
+ get: function () { return chunk4PL7TK42_cjs.useAITools; }
86
86
  });
87
87
  Object.defineProperty(exports, "useAgent", {
88
88
  enumerable: true,
89
- get: function () { return chunk6R63NBNP_cjs.useAgent; }
89
+ get: function () { return chunk4PL7TK42_cjs.useAgent; }
90
90
  });
91
91
  Object.defineProperty(exports, "useCapabilities", {
92
92
  enumerable: true,
93
- get: function () { return chunk6R63NBNP_cjs.useCapabilities; }
93
+ get: function () { return chunk4PL7TK42_cjs.useCapabilities; }
94
94
  });
95
95
  Object.defineProperty(exports, "useChat", {
96
96
  enumerable: true,
97
- get: function () { return chunk6R63NBNP_cjs.useChat; }
97
+ get: function () { return chunk4PL7TK42_cjs.useChat; }
98
98
  });
99
99
  Object.defineProperty(exports, "useContextStats", {
100
100
  enumerable: true,
101
- get: function () { return chunk6R63NBNP_cjs.useContextStats; }
101
+ get: function () { return chunk4PL7TK42_cjs.useContextStats; }
102
102
  });
103
103
  Object.defineProperty(exports, "useCopilotEvent", {
104
104
  enumerable: true,
105
- get: function () { return chunk6R63NBNP_cjs.useCopilotEvent; }
105
+ get: function () { return chunk4PL7TK42_cjs.useCopilotEvent; }
106
106
  });
107
107
  Object.defineProperty(exports, "useDevLogger", {
108
108
  enumerable: true,
109
- get: function () { return chunk6R63NBNP_cjs.useDevLogger; }
109
+ get: function () { return chunk4PL7TK42_cjs.useDevLogger; }
110
110
  });
111
111
  Object.defineProperty(exports, "useFeatureSupport", {
112
112
  enumerable: true,
113
- get: function () { return chunk6R63NBNP_cjs.useFeatureSupport; }
113
+ get: function () { return chunk4PL7TK42_cjs.useFeatureSupport; }
114
114
  });
115
115
  Object.defineProperty(exports, "useKnowledgeBase", {
116
116
  enumerable: true,
117
- get: function () { return chunk6R63NBNP_cjs.useKnowledgeBase; }
117
+ get: function () { return chunk4PL7TK42_cjs.useKnowledgeBase; }
118
118
  });
119
119
  Object.defineProperty(exports, "useMCPUIIntents", {
120
120
  enumerable: true,
121
- get: function () { return chunk6R63NBNP_cjs.useMCPUIIntents; }
121
+ get: function () { return chunk4PL7TK42_cjs.useMCPUIIntents; }
122
122
  });
123
123
  Object.defineProperty(exports, "useMessageCheckpoints", {
124
124
  enumerable: true,
125
- get: function () { return chunk6R63NBNP_cjs.useMessageCheckpoints; }
125
+ get: function () { return chunk4PL7TK42_cjs.useMessageCheckpoints; }
126
126
  });
127
127
  Object.defineProperty(exports, "useMessageMeta", {
128
128
  enumerable: true,
129
- get: function () { return chunk6R63NBNP_cjs.useMessageMeta; }
129
+ get: function () { return chunk4PL7TK42_cjs.useMessageMeta; }
130
130
  });
131
131
  Object.defineProperty(exports, "useSkill", {
132
132
  enumerable: true,
133
- get: function () { return chunk6R63NBNP_cjs.useSkill; }
133
+ get: function () { return chunk4PL7TK42_cjs.useSkill; }
134
134
  });
135
135
  Object.defineProperty(exports, "useSkillStatus", {
136
136
  enumerable: true,
137
- get: function () { return chunk6R63NBNP_cjs.useSkillStatus; }
137
+ get: function () { return chunk4PL7TK42_cjs.useSkillStatus; }
138
138
  });
139
139
  Object.defineProperty(exports, "useSuggestions", {
140
140
  enumerable: true,
141
- get: function () { return chunk6R63NBNP_cjs.useSuggestions; }
141
+ get: function () { return chunk4PL7TK42_cjs.useSuggestions; }
142
142
  });
143
143
  Object.defineProperty(exports, "useSupportedMediaTypes", {
144
144
  enumerable: true,
145
- get: function () { return chunk6R63NBNP_cjs.useSupportedMediaTypes; }
145
+ get: function () { return chunk4PL7TK42_cjs.useSupportedMediaTypes; }
146
146
  });
147
147
  Object.defineProperty(exports, "useThread", {
148
148
  enumerable: true,
149
- get: function () { return chunk6R63NBNP_cjs.useThread; }
149
+ get: function () { return chunk4PL7TK42_cjs.useThread; }
150
150
  });
151
151
  Object.defineProperty(exports, "useThreadManager", {
152
152
  enumerable: true,
153
- get: function () { return chunk6R63NBNP_cjs.useThreadManager; }
153
+ get: function () { return chunk4PL7TK42_cjs.useThreadManager; }
154
154
  });
155
155
  Object.defineProperty(exports, "useToolExecutor", {
156
156
  enumerable: true,
157
- get: function () { return chunk6R63NBNP_cjs.useToolExecutor; }
157
+ get: function () { return chunk4PL7TK42_cjs.useToolExecutor; }
158
158
  });
159
159
  Object.defineProperty(exports, "useToolWithSchema", {
160
160
  enumerable: true,
161
- get: function () { return chunk6R63NBNP_cjs.useToolWithSchema; }
161
+ get: function () { return chunk4PL7TK42_cjs.useToolWithSchema; }
162
162
  });
163
163
  Object.defineProperty(exports, "useToolsWithSchema", {
164
164
  enumerable: true,
165
- get: function () { return chunk6R63NBNP_cjs.useToolsWithSchema; }
165
+ get: function () { return chunk4PL7TK42_cjs.useToolsWithSchema; }
166
166
  });
167
167
  Object.defineProperty(exports, "AbstractAgentLoop", {
168
168
  enumerable: true,
169
- get: function () { return chunkZYLHGNIG_cjs.AbstractAgentLoop; }
169
+ get: function () { return chunkGW5ZZHJ7_cjs.AbstractAgentLoop; }
170
170
  });
171
171
  Object.defineProperty(exports, "AbstractChat", {
172
172
  enumerable: true,
173
- get: function () { return chunkZYLHGNIG_cjs.AbstractChat; }
173
+ get: function () { return chunkGW5ZZHJ7_cjs.AbstractChat; }
174
174
  });
175
175
  Object.defineProperty(exports, "CopilotProvider", {
176
176
  enumerable: true,
177
- get: function () { return chunkZYLHGNIG_cjs.CopilotProvider; }
177
+ get: function () { return chunkGW5ZZHJ7_cjs.CopilotProvider; }
178
178
  });
179
179
  Object.defineProperty(exports, "MessageHistoryContext", {
180
180
  enumerable: true,
181
- get: function () { return chunkZYLHGNIG_cjs.MessageHistoryContext; }
181
+ get: function () { return chunkGW5ZZHJ7_cjs.MessageHistoryContext; }
182
182
  });
183
183
  Object.defineProperty(exports, "MessageTree", {
184
184
  enumerable: true,
185
- get: function () { return chunkZYLHGNIG_cjs.MessageTree; }
185
+ get: function () { return chunkGW5ZZHJ7_cjs.MessageTree; }
186
186
  });
187
187
  Object.defineProperty(exports, "ReactChatState", {
188
188
  enumerable: true,
189
- get: function () { return chunkZYLHGNIG_cjs.ReactChatState; }
189
+ get: function () { return chunkGW5ZZHJ7_cjs.ReactChatState; }
190
190
  });
191
191
  Object.defineProperty(exports, "SkillProvider", {
192
192
  enumerable: true,
193
- get: function () { return chunkZYLHGNIG_cjs.SkillProvider; }
193
+ get: function () { return chunkGW5ZZHJ7_cjs.SkillProvider; }
194
194
  });
195
195
  Object.defineProperty(exports, "createReactChatState", {
196
196
  enumerable: true,
197
- get: function () { return chunkZYLHGNIG_cjs.createReactChatState; }
197
+ get: function () { return chunkGW5ZZHJ7_cjs.createReactChatState; }
198
198
  });
199
199
  Object.defineProperty(exports, "defaultMessageHistoryConfig", {
200
200
  enumerable: true,
201
- get: function () { return chunkZYLHGNIG_cjs.defaultMessageHistoryConfig; }
201
+ get: function () { return chunkGW5ZZHJ7_cjs.defaultMessageHistoryConfig; }
202
202
  });
203
203
  Object.defineProperty(exports, "initialAgentLoopState", {
204
204
  enumerable: true,
205
- get: function () { return chunkZYLHGNIG_cjs.initialAgentLoopState; }
205
+ get: function () { return chunkGW5ZZHJ7_cjs.initialAgentLoopState; }
206
206
  });
207
207
  Object.defineProperty(exports, "isCompactionMarker", {
208
208
  enumerable: true,
209
- get: function () { return chunkZYLHGNIG_cjs.isCompactionMarker; }
209
+ get: function () { return chunkGW5ZZHJ7_cjs.isCompactionMarker; }
210
210
  });
211
211
  Object.defineProperty(exports, "keepToolPairsAtomic", {
212
212
  enumerable: true,
213
- get: function () { return chunkZYLHGNIG_cjs.keepToolPairsAtomic; }
213
+ get: function () { return chunkGW5ZZHJ7_cjs.keepToolPairsAtomic; }
214
214
  });
215
215
  Object.defineProperty(exports, "toDisplayMessage", {
216
216
  enumerable: true,
217
- get: function () { return chunkZYLHGNIG_cjs.toDisplayMessage; }
217
+ get: function () { return chunkGW5ZZHJ7_cjs.toDisplayMessage; }
218
218
  });
219
219
  Object.defineProperty(exports, "toLLMMessage", {
220
220
  enumerable: true,
221
- get: function () { return chunkZYLHGNIG_cjs.toLLMMessage; }
221
+ get: function () { return chunkGW5ZZHJ7_cjs.toLLMMessage; }
222
222
  });
223
223
  Object.defineProperty(exports, "toLLMMessages", {
224
224
  enumerable: true,
225
- get: function () { return chunkZYLHGNIG_cjs.toLLMMessages; }
225
+ get: function () { return chunkGW5ZZHJ7_cjs.toLLMMessages; }
226
226
  });
227
227
  Object.defineProperty(exports, "useAIContext", {
228
228
  enumerable: true,
229
- get: function () { return chunkZYLHGNIG_cjs.useAIContext; }
229
+ get: function () { return chunkGW5ZZHJ7_cjs.useAIContext; }
230
230
  });
231
231
  Object.defineProperty(exports, "useAIContexts", {
232
232
  enumerable: true,
233
- get: function () { return chunkZYLHGNIG_cjs.useAIContexts; }
233
+ get: function () { return chunkGW5ZZHJ7_cjs.useAIContexts; }
234
234
  });
235
235
  Object.defineProperty(exports, "useCopilot", {
236
236
  enumerable: true,
237
- get: function () { return chunkZYLHGNIG_cjs.useCopilot; }
237
+ get: function () { return chunkGW5ZZHJ7_cjs.useCopilot; }
238
238
  });
239
239
  Object.defineProperty(exports, "useMCPClient", {
240
240
  enumerable: true,
241
- get: function () { return chunkZYLHGNIG_cjs.useMCPClient; }
241
+ get: function () { return chunkGW5ZZHJ7_cjs.useMCPClient; }
242
242
  });
243
243
  Object.defineProperty(exports, "useMCPTools", {
244
244
  enumerable: true,
245
- get: function () { return chunkZYLHGNIG_cjs.useMCPTools; }
245
+ get: function () { return chunkGW5ZZHJ7_cjs.useMCPTools; }
246
246
  });
247
247
  Object.defineProperty(exports, "useMessageHistory", {
248
248
  enumerable: true,
249
- get: function () { return chunkZYLHGNIG_cjs.useMessageHistory; }
249
+ get: function () { return chunkGW5ZZHJ7_cjs.useMessageHistory; }
250
250
  });
251
251
  Object.defineProperty(exports, "useMessageHistoryContext", {
252
252
  enumerable: true,
253
- get: function () { return chunkZYLHGNIG_cjs.useMessageHistoryContext; }
253
+ get: function () { return chunkGW5ZZHJ7_cjs.useMessageHistoryContext; }
254
254
  });
255
255
  Object.defineProperty(exports, "useTool", {
256
256
  enumerable: true,
257
- get: function () { return chunkZYLHGNIG_cjs.useTool; }
257
+ get: function () { return chunkGW5ZZHJ7_cjs.useTool; }
258
258
  });
259
259
  Object.defineProperty(exports, "useTools", {
260
260
  enumerable: true,
261
- get: function () { return chunkZYLHGNIG_cjs.useTools; }
261
+ get: function () { return chunkGW5ZZHJ7_cjs.useTools; }
262
262
  });
263
263
  Object.defineProperty(exports, "createLocalStorageAdapter", {
264
264
  enumerable: true,
@@ -665,6 +665,13 @@ interface AgentLoopConfig {
665
665
  tools?: ToolDefinition[];
666
666
  /** Max tool executions to keep in memory (default: 100). Oldest are pruned. */
667
667
  maxExecutionHistory?: number;
668
+ /**
669
+ * Returns the current thread id for tool handler context. Called once per
670
+ * tool invocation. Needed by consumers that need to scope per-tool state
671
+ * (e.g. per-thread browser-tab pinning in the Chrome extension). When
672
+ * omitted, `context.threadId` is undefined in handlers.
673
+ */
674
+ getThreadId?: () => string | undefined;
668
675
  }
669
676
  /**
670
677
  * Agent loop callbacks
@@ -808,6 +815,8 @@ declare class AbstractChat<T extends UIMessage = UIMessage> {
808
815
  get status(): ChatStatus$1;
809
816
  get error(): Error | undefined;
810
817
  get isStreaming(): boolean;
818
+ /** The thread id currently associated with this chat, if any. */
819
+ get threadId(): string | undefined;
811
820
  /**
812
821
  * Check if a request is currently in progress
813
822
  */
@@ -1516,6 +1525,23 @@ interface CopilotProviderProps {
1516
1525
  * Only inline skills (source.type === "inline") are supported client-side.
1517
1526
  */
1518
1527
  skills?: SkillDefinition[];
1528
+ /**
1529
+ * Allow multiple threads to stream concurrently. When enabled, switching away
1530
+ * from a thread that is still generating does NOT cancel its request — it
1531
+ * continues in the background. You can also start a new send on a different
1532
+ * thread while another is still streaming.
1533
+ *
1534
+ * When enabled:
1535
+ * - `useCopilot().messages/status/error` always reflect the ACTIVE thread.
1536
+ * - A new `busyThreadIds` set reflects every thread currently streaming.
1537
+ * - The provider maintains one `ReactChatWithTools` instance per thread.
1538
+ *
1539
+ * When `onCreateSession` is provided, it may be called concurrently for
1540
+ * different threads — ensure each call produces a distinct session id.
1541
+ *
1542
+ * @default false
1543
+ */
1544
+ concurrentThreads?: boolean;
1519
1545
  }
1520
1546
  type StreamChunkWithMessageId = StreamChunk & {
1521
1547
  messageId?: string;
@@ -1588,8 +1614,16 @@ interface CopilotContextValue {
1588
1614
  * Switch to a different thread (or start a new one).
1589
1615
  * Pass the session/thread ID from persistence to reuse it (no new session call),
1590
1616
  * or null to start a fresh thread (new session created on first sendMessage).
1591
- */
1592
- setActiveThread: (id: string | null) => void;
1617
+ *
1618
+ * When `concurrentThreads` is enabled on the provider, `opts.hydrateMessages`
1619
+ * is applied when the target instance is being created fresh (not yet
1620
+ * streaming). It is ignored if the instance already exists (which would
1621
+ * mean a stream is in-flight or completed) to avoid clobbering state.
1622
+ */
1623
+ setActiveThread: (id: string | null, opts?: {
1624
+ hydrateMessages?: UIMessage[];
1625
+ hydrateActiveLeafId?: string;
1626
+ }) => void;
1593
1627
  /**
1594
1628
  * Force a new session to be created on the next sendMessage.
1595
1629
  * Call when the current session has expired or credits are exhausted.
@@ -1621,6 +1655,44 @@ interface CopilotContextValue {
1621
1655
  * Use useMessageMeta(messageId) for the hook API.
1622
1656
  */
1623
1657
  messageMeta: MessageMetaStore;
1658
+ /**
1659
+ * Whether concurrent-thread streaming is enabled (via the `concurrentThreads`
1660
+ * prop on CopilotProvider). When false, the provider uses a single chat
1661
+ * instance and inactive threads cannot stream. When true, each thread has
1662
+ * its own instance and streams in the background on switch.
1663
+ */
1664
+ concurrentThreads: boolean;
1665
+ /**
1666
+ * The set of thread IDs that currently have an in-flight request
1667
+ * (status "submitted" or "streaming"). Always empty when `concurrentThreads`
1668
+ * is false. UI can use this to render per-thread busy indicators in a
1669
+ * thread picker.
1670
+ */
1671
+ busyThreadIds: ReadonlySet<string>;
1672
+ /**
1673
+ * Reactive map of per-thread pending tool approvals. Key = thread id,
1674
+ * value = ToolExecutions whose approvalStatus is "required". Empty when
1675
+ * `concurrentThreads` is false. UI can use this to light up indicators
1676
+ * on background threads that are blocked waiting for the user to approve
1677
+ * or reject a tool — the approval card only renders on the active thread,
1678
+ * so without this, a background thread's block is invisible.
1679
+ */
1680
+ pendingApprovalsByThread: ReadonlyMap<string, ToolExecution[]>;
1681
+ /**
1682
+ * Dispose the chat instance backing a given thread ID and remove it from
1683
+ * the registry. Aborts its in-flight stream if any. Call this when a
1684
+ * thread is deleted so its background stream doesn't keep running.
1685
+ * No-op when `concurrentThreads` is false.
1686
+ */
1687
+ disposeThreadInstance: (threadId: string) => void;
1688
+ /**
1689
+ * Commit a locally-generated thread id to the currently-active pending
1690
+ * chat instance. Used by persistence hooks (e.g. useInternalThreadManager)
1691
+ * to make a just-started thread visible in the picker immediately, without
1692
+ * waiting for the server to assign its session id. No-op when
1693
+ * `concurrentThreads` is false or the active instance is not a pending slot.
1694
+ */
1695
+ assignLocalThreadId: (localId: string) => void;
1624
1696
  }
1625
1697
  declare function useCopilot(): CopilotContextValue;
1626
1698
  declare function CopilotProvider(props: CopilotProviderProps): react_jsx_runtime.JSX.Element;
@@ -665,6 +665,13 @@ interface AgentLoopConfig {
665
665
  tools?: ToolDefinition[];
666
666
  /** Max tool executions to keep in memory (default: 100). Oldest are pruned. */
667
667
  maxExecutionHistory?: number;
668
+ /**
669
+ * Returns the current thread id for tool handler context. Called once per
670
+ * tool invocation. Needed by consumers that need to scope per-tool state
671
+ * (e.g. per-thread browser-tab pinning in the Chrome extension). When
672
+ * omitted, `context.threadId` is undefined in handlers.
673
+ */
674
+ getThreadId?: () => string | undefined;
668
675
  }
669
676
  /**
670
677
  * Agent loop callbacks
@@ -808,6 +815,8 @@ declare class AbstractChat<T extends UIMessage = UIMessage> {
808
815
  get status(): ChatStatus$1;
809
816
  get error(): Error | undefined;
810
817
  get isStreaming(): boolean;
818
+ /** The thread id currently associated with this chat, if any. */
819
+ get threadId(): string | undefined;
811
820
  /**
812
821
  * Check if a request is currently in progress
813
822
  */
@@ -1516,6 +1525,23 @@ interface CopilotProviderProps {
1516
1525
  * Only inline skills (source.type === "inline") are supported client-side.
1517
1526
  */
1518
1527
  skills?: SkillDefinition[];
1528
+ /**
1529
+ * Allow multiple threads to stream concurrently. When enabled, switching away
1530
+ * from a thread that is still generating does NOT cancel its request — it
1531
+ * continues in the background. You can also start a new send on a different
1532
+ * thread while another is still streaming.
1533
+ *
1534
+ * When enabled:
1535
+ * - `useCopilot().messages/status/error` always reflect the ACTIVE thread.
1536
+ * - A new `busyThreadIds` set reflects every thread currently streaming.
1537
+ * - The provider maintains one `ReactChatWithTools` instance per thread.
1538
+ *
1539
+ * When `onCreateSession` is provided, it may be called concurrently for
1540
+ * different threads — ensure each call produces a distinct session id.
1541
+ *
1542
+ * @default false
1543
+ */
1544
+ concurrentThreads?: boolean;
1519
1545
  }
1520
1546
  type StreamChunkWithMessageId = StreamChunk & {
1521
1547
  messageId?: string;
@@ -1588,8 +1614,16 @@ interface CopilotContextValue {
1588
1614
  * Switch to a different thread (or start a new one).
1589
1615
  * Pass the session/thread ID from persistence to reuse it (no new session call),
1590
1616
  * or null to start a fresh thread (new session created on first sendMessage).
1591
- */
1592
- setActiveThread: (id: string | null) => void;
1617
+ *
1618
+ * When `concurrentThreads` is enabled on the provider, `opts.hydrateMessages`
1619
+ * is applied when the target instance is being created fresh (not yet
1620
+ * streaming). It is ignored if the instance already exists (which would
1621
+ * mean a stream is in-flight or completed) to avoid clobbering state.
1622
+ */
1623
+ setActiveThread: (id: string | null, opts?: {
1624
+ hydrateMessages?: UIMessage[];
1625
+ hydrateActiveLeafId?: string;
1626
+ }) => void;
1593
1627
  /**
1594
1628
  * Force a new session to be created on the next sendMessage.
1595
1629
  * Call when the current session has expired or credits are exhausted.
@@ -1621,6 +1655,44 @@ interface CopilotContextValue {
1621
1655
  * Use useMessageMeta(messageId) for the hook API.
1622
1656
  */
1623
1657
  messageMeta: MessageMetaStore;
1658
+ /**
1659
+ * Whether concurrent-thread streaming is enabled (via the `concurrentThreads`
1660
+ * prop on CopilotProvider). When false, the provider uses a single chat
1661
+ * instance and inactive threads cannot stream. When true, each thread has
1662
+ * its own instance and streams in the background on switch.
1663
+ */
1664
+ concurrentThreads: boolean;
1665
+ /**
1666
+ * The set of thread IDs that currently have an in-flight request
1667
+ * (status "submitted" or "streaming"). Always empty when `concurrentThreads`
1668
+ * is false. UI can use this to render per-thread busy indicators in a
1669
+ * thread picker.
1670
+ */
1671
+ busyThreadIds: ReadonlySet<string>;
1672
+ /**
1673
+ * Reactive map of per-thread pending tool approvals. Key = thread id,
1674
+ * value = ToolExecutions whose approvalStatus is "required". Empty when
1675
+ * `concurrentThreads` is false. UI can use this to light up indicators
1676
+ * on background threads that are blocked waiting for the user to approve
1677
+ * or reject a tool — the approval card only renders on the active thread,
1678
+ * so without this, a background thread's block is invisible.
1679
+ */
1680
+ pendingApprovalsByThread: ReadonlyMap<string, ToolExecution[]>;
1681
+ /**
1682
+ * Dispose the chat instance backing a given thread ID and remove it from
1683
+ * the registry. Aborts its in-flight stream if any. Call this when a
1684
+ * thread is deleted so its background stream doesn't keep running.
1685
+ * No-op when `concurrentThreads` is false.
1686
+ */
1687
+ disposeThreadInstance: (threadId: string) => void;
1688
+ /**
1689
+ * Commit a locally-generated thread id to the currently-active pending
1690
+ * chat instance. Used by persistence hooks (e.g. useInternalThreadManager)
1691
+ * to make a just-started thread visible in the picker immediately, without
1692
+ * waiting for the server to assign its session id. No-op when
1693
+ * `concurrentThreads` is false or the active instance is not a pending slot.
1694
+ */
1695
+ assignLocalThreadId: (localId: string) => void;
1624
1696
  }
1625
1697
  declare function useCopilot(): CopilotContextValue;
1626
1698
  declare function CopilotProvider(props: CopilotProviderProps): react_jsx_runtime.JSX.Element;
@@ -1,5 +1,5 @@
1
- export { ReactChat, ReactThreadManager, ReactThreadManagerState, createMessageIntentHandler, createPermissionStorage, createReactChat, createReactThreadManager, createReactThreadManagerState, createSessionPermissionCache, createToolIntentHandler, defineSkill, formatKnowledgeResultsForAI, searchKnowledgeBase, useAIAction, useAIActions, useAITools, useAgent, useCapabilities, useChat, useContextStats, useCopilotEvent, useDevLogger, useFeatureSupport, useKnowledgeBase, useMCPUIIntents, useMessageCheckpoints, useMessageMeta, useSkill, useSkillStatus, useSuggestions, useSupportedMediaTypes, useThread, useThreadManager, useToolExecutor, useToolWithSchema, useToolsWithSchema } from '../chunk-YYLTWY5R.js';
2
- export { AbstractAgentLoop, AbstractChat, CopilotProvider, MessageHistoryContext, MessageTree, ReactChatState, SkillProvider, createReactChatState, defaultMessageHistoryConfig, initialAgentLoopState, isCompactionMarker, keepToolPairsAtomic, toDisplayMessage, toLLMMessage, toLLMMessages, useAIContext, useAIContexts, useCopilot, useMCPClient, useMCPTools, useMessageHistory, useMessageHistoryContext, useTool, useTools } from '../chunk-JPUKXFR4.js';
1
+ export { ReactChat, ReactThreadManager, ReactThreadManagerState, createMessageIntentHandler, createPermissionStorage, createReactChat, createReactThreadManager, createReactThreadManagerState, createSessionPermissionCache, createToolIntentHandler, defineSkill, formatKnowledgeResultsForAI, searchKnowledgeBase, useAIAction, useAIActions, useAITools, useAgent, useCapabilities, useChat, useContextStats, useCopilotEvent, useDevLogger, useFeatureSupport, useKnowledgeBase, useMCPUIIntents, useMessageCheckpoints, useMessageMeta, useSkill, useSkillStatus, useSuggestions, useSupportedMediaTypes, useThread, useThreadManager, useToolExecutor, useToolWithSchema, useToolsWithSchema } from '../chunk-VHJ46HKC.js';
2
+ export { AbstractAgentLoop, AbstractChat, CopilotProvider, MessageHistoryContext, MessageTree, ReactChatState, SkillProvider, createReactChatState, defaultMessageHistoryConfig, initialAgentLoopState, isCompactionMarker, keepToolPairsAtomic, toDisplayMessage, toLLMMessage, toLLMMessages, useAIContext, useAIContexts, useCopilot, useMCPClient, useMCPTools, useMessageHistory, useMessageHistoryContext, useTool, useTools } from '../chunk-37HN4F6S.js';
3
3
  export { createLocalStorageAdapter, createMemoryAdapter, createServerAdapter, generateSuggestionReason } from '../chunk-J5D3AZF6.js';
4
4
  import '../chunk-EWVQWTNV.js';
5
5
  import '../chunk-VNLLW3ZI.js';