@copilotkit/runtime 1.1.3-feat-runtime-remote-actions.2 → 1.2.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 +5 -18
  2. package/__snapshots__/schema/schema.graphql +0 -41
  3. package/dist/{chunk-JYLUCJP7.mjs → chunk-3MYGPMKL.mjs} +2 -2
  4. package/dist/{chunk-7FSNQXPE.mjs → chunk-3TQLJ3YL.mjs} +158 -786
  5. package/dist/chunk-3TQLJ3YL.mjs.map +1 -0
  6. package/dist/{chunk-BJ2LVHWA.mjs → chunk-736EEICU.mjs} +3 -3
  7. package/dist/{chunk-TBZGOJJX.mjs → chunk-GEIBJJQ4.mjs} +2 -14
  8. package/dist/chunk-GEIBJJQ4.mjs.map +1 -0
  9. package/dist/{chunk-WRPRFRSL.mjs → chunk-HCUZC4GO.mjs} +2 -2
  10. package/dist/chunk-MHLJQ2RF.mjs +158 -0
  11. package/dist/chunk-MHLJQ2RF.mjs.map +1 -0
  12. package/dist/{chunk-73NMP3DI.mjs → chunk-URMISMK2.mjs} +2 -2
  13. package/dist/{chunk-W7RRKPE2.mjs → chunk-ZHFBLKC3.mjs} +2 -2
  14. package/dist/graphql/types/converted/index.d.ts +1 -1
  15. package/dist/graphql/types/converted/index.js +0 -13
  16. package/dist/graphql/types/converted/index.js.map +1 -1
  17. package/dist/graphql/types/converted/index.mjs +1 -3
  18. package/dist/{index-079752b9.d.ts → index-13aa818e.d.ts} +1 -1
  19. package/dist/{index-0476e4f7.d.ts → index-aa091e3c.d.ts} +2 -24
  20. package/dist/index.d.ts +7 -7
  21. package/dist/index.js +245 -982
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +8 -8
  24. package/dist/{langserve-d6073a3b.d.ts → langserve-a54438c6.d.ts} +11 -24
  25. package/dist/lib/index.d.ts +7 -7
  26. package/dist/lib/index.js +245 -982
  27. package/dist/lib/index.js.map +1 -1
  28. package/dist/lib/index.mjs +8 -8
  29. package/dist/lib/integrations/index.d.ts +6 -6
  30. package/dist/lib/integrations/index.js +182 -437
  31. package/dist/lib/integrations/index.js.map +1 -1
  32. package/dist/lib/integrations/index.mjs +6 -6
  33. package/dist/lib/integrations/nest/index.d.ts +5 -5
  34. package/dist/lib/integrations/nest/index.js +182 -437
  35. package/dist/lib/integrations/nest/index.js.map +1 -1
  36. package/dist/lib/integrations/nest/index.mjs +4 -4
  37. package/dist/lib/integrations/node-express/index.d.ts +5 -5
  38. package/dist/lib/integrations/node-express/index.js +182 -437
  39. package/dist/lib/integrations/node-express/index.js.map +1 -1
  40. package/dist/lib/integrations/node-express/index.mjs +4 -4
  41. package/dist/lib/integrations/node-http/index.d.ts +5 -5
  42. package/dist/lib/integrations/node-http/index.js +182 -437
  43. package/dist/lib/integrations/node-http/index.js.map +1 -1
  44. package/dist/lib/integrations/node-http/index.mjs +3 -3
  45. package/dist/service-adapters/index.d.ts +3 -3
  46. package/dist/service-adapters/index.js.map +1 -1
  47. package/dist/service-adapters/index.mjs +3 -3
  48. package/dist/{copilot-runtime-d427e991.d.ts → shared-c5362338.d.ts} +38 -65
  49. package/package.json +5 -7
  50. package/src/graphql/inputs/generate-copilot-response.input.ts +0 -11
  51. package/src/graphql/inputs/message.input.ts +0 -30
  52. package/src/graphql/resolvers/copilot.resolver.ts +12 -56
  53. package/src/graphql/types/converted/index.ts +0 -15
  54. package/src/graphql/types/copilot-response.type.ts +0 -29
  55. package/src/graphql/types/enums.ts +0 -1
  56. package/src/lib/copilot-runtime.ts +231 -0
  57. package/src/lib/index.ts +1 -1
  58. package/src/lib/integrations/shared.ts +1 -1
  59. package/src/service-adapters/conversion.ts +0 -16
  60. package/src/service-adapters/events.ts +19 -101
  61. package/dist/chunk-5TYP4A3G.mjs +0 -260
  62. package/dist/chunk-5TYP4A3G.mjs.map +0 -1
  63. package/dist/chunk-7FSNQXPE.mjs.map +0 -1
  64. package/dist/chunk-TBZGOJJX.mjs.map +0 -1
  65. package/src/agents/langgraph/event-source.ts +0 -222
  66. package/src/agents/langgraph/events.ts +0 -309
  67. package/src/graphql/inputs/agent-session.input.ts +0 -13
  68. package/src/graphql/inputs/agent-state.input.ts +0 -10
  69. package/src/lib/runtime/copilot-runtime.ts +0 -360
  70. package/src/lib/runtime/remote-actions.ts +0 -241
  71. /package/dist/{chunk-JYLUCJP7.mjs.map → chunk-3MYGPMKL.mjs.map} +0 -0
  72. /package/dist/{chunk-BJ2LVHWA.mjs.map → chunk-736EEICU.mjs.map} +0 -0
  73. /package/dist/{chunk-WRPRFRSL.mjs.map → chunk-HCUZC4GO.mjs.map} +0 -0
  74. /package/dist/{chunk-73NMP3DI.mjs.map → chunk-URMISMK2.mjs.map} +0 -0
  75. /package/dist/{chunk-W7RRKPE2.mjs.map → chunk-ZHFBLKC3.mjs.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  streamLangChainResponse
3
- } from "./chunk-73NMP3DI.mjs";
3
+ } from "./chunk-URMISMK2.mjs";
4
4
  import {
5
5
  GuardrailsValidationFailureResponse,
6
6
  MessageStreamInterruptedResponse,
@@ -10,10 +10,9 @@ import {
10
10
  } from "./chunk-U3V2BCGI.mjs";
11
11
  import {
12
12
  ActionExecutionMessage,
13
- AgentStateMessage,
14
13
  ResultMessage,
15
14
  TextMessage
16
- } from "./chunk-TBZGOJJX.mjs";
15
+ } from "./chunk-GEIBJJQ4.mjs";
17
16
  import {
18
17
  BaseMessage
19
18
  } from "./chunk-RMZWGQ46.mjs";
