@copilotkit/runtime 1.6.0-next.9 → 1.7.0-next.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 (38) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/dist/{chunk-5ZBUMQE2.mjs → chunk-2BN7NZNC.mjs} +2 -2
  3. package/dist/{chunk-L7OTGCAG.mjs → chunk-34Y5DNNJ.mjs} +104 -74
  4. package/dist/chunk-34Y5DNNJ.mjs.map +1 -0
  5. package/dist/{chunk-7BCFHZLY.mjs → chunk-PH24IU7T.mjs} +2 -2
  6. package/dist/{chunk-4HQ5OZXN.mjs → chunk-ZYFN76KV.mjs} +2 -2
  7. package/dist/index.js +103 -73
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +4 -4
  10. package/dist/lib/index.js +103 -73
  11. package/dist/lib/index.js.map +1 -1
  12. package/dist/lib/index.mjs +4 -4
  13. package/dist/lib/integrations/index.js +6 -3
  14. package/dist/lib/integrations/index.js.map +1 -1
  15. package/dist/lib/integrations/index.mjs +4 -4
  16. package/dist/lib/integrations/nest/index.js +6 -3
  17. package/dist/lib/integrations/nest/index.js.map +1 -1
  18. package/dist/lib/integrations/nest/index.mjs +2 -2
  19. package/dist/lib/integrations/node-express/index.js +6 -3
  20. package/dist/lib/integrations/node-express/index.js.map +1 -1
  21. package/dist/lib/integrations/node-express/index.mjs +2 -2
  22. package/dist/lib/integrations/node-http/index.js +6 -3
  23. package/dist/lib/integrations/node-http/index.js.map +1 -1
  24. package/dist/lib/integrations/node-http/index.mjs +1 -1
  25. package/package.json +2 -2
  26. package/src/agents/langgraph/event-source.ts +11 -4
  27. package/src/graphql/resolvers/copilot.resolver.ts +4 -0
  28. package/src/lib/runtime/__tests__/remote-action-constructors.test.ts +45 -35
  29. package/src/lib/runtime/copilot-runtime.ts +23 -17
  30. package/src/lib/runtime/remote-action-constructors.ts +28 -68
  31. package/src/lib/runtime/remote-actions.ts +5 -5
  32. package/src/lib/streaming.ts +59 -0
  33. package/src/lib/telemetry-client.ts +3 -1
  34. package/src/service-adapters/events.ts +3 -3
  35. package/dist/chunk-L7OTGCAG.mjs.map +0 -1
  36. /package/dist/{chunk-5ZBUMQE2.mjs.map → chunk-2BN7NZNC.mjs.map} +0 -0
  37. /package/dist/{chunk-7BCFHZLY.mjs.map → chunk-PH24IU7T.mjs.map} +0 -0
  38. /package/dist/{chunk-4HQ5OZXN.mjs.map → chunk-ZYFN76KV.mjs.map} +0 -0
@@ -2,7 +2,7 @@ import {
2
2
  getCommonConfig,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-L7OTGCAG.mjs";
5
+ } from "./chunk-34Y5DNNJ.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-FHD4JECV.mjs";
@@ -77,4 +77,4 @@ export {
77
77
  config,
78
78
  copilotRuntimeNextJSPagesRouterEndpoint
79
79
  };
