@copilotkit/runtime-client-gql 1.10.6-next.3 → 1.10.6-next.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  import "./chunk-7ECCT6PK.mjs";
18
18
  import {
19
19
  CopilotRuntimeClient
20
- } from "./chunk-OO7ZIFJL.mjs";
20
+ } from "./chunk-2OWFBJIE.mjs";
21
21
  import "./chunk-WUF3XSW5.mjs";
22
22
  import "./chunk-EWRHYLZE.mjs";
23
23
  import "./chunk-AQ2Y6PF5.mjs";
@@ -7,7 +7,7 @@ import {
7
7
  aguiToolMessageToGQLResultMessage
8
8
  } from "../chunk-TNC2H2EO.mjs";
9
9
  import "../chunk-7ECCT6PK.mjs";
10
- import "../chunk-OO7ZIFJL.mjs";
10
+ import "../chunk-2OWFBJIE.mjs";
11
11
  import "../chunk-WUF3XSW5.mjs";
12
12
  import "../chunk-EWRHYLZE.mjs";
13
13
  import "../chunk-AQ2Y6PF5.mjs";
@@ -13,7 +13,7 @@ import {
13
13
  vi
14
14
  } from "../chunk-2R7M2FWR.mjs";
15
15
  import "../chunk-7ECCT6PK.mjs";
16
- import "../chunk-OO7ZIFJL.mjs";
16
+ import "../chunk-2OWFBJIE.mjs";
17
17
  import "../chunk-WUF3XSW5.mjs";
18
18
  import "../chunk-EWRHYLZE.mjs";
19
19
  import "../chunk-AQ2Y6PF5.mjs";
@@ -6,7 +6,7 @@ import {
6
6
  gqlToAGUI
7
7
  } from "../chunk-O7JH6IWQ.mjs";
8
8
  import "../chunk-7ECCT6PK.mjs";
9
- import "../chunk-OO7ZIFJL.mjs";
9
+ import "../chunk-2OWFBJIE.mjs";
10
10
  import "../chunk-WUF3XSW5.mjs";
11
11
  import "../chunk-EWRHYLZE.mjs";
12
12
  import "../chunk-AQ2Y6PF5.mjs";
@@ -12,7 +12,7 @@ import {
12
12
  vi
13
13
  } from "../chunk-2R7M2FWR.mjs";
14
14
  import "../chunk-7ECCT6PK.mjs";
15
- import "../chunk-OO7ZIFJL.mjs";
15
+ import "../chunk-2OWFBJIE.mjs";
16
16
  import "../chunk-WUF3XSW5.mjs";
17
17
  import "../chunk-EWRHYLZE.mjs";
18
18
  import "../chunk-AQ2Y6PF5.mjs";
@@ -15,7 +15,7 @@ import {
15
15
  gqlToAGUI
16
16
  } from "../chunk-O7JH6IWQ.mjs";
17
17
  import "../chunk-7ECCT6PK.mjs";
18
- import "../chunk-OO7ZIFJL.mjs";
18
+ import "../chunk-2OWFBJIE.mjs";
19
19
  import "../chunk-WUF3XSW5.mjs";
20
20
  import "../chunk-EWRHYLZE.mjs";
21
21
  import "../chunk-AQ2Y6PF5.mjs";
@@ -11,7 +11,7 @@ import {
11
11
  vi
12
12
  } from "../chunk-2R7M2FWR.mjs";
13
13
  import "../chunk-7ECCT6PK.mjs";
14
- import "../chunk-OO7ZIFJL.mjs";
14
+ import "../chunk-2OWFBJIE.mjs";
15
15
  import "../chunk-WUF3XSW5.mjs";
16
16
  import "../chunk-EWRHYLZE.mjs";
17
17
  import "../chunk-AQ2Y6PF5.mjs";
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
- "version": "1.10.6-next.3",
12
+ "version": "1.10.6-next.5",
13
13
  "sideEffects": false,
14
14
  "main": "./dist/index.js",
15
15
  "module": "./dist/index.mjs",
@@ -45,13 +45,13 @@
45
45
  "tsup": "^6.7.0",
46
46
  "typescript": "^5.4.5",
