@copilotkit/runtime 1.9.2-next.23 → 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 +16 -0
- package/dist/{chunk-ZQUGWRVU.mjs → chunk-3JXN25PL.mjs} +2 -2
- package/dist/{chunk-LYXJJDV3.mjs → chunk-BNLL5CH2.mjs} +2 -2
- package/dist/{chunk-C6PCDSTD.mjs → chunk-DOXGUQKL.mjs} +2 -2
- package/dist/{chunk-HZW6X63M.mjs → chunk-GJWXNXSA.mjs} +2 -2
- package/dist/{chunk-FIA5HRU2.mjs → chunk-YKYBGYYL.mjs} +81 -35
- 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 +80 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{langserve-fc5cac89.d.ts → langserve-3e8d0e06.d.ts} +6 -0
- package/dist/lib/index.d.ts +155 -5
- package/dist/lib/index.js +80 -34
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +5 -5
- package/dist/lib/integrations/index.d.ts +3 -3
- package/dist/lib/integrations/index.js +10 -10
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +4 -4
- package/dist/lib/integrations/nest/index.d.ts +2 -2
- package/dist/lib/integrations/nest/index.js +10 -10
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +2 -2
- package/dist/lib/integrations/node-express/index.d.ts +2 -2
- package/dist/lib/integrations/node-express/index.js +10 -10
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +2 -2
- package/dist/lib/integrations/node-http/index.d.ts +2 -2
- package/dist/lib/integrations/node-http/index.js +10 -10
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/dist/service-adapters/index.d.ts +4 -4
- package/dist/{shared-6b6dbf8b.d.ts → shared-96b46379.d.ts} +1 -1
- package/package.json +11 -11
- package/src/lib/runtime/copilot-runtime.ts +32 -19
- package/src/service-adapters/events.ts +40 -1
- package/dist/chunk-FIA5HRU2.mjs.map +0 -1
- /package/dist/{chunk-ZQUGWRVU.mjs.map → chunk-3JXN25PL.mjs.map} +0 -0
- /package/dist/{chunk-LYXJJDV3.mjs.map → chunk-BNLL5CH2.mjs.map} +0 -0
- /package/dist/{chunk-C6PCDSTD.mjs.map → chunk-DOXGUQKL.mjs.map} +0 -0
- /package/dist/{chunk-HZW6X63M.mjs.map → chunk-GJWXNXSA.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-DOXGUQKL.mjs";
|
|
5
5
|
import {
|
|
6
6
|
config,
|
|
7
7
|
copilotRuntimeNextJSAppRouterEndpoint,
|
|
8
8
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GJWXNXSA.mjs";
|
|
10
10
|
import {
|
|
11
11
|
copilotRuntimeNestEndpoint
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BNLL5CH2.mjs";
|
|
13
13
|
import {
|
|
14
14
|
copilotRuntimeNodeExpressEndpoint
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-3JXN25PL.mjs";
|
|
16
16
|
import {
|
|
17
17
|
CopilotRuntime,
|
|
18
18
|
addCustomHeaderPlugin,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
getCommonConfig,
|
|
29
29
|
langGraphPlatformEndpoint,
|
|
30
30
|
resolveEndpointType
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-YKYBGYYL.mjs";
|
|
32
32
|
import "./chunk-SHBDMA63.mjs";
|
|
33
33
|
import {
|
|
34
34
|
AnthropicAdapter,
|
|
@@ -146,6 +146,12 @@ declare class RuntimeEventSubject extends ReplaySubject<RuntimeEvent> {
|
|
|
146
146
|
declare class RuntimeEventSource {
|
|
147
147
|
private eventStream$;
|
|
148
148
|
private callback;
|
|
149
|
+
private errorHandler?;
|
|
150
|
+
private errorContext?;
|
|
151
|
+
constructor(params?: {
|
|
152
|
+
errorHandler?: (error: any, context: any) => Promise<void>;
|
|
153
|
+
errorContext?: any;
|
|
154
|
+
});
|
|
149
155
|
stream(callback: EventSourceCallback): Promise<void>;
|
|
150
156
|
sendErrorMessageToChat(message?: string): void;
|
|
151
157
|
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId, }: {
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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 './integrations/index.js';
|
|
4
4
|
export { copilotRuntimeNodeHttpEndpoint } from './integrations/node-http/index.js';
|
|
5
5
|
export { copilotRuntimeNodeExpressEndpoint } from './integrations/node-express/index.js';
|
|
6
6
|
export { copilotRuntimeNestEndpoint } from './integrations/nest/index.js';
|
|
7
7
|
import * as rxjs from 'rxjs';
|
|
8
|
-
import { TextMessageStartEvent, TextMessageContentEvent, TextMessageEndEvent, ToolCallStartEvent, ToolCallArgsEvent, ToolCallEndEvent, RunAgentInput } from '@ag-ui/client';
|
|
8
|
+
import { TextMessageStartEvent, TextMessageContentEvent, TextMessageEndEvent, ToolCallStartEvent, ToolCallArgsEvent, ToolCallEndEvent, RunAgentInput, EventType } from '@ag-ui/client';
|
|
9
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
|
-
import '../langserve-
|
|
12
|
+
import '../langserve-3e8d0e06.js';
|
|
13
13
|
import '../index-d4614f9b.js';
|
|
14
14
|
import '../graphql/types/base/index.js';
|
|
15
15
|
import '@copilotkit/shared';
|
|
@@ -39,7 +39,157 @@ declare enum CustomEventNames {
|
|
|
39
39
|
declare class LangGraphAgent extends LangGraphAgent$1 {
|
|
40
40
|
constructor(config: LangGraphAgentConfig);
|
|
41
41
|
dispatchEvent(event: ProcessedEvents): boolean;
|
|
42
|
-
run(input: RunAgentInput): rxjs.Observable<
|
|
42
|
+
run(input: RunAgentInput): rxjs.Observable<{
|
|
43
|
+
type: EventType.TEXT_MESSAGE_START;
|
|
44
|
+
role: "assistant";
|
|
45
|
+
messageId: string;
|
|
46
|
+
timestamp?: number | undefined;
|
|
47
|
+
rawEvent?: any;
|
|
48
|
+
} | {
|
|
49
|
+
type: EventType.TEXT_MESSAGE_CONTENT;
|
|
50
|
+
messageId: string;
|
|
51
|
+
delta: string;
|
|
52
|
+
timestamp?: number | undefined;
|
|
53
|
+
rawEvent?: any;
|
|
54
|
+
} | {
|
|
55
|
+
type: EventType.TEXT_MESSAGE_END;
|
|
56
|
+
messageId: string;
|
|
57
|
+
timestamp?: number | undefined;
|
|
58
|
+
rawEvent?: any;
|
|
59
|
+
} | {
|
|
60
|
+
type: EventType.TOOL_CALL_START;
|
|
61
|
+
toolCallId: string;
|
|
62
|
+
toolCallName: string;
|
|
63
|
+
timestamp?: number | undefined;
|
|
64
|
+
rawEvent?: any;
|
|
65
|
+
parentMessageId?: string | undefined;
|
|
66
|
+
} | {
|
|
67
|
+
type: EventType.TOOL_CALL_ARGS;
|
|
68
|
+
toolCallId: string;
|
|
69
|
+
delta: string;
|
|
70
|
+
timestamp?: number | undefined;
|
|
71
|
+
rawEvent?: any;
|
|
72
|
+
} | {
|
|
73
|
+
type: EventType.TOOL_CALL_END;
|
|
74
|
+
toolCallId: string;
|
|
75
|
+
timestamp?: number | undefined;
|
|
76
|
+
rawEvent?: any;
|
|
77
|
+
} | {
|
|
78
|
+
type: EventType.THINKING_TEXT_MESSAGE_START;
|
|
79
|
+
timestamp?: number | undefined;
|
|
80
|
+
rawEvent?: any;
|
|
81
|
+
} | {
|
|
82
|
+
type: EventType.THINKING_TEXT_MESSAGE_CONTENT;
|
|
83
|
+
delta: string;
|
|
84
|
+
timestamp?: number | undefined;
|
|
85
|
+
rawEvent?: any;
|
|
86
|
+
} | {
|
|
87
|
+
type: EventType.THINKING_TEXT_MESSAGE_END;
|
|
88
|
+
timestamp?: number | undefined;
|
|
89
|
+
rawEvent?: any;
|
|
90
|
+
} | {
|
|
91
|
+
type: EventType.THINKING_START;
|
|
92
|
+
timestamp?: number | undefined;
|
|
93
|
+
rawEvent?: any;
|
|
94
|
+
title?: string | undefined;
|
|
95
|
+
} | {
|
|
96
|
+
type: EventType.THINKING_END;
|
|
97
|
+
timestamp?: number | undefined;
|
|
98
|
+
rawEvent?: any;
|
|
99
|
+
} | {
|
|
100
|
+
type: EventType.STATE_SNAPSHOT;
|
|
101
|
+
timestamp?: number | undefined;
|
|
102
|
+
rawEvent?: any;
|
|
103
|
+
snapshot?: any;
|
|
104
|
+
} | {
|
|
105
|
+
type: EventType.STATE_DELTA;
|
|
106
|
+
delta: any[];
|
|
107
|
+
timestamp?: number | undefined;
|
|
108
|
+
rawEvent?: any;
|
|
109
|
+
} | {
|
|
110
|
+
type: EventType.MESSAGES_SNAPSHOT;
|
|
111
|
+
messages: ({
|
|
112
|
+
id: string;
|
|
113
|
+
role: "developer";
|
|
114
|
+
content: string;
|
|
115
|
+
name?: string | undefined;
|
|
116
|
+
} | {
|
|
117
|
+
id: string;
|
|
118
|
+
role: "system";
|
|
119
|
+
content: string;
|
|
120
|
+
name?: string | undefined;
|
|
121
|
+
} | {
|
|
122
|
+
id: string;
|
|
123
|
+
role: "assistant";
|
|
124
|
+
name?: string | undefined;
|
|
125
|
+
content?: string | undefined;
|
|
126
|
+
toolCalls?: {
|
|
127
|
+
function: {
|
|
128
|
+
name: string;
|
|
129
|
+
arguments: string;
|
|
130
|
+
};
|
|
131
|
+
type: "function";
|
|
132
|
+
id: string;
|
|
133
|
+
}[] | undefined;
|
|
134
|
+
} | {
|
|
135
|
+
id: string;
|
|
136
|
+
role: "user";
|
|
137
|
+
content: string;
|
|
138
|
+
name?: string | undefined;
|
|
139
|
+
} | {
|
|
140
|
+
id: string;
|
|
141
|
+
role: "tool";
|
|
142
|
+
content: string;
|
|
143
|
+
toolCallId: string;
|
|
144
|
+
})[];
|
|
145
|
+
timestamp?: number | undefined;
|
|
146
|
+
rawEvent?: any;
|
|
147
|
+
} | {
|
|
148
|
+
type: EventType.RAW;
|
|
149
|
+
timestamp?: number | undefined;
|
|
150
|
+
rawEvent?: any;
|
|
151
|
+
event?: any;
|
|
152
|
+
source?: string | undefined;
|
|
153
|
+
} | {
|
|
154
|
+
name: string;
|
|
155
|
+
type: EventType.CUSTOM;
|
|
156
|
+
value?: any;
|
|
157
|
+
timestamp?: number | undefined;
|
|
158
|
+
rawEvent?: any;
|
|
159
|
+
} | {
|
|
160
|
+
type: EventType.RUN_STARTED;
|
|
161
|
+
threadId: string;
|
|
162
|
+
runId: string;
|
|
163
|
+
timestamp?: number | undefined;
|
|
164
|
+
rawEvent?: any;
|
|
165
|
+
} | {
|
|
166
|
+
type: EventType.RUN_FINISHED;
|
|
167
|
+
threadId: string;
|
|
168
|
+
runId: string;
|
|
169
|
+
timestamp?: number | undefined;
|
|
170
|
+
rawEvent?: any;
|
|
171
|
+
result?: any;
|
|
172
|
+
} | {
|
|
173
|
+
message: string;
|
|
174
|
+
type: EventType.RUN_ERROR;
|
|
175
|
+
code?: string | undefined;
|
|
176
|
+
timestamp?: number | undefined;
|
|
177
|
+
rawEvent?: any;
|
|
178
|
+
} | {
|
|
179
|
+
type: EventType.STEP_STARTED;
|
|
180
|
+
stepName: string;
|
|
181
|
+
timestamp?: number | undefined;
|
|
182
|
+
rawEvent?: any;
|
|
183
|
+
} | {
|
|
184
|
+
type: EventType.STEP_FINISHED;
|
|
185
|
+
stepName: string;
|
|
186
|
+
timestamp?: number | undefined;
|
|
187
|
+
rawEvent?: any;
|
|
188
|
+
} | {
|
|
189
|
+
type: EventType;
|
|
190
|
+
name: string;
|
|
191
|
+
value: any;
|
|
192
|
+
}>;
|
|
43
193
|
langGraphDefaultMergeState(state: State, messages: Message[], tools: any): State;
|
|
44
194
|
getSchemaKeys(): Promise<SchemaKeys>;
|
|
45
195
|
}
|
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.25",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -82,11 +82,11 @@ var require_package = __commonJS({
|
|
|
82
82
|
"zod-to-json-schema": "^3.23.5"
|
|
83
83
|
},
|
|
84
84
|
dependencies: {
|
|
85
|
-
"@ag-ui/client": "0.0.
|
|
86
|
-
"@ag-ui/core": "0.0.
|
|
87
|
-
"@ag-ui/encoder": "0.0.
|
|
88
|
-
"@ag-ui/langgraph": "0.0.
|
|
89
|
-
"@ag-ui/proto": "0.0.
|
|
85
|
+
"@ag-ui/client": "0.0.34",
|
|
86
|
+
"@ag-ui/core": "0.0.34",
|
|
87
|
+
"@ag-ui/encoder": "0.0.34",
|
|
88
|
+
"@ag-ui/langgraph": "0.0.6",
|
|
89
|
+
"@ag-ui/proto": "0.0.34",
|
|
90
90
|
"@anthropic-ai/sdk": "^0.27.3",
|
|
91
91
|
"@copilotkit/shared": "workspace:*",
|
|
92
92
|
"@graphql-yoga/plugin-defer-stream": "^3.3.1",
|
|
@@ -114,10 +114,10 @@ var require_package = __commonJS({
|
|
|
114
114
|
zod: "^3.23.3"
|
|
115
115
|
},
|
|
116
116
|
peerDependencies: {
|
|
117
|
-
"@ag-ui/client": ">=0.0.
|
|
118
|
-
"@ag-ui/core": ">=0.0.
|
|
119
|
-
"@ag-ui/encoder": ">=0.0.
|
|
120
|
-
"@ag-ui/proto": ">=0.0.
|
|
117
|
+
"@ag-ui/client": ">=0.0.34",
|
|
118
|
+
"@ag-ui/core": ">=0.0.34",
|
|
119
|
+
"@ag-ui/encoder": ">=0.0.34",
|
|
120
|
+
"@ag-ui/proto": ">=0.0.34"
|
|
121
121
|
},
|
|
122
122
|
keywords: [
|
|
123
123
|
"copilotkit",
|
|
@@ -4394,30 +4394,30 @@ var CopilotRuntime = class {
|
|
|
4394
4394
|
async processRuntimeRequest(request) {
|
|
4395
4395
|
var _a, _b, _c, _d, _e;
|
|
4396
4396
|
const { serviceAdapter, messages: rawMessages, actions: clientSideActionsInput, threadId, runId, outputMessagesPromise, graphqlContext, forwardedParameters, url, extensions, agentSession, agentStates, publicApiKey } = request;
|
|
4397
|
-
const eventSource = new RuntimeEventSource(
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
await this.error("request", {
|
|
4401
|
-
threadId,
|
|
4402
|
-
runId,
|
|
4403
|
-
source: "runtime",
|
|
4404
|
-
request: {
|
|
4405
|
-
operation: "processRuntimeRequest",
|
|
4406
|
-
method: "POST",
|
|
4407
|
-
url,
|
|
4408
|
-
startTime: requestStartTime
|
|
4409
|
-
},
|
|
4410
|
-
agent: agentSession ? {
|
|
4411
|
-
name: agentSession.agentName
|
|
4412
|
-
} : void 0,
|
|
4413
|
-
messages: {
|
|
4414
|
-
input: rawMessages,
|
|
4415
|
-
messageCount: rawMessages.length
|
|
4397
|
+
const eventSource = new RuntimeEventSource({
|
|
4398
|
+
errorHandler: async (error, context) => {
|
|
4399
|
+
await this.error("error", context, error, publicApiKey);
|
|
4416
4400
|
},
|
|
4417
|
-
|
|
4418
|
-
|
|
4401
|
+
errorContext: {
|
|
4402
|
+
threadId,
|
|
4403
|
+
runId,
|
|
4404
|
+
source: "runtime",
|
|
4405
|
+
request: {
|
|
4406
|
+
operation: "processRuntimeRequest",
|
|
4407
|
+
method: "POST",
|
|
4408
|
+
url,
|
|
4409
|
+
startTime: Date.now()
|
|
4410
|
+
},
|
|
4411
|
+
agent: agentSession ? {
|
|
4412
|
+
name: agentSession.agentName
|
|
4413
|
+
} : void 0,
|
|
4414
|
+
technical: {
|
|
4415
|
+
environment: process.env.NODE_ENV
|
|
4416
|
+
}
|
|
4419
4417
|
}
|
|
4420
|
-
}
|
|
4418
|
+
});
|
|
4419
|
+
const requestStartTime = Date.now();
|
|
4420
|
+
const streamedChunks = [];
|
|
4421
4421
|
try {
|
|
4422
4422
|
if (Object.keys(this.agents).length && (agentSession == null ? void 0 : agentSession.agentName) && !this.delegateAgentProcessingToServiceAdapter) {
|
|
4423
4423
|
this.agents = {
|
|
@@ -4909,7 +4909,27 @@ please use an LLM adapter instead.`
|
|
|
4909
4909
|
properties: graphqlContext.properties
|
|
4910
4910
|
}));
|
|
4911
4911
|
try {
|
|
4912
|
-
const eventSource = new RuntimeEventSource(
|
|
4912
|
+
const eventSource = new RuntimeEventSource({
|
|
4913
|
+
errorHandler: async (error, context) => {
|
|
4914
|
+
await this.error("error", context, error, publicApiKey);
|
|
4915
|
+
},
|
|
4916
|
+
errorContext: {
|
|
4917
|
+
threadId,
|
|
4918
|
+
source: "agent",
|
|
4919
|
+
request: {
|
|
4920
|
+
operation: "processAgentRequest",
|
|
4921
|
+
method: "POST",
|
|
4922
|
+
startTime: requestStartTime
|
|
4923
|
+
},
|
|
4924
|
+
agent: {
|
|
4925
|
+
name: agentName,
|
|
4926
|
+
nodeName
|
|
4927
|
+
},
|
|
4928
|
+
technical: {
|
|
4929
|
+
environment: process.env.NODE_ENV
|
|
4930
|
+
}
|
|
4931
|
+
}
|
|
4932
|
+
});
|
|
4913
4933
|
const stream = await currentAgent.remoteAgentHandler({
|
|
4914
4934
|
name: agentName,
|
|
4915
4935
|
threadId,
|
|
@@ -6210,6 +6230,12 @@ __name(RuntimeEventSubject, "RuntimeEventSubject");
|
|
|
6210
6230
|
var RuntimeEventSource = class {
|
|
6211
6231
|
eventStream$ = new RuntimeEventSubject();
|
|
6212
6232
|
callback;
|
|
6233
|
+
errorHandler;
|
|
6234
|
+
errorContext;
|
|
6235
|
+
constructor(params) {
|
|
6236
|
+
this.errorHandler = params == null ? void 0 : params.errorHandler;
|
|
6237
|
+
this.errorContext = params == null ? void 0 : params.errorContext;
|
|
6238
|
+
}
|
|
6213
6239
|
async stream(callback) {
|
|
6214
6240
|
this.callback = callback;
|
|
6215
6241
|
}
|
|
@@ -6224,8 +6250,15 @@ var RuntimeEventSource = class {
|
|
|
6224
6250
|
}
|
|
6225
6251
|
}
|
|
6226
6252
|
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId }) {
|
|
6227
|
-
this.callback(this.eventStream$).catch((error) => {
|
|
6253
|
+
this.callback(this.eventStream$).catch(async (error) => {
|
|
6228
6254
|
const structuredError = (0, import_shared24.ensureStructuredError)(error, convertStreamingErrorToStructured2);
|
|
6255
|
+
if (this.errorHandler && this.errorContext) {
|
|
6256
|
+
try {
|
|
6257
|
+
await this.errorHandler(structuredError, this.errorContext);
|
|
6258
|
+
} catch (errorHandlerError) {
|
|
6259
|
+
console.error("Error in streaming error handler:", errorHandlerError);
|
|
6260
|
+
}
|
|
6261
|
+
}
|
|
6229
6262
|
this.eventStream$.error(structuredError);
|
|
6230
6263
|
this.eventStream$.complete();
|
|
6231
6264
|
});
|
|
@@ -6264,6 +6297,19 @@ var RuntimeEventSource = class {
|
|
|
6264
6297
|
telemetry_client_default.capture("oss.runtime.server_action_executed", {});
|
|
6265
6298
|
return (0, import_rxjs3.concat)((0, import_rxjs3.of)(eventWithState.event), toolCallEventStream$).pipe((0, import_rxjs3.catchError)((error) => {
|
|
6266
6299
|
const structuredError = (0, import_shared24.ensureStructuredError)(error, convertStreamingErrorToStructured2);
|
|
6300
|
+
if (this.errorHandler && this.errorContext) {
|
|
6301
|
+
(0, import_rxjs3.from)(this.errorHandler(structuredError, {
|
|
6302
|
+
...this.errorContext,
|
|
6303
|
+
action: {
|
|
6304
|
+
name: eventWithState.action.name,
|
|
6305
|
+
executionId: eventWithState.actionExecutionId
|
|
6306
|
+
}
|
|
6307
|
+
})).subscribe({
|
|
6308
|
+
error: (errorHandlerError) => {
|
|
6309
|
+
console.error("Error in action execution error handler:", errorHandlerError);
|
|
6310
|
+
}
|
|
6311
|
+
});
|
|
6312
|
+
}
|
|
6267
6313
|
toolCallEventStream$.sendActionExecutionResult({
|
|
6268
6314
|
actionExecutionId: eventWithState.actionExecutionId,
|
|
6269
6315
|
actionName: eventWithState.action.name,
|