@copilotkit/runtime 1.1.1-feat-runtime-remote-actions.0 → 1.1.2
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 +14 -3
- package/__snapshots__/schema/schema.graphql +0 -22
- package/dist/{chunk-4AJIFDOJ.mjs → chunk-6PAC74F2.mjs} +2 -2
- package/dist/{chunk-JMW74TAS.mjs → chunk-74B76SMO.mjs} +2 -2
- package/dist/{chunk-4MRXXS22.mjs → chunk-CUVWSISN.mjs} +3 -3
- package/dist/{chunk-KOC3ZRO4.mjs → chunk-GEIBJJQ4.mjs} +2 -12
- package/dist/chunk-GEIBJJQ4.mjs.map +1 -0
- package/dist/{chunk-MISUYYBG.mjs → chunk-MKV3LEJ6.mjs} +28 -356
- package/dist/chunk-MKV3LEJ6.mjs.map +1 -0
- package/dist/{chunk-CC3J37S6.mjs → chunk-NPCP4YZB.mjs} +2 -2
- package/dist/{chunk-CSIQEWDR.mjs → chunk-RDEOIOQR.mjs} +12 -101
- package/dist/chunk-RDEOIOQR.mjs.map +1 -0
- package/dist/{chunk-UTUNGR2L.mjs → chunk-URMISMK2.mjs} +2 -2
- package/dist/graphql/types/converted/index.d.ts +1 -1
- package/dist/graphql/types/converted/index.js +0 -11
- package/dist/graphql/types/converted/index.js.map +1 -1
- package/dist/graphql/types/converted/index.mjs +1 -3
- package/dist/{groq-adapter-35a54596.d.ts → groq-adapter-675b30c6.d.ts} +1 -1
- package/dist/{index-9cfb4d1f.d.ts → index-aa091e3c.d.ts} +1 -18
- package/dist/index.d.ts +8 -8
- package/dist/index.js +31 -451
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -8
- package/dist/{langserve-b97a6817.d.ts → langserve-a54438c6.d.ts} +2 -11
- package/dist/lib/index.d.ts +8 -8
- package/dist/lib/index.js +31 -451
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +8 -8
- package/dist/lib/integrations/index.d.ts +7 -7
- package/dist/lib/integrations/index.js +14 -132
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +6 -6
- package/dist/lib/integrations/nest/index.d.ts +5 -5
- package/dist/lib/integrations/nest/index.js +14 -132
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +4 -4
- package/dist/lib/integrations/node-express/index.d.ts +5 -5
- package/dist/lib/integrations/node-express/index.js +14 -132
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +4 -4
- package/dist/lib/integrations/node-http/index.d.ts +5 -5
- package/dist/lib/integrations/node-http/index.js +14 -132
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +3 -3
- package/dist/{pages-router-df63122a.d.ts → pages-router-df82c666.d.ts} +1 -1
- package/dist/service-adapters/index.d.ts +3 -3
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +3 -3
- package/dist/{copilot-runtime-40b55575.d.ts → shared-ec6c7db5.d.ts} +35 -47
- package/package.json +4 -4
- package/src/graphql/inputs/message.input.ts +0 -24
- package/src/graphql/resolvers/copilot.resolver.ts +7 -40
- package/src/graphql/types/converted/index.ts +0 -10
- package/src/graphql/types/copilot-response.type.ts +0 -23
- package/src/lib/{runtime/copilot-runtime.ts → copilot-runtime.ts} +14 -123
- package/src/lib/index.ts +1 -1
- package/src/lib/integrations/shared.ts +1 -1
- package/src/service-adapters/conversion.ts +0 -14
- package/src/service-adapters/events.ts +8 -49
- package/dist/chunk-CSIQEWDR.mjs.map +0 -1
- package/dist/chunk-KOC3ZRO4.mjs.map +0 -1
- package/dist/chunk-MISUYYBG.mjs.map +0 -1
- package/src/agents/langgraph/event-source.ts +0 -29
- package/src/agents/langgraph/events.ts +0 -295
- package/src/lib/runtime/remote-actions.ts +0 -271
- /package/dist/{chunk-4AJIFDOJ.mjs.map → chunk-6PAC74F2.mjs.map} +0 -0
- /package/dist/{chunk-JMW74TAS.mjs.map → chunk-74B76SMO.mjs.map} +0 -0
- /package/dist/{chunk-4MRXXS22.mjs.map → chunk-CUVWSISN.mjs.map} +0 -0
- /package/dist/{chunk-CC3J37S6.mjs.map → chunk-NPCP4YZB.mjs.map} +0 -0
- /package/dist/{chunk-UTUNGR2L.mjs.map → chunk-URMISMK2.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
# @copilotkit/runtime
|
|
2
2
|
|
|
3
|
-
## 1.1.
|
|
3
|
+
## 1.1.2
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- Pin headless-ui/react version to v2.1.1
|
|
8
8
|
- Updated dependencies
|
|
9
|
-
- @copilotkit/shared@1.1.
|
|
9
|
+
- @copilotkit/shared@1.1.2
|
|
10
|
+
|
|
11
|
+
## 1.1.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- - improved documentation
|
|
16
|
+
- center textarea popup
|
|
17
|
+
- show/hide dev console
|
|
18
|
+
- forward maxTokens, stop and force function calling
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @copilotkit/shared@1.1.1
|
|
10
21
|
|
|
11
22
|
## 1.1.0
|
|
12
23
|
|
|
@@ -30,27 +30,6 @@ input ActionInput {
|
|
|
30
30
|
name: String!
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
input AgentMessageInput {
|
|
34
|
-
agentName: String!
|
|
35
|
-
nodeName: String!
|
|
36
|
-
role: MessageRole!
|
|
37
|
-
running: Boolean!
|
|
38
|
-
state: String!
|
|
39
|
-
threadId: String!
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
type AgentMessageOutput implements BaseMessageOutput {
|
|
43
|
-
agentName: String!
|
|
44
|
-
createdAt: DateTimeISO!
|
|
45
|
-
id: String!
|
|
46
|
-
nodeName: String!
|
|
47
|
-
role: MessageRole!
|
|
48
|
-
running: Boolean!
|
|
49
|
-
state: String!
|
|
50
|
-
status: MessageStatus!
|
|
51
|
-
threadId: String!
|
|
52
|
-
}
|
|
53
|
-
|
|
54
33
|
interface BaseMessageOutput {
|
|
55
34
|
createdAt: DateTimeISO!
|
|
56
35
|
id: String!
|
|
@@ -151,7 +130,6 @@ scalar JSONObject @specifiedBy(url: "http://www.ecma-international.org/publicati
|
|
|
151
130
|
|
|
152
131
|
input MessageInput {
|
|
153
132
|
actionExecutionMessage: ActionExecutionMessageInput
|
|
154
|
-
agentMessage: AgentMessageInput
|
|
155
133
|
createdAt: DateTimeISO!
|
|
156
134
|
id: String!
|
|
157
135
|
resultMessage: ResultMessageInput
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
copilotRuntimeNodeHttpEndpoint,
|
|
3
3
|
telemetry_client_default
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MKV3LEJ6.mjs";
|
|
5
5
|
import {
|
|
6
6
|
__name
|
|
7
7
|
} from "./chunk-44O2JGUY.mjs";
|
|
@@ -21,4 +21,4 @@ __name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
|
|
|
21
21
|
export {
|
|
22
22
|
copilotRuntimeNodeExpressEndpoint
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-6PAC74F2.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
copilotRuntimeNodeHttpEndpoint,
|
|
3
3
|
telemetry_client_default
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MKV3LEJ6.mjs";
|
|
5
5
|
import {
|
|
6
6
|
__name
|
|
7
7
|
} from "./chunk-44O2JGUY.mjs";
|
|
@@ -21,4 +21,4 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|
|
|
21
21
|
export {
|
|
22
22
|
copilotRuntimeNestEndpoint
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-74B76SMO.mjs.map
|
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
convertActionInputToLangChainTool,
|
|
3
3
|
convertMessageToLangChainMessage,
|
|
4
4
|
streamLangChainResponse
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-URMISMK2.mjs";
|
|
6
6
|
import {
|
|
7
7
|
ActionExecutionMessage,
|
|
8
8
|
ResultMessage,
|
|
9
9
|
TextMessage
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-GEIBJJQ4.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
13
|
} from "./chunk-44O2JGUY.mjs";
|
|
@@ -881,4 +881,4 @@ export {
|
|
|
881
881
|
UnifyAdapter,
|
|
882
882
|
GroqAdapter
|
|
883
883
|
};
|
|
884
|
-
//# sourceMappingURL=chunk-
|
|
884
|
+
//# sourceMappingURL=chunk-CUVWSISN.mjs.map
|
|
@@ -23,20 +23,10 @@ var ResultMessage = class extends BaseMessage {
|
|
|
23
23
|
result;
|
|
24
24
|
};
|
|
25
25
|
__name(ResultMessage, "ResultMessage");
|
|
26
|
-
var AgentMessage = class extends BaseMessage {
|
|
27
|
-
threadId;
|
|
28
|
-
agentName;
|
|
29
|
-
nodeName;
|
|
30
|
-
role;
|
|
31
|
-
state;
|
|
32
|
-
running;
|
|
33
|
-
};
|
|
34
|
-
__name(AgentMessage, "AgentMessage");
|
|
35
26
|
|
|
36
27
|
export {
|
|
37
28
|
TextMessage,
|
|
38
29
|
ActionExecutionMessage,
|
|
39
|
-
ResultMessage
|
|
40
|
-
AgentMessage
|
|
30
|
+
ResultMessage
|
|
41
31
|
};
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
32
|
+
//# sourceMappingURL=chunk-GEIBJJQ4.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graphql/types/converted/index.ts"],"sourcesContent":["import {\n ActionExecutionMessageInput,\n ResultMessageInput,\n TextMessageInput,\n} from \"../../inputs/message.input\";\nimport { BaseMessage } from \"../base\";\nimport { ActionExecutionScope, MessageRole } from \"../enums\";\n\nexport class TextMessage extends BaseMessage implements TextMessageInput {\n content: string;\n role: MessageRole;\n}\n\nexport type Message = BaseMessage;\n\nexport class ActionExecutionMessage\n extends BaseMessage\n implements Omit<ActionExecutionMessageInput, \"arguments\">\n{\n name: string;\n arguments: Record<string, any>;\n scope: ActionExecutionScope;\n}\n\nexport class ResultMessage extends BaseMessage implements ResultMessageInput {\n actionExecutionId: string;\n actionName: string;\n result: string;\n}\n"],"mappings":";;;;;;;;AAQO,IAAMA,cAAN,cAA0BC,YAAAA;EAC/BC;EACAC;AACF;AAHaH;AAON,IAAMI,yBAAN,cACGH,YAAAA;EAGRI;EACAC;EACAC;AACF;AAPaH;AASN,IAAMI,gBAAN,cAA4BP,YAAAA;EACjCQ;EACAC;EACAC;AACF;AAJaH;","names":["TextMessage","BaseMessage","content","role","ActionExecutionMessage","name","arguments","scope","ResultMessage","actionExecutionId","actionName","result"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
streamLangChainResponse
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-URMISMK2.mjs";
|
|
4
4
|
import {
|
|
5
5
|
GuardrailsValidationFailureResponse,
|
|
6
6
|
MessageStreamInterruptedResponse,
|
|
@@ -10,10 +10,9 @@ import {
|
|
|
10
10
|
} from "./chunk-U3V2BCGI.mjs";
|
|
11
11
|
import {
|
|
12
12
|
ActionExecutionMessage,
|
|
13
|
-
AgentMessage,
|
|
14
13
|
ResultMessage,
|
|
15
14
|
TextMessage
|
|
16
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-GEIBJJQ4.mjs";
|
|
17
16
|
import {
|
|
18
17
|
BaseMessage
|
|
19
18
|
} from "./chunk-RMZWGQ46.mjs";
|
|
@@ -36,7 +35,7 @@ var require_package = __commonJS({
|
|
|
36
35
|
publishConfig: {
|
|
37
36
|
access: "public"
|
|
38
37
|
},
|
|
39
|
-
version: "1.1.
|
|
38
|
+
version: "1.1.2",
|
|
40
39
|
sideEffects: false,
|
|
41
40
|
main: "./dist/index.js",
|
|
42
41
|
module: "./dist/index.mjs",
|
|
@@ -178,7 +177,6 @@ var MessageInput = class extends BaseMessage {
|
|
|
178
177
|
textMessage;
|
|
179
178
|
actionExecutionMessage;
|
|
180
179
|
resultMessage;
|
|
181
|
-
agentMessage;
|
|
182
180
|
};
|
|
183
181
|
__name(MessageInput, "MessageInput");
|
|
184
182
|
_ts_decorate([
|
|
@@ -199,12 +197,6 @@ _ts_decorate([
|
|
|
199
197
|
}),
|
|
200
198
|
_ts_metadata("design:type", typeof ResultMessageInput === "undefined" ? Object : ResultMessageInput)
|
|
201
199
|
], MessageInput.prototype, "resultMessage", void 0);
|
|
202
|
-
_ts_decorate([
|
|
203
|
-
Field(() => AgentMessageInput, {
|
|
204
|
-
nullable: true
|
|
205
|
-
}),
|
|
206
|
-
_ts_metadata("design:type", typeof AgentMessageInput === "undefined" ? Object : AgentMessageInput)
|
|
207
|
-
], MessageInput.prototype, "agentMessage", void 0);
|
|
208
200
|
MessageInput = _ts_decorate([
|
|
209
201
|
InputType()
|
|
210
202
|
], MessageInput);
|
|
@@ -266,42 +258,6 @@ _ts_decorate([
|
|
|
266
258
|
ResultMessageInput = _ts_decorate([
|
|
267
259
|
InputType()
|
|
268
260
|
], ResultMessageInput);
|
|
269
|
-
var AgentMessageInput = class {
|
|
270
|
-
threadId;
|
|
271
|
-
agentName;
|
|
272
|
-
role;
|
|
273
|
-
state;
|
|
274
|
-
running;
|
|
275
|
-
nodeName;
|
|
276
|
-
};
|
|
277
|
-
__name(AgentMessageInput, "AgentMessageInput");
|
|
278
|
-
_ts_decorate([
|
|
279
|
-
Field(() => String),
|
|
280
|
-
_ts_metadata("design:type", String)
|
|
281
|
-
], AgentMessageInput.prototype, "threadId", void 0);
|
|
282
|
-
_ts_decorate([
|
|
283
|
-
Field(() => String),
|
|
284
|
-
_ts_metadata("design:type", String)
|
|
285
|
-
], AgentMessageInput.prototype, "agentName", void 0);
|
|
286
|
-
_ts_decorate([
|
|
287
|
-
Field(() => MessageRole),
|
|
288
|
-
_ts_metadata("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
|
|
289
|
-
], AgentMessageInput.prototype, "role", void 0);
|
|
290
|
-
_ts_decorate([
|
|
291
|
-
Field(() => String),
|
|
292
|
-
_ts_metadata("design:type", String)
|
|
293
|
-
], AgentMessageInput.prototype, "state", void 0);
|
|
294
|
-
_ts_decorate([
|
|
295
|
-
Field(() => Boolean),
|
|
296
|
-
_ts_metadata("design:type", Boolean)
|
|
297
|
-
], AgentMessageInput.prototype, "running", void 0);
|
|
298
|
-
_ts_decorate([
|
|
299
|
-
Field(() => String),
|
|
300
|
-
_ts_metadata("design:type", String)
|
|
301
|
-
], AgentMessageInput.prototype, "nodeName", void 0);
|
|
302
|
-
AgentMessageInput = _ts_decorate([
|
|
303
|
-
InputType()
|
|
304
|
-
], AgentMessageInput);
|
|
305
261
|
|
|
306
262
|
// src/graphql/inputs/frontend.input.ts
|
|
307
263
|
import { Field as Field3, InputType as InputType3 } from "type-graphql";
|
|
@@ -738,8 +694,6 @@ BaseMessageOutput = _ts_decorate9([
|
|
|
738
694
|
return ActionExecutionMessageOutput;
|
|
739
695
|
} else if (value.hasOwnProperty("result")) {
|
|
740
696
|
return ResultMessageOutput;
|
|
741
|
-
} else if (value.hasOwnProperty("agentName")) {
|
|
742
|
-
return AgentMessageOutput;
|
|
743
697
|
}
|
|
744
698
|
return void 0;
|
|
745
699
|
}
|
|
@@ -813,44 +767,6 @@ ResultMessageOutput = _ts_decorate9([
|
|
|
813
767
|
implements: BaseMessageOutput
|
|
814
768
|
})
|
|
815
769
|
], ResultMessageOutput);
|
|
816
|
-
var AgentMessageOutput = class {
|
|
817
|
-
threadId;
|
|
818
|
-
agentName;
|
|
819
|
-
nodeName;
|
|
820
|
-
role;
|
|
821
|
-
state;
|
|
822
|
-
running;
|
|
823
|
-
};
|
|
824
|
-
__name(AgentMessageOutput, "AgentMessageOutput");
|
|
825
|
-
_ts_decorate9([
|
|
826
|
-
Field9(() => String),
|
|
827
|
-
_ts_metadata9("design:type", String)
|
|
828
|
-
], AgentMessageOutput.prototype, "threadId", void 0);
|
|
829
|
-
_ts_decorate9([
|
|
830
|
-
Field9(() => String),
|
|
831
|
-
_ts_metadata9("design:type", String)
|
|
832
|
-
], AgentMessageOutput.prototype, "agentName", void 0);
|
|
833
|
-
_ts_decorate9([
|
|
834
|
-
Field9(() => String),
|
|
835
|
-
_ts_metadata9("design:type", String)
|
|
836
|
-
], AgentMessageOutput.prototype, "nodeName", void 0);
|
|
837
|
-
_ts_decorate9([
|
|
838
|
-
Field9(() => MessageRole),
|
|
839
|
-
_ts_metadata9("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
|
|
840
|
-
], AgentMessageOutput.prototype, "role", void 0);
|
|
841
|
-
_ts_decorate9([
|
|
842
|
-
Field9(() => String),
|
|
843
|
-
_ts_metadata9("design:type", String)
|
|
844
|
-
], AgentMessageOutput.prototype, "state", void 0);
|
|
845
|
-
_ts_decorate9([
|
|
846
|
-
Field9(() => Boolean),
|
|
847
|
-
_ts_metadata9("design:type", Boolean)
|
|
848
|
-
], AgentMessageOutput.prototype, "running", void 0);
|
|
849
|
-
AgentMessageOutput = _ts_decorate9([
|
|
850
|
-
ObjectType2({
|
|
851
|
-
implements: BaseMessageOutput
|
|
852
|
-
})
|
|
853
|
-
], AgentMessageOutput);
|
|
854
770
|
var CopilotResponse = class {
|
|
855
771
|
threadId;
|
|
856
772
|
status;
|
|
@@ -887,216 +803,6 @@ import { Repeater } from "graphql-yoga";
|
|
|
887
803
|
|
|
888
804
|
// src/service-adapters/events.ts
|
|
889
805
|
import { of, concat, map, scan, concatMap, ReplaySubject, firstValueFrom } from "rxjs";
|
|
890
|
-
|
|
891
|
-
// src/lib/telemetry-client.ts
|
|
892
|
-
import { TelemetryClient } from "@copilotkit/shared";
|
|
893
|
-
var packageJson = require_package();
|
|
894
|
-
var telemetryClient = new TelemetryClient({
|
|
895
|
-
packageName: packageJson.name,
|
|
896
|
-
packageVersion: packageJson.version
|
|
897
|
-
});
|
|
898
|
-
var telemetry_client_default = telemetryClient;
|
|
899
|
-
|
|
900
|
-
// src/lib/runtime/remote-actions.ts
|
|
901
|
-
function isAgentResult(obj, checkAgentMessageFlag = false) {
|
|
902
|
-
if (checkAgentMessageFlag) {
|
|
903
|
-
return typeof obj === "object" && obj !== null && "__agentMessage" in obj && obj.__agentMessage === true;
|
|
904
|
-
} else {
|
|
905
|
-
return typeof obj === "object" && obj !== null && "threadId" in obj && "state" in obj && "running" in obj && "name" in obj;
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
__name(isAgentResult, "isAgentResult");
|
|
909
|
-
function createHeaders(onBeforeRequest, graphqlContext) {
|
|
910
|
-
const headers = {
|
|
911
|
-
"Content-Type": "application/json"
|
|
912
|
-
};
|
|
913
|
-
if (onBeforeRequest) {
|
|
914
|
-
const { headers: additionalHeaders } = onBeforeRequest({
|
|
915
|
-
ctx: graphqlContext
|
|
916
|
-
});
|
|
917
|
-
if (additionalHeaders) {
|
|
918
|
-
Object.assign(headers, additionalHeaders);
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
return headers;
|
|
922
|
-
}
|
|
923
|
-
__name(createHeaders, "createHeaders");
|
|
924
|
-
async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: logger2 }) {
|
|
925
|
-
logger2.debug({
|
|
926
|
-
url
|
|
927
|
-
}, "Fetching actions from url");
|
|
928
|
-
const headers = createHeaders(onBeforeRequest, graphqlContext);
|
|
929
|
-
const response = await fetch(`${url}/info`, {
|
|
930
|
-
method: "POST",
|
|
931
|
-
headers,
|
|
932
|
-
body: JSON.stringify({
|
|
933
|
-
properties: graphqlContext.properties
|
|
934
|
-
})
|
|
935
|
-
});
|
|
936
|
-
if (!response.ok) {
|
|
937
|
-
logger2.error({
|
|
938
|
-
url,
|
|
939
|
-
status: response.status,
|
|
940
|
-
body: await response.text()
|
|
941
|
-
}, "Failed to fetch actions from url");
|
|
942
|
-
return [];
|
|
943
|
-
}
|
|
944
|
-
const json = await response.json();
|
|
945
|
-
logger2.debug({
|
|
946
|
-
json
|
|
947
|
-
}, "Fetched actions from url");
|
|
948
|
-
return json;
|
|
949
|
-
}
|
|
950
|
-
__name(fetchRemoteInfo, "fetchRemoteInfo");
|
|
951
|
-
function constructActions({ json, url, onBeforeRequest, graphqlContext, logger: logger2 }) {
|
|
952
|
-
return json["actions"].map((action) => ({
|
|
953
|
-
name: action.name,
|
|
954
|
-
description: action.description,
|
|
955
|
-
parameters: action.parameters,
|
|
956
|
-
handler: async (args) => {
|
|
957
|
-
logger2.debug({
|
|
958
|
-
actionName: action.name,
|
|
959
|
-
args
|
|
960
|
-
}, "Executing remote action");
|
|
961
|
-
const headers = createHeaders(onBeforeRequest, graphqlContext);
|
|
962
|
-
telemetry_client_default.capture("oss.runtime.remote_action_executed", {});
|
|
963
|
-
const response = await fetch(`${url}/actions/execute`, {
|
|
964
|
-
method: "POST",
|
|
965
|
-
headers,
|
|
966
|
-
body: JSON.stringify({
|
|
967
|
-
name: action.name,
|
|
968
|
-
parameters: args,
|
|
969
|
-
properties: graphqlContext.properties
|
|
970
|
-
})
|
|
971
|
-
});
|
|
972
|
-
if (!response.ok) {
|
|
973
|
-
logger2.error({
|
|
974
|
-
url,
|
|
975
|
-
status: response.status,
|
|
976
|
-
body: await response.text()
|
|
977
|
-
}, "Failed to execute remote action");
|
|
978
|
-
return "Failed to execute remote action";
|
|
979
|
-
}
|
|
980
|
-
const requestResult = await response.json();
|
|
981
|
-
if (isAgentResult(requestResult)) {
|
|
982
|
-
logger2.debug({
|
|
983
|
-
actionName: action.name,
|
|
984
|
-
result: requestResult
|
|
985
|
-
}, "Started agent session");
|
|
986
|
-
return {
|
|
987
|
-
...requestResult,
|
|
988
|
-
__agentMessage: true
|
|
989
|
-
};
|
|
990
|
-
} else {
|
|
991
|
-
const result = requestResult["result"];
|
|
992
|
-
logger2.debug({
|
|
993
|
-
actionName: action.name,
|
|
994
|
-
result
|
|
995
|
-
}, "Executed remote action");
|
|
996
|
-
return result;
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
}));
|
|
1000
|
-
}
|
|
1001
|
-
__name(constructActions, "constructActions");
|
|
1002
|
-
async function executeAgent({ agentName, nodeName, threadId, state, url, onBeforeRequest, graphqlContext, logger: logger2 }) {
|
|
1003
|
-
logger2.debug({
|
|
1004
|
-
agentName,
|
|
1005
|
-
threadId,
|
|
1006
|
-
state
|
|
1007
|
-
}, "Executing remote action");
|
|
1008
|
-
const headers = createHeaders(onBeforeRequest, graphqlContext);
|
|
1009
|
-
telemetry_client_default.capture("oss.runtime.remote_action_executed", {});
|
|
1010
|
-
const response = await fetch(`${url}/actions/execute`, {
|
|
1011
|
-
method: "POST",
|
|
1012
|
-
headers,
|
|
1013
|
-
body: JSON.stringify({
|
|
1014
|
-
threadId,
|
|
1015
|
-
state,
|
|
1016
|
-
name: agentName,
|
|
1017
|
-
nodeName
|
|
1018
|
-
})
|
|
1019
|
-
});
|
|
1020
|
-
if (!response.ok) {
|
|
1021
|
-
logger2.error({
|
|
1022
|
-
url,
|
|
1023
|
-
status: response.status,
|
|
1024
|
-
body: await response.text()
|
|
1025
|
-
}, "Failed to execute remote agent");
|
|
1026
|
-
throw new Error("Failed to execute remote agent");
|
|
1027
|
-
}
|
|
1028
|
-
const requestResult = await response.json();
|
|
1029
|
-
logger2.debug({
|
|
1030
|
-
agentName,
|
|
1031
|
-
threadId,
|
|
1032
|
-
state
|
|
1033
|
-
}, "Executed remote agent");
|
|
1034
|
-
return {
|
|
1035
|
-
...requestResult,
|
|
1036
|
-
__agentMessage: true
|
|
1037
|
-
};
|
|
1038
|
-
}
|
|
1039
|
-
__name(executeAgent, "executeAgent");
|
|
1040
|
-
async function setupRemoteActions({ remoteActionDefinitions, graphqlContext }) {
|
|
1041
|
-
const logger2 = graphqlContext.logger.child({
|
|
1042
|
-
component: "remote-actions.fetchRemoteActions"
|
|
1043
|
-
});
|
|
1044
|
-
logger2.debug({
|
|
1045
|
-
remoteActionDefinitions
|
|
1046
|
-
}, "Fetching remote actions");
|
|
1047
|
-
const filtered = remoteActionDefinitions.filter((value, index, self) => index === self.findIndex((t) => t.url === value.url));
|
|
1048
|
-
const result = await Promise.all(filtered.map(async (actionDefinition) => {
|
|
1049
|
-
const json = await fetchRemoteInfo({
|
|
1050
|
-
url: actionDefinition.url,
|
|
1051
|
-
onBeforeRequest: actionDefinition.onBeforeRequest,
|
|
1052
|
-
graphqlContext,
|
|
1053
|
-
logger: logger2.child({
|
|
1054
|
-
component: "remote-actions.fetchActionsFromUrl",
|
|
1055
|
-
actionDefinition
|
|
1056
|
-
})
|
|
1057
|
-
});
|
|
1058
|
-
return constructActions({
|
|
1059
|
-
json,
|
|
1060
|
-
url: actionDefinition.url,
|
|
1061
|
-
onBeforeRequest: actionDefinition.onBeforeRequest,
|
|
1062
|
-
graphqlContext,
|
|
1063
|
-
logger: logger2.child({
|
|
1064
|
-
component: "remote-actions.constructActions",
|
|
1065
|
-
actionDefinition
|
|
1066
|
-
})
|
|
1067
|
-
});
|
|
1068
|
-
}));
|
|
1069
|
-
return result.flat();
|
|
1070
|
-
}
|
|
1071
|
-
__name(setupRemoteActions, "setupRemoteActions");
|
|
1072
|
-
async function fetchRemoteActionLocations({ remoteActionDefinitions, graphqlContext }) {
|
|
1073
|
-
const logger2 = graphqlContext.logger.child({
|
|
1074
|
-
component: "remote-actions.fetchRemoteActionLocations"
|
|
1075
|
-
});
|
|
1076
|
-
logger2.debug({
|
|
1077
|
-
remoteActionDefinitions
|
|
1078
|
-
}, "Fetching remote action locations");
|
|
1079
|
-
const filtered = remoteActionDefinitions.filter((value, index, self) => index === self.findIndex((t) => t.url === value.url));
|
|
1080
|
-
const result = /* @__PURE__ */ new Map();
|
|
1081
|
-
await Promise.all(filtered.map(async (actionDefinition) => {
|
|
1082
|
-
const json = await fetchRemoteInfo({
|
|
1083
|
-
url: actionDefinition.url,
|
|
1084
|
-
onBeforeRequest: actionDefinition.onBeforeRequest,
|
|
1085
|
-
graphqlContext,
|
|
1086
|
-
logger: logger2.child({
|
|
1087
|
-
component: "remote-actions.fetchActionsFromUrl",
|
|
1088
|
-
actionDefinition
|
|
1089
|
-
})
|
|
1090
|
-
});
|
|
1091
|
-
json["actions"].forEach((action) => {
|
|
1092
|
-
result.set(action.name, actionDefinition.url);
|
|
1093
|
-
});
|
|
1094
|
-
}));
|
|
1095
|
-
return result;
|
|
1096
|
-
}
|
|
1097
|
-
__name(fetchRemoteActionLocations, "fetchRemoteActionLocations");
|
|
1098
|
-
|
|
1099
|
-
// src/service-adapters/events.ts
|
|
1100
806
|
var RuntimeEventTypes;
|
|
1101
807
|
(function(RuntimeEventTypes2) {
|
|
1102
808
|
RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
|
|
@@ -1106,7 +812,6 @@ var RuntimeEventTypes;
|
|
|
1106
812
|
RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
|
|
1107
813
|
RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
|
|
1108
814
|
RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
|
|
1109
|
-
RuntimeEventTypes2["AgentMessage"] = "AgentMessage";
|
|
1110
815
|
})(RuntimeEventTypes || (RuntimeEventTypes = {}));
|
|
1111
816
|
var RuntimeEventSubject = class extends ReplaySubject {
|
|
1112
817
|
constructor() {
|
|
@@ -1165,16 +870,6 @@ var RuntimeEventSubject = class extends ReplaySubject {
|
|
|
1165
870
|
result
|
|
1166
871
|
});
|
|
1167
872
|
}
|
|
1168
|
-
sendAgentMessage(threadId, agentName, nodeName, state, running) {
|
|
1169
|
-
this.next({
|
|
1170
|
-
type: "AgentMessage",
|
|
1171
|
-
threadId,
|
|
1172
|
-
agentName,
|
|
1173
|
-
nodeName,
|
|
1174
|
-
state,
|
|
1175
|
-
running
|
|
1176
|
-
});
|
|
1177
|
-
}
|
|
1178
873
|
};
|
|
1179
874
|
__name(RuntimeEventSubject, "RuntimeEventSubject");
|
|
1180
875
|
var RuntimeEventSource = class {
|
|
@@ -1222,7 +917,6 @@ var RuntimeEventSource = class {
|
|
|
1222
917
|
executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionId).catch((error) => {
|
|
1223
918
|
console.error(error);
|
|
1224
919
|
});
|
|
1225
|
-
telemetry_client_default.capture("oss.runtime.server_action_executed", {});
|
|
1226
920
|
return concat(of(eventWithState.event), toolCallEventStream$);
|
|
1227
921
|
} else {
|
|
1228
922
|
return of(eventWithState.event);
|
|
@@ -1245,19 +939,14 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
|
|
|
1245
939
|
args = JSON.parse(actionArguments);
|
|
1246
940
|
}
|
|
1247
941
|
const result = await action.handler(args);
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
eventStream
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
name: action.name,
|
|
1257
|
-
id: actionExecutionId
|
|
1258
|
-
}
|
|
1259
|
-
});
|
|
1260
|
-
}
|
|
942
|
+
await streamLangChainResponse({
|
|
943
|
+
result,
|
|
944
|
+
eventStream$,
|
|
945
|
+
actionExecution: {
|
|
946
|
+
name: action.name,
|
|
947
|
+
id: actionExecutionId
|
|
948
|
+
}
|
|
949
|
+
});
|
|
1261
950
|
}
|
|
1262
951
|
__name(executeAction, "executeAction");
|
|
1263
952
|
|
|
@@ -1265,6 +954,17 @@ __name(executeAction, "executeAction");
|
|
|
1265
954
|
import { GraphQLJSONObject } from "graphql-scalars";
|
|
1266
955
|
import { plainToInstance } from "class-transformer";
|
|
1267
956
|
import { GraphQLError } from "graphql";
|
|
957
|
+
|
|
958
|
+
// src/lib/telemetry-client.ts
|
|
959
|
+
import { TelemetryClient } from "@copilotkit/shared";
|
|
960
|
+
var packageJson = require_package();
|
|
961
|
+
var telemetryClient = new TelemetryClient({
|
|
962
|
+
packageName: packageJson.name,
|
|
963
|
+
packageVersion: packageJson.version
|
|
964
|
+
});
|
|
965
|
+
var telemetry_client_default = telemetryClient;
|
|
966
|
+
|
|
967
|
+
// src/graphql/resolvers/copilot.resolver.ts
|
|
1268
968
|
import { randomId } from "@copilotkit/shared";
|
|
1269
969
|
function _ts_decorate10(decorators, target, key, desc) {
|
|
1270
970
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1290,6 +990,7 @@ function _ts_param(paramIndex, decorator) {
|
|
|
1290
990
|
__name(_ts_param, "_ts_param");
|
|
1291
991
|
var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPublicApiKey, data, onResult, onError }) => {
|
|
1292
992
|
var _a;
|
|
993
|
+
console.log("invokeGuardrails.baseUrl", baseUrl);
|
|
1293
994
|
if (data.messages.length && ((_a = data.messages[data.messages.length - 1].textMessage) == null ? void 0 : _a.role) === MessageRole.user) {
|
|
1294
995
|
const messages = data.messages.filter((m) => m.textMessage !== void 0 && (m.textMessage.role === MessageRole.user || m.textMessage.role === MessageRole.assistant)).map((m) => ({
|
|
1295
996
|
role: m.textMessage.role,
|
|
@@ -1335,6 +1036,8 @@ var CopilotResolver = class {
|
|
|
1335
1036
|
logger2.debug({
|
|
1336
1037
|
data
|
|
1337
1038
|
}, "Generating Copilot response");
|
|
1039
|
+
const copilotRuntime = ctx._copilotkit.runtime;
|
|
1040
|
+
const serviceAdapter = ctx._copilotkit.serviceAdapter;
|
|
1338
1041
|
if (properties) {
|
|
1339
1042
|
logger2.debug("Properties provided, merging with context properties");
|
|
1340
1043
|
ctx.properties = {
|
|
@@ -1342,8 +1045,6 @@ var CopilotResolver = class {
|
|
|
1342
1045
|
...properties
|
|
1343
1046
|
};
|
|
1344
1047
|
}
|
|
1345
|
-
const copilotRuntime = ctx._copilotkit.runtime;
|
|
1346
|
-
const serviceAdapter = ctx._copilotkit.serviceAdapter;
|
|
1347
1048
|
let copilotCloudPublicApiKey = null;
|
|
1348
1049
|
let copilotCloudBaseUrl;
|
|
1349
1050
|
if (data.cloud) {
|
|
@@ -1389,8 +1090,8 @@ var CopilotResolver = class {
|
|
|
1389
1090
|
threadId: data.threadId,
|
|
1390
1091
|
runId: data.runId,
|
|
1391
1092
|
publicApiKey: void 0,
|
|
1093
|
+
properties: ctx.properties || {},
|
|
1392
1094
|
outputMessagesPromise,
|
|
1393
|
-
graphqlContext: ctx,
|
|
1394
1095
|
forwardedParameters: data.forwardedParameters
|
|
1395
1096
|
});
|
|
1396
1097
|
logger2.debug("Event source created, creating response");
|
|
@@ -1598,32 +1299,6 @@ var CopilotResolver = class {
|
|
|
1598
1299
|
result: event.result
|
|
1599
1300
|
}));
|
|
1600
1301
|
break;
|
|
1601
|
-
case RuntimeEventTypes.AgentMessage:
|
|
1602
|
-
logger2.debug({
|
|
1603
|
-
event
|
|
1604
|
-
}, "Agent message event received");
|
|
1605
|
-
pushMessage({
|
|
1606
|
-
id: randomId(),
|
|
1607
|
-
status: new SuccessMessageStatus(),
|
|
1608
|
-
threadId: event.threadId,
|
|
1609
|
-
agentName: event.agentName,
|
|
1610
|
-
nodeName: event.nodeName,
|
|
1611
|
-
state: JSON.stringify(event.state),
|
|
1612
|
-
running: event.running,
|
|
1613
|
-
role: MessageRole.assistant,
|
|
1614
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
1615
|
-
});
|
|
1616
|
-
outputMessages.push(plainToInstance(AgentMessage, {
|
|
1617
|
-
id: randomId(),
|
|
1618
|
-
threadId: event.threadId,
|
|
1619
|
-
agentName: event.agentName,
|
|
1620
|
-
nodeName: event.nodeName,
|
|
1621
|
-
state: JSON.stringify(event.state),
|
|
1622
|
-
running: event.running,
|
|
1623
|
-
role: MessageRole.assistant,
|
|
1624
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
1625
|
-
}));
|
|
1626
|
-
break;
|
|
1627
1302
|
}
|
|
1628
1303
|
},
|
|
1629
1304
|
error: (err) => {
|
|
@@ -1811,14 +1486,11 @@ function copilotRuntimeNodeHttpEndpoint(options) {
|
|
|
1811
1486
|
__name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
|
|
1812
1487
|
|
|
1813
1488
|
export {
|
|
1814
|
-
telemetry_client_default,
|
|
1815
|
-
executeAgent,
|
|
1816
|
-
setupRemoteActions,
|
|
1817
|
-
fetchRemoteActionLocations,
|
|
1818
1489
|
RuntimeEventSource,
|
|
1490
|
+
telemetry_client_default,
|
|
1819
1491
|
createContext,
|
|
1820
1492
|
buildSchema,
|
|
1821
1493
|
getCommonConfig,
|
|
1822
1494
|
copilotRuntimeNodeHttpEndpoint
|
|
1823
1495
|
};
|
|
1824
|
-
//# sourceMappingURL=chunk-
|
|
1496
|
+
//# sourceMappingURL=chunk-MKV3LEJ6.mjs.map
|