@copilotkit/runtime 1.50.0-beta.1 → 1.50.0-beta.11
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 +85 -0
- package/dist/chunk-2OZAGFV3.mjs +43 -0
- package/dist/chunk-2OZAGFV3.mjs.map +1 -0
- package/dist/chunk-62NE5S6M.mjs +226 -0
- package/dist/chunk-62NE5S6M.mjs.map +1 -0
- package/dist/chunk-6XRUR5UK.mjs +1 -0
- package/dist/chunk-6XRUR5UK.mjs.map +1 -0
- package/dist/chunk-AMUJQ6IR.mjs +50 -0
- package/dist/chunk-AMUJQ6IR.mjs.map +1 -0
- package/dist/chunk-BJEYMRDD.mjs +25 -0
- package/dist/chunk-BJEYMRDD.mjs.map +1 -0
- package/dist/chunk-DZV4ZIAR.mjs +3063 -0
- package/dist/chunk-DZV4ZIAR.mjs.map +1 -0
- package/dist/chunk-FHD4JECV.mjs +33 -0
- package/dist/chunk-FHD4JECV.mjs.map +1 -0
- package/dist/chunk-FMU55SEU.mjs +25 -0
- package/dist/chunk-FMU55SEU.mjs.map +1 -0
- package/dist/chunk-OWIGJONH.mjs +275 -0
- package/dist/chunk-OWIGJONH.mjs.map +1 -0
- package/dist/chunk-SBCOROE4.mjs +1112 -0
- package/dist/chunk-SBCOROE4.mjs.map +1 -0
- package/dist/chunk-TTUAEJLD.mjs +617 -0
- package/dist/chunk-TTUAEJLD.mjs.map +1 -0
- package/dist/chunk-XWBDEXDA.mjs +153 -0
- package/dist/chunk-XWBDEXDA.mjs.map +1 -0
- package/dist/chunk-Z752VE75.mjs +74 -0
- package/dist/chunk-Z752VE75.mjs.map +1 -0
- package/dist/graphql/message-conversion/index.d.ts +18 -0
- package/dist/graphql/message-conversion/index.js +725 -0
- package/dist/graphql/message-conversion/index.js.map +1 -0
- package/dist/graphql/message-conversion/index.mjs +245 -0
- package/dist/graphql/message-conversion/index.mjs.map +1 -0
- package/dist/graphql/types/base/index.d.ts +6 -0
- package/dist/graphql/types/base/index.js +63 -0
- package/dist/graphql/types/base/index.js.map +1 -0
- package/dist/graphql/types/base/index.mjs +8 -0
- package/dist/graphql/types/base/index.mjs.map +1 -0
- package/dist/graphql/types/converted/index.d.ts +2 -0
- package/dist/graphql/types/converted/index.js +294 -0
- package/dist/graphql/types/converted/index.js.map +1 -0
- package/dist/graphql/types/converted/index.mjs +20 -0
- package/dist/graphql/types/converted/index.mjs.map +1 -0
- package/dist/groq-adapter-50bc6e4a.d.ts +326 -0
- package/dist/index-adbd78f1.d.ts +154 -0
- package/dist/index.d.ts +136 -287
- package/dist/index.js +414 -293
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +407 -283
- package/dist/index.mjs.map +1 -1
- package/dist/langgraph.d.ts +284 -0
- package/dist/langgraph.js +211 -0
- package/dist/langgraph.js.map +1 -0
- package/dist/langgraph.mjs +206 -0
- package/dist/langgraph.mjs.map +1 -0
- package/dist/langserve-74a52292.d.ts +242 -0
- package/dist/lib/cloud/index.d.ts +6 -0
- package/dist/lib/cloud/index.js +18 -0
- package/dist/lib/cloud/index.js.map +1 -0
- package/dist/lib/cloud/index.mjs +1 -0
- package/dist/lib/cloud/index.mjs.map +1 -0
- package/dist/lib/index.d.ts +266 -0
- package/dist/lib/index.js +4944 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/index.mjs +74 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/integrations/index.d.ts +28 -0
- package/dist/lib/integrations/index.js +3024 -0
- package/dist/lib/integrations/index.js.map +1 -0
- package/dist/lib/integrations/index.mjs +36 -0
- package/dist/lib/integrations/index.mjs.map +1 -0
- package/dist/lib/integrations/nest/index.d.ts +16 -0
- package/dist/lib/integrations/nest/index.js +2937 -0
- package/dist/lib/integrations/nest/index.js.map +1 -0
- package/dist/lib/integrations/nest/index.mjs +13 -0
- package/dist/lib/integrations/nest/index.mjs.map +1 -0
- package/dist/lib/integrations/node-express/index.d.ts +16 -0
- package/dist/lib/integrations/node-express/index.js +2937 -0
- package/dist/lib/integrations/node-express/index.js.map +1 -0
- package/dist/lib/integrations/node-express/index.mjs +13 -0
- package/dist/lib/integrations/node-express/index.mjs.map +1 -0
- package/dist/lib/integrations/node-http/index.d.ts +16 -0
- package/dist/lib/integrations/node-http/index.js +2923 -0
- package/dist/lib/integrations/node-http/index.js.map +1 -0
- package/dist/lib/integrations/node-http/index.mjs +12 -0
- package/dist/lib/integrations/node-http/index.mjs.map +1 -0
- package/dist/service-adapters/index.d.ts +166 -0
- package/dist/service-adapters/index.js +1800 -0
- package/dist/service-adapters/index.js.map +1 -0
- package/dist/service-adapters/index.mjs +36 -0
- package/dist/service-adapters/index.mjs.map +1 -0
- package/dist/service-adapters/shared/index.d.ts +9 -0
- package/dist/service-adapters/shared/index.js +72 -0
- package/dist/service-adapters/shared/index.js.map +1 -0
- package/dist/service-adapters/shared/index.mjs +8 -0
- package/dist/service-adapters/shared/index.mjs.map +1 -0
- package/dist/shared-f6d43ef8.d.ts +446 -0
- package/dist/utils/index.d.ts +65 -0
- package/dist/utils/index.js +175 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +12 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2/index.js +7 -0
- package/dist/v2/index.js.map +1 -1
- package/dist/v2/index.mjs +1 -0
- package/dist/v2/index.mjs.map +1 -1
- package/package.json +56 -18
- package/src/graphql/message-conversion/agui-to-gql.test.ts +2 -2
- package/src/graphql/message-conversion/gql-to-agui.test.ts +30 -28
- package/src/graphql/message-conversion/roundtrip-conversion.test.ts +8 -8
- package/src/langgraph.ts +1 -0
- package/src/lib/index.ts +42 -1
- package/src/lib/integrations/nextjs/app-router.ts +3 -1
- package/src/lib/integrations/node-http/index.ts +132 -11
- package/src/lib/integrations/shared.ts +2 -2
- package/src/lib/runtime/agent-integrations/{langgraph.agent.ts → langgraph/agent.ts} +5 -30
- package/src/lib/runtime/agent-integrations/langgraph/consts.ts +34 -0
- package/src/lib/runtime/agent-integrations/langgraph/index.ts +2 -0
- package/src/lib/runtime/copilot-runtime.ts +86 -69
- package/src/lib/runtime/telemetry-agent-runner.ts +134 -0
- package/src/service-adapters/anthropic/anthropic-adapter.ts +16 -3
- package/src/service-adapters/bedrock/bedrock-adapter.ts +4 -1
- package/src/service-adapters/experimental/ollama/ollama-adapter.ts +2 -1
- package/src/service-adapters/google/google-genai-adapter.ts +9 -4
- package/src/service-adapters/groq/groq-adapter.ts +16 -3
- package/src/service-adapters/langchain/langchain-adapter.ts +5 -3
- package/src/service-adapters/langchain/langserve.ts +2 -1
- package/src/service-adapters/openai/openai-adapter.ts +17 -3
- package/src/service-adapters/openai/openai-assistant-adapter.ts +26 -11
- package/src/service-adapters/unify/unify-adapter.ts +3 -1
- package/src/v2/index.ts +1 -0
- package/tsup.config.ts +5 -2
package/dist/index.mjs
CHANGED
|
@@ -1,32 +1,21 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { AIMessage, HumanMessage, SystemMessage, ToolMessage } from '@langchain/core/messages';
|
|
2
|
+
import { TelemetryClient, CopilotKitLowLevelError, CopilotKitErrorCode, randomUUID, randomId, isTelemetryDisabled, CopilotKitMisuseError, getZodParameters, readBody, CopilotKitError, CopilotKitAgentDiscoveryError, parseJson, convertJsonSchemaToZodSchema } from '@copilotkit/shared';
|
|
3
|
+
import { HumanMessage, AIMessage, SystemMessage, ToolMessage } from '@langchain/core/messages';
|
|
5
4
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
6
|
-
import { awaitAllCallbacks } from '@langchain/core/callbacks/promises';
|
|
7
|
-
import { ChatGoogle } from '@langchain/google-gauth';
|
|
8
|
-
import { Groq } from 'groq-sdk';
|
|
9
5
|
import { registerEnumType, Field, InputType, ObjectType, createUnionType, InterfaceType, Query, Ctx, Mutation, Arg, Resolver, buildSchemaSync } from 'type-graphql';
|
|
10
|
-
import {
|
|
6
|
+
import { tap, catchError, finalize, ReplaySubject, shareReplay, firstValueFrom, skipWhile, takeWhile, filter, Subject, take } from 'rxjs';
|
|
11
7
|
import { GraphQLJSON, GraphQLJSONObject } from 'graphql-scalars';
|
|
12
8
|
import { Repeater } from 'graphql-yoga';
|
|
13
9
|
import { plainToInstance } from 'class-transformer';
|
|
14
10
|
import { GraphQLError } from 'graphql';
|
|
15
11
|
import { createHash } from 'crypto';
|
|
16
12
|
import { InMemoryAgentRunner, CopilotRuntime as CopilotRuntime$1, createCopilotEndpointSingleRoute } from '@copilotkitnext/runtime';
|
|
17
|
-
import { EventType } from '@ag-ui/client';
|
|
18
|
-
import { LangGraphAgent as LangGraphAgent$1 } from '@ag-ui/langgraph';
|
|
19
|
-
export { LangGraphHttpAgent } from '@ag-ui/langgraph';
|
|
20
13
|
import { BasicAgent } from '@copilotkitnext/agent';
|
|
21
14
|
import { useDeferStream } from '@graphql-yoga/plugin-defer-stream';
|
|
22
15
|
import createPinoLogger from 'pino';
|
|
23
16
|
import pretty from 'pino-pretty';
|
|
24
17
|
import { handle } from 'hono/vercel';
|
|
25
18
|
import { Readable } from 'stream';
|
|
26
|
-
import { RemoteRunnable } from 'langchain/runnables/remote';
|
|
27
|
-
import Anthropic from '@anthropic-ai/sdk';
|
|
28
|
-
import { Ollama } from '@langchain/community/llms/ollama';
|
|
29
|
-
import { ChatBedrockConverse } from '@langchain/aws';
|
|
30
19
|
|
|
31
20
|
var __create = Object.create;
|
|
32
21
|
var __defProp = Object.defineProperty;
|
|
@@ -35,7 +24,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
35
24
|
var __getProtoOf = Object.getPrototypeOf;
|
|
36
25
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
37
26
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
38
|
-
var
|
|
27
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
28
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
29
|
+
}) : x)(function(x) {
|
|
30
|
+
if (typeof require !== "undefined")
|
|
31
|
+
return require.apply(this, arguments);
|
|
32
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
33
|
+
});
|
|
34
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
39
35
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
40
36
|
};
|
|
41
37
|
var __copyProps = (to, from, except, desc) => {
|
|
@@ -69,7 +65,7 @@ var require_package = __commonJS({
|
|
|
69
65
|
publishConfig: {
|
|
70
66
|
access: "public"
|
|
71
67
|
},
|
|
72
|
-
version: "1.50.0-beta.
|
|
68
|
+
version: "1.50.0-beta.10",
|
|
73
69
|
sideEffects: false,
|
|
74
70
|
main: "./dist/index.js",
|
|
75
71
|
module: "./dist/index.mjs",
|
|
@@ -83,6 +79,11 @@ var require_package = __commonJS({
|
|
|
83
79
|
import: "./dist/v2/index.mjs",
|
|
84
80
|
require: "./dist/v2/index.js",
|
|
85
81
|
types: "./dist/v2/index.d.ts"
|
|
82
|
+
},
|
|
83
|
+
"./langgraph": {
|
|
84
|
+
import: "./dist/langgraph.mjs",
|
|
85
|
+
require: "./dist/langgraph.js",
|
|
86
|
+
types: "./dist/langgraph.d.ts"
|
|
86
87
|
}
|
|
87
88
|
},
|
|
88
89
|
types: "./dist/index.d.ts",
|
|
@@ -112,29 +113,21 @@ var require_package = __commonJS({
|
|
|
112
113
|
tsconfig: "workspace:*",
|
|
113
114
|
tsup: "^6.7.0",
|
|
114
115
|
typescript: "^5.2.3",
|
|
115
|
-
vitest: "^3.2.4"
|
|
116
|
-
"zod-to-json-schema": "^3.23.5"
|
|
116
|
+
vitest: "^3.2.4"
|
|
117
117
|
},
|
|
118
118
|
dependencies: {
|
|
119
|
-
"@anthropic-ai/sdk": "^0.57.0",
|
|
120
119
|
"@copilotkit/shared": "workspace:*",
|
|
121
|
-
"@copilotkitnext/agent": "0.0.
|
|
122
|
-
"@copilotkitnext/runtime": "0.0.
|
|
120
|
+
"@copilotkitnext/agent": "0.0.28",
|
|
121
|
+
"@copilotkitnext/runtime": "0.0.28",
|
|
123
122
|
"@graphql-yoga/plugin-defer-stream": "^3.3.1",
|
|
124
|
-
"@
|
|
125
|
-
"@langchain/community": "^0.3.29",
|
|
123
|
+
"@hono/node-server": "^1.13.5",
|
|
126
124
|
"@langchain/core": "^0.3.38",
|
|
127
|
-
"@langchain/google-gauth": "^0.1.0",
|
|
128
|
-
"@langchain/langgraph-sdk": "^0.0.70",
|
|
129
|
-
"@langchain/openai": "^0.4.2",
|
|
130
125
|
"@scarf/scarf": "^1.3.0",
|
|
131
126
|
"class-transformer": "^0.5.1",
|
|
132
127
|
"class-validator": "^0.14.1",
|
|
133
128
|
graphql: "^16.8.1",
|
|
134
129
|
"graphql-scalars": "^1.23.0",
|
|
135
130
|
"graphql-yoga": "^5.3.1",
|
|
136
|
-
"groq-sdk": "^0.5.0",
|
|
137
|
-
"@hono/node-server": "^1.13.5",
|
|
138
131
|
hono: "^4.10.3",
|
|
139
132
|
langchain: "^0.3.3",
|
|
140
133
|
openai: "^4.85.1",
|
|
@@ -147,11 +140,52 @@ var require_package = __commonJS({
|
|
|
147
140
|
zod: "^3.23.3"
|
|
148
141
|
},
|
|
149
142
|
peerDependencies: {
|
|
150
|
-
"@
|
|
151
|
-
"@ag-ui/
|
|
152
|
-
"@ag-ui/
|
|
153
|
-
"@ag-ui/
|
|
154
|
-
"@ag-ui/
|
|
143
|
+
"@anthropic-ai/sdk": "^0.57.0",
|
|
144
|
+
"@ag-ui/client": "^0.0.42",
|
|
145
|
+
"@ag-ui/core": ">=0.0.42",
|
|
146
|
+
"@ag-ui/encoder": ">=0.0.42",
|
|
147
|
+
"@ag-ui/langgraph": ">=0.0.20",
|
|
148
|
+
"@ag-ui/proto": ">=0.0.42",
|
|
149
|
+
"@langchain/aws": "^0.1.9",
|
|
150
|
+
"@langchain/community": "^0.3.58",
|
|
151
|
+
"@langchain/google-gauth": "^0.1.0",
|
|
152
|
+
"@langchain/langgraph-sdk": "^0.0.70",
|
|
153
|
+
"@langchain/openai": "^0.4.2",
|
|
154
|
+
"groq-sdk": ">=0.3.0 <1.0.0",
|
|
155
|
+
langchain: "^0.3.3",
|
|
156
|
+
openai: "^4.85.1"
|
|
157
|
+
},
|
|
158
|
+
peerDependenciesMeta: {
|
|
159
|
+
"@anthropic-ai/sdk": {
|
|
160
|
+
optional: true
|
|
161
|
+
},
|
|
162
|
+
"@ag-ui/langgraph": {
|
|
163
|
+
optional: true
|
|
164
|
+
},
|
|
165
|
+
"@langchain/aws": {
|
|
166
|
+
optional: true
|
|
167
|
+
},
|
|
168
|
+
"@langchain/community": {
|
|
169
|
+
optional: true
|
|
170
|
+
},
|
|
171
|
+
"@langchain/google-gauth": {
|
|
172
|
+
optional: true
|
|
173
|
+
},
|
|
174
|
+
"@langchain/langgraph-sdk": {
|
|
175
|
+
optional: true
|
|
176
|
+
},
|
|
177
|
+
"@langchain/openai": {
|
|
178
|
+
optional: true
|
|
179
|
+
},
|
|
180
|
+
"groq-sdk": {
|
|
181
|
+
optional: true
|
|
182
|
+
},
|
|
183
|
+
langchain: {
|
|
184
|
+
optional: true
|
|
185
|
+
},
|
|
186
|
+
openai: {
|
|
187
|
+
optional: true
|
|
188
|
+
}
|
|
155
189
|
},
|
|
156
190
|
keywords: [
|
|
157
191
|
"copilotkit",
|
|
@@ -402,13 +436,22 @@ var OpenAIAdapter = class {
|
|
|
402
436
|
return "OpenAIAdapter";
|
|
403
437
|
}
|
|
404
438
|
constructor(params) {
|
|
405
|
-
|
|
439
|
+
if (params == null ? void 0 : params.openai) {
|
|
440
|
+
this._openai = params.openai;
|
|
441
|
+
}
|
|
406
442
|
if (params == null ? void 0 : params.model) {
|
|
407
443
|
this.model = params.model;
|
|
408
444
|
}
|
|
409
445
|
this.disableParallelToolCalls = (params == null ? void 0 : params.disableParallelToolCalls) || false;
|
|
410
446
|
this.keepSystemRole = (params == null ? void 0 : params.keepSystemRole) ?? false;
|
|
411
447
|
}
|
|
448
|
+
ensureOpenAI() {
|
|
449
|
+
if (!this._openai) {
|
|
450
|
+
const OpenAI = __require("openai").default;
|
|
451
|
+
this._openai = new OpenAI();
|
|
452
|
+
}
|
|
453
|
+
return this._openai;
|
|
454
|
+
}
|
|
412
455
|
async process(request) {
|
|
413
456
|
const { threadId: threadIdFromRequest, model = this.model, messages, actions, eventSource, forwardedParameters } = request;
|
|
414
457
|
const tools = actions.map(convertActionInputToOpenAITool);
|
|
@@ -443,7 +486,8 @@ var OpenAIAdapter = class {
|
|
|
443
486
|
};
|
|
444
487
|
}
|
|
445
488
|
try {
|
|
446
|
-
const
|
|
489
|
+
const openai = this.ensureOpenAI();
|
|
490
|
+
const stream = openai.beta.chat.completions.stream({
|
|
447
491
|
model,
|
|
448
492
|
stream: true,
|
|
449
493
|
messages: openaiMessages,
|
|
@@ -803,11 +847,14 @@ var LangChainAdapter = class {
|
|
|
803
847
|
threadId
|
|
804
848
|
};
|
|
805
849
|
} finally {
|
|
850
|
+
const { awaitAllCallbacks } = __require("@langchain/core/callbacks/promises");
|
|
806
851
|
await awaitAllCallbacks();
|
|
807
852
|
}
|
|
808
853
|
}
|
|
809
854
|
};
|
|
810
855
|
__name(LangChainAdapter, "LangChainAdapter");
|
|
856
|
+
|
|
857
|
+
// src/service-adapters/google/google-genai-adapter.ts
|
|
811
858
|
var DEFAULT_MODEL2 = "gemini-1.5-pro";
|
|
812
859
|
var GoogleGenerativeAIAdapter = class extends LangChainAdapter {
|
|
813
860
|
provider = "google";
|
|
@@ -815,11 +862,14 @@ var GoogleGenerativeAIAdapter = class extends LangChainAdapter {
|
|
|
815
862
|
constructor(options) {
|
|
816
863
|
super({
|
|
817
864
|
chainFn: async ({ messages, tools, threadId }) => {
|
|
865
|
+
const { ChatGoogle } = __require("@langchain/google-gauth");
|
|
866
|
+
const { AIMessage: AIMessage2 } = __require("@langchain/core/messages");
|
|
818
867
|
const filteredMessages = messages.filter((message) => {
|
|
819
|
-
if (!(message instanceof
|
|
868
|
+
if (!(message instanceof AIMessage2)) {
|
|
820
869
|
return true;
|
|
821
870
|
}
|
|
822
|
-
|
|
871
|
+
const aiMsg = message;
|
|
872
|
+
return aiMsg.content && String(aiMsg.content).trim().length > 0 || aiMsg.tool_calls && aiMsg.tool_calls.length > 0;
|
|
823
873
|
});
|
|
824
874
|
this.model = (options == null ? void 0 : options.model) ?? "gemini-1.5-pro";
|
|
825
875
|
const model = new ChatGoogle({
|
|
@@ -837,8 +887,10 @@ var GoogleGenerativeAIAdapter = class extends LangChainAdapter {
|
|
|
837
887
|
}
|
|
838
888
|
};
|
|
839
889
|
__name(GoogleGenerativeAIAdapter, "GoogleGenerativeAIAdapter");
|
|
890
|
+
|
|
891
|
+
// src/service-adapters/openai/openai-assistant-adapter.ts
|
|
840
892
|
var OpenAIAssistantAdapter = class {
|
|
841
|
-
|
|
893
|
+
_openai;
|
|
842
894
|
codeInterpreterEnabled;
|
|
843
895
|
assistantId;
|
|
844
896
|
fileSearchEnabled;
|
|
@@ -848,19 +900,29 @@ var OpenAIAssistantAdapter = class {
|
|
|
848
900
|
return "OpenAIAssistantAdapter";
|
|
849
901
|
}
|
|
850
902
|
constructor(params) {
|
|
851
|
-
|
|
903
|
+
if (params.openai) {
|
|
904
|
+
this._openai = params.openai;
|
|
905
|
+
}
|
|
852
906
|
this.codeInterpreterEnabled = params.codeInterpreterEnabled === false || true;
|
|
853
907
|
this.fileSearchEnabled = params.fileSearchEnabled === false || true;
|
|
854
908
|
this.assistantId = params.assistantId;
|
|
855
909
|
this.disableParallelToolCalls = (params == null ? void 0 : params.disableParallelToolCalls) || false;
|
|
856
910
|
this.keepSystemRole = (params == null ? void 0 : params.keepSystemRole) ?? false;
|
|
857
911
|
}
|
|
912
|
+
ensureOpenAI() {
|
|
913
|
+
if (!this._openai) {
|
|
914
|
+
const OpenAI = __require("openai").default;
|
|
915
|
+
this._openai = new OpenAI({});
|
|
916
|
+
}
|
|
917
|
+
return this._openai;
|
|
918
|
+
}
|
|
858
919
|
async process(request) {
|
|
859
920
|
var _a, _b;
|
|
860
921
|
const { messages, actions, eventSource, runId, forwardedParameters } = request;
|
|
861
922
|
let threadId = (_b = (_a = request.extensions) == null ? void 0 : _a.openaiAssistantAPI) == null ? void 0 : _b.threadId;
|
|
923
|
+
const openai = this.ensureOpenAI();
|
|
862
924
|
if (!threadId) {
|
|
863
|
-
threadId = (await
|
|
925
|
+
threadId = (await openai.beta.threads.create()).id;
|
|
864
926
|
}
|
|
865
927
|
const lastMessage = messages.at(-1);
|
|
866
928
|
let nextRunId = void 0;
|
|
@@ -884,7 +946,8 @@ var OpenAIAssistantAdapter = class {
|
|
|
884
946
|
};
|
|
885
947
|
}
|
|
886
948
|
async submitToolOutputs(threadId, runId, messages, eventSource) {
|
|
887
|
-
|
|
949
|
+
const openai = this.ensureOpenAI();
|
|
950
|
+
let run = await openai.beta.threads.runs.retrieve(threadId, runId);
|
|
888
951
|
if (!run.required_action) {
|
|
889
952
|
throw new Error("No tool outputs required");
|
|
890
953
|
}
|
|
@@ -899,7 +962,7 @@ var OpenAIAssistantAdapter = class {
|
|
|
899
962
|
output: message.result
|
|
900
963
|
};
|
|
901
964
|
});
|
|
902
|
-
const stream =
|
|
965
|
+
const stream = openai.beta.threads.runs.submitToolOutputsStream(threadId, runId, {
|
|
903
966
|
tool_outputs: toolOutputs,
|
|
904
967
|
...this.disableParallelToolCalls && {
|
|
905
968
|
parallel_tool_calls: false
|
|
@@ -909,6 +972,7 @@ var OpenAIAssistantAdapter = class {
|
|
|
909
972
|
return runId;
|
|
910
973
|
}
|
|
911
974
|
async submitUserMessage(threadId, messages, actions, eventSource, forwardedParameters) {
|
|
975
|
+
const openai = this.ensureOpenAI();
|
|
912
976
|
messages = [
|
|
913
977
|
...messages
|
|
914
978
|
];
|
|
@@ -920,7 +984,7 @@ var OpenAIAssistantAdapter = class {
|
|
|
920
984
|
if (userMessage.role !== "user") {
|
|
921
985
|
throw new Error("No user message found");
|
|
922
986
|
}
|
|
923
|
-
await
|
|
987
|
+
await openai.beta.threads.messages.create(threadId, {
|
|
924
988
|
role: "user",
|
|
925
989
|
content: userMessage.content
|
|
926
990
|
});
|
|
@@ -938,7 +1002,7 @@ var OpenAIAssistantAdapter = class {
|
|
|
938
1002
|
}
|
|
939
1003
|
] : []
|
|
940
1004
|
];
|
|
941
|
-
let stream =
|
|
1005
|
+
let stream = openai.beta.threads.runs.stream(threadId, {
|
|
942
1006
|
assistant_id: this.assistantId,
|
|
943
1007
|
instructions,
|
|
944
1008
|
tools,
|
|
@@ -1057,6 +1121,7 @@ var UnifyAdapter = class {
|
|
|
1057
1121
|
}
|
|
1058
1122
|
async process(request) {
|
|
1059
1123
|
const tools = request.actions.map(convertActionInputToOpenAITool);
|
|
1124
|
+
const OpenAI = __require("openai").default;
|
|
1060
1125
|
const openai = new OpenAI({
|
|
1061
1126
|
apiKey: this.apiKey,
|
|
1062
1127
|
baseURL: "https://api.unify.ai/v0/"
|
|
@@ -1168,12 +1233,21 @@ var GroqAdapter = class {
|
|
|
1168
1233
|
return "GroqAdapter";
|
|
1169
1234
|
}
|
|
1170
1235
|
constructor(params) {
|
|
1171
|
-
|
|
1236
|
+
if (params == null ? void 0 : params.groq) {
|
|
1237
|
+
this._groq = params.groq;
|
|
1238
|
+
}
|
|
1172
1239
|
if (params == null ? void 0 : params.model) {
|
|
1173
1240
|
this.model = params.model;
|
|
1174
1241
|
}
|
|
1175
1242
|
this.disableParallelToolCalls = (params == null ? void 0 : params.disableParallelToolCalls) || false;
|
|
1176
1243
|
}
|
|
1244
|
+
ensureGroq() {
|
|
1245
|
+
if (!this._groq) {
|
|
1246
|
+
const { Groq } = __require("groq-sdk");
|
|
1247
|
+
this._groq = new Groq({});
|
|
1248
|
+
}
|
|
1249
|
+
return this._groq;
|
|
1250
|
+
}
|
|
1177
1251
|
async process(request) {
|
|
1178
1252
|
const { threadId, model = this.model, messages, actions, eventSource, forwardedParameters } = request;
|
|
1179
1253
|
const tools = actions.map(convertActionInputToOpenAITool);
|
|
@@ -1192,7 +1266,8 @@ var GroqAdapter = class {
|
|
|
1192
1266
|
}
|
|
1193
1267
|
let stream;
|
|
1194
1268
|
try {
|
|
1195
|
-
|
|
1269
|
+
const groq = this.ensureGroq();
|
|
1270
|
+
stream = await groq.chat.completions.create({
|
|
1196
1271
|
model,
|
|
1197
1272
|
stream: true,
|
|
1198
1273
|
messages: openaiMessages,
|
|
@@ -3158,6 +3233,82 @@ function aguiMessageWithImageToGQLMessage(message) {
|
|
|
3158
3233
|
});
|
|
3159
3234
|
}
|
|
3160
3235
|
__name(aguiMessageWithImageToGQLMessage, "aguiMessageWithImageToGQLMessage");
|
|
3236
|
+
var TelemetryAgentRunner = class {
|
|
3237
|
+
_runner;
|
|
3238
|
+
hashedLgcKey;
|
|
3239
|
+
constructor(config2) {
|
|
3240
|
+
this._runner = (config2 == null ? void 0 : config2.runner) ?? new InMemoryAgentRunner();
|
|
3241
|
+
this.hashedLgcKey = (config2 == null ? void 0 : config2.langsmithApiKey) ? createHash("sha256").update(config2.langsmithApiKey).digest("hex") : void 0;
|
|
3242
|
+
}
|
|
3243
|
+
/**
|
|
3244
|
+
* Runs an agent with telemetry tracking.
|
|
3245
|
+
* Wraps the underlying runner's Observable stream with telemetry events.
|
|
3246
|
+
*/
|
|
3247
|
+
run(...args) {
|
|
3248
|
+
const streamInfo = {
|
|
3249
|
+
hashedLgcKey: this.hashedLgcKey
|
|
3250
|
+
};
|
|
3251
|
+
let streamErrored = false;
|
|
3252
|
+
telemetry_client_default.capture("oss.runtime.agent_execution_stream_started", {
|
|
3253
|
+
hashedLgcKey: this.hashedLgcKey
|
|
3254
|
+
});
|
|
3255
|
+
return this._runner.run(...args).pipe(
|
|
3256
|
+
// Extract metadata from events if available
|
|
3257
|
+
tap((event) => {
|
|
3258
|
+
var _a;
|
|
3259
|
+
const rawEvent = event.rawEvent;
|
|
3260
|
+
if (rawEvent == null ? void 0 : rawEvent.data) {
|
|
3261
|
+
const data = rawEvent.data;
|
|
3262
|
+
if ((_a = data == null ? void 0 : data.output) == null ? void 0 : _a.model) {
|
|
3263
|
+
streamInfo.model = data.output.model;
|
|
3264
|
+
streamInfo.provider = data.output.model;
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
if (rawEvent == null ? void 0 : rawEvent.metadata) {
|
|
3268
|
+
const metadata = rawEvent.metadata;
|
|
3269
|
+
if (metadata == null ? void 0 : metadata.langgraph_host) {
|
|
3270
|
+
streamInfo.langGraphHost = metadata.langgraph_host;
|
|
3271
|
+
}
|
|
3272
|
+
if (metadata == null ? void 0 : metadata.langgraph_version) {
|
|
3273
|
+
streamInfo.langGraphVersion = metadata.langgraph_version;
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
}),
|
|
3277
|
+
catchError((error) => {
|
|
3278
|
+
streamErrored = true;
|
|
3279
|
+
telemetry_client_default.capture("oss.runtime.agent_execution_stream_errored", {
|
|
3280
|
+
...streamInfo,
|
|
3281
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3282
|
+
});
|
|
3283
|
+
throw error;
|
|
3284
|
+
}),
|
|
3285
|
+
finalize(() => {
|
|
3286
|
+
if (!streamErrored) {
|
|
3287
|
+
telemetry_client_default.capture("oss.runtime.agent_execution_stream_ended", streamInfo);
|
|
3288
|
+
}
|
|
3289
|
+
})
|
|
3290
|
+
);
|
|
3291
|
+
}
|
|
3292
|
+
/**
|
|
3293
|
+
* Delegates to the underlying runner's connect method
|
|
3294
|
+
*/
|
|
3295
|
+
connect(...args) {
|
|
3296
|
+
return this._runner.connect(...args);
|
|
3297
|
+
}
|
|
3298
|
+
/**
|
|
3299
|
+
* Delegates to the underlying runner's isRunning method
|
|
3300
|
+
*/
|
|
3301
|
+
isRunning(...args) {
|
|
3302
|
+
return this._runner.isRunning(...args);
|
|
3303
|
+
}
|
|
3304
|
+
/**
|
|
3305
|
+
* Delegates to the underlying runner's stop method
|
|
3306
|
+
*/
|
|
3307
|
+
stop(...args) {
|
|
3308
|
+
return this._runner.stop(...args);
|
|
3309
|
+
}
|
|
3310
|
+
};
|
|
3311
|
+
__name(TelemetryAgentRunner, "TelemetryAgentRunner");
|
|
3161
3312
|
|
|
3162
3313
|
// src/lib/runtime/types.ts
|
|
3163
3314
|
var EndpointType;
|
|
@@ -3301,199 +3452,6 @@ When using these tools:
|
|
|
3301
3452
|
7. Always check tool responses to determine your next action`;
|
|
3302
3453
|
}
|
|
3303
3454
|
__name(generateMcpToolInstructions, "generateMcpToolInstructions");
|
|
3304
|
-
|
|
3305
|
-
// src/agents/langgraph/events.ts
|
|
3306
|
-
var LangGraphEventTypes;
|
|
3307
|
-
(function(LangGraphEventTypes2) {
|
|
3308
|
-
LangGraphEventTypes2["OnChainStart"] = "on_chain_start";
|
|
3309
|
-
LangGraphEventTypes2["OnChainStream"] = "on_chain_stream";
|
|
3310
|
-
LangGraphEventTypes2["OnChainEnd"] = "on_chain_end";
|
|
3311
|
-
LangGraphEventTypes2["OnChatModelStart"] = "on_chat_model_start";
|
|
3312
|
-
LangGraphEventTypes2["OnChatModelStream"] = "on_chat_model_stream";
|
|
3313
|
-
LangGraphEventTypes2["OnChatModelEnd"] = "on_chat_model_end";
|
|
3314
|
-
LangGraphEventTypes2["OnToolStart"] = "on_tool_start";
|
|
3315
|
-
LangGraphEventTypes2["OnToolEnd"] = "on_tool_end";
|
|
3316
|
-
LangGraphEventTypes2["OnCopilotKitStateSync"] = "on_copilotkit_state_sync";
|
|
3317
|
-
LangGraphEventTypes2["OnCopilotKitEmitMessage"] = "on_copilotkit_emit_message";
|
|
3318
|
-
LangGraphEventTypes2["OnCopilotKitEmitToolCall"] = "on_copilotkit_emit_tool_call";
|
|
3319
|
-
LangGraphEventTypes2["OnCustomEvent"] = "on_custom_event";
|
|
3320
|
-
LangGraphEventTypes2["OnInterrupt"] = "on_interrupt";
|
|
3321
|
-
LangGraphEventTypes2["OnCopilotKitInterrupt"] = "on_copilotkit_interrupt";
|
|
3322
|
-
LangGraphEventTypes2["OnCopilotKitError"] = "on_copilotkit_error";
|
|
3323
|
-
})(LangGraphEventTypes || (LangGraphEventTypes = {}));
|
|
3324
|
-
var MetaEventNames;
|
|
3325
|
-
(function(MetaEventNames2) {
|
|
3326
|
-
MetaEventNames2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
|
|
3327
|
-
MetaEventNames2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
|
|
3328
|
-
})(MetaEventNames || (MetaEventNames = {}));
|
|
3329
|
-
var CustomEventNames;
|
|
3330
|
-
(function(CustomEventNames3) {
|
|
3331
|
-
CustomEventNames3["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
|
|
3332
|
-
CustomEventNames3["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
|
|
3333
|
-
CustomEventNames3["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
|
|
3334
|
-
CustomEventNames3["CopilotKitExit"] = "copilotkit_exit";
|
|
3335
|
-
})(CustomEventNames || (CustomEventNames = {}));
|
|
3336
|
-
var CustomEventNames2;
|
|
3337
|
-
(function(CustomEventNames3) {
|
|
3338
|
-
CustomEventNames3["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
|
|
3339
|
-
CustomEventNames3["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
|
|
3340
|
-
CustomEventNames3["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
|
|
3341
|
-
CustomEventNames3["CopilotKitExit"] = "copilotkit_exit";
|
|
3342
|
-
})(CustomEventNames2 || (CustomEventNames2 = {}));
|
|
3343
|
-
var LangGraphAgent = class extends LangGraphAgent$1 {
|
|
3344
|
-
constructor(config2) {
|
|
3345
|
-
super(config2);
|
|
3346
|
-
}
|
|
3347
|
-
// @ts-ignore
|
|
3348
|
-
clone() {
|
|
3349
|
-
return new LangGraphAgent(this.config);
|
|
3350
|
-
}
|
|
3351
|
-
dispatchEvent(event) {
|
|
3352
|
-
if (event.type === EventType.CUSTOM) {
|
|
3353
|
-
const customEvent = event;
|
|
3354
|
-
if (customEvent.name === "copilotkit_manually_emit_message") {
|
|
3355
|
-
this.subscriber.next({
|
|
3356
|
-
type: EventType.TEXT_MESSAGE_START,
|
|
3357
|
-
role: "assistant",
|
|
3358
|
-
messageId: customEvent.value.message_id,
|
|
3359
|
-
rawEvent: event
|
|
3360
|
-
});
|
|
3361
|
-
this.subscriber.next({
|
|
3362
|
-
type: EventType.TEXT_MESSAGE_CONTENT,
|
|
3363
|
-
messageId: customEvent.value.message_id,
|
|
3364
|
-
delta: customEvent.value.message,
|
|
3365
|
-
rawEvent: event
|
|
3366
|
-
});
|
|
3367
|
-
this.subscriber.next({
|
|
3368
|
-
type: EventType.TEXT_MESSAGE_END,
|
|
3369
|
-
messageId: customEvent.value.message_id,
|
|
3370
|
-
rawEvent: event
|
|
3371
|
-
});
|
|
3372
|
-
return true;
|
|
3373
|
-
}
|
|
3374
|
-
if (customEvent.name === "copilotkit_manually_emit_tool_call") {
|
|
3375
|
-
this.subscriber.next({
|
|
3376
|
-
type: EventType.TOOL_CALL_START,
|
|
3377
|
-
toolCallId: customEvent.value.id,
|
|
3378
|
-
toolCallName: customEvent.value.name,
|
|
3379
|
-
parentMessageId: customEvent.value.id,
|
|
3380
|
-
rawEvent: event
|
|
3381
|
-
});
|
|
3382
|
-
this.subscriber.next({
|
|
3383
|
-
type: EventType.TOOL_CALL_ARGS,
|
|
3384
|
-
toolCallId: customEvent.value.id,
|
|
3385
|
-
delta: customEvent.value.args,
|
|
3386
|
-
rawEvent: event
|
|
3387
|
-
});
|
|
3388
|
-
this.subscriber.next({
|
|
3389
|
-
type: EventType.TOOL_CALL_END,
|
|
3390
|
-
toolCallId: customEvent.value.id,
|
|
3391
|
-
rawEvent: event
|
|
3392
|
-
});
|
|
3393
|
-
return true;
|
|
3394
|
-
}
|
|
3395
|
-
if (customEvent.name === "copilotkit_manually_emit_intermediate_state") {
|
|
3396
|
-
this.activeRun.manuallyEmittedState = customEvent.value;
|
|
3397
|
-
this.dispatchEvent({
|
|
3398
|
-
type: EventType.STATE_SNAPSHOT,
|
|
3399
|
-
snapshot: this.getStateSnapshot({
|
|
3400
|
-
values: this.activeRun.manuallyEmittedState
|
|
3401
|
-
}),
|
|
3402
|
-
rawEvent: event
|
|
3403
|
-
});
|
|
3404
|
-
return true;
|
|
3405
|
-
}
|
|
3406
|
-
if (customEvent.name === "copilotkit_exit") {
|
|
3407
|
-
this.subscriber.next({
|
|
3408
|
-
type: EventType.CUSTOM,
|
|
3409
|
-
name: "Exit",
|
|
3410
|
-
value: true
|
|
3411
|
-
});
|
|
3412
|
-
return true;
|
|
3413
|
-
}
|
|
3414
|
-
}
|
|
3415
|
-
const rawEvent = event.rawEvent;
|
|
3416
|
-
if (!rawEvent) {
|
|
3417
|
-
this.subscriber.next(event);
|
|
3418
|
-
return true;
|
|
3419
|
-
}
|
|
3420
|
-
const isMessageEvent = event.type === EventType.TEXT_MESSAGE_START || event.type === EventType.TEXT_MESSAGE_CONTENT || event.type === EventType.TEXT_MESSAGE_END;
|
|
3421
|
-
const isToolEvent = event.type === EventType.TOOL_CALL_START || event.type === EventType.TOOL_CALL_ARGS || event.type === EventType.TOOL_CALL_END;
|
|
3422
|
-
if ("copilotkit:emit-tool-calls" in (rawEvent.metadata || {})) {
|
|
3423
|
-
if (rawEvent.metadata["copilotkit:emit-tool-calls"] === false && isToolEvent) {
|
|
3424
|
-
return false;
|
|
3425
|
-
}
|
|
3426
|
-
}
|
|
3427
|
-
if ("copilotkit:emit-messages" in (rawEvent.metadata || {})) {
|
|
3428
|
-
if (rawEvent.metadata["copilotkit:emit-messages"] === false && isMessageEvent) {
|
|
3429
|
-
return false;
|
|
3430
|
-
}
|
|
3431
|
-
}
|
|
3432
|
-
this.subscriber.next(event);
|
|
3433
|
-
return true;
|
|
3434
|
-
}
|
|
3435
|
-
// @ts-ignore
|
|
3436
|
-
run(input) {
|
|
3437
|
-
return super.run(input).pipe(map((processedEvent) => {
|
|
3438
|
-
var _a, _b, _c, _d, _e;
|
|
3439
|
-
if (processedEvent.type === EventType.RAW) {
|
|
3440
|
-
const event = processedEvent.event ?? processedEvent.rawEvent;
|
|
3441
|
-
const eventType = event.event;
|
|
3442
|
-
const toolCallData = (_c = (_b = (_a = event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.tool_call_chunks) == null ? void 0 : _c[0];
|
|
3443
|
-
const toolCallUsedToPredictState = (_e = (_d = event.metadata) == null ? void 0 : _d["copilotkit:emit-intermediate-state"]) == null ? void 0 : _e.some((predictStateTool) => predictStateTool.tool === (toolCallData == null ? void 0 : toolCallData.name));
|
|
3444
|
-
if (eventType === LangGraphEventTypes.OnChatModelStream && toolCallUsedToPredictState) {
|
|
3445
|
-
return {
|
|
3446
|
-
type: EventType.CUSTOM,
|
|
3447
|
-
name: "PredictState",
|
|
3448
|
-
value: event.metadata["copilotkit:emit-intermediate-state"]
|
|
3449
|
-
};
|
|
3450
|
-
}
|
|
3451
|
-
}
|
|
3452
|
-
return processedEvent;
|
|
3453
|
-
}));
|
|
3454
|
-
}
|
|
3455
|
-
langGraphDefaultMergeState(state, messages, input) {
|
|
3456
|
-
const aguiMergedState = super.langGraphDefaultMergeState(state, messages, input);
|
|
3457
|
-
const { tools: returnedTools, "ag-ui": agui } = aguiMergedState;
|
|
3458
|
-
const rawCombinedTools = [
|
|
3459
|
-
...returnedTools ?? [],
|
|
3460
|
-
...(agui == null ? void 0 : agui.tools) ?? []
|
|
3461
|
-
];
|
|
3462
|
-
const combinedTools = Array.from(new Map(rawCombinedTools.map((t) => [
|
|
3463
|
-
(t == null ? void 0 : t.id) ?? (t == null ? void 0 : t.name) ?? (t == null ? void 0 : t.key) ?? JSON.stringify(t),
|
|
3464
|
-
t
|
|
3465
|
-
])).values());
|
|
3466
|
-
return {
|
|
3467
|
-
...aguiMergedState,
|
|
3468
|
-
copilotkit: {
|
|
3469
|
-
actions: combinedTools,
|
|
3470
|
-
context: (agui == null ? void 0 : agui.context) ?? []
|
|
3471
|
-
}
|
|
3472
|
-
};
|
|
3473
|
-
}
|
|
3474
|
-
async getSchemaKeys() {
|
|
3475
|
-
const CONSTANT_KEYS = [
|
|
3476
|
-
"copilotkit"
|
|
3477
|
-
];
|
|
3478
|
-
const schemaKeys = await super.getSchemaKeys();
|
|
3479
|
-
return {
|
|
3480
|
-
config: schemaKeys.config,
|
|
3481
|
-
input: schemaKeys.input ? [
|
|
3482
|
-
...schemaKeys.input,
|
|
3483
|
-
...CONSTANT_KEYS
|
|
3484
|
-
] : null,
|
|
3485
|
-
output: schemaKeys.output ? [
|
|
3486
|
-
...schemaKeys.output,
|
|
3487
|
-
...CONSTANT_KEYS
|
|
3488
|
-
] : null,
|
|
3489
|
-
context: schemaKeys.context ? [
|
|
3490
|
-
...schemaKeys.context,
|
|
3491
|
-
...CONSTANT_KEYS
|
|
3492
|
-
] : null
|
|
3493
|
-
};
|
|
3494
|
-
}
|
|
3495
|
-
};
|
|
3496
|
-
__name(LangGraphAgent, "LangGraphAgent");
|
|
3497
3455
|
var CopilotRuntime = class {
|
|
3498
3456
|
params;
|
|
3499
3457
|
observability;
|
|
@@ -3503,12 +3461,17 @@ var CopilotRuntime = class {
|
|
|
3503
3461
|
_instance;
|
|
3504
3462
|
constructor(params) {
|
|
3505
3463
|
const agents = (params == null ? void 0 : params.agents) ?? {};
|
|
3464
|
+
const endpointAgents = this.assignEndpointsToAgents((params == null ? void 0 : params.remoteEndpoints) ?? []);
|
|
3465
|
+
const baseRunner = (params == null ? void 0 : params.runner) ?? new InMemoryAgentRunner();
|
|
3466
|
+
const runner = isTelemetryDisabled() ? baseRunner : new TelemetryAgentRunner({
|
|
3467
|
+
runner: baseRunner
|
|
3468
|
+
});
|
|
3506
3469
|
this.runtimeArgs = {
|
|
3507
3470
|
agents: {
|
|
3508
|
-
...
|
|
3471
|
+
...endpointAgents,
|
|
3509
3472
|
...agents
|
|
3510
3473
|
},
|
|
3511
|
-
runner
|
|
3474
|
+
runner,
|
|
3512
3475
|
// TODO: add support for transcriptionService from CopilotRuntimeOptionsVNext once it is ready
|
|
3513
3476
|
// transcriptionService: params?.transcriptionService,
|
|
3514
3477
|
beforeRequestMiddleware: this.createOnBeforeRequestHandler(params).bind(this),
|
|
@@ -3524,29 +3487,16 @@ var CopilotRuntime = class {
|
|
|
3524
3487
|
return this._instance;
|
|
3525
3488
|
}
|
|
3526
3489
|
assignEndpointsToAgents(endpoints) {
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
deploymentUrl: lgEndpoint.deploymentUrl,
|
|
3535
|
-
langsmithApiKey: lgEndpoint.langsmithApiKey,
|
|
3536
|
-
graphId
|
|
3537
|
-
});
|
|
3538
|
-
});
|
|
3539
|
-
return {
|
|
3540
|
-
...acc,
|
|
3541
|
-
...lgAgents
|
|
3542
|
-
};
|
|
3543
|
-
}
|
|
3544
|
-
return acc;
|
|
3545
|
-
}, {});
|
|
3490
|
+
let result = {};
|
|
3491
|
+
if (endpoints.some((endpoint) => resolveEndpointType(endpoint) == EndpointType.LangGraphPlatform)) {
|
|
3492
|
+
throw new CopilotKitMisuseError({
|
|
3493
|
+
message: 'LangGraphPlatformEndpoint in remoteEndpoints is deprecated. Please use the "agents" option instead with LangGraphAgent from "@copilotkit/runtime/langgraph". Example: agents: { myAgent: new LangGraphAgent({ deploymentUrl: "...", graphId: "..." }) }'
|
|
3494
|
+
});
|
|
3495
|
+
}
|
|
3496
|
+
return result;
|
|
3546
3497
|
}
|
|
3547
3498
|
handleServiceAdapter(serviceAdapter) {
|
|
3548
3499
|
this.runtimeArgs.agents = Promise.resolve(this.runtimeArgs.agents ?? {}).then(async (agents) => {
|
|
3549
|
-
var _a;
|
|
3550
3500
|
let agentsList = agents;
|
|
3551
3501
|
const isAgentsListEmpty = !Object.keys(agents).length;
|
|
3552
3502
|
const hasServiceAdapter = Boolean(serviceAdapter);
|
|
@@ -3564,7 +3514,7 @@ var CopilotRuntime = class {
|
|
|
3564
3514
|
model: `${serviceAdapter.provider}/${serviceAdapter.model}`
|
|
3565
3515
|
});
|
|
3566
3516
|
}
|
|
3567
|
-
if (
|
|
3517
|
+
if (this.params.actions) {
|
|
3568
3518
|
const mcpTools = await this.getToolsFromMCP();
|
|
3569
3519
|
agentsList = this.assignToolsToAgents(agents, [
|
|
3570
3520
|
...this.getToolsFromActions(this.params.actions),
|
|
@@ -3585,7 +3535,8 @@ var CopilotRuntime = class {
|
|
|
3585
3535
|
return {
|
|
3586
3536
|
name: action.name,
|
|
3587
3537
|
description: action.description || "",
|
|
3588
|
-
parameters: zodSchema
|
|
3538
|
+
parameters: zodSchema,
|
|
3539
|
+
execute: () => Promise.resolve()
|
|
3589
3540
|
};
|
|
3590
3541
|
});
|
|
3591
3542
|
}
|
|
@@ -3613,11 +3564,24 @@ var CopilotRuntime = class {
|
|
|
3613
3564
|
}
|
|
3614
3565
|
createOnBeforeRequestHandler(params) {
|
|
3615
3566
|
return async (hookParams) => {
|
|
3616
|
-
var _a, _b;
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3567
|
+
var _a, _b, _c, _d;
|
|
3568
|
+
const { request } = hookParams;
|
|
3569
|
+
const publicApiKey = request.headers.get("x-copilotcloud-public-api-key");
|
|
3570
|
+
const body = await readBody(request);
|
|
3571
|
+
const forwardedProps = body.forwardedProps;
|
|
3572
|
+
const cloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL || "https://api.cloud.copilotkit.ai";
|
|
3573
|
+
telemetry_client_default.capture("oss.runtime.copilot_request_created", {
|
|
3574
|
+
"cloud.guardrails.enabled": ((_a = forwardedProps == null ? void 0 : forwardedProps.cloud) == null ? void 0 : _a.guardrails) !== void 0,
|
|
3575
|
+
requestType: ((_b = forwardedProps == null ? void 0 : forwardedProps.metadata) == null ? void 0 : _b.requestType) ?? "unknown",
|
|
3576
|
+
"cloud.api_key_provided": !!publicApiKey,
|
|
3577
|
+
...publicApiKey ? {
|
|
3578
|
+
"cloud.public_api_key": publicApiKey
|
|
3579
|
+
} : {},
|
|
3580
|
+
"cloud.base_url": cloudBaseUrl
|
|
3581
|
+
});
|
|
3582
|
+
(_c = params == null ? void 0 : params.beforeRequestMiddleware) == null ? void 0 : _c.call(params, hookParams);
|
|
3583
|
+
if ((_d = params == null ? void 0 : params.middleware) == null ? void 0 : _d.onBeforeRequest) {
|
|
3584
|
+
const { request: request2, runtime, path } = hookParams;
|
|
3621
3585
|
const gqlMessages = aguiToGQL(body.messages).reduce((acc, msg) => {
|
|
3622
3586
|
if ("role" in msg && msg.role === "user") {
|
|
3623
3587
|
acc.inputMessages.push(msg);
|
|
@@ -3635,7 +3599,7 @@ var CopilotRuntime = class {
|
|
|
3635
3599
|
runId: body.runId,
|
|
3636
3600
|
inputMessages,
|
|
3637
3601
|
properties: body.forwardedProps,
|
|
3638
|
-
url:
|
|
3602
|
+
url: request2.url
|
|
3639
3603
|
});
|
|
3640
3604
|
}
|
|
3641
3605
|
};
|
|
@@ -3736,7 +3700,8 @@ var CopilotRuntime = class {
|
|
|
3736
3700
|
return {
|
|
3737
3701
|
name: toolName,
|
|
3738
3702
|
description: tool.description || `MCP tool: ${toolName} (from ${endpointUrl})`,
|
|
3739
|
-
parameters: zodSchema
|
|
3703
|
+
parameters: zodSchema,
|
|
3704
|
+
execute: () => Promise.resolve()
|
|
3740
3705
|
};
|
|
3741
3706
|
});
|
|
3742
3707
|
this.mcpToolsCache.set(endpointUrl, toolDefs);
|
|
@@ -3887,6 +3852,38 @@ _ts_decorate19([
|
|
|
3887
3852
|
AgentsResponse = _ts_decorate19([
|
|
3888
3853
|
ObjectType()
|
|
3889
3854
|
], AgentsResponse);
|
|
3855
|
+
|
|
3856
|
+
// src/agents/langgraph/events.ts
|
|
3857
|
+
var LangGraphEventTypes;
|
|
3858
|
+
(function(LangGraphEventTypes2) {
|
|
3859
|
+
LangGraphEventTypes2["OnChainStart"] = "on_chain_start";
|
|
3860
|
+
LangGraphEventTypes2["OnChainStream"] = "on_chain_stream";
|
|
3861
|
+
LangGraphEventTypes2["OnChainEnd"] = "on_chain_end";
|
|
3862
|
+
LangGraphEventTypes2["OnChatModelStart"] = "on_chat_model_start";
|
|
3863
|
+
LangGraphEventTypes2["OnChatModelStream"] = "on_chat_model_stream";
|
|
3864
|
+
LangGraphEventTypes2["OnChatModelEnd"] = "on_chat_model_end";
|
|
3865
|
+
LangGraphEventTypes2["OnToolStart"] = "on_tool_start";
|
|
3866
|
+
LangGraphEventTypes2["OnToolEnd"] = "on_tool_end";
|
|
3867
|
+
LangGraphEventTypes2["OnCopilotKitStateSync"] = "on_copilotkit_state_sync";
|
|
3868
|
+
LangGraphEventTypes2["OnCopilotKitEmitMessage"] = "on_copilotkit_emit_message";
|
|
3869
|
+
LangGraphEventTypes2["OnCopilotKitEmitToolCall"] = "on_copilotkit_emit_tool_call";
|
|
3870
|
+
LangGraphEventTypes2["OnCustomEvent"] = "on_custom_event";
|
|
3871
|
+
LangGraphEventTypes2["OnInterrupt"] = "on_interrupt";
|
|
3872
|
+
LangGraphEventTypes2["OnCopilotKitInterrupt"] = "on_copilotkit_interrupt";
|
|
3873
|
+
LangGraphEventTypes2["OnCopilotKitError"] = "on_copilotkit_error";
|
|
3874
|
+
})(LangGraphEventTypes || (LangGraphEventTypes = {}));
|
|
3875
|
+
var MetaEventNames;
|
|
3876
|
+
(function(MetaEventNames2) {
|
|
3877
|
+
MetaEventNames2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
|
|
3878
|
+
MetaEventNames2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
|
|
3879
|
+
})(MetaEventNames || (MetaEventNames = {}));
|
|
3880
|
+
var CustomEventNames;
|
|
3881
|
+
(function(CustomEventNames2) {
|
|
3882
|
+
CustomEventNames2["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
|
|
3883
|
+
CustomEventNames2["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
|
|
3884
|
+
CustomEventNames2["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
|
|
3885
|
+
CustomEventNames2["CopilotKitExit"] = "copilotkit_exit";
|
|
3886
|
+
})(CustomEventNames || (CustomEventNames = {}));
|
|
3890
3887
|
function _ts_decorate20(decorators, target, key, desc) {
|
|
3891
3888
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3892
3889
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4718,7 +4715,9 @@ function copilotRuntimeNextJSAppRouterEndpoint(options) {
|
|
|
4718
4715
|
const logger2 = commonConfig.logging;
|
|
4719
4716
|
logger2.debug("Creating NextJS App Router endpoint");
|
|
4720
4717
|
const serviceAdapter = options.serviceAdapter;
|
|
4721
|
-
|
|
4718
|
+
if (serviceAdapter) {
|
|
4719
|
+
options.runtime.handleServiceAdapter(serviceAdapter);
|
|
4720
|
+
}
|
|
4722
4721
|
const copilotRoute = createCopilotEndpointSingleRoute({
|
|
4723
4722
|
runtime: options.runtime.instance,
|
|
4724
4723
|
basePath: options.baseUrl ?? options.endpoint
|
|
@@ -4748,12 +4747,59 @@ function readableStreamToNodeStream(webStream) {
|
|
|
4748
4747
|
}
|
|
4749
4748
|
__name(readableStreamToNodeStream, "readableStreamToNodeStream");
|
|
4750
4749
|
function getFullUrl(req) {
|
|
4751
|
-
const
|
|
4750
|
+
const expressPath = req.originalUrl ?? (req.baseUrl ? `${req.baseUrl}${req.url ?? ""}` : void 0);
|
|
4751
|
+
const path = expressPath || req.url || "/";
|
|
4752
4752
|
const host = req.headers["x-forwarded-host"] || req.headers.host || "localhost";
|
|
4753
4753
|
const proto = req.headers["x-forwarded-proto"] || (req.socket.encrypted ? "https" : "http");
|
|
4754
4754
|
return `${proto}://${host}${path}`;
|
|
4755
4755
|
}
|
|
4756
4756
|
__name(getFullUrl, "getFullUrl");
|
|
4757
|
+
function toHeaders(rawHeaders) {
|
|
4758
|
+
const headers = new Headers();
|
|
4759
|
+
for (const [key, value] of Object.entries(rawHeaders)) {
|
|
4760
|
+
if (value === void 0)
|
|
4761
|
+
continue;
|
|
4762
|
+
if (Array.isArray(value)) {
|
|
4763
|
+
value.forEach((entry) => headers.append(key, entry));
|
|
4764
|
+
continue;
|
|
4765
|
+
}
|
|
4766
|
+
headers.append(key, value);
|
|
4767
|
+
}
|
|
4768
|
+
return headers;
|
|
4769
|
+
}
|
|
4770
|
+
__name(toHeaders, "toHeaders");
|
|
4771
|
+
function isStreamConsumed(req) {
|
|
4772
|
+
const readableState = req._readableState;
|
|
4773
|
+
return Boolean(req.readableEnded || req.complete || (readableState == null ? void 0 : readableState.ended) || (readableState == null ? void 0 : readableState.endEmitted));
|
|
4774
|
+
}
|
|
4775
|
+
__name(isStreamConsumed, "isStreamConsumed");
|
|
4776
|
+
function synthesizeBodyFromParsedBody(parsedBody, headers) {
|
|
4777
|
+
if (parsedBody === null || parsedBody === void 0) {
|
|
4778
|
+
return {
|
|
4779
|
+
body: null
|
|
4780
|
+
};
|
|
4781
|
+
}
|
|
4782
|
+
if (parsedBody instanceof Buffer || parsedBody instanceof Uint8Array) {
|
|
4783
|
+
return {
|
|
4784
|
+
body: parsedBody
|
|
4785
|
+
};
|
|
4786
|
+
}
|
|
4787
|
+
if (typeof parsedBody === "string") {
|
|
4788
|
+
return {
|
|
4789
|
+
body: parsedBody,
|
|
4790
|
+
contentType: headers.get("content-type") ?? "text/plain"
|
|
4791
|
+
};
|
|
4792
|
+
}
|
|
4793
|
+
return {
|
|
4794
|
+
body: JSON.stringify(parsedBody),
|
|
4795
|
+
contentType: "application/json"
|
|
4796
|
+
};
|
|
4797
|
+
}
|
|
4798
|
+
__name(synthesizeBodyFromParsedBody, "synthesizeBodyFromParsedBody");
|
|
4799
|
+
function isDisturbedOrLockedError(error) {
|
|
4800
|
+
return error instanceof TypeError && typeof error.message === "string" && (error.message.includes("disturbed") || error.message.includes("locked"));
|
|
4801
|
+
}
|
|
4802
|
+
__name(isDisturbedOrLockedError, "isDisturbedOrLockedError");
|
|
4757
4803
|
function copilotRuntimeNodeHttpEndpoint(options) {
|
|
4758
4804
|
var _a;
|
|
4759
4805
|
const commonConfig = getCommonConfig(options);
|
|
@@ -4771,7 +4817,9 @@ function copilotRuntimeNodeHttpEndpoint(options) {
|
|
|
4771
4817
|
const logger2 = commonConfig.logging;
|
|
4772
4818
|
logger2.debug("Creating Node HTTP endpoint");
|
|
4773
4819
|
const serviceAdapter = options.serviceAdapter;
|
|
4774
|
-
|
|
4820
|
+
if (serviceAdapter) {
|
|
4821
|
+
options.runtime.handleServiceAdapter(serviceAdapter);
|
|
4822
|
+
}
|
|
4775
4823
|
const honoApp = createCopilotEndpointSingleRoute({
|
|
4776
4824
|
runtime: options.runtime.instance,
|
|
4777
4825
|
basePath: options.baseUrl ?? options.endpoint
|
|
@@ -4779,14 +4827,59 @@ function copilotRuntimeNodeHttpEndpoint(options) {
|
|
|
4779
4827
|
return /* @__PURE__ */ __name(async function handler(req, res) {
|
|
4780
4828
|
const url = getFullUrl(req);
|
|
4781
4829
|
const hasBody = req.method !== "GET" && req.method !== "HEAD";
|
|
4782
|
-
const
|
|
4830
|
+
const baseHeaders = toHeaders(req.headers);
|
|
4831
|
+
const parsedBody = req.body;
|
|
4832
|
+
const streamConsumed = isStreamConsumed(req) || parsedBody !== void 0;
|
|
4833
|
+
const canStream = hasBody && !streamConsumed;
|
|
4834
|
+
let requestBody = void 0;
|
|
4835
|
+
let useDuplex = false;
|
|
4836
|
+
if (hasBody && canStream) {
|
|
4837
|
+
requestBody = req;
|
|
4838
|
+
useDuplex = true;
|
|
4839
|
+
}
|
|
4840
|
+
if (hasBody && streamConsumed) {
|
|
4841
|
+
if (parsedBody !== void 0) {
|
|
4842
|
+
const synthesized = synthesizeBodyFromParsedBody(parsedBody, baseHeaders);
|
|
4843
|
+
requestBody = synthesized.body ?? void 0;
|
|
4844
|
+
baseHeaders.delete("content-length");
|
|
4845
|
+
if (synthesized.contentType) {
|
|
4846
|
+
baseHeaders.set("content-type", synthesized.contentType);
|
|
4847
|
+
}
|
|
4848
|
+
logger2.debug("Request stream already consumed; using parsed req.body to rebuild request.");
|
|
4849
|
+
} else {
|
|
4850
|
+
logger2.warn("Request stream consumed with no available body; sending empty payload.");
|
|
4851
|
+
requestBody = void 0;
|
|
4852
|
+
}
|
|
4853
|
+
}
|
|
4854
|
+
const buildRequest = /* @__PURE__ */ __name((body, headers, duplex) => new Request(url, {
|
|
4783
4855
|
method: req.method,
|
|
4784
|
-
headers
|
|
4785
|
-
body
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4856
|
+
headers,
|
|
4857
|
+
body,
|
|
4858
|
+
duplex: duplex ? "half" : void 0
|
|
4859
|
+
}), "buildRequest");
|
|
4860
|
+
let response;
|
|
4861
|
+
try {
|
|
4862
|
+
response = await honoApp.fetch(buildRequest(requestBody, baseHeaders, useDuplex));
|
|
4863
|
+
} catch (error) {
|
|
4864
|
+
if (isDisturbedOrLockedError(error) && hasBody) {
|
|
4865
|
+
logger2.warn("Encountered disturbed/locked request body; rebuilding request using parsed body or empty payload.");
|
|
4866
|
+
const fallbackHeaders = new Headers(baseHeaders);
|
|
4867
|
+
let fallbackBody;
|
|
4868
|
+
if (parsedBody !== void 0) {
|
|
4869
|
+
const synthesized = synthesizeBodyFromParsedBody(parsedBody, fallbackHeaders);
|
|
4870
|
+
fallbackBody = synthesized.body ?? void 0;
|
|
4871
|
+
fallbackHeaders.delete("content-length");
|
|
4872
|
+
if (synthesized.contentType) {
|
|
4873
|
+
fallbackHeaders.set("content-type", synthesized.contentType);
|
|
4874
|
+
}
|
|
4875
|
+
} else {
|
|
4876
|
+
fallbackBody = void 0;
|
|
4877
|
+
}
|
|
4878
|
+
response = await honoApp.fetch(buildRequest(fallbackBody, fallbackHeaders, false));
|
|
4879
|
+
} else {
|
|
4880
|
+
throw error;
|
|
4881
|
+
}
|
|
4882
|
+
}
|
|
4790
4883
|
res.statusCode = response.status;
|
|
4791
4884
|
response.headers.forEach((value, key) => {
|
|
4792
4885
|
res.setHeader(key, value);
|
|
@@ -4849,6 +4942,22 @@ function copilotRuntimeNestEndpoint(options) {
|
|
|
4849
4942
|
return copilotRuntimeNodeHttpEndpoint(options);
|
|
4850
4943
|
}
|
|
4851
4944
|
__name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|
|
4945
|
+
|
|
4946
|
+
// src/lib/index.ts
|
|
4947
|
+
var LangGraphAgent = class {
|
|
4948
|
+
constructor() {
|
|
4949
|
+
throw new Error("LangGraphAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead");
|
|
4950
|
+
}
|
|
4951
|
+
};
|
|
4952
|
+
__name(LangGraphAgent, "LangGraphAgent");
|
|
4953
|
+
var LangGraphHttpAgent = class {
|
|
4954
|
+
constructor() {
|
|
4955
|
+
throw new Error("LangGraphHttpAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead");
|
|
4956
|
+
}
|
|
4957
|
+
};
|
|
4958
|
+
__name(LangGraphHttpAgent, "LangGraphHttpAgent");
|
|
4959
|
+
|
|
4960
|
+
// src/service-adapters/langchain/langserve.ts
|
|
4852
4961
|
var RemoteChain = class {
|
|
4853
4962
|
name;
|
|
4854
4963
|
description;
|
|
@@ -4871,6 +4980,7 @@ var RemoteChain = class {
|
|
|
4871
4980
|
description: this.description,
|
|
4872
4981
|
parameters: this.parameters,
|
|
4873
4982
|
handler: async (args) => {
|
|
4983
|
+
const { RemoteRunnable } = __require("langchain/runnables/remote");
|
|
4874
4984
|
const runnable = new RemoteRunnable({
|
|
4875
4985
|
url: this.chainUrl
|
|
4876
4986
|
});
|
|
@@ -5083,7 +5193,9 @@ var AnthropicAdapter = class {
|
|
|
5083
5193
|
return "AnthropicAdapter";
|
|
5084
5194
|
}
|
|
5085
5195
|
constructor(params) {
|
|
5086
|
-
|
|
5196
|
+
if (params == null ? void 0 : params.anthropic) {
|
|
5197
|
+
this._anthropic = params.anthropic;
|
|
5198
|
+
}
|
|
5087
5199
|
if (params == null ? void 0 : params.model) {
|
|
5088
5200
|
this.model = params.model;
|
|
5089
5201
|
}
|
|
@@ -5091,6 +5203,13 @@ var AnthropicAdapter = class {
|
|
|
5091
5203
|
enabled: false
|
|
5092
5204
|
};
|
|
5093
5205
|
}
|
|
5206
|
+
ensureAnthropic() {
|
|
5207
|
+
if (!this._anthropic) {
|
|
5208
|
+
const Anthropic = __require("@anthropic-ai/sdk").default;
|
|
5209
|
+
this._anthropic = new Anthropic({});
|
|
5210
|
+
}
|
|
5211
|
+
return this._anthropic;
|
|
5212
|
+
}
|
|
5094
5213
|
/**
|
|
5095
5214
|
* Adds cache control to system prompt
|
|
5096
5215
|
*/
|
|
@@ -5231,7 +5350,8 @@ var AnthropicAdapter = class {
|
|
|
5231
5350
|
},
|
|
5232
5351
|
stream: true
|
|
5233
5352
|
};
|
|
5234
|
-
const
|
|
5353
|
+
const anthropic = this.ensureAnthropic();
|
|
5354
|
+
const stream = await anthropic.messages.create(createParams);
|
|
5235
5355
|
eventSource.stream(async (eventStream$) => {
|
|
5236
5356
|
let mode = null;
|
|
5237
5357
|
let didOutputText = false;
|
|
@@ -5376,6 +5496,7 @@ var ExperimentalOllamaAdapter = class {
|
|
|
5376
5496
|
}
|
|
5377
5497
|
async process(request) {
|
|
5378
5498
|
const { messages, actions, eventSource } = request;
|
|
5499
|
+
const { Ollama } = __require("@langchain/community/llms/ollama");
|
|
5379
5500
|
const ollama = new Ollama({
|
|
5380
5501
|
model: this.model
|
|
5381
5502
|
});
|
|
@@ -5403,6 +5524,8 @@ var ExperimentalOllamaAdapter = class {
|
|
|
5403
5524
|
}
|
|
5404
5525
|
};
|
|
5405
5526
|
__name(ExperimentalOllamaAdapter, "ExperimentalOllamaAdapter");
|
|
5527
|
+
|
|
5528
|
+
// src/service-adapters/bedrock/bedrock-adapter.ts
|
|
5406
5529
|
var DEFAULT_MODEL6 = "amazon.nova-lite-v1:0";
|
|
5407
5530
|
var BedrockAdapter = class extends LangChainAdapter {
|
|
5408
5531
|
provider = "bedrock";
|
|
@@ -5410,6 +5533,7 @@ var BedrockAdapter = class extends LangChainAdapter {
|
|
|
5410
5533
|
constructor(options) {
|
|
5411
5534
|
super({
|
|
5412
5535
|
chainFn: async ({ messages, tools, threadId }) => {
|
|
5536
|
+
const { ChatBedrockConverse } = __require("@langchain/aws");
|
|
5413
5537
|
this.model = (options == null ? void 0 : options.model) ?? "amazon.nova-lite-v1:0";
|
|
5414
5538
|
const model = new ChatBedrockConverse({
|
|
5415
5539
|
model: this.model,
|
|
@@ -5438,6 +5562,6 @@ var EmptyAdapter = class {
|
|
|
5438
5562
|
__name(EmptyAdapter, "EmptyAdapter");
|
|
5439
5563
|
var ExperimentalEmptyAdapter = EmptyAdapter;
|
|
5440
5564
|
|
|
5441
|
-
export { AnthropicAdapter, BedrockAdapter, CopilotRuntime,
|
|
5565
|
+
export { AnthropicAdapter, BedrockAdapter, CopilotRuntime, EmptyAdapter, ExperimentalEmptyAdapter, ExperimentalOllamaAdapter, GoogleGenerativeAIAdapter, GroqAdapter, GuardrailsValidationFailureResponse, LangChainAdapter, LangGraphAgent, LangGraphHttpAgent, MessageStreamInterruptedResponse, OpenAIAdapter, OpenAIAssistantAdapter, RemoteChain, TelemetryAgentRunner, UnifyAdapter, UnknownErrorResponse, addCustomHeaderPlugin, buildSchema, config, convertMCPToolsToActions, convertServiceAdapterError, copilotKitEndpoint, copilotRuntimeNestEndpoint, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint, copilotRuntimeNodeExpressEndpoint, copilotRuntimeNodeHttpEndpoint, createContext, createLogger, extractParametersFromSchema, generateMcpToolInstructions, getCommonConfig, langGraphPlatformEndpoint, readableStreamToNodeStream, resolveEndpointType };
|
|
5442
5566
|
//# sourceMappingURL=out.js.map
|
|
5443
5567
|
//# sourceMappingURL=index.mjs.map
|