@@ -36,7 +35,7 @@ var require_package = __commonJS({
36
35
  publishConfig: {
37
36
  access: "public"
38
37
  },
39
- version: "1.1.3-feat-runtime-remote-actions.2",
38
+ version: "1.2.0",
40
39
  sideEffects: false,
41
40
  main: "./dist/index.js",
42
41
  module: "./dist/index.mjs",
@@ -51,9 +50,7 @@ var require_package = __commonJS({
51
50
  test: "jest --passWithNoTests",
52
51
  "check-types": "tsc --noEmit",
53
52
  clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next && rm -rf __snapshots__",
54
- "generate-graphql-schema": "rm -rf __snapshots__ && ts-node ./scripts/generate-gql-schema.ts",
55
- "link:global": "pnpm link --global",
56
- "unlink:global": "pnpm unlink --global"
53
+ "generate-graphql-schema": "rm -rf __snapshots__ && ts-node ./scripts/generate-gql-schema.ts"
57
54
  },
58
55
  devDependencies: {
59
56
  "@swc/core": "1.5.28",
@@ -117,10 +114,10 @@ import { buildSchemaSync } from "type-graphql";
117
114
 
118
115
  // src/graphql/resolvers/copilot.resolver.ts
119
116
  import { Arg, Ctx, Mutation, Query, Resolver } from "type-graphql";
120
- import { ReplaySubject as ReplaySubject3, Subject, finalize, firstValueFrom as firstValueFrom2, shareReplay, skipWhile, take, takeWhile, tap } from "rxjs";
117
+ import { ReplaySubject as ReplaySubject2, Subject, finalize, firstValueFrom as firstValueFrom2, shareReplay, skipWhile, take, takeWhile, tap } from "rxjs";
121
118
 
122
119
  // src/graphql/inputs/generate-copilot-response.input.ts
123
- import { Field as Field9, InputType as InputType9 } from "type-graphql";
120
+ import { Field as Field7, InputType as InputType7 } from "type-graphql";
124
121
 
125
122
  // src/graphql/inputs/message.input.ts
126
123
  import { Field, InputType } from "type-graphql";
@@ -137,7 +134,6 @@ var ActionExecutionScope;
137
134
  (function(ActionExecutionScope2) {
138
135
  ActionExecutionScope2["server"] = "server";
139
136
  ActionExecutionScope2["client"] = "client";
140
- ActionExecutionScope2["passThrough"] = "passThrough";
141
137
  })(ActionExecutionScope || (ActionExecutionScope = {}));
142
138
  var CopilotRequestType;
143
139
  (function(CopilotRequestType2) {
@@ -181,7 +177,6 @@ var MessageInput = class extends BaseMessage {
181
177
  textMessage;
182
178
  actionExecutionMessage;
183
179
  resultMessage;
184
- agentStateMessage;
185
180
  };
186
181
  __name(MessageInput, "MessageInput");
187
182
  _ts_decorate([
@@ -202,12 +197,6 @@ _ts_decorate([
202
197
  }),
203
198
  _ts_metadata("design:type", typeof ResultMessageInput === "undefined" ? Object : ResultMessageInput)
204
199
  ], MessageInput.prototype, "resultMessage", void 0);
205
- _ts_decorate([
206
- Field(() => AgentStateMessageInput, {
207
- nullable: true
208
- }),
209
- _ts_metadata("design:type", typeof AgentStateMessageInput === "undefined" ? Object : AgentStateMessageInput)
210
- ], MessageInput.prototype, "agentStateMessage", void 0);
211
200
  MessageInput = _ts_decorate([
212
201
  InputType()
213
202
  ], MessageInput);
@@ -269,52 +258,6 @@ _ts_decorate([
269
258
  ResultMessageInput = _ts_decorate([
270
259
  InputType()
271
260
  ], ResultMessageInput);
272
- var AgentStateMessageInput = class {
273
- threadId;
274
- agentName;
275
- role;
276
- state;
277
- running;
278
- nodeName;
279
- runId;
280
- active;
281
- };
282
- __name(AgentStateMessageInput, "AgentStateMessageInput");
283
- _ts_decorate([
284
- Field(() => String),
285
- _ts_metadata("design:type", String)
286
- ], AgentStateMessageInput.prototype, "threadId", void 0);
287
- _ts_decorate([
288
- Field(() => String),
289
- _ts_metadata("design:type", String)
290
- ], AgentStateMessageInput.prototype, "agentName", void 0);
291
- _ts_decorate([
292
- Field(() => MessageRole),
293
- _ts_metadata("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
294
- ], AgentStateMessageInput.prototype, "role", void 0);
295
- _ts_decorate([
296
- Field(() => String),
297
- _ts_metadata("design:type", String)
298
- ], AgentStateMessageInput.prototype, "state", void 0);
299
- _ts_decorate([
300
- Field(() => Boolean),
301
- _ts_metadata("design:type", Boolean)
302
- ], AgentStateMessageInput.prototype, "running", void 0);
303
- _ts_decorate([
304
- Field(() => String),
305
- _ts_metadata("design:type", String)
306
- ], AgentStateMessageInput.prototype, "nodeName", void 0);
307
- _ts_decorate([
308
- Field(() => String),
309
- _ts_metadata("design:type", String)
310
- ], AgentStateMessageInput.prototype, "runId", void 0);
311
- _ts_decorate([
312
- Field(() => Boolean),
313
- _ts_metadata("design:type", Boolean)
314
- ], AgentStateMessageInput.prototype, "active", void 0);
315
- AgentStateMessageInput = _ts_decorate([
316
- InputType()
317
- ], AgentStateMessageInput);
318
261
 
319
262
  // src/graphql/inputs/frontend.input.ts
320
263
  import { Field as Field3, InputType as InputType3 } from "type-graphql";
@@ -556,8 +499,7 @@ ForwardedParametersInput = _ts_decorate6([
556
499
  InputType6()
557
500
  ], ForwardedParametersInput);
558
501
 
559
- // src/graphql/inputs/agent-session.input.ts
560
- import { Field as Field7, InputType as InputType7 } from "type-graphql";
502
+ // src/graphql/inputs/generate-copilot-response.input.ts
561
503
  function _ts_decorate7(decorators, target, key, desc) {
562
504
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
563
505
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -574,96 +516,18 @@ function _ts_metadata7(k, v) {
574
516
  return Reflect.metadata(k, v);
575
517
  }
576
518
  __name(_ts_metadata7, "_ts_metadata");
577
- var AgentSessionInput = class {
578
- agentName;
579
- threadId;
580
- nodeName;
581
- };
582
- __name(AgentSessionInput, "AgentSessionInput");
583
- _ts_decorate7([
584
- Field7(() => String),
585
- _ts_metadata7("design:type", String)
586
- ], AgentSessionInput.prototype, "agentName", void 0);
587
- _ts_decorate7([
588
- Field7(() => String, {
589
- nullable: true
590
- }),
591
- _ts_metadata7("design:type", String)
592
- ], AgentSessionInput.prototype, "threadId", void 0);
593
- _ts_decorate7([
594
- Field7(() => String, {
595
- nullable: true
596
- }),
597
- _ts_metadata7("design:type", String)
598
- ], AgentSessionInput.prototype, "nodeName", void 0);
599
- AgentSessionInput = _ts_decorate7([
600
- InputType7()
601
- ], AgentSessionInput);
602
-
603
- // src/graphql/inputs/agent-state.input.ts
604
- import { Field as Field8, InputType as InputType8 } from "type-graphql";
605
- function _ts_decorate8(decorators, target, key, desc) {
606
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
607
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
608
- r = Reflect.decorate(decorators, target, key, desc);
609
- else
610
- for (var i = decorators.length - 1; i >= 0; i--)
611
- if (d = decorators[i])
612
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
613
- return c > 3 && r && Object.defineProperty(target, key, r), r;
614
- }
615
- __name(_ts_decorate8, "_ts_decorate");
616
- function _ts_metadata8(k, v) {
617
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
618
- return Reflect.metadata(k, v);
619
- }
620
- __name(_ts_metadata8, "_ts_metadata");
621
- var AgentStateInput = class {
622
- agentName;
623
- state;
624
- };
625
- __name(AgentStateInput, "AgentStateInput");
626
- _ts_decorate8([
627
- Field8(() => String),
628
- _ts_metadata8("design:type", String)
629
- ], AgentStateInput.prototype, "agentName", void 0);
630
- _ts_decorate8([
631
- Field8(() => String),
632
- _ts_metadata8("design:type", String)
633
- ], AgentStateInput.prototype, "state", void 0);
634
- AgentStateInput = _ts_decorate8([
635
- InputType8()
636
- ], AgentStateInput);
637
-
638
- // src/graphql/inputs/generate-copilot-response.input.ts
639
- function _ts_decorate9(decorators, target, key, desc) {
640
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
641
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
642
- r = Reflect.decorate(decorators, target, key, desc);
643
- else
644
- for (var i = decorators.length - 1; i >= 0; i--)
645
- if (d = decorators[i])
646
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
647
- return c > 3 && r && Object.defineProperty(target, key, r), r;
648
- }
649
- __name(_ts_decorate9, "_ts_decorate");
650
- function _ts_metadata9(k, v) {
651
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
652
- return Reflect.metadata(k, v);
653
- }
654
- __name(_ts_metadata9, "_ts_metadata");
655
519
  var GenerateCopilotResponseMetadataInput = class {
656
520
  requestType;
657
521
  };
658
522
  __name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
659
- _ts_decorate9([
660
- Field9(() => CopilotRequestType, {
523
+ _ts_decorate7([
524
+ Field7(() => CopilotRequestType, {
661
525
  nullable: true
662
526
  }),
663
- _ts_metadata9("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
527
+ _ts_metadata7("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
664
528
  ], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
665
- GenerateCopilotResponseMetadataInput = _ts_decorate9([
666
- InputType9()
529
+ GenerateCopilotResponseMetadataInput = _ts_decorate7([
530
+ InputType7()
667
531
  ], GenerateCopilotResponseMetadataInput);
668
532
  var GenerateCopilotResponseInput = class {
669
533
  metadata;
@@ -673,81 +537,58 @@ var GenerateCopilotResponseInput = class {
673
537
  frontend;
674
538
  cloud;
675
539
  forwardedParameters;
676
- agentSession;
677
- agentState;
678
- agentStates;
679
540
  };
680
541
  __name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
681
- _ts_decorate9([
682
- Field9(() => GenerateCopilotResponseMetadataInput, {
542
+ _ts_decorate7([
543
+ Field7(() => GenerateCopilotResponseMetadataInput, {
683
544
  nullable: false
684
545
  }),
685
- _ts_metadata9("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
546
+ _ts_metadata7("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
686
547
  ], GenerateCopilotResponseInput.prototype, "metadata", void 0);
687
- _ts_decorate9([
688
- Field9(() => String, {
548
+ _ts_decorate7([
549
+ Field7(() => String, {
689
550
  nullable: true
690
551
  }),
691
- _ts_metadata9("design:type", String)
552
+ _ts_metadata7("design:type", String)
692
553
  ], GenerateCopilotResponseInput.prototype, "threadId", void 0);
693
- _ts_decorate9([
694
- Field9(() => String, {
554
+ _ts_decorate7([
555
+ Field7(() => String, {
695
556
  nullable: true
696
557
  }),
697
- _ts_metadata9("design:type", String)
558
+ _ts_metadata7("design:type", String)
698
559
  ], GenerateCopilotResponseInput.prototype, "runId", void 0);
699
- _ts_decorate9([
700
- Field9(() => [
560
+ _ts_decorate7([
561
+ Field7(() => [
701
562
  MessageInput
702
563
  ]),
703
- _ts_metadata9("design:type", Array)
564
+ _ts_metadata7("design:type", Array)
704
565
  ], GenerateCopilotResponseInput.prototype, "messages", void 0);
705
- _ts_decorate9([
706
- Field9(() => FrontendInput),
707
- _ts_metadata9("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
566
+ _ts_decorate7([
567
+ Field7(() => FrontendInput),
568
+ _ts_metadata7("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
708
569
  ], GenerateCopilotResponseInput.prototype, "frontend", void 0);
709
- _ts_decorate9([
710
- Field9(() => CloudInput, {
570
+ _ts_decorate7([
571
+ Field7(() => CloudInput, {
711
572
  nullable: true
712
573
  }),
713
- _ts_metadata9("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
574
+ _ts_metadata7("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
714
575
  ], GenerateCopilotResponseInput.prototype, "cloud", void 0);
715
- _ts_decorate9([
716
- Field9(() => ForwardedParametersInput, {
576
+ _ts_decorate7([
577
+ Field7(() => ForwardedParametersInput, {
717
578
  nullable: true
718
579
  }),
719
- _ts_metadata9("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
580
+ _ts_metadata7("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
720
581
  ], GenerateCopilotResponseInput.prototype, "forwardedParameters", void 0);
721
- _ts_decorate9([
722
- Field9(() => AgentSessionInput, {
723
- nullable: true
724
- }),
725
- _ts_metadata9("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
726
- ], GenerateCopilotResponseInput.prototype, "agentSession", void 0);
727
- _ts_decorate9([
728
- Field9(() => AgentStateInput, {
729
- nullable: true
730
- }),
731
- _ts_metadata9("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
732
- ], GenerateCopilotResponseInput.prototype, "agentState", void 0);
733
- _ts_decorate9([
734
- Field9(() => [
735
- AgentStateInput
736
- ], {
737
- nullable: true
738
- }),
739
- _ts_metadata9("design:type", Array)
740
- ], GenerateCopilotResponseInput.prototype, "agentStates", void 0);
741
- GenerateCopilotResponseInput = _ts_decorate9([
742
- InputType9()
582
+ GenerateCopilotResponseInput = _ts_decorate7([
583
+ InputType7()
743
584
  ], GenerateCopilotResponseInput);
744
585
 
745
586
  // src/graphql/types/copilot-response.type.ts
746
- import { Field as Field11, InterfaceType, ObjectType as ObjectType2 } from "type-graphql";
587
+ import { Field as Field9, InterfaceType, ObjectType as ObjectType2 } from "type-graphql";
747
588
 
748
589
  // src/graphql/types/message-status.type.ts
749
- import { Field as Field10, ObjectType, createUnionType, registerEnumType as registerEnumType2 } from "type-graphql";
750
- function _ts_decorate10(decorators, target, key, desc) {
590
+ import { Field as Field8, ObjectType, createUnionType, registerEnumType as registerEnumType2 } from "type-graphql";
591
+ function _ts_decorate8(decorators, target, key, desc) {
751
592
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
752
593
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
753
594
  r = Reflect.decorate(decorators, target, key, desc);
@@ -757,12 +598,12 @@ function _ts_decorate10(decorators, target, key, desc) {
757
598
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
758
599
  return c > 3 && r && Object.defineProperty(target, key, r), r;
759
600
  }
760
- __name(_ts_decorate10, "_ts_decorate");
761
- function _ts_metadata10(k, v) {
601
+ __name(_ts_decorate8, "_ts_decorate");
602
+ function _ts_metadata8(k, v) {
762
603
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
763
604
  return Reflect.metadata(k, v);
764
605
  }
765
- __name(_ts_metadata10, "_ts_metadata");
606
+ __name(_ts_metadata8, "_ts_metadata");
766
607
  var MessageStatusCode;
767
608
  (function(MessageStatusCode2) {
768
609
  MessageStatusCode2["Pending"] = "pending";
@@ -775,25 +616,25 @@ registerEnumType2(MessageStatusCode, {
775
616
  var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
776
617
  code;
777
618
  }, "BaseMessageStatus");
778
- _ts_decorate10([
779
- Field10(() => MessageStatusCode),
780
- _ts_metadata10("design:type", String)
619
+ _ts_decorate8([
620
+ Field8(() => MessageStatusCode),
621
+ _ts_metadata8("design:type", String)
781
622
  ], BaseMessageStatus.prototype, "code", void 0);
782
- BaseMessageStatus = _ts_decorate10([
623
+ BaseMessageStatus = _ts_decorate8([
783
624
  ObjectType()
784
625
  ], BaseMessageStatus);
785
626
  var PendingMessageStatus = class extends BaseMessageStatus {
786
627
  code = "pending";
787
628
  };
788
629
  __name(PendingMessageStatus, "PendingMessageStatus");
789
- PendingMessageStatus = _ts_decorate10([
630
+ PendingMessageStatus = _ts_decorate8([
790
631
  ObjectType()
791
632
  ], PendingMessageStatus);
792
633
  var SuccessMessageStatus = class extends BaseMessageStatus {
793
634
  code = "success";
794
635
  };
795
636
  __name(SuccessMessageStatus, "SuccessMessageStatus");
796
- SuccessMessageStatus = _ts_decorate10([
637
+ SuccessMessageStatus = _ts_decorate8([
797
638
  ObjectType()
798
639
  ], SuccessMessageStatus);
799
640
  var FailedMessageStatus = class extends BaseMessageStatus {
@@ -801,11 +642,11 @@ var FailedMessageStatus = class extends BaseMessageStatus {
801
642
  reason;
802
643
  };
803
644
  __name(FailedMessageStatus, "FailedMessageStatus");
804
- _ts_decorate10([
805
- Field10(() => String),
806
- _ts_metadata10("design:type", String)
645
+ _ts_decorate8([
646
+ Field8(() => String),
647
+ _ts_metadata8("design:type", String)
807
648
  ], FailedMessageStatus.prototype, "reason", void 0);
808
- FailedMessageStatus = _ts_decorate10([
649
+ FailedMessageStatus = _ts_decorate8([
809
650
  ObjectType()
810
651
  ], FailedMessageStatus);
811
652
  var MessageStatusUnion = createUnionType({
@@ -818,7 +659,7 @@ var MessageStatusUnion = createUnionType({
818
659
  });
819
660
 
820
661
  // src/graphql/types/copilot-response.type.ts
821
- function _ts_decorate11(decorators, target, key, desc) {
662
+ function _ts_decorate9(decorators, target, key, desc) {
822
663
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
823
664
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
824
665
  r = Reflect.decorate(decorators, target, key, desc);
@@ -828,30 +669,30 @@ function _ts_decorate11(decorators, target, key, desc) {
828
669
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
829
670
  return c > 3 && r && Object.defineProperty(target, key, r), r;
830
671
  }
831
- __name(_ts_decorate11, "_ts_decorate");
832
- function _ts_metadata11(k, v) {
672
+ __name(_ts_decorate9, "_ts_decorate");
673
+ function _ts_metadata9(k, v) {
833
674
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
834
675
  return Reflect.metadata(k, v);
835
676
  }
836
- __name(_ts_metadata11, "_ts_metadata");
677
+ __name(_ts_metadata9, "_ts_metadata");
837
678
  var BaseMessageOutput = /* @__PURE__ */ __name(class BaseMessageOutput2 {
838
679
  id;
839
680
  createdAt;
840
681
  status;
841
682
  }, "BaseMessageOutput");
842
- _ts_decorate11([
843
- Field11(() => String),
844
- _ts_metadata11("design:type", String)
683
+ _ts_decorate9([
684
+ Field9(() => String),
685
+ _ts_metadata9("design:type", String)
845
686
  ], BaseMessageOutput.prototype, "id", void 0);
846
- _ts_decorate11([
847
- Field11(() => Date),
848
- _ts_metadata11("design:type", typeof Date === "undefined" ? Object : Date)
687
+ _ts_decorate9([
688
+ Field9(() => Date),
689
+ _ts_metadata9("design:type", typeof Date === "undefined" ? Object : Date)
849
690
  ], BaseMessageOutput.prototype, "createdAt", void 0);
850
- _ts_decorate11([
851
- Field11(() => MessageStatusUnion),
852
- _ts_metadata11("design:type", Object)
691
+ _ts_decorate9([
692
+ Field9(() => MessageStatusUnion),
693
+ _ts_metadata9("design:type", Object)
853
694
  ], BaseMessageOutput.prototype, "status", void 0);
854
- BaseMessageOutput = _ts_decorate11([
695
+ BaseMessageOutput = _ts_decorate9([
855
696
  InterfaceType({
856
697
  resolveType(value) {
857
698
  if (value.hasOwnProperty("content")) {
@@ -860,8 +701,6 @@ BaseMessageOutput = _ts_decorate11([
860
701
  return ActionExecutionMessageOutput;
861
702
  } else if (value.hasOwnProperty("result")) {
862
703
  return ResultMessageOutput;
863
- } else if (value.hasOwnProperty("state")) {
864
- return AgentStateMessageOutput;
865
704
  }
866
705
  return void 0;
867
706
  }
@@ -872,17 +711,17 @@ var TextMessageOutput = class {
872
711
  content;
873
712
  };
874
713
  __name(TextMessageOutput, "TextMessageOutput");
875
- _ts_decorate11([
876
- Field11(() => MessageRole),
877
- _ts_metadata11("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
714
+ _ts_decorate9([
715
+ Field9(() => MessageRole),
716
+ _ts_metadata9("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
878
717
  ], TextMessageOutput.prototype, "role", void 0);
879
- _ts_decorate11([
880
- Field11(() => [
718
+ _ts_decorate9([
719
+ Field9(() => [
881
720
  String
882
721
  ]),
883
- _ts_metadata11("design:type", Array)
722
+ _ts_metadata9("design:type", Array)
884
723
  ], TextMessageOutput.prototype, "content", void 0);
885
- TextMessageOutput = _ts_decorate11([
724
+ TextMessageOutput = _ts_decorate9([
886
725
  ObjectType2({
887
726
  implements: BaseMessageOutput
888
727
  })
@@ -893,21 +732,21 @@ var ActionExecutionMessageOutput = class {
893
732
  arguments;
894
733
  };
895
734
  __name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
896
- _ts_decorate11([
897
- Field11(() => String),
898
- _ts_metadata11("design:type", String)
735
+ _ts_decorate9([
736
+ Field9(() => String),
737
+ _ts_metadata9("design:type", String)
899
738
  ], ActionExecutionMessageOutput.prototype, "name", void 0);
900
- _ts_decorate11([
901
- Field11(() => ActionExecutionScope),
902
- _ts_metadata11("design:type", typeof ActionExecutionScope === "undefined" ? Object : ActionExecutionScope)
739
+ _ts_decorate9([
740
+ Field9(() => ActionExecutionScope),
741
+ _ts_metadata9("design:type", typeof ActionExecutionScope === "undefined" ? Object : ActionExecutionScope)
903
742
  ], ActionExecutionMessageOutput.prototype, "scope", void 0);
904
- _ts_decorate11([
905
- Field11(() => [
743
+ _ts_decorate9([
744
+ Field9(() => [
906
745
  String
907
746
  ]),
908
- _ts_metadata11("design:type", Array)
747
+ _ts_metadata9("design:type", Array)
909
748
  ], ActionExecutionMessageOutput.prototype, "arguments", void 0);
910
- ActionExecutionMessageOutput = _ts_decorate11([
749
+ ActionExecutionMessageOutput = _ts_decorate9([
911
750
  ObjectType2({
912
751
  implements: BaseMessageOutput
913
752
  })
@@ -918,71 +757,23 @@ var ResultMessageOutput = class {
918
757
  result;
919
758
  };
920
759
  __name(ResultMessageOutput, "ResultMessageOutput");
921
- _ts_decorate11([
922
- Field11(() => String),
923
- _ts_metadata11("design:type", String)
760
+ _ts_decorate9([
761
+ Field9(() => String),
762
+ _ts_metadata9("design:type", String)
924
763
  ], ResultMessageOutput.prototype, "actionExecutionId", void 0);
925
- _ts_decorate11([
926
- Field11(() => String),
927
- _ts_metadata11("design:type", String)
764
+ _ts_decorate9([
765
+ Field9(() => String),
766
+ _ts_metadata9("design:type", String)
928
767
  ], ResultMessageOutput.prototype, "actionName", void 0);
929
- _ts_decorate11([
930
- Field11(() => String),
931
- _ts_metadata11("design:type", String)
768
+ _ts_decorate9([
769
+ Field9(() => String),
770
+ _ts_metadata9("design:type", String)
932
771
  ], ResultMessageOutput.prototype, "result", void 0);
933
- ResultMessageOutput = _ts_decorate11([
772
+ ResultMessageOutput = _ts_decorate9([
934
773
  ObjectType2({
935
774
  implements: BaseMessageOutput
936
775
  })
937
776
  ], ResultMessageOutput);
938
- var AgentStateMessageOutput = class {
939
- threadId;
940
- agentName;
941
- nodeName;
942
- runId;
943
- active;
944
- role;
945
- state;
946
- running;
947
- };
948
- __name(AgentStateMessageOutput, "AgentStateMessageOutput");
949
- _ts_decorate11([
950
- Field11(() => String),
951
- _ts_metadata11("design:type", String)
952
- ], AgentStateMessageOutput.prototype, "threadId", void 0);
953
- _ts_decorate11([
954
- Field11(() => String),
955
- _ts_metadata11("design:type", String)
956
- ], AgentStateMessageOutput.prototype, "agentName", void 0);
957
- _ts_decorate11([
958
- Field11(() => String),
959
- _ts_metadata11("design:type", String)
960
- ], AgentStateMessageOutput.prototype, "nodeName", void 0);
961
- _ts_decorate11([
962
- Field11(() => String),
963
- _ts_metadata11("design:type", String)
964
- ], AgentStateMessageOutput.prototype, "runId", void 0);
965
- _ts_decorate11([
966
- Field11(() => Boolean),
967
- _ts_metadata11("design:type", Boolean)
968
- ], AgentStateMessageOutput.prototype, "active", void 0);
969
- _ts_decorate11([
970
- Field11(() => MessageRole),
971
- _ts_metadata11("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
972
- ], AgentStateMessageOutput.prototype, "role", void 0);
973
- _ts_decorate11([
974
- Field11(() => String),
975
- _ts_metadata11("design:type", String)
976
- ], AgentStateMessageOutput.prototype, "state", void 0);
977
- _ts_decorate11([
978
- Field11(() => Boolean),
979
- _ts_metadata11("design:type", Boolean)
980
- ], AgentStateMessageOutput.prototype, "running", void 0);
981
- AgentStateMessageOutput = _ts_decorate11([
982
- ObjectType2({
983
- implements: BaseMessageOutput
984
- })
985
- ], AgentStateMessageOutput);
986
777
  var CopilotResponse = class {
987
778
  threadId;
988
779
  status;
@@ -990,27 +781,27 @@ var CopilotResponse = class {
990
781
  messages;
991
782
  };
992
783
  __name(CopilotResponse, "CopilotResponse");
993
- _ts_decorate11([
994
- Field11(() => String),
995
- _ts_metadata11("design:type", String)
784
+ _ts_decorate9([
785
+ Field9(() => String),
786
+ _ts_metadata9("design:type", String)
996
787
  ], CopilotResponse.prototype, "threadId", void 0);
997
- _ts_decorate11([
998
- Field11(() => ResponseStatusUnion),
999
- _ts_metadata11("design:type", Object)
788
+ _ts_decorate9([
789
+ Field9(() => ResponseStatusUnion),
790
+ _ts_metadata9("design:type", Object)
1000
791
  ], CopilotResponse.prototype, "status", void 0);
1001
- _ts_decorate11([
1002
- Field11({
792
+ _ts_decorate9([
793
+ Field9({
1003
794
  nullable: true
1004
795
  }),
1005
- _ts_metadata11("design:type", String)
796
+ _ts_metadata9("design:type", String)
1006
797
  ], CopilotResponse.prototype, "runId", void 0);
1007
- _ts_decorate11([
1008
- Field11(() => [
798
+ _ts_decorate9([
799
+ Field9(() => [
1009
800
  BaseMessageOutput
1010
801
  ]),
1011
- _ts_metadata11("design:type", Array)
802
+ _ts_metadata9("design:type", Array)
1012
803
  ], CopilotResponse.prototype, "messages", void 0);
1013
- CopilotResponse = _ts_decorate11([
804
+ CopilotResponse = _ts_decorate9([
1014
805
  ObjectType2()
1015
806
  ], CopilotResponse);
1016
807
 
@@ -1018,366 +809,7 @@ CopilotResponse = _ts_decorate11([
1018
809
  import { Repeater } from "graphql-yoga";
1019
810
 
1020
811
  // src/service-adapters/events.ts
1021
- import { of, concat, map, scan as scan2, concatMap, ReplaySubject as ReplaySubject2, firstValueFrom, from } from "rxjs";
1022
-
1023
- // src/lib/telemetry-client.ts
1024
- import { TelemetryClient } from "@copilotkit/shared";
1025
- var packageJson = require_package();
1026
- var telemetryClient = new TelemetryClient({
1027
- packageName: packageJson.name,
1028
- packageVersion: packageJson.version
1029
- });
1030
- var telemetry_client_default = telemetryClient;
1031
-
1032
- // src/agents/langgraph/event-source.ts
1033
- import { ReplaySubject, scan, mergeMap } from "rxjs";
1034
-
1035
- // src/agents/langgraph/events.ts
1036
- var LangGraphEventTypes;
1037
- (function(LangGraphEventTypes2) {
1038
- LangGraphEventTypes2["OnChainStart"] = "on_chain_start";
1039
- LangGraphEventTypes2["OnChainStream"] = "on_chain_stream";
1040
- LangGraphEventTypes2["OnChainEnd"] = "on_chain_end";
1041
- LangGraphEventTypes2["OnChatModelStart"] = "on_chat_model_start";
1042
- LangGraphEventTypes2["OnChatModelStream"] = "on_chat_model_stream";
1043
- LangGraphEventTypes2["OnChatModelEnd"] = "on_chat_model_end";
1044
- LangGraphEventTypes2["OnToolStart"] = "on_tool_start";
1045
- LangGraphEventTypes2["OnToolEnd"] = "on_tool_end";
1046
- LangGraphEventTypes2["OnCopilotKitStateSync"] = "on_copilotkit_state_sync";
1047
- })(LangGraphEventTypes || (LangGraphEventTypes = {}));
1048
-
1049
- // src/agents/langgraph/event-source.ts
1050
- var RemoteLangGraphEventSource = class {
1051
- eventStream$ = new ReplaySubject();
1052
- async streamResponse(response) {
1053
- const reader = response.body.getReader();
1054
- const decoder = new TextDecoder();
1055
- let buffer = [];
1056
- const eventStream$ = this.eventStream$;
1057
- function flushBuffer() {
1058
- const currentBuffer = buffer.join("");
1059
- if (currentBuffer.trim().length === 0) {
1060
- return;
1061
- }
1062
- const parts = currentBuffer.split("\n");
1063
- if (parts.length === 0) {
1064
- return;
1065
- }
1066
- const lastPartIsComplete = currentBuffer.endsWith("\n");
1067
- buffer = [];
1068
- if (!lastPartIsComplete) {
1069
- buffer.push(parts.pop());
1070
- }
1071
- parts.map((part) => part.trim()).filter((part) => part != "").forEach((part) => {
1072
- eventStream$.next(JSON.parse(part));
1073
- });
1074
- }
1075
- __name(flushBuffer, "flushBuffer");
1076
- while (true) {
1077
- const { done, value } = await reader.read();
1078
- if (!done) {
1079
- buffer.push(decoder.decode(value, {
1080
- stream: true
1081
- }));
1082
- }
1083
- flushBuffer();
1084
- if (done) {
1085
- break;
1086
- }
1087
- }
1088
- eventStream$.complete();
1089
- }
1090
- processLangGraphEvents() {
1091
- return this.eventStream$.pipe(scan((acc, event) => {
1092
- var _a, _b, _c, _d, _e, _f, _g, _h;
1093
- if (event.event === LangGraphEventTypes.OnChatModelStream) {
1094
- if ((_c = (_b = (_a = event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.kwargs) == null ? void 0 : _c.tool_call_chunks) {
1095
- acc.prevToolCallId = acc.toolCallId;
1096
- acc.toolCallId = (_d = event.data.chunk.kwargs) == null ? void 0 : _d.id;
1097
- if ((_e = event.data.chunk.kwargs.tool_call_chunks[0]) == null ? void 0 : _e.name) {
1098
- acc.toolCallName = event.data.chunk.kwargs.tool_call_chunks[0].name;
1099
- }
1100
- }
1101
- acc.prevMessageId = acc.messageId;
1102
- acc.messageId = (_h = (_g = (_f = event.data) == null ? void 0 : _f.chunk) == null ? void 0 : _g.kwargs) == null ? void 0 : _h.id;
1103
- } else {
1104
- acc.prevToolCallId = acc.toolCallId;
1105
- acc.toolCallId = null;
1106
- acc.prevMessageId = acc.messageId;
1107
- acc.messageId = null;
1108
- acc.toolCallName = null;
1109
- }
1110
- acc.event = event;
1111
- return acc;
1112
- }, {
1113
- event: null,
1114
- toolCallId: null,
1115
- prevToolCallId: null,
1116
- messageId: null,
1117
- toolCallName: null,
1118
- prevMessageId: null
1119
- }), mergeMap((eventWithState) => {
1120
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1121
- const events = [];
1122
- let shouldEmitMessages = false;
1123
- let shouldEmitToolCalls = false;
1124
- if (eventWithState.event.event == LangGraphEventTypes.OnChatModelStream) {
1125
- if ((_a = eventWithState.event.tags) == null ? void 0 : _a.includes("copilotkit:emit-tool-calls")) {
1126
- shouldEmitToolCalls = true;
1127
- }
1128
- if ((_b = eventWithState.event.tags) == null ? void 0 : _b.includes("copilotkit:emit-messages")) {
1129
- shouldEmitMessages = true;
1130
- }
1131
- }
1132
- if (eventWithState.prevToolCallId !== null && eventWithState.prevToolCallId !== eventWithState.toolCallId && shouldEmitToolCalls) {
1133
- events.push({
1134
- type: RuntimeEventTypes.ActionExecutionEnd
1135
- });
1136
- }
1137
- if (eventWithState.prevMessageId !== null && eventWithState.prevMessageId !== eventWithState.messageId && shouldEmitMessages) {
1138
- events.push({
1139
- type: RuntimeEventTypes.TextMessageEnd
1140
- });
1141
- }
1142
- switch (eventWithState.event.event) {
1143
- case LangGraphEventTypes.OnCopilotKitStateSync:
1144
- events.push({
1145
- type: RuntimeEventTypes.AgentStateMessage,
1146
- threadId: eventWithState.event.thread_id,
1147
- role: eventWithState.event.role,
1148
- agentName: eventWithState.event.agent_name,
1149
- nodeName: eventWithState.event.node_name,
1150
- runId: eventWithState.event.run_id,
1151
- active: eventWithState.event.active,
1152
- state: JSON.stringify(eventWithState.event.state),
1153
- running: eventWithState.event.running
1154
- });
1155
- break;
1156
- case LangGraphEventTypes.OnToolEnd:
1157
- break;
1158
- case LangGraphEventTypes.OnChatModelStream:
1159
- if (eventWithState.toolCallId !== null && eventWithState.prevToolCallId !== eventWithState.toolCallId) {
1160
- if (shouldEmitToolCalls) {
1161
- events.push({
1162
- type: RuntimeEventTypes.ActionExecutionStart,
1163
- actionExecutionId: eventWithState.toolCallId,
1164
- actionName: eventWithState.toolCallName,
1165
- scope: "client"
1166
- });
1167
- }
1168
- } else if (eventWithState.messageId !== null && eventWithState.prevMessageId !== eventWithState.messageId) {
1169
- if (shouldEmitMessages) {
1170
- events.push({
1171
- type: RuntimeEventTypes.TextMessageStart,
1172
- messageId: eventWithState.messageId
1173
- });
1174
- }
1175
- }
1176
- 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;
1177
- const content = (_j = (_i = (_h = eventWithState.event.data) == null ? void 0 : _h.chunk) == null ? void 0 : _i.kwargs) == null ? void 0 : _j.content;
1178
- if (args) {
1179
- if (shouldEmitToolCalls) {
1180
- events.push({
1181
- type: RuntimeEventTypes.ActionExecutionArgs,
1182
- args
1183
- });
1184
- }
1185
- } else if (eventWithState.messageId !== null && content) {
1186
- if (shouldEmitMessages) {
1187
- events.push({
1188
- type: RuntimeEventTypes.TextMessageContent,
1189
- content
1190
- });
1191
- }
1192
- }
1193
- break;
1194
- }
1195
- return events;
1196
- }));
1197
- }
1198
- };
1199
- __name(RemoteLangGraphEventSource, "RemoteLangGraphEventSource");
1200
-
1201
- // src/lib/runtime/remote-actions.ts
1202
- function isLangGraphAgentAction(action) {
1203
- if (!action) {
1204
- return false;
1205
- }
1206
- return typeof action.langGraphAgentHandler === "function";
1207
- }
1208
- __name(isLangGraphAgentAction, "isLangGraphAgentAction");
1209
- function createHeaders(onBeforeRequest, graphqlContext) {
1210
- const headers = {
1211
- "Content-Type": "application/json"
1212
- };
1213
- if (onBeforeRequest) {
1214
- const { headers: additionalHeaders } = onBeforeRequest({
1215
- ctx: graphqlContext
1216
- });
1217
- if (additionalHeaders) {
1218
- Object.assign(headers, additionalHeaders);
1219
- }
1220
- }
1221
- return headers;
1222
- }
1223
- __name(createHeaders, "createHeaders");
1224
- async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: logger2 }) {
1225
- logger2.debug({
1226
- url
1227
- }, "Fetching actions from url");
1228
- const headers = createHeaders(onBeforeRequest, graphqlContext);
1229
- const response = await fetch(`${url}/info`, {
1230
- method: "POST",
1231
- headers,
1232
- body: JSON.stringify({
1233
- properties: graphqlContext.properties
1234
- })
1235
- });
1236
- if (!response.ok) {
1237
- logger2.error({
1238
- url,
1239
- status: response.status,
1240
- body: await response.text()
1241
- }, "Failed to fetch actions from url");
1242
- return [];
1243
- }
1244
- const json = await response.json();
1245
- logger2.debug({
1246
- json
1247
- }, "Fetched actions from url");
1248
- return json;
1249
- }
1250
- __name(fetchRemoteInfo, "fetchRemoteInfo");
1251
- function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, logger: logger2, messages, agentStates }) {
1252
- const actions = json["actions"].map((action) => ({
1253
- name: action.name,
1254
- description: action.description,
1255
- parameters: action.parameters,
1256
- handler: async (args) => {
1257
- logger2.debug({
1258
- actionName: action.name,
1259
- args
1260
- }, "Executing remote action");
1261
- const headers = createHeaders(onBeforeRequest, graphqlContext);
1262
- telemetry_client_default.capture("oss.runtime.remote_action_executed", {});
1263
- const response = await fetch(`${url}/actions/execute`, {
1264
- method: "POST",
1265
- headers,
1266
- body: JSON.stringify({
1267
- name: action.name,
1268
- arguments: args,
1269
- properties: graphqlContext.properties
1270
- })
1271
- });
1272
- if (!response.ok) {
1273
- logger2.error({
1274
- url,
1275
- status: response.status,
1276
- body: await response.text()
1277
- }, "Failed to execute remote action");
1278
- return "Failed to execute remote action";
1279
- }
1280
- const requestResult = await response.json();
1281
- const result = requestResult["result"];
1282
- logger2.debug({
1283
- actionName: action.name,
1284
- result
1285
- }, "Executed remote action");
1286
- return result;
1287
- }
1288
- }));
1289
- const agents = json["agents"].map((agent) => ({
1290
- name: agent.name,
1291
- description: agent.description,
1292
- parameters: [],
1293
- handler: async (_args) => {
1294
- },
1295
- langGraphAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName }) => {
1296
- var _a;
1297
- logger2.debug({
1298
- actionName: agent.name
1299
- }, "Executing remote agent");
1300
- const headers = createHeaders(onBeforeRequest, graphqlContext);
1301
- telemetry_client_default.capture("oss.runtime.remote_action_executed", {});
1302
- let state = {};
1303
- if (agentStates) {
1304
- const jsonState = (_a = agentStates.find((state2) => state2.agentName === name)) == null ? void 0 : _a.state;
1305
- if (jsonState) {
1306
- state = JSON.parse(jsonState);
1307
- }
1308
- }
1309
- const response = await fetch(`${url}/agents/execute`, {
1310
- method: "POST",
1311
- headers,
1312
- body: JSON.stringify({
1313
- name,
1314
- threadId,
1315
- nodeName,
1316
- messages,
1317
- state,
1318
- properties: graphqlContext.properties,
1319
- actions: actionInputsWithoutAgents.map((action) => ({
1320
- name: action.name,
1321
- description: action.description,
1322
- parameters: JSON.parse(action.jsonSchema)
1323
- }))
1324
- })
1325
- });
1326
- if (!response.ok) {
1327
- logger2.error({
1328
- url,
1329
- status: response.status,
1330
- body: await response.text()
1331
- }, "Failed to execute remote agent");
1332
- throw new Error("Failed to execute remote agent");
1333
- }
1334
- const eventSource = new RemoteLangGraphEventSource();
1335
- eventSource.streamResponse(response);
1336
- return eventSource.processLangGraphEvents();
1337
- }
1338
- }));
1339
- return [
1340
- ...actions,
1341
- ...agents
1342
- ];
1343
- }
1344
- __name(constructRemoteActions, "constructRemoteActions");
1345
- async function setupRemoteActions({ remoteActionDefinitions, graphqlContext, messages, agentStates }) {
1346
- const logger2 = graphqlContext.logger.child({
1347
- component: "remote-actions.fetchRemoteActions"
1348
- });
1349
- logger2.debug({
1350
- remoteActionDefinitions
1351
- }, "Fetching remote actions");
1352
- const filtered = remoteActionDefinitions.filter((value, index, self) => index === self.findIndex((t) => t.url === value.url));
1353
- const result = await Promise.all(filtered.map(async (actionDefinition) => {
1354
- const json = await fetchRemoteInfo({
1355
- url: actionDefinition.url,
1356
- onBeforeRequest: actionDefinition.onBeforeRequest,
1357
- graphqlContext,
1358
- logger: logger2.child({
1359
- component: "remote-actions.fetchActionsFromUrl",
1360
- actionDefinition
1361
- })
1362
- });
1363
- return constructRemoteActions({
1364
- json,
1365
- messages,
1366
- url: actionDefinition.url,
1367
- onBeforeRequest: actionDefinition.onBeforeRequest,
1368
- graphqlContext,
1369
- logger: logger2.child({
1370
- component: "remote-actions.constructActions",
1371
- actionDefinition
1372
- }),
1373
- agentStates
1374
- });
1375
- }));
1376
- return result.flat();
1377
- }
1378
- __name(setupRemoteActions, "setupRemoteActions");
1379
-
1380
- // src/service-adapters/events.ts
812
+ import { of, concat, map, scan, concatMap, ReplaySubject, firstValueFrom } from "rxjs";
1381
813
  var RuntimeEventTypes;
1382
814
  (function(RuntimeEventTypes2) {
1383
815
  RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
@@ -1387,9 +819,8 @@ var RuntimeEventTypes;
1387
819
  RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
1388
820
  RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
1389
821
  RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
1390
- RuntimeEventTypes2["AgentStateMessage"] = "AgentStateMessage";
1391
822
  })(RuntimeEventTypes || (RuntimeEventTypes = {}));
1392
- var RuntimeEventSubject = class extends ReplaySubject2 {
823
+ var RuntimeEventSubject = class extends ReplaySubject {
1393
824
  constructor() {
1394
825
  super();
1395
826
  }
@@ -1446,19 +877,6 @@ var RuntimeEventSubject = class extends ReplaySubject2 {
1446
877
  result
1447
878
  });
1448
879
  }
1449
- sendAgentStateMessage(threadId, agentName, nodeName, runId, active, role, state, running) {
1450
- this.next({
1451
- type: "AgentStateMessage",
1452
- threadId,
1453
- agentName,
1454
- nodeName,
1455
- runId,
1456
- active,
1457
- role,
1458
- state,
1459
- running
1460
- });
1461
- }
1462
880
  };
1463
881
  __name(RuntimeEventSubject, "RuntimeEventSubject");
1464
882
  var RuntimeEventSource = class {
@@ -1467,7 +885,7 @@ var RuntimeEventSource = class {
1467
885
  async stream(callback) {
1468
886
  this.callback = callback;
1469
887
  }
1470
- processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents }) {
888
+ process({ serversideActions, guardrailsResult$ }) {
1471
889
  this.callback(this.eventStream$).catch((error) => {
1472
890
  console.error("Error in event source callback", error);
1473
891
  });
@@ -1475,23 +893,18 @@ var RuntimeEventSource = class {
1475
893
  // mark tools for server side execution
1476
894
  map((event) => {
1477
895
  if (event.type === "ActionExecutionStart") {
1478
- if (event.scope !== "passThrough") {
1479
- event.scope = serverSideActions.find((action) => action.name === event.actionName) ? "server" : "client";
1480
- }
896
+ event.scope = serversideActions.find((action) => action.name === event.actionName) ? "server" : "client";
1481
897
  }
1482
898
  return event;
1483
899
  }),
1484
900
  // track state
1485
- scan2((acc, event) => {
1486
- acc = {
1487
- ...acc
1488
- };
901
+ scan((acc, event) => {
1489
902
  if (event.type === "ActionExecutionStart") {
1490
903
  acc.callActionServerSide = event.scope === "server";
1491
904
  acc.args = "";
1492
905
  acc.actionExecutionId = event.actionExecutionId;
1493
906
  if (acc.callActionServerSide) {
1494
- acc.action = serverSideActions.find((action) => action.name === event.actionName);
907
+ acc.action = serversideActions.find((action) => action.name === event.actionName);
1495
908
  }
1496
909
  } else if (event.type === "ActionExecutionArgs") {
1497
910
  acc.args += event.args;
@@ -1508,10 +921,9 @@ var RuntimeEventSource = class {
1508
921
  concatMap((eventWithState) => {
1509
922
  if (eventWithState.event.type === "ActionExecutionEnd" && eventWithState.callActionServerSide) {
1510
923
  const toolCallEventStream$ = new RuntimeEventSubject();
1511
- executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionId, actionInputsWithoutAgents).catch((error) => {
924
+ executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionId).catch((error) => {
1512
925
  console.error(error);
1513
926
  });
1514
- telemetry_client_default.capture("oss.runtime.server_action_executed", {});
1515
927
  return concat(of(eventWithState.event), toolCallEventStream$);
1516
928
  } else {
1517
929
  return of(eventWithState.event);
@@ -1521,8 +933,7 @@ var RuntimeEventSource = class {
1521
933
  }
1522
934
  };
1523
935
  __name(RuntimeEventSource, "RuntimeEventSource");
1524
- async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionId, actionInputsWithoutAgents) {
1525
- var _a;
936
+ async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionId) {
1526
937
  if (guardrailsResult$) {
1527
938
  const { status } = await firstValueFrom(guardrailsResult$);
1528
939
  if (status === "denied") {
@@ -1534,28 +945,15 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
1534
945
  if (actionArguments) {
1535
946
  args = JSON.parse(actionArguments);
1536
947
  }
1537
- if (isLangGraphAgentAction(action)) {
1538
- eventStream$.sendActionExecutionResult(actionExecutionId, action.name, `${action.name} agent started`);
1539
- const stream = await action.langGraphAgentHandler({
948
+ const result = await action.handler(args);
949
+ await streamLangChainResponse({
950
+ result,
951
+ eventStream$,
952
+ actionExecution: {
1540
953
  name: action.name,
1541
- actionInputsWithoutAgents
1542
- });
1543
- from(stream).subscribe({
1544
- next: (event) => eventStream$.next(event),
1545
- error: (err) => console.error("Error in stream", err),
1546
- complete: () => eventStream$.complete()
1547
- });
1548
- } else {
1549
- const result = await ((_a = action.handler) == null ? void 0 : _a.call(action, args));
1550
- await streamLangChainResponse({
1551
- result,
1552
- eventStream$,
1553
- actionExecution: {
1554
- name: action.name,
1555
- id: actionExecutionId
1556
- }
1557
- });
1558
- }
954
+ id: actionExecutionId
955
+ }
956
+ });
1559
957
  }
1560
958
  __name(executeAction, "executeAction");
1561
959
 
@@ -1563,8 +961,19 @@ __name(executeAction, "executeAction");
1563
961
  import { GraphQLJSONObject } from "graphql-scalars";
1564
962
  import { plainToInstance } from "class-transformer";
1565
963
  import { GraphQLError } from "graphql";
964
+
965
+ // src/lib/telemetry-client.ts
966
+ import { TelemetryClient } from "@copilotkit/shared";
967
+ var packageJson = require_package();
968
+ var telemetryClient = new TelemetryClient({
969
+ packageName: packageJson.name,
970
+ packageVersion: packageJson.version
971
+ });
972
+ var telemetry_client_default = telemetryClient;
973
+
974
+ // src/graphql/resolvers/copilot.resolver.ts
1566
975
  import { randomId } from "@copilotkit/shared";
1567
- function _ts_decorate12(decorators, target, key, desc) {
976
+ function _ts_decorate10(decorators, target, key, desc) {
1568
977
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1569
978
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1570
979
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1574,12 +983,12 @@ function _ts_decorate12(decorators, target, key, desc) {
1574
983
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1575
984
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1576
985
  }
1577
- __name(_ts_decorate12, "_ts_decorate");
1578
- function _ts_metadata12(k, v) {
986
+ __name(_ts_decorate10, "_ts_decorate");
987
+ function _ts_metadata10(k, v) {
1579
988
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1580
989
  return Reflect.metadata(k, v);
1581
990
  }
1582
- __name(_ts_metadata12, "_ts_metadata");
991
+ __name(_ts_metadata10, "_ts_metadata");
1583
992
  function _ts_param(paramIndex, decorator) {
1584
993
  return function(target, key) {
1585
994
  decorator(target, key, paramIndex);
@@ -1588,6 +997,7 @@ function _ts_param(paramIndex, decorator) {
1588
997
  __name(_ts_param, "_ts_param");
1589
998
  var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPublicApiKey, data, onResult, onError }) => {
1590
999
  var _a;
1000
+ console.log("invokeGuardrails.baseUrl", baseUrl);
1591
1001
  if (data.messages.length && ((_a = data.messages[data.messages.length - 1].textMessage) == null ? void 0 : _a.role) === MessageRole.user) {
1592
1002
  const messages = data.messages.filter((m) => m.textMessage !== void 0 && (m.textMessage.role === MessageRole.user || m.textMessage.role === MessageRole.assistant)).map((m) => ({
1593
1003
  role: m.textMessage.role,
@@ -1633,6 +1043,8 @@ var CopilotResolver = class {
1633
1043
  logger2.debug({
1634
1044
  data
1635
1045
  }, "Generating Copilot response");
1046
+ const copilotRuntime = ctx._copilotkit.runtime;
1047
+ const serviceAdapter = ctx._copilotkit.serviceAdapter;
1636
1048
  if (properties) {
1637
1049
  logger2.debug("Properties provided, merging with context properties");
1638
1050
  ctx.properties = {
@@ -1640,8 +1052,6 @@ var CopilotResolver = class {
1640
1052
  ...properties
1641
1053
  };
1642
1054
  }
1643
- const copilotRuntime = ctx._copilotkit.runtime;
1644
- const serviceAdapter = ctx._copilotkit.serviceAdapter;
1645
1055
  let copilotCloudPublicApiKey = null;
1646
1056
  let copilotCloudBaseUrl;
1647
1057
  if (data.cloud) {
@@ -1669,9 +1079,9 @@ var CopilotResolver = class {
1669
1079
  });
1670
1080
  }
1671
1081
  logger2.debug("Setting up subjects");
1672
- const responseStatus$ = new ReplaySubject3();
1673
- const interruptStreaming$ = new ReplaySubject3();
1674
- const guardrailsResult$ = new ReplaySubject3();
1082
+ const responseStatus$ = new ReplaySubject2();
1083
+ const interruptStreaming$ = new ReplaySubject2();
1084
+ const guardrailsResult$ = new ReplaySubject2();
1675
1085
  let outputMessages = [];
1676
1086
  let resolveOutputMessagesPromise;
1677
1087
  let rejectOutputMessagesPromise;
@@ -1680,18 +1090,16 @@ var CopilotResolver = class {
1680
1090
  rejectOutputMessagesPromise = reject;
1681
1091
  });
1682
1092
  logger2.debug("Processing");
1683
- const { eventSource, threadId = randomId(), runId, serverSideActions, actionInputsWithoutAgents } = await copilotRuntime.processRuntimeRequest({
1093
+ const { eventSource, threadId = randomId(), runId, actions } = await copilotRuntime.process({
1684
1094
  serviceAdapter,
1685
1095
  messages: data.messages,
1686
1096
  actions: data.frontend.actions,
1687
1097
  threadId: data.threadId,
1688
1098
  runId: data.runId,
1689
1099
  publicApiKey: void 0,
1100
+ properties: ctx.properties || {},
1690
1101
  outputMessagesPromise,
1691
- graphqlContext: ctx,
1692
1102
  forwardedParameters: data.forwardedParameters,
1693
- agentSession: data.agentSession,
1694
- agentStates: data.agentStates,
1695
1103
  url: data.frontend.url
1696
1104
  });
1697
1105
  logger2.debug("Event source created, creating response");
@@ -1749,13 +1157,9 @@ var CopilotResolver = class {
1749
1157
  });
1750
1158
  }
1751
1159
  let eventStreamSubscription;
1752
- const eventStream = eventSource.processRuntimeEvents({
1753
- serverSideActions,
1754
- guardrailsResult$: ((_b2 = data.cloud) == null ? void 0 : _b2.guardrails) ? guardrailsResult$ : null,
1755
- actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
1756
- // TODO-AGENTS: do not exclude ALL server side actions
1757
- (action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
1758
- )
1160
+ const eventStream = eventSource.process({
1161
+ serversideActions: actions,
1162
+ guardrailsResult$: ((_b2 = data.cloud) == null ? void 0 : _b2.guardrails) ? guardrailsResult$ : null
1759
1163
  }).pipe(
1760
1164
  // shareReplay() ensures that later subscribers will see the whole stream instead of
1761
1165
  // just the events that were emitted after the subscriber was added.
@@ -1903,36 +1307,6 @@ var CopilotResolver = class {
1903
1307
  result: event.result
1904
1308
  }));
1905
1309
  break;
1906
- case RuntimeEventTypes.AgentStateMessage:
1907
- logger2.debug({
1908
- event
1909
- }, "Agent message event received");
1910
- pushMessage({
1911
- id: randomId(),
1912
- status: new SuccessMessageStatus(),
1913
- threadId: event.threadId,
1914
- agentName: event.agentName,
1915
- nodeName: event.nodeName,
1916
- runId: event.runId,
1917
- active: event.active,
1918
- state: event.state,
1919
- running: event.running,
1920
- role: MessageRole.assistant,
1921
- createdAt: /* @__PURE__ */ new Date()
1922
- });
1923
- outputMessages.push(plainToInstance(AgentStateMessage, {
1924
- id: randomId(),
1925
- threadId: event.threadId,
1926
- agentName: event.agentName,
1927
- nodeName: event.nodeName,
1928
- runId: event.runId,
1929
- active: event.active,
1930
- state: event.state,
1931
- running: event.running,
1932
- role: MessageRole.assistant,
1933
- createdAt: /* @__PURE__ */ new Date()
1934
- }));
1935
- break;
1936
1310
  }
1937
1311
  },
1938
1312
  error: (err) => {
@@ -1965,28 +1339,28 @@ var CopilotResolver = class {
1965
1339
  }
1966
1340
  };
1967
1341
  __name(CopilotResolver, "CopilotResolver");
1968
- _ts_decorate12([
1342
+ _ts_decorate10([
1969
1343
  Query(() => String),
1970
- _ts_metadata12("design:type", Function),
1971
- _ts_metadata12("design:paramtypes", []),
1972
- _ts_metadata12("design:returntype", Promise)
1344
+ _ts_metadata10("design:type", Function),
1345
+ _ts_metadata10("design:paramtypes", []),
1346
+ _ts_metadata10("design:returntype", Promise)
1973
1347
  ], CopilotResolver.prototype, "hello", null);
1974
- _ts_decorate12([
1348
+ _ts_decorate10([
1975
1349
  Mutation(() => CopilotResponse),
1976
1350
  _ts_param(0, Ctx()),
1977
1351
  _ts_param(1, Arg("data")),
1978
1352
  _ts_param(2, Arg("properties", () => GraphQLJSONObject, {
1979
1353
  nullable: true
1980
1354
  })),
1981
- _ts_metadata12("design:type", Function),
1982
- _ts_metadata12("design:paramtypes", [
1355
+ _ts_metadata10("design:type", Function),
1356
+ _ts_metadata10("design:paramtypes", [
1983
1357
  typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
1984
1358
  typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
1985
1359
  typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
1986
1360
  ]),
1987
- _ts_metadata12("design:returntype", Promise)
1361
+ _ts_metadata10("design:returntype", Promise)
1988
1362
  ], CopilotResolver.prototype, "generateCopilotResponse", null);
1989
- CopilotResolver = _ts_decorate12([
1363
+ CopilotResolver = _ts_decorate10([
1990
1364
  Resolver(() => CopilotResponse)
1991
1365
  ], CopilotResolver);
1992
1366
 
@@ -2120,13 +1494,11 @@ function copilotRuntimeNodeHttpEndpoint(options) {
2120
1494
  __name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
2121
1495
 
2122
1496
  export {
2123
- telemetry_client_default,
2124
- isLangGraphAgentAction,
2125
- setupRemoteActions,
2126
1497
  RuntimeEventSource,
1498
+ telemetry_client_default,
2127
1499
  createContext,
2128
1500
  buildSchema,
2129
1501
  getCommonConfig,
2130
1502
  copilotRuntimeNodeHttpEndpoint
2131
1503
  };
2132
- //# sourceMappingURL=chunk-7FSNQXPE.mjs.map
1504
+ //# sourceMappingURL=chunk-3TQLJ3YL.mjs.map