@copilotkit/react-core 1.66.2 → 1.66.4
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-CBCT7BlL.d.cts.map +1 -1
- package/dist/copilotkit-D0aAnD3i.d.mts.map +1 -1
- package/dist/{copilotkit-DnlgZWST.mjs → copilotkit-nRjRp2_5.mjs} +73 -19
- package/dist/copilotkit-nRjRp2_5.mjs.map +1 -0
- package/dist/{copilotkit-2v7ami2b.cjs → copilotkit-sitn7Oe8.cjs} +73 -19
- package/dist/copilotkit-sitn7Oe8.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +35 -16
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +35 -16
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.mjs +35 -16
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +72 -18
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/dist/copilotkit-2v7ami2b.cjs.map +0 -1
- package/dist/copilotkit-DnlgZWST.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_copilotkit = require('./copilotkit-
|
|
4
|
+
const require_copilotkit = require('./copilotkit-sitn7Oe8.cjs');
|
|
5
5
|
let react = require("react");
|
|
6
6
|
react = require_copilotkit.__toESM(react);
|
|
7
7
|
let _copilotkit_core = require("@copilotkit/core");
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { Tt as useCopilotKit, X as useConfigureSuggestions, Y as useInterrupt, Z as useSuggestions, a as ThreadsProvider, c as CoAgentStateRendersProvider, ct as useRenderCustomMessages, d as shouldShowDevConsole, f as useToast, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, jt as useCopilotChatConfiguration, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, nt as useHumanInTheLoop$1, o as useThreads, ot as useFrontendTool$1, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, tt as useAgent, u as useAsyncCallback, ut as defineToolCallRenderer, wt as useRenderToolCall$1 } from "./copilotkit-
|
|
3
|
+
import { Tt as useCopilotKit, X as useConfigureSuggestions, Y as useInterrupt, Z as useSuggestions, a as ThreadsProvider, c as CoAgentStateRendersProvider, ct as useRenderCustomMessages, d as shouldShowDevConsole, f as useToast, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, jt as useCopilotChatConfiguration, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, nt as useHumanInTheLoop$1, o as useThreads, ot as useFrontendTool$1, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, tt as useAgent, u as useAsyncCallback, ut as defineToolCallRenderer, wt as useRenderToolCall$1 } from "./copilotkit-nRjRp2_5.mjs";
|
|
4
4
|
import React, { Fragment, createElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus } from "@copilotkit/core";
|
|
6
6
|
import { AGUIConnectNotImplementedError, HttpAgent } from "@ag-ui/client";
|
package/dist/index.umd.js
CHANGED
|
@@ -3311,6 +3311,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3311
3311
|
pendingRef.current = pending;
|
|
3312
3312
|
const [handlerResult, setHandlerResult] = (0, react.useState)(null);
|
|
3313
3313
|
const interruptStateRef = (0, react.useRef)(new _copilotkit_core.ɵInterruptState());
|
|
3314
|
+
const interruptRunIdsRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
3315
|
+
const legacyRunIdRef = (0, react.useRef)(void 0);
|
|
3314
3316
|
(0, react.useEffect)(() => {
|
|
3315
3317
|
const interruptState = interruptStateRef.current;
|
|
3316
3318
|
let localLegacy = null;
|
|
@@ -3323,19 +3325,26 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3323
3325
|
};
|
|
3324
3326
|
},
|
|
3325
3327
|
onRunFinishedEvent: (params) => {
|
|
3326
|
-
if (params.outcome === "interrupt")
|
|
3328
|
+
if (params.outcome === "interrupt") {
|
|
3329
|
+
const runId = params.input.runId;
|
|
3330
|
+
for (const interrupt of params.interrupts) interruptRunIdsRef.current.set(interrupt.id, runId);
|
|
3331
|
+
localStandard = params.interrupts;
|
|
3332
|
+
}
|
|
3327
3333
|
},
|
|
3328
3334
|
onRunStartedEvent: () => {
|
|
3329
3335
|
localLegacy = null;
|
|
3330
3336
|
localStandard = null;
|
|
3337
|
+
interruptRunIdsRef.current.clear();
|
|
3338
|
+
legacyRunIdRef.current = void 0;
|
|
3331
3339
|
interruptState.clear();
|
|
3332
3340
|
setPending(null);
|
|
3333
3341
|
},
|
|
3334
|
-
onRunFinalized: () => {
|
|
3342
|
+
onRunFinalized: (params) => {
|
|
3335
3343
|
if (localStandard && localStandard.length > 0) {
|
|
3336
3344
|
interruptState.setStandard(localStandard);
|
|
3337
3345
|
setPending(interruptState.pending);
|
|
3338
3346
|
} else if (localLegacy) {
|
|
3347
|
+
legacyRunIdRef.current = params.input.runId;
|
|
3339
3348
|
interruptState.setLegacy(localLegacy);
|
|
3340
3349
|
setPending(interruptState.pending);
|
|
3341
3350
|
}
|
|
@@ -3345,6 +3354,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3345
3354
|
onRunFailed: () => {
|
|
3346
3355
|
localLegacy = null;
|
|
3347
3356
|
localStandard = null;
|
|
3357
|
+
interruptRunIdsRef.current.clear();
|
|
3358
|
+
legacyRunIdRef.current = void 0;
|
|
3348
3359
|
interruptState.clear();
|
|
3349
3360
|
setPending(null);
|
|
3350
3361
|
}
|
|
@@ -3359,18 +3370,22 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3359
3370
|
if (!current) return;
|
|
3360
3371
|
if (current.kind === "standard" && current.interrupts.length > 1 && interruptId === void 0) console.warn(`[CopilotKit] useInterrupt: resolve()/cancel() called without an interruptId while ${current.interrupts.length} interrupts are open; defaulting to the first. Pass an interruptId to address a specific interrupt.`);
|
|
3361
3372
|
const decision = interruptStateRef.current.resolve(payload, interruptId);
|
|
3362
|
-
if (decision.kind === "legacy-resume")
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3373
|
+
if (decision.kind === "legacy-resume") {
|
|
3374
|
+
const runId = legacyRunIdRef.current;
|
|
3375
|
+
try {
|
|
3376
|
+
return await copilotkit.runAgent({
|
|
3377
|
+
agent,
|
|
3378
|
+
...runId !== void 0 ? { runId } : {},
|
|
3379
|
+
forwardedProps: { command: {
|
|
3380
|
+
resume: decision.payload,
|
|
3381
|
+
interruptEvent: decision.interruptValue
|
|
3382
|
+
} }
|
|
3383
|
+
});
|
|
3384
|
+
} catch (err) {
|
|
3385
|
+
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
3386
|
+
setPending(null);
|
|
3387
|
+
throw err;
|
|
3388
|
+
}
|
|
3374
3389
|
}
|
|
3375
3390
|
if (decision.kind === "expired") {
|
|
3376
3391
|
console.error(`[CopilotKit] useInterrupt: interrupt ${decision.interrupt.id} expired at ${decision.interrupt.expiresAt}; not resuming.`);
|
|
@@ -3379,6 +3394,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3379
3394
|
return;
|
|
3380
3395
|
}
|
|
3381
3396
|
if (decision.kind !== "resume") return;
|
|
3397
|
+
const runId = decision.resume.map((entry) => interruptRunIdsRef.current.get(entry.interruptId)).find((candidate) => candidate !== void 0);
|
|
3382
3398
|
for (const toolResult of decision.toolResults) agent.addMessage({
|
|
3383
3399
|
id: (0, _ag_ui_client.randomUUID)(),
|
|
3384
3400
|
role: "tool",
|
|
@@ -3388,7 +3404,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3388
3404
|
try {
|
|
3389
3405
|
return await copilotkit.runAgent({
|
|
3390
3406
|
agent,
|
|
3391
|
-
resume: decision.resume
|
|
3407
|
+
resume: decision.resume,
|
|
3408
|
+
...runId !== void 0 ? { runId } : {}
|
|
3392
3409
|
});
|
|
3393
3410
|
} catch (err) {
|
|
3394
3411
|
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
@@ -3415,6 +3432,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3415
3432
|
return;
|
|
3416
3433
|
}
|
|
3417
3434
|
if (decision.kind !== "resume") return;
|
|
3435
|
+
const runId = decision.resume.map((entry) => interruptRunIdsRef.current.get(entry.interruptId)).find((candidate) => candidate !== void 0);
|
|
3418
3436
|
for (const toolResult of decision.toolResults) agent.addMessage({
|
|
3419
3437
|
id: (0, _ag_ui_client.randomUUID)(),
|
|
3420
3438
|
role: "tool",
|
|
@@ -3424,7 +3442,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3424
3442
|
try {
|
|
3425
3443
|
return await copilotkit.runAgent({
|
|
3426
3444
|
agent,
|
|
3427
|
-
resume: decision.resume
|
|
3445
|
+
resume: decision.resume,
|
|
3446
|
+
...runId !== void 0 ? { runId } : {}
|
|
3428
3447
|
});
|
|
3429
3448
|
} catch (err) {
|
|
3430
3449
|
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|