@copilotkit/runtime 0.38.0-mme-alpha.0 → 1.0.0-beta.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 (51) hide show
  1. package/.turbo/turbo-build.log +41 -41
  2. package/CHANGELOG.md +10 -4
  3. package/dist/{chunk-6OJ47NCG.mjs → chunk-2PJG3NAC.mjs} +2 -2
  4. package/dist/{chunk-EWS5TMDA.mjs → chunk-6YGDE3YI.mjs} +91 -84
  5. package/dist/chunk-6YGDE3YI.mjs.map +1 -0
  6. package/dist/{chunk-XI3HBDMA.mjs → chunk-JBDOA7MK.mjs} +22 -11
  7. package/dist/chunk-JBDOA7MK.mjs.map +1 -0
  8. package/dist/{chunk-XXYCNRFT.mjs → chunk-JIKPSUGQ.mjs} +36 -69
  9. package/dist/chunk-JIKPSUGQ.mjs.map +1 -0
  10. package/dist/{index-d5ba24be.d.ts → index-0e75acd2.d.ts} +64 -38
  11. package/dist/index.d.ts +4 -4
  12. package/dist/index.js +163 -186
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.mjs +4 -10
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/{langchain-adapter-54784d29.d.ts → langchain-adapter-a02d1d38.d.ts} +4 -4
  17. package/dist/{langserve-63794237.d.ts → langserve-75ebbc38.d.ts} +1 -2
  18. package/dist/lib/index.d.ts +4 -4
  19. package/dist/lib/index.js +163 -186
  20. package/dist/lib/index.js.map +1 -1
  21. package/dist/lib/index.mjs +4 -10
  22. package/dist/lib/integrations/index.d.ts +3 -3
  23. package/dist/lib/integrations/index.js +118 -95
  24. package/dist/lib/integrations/index.js.map +1 -1
  25. package/dist/lib/integrations/index.mjs +2 -2
  26. package/dist/lib/integrations/node-http/index.d.ts +2 -2
  27. package/dist/lib/integrations/node-http/index.js +118 -95
  28. package/dist/lib/integrations/node-http/index.js.map +1 -1
  29. package/dist/lib/integrations/node-http/index.mjs +1 -1
  30. package/dist/{pages-router-d94f01da.d.ts → pages-router-e81920d5.d.ts} +1 -1
  31. package/dist/service-adapters/index.d.ts +2 -2
  32. package/dist/service-adapters/index.js +28 -17
  33. package/dist/service-adapters/index.js.map +1 -1
  34. package/dist/service-adapters/index.mjs +1 -1
  35. package/package.json +4 -4
  36. package/src/graphql/resolvers/copilot.resolver.ts +95 -24
  37. package/src/lib/copilot-runtime.ts +106 -36
  38. package/src/lib/index.ts +0 -1
  39. package/src/lib/integrations/shared.ts +1 -1
  40. package/src/service-adapters/experimental/groq/groq-adapter.ts +3 -1
  41. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +3 -1
  42. package/src/service-adapters/google/google-genai-adapter.ts +3 -1
  43. package/src/service-adapters/langchain/langchain-adapter.ts +8 -9
  44. package/src/service-adapters/openai/openai-adapter.ts +8 -7
  45. package/src/service-adapters/openai/openai-assistant-adapter.ts +6 -8
  46. package/src/service-adapters/service-adapter.ts +1 -2
  47. package/dist/chunk-EWS5TMDA.mjs.map +0 -1
  48. package/dist/chunk-XI3HBDMA.mjs.map +0 -1
  49. package/dist/chunk-XXYCNRFT.mjs.map +0 -1
  50. package/src/lib/copilot-cloud.ts +0 -63
  51. /package/dist/{chunk-6OJ47NCG.mjs.map → chunk-2PJG3NAC.mjs.map} +0 -0
@@ -1,5 +1,5 @@
1
1
 
2
- > @copilotkit/runtime@0.38.0-mme-alpha.0 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/runtime
2
+ > @copilotkit/runtime@1.0.0-beta.0 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/runtime
3
3
  > tsup --clean
4
4
 
5
5
  CLI Building entry: src/index.ts, src/lib/index.ts, src/service-adapters/index.ts, src/utils/index.ts, src/lib/cloud/index.ts, src/lib/integrations/index.ts, src/graphql/types/base/index.ts, src/graphql/types/converted/index.ts, src/lib/integrations/node-http/index.ts
