@copilotkit/runtime 1.5.15-next.7 → 1.5.15

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 +25 -0
  2. package/__snapshots__/schema/schema.graphql +14 -1
  3. package/dist/{chunk-F4WILQ32.mjs → chunk-2ITUMI4O.mjs} +2 -2
  4. package/dist/{chunk-BUEAVIXA.mjs → chunk-GRU4U3VO.mjs} +2 -2
  5. package/dist/{chunk-OMS5GY45.mjs → chunk-HOTR3KYO.mjs} +538 -416
  6. package/dist/chunk-HOTR3KYO.mjs.map +1 -0
  7. package/dist/{chunk-65VBDTR4.mjs → chunk-USNCP24V.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-2ITUMI4O.mjs.map} +0 -0
  49. /package/dist/{chunk-BUEAVIXA.mjs.map → chunk-GRU4U3VO.mjs.map} +0 -0
  50. /package/dist/{chunk-65VBDTR4.mjs.map → chunk-USNCP24V.mjs.map} +0 -0
package/dist/lib/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",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -1255,10 +1255,12 @@ var LangGraphEventTypes;
1255
1255
  LangGraphEventTypes2["OnCopilotKitEmitToolCall"] = "on_copilotkit_emit_tool_call";
1256
1256
  LangGraphEventTypes2["OnCustomEvent"] = "on_custom_event";
1257
1257
  LangGraphEventTypes2["OnInterrupt"] = "on_interrupt";
1258
+ LangGraphEventTypes2["OnCopilotKitInterrupt"] = "on_copilotkit_interrupt";
1258
1259
  })(LangGraphEventTypes || (LangGraphEventTypes = {}));
1259
1260
  var MetaEventNames;
1260
1261
  (function(MetaEventNames2) {
1261
1262
  MetaEventNames2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1263
+ MetaEventNames2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1262
1264
  })(MetaEventNames || (MetaEventNames = {}));
1263
1265
  var CustomEventNames;
1264
1266
  (function(CustomEventNames2) {
@@ -1363,6 +1365,13 @@ var RemoteLangGraphEventSource = class {
1363
1365
  value: acc.event.value
1364
1366
  });
1365
1367
  }
1368
+ if (acc.event.event === LangGraphEventTypes.OnCopilotKitInterrupt) {
1369
+ events.push({
1370
+ type: RuntimeEventTypes.MetaEvent,
1371
+ name: RuntimeMetaEventName.CopilotKitLangGraphInterruptEvent,
1372
+ data: acc.event.data
1373
+ });
1374
+ }
1366
1375
  const responseMetadata = this.getResponseMetadata(acc.event);
1367
1376
  if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls" && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)) {
1368
1377
  events.push({
@@ -1531,6 +1540,12 @@ var ActionInputAvailability;
1531
1540
  });
1532
1541
 
1533
1542
  // src/graphql/types/meta-events.type.ts
1543
+ var import_type_graphql6 = require("type-graphql");
1544
+
1545
+ // src/graphql/types/copilot-response.type.ts
1546
+ var import_type_graphql5 = require("type-graphql");
1547
+
1548
+ // src/graphql/types/message-status.type.ts
1534
1549
  var import_type_graphql2 = require("type-graphql");
1535
1550
  function _ts_decorate(decorators, target, key, desc) {
1536
1551
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1548,151 +1563,634 @@ function _ts_metadata(k, v) {
1548
1563
  return Reflect.metadata(k, v);
1549
1564
  }
1550
1565
  __name(_ts_metadata, "_ts_metadata");
1551
- var MetaEventName;
1552
- (function(MetaEventName2) {
1553
- MetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1554
- })(MetaEventName || (MetaEventName = {}));
1555
- (0, import_type_graphql2.registerEnumType)(MetaEventName, {
1556
- name: "MetaEventName",
1557
- description: "Meta event types"
1566
+ var MessageStatusCode;
1567
+ (function(MessageStatusCode2) {
1568
+ MessageStatusCode2["Pending"] = "pending";
1569
+ MessageStatusCode2["Success"] = "success";
1570
+ MessageStatusCode2["Failed"] = "failed";
1571
+ })(MessageStatusCode || (MessageStatusCode = {}));
1572
+ (0, import_type_graphql2.registerEnumType)(MessageStatusCode, {
1573
+ name: "MessageStatusCode"
1558
1574
  });
1559
- var BaseMetaEvent = class {
1560
- type = "MetaEvent";
1561
- name;
1562
- };
1563
- __name(BaseMetaEvent, "BaseMetaEvent");
1564
- _ts_decorate([
1565
- (0, import_type_graphql2.Field)(() => String),
1566
- _ts_metadata("design:type", String)
1567
- ], BaseMetaEvent.prototype, "type", void 0);
1575
+ var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
1576
+ code;
1577
+ }, "BaseMessageStatus");
1568
1578
  _ts_decorate([
1569
- (0, import_type_graphql2.Field)(() => MetaEventName),
1579
+ (0, import_type_graphql2.Field)(() => MessageStatusCode),
1570
1580
  _ts_metadata("design:type", String)
1571
- ], BaseMetaEvent.prototype, "name", void 0);
1572
- BaseMetaEvent = _ts_decorate([
1573
- (0, import_type_graphql2.InterfaceType)()
1574
- ], BaseMetaEvent);
1575
- var LangGraphInterruptEvent = class {
1576
- name = "LangGraphInterruptEvent";
1577
- value;
1578
- response;
1581
+ ], BaseMessageStatus.prototype, "code", void 0);
1582
+ BaseMessageStatus = _ts_decorate([
1583
+ (0, import_type_graphql2.ObjectType)()
1584
+ ], BaseMessageStatus);
1585
+ var PendingMessageStatus = class extends BaseMessageStatus {
1586
+ code = "pending";
1579
1587
  };
