@copilotkit/runtime 1.9.2-next.6 → 1.9.2-next.8
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/CHANGELOG.md +14 -0
- package/dist/{chunk-K4JQLKXK.mjs → chunk-4TLMVLU4.mjs} +2 -2
- package/dist/{chunk-6FLO2QTT.mjs → chunk-5SG4WWXH.mjs} +19 -2
- package/dist/chunk-5SG4WWXH.mjs.map +1 -0
- package/dist/{chunk-6AD7VT26.mjs → chunk-JWPSIGSA.mjs} +2 -2
- package/dist/{chunk-JZWHLURE.mjs → chunk-KYCDL2KX.mjs} +2 -2
- package/dist/{chunk-RCIYK6YJ.mjs → chunk-WIXS6EG7.mjs} +47 -38
- package/dist/chunk-WIXS6EG7.mjs.map +1 -0
- package/dist/index.js +58 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js +58 -32
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +6 -6
- package/dist/lib/integrations/index.js +1 -1
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +5 -5
- package/dist/lib/integrations/nest/index.js +1 -1
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +3 -3
- package/dist/lib/integrations/node-express/index.js +1 -1
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +3 -3
- package/dist/lib/integrations/node-http/index.js +1 -1
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +2 -2
- package/package.json +2 -2
- package/src/lib/runtime/langgraph/langgraph-agent.ts +12 -0
- package/src/lib/runtime/remote-lg-action.ts +45 -37
- package/dist/chunk-6FLO2QTT.mjs.map +0 -1
- package/dist/chunk-RCIYK6YJ.mjs.map +0 -1
- /package/dist/{chunk-K4JQLKXK.mjs.map → chunk-4TLMVLU4.mjs.map} +0 -0
- /package/dist/{chunk-6AD7VT26.mjs.map → chunk-JWPSIGSA.mjs.map} +0 -0
- /package/dist/{chunk-JZWHLURE.mjs.map → chunk-KYCDL2KX.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CustomEventNames,
|
|
3
3
|
LangGraphAgent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5SG4WWXH.mjs";
|
|
5
5
|
import {
|
|
6
6
|
config,
|
|
7
7
|
copilotRuntimeNextJSAppRouterEndpoint,
|
|
8
8
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JWPSIGSA.mjs";
|
|
10
10
|
import {
|
|
11
11
|
copilotRuntimeNestEndpoint
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-4TLMVLU4.mjs";
|
|
13
13
|
import {
|
|
14
14
|
copilotRuntimeNodeExpressEndpoint
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-KYCDL2KX.mjs";
|
|
16
16
|
import {
|
|
17
17
|
CopilotRuntime,
|
|
18
18
|
addCustomHeaderPlugin,
|
|
@@ -28,12 +28,7 @@ import {
|
|
|
28
28
|
getCommonConfig,
|
|
29
29
|
langGraphPlatformEndpoint,
|
|
30
30
|
resolveEndpointType
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import {
|
|
33
|
-
GuardrailsValidationFailureResponse,
|
|
34
|
-
MessageStreamInterruptedResponse,
|
|
35
|
-
UnknownErrorResponse
|
|
36
|
-
} from "./chunk-5BIEM2UU.mjs";
|
|
31
|
+
} from "./chunk-WIXS6EG7.mjs";
|
|
37
32
|
import {
|
|
38
33
|
AnthropicAdapter,
|
|
39
34
|
BedrockAdapter,
|
|
@@ -48,6 +43,11 @@ import {
|
|
|
48
43
|
RemoteChain,
|
|
49
44
|
UnifyAdapter
|
|
50
45
|
} from "./chunk-IIXJVVTV.mjs";
|
|
46
|
+
import {
|
|
47
|
+
GuardrailsValidationFailureResponse,
|
|
48
|
+
MessageStreamInterruptedResponse,
|
|
49
|
+
UnknownErrorResponse
|
|
50
|
+
} from "./chunk-5BIEM2UU.mjs";
|
|
51
51
|
import "./chunk-SHBDMA63.mjs";
|
|
52
52
|
import "./chunk-2OZAGFV3.mjs";
|
|
53
53
|
import "./chunk-FHD4JECV.mjs";
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { copilotRuntimeNodeExpressEndpoint } from './integrations/node-express/i
|
|
|
6
6
|
export { copilotRuntimeNestEndpoint } from './integrations/nest/index.js';
|
|
7
7
|
import * as rxjs from 'rxjs';
|
|
8
8
|
import { TextMessageStartEvent, TextMessageContentEvent, TextMessageEndEvent, ToolCallStartEvent, ToolCallArgsEvent, ToolCallEndEvent, RunAgentInput } from '@ag-ui/client';
|
|
9
|
-
import { LangGraphAgent as LangGraphAgent$1, LangGraphAgentConfig, ProcessedEvents } from '@ag-ui/langgraph';
|
|
9
|
+
import { LangGraphAgent as LangGraphAgent$1, LangGraphAgentConfig, ProcessedEvents, SchemaKeys } from '@ag-ui/langgraph';
|
|
10
10
|
import { Message } from '@langchain/langgraph-sdk/dist/types.messages';
|
|
11
11
|
import 'openai';
|
|
12
12
|
import '../langserve-4a5c9217.js';
|
|
@@ -41,6 +41,7 @@ declare class LangGraphAgent extends LangGraphAgent$1 {
|
|
|
41
41
|
dispatchEvent(event: ProcessedEvents): boolean;
|
|
42
42
|
run(input: RunAgentInput): rxjs.Observable<any>;
|
|
43
43
|
langGraphDefaultMergeState(state: State, messages: Message[], tools: any): State;
|
|
44
|
+
getSchemaKeys(): Promise<SchemaKeys>;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
export { CustomEventNames, LangGraphAgent, PredictStateTool, State, TextMessageEvents, ToolCallEvents };
|
package/dist/lib/index.js
CHANGED
|
@@ -44,7 +44,7 @@ var require_package = __commonJS({
|
|
|
44
44
|
publishConfig: {
|
|
45
45
|
access: "public"
|
|
46
46
|
},
|
|
47
|
-
version: "1.9.2-next.
|
|
47
|
+
version: "1.9.2-next.8",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -3100,7 +3100,6 @@ async function fetchWithRetry(url, options, logger2) {
|
|
|
3100
3100
|
__name(fetchWithRetry, "fetchWithRetry");
|
|
3101
3101
|
|
|
3102
3102
|
// src/lib/runtime/remote-lg-action.ts
|
|
3103
|
-
var activeInterruptEvent = false;
|
|
3104
3103
|
async function execute(args) {
|
|
3105
3104
|
return new ReadableStream({
|
|
3106
3105
|
async start(controller) {
|
|
@@ -3143,7 +3142,7 @@ async function execute(args) {
|
|
|
3143
3142
|
}
|
|
3144
3143
|
__name(execute, "execute");
|
|
3145
3144
|
async function streamEvents(controller, args) {
|
|
3146
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3145
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3147
3146
|
const { deploymentUrl, langsmithApiKey, threadId: argsInitialThreadId, agent, nodeName: initialNodeName, state: initialState, config: explicitConfig, messages, actions, logger: logger2, properties, metaEvents } = args;
|
|
3148
3147
|
let nodeName = initialNodeName;
|
|
3149
3148
|
let state = initialState;
|
|
@@ -3201,18 +3200,14 @@ async function streamEvents(controller, args) {
|
|
|
3201
3200
|
command: void 0
|
|
3202
3201
|
};
|
|
3203
3202
|
const lgInterruptMetaEvent = metaEvents == null ? void 0 : metaEvents.find((ev) => ev.name === MetaEventName.LangGraphInterruptEvent);
|
|
3204
|
-
if (activeInterruptEvent && !lgInterruptMetaEvent) {
|
|
3205
|
-
payload.command = {
|
|
3206
|
-
resume: state.messages
|
|
3207
|
-
};
|
|
3208
|
-
}
|
|
3209
3203
|
if (lgInterruptMetaEvent == null ? void 0 : lgInterruptMetaEvent.response) {
|
|
3210
3204
|
let response = lgInterruptMetaEvent.response;
|
|
3211
3205
|
payload.command = {
|
|
3212
3206
|
resume: (0, import_shared9.parseJson)(response, response)
|
|
3213
3207
|
};
|
|
3214
3208
|
}
|
|
3215
|
-
|
|
3209
|
+
const interrupts = ((_b = (_a = agentState.tasks) == null ? void 0 : _a[0]) == null ? void 0 : _b.interrupts) ?? [];
|
|
3210
|
+
if (mode === "continue" && !interrupts.length) {
|
|
3216
3211
|
await client.threads.updateState(threadId, {
|
|
3217
3212
|
values: state,
|
|
3218
3213
|
asNode: nodeName
|
|
@@ -3274,12 +3269,23 @@ async function streamEvents(controller, args) {
|
|
|
3274
3269
|
let emitIntermediateStateUntilEnd = null;
|
|
3275
3270
|
let shouldExit = false;
|
|
3276
3271
|
let externalRunId = null;
|
|
3277
|
-
const streamResponse = client.runs.stream(threadId, assistantId, payload);
|
|
3278
3272
|
const emit = /* @__PURE__ */ __name((message) => controller.enqueue(new TextEncoder().encode(message)), "emit");
|
|
3273
|
+
if ((interrupts == null ? void 0 : interrupts.length) && !((_c = payload.command) == null ? void 0 : _c.resume)) {
|
|
3274
|
+
if (!lgInterruptMetaEvent) {
|
|
3275
|
+
payload.command = {
|
|
3276
|
+
resume: state.messages
|
|
3277
|
+
};
|
|
3278
|
+
} else {
|
|
3279
|
+
interrupts.forEach((interrupt) => {
|
|
3280
|
+
emitInterrupt(interrupt.value, emit);
|
|
3281
|
+
});
|
|
3282
|
+
return Promise.resolve();
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
const streamResponse = client.runs.stream(threadId, assistantId, payload);
|
|
3279
3286
|
let latestStateValues = {};
|
|
3280
3287
|
let updatedState = state;
|
|
3281
3288
|
let manuallyEmittedState = null;
|
|
3282
|
-
activeInterruptEvent = false;
|
|
3283
3289
|
try {
|
|
3284
3290
|
telemetry_client_default.capture("oss.runtime.agent_execution_stream_started", {
|
|
3285
3291
|
hashedLgcKey: streamInfo.hashedLgcKey
|
|
@@ -3298,23 +3304,8 @@ async function streamEvents(controller, args) {
|
|
|
3298
3304
|
const chunk = streamResponseChunk;
|
|
3299
3305
|
const interruptEvents = chunk.data.__interrupt__;
|
|
3300
3306
|
if (interruptEvents == null ? void 0 : interruptEvents.length) {
|
|
3301
|
-
activeInterruptEvent = true;
|
|
3302
3307
|
const interruptValue = interruptEvents == null ? void 0 : interruptEvents[0].value;
|
|
3303
|
-
|
|
3304
|
-
const evValue = interruptValue.__copilotkit_interrupt_value__;
|
|
3305
|
-
emit(JSON.stringify({
|
|
3306
|
-
event: LangGraphEventTypes.OnCopilotKitInterrupt,
|
|
3307
|
-
data: {
|
|
3308
|
-
value: typeof evValue === "string" ? evValue : JSON.stringify(evValue),
|
|
3309
|
-
messages: langchainMessagesToCopilotKit(interruptValue.__copilotkit_messages__)
|
|
3310
|
-
}
|
|
3311
|
-
}) + "\n");
|
|
3312
|
-
} else {
|
|
3313
|
-
emit(JSON.stringify({
|
|
3314
|
-
event: LangGraphEventTypes.OnInterrupt,
|
|
3315
|
-
value: typeof interruptValue === "string" ? interruptValue : JSON.stringify(interruptValue)
|
|
3316
|
-
}) + "\n");
|
|
3317
|
-
}
|
|
3308
|
+
emitInterrupt(interruptValue, emit);
|
|
3318
3309
|
continue;
|
|
3319
3310
|
}
|
|
3320
3311
|
if (streamResponseChunk.event === "updates")
|
|
@@ -3329,8 +3320,8 @@ async function streamEvents(controller, args) {
|
|
|
3329
3320
|
const runId = chunkData.metadata.run_id;
|
|
3330
3321
|
externalRunId = runId;
|
|
3331
3322
|
const metadata = chunkData.metadata;
|
|
3332
|
-
if (((
|
|
3333
|
-
streamInfo.provider = (
|
|
3323
|
+
if (((_e = (_d = chunkData.data) == null ? void 0 : _d.output) == null ? void 0 : _e.model) != null && ((_g = (_f = chunkData.data) == null ? void 0 : _f.output) == null ? void 0 : _g.model) != "") {
|
|
3324
|
+
streamInfo.provider = (_i = (_h = chunkData.data) == null ? void 0 : _h.output) == null ? void 0 : _i.model;
|
|
3334
3325
|
}
|
|
3335
3326
|
if (metadata.langgraph_host != null && metadata.langgraph_host != "") {
|
|
3336
3327
|
streamInfo.langGraphHost = metadata.langgraph_host;
|
|
@@ -3401,9 +3392,9 @@ async function streamEvents(controller, args) {
|
|
|
3401
3392
|
emit(JSON.stringify(chunkData) + "\n");
|
|
3402
3393
|
}
|
|
3403
3394
|
state = await client.threads.getState(threadId);
|
|
3404
|
-
const
|
|
3405
|
-
nodeName =
|
|
3406
|
-
const isEndNode = state.next.length === 0 && !
|
|
3395
|
+
const interrupts2 = (_k = (_j = state.tasks) == null ? void 0 : _j[0]) == null ? void 0 : _k.interrupts;
|
|
3396
|
+
nodeName = interrupts2 ? nodeName : Object.keys(state.metadata.writes)[0];
|
|
3397
|
+
const isEndNode = state.next.length === 0 && !interrupts2;
|
|
3407
3398
|
telemetry_client_default.capture("oss.runtime.agent_execution_stream_ended", streamInfo);
|
|
3408
3399
|
emit(getStateSyncEvent({
|
|
3409
3400
|
threadId,
|
|
@@ -3735,6 +3726,24 @@ function filterObjectBySchemaKeys(obj, schemaKeys) {
|
|
|
3735
3726
|
return Object.fromEntries(Object.entries(obj).filter(([key]) => schemaKeys.includes(key)));
|
|
3736
3727
|
}
|
|
3737
3728
|
__name(filterObjectBySchemaKeys, "filterObjectBySchemaKeys");
|
|
3729
|
+
function emitInterrupt(interruptValue, emit) {
|
|
3730
|
+
if (typeof interruptValue != "string" && "__copilotkit_interrupt_value__" in interruptValue) {
|
|
3731
|
+
const evValue = interruptValue.__copilotkit_interrupt_value__;
|
|
3732
|
+
emit(JSON.stringify({
|
|
3733
|
+
event: LangGraphEventTypes.OnCopilotKitInterrupt,
|
|
3734
|
+
data: {
|
|
3735
|
+
value: typeof evValue === "string" ? evValue : JSON.stringify(evValue),
|
|
3736
|
+
messages: langchainMessagesToCopilotKit(interruptValue.__copilotkit_messages__)
|
|
3737
|
+
}
|
|
3738
|
+
}) + "\n");
|
|
3739
|
+
} else {
|
|
3740
|
+
emit(JSON.stringify({
|
|
3741
|
+
event: LangGraphEventTypes.OnInterrupt,
|
|
3742
|
+
value: typeof interruptValue === "string" ? interruptValue : JSON.stringify(interruptValue)
|
|
3743
|
+
}) + "\n");
|
|
3744
|
+
}
|
|
3745
|
+
}
|
|
3746
|
+
__name(emitInterrupt, "emitInterrupt");
|
|
3738
3747
|
|
|
3739
3748
|
// src/lib/runtime/remote-action-constructors.ts
|
|
3740
3749
|
var import_shared11 = require("@copilotkit/shared");
|
|
@@ -7255,6 +7264,23 @@ var LangGraphAgent = class extends import_langgraph.LangGraphAgent {
|
|
|
7255
7264
|
}
|
|
7256
7265
|
};
|
|
7257
7266
|
}
|
|
7267
|
+
async getSchemaKeys() {
|
|
7268
|
+
const CONSTANT_KEYS = [
|
|
7269
|
+
"copilotkit"
|
|
7270
|
+
];
|
|
7271
|
+
const schemaKeys = await super.getSchemaKeys();
|
|
7272
|
+
return {
|
|
7273
|
+
config: schemaKeys.config,
|
|
7274
|
+
input: schemaKeys.input ? [
|
|
7275
|
+
...schemaKeys.input,
|
|
7276
|
+
...CONSTANT_KEYS
|
|
7277
|
+
] : null,
|
|
7278
|
+
output: schemaKeys.output ? [
|
|
7279
|
+
...schemaKeys.output,
|
|
7280
|
+
...CONSTANT_KEYS
|
|
7281
|
+
] : null
|
|
7282
|
+
};
|
|
7283
|
+
}
|
|
7258
7284
|
};
|
|
7259
7285
|
__name(LangGraphAgent, "LangGraphAgent");
|
|
7260
7286
|
// Annotate the CommonJS export names for ESM import in node:
|