@copilotkit/runtime 1.5.15-next.7 → 1.5.15-next.8

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/__snapshots__/schema/schema.graphql +14 -1
  3. package/dist/{chunk-F4WILQ32.mjs → chunk-253HES6R.mjs} +2 -2
  4. package/dist/{chunk-BUEAVIXA.mjs → chunk-5EJIMI36.mjs} +2 -2
  5. package/dist/{chunk-OMS5GY45.mjs → chunk-HG6ZQKQW.mjs} +538 -416
  6. package/dist/chunk-HG6ZQKQW.mjs.map +1 -0
  7. package/dist/{chunk-65VBDTR4.mjs → chunk-R7GOSVTA.mjs} +2 -2
  8. package/dist/{copilot-runtime-a113045f.d.ts → copilot-runtime-3e7f1c7b.d.ts} +5 -4
  9. package/dist/graphql/types/converted/index.d.ts +1 -1
  10. package/dist/{groq-adapter-248058e8.d.ts → groq-adapter-3b894689.d.ts} +1 -1
  11. package/dist/{index-a7f37670.d.ts → index-f6d1f30b.d.ts} +1 -1
  12. package/dist/index.d.ts +4 -4
  13. package/dist/index.js +1283 -1161
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +4 -4
  16. package/dist/{langserve-9580bd66.d.ts → langserve-3a591089.d.ts} +11 -3
  17. package/dist/lib/index.d.ts +4 -4
  18. package/dist/lib/index.js +1283 -1161
  19. package/dist/lib/index.js.map +1 -1
  20. package/dist/lib/index.mjs +4 -4
  21. package/dist/lib/integrations/index.d.ts +4 -4
  22. package/dist/lib/integrations/index.js +493 -400
  23. package/dist/lib/integrations/index.js.map +1 -1
  24. package/dist/lib/integrations/index.mjs +4 -4
  25. package/dist/lib/integrations/nest/index.d.ts +3 -3
  26. package/dist/lib/integrations/nest/index.js +493 -400
  27. package/dist/lib/integrations/nest/index.js.map +1 -1
  28. package/dist/lib/integrations/nest/index.mjs +2 -2
  29. package/dist/lib/integrations/node-express/index.d.ts +3 -3
  30. package/dist/lib/integrations/node-express/index.js +493 -400
  31. package/dist/lib/integrations/node-express/index.js.map +1 -1
  32. package/dist/lib/integrations/node-express/index.mjs +2 -2
  33. package/dist/lib/integrations/node-http/index.d.ts +3 -3
  34. package/dist/lib/integrations/node-http/index.js +493 -400
  35. package/dist/lib/integrations/node-http/index.js.map +1 -1
  36. package/dist/lib/integrations/node-http/index.mjs +1 -1
  37. package/dist/service-adapters/index.d.ts +4 -4
  38. package/package.json +2 -2
  39. package/src/agents/langgraph/event-source.ts +7 -0
  40. package/src/agents/langgraph/events.ts +11 -1
  41. package/src/graphql/inputs/meta-event.input.ts +4 -3
  42. package/src/graphql/resolvers/copilot.resolver.ts +44 -1
  43. package/src/graphql/types/copilot-response.type.ts +1 -3
  44. package/src/graphql/types/meta-events.type.ts +41 -1
  45. package/src/lib/runtime/remote-lg-action.ts +44 -19
  46. package/src/service-adapters/events.ts +8 -2
  47. package/dist/chunk-OMS5GY45.mjs.map +0 -1
  48. /package/dist/{chunk-F4WILQ32.mjs.map → chunk-253HES6R.mjs.map} +0 -0
  49. /package/dist/{chunk-BUEAVIXA.mjs.map → chunk-5EJIMI36.mjs.map} +0 -0
  50. /package/dist/{chunk-65VBDTR4.mjs.map → chunk-R7GOSVTA.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ var require_package = __commonJS({
44
44
  publishConfig: {
45
45
  access: "public"
46
46
  },
47
- version: "1.5.15-next.7",
47
+ version: "1.5.15-next.8",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -1591,10 +1591,12 @@ var LangGraphEventTypes;
1591
1591
  LangGraphEventTypes2["OnCopilotKitEmitToolCall"] = "on_copilotkit_emit_tool_call";
1592
1592
  LangGraphEventTypes2["OnCustomEvent"] = "on_custom_event";
1593
1593
  LangGraphEventTypes2["OnInterrupt"] = "on_interrupt";
1594
+ LangGraphEventTypes2["OnCopilotKitInterrupt"] = "on_copilotkit_interrupt";
1594
1595
  })(LangGraphEventTypes || (LangGraphEventTypes = {}));
1595
1596
  var MetaEventNames;
1596
1597
  (function(MetaEventNames2) {
1597
1598
  MetaEventNames2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1599
+ MetaEventNames2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1598
1600
  })(MetaEventNames || (MetaEventNames = {}));
1599
1601
  var CustomEventNames;
1600
1602
  (function(CustomEventNames2) {
@@ -1699,6 +1701,13 @@ var RemoteLangGraphEventSource = class {
1699
1701
  value: acc.event.value
1700
1702
  });
1701
1703
  }
1704
+ if (acc.event.event === LangGraphEventTypes.OnCopilotKitInterrupt) {
1705
+ events.push({
1706
+ type: RuntimeEventTypes.MetaEvent,
1707
+ name: RuntimeMetaEventName.CopilotKitLangGraphInterruptEvent,
1708
+ data: acc.event.data
1709
+ });
1710
+ }
1702
1711
  const responseMetadata = this.getResponseMetadata(acc.event);
1703
1712
  if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls" && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)) {
1704
1713
  events.push({
@@ -1867,6 +1876,12 @@ var ActionInputAvailability;
1867
1876
  });
1868
1877
 
1869
1878
  // src/graphql/types/meta-events.type.ts
1879
+ var import_type_graphql6 = require("type-graphql");
1880
+
1881
+ // src/graphql/types/copilot-response.type.ts
1882
+ var import_type_graphql5 = require("type-graphql");
1883
+
1884
+ // src/graphql/types/message-status.type.ts
1870
1885
  var import_type_graphql2 = require("type-graphql");
1871
1886
  function _ts_decorate(decorators, target, key, desc) {
1872
1887
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1884,151 +1899,634 @@ function _ts_metadata(k, v) {
1884
1899
  return Reflect.metadata(k, v);
1885
1900
  }
1886
1901
  __name(_ts_metadata, "_ts_metadata");
1887
- var MetaEventName;
1888
- (function(MetaEventName2) {
1889
- MetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1890
- })(MetaEventName || (MetaEventName = {}));
1891
- (0, import_type_graphql2.registerEnumType)(MetaEventName, {
1892
- name: "MetaEventName",
1893
- description: "Meta event types"
1902
+ var MessageStatusCode;
1903
+ (function(MessageStatusCode2) {
1904
+ MessageStatusCode2["Pending"] = "pending";
1905
+ MessageStatusCode2["Success"] = "success";
1906
+ MessageStatusCode2["Failed"] = "failed";
1907
+ })(MessageStatusCode || (MessageStatusCode = {}));
1908
+ (0, import_type_graphql2.registerEnumType)(MessageStatusCode, {
1909
+ name: "MessageStatusCode"
1894
1910
  });
1895
- var BaseMetaEvent = class {
1896
- type = "MetaEvent";
1897
- name;
1898
- };
1899
- __name(BaseMetaEvent, "BaseMetaEvent");
1900
- _ts_decorate([
1901
- (0, import_type_graphql2.Field)(() => String),
1902
- _ts_metadata("design:type", String)
1903
- ], BaseMetaEvent.prototype, "type", void 0);
1911
+ var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
1912
+ code;
1913
+ }, "BaseMessageStatus");
1904
1914
  _ts_decorate([
1905
- (0, import_type_graphql2.Field)(() => MetaEventName),
1915
+ (0, import_type_graphql2.Field)(() => MessageStatusCode),
1906
1916
  _ts_metadata("design:type", String)
1907
- ], BaseMetaEvent.prototype, "name", void 0);
1908
- BaseMetaEvent = _ts_decorate([
1909
- (0, import_type_graphql2.InterfaceType)()
1910
- ], BaseMetaEvent);
1911
- var LangGraphInterruptEvent = class {
1912
- name = "LangGraphInterruptEvent";
1913
- value;
1914
- response;
1917
+ ], BaseMessageStatus.prototype, "code", void 0);
1918
+ BaseMessageStatus = _ts_decorate([
1919
+ (0, import_type_graphql2.ObjectType)()
1920
+ ], BaseMessageStatus);
1921
+ var PendingMessageStatus = class extends BaseMessageStatus {
1922
+ code = "pending";
1915
1923
  };
1916
- __name(LangGraphInterruptEvent, "LangGraphInterruptEvent");
1917
- _ts_decorate([
1918
- (0, import_type_graphql2.Field)(() => MetaEventName),
1919
- _ts_metadata("design:type", typeof MetaEventName === "undefined" || false ? Object : "LangGraphInterruptEvent")
1920
- ], LangGraphInterruptEvent.prototype, "name", void 0);
1924
+ __name(PendingMessageStatus, "PendingMessageStatus");
1925
+ PendingMessageStatus = _ts_decorate([
1926
+ (0, import_type_graphql2.ObjectType)()
1927
+ ], PendingMessageStatus);
1928
+ var SuccessMessageStatus = class extends BaseMessageStatus {
1929
+ code = "success";
1930
+ };
1931
+ __name(SuccessMessageStatus, "SuccessMessageStatus");
1932
+ SuccessMessageStatus = _ts_decorate([
1933
+ (0, import_type_graphql2.ObjectType)()
1934
+ ], SuccessMessageStatus);
1935
+ var FailedMessageStatus = class extends BaseMessageStatus {
1936
+ code = "failed";
1937
+ reason;
1938
+ };
1939
+ __name(FailedMessageStatus, "FailedMessageStatus");
1921
1940
  _ts_decorate([
1922
1941
  (0, import_type_graphql2.Field)(() => String),
1923
1942
  _ts_metadata("design:type", String)
1924
- ], LangGraphInterruptEvent.prototype, "value", void 0);
1925
- _ts_decorate([
1926
- (0, import_type_graphql2.Field)(() => String, {
1943
+ ], FailedMessageStatus.prototype, "reason", void 0);
1944
+ FailedMessageStatus = _ts_decorate([
1945
+ (0, import_type_graphql2.ObjectType)()
1946
+ ], FailedMessageStatus);
1947
+ var MessageStatusUnion = (0, import_type_graphql2.createUnionType)({
1948
+ name: "MessageStatus",
1949
+ types: () => [
1950
+ PendingMessageStatus,
1951
+ SuccessMessageStatus,
1952
+ FailedMessageStatus
1953
+ ]
1954
+ });
1955
+
1956
+ // src/graphql/types/response-status.type.ts
1957
+ var import_graphql_scalars = require("graphql-scalars");
1958
+ var import_type_graphql3 = require("type-graphql");
1959
+ function _ts_decorate2(decorators, target, key, desc) {
1960
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1961
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1962
+ r = Reflect.decorate(decorators, target, key, desc);
1963
+ else
1964
+ for (var i = decorators.length - 1; i >= 0; i--)
1965
+ if (d = decorators[i])
1966
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1967
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1968
+ }
1969
+ __name(_ts_decorate2, "_ts_decorate");
1970
+ function _ts_metadata2(k, v) {
1971
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1972
+ return Reflect.metadata(k, v);
1973
+ }
1974
+ __name(_ts_metadata2, "_ts_metadata");
1975
+ var ResponseStatusCode;
1976
+ (function(ResponseStatusCode2) {
1977
+ ResponseStatusCode2["Pending"] = "pending";
1978
+ ResponseStatusCode2["Success"] = "success";
1979
+ ResponseStatusCode2["Failed"] = "failed";
1980
+ })(ResponseStatusCode || (ResponseStatusCode = {}));
1981
+ (0, import_type_graphql3.registerEnumType)(ResponseStatusCode, {
1982
+ name: "ResponseStatusCode"
1983
+ });
1984
+ var BaseResponseStatus = /* @__PURE__ */ __name(class BaseResponseStatus2 {
1985
+ code;
1986
+ }, "BaseResponseStatus");
1987
+ _ts_decorate2([
1988
+ (0, import_type_graphql3.Field)(() => ResponseStatusCode),
1989
+ _ts_metadata2("design:type", String)
1990
+ ], BaseResponseStatus.prototype, "code", void 0);
1991
+ BaseResponseStatus = _ts_decorate2([
1992
+ (0, import_type_graphql3.InterfaceType)({
1993
+ resolveType(value) {
1994
+ if (value.code === "success") {
1995
+ return SuccessResponseStatus;
1996
+ } else if (value.code === "failed") {
1997
+ return FailedResponseStatus;
1998
+ } else if (value.code === "pending") {
1999
+ return PendingResponseStatus;
2000
+ }
2001
+ return void 0;
2002
+ }
2003
+ }),
2004
+ (0, import_type_graphql3.ObjectType)()
2005
+ ], BaseResponseStatus);
2006
+ var PendingResponseStatus = class extends BaseResponseStatus {
2007
+ code = "pending";
2008
+ };
2009
+ __name(PendingResponseStatus, "PendingResponseStatus");
2010
+ PendingResponseStatus = _ts_decorate2([
2011
+ (0, import_type_graphql3.ObjectType)({
2012
+ implements: BaseResponseStatus
2013
+ })
2014
+ ], PendingResponseStatus);
2015
+ var SuccessResponseStatus = class extends BaseResponseStatus {
2016
+ code = "success";
2017
+ };
2018
+ __name(SuccessResponseStatus, "SuccessResponseStatus");
2019
+ SuccessResponseStatus = _ts_decorate2([
2020
+ (0, import_type_graphql3.ObjectType)({
2021
+ implements: BaseResponseStatus
2022
+ })
2023
+ ], SuccessResponseStatus);
2024
+ var FailedResponseStatusReason;
2025
+ (function(FailedResponseStatusReason2) {
2026
+ FailedResponseStatusReason2["GUARDRAILS_VALIDATION_FAILED"] = "GUARDRAILS_VALIDATION_FAILED";
2027
+ FailedResponseStatusReason2["MESSAGE_STREAM_INTERRUPTED"] = "MESSAGE_STREAM_INTERRUPTED";
2028
+ FailedResponseStatusReason2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
2029
+ })(FailedResponseStatusReason || (FailedResponseStatusReason = {}));
2030
+ (0, import_type_graphql3.registerEnumType)(FailedResponseStatusReason, {
2031
+ name: "FailedResponseStatusReason"
2032
+ });
2033
+ var FailedResponseStatus = class extends BaseResponseStatus {
2034
+ code = "failed";
2035
+ reason;
2036
+ details = null;
2037
+ };
2038
+ __name(FailedResponseStatus, "FailedResponseStatus");
2039
+ _ts_decorate2([
2040
+ (0, import_type_graphql3.Field)(() => FailedResponseStatusReason),
2041
+ _ts_metadata2("design:type", String)
2042
+ ], FailedResponseStatus.prototype, "reason", void 0);
2043
+ _ts_decorate2([
2044
+ (0, import_type_graphql3.Field)(() => import_graphql_scalars.GraphQLJSON, {
1927
2045
  nullable: true
1928
2046
  }),
1929
- _ts_metadata("design:type", String)
1930
- ], LangGraphInterruptEvent.prototype, "response", void 0);
1931
- LangGraphInterruptEvent = _ts_decorate([
1932
- (0, import_type_graphql2.ObjectType)({
1933
- implements: BaseMetaEvent
2047
+ _ts_metadata2("design:type", typeof Record === "undefined" ? Object : Record)
2048
+ ], FailedResponseStatus.prototype, "details", void 0);
2049
+ FailedResponseStatus = _ts_decorate2([
2050
+ (0, import_type_graphql3.ObjectType)({
2051
+ implements: BaseResponseStatus
1934
2052
  })
1935
- ], LangGraphInterruptEvent);
2053
+ ], FailedResponseStatus);
2054
+ var ResponseStatusUnion = (0, import_type_graphql3.createUnionType)({
2055
+ name: "ResponseStatus",
2056
+ types: () => [
2057
+ PendingResponseStatus,
2058
+ SuccessResponseStatus,
2059
+ FailedResponseStatus
2060
+ ]
2061
+ });
1936
2062
 
1937
- // src/lib/runtime/remote-lg-action.ts
1938
- async function execute(args) {
1939
- return new ReadableStream({
1940
- async start(controller) {
1941
- try {
1942
- await streamEvents(controller, args);
1943
- controller.close();
1944
- } catch (err) {
1945
- }
1946
- }
1947
- });
2063
+ // src/graphql/types/extensions-response.type.ts
2064
+ var import_type_graphql4 = require("type-graphql");
2065
+ function _ts_decorate3(decorators, target, key, desc) {
2066
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2067
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2068
+ r = Reflect.decorate(decorators, target, key, desc);
2069
+ else
2070
+ for (var i = decorators.length - 1; i >= 0; i--)
2071
+ if (d = decorators[i])
2072
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2073
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1948
2074
  }
1949
- __name(execute, "execute");
1950
- async function streamEvents(controller, args) {
1951
- var _a, _b, _c, _d, _e, _f, _g, _h;
1952
- const { deploymentUrl, langsmithApiKey, threadId: argsInitialThreadId, agent, nodeName: initialNodeName, state: initialState, messages, actions, logger: logger2, properties, metaEvents } = args;
1953
- let nodeName = initialNodeName;
1954
- let state = initialState;
1955
- const { name, assistantId: initialAssistantId } = agent;
1956
- const propertyHeaders = properties.authorization ? {
1957
- authorization: `Bearer ${properties.authorization}`
1958
- } : null;
1959
- const client = new import_langgraph_sdk.Client({
1960
- apiUrl: deploymentUrl,
1961
- apiKey: langsmithApiKey,
1962
- defaultHeaders: {
1963
- ...propertyHeaders
1964
- }
1965
- });
1966
- let threadId = argsInitialThreadId ?? (0, import_shared10.randomUUID)();
1967
- if (argsInitialThreadId && argsInitialThreadId.startsWith("ck-")) {
1968
- threadId = argsInitialThreadId.substring(3);
1969
- }
1970
- if (!(0, import_shared10.isValidUUID)(threadId)) {
1971
- console.warn(`Cannot use the threadId ${threadId} with LangGraph Platform. Must be a valid UUID.`);
1972
- }
1973
- let wasInitiatedWithExistingThread = true;
1974
- try {
1975
- await client.threads.get(threadId);
1976
- } catch (error) {
1977
- wasInitiatedWithExistingThread = false;
1978
- await client.threads.create({
1979
- threadId
1980
- });
1981
- }
1982
- let agentState = {
1983
- values: {}
1984
- };
1985
- if (wasInitiatedWithExistingThread) {
1986
- agentState = await client.threads.getState(threadId);
1987
- }
1988
- const agentStateValues = agentState.values;
1989
- state.messages = agentStateValues.messages;
1990
- const mode = threadId && nodeName != "__end__" && nodeName != void 0 && nodeName != null ? "continue" : "start";
1991
- let formattedMessages = [];
1992
- try {
1993
- formattedMessages = copilotkitMessagesToLangChain(messages);
1994
- } catch (e) {
1995
- logger2.error(e, `Error event thrown: ${e.message}`);
1996
- }
1997
- state = langGraphDefaultMergeState(state, formattedMessages, actions, name);
1998
- const lgInterruptEvent = metaEvents == null ? void 0 : metaEvents.find((ev) => ev.name === MetaEventName.LangGraphInterruptEvent);
1999
- if (mode === "continue" && !lgInterruptEvent) {
2000
- await client.threads.updateState(threadId, {
2001
- values: state,
2002
- asNode: nodeName
2003
- });
2004
- }
2005
- let streamInfo = {
2006
- hashedLgcKey: (0, import_node_crypto.createHash)("sha256").update(langsmithApiKey).digest("hex")
2007
- };
2008
- const assistants = await client.assistants.search();
2009
- const retrievedAssistant = assistants.find((a) => a.name === name || a.assistant_id === initialAssistantId);
2010
- if (!retrievedAssistant) {
2011
- telemetry_client_default.capture("oss.runtime.agent_execution_stream_errored", {
2012
- ...streamInfo,
2013
- error: `Found no assistants for given information, while ${assistants.length} assistants exists`
2014
- });
2015
- console.error(`
2016
- No agent found for the agent name specified in CopilotKit provider
2017
- Please check your available agents or provide an agent ID in the LangGraph Platform endpoint definition.
2018
-
2019
-
2020
- These are the available agents: [${assistants.map((a) => `${a.name} (ID: ${a.assistant_id})`).join(", ")}]
2021
- `);
2022
- throw new Error("No agent id found");
2075
+ __name(_ts_decorate3, "_ts_decorate");
2076
+ function _ts_metadata3(k, v) {
2077
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2078
+ return Reflect.metadata(k, v);
2079
+ }
2080
+ __name(_ts_metadata3, "_ts_metadata");
2081
+ var ExtensionsResponse = class {
2082
+ openaiAssistantAPI;
2083
+ };
2084
+ __name(ExtensionsResponse, "ExtensionsResponse");
2085
+ _ts_decorate3([
2086
+ (0, import_type_graphql4.Field)(() => OpenAIApiAssistantAPIResponse, {
2087
+ nullable: true
2088
+ }),
2089
+ _ts_metadata3("design:type", typeof OpenAIApiAssistantAPIResponse === "undefined" ? Object : OpenAIApiAssistantAPIResponse)
2090
+ ], ExtensionsResponse.prototype, "openaiAssistantAPI", void 0);
2091
+ ExtensionsResponse = _ts_decorate3([
2092
+ (0, import_type_graphql4.ObjectType)()
2093
+ ], ExtensionsResponse);
2094
+ var OpenAIApiAssistantAPIResponse = class {
2095
+ runId;
2096
+ threadId;
2097
+ };
2098
+ __name(OpenAIApiAssistantAPIResponse, "OpenAIApiAssistantAPIResponse");
2099
+ _ts_decorate3([
2100
+ (0, import_type_graphql4.Field)(() => String, {
2101
+ nullable: true
2102
+ }),
2103
+ _ts_metadata3("design:type", String)
2104
+ ], OpenAIApiAssistantAPIResponse.prototype, "runId", void 0);
2105
+ _ts_decorate3([
2106
+ (0, import_type_graphql4.Field)(() => String, {
2107
+ nullable: true
2108
+ }),
2109
+ _ts_metadata3("design:type", String)
2110
+ ], OpenAIApiAssistantAPIResponse.prototype, "threadId", void 0);
2111
+ OpenAIApiAssistantAPIResponse = _ts_decorate3([
2112
+ (0, import_type_graphql4.ObjectType)()
2113
+ ], OpenAIApiAssistantAPIResponse);
2114
+
2115
+ // src/graphql/types/copilot-response.type.ts
2116
+ function _ts_decorate4(decorators, target, key, desc) {
2117
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2118
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2119
+ r = Reflect.decorate(decorators, target, key, desc);
2120
+ else
2121
+ for (var i = decorators.length - 1; i >= 0; i--)
2122
+ if (d = decorators[i])
2123
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2124
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2125
+ }
2126
+ __name(_ts_decorate4, "_ts_decorate");
2127
+ function _ts_metadata4(k, v) {
2128
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2129
+ return Reflect.metadata(k, v);
2130
+ }
2131
+ __name(_ts_metadata4, "_ts_metadata");
2132
+ var BaseMessageOutput = class {
2133
+ id;
2134
+ createdAt;
2135
+ status;
2136
+ };
2137
+ __name(BaseMessageOutput, "BaseMessageOutput");
2138
+ _ts_decorate4([
2139
+ (0, import_type_graphql5.Field)(() => String),
2140
+ _ts_metadata4("design:type", String)
2141
+ ], BaseMessageOutput.prototype, "id", void 0);
2142
+ _ts_decorate4([
2143
+ (0, import_type_graphql5.Field)(() => Date),
2144
+ _ts_metadata4("design:type", typeof Date === "undefined" ? Object : Date)
2145
+ ], BaseMessageOutput.prototype, "createdAt", void 0);
2146
+ _ts_decorate4([
2147
+ (0, import_type_graphql5.Field)(() => MessageStatusUnion),
2148
+ _ts_metadata4("design:type", Object)
2149
+ ], BaseMessageOutput.prototype, "status", void 0);
2150
+ BaseMessageOutput = _ts_decorate4([
2151
+ (0, import_type_graphql5.InterfaceType)({
2152
+ resolveType(value) {
2153
+ if (value.hasOwnProperty("content")) {
2154
+ return TextMessageOutput;
2155
+ } else if (value.hasOwnProperty("name")) {
2156
+ return ActionExecutionMessageOutput;
2157
+ } else if (value.hasOwnProperty("result")) {
2158
+ return ResultMessageOutput;
2159
+ } else if (value.hasOwnProperty("state")) {
2160
+ return AgentStateMessageOutput;
2161
+ }
2162
+ return void 0;
2163
+ }
2164
+ })
2165
+ ], BaseMessageOutput);
2166
+ var TextMessageOutput = class {
2167
+ role;
2168
+ content;
2169
+ parentMessageId;
2170
+ };
2171
+ __name(TextMessageOutput, "TextMessageOutput");
2172
+ _ts_decorate4([
2173
+ (0, import_type_graphql5.Field)(() => MessageRole),
2174
+ _ts_metadata4("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
2175
+ ], TextMessageOutput.prototype, "role", void 0);
2176
+ _ts_decorate4([
2177
+ (0, import_type_graphql5.Field)(() => [
2178
+ String
2179
+ ]),
2180
+ _ts_metadata4("design:type", Array)
2181
+ ], TextMessageOutput.prototype, "content", void 0);
2182
+ _ts_decorate4([
2183
+ (0, import_type_graphql5.Field)(() => String, {
2184
+ nullable: true
2185
+ }),
2186
+ _ts_metadata4("design:type", String)
2187
+ ], TextMessageOutput.prototype, "parentMessageId", void 0);
2188
+ TextMessageOutput = _ts_decorate4([
2189
+ (0, import_type_graphql5.ObjectType)({
2190
+ implements: BaseMessageOutput
2191
+ })
2192
+ ], TextMessageOutput);
2193
+ var ActionExecutionMessageOutput = class {
2194
+ name;
2195
+ scope;
2196
+ arguments;
2197
+ parentMessageId;
2198
+ };
2199
+ __name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
2200
+ _ts_decorate4([
2201
+ (0, import_type_graphql5.Field)(() => String),
2202
+ _ts_metadata4("design:type", String)
2203
+ ], ActionExecutionMessageOutput.prototype, "name", void 0);
2204
+ _ts_decorate4([
2205
+ (0, import_type_graphql5.Field)(() => String, {
2206
+ nullable: true,
2207
+ deprecationReason: "This field will be removed in a future version"
2208
+ }),
2209
+ _ts_metadata4("design:type", String)
2210
+ ], ActionExecutionMessageOutput.prototype, "scope", void 0);
2211
+ _ts_decorate4([
2212
+ (0, import_type_graphql5.Field)(() => [
2213
+ String
2214
+ ]),
2215
+ _ts_metadata4("design:type", Array)
2216
+ ], ActionExecutionMessageOutput.prototype, "arguments", void 0);
2217
+ _ts_decorate4([
2218
+ (0, import_type_graphql5.Field)(() => String, {
2219
+ nullable: true
2220
+ }),
2221
+ _ts_metadata4("design:type", String)
2222
+ ], ActionExecutionMessageOutput.prototype, "parentMessageId", void 0);
2223
+ ActionExecutionMessageOutput = _ts_decorate4([
2224
+ (0, import_type_graphql5.ObjectType)({
2225
+ implements: BaseMessageOutput
2226
+ })
2227
+ ], ActionExecutionMessageOutput);
2228
+ var ResultMessageOutput = class {
2229
+ actionExecutionId;
2230
+ actionName;
2231
+ result;
2232
+ };
2233
+ __name(ResultMessageOutput, "ResultMessageOutput");
2234
+ _ts_decorate4([
2235
+ (0, import_type_graphql5.Field)(() => String),
2236
+ _ts_metadata4("design:type", String)
2237
+ ], ResultMessageOutput.prototype, "actionExecutionId", void 0);
2238
+ _ts_decorate4([
2239
+ (0, import_type_graphql5.Field)(() => String),
2240
+ _ts_metadata4("design:type", String)
2241
+ ], ResultMessageOutput.prototype, "actionName", void 0);
2242
+ _ts_decorate4([
2243
+ (0, import_type_graphql5.Field)(() => String),
2244
+ _ts_metadata4("design:type", String)
2245
+ ], ResultMessageOutput.prototype, "result", void 0);
2246
+ ResultMessageOutput = _ts_decorate4([
2247
+ (0, import_type_graphql5.ObjectType)({
2248
+ implements: BaseMessageOutput
2249
+ })
2250
+ ], ResultMessageOutput);
2251
+ var AgentStateMessageOutput = class {
2252
+ threadId;
2253
+ agentName;
2254
+ nodeName;
2255
+ runId;
2256
+ active;
2257
+ role;
2258
+ state;
2259
+ running;
2260
+ };
2261
+ __name(AgentStateMessageOutput, "AgentStateMessageOutput");
2262
+ _ts_decorate4([
2263
+ (0, import_type_graphql5.Field)(() => String),
2264
+ _ts_metadata4("design:type", String)
2265
+ ], AgentStateMessageOutput.prototype, "threadId", void 0);
2266
+ _ts_decorate4([
2267
+ (0, import_type_graphql5.Field)(() => String),
2268
+ _ts_metadata4("design:type", String)
2269
+ ], AgentStateMessageOutput.prototype, "agentName", void 0);
2270
+ _ts_decorate4([
2271
+ (0, import_type_graphql5.Field)(() => String),
2272
+ _ts_metadata4("design:type", String)
2273
+ ], AgentStateMessageOutput.prototype, "nodeName", void 0);
2274
+ _ts_decorate4([
2275
+ (0, import_type_graphql5.Field)(() => String),
2276
+ _ts_metadata4("design:type", String)
2277
+ ], AgentStateMessageOutput.prototype, "runId", void 0);
2278
+ _ts_decorate4([
2279
+ (0, import_type_graphql5.Field)(() => Boolean),
2280
+ _ts_metadata4("design:type", Boolean)
2281
+ ], AgentStateMessageOutput.prototype, "active", void 0);
2282
+ _ts_decorate4([
2283
+ (0, import_type_graphql5.Field)(() => MessageRole),
2284
+ _ts_metadata4("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
2285
+ ], AgentStateMessageOutput.prototype, "role", void 0);
2286
+ _ts_decorate4([
2287
+ (0, import_type_graphql5.Field)(() => String),
2288
+ _ts_metadata4("design:type", String)
2289
+ ], AgentStateMessageOutput.prototype, "state", void 0);
2290
+ _ts_decorate4([
2291
+ (0, import_type_graphql5.Field)(() => Boolean),
2292
+ _ts_metadata4("design:type", Boolean)
2293
+ ], AgentStateMessageOutput.prototype, "running", void 0);
2294
+ AgentStateMessageOutput = _ts_decorate4([
2295
+ (0, import_type_graphql5.ObjectType)({
2296
+ implements: BaseMessageOutput
2297
+ })
2298
+ ], AgentStateMessageOutput);
2299
+ var CopilotResponse = class {
2300
+ threadId;
2301
+ status;
2302
+ runId;
2303
+ messages;
2304
+ extensions;
2305
+ metaEvents;
2306
+ };
2307
+ __name(CopilotResponse, "CopilotResponse");
2308
+ _ts_decorate4([
2309
+ (0, import_type_graphql5.Field)(() => String),
2310
+ _ts_metadata4("design:type", String)
2311
+ ], CopilotResponse.prototype, "threadId", void 0);
2312
+ _ts_decorate4([
2313
+ (0, import_type_graphql5.Field)(() => ResponseStatusUnion),
2314
+ _ts_metadata4("design:type", Object)
2315
+ ], CopilotResponse.prototype, "status", void 0);
2316
+ _ts_decorate4([
2317
+ (0, import_type_graphql5.Field)({
2318
+ nullable: true
2319
+ }),
2320
+ _ts_metadata4("design:type", String)
2321
+ ], CopilotResponse.prototype, "runId", void 0);
2322
+ _ts_decorate4([
2323
+ (0, import_type_graphql5.Field)(() => [
2324
+ BaseMessageOutput
2325
+ ]),
2326
+ _ts_metadata4("design:type", Array)
2327
+ ], CopilotResponse.prototype, "messages", void 0);
2328
+ _ts_decorate4([
2329
+ (0, import_type_graphql5.Field)(() => ExtensionsResponse, {
2330
+ nullable: true
2331
+ }),
2332
+ _ts_metadata4("design:type", typeof ExtensionsResponse === "undefined" ? Object : ExtensionsResponse)
2333
+ ], CopilotResponse.prototype, "extensions", void 0);
2334
+ _ts_decorate4([
2335
+ (0, import_type_graphql5.Field)(() => [
2336
+ BaseMetaEvent
2337
+ ], {
2338
+ nullable: true
2339
+ }),
2340
+ _ts_metadata4("design:type", Array)
2341
+ ], CopilotResponse.prototype, "metaEvents", void 0);
2342
+ CopilotResponse = _ts_decorate4([
2343
+ (0, import_type_graphql5.ObjectType)()
2344
+ ], CopilotResponse);
2345
+
2346
+ // src/graphql/types/meta-events.type.ts
2347
+ function _ts_decorate5(decorators, target, key, desc) {
2348
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2349
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2350
+ r = Reflect.decorate(decorators, target, key, desc);
2351
+ else
2352
+ for (var i = decorators.length - 1; i >= 0; i--)
2353
+ if (d = decorators[i])
2354
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2355
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2356
+ }
2357
+ __name(_ts_decorate5, "_ts_decorate");
2358
+ function _ts_metadata5(k, v) {
2359
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2360
+ return Reflect.metadata(k, v);
2361
+ }
2362
+ __name(_ts_metadata5, "_ts_metadata");
2363
+ var MetaEventName;
2364
+ (function(MetaEventName2) {
2365
+ MetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
2366
+ MetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
2367
+ })(MetaEventName || (MetaEventName = {}));
2368
+ (0, import_type_graphql6.registerEnumType)(MetaEventName, {
2369
+ name: "MetaEventName",
2370
+ description: "Meta event types"
2371
+ });
2372
+ var BaseMetaEvent = class {
2373
+ type = "MetaEvent";
2374
+ name;
2375
+ };
2376
+ __name(BaseMetaEvent, "BaseMetaEvent");
2377
+ _ts_decorate5([
2378
+ (0, import_type_graphql6.Field)(() => String),
2379
+ _ts_metadata5("design:type", String)
2380
+ ], BaseMetaEvent.prototype, "type", void 0);
2381
+ _ts_decorate5([
2382
+ (0, import_type_graphql6.Field)(() => MetaEventName),
2383
+ _ts_metadata5("design:type", String)
2384
+ ], BaseMetaEvent.prototype, "name", void 0);
2385
+ BaseMetaEvent = _ts_decorate5([
2386
+ (0, import_type_graphql6.InterfaceType)({
2387
+ resolveType(value) {
2388
+ if (value.name === "LangGraphInterruptEvent") {
2389
+ return LangGraphInterruptEvent;
2390
+ } else if (value.name === "CopilotKitLangGraphInterruptEvent") {
2391
+ return CopilotKitLangGraphInterruptEvent;
2392
+ }
2393
+ return void 0;
2394
+ }
2395
+ }),
2396
+ (0, import_type_graphql6.InterfaceType)()
2397
+ ], BaseMetaEvent);
2398
+ var CopilotKitLangGraphInterruptEventData = class {
2399
+ value;
2400
+ messages;
2401
+ };
2402
+ __name(CopilotKitLangGraphInterruptEventData, "CopilotKitLangGraphInterruptEventData");
2403
+ _ts_decorate5([
2404
+ (0, import_type_graphql6.Field)(() => String),
2405
+ _ts_metadata5("design:type", String)
2406
+ ], CopilotKitLangGraphInterruptEventData.prototype, "value", void 0);
2407
+ _ts_decorate5([
2408
+ (0, import_type_graphql6.Field)(() => [
2409
+ BaseMessageOutput
2410
+ ]),
2411
+ _ts_metadata5("design:type", Array)
2412
+ ], CopilotKitLangGraphInterruptEventData.prototype, "messages", void 0);
2413
+ CopilotKitLangGraphInterruptEventData = _ts_decorate5([
2414
+ (0, import_type_graphql6.ObjectType)()
2415
+ ], CopilotKitLangGraphInterruptEventData);
2416
+ var LangGraphInterruptEvent = class {
2417
+ name = "LangGraphInterruptEvent";
2418
+ value;
2419
+ response;
2420
+ };
2421
+ __name(LangGraphInterruptEvent, "LangGraphInterruptEvent");
2422
+ _ts_decorate5([
2423
+ (0, import_type_graphql6.Field)(() => MetaEventName),
2424
+ _ts_metadata5("design:type", typeof MetaEventName === "undefined" || false ? Object : "LangGraphInterruptEvent")
2425
+ ], LangGraphInterruptEvent.prototype, "name", void 0);
2426
+ _ts_decorate5([
2427
+ (0, import_type_graphql6.Field)(() => String),
2428
+ _ts_metadata5("design:type", String)
2429
+ ], LangGraphInterruptEvent.prototype, "value", void 0);
2430
+ _ts_decorate5([
2431
+ (0, import_type_graphql6.Field)(() => String, {
2432
+ nullable: true
2433
+ }),
2434
+ _ts_metadata5("design:type", String)
2435
+ ], LangGraphInterruptEvent.prototype, "response", void 0);
2436
+ LangGraphInterruptEvent = _ts_decorate5([
2437
+ (0, import_type_graphql6.ObjectType)({
2438
+ implements: BaseMetaEvent
2439
+ })
2440
+ ], LangGraphInterruptEvent);
2441
+ var CopilotKitLangGraphInterruptEvent = class {
2442
+ name = "CopilotKitLangGraphInterruptEvent";
2443
+ data;
2444
+ response;
2445
+ };
2446
+ __name(CopilotKitLangGraphInterruptEvent, "CopilotKitLangGraphInterruptEvent");
2447
+ _ts_decorate5([
2448
+ (0, import_type_graphql6.Field)(() => MetaEventName),
2449
+ _ts_metadata5("design:type", typeof MetaEventName === "undefined" || false ? Object : "CopilotKitLangGraphInterruptEvent")
2450
+ ], CopilotKitLangGraphInterruptEvent.prototype, "name", void 0);
2451
+ _ts_decorate5([
2452
+ (0, import_type_graphql6.Field)(() => CopilotKitLangGraphInterruptEventData),
2453
+ _ts_metadata5("design:type", typeof CopilotKitLangGraphInterruptEventData === "undefined" ? Object : CopilotKitLangGraphInterruptEventData)
2454
+ ], CopilotKitLangGraphInterruptEvent.prototype, "data", void 0);
2455
+ _ts_decorate5([
2456
+ (0, import_type_graphql6.Field)(() => String, {
2457
+ nullable: true
2458
+ }),
2459
+ _ts_metadata5("design:type", String)
2460
+ ], CopilotKitLangGraphInterruptEvent.prototype, "response", void 0);
2461
+ CopilotKitLangGraphInterruptEvent = _ts_decorate5([
2462
+ (0, import_type_graphql6.ObjectType)({
2463
+ implements: BaseMetaEvent
2464
+ })
2465
+ ], CopilotKitLangGraphInterruptEvent);
2466
+
2467
+ // src/lib/runtime/remote-lg-action.ts
2468
+ var activeInterruptEvent = false;
2469
+ async function execute(args) {
2470
+ return new ReadableStream({
2471
+ async start(controller) {
2472
+ try {
2473
+ await streamEvents(controller, args);
2474
+ controller.close();
2475
+ } catch (err) {
2476
+ }
2477
+ }
2478
+ });
2479
+ }
2480
+ __name(execute, "execute");
2481
+ async function streamEvents(controller, args) {
2482
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2483
+ const { deploymentUrl, langsmithApiKey, threadId: argsInitialThreadId, agent, nodeName: initialNodeName, state: initialState, messages, actions, logger: logger2, properties, metaEvents } = args;
2484
+ let nodeName = initialNodeName;
2485
+ let state = initialState;
2486
+ const { name, assistantId: initialAssistantId } = agent;
2487
+ const propertyHeaders = properties.authorization ? {
2488
+ authorization: `Bearer ${properties.authorization}`
2489
+ } : null;
2490
+ const client = new import_langgraph_sdk.Client({
2491
+ apiUrl: deploymentUrl,
2492
+ apiKey: langsmithApiKey,
2493
+ defaultHeaders: {
2494
+ ...propertyHeaders
2495
+ }
2496
+ });
2497
+ let threadId = argsInitialThreadId ?? (0, import_shared10.randomUUID)();
2498
+ if (argsInitialThreadId && argsInitialThreadId.startsWith("ck-")) {
2499
+ threadId = argsInitialThreadId.substring(3);
2023
2500
  }
2024
- const assistantId = retrievedAssistant.assistant_id;
2025
- const graphInfo = await client.assistants.getGraph(assistantId);
2501
+ if (!(0, import_shared10.isValidUUID)(threadId)) {
2502
+ console.warn(`Cannot use the threadId ${threadId} with LangGraph Platform. Must be a valid UUID.`);
2503
+ }
2504
+ let wasInitiatedWithExistingThread = true;
2505
+ try {
2506
+ await client.threads.get(threadId);
2507
+ } catch (error) {
2508
+ wasInitiatedWithExistingThread = false;
2509
+ await client.threads.create({
2510
+ threadId
2511
+ });
2512
+ }
2513
+ let agentState = {
2514
+ values: {}
2515
+ };
2516
+ if (wasInitiatedWithExistingThread) {
2517
+ agentState = await client.threads.getState(threadId);
2518
+ }
2519
+ const agentStateValues = agentState.values;
2520
+ state.messages = agentStateValues.messages;
2521
+ const mode = threadId && nodeName != "__end__" && nodeName != void 0 && nodeName != null ? "continue" : "start";
2522
+ let formattedMessages = [];
2523
+ try {
2524
+ formattedMessages = copilotkitMessagesToLangChain(messages);
2525
+ } catch (e) {
2526
+ logger2.error(e, `Error event thrown: ${e.message}`);
2527
+ }
2528
+ state = langGraphDefaultMergeState(state, formattedMessages, actions, name);
2026
2529
  const streamInput = mode === "start" ? state : null;
2027
- let streamingStateExtractor = new StreamingStateExtractor([]);
2028
- let prevNodeName = null;
2029
- let emitIntermediateStateUntilEnd = null;
2030
- let shouldExit = false;
2031
- let externalRunId = null;
2032
2530
  const payload = {
2033
2531
  input: streamInput,
2034
2532
  streamMode: [
@@ -2038,16 +2536,55 @@ async function streamEvents(controller, args) {
2038
2536
  ],
2039
2537
  command: void 0
2040
2538
  };
2041
- if (lgInterruptEvent == null ? void 0 : lgInterruptEvent.response) {
2539
+ const lgInterruptMetaEvent = metaEvents == null ? void 0 : metaEvents.find((ev) => ev.name === MetaEventName.LangGraphInterruptEvent);
2540
+ if (activeInterruptEvent && !lgInterruptMetaEvent) {
2541
+ payload.command = {
2542
+ resume: formattedMessages[formattedMessages.length - 1]
2543
+ };
2544
+ }
2545
+ if (lgInterruptMetaEvent == null ? void 0 : lgInterruptMetaEvent.response) {
2042
2546
  payload.command = {
2043
- resume: lgInterruptEvent.response
2547
+ resume: lgInterruptMetaEvent.response
2044
2548
  };
2045
2549
  }
2550
+ if (mode === "continue" && !activeInterruptEvent) {
2551
+ await client.threads.updateState(threadId, {
2552
+ values: state,
2553
+ asNode: nodeName
2554
+ });
2555
+ }
2556
+ let streamInfo = {
2557
+ hashedLgcKey: (0, import_node_crypto.createHash)("sha256").update(langsmithApiKey).digest("hex")
2558
+ };
2559
+ const assistants = await client.assistants.search();
2560
+ const retrievedAssistant = assistants.find((a) => a.name === name || a.assistant_id === initialAssistantId);
2561
+ if (!retrievedAssistant) {
2562
+ telemetry_client_default.capture("oss.runtime.agent_execution_stream_errored", {
2563
+ ...streamInfo,
2564
+ error: `Found no assistants for given information, while ${assistants.length} assistants exists`
2565
+ });
2566
+ console.error(`
2567
+ No agent found for the agent name specified in CopilotKit provider
2568
+ Please check your available agents or provide an agent ID in the LangGraph Platform endpoint definition.
2569
+
2570
+
2571
+ These are the available agents: [${assistants.map((a) => `${a.name} (ID: ${a.assistant_id})`).join(", ")}]
2572
+ `);
2573
+ throw new Error("No agent id found");
2574
+ }
2575
+ const assistantId = retrievedAssistant.assistant_id;
2576
+ const graphInfo = await client.assistants.getGraph(assistantId);
2577
+ let streamingStateExtractor = new StreamingStateExtractor([]);
2578
+ let prevNodeName = null;
2579
+ let emitIntermediateStateUntilEnd = null;
2580
+ let shouldExit = false;
2581
+ let externalRunId = null;
2046
2582
  const streamResponse2 = client.runs.stream(threadId, assistantId, payload);
2047
2583
  const emit = /* @__PURE__ */ __name((message) => controller.enqueue(new TextEncoder().encode(message)), "emit");
2048
2584
  let latestStateValues = {};
2049
2585
  let updatedState = state;
2050
2586
  let manuallyEmittedState = null;
2587
+ activeInterruptEvent = false;
2051
2588
  try {
2052
2589
  telemetry_client_default.capture("oss.runtime.agent_execution_stream_started", {
2053
2590
  hashedLgcKey: streamInfo.hashedLgcKey
@@ -2063,11 +2600,24 @@ async function streamEvents(controller, args) {
2063
2600
  if (chunk.event === "error") {
2064
2601
  throw new Error(`Error event thrown: ${chunk.data.message}`);
2065
2602
  }
2066
- if (chunk.event === "updates" && chunk.data.__interrupt__) {
2067
- emit(JSON.stringify({
2068
- event: LangGraphEventTypes.OnInterrupt,
2069
- value: chunk.data.__interrupt__[0].value
2070
- }) + "\n");
2603
+ const interruptEvents = (_a = chunk.data) == null ? void 0 : _a.__interrupt__;
2604
+ if (interruptEvents == null ? void 0 : interruptEvents.length) {
2605
+ activeInterruptEvent = true;
2606
+ const interruptValue = interruptEvents == null ? void 0 : interruptEvents[0].value;
2607
+ if (typeof interruptValue != "string" && "__copilotkit_interrupt_value__" in interruptValue) {
2608
+ emit(JSON.stringify({
2609
+ event: LangGraphEventTypes.OnCopilotKitInterrupt,
2610
+ data: {
2611
+ value: interruptValue.__copilotkit_interrupt_value__,
2612
+ messages: langchainMessagesToCopilotKit(interruptValue.__copilotkit_messages__)
2613
+ }
2614
+ }) + "\n");
2615
+ } else {
2616
+ emit(JSON.stringify({
2617
+ event: LangGraphEventTypes.OnInterrupt,
2618
+ value: interruptValue
2619
+ }) + "\n");
2620
+ }
2071
2621
  continue;
2072
2622
  }
2073
2623
  if (chunk.event === "updates")
@@ -2082,8 +2632,8 @@ async function streamEvents(controller, args) {
2082
2632
  const runId = event.metadata.run_id;
2083
2633
  externalRunId = runId;
2084
2634
  const metadata = event.metadata;
2085
- if (((_b = (_a = event.data) == null ? void 0 : _a.output) == null ? void 0 : _b.model) != null && ((_d = (_c = event.data) == null ? void 0 : _c.output) == null ? void 0 : _d.model) != "") {
2086
- streamInfo.provider = (_f = (_e = event.data) == null ? void 0 : _e.output) == null ? void 0 : _f.model;
2635
+ if (((_c = (_b = event.data) == null ? void 0 : _b.output) == null ? void 0 : _c.model) != null && ((_e = (_d = event.data) == null ? void 0 : _d.output) == null ? void 0 : _e.model) != "") {
2636
+ streamInfo.provider = (_g = (_f = event.data) == null ? void 0 : _f.output) == null ? void 0 : _g.model;
2087
2637
  }
2088
2638
  if (metadata.langgraph_host != null && metadata.langgraph_host != "") {
2089
2639
  streamInfo.langGraphHost = metadata.langgraph_host;
@@ -2152,7 +2702,7 @@ async function streamEvents(controller, args) {
2152
2702
  emit(JSON.stringify(event) + "\n");
2153
2703
  }
2154
2704
  state = await client.threads.getState(threadId);
2155
- const interrupts = (_h = (_g = state.tasks) == null ? void 0 : _g[0]) == null ? void 0 : _h.interrupts;
2705
+ const interrupts = (_i = (_h = state.tasks) == null ? void 0 : _h[0]) == null ? void 0 : _i.interrupts;
2156
2706
  nodeName = interrupts ? nodeName : Object.keys(state.metadata.writes)[0];
2157
2707
  const isEndNode = state.next.length === 0 && !interrupts;
2158
2708
  telemetry_client_default.capture("oss.runtime.agent_execution_stream_ended", streamInfo);
@@ -2840,8 +3390,8 @@ __name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
2840
3390
  var telemetry_client_default = telemetryClient;
2841
3391
 
2842
3392
  // src/graphql/types/base/index.ts
2843
- var import_type_graphql3 = require("type-graphql");
2844
- function _ts_decorate2(decorators, target, key, desc) {
3393
+ var import_type_graphql7 = require("type-graphql");
3394
+ function _ts_decorate6(decorators, target, key, desc) {
2845
3395
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2846
3396
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2847
3397
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2851,27 +3401,27 @@ function _ts_decorate2(decorators, target, key, desc) {
2851
3401
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2852
3402
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2853
3403
  }
2854
- __name(_ts_decorate2, "_ts_decorate");
2855
- function _ts_metadata2(k, v) {
3404
+ __name(_ts_decorate6, "_ts_decorate");
3405
+ function _ts_metadata6(k, v) {
2856
3406
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2857
3407
  return Reflect.metadata(k, v);
2858
3408
  }
2859
- __name(_ts_metadata2, "_ts_metadata");
3409
+ __name(_ts_metadata6, "_ts_metadata");
2860
3410
  var BaseMessageInput = class {
2861
3411
  id;
2862
3412
  createdAt;
2863
3413
  };
2864
3414
  __name(BaseMessageInput, "BaseMessageInput");
2865
- _ts_decorate2([
2866
- (0, import_type_graphql3.Field)(() => String),
2867
- _ts_metadata2("design:type", String)
3415
+ _ts_decorate6([
3416
+ (0, import_type_graphql7.Field)(() => String),
3417
+ _ts_metadata6("design:type", String)
2868
3418
  ], BaseMessageInput.prototype, "id", void 0);
2869
- _ts_decorate2([
2870
- (0, import_type_graphql3.Field)(() => Date),
2871
- _ts_metadata2("design:type", typeof Date === "undefined" ? Object : Date)
3419
+ _ts_decorate6([
3420
+ (0, import_type_graphql7.Field)(() => Date),
3421
+ _ts_metadata6("design:type", typeof Date === "undefined" ? Object : Date)
2872
3422
  ], BaseMessageInput.prototype, "createdAt", void 0);
2873
- BaseMessageInput = _ts_decorate2([
2874
- (0, import_type_graphql3.InputType)()
3423
+ BaseMessageInput = _ts_decorate6([
3424
+ (0, import_type_graphql7.InputType)()
2875
3425
  ], BaseMessageInput);
2876
3426
 
2877
3427
  // src/graphql/types/converted/index.ts
@@ -3006,6 +3556,7 @@ var RuntimeMetaEventName;
3006
3556
  (function(RuntimeMetaEventName2) {
3007
3557
  RuntimeMetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
3008
3558
  RuntimeMetaEventName2["LangGraphInterruptResumeEvent"] = "LangGraphInterruptResumeEvent";
3559
+ RuntimeMetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
3009
3560
  })(RuntimeMetaEventName || (RuntimeMetaEventName = {}));
3010
3561
  var RuntimeEventSubject = class extends import_rxjs2.ReplaySubject {
3011
3562
  constructor() {
@@ -3595,455 +4146,121 @@ please use an LLM adapter instead.`
3595
4146
  (0, import_rxjs3.from)(stream).subscribe({
3596
4147
  next: (event) => eventStream$.next(event),
3597
4148
  error: (err) => {
3598
- console.error("Error in stream", err);
3599
- eventStream$.error(err);
3600
- eventStream$.complete();
3601
- },
3602
- complete: () => eventStream$.complete()
3603
- });
3604
- });
3605
- outputMessagesPromise.then((outputMessages) => {
3606
- var _a2;
3607
- (_a2 = this.onAfterRequest) == null ? void 0 : _a2.call(this, {
3608
- threadId,
3609
- runId: void 0,
3610
- inputMessages: messages,
3611
- outputMessages,
3612
- properties: graphqlContext.properties
3613
- });
3614
- }).catch((_error) => {
3615
- });
3616
- return {
3617
- threadId,
3618
- runId: void 0,
3619
- eventSource,
3620
- serverSideActions: [],
3621
- actionInputsWithoutAgents: allAvailableActions
3622
- };
3623
- } catch (error) {
3624
- console.error("Error getting response:", error);
3625
- throw error;
3626
- }
3627
- }
3628
- async getServerSideActions(request) {
3629
- const { messages: rawMessages, graphqlContext, agentStates, url } = request;
3630
- const inputMessages = convertGqlInputToMessages(rawMessages);
3631
- const langserveFunctions = [];
3632
- for (const chainPromise of this.langserve) {
3633
- try {
3634
- const chain = await chainPromise;
3635
- langserveFunctions.push(chain);
3636
- } catch (error) {
3637
- console.error("Error loading langserve chain:", error);
3638
- }
3639
- }
3640
- const remoteEndpointDefinitions = this.remoteEndpointDefinitions.map((endpoint) => ({
3641
- ...endpoint,
3642
- type: resolveEndpointType(endpoint)
3643
- }));
3644
- const remoteActions = await setupRemoteActions({
3645
- remoteEndpointDefinitions,
3646
- graphqlContext,
3647
- messages: inputMessages,
3648
- agentStates,
3649
- frontendUrl: url
3650
- });
3651
- const configuredActions = typeof this.actions === "function" ? this.actions({
3652
- properties: graphqlContext.properties,
3653
- url
3654
- }) : this.actions;
3655
- return [
3656
- ...configuredActions,
3657
- ...langserveFunctions,
3658
- ...remoteActions
3659
- ];
3660
- }
3661
- };
3662
- __name(CopilotRuntime, "CopilotRuntime");
3663
- function flattenToolCallsNoDuplicates(toolsByPriority) {
3664
- let allTools = [];
3665
- const allToolNames = [];
3666
- for (const tool of toolsByPriority) {
3667
- if (!allToolNames.includes(tool.name)) {
3668
- allTools.push(tool);
3669
- allToolNames.push(tool.name);
3670
- }
3671
- }
3672
- return allTools;
3673
- }
3674
- __name(flattenToolCallsNoDuplicates, "flattenToolCallsNoDuplicates");
3675
- function copilotKitEndpoint(config2) {
3676
- return {
3677
- ...config2,
3678
- type: EndpointType.CopilotKit
3679
- };
3680
- }
3681
- __name(copilotKitEndpoint, "copilotKitEndpoint");
3682
- function langGraphPlatformEndpoint(config2) {
3683
- return {
3684
- ...config2,
3685
- type: EndpointType.LangGraphPlatform
3686
- };
3687
- }
3688
- __name(langGraphPlatformEndpoint, "langGraphPlatformEndpoint");
3689
- function resolveEndpointType(endpoint) {
3690
- if (!endpoint.type) {
3691
- if ("langsmithApiKey" in endpoint && "deploymentUrl" in endpoint && "agents" in endpoint) {
3692
- return EndpointType.LangGraphPlatform;
3693
- } else {
3694
- return EndpointType.CopilotKit;
3695
- }
3696
- }
3697
- return endpoint.type;
3698
- }
3699
- __name(resolveEndpointType, "resolveEndpointType");
3700
-
3701
- // src/lib/integrations/shared.ts
3702
- var import_type_graphql26 = require("type-graphql");
3703
-
3704
- // src/graphql/resolvers/copilot.resolver.ts
3705
- var import_type_graphql20 = require("type-graphql");
3706
- var import_rxjs4 = require("rxjs");
3707
-
3708
- // src/graphql/inputs/generate-copilot-response.input.ts
3709
- var import_type_graphql14 = require("type-graphql");
3710
-
3711
- // src/graphql/inputs/message.input.ts
3712
- var import_type_graphql4 = require("type-graphql");
3713
- function _ts_decorate3(decorators, target, key, desc) {
3714
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3715
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3716
- r = Reflect.decorate(decorators, target, key, desc);
3717
- else
3718
- for (var i = decorators.length - 1; i >= 0; i--)
3719
- if (d = decorators[i])
3720
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3721
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3722
- }
3723
- __name(_ts_decorate3, "_ts_decorate");
3724
- function _ts_metadata3(k, v) {
3725
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3726
- return Reflect.metadata(k, v);
3727
- }
3728
- __name(_ts_metadata3, "_ts_metadata");
3729
- var MessageInput = class extends BaseMessageInput {
3730
- textMessage;
3731
- actionExecutionMessage;
3732
- resultMessage;
3733
- agentStateMessage;
3734
- };
3735
- __name(MessageInput, "MessageInput");
3736
- _ts_decorate3([
3737
- (0, import_type_graphql4.Field)(() => TextMessageInput, {
3738
- nullable: true
3739
- }),
3740
- _ts_metadata3("design:type", typeof TextMessageInput === "undefined" ? Object : TextMessageInput)
3741
- ], MessageInput.prototype, "textMessage", void 0);
3742
- _ts_decorate3([
3743
- (0, import_type_graphql4.Field)(() => ActionExecutionMessageInput, {
3744
- nullable: true
3745
- }),
3746
- _ts_metadata3("design:type", typeof ActionExecutionMessageInput === "undefined" ? Object : ActionExecutionMessageInput)
3747
- ], MessageInput.prototype, "actionExecutionMessage", void 0);
3748
- _ts_decorate3([
3749
- (0, import_type_graphql4.Field)(() => ResultMessageInput, {
3750
- nullable: true
3751
- }),
3752
- _ts_metadata3("design:type", typeof ResultMessageInput === "undefined" ? Object : ResultMessageInput)
3753
- ], MessageInput.prototype, "resultMessage", void 0);
3754
- _ts_decorate3([
3755
- (0, import_type_graphql4.Field)(() => AgentStateMessageInput, {
3756
- nullable: true
3757
- }),
3758
- _ts_metadata3("design:type", typeof AgentStateMessageInput === "undefined" ? Object : AgentStateMessageInput)
3759
- ], MessageInput.prototype, "agentStateMessage", void 0);
3760
- MessageInput = _ts_decorate3([
3761
- (0, import_type_graphql4.InputType)()
3762
- ], MessageInput);
3763
- var TextMessageInput = class {
3764
- content;
3765
- parentMessageId;
3766
- role;
3767
- };
3768
- __name(TextMessageInput, "TextMessageInput");
3769
- _ts_decorate3([
3770
- (0, import_type_graphql4.Field)(() => String),
3771
- _ts_metadata3("design:type", String)
3772
- ], TextMessageInput.prototype, "content", void 0);
3773
- _ts_decorate3([
3774
- (0, import_type_graphql4.Field)(() => String, {
3775
- nullable: true
3776
- }),
3777
- _ts_metadata3("design:type", String)
3778
- ], TextMessageInput.prototype, "parentMessageId", void 0);
3779
- _ts_decorate3([
3780
- (0, import_type_graphql4.Field)(() => MessageRole),
3781
- _ts_metadata3("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
3782
- ], TextMessageInput.prototype, "role", void 0);
3783
- TextMessageInput = _ts_decorate3([
3784
- (0, import_type_graphql4.InputType)()
3785
- ], TextMessageInput);
3786
- var ActionExecutionMessageInput = class {
3787
- name;
3788
- arguments;
3789
- parentMessageId;
3790
- scope;
3791
- };
3792
- __name(ActionExecutionMessageInput, "ActionExecutionMessageInput");
3793
- _ts_decorate3([
3794
- (0, import_type_graphql4.Field)(() => String),
3795
- _ts_metadata3("design:type", String)
3796
- ], ActionExecutionMessageInput.prototype, "name", void 0);
3797
- _ts_decorate3([
3798
- (0, import_type_graphql4.Field)(() => String),
3799
- _ts_metadata3("design:type", String)
3800
- ], ActionExecutionMessageInput.prototype, "arguments", void 0);
3801
- _ts_decorate3([
3802
- (0, import_type_graphql4.Field)(() => String, {
3803
- nullable: true
3804
- }),
3805
- _ts_metadata3("design:type", String)
3806
- ], ActionExecutionMessageInput.prototype, "parentMessageId", void 0);
3807
- _ts_decorate3([
3808
- (0, import_type_graphql4.Field)(() => String, {
3809
- nullable: true,
3810
- deprecationReason: "This field will be removed in a future version"
3811
- }),
3812
- _ts_metadata3("design:type", typeof String === "undefined" ? Object : String)
3813
- ], ActionExecutionMessageInput.prototype, "scope", void 0);
3814
- ActionExecutionMessageInput = _ts_decorate3([
3815
- (0, import_type_graphql4.InputType)()
3816
- ], ActionExecutionMessageInput);
3817
- var ResultMessageInput = class {
3818
- actionExecutionId;
3819
- actionName;
3820
- parentMessageId;
3821
- result;
3822
- };
3823
- __name(ResultMessageInput, "ResultMessageInput");
3824
- _ts_decorate3([
3825
- (0, import_type_graphql4.Field)(() => String),
3826
- _ts_metadata3("design:type", String)
3827
- ], ResultMessageInput.prototype, "actionExecutionId", void 0);
3828
- _ts_decorate3([
3829
- (0, import_type_graphql4.Field)(() => String),
3830
- _ts_metadata3("design:type", String)
3831
- ], ResultMessageInput.prototype, "actionName", void 0);
3832
- _ts_decorate3([
3833
- (0, import_type_graphql4.Field)(() => String, {
3834
- nullable: true
3835
- }),
3836
- _ts_metadata3("design:type", String)
3837
- ], ResultMessageInput.prototype, "parentMessageId", void 0);
3838
- _ts_decorate3([
3839
- (0, import_type_graphql4.Field)(() => String),
3840
- _ts_metadata3("design:type", String)
3841
- ], ResultMessageInput.prototype, "result", void 0);
3842
- ResultMessageInput = _ts_decorate3([
3843
- (0, import_type_graphql4.InputType)()
3844
- ], ResultMessageInput);
3845
- var AgentStateMessageInput = class {
3846
- threadId;
3847
- agentName;
3848
- role;
3849
- state;
3850
- running;
3851
- nodeName;
3852
- runId;
3853
- active;
4149
+ console.error("Error in stream", err);
4150
+ eventStream$.error(err);
4151
+ eventStream$.complete();
4152
+ },
4153
+ complete: () => eventStream$.complete()
4154
+ });
4155
+ });
4156
+ outputMessagesPromise.then((outputMessages) => {
4157
+ var _a2;
4158
+ (_a2 = this.onAfterRequest) == null ? void 0 : _a2.call(this, {
4159
+ threadId,
4160
+ runId: void 0,
4161
+ inputMessages: messages,
4162
+ outputMessages,
4163
+ properties: graphqlContext.properties
4164
+ });
4165
+ }).catch((_error) => {
4166
+ });
4167
+ return {
4168
+ threadId,
4169
+ runId: void 0,
4170
+ eventSource,
4171
+ serverSideActions: [],
4172
+ actionInputsWithoutAgents: allAvailableActions
4173
+ };
4174
+ } catch (error) {
4175
+ console.error("Error getting response:", error);
4176
+ throw error;
4177
+ }
4178
+ }
4179
+ async getServerSideActions(request) {
4180
+ const { messages: rawMessages, graphqlContext, agentStates, url } = request;
4181
+ const inputMessages = convertGqlInputToMessages(rawMessages);
4182
+ const langserveFunctions = [];
4183
+ for (const chainPromise of this.langserve) {
4184
+ try {
4185
+ const chain = await chainPromise;
4186
+ langserveFunctions.push(chain);
4187
+ } catch (error) {
4188
+ console.error("Error loading langserve chain:", error);
4189
+ }
4190
+ }
4191
+ const remoteEndpointDefinitions = this.remoteEndpointDefinitions.map((endpoint) => ({
4192
+ ...endpoint,
4193
+ type: resolveEndpointType(endpoint)
4194
+ }));
4195
+ const remoteActions = await setupRemoteActions({
4196
+ remoteEndpointDefinitions,
4197
+ graphqlContext,
4198
+ messages: inputMessages,
4199
+ agentStates,
4200
+ frontendUrl: url
4201
+ });
4202
+ const configuredActions = typeof this.actions === "function" ? this.actions({
4203
+ properties: graphqlContext.properties,
4204
+ url
4205
+ }) : this.actions;
4206
+ return [
4207
+ ...configuredActions,
4208
+ ...langserveFunctions,
4209
+ ...remoteActions
4210
+ ];
4211
+ }
3854
4212
  };
3855
- __name(AgentStateMessageInput, "AgentStateMessageInput");
3856
- _ts_decorate3([
3857
- (0, import_type_graphql4.Field)(() => String),
3858
- _ts_metadata3("design:type", String)
3859
- ], AgentStateMessageInput.prototype, "threadId", void 0);
3860
- _ts_decorate3([
3861
- (0, import_type_graphql4.Field)(() => String),
3862
- _ts_metadata3("design:type", String)
3863
- ], AgentStateMessageInput.prototype, "agentName", void 0);
3864
- _ts_decorate3([
3865
- (0, import_type_graphql4.Field)(() => MessageRole),
3866
- _ts_metadata3("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
3867
- ], AgentStateMessageInput.prototype, "role", void 0);
3868
- _ts_decorate3([
3869
- (0, import_type_graphql4.Field)(() => String),
3870
- _ts_metadata3("design:type", String)
3871
- ], AgentStateMessageInput.prototype, "state", void 0);
3872
- _ts_decorate3([
3873
- (0, import_type_graphql4.Field)(() => Boolean),
3874
- _ts_metadata3("design:type", Boolean)
3875
- ], AgentStateMessageInput.prototype, "running", void 0);
3876
- _ts_decorate3([
3877
- (0, import_type_graphql4.Field)(() => String),
3878
- _ts_metadata3("design:type", String)
3879
- ], AgentStateMessageInput.prototype, "nodeName", void 0);
3880
- _ts_decorate3([
3881
- (0, import_type_graphql4.Field)(() => String),
3882
- _ts_metadata3("design:type", String)
3883
- ], AgentStateMessageInput.prototype, "runId", void 0);
3884
- _ts_decorate3([
3885
- (0, import_type_graphql4.Field)(() => Boolean),
3886
- _ts_metadata3("design:type", Boolean)
3887
- ], AgentStateMessageInput.prototype, "active", void 0);
3888
- AgentStateMessageInput = _ts_decorate3([
3889
- (0, import_type_graphql4.InputType)()
3890
- ], AgentStateMessageInput);
3891
-
3892
- // src/graphql/inputs/frontend.input.ts
3893
- var import_type_graphql6 = require("type-graphql");
3894
-
3895
- // src/graphql/inputs/action.input.ts
3896
- var import_type_graphql5 = require("type-graphql");
3897
- function _ts_decorate4(decorators, target, key, desc) {
3898
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3899
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3900
- r = Reflect.decorate(decorators, target, key, desc);
3901
- else
3902
- for (var i = decorators.length - 1; i >= 0; i--)
3903
- if (d = decorators[i])
3904
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3905
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4213
+ __name(CopilotRuntime, "CopilotRuntime");
4214
+ function flattenToolCallsNoDuplicates(toolsByPriority) {
4215
+ let allTools = [];
4216
+ const allToolNames = [];
4217
+ for (const tool of toolsByPriority) {
4218
+ if (!allToolNames.includes(tool.name)) {
4219
+ allTools.push(tool);
4220
+ allToolNames.push(tool.name);
4221
+ }
4222
+ }
4223
+ return allTools;
3906
4224
  }
3907
- __name(_ts_decorate4, "_ts_decorate");
3908
- function _ts_metadata4(k, v) {
3909
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3910
- return Reflect.metadata(k, v);
4225
+ __name(flattenToolCallsNoDuplicates, "flattenToolCallsNoDuplicates");
4226
+ function copilotKitEndpoint(config2) {
4227
+ return {
4228
+ ...config2,
4229
+ type: EndpointType.CopilotKit
4230
+ };
3911
4231
  }
3912
- __name(_ts_metadata4, "_ts_metadata");
3913
- var ActionInput = class {
3914
- name;
3915
- description;
3916
- jsonSchema;
3917
- available;
3918
- };
3919
- __name(ActionInput, "ActionInput");
3920
- _ts_decorate4([
3921
- (0, import_type_graphql5.Field)(() => String),
3922
- _ts_metadata4("design:type", String)
3923
- ], ActionInput.prototype, "name", void 0);
3924
- _ts_decorate4([
3925
- (0, import_type_graphql5.Field)(() => String),
3926
- _ts_metadata4("design:type", String)
3927
- ], ActionInput.prototype, "description", void 0);
3928
- _ts_decorate4([
3929
- (0, import_type_graphql5.Field)(() => String),
3930
- _ts_metadata4("design:type", String)
3931
- ], ActionInput.prototype, "jsonSchema", void 0);
3932
- _ts_decorate4([
3933
- (0, import_type_graphql5.Field)(() => ActionInputAvailability, {
3934
- nullable: true
3935
- }),
3936
- _ts_metadata4("design:type", typeof ActionInputAvailability === "undefined" ? Object : ActionInputAvailability)
3937
- ], ActionInput.prototype, "available", void 0);
3938
- ActionInput = _ts_decorate4([
3939
- (0, import_type_graphql5.InputType)()
3940
- ], ActionInput);
3941
-
3942
- // src/graphql/inputs/frontend.input.ts
3943
- function _ts_decorate5(decorators, target, key, desc) {
3944
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3945
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3946
- r = Reflect.decorate(decorators, target, key, desc);
3947
- else
3948
- for (var i = decorators.length - 1; i >= 0; i--)
3949
- if (d = decorators[i])
3950
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3951
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4232
+ __name(copilotKitEndpoint, "copilotKitEndpoint");
4233
+ function langGraphPlatformEndpoint(config2) {
4234
+ return {
4235
+ ...config2,
4236
+ type: EndpointType.LangGraphPlatform
4237
+ };
3952
4238
  }
3953
- __name(_ts_decorate5, "_ts_decorate");
3954
- function _ts_metadata5(k, v) {
3955
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3956
- return Reflect.metadata(k, v);
4239
+ __name(langGraphPlatformEndpoint, "langGraphPlatformEndpoint");
4240
+ function resolveEndpointType(endpoint) {
4241
+ if (!endpoint.type) {
4242
+ if ("langsmithApiKey" in endpoint && "deploymentUrl" in endpoint && "agents" in endpoint) {
4243
+ return EndpointType.LangGraphPlatform;
4244
+ } else {
4245
+ return EndpointType.CopilotKit;
4246
+ }
4247
+ }
4248
+ return endpoint.type;
3957
4249
  }
3958
- __name(_ts_metadata5, "_ts_metadata");
3959
- var FrontendInput = class {
3960
- toDeprecate_fullContext;
3961
- actions;
3962
- url;
3963
- };
3964
- __name(FrontendInput, "FrontendInput");
3965
- _ts_decorate5([
3966
- (0, import_type_graphql6.Field)(() => String, {
3967
- nullable: true
3968
- }),
3969
- _ts_metadata5("design:type", String)
3970
- ], FrontendInput.prototype, "toDeprecate_fullContext", void 0);
3971
- _ts_decorate5([
3972
- (0, import_type_graphql6.Field)(() => [
3973
- ActionInput
3974
- ]),
3975
- _ts_metadata5("design:type", Array)
3976
- ], FrontendInput.prototype, "actions", void 0);
3977
- _ts_decorate5([
3978
- (0, import_type_graphql6.Field)(() => String, {
3979
- nullable: true
3980
- }),
3981
- _ts_metadata5("design:type", String)
3982
- ], FrontendInput.prototype, "url", void 0);
3983
- FrontendInput = _ts_decorate5([
3984
- (0, import_type_graphql6.InputType)()
3985
- ], FrontendInput);
4250
+ __name(resolveEndpointType, "resolveEndpointType");
3986
4251
 
3987
- // src/graphql/inputs/cloud.input.ts
3988
- var import_type_graphql8 = require("type-graphql");
4252
+ // src/lib/integrations/shared.ts
4253
+ var import_type_graphql26 = require("type-graphql");
3989
4254
 
3990
- // src/graphql/inputs/cloud-guardrails.input.ts
3991
- var import_type_graphql7 = require("type-graphql");
3992
- function _ts_decorate6(decorators, target, key, desc) {
3993
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3994
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3995
- r = Reflect.decorate(decorators, target, key, desc);
3996
- else
3997
- for (var i = decorators.length - 1; i >= 0; i--)
3998
- if (d = decorators[i])
3999
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4000
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4001
- }
4002
- __name(_ts_decorate6, "_ts_decorate");
4003
- function _ts_metadata6(k, v) {
4004
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4005
- return Reflect.metadata(k, v);
4006
- }
4007
- __name(_ts_metadata6, "_ts_metadata");
4008
- var GuardrailsRuleInput = class {
4009
- allowList = [];
4010
- denyList = [];
4011
- };
4012
- __name(GuardrailsRuleInput, "GuardrailsRuleInput");
4013
- _ts_decorate6([
4014
- (0, import_type_graphql7.Field)(() => [
4015
- String
4016
- ], {
4017
- nullable: true
4018
- }),
4019
- _ts_metadata6("design:type", Array)
4020
- ], GuardrailsRuleInput.prototype, "allowList", void 0);
4021
- _ts_decorate6([
4022
- (0, import_type_graphql7.Field)(() => [
4023
- String
4024
- ], {
4025
- nullable: true
4026
- }),
4027
- _ts_metadata6("design:type", Array)
4028
- ], GuardrailsRuleInput.prototype, "denyList", void 0);
4029
- GuardrailsRuleInput = _ts_decorate6([
4030
- (0, import_type_graphql7.InputType)()
4031
- ], GuardrailsRuleInput);
4032
- var GuardrailsInput = class {
4033
- inputValidationRules;
4034
- };
4035
- __name(GuardrailsInput, "GuardrailsInput");
4036
- _ts_decorate6([
4037
- (0, import_type_graphql7.Field)(() => GuardrailsRuleInput, {
4038
- nullable: false
4039
- }),
4040
- _ts_metadata6("design:type", typeof GuardrailsRuleInput === "undefined" ? Object : GuardrailsRuleInput)
4041
- ], GuardrailsInput.prototype, "inputValidationRules", void 0);
4042
- GuardrailsInput = _ts_decorate6([
4043
- (0, import_type_graphql7.InputType)()
4044
- ], GuardrailsInput);
4255
+ // src/graphql/resolvers/copilot.resolver.ts
4256
+ var import_type_graphql20 = require("type-graphql");
4257
+ var import_rxjs4 = require("rxjs");
4045
4258
 
4046
- // src/graphql/inputs/cloud.input.ts
4259
+ // src/graphql/inputs/generate-copilot-response.input.ts
4260
+ var import_type_graphql18 = require("type-graphql");
4261
+
4262
+ // src/graphql/inputs/message.input.ts
4263
+ var import_type_graphql8 = require("type-graphql");
4047
4264
  function _ts_decorate7(decorators, target, key, desc) {
4048
4265
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4049
4266
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -4060,21 +4277,173 @@ function _ts_metadata7(k, v) {
4060
4277
  return Reflect.metadata(k, v);
4061
4278
  }
4062
4279
  __name(_ts_metadata7, "_ts_metadata");
4063
- var CloudInput = class {
4064
- guardrails;
4280
+ var MessageInput = class extends BaseMessageInput {
4281
+ textMessage;
4282
+ actionExecutionMessage;
4283
+ resultMessage;
4284
+ agentStateMessage;
4065
4285
  };
4066
- __name(CloudInput, "CloudInput");
4286
+ __name(MessageInput, "MessageInput");
4067
4287
  _ts_decorate7([
4068
- (0, import_type_graphql8.Field)(() => GuardrailsInput, {
4288
+ (0, import_type_graphql8.Field)(() => TextMessageInput, {
4069
4289
  nullable: true
4070
4290
  }),
4071
- _ts_metadata7("design:type", typeof GuardrailsInput === "undefined" ? Object : GuardrailsInput)
4072
- ], CloudInput.prototype, "guardrails", void 0);
4073
- CloudInput = _ts_decorate7([
4291
+ _ts_metadata7("design:type", typeof TextMessageInput === "undefined" ? Object : TextMessageInput)
4292
+ ], MessageInput.prototype, "textMessage", void 0);
4293
+ _ts_decorate7([
4294
+ (0, import_type_graphql8.Field)(() => ActionExecutionMessageInput, {
4295
+ nullable: true
4296
+ }),
4297
+ _ts_metadata7("design:type", typeof ActionExecutionMessageInput === "undefined" ? Object : ActionExecutionMessageInput)
4298
+ ], MessageInput.prototype, "actionExecutionMessage", void 0);
4299
+ _ts_decorate7([
4300
+ (0, import_type_graphql8.Field)(() => ResultMessageInput, {
4301
+ nullable: true
4302
+ }),
4303
+ _ts_metadata7("design:type", typeof ResultMessageInput === "undefined" ? Object : ResultMessageInput)
4304
+ ], MessageInput.prototype, "resultMessage", void 0);
4305
+ _ts_decorate7([
4306
+ (0, import_type_graphql8.Field)(() => AgentStateMessageInput, {
4307
+ nullable: true
4308
+ }),
4309
+ _ts_metadata7("design:type", typeof AgentStateMessageInput === "undefined" ? Object : AgentStateMessageInput)
4310
+ ], MessageInput.prototype, "agentStateMessage", void 0);
4311
+ MessageInput = _ts_decorate7([
4074
4312
  (0, import_type_graphql8.InputType)()
4075
- ], CloudInput);
4313
+ ], MessageInput);
4314
+ var TextMessageInput = class {
4315
+ content;
4316
+ parentMessageId;
4317
+ role;
4318
+ };
4319
+ __name(TextMessageInput, "TextMessageInput");
4320
+ _ts_decorate7([
4321
+ (0, import_type_graphql8.Field)(() => String),
4322
+ _ts_metadata7("design:type", String)
4323
+ ], TextMessageInput.prototype, "content", void 0);
4324
+ _ts_decorate7([
4325
+ (0, import_type_graphql8.Field)(() => String, {
4326
+ nullable: true
4327
+ }),
4328
+ _ts_metadata7("design:type", String)
4329
+ ], TextMessageInput.prototype, "parentMessageId", void 0);
4330
+ _ts_decorate7([
4331
+ (0, import_type_graphql8.Field)(() => MessageRole),
4332
+ _ts_metadata7("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4333
+ ], TextMessageInput.prototype, "role", void 0);
4334
+ TextMessageInput = _ts_decorate7([
4335
+ (0, import_type_graphql8.InputType)()
4336
+ ], TextMessageInput);
4337
+ var ActionExecutionMessageInput = class {
4338
+ name;
4339
+ arguments;
4340
+ parentMessageId;
4341
+ scope;
4342
+ };
4343
+ __name(ActionExecutionMessageInput, "ActionExecutionMessageInput");
4344
+ _ts_decorate7([
4345
+ (0, import_type_graphql8.Field)(() => String),
4346
+ _ts_metadata7("design:type", String)
4347
+ ], ActionExecutionMessageInput.prototype, "name", void 0);
4348
+ _ts_decorate7([
4349
+ (0, import_type_graphql8.Field)(() => String),
4350
+ _ts_metadata7("design:type", String)
4351
+ ], ActionExecutionMessageInput.prototype, "arguments", void 0);
4352
+ _ts_decorate7([
4353
+ (0, import_type_graphql8.Field)(() => String, {
4354
+ nullable: true
4355
+ }),
4356
+ _ts_metadata7("design:type", String)
4357
+ ], ActionExecutionMessageInput.prototype, "parentMessageId", void 0);
4358
+ _ts_decorate7([
4359
+ (0, import_type_graphql8.Field)(() => String, {
4360
+ nullable: true,
4361
+ deprecationReason: "This field will be removed in a future version"
4362
+ }),
4363
+ _ts_metadata7("design:type", typeof String === "undefined" ? Object : String)
4364
+ ], ActionExecutionMessageInput.prototype, "scope", void 0);
4365
+ ActionExecutionMessageInput = _ts_decorate7([
4366
+ (0, import_type_graphql8.InputType)()
4367
+ ], ActionExecutionMessageInput);
4368
+ var ResultMessageInput = class {
4369
+ actionExecutionId;
4370
+ actionName;
4371
+ parentMessageId;
4372
+ result;
4373
+ };
4374
+ __name(ResultMessageInput, "ResultMessageInput");
4375
+ _ts_decorate7([
4376
+ (0, import_type_graphql8.Field)(() => String),
4377
+ _ts_metadata7("design:type", String)
4378
+ ], ResultMessageInput.prototype, "actionExecutionId", void 0);
4379
+ _ts_decorate7([
4380
+ (0, import_type_graphql8.Field)(() => String),
4381
+ _ts_metadata7("design:type", String)
4382
+ ], ResultMessageInput.prototype, "actionName", void 0);
4383
+ _ts_decorate7([
4384
+ (0, import_type_graphql8.Field)(() => String, {
4385
+ nullable: true
4386
+ }),
4387
+ _ts_metadata7("design:type", String)
4388
+ ], ResultMessageInput.prototype, "parentMessageId", void 0);
4389
+ _ts_decorate7([
4390
+ (0, import_type_graphql8.Field)(() => String),
4391
+ _ts_metadata7("design:type", String)
4392
+ ], ResultMessageInput.prototype, "result", void 0);
4393
+ ResultMessageInput = _ts_decorate7([
4394
+ (0, import_type_graphql8.InputType)()
4395
+ ], ResultMessageInput);
4396
+ var AgentStateMessageInput = class {
4397
+ threadId;
4398
+ agentName;
4399
+ role;
4400
+ state;
4401
+ running;
4402
+ nodeName;
4403
+ runId;
4404
+ active;
4405
+ };
4406
+ __name(AgentStateMessageInput, "AgentStateMessageInput");
4407
+ _ts_decorate7([
4408
+ (0, import_type_graphql8.Field)(() => String),
4409
+ _ts_metadata7("design:type", String)
4410
+ ], AgentStateMessageInput.prototype, "threadId", void 0);
4411
+ _ts_decorate7([
4412
+ (0, import_type_graphql8.Field)(() => String),
4413
+ _ts_metadata7("design:type", String)
4414
+ ], AgentStateMessageInput.prototype, "agentName", void 0);
4415
+ _ts_decorate7([
4416
+ (0, import_type_graphql8.Field)(() => MessageRole),
4417
+ _ts_metadata7("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4418
+ ], AgentStateMessageInput.prototype, "role", void 0);
4419
+ _ts_decorate7([
4420
+ (0, import_type_graphql8.Field)(() => String),
4421
+ _ts_metadata7("design:type", String)
4422
+ ], AgentStateMessageInput.prototype, "state", void 0);
4423
+ _ts_decorate7([
4424
+ (0, import_type_graphql8.Field)(() => Boolean),
4425
+ _ts_metadata7("design:type", Boolean)
4426
+ ], AgentStateMessageInput.prototype, "running", void 0);
4427
+ _ts_decorate7([
4428
+ (0, import_type_graphql8.Field)(() => String),
4429
+ _ts_metadata7("design:type", String)
4430
+ ], AgentStateMessageInput.prototype, "nodeName", void 0);
4431
+ _ts_decorate7([
4432
+ (0, import_type_graphql8.Field)(() => String),
4433
+ _ts_metadata7("design:type", String)
4434
+ ], AgentStateMessageInput.prototype, "runId", void 0);
4435
+ _ts_decorate7([
4436
+ (0, import_type_graphql8.Field)(() => Boolean),
4437
+ _ts_metadata7("design:type", Boolean)
4438
+ ], AgentStateMessageInput.prototype, "active", void 0);
4439
+ AgentStateMessageInput = _ts_decorate7([
4440
+ (0, import_type_graphql8.InputType)()
4441
+ ], AgentStateMessageInput);
4076
4442
 
4077
- // src/graphql/inputs/forwarded-parameters.input.ts
4443
+ // src/graphql/inputs/frontend.input.ts
4444
+ var import_type_graphql10 = require("type-graphql");
4445
+
4446
+ // src/graphql/inputs/action.input.ts
4078
4447
  var import_type_graphql9 = require("type-graphql");
4079
4448
  function _ts_decorate8(decorators, target, key, desc) {
4080
4449
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4092,59 +4461,36 @@ function _ts_metadata8(k, v) {
4092
4461
  return Reflect.metadata(k, v);
4093
4462
  }
4094
4463
  __name(_ts_metadata8, "_ts_metadata");
4095
- var ForwardedParametersInput = class {
4096
- model;
4097
- maxTokens;
4098
- stop;
4099
- toolChoice;
4100
- toolChoiceFunctionName;
4101
- temperature;
4464
+ var ActionInput = class {
4465
+ name;
4466
+ description;
4467
+ jsonSchema;
4468
+ available;
4102
4469
  };
4103
- __name(ForwardedParametersInput, "ForwardedParametersInput");
4470
+ __name(ActionInput, "ActionInput");
4104
4471
  _ts_decorate8([
4105
- (0, import_type_graphql9.Field)(() => String, {
4106
- nullable: true
4107
- }),
4472
+ (0, import_type_graphql9.Field)(() => String),
4108
4473
  _ts_metadata8("design:type", String)
4109
- ], ForwardedParametersInput.prototype, "model", void 0);
4110
- _ts_decorate8([
4111
- (0, import_type_graphql9.Field)(() => Number, {
4112
- nullable: true
4113
- }),
4114
- _ts_metadata8("design:type", Number)
4115
- ], ForwardedParametersInput.prototype, "maxTokens", void 0);
4116
- _ts_decorate8([
4117
- (0, import_type_graphql9.Field)(() => [
4118
- String
4119
- ], {
4120
- nullable: true
4121
- }),
4122
- _ts_metadata8("design:type", Array)
4123
- ], ForwardedParametersInput.prototype, "stop", void 0);
4474
+ ], ActionInput.prototype, "name", void 0);
4124
4475
  _ts_decorate8([
4125
- (0, import_type_graphql9.Field)(() => String, {
4126
- nullable: true
4127
- }),
4128
- _ts_metadata8("design:type", typeof String === "undefined" ? Object : String)
4129
- ], ForwardedParametersInput.prototype, "toolChoice", void 0);
4476
+ (0, import_type_graphql9.Field)(() => String),
4477
+ _ts_metadata8("design:type", String)
4478
+ ], ActionInput.prototype, "description", void 0);
4130
4479
  _ts_decorate8([
4131
- (0, import_type_graphql9.Field)(() => String, {
4132
- nullable: true
4133
- }),
4480
+ (0, import_type_graphql9.Field)(() => String),
4134
4481
  _ts_metadata8("design:type", String)
4135
- ], ForwardedParametersInput.prototype, "toolChoiceFunctionName", void 0);
4482
+ ], ActionInput.prototype, "jsonSchema", void 0);
4136
4483
  _ts_decorate8([
4137
- (0, import_type_graphql9.Field)(() => Number, {
4484
+ (0, import_type_graphql9.Field)(() => ActionInputAvailability, {
4138
4485
  nullable: true
4139
4486
  }),
4140
- _ts_metadata8("design:type", Number)
4141
- ], ForwardedParametersInput.prototype, "temperature", void 0);
4142
- ForwardedParametersInput = _ts_decorate8([
4487
+ _ts_metadata8("design:type", typeof ActionInputAvailability === "undefined" ? Object : ActionInputAvailability)
4488
+ ], ActionInput.prototype, "available", void 0);
4489
+ ActionInput = _ts_decorate8([
4143
4490
  (0, import_type_graphql9.InputType)()
4144
- ], ForwardedParametersInput);
4491
+ ], ActionInput);
4145
4492
 
4146
- // src/graphql/inputs/agent-session.input.ts
4147
- var import_type_graphql10 = require("type-graphql");
4493
+ // src/graphql/inputs/frontend.input.ts
4148
4494
  function _ts_decorate9(decorators, target, key, desc) {
4149
4495
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4150
4496
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -4161,33 +4507,38 @@ function _ts_metadata9(k, v) {
4161
4507
  return Reflect.metadata(k, v);
4162
4508
  }
4163
4509
  __name(_ts_metadata9, "_ts_metadata");
4164
- var AgentSessionInput = class {
4165
- agentName;
4166
- threadId;
4167
- nodeName;
4510
+ var FrontendInput = class {
4511
+ toDeprecate_fullContext;
4512
+ actions;
4513
+ url;
4168
4514
  };
4169
- __name(AgentSessionInput, "AgentSessionInput");
4170
- _ts_decorate9([
4171
- (0, import_type_graphql10.Field)(() => String),
4172
- _ts_metadata9("design:type", String)
4173
- ], AgentSessionInput.prototype, "agentName", void 0);
4515
+ __name(FrontendInput, "FrontendInput");
4174
4516
  _ts_decorate9([
4175
4517
  (0, import_type_graphql10.Field)(() => String, {
4176
4518
  nullable: true
4177
4519
  }),
4178
4520
  _ts_metadata9("design:type", String)
4179
- ], AgentSessionInput.prototype, "threadId", void 0);
4521
+ ], FrontendInput.prototype, "toDeprecate_fullContext", void 0);
4522
+ _ts_decorate9([
4523
+ (0, import_type_graphql10.Field)(() => [
4524
+ ActionInput
4525
+ ]),
4526
+ _ts_metadata9("design:type", Array)
4527
+ ], FrontendInput.prototype, "actions", void 0);
4180
4528
  _ts_decorate9([
4181
4529
  (0, import_type_graphql10.Field)(() => String, {
4182
4530
  nullable: true
4183
4531
  }),
4184
4532
  _ts_metadata9("design:type", String)
4185
- ], AgentSessionInput.prototype, "nodeName", void 0);
4186
- AgentSessionInput = _ts_decorate9([
4533
+ ], FrontendInput.prototype, "url", void 0);
4534
+ FrontendInput = _ts_decorate9([
4187
4535
  (0, import_type_graphql10.InputType)()
4188
- ], AgentSessionInput);
4536
+ ], FrontendInput);
4189
4537
 
4190
- // src/graphql/inputs/agent-state.input.ts
4538
+ // src/graphql/inputs/cloud.input.ts
4539
+ var import_type_graphql12 = require("type-graphql");
4540
+
4541
+ // src/graphql/inputs/cloud-guardrails.input.ts
4191
4542
  var import_type_graphql11 = require("type-graphql");
4192
4543
  function _ts_decorate10(decorators, target, key, desc) {
4193
4544
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4205,76 +4556,76 @@ function _ts_metadata10(k, v) {
4205
4556
  return Reflect.metadata(k, v);
4206
4557
  }
4207
4558
  __name(_ts_metadata10, "_ts_metadata");
4208
- var AgentStateInput = class {
4209
- agentName;
4210
- state;
4559
+ var GuardrailsRuleInput = class {
4560
+ allowList = [];
4561
+ denyList = [];
4211
4562
  };
4212
- __name(AgentStateInput, "AgentStateInput");
4563
+ __name(GuardrailsRuleInput, "GuardrailsRuleInput");
4213
4564
  _ts_decorate10([
4214
- (0, import_type_graphql11.Field)(() => String),
4215
- _ts_metadata10("design:type", String)
4216
- ], AgentStateInput.prototype, "agentName", void 0);
4565
+ (0, import_type_graphql11.Field)(() => [
4566
+ String
4567
+ ], {
4568
+ nullable: true
4569
+ }),
4570
+ _ts_metadata10("design:type", Array)
4571
+ ], GuardrailsRuleInput.prototype, "allowList", void 0);
4217
4572
  _ts_decorate10([
4218
- (0, import_type_graphql11.Field)(() => String),
4219
- _ts_metadata10("design:type", String)
4220
- ], AgentStateInput.prototype, "state", void 0);
4221
- AgentStateInput = _ts_decorate10([
4573
+ (0, import_type_graphql11.Field)(() => [
4574
+ String
4575
+ ], {
4576
+ nullable: true
4577
+ }),
4578
+ _ts_metadata10("design:type", Array)
4579
+ ], GuardrailsRuleInput.prototype, "denyList", void 0);
4580
+ GuardrailsRuleInput = _ts_decorate10([
4222
4581
  (0, import_type_graphql11.InputType)()
4223
- ], AgentStateInput);
4582
+ ], GuardrailsRuleInput);
4583
+ var GuardrailsInput = class {
4584
+ inputValidationRules;
4585
+ };
4586
+ __name(GuardrailsInput, "GuardrailsInput");
4587
+ _ts_decorate10([
4588
+ (0, import_type_graphql11.Field)(() => GuardrailsRuleInput, {
4589
+ nullable: false
4590
+ }),
4591
+ _ts_metadata10("design:type", typeof GuardrailsRuleInput === "undefined" ? Object : GuardrailsRuleInput)
4592
+ ], GuardrailsInput.prototype, "inputValidationRules", void 0);
4593
+ GuardrailsInput = _ts_decorate10([
4594
+ (0, import_type_graphql11.InputType)()
4595
+ ], GuardrailsInput);
4224
4596
 
4225
- // src/graphql/inputs/extensions.input.ts
4226
- var import_type_graphql12 = require("type-graphql");
4597
+ // src/graphql/inputs/cloud.input.ts
4227
4598
  function _ts_decorate11(decorators, target, key, desc) {
4228
4599
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4229
4600
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4230
4601
  r = Reflect.decorate(decorators, target, key, desc);
4231
4602
  else
4232
- for (var i = decorators.length - 1; i >= 0; i--)
4233
- if (d = decorators[i])
4234
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4235
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4236
- }
4237
- __name(_ts_decorate11, "_ts_decorate");
4238
- function _ts_metadata11(k, v) {
4239
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4240
- return Reflect.metadata(k, v);
4241
- }
4242
- __name(_ts_metadata11, "_ts_metadata");
4243
- var ExtensionsInput = class {
4244
- openaiAssistantAPI;
4245
- };
4246
- __name(ExtensionsInput, "ExtensionsInput");
4247
- _ts_decorate11([
4248
- (0, import_type_graphql12.Field)(() => OpenAIApiAssistantAPIInput, {
4249
- nullable: true
4250
- }),
4251
- _ts_metadata11("design:type", typeof OpenAIApiAssistantAPIInput === "undefined" ? Object : OpenAIApiAssistantAPIInput)
4252
- ], ExtensionsInput.prototype, "openaiAssistantAPI", void 0);
4253
- ExtensionsInput = _ts_decorate11([
4254
- (0, import_type_graphql12.InputType)()
4255
- ], ExtensionsInput);
4256
- var OpenAIApiAssistantAPIInput = class {
4257
- runId;
4258
- threadId;
4603
+ for (var i = decorators.length - 1; i >= 0; i--)
4604
+ if (d = decorators[i])
4605
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4606
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4607
+ }
4608
+ __name(_ts_decorate11, "_ts_decorate");
4609
+ function _ts_metadata11(k, v) {
4610
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4611
+ return Reflect.metadata(k, v);
4612
+ }
4613
+ __name(_ts_metadata11, "_ts_metadata");
4614
+ var CloudInput = class {
4615
+ guardrails;
4259
4616
  };
4260
- __name(OpenAIApiAssistantAPIInput, "OpenAIApiAssistantAPIInput");
4261
- _ts_decorate11([
4262
- (0, import_type_graphql12.Field)(() => String, {
4263
- nullable: true
4264
- }),
4265
- _ts_metadata11("design:type", String)
4266
- ], OpenAIApiAssistantAPIInput.prototype, "runId", void 0);
4617
+ __name(CloudInput, "CloudInput");
4267
4618
  _ts_decorate11([
4268
- (0, import_type_graphql12.Field)(() => String, {
4619
+ (0, import_type_graphql12.Field)(() => GuardrailsInput, {
4269
4620
  nullable: true
4270
4621
  }),
4271
- _ts_metadata11("design:type", String)
4272
- ], OpenAIApiAssistantAPIInput.prototype, "threadId", void 0);
4273
- OpenAIApiAssistantAPIInput = _ts_decorate11([
4622
+ _ts_metadata11("design:type", typeof GuardrailsInput === "undefined" ? Object : GuardrailsInput)
4623
+ ], CloudInput.prototype, "guardrails", void 0);
4624
+ CloudInput = _ts_decorate11([
4274
4625
  (0, import_type_graphql12.InputType)()
4275
- ], OpenAIApiAssistantAPIInput);
4626
+ ], CloudInput);
4276
4627
 
4277
- // src/graphql/inputs/meta-event.input.ts
4628
+ // src/graphql/inputs/forwarded-parameters.input.ts
4278
4629
  var import_type_graphql13 = require("type-graphql");
4279
4630
  function _ts_decorate12(decorators, target, key, desc) {
4280
4631
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4292,36 +4643,59 @@ function _ts_metadata12(k, v) {
4292
4643
  return Reflect.metadata(k, v);
4293
4644
  }
4294
4645
  __name(_ts_metadata12, "_ts_metadata");
4295
- var MetaEventInput = class {
4296
- type = "MetaEvent";
4297
- name;
4298
- value;
4299
- response;
4646
+ var ForwardedParametersInput = class {
4647
+ model;
4648
+ maxTokens;
4649
+ stop;
4650
+ toolChoice;
4651
+ toolChoiceFunctionName;
4652
+ temperature;
4300
4653
  };
4301
- __name(MetaEventInput, "MetaEventInput");
4654
+ __name(ForwardedParametersInput, "ForwardedParametersInput");
4302
4655
  _ts_decorate12([
4303
- (0, import_type_graphql13.Field)(() => String),
4656
+ (0, import_type_graphql13.Field)(() => String, {
4657
+ nullable: true
4658
+ }),
4304
4659
  _ts_metadata12("design:type", String)
4305
- ], MetaEventInput.prototype, "type", void 0);
4660
+ ], ForwardedParametersInput.prototype, "model", void 0);
4306
4661
  _ts_decorate12([
4307
- (0, import_type_graphql13.Field)(() => MetaEventName),
4308
- _ts_metadata12("design:type", typeof MetaEventName === "undefined" ? Object : MetaEventName)
4309
- ], MetaEventInput.prototype, "name", void 0);
4662
+ (0, import_type_graphql13.Field)(() => Number, {
4663
+ nullable: true
4664
+ }),
4665
+ _ts_metadata12("design:type", Number)
4666
+ ], ForwardedParametersInput.prototype, "maxTokens", void 0);
4310
4667
  _ts_decorate12([
4311
- (0, import_type_graphql13.Field)(() => String),
4312
- _ts_metadata12("design:type", String)
4313
- ], MetaEventInput.prototype, "value", void 0);
4668
+ (0, import_type_graphql13.Field)(() => [
4669
+ String
4670
+ ], {
4671
+ nullable: true
4672
+ }),
4673
+ _ts_metadata12("design:type", Array)
4674
+ ], ForwardedParametersInput.prototype, "stop", void 0);
4675
+ _ts_decorate12([
4676
+ (0, import_type_graphql13.Field)(() => String, {
4677
+ nullable: true
4678
+ }),
4679
+ _ts_metadata12("design:type", typeof String === "undefined" ? Object : String)
4680
+ ], ForwardedParametersInput.prototype, "toolChoice", void 0);
4314
4681
  _ts_decorate12([
4315
4682
  (0, import_type_graphql13.Field)(() => String, {
4316
4683
  nullable: true
4317
4684
  }),
4318
4685
  _ts_metadata12("design:type", String)
4319
- ], MetaEventInput.prototype, "response", void 0);
4320
- MetaEventInput = _ts_decorate12([
4686
+ ], ForwardedParametersInput.prototype, "toolChoiceFunctionName", void 0);
4687
+ _ts_decorate12([
4688
+ (0, import_type_graphql13.Field)(() => Number, {
4689
+ nullable: true
4690
+ }),
4691
+ _ts_metadata12("design:type", Number)
4692
+ ], ForwardedParametersInput.prototype, "temperature", void 0);
4693
+ ForwardedParametersInput = _ts_decorate12([
4321
4694
  (0, import_type_graphql13.InputType)()
4322
- ], MetaEventInput);
4695
+ ], ForwardedParametersInput);
4323
4696
 
4324
- // src/graphql/inputs/generate-copilot-response.input.ts
4697
+ // src/graphql/inputs/agent-session.input.ts
4698
+ var import_type_graphql14 = require("type-graphql");
4325
4699
  function _ts_decorate13(decorators, target, key, desc) {
4326
4700
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4327
4701
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -4338,116 +4712,33 @@ function _ts_metadata13(k, v) {
4338
4712
  return Reflect.metadata(k, v);
4339
4713
  }
4340
4714
  __name(_ts_metadata13, "_ts_metadata");
4341
- var GenerateCopilotResponseMetadataInput = class {
4342
- requestType;
4343
- };
4344
- __name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
4345
- _ts_decorate13([
4346
- (0, import_type_graphql14.Field)(() => CopilotRequestType, {
4347
- nullable: true
4348
- }),
4349
- _ts_metadata13("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
4350
- ], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
4351
- GenerateCopilotResponseMetadataInput = _ts_decorate13([
4352
- (0, import_type_graphql14.InputType)()
4353
- ], GenerateCopilotResponseMetadataInput);
4354
- var GenerateCopilotResponseInput = class {
4355
- metadata;
4715
+ var AgentSessionInput = class {
4716
+ agentName;
4356
4717
  threadId;
4357
- runId;
4358
- messages;
4359
- frontend;
4360
- cloud;
4361
- forwardedParameters;
4362
- agentSession;
4363
- agentState;
4364
- agentStates;
4365
- extensions;
4366
- metaEvents;
4718
+ nodeName;
4367
4719
  };
4368
- __name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
4720
+ __name(AgentSessionInput, "AgentSessionInput");
4369
4721
  _ts_decorate13([
4370
- (0, import_type_graphql14.Field)(() => GenerateCopilotResponseMetadataInput, {
4371
- nullable: false
4372
- }),
4373
- _ts_metadata13("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
4374
- ], GenerateCopilotResponseInput.prototype, "metadata", void 0);
4722
+ (0, import_type_graphql14.Field)(() => String),
4723
+ _ts_metadata13("design:type", String)
4724
+ ], AgentSessionInput.prototype, "agentName", void 0);
4375
4725
  _ts_decorate13([
4376
4726
  (0, import_type_graphql14.Field)(() => String, {
4377
4727
  nullable: true
4378
4728
  }),
4379
4729
  _ts_metadata13("design:type", String)
4380
- ], GenerateCopilotResponseInput.prototype, "threadId", void 0);
4730
+ ], AgentSessionInput.prototype, "threadId", void 0);
4381
4731
  _ts_decorate13([
4382
4732
  (0, import_type_graphql14.Field)(() => String, {
4383
4733
  nullable: true
4384
4734
  }),
4385
4735
  _ts_metadata13("design:type", String)
4386
- ], GenerateCopilotResponseInput.prototype, "runId", void 0);
4387
- _ts_decorate13([
4388
- (0, import_type_graphql14.Field)(() => [
4389
- MessageInput
4390
- ]),
4391
- _ts_metadata13("design:type", Array)
4392
- ], GenerateCopilotResponseInput.prototype, "messages", void 0);
4393
- _ts_decorate13([
4394
- (0, import_type_graphql14.Field)(() => FrontendInput),
4395
- _ts_metadata13("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
4396
- ], GenerateCopilotResponseInput.prototype, "frontend", void 0);
4397
- _ts_decorate13([
4398
- (0, import_type_graphql14.Field)(() => CloudInput, {
4399
- nullable: true
4400
- }),
4401
- _ts_metadata13("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
4402
- ], GenerateCopilotResponseInput.prototype, "cloud", void 0);
4403
- _ts_decorate13([
4404
- (0, import_type_graphql14.Field)(() => ForwardedParametersInput, {
4405
- nullable: true
4406
- }),
4407
- _ts_metadata13("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
4408
- ], GenerateCopilotResponseInput.prototype, "forwardedParameters", void 0);
4409
- _ts_decorate13([
4410
- (0, import_type_graphql14.Field)(() => AgentSessionInput, {
4411
- nullable: true
4412
- }),
4413
- _ts_metadata13("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
4414
- ], GenerateCopilotResponseInput.prototype, "agentSession", void 0);
4415
- _ts_decorate13([
4416
- (0, import_type_graphql14.Field)(() => AgentStateInput, {
4417
- nullable: true
4418
- }),
4419
- _ts_metadata13("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
4420
- ], GenerateCopilotResponseInput.prototype, "agentState", void 0);
4421
- _ts_decorate13([
4422
- (0, import_type_graphql14.Field)(() => [
4423
- AgentStateInput
4424
- ], {
4425
- nullable: true
4426
- }),
4427
- _ts_metadata13("design:type", Array)
4428
- ], GenerateCopilotResponseInput.prototype, "agentStates", void 0);
4429
- _ts_decorate13([
4430
- (0, import_type_graphql14.Field)(() => ExtensionsInput, {
4431
- nullable: true
4432
- }),
4433
- _ts_metadata13("design:type", typeof ExtensionsInput === "undefined" ? Object : ExtensionsInput)
4434
- ], GenerateCopilotResponseInput.prototype, "extensions", void 0);
4435
- _ts_decorate13([
4436
- (0, import_type_graphql14.Field)(() => [
4437
- MetaEventInput
4438
- ], {
4439
- nullable: true
4440
- }),
4441
- _ts_metadata13("design:type", Array)
4442
- ], GenerateCopilotResponseInput.prototype, "metaEvents", void 0);
4443
- GenerateCopilotResponseInput = _ts_decorate13([
4736
+ ], AgentSessionInput.prototype, "nodeName", void 0);
4737
+ AgentSessionInput = _ts_decorate13([
4444
4738
  (0, import_type_graphql14.InputType)()
4445
- ], GenerateCopilotResponseInput);
4446
-
4447
- // src/graphql/types/copilot-response.type.ts
4448
- var import_type_graphql18 = require("type-graphql");
4739
+ ], AgentSessionInput);
4449
4740
 
4450
- // src/graphql/types/message-status.type.ts
4741
+ // src/graphql/inputs/agent-state.input.ts
4451
4742
  var import_type_graphql15 = require("type-graphql");
4452
4743
  function _ts_decorate14(decorators, target, key, desc) {
4453
4744
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4465,62 +4756,24 @@ function _ts_metadata14(k, v) {
4465
4756
  return Reflect.metadata(k, v);
4466
4757
  }
4467
4758
  __name(_ts_metadata14, "_ts_metadata");
4468
- var MessageStatusCode;
4469
- (function(MessageStatusCode2) {
4470
- MessageStatusCode2["Pending"] = "pending";
4471
- MessageStatusCode2["Success"] = "success";
4472
- MessageStatusCode2["Failed"] = "failed";
4473
- })(MessageStatusCode || (MessageStatusCode = {}));
4474
- (0, import_type_graphql15.registerEnumType)(MessageStatusCode, {
4475
- name: "MessageStatusCode"
4476
- });
4477
- var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
4478
- code;
4479
- }, "BaseMessageStatus");
4759
+ var AgentStateInput = class {
4760
+ agentName;
4761
+ state;
4762
+ };
4763
+ __name(AgentStateInput, "AgentStateInput");
4480
4764
  _ts_decorate14([
4481
- (0, import_type_graphql15.Field)(() => MessageStatusCode),
4765
+ (0, import_type_graphql15.Field)(() => String),
4482
4766
  _ts_metadata14("design:type", String)
4483
- ], BaseMessageStatus.prototype, "code", void 0);
4484
- BaseMessageStatus = _ts_decorate14([
4485
- (0, import_type_graphql15.ObjectType)()
4486
- ], BaseMessageStatus);
4487
- var PendingMessageStatus = class extends BaseMessageStatus {
4488
- code = "pending";
4489
- };
4490
- __name(PendingMessageStatus, "PendingMessageStatus");
4491
- PendingMessageStatus = _ts_decorate14([
4492
- (0, import_type_graphql15.ObjectType)()
4493
- ], PendingMessageStatus);
4494
- var SuccessMessageStatus = class extends BaseMessageStatus {
4495
- code = "success";
4496
- };
4497
- __name(SuccessMessageStatus, "SuccessMessageStatus");
4498
- SuccessMessageStatus = _ts_decorate14([
4499
- (0, import_type_graphql15.ObjectType)()
4500
- ], SuccessMessageStatus);
4501
- var FailedMessageStatus = class extends BaseMessageStatus {
4502
- code = "failed";
4503
- reason;
4504
- };
4505
- __name(FailedMessageStatus, "FailedMessageStatus");
4767
+ ], AgentStateInput.prototype, "agentName", void 0);
4506
4768
  _ts_decorate14([
4507
4769
  (0, import_type_graphql15.Field)(() => String),
4508
4770
  _ts_metadata14("design:type", String)
4509
- ], FailedMessageStatus.prototype, "reason", void 0);
4510
- FailedMessageStatus = _ts_decorate14([
4511
- (0, import_type_graphql15.ObjectType)()
4512
- ], FailedMessageStatus);
4513
- var MessageStatusUnion = (0, import_type_graphql15.createUnionType)({
4514
- name: "MessageStatus",
4515
- types: () => [
4516
- PendingMessageStatus,
4517
- SuccessMessageStatus,
4518
- FailedMessageStatus
4519
- ]
4520
- });
4771
+ ], AgentStateInput.prototype, "state", void 0);
4772
+ AgentStateInput = _ts_decorate14([
4773
+ (0, import_type_graphql15.InputType)()
4774
+ ], AgentStateInput);
4521
4775
 
4522
- // src/graphql/types/response-status.type.ts
4523
- var import_graphql_scalars = require("graphql-scalars");
4776
+ // src/graphql/inputs/extensions.input.ts
4524
4777
  var import_type_graphql16 = require("type-graphql");
4525
4778
  function _ts_decorate15(decorators, target, key, desc) {
4526
4779
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4538,95 +4791,41 @@ function _ts_metadata15(k, v) {
4538
4791
  return Reflect.metadata(k, v);
4539
4792
  }
4540
4793
  __name(_ts_metadata15, "_ts_metadata");
4541
- var ResponseStatusCode;
4542
- (function(ResponseStatusCode2) {
4543
- ResponseStatusCode2["Pending"] = "pending";
4544
- ResponseStatusCode2["Success"] = "success";
4545
- ResponseStatusCode2["Failed"] = "failed";
4546
- })(ResponseStatusCode || (ResponseStatusCode = {}));
4547
- (0, import_type_graphql16.registerEnumType)(ResponseStatusCode, {
4548
- name: "ResponseStatusCode"
4549
- });
4550
- var BaseResponseStatus = /* @__PURE__ */ __name(class BaseResponseStatus2 {
4551
- code;
4552
- }, "BaseResponseStatus");
4553
- _ts_decorate15([
4554
- (0, import_type_graphql16.Field)(() => ResponseStatusCode),
4555
- _ts_metadata15("design:type", String)
4556
- ], BaseResponseStatus.prototype, "code", void 0);
4557
- BaseResponseStatus = _ts_decorate15([
4558
- (0, import_type_graphql16.InterfaceType)({
4559
- resolveType(value) {
4560
- if (value.code === "success") {
4561
- return SuccessResponseStatus;
4562
- } else if (value.code === "failed") {
4563
- return FailedResponseStatus;
4564
- } else if (value.code === "pending") {
4565
- return PendingResponseStatus;
4566
- }
4567
- return void 0;
4568
- }
4569
- }),
4570
- (0, import_type_graphql16.ObjectType)()
4571
- ], BaseResponseStatus);
4572
- var PendingResponseStatus = class extends BaseResponseStatus {
4573
- code = "pending";
4574
- };
4575
- __name(PendingResponseStatus, "PendingResponseStatus");
4576
- PendingResponseStatus = _ts_decorate15([
4577
- (0, import_type_graphql16.ObjectType)({
4578
- implements: BaseResponseStatus
4579
- })
4580
- ], PendingResponseStatus);
4581
- var SuccessResponseStatus = class extends BaseResponseStatus {
4582
- code = "success";
4794
+ var ExtensionsInput = class {
4795
+ openaiAssistantAPI;
4583
4796
  };
4584
- __name(SuccessResponseStatus, "SuccessResponseStatus");
4585
- SuccessResponseStatus = _ts_decorate15([
4586
- (0, import_type_graphql16.ObjectType)({
4587
- implements: BaseResponseStatus
4588
- })
4589
- ], SuccessResponseStatus);
4590
- var FailedResponseStatusReason;
4591
- (function(FailedResponseStatusReason2) {
4592
- FailedResponseStatusReason2["GUARDRAILS_VALIDATION_FAILED"] = "GUARDRAILS_VALIDATION_FAILED";
4593
- FailedResponseStatusReason2["MESSAGE_STREAM_INTERRUPTED"] = "MESSAGE_STREAM_INTERRUPTED";
4594
- FailedResponseStatusReason2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
4595
- })(FailedResponseStatusReason || (FailedResponseStatusReason = {}));
4596
- (0, import_type_graphql16.registerEnumType)(FailedResponseStatusReason, {
4597
- name: "FailedResponseStatusReason"
4598
- });
4599
- var FailedResponseStatus = class extends BaseResponseStatus {
4600
- code = "failed";
4601
- reason;
4602
- details = null;
4797
+ __name(ExtensionsInput, "ExtensionsInput");
4798
+ _ts_decorate15([
4799
+ (0, import_type_graphql16.Field)(() => OpenAIApiAssistantAPIInput, {
4800
+ nullable: true
4801
+ }),
4802
+ _ts_metadata15("design:type", typeof OpenAIApiAssistantAPIInput === "undefined" ? Object : OpenAIApiAssistantAPIInput)
4803
+ ], ExtensionsInput.prototype, "openaiAssistantAPI", void 0);
4804
+ ExtensionsInput = _ts_decorate15([
4805
+ (0, import_type_graphql16.InputType)()
4806
+ ], ExtensionsInput);
4807
+ var OpenAIApiAssistantAPIInput = class {
4808
+ runId;
4809
+ threadId;
4603
4810
  };
4604
- __name(FailedResponseStatus, "FailedResponseStatus");
4811
+ __name(OpenAIApiAssistantAPIInput, "OpenAIApiAssistantAPIInput");
4605
4812
  _ts_decorate15([
4606
- (0, import_type_graphql16.Field)(() => FailedResponseStatusReason),
4813
+ (0, import_type_graphql16.Field)(() => String, {
4814
+ nullable: true
4815
+ }),
4607
4816
  _ts_metadata15("design:type", String)
4608
- ], FailedResponseStatus.prototype, "reason", void 0);
4817
+ ], OpenAIApiAssistantAPIInput.prototype, "runId", void 0);
4609
4818
  _ts_decorate15([
4610
- (0, import_type_graphql16.Field)(() => import_graphql_scalars.GraphQLJSON, {
4819
+ (0, import_type_graphql16.Field)(() => String, {
4611
4820
  nullable: true
4612
4821
  }),
4613
- _ts_metadata15("design:type", typeof Record === "undefined" ? Object : Record)
4614
- ], FailedResponseStatus.prototype, "details", void 0);
4615
- FailedResponseStatus = _ts_decorate15([
4616
- (0, import_type_graphql16.ObjectType)({
4617
- implements: BaseResponseStatus
4618
- })
4619
- ], FailedResponseStatus);
4620
- var ResponseStatusUnion = (0, import_type_graphql16.createUnionType)({
4621
- name: "ResponseStatus",
4622
- types: () => [
4623
- PendingResponseStatus,
4624
- SuccessResponseStatus,
4625
- FailedResponseStatus
4626
- ]
4627
- });
4822
+ _ts_metadata15("design:type", String)
4823
+ ], OpenAIApiAssistantAPIInput.prototype, "threadId", void 0);
4824
+ OpenAIApiAssistantAPIInput = _ts_decorate15([
4825
+ (0, import_type_graphql16.InputType)()
4826
+ ], OpenAIApiAssistantAPIInput);
4628
4827
 
4629
- // src/graphql/types/extensions-response.type.ts
4828
+ // src/graphql/inputs/meta-event.input.ts
4630
4829
  var import_type_graphql17 = require("type-graphql");
4631
4830
  function _ts_decorate16(decorators, target, key, desc) {
4632
4831
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4644,41 +4843,40 @@ function _ts_metadata16(k, v) {
4644
4843
  return Reflect.metadata(k, v);
4645
4844
  }
4646
4845
  __name(_ts_metadata16, "_ts_metadata");
4647
- var ExtensionsResponse = class {
4648
- openaiAssistantAPI;
4846
+ var MetaEventInput = class {
4847
+ name;
4848
+ value;
4849
+ response;
4850
+ messages;
4649
4851
  };
4650
- __name(ExtensionsResponse, "ExtensionsResponse");
4852
+ __name(MetaEventInput, "MetaEventInput");
4651
4853
  _ts_decorate16([
4652
- (0, import_type_graphql17.Field)(() => OpenAIApiAssistantAPIResponse, {
4653
- nullable: true
4654
- }),
4655
- _ts_metadata16("design:type", typeof OpenAIApiAssistantAPIResponse === "undefined" ? Object : OpenAIApiAssistantAPIResponse)
4656
- ], ExtensionsResponse.prototype, "openaiAssistantAPI", void 0);
4657
- ExtensionsResponse = _ts_decorate16([
4658
- (0, import_type_graphql17.ObjectType)()
4659
- ], ExtensionsResponse);
4660
- var OpenAIApiAssistantAPIResponse = class {
4661
- runId;
4662
- threadId;
4663
- };
4664
- __name(OpenAIApiAssistantAPIResponse, "OpenAIApiAssistantAPIResponse");
4854
+ (0, import_type_graphql17.Field)(() => MetaEventName),
4855
+ _ts_metadata16("design:type", typeof MetaEventName === "undefined" ? Object : MetaEventName)
4856
+ ], MetaEventInput.prototype, "name", void 0);
4857
+ _ts_decorate16([
4858
+ (0, import_type_graphql17.Field)(() => String),
4859
+ _ts_metadata16("design:type", String)
4860
+ ], MetaEventInput.prototype, "value", void 0);
4665
4861
  _ts_decorate16([
4666
4862
  (0, import_type_graphql17.Field)(() => String, {
4667
4863
  nullable: true
4668
4864
  }),
4669
4865
  _ts_metadata16("design:type", String)
4670
- ], OpenAIApiAssistantAPIResponse.prototype, "runId", void 0);
4866
+ ], MetaEventInput.prototype, "response", void 0);
4671
4867
  _ts_decorate16([
4672
- (0, import_type_graphql17.Field)(() => String, {
4868
+ (0, import_type_graphql17.Field)(() => [
4869
+ MessageInput
4870
+ ], {
4673
4871
  nullable: true
4674
4872
  }),
4675
- _ts_metadata16("design:type", String)
4676
- ], OpenAIApiAssistantAPIResponse.prototype, "threadId", void 0);
4677
- OpenAIApiAssistantAPIResponse = _ts_decorate16([
4678
- (0, import_type_graphql17.ObjectType)()
4679
- ], OpenAIApiAssistantAPIResponse);
4873
+ _ts_metadata16("design:type", Array)
4874
+ ], MetaEventInput.prototype, "messages", void 0);
4875
+ MetaEventInput = _ts_decorate16([
4876
+ (0, import_type_graphql17.InputType)()
4877
+ ], MetaEventInput);
4680
4878
 
4681
- // src/graphql/types/copilot-response.type.ts
4879
+ // src/graphql/inputs/generate-copilot-response.input.ts
4682
4880
  function _ts_decorate17(decorators, target, key, desc) {
4683
4881
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4684
4882
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -4695,221 +4893,111 @@ function _ts_metadata17(k, v) {
4695
4893
  return Reflect.metadata(k, v);
4696
4894
  }
4697
4895
  __name(_ts_metadata17, "_ts_metadata");
4698
- var BaseMessageOutput = class {
4699
- id;
4700
- createdAt;
4701
- status;
4896
+ var GenerateCopilotResponseMetadataInput = class {
4897
+ requestType;
4702
4898
  };
4703
- __name(BaseMessageOutput, "BaseMessageOutput");
4704
- _ts_decorate17([
4705
- (0, import_type_graphql18.Field)(() => String),
4706
- _ts_metadata17("design:type", String)
4707
- ], BaseMessageOutput.prototype, "id", void 0);
4708
- _ts_decorate17([
4709
- (0, import_type_graphql18.Field)(() => Date),
4710
- _ts_metadata17("design:type", typeof Date === "undefined" ? Object : Date)
4711
- ], BaseMessageOutput.prototype, "createdAt", void 0);
4899
+ __name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
4712
4900
  _ts_decorate17([
4713
- (0, import_type_graphql18.Field)(() => MessageStatusUnion),
4714
- _ts_metadata17("design:type", Object)
4715
- ], BaseMessageOutput.prototype, "status", void 0);
4716
- BaseMessageOutput = _ts_decorate17([
4717
- (0, import_type_graphql18.InterfaceType)({
4718
- resolveType(value) {
4719
- if (value.hasOwnProperty("content")) {
4720
- return TextMessageOutput;
4721
- } else if (value.hasOwnProperty("name")) {
4722
- return ActionExecutionMessageOutput;
4723
- } else if (value.hasOwnProperty("result")) {
4724
- return ResultMessageOutput;
4725
- } else if (value.hasOwnProperty("state")) {
4726
- return AgentStateMessageOutput;
4727
- } else if (value.name === MetaEventName.LangGraphInterruptEvent) {
4728
- return LangGraphInterruptEvent;
4729
- }
4730
- return void 0;
4731
- }
4732
- })
4733
- ], BaseMessageOutput);
4734
- var TextMessageOutput = class {
4735
- role;
4736
- content;
4737
- parentMessageId;
4901
+ (0, import_type_graphql18.Field)(() => CopilotRequestType, {
4902
+ nullable: true
4903
+ }),
4904
+ _ts_metadata17("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
4905
+ ], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
4906
+ GenerateCopilotResponseMetadataInput = _ts_decorate17([
4907
+ (0, import_type_graphql18.InputType)()
4908
+ ], GenerateCopilotResponseMetadataInput);
4909
+ var GenerateCopilotResponseInput = class {
4910
+ metadata;
4911
+ threadId;
4912
+ runId;
4913
+ messages;
4914
+ frontend;
4915
+ cloud;
4916
+ forwardedParameters;
4917
+ agentSession;
4918
+ agentState;
4919
+ agentStates;
4920
+ extensions;
4921
+ metaEvents;
4738
4922
  };
4739
- __name(TextMessageOutput, "TextMessageOutput");
4740
- _ts_decorate17([
4741
- (0, import_type_graphql18.Field)(() => MessageRole),
4742
- _ts_metadata17("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4743
- ], TextMessageOutput.prototype, "role", void 0);
4923
+ __name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
4744
4924
  _ts_decorate17([
4745
- (0, import_type_graphql18.Field)(() => [
4746
- String
4747
- ]),
4748
- _ts_metadata17("design:type", Array)
4749
- ], TextMessageOutput.prototype, "content", void 0);
4925
+ (0, import_type_graphql18.Field)(() => GenerateCopilotResponseMetadataInput, {
4926
+ nullable: false
4927
+ }),
4928
+ _ts_metadata17("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
4929
+ ], GenerateCopilotResponseInput.prototype, "metadata", void 0);
4750
4930
  _ts_decorate17([
4751
4931
  (0, import_type_graphql18.Field)(() => String, {
4752
4932
  nullable: true
4753
4933
  }),
4754
4934
  _ts_metadata17("design:type", String)
4755
- ], TextMessageOutput.prototype, "parentMessageId", void 0);
4756
- TextMessageOutput = _ts_decorate17([
4757
- (0, import_type_graphql18.ObjectType)({
4758
- implements: BaseMessageOutput
4759
- })
4760
- ], TextMessageOutput);
4761
- var ActionExecutionMessageOutput = class {
4762
- name;
4763
- scope;
4764
- arguments;
4765
- parentMessageId;
4766
- };
4767
- __name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
4768
- _ts_decorate17([
4769
- (0, import_type_graphql18.Field)(() => String),
4770
- _ts_metadata17("design:type", String)
4771
- ], ActionExecutionMessageOutput.prototype, "name", void 0);
4935
+ ], GenerateCopilotResponseInput.prototype, "threadId", void 0);
4772
4936
  _ts_decorate17([
4773
4937
  (0, import_type_graphql18.Field)(() => String, {
4774
- nullable: true,
4775
- deprecationReason: "This field will be removed in a future version"
4938
+ nullable: true
4776
4939
  }),
4777
4940
  _ts_metadata17("design:type", String)
4778
- ], ActionExecutionMessageOutput.prototype, "scope", void 0);
4941
+ ], GenerateCopilotResponseInput.prototype, "runId", void 0);
4779
4942
  _ts_decorate17([
4780
4943
  (0, import_type_graphql18.Field)(() => [
4781
- String
4944
+ MessageInput
4782
4945
  ]),
4783
4946
  _ts_metadata17("design:type", Array)
4784
- ], ActionExecutionMessageOutput.prototype, "arguments", void 0);
4947
+ ], GenerateCopilotResponseInput.prototype, "messages", void 0);
4785
4948
  _ts_decorate17([
4786
- (0, import_type_graphql18.Field)(() => String, {
4949
+ (0, import_type_graphql18.Field)(() => FrontendInput),
4950
+ _ts_metadata17("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
4951
+ ], GenerateCopilotResponseInput.prototype, "frontend", void 0);
4952
+ _ts_decorate17([
4953
+ (0, import_type_graphql18.Field)(() => CloudInput, {
4787
4954
  nullable: true
4788
4955
  }),
4789
- _ts_metadata17("design:type", String)
4790
- ], ActionExecutionMessageOutput.prototype, "parentMessageId", void 0);
4791
- ActionExecutionMessageOutput = _ts_decorate17([
4792
- (0, import_type_graphql18.ObjectType)({
4793
- implements: BaseMessageOutput
4794
- })
4795
- ], ActionExecutionMessageOutput);
4796
- var ResultMessageOutput = class {
4797
- actionExecutionId;
4798
- actionName;
4799
- result;
4800
- };
4801
- __name(ResultMessageOutput, "ResultMessageOutput");
4802
- _ts_decorate17([
4803
- (0, import_type_graphql18.Field)(() => String),
4804
- _ts_metadata17("design:type", String)
4805
- ], ResultMessageOutput.prototype, "actionExecutionId", void 0);
4806
- _ts_decorate17([
4807
- (0, import_type_graphql18.Field)(() => String),
4808
- _ts_metadata17("design:type", String)
4809
- ], ResultMessageOutput.prototype, "actionName", void 0);
4810
- _ts_decorate17([
4811
- (0, import_type_graphql18.Field)(() => String),
4812
- _ts_metadata17("design:type", String)
4813
- ], ResultMessageOutput.prototype, "result", void 0);
4814
- ResultMessageOutput = _ts_decorate17([
4815
- (0, import_type_graphql18.ObjectType)({
4816
- implements: BaseMessageOutput
4817
- })
4818
- ], ResultMessageOutput);
4819
- var AgentStateMessageOutput = class {
4820
- threadId;
4821
- agentName;
4822
- nodeName;
4823
- runId;
4824
- active;
4825
- role;
4826
- state;
4827
- running;
4828
- };
4829
- __name(AgentStateMessageOutput, "AgentStateMessageOutput");
4830
- _ts_decorate17([
4831
- (0, import_type_graphql18.Field)(() => String),
4832
- _ts_metadata17("design:type", String)
4833
- ], AgentStateMessageOutput.prototype, "threadId", void 0);
4834
- _ts_decorate17([
4835
- (0, import_type_graphql18.Field)(() => String),
4836
- _ts_metadata17("design:type", String)
4837
- ], AgentStateMessageOutput.prototype, "agentName", void 0);
4838
- _ts_decorate17([
4839
- (0, import_type_graphql18.Field)(() => String),
4840
- _ts_metadata17("design:type", String)
4841
- ], AgentStateMessageOutput.prototype, "nodeName", void 0);
4842
- _ts_decorate17([
4843
- (0, import_type_graphql18.Field)(() => String),
4844
- _ts_metadata17("design:type", String)
4845
- ], AgentStateMessageOutput.prototype, "runId", void 0);
4846
- _ts_decorate17([
4847
- (0, import_type_graphql18.Field)(() => Boolean),
4848
- _ts_metadata17("design:type", Boolean)
4849
- ], AgentStateMessageOutput.prototype, "active", void 0);
4850
- _ts_decorate17([
4851
- (0, import_type_graphql18.Field)(() => MessageRole),
4852
- _ts_metadata17("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4853
- ], AgentStateMessageOutput.prototype, "role", void 0);
4854
- _ts_decorate17([
4855
- (0, import_type_graphql18.Field)(() => String),
4856
- _ts_metadata17("design:type", String)
4857
- ], AgentStateMessageOutput.prototype, "state", void 0);
4858
- _ts_decorate17([
4859
- (0, import_type_graphql18.Field)(() => Boolean),
4860
- _ts_metadata17("design:type", Boolean)
4861
- ], AgentStateMessageOutput.prototype, "running", void 0);
4862
- AgentStateMessageOutput = _ts_decorate17([
4863
- (0, import_type_graphql18.ObjectType)({
4864
- implements: BaseMessageOutput
4865
- })
4866
- ], AgentStateMessageOutput);
4867
- var CopilotResponse = class {
4868
- threadId;
4869
- status;
4870
- runId;
4871
- messages;
4872
- extensions;
4873
- metaEvents;
4874
- };
4875
- __name(CopilotResponse, "CopilotResponse");
4956
+ _ts_metadata17("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
4957
+ ], GenerateCopilotResponseInput.prototype, "cloud", void 0);
4876
4958
  _ts_decorate17([
4877
- (0, import_type_graphql18.Field)(() => String),
4878
- _ts_metadata17("design:type", String)
4879
- ], CopilotResponse.prototype, "threadId", void 0);
4959
+ (0, import_type_graphql18.Field)(() => ForwardedParametersInput, {
4960
+ nullable: true
4961
+ }),
4962
+ _ts_metadata17("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
4963
+ ], GenerateCopilotResponseInput.prototype, "forwardedParameters", void 0);
4880
4964
  _ts_decorate17([
4881
- (0, import_type_graphql18.Field)(() => ResponseStatusUnion),
4882
- _ts_metadata17("design:type", Object)
4883
- ], CopilotResponse.prototype, "status", void 0);
4965
+ (0, import_type_graphql18.Field)(() => AgentSessionInput, {
4966
+ nullable: true
4967
+ }),
4968
+ _ts_metadata17("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
4969
+ ], GenerateCopilotResponseInput.prototype, "agentSession", void 0);
4884
4970
  _ts_decorate17([
4885
- (0, import_type_graphql18.Field)({
4971
+ (0, import_type_graphql18.Field)(() => AgentStateInput, {
4886
4972
  nullable: true
4887
4973
  }),
4888
- _ts_metadata17("design:type", String)
4889
- ], CopilotResponse.prototype, "runId", void 0);
4974
+ _ts_metadata17("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
4975
+ ], GenerateCopilotResponseInput.prototype, "agentState", void 0);
4890
4976
  _ts_decorate17([
4891
4977
  (0, import_type_graphql18.Field)(() => [
4892
- BaseMessageOutput
4893
- ]),
4978
+ AgentStateInput
4979
+ ], {
4980
+ nullable: true
4981
+ }),
4894
4982
  _ts_metadata17("design:type", Array)
4895
- ], CopilotResponse.prototype, "messages", void 0);
4983
+ ], GenerateCopilotResponseInput.prototype, "agentStates", void 0);
4896
4984
  _ts_decorate17([
4897
- (0, import_type_graphql18.Field)(() => ExtensionsResponse, {
4985
+ (0, import_type_graphql18.Field)(() => ExtensionsInput, {
4898
4986
  nullable: true
4899
4987
  }),
4900
- _ts_metadata17("design:type", typeof ExtensionsResponse === "undefined" ? Object : ExtensionsResponse)
4901
- ], CopilotResponse.prototype, "extensions", void 0);
4988
+ _ts_metadata17("design:type", typeof ExtensionsInput === "undefined" ? Object : ExtensionsInput)
4989
+ ], GenerateCopilotResponseInput.prototype, "extensions", void 0);
4902
4990
  _ts_decorate17([
4903
4991
  (0, import_type_graphql18.Field)(() => [
4904
- BaseMetaEvent
4992
+ MetaEventInput
4905
4993
  ], {
4906
4994
  nullable: true
4907
4995
  }),
4908
4996
  _ts_metadata17("design:type", Array)
4909
- ], CopilotResponse.prototype, "metaEvents", void 0);
4910
- CopilotResponse = _ts_decorate17([
4911
- (0, import_type_graphql18.ObjectType)()
4912
- ], CopilotResponse);
4997
+ ], GenerateCopilotResponseInput.prototype, "metaEvents", void 0);
4998
+ GenerateCopilotResponseInput = _ts_decorate17([
4999
+ (0, import_type_graphql18.InputType)()
5000
+ ], GenerateCopilotResponseInput);
4913
5001
 
4914
5002
  // src/graphql/resolvers/copilot.resolver.ts
4915
5003
  var import_graphql_yoga = require("graphql-yoga");
@@ -5187,6 +5275,40 @@ var CopilotResolver = class {
5187
5275
  value: event.value
5188
5276
  }));
5189
5277
  break;
5278
+ case RuntimeMetaEventName.CopilotKitLangGraphInterruptEvent:
5279
+ push((0, import_class_transformer3.plainToInstance)(CopilotKitLangGraphInterruptEvent, {
5280
+ type: event.type,
5281
+ name: event.name,
5282
+ data: {
5283
+ value: typeof event.data.value === "string" ? event.data.value : JSON.stringify(event.data.value),
5284
+ messages: event.data.messages.map((message) => {
5285
+ if (message.type === "TextMessage" || "content" in message && "role" in message) {
5286
+ return (0, import_class_transformer3.plainToInstance)(TextMessage, {
5287
+ id: message.id,
5288
+ createdAt: /* @__PURE__ */ new Date(),
5289
+ content: [
5290
+ message.content
5291
+ ],
5292
+ role: message.role,
5293
+ status: new SuccessMessageStatus()
5294
+ });
5295
+ }
5296
+ if ("arguments" in message) {
5297
+ return (0, import_class_transformer3.plainToInstance)(ActionExecutionMessage, {
5298
+ name: message.name,
5299
+ id: message.id,
5300
+ arguments: [
5301
+ JSON.stringify(message.arguments)
5302
+ ],
5303
+ createdAt: /* @__PURE__ */ new Date(),
5304
+ status: new SuccessMessageStatus()
5305
+ });
5306
+ }
5307
+ throw new Error("Unknown message in metaEvents copilot resolver");
5308
+ })
5309
+ }
5310
+ }));
5311
+ break;
5190
5312
  }
5191
5313
  },
5192
5314
  error: (err) => {