@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/headless.cjs
CHANGED
|
@@ -338,57 +338,58 @@ const ALL_UPDATES = [
|
|
|
338
338
|
UseAgentUpdate.OnRunStatusChanged
|
|
339
339
|
];
|
|
340
340
|
function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
341
|
-
|
|
341
|
+
const chatConfig = useCopilotChatConfiguration();
|
|
342
|
+
const resolvedAgentId = agentId ?? chatConfig?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
342
343
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
343
344
|
const providerThrottleMs = copilotkit.defaultThrottleMs;
|
|
344
345
|
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
345
346
|
const updateFlags = (0, react.useMemo)(() => updates ?? ALL_UPDATES, [JSON.stringify(updates)]);
|
|
346
347
|
const provisionalAgentCache = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
347
348
|
const agent = (0, react.useMemo)(() => {
|
|
348
|
-
const existing = copilotkit.getAgent(
|
|
349
|
+
const existing = copilotkit.getAgent(resolvedAgentId);
|
|
349
350
|
if (existing) {
|
|
350
|
-
provisionalAgentCache.current.delete(
|
|
351
|
+
provisionalAgentCache.current.delete(resolvedAgentId);
|
|
351
352
|
return existing;
|
|
352
353
|
}
|
|
353
354
|
const isRuntimeConfigured = copilotkit.runtimeUrl !== void 0;
|
|
354
355
|
const status = copilotkit.runtimeConnectionStatus;
|
|
355
356
|
if (isRuntimeConfigured && (status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Disconnected || status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connecting)) {
|
|
356
|
-
const cached = provisionalAgentCache.current.get(
|
|
357
|
+
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
357
358
|
if (cached) {
|
|
358
359
|
copilotkit.applyHeadersToAgent(cached);
|
|
359
360
|
return cached;
|
|
360
361
|
}
|
|
361
362
|
const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
|
|
362
363
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
363
|
-
agentId,
|
|
364
|
+
agentId: resolvedAgentId,
|
|
364
365
|
transport: copilotkit.runtimeTransport,
|
|
365
366
|
runtimeMode: "pending"
|
|
366
367
|
});
|
|
367
368
|
copilotkit.applyHeadersToAgent(provisional);
|
|
368
|
-
provisionalAgentCache.current.set(
|
|
369
|
+
provisionalAgentCache.current.set(resolvedAgentId, provisional);
|
|
369
370
|
return provisional;
|
|
370
371
|
}
|
|
371
372
|
if (isRuntimeConfigured && status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Error) {
|
|
372
|
-
const cached = provisionalAgentCache.current.get(
|
|
373
|
+
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
373
374
|
if (cached) {
|
|
374
375
|
copilotkit.applyHeadersToAgent(cached);
|
|
375
376
|
return cached;
|
|
376
377
|
}
|
|
377
378
|
const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
|
|
378
379
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
379
|
-
agentId,
|
|
380
|
+
agentId: resolvedAgentId,
|
|
380
381
|
transport: copilotkit.runtimeTransport,
|
|
381
382
|
runtimeMode: "pending"
|
|
382
383
|
});
|
|
383
384
|
copilotkit.applyHeadersToAgent(provisional);
|
|
384
|
-
provisionalAgentCache.current.set(
|
|
385
|
+
provisionalAgentCache.current.set(resolvedAgentId, provisional);
|
|
385
386
|
return provisional;
|
|
386
387
|
}
|
|
387
388
|
const knownAgents = Object.keys(copilotkit.agents ?? {});
|
|
388
389
|
const runtimePart = isRuntimeConfigured ? `runtimeUrl=${copilotkit.runtimeUrl}` : "no runtimeUrl";
|
|
389
|
-
throw new Error(`useAgent: Agent '${
|
|
390
|
+
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.");
|
|
390
391
|
}, [
|
|
391
|
-
|
|
392
|
+
resolvedAgentId,
|
|
392
393
|
copilotkit.agents,
|
|
393
394
|
copilotkit.runtimeConnectionStatus,
|
|
394
395
|
copilotkit.runtimeUrl,
|
|
@@ -433,7 +434,6 @@ function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
|
433
434
|
(0, react.useEffect)(() => {
|
|
434
435
|
if (agent instanceof _ag_ui_client.HttpAgent) copilotkit.applyHeadersToAgent(agent);
|
|
435
436
|
}, [agent, JSON.stringify(copilotkit.headers)]);
|
|
436
|
-
const chatConfig = useCopilotChatConfiguration();
|
|
437
437
|
const configThreadId = chatConfig?.threadId;
|
|
438
438
|
const configHasExplicitThreadId = chatConfig?.hasExplicitThreadId;
|
|
439
439
|
(0, react.useEffect)(() => {
|
|
@@ -1201,6 +1201,7 @@ function useThreads({ agentId, includeArchived, limit, enabled = true }) {
|
|
|
1201
1201
|
})), [coreThreads]);
|
|
1202
1202
|
const storeIsLoading = useThreadStoreSelector(store, _copilotkit_core.ɵselectThreadsIsLoading);
|
|
1203
1203
|
const storeError = useThreadStoreSelector(store, _copilotkit_core.ɵselectThreadsError);
|
|
1204
|
+
const fetchMoreError = useThreadStoreSelector(store, _copilotkit_core.ɵselectFetchMoreError);
|
|
1204
1205
|
const hasMoreThreads = useThreadStoreSelector(store, _copilotkit_core.ɵselectHasNextPage);
|
|
1205
1206
|
const isFetchingMoreThreads = useThreadStoreSelector(store, _copilotkit_core.ɵselectIsFetchingNextPage);
|
|
1206
1207
|
const isMutating = useThreadStoreSelector(store, _copilotkit_core.ɵselectIsMutating);
|
|
@@ -1306,6 +1307,7 @@ function useThreads({ agentId, includeArchived, limit, enabled = true }) {
|
|
|
1306
1307
|
isLoading,
|
|
1307
1308
|
error,
|
|
1308
1309
|
listError,
|
|
1310
|
+
fetchMoreError,
|
|
1309
1311
|
hasMoreThreads,
|
|
1310
1312
|
isFetchingMoreThreads,
|
|
1311
1313
|
isMutating,
|
|
@@ -1419,13 +1421,15 @@ function useRenderTool(config, deps) {
|
|
|
1419
1421
|
//#endregion
|
|
1420
1422
|
//#region src/v2/hooks/use-capabilities.tsx
|
|
1421
1423
|
/**
|
|
1422
|
-
* Returns the capabilities declared by the given agent (or the
|
|
1424
|
+
* Returns the capabilities declared by the given agent (or the agent resolved
|
|
1425
|
+
* from the surrounding chat configuration, falling back to the default agent).
|
|
1423
1426
|
* Capabilities are populated from the runtime `/info` response at connection
|
|
1424
1427
|
* time. The hook reads them synchronously from the agent instance — there is
|
|
1425
1428
|
* no separate loading state, but the value will be `undefined` until the
|
|
1426
1429
|
* runtime handshake completes.
|
|
1427
1430
|
*
|
|
1428
|
-
* @param agentId - Optional agent ID. If omitted,
|
|
1431
|
+
* @param agentId - Optional agent ID. If omitted, inherits the surrounding
|
|
1432
|
+
* chat configuration's agent, falling back to the default agent.
|
|
1429
1433
|
* @returns The agent's capabilities, or `undefined` if the agent doesn't
|
|
1430
1434
|
* declare capabilities.
|
|
1431
1435
|
*/
|