@copilotkit/runtime 1.2.0 → 1.2.2-feat-runtime-remote-actions.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/__snapshots__/schema/schema.graphql +41 -0
  3. package/dist/{chunk-HCUZC4GO.mjs → chunk-2N45GS3P.mjs} +2 -2
  4. package/dist/{chunk-URMISMK2.mjs → chunk-73NMP3DI.mjs} +2 -2
  5. package/dist/{chunk-736EEICU.mjs → chunk-BJ2LVHWA.mjs} +3 -3
  6. package/dist/{chunk-ZHFBLKC3.mjs → chunk-T6O5FSTK.mjs} +2 -2
  7. package/dist/{chunk-GEIBJJQ4.mjs → chunk-TBZGOJJX.mjs} +14 -2
  8. package/dist/chunk-TBZGOJJX.mjs.map +1 -0
  9. package/dist/{chunk-3MYGPMKL.mjs → chunk-X5QBBMCJ.mjs} +2 -2
  10. package/dist/{chunk-3TQLJ3YL.mjs → chunk-XROLDARH.mjs} +786 -158
  11. package/dist/chunk-XROLDARH.mjs.map +1 -0
  12. package/dist/chunk-ZNZGATLW.mjs +260 -0
  13. package/dist/chunk-ZNZGATLW.mjs.map +1 -0
  14. package/dist/{shared-c5362338.d.ts → copilot-runtime-d427e991.d.ts} +65 -38
  15. package/dist/graphql/types/converted/index.d.ts +1 -1
  16. package/dist/graphql/types/converted/index.js +13 -0
  17. package/dist/graphql/types/converted/index.js.map +1 -1
  18. package/dist/graphql/types/converted/index.mjs +3 -1
  19. package/dist/{index-aa091e3c.d.ts → index-0476e4f7.d.ts} +24 -2
  20. package/dist/{index-13aa818e.d.ts → index-079752b9.d.ts} +1 -1
  21. package/dist/index.d.ts +7 -7
  22. package/dist/index.js +982 -245
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +8 -8
  25. package/dist/{langserve-a54438c6.d.ts → langserve-d6073a3b.d.ts} +24 -11
  26. package/dist/lib/index.d.ts +7 -7
  27. package/dist/lib/index.js +982 -245
  28. package/dist/lib/index.js.map +1 -1
  29. package/dist/lib/index.mjs +8 -8
  30. package/dist/lib/integrations/index.d.ts +6 -6
  31. package/dist/lib/integrations/index.js +437 -182
  32. package/dist/lib/integrations/index.js.map +1 -1
  33. package/dist/lib/integrations/index.mjs +6 -6
  34. package/dist/lib/integrations/nest/index.d.ts +5 -5
  35. package/dist/lib/integrations/nest/index.js +437 -182
  36. package/dist/lib/integrations/nest/index.js.map +1 -1
  37. package/dist/lib/integrations/nest/index.mjs +4 -4
  38. package/dist/lib/integrations/node-express/index.d.ts +5 -5
  39. package/dist/lib/integrations/node-express/index.js +437 -182
  40. package/dist/lib/integrations/node-express/index.js.map +1 -1
  41. package/dist/lib/integrations/node-express/index.mjs +4 -4
  42. package/dist/lib/integrations/node-http/index.d.ts +5 -5
  43. package/dist/lib/integrations/node-http/index.js +437 -182
  44. package/dist/lib/integrations/node-http/index.js.map +1 -1
  45. package/dist/lib/integrations/node-http/index.mjs +3 -3
  46. package/dist/service-adapters/index.d.ts +3 -3
  47. package/dist/service-adapters/index.js.map +1 -1
  48. package/dist/service-adapters/index.mjs +3 -3
  49. package/package.json +7 -5
  50. package/src/agents/langgraph/event-source.ts +222 -0
  51. package/src/agents/langgraph/events.ts +309 -0
  52. package/src/graphql/inputs/agent-session.input.ts +13 -0
  53. package/src/graphql/inputs/agent-state.input.ts +10 -0
  54. package/src/graphql/inputs/generate-copilot-response.input.ts +11 -0
  55. package/src/graphql/inputs/message.input.ts +30 -0
  56. package/src/graphql/resolvers/copilot.resolver.ts +56 -12
  57. package/src/graphql/types/converted/index.ts +15 -0
  58. package/src/graphql/types/copilot-response.type.ts +29 -0
  59. package/src/graphql/types/enums.ts +1 -0
  60. package/src/lib/index.ts +1 -1
  61. package/src/lib/integrations/shared.ts +1 -1
  62. package/src/lib/runtime/copilot-runtime.ts +360 -0
  63. package/src/lib/runtime/remote-actions.ts +241 -0
  64. package/src/service-adapters/conversion.ts +16 -0
  65. package/src/service-adapters/events.ts +101 -19
  66. package/dist/chunk-3TQLJ3YL.mjs.map +0 -1
  67. package/dist/chunk-GEIBJJQ4.mjs.map +0 -1
  68. package/dist/chunk-MHLJQ2RF.mjs +0 -158
  69. package/dist/chunk-MHLJQ2RF.mjs.map +0 -1
  70. package/src/lib/copilot-runtime.ts +0 -231
  71. /package/dist/{chunk-HCUZC4GO.mjs.map → chunk-2N45GS3P.mjs.map} +0 -0
  72. /package/dist/{chunk-URMISMK2.mjs.map → chunk-73NMP3DI.mjs.map} +0 -0
  73. /package/dist/{chunk-736EEICU.mjs.map → chunk-BJ2LVHWA.mjs.map} +0 -0
  74. /package/dist/{chunk-ZHFBLKC3.mjs.map → chunk-T6O5FSTK.mjs.map} +0 -0
  75. /package/dist/{chunk-3MYGPMKL.mjs.map → chunk-X5QBBMCJ.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -12,11 +12,11 @@ var __export = (target, all) => {
12
12
  for (var name in all)
13
13
  __defProp(target, name, { get: all[name], enumerable: true });
14
14
  };
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
15
+ var __copyProps = (to, from3, except, desc) => {
16
+ if (from3 && typeof from3 === "object" || typeof from3 === "function") {
17
+ for (let key of __getOwnPropNames(from3))
18
18
  if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ __defProp(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc(from3, key)) || desc.enumerable });
20
20
  }
21
21
  return to;
22
22
  };