@@ -10,76 +10,76 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  CJS Build start
13
- CJS dist/index.js 89.88 KB
14
- CJS dist/lib/index.js 89.52 KB
15
- CJS dist/service-adapters/index.js 32.32 KB
13
+ CJS dist/graphql/types/base/index.js 2.44 KB
14
+ CJS dist/graphql/types/converted/index.js 3.04 KB
15
+ CJS dist/index.js 90.21 KB
16
+ CJS dist/lib/index.js 89.86 KB
17
+ CJS dist/service-adapters/index.js 32.69 KB
16
18
  CJS dist/utils/index.js 6.32 KB
17
19
  CJS dist/lib/cloud/index.js 787.00 B
18
- CJS dist/lib/integrations/index.js 50.86 KB
19
- CJS dist/lib/integrations/node-http/index.js 49.19 KB
20
- CJS dist/graphql/types/converted/index.js 3.04 KB
21
- CJS dist/index.js.map 138.89 KB
22
- CJS dist/service-adapters/index.js.map 61.49 KB
23
- CJS dist/lib/index.js.map 139.27 KB
24
- CJS dist/lib/cloud/index.js.map 217.00 B
25
- CJS dist/utils/index.js.map 5.63 KB
26
- CJS dist/lib/integrations/index.js.map 60.77 KB
27
- CJS dist/lib/integrations/node-http/index.js.map 57.87 KB
28
- CJS dist/graphql/types/base/index.js 2.44 KB
29
- CJS dist/graphql/types/converted/index.js.map 1.76 KB
20
+ CJS dist/lib/integrations/index.js 52.20 KB
21
+ CJS dist/lib/integrations/node-http/index.js 50.54 KB
30
22
  CJS dist/graphql/types/base/index.js.map 645.00 B
31
- CJS ⚡️ Build success in 219ms
32
- ESM dist/lib/integrations/node-http/index.mjs 349.00 B
33
- ESM dist/index.mjs 1.33 KB
34
- ESM dist/lib/index.mjs 1.09 KB
23
+ CJS dist/graphql/types/converted/index.js.map 1.76 KB
24
+ CJS dist/index.js.map 141.53 KB
25
+ CJS dist/lib/index.js.map 141.87 KB
26
+ CJS dist/service-adapters/index.js.map 62.05 KB
27
+ CJS dist/utils/index.js.map 5.63 KB
28
+ CJS dist/lib/cloud/index.js.map 217.00 B
29
+ CJS dist/lib/integrations/index.js.map 64.90 KB
30
+ CJS dist/lib/integrations/node-http/index.js.map 61.99 KB
31
+ CJS ⚡️ Build success in 216ms
32
+ ESM dist/index.mjs 1.22 KB
33
+ ESM dist/lib/index.mjs 1007.00 B
35
34
  ESM dist/service-adapters/index.mjs 427.00 B
36
- ESM dist/chunk-XXYCNRFT.mjs 5.50 KB
37
- ESM dist/chunk-XI3HBDMA.mjs 20.99 KB
38
35
  ESM dist/utils/index.mjs 315.00 B
39
36
  ESM dist/lib/cloud/index.mjs 34.00 B
40
37
  ESM dist/lib/integrations/index.mjs 664.00 B
41
- ESM dist/chunk-6OJ47NCG.mjs 1.41 KB
42
- ESM dist/chunk-EWS5TMDA.mjs 43.25 KB
38
+ ESM dist/chunk-JIKPSUGQ.mjs 4.67 KB
39
+ ESM dist/chunk-JBDOA7MK.mjs 21.31 KB
40
+ ESM dist/chunk-2PJG3NAC.mjs 1.41 KB
41
+ ESM dist/chunk-6YGDE3YI.mjs 44.14 KB
43
42
  ESM dist/chunk-FRK6BXXV.mjs 7.85 KB
44
43
  ESM dist/chunk-BYB2LNMK.mjs 4.91 KB
45
44
  ESM dist/chunk-OZMCHYYR.mjs 645.00 B
46
45
  ESM dist/chunk-6NZ4UMOD.mjs 1.36 KB
47
46
  ESM dist/chunk-RHQLCJGG.mjs 194.00 B
48
- ESM dist/lib/integrations/node-http/index.mjs.map 71.00 B
49
- ESM dist/index.mjs.map 219.00 B
47
+ ESM dist/lib/integrations/node-http/index.mjs 349.00 B
48
+ ESM dist/index.mjs.map 216.00 B
50
49
  ESM dist/lib/index.mjs.map 71.00 B
