@copilotkit/runtime-client-gql 1.10.1-next.0 → 1.10.1-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{chunk-AES3X7TL.mjs → chunk-23JYINXK.mjs} +2 -2
  3. package/dist/{chunk-AES3X7TL.mjs.map → chunk-23JYINXK.mjs.map} +1 -1
  4. package/dist/{chunk-7OSRQ2O3.mjs → chunk-SCACOKQX.mjs} +30 -6
  5. package/dist/chunk-SCACOKQX.mjs.map +1 -0
  6. package/dist/{chunk-IGXWE4TX.mjs → chunk-ZYA32QXZ.mjs} +14 -2
  7. package/dist/chunk-ZYA32QXZ.mjs.map +1 -0
  8. package/dist/client/CopilotRuntimeClient.js +1 -1
  9. package/dist/client/CopilotRuntimeClient.js.map +1 -1
  10. package/dist/client/CopilotRuntimeClient.mjs +1 -1
  11. package/dist/client/index.js +1 -1
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/client/index.mjs +1 -1
  14. package/dist/index.js +43 -7
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +3 -3
  17. package/dist/message-conversion/agui-to-gql.js +29 -5
  18. package/dist/message-conversion/agui-to-gql.js.map +1 -1
  19. package/dist/message-conversion/agui-to-gql.mjs +2 -2
  20. package/dist/message-conversion/agui-to-gql.test.js +149 -5
  21. package/dist/message-conversion/agui-to-gql.test.js.map +1 -1
  22. package/dist/message-conversion/agui-to-gql.test.mjs +122 -2
  23. package/dist/message-conversion/agui-to-gql.test.mjs.map +1 -1
  24. package/dist/message-conversion/gql-to-agui.js +13 -1
  25. package/dist/message-conversion/gql-to-agui.js.map +1 -1
  26. package/dist/message-conversion/gql-to-agui.mjs +2 -2
  27. package/dist/message-conversion/gql-to-agui.test.js +127 -1
  28. package/dist/message-conversion/gql-to-agui.test.js.map +1 -1
  29. package/dist/message-conversion/gql-to-agui.test.mjs +116 -2
  30. package/dist/message-conversion/gql-to-agui.test.mjs.map +1 -1
  31. package/dist/message-conversion/index.js +42 -6
  32. package/dist/message-conversion/index.js.map +1 -1
  33. package/dist/message-conversion/index.mjs +3 -3
  34. package/dist/message-conversion/roundtrip-conversion.test.js +119 -6
  35. package/dist/message-conversion/roundtrip-conversion.test.js.map +1 -1
  36. package/dist/message-conversion/roundtrip-conversion.test.mjs +80 -3
  37. package/dist/message-conversion/roundtrip-conversion.test.mjs.map +1 -1
  38. package/package.json +3 -3
  39. package/src/message-conversion/agui-to-gql.test.ts +140 -0
  40. package/src/message-conversion/agui-to-gql.ts +45 -7
  41. package/src/message-conversion/gql-to-agui.test.ts +139 -0
  42. package/src/message-conversion/gql-to-agui.ts +19 -1
  43. package/src/message-conversion/roundtrip-conversion.test.ts +106 -0
  44. package/dist/chunk-7OSRQ2O3.mjs.map +0 -1
  45. package/dist/chunk-IGXWE4TX.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/message-conversion/index.ts","../../src/graphql/@generated/graphql.ts","../../src/client/types.ts","../../src/message-conversion/agui-to-gql.ts","../../src/message-conversion/gql-to-agui.ts"],"sourcesContent":["export * from \"./agui-to-gql\";\nexport * from \"./gql-to-agui\";\n","/* eslint-disable */\nimport type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';\nexport type Maybe<T> = T | null;\nexport type InputMaybe<T> = Maybe<T>;\nexport type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };\nexport type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };\nexport type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };\nexport type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };\nexport type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };\n/** All built-in and custom scalars, mapped to their actual values */\nexport type Scalars = {\n ID: { input: string; output: string; }\n String: { input: string; output: string; }\n Boolean: { input: boolean; output: boolean; }\n Int: { input: number; output: number; }\n Float: { input: number; output: number; }\n /** A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.This scalar is serialized to a string in ISO 8601 format and parsed from a string in ISO 8601 format. */\n DateTimeISO: { input: any; output: any; }\n /** The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). */\n JSON: { input: any; output: any; }\n /** The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). */\n JSONObject: { input: any; output: any; }\n};\n\nexport type ActionExecutionMessageInput = {\n arguments: Scalars['String']['input'];\n name: Scalars['String']['input'];\n parentMessageId?: InputMaybe<Scalars['String']['input']>;\n /** @deprecated This field will be removed in a future version */\n scope?: InputMaybe<Scalars['String']['input']>;\n};\n\nexport type ActionExecutionMessageOutput = BaseMessageOutput & {\n __typename?: 'ActionExecutionMessageOutput';\n arguments: Array<Scalars['String']['output']>;\n createdAt: Scalars['DateTimeISO']['output'];\n id: Scalars['String']['output'];\n name: Scalars['String']['output'];\n parentMessageId?: Maybe<Scalars['String']['output']>;\n /** @deprecated This field will be removed in a future version */\n scope?: Maybe<Scalars['String']['output']>;\n status: MessageStatus;\n};\n\nexport type ActionInput = {\n available?: InputMaybe<ActionInputAvailability>;\n description: Scalars['String']['input'];\n jsonSchema: Scalars['String']['input'];\n name: Scalars['String']['input'];\n};\n\n/** The availability of the frontend action */\nexport enum ActionInputAvailability {\n Disabled = 'disabled',\n Enabled = 'enabled',\n Remote = 'remote'\n}\n\nexport type Agent = {\n __typename?: 'Agent';\n description: Scalars['String']['output'];\n id: Scalars['String']['output'];\n name: Scalars['String']['output'];\n};\n\nexport type AgentSessionInput = {\n agentName: Scalars['String']['input'];\n nodeName?: InputMaybe<Scalars['String']['input']>;\n threadId?: InputMaybe<Scalars['String']['input']>;\n};\n\nexport type AgentStateInput = {\n agentName: Scalars['String']['input'];\n config?: InputMaybe<Scalars['String']['input']>;\n state: Scalars['String']['input'];\n};\n\nexport type AgentStateMessageInput = {\n active: Scalars['Boolean']['input'];\n agentName: Scalars['String']['input'];\n nodeName: Scalars['String']['input'];\n role: MessageRole;\n runId: Scalars['String']['input'];\n running: Scalars['Boolean']['input'];\n state: Scalars['String']['input'];\n threadId: Scalars['String']['input'];\n};\n\nexport type AgentStateMessageOutput = BaseMessageOutput & {\n __typename?: 'AgentStateMessageOutput';\n active: Scalars['Boolean']['output'];\n agentName: Scalars['String']['output'];\n createdAt: Scalars['DateTimeISO']['output'];\n id: Scalars['String']['output'];\n nodeName: Scalars['String']['output'];\n role: MessageRole;\n runId: Scalars['String']['output'];\n running: Scalars['Boolean']['output'];\n state: Scalars['String']['output'];\n status: MessageStatus;\n threadId: Scalars['String']['output'];\n};\n\nexport type AgentsResponse = {\n __typename?: 'AgentsResponse';\n agents: Array<Agent>;\n};\n\nexport type BaseMessageOutput = {\n createdAt: Scalars['DateTimeISO']['output'];\n id: Scalars['String']['output'];\n status: MessageStatus;\n};\n\nexport type BaseMetaEvent = {\n name: MetaEventName;\n type: Scalars['String']['output'];\n};\n\nexport type BaseResponseStatus = {\n code: ResponseStatusCode;\n};\n\nexport type CloudInput = {\n guardrails?: InputMaybe<GuardrailsInput>;\n};\n\nexport type CopilotKitLangGraphInterruptEvent = BaseMetaEvent & {\n __typename?: 'CopilotKitLangGraphInterruptEvent';\n data: CopilotKitLangGraphInterruptEventData;\n name: MetaEventName;\n response?: Maybe<Scalars['String']['output']>;\n type: Scalars['String']['output'];\n};\n\nexport type CopilotKitLangGraphInterruptEventData = {\n __typename?: 'CopilotKitLangGraphInterruptEventData';\n messages: Array<BaseMessageOutput>;\n value: Scalars['String']['output'];\n};\n\n/** The type of Copilot request */\nexport enum CopilotRequestType {\n Chat = 'Chat',\n Suggestion = 'Suggestion',\n Task = 'Task',\n TextareaCompletion = 'TextareaCompletion',\n TextareaPopover = 'TextareaPopover'\n}\n\nexport type CopilotResponse = {\n __typename?: 'CopilotResponse';\n extensions?: Maybe<ExtensionsResponse>;\n messages: Array<BaseMessageOutput>;\n metaEvents?: Maybe<Array<BaseMetaEvent>>;\n runId?: Maybe<Scalars['String']['output']>;\n status: ResponseStatus;\n threadId: Scalars['String']['output'];\n};\n\nexport type ExtensionsInput = {\n openaiAssistantAPI?: InputMaybe<OpenAiApiAssistantApiInput>;\n};\n\nexport type ExtensionsResponse = {\n __typename?: 'ExtensionsResponse';\n openaiAssistantAPI?: Maybe<OpenAiApiAssistantApiResponse>;\n};\n\nexport type FailedMessageStatus = {\n __typename?: 'FailedMessageStatus';\n code: MessageStatusCode;\n reason: Scalars['String']['output'];\n};\n\nexport type FailedResponseStatus = BaseResponseStatus & {\n __typename?: 'FailedResponseStatus';\n code: ResponseStatusCode;\n details?: Maybe<Scalars['JSON']['output']>;\n reason: FailedResponseStatusReason;\n};\n\nexport enum FailedResponseStatusReason {\n GuardrailsValidationFailed = 'GUARDRAILS_VALIDATION_FAILED',\n MessageStreamInterrupted = 'MESSAGE_STREAM_INTERRUPTED',\n UnknownError = 'UNKNOWN_ERROR'\n}\n\nexport type ForwardedParametersInput = {\n maxTokens?: InputMaybe<Scalars['Float']['input']>;\n model?: InputMaybe<Scalars['String']['input']>;\n stop?: InputMaybe<Array<Scalars['String']['input']>>;\n temperature?: InputMaybe<Scalars['Float']['input']>;\n toolChoice?: InputMaybe<Scalars['String']['input']>;\n toolChoiceFunctionName?: InputMaybe<Scalars['String']['input']>;\n};\n\nexport type FrontendInput = {\n actions: Array<ActionInput>;\n toDeprecate_fullContext?: InputMaybe<Scalars['String']['input']>;\n url?: InputMaybe<Scalars['String']['input']>;\n};\n\nexport type GenerateCopilotResponseInput = {\n agentSession?: InputMaybe<AgentSessionInput>;\n agentState?: InputMaybe<AgentStateInput>;\n agentStates?: InputMaybe<Array<AgentStateInput>>;\n cloud?: InputMaybe<CloudInput>;\n extensions?: InputMaybe<ExtensionsInput>;\n forwardedParameters?: InputMaybe<ForwardedParametersInput>;\n frontend: FrontendInput;\n messages: Array<MessageInput>;\n metaEvents?: InputMaybe<Array<MetaEventInput>>;\n metadata: GenerateCopilotResponseMetadataInput;\n runId?: InputMaybe<Scalars['String']['input']>;\n threadId?: InputMaybe<Scalars['String']['input']>;\n};\n\nexport type GenerateCopilotResponseMetadataInput = {\n requestType?: InputMaybe<CopilotRequestType>;\n};\n\nexport type GuardrailsInput = {\n inputValidationRules: GuardrailsRuleInput;\n};\n\nexport type GuardrailsRuleInput = {\n allowList?: InputMaybe<Array<Scalars['String']['input']>>;\n denyList?: InputMaybe<Array<Scalars['String']['input']>>;\n};\n\nexport type ImageMessageInput = {\n bytes: Scalars['String']['input'];\n format: Scalars['String']['input'];\n parentMessageId?: InputMaybe<Scalars['String']['input']>;\n role: MessageRole;\n};\n\nexport type ImageMessageOutput = BaseMessageOutput & {\n __typename?: 'ImageMessageOutput';\n bytes: Scalars['String']['output'];\n createdAt: Scalars['DateTimeISO']['output'];\n format: Scalars['String']['output'];\n id: Scalars['String']['output'];\n parentMessageId?: Maybe<Scalars['String']['output']>;\n role: MessageRole;\n status: MessageStatus;\n};\n\nexport type LangGraphInterruptEvent = BaseMetaEvent & {\n __typename?: 'LangGraphInterruptEvent';\n name: MetaEventName;\n response?: Maybe<Scalars['String']['output']>;\n type: Scalars['String']['output'];\n value: Scalars['String']['output'];\n};\n\nexport type LoadAgentStateInput = {\n agentName: Scalars['String']['input'];\n threadId: Scalars['String']['input'];\n};\n\nexport type LoadAgentStateResponse = {\n __typename?: 'LoadAgentStateResponse';\n messages: Scalars['String']['output'];\n state: Scalars['String']['output'];\n threadExists: Scalars['Boolean']['output'];\n threadId: Scalars['String']['output'];\n};\n\nexport type MessageInput = {\n actionExecutionMessage?: InputMaybe<ActionExecutionMessageInput>;\n agentStateMessage?: InputMaybe<AgentStateMessageInput>;\n createdAt: Scalars['DateTimeISO']['input'];\n id: Scalars['String']['input'];\n imageMessage?: InputMaybe<ImageMessageInput>;\n resultMessage?: InputMaybe<ResultMessageInput>;\n textMessage?: InputMaybe<TextMessageInput>;\n};\n\n/** The role of the message */\nexport enum MessageRole {\n Assistant = 'assistant',\n Developer = 'developer',\n System = 'system',\n Tool = 'tool',\n User = 'user'\n}\n\nexport type MessageStatus = FailedMessageStatus | PendingMessageStatus | SuccessMessageStatus;\n\nexport enum MessageStatusCode {\n Failed = 'Failed',\n Pending = 'Pending',\n Success = 'Success'\n}\n\nexport type MetaEventInput = {\n messages?: InputMaybe<Array<MessageInput>>;\n name: MetaEventName;\n response?: InputMaybe<Scalars['String']['input']>;\n value: Scalars['String']['input'];\n};\n\n/** Meta event types */\nexport enum MetaEventName {\n CopilotKitLangGraphInterruptEvent = 'CopilotKitLangGraphInterruptEvent',\n LangGraphInterruptEvent = 'LangGraphInterruptEvent'\n}\n\nexport type Mutation = {\n __typename?: 'Mutation';\n generateCopilotResponse: CopilotResponse;\n};\n\n\nexport type MutationGenerateCopilotResponseArgs = {\n data: GenerateCopilotResponseInput;\n properties?: InputMaybe<Scalars['JSONObject']['input']>;\n};\n\nexport type OpenAiApiAssistantApiInput = {\n runId?: InputMaybe<Scalars['String']['input']>;\n threadId?: InputMaybe<Scalars['String']['input']>;\n};\n\nexport type OpenAiApiAssistantApiResponse = {\n __typename?: 'OpenAIApiAssistantAPIResponse';\n runId?: Maybe<Scalars['String']['output']>;\n threadId?: Maybe<Scalars['String']['output']>;\n};\n\nexport type PendingMessageStatus = {\n __typename?: 'PendingMessageStatus';\n code: MessageStatusCode;\n};\n\nexport type PendingResponseStatus = BaseResponseStatus & {\n __typename?: 'PendingResponseStatus';\n code: ResponseStatusCode;\n};\n\nexport type Query = {\n __typename?: 'Query';\n availableAgents: AgentsResponse;\n hello: Scalars['String']['output'];\n loadAgentState: LoadAgentStateResponse;\n};\n\n\nexport type QueryLoadAgentStateArgs = {\n data: LoadAgentStateInput;\n};\n\nexport type ResponseStatus = FailedResponseStatus | PendingResponseStatus | SuccessResponseStatus;\n\nexport enum ResponseStatusCode {\n Failed = 'Failed',\n Pending = 'Pending',\n Success = 'Success'\n}\n\nexport type ResultMessageInput = {\n actionExecutionId: Scalars['String']['input'];\n actionName: Scalars['String']['input'];\n parentMessageId?: InputMaybe<Scalars['String']['input']>;\n result: Scalars['String']['input'];\n};\n\nexport type ResultMessageOutput = BaseMessageOutput & {\n __typename?: 'ResultMessageOutput';\n actionExecutionId: Scalars['String']['output'];\n actionName: Scalars['String']['output'];\n createdAt: Scalars['DateTimeISO']['output'];\n id: Scalars['String']['output'];\n result: Scalars['String']['output'];\n status: MessageStatus;\n};\n\nexport type SuccessMessageStatus = {\n __typename?: 'SuccessMessageStatus';\n code: MessageStatusCode;\n};\n\nexport type SuccessResponseStatus = BaseResponseStatus & {\n __typename?: 'SuccessResponseStatus';\n code: ResponseStatusCode;\n};\n\nexport type TextMessageInput = {\n content: Scalars['String']['input'];\n parentMessageId?: InputMaybe<Scalars['String']['input']>;\n role: MessageRole;\n};\n\nexport type TextMessageOutput = BaseMessageOutput & {\n __typename?: 'TextMessageOutput';\n content: Array<Scalars['String']['output']>;\n createdAt: Scalars['DateTimeISO']['output'];\n id: Scalars['String']['output'];\n parentMessageId?: Maybe<Scalars['String']['output']>;\n role: MessageRole;\n status: MessageStatus;\n};\n\nexport type GenerateCopilotResponseMutationVariables = Exact<{\n data: GenerateCopilotResponseInput;\n properties?: InputMaybe<Scalars['JSONObject']['input']>;\n}>;\n\n\nexport type GenerateCopilotResponseMutation = { __typename?: 'Mutation', generateCopilotResponse: { __typename?: 'CopilotResponse', threadId: string, runId?: string | null, extensions?: { __typename?: 'ExtensionsResponse', openaiAssistantAPI?: { __typename?: 'OpenAIApiAssistantAPIResponse', runId?: string | null, threadId?: string | null } | null } | null, messages: Array<{ __typename: 'ActionExecutionMessageOutput', id: string, createdAt: any, name: string, arguments: Array<string>, parentMessageId?: string | null, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'AgentStateMessageOutput', id: string, createdAt: any, threadId: string, state: string, running: boolean, agentName: string, nodeName: string, runId: string, active: boolean, role: MessageRole, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'ImageMessageOutput', id: string, createdAt: any, format: string, bytes: string, role: MessageRole, parentMessageId?: string | null, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'ResultMessageOutput', id: string, createdAt: any, result: string, actionExecutionId: string, actionName: string, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'TextMessageOutput', id: string, createdAt: any, content: Array<string>, role: MessageRole, parentMessageId?: string | null, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } }>, metaEvents?: Array<{ __typename?: 'CopilotKitLangGraphInterruptEvent', type: string, name: MetaEventName, data: { __typename?: 'CopilotKitLangGraphInterruptEventData', value: string, messages: Array<{ __typename: 'ActionExecutionMessageOutput', id: string, createdAt: any, name: string, arguments: Array<string>, parentMessageId?: string | null, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'AgentStateMessageOutput', id: string, createdAt: any, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'ImageMessageOutput', id: string, createdAt: any, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'ResultMessageOutput', id: string, createdAt: any, result: string, actionExecutionId: string, actionName: string, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'TextMessageOutput', id: string, createdAt: any, content: Array<string>, role: MessageRole, parentMessageId?: string | null, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } }> } } | { __typename?: 'LangGraphInterruptEvent', type: string, name: MetaEventName, value: string }> | null } & ({ __typename?: 'CopilotResponse', status: { __typename?: 'FailedResponseStatus', code: ResponseStatusCode, reason: FailedResponseStatusReason, details?: any | null } | { __typename?: 'PendingResponseStatus', code: ResponseStatusCode } | { __typename?: 'SuccessResponseStatus', code: ResponseStatusCode } } | { __typename?: 'CopilotResponse', status?: never }) };\n\nexport type AvailableAgentsQueryVariables = Exact<{ [key: string]: never; }>;\n\n\nexport type AvailableAgentsQuery = { __typename?: 'Query', availableAgents: { __typename?: 'AgentsResponse', agents: Array<{ __typename?: 'Agent', name: string, id: string, description: string }> } };\n\nexport type LoadAgentStateQueryVariables = Exact<{\n data: LoadAgentStateInput;\n}>;\n\n\nexport type LoadAgentStateQuery = { __typename?: 'Query', loadAgentState: { __typename?: 'LoadAgentStateResponse', threadId: string, threadExists: boolean, state: string, messages: string } };\n\n\nexport const GenerateCopilotResponseDocument = {\"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\"}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<GenerateCopilotResponseMutation, GenerateCopilotResponseMutationVariables>;\nexport const AvailableAgentsDocument = {\"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\"}}]}}]}}]}}]} as unknown as DocumentNode<AvailableAgentsQuery, AvailableAgentsQueryVariables>;\nexport const LoadAgentStateDocument = {\"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\"}}]}}]}}]} as unknown as DocumentNode<LoadAgentStateQuery, LoadAgentStateQueryVariables>;","import { randomId } from \"@copilotkit/shared\";\nimport {\n ActionExecutionMessageInput,\n MessageRole,\n MessageStatus,\n ResultMessageInput,\n TextMessageInput,\n BaseMessageOutput,\n AgentStateMessageInput,\n MessageStatusCode,\n LangGraphInterruptEvent as GqlLangGraphInterruptEvent,\n MetaEventName,\n CopilotKitLangGraphInterruptEvent as GqlCopilotKitLangGraphInterruptEvent,\n ImageMessageInput,\n} from \"../graphql/@generated/graphql\";\nimport { parseJson } from \"@copilotkit/shared\";\n\ntype MessageType =\n | \"TextMessage\"\n | \"ActionExecutionMessage\"\n | \"ResultMessage\"\n | \"AgentStateMessage\"\n | \"ImageMessage\";\n\nexport class Message {\n type: MessageType;\n id: BaseMessageOutput[\"id\"];\n createdAt: BaseMessageOutput[\"createdAt\"];\n status: MessageStatus;\n\n constructor(props: any) {\n props.id ??= randomId();\n props.status ??= { code: MessageStatusCode.Success };\n props.createdAt ??= new Date();\n Object.assign(this, props);\n }\n\n isTextMessage(): this is TextMessage {\n return this.type === \"TextMessage\";\n }\n\n isActionExecutionMessage(): this is ActionExecutionMessage {\n return this.type === \"ActionExecutionMessage\";\n }\n\n isResultMessage(): this is ResultMessage {\n return this.type === \"ResultMessage\";\n }\n\n isAgentStateMessage(): this is AgentStateMessage {\n return this.type === \"AgentStateMessage\";\n }\n\n isImageMessage(): this is ImageMessage {\n return this.type === \"ImageMessage\";\n }\n}\n\n// alias Role to MessageRole\nexport const Role = MessageRole;\n\n// when constructing any message, the base fields are optional\ntype MessageConstructorOptions = Partial<Message>;\n\ntype TextMessageConstructorOptions = MessageConstructorOptions & TextMessageInput;\n\nexport class TextMessage extends Message implements TextMessageConstructorOptions {\n role: TextMessageInput[\"role\"];\n content: TextMessageInput[\"content\"];\n parentMessageId: TextMessageInput[\"parentMessageId\"];\n\n constructor(props: TextMessageConstructorOptions) {\n super(props);\n this.type = \"TextMessage\";\n }\n}\n\ntype ActionExecutionMessageConstructorOptions = MessageConstructorOptions &\n Omit<ActionExecutionMessageInput, \"arguments\"> & {\n arguments: Record<string, any>;\n };\n\nexport class ActionExecutionMessage\n extends Message\n implements Omit<ActionExecutionMessageInput, \"arguments\" | \"scope\">\n{\n name: ActionExecutionMessageInput[\"name\"];\n arguments: Record<string, any>;\n parentMessageId: ActionExecutionMessageInput[\"parentMessageId\"];\n constructor(props: ActionExecutionMessageConstructorOptions) {\n super(props);\n this.type = \"ActionExecutionMessage\";\n }\n}\n\ntype ResultMessageConstructorOptions = MessageConstructorOptions & ResultMessageInput;\n\nexport class ResultMessage extends Message implements ResultMessageConstructorOptions {\n actionExecutionId: ResultMessageInput[\"actionExecutionId\"];\n actionName: ResultMessageInput[\"actionName\"];\n result: ResultMessageInput[\"result\"];\n\n constructor(props: ResultMessageConstructorOptions) {\n super(props);\n this.type = \"ResultMessage\";\n }\n\n static decodeResult(result: string): any {\n return parseJson(result, result);\n }\n\n static encodeResult(result: any): string {\n if (result === undefined) {\n return \"\";\n } else if (typeof result === \"string\") {\n return result;\n } else {\n return JSON.stringify(result);\n }\n }\n}\n\nexport class AgentStateMessage extends Message implements Omit<AgentStateMessageInput, \"state\"> {\n agentName: AgentStateMessageInput[\"agentName\"];\n state: any;\n running: AgentStateMessageInput[\"running\"];\n threadId: AgentStateMessageInput[\"threadId\"];\n role: AgentStateMessageInput[\"role\"];\n nodeName: AgentStateMessageInput[\"nodeName\"];\n runId: AgentStateMessageInput[\"runId\"];\n active: AgentStateMessageInput[\"active\"];\n\n constructor(props: any) {\n super(props);\n this.type = \"AgentStateMessage\";\n }\n}\n\ntype ImageMessageConstructorOptions = MessageConstructorOptions & ImageMessageInput;\n\nexport class ImageMessage extends Message implements ImageMessageConstructorOptions {\n format: ImageMessageInput[\"format\"];\n bytes: ImageMessageInput[\"bytes\"];\n role: ImageMessageInput[\"role\"];\n parentMessageId: ImageMessageInput[\"parentMessageId\"];\n\n constructor(props: ImageMessageConstructorOptions) {\n super(props);\n this.type = \"ImageMessage\";\n }\n}\n\nexport function langGraphInterruptEvent(\n eventProps: Omit<LangGraphInterruptEvent, \"name\" | \"type\" | \"__typename\">,\n): LangGraphInterruptEvent {\n return { ...eventProps, name: MetaEventName.LangGraphInterruptEvent, type: \"MetaEvent\" };\n}\n\nexport type LangGraphInterruptEvent<TValue extends any = any> = GqlLangGraphInterruptEvent & {\n value: TValue;\n};\n\ntype CopilotKitLangGraphInterruptEvent<TValue extends any = any> =\n GqlCopilotKitLangGraphInterruptEvent & {\n data: GqlCopilotKitLangGraphInterruptEvent[\"data\"] & { value: TValue };\n };\n\nexport type MetaEvent = LangGraphInterruptEvent | CopilotKitLangGraphInterruptEvent;\n","import * as gql from \"../client\";\nimport { MessageRole } from \"../graphql/@generated/graphql\";\nimport agui from \"@copilotkit/shared\"; // named agui for clarity, but this only includes agui message types\n\n// Helper function to extract agent name from message\nfunction extractAgentName(message: agui.Message): string {\n if (message.role !== \"assistant\") {\n throw new Error(`Cannot extract agent name from message with role ${message.role}`);\n }\n\n return message.agentName || \"unknown\";\n}\n\n// Type guard for agent state message\nfunction isAgentStateMessage(message: agui.Message): boolean {\n return message.role === \"assistant\" && \"agentName\" in message && \"state\" in message;\n}\n\n// Type guard for messages with image property\nfunction hasImageProperty(message: agui.Message): boolean {\n const canContainImage = message.role === \"assistant\" || message.role === \"user\";\n if (!canContainImage || message.image === undefined) {\n return false;\n }\n\n const isMalformed = message.image.format === undefined || message.image.bytes === undefined;\n if (isMalformed) {\n return false;\n }\n\n return true;\n}\n\n/*\n ----------------------------\n AGUI Message -> GQL Message\n ----------------------------\n*/\nexport function aguiToGQL(\n messages: agui.Message[] | agui.Message,\n actions?: Record<string, any>,\n coAgentStateRenders?: Record<string, any>,\n): gql.Message[] {\n const gqlMessages: gql.Message[] = [];\n messages = Array.isArray(messages) ? messages : [messages];\n\n // Track tool call names by their IDs for use in result messages\n const toolCallNames: Record<string, string> = {};\n\n for (const message of messages) {\n // Agent state message support\n if (isAgentStateMessage(message)) {\n const agentName = extractAgentName(message);\n const state = \"state\" in message && message.state ? message.state : {};\n gqlMessages.push(\n new gql.AgentStateMessage({\n id: message.id,\n agentName,\n state,\n role: gql.Role.Assistant,\n }),\n );\n // Optionally preserve render function\n if (\"generativeUI\" in message && message.generativeUI && coAgentStateRenders) {\n coAgentStateRenders[agentName] = {\n name: agentName,\n render: message.generativeUI,\n };\n }\n continue;\n }\n\n if (hasImageProperty(message)) {\n gqlMessages.push(aguiMessageWithImageToGQLMessage(message));\n continue;\n }\n\n // Action execution message support\n if (message.role === \"assistant\" && message.toolCalls) {\n gqlMessages.push(aguiTextMessageToGQLMessage(message));\n for (const toolCall of message.toolCalls) {\n // Track the tool call name by its ID\n toolCallNames[toolCall.id] = toolCall.function.name;\n\n const actionExecMsg = aguiToolCallToGQLActionExecution(toolCall, message.id);\n // Preserve render function in actions context\n if (\"generativeUI\" in message && message.generativeUI && actions) {\n const actionName = toolCall.function.name;\n // Check for specific action first, then wild card action\n const specificAction = Object.values(actions).find(\n (action: any) => action.name === actionName,\n );\n const wildcardAction = Object.values(actions).find((action: any) => action.name === \"*\");\n\n // Assign render function to the matching action (specific takes priority)\n if (specificAction) {\n specificAction.render = message.generativeUI;\n } else if (wildcardAction) {\n wildcardAction.render = message.generativeUI;\n }\n }\n gqlMessages.push(actionExecMsg);\n }\n continue;\n }\n // Regular text messages\n if (\n message.role === \"developer\" ||\n message.role === \"system\" ||\n message.role === \"assistant\" ||\n message.role === \"user\"\n ) {\n gqlMessages.push(aguiTextMessageToGQLMessage(message));\n continue;\n }\n // Tool result message\n if (message.role === \"tool\") {\n gqlMessages.push(aguiToolMessageToGQLResultMessage(message, toolCallNames));\n continue;\n }\n throw new Error(\n `Unknown message role: \"${(message as any).role}\" in message with id: ${(message as any).id}`,\n );\n }\n\n return gqlMessages;\n}\n\nexport function aguiTextMessageToGQLMessage(message: agui.Message): gql.TextMessage {\n if (\n message.role !== \"developer\" &&\n message.role !== \"system\" &&\n message.role !== \"assistant\" &&\n message.role !== \"user\"\n ) {\n throw new Error(`Cannot convert message with role ${message.role} to TextMessage`);\n }\n\n let roleValue: MessageRole;\n\n if (message.role === \"developer\") {\n roleValue = gql.Role.Developer;\n } else if (message.role === \"system\") {\n roleValue = gql.Role.System;\n } else if (message.role === \"assistant\") {\n roleValue = gql.Role.Assistant;\n } else {\n roleValue = gql.Role.User;\n }\n\n return new gql.TextMessage({\n id: message.id,\n content: message.content || \"\",\n role: roleValue,\n });\n}\n\nexport function aguiToolCallToGQLActionExecution(\n toolCall: agui.ToolCall,\n parentMessageId: string,\n): gql.ActionExecutionMessage {\n if (toolCall.type !== \"function\") {\n throw new Error(`Unsupported tool call type: ${toolCall.type}`);\n }\n\n // Parse arguments with error handling\n let argumentsObj: any;\n try {\n argumentsObj = JSON.parse(toolCall.function.arguments);\n } catch (error) {\n console.warn(`Failed to parse tool call arguments for ${toolCall.function.name}:`, error);\n // Provide fallback empty object to prevent application crash\n argumentsObj = {};\n }\n\n // Always include name and arguments\n return new gql.ActionExecutionMessage({\n id: toolCall.id,\n name: toolCall.function.name,\n arguments: argumentsObj,\n parentMessageId: parentMessageId,\n });\n}\n\nexport function aguiToolMessageToGQLResultMessage(\n message: agui.Message,\n toolCallNames: Record<string, string>,\n): gql.ResultMessage {\n if (message.role !== \"tool\") {\n throw new Error(`Cannot convert message with role ${message.role} to ResultMessage`);\n }\n\n if (!message.toolCallId) {\n throw new Error(\"Tool message must have a toolCallId\");\n }\n\n const actionName = toolCallNames[message.toolCallId] || \"unknown\";\n\n return new gql.ResultMessage({\n id: message.id,\n result: message.content || \"\",\n actionExecutionId: message.toolCallId,\n actionName: message.toolName || actionName,\n });\n}\n\n// New function to handle AGUI messages with render functions\nexport function aguiMessageWithRenderToGQL(\n message: agui.Message,\n actions?: Record<string, any>,\n coAgentStateRenders?: Record<string, any>,\n): gql.Message[] {\n // Handle the special case: assistant messages with render function but no tool calls\n if (\n message.role === \"assistant\" &&\n \"generativeUI\" in message &&\n message.generativeUI &&\n !message.toolCalls\n ) {\n const gqlMessages: gql.Message[] = [];\n gqlMessages.push(\n new gql.AgentStateMessage({\n id: message.id,\n agentName: \"unknown\",\n state: {},\n role: gql.Role.Assistant,\n }),\n );\n if (coAgentStateRenders) {\n coAgentStateRenders.unknown = {\n name: \"unknown\",\n render: message.generativeUI,\n };\n }\n return gqlMessages;\n }\n\n // For all other cases, delegate to aguiToGQL\n return aguiToGQL([message], actions, coAgentStateRenders);\n}\n\nexport function aguiMessageWithImageToGQLMessage(message: agui.Message): gql.ImageMessage {\n if (!hasImageProperty(message)) {\n throw new Error(`Cannot convert message to ImageMessage: missing format or bytes`);\n }\n\n let roleValue: MessageRole;\n if (message.role === \"assistant\") {\n roleValue = gql.Role.Assistant;\n } else {\n roleValue = gql.Role.User;\n }\n\n if (message.role !== \"assistant\" && message.role !== \"user\") {\n throw new Error(`Cannot convert message with role ${message.role} to ImageMessage`);\n }\n\n return new gql.ImageMessage({\n id: message.id,\n format: message.image!.format,\n bytes: message.image!.bytes,\n role: roleValue,\n });\n}\n","import * as gql from \"../client\";\nimport agui from \"@copilotkit/shared\";\nimport { MessageStatusCode } from \"../graphql/@generated/graphql\";\n\n// Define valid image formats based on the supported formats in the codebase\nconst VALID_IMAGE_FORMATS = [\"jpeg\", \"png\", \"webp\", \"gif\"] as const;\ntype ValidImageFormat = (typeof VALID_IMAGE_FORMATS)[number];\n\n// Validation function for image format\nfunction validateImageFormat(format: string): format is ValidImageFormat {\n return VALID_IMAGE_FORMATS.includes(format as ValidImageFormat);\n}\n\n/*\n ----------------------------\n GQL Message -> AGUI Message\n ----------------------------\n*/\nexport function gqlToAGUI(\n messages: gql.Message[] | gql.Message,\n actions?: Record<string, any>,\n coAgentStateRenders?: Record<string, any>,\n): agui.Message[] {\n let aguiMessages: agui.Message[] = [];\n messages = Array.isArray(messages) ? messages : [messages];\n\n // Create a map of action execution ID to result for completed actions\n const actionResults = new Map<string, string>();\n for (const message of messages) {\n if (message.isResultMessage()) {\n actionResults.set(message.actionExecutionId, message.result);\n }\n }\n\n for (const message of messages) {\n if (message.isTextMessage()) {\n aguiMessages.push(gqlTextMessageToAGUIMessage(message));\n } else if (message.isResultMessage()) {\n aguiMessages.push(gqlResultMessageToAGUIMessage(message));\n } else if (message.isActionExecutionMessage()) {\n aguiMessages.push(gqlActionExecutionMessageToAGUIMessage(message, actions, actionResults));\n } else if (message.isAgentStateMessage()) {\n aguiMessages.push(gqlAgentStateMessageToAGUIMessage(message, coAgentStateRenders));\n } else if (message.isImageMessage()) {\n aguiMessages.push(gqlImageMessageToAGUIMessage(message));\n } else {\n throw new Error(\"Unknown message type\");\n }\n }\n\n return aguiMessages;\n}\n\nexport function gqlActionExecutionMessageToAGUIMessage(\n message: gql.ActionExecutionMessage,\n actions?: Record<string, any>,\n actionResults?: Map<string, string>,\n): agui.Message {\n // Check if we have actions and if there's a specific action or wild card action\n const hasSpecificAction =\n actions && Object.values(actions).some((action: any) => action.name === message.name);\n const hasWildcardAction =\n actions && Object.values(actions).some((action: any) => action.name === \"*\");\n\n if (!actions || (!hasSpecificAction && !hasWildcardAction)) {\n return {\n id: message.id,\n role: \"assistant\",\n toolCalls: [actionExecutionMessageToAGUIMessage(message)],\n name: message.name,\n };\n }\n\n // Find the specific action first, then fall back to wild card action\n const action =\n Object.values(actions).find((action: any) => action.name === message.name) ||\n Object.values(actions).find((action: any) => action.name === \"*\");\n\n // Create render function wrapper that provides proper props\n const createRenderWrapper = (originalRender: any) => {\n if (!originalRender) return undefined;\n\n return (props?: any) => {\n // Determine the correct status based on the same logic as RenderActionExecutionMessage\n const actionResult = actionResults?.get(message.id);\n let status: \"inProgress\" | \"executing\" | \"complete\" = \"inProgress\";\n\n if (actionResult !== undefined) {\n status = \"complete\";\n } else if (message.status?.code !== MessageStatusCode.Pending) {\n status = \"executing\";\n }\n\n // Provide the full props structure that the render function expects\n const renderProps = {\n status: props?.status || status,\n args: message.arguments || {},\n result: props?.result || actionResult || undefined,\n respond: props?.respond || (() => {}),\n messageId: message.id,\n ...props,\n };\n\n return originalRender(renderProps);\n };\n };\n\n return {\n id: message.id,\n role: \"assistant\",\n content: \"\",\n toolCalls: [actionExecutionMessageToAGUIMessage(message)],\n generativeUI: createRenderWrapper(action.render),\n name: message.name,\n } as agui.AIMessage;\n}\n\nfunction gqlAgentStateMessageToAGUIMessage(\n message: gql.AgentStateMessage,\n coAgentStateRenders?: Record<string, any>,\n): agui.Message {\n if (\n coAgentStateRenders &&\n Object.values(coAgentStateRenders).some((render: any) => render.name === message.agentName)\n ) {\n const render = Object.values(coAgentStateRenders).find(\n (render: any) => render.name === message.agentName,\n );\n\n // Create render function wrapper that provides proper props\n const createRenderWrapper = (originalRender: any) => {\n if (!originalRender) return undefined;\n\n return (props?: any) => {\n // Determine the correct status based on the same logic as RenderActionExecutionMessage\n const state = message.state;\n\n // Provide the full props structure that the render function expects\n const renderProps = {\n state: state,\n };\n\n return originalRender(renderProps);\n };\n };\n\n return {\n id: message.id,\n role: \"assistant\",\n generativeUI: createRenderWrapper(render.render),\n agentName: message.agentName,\n state: message.state,\n };\n }\n\n return {\n id: message.id,\n role: \"assistant\",\n agentName: message.agentName,\n state: message.state,\n };\n}\n\nfunction actionExecutionMessageToAGUIMessage(\n actionExecutionMessage: gql.ActionExecutionMessage,\n): agui.ToolCall {\n return {\n id: actionExecutionMessage.id,\n function: {\n name: actionExecutionMessage.name,\n arguments: JSON.stringify(actionExecutionMessage.arguments),\n },\n type: \"function\",\n };\n}\n\nexport function gqlTextMessageToAGUIMessage(message: gql.TextMessage): agui.Message {\n switch (message.role) {\n case gql.Role.Developer:\n return {\n id: message.id,\n role: \"developer\",\n content: message.content,\n };\n case gql.Role.System:\n return {\n id: message.id,\n role: \"system\",\n content: message.content,\n };\n case gql.Role.Assistant:\n return {\n id: message.id,\n role: \"assistant\",\n content: message.content,\n };\n case gql.Role.User:\n return {\n id: message.id,\n role: \"user\",\n content: message.content,\n };\n default:\n throw new Error(\"Unknown message role\");\n }\n}\n\nexport function gqlResultMessageToAGUIMessage(message: gql.ResultMessage): agui.Message {\n return {\n id: message.id,\n role: \"tool\",\n content: message.result,\n toolCallId: message.actionExecutionId,\n toolName: message.actionName,\n };\n}\n\nexport function gqlImageMessageToAGUIMessage(message: gql.ImageMessage): agui.Message {\n // Validate image format\n if (!validateImageFormat(message.format)) {\n throw new Error(\n `Invalid image format: ${message.format}. Supported formats are: ${VALID_IMAGE_FORMATS.join(\", \")}`,\n );\n }\n\n // Validate that bytes is a non-empty string\n if (!message.bytes || typeof message.bytes !== \"string\" || message.bytes.trim() === \"\") {\n throw new Error(\"Image bytes must be a non-empty string\");\n }\n\n // Determine the role based on the message role\n const role = message.role === gql.Role.Assistant ? \"assistant\" : \"user\";\n\n // Create the image message with proper typing\n const imageMessage: agui.Message = {\n id: message.id,\n role,\n content: \"\",\n image: {\n format: message.format,\n bytes: message.bytes,\n },\n };\n\n return imageMessage;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACyRO,IAAK,cAAL,kBAAKA,iBAAL;AACL,EAAAA,aAAA,eAAY;AACZ,EAAAA,aAAA,eAAY;AACZ,EAAAA,aAAA,YAAS;AACT,EAAAA,aAAA,UAAO;AACP,EAAAA,aAAA,UAAO;AALG,SAAAA;AAAA,GAAA;;;ACzRZ,oBAAyB;AAezB,IAAAC,iBAA0B;AASnB,IAAM,UAAN,MAAc;AAAA,EAMnB,YAAY,OAAY;AACtB,UAAM,OAAN,MAAM,SAAO,wBAAS;AACtB,UAAM,WAAN,MAAM,SAAW,EAAE,8BAAgC;AACnD,UAAM,cAAN,MAAM,YAAc,oBAAI,KAAK;AAC7B,WAAO,OAAO,MAAM,KAAK;AAAA,EAC3B;AAAA,EAEA,gBAAqC;AACnC,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,2BAA2D;AACzD,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,kBAAyC;AACvC,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,E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,QAAQ;AAAA,IACjB;AAAA,EACF;AAEA,SAAO;AACT;","names":["MessageRole","import_shared","action","render"]}
