@copilotkit/runtime 1.9.2-next.2 → 1.9.2-next.21
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 +136 -0
- package/dist/{chunk-CD2SZGIZ.mjs → chunk-47L6Z7PJ.mjs} +2 -2
- package/dist/chunk-AMUJQ6IR.mjs +50 -0
- package/dist/chunk-AMUJQ6IR.mjs.map +1 -0
- package/dist/{chunk-DOWRU5U6.mjs → chunk-IBYPYIVX.mjs} +2353 -1854
- package/dist/chunk-IBYPYIVX.mjs.map +1 -0
- package/dist/{chunk-D3SPXEVJ.mjs → chunk-IXK4UOV6.mjs} +2 -2
- package/dist/{chunk-6TQCQ3WJ.mjs → chunk-P3HORCYJ.mjs} +2 -2
- package/dist/{chunk-IIXJVVTV.mjs → chunk-QLLV2QVK.mjs} +132 -78
- package/dist/chunk-QLLV2QVK.mjs.map +1 -0
- package/dist/{chunk-ODF35LFG.mjs → chunk-UPC6N4MV.mjs} +19 -2
- package/dist/chunk-UPC6N4MV.mjs.map +1 -0
- package/dist/{chunk-5BIEM2UU.mjs → chunk-XWBDEXDA.mjs} +4 -3
- package/dist/{chunk-5BIEM2UU.mjs.map → chunk-XWBDEXDA.mjs.map} +1 -1
- package/dist/{groq-adapter-25a2bd35.d.ts → groq-adapter-098f97f6.d.ts} +5 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3728 -3114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -8
- package/dist/index.mjs.map +1 -1
- package/dist/lib/index.d.ts +5 -4
- package/dist/lib/index.js +2711 -2140
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +9 -8
- package/dist/lib/integrations/index.d.ts +3 -3
- package/dist/lib/integrations/index.js +160 -96
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +7 -6
- package/dist/lib/integrations/nest/index.d.ts +2 -2
- package/dist/lib/integrations/nest/index.js +160 -96
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +5 -4
- package/dist/lib/integrations/node-express/index.d.ts +2 -2
- package/dist/lib/integrations/node-express/index.js +160 -96
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +5 -4
- package/dist/lib/integrations/node-http/index.d.ts +2 -2
- package/dist/lib/integrations/node-http/index.js +160 -96
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +4 -3
- package/dist/service-adapters/index.d.ts +6 -4
- package/dist/service-adapters/index.js +202 -107
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +6 -2
- package/dist/service-adapters/shared/index.d.ts +9 -0
- package/dist/service-adapters/shared/index.js +72 -0
- package/dist/service-adapters/shared/index.js.map +1 -0
- package/dist/service-adapters/shared/index.mjs +8 -0
- package/dist/service-adapters/shared/index.mjs.map +1 -0
- package/dist/{shared-e272b15a.d.ts → shared-41d4988d.d.ts} +45 -5
- package/dist/utils/index.d.ts +17 -1
- package/dist/utils/index.js +3 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/package.json +2 -2
- package/src/agents/langgraph/event-source.ts +36 -38
- package/src/agents/langgraph/events.ts +19 -1
- package/src/graphql/resolvers/copilot.resolver.ts +107 -45
- package/src/graphql/resolvers/state.resolver.ts +3 -3
- package/src/lib/error-messages.ts +200 -0
- package/src/lib/integrations/shared.ts +43 -0
- package/src/lib/runtime/__tests__/copilot-runtime-error.test.ts +169 -0
- package/src/lib/runtime/agui-action.ts +9 -3
- package/src/lib/runtime/copilot-runtime.ts +384 -83
- package/src/lib/runtime/langgraph/langgraph-agent.ts +12 -0
- package/src/lib/runtime/remote-action-constructors.ts +28 -3
- package/src/lib/runtime/remote-actions.ts +6 -0
- package/src/lib/runtime/remote-lg-action.ts +130 -40
- package/src/lib/streaming.ts +125 -36
- package/src/service-adapters/anthropic/anthropic-adapter.ts +67 -8
- package/src/service-adapters/anthropic/utils.ts +3 -8
- package/src/service-adapters/events.ts +37 -81
- package/src/service-adapters/google/google-genai-adapter.ts +5 -0
- package/src/service-adapters/groq/groq-adapter.ts +66 -56
- package/src/service-adapters/index.ts +1 -0
- package/src/service-adapters/openai/openai-adapter.ts +4 -3
- package/src/service-adapters/shared/error-utils.ts +61 -0
- package/src/service-adapters/shared/index.ts +1 -0
- package/src/utils/failed-response-status-reasons.ts +23 -1
- package/tests/service-adapters/anthropic/anthropic-adapter.test.ts +172 -387
- package/dist/chunk-DOWRU5U6.mjs.map +0 -1
- package/dist/chunk-IIXJVVTV.mjs.map +0 -1
- package/dist/chunk-ODF35LFG.mjs.map +0 -1
- package/dist/{chunk-CD2SZGIZ.mjs.map → chunk-47L6Z7PJ.mjs.map} +0 -0
- package/dist/{chunk-D3SPXEVJ.mjs.map → chunk-IXK4UOV6.mjs.map} +0 -0
- package/dist/{chunk-6TQCQ3WJ.mjs.map → chunk-P3HORCYJ.mjs.map} +0 -0
- package/dist/{langserve-4a5c9217.d.ts → langserve-fc5cac89.d.ts} +7 -7
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
copilotRuntimeNestEndpoint
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
5
|
-
import "../../../chunk-IIXJVVTV.mjs";
|
|
6
|
-
import "../../../chunk-5BIEM2UU.mjs";
|
|
3
|
+
} from "../../../chunk-P3HORCYJ.mjs";
|
|
4
|
+
import "../../../chunk-IBYPYIVX.mjs";
|
|
7
5
|
import "../../../chunk-SHBDMA63.mjs";
|
|
6
|
+
import "../../../chunk-QLLV2QVK.mjs";
|
|
7
|
+
import "../../../chunk-XWBDEXDA.mjs";
|
|
8
|
+
import "../../../chunk-AMUJQ6IR.mjs";
|
|
8
9
|
import "../../../chunk-2OZAGFV3.mjs";
|
|
9
10
|
import "../../../chunk-FHD4JECV.mjs";
|
|
10
11
|
export {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as graphql_yoga from 'graphql-yoga';
|
|
2
|
-
import { b as CreateCopilotRuntimeServerOptions, G as GraphQLContext } from '../../../shared-
|
|
2
|
+
import { b as CreateCopilotRuntimeServerOptions, G as GraphQLContext } from '../../../shared-41d4988d.js';
|
|
3
3
|
import 'graphql';
|
|
4
4
|
import 'pino';
|
|
5
5
|
import '@copilotkit/shared';
|
|
6
|
-
import '../../../langserve-
|
|
6
|
+
import '../../../langserve-fc5cac89.js';
|
|
7
7
|
import '../../../index-d4614f9b.js';
|
|
8
8
|
import '../../../graphql/types/base/index.js';
|
|
9
9
|
import 'rxjs';
|
|
@@ -44,7 +44,7 @@ var require_package = __commonJS({
|
|
|
44
44
|
publishConfig: {
|
|
45
45
|
access: "public"
|
|
46
46
|
},
|
|
47
|
-
version: "1.9.2-next.
|
|
47
|
+
version: "1.9.2-next.21",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -1639,59 +1639,9 @@ var import_graphql_yoga = require("graphql-yoga");
|
|
|
1639
1639
|
|
|
1640
1640
|
// src/service-adapters/events.ts
|
|
1641
1641
|
var import_shared5 = require("@copilotkit/shared");
|
|
1642
|
+
var import_class_transformer = require("class-transformer");
|
|
1642
1643
|
var import_rxjs2 = require("rxjs");
|
|
1643
1644
|
|
|
1644
|
-
// src/lib/telemetry-client.ts
|
|
1645
|
-
var import_shared4 = require("@copilotkit/shared");
|
|
1646
|
-
|
|
1647
|
-
// src/lib/runtime/remote-actions.ts
|
|
1648
|
-
var import_shared = require("@copilotkit/shared");
|
|
1649
|
-
|
|
1650
|
-
// src/agents/langgraph/events.ts
|
|
1651
|
-
var LangGraphEventTypes;
|
|
1652
|
-
(function(LangGraphEventTypes2) {
|
|
1653
|
-
LangGraphEventTypes2["OnChainStart"] = "on_chain_start";
|
|
1654
|
-
LangGraphEventTypes2["OnChainStream"] = "on_chain_stream";
|
|
1655
|
-
LangGraphEventTypes2["OnChainEnd"] = "on_chain_end";
|
|
1656
|
-
LangGraphEventTypes2["OnChatModelStart"] = "on_chat_model_start";
|
|
1657
|
-
LangGraphEventTypes2["OnChatModelStream"] = "on_chat_model_stream";
|
|
1658
|
-
LangGraphEventTypes2["OnChatModelEnd"] = "on_chat_model_end";
|
|
1659
|
-
LangGraphEventTypes2["OnToolStart"] = "on_tool_start";
|
|
1660
|
-
LangGraphEventTypes2["OnToolEnd"] = "on_tool_end";
|
|
1661
|
-
LangGraphEventTypes2["OnCopilotKitStateSync"] = "on_copilotkit_state_sync";
|
|
1662
|
-
LangGraphEventTypes2["OnCopilotKitEmitMessage"] = "on_copilotkit_emit_message";
|
|
1663
|
-
LangGraphEventTypes2["OnCopilotKitEmitToolCall"] = "on_copilotkit_emit_tool_call";
|
|
1664
|
-
LangGraphEventTypes2["OnCustomEvent"] = "on_custom_event";
|
|
1665
|
-
LangGraphEventTypes2["OnInterrupt"] = "on_interrupt";
|
|
1666
|
-
LangGraphEventTypes2["OnCopilotKitInterrupt"] = "on_copilotkit_interrupt";
|
|
1667
|
-
})(LangGraphEventTypes || (LangGraphEventTypes = {}));
|
|
1668
|
-
var MetaEventNames;
|
|
1669
|
-
(function(MetaEventNames2) {
|
|
1670
|
-
MetaEventNames2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
|
|
1671
|
-
MetaEventNames2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
|
|
1672
|
-
})(MetaEventNames || (MetaEventNames = {}));
|
|
1673
|
-
var CustomEventNames;
|
|
1674
|
-
(function(CustomEventNames2) {
|
|
1675
|
-
CustomEventNames2["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
|
|
1676
|
-
CustomEventNames2["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
|
|
1677
|
-
CustomEventNames2["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
|
|
1678
|
-
CustomEventNames2["CopilotKitExit"] = "copilotkit_exit";
|
|
1679
|
-
})(CustomEventNames || (CustomEventNames = {}));
|
|
1680
|
-
|
|
1681
|
-
// src/lib/runtime/remote-actions.ts
|
|
1682
|
-
var import_shared2 = require("@copilotkit/shared");
|
|
1683
|
-
var EndpointType;
|
|
1684
|
-
(function(EndpointType2) {
|
|
1685
|
-
EndpointType2["CopilotKit"] = "copilotKit";
|
|
1686
|
-
EndpointType2["LangGraphPlatform"] = "langgraph-platform";
|
|
1687
|
-
})(EndpointType || (EndpointType = {}));
|
|
1688
|
-
|
|
1689
|
-
// src/lib/telemetry-client.ts
|
|
1690
|
-
var import_node_crypto = require("crypto");
|
|
1691
|
-
|
|
1692
|
-
// src/lib/runtime/copilot-runtime.ts
|
|
1693
|
-
var import_shared3 = require("@copilotkit/shared");
|
|
1694
|
-
|
|
1695
1645
|
// src/graphql/types/converted/index.ts
|
|
1696
1646
|
var Message = class extends BaseMessageInput {
|
|
1697
1647
|
type;
|
|
@@ -1809,9 +1759,51 @@ var AgentStateMessage = class extends Message {
|
|
|
1809
1759
|
};
|
|
1810
1760
|
__name(AgentStateMessage, "AgentStateMessage");
|
|
1811
1761
|
|
|
1762
|
+
// src/lib/runtime/remote-actions.ts
|
|
1763
|
+
var import_shared3 = require("@copilotkit/shared");
|
|
1764
|
+
|
|
1765
|
+
// src/lib/telemetry-client.ts
|
|
1766
|
+
var import_shared2 = require("@copilotkit/shared");
|
|
1767
|
+
var import_node_crypto = require("crypto");
|
|
1768
|
+
|
|
1812
1769
|
// src/lib/runtime/copilot-runtime.ts
|
|
1770
|
+
var import_shared = require("@copilotkit/shared");
|
|
1813
1771
|
var import_rxjs = require("rxjs");
|
|
1814
1772
|
var import_langgraph_sdk = require("@langchain/langgraph-sdk");
|
|
1773
|
+
|
|
1774
|
+
// src/agents/langgraph/events.ts
|
|
1775
|
+
var LangGraphEventTypes;
|
|
1776
|
+
(function(LangGraphEventTypes2) {
|
|
1777
|
+
LangGraphEventTypes2["OnChainStart"] = "on_chain_start";
|
|
1778
|
+
LangGraphEventTypes2["OnChainStream"] = "on_chain_stream";
|
|
1779
|
+
LangGraphEventTypes2["OnChainEnd"] = "on_chain_end";
|
|
1780
|
+
LangGraphEventTypes2["OnChatModelStart"] = "on_chat_model_start";
|
|
1781
|
+
LangGraphEventTypes2["OnChatModelStream"] = "on_chat_model_stream";
|
|
1782
|
+
LangGraphEventTypes2["OnChatModelEnd"] = "on_chat_model_end";
|
|
1783
|
+
LangGraphEventTypes2["OnToolStart"] = "on_tool_start";
|
|
1784
|
+
LangGraphEventTypes2["OnToolEnd"] = "on_tool_end";
|
|
1785
|
+
LangGraphEventTypes2["OnCopilotKitStateSync"] = "on_copilotkit_state_sync";
|
|
1786
|
+
LangGraphEventTypes2["OnCopilotKitEmitMessage"] = "on_copilotkit_emit_message";
|
|
1787
|
+
LangGraphEventTypes2["OnCopilotKitEmitToolCall"] = "on_copilotkit_emit_tool_call";
|
|
1788
|
+
LangGraphEventTypes2["OnCustomEvent"] = "on_custom_event";
|
|
1789
|
+
LangGraphEventTypes2["OnInterrupt"] = "on_interrupt";
|
|
1790
|
+
LangGraphEventTypes2["OnCopilotKitInterrupt"] = "on_copilotkit_interrupt";
|
|
1791
|
+
LangGraphEventTypes2["OnCopilotKitError"] = "on_copilotkit_error";
|
|
1792
|
+
})(LangGraphEventTypes || (LangGraphEventTypes = {}));
|
|
1793
|
+
var MetaEventNames;
|
|
1794
|
+
(function(MetaEventNames2) {
|
|
1795
|
+
MetaEventNames2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
|
|
1796
|
+
MetaEventNames2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
|
|
1797
|
+
})(MetaEventNames || (MetaEventNames = {}));
|
|
1798
|
+
var CustomEventNames;
|
|
1799
|
+
(function(CustomEventNames2) {
|
|
1800
|
+
CustomEventNames2["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
|
|
1801
|
+
CustomEventNames2["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
|
|
1802
|
+
CustomEventNames2["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
|
|
1803
|
+
CustomEventNames2["CopilotKitExit"] = "copilotkit_exit";
|
|
1804
|
+
})(CustomEventNames || (CustomEventNames = {}));
|
|
1805
|
+
|
|
1806
|
+
// src/lib/runtime/copilot-runtime.ts
|
|
1815
1807
|
function resolveEndpointType(endpoint) {
|
|
1816
1808
|
if (!endpoint.type) {
|
|
1817
1809
|
if ("deploymentUrl" in endpoint && "agents" in endpoint) {
|
|
@@ -1826,7 +1818,7 @@ __name(resolveEndpointType, "resolveEndpointType");
|
|
|
1826
1818
|
|
|
1827
1819
|
// src/lib/telemetry-client.ts
|
|
1828
1820
|
var packageJson = require_package();
|
|
1829
|
-
var telemetryClient = new
|
|
1821
|
+
var telemetryClient = new import_shared2.TelemetryClient({
|
|
1830
1822
|
packageName: packageJson.name,
|
|
1831
1823
|
packageVersion: packageJson.version
|
|
1832
1824
|
});
|
|
@@ -1881,8 +1873,15 @@ function getRuntimeInstanceTelemetryInfo(options) {
|
|
|
1881
1873
|
__name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
|
|
1882
1874
|
var telemetry_client_default = telemetryClient;
|
|
1883
1875
|
|
|
1876
|
+
// src/lib/runtime/remote-actions.ts
|
|
1877
|
+
var import_shared4 = require("@copilotkit/shared");
|
|
1878
|
+
var EndpointType;
|
|
1879
|
+
(function(EndpointType2) {
|
|
1880
|
+
EndpointType2["CopilotKit"] = "copilotKit";
|
|
1881
|
+
EndpointType2["LangGraphPlatform"] = "langgraph-platform";
|
|
1882
|
+
})(EndpointType || (EndpointType = {}));
|
|
1883
|
+
|
|
1884
1884
|
// src/service-adapters/events.ts
|
|
1885
|
-
var import_class_transformer = require("class-transformer");
|
|
1886
1885
|
var RuntimeEventTypes;
|
|
1887
1886
|
(function(RuntimeEventTypes2) {
|
|
1888
1887
|
RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
|
|
@@ -1931,10 +1930,11 @@ var MessageStreamInterruptedResponse = class extends FailedResponseStatus {
|
|
|
1931
1930
|
__name(MessageStreamInterruptedResponse, "MessageStreamInterruptedResponse");
|
|
1932
1931
|
var UnknownErrorResponse = class extends FailedResponseStatus {
|
|
1933
1932
|
reason = FailedResponseStatusReason.UNKNOWN_ERROR;
|
|
1934
|
-
constructor({ description }) {
|
|
1933
|
+
constructor({ description, originalError }) {
|
|
1935
1934
|
super();
|
|
1936
1935
|
this.details = {
|
|
1937
|
-
description
|
|
1936
|
+
description,
|
|
1937
|
+
originalError
|
|
1938
1938
|
};
|
|
1939
1939
|
}
|
|
1940
1940
|
};
|
|
@@ -2067,7 +2067,7 @@ var CopilotResolver = class {
|
|
|
2067
2067
|
};
|
|
2068
2068
|
}
|
|
2069
2069
|
async generateCopilotResponse(ctx, data, properties) {
|
|
2070
|
-
var _a, _b, _c, _d;
|
|
2070
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2071
2071
|
telemetry_client_default.capture("oss.runtime.copilot_request_created", {
|
|
2072
2072
|
"cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
|
|
2073
2073
|
requestType: data.metadata.requestType,
|
|
@@ -2098,23 +2098,32 @@ var CopilotResolver = class {
|
|
|
2098
2098
|
const serviceAdapter = ctx._copilotkit.serviceAdapter;
|
|
2099
2099
|
let copilotCloudPublicApiKey = null;
|
|
2100
2100
|
let copilotCloudBaseUrl;
|
|
2101
|
+
const publicApiKeyFromHeaders = ctx.request.headers.get("x-copilotcloud-public-api-key");
|
|
2102
|
+
if (publicApiKeyFromHeaders) {
|
|
2103
|
+
copilotCloudPublicApiKey = publicApiKeyFromHeaders;
|
|
2104
|
+
}
|
|
2101
2105
|
if (data.cloud) {
|
|
2102
2106
|
logger2 = logger2.child({
|
|
2103
2107
|
cloud: true
|
|
2104
2108
|
});
|
|
2105
2109
|
logger2.debug("Cloud configuration provided, checking for public API key in headers");
|
|
2106
|
-
|
|
2107
|
-
if (key) {
|
|
2108
|
-
logger2.debug("Public API key found in headers");
|
|
2109
|
-
copilotCloudPublicApiKey = key;
|
|
2110
|
-
} else {
|
|
2110
|
+
if (!copilotCloudPublicApiKey) {
|
|
2111
2111
|
logger2.error("Public API key not found in headers");
|
|
2112
|
+
await copilotRuntime.errorGraphQLError({
|
|
2113
|
+
message: "X-CopilotCloud-Public-API-Key header is required",
|
|
2114
|
+
code: "MISSING_PUBLIC_API_KEY",
|
|
2115
|
+
type: "GraphQLError"
|
|
2116
|
+
}, {
|
|
2117
|
+
operation: "generateCopilotResponse",
|
|
2118
|
+
cloudConfigPresent: Boolean(data.cloud),
|
|
2119
|
+
guardrailsEnabled: Boolean((_b = data.cloud) == null ? void 0 : _b.guardrails)
|
|
2120
|
+
});
|
|
2112
2121
|
throw new import_graphql.GraphQLError("X-CopilotCloud-Public-API-Key header is required");
|
|
2113
2122
|
}
|
|
2114
2123
|
if (process.env.COPILOT_CLOUD_BASE_URL) {
|
|
2115
2124
|
copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
|
|
2116
|
-
} else if ((
|
|
2117
|
-
copilotCloudBaseUrl = (
|
|
2125
|
+
} else if ((_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl) {
|
|
2126
|
+
copilotCloudBaseUrl = (_d = ctx._copilotkit.cloud) == null ? void 0 : _d.baseUrl;
|
|
2118
2127
|
} else {
|
|
2119
2128
|
copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
|
|
2120
2129
|
}
|
|
@@ -2137,26 +2146,41 @@ var CopilotResolver = class {
|
|
|
2137
2146
|
ctx.properties["copilotCloudPublicApiKey"] = copilotCloudPublicApiKey;
|
|
2138
2147
|
}
|
|
2139
2148
|
logger2.debug("Processing");
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2149
|
+
let runtimeResponse;
|
|
2150
|
+
try {
|
|
2151
|
+
runtimeResponse = await copilotRuntime.processRuntimeRequest({
|
|
2152
|
+
serviceAdapter,
|
|
2153
|
+
messages: data.messages,
|
|
2154
|
+
actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
|
|
2155
|
+
threadId: data.threadId,
|
|
2156
|
+
runId: data.runId,
|
|
2157
|
+
publicApiKey: copilotCloudPublicApiKey,
|
|
2158
|
+
outputMessagesPromise,
|
|
2159
|
+
graphqlContext: ctx,
|
|
2160
|
+
forwardedParameters: data.forwardedParameters,
|
|
2161
|
+
agentSession: data.agentSession,
|
|
2162
|
+
agentStates: data.agentStates,
|
|
2163
|
+
url: data.frontend.url,
|
|
2164
|
+
extensions: data.extensions,
|
|
2165
|
+
metaEvents: data.metaEvents
|
|
2166
|
+
});
|
|
2167
|
+
} catch (error) {
|
|
2168
|
+
if ((0, import_shared7.isStructuredCopilotKitError)(error) || ((_e = error == null ? void 0 : error.extensions) == null ? void 0 : _e.visibility)) {
|
|
2169
|
+
throw new import_graphql.GraphQLError(error.message || "Agent error occurred", {
|
|
2170
|
+
extensions: {
|
|
2171
|
+
...error.extensions,
|
|
2172
|
+
code: error.code || ((_f = error.extensions) == null ? void 0 : _f.code) || "AGENT_ERROR",
|
|
2173
|
+
originalError: error
|
|
2174
|
+
}
|
|
2175
|
+
});
|
|
2176
|
+
}
|
|
2177
|
+
throw error;
|
|
2178
|
+
}
|
|
2179
|
+
const { eventSource, threadId = (0, import_shared6.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = runtimeResponse;
|
|
2156
2180
|
logger2.debug("Event source created, creating response");
|
|
2157
2181
|
const eventStream = eventSource.processRuntimeEvents({
|
|
2158
2182
|
serverSideActions,
|
|
2159
|
-
guardrailsResult$: ((
|
|
2183
|
+
guardrailsResult$: ((_g = data.cloud) == null ? void 0 : _g.guardrails) ? guardrailsResult$ : null,
|
|
2160
2184
|
actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
|
|
2161
2185
|
// TODO-AGENTS: do not exclude ALL server side actions
|
|
2162
2186
|
(action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
|
|
@@ -2237,12 +2261,16 @@ var CopilotResolver = class {
|
|
|
2237
2261
|
}
|
|
2238
2262
|
},
|
|
2239
2263
|
error: (err) => {
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
}
|
|
2264
|
+
var _a2, _b2;
|
|
2265
|
+
if (((_a2 = err == null ? void 0 : err.name) == null ? void 0 : _a2.includes("CopilotKit")) || ((_b2 = err == null ? void 0 : err.extensions) == null ? void 0 : _b2.visibility)) {
|
|
2266
|
+
responseStatus$.next(new UnknownErrorResponse({
|
|
2267
|
+
description: err.message || "Agent error occurred"
|
|
2268
|
+
}));
|
|
2269
|
+
} else {
|
|
2270
|
+
responseStatus$.next(new UnknownErrorResponse({
|
|
2271
|
+
description: `An unknown error has occurred in the event stream`
|
|
2272
|
+
}));
|
|
2273
|
+
}
|
|
2246
2274
|
eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
|
|
2247
2275
|
stop();
|
|
2248
2276
|
},
|
|
@@ -2486,13 +2514,23 @@ var CopilotResolver = class {
|
|
|
2486
2514
|
}
|
|
2487
2515
|
},
|
|
2488
2516
|
error: (err) => {
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2517
|
+
var _a3, _b2, _c2, _d2, _e2, _f2;
|
|
2518
|
+
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)) {
|
|
2519
|
+
responseStatus$.next(new UnknownErrorResponse({
|
|
2520
|
+
description: err.message || "Agent error occurred",
|
|
2521
|
+
// Include original error information for frontend to extract
|
|
2522
|
+
originalError: {
|
|
2523
|
+
code: err.code || ((_b2 = err.extensions) == null ? void 0 : _b2.code),
|
|
2524
|
+
statusCode: err.statusCode || ((_c2 = err.extensions) == null ? void 0 : _c2.statusCode),
|
|
2525
|
+
severity: err.severity || ((_d2 = err.extensions) == null ? void 0 : _d2.severity),
|
|
2526
|
+
visibility: err.visibility || ((_e2 = err.extensions) == null ? void 0 : _e2.visibility),
|
|
2527
|
+
originalErrorType: err.originalErrorType || ((_f2 = err.extensions) == null ? void 0 : _f2.originalErrorType),
|
|
2528
|
+
extensions: err.extensions
|
|
2529
|
+
}
|
|
2530
|
+
}));
|
|
2493
2531
|
eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
|
|
2494
2532
|
rejectOutputMessagesPromise(err);
|
|
2495
|
-
stopStreamingMessages(
|
|
2533
|
+
stopStreamingMessages();
|
|
2496
2534
|
return;
|
|
2497
2535
|
}
|
|
2498
2536
|
responseStatus$.next(new UnknownErrorResponse({
|
|
@@ -2697,9 +2735,9 @@ function _ts_param2(paramIndex, decorator) {
|
|
|
2697
2735
|
__name(_ts_param2, "_ts_param");
|
|
2698
2736
|
var StateResolver = class {
|
|
2699
2737
|
async loadAgentState(ctx, data) {
|
|
2700
|
-
const agents = await ctx._copilotkit.runtime.
|
|
2701
|
-
const
|
|
2702
|
-
if (!
|
|
2738
|
+
const agents = await ctx._copilotkit.runtime.getAllAgents(ctx);
|
|
2739
|
+
const hasAgent = agents.some((agent) => agent.name === data.agentName);
|
|
2740
|
+
if (!hasAgent) {
|
|
2703
2741
|
throw new import_shared8.CopilotKitAgentDiscoveryError({
|
|
2704
2742
|
agentName: data.agentName,
|
|
2705
2743
|
availableAgents: agents.map((a) => ({
|
|
@@ -2730,6 +2768,7 @@ StateResolver = _ts_decorate22([
|
|
|
2730
2768
|
|
|
2731
2769
|
// src/lib/integrations/shared.ts
|
|
2732
2770
|
var packageJson2 = __toESM(require_package());
|
|
2771
|
+
var import_shared9 = require("@copilotkit/shared");
|
|
2733
2772
|
var logger = createLogger();
|
|
2734
2773
|
var addCustomHeaderPlugin = {
|
|
2735
2774
|
onResponse({ response }) {
|
|
@@ -2794,6 +2833,13 @@ function getCommonConfig(options) {
|
|
|
2794
2833
|
serviceAdapter: options.serviceAdapter.constructor.name
|
|
2795
2834
|
}
|
|
2796
2835
|
});
|
|
2836
|
+
const userErrorCodes = [
|
|
2837
|
+
import_shared9.CopilotKitErrorCode.AGENT_NOT_FOUND,
|
|
2838
|
+
import_shared9.CopilotKitErrorCode.API_NOT_FOUND,
|
|
2839
|
+
import_shared9.CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND,
|
|
2840
|
+
import_shared9.CopilotKitErrorCode.CONFIGURATION_ERROR,
|
|
2841
|
+
import_shared9.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR
|
|
2842
|
+
];
|
|
2797
2843
|
return {
|
|
2798
2844
|
logging: createLogger({
|
|
2799
2845
|
component: "Yoga GraphQL",
|
|
@@ -2804,7 +2850,25 @@ function getCommonConfig(options) {
|
|
|
2804
2850
|
(0, import_plugin_defer_stream.useDeferStream)(),
|
|
2805
2851
|
addCustomHeaderPlugin
|
|
2806
2852
|
],
|
|
2807
|
-
context: (ctx) => createContext(ctx, options, contextLogger, options.properties)
|
|
2853
|
+
context: (ctx) => createContext(ctx, options, contextLogger, options.properties),
|
|
2854
|
+
// Suppress logging for user configuration errors
|
|
2855
|
+
maskedErrors: {
|
|
2856
|
+
maskError: (error, message, isDev) => {
|
|
2857
|
+
const originalError = error.originalError || error;
|
|
2858
|
+
const extensions = error.extensions;
|
|
2859
|
+
const errorCode = extensions == null ? void 0 : extensions.code;
|
|
2860
|
+
if (errorCode && userErrorCodes.includes(errorCode)) {
|
|
2861
|
+
console.debug("User configuration error:", error.message);
|
|
2862
|
+
return error;
|
|
2863
|
+
}
|
|
2864
|
+
if (originalError instanceof import_shared9.CopilotKitError && userErrorCodes.includes(originalError.code)) {
|
|
2865
|
+
console.debug("User configuration error:", error.message);
|
|
2866
|
+
return error;
|
|
2867
|
+
}
|
|
2868
|
+
console.error("Application error:", error);
|
|
2869
|
+
return error;
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2808
2872
|
};
|
|
2809
2873
|
}
|
|
2810
2874
|
__name(getCommonConfig, "getCommonConfig");
|