@copilotkit/runtime 1.9.2-next.24 → 1.9.2-next.25
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 +9 -0
- package/dist/{chunk-FR4C3TPU.mjs → chunk-3JXN25PL.mjs} +2 -2
- package/dist/{chunk-ECQRTXJX.mjs → chunk-BNLL5CH2.mjs} +2 -2
- package/dist/{chunk-S2YGYQDH.mjs → chunk-DOXGUQKL.mjs} +2 -2
- package/dist/{chunk-TBVA4IGX.mjs → chunk-GJWXNXSA.mjs} +2 -2
- package/dist/{chunk-GAUZHH2X.mjs → chunk-YKYBGYYL.mjs} +79 -33
- package/dist/chunk-YKYBGYYL.mjs.map +1 -0
- 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 +71 -25
- 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 +71 -25
- 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 +32 -19
- package/src/service-adapters/events.ts +40 -1
- package/dist/chunk-GAUZHH2X.mjs.map +0 -1
- /package/dist/{chunk-FR4C3TPU.mjs.map → chunk-3JXN25PL.mjs.map} +0 -0
- /package/dist/{chunk-ECQRTXJX.mjs.map → chunk-BNLL5CH2.mjs.map} +0 -0
- /package/dist/{chunk-S2YGYQDH.mjs.map → chunk-DOXGUQKL.mjs.map} +0 -0
- /package/dist/{chunk-TBVA4IGX.mjs.map → chunk-GJWXNXSA.mjs.map} +0 -0
|
@@ -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.25",
|
|
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
|
|
4863
|
-
},
|
|
4864
|
-
agent: agentSession ? {
|
|
4865
|
-
name: agentSession.agentName
|
|
4866
|
-
} : void 0,
|
|
4867
|
-
messages: {
|
|
4868
|
-
input: rawMessages,
|
|
4869
|
-
messageCount: rawMessages.length
|
|
4851
|
+
const eventSource = new RuntimeEventSource({
|
|
4852
|
+
errorHandler: async (error, context) => {
|
|
4853
|
+
await this.error("error", context, error, publicApiKey);
|
|
4870
4854
|
},
|
|
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 = {
|
|
@@ -5363,7 +5363,27 @@ please use an LLM adapter instead.`
|
|
|
5363
5363
|
properties: graphqlContext.properties
|
|
5364
5364
|
}));
|
|
5365
5365
|
try {
|
|
5366
|
-
const eventSource = new RuntimeEventSource(
|
|
5366
|
+
const eventSource = new RuntimeEventSource({
|
|
5367
|
+
errorHandler: async (error, context) => {
|
|
5368
|
+
await this.error("error", context, error, publicApiKey);
|
|
5369
|
+
},
|
|
5370
|
+
errorContext: {
|
|
5371
|
+
threadId,
|
|
5372
|
+
source: "agent",
|
|
5373
|
+
request: {
|
|
5374
|
+
operation: "processAgentRequest",
|
|
5375
|
+
method: "POST",
|
|
5376
|
+
startTime: requestStartTime
|
|
5377
|
+
},
|
|
5378
|
+
agent: {
|
|
5379
|
+
name: agentName,
|
|
5380
|
+
nodeName
|
|
5381
|
+
},
|
|
5382
|
+
technical: {
|
|
5383
|
+
environment: process.env.NODE_ENV
|
|
5384
|
+
}
|
|
5385
|
+
}
|
|
5386
|
+
});
|
|
5367
5387
|
const stream = await currentAgent.remoteAgentHandler({
|
|
5368
5388
|
name: agentName,
|
|
5369
5389
|
threadId,
|
|
@@ -6664,6 +6684,12 @@ __name(RuntimeEventSubject, "RuntimeEventSubject");
|
|
|
6664
6684
|
var RuntimeEventSource = class {
|
|
6665
6685
|
eventStream$ = new RuntimeEventSubject();
|
|
6666
6686
|
callback;
|
|
6687
|
+
errorHandler;
|
|
6688
|
+
errorContext;
|
|
6689
|
+
constructor(params) {
|
|
6690
|
+
this.errorHandler = params == null ? void 0 : params.errorHandler;
|
|
6691
|
+
this.errorContext = params == null ? void 0 : params.errorContext;
|
|
6692
|
+
}
|
|
6667
6693
|
async stream(callback) {
|
|
6668
6694
|
this.callback = callback;
|
|
6669
6695
|
}
|
|
@@ -6678,8 +6704,15 @@ var RuntimeEventSource = class {
|
|
|
6678
6704
|
}
|
|
6679
6705
|
}
|
|
6680
6706
|
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId }) {
|
|
6681
|
-
this.callback(this.eventStream$).catch((error) => {
|
|
6707
|
+
this.callback(this.eventStream$).catch(async (error) => {
|
|
6682
6708
|
const structuredError = (0, import_shared27.ensureStructuredError)(error, convertStreamingErrorToStructured2);
|
|
6709
|
+
if (this.errorHandler && this.errorContext) {
|
|
6710
|
+
try {
|
|
6711
|
+
await this.errorHandler(structuredError, this.errorContext);
|
|
6712
|
+
} catch (errorHandlerError) {
|
|
6713
|
+
console.error("Error in streaming error handler:", errorHandlerError);
|
|
6714
|
+
}
|
|
6715
|
+
}
|
|
6683
6716
|
this.eventStream$.error(structuredError);
|
|
6684
6717
|
this.eventStream$.complete();
|
|
6685
6718
|
});
|
|
@@ -6718,6 +6751,19 @@ var RuntimeEventSource = class {
|
|
|
6718
6751
|
telemetry_client_default.capture("oss.runtime.server_action_executed", {});
|
|
6719
6752
|
return (0, import_rxjs3.concat)((0, import_rxjs3.of)(eventWithState.event), toolCallEventStream$).pipe((0, import_rxjs3.catchError)((error) => {
|
|
6720
6753
|
const structuredError = (0, import_shared27.ensureStructuredError)(error, convertStreamingErrorToStructured2);
|
|
6754
|
+
if (this.errorHandler && this.errorContext) {
|
|
6755
|
+
(0, import_rxjs3.from)(this.errorHandler(structuredError, {
|
|
6756
|
+
...this.errorContext,
|
|
6757
|
+
action: {
|
|
6758
|
+
name: eventWithState.action.name,
|
|
6759
|
+
executionId: eventWithState.actionExecutionId
|
|
6760
|
+
}
|
|
6761
|
+
})).subscribe({
|
|
6762
|
+
error: (errorHandlerError) => {
|
|
6763
|
+
console.error("Error in action execution error handler:", errorHandlerError);
|
|
6764
|
+
}
|
|
6765
|
+
});
|
|
6766
|
+
}
|
|
6721
6767
|
toolCallEventStream$.sendActionExecutionResult({
|
|
6722
6768
|
actionExecutionId: eventWithState.actionExecutionId,
|
|
6723
6769
|
actionName: eventWithState.action.name,
|