47
47
  "vitest": "^3.1.3",
48
- "@copilotkit/runtime": "1.10.6-next.3"
48
+ "@copilotkit/runtime": "1.10.6-next.5"
49
49
  },
50
50
  "dependencies": {
51
51
  "@urql/core": "^5.0.3",
52
52
  "untruncate-json": "^0.0.1",
53
53
  "urql": "^4.1.0",
54
- "@copilotkit/shared": "1.10.6-next.3"
54
+ "@copilotkit/shared": "1.10.6-next.5"
55
55
  },
56
56
  "keywords": [
57
57
  "copilotkit",
@@ -118,13 +118,6 @@ export class CopilotRuntimeClient {
118
118
  GenerateCopilotResponseMutationVariables
119
119
  >(generateCopilotResponseMutation, { data, properties }, { fetch: fetchFn });
120
120
 
121
- // Add error handling for GraphQL errors that occur during mutation execution
122
- result.subscribe(({ error }) => {
123
- if (error && this.handleGQLErrors) {
124
- this.handleGQLErrors(error);
125
- }
126
- });
127
-
128
121
  return result;
129
122
  }
130
123
 
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/client/CopilotRuntimeClient.ts","../package.json"],"sourcesContent":["import { Client, cacheExchange, fetchExchange } from \"@urql/core\";\nimport * as packageJson from \"../../package.json\";\nimport {\n AvailableAgentsQuery,\n GenerateCopilotResponseMutation,\n GenerateCopilotResponseMutationVariables,\n LoadAgentStateQuery,\n} from \"../graphql/@generated/graphql\";\nimport { generateCopilotResponseMutation } from \"../graphql/definitions/mutations\";\nimport { getAvailableAgentsQuery, loadAgentStateQuery } from \"../graphql/definitions/queries\";\nimport { OperationResultSource, OperationResult } from \"urql\";\nimport {\n ResolvedCopilotKitError,\n CopilotKitLowLevelError,\n CopilotKitError,\n CopilotKitVersionMismatchError,\n getPossibleVersionMismatch,\n} from \"@copilotkit/shared\";\n\nconst createFetchFn =\n (signal?: AbortSignal, handleGQLWarning?: (warning: string) => void) =>\n async (...args: Parameters<typeof fetch>) => {\n // @ts-expect-error -- since this is our own header, TS will not recognize\n const publicApiKey = args[1]?.headers?.[\"x-copilotcloud-public-api-key\"];\n try {\n const result = await fetch(args[0], { ...(args[1] ?? {}), signal });\n\n // No mismatch checking if cloud is being used\n const mismatch = publicApiKey\n ? null\n : await getPossibleVersionMismatch({\n runtimeVersion: result.headers.get(\"X-CopilotKit-Runtime-Version\")!,\n runtimeClientGqlVersion: packageJson.version,\n });\n if (result.status !== 200) {\n if (result.status >= 400 && result.status <= 500) {\n if (mismatch) {\n throw new CopilotKitVersionMismatchError(mismatch);\n }\n\n throw new ResolvedCopilotKitError({ status: result.status });\n }\n }\n\n if (mismatch && handleGQLWarning) {\n handleGQLWarning(mismatch.message);\n }\n\n return result;\n } catch (error) {\n // Let abort error pass through. It will be suppressed later\n if (\n (error as Error).message.includes(\"BodyStreamBuffer was aborted\") ||\n (error as Error).message.includes(\"signal is aborted without reason\")\n ) {\n throw error;\n }\n if (error instanceof CopilotKitError) {\n throw error;\n }\n throw new CopilotKitLowLevelError({ error: error as Error, url: args[0] as string });\n }\n };\n\nexport interface CopilotRuntimeClientOptions {\n url: string;\n publicApiKey?: string;\n headers?: Record<string, string>;\n credentials?: RequestCredentials;\n handleGQLErrors?: (error: Error) => void;\n handleGQLWarning?: (warning: string) => void;\n}\n\nexport class CopilotRuntimeClient {\n client: Client;\n public handleGQLErrors?: (error: Error) => void;\n public handleGQLWarning?: (warning: string) => void;\n\n constructor(options: CopilotRuntimeClientOptions) {\n const headers: Record<string, string> = {};\n\n this.handleGQLErrors = options.handleGQLErrors;\n this.handleGQLWarning = options.handleGQLWarning;\n\n if (options.headers) {\n Object.assign(headers, options.headers);\n }\n\n if (options.publicApiKey) {\n headers[\"x-copilotcloud-public-api-key\"] = options.publicApiKey;\n }\n\n this.client = new Client({\n url: options.url,\n exchanges: [cacheExchange, fetchExchange],\n fetchOptions: {\n headers: {\n ...headers,\n \"X-CopilotKit-Runtime-Client-GQL-Version\": packageJson.version,\n },\n ...(options.credentials ? { credentials: options.credentials } : {}),\n },\n });\n }\n\n generateCopilotResponse({\n data,\n properties,\n signal,\n }: {\n data: GenerateCopilotResponseMutationVariables[\"data\"];\n properties?: GenerateCopilotResponseMutationVariables[\"properties\"];\n signal?: AbortSignal;\n }) {\n const fetchFn = createFetchFn(signal, this.handleGQLWarning);\n const result = this.client.mutation<\n GenerateCopilotResponseMutation,\n GenerateCopilotResponseMutationVariables\n >(generateCopilotResponseMutation, { data, properties }, { fetch: fetchFn });\n\n // Add error handling for GraphQL errors that occur during mutation execution\n result.subscribe(({ error }) => {\n if (error && this.handleGQLErrors) {\n this.handleGQLErrors(error);\n }\n });\n\n return result;\n }\n\n public asStream<S, T>(source: OperationResultSource<OperationResult<S, { data: T }>>) {\n const handleGQLErrors = this.handleGQLErrors;\n return new ReadableStream<S>({\n start(controller) {\n source.subscribe(({ data, hasNext, error }) => {\n if (error) {\n if (\n error.message.includes(\"BodyStreamBuffer was aborted\") ||\n error.message.includes(\"signal is aborted without reason\")\n ) {\n // close the stream if there is no next item\n if (!hasNext) controller.close();\n\n //suppress this specific error\n console.warn(\"Abort error suppressed\");\n return;\n }\n\n // Handle structured errors specially - check if it's a CopilotKitError with visibility\n if ((error as any).extensions?.visibility) {\n // Create a synthetic GraphQL error with the structured error info\n const syntheticError = {\n ...error,\n graphQLErrors: [\n {\n message: error.message,\n extensions: (error as any).extensions,\n },\n ],\n };\n\n if (handleGQLErrors) {\n handleGQLErrors(syntheticError);\n }\n return; // Don't close the stream for structured errors, let the error handler decide\n }\n\n controller.error(error);\n if (handleGQLErrors) {\n handleGQLErrors(error);\n }\n } else {\n controller.enqueue(data);\n if (!hasNext) {\n controller.close();\n }\n }\n });\n },\n });\n }\n\n availableAgents() {\n const fetchFn = createFetchFn();\n return this.client.query<AvailableAgentsQuery>(getAvailableAgentsQuery, {}, { fetch: fetchFn });\n }\n\n loadAgentState(data: { threadId: string; agentName: string }) {\n const fetchFn = createFetchFn();\n const result = this.client.query<LoadAgentStateQuery>(\n loadAgentStateQuery,\n { data },\n { fetch: fetchFn },\n );\n\n // Add error handling for GraphQL errors - similar to generateCopilotResponse\n result\n .toPromise()\n .then(({ error }) => {\n if (error && this.handleGQLErrors) {\n this.handleGQLErrors(error);\n }\n })\n .catch(() => {}); // Suppress promise rejection warnings\n\n return result;\n }\n\n static removeGraphQLTypename(data: any) {\n if (Array.isArray(data)) {\n data.forEach((item) => CopilotRuntimeClient.removeGraphQLTypename(item));\n } else if (typeof data === \"object\" && data !== null) {\n delete data.__typename;\n Object.keys(data).forEach((key) => {\n if (typeof data[key] === \"object\" && data[key] !== null) {\n CopilotRuntimeClient.removeGraphQLTypename(data[key]);\n }\n });\n }\n return data;\n }\n}\n","{\n \"name\": \"@copilotkit/runtime-client-gql\",\n \"private\": false,\n \"homepage\": \"https://github.com/CopilotKit/CopilotKit\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/CopilotKit/CopilotKit.git\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"version\": \"1.10.6-next.3\",\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"scripts\": {\n \"build\": \"pnpm run graphql-codegen && tsup --clean\",\n \"dev\": \"concurrently \\\"pnpm run graphql-codegen:watch\\\" \\\"tsup --watch --no-splitting\\\"\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"check-types\": \"tsc --noEmit\",\n \"clean\": \"rm -rf .turbo && rm -rf node_modules && rm -rf ./src/graphql/@generated && rm -rf dist && rm -rf .next\",\n \"graphql-codegen\": \"graphql-codegen -c codegen.ts\",\n \"graphql-codegen:watch\": \"graphql-codegen -c codegen.ts --watch\",\n \"link:global\": \"pnpm link --global\",\n \"unlink:global\": \"pnpm unlink --global\"\n },\n \"peerDependencies\": {\n \"react\": \"^18 || ^19 || ^19.0.0-rc\"\n },\n \"devDependencies\": {\n \"@copilotkit/runtime\": \"workspace:*\",\n \"@graphql-codegen/cli\": \"^5.0.2\",\n \"@graphql-codegen/client-preset\": \"^4.2.6\",\n \"@graphql-codegen/introspection\": \"^4.0.3\",\n \"@graphql-codegen/typescript\": \"^4.0.7\",\n \"@graphql-codegen/typescript-operations\": \"^4.2.1\",\n \"@graphql-codegen/typescript-urql\": \"^4.0.0\",\n \"@graphql-codegen/urql-introspection\": \"^3.0.0\",\n \"@graphql-typed-document-node/core\": \"^3.2.0\",\n \"@parcel/watcher\": \"^2.4.1\",\n \"@types/node\": \"^20.12.12\",\n \"concurrently\": \"^8.2.2\",\n \"esbuild\": \"^0.23.0\",\n \"graphql\": \"^16.8.1\",\n \"jest\": \"^29.6.4\",\n \"ts-jest\": \"^29.1.1\",\n \"ts-node\": \"^10.9.2\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.4.5\",\n \"vitest\": \"^3.1.3\"\n },\n \"dependencies\": {\n \"@copilotkit/shared\": \"workspace:*\",\n \"@urql/core\": \"^5.0.3\",\n \"untruncate-json\": \"^0.0.1\",\n \"urql\": \"^4.1.0\"\n },\n \"keywords\": [\n \"copilotkit\",\n \"copilot\",\n \"react\",\n \"nextjs\",\n \"nodejs\",\n \"ai\",\n \"assistant\",\n \"javascript\",\n \"automation\",\n \"textarea\"\n ]\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,QAAQ,eAAe,qBAAqB;;;ACWnD,cAAW;;;ADAb;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,IAAM,gBACJ,CAAC,QAAsB,qBACvB,UAAU,SAAmC;AArB/C;AAuBI,QAAM,gBAAe,gBAAK,CAAC,MAAN,mBAAS,YAAT,mBAAmB;AACxC,MAAI;AACF,UAAM,SAAS,MAAM,MAAM,KAAK,CAAC,GAAG,EAAE,GAAI,KAAK,CAAC,KAAK,CAAC,GAAI,OAAO,CAAC;AAGlE,UAAM,WAAW,eACb,OACA,MAAM,2BAA2B;AAAA,MAC/B,gBAAgB,OAAO,QAAQ,IAAI,8BAA8B;AAAA,MACjE,yBAAqC;AAAA,IACvC,CAAC;AACL,QAAI,OAAO,WAAW,KAAK;AACzB,UAAI,OAAO,UAAU,OAAO,OAAO,UAAU,KAAK;AAChD,YAAI,UAAU;AACZ,gBAAM,IAAI,+BAA+B,QAAQ;AAAA,QACnD;AAEA,cAAM,IAAI,wBAAwB,EAAE,QAAQ,OAAO,OAAO,CAAC;AA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