@copilotkit/runtime 1.5.12-next.5 → 1.5.12-next.7
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 +17 -0
- package/__snapshots__/schema/schema.graphql +33 -0
- package/dist/{chunk-MFDRA3BJ.mjs → chunk-34276UUU.mjs} +652 -285
- package/dist/chunk-34276UUU.mjs.map +1 -0
- package/dist/{chunk-XRW7ZSWJ.mjs → chunk-DLESGNLO.mjs} +2 -2
- package/dist/{chunk-TPTCSIAR.mjs → chunk-S3KKBII4.mjs} +42 -30
- package/dist/chunk-S3KKBII4.mjs.map +1 -0
- package/dist/{chunk-QDMAQO2C.mjs → chunk-UBYSQI43.mjs} +2 -2
- package/dist/{chunk-NORCONUM.mjs → chunk-WTUPF3W3.mjs} +2 -2
- package/dist/{copilot-runtime-1a224a0f.d.ts → copilot-runtime-8c442d65.d.ts} +16 -3
- 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 +727 -348
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- 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 +725 -346
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +5 -5
- package/dist/lib/integrations/index.d.ts +4 -4
- package/dist/lib/integrations/index.js +504 -244
- 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 +504 -244
- 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 +504 -244
- 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 +504 -244
- 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 +155 -31
- package/src/lib/runtime/remote-action-constructors.ts +42 -33
- package/src/lib/runtime/remote-actions.ts +12 -7
- 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-MFDRA3BJ.mjs.map +0 -1
- package/dist/chunk-TPTCSIAR.mjs.map +0 -1
- /package/dist/{chunk-XRW7ZSWJ.mjs.map → chunk-DLESGNLO.mjs.map} +0 -0
- /package/dist/{chunk-QDMAQO2C.mjs.map → chunk-UBYSQI43.mjs.map} +0 -0
- /package/dist/{chunk-NORCONUM.mjs.map → chunk-WTUPF3W3.mjs.map} +0 -0
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
EmptyAdapter,
|
|
3
3
|
RemoteChain,
|
|
4
4
|
streamLangChainResponse
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-S3KKBII4.mjs";
|
|
6
6
|
import {
|
|
7
7
|
GuardrailsValidationFailureResponse,
|
|
8
8
|
MessageStreamInterruptedResponse,
|
|
@@ -38,7 +38,7 @@ var require_package = __commonJS({
|
|
|
38
38
|
publishConfig: {
|
|
39
39
|
access: "public"
|
|
40
40
|
},
|
|
41
|
-
version: "1.5.12-next.
|
|
41
|
+
version: "1.5.12-next.7",
|
|
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
|
-
initialThreadId = initialThreadId.substring(3);
|
|
1478
|
+
let threadId = argsInitialThreadId ?? randomUUID();
|
|
1479
|
+
if (argsInitialThreadId && argsInitialThreadId.startsWith("ck-")) {
|
|
1480
|
+
threadId = argsInitialThreadId.substring(3);
|
|
1362
1481
|
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1482
|
+
if (!isValidUUID(threadId)) {
|
|
1483
|
+
console.warn(`Cannot use the threadId ${threadId} with LangGraph Platform. Must be a valid UUID.`);
|
|
1484
|
+
}
|
|
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);
|
|
@@ -1796,6 +1919,7 @@ function copilotkitMessagesToLangChain(messages) {
|
|
|
1796
1919
|
__name(copilotkitMessagesToLangChain, "copilotkitMessagesToLangChain");
|
|
1797
1920
|
|
|
1798
1921
|
// src/lib/runtime/remote-action-constructors.ts
|
|
1922
|
+
import { CopilotKitError, CopilotKitLowLevelError } from "@copilotkit/shared";
|
|
1799
1923
|
function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, messages, agentStates }) {
|
|
1800
1924
|
const agents = endpoint.agents.map((agent) => ({
|
|
1801
1925
|
name: agent.name,
|
|
@@ -1876,8 +2000,9 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
1876
2000
|
type: "self-hosted",
|
|
1877
2001
|
agentsAmount: totalAgents
|
|
1878
2002
|
});
|
|
2003
|
+
const fetchUrl = `${url}/actions/execute`;
|
|
1879
2004
|
try {
|
|
1880
|
-
const response = await fetch(
|
|
2005
|
+
const response = await fetch(fetchUrl, {
|
|
1881
2006
|
method: "POST",
|
|
1882
2007
|
headers,
|
|
1883
2008
|
body: JSON.stringify({
|
|
@@ -1902,10 +2027,13 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
1902
2027
|
}, "Executed remote action");
|
|
1903
2028
|
return result;
|
|
1904
2029
|
} catch (error) {
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
}
|
|
1908
|
-
|
|
2030
|
+
if (error instanceof CopilotKitError) {
|
|
2031
|
+
throw error;
|
|
2032
|
+
}
|
|
2033
|
+
throw new CopilotKitLowLevelError({
|
|
2034
|
+
error,
|
|
2035
|
+
url: fetchUrl
|
|
2036
|
+
});
|
|
1909
2037
|
}
|
|
1910
2038
|
}
|
|
1911
2039
|
}));
|
|
@@ -1933,37 +2061,48 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
1933
2061
|
state = JSON.parse(jsonState);
|
|
1934
2062
|
}
|
|
1935
2063
|
}
|
|
1936
|
-
const
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
2064
|
+
const fetchUrl = `${url}/agents/execute`;
|
|
2065
|
+
try {
|
|
2066
|
+
const response = await fetch(fetchUrl, {
|
|
2067
|
+
method: "POST",
|
|
2068
|
+
headers,
|
|
2069
|
+
body: JSON.stringify({
|
|
2070
|
+
name,
|
|
2071
|
+
threadId,
|
|
2072
|
+
nodeName,
|
|
2073
|
+
messages: [
|
|
2074
|
+
...messages,
|
|
2075
|
+
...additionalMessages
|
|
2076
|
+
],
|
|
2077
|
+
state,
|
|
2078
|
+
properties: graphqlContext.properties,
|
|
2079
|
+
actions: actionInputsWithoutAgents.map((action) => ({
|
|
2080
|
+
name: action.name,
|
|
2081
|
+
description: action.description,
|
|
2082
|
+
parameters: JSON.parse(action.jsonSchema)
|
|
2083
|
+
}))
|
|
2084
|
+
})
|
|
2085
|
+
});
|
|
2086
|
+
if (!response.ok) {
|
|
2087
|
+
logger2.error({
|
|
2088
|
+
url,
|
|
2089
|
+
status: response.status,
|
|
2090
|
+
body: await response.text()
|
|
2091
|
+
}, "Failed to execute remote agent");
|
|
2092
|
+
throw new Error("Failed to execute remote agent");
|
|
2093
|
+
}
|
|
2094
|
+
const eventSource = new RemoteLangGraphEventSource();
|
|
2095
|
+
streamResponse(response.body, eventSource.eventStream$);
|
|
2096
|
+
return eventSource.processLangGraphEvents();
|
|
2097
|
+
} catch (error) {
|
|
2098
|
+
if (error instanceof CopilotKitError) {
|
|
2099
|
+
throw error;
|
|
2100
|
+
}
|
|
2101
|
+
throw new CopilotKitLowLevelError({
|
|
2102
|
+
error,
|
|
2103
|
+
url: fetchUrl
|
|
2104
|
+
});
|
|
1963
2105
|
}
|
|
1964
|
-
const eventSource = new RemoteLangGraphEventSource();
|
|
1965
|
-
streamResponse(response.body, eventSource.eventStream$);
|
|
1966
|
-
return eventSource.processLangGraphEvents();
|
|
1967
2106
|
}
|
|
1968
2107
|
})) : [];
|
|
1969
2108
|
return [
|
|
@@ -2033,6 +2172,7 @@ function createHeaders(onBeforeRequest, graphqlContext) {
|
|
|
2033
2172
|
__name(createHeaders, "createHeaders");
|
|
2034
2173
|
|
|
2035
2174
|
// src/lib/runtime/remote-actions.ts
|
|
2175
|
+
import { CopilotKitLowLevelError as CopilotKitLowLevelError2, ResolvedCopilotKitError, CopilotKitError as CopilotKitError2 } from "@copilotkit/shared";
|
|
2036
2176
|
var EndpointType;
|
|
2037
2177
|
(function(EndpointType2) {
|
|
2038
2178
|
EndpointType2["CopilotKit"] = "copilotKit";
|
|
@@ -2050,8 +2190,9 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
|
|
|
2050
2190
|
url
|
|
2051
2191
|
}, "Fetching actions from url");
|
|
2052
2192
|
const headers = createHeaders(onBeforeRequest, graphqlContext);
|
|
2193
|
+
const fetchUrl = `${url}/info`;
|
|
2053
2194
|
try {
|
|
2054
|
-
const response = await fetch(
|
|
2195
|
+
const response = await fetch(fetchUrl, {
|
|
2055
2196
|
method: "POST",
|
|
2056
2197
|
headers,
|
|
2057
2198
|
body: JSON.stringify({
|
|
@@ -2065,10 +2206,10 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
|
|
|
2065
2206
|
status: response.status,
|
|
2066
2207
|
body: await response.text()
|
|
2067
2208
|
}, "Failed to fetch actions from url");
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
};
|
|
2209
|
+
throw new ResolvedCopilotKitError({
|
|
2210
|
+
status: response.status,
|
|
2211
|
+
isRemoteEndpoint: true
|
|
2212
|
+
});
|
|
2072
2213
|
}
|
|
2073
2214
|
const json = await response.json();
|
|
2074
2215
|
logger2.debug({
|
|
@@ -2076,13 +2217,13 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
|
|
|
2076
2217
|
}, "Fetched actions from url");
|
|
2077
2218
|
return json;
|
|
2078
2219
|
} catch (error) {
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
}
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
};
|
|
2220
|
+
if (error instanceof CopilotKitError2) {
|
|
2221
|
+
throw error;
|
|
2222
|
+
}
|
|
2223
|
+
throw new CopilotKitLowLevelError2({
|
|
2224
|
+
error,
|
|
2225
|
+
url: fetchUrl
|
|
2226
|
+
});
|
|
2086
2227
|
}
|
|
2087
2228
|
}
|
|
2088
2229
|
__name(fetchRemoteInfo, "fetchRemoteInfo");
|
|
@@ -2143,7 +2284,7 @@ __name(setupRemoteActions, "setupRemoteActions");
|
|
|
2143
2284
|
import { createHash as createHash3 } from "crypto";
|
|
2144
2285
|
|
|
2145
2286
|
// src/lib/runtime/copilot-runtime.ts
|
|
2146
|
-
import { actionParametersToJsonSchema, randomId as randomId2 } from "@copilotkit/shared";
|
|
2287
|
+
import { actionParametersToJsonSchema, ResolvedCopilotKitError as ResolvedCopilotKitError2, CopilotKitApiDiscoveryError, randomId as randomId2, CopilotKitError as CopilotKitError3, CopilotKitLowLevelError as CopilotKitLowLevelError3, CopilotKitAgentDiscoveryError, CopilotKitMisuseError } from "@copilotkit/shared";
|
|
2147
2288
|
|
|
2148
2289
|
// src/service-adapters/conversion.ts
|
|
2149
2290
|
import { plainToInstance } from "class-transformer";
|
|
@@ -2195,6 +2336,7 @@ __name(convertGqlInputToMessages, "convertGqlInputToMessages");
|
|
|
2195
2336
|
|
|
2196
2337
|
// src/lib/runtime/copilot-runtime.ts
|
|
2197
2338
|
import { from } from "rxjs";
|
|
2339
|
+
import { Client as LangGraphClient } from "@langchain/langgraph-sdk";
|
|
2198
2340
|
var CopilotRuntime = class {
|
|
2199
2341
|
actions;
|
|
2200
2342
|
remoteEndpointDefinitions;
|
|
@@ -2214,16 +2356,18 @@ var CopilotRuntime = class {
|
|
|
2214
2356
|
}
|
|
2215
2357
|
async processRuntimeRequest(request) {
|
|
2216
2358
|
var _a;
|
|
2217
|
-
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;
|
|
2218
2360
|
const eventSource = new RuntimeEventSource();
|
|
2219
2361
|
try {
|
|
2220
2362
|
if (agentSession) {
|
|
2221
2363
|
return await this.processAgentRequest(request);
|
|
2222
2364
|
}
|
|
2223
2365
|
if (serviceAdapter instanceof EmptyAdapter) {
|
|
2224
|
-
throw new
|
|
2366
|
+
throw new CopilotKitMisuseError({
|
|
2367
|
+
message: `Invalid adapter configuration: EmptyAdapter is only meant to be used with agent lock mode.
|
|
2225
2368
|
For non-agent components like useCopilotChatSuggestions, CopilotTextarea, or CopilotTask,
|
|
2226
|
-
please use an LLM adapter instead.`
|
|
2369
|
+
please use an LLM adapter instead.`
|
|
2370
|
+
});
|
|
2227
2371
|
}
|
|
2228
2372
|
const messages = rawMessages.filter((message) => !message.agentStateMessage);
|
|
2229
2373
|
const inputMessages = convertGqlInputToMessages(messages);
|
|
@@ -2253,12 +2397,14 @@ please use an LLM adapter instead.`);
|
|
|
2253
2397
|
threadId,
|
|
2254
2398
|
runId,
|
|
2255
2399
|
eventSource,
|
|
2256
|
-
forwardedParameters
|
|
2400
|
+
forwardedParameters,
|
|
2401
|
+
extensions
|
|
2257
2402
|
});
|
|
2403
|
+
const nonEmptyThreadId = threadId ?? result.threadId;
|
|
2258
2404
|
outputMessagesPromise.then((outputMessages) => {
|
|
2259
2405
|
var _a2;
|
|
2260
2406
|
(_a2 = this.onAfterRequest) == null ? void 0 : _a2.call(this, {
|
|
2261
|
-
threadId:
|
|
2407
|
+
threadId: nonEmptyThreadId,
|
|
2262
2408
|
runId: result.runId,
|
|
2263
2409
|
inputMessages,
|
|
2264
2410
|
outputMessages,
|
|
@@ -2268,16 +2414,20 @@ please use an LLM adapter instead.`);
|
|
|
2268
2414
|
}).catch((_error) => {
|
|
2269
2415
|
});
|
|
2270
2416
|
return {
|
|
2271
|
-
threadId:
|
|
2417
|
+
threadId: nonEmptyThreadId,
|
|
2272
2418
|
runId: result.runId,
|
|
2273
2419
|
eventSource,
|
|
2274
2420
|
serverSideActions,
|
|
2275
2421
|
actionInputsWithoutAgents: actionInputs.filter((action) => (
|
|
2276
2422
|
// TODO-AGENTS: do not exclude ALL server side actions
|
|
2277
2423
|
!serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
|
|
2278
|
-
))
|
|
2424
|
+
)),
|
|
2425
|
+
extensions: result.extensions
|
|
2279
2426
|
};
|
|
2280
2427
|
} catch (error) {
|
|
2428
|
+
if (error instanceof CopilotKitError3) {
|
|
2429
|
+
throw error;
|
|
2430
|
+
}
|
|
2281
2431
|
console.error("Error getting response:", error);
|
|
2282
2432
|
eventSource.sendErrorMessageToChat();
|
|
2283
2433
|
throw error;
|
|
@@ -2288,49 +2438,126 @@ please use an LLM adapter instead.`);
|
|
|
2288
2438
|
const agents = this.remoteEndpointDefinitions.reduce(async (acc, endpoint) => {
|
|
2289
2439
|
const agents2 = await acc;
|
|
2290
2440
|
if (endpoint.type === EndpointType.LangGraphPlatform) {
|
|
2291
|
-
const
|
|
2292
|
-
|
|
2293
|
-
|
|
2441
|
+
const client = new LangGraphClient({
|
|
2442
|
+
apiUrl: endpoint.deploymentUrl,
|
|
2443
|
+
apiKey: endpoint.langsmithApiKey
|
|
2294
2444
|
});
|
|
2295
|
-
const
|
|
2296
|
-
const
|
|
2445
|
+
const data = await client.assistants.search();
|
|
2446
|
+
const endpointAgents = (data ?? []).map((entry) => ({
|
|
2297
2447
|
name: entry.graph_id,
|
|
2298
|
-
id: entry.assistant_id
|
|
2448
|
+
id: entry.assistant_id,
|
|
2449
|
+
description: "",
|
|
2450
|
+
endpoint
|
|
2299
2451
|
}));
|
|
2300
2452
|
return [
|
|
2301
2453
|
...agents2,
|
|
2302
|
-
...
|
|
2454
|
+
...endpointAgents
|
|
2303
2455
|
];
|
|
2304
2456
|
}
|
|
2305
|
-
const
|
|
2457
|
+
const fetchUrl = `${endpoint.url}/info`;
|
|
2458
|
+
try {
|
|
2459
|
+
const response = await fetch(fetchUrl, {
|
|
2460
|
+
method: "POST",
|
|
2461
|
+
headers,
|
|
2462
|
+
body: JSON.stringify({
|
|
2463
|
+
properties: graphqlContext.properties
|
|
2464
|
+
})
|
|
2465
|
+
});
|
|
2466
|
+
if (!response.ok) {
|
|
2467
|
+
if (response.status === 404) {
|
|
2468
|
+
throw new CopilotKitApiDiscoveryError();
|
|
2469
|
+
}
|
|
2470
|
+
throw new ResolvedCopilotKitError2({
|
|
2471
|
+
status: response.status,
|
|
2472
|
+
isRemoteEndpoint: true
|
|
2473
|
+
});
|
|
2474
|
+
}
|
|
2475
|
+
const data = await response.json();
|
|
2476
|
+
const endpointAgents = ((data == null ? void 0 : data.agents) ?? []).map((agent) => ({
|
|
2477
|
+
name: agent.name,
|
|
2478
|
+
description: agent.description ?? "" ?? "",
|
|
2479
|
+
id: randomId2(),
|
|
2480
|
+
endpoint
|
|
2481
|
+
}));
|
|
2482
|
+
return [
|
|
2483
|
+
...agents2,
|
|
2484
|
+
...endpointAgents
|
|
2485
|
+
];
|
|
2486
|
+
} catch (error) {
|
|
2487
|
+
if (error instanceof CopilotKitError3) {
|
|
2488
|
+
throw error;
|
|
2489
|
+
}
|
|
2490
|
+
throw new CopilotKitLowLevelError3({
|
|
2491
|
+
error,
|
|
2492
|
+
url: fetchUrl
|
|
2493
|
+
});
|
|
2494
|
+
}
|
|
2495
|
+
}, Promise.resolve([]));
|
|
2496
|
+
return agents;
|
|
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`, {
|
|
2306
2531
|
method: "POST",
|
|
2307
2532
|
headers,
|
|
2308
2533
|
body: JSON.stringify({
|
|
2309
|
-
properties: graphqlContext.properties
|
|
2534
|
+
properties: graphqlContext.properties,
|
|
2535
|
+
threadId,
|
|
2536
|
+
name: agentName
|
|
2310
2537
|
})
|
|
2311
2538
|
});
|
|
2312
2539
|
const data = await response.json();
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
}
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
];
|
|
2322
|
-
}, Promise.resolve([]));
|
|
2323
|
-
return agents;
|
|
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
|
+
}
|
|
2324
2548
|
}
|
|
2325
2549
|
async processAgentRequest(request) {
|
|
2326
2550
|
var _a;
|
|
2327
|
-
const { messages: rawMessages, outputMessagesPromise, graphqlContext, agentSession } = request;
|
|
2328
|
-
const {
|
|
2551
|
+
const { messages: rawMessages, outputMessagesPromise, graphqlContext, agentSession, threadId: threadIdFromRequest } = request;
|
|
2552
|
+
const { agentName, nodeName } = agentSession;
|
|
2553
|
+
const threadId = threadIdFromRequest ?? agentSession.threadId;
|
|
2329
2554
|
const serverSideActions = await this.getServerSideActions(request);
|
|
2330
2555
|
const messages = convertGqlInputToMessages(rawMessages);
|
|
2331
2556
|
const agent = serverSideActions.find((action) => action.name === agentName && isLangGraphAgentAction(action));
|
|
2332
2557
|
if (!agent) {
|
|
2333
|
-
throw new
|
|
2558
|
+
throw new CopilotKitAgentDiscoveryError({
|
|
2559
|
+
agentName
|
|
2560
|
+
});
|
|
2334
2561
|
}
|
|
2335
2562
|
const serverSideActionsInput = serverSideActions.filter((action) => !isLangGraphAgentAction(action)).map((action) => ({
|
|
2336
2563
|
name: action.name,
|
|
@@ -2631,7 +2858,7 @@ var RuntimeEventSource = class {
|
|
|
2631
2858
|
this.eventStream$.sendTextMessage(randomId3(), errorMessage);
|
|
2632
2859
|
}
|
|
2633
2860
|
}
|
|
2634
|
-
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents }) {
|
|
2861
|
+
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId }) {
|
|
2635
2862
|
this.callback(this.eventStream$).catch((error) => {
|
|
2636
2863
|
console.error("Error in event source callback", error);
|
|
2637
2864
|
this.sendErrorMessageToChat();
|
|
@@ -2667,7 +2894,7 @@ var RuntimeEventSource = class {
|
|
|
2667
2894
|
concatMap((eventWithState) => {
|
|
2668
2895
|
if (eventWithState.event.type === "ActionExecutionEnd" && eventWithState.callActionServerSide) {
|
|
2669
2896
|
const toolCallEventStream$ = new RuntimeEventSubject();
|
|
2670
|
-
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) => {
|
|
2671
2898
|
console.error(error);
|
|
2672
2899
|
});
|
|
2673
2900
|
telemetry_client_default.capture("oss.runtime.server_action_executed", {});
|
|
@@ -2684,7 +2911,7 @@ var RuntimeEventSource = class {
|
|
|
2684
2911
|
}
|
|
2685
2912
|
};
|
|
2686
2913
|
__name(RuntimeEventSource, "RuntimeEventSource");
|
|
2687
|
-
async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionParentMessageId, actionExecutionId, actionInputsWithoutAgents) {
|
|
2914
|
+
async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionParentMessageId, actionExecutionId, actionInputsWithoutAgents, threadId) {
|
|
2688
2915
|
var _a;
|
|
2689
2916
|
if (guardrailsResult$) {
|
|
2690
2917
|
const { status } = await firstValueFrom(guardrailsResult$);
|
|
@@ -2735,6 +2962,7 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
|
|
|
2735
2962
|
});
|
|
2736
2963
|
const stream = await action.langGraphAgentHandler({
|
|
2737
2964
|
name: action.name,
|
|
2965
|
+
threadId,
|
|
2738
2966
|
actionInputsWithoutAgents,
|
|
2739
2967
|
additionalMessages: [
|
|
2740
2968
|
agentExecution,
|
|
@@ -2791,8 +3019,8 @@ import { GraphQLError } from "graphql";
|
|
|
2791
3019
|
import { randomId as randomId4 } from "@copilotkit/shared";
|
|
2792
3020
|
|
|
2793
3021
|
// src/graphql/types/agents-response.type.ts
|
|
2794
|
-
import { Field as
|
|
2795
|
-
function
|
|
3022
|
+
import { Field as Field14, ObjectType as ObjectType4 } from "type-graphql";
|
|
3023
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2796
3024
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2797
3025
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2798
3026
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2802,49 +3030,49 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
2802
3030
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2803
3031
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2804
3032
|
}
|
|
2805
|
-
__name(
|
|
2806
|
-
function
|
|
3033
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
3034
|
+
function _ts_metadata14(k, v) {
|
|
2807
3035
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2808
3036
|
return Reflect.metadata(k, v);
|
|
2809
3037
|
}
|
|
2810
|
-
__name(
|
|
3038
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2811
3039
|
var Agent = class {
|
|
2812
3040
|
id;
|
|
2813
3041
|
name;
|
|
2814
3042
|
description;
|
|
2815
3043
|
};
|
|
2816
3044
|
__name(Agent, "Agent");
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
3045
|
+
_ts_decorate14([
|
|
3046
|
+
Field14(() => String),
|
|
3047
|
+
_ts_metadata14("design:type", String)
|
|
2820
3048
|
], Agent.prototype, "id", void 0);
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
3049
|
+
_ts_decorate14([
|
|
3050
|
+
Field14(() => String),
|
|
3051
|
+
_ts_metadata14("design:type", String)
|
|
2824
3052
|
], Agent.prototype, "name", void 0);
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
3053
|
+
_ts_decorate14([
|
|
3054
|
+
Field14(() => String),
|
|
3055
|
+
_ts_metadata14("design:type", String)
|
|
2828
3056
|
], Agent.prototype, "description", void 0);
|
|
2829
|
-
Agent =
|
|
2830
|
-
|
|
3057
|
+
Agent = _ts_decorate14([
|
|
3058
|
+
ObjectType4()
|
|
2831
3059
|
], Agent);
|
|
2832
3060
|
var AgentsResponse = class {
|
|
2833
3061
|
agents;
|
|
2834
3062
|
};
|
|
2835
3063
|
__name(AgentsResponse, "AgentsResponse");
|
|
2836
|
-
|
|
2837
|
-
|
|
3064
|
+
_ts_decorate14([
|
|
3065
|
+
Field14(() => [
|
|
2838
3066
|
Agent
|
|
2839
3067
|
]),
|
|
2840
|
-
|
|
3068
|
+
_ts_metadata14("design:type", Array)
|
|
2841
3069
|
], AgentsResponse.prototype, "agents", void 0);
|
|
2842
|
-
AgentsResponse =
|
|
2843
|
-
|
|
3070
|
+
AgentsResponse = _ts_decorate14([
|
|
3071
|
+
ObjectType4()
|
|
2844
3072
|
], AgentsResponse);
|
|
2845
3073
|
|
|
2846
3074
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
2847
|
-
function
|
|
3075
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2848
3076
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2849
3077
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2850
3078
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2854,12 +3082,12 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
2854
3082
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2855
3083
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2856
3084
|
}
|
|
2857
|
-
__name(
|
|
2858
|
-
function
|
|
3085
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
3086
|
+
function _ts_metadata15(k, v) {
|
|
2859
3087
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2860
3088
|
return Reflect.metadata(k, v);
|
|
2861
3089
|
}
|
|
2862
|
-
__name(
|
|
3090
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
2863
3091
|
function _ts_param(paramIndex, decorator) {
|
|
2864
3092
|
return function(target, key) {
|
|
2865
3093
|
decorator(target, key, paramIndex);
|
|
@@ -2906,10 +3134,10 @@ var CopilotResolver = class {
|
|
|
2906
3134
|
component: "CopilotResolver.availableAgents"
|
|
2907
3135
|
});
|
|
2908
3136
|
logger2.debug("Processing");
|
|
2909
|
-
const
|
|
3137
|
+
const agentsWithEndpoints = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
|
|
2910
3138
|
logger2.debug("Event source created, creating response");
|
|
2911
3139
|
return {
|
|
2912
|
-
agents
|
|
3140
|
+
agents: agentsWithEndpoints.map(({ endpoint, ...agentWithoutEndpoint }) => agentWithoutEndpoint)
|
|
2913
3141
|
};
|
|
2914
3142
|
}
|
|
2915
3143
|
async generateCopilotResponse(ctx, data, properties) {
|
|
@@ -2971,7 +3199,7 @@ var CopilotResolver = class {
|
|
|
2971
3199
|
rejectOutputMessagesPromise = reject;
|
|
2972
3200
|
});
|
|
2973
3201
|
logger2.debug("Processing");
|
|
2974
|
-
const { eventSource, threadId = randomId4(), runId, serverSideActions, actionInputsWithoutAgents } = await copilotRuntime.processRuntimeRequest({
|
|
3202
|
+
const { eventSource, threadId = randomId4(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = await copilotRuntime.processRuntimeRequest({
|
|
2975
3203
|
serviceAdapter,
|
|
2976
3204
|
messages: data.messages,
|
|
2977
3205
|
actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
|
|
@@ -2983,13 +3211,15 @@ var CopilotResolver = class {
|
|
|
2983
3211
|
forwardedParameters: data.forwardedParameters,
|
|
2984
3212
|
agentSession: data.agentSession,
|
|
2985
3213
|
agentStates: data.agentStates,
|
|
2986
|
-
url: data.frontend.url
|
|
3214
|
+
url: data.frontend.url,
|
|
3215
|
+
extensions: data.extensions
|
|
2987
3216
|
});
|
|
2988
3217
|
logger2.debug("Event source created, creating response");
|
|
2989
3218
|
const response = {
|
|
2990
3219
|
threadId,
|
|
2991
3220
|
runId,
|
|
2992
3221
|
status: firstValueFrom2(responseStatus$),
|
|
3222
|
+
extensions,
|
|
2993
3223
|
messages: new Repeater(async (pushMessage, stopStreamingMessages) => {
|
|
2994
3224
|
var _a2, _b2;
|
|
2995
3225
|
logger2.debug("Messages repeater created");
|
|
@@ -3046,7 +3276,8 @@ var CopilotResolver = class {
|
|
|
3046
3276
|
actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
|
|
3047
3277
|
// TODO-AGENTS: do not exclude ALL server side actions
|
|
3048
3278
|
(action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
|
|
3049
|
-
)
|
|
3279
|
+
),
|
|
3280
|
+
threadId
|
|
3050
3281
|
}).pipe(
|
|
3051
3282
|
// shareReplay() ensures that later subscribers will see the whole stream instead of
|
|
3052
3283
|
// just the events that were emitted after the subscriber was added.
|
|
@@ -3264,37 +3495,37 @@ var CopilotResolver = class {
|
|
|
3264
3495
|
}
|
|
3265
3496
|
};
|
|
3266
3497
|
__name(CopilotResolver, "CopilotResolver");
|
|
3267
|
-
|
|
3498
|
+
_ts_decorate15([
|
|
3268
3499
|
Query(() => String),
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3500
|
+
_ts_metadata15("design:type", Function),
|
|
3501
|
+
_ts_metadata15("design:paramtypes", []),
|
|
3502
|
+
_ts_metadata15("design:returntype", Promise)
|
|
3272
3503
|
], CopilotResolver.prototype, "hello", null);
|
|
3273
|
-
|
|
3504
|
+
_ts_decorate15([
|
|
3274
3505
|
Query(() => AgentsResponse),
|
|
3275
3506
|
_ts_param(0, Ctx()),
|
|
3276
|
-
|
|
3277
|
-
|
|
3507
|
+
_ts_metadata15("design:type", Function),
|
|
3508
|
+
_ts_metadata15("design:paramtypes", [
|
|
3278
3509
|
typeof GraphQLContext === "undefined" ? Object : GraphQLContext
|
|
3279
3510
|
]),
|
|
3280
|
-
|
|
3511
|
+
_ts_metadata15("design:returntype", Promise)
|
|
3281
3512
|
], CopilotResolver.prototype, "availableAgents", null);
|
|
3282
|
-
|
|
3513
|
+
_ts_decorate15([
|
|
3283
3514
|
Mutation(() => CopilotResponse),
|
|
3284
3515
|
_ts_param(0, Ctx()),
|
|
3285
3516
|
_ts_param(1, Arg("data")),
|
|
3286
3517
|
_ts_param(2, Arg("properties", () => GraphQLJSONObject, {
|
|
3287
3518
|
nullable: true
|
|
3288
3519
|
})),
|
|
3289
|
-
|
|
3290
|
-
|
|
3520
|
+
_ts_metadata15("design:type", Function),
|
|
3521
|
+
_ts_metadata15("design:paramtypes", [
|
|
3291
3522
|
typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
|
|
3292
3523
|
typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
|
|
3293
3524
|
typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
|
|
3294
3525
|
]),
|
|
3295
|
-
|
|
3526
|
+
_ts_metadata15("design:returntype", Promise)
|
|
3296
3527
|
], CopilotResolver.prototype, "generateCopilotResponse", null);
|
|
3297
|
-
CopilotResolver =
|
|
3528
|
+
CopilotResolver = _ts_decorate15([
|
|
3298
3529
|
Resolver(() => CopilotResponse)
|
|
3299
3530
|
], CopilotResolver);
|
|
3300
3531
|
|
|
@@ -3329,6 +3560,141 @@ function createLogger(options) {
|
|
|
3329
3560
|
}
|
|
3330
3561
|
__name(createLogger, "createLogger");
|
|
3331
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
|
+
|
|
3332
3698
|
// src/lib/integrations/shared.ts
|
|
3333
3699
|
var logger = createLogger();
|
|
3334
3700
|
async function createContext(initialContext, copilotKitContext, contextLogger, properties = {}) {
|
|
@@ -3352,7 +3718,8 @@ function buildSchema(options = {}) {
|
|
|
3352
3718
|
logger.debug("Building GraphQL schema...");
|
|
3353
3719
|
const schema = buildSchemaSync({
|
|
3354
3720
|
resolvers: [
|
|
3355
|
-
CopilotResolver
|
|
3721
|
+
CopilotResolver,
|
|
3722
|
+
StateResolver
|
|
3356
3723
|
],
|
|
3357
3724
|
emitSchemaFile: options.emitSchemaFile
|
|
3358
3725
|
});
|
|
@@ -3440,4 +3807,4 @@ export {
|
|
|
3440
3807
|
getCommonConfig,
|
|
3441
3808
|
copilotRuntimeNodeHttpEndpoint
|
|
3442
3809
|
};
|
|
3443
|
-
//# sourceMappingURL=chunk-
|
|
3810
|
+
//# sourceMappingURL=chunk-34276UUU.mjs.map
|