@copilotkit/runtime 1.5.12-next.6 → 1.5.12
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.
- package/CHANGELOG.md +22 -0
- package/__snapshots__/schema/schema.graphql +33 -0
- package/dist/{chunk-XM2VJFL6.mjs → chunk-4LRVKGBI.mjs} +2 -2
- package/dist/{chunk-YGXAWYRB.mjs → chunk-IS3QAGOU.mjs} +2 -2
- package/dist/{chunk-ON4AESON.mjs → chunk-PFELVFS7.mjs} +540 -221
- package/dist/chunk-PFELVFS7.mjs.map +1 -0
- package/dist/{chunk-TPTCSIAR.mjs → chunk-S3KKBII4.mjs} +42 -30
- package/dist/chunk-S3KKBII4.mjs.map +1 -0
- package/dist/{chunk-BKIGYRXE.mjs → chunk-W6EE6OTN.mjs} +2 -2
- package/dist/{copilot-runtime-da917bd5.d.ts → copilot-runtime-8c442d65.d.ts} +16 -5
- package/dist/graphql/types/converted/index.d.ts +1 -1
- package/dist/{groq-adapter-c35c5374.d.ts → groq-adapter-7a82cd22.d.ts} +21 -1
- package/dist/{index-24315d90.d.ts → index-a7f37670.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +628 -297
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/{langserve-a16ef8f4.d.ts → langserve-e308c437.d.ts} +32 -3
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/index.js +626 -295
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +6 -6
- package/dist/lib/integrations/index.d.ts +4 -4
- package/dist/lib/integrations/index.js +495 -237
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +5 -5
- package/dist/lib/integrations/nest/index.d.ts +3 -3
- package/dist/lib/integrations/nest/index.js +495 -237
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +3 -3
- package/dist/lib/integrations/node-express/index.d.ts +3 -3
- package/dist/lib/integrations/node-express/index.js +495 -237
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +3 -3
- package/dist/lib/integrations/node-http/index.d.ts +3 -3
- package/dist/lib/integrations/node-http/index.js +495 -237
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +2 -2
- package/dist/service-adapters/index.d.ts +4 -4
- package/dist/service-adapters/index.js +23 -11
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +1 -1
- package/package.json +2 -2
- package/src/graphql/inputs/extensions.input.ts +21 -0
- package/src/graphql/inputs/generate-copilot-response.input.ts +4 -0
- package/src/graphql/inputs/load-agent-state.input.ts +10 -0
- package/src/graphql/resolvers/copilot.resolver.ts +8 -3
- package/src/graphql/resolvers/state.resolver.ts +23 -0
- package/src/graphql/types/agents-response.type.ts +1 -4
- package/src/graphql/types/copilot-response.type.ts +5 -1
- package/src/graphql/types/extensions-response.type.ts +23 -0
- package/src/graphql/types/load-agent-state-response.type.ts +17 -0
- package/src/lib/integrations/shared.ts +2 -1
- package/src/lib/runtime/copilot-runtime.ts +102 -9
- package/src/lib/runtime/remote-lg-action.ts +24 -12
- package/src/service-adapters/anthropic/anthropic-adapter.ts +2 -3
- package/src/service-adapters/empty/empty-adapter.ts +2 -2
- package/src/service-adapters/events.ts +5 -0
- package/src/service-adapters/experimental/ollama/ollama-adapter.ts +2 -2
- package/src/service-adapters/groq/groq-adapter.ts +2 -2
- package/src/service-adapters/langchain/langchain-adapter.ts +10 -3
- package/src/service-adapters/openai/openai-adapter.ts +4 -3
- package/src/service-adapters/openai/openai-assistant-adapter.ts +15 -4
- package/src/service-adapters/service-adapter.ts +4 -0
- package/src/service-adapters/unify/unify-adapter.ts +2 -3
- package/dist/chunk-ON4AESON.mjs.map +0 -1
- package/dist/chunk-TPTCSIAR.mjs.map +0 -1
- /package/dist/{chunk-XM2VJFL6.mjs.map → chunk-4LRVKGBI.mjs.map} +0 -0
- /package/dist/{chunk-YGXAWYRB.mjs.map → chunk-IS3QAGOU.mjs.map} +0 -0
- /package/dist/{chunk-BKIGYRXE.mjs.map → chunk-W6EE6OTN.mjs.map} +0 -0
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EmptyAdapter,
|
|
3
|
-
RemoteChain,
|
|
4
|
-
streamLangChainResponse
|
|
5
|
-
} from "./chunk-TPTCSIAR.mjs";
|
|
6
1
|
import {
|
|
7
2
|
GuardrailsValidationFailureResponse,
|
|
8
3
|
MessageStreamInterruptedResponse,
|
|
@@ -10,6 +5,11 @@ import {
|
|
|
10
5
|
SuccessResponseStatus,
|
|
11
6
|
UnknownErrorResponse
|
|
12
7
|
} from "./chunk-U3V2BCGI.mjs";
|
|
8
|
+
import {
|
|
9
|
+
EmptyAdapter,
|
|
10
|
+
RemoteChain,
|
|
11
|
+
streamLangChainResponse
|
|
12
|
+
} from "./chunk-S3KKBII4.mjs";
|
|
13
13
|
import {
|
|
14
14
|
ActionExecutionMessage,
|
|
15
15
|
AgentStateMessage,
|
|
@@ -38,7 +38,7 @@ var require_package = __commonJS({
|
|
|
38
38
|
publishConfig: {
|
|
39
39
|
access: "public"
|
|
40
40
|
},
|
|
41
|
-
version: "1.5.12
|
|
41
|
+
version: "1.5.12",
|
|
42
42
|
sideEffects: false,
|
|
43
43
|
main: "./dist/index.js",
|
|
44
44
|
module: "./dist/index.mjs",
|
|
@@ -126,7 +126,7 @@ import { Arg, Ctx, Mutation, Query, Resolver } from "type-graphql";
|
|
|
126
126
|
import { ReplaySubject as ReplaySubject3, Subject, filter, finalize, firstValueFrom as firstValueFrom2, shareReplay, skipWhile, take, takeWhile, tap } from "rxjs";
|
|
127
127
|
|
|
128
128
|
// src/graphql/inputs/generate-copilot-response.input.ts
|
|
129
|
-
import { Field as
|
|
129
|
+
import { Field as Field10, InputType as InputType10 } from "type-graphql";
|
|
130
130
|
|
|
131
131
|
// src/graphql/inputs/message.input.ts
|
|
132
132
|
import { Field, InputType } from "type-graphql";
|
|
@@ -680,7 +680,8 @@ AgentStateInput = _ts_decorate8([
|
|
|
680
680
|
InputType8()
|
|
681
681
|
], AgentStateInput);
|
|
682
682
|
|
|
683
|
-
// src/graphql/inputs/
|
|
683
|
+
// src/graphql/inputs/extensions.input.ts
|
|
684
|
+
import { Field as Field9, InputType as InputType9 } from "type-graphql";
|
|
684
685
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
685
686
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
686
687
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -697,18 +698,69 @@ function _ts_metadata9(k, v) {
|
|
|
697
698
|
return Reflect.metadata(k, v);
|
|
698
699
|
}
|
|
699
700
|
__name(_ts_metadata9, "_ts_metadata");
|
|
701
|
+
var ExtensionsInput = class {
|
|
702
|
+
openaiAssistantAPI;
|
|
703
|
+
};
|
|
704
|
+
__name(ExtensionsInput, "ExtensionsInput");
|
|
705
|
+
_ts_decorate9([
|
|
706
|
+
Field9(() => OpenAIApiAssistantAPIInput, {
|
|
707
|
+
nullable: true
|
|
708
|
+
}),
|
|
709
|
+
_ts_metadata9("design:type", typeof OpenAIApiAssistantAPIInput === "undefined" ? Object : OpenAIApiAssistantAPIInput)
|
|
710
|
+
], ExtensionsInput.prototype, "openaiAssistantAPI", void 0);
|
|
711
|
+
ExtensionsInput = _ts_decorate9([
|
|
712
|
+
InputType9()
|
|
713
|
+
], ExtensionsInput);
|
|
714
|
+
var OpenAIApiAssistantAPIInput = class {
|
|
715
|
+
runId;
|
|
716
|
+
threadId;
|
|
717
|
+
};
|
|
718
|
+
__name(OpenAIApiAssistantAPIInput, "OpenAIApiAssistantAPIInput");
|
|
719
|
+
_ts_decorate9([
|
|
720
|
+
Field9(() => String, {
|
|
721
|
+
nullable: true
|
|
722
|
+
}),
|
|
723
|
+
_ts_metadata9("design:type", String)
|
|
724
|
+
], OpenAIApiAssistantAPIInput.prototype, "runId", void 0);
|
|
725
|
+
_ts_decorate9([
|
|
726
|
+
Field9(() => String, {
|
|
727
|
+
nullable: true
|
|
728
|
+
}),
|
|
729
|
+
_ts_metadata9("design:type", String)
|
|
730
|
+
], OpenAIApiAssistantAPIInput.prototype, "threadId", void 0);
|
|
731
|
+
OpenAIApiAssistantAPIInput = _ts_decorate9([
|
|
732
|
+
InputType9()
|
|
733
|
+
], OpenAIApiAssistantAPIInput);
|
|
734
|
+
|
|
735
|
+
// src/graphql/inputs/generate-copilot-response.input.ts
|
|
736
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
737
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
738
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
739
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
740
|
+
else
|
|
741
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
742
|
+
if (d = decorators[i])
|
|
743
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
744
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
745
|
+
}
|
|
746
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
747
|
+
function _ts_metadata10(k, v) {
|
|
748
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
749
|
+
return Reflect.metadata(k, v);
|
|
750
|
+
}
|
|
751
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
700
752
|
var GenerateCopilotResponseMetadataInput = class {
|
|
701
753
|
requestType;
|
|
702
754
|
};
|
|
703
755
|
__name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
|
|
704
|
-
|
|
705
|
-
|
|
756
|
+
_ts_decorate10([
|
|
757
|
+
Field10(() => CopilotRequestType, {
|
|
706
758
|
nullable: true
|
|
707
759
|
}),
|
|
708
|
-
|
|
760
|
+
_ts_metadata10("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
|
|
709
761
|
], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
|
|
710
|
-
GenerateCopilotResponseMetadataInput =
|
|
711
|
-
|
|
762
|
+
GenerateCopilotResponseMetadataInput = _ts_decorate10([
|
|
763
|
+
InputType10()
|
|
712
764
|
], GenerateCopilotResponseMetadataInput);
|
|
713
765
|
var GenerateCopilotResponseInput = class {
|
|
714
766
|
metadata;
|
|
@@ -721,78 +773,85 @@ var GenerateCopilotResponseInput = class {
|
|
|
721
773
|
agentSession;
|
|
722
774
|
agentState;
|
|
723
775
|
agentStates;
|
|
776
|
+
extensions;
|
|
724
777
|
};
|
|
725
778
|
__name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
|
|
726
|
-
|
|
727
|
-
|
|
779
|
+
_ts_decorate10([
|
|
780
|
+
Field10(() => GenerateCopilotResponseMetadataInput, {
|
|
728
781
|
nullable: false
|
|
729
782
|
}),
|
|
730
|
-
|
|
783
|
+
_ts_metadata10("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
|
|
731
784
|
], GenerateCopilotResponseInput.prototype, "metadata", void 0);
|
|
732
|
-
|
|
733
|
-
|
|
785
|
+
_ts_decorate10([
|
|
786
|
+
Field10(() => String, {
|
|
734
787
|
nullable: true
|
|
735
788
|
}),
|
|
736
|
-
|
|
789
|
+
_ts_metadata10("design:type", String)
|
|
737
790
|
], GenerateCopilotResponseInput.prototype, "threadId", void 0);
|
|
738
|
-
|
|
739
|
-
|
|
791
|
+
_ts_decorate10([
|
|
792
|
+
Field10(() => String, {
|
|
740
793
|
nullable: true
|
|
741
794
|
}),
|
|
742
|
-
|
|
795
|
+
_ts_metadata10("design:type", String)
|
|
743
796
|
], GenerateCopilotResponseInput.prototype, "runId", void 0);
|
|
744
|
-
|
|
745
|
-
|
|
797
|
+
_ts_decorate10([
|
|
798
|
+
Field10(() => [
|
|
746
799
|
MessageInput
|
|
747
800
|
]),
|
|
748
|
-
|
|
801
|
+
_ts_metadata10("design:type", Array)
|
|
749
802
|
], GenerateCopilotResponseInput.prototype, "messages", void 0);
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
803
|
+
_ts_decorate10([
|
|
804
|
+
Field10(() => FrontendInput),
|
|
805
|
+
_ts_metadata10("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
|
|
753
806
|
], GenerateCopilotResponseInput.prototype, "frontend", void 0);
|
|
754
|
-
|
|
755
|
-
|
|
807
|
+
_ts_decorate10([
|
|
808
|
+
Field10(() => CloudInput, {
|
|
756
809
|
nullable: true
|
|
757
810
|
}),
|
|
758
|
-
|
|
811
|
+
_ts_metadata10("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
|
|
759
812
|
], GenerateCopilotResponseInput.prototype, "cloud", void 0);
|
|
760
|
-
|
|
761
|
-
|
|
813
|
+
_ts_decorate10([
|
|
814
|
+
Field10(() => ForwardedParametersInput, {
|
|
762
815
|
nullable: true
|
|
763
816
|
}),
|
|
764
|
-
|
|
817
|
+
_ts_metadata10("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
|
|
765
818
|
], GenerateCopilotResponseInput.prototype, "forwardedParameters", void 0);
|
|
766
|
-
|
|
767
|
-
|
|
819
|
+
_ts_decorate10([
|
|
820
|
+
Field10(() => AgentSessionInput, {
|
|
768
821
|
nullable: true
|
|
769
822
|
}),
|
|
770
|
-
|
|
823
|
+
_ts_metadata10("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
|
|
771
824
|
], GenerateCopilotResponseInput.prototype, "agentSession", void 0);
|
|
772
|
-
|
|
773
|
-
|
|
825
|
+
_ts_decorate10([
|
|
826
|
+
Field10(() => AgentStateInput, {
|
|
774
827
|
nullable: true
|
|
775
828
|
}),
|
|
776
|
-
|
|
829
|
+
_ts_metadata10("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
|
|
777
830
|
], GenerateCopilotResponseInput.prototype, "agentState", void 0);
|
|
778
|
-
|
|
779
|
-
|
|
831
|
+
_ts_decorate10([
|
|
832
|
+
Field10(() => [
|
|
780
833
|
AgentStateInput
|
|
781
834
|
], {
|
|
782
835
|
nullable: true
|
|
783
836
|
}),
|
|
784
|
-
|
|
837
|
+
_ts_metadata10("design:type", Array)
|
|
785
838
|
], GenerateCopilotResponseInput.prototype, "agentStates", void 0);
|
|
786
|
-
|
|
787
|
-
|
|
839
|
+
_ts_decorate10([
|
|
840
|
+
Field10(() => ExtensionsInput, {
|
|
841
|
+
nullable: true
|
|
842
|
+
}),
|
|
843
|
+
_ts_metadata10("design:type", typeof ExtensionsInput === "undefined" ? Object : ExtensionsInput)
|
|
844
|
+
], GenerateCopilotResponseInput.prototype, "extensions", void 0);
|
|
845
|
+
GenerateCopilotResponseInput = _ts_decorate10([
|
|
846
|
+
InputType10()
|
|
788
847
|
], GenerateCopilotResponseInput);
|
|
789
848
|
|
|
790
849
|
// src/graphql/types/copilot-response.type.ts
|
|
791
|
-
import { Field as
|
|
850
|
+
import { Field as Field13, InterfaceType, ObjectType as ObjectType3 } from "type-graphql";
|
|
792
851
|
|
|
793
852
|
// src/graphql/types/message-status.type.ts
|
|
794
|
-
import { Field as
|
|
795
|
-
function
|
|
853
|
+
import { Field as Field11, ObjectType, createUnionType, registerEnumType as registerEnumType2 } from "type-graphql";
|
|
854
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
796
855
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
797
856
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
798
857
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -802,12 +861,12 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
802
861
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
803
862
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
804
863
|
}
|
|
805
|
-
__name(
|
|
806
|
-
function
|
|
864
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
865
|
+
function _ts_metadata11(k, v) {
|
|
807
866
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
808
867
|
return Reflect.metadata(k, v);
|
|
809
868
|
}
|
|
810
|
-
__name(
|
|
869
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
811
870
|
var MessageStatusCode;
|
|
812
871
|
(function(MessageStatusCode2) {
|
|
813
872
|
MessageStatusCode2["Pending"] = "pending";
|
|
@@ -820,25 +879,25 @@ registerEnumType2(MessageStatusCode, {
|
|
|
820
879
|
var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
|
|
821
880
|
code;
|
|
822
881
|
}, "BaseMessageStatus");
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
882
|
+
_ts_decorate11([
|
|
883
|
+
Field11(() => MessageStatusCode),
|
|
884
|
+
_ts_metadata11("design:type", String)
|
|
826
885
|
], BaseMessageStatus.prototype, "code", void 0);
|
|
827
|
-
BaseMessageStatus =
|
|
886
|
+
BaseMessageStatus = _ts_decorate11([
|
|
828
887
|
ObjectType()
|
|
829
888
|
], BaseMessageStatus);
|
|
830
889
|
var PendingMessageStatus = class extends BaseMessageStatus {
|
|
831
890
|
code = "pending";
|
|
832
891
|
};
|
|
833
892
|
__name(PendingMessageStatus, "PendingMessageStatus");
|
|
834
|
-
PendingMessageStatus =
|
|
893
|
+
PendingMessageStatus = _ts_decorate11([
|
|
835
894
|
ObjectType()
|
|
836
895
|
], PendingMessageStatus);
|
|
837
896
|
var SuccessMessageStatus = class extends BaseMessageStatus {
|
|
838
897
|
code = "success";
|
|
839
898
|
};
|
|
840
899
|
__name(SuccessMessageStatus, "SuccessMessageStatus");
|
|
841
|
-
SuccessMessageStatus =
|
|
900
|
+
SuccessMessageStatus = _ts_decorate11([
|
|
842
901
|
ObjectType()
|
|
843
902
|
], SuccessMessageStatus);
|
|
844
903
|
var FailedMessageStatus = class extends BaseMessageStatus {
|
|
@@ -846,11 +905,11 @@ var FailedMessageStatus = class extends BaseMessageStatus {
|
|
|
846
905
|
reason;
|
|
847
906
|
};
|
|
848
907
|
__name(FailedMessageStatus, "FailedMessageStatus");
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
908
|
+
_ts_decorate11([
|
|
909
|
+
Field11(() => String),
|
|
910
|
+
_ts_metadata11("design:type", String)
|
|
852
911
|
], FailedMessageStatus.prototype, "reason", void 0);
|
|
853
|
-
FailedMessageStatus =
|
|
912
|
+
FailedMessageStatus = _ts_decorate11([
|
|
854
913
|
ObjectType()
|
|
855
914
|
], FailedMessageStatus);
|
|
856
915
|
var MessageStatusUnion = createUnionType({
|
|
@@ -862,8 +921,60 @@ var MessageStatusUnion = createUnionType({
|
|
|
862
921
|
]
|
|
863
922
|
});
|
|
864
923
|
|
|
924
|
+
// src/graphql/types/extensions-response.type.ts
|
|
925
|
+
import { Field as Field12, ObjectType as ObjectType2 } from "type-graphql";
|
|
926
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
927
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
928
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
929
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
930
|
+
else
|
|
931
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
932
|
+
if (d = decorators[i])
|
|
933
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
934
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
935
|
+
}
|
|
936
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
937
|
+
function _ts_metadata12(k, v) {
|
|
938
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
939
|
+
return Reflect.metadata(k, v);
|
|
940
|
+
}
|
|
941
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
942
|
+
var ExtensionsResponse = class {
|
|
943
|
+
openaiAssistantAPI;
|
|
944
|
+
};
|
|
945
|
+
__name(ExtensionsResponse, "ExtensionsResponse");
|
|
946
|
+
_ts_decorate12([
|
|
947
|
+
Field12(() => OpenAIApiAssistantAPIResponse, {
|
|
948
|
+
nullable: true
|
|
949
|
+
}),
|
|
950
|
+
_ts_metadata12("design:type", typeof OpenAIApiAssistantAPIResponse === "undefined" ? Object : OpenAIApiAssistantAPIResponse)
|
|
951
|
+
], ExtensionsResponse.prototype, "openaiAssistantAPI", void 0);
|
|
952
|
+
ExtensionsResponse = _ts_decorate12([
|
|
953
|
+
ObjectType2()
|
|
954
|
+
], ExtensionsResponse);
|
|
955
|
+
var OpenAIApiAssistantAPIResponse = class {
|
|
956
|
+
runId;
|
|
957
|
+
threadId;
|
|
958
|
+
};
|
|
959
|
+
__name(OpenAIApiAssistantAPIResponse, "OpenAIApiAssistantAPIResponse");
|
|
960
|
+
_ts_decorate12([
|
|
961
|
+
Field12(() => String, {
|
|
962
|
+
nullable: true
|
|
963
|
+
}),
|
|
964
|
+
_ts_metadata12("design:type", String)
|
|
965
|
+
], OpenAIApiAssistantAPIResponse.prototype, "runId", void 0);
|
|
966
|
+
_ts_decorate12([
|
|
967
|
+
Field12(() => String, {
|
|
968
|
+
nullable: true
|
|
969
|
+
}),
|
|
970
|
+
_ts_metadata12("design:type", String)
|
|
971
|
+
], OpenAIApiAssistantAPIResponse.prototype, "threadId", void 0);
|
|
972
|
+
OpenAIApiAssistantAPIResponse = _ts_decorate12([
|
|
973
|
+
ObjectType2()
|
|
974
|
+
], OpenAIApiAssistantAPIResponse);
|
|
975
|
+
|
|
865
976
|
// src/graphql/types/copilot-response.type.ts
|
|
866
|
-
function
|
|
977
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
867
978
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
868
979
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
869
980
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -873,30 +984,31 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
873
984
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
874
985
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
875
986
|
}
|
|
876
|
-
__name(
|
|
877
|
-
function
|
|
987
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
988
|
+
function _ts_metadata13(k, v) {
|
|
878
989
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
879
990
|
return Reflect.metadata(k, v);
|
|
880
991
|
}
|
|
881
|
-
__name(
|
|
882
|
-
var BaseMessageOutput =
|
|
992
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
993
|
+
var BaseMessageOutput = class {
|
|
883
994
|
id;
|
|
884
995
|
createdAt;
|
|
885
996
|
status;
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
997
|
+
};
|
|
998
|
+
__name(BaseMessageOutput, "BaseMessageOutput");
|
|
999
|
+
_ts_decorate13([
|
|
1000
|
+
Field13(() => String),
|
|
1001
|
+
_ts_metadata13("design:type", String)
|
|
890
1002
|
], BaseMessageOutput.prototype, "id", void 0);
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1003
|
+
_ts_decorate13([
|
|
1004
|
+
Field13(() => Date),
|
|
1005
|
+
_ts_metadata13("design:type", typeof Date === "undefined" ? Object : Date)
|
|
894
1006
|
], BaseMessageOutput.prototype, "createdAt", void 0);
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
1007
|
+
_ts_decorate13([
|
|
1008
|
+
Field13(() => MessageStatusUnion),
|
|
1009
|
+
_ts_metadata13("design:type", Object)
|
|
898
1010
|
], BaseMessageOutput.prototype, "status", void 0);
|
|
899
|
-
BaseMessageOutput =
|
|
1011
|
+
BaseMessageOutput = _ts_decorate13([
|
|
900
1012
|
InterfaceType({
|
|
901
1013
|
resolveType(value) {
|
|
902
1014
|
if (value.hasOwnProperty("content")) {
|
|
@@ -918,24 +1030,24 @@ var TextMessageOutput = class {
|
|
|
918
1030
|
parentMessageId;
|
|
919
1031
|
};
|
|
920
1032
|
__name(TextMessageOutput, "TextMessageOutput");
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
1033
|
+
_ts_decorate13([
|
|
1034
|
+
Field13(() => MessageRole),
|
|
1035
|
+
_ts_metadata13("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
|
|
924
1036
|
], TextMessageOutput.prototype, "role", void 0);
|
|
925
|
-
|
|
926
|
-
|
|
1037
|
+
_ts_decorate13([
|
|
1038
|
+
Field13(() => [
|
|
927
1039
|
String
|
|
928
1040
|
]),
|
|
929
|
-
|
|
1041
|
+
_ts_metadata13("design:type", Array)
|
|
930
1042
|
], TextMessageOutput.prototype, "content", void 0);
|
|
931
|
-
|
|
932
|
-
|
|
1043
|
+
_ts_decorate13([
|
|
1044
|
+
Field13(() => String, {
|
|
933
1045
|
nullable: true
|
|
934
1046
|
}),
|
|
935
|
-
|
|
1047
|
+
_ts_metadata13("design:type", String)
|
|
936
1048
|
], TextMessageOutput.prototype, "parentMessageId", void 0);
|
|
937
|
-
TextMessageOutput =
|
|
938
|
-
|
|
1049
|
+
TextMessageOutput = _ts_decorate13([
|
|
1050
|
+
ObjectType3({
|
|
939
1051
|
implements: BaseMessageOutput
|
|
940
1052
|
})
|
|
941
1053
|
], TextMessageOutput);
|
|
@@ -946,31 +1058,31 @@ var ActionExecutionMessageOutput = class {
|
|
|
946
1058
|
parentMessageId;
|
|
947
1059
|
};
|
|
948
1060
|
__name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1061
|
+
_ts_decorate13([
|
|
1062
|
+
Field13(() => String),
|
|
1063
|
+
_ts_metadata13("design:type", String)
|
|
952
1064
|
], ActionExecutionMessageOutput.prototype, "name", void 0);
|
|
953
|
-
|
|
954
|
-
|
|
1065
|
+
_ts_decorate13([
|
|
1066
|
+
Field13(() => String, {
|
|
955
1067
|
nullable: true,
|
|
956
1068
|
deprecationReason: "This field will be removed in a future version"
|
|
957
1069
|
}),
|
|
958
|
-
|
|
1070
|
+
_ts_metadata13("design:type", String)
|
|
959
1071
|
], ActionExecutionMessageOutput.prototype, "scope", void 0);
|
|
960
|
-
|
|
961
|
-
|
|
1072
|
+
_ts_decorate13([
|
|
1073
|
+
Field13(() => [
|
|
962
1074
|
String
|
|
963
1075
|
]),
|
|
964
|
-
|
|
1076
|
+
_ts_metadata13("design:type", Array)
|
|
965
1077
|
], ActionExecutionMessageOutput.prototype, "arguments", void 0);
|
|
966
|
-
|
|
967
|
-
|
|
1078
|
+
_ts_decorate13([
|
|
1079
|
+
Field13(() => String, {
|
|
968
1080
|
nullable: true
|
|
969
1081
|
}),
|
|
970
|
-
|
|
1082
|
+
_ts_metadata13("design:type", String)
|
|
971
1083
|
], ActionExecutionMessageOutput.prototype, "parentMessageId", void 0);
|
|
972
|
-
ActionExecutionMessageOutput =
|
|
973
|
-
|
|
1084
|
+
ActionExecutionMessageOutput = _ts_decorate13([
|
|
1085
|
+
ObjectType3({
|
|
974
1086
|
implements: BaseMessageOutput
|
|
975
1087
|
})
|
|
976
1088
|
], ActionExecutionMessageOutput);
|
|
@@ -980,20 +1092,20 @@ var ResultMessageOutput = class {
|
|
|
980
1092
|
result;
|
|
981
1093
|
};
|
|
982
1094
|
__name(ResultMessageOutput, "ResultMessageOutput");
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1095
|
+
_ts_decorate13([
|
|
1096
|
+
Field13(() => String),
|
|
1097
|
+
_ts_metadata13("design:type", String)
|
|
986
1098
|
], ResultMessageOutput.prototype, "actionExecutionId", void 0);
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
1099
|
+
_ts_decorate13([
|
|
1100
|
+
Field13(() => String),
|
|
1101
|
+
_ts_metadata13("design:type", String)
|
|
990
1102
|
], ResultMessageOutput.prototype, "actionName", void 0);
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1103
|
+
_ts_decorate13([
|
|
1104
|
+
Field13(() => String),
|
|
1105
|
+
_ts_metadata13("design:type", String)
|
|
994
1106
|
], ResultMessageOutput.prototype, "result", void 0);
|
|
995
|
-
ResultMessageOutput =
|
|
996
|
-
|
|
1107
|
+
ResultMessageOutput = _ts_decorate13([
|
|
1108
|
+
ObjectType3({
|
|
997
1109
|
implements: BaseMessageOutput
|
|
998
1110
|
})
|
|
999
1111
|
], ResultMessageOutput);
|
|
@@ -1008,40 +1120,40 @@ var AgentStateMessageOutput = class {
|
|
|
1008
1120
|
running;
|
|
1009
1121
|
};
|
|
1010
1122
|
__name(AgentStateMessageOutput, "AgentStateMessageOutput");
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1123
|
+
_ts_decorate13([
|
|
1124
|
+
Field13(() => String),
|
|
1125
|
+
_ts_metadata13("design:type", String)
|
|
1014
1126
|
], AgentStateMessageOutput.prototype, "threadId", void 0);
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1127
|
+
_ts_decorate13([
|
|
1128
|
+
Field13(() => String),
|
|
1129
|
+
_ts_metadata13("design:type", String)
|
|
1018
1130
|
], AgentStateMessageOutput.prototype, "agentName", void 0);
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1131
|
+
_ts_decorate13([
|
|
1132
|
+
Field13(() => String),
|
|
1133
|
+
_ts_metadata13("design:type", String)
|
|
1022
1134
|
], AgentStateMessageOutput.prototype, "nodeName", void 0);
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1135
|
+
_ts_decorate13([
|
|
1136
|
+
Field13(() => String),
|
|
1137
|
+
_ts_metadata13("design:type", String)
|
|
1026
1138
|
], AgentStateMessageOutput.prototype, "runId", void 0);
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1139
|
+
_ts_decorate13([
|
|
1140
|
+
Field13(() => Boolean),
|
|
1141
|
+
_ts_metadata13("design:type", Boolean)
|
|
1030
1142
|
], AgentStateMessageOutput.prototype, "active", void 0);
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1143
|
+
_ts_decorate13([
|
|
1144
|
+
Field13(() => MessageRole),
|
|
1145
|
+
_ts_metadata13("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
|
|
1034
1146
|
], AgentStateMessageOutput.prototype, "role", void 0);
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1147
|
+
_ts_decorate13([
|
|
1148
|
+
Field13(() => String),
|
|
1149
|
+
_ts_metadata13("design:type", String)
|
|
1038
1150
|
], AgentStateMessageOutput.prototype, "state", void 0);
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1151
|
+
_ts_decorate13([
|
|
1152
|
+
Field13(() => Boolean),
|
|
1153
|
+
_ts_metadata13("design:type", Boolean)
|
|
1042
1154
|
], AgentStateMessageOutput.prototype, "running", void 0);
|
|
1043
|
-
AgentStateMessageOutput =
|
|
1044
|
-
|
|
1155
|
+
AgentStateMessageOutput = _ts_decorate13([
|
|
1156
|
+
ObjectType3({
|
|
1045
1157
|
implements: BaseMessageOutput
|
|
1046
1158
|
})
|
|
1047
1159
|
], AgentStateMessageOutput);
|
|
@@ -1050,30 +1162,37 @@ var CopilotResponse = class {
|
|
|
1050
1162
|
status;
|
|
1051
1163
|
runId;
|
|
1052
1164
|
messages;
|
|
1165
|
+
extensions;
|
|
1053
1166
|
};
|
|
1054
1167
|
__name(CopilotResponse, "CopilotResponse");
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1168
|
+
_ts_decorate13([
|
|
1169
|
+
Field13(() => String),
|
|
1170
|
+
_ts_metadata13("design:type", String)
|
|
1058
1171
|
], CopilotResponse.prototype, "threadId", void 0);
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1172
|
+
_ts_decorate13([
|
|
1173
|
+
Field13(() => ResponseStatusUnion),
|
|
1174
|
+
_ts_metadata13("design:type", Object)
|
|
1062
1175
|
], CopilotResponse.prototype, "status", void 0);
|
|
1063
|
-
|
|
1064
|
-
|
|
1176
|
+
_ts_decorate13([
|
|
1177
|
+
Field13({
|
|
1065
1178
|
nullable: true
|
|
1066
1179
|
}),
|
|
1067
|
-
|
|
1180
|
+
_ts_metadata13("design:type", String)
|
|
1068
1181
|
], CopilotResponse.prototype, "runId", void 0);
|
|
1069
|
-
|
|
1070
|
-
|
|
1182
|
+
_ts_decorate13([
|
|
1183
|
+
Field13(() => [
|
|
1071
1184
|
BaseMessageOutput
|
|
1072
1185
|
]),
|
|
1073
|
-
|
|
1186
|
+
_ts_metadata13("design:type", Array)
|
|
1074
1187
|
], CopilotResponse.prototype, "messages", void 0);
|
|
1075
|
-
|
|
1076
|
-
|
|
1188
|
+
_ts_decorate13([
|
|
1189
|
+
Field13(() => ExtensionsResponse, {
|
|
1190
|
+
nullable: true
|
|
1191
|
+
}),
|
|
1192
|
+
_ts_metadata13("design:type", typeof ExtensionsResponse === "undefined" ? Object : ExtensionsResponse)
|
|
1193
|
+
], CopilotResponse.prototype, "extensions", void 0);
|
|
1194
|
+
CopilotResponse = _ts_decorate13([
|
|
1195
|
+
ObjectType3()
|
|
1077
1196
|
], CopilotResponse);
|
|
1078
1197
|
|
|
1079
1198
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
@@ -1331,7 +1450,8 @@ __name(RemoteLangGraphEventSource, "RemoteLangGraphEventSource");
|
|
|
1331
1450
|
|
|
1332
1451
|
// src/lib/runtime/remote-lg-action.ts
|
|
1333
1452
|
import { Client } from "@langchain/langgraph-sdk";
|
|
1334
|
-
import { createHash
|
|
1453
|
+
import { createHash } from "crypto";
|
|
1454
|
+
import { randomUUID, isValidUUID } from "@copilotkit/shared";
|
|
1335
1455
|
import { parse as parsePartialJson } from "partial-json";
|
|
1336
1456
|
async function execute(args) {
|
|
1337
1457
|
return new ReadableStream({
|
|
@@ -1347,7 +1467,7 @@ async function execute(args) {
|
|
|
1347
1467
|
__name(execute, "execute");
|
|
1348
1468
|
async function streamEvents(controller, args) {
|
|
1349
1469
|
var _a, _b, _c, _d, _e, _f;
|
|
1350
|
-
const { deploymentUrl, langsmithApiKey, threadId:
|
|
1470
|
+
const { deploymentUrl, langsmithApiKey, threadId: argsInitialThreadId, agent, nodeName: initialNodeName, state: initialState, messages, actions, logger: logger2 } = args;
|
|
1351
1471
|
let nodeName = initialNodeName;
|
|
1352
1472
|
let state = initialState;
|
|
1353
1473
|
const { name, assistantId: initialAssistantId } = agent;
|
|
@@ -1355,15 +1475,18 @@ async function streamEvents(controller, args) {
|
|
|
1355
1475
|
apiUrl: deploymentUrl,
|
|
1356
1476
|
apiKey: langsmithApiKey
|
|
1357
1477
|
});
|
|
1358
|
-
let
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1478
|
+
let threadId = argsInitialThreadId ?? randomUUID();
|
|
1479
|
+
if (argsInitialThreadId && argsInitialThreadId.startsWith("ck-")) {
|
|
1480
|
+
threadId = argsInitialThreadId.substring(3);
|
|
1481
|
+
}
|
|
1482
|
+
if (!isValidUUID(threadId)) {
|
|
1483
|
+
console.warn(`Cannot use the threadId ${threadId} with LangGraph Platform. Must be a valid UUID.`);
|
|
1362
1484
|
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1485
|
+
let wasInitiatedWithExistingThread = true;
|
|
1486
|
+
try {
|
|
1365
1487
|
await client.threads.get(threadId);
|
|
1366
|
-
}
|
|
1488
|
+
} catch (error) {
|
|
1489
|
+
wasInitiatedWithExistingThread = false;
|
|
1367
1490
|
await client.threads.create({
|
|
1368
1491
|
threadId
|
|
1369
1492
|
});
|
|
@@ -1376,7 +1499,7 @@ async function streamEvents(controller, args) {
|
|
|
1376
1499
|
}
|
|
1377
1500
|
const agentStateValues = agentState.values;
|
|
1378
1501
|
state.messages = agentStateValues.messages;
|
|
1379
|
-
const mode =
|
|
1502
|
+
const mode = threadId && nodeName != "__end__" && nodeName != void 0 && nodeName != null ? "continue" : "start";
|
|
1380
1503
|
let formattedMessages = [];
|
|
1381
1504
|
try {
|
|
1382
1505
|
formattedMessages = copilotkitMessagesToLangChain(messages);
|
|
@@ -2162,7 +2285,6 @@ import { createHash as createHash3 } from "crypto";
|
|
|
2162
2285
|
|
|
2163
2286
|
// src/lib/runtime/copilot-runtime.ts
|
|
2164
2287
|
import { actionParametersToJsonSchema, ResolvedCopilotKitError as ResolvedCopilotKitError2, CopilotKitApiDiscoveryError, randomId as randomId2, CopilotKitError as CopilotKitError3, CopilotKitLowLevelError as CopilotKitLowLevelError3, CopilotKitAgentDiscoveryError, CopilotKitMisuseError } from "@copilotkit/shared";
|
|
2165
|
-
import { Client as LangGraphClient } from "@langchain/langgraph-sdk";
|
|
2166
2288
|
|
|
2167
2289
|
// src/service-adapters/conversion.ts
|
|
2168
2290
|
import { plainToInstance } from "class-transformer";
|
|
@@ -2214,6 +2336,7 @@ __name(convertGqlInputToMessages, "convertGqlInputToMessages");
|
|
|
2214
2336
|
|
|
2215
2337
|
// src/lib/runtime/copilot-runtime.ts
|
|
2216
2338
|
import { from } from "rxjs";
|
|
2339
|
+
import { Client as LangGraphClient } from "@langchain/langgraph-sdk";
|
|
2217
2340
|
var CopilotRuntime = class {
|
|
2218
2341
|
actions;
|
|
2219
2342
|
remoteEndpointDefinitions;
|
|
@@ -2233,7 +2356,7 @@ var CopilotRuntime = class {
|
|
|
2233
2356
|
}
|
|
2234
2357
|
async processRuntimeRequest(request) {
|
|
2235
2358
|
var _a;
|
|
2236
|
-
const { serviceAdapter, messages: rawMessages, actions: clientSideActionsInput, threadId, runId, outputMessagesPromise, graphqlContext, forwardedParameters, agentSession, url } = request;
|
|
2359
|
+
const { serviceAdapter, messages: rawMessages, actions: clientSideActionsInput, threadId, runId, outputMessagesPromise, graphqlContext, forwardedParameters, agentSession, url, extensions } = request;
|
|
2237
2360
|
const eventSource = new RuntimeEventSource();
|
|
2238
2361
|
try {
|
|
2239
2362
|
if (agentSession) {
|
|
@@ -2274,12 +2397,14 @@ please use an LLM adapter instead.`
|
|
|
2274
2397
|
threadId,
|
|
2275
2398
|
runId,
|
|
2276
2399
|
eventSource,
|
|
2277
|
-
forwardedParameters
|
|
2400
|
+
forwardedParameters,
|
|
2401
|
+
extensions
|
|
2278
2402
|
});
|
|
2403
|
+
const nonEmptyThreadId = threadId ?? result.threadId;
|
|
2279
2404
|
outputMessagesPromise.then((outputMessages) => {
|
|
2280
2405
|
var _a2;
|
|
2281
2406
|
(_a2 = this.onAfterRequest) == null ? void 0 : _a2.call(this, {
|
|
2282
|
-
threadId:
|
|
2407
|
+
threadId: nonEmptyThreadId,
|
|
2283
2408
|
runId: result.runId,
|
|
2284
2409
|
inputMessages,
|
|
2285
2410
|
outputMessages,
|
|
@@ -2289,14 +2414,15 @@ please use an LLM adapter instead.`
|
|
|
2289
2414
|
}).catch((_error) => {
|
|
2290
2415
|
});
|
|
2291
2416
|
return {
|
|
2292
|
-
threadId:
|
|
2417
|
+
threadId: nonEmptyThreadId,
|
|
2293
2418
|
runId: result.runId,
|
|
2294
2419
|
eventSource,
|
|
2295
2420
|
serverSideActions,
|
|
2296
2421
|
actionInputsWithoutAgents: actionInputs.filter((action) => (
|
|
2297
2422
|
// TODO-AGENTS: do not exclude ALL server side actions
|
|
2298
2423
|
!serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
|
|
2299
|
-
))
|
|
2424
|
+
)),
|
|
2425
|
+
extensions: result.extensions
|
|
2300
2426
|
};
|
|
2301
2427
|
} catch (error) {
|
|
2302
2428
|
if (error instanceof CopilotKitError3) {
|
|
@@ -2349,8 +2475,9 @@ please use an LLM adapter instead.`
|
|
|
2349
2475
|
const data = await response.json();
|
|
2350
2476
|
const endpointAgents = ((data == null ? void 0 : data.agents) ?? []).map((agent) => ({
|
|
2351
2477
|
name: agent.name,
|
|
2352
|
-
description: agent.description ?? "",
|
|
2353
|
-
id: randomId2()
|
|
2478
|
+
description: agent.description ?? "" ?? "",
|
|
2479
|
+
id: randomId2(),
|
|
2480
|
+
endpoint
|
|
2354
2481
|
}));
|
|
2355
2482
|
return [
|
|
2356
2483
|
...agents2,
|
|
@@ -2368,10 +2495,62 @@ please use an LLM adapter instead.`
|
|
|
2368
2495
|
}, Promise.resolve([]));
|
|
2369
2496
|
return agents;
|
|
2370
2497
|
}
|
|
2498
|
+
async loadAgentState(graphqlContext, threadId, agentName) {
|
|
2499
|
+
const agentsWithEndpoints = await this.discoverAgentsFromEndpoints(graphqlContext);
|
|
2500
|
+
const agentWithEndpoint = agentsWithEndpoints.find((agent) => agent.name === agentName);
|
|
2501
|
+
if (!agentWithEndpoint) {
|
|
2502
|
+
throw new Error("Agent not found");
|
|
2503
|
+
}
|
|
2504
|
+
const headers = createHeaders(null, graphqlContext);
|
|
2505
|
+
if (agentWithEndpoint.endpoint.type === EndpointType.LangGraphPlatform) {
|
|
2506
|
+
const client = new LangGraphClient({
|
|
2507
|
+
apiUrl: agentWithEndpoint.endpoint.deploymentUrl,
|
|
2508
|
+
apiKey: agentWithEndpoint.endpoint.langsmithApiKey
|
|
2509
|
+
});
|
|
2510
|
+
const state = (await client.threads.getState(threadId)).values;
|
|
2511
|
+
if (Object.keys(state).length === 0) {
|
|
2512
|
+
return {
|
|
2513
|
+
threadId,
|
|
2514
|
+
threadExists: false,
|
|
2515
|
+
state: JSON.stringify({}),
|
|
2516
|
+
messages: JSON.stringify([])
|
|
2517
|
+
};
|
|
2518
|
+
} else {
|
|
2519
|
+
console.log(state);
|
|
2520
|
+
const { messages, ...stateWithoutMessages } = state;
|
|
2521
|
+
const copilotkitMessages = langchainMessagesToCopilotKit(messages);
|
|
2522
|
+
return {
|
|
2523
|
+
threadId,
|
|
2524
|
+
threadExists: true,
|
|
2525
|
+
state: JSON.stringify(stateWithoutMessages),
|
|
2526
|
+
messages: JSON.stringify(copilotkitMessages)
|
|
2527
|
+
};
|
|
2528
|
+
}
|
|
2529
|
+
} else if (agentWithEndpoint.endpoint.type === EndpointType.CopilotKit || !("type" in agentWithEndpoint.endpoint)) {
|
|
2530
|
+
const response = await fetch(`${agentWithEndpoint.endpoint.url}/agents/state`, {
|
|
2531
|
+
method: "POST",
|
|
2532
|
+
headers,
|
|
2533
|
+
body: JSON.stringify({
|
|
2534
|
+
properties: graphqlContext.properties,
|
|
2535
|
+
threadId,
|
|
2536
|
+
name: agentName
|
|
2537
|
+
})
|
|
2538
|
+
});
|
|
2539
|
+
const data = await response.json();
|
|
2540
|
+
return {
|
|
2541
|
+
...data,
|
|
2542
|
+
state: JSON.stringify(data.state),
|
|
2543
|
+
messages: JSON.stringify(data.messages)
|
|
2544
|
+
};
|
|
2545
|
+
} else {
|
|
2546
|
+
throw new Error(`Unknown endpoint type: ${agentWithEndpoint.endpoint.type}`);
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2371
2549
|
async processAgentRequest(request) {
|
|
2372
2550
|
var _a;
|
|
2373
|
-
const { messages: rawMessages, outputMessagesPromise, graphqlContext, agentSession } = request;
|
|
2374
|
-
const {
|
|
2551
|
+
const { messages: rawMessages, outputMessagesPromise, graphqlContext, agentSession, threadId: threadIdFromRequest } = request;
|
|
2552
|
+
const { agentName, nodeName } = agentSession;
|
|
2553
|
+
const threadId = threadIdFromRequest ?? agentSession.threadId;
|
|
2375
2554
|
const serverSideActions = await this.getServerSideActions(request);
|
|
2376
2555
|
const messages = convertGqlInputToMessages(rawMessages);
|
|
2377
2556
|
const agent = serverSideActions.find((action) => action.name === agentName && isLangGraphAgentAction(action));
|
|
@@ -2679,7 +2858,7 @@ var RuntimeEventSource = class {
|
|
|
2679
2858
|
this.eventStream$.sendTextMessage(randomId3(), errorMessage);
|
|
2680
2859
|
}
|
|
2681
2860
|
}
|
|
2682
|
-
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents }) {
|
|
2861
|
+
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId }) {
|
|
2683
2862
|
this.callback(this.eventStream$).catch((error) => {
|
|
2684
2863
|
console.error("Error in event source callback", error);
|
|
2685
2864
|
this.sendErrorMessageToChat();
|
|
@@ -2715,7 +2894,7 @@ var RuntimeEventSource = class {
|
|
|
2715
2894
|
concatMap((eventWithState) => {
|
|
2716
2895
|
if (eventWithState.event.type === "ActionExecutionEnd" && eventWithState.callActionServerSide) {
|
|
2717
2896
|
const toolCallEventStream$ = new RuntimeEventSubject();
|
|
2718
|
-
executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionParentMessageId, eventWithState.actionExecutionId, actionInputsWithoutAgents).catch((error) => {
|
|
2897
|
+
executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionParentMessageId, eventWithState.actionExecutionId, actionInputsWithoutAgents, threadId).catch((error) => {
|
|
2719
2898
|
console.error(error);
|
|
2720
2899
|
});
|
|
2721
2900
|
telemetry_client_default.capture("oss.runtime.server_action_executed", {});
|
|
@@ -2732,7 +2911,7 @@ var RuntimeEventSource = class {
|
|
|
2732
2911
|
}
|
|
2733
2912
|
};
|
|
2734
2913
|
__name(RuntimeEventSource, "RuntimeEventSource");
|
|
2735
|
-
async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionParentMessageId, actionExecutionId, actionInputsWithoutAgents) {
|
|
2914
|
+
async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionParentMessageId, actionExecutionId, actionInputsWithoutAgents, threadId) {
|
|
2736
2915
|
var _a;
|
|
2737
2916
|
if (guardrailsResult$) {
|
|
2738
2917
|
const { status } = await firstValueFrom(guardrailsResult$);
|
|
@@ -2783,6 +2962,7 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
|
|
|
2783
2962
|
});
|
|
2784
2963
|
const stream = await action.langGraphAgentHandler({
|
|
2785
2964
|
name: action.name,
|
|
2965
|
+
threadId,
|
|
2786
2966
|
actionInputsWithoutAgents,
|
|
2787
2967
|
additionalMessages: [
|
|
2788
2968
|
agentExecution,
|
|
@@ -2839,8 +3019,8 @@ import { GraphQLError } from "graphql";
|
|
|
2839
3019
|
import { randomId as randomId4 } from "@copilotkit/shared";
|
|
2840
3020
|
|
|
2841
3021
|
// src/graphql/types/agents-response.type.ts
|
|
2842
|
-
import { Field as
|
|
2843
|
-
function
|
|
3022
|
+
import { Field as Field14, ObjectType as ObjectType4 } from "type-graphql";
|
|
3023
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2844
3024
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2845
3025
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2846
3026
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2850,49 +3030,49 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
2850
3030
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2851
3031
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2852
3032
|
}
|
|
2853
|
-
__name(
|
|
2854
|
-
function
|
|
3033
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
3034
|
+
function _ts_metadata14(k, v) {
|
|
2855
3035
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2856
3036
|
return Reflect.metadata(k, v);
|
|
2857
3037
|
}
|
|
2858
|
-
__name(
|
|
3038
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2859
3039
|
var Agent = class {
|
|
2860
3040
|
id;
|
|
2861
3041
|
name;
|
|
2862
3042
|
description;
|
|
2863
3043
|
};
|
|
2864
3044
|
__name(Agent, "Agent");
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
3045
|
+
_ts_decorate14([
|
|
3046
|
+
Field14(() => String),
|
|
3047
|
+
_ts_metadata14("design:type", String)
|
|
2868
3048
|
], Agent.prototype, "id", void 0);
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
3049
|
+
_ts_decorate14([
|
|
3050
|
+
Field14(() => String),
|
|
3051
|
+
_ts_metadata14("design:type", String)
|
|
2872
3052
|
], Agent.prototype, "name", void 0);
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
3053
|
+
_ts_decorate14([
|
|
3054
|
+
Field14(() => String),
|
|
3055
|
+
_ts_metadata14("design:type", String)
|
|
2876
3056
|
], Agent.prototype, "description", void 0);
|
|
2877
|
-
Agent =
|
|
2878
|
-
|
|
3057
|
+
Agent = _ts_decorate14([
|
|
3058
|
+
ObjectType4()
|
|
2879
3059
|
], Agent);
|
|
2880
3060
|
var AgentsResponse = class {
|
|
2881
3061
|
agents;
|
|
2882
3062
|
};
|
|
2883
3063
|
__name(AgentsResponse, "AgentsResponse");
|
|
2884
|
-
|
|
2885
|
-
|
|
3064
|
+
_ts_decorate14([
|
|
3065
|
+
Field14(() => [
|
|
2886
3066
|
Agent
|
|
2887
3067
|
]),
|
|
2888
|
-
|
|
3068
|
+
_ts_metadata14("design:type", Array)
|
|
2889
3069
|
], AgentsResponse.prototype, "agents", void 0);
|
|
2890
|
-
AgentsResponse =
|
|
2891
|
-
|
|
3070
|
+
AgentsResponse = _ts_decorate14([
|
|
3071
|
+
ObjectType4()
|
|
2892
3072
|
], AgentsResponse);
|
|
2893
3073
|
|
|
2894
3074
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
2895
|
-
function
|
|
3075
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2896
3076
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2897
3077
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2898
3078
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2902,12 +3082,12 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
2902
3082
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2903
3083
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2904
3084
|
}
|
|
2905
|
-
__name(
|
|
2906
|
-
function
|
|
3085
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
3086
|
+
function _ts_metadata15(k, v) {
|
|
2907
3087
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2908
3088
|
return Reflect.metadata(k, v);
|
|
2909
3089
|
}
|
|
2910
|
-
__name(
|
|
3090
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
2911
3091
|
function _ts_param(paramIndex, decorator) {
|
|
2912
3092
|
return function(target, key) {
|
|
2913
3093
|
decorator(target, key, paramIndex);
|
|
@@ -2954,10 +3134,10 @@ var CopilotResolver = class {
|
|
|
2954
3134
|
component: "CopilotResolver.availableAgents"
|
|
2955
3135
|
});
|
|
2956
3136
|
logger2.debug("Processing");
|
|
2957
|
-
const
|
|
3137
|
+
const agentsWithEndpoints = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
|
|
2958
3138
|
logger2.debug("Event source created, creating response");
|
|
2959
3139
|
return {
|
|
2960
|
-
agents
|
|
3140
|
+
agents: agentsWithEndpoints.map(({ endpoint, ...agentWithoutEndpoint }) => agentWithoutEndpoint)
|
|
2961
3141
|
};
|
|
2962
3142
|
}
|
|
2963
3143
|
async generateCopilotResponse(ctx, data, properties) {
|
|
@@ -3019,7 +3199,7 @@ var CopilotResolver = class {
|
|
|
3019
3199
|
rejectOutputMessagesPromise = reject;
|
|
3020
3200
|
});
|
|
3021
3201
|
logger2.debug("Processing");
|
|
3022
|
-
const { eventSource, threadId = randomId4(), runId, serverSideActions, actionInputsWithoutAgents } = await copilotRuntime.processRuntimeRequest({
|
|
3202
|
+
const { eventSource, threadId = randomId4(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = await copilotRuntime.processRuntimeRequest({
|
|
3023
3203
|
serviceAdapter,
|
|
3024
3204
|
messages: data.messages,
|
|
3025
3205
|
actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
|
|
@@ -3031,13 +3211,15 @@ var CopilotResolver = class {
|
|
|
3031
3211
|
forwardedParameters: data.forwardedParameters,
|
|
3032
3212
|
agentSession: data.agentSession,
|
|
3033
3213
|
agentStates: data.agentStates,
|
|
3034
|
-
url: data.frontend.url
|
|
3214
|
+
url: data.frontend.url,
|
|
3215
|
+
extensions: data.extensions
|
|
3035
3216
|
});
|
|
3036
3217
|
logger2.debug("Event source created, creating response");
|
|
3037
3218
|
const response = {
|
|
3038
3219
|
threadId,
|
|
3039
3220
|
runId,
|
|
3040
3221
|
status: firstValueFrom2(responseStatus$),
|
|
3222
|
+
extensions,
|
|
3041
3223
|
messages: new Repeater(async (pushMessage, stopStreamingMessages) => {
|
|
3042
3224
|
var _a2, _b2;
|
|
3043
3225
|
logger2.debug("Messages repeater created");
|
|
@@ -3094,7 +3276,8 @@ var CopilotResolver = class {
|
|
|
3094
3276
|
actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
|
|
3095
3277
|
// TODO-AGENTS: do not exclude ALL server side actions
|
|
3096
3278
|
(action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
|
|
3097
|
-
)
|
|
3279
|
+
),
|
|
3280
|
+
threadId
|
|
3098
3281
|
}).pipe(
|
|
3099
3282
|
// shareReplay() ensures that later subscribers will see the whole stream instead of
|
|
3100
3283
|
// just the events that were emitted after the subscriber was added.
|
|
@@ -3312,37 +3495,37 @@ var CopilotResolver = class {
|
|
|
3312
3495
|
}
|
|
3313
3496
|
};
|
|
3314
3497
|
__name(CopilotResolver, "CopilotResolver");
|
|
3315
|
-
|
|
3498
|
+
_ts_decorate15([
|
|
3316
3499
|
Query(() => String),
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3500
|
+
_ts_metadata15("design:type", Function),
|
|
3501
|
+
_ts_metadata15("design:paramtypes", []),
|
|
3502
|
+
_ts_metadata15("design:returntype", Promise)
|
|
3320
3503
|
], CopilotResolver.prototype, "hello", null);
|
|
3321
|
-
|
|
3504
|
+
_ts_decorate15([
|
|
3322
3505
|
Query(() => AgentsResponse),
|
|
3323
3506
|
_ts_param(0, Ctx()),
|
|
3324
|
-
|
|
3325
|
-
|
|
3507
|
+
_ts_metadata15("design:type", Function),
|
|
3508
|
+
_ts_metadata15("design:paramtypes", [
|
|
3326
3509
|
typeof GraphQLContext === "undefined" ? Object : GraphQLContext
|
|
3327
3510
|
]),
|
|
3328
|
-
|
|
3511
|
+
_ts_metadata15("design:returntype", Promise)
|
|
3329
3512
|
], CopilotResolver.prototype, "availableAgents", null);
|
|
3330
|
-
|
|
3513
|
+
_ts_decorate15([
|
|
3331
3514
|
Mutation(() => CopilotResponse),
|
|
3332
3515
|
_ts_param(0, Ctx()),
|
|
3333
3516
|
_ts_param(1, Arg("data")),
|
|
3334
3517
|
_ts_param(2, Arg("properties", () => GraphQLJSONObject, {
|
|
3335
3518
|
nullable: true
|
|
3336
3519
|
})),
|
|
3337
|
-
|
|
3338
|
-
|
|
3520
|
+
_ts_metadata15("design:type", Function),
|
|
3521
|
+
_ts_metadata15("design:paramtypes", [
|
|
3339
3522
|
typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
|
|
3340
3523
|
typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
|
|
3341
3524
|
typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
|
|
3342
3525
|
]),
|
|
3343
|
-
|
|
3526
|
+
_ts_metadata15("design:returntype", Promise)
|
|
3344
3527
|
], CopilotResolver.prototype, "generateCopilotResponse", null);
|
|
3345
|
-
CopilotResolver =
|
|
3528
|
+
CopilotResolver = _ts_decorate15([
|
|
3346
3529
|
Resolver(() => CopilotResponse)
|
|
3347
3530
|
], CopilotResolver);
|
|
3348
3531
|
|
|
@@ -3377,6 +3560,141 @@ function createLogger(options) {
|
|
|
3377
3560
|
}
|
|
3378
3561
|
__name(createLogger, "createLogger");
|
|
3379
3562
|
|
|
3563
|
+
// src/graphql/resolvers/state.resolver.ts
|
|
3564
|
+
import { Arg as Arg2, Resolver as Resolver2 } from "type-graphql";
|
|
3565
|
+
import { Ctx as Ctx2 } from "type-graphql";
|
|
3566
|
+
import { Query as Query2 } from "type-graphql";
|
|
3567
|
+
|
|
3568
|
+
// src/graphql/types/load-agent-state-response.type.ts
|
|
3569
|
+
import { Field as Field15, ObjectType as ObjectType5 } from "type-graphql";
|
|
3570
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
3571
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3572
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3573
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3574
|
+
else
|
|
3575
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3576
|
+
if (d = decorators[i])
|
|
3577
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3578
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3579
|
+
}
|
|
3580
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
3581
|
+
function _ts_metadata16(k, v) {
|
|
3582
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
3583
|
+
return Reflect.metadata(k, v);
|
|
3584
|
+
}
|
|
3585
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
3586
|
+
var LoadAgentStateResponse = class {
|
|
3587
|
+
threadId;
|
|
3588
|
+
threadExists;
|
|
3589
|
+
state;
|
|
3590
|
+
messages;
|
|
3591
|
+
};
|
|
3592
|
+
__name(LoadAgentStateResponse, "LoadAgentStateResponse");
|
|
3593
|
+
_ts_decorate16([
|
|
3594
|
+
Field15(() => String),
|
|
3595
|
+
_ts_metadata16("design:type", String)
|
|
3596
|
+
], LoadAgentStateResponse.prototype, "threadId", void 0);
|
|
3597
|
+
_ts_decorate16([
|
|
3598
|
+
Field15(() => Boolean),
|
|
3599
|
+
_ts_metadata16("design:type", Boolean)
|
|
3600
|
+
], LoadAgentStateResponse.prototype, "threadExists", void 0);
|
|
3601
|
+
_ts_decorate16([
|
|
3602
|
+
Field15(() => String),
|
|
3603
|
+
_ts_metadata16("design:type", String)
|
|
3604
|
+
], LoadAgentStateResponse.prototype, "state", void 0);
|
|
3605
|
+
_ts_decorate16([
|
|
3606
|
+
Field15(() => String),
|
|
3607
|
+
_ts_metadata16("design:type", String)
|
|
3608
|
+
], LoadAgentStateResponse.prototype, "messages", void 0);
|
|
3609
|
+
LoadAgentStateResponse = _ts_decorate16([
|
|
3610
|
+
ObjectType5()
|
|
3611
|
+
], LoadAgentStateResponse);
|
|
3612
|
+
|
|
3613
|
+
// src/graphql/inputs/load-agent-state.input.ts
|
|
3614
|
+
import { Field as Field16, InputType as InputType11 } from "type-graphql";
|
|
3615
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
3616
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3617
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3618
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3619
|
+
else
|
|
3620
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3621
|
+
if (d = decorators[i])
|
|
3622
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3623
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3624
|
+
}
|
|
3625
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
3626
|
+
function _ts_metadata17(k, v) {
|
|
3627
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
3628
|
+
return Reflect.metadata(k, v);
|
|
3629
|
+
}
|
|
3630
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
3631
|
+
var LoadAgentStateInput = class {
|
|
3632
|
+
threadId;
|
|
3633
|
+
agentName;
|
|
3634
|
+
};
|
|
3635
|
+
__name(LoadAgentStateInput, "LoadAgentStateInput");
|
|
3636
|
+
_ts_decorate17([
|
|
3637
|
+
Field16(() => String),
|
|
3638
|
+
_ts_metadata17("design:type", String)
|
|
3639
|
+
], LoadAgentStateInput.prototype, "threadId", void 0);
|
|
3640
|
+
_ts_decorate17([
|
|
3641
|
+
Field16(() => String),
|
|
3642
|
+
_ts_metadata17("design:type", String)
|
|
3643
|
+
], LoadAgentStateInput.prototype, "agentName", void 0);
|
|
3644
|
+
LoadAgentStateInput = _ts_decorate17([
|
|
3645
|
+
InputType11()
|
|
3646
|
+
], LoadAgentStateInput);
|
|
3647
|
+
|
|
3648
|
+
// src/graphql/resolvers/state.resolver.ts
|
|
3649
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
3650
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3651
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3652
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3653
|
+
else
|
|
3654
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3655
|
+
if (d = decorators[i])
|
|
3656
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3657
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3658
|
+
}
|
|
3659
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3660
|
+
function _ts_metadata18(k, v) {
|
|
3661
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
3662
|
+
return Reflect.metadata(k, v);
|
|
3663
|
+
}
|
|
3664
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3665
|
+
function _ts_param2(paramIndex, decorator) {
|
|
3666
|
+
return function(target, key) {
|
|
3667
|
+
decorator(target, key, paramIndex);
|
|
3668
|
+
};
|
|
3669
|
+
}
|
|
3670
|
+
__name(_ts_param2, "_ts_param");
|
|
3671
|
+
var StateResolver = class {
|
|
3672
|
+
async loadAgentState(ctx, data) {
|
|
3673
|
+
const agents = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
|
|
3674
|
+
const agent = agents.find((agent2) => agent2.name === data.agentName);
|
|
3675
|
+
if (!agent) {
|
|
3676
|
+
throw new Error("Agent not found");
|
|
3677
|
+
}
|
|
3678
|
+
const state = await ctx._copilotkit.runtime.loadAgentState(ctx, data.threadId, data.agentName);
|
|
3679
|
+
return state;
|
|
3680
|
+
}
|
|
3681
|
+
};
|
|
3682
|
+
__name(StateResolver, "StateResolver");
|
|
3683
|
+
_ts_decorate18([
|
|
3684
|
+
Query2(() => LoadAgentStateResponse),
|
|
3685
|
+
_ts_param2(0, Ctx2()),
|
|
3686
|
+
_ts_param2(1, Arg2("data")),
|
|
3687
|
+
_ts_metadata18("design:type", Function),
|
|
3688
|
+
_ts_metadata18("design:paramtypes", [
|
|
3689
|
+
typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
|
|
3690
|
+
typeof LoadAgentStateInput === "undefined" ? Object : LoadAgentStateInput
|
|
3691
|
+
]),
|
|
3692
|
+
_ts_metadata18("design:returntype", Promise)
|
|
3693
|
+
], StateResolver.prototype, "loadAgentState", null);
|
|
3694
|
+
StateResolver = _ts_decorate18([
|
|
3695
|
+
Resolver2(() => LoadAgentStateResponse)
|
|
3696
|
+
], StateResolver);
|
|
3697
|
+
|
|
3380
3698
|
// src/lib/integrations/shared.ts
|
|
3381
3699
|
var logger = createLogger();
|
|
3382
3700
|
async function createContext(initialContext, copilotKitContext, contextLogger, properties = {}) {
|
|
@@ -3400,7 +3718,8 @@ function buildSchema(options = {}) {
|
|
|
3400
3718
|
logger.debug("Building GraphQL schema...");
|
|
3401
3719
|
const schema = buildSchemaSync({
|
|
3402
3720
|
resolvers: [
|
|
3403
|
-
CopilotResolver
|
|
3721
|
+
CopilotResolver,
|
|
3722
|
+
StateResolver
|
|
3404
3723
|
],
|
|
3405
3724
|
emitSchemaFile: options.emitSchemaFile
|
|
3406
3725
|
});
|
|
@@ -3488,4 +3807,4 @@ export {
|
|
|
3488
3807
|
getCommonConfig,
|
|
3489
3808
|
copilotRuntimeNodeHttpEndpoint
|
|
3490
3809
|
};
|
|
3491
|
-
//# sourceMappingURL=chunk-
|
|
3810
|
+
//# sourceMappingURL=chunk-PFELVFS7.mjs.map
|