@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.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('reflect-metadata');
|
|
4
|
-
var OpenAI = require('openai');
|
|
5
4
|
var shared = require('@copilotkit/shared');
|
|
6
5
|
var messages = require('@langchain/core/messages');
|
|
7
6
|
var tools = require('@langchain/core/tools');
|
|
8
|
-
var promises = require('@langchain/core/callbacks/promises');
|
|
9
|
-
var googleGauth = require('@langchain/google-gauth');
|
|
10
|
-
var groqSdk = require('groq-sdk');
|
|
11
7
|
var typeGraphql = require('type-graphql');
|
|
12
8
|
var rxjs = require('rxjs');
|
|
13
9
|
var graphqlScalars = require('graphql-scalars');
|
|
@@ -16,25 +12,17 @@ var classTransformer = require('class-transformer');
|
|
|
16
12
|
var graphql = require('graphql');
|
|
17
13
|
var crypto = require('crypto');
|
|
18
14
|
var runtime = require('@copilotkitnext/runtime');
|
|
19
|
-
var client = require('@ag-ui/client');
|
|
20
|
-
var langgraph = require('@ag-ui/langgraph');
|
|
21
15
|
var agent = require('@copilotkitnext/agent');
|
|
22
16
|
var pluginDeferStream = require('@graphql-yoga/plugin-defer-stream');
|
|
23
17
|
var createPinoLogger = require('pino');
|
|
24
18
|
var pretty = require('pino-pretty');
|
|
25
19
|
var vercel = require('hono/vercel');
|
|
26
20
|
var stream = require('stream');
|
|
27
|
-
var remote = require('langchain/runnables/remote');
|
|
28
|
-
var Anthropic = require('@anthropic-ai/sdk');
|
|
29
|
-
var ollama = require('@langchain/community/llms/ollama');
|
|
30
|
-
var aws = require('@langchain/aws');
|
|
31
21
|
|
|
32
22
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
33
23
|
|
|
34
|
-
var OpenAI__default = /*#__PURE__*/_interopDefault(OpenAI);
|
|
35
24
|
var createPinoLogger__default = /*#__PURE__*/_interopDefault(createPinoLogger);
|
|
36
25
|
var pretty__default = /*#__PURE__*/_interopDefault(pretty);
|
|
37
|
-
var Anthropic__default = /*#__PURE__*/_interopDefault(Anthropic);
|
|
38
26
|
|
|
39
27
|
var __create = Object.create;
|
|
40
28
|
var __defProp = Object.defineProperty;
|
|
@@ -43,7 +31,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
43
31
|
var __getProtoOf = Object.getPrototypeOf;
|
|
44
32
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
45
33
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
46
|
-
var
|
|
34
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
35
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
36
|
+
}) : x)(function(x) {
|
|
37
|
+
if (typeof require !== "undefined")
|
|
38
|
+
return require.apply(this, arguments);
|
|
39
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
40
|
+
});
|
|
41
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
47
42
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
48
43
|
};
|
|
49
44
|
var __copyProps = (to, from, except, desc) => {
|
|
@@ -77,7 +72,7 @@ var require_package = __commonJS({
|
|
|
77
72
|
publishConfig: {
|
|
78
73
|
access: "public"
|
|
79
74
|
},
|
|
80
|
-
version: "1.50.0-beta.
|
|
75
|
+
version: "1.50.0-beta.10",
|
|
81
76
|
sideEffects: false,
|
|
82
77
|
main: "./dist/index.js",
|
|
83
78
|
module: "./dist/index.mjs",
|
|
@@ -91,6 +86,11 @@ var require_package = __commonJS({
|
|
|
91
86
|
import: "./dist/v2/index.mjs",
|
|
92
87
|
require: "./dist/v2/index.js",
|
|
93
88
|
types: "./dist/v2/index.d.ts"
|
|
89
|
+
},
|
|
90
|
+
"./langgraph": {
|
|
91
|
+
import: "./dist/langgraph.mjs",
|
|
92
|
+
require: "./dist/langgraph.js",
|
|
93
|
+
types: "./dist/langgraph.d.ts"
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
types: "./dist/index.d.ts",
|
|
@@ -120,29 +120,21 @@ var require_package = __commonJS({
|
|
|
120
120
|
tsconfig: "workspace:*",
|
|
121
121
|
tsup: "^6.7.0",
|
|
122
122
|
typescript: "^5.2.3",
|
|
123
|
-
vitest: "^3.2.4"
|
|
124
|
-
"zod-to-json-schema": "^3.23.5"
|
|
123
|
+
vitest: "^3.2.4"
|
|
125
124
|
},
|
|
126
125
|
dependencies: {
|
|
127
|
-
"@anthropic-ai/sdk": "^0.57.0",
|
|
128
126
|
"@copilotkit/shared": "workspace:*",
|
|
129
|
-
"@copilotkitnext/agent": "0.0.
|
|
130
|
-
"@copilotkitnext/runtime": "0.0.
|
|
127
|
+
"@copilotkitnext/agent": "0.0.28",
|
|
128
|
+
"@copilotkitnext/runtime": "0.0.28",
|
|
131
129
|
"@graphql-yoga/plugin-defer-stream": "^3.3.1",
|
|
132
|
-
"@
|
|
133
|
-
"@langchain/community": "^0.3.29",
|
|
130
|
+
"@hono/node-server": "^1.13.5",
|
|
134
131
|
"@langchain/core": "^0.3.38",
|
|
135
|
-
"@langchain/google-gauth": "^0.1.0",
|
|
136
|
-
"@langchain/langgraph-sdk": "^0.0.70",
|
|
137
|
-
"@langchain/openai": "^0.4.2",
|
|
138
132
|
"@scarf/scarf": "^1.3.0",
|
|
139
133
|
"class-transformer": "^0.5.1",
|
|
140
134
|
"class-validator": "^0.14.1",
|
|
141
135
|
graphql: "^16.8.1",
|
|
142
136
|
"graphql-scalars": "^1.23.0",
|
|
143
137
|
"graphql-yoga": "^5.3.1",
|
|
144
|
-
"groq-sdk": "^0.5.0",
|
|
145
|
-
"@hono/node-server": "^1.13.5",
|
|
146
138
|
hono: "^4.10.3",
|
|
147
139
|
langchain: "^0.3.3",
|
|
148
140
|
openai: "^4.85.1",
|
|
@@ -155,11 +147,52 @@ var require_package = __commonJS({
|
|
|
155
147
|
zod: "^3.23.3"
|
|
156
148
|
},
|
|
157
149
|
peerDependencies: {
|
|
158
|
-
"@
|
|
159
|
-
"@ag-ui/
|
|
160
|
-
"@ag-ui/
|
|
161
|
-
"@ag-ui/
|
|
162
|
-
"@ag-ui/
|
|
150
|
+
"@anthropic-ai/sdk": "^0.57.0",
|
|
151
|
+
"@ag-ui/client": "^0.0.42",
|
|
152
|
+
"@ag-ui/core": ">=0.0.42",
|
|
153
|
+
"@ag-ui/encoder": ">=0.0.42",
|
|
154
|
+
"@ag-ui/langgraph": ">=0.0.20",
|
|
155
|
+
"@ag-ui/proto": ">=0.0.42",
|
|
156
|
+
"@langchain/aws": "^0.1.9",
|
|
157
|
+
"@langchain/community": "^0.3.58",
|
|
158
|
+
"@langchain/google-gauth": "^0.1.0",
|
|
159
|
+
"@langchain/langgraph-sdk": "^0.0.70",
|
|
160
|
+
"@langchain/openai": "^0.4.2",
|
|
161
|
+
"groq-sdk": ">=0.3.0 <1.0.0",
|
|
162
|
+
langchain: "^0.3.3",
|
|
163
|
+
openai: "^4.85.1"
|
|
164
|
+
},
|
|
165
|
+
peerDependenciesMeta: {
|
|
166
|
+
"@anthropic-ai/sdk": {
|
|
167
|
+
optional: true
|
|
168
|
+
},
|
|
169
|
+
"@ag-ui/langgraph": {
|
|
170
|
+
optional: true
|
|
171
|
+
},
|
|
172
|
+
"@langchain/aws": {
|
|
173
|
+
optional: true
|
|
174
|
+
},
|
|
175
|
+
"@langchain/community": {
|
|
176
|
+
optional: true
|
|
177
|
+
},
|
|
178
|
+
"@langchain/google-gauth": {
|
|
179
|
+
optional: true
|
|
180
|
+
},
|
|
181
|
+
"@langchain/langgraph-sdk": {
|
|
182
|
+
optional: true
|
|
183
|
+
},
|
|
184
|
+
"@langchain/openai": {
|
|
185
|
+
optional: true
|
|
186
|
+
},
|
|
187
|
+
"groq-sdk": {
|
|
188
|
+
optional: true
|
|
189
|
+
},
|
|
190
|
+
langchain: {
|
|
191
|
+
optional: true
|
|
192
|
+
},
|
|
193
|
+
openai: {
|
|
194
|
+
optional: true
|
|
195
|
+
}
|
|
163
196
|
},
|
|
164
197
|
keywords: [
|
|
165
198
|
"copilotkit",
|
|
@@ -410,13 +443,22 @@ var OpenAIAdapter = class {
|
|
|
410
443
|
return "OpenAIAdapter";
|
|
411
444
|
}
|
|
412
445
|
constructor(params) {
|
|
413
|
-
|
|
446
|
+
if (params == null ? void 0 : params.openai) {
|
|
447
|
+
this._openai = params.openai;
|
|
448
|
+
}
|
|
414
449
|
if (params == null ? void 0 : params.model) {
|
|
415
450
|
this.model = params.model;
|
|
416
451
|
}
|
|
417
452
|
this.disableParallelToolCalls = (params == null ? void 0 : params.disableParallelToolCalls) || false;
|
|
418
453
|
this.keepSystemRole = (params == null ? void 0 : params.keepSystemRole) ?? false;
|
|
419
454
|
}
|
|
455
|
+
ensureOpenAI() {
|
|
456
|
+
if (!this._openai) {
|
|
457
|
+
const OpenAI = __require("openai").default;
|
|
458
|
+
this._openai = new OpenAI();
|
|
459
|
+
}
|
|
460
|
+
return this._openai;
|
|
461
|
+
}
|
|
420
462
|
async process(request) {
|
|
421
463
|
const { threadId: threadIdFromRequest, model = this.model, messages, actions, eventSource, forwardedParameters } = request;
|
|
422
464
|
const tools = actions.map(convertActionInputToOpenAITool);
|
|
@@ -451,7 +493,8 @@ var OpenAIAdapter = class {
|
|
|
451
493
|
};
|
|
452
494
|
}
|
|
453
495
|
try {
|
|
454
|
-
const
|
|
496
|
+
const openai = this.ensureOpenAI();
|
|
497
|
+
const stream = openai.beta.chat.completions.stream({
|
|
455
498
|
model,
|
|
456
499
|
stream: true,
|
|
457
500
|
messages: openaiMessages,
|
|
@@ -811,26 +854,32 @@ var LangChainAdapter = class {
|
|
|
811
854
|
threadId
|
|
812
855
|
};
|
|
813
856
|
} finally {
|
|
814
|
-
|
|
857
|
+
const { awaitAllCallbacks } = __require("@langchain/core/callbacks/promises");
|
|
858
|
+
await awaitAllCallbacks();
|
|
815
859
|
}
|
|
816
860
|
}
|
|
817
861
|
};
|
|
818
862
|
__name(LangChainAdapter, "LangChainAdapter");
|
|
863
|
+
|
|
864
|
+
// src/service-adapters/google/google-genai-adapter.ts
|
|
819
865
|
var DEFAULT_MODEL2 = "gemini-1.5-pro";
|
|
820
866
|
var GoogleGenerativeAIAdapter = class extends LangChainAdapter {
|
|
821
867
|
provider = "google";
|
|
822
868
|
model = DEFAULT_MODEL2;
|
|
823
869
|
constructor(options) {
|
|
824
870
|
super({
|
|
825
|
-
chainFn: async ({ messages
|
|
826
|
-
const
|
|
827
|
-
|
|
871
|
+
chainFn: async ({ messages, tools, threadId }) => {
|
|
872
|
+
const { ChatGoogle } = __require("@langchain/google-gauth");
|
|
873
|
+
const { AIMessage: AIMessage2 } = __require("@langchain/core/messages");
|
|
874
|
+
const filteredMessages = messages.filter((message) => {
|
|
875
|
+
if (!(message instanceof AIMessage2)) {
|
|
828
876
|
return true;
|
|
829
877
|
}
|
|
830
|
-
|
|
878
|
+
const aiMsg = message;
|
|
879
|
+
return aiMsg.content && String(aiMsg.content).trim().length > 0 || aiMsg.tool_calls && aiMsg.tool_calls.length > 0;
|
|
831
880
|
});
|
|
832
881
|
this.model = (options == null ? void 0 : options.model) ?? "gemini-1.5-pro";
|
|
833
|
-
const model = new
|
|
882
|
+
const model = new ChatGoogle({
|
|
834
883
|
apiKey: (options == null ? void 0 : options.apiKey) ?? process.env.GOOGLE_API_KEY,
|
|
835
884
|
modelName: this.model,
|
|
836
885
|
apiVersion: "v1beta"
|
|
@@ -845,8 +894,10 @@ var GoogleGenerativeAIAdapter = class extends LangChainAdapter {
|
|
|
845
894
|
}
|
|
846
895
|
};
|
|
847
896
|
__name(GoogleGenerativeAIAdapter, "GoogleGenerativeAIAdapter");
|
|
897
|
+
|
|
898
|
+
// src/service-adapters/openai/openai-assistant-adapter.ts
|
|
848
899
|
var OpenAIAssistantAdapter = class {
|
|
849
|
-
|
|
900
|
+
_openai;
|
|
850
901
|
codeInterpreterEnabled;
|
|
851
902
|
assistantId;
|
|
852
903
|
fileSearchEnabled;
|
|
@@ -856,19 +907,29 @@ var OpenAIAssistantAdapter = class {
|
|
|
856
907
|
return "OpenAIAssistantAdapter";
|
|
857
908
|
}
|
|
858
909
|
constructor(params) {
|
|
859
|
-
|
|
910
|
+
if (params.openai) {
|
|
911
|
+
this._openai = params.openai;
|
|
912
|
+
}
|
|
860
913
|
this.codeInterpreterEnabled = params.codeInterpreterEnabled === false || true;
|
|
861
914
|
this.fileSearchEnabled = params.fileSearchEnabled === false || true;
|
|
862
915
|
this.assistantId = params.assistantId;
|
|
863
916
|
this.disableParallelToolCalls = (params == null ? void 0 : params.disableParallelToolCalls) || false;
|
|
864
917
|
this.keepSystemRole = (params == null ? void 0 : params.keepSystemRole) ?? false;
|
|
865
918
|
}
|
|
919
|
+
ensureOpenAI() {
|
|
920
|
+
if (!this._openai) {
|
|
921
|
+
const OpenAI = __require("openai").default;
|
|
922
|
+
this._openai = new OpenAI({});
|
|
923
|
+
}
|
|
924
|
+
return this._openai;
|
|
925
|
+
}
|
|
866
926
|
async process(request) {
|
|
867
927
|
var _a, _b;
|
|
868
928
|
const { messages, actions, eventSource, runId, forwardedParameters } = request;
|
|
869
929
|
let threadId = (_b = (_a = request.extensions) == null ? void 0 : _a.openaiAssistantAPI) == null ? void 0 : _b.threadId;
|
|
930
|
+
const openai = this.ensureOpenAI();
|
|
870
931
|
if (!threadId) {
|
|
871
|
-
threadId = (await
|
|
932
|
+
threadId = (await openai.beta.threads.create()).id;
|
|
872
933
|
}
|
|
873
934
|
const lastMessage = messages.at(-1);
|
|
874
935
|
let nextRunId = void 0;
|
|
@@ -892,7 +953,8 @@ var OpenAIAssistantAdapter = class {
|
|
|
892
953
|
};
|
|
893
954
|
}
|
|
894
955
|
async submitToolOutputs(threadId, runId, messages, eventSource) {
|
|
895
|
-
|
|
956
|
+
const openai = this.ensureOpenAI();
|
|
957
|
+
let run = await openai.beta.threads.runs.retrieve(threadId, runId);
|
|
896
958
|
if (!run.required_action) {
|
|
897
959
|
throw new Error("No tool outputs required");
|
|
898
960
|
}
|
|
@@ -907,7 +969,7 @@ var OpenAIAssistantAdapter = class {
|
|
|
907
969
|
output: message.result
|
|
908
970
|
};
|
|
909
971
|
});
|
|
910
|
-
const stream =
|
|
972
|
+
const stream = openai.beta.threads.runs.submitToolOutputsStream(threadId, runId, {
|
|
911
973
|
tool_outputs: toolOutputs,
|
|
912
974
|
...this.disableParallelToolCalls && {
|
|
913
975
|
parallel_tool_calls: false
|
|
@@ -917,6 +979,7 @@ var OpenAIAssistantAdapter = class {
|
|
|
917
979
|
return runId;
|
|
918
980
|
}
|
|
919
981
|
async submitUserMessage(threadId, messages, actions, eventSource, forwardedParameters) {
|
|
982
|
+
const openai = this.ensureOpenAI();
|
|
920
983
|
messages = [
|
|
921
984
|
...messages
|
|
922
985
|
];
|
|
@@ -928,7 +991,7 @@ var OpenAIAssistantAdapter = class {
|
|
|
928
991
|
if (userMessage.role !== "user") {
|
|
929
992
|
throw new Error("No user message found");
|
|
930
993
|
}
|
|
931
|
-
await
|
|
994
|
+
await openai.beta.threads.messages.create(threadId, {
|
|
932
995
|
role: "user",
|
|
933
996
|
content: userMessage.content
|
|
934
997
|
});
|
|
@@ -946,7 +1009,7 @@ var OpenAIAssistantAdapter = class {
|
|
|
946
1009
|
}
|
|
947
1010
|
] : []
|
|
948
1011
|
];
|
|
949
|
-
let stream =
|
|
1012
|
+
let stream = openai.beta.threads.runs.stream(threadId, {
|
|
950
1013
|
assistant_id: this.assistantId,
|
|
951
1014
|
instructions,
|
|
952
1015
|
tools,
|
|
@@ -1065,7 +1128,8 @@ var UnifyAdapter = class {
|
|
|
1065
1128
|
}
|
|
1066
1129
|
async process(request) {
|
|
1067
1130
|
const tools = request.actions.map(convertActionInputToOpenAITool);
|
|
1068
|
-
const
|
|
1131
|
+
const OpenAI = __require("openai").default;
|
|
1132
|
+
const openai = new OpenAI({
|
|
1069
1133
|
apiKey: this.apiKey,
|
|
1070
1134
|
baseURL: "https://api.unify.ai/v0/"
|
|
1071
1135
|
});
|
|
@@ -1176,12 +1240,21 @@ var GroqAdapter = class {
|
|
|
1176
1240
|
return "GroqAdapter";
|
|
1177
1241
|
}
|
|
1178
1242
|
constructor(params) {
|
|
1179
|
-
|
|
1243
|
+
if (params == null ? void 0 : params.groq) {
|
|
1244
|
+
this._groq = params.groq;
|
|
1245
|
+
}
|
|
1180
1246
|
if (params == null ? void 0 : params.model) {
|
|
1181
1247
|
this.model = params.model;
|
|
1182
1248
|
}
|
|
1183
1249
|
this.disableParallelToolCalls = (params == null ? void 0 : params.disableParallelToolCalls) || false;
|
|
1184
1250
|
}
|
|
1251
|
+
ensureGroq() {
|
|
1252
|
+
if (!this._groq) {
|
|
1253
|
+
const { Groq } = __require("groq-sdk");
|
|
1254
|
+
this._groq = new Groq({});
|
|
1255
|
+
}
|
|
1256
|
+
return this._groq;
|
|
1257
|
+
}
|
|
1185
1258
|
async process(request) {
|
|
1186
1259
|
const { threadId, model = this.model, messages, actions, eventSource, forwardedParameters } = request;
|
|
1187
1260
|
const tools = actions.map(convertActionInputToOpenAITool);
|
|
@@ -1200,7 +1273,8 @@ var GroqAdapter = class {
|
|
|
1200
1273
|
}
|
|
1201
1274
|
let stream;
|
|
1202
1275
|
try {
|
|
1203
|
-
|
|
1276
|
+
const groq = this.ensureGroq();
|
|
1277
|
+
stream = await groq.chat.completions.create({
|
|
1204
1278
|
model,
|
|
1205
1279
|
stream: true,
|
|
1206
1280
|
messages: openaiMessages,
|
|
@@ -3166,6 +3240,82 @@ function aguiMessageWithImageToGQLMessage(message) {
|
|
|
3166
3240
|
});
|
|
3167
3241
|
}
|
|
3168
3242
|
__name(aguiMessageWithImageToGQLMessage, "aguiMessageWithImageToGQLMessage");
|
|
3243
|
+
var TelemetryAgentRunner = class {
|
|
3244
|
+
_runner;
|
|
3245
|
+
hashedLgcKey;
|
|
3246
|
+
constructor(config2) {
|
|
3247
|
+
this._runner = (config2 == null ? void 0 : config2.runner) ?? new runtime.InMemoryAgentRunner();
|
|
3248
|
+
this.hashedLgcKey = (config2 == null ? void 0 : config2.langsmithApiKey) ? crypto.createHash("sha256").update(config2.langsmithApiKey).digest("hex") : void 0;
|
|
3249
|
+
}
|
|
3250
|
+
/**
|
|
3251
|
+
* Runs an agent with telemetry tracking.
|
|
3252
|
+
* Wraps the underlying runner's Observable stream with telemetry events.
|
|
3253
|
+
*/
|
|
3254
|
+
run(...args) {
|
|
3255
|
+
const streamInfo = {
|
|
3256
|
+
hashedLgcKey: this.hashedLgcKey
|
|
3257
|
+
};
|
|
3258
|
+
let streamErrored = false;
|
|
3259
|
+
telemetry_client_default.capture("oss.runtime.agent_execution_stream_started", {
|
|
3260
|
+
hashedLgcKey: this.hashedLgcKey
|
|
3261
|
+
});
|
|
3262
|
+
return this._runner.run(...args).pipe(
|
|
3263
|
+
// Extract metadata from events if available
|
|
3264
|
+
rxjs.tap((event) => {
|
|
3265
|
+
var _a;
|
|
3266
|
+
const rawEvent = event.rawEvent;
|
|
3267
|
+
if (rawEvent == null ? void 0 : rawEvent.data) {
|
|
3268
|
+
const data = rawEvent.data;
|
|
3269
|
+
if ((_a = data == null ? void 0 : data.output) == null ? void 0 : _a.model) {
|
|
3270
|
+
streamInfo.model = data.output.model;
|
|
3271
|
+
streamInfo.provider = data.output.model;
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3274
|
+
if (rawEvent == null ? void 0 : rawEvent.metadata) {
|
|
3275
|
+
const metadata = rawEvent.metadata;
|
|
3276
|
+
if (metadata == null ? void 0 : metadata.langgraph_host) {
|
|
3277
|
+
streamInfo.langGraphHost = metadata.langgraph_host;
|
|
3278
|
+
}
|
|
3279
|
+
if (metadata == null ? void 0 : metadata.langgraph_version) {
|
|
3280
|
+
streamInfo.langGraphVersion = metadata.langgraph_version;
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
}),
|
|
3284
|
+
rxjs.catchError((error) => {
|
|
3285
|
+
streamErrored = true;
|
|
3286
|
+
telemetry_client_default.capture("oss.runtime.agent_execution_stream_errored", {
|
|
3287
|
+
...streamInfo,
|
|
3288
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3289
|
+
});
|
|
3290
|
+
throw error;
|
|
3291
|
+
}),
|
|
3292
|
+
rxjs.finalize(() => {
|
|
3293
|
+
if (!streamErrored) {
|
|
3294
|
+
telemetry_client_default.capture("oss.runtime.agent_execution_stream_ended", streamInfo);
|
|
3295
|
+
}
|
|
3296
|
+
})
|
|
3297
|
+
);
|
|
3298
|
+
}
|
|
3299
|
+
/**
|
|
3300
|
+
* Delegates to the underlying runner's connect method
|
|
3301
|
+
*/
|
|
3302
|
+
connect(...args) {
|
|
3303
|
+
return this._runner.connect(...args);
|
|
3304
|
+
}
|
|
3305
|
+
/**
|
|
3306
|
+
* Delegates to the underlying runner's isRunning method
|
|
3307
|
+
*/
|
|
3308
|
+
isRunning(...args) {
|
|
3309
|
+
return this._runner.isRunning(...args);
|
|
3310
|
+
}
|
|
3311
|
+
/**
|
|
3312
|
+
* Delegates to the underlying runner's stop method
|
|
3313
|
+
*/
|
|
3314
|
+
stop(...args) {
|
|
3315
|
+
return this._runner.stop(...args);
|
|
3316
|
+
}
|
|
3317
|
+
};
|
|
3318
|
+
__name(TelemetryAgentRunner, "TelemetryAgentRunner");
|
|
3169
3319
|
|
|
3170
3320
|
// src/lib/runtime/types.ts
|
|
3171
3321
|
var EndpointType;
|
|
@@ -3309,199 +3459,6 @@ When using these tools:
|
|
|
3309
3459
|
7. Always check tool responses to determine your next action`;
|
|
3310
3460
|
}
|
|
3311
3461
|
__name(generateMcpToolInstructions, "generateMcpToolInstructions");
|
|
3312
|
-
|
|
3313
|
-
// src/agents/langgraph/events.ts
|
|
3314
|
-
var LangGraphEventTypes;
|
|
3315
|
-
(function(LangGraphEventTypes2) {
|
|
3316
|
-
LangGraphEventTypes2["OnChainStart"] = "on_chain_start";
|
|
3317
|
-
LangGraphEventTypes2["OnChainStream"] = "on_chain_stream";
|
|
3318
|
-
LangGraphEventTypes2["OnChainEnd"] = "on_chain_end";
|
|
3319
|
-
LangGraphEventTypes2["OnChatModelStart"] = "on_chat_model_start";
|
|
3320
|
-
LangGraphEventTypes2["OnChatModelStream"] = "on_chat_model_stream";
|
|
3321
|
-
LangGraphEventTypes2["OnChatModelEnd"] = "on_chat_model_end";
|
|
3322
|
-
LangGraphEventTypes2["OnToolStart"] = "on_tool_start";
|
|
3323
|
-
LangGraphEventTypes2["OnToolEnd"] = "on_tool_end";
|
|
3324
|
-
LangGraphEventTypes2["OnCopilotKitStateSync"] = "on_copilotkit_state_sync";
|
|
3325
|
-
LangGraphEventTypes2["OnCopilotKitEmitMessage"] = "on_copilotkit_emit_message";
|
|
3326
|
-
LangGraphEventTypes2["OnCopilotKitEmitToolCall"] = "on_copilotkit_emit_tool_call";
|
|
3327
|
-
LangGraphEventTypes2["OnCustomEvent"] = "on_custom_event";
|
|
3328
|
-
LangGraphEventTypes2["OnInterrupt"] = "on_interrupt";
|
|
3329
|
-
LangGraphEventTypes2["OnCopilotKitInterrupt"] = "on_copilotkit_interrupt";
|
|
3330
|
-
LangGraphEventTypes2["OnCopilotKitError"] = "on_copilotkit_error";
|
|
3331
|
-
})(LangGraphEventTypes || (LangGraphEventTypes = {}));
|
|
3332
|
-
var MetaEventNames;
|
|
3333
|
-
(function(MetaEventNames2) {
|
|
3334
|
-
MetaEventNames2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
|
|
3335
|
-
MetaEventNames2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
|
|
3336
|
-
})(MetaEventNames || (MetaEventNames = {}));
|
|
3337
|
-
var CustomEventNames;
|
|
3338
|
-
(function(CustomEventNames3) {
|
|
3339
|
-
CustomEventNames3["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
|
|
3340
|
-
CustomEventNames3["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
|
|
3341
|
-
CustomEventNames3["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
|
|
3342
|
-
CustomEventNames3["CopilotKitExit"] = "copilotkit_exit";
|
|
3343
|
-
})(CustomEventNames || (CustomEventNames = {}));
|
|
3344
|
-
exports.CustomEventNames = void 0;
|
|
3345
|
-
(function(CustomEventNames3) {
|
|
3346
|
-
CustomEventNames3["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
|
|
3347
|
-
CustomEventNames3["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
|
|
3348
|
-
CustomEventNames3["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
|
|
3349
|
-
CustomEventNames3["CopilotKitExit"] = "copilotkit_exit";
|
|
3350
|
-
})(exports.CustomEventNames || (exports.CustomEventNames = {}));
|
|
3351
|
-
var LangGraphAgent = class extends langgraph.LangGraphAgent {
|
|
3352
|
-
constructor(config2) {
|
|
3353
|
-
super(config2);
|
|
3354
|
-
}
|
|
3355
|
-
// @ts-ignore
|
|
3356
|
-
clone() {
|
|
3357
|
-
return new LangGraphAgent(this.config);
|
|
3358
|
-
}
|
|
3359
|
-
dispatchEvent(event) {
|
|
3360
|
-
if (event.type === client.EventType.CUSTOM) {
|
|
3361
|
-
const customEvent = event;
|
|
3362
|
-
if (customEvent.name === "copilotkit_manually_emit_message") {
|
|
3363
|
-
this.subscriber.next({
|
|
3364
|
-
type: client.EventType.TEXT_MESSAGE_START,
|
|
3365
|
-
role: "assistant",
|
|
3366
|
-
messageId: customEvent.value.message_id,
|
|
3367
|
-
rawEvent: event
|
|
3368
|
-
});
|
|
3369
|
-
this.subscriber.next({
|
|
3370
|
-
type: client.EventType.TEXT_MESSAGE_CONTENT,
|
|
3371
|
-
messageId: customEvent.value.message_id,
|
|
3372
|
-
delta: customEvent.value.message,
|
|
3373
|
-
rawEvent: event
|
|
3374
|
-
});
|
|
3375
|
-
this.subscriber.next({
|
|
3376
|
-
type: client.EventType.TEXT_MESSAGE_END,
|
|
3377
|
-
messageId: customEvent.value.message_id,
|
|
3378
|
-
rawEvent: event
|
|
3379
|
-
});
|
|
3380
|
-
return true;
|
|
3381
|
-
}
|
|
3382
|
-
if (customEvent.name === "copilotkit_manually_emit_tool_call") {
|
|
3383
|
-
this.subscriber.next({
|
|
3384
|
-
type: client.EventType.TOOL_CALL_START,
|
|
3385
|
-
toolCallId: customEvent.value.id,
|
|
3386
|
-
toolCallName: customEvent.value.name,
|
|
3387
|
-
parentMessageId: customEvent.value.id,
|
|
3388
|
-
rawEvent: event
|
|
3389
|
-
});
|
|
3390
|
-
this.subscriber.next({
|
|
3391
|
-
type: client.EventType.TOOL_CALL_ARGS,
|
|
3392
|
-
toolCallId: customEvent.value.id,
|
|
3393
|
-
delta: customEvent.value.args,
|
|
3394
|
-
rawEvent: event
|
|
3395
|
-
});
|
|
3396
|
-
this.subscriber.next({
|
|
3397
|
-
type: client.EventType.TOOL_CALL_END,
|
|
3398
|
-
toolCallId: customEvent.value.id,
|
|
3399
|
-
rawEvent: event
|
|
3400
|
-
});
|
|
3401
|
-
return true;
|
|
3402
|
-
}
|
|
3403
|
-
if (customEvent.name === "copilotkit_manually_emit_intermediate_state") {
|
|
3404
|
-
this.activeRun.manuallyEmittedState = customEvent.value;
|
|
3405
|
-
this.dispatchEvent({
|
|
3406
|
-
type: client.EventType.STATE_SNAPSHOT,
|
|
3407
|
-
snapshot: this.getStateSnapshot({
|
|
3408
|
-
values: this.activeRun.manuallyEmittedState
|
|
3409
|
-
}),
|
|
3410
|
-
rawEvent: event
|
|
3411
|
-
});
|
|
3412
|
-
return true;
|
|
3413
|
-
}
|
|
3414
|
-
if (customEvent.name === "copilotkit_exit") {
|
|
3415
|
-
this.subscriber.next({
|
|
3416
|
-
type: client.EventType.CUSTOM,
|
|
3417
|
-
name: "Exit",
|
|
3418
|
-
value: true
|
|
3419
|
-
});
|
|
3420
|
-
return true;
|
|
3421
|
-
}
|
|
3422
|
-
}
|
|
3423
|
-
const rawEvent = event.rawEvent;
|
|
3424
|
-
if (!rawEvent) {
|
|
3425
|
-
this.subscriber.next(event);
|
|
3426
|
-
return true;
|
|
3427
|
-
}
|
|
3428
|
-
const isMessageEvent = event.type === client.EventType.TEXT_MESSAGE_START || event.type === client.EventType.TEXT_MESSAGE_CONTENT || event.type === client.EventType.TEXT_MESSAGE_END;
|
|
3429
|
-
const isToolEvent = event.type === client.EventType.TOOL_CALL_START || event.type === client.EventType.TOOL_CALL_ARGS || event.type === client.EventType.TOOL_CALL_END;
|
|
3430
|
-
if ("copilotkit:emit-tool-calls" in (rawEvent.metadata || {})) {
|
|
3431
|
-
if (rawEvent.metadata["copilotkit:emit-tool-calls"] === false && isToolEvent) {
|
|
3432
|
-
return false;
|
|
3433
|
-
}
|
|
3434
|
-
}
|
|
3435
|
-
if ("copilotkit:emit-messages" in (rawEvent.metadata || {})) {
|
|
3436
|
-
if (rawEvent.metadata["copilotkit:emit-messages"] === false && isMessageEvent) {
|
|
3437
|
-
return false;
|
|
3438
|
-
}
|
|
3439
|
-
}
|
|
3440
|
-
this.subscriber.next(event);
|
|
3441
|
-
return true;
|
|
3442
|
-
}
|
|
3443
|
-
// @ts-ignore
|
|
3444
|
-
run(input) {
|
|
3445
|
-
return super.run(input).pipe(rxjs.map((processedEvent) => {
|
|
3446
|
-
var _a, _b, _c, _d, _e;
|
|
3447
|
-
if (processedEvent.type === client.EventType.RAW) {
|
|
3448
|
-
const event = processedEvent.event ?? processedEvent.rawEvent;
|
|
3449
|
-
const eventType = event.event;
|
|
3450
|
-
const toolCallData = (_c = (_b = (_a = event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.tool_call_chunks) == null ? void 0 : _c[0];
|
|
3451
|
-
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));
|
|
3452
|
-
if (eventType === LangGraphEventTypes.OnChatModelStream && toolCallUsedToPredictState) {
|
|
3453
|
-
return {
|
|
3454
|
-
type: client.EventType.CUSTOM,
|
|
3455
|
-
name: "PredictState",
|
|
3456
|
-
value: event.metadata["copilotkit:emit-intermediate-state"]
|
|
3457
|
-
};
|
|
3458
|
-
}
|
|
3459
|
-
}
|
|
3460
|
-
return processedEvent;
|
|
3461
|
-
}));
|
|
3462
|
-
}
|
|
3463
|
-
langGraphDefaultMergeState(state, messages, input) {
|
|
3464
|
-
const aguiMergedState = super.langGraphDefaultMergeState(state, messages, input);
|
|
3465
|
-
const { tools: returnedTools, "ag-ui": agui } = aguiMergedState;
|
|
3466
|
-
const rawCombinedTools = [
|
|
3467
|
-
...returnedTools ?? [],
|
|
3468
|
-
...(agui == null ? void 0 : agui.tools) ?? []
|
|
3469
|
-
];
|
|
3470
|
-
const combinedTools = Array.from(new Map(rawCombinedTools.map((t) => [
|
|
3471
|
-
(t == null ? void 0 : t.id) ?? (t == null ? void 0 : t.name) ?? (t == null ? void 0 : t.key) ?? JSON.stringify(t),
|
|
3472
|
-
t
|
|
3473
|
-
])).values());
|
|
3474
|
-
return {
|
|
3475
|
-
...aguiMergedState,
|
|
3476
|
-
copilotkit: {
|
|
3477
|
-
actions: combinedTools,
|
|
3478
|
-
context: (agui == null ? void 0 : agui.context) ?? []
|
|
3479
|
-
}
|
|
3480
|
-
};
|
|
3481
|
-
}
|
|
3482
|
-
async getSchemaKeys() {
|
|
3483
|
-
const CONSTANT_KEYS = [
|
|
3484
|
-
"copilotkit"
|
|
3485
|
-
];
|
|
3486
|
-
const schemaKeys = await super.getSchemaKeys();
|
|
3487
|
-
return {
|
|
3488
|
-
config: schemaKeys.config,
|
|
3489
|
-
input: schemaKeys.input ? [
|
|
3490
|
-
...schemaKeys.input,
|
|
3491
|
-
...CONSTANT_KEYS
|
|
3492
|
-
] : null,
|
|
3493
|
-
output: schemaKeys.output ? [
|
|
3494
|
-
...schemaKeys.output,
|
|
3495
|
-
...CONSTANT_KEYS
|
|
3496
|
-
] : null,
|
|
3497
|
-
context: schemaKeys.context ? [
|
|
3498
|
-
...schemaKeys.context,
|
|
3499
|
-
...CONSTANT_KEYS
|
|
3500
|
-
] : null
|
|
3501
|
-
};
|
|
3502
|
-
}
|
|
3503
|
-
};
|
|
3504
|
-
__name(LangGraphAgent, "LangGraphAgent");
|
|
3505
3462
|
var CopilotRuntime = class {
|
|
3506
3463
|
params;
|
|
3507
3464
|
observability;
|
|
@@ -3511,12 +3468,17 @@ var CopilotRuntime = class {
|
|
|
3511
3468
|
_instance;
|
|
3512
3469
|
constructor(params) {
|
|
3513
3470
|
const agents = (params == null ? void 0 : params.agents) ?? {};
|
|
3471
|
+
const endpointAgents = this.assignEndpointsToAgents((params == null ? void 0 : params.remoteEndpoints) ?? []);
|
|
3472
|
+
const baseRunner = (params == null ? void 0 : params.runner) ?? new runtime.InMemoryAgentRunner();
|
|
3473
|
+
const runner = shared.isTelemetryDisabled() ? baseRunner : new TelemetryAgentRunner({
|
|
3474
|
+
runner: baseRunner
|
|
3475
|
+
});
|
|
3514
3476
|
this.runtimeArgs = {
|
|
3515
3477
|
agents: {
|
|
3516
|
-
...
|
|
3478
|
+
...endpointAgents,
|
|
3517
3479
|
...agents
|
|
3518
3480
|
},
|
|
3519
|
-
runner
|
|
3481
|
+
runner,
|
|
3520
3482
|
// TODO: add support for transcriptionService from CopilotRuntimeOptionsVNext once it is ready
|
|
3521
3483
|
// transcriptionService: params?.transcriptionService,
|
|
3522
3484
|
beforeRequestMiddleware: this.createOnBeforeRequestHandler(params).bind(this),
|
|
@@ -3532,29 +3494,16 @@ var CopilotRuntime = class {
|
|
|
3532
3494
|
return this._instance;
|
|
3533
3495
|
}
|
|
3534
3496
|
assignEndpointsToAgents(endpoints) {
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
deploymentUrl: lgEndpoint.deploymentUrl,
|
|
3543
|
-
langsmithApiKey: lgEndpoint.langsmithApiKey,
|
|
3544
|
-
graphId
|
|
3545
|
-
});
|
|
3546
|
-
});
|
|
3547
|
-
return {
|
|
3548
|
-
...acc,
|
|
3549
|
-
...lgAgents
|
|
3550
|
-
};
|
|
3551
|
-
}
|
|
3552
|
-
return acc;
|
|
3553
|
-
}, {});
|
|
3497
|
+
let result = {};
|
|
3498
|
+
if (endpoints.some((endpoint) => resolveEndpointType(endpoint) == EndpointType.LangGraphPlatform)) {
|
|
3499
|
+
throw new shared.CopilotKitMisuseError({
|
|
3500
|
+
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: "..." }) }'
|
|
3501
|
+
});
|
|
3502
|
+
}
|
|
3503
|
+
return result;
|
|
3554
3504
|
}
|
|
3555
3505
|
handleServiceAdapter(serviceAdapter) {
|
|
3556
3506
|
this.runtimeArgs.agents = Promise.resolve(this.runtimeArgs.agents ?? {}).then(async (agents) => {
|
|
3557
|
-
var _a;
|
|
3558
3507
|
let agentsList = agents;
|
|
3559
3508
|
const isAgentsListEmpty = !Object.keys(agents).length;
|
|
3560
3509
|
const hasServiceAdapter = Boolean(serviceAdapter);
|
|
@@ -3572,7 +3521,7 @@ var CopilotRuntime = class {
|
|
|
3572
3521
|
model: `${serviceAdapter.provider}/${serviceAdapter.model}`
|
|
3573
3522
|
});
|
|
3574
3523
|
}
|
|
3575
|
-
if (
|
|
3524
|
+
if (this.params.actions) {
|
|
3576
3525
|
const mcpTools = await this.getToolsFromMCP();
|
|
3577
3526
|
agentsList = this.assignToolsToAgents(agents, [
|
|
3578
3527
|
...this.getToolsFromActions(this.params.actions),
|
|
@@ -3593,7 +3542,8 @@ var CopilotRuntime = class {
|
|
|
3593
3542
|
return {
|
|
3594
3543
|
name: action.name,
|
|
3595
3544
|
description: action.description || "",
|
|
3596
|
-
parameters: zodSchema
|
|
3545
|
+
parameters: zodSchema,
|
|
3546
|
+
execute: () => Promise.resolve()
|
|
3597
3547
|
};
|
|
3598
3548
|
});
|
|
3599
3549
|
}
|
|
@@ -3621,11 +3571,24 @@ var CopilotRuntime = class {
|
|
|
3621
3571
|
}
|
|
3622
3572
|
createOnBeforeRequestHandler(params) {
|
|
3623
3573
|
return async (hookParams) => {
|
|
3624
|
-
var _a, _b;
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3574
|
+
var _a, _b, _c, _d;
|
|
3575
|
+
const { request } = hookParams;
|
|
3576
|
+
const publicApiKey = request.headers.get("x-copilotcloud-public-api-key");
|
|
3577
|
+
const body = await shared.readBody(request);
|
|
3578
|
+
const forwardedProps = body.forwardedProps;
|
|
3579
|
+
const cloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL || "https://api.cloud.copilotkit.ai";
|
|
3580
|
+
telemetry_client_default.capture("oss.runtime.copilot_request_created", {
|
|
3581
|
+
"cloud.guardrails.enabled": ((_a = forwardedProps == null ? void 0 : forwardedProps.cloud) == null ? void 0 : _a.guardrails) !== void 0,
|
|
3582
|
+
requestType: ((_b = forwardedProps == null ? void 0 : forwardedProps.metadata) == null ? void 0 : _b.requestType) ?? "unknown",
|
|
3583
|
+
"cloud.api_key_provided": !!publicApiKey,
|
|
3584
|
+
...publicApiKey ? {
|
|
3585
|
+
"cloud.public_api_key": publicApiKey
|
|
3586
|
+
} : {},
|
|
3587
|
+
"cloud.base_url": cloudBaseUrl
|
|
3588
|
+
});
|
|
3589
|
+
(_c = params == null ? void 0 : params.beforeRequestMiddleware) == null ? void 0 : _c.call(params, hookParams);
|
|
3590
|
+
if ((_d = params == null ? void 0 : params.middleware) == null ? void 0 : _d.onBeforeRequest) {
|
|
3591
|
+
const { request: request2, runtime, path } = hookParams;
|
|
3629
3592
|
const gqlMessages = aguiToGQL(body.messages).reduce((acc, msg) => {
|
|
3630
3593
|
if ("role" in msg && msg.role === "user") {
|
|
3631
3594
|
acc.inputMessages.push(msg);
|
|
@@ -3643,7 +3606,7 @@ var CopilotRuntime = class {
|
|
|
3643
3606
|
runId: body.runId,
|
|
3644
3607
|
inputMessages,
|
|
3645
3608
|
properties: body.forwardedProps,
|
|
3646
|
-
url:
|
|
3609
|
+
url: request2.url
|
|
3647
3610
|
});
|
|
3648
3611
|
}
|
|
3649
3612
|
};
|
|
@@ -3744,7 +3707,8 @@ var CopilotRuntime = class {
|
|
|
3744
3707
|
return {
|
|
3745
3708
|
name: toolName,
|
|
3746
3709
|
description: tool.description || `MCP tool: ${toolName} (from ${endpointUrl})`,
|
|
3747
|
-
parameters: zodSchema
|
|
3710
|
+
parameters: zodSchema,
|
|
3711
|
+
execute: () => Promise.resolve()
|
|
3748
3712
|
};
|
|
3749
3713
|
});
|
|
3750
3714
|
this.mcpToolsCache.set(endpointUrl, toolDefs);
|
|
@@ -3895,6 +3859,38 @@ _ts_decorate19([
|
|
|
3895
3859
|
AgentsResponse = _ts_decorate19([
|
|
3896
3860
|
typeGraphql.ObjectType()
|
|
3897
3861
|
], AgentsResponse);
|
|
3862
|
+
|
|
3863
|
+
// src/agents/langgraph/events.ts
|
|
3864
|
+
var LangGraphEventTypes;
|
|
3865
|
+
(function(LangGraphEventTypes2) {
|
|
3866
|
+
LangGraphEventTypes2["OnChainStart"] = "on_chain_start";
|
|
3867
|
+
LangGraphEventTypes2["OnChainStream"] = "on_chain_stream";
|
|
3868
|
+
LangGraphEventTypes2["OnChainEnd"] = "on_chain_end";
|
|
3869
|
+
LangGraphEventTypes2["OnChatModelStart"] = "on_chat_model_start";
|
|
3870
|
+
LangGraphEventTypes2["OnChatModelStream"] = "on_chat_model_stream";
|
|
3871
|
+
LangGraphEventTypes2["OnChatModelEnd"] = "on_chat_model_end";
|
|
3872
|
+
LangGraphEventTypes2["OnToolStart"] = "on_tool_start";
|
|
3873
|
+
LangGraphEventTypes2["OnToolEnd"] = "on_tool_end";
|
|
3874
|
+
LangGraphEventTypes2["OnCopilotKitStateSync"] = "on_copilotkit_state_sync";
|
|
3875
|
+
LangGraphEventTypes2["OnCopilotKitEmitMessage"] = "on_copilotkit_emit_message";
|
|
3876
|
+
LangGraphEventTypes2["OnCopilotKitEmitToolCall"] = "on_copilotkit_emit_tool_call";
|
|
3877
|
+
LangGraphEventTypes2["OnCustomEvent"] = "on_custom_event";
|
|
3878
|
+
LangGraphEventTypes2["OnInterrupt"] = "on_interrupt";
|
|
3879
|
+
LangGraphEventTypes2["OnCopilotKitInterrupt"] = "on_copilotkit_interrupt";
|
|
3880
|
+
LangGraphEventTypes2["OnCopilotKitError"] = "on_copilotkit_error";
|
|
3881
|
+
})(LangGraphEventTypes || (LangGraphEventTypes = {}));
|
|
3882
|
+
var MetaEventNames;
|
|
3883
|
+
(function(MetaEventNames2) {
|
|
3884
|
+
MetaEventNames2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
|
|
3885
|
+
MetaEventNames2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
|
|
3886
|
+
})(MetaEventNames || (MetaEventNames = {}));
|
|
3887
|
+
var CustomEventNames;
|
|
3888
|
+
(function(CustomEventNames2) {
|
|
3889
|
+
CustomEventNames2["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
|
|
3890
|
+
CustomEventNames2["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
|
|
3891
|
+
CustomEventNames2["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
|
|
3892
|
+
CustomEventNames2["CopilotKitExit"] = "copilotkit_exit";
|
|
3893
|
+
})(CustomEventNames || (CustomEventNames = {}));
|
|
3898
3894
|
function _ts_decorate20(decorators, target, key, desc) {
|
|
3899
3895
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3900
3896
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4726,7 +4722,9 @@ function copilotRuntimeNextJSAppRouterEndpoint(options) {
|
|
|
4726
4722
|
const logger2 = commonConfig.logging;
|
|
4727
4723
|
logger2.debug("Creating NextJS App Router endpoint");
|
|
4728
4724
|
const serviceAdapter = options.serviceAdapter;
|
|
4729
|
-
|
|
4725
|
+
if (serviceAdapter) {
|
|
4726
|
+
options.runtime.handleServiceAdapter(serviceAdapter);
|
|
4727
|
+
}
|
|
4730
4728
|
const copilotRoute = runtime.createCopilotEndpointSingleRoute({
|
|
4731
4729
|
runtime: options.runtime.instance,
|
|
4732
4730
|
basePath: options.baseUrl ?? options.endpoint
|
|
@@ -4756,12 +4754,59 @@ function readableStreamToNodeStream(webStream) {
|
|
|
4756
4754
|
}
|
|
4757
4755
|
__name(readableStreamToNodeStream, "readableStreamToNodeStream");
|
|
4758
4756
|
function getFullUrl(req) {
|
|
4759
|
-
const
|
|
4757
|
+
const expressPath = req.originalUrl ?? (req.baseUrl ? `${req.baseUrl}${req.url ?? ""}` : void 0);
|
|
4758
|
+
const path = expressPath || req.url || "/";
|
|
4760
4759
|
const host = req.headers["x-forwarded-host"] || req.headers.host || "localhost";
|
|
4761
4760
|
const proto = req.headers["x-forwarded-proto"] || (req.socket.encrypted ? "https" : "http");
|
|
4762
4761
|
return `${proto}://${host}${path}`;
|
|
4763
4762
|
}
|
|
4764
4763
|
__name(getFullUrl, "getFullUrl");
|
|
4764
|
+
function toHeaders(rawHeaders) {
|
|
4765
|
+
const headers = new Headers();
|
|
4766
|
+
for (const [key, value] of Object.entries(rawHeaders)) {
|
|
4767
|
+
if (value === void 0)
|
|
4768
|
+
continue;
|
|
4769
|
+
if (Array.isArray(value)) {
|
|
4770
|
+
value.forEach((entry) => headers.append(key, entry));
|
|
4771
|
+
continue;
|
|
4772
|
+
}
|
|
4773
|
+
headers.append(key, value);
|
|
4774
|
+
}
|
|
4775
|
+
return headers;
|
|
4776
|
+
}
|
|
4777
|
+
__name(toHeaders, "toHeaders");
|
|
4778
|
+
function isStreamConsumed(req) {
|
|
4779
|
+
const readableState = req._readableState;
|
|
4780
|
+
return Boolean(req.readableEnded || req.complete || (readableState == null ? void 0 : readableState.ended) || (readableState == null ? void 0 : readableState.endEmitted));
|
|
4781
|
+
}
|
|
4782
|
+
__name(isStreamConsumed, "isStreamConsumed");
|
|
4783
|
+
function synthesizeBodyFromParsedBody(parsedBody, headers) {
|
|
4784
|
+
if (parsedBody === null || parsedBody === void 0) {
|
|
4785
|
+
return {
|
|
4786
|
+
body: null
|
|
4787
|
+
};
|
|
4788
|
+
}
|
|
4789
|
+
if (parsedBody instanceof Buffer || parsedBody instanceof Uint8Array) {
|
|
4790
|
+
return {
|
|
4791
|
+
body: parsedBody
|
|
4792
|
+
};
|
|
4793
|
+
}
|
|
4794
|
+
if (typeof parsedBody === "string") {
|
|
4795
|
+
return {
|
|
4796
|
+
body: parsedBody,
|
|
4797
|
+
contentType: headers.get("content-type") ?? "text/plain"
|
|
4798
|
+
};
|
|
4799
|
+
}
|
|
4800
|
+
return {
|
|
4801
|
+
body: JSON.stringify(parsedBody),
|
|
4802
|
+
contentType: "application/json"
|
|
4803
|
+
};
|
|
4804
|
+
}
|
|
4805
|
+
__name(synthesizeBodyFromParsedBody, "synthesizeBodyFromParsedBody");
|
|
4806
|
+
function isDisturbedOrLockedError(error) {
|
|
4807
|
+
return error instanceof TypeError && typeof error.message === "string" && (error.message.includes("disturbed") || error.message.includes("locked"));
|
|
4808
|
+
}
|
|
4809
|
+
__name(isDisturbedOrLockedError, "isDisturbedOrLockedError");
|
|
4765
4810
|
function copilotRuntimeNodeHttpEndpoint(options) {
|
|
4766
4811
|
var _a;
|
|
4767
4812
|
const commonConfig = getCommonConfig(options);
|
|
@@ -4779,7 +4824,9 @@ function copilotRuntimeNodeHttpEndpoint(options) {
|
|
|
4779
4824
|
const logger2 = commonConfig.logging;
|
|
4780
4825
|
logger2.debug("Creating Node HTTP endpoint");
|
|
4781
4826
|
const serviceAdapter = options.serviceAdapter;
|
|
4782
|
-
|
|
4827
|
+
if (serviceAdapter) {
|
|
4828
|
+
options.runtime.handleServiceAdapter(serviceAdapter);
|
|
4829
|
+
}
|
|
4783
4830
|
const honoApp = runtime.createCopilotEndpointSingleRoute({
|
|
4784
4831
|
runtime: options.runtime.instance,
|
|
4785
4832
|
basePath: options.baseUrl ?? options.endpoint
|
|
@@ -4787,14 +4834,59 @@ function copilotRuntimeNodeHttpEndpoint(options) {
|
|
|
4787
4834
|
return /* @__PURE__ */ __name(async function handler(req, res) {
|
|
4788
4835
|
const url = getFullUrl(req);
|
|
4789
4836
|
const hasBody = req.method !== "GET" && req.method !== "HEAD";
|
|
4790
|
-
const
|
|
4837
|
+
const baseHeaders = toHeaders(req.headers);
|
|
4838
|
+
const parsedBody = req.body;
|
|
4839
|
+
const streamConsumed = isStreamConsumed(req) || parsedBody !== void 0;
|
|
4840
|
+
const canStream = hasBody && !streamConsumed;
|
|
4841
|
+
let requestBody = void 0;
|
|
4842
|
+
let useDuplex = false;
|
|
4843
|
+
if (hasBody && canStream) {
|
|
4844
|
+
requestBody = req;
|
|
4845
|
+
useDuplex = true;
|
|
4846
|
+
}
|
|
4847
|
+
if (hasBody && streamConsumed) {
|
|
4848
|
+
if (parsedBody !== void 0) {
|
|
4849
|
+
const synthesized = synthesizeBodyFromParsedBody(parsedBody, baseHeaders);
|
|
4850
|
+
requestBody = synthesized.body ?? void 0;
|
|
4851
|
+
baseHeaders.delete("content-length");
|
|
4852
|
+
if (synthesized.contentType) {
|
|
4853
|
+
baseHeaders.set("content-type", synthesized.contentType);
|
|
4854
|
+
}
|
|
4855
|
+
logger2.debug("Request stream already consumed; using parsed req.body to rebuild request.");
|
|
4856
|
+
} else {
|
|
4857
|
+
logger2.warn("Request stream consumed with no available body; sending empty payload.");
|
|
4858
|
+
requestBody = void 0;
|
|
4859
|
+
}
|
|
4860
|
+
}
|
|
4861
|
+
const buildRequest = /* @__PURE__ */ __name((body, headers, duplex) => new Request(url, {
|
|
4791
4862
|
method: req.method,
|
|
4792
|
-
headers
|
|
4793
|
-
body
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4863
|
+
headers,
|
|
4864
|
+
body,
|
|
4865
|
+
duplex: duplex ? "half" : void 0
|
|
4866
|
+
}), "buildRequest");
|
|
4867
|
+
let response;
|
|
4868
|
+
try {
|
|
4869
|
+
response = await honoApp.fetch(buildRequest(requestBody, baseHeaders, useDuplex));
|
|
4870
|
+
} catch (error) {
|
|
4871
|
+
if (isDisturbedOrLockedError(error) && hasBody) {
|
|
4872
|
+
logger2.warn("Encountered disturbed/locked request body; rebuilding request using parsed body or empty payload.");
|
|
4873
|
+
const fallbackHeaders = new Headers(baseHeaders);
|
|
4874
|
+
let fallbackBody;
|
|
4875
|
+
if (parsedBody !== void 0) {
|
|
4876
|
+
const synthesized = synthesizeBodyFromParsedBody(parsedBody, fallbackHeaders);
|
|
4877
|
+
fallbackBody = synthesized.body ?? void 0;
|
|
4878
|
+
fallbackHeaders.delete("content-length");
|
|
4879
|
+
if (synthesized.contentType) {
|
|
4880
|
+
fallbackHeaders.set("content-type", synthesized.contentType);
|
|
4881
|
+
}
|
|
4882
|
+
} else {
|
|
4883
|
+
fallbackBody = void 0;
|
|
4884
|
+
}
|
|
4885
|
+
response = await honoApp.fetch(buildRequest(fallbackBody, fallbackHeaders, false));
|
|
4886
|
+
} else {
|
|
4887
|
+
throw error;
|
|
4888
|
+
}
|
|
4889
|
+
}
|
|
4798
4890
|
res.statusCode = response.status;
|
|
4799
4891
|
response.headers.forEach((value, key) => {
|
|
4800
4892
|
res.setHeader(key, value);
|
|
@@ -4857,6 +4949,22 @@ function copilotRuntimeNestEndpoint(options) {
|
|
|
4857
4949
|
return copilotRuntimeNodeHttpEndpoint(options);
|
|
4858
4950
|
}
|
|
4859
4951
|
__name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|
|
4952
|
+
|
|
4953
|
+
// src/lib/index.ts
|
|
4954
|
+
var LangGraphAgent = class {
|
|
4955
|
+
constructor() {
|
|
4956
|
+
throw new Error("LangGraphAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead");
|
|
4957
|
+
}
|
|
4958
|
+
};
|
|
4959
|
+
__name(LangGraphAgent, "LangGraphAgent");
|
|
4960
|
+
var LangGraphHttpAgent = class {
|
|
4961
|
+
constructor() {
|
|
4962
|
+
throw new Error("LangGraphHttpAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead");
|
|
4963
|
+
}
|
|
4964
|
+
};
|
|
4965
|
+
__name(LangGraphHttpAgent, "LangGraphHttpAgent");
|
|
4966
|
+
|
|
4967
|
+
// src/service-adapters/langchain/langserve.ts
|
|
4860
4968
|
var RemoteChain = class {
|
|
4861
4969
|
name;
|
|
4862
4970
|
description;
|
|
@@ -4879,7 +4987,8 @@ var RemoteChain = class {
|
|
|
4879
4987
|
description: this.description,
|
|
4880
4988
|
parameters: this.parameters,
|
|
4881
4989
|
handler: async (args) => {
|
|
4882
|
-
const
|
|
4990
|
+
const { RemoteRunnable } = __require("langchain/runnables/remote");
|
|
4991
|
+
const runnable = new RemoteRunnable({
|
|
4883
4992
|
url: this.chainUrl
|
|
4884
4993
|
});
|
|
4885
4994
|
let input;
|
|
@@ -5091,7 +5200,9 @@ var AnthropicAdapter = class {
|
|
|
5091
5200
|
return "AnthropicAdapter";
|
|
5092
5201
|
}
|
|
5093
5202
|
constructor(params) {
|
|
5094
|
-
|
|
5203
|
+
if (params == null ? void 0 : params.anthropic) {
|
|
5204
|
+
this._anthropic = params.anthropic;
|
|
5205
|
+
}
|
|
5095
5206
|
if (params == null ? void 0 : params.model) {
|
|
5096
5207
|
this.model = params.model;
|
|
5097
5208
|
}
|
|
@@ -5099,6 +5210,13 @@ var AnthropicAdapter = class {
|
|
|
5099
5210
|
enabled: false
|
|
5100
5211
|
};
|
|
5101
5212
|
}
|
|
5213
|
+
ensureAnthropic() {
|
|
5214
|
+
if (!this._anthropic) {
|
|
5215
|
+
const Anthropic = __require("@anthropic-ai/sdk").default;
|
|
5216
|
+
this._anthropic = new Anthropic({});
|
|
5217
|
+
}
|
|
5218
|
+
return this._anthropic;
|
|
5219
|
+
}
|
|
5102
5220
|
/**
|
|
5103
5221
|
* Adds cache control to system prompt
|
|
5104
5222
|
*/
|
|
@@ -5239,7 +5357,8 @@ var AnthropicAdapter = class {
|
|
|
5239
5357
|
},
|
|
5240
5358
|
stream: true
|
|
5241
5359
|
};
|
|
5242
|
-
const
|
|
5360
|
+
const anthropic = this.ensureAnthropic();
|
|
5361
|
+
const stream = await anthropic.messages.create(createParams);
|
|
5243
5362
|
eventSource.stream(async (eventStream$) => {
|
|
5244
5363
|
let mode = null;
|
|
5245
5364
|
let didOutputText = false;
|
|
@@ -5384,11 +5503,12 @@ var ExperimentalOllamaAdapter = class {
|
|
|
5384
5503
|
}
|
|
5385
5504
|
async process(request) {
|
|
5386
5505
|
const { messages, actions, eventSource } = request;
|
|
5387
|
-
const
|
|
5506
|
+
const { Ollama } = __require("@langchain/community/llms/ollama");
|
|
5507
|
+
const ollama = new Ollama({
|
|
5388
5508
|
model: this.model
|
|
5389
5509
|
});
|
|
5390
5510
|
const contents = messages.filter((m) => m.isTextMessage()).map((m) => m.content);
|
|
5391
|
-
const _stream = await ollama
|
|
5511
|
+
const _stream = await ollama.stream(contents);
|
|
5392
5512
|
eventSource.stream(async (eventStream$) => {
|
|
5393
5513
|
const currentMessageId = shared.randomId();
|
|
5394
5514
|
eventStream$.sendTextMessageStart({
|
|
@@ -5411,6 +5531,8 @@ var ExperimentalOllamaAdapter = class {
|
|
|
5411
5531
|
}
|
|
5412
5532
|
};
|
|
5413
5533
|
__name(ExperimentalOllamaAdapter, "ExperimentalOllamaAdapter");
|
|
5534
|
+
|
|
5535
|
+
// src/service-adapters/bedrock/bedrock-adapter.ts
|
|
5414
5536
|
var DEFAULT_MODEL6 = "amazon.nova-lite-v1:0";
|
|
5415
5537
|
var BedrockAdapter = class extends LangChainAdapter {
|
|
5416
5538
|
provider = "bedrock";
|
|
@@ -5418,8 +5540,9 @@ var BedrockAdapter = class extends LangChainAdapter {
|
|
|
5418
5540
|
constructor(options) {
|
|
5419
5541
|
super({
|
|
5420
5542
|
chainFn: async ({ messages, tools, threadId }) => {
|
|
5543
|
+
const { ChatBedrockConverse } = __require("@langchain/aws");
|
|
5421
5544
|
this.model = (options == null ? void 0 : options.model) ?? "amazon.nova-lite-v1:0";
|
|
5422
|
-
const model = new
|
|
5545
|
+
const model = new ChatBedrockConverse({
|
|
5423
5546
|
model: this.model,
|
|
5424
5547
|
region: (options == null ? void 0 : options.region) ?? "us-east-1",
|
|
5425
5548
|
credentials: (options == null ? void 0 : options.credentials) ? {
|
|
@@ -5446,10 +5569,6 @@ var EmptyAdapter = class {
|
|
|
5446
5569
|
__name(EmptyAdapter, "EmptyAdapter");
|
|
5447
5570
|
var ExperimentalEmptyAdapter = EmptyAdapter;
|
|
5448
5571
|
|
|
5449
|
-
Object.defineProperty(exports, 'LangGraphHttpAgent', {
|
|
5450
|
-
enumerable: true,
|
|
5451
|
-
get: function () { return langgraph.LangGraphHttpAgent; }
|
|
5452
|
-
});
|
|
5453
5572
|
exports.AnthropicAdapter = AnthropicAdapter;
|
|
5454
5573
|
exports.BedrockAdapter = BedrockAdapter;
|
|
5455
5574
|
exports.CopilotRuntime = CopilotRuntime;
|
|
@@ -5461,10 +5580,12 @@ exports.GroqAdapter = GroqAdapter;
|
|
|
5461
5580
|
exports.GuardrailsValidationFailureResponse = GuardrailsValidationFailureResponse;
|
|
5462
5581
|
exports.LangChainAdapter = LangChainAdapter;
|
|
5463
5582
|
exports.LangGraphAgent = LangGraphAgent;
|
|
5583
|
+
exports.LangGraphHttpAgent = LangGraphHttpAgent;
|
|
5464
5584
|
exports.MessageStreamInterruptedResponse = MessageStreamInterruptedResponse;
|
|
5465
5585
|
exports.OpenAIAdapter = OpenAIAdapter;
|
|
5466
5586
|
exports.OpenAIAssistantAdapter = OpenAIAssistantAdapter;
|
|
5467
5587
|
exports.RemoteChain = RemoteChain;
|
|
5588
|
+
exports.TelemetryAgentRunner = TelemetryAgentRunner;
|
|
5468
5589
|
exports.UnifyAdapter = UnifyAdapter;
|
|
5469
5590
|
exports.UnknownErrorResponse = UnknownErrorResponse;
|
|
5470
5591
|
exports.addCustomHeaderPlugin = addCustomHeaderPlugin;
|