@copilotkit/runtime-client-gql 1.51.4 → 1.51.5-next.1
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 +15 -0
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/client/CopilotRuntimeClient.cjs +119 -0
- package/dist/client/CopilotRuntimeClient.cjs.map +1 -0
- package/dist/client/CopilotRuntimeClient.d.cts +44 -0
- package/dist/client/CopilotRuntimeClient.d.cts.map +1 -0
- package/dist/client/CopilotRuntimeClient.d.mts +44 -0
- package/dist/client/CopilotRuntimeClient.d.mts.map +1 -0
- package/dist/client/CopilotRuntimeClient.mjs +116 -10
- package/dist/client/CopilotRuntimeClient.mjs.map +1 -1
- package/dist/client/conversion.cjs +194 -0
- package/dist/client/conversion.cjs.map +1 -0
- package/dist/client/{conversion.d.ts → conversion.d.cts} +5 -4
- package/dist/client/conversion.d.cts.map +1 -0
- package/dist/client/conversion.d.mts +12 -0
- package/dist/client/conversion.d.mts.map +1 -0
- package/dist/client/conversion.mjs +187 -17
- package/dist/client/conversion.mjs.map +1 -1
- package/dist/client/index.d.cts +5 -0
- package/dist/client/index.d.mts +5 -0
- package/dist/client/types.cjs +86 -0
- package/dist/client/types.cjs.map +1 -0
- package/dist/client/types.d.cts +76 -0
- package/dist/client/types.d.cts.map +1 -0
- package/dist/client/types.d.mts +76 -0
- package/dist/client/types.d.mts.map +1 -0
- package/dist/client/types.mjs +76 -21
- package/dist/client/types.mjs.map +1 -1
- package/dist/graphql/@generated/gql.cjs +15 -0
- package/dist/graphql/@generated/gql.cjs.map +1 -0
- package/dist/graphql/@generated/gql.mjs +13 -7
- package/dist/graphql/@generated/gql.mjs.map +1 -1
- package/dist/graphql/@generated/graphql.cjs +1154 -0
- package/dist/graphql/@generated/graphql.cjs.map +1 -0
- package/dist/graphql/@generated/graphql.d.cts +642 -0
- package/dist/graphql/@generated/graphql.d.cts.map +1 -0
- package/dist/graphql/@generated/graphql.d.mts +642 -0
- package/dist/graphql/@generated/graphql.d.mts.map +1 -0
- package/dist/graphql/@generated/graphql.mjs +1142 -24
- package/dist/graphql/@generated/graphql.mjs.map +1 -1
- package/dist/{chunk-E5FOLXLN.mjs → graphql/definitions/mutations.cjs} +8 -11
- package/dist/graphql/definitions/mutations.cjs.map +1 -0
- package/dist/graphql/definitions/mutations.mjs +140 -9
- package/dist/graphql/definitions/mutations.mjs.map +1 -1
- package/dist/graphql/definitions/queries.cjs +35 -0
- package/dist/graphql/definitions/queries.cjs.map +1 -0
- package/dist/graphql/definitions/queries.mjs +33 -11
- package/dist/graphql/definitions/queries.mjs.map +1 -1
- package/dist/index.cjs +43 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.mjs +8 -91
- package/dist/index.umd.js +2080 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/message-conversion/agui-to-gql.cjs +162 -0
- package/dist/message-conversion/agui-to-gql.cjs.map +1 -0
- package/dist/message-conversion/{agui-to-gql.d.ts → agui-to-gql.d.cts} +6 -5
- package/dist/message-conversion/agui-to-gql.d.cts.map +1 -0
- package/dist/message-conversion/agui-to-gql.d.mts +14 -0
- package/dist/message-conversion/agui-to-gql.d.mts.map +1 -0
- package/dist/message-conversion/agui-to-gql.mjs +156 -25
- package/dist/message-conversion/agui-to-gql.mjs.map +1 -1
- package/dist/message-conversion/gql-to-agui.cjs +169 -0
- package/dist/message-conversion/gql-to-agui.cjs.map +1 -0
- package/dist/message-conversion/{gql-to-agui.d.ts → gql-to-agui.d.cts} +6 -5
- package/dist/message-conversion/gql-to-agui.d.cts.map +1 -0
- package/dist/message-conversion/gql-to-agui.d.mts +13 -0
- package/dist/message-conversion/gql-to-agui.d.mts.map +1 -0
- package/dist/message-conversion/gql-to-agui.mjs +164 -23
- package/dist/message-conversion/gql-to-agui.mjs.map +1 -1
- package/dist/message-conversion/index.d.cts +2 -0
- package/dist/message-conversion/index.d.mts +2 -0
- package/dist/package.cjs +12 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.mjs +6 -0
- package/dist/package.mjs.map +1 -0
- package/package.json +15 -15
- package/src/message-conversion/agui-to-gql.test.ts +70 -0
- package/src/message-conversion/agui-to-gql.ts +4 -0
- package/tsdown.config.ts +49 -0
- package/vitest.config.mjs +11 -0
- package/dist/chunk-2XWNDVTL.mjs +0 -176
- package/dist/chunk-2XWNDVTL.mjs.map +0 -1
- package/dist/chunk-7ECCT6PK.mjs +0 -1
- package/dist/chunk-7ECCT6PK.mjs.map +0 -1
- package/dist/chunk-A4INSSNE.mjs +0 -17722
- package/dist/chunk-A4INSSNE.mjs.map +0 -1
- package/dist/chunk-CA4VMP2C.mjs +0 -1
- package/dist/chunk-CA4VMP2C.mjs.map +0 -1
- package/dist/chunk-DELDZXUX.mjs +0 -31
- package/dist/chunk-DELDZXUX.mjs.map +0 -1
- package/dist/chunk-E5FOLXLN.mjs.map +0 -1
- package/dist/chunk-LTVE64IE.mjs +0 -241
- package/dist/chunk-LTVE64IE.mjs.map +0 -1
- package/dist/chunk-M4CK5HDR.mjs +0 -237
- package/dist/chunk-M4CK5HDR.mjs.map +0 -1
- package/dist/chunk-OBDQ5BWD.mjs +0 -63
- package/dist/chunk-OBDQ5BWD.mjs.map +0 -1
- package/dist/chunk-QUH7QWUA.mjs +0 -38
- package/dist/chunk-QUH7QWUA.mjs.map +0 -1
- package/dist/chunk-SDQPJXLL.mjs +0 -20
- package/dist/chunk-SDQPJXLL.mjs.map +0 -1
- package/dist/chunk-UOAPP5IN.mjs +0 -93
- package/dist/chunk-UOAPP5IN.mjs.map +0 -1
- package/dist/chunk-VIHKTLUA.mjs +0 -221
- package/dist/chunk-VIHKTLUA.mjs.map +0 -1
- package/dist/chunk-XZPL6QVK.mjs +0 -24
- package/dist/chunk-XZPL6QVK.mjs.map +0 -1
- package/dist/client/CopilotRuntimeClient.d.ts +0 -39
- package/dist/client/CopilotRuntimeClient.js +0 -366
- package/dist/client/CopilotRuntimeClient.js.map +0 -1
- package/dist/client/conversion.js +0 -339
- package/dist/client/conversion.js.map +0 -1
- package/dist/client/index.d.ts +0 -8
- package/dist/client/index.js +0 -711
- package/dist/client/index.js.map +0 -1
- package/dist/client/index.mjs +0 -43
- package/dist/client/index.mjs.map +0 -1
- package/dist/client/types.d.ts +0 -75
- package/dist/client/types.js +0 -132
- package/dist/client/types.js.map +0 -1
- package/dist/graphql/@generated/fragment-masking.d.ts +0 -22
- package/dist/graphql/@generated/fragment-masking.js +0 -50
- package/dist/graphql/@generated/fragment-masking.js.map +0 -1
- package/dist/graphql/@generated/fragment-masking.mjs +0 -12
- package/dist/graphql/@generated/fragment-masking.mjs.map +0 -1
- package/dist/graphql/@generated/gql.d.ts +0 -48
- package/dist/graphql/@generated/gql.js +0 -45
- package/dist/graphql/@generated/gql.js.map +0 -1
- package/dist/graphql/@generated/graphql.d.ts +0 -655
- package/dist/graphql/@generated/graphql.js +0 -96
- package/dist/graphql/@generated/graphql.js.map +0 -1
- package/dist/graphql/@generated/index.d.ts +0 -4
- package/dist/graphql/@generated/index.js +0 -69
- package/dist/graphql/@generated/index.js.map +0 -1
- package/dist/graphql/@generated/index.mjs +0 -17
- package/dist/graphql/@generated/index.mjs.map +0 -1
- package/dist/graphql/definitions/mutations.d.ts +0 -9
- package/dist/graphql/definitions/mutations.js +0 -181
- package/dist/graphql/definitions/mutations.js.map +0 -1
- package/dist/graphql/definitions/queries.d.ts +0 -11
- package/dist/graphql/definitions/queries.js +0 -76
- package/dist/graphql/definitions/queries.js.map +0 -1
- package/dist/index.d.ts +0 -11
- package/dist/index.js +0 -1222
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/magic-string.es-XBKSJO3K.mjs +0 -1389
- package/dist/magic-string.es-XBKSJO3K.mjs.map +0 -1
- package/dist/message-conversion/agui-to-gql.js +0 -344
- package/dist/message-conversion/agui-to-gql.js.map +0 -1
- package/dist/message-conversion/agui-to-gql.test.d.ts +0 -2
- package/dist/message-conversion/agui-to-gql.test.js +0 -20553
- package/dist/message-conversion/agui-to-gql.test.js.map +0 -1
- package/dist/message-conversion/agui-to-gql.test.mjs +0 -1137
- package/dist/message-conversion/agui-to-gql.test.mjs.map +0 -1
- package/dist/message-conversion/gql-to-agui.js +0 -262
- package/dist/message-conversion/gql-to-agui.js.map +0 -1
- package/dist/message-conversion/gql-to-agui.test.d.ts +0 -2
- package/dist/message-conversion/gql-to-agui.test.js +0 -20850
- package/dist/message-conversion/gql-to-agui.test.js.map +0 -1
- package/dist/message-conversion/gql-to-agui.test.mjs +0 -1447
- package/dist/message-conversion/gql-to-agui.test.mjs.map +0 -1
- package/dist/message-conversion/index.d.ts +0 -6
- package/dist/message-conversion/index.js +0 -563
- package/dist/message-conversion/index.js.map +0 -1
- package/dist/message-conversion/index.mjs +0 -39
- package/dist/message-conversion/index.mjs.map +0 -1
- package/dist/message-conversion/roundtrip-conversion.test.d.ts +0 -2
- package/dist/message-conversion/roundtrip-conversion.test.js +0 -20095
- package/dist/message-conversion/roundtrip-conversion.test.js.map +0 -1
- package/dist/message-conversion/roundtrip-conversion.test.mjs +0 -489
- package/dist/message-conversion/roundtrip-conversion.test.mjs.map +0 -1
- package/jest.config.js +0 -5
- package/rollup.config.mjs +0 -62
- package/tsup.config.ts +0 -12
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2080 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@urql/core"),require("@copilotkit/shared")):"function"==typeof define&&define.amd?define(["exports","@urql/core","@copilotkit/shared"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).CopilotKitRuntimeClientGQL={},e.UrqlCore,e.CopilotKitShared)}(this,function(e,n,t){"use strict";var a,s,i,o,d,r,l,u="1.51.4";e.ActionInputAvailability=void 0,(a=e.ActionInputAvailability||(e.ActionInputAvailability={})).Disabled="disabled",a.Enabled="enabled",a.Remote="remote",e.CopilotRequestType=void 0,(s=e.CopilotRequestType||(e.CopilotRequestType={})).Chat="Chat",s.Suggestion="Suggestion",s.Task="Task",s.TextareaCompletion="TextareaCompletion",s.TextareaPopover="TextareaPopover",e.FailedResponseStatusReason=void 0,(i=e.FailedResponseStatusReason||(e.FailedResponseStatusReason={})).GuardrailsValidationFailed="GUARDRAILS_VALIDATION_FAILED",i.MessageStreamInterrupted="MESSAGE_STREAM_INTERRUPTED",i.UnknownError="UNKNOWN_ERROR",e.MessageRole=void 0,(o=e.MessageRole||(e.MessageRole={})).Assistant="assistant",o.Developer="developer",o.System="system",o.Tool="tool",o.User="user",e.MessageStatusCode=void 0,(d=e.MessageStatusCode||(e.MessageStatusCode={})).Failed="Failed",d.Pending="Pending",d.Success="Success",e.MetaEventName=void 0,(r=e.MetaEventName||(e.MetaEventName={})).CopilotKitLangGraphInterruptEvent="CopilotKitLangGraphInterruptEvent",r.LangGraphInterruptEvent="LangGraphInterruptEvent",e.ResponseStatusCode=void 0,(l=e.ResponseStatusCode||(e.ResponseStatusCode={})).Failed="Failed",l.Pending="Pending",l.Success="Success";const c={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"generateCopilotResponse"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"data"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"GenerateCopilotResponseInput"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"properties"}},type:{kind:"NamedType",name:{kind:"Name",value:"JSONObject"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"generateCopilotResponse"},arguments:[{kind:"Argument",name:{kind:"Name",value:"data"},value:{kind:"Variable",name:{kind:"Name",value:"data"}}},{kind:"Argument",name:{kind:"Name",value:"properties"},value:{kind:"Variable",name:{kind:"Name",value:"properties"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threadId"}},{kind:"Field",name:{kind:"Name",value:"runId"}},{kind:"Field",name:{kind:"Name",value:"extensions"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"openaiAssistantAPI"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"runId"}},{kind:"Field",name:{kind:"Name",value:"threadId"}}]}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"CopilotResponse"}},directives:[{kind:"Directive",name:{kind:"Name",value:"defer"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"status"},selectionSet:{kind:"SelectionSet",selections:[{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"BaseResponseStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"FailedResponseStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"reason"}},{kind:"Field",name:{kind:"Name",value:"details"}}]}}]}}]}},{kind:"Field",name:{kind:"Name",value:"messages"},directives:[{kind:"Directive",name:{kind:"Name",value:"stream"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"__typename"}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"BaseMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"createdAt"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"BaseMessageOutput"}},directives:[{kind:"Directive",name:{kind:"Name",value:"defer"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"status"},selectionSet:{kind:"SelectionSet",selections:[{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"SuccessMessageStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"FailedMessageStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}},{kind:"Field",name:{kind:"Name",value:"reason"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"PendingMessageStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}}]}}]}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"TextMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"content"},directives:[{kind:"Directive",name:{kind:"Name",value:"stream"}}]},{kind:"Field",name:{kind:"Name",value:"role"}},{kind:"Field",name:{kind:"Name",value:"parentMessageId"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"ImageMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"format"}},{kind:"Field",name:{kind:"Name",value:"bytes"}},{kind:"Field",name:{kind:"Name",value:"role"}},{kind:"Field",name:{kind:"Name",value:"parentMessageId"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"ActionExecutionMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"arguments"},directives:[{kind:"Directive",name:{kind:"Name",value:"stream"}}]},{kind:"Field",name:{kind:"Name",value:"parentMessageId"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"ResultMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"result"}},{kind:"Field",name:{kind:"Name",value:"actionExecutionId"}},{kind:"Field",name:{kind:"Name",value:"actionName"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"AgentStateMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threadId"}},{kind:"Field",name:{kind:"Name",value:"state"}},{kind:"Field",name:{kind:"Name",value:"running"}},{kind:"Field",name:{kind:"Name",value:"agentName"}},{kind:"Field",name:{kind:"Name",value:"nodeName"}},{kind:"Field",name:{kind:"Name",value:"runId"}},{kind:"Field",name:{kind:"Name",value:"active"}},{kind:"Field",name:{kind:"Name",value:"role"}}]}}]}},{kind:"Field",name:{kind:"Name",value:"metaEvents"},directives:[{kind:"Directive",name:{kind:"Name",value:"stream"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"LangGraphInterruptEvent"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"type"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"value"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"CopilotKitLangGraphInterruptEvent"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"type"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"data"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"messages"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"__typename"}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"BaseMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"createdAt"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"BaseMessageOutput"}},directives:[{kind:"Directive",name:{kind:"Name",value:"defer"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"status"},selectionSet:{kind:"SelectionSet",selections:[{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"SuccessMessageStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"FailedMessageStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}},{kind:"Field",name:{kind:"Name",value:"reason"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"PendingMessageStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}}]}}]}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"TextMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"content"}},{kind:"Field",name:{kind:"Name",value:"role"}},{kind:"Field",name:{kind:"Name",value:"parentMessageId"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"ActionExecutionMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"arguments"}},{kind:"Field",name:{kind:"Name",value:"parentMessageId"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"ResultMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"result"}},{kind:"Field",name:{kind:"Name",value:"actionExecutionId"}},{kind:"Field",name:{kind:"Name",value:"actionName"}}]}}]}},{kind:"Field",name:{kind:"Name",value:"value"}}]}}]}}]}}]}}]}}]},m={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"availableAgents"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"availableAgents"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"agents"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"description"}}]}}]}}]}}]},g={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"loadAgentState"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"data"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"LoadAgentStateInput"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"loadAgentState"},arguments:[{kind:"Argument",name:{kind:"Name",value:"data"},value:{kind:"Variable",name:{kind:"Name",value:"data"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threadId"}},{kind:"Field",name:{kind:"Name",value:"threadExists"}},{kind:"Field",name:{kind:"Name",value:"state"}},{kind:"Field",name:{kind:"Name",value:"messages"}}]}}]}}]},p={"\n mutation generateCopilotResponse(\n $data: GenerateCopilotResponseInput!\n $properties: JSONObject\n ) {\n generateCopilotResponse(data: $data, properties: $properties) {\n threadId\n runId\n extensions {\n openaiAssistantAPI {\n runId\n threadId\n }\n }\n ... on CopilotResponse @defer {\n status {\n ... on BaseResponseStatus {\n code\n }\n ... on FailedResponseStatus {\n reason\n details\n }\n }\n }\n messages @stream {\n __typename\n ... on BaseMessageOutput {\n id\n createdAt\n }\n ... on BaseMessageOutput @defer {\n status {\n ... on SuccessMessageStatus {\n code\n }\n ... on FailedMessageStatus {\n code\n reason\n }\n ... on PendingMessageStatus {\n code\n }\n }\n }\n ... on TextMessageOutput {\n content @stream\n role\n parentMessageId\n }\n ... on ImageMessageOutput {\n format\n bytes\n role\n parentMessageId\n }\n ... on ActionExecutionMessageOutput {\n name\n arguments @stream\n parentMessageId\n }\n ... on ResultMessageOutput {\n result\n actionExecutionId\n actionName\n }\n ... on AgentStateMessageOutput {\n threadId\n state\n running\n agentName\n nodeName\n runId\n active\n role\n }\n }\n metaEvents @stream {\n ... on LangGraphInterruptEvent {\n type\n name\n value\n }\n\n ... on CopilotKitLangGraphInterruptEvent {\n type\n name\n data {\n messages {\n __typename\n ... on BaseMessageOutput {\n id\n createdAt\n }\n ... on BaseMessageOutput @defer {\n status {\n ... on SuccessMessageStatus {\n code\n }\n ... on FailedMessageStatus {\n code\n reason\n }\n ... on PendingMessageStatus {\n code\n }\n }\n }\n ... on TextMessageOutput {\n content\n role\n parentMessageId\n }\n ... on ActionExecutionMessageOutput {\n name\n arguments\n parentMessageId\n }\n ... on ResultMessageOutput {\n result\n actionExecutionId\n actionName\n }\n }\n value\n }\n }\n }\n }\n }\n":c,"\n query availableAgents {\n availableAgents {\n agents {\n name\n id\n description\n }\n }\n }\n":m,"\n query loadAgentState($data: LoadAgentStateInput!) {\n loadAgentState(data: $data) {\n threadId\n threadExists\n state\n messages\n }\n }\n":g};function k(e){var n;return null!==(n=p[e])&&void 0!==n?n:{}}const v=k("\n mutation generateCopilotResponse(\n $data: GenerateCopilotResponseInput!\n $properties: JSONObject\n ) {\n generateCopilotResponse(data: $data, properties: $properties) {\n threadId\n runId\n extensions {\n openaiAssistantAPI {\n runId\n threadId\n }\n }\n ... on CopilotResponse @defer {\n status {\n ... on BaseResponseStatus {\n code\n }\n ... on FailedResponseStatus {\n reason\n details\n }\n }\n }\n messages @stream {\n __typename\n ... on BaseMessageOutput {\n id\n createdAt\n }\n ... on BaseMessageOutput @defer {\n status {\n ... on SuccessMessageStatus {\n code\n }\n ... on FailedMessageStatus {\n code\n reason\n }\n ... on PendingMessageStatus {\n code\n }\n }\n }\n ... on TextMessageOutput {\n content @stream\n role\n parentMessageId\n }\n ... on ImageMessageOutput {\n format\n bytes\n role\n parentMessageId\n }\n ... on ActionExecutionMessageOutput {\n name\n arguments @stream\n parentMessageId\n }\n ... on ResultMessageOutput {\n result\n actionExecutionId\n actionName\n }\n ... on AgentStateMessageOutput {\n threadId\n state\n running\n agentName\n nodeName\n runId\n active\n role\n }\n }\n metaEvents @stream {\n ... on LangGraphInterruptEvent {\n type\n name\n value\n }\n\n ... on CopilotKitLangGraphInterruptEvent {\n type\n name\n data {\n messages {\n __typename\n ... on BaseMessageOutput {\n id\n createdAt\n }\n ... on BaseMessageOutput @defer {\n status {\n ... on SuccessMessageStatus {\n code\n }\n ... on FailedMessageStatus {\n code\n reason\n }\n ... on PendingMessageStatus {\n code\n }\n }\n }\n ... on TextMessageOutput {\n content\n role\n parentMessageId\n }\n ... on ActionExecutionMessageOutput {\n name\n arguments\n parentMessageId\n }\n ... on ResultMessageOutput {\n result\n actionExecutionId\n actionName\n }\n }\n value\n }\n }\n }\n }\n }\n"),N=k("\n query availableAgents {\n availableAgents {\n agents {\n name\n id\n description\n }\n }\n }\n"),S=k("\n query loadAgentState($data: LoadAgentStateInput!) {\n loadAgentState(data: $data) {\n threadId\n threadExists\n state\n messages\n }\n }\n"),f=(e,n)=>async(...a)=>{var s,i,o;const d=null===(i=null===(s=a[1])||void 0===s?void 0:s.headers)||void 0===i?void 0:i["x-copilotcloud-public-api-key"];try{const s=await fetch(a[0],Object.assign(Object.assign({},null!==(o=a[1])&&void 0!==o?o:{}),{signal:e})),i=d?null:await t.getPossibleVersionMismatch({runtimeVersion:s.headers.get("X-CopilotKit-Runtime-Version"),runtimeClientGqlVersion:u});if(200!==s.status&&s.status>=400&&s.status<=500){if(i)throw new t.CopilotKitVersionMismatchError(i);throw new t.ResolvedCopilotKitError({status:s.status})}return i&&n&&n(i.message),s}catch(e){if(e.message.includes("BodyStreamBuffer was aborted")||e.message.includes("signal is aborted without reason"))throw e;if(e instanceof t.CopilotKitError)throw e;throw new t.CopilotKitLowLevelError({error:e,url:a[0]})}};class y{constructor(e){const t={};this.handleGQLErrors=e.handleGQLErrors,this.handleGQLWarning=e.handleGQLWarning,e.headers&&Object.assign(t,e.headers),e.publicApiKey&&(t["x-copilotcloud-public-api-key"]=e.publicApiKey),this.client=new n.Client({url:e.url,exchanges:[n.cacheExchange,n.fetchExchange],fetchOptions:Object.assign({headers:Object.assign(Object.assign({},t),{"X-CopilotKit-Runtime-Client-GQL-Version":u})},e.credentials?{credentials:e.credentials}:{})})}generateCopilotResponse({data:e,properties:n,signal:t}){const a=f(t,this.handleGQLWarning);return this.client.mutation(v,{data:e,properties:n},{fetch:a})}asStream(e){const n=this.handleGQLErrors;return new ReadableStream({start(t){e.subscribe(({data:e,hasNext:a,error:s})=>{var i;if(s){if(s.message.includes("BodyStreamBuffer was aborted")||s.message.includes("signal is aborted without reason"))return a||t.close(),void console.warn("Abort error suppressed");if(null===(i=s.extensions)||void 0===i?void 0:i.visibility){const e=Object.assign(Object.assign({},s),{graphQLErrors:[{message:s.message,extensions:s.extensions}]});return void(n&&n(e))}t.error(s),n&&n(s)}else t.enqueue(e),a||t.close()})}})}availableAgents(){const e=f();return this.client.query(N,{},{fetch:e})}loadAgentState(e){const n=f(),t=this.client.query(S,{data:e},{fetch:n});return t.toPromise().then(({error:e})=>{e&&this.handleGQLErrors&&this.handleGQLErrors(e)}).catch(()=>{}),t}static removeGraphQLTypename(e){return Array.isArray(e)?e.forEach(e=>y.removeGraphQLTypename(e)):"object"==typeof e&&null!==e&&(delete e.__typename,Object.keys(e).forEach(n=>{"object"==typeof e[n]&&null!==e[n]&&y.removeGraphQLTypename(e[n])})),e}}class M{constructor(n){var a,s,i;null!==(a=n.id)&&void 0!==a||(n.id=t.randomId()),null!==(s=n.status)&&void 0!==s||(n.status={code:e.MessageStatusCode.Success}),null!==(i=n.createdAt)&&void 0!==i||(n.createdAt=new Date),Object.assign(this,n)}isTextMessage(){return"TextMessage"===this.type}isActionExecutionMessage(){return"ActionExecutionMessage"===this.type}isResultMessage(){return"ResultMessage"===this.type}isAgentStateMessage(){return"AgentStateMessage"===this.type}isImageMessage(){return"ImageMessage"===this.type}}const I=e.MessageRole;class h extends M{constructor(e){super(e),this.type="TextMessage",this.type="TextMessage"}}class b extends M{constructor(e){super(e),this.type="ActionExecutionMessage"}}class A extends M{constructor(e){super(e),this.type="ResultMessage"}static decodeResult(e){return t.parseJson(e,e)}static encodeResult(e){return void 0===e?"":"string"==typeof e?e:JSON.stringify(e)}}class F extends M{constructor(e){super(e),this.type="AgentStateMessage"}}class C extends M{constructor(e){super(e),this.type="ImageMessage"}}function E(e){return" \r\n\t".indexOf(e)>=0}function w(e){try{return e.length?JSON.parse(function(e){for(var n,t,a,s=["topLevel"],i=0,o=function(e){return s.push(e)},d=function(e){return s[s.length-1]=e},r=function(e){null==n&&(n=i,t=s.length,a=e)},l=function(e){e===a&&(n=void 0,t=void 0,a=void 0)},u=function(){return s.pop()},c=function(){return i--},m=function(e){if("0"<=e&&e<="9")o("number");else switch(e){case'"':return void o("string");case"-":return void o("numberNeedsDigit");case"t":return void o("true");case"f":return void o("false");case"n":return void o("null");case"[":return void o("arrayNeedsValue");case"{":return void o("objectNeedsKey")}},g=e.length;i<g;i++){var p=e[i];switch(s[s.length-1]){case"topLevel":m(p);break;case"string":switch(p){case'"':u();break;case"\\":r("stringEscape"),o("stringEscaped")}break;case"stringEscaped":"u"===p?o("stringUnicode"):(l("stringEscape"),u());break;case"stringUnicode":i-e.lastIndexOf("u",i)===4&&(l("stringEscape"),u());break;case"number":"."===p?d("numberNeedsDigit"):"e"===p||"E"===p?d("numberNeedsExponent"):(p<"0"||p>"9")&&(c(),u());break;case"numberNeedsDigit":d("number");break;case"numberNeedsExponent":d("+"===p||"-"===p?"numberNeedsDigit":"number");break;case"true":case"false":case"null":(p<"a"||p>"z")&&(c(),u());break;case"arrayNeedsValue":"]"===p?u():E(p)||(l("collectionItem"),d("arrayNeedsComma"),m(p));break;case"arrayNeedsComma":"]"===p?u():","===p&&(r("collectionItem"),d("arrayNeedsValue"));break;case"objectNeedsKey":"}"===p?u():'"'===p&&(r("collectionItem"),d("objectNeedsColon"),o("string"));break;case"objectNeedsColon":":"===p&&d("objectNeedsValue");break;case"objectNeedsValue":E(p)||(l("collectionItem"),d("objectNeedsComma"),m(p));break;case"objectNeedsComma":"}"===p?u():","===p&&(r("collectionItem"),d("objectNeedsKey"))}}null!=t&&(s.length=t);for(var k=[null!=n?e.slice(0,n):e],v=function(n){return k.push(n.slice(e.length-e.lastIndexOf(n[0])))},N=s.length-1;N>=0;N--)switch(s[N]){case"string":k.push('"');break;case"numberNeedsDigit":case"numberNeedsExponent":k.push("0");break;case"true":v("true");break;case"false":v("false");break;case"null":v("null");break;case"arrayNeedsValue":case"arrayNeedsComma":k.push("]");break;case"objectNeedsKey":case"objectNeedsColon":case"objectNeedsValue":case"objectNeedsComma":k.push("}")}return k.join("")}(e.join(""))):{}}catch(e){return{}}}function O(e){if("assistant"!==e.role)throw new Error(`Cannot extract agent name from message with role ${e.role}`);return e.agentName||"unknown"}function x(e){return"assistant"===e.role&&"agentName"in e&&"state"in e}function T(e){if(!("assistant"===e.role||"user"===e.role)||void 0===e.image)return!1;return!(void 0===e.image.format||void 0===e.image.bytes)}function R(e,n,t){const a=[];e=Array.isArray(e)?e:[e];const s={};for(const i of e){if(x(i)){const e=O(i),n="state"in i&&i.state?i.state:{};a.push(new F({id:i.id,agentName:e,state:n,role:I.Assistant})),"generativeUI"in i&&i.generativeUI&&t&&(t[e]={name:e,render:i.generativeUI});continue}if(T(i))a.push(L(i));else if("assistant"===i.role&&i.toolCalls){a.push(j(i));for(const e of i.toolCalls){s[e.id]=e.function.name;const t=G(e,i.id);if("generativeUI"in i&&i.generativeUI&&n){const t=e.function.name,a=Object.values(n).find(e=>e.name===t),s=Object.values(n).find(e=>"*"===e.name);a?a.render=i.generativeUI:s&&(s.render=i.generativeUI)}a.push(t)}}else if("developer"!==i.role&&"system"!==i.role&&"assistant"!==i.role&&"user"!==i.role){if("tool"!==i.role)throw new Error(`Unknown message role: "${i.role}" in message with id: ${i.id}`);a.push(D(i,s))}else a.push(j(i))}return a}function j(e){if("developer"!==e.role&&"system"!==e.role&&"assistant"!==e.role&&"user"!==e.role)throw new Error(`Cannot convert message with role ${e.role} to TextMessage`);let n;return n="developer"===e.role?I.Developer:"system"===e.role?I.System:"assistant"===e.role?I.Assistant:I.User,new h({id:e.id,content:e.content||"",role:n})}function G(e,n){if("function"!==e.type)throw new Error(`Unsupported tool call type: ${e.type}`);let t;if("string"==typeof e.function.arguments)try{t=JSON.parse(e.function.arguments)}catch(n){console.warn(`Failed to parse tool call arguments for ${e.function.name}:`,n),t={}}else"object"==typeof e.function.arguments&&null!==e.function.arguments?t=e.function.arguments:(console.warn(`Invalid tool call arguments type for ${e.function.name}:`,typeof e.function.arguments),t={});return new b({id:e.id,name:e.function.name,arguments:t,parentMessageId:n})}function D(e,n){if("tool"!==e.role)throw new Error(`Cannot convert message with role ${e.role} to ResultMessage`);if(!e.toolCallId)throw new Error("Tool message must have a toolCallId");const t=n[e.toolCallId]||"unknown";let a;const s=e.content||"";if("string"==typeof s)a=s;else if("object"==typeof s&&null!==s)try{a=JSON.stringify(s)}catch(e){console.warn(`Failed to stringify tool result for ${t}:`,e),a=String(s)}else a=String(s);return new A({id:e.id,result:a,actionExecutionId:e.toolCallId,actionName:e.toolName||t})}function L(e){if(!T(e))throw new Error("Cannot convert message to ImageMessage: missing format or bytes");let n;if(n="assistant"===e.role?I.Assistant:I.User,"assistant"!==e.role&&"user"!==e.role)throw new Error(`Cannot convert message with role ${e.role} to ImageMessage`);return new C({id:e.id,format:e.image.format,bytes:e.image.bytes,role:n})}const U=["jpeg","png","webp","gif"];function _(n,t,a){const s=t&&Object.values(t).some(e=>e.name===n.name),i=t&&Object.values(t).some(e=>"*"===e.name);if(!t||!s&&!i)return{id:n.id,role:"assistant",toolCalls:[P(n)],name:n.name};const o=Object.values(t).find(e=>e.name===n.name)||Object.values(t).find(e=>"*"===e.name);return{id:n.id,role:"assistant",content:"",toolCalls:[P(n)],generativeUI:(t=>{if(t)return s=>{var i,d;let r=null==a?void 0:a.get(n.id),l="inProgress";if(void 0!==r?l="complete":(null===(i=n.status)||void 0===i?void 0:i.code)!==e.MessageStatusCode.Pending&&(l="executing"),"string"==typeof(null==s?void 0:s.result))try{s.result=JSON.parse(s.result)}catch(e){}if("string"==typeof r)try{r=JSON.parse(r)}catch(e){}const u={status:(null==s?void 0:s.status)||l,args:n.arguments||{},result:(null==s?void 0:s.result)||r||void 0,messageId:n.id};if("*"===o.name)return t(Object.assign(Object.assign(Object.assign({},u),s),{name:n.name}));{const e=null!==(d=null==s?void 0:s.respond)&&void 0!==d?d:()=>{};return t(Object.assign(Object.assign(Object.assign({},u),s),{respond:e}))}}})(o.render),name:n.name}}function q(e,n){if(n&&Object.values(n).some(n=>n.name===e.agentName)){const t=Object.values(n).find(n=>n.name===e.agentName),a=n=>{if(n)return t=>{const a=e.state;return n({state:a})}};return{id:e.id,role:"assistant",generativeUI:a(t.render),agentName:e.agentName,state:e.state}}return{id:e.id,role:"assistant",agentName:e.agentName,state:e.state}}function P(e){return{id:e.id,function:{name:e.name,arguments:JSON.stringify(e.arguments)},type:"function"}}function V(e){switch(e.role){case I.Developer:return{id:e.id,role:"developer",content:e.content};case I.System:return{id:e.id,role:"system",content:e.content};case I.Assistant:return{id:e.id,role:"assistant",content:e.content};case I.User:return{id:e.id,role:"user",content:e.content};default:throw new Error("Unknown message role")}}function $(e){return{id:e.id,role:"tool",content:e.result,toolCallId:e.actionExecutionId,toolName:e.actionName}}function K(e){if(n=e.format,!U.includes(n))throw new Error(`Invalid image format: ${e.format}. Supported formats are: ${U.join(", ")}`);var n;if(!e.bytes||"string"!=typeof e.bytes||""===e.bytes.trim())throw new Error("Image bytes must be a non-empty string");const t=e.role===I.Assistant?"assistant":"user";return{id:e.id,role:t,content:"",image:{format:e.format,bytes:e.bytes}}}e.ActionExecutionMessage=b,e.AgentStateMessage=F,e.AvailableAgentsDocument=m,e.CopilotRuntimeClient=y,e.GenerateCopilotResponseDocument=c,e.ImageMessage=C,e.LoadAgentStateDocument=g,e.Message=M,e.ResultMessage=A,e.Role=I,e.TextMessage=h,e.aguiMessageWithImageToGQLMessage=L,e.aguiMessageWithRenderToGQL=function(e,n,t){if("assistant"===e.role&&"generativeUI"in e&&e.generativeUI&&!e.toolCalls){const n=[];return n.push(new F({id:e.id,agentName:"unknown",state:{},role:I.Assistant})),t&&(t.unknown={name:"unknown",render:e.generativeUI}),n}return R([e],n,t)},e.aguiTextMessageToGQLMessage=j,e.aguiToGQL=R,e.aguiToolCallToGQLActionExecution=G,e.aguiToolMessageToGQLResultMessage=D,e.convertGqlOutputToMessages=function(n){return n.map(n=>{if("TextMessageOutput"===n.__typename)return new h({id:n.id,role:n.role,content:n.content.join(""),parentMessageId:n.parentMessageId,createdAt:new Date,status:n.status||{code:e.MessageStatusCode.Pending}});if("ActionExecutionMessageOutput"===n.__typename)return new b({id:n.id,name:n.name,arguments:w(n.arguments),parentMessageId:n.parentMessageId,createdAt:new Date,status:n.status||{code:e.MessageStatusCode.Pending}});if("ResultMessageOutput"===n.__typename)return new A({id:n.id,result:n.result,actionExecutionId:n.actionExecutionId,actionName:n.actionName,createdAt:new Date,status:n.status||{code:e.MessageStatusCode.Pending}});if("AgentStateMessageOutput"===n.__typename)return new F({id:n.id,threadId:n.threadId,role:n.role,agentName:n.agentName,nodeName:n.nodeName,runId:n.runId,active:n.active,running:n.running,state:t.parseJson(n.state,{}),createdAt:new Date});if("ImageMessageOutput"===n.__typename)return new C({id:n.id,format:n.format,bytes:n.bytes,role:n.role,parentMessageId:n.parentMessageId,createdAt:new Date,status:n.status||{code:e.MessageStatusCode.Pending}});throw new Error("Unknown message type")})},e.convertMessagesToGqlInput=function(e){return e.map(e=>{if(e.isTextMessage())return{id:e.id,createdAt:e.createdAt,textMessage:{content:e.content,role:e.role,parentMessageId:e.parentMessageId}};if(e.isActionExecutionMessage())return{id:e.id,createdAt:e.createdAt,actionExecutionMessage:{name:e.name,arguments:JSON.stringify(e.arguments),parentMessageId:e.parentMessageId}};if(e.isResultMessage())return{id:e.id,createdAt:e.createdAt,resultMessage:{result:e.result,actionExecutionId:e.actionExecutionId,actionName:e.actionName}};if(e.isAgentStateMessage())return{id:e.id,createdAt:e.createdAt,agentStateMessage:{threadId:e.threadId,role:e.role,agentName:e.agentName,nodeName:e.nodeName,runId:e.runId,active:e.active,running:e.running,state:JSON.stringify(e.state)}};if(e.isImageMessage())return{id:e.id,createdAt:e.createdAt,imageMessage:{format:e.format,bytes:e.bytes,role:e.role,parentMessageId:e.parentMessageId}};throw new Error("Unknown message type")})},e.filterAdjacentAgentStateMessages=function(e){const n=[];return e.forEach((e,t)=>{if("AgentStateMessageOutput"!==e.__typename)n.push(e);else{const t=n.findIndex(n=>"AgentStateMessageOutput"===n.__typename&&n.agentName===e.agentName);-1===t?n.push(e):n[t]=e}}),n},e.filterAgentStateMessages=function(e){return e.filter(e=>!e.isAgentStateMessage())},e.gqlActionExecutionMessageToAGUIMessage=_,e.gqlImageMessageToAGUIMessage=K,e.gqlResultMessageToAGUIMessage=$,e.gqlTextMessageToAGUIMessage=V,e.gqlToAGUI=function(e,n,t){let a=[];e=Array.isArray(e)?e:[e];const s=new Map;for(const n of e)n.isResultMessage()&&s.set(n.actionExecutionId,n.result);for(const i of e)if(i.isTextMessage())a.push(V(i));else if(i.isResultMessage())a.push($(i));else if(i.isActionExecutionMessage())a.push(_(i,n,s));else if(i.isAgentStateMessage())a.push(q(i,t));else{if(!i.isImageMessage())throw new Error("Unknown message type");a.push(K(i))}return a},e.langGraphInterruptEvent=function(n){return Object.assign(Object.assign({},n),{name:e.MetaEventName.LangGraphInterruptEvent,type:"MetaEvent"})},e.loadMessagesFromJsonRepresentation=function(n){const t=[];for(const a of n)"content"in a?t.push(new h({id:a.id,role:a.role,content:a.content,parentMessageId:a.parentMessageId,createdAt:a.createdAt||new Date,status:a.status||{code:e.MessageStatusCode.Success}})):"arguments"in a?t.push(new b({id:a.id,name:a.name,arguments:a.arguments,parentMessageId:a.parentMessageId,createdAt:a.createdAt||new Date,status:a.status||{code:e.MessageStatusCode.Success}})):"result"in a?t.push(new A({id:a.id,result:a.result,actionExecutionId:a.actionExecutionId,actionName:a.actionName,createdAt:a.createdAt||new Date,status:a.status||{code:e.MessageStatusCode.Success}})):"state"in a?t.push(new F({id:a.id,threadId:a.threadId,role:a.role,agentName:a.agentName,nodeName:a.nodeName,runId:a.runId,active:a.active,running:a.running,state:a.state,createdAt:a.createdAt||new Date})):"format"in a&&"bytes"in a&&t.push(new C({id:a.id,format:a.format,bytes:a.bytes,role:a.role,parentMessageId:a.parentMessageId,createdAt:a.createdAt||new Date,status:a.status||{code:e.MessageStatusCode.Success}}));return t}});
|
|
2
|
-
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@urql/core'), require('@copilotkit/shared'), require('untruncate-json')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@urql/core', '@copilotkit/shared', 'untruncate-json'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitRuntimeClientGQL = {}), global.UrqlCore,global.CopilotKitShared,global.untruncateJson));
|
|
5
|
+
})(this, function(exports, _urql_core, _copilotkit_shared, untruncate_json) {
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
7
|
+
//#region \0rolldown/runtime.js
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
17
|
+
key = keys[i];
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
19
|
+
__defProp(to, key, {
|
|
20
|
+
get: ((k) => from[k]).bind(null, key),
|
|
21
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
29
|
+
value: mod,
|
|
30
|
+
enumerable: true
|
|
31
|
+
}) : target, mod));
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
untruncate_json = __toESM(untruncate_json);
|
|
35
|
+
|
|
36
|
+
//#region package.json
|
|
37
|
+
var version = "1.51.5-next.1";
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/graphql/@generated/graphql.ts
|
|
41
|
+
/** The availability of the frontend action */
|
|
42
|
+
let ActionInputAvailability = /* @__PURE__ */ function(ActionInputAvailability) {
|
|
43
|
+
ActionInputAvailability["Disabled"] = "disabled";
|
|
44
|
+
ActionInputAvailability["Enabled"] = "enabled";
|
|
45
|
+
ActionInputAvailability["Remote"] = "remote";
|
|
46
|
+
return ActionInputAvailability;
|
|
47
|
+
}({});
|
|
48
|
+
/** The type of Copilot request */
|
|
49
|
+
let CopilotRequestType = /* @__PURE__ */ function(CopilotRequestType) {
|
|
50
|
+
CopilotRequestType["Chat"] = "Chat";
|
|
51
|
+
CopilotRequestType["Suggestion"] = "Suggestion";
|
|
52
|
+
CopilotRequestType["Task"] = "Task";
|
|
53
|
+
CopilotRequestType["TextareaCompletion"] = "TextareaCompletion";
|
|
54
|
+
CopilotRequestType["TextareaPopover"] = "TextareaPopover";
|
|
55
|
+
return CopilotRequestType;
|
|
56
|
+
}({});
|
|
57
|
+
let FailedResponseStatusReason = /* @__PURE__ */ function(FailedResponseStatusReason) {
|
|
58
|
+
FailedResponseStatusReason["GuardrailsValidationFailed"] = "GUARDRAILS_VALIDATION_FAILED";
|
|
59
|
+
FailedResponseStatusReason["MessageStreamInterrupted"] = "MESSAGE_STREAM_INTERRUPTED";
|
|
60
|
+
FailedResponseStatusReason["UnknownError"] = "UNKNOWN_ERROR";
|
|
61
|
+
return FailedResponseStatusReason;
|
|
62
|
+
}({});
|
|
63
|
+
/** The role of the message */
|
|
64
|
+
let MessageRole = /* @__PURE__ */ function(MessageRole) {
|
|
65
|
+
MessageRole["Assistant"] = "assistant";
|
|
66
|
+
MessageRole["Developer"] = "developer";
|
|
67
|
+
MessageRole["System"] = "system";
|
|
68
|
+
MessageRole["Tool"] = "tool";
|
|
69
|
+
MessageRole["User"] = "user";
|
|
70
|
+
return MessageRole;
|
|
71
|
+
}({});
|
|
72
|
+
let MessageStatusCode = /* @__PURE__ */ function(MessageStatusCode) {
|
|
73
|
+
MessageStatusCode["Failed"] = "Failed";
|
|
74
|
+
MessageStatusCode["Pending"] = "Pending";
|
|
75
|
+
MessageStatusCode["Success"] = "Success";
|
|
76
|
+
return MessageStatusCode;
|
|
77
|
+
}({});
|
|
78
|
+
/** Meta event types */
|
|
79
|
+
let MetaEventName = /* @__PURE__ */ function(MetaEventName) {
|
|
80
|
+
MetaEventName["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
|
|
81
|
+
MetaEventName["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
|
|
82
|
+
return MetaEventName;
|
|
83
|
+
}({});
|
|
84
|
+
let ResponseStatusCode = /* @__PURE__ */ function(ResponseStatusCode) {
|
|
85
|
+
ResponseStatusCode["Failed"] = "Failed";
|
|
86
|
+
ResponseStatusCode["Pending"] = "Pending";
|
|
87
|
+
ResponseStatusCode["Success"] = "Success";
|
|
88
|
+
return ResponseStatusCode;
|
|
89
|
+
}({});
|
|
90
|
+
const GenerateCopilotResponseDocument = {
|
|
91
|
+
"kind": "Document",
|
|
92
|
+
"definitions": [{
|
|
93
|
+
"kind": "OperationDefinition",
|
|
94
|
+
"operation": "mutation",
|
|
95
|
+
"name": {
|
|
96
|
+
"kind": "Name",
|
|
97
|
+
"value": "generateCopilotResponse"
|
|
98
|
+
},
|
|
99
|
+
"variableDefinitions": [{
|
|
100
|
+
"kind": "VariableDefinition",
|
|
101
|
+
"variable": {
|
|
102
|
+
"kind": "Variable",
|
|
103
|
+
"name": {
|
|
104
|
+
"kind": "Name",
|
|
105
|
+
"value": "data"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"type": {
|
|
109
|
+
"kind": "NonNullType",
|
|
110
|
+
"type": {
|
|
111
|
+
"kind": "NamedType",
|
|
112
|
+
"name": {
|
|
113
|
+
"kind": "Name",
|
|
114
|
+
"value": "GenerateCopilotResponseInput"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
"kind": "VariableDefinition",
|
|
120
|
+
"variable": {
|
|
121
|
+
"kind": "Variable",
|
|
122
|
+
"name": {
|
|
123
|
+
"kind": "Name",
|
|
124
|
+
"value": "properties"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"type": {
|
|
128
|
+
"kind": "NamedType",
|
|
129
|
+
"name": {
|
|
130
|
+
"kind": "Name",
|
|
131
|
+
"value": "JSONObject"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}],
|
|
135
|
+
"selectionSet": {
|
|
136
|
+
"kind": "SelectionSet",
|
|
137
|
+
"selections": [{
|
|
138
|
+
"kind": "Field",
|
|
139
|
+
"name": {
|
|
140
|
+
"kind": "Name",
|
|
141
|
+
"value": "generateCopilotResponse"
|
|
142
|
+
},
|
|
143
|
+
"arguments": [{
|
|
144
|
+
"kind": "Argument",
|
|
145
|
+
"name": {
|
|
146
|
+
"kind": "Name",
|
|
147
|
+
"value": "data"
|
|
148
|
+
},
|
|
149
|
+
"value": {
|
|
150
|
+
"kind": "Variable",
|
|
151
|
+
"name": {
|
|
152
|
+
"kind": "Name",
|
|
153
|
+
"value": "data"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
"kind": "Argument",
|
|
158
|
+
"name": {
|
|
159
|
+
"kind": "Name",
|
|
160
|
+
"value": "properties"
|
|
161
|
+
},
|
|
162
|
+
"value": {
|
|
163
|
+
"kind": "Variable",
|
|
164
|
+
"name": {
|
|
165
|
+
"kind": "Name",
|
|
166
|
+
"value": "properties"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}],
|
|
170
|
+
"selectionSet": {
|
|
171
|
+
"kind": "SelectionSet",
|
|
172
|
+
"selections": [
|
|
173
|
+
{
|
|
174
|
+
"kind": "Field",
|
|
175
|
+
"name": {
|
|
176
|
+
"kind": "Name",
|
|
177
|
+
"value": "threadId"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"kind": "Field",
|
|
182
|
+
"name": {
|
|
183
|
+
"kind": "Name",
|
|
184
|
+
"value": "runId"
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"kind": "Field",
|
|
189
|
+
"name": {
|
|
190
|
+
"kind": "Name",
|
|
191
|
+
"value": "extensions"
|
|
192
|
+
},
|
|
193
|
+
"selectionSet": {
|
|
194
|
+
"kind": "SelectionSet",
|
|
195
|
+
"selections": [{
|
|
196
|
+
"kind": "Field",
|
|
197
|
+
"name": {
|
|
198
|
+
"kind": "Name",
|
|
199
|
+
"value": "openaiAssistantAPI"
|
|
200
|
+
},
|
|
201
|
+
"selectionSet": {
|
|
202
|
+
"kind": "SelectionSet",
|
|
203
|
+
"selections": [{
|
|
204
|
+
"kind": "Field",
|
|
205
|
+
"name": {
|
|
206
|
+
"kind": "Name",
|
|
207
|
+
"value": "runId"
|
|
208
|
+
}
|
|
209
|
+
}, {
|
|
210
|
+
"kind": "Field",
|
|
211
|
+
"name": {
|
|
212
|
+
"kind": "Name",
|
|
213
|
+
"value": "threadId"
|
|
214
|
+
}
|
|
215
|
+
}]
|
|
216
|
+
}
|
|
217
|
+
}]
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"kind": "InlineFragment",
|
|
222
|
+
"typeCondition": {
|
|
223
|
+
"kind": "NamedType",
|
|
224
|
+
"name": {
|
|
225
|
+
"kind": "Name",
|
|
226
|
+
"value": "CopilotResponse"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
"directives": [{
|
|
230
|
+
"kind": "Directive",
|
|
231
|
+
"name": {
|
|
232
|
+
"kind": "Name",
|
|
233
|
+
"value": "defer"
|
|
234
|
+
}
|
|
235
|
+
}],
|
|
236
|
+
"selectionSet": {
|
|
237
|
+
"kind": "SelectionSet",
|
|
238
|
+
"selections": [{
|
|
239
|
+
"kind": "Field",
|
|
240
|
+
"name": {
|
|
241
|
+
"kind": "Name",
|
|
242
|
+
"value": "status"
|
|
243
|
+
},
|
|
244
|
+
"selectionSet": {
|
|
245
|
+
"kind": "SelectionSet",
|
|
246
|
+
"selections": [{
|
|
247
|
+
"kind": "InlineFragment",
|
|
248
|
+
"typeCondition": {
|
|
249
|
+
"kind": "NamedType",
|
|
250
|
+
"name": {
|
|
251
|
+
"kind": "Name",
|
|
252
|
+
"value": "BaseResponseStatus"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
"selectionSet": {
|
|
256
|
+
"kind": "SelectionSet",
|
|
257
|
+
"selections": [{
|
|
258
|
+
"kind": "Field",
|
|
259
|
+
"name": {
|
|
260
|
+
"kind": "Name",
|
|
261
|
+
"value": "code"
|
|
262
|
+
}
|
|
263
|
+
}]
|
|
264
|
+
}
|
|
265
|
+
}, {
|
|
266
|
+
"kind": "InlineFragment",
|
|
267
|
+
"typeCondition": {
|
|
268
|
+
"kind": "NamedType",
|
|
269
|
+
"name": {
|
|
270
|
+
"kind": "Name",
|
|
271
|
+
"value": "FailedResponseStatus"
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
"selectionSet": {
|
|
275
|
+
"kind": "SelectionSet",
|
|
276
|
+
"selections": [{
|
|
277
|
+
"kind": "Field",
|
|
278
|
+
"name": {
|
|
279
|
+
"kind": "Name",
|
|
280
|
+
"value": "reason"
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
"kind": "Field",
|
|
284
|
+
"name": {
|
|
285
|
+
"kind": "Name",
|
|
286
|
+
"value": "details"
|
|
287
|
+
}
|
|
288
|
+
}]
|
|
289
|
+
}
|
|
290
|
+
}]
|
|
291
|
+
}
|
|
292
|
+
}]
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"kind": "Field",
|
|
297
|
+
"name": {
|
|
298
|
+
"kind": "Name",
|
|
299
|
+
"value": "messages"
|
|
300
|
+
},
|
|
301
|
+
"directives": [{
|
|
302
|
+
"kind": "Directive",
|
|
303
|
+
"name": {
|
|
304
|
+
"kind": "Name",
|
|
305
|
+
"value": "stream"
|
|
306
|
+
}
|
|
307
|
+
}],
|
|
308
|
+
"selectionSet": {
|
|
309
|
+
"kind": "SelectionSet",
|
|
310
|
+
"selections": [
|
|
311
|
+
{
|
|
312
|
+
"kind": "Field",
|
|
313
|
+
"name": {
|
|
314
|
+
"kind": "Name",
|
|
315
|
+
"value": "__typename"
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"kind": "InlineFragment",
|
|
320
|
+
"typeCondition": {
|
|
321
|
+
"kind": "NamedType",
|
|
322
|
+
"name": {
|
|
323
|
+
"kind": "Name",
|
|
324
|
+
"value": "BaseMessageOutput"
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
"selectionSet": {
|
|
328
|
+
"kind": "SelectionSet",
|
|
329
|
+
"selections": [{
|
|
330
|
+
"kind": "Field",
|
|
331
|
+
"name": {
|
|
332
|
+
"kind": "Name",
|
|
333
|
+
"value": "id"
|
|
334
|
+
}
|
|
335
|
+
}, {
|
|
336
|
+
"kind": "Field",
|
|
337
|
+
"name": {
|
|
338
|
+
"kind": "Name",
|
|
339
|
+
"value": "createdAt"
|
|
340
|
+
}
|
|
341
|
+
}]
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
"kind": "InlineFragment",
|
|
346
|
+
"typeCondition": {
|
|
347
|
+
"kind": "NamedType",
|
|
348
|
+
"name": {
|
|
349
|
+
"kind": "Name",
|
|
350
|
+
"value": "BaseMessageOutput"
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
"directives": [{
|
|
354
|
+
"kind": "Directive",
|
|
355
|
+
"name": {
|
|
356
|
+
"kind": "Name",
|
|
357
|
+
"value": "defer"
|
|
358
|
+
}
|
|
359
|
+
}],
|
|
360
|
+
"selectionSet": {
|
|
361
|
+
"kind": "SelectionSet",
|
|
362
|
+
"selections": [{
|
|
363
|
+
"kind": "Field",
|
|
364
|
+
"name": {
|
|
365
|
+
"kind": "Name",
|
|
366
|
+
"value": "status"
|
|
367
|
+
},
|
|
368
|
+
"selectionSet": {
|
|
369
|
+
"kind": "SelectionSet",
|
|
370
|
+
"selections": [
|
|
371
|
+
{
|
|
372
|
+
"kind": "InlineFragment",
|
|
373
|
+
"typeCondition": {
|
|
374
|
+
"kind": "NamedType",
|
|
375
|
+
"name": {
|
|
376
|
+
"kind": "Name",
|
|
377
|
+
"value": "SuccessMessageStatus"
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
"selectionSet": {
|
|
381
|
+
"kind": "SelectionSet",
|
|
382
|
+
"selections": [{
|
|
383
|
+
"kind": "Field",
|
|
384
|
+
"name": {
|
|
385
|
+
"kind": "Name",
|
|
386
|
+
"value": "code"
|
|
387
|
+
}
|
|
388
|
+
}]
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"kind": "InlineFragment",
|
|
393
|
+
"typeCondition": {
|
|
394
|
+
"kind": "NamedType",
|
|
395
|
+
"name": {
|
|
396
|
+
"kind": "Name",
|
|
397
|
+
"value": "FailedMessageStatus"
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
"selectionSet": {
|
|
401
|
+
"kind": "SelectionSet",
|
|
402
|
+
"selections": [{
|
|
403
|
+
"kind": "Field",
|
|
404
|
+
"name": {
|
|
405
|
+
"kind": "Name",
|
|
406
|
+
"value": "code"
|
|
407
|
+
}
|
|
408
|
+
}, {
|
|
409
|
+
"kind": "Field",
|
|
410
|
+
"name": {
|
|
411
|
+
"kind": "Name",
|
|
412
|
+
"value": "reason"
|
|
413
|
+
}
|
|
414
|
+
}]
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"kind": "InlineFragment",
|
|
419
|
+
"typeCondition": {
|
|
420
|
+
"kind": "NamedType",
|
|
421
|
+
"name": {
|
|
422
|
+
"kind": "Name",
|
|
423
|
+
"value": "PendingMessageStatus"
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
"selectionSet": {
|
|
427
|
+
"kind": "SelectionSet",
|
|
428
|
+
"selections": [{
|
|
429
|
+
"kind": "Field",
|
|
430
|
+
"name": {
|
|
431
|
+
"kind": "Name",
|
|
432
|
+
"value": "code"
|
|
433
|
+
}
|
|
434
|
+
}]
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
]
|
|
438
|
+
}
|
|
439
|
+
}]
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
"kind": "InlineFragment",
|
|
444
|
+
"typeCondition": {
|
|
445
|
+
"kind": "NamedType",
|
|
446
|
+
"name": {
|
|
447
|
+
"kind": "Name",
|
|
448
|
+
"value": "TextMessageOutput"
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
"selectionSet": {
|
|
452
|
+
"kind": "SelectionSet",
|
|
453
|
+
"selections": [
|
|
454
|
+
{
|
|
455
|
+
"kind": "Field",
|
|
456
|
+
"name": {
|
|
457
|
+
"kind": "Name",
|
|
458
|
+
"value": "content"
|
|
459
|
+
},
|
|
460
|
+
"directives": [{
|
|
461
|
+
"kind": "Directive",
|
|
462
|
+
"name": {
|
|
463
|
+
"kind": "Name",
|
|
464
|
+
"value": "stream"
|
|
465
|
+
}
|
|
466
|
+
}]
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
"kind": "Field",
|
|
470
|
+
"name": {
|
|
471
|
+
"kind": "Name",
|
|
472
|
+
"value": "role"
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
"kind": "Field",
|
|
477
|
+
"name": {
|
|
478
|
+
"kind": "Name",
|
|
479
|
+
"value": "parentMessageId"
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
]
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
"kind": "InlineFragment",
|
|
487
|
+
"typeCondition": {
|
|
488
|
+
"kind": "NamedType",
|
|
489
|
+
"name": {
|
|
490
|
+
"kind": "Name",
|
|
491
|
+
"value": "ImageMessageOutput"
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
"selectionSet": {
|
|
495
|
+
"kind": "SelectionSet",
|
|
496
|
+
"selections": [
|
|
497
|
+
{
|
|
498
|
+
"kind": "Field",
|
|
499
|
+
"name": {
|
|
500
|
+
"kind": "Name",
|
|
501
|
+
"value": "format"
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
"kind": "Field",
|
|
506
|
+
"name": {
|
|
507
|
+
"kind": "Name",
|
|
508
|
+
"value": "bytes"
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
"kind": "Field",
|
|
513
|
+
"name": {
|
|
514
|
+
"kind": "Name",
|
|
515
|
+
"value": "role"
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
"kind": "Field",
|
|
520
|
+
"name": {
|
|
521
|
+
"kind": "Name",
|
|
522
|
+
"value": "parentMessageId"
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
]
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
"kind": "InlineFragment",
|
|
530
|
+
"typeCondition": {
|
|
531
|
+
"kind": "NamedType",
|
|
532
|
+
"name": {
|
|
533
|
+
"kind": "Name",
|
|
534
|
+
"value": "ActionExecutionMessageOutput"
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
"selectionSet": {
|
|
538
|
+
"kind": "SelectionSet",
|
|
539
|
+
"selections": [
|
|
540
|
+
{
|
|
541
|
+
"kind": "Field",
|
|
542
|
+
"name": {
|
|
543
|
+
"kind": "Name",
|
|
544
|
+
"value": "name"
|
|
545
|
+
}
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
"kind": "Field",
|
|
549
|
+
"name": {
|
|
550
|
+
"kind": "Name",
|
|
551
|
+
"value": "arguments"
|
|
552
|
+
},
|
|
553
|
+
"directives": [{
|
|
554
|
+
"kind": "Directive",
|
|
555
|
+
"name": {
|
|
556
|
+
"kind": "Name",
|
|
557
|
+
"value": "stream"
|
|
558
|
+
}
|
|
559
|
+
}]
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
"kind": "Field",
|
|
563
|
+
"name": {
|
|
564
|
+
"kind": "Name",
|
|
565
|
+
"value": "parentMessageId"
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
]
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
"kind": "InlineFragment",
|
|
573
|
+
"typeCondition": {
|
|
574
|
+
"kind": "NamedType",
|
|
575
|
+
"name": {
|
|
576
|
+
"kind": "Name",
|
|
577
|
+
"value": "ResultMessageOutput"
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
"selectionSet": {
|
|
581
|
+
"kind": "SelectionSet",
|
|
582
|
+
"selections": [
|
|
583
|
+
{
|
|
584
|
+
"kind": "Field",
|
|
585
|
+
"name": {
|
|
586
|
+
"kind": "Name",
|
|
587
|
+
"value": "result"
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
"kind": "Field",
|
|
592
|
+
"name": {
|
|
593
|
+
"kind": "Name",
|
|
594
|
+
"value": "actionExecutionId"
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
"kind": "Field",
|
|
599
|
+
"name": {
|
|
600
|
+
"kind": "Name",
|
|
601
|
+
"value": "actionName"
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
]
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
"kind": "InlineFragment",
|
|
609
|
+
"typeCondition": {
|
|
610
|
+
"kind": "NamedType",
|
|
611
|
+
"name": {
|
|
612
|
+
"kind": "Name",
|
|
613
|
+
"value": "AgentStateMessageOutput"
|
|
614
|
+
}
|
|
615
|
+
},
|
|
616
|
+
"selectionSet": {
|
|
617
|
+
"kind": "SelectionSet",
|
|
618
|
+
"selections": [
|
|
619
|
+
{
|
|
620
|
+
"kind": "Field",
|
|
621
|
+
"name": {
|
|
622
|
+
"kind": "Name",
|
|
623
|
+
"value": "threadId"
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
"kind": "Field",
|
|
628
|
+
"name": {
|
|
629
|
+
"kind": "Name",
|
|
630
|
+
"value": "state"
|
|
631
|
+
}
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
"kind": "Field",
|
|
635
|
+
"name": {
|
|
636
|
+
"kind": "Name",
|
|
637
|
+
"value": "running"
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
"kind": "Field",
|
|
642
|
+
"name": {
|
|
643
|
+
"kind": "Name",
|
|
644
|
+
"value": "agentName"
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
"kind": "Field",
|
|
649
|
+
"name": {
|
|
650
|
+
"kind": "Name",
|
|
651
|
+
"value": "nodeName"
|
|
652
|
+
}
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
"kind": "Field",
|
|
656
|
+
"name": {
|
|
657
|
+
"kind": "Name",
|
|
658
|
+
"value": "runId"
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
"kind": "Field",
|
|
663
|
+
"name": {
|
|
664
|
+
"kind": "Name",
|
|
665
|
+
"value": "active"
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
"kind": "Field",
|
|
670
|
+
"name": {
|
|
671
|
+
"kind": "Name",
|
|
672
|
+
"value": "role"
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
]
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
]
|
|
679
|
+
}
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
"kind": "Field",
|
|
683
|
+
"name": {
|
|
684
|
+
"kind": "Name",
|
|
685
|
+
"value": "metaEvents"
|
|
686
|
+
},
|
|
687
|
+
"directives": [{
|
|
688
|
+
"kind": "Directive",
|
|
689
|
+
"name": {
|
|
690
|
+
"kind": "Name",
|
|
691
|
+
"value": "stream"
|
|
692
|
+
}
|
|
693
|
+
}],
|
|
694
|
+
"selectionSet": {
|
|
695
|
+
"kind": "SelectionSet",
|
|
696
|
+
"selections": [{
|
|
697
|
+
"kind": "InlineFragment",
|
|
698
|
+
"typeCondition": {
|
|
699
|
+
"kind": "NamedType",
|
|
700
|
+
"name": {
|
|
701
|
+
"kind": "Name",
|
|
702
|
+
"value": "LangGraphInterruptEvent"
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
"selectionSet": {
|
|
706
|
+
"kind": "SelectionSet",
|
|
707
|
+
"selections": [
|
|
708
|
+
{
|
|
709
|
+
"kind": "Field",
|
|
710
|
+
"name": {
|
|
711
|
+
"kind": "Name",
|
|
712
|
+
"value": "type"
|
|
713
|
+
}
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
"kind": "Field",
|
|
717
|
+
"name": {
|
|
718
|
+
"kind": "Name",
|
|
719
|
+
"value": "name"
|
|
720
|
+
}
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
"kind": "Field",
|
|
724
|
+
"name": {
|
|
725
|
+
"kind": "Name",
|
|
726
|
+
"value": "value"
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
]
|
|
730
|
+
}
|
|
731
|
+
}, {
|
|
732
|
+
"kind": "InlineFragment",
|
|
733
|
+
"typeCondition": {
|
|
734
|
+
"kind": "NamedType",
|
|
735
|
+
"name": {
|
|
736
|
+
"kind": "Name",
|
|
737
|
+
"value": "CopilotKitLangGraphInterruptEvent"
|
|
738
|
+
}
|
|
739
|
+
},
|
|
740
|
+
"selectionSet": {
|
|
741
|
+
"kind": "SelectionSet",
|
|
742
|
+
"selections": [
|
|
743
|
+
{
|
|
744
|
+
"kind": "Field",
|
|
745
|
+
"name": {
|
|
746
|
+
"kind": "Name",
|
|
747
|
+
"value": "type"
|
|
748
|
+
}
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
"kind": "Field",
|
|
752
|
+
"name": {
|
|
753
|
+
"kind": "Name",
|
|
754
|
+
"value": "name"
|
|
755
|
+
}
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
"kind": "Field",
|
|
759
|
+
"name": {
|
|
760
|
+
"kind": "Name",
|
|
761
|
+
"value": "data"
|
|
762
|
+
},
|
|
763
|
+
"selectionSet": {
|
|
764
|
+
"kind": "SelectionSet",
|
|
765
|
+
"selections": [{
|
|
766
|
+
"kind": "Field",
|
|
767
|
+
"name": {
|
|
768
|
+
"kind": "Name",
|
|
769
|
+
"value": "messages"
|
|
770
|
+
},
|
|
771
|
+
"selectionSet": {
|
|
772
|
+
"kind": "SelectionSet",
|
|
773
|
+
"selections": [
|
|
774
|
+
{
|
|
775
|
+
"kind": "Field",
|
|
776
|
+
"name": {
|
|
777
|
+
"kind": "Name",
|
|
778
|
+
"value": "__typename"
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
"kind": "InlineFragment",
|
|
783
|
+
"typeCondition": {
|
|
784
|
+
"kind": "NamedType",
|
|
785
|
+
"name": {
|
|
786
|
+
"kind": "Name",
|
|
787
|
+
"value": "BaseMessageOutput"
|
|
788
|
+
}
|
|
789
|
+
},
|
|
790
|
+
"selectionSet": {
|
|
791
|
+
"kind": "SelectionSet",
|
|
792
|
+
"selections": [{
|
|
793
|
+
"kind": "Field",
|
|
794
|
+
"name": {
|
|
795
|
+
"kind": "Name",
|
|
796
|
+
"value": "id"
|
|
797
|
+
}
|
|
798
|
+
}, {
|
|
799
|
+
"kind": "Field",
|
|
800
|
+
"name": {
|
|
801
|
+
"kind": "Name",
|
|
802
|
+
"value": "createdAt"
|
|
803
|
+
}
|
|
804
|
+
}]
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
"kind": "InlineFragment",
|
|
809
|
+
"typeCondition": {
|
|
810
|
+
"kind": "NamedType",
|
|
811
|
+
"name": {
|
|
812
|
+
"kind": "Name",
|
|
813
|
+
"value": "BaseMessageOutput"
|
|
814
|
+
}
|
|
815
|
+
},
|
|
816
|
+
"directives": [{
|
|
817
|
+
"kind": "Directive",
|
|
818
|
+
"name": {
|
|
819
|
+
"kind": "Name",
|
|
820
|
+
"value": "defer"
|
|
821
|
+
}
|
|
822
|
+
}],
|
|
823
|
+
"selectionSet": {
|
|
824
|
+
"kind": "SelectionSet",
|
|
825
|
+
"selections": [{
|
|
826
|
+
"kind": "Field",
|
|
827
|
+
"name": {
|
|
828
|
+
"kind": "Name",
|
|
829
|
+
"value": "status"
|
|
830
|
+
},
|
|
831
|
+
"selectionSet": {
|
|
832
|
+
"kind": "SelectionSet",
|
|
833
|
+
"selections": [
|
|
834
|
+
{
|
|
835
|
+
"kind": "InlineFragment",
|
|
836
|
+
"typeCondition": {
|
|
837
|
+
"kind": "NamedType",
|
|
838
|
+
"name": {
|
|
839
|
+
"kind": "Name",
|
|
840
|
+
"value": "SuccessMessageStatus"
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
"selectionSet": {
|
|
844
|
+
"kind": "SelectionSet",
|
|
845
|
+
"selections": [{
|
|
846
|
+
"kind": "Field",
|
|
847
|
+
"name": {
|
|
848
|
+
"kind": "Name",
|
|
849
|
+
"value": "code"
|
|
850
|
+
}
|
|
851
|
+
}]
|
|
852
|
+
}
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
"kind": "InlineFragment",
|
|
856
|
+
"typeCondition": {
|
|
857
|
+
"kind": "NamedType",
|
|
858
|
+
"name": {
|
|
859
|
+
"kind": "Name",
|
|
860
|
+
"value": "FailedMessageStatus"
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
"selectionSet": {
|
|
864
|
+
"kind": "SelectionSet",
|
|
865
|
+
"selections": [{
|
|
866
|
+
"kind": "Field",
|
|
867
|
+
"name": {
|
|
868
|
+
"kind": "Name",
|
|
869
|
+
"value": "code"
|
|
870
|
+
}
|
|
871
|
+
}, {
|
|
872
|
+
"kind": "Field",
|
|
873
|
+
"name": {
|
|
874
|
+
"kind": "Name",
|
|
875
|
+
"value": "reason"
|
|
876
|
+
}
|
|
877
|
+
}]
|
|
878
|
+
}
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
"kind": "InlineFragment",
|
|
882
|
+
"typeCondition": {
|
|
883
|
+
"kind": "NamedType",
|
|
884
|
+
"name": {
|
|
885
|
+
"kind": "Name",
|
|
886
|
+
"value": "PendingMessageStatus"
|
|
887
|
+
}
|
|
888
|
+
},
|
|
889
|
+
"selectionSet": {
|
|
890
|
+
"kind": "SelectionSet",
|
|
891
|
+
"selections": [{
|
|
892
|
+
"kind": "Field",
|
|
893
|
+
"name": {
|
|
894
|
+
"kind": "Name",
|
|
895
|
+
"value": "code"
|
|
896
|
+
}
|
|
897
|
+
}]
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
]
|
|
901
|
+
}
|
|
902
|
+
}]
|
|
903
|
+
}
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
"kind": "InlineFragment",
|
|
907
|
+
"typeCondition": {
|
|
908
|
+
"kind": "NamedType",
|
|
909
|
+
"name": {
|
|
910
|
+
"kind": "Name",
|
|
911
|
+
"value": "TextMessageOutput"
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
"selectionSet": {
|
|
915
|
+
"kind": "SelectionSet",
|
|
916
|
+
"selections": [
|
|
917
|
+
{
|
|
918
|
+
"kind": "Field",
|
|
919
|
+
"name": {
|
|
920
|
+
"kind": "Name",
|
|
921
|
+
"value": "content"
|
|
922
|
+
}
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
"kind": "Field",
|
|
926
|
+
"name": {
|
|
927
|
+
"kind": "Name",
|
|
928
|
+
"value": "role"
|
|
929
|
+
}
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
"kind": "Field",
|
|
933
|
+
"name": {
|
|
934
|
+
"kind": "Name",
|
|
935
|
+
"value": "parentMessageId"
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
]
|
|
939
|
+
}
|
|
940
|
+
},
|
|
941
|
+
{
|
|
942
|
+
"kind": "InlineFragment",
|
|
943
|
+
"typeCondition": {
|
|
944
|
+
"kind": "NamedType",
|
|
945
|
+
"name": {
|
|
946
|
+
"kind": "Name",
|
|
947
|
+
"value": "ActionExecutionMessageOutput"
|
|
948
|
+
}
|
|
949
|
+
},
|
|
950
|
+
"selectionSet": {
|
|
951
|
+
"kind": "SelectionSet",
|
|
952
|
+
"selections": [
|
|
953
|
+
{
|
|
954
|
+
"kind": "Field",
|
|
955
|
+
"name": {
|
|
956
|
+
"kind": "Name",
|
|
957
|
+
"value": "name"
|
|
958
|
+
}
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
"kind": "Field",
|
|
962
|
+
"name": {
|
|
963
|
+
"kind": "Name",
|
|
964
|
+
"value": "arguments"
|
|
965
|
+
}
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
"kind": "Field",
|
|
969
|
+
"name": {
|
|
970
|
+
"kind": "Name",
|
|
971
|
+
"value": "parentMessageId"
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
]
|
|
975
|
+
}
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
"kind": "InlineFragment",
|
|
979
|
+
"typeCondition": {
|
|
980
|
+
"kind": "NamedType",
|
|
981
|
+
"name": {
|
|
982
|
+
"kind": "Name",
|
|
983
|
+
"value": "ResultMessageOutput"
|
|
984
|
+
}
|
|
985
|
+
},
|
|
986
|
+
"selectionSet": {
|
|
987
|
+
"kind": "SelectionSet",
|
|
988
|
+
"selections": [
|
|
989
|
+
{
|
|
990
|
+
"kind": "Field",
|
|
991
|
+
"name": {
|
|
992
|
+
"kind": "Name",
|
|
993
|
+
"value": "result"
|
|
994
|
+
}
|
|
995
|
+
},
|
|
996
|
+
{
|
|
997
|
+
"kind": "Field",
|
|
998
|
+
"name": {
|
|
999
|
+
"kind": "Name",
|
|
1000
|
+
"value": "actionExecutionId"
|
|
1001
|
+
}
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
"kind": "Field",
|
|
1005
|
+
"name": {
|
|
1006
|
+
"kind": "Name",
|
|
1007
|
+
"value": "actionName"
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
]
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
]
|
|
1014
|
+
}
|
|
1015
|
+
}, {
|
|
1016
|
+
"kind": "Field",
|
|
1017
|
+
"name": {
|
|
1018
|
+
"kind": "Name",
|
|
1019
|
+
"value": "value"
|
|
1020
|
+
}
|
|
1021
|
+
}]
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
]
|
|
1025
|
+
}
|
|
1026
|
+
}]
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
]
|
|
1030
|
+
}
|
|
1031
|
+
}]
|
|
1032
|
+
}
|
|
1033
|
+
}]
|
|
1034
|
+
};
|
|
1035
|
+
const AvailableAgentsDocument = {
|
|
1036
|
+
"kind": "Document",
|
|
1037
|
+
"definitions": [{
|
|
1038
|
+
"kind": "OperationDefinition",
|
|
1039
|
+
"operation": "query",
|
|
1040
|
+
"name": {
|
|
1041
|
+
"kind": "Name",
|
|
1042
|
+
"value": "availableAgents"
|
|
1043
|
+
},
|
|
1044
|
+
"selectionSet": {
|
|
1045
|
+
"kind": "SelectionSet",
|
|
1046
|
+
"selections": [{
|
|
1047
|
+
"kind": "Field",
|
|
1048
|
+
"name": {
|
|
1049
|
+
"kind": "Name",
|
|
1050
|
+
"value": "availableAgents"
|
|
1051
|
+
},
|
|
1052
|
+
"selectionSet": {
|
|
1053
|
+
"kind": "SelectionSet",
|
|
1054
|
+
"selections": [{
|
|
1055
|
+
"kind": "Field",
|
|
1056
|
+
"name": {
|
|
1057
|
+
"kind": "Name",
|
|
1058
|
+
"value": "agents"
|
|
1059
|
+
},
|
|
1060
|
+
"selectionSet": {
|
|
1061
|
+
"kind": "SelectionSet",
|
|
1062
|
+
"selections": [
|
|
1063
|
+
{
|
|
1064
|
+
"kind": "Field",
|
|
1065
|
+
"name": {
|
|
1066
|
+
"kind": "Name",
|
|
1067
|
+
"value": "name"
|
|
1068
|
+
}
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
"kind": "Field",
|
|
1072
|
+
"name": {
|
|
1073
|
+
"kind": "Name",
|
|
1074
|
+
"value": "id"
|
|
1075
|
+
}
|
|
1076
|
+
},
|
|
1077
|
+
{
|
|
1078
|
+
"kind": "Field",
|
|
1079
|
+
"name": {
|
|
1080
|
+
"kind": "Name",
|
|
1081
|
+
"value": "description"
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
]
|
|
1085
|
+
}
|
|
1086
|
+
}]
|
|
1087
|
+
}
|
|
1088
|
+
}]
|
|
1089
|
+
}
|
|
1090
|
+
}]
|
|
1091
|
+
};
|
|
1092
|
+
const LoadAgentStateDocument = {
|
|
1093
|
+
"kind": "Document",
|
|
1094
|
+
"definitions": [{
|
|
1095
|
+
"kind": "OperationDefinition",
|
|
1096
|
+
"operation": "query",
|
|
1097
|
+
"name": {
|
|
1098
|
+
"kind": "Name",
|
|
1099
|
+
"value": "loadAgentState"
|
|
1100
|
+
},
|
|
1101
|
+
"variableDefinitions": [{
|
|
1102
|
+
"kind": "VariableDefinition",
|
|
1103
|
+
"variable": {
|
|
1104
|
+
"kind": "Variable",
|
|
1105
|
+
"name": {
|
|
1106
|
+
"kind": "Name",
|
|
1107
|
+
"value": "data"
|
|
1108
|
+
}
|
|
1109
|
+
},
|
|
1110
|
+
"type": {
|
|
1111
|
+
"kind": "NonNullType",
|
|
1112
|
+
"type": {
|
|
1113
|
+
"kind": "NamedType",
|
|
1114
|
+
"name": {
|
|
1115
|
+
"kind": "Name",
|
|
1116
|
+
"value": "LoadAgentStateInput"
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
}],
|
|
1121
|
+
"selectionSet": {
|
|
1122
|
+
"kind": "SelectionSet",
|
|
1123
|
+
"selections": [{
|
|
1124
|
+
"kind": "Field",
|
|
1125
|
+
"name": {
|
|
1126
|
+
"kind": "Name",
|
|
1127
|
+
"value": "loadAgentState"
|
|
1128
|
+
},
|
|
1129
|
+
"arguments": [{
|
|
1130
|
+
"kind": "Argument",
|
|
1131
|
+
"name": {
|
|
1132
|
+
"kind": "Name",
|
|
1133
|
+
"value": "data"
|
|
1134
|
+
},
|
|
1135
|
+
"value": {
|
|
1136
|
+
"kind": "Variable",
|
|
1137
|
+
"name": {
|
|
1138
|
+
"kind": "Name",
|
|
1139
|
+
"value": "data"
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
}],
|
|
1143
|
+
"selectionSet": {
|
|
1144
|
+
"kind": "SelectionSet",
|
|
1145
|
+
"selections": [
|
|
1146
|
+
{
|
|
1147
|
+
"kind": "Field",
|
|
1148
|
+
"name": {
|
|
1149
|
+
"kind": "Name",
|
|
1150
|
+
"value": "threadId"
|
|
1151
|
+
}
|
|
1152
|
+
},
|
|
1153
|
+
{
|
|
1154
|
+
"kind": "Field",
|
|
1155
|
+
"name": {
|
|
1156
|
+
"kind": "Name",
|
|
1157
|
+
"value": "threadExists"
|
|
1158
|
+
}
|
|
1159
|
+
},
|
|
1160
|
+
{
|
|
1161
|
+
"kind": "Field",
|
|
1162
|
+
"name": {
|
|
1163
|
+
"kind": "Name",
|
|
1164
|
+
"value": "state"
|
|
1165
|
+
}
|
|
1166
|
+
},
|
|
1167
|
+
{
|
|
1168
|
+
"kind": "Field",
|
|
1169
|
+
"name": {
|
|
1170
|
+
"kind": "Name",
|
|
1171
|
+
"value": "messages"
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
]
|
|
1175
|
+
}
|
|
1176
|
+
}]
|
|
1177
|
+
}
|
|
1178
|
+
}]
|
|
1179
|
+
};
|
|
1180
|
+
|
|
1181
|
+
//#endregion
|
|
1182
|
+
//#region src/graphql/@generated/gql.ts
|
|
1183
|
+
const documents = {
|
|
1184
|
+
"\n mutation generateCopilotResponse(\n $data: GenerateCopilotResponseInput!\n $properties: JSONObject\n ) {\n generateCopilotResponse(data: $data, properties: $properties) {\n threadId\n runId\n extensions {\n openaiAssistantAPI {\n runId\n threadId\n }\n }\n ... on CopilotResponse @defer {\n status {\n ... on BaseResponseStatus {\n code\n }\n ... on FailedResponseStatus {\n reason\n details\n }\n }\n }\n messages @stream {\n __typename\n ... on BaseMessageOutput {\n id\n createdAt\n }\n ... on BaseMessageOutput @defer {\n status {\n ... on SuccessMessageStatus {\n code\n }\n ... on FailedMessageStatus {\n code\n reason\n }\n ... on PendingMessageStatus {\n code\n }\n }\n }\n ... on TextMessageOutput {\n content @stream\n role\n parentMessageId\n }\n ... on ImageMessageOutput {\n format\n bytes\n role\n parentMessageId\n }\n ... on ActionExecutionMessageOutput {\n name\n arguments @stream\n parentMessageId\n }\n ... on ResultMessageOutput {\n result\n actionExecutionId\n actionName\n }\n ... on AgentStateMessageOutput {\n threadId\n state\n running\n agentName\n nodeName\n runId\n active\n role\n }\n }\n metaEvents @stream {\n ... on LangGraphInterruptEvent {\n type\n name\n value\n }\n\n ... on CopilotKitLangGraphInterruptEvent {\n type\n name\n data {\n messages {\n __typename\n ... on BaseMessageOutput {\n id\n createdAt\n }\n ... on BaseMessageOutput @defer {\n status {\n ... on SuccessMessageStatus {\n code\n }\n ... on FailedMessageStatus {\n code\n reason\n }\n ... on PendingMessageStatus {\n code\n }\n }\n }\n ... on TextMessageOutput {\n content\n role\n parentMessageId\n }\n ... on ActionExecutionMessageOutput {\n name\n arguments\n parentMessageId\n }\n ... on ResultMessageOutput {\n result\n actionExecutionId\n actionName\n }\n }\n value\n }\n }\n }\n }\n }\n": GenerateCopilotResponseDocument,
|
|
1185
|
+
"\n query availableAgents {\n availableAgents {\n agents {\n name\n id\n description\n }\n }\n }\n": AvailableAgentsDocument,
|
|
1186
|
+
"\n query loadAgentState($data: LoadAgentStateInput!) {\n loadAgentState(data: $data) {\n threadId\n threadExists\n state\n messages\n }\n }\n": LoadAgentStateDocument
|
|
1187
|
+
};
|
|
1188
|
+
function graphql(source) {
|
|
1189
|
+
var _source;
|
|
1190
|
+
return (_source = documents[source]) !== null && _source !== void 0 ? _source : {};
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
//#endregion
|
|
1194
|
+
//#region src/graphql/definitions/mutations.ts
|
|
1195
|
+
const generateCopilotResponseMutation = graphql(
|
|
1196
|
+
/** GraphQL **/
|
|
1197
|
+
`
|
|
1198
|
+
mutation generateCopilotResponse(
|
|
1199
|
+
$data: GenerateCopilotResponseInput!
|
|
1200
|
+
$properties: JSONObject
|
|
1201
|
+
) {
|
|
1202
|
+
generateCopilotResponse(data: $data, properties: $properties) {
|
|
1203
|
+
threadId
|
|
1204
|
+
runId
|
|
1205
|
+
extensions {
|
|
1206
|
+
openaiAssistantAPI {
|
|
1207
|
+
runId
|
|
1208
|
+
threadId
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
... on CopilotResponse @defer {
|
|
1212
|
+
status {
|
|
1213
|
+
... on BaseResponseStatus {
|
|
1214
|
+
code
|
|
1215
|
+
}
|
|
1216
|
+
... on FailedResponseStatus {
|
|
1217
|
+
reason
|
|
1218
|
+
details
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
messages @stream {
|
|
1223
|
+
__typename
|
|
1224
|
+
... on BaseMessageOutput {
|
|
1225
|
+
id
|
|
1226
|
+
createdAt
|
|
1227
|
+
}
|
|
1228
|
+
... on BaseMessageOutput @defer {
|
|
1229
|
+
status {
|
|
1230
|
+
... on SuccessMessageStatus {
|
|
1231
|
+
code
|
|
1232
|
+
}
|
|
1233
|
+
... on FailedMessageStatus {
|
|
1234
|
+
code
|
|
1235
|
+
reason
|
|
1236
|
+
}
|
|
1237
|
+
... on PendingMessageStatus {
|
|
1238
|
+
code
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
... on TextMessageOutput {
|
|
1243
|
+
content @stream
|
|
1244
|
+
role
|
|
1245
|
+
parentMessageId
|
|
1246
|
+
}
|
|
1247
|
+
... on ImageMessageOutput {
|
|
1248
|
+
format
|
|
1249
|
+
bytes
|
|
1250
|
+
role
|
|
1251
|
+
parentMessageId
|
|
1252
|
+
}
|
|
1253
|
+
... on ActionExecutionMessageOutput {
|
|
1254
|
+
name
|
|
1255
|
+
arguments @stream
|
|
1256
|
+
parentMessageId
|
|
1257
|
+
}
|
|
1258
|
+
... on ResultMessageOutput {
|
|
1259
|
+
result
|
|
1260
|
+
actionExecutionId
|
|
1261
|
+
actionName
|
|
1262
|
+
}
|
|
1263
|
+
... on AgentStateMessageOutput {
|
|
1264
|
+
threadId
|
|
1265
|
+
state
|
|
1266
|
+
running
|
|
1267
|
+
agentName
|
|
1268
|
+
nodeName
|
|
1269
|
+
runId
|
|
1270
|
+
active
|
|
1271
|
+
role
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
metaEvents @stream {
|
|
1275
|
+
... on LangGraphInterruptEvent {
|
|
1276
|
+
type
|
|
1277
|
+
name
|
|
1278
|
+
value
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
... on CopilotKitLangGraphInterruptEvent {
|
|
1282
|
+
type
|
|
1283
|
+
name
|
|
1284
|
+
data {
|
|
1285
|
+
messages {
|
|
1286
|
+
__typename
|
|
1287
|
+
... on BaseMessageOutput {
|
|
1288
|
+
id
|
|
1289
|
+
createdAt
|
|
1290
|
+
}
|
|
1291
|
+
... on BaseMessageOutput @defer {
|
|
1292
|
+
status {
|
|
1293
|
+
... on SuccessMessageStatus {
|
|
1294
|
+
code
|
|
1295
|
+
}
|
|
1296
|
+
... on FailedMessageStatus {
|
|
1297
|
+
code
|
|
1298
|
+
reason
|
|
1299
|
+
}
|
|
1300
|
+
... on PendingMessageStatus {
|
|
1301
|
+
code
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
... on TextMessageOutput {
|
|
1306
|
+
content
|
|
1307
|
+
role
|
|
1308
|
+
parentMessageId
|
|
1309
|
+
}
|
|
1310
|
+
... on ActionExecutionMessageOutput {
|
|
1311
|
+
name
|
|
1312
|
+
arguments
|
|
1313
|
+
parentMessageId
|
|
1314
|
+
}
|
|
1315
|
+
... on ResultMessageOutput {
|
|
1316
|
+
result
|
|
1317
|
+
actionExecutionId
|
|
1318
|
+
actionName
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
value
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
`
|
|
1328
|
+
);
|
|
1329
|
+
|
|
1330
|
+
//#endregion
|
|
1331
|
+
//#region src/graphql/definitions/queries.ts
|
|
1332
|
+
const getAvailableAgentsQuery = graphql(
|
|
1333
|
+
/** GraphQL **/
|
|
1334
|
+
`
|
|
1335
|
+
query availableAgents {
|
|
1336
|
+
availableAgents {
|
|
1337
|
+
agents {
|
|
1338
|
+
name
|
|
1339
|
+
id
|
|
1340
|
+
description
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
`
|
|
1345
|
+
);
|
|
1346
|
+
const loadAgentStateQuery = graphql(
|
|
1347
|
+
/** GraphQL **/
|
|
1348
|
+
`
|
|
1349
|
+
query loadAgentState($data: LoadAgentStateInput!) {
|
|
1350
|
+
loadAgentState(data: $data) {
|
|
1351
|
+
threadId
|
|
1352
|
+
threadExists
|
|
1353
|
+
state
|
|
1354
|
+
messages
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
`
|
|
1358
|
+
);
|
|
1359
|
+
|
|
1360
|
+
//#endregion
|
|
1361
|
+
//#region src/client/CopilotRuntimeClient.ts
|
|
1362
|
+
const createFetchFn = (signal, handleGQLWarning) => async (...args) => {
|
|
1363
|
+
var _args$;
|
|
1364
|
+
const publicApiKey = (_args$ = args[1]) === null || _args$ === void 0 || (_args$ = _args$.headers) === null || _args$ === void 0 ? void 0 : _args$["x-copilotcloud-public-api-key"];
|
|
1365
|
+
try {
|
|
1366
|
+
var _args$2;
|
|
1367
|
+
const result = await fetch(args[0], {
|
|
1368
|
+
...(_args$2 = args[1]) !== null && _args$2 !== void 0 ? _args$2 : {},
|
|
1369
|
+
signal
|
|
1370
|
+
});
|
|
1371
|
+
const mismatch = publicApiKey ? null : await (0, _copilotkit_shared.getPossibleVersionMismatch)({
|
|
1372
|
+
runtimeVersion: result.headers.get("X-CopilotKit-Runtime-Version"),
|
|
1373
|
+
runtimeClientGqlVersion: version
|
|
1374
|
+
});
|
|
1375
|
+
if (result.status !== 200) {
|
|
1376
|
+
if (result.status >= 400 && result.status <= 500) {
|
|
1377
|
+
if (mismatch) throw new _copilotkit_shared.CopilotKitVersionMismatchError(mismatch);
|
|
1378
|
+
throw new _copilotkit_shared.ResolvedCopilotKitError({ status: result.status });
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
if (mismatch && handleGQLWarning) handleGQLWarning(mismatch.message);
|
|
1382
|
+
return result;
|
|
1383
|
+
} catch (error) {
|
|
1384
|
+
if (error.message.includes("BodyStreamBuffer was aborted") || error.message.includes("signal is aborted without reason")) throw error;
|
|
1385
|
+
if (error instanceof _copilotkit_shared.CopilotKitError) throw error;
|
|
1386
|
+
throw new _copilotkit_shared.CopilotKitLowLevelError({
|
|
1387
|
+
error,
|
|
1388
|
+
url: args[0]
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
1392
|
+
var CopilotRuntimeClient = class CopilotRuntimeClient {
|
|
1393
|
+
constructor(options) {
|
|
1394
|
+
const headers = {};
|
|
1395
|
+
this.handleGQLErrors = options.handleGQLErrors;
|
|
1396
|
+
this.handleGQLWarning = options.handleGQLWarning;
|
|
1397
|
+
if (options.headers) Object.assign(headers, options.headers);
|
|
1398
|
+
if (options.publicApiKey) headers["x-copilotcloud-public-api-key"] = options.publicApiKey;
|
|
1399
|
+
this.client = new _urql_core.Client({
|
|
1400
|
+
url: options.url,
|
|
1401
|
+
exchanges: [_urql_core.cacheExchange, _urql_core.fetchExchange],
|
|
1402
|
+
fetchOptions: {
|
|
1403
|
+
headers: {
|
|
1404
|
+
...headers,
|
|
1405
|
+
"X-CopilotKit-Runtime-Client-GQL-Version": version
|
|
1406
|
+
},
|
|
1407
|
+
...options.credentials ? { credentials: options.credentials } : {}
|
|
1408
|
+
}
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
generateCopilotResponse({ data, properties, signal }) {
|
|
1412
|
+
const fetchFn = createFetchFn(signal, this.handleGQLWarning);
|
|
1413
|
+
return this.client.mutation(generateCopilotResponseMutation, {
|
|
1414
|
+
data,
|
|
1415
|
+
properties
|
|
1416
|
+
}, { fetch: fetchFn });
|
|
1417
|
+
}
|
|
1418
|
+
asStream(source) {
|
|
1419
|
+
const handleGQLErrors = this.handleGQLErrors;
|
|
1420
|
+
return new ReadableStream({ start(controller) {
|
|
1421
|
+
source.subscribe(({ data, hasNext, error }) => {
|
|
1422
|
+
if (error) {
|
|
1423
|
+
var _extensions;
|
|
1424
|
+
if (error.message.includes("BodyStreamBuffer was aborted") || error.message.includes("signal is aborted without reason")) {
|
|
1425
|
+
if (!hasNext) controller.close();
|
|
1426
|
+
console.warn("Abort error suppressed");
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1429
|
+
if ((_extensions = error.extensions) === null || _extensions === void 0 ? void 0 : _extensions.visibility) {
|
|
1430
|
+
const syntheticError = {
|
|
1431
|
+
...error,
|
|
1432
|
+
graphQLErrors: [{
|
|
1433
|
+
message: error.message,
|
|
1434
|
+
extensions: error.extensions
|
|
1435
|
+
}]
|
|
1436
|
+
};
|
|
1437
|
+
if (handleGQLErrors) handleGQLErrors(syntheticError);
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
controller.error(error);
|
|
1441
|
+
if (handleGQLErrors) handleGQLErrors(error);
|
|
1442
|
+
} else {
|
|
1443
|
+
controller.enqueue(data);
|
|
1444
|
+
if (!hasNext) controller.close();
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
} });
|
|
1448
|
+
}
|
|
1449
|
+
availableAgents() {
|
|
1450
|
+
const fetchFn = createFetchFn();
|
|
1451
|
+
return this.client.query(getAvailableAgentsQuery, {}, { fetch: fetchFn });
|
|
1452
|
+
}
|
|
1453
|
+
loadAgentState(data) {
|
|
1454
|
+
const fetchFn = createFetchFn();
|
|
1455
|
+
const result = this.client.query(loadAgentStateQuery, { data }, { fetch: fetchFn });
|
|
1456
|
+
result.toPromise().then(({ error }) => {
|
|
1457
|
+
if (error && this.handleGQLErrors) this.handleGQLErrors(error);
|
|
1458
|
+
}).catch(() => {});
|
|
1459
|
+
return result;
|
|
1460
|
+
}
|
|
1461
|
+
static removeGraphQLTypename(data) {
|
|
1462
|
+
if (Array.isArray(data)) data.forEach((item) => CopilotRuntimeClient.removeGraphQLTypename(item));
|
|
1463
|
+
else if (typeof data === "object" && data !== null) {
|
|
1464
|
+
delete data.__typename;
|
|
1465
|
+
Object.keys(data).forEach((key) => {
|
|
1466
|
+
if (typeof data[key] === "object" && data[key] !== null) CopilotRuntimeClient.removeGraphQLTypename(data[key]);
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
return data;
|
|
1470
|
+
}
|
|
1471
|
+
};
|
|
1472
|
+
|
|
1473
|
+
//#endregion
|
|
1474
|
+
//#region src/client/types.ts
|
|
1475
|
+
var Message = class {
|
|
1476
|
+
constructor(props) {
|
|
1477
|
+
var _props$id, _props$status, _props$createdAt;
|
|
1478
|
+
(_props$id = props.id) !== null && _props$id !== void 0 || (props.id = (0, _copilotkit_shared.randomId)());
|
|
1479
|
+
(_props$status = props.status) !== null && _props$status !== void 0 || (props.status = { code: MessageStatusCode.Success });
|
|
1480
|
+
(_props$createdAt = props.createdAt) !== null && _props$createdAt !== void 0 || (props.createdAt = /* @__PURE__ */ new Date());
|
|
1481
|
+
Object.assign(this, props);
|
|
1482
|
+
}
|
|
1483
|
+
isTextMessage() {
|
|
1484
|
+
return this.type === "TextMessage";
|
|
1485
|
+
}
|
|
1486
|
+
isActionExecutionMessage() {
|
|
1487
|
+
return this.type === "ActionExecutionMessage";
|
|
1488
|
+
}
|
|
1489
|
+
isResultMessage() {
|
|
1490
|
+
return this.type === "ResultMessage";
|
|
1491
|
+
}
|
|
1492
|
+
isAgentStateMessage() {
|
|
1493
|
+
return this.type === "AgentStateMessage";
|
|
1494
|
+
}
|
|
1495
|
+
isImageMessage() {
|
|
1496
|
+
return this.type === "ImageMessage";
|
|
1497
|
+
}
|
|
1498
|
+
};
|
|
1499
|
+
const Role = MessageRole;
|
|
1500
|
+
var TextMessage = class extends Message {
|
|
1501
|
+
constructor(props) {
|
|
1502
|
+
super(props);
|
|
1503
|
+
this.type = "TextMessage";
|
|
1504
|
+
this.type = "TextMessage";
|
|
1505
|
+
}
|
|
1506
|
+
};
|
|
1507
|
+
var ActionExecutionMessage = class extends Message {
|
|
1508
|
+
constructor(props) {
|
|
1509
|
+
super(props);
|
|
1510
|
+
this.type = "ActionExecutionMessage";
|
|
1511
|
+
}
|
|
1512
|
+
};
|
|
1513
|
+
var ResultMessage = class extends Message {
|
|
1514
|
+
constructor(props) {
|
|
1515
|
+
super(props);
|
|
1516
|
+
this.type = "ResultMessage";
|
|
1517
|
+
}
|
|
1518
|
+
static decodeResult(result) {
|
|
1519
|
+
return (0, _copilotkit_shared.parseJson)(result, result);
|
|
1520
|
+
}
|
|
1521
|
+
static encodeResult(result) {
|
|
1522
|
+
if (result === void 0) return "";
|
|
1523
|
+
else if (typeof result === "string") return result;
|
|
1524
|
+
else return JSON.stringify(result);
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
var AgentStateMessage = class extends Message {
|
|
1528
|
+
constructor(props) {
|
|
1529
|
+
super(props);
|
|
1530
|
+
this.type = "AgentStateMessage";
|
|
1531
|
+
}
|
|
1532
|
+
};
|
|
1533
|
+
var ImageMessage = class extends Message {
|
|
1534
|
+
constructor(props) {
|
|
1535
|
+
super(props);
|
|
1536
|
+
this.type = "ImageMessage";
|
|
1537
|
+
}
|
|
1538
|
+
};
|
|
1539
|
+
function langGraphInterruptEvent(eventProps) {
|
|
1540
|
+
return {
|
|
1541
|
+
...eventProps,
|
|
1542
|
+
name: MetaEventName.LangGraphInterruptEvent,
|
|
1543
|
+
type: "MetaEvent"
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
//#endregion
|
|
1548
|
+
//#region src/client/conversion.ts
|
|
1549
|
+
function filterAgentStateMessages(messages) {
|
|
1550
|
+
return messages.filter((message) => !message.isAgentStateMessage());
|
|
1551
|
+
}
|
|
1552
|
+
function convertMessagesToGqlInput(messages) {
|
|
1553
|
+
return messages.map((message) => {
|
|
1554
|
+
if (message.isTextMessage()) return {
|
|
1555
|
+
id: message.id,
|
|
1556
|
+
createdAt: message.createdAt,
|
|
1557
|
+
textMessage: {
|
|
1558
|
+
content: message.content,
|
|
1559
|
+
role: message.role,
|
|
1560
|
+
parentMessageId: message.parentMessageId
|
|
1561
|
+
}
|
|
1562
|
+
};
|
|
1563
|
+
else if (message.isActionExecutionMessage()) return {
|
|
1564
|
+
id: message.id,
|
|
1565
|
+
createdAt: message.createdAt,
|
|
1566
|
+
actionExecutionMessage: {
|
|
1567
|
+
name: message.name,
|
|
1568
|
+
arguments: JSON.stringify(message.arguments),
|
|
1569
|
+
parentMessageId: message.parentMessageId
|
|
1570
|
+
}
|
|
1571
|
+
};
|
|
1572
|
+
else if (message.isResultMessage()) return {
|
|
1573
|
+
id: message.id,
|
|
1574
|
+
createdAt: message.createdAt,
|
|
1575
|
+
resultMessage: {
|
|
1576
|
+
result: message.result,
|
|
1577
|
+
actionExecutionId: message.actionExecutionId,
|
|
1578
|
+
actionName: message.actionName
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
else if (message.isAgentStateMessage()) return {
|
|
1582
|
+
id: message.id,
|
|
1583
|
+
createdAt: message.createdAt,
|
|
1584
|
+
agentStateMessage: {
|
|
1585
|
+
threadId: message.threadId,
|
|
1586
|
+
role: message.role,
|
|
1587
|
+
agentName: message.agentName,
|
|
1588
|
+
nodeName: message.nodeName,
|
|
1589
|
+
runId: message.runId,
|
|
1590
|
+
active: message.active,
|
|
1591
|
+
running: message.running,
|
|
1592
|
+
state: JSON.stringify(message.state)
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1595
|
+
else if (message.isImageMessage()) return {
|
|
1596
|
+
id: message.id,
|
|
1597
|
+
createdAt: message.createdAt,
|
|
1598
|
+
imageMessage: {
|
|
1599
|
+
format: message.format,
|
|
1600
|
+
bytes: message.bytes,
|
|
1601
|
+
role: message.role,
|
|
1602
|
+
parentMessageId: message.parentMessageId
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1605
|
+
else throw new Error("Unknown message type");
|
|
1606
|
+
});
|
|
1607
|
+
}
|
|
1608
|
+
function filterAdjacentAgentStateMessages(messages) {
|
|
1609
|
+
const filteredMessages = [];
|
|
1610
|
+
messages.forEach((message, i) => {
|
|
1611
|
+
if (message.__typename !== "AgentStateMessageOutput") filteredMessages.push(message);
|
|
1612
|
+
else {
|
|
1613
|
+
const prevAgentStateMessageIndex = filteredMessages.findIndex((m) => m.__typename === "AgentStateMessageOutput" && m.agentName === message.agentName);
|
|
1614
|
+
if (prevAgentStateMessageIndex === -1) filteredMessages.push(message);
|
|
1615
|
+
else filteredMessages[prevAgentStateMessageIndex] = message;
|
|
1616
|
+
}
|
|
1617
|
+
});
|
|
1618
|
+
return filteredMessages;
|
|
1619
|
+
}
|
|
1620
|
+
function convertGqlOutputToMessages(messages) {
|
|
1621
|
+
return messages.map((message) => {
|
|
1622
|
+
if (message.__typename === "TextMessageOutput") return new TextMessage({
|
|
1623
|
+
id: message.id,
|
|
1624
|
+
role: message.role,
|
|
1625
|
+
content: message.content.join(""),
|
|
1626
|
+
parentMessageId: message.parentMessageId,
|
|
1627
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1628
|
+
status: message.status || { code: MessageStatusCode.Pending }
|
|
1629
|
+
});
|
|
1630
|
+
else if (message.__typename === "ActionExecutionMessageOutput") return new ActionExecutionMessage({
|
|
1631
|
+
id: message.id,
|
|
1632
|
+
name: message.name,
|
|
1633
|
+
arguments: getPartialArguments(message.arguments),
|
|
1634
|
+
parentMessageId: message.parentMessageId,
|
|
1635
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1636
|
+
status: message.status || { code: MessageStatusCode.Pending }
|
|
1637
|
+
});
|
|
1638
|
+
else if (message.__typename === "ResultMessageOutput") return new ResultMessage({
|
|
1639
|
+
id: message.id,
|
|
1640
|
+
result: message.result,
|
|
1641
|
+
actionExecutionId: message.actionExecutionId,
|
|
1642
|
+
actionName: message.actionName,
|
|
1643
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1644
|
+
status: message.status || { code: MessageStatusCode.Pending }
|
|
1645
|
+
});
|
|
1646
|
+
else if (message.__typename === "AgentStateMessageOutput") return new AgentStateMessage({
|
|
1647
|
+
id: message.id,
|
|
1648
|
+
threadId: message.threadId,
|
|
1649
|
+
role: message.role,
|
|
1650
|
+
agentName: message.agentName,
|
|
1651
|
+
nodeName: message.nodeName,
|
|
1652
|
+
runId: message.runId,
|
|
1653
|
+
active: message.active,
|
|
1654
|
+
running: message.running,
|
|
1655
|
+
state: (0, _copilotkit_shared.parseJson)(message.state, {}),
|
|
1656
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
1657
|
+
});
|
|
1658
|
+
else if (message.__typename === "ImageMessageOutput") return new ImageMessage({
|
|
1659
|
+
id: message.id,
|
|
1660
|
+
format: message.format,
|
|
1661
|
+
bytes: message.bytes,
|
|
1662
|
+
role: message.role,
|
|
1663
|
+
parentMessageId: message.parentMessageId,
|
|
1664
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1665
|
+
status: message.status || { code: MessageStatusCode.Pending }
|
|
1666
|
+
});
|
|
1667
|
+
throw new Error("Unknown message type");
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
function loadMessagesFromJsonRepresentation(json) {
|
|
1671
|
+
const result = [];
|
|
1672
|
+
for (const item of json) if ("content" in item) result.push(new TextMessage({
|
|
1673
|
+
id: item.id,
|
|
1674
|
+
role: item.role,
|
|
1675
|
+
content: item.content,
|
|
1676
|
+
parentMessageId: item.parentMessageId,
|
|
1677
|
+
createdAt: item.createdAt || /* @__PURE__ */ new Date(),
|
|
1678
|
+
status: item.status || { code: MessageStatusCode.Success }
|
|
1679
|
+
}));
|
|
1680
|
+
else if ("arguments" in item) result.push(new ActionExecutionMessage({
|
|
1681
|
+
id: item.id,
|
|
1682
|
+
name: item.name,
|
|
1683
|
+
arguments: item.arguments,
|
|
1684
|
+
parentMessageId: item.parentMessageId,
|
|
1685
|
+
createdAt: item.createdAt || /* @__PURE__ */ new Date(),
|
|
1686
|
+
status: item.status || { code: MessageStatusCode.Success }
|
|
1687
|
+
}));
|
|
1688
|
+
else if ("result" in item) result.push(new ResultMessage({
|
|
1689
|
+
id: item.id,
|
|
1690
|
+
result: item.result,
|
|
1691
|
+
actionExecutionId: item.actionExecutionId,
|
|
1692
|
+
actionName: item.actionName,
|
|
1693
|
+
createdAt: item.createdAt || /* @__PURE__ */ new Date(),
|
|
1694
|
+
status: item.status || { code: MessageStatusCode.Success }
|
|
1695
|
+
}));
|
|
1696
|
+
else if ("state" in item) result.push(new AgentStateMessage({
|
|
1697
|
+
id: item.id,
|
|
1698
|
+
threadId: item.threadId,
|
|
1699
|
+
role: item.role,
|
|
1700
|
+
agentName: item.agentName,
|
|
1701
|
+
nodeName: item.nodeName,
|
|
1702
|
+
runId: item.runId,
|
|
1703
|
+
active: item.active,
|
|
1704
|
+
running: item.running,
|
|
1705
|
+
state: item.state,
|
|
1706
|
+
createdAt: item.createdAt || /* @__PURE__ */ new Date()
|
|
1707
|
+
}));
|
|
1708
|
+
else if ("format" in item && "bytes" in item) result.push(new ImageMessage({
|
|
1709
|
+
id: item.id,
|
|
1710
|
+
format: item.format,
|
|
1711
|
+
bytes: item.bytes,
|
|
1712
|
+
role: item.role,
|
|
1713
|
+
parentMessageId: item.parentMessageId,
|
|
1714
|
+
createdAt: item.createdAt || /* @__PURE__ */ new Date(),
|
|
1715
|
+
status: item.status || { code: MessageStatusCode.Success }
|
|
1716
|
+
}));
|
|
1717
|
+
return result;
|
|
1718
|
+
}
|
|
1719
|
+
function getPartialArguments(args) {
|
|
1720
|
+
try {
|
|
1721
|
+
if (!args.length) return {};
|
|
1722
|
+
return JSON.parse((0, untruncate_json.default)(args.join("")));
|
|
1723
|
+
} catch (e) {
|
|
1724
|
+
return {};
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
//#endregion
|
|
1729
|
+
//#region src/message-conversion/agui-to-gql.ts
|
|
1730
|
+
function extractAgentName(message) {
|
|
1731
|
+
if (message.role !== "assistant") throw new Error(`Cannot extract agent name from message with role ${message.role}`);
|
|
1732
|
+
return message.agentName || "unknown";
|
|
1733
|
+
}
|
|
1734
|
+
function isAgentStateMessage(message) {
|
|
1735
|
+
return message.role === "assistant" && "agentName" in message && "state" in message;
|
|
1736
|
+
}
|
|
1737
|
+
function hasImageProperty(message) {
|
|
1738
|
+
if (!(message.role === "assistant" || message.role === "user") || message.image === void 0) return false;
|
|
1739
|
+
if (message.image.format === void 0 || message.image.bytes === void 0) return false;
|
|
1740
|
+
return true;
|
|
1741
|
+
}
|
|
1742
|
+
function aguiToGQL(messages, actions, coAgentStateRenders) {
|
|
1743
|
+
const gqlMessages = [];
|
|
1744
|
+
messages = Array.isArray(messages) ? messages : [messages];
|
|
1745
|
+
const toolCallNames = {};
|
|
1746
|
+
for (const message of messages) {
|
|
1747
|
+
if (isAgentStateMessage(message)) {
|
|
1748
|
+
const agentName = extractAgentName(message);
|
|
1749
|
+
const state = "state" in message && message.state ? message.state : {};
|
|
1750
|
+
gqlMessages.push(new AgentStateMessage({
|
|
1751
|
+
id: message.id,
|
|
1752
|
+
agentName,
|
|
1753
|
+
state,
|
|
1754
|
+
role: Role.Assistant
|
|
1755
|
+
}));
|
|
1756
|
+
if ("generativeUI" in message && message.generativeUI && coAgentStateRenders) coAgentStateRenders[agentName] = {
|
|
1757
|
+
name: agentName,
|
|
1758
|
+
render: message.generativeUI
|
|
1759
|
+
};
|
|
1760
|
+
continue;
|
|
1761
|
+
}
|
|
1762
|
+
if (hasImageProperty(message)) {
|
|
1763
|
+
gqlMessages.push(aguiMessageWithImageToGQLMessage(message));
|
|
1764
|
+
continue;
|
|
1765
|
+
}
|
|
1766
|
+
if (message.role === "assistant" && message.toolCalls) {
|
|
1767
|
+
gqlMessages.push(aguiTextMessageToGQLMessage(message));
|
|
1768
|
+
for (const toolCall of message.toolCalls) {
|
|
1769
|
+
toolCallNames[toolCall.id] = toolCall.function.name;
|
|
1770
|
+
const actionExecMsg = aguiToolCallToGQLActionExecution(toolCall, message.id);
|
|
1771
|
+
if ("generativeUI" in message && message.generativeUI && actions) {
|
|
1772
|
+
const actionName = toolCall.function.name;
|
|
1773
|
+
const specificAction = Object.values(actions).find((action) => action.name === actionName);
|
|
1774
|
+
const wildcardAction = Object.values(actions).find((action) => action.name === "*");
|
|
1775
|
+
if (specificAction) specificAction.render = message.generativeUI;
|
|
1776
|
+
else if (wildcardAction) wildcardAction.render = message.generativeUI;
|
|
1777
|
+
}
|
|
1778
|
+
gqlMessages.push(actionExecMsg);
|
|
1779
|
+
}
|
|
1780
|
+
continue;
|
|
1781
|
+
}
|
|
1782
|
+
if (message.role === "reasoning") continue;
|
|
1783
|
+
if (message.role === "developer" || message.role === "system" || message.role === "assistant" || message.role === "user") {
|
|
1784
|
+
gqlMessages.push(aguiTextMessageToGQLMessage(message));
|
|
1785
|
+
continue;
|
|
1786
|
+
}
|
|
1787
|
+
if (message.role === "tool") {
|
|
1788
|
+
gqlMessages.push(aguiToolMessageToGQLResultMessage(message, toolCallNames));
|
|
1789
|
+
continue;
|
|
1790
|
+
}
|
|
1791
|
+
throw new Error(`Unknown message role: "${message.role}" in message with id: ${message.id}`);
|
|
1792
|
+
}
|
|
1793
|
+
return gqlMessages;
|
|
1794
|
+
}
|
|
1795
|
+
function aguiTextMessageToGQLMessage(message) {
|
|
1796
|
+
if (message.role !== "developer" && message.role !== "system" && message.role !== "assistant" && message.role !== "user") throw new Error(`Cannot convert message with role ${message.role} to TextMessage`);
|
|
1797
|
+
let roleValue;
|
|
1798
|
+
if (message.role === "developer") roleValue = Role.Developer;
|
|
1799
|
+
else if (message.role === "system") roleValue = Role.System;
|
|
1800
|
+
else if (message.role === "assistant") roleValue = Role.Assistant;
|
|
1801
|
+
else roleValue = Role.User;
|
|
1802
|
+
return new TextMessage({
|
|
1803
|
+
id: message.id,
|
|
1804
|
+
content: message.content || "",
|
|
1805
|
+
role: roleValue
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
function aguiToolCallToGQLActionExecution(toolCall, parentMessageId) {
|
|
1809
|
+
if (toolCall.type !== "function") throw new Error(`Unsupported tool call type: ${toolCall.type}`);
|
|
1810
|
+
let argumentsObj;
|
|
1811
|
+
if (typeof toolCall.function.arguments === "string") try {
|
|
1812
|
+
argumentsObj = JSON.parse(toolCall.function.arguments);
|
|
1813
|
+
} catch (error) {
|
|
1814
|
+
console.warn(`Failed to parse tool call arguments for ${toolCall.function.name}:`, error);
|
|
1815
|
+
argumentsObj = {};
|
|
1816
|
+
}
|
|
1817
|
+
else if (typeof toolCall.function.arguments === "object" && toolCall.function.arguments !== null) argumentsObj = toolCall.function.arguments;
|
|
1818
|
+
else {
|
|
1819
|
+
console.warn(`Invalid tool call arguments type for ${toolCall.function.name}:`, typeof toolCall.function.arguments);
|
|
1820
|
+
argumentsObj = {};
|
|
1821
|
+
}
|
|
1822
|
+
return new ActionExecutionMessage({
|
|
1823
|
+
id: toolCall.id,
|
|
1824
|
+
name: toolCall.function.name,
|
|
1825
|
+
arguments: argumentsObj,
|
|
1826
|
+
parentMessageId
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
function aguiToolMessageToGQLResultMessage(message, toolCallNames) {
|
|
1830
|
+
if (message.role !== "tool") throw new Error(`Cannot convert message with role ${message.role} to ResultMessage`);
|
|
1831
|
+
if (!message.toolCallId) throw new Error("Tool message must have a toolCallId");
|
|
1832
|
+
const actionName = toolCallNames[message.toolCallId] || "unknown";
|
|
1833
|
+
let resultContent;
|
|
1834
|
+
const messageContent = message.content || "";
|
|
1835
|
+
if (typeof messageContent === "string") resultContent = messageContent;
|
|
1836
|
+
else if (typeof messageContent === "object" && messageContent !== null) try {
|
|
1837
|
+
resultContent = JSON.stringify(messageContent);
|
|
1838
|
+
} catch (error) {
|
|
1839
|
+
console.warn(`Failed to stringify tool result for ${actionName}:`, error);
|
|
1840
|
+
resultContent = String(messageContent);
|
|
1841
|
+
}
|
|
1842
|
+
else resultContent = String(messageContent);
|
|
1843
|
+
return new ResultMessage({
|
|
1844
|
+
id: message.id,
|
|
1845
|
+
result: resultContent,
|
|
1846
|
+
actionExecutionId: message.toolCallId,
|
|
1847
|
+
actionName: message.toolName || actionName
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
function aguiMessageWithRenderToGQL(message, actions, coAgentStateRenders) {
|
|
1851
|
+
if (message.role === "assistant" && "generativeUI" in message && message.generativeUI && !message.toolCalls) {
|
|
1852
|
+
const gqlMessages = [];
|
|
1853
|
+
gqlMessages.push(new AgentStateMessage({
|
|
1854
|
+
id: message.id,
|
|
1855
|
+
agentName: "unknown",
|
|
1856
|
+
state: {},
|
|
1857
|
+
role: Role.Assistant
|
|
1858
|
+
}));
|
|
1859
|
+
if (coAgentStateRenders) coAgentStateRenders.unknown = {
|
|
1860
|
+
name: "unknown",
|
|
1861
|
+
render: message.generativeUI
|
|
1862
|
+
};
|
|
1863
|
+
return gqlMessages;
|
|
1864
|
+
}
|
|
1865
|
+
return aguiToGQL([message], actions, coAgentStateRenders);
|
|
1866
|
+
}
|
|
1867
|
+
function aguiMessageWithImageToGQLMessage(message) {
|
|
1868
|
+
if (!hasImageProperty(message)) throw new Error(`Cannot convert message to ImageMessage: missing format or bytes`);
|
|
1869
|
+
let roleValue;
|
|
1870
|
+
if (message.role === "assistant") roleValue = Role.Assistant;
|
|
1871
|
+
else roleValue = Role.User;
|
|
1872
|
+
if (message.role !== "assistant" && message.role !== "user") throw new Error(`Cannot convert message with role ${message.role} to ImageMessage`);
|
|
1873
|
+
return new ImageMessage({
|
|
1874
|
+
id: message.id,
|
|
1875
|
+
format: message.image.format,
|
|
1876
|
+
bytes: message.image.bytes,
|
|
1877
|
+
role: roleValue
|
|
1878
|
+
});
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
//#endregion
|
|
1882
|
+
//#region src/message-conversion/gql-to-agui.ts
|
|
1883
|
+
const VALID_IMAGE_FORMATS = [
|
|
1884
|
+
"jpeg",
|
|
1885
|
+
"png",
|
|
1886
|
+
"webp",
|
|
1887
|
+
"gif"
|
|
1888
|
+
];
|
|
1889
|
+
function validateImageFormat(format) {
|
|
1890
|
+
return VALID_IMAGE_FORMATS.includes(format);
|
|
1891
|
+
}
|
|
1892
|
+
function gqlToAGUI(messages, actions, coAgentStateRenders) {
|
|
1893
|
+
let aguiMessages = [];
|
|
1894
|
+
messages = Array.isArray(messages) ? messages : [messages];
|
|
1895
|
+
const actionResults = /* @__PURE__ */ new Map();
|
|
1896
|
+
for (const message of messages) if (message.isResultMessage()) actionResults.set(message.actionExecutionId, message.result);
|
|
1897
|
+
for (const message of messages) if (message.isTextMessage()) aguiMessages.push(gqlTextMessageToAGUIMessage(message));
|
|
1898
|
+
else if (message.isResultMessage()) aguiMessages.push(gqlResultMessageToAGUIMessage(message));
|
|
1899
|
+
else if (message.isActionExecutionMessage()) aguiMessages.push(gqlActionExecutionMessageToAGUIMessage(message, actions, actionResults));
|
|
1900
|
+
else if (message.isAgentStateMessage()) aguiMessages.push(gqlAgentStateMessageToAGUIMessage(message, coAgentStateRenders));
|
|
1901
|
+
else if (message.isImageMessage()) aguiMessages.push(gqlImageMessageToAGUIMessage(message));
|
|
1902
|
+
else throw new Error("Unknown message type");
|
|
1903
|
+
return aguiMessages;
|
|
1904
|
+
}
|
|
1905
|
+
function gqlActionExecutionMessageToAGUIMessage(message, actions, actionResults) {
|
|
1906
|
+
const hasSpecificAction = actions && Object.values(actions).some((action) => action.name === message.name);
|
|
1907
|
+
const hasWildcardAction = actions && Object.values(actions).some((action) => action.name === "*");
|
|
1908
|
+
if (!actions || !hasSpecificAction && !hasWildcardAction) return {
|
|
1909
|
+
id: message.id,
|
|
1910
|
+
role: "assistant",
|
|
1911
|
+
toolCalls: [actionExecutionMessageToAGUIMessage(message)],
|
|
1912
|
+
name: message.name
|
|
1913
|
+
};
|
|
1914
|
+
const action = Object.values(actions).find((action) => action.name === message.name) || Object.values(actions).find((action) => action.name === "*");
|
|
1915
|
+
const createRenderWrapper = (originalRender) => {
|
|
1916
|
+
if (!originalRender) return void 0;
|
|
1917
|
+
return (props) => {
|
|
1918
|
+
var _message$status;
|
|
1919
|
+
let actionResult = actionResults === null || actionResults === void 0 ? void 0 : actionResults.get(message.id);
|
|
1920
|
+
let status = "inProgress";
|
|
1921
|
+
if (actionResult !== void 0) status = "complete";
|
|
1922
|
+
else if (((_message$status = message.status) === null || _message$status === void 0 ? void 0 : _message$status.code) !== MessageStatusCode.Pending) status = "executing";
|
|
1923
|
+
if (typeof (props === null || props === void 0 ? void 0 : props.result) === "string") try {
|
|
1924
|
+
props.result = JSON.parse(props.result);
|
|
1925
|
+
} catch (e) {}
|
|
1926
|
+
if (typeof actionResult === "string") try {
|
|
1927
|
+
actionResult = JSON.parse(actionResult);
|
|
1928
|
+
} catch (e) {}
|
|
1929
|
+
const baseProps = {
|
|
1930
|
+
status: (props === null || props === void 0 ? void 0 : props.status) || status,
|
|
1931
|
+
args: message.arguments || {},
|
|
1932
|
+
result: (props === null || props === void 0 ? void 0 : props.result) || actionResult || void 0,
|
|
1933
|
+
messageId: message.id
|
|
1934
|
+
};
|
|
1935
|
+
if (action.name === "*") return originalRender({
|
|
1936
|
+
...baseProps,
|
|
1937
|
+
...props,
|
|
1938
|
+
name: message.name
|
|
1939
|
+
});
|
|
1940
|
+
else {
|
|
1941
|
+
var _props$respond;
|
|
1942
|
+
const respond = (_props$respond = props === null || props === void 0 ? void 0 : props.respond) !== null && _props$respond !== void 0 ? _props$respond : (() => {});
|
|
1943
|
+
return originalRender({
|
|
1944
|
+
...baseProps,
|
|
1945
|
+
...props,
|
|
1946
|
+
respond
|
|
1947
|
+
});
|
|
1948
|
+
}
|
|
1949
|
+
};
|
|
1950
|
+
};
|
|
1951
|
+
return {
|
|
1952
|
+
id: message.id,
|
|
1953
|
+
role: "assistant",
|
|
1954
|
+
content: "",
|
|
1955
|
+
toolCalls: [actionExecutionMessageToAGUIMessage(message)],
|
|
1956
|
+
generativeUI: createRenderWrapper(action.render),
|
|
1957
|
+
name: message.name
|
|
1958
|
+
};
|
|
1959
|
+
}
|
|
1960
|
+
function gqlAgentStateMessageToAGUIMessage(message, coAgentStateRenders) {
|
|
1961
|
+
if (coAgentStateRenders && Object.values(coAgentStateRenders).some((render) => render.name === message.agentName)) {
|
|
1962
|
+
const render = Object.values(coAgentStateRenders).find((render) => render.name === message.agentName);
|
|
1963
|
+
const createRenderWrapper = (originalRender) => {
|
|
1964
|
+
if (!originalRender) return void 0;
|
|
1965
|
+
return (props) => {
|
|
1966
|
+
return originalRender({ state: message.state });
|
|
1967
|
+
};
|
|
1968
|
+
};
|
|
1969
|
+
return {
|
|
1970
|
+
id: message.id,
|
|
1971
|
+
role: "assistant",
|
|
1972
|
+
generativeUI: createRenderWrapper(render.render),
|
|
1973
|
+
agentName: message.agentName,
|
|
1974
|
+
state: message.state
|
|
1975
|
+
};
|
|
1976
|
+
}
|
|
1977
|
+
return {
|
|
1978
|
+
id: message.id,
|
|
1979
|
+
role: "assistant",
|
|
1980
|
+
agentName: message.agentName,
|
|
1981
|
+
state: message.state
|
|
1982
|
+
};
|
|
1983
|
+
}
|
|
1984
|
+
function actionExecutionMessageToAGUIMessage(actionExecutionMessage) {
|
|
1985
|
+
return {
|
|
1986
|
+
id: actionExecutionMessage.id,
|
|
1987
|
+
function: {
|
|
1988
|
+
name: actionExecutionMessage.name,
|
|
1989
|
+
arguments: JSON.stringify(actionExecutionMessage.arguments)
|
|
1990
|
+
},
|
|
1991
|
+
type: "function"
|
|
1992
|
+
};
|
|
1993
|
+
}
|
|
1994
|
+
function gqlTextMessageToAGUIMessage(message) {
|
|
1995
|
+
switch (message.role) {
|
|
1996
|
+
case Role.Developer: return {
|
|
1997
|
+
id: message.id,
|
|
1998
|
+
role: "developer",
|
|
1999
|
+
content: message.content
|
|
2000
|
+
};
|
|
2001
|
+
case Role.System: return {
|
|
2002
|
+
id: message.id,
|
|
2003
|
+
role: "system",
|
|
2004
|
+
content: message.content
|
|
2005
|
+
};
|
|
2006
|
+
case Role.Assistant: return {
|
|
2007
|
+
id: message.id,
|
|
2008
|
+
role: "assistant",
|
|
2009
|
+
content: message.content
|
|
2010
|
+
};
|
|
2011
|
+
case Role.User: return {
|
|
2012
|
+
id: message.id,
|
|
2013
|
+
role: "user",
|
|
2014
|
+
content: message.content
|
|
2015
|
+
};
|
|
2016
|
+
default: throw new Error("Unknown message role");
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
function gqlResultMessageToAGUIMessage(message) {
|
|
2020
|
+
return {
|
|
2021
|
+
id: message.id,
|
|
2022
|
+
role: "tool",
|
|
2023
|
+
content: message.result,
|
|
2024
|
+
toolCallId: message.actionExecutionId,
|
|
2025
|
+
toolName: message.actionName
|
|
2026
|
+
};
|
|
2027
|
+
}
|
|
2028
|
+
function gqlImageMessageToAGUIMessage(message) {
|
|
2029
|
+
if (!validateImageFormat(message.format)) throw new Error(`Invalid image format: ${message.format}. Supported formats are: ${VALID_IMAGE_FORMATS.join(", ")}`);
|
|
2030
|
+
if (!message.bytes || typeof message.bytes !== "string" || message.bytes.trim() === "") throw new Error("Image bytes must be a non-empty string");
|
|
2031
|
+
const role = message.role === Role.Assistant ? "assistant" : "user";
|
|
2032
|
+
return {
|
|
2033
|
+
id: message.id,
|
|
2034
|
+
role,
|
|
2035
|
+
content: "",
|
|
2036
|
+
image: {
|
|
2037
|
+
format: message.format,
|
|
2038
|
+
bytes: message.bytes
|
|
2039
|
+
}
|
|
2040
|
+
};
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
//#endregion
|
|
2044
|
+
exports.ActionExecutionMessage = ActionExecutionMessage;
|
|
2045
|
+
exports.ActionInputAvailability = ActionInputAvailability;
|
|
2046
|
+
exports.AgentStateMessage = AgentStateMessage;
|
|
2047
|
+
exports.AvailableAgentsDocument = AvailableAgentsDocument;
|
|
2048
|
+
exports.CopilotRequestType = CopilotRequestType;
|
|
2049
|
+
exports.CopilotRuntimeClient = CopilotRuntimeClient;
|
|
2050
|
+
exports.FailedResponseStatusReason = FailedResponseStatusReason;
|
|
2051
|
+
exports.GenerateCopilotResponseDocument = GenerateCopilotResponseDocument;
|
|
2052
|
+
exports.ImageMessage = ImageMessage;
|
|
2053
|
+
exports.LoadAgentStateDocument = LoadAgentStateDocument;
|
|
2054
|
+
exports.Message = Message;
|
|
2055
|
+
exports.MessageRole = MessageRole;
|
|
2056
|
+
exports.MessageStatusCode = MessageStatusCode;
|
|
2057
|
+
exports.MetaEventName = MetaEventName;
|
|
2058
|
+
exports.ResponseStatusCode = ResponseStatusCode;
|
|
2059
|
+
exports.ResultMessage = ResultMessage;
|
|
2060
|
+
exports.Role = Role;
|
|
2061
|
+
exports.TextMessage = TextMessage;
|
|
2062
|
+
exports.aguiMessageWithImageToGQLMessage = aguiMessageWithImageToGQLMessage;
|
|
2063
|
+
exports.aguiMessageWithRenderToGQL = aguiMessageWithRenderToGQL;
|
|
2064
|
+
exports.aguiTextMessageToGQLMessage = aguiTextMessageToGQLMessage;
|
|
2065
|
+
exports.aguiToGQL = aguiToGQL;
|
|
2066
|
+
exports.aguiToolCallToGQLActionExecution = aguiToolCallToGQLActionExecution;
|
|
2067
|
+
exports.aguiToolMessageToGQLResultMessage = aguiToolMessageToGQLResultMessage;
|
|
2068
|
+
exports.convertGqlOutputToMessages = convertGqlOutputToMessages;
|
|
2069
|
+
exports.convertMessagesToGqlInput = convertMessagesToGqlInput;
|
|
2070
|
+
exports.filterAdjacentAgentStateMessages = filterAdjacentAgentStateMessages;
|
|
2071
|
+
exports.filterAgentStateMessages = filterAgentStateMessages;
|
|
2072
|
+
exports.gqlActionExecutionMessageToAGUIMessage = gqlActionExecutionMessageToAGUIMessage;
|
|
2073
|
+
exports.gqlImageMessageToAGUIMessage = gqlImageMessageToAGUIMessage;
|
|
2074
|
+
exports.gqlResultMessageToAGUIMessage = gqlResultMessageToAGUIMessage;
|
|
2075
|
+
exports.gqlTextMessageToAGUIMessage = gqlTextMessageToAGUIMessage;
|
|
2076
|
+
exports.gqlToAGUI = gqlToAGUI;
|
|
2077
|
+
exports.langGraphInterruptEvent = langGraphInterruptEvent;
|
|
2078
|
+
exports.loadMessagesFromJsonRepresentation = loadMessagesFromJsonRepresentation;
|
|
2079
|
+
});
|
|
2080
|
+
//# sourceMappingURL=index.umd.js.map
|