@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
|
@@ -1830,6 +1830,34 @@ function InlineFeatureWarning({ featureName }) {
|
|
|
1830
1830
|
|
|
1831
1831
|
//#endregion
|
|
1832
1832
|
//#region src/v2/components/MCPAppsActivityRenderer.tsx
|
|
1833
|
+
/**
|
|
1834
|
+
* Run an MCP app `ui/message` follow-up, scoped to the thread it was enqueued
|
|
1835
|
+
* for (issue #5819).
|
|
1836
|
+
*
|
|
1837
|
+
* The MCP request queue delays follow-up work until the agent is idle. There is
|
|
1838
|
+
* a single shared registry agent per id, and switching threads overwrites its
|
|
1839
|
+
* `threadId`/`messages` in place. So if the host switches threads while a
|
|
1840
|
+
* follow-up is queued, running it now would execute against — and stream into —
|
|
1841
|
+
* the now-foreground thread.
|
|
1842
|
+
*
|
|
1843
|
+
* - **Same thread** (the common case): run on the shared agent, unchanged.
|
|
1844
|
+
* - **Thread changed**: the shared agent has moved on, so the follow-up can no
|
|
1845
|
+
* longer run in its originating thread's context. Drop it rather than leak it
|
|
1846
|
+
* into the current thread. (The MCP app already received its `ui/message` ack
|
|
1847
|
+
* at enqueue time; only the optional agent turn is skipped.)
|
|
1848
|
+
*
|
|
1849
|
+
* @internal exported for testing.
|
|
1850
|
+
*/
|
|
1851
|
+
async function ɵrunMcpFollowUp({ host, agent, capturedThreadId }) {
|
|
1852
|
+
const currentThreadId = agent.threadId || "default";
|
|
1853
|
+
const originThreadId = capturedThreadId || "default";
|
|
1854
|
+
if (currentThreadId === originThreadId) return host.runAgent({ agent });
|
|
1855
|
+
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.`);
|
|
1856
|
+
return {
|
|
1857
|
+
result: void 0,
|
|
1858
|
+
newMessages: []
|
|
1859
|
+
};
|
|
1860
|
+
}
|
|
1833
1861
|
const PROTOCOL_VERSION = "2025-06-18";
|
|
1834
1862
|
function buildSandboxHTML(extraCspDomains) {
|
|
1835
1863
|
const baseScriptSrc = "'self' 'wasm-unsafe-eval' 'unsafe-inline' 'unsafe-eval' blob: data: http://localhost:* https://localhost:*";
|
|
@@ -2152,7 +2180,14 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
2152
2180
|
content: textContent
|
|
2153
2181
|
});
|
|
2154
2182
|
sendResponse(msg.id, { isError: false });
|
|
2155
|
-
if ((params.followUp ?? role === "user") && textContent)
|
|
2183
|
+
if ((params.followUp ?? role === "user") && textContent) {
|
|
2184
|
+
const capturedThreadId = currentAgent.threadId || "default";
|
|
2185
|
+
mcpAppsRequestQueue.enqueue(currentAgent, () => ɵrunMcpFollowUp({
|
|
2186
|
+
host: copilotkit,
|
|
2187
|
+
agent: currentAgent,
|
|
2188
|
+
capturedThreadId
|
|
2189
|
+
})).catch((err) => console.error("[MCPAppsRenderer] ui/message agent run failed:", err));
|
|
2190
|
+
}
|
|
2156
2191
|
} catch (err) {
|
|
2157
2192
|
console.error("[MCPAppsRenderer] ui/message error:", err);
|
|
2158
2193
|
sendResponse(msg.id, { isError: true });
|
|
@@ -3635,6 +3670,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3635
3670
|
if (copilotkitRef.current === null) {
|
|
3636
3671
|
copilotkitRef.current = new CopilotKitCoreReact({
|
|
3637
3672
|
runtimeUrl: chatApiEndpoint,
|
|
3673
|
+
deferInitialConnection: true,
|
|
3638
3674
|
runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
|
|
3639
3675
|
headers: mergedHeaders,
|
|
3640
3676
|
credentials,
|
|
@@ -3718,6 +3754,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3718
3754
|
} : properties);
|
|
3719
3755
|
copilotkit.setAgents__unsafe_dev_only(mergedAgents);
|
|
3720
3756
|
copilotkit.setDebug(debug);
|
|
3757
|
+
copilotkit.connect();
|
|
3721
3758
|
}, [
|
|
3722
3759
|
copilotkit,
|
|
3723
3760
|
chatApiEndpoint,
|
|
@@ -4382,57 +4419,58 @@ const ALL_UPDATES = [
|
|
|
4382
4419
|
UseAgentUpdate.OnRunStatusChanged
|
|
4383
4420
|
];
|
|
4384
4421
|
function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
4385
|
-
|
|
4422
|
+
const chatConfig = useCopilotChatConfiguration();
|
|
4423
|
+
const resolvedAgentId = agentId ?? chatConfig?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
4386
4424
|
const { copilotkit } = useCopilotKit();
|
|
4387
4425
|
const providerThrottleMs = copilotkit.defaultThrottleMs;
|
|
4388
4426
|
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
4389
4427
|
const updateFlags = (0, react.useMemo)(() => updates ?? ALL_UPDATES, [JSON.stringify(updates)]);
|
|
4390
4428
|
const provisionalAgentCache = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
4391
4429
|
const agent = (0, react.useMemo)(() => {
|
|
4392
|
-
const existing = copilotkit.getAgent(
|
|
4430
|
+
const existing = copilotkit.getAgent(resolvedAgentId);
|
|
4393
4431
|
if (existing) {
|
|
4394
|
-
provisionalAgentCache.current.delete(
|
|
4432
|
+
provisionalAgentCache.current.delete(resolvedAgentId);
|
|
4395
4433
|
return existing;
|
|
4396
4434
|
}
|
|
4397
4435
|
const isRuntimeConfigured = copilotkit.runtimeUrl !== void 0;
|
|
4398
4436
|
const status = copilotkit.runtimeConnectionStatus;
|
|
4399
4437
|
if (isRuntimeConfigured && (status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Disconnected || status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connecting)) {
|
|
4400
|
-
const cached = provisionalAgentCache.current.get(
|
|
4438
|
+
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
4401
4439
|
if (cached) {
|
|
4402
4440
|
copilotkit.applyHeadersToAgent(cached);
|
|
4403
4441
|
return cached;
|
|
4404
4442
|
}
|
|
4405
4443
|
const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
|
|
4406
4444
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
4407
|
-
agentId,
|
|
4445
|
+
agentId: resolvedAgentId,
|
|
4408
4446
|
transport: copilotkit.runtimeTransport,
|
|
4409
4447
|
runtimeMode: "pending"
|
|
4410
4448
|
});
|
|
4411
4449
|
copilotkit.applyHeadersToAgent(provisional);
|
|
4412
|
-
provisionalAgentCache.current.set(
|
|
4450
|
+
provisionalAgentCache.current.set(resolvedAgentId, provisional);
|
|
4413
4451
|
return provisional;
|
|
4414
4452
|
}
|
|
4415
4453
|
if (isRuntimeConfigured && status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Error) {
|
|
4416
|
-
const cached = provisionalAgentCache.current.get(
|
|
4454
|
+
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
4417
4455
|
if (cached) {
|
|
4418
4456
|
copilotkit.applyHeadersToAgent(cached);
|
|
4419
4457
|
return cached;
|
|
4420
4458
|
}
|
|
4421
4459
|
const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
|
|
4422
4460
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
4423
|
-
agentId,
|
|
4461
|
+
agentId: resolvedAgentId,
|
|
4424
4462
|
transport: copilotkit.runtimeTransport,
|
|
4425
4463
|
runtimeMode: "pending"
|
|
4426
4464
|
});
|
|
4427
4465
|
copilotkit.applyHeadersToAgent(provisional);
|
|
4428
|
-
provisionalAgentCache.current.set(
|
|
4466
|
+
provisionalAgentCache.current.set(resolvedAgentId, provisional);
|
|
4429
4467
|
return provisional;
|
|
4430
4468
|
}
|
|
4431
4469
|
const knownAgents = Object.keys(copilotkit.agents ?? {});
|
|
4432
4470
|
const runtimePart = isRuntimeConfigured ? `runtimeUrl=${copilotkit.runtimeUrl}` : "no runtimeUrl";
|
|
4433
|
-
throw new Error(`useAgent: Agent '${
|
|
4471
|
+
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.");
|
|
4434
4472
|
}, [
|
|
4435
|
-
|
|
4473
|
+
resolvedAgentId,
|
|
4436
4474
|
copilotkit.agents,
|
|
4437
4475
|
copilotkit.runtimeConnectionStatus,
|
|
4438
4476
|
copilotkit.runtimeUrl,
|
|
@@ -4477,7 +4515,6 @@ function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
|
4477
4515
|
(0, react.useEffect)(() => {
|
|
4478
4516
|
if (agent instanceof _ag_ui_client.HttpAgent) copilotkit.applyHeadersToAgent(agent);
|
|
4479
4517
|
}, [agent, JSON.stringify(copilotkit.headers)]);
|
|
4480
|
-
const chatConfig = useCopilotChatConfiguration();
|
|
4481
4518
|
const configThreadId = chatConfig?.threadId;
|
|
4482
4519
|
const configHasExplicitThreadId = chatConfig?.hasExplicitThreadId;
|
|
4483
4520
|
(0, react.useEffect)(() => {
|
|
@@ -4494,13 +4531,15 @@ function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
|
4494
4531
|
//#endregion
|
|
4495
4532
|
//#region src/v2/hooks/use-capabilities.tsx
|
|
4496
4533
|
/**
|
|
4497
|
-
* Returns the capabilities declared by the given agent (or the
|
|
4534
|
+
* Returns the capabilities declared by the given agent (or the agent resolved
|
|
4535
|
+
* from the surrounding chat configuration, falling back to the default agent).
|
|
4498
4536
|
* Capabilities are populated from the runtime `/info` response at connection
|
|
4499
4537
|
* time. The hook reads them synchronously from the agent instance — there is
|
|
4500
4538
|
* no separate loading state, but the value will be `undefined` until the
|
|
4501
4539
|
* runtime handshake completes.
|
|
4502
4540
|
*
|
|
4503
|
-
* @param agentId - Optional agent ID. If omitted,
|
|
4541
|
+
* @param agentId - Optional agent ID. If omitted, inherits the surrounding
|
|
4542
|
+
* chat configuration's agent, falling back to the default agent.
|
|
4504
4543
|
* @returns The agent's capabilities, or `undefined` if the agent doesn't
|
|
4505
4544
|
* declare capabilities.
|
|
4506
4545
|
*/
|
|
@@ -5073,6 +5112,7 @@ function useThreads$1({ agentId, includeArchived, limit, enabled = true }) {
|
|
|
5073
5112
|
})), [coreThreads]);
|
|
5074
5113
|
const storeIsLoading = useThreadStoreSelector(store, _copilotkit_core.ɵselectThreadsIsLoading);
|
|
5075
5114
|
const storeError = useThreadStoreSelector(store, _copilotkit_core.ɵselectThreadsError);
|
|
5115
|
+
const fetchMoreError = useThreadStoreSelector(store, _copilotkit_core.ɵselectFetchMoreError);
|
|
5076
5116
|
const hasMoreThreads = useThreadStoreSelector(store, _copilotkit_core.ɵselectHasNextPage);
|
|
5077
5117
|
const isFetchingMoreThreads = useThreadStoreSelector(store, _copilotkit_core.ɵselectIsFetchingNextPage);
|
|
5078
5118
|
const isMutating = useThreadStoreSelector(store, _copilotkit_core.ɵselectIsMutating);
|
|
@@ -5178,6 +5218,7 @@ function useThreads$1({ agentId, includeArchived, limit, enabled = true }) {
|
|
|
5178
5218
|
isLoading,
|
|
5179
5219
|
error,
|
|
5180
5220
|
listError,
|
|
5221
|
+
fetchMoreError,
|
|
5181
5222
|
hasMoreThreads,
|
|
5182
5223
|
isFetchingMoreThreads,
|
|
5183
5224
|
isMutating,
|
|
@@ -5194,6 +5235,70 @@ function useThreads$1({ agentId, includeArchived, limit, enabled = true }) {
|
|
|
5194
5235
|
};
|
|
5195
5236
|
}
|
|
5196
5237
|
|
|
5238
|
+
//#endregion
|
|
5239
|
+
//#region src/v2/hooks/use-memories.tsx
|
|
5240
|
+
function useMemoryStoreSelector(store, selector) {
|
|
5241
|
+
return (0, react.useSyncExternalStore)((0, react.useCallback)((onStoreChange) => {
|
|
5242
|
+
const subscription = store.select(selector).subscribe(onStoreChange);
|
|
5243
|
+
return () => subscription.unsubscribe();
|
|
5244
|
+
}, [store, selector]), () => selector(store.getState()), () => selector(store.getServerState()));
|
|
5245
|
+
}
|
|
5246
|
+
/**
|
|
5247
|
+
* React hook for listing and managing platform memories.
|
|
5248
|
+
*
|
|
5249
|
+
* Reads the memory store owned and wired by `CopilotKitCore`. On mount the
|
|
5250
|
+
* hook exposes the live list plus stable `addMemory` / `updateMemory` /
|
|
5251
|
+
* `removeMemory` / `refresh` callbacks. Mutations are server-authoritative:
|
|
5252
|
+
* each resolves once the platform confirms the operation and rejects with an
|
|
5253
|
+
* `Error` on failure.
|
|
5254
|
+
*
|
|
5255
|
+
* Realtime updates are automatic: the core's memory store opens its own
|
|
5256
|
+
* `user_meta:memories:<joinCode>` channel and applies `memory_metadata` deltas
|
|
5257
|
+
* to the list. You can still call `refresh()` to re-pull the REST snapshot on
|
|
5258
|
+
* demand.
|
|
5259
|
+
*
|
|
5260
|
+
* @returns Memory list state and stable mutation callbacks.
|
|
5261
|
+
*
|
|
5262
|
+
* @example
|
|
5263
|
+
* ```tsx
|
|
5264
|
+
* import { useMemories } from "@copilotkit/react-core";
|
|
5265
|
+
*
|
|
5266
|
+
* function MemoryList() {
|
|
5267
|
+
* const { memories, isLoading, isAvailable, addMemory, removeMemory } =
|
|
5268
|
+
* useMemories();
|
|
5269
|
+
*
|
|
5270
|
+
* if (!isAvailable) return null;
|
|
5271
|
+
* if (isLoading) return <p>Loading…</p>;
|
|
5272
|
+
*
|
|
5273
|
+
* return (
|
|
5274
|
+
* <ul>
|
|
5275
|
+
* {memories.map((m) => (
|
|
5276
|
+
* <li key={m.id}>
|
|
5277
|
+
* {m.content}
|
|
5278
|
+
* <button onClick={() => removeMemory(m.id)}>Delete</button>
|
|
5279
|
+
* </li>
|
|
5280
|
+
* ))}
|
|
5281
|
+
* </ul>
|
|
5282
|
+
* );
|
|
5283
|
+
* }
|
|
5284
|
+
* ```
|
|
5285
|
+
*/
|
|
5286
|
+
function useMemories() {
|
|
5287
|
+
const { copilotkit } = useCopilotKit();
|
|
5288
|
+
const store = copilotkit.getMemoryStore();
|
|
5289
|
+
return {
|
|
5290
|
+
memories: useMemoryStoreSelector(store, _copilotkit_core.ɵselectMemories),
|
|
5291
|
+
isLoading: useMemoryStoreSelector(store, _copilotkit_core.ɵselectMemoriesIsLoading),
|
|
5292
|
+
error: useMemoryStoreSelector(store, _copilotkit_core.ɵselectMemoriesError),
|
|
5293
|
+
isAvailable: useMemoryStoreSelector(store, _copilotkit_core.ɵselectMemoriesAvailable),
|
|
5294
|
+
realtimeStatus: useMemoryStoreSelector(store, _copilotkit_core.ɵselectMemoriesRealtimeStatus),
|
|
5295
|
+
refresh: (0, react.useCallback)(() => store.refresh(), [store]),
|
|
5296
|
+
addMemory: (0, react.useCallback)((input) => store.addMemory(input), [store]),
|
|
5297
|
+
updateMemory: (0, react.useCallback)((id, changes) => store.updateMemory(id, changes), [store]),
|
|
5298
|
+
removeMemory: (0, react.useCallback)((id) => store.removeMemory(id), [store])
|
|
5299
|
+
};
|
|
5300
|
+
}
|
|
5301
|
+
|
|
5197
5302
|
//#endregion
|
|
5198
5303
|
//#region src/v2/lib/record-annotation.ts
|
|
5199
5304
|
/**
|
|
@@ -9055,7 +9160,7 @@ function findChatInput(origin) {
|
|
|
9055
9160
|
* during prerender to avoid hydration mismatch).
|
|
9056
9161
|
* - Feeds the element domain data: `threads`, `loading`, `error`,
|
|
9057
9162
|
* `activeThreadId`, `licensed`, fetch-more state.
|
|
9058
|
-
* - Routes the element's
|
|
9163
|
+
* - Routes the element's outbound events to core thread operations
|
|
9059
9164
|
* ({@link useThreads}) and chat-configuration changes.
|
|
9060
9165
|
* - Registers with the surrounding chat configuration so the header
|
|
9061
9166
|
* thread-list launcher appears, and binds the element `open` state to the
|
|
@@ -9082,16 +9187,16 @@ function findChatInput(origin) {
|
|
|
9082
9187
|
* </CopilotKitProvider>
|
|
9083
9188
|
* ```
|
|
9084
9189
|
*/
|
|
9085
|
-
function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed, licenseUrl, renderRow, label, limit, "data-testid": dataTestId = "copilot-threads-drawer" }) {
|
|
9190
|
+
function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed, licenseUrl, renderRow, label, recentLabel, collapsible, onCollapseChange, limit, "data-testid": dataTestId = "copilot-threads-drawer" }) {
|
|
9086
9191
|
const configuration = useCopilotChatConfiguration();
|
|
9087
9192
|
const { status, checkFeature } = useLicenseContext();
|
|
9088
9193
|
const licensePresent = status === "valid" || status === "expiring";
|
|
9089
9194
|
const featureLicensed = checkFeature("threads");
|
|
9090
9195
|
const licensed = licensePresent && featureLicensed;
|
|
9091
9196
|
const licensePending = status === null;
|
|
9092
|
-
const resolvedAgentId = agentId ?? configuration?.agentId ??
|
|
9197
|
+
const resolvedAgentId = agentId ?? configuration?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
9093
9198
|
const activeThreadId = configuration?.threadId ?? null;
|
|
9094
|
-
const { threads, isLoading, listError, hasMoreThreads, isFetchingMoreThreads, archiveThread, unarchiveThread, deleteThread, fetchMoreThreads, refetchThreads, startNewThread } = useThreads$1({
|
|
9199
|
+
const { threads, isLoading, listError, fetchMoreError, hasMoreThreads, isFetchingMoreThreads, archiveThread, unarchiveThread, deleteThread, fetchMoreThreads, refetchThreads, startNewThread } = useThreads$1({
|
|
9095
9200
|
agentId: resolvedAgentId,
|
|
9096
9201
|
includeArchived: true,
|
|
9097
9202
|
enabled: licensed,
|
|
@@ -9172,6 +9277,9 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
|
|
|
9172
9277
|
const handleLoadMore = (0, react.useCallback)(() => {
|
|
9173
9278
|
fetchMoreThreads();
|
|
9174
9279
|
}, [fetchMoreThreads]);
|
|
9280
|
+
const handleCollapseChange = (0, react.useCallback)((collapsed) => {
|
|
9281
|
+
onCollapseChange?.(collapsed);
|
|
9282
|
+
}, [onCollapseChange]);
|
|
9175
9283
|
const handlersRef = (0, react.useRef)({
|
|
9176
9284
|
handleThreadSelected,
|
|
9177
9285
|
handleNewThread,
|
|
@@ -9182,7 +9290,8 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
|
|
|
9182
9290
|
handleRetry,
|
|
9183
9291
|
handleOpenChange,
|
|
9184
9292
|
handleLicensed,
|
|
9185
|
-
handleLoadMore
|
|
9293
|
+
handleLoadMore,
|
|
9294
|
+
handleCollapseChange
|
|
9186
9295
|
});
|
|
9187
9296
|
handlersRef.current = {
|
|
9188
9297
|
handleThreadSelected,
|
|
@@ -9194,7 +9303,8 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
|
|
|
9194
9303
|
handleRetry,
|
|
9195
9304
|
handleOpenChange,
|
|
9196
9305
|
handleLicensed,
|
|
9197
|
-
handleLoadMore
|
|
9306
|
+
handleLoadMore,
|
|
9307
|
+
handleCollapseChange
|
|
9198
9308
|
};
|
|
9199
9309
|
(0, react.useEffect)(() => {
|
|
9200
9310
|
const el = elementRef.current;
|
|
@@ -9229,6 +9339,10 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
|
|
|
9229
9339
|
};
|
|
9230
9340
|
const onLicensedEvent = () => handlersRef.current.handleLicensed();
|
|
9231
9341
|
const onLoadMore = () => handlersRef.current.handleLoadMore();
|
|
9342
|
+
const onCollapseChangeEvent = (event) => {
|
|
9343
|
+
const detail = event.detail;
|
|
9344
|
+
handlersRef.current.handleCollapseChange(detail.collapsed);
|
|
9345
|
+
};
|
|
9232
9346
|
el.addEventListener("thread-selected", onThreadSelected);
|
|
9233
9347
|
el.addEventListener("new-thread", onNewThreadEvent);
|
|
9234
9348
|
el.addEventListener("archive", onArchive);
|
|
@@ -9239,6 +9353,7 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
|
|
|
9239
9353
|
el.addEventListener("retry", onRetry);
|
|
9240
9354
|
el.addEventListener("licensed", onLicensedEvent);
|
|
9241
9355
|
el.addEventListener("load-more", onLoadMore);
|
|
9356
|
+
el.addEventListener("collapse-change", onCollapseChangeEvent);
|
|
9242
9357
|
return () => {
|
|
9243
9358
|
el.removeEventListener("thread-selected", onThreadSelected);
|
|
9244
9359
|
el.removeEventListener("new-thread", onNewThreadEvent);
|
|
@@ -9250,6 +9365,7 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
|
|
|
9250
9365
|
el.removeEventListener("retry", onRetry);
|
|
9251
9366
|
el.removeEventListener("licensed", onLicensedEvent);
|
|
9252
9367
|
el.removeEventListener("load-more", onLoadMore);
|
|
9368
|
+
el.removeEventListener("collapse-change", onCollapseChangeEvent);
|
|
9253
9369
|
};
|
|
9254
9370
|
}, [mounted]);
|
|
9255
9371
|
(0, react.useEffect)(() => {
|
|
@@ -9266,9 +9382,11 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
|
|
|
9266
9382
|
el.licensed = licensed || licensePending;
|
|
9267
9383
|
el.hasMore = hasMoreThreads;
|
|
9268
9384
|
el.fetchingMore = isFetchingMoreThreads;
|
|
9385
|
+
el.fetchMoreError = fetchMoreError ? fetchMoreError.message : null;
|
|
9269
9386
|
}, [
|
|
9270
9387
|
isLoading,
|
|
9271
9388
|
listError,
|
|
9389
|
+
fetchMoreError,
|
|
9272
9390
|
activeThreadId,
|
|
9273
9391
|
licensed,
|
|
9274
9392
|
licensePending,
|
|
@@ -9291,6 +9409,11 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
|
|
|
9291
9409
|
if (!el) return;
|
|
9292
9410
|
if (licenseUrl !== void 0) el.licenseUrl = licenseUrl;
|
|
9293
9411
|
}, [licenseUrl, mounted]);
|
|
9412
|
+
(0, react.useEffect)(() => {
|
|
9413
|
+
const el = elementRef.current;
|
|
9414
|
+
if (!el) return;
|
|
9415
|
+
if (collapsible !== void 0) el.collapsible = collapsible;
|
|
9416
|
+
}, [collapsible, mounted]);
|
|
9294
9417
|
const rowChildren = (0, react.useMemo)(() => {
|
|
9295
9418
|
if (!renderRow) return null;
|
|
9296
9419
|
return drawerThreads.map((drawerThread) => {
|
|
@@ -9311,7 +9434,8 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
|
|
|
9311
9434
|
if (!mounted) return null;
|
|
9312
9435
|
return react.default.createElement(_copilotkit_web_components_threads_drawer.COPILOTKIT_THREADS_DRAWER_TAG, {
|
|
9313
9436
|
ref: elementRef,
|
|
9314
|
-
"data-testid": dataTestId
|
|
9437
|
+
"data-testid": dataTestId,
|
|
9438
|
+
...recentLabel !== void 0 ? { "recent-label": recentLabel } : {}
|
|
9315
9439
|
}, rowChildren);
|
|
9316
9440
|
}
|
|
9317
9441
|
CopilotThreadsDrawer.displayName = "CopilotThreadsDrawer";
|
|
@@ -10964,8 +11088,18 @@ const usePredictStateSubscription = (agent) => {
|
|
|
10964
11088
|
}, [agent, getSubscriber]);
|
|
10965
11089
|
};
|
|
10966
11090
|
function CopilotListenersAgentSubscription() {
|
|
10967
|
-
const
|
|
10968
|
-
const
|
|
11091
|
+
const { copilotkit } = useCopilotKit();
|
|
11092
|
+
const configAgentId = useCopilotChatConfiguration()?.agentId;
|
|
11093
|
+
const { agent } = useAgent({ agentId: (0, react.useMemo)(() => {
|
|
11094
|
+
const requested = configAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
11095
|
+
const registered = copilotkit.agents ?? {};
|
|
11096
|
+
if (registered[requested]) return requested;
|
|
11097
|
+
if (requested === _copilotkit_shared.DEFAULT_AGENT_ID) {
|
|
11098
|
+
const firstRegistered = Object.keys(registered)[0];
|
|
11099
|
+
if (firstRegistered) return firstRegistered;
|
|
11100
|
+
}
|
|
11101
|
+
return requested;
|
|
11102
|
+
}, [configAgentId, copilotkit.agents]) });
|
|
10969
11103
|
usePredictStateSubscription(agent);
|
|
10970
11104
|
return null;
|
|
10971
11105
|
}
|
|
@@ -11696,6 +11830,12 @@ Object.defineProperty(exports, 'DefaultOpenIcon', {
|
|
|
11696
11830
|
return DefaultOpenIcon;
|
|
11697
11831
|
}
|
|
11698
11832
|
});
|
|
11833
|
+
Object.defineProperty(exports, 'GenerateSandboxedUiArgsSchema', {
|
|
11834
|
+
enumerable: true,
|
|
11835
|
+
get: function () {
|
|
11836
|
+
return GenerateSandboxedUiArgsSchema;
|
|
11837
|
+
}
|
|
11838
|
+
});
|
|
11699
11839
|
Object.defineProperty(exports, 'INTELLIGENCE_TURN_HEAD', {
|
|
11700
11840
|
enumerable: true,
|
|
11701
11841
|
get: function () {
|
|
@@ -11732,6 +11872,30 @@ Object.defineProperty(exports, 'MCPAppsActivityType', {
|
|
|
11732
11872
|
return MCPAppsActivityType;
|
|
11733
11873
|
}
|
|
11734
11874
|
});
|
|
11875
|
+
Object.defineProperty(exports, 'OpenGenerativeUIActivityRenderer', {
|
|
11876
|
+
enumerable: true,
|
|
11877
|
+
get: function () {
|
|
11878
|
+
return OpenGenerativeUIActivityRenderer;
|
|
11879
|
+
}
|
|
11880
|
+
});
|
|
11881
|
+
Object.defineProperty(exports, 'OpenGenerativeUIActivityType', {
|
|
11882
|
+
enumerable: true,
|
|
11883
|
+
get: function () {
|
|
11884
|
+
return OpenGenerativeUIActivityType;
|
|
11885
|
+
}
|
|
11886
|
+
});
|
|
11887
|
+
Object.defineProperty(exports, 'OpenGenerativeUIContentSchema', {
|
|
11888
|
+
enumerable: true,
|
|
11889
|
+
get: function () {
|
|
11890
|
+
return OpenGenerativeUIContentSchema;
|
|
11891
|
+
}
|
|
11892
|
+
});
|
|
11893
|
+
Object.defineProperty(exports, 'OpenGenerativeUIToolRenderer', {
|
|
11894
|
+
enumerable: true,
|
|
11895
|
+
get: function () {
|
|
11896
|
+
return OpenGenerativeUIToolRenderer;
|
|
11897
|
+
}
|
|
11898
|
+
});
|
|
11735
11899
|
Object.defineProperty(exports, 'SandboxFunctionsContext', {
|
|
11736
11900
|
enumerable: true,
|
|
11737
11901
|
get: function () {
|
|
@@ -11918,6 +12082,12 @@ Object.defineProperty(exports, 'useLearningContainersInCurrentThread', {
|
|
|
11918
12082
|
return useLearningContainersInCurrentThread;
|
|
11919
12083
|
}
|
|
11920
12084
|
});
|
|
12085
|
+
Object.defineProperty(exports, 'useMemories', {
|
|
12086
|
+
enumerable: true,
|
|
12087
|
+
get: function () {
|
|
12088
|
+
return useMemories;
|
|
12089
|
+
}
|
|
12090
|
+
});
|
|
11921
12091
|
Object.defineProperty(exports, 'useRenderActivityMessage', {
|
|
11922
12092
|
enumerable: true,
|
|
11923
12093
|
get: function () {
|
|
@@ -11972,4 +12142,10 @@ Object.defineProperty(exports, 'useToast', {
|
|
|
11972
12142
|
return useToast;
|
|
11973
12143
|
}
|
|
11974
12144
|
});
|
|
11975
|
-
|
|
12145
|
+
Object.defineProperty(exports, 'ɵrunMcpFollowUp', {
|
|
12146
|
+
enumerable: true,
|
|
12147
|
+
get: function () {
|
|
12148
|
+
return ɵrunMcpFollowUp;
|
|
12149
|
+
}
|
|
12150
|
+
});
|
|
12151
|
+
//# sourceMappingURL=copilotkit-nu7NwzH6.cjs.map
|