80
- //# sourceMappingURL=chunk-7BCFHZLY.mjs.map
80
+ //# sourceMappingURL=chunk-PH24IU7T.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-L7OTGCAG.mjs";
5
+ } from "./chunk-34Y5DNNJ.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-FHD4JECV.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
22
22
  export {
23
23
  copilotRuntimeNodeExpressEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-4HQ5OZXN.mjs.map
25
+ //# sourceMappingURL=chunk-ZYFN76KV.mjs.map
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ var require_package = __commonJS({
44
44
  publishConfig: {
45
45
  access: "public"
46
46
  },
47
- version: "1.6.0-next.9",
47
+ version: "1.7.0-next.0",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -1697,10 +1697,11 @@ var RemoteLangGraphEventSource = class {
1697
1697
  let isToolCallEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls";
1698
1698
  acc.isToolCallStart = toolCallChunks.some((chunk) => chunk.name && chunk.id);
1699
1699
  acc.isMessageStart = prevMessageId !== acc.lastMessageId && !acc.isToolCallStart;
1700
- if (acc.isToolCall && !toolCallCheck) {
1700
+ let previousRoundHadToolCall = acc.isToolCall;
1701
+ acc.isToolCall = toolCallCheck;
1702
+ if (previousRoundHadToolCall && !toolCallCheck) {
1701
1703
  isToolCallEnd = true;
1702
1704
  }
1703
- acc.isToolCall = toolCallCheck;
1704
1705
  acc.isToolCallEnd = isToolCallEnd;
1705
1706
  acc.isMessageEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop";
1706
1707
  ({ name: acc.lastToolCallName, id: acc.lastToolCallId } = toolCallChunks.find((chunk) => chunk.name && chunk.id) ?? {
@@ -1721,7 +1722,8 @@ var RemoteLangGraphEventSource = class {
1721
1722
  lastMessageId: null,
1722
1723
  lastToolCallId: null,
1723
1724
  lastToolCallName: null,
1724
- currentContent: null
1725
+ currentContent: null,
1726
+ processedToolCallIds: /* @__PURE__ */ new Set()
1725
1727
  }), (0, import_rxjs.mergeMap)((acc) => {
1726
1728
  const events = [];
1727
1729
  let shouldEmitMessages = true;
@@ -1749,7 +1751,8 @@ var RemoteLangGraphEventSource = class {
1749
1751
  });
1750
1752
  }
1751
1753
  const responseMetadata = this.getResponseMetadata(acc.event);
1752
- if (acc.isToolCallEnd && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)) {
1754
+ if (acc.isToolCallEnd && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName) && acc.lastToolCallId && !acc.processedToolCallIds.has(acc.lastToolCallId)) {
1755
+ acc.processedToolCallIds.add(acc.lastToolCallId);
1753
1756
  events.push({
1754
1757
  type: RuntimeEventTypes.ActionExecutionEnd,
1755
1758
  actionExecutionId: acc.lastToolCallId
@@ -1816,6 +1819,7 @@ var RemoteLangGraphEventSource = class {
1816
1819
  parentMessageId: acc.lastMessageId
1817
1820
  });
1818
1821
  } else if (acc.isMessageStart && shouldEmitMessages) {
1822
+ acc.processedToolCallIds.clear();
1819
1823
  events.push({
1820
1824
  type: RuntimeEventTypes.TextMessageStart,
1821
1825
  messageId: acc.lastMessageId
@@ -2633,7 +2637,7 @@ async function streamEvents(controller, args) {
2633
2637
  let emitIntermediateStateUntilEnd = null;
2634
2638
  let shouldExit = false;
2635
2639
  let externalRunId = null;
2636
- const streamResponse2 = client.runs.stream(threadId, assistantId, payload);
2640
+ const streamResponse = client.runs.stream(threadId, assistantId, payload);
2637
2641
  const emit = /* @__PURE__ */ __name((message) => controller.enqueue(new TextEncoder().encode(message)), "emit");
2638
2642
  let latestStateValues = {};
2639
2643
  let updatedState = state;
@@ -2643,7 +2647,7 @@ async function streamEvents(controller, args) {
2643
2647
  telemetry_client_default.capture("oss.runtime.agent_execution_stream_started", {
2644
2648
  hashedLgcKey: streamInfo.hashedLgcKey
2645
2649
  });
2646
- for await (const chunk of streamResponse2) {
2650
+ for await (const chunk of streamResponse) {
2647
2651
  if (![
2648
2652
  "events",
2649
2653
  "values",
@@ -3058,6 +3062,54 @@ __name(getSchemaKeys, "getSchemaKeys");
3058
3062
 
3059
3063
  // src/lib/runtime/remote-action-constructors.ts
3060
3064
  var import_shared13 = require("@copilotkit/shared");
3065
+
3066
+ // src/lib/streaming.ts
3067
+ async function writeJsonLineResponseToEventStream(response, eventStream$) {
3068
+ const reader = response.getReader();
3069
+ const decoder = new TextDecoder();
3070
+ let buffer = [];
3071
+ function flushBuffer() {
3072
+ const currentBuffer = buffer.join("");
3073
+ if (currentBuffer.trim().length === 0) {
3074
+ return;
3075
+ }
3076
+ const parts = currentBuffer.split("\n");
3077
+ if (parts.length === 0) {
3078
+ return;
3079
+ }
3080
+ const lastPartIsComplete = currentBuffer.endsWith("\n");
3081
+ buffer = [];
3082
+ if (!lastPartIsComplete) {
3083
+ buffer.push(parts.pop());
3084
+ }
3085
+ parts.map((part) => part.trim()).filter((part) => part != "").forEach((part) => {
3086
+ eventStream$.next(JSON.parse(part));
3087
+ });
3088
+ }
3089
+ __name(flushBuffer, "flushBuffer");
3090
+ try {
3091
+ while (true) {
3092
+ const { done, value } = await reader.read();
3093
+ if (!done) {
3094
+ buffer.push(decoder.decode(value, {
3095
+ stream: true
3096
+ }));
3097
+ }
3098
+ flushBuffer();
3099
+ if (done) {
3100
+ break;
3101
+ }
3102
+ }
3103
+ } catch (error) {
3104
+ console.error("Error in stream", error);
3105
+ eventStream$.error(error);
3106
+ return;
3107
+ }
3108
+ eventStream$.complete();
3109
+ }
3110
+ __name(writeJsonLineResponseToEventStream, "writeJsonLineResponseToEventStream");
3111
+
3112
+ // src/lib/runtime/remote-action-constructors.ts
3061
3113
  var import_shared14 = require("@copilotkit/shared");
3062
3114
  var import_shared15 = require("@copilotkit/shared");
3063
3115
  function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, messages, agentStates }) {
@@ -3067,7 +3119,7 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
3067
3119
  parameters: [],
3068
3120
  handler: async (_args) => {
3069
3121
  },
3070
- langGraphAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName, additionalMessages = [], metaEvents }) => {
3122
+ remoteAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName, additionalMessages = [], metaEvents }) => {
3071
3123
  logger2.debug({
3072
3124
  actionName: agent.name
3073
3125
  }, "Executing LangGraph Platform agent");
@@ -3111,7 +3163,7 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
3111
3163
  metaEvents
3112
3164
  });
3113
3165
  const eventSource = new RemoteLangGraphEventSource();
3114
- streamResponse(response, eventSource.eventStream$);
3166
+ writeJsonLineResponseToEventStream(response, eventSource.eventStream$);
3115
3167
  return eventSource.processLangGraphEvents();
3116
3168
  } catch (error) {
3117
3169
  logger2.error({
@@ -3128,6 +3180,11 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
3128
3180
  ];
3129
3181
  }
3130
3182
  __name(constructLGCRemoteAction, "constructLGCRemoteAction");
3183
+ var RemoteAgentType;
3184
+ (function(RemoteAgentType2) {
3185
+ RemoteAgentType2["LangGraph"] = "langgraph";
3186
+ RemoteAgentType2["CrewAI"] = "crewai";
3187
+ })(RemoteAgentType || (RemoteAgentType = {}));
3131
3188
  function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, logger: logger2, messages, agentStates }) {
3132
3189
  const totalAgents = Array.isArray(json["agents"]) ? json["agents"].length : 0;
3133
3190
  const actions = json["actions"].map((action) => ({
@@ -3197,7 +3254,7 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
3197
3254
  parameters: [],
3198
3255
  handler: async (_args) => {
3199
3256
  },
3200
- langGraphAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName, additionalMessages = [], metaEvents }) => {
3257
+ remoteAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName, additionalMessages = [], metaEvents }) => {
3201
3258
  logger2.debug({
3202
3259
  actionName: agent.name
3203
3260
  }, "Executing remote agent");
@@ -3257,9 +3314,17 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
3257
3314
  isRemoteEndpoint: true
3258
3315
  });
3259
3316
  }
3260
- const eventSource = new RemoteLangGraphEventSource();
3261
- streamResponse(response.body, eventSource.eventStream$);
3262
- return eventSource.processLangGraphEvents();
3317
+ if (agent.type === "langgraph") {
3318
+ const eventSource = new RemoteLangGraphEventSource();
3319
+ writeJsonLineResponseToEventStream(response.body, eventSource.eventStream$);
3320
+ return eventSource.processLangGraphEvents();
3321
+ } else if (agent.type === "crewai") {
3322
+ const eventStream$ = new RuntimeEventSubject();
3323
+ writeJsonLineResponseToEventStream(response.body, eventStream$);
3324
+ return eventStream$;
3325
+ } else {
3326
+ throw new Error("Unsupported agent type");
3327
+ }
3263
3328
  } catch (error) {
3264
3329
  if (error instanceof import_shared13.CopilotKitError) {
3265
3330
  throw error;
@@ -3277,50 +3342,6 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
3277
3342
  ];
3278
3343
  }
3279
3344
  __name(constructRemoteActions, "constructRemoteActions");
3280
- async function streamResponse(response, eventStream$) {
3281
- const reader = response.getReader();
3282
- const decoder = new TextDecoder();
3283
- let buffer = [];
3284
- function flushBuffer() {
3285
- const currentBuffer = buffer.join("");
3286
- if (currentBuffer.trim().length === 0) {
3287
- return;
3288
- }
3289
- const parts = currentBuffer.split("\n");
3290
- if (parts.length === 0) {
3291
- return;
3292
- }
3293
- const lastPartIsComplete = currentBuffer.endsWith("\n");
3294
- buffer = [];
3295
- if (!lastPartIsComplete) {
3296
- buffer.push(parts.pop());
3297
- }
3298
- parts.map((part) => part.trim()).filter((part) => part != "").forEach((part) => {
3299
- eventStream$.next(JSON.parse(part));
3300
- });
3301
- }
3302
- __name(flushBuffer, "flushBuffer");
3303
- try {
3304
- while (true) {
3305
- const { done, value } = await reader.read();
3306
- if (!done) {
3307
- buffer.push(decoder.decode(value, {
3308
- stream: true
3309
- }));
3310
- }
3311
- flushBuffer();
3312
- if (done) {
3313
- break;
3314
- }
3315
- }
3316
- } catch (error) {
3317
- console.error("Error in stream", error);
3318
- eventStream$.error(error);
3319
- return;
3320
- }
3321
- eventStream$.complete();
3322
- }
3323
- __name(streamResponse, "streamResponse");
3324
3345
  function createHeaders(onBeforeRequest, graphqlContext) {
3325
3346
  const headers = {
3326
3347
  "Content-Type": "application/json"
@@ -3344,13 +3365,13 @@ var EndpointType;
3344
3365
  EndpointType2["CopilotKit"] = "copilotKit";
3345
3366
  EndpointType2["LangGraphPlatform"] = "langgraph-platform";
3346
3367
  })(EndpointType || (EndpointType = {}));
3347
- function isLangGraphAgentAction(action) {
3368
+ function isRemoteAgentAction(action) {
3348
3369
  if (!action) {
3349
3370
  return false;
3350
3371
  }
3351
- return typeof action.langGraphAgentHandler === "function";
3372
+ return typeof action.remoteAgentHandler === "function";
3352
3373
  }
3353
- __name(isLangGraphAgentAction, "isLangGraphAgentAction");
3374
+ __name(isRemoteAgentAction, "isRemoteAgentAction");
3354
3375
  async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: logger2, frontendUrl }) {
3355
3376
  logger2.debug({
3356
3377
  url
@@ -3474,7 +3495,7 @@ function getRuntimeInstanceTelemetryInfo(runtime) {
3474
3495
  info = {
3475
3496
  ...info,
3476
3497
  agentsAmount: ep.agents.length,
3477
- hashedKey: (0, import_node_crypto3.createHash)("sha256").update(ep.langsmithApiKey).digest("hex")
3498
+ hashedKey: ep.langsmithApiKey ? (0, import_node_crypto3.createHash)("sha256").update(ep.langsmithApiKey).digest("hex") : null
3478
3499
  };
3479
3500
  }
3480
3501
  return info;
@@ -3854,7 +3875,7 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
3854
3875
  return;
3855
3876
  }
3856
3877
  }
3857
- if (isLangGraphAgentAction(action)) {
3878
+ if (isRemoteAgentAction(action)) {
3858
3879
  const result = `${action.name} agent started`;
3859
3880
  const agentExecution = (0, import_class_transformer.plainToInstance)(ActionExecutionMessage, {
3860
3881
  id: actionExecutionId,
@@ -3875,7 +3896,7 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
3875
3896
  actionName: action.name,
3876
3897
  result
3877
3898
  });
3878
- const stream = await action.langGraphAgentHandler({
3899
+ const stream = await action.remoteAgentHandler({
3879
3900
  name: action.name,
3880
3901
  threadId,
3881
3902
  actionInputsWithoutAgents,
@@ -3989,7 +4010,12 @@ var CopilotRuntime = class {
3989
4010
  delegateAgentProcessingToServiceAdapter;
3990
4011
  constructor(params) {
3991
4012
  var _a, _b;
3992
- this.actions = (params == null ? void 0 : params.actions) || [];
4013
+ if ((params == null ? void 0 : params.actions) && (params == null ? void 0 : params.remoteEndpoints)) {
4014
+ console.warn("Actions set in runtime instance will be ignored when remote endpoints are set");
4015
+ this.actions = [];
4016
+ } else {
4017
+ this.actions = (params == null ? void 0 : params.actions) || [];
4018
+ }
3993
4019
  for (const chain of (params == null ? void 0 : params.langserve) || []) {
3994
4020
  const remoteChain = new RemoteChain(chain);
3995
4021
  this.langserve.push(remoteChain.toAction());
@@ -4081,7 +4107,6 @@ please use an LLM adapter instead.`
4081
4107
  }
4082
4108
  }
4083
4109
  async discoverAgentsFromEndpoints(graphqlContext) {
4084
- const headers = createHeaders(null, graphqlContext);
4085
4110
  const agents = this.remoteEndpointDefinitions.reduce(async (acc, endpoint) => {
4086
4111
  const agents2 = await acc;
4087
4112
  if (endpoint.type === EndpointType.LangGraphPlatform) {
@@ -4107,11 +4132,12 @@ please use an LLM adapter instead.`
4107
4132
  ...endpointAgents
4108
4133
  ];
4109
4134
  }
4135
+ const cpkEndpoint = endpoint;
4110
4136
  const fetchUrl = `${endpoint.url}/info`;
4111
4137
  try {
4112
4138
  const response = await fetch(fetchUrl, {
4113
4139
  method: "POST",
4114
- headers,
4140
+ headers: createHeaders(cpkEndpoint.onBeforeRequest, graphqlContext),
4115
4141
  body: JSON.stringify({
4116
4142
  properties: graphqlContext.properties
4117
4143
  })
@@ -4192,11 +4218,12 @@ please use an LLM adapter instead.`
4192
4218
  };
4193
4219
  }
4194
4220
  } else if (agentWithEndpoint.endpoint.type === EndpointType.CopilotKit || !("type" in agentWithEndpoint.endpoint)) {
4195
- const fetchUrl = `${agentWithEndpoint.endpoint.url}/agents/state`;
4221
+ const cpkEndpoint = agentWithEndpoint.endpoint;
4222
+ const fetchUrl = `${cpkEndpoint.url}/agents/state`;
4196
4223
  try {
4197
4224
  const response = await fetch(fetchUrl, {
4198
4225
  method: "POST",
4199
- headers,
4226
+ headers: createHeaders(cpkEndpoint.onBeforeRequest, graphqlContext),
4200
4227
  body: JSON.stringify({
4201
4228
  properties: graphqlContext.properties,
4202
4229
  threadId,
@@ -4241,7 +4268,7 @@ please use an LLM adapter instead.`
4241
4268
  const threadId = threadIdFromRequest ?? agentSession.threadId;
4242
4269
  const serverSideActions = await this.getServerSideActions(request);
4243
4270
  const messages = convertGqlInputToMessages(rawMessages);
4244
- const currentAgent = serverSideActions.find((action) => action.name === agentName && isLangGraphAgentAction(action));
4271
+ const currentAgent = serverSideActions.find((action) => action.name === agentName && isRemoteAgentAction(action));
4245
4272
  if (!currentAgent) {
4246
4273
  throw new import_shared20.CopilotKitAgentDiscoveryError({
4247
4274
  agentName
@@ -4249,8 +4276,8 @@ please use an LLM adapter instead.`
4249
4276
  }
4250
4277
  const availableActionsForCurrentAgent = serverSideActions.filter((action) => (
4251
4278
  // Case 1: Keep all regular (non-agent) actions
4252
- !isLangGraphAgentAction(action) || // Case 2: For agent actions, keep all except self (prevent infinite loops)
4253
- isLangGraphAgentAction(action) && action.name !== agentName
4279
+ !isRemoteAgentAction(action) || // Case 2: For agent actions, keep all except self (prevent infinite loops)
4280
+ isRemoteAgentAction(action) && action.name !== agentName
4254
4281
  )).map((action) => ({
4255
4282
  name: action.name,
4256
4283
  description: action.description,
@@ -4268,7 +4295,7 @@ please use an LLM adapter instead.`
4268
4295
  }));
4269
4296
  try {
4270
4297
  const eventSource = new RuntimeEventSource();
4271
- const stream = await currentAgent.langGraphAgentHandler({
4298
+ const stream = await currentAgent.remoteAgentHandler({
4272
4299
  name: agentName,
4273
4300
  threadId,
4274
4301
  nodeName,
@@ -4372,7 +4399,7 @@ function langGraphPlatformEndpoint(config2) {
4372
4399
  __name(langGraphPlatformEndpoint, "langGraphPlatformEndpoint");
4373
4400
  function resolveEndpointType(endpoint) {
4374
4401
  if (!endpoint.type) {
4375
- if ("langsmithApiKey" in endpoint && "deploymentUrl" in endpoint && "agents" in endpoint) {
4402
+ if ("deploymentUrl" in endpoint && "agents" in endpoint) {
4376
4403
  return EndpointType.LangGraphPlatform;
4377
4404
  } else {
4378
4405
  return EndpointType.CopilotKit;
@@ -5361,6 +5388,9 @@ var CopilotResolver = class {
5361
5388
  resolveOutputMessagesPromise = resolve;
5362
5389
  rejectOutputMessagesPromise = reject;
5363
5390
  });
5391
+ if (copilotCloudPublicApiKey) {
5392
+ ctx.properties["copilotCloudPublicApiKey"] = copilotCloudPublicApiKey;
5393
+ }
5364
5394
  logger2.debug("Processing");
5365
5395
  const { eventSource, threadId = (0, import_shared21.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = await copilotRuntime.processRuntimeRequest({
5366
5396
  serviceAdapter,