1580
- __name(LangGraphInterruptEvent, "LangGraphInterruptEvent");
1581
- _ts_decorate([
1582
- (0, import_type_graphql2.Field)(() => MetaEventName),
1583
- _ts_metadata("design:type", typeof MetaEventName === "undefined" || false ? Object : "LangGraphInterruptEvent")
1584
- ], LangGraphInterruptEvent.prototype, "name", void 0);
1588
+ __name(PendingMessageStatus, "PendingMessageStatus");
1589
+ PendingMessageStatus = _ts_decorate([
1590
+ (0, import_type_graphql2.ObjectType)()
1591
+ ], PendingMessageStatus);
1592
+ var SuccessMessageStatus = class extends BaseMessageStatus {
1593
+ code = "success";
1594
+ };
1595
+ __name(SuccessMessageStatus, "SuccessMessageStatus");
1596
+ SuccessMessageStatus = _ts_decorate([
1597
+ (0, import_type_graphql2.ObjectType)()
1598
+ ], SuccessMessageStatus);
1599
+ var FailedMessageStatus = class extends BaseMessageStatus {
1600
+ code = "failed";
1601
+ reason;
1602
+ };
1603
+ __name(FailedMessageStatus, "FailedMessageStatus");
1585
1604
  _ts_decorate([
1586
1605
  (0, import_type_graphql2.Field)(() => String),
1587
1606
  _ts_metadata("design:type", String)
1588
- ], LangGraphInterruptEvent.prototype, "value", void 0);
1589
- _ts_decorate([
1590
- (0, import_type_graphql2.Field)(() => String, {
1607
+ ], FailedMessageStatus.prototype, "reason", void 0);
1608
+ FailedMessageStatus = _ts_decorate([
1609
+ (0, import_type_graphql2.ObjectType)()
1610
+ ], FailedMessageStatus);
1611
+ var MessageStatusUnion = (0, import_type_graphql2.createUnionType)({
1612
+ name: "MessageStatus",
1613
+ types: () => [
1614
+ PendingMessageStatus,
1615
+ SuccessMessageStatus,
1616
+ FailedMessageStatus
1617
+ ]
1618
+ });
1619
+
1620
+ // src/graphql/types/response-status.type.ts
1621
+ var import_graphql_scalars = require("graphql-scalars");
1622
+ var import_type_graphql3 = require("type-graphql");
1623
+ function _ts_decorate2(decorators, target, key, desc) {
1624
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1625
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1626
+ r = Reflect.decorate(decorators, target, key, desc);
1627
+ else
1628
+ for (var i = decorators.length - 1; i >= 0; i--)
1629
+ if (d = decorators[i])
1630
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1631
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1632
+ }
1633
+ __name(_ts_decorate2, "_ts_decorate");
1634
+ function _ts_metadata2(k, v) {
1635
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1636
+ return Reflect.metadata(k, v);
1637
+ }
1638
+ __name(_ts_metadata2, "_ts_metadata");
1639
+ var ResponseStatusCode;
1640
+ (function(ResponseStatusCode2) {
1641
+ ResponseStatusCode2["Pending"] = "pending";
1642
+ ResponseStatusCode2["Success"] = "success";
1643
+ ResponseStatusCode2["Failed"] = "failed";
1644
+ })(ResponseStatusCode || (ResponseStatusCode = {}));
1645
+ (0, import_type_graphql3.registerEnumType)(ResponseStatusCode, {
1646
+ name: "ResponseStatusCode"
1647
+ });
1648
+ var BaseResponseStatus = /* @__PURE__ */ __name(class BaseResponseStatus2 {
1649
+ code;
1650
+ }, "BaseResponseStatus");
1651
+ _ts_decorate2([
1652
+ (0, import_type_graphql3.Field)(() => ResponseStatusCode),
1653
+ _ts_metadata2("design:type", String)
1654
+ ], BaseResponseStatus.prototype, "code", void 0);
1655
+ BaseResponseStatus = _ts_decorate2([
1656
+ (0, import_type_graphql3.InterfaceType)({
1657
+ resolveType(value) {
1658
+ if (value.code === "success") {
1659
+ return SuccessResponseStatus;
1660
+ } else if (value.code === "failed") {
1661
+ return FailedResponseStatus;
1662
+ } else if (value.code === "pending") {
1663
+ return PendingResponseStatus;
1664
+ }
1665
+ return void 0;
1666
+ }
1667
+ }),
1668
+ (0, import_type_graphql3.ObjectType)()
1669
+ ], BaseResponseStatus);
1670
+ var PendingResponseStatus = class extends BaseResponseStatus {
1671
+ code = "pending";
1672
+ };
1673
+ __name(PendingResponseStatus, "PendingResponseStatus");
1674
+ PendingResponseStatus = _ts_decorate2([
1675
+ (0, import_type_graphql3.ObjectType)({
1676
+ implements: BaseResponseStatus
1677
+ })
1678
+ ], PendingResponseStatus);
1679
+ var SuccessResponseStatus = class extends BaseResponseStatus {
1680
+ code = "success";
1681
+ };
1682
+ __name(SuccessResponseStatus, "SuccessResponseStatus");
1683
+ SuccessResponseStatus = _ts_decorate2([
1684
+ (0, import_type_graphql3.ObjectType)({
1685
+ implements: BaseResponseStatus
1686
+ })
1687
+ ], SuccessResponseStatus);
1688
+ var FailedResponseStatusReason;
1689
+ (function(FailedResponseStatusReason2) {
1690
+ FailedResponseStatusReason2["GUARDRAILS_VALIDATION_FAILED"] = "GUARDRAILS_VALIDATION_FAILED";
1691
+ FailedResponseStatusReason2["MESSAGE_STREAM_INTERRUPTED"] = "MESSAGE_STREAM_INTERRUPTED";
1692
+ FailedResponseStatusReason2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
1693
+ })(FailedResponseStatusReason || (FailedResponseStatusReason = {}));
1694
+ (0, import_type_graphql3.registerEnumType)(FailedResponseStatusReason, {
1695
+ name: "FailedResponseStatusReason"
1696
+ });
1697
+ var FailedResponseStatus = class extends BaseResponseStatus {
1698
+ code = "failed";
1699
+ reason;
1700
+ details = null;
1701
+ };
1702
+ __name(FailedResponseStatus, "FailedResponseStatus");
1703
+ _ts_decorate2([
1704
+ (0, import_type_graphql3.Field)(() => FailedResponseStatusReason),
1705
+ _ts_metadata2("design:type", String)
1706
+ ], FailedResponseStatus.prototype, "reason", void 0);
1707
+ _ts_decorate2([
1708
+ (0, import_type_graphql3.Field)(() => import_graphql_scalars.GraphQLJSON, {
1591
1709
  nullable: true
1592
1710
  }),
1593
- _ts_metadata("design:type", String)
1594
- ], LangGraphInterruptEvent.prototype, "response", void 0);
1595
- LangGraphInterruptEvent = _ts_decorate([
1596
- (0, import_type_graphql2.ObjectType)({
1597
- implements: BaseMetaEvent
1711
+ _ts_metadata2("design:type", typeof Record === "undefined" ? Object : Record)
1712
+ ], FailedResponseStatus.prototype, "details", void 0);
1713
+ FailedResponseStatus = _ts_decorate2([
1714
+ (0, import_type_graphql3.ObjectType)({
1715
+ implements: BaseResponseStatus
1598
1716
  })
1599
- ], LangGraphInterruptEvent);
1717
+ ], FailedResponseStatus);
1718
+ var ResponseStatusUnion = (0, import_type_graphql3.createUnionType)({
1719
+ name: "ResponseStatus",
1720
+ types: () => [
1721
+ PendingResponseStatus,
1722
+ SuccessResponseStatus,
1723
+ FailedResponseStatus
1724
+ ]
1725
+ });
1600
1726
 
1601
- // src/lib/runtime/remote-lg-action.ts
1602
- async function execute(args) {
1603
- return new ReadableStream({
1604
- async start(controller) {
1605
- try {
1606
- await streamEvents(controller, args);
1607
- controller.close();
1608
- } catch (err) {
1609
- }
1610
- }
1611
- });
1727
+ // src/graphql/types/extensions-response.type.ts
1728
+ var import_type_graphql4 = require("type-graphql");
1729
+ function _ts_decorate3(decorators, target, key, desc) {
1730
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1731
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1732
+ r = Reflect.decorate(decorators, target, key, desc);
1733
+ else
1734
+ for (var i = decorators.length - 1; i >= 0; i--)
1735
+ if (d = decorators[i])
1736
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1737
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1612
1738
  }
1613
- __name(execute, "execute");
1614
- async function streamEvents(controller, args) {
1615
- var _a, _b, _c, _d, _e, _f, _g, _h;
1616
- const { deploymentUrl, langsmithApiKey, threadId: argsInitialThreadId, agent, nodeName: initialNodeName, state: initialState, messages, actions, logger: logger2, properties, metaEvents } = args;
1617
- let nodeName = initialNodeName;
1618
- let state = initialState;
1619
- const { name, assistantId: initialAssistantId } = agent;
1620
- const propertyHeaders = properties.authorization ? {
1621
- authorization: `Bearer ${properties.authorization}`
1622
- } : null;
1623
- const client = new import_langgraph_sdk.Client({
1624
- apiUrl: deploymentUrl,
1625
- apiKey: langsmithApiKey,
1626
- defaultHeaders: {
1627
- ...propertyHeaders
1628
- }
1629
- });
1630
- let threadId = argsInitialThreadId ?? (0, import_shared8.randomUUID)();
1631
- if (argsInitialThreadId && argsInitialThreadId.startsWith("ck-")) {
1632
- threadId = argsInitialThreadId.substring(3);
1633
- }
1634
- if (!(0, import_shared8.isValidUUID)(threadId)) {
1635
- console.warn(`Cannot use the threadId ${threadId} with LangGraph Platform. Must be a valid UUID.`);
1636
- }
1637
- let wasInitiatedWithExistingThread = true;
1638
- try {
1639
- await client.threads.get(threadId);
1640
- } catch (error) {
1641
- wasInitiatedWithExistingThread = false;
1642
- await client.threads.create({
1643
- threadId
1644
- });
1645
- }
1646
- let agentState = {
1647
- values: {}
1648
- };
1649
- if (wasInitiatedWithExistingThread) {
1650
- agentState = await client.threads.getState(threadId);
1651
- }
1652
- const agentStateValues = agentState.values;
1653
- state.messages = agentStateValues.messages;
1654
- const mode = threadId && nodeName != "__end__" && nodeName != void 0 && nodeName != null ? "continue" : "start";
1655
- let formattedMessages = [];
1656
- try {
1657
- formattedMessages = copilotkitMessagesToLangChain(messages);
1658
- } catch (e) {
1659
- logger2.error(e, `Error event thrown: ${e.message}`);
1660
- }
1661
- state = langGraphDefaultMergeState(state, formattedMessages, actions, name);
1662
- const lgInterruptEvent = metaEvents == null ? void 0 : metaEvents.find((ev) => ev.name === MetaEventName.LangGraphInterruptEvent);
1663
- if (mode === "continue" && !lgInterruptEvent) {
1664
- await client.threads.updateState(threadId, {
1665
- values: state,
1666
- asNode: nodeName
1667
- });
1668
- }
1669
- let streamInfo = {
1670
- hashedLgcKey: (0, import_node_crypto.createHash)("sha256").update(langsmithApiKey).digest("hex")
1671
- };
1672
- const assistants = await client.assistants.search();
1673
- const retrievedAssistant = assistants.find((a) => a.name === name || a.assistant_id === initialAssistantId);
1674
- if (!retrievedAssistant) {
1675
- telemetry_client_default.capture("oss.runtime.agent_execution_stream_errored", {
1676
- ...streamInfo,
1677
- error: `Found no assistants for given information, while ${assistants.length} assistants exists`
1678
- });
1679
- console.error(`
1680
- No agent found for the agent name specified in CopilotKit provider
1681
- Please check your available agents or provide an agent ID in the LangGraph Platform endpoint definition.
1682
-
1683
-
1684
- These are the available agents: [${assistants.map((a) => `${a.name} (ID: ${a.assistant_id})`).join(", ")}]
1685
- `);
1686
- throw new Error("No agent id found");
1739
+ __name(_ts_decorate3, "_ts_decorate");
1740
+ function _ts_metadata3(k, v) {
1741
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1742
+ return Reflect.metadata(k, v);
1743
+ }
1744
+ __name(_ts_metadata3, "_ts_metadata");
1745
+ var ExtensionsResponse = class {
1746
+ openaiAssistantAPI;
1747
+ };
1748
+ __name(ExtensionsResponse, "ExtensionsResponse");
1749
+ _ts_decorate3([
1750
+ (0, import_type_graphql4.Field)(() => OpenAIApiAssistantAPIResponse, {
1751
+ nullable: true
1752
+ }),
1753
+ _ts_metadata3("design:type", typeof OpenAIApiAssistantAPIResponse === "undefined" ? Object : OpenAIApiAssistantAPIResponse)
1754
+ ], ExtensionsResponse.prototype, "openaiAssistantAPI", void 0);
1755
+ ExtensionsResponse = _ts_decorate3([
1756
+ (0, import_type_graphql4.ObjectType)()
1757
+ ], ExtensionsResponse);
1758
+ var OpenAIApiAssistantAPIResponse = class {
1759
+ runId;
1760
+ threadId;
1761
+ };
1762
+ __name(OpenAIApiAssistantAPIResponse, "OpenAIApiAssistantAPIResponse");
1763
+ _ts_decorate3([
1764
+ (0, import_type_graphql4.Field)(() => String, {
1765
+ nullable: true
1766
+ }),
1767
+ _ts_metadata3("design:type", String)
1768
+ ], OpenAIApiAssistantAPIResponse.prototype, "runId", void 0);
1769
+ _ts_decorate3([
1770
+ (0, import_type_graphql4.Field)(() => String, {
1771
+ nullable: true
1772
+ }),
1773
+ _ts_metadata3("design:type", String)
1774
+ ], OpenAIApiAssistantAPIResponse.prototype, "threadId", void 0);
1775
+ OpenAIApiAssistantAPIResponse = _ts_decorate3([
1776
+ (0, import_type_graphql4.ObjectType)()
1777
+ ], OpenAIApiAssistantAPIResponse);
1778
+
1779
+ // src/graphql/types/copilot-response.type.ts
1780
+ function _ts_decorate4(decorators, target, key, desc) {
1781
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1782
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1783
+ r = Reflect.decorate(decorators, target, key, desc);
1784
+ else
1785
+ for (var i = decorators.length - 1; i >= 0; i--)
1786
+ if (d = decorators[i])
1787
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1788
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1789
+ }
1790
+ __name(_ts_decorate4, "_ts_decorate");
1791
+ function _ts_metadata4(k, v) {
1792
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1793
+ return Reflect.metadata(k, v);
1794
+ }
1795
+ __name(_ts_metadata4, "_ts_metadata");
1796
+ var BaseMessageOutput = class {
1797
+ id;
1798
+ createdAt;
1799
+ status;
1800
+ };
1801
+ __name(BaseMessageOutput, "BaseMessageOutput");
1802
+ _ts_decorate4([
1803
+ (0, import_type_graphql5.Field)(() => String),
1804
+ _ts_metadata4("design:type", String)
1805
+ ], BaseMessageOutput.prototype, "id", void 0);
1806
+ _ts_decorate4([
1807
+ (0, import_type_graphql5.Field)(() => Date),
1808
+ _ts_metadata4("design:type", typeof Date === "undefined" ? Object : Date)
1809
+ ], BaseMessageOutput.prototype, "createdAt", void 0);
1810
+ _ts_decorate4([
1811
+ (0, import_type_graphql5.Field)(() => MessageStatusUnion),
1812
+ _ts_metadata4("design:type", Object)
1813
+ ], BaseMessageOutput.prototype, "status", void 0);
1814
+ BaseMessageOutput = _ts_decorate4([
1815
+ (0, import_type_graphql5.InterfaceType)({
1816
+ resolveType(value) {
1817
+ if (value.hasOwnProperty("content")) {
1818
+ return TextMessageOutput;
1819
+ } else if (value.hasOwnProperty("name")) {
1820
+ return ActionExecutionMessageOutput;
1821
+ } else if (value.hasOwnProperty("result")) {
1822
+ return ResultMessageOutput;
1823
+ } else if (value.hasOwnProperty("state")) {
1824
+ return AgentStateMessageOutput;
1825
+ }
1826
+ return void 0;
1827
+ }
1828
+ })
1829
+ ], BaseMessageOutput);
1830
+ var TextMessageOutput = class {
1831
+ role;
1832
+ content;
1833
+ parentMessageId;
1834
+ };
1835
+ __name(TextMessageOutput, "TextMessageOutput");
1836
+ _ts_decorate4([
1837
+ (0, import_type_graphql5.Field)(() => MessageRole),
1838
+ _ts_metadata4("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
1839
+ ], TextMessageOutput.prototype, "role", void 0);
1840
+ _ts_decorate4([
1841
+ (0, import_type_graphql5.Field)(() => [
1842
+ String
1843
+ ]),
1844
+ _ts_metadata4("design:type", Array)
1845
+ ], TextMessageOutput.prototype, "content", void 0);
1846
+ _ts_decorate4([
1847
+ (0, import_type_graphql5.Field)(() => String, {
1848
+ nullable: true
1849
+ }),
1850
+ _ts_metadata4("design:type", String)
1851
+ ], TextMessageOutput.prototype, "parentMessageId", void 0);
1852
+ TextMessageOutput = _ts_decorate4([
1853
+ (0, import_type_graphql5.ObjectType)({
1854
+ implements: BaseMessageOutput
1855
+ })
1856
+ ], TextMessageOutput);
1857
+ var ActionExecutionMessageOutput = class {
1858
+ name;
1859
+ scope;
1860
+ arguments;
1861
+ parentMessageId;
1862
+ };
1863
+ __name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
1864
+ _ts_decorate4([
1865
+ (0, import_type_graphql5.Field)(() => String),
1866
+ _ts_metadata4("design:type", String)
1867
+ ], ActionExecutionMessageOutput.prototype, "name", void 0);
1868
+ _ts_decorate4([
1869
+ (0, import_type_graphql5.Field)(() => String, {
1870
+ nullable: true,
1871
+ deprecationReason: "This field will be removed in a future version"
1872
+ }),
1873
+ _ts_metadata4("design:type", String)
1874
+ ], ActionExecutionMessageOutput.prototype, "scope", void 0);
1875
+ _ts_decorate4([
1876
+ (0, import_type_graphql5.Field)(() => [
1877
+ String
1878
+ ]),
1879
+ _ts_metadata4("design:type", Array)
1880
+ ], ActionExecutionMessageOutput.prototype, "arguments", void 0);
1881
+ _ts_decorate4([
1882
+ (0, import_type_graphql5.Field)(() => String, {
1883
+ nullable: true
1884
+ }),
1885
+ _ts_metadata4("design:type", String)
1886
+ ], ActionExecutionMessageOutput.prototype, "parentMessageId", void 0);
1887
+ ActionExecutionMessageOutput = _ts_decorate4([
1888
+ (0, import_type_graphql5.ObjectType)({
1889
+ implements: BaseMessageOutput
1890
+ })
1891
+ ], ActionExecutionMessageOutput);
1892
+ var ResultMessageOutput = class {
1893
+ actionExecutionId;
1894
+ actionName;
1895
+ result;
1896
+ };
1897
+ __name(ResultMessageOutput, "ResultMessageOutput");
1898
+ _ts_decorate4([
1899
+ (0, import_type_graphql5.Field)(() => String),
1900
+ _ts_metadata4("design:type", String)
1901
+ ], ResultMessageOutput.prototype, "actionExecutionId", void 0);
1902
+ _ts_decorate4([
1903
+ (0, import_type_graphql5.Field)(() => String),
1904
+ _ts_metadata4("design:type", String)
1905
+ ], ResultMessageOutput.prototype, "actionName", void 0);
1906
+ _ts_decorate4([
1907
+ (0, import_type_graphql5.Field)(() => String),
1908
+ _ts_metadata4("design:type", String)
1909
+ ], ResultMessageOutput.prototype, "result", void 0);
1910
+ ResultMessageOutput = _ts_decorate4([
1911
+ (0, import_type_graphql5.ObjectType)({
1912
+ implements: BaseMessageOutput
1913
+ })
1914
+ ], ResultMessageOutput);
1915
+ var AgentStateMessageOutput = class {
1916
+ threadId;
1917
+ agentName;
1918
+ nodeName;
1919
+ runId;
1920
+ active;
1921
+ role;
1922
+ state;
1923
+ running;
1924
+ };
1925
+ __name(AgentStateMessageOutput, "AgentStateMessageOutput");
1926
+ _ts_decorate4([
1927
+ (0, import_type_graphql5.Field)(() => String),
1928
+ _ts_metadata4("design:type", String)
1929
+ ], AgentStateMessageOutput.prototype, "threadId", void 0);
1930
+ _ts_decorate4([
1931
+ (0, import_type_graphql5.Field)(() => String),
1932
+ _ts_metadata4("design:type", String)
1933
+ ], AgentStateMessageOutput.prototype, "agentName", void 0);
1934
+ _ts_decorate4([
1935
+ (0, import_type_graphql5.Field)(() => String),
1936
+ _ts_metadata4("design:type", String)
1937
+ ], AgentStateMessageOutput.prototype, "nodeName", void 0);
1938
+ _ts_decorate4([
1939
+ (0, import_type_graphql5.Field)(() => String),
1940
+ _ts_metadata4("design:type", String)
1941
+ ], AgentStateMessageOutput.prototype, "runId", void 0);
1942
+ _ts_decorate4([
1943
+ (0, import_type_graphql5.Field)(() => Boolean),
1944
+ _ts_metadata4("design:type", Boolean)
1945
+ ], AgentStateMessageOutput.prototype, "active", void 0);
1946
+ _ts_decorate4([
1947
+ (0, import_type_graphql5.Field)(() => MessageRole),
1948
+ _ts_metadata4("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
1949
+ ], AgentStateMessageOutput.prototype, "role", void 0);
1950
+ _ts_decorate4([
1951
+ (0, import_type_graphql5.Field)(() => String),
1952
+ _ts_metadata4("design:type", String)
1953
+ ], AgentStateMessageOutput.prototype, "state", void 0);
1954
+ _ts_decorate4([
1955
+ (0, import_type_graphql5.Field)(() => Boolean),
1956
+ _ts_metadata4("design:type", Boolean)
1957
+ ], AgentStateMessageOutput.prototype, "running", void 0);
1958
+ AgentStateMessageOutput = _ts_decorate4([
1959
+ (0, import_type_graphql5.ObjectType)({
1960
+ implements: BaseMessageOutput
1961
+ })
1962
+ ], AgentStateMessageOutput);
1963
+ var CopilotResponse = class {
1964
+ threadId;
1965
+ status;
1966
+ runId;
1967
+ messages;
1968
+ extensions;
1969
+ metaEvents;
1970
+ };
1971
+ __name(CopilotResponse, "CopilotResponse");
1972
+ _ts_decorate4([
1973
+ (0, import_type_graphql5.Field)(() => String),
1974
+ _ts_metadata4("design:type", String)
1975
+ ], CopilotResponse.prototype, "threadId", void 0);
1976
+ _ts_decorate4([
1977
+ (0, import_type_graphql5.Field)(() => ResponseStatusUnion),
1978
+ _ts_metadata4("design:type", Object)
1979
+ ], CopilotResponse.prototype, "status", void 0);
1980
+ _ts_decorate4([
1981
+ (0, import_type_graphql5.Field)({
1982
+ nullable: true
1983
+ }),
1984
+ _ts_metadata4("design:type", String)
1985
+ ], CopilotResponse.prototype, "runId", void 0);
1986
+ _ts_decorate4([
1987
+ (0, import_type_graphql5.Field)(() => [
1988
+ BaseMessageOutput
1989
+ ]),
1990
+ _ts_metadata4("design:type", Array)
1991
+ ], CopilotResponse.prototype, "messages", void 0);
1992
+ _ts_decorate4([
1993
+ (0, import_type_graphql5.Field)(() => ExtensionsResponse, {
1994
+ nullable: true
1995
+ }),
1996
+ _ts_metadata4("design:type", typeof ExtensionsResponse === "undefined" ? Object : ExtensionsResponse)
1997
+ ], CopilotResponse.prototype, "extensions", void 0);
1998
+ _ts_decorate4([
1999
+ (0, import_type_graphql5.Field)(() => [
2000
+ BaseMetaEvent
2001
+ ], {
2002
+ nullable: true
2003
+ }),
2004
+ _ts_metadata4("design:type", Array)
2005
+ ], CopilotResponse.prototype, "metaEvents", void 0);
2006
+ CopilotResponse = _ts_decorate4([
2007
+ (0, import_type_graphql5.ObjectType)()
2008
+ ], CopilotResponse);
2009
+
2010
+ // src/graphql/types/meta-events.type.ts
2011
+ function _ts_decorate5(decorators, target, key, desc) {
2012
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2013
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2014
+ r = Reflect.decorate(decorators, target, key, desc);
2015
+ else
2016
+ for (var i = decorators.length - 1; i >= 0; i--)
2017
+ if (d = decorators[i])
2018
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2019
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2020
+ }
2021
+ __name(_ts_decorate5, "_ts_decorate");
2022
+ function _ts_metadata5(k, v) {
2023
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2024
+ return Reflect.metadata(k, v);
2025
+ }
2026
+ __name(_ts_metadata5, "_ts_metadata");
2027
+ var MetaEventName;
2028
+ (function(MetaEventName2) {
2029
+ MetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
2030
+ MetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
2031
+ })(MetaEventName || (MetaEventName = {}));
2032
+ (0, import_type_graphql6.registerEnumType)(MetaEventName, {
2033
+ name: "MetaEventName",
2034
+ description: "Meta event types"
2035
+ });
2036
+ var BaseMetaEvent = class {
2037
+ type = "MetaEvent";
2038
+ name;
2039
+ };
2040
+ __name(BaseMetaEvent, "BaseMetaEvent");
2041
+ _ts_decorate5([
2042
+ (0, import_type_graphql6.Field)(() => String),
2043
+ _ts_metadata5("design:type", String)
2044
+ ], BaseMetaEvent.prototype, "type", void 0);
2045
+ _ts_decorate5([
2046
+ (0, import_type_graphql6.Field)(() => MetaEventName),
2047
+ _ts_metadata5("design:type", String)
2048
+ ], BaseMetaEvent.prototype, "name", void 0);
2049
+ BaseMetaEvent = _ts_decorate5([
2050
+ (0, import_type_graphql6.InterfaceType)({
2051
+ resolveType(value) {
2052
+ if (value.name === "LangGraphInterruptEvent") {
2053
+ return LangGraphInterruptEvent;
2054
+ } else if (value.name === "CopilotKitLangGraphInterruptEvent") {
2055
+ return CopilotKitLangGraphInterruptEvent;
2056
+ }
2057
+ return void 0;
2058
+ }
2059
+ }),
2060
+ (0, import_type_graphql6.InterfaceType)()
2061
+ ], BaseMetaEvent);
2062
+ var CopilotKitLangGraphInterruptEventData = class {
2063
+ value;
2064
+ messages;
2065
+ };
2066
+ __name(CopilotKitLangGraphInterruptEventData, "CopilotKitLangGraphInterruptEventData");
2067
+ _ts_decorate5([
2068
+ (0, import_type_graphql6.Field)(() => String),
2069
+ _ts_metadata5("design:type", String)
2070
+ ], CopilotKitLangGraphInterruptEventData.prototype, "value", void 0);
2071
+ _ts_decorate5([
2072
+ (0, import_type_graphql6.Field)(() => [
2073
+ BaseMessageOutput
2074
+ ]),
2075
+ _ts_metadata5("design:type", Array)
2076
+ ], CopilotKitLangGraphInterruptEventData.prototype, "messages", void 0);
2077
+ CopilotKitLangGraphInterruptEventData = _ts_decorate5([
2078
+ (0, import_type_graphql6.ObjectType)()
2079
+ ], CopilotKitLangGraphInterruptEventData);
2080
+ var LangGraphInterruptEvent = class {
2081
+ name = "LangGraphInterruptEvent";
2082
+ value;
2083
+ response;
2084
+ };
2085
+ __name(LangGraphInterruptEvent, "LangGraphInterruptEvent");
2086
+ _ts_decorate5([
2087
+ (0, import_type_graphql6.Field)(() => MetaEventName),
2088
+ _ts_metadata5("design:type", typeof MetaEventName === "undefined" || false ? Object : "LangGraphInterruptEvent")
2089
+ ], LangGraphInterruptEvent.prototype, "name", void 0);
2090
+ _ts_decorate5([
2091
+ (0, import_type_graphql6.Field)(() => String),
2092
+ _ts_metadata5("design:type", String)
2093
+ ], LangGraphInterruptEvent.prototype, "value", void 0);
2094
+ _ts_decorate5([
2095
+ (0, import_type_graphql6.Field)(() => String, {
2096
+ nullable: true
2097
+ }),
2098
+ _ts_metadata5("design:type", String)
2099
+ ], LangGraphInterruptEvent.prototype, "response", void 0);
2100
+ LangGraphInterruptEvent = _ts_decorate5([
2101
+ (0, import_type_graphql6.ObjectType)({
2102
+ implements: BaseMetaEvent
2103
+ })
2104
+ ], LangGraphInterruptEvent);
2105
+ var CopilotKitLangGraphInterruptEvent = class {
2106
+ name = "CopilotKitLangGraphInterruptEvent";
2107
+ data;
2108
+ response;
2109
+ };
2110
+ __name(CopilotKitLangGraphInterruptEvent, "CopilotKitLangGraphInterruptEvent");
2111
+ _ts_decorate5([
2112
+ (0, import_type_graphql6.Field)(() => MetaEventName),
2113
+ _ts_metadata5("design:type", typeof MetaEventName === "undefined" || false ? Object : "CopilotKitLangGraphInterruptEvent")
2114
+ ], CopilotKitLangGraphInterruptEvent.prototype, "name", void 0);
2115
+ _ts_decorate5([
2116
+ (0, import_type_graphql6.Field)(() => CopilotKitLangGraphInterruptEventData),
2117
+ _ts_metadata5("design:type", typeof CopilotKitLangGraphInterruptEventData === "undefined" ? Object : CopilotKitLangGraphInterruptEventData)
2118
+ ], CopilotKitLangGraphInterruptEvent.prototype, "data", void 0);
2119
+ _ts_decorate5([
2120
+ (0, import_type_graphql6.Field)(() => String, {
2121
+ nullable: true
2122
+ }),
2123
+ _ts_metadata5("design:type", String)
2124
+ ], CopilotKitLangGraphInterruptEvent.prototype, "response", void 0);
2125
+ CopilotKitLangGraphInterruptEvent = _ts_decorate5([
2126
+ (0, import_type_graphql6.ObjectType)({
2127
+ implements: BaseMetaEvent
2128
+ })
2129
+ ], CopilotKitLangGraphInterruptEvent);
2130
+
2131
+ // src/lib/runtime/remote-lg-action.ts
2132
+ var activeInterruptEvent = false;
2133
+ async function execute(args) {
2134
+ return new ReadableStream({
2135
+ async start(controller) {
2136
+ try {
2137
+ await streamEvents(controller, args);
2138
+ controller.close();
2139
+ } catch (err) {
2140
+ }
2141
+ }
2142
+ });
2143
+ }
2144
+ __name(execute, "execute");
2145
+ async function streamEvents(controller, args) {
2146
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2147
+ const { deploymentUrl, langsmithApiKey, threadId: argsInitialThreadId, agent, nodeName: initialNodeName, state: initialState, messages, actions, logger: logger2, properties, metaEvents } = args;
2148
+ let nodeName = initialNodeName;
2149
+ let state = initialState;
2150
+ const { name, assistantId: initialAssistantId } = agent;
2151
+ const propertyHeaders = properties.authorization ? {
2152
+ authorization: `Bearer ${properties.authorization}`
2153
+ } : null;
2154
+ const client = new import_langgraph_sdk.Client({
2155
+ apiUrl: deploymentUrl,
2156
+ apiKey: langsmithApiKey,
2157
+ defaultHeaders: {
2158
+ ...propertyHeaders
2159
+ }
2160
+ });
2161
+ let threadId = argsInitialThreadId ?? (0, import_shared8.randomUUID)();
2162
+ if (argsInitialThreadId && argsInitialThreadId.startsWith("ck-")) {
2163
+ threadId = argsInitialThreadId.substring(3);
1687
2164
  }
1688
- const assistantId = retrievedAssistant.assistant_id;
1689
- const graphInfo = await client.assistants.getGraph(assistantId);
2165
+ if (!(0, import_shared8.isValidUUID)(threadId)) {
2166
+ console.warn(`Cannot use the threadId ${threadId} with LangGraph Platform. Must be a valid UUID.`);
2167
+ }
2168
+ let wasInitiatedWithExistingThread = true;
2169
+ try {
2170
+ await client.threads.get(threadId);
2171
+ } catch (error) {
2172
+ wasInitiatedWithExistingThread = false;
2173
+ await client.threads.create({
2174
+ threadId
2175
+ });
2176
+ }
2177
+ let agentState = {
2178
+ values: {}
2179
+ };
2180
+ if (wasInitiatedWithExistingThread) {
2181
+ agentState = await client.threads.getState(threadId);
2182
+ }
2183
+ const agentStateValues = agentState.values;
2184
+ state.messages = agentStateValues.messages;
2185
+ const mode = threadId && nodeName != "__end__" && nodeName != void 0 && nodeName != null ? "continue" : "start";
2186
+ let formattedMessages = [];
2187
+ try {
2188
+ formattedMessages = copilotkitMessagesToLangChain(messages);
2189
+ } catch (e) {
2190
+ logger2.error(e, `Error event thrown: ${e.message}`);
2191
+ }
2192
+ state = langGraphDefaultMergeState(state, formattedMessages, actions, name);
1690
2193
  const streamInput = mode === "start" ? state : null;
1691
- let streamingStateExtractor = new StreamingStateExtractor([]);
1692
- let prevNodeName = null;
1693
- let emitIntermediateStateUntilEnd = null;
1694
- let shouldExit = false;
1695
- let externalRunId = null;
1696
2194
  const payload = {
1697
2195
  input: streamInput,
1698
2196
  streamMode: [
@@ -1702,16 +2200,55 @@ async function streamEvents(controller, args) {
1702
2200
  ],
1703
2201
  command: void 0
1704
2202
  };
1705
- if (lgInterruptEvent == null ? void 0 : lgInterruptEvent.response) {
2203
+ const lgInterruptMetaEvent = metaEvents == null ? void 0 : metaEvents.find((ev) => ev.name === MetaEventName.LangGraphInterruptEvent);
2204
+ if (activeInterruptEvent && !lgInterruptMetaEvent) {
2205
+ payload.command = {
2206
+ resume: formattedMessages[formattedMessages.length - 1]
2207
+ };
2208
+ }
2209
+ if (lgInterruptMetaEvent == null ? void 0 : lgInterruptMetaEvent.response) {
1706
2210
  payload.command = {
1707
- resume: lgInterruptEvent.response
2211
+ resume: lgInterruptMetaEvent.response
1708
2212
  };
1709
2213
  }
2214
+ if (mode === "continue" && !activeInterruptEvent) {
2215
+ await client.threads.updateState(threadId, {
2216
+ values: state,
2217
+ asNode: nodeName
2218
+ });
2219
+ }
2220
+ let streamInfo = {
2221
+ hashedLgcKey: (0, import_node_crypto.createHash)("sha256").update(langsmithApiKey).digest("hex")
2222
+ };
2223
+ const assistants = await client.assistants.search();
2224
+ const retrievedAssistant = assistants.find((a) => a.name === name || a.assistant_id === initialAssistantId);
2225
+ if (!retrievedAssistant) {
2226
+ telemetry_client_default.capture("oss.runtime.agent_execution_stream_errored", {
2227
+ ...streamInfo,
2228
+ error: `Found no assistants for given information, while ${assistants.length} assistants exists`
2229
+ });
2230
+ console.error(`
2231
+ No agent found for the agent name specified in CopilotKit provider
2232
+ Please check your available agents or provide an agent ID in the LangGraph Platform endpoint definition.
2233
+
2234
+
2235
+ These are the available agents: [${assistants.map((a) => `${a.name} (ID: ${a.assistant_id})`).join(", ")}]
2236
+ `);
2237
+ throw new Error("No agent id found");
2238
+ }
2239
+ const assistantId = retrievedAssistant.assistant_id;
2240
+ const graphInfo = await client.assistants.getGraph(assistantId);
2241
+ let streamingStateExtractor = new StreamingStateExtractor([]);
2242
+ let prevNodeName = null;
2243
+ let emitIntermediateStateUntilEnd = null;
2244
+ let shouldExit = false;
2245
+ let externalRunId = null;
1710
2246
  const streamResponse2 = client.runs.stream(threadId, assistantId, payload);
1711
2247
  const emit = /* @__PURE__ */ __name((message) => controller.enqueue(new TextEncoder().encode(message)), "emit");
1712
2248
  let latestStateValues = {};
1713
2249
  let updatedState = state;
1714
2250
  let manuallyEmittedState = null;
2251
+ activeInterruptEvent = false;
1715
2252
  try {
1716
2253
  telemetry_client_default.capture("oss.runtime.agent_execution_stream_started", {
1717
2254
  hashedLgcKey: streamInfo.hashedLgcKey
@@ -1727,11 +2264,24 @@ async function streamEvents(controller, args) {
1727
2264
  if (chunk.event === "error") {
1728
2265
  throw new Error(`Error event thrown: ${chunk.data.message}`);
1729
2266
  }
1730
- if (chunk.event === "updates" && chunk.data.__interrupt__) {
1731
- emit(JSON.stringify({
1732
- event: LangGraphEventTypes.OnInterrupt,
1733
- value: chunk.data.__interrupt__[0].value
1734
- }) + "\n");
2267
+ const interruptEvents = (_a = chunk.data) == null ? void 0 : _a.__interrupt__;
2268
+ if (interruptEvents == null ? void 0 : interruptEvents.length) {
2269
+ activeInterruptEvent = true;
2270
+ const interruptValue = interruptEvents == null ? void 0 : interruptEvents[0].value;
2271
+ if (typeof interruptValue != "string" && "__copilotkit_interrupt_value__" in interruptValue) {
2272
+ emit(JSON.stringify({
2273
+ event: LangGraphEventTypes.OnCopilotKitInterrupt,
2274
+ data: {
2275
+ value: interruptValue.__copilotkit_interrupt_value__,
2276
+ messages: langchainMessagesToCopilotKit(interruptValue.__copilotkit_messages__)
2277
+ }
2278
+ }) + "\n");
2279
+ } else {
2280
+ emit(JSON.stringify({
2281
+ event: LangGraphEventTypes.OnInterrupt,
2282
+ value: interruptValue
2283
+ }) + "\n");
2284
+ }
1735
2285
  continue;
1736
2286
  }
1737
2287
  if (chunk.event === "updates")
@@ -1746,8 +2296,8 @@ async function streamEvents(controller, args) {
1746
2296
  const runId = event.metadata.run_id;
1747
2297
  externalRunId = runId;
1748
2298
  const metadata = event.metadata;
1749
- 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) != "") {
1750
- streamInfo.provider = (_f = (_e = event.data) == null ? void 0 : _e.output) == null ? void 0 : _f.model;
2299
+ 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) != "") {
2300
+ streamInfo.provider = (_g = (_f = event.data) == null ? void 0 : _f.output) == null ? void 0 : _g.model;
1751
2301
  }
1752
2302
  if (metadata.langgraph_host != null && metadata.langgraph_host != "") {
1753
2303
  streamInfo.langGraphHost = metadata.langgraph_host;
@@ -1816,7 +2366,7 @@ async function streamEvents(controller, args) {
1816
2366
  emit(JSON.stringify(event) + "\n");
1817
2367
  }
1818
2368
  state = await client.threads.getState(threadId);
1819
- const interrupts = (_h = (_g = state.tasks) == null ? void 0 : _g[0]) == null ? void 0 : _h.interrupts;
2369
+ const interrupts = (_i = (_h = state.tasks) == null ? void 0 : _h[0]) == null ? void 0 : _i.interrupts;
1820
2370
  nodeName = interrupts ? nodeName : Object.keys(state.metadata.writes)[0];
1821
2371
  const isEndNode = state.next.length === 0 && !interrupts;
1822
2372
  telemetry_client_default.capture("oss.runtime.agent_execution_stream_ended", streamInfo);
@@ -2504,8 +3054,8 @@ __name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
2504
3054
  var telemetry_client_default = telemetryClient;
2505
3055
 
2506
3056
  // src/graphql/types/base/index.ts
2507
- var import_type_graphql3 = require("type-graphql");
2508
- function _ts_decorate2(decorators, target, key, desc) {
3057
+ var import_type_graphql7 = require("type-graphql");
3058
+ function _ts_decorate6(decorators, target, key, desc) {
2509
3059
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2510
3060
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2511
3061
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2515,27 +3065,27 @@ function _ts_decorate2(decorators, target, key, desc) {
2515
3065
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2516
3066
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2517
3067
  }
2518
- __name(_ts_decorate2, "_ts_decorate");
2519
- function _ts_metadata2(k, v) {
3068
+ __name(_ts_decorate6, "_ts_decorate");
3069
+ function _ts_metadata6(k, v) {
2520
3070
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2521
3071
  return Reflect.metadata(k, v);
2522
3072
  }
2523
- __name(_ts_metadata2, "_ts_metadata");
3073
+ __name(_ts_metadata6, "_ts_metadata");
2524
3074
  var BaseMessageInput = class {
2525
3075
  id;
2526
3076
  createdAt;
2527
3077
  };
2528
3078
  __name(BaseMessageInput, "BaseMessageInput");
2529
- _ts_decorate2([
2530
- (0, import_type_graphql3.Field)(() => String),
2531
- _ts_metadata2("design:type", String)
3079
+ _ts_decorate6([
3080
+ (0, import_type_graphql7.Field)(() => String),
3081
+ _ts_metadata6("design:type", String)
2532
3082
  ], BaseMessageInput.prototype, "id", void 0);
2533
- _ts_decorate2([
2534
- (0, import_type_graphql3.Field)(() => Date),
2535
- _ts_metadata2("design:type", typeof Date === "undefined" ? Object : Date)
3083
+ _ts_decorate6([
3084
+ (0, import_type_graphql7.Field)(() => Date),
3085
+ _ts_metadata6("design:type", typeof Date === "undefined" ? Object : Date)
2536
3086
  ], BaseMessageInput.prototype, "createdAt", void 0);
2537
- BaseMessageInput = _ts_decorate2([
2538
- (0, import_type_graphql3.InputType)()
3087
+ BaseMessageInput = _ts_decorate6([
3088
+ (0, import_type_graphql7.InputType)()
2539
3089
  ], BaseMessageInput);
2540
3090
 
2541
3091
  // src/graphql/types/converted/index.ts
@@ -2670,6 +3220,7 @@ var RuntimeMetaEventName;
2670
3220
  (function(RuntimeMetaEventName2) {
2671
3221
  RuntimeMetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
2672
3222
  RuntimeMetaEventName2["LangGraphInterruptResumeEvent"] = "LangGraphInterruptResumeEvent";
3223
+ RuntimeMetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
2673
3224
  })(RuntimeMetaEventName || (RuntimeMetaEventName = {}));
2674
3225
  var RuntimeEventSubject = class extends import_rxjs2.ReplaySubject {
2675
3226
  constructor() {
@@ -3259,455 +3810,121 @@ please use an LLM adapter instead.`
3259
3810
  (0, import_rxjs3.from)(stream).subscribe({
3260
3811
  next: (event) => eventStream$.next(event),
3261
3812
  error: (err) => {
3262
- console.error("Error in stream", err);
3263
- eventStream$.error(err);
3264
- eventStream$.complete();
3265
- },
3266
- complete: () => eventStream$.complete()
3267
- });
3268
- });
3269
- outputMessagesPromise.then((outputMessages) => {
3270
- var _a2;
3271
- (_a2 = this.onAfterRequest) == null ? void 0 : _a2.call(this, {
3272
- threadId,
3273
- runId: void 0,
3274
- inputMessages: messages,
3275
- outputMessages,
3276
- properties: graphqlContext.properties
3277
- });
3278
- }).catch((_error) => {
3279
- });
3280
- return {
3281
- threadId,
3282
- runId: void 0,
3283
- eventSource,
3284
- serverSideActions: [],
3285
- actionInputsWithoutAgents: allAvailableActions
3286
- };
3287
- } catch (error) {
3288
- console.error("Error getting response:", error);
3289
- throw error;
3290
- }
3291
- }
3292
- async getServerSideActions(request) {
3293
- const { messages: rawMessages, graphqlContext, agentStates, url } = request;
3294
- const inputMessages = convertGqlInputToMessages(rawMessages);
3295
- const langserveFunctions = [];
3296
- for (const chainPromise of this.langserve) {
3297
- try {
3298
- const chain = await chainPromise;
3299
- langserveFunctions.push(chain);
3300
- } catch (error) {
3301
- console.error("Error loading langserve chain:", error);
3302
- }
3303
- }
3304
- const remoteEndpointDefinitions = this.remoteEndpointDefinitions.map((endpoint) => ({
3305
- ...endpoint,
3306
- type: resolveEndpointType(endpoint)
3307
- }));
3308
- const remoteActions = await setupRemoteActions({
3309
- remoteEndpointDefinitions,
3310
- graphqlContext,
3311
- messages: inputMessages,
3312
- agentStates,
3313
- frontendUrl: url
3314
- });
3315
- const configuredActions = typeof this.actions === "function" ? this.actions({
3316
- properties: graphqlContext.properties,
3317
- url
3318
- }) : this.actions;
3319
- return [
3320
- ...configuredActions,
3321
- ...langserveFunctions,
3322
- ...remoteActions
3323
- ];
3324
- }
3325
- };
3326
- __name(CopilotRuntime, "CopilotRuntime");
3327
- function flattenToolCallsNoDuplicates(toolsByPriority) {
3328
- let allTools = [];
3329
- const allToolNames = [];
3330
- for (const tool of toolsByPriority) {
3331
- if (!allToolNames.includes(tool.name)) {
3332
- allTools.push(tool);
3333
- allToolNames.push(tool.name);
3334
- }
3335
- }
3336
- return allTools;
3337
- }
3338
- __name(flattenToolCallsNoDuplicates, "flattenToolCallsNoDuplicates");
3339
- function copilotKitEndpoint(config2) {
3340
- return {
3341
- ...config2,
3342
- type: EndpointType.CopilotKit
3343
- };
3344
- }
3345
- __name(copilotKitEndpoint, "copilotKitEndpoint");
3346
- function langGraphPlatformEndpoint(config2) {
3347
- return {
3348
- ...config2,
3349
- type: EndpointType.LangGraphPlatform
3350
- };
3351
- }
3352
- __name(langGraphPlatformEndpoint, "langGraphPlatformEndpoint");
3353
- function resolveEndpointType(endpoint) {
3354
- if (!endpoint.type) {
3355
- if ("langsmithApiKey" in endpoint && "deploymentUrl" in endpoint && "agents" in endpoint) {
3356
- return EndpointType.LangGraphPlatform;
3357
- } else {
3358
- return EndpointType.CopilotKit;
3359
- }
3360
- }
3361
- return endpoint.type;
3362
- }
3363
- __name(resolveEndpointType, "resolveEndpointType");
3364
-
3365
- // src/lib/integrations/shared.ts
3366
- var import_type_graphql26 = require("type-graphql");
3367
-
3368
- // src/graphql/resolvers/copilot.resolver.ts
3369
- var import_type_graphql20 = require("type-graphql");
3370
- var import_rxjs4 = require("rxjs");
3371
-
3372
- // src/graphql/inputs/generate-copilot-response.input.ts
3373
- var import_type_graphql14 = require("type-graphql");
3374
-
3375
- // src/graphql/inputs/message.input.ts
3376
- var import_type_graphql4 = require("type-graphql");
3377
- function _ts_decorate3(decorators, target, key, desc) {
3378
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3379
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3380
- r = Reflect.decorate(decorators, target, key, desc);
3381
- else
3382
- for (var i = decorators.length - 1; i >= 0; i--)
3383
- if (d = decorators[i])
3384
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3385
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3386
- }
3387
- __name(_ts_decorate3, "_ts_decorate");
3388
- function _ts_metadata3(k, v) {
3389
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3390
- return Reflect.metadata(k, v);
3391
- }
3392
- __name(_ts_metadata3, "_ts_metadata");
3393
- var MessageInput = class extends BaseMessageInput {
3394
- textMessage;
3395
- actionExecutionMessage;
3396
- resultMessage;
3397
- agentStateMessage;
3398
- };
3399
- __name(MessageInput, "MessageInput");
3400
- _ts_decorate3([
3401
- (0, import_type_graphql4.Field)(() => TextMessageInput, {
3402
- nullable: true
3403
- }),
3404
- _ts_metadata3("design:type", typeof TextMessageInput === "undefined" ? Object : TextMessageInput)
3405
- ], MessageInput.prototype, "textMessage", void 0);
3406
- _ts_decorate3([
3407
- (0, import_type_graphql4.Field)(() => ActionExecutionMessageInput, {
3408
- nullable: true
3409
- }),
3410
- _ts_metadata3("design:type", typeof ActionExecutionMessageInput === "undefined" ? Object : ActionExecutionMessageInput)
3411
- ], MessageInput.prototype, "actionExecutionMessage", void 0);
3412
- _ts_decorate3([
3413
- (0, import_type_graphql4.Field)(() => ResultMessageInput, {
3414
- nullable: true
3415
- }),
3416
- _ts_metadata3("design:type", typeof ResultMessageInput === "undefined" ? Object : ResultMessageInput)
3417
- ], MessageInput.prototype, "resultMessage", void 0);
3418
- _ts_decorate3([
3419
- (0, import_type_graphql4.Field)(() => AgentStateMessageInput, {
3420
- nullable: true
3421
- }),
3422
- _ts_metadata3("design:type", typeof AgentStateMessageInput === "undefined" ? Object : AgentStateMessageInput)
3423
- ], MessageInput.prototype, "agentStateMessage", void 0);
3424
- MessageInput = _ts_decorate3([
3425
- (0, import_type_graphql4.InputType)()
3426
- ], MessageInput);
3427
- var TextMessageInput = class {
3428
- content;
3429
- parentMessageId;
3430
- role;
3431
- };
3432
- __name(TextMessageInput, "TextMessageInput");
3433
- _ts_decorate3([
3434
- (0, import_type_graphql4.Field)(() => String),
3435
- _ts_metadata3("design:type", String)
3436
- ], TextMessageInput.prototype, "content", void 0);
3437
- _ts_decorate3([
3438
- (0, import_type_graphql4.Field)(() => String, {
3439
- nullable: true
3440
- }),
3441
- _ts_metadata3("design:type", String)
3442
- ], TextMessageInput.prototype, "parentMessageId", void 0);
3443
- _ts_decorate3([
3444
- (0, import_type_graphql4.Field)(() => MessageRole),
3445
- _ts_metadata3("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
3446
- ], TextMessageInput.prototype, "role", void 0);
3447
- TextMessageInput = _ts_decorate3([
3448
- (0, import_type_graphql4.InputType)()
3449
- ], TextMessageInput);
3450
- var ActionExecutionMessageInput = class {
3451
- name;
3452
- arguments;
3453
- parentMessageId;
3454
- scope;
3455
- };
3456
- __name(ActionExecutionMessageInput, "ActionExecutionMessageInput");
3457
- _ts_decorate3([
3458
- (0, import_type_graphql4.Field)(() => String),
3459
- _ts_metadata3("design:type", String)
3460
- ], ActionExecutionMessageInput.prototype, "name", void 0);
3461
- _ts_decorate3([
3462
- (0, import_type_graphql4.Field)(() => String),
3463
- _ts_metadata3("design:type", String)
3464
- ], ActionExecutionMessageInput.prototype, "arguments", void 0);
3465
- _ts_decorate3([
3466
- (0, import_type_graphql4.Field)(() => String, {
3467
- nullable: true
3468
- }),
3469
- _ts_metadata3("design:type", String)
3470
- ], ActionExecutionMessageInput.prototype, "parentMessageId", void 0);
3471
- _ts_decorate3([
3472
- (0, import_type_graphql4.Field)(() => String, {
3473
- nullable: true,
3474
- deprecationReason: "This field will be removed in a future version"
3475
- }),
3476
- _ts_metadata3("design:type", typeof String === "undefined" ? Object : String)
3477
- ], ActionExecutionMessageInput.prototype, "scope", void 0);
3478
- ActionExecutionMessageInput = _ts_decorate3([
3479
- (0, import_type_graphql4.InputType)()
3480
- ], ActionExecutionMessageInput);
3481
- var ResultMessageInput = class {
3482
- actionExecutionId;
3483
- actionName;
3484
- parentMessageId;
3485
- result;
3486
- };
3487
- __name(ResultMessageInput, "ResultMessageInput");
3488
- _ts_decorate3([
3489
- (0, import_type_graphql4.Field)(() => String),
3490
- _ts_metadata3("design:type", String)
3491
- ], ResultMessageInput.prototype, "actionExecutionId", void 0);
3492
- _ts_decorate3([
3493
- (0, import_type_graphql4.Field)(() => String),
3494
- _ts_metadata3("design:type", String)
3495
- ], ResultMessageInput.prototype, "actionName", void 0);
3496
- _ts_decorate3([
3497
- (0, import_type_graphql4.Field)(() => String, {
3498
- nullable: true
3499
- }),
3500
- _ts_metadata3("design:type", String)
3501
- ], ResultMessageInput.prototype, "parentMessageId", void 0);
3502
- _ts_decorate3([
3503
- (0, import_type_graphql4.Field)(() => String),
3504
- _ts_metadata3("design:type", String)
3505
- ], ResultMessageInput.prototype, "result", void 0);
3506
- ResultMessageInput = _ts_decorate3([
3507
- (0, import_type_graphql4.InputType)()
3508
- ], ResultMessageInput);
3509
- var AgentStateMessageInput = class {
3510
- threadId;
3511
- agentName;
3512
- role;
3513
- state;
3514
- running;
3515
- nodeName;
3516
- runId;
3517
- active;
3813
+ console.error("Error in stream", err);
3814
+ eventStream$.error(err);
3815
+ eventStream$.complete();
3816
+ },
3817
+ complete: () => eventStream$.complete()
3818
+ });
3819
+ });
3820
+ outputMessagesPromise.then((outputMessages) => {
3821
+ var _a2;
3822
+ (_a2 = this.onAfterRequest) == null ? void 0 : _a2.call(this, {
3823
+ threadId,
3824
+ runId: void 0,
3825
+ inputMessages: messages,
3826
+ outputMessages,
3827
+ properties: graphqlContext.properties
3828
+ });
3829
+ }).catch((_error) => {
3830
+ });
3831
+ return {
3832
+ threadId,
3833
+ runId: void 0,
3834
+ eventSource,
3835
+ serverSideActions: [],
3836
+ actionInputsWithoutAgents: allAvailableActions
3837
+ };
3838
+ } catch (error) {
3839
+ console.error("Error getting response:", error);
3840
+ throw error;
3841
+ }
3842
+ }
3843
+ async getServerSideActions(request) {
3844
+ const { messages: rawMessages, graphqlContext, agentStates, url } = request;
3845
+ const inputMessages = convertGqlInputToMessages(rawMessages);
3846
+ const langserveFunctions = [];
3847
+ for (const chainPromise of this.langserve) {
3848
+ try {
3849
+ const chain = await chainPromise;
3850
+ langserveFunctions.push(chain);
3851
+ } catch (error) {
3852
+ console.error("Error loading langserve chain:", error);
3853
+ }
3854
+ }
3855
+ const remoteEndpointDefinitions = this.remoteEndpointDefinitions.map((endpoint) => ({
3856
+ ...endpoint,
3857
+ type: resolveEndpointType(endpoint)
3858
+ }));
3859
+ const remoteActions = await setupRemoteActions({
3860
+ remoteEndpointDefinitions,
3861
+ graphqlContext,
3862
+ messages: inputMessages,
3863
+ agentStates,
3864
+ frontendUrl: url
3865
+ });
3866
+ const configuredActions = typeof this.actions === "function" ? this.actions({
3867
+ properties: graphqlContext.properties,
3868
+ url
3869
+ }) : this.actions;
3870
+ return [
3871
+ ...configuredActions,
3872
+ ...langserveFunctions,
3873
+ ...remoteActions
3874
+ ];
3875
+ }
3518
3876
  };
3519
- __name(AgentStateMessageInput, "AgentStateMessageInput");
3520
- _ts_decorate3([
3521
- (0, import_type_graphql4.Field)(() => String),
3522
- _ts_metadata3("design:type", String)
3523
- ], AgentStateMessageInput.prototype, "threadId", void 0);
3524
- _ts_decorate3([
3525
- (0, import_type_graphql4.Field)(() => String),
3526
- _ts_metadata3("design:type", String)
3527
- ], AgentStateMessageInput.prototype, "agentName", void 0);
3528
- _ts_decorate3([
3529
- (0, import_type_graphql4.Field)(() => MessageRole),
3530
- _ts_metadata3("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
3531
- ], AgentStateMessageInput.prototype, "role", void 0);
3532
- _ts_decorate3([
3533
- (0, import_type_graphql4.Field)(() => String),
3534
- _ts_metadata3("design:type", String)
3535
- ], AgentStateMessageInput.prototype, "state", void 0);
3536
- _ts_decorate3([
3537
- (0, import_type_graphql4.Field)(() => Boolean),
3538
- _ts_metadata3("design:type", Boolean)
3539
- ], AgentStateMessageInput.prototype, "running", void 0);
3540
- _ts_decorate3([
3541
- (0, import_type_graphql4.Field)(() => String),
3542
- _ts_metadata3("design:type", String)
3543
- ], AgentStateMessageInput.prototype, "nodeName", void 0);
3544
- _ts_decorate3([
3545
- (0, import_type_graphql4.Field)(() => String),
3546
- _ts_metadata3("design:type", String)
3547
- ], AgentStateMessageInput.prototype, "runId", void 0);
3548
- _ts_decorate3([
3549
- (0, import_type_graphql4.Field)(() => Boolean),
3550
- _ts_metadata3("design:type", Boolean)
3551
- ], AgentStateMessageInput.prototype, "active", void 0);
3552
- AgentStateMessageInput = _ts_decorate3([
3553
- (0, import_type_graphql4.InputType)()
3554
- ], AgentStateMessageInput);
3555
-
3556
- // src/graphql/inputs/frontend.input.ts
3557
- var import_type_graphql6 = require("type-graphql");
3558
-
3559
- // src/graphql/inputs/action.input.ts
3560
- var import_type_graphql5 = require("type-graphql");
3561
- function _ts_decorate4(decorators, target, key, desc) {
3562
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3563
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3564
- r = Reflect.decorate(decorators, target, key, desc);
3565
- else
3566
- for (var i = decorators.length - 1; i >= 0; i--)
3567
- if (d = decorators[i])
3568
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3569
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3877
+ __name(CopilotRuntime, "CopilotRuntime");
3878
+ function flattenToolCallsNoDuplicates(toolsByPriority) {
3879
+ let allTools = [];
3880
+ const allToolNames = [];
3881
+ for (const tool of toolsByPriority) {
3882
+ if (!allToolNames.includes(tool.name)) {
3883
+ allTools.push(tool);
3884
+ allToolNames.push(tool.name);
3885
+ }
3886
+ }
3887
+ return allTools;
3570
3888
  }
3571
- __name(_ts_decorate4, "_ts_decorate");
3572
- function _ts_metadata4(k, v) {
3573
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3574
- return Reflect.metadata(k, v);
3889
+ __name(flattenToolCallsNoDuplicates, "flattenToolCallsNoDuplicates");
3890
+ function copilotKitEndpoint(config2) {
3891
+ return {
3892
+ ...config2,
3893
+ type: EndpointType.CopilotKit
3894
+ };
3575
3895
  }
3576
- __name(_ts_metadata4, "_ts_metadata");
3577
- var ActionInput = class {
3578
- name;
3579
- description;
3580
- jsonSchema;
3581
- available;
3582
- };
3583
- __name(ActionInput, "ActionInput");
3584
- _ts_decorate4([
3585
- (0, import_type_graphql5.Field)(() => String),
3586
- _ts_metadata4("design:type", String)
3587
- ], ActionInput.prototype, "name", void 0);
3588
- _ts_decorate4([
3589
- (0, import_type_graphql5.Field)(() => String),
3590
- _ts_metadata4("design:type", String)
3591
- ], ActionInput.prototype, "description", void 0);
3592
- _ts_decorate4([
3593
- (0, import_type_graphql5.Field)(() => String),
3594
- _ts_metadata4("design:type", String)
3595
- ], ActionInput.prototype, "jsonSchema", void 0);
3596
- _ts_decorate4([
3597
- (0, import_type_graphql5.Field)(() => ActionInputAvailability, {
3598
- nullable: true
3599
- }),
3600
- _ts_metadata4("design:type", typeof ActionInputAvailability === "undefined" ? Object : ActionInputAvailability)
3601
- ], ActionInput.prototype, "available", void 0);
3602
- ActionInput = _ts_decorate4([
3603
- (0, import_type_graphql5.InputType)()
3604
- ], ActionInput);
3605
-
3606
- // src/graphql/inputs/frontend.input.ts
3607
- function _ts_decorate5(decorators, target, key, desc) {
3608
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3609
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3610
- r = Reflect.decorate(decorators, target, key, desc);
3611
- else
3612
- for (var i = decorators.length - 1; i >= 0; i--)
3613
- if (d = decorators[i])
3614
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3615
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3896
+ __name(copilotKitEndpoint, "copilotKitEndpoint");
3897
+ function langGraphPlatformEndpoint(config2) {
3898
+ return {
3899
+ ...config2,
3900
+ type: EndpointType.LangGraphPlatform
3901
+ };
3616
3902
  }
3617
- __name(_ts_decorate5, "_ts_decorate");
3618
- function _ts_metadata5(k, v) {
3619
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3620
- return Reflect.metadata(k, v);
3903
+ __name(langGraphPlatformEndpoint, "langGraphPlatformEndpoint");
3904
+ function resolveEndpointType(endpoint) {
3905
+ if (!endpoint.type) {
3906
+ if ("langsmithApiKey" in endpoint && "deploymentUrl" in endpoint && "agents" in endpoint) {
3907
+ return EndpointType.LangGraphPlatform;
3908
+ } else {
3909
+ return EndpointType.CopilotKit;
3910
+ }
3911
+ }
3912
+ return endpoint.type;
3621
3913
  }
3622
- __name(_ts_metadata5, "_ts_metadata");
3623
- var FrontendInput = class {
3624
- toDeprecate_fullContext;
3625
- actions;
3626
- url;
3627
- };
3628
- __name(FrontendInput, "FrontendInput");
3629
- _ts_decorate5([
3630
- (0, import_type_graphql6.Field)(() => String, {
3631
- nullable: true
3632
- }),
3633
- _ts_metadata5("design:type", String)
3634
- ], FrontendInput.prototype, "toDeprecate_fullContext", void 0);
3635
- _ts_decorate5([
3636
- (0, import_type_graphql6.Field)(() => [
3637
- ActionInput
3638
- ]),
3639
- _ts_metadata5("design:type", Array)
3640
- ], FrontendInput.prototype, "actions", void 0);
3641
- _ts_decorate5([
3642
- (0, import_type_graphql6.Field)(() => String, {
3643
- nullable: true
3644
- }),
3645
- _ts_metadata5("design:type", String)
3646
- ], FrontendInput.prototype, "url", void 0);
3647
- FrontendInput = _ts_decorate5([
3648
- (0, import_type_graphql6.InputType)()
3649
- ], FrontendInput);
3914
+ __name(resolveEndpointType, "resolveEndpointType");
3650
3915
 
3651
- // src/graphql/inputs/cloud.input.ts
3652
- var import_type_graphql8 = require("type-graphql");
3916
+ // src/lib/integrations/shared.ts
3917
+ var import_type_graphql26 = require("type-graphql");
3653
3918
 
3654
- // src/graphql/inputs/cloud-guardrails.input.ts
3655
- var import_type_graphql7 = require("type-graphql");
3656
- function _ts_decorate6(decorators, target, key, desc) {
3657
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3658
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3659
- r = Reflect.decorate(decorators, target, key, desc);
3660
- else
3661
- for (var i = decorators.length - 1; i >= 0; i--)
3662
- if (d = decorators[i])
3663
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3664
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3665
- }
3666
- __name(_ts_decorate6, "_ts_decorate");
3667
- function _ts_metadata6(k, v) {
3668
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3669
- return Reflect.metadata(k, v);
3670
- }
3671
- __name(_ts_metadata6, "_ts_metadata");
3672
- var GuardrailsRuleInput = class {
3673
- allowList = [];
3674
- denyList = [];
3675
- };
3676
- __name(GuardrailsRuleInput, "GuardrailsRuleInput");
3677
- _ts_decorate6([
3678
- (0, import_type_graphql7.Field)(() => [
3679
- String
3680
- ], {
3681
- nullable: true
3682
- }),
3683
- _ts_metadata6("design:type", Array)
3684
- ], GuardrailsRuleInput.prototype, "allowList", void 0);
3685
- _ts_decorate6([
3686
- (0, import_type_graphql7.Field)(() => [
3687
- String
3688
- ], {
3689
- nullable: true
3690
- }),
3691
- _ts_metadata6("design:type", Array)
3692
- ], GuardrailsRuleInput.prototype, "denyList", void 0);
3693
- GuardrailsRuleInput = _ts_decorate6([
3694
- (0, import_type_graphql7.InputType)()
3695
- ], GuardrailsRuleInput);
3696
- var GuardrailsInput = class {
3697
- inputValidationRules;
3698
- };
3699
- __name(GuardrailsInput, "GuardrailsInput");
3700
- _ts_decorate6([
3701
- (0, import_type_graphql7.Field)(() => GuardrailsRuleInput, {
3702
- nullable: false
3703
- }),
3704
- _ts_metadata6("design:type", typeof GuardrailsRuleInput === "undefined" ? Object : GuardrailsRuleInput)
3705
- ], GuardrailsInput.prototype, "inputValidationRules", void 0);
3706
- GuardrailsInput = _ts_decorate6([
3707
- (0, import_type_graphql7.InputType)()
3708
- ], GuardrailsInput);
3919
+ // src/graphql/resolvers/copilot.resolver.ts
3920
+ var import_type_graphql20 = require("type-graphql");
3921
+ var import_rxjs4 = require("rxjs");
3709
3922
 
3710
- // src/graphql/inputs/cloud.input.ts
3923
+ // src/graphql/inputs/generate-copilot-response.input.ts
3924
+ var import_type_graphql18 = require("type-graphql");
3925
+
3926
+ // src/graphql/inputs/message.input.ts
3927
+ var import_type_graphql8 = require("type-graphql");
3711
3928
  function _ts_decorate7(decorators, target, key, desc) {
3712
3929
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3713
3930
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3724,21 +3941,173 @@ function _ts_metadata7(k, v) {
3724
3941
  return Reflect.metadata(k, v);
3725
3942
  }
3726
3943
  __name(_ts_metadata7, "_ts_metadata");
3727
- var CloudInput = class {
3728
- guardrails;
3944
+ var MessageInput = class extends BaseMessageInput {
3945
+ textMessage;
3946
+ actionExecutionMessage;
3947
+ resultMessage;
3948
+ agentStateMessage;
3729
3949
  };
3730
- __name(CloudInput, "CloudInput");
3950
+ __name(MessageInput, "MessageInput");
3731
3951
  _ts_decorate7([
3732
- (0, import_type_graphql8.Field)(() => GuardrailsInput, {
3952
+ (0, import_type_graphql8.Field)(() => TextMessageInput, {
3733
3953
  nullable: true
3734
3954
  }),
3735
- _ts_metadata7("design:type", typeof GuardrailsInput === "undefined" ? Object : GuardrailsInput)
3736
- ], CloudInput.prototype, "guardrails", void 0);
3737
- CloudInput = _ts_decorate7([
3955
+ _ts_metadata7("design:type", typeof TextMessageInput === "undefined" ? Object : TextMessageInput)
3956
+ ], MessageInput.prototype, "textMessage", void 0);
3957
+ _ts_decorate7([
3958
+ (0, import_type_graphql8.Field)(() => ActionExecutionMessageInput, {
3959
+ nullable: true
3960
+ }),
3961
+ _ts_metadata7("design:type", typeof ActionExecutionMessageInput === "undefined" ? Object : ActionExecutionMessageInput)
3962
+ ], MessageInput.prototype, "actionExecutionMessage", void 0);
3963
+ _ts_decorate7([
3964
+ (0, import_type_graphql8.Field)(() => ResultMessageInput, {
3965
+ nullable: true
3966
+ }),
3967
+ _ts_metadata7("design:type", typeof ResultMessageInput === "undefined" ? Object : ResultMessageInput)
3968
+ ], MessageInput.prototype, "resultMessage", void 0);
3969
+ _ts_decorate7([
3970
+ (0, import_type_graphql8.Field)(() => AgentStateMessageInput, {
3971
+ nullable: true
3972
+ }),
3973
+ _ts_metadata7("design:type", typeof AgentStateMessageInput === "undefined" ? Object : AgentStateMessageInput)
3974
+ ], MessageInput.prototype, "agentStateMessage", void 0);
3975
+ MessageInput = _ts_decorate7([
3738
3976
  (0, import_type_graphql8.InputType)()
3739
- ], CloudInput);
3977
+ ], MessageInput);
3978
+ var TextMessageInput = class {
3979
+ content;
3980
+ parentMessageId;
3981
+ role;
3982
+ };
3983
+ __name(TextMessageInput, "TextMessageInput");
3984
+ _ts_decorate7([
3985
+ (0, import_type_graphql8.Field)(() => String),
3986
+ _ts_metadata7("design:type", String)
3987
+ ], TextMessageInput.prototype, "content", void 0);
3988
+ _ts_decorate7([
3989
+ (0, import_type_graphql8.Field)(() => String, {
3990
+ nullable: true
3991
+ }),
3992
+ _ts_metadata7("design:type", String)
3993
+ ], TextMessageInput.prototype, "parentMessageId", void 0);
3994
+ _ts_decorate7([
3995
+ (0, import_type_graphql8.Field)(() => MessageRole),
3996
+ _ts_metadata7("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
3997
+ ], TextMessageInput.prototype, "role", void 0);
3998
+ TextMessageInput = _ts_decorate7([
3999
+ (0, import_type_graphql8.InputType)()
4000
+ ], TextMessageInput);
4001
+ var ActionExecutionMessageInput = class {
4002
+ name;
4003
+ arguments;
4004
+ parentMessageId;
4005
+ scope;
4006
+ };
4007
+ __name(ActionExecutionMessageInput, "ActionExecutionMessageInput");
4008
+ _ts_decorate7([
4009
+ (0, import_type_graphql8.Field)(() => String),
4010
+ _ts_metadata7("design:type", String)
4011
+ ], ActionExecutionMessageInput.prototype, "name", void 0);
4012
+ _ts_decorate7([
4013
+ (0, import_type_graphql8.Field)(() => String),
4014
+ _ts_metadata7("design:type", String)
4015
+ ], ActionExecutionMessageInput.prototype, "arguments", void 0);
4016
+ _ts_decorate7([
4017
+ (0, import_type_graphql8.Field)(() => String, {
4018
+ nullable: true
4019
+ }),
4020
+ _ts_metadata7("design:type", String)
4021
+ ], ActionExecutionMessageInput.prototype, "parentMessageId", void 0);
4022
+ _ts_decorate7([
4023
+ (0, import_type_graphql8.Field)(() => String, {
4024
+ nullable: true,
4025
+ deprecationReason: "This field will be removed in a future version"
4026
+ }),
4027
+ _ts_metadata7("design:type", typeof String === "undefined" ? Object : String)
4028
+ ], ActionExecutionMessageInput.prototype, "scope", void 0);
4029
+ ActionExecutionMessageInput = _ts_decorate7([
4030
+ (0, import_type_graphql8.InputType)()
4031
+ ], ActionExecutionMessageInput);
4032
+ var ResultMessageInput = class {
4033
+ actionExecutionId;
4034
+ actionName;
4035
+ parentMessageId;
4036
+ result;
4037
+ };
4038
+ __name(ResultMessageInput, "ResultMessageInput");
4039
+ _ts_decorate7([
4040
+ (0, import_type_graphql8.Field)(() => String),
4041
+ _ts_metadata7("design:type", String)
4042
+ ], ResultMessageInput.prototype, "actionExecutionId", void 0);
4043
+ _ts_decorate7([
4044
+ (0, import_type_graphql8.Field)(() => String),
4045
+ _ts_metadata7("design:type", String)
4046
+ ], ResultMessageInput.prototype, "actionName", void 0);
4047
+ _ts_decorate7([
4048
+ (0, import_type_graphql8.Field)(() => String, {
4049
+ nullable: true
4050
+ }),
4051
+ _ts_metadata7("design:type", String)
4052
+ ], ResultMessageInput.prototype, "parentMessageId", void 0);
4053
+ _ts_decorate7([
4054
+ (0, import_type_graphql8.Field)(() => String),
4055
+ _ts_metadata7("design:type", String)
4056
+ ], ResultMessageInput.prototype, "result", void 0);
4057
+ ResultMessageInput = _ts_decorate7([
4058
+ (0, import_type_graphql8.InputType)()
4059
+ ], ResultMessageInput);
4060
+ var AgentStateMessageInput = class {
4061
+ threadId;
4062
+ agentName;
4063
+ role;
4064
+ state;
4065
+ running;
4066
+ nodeName;
4067
+ runId;
4068
+ active;
4069
+ };
4070
+ __name(AgentStateMessageInput, "AgentStateMessageInput");
4071
+ _ts_decorate7([
4072
+ (0, import_type_graphql8.Field)(() => String),
4073
+ _ts_metadata7("design:type", String)
4074
+ ], AgentStateMessageInput.prototype, "threadId", void 0);
4075
+ _ts_decorate7([
4076
+ (0, import_type_graphql8.Field)(() => String),
4077
+ _ts_metadata7("design:type", String)
4078
+ ], AgentStateMessageInput.prototype, "agentName", void 0);
4079
+ _ts_decorate7([
4080
+ (0, import_type_graphql8.Field)(() => MessageRole),
4081
+ _ts_metadata7("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4082
+ ], AgentStateMessageInput.prototype, "role", void 0);
4083
+ _ts_decorate7([
4084
+ (0, import_type_graphql8.Field)(() => String),
4085
+ _ts_metadata7("design:type", String)
4086
+ ], AgentStateMessageInput.prototype, "state", void 0);
4087
+ _ts_decorate7([
4088
+ (0, import_type_graphql8.Field)(() => Boolean),
4089
+ _ts_metadata7("design:type", Boolean)
4090
+ ], AgentStateMessageInput.prototype, "running", void 0);
4091
+ _ts_decorate7([
4092
+ (0, import_type_graphql8.Field)(() => String),
4093
+ _ts_metadata7("design:type", String)
4094
+ ], AgentStateMessageInput.prototype, "nodeName", void 0);
4095
+ _ts_decorate7([
4096
+ (0, import_type_graphql8.Field)(() => String),
4097
+ _ts_metadata7("design:type", String)
4098
+ ], AgentStateMessageInput.prototype, "runId", void 0);
4099
+ _ts_decorate7([
4100
+ (0, import_type_graphql8.Field)(() => Boolean),
4101
+ _ts_metadata7("design:type", Boolean)
4102
+ ], AgentStateMessageInput.prototype, "active", void 0);
4103
+ AgentStateMessageInput = _ts_decorate7([
4104
+ (0, import_type_graphql8.InputType)()
4105
+ ], AgentStateMessageInput);
3740
4106
 
3741
- // src/graphql/inputs/forwarded-parameters.input.ts
4107
+ // src/graphql/inputs/frontend.input.ts
4108
+ var import_type_graphql10 = require("type-graphql");
4109
+
4110
+ // src/graphql/inputs/action.input.ts
3742
4111
  var import_type_graphql9 = require("type-graphql");
3743
4112
  function _ts_decorate8(decorators, target, key, desc) {
3744
4113
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -3756,59 +4125,36 @@ function _ts_metadata8(k, v) {
3756
4125
  return Reflect.metadata(k, v);
3757
4126
  }
3758
4127
  __name(_ts_metadata8, "_ts_metadata");
3759
- var ForwardedParametersInput = class {
3760
- model;
3761
- maxTokens;
3762
- stop;
3763
- toolChoice;
3764
- toolChoiceFunctionName;
3765
- temperature;
4128
+ var ActionInput = class {
4129
+ name;
4130
+ description;
4131
+ jsonSchema;
4132
+ available;
3766
4133
  };
3767
- __name(ForwardedParametersInput, "ForwardedParametersInput");
4134
+ __name(ActionInput, "ActionInput");
3768
4135
  _ts_decorate8([
3769
- (0, import_type_graphql9.Field)(() => String, {
3770
- nullable: true
3771
- }),
4136
+ (0, import_type_graphql9.Field)(() => String),
3772
4137
  _ts_metadata8("design:type", String)
3773
- ], ForwardedParametersInput.prototype, "model", void 0);
3774
- _ts_decorate8([
3775
- (0, import_type_graphql9.Field)(() => Number, {
3776
- nullable: true
3777
- }),
3778
- _ts_metadata8("design:type", Number)
3779
- ], ForwardedParametersInput.prototype, "maxTokens", void 0);
3780
- _ts_decorate8([
3781
- (0, import_type_graphql9.Field)(() => [
3782
- String
3783
- ], {
3784
- nullable: true
3785
- }),
3786
- _ts_metadata8("design:type", Array)
3787
- ], ForwardedParametersInput.prototype, "stop", void 0);
4138
+ ], ActionInput.prototype, "name", void 0);
3788
4139
  _ts_decorate8([
3789
- (0, import_type_graphql9.Field)(() => String, {
3790
- nullable: true
3791
- }),
3792
- _ts_metadata8("design:type", typeof String === "undefined" ? Object : String)
3793
- ], ForwardedParametersInput.prototype, "toolChoice", void 0);
4140
+ (0, import_type_graphql9.Field)(() => String),
4141
+ _ts_metadata8("design:type", String)
4142
+ ], ActionInput.prototype, "description", void 0);
3794
4143
  _ts_decorate8([
3795
- (0, import_type_graphql9.Field)(() => String, {
3796
- nullable: true
3797
- }),
4144
+ (0, import_type_graphql9.Field)(() => String),
3798
4145
  _ts_metadata8("design:type", String)
3799
- ], ForwardedParametersInput.prototype, "toolChoiceFunctionName", void 0);
4146
+ ], ActionInput.prototype, "jsonSchema", void 0);
3800
4147
  _ts_decorate8([
3801
- (0, import_type_graphql9.Field)(() => Number, {
4148
+ (0, import_type_graphql9.Field)(() => ActionInputAvailability, {
3802
4149
  nullable: true
3803
4150
  }),
3804
- _ts_metadata8("design:type", Number)
3805
- ], ForwardedParametersInput.prototype, "temperature", void 0);
3806
- ForwardedParametersInput = _ts_decorate8([
4151
+ _ts_metadata8("design:type", typeof ActionInputAvailability === "undefined" ? Object : ActionInputAvailability)
4152
+ ], ActionInput.prototype, "available", void 0);
4153
+ ActionInput = _ts_decorate8([
3807
4154
  (0, import_type_graphql9.InputType)()
3808
- ], ForwardedParametersInput);
4155
+ ], ActionInput);
3809
4156
 
3810
- // src/graphql/inputs/agent-session.input.ts
3811
- var import_type_graphql10 = require("type-graphql");
4157
+ // src/graphql/inputs/frontend.input.ts
3812
4158
  function _ts_decorate9(decorators, target, key, desc) {
3813
4159
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3814
4160
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3825,33 +4171,38 @@ function _ts_metadata9(k, v) {
3825
4171
  return Reflect.metadata(k, v);
3826
4172
  }
3827
4173
  __name(_ts_metadata9, "_ts_metadata");
3828
- var AgentSessionInput = class {
3829
- agentName;
3830
- threadId;
3831
- nodeName;
4174
+ var FrontendInput = class {
4175
+ toDeprecate_fullContext;
4176
+ actions;
4177
+ url;
3832
4178
  };
3833
- __name(AgentSessionInput, "AgentSessionInput");
3834
- _ts_decorate9([
3835
- (0, import_type_graphql10.Field)(() => String),
3836
- _ts_metadata9("design:type", String)
3837
- ], AgentSessionInput.prototype, "agentName", void 0);
4179
+ __name(FrontendInput, "FrontendInput");
3838
4180
  _ts_decorate9([
3839
4181
  (0, import_type_graphql10.Field)(() => String, {
3840
4182
  nullable: true
3841
4183
  }),
3842
4184
  _ts_metadata9("design:type", String)
3843
- ], AgentSessionInput.prototype, "threadId", void 0);
4185
+ ], FrontendInput.prototype, "toDeprecate_fullContext", void 0);
4186
+ _ts_decorate9([
4187
+ (0, import_type_graphql10.Field)(() => [
4188
+ ActionInput
4189
+ ]),
4190
+ _ts_metadata9("design:type", Array)
4191
+ ], FrontendInput.prototype, "actions", void 0);
3844
4192
  _ts_decorate9([
3845
4193
  (0, import_type_graphql10.Field)(() => String, {
3846
4194
  nullable: true
3847
4195
  }),
3848
4196
  _ts_metadata9("design:type", String)
3849
- ], AgentSessionInput.prototype, "nodeName", void 0);
3850
- AgentSessionInput = _ts_decorate9([
4197
+ ], FrontendInput.prototype, "url", void 0);
4198
+ FrontendInput = _ts_decorate9([
3851
4199
  (0, import_type_graphql10.InputType)()
3852
- ], AgentSessionInput);
4200
+ ], FrontendInput);
3853
4201
 
3854
- // src/graphql/inputs/agent-state.input.ts
4202
+ // src/graphql/inputs/cloud.input.ts
4203
+ var import_type_graphql12 = require("type-graphql");
4204
+
4205
+ // src/graphql/inputs/cloud-guardrails.input.ts
3855
4206
  var import_type_graphql11 = require("type-graphql");
3856
4207
  function _ts_decorate10(decorators, target, key, desc) {
3857
4208
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -3869,76 +4220,76 @@ function _ts_metadata10(k, v) {
3869
4220
  return Reflect.metadata(k, v);
3870
4221
  }
3871
4222
  __name(_ts_metadata10, "_ts_metadata");
3872
- var AgentStateInput = class {
3873
- agentName;
3874
- state;
4223
+ var GuardrailsRuleInput = class {
4224
+ allowList = [];
4225
+ denyList = [];
3875
4226
  };
3876
- __name(AgentStateInput, "AgentStateInput");
4227
+ __name(GuardrailsRuleInput, "GuardrailsRuleInput");
3877
4228
  _ts_decorate10([
3878
- (0, import_type_graphql11.Field)(() => String),
3879
- _ts_metadata10("design:type", String)
3880
- ], AgentStateInput.prototype, "agentName", void 0);
4229
+ (0, import_type_graphql11.Field)(() => [
4230
+ String
4231
+ ], {
4232
+ nullable: true
4233
+ }),
4234
+ _ts_metadata10("design:type", Array)
4235
+ ], GuardrailsRuleInput.prototype, "allowList", void 0);
3881
4236
  _ts_decorate10([
3882
- (0, import_type_graphql11.Field)(() => String),
3883
- _ts_metadata10("design:type", String)
3884
- ], AgentStateInput.prototype, "state", void 0);
3885
- AgentStateInput = _ts_decorate10([
4237
+ (0, import_type_graphql11.Field)(() => [
4238
+ String
4239
+ ], {
4240
+ nullable: true
4241
+ }),
4242
+ _ts_metadata10("design:type", Array)
4243
+ ], GuardrailsRuleInput.prototype, "denyList", void 0);
4244
+ GuardrailsRuleInput = _ts_decorate10([
3886
4245
  (0, import_type_graphql11.InputType)()
3887
- ], AgentStateInput);
4246
+ ], GuardrailsRuleInput);
4247
+ var GuardrailsInput = class {
4248
+ inputValidationRules;
4249
+ };
4250
+ __name(GuardrailsInput, "GuardrailsInput");
4251
+ _ts_decorate10([
4252
+ (0, import_type_graphql11.Field)(() => GuardrailsRuleInput, {
4253
+ nullable: false
4254
+ }),
4255
+ _ts_metadata10("design:type", typeof GuardrailsRuleInput === "undefined" ? Object : GuardrailsRuleInput)
4256
+ ], GuardrailsInput.prototype, "inputValidationRules", void 0);
4257
+ GuardrailsInput = _ts_decorate10([
4258
+ (0, import_type_graphql11.InputType)()
4259
+ ], GuardrailsInput);
3888
4260
 
3889
- // src/graphql/inputs/extensions.input.ts
3890
- var import_type_graphql12 = require("type-graphql");
4261
+ // src/graphql/inputs/cloud.input.ts
3891
4262
  function _ts_decorate11(decorators, target, key, desc) {
3892
4263
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3893
4264
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3894
4265
  r = Reflect.decorate(decorators, target, key, desc);
3895
4266
  else
3896
- for (var i = decorators.length - 1; i >= 0; i--)
3897
- if (d = decorators[i])
3898
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3899
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3900
- }
3901
- __name(_ts_decorate11, "_ts_decorate");
3902
- function _ts_metadata11(k, v) {
3903
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3904
- return Reflect.metadata(k, v);
3905
- }
3906
- __name(_ts_metadata11, "_ts_metadata");
3907
- var ExtensionsInput = class {
3908
- openaiAssistantAPI;
3909
- };
3910
- __name(ExtensionsInput, "ExtensionsInput");
3911
- _ts_decorate11([
3912
- (0, import_type_graphql12.Field)(() => OpenAIApiAssistantAPIInput, {
3913
- nullable: true
3914
- }),
3915
- _ts_metadata11("design:type", typeof OpenAIApiAssistantAPIInput === "undefined" ? Object : OpenAIApiAssistantAPIInput)
3916
- ], ExtensionsInput.prototype, "openaiAssistantAPI", void 0);
3917
- ExtensionsInput = _ts_decorate11([
3918
- (0, import_type_graphql12.InputType)()
3919
- ], ExtensionsInput);
3920
- var OpenAIApiAssistantAPIInput = class {
3921
- runId;
3922
- threadId;
4267
+ for (var i = decorators.length - 1; i >= 0; i--)
4268
+ if (d = decorators[i])
4269
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4270
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4271
+ }
4272
+ __name(_ts_decorate11, "_ts_decorate");
4273
+ function _ts_metadata11(k, v) {
4274
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4275
+ return Reflect.metadata(k, v);
4276
+ }
4277
+ __name(_ts_metadata11, "_ts_metadata");
4278
+ var CloudInput = class {
4279
+ guardrails;
3923
4280
  };
3924
- __name(OpenAIApiAssistantAPIInput, "OpenAIApiAssistantAPIInput");
3925
- _ts_decorate11([
3926
- (0, import_type_graphql12.Field)(() => String, {
3927
- nullable: true
3928
- }),
3929
- _ts_metadata11("design:type", String)
3930
- ], OpenAIApiAssistantAPIInput.prototype, "runId", void 0);
4281
+ __name(CloudInput, "CloudInput");
3931
4282
  _ts_decorate11([
3932
- (0, import_type_graphql12.Field)(() => String, {
4283
+ (0, import_type_graphql12.Field)(() => GuardrailsInput, {
3933
4284
  nullable: true
3934
4285
  }),
3935
- _ts_metadata11("design:type", String)
3936
- ], OpenAIApiAssistantAPIInput.prototype, "threadId", void 0);
3937
- OpenAIApiAssistantAPIInput = _ts_decorate11([
4286
+ _ts_metadata11("design:type", typeof GuardrailsInput === "undefined" ? Object : GuardrailsInput)
4287
+ ], CloudInput.prototype, "guardrails", void 0);
4288
+ CloudInput = _ts_decorate11([
3938
4289
  (0, import_type_graphql12.InputType)()
3939
- ], OpenAIApiAssistantAPIInput);
4290
+ ], CloudInput);
3940
4291
 
3941
- // src/graphql/inputs/meta-event.input.ts
4292
+ // src/graphql/inputs/forwarded-parameters.input.ts
3942
4293
  var import_type_graphql13 = require("type-graphql");
3943
4294
  function _ts_decorate12(decorators, target, key, desc) {
3944
4295
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -3956,36 +4307,59 @@ function _ts_metadata12(k, v) {
3956
4307
  return Reflect.metadata(k, v);
3957
4308
  }
3958
4309
  __name(_ts_metadata12, "_ts_metadata");
3959
- var MetaEventInput = class {
3960
- type = "MetaEvent";
3961
- name;
3962
- value;
3963
- response;
4310
+ var ForwardedParametersInput = class {
4311
+ model;
4312
+ maxTokens;
4313
+ stop;
4314
+ toolChoice;
4315
+ toolChoiceFunctionName;
4316
+ temperature;
3964
4317
  };
3965
- __name(MetaEventInput, "MetaEventInput");
4318
+ __name(ForwardedParametersInput, "ForwardedParametersInput");
3966
4319
  _ts_decorate12([
3967
- (0, import_type_graphql13.Field)(() => String),
4320
+ (0, import_type_graphql13.Field)(() => String, {
4321
+ nullable: true
4322
+ }),
3968
4323
  _ts_metadata12("design:type", String)
3969
- ], MetaEventInput.prototype, "type", void 0);
4324
+ ], ForwardedParametersInput.prototype, "model", void 0);
3970
4325
  _ts_decorate12([
3971
- (0, import_type_graphql13.Field)(() => MetaEventName),
3972
- _ts_metadata12("design:type", typeof MetaEventName === "undefined" ? Object : MetaEventName)
3973
- ], MetaEventInput.prototype, "name", void 0);
4326
+ (0, import_type_graphql13.Field)(() => Number, {
4327
+ nullable: true
4328
+ }),
4329
+ _ts_metadata12("design:type", Number)
4330
+ ], ForwardedParametersInput.prototype, "maxTokens", void 0);
3974
4331
  _ts_decorate12([
3975
- (0, import_type_graphql13.Field)(() => String),
3976
- _ts_metadata12("design:type", String)
3977
- ], MetaEventInput.prototype, "value", void 0);
4332
+ (0, import_type_graphql13.Field)(() => [
4333
+ String
4334
+ ], {
4335
+ nullable: true
4336
+ }),
4337
+ _ts_metadata12("design:type", Array)
4338
+ ], ForwardedParametersInput.prototype, "stop", void 0);
4339
+ _ts_decorate12([
4340
+ (0, import_type_graphql13.Field)(() => String, {
4341
+ nullable: true
4342
+ }),
4343
+ _ts_metadata12("design:type", typeof String === "undefined" ? Object : String)
4344
+ ], ForwardedParametersInput.prototype, "toolChoice", void 0);
3978
4345
  _ts_decorate12([
3979
4346
  (0, import_type_graphql13.Field)(() => String, {
3980
4347
  nullable: true
3981
4348
  }),
3982
4349
  _ts_metadata12("design:type", String)
3983
- ], MetaEventInput.prototype, "response", void 0);
3984
- MetaEventInput = _ts_decorate12([
4350
+ ], ForwardedParametersInput.prototype, "toolChoiceFunctionName", void 0);
4351
+ _ts_decorate12([
4352
+ (0, import_type_graphql13.Field)(() => Number, {
4353
+ nullable: true
4354
+ }),
4355
+ _ts_metadata12("design:type", Number)
4356
+ ], ForwardedParametersInput.prototype, "temperature", void 0);
4357
+ ForwardedParametersInput = _ts_decorate12([
3985
4358
  (0, import_type_graphql13.InputType)()
3986
- ], MetaEventInput);
4359
+ ], ForwardedParametersInput);
3987
4360
 
3988
- // src/graphql/inputs/generate-copilot-response.input.ts
4361
+ // src/graphql/inputs/agent-session.input.ts
4362
+ var import_type_graphql14 = require("type-graphql");
3989
4363
  function _ts_decorate13(decorators, target, key, desc) {
3990
4364
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3991
4365
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -4002,116 +4376,33 @@ function _ts_metadata13(k, v) {
4002
4376
  return Reflect.metadata(k, v);
4003
4377
  }
4004
4378
  __name(_ts_metadata13, "_ts_metadata");
4005
- var GenerateCopilotResponseMetadataInput = class {
4006
- requestType;
4007
- };
4008
- __name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
4009
- _ts_decorate13([
4010
- (0, import_type_graphql14.Field)(() => CopilotRequestType, {
4011
- nullable: true
4012
- }),
4013
- _ts_metadata13("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
4014
- ], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
4015
- GenerateCopilotResponseMetadataInput = _ts_decorate13([
4016
- (0, import_type_graphql14.InputType)()
4017
- ], GenerateCopilotResponseMetadataInput);
4018
- var GenerateCopilotResponseInput = class {
4019
- metadata;
4379
+ var AgentSessionInput = class {
4380
+ agentName;
4020
4381
  threadId;
4021
- runId;
4022
- messages;
4023
- frontend;
4024
- cloud;
4025
- forwardedParameters;
4026
- agentSession;
4027
- agentState;
4028
- agentStates;
4029
- extensions;
4030
- metaEvents;
4382
+ nodeName;
4031
4383
  };
4032
- __name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
4384
+ __name(AgentSessionInput, "AgentSessionInput");
4033
4385
  _ts_decorate13([
4034
- (0, import_type_graphql14.Field)(() => GenerateCopilotResponseMetadataInput, {
4035
- nullable: false
4036
- }),
4037
- _ts_metadata13("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
4038
- ], GenerateCopilotResponseInput.prototype, "metadata", void 0);
4386
+ (0, import_type_graphql14.Field)(() => String),
4387
+ _ts_metadata13("design:type", String)
4388
+ ], AgentSessionInput.prototype, "agentName", void 0);
4039
4389
  _ts_decorate13([
4040
4390
  (0, import_type_graphql14.Field)(() => String, {
4041
4391
  nullable: true
4042
4392
  }),
4043
4393
  _ts_metadata13("design:type", String)
4044
- ], GenerateCopilotResponseInput.prototype, "threadId", void 0);
4394
+ ], AgentSessionInput.prototype, "threadId", void 0);
4045
4395
  _ts_decorate13([
4046
4396
  (0, import_type_graphql14.Field)(() => String, {
4047
4397
  nullable: true
4048
4398
  }),
4049
4399
  _ts_metadata13("design:type", String)
4050
- ], GenerateCopilotResponseInput.prototype, "runId", void 0);
4051
- _ts_decorate13([
4052
- (0, import_type_graphql14.Field)(() => [
4053
- MessageInput
4054
- ]),
4055
- _ts_metadata13("design:type", Array)
4056
- ], GenerateCopilotResponseInput.prototype, "messages", void 0);
4057
- _ts_decorate13([
4058
- (0, import_type_graphql14.Field)(() => FrontendInput),
4059
- _ts_metadata13("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
4060
- ], GenerateCopilotResponseInput.prototype, "frontend", void 0);
4061
- _ts_decorate13([
4062
- (0, import_type_graphql14.Field)(() => CloudInput, {
4063
- nullable: true
4064
- }),
4065
- _ts_metadata13("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
4066
- ], GenerateCopilotResponseInput.prototype, "cloud", void 0);
4067
- _ts_decorate13([
4068
- (0, import_type_graphql14.Field)(() => ForwardedParametersInput, {
4069
- nullable: true
4070
- }),
4071
- _ts_metadata13("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
4072
- ], GenerateCopilotResponseInput.prototype, "forwardedParameters", void 0);
4073
- _ts_decorate13([
4074
- (0, import_type_graphql14.Field)(() => AgentSessionInput, {
4075
- nullable: true
4076
- }),
4077
- _ts_metadata13("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
4078
- ], GenerateCopilotResponseInput.prototype, "agentSession", void 0);
4079
- _ts_decorate13([
4080
- (0, import_type_graphql14.Field)(() => AgentStateInput, {
4081
- nullable: true
4082
- }),
4083
- _ts_metadata13("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
4084
- ], GenerateCopilotResponseInput.prototype, "agentState", void 0);
4085
- _ts_decorate13([
4086
- (0, import_type_graphql14.Field)(() => [
4087
- AgentStateInput
4088
- ], {
4089
- nullable: true
4090
- }),
4091
- _ts_metadata13("design:type", Array)
4092
- ], GenerateCopilotResponseInput.prototype, "agentStates", void 0);
4093
- _ts_decorate13([
4094
- (0, import_type_graphql14.Field)(() => ExtensionsInput, {
4095
- nullable: true
4096
- }),
4097
- _ts_metadata13("design:type", typeof ExtensionsInput === "undefined" ? Object : ExtensionsInput)
4098
- ], GenerateCopilotResponseInput.prototype, "extensions", void 0);
4099
- _ts_decorate13([
4100
- (0, import_type_graphql14.Field)(() => [
4101
- MetaEventInput
4102
- ], {
4103
- nullable: true
4104
- }),
4105
- _ts_metadata13("design:type", Array)
4106
- ], GenerateCopilotResponseInput.prototype, "metaEvents", void 0);
4107
- GenerateCopilotResponseInput = _ts_decorate13([
4400
+ ], AgentSessionInput.prototype, "nodeName", void 0);
4401
+ AgentSessionInput = _ts_decorate13([
4108
4402
  (0, import_type_graphql14.InputType)()
4109
- ], GenerateCopilotResponseInput);
4110
-
4111
- // src/graphql/types/copilot-response.type.ts
4112
- var import_type_graphql18 = require("type-graphql");
4403
+ ], AgentSessionInput);
4113
4404
 
4114
- // src/graphql/types/message-status.type.ts
4405
+ // src/graphql/inputs/agent-state.input.ts
4115
4406
  var import_type_graphql15 = require("type-graphql");
4116
4407
  function _ts_decorate14(decorators, target, key, desc) {
4117
4408
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4129,62 +4420,24 @@ function _ts_metadata14(k, v) {
4129
4420
  return Reflect.metadata(k, v);
4130
4421
  }
4131
4422
  __name(_ts_metadata14, "_ts_metadata");
4132
- var MessageStatusCode;
4133
- (function(MessageStatusCode2) {
4134
- MessageStatusCode2["Pending"] = "pending";
4135
- MessageStatusCode2["Success"] = "success";
4136
- MessageStatusCode2["Failed"] = "failed";
4137
- })(MessageStatusCode || (MessageStatusCode = {}));
4138
- (0, import_type_graphql15.registerEnumType)(MessageStatusCode, {
4139
- name: "MessageStatusCode"
4140
- });
4141
- var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
4142
- code;
4143
- }, "BaseMessageStatus");
4423
+ var AgentStateInput = class {
4424
+ agentName;
4425
+ state;
4426
+ };
4427
+ __name(AgentStateInput, "AgentStateInput");
4144
4428
  _ts_decorate14([
4145
- (0, import_type_graphql15.Field)(() => MessageStatusCode),
4429
+ (0, import_type_graphql15.Field)(() => String),
4146
4430
  _ts_metadata14("design:type", String)
4147
- ], BaseMessageStatus.prototype, "code", void 0);
4148
- BaseMessageStatus = _ts_decorate14([
4149
- (0, import_type_graphql15.ObjectType)()
4150
- ], BaseMessageStatus);
4151
- var PendingMessageStatus = class extends BaseMessageStatus {
4152
- code = "pending";
4153
- };
4154
- __name(PendingMessageStatus, "PendingMessageStatus");
4155
- PendingMessageStatus = _ts_decorate14([
4156
- (0, import_type_graphql15.ObjectType)()
4157
- ], PendingMessageStatus);
4158
- var SuccessMessageStatus = class extends BaseMessageStatus {
4159
- code = "success";
4160
- };
4161
- __name(SuccessMessageStatus, "SuccessMessageStatus");
4162
- SuccessMessageStatus = _ts_decorate14([
4163
- (0, import_type_graphql15.ObjectType)()
4164
- ], SuccessMessageStatus);
4165
- var FailedMessageStatus = class extends BaseMessageStatus {
4166
- code = "failed";
4167
- reason;
4168
- };
4169
- __name(FailedMessageStatus, "FailedMessageStatus");
4431
+ ], AgentStateInput.prototype, "agentName", void 0);
4170
4432
  _ts_decorate14([
4171
4433
  (0, import_type_graphql15.Field)(() => String),
4172
4434
  _ts_metadata14("design:type", String)
4173
- ], FailedMessageStatus.prototype, "reason", void 0);
4174
- FailedMessageStatus = _ts_decorate14([
4175
- (0, import_type_graphql15.ObjectType)()
4176
- ], FailedMessageStatus);
4177
- var MessageStatusUnion = (0, import_type_graphql15.createUnionType)({
4178
- name: "MessageStatus",
4179
- types: () => [
4180
- PendingMessageStatus,
4181
- SuccessMessageStatus,
4182
- FailedMessageStatus
4183
- ]
4184
- });
4435
+ ], AgentStateInput.prototype, "state", void 0);
4436
+ AgentStateInput = _ts_decorate14([
4437
+ (0, import_type_graphql15.InputType)()
4438
+ ], AgentStateInput);
4185
4439
 
4186
- // src/graphql/types/response-status.type.ts
4187
- var import_graphql_scalars = require("graphql-scalars");
4440
+ // src/graphql/inputs/extensions.input.ts
4188
4441
  var import_type_graphql16 = require("type-graphql");
4189
4442
  function _ts_decorate15(decorators, target, key, desc) {
4190
4443
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4202,95 +4455,41 @@ function _ts_metadata15(k, v) {
4202
4455
  return Reflect.metadata(k, v);
4203
4456
  }
4204
4457
  __name(_ts_metadata15, "_ts_metadata");
4205
- var ResponseStatusCode;
4206
- (function(ResponseStatusCode2) {
4207
- ResponseStatusCode2["Pending"] = "pending";
4208
- ResponseStatusCode2["Success"] = "success";
4209
- ResponseStatusCode2["Failed"] = "failed";
4210
- })(ResponseStatusCode || (ResponseStatusCode = {}));
4211
- (0, import_type_graphql16.registerEnumType)(ResponseStatusCode, {
4212
- name: "ResponseStatusCode"
4213
- });
4214
- var BaseResponseStatus = /* @__PURE__ */ __name(class BaseResponseStatus2 {
4215
- code;
4216
- }, "BaseResponseStatus");
4217
- _ts_decorate15([
4218
- (0, import_type_graphql16.Field)(() => ResponseStatusCode),
4219
- _ts_metadata15("design:type", String)
4220
- ], BaseResponseStatus.prototype, "code", void 0);
4221
- BaseResponseStatus = _ts_decorate15([
4222
- (0, import_type_graphql16.InterfaceType)({
4223
- resolveType(value) {
4224
- if (value.code === "success") {
4225
- return SuccessResponseStatus;
4226
- } else if (value.code === "failed") {
4227
- return FailedResponseStatus;
4228
- } else if (value.code === "pending") {
4229
- return PendingResponseStatus;
4230
- }
4231
- return void 0;
4232
- }
4233
- }),
4234
- (0, import_type_graphql16.ObjectType)()
4235
- ], BaseResponseStatus);
4236
- var PendingResponseStatus = class extends BaseResponseStatus {
4237
- code = "pending";
4238
- };
4239
- __name(PendingResponseStatus, "PendingResponseStatus");
4240
- PendingResponseStatus = _ts_decorate15([
4241
- (0, import_type_graphql16.ObjectType)({
4242
- implements: BaseResponseStatus
4243
- })
4244
- ], PendingResponseStatus);
4245
- var SuccessResponseStatus = class extends BaseResponseStatus {
4246
- code = "success";
4458
+ var ExtensionsInput = class {
4459
+ openaiAssistantAPI;
4247
4460
  };
4248
- __name(SuccessResponseStatus, "SuccessResponseStatus");
4249
- SuccessResponseStatus = _ts_decorate15([
4250
- (0, import_type_graphql16.ObjectType)({
4251
- implements: BaseResponseStatus
4252
- })
4253
- ], SuccessResponseStatus);
4254
- var FailedResponseStatusReason;
4255
- (function(FailedResponseStatusReason2) {
4256
- FailedResponseStatusReason2["GUARDRAILS_VALIDATION_FAILED"] = "GUARDRAILS_VALIDATION_FAILED";
4257
- FailedResponseStatusReason2["MESSAGE_STREAM_INTERRUPTED"] = "MESSAGE_STREAM_INTERRUPTED";
4258
- FailedResponseStatusReason2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
4259
- })(FailedResponseStatusReason || (FailedResponseStatusReason = {}));
4260
- (0, import_type_graphql16.registerEnumType)(FailedResponseStatusReason, {
4261
- name: "FailedResponseStatusReason"
4262
- });
4263
- var FailedResponseStatus = class extends BaseResponseStatus {
4264
- code = "failed";
4265
- reason;
4266
- details = null;
4461
+ __name(ExtensionsInput, "ExtensionsInput");
4462
+ _ts_decorate15([
4463
+ (0, import_type_graphql16.Field)(() => OpenAIApiAssistantAPIInput, {
4464
+ nullable: true
4465
+ }),
4466
+ _ts_metadata15("design:type", typeof OpenAIApiAssistantAPIInput === "undefined" ? Object : OpenAIApiAssistantAPIInput)
4467
+ ], ExtensionsInput.prototype, "openaiAssistantAPI", void 0);
4468
+ ExtensionsInput = _ts_decorate15([
4469
+ (0, import_type_graphql16.InputType)()
4470
+ ], ExtensionsInput);
4471
+ var OpenAIApiAssistantAPIInput = class {
4472
+ runId;
4473
+ threadId;
4267
4474
  };
4268
- __name(FailedResponseStatus, "FailedResponseStatus");
4475
+ __name(OpenAIApiAssistantAPIInput, "OpenAIApiAssistantAPIInput");
4269
4476
  _ts_decorate15([
4270
- (0, import_type_graphql16.Field)(() => FailedResponseStatusReason),
4477
+ (0, import_type_graphql16.Field)(() => String, {
4478
+ nullable: true
4479
+ }),
4271
4480
  _ts_metadata15("design:type", String)
4272
- ], FailedResponseStatus.prototype, "reason", void 0);
4481
+ ], OpenAIApiAssistantAPIInput.prototype, "runId", void 0);
4273
4482
  _ts_decorate15([
4274
- (0, import_type_graphql16.Field)(() => import_graphql_scalars.GraphQLJSON, {
4483
+ (0, import_type_graphql16.Field)(() => String, {
4275
4484
  nullable: true
4276
4485
  }),
4277
- _ts_metadata15("design:type", typeof Record === "undefined" ? Object : Record)
4278
- ], FailedResponseStatus.prototype, "details", void 0);
4279
- FailedResponseStatus = _ts_decorate15([
4280
- (0, import_type_graphql16.ObjectType)({
4281
- implements: BaseResponseStatus
4282
- })
4283
- ], FailedResponseStatus);
4284
- var ResponseStatusUnion = (0, import_type_graphql16.createUnionType)({
4285
- name: "ResponseStatus",
4286
- types: () => [
4287
- PendingResponseStatus,
4288
- SuccessResponseStatus,
4289
- FailedResponseStatus
4290
- ]
4291
- });
4486
+ _ts_metadata15("design:type", String)
4487
+ ], OpenAIApiAssistantAPIInput.prototype, "threadId", void 0);
4488
+ OpenAIApiAssistantAPIInput = _ts_decorate15([
4489
+ (0, import_type_graphql16.InputType)()
4490
+ ], OpenAIApiAssistantAPIInput);
4292
4491
 
4293
- // src/graphql/types/extensions-response.type.ts
4492
+ // src/graphql/inputs/meta-event.input.ts
4294
4493
  var import_type_graphql17 = require("type-graphql");
4295
4494
  function _ts_decorate16(decorators, target, key, desc) {
4296
4495
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4308,41 +4507,40 @@ function _ts_metadata16(k, v) {
4308
4507
  return Reflect.metadata(k, v);
4309
4508
  }
4310
4509
  __name(_ts_metadata16, "_ts_metadata");
4311
- var ExtensionsResponse = class {
4312
- openaiAssistantAPI;
4510
+ var MetaEventInput = class {
4511
+ name;
4512
+ value;
4513
+ response;
4514
+ messages;
4313
4515
  };
4314
- __name(ExtensionsResponse, "ExtensionsResponse");
4516
+ __name(MetaEventInput, "MetaEventInput");
4315
4517
  _ts_decorate16([
4316
- (0, import_type_graphql17.Field)(() => OpenAIApiAssistantAPIResponse, {
4317
- nullable: true
4318
- }),
4319
- _ts_metadata16("design:type", typeof OpenAIApiAssistantAPIResponse === "undefined" ? Object : OpenAIApiAssistantAPIResponse)
4320
- ], ExtensionsResponse.prototype, "openaiAssistantAPI", void 0);
4321
- ExtensionsResponse = _ts_decorate16([
4322
- (0, import_type_graphql17.ObjectType)()
4323
- ], ExtensionsResponse);
4324
- var OpenAIApiAssistantAPIResponse = class {
4325
- runId;
4326
- threadId;
4327
- };
4328
- __name(OpenAIApiAssistantAPIResponse, "OpenAIApiAssistantAPIResponse");
4518
+ (0, import_type_graphql17.Field)(() => MetaEventName),
4519
+ _ts_metadata16("design:type", typeof MetaEventName === "undefined" ? Object : MetaEventName)
4520
+ ], MetaEventInput.prototype, "name", void 0);
4521
+ _ts_decorate16([
4522
+ (0, import_type_graphql17.Field)(() => String),
4523
+ _ts_metadata16("design:type", String)
4524
+ ], MetaEventInput.prototype, "value", void 0);
4329
4525
  _ts_decorate16([
4330
4526
  (0, import_type_graphql17.Field)(() => String, {
4331
4527
  nullable: true
4332
4528
  }),
4333
4529
  _ts_metadata16("design:type", String)
4334
- ], OpenAIApiAssistantAPIResponse.prototype, "runId", void 0);
4530
+ ], MetaEventInput.prototype, "response", void 0);
4335
4531
  _ts_decorate16([
4336
- (0, import_type_graphql17.Field)(() => String, {
4532
+ (0, import_type_graphql17.Field)(() => [
4533
+ MessageInput
4534
+ ], {
4337
4535
  nullable: true
4338
4536
  }),
4339
- _ts_metadata16("design:type", String)
4340
- ], OpenAIApiAssistantAPIResponse.prototype, "threadId", void 0);
4341
- OpenAIApiAssistantAPIResponse = _ts_decorate16([
4342
- (0, import_type_graphql17.ObjectType)()
4343
- ], OpenAIApiAssistantAPIResponse);
4537
+ _ts_metadata16("design:type", Array)
4538
+ ], MetaEventInput.prototype, "messages", void 0);
4539
+ MetaEventInput = _ts_decorate16([
4540
+ (0, import_type_graphql17.InputType)()
4541
+ ], MetaEventInput);
4344
4542
 
4345
- // src/graphql/types/copilot-response.type.ts
4543
+ // src/graphql/inputs/generate-copilot-response.input.ts
4346
4544
  function _ts_decorate17(decorators, target, key, desc) {
4347
4545
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4348
4546
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -4359,221 +4557,111 @@ function _ts_metadata17(k, v) {
4359
4557
  return Reflect.metadata(k, v);
4360
4558
  }
4361
4559
  __name(_ts_metadata17, "_ts_metadata");
4362
- var BaseMessageOutput = class {
4363
- id;
4364
- createdAt;
4365
- status;
4560
+ var GenerateCopilotResponseMetadataInput = class {
4561
+ requestType;
4366
4562
  };
4367
- __name(BaseMessageOutput, "BaseMessageOutput");
4368
- _ts_decorate17([
4369
- (0, import_type_graphql18.Field)(() => String),
4370
- _ts_metadata17("design:type", String)
4371
- ], BaseMessageOutput.prototype, "id", void 0);
4372
- _ts_decorate17([
4373
- (0, import_type_graphql18.Field)(() => Date),
4374
- _ts_metadata17("design:type", typeof Date === "undefined" ? Object : Date)
4375
- ], BaseMessageOutput.prototype, "createdAt", void 0);
4563
+ __name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
4376
4564
  _ts_decorate17([
4377
- (0, import_type_graphql18.Field)(() => MessageStatusUnion),
4378
- _ts_metadata17("design:type", Object)
4379
- ], BaseMessageOutput.prototype, "status", void 0);
4380
- BaseMessageOutput = _ts_decorate17([
4381
- (0, import_type_graphql18.InterfaceType)({
4382
- resolveType(value) {
4383
- if (value.hasOwnProperty("content")) {
4384
- return TextMessageOutput;
4385
- } else if (value.hasOwnProperty("name")) {
4386
- return ActionExecutionMessageOutput;
4387
- } else if (value.hasOwnProperty("result")) {
4388
- return ResultMessageOutput;
4389
- } else if (value.hasOwnProperty("state")) {
4390
- return AgentStateMessageOutput;
4391
- } else if (value.name === MetaEventName.LangGraphInterruptEvent) {
4392
- return LangGraphInterruptEvent;
4393
- }
4394
- return void 0;
4395
- }
4396
- })
4397
- ], BaseMessageOutput);
4398
- var TextMessageOutput = class {
4399
- role;
4400
- content;
4401
- parentMessageId;
4565
+ (0, import_type_graphql18.Field)(() => CopilotRequestType, {
4566
+ nullable: true
4567
+ }),
4568
+ _ts_metadata17("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
4569
+ ], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
4570
+ GenerateCopilotResponseMetadataInput = _ts_decorate17([
4571
+ (0, import_type_graphql18.InputType)()
4572
+ ], GenerateCopilotResponseMetadataInput);
4573
+ var GenerateCopilotResponseInput = class {
4574
+ metadata;
4575
+ threadId;
4576
+ runId;
4577
+ messages;
4578
+ frontend;
4579
+ cloud;
4580
+ forwardedParameters;
4581
+ agentSession;
4582
+ agentState;
4583
+ agentStates;
4584
+ extensions;
4585
+ metaEvents;
4402
4586
  };
4403
- __name(TextMessageOutput, "TextMessageOutput");
4404
- _ts_decorate17([
4405
- (0, import_type_graphql18.Field)(() => MessageRole),
4406
- _ts_metadata17("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4407
- ], TextMessageOutput.prototype, "role", void 0);
4587
+ __name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
4408
4588
  _ts_decorate17([
4409
- (0, import_type_graphql18.Field)(() => [
4410
- String
4411
- ]),
4412
- _ts_metadata17("design:type", Array)
4413
- ], TextMessageOutput.prototype, "content", void 0);
4589
+ (0, import_type_graphql18.Field)(() => GenerateCopilotResponseMetadataInput, {
4590
+ nullable: false
4591
+ }),
4592
+ _ts_metadata17("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
4593
+ ], GenerateCopilotResponseInput.prototype, "metadata", void 0);
4414
4594
  _ts_decorate17([
4415
4595
  (0, import_type_graphql18.Field)(() => String, {
4416
4596
  nullable: true
4417
4597
  }),
4418
4598
  _ts_metadata17("design:type", String)
4419
- ], TextMessageOutput.prototype, "parentMessageId", void 0);
4420
- TextMessageOutput = _ts_decorate17([
4421
- (0, import_type_graphql18.ObjectType)({
4422
- implements: BaseMessageOutput
4423
- })
4424
- ], TextMessageOutput);
4425
- var ActionExecutionMessageOutput = class {
4426
- name;
4427
- scope;
4428
- arguments;
4429
- parentMessageId;
4430
- };
4431
- __name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
4432
- _ts_decorate17([
4433
- (0, import_type_graphql18.Field)(() => String),
4434
- _ts_metadata17("design:type", String)
4435
- ], ActionExecutionMessageOutput.prototype, "name", void 0);
4599
+ ], GenerateCopilotResponseInput.prototype, "threadId", void 0);
4436
4600
  _ts_decorate17([
4437
4601
  (0, import_type_graphql18.Field)(() => String, {
4438
- nullable: true,
4439
- deprecationReason: "This field will be removed in a future version"
4602
+ nullable: true
4440
4603
  }),
4441
4604
  _ts_metadata17("design:type", String)
4442
- ], ActionExecutionMessageOutput.prototype, "scope", void 0);
4605
+ ], GenerateCopilotResponseInput.prototype, "runId", void 0);
4443
4606
  _ts_decorate17([
4444
4607
  (0, import_type_graphql18.Field)(() => [
4445
- String
4608
+ MessageInput
4446
4609
  ]),
4447
4610
  _ts_metadata17("design:type", Array)
4448
- ], ActionExecutionMessageOutput.prototype, "arguments", void 0);
4611
+ ], GenerateCopilotResponseInput.prototype, "messages", void 0);
4449
4612
  _ts_decorate17([
4450
- (0, import_type_graphql18.Field)(() => String, {
4613
+ (0, import_type_graphql18.Field)(() => FrontendInput),
4614
+ _ts_metadata17("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
4615
+ ], GenerateCopilotResponseInput.prototype, "frontend", void 0);
4616
+ _ts_decorate17([
4617
+ (0, import_type_graphql18.Field)(() => CloudInput, {
4451
4618
  nullable: true
4452
4619
  }),
4453
- _ts_metadata17("design:type", String)
4454
- ], ActionExecutionMessageOutput.prototype, "parentMessageId", void 0);
4455
- ActionExecutionMessageOutput = _ts_decorate17([
4456
- (0, import_type_graphql18.ObjectType)({
4457
- implements: BaseMessageOutput
4458
- })
4459
- ], ActionExecutionMessageOutput);
4460
- var ResultMessageOutput = class {
4461
- actionExecutionId;
4462
- actionName;
4463
- result;
4464
- };
4465
- __name(ResultMessageOutput, "ResultMessageOutput");
4466
- _ts_decorate17([
4467
- (0, import_type_graphql18.Field)(() => String),
4468
- _ts_metadata17("design:type", String)
4469
- ], ResultMessageOutput.prototype, "actionExecutionId", void 0);
4470
- _ts_decorate17([
4471
- (0, import_type_graphql18.Field)(() => String),
4472
- _ts_metadata17("design:type", String)
4473
- ], ResultMessageOutput.prototype, "actionName", void 0);
4474
- _ts_decorate17([
4475
- (0, import_type_graphql18.Field)(() => String),
4476
- _ts_metadata17("design:type", String)
4477
- ], ResultMessageOutput.prototype, "result", void 0);
4478
- ResultMessageOutput = _ts_decorate17([
4479
- (0, import_type_graphql18.ObjectType)({
4480
- implements: BaseMessageOutput
4481
- })
4482
- ], ResultMessageOutput);
4483
- var AgentStateMessageOutput = class {
4484
- threadId;
4485
- agentName;
4486
- nodeName;
4487
- runId;
4488
- active;
4489
- role;
4490
- state;
4491
- running;
4492
- };
4493
- __name(AgentStateMessageOutput, "AgentStateMessageOutput");
4494
- _ts_decorate17([
4495
- (0, import_type_graphql18.Field)(() => String),
4496
- _ts_metadata17("design:type", String)
4497
- ], AgentStateMessageOutput.prototype, "threadId", void 0);
4498
- _ts_decorate17([
4499
- (0, import_type_graphql18.Field)(() => String),
4500
- _ts_metadata17("design:type", String)
4501
- ], AgentStateMessageOutput.prototype, "agentName", void 0);
4502
- _ts_decorate17([
4503
- (0, import_type_graphql18.Field)(() => String),
4504
- _ts_metadata17("design:type", String)
4505
- ], AgentStateMessageOutput.prototype, "nodeName", void 0);
4506
- _ts_decorate17([
4507
- (0, import_type_graphql18.Field)(() => String),
4508
- _ts_metadata17("design:type", String)
4509
- ], AgentStateMessageOutput.prototype, "runId", void 0);
4510
- _ts_decorate17([
4511
- (0, import_type_graphql18.Field)(() => Boolean),
4512
- _ts_metadata17("design:type", Boolean)
4513
- ], AgentStateMessageOutput.prototype, "active", void 0);
4514
- _ts_decorate17([
4515
- (0, import_type_graphql18.Field)(() => MessageRole),
4516
- _ts_metadata17("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4517
- ], AgentStateMessageOutput.prototype, "role", void 0);
4518
- _ts_decorate17([
4519
- (0, import_type_graphql18.Field)(() => String),
4520
- _ts_metadata17("design:type", String)
4521
- ], AgentStateMessageOutput.prototype, "state", void 0);
4522
- _ts_decorate17([
4523
- (0, import_type_graphql18.Field)(() => Boolean),
4524
- _ts_metadata17("design:type", Boolean)
4525
- ], AgentStateMessageOutput.prototype, "running", void 0);
4526
- AgentStateMessageOutput = _ts_decorate17([
4527
- (0, import_type_graphql18.ObjectType)({
4528
- implements: BaseMessageOutput
4529
- })
4530
- ], AgentStateMessageOutput);
4531
- var CopilotResponse = class {
4532
- threadId;
4533
- status;
4534
- runId;
4535
- messages;
4536
- extensions;
4537
- metaEvents;
4538
- };
4539
- __name(CopilotResponse, "CopilotResponse");
4620
+ _ts_metadata17("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
4621
+ ], GenerateCopilotResponseInput.prototype, "cloud", void 0);
4540
4622
  _ts_decorate17([
4541
- (0, import_type_graphql18.Field)(() => String),
4542
- _ts_metadata17("design:type", String)
4543
- ], CopilotResponse.prototype, "threadId", void 0);
4623
+ (0, import_type_graphql18.Field)(() => ForwardedParametersInput, {
4624
+ nullable: true
4625
+ }),
4626
+ _ts_metadata17("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
4627
+ ], GenerateCopilotResponseInput.prototype, "forwardedParameters", void 0);
4544
4628
  _ts_decorate17([
4545
- (0, import_type_graphql18.Field)(() => ResponseStatusUnion),
4546
- _ts_metadata17("design:type", Object)
4547
- ], CopilotResponse.prototype, "status", void 0);
4629
+ (0, import_type_graphql18.Field)(() => AgentSessionInput, {
4630
+ nullable: true
4631
+ }),
4632
+ _ts_metadata17("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
4633
+ ], GenerateCopilotResponseInput.prototype, "agentSession", void 0);
4548
4634
  _ts_decorate17([
4549
- (0, import_type_graphql18.Field)({
4635
+ (0, import_type_graphql18.Field)(() => AgentStateInput, {
4550
4636
  nullable: true
4551
4637
  }),
4552
- _ts_metadata17("design:type", String)
4553
- ], CopilotResponse.prototype, "runId", void 0);
4638
+ _ts_metadata17("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
4639
+ ], GenerateCopilotResponseInput.prototype, "agentState", void 0);
4554
4640
  _ts_decorate17([
4555
4641
  (0, import_type_graphql18.Field)(() => [
4556
- BaseMessageOutput
4557
- ]),
4642
+ AgentStateInput
4643
+ ], {
4644
+ nullable: true
4645
+ }),
4558
4646
  _ts_metadata17("design:type", Array)
4559
- ], CopilotResponse.prototype, "messages", void 0);
4647
+ ], GenerateCopilotResponseInput.prototype, "agentStates", void 0);
4560
4648
  _ts_decorate17([
4561
- (0, import_type_graphql18.Field)(() => ExtensionsResponse, {
4649
+ (0, import_type_graphql18.Field)(() => ExtensionsInput, {
4562
4650
  nullable: true
4563
4651
  }),
4564
- _ts_metadata17("design:type", typeof ExtensionsResponse === "undefined" ? Object : ExtensionsResponse)
4565
- ], CopilotResponse.prototype, "extensions", void 0);
4652
+ _ts_metadata17("design:type", typeof ExtensionsInput === "undefined" ? Object : ExtensionsInput)
4653
+ ], GenerateCopilotResponseInput.prototype, "extensions", void 0);
4566
4654
  _ts_decorate17([
4567
4655
  (0, import_type_graphql18.Field)(() => [
4568
- BaseMetaEvent
4656
+ MetaEventInput
4569
4657
  ], {
4570
4658
  nullable: true
4571
4659
  }),
4572
4660
  _ts_metadata17("design:type", Array)
4573
- ], CopilotResponse.prototype, "metaEvents", void 0);
4574
- CopilotResponse = _ts_decorate17([
4575
- (0, import_type_graphql18.ObjectType)()
4576
- ], CopilotResponse);
4661
+ ], GenerateCopilotResponseInput.prototype, "metaEvents", void 0);
4662
+ GenerateCopilotResponseInput = _ts_decorate17([
4663
+ (0, import_type_graphql18.InputType)()
4664
+ ], GenerateCopilotResponseInput);
4577
4665
 
4578
4666
  // src/graphql/resolvers/copilot.resolver.ts
4579
4667
  var import_graphql_yoga = require("graphql-yoga");
@@ -4851,6 +4939,40 @@ var CopilotResolver = class {
4851
4939
  value: event.value
4852
4940
  }));
4853
4941
  break;
4942
+ case RuntimeMetaEventName.CopilotKitLangGraphInterruptEvent:
4943
+ push((0, import_class_transformer3.plainToInstance)(CopilotKitLangGraphInterruptEvent, {
4944
+ type: event.type,
4945
+ name: event.name,
4946
+ data: {
4947
+ value: typeof event.data.value === "string" ? event.data.value : JSON.stringify(event.data.value),
4948
+ messages: event.data.messages.map((message) => {
4949
+ if (message.type === "TextMessage" || "content" in message && "role" in message) {
4950
+ return (0, import_class_transformer3.plainToInstance)(TextMessage, {
4951
+ id: message.id,
4952
+ createdAt: /* @__PURE__ */ new Date(),
4953
+ content: [
4954
+ message.content
4955
+ ],
4956
+ role: message.role,
4957
+ status: new SuccessMessageStatus()
4958
+ });
4959
+ }
4960
+ if ("arguments" in message) {
4961
+ return (0, import_class_transformer3.plainToInstance)(ActionExecutionMessage, {
4962
+ name: message.name,
4963
+ id: message.id,
4964
+ arguments: [
4965
+ JSON.stringify(message.arguments)
4966
+ ],
4967
+ createdAt: /* @__PURE__ */ new Date(),
4968
+ status: new SuccessMessageStatus()
4969
+ });
4970
+ }
4971
+ throw new Error("Unknown message in metaEvents copilot resolver");
4972
+ })
4973
+ }
4974
+ }));
4975
+ break;
4854
4976
  }
4855
4977
  },
4856
4978
  error: (err) => {