@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",
|
|
@@ -156,7 +153,7 @@ var import_type_graphql27 = require("type-graphql");
|
|
|
156
153
|
|
|
157
154
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
158
155
|
var import_type_graphql21 = require("type-graphql");
|
|
159
|
-
var
|
|
156
|
+
var import_rxjs3 = require("rxjs");
|
|
160
157
|
|
|
161
158
|
// src/graphql/inputs/generate-copilot-response.input.ts
|
|
162
159
|
var import_type_graphql19 = require("type-graphql");
|
|
@@ -168,11 +165,11 @@ var import_type_graphql3 = require("type-graphql");
|
|
|
168
165
|
var import_type_graphql = require("type-graphql");
|
|
169
166
|
var MessageRole;
|
|
170
167
|
(function(MessageRole2) {
|
|
168
|
+
MessageRole2["user"] = "user";
|
|
171
169
|
MessageRole2["assistant"] = "assistant";
|
|
172
|
-
MessageRole2["developer"] = "developer";
|
|
173
170
|
MessageRole2["system"] = "system";
|
|
174
171
|
MessageRole2["tool"] = "tool";
|
|
175
|
-
MessageRole2["
|
|
172
|
+
MessageRole2["developer"] = "developer";
|
|
176
173
|
})(MessageRole || (MessageRole = {}));
|
|
177
174
|
var CopilotRequestType;
|
|
178
175
|
(function(CopilotRequestType2) {
|
|
@@ -879,10 +876,9 @@ var MessageStatusCode;
|
|
|
879
876
|
(0, import_type_graphql12.registerEnumType)(MessageStatusCode, {
|
|
880
877
|
name: "MessageStatusCode"
|
|
881
878
|
});
|
|
882
|
-
var BaseMessageStatus = class {
|
|
879
|
+
var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
|
|
883
880
|
code;
|
|
884
|
-
};
|
|
885
|
-
__name(BaseMessageStatus, "BaseMessageStatus");
|
|
881
|
+
}, "BaseMessageStatus");
|
|
886
882
|
_ts_decorate11([
|
|
887
883
|
(0, import_type_graphql12.Field)(() => MessageStatusCode),
|
|
888
884
|
_ts_metadata11("design:type", String)
|
|
@@ -1689,24 +1685,13 @@ GenerateCopilotResponseInput = _ts_decorate18([
|
|
|
1689
1685
|
var import_graphql_yoga = require("graphql-yoga");
|
|
1690
1686
|
|
|
1691
1687
|
// src/service-adapters/events.ts
|
|
1692
|
-
var
|
|
1693
|
-
var
|
|
1688
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
1689
|
+
var import_class_transformer = require("class-transformer");
|
|
1690
|
+
var import_rxjs2 = require("rxjs");
|
|
1694
1691
|
|
|
1695
1692
|
// src/graphql/types/converted/index.ts
|
|
1696
|
-
var
|
|
1697
|
-
var Message = class {
|
|
1693
|
+
var Message = class extends BaseMessageInput {
|
|
1698
1694
|
type;
|
|
1699
|
-
id;
|
|
1700
|
-
createdAt;
|
|
1701
|
-
status;
|
|
1702
|
-
constructor(props) {
|
|
1703
|
-
props.id ?? (props.id = (0, import_shared.randomId)());
|
|
1704
|
-
props.status ?? (props.status = {
|
|
1705
|
-
code: MessageStatusCode.Success
|
|
1706
|
-
});
|
|
1707
|
-
props.createdAt ?? (props.createdAt = /* @__PURE__ */ new Date());
|
|
1708
|
-
Object.assign(this, props);
|
|
1709
|
-
}
|
|
1710
1695
|
isTextMessage() {
|
|
1711
1696
|
return this.type === "TextMessage";
|
|
1712
1697
|
}
|
|
@@ -1725,14 +1710,10 @@ var Message = class {
|
|
|
1725
1710
|
};
|
|
1726
1711
|
__name(Message, "Message");
|
|
1727
1712
|
var TextMessage = class extends Message {
|
|
1713
|
+
type = "TextMessage";
|
|
1728
1714
|
content;
|
|
1729
|
-
parentMessageId;
|
|
1730
1715
|
role;
|
|
1731
|
-
|
|
1732
|
-
constructor(props) {
|
|
1733
|
-
super(props);
|
|
1734
|
-
this.type = "TextMessage";
|
|
1735
|
-
}
|
|
1716
|
+
parentMessageId;
|
|
1736
1717
|
};
|
|
1737
1718
|
__name(TextMessage, "TextMessage");
|
|
1738
1719
|
var ActionExecutionMessage = class extends Message {
|
|
@@ -1825,80 +1806,17 @@ var AgentStateMessage = class extends Message {
|
|
|
1825
1806
|
};
|
|
1826
1807
|
__name(AgentStateMessage, "AgentStateMessage");
|
|
1827
1808
|
|
|
1828
|
-
// src/
|
|
1829
|
-
var
|
|
1830
|
-
(function(RuntimeEventTypes2) {
|
|
1831
|
-
RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
|
|
1832
|
-
RuntimeEventTypes2["TextMessageContent"] = "TextMessageContent";
|
|
1833
|
-
RuntimeEventTypes2["TextMessageEnd"] = "TextMessageEnd";
|
|
1834
|
-
RuntimeEventTypes2["ActionExecutionStart"] = "ActionExecutionStart";
|
|
1835
|
-
RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
|
|
1836
|
-
RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
|
|
1837
|
-
RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
|
|
1838
|
-
RuntimeEventTypes2["AgentStateMessage"] = "AgentStateMessage";
|
|
1839
|
-
RuntimeEventTypes2["MetaEvent"] = "MetaEvent";
|
|
1840
|
-
RuntimeEventTypes2["RunError"] = "RunError";
|
|
1841
|
-
})(RuntimeEventTypes || (RuntimeEventTypes = {}));
|
|
1842
|
-
var RuntimeMetaEventName;
|
|
1843
|
-
(function(RuntimeMetaEventName2) {
|
|
1844
|
-
RuntimeMetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
|
|
1845
|
-
RuntimeMetaEventName2["LangGraphInterruptResumeEvent"] = "LangGraphInterruptResumeEvent";
|
|
1846
|
-
RuntimeMetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
|
|
1847
|
-
})(RuntimeMetaEventName || (RuntimeMetaEventName = {}));
|
|
1848
|
-
|
|
1849
|
-
// src/graphql/resolvers/copilot.resolver.ts
|
|
1850
|
-
var import_graphql_scalars2 = require("graphql-scalars");
|
|
1851
|
-
var import_class_transformer = require("class-transformer");
|
|
1852
|
-
var import_graphql = require("graphql");
|
|
1853
|
-
|
|
1854
|
-
// src/utils/failed-response-status-reasons.ts
|
|
1855
|
-
var GuardrailsValidationFailureResponse = class extends FailedResponseStatus {
|
|
1856
|
-
reason = FailedResponseStatusReason.GUARDRAILS_VALIDATION_FAILED;
|
|
1857
|
-
constructor({ guardrailsReason }) {
|
|
1858
|
-
super();
|
|
1859
|
-
this.details = {
|
|
1860
|
-
guardrailsReason
|
|
1861
|
-
};
|
|
1862
|
-
}
|
|
1863
|
-
};
|
|
1864
|
-
__name(GuardrailsValidationFailureResponse, "GuardrailsValidationFailureResponse");
|
|
1865
|
-
var MessageStreamInterruptedResponse = class extends FailedResponseStatus {
|
|
1866
|
-
reason = FailedResponseStatusReason.MESSAGE_STREAM_INTERRUPTED;
|
|
1867
|
-
constructor({ messageId }) {
|
|
1868
|
-
super();
|
|
1869
|
-
this.details = {
|
|
1870
|
-
messageId,
|
|
1871
|
-
description: "Check the message for mode details"
|
|
1872
|
-
};
|
|
1873
|
-
}
|
|
1874
|
-
};
|
|
1875
|
-
__name(MessageStreamInterruptedResponse, "MessageStreamInterruptedResponse");
|
|
1876
|
-
var UnknownErrorResponse = class extends FailedResponseStatus {
|
|
1877
|
-
reason = FailedResponseStatusReason.UNKNOWN_ERROR;
|
|
1878
|
-
constructor({ description, originalError }) {
|
|
1879
|
-
super();
|
|
1880
|
-
this.details = {
|
|
1881
|
-
description,
|
|
1882
|
-
originalError
|
|
1883
|
-
};
|
|
1884
|
-
}
|
|
1885
|
-
};
|
|
1886
|
-
__name(UnknownErrorResponse, "UnknownErrorResponse");
|
|
1809
|
+
// src/lib/runtime/remote-actions.ts
|
|
1810
|
+
var import_shared3 = require("@copilotkit/shared");
|
|
1887
1811
|
|
|
1888
1812
|
// src/lib/telemetry-client.ts
|
|
1889
|
-
var
|
|
1813
|
+
var import_shared2 = require("@copilotkit/shared");
|
|
1890
1814
|
var import_node_crypto = require("crypto");
|
|
1891
1815
|
|
|
1892
1816
|
// src/lib/runtime/copilot-runtime.ts
|
|
1893
|
-
var
|
|
1894
|
-
var
|
|
1895
|
-
|
|
1896
|
-
// src/lib/runtime/types.ts
|
|
1897
|
-
var EndpointType;
|
|
1898
|
-
(function(EndpointType2) {
|
|
1899
|
-
EndpointType2["CopilotKit"] = "copilotKit";
|
|
1900
|
-
EndpointType2["LangGraphPlatform"] = "langgraph-platform";
|
|
1901
|
-
})(EndpointType || (EndpointType = {}));
|
|
1817
|
+
var import_shared = require("@copilotkit/shared");
|
|
1818
|
+
var import_rxjs = require("rxjs");
|
|
1819
|
+
var import_langgraph_sdk = require("@langchain/langgraph-sdk");
|
|
1902
1820
|
|
|
1903
1821
|
// src/agents/langgraph/events.ts
|
|
1904
1822
|
var LangGraphEventTypes;
|
|
@@ -1933,7 +1851,6 @@ var CustomEventNames;
|
|
|
1933
1851
|
})(CustomEventNames || (CustomEventNames = {}));
|
|
1934
1852
|
|
|
1935
1853
|
// src/lib/runtime/copilot-runtime.ts
|
|
1936
|
-
var import_agent = require("@copilotkitnext/agent");
|
|
1937
1854
|
function resolveEndpointType(endpoint) {
|
|
1938
1855
|
if (!endpoint.type) {
|
|
1939
1856
|
if ("deploymentUrl" in endpoint && "agents" in endpoint) {
|
|
@@ -1948,15 +1865,14 @@ __name(resolveEndpointType, "resolveEndpointType");
|
|
|
1948
1865
|
|
|
1949
1866
|
// src/lib/telemetry-client.ts
|
|
1950
1867
|
var packageJson = require_package();
|
|
1951
|
-
var telemetryClient = new
|
|
1868
|
+
var telemetryClient = new import_shared2.TelemetryClient({
|
|
1952
1869
|
packageName: packageJson.name,
|
|
1953
1870
|
packageVersion: packageJson.version
|
|
1954
1871
|
});
|
|
1955
1872
|
function getRuntimeInstanceTelemetryInfo(options) {
|
|
1956
|
-
var _a, _b
|
|
1873
|
+
var _a, _b;
|
|
1957
1874
|
const runtime = options.runtime;
|
|
1958
|
-
const
|
|
1959
|
-
const endpointsInfo = remoteEndpoints.reduce((acc, endpoint) => {
|
|
1875
|
+
const endpointsInfo = runtime.remoteEndpointDefinitions.reduce((acc, endpoint) => {
|
|
1960
1876
|
let info = {
|
|
1961
1877
|
...acc
|
|
1962
1878
|
};
|
|
@@ -1984,19 +1900,19 @@ function getRuntimeInstanceTelemetryInfo(options) {
|
|
|
1984
1900
|
agentsAmount: null,
|
|
1985
1901
|
hashedKey: null
|
|
1986
1902
|
});
|
|
1987
|
-
const publicApiKey = (
|
|
1903
|
+
const publicApiKey = (_a = options.cloud) == null ? void 0 : _a.publicApiKey;
|
|
1988
1904
|
const apiKeyProvided = !!publicApiKey && publicApiKey.trim().length > 0;
|
|
1989
1905
|
return {
|
|
1990
|
-
actionsAmount:
|
|
1991
|
-
endpointsAmount:
|
|
1906
|
+
actionsAmount: runtime.actions.length,
|
|
1907
|
+
endpointsAmount: runtime.remoteEndpointDefinitions.length,
|
|
1992
1908
|
endpointTypes: endpointsInfo.endpointTypes,
|
|
1993
|
-
agentsAmount:
|
|
1909
|
+
agentsAmount: endpointsInfo.agentsAmount,
|
|
1994
1910
|
hashedLgcKey: endpointsInfo.hashedKey,
|
|
1995
1911
|
"cloud.api_key_provided": apiKeyProvided,
|
|
1996
1912
|
...apiKeyProvided ? {
|
|
1997
1913
|
"cloud.public_api_key": publicApiKey
|
|
1998
1914
|
} : {},
|
|
1999
|
-
...((
|
|
1915
|
+
...((_b = options.cloud) == null ? void 0 : _b.baseUrl) ? {
|
|
2000
1916
|
"cloud.base_url": options.cloud.baseUrl
|
|
2001
1917
|
} : {}
|
|
2002
1918
|
};
|
|
@@ -2004,8 +1920,76 @@ function getRuntimeInstanceTelemetryInfo(options) {
|
|
|
2004
1920
|
__name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
|
|
2005
1921
|
var telemetry_client_default = telemetryClient;
|
|
2006
1922
|
|
|
1923
|
+
// src/lib/runtime/remote-actions.ts
|
|
1924
|
+
var import_shared4 = require("@copilotkit/shared");
|
|
1925
|
+
var EndpointType;
|
|
1926
|
+
(function(EndpointType2) {
|
|
1927
|
+
EndpointType2["CopilotKit"] = "copilotKit";
|
|
1928
|
+
EndpointType2["LangGraphPlatform"] = "langgraph-platform";
|
|
1929
|
+
})(EndpointType || (EndpointType = {}));
|
|
1930
|
+
|
|
1931
|
+
// src/service-adapters/events.ts
|
|
1932
|
+
var RuntimeEventTypes;
|
|
1933
|
+
(function(RuntimeEventTypes2) {
|
|
1934
|
+
RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
|
|
1935
|
+
RuntimeEventTypes2["TextMessageContent"] = "TextMessageContent";
|
|
1936
|
+
RuntimeEventTypes2["TextMessageEnd"] = "TextMessageEnd";
|
|
1937
|
+
RuntimeEventTypes2["ActionExecutionStart"] = "ActionExecutionStart";
|
|
1938
|
+
RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
|
|
1939
|
+
RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
|
|
1940
|
+
RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
|
|
1941
|
+
RuntimeEventTypes2["AgentStateMessage"] = "AgentStateMessage";
|
|
1942
|
+
RuntimeEventTypes2["MetaEvent"] = "MetaEvent";
|
|
1943
|
+
RuntimeEventTypes2["RunError"] = "RunError";
|
|
1944
|
+
})(RuntimeEventTypes || (RuntimeEventTypes = {}));
|
|
1945
|
+
var RuntimeMetaEventName;
|
|
1946
|
+
(function(RuntimeMetaEventName2) {
|
|
1947
|
+
RuntimeMetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
|
|
1948
|
+
RuntimeMetaEventName2["LangGraphInterruptResumeEvent"] = "LangGraphInterruptResumeEvent";
|
|
1949
|
+
RuntimeMetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
|
|
1950
|
+
})(RuntimeMetaEventName || (RuntimeMetaEventName = {}));
|
|
1951
|
+
|
|
2007
1952
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
2008
|
-
var
|
|
1953
|
+
var import_graphql_scalars2 = require("graphql-scalars");
|
|
1954
|
+
var import_class_transformer2 = require("class-transformer");
|
|
1955
|
+
var import_graphql = require("graphql");
|
|
1956
|
+
|
|
1957
|
+
// src/utils/failed-response-status-reasons.ts
|
|
1958
|
+
var GuardrailsValidationFailureResponse = class extends FailedResponseStatus {
|
|
1959
|
+
reason = FailedResponseStatusReason.GUARDRAILS_VALIDATION_FAILED;
|
|
1960
|
+
constructor({ guardrailsReason }) {
|
|
1961
|
+
super();
|
|
1962
|
+
this.details = {
|
|
1963
|
+
guardrailsReason
|
|
1964
|
+
};
|
|
1965
|
+
}
|
|
1966
|
+
};
|
|
1967
|
+
__name(GuardrailsValidationFailureResponse, "GuardrailsValidationFailureResponse");
|
|
1968
|
+
var MessageStreamInterruptedResponse = class extends FailedResponseStatus {
|
|
1969
|
+
reason = FailedResponseStatusReason.MESSAGE_STREAM_INTERRUPTED;
|
|
1970
|
+
constructor({ messageId }) {
|
|
1971
|
+
super();
|
|
1972
|
+
this.details = {
|
|
1973
|
+
messageId,
|
|
1974
|
+
description: "Check the message for mode details"
|
|
1975
|
+
};
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1978
|
+
__name(MessageStreamInterruptedResponse, "MessageStreamInterruptedResponse");
|
|
1979
|
+
var UnknownErrorResponse = class extends FailedResponseStatus {
|
|
1980
|
+
reason = FailedResponseStatusReason.UNKNOWN_ERROR;
|
|
1981
|
+
constructor({ description, originalError }) {
|
|
1982
|
+
super();
|
|
1983
|
+
this.details = {
|
|
1984
|
+
description,
|
|
1985
|
+
originalError
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
};
|
|
1989
|
+
__name(UnknownErrorResponse, "UnknownErrorResponse");
|
|
1990
|
+
|
|
1991
|
+
// src/graphql/resolvers/copilot.resolver.ts
|
|
1992
|
+
var import_shared6 = require("@copilotkit/shared");
|
|
2009
1993
|
|
|
2010
1994
|
// src/graphql/types/agents-response.type.ts
|
|
2011
1995
|
var import_type_graphql20 = require("type-graphql");
|
|
@@ -2061,7 +2045,7 @@ AgentsResponse = _ts_decorate19([
|
|
|
2061
2045
|
], AgentsResponse);
|
|
2062
2046
|
|
|
2063
2047
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
2064
|
-
var
|
|
2048
|
+
var import_shared7 = require("@copilotkit/shared");
|
|
2065
2049
|
function _ts_decorate20(decorators, target, key, desc) {
|
|
2066
2050
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2067
2051
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -2124,14 +2108,14 @@ var CopilotResolver = class {
|
|
|
2124
2108
|
component: "CopilotResolver.availableAgents"
|
|
2125
2109
|
});
|
|
2126
2110
|
logger2.debug("Processing");
|
|
2127
|
-
const agentsWithEndpoints =
|
|
2111
|
+
const agentsWithEndpoints = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
|
|
2128
2112
|
logger2.debug("Event source created, creating response");
|
|
2129
2113
|
return {
|
|
2130
2114
|
agents: agentsWithEndpoints.map(({ endpoint, ...agentWithoutEndpoint }) => agentWithoutEndpoint)
|
|
2131
2115
|
};
|
|
2132
2116
|
}
|
|
2133
2117
|
async generateCopilotResponse(ctx, data, properties) {
|
|
2134
|
-
var _a, _b, _c, _d;
|
|
2118
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2135
2119
|
telemetry_client_default.capture("oss.runtime.copilot_request_created", {
|
|
2136
2120
|
"cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
|
|
2137
2121
|
requestType: data.metadata.requestType,
|
|
@@ -2173,12 +2157,21 @@ var CopilotResolver = class {
|
|
|
2173
2157
|
logger2.debug("Cloud configuration provided, checking for public API key in headers");
|
|
2174
2158
|
if (!copilotCloudPublicApiKey) {
|
|
2175
2159
|
logger2.error("Public API key not found in headers");
|
|
2160
|
+
await copilotRuntime.errorGraphQLError({
|
|
2161
|
+
message: "X-CopilotCloud-Public-API-Key header is required",
|
|
2162
|
+
code: "MISSING_PUBLIC_API_KEY",
|
|
2163
|
+
type: "GraphQLError"
|
|
2164
|
+
}, {
|
|
2165
|
+
operation: "generateCopilotResponse",
|
|
2166
|
+
cloudConfigPresent: Boolean(data.cloud),
|
|
2167
|
+
guardrailsEnabled: Boolean((_b = data.cloud) == null ? void 0 : _b.guardrails)
|
|
2168
|
+
});
|
|
2176
2169
|
throw new import_graphql.GraphQLError("X-CopilotCloud-Public-API-Key header is required");
|
|
2177
2170
|
}
|
|
2178
2171
|
if (process.env.COPILOT_CLOUD_BASE_URL) {
|
|
2179
2172
|
copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
|
|
2180
|
-
} else if ((
|
|
2181
|
-
copilotCloudBaseUrl = (
|
|
2173
|
+
} else if ((_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl) {
|
|
2174
|
+
copilotCloudBaseUrl = (_d = ctx._copilotkit.cloud) == null ? void 0 : _d.baseUrl;
|
|
2182
2175
|
} else {
|
|
2183
2176
|
copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
|
|
2184
2177
|
}
|
|
@@ -2187,9 +2180,9 @@ var CopilotResolver = class {
|
|
|
2187
2180
|
});
|
|
2188
2181
|
}
|
|
2189
2182
|
logger2.debug("Setting up subjects");
|
|
2190
|
-
const responseStatus$ = new
|
|
2191
|
-
const interruptStreaming$ = new
|
|
2192
|
-
const guardrailsResult$ = new
|
|
2183
|
+
const responseStatus$ = new import_rxjs3.ReplaySubject();
|
|
2184
|
+
const interruptStreaming$ = new import_rxjs3.ReplaySubject();
|
|
2185
|
+
const guardrailsResult$ = new import_rxjs3.ReplaySubject();
|
|
2193
2186
|
let outputMessages = [];
|
|
2194
2187
|
let resolveOutputMessagesPromise;
|
|
2195
2188
|
let rejectOutputMessagesPromise;
|
|
@@ -2202,11 +2195,41 @@ var CopilotResolver = class {
|
|
|
2202
2195
|
}
|
|
2203
2196
|
logger2.debug("Processing");
|
|
2204
2197
|
let runtimeResponse;
|
|
2205
|
-
|
|
2198
|
+
try {
|
|
2199
|
+
runtimeResponse = await copilotRuntime.processRuntimeRequest({
|
|
2200
|
+
serviceAdapter,
|
|
2201
|
+
messages: data.messages,
|
|
2202
|
+
actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
|
|
2203
|
+
threadId: data.threadId,
|
|
2204
|
+
runId: data.runId,
|
|
2205
|
+
publicApiKey: copilotCloudPublicApiKey,
|
|
2206
|
+
outputMessagesPromise,
|
|
2207
|
+
graphqlContext: ctx,
|
|
2208
|
+
forwardedParameters: data.forwardedParameters,
|
|
2209
|
+
agentSession: data.agentSession,
|
|
2210
|
+
agentStates: data.agentStates,
|
|
2211
|
+
url: data.frontend.url,
|
|
2212
|
+
extensions: data.extensions,
|
|
2213
|
+
metaEvents: data.metaEvents,
|
|
2214
|
+
context: data.context
|
|
2215
|
+
});
|
|
2216
|
+
} catch (error) {
|
|
2217
|
+
if ((0, import_shared7.isStructuredCopilotKitError)(error) || ((_e = error == null ? void 0 : error.extensions) == null ? void 0 : _e.visibility)) {
|
|
2218
|
+
throw new import_graphql.GraphQLError(error.message || "Agent error occurred", {
|
|
2219
|
+
extensions: {
|
|
2220
|
+
...error.extensions,
|
|
2221
|
+
code: error.code || ((_f = error.extensions) == null ? void 0 : _f.code) || "AGENT_ERROR",
|
|
2222
|
+
originalError: error
|
|
2223
|
+
}
|
|
2224
|
+
});
|
|
2225
|
+
}
|
|
2226
|
+
throw error;
|
|
2227
|
+
}
|
|
2228
|
+
const { eventSource, threadId = (0, import_shared6.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = runtimeResponse;
|
|
2206
2229
|
logger2.debug("Event source created, creating response");
|
|
2207
2230
|
const eventStream = eventSource.processRuntimeEvents({
|
|
2208
2231
|
serverSideActions,
|
|
2209
|
-
guardrailsResult$: ((
|
|
2232
|
+
guardrailsResult$: ((_g = data.cloud) == null ? void 0 : _g.guardrails) ? guardrailsResult$ : null,
|
|
2210
2233
|
actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
|
|
2211
2234
|
// TODO-AGENTS: do not exclude ALL server side actions
|
|
2212
2235
|
(action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
|
|
@@ -2215,15 +2238,15 @@ var CopilotResolver = class {
|
|
|
2215
2238
|
}).pipe(
|
|
2216
2239
|
// shareReplay() ensures that later subscribers will see the whole stream instead of
|
|
2217
2240
|
// just the events that were emitted after the subscriber was added.
|
|
2218
|
-
(0,
|
|
2219
|
-
(0,
|
|
2241
|
+
(0, import_rxjs3.shareReplay)(),
|
|
2242
|
+
(0, import_rxjs3.finalize)(() => {
|
|
2220
2243
|
logger2.debug("Event stream finalized");
|
|
2221
2244
|
})
|
|
2222
2245
|
);
|
|
2223
2246
|
const response = {
|
|
2224
2247
|
threadId,
|
|
2225
2248
|
runId,
|
|
2226
|
-
status: (0,
|
|
2249
|
+
status: (0, import_rxjs3.firstValueFrom)(responseStatus$),
|
|
2227
2250
|
extensions,
|
|
2228
2251
|
metaEvents: new import_graphql_yoga.Repeater(async (push, stop) => {
|
|
2229
2252
|
let eventStreamSubscription;
|
|
@@ -2234,7 +2257,7 @@ var CopilotResolver = class {
|
|
|
2234
2257
|
}
|
|
2235
2258
|
switch (event.name) {
|
|
2236
2259
|
case LangGraphEventTypes.OnInterrupt:
|
|
2237
|
-
push((0,
|
|
2260
|
+
push((0, import_class_transformer2.plainToInstance)(LangGraphInterruptEvent, {
|
|
2238
2261
|
// @ts-ignore
|
|
2239
2262
|
type: event.type,
|
|
2240
2263
|
// @ts-ignore
|
|
@@ -2244,21 +2267,21 @@ var CopilotResolver = class {
|
|
|
2244
2267
|
}));
|
|
2245
2268
|
break;
|
|
2246
2269
|
case RuntimeMetaEventName.LangGraphInterruptEvent:
|
|
2247
|
-
push((0,
|
|
2270
|
+
push((0, import_class_transformer2.plainToInstance)(LangGraphInterruptEvent, {
|
|
2248
2271
|
type: event.type,
|
|
2249
2272
|
name: event.name,
|
|
2250
2273
|
value: event.value
|
|
2251
2274
|
}));
|
|
2252
2275
|
break;
|
|
2253
2276
|
case RuntimeMetaEventName.CopilotKitLangGraphInterruptEvent:
|
|
2254
|
-
push((0,
|
|
2277
|
+
push((0, import_class_transformer2.plainToInstance)(CopilotKitLangGraphInterruptEvent, {
|
|
2255
2278
|
type: event.type,
|
|
2256
2279
|
name: event.name,
|
|
2257
2280
|
data: {
|
|
2258
2281
|
value: event.data.value,
|
|
2259
2282
|
messages: event.data.messages.map((message) => {
|
|
2260
2283
|
if (message.type === "TextMessage" || "content" in message && "role" in message) {
|
|
2261
|
-
return (0,
|
|
2284
|
+
return (0, import_class_transformer2.plainToInstance)(TextMessage, {
|
|
2262
2285
|
id: message.id,
|
|
2263
2286
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2264
2287
|
content: [
|
|
@@ -2269,7 +2292,7 @@ var CopilotResolver = class {
|
|
|
2269
2292
|
});
|
|
2270
2293
|
}
|
|
2271
2294
|
if ("arguments" in message) {
|
|
2272
|
-
return (0,
|
|
2295
|
+
return (0, import_class_transformer2.plainToInstance)(ActionExecutionMessage, {
|
|
2273
2296
|
name: message.name,
|
|
2274
2297
|
id: message.id,
|
|
2275
2298
|
arguments: [
|
|
@@ -2333,8 +2356,8 @@ var CopilotResolver = class {
|
|
|
2333
2356
|
reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
|
|
2334
2357
|
});
|
|
2335
2358
|
outputMessages = [
|
|
2336
|
-
(0,
|
|
2337
|
-
id: (0,
|
|
2359
|
+
(0, import_class_transformer2.plainToInstance)(TextMessage, {
|
|
2360
|
+
id: (0, import_shared6.randomId)(),
|
|
2338
2361
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2339
2362
|
content: result.reason,
|
|
2340
2363
|
role: MessageRole.assistant
|
|
@@ -2367,30 +2390,30 @@ var CopilotResolver = class {
|
|
|
2367
2390
|
case RuntimeEventTypes.TextMessageStart:
|
|
2368
2391
|
const textMessageContentStream = eventStream.pipe(
|
|
2369
2392
|
// skip until this message start event
|
|
2370
|
-
(0,
|
|
2393
|
+
(0, import_rxjs3.skipWhile)((e) => e !== event),
|
|
2371
2394
|
// take until the message end event
|
|
2372
|
-
(0,
|
|
2395
|
+
(0, import_rxjs3.takeWhile)((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
|
|
2373
2396
|
// filter out any other message events or message ids
|
|
2374
|
-
(0,
|
|
2397
|
+
(0, import_rxjs3.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
|
|
2375
2398
|
);
|
|
2376
|
-
const streamingTextStatus = new
|
|
2399
|
+
const streamingTextStatus = new import_rxjs3.Subject();
|
|
2377
2400
|
const messageId = event.messageId;
|
|
2378
2401
|
pushMessage({
|
|
2379
2402
|
id: messageId,
|
|
2380
2403
|
parentMessageId: event.parentMessageId,
|
|
2381
|
-
status: (0,
|
|
2404
|
+
status: (0, import_rxjs3.firstValueFrom)(streamingTextStatus),
|
|
2382
2405
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2383
2406
|
role: MessageRole.assistant,
|
|
2384
2407
|
content: new import_graphql_yoga.Repeater(async (pushTextChunk, stopStreamingText) => {
|
|
2385
2408
|
logger2.debug("Text message content repeater created");
|
|
2386
2409
|
const textChunks = [];
|
|
2387
2410
|
let textSubscription;
|
|
2388
|
-
interruptStreaming$.pipe((0,
|
|
2411
|
+
interruptStreaming$.pipe((0, import_rxjs3.shareReplay)(), (0, import_rxjs3.take)(1), (0, import_rxjs3.tap)(({ reason, messageId: messageId2 }) => {
|
|
2389
2412
|
logger2.debug({
|
|
2390
2413
|
reason,
|
|
2391
2414
|
messageId: messageId2
|
|
2392
2415
|
}, "Text streaming interrupted");
|
|
2393
|
-
streamingTextStatus.next((0,
|
|
2416
|
+
streamingTextStatus.next((0, import_class_transformer2.plainToInstance)(FailedMessageStatus, {
|
|
2394
2417
|
reason
|
|
2395
2418
|
}));
|
|
2396
2419
|
responseStatus$.next(new MessageStreamInterruptedResponse({
|
|
@@ -2423,7 +2446,7 @@ var CopilotResolver = class {
|
|
|
2423
2446
|
streamingTextStatus.next(new SuccessMessageStatus());
|
|
2424
2447
|
stopStreamingText();
|
|
2425
2448
|
textSubscription == null ? void 0 : textSubscription.unsubscribe();
|
|
2426
|
-
outputMessages.push((0,
|
|
2449
|
+
outputMessages.push((0, import_class_transformer2.plainToInstance)(TextMessage, {
|
|
2427
2450
|
id: messageId,
|
|
2428
2451
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2429
2452
|
content: textChunks.join(""),
|
|
@@ -2437,17 +2460,17 @@ var CopilotResolver = class {
|
|
|
2437
2460
|
case RuntimeEventTypes.ActionExecutionStart:
|
|
2438
2461
|
logger2.debug("Action execution start event received");
|
|
2439
2462
|
const actionExecutionArgumentStream = eventStream.pipe(
|
|
2440
|
-
(0,
|
|
2463
|
+
(0, import_rxjs3.skipWhile)((e) => e !== event),
|
|
2441
2464
|
// take until the action execution end event
|
|
2442
|
-
(0,
|
|
2465
|
+
(0, import_rxjs3.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
|
|
2443
2466
|
// filter out any other action execution events or action execution ids
|
|
2444
|
-
(0,
|
|
2467
|
+
(0, import_rxjs3.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
|
|
2445
2468
|
);
|
|
2446
|
-
const streamingArgumentsStatus = new
|
|
2469
|
+
const streamingArgumentsStatus = new import_rxjs3.Subject();
|
|
2447
2470
|
pushMessage({
|
|
2448
2471
|
id: event.actionExecutionId,
|
|
2449
2472
|
parentMessageId: event.parentMessageId,
|
|
2450
|
-
status: (0,
|
|
2473
|
+
status: (0, import_rxjs3.firstValueFrom)(streamingArgumentsStatus),
|
|
2451
2474
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2452
2475
|
name: event.actionName,
|
|
2453
2476
|
arguments: new import_graphql_yoga.Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
|
|
@@ -2465,7 +2488,7 @@ var CopilotResolver = class {
|
|
|
2465
2488
|
logger2.error({
|
|
2466
2489
|
err
|
|
2467
2490
|
}, "Error in action execution argument stream");
|
|
2468
|
-
streamingArgumentsStatus.next((0,
|
|
2491
|
+
streamingArgumentsStatus.next((0, import_class_transformer2.plainToInstance)(FailedMessageStatus, {
|
|
2469
2492
|
reason: "An unknown error has occurred in the action execution argument stream"
|
|
2470
2493
|
}));
|
|
2471
2494
|
stopStreamingArguments();
|
|
@@ -2476,7 +2499,7 @@ var CopilotResolver = class {
|
|
|
2476
2499
|
streamingArgumentsStatus.next(new SuccessMessageStatus());
|
|
2477
2500
|
stopStreamingArguments();
|
|
2478
2501
|
actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
|
|
2479
|
-
outputMessages.push((0,
|
|
2502
|
+
outputMessages.push((0, import_class_transformer2.plainToInstance)(ActionExecutionMessage, {
|
|
2480
2503
|
id: event.actionExecutionId,
|
|
2481
2504
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2482
2505
|
name: event.actionName,
|
|
@@ -2499,7 +2522,7 @@ var CopilotResolver = class {
|
|
|
2499
2522
|
actionName: event.actionName,
|
|
2500
2523
|
result: event.result
|
|
2501
2524
|
});
|
|
2502
|
-
outputMessages.push((0,
|
|
2525
|
+
outputMessages.push((0, import_class_transformer2.plainToInstance)(ResultMessage, {
|
|
2503
2526
|
id: "result-" + event.actionExecutionId,
|
|
2504
2527
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2505
2528
|
actionExecutionId: event.actionExecutionId,
|
|
@@ -2512,7 +2535,7 @@ var CopilotResolver = class {
|
|
|
2512
2535
|
event
|
|
2513
2536
|
}, "Agent message event received");
|
|
2514
2537
|
pushMessage({
|
|
2515
|
-
id: (0,
|
|
2538
|
+
id: (0, import_shared6.randomId)(),
|
|
2516
2539
|
status: new SuccessMessageStatus(),
|
|
2517
2540
|
threadId: event.threadId,
|
|
2518
2541
|
agentName: event.agentName,
|
|
@@ -2524,8 +2547,8 @@ var CopilotResolver = class {
|
|
|
2524
2547
|
role: MessageRole.assistant,
|
|
2525
2548
|
createdAt: /* @__PURE__ */ new Date()
|
|
2526
2549
|
});
|
|
2527
|
-
outputMessages.push((0,
|
|
2528
|
-
id: (0,
|
|
2550
|
+
outputMessages.push((0, import_class_transformer2.plainToInstance)(AgentStateMessage, {
|
|
2551
|
+
id: (0, import_shared6.randomId)(),
|
|
2529
2552
|
threadId: event.threadId,
|
|
2530
2553
|
agentName: event.agentName,
|
|
2531
2554
|
nodeName: event.nodeName,
|
|
@@ -2540,8 +2563,8 @@ var CopilotResolver = class {
|
|
|
2540
2563
|
}
|
|
2541
2564
|
},
|
|
2542
2565
|
error: (err) => {
|
|
2543
|
-
var _a3, _b2, _c2, _d2,
|
|
2544
|
-
if (err instanceof
|
|
2566
|
+
var _a3, _b2, _c2, _d2, _e2, _f2;
|
|
2567
|
+
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)) {
|
|
2545
2568
|
responseStatus$.next(new UnknownErrorResponse({
|
|
2546
2569
|
description: err.message || "Agent error occurred",
|
|
2547
2570
|
// Include original error information for frontend to extract
|
|
@@ -2549,8 +2572,8 @@ var CopilotResolver = class {
|
|
|
2549
2572
|
code: err.code || ((_b2 = err.extensions) == null ? void 0 : _b2.code),
|
|
2550
2573
|
statusCode: err.statusCode || ((_c2 = err.extensions) == null ? void 0 : _c2.statusCode),
|
|
2551
2574
|
severity: err.severity || ((_d2 = err.extensions) == null ? void 0 : _d2.severity),
|
|
2552
|
-
visibility: err.visibility || ((
|
|
2553
|
-
originalErrorType: err.originalErrorType || ((
|
|
2575
|
+
visibility: err.visibility || ((_e2 = err.extensions) == null ? void 0 : _e2.visibility),
|
|
2576
|
+
originalErrorType: err.originalErrorType || ((_f2 = err.extensions) == null ? void 0 : _f2.originalErrorType),
|
|
2554
2577
|
extensions: err.extensions
|
|
2555
2578
|
}
|
|
2556
2579
|
}));
|
|
@@ -2571,7 +2594,7 @@ var CopilotResolver = class {
|
|
|
2571
2594
|
logger2.debug("Event stream completed");
|
|
2572
2595
|
if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
|
|
2573
2596
|
logger2.debug("Guardrails is enabled, waiting for guardrails result");
|
|
2574
|
-
await (0,
|
|
2597
|
+
await (0, import_rxjs3.firstValueFrom)(guardrailsResult$);
|
|
2575
2598
|
}
|
|
2576
2599
|
responseStatus$.next(new SuccessResponseStatus());
|
|
2577
2600
|
eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
|
|
@@ -2736,7 +2759,7 @@ LoadAgentStateInput = _ts_decorate22([
|
|
|
2736
2759
|
], LoadAgentStateInput);
|
|
2737
2760
|
|
|
2738
2761
|
// src/graphql/resolvers/state.resolver.ts
|
|
2739
|
-
var
|
|
2762
|
+
var import_shared8 = require("@copilotkit/shared");
|
|
2740
2763
|
function _ts_decorate23(decorators, target, key, desc) {
|
|
2741
2764
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2742
2765
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -2761,10 +2784,10 @@ function _ts_param2(paramIndex, decorator) {
|
|
|
2761
2784
|
__name(_ts_param2, "_ts_param");
|
|
2762
2785
|
var StateResolver = class {
|
|
2763
2786
|
async loadAgentState(ctx, data) {
|
|
2764
|
-
const agents =
|
|
2787
|
+
const agents = await ctx._copilotkit.runtime.getAllAgents(ctx);
|
|
2765
2788
|
const hasAgent = agents.some((agent) => agent.name === data.agentName);
|
|
2766
2789
|
if (!hasAgent) {
|
|
2767
|
-
throw new
|
|
2790
|
+
throw new import_shared8.CopilotKitAgentDiscoveryError({
|
|
2768
2791
|
agentName: data.agentName,
|
|
2769
2792
|
availableAgents: agents.map((a) => ({
|
|
2770
2793
|
name: a.name,
|
|
@@ -2772,7 +2795,7 @@ var StateResolver = class {
|
|
|
2772
2795
|
}))
|
|
2773
2796
|
});
|
|
2774
2797
|
}
|
|
2775
|
-
const state =
|
|
2798
|
+
const state = await ctx._copilotkit.runtime.loadAgentState(ctx, data.threadId, data.agentName);
|
|
2776
2799
|
return state;
|
|
2777
2800
|
}
|
|
2778
2801
|
};
|
|
@@ -2794,7 +2817,7 @@ StateResolver = _ts_decorate23([
|
|
|
2794
2817
|
|
|
2795
2818
|
// src/lib/integrations/shared.ts
|
|
2796
2819
|
var packageJson2 = __toESM(require_package());
|
|
2797
|
-
var
|
|
2820
|
+
var import_shared9 = require("@copilotkit/shared");
|
|
2798
2821
|
var logger = createLogger();
|
|
2799
2822
|
var addCustomHeaderPlugin = {
|
|
2800
2823
|
onResponse({ response }) {
|
|
@@ -2860,11 +2883,11 @@ function getCommonConfig(options) {
|
|
|
2860
2883
|
}
|
|
2861
2884
|
});
|
|
2862
2885
|
const userErrorCodes = [
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2886
|
+
import_shared9.CopilotKitErrorCode.AGENT_NOT_FOUND,
|
|
2887
|
+
import_shared9.CopilotKitErrorCode.API_NOT_FOUND,
|
|
2888
|
+
import_shared9.CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND,
|
|
2889
|
+
import_shared9.CopilotKitErrorCode.CONFIGURATION_ERROR,
|
|
2890
|
+
import_shared9.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR
|
|
2868
2891
|
];
|
|
2869
2892
|
return {
|
|
2870
2893
|
logging: createLogger({
|
|
@@ -2887,7 +2910,7 @@ function getCommonConfig(options) {
|
|
|
2887
2910
|
console.debug("User configuration error:", error.message);
|
|
2888
2911
|
return error;
|
|
2889
2912
|
}
|
|
2890
|
-
if (originalError instanceof
|
|
2913
|
+
if (originalError instanceof import_shared9.CopilotKitError && userErrorCodes.includes(originalError.code)) {
|
|
2891
2914
|
console.debug("User configuration error:", error.message);
|
|
2892
2915
|
return error;
|
|
2893
2916
|
}
|
|
@@ -2900,7 +2923,7 @@ function getCommonConfig(options) {
|
|
|
2900
2923
|
__name(getCommonConfig, "getCommonConfig");
|
|
2901
2924
|
|
|
2902
2925
|
// src/lib/integrations/nextjs/app-router.ts
|
|
2903
|
-
var
|
|
2926
|
+
var import_graphql_yoga2 = require("graphql-yoga");
|
|
2904
2927
|
function copilotRuntimeNextJSAppRouterEndpoint(options) {
|
|
2905
2928
|
var _a;
|
|
2906
2929
|
const commonConfig = getCommonConfig(options);
|
|
@@ -2917,17 +2940,24 @@ function copilotRuntimeNextJSAppRouterEndpoint(options) {
|
|
|
2917
2940
|
telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
|
|
2918
2941
|
const logger2 = commonConfig.logging;
|
|
2919
2942
|
logger2.debug("Creating NextJS App Router endpoint");
|
|
2920
|
-
const
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2943
|
+
const yoga = (0, import_graphql_yoga2.createYoga)({
|
|
2944
|
+
...commonConfig,
|
|
2945
|
+
graphqlEndpoint: options.endpoint,
|
|
2946
|
+
fetchAPI: {
|
|
2947
|
+
Response: globalThis.Response
|
|
2948
|
+
}
|
|
2925
2949
|
});
|
|
2950
|
+
return {
|
|
2951
|
+
handleRequest: yoga,
|
|
2952
|
+
GET: yoga,
|
|
2953
|
+
POST: yoga,
|
|
2954
|
+
OPTIONS: yoga
|
|
2955
|
+
};
|
|
2926
2956
|
}
|
|
2927
2957
|
__name(copilotRuntimeNextJSAppRouterEndpoint, "copilotRuntimeNextJSAppRouterEndpoint");
|
|
2928
2958
|
|
|
2929
2959
|
// src/lib/integrations/nextjs/pages-router.ts
|
|
2930
|
-
var
|
|
2960
|
+
var import_graphql_yoga3 = require("graphql-yoga");
|
|
2931
2961
|
var config = {
|
|
2932
2962
|
api: {
|
|
2933
2963
|
bodyParser: false
|
|
@@ -2949,17 +2979,16 @@ function copilotRuntimeNextJSPagesRouterEndpoint(options) {
|
|
|
2949
2979
|
telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
|
|
2950
2980
|
const logger2 = commonConfig.logging;
|
|
2951
2981
|
logger2.debug("Creating NextJS Pages Router endpoint");
|
|
2952
|
-
const
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
runtime: options.runtime.instance,
|
|
2956
|
-
basePath: options.baseUrl
|
|
2982
|
+
const yoga = (0, import_graphql_yoga3.createYoga)({
|
|
2983
|
+
...commonConfig,
|
|
2984
|
+
graphqlEndpoint: options.endpoint
|
|
2957
2985
|
});
|
|
2986
|
+
return yoga;
|
|
2958
2987
|
}
|
|
2959
2988
|
__name(copilotRuntimeNextJSPagesRouterEndpoint, "copilotRuntimeNextJSPagesRouterEndpoint");
|
|
2960
2989
|
|
|
2961
2990
|
// src/lib/integrations/node-http/index.ts
|
|
2962
|
-
var
|
|
2991
|
+
var import_graphql_yoga4 = require("graphql-yoga");
|
|
2963
2992
|
function copilotRuntimeNodeHttpEndpoint(options) {
|
|
2964
2993
|
var _a;
|
|
2965
2994
|
const commonConfig = getCommonConfig(options);
|
|
@@ -2976,12 +3005,11 @@ function copilotRuntimeNodeHttpEndpoint(options) {
|
|
|
2976
3005
|
telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
|
|
2977
3006
|
const logger2 = commonConfig.logging;
|
|
2978
3007
|
logger2.debug("Creating Node HTTP endpoint");
|
|
2979
|
-
const
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
runtime: options.runtime.instance,
|
|
2983
|
-
basePath: options.baseUrl
|
|
3008
|
+
const yoga = (0, import_graphql_yoga4.createYoga)({
|
|
3009
|
+
...commonConfig,
|
|
3010
|
+
graphqlEndpoint: options.endpoint
|
|
2984
3011
|
});
|
|
3012
|
+
return yoga;
|
|
2985
3013
|
}
|
|
2986
3014
|
__name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
|
|
2987
3015
|
|