51
50
  ESM dist/service-adapters/index.mjs.map 71.00 B
52
- ESM dist/chunk-XXYCNRFT.mjs.map 14.96 KB
53
- ESM dist/chunk-XI3HBDMA.mjs.map 44.81 KB
54
51
  ESM dist/utils/index.mjs.map 71.00 B
55
- ESM dist/lib/integrations/index.mjs.map 71.00 B
56
52
  ESM dist/lib/cloud/index.mjs.map 71.00 B
57
- ESM dist/chunk-EWS5TMDA.mjs.map 55.37 KB
53
+ ESM dist/lib/integrations/index.mjs.map 71.00 B
54
+ ESM dist/graphql/types/base/index.mjs 159.00 B
55
+ ESM dist/chunk-JIKPSUGQ.mjs.map 13.94 KB
56
+ ESM dist/chunk-JBDOA7MK.mjs.map 45.36 KB
57
+ ESM dist/chunk-2PJG3NAC.mjs.map 2.79 KB
58
+ ESM dist/chunk-6YGDE3YI.mjs.map 58.33 KB
58
59
  ESM dist/chunk-FRK6BXXV.mjs.map 14.76 KB
59
- ESM dist/chunk-6OJ47NCG.mjs.map 2.79 KB
60
60
  ESM dist/chunk-BYB2LNMK.mjs.map 5.63 KB
61
- ESM dist/chunk-6NZ4UMOD.mjs.map 645.00 B
62
61
  ESM dist/chunk-OZMCHYYR.mjs.map 1.18 KB
62
+ ESM dist/chunk-6NZ4UMOD.mjs.map 645.00 B
63
63
  ESM dist/chunk-RHQLCJGG.mjs.map 71.00 B
64
- ESM dist/graphql/types/base/index.mjs 159.00 B
65
64
  ESM dist/graphql/types/converted/index.mjs 283.00 B
65
+ ESM dist/lib/integrations/node-http/index.mjs.map 71.00 B
66
66
  ESM dist/graphql/types/base/index.mjs.map 71.00 B
67
67
  ESM dist/graphql/types/converted/index.mjs.map 71.00 B
68
- ESM ⚡️ Build success in 220ms
68
+ ESM ⚡️ Build success in 219ms
69
69
  DTS Build start
70
- DTS ⚡️ Build success in 7728ms
71
- DTS dist/index.d.ts 1.42 KB
70
+ DTS ⚡️ Build success in 7048ms
71
+ DTS dist/index.d.ts 1.28 KB
72
72
  DTS dist/lib/cloud/index.d.ts 116.00 B
73
73
  DTS dist/graphql/types/base/index.d.ts 92.00 B
74
- DTS dist/lib/index.d.ts 1.25 KB
74
+ DTS dist/lib/index.d.ts 1.11 KB
75
75
  DTS dist/service-adapters/index.d.ts 543.00 B
76
76
  DTS dist/utils/index.d.ts 172.00 B
77
77
  DTS dist/lib/integrations/index.d.ts 688.00 B
78
78
  DTS dist/lib/integrations/node-http/index.d.ts 338.00 B
79
79
  DTS dist/graphql/types/converted/index.d.ts 153.00 B
80
- DTS dist/index-d5ba24be.d.ts 7.31 KB
81
- DTS dist/langchain-adapter-54784d29.d.ts 5.87 KB
82
- DTS dist/pages-router-d94f01da.d.ts 891.00 B
80
+ DTS dist/index-0e75acd2.d.ts 7.66 KB
81
+ DTS dist/langchain-adapter-a02d1d38.d.ts 5.74 KB
82
+ DTS dist/pages-router-e81920d5.d.ts 891.00 B
83
83
  DTS dist/failed-response-status-reasons-0ab19e06.d.ts 1.41 KB
84
- DTS dist/langserve-63794237.d.ts 3.62 KB
84
+ DTS dist/langserve-75ebbc38.d.ts 3.59 KB
85
85
  DTS dist/index-aa091e3c.d.ts 1.33 KB
package/CHANGELOG.md CHANGED
@@ -1,12 +1,18 @@
1
1
  # @copilotkit/runtime
2
2
 
3
- ## 0.38.0-mme-alpha.0
3
+ ## 1.0.0-beta.0
4
4
 
