@copilotkit/runtime-client-gql 0.0.0-mme-load-agent-state-20250117154700

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 (92) hide show
  1. package/CHANGELOG.md +937 -0
  2. package/README.md +46 -0
  3. package/codegen.ts +22 -0
  4. package/dist/chunk-7ECCT6PK.mjs +1 -0
  5. package/dist/chunk-7ECCT6PK.mjs.map +1 -0
  6. package/dist/chunk-BBNGLVX5.mjs +38 -0
  7. package/dist/chunk-BBNGLVX5.mjs.map +1 -0
  8. package/dist/chunk-GQ2BQR46.mjs +119 -0
  9. package/dist/chunk-GQ2BQR46.mjs.map +1 -0
  10. package/dist/chunk-JGGSE6H3.mjs +20 -0
  11. package/dist/chunk-JGGSE6H3.mjs.map +1 -0
  12. package/dist/chunk-LBECNDL5.mjs +56 -0
  13. package/dist/chunk-LBECNDL5.mjs.map +1 -0
  14. package/dist/chunk-MLWD2EGY.mjs +200 -0
  15. package/dist/chunk-MLWD2EGY.mjs.map +1 -0
  16. package/dist/chunk-RHAQH56F.mjs +84 -0
  17. package/dist/chunk-RHAQH56F.mjs.map +1 -0
  18. package/dist/chunk-RIPDMDI6.mjs +77 -0
  19. package/dist/chunk-RIPDMDI6.mjs.map +1 -0
  20. package/dist/chunk-XZPL6QVK.mjs +24 -0
  21. package/dist/chunk-XZPL6QVK.mjs.map +1 -0
  22. package/dist/client/CopilotRuntimeClient.d.ts +37 -0
  23. package/dist/client/CopilotRuntimeClient.js +251 -0
  24. package/dist/client/CopilotRuntimeClient.js.map +1 -0
  25. package/dist/client/CopilotRuntimeClient.mjs +11 -0
  26. package/dist/client/CopilotRuntimeClient.mjs.map +1 -0
  27. package/dist/client/conversion.d.ts +11 -0
  28. package/dist/client/conversion.js +296 -0
  29. package/dist/client/conversion.js.map +1 -0
  30. package/dist/client/conversion.mjs +17 -0
  31. package/dist/client/conversion.mjs.map +1 -0
  32. package/dist/client/index.d.ts +8 -0
  33. package/dist/client/index.js +541 -0
  34. package/dist/client/index.js.map +1 -0
  35. package/dist/client/index.mjs +38 -0
  36. package/dist/client/index.mjs.map +1 -0
  37. package/dist/client/types.d.ts +55 -0
  38. package/dist/client/types.js +113 -0
  39. package/dist/client/types.js.map +1 -0
  40. package/dist/client/types.mjs +18 -0
  41. package/dist/client/types.mjs.map +1 -0
  42. package/dist/graphql/@generated/fragment-masking.d.ts +22 -0
  43. package/dist/graphql/@generated/fragment-masking.js +50 -0
  44. package/dist/graphql/@generated/fragment-masking.js.map +1 -0
  45. package/dist/graphql/@generated/fragment-masking.mjs +11 -0
  46. package/dist/graphql/@generated/fragment-masking.mjs.map +1 -0
  47. package/dist/graphql/@generated/gql.d.ts +53 -0
  48. package/dist/graphql/@generated/gql.js +45 -0
  49. package/dist/graphql/@generated/gql.js.map +1 -0
  50. package/dist/graphql/@generated/gql.mjs +8 -0
  51. package/dist/graphql/@generated/gql.mjs.map +1 -0
  52. package/dist/graphql/@generated/graphql.d.ts +477 -0
  53. package/dist/graphql/@generated/graphql.js +88 -0
  54. package/dist/graphql/@generated/graphql.js.map +1 -0
  55. package/dist/graphql/@generated/graphql.mjs +23 -0
  56. package/dist/graphql/@generated/graphql.mjs.map +1 -0
  57. package/dist/graphql/@generated/index.d.ts +4 -0
  58. package/dist/graphql/@generated/index.js +69 -0
  59. package/dist/graphql/@generated/index.js.map +1 -0
  60. package/dist/graphql/@generated/index.mjs +16 -0
  61. package/dist/graphql/@generated/index.mjs.map +1 -0
  62. package/dist/graphql/definitions/mutations.d.ts +9 -0
  63. package/dist/graphql/definitions/mutations.js +121 -0
  64. package/dist/graphql/definitions/mutations.js.map +1 -0
  65. package/dist/graphql/definitions/mutations.mjs +9 -0
  66. package/dist/graphql/definitions/mutations.mjs.map +1 -0
  67. package/dist/graphql/definitions/queries.d.ts +11 -0
  68. package/dist/graphql/definitions/queries.js +76 -0
  69. package/dist/graphql/definitions/queries.js.map +1 -0
  70. package/dist/graphql/definitions/queries.mjs +11 -0
  71. package/dist/graphql/definitions/queries.mjs.map +1 -0
  72. package/dist/index.d.ts +8 -0
  73. package/dist/index.js +591 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/index.mjs +57 -0
  76. package/dist/index.mjs.map +1 -0
  77. package/jest.config.js +5 -0
  78. package/package.json +77 -0
  79. package/src/client/CopilotRuntimeClient.ts +150 -0
  80. package/src/client/conversion.ts +211 -0
  81. package/src/client/index.ts +10 -0
  82. package/src/client/types.ts +127 -0
  83. package/src/graphql/@generated/fragment-masking.ts +87 -0
  84. package/src/graphql/@generated/gql.ts +52 -0
  85. package/src/graphql/@generated/graphql.ts +366 -0
  86. package/src/graphql/@generated/index.ts +2 -0
  87. package/src/graphql/definitions/mutations.ts +73 -0
  88. package/src/graphql/definitions/queries.ts +24 -0
  89. package/src/index.ts +2 -0
  90. package/tsconfig.json +16 -0
  91. package/tsup.config.ts +33 -0
  92. package/typedoc.json +4 -0
