@copilotkit/runtime 1.50.0-beta.9 → 1.50.0
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 +157 -0
- package/dist/chunk-27JKTS6P.mjs +1704 -0
- package/dist/chunk-27JKTS6P.mjs.map +1 -0
- package/dist/{chunk-FMU55SEU.mjs → chunk-2GPTVDTO.mjs} +2 -2
- package/dist/chunk-3AJVKDZX.mjs +3097 -0
- package/dist/chunk-3AJVKDZX.mjs.map +1 -0
- package/dist/{chunk-BJEYMRDD.mjs → chunk-45RCC3ZS.mjs} +2 -2
- package/dist/chunk-4EHJ4XFJ.mjs +25 -0
- package/dist/chunk-4EHJ4XFJ.mjs.map +1 -0
- package/dist/chunk-4IANB4TC.mjs +25 -0
- package/dist/chunk-4IANB4TC.mjs.map +1 -0
- package/dist/{chunk-Z752VE75.mjs → chunk-4KES76K3.mjs} +2 -2
- package/dist/chunk-4OGE3SLW.mjs +3100 -0
- package/dist/chunk-4OGE3SLW.mjs.map +1 -0
- package/dist/chunk-54YJBMCP.mjs +3097 -0
- package/dist/chunk-54YJBMCP.mjs.map +1 -0
- package/dist/chunk-6ER4SZYH.mjs +74 -0
- package/dist/chunk-6ER4SZYH.mjs.map +1 -0
- package/dist/chunk-6TNSLHVR.mjs +74 -0
- package/dist/chunk-6TNSLHVR.mjs.map +1 -0
- package/dist/chunk-7V4BK7TZ.mjs +25 -0
- package/dist/chunk-7V4BK7TZ.mjs.map +1 -0
- package/dist/chunk-7YZIEXD2.mjs +74 -0
- package/dist/chunk-7YZIEXD2.mjs.map +1 -0
- package/dist/chunk-A4XHOAFU.mjs +25 -0
- package/dist/chunk-A4XHOAFU.mjs.map +1 -0
- package/dist/chunk-A555KEAD.mjs +6020 -0
- package/dist/chunk-A555KEAD.mjs.map +1 -0
- package/dist/chunk-AF73TFTX.mjs +74 -0
- package/dist/chunk-AF73TFTX.mjs.map +1 -0
- package/dist/chunk-AQG2SVCA.mjs +25 -0
- package/dist/chunk-AQG2SVCA.mjs.map +1 -0
- package/dist/chunk-BJZHMXND.mjs +74 -0
- package/dist/chunk-BJZHMXND.mjs.map +1 -0
- package/dist/chunk-CB2OJXF6.mjs +25 -0
- package/dist/chunk-CB2OJXF6.mjs.map +1 -0
- package/dist/chunk-CEOMFPJU.mjs +6020 -0
- package/dist/chunk-CEOMFPJU.mjs.map +1 -0
- package/dist/chunk-CZVLR7CC.mjs +175 -0
- package/dist/chunk-CZVLR7CC.mjs.map +1 -0
- package/dist/{chunk-SBCOROE4.mjs → chunk-DCEEHMLJ.mjs} +16 -1
- package/dist/chunk-DCEEHMLJ.mjs.map +1 -0
- package/dist/chunk-DE3CLKUG.mjs +25 -0
- package/dist/chunk-DE3CLKUG.mjs.map +1 -0
- package/dist/chunk-DTPRUTNV.mjs +25 -0
- package/dist/chunk-DTPRUTNV.mjs.map +1 -0
- package/dist/{chunk-TTUAEJLD.mjs → chunk-ERUOA47O.mjs} +11 -2
- package/dist/chunk-ERUOA47O.mjs.map +1 -0
- package/dist/chunk-ESSRC64W.mjs +74 -0
- package/dist/chunk-ESSRC64W.mjs.map +1 -0
- package/dist/chunk-GRAN6K6N.mjs +25 -0
- package/dist/chunk-GRAN6K6N.mjs.map +1 -0
- package/dist/chunk-I27F2UPA.mjs +175 -0
- package/dist/chunk-I27F2UPA.mjs.map +1 -0
- package/dist/chunk-IAZKTOQW.mjs +25 -0
- package/dist/chunk-IAZKTOQW.mjs.map +1 -0
- package/dist/chunk-J6XZ5MFB.mjs +25 -0
- package/dist/chunk-J6XZ5MFB.mjs.map +1 -0
- package/dist/chunk-JJ32MA4C.mjs +73 -0
- package/dist/chunk-JJ32MA4C.mjs.map +1 -0
- package/dist/chunk-JJY4ZTHQ.mjs +25 -0
- package/dist/chunk-JJY4ZTHQ.mjs.map +1 -0
- package/dist/chunk-KEYLBFU2.mjs +3117 -0
- package/dist/chunk-KEYLBFU2.mjs.map +1 -0
- package/dist/chunk-KQ53L4WZ.mjs +3094 -0
- package/dist/chunk-KQ53L4WZ.mjs.map +1 -0
- package/dist/chunk-KTELVQ67.mjs +3098 -0
- package/dist/chunk-KTELVQ67.mjs.map +1 -0
- package/dist/chunk-LPEPX6NH.mjs +25 -0
- package/dist/chunk-LPEPX6NH.mjs.map +1 -0
- package/dist/chunk-MDXE55DK.mjs +3117 -0
- package/dist/chunk-MDXE55DK.mjs.map +1 -0
- package/dist/chunk-MMFUVOXH.mjs +73 -0
- package/dist/chunk-MMFUVOXH.mjs.map +1 -0
- package/dist/chunk-N3Y4U66N.mjs +253 -0
- package/dist/chunk-N3Y4U66N.mjs.map +1 -0
- package/dist/chunk-O7UYB4MH.mjs +25 -0
- package/dist/chunk-O7UYB4MH.mjs.map +1 -0
- package/dist/chunk-OFNVQHNM.mjs +3089 -0
- package/dist/chunk-OFNVQHNM.mjs.map +1 -0
- package/dist/{chunk-DZV4ZIAR.mjs → chunk-OFSV5GET.mjs} +17 -6
- package/dist/chunk-OFSV5GET.mjs.map +1 -0
- package/dist/chunk-OMRST67R.mjs +25 -0
- package/dist/chunk-OMRST67R.mjs.map +1 -0
- package/dist/chunk-PRZHE74A.mjs +25 -0
- package/dist/chunk-PRZHE74A.mjs.map +1 -0
- package/dist/chunk-PTYRVXXP.mjs +80 -0
- package/dist/chunk-PTYRVXXP.mjs.map +1 -0
- package/dist/chunk-R22B5CCO.mjs +25 -0
- package/dist/chunk-R22B5CCO.mjs.map +1 -0
- package/dist/chunk-SHBDMA63.mjs +141 -0
- package/dist/chunk-SHBDMA63.mjs.map +1 -0
- package/dist/chunk-SPVXBPRA.mjs +74 -0
- package/dist/chunk-SPVXBPRA.mjs.map +1 -0
- package/dist/chunk-T72G46ME.mjs +25 -0
- package/dist/chunk-T72G46ME.mjs.map +1 -0
- package/dist/chunk-TGELROPU.mjs +25 -0
- package/dist/chunk-TGELROPU.mjs.map +1 -0
- package/dist/chunk-UNX4IAAD.mjs +25 -0
- package/dist/chunk-UNX4IAAD.mjs.map +1 -0
- package/dist/chunk-V4DHVC7M.mjs +3085 -0
- package/dist/chunk-V4DHVC7M.mjs.map +1 -0
- package/dist/chunk-VVRFOB66.mjs +25 -0
- package/dist/chunk-VVRFOB66.mjs.map +1 -0
- package/dist/chunk-W6NVBYM6.mjs +80 -0
- package/dist/chunk-W6NVBYM6.mjs.map +1 -0
- package/dist/chunk-W7MBACGC.mjs +74 -0
- package/dist/chunk-W7MBACGC.mjs.map +1 -0
- package/dist/chunk-WMD4XZZS.mjs +25 -0
- package/dist/chunk-WMD4XZZS.mjs.map +1 -0
- package/dist/chunk-WX2ZNCRT.mjs +74 -0
- package/dist/chunk-WX2ZNCRT.mjs.map +1 -0
- package/dist/chunk-Y2Z62E2T.mjs +74 -0
- package/dist/chunk-Y2Z62E2T.mjs.map +1 -0
- package/dist/chunk-YO4I6RVI.mjs +25 -0
- package/dist/chunk-YO4I6RVI.mjs.map +1 -0
- package/dist/chunk-Z6Q5IW6I.mjs +3098 -0
- package/dist/chunk-Z6Q5IW6I.mjs.map +1 -0
- package/dist/chunk-Z726O3G2.mjs +25 -0
- package/dist/chunk-Z726O3G2.mjs.map +1 -0
- package/dist/chunk-ZE4SMZZR.mjs +3097 -0
- package/dist/chunk-ZE4SMZZR.mjs.map +1 -0
- package/dist/chunk-ZULZB33C.mjs +73 -0
- package/dist/chunk-ZULZB33C.mjs.map +1 -0
- package/dist/chunk-ZVRGXMY7.mjs +25 -0
- package/dist/chunk-ZVRGXMY7.mjs.map +1 -0
- package/dist/chunk-ZZ35WBYQ.mjs +25 -0
- package/dist/chunk-ZZ35WBYQ.mjs.map +1 -0
- package/dist/graphql/types/converted/index.d.ts +1 -1
- package/dist/graphql/types/converted/index.js +16 -110
- package/dist/graphql/types/converted/index.js.map +1 -1
- package/dist/graphql/types/converted/index.mjs +2 -3
- package/dist/{groq-adapter-50bc6e4a.d.ts → groq-adapter-540da9c3.d.ts} +6 -1
- package/dist/groq-adapter-a6f5e9d2.d.ts +331 -0
- package/dist/groq-adapter-c8aec5c5.d.ts +321 -0
- package/dist/index-96b330da.d.ts +119 -0
- package/dist/index.d.ts +67 -8
- package/dist/index.js +118 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +120 -31
- package/dist/index.mjs.map +1 -1
- package/dist/langserve-0c6100e3.d.ts +257 -0
- package/dist/langserve-978d5790.d.ts +243 -0
- package/dist/{langserve-74a52292.d.ts → langserve-9fc76ce5.d.ts} +1 -0
- package/dist/lib/index.d.ts +5 -59
- package/dist/lib/index.js +3702 -803
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +20 -18
- package/dist/lib/integrations/index.d.ts +15 -9
- package/dist/lib/integrations/index.js +215 -187
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +8 -7
- package/dist/lib/integrations/nest/index.d.ts +5 -6
- package/dist/lib/integrations/nest/index.js +197 -175
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +6 -5
- package/dist/lib/integrations/node-express/index.d.ts +5 -6
- package/dist/lib/integrations/node-express/index.js +197 -175
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +6 -5
- package/dist/lib/integrations/node-http/index.d.ts +5 -6
- package/dist/lib/integrations/node-http/index.js +197 -175
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +5 -4
- package/dist/service-adapters/index.d.ts +7 -11
- package/dist/service-adapters/index.js +8 -21
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +2 -4
- package/dist/shared-0a7346ce.d.ts +466 -0
- package/dist/{shared-f6d43ef8.d.ts → shared-35c6eb04.d.ts} +3 -1
- package/dist/shared-9ed1dc31.d.ts +414 -0
- package/dist/shared-da5708fe.d.ts +449 -0
- package/package.json +14 -20
- package/src/lib/index.ts +7 -6
- package/src/lib/runtime/copilot-runtime.ts +62 -26
- package/src/lib/runtime/telemetry-agent-runner.ts +139 -0
- package/dist/chunk-DZV4ZIAR.mjs.map +0 -1
- package/dist/chunk-SBCOROE4.mjs.map +0 -1
- package/dist/chunk-TTUAEJLD.mjs.map +0 -1
- /package/dist/{chunk-FMU55SEU.mjs.map → chunk-2GPTVDTO.mjs.map} +0 -0
- /package/dist/{chunk-BJEYMRDD.mjs.map → chunk-45RCC3ZS.mjs.map} +0 -0
- /package/dist/{chunk-Z752VE75.mjs.map → chunk-4KES76K3.mjs.map} +0 -0
|
@@ -12,11 +12,11 @@ var __export = (target, all) => {
|
|
|
12
12
|
for (var name in all)
|
|
13
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
14
|
};
|
|
15
|
-
var __copyProps = (to,
|
|
16
|
-
if (
|
|
17
|
-
for (let key of __getOwnPropNames(
|
|
15
|
+
var __copyProps = (to, from3, except, desc) => {
|
|
16
|
+
if (from3 && typeof from3 === "object" || typeof from3 === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from3))
|
|
18
18
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
-
__defProp(to, key, { get: () =>
|
|
19
|
+
__defProp(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc(from3, key)) || desc.enumerable });
|
|
20
20
|
}
|
|
21
21
|
return to;
|
|
22
22
|
};
|
|
@@ -79,14 +79,11 @@ var require_package = __commonJS({
|
|
|
79
79
|
tsconfig: "workspace:*",
|
|
80
80
|
tsup: "^6.7.0",
|
|
81
81
|
typescript: "^5.2.3",
|
|
82
|
-
vitest: "^3.2.4",
|
|
83
82
|
"zod-to-json-schema": "^3.23.5"
|
|
84
83
|
},
|
|
85
84
|
dependencies: {
|
|
86
85
|
"@anthropic-ai/sdk": "^0.57.0",
|
|
87
86
|
"@copilotkit/shared": "workspace:*",
|
|
88
|
-
"@copilotkitnext/agent": "^0.0.17",
|
|
89
|
-
"@copilotkitnext/runtime": "^0.0.17",
|
|
90
87
|
"@graphql-yoga/plugin-defer-stream": "^3.3.1",
|
|
91
88
|
"@langchain/aws": "^0.1.9",
|
|
92
89
|
"@langchain/community": "^0.3.29",
|
|
@@ -141,14 +138,14 @@ __export(node_http_exports, {
|
|
|
141
138
|
copilotRuntimeNodeHttpEndpoint: () => copilotRuntimeNodeHttpEndpoint
|
|
142
139
|
});
|
|
143
140
|
module.exports = __toCommonJS(node_http_exports);
|
|
144
|
-
var
|
|
141
|
+
var import_graphql_yoga2 = require("graphql-yoga");
|
|
145
142
|
|
|
146
143
|
// src/lib/integrations/shared.ts
|
|
147
144
|
var import_type_graphql27 = require("type-graphql");
|
|
148
145
|
|
|
149
146
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
150
147
|
var import_type_graphql21 = require("type-graphql");
|
|
151
|
-
var
|
|
148
|
+
var import_rxjs3 = require("rxjs");
|
|
152
149
|
|
|
153
150
|
// src/graphql/inputs/generate-copilot-response.input.ts
|
|
154
151
|
var import_type_graphql19 = require("type-graphql");
|
|
@@ -160,11 +157,11 @@ var import_type_graphql3 = require("type-graphql");
|
|
|
160
157
|
var import_type_graphql = require("type-graphql");
|
|
161
158
|
var MessageRole;
|
|
162
159
|
(function(MessageRole2) {
|
|
160
|
+
MessageRole2["user"] = "user";
|
|
163
161
|
MessageRole2["assistant"] = "assistant";
|
|
164
|
-
MessageRole2["developer"] = "developer";
|
|
165
162
|
MessageRole2["system"] = "system";
|
|
166
163
|
MessageRole2["tool"] = "tool";
|
|
167
|
-
MessageRole2["
|
|
164
|
+
MessageRole2["developer"] = "developer";
|
|
168
165
|
})(MessageRole || (MessageRole = {}));
|
|
169
166
|
var CopilotRequestType;
|
|
170
167
|
(function(CopilotRequestType2) {
|
|
@@ -871,10 +868,9 @@ var MessageStatusCode;
|
|
|
871
868
|
(0, import_type_graphql12.registerEnumType)(MessageStatusCode, {
|
|
872
869
|
name: "MessageStatusCode"
|
|
873
870
|
});
|
|
874
|
-
var BaseMessageStatus = class {
|
|
871
|
+
var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
|
|
875
872
|
code;
|
|
876
|
-
};
|
|
877
|
-
__name(BaseMessageStatus, "BaseMessageStatus");
|
|
873
|
+
}, "BaseMessageStatus");
|
|
878
874
|
_ts_decorate11([
|
|
879
875
|
(0, import_type_graphql12.Field)(() => MessageStatusCode),
|
|
880
876
|
_ts_metadata11("design:type", String)
|
|
@@ -1681,24 +1677,13 @@ GenerateCopilotResponseInput = _ts_decorate18([
|
|
|
1681
1677
|
var import_graphql_yoga = require("graphql-yoga");
|
|
1682
1678
|
|
|
1683
1679
|
// src/service-adapters/events.ts
|
|
1684
|
-
var
|
|
1685
|
-
var
|
|
1680
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
1681
|
+
var import_class_transformer = require("class-transformer");
|
|
1682
|
+
var import_rxjs2 = require("rxjs");
|
|
1686
1683
|
|
|
1687
1684
|
// src/graphql/types/converted/index.ts
|
|
1688
|
-
var
|
|
1689
|
-
var Message = class {
|
|
1685
|
+
var Message = class extends BaseMessageInput {
|
|
1690
1686
|
type;
|
|
1691
|
-
id;
|
|
1692
|
-
createdAt;
|
|
1693
|
-
status;
|
|
1694
|
-
constructor(props) {
|
|
1695
|
-
props.id ?? (props.id = (0, import_shared.randomId)());
|
|
1696
|
-
props.status ?? (props.status = {
|
|
1697
|
-
code: MessageStatusCode.Success
|
|
1698
|
-
});
|
|
1699
|
-
props.createdAt ?? (props.createdAt = /* @__PURE__ */ new Date());
|
|
1700
|
-
Object.assign(this, props);
|
|
1701
|
-
}
|
|
1702
1687
|
isTextMessage() {
|
|
1703
1688
|
return this.type === "TextMessage";
|
|
1704
1689
|
}
|
|
@@ -1717,14 +1702,10 @@ var Message = class {
|
|
|
1717
1702
|
};
|
|
1718
1703
|
__name(Message, "Message");
|
|
1719
1704
|
var TextMessage = class extends Message {
|
|
1705
|
+
type = "TextMessage";
|
|
1720
1706
|
content;
|
|
1721
|
-
parentMessageId;
|
|
1722
1707
|
role;
|
|
1723
|
-
|
|
1724
|
-
constructor(props) {
|
|
1725
|
-
super(props);
|
|
1726
|
-
this.type = "TextMessage";
|
|
1727
|
-
}
|
|
1708
|
+
parentMessageId;
|
|
1728
1709
|
};
|
|
1729
1710
|
__name(TextMessage, "TextMessage");
|
|
1730
1711
|
var ActionExecutionMessage = class extends Message {
|
|
@@ -1817,80 +1798,17 @@ var AgentStateMessage = class extends Message {
|
|
|
1817
1798
|
};
|
|
1818
1799
|
__name(AgentStateMessage, "AgentStateMessage");
|
|
1819
1800
|
|
|
1820
|
-
// src/
|
|
1821
|
-
var
|
|
1822
|
-
(function(RuntimeEventTypes2) {
|
|
1823
|
-
RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
|
|
1824
|
-
RuntimeEventTypes2["TextMessageContent"] = "TextMessageContent";
|
|
1825
|
-
RuntimeEventTypes2["TextMessageEnd"] = "TextMessageEnd";
|
|
1826
|
-
RuntimeEventTypes2["ActionExecutionStart"] = "ActionExecutionStart";
|
|
1827
|
-
RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
|
|
1828
|
-
RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
|
|
1829
|
-
RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
|
|
1830
|
-
RuntimeEventTypes2["AgentStateMessage"] = "AgentStateMessage";
|
|
1831
|
-
RuntimeEventTypes2["MetaEvent"] = "MetaEvent";
|
|
1832
|
-
RuntimeEventTypes2["RunError"] = "RunError";
|
|
1833
|
-
})(RuntimeEventTypes || (RuntimeEventTypes = {}));
|
|
1834
|
-
var RuntimeMetaEventName;
|
|
1835
|
-
(function(RuntimeMetaEventName2) {
|
|
1836
|
-
RuntimeMetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
|
|
1837
|
-
RuntimeMetaEventName2["LangGraphInterruptResumeEvent"] = "LangGraphInterruptResumeEvent";
|
|
1838
|
-
RuntimeMetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
|
|
1839
|
-
})(RuntimeMetaEventName || (RuntimeMetaEventName = {}));
|
|
1840
|
-
|
|
1841
|
-
// src/graphql/resolvers/copilot.resolver.ts
|
|
1842
|
-
var import_graphql_scalars2 = require("graphql-scalars");
|
|
1843
|
-
var import_class_transformer = require("class-transformer");
|
|
1844
|
-
var import_graphql = require("graphql");
|
|
1845
|
-
|
|
1846
|
-
// src/utils/failed-response-status-reasons.ts
|
|
1847
|
-
var GuardrailsValidationFailureResponse = class extends FailedResponseStatus {
|
|
1848
|
-
reason = FailedResponseStatusReason.GUARDRAILS_VALIDATION_FAILED;
|
|
1849
|
-
constructor({ guardrailsReason }) {
|
|
1850
|
-
super();
|
|
1851
|
-
this.details = {
|
|
1852
|
-
guardrailsReason
|
|
1853
|
-
};
|
|
1854
|
-
}
|
|
1855
|
-
};
|
|
1856
|
-
__name(GuardrailsValidationFailureResponse, "GuardrailsValidationFailureResponse");
|
|
1857
|
-
var MessageStreamInterruptedResponse = class extends FailedResponseStatus {
|
|
1858
|
-
reason = FailedResponseStatusReason.MESSAGE_STREAM_INTERRUPTED;
|
|
1859
|
-
constructor({ messageId }) {
|
|
1860
|
-
super();
|
|
1861
|
-
this.details = {
|
|
1862
|
-
messageId,
|
|
1863
|
-
description: "Check the message for mode details"
|
|
1864
|
-
};
|
|
1865
|
-
}
|
|
1866
|
-
};
|
|
1867
|
-
__name(MessageStreamInterruptedResponse, "MessageStreamInterruptedResponse");
|
|
1868
|
-
var UnknownErrorResponse = class extends FailedResponseStatus {
|
|
1869
|
-
reason = FailedResponseStatusReason.UNKNOWN_ERROR;
|
|
1870
|
-
constructor({ description, originalError }) {
|
|
1871
|
-
super();
|
|
1872
|
-
this.details = {
|
|
1873
|
-
description,
|
|
1874
|
-
originalError
|
|
1875
|
-
};
|
|
1876
|
-
}
|
|
1877
|
-
};
|
|
1878
|
-
__name(UnknownErrorResponse, "UnknownErrorResponse");
|
|
1801
|
+
// src/lib/runtime/remote-actions.ts
|
|
1802
|
+
var import_shared3 = require("@copilotkit/shared");
|
|
1879
1803
|
|
|
1880
1804
|
// src/lib/telemetry-client.ts
|
|
1881
|
-
var
|
|
1805
|
+
var import_shared2 = require("@copilotkit/shared");
|
|
1882
1806
|
var import_node_crypto = require("crypto");
|
|
1883
1807
|
|
|
1884
1808
|
// src/lib/runtime/copilot-runtime.ts
|
|
1885
|
-
var
|
|
1886
|
-
var
|
|
1887
|
-
|
|
1888
|
-
// src/lib/runtime/types.ts
|
|
1889
|
-
var EndpointType;
|
|
1890
|
-
(function(EndpointType2) {
|
|
1891
|
-
EndpointType2["CopilotKit"] = "copilotKit";
|
|
1892
|
-
EndpointType2["LangGraphPlatform"] = "langgraph-platform";
|
|
1893
|
-
})(EndpointType || (EndpointType = {}));
|
|
1809
|
+
var import_shared = require("@copilotkit/shared");
|
|
1810
|
+
var import_rxjs = require("rxjs");
|
|
1811
|
+
var import_langgraph_sdk = require("@langchain/langgraph-sdk");
|
|
1894
1812
|
|
|
1895
1813
|
// src/agents/langgraph/events.ts
|
|
1896
1814
|
var LangGraphEventTypes;
|
|
@@ -1925,7 +1843,6 @@ var CustomEventNames;
|
|
|
1925
1843
|
})(CustomEventNames || (CustomEventNames = {}));
|
|
1926
1844
|
|
|
1927
1845
|
// src/lib/runtime/copilot-runtime.ts
|
|
1928
|
-
var import_agent = require("@copilotkitnext/agent");
|
|
1929
1846
|
function resolveEndpointType(endpoint) {
|
|
1930
1847
|
if (!endpoint.type) {
|
|
1931
1848
|
if ("deploymentUrl" in endpoint && "agents" in endpoint) {
|
|
@@ -1940,15 +1857,14 @@ __name(resolveEndpointType, "resolveEndpointType");
|
|
|
1940
1857
|
|
|
1941
1858
|
// src/lib/telemetry-client.ts
|
|
1942
1859
|
var packageJson = require_package();
|
|
1943
|
-
var telemetryClient = new
|
|
1860
|
+
var telemetryClient = new import_shared2.TelemetryClient({
|
|
1944
1861
|
packageName: packageJson.name,
|
|
1945
1862
|
packageVersion: packageJson.version
|
|
1946
1863
|
});
|
|
1947
1864
|
function getRuntimeInstanceTelemetryInfo(options) {
|
|
1948
|
-
var _a, _b
|
|
1865
|
+
var _a, _b;
|
|
1949
1866
|
const runtime = options.runtime;
|
|
1950
|
-
const
|
|
1951
|
-
const endpointsInfo = remoteEndpoints.reduce((acc, endpoint) => {
|
|
1867
|
+
const endpointsInfo = runtime.remoteEndpointDefinitions.reduce((acc, endpoint) => {
|
|
1952
1868
|
let info = {
|
|
1953
1869
|
...acc
|
|
1954
1870
|
};
|
|
@@ -1976,19 +1892,19 @@ function getRuntimeInstanceTelemetryInfo(options) {
|
|
|
1976
1892
|
agentsAmount: null,
|
|
1977
1893
|
hashedKey: null
|
|
1978
1894
|
});
|
|
1979
|
-
const publicApiKey = (
|
|
1895
|
+
const publicApiKey = (_a = options.cloud) == null ? void 0 : _a.publicApiKey;
|
|
1980
1896
|
const apiKeyProvided = !!publicApiKey && publicApiKey.trim().length > 0;
|
|
1981
1897
|
return {
|
|
1982
|
-
actionsAmount:
|
|
1983
|
-
endpointsAmount:
|
|
1898
|
+
actionsAmount: runtime.actions.length,
|
|
1899
|
+
endpointsAmount: runtime.remoteEndpointDefinitions.length,
|
|
1984
1900
|
endpointTypes: endpointsInfo.endpointTypes,
|
|
1985
|
-
agentsAmount:
|
|
1901
|
+
agentsAmount: endpointsInfo.agentsAmount,
|
|
1986
1902
|
hashedLgcKey: endpointsInfo.hashedKey,
|
|
1987
1903
|
"cloud.api_key_provided": apiKeyProvided,
|
|
1988
1904
|
...apiKeyProvided ? {
|
|
1989
1905
|
"cloud.public_api_key": publicApiKey
|
|
1990
1906
|
} : {},
|
|
1991
|
-
...((
|
|
1907
|
+
...((_b = options.cloud) == null ? void 0 : _b.baseUrl) ? {
|
|
1992
1908
|
"cloud.base_url": options.cloud.baseUrl
|
|
1993
1909
|
} : {}
|
|
1994
1910
|
};
|
|
@@ -1996,8 +1912,76 @@ function getRuntimeInstanceTelemetryInfo(options) {
|
|
|
1996
1912
|
__name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
|
|
1997
1913
|
var telemetry_client_default = telemetryClient;
|
|
1998
1914
|
|
|
1915
|
+
// src/lib/runtime/remote-actions.ts
|
|
1916
|
+
var import_shared4 = require("@copilotkit/shared");
|
|
1917
|
+
var EndpointType;
|
|
1918
|
+
(function(EndpointType2) {
|
|
1919
|
+
EndpointType2["CopilotKit"] = "copilotKit";
|
|
1920
|
+
EndpointType2["LangGraphPlatform"] = "langgraph-platform";
|
|
1921
|
+
})(EndpointType || (EndpointType = {}));
|
|
1922
|
+
|
|
1923
|
+
// src/service-adapters/events.ts
|
|
1924
|
+
var RuntimeEventTypes;
|
|
1925
|
+
(function(RuntimeEventTypes2) {
|
|
1926
|
+
RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
|
|
1927
|
+
RuntimeEventTypes2["TextMessageContent"] = "TextMessageContent";
|
|
1928
|
+
RuntimeEventTypes2["TextMessageEnd"] = "TextMessageEnd";
|
|
1929
|
+
RuntimeEventTypes2["ActionExecutionStart"] = "ActionExecutionStart";
|
|
1930
|
+
RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
|
|
1931
|
+
RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
|
|
1932
|
+
RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
|
|
1933
|
+
RuntimeEventTypes2["AgentStateMessage"] = "AgentStateMessage";
|
|
1934
|
+
RuntimeEventTypes2["MetaEvent"] = "MetaEvent";
|
|
1935
|
+
RuntimeEventTypes2["RunError"] = "RunError";
|
|
1936
|
+
})(RuntimeEventTypes || (RuntimeEventTypes = {}));
|
|
1937
|
+
var RuntimeMetaEventName;
|
|
1938
|
+
(function(RuntimeMetaEventName2) {
|
|
1939
|
+
RuntimeMetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
|
|
1940
|
+
RuntimeMetaEventName2["LangGraphInterruptResumeEvent"] = "LangGraphInterruptResumeEvent";
|
|
1941
|
+
RuntimeMetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
|
|
1942
|
+
})(RuntimeMetaEventName || (RuntimeMetaEventName = {}));
|
|
1943
|
+
|
|
1999
1944
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
2000
|
-
var
|
|
1945
|
+
var import_graphql_scalars2 = require("graphql-scalars");
|
|
1946
|
+
var import_class_transformer2 = require("class-transformer");
|
|
1947
|
+
var import_graphql = require("graphql");
|
|
1948
|
+
|
|
1949
|
+
// src/utils/failed-response-status-reasons.ts
|
|
1950
|
+
var GuardrailsValidationFailureResponse = class extends FailedResponseStatus {
|
|
1951
|
+
reason = FailedResponseStatusReason.GUARDRAILS_VALIDATION_FAILED;
|
|
1952
|
+
constructor({ guardrailsReason }) {
|
|
1953
|
+
super();
|
|
1954
|
+
this.details = {
|
|
1955
|
+
guardrailsReason
|
|
1956
|
+
};
|
|
1957
|
+
}
|
|
1958
|
+
};
|
|
1959
|
+
__name(GuardrailsValidationFailureResponse, "GuardrailsValidationFailureResponse");
|
|
1960
|
+
var MessageStreamInterruptedResponse = class extends FailedResponseStatus {
|
|
1961
|
+
reason = FailedResponseStatusReason.MESSAGE_STREAM_INTERRUPTED;
|
|
1962
|
+
constructor({ messageId }) {
|
|
1963
|
+
super();
|
|
1964
|
+
this.details = {
|
|
1965
|
+
messageId,
|
|
1966
|
+
description: "Check the message for mode details"
|
|
1967
|
+
};
|
|
1968
|
+
}
|
|
1969
|
+
};
|
|
1970
|
+
__name(MessageStreamInterruptedResponse, "MessageStreamInterruptedResponse");
|
|
1971
|
+
var UnknownErrorResponse = class extends FailedResponseStatus {
|
|
1972
|
+
reason = FailedResponseStatusReason.UNKNOWN_ERROR;
|
|
1973
|
+
constructor({ description, originalError }) {
|
|
1974
|
+
super();
|
|
1975
|
+
this.details = {
|
|
1976
|
+
description,
|
|
1977
|
+
originalError
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
};
|
|
1981
|
+
__name(UnknownErrorResponse, "UnknownErrorResponse");
|
|
1982
|
+
|
|
1983
|
+
// src/graphql/resolvers/copilot.resolver.ts
|
|
1984
|
+
var import_shared6 = require("@copilotkit/shared");
|
|
2001
1985
|
|
|
2002
1986
|
// src/graphql/types/agents-response.type.ts
|
|
2003
1987
|
var import_type_graphql20 = require("type-graphql");
|
|
@@ -2053,7 +2037,7 @@ AgentsResponse = _ts_decorate19([
|
|
|
2053
2037
|
], AgentsResponse);
|
|
2054
2038
|
|
|
2055
2039
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
2056
|
-
var
|
|
2040
|
+
var import_shared7 = require("@copilotkit/shared");
|
|
2057
2041
|
function _ts_decorate20(decorators, target, key, desc) {
|
|
2058
2042
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2059
2043
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -2116,14 +2100,14 @@ var CopilotResolver = class {
|
|
|
2116
2100
|
component: "CopilotResolver.availableAgents"
|
|
2117
2101
|
});
|
|
2118
2102
|
logger2.debug("Processing");
|
|
2119
|
-
const agentsWithEndpoints =
|
|
2103
|
+
const agentsWithEndpoints = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
|
|
2120
2104
|
logger2.debug("Event source created, creating response");
|
|
2121
2105
|
return {
|
|
2122
2106
|
agents: agentsWithEndpoints.map(({ endpoint, ...agentWithoutEndpoint }) => agentWithoutEndpoint)
|
|
2123
2107
|
};
|
|
2124
2108
|
}
|
|
2125
2109
|
async generateCopilotResponse(ctx, data, properties) {
|
|
2126
|
-
var _a, _b, _c, _d;
|
|
2110
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2127
2111
|
telemetry_client_default.capture("oss.runtime.copilot_request_created", {
|
|
2128
2112
|
"cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
|
|
2129
2113
|
requestType: data.metadata.requestType,
|
|
@@ -2165,12 +2149,21 @@ var CopilotResolver = class {
|
|
|
2165
2149
|
logger2.debug("Cloud configuration provided, checking for public API key in headers");
|
|
2166
2150
|
if (!copilotCloudPublicApiKey) {
|
|
2167
2151
|
logger2.error("Public API key not found in headers");
|
|
2152
|
+
await copilotRuntime.errorGraphQLError({
|
|
2153
|
+
message: "X-CopilotCloud-Public-API-Key header is required",
|
|
2154
|
+
code: "MISSING_PUBLIC_API_KEY",
|
|
2155
|
+
type: "GraphQLError"
|
|
2156
|
+
}, {
|
|
2157
|
+
operation: "generateCopilotResponse",
|
|
2158
|
+
cloudConfigPresent: Boolean(data.cloud),
|
|
2159
|
+
guardrailsEnabled: Boolean((_b = data.cloud) == null ? void 0 : _b.guardrails)
|
|
2160
|
+
});
|
|
2168
2161
|
throw new import_graphql.GraphQLError("X-CopilotCloud-Public-API-Key header is required");
|
|
2169
2162
|
}
|
|
2170
2163
|
if (process.env.COPILOT_CLOUD_BASE_URL) {
|
|
2171
2164
|
copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
|
|
2172
|
-
} else if ((
|
|
2173
|
-
copilotCloudBaseUrl = (
|
|
2165
|
+
} else if ((_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl) {
|
|
2166
|
+
copilotCloudBaseUrl = (_d = ctx._copilotkit.cloud) == null ? void 0 : _d.baseUrl;
|
|
2174
2167
|
} else {
|
|
2175
2168
|
copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
|
|
2176
2169
|
}
|
|
@@ -2179,9 +2172,9 @@ var CopilotResolver = class {
|
|
|
2179
2172
|
});
|
|
2180
2173
|
}
|
|
2181
2174
|
logger2.debug("Setting up subjects");
|
|
2182
|
-
const responseStatus$ = new
|
|
2183
|
-
const interruptStreaming$ = new
|
|
2184
|
-
const guardrailsResult$ = new
|
|
2175
|
+
const responseStatus$ = new import_rxjs3.ReplaySubject();
|
|
2176
|
+
const interruptStreaming$ = new import_rxjs3.ReplaySubject();
|
|
2177
|
+
const guardrailsResult$ = new import_rxjs3.ReplaySubject();
|
|
2185
2178
|
let outputMessages = [];
|
|
2186
2179
|
let resolveOutputMessagesPromise;
|
|
2187
2180
|
let rejectOutputMessagesPromise;
|
|
@@ -2194,11 +2187,41 @@ var CopilotResolver = class {
|
|
|
2194
2187
|
}
|
|
2195
2188
|
logger2.debug("Processing");
|
|
2196
2189
|
let runtimeResponse;
|
|
2197
|
-
|
|
2190
|
+
try {
|
|
2191
|
+
runtimeResponse = await copilotRuntime.processRuntimeRequest({
|
|
2192
|
+
serviceAdapter,
|
|
2193
|
+
messages: data.messages,
|
|
2194
|
+
actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
|
|
2195
|
+
threadId: data.threadId,
|
|
2196
|
+
runId: data.runId,
|
|
2197
|
+
publicApiKey: copilotCloudPublicApiKey,
|
|
2198
|
+
outputMessagesPromise,
|
|
2199
|
+
graphqlContext: ctx,
|
|
2200
|
+
forwardedParameters: data.forwardedParameters,
|
|
2201
|
+
agentSession: data.agentSession,
|
|
2202
|
+
agentStates: data.agentStates,
|
|
2203
|
+
url: data.frontend.url,
|
|
2204
|
+
extensions: data.extensions,
|
|
2205
|
+
metaEvents: data.metaEvents,
|
|
2206
|
+
context: data.context
|
|
2207
|
+
});
|
|
2208
|
+
} catch (error) {
|
|
2209
|
+
if ((0, import_shared7.isStructuredCopilotKitError)(error) || ((_e = error == null ? void 0 : error.extensions) == null ? void 0 : _e.visibility)) {
|
|
2210
|
+
throw new import_graphql.GraphQLError(error.message || "Agent error occurred", {
|
|
2211
|
+
extensions: {
|
|
2212
|
+
...error.extensions,
|
|
2213
|
+
code: error.code || ((_f = error.extensions) == null ? void 0 : _f.code) || "AGENT_ERROR",
|
|
2214
|
+
originalError: error
|
|
2215
|
+
}
|
|
2216
|
+
});
|
|
2217
|
+
}
|
|
2218
|
+
throw error;
|
|
2219
|
+
}
|
|
2220
|
+
const { eventSource, threadId = (0, import_shared6.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = runtimeResponse;
|
|
2198
2221
|
logger2.debug("Event source created, creating response");
|
|
2199
2222
|
const eventStream = eventSource.processRuntimeEvents({
|
|
2200
2223
|
serverSideActions,
|
|
2201
|
-
guardrailsResult$: ((
|
|
2224
|
+
guardrailsResult$: ((_g = data.cloud) == null ? void 0 : _g.guardrails) ? guardrailsResult$ : null,
|
|
2202
2225
|
actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
|
|
2203
2226
|
// TODO-AGENTS: do not exclude ALL server side actions
|
|
2204
2227
|
(action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
|
|
@@ -2207,15 +2230,15 @@ var CopilotResolver = class {
|
|
|
2207
2230
|
}).pipe(
|
|
2208
2231
|
// shareReplay() ensures that later subscribers will see the whole stream instead of
|
|
2209
2232
|
// just the events that were emitted after the subscriber was added.
|
|
2210
|
-
(0,
|
|
2211
|
-
(0,
|
|
2233
|
+
(0, import_rxjs3.shareReplay)(),
|
|
2234
|
+
(0, import_rxjs3.finalize)(() => {
|
|
2212
2235
|
logger2.debug("Event stream finalized");
|
|
2213
2236
|
})
|
|
2214
2237
|
);
|
|
2215
2238
|
const response = {
|
|
2216
2239
|
threadId,
|
|
2217
2240
|
runId,
|
|
2218
|
-
status: (0,
|
|
2241
|
+
status: (0, import_rxjs3.firstValueFrom)(responseStatus$),
|
|
2219
2242
|
extensions,
|
|
2220
2243
|
metaEvents: new import_graphql_yoga.Repeater(async (push, stop) => {
|
|
2221
2244
|
let eventStreamSubscription;
|
|
@@ -2226,7 +2249,7 @@ var CopilotResolver = class {
|
|
|
2226
2249
|
}
|
|
2227
2250
|
switch (event.name) {
|
|
2228
2251
|
case LangGraphEventTypes.OnInterrupt:
|
|
2229
|
-
push((0,
|
|
2252
|
+
push((0, import_class_transformer2.plainToInstance)(LangGraphInterruptEvent, {
|
|
2230
2253
|
// @ts-ignore
|
|
2231
2254
|
type: event.type,
|
|
2232
2255
|
// @ts-ignore
|
|
@@ -2236,21 +2259,21 @@ var CopilotResolver = class {
|
|
|
2236
2259
|
}));
|
|
2237
2260
|
break;
|
|
2238
2261
|
case RuntimeMetaEventName.LangGraphInterruptEvent:
|
|
2239
|
-
push((0,
|
|
2262
|
+
push((0, import_class_transformer2.plainToInstance)(LangGraphInterruptEvent, {
|
|
2240
2263
|
type: event.type,
|
|
2241
2264
|
name: event.name,
|
|
2242
2265
|
value: event.value
|
|
2243
2266
|
}));
|
|
2244
2267
|
break;
|
|
2245
2268
|
case RuntimeMetaEventName.CopilotKitLangGraphInterruptEvent:
|
|
2246
|
-
push((0,
|
|
2269
|
+
push((0, import_class_transformer2.plainToInstance)(CopilotKitLangGraphInterruptEvent, {
|
|
2247
2270
|
type: event.type,
|
|
2248
2271
|
name: event.name,
|
|
2249
2272
|
data: {
|
|
2250
2273
|
value: event.data.value,
|
|
2251
2274
|
messages: event.data.messages.map((message) => {
|
|
2252
2275
|
if (message.type === "TextMessage" || "content" in message && "role" in message) {
|
|
2253
|
-
return (0,
|
|
2276
|
+
return (0, import_class_transformer2.plainToInstance)(TextMessage, {
|
|
2254
2277
|
id: message.id,
|
|
2255
2278
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2256
2279
|
content: [
|
|
@@ -2261,7 +2284,7 @@ var CopilotResolver = class {
|
|
|
2261
2284
|
});
|
|
2262
2285
|
}
|
|
2263
2286
|
if ("arguments" in message) {
|
|
2264
|
-
return (0,
|
|
2287
|
+
return (0, import_class_transformer2.plainToInstance)(ActionExecutionMessage, {
|
|
2265
2288
|
name: message.name,
|
|
2266
2289
|
id: message.id,
|
|
2267
2290
|
arguments: [
|
|
@@ -2325,8 +2348,8 @@ var CopilotResolver = class {
|
|
|
2325
2348
|
reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
|
|
2326
2349
|
});
|
|
2327
2350
|
outputMessages = [
|
|
2328
|
-
(0,
|
|
2329
|
-
id: (0,
|
|
2351
|
+
(0, import_class_transformer2.plainToInstance)(TextMessage, {
|
|
2352
|
+
id: (0, import_shared6.randomId)(),
|
|
2330
2353
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2331
2354
|
content: result.reason,
|
|
2332
2355
|
role: MessageRole.assistant
|
|
@@ -2359,30 +2382,30 @@ var CopilotResolver = class {
|
|
|
2359
2382
|
case RuntimeEventTypes.TextMessageStart:
|
|
2360
2383
|
const textMessageContentStream = eventStream.pipe(
|
|
2361
2384
|
// skip until this message start event
|
|
2362
|
-
(0,
|
|
2385
|
+
(0, import_rxjs3.skipWhile)((e) => e !== event),
|
|
2363
2386
|
// take until the message end event
|
|
2364
|
-
(0,
|
|
2387
|
+
(0, import_rxjs3.takeWhile)((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
|
|
2365
2388
|
// filter out any other message events or message ids
|
|
2366
|
-
(0,
|
|
2389
|
+
(0, import_rxjs3.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
|
|
2367
2390
|
);
|
|
2368
|
-
const streamingTextStatus = new
|
|
2391
|
+
const streamingTextStatus = new import_rxjs3.Subject();
|
|
2369
2392
|
const messageId = event.messageId;
|
|
2370
2393
|
pushMessage({
|
|
2371
2394
|
id: messageId,
|
|
2372
2395
|
parentMessageId: event.parentMessageId,
|
|
2373
|
-
status: (0,
|
|
2396
|
+
status: (0, import_rxjs3.firstValueFrom)(streamingTextStatus),
|
|
2374
2397
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2375
2398
|
role: MessageRole.assistant,
|
|
2376
2399
|
content: new import_graphql_yoga.Repeater(async (pushTextChunk, stopStreamingText) => {
|
|
2377
2400
|
logger2.debug("Text message content repeater created");
|
|
2378
2401
|
const textChunks = [];
|
|
2379
2402
|
let textSubscription;
|
|
2380
|
-
interruptStreaming$.pipe((0,
|
|
2403
|
+
interruptStreaming$.pipe((0, import_rxjs3.shareReplay)(), (0, import_rxjs3.take)(1), (0, import_rxjs3.tap)(({ reason, messageId: messageId2 }) => {
|
|
2381
2404
|
logger2.debug({
|
|
2382
2405
|
reason,
|
|
2383
2406
|
messageId: messageId2
|
|
2384
2407
|
}, "Text streaming interrupted");
|
|
2385
|
-
streamingTextStatus.next((0,
|
|
2408
|
+
streamingTextStatus.next((0, import_class_transformer2.plainToInstance)(FailedMessageStatus, {
|
|
2386
2409
|
reason
|
|
2387
2410
|
}));
|
|
2388
2411
|
responseStatus$.next(new MessageStreamInterruptedResponse({
|
|
@@ -2415,7 +2438,7 @@ var CopilotResolver = class {
|
|
|
2415
2438
|
streamingTextStatus.next(new SuccessMessageStatus());
|
|
2416
2439
|
stopStreamingText();
|
|
2417
2440
|
textSubscription == null ? void 0 : textSubscription.unsubscribe();
|
|
2418
|
-
outputMessages.push((0,
|
|
2441
|
+
outputMessages.push((0, import_class_transformer2.plainToInstance)(TextMessage, {
|
|
2419
2442
|
id: messageId,
|
|
2420
2443
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2421
2444
|
content: textChunks.join(""),
|
|
@@ -2429,17 +2452,17 @@ var CopilotResolver = class {
|
|
|
2429
2452
|
case RuntimeEventTypes.ActionExecutionStart:
|
|
2430
2453
|
logger2.debug("Action execution start event received");
|
|
2431
2454
|
const actionExecutionArgumentStream = eventStream.pipe(
|
|
2432
|
-
(0,
|
|
2455
|
+
(0, import_rxjs3.skipWhile)((e) => e !== event),
|
|
2433
2456
|
// take until the action execution end event
|
|
2434
|
-
(0,
|
|
2457
|
+
(0, import_rxjs3.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
|
|
2435
2458
|
// filter out any other action execution events or action execution ids
|
|
2436
|
-
(0,
|
|
2459
|
+
(0, import_rxjs3.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
|
|
2437
2460
|
);
|
|
2438
|
-
const streamingArgumentsStatus = new
|
|
2461
|
+
const streamingArgumentsStatus = new import_rxjs3.Subject();
|
|
2439
2462
|
pushMessage({
|
|
2440
2463
|
id: event.actionExecutionId,
|
|
2441
2464
|
parentMessageId: event.parentMessageId,
|
|
2442
|
-
status: (0,
|
|
2465
|
+
status: (0, import_rxjs3.firstValueFrom)(streamingArgumentsStatus),
|
|
2443
2466
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2444
2467
|
name: event.actionName,
|
|
2445
2468
|
arguments: new import_graphql_yoga.Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
|
|
@@ -2457,7 +2480,7 @@ var CopilotResolver = class {
|
|
|
2457
2480
|
logger2.error({
|
|
2458
2481
|
err
|
|
2459
2482
|
}, "Error in action execution argument stream");
|
|
2460
|
-
streamingArgumentsStatus.next((0,
|
|
2483
|
+
streamingArgumentsStatus.next((0, import_class_transformer2.plainToInstance)(FailedMessageStatus, {
|
|
2461
2484
|
reason: "An unknown error has occurred in the action execution argument stream"
|
|
2462
2485
|
}));
|
|
2463
2486
|
stopStreamingArguments();
|
|
@@ -2468,7 +2491,7 @@ var CopilotResolver = class {
|
|
|
2468
2491
|
streamingArgumentsStatus.next(new SuccessMessageStatus());
|
|
2469
2492
|
stopStreamingArguments();
|
|
2470
2493
|
actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
|
|
2471
|
-
outputMessages.push((0,
|
|
2494
|
+
outputMessages.push((0, import_class_transformer2.plainToInstance)(ActionExecutionMessage, {
|
|
2472
2495
|
id: event.actionExecutionId,
|
|
2473
2496
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2474
2497
|
name: event.actionName,
|
|
@@ -2491,7 +2514,7 @@ var CopilotResolver = class {
|
|
|
2491
2514
|
actionName: event.actionName,
|
|
2492
2515
|
result: event.result
|
|
2493
2516
|
});
|
|
2494
|
-
outputMessages.push((0,
|
|
2517
|
+
outputMessages.push((0, import_class_transformer2.plainToInstance)(ResultMessage, {
|
|
2495
2518
|
id: "result-" + event.actionExecutionId,
|
|
2496
2519
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2497
2520
|
actionExecutionId: event.actionExecutionId,
|
|
@@ -2504,7 +2527,7 @@ var CopilotResolver = class {
|
|
|
2504
2527
|
event
|
|
2505
2528
|
}, "Agent message event received");
|
|
2506
2529
|
pushMessage({
|
|
2507
|
-
id: (0,
|
|
2530
|
+
id: (0, import_shared6.randomId)(),
|
|
2508
2531
|
status: new SuccessMessageStatus(),
|
|
2509
2532
|
threadId: event.threadId,
|
|
2510
2533
|
agentName: event.agentName,
|
|
@@ -2516,8 +2539,8 @@ var CopilotResolver = class {
|
|
|
2516
2539
|
role: MessageRole.assistant,
|
|
2517
2540
|
createdAt: /* @__PURE__ */ new Date()
|
|
2518
2541
|
});
|
|
2519
|
-
outputMessages.push((0,
|
|
2520
|
-
id: (0,
|
|
2542
|
+
outputMessages.push((0, import_class_transformer2.plainToInstance)(AgentStateMessage, {
|
|
2543
|
+
id: (0, import_shared6.randomId)(),
|
|
2521
2544
|
threadId: event.threadId,
|
|
2522
2545
|
agentName: event.agentName,
|
|
2523
2546
|
nodeName: event.nodeName,
|
|
@@ -2532,8 +2555,8 @@ var CopilotResolver = class {
|
|
|
2532
2555
|
}
|
|
2533
2556
|
},
|
|
2534
2557
|
error: (err) => {
|
|
2535
|
-
var _a3, _b2, _c2, _d2,
|
|
2536
|
-
if (err instanceof
|
|
2558
|
+
var _a3, _b2, _c2, _d2, _e2, _f2;
|
|
2559
|
+
if (err instanceof import_shared7.CopilotKitError || err instanceof import_shared7.CopilotKitLowLevelError || err instanceof Error && err.name && err.name.includes("CopilotKit") || ((_a3 = err == null ? void 0 : err.extensions) == null ? void 0 : _a3.visibility)) {
|
|
2537
2560
|
responseStatus$.next(new UnknownErrorResponse({
|
|
2538
2561
|
description: err.message || "Agent error occurred",
|
|
2539
2562
|
// Include original error information for frontend to extract
|
|
@@ -2541,8 +2564,8 @@ var CopilotResolver = class {
|
|
|
2541
2564
|
code: err.code || ((_b2 = err.extensions) == null ? void 0 : _b2.code),
|
|
2542
2565
|
statusCode: err.statusCode || ((_c2 = err.extensions) == null ? void 0 : _c2.statusCode),
|
|
2543
2566
|
severity: err.severity || ((_d2 = err.extensions) == null ? void 0 : _d2.severity),
|
|
2544
|
-
visibility: err.visibility || ((
|
|
2545
|
-
originalErrorType: err.originalErrorType || ((
|
|
2567
|
+
visibility: err.visibility || ((_e2 = err.extensions) == null ? void 0 : _e2.visibility),
|
|
2568
|
+
originalErrorType: err.originalErrorType || ((_f2 = err.extensions) == null ? void 0 : _f2.originalErrorType),
|
|
2546
2569
|
extensions: err.extensions
|
|
2547
2570
|
}
|
|
2548
2571
|
}));
|
|
@@ -2563,7 +2586,7 @@ var CopilotResolver = class {
|
|
|
2563
2586
|
logger2.debug("Event stream completed");
|
|
2564
2587
|
if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
|
|
2565
2588
|
logger2.debug("Guardrails is enabled, waiting for guardrails result");
|
|
2566
|
-
await (0,
|
|
2589
|
+
await (0, import_rxjs3.firstValueFrom)(guardrailsResult$);
|
|
2567
2590
|
}
|
|
2568
2591
|
responseStatus$.next(new SuccessResponseStatus());
|
|
2569
2592
|
eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
|
|
@@ -2728,7 +2751,7 @@ LoadAgentStateInput = _ts_decorate22([
|
|
|
2728
2751
|
], LoadAgentStateInput);
|
|
2729
2752
|
|
|
2730
2753
|
// src/graphql/resolvers/state.resolver.ts
|
|
2731
|
-
var
|
|
2754
|
+
var import_shared8 = require("@copilotkit/shared");
|
|
2732
2755
|
function _ts_decorate23(decorators, target, key, desc) {
|
|
2733
2756
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2734
2757
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -2753,10 +2776,10 @@ function _ts_param2(paramIndex, decorator) {
|
|
|
2753
2776
|
__name(_ts_param2, "_ts_param");
|
|
2754
2777
|
var StateResolver = class {
|
|
2755
2778
|
async loadAgentState(ctx, data) {
|
|
2756
|
-
const agents =
|
|
2779
|
+
const agents = await ctx._copilotkit.runtime.getAllAgents(ctx);
|
|
2757
2780
|
const hasAgent = agents.some((agent) => agent.name === data.agentName);
|
|
2758
2781
|
if (!hasAgent) {
|
|
2759
|
-
throw new
|
|
2782
|
+
throw new import_shared8.CopilotKitAgentDiscoveryError({
|
|
2760
2783
|
agentName: data.agentName,
|
|
2761
2784
|
availableAgents: agents.map((a) => ({
|
|
2762
2785
|
name: a.name,
|
|
@@ -2764,7 +2787,7 @@ var StateResolver = class {
|
|
|
2764
2787
|
}))
|
|
2765
2788
|
});
|
|
2766
2789
|
}
|
|
2767
|
-
const state =
|
|
2790
|
+
const state = await ctx._copilotkit.runtime.loadAgentState(ctx, data.threadId, data.agentName);
|
|
2768
2791
|
return state;
|
|
2769
2792
|
}
|
|
2770
2793
|
};
|
|
@@ -2786,7 +2809,7 @@ StateResolver = _ts_decorate23([
|
|
|
2786
2809
|
|
|
2787
2810
|
// src/lib/integrations/shared.ts
|
|
2788
2811
|
var packageJson2 = __toESM(require_package());
|
|
2789
|
-
var
|
|
2812
|
+
var import_shared9 = require("@copilotkit/shared");
|
|
2790
2813
|
var logger = createLogger();
|
|
2791
2814
|
var addCustomHeaderPlugin = {
|
|
2792
2815
|
onResponse({ response }) {
|
|
@@ -2852,11 +2875,11 @@ function getCommonConfig(options) {
|
|
|
2852
2875
|
}
|
|
2853
2876
|
});
|
|
2854
2877
|
const userErrorCodes = [
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2878
|
+
import_shared9.CopilotKitErrorCode.AGENT_NOT_FOUND,
|
|
2879
|
+
import_shared9.CopilotKitErrorCode.API_NOT_FOUND,
|
|
2880
|
+
import_shared9.CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND,
|
|
2881
|
+
import_shared9.CopilotKitErrorCode.CONFIGURATION_ERROR,
|
|
2882
|
+
import_shared9.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR
|
|
2860
2883
|
];
|
|
2861
2884
|
return {
|
|
2862
2885
|
logging: createLogger({
|
|
@@ -2879,7 +2902,7 @@ function getCommonConfig(options) {
|
|
|
2879
2902
|
console.debug("User configuration error:", error.message);
|
|
2880
2903
|
return error;
|
|
2881
2904
|
}
|
|
2882
|
-
if (originalError instanceof
|
|
2905
|
+
if (originalError instanceof import_shared9.CopilotKitError && userErrorCodes.includes(originalError.code)) {
|
|
2883
2906
|
console.debug("User configuration error:", error.message);
|
|
2884
2907
|
return error;
|
|
2885
2908
|
}
|
|
@@ -2908,12 +2931,11 @@ function copilotRuntimeNodeHttpEndpoint(options) {
|
|
|
2908
2931
|
telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
|
|
2909
2932
|
const logger2 = commonConfig.logging;
|
|
2910
2933
|
logger2.debug("Creating Node HTTP endpoint");
|
|
2911
|
-
const
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
runtime: options.runtime.instance,
|
|
2915
|
-
basePath: options.baseUrl
|
|
2934
|
+
const yoga = (0, import_graphql_yoga2.createYoga)({
|
|
2935
|
+
...commonConfig,
|
|
2936
|
+
graphqlEndpoint: options.endpoint
|
|
2916
2937
|
});
|
|
2938
|
+
return yoga;
|
|
2917
2939
|
}
|
|
2918
2940
|
__name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
|
|
2919
2941
|
// Annotate the CommonJS export names for ESM import in node:
|