5
- ### Minor Changes
5
+ ### Major Changes
6
6
 
7
- - GraphQL based protocol
7
+ - V1.0 Release Candidate
8
+
9
+ - A robust new protocol between the frontend and the Copilot Runtime
10
+ - Support for Copilot Cloud
11
+ - Generative UI
12
+ - Support for LangChain universal tool calling
13
+ - OpenAI assistant API streaming
8
14
 
9
15
  ### Patch Changes
10
16
 
11
17
  - Updated dependencies
12
- - @copilotkit/shared@0.38.0-mme-alpha.0
18
+ - @copilotkit/shared@1.0.0-beta.0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getCommonConfig
3
- } from "./chunk-EWS5TMDA.mjs";
3
+ } from "./chunk-6YGDE3YI.mjs";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-RHQLCJGG.mjs";
@@ -51,4 +51,4 @@ export {
51
51
  config,
52
52
  copilotRuntimeNextJSPagesRouterEndpoint
53
53
  };
54
- //# sourceMappingURL=chunk-6OJ47NCG.mjs.map
54
+ //# sourceMappingURL=chunk-2PJG3NAC.mjs.map
@@ -8,6 +8,11 @@ import {
8
8
  SuccessResponseStatus,
9
9
  UnknownErrorResponse
10
10
  } from "./chunk-BYB2LNMK.mjs";
11
+ import {
12
+ ActionExecutionMessage,
13
+ ResultMessage,
14
+ TextMessage
15
+ } from "./chunk-OZMCHYYR.mjs";
11
16
  import {
12
17
  BaseMessage
13
18
  } from "./chunk-6NZ4UMOD.mjs";
@@ -765,9 +770,7 @@ __name(executeAction, "executeAction");
765
770
  // src/graphql/resolvers/copilot.resolver.ts
766
771
  import { GraphQLJSONObject } from "graphql-scalars";
767
772
  import { plainToInstance } from "class-transformer";
768
-
769
- // src/graphql/types/guardrails-result.type.ts
770
- import { Field as Field9, ObjectType as ObjectType3, registerEnumType as registerEnumType3 } from "type-graphql";
773
+ import { GraphQLError } from "graphql";
771
774
  function _ts_decorate9(decorators, target, key, desc) {
772
775
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
773
776
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -784,59 +787,13 @@ function _ts_metadata9(k, v) {
784
787
  return Reflect.metadata(k, v);
785
788
  }
786
789
  __name(_ts_metadata9, "_ts_metadata");
787
- var GuardrailsResultStatus;
788
- (function(GuardrailsResultStatus2) {
789
- GuardrailsResultStatus2["ALLOWED"] = "allowed";
790
- GuardrailsResultStatus2["DENIED"] = "denied";
791
- })(GuardrailsResultStatus || (GuardrailsResultStatus = {}));
792
- registerEnumType3(GuardrailsResultStatus, {
793
- name: "GuardrailsResultStatus",
794
- description: "The status of the guardrails check"
795
- });
796
- var GuardrailsResult = class {
797
- status;
798
- reason;
799
- };
800
- __name(GuardrailsResult, "GuardrailsResult");
801
- _ts_decorate9([
802
- Field9(() => GuardrailsResultStatus),
803
- _ts_metadata9("design:type", String)
804
- ], GuardrailsResult.prototype, "status", void 0);
805
- _ts_decorate9([
806
- Field9(() => String, {
807
- nullable: true
808
- }),
809
- _ts_metadata9("design:type", String)
810
- ], GuardrailsResult.prototype, "reason", void 0);
811
- GuardrailsResult = _ts_decorate9([
812
- ObjectType3()
813
- ], GuardrailsResult);
814
-
815
- // src/graphql/resolvers/copilot.resolver.ts
816
- import { GraphQLError } from "graphql";
817
- function _ts_decorate10(decorators, target, key, desc) {
818
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
819
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
820
- r = Reflect.decorate(decorators, target, key, desc);
821
- else
822
- for (var i = decorators.length - 1; i >= 0; i--)
823
- if (d = decorators[i])
824
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
825
- return c > 3 && r && Object.defineProperty(target, key, r), r;
826
- }
827
- __name(_ts_decorate10, "_ts_decorate");
828
- function _ts_metadata10(k, v) {
829
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
830
- return Reflect.metadata(k, v);
831
- }
832
- __name(_ts_metadata10, "_ts_metadata");
833
790
  function _ts_param(paramIndex, decorator) {
834
791
  return function(target, key) {
835
792
  decorator(target, key, paramIndex);
836
793
  };
837
794
  }
838
795
  __name(_ts_param, "_ts_param");
839
- var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPublicApiKey, data, logger: logger2, onResult }) => {
796
+ var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPublicApiKey, data, onResult, onError }) => {
840
797
  var _a;
841
798
  if (data.messages.length && ((_a = data.messages[data.messages.length - 1].textMessage) == null ? void 0 : _a.role) === MessageRole.user) {
842
799
  const messages = data.messages.filter((m) => m.textMessage !== void 0 && (m.textMessage.role === MessageRole.user || m.textMessage.role === MessageRole.assistant)).map((m) => ({
@@ -859,18 +816,12 @@ var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPubl
859
816
  },
860
817
  body: JSON.stringify(body)
861
818
  });
862
- const responseBody = await guardrailsResult.json();
863
- if (!guardrailsResult.ok) {
864
- logger2.error({
865
- error: responseBody
866
- }, "Failed to invoke guardrails");
867
- throw new GraphQLError("Failed to invoke guardrails");
819
+ if (guardrailsResult.ok) {
820
+ const resultJson = await guardrailsResult.json();
821
+ onResult(resultJson);
822
+ } else {
823
+ onError(await guardrailsResult.json());
868
824
  }
869
- onResult(responseBody);
870
- } else {
871
- onResult({
872
- status: GuardrailsResultStatus.ALLOWED
873
- });
874
825
  }
875
826
  }, "invokeGuardrails");