@@ -0,0 +1,211 @@
1
+ import {
2
+ GenerateCopilotResponseMutation,
3
+ MessageInput,
4
+ MessageStatusCode,
5
+ } from "../graphql/@generated/graphql";
6
+ import {
7
+ ActionExecutionMessage,
8
+ AgentStateMessage,
9
+ Message,
10
+ ResultMessage,
11
+ TextMessage,
12
+ } from "./types";
13
+
14
+ import untruncateJson from "untruncate-json";
15
+
16
+ export function filterAgentStateMessages(messages: Message[]): Message[] {
17
+ return messages.filter((message) => !message.isAgentStateMessage());
18
+ }
19
+
20
+ export function convertMessagesToGqlInput(messages: Message[]): MessageInput[] {
21
+ return messages.map((message) => {
22
+ if (message.isTextMessage()) {
23
+ return {
24
+ id: message.id,
25
+ createdAt: message.createdAt,
26
+ textMessage: {
27
+ content: message.content,
28
+ role: message.role as any,
29
+ parentMessageId: message.parentMessageId,
30
+ },
31
+ };
32
+ } else if (message.isActionExecutionMessage()) {
33
+ return {
34
+ id: message.id,
35
+ createdAt: message.createdAt,
36
+ actionExecutionMessage: {
37
+ name: message.name,
38
+ arguments: JSON.stringify(message.arguments),
39
+ parentMessageId: message.parentMessageId,
40
+ },
41
+ };
42
+ } else if (message.isResultMessage()) {
43
+ return {
44
+ id: message.id,
45
+ createdAt: message.createdAt,
46
+ resultMessage: {
47
+ result: message.result,
48
+ actionExecutionId: message.actionExecutionId,
49
+ actionName: message.actionName,
50
+ },
51
+ };
52
+ } else if (message.isAgentStateMessage()) {
53
+ return {
54
+ id: message.id,
55
+ createdAt: message.createdAt,
56
+ agentStateMessage: {
57
+ threadId: message.threadId,
58
+ role: message.role,
59
+ agentName: message.agentName,
60
+ nodeName: message.nodeName,
61
+ runId: message.runId,
62
+ active: message.active,
63
+ running: message.running,
64
+ state: JSON.stringify(message.state),
65
+ },
66
+ };
67
+ } else {
68
+ throw new Error("Unknown message type");
69
+ }
70
+ });
71
+ }
72
+
73
+ export function filterAdjacentAgentStateMessages(
74
+ messages: GenerateCopilotResponseMutation["generateCopilotResponse"]["messages"],
75
+ ): GenerateCopilotResponseMutation["generateCopilotResponse"]["messages"] {
76
+ const filteredMessages: GenerateCopilotResponseMutation["generateCopilotResponse"]["messages"] =
77
+ [];
78
+
79
+ messages.forEach((message, i) => {
80
+ // keep all other message types
81
+ if (message.__typename !== "AgentStateMessageOutput") {
82
+ filteredMessages.push(message);
83
+ } else {
84
+ const prevAgentStateMessageIndex = filteredMessages.findIndex(
85
+ // TODO: also check runId
86
+ (m) => m.__typename === "AgentStateMessageOutput" && m.agentName === message.agentName,
87
+ );
88
+ if (prevAgentStateMessageIndex === -1) {
89
+ filteredMessages.push(message);
90
+ } else {
91
+ filteredMessages[prevAgentStateMessageIndex] = message;
92
+ }
93
+ }
94
+ });
95
+
96
+ return filteredMessages;
97
+ }
98
+
99
+ export function convertGqlOutputToMessages(
100
+ messages: GenerateCopilotResponseMutation["generateCopilotResponse"]["messages"],
101
+ ): Message[] {
102
+ return messages.map((message) => {
103
+ if (message.__typename === "TextMessageOutput") {
104
+ return new TextMessage({
105
+ id: message.id,
106
+ role: message.role,
107
+ content: message.content.join(""),
108
+ parentMessageId: message.parentMessageId,
109
+ createdAt: new Date(),
110
+ status: message.status || { code: MessageStatusCode.Pending },
111
+ });
112
+ } else if (message.__typename === "ActionExecutionMessageOutput") {
113
+ return new ActionExecutionMessage({
114
+ id: message.id,
115
+ name: message.name,
116
+ arguments: getPartialArguments(message.arguments),
117
+ parentMessageId: message.parentMessageId,
118
+ createdAt: new Date(),
119
+ status: message.status || { code: MessageStatusCode.Pending },
120
+ });
121
+ } else if (message.__typename === "ResultMessageOutput") {
122
+ return new ResultMessage({
123
+ id: message.id,
124
+ result: message.result,
125
+ actionExecutionId: message.actionExecutionId,
126
+ actionName: message.actionName,
127
+ createdAt: new Date(),
128
+ status: message.status || { code: MessageStatusCode.Pending },
129
+ });
130
+ } else if (message.__typename === "AgentStateMessageOutput") {
131
+ return new AgentStateMessage({
132
+ id: message.id,
133
+ threadId: message.threadId,
134
+ role: message.role,
135
+ agentName: message.agentName,
136
+ nodeName: message.nodeName,
137
+ runId: message.runId,
138
+ active: message.active,
139
+ running: message.running,
140
+ state: JSON.parse(message.state),
141
+ createdAt: new Date(),
142
+ });
143
+ }
144
+
145
+ throw new Error("Unknown message type");
146
+ });
147
+ }
148
+
149
+ export function loadMessagesFromJsonRepresentation(json: any[]): Message[] {
150
+ const result: Message[] = [];
151
+ for (const item of json) {
152
+ if ("content" in item) {
153
+ result.push(
154
+ new TextMessage({
155
+ id: item.id,
156
+ role: item.role,
157
+ content: item.content,
158
+ parentMessageId: item.parentMessageId,
159
+ createdAt: item.createdAt || new Date(),
160
+ status: item.status || { code: MessageStatusCode.Success },
161
+ }),
162
+ );
163
+ } else if ("arguments" in item) {
164
+ result.push(
165
+ new ActionExecutionMessage({
166
+ id: item.id,
167
+ name: item.name,
168
+ arguments: item.arguments,
169
+ parentMessageId: item.parentMessageId,
170
+ createdAt: item.createdAt || new Date(),
171
+ status: item.status || { code: MessageStatusCode.Success },
172
+ }),
173
+ );
174
+ } else if ("result" in item) {
175
+ result.push(
176
+ new ResultMessage({
177
+ id: item.id,
178
+ result: item.result,
179
+ actionExecutionId: item.actionExecutionId,
180
+ actionName: item.actionName,
181
+ createdAt: item.createdAt || new Date(),
182
+ status: item.status || { code: MessageStatusCode.Success },
183
+ }),
184
+ );
185
+ } else if ("state" in item) {
186
+ result.push(
187
+ new AgentStateMessage({
188
+ id: item.id,
189
+ threadId: item.threadId,
190
+ role: item.role,
191
+ agentName: item.agentName,
192
+ nodeName: item.nodeName,
193
+ runId: item.runId,
194
+ active: item.active,
195
+ running: item.running,
196
+ state: item.state,
197
+ createdAt: item.createdAt || new Date(),
198
+ }),
199
+ );
200
+ }
201
+ }
202
+ return result;
203
+ }
204
+
205
+ function getPartialArguments(args: string[]) {
206
+ try {
207
+ return JSON.parse(untruncateJson(args.join("")));
208
+ } catch (e) {
209
+ return {};
210
+ }
211
+ }
@@ -0,0 +1,10 @@
1
+ export * from "./CopilotRuntimeClient";
2
+ export {
3
+ convertMessagesToGqlInput,
4
+ convertGqlOutputToMessages,
5
+ filterAdjacentAgentStateMessages,
6
+ filterAgentStateMessages,
7
+ loadMessagesFromJsonRepresentation,
8
+ } from "./conversion";
9
+ export * from "./types";
10
+ export type { GraphQLError } from "graphql";
@@ -0,0 +1,127 @@
1
+ import { randomId } from "@copilotkit/shared";
2
+ import {
3
+ ActionExecutionMessageInput,
4
+ MessageRole,
5
+ MessageStatus,
6
+ ResultMessageInput,
7
+ TextMessageInput,
8
+ BaseMessageOutput,
9
+ AgentStateMessageInput,
10
+ MessageStatusCode,
11
+ } from "../graphql/@generated/graphql";
12
+
13
+ type MessageType = "TextMessage" | "ActionExecutionMessage" | "ResultMessage" | "AgentStateMessage";
14
+
15
+ export class Message {
16
+ type: MessageType;
17
+ id: BaseMessageOutput["id"];
18
+ createdAt: BaseMessageOutput["createdAt"];
19
+ status: MessageStatus;
20
+
21
+ constructor(props: any) {
22
+ props.id ??= randomId();
23
+ props.status ??= { code: MessageStatusCode.Success };
24
+ props.createdAt ??= new Date();
25
+ Object.assign(this, props);
26
+ }
27
+
28
+ isTextMessage(): this is TextMessage {
29
+ return this.type === "TextMessage";
30
+ }
31
+
32
+ isActionExecutionMessage(): this is ActionExecutionMessage {
33
+ return this.type === "ActionExecutionMessage";
34
+ }
35
+
36
+ isResultMessage(): this is ResultMessage {
37
+ return this.type === "ResultMessage";
38
+ }
39
+
40
+ isAgentStateMessage(): this is AgentStateMessage {
41
+ return this.type === "AgentStateMessage";
42
+ }
43
+ }
44
+
45
+ // alias Role to MessageRole
46
+ export const Role = MessageRole;
47
+
48
+ // when constructing any message, the base fields are optional
49
+ type MessageConstructorOptions = Partial<Message>;
50
+
51
+ type TextMessageConstructorOptions = MessageConstructorOptions & TextMessageInput;
52
+
53
+ export class TextMessage extends Message implements TextMessageConstructorOptions {
54
+ role: TextMessageInput["role"];
55
+ content: TextMessageInput["content"];
56
+ parentMessageId: TextMessageInput["parentMessageId"];
57
+
58
+ constructor(props: TextMessageConstructorOptions) {
59
+ super(props);
60
+ this.type = "TextMessage";
61
+ }
62
+ }
63
+
64
+ type ActionExecutionMessageConstructorOptions = MessageConstructorOptions &
65
+ Omit<ActionExecutionMessageInput, "arguments"> & {
66
+ arguments: Record<string, any>;
67
+ };
68
+
69
+ export class ActionExecutionMessage
70
+ extends Message
71
+ implements Omit<ActionExecutionMessageInput, "arguments" | "scope">
72
+ {
73
+ name: ActionExecutionMessageInput["name"];
74
+ arguments: Record<string, any>;
75
+ parentMessageId: ActionExecutionMessageInput["parentMessageId"];
76
+ constructor(props: ActionExecutionMessageConstructorOptions) {
77
+ super(props);
78
+ this.type = "ActionExecutionMessage";
79
+ }
80
+ }
81
+
82
+ type ResultMessageConstructorOptions = MessageConstructorOptions & ResultMessageInput;
83
+
84
+ export class ResultMessage extends Message implements ResultMessageConstructorOptions {
85
+ actionExecutionId: ResultMessageInput["actionExecutionId"];
86
+ actionName: ResultMessageInput["actionName"];
87
+ result: ResultMessageInput["result"];
88
+
89
+ constructor(props: ResultMessageConstructorOptions) {
90
+ super(props);
91
+ this.type = "ResultMessage";
92
+ }
93
+
94
+ static decodeResult(result: string): any {
95
+ try {
96
+ return JSON.parse(result);
97
+ } catch (e) {
98
+ return result;
99
+ }
100
+ }
101
+
102
+ static encodeResult(result: any): string {
103
+ if (result === undefined) {
104
+ return "";
105
+ } else if (typeof result === "string") {
106
+ return result;
107
+ } else {
108
+ return JSON.stringify(result);
109
+ }
110
+ }
111
+ }
112
+
113
+ export class AgentStateMessage extends Message implements Omit<AgentStateMessageInput, "state"> {
114
+ agentName: AgentStateMessageInput["agentName"];
115
+ state: any;
116
+ running: AgentStateMessageInput["running"];
117
+ threadId: AgentStateMessageInput["threadId"];
118
+ role: AgentStateMessageInput["role"];
119
+ nodeName: AgentStateMessageInput["nodeName"];
120
+ runId: AgentStateMessageInput["runId"];
121
+ active: AgentStateMessageInput["active"];
122
+
123
+ constructor(props: any) {
124
+ super(props);
125
+ this.type = "AgentStateMessage";
126
+ }
127
+ }
@@ -0,0 +1,87 @@
1
+ /* eslint-disable */
2
+ import type { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
3
+ import type { FragmentDefinitionNode } from 'graphql';
4
+ import type { Incremental } from './graphql';
5
+
6
+
7
+ export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<
8
+ infer TType,
9
+ any
10
+ >
11
+ ? [TType] extends [{ ' $fragmentName'?: infer TKey }]
12
+ ? TKey extends string
13
+ ? { ' $fragmentRefs'?: { [key in TKey]: TType } }
14
+ : never
15
+ : never
16
+ : never;
17
+
18
+ // return non-nullable if `fragmentType` is non-nullable
19
+ export function useFragment<TType>(
20
+ _documentNode: DocumentTypeDecoration<TType, any>,
21
+ fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>
22
+ ): TType;
23
+ // return nullable if `fragmentType` is undefined
24
+ export function useFragment<TType>(
25
+ _documentNode: DocumentTypeDecoration<TType, any>,
26
+ fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | undefined
27
+ ): TType | undefined;
28
+ // return nullable if `fragmentType` is nullable
29
+ export function useFragment<TType>(
30
+ _documentNode: DocumentTypeDecoration<TType, any>,
31
+ fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null
32
+ ): TType | null;
33
+ // return nullable if `fragmentType` is nullable or undefined
34
+ export function useFragment<TType>(
35
+ _documentNode: DocumentTypeDecoration<TType, any>,
36
+ fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined
37
+ ): TType | null | undefined;
38
+ // return array of non-nullable if `fragmentType` is array of non-nullable
39
+ export function useFragment<TType>(
40
+ _documentNode: DocumentTypeDecoration<TType, any>,
41
+ fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>>
42
+ ): Array<TType>;
43
+ // return array of nullable if `fragmentType` is array of nullable
44
+ export function useFragment<TType>(
45
+ _documentNode: DocumentTypeDecoration<TType, any>,
46
+ fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
47
+ ): Array<TType> | null | undefined;
48
+ // return readonly array of non-nullable if `fragmentType` is array of non-nullable
49
+ export function useFragment<TType>(
50
+ _documentNode: DocumentTypeDecoration<TType, any>,
51
+ fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
52
+ ): ReadonlyArray<TType>;
53
+ // return readonly array of nullable if `fragmentType` is array of nullable
54
+ export function useFragment<TType>(
55
+ _documentNode: DocumentTypeDecoration<TType, any>,
56
+ fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
57
+ ): ReadonlyArray<TType> | null | undefined;
58
+ export function useFragment<TType>(
59
+ _documentNode: DocumentTypeDecoration<TType, any>,
60
+ fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | Array<FragmentType<DocumentTypeDecoration<TType, any>>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
61
+ ): TType | Array<TType> | ReadonlyArray<TType> | null | undefined {
62
+ return fragmentType as any;
63
+ }
64
+
65
+
66
+ export function makeFragmentData<
67
+ F extends DocumentTypeDecoration<any, any>,
68
+ FT extends ResultOf<F>
69
+ >(data: FT, _fragment: F): FragmentType<F> {
70
+ return data as FragmentType<F>;
71
+ }
72
+ export function isFragmentReady<TQuery, TFrag>(
73
+ queryNode: DocumentTypeDecoration<TQuery, any>,
74
+ fragmentNode: TypedDocumentNode<TFrag>,
75
+ data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined
76
+ ): data is FragmentType<typeof fragmentNode> {
77
+ const deferredFields = (queryNode as { __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> } }).__meta__
78
+ ?.deferredFields;
79
+
80
+ if (!deferredFields) return true;
81
+
82
+ const fragDef = fragmentNode.definitions[0] as FragmentDefinitionNode | undefined;
83
+ const fragName = fragDef?.name?.value;
84
+
85
+ const fields = (fragName && deferredFields[fragName]) || [];
86
+ return fields.length > 0 && fields.every(field => data && field in data);
87
+ }
@@ -0,0 +1,52 @@
1
+ /* eslint-disable */
2
+ import * as types from './graphql';
3
+ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
4
+
5
+ /**
6
+ * Map of all GraphQL operations in the project.
7
+ *
8
+ * This map has several performance disadvantages:
9
+ * 1. It is not tree-shakeable, so it will include all operations in the project.
10
+ * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.
11
+ * 3. It does not support dead code elimination, so it will add unused operations.
12
+ *
13
+ * Therefore it is highly recommended to use the babel or swc plugin for production.
14
+ */
15
+ const documents = {
16
+ "\n mutation generateCopilotResponse($data: GenerateCopilotResponseInput!, $properties: JSONObject) {\n generateCopilotResponse(data: $data, properties: $properties) {\n threadId\n runId\n extensions {\n openaiAssistantAPI {\n runId\n threadId\n }\n }\n ... on CopilotResponse @defer {\n status {\n ... on BaseResponseStatus {\n code\n }\n ... on FailedResponseStatus {\n reason\n details\n }\n }\n }\n messages @stream {\n __typename\n ... on BaseMessageOutput {\n id\n createdAt\n }\n ... on BaseMessageOutput @defer {\n status {\n ... on SuccessMessageStatus {\n code\n }\n ... on FailedMessageStatus {\n code\n reason\n }\n ... on PendingMessageStatus {\n code\n }\n }\n }\n ... on TextMessageOutput {\n content @stream\n role\n parentMessageId\n }\n ... on ActionExecutionMessageOutput {\n name\n arguments @stream\n parentMessageId\n }\n ... on ResultMessageOutput {\n result\n actionExecutionId\n actionName\n }\n ... on AgentStateMessageOutput {\n threadId\n state\n running\n agentName\n nodeName\n runId\n active\n role\n }\n }\n }\n }\n": types.GenerateCopilotResponseDocument,
17
+ "\n query availableAgents {\n availableAgents {\n agents {\n name\n id\n description\n }\n }\n }\n": types.AvailableAgentsDocument,
18
+ "\n query loadAgentState($data: LoadAgentStateInput!) {\n loadAgentState(data: $data) {\n threadId\n threadExists\n state\n messages\n }\n }\n": types.LoadAgentStateDocument,
19
+ };
20
+
21
+ /**
22
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
23
+ *
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
28
+ * ```
29
+ *
30
+ * The query argument is unknown!
31
+ * Please regenerate the types.
32
+ */
33
+ export function graphql(source: string): unknown;
34
+
35
+ /**
36
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
37
+ */
38
+ export function graphql(source: "\n mutation generateCopilotResponse($data: GenerateCopilotResponseInput!, $properties: JSONObject) {\n generateCopilotResponse(data: $data, properties: $properties) {\n threadId\n runId\n extensions {\n openaiAssistantAPI {\n runId\n threadId\n }\n }\n ... on CopilotResponse @defer {\n status {\n ... on BaseResponseStatus {\n code\n }\n ... on FailedResponseStatus {\n reason\n details\n }\n }\n }\n messages @stream {\n __typename\n ... on BaseMessageOutput {\n id\n createdAt\n }\n ... on BaseMessageOutput @defer {\n status {\n ... on SuccessMessageStatus {\n code\n }\n ... on FailedMessageStatus {\n code\n reason\n }\n ... on PendingMessageStatus {\n code\n }\n }\n }\n ... on TextMessageOutput {\n content @stream\n role\n parentMessageId\n }\n ... on ActionExecutionMessageOutput {\n name\n arguments @stream\n parentMessageId\n }\n ... on ResultMessageOutput {\n result\n actionExecutionId\n actionName\n }\n ... on AgentStateMessageOutput {\n threadId\n state\n running\n agentName\n nodeName\n runId\n active\n role\n }\n }\n }\n }\n"): (typeof documents)["\n mutation generateCopilotResponse($data: GenerateCopilotResponseInput!, $properties: JSONObject) {\n generateCopilotResponse(data: $data, properties: $properties) {\n threadId\n runId\n extensions {\n openaiAssistantAPI {\n runId\n threadId\n }\n }\n ... on CopilotResponse @defer {\n status {\n ... on BaseResponseStatus {\n code\n }\n ... on FailedResponseStatus {\n reason\n details\n }\n }\n }\n messages @stream {\n __typename\n ... on BaseMessageOutput {\n id\n createdAt\n }\n ... on BaseMessageOutput @defer {\n status {\n ... on SuccessMessageStatus {\n code\n }\n ... on FailedMessageStatus {\n code\n reason\n }\n ... on PendingMessageStatus {\n code\n }\n }\n }\n ... on TextMessageOutput {\n content @stream\n role\n parentMessageId\n }\n ... on ActionExecutionMessageOutput {\n name\n arguments @stream\n parentMessageId\n }\n ... on ResultMessageOutput {\n result\n actionExecutionId\n actionName\n }\n ... on AgentStateMessageOutput {\n threadId\n state\n running\n agentName\n nodeName\n runId\n active\n role\n }\n }\n }\n }\n"];
39
+ /**
40
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
41
+ */
42
+ export function graphql(source: "\n query availableAgents {\n availableAgents {\n agents {\n name\n id\n description\n }\n }\n }\n"): (typeof documents)["\n query availableAgents {\n availableAgents {\n agents {\n name\n id\n description\n }\n }\n }\n"];
43
+ /**
44
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
45
+ */
46
+ export function graphql(source: "\n query loadAgentState($data: LoadAgentStateInput!) {\n loadAgentState(data: $data) {\n threadId\n threadExists\n state\n messages\n }\n }\n"): (typeof documents)["\n query loadAgentState($data: LoadAgentStateInput!) {\n loadAgentState(data: $data) {\n threadId\n threadExists\n state\n messages\n }\n }\n"];
47
+
48
+ export function graphql(source: string) {
49
+ return (documents as any)[source] ?? {};
50
+ }
51
+
52
+ export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never;