@copilotkit/react-core 1.62.2 → 1.63.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/dist/{copilotkit-Cga6AHO0.d.cts → copilotkit-BHs-vx6l.d.cts} +285 -6
- package/dist/copilotkit-BHs-vx6l.d.cts.map +1 -0
- package/dist/{copilotkit-CmcMFc8o.mjs → copilotkit-BLh58_Tt.mjs} +161 -27
- package/dist/copilotkit-BLh58_Tt.mjs.map +1 -0
- package/dist/{copilotkit-DnLpJ2Cl.d.mts → copilotkit-CN_LykOC.d.mts} +285 -6
- package/dist/copilotkit-CN_LykOC.d.mts.map +1 -0
- package/dist/{copilotkit-lHheGQWt.cjs → copilotkit-nu7NwzH6.cjs} +201 -25
- package/dist/copilotkit-nu7NwzH6.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +62 -15
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +18 -14
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +16 -2
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +17 -3
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +19 -15
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +8 -1
- package/dist/v2/index.css +1 -1
- package/dist/v2/index.d.cts +2 -3
- package/dist/v2/index.d.mts +2 -3
- package/dist/v2/index.mjs +2 -2
- package/dist/v2/index.umd.js +165 -24
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +8 -8
- package/dist/copilotkit-Cga6AHO0.d.cts.map +0 -1
- package/dist/copilotkit-CmcMFc8o.mjs.map +0 -1
- package/dist/copilotkit-DnLpJ2Cl.d.mts.map +0 -1
- package/dist/copilotkit-lHheGQWt.cjs.map +0 -1
package/dist/v2/index.umd.js
CHANGED
|
@@ -1815,6 +1815,34 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
1815
1815
|
|
|
1816
1816
|
//#endregion
|
|
1817
1817
|
//#region src/v2/components/MCPAppsActivityRenderer.tsx
|
|
1818
|
+
/**
|
|
1819
|
+
* Run an MCP app `ui/message` follow-up, scoped to the thread it was enqueued
|
|
1820
|
+
* for (issue #5819).
|
|
1821
|
+
*
|
|
1822
|
+
* The MCP request queue delays follow-up work until the agent is idle. There is
|
|
1823
|
+
* a single shared registry agent per id, and switching threads overwrites its
|
|
1824
|
+
* `threadId`/`messages` in place. So if the host switches threads while a
|
|
1825
|
+
* follow-up is queued, running it now would execute against — and stream into —
|
|
1826
|
+
* the now-foreground thread.
|
|
1827
|
+
*
|
|
1828
|
+
* - **Same thread** (the common case): run on the shared agent, unchanged.
|
|
1829
|
+
* - **Thread changed**: the shared agent has moved on, so the follow-up can no
|
|
1830
|
+
* longer run in its originating thread's context. Drop it rather than leak it
|
|
1831
|
+
* into the current thread. (The MCP app already received its `ui/message` ack
|
|
1832
|
+
* at enqueue time; only the optional agent turn is skipped.)
|
|
1833
|
+
*
|
|
1834
|
+
* @internal exported for testing.
|
|
1835
|
+
*/
|
|
1836
|
+
async function ɵrunMcpFollowUp({ host, agent, capturedThreadId }) {
|
|
1837
|
+
const currentThreadId = agent.threadId || "default";
|
|
1838
|
+
const originThreadId = capturedThreadId || "default";
|
|
1839
|
+
if (currentThreadId === originThreadId) return host.runAgent({ agent });
|
|
1840
|
+
console.warn(`[MCPAppsRenderer] ui/message follow-up dropped: the thread changed (${originThreadId} → ${currentThreadId}) between enqueue and execution, so running it would leak into the now-foreground thread.`);
|
|
1841
|
+
return {
|
|
1842
|
+
result: void 0,
|
|
1843
|
+
newMessages: []
|
|
1844
|
+
};
|
|
1845
|
+
}
|
|
1818
1846
|
const PROTOCOL_VERSION = "2025-06-18";
|
|
1819
1847
|
function buildSandboxHTML(extraCspDomains) {
|
|
1820
1848
|
const baseScriptSrc = "'self' 'wasm-unsafe-eval' 'unsafe-inline' 'unsafe-eval' blob: data: http://localhost:* https://localhost:*";
|
|
@@ -2137,7 +2165,14 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2137
2165
|
content: textContent
|
|
2138
2166
|
});
|
|
2139
2167
|
sendResponse(msg.id, { isError: false });
|
|
2140
|
-
if ((params.followUp ?? role === "user") && textContent)
|
|
2168
|
+
if ((params.followUp ?? role === "user") && textContent) {
|
|
2169
|
+
const capturedThreadId = currentAgent.threadId || "default";
|
|
2170
|
+
mcpAppsRequestQueue.enqueue(currentAgent, () => ɵrunMcpFollowUp({
|
|
2171
|
+
host: copilotkit,
|
|
2172
|
+
agent: currentAgent,
|
|
2173
|
+
capturedThreadId
|
|
2174
|
+
})).catch((err) => console.error("[MCPAppsRenderer] ui/message agent run failed:", err));
|
|
2175
|
+
}
|
|
2141
2176
|
} catch (err) {
|
|
2142
2177
|
console.error("[MCPAppsRenderer] ui/message error:", err);
|
|
2143
2178
|
sendResponse(msg.id, { isError: true });
|
|
@@ -3620,6 +3655,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3620
3655
|
if (copilotkitRef.current === null) {
|
|
3621
3656
|
copilotkitRef.current = new CopilotKitCoreReact({
|
|
3622
3657
|
runtimeUrl: chatApiEndpoint,
|
|
3658
|
+
deferInitialConnection: true,
|
|
3623
3659
|
runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
|
|
3624
3660
|
headers: mergedHeaders,
|
|
3625
3661
|
credentials,
|
|
@@ -3703,6 +3739,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3703
3739
|
} : properties);
|
|
3704
3740
|
copilotkit.setAgents__unsafe_dev_only(mergedAgents);
|
|
3705
3741
|
copilotkit.setDebug(debug);
|
|
3742
|
+
copilotkit.connect();
|
|
3706
3743
|
}, [
|
|
3707
3744
|
copilotkit,
|
|
3708
3745
|
chatApiEndpoint,
|
|
@@ -4367,57 +4404,58 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4367
4404
|
UseAgentUpdate.OnRunStatusChanged
|
|
4368
4405
|
];
|
|
4369
4406
|
function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
4370
|
-
|
|
4407
|
+
const chatConfig = useCopilotChatConfiguration();
|
|
4408
|
+
const resolvedAgentId = agentId ?? chatConfig?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
4371
4409
|
const { copilotkit } = useCopilotKit();
|
|
4372
4410
|
const providerThrottleMs = copilotkit.defaultThrottleMs;
|
|
4373
4411
|
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
4374
4412
|
const updateFlags = (0, react.useMemo)(() => updates ?? ALL_UPDATES, [JSON.stringify(updates)]);
|
|
4375
4413
|
const provisionalAgentCache = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
4376
4414
|
const agent = (0, react.useMemo)(() => {
|
|
4377
|
-
const existing = copilotkit.getAgent(
|
|
4415
|
+
const existing = copilotkit.getAgent(resolvedAgentId);
|
|
4378
4416
|
if (existing) {
|
|
4379
|
-
provisionalAgentCache.current.delete(
|
|
4417
|
+
provisionalAgentCache.current.delete(resolvedAgentId);
|
|
4380
4418
|
return existing;
|
|
4381
4419
|
}
|
|
4382
4420
|
const isRuntimeConfigured = copilotkit.runtimeUrl !== void 0;
|
|
4383
4421
|
const status = copilotkit.runtimeConnectionStatus;
|
|
4384
4422
|
if (isRuntimeConfigured && (status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Disconnected || status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connecting)) {
|
|
4385
|
-
const cached = provisionalAgentCache.current.get(
|
|
4423
|
+
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
4386
4424
|
if (cached) {
|
|
4387
4425
|
copilotkit.applyHeadersToAgent(cached);
|
|
4388
4426
|
return cached;
|
|
4389
4427
|
}
|
|
4390
4428
|
const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
|
|
4391
4429
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
4392
|
-
agentId,
|
|
4430
|
+
agentId: resolvedAgentId,
|
|
4393
4431
|
transport: copilotkit.runtimeTransport,
|
|
4394
4432
|
runtimeMode: "pending"
|
|
4395
4433
|
});
|
|
4396
4434
|
copilotkit.applyHeadersToAgent(provisional);
|
|
4397
|
-
provisionalAgentCache.current.set(
|
|
4435
|
+
provisionalAgentCache.current.set(resolvedAgentId, provisional);
|
|
4398
4436
|
return provisional;
|
|
4399
4437
|
}
|
|
4400
4438
|
if (isRuntimeConfigured && status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Error) {
|
|
4401
|
-
const cached = provisionalAgentCache.current.get(
|
|
4439
|
+
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
4402
4440
|
if (cached) {
|
|
4403
4441
|
copilotkit.applyHeadersToAgent(cached);
|
|
4404
4442
|
return cached;
|
|
4405
4443
|
}
|
|
4406
4444
|
const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
|
|
4407
4445
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
4408
|
-
agentId,
|
|
4446
|
+
agentId: resolvedAgentId,
|
|
4409
4447
|
transport: copilotkit.runtimeTransport,
|
|
4410
4448
|
runtimeMode: "pending"
|
|
4411
4449
|
});
|
|
4412
4450
|
copilotkit.applyHeadersToAgent(provisional);
|
|
4413
|
-
provisionalAgentCache.current.set(
|
|
4451
|
+
provisionalAgentCache.current.set(resolvedAgentId, provisional);
|
|
4414
4452
|
return provisional;
|
|
4415
4453
|
}
|
|
4416
4454
|
const knownAgents = Object.keys(copilotkit.agents ?? {});
|
|
4417
4455
|
const runtimePart = isRuntimeConfigured ? `runtimeUrl=${copilotkit.runtimeUrl}` : "no runtimeUrl";
|
|
4418
|
-
throw new Error(`useAgent: Agent '${
|
|
4456
|
+
throw new Error(`useAgent: Agent '${resolvedAgentId}' not found after runtime sync (${runtimePart}). ` + (knownAgents.length ? `Known agents: [${knownAgents.join(", ")}]` : "No agents registered.") + " Verify your runtime /info and/or agents__unsafe_dev_only.");
|
|
4419
4457
|
}, [
|
|
4420
|
-
|
|
4458
|
+
resolvedAgentId,
|
|
4421
4459
|
copilotkit.agents,
|
|
4422
4460
|
copilotkit.runtimeConnectionStatus,
|
|
4423
4461
|
copilotkit.runtimeUrl,
|
|
@@ -4462,7 +4500,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4462
4500
|
(0, react.useEffect)(() => {
|
|
4463
4501
|
if (agent instanceof _ag_ui_client.HttpAgent) copilotkit.applyHeadersToAgent(agent);
|
|
4464
4502
|
}, [agent, JSON.stringify(copilotkit.headers)]);
|
|
4465
|
-
const chatConfig = useCopilotChatConfiguration();
|
|
4466
4503
|
const configThreadId = chatConfig?.threadId;
|
|
4467
4504
|
const configHasExplicitThreadId = chatConfig?.hasExplicitThreadId;
|
|
4468
4505
|
(0, react.useEffect)(() => {
|
|
@@ -4479,13 +4516,15 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4479
4516
|
//#endregion
|
|
4480
4517
|
//#region src/v2/hooks/use-capabilities.tsx
|
|
4481
4518
|
/**
|
|
4482
|
-
* Returns the capabilities declared by the given agent (or the
|
|
4519
|
+
* Returns the capabilities declared by the given agent (or the agent resolved
|
|
4520
|
+
* from the surrounding chat configuration, falling back to the default agent).
|
|
4483
4521
|
* Capabilities are populated from the runtime `/info` response at connection
|
|
4484
4522
|
* time. The hook reads them synchronously from the agent instance — there is
|
|
4485
4523
|
* no separate loading state, but the value will be `undefined` until the
|
|
4486
4524
|
* runtime handshake completes.
|
|
4487
4525
|
*
|
|
4488
|
-
* @param agentId - Optional agent ID. If omitted,
|
|
4526
|
+
* @param agentId - Optional agent ID. If omitted, inherits the surrounding
|
|
4527
|
+
* chat configuration's agent, falling back to the default agent.
|
|
4489
4528
|
* @returns The agent's capabilities, or `undefined` if the agent doesn't
|
|
4490
4529
|
* declare capabilities.
|
|
4491
4530
|
*/
|
|
@@ -5058,6 +5097,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5058
5097
|
})), [coreThreads]);
|
|
5059
5098
|
const storeIsLoading = useThreadStoreSelector(store, _copilotkit_core.ɵselectThreadsIsLoading);
|
|
5060
5099
|
const storeError = useThreadStoreSelector(store, _copilotkit_core.ɵselectThreadsError);
|
|
5100
|
+
const fetchMoreError = useThreadStoreSelector(store, _copilotkit_core.ɵselectFetchMoreError);
|
|
5061
5101
|
const hasMoreThreads = useThreadStoreSelector(store, _copilotkit_core.ɵselectHasNextPage);
|
|
5062
5102
|
const isFetchingMoreThreads = useThreadStoreSelector(store, _copilotkit_core.ɵselectIsFetchingNextPage);
|
|
5063
5103
|
const isMutating = useThreadStoreSelector(store, _copilotkit_core.ɵselectIsMutating);
|
|
@@ -5163,6 +5203,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5163
5203
|
isLoading,
|
|
5164
5204
|
error,
|
|
5165
5205
|
listError,
|
|
5206
|
+
fetchMoreError,
|
|
5166
5207
|
hasMoreThreads,
|
|
5167
5208
|
isFetchingMoreThreads,
|
|
5168
5209
|
isMutating,
|
|
@@ -5179,6 +5220,70 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5179
5220
|
};
|
|
5180
5221
|
}
|
|
5181
5222
|
|
|
5223
|
+
//#endregion
|
|
5224
|
+
//#region src/v2/hooks/use-memories.tsx
|
|
5225
|
+
function useMemoryStoreSelector(store, selector) {
|
|
5226
|
+
return (0, react.useSyncExternalStore)((0, react.useCallback)((onStoreChange) => {
|
|
5227
|
+
const subscription = store.select(selector).subscribe(onStoreChange);
|
|
5228
|
+
return () => subscription.unsubscribe();
|
|
5229
|
+
}, [store, selector]), () => selector(store.getState()), () => selector(store.getServerState()));
|
|
5230
|
+
}
|
|
5231
|
+
/**
|
|
5232
|
+
* React hook for listing and managing platform memories.
|
|
5233
|
+
*
|
|
5234
|
+
* Reads the memory store owned and wired by `CopilotKitCore`. On mount the
|
|
5235
|
+
* hook exposes the live list plus stable `addMemory` / `updateMemory` /
|
|
5236
|
+
* `removeMemory` / `refresh` callbacks. Mutations are server-authoritative:
|
|
5237
|
+
* each resolves once the platform confirms the operation and rejects with an
|
|
5238
|
+
* `Error` on failure.
|
|
5239
|
+
*
|
|
5240
|
+
* Realtime updates are automatic: the core's memory store opens its own
|
|
5241
|
+
* `user_meta:memories:<joinCode>` channel and applies `memory_metadata` deltas
|
|
5242
|
+
* to the list. You can still call `refresh()` to re-pull the REST snapshot on
|
|
5243
|
+
* demand.
|
|
5244
|
+
*
|
|
5245
|
+
* @returns Memory list state and stable mutation callbacks.
|
|
5246
|
+
*
|
|
5247
|
+
* @example
|
|
5248
|
+
* ```tsx
|
|
5249
|
+
* import { useMemories } from "@copilotkit/react-core";
|
|
5250
|
+
*
|
|
5251
|
+
* function MemoryList() {
|
|
5252
|
+
* const { memories, isLoading, isAvailable, addMemory, removeMemory } =
|
|
5253
|
+
* useMemories();
|
|
5254
|
+
*
|
|
5255
|
+
* if (!isAvailable) return null;
|
|
5256
|
+
* if (isLoading) return <p>Loading…</p>;
|
|
5257
|
+
*
|
|
5258
|
+
* return (
|
|
5259
|
+
* <ul>
|
|
5260
|
+
* {memories.map((m) => (
|
|
5261
|
+
* <li key={m.id}>
|
|
5262
|
+
* {m.content}
|
|
5263
|
+
* <button onClick={() => removeMemory(m.id)}>Delete</button>
|
|
5264
|
+
* </li>
|
|
5265
|
+
* ))}
|
|
5266
|
+
* </ul>
|
|
5267
|
+
* );
|
|
5268
|
+
* }
|
|
5269
|
+
* ```
|
|
5270
|
+
*/
|
|
5271
|
+
function useMemories() {
|
|
5272
|
+
const { copilotkit } = useCopilotKit();
|
|
5273
|
+
const store = copilotkit.getMemoryStore();
|
|
5274
|
+
return {
|
|
5275
|
+
memories: useMemoryStoreSelector(store, _copilotkit_core.ɵselectMemories),
|
|
5276
|
+
isLoading: useMemoryStoreSelector(store, _copilotkit_core.ɵselectMemoriesIsLoading),
|
|
5277
|
+
error: useMemoryStoreSelector(store, _copilotkit_core.ɵselectMemoriesError),
|
|
5278
|
+
isAvailable: useMemoryStoreSelector(store, _copilotkit_core.ɵselectMemoriesAvailable),
|
|
5279
|
+
realtimeStatus: useMemoryStoreSelector(store, _copilotkit_core.ɵselectMemoriesRealtimeStatus),
|
|
5280
|
+
refresh: (0, react.useCallback)(() => store.refresh(), [store]),
|
|
5281
|
+
addMemory: (0, react.useCallback)((input) => store.addMemory(input), [store]),
|
|
5282
|
+
updateMemory: (0, react.useCallback)((id, changes) => store.updateMemory(id, changes), [store]),
|
|
5283
|
+
removeMemory: (0, react.useCallback)((id) => store.removeMemory(id), [store])
|
|
5284
|
+
};
|
|
5285
|
+
}
|
|
5286
|
+
|
|
5182
5287
|
//#endregion
|
|
5183
5288
|
//#region src/v2/lib/record-annotation.ts
|
|
5184
5289
|
/**
|
|
@@ -9040,7 +9145,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9040
9145
|
* during prerender to avoid hydration mismatch).
|
|
9041
9146
|
* - Feeds the element domain data: `threads`, `loading`, `error`,
|
|
9042
9147
|
* `activeThreadId`, `licensed`, fetch-more state.
|
|
9043
|
-
* - Routes the element's
|
|
9148
|
+
* - Routes the element's outbound events to core thread operations
|
|
9044
9149
|
* ({@link useThreads}) and chat-configuration changes.
|
|
9045
9150
|
* - Registers with the surrounding chat configuration so the header
|
|
9046
9151
|
* thread-list launcher appears, and binds the element `open` state to the
|
|
@@ -9067,16 +9172,16 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9067
9172
|
* </CopilotKitProvider>
|
|
9068
9173
|
* ```
|
|
9069
9174
|
*/
|
|
9070
|
-
function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed, licenseUrl, renderRow, label, limit, "data-testid": dataTestId = "copilot-threads-drawer" }) {
|
|
9175
|
+
function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed, licenseUrl, renderRow, label, recentLabel, collapsible, onCollapseChange, limit, "data-testid": dataTestId = "copilot-threads-drawer" }) {
|
|
9071
9176
|
const configuration = useCopilotChatConfiguration();
|
|
9072
9177
|
const { status, checkFeature } = useLicenseContext();
|
|
9073
9178
|
const licensePresent = status === "valid" || status === "expiring";
|
|
9074
9179
|
const featureLicensed = checkFeature("threads");
|
|
9075
9180
|
const licensed = licensePresent && featureLicensed;
|
|
9076
9181
|
const licensePending = status === null;
|
|
9077
|
-
const resolvedAgentId = agentId ?? configuration?.agentId ??
|
|
9182
|
+
const resolvedAgentId = agentId ?? configuration?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
9078
9183
|
const activeThreadId = configuration?.threadId ?? null;
|
|
9079
|
-
const { threads, isLoading, listError, hasMoreThreads, isFetchingMoreThreads, archiveThread, unarchiveThread, deleteThread, fetchMoreThreads, refetchThreads, startNewThread } = useThreads({
|
|
9184
|
+
const { threads, isLoading, listError, fetchMoreError, hasMoreThreads, isFetchingMoreThreads, archiveThread, unarchiveThread, deleteThread, fetchMoreThreads, refetchThreads, startNewThread } = useThreads({
|
|
9080
9185
|
agentId: resolvedAgentId,
|
|
9081
9186
|
includeArchived: true,
|
|
9082
9187
|
enabled: licensed,
|
|
@@ -9157,6 +9262,9 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9157
9262
|
const handleLoadMore = (0, react.useCallback)(() => {
|
|
9158
9263
|
fetchMoreThreads();
|
|
9159
9264
|
}, [fetchMoreThreads]);
|
|
9265
|
+
const handleCollapseChange = (0, react.useCallback)((collapsed) => {
|
|
9266
|
+
onCollapseChange?.(collapsed);
|
|
9267
|
+
}, [onCollapseChange]);
|
|
9160
9268
|
const handlersRef = (0, react.useRef)({
|
|
9161
9269
|
handleThreadSelected,
|
|
9162
9270
|
handleNewThread,
|
|
@@ -9167,7 +9275,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9167
9275
|
handleRetry,
|
|
9168
9276
|
handleOpenChange,
|
|
9169
9277
|
handleLicensed,
|
|
9170
|
-
handleLoadMore
|
|
9278
|
+
handleLoadMore,
|
|
9279
|
+
handleCollapseChange
|
|
9171
9280
|
});
|
|
9172
9281
|
handlersRef.current = {
|
|
9173
9282
|
handleThreadSelected,
|
|
@@ -9179,7 +9288,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9179
9288
|
handleRetry,
|
|
9180
9289
|
handleOpenChange,
|
|
9181
9290
|
handleLicensed,
|
|
9182
|
-
handleLoadMore
|
|
9291
|
+
handleLoadMore,
|
|
9292
|
+
handleCollapseChange
|
|
9183
9293
|
};
|
|
9184
9294
|
(0, react.useEffect)(() => {
|
|
9185
9295
|
const el = elementRef.current;
|
|
@@ -9214,6 +9324,10 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9214
9324
|
};
|
|
9215
9325
|
const onLicensedEvent = () => handlersRef.current.handleLicensed();
|
|
9216
9326
|
const onLoadMore = () => handlersRef.current.handleLoadMore();
|
|
9327
|
+
const onCollapseChangeEvent = (event) => {
|
|
9328
|
+
const detail = event.detail;
|
|
9329
|
+
handlersRef.current.handleCollapseChange(detail.collapsed);
|
|
9330
|
+
};
|
|
9217
9331
|
el.addEventListener("thread-selected", onThreadSelected);
|
|
9218
9332
|
el.addEventListener("new-thread", onNewThreadEvent);
|
|
9219
9333
|
el.addEventListener("archive", onArchive);
|
|
@@ -9224,6 +9338,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9224
9338
|
el.addEventListener("retry", onRetry);
|
|
9225
9339
|
el.addEventListener("licensed", onLicensedEvent);
|
|
9226
9340
|
el.addEventListener("load-more", onLoadMore);
|
|
9341
|
+
el.addEventListener("collapse-change", onCollapseChangeEvent);
|
|
9227
9342
|
return () => {
|
|
9228
9343
|
el.removeEventListener("thread-selected", onThreadSelected);
|
|
9229
9344
|
el.removeEventListener("new-thread", onNewThreadEvent);
|
|
@@ -9235,6 +9350,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9235
9350
|
el.removeEventListener("retry", onRetry);
|
|
9236
9351
|
el.removeEventListener("licensed", onLicensedEvent);
|
|
9237
9352
|
el.removeEventListener("load-more", onLoadMore);
|
|
9353
|
+
el.removeEventListener("collapse-change", onCollapseChangeEvent);
|
|
9238
9354
|
};
|
|
9239
9355
|
}, [mounted]);
|
|
9240
9356
|
(0, react.useEffect)(() => {
|
|
@@ -9251,9 +9367,11 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9251
9367
|
el.licensed = licensed || licensePending;
|
|
9252
9368
|
el.hasMore = hasMoreThreads;
|
|
9253
9369
|
el.fetchingMore = isFetchingMoreThreads;
|
|
9370
|
+
el.fetchMoreError = fetchMoreError ? fetchMoreError.message : null;
|
|
9254
9371
|
}, [
|
|
9255
9372
|
isLoading,
|
|
9256
9373
|
listError,
|
|
9374
|
+
fetchMoreError,
|
|
9257
9375
|
activeThreadId,
|
|
9258
9376
|
licensed,
|
|
9259
9377
|
licensePending,
|
|
@@ -9276,6 +9394,11 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9276
9394
|
if (!el) return;
|
|
9277
9395
|
if (licenseUrl !== void 0) el.licenseUrl = licenseUrl;
|
|
9278
9396
|
}, [licenseUrl, mounted]);
|
|
9397
|
+
(0, react.useEffect)(() => {
|
|
9398
|
+
const el = elementRef.current;
|
|
9399
|
+
if (!el) return;
|
|
9400
|
+
if (collapsible !== void 0) el.collapsible = collapsible;
|
|
9401
|
+
}, [collapsible, mounted]);
|
|
9279
9402
|
const rowChildren = (0, react.useMemo)(() => {
|
|
9280
9403
|
if (!renderRow) return null;
|
|
9281
9404
|
return drawerThreads.map((drawerThread) => {
|
|
@@ -9296,7 +9419,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9296
9419
|
if (!mounted) return null;
|
|
9297
9420
|
return react.default.createElement(_copilotkit_web_components_threads_drawer.COPILOTKIT_THREADS_DRAWER_TAG, {
|
|
9298
9421
|
ref: elementRef,
|
|
9299
|
-
"data-testid": dataTestId
|
|
9422
|
+
"data-testid": dataTestId,
|
|
9423
|
+
...recentLabel !== void 0 ? { "recent-label": recentLabel } : {}
|
|
9300
9424
|
}, rowChildren);
|
|
9301
9425
|
}
|
|
9302
9426
|
CopilotThreadsDrawer.displayName = "CopilotThreadsDrawer";
|
|
@@ -10835,8 +10959,18 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
10835
10959
|
}, [agent, getSubscriber]);
|
|
10836
10960
|
};
|
|
10837
10961
|
function CopilotListenersAgentSubscription() {
|
|
10838
|
-
const
|
|
10839
|
-
const
|
|
10962
|
+
const { copilotkit } = useCopilotKit();
|
|
10963
|
+
const configAgentId = useCopilotChatConfiguration()?.agentId;
|
|
10964
|
+
const { agent } = useAgent({ agentId: (0, react.useMemo)(() => {
|
|
10965
|
+
const requested = configAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
10966
|
+
const registered = copilotkit.agents ?? {};
|
|
10967
|
+
if (registered[requested]) return requested;
|
|
10968
|
+
if (requested === _copilotkit_shared.DEFAULT_AGENT_ID) {
|
|
10969
|
+
const firstRegistered = Object.keys(registered)[0];
|
|
10970
|
+
if (firstRegistered) return firstRegistered;
|
|
10971
|
+
}
|
|
10972
|
+
return requested;
|
|
10973
|
+
}, [configAgentId, copilotkit.agents]) });
|
|
10840
10974
|
usePredictStateSubscription(agent);
|
|
10841
10975
|
return null;
|
|
10842
10976
|
}
|
|
@@ -11417,12 +11551,17 @@ Object.defineProperty(exports, 'CopilotSidebarView', {
|
|
|
11417
11551
|
}
|
|
11418
11552
|
});
|
|
11419
11553
|
exports.CopilotThreadsDrawer = CopilotThreadsDrawer;
|
|
11554
|
+
exports.GenerateSandboxedUiArgsSchema = GenerateSandboxedUiArgsSchema;
|
|
11420
11555
|
exports.INTELLIGENCE_TURN_HEAD = INTELLIGENCE_TURN_HEAD;
|
|
11421
11556
|
exports.IntelligenceIndicator = IntelligenceIndicator;
|
|
11422
11557
|
exports.IntelligenceIndicatorView = IntelligenceIndicatorView;
|
|
11423
11558
|
exports.MCPAppsActivityContentSchema = MCPAppsActivityContentSchema;
|
|
11424
11559
|
exports.MCPAppsActivityRenderer = MCPAppsActivityRenderer;
|
|
11425
11560
|
exports.MCPAppsActivityType = MCPAppsActivityType;
|
|
11561
|
+
exports.OpenGenerativeUIActivityRenderer = OpenGenerativeUIActivityRenderer;
|
|
11562
|
+
exports.OpenGenerativeUIActivityType = OpenGenerativeUIActivityType;
|
|
11563
|
+
exports.OpenGenerativeUIContentSchema = OpenGenerativeUIContentSchema;
|
|
11564
|
+
exports.OpenGenerativeUIToolRenderer = OpenGenerativeUIToolRenderer;
|
|
11426
11565
|
exports.SandboxFunctionsContext = SandboxFunctionsContext;
|
|
11427
11566
|
exports.UseAgentUpdate = UseAgentUpdate;
|
|
11428
11567
|
exports.WildcardToolCallRender = WildcardToolCallRender;
|
|
@@ -11451,6 +11590,7 @@ exports.useLearnFromUserAction = useLearnFromUserAction;
|
|
|
11451
11590
|
exports.useLearnFromUserActionInCurrentThread = useLearnFromUserActionInCurrentThread;
|
|
11452
11591
|
exports.useLearningContainers = useLearningContainers;
|
|
11453
11592
|
exports.useLearningContainersInCurrentThread = useLearningContainersInCurrentThread;
|
|
11593
|
+
exports.useMemories = useMemories;
|
|
11454
11594
|
exports.useRenderActivityMessage = useRenderActivityMessage;
|
|
11455
11595
|
exports.useRenderCustomMessages = useRenderCustomMessages;
|
|
11456
11596
|
exports.useRenderTool = useRenderTool;
|
|
@@ -11458,6 +11598,7 @@ exports.useRenderToolCall = useRenderToolCall;
|
|
|
11458
11598
|
exports.useSandboxFunctions = useSandboxFunctions;
|
|
11459
11599
|
exports.useSuggestions = useSuggestions;
|
|
11460
11600
|
exports.useThreads = useThreads;
|
|
11601
|
+
exports.ɵrunMcpFollowUp = ɵrunMcpFollowUp;
|
|
11461
11602
|
Object.keys(_copilotkit_core).forEach(function (k) {
|
|
11462
11603
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
11463
11604
|
enumerable: true,
|