@@ -44,7 +44,7 @@ var require_package = __commonJS({
44
44
  publishConfig: {
45
45
  access: "public"
46
46
  },
47
- version: "1.2.0",
47
+ version: "1.2.2-feat-runtime-remote-actions.0",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -59,7 +59,9 @@ var require_package = __commonJS({
59
59
  test: "jest --passWithNoTests",
60
60
  "check-types": "tsc --noEmit",
61
61
  clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next && rm -rf __snapshots__",
62
- "generate-graphql-schema": "rm -rf __snapshots__ && ts-node ./scripts/generate-gql-schema.ts"
62
+ "generate-graphql-schema": "rm -rf __snapshots__ && ts-node ./scripts/generate-gql-schema.ts",
63
+ "link:global": "pnpm link --global",
64
+ "unlink:global": "pnpm unlink --global"
63
65
  },
64
66
  devDependencies: {
65
67
  "@swc/core": "1.5.28",
@@ -142,8 +144,8 @@ __export(src_exports, {
142
144
  module.exports = __toCommonJS(src_exports);
143
145
  var import_reflect_metadata = require("reflect-metadata");
144
146
 
145
- // src/lib/copilot-runtime.ts
146
- var import_shared7 = require("@copilotkit/shared");
147
+ // src/lib/runtime/copilot-runtime.ts
148
+ var import_shared8 = require("@copilotkit/shared");
147
149
 
148
150
  // src/service-adapters/openai/openai-adapter.ts
149
151
  var import_openai = __toESM(require("openai"));
@@ -201,6 +203,17 @@ var ResultMessage = class extends BaseMessage {
201
203
  result;
202
204
  };
203
205
  __name(ResultMessage, "ResultMessage");
206
+ var AgentStateMessage = class extends BaseMessage {
207
+ threadId;
208
+ agentName;
209
+ nodeName;
210
+ runId;
211
+ active;
212
+ role;
213
+ state;
214
+ running;
215
+ };
216
+ __name(AgentStateMessage, "AgentStateMessage");
204
217
 
205
218
  // src/service-adapters/openai/utils.ts
206
219
  function limitMessagesToTokenCount(messages, tools, model, maxTokens) {
@@ -1270,7 +1283,366 @@ var GroqAdapter = class {
1270
1283
  __name(GroqAdapter, "GroqAdapter");
1271
1284
 
1272
1285
  // src/service-adapters/events.ts
1286
+ var import_rxjs2 = require("rxjs");
1287
+
1288
+ // src/lib/telemetry-client.ts
1289
+ var import_shared7 = require("@copilotkit/shared");
1290
+ var packageJson = require_package();
1291
+ var telemetryClient = new import_shared7.TelemetryClient({
1292
+ packageName: packageJson.name,
1293
+ packageVersion: packageJson.version
1294
+ });
1295
+ var telemetry_client_default = telemetryClient;
1296
+
1297
+ // src/agents/langgraph/event-source.ts
1273
1298
  var import_rxjs = require("rxjs");
1299
+
1300
+ // src/agents/langgraph/events.ts
1301
+ var LangGraphEventTypes;
1302
+ (function(LangGraphEventTypes2) {
1303
+ LangGraphEventTypes2["OnChainStart"] = "on_chain_start";
1304
+ LangGraphEventTypes2["OnChainStream"] = "on_chain_stream";
1305
+ LangGraphEventTypes2["OnChainEnd"] = "on_chain_end";
1306
+ LangGraphEventTypes2["OnChatModelStart"] = "on_chat_model_start";
1307
+ LangGraphEventTypes2["OnChatModelStream"] = "on_chat_model_stream";
1308
+ LangGraphEventTypes2["OnChatModelEnd"] = "on_chat_model_end";
1309
+ LangGraphEventTypes2["OnToolStart"] = "on_tool_start";
1310
+ LangGraphEventTypes2["OnToolEnd"] = "on_tool_end";
1311
+ LangGraphEventTypes2["OnCopilotKitStateSync"] = "on_copilotkit_state_sync";
1312
+ })(LangGraphEventTypes || (LangGraphEventTypes = {}));
1313
+
1314
+ // src/agents/langgraph/event-source.ts
1315
+ var RemoteLangGraphEventSource = class {
1316
+ eventStream$ = new import_rxjs.ReplaySubject();
1317
+ async streamResponse(response) {
1318
+ const reader = response.body.getReader();
1319
+ const decoder = new TextDecoder();
1320
+ let buffer = [];
1321
+ const eventStream$ = this.eventStream$;
1322
+ function flushBuffer() {
1323
+ const currentBuffer = buffer.join("");
1324
+ if (currentBuffer.trim().length === 0) {
1325
+ return;
1326
+ }
1327
+ const parts = currentBuffer.split("\n");
1328
+ if (parts.length === 0) {
1329
+ return;
1330
+ }
1331
+ const lastPartIsComplete = currentBuffer.endsWith("\n");
1332
+ buffer = [];
1333
+ if (!lastPartIsComplete) {
1334
+ buffer.push(parts.pop());
1335
+ }
1336
+ parts.map((part) => part.trim()).filter((part) => part != "").forEach((part) => {
1337
+ eventStream$.next(JSON.parse(part));
1338
+ });
1339
+ }
1340
+ __name(flushBuffer, "flushBuffer");
1341
+ while (true) {
1342
+ const { done, value } = await reader.read();
1343
+ if (!done) {
1344
+ buffer.push(decoder.decode(value, {
1345
+ stream: true
1346
+ }));
1347
+ }
1348
+ flushBuffer();
1349
+ if (done) {
1350
+ break;
1351
+ }
1352
+ }
1353
+ eventStream$.complete();
1354
+ }
1355
+ processLangGraphEvents() {
1356
+ return this.eventStream$.pipe((0, import_rxjs.scan)((acc, event) => {
1357
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1358
+ if (event.event === LangGraphEventTypes.OnChatModelStream) {
1359
+ if ((_c = (_b = (_a = event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.kwargs) == null ? void 0 : _c.tool_call_chunks) {
1360
+ acc.prevToolCallId = acc.toolCallId;
1361
+ acc.toolCallId = (_d = event.data.chunk.kwargs) == null ? void 0 : _d.id;
1362
+ if ((_e = event.data.chunk.kwargs.tool_call_chunks[0]) == null ? void 0 : _e.name) {
1363
+ acc.toolCallName = event.data.chunk.kwargs.tool_call_chunks[0].name;
1364
+ }
1365
+ }
1366
+ acc.prevMessageId = acc.messageId;
1367
+ acc.messageId = (_h = (_g = (_f = event.data) == null ? void 0 : _f.chunk) == null ? void 0 : _g.kwargs) == null ? void 0 : _h.id;
1368
+ } else {
1369
+ acc.prevToolCallId = acc.toolCallId;
1370
+ acc.toolCallId = null;
1371
+ acc.prevMessageId = acc.messageId;
1372
+ acc.messageId = null;
1373
+ acc.toolCallName = null;
1374
+ }
1375
+ acc.event = event;
1376
+ return acc;
1377
+ }, {
1378
+ event: null,
1379
+ toolCallId: null,
1380
+ prevToolCallId: null,
1381
+ messageId: null,
1382
+ toolCallName: null,
1383
+ prevMessageId: null
1384
+ }), (0, import_rxjs.mergeMap)((eventWithState) => {
1385
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1386
+ const events = [];
1387
+ let shouldEmitMessages = false;
1388
+ let shouldEmitToolCalls = false;
1389
+ if (eventWithState.event.event == LangGraphEventTypes.OnChatModelStream) {
1390
+ if ((_a = eventWithState.event.tags) == null ? void 0 : _a.includes("copilotkit:emit-tool-calls")) {
1391
+ shouldEmitToolCalls = true;
1392
+ }
1393
+ if ((_b = eventWithState.event.tags) == null ? void 0 : _b.includes("copilotkit:emit-messages")) {
1394
+ shouldEmitMessages = true;
1395
+ }
1396
+ }
1397
+ if (eventWithState.prevToolCallId !== null && eventWithState.prevToolCallId !== eventWithState.toolCallId && shouldEmitToolCalls) {
1398
+ events.push({
1399
+ type: RuntimeEventTypes.ActionExecutionEnd
1400
+ });
1401
+ }
1402
+ if (eventWithState.prevMessageId !== null && eventWithState.prevMessageId !== eventWithState.messageId && shouldEmitMessages) {
1403
+ events.push({
1404
+ type: RuntimeEventTypes.TextMessageEnd
1405
+ });
1406
+ }
1407
+ switch (eventWithState.event.event) {
1408
+ case LangGraphEventTypes.OnCopilotKitStateSync:
1409
+ events.push({
1410
+ type: RuntimeEventTypes.AgentStateMessage,
1411
+ threadId: eventWithState.event.thread_id,
1412
+ role: eventWithState.event.role,
1413
+ agentName: eventWithState.event.agent_name,
1414
+ nodeName: eventWithState.event.node_name,
1415
+ runId: eventWithState.event.run_id,
1416
+ active: eventWithState.event.active,
1417
+ state: JSON.stringify(eventWithState.event.state),
1418
+ running: eventWithState.event.running
1419
+ });
1420
+ break;
1421
+ case LangGraphEventTypes.OnToolEnd:
1422
+ break;
1423
+ case LangGraphEventTypes.OnChatModelStream:
1424
+ if (eventWithState.toolCallId !== null && eventWithState.prevToolCallId !== eventWithState.toolCallId) {
1425
+ if (shouldEmitToolCalls) {
1426
+ events.push({
1427
+ type: RuntimeEventTypes.ActionExecutionStart,
1428
+ actionExecutionId: eventWithState.toolCallId,
1429
+ actionName: eventWithState.toolCallName,
1430
+ scope: "client"
1431
+ });
1432
+ }
1433
+ } else if (eventWithState.messageId !== null && eventWithState.prevMessageId !== eventWithState.messageId) {
1434
+ if (shouldEmitMessages) {
1435
+ events.push({
1436
+ type: RuntimeEventTypes.TextMessageStart,
1437
+ messageId: eventWithState.messageId
1438
+ });
1439
+ }
1440
+ }
1441
+ const args = (_g = (_f = (_e = (_d = (_c = eventWithState.event.data) == null ? void 0 : _c.chunk) == null ? void 0 : _d.kwargs) == null ? void 0 : _e.tool_call_chunks) == null ? void 0 : _f[0]) == null ? void 0 : _g.args;
1442
+ const content = (_j = (_i = (_h = eventWithState.event.data) == null ? void 0 : _h.chunk) == null ? void 0 : _i.kwargs) == null ? void 0 : _j.content;
1443
+ if (args) {
1444
+ if (shouldEmitToolCalls) {
1445
+ events.push({
1446
+ type: RuntimeEventTypes.ActionExecutionArgs,
1447
+ args
1448
+ });
1449
+ }
1450
+ } else if (eventWithState.messageId !== null && content) {
1451
+ if (shouldEmitMessages) {
1452
+ events.push({
1453
+ type: RuntimeEventTypes.TextMessageContent,
1454
+ content
1455
+ });
1456
+ }
1457
+ }
1458
+ break;
1459
+ }
1460
+ return events;
1461
+ }));
1462
+ }
1463
+ };
1464
+ __name(RemoteLangGraphEventSource, "RemoteLangGraphEventSource");
1465
+
1466
+ // src/lib/runtime/remote-actions.ts
1467
+ function isLangGraphAgentAction(action) {
1468
+ if (!action) {
1469
+ return false;
1470
+ }
1471
+ return typeof action.langGraphAgentHandler === "function";
1472
+ }
1473
+ __name(isLangGraphAgentAction, "isLangGraphAgentAction");
1474
+ function createHeaders(onBeforeRequest, graphqlContext) {
1475
+ const headers = {
1476
+ "Content-Type": "application/json"
1477
+ };
1478
+ if (onBeforeRequest) {
1479
+ const { headers: additionalHeaders } = onBeforeRequest({
1480
+ ctx: graphqlContext
1481
+ });
1482
+ if (additionalHeaders) {
1483
+ Object.assign(headers, additionalHeaders);
1484
+ }
1485
+ }
1486
+ return headers;
1487
+ }
1488
+ __name(createHeaders, "createHeaders");
1489
+ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: logger2 }) {
1490
+ logger2.debug({
1491
+ url
1492
+ }, "Fetching actions from url");
1493
+ const headers = createHeaders(onBeforeRequest, graphqlContext);
1494
+ const response = await fetch(`${url}/info`, {
1495
+ method: "POST",
1496
+ headers,
1497
+ body: JSON.stringify({
1498
+ properties: graphqlContext.properties
1499
+ })
1500
+ });
1501
+ if (!response.ok) {
1502
+ logger2.error({
1503
+ url,
1504
+ status: response.status,
1505
+ body: await response.text()
1506
+ }, "Failed to fetch actions from url");
1507
+ return [];
1508
+ }
1509
+ const json = await response.json();
1510
+ logger2.debug({
1511
+ json
1512
+ }, "Fetched actions from url");
1513
+ return json;
1514
+ }
1515
+ __name(fetchRemoteInfo, "fetchRemoteInfo");
1516
+ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, logger: logger2, messages, agentStates }) {
1517
+ const actions = json["actions"].map((action) => ({
1518
+ name: action.name,
1519
+ description: action.description,
1520
+ parameters: action.parameters,
1521
+ handler: async (args) => {
1522
+ logger2.debug({
1523
+ actionName: action.name,
1524
+ args
1525
+ }, "Executing remote action");
1526
+ const headers = createHeaders(onBeforeRequest, graphqlContext);
1527
+ telemetry_client_default.capture("oss.runtime.remote_action_executed", {});
1528
+ const response = await fetch(`${url}/actions/execute`, {
1529
+ method: "POST",
1530
+ headers,
1531
+ body: JSON.stringify({
1532
+ name: action.name,
1533
+ arguments: args,
1534
+ properties: graphqlContext.properties
1535
+ })
1536
+ });
1537
+ if (!response.ok) {
1538
+ logger2.error({
1539
+ url,
1540
+ status: response.status,
1541
+ body: await response.text()
1542
+ }, "Failed to execute remote action");
1543
+ return "Failed to execute remote action";
1544
+ }
1545
+ const requestResult = await response.json();
1546
+ const result = requestResult["result"];
1547
+ logger2.debug({
1548
+ actionName: action.name,
1549
+ result
1550
+ }, "Executed remote action");
1551
+ return result;
1552
+ }
1553
+ }));
1554
+ const agents = json["agents"].map((agent) => ({
1555
+ name: agent.name,
1556
+ description: agent.description,
1557
+ parameters: [],
1558
+ handler: async (_args) => {
1559
+ },
1560
+ langGraphAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName }) => {
1561
+ var _a;
1562
+ logger2.debug({
1563
+ actionName: agent.name
1564
+ }, "Executing remote agent");
1565
+ const headers = createHeaders(onBeforeRequest, graphqlContext);
1566
+ telemetry_client_default.capture("oss.runtime.remote_action_executed", {});
1567
+ let state = {};
1568
+ if (agentStates) {
1569
+ const jsonState = (_a = agentStates.find((state2) => state2.agentName === name)) == null ? void 0 : _a.state;
1570
+ if (jsonState) {
1571
+ state = JSON.parse(jsonState);
1572
+ }
1573
+ }
1574
+ const response = await fetch(`${url}/agents/execute`, {
1575
+ method: "POST",
1576
+ headers,
1577
+ body: JSON.stringify({
1578
+ name,
1579
+ threadId,
1580
+ nodeName,
1581
+ messages,
1582
+ state,
1583
+ properties: graphqlContext.properties,
1584
+ actions: actionInputsWithoutAgents.map((action) => ({
1585
+ name: action.name,
1586
+ description: action.description,
1587
+ parameters: JSON.parse(action.jsonSchema)
1588
+ }))
1589
+ })
1590
+ });
1591
+ if (!response.ok) {
1592
+ logger2.error({
1593
+ url,
1594
+ status: response.status,
1595
+ body: await response.text()
1596
+ }, "Failed to execute remote agent");
1597
+ throw new Error("Failed to execute remote agent");
1598
+ }
1599
+ const eventSource = new RemoteLangGraphEventSource();
1600
+ eventSource.streamResponse(response);
1601
+ return eventSource.processLangGraphEvents();
1602
+ }
1603
+ }));
1604
+ return [
1605
+ ...actions,
1606
+ ...agents
1607
+ ];
1608
+ }
1609
+ __name(constructRemoteActions, "constructRemoteActions");
1610
+ async function setupRemoteActions({ remoteActionDefinitions, graphqlContext, messages, agentStates }) {
1611
+ const logger2 = graphqlContext.logger.child({
1612
+ component: "remote-actions.fetchRemoteActions"
1613
+ });
1614
+ logger2.debug({
1615
+ remoteActionDefinitions
1616
+ }, "Fetching remote actions");
1617
+ const filtered = remoteActionDefinitions.filter((value, index, self) => index === self.findIndex((t) => t.url === value.url));
1618
+ const result = await Promise.all(filtered.map(async (actionDefinition) => {
1619
+ const json = await fetchRemoteInfo({
1620
+ url: actionDefinition.url,
1621
+ onBeforeRequest: actionDefinition.onBeforeRequest,
1622
+ graphqlContext,
1623
+ logger: logger2.child({
1624
+ component: "remote-actions.fetchActionsFromUrl",
1625
+ actionDefinition
1626
+ })
1627
+ });
1628
+ return constructRemoteActions({
1629
+ json,
1630
+ messages,
1631
+ url: actionDefinition.url,
1632
+ onBeforeRequest: actionDefinition.onBeforeRequest,
1633
+ graphqlContext,
1634
+ logger: logger2.child({
1635
+ component: "remote-actions.constructActions",
1636
+ actionDefinition
1637
+ }),
1638
+ agentStates
1639
+ });
1640
+ }));
1641
+ return result.flat();
1642
+ }
1643
+ __name(setupRemoteActions, "setupRemoteActions");
1644
+
1645
+ // src/service-adapters/events.ts
1274
1646
  var RuntimeEventTypes;
1275
1647
  (function(RuntimeEventTypes2) {
1276
1648
  RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
@@ -1280,8 +1652,9 @@ var RuntimeEventTypes;
1280
1652
  RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
1281
1653
  RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
1282
1654
  RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
1655
+ RuntimeEventTypes2["AgentStateMessage"] = "AgentStateMessage";
1283
1656
  })(RuntimeEventTypes || (RuntimeEventTypes = {}));
1284
- var RuntimeEventSubject = class extends import_rxjs.ReplaySubject {
1657
+ var RuntimeEventSubject = class extends import_rxjs2.ReplaySubject {
1285
1658
  constructor() {
1286
1659
  super();
1287
1660
  }
@@ -1338,6 +1711,19 @@ var RuntimeEventSubject = class extends import_rxjs.ReplaySubject {
1338
1711
  result
1339
1712
  });
1340
1713
  }
1714
+ sendAgentStateMessage(threadId, agentName, nodeName, runId, active, role, state, running) {
1715
+ this.next({
1716
+ type: "AgentStateMessage",
1717
+ threadId,
1718
+ agentName,
1719
+ nodeName,
1720
+ runId,
1721
+ active,
1722
+ role,
1723
+ state,
1724
+ running
1725
+ });
1726
+ }
1341
1727
  };
1342
1728
  __name(RuntimeEventSubject, "RuntimeEventSubject");
1343
1729
  var RuntimeEventSource = class {
@@ -1346,26 +1732,31 @@ var RuntimeEventSource = class {
1346
1732
  async stream(callback) {
1347
1733
  this.callback = callback;
1348
1734
  }
1349
- process({ serversideActions, guardrailsResult$ }) {
1735
+ processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents }) {
1350
1736
  this.callback(this.eventStream$).catch((error) => {
1351
1737
  console.error("Error in event source callback", error);
1352
1738
  });
1353
1739
  return this.eventStream$.pipe(
1354
1740
  // mark tools for server side execution
1355
- (0, import_rxjs.map)((event) => {
1741
+ (0, import_rxjs2.map)((event) => {
1356
1742
  if (event.type === "ActionExecutionStart") {
1357
- event.scope = serversideActions.find((action) => action.name === event.actionName) ? "server" : "client";
1743
+ if (event.scope !== "passThrough") {
1744
+ event.scope = serverSideActions.find((action) => action.name === event.actionName) ? "server" : "client";
1745
+ }
1358
1746
  }
1359
1747
  return event;
1360
1748
  }),
1361
1749
  // track state
1362
- (0, import_rxjs.scan)((acc, event) => {
1750
+ (0, import_rxjs2.scan)((acc, event) => {
1751
+ acc = {
1752
+ ...acc
1753
+ };
1363
1754
  if (event.type === "ActionExecutionStart") {
1364
1755
  acc.callActionServerSide = event.scope === "server";
1365
1756
  acc.args = "";
1366
1757
  acc.actionExecutionId = event.actionExecutionId;
1367
1758
  if (acc.callActionServerSide) {
1368
- acc.action = serversideActions.find((action) => action.name === event.actionName);
1759
+ acc.action = serverSideActions.find((action) => action.name === event.actionName);
1369
1760
  }
1370
1761
  } else if (event.type === "ActionExecutionArgs") {
1371
1762
  acc.args += event.args;
@@ -1379,24 +1770,26 @@ var RuntimeEventSource = class {
1379
1770
  actionExecutionId: null,
1380
1771
  action: null
1381
1772
  }),
1382
- (0, import_rxjs.concatMap)((eventWithState) => {
1773
+ (0, import_rxjs2.concatMap)((eventWithState) => {
1383
1774
  if (eventWithState.event.type === "ActionExecutionEnd" && eventWithState.callActionServerSide) {
1384
1775
  const toolCallEventStream$ = new RuntimeEventSubject();
1385
- executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionId).catch((error) => {
1776
+ executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionId, actionInputsWithoutAgents).catch((error) => {
1386
1777
  console.error(error);
1387
1778
  });
1388
- return (0, import_rxjs.concat)((0, import_rxjs.of)(eventWithState.event), toolCallEventStream$);
1779
+ telemetry_client_default.capture("oss.runtime.server_action_executed", {});
1780
+ return (0, import_rxjs2.concat)((0, import_rxjs2.of)(eventWithState.event), toolCallEventStream$);
1389
1781
  } else {
1390
- return (0, import_rxjs.of)(eventWithState.event);
1782
+ return (0, import_rxjs2.of)(eventWithState.event);
1391
1783
  }
1392
1784
  })
1393
1785
  );
1394
1786
  }
1395
1787
  };
1396
1788
  __name(RuntimeEventSource, "RuntimeEventSource");
1397
- async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionId) {
1789
+ async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionId, actionInputsWithoutAgents) {
1790
+ var _a;
1398
1791
  if (guardrailsResult$) {
1399
- const { status } = await (0, import_rxjs.firstValueFrom)(guardrailsResult$);
1792
+ const { status } = await (0, import_rxjs2.firstValueFrom)(guardrailsResult$);
1400
1793
  if (status === "denied") {
1401
1794
  eventStream$.complete();
1402
1795
  return;
@@ -1406,15 +1799,28 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
1406
1799
  if (actionArguments) {
1407
1800
  args = JSON.parse(actionArguments);
1408
1801
  }
1409
- const result = await action.handler(args);
1410
- await streamLangChainResponse({
1411
- result,
1412
- eventStream$,
1413
- actionExecution: {
1802
+ if (isLangGraphAgentAction(action)) {
1803
+ eventStream$.sendActionExecutionResult(actionExecutionId, action.name, `${action.name} agent started`);
1804
+ const stream = await action.langGraphAgentHandler({
1414
1805
  name: action.name,
1415
- id: actionExecutionId
1416
- }
1417
- });
1806
+ actionInputsWithoutAgents
1807
+ });
1808
+ (0, import_rxjs2.from)(stream).subscribe({
1809
+ next: (event) => eventStream$.next(event),
1810
+ error: (err) => console.error("Error in stream", err),
1811
+ complete: () => eventStream$.complete()
1812
+ });
1813
+ } else {
1814
+ const result = await ((_a = action.handler) == null ? void 0 : _a.call(action, args));
1815
+ await streamLangChainResponse({
1816
+ result,
1817
+ eventStream$,
1818
+ actionExecution: {
1819
+ name: action.name,
1820
+ id: actionExecutionId
1821
+ }
1822
+ });
1823
+ }
1418
1824
  }
1419
1825
  __name(executeAction, "executeAction");
1420
1826
 
@@ -1446,15 +1852,30 @@ function convertGqlInputToMessages(inputMessages) {
1446
1852
  actionName: message.resultMessage.actionName,
1447
1853
  result: message.resultMessage.result
1448
1854
  }));
1855
+ } else if (message.agentStateMessage) {
1856
+ messages.push((0, import_class_transformer.plainToInstance)(AgentStateMessage, {
1857
+ id: message.id,
1858
+ threadId: message.agentStateMessage.threadId,
1859
+ createdAt: message.createdAt,
1860
+ agentName: message.agentStateMessage.agentName,
1861
+ nodeName: message.agentStateMessage.nodeName,
1862
+ runId: message.agentStateMessage.runId,
1863
+ active: message.agentStateMessage.active,
1864
+ role: message.agentStateMessage.role,
1865
+ state: JSON.parse(message.agentStateMessage.state),
1866
+ running: message.agentStateMessage.running
1867
+ }));
1449
1868
  }
1450
1869
  }
1451
1870
  return messages;
1452
1871
  }
1453
1872
  __name(convertGqlInputToMessages, "convertGqlInputToMessages");
1454
1873
 
1455
- // src/lib/copilot-runtime.ts
1874
+ // src/lib/runtime/copilot-runtime.ts
1875
+ var import_rxjs3 = require("rxjs");
1456
1876
  var CopilotRuntime = class {
1457
1877
  actions;
1878
+ remoteActionDefinitions;
1458
1879
  langserve = [];
1459
1880
  onBeforeRequest;
1460
1881
  onAfterRequest;
@@ -1465,44 +1886,33 @@ var CopilotRuntime = class {
1465
1886
  const remoteChain = new RemoteChain(chain);
1466
1887
  this.langserve.push(remoteChain.toAction());
1467
1888
  }
1889
+ this.remoteActionDefinitions = (params == null ? void 0 : params.remoteActions) || [];
1468
1890
  this.onBeforeRequest = (_a = params == null ? void 0 : params.middleware) == null ? void 0 : _a.onBeforeRequest;
1469
1891
  this.onAfterRequest = (_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onAfterRequest;
1470
1892
  }
1471
- async process(request) {
1893
+ async processRuntimeRequest(request) {
1472
1894
  var _a;
1473
- const { serviceAdapter, messages, actions: clientSideActionsInput, threadId, runId, properties, outputMessagesPromise, forwardedParameters, url } = request;
1474
- const langserveFunctions = [];
1475
- for (const chainPromise of this.langserve) {
1476
- try {
1477
- const chain = await chainPromise;
1478
- langserveFunctions.push(chain);
1479
- } catch (error) {
1480
- console.error("Error loading langserve chain:", error);
1481
- }
1895
+ const { serviceAdapter, messages: rawMessages, actions: clientSideActionsInput, threadId, runId, outputMessagesPromise, graphqlContext, forwardedParameters, agentSession, url } = request;
1896
+ if (agentSession) {
1897
+ return this.processAgentRequest(request);
1482
1898
  }
1483
- const configuredActions = typeof this.actions === "function" ? this.actions({
1484
- properties,
1485
- url
1486
- }) : this.actions;
1487
- const actions = [
1488
- ...configuredActions,
1489
- ...langserveFunctions
1490
- ];
1491
- const serverSideActionsInput = actions.map((action) => ({
1899
+ const messages = rawMessages.filter((message) => !message.agentStateMessage);
1900
+ const inputMessages = convertGqlInputToMessages(messages);
1901
+ const serverSideActions = await this.getServerSideActions(request);
1902
+ const serverSideActionsInput = serverSideActions.map((action) => ({
1492
1903
  name: action.name,
1493
1904
  description: action.description,
1494
- jsonSchema: JSON.stringify((0, import_shared7.actionParametersToJsonSchema)(action.parameters))
1905
+ jsonSchema: JSON.stringify((0, import_shared8.actionParametersToJsonSchema)(action.parameters))
1495
1906
  }));
1496
1907
  const actionInputs = flattenToolCallsNoDuplicates([
1497
1908
  ...serverSideActionsInput,
1498
1909
  ...clientSideActionsInput
1499
1910
  ]);
1500
- const inputMessages = convertGqlInputToMessages(messages);
1501
1911
  await ((_a = this.onBeforeRequest) == null ? void 0 : _a.call(this, {
1502
1912
  threadId,
1503
1913
  runId,
1504
1914
  inputMessages,
1505
- properties,
1915
+ properties: graphqlContext.properties,
1506
1916
  url
1507
1917
  }));
1508
1918
  try {
@@ -1522,7 +1932,7 @@ var CopilotRuntime = class {
1522
1932
  runId: result.runId,
1523
1933
  inputMessages,
1524
1934
  outputMessages,
1525
- properties,
1935
+ properties: graphqlContext.properties,
1526
1936
  url
1527
1937
  });
1528
1938
  }).catch((_error) => {
@@ -1531,13 +1941,108 @@ var CopilotRuntime = class {
1531
1941
  threadId: result.threadId,
1532
1942
  runId: result.runId,
1533
1943
  eventSource,
1534
- actions
1944
+ serverSideActions,
1945
+ actionInputsWithoutAgents: actionInputs.filter((action) => (
1946
+ // TODO-AGENTS: do not exclude ALL server side actions
1947
+ !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
1948
+ ))
1949
+ };
1950
+ } catch (error) {
1951
+ console.error("Error getting response:", error);
1952
+ throw error;
1953
+ }
1954
+ }
1955
+ async processAgentRequest(request) {
1956
+ var _a;
1957
+ const { messages: rawMessages, outputMessagesPromise, graphqlContext, agentSession } = request;
1958
+ const { threadId = (0, import_shared8.randomId)(), agentName, nodeName } = agentSession;
1959
+ const serverSideActions = await this.getServerSideActions(request);
1960
+ const messages = convertGqlInputToMessages(rawMessages);
1961
+ const agent = serverSideActions.find((action) => action.name === agentName && isLangGraphAgentAction(action));
1962
+ if (!agent) {
1963
+ throw new Error(`Agent ${agentName} not found`);
1964
+ }
1965
+ const serverSideActionsInput = serverSideActions.filter((action) => !isLangGraphAgentAction(action)).map((action) => ({
1966
+ name: action.name,
1967
+ description: action.description,
1968
+ jsonSchema: JSON.stringify((0, import_shared8.actionParametersToJsonSchema)(action.parameters))
1969
+ }));
1970
+ const actionInputsWithoutAgents = flattenToolCallsNoDuplicates([
1971
+ ...serverSideActionsInput,
1972
+ ...request.actions
1973
+ ]);
1974
+ await ((_a = this.onBeforeRequest) == null ? void 0 : _a.call(this, {
1975
+ threadId,
1976
+ runId: void 0,
1977
+ inputMessages: messages,
1978
+ properties: graphqlContext.properties
1979
+ }));
1980
+ try {
1981
+ const eventSource = new RuntimeEventSource();
1982
+ const stream = await agent.langGraphAgentHandler({
1983
+ name: agentName,
1984
+ threadId,
1985
+ nodeName,
1986
+ actionInputsWithoutAgents
1987
+ });
1988
+ eventSource.stream(async (eventStream$) => {
1989
+ (0, import_rxjs3.from)(stream).subscribe({
1990
+ next: (event) => eventStream$.next(event),
1991
+ error: (err) => console.error("Error in stream", err),
1992
+ complete: () => eventStream$.complete()
1993
+ });
1994
+ });
1995
+ outputMessagesPromise.then((outputMessages) => {
1996
+ var _a2;
1997
+ (_a2 = this.onAfterRequest) == null ? void 0 : _a2.call(this, {
1998
+ threadId,
1999
+ runId: void 0,
2000
+ inputMessages: messages,
2001
+ outputMessages,
2002
+ properties: graphqlContext.properties
2003
+ });
2004
+ }).catch((_error) => {
2005
+ });
2006
+ return {
2007
+ threadId,
2008
+ runId: void 0,
2009
+ eventSource,
2010
+ serverSideActions: [],
2011
+ actionInputsWithoutAgents
1535
2012
  };
1536
2013
  } catch (error) {
1537
2014
  console.error("Error getting response:", error);
1538
2015
  throw error;
1539
2016
  }
1540
2017
  }
2018
+ async getServerSideActions(request) {
2019
+ const { messages: rawMessages, graphqlContext, agentStates, url } = request;
2020
+ const inputMessages = convertGqlInputToMessages(rawMessages);
2021
+ const langserveFunctions = [];
2022
+ for (const chainPromise of this.langserve) {
2023
+ try {
2024
+ const chain = await chainPromise;
2025
+ langserveFunctions.push(chain);
2026
+ } catch (error) {
2027
+ console.error("Error loading langserve chain:", error);
2028
+ }
2029
+ }
2030
+ const remoteActions = await setupRemoteActions({
2031
+ remoteActionDefinitions: this.remoteActionDefinitions,
2032
+ graphqlContext,
2033
+ messages: inputMessages,
2034
+ agentStates
2035
+ });
2036
+ const configuredActions = typeof this.actions === "function" ? this.actions({
2037
+ properties: graphqlContext.properties,
2038
+ url
2039
+ }) : this.actions;
2040
+ return [
2041
+ ...configuredActions,
2042
+ ...langserveFunctions,
2043
+ ...remoteActions
2044
+ ];
2045
+ }
1541
2046
  };
1542
2047
  __name(CopilotRuntime, "CopilotRuntime");
1543
2048
  function flattenToolCallsNoDuplicates(toolsByPriority) {
@@ -1554,14 +2059,14 @@ function flattenToolCallsNoDuplicates(toolsByPriority) {
1554
2059
  __name(flattenToolCallsNoDuplicates, "flattenToolCallsNoDuplicates");
1555
2060
 
1556
2061
  // src/lib/integrations/shared.ts
1557
- var import_type_graphql14 = require("type-graphql");
2062
+ var import_type_graphql16 = require("type-graphql");
1558
2063
 
1559
2064
  // src/graphql/resolvers/copilot.resolver.ts
1560
- var import_type_graphql13 = require("type-graphql");
1561
- var import_rxjs2 = require("rxjs");
2065
+ var import_type_graphql15 = require("type-graphql");
2066
+ var import_rxjs4 = require("rxjs");
1562
2067
 
1563
2068
  // src/graphql/inputs/generate-copilot-response.input.ts
1564
- var import_type_graphql9 = require("type-graphql");
2069
+ var import_type_graphql11 = require("type-graphql");
1565
2070
 
1566
2071
  // src/graphql/inputs/message.input.ts
1567
2072
  var import_type_graphql3 = require("type-graphql");
@@ -1578,6 +2083,7 @@ var ActionExecutionScope;
1578
2083
  (function(ActionExecutionScope2) {
1579
2084
  ActionExecutionScope2["server"] = "server";
1580
2085
  ActionExecutionScope2["client"] = "client";
2086
+ ActionExecutionScope2["passThrough"] = "passThrough";
1581
2087
  })(ActionExecutionScope || (ActionExecutionScope = {}));
1582
2088
  var CopilotRequestType;
1583
2089
  (function(CopilotRequestType2) {
@@ -1621,6 +2127,7 @@ var MessageInput = class extends BaseMessage {
1621
2127
  textMessage;
1622
2128
  actionExecutionMessage;
1623
2129
  resultMessage;
2130
+ agentStateMessage;
1624
2131
  };
1625
2132
  __name(MessageInput, "MessageInput");
1626
2133
  _ts_decorate2([
@@ -1641,6 +2148,12 @@ _ts_decorate2([
1641
2148
  }),
1642
2149
  _ts_metadata2("design:type", typeof ResultMessageInput === "undefined" ? Object : ResultMessageInput)
1643
2150
  ], MessageInput.prototype, "resultMessage", void 0);
2151
+ _ts_decorate2([
2152
+ (0, import_type_graphql3.Field)(() => AgentStateMessageInput, {
2153
+ nullable: true
2154
+ }),
2155
+ _ts_metadata2("design:type", typeof AgentStateMessageInput === "undefined" ? Object : AgentStateMessageInput)
2156
+ ], MessageInput.prototype, "agentStateMessage", void 0);
1644
2157
  MessageInput = _ts_decorate2([
1645
2158
  (0, import_type_graphql3.InputType)()
1646
2159
  ], MessageInput);
@@ -1702,6 +2215,52 @@ _ts_decorate2([
1702
2215
  ResultMessageInput = _ts_decorate2([
1703
2216
  (0, import_type_graphql3.InputType)()
1704
2217
  ], ResultMessageInput);
2218
+ var AgentStateMessageInput = class {
2219
+ threadId;
2220
+ agentName;
2221
+ role;
2222
+ state;
2223
+ running;
2224
+ nodeName;
2225
+ runId;
2226
+ active;
2227
+ };
2228
+ __name(AgentStateMessageInput, "AgentStateMessageInput");
2229
+ _ts_decorate2([
2230
+ (0, import_type_graphql3.Field)(() => String),
2231
+ _ts_metadata2("design:type", String)
2232
+ ], AgentStateMessageInput.prototype, "threadId", void 0);
2233
+ _ts_decorate2([
2234
+ (0, import_type_graphql3.Field)(() => String),
2235
+ _ts_metadata2("design:type", String)
2236
+ ], AgentStateMessageInput.prototype, "agentName", void 0);
2237
+ _ts_decorate2([
2238
+ (0, import_type_graphql3.Field)(() => MessageRole),
2239
+ _ts_metadata2("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
2240
+ ], AgentStateMessageInput.prototype, "role", void 0);
2241
+ _ts_decorate2([
2242
+ (0, import_type_graphql3.Field)(() => String),
2243
+ _ts_metadata2("design:type", String)
2244
+ ], AgentStateMessageInput.prototype, "state", void 0);
2245
+ _ts_decorate2([
2246
+ (0, import_type_graphql3.Field)(() => Boolean),
2247
+ _ts_metadata2("design:type", Boolean)
2248
+ ], AgentStateMessageInput.prototype, "running", void 0);
2249
+ _ts_decorate2([
2250
+ (0, import_type_graphql3.Field)(() => String),
2251
+ _ts_metadata2("design:type", String)
2252
+ ], AgentStateMessageInput.prototype, "nodeName", void 0);
2253
+ _ts_decorate2([
2254
+ (0, import_type_graphql3.Field)(() => String),
2255
+ _ts_metadata2("design:type", String)
2256
+ ], AgentStateMessageInput.prototype, "runId", void 0);
2257
+ _ts_decorate2([
2258
+ (0, import_type_graphql3.Field)(() => Boolean),
2259
+ _ts_metadata2("design:type", Boolean)
2260
+ ], AgentStateMessageInput.prototype, "active", void 0);
2261
+ AgentStateMessageInput = _ts_decorate2([
2262
+ (0, import_type_graphql3.InputType)()
2263
+ ], AgentStateMessageInput);
1705
2264
 
1706
2265
  // src/graphql/inputs/frontend.input.ts
1707
2266
  var import_type_graphql5 = require("type-graphql");
@@ -1943,7 +2502,8 @@ ForwardedParametersInput = _ts_decorate7([
1943
2502
  (0, import_type_graphql8.InputType)()
1944
2503
  ], ForwardedParametersInput);
1945
2504
 
1946
- // src/graphql/inputs/generate-copilot-response.input.ts
2505
+ // src/graphql/inputs/agent-session.input.ts
2506
+ var import_type_graphql9 = require("type-graphql");
1947
2507
  function _ts_decorate8(decorators, target, key, desc) {
1948
2508
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1949
2509
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -1960,18 +2520,96 @@ function _ts_metadata8(k, v) {
1960
2520
  return Reflect.metadata(k, v);
1961
2521
  }
1962
2522
  __name(_ts_metadata8, "_ts_metadata");
2523
+ var AgentSessionInput = class {
2524
+ agentName;
2525
+ threadId;
2526
+ nodeName;
2527
+ };
2528
+ __name(AgentSessionInput, "AgentSessionInput");
2529
+ _ts_decorate8([
2530
+ (0, import_type_graphql9.Field)(() => String),
2531
+ _ts_metadata8("design:type", String)
2532
+ ], AgentSessionInput.prototype, "agentName", void 0);
2533
+ _ts_decorate8([
2534
+ (0, import_type_graphql9.Field)(() => String, {
2535
+ nullable: true
2536
+ }),
2537
+ _ts_metadata8("design:type", String)
2538
+ ], AgentSessionInput.prototype, "threadId", void 0);
2539
+ _ts_decorate8([
2540
+ (0, import_type_graphql9.Field)(() => String, {
2541
+ nullable: true
2542
+ }),
2543
+ _ts_metadata8("design:type", String)
2544
+ ], AgentSessionInput.prototype, "nodeName", void 0);
2545
+ AgentSessionInput = _ts_decorate8([
2546
+ (0, import_type_graphql9.InputType)()
2547
+ ], AgentSessionInput);
2548
+
2549
+ // src/graphql/inputs/agent-state.input.ts
2550
+ var import_type_graphql10 = require("type-graphql");
2551
+ function _ts_decorate9(decorators, target, key, desc) {
2552
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2553
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2554
+ r = Reflect.decorate(decorators, target, key, desc);
2555
+ else
2556
+ for (var i = decorators.length - 1; i >= 0; i--)
2557
+ if (d = decorators[i])
2558
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2559
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2560
+ }
2561
+ __name(_ts_decorate9, "_ts_decorate");
2562
+ function _ts_metadata9(k, v) {
2563
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2564
+ return Reflect.metadata(k, v);
2565
+ }
2566
+ __name(_ts_metadata9, "_ts_metadata");
2567
+ var AgentStateInput = class {
2568
+ agentName;
2569
+ state;
2570
+ };
2571
+ __name(AgentStateInput, "AgentStateInput");
2572
+ _ts_decorate9([
2573
+ (0, import_type_graphql10.Field)(() => String),
2574
+ _ts_metadata9("design:type", String)
2575
+ ], AgentStateInput.prototype, "agentName", void 0);
2576
+ _ts_decorate9([
2577
+ (0, import_type_graphql10.Field)(() => String),
2578
+ _ts_metadata9("design:type", String)
2579
+ ], AgentStateInput.prototype, "state", void 0);
2580
+ AgentStateInput = _ts_decorate9([
2581
+ (0, import_type_graphql10.InputType)()
2582
+ ], AgentStateInput);
2583
+
2584
+ // src/graphql/inputs/generate-copilot-response.input.ts
2585
+ function _ts_decorate10(decorators, target, key, desc) {
2586
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2587
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2588
+ r = Reflect.decorate(decorators, target, key, desc);
2589
+ else
2590
+ for (var i = decorators.length - 1; i >= 0; i--)
2591
+ if (d = decorators[i])
2592
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2593
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2594
+ }
2595
+ __name(_ts_decorate10, "_ts_decorate");
2596
+ function _ts_metadata10(k, v) {
2597
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2598
+ return Reflect.metadata(k, v);
2599
+ }
2600
+ __name(_ts_metadata10, "_ts_metadata");
1963
2601
  var GenerateCopilotResponseMetadataInput = class {
1964
2602
  requestType;
1965
2603
  };
1966
2604
  __name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
1967
- _ts_decorate8([
1968
- (0, import_type_graphql9.Field)(() => CopilotRequestType, {
2605
+ _ts_decorate10([
2606
+ (0, import_type_graphql11.Field)(() => CopilotRequestType, {
1969
2607
  nullable: true
1970
2608
  }),
1971
- _ts_metadata8("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
2609
+ _ts_metadata10("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
1972
2610
  ], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
1973
- GenerateCopilotResponseMetadataInput = _ts_decorate8([
1974
- (0, import_type_graphql9.InputType)()
2611
+ GenerateCopilotResponseMetadataInput = _ts_decorate10([
2612
+ (0, import_type_graphql11.InputType)()
1975
2613
  ], GenerateCopilotResponseMetadataInput);
1976
2614
  var GenerateCopilotResponseInput = class {
1977
2615
  metadata;
@@ -1981,58 +2619,81 @@ var GenerateCopilotResponseInput = class {
1981
2619
  frontend;
1982
2620
  cloud;
1983
2621
  forwardedParameters;
2622
+ agentSession;
2623
+ agentState;
2624
+ agentStates;
1984
2625
  };
1985
2626
  __name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
1986
- _ts_decorate8([
1987
- (0, import_type_graphql9.Field)(() => GenerateCopilotResponseMetadataInput, {
2627
+ _ts_decorate10([
2628
+ (0, import_type_graphql11.Field)(() => GenerateCopilotResponseMetadataInput, {
1988
2629
  nullable: false
1989
2630
  }),
1990
- _ts_metadata8("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
2631
+ _ts_metadata10("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
1991
2632
  ], GenerateCopilotResponseInput.prototype, "metadata", void 0);
1992
- _ts_decorate8([
1993
- (0, import_type_graphql9.Field)(() => String, {
2633
+ _ts_decorate10([
2634
+ (0, import_type_graphql11.Field)(() => String, {
1994
2635
  nullable: true
1995
2636
  }),
1996
- _ts_metadata8("design:type", String)
2637
+ _ts_metadata10("design:type", String)
1997
2638
  ], GenerateCopilotResponseInput.prototype, "threadId", void 0);
1998
- _ts_decorate8([
1999
- (0, import_type_graphql9.Field)(() => String, {
2639
+ _ts_decorate10([
2640
+ (0, import_type_graphql11.Field)(() => String, {
2000
2641
  nullable: true
2001
2642
  }),
2002
- _ts_metadata8("design:type", String)
2643
+ _ts_metadata10("design:type", String)
2003
2644
  ], GenerateCopilotResponseInput.prototype, "runId", void 0);
2004
- _ts_decorate8([
2005
- (0, import_type_graphql9.Field)(() => [
2645
+ _ts_decorate10([
2646
+ (0, import_type_graphql11.Field)(() => [
2006
2647
  MessageInput
2007
2648
  ]),
2008
- _ts_metadata8("design:type", Array)
2649
+ _ts_metadata10("design:type", Array)
2009
2650
  ], GenerateCopilotResponseInput.prototype, "messages", void 0);
2010
- _ts_decorate8([
2011
- (0, import_type_graphql9.Field)(() => FrontendInput),
2012
- _ts_metadata8("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
2651
+ _ts_decorate10([
2652
+ (0, import_type_graphql11.Field)(() => FrontendInput),
2653
+ _ts_metadata10("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
2013
2654
  ], GenerateCopilotResponseInput.prototype, "frontend", void 0);
2014
- _ts_decorate8([
2015
- (0, import_type_graphql9.Field)(() => CloudInput, {
2655
+ _ts_decorate10([
2656
+ (0, import_type_graphql11.Field)(() => CloudInput, {
2016
2657
  nullable: true
2017
2658
  }),
2018
- _ts_metadata8("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
2659
+ _ts_metadata10("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
2019
2660
  ], GenerateCopilotResponseInput.prototype, "cloud", void 0);
2020
- _ts_decorate8([
2021
- (0, import_type_graphql9.Field)(() => ForwardedParametersInput, {
2661
+ _ts_decorate10([
2662
+ (0, import_type_graphql11.Field)(() => ForwardedParametersInput, {
2022
2663
  nullable: true
2023
2664
  }),
2024
- _ts_metadata8("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
2665
+ _ts_metadata10("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
2025
2666
  ], GenerateCopilotResponseInput.prototype, "forwardedParameters", void 0);
2026
- GenerateCopilotResponseInput = _ts_decorate8([
2027
- (0, import_type_graphql9.InputType)()
2667
+ _ts_decorate10([
2668
+ (0, import_type_graphql11.Field)(() => AgentSessionInput, {
2669
+ nullable: true
2670
+ }),
2671
+ _ts_metadata10("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
2672
+ ], GenerateCopilotResponseInput.prototype, "agentSession", void 0);
2673
+ _ts_decorate10([
2674
+ (0, import_type_graphql11.Field)(() => AgentStateInput, {
2675
+ nullable: true
2676
+ }),
2677
+ _ts_metadata10("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
2678
+ ], GenerateCopilotResponseInput.prototype, "agentState", void 0);
2679
+ _ts_decorate10([
2680
+ (0, import_type_graphql11.Field)(() => [
2681
+ AgentStateInput
2682
+ ], {
2683
+ nullable: true
2684
+ }),
2685
+ _ts_metadata10("design:type", Array)
2686
+ ], GenerateCopilotResponseInput.prototype, "agentStates", void 0);
2687
+ GenerateCopilotResponseInput = _ts_decorate10([
2688
+ (0, import_type_graphql11.InputType)()
2028
2689
  ], GenerateCopilotResponseInput);
2029
2690
 
2030
2691
  // src/graphql/types/copilot-response.type.ts
2031
- var import_type_graphql12 = require("type-graphql");
2692
+ var import_type_graphql14 = require("type-graphql");
2032
2693
 
2033
2694
  // src/graphql/types/message-status.type.ts
2034
- var import_type_graphql10 = require("type-graphql");
2035
- function _ts_decorate9(decorators, target, key, desc) {
2695
+ var import_type_graphql12 = require("type-graphql");
2696
+ function _ts_decorate11(decorators, target, key, desc) {
2036
2697
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2037
2698
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2038
2699
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2042,58 +2703,58 @@ function _ts_decorate9(decorators, target, key, desc) {
2042
2703
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2043
2704
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2044
2705
  }
2045
- __name(_ts_decorate9, "_ts_decorate");
2046
- function _ts_metadata9(k, v) {
2706
+ __name(_ts_decorate11, "_ts_decorate");
2707
+ function _ts_metadata11(k, v) {
2047
2708
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2048
2709
  return Reflect.metadata(k, v);
2049
2710
  }
2050
- __name(_ts_metadata9, "_ts_metadata");
2711
+ __name(_ts_metadata11, "_ts_metadata");
2051
2712
  var MessageStatusCode;
2052
2713
  (function(MessageStatusCode2) {
2053
2714
  MessageStatusCode2["Pending"] = "pending";
2054
2715
  MessageStatusCode2["Success"] = "success";
2055
2716
  MessageStatusCode2["Failed"] = "failed";
2056
2717
  })(MessageStatusCode || (MessageStatusCode = {}));
2057
- (0, import_type_graphql10.registerEnumType)(MessageStatusCode, {
2718
+ (0, import_type_graphql12.registerEnumType)(MessageStatusCode, {
2058
2719
  name: "MessageStatusCode"
2059
2720
  });
2060
2721
  var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
2061
2722
  code;
2062
2723
  }, "BaseMessageStatus");
2063
- _ts_decorate9([
2064
- (0, import_type_graphql10.Field)(() => MessageStatusCode),
2065
- _ts_metadata9("design:type", String)
2724
+ _ts_decorate11([
2725
+ (0, import_type_graphql12.Field)(() => MessageStatusCode),
2726
+ _ts_metadata11("design:type", String)
2066
2727
  ], BaseMessageStatus.prototype, "code", void 0);
2067
- BaseMessageStatus = _ts_decorate9([
2068
- (0, import_type_graphql10.ObjectType)()
2728
+ BaseMessageStatus = _ts_decorate11([
2729
+ (0, import_type_graphql12.ObjectType)()
2069
2730
  ], BaseMessageStatus);
2070
2731
  var PendingMessageStatus = class extends BaseMessageStatus {
2071
2732
  code = "pending";
2072
2733
  };
2073
2734
  __name(PendingMessageStatus, "PendingMessageStatus");
2074
- PendingMessageStatus = _ts_decorate9([
2075
- (0, import_type_graphql10.ObjectType)()
2735
+ PendingMessageStatus = _ts_decorate11([
2736
+ (0, import_type_graphql12.ObjectType)()
2076
2737
  ], PendingMessageStatus);
2077
2738
  var SuccessMessageStatus = class extends BaseMessageStatus {
2078
2739
  code = "success";
2079
2740
  };
2080
2741
  __name(SuccessMessageStatus, "SuccessMessageStatus");
2081
- SuccessMessageStatus = _ts_decorate9([
2082
- (0, import_type_graphql10.ObjectType)()
2742
+ SuccessMessageStatus = _ts_decorate11([
2743
+ (0, import_type_graphql12.ObjectType)()
2083
2744
  ], SuccessMessageStatus);
2084
2745
  var FailedMessageStatus = class extends BaseMessageStatus {
2085
2746
  code = "failed";
2086
2747
  reason;
2087
2748
  };
2088
2749
  __name(FailedMessageStatus, "FailedMessageStatus");
2089
- _ts_decorate9([
2090
- (0, import_type_graphql10.Field)(() => String),
2091
- _ts_metadata9("design:type", String)
2750
+ _ts_decorate11([
2751
+ (0, import_type_graphql12.Field)(() => String),
2752
+ _ts_metadata11("design:type", String)
2092
2753
  ], FailedMessageStatus.prototype, "reason", void 0);
2093
- FailedMessageStatus = _ts_decorate9([
2094
- (0, import_type_graphql10.ObjectType)()
2754
+ FailedMessageStatus = _ts_decorate11([
2755
+ (0, import_type_graphql12.ObjectType)()
2095
2756
  ], FailedMessageStatus);
2096
- var MessageStatusUnion = (0, import_type_graphql10.createUnionType)({
2757
+ var MessageStatusUnion = (0, import_type_graphql12.createUnionType)({
2097
2758
  name: "MessageStatus",
2098
2759
  types: () => [
2099
2760
  PendingMessageStatus,
@@ -2104,8 +2765,8 @@ var MessageStatusUnion = (0, import_type_graphql10.createUnionType)({
2104
2765
 
2105
2766
  // src/graphql/types/response-status.type.ts
2106
2767
  var import_graphql_scalars = require("graphql-scalars");
2107
- var import_type_graphql11 = require("type-graphql");
2108
- function _ts_decorate10(decorators, target, key, desc) {
2768
+ var import_type_graphql13 = require("type-graphql");
2769
+ function _ts_decorate12(decorators, target, key, desc) {
2109
2770
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2110
2771
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2111
2772
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2115,30 +2776,30 @@ function _ts_decorate10(decorators, target, key, desc) {
2115
2776
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2116
2777
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2117
2778
  }
2118
- __name(_ts_decorate10, "_ts_decorate");
2119
- function _ts_metadata10(k, v) {
2779
+ __name(_ts_decorate12, "_ts_decorate");
2780
+ function _ts_metadata12(k, v) {
2120
2781
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2121
2782
  return Reflect.metadata(k, v);
2122
2783
  }
2123
- __name(_ts_metadata10, "_ts_metadata");
2784
+ __name(_ts_metadata12, "_ts_metadata");
2124
2785
  var ResponseStatusCode;
2125
2786
  (function(ResponseStatusCode2) {
2126
2787
  ResponseStatusCode2["Pending"] = "pending";
2127
2788
  ResponseStatusCode2["Success"] = "success";
2128
2789
  ResponseStatusCode2["Failed"] = "failed";
2129
2790
  })(ResponseStatusCode || (ResponseStatusCode = {}));
2130
- (0, import_type_graphql11.registerEnumType)(ResponseStatusCode, {
2791
+ (0, import_type_graphql13.registerEnumType)(ResponseStatusCode, {
2131
2792
  name: "ResponseStatusCode"
2132
2793
  });
2133
2794
  var BaseResponseStatus = /* @__PURE__ */ __name(class BaseResponseStatus2 {
2134
2795
  code;
2135
2796
  }, "BaseResponseStatus");
2136
- _ts_decorate10([
2137
- (0, import_type_graphql11.Field)(() => ResponseStatusCode),
2138
- _ts_metadata10("design:type", String)
2797
+ _ts_decorate12([
2798
+ (0, import_type_graphql13.Field)(() => ResponseStatusCode),
2799
+ _ts_metadata12("design:type", String)
2139
2800
  ], BaseResponseStatus.prototype, "code", void 0);
2140
- BaseResponseStatus = _ts_decorate10([
2141
- (0, import_type_graphql11.InterfaceType)({
2801
+ BaseResponseStatus = _ts_decorate12([
2802
+ (0, import_type_graphql13.InterfaceType)({
2142
2803
  resolveType(value) {
2143
2804
  if (value.code === "success") {
2144
2805
  return SuccessResponseStatus;
@@ -2150,14 +2811,14 @@ BaseResponseStatus = _ts_decorate10([
2150
2811
  return void 0;
2151
2812
  }
2152
2813
  }),
2153
- (0, import_type_graphql11.ObjectType)()
2814
+ (0, import_type_graphql13.ObjectType)()
2154
2815
  ], BaseResponseStatus);
2155
2816
  var PendingResponseStatus = class extends BaseResponseStatus {
2156
2817
  code = "pending";
2157
2818
  };
2158
2819
  __name(PendingResponseStatus, "PendingResponseStatus");
2159
- PendingResponseStatus = _ts_decorate10([
2160
- (0, import_type_graphql11.ObjectType)({
2820
+ PendingResponseStatus = _ts_decorate12([
2821
+ (0, import_type_graphql13.ObjectType)({
2161
2822
  implements: BaseResponseStatus
2162
2823
  })
2163
2824
  ], PendingResponseStatus);
@@ -2165,8 +2826,8 @@ var SuccessResponseStatus = class extends BaseResponseStatus {
2165
2826
  code = "success";
2166
2827
  };
2167
2828
  __name(SuccessResponseStatus, "SuccessResponseStatus");
2168
- SuccessResponseStatus = _ts_decorate10([
2169
- (0, import_type_graphql11.ObjectType)({
2829
+ SuccessResponseStatus = _ts_decorate12([
2830
+ (0, import_type_graphql13.ObjectType)({
2170
2831
  implements: BaseResponseStatus
2171
2832
  })
2172
2833
  ], SuccessResponseStatus);
@@ -2176,7 +2837,7 @@ var FailedResponseStatusReason;
2176
2837
  FailedResponseStatusReason2["MESSAGE_STREAM_INTERRUPTED"] = "MESSAGE_STREAM_INTERRUPTED";
2177
2838
  FailedResponseStatusReason2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
2178
2839
  })(FailedResponseStatusReason || (FailedResponseStatusReason = {}));
2179
- (0, import_type_graphql11.registerEnumType)(FailedResponseStatusReason, {
2840
+ (0, import_type_graphql13.registerEnumType)(FailedResponseStatusReason, {
2180
2841
  name: "FailedResponseStatusReason"
2181
2842
  });
2182
2843
  var FailedResponseStatus = class extends BaseResponseStatus {
@@ -2185,22 +2846,22 @@ var FailedResponseStatus = class extends BaseResponseStatus {
2185
2846
  details = null;
2186
2847
  };
2187
2848
  __name(FailedResponseStatus, "FailedResponseStatus");
2188
- _ts_decorate10([
2189
- (0, import_type_graphql11.Field)(() => FailedResponseStatusReason),
2190
- _ts_metadata10("design:type", String)
2849
+ _ts_decorate12([
2850
+ (0, import_type_graphql13.Field)(() => FailedResponseStatusReason),
2851
+ _ts_metadata12("design:type", String)
2191
2852
  ], FailedResponseStatus.prototype, "reason", void 0);
2192
- _ts_decorate10([
2193
- (0, import_type_graphql11.Field)(() => import_graphql_scalars.GraphQLJSON, {
2853
+ _ts_decorate12([
2854
+ (0, import_type_graphql13.Field)(() => import_graphql_scalars.GraphQLJSON, {
2194
2855
  nullable: true
2195
2856
  }),
2196
- _ts_metadata10("design:type", typeof Record === "undefined" ? Object : Record)
2857
+ _ts_metadata12("design:type", typeof Record === "undefined" ? Object : Record)
2197
2858
  ], FailedResponseStatus.prototype, "details", void 0);
2198
- FailedResponseStatus = _ts_decorate10([
2199
- (0, import_type_graphql11.ObjectType)({
2859
+ FailedResponseStatus = _ts_decorate12([
2860
+ (0, import_type_graphql13.ObjectType)({
2200
2861
  implements: BaseResponseStatus
2201
2862
  })
2202
2863
  ], FailedResponseStatus);
2203
- var ResponseStatusUnion = (0, import_type_graphql11.createUnionType)({
2864
+ var ResponseStatusUnion = (0, import_type_graphql13.createUnionType)({
2204
2865
  name: "ResponseStatus",
2205
2866
  types: () => [
2206
2867
  PendingResponseStatus,
@@ -2210,7 +2871,7 @@ var ResponseStatusUnion = (0, import_type_graphql11.createUnionType)({
2210
2871
  });
2211
2872
 
2212
2873
  // src/graphql/types/copilot-response.type.ts
2213
- function _ts_decorate11(decorators, target, key, desc) {
2874
+ function _ts_decorate13(decorators, target, key, desc) {
2214
2875
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2215
2876
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2216
2877
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2220,31 +2881,31 @@ function _ts_decorate11(decorators, target, key, desc) {
2220
2881
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2221
2882
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2222
2883
  }
2223
- __name(_ts_decorate11, "_ts_decorate");
2224
- function _ts_metadata11(k, v) {
2884
+ __name(_ts_decorate13, "_ts_decorate");
2885
+ function _ts_metadata13(k, v) {
2225
2886
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2226
2887
  return Reflect.metadata(k, v);
2227
2888
  }
2228
- __name(_ts_metadata11, "_ts_metadata");
2889
+ __name(_ts_metadata13, "_ts_metadata");
2229
2890
  var BaseMessageOutput = /* @__PURE__ */ __name(class BaseMessageOutput2 {
2230
2891
  id;
2231
2892
  createdAt;
2232
2893
  status;
2233
2894
  }, "BaseMessageOutput");
2234
- _ts_decorate11([
2235
- (0, import_type_graphql12.Field)(() => String),
2236
- _ts_metadata11("design:type", String)
2895
+ _ts_decorate13([
2896
+ (0, import_type_graphql14.Field)(() => String),
2897
+ _ts_metadata13("design:type", String)
2237
2898
  ], BaseMessageOutput.prototype, "id", void 0);
2238
- _ts_decorate11([
2239
- (0, import_type_graphql12.Field)(() => Date),
2240
- _ts_metadata11("design:type", typeof Date === "undefined" ? Object : Date)
2899
+ _ts_decorate13([
2900
+ (0, import_type_graphql14.Field)(() => Date),
2901
+ _ts_metadata13("design:type", typeof Date === "undefined" ? Object : Date)
2241
2902
  ], BaseMessageOutput.prototype, "createdAt", void 0);
2242
- _ts_decorate11([
2243
- (0, import_type_graphql12.Field)(() => MessageStatusUnion),
2244
- _ts_metadata11("design:type", Object)
2903
+ _ts_decorate13([
2904
+ (0, import_type_graphql14.Field)(() => MessageStatusUnion),
2905
+ _ts_metadata13("design:type", Object)
2245
2906
  ], BaseMessageOutput.prototype, "status", void 0);
2246
- BaseMessageOutput = _ts_decorate11([
2247
- (0, import_type_graphql12.InterfaceType)({
2907
+ BaseMessageOutput = _ts_decorate13([
2908
+ (0, import_type_graphql14.InterfaceType)({
2248
2909
  resolveType(value) {
2249
2910
  if (value.hasOwnProperty("content")) {
2250
2911
  return TextMessageOutput;
@@ -2252,6 +2913,8 @@ BaseMessageOutput = _ts_decorate11([
2252
2913
  return ActionExecutionMessageOutput;
2253
2914
  } else if (value.hasOwnProperty("result")) {
2254
2915
  return ResultMessageOutput;
2916
+ } else if (value.hasOwnProperty("state")) {
2917
+ return AgentStateMessageOutput;
2255
2918
  }
2256
2919
  return void 0;
2257
2920
  }
@@ -2262,18 +2925,18 @@ var TextMessageOutput = class {
2262
2925
  content;
2263
2926
  };
2264
2927
  __name(TextMessageOutput, "TextMessageOutput");
2265
- _ts_decorate11([
2266
- (0, import_type_graphql12.Field)(() => MessageRole),
2267
- _ts_metadata11("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
2928
+ _ts_decorate13([
2929
+ (0, import_type_graphql14.Field)(() => MessageRole),
2930
+ _ts_metadata13("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
2268
2931
  ], TextMessageOutput.prototype, "role", void 0);
2269
- _ts_decorate11([
2270
- (0, import_type_graphql12.Field)(() => [
2932
+ _ts_decorate13([
2933
+ (0, import_type_graphql14.Field)(() => [
2271
2934
  String
2272
2935
  ]),
2273
- _ts_metadata11("design:type", Array)
2936
+ _ts_metadata13("design:type", Array)
2274
2937
  ], TextMessageOutput.prototype, "content", void 0);
2275
- TextMessageOutput = _ts_decorate11([
2276
- (0, import_type_graphql12.ObjectType)({
2938
+ TextMessageOutput = _ts_decorate13([
2939
+ (0, import_type_graphql14.ObjectType)({
2277
2940
  implements: BaseMessageOutput
2278
2941
  })
2279
2942
  ], TextMessageOutput);
@@ -2283,22 +2946,22 @@ var ActionExecutionMessageOutput = class {
2283
2946
  arguments;
2284
2947
  };
2285
2948
  __name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
2286
- _ts_decorate11([
2287
- (0, import_type_graphql12.Field)(() => String),
2288
- _ts_metadata11("design:type", String)
2949
+ _ts_decorate13([
2950
+ (0, import_type_graphql14.Field)(() => String),
2951
+ _ts_metadata13("design:type", String)
2289
2952
  ], ActionExecutionMessageOutput.prototype, "name", void 0);
2290
- _ts_decorate11([
2291
- (0, import_type_graphql12.Field)(() => ActionExecutionScope),
2292
- _ts_metadata11("design:type", typeof ActionExecutionScope === "undefined" ? Object : ActionExecutionScope)
2953
+ _ts_decorate13([
2954
+ (0, import_type_graphql14.Field)(() => ActionExecutionScope),
2955
+ _ts_metadata13("design:type", typeof ActionExecutionScope === "undefined" ? Object : ActionExecutionScope)
2293
2956
  ], ActionExecutionMessageOutput.prototype, "scope", void 0);
2294
- _ts_decorate11([
2295
- (0, import_type_graphql12.Field)(() => [
2957
+ _ts_decorate13([
2958
+ (0, import_type_graphql14.Field)(() => [
2296
2959
  String
2297
2960
  ]),
2298
- _ts_metadata11("design:type", Array)
2961
+ _ts_metadata13("design:type", Array)
2299
2962
  ], ActionExecutionMessageOutput.prototype, "arguments", void 0);
2300
- ActionExecutionMessageOutput = _ts_decorate11([
2301
- (0, import_type_graphql12.ObjectType)({
2963
+ ActionExecutionMessageOutput = _ts_decorate13([
2964
+ (0, import_type_graphql14.ObjectType)({
2302
2965
  implements: BaseMessageOutput
2303
2966
  })
2304
2967
  ], ActionExecutionMessageOutput);
@@ -2308,23 +2971,71 @@ var ResultMessageOutput = class {
2308
2971
  result;
2309
2972
  };
2310
2973
  __name(ResultMessageOutput, "ResultMessageOutput");
2311
- _ts_decorate11([
2312
- (0, import_type_graphql12.Field)(() => String),
2313
- _ts_metadata11("design:type", String)
2974
+ _ts_decorate13([
2975
+ (0, import_type_graphql14.Field)(() => String),
2976
+ _ts_metadata13("design:type", String)
2314
2977
  ], ResultMessageOutput.prototype, "actionExecutionId", void 0);
2315
- _ts_decorate11([
2316
- (0, import_type_graphql12.Field)(() => String),
2317
- _ts_metadata11("design:type", String)
2978
+ _ts_decorate13([
2979
+ (0, import_type_graphql14.Field)(() => String),
2980
+ _ts_metadata13("design:type", String)
2318
2981
  ], ResultMessageOutput.prototype, "actionName", void 0);
2319
- _ts_decorate11([
2320
- (0, import_type_graphql12.Field)(() => String),
2321
- _ts_metadata11("design:type", String)
2982
+ _ts_decorate13([
2983
+ (0, import_type_graphql14.Field)(() => String),
2984
+ _ts_metadata13("design:type", String)
2322
2985
  ], ResultMessageOutput.prototype, "result", void 0);
2323
- ResultMessageOutput = _ts_decorate11([
2324
- (0, import_type_graphql12.ObjectType)({
2986
+ ResultMessageOutput = _ts_decorate13([
2987
+ (0, import_type_graphql14.ObjectType)({
2325
2988
  implements: BaseMessageOutput
2326
2989
  })
2327
2990
  ], ResultMessageOutput);
2991
+ var AgentStateMessageOutput = class {
2992
+ threadId;
2993
+ agentName;
2994
+ nodeName;
2995
+ runId;
2996
+ active;
2997
+ role;
2998
+ state;
2999
+ running;
3000
+ };
3001
+ __name(AgentStateMessageOutput, "AgentStateMessageOutput");
3002
+ _ts_decorate13([
3003
+ (0, import_type_graphql14.Field)(() => String),
3004
+ _ts_metadata13("design:type", String)
3005
+ ], AgentStateMessageOutput.prototype, "threadId", void 0);
3006
+ _ts_decorate13([
3007
+ (0, import_type_graphql14.Field)(() => String),
3008
+ _ts_metadata13("design:type", String)
3009
+ ], AgentStateMessageOutput.prototype, "agentName", void 0);
3010
+ _ts_decorate13([
3011
+ (0, import_type_graphql14.Field)(() => String),
3012
+ _ts_metadata13("design:type", String)
3013
+ ], AgentStateMessageOutput.prototype, "nodeName", void 0);
3014
+ _ts_decorate13([
3015
+ (0, import_type_graphql14.Field)(() => String),
3016
+ _ts_metadata13("design:type", String)
3017
+ ], AgentStateMessageOutput.prototype, "runId", void 0);
3018
+ _ts_decorate13([
3019
+ (0, import_type_graphql14.Field)(() => Boolean),
3020
+ _ts_metadata13("design:type", Boolean)
3021
+ ], AgentStateMessageOutput.prototype, "active", void 0);
3022
+ _ts_decorate13([
3023
+ (0, import_type_graphql14.Field)(() => MessageRole),
3024
+ _ts_metadata13("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
3025
+ ], AgentStateMessageOutput.prototype, "role", void 0);
3026
+ _ts_decorate13([
3027
+ (0, import_type_graphql14.Field)(() => String),
3028
+ _ts_metadata13("design:type", String)
3029
+ ], AgentStateMessageOutput.prototype, "state", void 0);
3030
+ _ts_decorate13([
3031
+ (0, import_type_graphql14.Field)(() => Boolean),
3032
+ _ts_metadata13("design:type", Boolean)
3033
+ ], AgentStateMessageOutput.prototype, "running", void 0);
3034
+ AgentStateMessageOutput = _ts_decorate13([
3035
+ (0, import_type_graphql14.ObjectType)({
3036
+ implements: BaseMessageOutput
3037
+ })
3038
+ ], AgentStateMessageOutput);
2328
3039
  var CopilotResponse = class {
2329
3040
  threadId;
2330
3041
  status;
@@ -2332,28 +3043,28 @@ var CopilotResponse = class {
2332
3043
  messages;
2333
3044
  };
2334
3045
  __name(CopilotResponse, "CopilotResponse");
2335
- _ts_decorate11([
2336
- (0, import_type_graphql12.Field)(() => String),
2337
- _ts_metadata11("design:type", String)
3046
+ _ts_decorate13([
3047
+ (0, import_type_graphql14.Field)(() => String),
3048
+ _ts_metadata13("design:type", String)
2338
3049
  ], CopilotResponse.prototype, "threadId", void 0);
2339
- _ts_decorate11([
2340
- (0, import_type_graphql12.Field)(() => ResponseStatusUnion),
2341
- _ts_metadata11("design:type", Object)
3050
+ _ts_decorate13([
3051
+ (0, import_type_graphql14.Field)(() => ResponseStatusUnion),
3052
+ _ts_metadata13("design:type", Object)
2342
3053
  ], CopilotResponse.prototype, "status", void 0);
2343
- _ts_decorate11([
2344
- (0, import_type_graphql12.Field)({
3054
+ _ts_decorate13([
3055
+ (0, import_type_graphql14.Field)({
2345
3056
  nullable: true
2346
3057
  }),
2347
- _ts_metadata11("design:type", String)
3058
+ _ts_metadata13("design:type", String)
2348
3059
  ], CopilotResponse.prototype, "runId", void 0);
2349
- _ts_decorate11([
2350
- (0, import_type_graphql12.Field)(() => [
3060
+ _ts_decorate13([
3061
+ (0, import_type_graphql14.Field)(() => [
2351
3062
  BaseMessageOutput
2352
3063
  ]),
2353
- _ts_metadata11("design:type", Array)
3064
+ _ts_metadata13("design:type", Array)
2354
3065
  ], CopilotResponse.prototype, "messages", void 0);
2355
- CopilotResponse = _ts_decorate11([
2356
- (0, import_type_graphql12.ObjectType)()
3066
+ CopilotResponse = _ts_decorate13([
3067
+ (0, import_type_graphql14.ObjectType)()
2357
3068
  ], CopilotResponse);
2358
3069
 
2359
3070
  // src/graphql/resolvers/copilot.resolver.ts
@@ -2395,18 +3106,9 @@ var UnknownErrorResponse = class extends FailedResponseStatus {
2395
3106
  };
2396
3107
  __name(UnknownErrorResponse, "UnknownErrorResponse");
2397
3108
 
2398
- // src/lib/telemetry-client.ts
2399
- var import_shared8 = require("@copilotkit/shared");
2400
- var packageJson = require_package();
2401
- var telemetryClient = new import_shared8.TelemetryClient({
2402
- packageName: packageJson.name,
2403
- packageVersion: packageJson.version
2404
- });
2405
- var telemetry_client_default = telemetryClient;
2406
-
2407
3109
  // src/graphql/resolvers/copilot.resolver.ts
2408
3110
  var import_shared9 = require("@copilotkit/shared");
2409
- function _ts_decorate12(decorators, target, key, desc) {
3111
+ function _ts_decorate14(decorators, target, key, desc) {
2410
3112
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2411
3113
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2412
3114
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2416,12 +3118,12 @@ function _ts_decorate12(decorators, target, key, desc) {
2416
3118
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2417
3119
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2418
3120
  }
2419
- __name(_ts_decorate12, "_ts_decorate");
2420
- function _ts_metadata12(k, v) {
3121
+ __name(_ts_decorate14, "_ts_decorate");
3122
+ function _ts_metadata14(k, v) {
2421
3123
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2422
3124
  return Reflect.metadata(k, v);
2423
3125
  }
2424
- __name(_ts_metadata12, "_ts_metadata");
3126
+ __name(_ts_metadata14, "_ts_metadata");
2425
3127
  function _ts_param(paramIndex, decorator) {
2426
3128
  return function(target, key) {
2427
3129
  decorator(target, key, paramIndex);
@@ -2430,7 +3132,6 @@ function _ts_param(paramIndex, decorator) {
2430
3132
  __name(_ts_param, "_ts_param");
2431
3133
  var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPublicApiKey, data, onResult, onError }) => {
2432
3134
  var _a;
2433
- console.log("invokeGuardrails.baseUrl", baseUrl);
2434
3135
  if (data.messages.length && ((_a = data.messages[data.messages.length - 1].textMessage) == null ? void 0 : _a.role) === MessageRole.user) {
2435
3136
  const messages = data.messages.filter((m) => m.textMessage !== void 0 && (m.textMessage.role === MessageRole.user || m.textMessage.role === MessageRole.assistant)).map((m) => ({
2436
3137
  role: m.textMessage.role,
@@ -2476,8 +3177,6 @@ var CopilotResolver = class {
2476
3177
  logger2.debug({
2477
3178
  data
2478
3179
  }, "Generating Copilot response");
2479
- const copilotRuntime = ctx._copilotkit.runtime;
2480
- const serviceAdapter = ctx._copilotkit.serviceAdapter;
2481
3180
  if (properties) {
2482
3181
  logger2.debug("Properties provided, merging with context properties");
2483
3182
  ctx.properties = {
@@ -2485,6 +3184,8 @@ var CopilotResolver = class {
2485
3184
  ...properties
2486
3185
  };
2487
3186
  }
3187
+ const copilotRuntime = ctx._copilotkit.runtime;
3188
+ const serviceAdapter = ctx._copilotkit.serviceAdapter;
2488
3189
  let copilotCloudPublicApiKey = null;
2489
3190
  let copilotCloudBaseUrl;
2490
3191
  if (data.cloud) {
@@ -2512,9 +3213,9 @@ var CopilotResolver = class {
2512
3213
  });
2513
3214
  }
2514
3215
  logger2.debug("Setting up subjects");
2515
- const responseStatus$ = new import_rxjs2.ReplaySubject();
2516
- const interruptStreaming$ = new import_rxjs2.ReplaySubject();
2517
- const guardrailsResult$ = new import_rxjs2.ReplaySubject();
3216
+ const responseStatus$ = new import_rxjs4.ReplaySubject();
3217
+ const interruptStreaming$ = new import_rxjs4.ReplaySubject();
3218
+ const guardrailsResult$ = new import_rxjs4.ReplaySubject();
2518
3219
  let outputMessages = [];
2519
3220
  let resolveOutputMessagesPromise;
2520
3221
  let rejectOutputMessagesPromise;
@@ -2523,23 +3224,25 @@ var CopilotResolver = class {
2523
3224
  rejectOutputMessagesPromise = reject;
2524
3225
  });
2525
3226
  logger2.debug("Processing");
2526
- const { eventSource, threadId = (0, import_shared9.randomId)(), runId, actions } = await copilotRuntime.process({
3227
+ const { eventSource, threadId = (0, import_shared9.randomId)(), runId, serverSideActions, actionInputsWithoutAgents } = await copilotRuntime.processRuntimeRequest({
2527
3228
  serviceAdapter,
2528
3229
  messages: data.messages,
2529
3230
  actions: data.frontend.actions,
2530
3231
  threadId: data.threadId,
2531
3232
  runId: data.runId,
2532
3233
  publicApiKey: void 0,
2533
- properties: ctx.properties || {},
2534
3234
  outputMessagesPromise,
3235
+ graphqlContext: ctx,
2535
3236
  forwardedParameters: data.forwardedParameters,
3237
+ agentSession: data.agentSession,
3238
+ agentStates: data.agentStates,
2536
3239
  url: data.frontend.url
2537
3240
  });
2538
3241
  logger2.debug("Event source created, creating response");
2539
3242
  const response = {
2540
3243
  threadId,
2541
3244
  runId,
2542
- status: (0, import_rxjs2.firstValueFrom)(responseStatus$),
3245
+ status: (0, import_rxjs4.firstValueFrom)(responseStatus$),
2543
3246
  messages: new import_graphql_yoga.Repeater(async (pushMessage, stopStreamingMessages) => {
2544
3247
  var _a2, _b2;
2545
3248
  logger2.debug("Messages repeater created");
@@ -2590,14 +3293,18 @@ var CopilotResolver = class {
2590
3293
  });
2591
3294
  }
2592
3295
  let eventStreamSubscription;
2593
- const eventStream = eventSource.process({
2594
- serversideActions: actions,
2595
- guardrailsResult$: ((_b2 = data.cloud) == null ? void 0 : _b2.guardrails) ? guardrailsResult$ : null
3296
+ const eventStream = eventSource.processRuntimeEvents({
3297
+ serverSideActions,
3298
+ guardrailsResult$: ((_b2 = data.cloud) == null ? void 0 : _b2.guardrails) ? guardrailsResult$ : null,
3299
+ actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
3300
+ // TODO-AGENTS: do not exclude ALL server side actions
3301
+ (action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
3302
+ )
2596
3303
  }).pipe(
2597
3304
  // shareReplay() ensures that later subscribers will see the whole stream instead of
2598
3305
  // just the events that were emitted after the subscriber was added.
2599
- (0, import_rxjs2.shareReplay)(),
2600
- (0, import_rxjs2.finalize)(() => {
3306
+ (0, import_rxjs4.shareReplay)(),
3307
+ (0, import_rxjs4.finalize)(() => {
2601
3308
  logger2.debug("Event stream finalized");
2602
3309
  })
2603
3310
  );
@@ -2608,22 +3315,22 @@ var CopilotResolver = class {
2608
3315
  case RuntimeEventTypes.TextMessageStart:
2609
3316
  const textMessageContentStream = eventStream.pipe(
2610
3317
  // skip until this message start event
2611
- (0, import_rxjs2.skipWhile)((e) => e !== event),
3318
+ (0, import_rxjs4.skipWhile)((e) => e !== event),
2612
3319
  // take until the message end event
2613
- (0, import_rxjs2.takeWhile)((e) => e.type != RuntimeEventTypes.TextMessageEnd)
3320
+ (0, import_rxjs4.takeWhile)((e) => e.type != RuntimeEventTypes.TextMessageEnd)
2614
3321
  );
2615
- const streamingTextStatus = new import_rxjs2.Subject();
3322
+ const streamingTextStatus = new import_rxjs4.Subject();
2616
3323
  const messageId = (0, import_shared9.randomId)();
2617
3324
  pushMessage({
2618
3325
  id: messageId,
2619
- status: (0, import_rxjs2.firstValueFrom)(streamingTextStatus),
3326
+ status: (0, import_rxjs4.firstValueFrom)(streamingTextStatus),
2620
3327
  createdAt: /* @__PURE__ */ new Date(),
2621
3328
  role: MessageRole.assistant,
2622
3329
  content: new import_graphql_yoga.Repeater(async (pushTextChunk, stopStreamingText) => {
2623
3330
  logger2.debug("Text message content repeater created");
2624
3331
  const textChunks = [];
2625
3332
  let textSubscription;
2626
- interruptStreaming$.pipe((0, import_rxjs2.shareReplay)(), (0, import_rxjs2.take)(1), (0, import_rxjs2.tap)(({ reason, messageId: messageId2 }) => {
3333
+ interruptStreaming$.pipe((0, import_rxjs4.shareReplay)(), (0, import_rxjs4.take)(1), (0, import_rxjs4.tap)(({ reason, messageId: messageId2 }) => {
2627
3334
  logger2.debug({
2628
3335
  reason,
2629
3336
  messageId: messageId2
@@ -2674,11 +3381,11 @@ var CopilotResolver = class {
2674
3381
  break;
2675
3382
  case RuntimeEventTypes.ActionExecutionStart:
2676
3383
  logger2.debug("Action execution start event received");
2677
- const actionExecutionArgumentStream = eventStream.pipe((0, import_rxjs2.skipWhile)((e) => e !== event), (0, import_rxjs2.takeWhile)((e) => e.type != RuntimeEventTypes.ActionExecutionEnd));
2678
- const streamingArgumentsStatus = new import_rxjs2.Subject();
3384
+ const actionExecutionArgumentStream = eventStream.pipe((0, import_rxjs4.skipWhile)((e) => e !== event), (0, import_rxjs4.takeWhile)((e) => e.type != RuntimeEventTypes.ActionExecutionEnd));
3385
+ const streamingArgumentsStatus = new import_rxjs4.Subject();
2679
3386
  pushMessage({
2680
3387
  id: event.actionExecutionId,
2681
- status: (0, import_rxjs2.firstValueFrom)(streamingArgumentsStatus),
3388
+ status: (0, import_rxjs4.firstValueFrom)(streamingArgumentsStatus),
2682
3389
  createdAt: /* @__PURE__ */ new Date(),
2683
3390
  name: event.actionName,
2684
3391
  scope: event.scope,
@@ -2740,6 +3447,36 @@ var CopilotResolver = class {
2740
3447
  result: event.result
2741
3448
  }));
2742
3449
  break;
3450
+ case RuntimeEventTypes.AgentStateMessage:
3451
+ logger2.debug({
3452
+ event
3453
+ }, "Agent message event received");
3454
+ pushMessage({
3455
+ id: (0, import_shared9.randomId)(),
3456
+ status: new SuccessMessageStatus(),
3457
+ threadId: event.threadId,
3458
+ agentName: event.agentName,
3459
+ nodeName: event.nodeName,
3460
+ runId: event.runId,
3461
+ active: event.active,
3462
+ state: event.state,
3463
+ running: event.running,
3464
+ role: MessageRole.assistant,
3465
+ createdAt: /* @__PURE__ */ new Date()
3466
+ });
3467
+ outputMessages.push((0, import_class_transformer2.plainToInstance)(AgentStateMessage, {
3468
+ id: (0, import_shared9.randomId)(),
3469
+ threadId: event.threadId,
3470
+ agentName: event.agentName,
3471
+ nodeName: event.nodeName,
3472
+ runId: event.runId,
3473
+ active: event.active,
3474
+ state: event.state,
3475
+ running: event.running,
3476
+ role: MessageRole.assistant,
3477
+ createdAt: /* @__PURE__ */ new Date()
3478
+ }));
3479
+ break;
2743
3480
  }
2744
3481
  },
2745
3482
  error: (err) => {
@@ -2758,7 +3495,7 @@ var CopilotResolver = class {
2758
3495
  logger2.debug("Event stream completed");
2759
3496
  if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
2760
3497
  logger2.debug("Guardrails is enabled, waiting for guardrails result");
2761
- await (0, import_rxjs2.firstValueFrom)(guardrailsResult$);
3498
+ await (0, import_rxjs4.firstValueFrom)(guardrailsResult$);
2762
3499
  }
2763
3500
  responseStatus$.next(new SuccessResponseStatus());
2764
3501
  eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
@@ -2772,29 +3509,29 @@ var CopilotResolver = class {
2772
3509
  }
2773
3510
  };
2774
3511
  __name(CopilotResolver, "CopilotResolver");
2775
- _ts_decorate12([
2776
- (0, import_type_graphql13.Query)(() => String),
2777
- _ts_metadata12("design:type", Function),
2778
- _ts_metadata12("design:paramtypes", []),
2779
- _ts_metadata12("design:returntype", Promise)
3512
+ _ts_decorate14([
3513
+ (0, import_type_graphql15.Query)(() => String),
3514
+ _ts_metadata14("design:type", Function),
3515
+ _ts_metadata14("design:paramtypes", []),
3516
+ _ts_metadata14("design:returntype", Promise)
2780
3517
  ], CopilotResolver.prototype, "hello", null);
2781
- _ts_decorate12([
2782
- (0, import_type_graphql13.Mutation)(() => CopilotResponse),
2783
- _ts_param(0, (0, import_type_graphql13.Ctx)()),
2784
- _ts_param(1, (0, import_type_graphql13.Arg)("data")),
2785
- _ts_param(2, (0, import_type_graphql13.Arg)("properties", () => import_graphql_scalars2.GraphQLJSONObject, {
3518
+ _ts_decorate14([
3519
+ (0, import_type_graphql15.Mutation)(() => CopilotResponse),
3520
+ _ts_param(0, (0, import_type_graphql15.Ctx)()),
3521
+ _ts_param(1, (0, import_type_graphql15.Arg)("data")),
3522
+ _ts_param(2, (0, import_type_graphql15.Arg)("properties", () => import_graphql_scalars2.GraphQLJSONObject, {
2786
3523
  nullable: true
2787
3524
  })),
2788
- _ts_metadata12("design:type", Function),
2789
- _ts_metadata12("design:paramtypes", [
3525
+ _ts_metadata14("design:type", Function),
3526
+ _ts_metadata14("design:paramtypes", [
2790
3527
  typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
2791
3528
  typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
2792
3529
  typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
2793
3530
  ]),
2794
- _ts_metadata12("design:returntype", Promise)
3531
+ _ts_metadata14("design:returntype", Promise)
2795
3532
  ], CopilotResolver.prototype, "generateCopilotResponse", null);
2796
- CopilotResolver = _ts_decorate12([
2797
- (0, import_type_graphql13.Resolver)(() => CopilotResponse)
3533
+ CopilotResolver = _ts_decorate14([
3534
+ (0, import_type_graphql15.Resolver)(() => CopilotResponse)
2798
3535
  ], CopilotResolver);
2799
3536
 
2800
3537
  // src/lib/integrations/shared.ts
@@ -2849,7 +3586,7 @@ async function createContext(initialContext, copilotKitContext, contextLogger, p
2849
3586
  __name(createContext, "createContext");
2850
3587
  function buildSchema(options = {}) {
2851
3588
  logger.debug("Building GraphQL schema...");
2852
- const schema = (0, import_type_graphql14.buildSchemaSync)({
3589
+ const schema = (0, import_type_graphql16.buildSchemaSync)({
2853
3590
  resolvers: [
2854
3591
  CopilotResolver
2855
3592
  ],