@copilotkit/runtime 1.9.2-next.24 → 1.9.2-next.26
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 +16 -0
- package/dist/{chunk-S2YGYQDH.mjs → chunk-3RL34U4Q.mjs} +2 -2
- package/dist/{chunk-FR4C3TPU.mjs → chunk-D7OAY4CQ.mjs} +2 -2
- package/dist/{chunk-GAUZHH2X.mjs → chunk-GRU5EPNU.mjs} +91 -39
- package/dist/chunk-GRU5EPNU.mjs.map +1 -0
- package/dist/{chunk-ECQRTXJX.mjs → chunk-PQG7ZI72.mjs} +2 -2
- package/dist/{chunk-TBVA4IGX.mjs → chunk-SE7TPKR2.mjs} +2 -2
- package/dist/{groq-adapter-098f97f6.d.ts → groq-adapter-742818f2.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +83 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/{langserve-fc5cac89.d.ts → langserve-3e8d0e06.d.ts} +6 -0
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.js +83 -31
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +6 -6
- package/dist/lib/integrations/index.d.ts +3 -3
- 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.d.ts +2 -2
- 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.d.ts +2 -2
- 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.d.ts +2 -2
- 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/dist/service-adapters/index.d.ts +4 -4
- package/dist/{shared-6b6dbf8b.d.ts → shared-96b46379.d.ts} +1 -1
- package/package.json +2 -2
- package/src/lib/runtime/copilot-runtime.ts +46 -28
- package/src/service-adapters/events.ts +40 -1
- package/dist/chunk-GAUZHH2X.mjs.map +0 -1
- /package/dist/{chunk-S2YGYQDH.mjs.map → chunk-3RL34U4Q.mjs.map} +0 -0
- /package/dist/{chunk-FR4C3TPU.mjs.map → chunk-D7OAY4CQ.mjs.map} +0 -0
- /package/dist/{chunk-ECQRTXJX.mjs.map → chunk-PQG7ZI72.mjs.map} +0 -0
- /package/dist/{chunk-TBVA4IGX.mjs.map → chunk-SE7TPKR2.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @copilotkit/runtime
|
|
2
2
|
|
|
3
|
+
## 1.9.2-next.26
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 83822d2: - fix: do not show error on state loading if thread does not exist
|
|
8
|
+
- @copilotkit/shared@1.9.2-next.26
|
|
9
|
+
|
|
10
|
+
## 1.9.2-next.25
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- f3f0181: - fix: connect streaming errors to runtime onError handler
|
|
15
|
+
- remove request logging
|
|
16
|
+
- f3f0181: - fix: connect streaming errors to runtime onError handler
|
|
17
|
+
- @copilotkit/shared@1.9.2-next.25
|
|
18
|
+
|
|
3
19
|
## 1.9.2-next.24
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LangGraphEventTypes
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GRU5EPNU.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__name
|
|
6
6
|
} from "./chunk-FHD4JECV.mjs";
|
|
@@ -155,4 +155,4 @@ export {
|
|
|
155
155
|
CustomEventNames,
|
|
156
156
|
LangGraphAgent
|
|
157
157
|
};
|
|
158
|
-
//# sourceMappingURL=chunk-
|
|
158
|
+
//# sourceMappingURL=chunk-3RL34U4Q.mjs.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
copilotRuntimeNodeHttpEndpoint,
|
|
3
3
|
getRuntimeInstanceTelemetryInfo,
|
|
4
4
|
telemetry_client_default
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GRU5EPNU.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__name
|
|
8
8
|
} from "./chunk-FHD4JECV.mjs";
|
|
@@ -22,4 +22,4 @@ __name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
|
|
|
22
22
|
export {
|
|
23
23
|
copilotRuntimeNodeExpressEndpoint
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
//# sourceMappingURL=chunk-D7OAY4CQ.mjs.map
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActionExecutionMessage,
|
|
3
|
+
AgentStateMessage,
|
|
4
|
+
ImageMessage,
|
|
5
|
+
ResultMessage,
|
|
6
|
+
TextMessage
|
|
7
|
+
} from "./chunk-SHBDMA63.mjs";
|
|
1
8
|
import {
|
|
2
9
|
EmptyAdapter,
|
|
3
10
|
RemoteChain,
|
|
@@ -10,13 +17,6 @@ import {
|
|
|
10
17
|
SuccessResponseStatus,
|
|
11
18
|
UnknownErrorResponse
|
|
12
19
|
} from "./chunk-XWBDEXDA.mjs";
|
|
13
|
-
import {
|
|
14
|
-
ActionExecutionMessage,
|
|
15
|
-
AgentStateMessage,
|
|
16
|
-
ImageMessage,
|
|
17
|
-
ResultMessage,
|
|
18
|
-
TextMessage
|
|
19
|
-
} from "./chunk-SHBDMA63.mjs";
|
|
20
20
|
import {
|
|
21
21
|
BaseMessageInput
|
|
22
22
|
} from "./chunk-2OZAGFV3.mjs";
|
|
@@ -40,7 +40,7 @@ var require_package = __commonJS({
|
|
|
40
40
|
publishConfig: {
|
|
41
41
|
access: "public"
|
|
42
42
|
},
|
|
43
|
-
version: "1.9.2-next.
|
|
43
|
+
version: "1.9.2-next.26",
|
|
44
44
|
sideEffects: false,
|
|
45
45
|
main: "./dist/index.js",
|
|
46
46
|
module: "./dist/index.mjs",
|
|
@@ -2877,30 +2877,30 @@ var CopilotRuntime = class {
|
|
|
2877
2877
|
async processRuntimeRequest(request) {
|
|
2878
2878
|
var _a, _b, _c, _d, _e;
|
|
2879
2879
|
const { serviceAdapter, messages: rawMessages, actions: clientSideActionsInput, threadId, runId, outputMessagesPromise, graphqlContext, forwardedParameters, url, extensions, agentSession, agentStates, publicApiKey } = request;
|
|
2880
|
-
const eventSource = new RuntimeEventSource(
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
await this.error("request", {
|
|
2884
|
-
threadId,
|
|
2885
|
-
runId,
|
|
2886
|
-
source: "runtime",
|
|
2887
|
-
request: {
|
|
2888
|
-
operation: "processRuntimeRequest",
|
|
2889
|
-
method: "POST",
|
|
2890
|
-
url,
|
|
2891
|
-
startTime: requestStartTime
|
|
2880
|
+
const eventSource = new RuntimeEventSource({
|
|
2881
|
+
errorHandler: async (error, context) => {
|
|
2882
|
+
await this.error("error", context, error, publicApiKey);
|
|
2892
2883
|
},
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2884
|
+
errorContext: {
|
|
2885
|
+
threadId,
|
|
2886
|
+
runId,
|
|
2887
|
+
source: "runtime",
|
|
2888
|
+
request: {
|
|
2889
|
+
operation: "processRuntimeRequest",
|
|
2890
|
+
method: "POST",
|
|
2891
|
+
url,
|
|
2892
|
+
startTime: Date.now()
|
|
2893
|
+
},
|
|
2894
|
+
agent: agentSession ? {
|
|
2895
|
+
name: agentSession.agentName
|
|
2896
|
+
} : void 0,
|
|
2897
|
+
technical: {
|
|
2898
|
+
environment: process.env.NODE_ENV
|
|
2899
|
+
}
|
|
2902
2900
|
}
|
|
2903
|
-
}
|
|
2901
|
+
});
|
|
2902
|
+
const requestStartTime = Date.now();
|
|
2903
|
+
const streamedChunks = [];
|
|
2904
2904
|
try {
|
|
2905
2905
|
if (Object.keys(this.agents).length && (agentSession == null ? void 0 : agentSession.agentName) && !this.delegateAgentProcessingToServiceAdapter) {
|
|
2906
2906
|
this.agents = {
|
|
@@ -3211,6 +3211,7 @@ please use an LLM adapter instead.`
|
|
|
3211
3211
|
}));
|
|
3212
3212
|
}
|
|
3213
3213
|
async loadAgentState(graphqlContext, threadId, agentName) {
|
|
3214
|
+
var _a;
|
|
3214
3215
|
const agents = await this.getAllAgents(graphqlContext);
|
|
3215
3216
|
const agent = agents.find((agent2) => agent2.name === agentName);
|
|
3216
3217
|
if (!agent) {
|
|
@@ -3291,12 +3292,17 @@ please use an LLM adapter instead.`
|
|
|
3291
3292
|
state = client ? (await client.threads.getState(threadId)).values : {};
|
|
3292
3293
|
} catch (error) {
|
|
3293
3294
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3295
|
+
const errorStatus = ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.status) || (error == null ? void 0 : error.status);
|
|
3296
|
+
if (errorStatus === 404) {
|
|
3297
|
+
state = {};
|
|
3298
|
+
} else {
|
|
3299
|
+
console.debug(`Agent '${agentName}' configuration issue: ${errorMessage}`);
|
|
3300
|
+
throw new ResolvedCopilotKitError({
|
|
3301
|
+
status: 400,
|
|
3302
|
+
message: `Agent '${agentName}' failed to execute: ${errorMessage}`,
|
|
3303
|
+
code: CopilotKitErrorCode2.CONFIGURATION_ERROR
|
|
3304
|
+
});
|
|
3305
|
+
}
|
|
3300
3306
|
}
|
|
3301
3307
|
if (Object.keys(state).length === 0) {
|
|
3302
3308
|
return {
|
|
@@ -3392,7 +3398,27 @@ please use an LLM adapter instead.`
|
|
|
3392
3398
|
properties: graphqlContext.properties
|
|
3393
3399
|
}));
|
|
3394
3400
|
try {
|
|
3395
|
-
const eventSource = new RuntimeEventSource(
|
|
3401
|
+
const eventSource = new RuntimeEventSource({
|
|
3402
|
+
errorHandler: async (error, context) => {
|
|
3403
|
+
await this.error("error", context, error, publicApiKey);
|
|
3404
|
+
},
|
|
3405
|
+
errorContext: {
|
|
3406
|
+
threadId,
|
|
3407
|
+
source: "agent",
|
|
3408
|
+
request: {
|
|
3409
|
+
operation: "processAgentRequest",
|
|
3410
|
+
method: "POST",
|
|
3411
|
+
startTime: requestStartTime
|
|
3412
|
+
},
|
|
3413
|
+
agent: {
|
|
3414
|
+
name: agentName,
|
|
3415
|
+
nodeName
|
|
3416
|
+
},
|
|
3417
|
+
technical: {
|
|
3418
|
+
environment: process.env.NODE_ENV
|
|
3419
|
+
}
|
|
3420
|
+
}
|
|
3421
|
+
});
|
|
3396
3422
|
const stream = await currentAgent.remoteAgentHandler({
|
|
3397
3423
|
name: agentName,
|
|
3398
3424
|
threadId,
|
|
@@ -4693,6 +4719,12 @@ __name(RuntimeEventSubject, "RuntimeEventSubject");
|
|
|
4693
4719
|
var RuntimeEventSource = class {
|
|
4694
4720
|
eventStream$ = new RuntimeEventSubject();
|
|
4695
4721
|
callback;
|
|
4722
|
+
errorHandler;
|
|
4723
|
+
errorContext;
|
|
4724
|
+
constructor(params) {
|
|
4725
|
+
this.errorHandler = params == null ? void 0 : params.errorHandler;
|
|
4726
|
+
this.errorContext = params == null ? void 0 : params.errorContext;
|
|
4727
|
+
}
|
|
4696
4728
|
async stream(callback) {
|
|
4697
4729
|
this.callback = callback;
|
|
4698
4730
|
}
|
|
@@ -4707,8 +4739,15 @@ var RuntimeEventSource = class {
|
|
|
4707
4739
|
}
|
|
4708
4740
|
}
|
|
4709
4741
|
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId }) {
|
|
4710
|
-
this.callback(this.eventStream$).catch((error) => {
|
|
4742
|
+
this.callback(this.eventStream$).catch(async (error) => {
|
|
4711
4743
|
const structuredError = ensureStructuredError3(error, convertStreamingErrorToStructured2);
|
|
4744
|
+
if (this.errorHandler && this.errorContext) {
|
|
4745
|
+
try {
|
|
4746
|
+
await this.errorHandler(structuredError, this.errorContext);
|
|
4747
|
+
} catch (errorHandlerError) {
|
|
4748
|
+
console.error("Error in streaming error handler:", errorHandlerError);
|
|
4749
|
+
}
|
|
4750
|
+
}
|
|
4712
4751
|
this.eventStream$.error(structuredError);
|
|
4713
4752
|
this.eventStream$.complete();
|
|
4714
4753
|
});
|
|
@@ -4747,6 +4786,19 @@ var RuntimeEventSource = class {
|
|
|
4747
4786
|
telemetry_client_default.capture("oss.runtime.server_action_executed", {});
|
|
4748
4787
|
return concat(of(eventWithState.event), toolCallEventStream$).pipe(catchError2((error) => {
|
|
4749
4788
|
const structuredError = ensureStructuredError3(error, convertStreamingErrorToStructured2);
|
|
4789
|
+
if (this.errorHandler && this.errorContext) {
|
|
4790
|
+
from2(this.errorHandler(structuredError, {
|
|
4791
|
+
...this.errorContext,
|
|
4792
|
+
action: {
|
|
4793
|
+
name: eventWithState.action.name,
|
|
4794
|
+
executionId: eventWithState.actionExecutionId
|
|
4795
|
+
}
|
|
4796
|
+
})).subscribe({
|
|
4797
|
+
error: (errorHandlerError) => {
|
|
4798
|
+
console.error("Error in action execution error handler:", errorHandlerError);
|
|
4799
|
+
}
|
|
4800
|
+
});
|
|
4801
|
+
}
|
|
4750
4802
|
toolCallEventStream$.sendActionExecutionResult({
|
|
4751
4803
|
actionExecutionId: eventWithState.actionExecutionId,
|
|
4752
4804
|
actionName: eventWithState.action.name,
|
|
@@ -5863,4 +5915,4 @@ export {
|
|
|
5863
5915
|
getCommonConfig,
|
|
5864
5916
|
copilotRuntimeNodeHttpEndpoint
|
|
5865
5917
|
};
|
|
5866
|
-
//# sourceMappingURL=chunk-
|
|
5918
|
+
//# sourceMappingURL=chunk-GRU5EPNU.mjs.map
|