876
827
  var CopilotResolver = class {
@@ -923,6 +874,13 @@ var CopilotResolver = class {
923
874
  const responseStatus$ = new ReplaySubject2();
924
875
  const interruptStreaming$ = new ReplaySubject2();
925
876
  const guardrailsResult$ = new ReplaySubject2();
877
+ let outputMessages = [];
878
+ let resolveOutputMessagesPromise;
879
+ let rejectOutputMessagesPromise;
880
+ const outputMessagesPromise = new Promise((resolve, reject) => {
881
+ resolveOutputMessagesPromise = resolve;
882
+ rejectOutputMessagesPromise = reject;
883
+ });
926
884
  logger2.debug("Processing");
927
885
  const { eventSource, threadId = nanoid(), runId, actions } = await copilotRuntime.process({
928
886
  serviceAdapter,
@@ -930,7 +888,9 @@ var CopilotResolver = class {
930
888
  actions: data.frontend.actions,
931
889
  threadId: data.threadId,
932
890
  runId: data.runId,
933
- publicApiKey: void 0
891
+ publicApiKey: void 0,
892
+ properties: ctx.properties || {},
893
+ outputMessagesPromise
934
894
  });
935
895
  logger2.debug("Event source created, creating response");
936
896
  const response = {
@@ -949,7 +909,6 @@ var CopilotResolver = class {
949
909
  baseUrl: copilotCloudBaseUrl,
950
910
  copilotCloudPublicApiKey,
951
911
  data,
952
- logger: logger2,
953
912
  onResult: (result) => {
954
913
  logger2.debug({
955
914
  status: result.status
@@ -962,21 +921,41 @@ var CopilotResolver = class {
962
921
  interruptStreaming$.next({
963
922
  reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
964
923
  });
924
+ outputMessages = [
925
+ plainToInstance(TextMessage, {
926
+ id: nanoid(),
927
+ createdAt: /* @__PURE__ */ new Date(),
928
+ content: result.reason,
929
+ role: MessageRole.assistant
930
+ })
931
+ ];
932
+ resolveOutputMessagesPromise(outputMessages);
965
933
  }
934
+ },
935
+ onError: (err) => {
936
+ logger2.error({
937
+ err
938
+ }, "Error in guardrails validation");
939
+ responseStatus$.next(new UnknownErrorResponse({
940
+ description: `An unknown error has occurred in the guardrails validation`
941
+ }));
942
+ interruptStreaming$.next({
943
+ reason: `Interrupted due to unknown error in guardrails validation`
944
+ });
945
+ rejectOutputMessagesPromise(err);
966
946
  }
967
947
  });
968
948
  }
969
949
  let eventStreamSubscription;
970
950
  const eventStream = eventSource.process({
971
- serversideActions: copilotRuntime.actions,
951
+ serversideActions: actions,
972
952
  guardrailsResult$: ((_b = data.cloud) == null ? void 0 : _b.guardrails) ? guardrailsResult$ : null
973
953
  }).pipe(
974
954
  // shareReplay() ensures that later subscribers will see the whole stream instead of
975
955
  // just the events that were emitted after the subscriber was added.
976
956
  shareReplay(),
977
957
  finalize(() => {
978
- logger2.debug("Event stream finalized, stopping streaming messages");
979
- stopStreamingMessages();
958
+ logger2.debug("Event stream finalized");
980
959
  })
981
960
  );
982
961
  logger2.debug("Event stream created, subscribing to event stream");
@@ -999,6 +978,7 @@ var CopilotResolver = class {
999
978
  role: MessageRole.assistant,
1000
979
  content: new Repeater(async (pushTextChunk, stopStreamingText) => {
1001
980
  logger2.debug("Text message content repeater created");
981
+ const textChunks = [];
1002
982
  let textSubscription;
1003
983
  interruptStreaming$.pipe(shareReplay(), take(1), tap(({ reason, messageId: messageId2 }) => {
1004
984
  logger2.debug({
@@ -1012,13 +992,14 @@ var CopilotResolver = class {
1012
992
  messageId: messageId2
1013
993
  }));
1014
994
  stopStreamingText();
1015
- textSubscription.unsubscribe();
995
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
1016
996
  })).subscribe();
1017
997
  logger2.debug("Subscribing to text message content stream");
1018
998
  textSubscription = textMessageContentStream.subscribe({
1019
999
  next: async (e) => {
1020
1000
  if (e.type == RuntimeEventTypes.TextMessageContent) {
1021
1001
  await pushTextChunk(e.content);
1002
+ textChunks.push(e.content);
1022
1003
  }
1023
1004
  },
1024
1005
  error: (err) => {
@@ -1030,13 +1011,19 @@ var CopilotResolver = class {
1030
1011
  messageId
1031
1012
  });
1032
1013
  stopStreamingText();
1033
- textSubscription.unsubscribe();
1014
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
1034
1015
  },
1035
1016
  complete: () => {
1036
1017
  logger2.debug("Text message content stream completed");
1037
1018
  streamingTextStatus.next(new SuccessMessageStatus());
1038
1019
  stopStreamingText();
1039
- textSubscription.unsubscribe();
1020
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
1021
+ outputMessages.push(plainToInstance(TextMessage, {
1022
+ id: messageId,
1023
+ createdAt: /* @__PURE__ */ new Date(),
1024
+ content: textChunks.join(""),
1025
+ role: MessageRole.assistant
1026
+ }));
1040
1027
  }
1041
1028
  });
1042
1029
  })
@@ -1054,11 +1041,13 @@ var CopilotResolver = class {
1054
1041
  scope: event.scope,
1055
1042
  arguments: new Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
1056
1043
  logger2.debug("Action execution argument stream created");
1044
+ const argumentChunks = [];
1057
1045
  let actionExecutionArgumentSubscription;
1058
1046
  actionExecutionArgumentSubscription = actionExecutionArgumentStream.subscribe({
1059
1047
  next: async (e) => {
1060
1048
  if (e.type == RuntimeEventTypes.ActionExecutionArgs) {
1061
1049
  await pushArgumentsChunk(e.args);
1050
+ argumentChunks.push(e.args);
1062
1051
  }
1063
1052
  },
1064
1053
  error: (err) => {
@@ -1069,20 +1058,29 @@ var CopilotResolver = class {
1069
1058
  reason: "An unknown error has occurred in the action execution argument stream"
1070
1059
  }));
1071
1060
  stopStreamingArguments();
1072
- actionExecutionArgumentSubscription.unsubscribe();
1061
+ actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
1073
1062
  },
1074
1063
  complete: () => {
1075
1064
  logger2.debug("Action execution argument stream completed");
1076
1065
  streamingArgumentsStatus.next(new SuccessMessageStatus());
1077
1066
  stopStreamingArguments();
1078
- actionExecutionArgumentSubscription.unsubscribe();
1067
+ actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
1068
+ outputMessages.push(plainToInstance(ActionExecutionMessage, {
1069
+ id: event.actionExecutionId,
1070
+ createdAt: /* @__PURE__ */ new Date(),
1071
+ name: event.actionName,
1072
+ scope: event.scope,
1073
+ arguments: argumentChunks.join("")
1074
+ }));
1079
1075
  }
1080
1076
  });
1081
1077
  })
1082
1078
  });