1
+ {"version":3,"sources":["../../src/message-conversion/index.ts","../../src/graphql/@generated/graphql.ts","../../src/client/types.ts","../../src/message-conversion/agui-to-gql.ts","../../src/message-conversion/gql-to-agui.ts"],"sourcesContent":["export * from \"./agui-to-gql\";\nexport * from \"./gql-to-agui\";\n","/* eslint-disable */\nimport type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';\nexport type Maybe<T> = T | null;\nexport type InputMaybe<T> = Maybe<T>;\nexport type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };\nexport type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };\nexport type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };\nexport type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };\nexport type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };\n/** All built-in and custom scalars, mapped to their actual values */\nexport type Scalars = {\n ID: { input: string; output: string; }\n String: { input: string; output: string; }\n Boolean: { input: boolean; output: boolean; }\n Int: { input: number; output: number; }\n Float: { input: number; output: number; }\n /** A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.This scalar is serialized to a string in ISO 8601 format and parsed from a string in ISO 8601 format. */\n DateTimeISO: { input: any; output: any; }\n /** The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). */\n JSON: { input: any; output: any; }\n /** The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). */\n JSONObject: { input: any; output: any; }\n};\n\nexport type ActionExecutionMessageInput = {\n arguments: Scalars['String']['input'];\n name: Scalars['String']['input'];\n parentMessageId?: InputMaybe<Scalars['String']['input']>;\n /** @deprecated This field will be removed in a future version */\n scope?: InputMaybe<Scalars['String']['input']>;\n};\n\nexport type ActionExecutionMessageOutput = BaseMessageOutput & {\n __typename?: 'ActionExecutionMessageOutput';\n arguments: Array<Scalars['String']['output']>;\n createdAt: Scalars['DateTimeISO']['output'];\n id: Scalars['String']['output'];\n name: Scalars['String']['output'];\n parentMessageId?: Maybe<Scalars['String']['output']>;\n /** @deprecated This field will be removed in a future version */\n scope?: Maybe<Scalars['String']['output']>;\n status: MessageStatus;\n};\n\nexport type ActionInput = {\n available?: InputMaybe<ActionInputAvailability>;\n description: Scalars['String']['input'];\n jsonSchema: Scalars['String']['input'];\n name: Scalars['String']['input'];\n};\n\n/** The availability of the frontend action */\nexport enum ActionInputAvailability {\n Disabled = 'disabled',\n Enabled = 'enabled',\n Remote = 'remote'\n}\n\nexport type Agent = {\n __typename?: 'Agent';\n description: Scalars['String']['output'];\n id: Scalars['String']['output'];\n name: Scalars['String']['output'];\n};\n\nexport type AgentSessionInput = {\n agentName: Scalars['String']['input'];\n nodeName?: InputMaybe<Scalars['String']['input']>;\n threadId?: InputMaybe<Scalars['String']['input']>;\n};\n\nexport type AgentStateInput = {\n agentName: Scalars['String']['input'];\n config?: InputMaybe<Scalars['String']['input']>;\n state: Scalars['String']['input'];\n};\n\nexport type AgentStateMessageInput = {\n active: Scalars['Boolean']['input'];\n agentName: Scalars['String']['input'];\n nodeName: Scalars['String']['input'];\n role: MessageRole;\n runId: Scalars['String']['input'];\n running: Scalars['Boolean']['input'];\n state: Scalars['String']['input'];\n threadId: Scalars['String']['input'];\n};\n\nexport type AgentStateMessageOutput = BaseMessageOutput & {\n __typename?: 'AgentStateMessageOutput';\n active: Scalars['Boolean']['output'];\n agentName: Scalars['String']['output'];\n createdAt: Scalars['DateTimeISO']['output'];\n id: Scalars['String']['output'];\n nodeName: Scalars['String']['output'];\n role: MessageRole;\n runId: Scalars['String']['output'];\n running: Scalars['Boolean']['output'];\n state: Scalars['String']['output'];\n status: MessageStatus;\n threadId: Scalars['String']['output'];\n};\n\nexport type AgentsResponse = {\n __typename?: 'AgentsResponse';\n agents: Array<Agent>;\n};\n\nexport type BaseMessageOutput = {\n createdAt: Scalars['DateTimeISO']['output'];\n id: Scalars['String']['output'];\n status: MessageStatus;\n};\n\nexport type BaseMetaEvent = {\n name: MetaEventName;\n type: Scalars['String']['output'];\n};\n\nexport type BaseResponseStatus = {\n code: ResponseStatusCode;\n};\n\nexport type CloudInput = {\n guardrails?: InputMaybe<GuardrailsInput>;\n};\n\nexport type CopilotKitLangGraphInterruptEvent = BaseMetaEvent & {\n __typename?: 'CopilotKitLangGraphInterruptEvent';\n data: CopilotKitLangGraphInterruptEventData;\n name: MetaEventName;\n response?: Maybe<Scalars['String']['output']>;\n type: Scalars['String']['output'];\n};\n\nexport type CopilotKitLangGraphInterruptEventData = {\n __typename?: 'CopilotKitLangGraphInterruptEventData';\n messages: Array<BaseMessageOutput>;\n value: Scalars['String']['output'];\n};\n\n/** The type of Copilot request */\nexport enum CopilotRequestType {\n Chat = 'Chat',\n Suggestion = 'Suggestion',\n Task = 'Task',\n TextareaCompletion = 'TextareaCompletion',\n TextareaPopover = 'TextareaPopover'\n}\n\nexport type CopilotResponse = {\n __typename?: 'CopilotResponse';\n extensions?: Maybe<ExtensionsResponse>;\n messages: Array<BaseMessageOutput>;\n metaEvents?: Maybe<Array<BaseMetaEvent>>;\n runId?: Maybe<Scalars['String']['output']>;\n status: ResponseStatus;\n threadId: Scalars['String']['output'];\n};\n\nexport type ExtensionsInput = {\n openaiAssistantAPI?: InputMaybe<OpenAiApiAssistantApiInput>;\n};\n\nexport type ExtensionsResponse = {\n __typename?: 'ExtensionsResponse';\n openaiAssistantAPI?: Maybe<OpenAiApiAssistantApiResponse>;\n};\n\nexport type FailedMessageStatus = {\n __typename?: 'FailedMessageStatus';\n code: MessageStatusCode;\n reason: Scalars['String']['output'];\n};\n\nexport type FailedResponseStatus = BaseResponseStatus & {\n __typename?: 'FailedResponseStatus';\n code: ResponseStatusCode;\n details?: Maybe<Scalars['JSON']['output']>;\n reason: FailedResponseStatusReason;\n};\n\nexport enum FailedResponseStatusReason {\n GuardrailsValidationFailed = 'GUARDRAILS_VALIDATION_FAILED',\n MessageStreamInterrupted = 'MESSAGE_STREAM_INTERRUPTED',\n UnknownError = 'UNKNOWN_ERROR'\n}\n\nexport type ForwardedParametersInput = {\n maxTokens?: InputMaybe<Scalars['Float']['input']>;\n model?: InputMaybe<Scalars['String']['input']>;\n stop?: InputMaybe<Array<Scalars['String']['input']>>;\n temperature?: InputMaybe<Scalars['Float']['input']>;\n toolChoice?: InputMaybe<Scalars['String']['input']>;\n toolChoiceFunctionName?: InputMaybe<Scalars['String']['input']>;\n};\n\nexport type FrontendInput = {\n actions: Array<ActionInput>;\n toDeprecate_fullContext?: InputMaybe<Scalars['String']['input']>;\n url?: InputMaybe<Scalars['String']['input']>;\n};\n\nexport type GenerateCopilotResponseInput = {\n agentSession?: InputMaybe<AgentSessionInput>;\n agentState?: InputMaybe<AgentStateInput>;\n agentStates?: InputMaybe<Array<AgentStateInput>>;\n cloud?: InputMaybe<CloudInput>;\n extensions?: InputMaybe<ExtensionsInput>;\n forwardedParameters?: InputMaybe<ForwardedParametersInput>;\n frontend: FrontendInput;\n messages: Array<MessageInput>;\n metaEvents?: InputMaybe<Array<MetaEventInput>>;\n metadata: GenerateCopilotResponseMetadataInput;\n runId?: InputMaybe<Scalars['String']['input']>;\n threadId?: InputMaybe<Scalars['String']['input']>;\n};\n\nexport type GenerateCopilotResponseMetadataInput = {\n requestType?: InputMaybe<CopilotRequestType>;\n};\n\nexport type GuardrailsInput = {\n inputValidationRules: GuardrailsRuleInput;\n};\n\nexport type GuardrailsRuleInput = {\n allowList?: InputMaybe<Array<Scalars['String']['input']>>;\n denyList?: InputMaybe<Array<Scalars['String']['input']>>;\n};\n\nexport type ImageMessageInput = {\n bytes: Scalars['String']['input'];\n format: Scalars['String']['input'];\n parentMessageId?: InputMaybe<Scalars['String']['input']>;\n role: MessageRole;\n};\n\nexport type ImageMessageOutput = BaseMessageOutput & {\n __typename?: 'ImageMessageOutput';\n bytes: Scalars['String']['output'];\n createdAt: Scalars['DateTimeISO']['output'];\n format: Scalars['String']['output'];\n id: Scalars['String']['output'];\n parentMessageId?: Maybe<Scalars['String']['output']>;\n role: MessageRole;\n status: MessageStatus;\n};\n\nexport type LangGraphInterruptEvent = BaseMetaEvent & {\n __typename?: 'LangGraphInterruptEvent';\n name: MetaEventName;\n response?: Maybe<Scalars['String']['output']>;\n type: Scalars['String']['output'];\n value: Scalars['String']['output'];\n};\n\nexport type LoadAgentStateInput = {\n agentName: Scalars['String']['input'];\n threadId: Scalars['String']['input'];\n};\n\nexport type LoadAgentStateResponse = {\n __typename?: 'LoadAgentStateResponse';\n messages: Scalars['String']['output'];\n state: Scalars['String']['output'];\n threadExists: Scalars['Boolean']['output'];\n threadId: Scalars['String']['output'];\n};\n\nexport type MessageInput = {\n actionExecutionMessage?: InputMaybe<ActionExecutionMessageInput>;\n agentStateMessage?: InputMaybe<AgentStateMessageInput>;\n createdAt: Scalars['DateTimeISO']['input'];\n id: Scalars['String']['input'];\n imageMessage?: InputMaybe<ImageMessageInput>;\n resultMessage?: InputMaybe<ResultMessageInput>;\n textMessage?: InputMaybe<TextMessageInput>;\n};\n\n/** The role of the message */\nexport enum MessageRole {\n Assistant = 'assistant',\n Developer = 'developer',\n System = 'system',\n Tool = 'tool',\n User = 'user'\n}\n\nexport type MessageStatus = FailedMessageStatus | PendingMessageStatus | SuccessMessageStatus;\n\nexport enum MessageStatusCode {\n Failed = 'Failed',\n Pending = 'Pending',\n Success = 'Success'\n}\n\nexport type MetaEventInput = {\n messages?: InputMaybe<Array<MessageInput>>;\n name: MetaEventName;\n response?: InputMaybe<Scalars['String']['input']>;\n value: Scalars['String']['input'];\n};\n\n/** Meta event types */\nexport enum MetaEventName {\n CopilotKitLangGraphInterruptEvent = 'CopilotKitLangGraphInterruptEvent',\n LangGraphInterruptEvent = 'LangGraphInterruptEvent'\n}\n\nexport type Mutation = {\n __typename?: 'Mutation';\n generateCopilotResponse: CopilotResponse;\n};\n\n\nexport type MutationGenerateCopilotResponseArgs = {\n data: GenerateCopilotResponseInput;\n properties?: InputMaybe<Scalars['JSONObject']['input']>;\n};\n\nexport type OpenAiApiAssistantApiInput = {\n runId?: InputMaybe<Scalars['String']['input']>;\n threadId?: InputMaybe<Scalars['String']['input']>;\n};\n\nexport type OpenAiApiAssistantApiResponse = {\n __typename?: 'OpenAIApiAssistantAPIResponse';\n runId?: Maybe<Scalars['String']['output']>;\n threadId?: Maybe<Scalars['String']['output']>;\n};\n\nexport type PendingMessageStatus = {\n __typename?: 'PendingMessageStatus';\n code: MessageStatusCode;\n};\n\nexport type PendingResponseStatus = BaseResponseStatus & {\n __typename?: 'PendingResponseStatus';\n code: ResponseStatusCode;\n};\n\nexport type Query = {\n __typename?: 'Query';\n availableAgents: AgentsResponse;\n hello: Scalars['String']['output'];\n loadAgentState: LoadAgentStateResponse;\n};\n\n\nexport type QueryLoadAgentStateArgs = {\n data: LoadAgentStateInput;\n};\n\nexport type ResponseStatus = FailedResponseStatus | PendingResponseStatus | SuccessResponseStatus;\n\nexport enum ResponseStatusCode {\n Failed = 'Failed',\n Pending = 'Pending',\n Success = 'Success'\n}\n\nexport type ResultMessageInput = {\n actionExecutionId: Scalars['String']['input'];\n actionName: Scalars['String']['input'];\n parentMessageId?: InputMaybe<Scalars['String']['input']>;\n result: Scalars['String']['input'];\n};\n\nexport type ResultMessageOutput = BaseMessageOutput & {\n __typename?: 'ResultMessageOutput';\n actionExecutionId: Scalars['String']['output'];\n actionName: Scalars['String']['output'];\n createdAt: Scalars['DateTimeISO']['output'];\n id: Scalars['String']['output'];\n result: Scalars['String']['output'];\n status: MessageStatus;\n};\n\nexport type SuccessMessageStatus = {\n __typename?: 'SuccessMessageStatus';\n code: MessageStatusCode;\n};\n\nexport type SuccessResponseStatus = BaseResponseStatus & {\n __typename?: 'SuccessResponseStatus';\n code: ResponseStatusCode;\n};\n\nexport type TextMessageInput = {\n content: Scalars['String']['input'];\n parentMessageId?: InputMaybe<Scalars['String']['input']>;\n role: MessageRole;\n};\n\nexport type TextMessageOutput = BaseMessageOutput & {\n __typename?: 'TextMessageOutput';\n content: Array<Scalars['String']['output']>;\n createdAt: Scalars['DateTimeISO']['output'];\n id: Scalars['String']['output'];\n parentMessageId?: Maybe<Scalars['String']['output']>;\n role: MessageRole;\n status: MessageStatus;\n};\n\nexport type GenerateCopilotResponseMutationVariables = Exact<{\n data: GenerateCopilotResponseInput;\n properties?: InputMaybe<Scalars['JSONObject']['input']>;\n}>;\n\n\nexport type GenerateCopilotResponseMutation = { __typename?: 'Mutation', generateCopilotResponse: { __typename?: 'CopilotResponse', threadId: string, runId?: string | null, extensions?: { __typename?: 'ExtensionsResponse', openaiAssistantAPI?: { __typename?: 'OpenAIApiAssistantAPIResponse', runId?: string | null, threadId?: string | null } | null } | null, messages: Array<{ __typename: 'ActionExecutionMessageOutput', id: string, createdAt: any, name: string, arguments: Array<string>, parentMessageId?: string | null, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'AgentStateMessageOutput', id: string, createdAt: any, threadId: string, state: string, running: boolean, agentName: string, nodeName: string, runId: string, active: boolean, role: MessageRole, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'ImageMessageOutput', id: string, createdAt: any, format: string, bytes: string, role: MessageRole, parentMessageId?: string | null, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'ResultMessageOutput', id: string, createdAt: any, result: string, actionExecutionId: string, actionName: string, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'TextMessageOutput', id: string, createdAt: any, content: Array<string>, role: MessageRole, parentMessageId?: string | null, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } }>, metaEvents?: Array<{ __typename?: 'CopilotKitLangGraphInterruptEvent', type: string, name: MetaEventName, data: { __typename?: 'CopilotKitLangGraphInterruptEventData', value: string, messages: Array<{ __typename: 'ActionExecutionMessageOutput', id: string, createdAt: any, name: string, arguments: Array<string>, parentMessageId?: string | null, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'AgentStateMessageOutput', id: string, createdAt: any, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'ImageMessageOutput', id: string, createdAt: any, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'ResultMessageOutput', id: string, createdAt: any, result: string, actionExecutionId: string, actionName: string, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } } | { __typename: 'TextMessageOutput', id: string, createdAt: any, content: Array<string>, role: MessageRole, parentMessageId?: string | null, status: { __typename?: 'FailedMessageStatus', code: MessageStatusCode, reason: string } | { __typename?: 'PendingMessageStatus', code: MessageStatusCode } | { __typename?: 'SuccessMessageStatus', code: MessageStatusCode } }> } } | { __typename?: 'LangGraphInterruptEvent', type: string, name: MetaEventName, value: string }> | null } & ({ __typename?: 'CopilotResponse', status: { __typename?: 'FailedResponseStatus', code: ResponseStatusCode, reason: FailedResponseStatusReason, details?: any | null } | { __typename?: 'PendingResponseStatus', code: ResponseStatusCode } | { __typename?: 'SuccessResponseStatus', code: ResponseStatusCode } } | { __typename?: 'CopilotResponse', status?: never }) };\n\nexport type AvailableAgentsQueryVariables = Exact<{ [key: string]: never; }>;\n\n\nexport type AvailableAgentsQuery = { __typename?: 'Query', availableAgents: { __typename?: 'AgentsResponse', agents: Array<{ __typename?: 'Agent', name: string, id: string, description: string }> } };\n\nexport type LoadAgentStateQueryVariables = Exact<{\n data: LoadAgentStateInput;\n}>;\n\n\nexport type LoadAgentStateQuery = { __typename?: 'Query', loadAgentState: { __typename?: 'LoadAgentStateResponse', threadId: string, threadExists: boolean, state: string, messages: string } };\n\n\nexport const GenerateCopilotResponseDocument = {\"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\"}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<GenerateCopilotResponseMutation, GenerateCopilotResponseMutationVariables>;\nexport const AvailableAgentsDocument = {\"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\"}}]}}]}}]}}]} as unknown as DocumentNode<AvailableAgentsQuery, AvailableAgentsQueryVariables>;\nexport const LoadAgentStateDocument = {\"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\"}}]}}]}}]} as unknown as DocumentNode<LoadAgentStateQuery, LoadAgentStateQueryVariables>;","import { randomId } from \"@copilotkit/shared\";\nimport {\n ActionExecutionMessageInput,\n MessageRole,\n MessageStatus,\n ResultMessageInput,\n TextMessageInput,\n BaseMessageOutput,\n AgentStateMessageInput,\n MessageStatusCode,\n LangGraphInterruptEvent as GqlLangGraphInterruptEvent,\n MetaEventName,\n CopilotKitLangGraphInterruptEvent as GqlCopilotKitLangGraphInterruptEvent,\n ImageMessageInput,\n} from \"../graphql/@generated/graphql\";\nimport { parseJson } from \"@copilotkit/shared\";\n\ntype MessageType =\n | \"TextMessage\"\n | \"ActionExecutionMessage\"\n | \"ResultMessage\"\n | \"AgentStateMessage\"\n | \"ImageMessage\";\n\nexport class Message {\n type: MessageType;\n id: BaseMessageOutput[\"id\"];\n createdAt: BaseMessageOutput[\"createdAt\"];\n status: MessageStatus;\n\n constructor(props: any) {\n props.id ??= randomId();\n props.status ??= { code: MessageStatusCode.Success };\n props.createdAt ??= new Date();\n Object.assign(this, props);\n }\n\n isTextMessage(): this is TextMessage {\n return this.type === \"TextMessage\";\n }\n\n isActionExecutionMessage(): this is ActionExecutionMessage {\n return this.type === \"ActionExecutionMessage\";\n }\n\n isResultMessage(): this is ResultMessage {\n return this.type === \"ResultMessage\";\n }\n\n isAgentStateMessage(): this is AgentStateMessage {\n return this.type === \"AgentStateMessage\";\n }\n\n isImageMessage(): this is ImageMessage {\n return this.type === \"ImageMessage\";\n }\n}\n\n// alias Role to MessageRole\nexport const Role = MessageRole;\n\n// when constructing any message, the base fields are optional\ntype MessageConstructorOptions = Partial<Message>;\n\ntype TextMessageConstructorOptions = MessageConstructorOptions & TextMessageInput;\n\nexport class TextMessage extends Message implements TextMessageConstructorOptions {\n role: TextMessageInput[\"role\"];\n content: TextMessageInput[\"content\"];\n parentMessageId: TextMessageInput[\"parentMessageId\"];\n\n constructor(props: TextMessageConstructorOptions) {\n super(props);\n this.type = \"TextMessage\";\n }\n}\n\ntype ActionExecutionMessageConstructorOptions = MessageConstructorOptions &\n Omit<ActionExecutionMessageInput, \"arguments\"> & {\n arguments: Record<string, any>;\n };\n\nexport class ActionExecutionMessage\n extends Message\n implements Omit<ActionExecutionMessageInput, \"arguments\" | \"scope\">\n{\n name: ActionExecutionMessageInput[\"name\"];\n arguments: Record<string, any>;\n parentMessageId: ActionExecutionMessageInput[\"parentMessageId\"];\n constructor(props: ActionExecutionMessageConstructorOptions) {\n super(props);\n this.type = \"ActionExecutionMessage\";\n }\n}\n\ntype ResultMessageConstructorOptions = MessageConstructorOptions & ResultMessageInput;\n\nexport class ResultMessage extends Message implements ResultMessageConstructorOptions {\n actionExecutionId: ResultMessageInput[\"actionExecutionId\"];\n actionName: ResultMessageInput[\"actionName\"];\n result: ResultMessageInput[\"result\"];\n\n constructor(props: ResultMessageConstructorOptions) {\n super(props);\n this.type = \"ResultMessage\";\n }\n\n static decodeResult(result: string): any {\n return parseJson(result, result);\n }\n\n static encodeResult(result: any): string {\n if (result === undefined) {\n return \"\";\n } else if (typeof result === \"string\") {\n return result;\n } else {\n return JSON.stringify(result);\n }\n }\n}\n\nexport class AgentStateMessage extends Message implements Omit<AgentStateMessageInput, \"state\"> {\n agentName: AgentStateMessageInput[\"agentName\"];\n state: any;\n running: AgentStateMessageInput[\"running\"];\n threadId: AgentStateMessageInput[\"threadId\"];\n role: AgentStateMessageInput[\"role\"];\n nodeName: AgentStateMessageInput[\"nodeName\"];\n runId: AgentStateMessageInput[\"runId\"];\n active: AgentStateMessageInput[\"active\"];\n\n constructor(props: any) {\n super(props);\n this.type = \"AgentStateMessage\";\n }\n}\n\ntype ImageMessageConstructorOptions = MessageConstructorOptions & ImageMessageInput;\n\nexport class ImageMessage extends Message implements ImageMessageConstructorOptions {\n format: ImageMessageInput[\"format\"];\n bytes: ImageMessageInput[\"bytes\"];\n role: ImageMessageInput[\"role\"];\n parentMessageId: ImageMessageInput[\"parentMessageId\"];\n\n constructor(props: ImageMessageConstructorOptions) {\n super(props);\n this.type = \"ImageMessage\";\n }\n}\n\nexport function langGraphInterruptEvent(\n eventProps: Omit<LangGraphInterruptEvent, \"name\" | \"type\" | \"__typename\">,\n): LangGraphInterruptEvent {\n return { ...eventProps, name: MetaEventName.LangGraphInterruptEvent, type: \"MetaEvent\" };\n}\n\nexport type LangGraphInterruptEvent<TValue extends any = any> = GqlLangGraphInterruptEvent & {\n value: TValue;\n};\n\ntype CopilotKitLangGraphInterruptEvent<TValue extends any = any> =\n GqlCopilotKitLangGraphInterruptEvent & {\n data: GqlCopilotKitLangGraphInterruptEvent[\"data\"] & { value: TValue };\n };\n\nexport type MetaEvent = LangGraphInterruptEvent | CopilotKitLangGraphInterruptEvent;\n","import * as gql from \"../client\";\nimport { MessageRole } from \"../graphql/@generated/graphql\";\nimport agui from \"@copilotkit/shared\"; // named agui for clarity, but this only includes agui message types\n\n// Helper function to extract agent name from message\nfunction extractAgentName(message: agui.Message): string {\n if (message.role !== \"assistant\") {\n throw new Error(`Cannot extract agent name from message with role ${message.role}`);\n }\n\n return message.agentName || \"unknown\";\n}\n\n// Type guard for agent state message\nfunction isAgentStateMessage(message: agui.Message): boolean {\n return message.role === \"assistant\" && \"agentName\" in message && \"state\" in message;\n}\n\n// Type guard for messages with image property\nfunction hasImageProperty(message: agui.Message): boolean {\n const canContainImage = message.role === \"assistant\" || message.role === \"user\";\n if (!canContainImage || message.image === undefined) {\n return false;\n }\n\n const isMalformed = message.image.format === undefined || message.image.bytes === undefined;\n if (isMalformed) {\n return false;\n }\n\n return true;\n}\n\n/*\n ----------------------------\n AGUI Message -> GQL Message\n ----------------------------\n*/\nexport function aguiToGQL(\n messages: agui.Message[] | agui.Message,\n actions?: Record<string, any>,\n coAgentStateRenders?: Record<string, any>,\n): gql.Message[] {\n const gqlMessages: gql.Message[] = [];\n messages = Array.isArray(messages) ? messages : [messages];\n\n // Track tool call names by their IDs for use in result messages\n const toolCallNames: Record<string, string> = {};\n\n for (const message of messages) {\n // Agent state message support\n if (isAgentStateMessage(message)) {\n const agentName = extractAgentName(message);\n const state = \"state\" in message && message.state ? message.state : {};\n gqlMessages.push(\n new gql.AgentStateMessage({\n id: message.id,\n agentName,\n state,\n role: gql.Role.Assistant,\n }),\n );\n // Optionally preserve render function\n if (\"generativeUI\" in message && message.generativeUI && coAgentStateRenders) {\n coAgentStateRenders[agentName] = {\n name: agentName,\n render: message.generativeUI,\n };\n }\n continue;\n }\n\n if (hasImageProperty(message)) {\n gqlMessages.push(aguiMessageWithImageToGQLMessage(message));\n continue;\n }\n\n // Action execution message support\n if (message.role === \"assistant\" && message.toolCalls) {\n gqlMessages.push(aguiTextMessageToGQLMessage(message));\n for (const toolCall of message.toolCalls) {\n // Track the tool call name by its ID\n toolCallNames[toolCall.id] = toolCall.function.name;\n\n const actionExecMsg = aguiToolCallToGQLActionExecution(toolCall, message.id);\n // Preserve render function in actions context\n if (\"generativeUI\" in message && message.generativeUI && actions) {\n const actionName = toolCall.function.name;\n // Check for specific action first, then wild card action\n const specificAction = Object.values(actions).find(\n (action: any) => action.name === actionName,\n );\n const wildcardAction = Object.values(actions).find((action: any) => action.name === \"*\");\n\n // Assign render function to the matching action (specific takes priority)\n if (specificAction) {\n specificAction.render = message.generativeUI;\n } else if (wildcardAction) {\n wildcardAction.render = message.generativeUI;\n }\n }\n gqlMessages.push(actionExecMsg);\n }\n continue;\n }\n // Regular text messages\n if (\n message.role === \"developer\" ||\n message.role === \"system\" ||\n message.role === \"assistant\" ||\n message.role === \"user\"\n ) {\n gqlMessages.push(aguiTextMessageToGQLMessage(message));\n continue;\n }\n // Tool result message\n if (message.role === \"tool\") {\n gqlMessages.push(aguiToolMessageToGQLResultMessage(message, toolCallNames));\n continue;\n }\n throw new Error(\n `Unknown message role: \"${(message as any).role}\" in message with id: ${(message as any).id}`,\n );\n }\n\n return gqlMessages;\n}\n\nexport function aguiTextMessageToGQLMessage(message: agui.Message): gql.TextMessage {\n if (\n message.role !== \"developer\" &&\n message.role !== \"system\" &&\n message.role !== \"assistant\" &&\n message.role !== \"user\"\n ) {\n throw new Error(`Cannot convert message with role ${message.role} to TextMessage`);\n }\n\n let roleValue: MessageRole;\n\n if (message.role === \"developer\") {\n roleValue = gql.Role.Developer;\n } else if (message.role === \"system\") {\n roleValue = gql.Role.System;\n } else if (message.role === \"assistant\") {\n roleValue = gql.Role.Assistant;\n } else {\n roleValue = gql.Role.User;\n }\n\n return new gql.TextMessage({\n id: message.id,\n content: message.content || \"\",\n role: roleValue,\n });\n}\n\nexport function aguiToolCallToGQLActionExecution(\n toolCall: agui.ToolCall,\n parentMessageId: string,\n): gql.ActionExecutionMessage {\n if (toolCall.type !== \"function\") {\n throw new Error(`Unsupported tool call type: ${toolCall.type}`);\n }\n\n // Handle arguments - they should be a JSON string in AGUI format,\n // but we need to convert them to an object for GQL format\n let argumentsObj: any;\n\n if (typeof toolCall.function.arguments === \"string\") {\n // Expected case: arguments is a JSON string\n try {\n argumentsObj = JSON.parse(toolCall.function.arguments);\n } catch (error) {\n console.warn(`Failed to parse tool call arguments for ${toolCall.function.name}:`, error);\n // Provide fallback empty object to prevent application crash\n argumentsObj = {};\n }\n } else if (\n typeof toolCall.function.arguments === \"object\" &&\n toolCall.function.arguments !== null\n ) {\n // Backward compatibility: arguments is already an object\n argumentsObj = toolCall.function.arguments;\n } else {\n // Fallback for undefined, null, or other types\n console.warn(\n `Invalid tool call arguments type for ${toolCall.function.name}:`,\n typeof toolCall.function.arguments,\n );\n argumentsObj = {};\n }\n\n // Always include name and arguments\n return new gql.ActionExecutionMessage({\n id: toolCall.id,\n name: toolCall.function.name,\n arguments: argumentsObj,\n parentMessageId: parentMessageId,\n });\n}\n\nexport function aguiToolMessageToGQLResultMessage(\n message: agui.Message,\n toolCallNames: Record<string, string>,\n): gql.ResultMessage {\n if (message.role !== \"tool\") {\n throw new Error(`Cannot convert message with role ${message.role} to ResultMessage`);\n }\n\n if (!message.toolCallId) {\n throw new Error(\"Tool message must have a toolCallId\");\n }\n\n const actionName = toolCallNames[message.toolCallId] || \"unknown\";\n\n // Handle result content - it could be a string or an object that needs serialization\n let resultContent: string;\n const messageContent = message.content || \"\";\n\n if (typeof messageContent === \"string\") {\n // Expected case: content is already a string\n resultContent = messageContent;\n } else if (typeof messageContent === \"object\" && messageContent !== null) {\n // Handle case where content is an object that needs to be serialized\n try {\n resultContent = JSON.stringify(messageContent);\n } catch (error) {\n console.warn(`Failed to stringify tool result for ${actionName}:`, error);\n resultContent = String(messageContent);\n }\n } else {\n // Handle other types (number, boolean, etc.)\n resultContent = String(messageContent);\n }\n\n return new gql.ResultMessage({\n id: message.id,\n result: resultContent,\n actionExecutionId: message.toolCallId,\n actionName: message.toolName || actionName,\n });\n}\n\n// New function to handle AGUI messages with render functions\nexport function aguiMessageWithRenderToGQL(\n message: agui.Message,\n actions?: Record<string, any>,\n coAgentStateRenders?: Record<string, any>,\n): gql.Message[] {\n // Handle the special case: assistant messages with render function but no tool calls\n if (\n message.role === \"assistant\" &&\n \"generativeUI\" in message &&\n message.generativeUI &&\n !message.toolCalls\n ) {\n const gqlMessages: gql.Message[] = [];\n gqlMessages.push(\n new gql.AgentStateMessage({\n id: message.id,\n agentName: \"unknown\",\n state: {},\n role: gql.Role.Assistant,\n }),\n );\n if (coAgentStateRenders) {\n coAgentStateRenders.unknown = {\n name: \"unknown\",\n render: message.generativeUI,\n };\n }\n return gqlMessages;\n }\n\n // For all other cases, delegate to aguiToGQL\n return aguiToGQL([message], actions, coAgentStateRenders);\n}\n\nexport function aguiMessageWithImageToGQLMessage(message: agui.Message): gql.ImageMessage {\n if (!hasImageProperty(message)) {\n throw new Error(`Cannot convert message to ImageMessage: missing format or bytes`);\n }\n\n let roleValue: MessageRole;\n if (message.role === \"assistant\") {\n roleValue = gql.Role.Assistant;\n } else {\n roleValue = gql.Role.User;\n }\n\n if (message.role !== \"assistant\" && message.role !== \"user\") {\n throw new Error(`Cannot convert message with role ${message.role} to ImageMessage`);\n }\n\n return new gql.ImageMessage({\n id: message.id,\n format: message.image!.format,\n bytes: message.image!.bytes,\n role: roleValue,\n });\n}\n","import * as gql from \"../client\";\nimport agui from \"@copilotkit/shared\";\nimport { MessageStatusCode } from \"../graphql/@generated/graphql\";\n\n// Define valid image formats based on the supported formats in the codebase\nconst VALID_IMAGE_FORMATS = [\"jpeg\", \"png\", \"webp\", \"gif\"] as const;\ntype ValidImageFormat = (typeof VALID_IMAGE_FORMATS)[number];\n\n// Validation function for image format\nfunction validateImageFormat(format: string): format is ValidImageFormat {\n return VALID_IMAGE_FORMATS.includes(format as ValidImageFormat);\n}\n\n/*\n ----------------------------\n GQL Message -> AGUI Message\n ----------------------------\n*/\nexport function gqlToAGUI(\n messages: gql.Message[] | gql.Message,\n actions?: Record<string, any>,\n coAgentStateRenders?: Record<string, any>,\n): agui.Message[] {\n let aguiMessages: agui.Message[] = [];\n messages = Array.isArray(messages) ? messages : [messages];\n\n // Create a map of action execution ID to result for completed actions\n const actionResults = new Map<string, string>();\n for (const message of messages) {\n if (message.isResultMessage()) {\n actionResults.set(message.actionExecutionId, message.result);\n }\n }\n\n for (const message of messages) {\n if (message.isTextMessage()) {\n aguiMessages.push(gqlTextMessageToAGUIMessage(message));\n } else if (message.isResultMessage()) {\n aguiMessages.push(gqlResultMessageToAGUIMessage(message));\n } else if (message.isActionExecutionMessage()) {\n aguiMessages.push(gqlActionExecutionMessageToAGUIMessage(message, actions, actionResults));\n } else if (message.isAgentStateMessage()) {\n aguiMessages.push(gqlAgentStateMessageToAGUIMessage(message, coAgentStateRenders));\n } else if (message.isImageMessage()) {\n aguiMessages.push(gqlImageMessageToAGUIMessage(message));\n } else {\n throw new Error(\"Unknown message type\");\n }\n }\n\n return aguiMessages;\n}\n\nexport function gqlActionExecutionMessageToAGUIMessage(\n message: gql.ActionExecutionMessage,\n actions?: Record<string, any>,\n actionResults?: Map<string, string>,\n): agui.Message {\n // Check if we have actions and if there's a specific action or wild card action\n const hasSpecificAction =\n actions && Object.values(actions).some((action: any) => action.name === message.name);\n const hasWildcardAction =\n actions && Object.values(actions).some((action: any) => action.name === \"*\");\n\n if (!actions || (!hasSpecificAction && !hasWildcardAction)) {\n return {\n id: message.id,\n role: \"assistant\",\n toolCalls: [actionExecutionMessageToAGUIMessage(message)],\n name: message.name,\n };\n }\n\n // Find the specific action first, then fall back to wild card action\n const action =\n Object.values(actions).find((action: any) => action.name === message.name) ||\n Object.values(actions).find((action: any) => action.name === \"*\");\n\n // Create render function wrapper that provides proper props\n const createRenderWrapper = (originalRender: any) => {\n if (!originalRender) return undefined;\n\n return (props?: any) => {\n // Determine the correct status based on the same logic as RenderActionExecutionMessage\n let actionResult: any = actionResults?.get(message.id);\n let status: \"inProgress\" | \"executing\" | \"complete\" = \"inProgress\";\n\n if (actionResult !== undefined) {\n status = \"complete\";\n } else if (message.status?.code !== MessageStatusCode.Pending) {\n status = \"executing\";\n }\n\n // if props.result is a string, parse it as JSON but don't throw an error if it's not valid JSON\n if (typeof props?.result === \"string\") {\n try {\n props.result = JSON.parse(props.result);\n } catch (e) {\n /* do nothing */\n }\n }\n\n // if actionResult is a string, parse it as JSON but don't throw an error if it's not valid JSON\n if (typeof actionResult === \"string\") {\n try {\n actionResult = JSON.parse(actionResult);\n } catch (e) {\n /* do nothing */\n }\n }\n\n // Provide the full props structure that the render function expects\n const renderProps = {\n status: props?.status || status,\n args: message.arguments || {},\n result: props?.result || actionResult || undefined,\n respond: props?.respond || (() => {}),\n messageId: message.id,\n ...props,\n };\n\n return originalRender(renderProps);\n };\n };\n\n return {\n id: message.id,\n role: \"assistant\",\n content: \"\",\n toolCalls: [actionExecutionMessageToAGUIMessage(message)],\n generativeUI: createRenderWrapper(action.render),\n name: message.name,\n } as agui.AIMessage;\n}\n\nfunction gqlAgentStateMessageToAGUIMessage(\n message: gql.AgentStateMessage,\n coAgentStateRenders?: Record<string, any>,\n): agui.Message {\n if (\n coAgentStateRenders &&\n Object.values(coAgentStateRenders).some((render: any) => render.name === message.agentName)\n ) {\n const render = Object.values(coAgentStateRenders).find(\n (render: any) => render.name === message.agentName,\n );\n\n // Create render function wrapper that provides proper props\n const createRenderWrapper = (originalRender: any) => {\n if (!originalRender) return undefined;\n\n return (props?: any) => {\n // Determine the correct status based on the same logic as RenderActionExecutionMessage\n const state = message.state;\n\n // Provide the full props structure that the render function expects\n const renderProps = {\n state: state,\n };\n\n return originalRender(renderProps);\n };\n };\n\n return {\n id: message.id,\n role: \"assistant\",\n generativeUI: createRenderWrapper(render.render),\n agentName: message.agentName,\n state: message.state,\n };\n }\n\n return {\n id: message.id,\n role: \"assistant\",\n agentName: message.agentName,\n state: message.state,\n };\n}\n\nfunction actionExecutionMessageToAGUIMessage(\n actionExecutionMessage: gql.ActionExecutionMessage,\n): agui.ToolCall {\n return {\n id: actionExecutionMessage.id,\n function: {\n name: actionExecutionMessage.name,\n arguments: JSON.stringify(actionExecutionMessage.arguments),\n },\n type: \"function\",\n };\n}\n\nexport function gqlTextMessageToAGUIMessage(message: gql.TextMessage): agui.Message {\n switch (message.role) {\n case gql.Role.Developer:\n return {\n id: message.id,\n role: \"developer\",\n content: message.content,\n };\n case gql.Role.System:\n return {\n id: message.id,\n role: \"system\",\n content: message.content,\n };\n case gql.Role.Assistant:\n return {\n id: message.id,\n role: \"assistant\",\n content: message.content,\n };\n case gql.Role.User:\n return {\n id: message.id,\n role: \"user\",\n content: message.content,\n };\n default:\n throw new Error(\"Unknown message role\");\n }\n}\n\nexport function gqlResultMessageToAGUIMessage(message: gql.ResultMessage): agui.Message {\n return {\n id: message.id,\n role: \"tool\",\n content: message.result,\n toolCallId: message.actionExecutionId,\n toolName: message.actionName,\n };\n}\n\nexport function gqlImageMessageToAGUIMessage(message: gql.ImageMessage): agui.Message {\n // Validate image format\n if (!validateImageFormat(message.format)) {\n throw new Error(\n `Invalid image format: ${message.format}. Supported formats are: ${VALID_IMAGE_FORMATS.join(\", \")}`,\n );\n }\n\n // Validate that bytes is a non-empty string\n if (!message.bytes || typeof message.bytes !== \"string\" || message.bytes.trim() === \"\") {\n throw new Error(\"Image bytes must be a non-empty string\");\n }\n\n // Determine the role based on the message role\n const role = message.role === gql.Role.Assistant ? \"assistant\" : \"user\";\n\n // Create the image message with proper typing\n const imageMessage: agui.Message = {\n id: message.id,\n role,\n content: \"\",\n image: {\n format: message.format,\n bytes: message.bytes,\n },\n };\n\n return imageMessage;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACyRO,IAAK,cAAL,kBAAKA,iBAAL;AACL,EAAAA,aAAA,eAAY;AACZ,EAAAA,aAAA,eAAY;AACZ,EAAAA,aAAA,YAAS;AACT,EAAAA,aAAA,UAAO;AACP,EAAAA,aAAA,UAAO;AALG,SAAAA;AAAA,GAAA;;;ACzRZ,oBAAyB;AAezB,IAAAC,iBAA0B;AASnB,IAAM,UAAN,MAAc;AAAA,EAMnB,Y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QAAQ;AAAA,IACjB;AAAA,EACF;AAEA,SAAO;AACT;","names":["MessageRole","import_shared","action","render"]}
@@ -6,16 +6,16 @@ import {
6
6
  aguiToGQL,
7
7
  aguiToolCallToGQLActionExecution,
8
8
  aguiToolMessageToGQLResultMessage
9
- } from "../chunk-7OSRQ2O3.mjs";
9
+ } from "../chunk-SCACOKQX.mjs";
10
10
  import {
11
11
  gqlActionExecutionMessageToAGUIMessage,
12
12
  gqlImageMessageToAGUIMessage,
13
13
  gqlResultMessageToAGUIMessage,
14
14
  gqlTextMessageToAGUIMessage,
15
15
  gqlToAGUI
16
- } from "../chunk-IGXWE4TX.mjs";
16
+ } from "../chunk-ZYA32QXZ.mjs";
17
17
  import "../chunk-7ECCT6PK.mjs";
