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