@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
|
@@ -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(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|
|
|
22
22
|
export {
|
|
23
23
|
copilotRuntimeNestEndpoint
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
//# sourceMappingURL=chunk-PQG7ZI72.mjs.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
getCommonConfig,
|
|
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";
|
|
@@ -77,4 +77,4 @@ export {
|
|
|
77
77
|
config,
|
|
78
78
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-SE7TPKR2.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
|
-
import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from './langserve-
|
|
2
|
+
import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from './langserve-3e8d0e06.js';
|
|
3
3
|
import { BaseMessageChunk, AIMessage, AIMessageChunk, BaseMessage } from '@langchain/core/messages';
|
|
4
4
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
5
5
|
import { IterableReadableStream, IterableReadableStreamInterface } from '@langchain/core/utils/stream';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from './groq-adapter-
|
|
2
|
-
export { e as CommonConfig, C as CopilotRequestContextProperties, k as CopilotRuntime, j as CopilotRuntimeConstructorParams, f as CopilotRuntimeLogger, i as CopilotRuntimeRequest, b as CreateCopilotRuntimeServerOptions, G as GraphQLContext, L as LogLevel, o as MCPClient, p as MCPEndpointConfig, M as MCPTool, a as addCustomHeaderPlugin, d as buildSchema, s as convertMCPToolsToActions, m as copilotKitEndpoint, c as createContext, h as createLogger, q as extractParametersFromSchema, l as flattenToolCallsNoDuplicates, t as generateMcpToolInstructions, g as getCommonConfig, n as langGraphPlatformEndpoint, r as resolveEndpointType } from './shared-
|
|
1
|
+
export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from './groq-adapter-742818f2.js';
|
|
2
|
+
export { e as CommonConfig, C as CopilotRequestContextProperties, k as CopilotRuntime, j as CopilotRuntimeConstructorParams, f as CopilotRuntimeLogger, i as CopilotRuntimeRequest, b as CreateCopilotRuntimeServerOptions, G as GraphQLContext, L as LogLevel, o as MCPClient, p as MCPEndpointConfig, M as MCPTool, a as addCustomHeaderPlugin, d as buildSchema, s as convertMCPToolsToActions, m as copilotKitEndpoint, c as createContext, h as createLogger, q as extractParametersFromSchema, l as flattenToolCallsNoDuplicates, t as generateMcpToolInstructions, g as getCommonConfig, n as langGraphPlatformEndpoint, r as resolveEndpointType } from './shared-96b46379.js';
|
|
3
3
|
export { CopilotRuntimeServerInstance, config, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint } from './lib/integrations/index.js';
|
|
4
4
|
export { copilotRuntimeNodeHttpEndpoint } from './lib/integrations/node-http/index.js';
|
|
5
5
|
export { copilotRuntimeNodeExpressEndpoint } from './lib/integrations/node-express/index.js';
|
|
6
6
|
export { copilotRuntimeNestEndpoint } from './lib/integrations/nest/index.js';
|
|
7
7
|
export { CustomEventNames, LangGraphAgent, PredictStateTool, State, TextMessageEvents, ToolCallEvents } from './lib/index.js';
|
|
8
8
|
export { GuardrailsValidationFailureResponse, MessageStreamInterruptedResponse, UnknownErrorResponse } from './utils/index.js';
|
|
9
|
-
export { C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse, b as CopilotServiceAdapter, c as RemoteChain, R as RemoteChainParameters } from './langserve-
|
|
9
|
+
export { C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse, b as CopilotServiceAdapter, c as RemoteChain, R as RemoteChainParameters } from './langserve-3e8d0e06.js';
|
|
10
10
|
export { convertServiceAdapterError } from './service-adapters/shared/index.js';
|
|
11
11
|
export { AnthropicAdapter, AnthropicAdapterParams, BedrockAdapter, BedrockAdapterParams, EmptyAdapter, ExperimentalEmptyAdapter, ExperimentalOllamaAdapter } from './service-adapters/index.js';
|
|
12
12
|
import 'openai';
|
package/dist/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.26",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -4848,30 +4848,30 @@ var CopilotRuntime = class {
|
|
|
4848
4848
|
async processRuntimeRequest(request) {
|
|
4849
4849
|
var _a, _b, _c, _d, _e;
|
|
4850
4850
|
const { serviceAdapter, messages: rawMessages, actions: clientSideActionsInput, threadId, runId, outputMessagesPromise, graphqlContext, forwardedParameters, url, extensions, agentSession, agentStates, publicApiKey } = request;
|
|
4851
|
-
const eventSource = new RuntimeEventSource(
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
await this.error("request", {
|
|
4855
|
-
threadId,
|
|
4856
|
-
runId,
|
|
4857
|
-
source: "runtime",
|
|
4858
|
-
request: {
|
|
4859
|
-
operation: "processRuntimeRequest",
|
|
4860
|
-
method: "POST",
|
|
4861
|
-
url,
|
|
4862
|
-
startTime: requestStartTime
|
|
4851
|
+
const eventSource = new RuntimeEventSource({
|
|
4852
|
+
errorHandler: async (error, context) => {
|
|
4853
|
+
await this.error("error", context, error, publicApiKey);
|
|
4863
4854
|
},
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4855
|
+
errorContext: {
|
|
4856
|
+
threadId,
|
|
4857
|
+
runId,
|
|
4858
|
+
source: "runtime",
|
|
4859
|
+
request: {
|
|
4860
|
+
operation: "processRuntimeRequest",
|
|
4861
|
+
method: "POST",
|
|
4862
|
+
url,
|
|
4863
|
+
startTime: Date.now()
|
|
4864
|
+
},
|
|
4865
|
+
agent: agentSession ? {
|
|
4866
|
+
name: agentSession.agentName
|
|
4867
|
+
} : void 0,
|
|
4868
|
+
technical: {
|
|
4869
|
+
environment: process.env.NODE_ENV
|
|
4870
|
+
}
|
|
4873
4871
|
}
|
|
4874
|
-
}
|
|
4872
|
+
});
|
|
4873
|
+
const requestStartTime = Date.now();
|
|
4874
|
+
const streamedChunks = [];
|
|
4875
4875
|
try {
|
|
4876
4876
|
if (Object.keys(this.agents).length && (agentSession == null ? void 0 : agentSession.agentName) && !this.delegateAgentProcessingToServiceAdapter) {
|
|
4877
4877
|
this.agents = {
|
|
@@ -5182,6 +5182,7 @@ please use an LLM adapter instead.`
|
|
|
5182
5182
|
}));
|
|
5183
5183
|
}
|
|
5184
5184
|
async loadAgentState(graphqlContext, threadId, agentName) {
|
|
5185
|
+
var _a;
|
|
5185
5186
|
const agents = await this.getAllAgents(graphqlContext);
|
|
5186
5187
|
const agent = agents.find((agent2) => agent2.name === agentName);
|
|
5187
5188
|
if (!agent) {
|
|
@@ -5262,12 +5263,17 @@ please use an LLM adapter instead.`
|
|
|
5262
5263
|
state = client ? (await client.threads.getState(threadId)).values : {};
|
|
5263
5264
|
} catch (error) {
|
|
5264
5265
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5266
|
+
const errorStatus = ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.status) || (error == null ? void 0 : error.status);
|
|
5267
|
+
if (errorStatus === 404) {
|
|
5268
|
+
state = {};
|
|
5269
|
+
} else {
|
|
5270
|
+
console.debug(`Agent '${agentName}' configuration issue: ${errorMessage}`);
|
|
5271
|
+
throw new import_shared18.ResolvedCopilotKitError({
|
|
5272
|
+
status: 400,
|
|
5273
|
+
message: `Agent '${agentName}' failed to execute: ${errorMessage}`,
|
|
5274
|
+
code: import_shared18.CopilotKitErrorCode.CONFIGURATION_ERROR
|
|
5275
|
+
});
|
|
5276
|
+
}
|
|
5271
5277
|
}
|
|
5272
5278
|
if (Object.keys(state).length === 0) {
|
|
5273
5279
|
return {
|
|
@@ -5363,7 +5369,27 @@ please use an LLM adapter instead.`
|
|
|
5363
5369
|
properties: graphqlContext.properties
|
|
5364
5370
|
}));
|
|
5365
5371
|
try {
|
|
5366
|
-
const eventSource = new RuntimeEventSource(
|
|
5372
|
+
const eventSource = new RuntimeEventSource({
|
|
5373
|
+
errorHandler: async (error, context) => {
|
|
5374
|
+
await this.error("error", context, error, publicApiKey);
|
|
5375
|
+
},
|
|
5376
|
+
errorContext: {
|
|
5377
|
+
threadId,
|
|
5378
|
+
source: "agent",
|
|
5379
|
+
request: {
|
|
5380
|
+
operation: "processAgentRequest",
|
|
5381
|
+
method: "POST",
|
|
5382
|
+
startTime: requestStartTime
|
|
5383
|
+
},
|
|
5384
|
+
agent: {
|
|
5385
|
+
name: agentName,
|
|
5386
|
+
nodeName
|
|
5387
|
+
},
|
|
5388
|
+
technical: {
|
|
5389
|
+
environment: process.env.NODE_ENV
|
|
5390
|
+
}
|
|
5391
|
+
}
|
|
5392
|
+
});
|
|
5367
5393
|
const stream = await currentAgent.remoteAgentHandler({
|
|
5368
5394
|
name: agentName,
|
|
5369
5395
|
threadId,
|
|
@@ -6664,6 +6690,12 @@ __name(RuntimeEventSubject, "RuntimeEventSubject");
|
|
|
6664
6690
|
var RuntimeEventSource = class {
|
|
6665
6691
|
eventStream$ = new RuntimeEventSubject();
|
|
6666
6692
|
callback;
|
|
6693
|
+
errorHandler;
|
|
6694
|
+
errorContext;
|
|
6695
|
+
constructor(params) {
|
|
6696
|
+
this.errorHandler = params == null ? void 0 : params.errorHandler;
|
|
6697
|
+
this.errorContext = params == null ? void 0 : params.errorContext;
|
|
6698
|
+
}
|
|
6667
6699
|
async stream(callback) {
|
|
6668
6700
|
this.callback = callback;
|
|
6669
6701
|
}
|
|
@@ -6678,8 +6710,15 @@ var RuntimeEventSource = class {
|
|
|
6678
6710
|
}
|
|
6679
6711
|
}
|
|
6680
6712
|
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId }) {
|
|
6681
|
-
this.callback(this.eventStream$).catch((error) => {
|
|
6713
|
+
this.callback(this.eventStream$).catch(async (error) => {
|
|
6682
6714
|
const structuredError = (0, import_shared27.ensureStructuredError)(error, convertStreamingErrorToStructured2);
|
|
6715
|
+
if (this.errorHandler && this.errorContext) {
|
|
6716
|
+
try {
|
|
6717
|
+
await this.errorHandler(structuredError, this.errorContext);
|
|
6718
|
+
} catch (errorHandlerError) {
|
|
6719
|
+
console.error("Error in streaming error handler:", errorHandlerError);
|
|
6720
|
+
}
|
|
6721
|
+
}
|
|
6683
6722
|
this.eventStream$.error(structuredError);
|
|
6684
6723
|
this.eventStream$.complete();
|
|
6685
6724
|
});
|
|
@@ -6718,6 +6757,19 @@ var RuntimeEventSource = class {
|
|
|
6718
6757
|
telemetry_client_default.capture("oss.runtime.server_action_executed", {});
|
|
6719
6758
|
return (0, import_rxjs3.concat)((0, import_rxjs3.of)(eventWithState.event), toolCallEventStream$).pipe((0, import_rxjs3.catchError)((error) => {
|
|
6720
6759
|
const structuredError = (0, import_shared27.ensureStructuredError)(error, convertStreamingErrorToStructured2);
|
|
6760
|
+
if (this.errorHandler && this.errorContext) {
|
|
6761
|
+
(0, import_rxjs3.from)(this.errorHandler(structuredError, {
|
|
6762
|
+
...this.errorContext,
|
|
6763
|
+
action: {
|
|
6764
|
+
name: eventWithState.action.name,
|
|
6765
|
+
executionId: eventWithState.actionExecutionId
|
|
6766
|
+
}
|
|
6767
|
+
})).subscribe({
|
|
6768
|
+
error: (errorHandlerError) => {
|
|
6769
|
+
console.error("Error in action execution error handler:", errorHandlerError);
|
|
6770
|
+
}
|
|
6771
|
+
});
|
|
6772
|
+
}
|
|
6721
6773
|
toolCallEventStream$.sendActionExecutionResult({
|
|
6722
6774
|
actionExecutionId: eventWithState.actionExecutionId,
|
|
6723
6775
|
actionName: eventWithState.action.name,
|