18
- import "../chunk-AES3X7TL.mjs";
18
+ import "../chunk-23JYINXK.mjs";
19
19
  import "../chunk-X2UAP3QY.mjs";
20
20
  import "../chunk-HEODM5TW.mjs";
21
21
  import "../chunk-4KTMZMM2.mjs";
@@ -19066,10 +19066,20 @@ function aguiToolCallToGQLActionExecution(toolCall, parentMessageId) {
19066
19066
  throw new Error(`Unsupported tool call type: ${toolCall.type}`);
19067
19067
  }
19068
19068
  let argumentsObj;
19069
- try {
19070
- argumentsObj = JSON.parse(toolCall.function.arguments);
19071
- } catch (error) {
19072
- console.warn(`Failed to parse tool call arguments for ${toolCall.function.name}:`, error);
19069
+ if (typeof toolCall.function.arguments === "string") {
19070
+ try {
19071
+ argumentsObj = JSON.parse(toolCall.function.arguments);
19072
+ } catch (error) {
19073
+ console.warn(`Failed to parse tool call arguments for ${toolCall.function.name}:`, error);
19074
+ argumentsObj = {};
19075
+ }
19076
+ } else if (typeof toolCall.function.arguments === "object" && toolCall.function.arguments !== null) {
19077
+ argumentsObj = toolCall.function.arguments;
19078
+ } else {
19079
+ console.warn(
19080
+ `Invalid tool call arguments type for ${toolCall.function.name}:`,
19081
+ typeof toolCall.function.arguments
19082
+ );
19073
19083
  argumentsObj = {};
19074
19084
  }
19075
19085
  return new ActionExecutionMessage({
@@ -19087,9 +19097,23 @@ function aguiToolMessageToGQLResultMessage(message, toolCallNames) {
19087
19097
  throw new Error("Tool message must have a toolCallId");
19088
19098
  }
19089
19099
  const actionName = toolCallNames[message.toolCallId] || "unknown";
19100
+ let resultContent;
19101
+ const messageContent = message.content || "";
19102
+ if (typeof messageContent === "string") {
19103
+ resultContent = messageContent;
19104
+ } else if (typeof messageContent === "object" && messageContent !== null) {
19105
+ try {
19106
+ resultContent = JSON.stringify(messageContent);
19107
+ } catch (error) {
19108
+ console.warn(`Failed to stringify tool result for ${actionName}:`, error);
19109
+ resultContent = String(messageContent);
19110
+ }
19111
+ } else {
19112
+ resultContent = String(messageContent);
19113
+ }
19090
19114
  return new ResultMessage({
19091
19115
  id: message.id,
19092
- result: message.content || "",
19116
+ result: resultContent,
19093
19117
  actionExecutionId: message.toolCallId,
19094
19118
  actionName: message.toolName || actionName
19095
19119
  });
@@ -19163,13 +19187,25 @@ function gqlActionExecutionMessageToAGUIMessage(message, actions, actionResults)
19163
19187
  return void 0;
19164
19188
  return (props) => {
19165
19189
  var _a3;
19166
- const actionResult = actionResults == null ? void 0 : actionResults.get(message.id);
19190
+ let actionResult = actionResults == null ? void 0 : actionResults.get(message.id);
19167
19191
  let status = "inProgress";
19168
19192
  if (actionResult !== void 0) {
19169
19193
  status = "complete";
19170
19194
  } else if (((_a3 = message.status) == null ? void 0 : _a3.code) !== "Pending" /* Pending */) {
19171
19195
  status = "executing";
19172
19196
  }
19197
+ if (typeof (props == null ? void 0 : props.result) === "string") {
19198
+ try {
19199
+ props.result = JSON.parse(props.result);
19200
+ } catch (e) {
19201
+ }
19202
+ }
19203
+ if (typeof actionResult === "string") {
19204
+ try {
19205
+ actionResult = JSON.parse(actionResult);
19206
+ } catch (e) {
19207
+ }
19208
+ }
19173
19209
  const renderProps = {
19174
19210
  status: (props == null ? void 0 : props.status) || status,
19175
19211
  args: message.arguments || {},
@@ -19575,6 +19611,83 @@ describe("roundtrip message conversion", () => {
19575
19611
  globalExpect(gqlMsgs2[1].name).toBe("unknownAction");
19576
19612
  globalExpect(gqlMsgs2[1].arguments).toEqual({ test: "wildcard-gql-value" });
19577
19613
  });
19614
+ test3("roundtrip conversion with result parsing edge cases", () => {
19615
+ const toolResultMsg = {
19616
+ id: "tool-result-json",
19617
+ role: "tool",
19618
+ content: '{"status": "success", "data": {"value": 42}}',
19619
+ toolCallId: "tool-call-json",
19620
+ toolName: "jsonAction"
19621
+ };
19622
+ const gqlMsgs = aguiToGQL(toolResultMsg);
19623
+ const aguiMsgs = gqlToAGUI(gqlMsgs);
19624
+ globalExpect(gqlMsgs).toHaveLength(1);
19625
+ globalExpect(gqlMsgs[0]).toBeInstanceOf(ResultMessage);
19626
+ globalExpect(gqlMsgs[0].result).toBe('{"status": "success", "data": {"value": 42}}');
19627
+ globalExpect(aguiMsgs).toHaveLength(1);
19628
+ globalExpect(aguiMsgs[0].role).toBe("tool");
19629
+ globalExpect(aguiMsgs[0].content).toBe('{"status": "success", "data": {"value": 42}}');
19630
+ });
19631
+ test3("roundtrip conversion with object content in tool results", () => {
19632
+ const toolResultMsg = {
19633
+ id: "tool-result-object",
19634
+ role: "tool",
19635
+ content: { status: "success", data: { value: 42 } },
19636
+ toolCallId: "tool-call-object",
19637
+ toolName: "objectAction"
19638
+ };
19639
+ const gqlMsgs = aguiToGQL(toolResultMsg);
19640
+ const aguiMsgs = gqlToAGUI(gqlMsgs);
19641
+ globalExpect(gqlMsgs).toHaveLength(1);
19642
+ globalExpect(gqlMsgs[0]).toBeInstanceOf(ResultMessage);
19643
+ globalExpect(gqlMsgs[0].result).toBe('{"status":"success","data":{"value":42}}');
19644
+ globalExpect(aguiMsgs).toHaveLength(1);
19645
+ globalExpect(aguiMsgs[0].role).toBe("tool");
19646
+ globalExpect(aguiMsgs[0].content).toBe('{"status":"success","data":{"value":42}}');
19647
+ });
19648
+ test3("roundtrip conversion with action execution and result parsing", () => {
19649
+ const mockRender = vi.fn((props) => `Rendered: ${JSON.stringify(props.result)}`);
19650
+ const actionExecMsg = new ActionExecutionMessage({
19651
+ id: "action-with-result",
19652
+ name: "testAction",
19653
+ arguments: { input: "test-value" },
19654
+ parentMessageId: "parent-result"
19655
+ });
19656
+ const resultMsg = new ResultMessage({
19657
+ id: "result-with-json",
19658
+ result: '{"output": "processed", "count": 5}',
19659
+ actionExecutionId: "action-with-result",
19660
+ actionName: "testAction"
19661
+ });
19662
+ const actions = {
19663
+ testAction: {
19664
+ name: "testAction",
19665
+ render: mockRender
19666
+ }
19667
+ };
19668
+ const aguiMsgs = gqlToAGUI([actionExecMsg, resultMsg], actions);
19669
+ globalExpect(aguiMsgs).toHaveLength(2);
19670
+ globalExpect(aguiMsgs[0].role).toBe("assistant");
19671
+ globalExpect("generativeUI" in aguiMsgs[0]).toBe(true);
19672
+ globalExpect(aguiMsgs[1].role).toBe("tool");
19673
+ globalExpect(aguiMsgs[1].content).toBe('{"output": "processed", "count": 5}');
19674
+ if ("generativeUI" in aguiMsgs[0] && aguiMsgs[0].generativeUI) {
19675
+ aguiMsgs[0].generativeUI({ result: '{"parsed": true}' });
19676
+ globalExpect(mockRender).toHaveBeenCalledWith(
19677
+ globalExpect.objectContaining({
19678
+ result: { parsed: true }
19679
+ // Should be parsed from string
19680
+ })
19681
+ );
19682
+ }
19683
+ const gqlMsgs2 = aguiToGQL(aguiMsgs, actions);
19684
+ globalExpect(gqlMsgs2).toHaveLength(3);
19685
+ globalExpect(gqlMsgs2[0]).toBeInstanceOf(TextMessage);
19686
+ globalExpect(gqlMsgs2[1]).toBeInstanceOf(ActionExecutionMessage);
19687
+ globalExpect(gqlMsgs2[2]).toBeInstanceOf(ResultMessage);
19688
+ globalExpect(gqlMsgs2[1].arguments).toEqual({ input: "test-value" });
19689
+ globalExpect(gqlMsgs2[2].result).toBe('{"output": "processed", "count": 5}');
19690
+ });
19578
19691
  });
19579
19692
  /*! Bundled license information:
19580
19693