1083
1079
  break;
1084
1080
  case RuntimeEventTypes.ActionExecutionResult:
1085
- logger2.debug("Action execution result event received");
1081
+ logger2.debug({
1082
+ result: event.result
1083
+ }, "Action execution result event received");
1086
1084
  pushMessage({
1087
1085
  id: nanoid(),
1088
1086
  status: new SuccessMessageStatus(),
@@ -1091,6 +1089,13 @@ var CopilotResolver = class {
1091
1089
  actionName: event.actionName,
1092
1090
  result: event.result
1093
1091
  });
1092
+ outputMessages.push(plainToInstance(ResultMessage, {
1093
+ id: nanoid(),
1094
+ createdAt: /* @__PURE__ */ new Date(),
1095
+ actionExecutionId: event.actionExecutionId,
1096
+ actionName: event.actionName,
1097
+ result: event.result
1098
+ }));
1094
1099
  break;
1095
1100
  }
1096
1101
  },
@@ -1101,8 +1106,9 @@ var CopilotResolver = class {
1101
1106
  responseStatus$.next(new UnknownErrorResponse({
1102
1107
  description: `An unknown error has occurred in the event stream`
1103
1108
  }));
1104
- eventStreamSubscription.unsubscribe();
1109
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
1105
1110
  stopStreamingMessages();
1111
+ rejectOutputMessagesPromise(err);
1106
1112
  },
1107
1113
  complete: async () => {
1108
1114
  var _a2;
@@ -1112,8 +1118,9 @@ var CopilotResolver = class {
1112
1118
  await firstValueFrom2(guardrailsResult$);
1113
1119
  }
1114
1120
  responseStatus$.next(new SuccessResponseStatus());
1115
- eventStreamSubscription.unsubscribe();
1121
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
1116
1122
  stopStreamingMessages();
1123
+ resolveOutputMessagesPromise(outputMessages);
1117
1124
  }
1118
1125
  });
1119
1126
  })
@@ -1122,28 +1129,28 @@ var CopilotResolver = class {
1122
1129
  }
1123
1130
  };
1124
1131
  __name(CopilotResolver, "CopilotResolver");
1125
- _ts_decorate10([
1132
+ _ts_decorate9([
1126
1133
  Query(() => String),
1127
- _ts_metadata10("design:type", Function),
1128
- _ts_metadata10("design:paramtypes", []),
1129
- _ts_metadata10("design:returntype", Promise)
1134
+ _ts_metadata9("design:type", Function),
1135
+ _ts_metadata9("design:paramtypes", []),
1136
+ _ts_metadata9("design:returntype", Promise)
1130
1137
  ], CopilotResolver.prototype, "hello", null);
1131
- _ts_decorate10([
1138
+ _ts_decorate9([
1132
1139
  Mutation(() => CopilotResponse),
1133
1140
  _ts_param(0, Ctx()),
1134
1141
  _ts_param(1, Arg("data")),
1135
1142
  _ts_param(2, Arg("properties", () => GraphQLJSONObject, {
1136
1143
  nullable: true
1137
1144
  })),
1138
- _ts_metadata10("design:type", Function),
1139
- _ts_metadata10("design:paramtypes", [
1145
+ _ts_metadata9("design:type", Function),
1146
+ _ts_metadata9("design:paramtypes", [
1140
1147
  typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
1141
1148
  typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
1142
1149
  typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
1143
1150
  ]),
1144
- _ts_metadata10("design:returntype", Promise)
1151
+ _ts_metadata9("design:returntype", Promise)
1145
1152
  ], CopilotResolver.prototype, "generateCopilotResponse", null);
1146
- CopilotResolver = _ts_decorate10([
1153
+ CopilotResolver = _ts_decorate9([
1147
1154
  Resolver(() => CopilotResponse)
1148
1155
  ], CopilotResolver);
1149
1156
 
@@ -1253,4 +1260,4 @@ export {
1253
1260
  getCommonConfig,
1254
1261
  copilotRuntimeNodeHttpEndpoint
1255
1262
  };
1256
- //# sourceMappingURL=chunk-EWS5TMDA.mjs.map
1263
+ //# sourceMappingURL=chunk-6YGDE3YI.mjs.map