From 04f1e98ac26459f5c127712d4c10ff8c03cfd6bb Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 4 Jun 2025 11:08:42 -0700 Subject: [PATCH 01/21] premature close tinkering --- packages/fetch/package-lock.json | 263 ------------ packages/fetch/src/chunk-transformer.test.ts | 137 +++++++ packages/fetch/src/node-fetch-bug.test.ts | 135 +++++++ packages/fetch/src/premature-close.test.ts | 405 +++++++++++++++++++ 4 files changed, 677 insertions(+), 263 deletions(-) create mode 100644 packages/fetch/src/chunk-transformer.test.ts create mode 100644 packages/fetch/src/node-fetch-bug.test.ts create mode 100644 packages/fetch/src/premature-close.test.ts diff --git a/packages/fetch/package-lock.json b/packages/fetch/package-lock.json index 58a83593b..f2f55c648 100644 --- a/packages/fetch/package-lock.json +++ b/packages/fetch/package-lock.json @@ -17,8 +17,6 @@ }, "devDependencies": { "@types/follow-redirects": "^1.14.4", - "cross-env": "^7.0.3", - "ts-node": "^10.9.2", "vitest": "^3.2.0" } }, @@ -30,28 +28,6 @@ "zod": "^3.23.8" } }, - "node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, "node_modules/@esbuild/aix-ppc64": { "version": "0.25.5", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.5.tgz", @@ -452,15 +428,6 @@ "node": ">=18" } }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", @@ -727,30 +694,6 @@ "win32" ] }, - "node_modules/@tsconfig/node10": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", - "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", - "dev": true - }, - "node_modules/@tsconfig/node12": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true - }, - "node_modules/@tsconfig/node14": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true - }, - "node_modules/@tsconfig/node16": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true - }, "node_modules/@types/chai": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.2.tgz", @@ -897,30 +840,6 @@ "url": "https://opencollective.com/vitest" } }, - "node_modules/acorn": { - "version": "8.14.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", - "integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-walk": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", - "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", - "dev": true, - "dependencies": { - "acorn": "^8.11.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/agent-base": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", @@ -932,12 +851,6 @@ "node": ">= 14" } }, - "node_modules/arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true - }, "node_modules/assertion-error": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", @@ -981,44 +894,6 @@ "node": ">= 16" } }, - "node_modules/create-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true - }, - "node_modules/cross-env": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", - "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.1" - }, - "bin": { - "cross-env": "src/bin/cross-env.js", - "cross-env-shell": "src/bin/cross-env-shell.js" - }, - "engines": { - "node": ">=10.14", - "npm": ">=6", - "yarn": ">=1" - } - }, - "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/data-uri-to-buffer": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", @@ -1052,15 +927,6 @@ "node": ">=6" } }, - "node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true, - "engines": { - "node": ">=0.3.1" - } - }, "node_modules/es-module-lexer": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", @@ -1215,12 +1081,6 @@ "node": ">= 14" } }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true - }, "node_modules/loupe": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.3.tgz", @@ -1236,12 +1096,6 @@ "@jridgewell/sourcemap-codec": "^1.5.0" } }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true - }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -1300,15 +1154,6 @@ "url": "https://opencollective.com/node-fetch" } }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/pathe": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", @@ -1397,27 +1242,6 @@ "fsevents": "~2.3.2" } }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/siginfo": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", @@ -1526,75 +1350,12 @@ "node": ">=14.0.0" } }, - "node_modules/ts-node": { - "version": "10.9.2", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", - "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", - "dev": true, - "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, - "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } - } - }, - "node_modules/typescript": { - "version": "5.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", - "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", - "dev": true, - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true }, - "node_modules/v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true - }, "node_modules/vite": { "version": "6.3.5", "resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz", @@ -1809,21 +1570,6 @@ "node": ">= 8" } }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/why-is-node-running": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", @@ -1840,15 +1586,6 @@ "node": ">=8" } }, - "node_modules/yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/zod": { "version": "3.23.8", "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", diff --git a/packages/fetch/src/chunk-transformer.test.ts b/packages/fetch/src/chunk-transformer.test.ts new file mode 100644 index 000000000..1f8354e62 --- /dev/null +++ b/packages/fetch/src/chunk-transformer.test.ts @@ -0,0 +1,137 @@ +import { RequestOptions } from "@continuedev/config-types"; +import { Response } from "node-fetch"; +import { fetchwithRequestOptions } from "./fetch.js"; + +// Buffer accumulator that ensures proper chunk boundaries +class ChunkAccumulatorTransform implements Transformer { + private buffer: Uint8Array = new Uint8Array(0); + private expectedChunkSize: number | null = null; + private readonly minBufferSize = 8192; // 8KB minimum buffer + + constructor() { + this.buffer = new Uint8Array(0); + } + + private concatUint8Arrays(a: Uint8Array, b: Uint8Array): Uint8Array { + const result = new Uint8Array(a.length + b.length); + result.set(a, 0); + result.set(b, a.length); + return result; + } + + private tryParseChunkSize( + data: Uint8Array, + startIndex: number, + ): { size: number | null; endIndex: number } { + let size = 0; + let i = startIndex; + + // Look for the chunk size end marker + while (i < data.length - 1) { + // Check for CRLF + if (data[i] === 0x0d && data[i + 1] === 0x0a) { + return { size, endIndex: i + 2 }; + } + + // Parse hex digit + const char = String.fromCharCode(data[i]); + const digit = parseInt(char, 16); + if (!isNaN(digit)) { + size = (size << 4) | digit; + } + i++; + } + + return { size: null, endIndex: startIndex }; + } + + transform( + chunk: Uint8Array, + controller: TransformStreamDefaultController, + ) { + // Accumulate incoming data + this.buffer = this.concatUint8Arrays(this.buffer, chunk); + + // Process buffer while we have enough data + while (this.buffer.length > 0) { + // If we don't have a chunk size yet, try to parse it + if (this.expectedChunkSize === null) { + const { size, endIndex } = this.tryParseChunkSize(this.buffer, 0); + + if (size === null) { + // Not enough data to parse chunk size + if (this.buffer.length > this.minBufferSize) { + // Buffer is getting too large, flush it + controller.enqueue(this.buffer); + this.buffer = new Uint8Array(0); + } + return; + } + + this.expectedChunkSize = size; + this.buffer = this.buffer.slice(endIndex); + } + + // Check if we have a complete chunk + const expectedTotalSize = this.expectedChunkSize + 2; // +2 for CRLF + if (this.buffer.length < expectedTotalSize) { + return; // Wait for more data + } + + // We have a complete chunk, emit it + const chunk = this.buffer.slice(0, expectedTotalSize); + controller.enqueue(chunk); + + // Keep the rest in the buffer + this.buffer = this.buffer.slice(expectedTotalSize); + this.expectedChunkSize = null; + + // Check for end chunk + if ( + chunk.length >= 5 && + chunk[0] === 0x30 && // '0' + chunk[1] === 0x0d && // CR + chunk[2] === 0x0a && // LF + chunk[3] === 0x0d && // CR + chunk[4] === 0x0a + ) { + // LF + controller.terminate(); + return; + } + } + } + + flush(controller: TransformStreamDefaultController) { + if (this.buffer.length > 0) { + controller.enqueue(this.buffer); + } + } +} + +/** + * Creates a robust fetch function that handles ambiguous chunk boundaries + */ +export async function robustFetch( + url: string, + options?: RequestOptions, +): Promise { + const response = await fetchwithRequestOptions(url, options); + + // Only transform chunked responses + const transferEncoding = response.headers.get("transfer-encoding"); + if (transferEncoding?.toLowerCase().includes("chunked")) { + const transformStream = new TransformStream( + new ChunkAccumulatorTransform(), + ); + + // Create a new response with the transformed body + return new Response(response.body?.pipeThrough(transformStream), { + status: response.status, + statusText: response.statusText, + headers: options?.headers, + }); + } + + return response; +} diff --git a/packages/fetch/src/node-fetch-bug.test.ts b/packages/fetch/src/node-fetch-bug.test.ts new file mode 100644 index 000000000..d1b320f75 --- /dev/null +++ b/packages/fetch/src/node-fetch-bug.test.ts @@ -0,0 +1,135 @@ +import { Buffer } from "buffer"; +import { EventEmitter } from "events"; +import { describe, expect, it } from "vitest"; + +/** + * This test reproduces the issue described in + * https://github.com/node-fetch/node-fetch/issues/1576 + * + * The issue is that node-fetch has a hard-coded assumption about how the end-of-chunked-response + * marker (0\r\n\r\n) might be split across chunks. It only handles two specific cases: + * 1. The entire marker is in the last chunk + * 2. The marker is split exactly as [0\r\n] + [\r\n] + * + * However, in real-world scenarios, the marker can be split in other ways, causing + * "Premature close" errors. + */ + +describe("node-fetch chunked encoding bug", () => { + // Mock the relevant portion of node-fetch's response handling + const LAST_CHUNK = Buffer.from("0\r\n\r\n"); + + function simulateChunkedResponseHandling(chunks: Buffer[]) { + const socket = new EventEmitter(); + let previousChunk: Buffer | undefined; + let properLastChunkReceived = false; + + // This is the problematic code from node-fetch + const onData = (buf: Buffer) => { + // Check if the entire marker is in the current chunk + properLastChunkReceived = Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0; + + // This is the limited assumption - it only handles one specific way the marker can be split + if (!properLastChunkReceived && previousChunk) { + properLastChunkReceived = + Buffer.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === + 0 && Buffer.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0; + } + + previousChunk = buf; + }; + + // Simulate receiving chunks + chunks.forEach((chunk) => { + onData(chunk); + socket.emit("data", chunk); + }); + + return properLastChunkReceived; + } + + // This is the improved code proposed in the GitHub issue by Treverix + function simulateImprovedChunkedResponseHandling(chunks: Buffer[]) { + const socket = new EventEmitter(); + let previousChunk: Buffer | undefined; + let properLastChunkReceived = false; + + const onData = (buf: Buffer) => { + // Check if the entire marker is in the current chunk + properLastChunkReceived = Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0; + + // More flexible handling of split markers + if (!properLastChunkReceived && previousChunk) { + if (buf.length < 5) { + // Create a composite buffer from the end of previous chunk and the current chunk + const composite = Buffer.from([...previousChunk.slice(-5), ...buf]); + properLastChunkReceived = + Buffer.compare(composite.slice(-5), LAST_CHUNK) === 0; + } + } + + previousChunk = buf; + }; + + // Simulate receiving chunks + chunks.forEach((chunk) => { + onData(chunk); + socket.emit("data", chunk); + }); + + return properLastChunkReceived; + } + + it("fails to detect end of chunked response when split in unexpected way", () => { + // This is the case reported in the GitHub issue + // previousChunk = [ (...), 0, 13, 10, 48, 13] + // lastChunk = [ 10, 13, 10] + // Where 13 = \r and 10 = \n + const previousChunk = Buffer.from([0, 13, 10, 48, 13]); + const lastChunk = Buffer.from([10, 13, 10]); + + // With the original implementation, it fails to detect the end marker + const originalResult = simulateChunkedResponseHandling([ + previousChunk, + lastChunk, + ]); + expect(originalResult).toBe(false); + + // With the improved implementation, it correctly detects the end marker + const improvedResult = simulateImprovedChunkedResponseHandling([ + previousChunk, + lastChunk, + ]); + expect(improvedResult).toBe(true); + }); + + it("handles various ways the end marker can be split", () => { + // Test various ways the marker can be split across chunks + const testCases = [ + // Case 1: [0] + [\r\n\r\n] + [Buffer.from([0]), Buffer.from([13, 10, 13, 10])], + + // Case 2: [0\r] + [\n\r\n] + [Buffer.from([0, 13]), Buffer.from([10, 13, 10])], + + // Case 3: [0\r\n] + [\r\n] + [Buffer.from([0, 13, 10]), Buffer.from([13, 10])], + + // Case 4: [0\r\n\r] + [\n] + [Buffer.from([0, 13, 10, 13]), Buffer.from([10])], + + // Case 5: [..., 0, \r, \n, \r] + [\n, ...] + [Buffer.from([99, 0, 13, 10, 13]), Buffer.from([10, 99])], + ]; + + testCases.forEach((chunks, index) => { + // The original implementation only handles case 3 correctly + const originalResult = simulateChunkedResponseHandling(chunks); + expect(originalResult).toBe(index === 2); + + // The improved implementation handles all cases + const improvedResult = simulateImprovedChunkedResponseHandling(chunks); + expect(improvedResult).toBe(true); + }); + }); +}); diff --git a/packages/fetch/src/premature-close.test.ts b/packages/fetch/src/premature-close.test.ts new file mode 100644 index 000000000..699dcde6c --- /dev/null +++ b/packages/fetch/src/premature-close.test.ts @@ -0,0 +1,405 @@ +import { createServer } from "http"; +import { describe, expect, it } from "vitest"; +import { fetchwithRequestOptions } from "./fetch.js"; +import { streamResponse } from "./stream.js"; +describe("Fetch Premature Close Tests", () => { + // This test specifically forces conditions that cause premature close + it("should reproduce premature close error with chunked encoding", async () => { + // Create a server that intentionally misbehaves + const server = createServer((req, res) => { + // Set chunked transfer encoding + res.writeHead(200, { + "Content-Type": "text/plain", + "Transfer-Encoding": "chunked", + }); + + let chunk = 0; + const interval = setInterval(() => { + // Send malformed chunk sizes occasionally + if (chunk === 2) { + // Send a malformed chunk that will trigger the issue + res.write("5\r\nHello\r\n3\r"); // Intentionally incomplete chunk + clearInterval(interval); + + // Force socket closure mid-stream + setTimeout(() => { + // @ts-ignore - accessing private property for test + res.socket?.destroy(); + }, 50); + + return; + } + + res.write(`${chunk.toString(16)}\r\nChunk${chunk}\r\n`); + chunk++; + }, 10); + }); + + // Start server on random port + await new Promise((resolve) => server.listen(0, resolve)); + const port = (server.address() as any).port; + + try { + // Make request and attempt to stream response + const response = await fetchwithRequestOptions( + `http://localhost:${port}`, + { + headers: { + Connection: "keep-alive", + }, + }, + ); + + // Try to consume the stream + const chunks: string[] = []; + try { + for await (const chunk of streamResponse( + response as unknown as Response, + )) { + chunks.push(chunk); + } + // If we get here, the test failed because we expected an error + throw new Error( + "Expected premature close error but stream completed successfully", + ); + } catch (e) { + // Verify we got the expected error + expect(e).toBeTruthy(); + expect((e as Error).message).toMatch(/premature close/i); + } + } finally { + // Cleanup + server.close(); + } + }); + + // This test reproduces the issue using timing and connection pooling + it("should reproduce premature close with connection reuse", async () => { + // Create a server that intentionally causes issues with keep-alive connections + const server = createServer((req, res) => { + res.writeHead(200, { + "Content-Type": "text/plain", + Connection: "keep-alive", + "Transfer-Encoding": "chunked", + }); + + let bytesSent = 0; + const streamSize = 1024 * 1024; // 1MB + const chunkSize = 16384; // 16KB + + const writeChunk = () => { + if (bytesSent >= streamSize) { + res.end(); + return; + } + + const chunk = Buffer.alloc(chunkSize).fill("x"); + bytesSent += chunk.length; + + // Randomly corrupt the stream + if (Math.random() < 0.1) { + // @ts-ignore - accessing private property for test + res.socket?.destroy(); + return; + } + + res.write(chunk); + setImmediate(writeChunk); + }; + + writeChunk(); + }); + + await new Promise((resolve) => server.listen(0, resolve)); + const port = (server.address() as any).port; + + try { + // Make multiple concurrent requests to force connection pooling + const requests = Array(5) + .fill(null) + .map(async (_, i) => { + try { + const response = await fetchwithRequestOptions( + `http://localhost:${port}`, + { + headers: { + Connection: "keep-alive", + }, + }, + ); + + const chunks: string[] = []; + for await (const chunk of streamResponse( + response as unknown as Response, + )) { + chunks.push(chunk); + } + } catch (e) { + expect(e).toBeTruthy(); + expect((e as Error).message).toMatch( + /premature close|socket hang up/i, + ); + } + }); + + await Promise.all(requests); + } finally { + server.close(); + } + }); + + // This test reproduces the issue using a delayed response + it("should reproduce premature close with delayed response", async () => { + const server = createServer((req, res) => { + res.writeHead(200, { + "Content-Type": "text/plain", + "Transfer-Encoding": "chunked", + }); + + // Start sending data + let count = 0; + const interval = setInterval(() => { + if (count >= 5) { + clearInterval(interval); + // Delay then destroy the socket + setTimeout(() => { + // @ts-ignore - accessing private property for test + res.socket?.destroy(); + }, 100); + return; + } + + // Send a chunk with a delay + setTimeout(() => { + res.write(`chunk ${count}\n`); + }, count * 50); + + count++; + }, 10); + }); + + await new Promise((resolve) => server.listen(0, resolve)); + const port = (server.address() as any).port; + + try { + const response = await fetchwithRequestOptions( + `http://localhost:${port}`, + ); + + const chunks: string[] = []; + try { + for await (const chunk of streamResponse( + response as unknown as Response, + )) { + chunks.push(chunk); + // Optional artificial processing delay + await new Promise((resolve) => setTimeout(resolve, 20)); + } + throw new Error( + "Expected premature close error but stream completed successfully", + ); + } catch (e) { + expect(e).toBeTruthy(); + expect((e as Error).message).toMatch(/premature close/i); + } + } finally { + server.close(); + } + }); + + it("should properly handle chunk boundary in the terminating sequence", async () => { + // Flag to track if response was fully sent + let responseFullySent = false; + + const server = createServer((req, res) => { + res.writeHead(200, { + "Content-Type": "text/plain", + "Transfer-Encoding": "chunked", + }); + + // Send normal chunks directly as data (not writing the chunk headers manually) + // Node's HTTP server will handle adding the proper chunk headers + res.write("Hello"); + res.write("World!!"); + + // Now manually control the terminating sequence to split it at the boundary + // First, end the response but intercept the actual write + const originalEnd = res.end; + res.end = function () { + // Instead of letting Node send the terminating sequence normally, + // we'll send it split across a boundary + + // Manually send the first part of the termination sequence "0\r\n\r" + // @ts-ignore - accessing private property for test + const socket = res.socket; + socket?.write("0\r\n\r", "utf8"); + + // Small delay to ensure split across packets + setTimeout(() => { + // Send the final "\n" to complete the terminating sequence + socket?.write("\n", "utf8", () => { + // Mark that we've fully sent the response + responseFullySent = true; + }); + }, 20); + + // Don't call the original end since we're manually handling it + return res; + }; + }); + + await new Promise((resolve) => server.listen(0, resolve)); + const port = (server.address() as any).port; + + try { + const response = await fetchwithRequestOptions( + `http://localhost:${port}`, + { + headers: { + Connection: "keep-alive", + }, + }, + ); + + const chunks: Uint8Array[] = []; + let streamCompleted = false; + + try { + // Collect chunks as raw buffers to avoid encoding issues + for await (const chunk of streamResponse( + response as unknown as Response, + )) { + // Store the raw chunk + chunks.push(Buffer.from(chunk) as Uint8Array); + } + + // If we get here, the stream completed successfully + streamCompleted = true; + + // Wait a bit more to ensure server has time to set responseFullySent flag + await new Promise((resolve) => setTimeout(resolve, 100)); + + // Verify the response was fully sent by the server + expect(responseFullySent).toBe(true); + + // Convert all chunks to a single string and verify content + const content = Buffer.concat(chunks).toString("utf8"); + expect(content).toBe("HelloWorld!!"); + } catch (e) { + // If the server fully sent the response but we got an error, + // this confirms the client has an issue with the split boundary + if (responseFullySent) { + // This is the assertion that proves the 3/2 boundary issue exists + console.log( + "Server sent complete response but client failed to parse it properly", + ); + console.log("Error:", (e as Error).message); + expect((e as Error).message).toMatch( + /premature close|invalid chunked encoding/i, + ); + + // We should still verify we got some data before the error + const partialContent = Buffer.concat(chunks).toString("utf8"); + expect(partialContent).toContain("Hello"); + } else { + // If the server didn't fully send the response, the test is inconclusive + throw new Error( + "Test inconclusive: Server didn't complete sending response before error occurred", + ); + } + } + + // If the stream completed and the response was fully sent, + // the client correctly handled the split boundary + if (streamCompleted && responseFullySent) { + console.log("Client correctly handled split terminating sequence"); + } + } finally { + server.close(); + } + }); + + // This test reproduces the 3/2 assumption bug with multiline chunks + it("should reproduce premature close with multiline chunks containing line breaks", async () => { + const server = createServer((req, res) => { + res.writeHead(200, { + "Content-Type": "text/plain", + "Transfer-Encoding": "chunked", + }); + + // First send a normal chunk + res.write("A\r\nHello there\r\n"); + + // Send a chunk with a size that contains multiline data with \r\n inside + // This is valid chunked encoding but might confuse parsers + // The chunk size "1E" = 30 bytes + res.write("1E\r\n"); // Chunk size header + res.write("Line 1\r\nLine 2\r\nLine 3 not done yet"); // 30 bytes total + res.write("\r\n"); // Chunk terminator + + // Now send another chunk that starts with a line continuation + // This creates a situation where \r\n appears in data and as chunk boundaries + res.write("14\r\n"); // Size of 20 bytes + res.write(" continued from before\r\n"); + res.write("\r\n"); // Chunk terminator + + // Here's where we'll try to trigger the bug + // Send the final chunk marker but split across what could be mistaken for a line boundary + setTimeout(() => { + // Send "0\r" first - this could be mistaken for start of a line ending + res.write("0\r"); + + // Small delay to ensure separate TCP packets + setTimeout(() => { + // Now send "\n\r\n" - this creates ambiguous line endings + res.write("\n\r\n"); + + // Force close after a small delay to simulate network issues + setTimeout(() => { + // @ts-ignore - accessing private property for test + res.socket?.destroy(); + }, 20); + }, 10); + }, 10); + }); + + await new Promise((resolve) => server.listen(0, resolve)); + const port = (server.address() as any).port; + + try { + const response = await fetchwithRequestOptions( + `http://localhost:${port}`, + { + headers: { + Connection: "keep-alive", + }, + }, + ); + + const chunks: string[] = []; + try { + for await (const chunk of streamResponse( + response as unknown as Response, + )) { + chunks.push(chunk); + } + throw new Error( + "Expected premature close error but stream completed successfully", + ); + } catch (e) { + expect(e).toBeTruthy(); + expect((e as Error).message).toMatch(/premature close/i); + + // Verify we received the multiline data before the error + const receivedData = chunks.join(""); + expect(receivedData).toContain("Hello there"); + expect(receivedData).toContain("Line 1"); + expect(receivedData).toContain("Line 2"); + expect(receivedData).toContain("Line 3 not done yet"); + expect(receivedData).toContain("continued from before"); + } + } finally { + server.close(); + } + }); +}); From cd0a5e0af99f8e80d8ddf09bd8bdf1b62284bb64 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Wed, 4 Jun 2025 15:24:32 -0700 Subject: [PATCH 02/21] propagate errors to render in the extension gui --- core/config/yaml/loadYaml.ts | 65 ++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index aa4c3919a..b8cbf1938 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -117,39 +117,46 @@ async function loadConfigYaml(options: { // `Loading config.yaml from ${JSON.stringify(packageIdentifier)} with root path ${rootPath}`, // ); - let config = - overrideConfigYaml ?? - // This is how we allow use of blocks locally - (await unrollAssistant( - packageIdentifier, - new RegistryClient({ - accessToken: await controlPlaneClient.getAccessToken(), - apiBase: getControlPlaneEnvSync(ideSettings.continueTestEnvironment) - .CONTROL_PLANE_URL, - rootPath, - }), - { - currentUserSlug: "", - onPremProxyUrl: null, + // This is how we allow use of blocks locally + const NEED_ERROR_PROPAGATION = true; + const unrollResult = await unrollAssistant( + packageIdentifier, + new RegistryClient({ + accessToken: await controlPlaneClient.getAccessToken(), + apiBase: getControlPlaneEnvSync(ideSettings.continueTestEnvironment) + .CONTROL_PLANE_URL, + rootPath, + }), + { + currentUserSlug: "", + onPremProxyUrl: null, + orgScopeId, + platformClient: new LocalPlatformClient( orgScopeId, - platformClient: new LocalPlatformClient( - orgScopeId, - controlPlaneClient, - ide, - ), - renderSecrets: true, - injectBlocks: allLocalBlocks, - }, - )); + controlPlaneClient, + ide, + ), + renderSecrets: true, + injectBlocks: allLocalBlocks, + }, + NEED_ERROR_PROPAGATION, + ); - const errors = isAssistantUnrolledNonNullable(config) - ? validateConfigYaml(config) - : [ - { + const errors: ConfigValidationError[] = []; + + let config = overrideConfigYaml ?? unrollResult.config; + if (config) { + isAssistantUnrolledNonNullable(config) + ? errors.push(...validateConfigYaml(config)) + : errors.push({ fatal: true, message: "Assistant includes blocks that don't exist", - }, - ]; + }); + } + + if (unrollResult.errors) { + errors.push(...unrollResult.errors); + } if (errors?.some((error) => error.fatal)) { return { From 803e6c8099a69418b1a923075f438d38ddd9354f Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Wed, 4 Jun 2025 15:26:45 -0700 Subject: [PATCH 03/21] add overloads to unrollAssistant and unrollAssistantFromContent to handle cases where we need error propagation, return a sum type from unrollBlocks, wrap objects in JSON.stringify to avoid displaying [object Object]. --- packages/config-yaml/src/load/unroll.ts | 132 ++++++++++++++++++++++-- 1 file changed, 124 insertions(+), 8 deletions(-) diff --git a/packages/config-yaml/src/load/unroll.ts b/packages/config-yaml/src/load/unroll.ts index 0b5003473..b90072b9b 100644 --- a/packages/config-yaml/src/load/unroll.ts +++ b/packages/config-yaml/src/load/unroll.ts @@ -17,6 +17,7 @@ import { configYamlSchema, Rule, } from "../schemas/index.js"; +import { ConfigResult } from "../validation.js"; import { packageIdentifierToShorthandSlug, useProxyForUnrenderedSecrets, @@ -204,14 +205,49 @@ export type UnrollAssistantOptions = | DoNotRenderSecretsUnrollAssistantOptions | RenderSecretsUnrollAssistantOptions; +// Overload when we need error propapagation. export async function unrollAssistant( id: PackageIdentifier, registry: Registry, options: UnrollAssistantOptions, -): Promise { + needErrorPropagation: true, +): Promise>; + +// Overload when we don't need error propapagation. +export async function unrollAssistant( + id: PackageIdentifier, + registry: Registry, + options: UnrollAssistantOptions, + needErrorPropagation?: false, +): Promise; + +export async function unrollAssistant( + id: PackageIdentifier, + registry: Registry, + options: UnrollAssistantOptions, + needErrorPropagation: boolean = false, +): Promise> { // Request the content from the registry const rawContent = await registry.getContent(id); - return unrollAssistantFromContent(id, rawContent, registry, options); + + // Somewhat annoyingly, we need this redundant ternary to circumvent overload matching error. + // Without it TypeScript complains that no overloads of unrollAssistant + // has a field needErrorPropagation that accepts a boolean. + return needErrorPropagation + ? unrollAssistantFromContent( + id, + rawContent, + registry, + options, + needErrorPropagation, + ) + : unrollAssistantFromContent( + id, + rawContent, + registry, + options, + needErrorPropagation, + ); } function renderTemplateData( @@ -231,12 +267,31 @@ function renderTemplateData( return templatedYaml; } +// Overload when we need error propapagation. export async function unrollAssistantFromContent( id: PackageIdentifier, rawYaml: string, registry: Registry, options: UnrollAssistantOptions, -): Promise { + needErrorPropagation: true, +): Promise>; + +// Overload when we need don't error propapagation. +export async function unrollAssistantFromContent( + id: PackageIdentifier, + rawYaml: string, + registry: Registry, + options: UnrollAssistantOptions, + needErrorPropagation?: false, +): Promise; + +export async function unrollAssistantFromContent( + id: PackageIdentifier, + rawYaml: string, + registry: Registry, + options: UnrollAssistantOptions, + needErrorPropagation: boolean = false, +): Promise> { // Parse string to Zod-validated YAML let parsedYaml = parseConfigYaml(rawYaml); @@ -245,10 +300,15 @@ export async function unrollAssistantFromContent( parsedYaml, registry, options.injectBlocks, + needErrorPropagation, ); // Back to a string so we can fill in template variables - const rawUnrolledYaml = YAML.stringify(unrolledAssistant); + const rawUnrolledYaml = needErrorPropagation + ? YAML.stringify( + (unrolledAssistant as ConfigResult).config, + ) + : YAML.stringify(unrolledAssistant); // Convert all of the template variables to FQSNs // Secrets from the block will have the assistant slug prepended to the FQSN @@ -277,14 +337,37 @@ export async function unrollAssistantFromContent( options.orgScopeId, options.onPremProxyUrl, ); + + if (needErrorPropagation) { + return { + config: finalConfig, + errors: (unrolledAssistant as ConfigResult).errors, + configLoadInterrupted: ( + unrolledAssistant as ConfigResult + ).configLoadInterrupted, + }; + } + return finalConfig; } +// We don't need oveloads here because +// the only place unrollBlocks is called directly is this file. +// unrollAssistantFromContent and unrollAssistant +// are called elsewhere in this project +// and imported in other projects. export async function unrollBlocks( assistant: ConfigYaml, registry: Registry, injectBlocks: PackageIdentifier[] | undefined, -): Promise { + needErrorPropagation: boolean = false, +): Promise> { + const configResult: ConfigResult = { + config: undefined, + errors: [], + configLoadInterrupted: false, + }; + const unrolledAssistant: AssistantUnrolled = { name: assistant.name, version: assistant.version, @@ -316,8 +399,16 @@ export async function unrollBlocks( ); } } catch (err) { + if (needErrorPropagation) { + configResult.errors?.push({ + fatal: false, + // Using JSON.stringify to avoid printing [object Object]. + message: `Failed to unroll block ${JSON.stringify(unrolledBlock.uses)}: ${(err as Error).message}`, + }); + } + console.error( - `Failed to unroll block ${unrolledBlock.uses}: ${(err as Error).message}`, + `Failed to unroll block ${JSON.stringify(unrolledBlock.uses)}: ${(err as Error).message}`, ); sectionBlocks.push(null); } @@ -349,8 +440,16 @@ export async function unrollBlocks( rules.push(block); } } catch (err) { + if (needErrorPropagation) { + configResult.errors?.push({ + fatal: false, + // Using JSON.stringify to avoid printing [object Object]. + message: `Failed to unroll block ${JSON.stringify(rule.uses)}: ${(err as Error).message}`, + }); + } + console.error( - `Failed to unroll block ${rule.uses}: ${(err as Error).message}`, + `Failed to unroll block ${JSON.stringify(rule.uses)}: ${(err as Error).message}`, ); rules.push(null); } @@ -381,12 +480,29 @@ export async function unrollBlocks( ); } } catch (err) { + if (needErrorPropagation) { + configResult.errors?.push({ + fatal: false, + // Using JSON.stringify to avoid printing [object Object]. + message: `Failed to unroll block ${JSON.stringify(injectBlock)}: ${(err as Error).message}`, + }); + } + console.error( - `Failed to unroll block ${injectBlock}: ${(err as Error).message}`, + `Failed to unroll block ${JSON.stringify(injectBlock)}: ${(err as Error).message}`, ); } } + if (needErrorPropagation) { + configResult.config = unrolledAssistant; + if (configResult.errors?.length == 0) { + configResult.errors = undefined; + } + configResult.configLoadInterrupted = false; + return configResult; + } + return unrolledAssistant; } From 96ecb2cf1bb9e2c82aabb8061c66faaa0cffaa33 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Wed, 4 Jun 2025 15:27:24 -0700 Subject: [PATCH 04/21] fix a bug where icons will shrink depending on error message size --- .../mainInput/Lump/sections/errors/ErrorSection.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx b/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx index c5aa0a039..bd06d197d 100644 --- a/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx @@ -24,9 +24,9 @@ export function ErrorSection() { }`} > {error.fatal ? ( - + ) : ( - + )}

Date: Wed, 4 Jun 2025 15:27:33 -0700 Subject: [PATCH 05/21] update deps --- extensions/vscode/package-lock.json | 6 +++--- gui/package-lock.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index e516f171e..1656cee97 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.41", + "version": "1.1.43", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.41", + "version": "1.1.43", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", @@ -107,7 +107,7 @@ "@aws-sdk/credential-providers": "^3.778.0", "@continuedev/config-types": "^1.0.13", "@continuedev/config-yaml": "file:../packages/config-yaml", - "@continuedev/fetch": "^1.0.10", + "@continuedev/fetch": "^1.0.13", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.25", "@modelcontextprotocol/sdk": "^1.12.0", diff --git a/gui/package-lock.json b/gui/package-lock.json index 1fb8463d7..b34d65846 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -111,7 +111,7 @@ "@aws-sdk/credential-providers": "^3.778.0", "@continuedev/config-types": "^1.0.13", "@continuedev/config-yaml": "file:../packages/config-yaml", - "@continuedev/fetch": "^1.0.10", + "@continuedev/fetch": "^1.0.13", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.25", "@modelcontextprotocol/sdk": "^1.12.0", From 364603e4dc9b83da51af04328139a73c374400f6 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Wed, 4 Jun 2025 16:20:13 -0700 Subject: [PATCH 06/21] fix prettier checks by pulling from main --- core/tools/implementations/runTerminalCommand.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/tools/implementations/runTerminalCommand.ts b/core/tools/implementations/runTerminalCommand.ts index b83adc479..785f4ee30 100644 --- a/core/tools/implementations/runTerminalCommand.ts +++ b/core/tools/implementations/runTerminalCommand.ts @@ -10,7 +10,17 @@ import { const asyncExec = util.promisify(childProcess.exec); -const ENABLED_FOR_REMOTES = ["","local","wsl","dev-container","devcontainer","ssh-remote","attached-container","codespaces","tunnel"]; +const ENABLED_FOR_REMOTES = [ + "", + "local", + "wsl", + "dev-container", + "devcontainer", + "ssh-remote", + "attached-container", + "codespaces", + "tunnel", +]; export const runTerminalCommandImpl: ToolImpl = async (args, extras) => { // Default to waiting for completion if not specified From f7fc1b83f2fb67caaaeed41e8df9381d08764272 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Thu, 5 Jun 2025 11:53:19 -0700 Subject: [PATCH 07/21] remove NEED_ERROR_PROPAGATION, pass asConfigResult as part of the option instead --- core/config/yaml/loadYaml.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index b8cbf1938..68f849aaf 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -118,7 +118,6 @@ async function loadConfigYaml(options: { // ); // This is how we allow use of blocks locally - const NEED_ERROR_PROPAGATION = true; const unrollResult = await unrollAssistant( packageIdentifier, new RegistryClient({ @@ -138,20 +137,21 @@ async function loadConfigYaml(options: { ), renderSecrets: true, injectBlocks: allLocalBlocks, + asConfigResult: true }, - NEED_ERROR_PROPAGATION, ); const errors: ConfigValidationError[] = []; - let config = overrideConfigYaml ?? unrollResult.config; + const config = overrideConfigYaml ?? unrollResult.config; + if (config) { isAssistantUnrolledNonNullable(config) ? errors.push(...validateConfigYaml(config)) : errors.push({ - fatal: true, - message: "Assistant includes blocks that don't exist", - }); + fatal: true, + message: "Assistant includes blocks that don't exist", + }); } if (unrollResult.errors) { From cdcb35484dac4dd2cd670a7d04243657e57b88ff Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Thu, 5 Jun 2025 11:54:42 -0700 Subject: [PATCH 08/21] add asConfigResult field to BaseUnrollAssistantOptions --- packages/config-yaml/src/load/unroll.ts | 134 ++++++++---------------- 1 file changed, 46 insertions(+), 88 deletions(-) diff --git a/packages/config-yaml/src/load/unroll.ts b/packages/config-yaml/src/load/unroll.ts index b90072b9b..7d201d22b 100644 --- a/packages/config-yaml/src/load/unroll.ts +++ b/packages/config-yaml/src/load/unroll.ts @@ -17,7 +17,7 @@ import { configYamlSchema, Rule, } from "../schemas/index.js"; -import { ConfigResult } from "../validation.js"; +import { ConfigResult, ConfigValidationError } from "../validation.js"; import { packageIdentifierToShorthandSlug, useProxyForUnrenderedSecrets, @@ -184,6 +184,7 @@ async function extractRenderedSecretsMap( export interface BaseUnrollAssistantOptions { renderSecrets: boolean; injectBlocks?: PackageIdentifier[]; + asConfigResult?: true; } export interface DoNotRenderSecretsUnrollAssistantOptions @@ -205,49 +206,35 @@ export type UnrollAssistantOptions = | DoNotRenderSecretsUnrollAssistantOptions | RenderSecretsUnrollAssistantOptions; -// Overload when we need error propapagation. +// Overload to satisfy existing consumers of unrollAssistant. export async function unrollAssistant( id: PackageIdentifier, registry: Registry, - options: UnrollAssistantOptions, - needErrorPropagation: true, + options: UnrollAssistantOptions & { asConfigResult: true } ): Promise>; -// Overload when we don't need error propapagation. export async function unrollAssistant( id: PackageIdentifier, registry: Registry, - options: UnrollAssistantOptions, - needErrorPropagation?: false, + options: UnrollAssistantOptions ): Promise; export async function unrollAssistant( id: PackageIdentifier, registry: Registry, options: UnrollAssistantOptions, - needErrorPropagation: boolean = false, ): Promise> { // Request the content from the registry const rawContent = await registry.getContent(id); - // Somewhat annoyingly, we need this redundant ternary to circumvent overload matching error. - // Without it TypeScript complains that no overloads of unrollAssistant - // has a field needErrorPropagation that accepts a boolean. - return needErrorPropagation - ? unrollAssistantFromContent( - id, - rawContent, - registry, - options, - needErrorPropagation, - ) - : unrollAssistantFromContent( - id, - rawContent, - registry, - options, - needErrorPropagation, - ); + const result = unrollAssistantFromContent( + id, + rawContent, + registry, + options, + ) + + return result; } function renderTemplateData( @@ -267,30 +254,11 @@ function renderTemplateData( return templatedYaml; } -// Overload when we need error propapagation. export async function unrollAssistantFromContent( id: PackageIdentifier, rawYaml: string, registry: Registry, options: UnrollAssistantOptions, - needErrorPropagation: true, -): Promise>; - -// Overload when we need don't error propapagation. -export async function unrollAssistantFromContent( - id: PackageIdentifier, - rawYaml: string, - registry: Registry, - options: UnrollAssistantOptions, - needErrorPropagation?: false, -): Promise; - -export async function unrollAssistantFromContent( - id: PackageIdentifier, - rawYaml: string, - registry: Registry, - options: UnrollAssistantOptions, - needErrorPropagation: boolean = false, ): Promise> { // Parse string to Zod-validated YAML let parsedYaml = parseConfigYaml(rawYaml); @@ -300,15 +268,16 @@ export async function unrollAssistantFromContent( parsedYaml, registry, options.injectBlocks, - needErrorPropagation, + options.asConfigResult ?? false ); // Back to a string so we can fill in template variables - const rawUnrolledYaml = needErrorPropagation - ? YAML.stringify( - (unrolledAssistant as ConfigResult).config, - ) - : YAML.stringify(unrolledAssistant); + const rawUnrolledYaml = YAML.stringify(unrolledAssistant); + // const rawUnrolledYaml = needErrorPropagation + // ? YAML.stringify( + // (unrolledAssistant as ConfigResult).config, + // ) + // : YAML.stringify(unrolledAssistant); // Convert all of the template variables to FQSNs // Secrets from the block will have the assistant slug prepended to the FQSN @@ -338,7 +307,7 @@ export async function unrollAssistantFromContent( options.onPremProxyUrl, ); - if (needErrorPropagation) { + if (options.asConfigResult) { return { config: finalConfig, errors: (unrolledAssistant as ConfigResult).errors, @@ -351,22 +320,13 @@ export async function unrollAssistantFromContent( return finalConfig; } -// We don't need oveloads here because -// the only place unrollBlocks is called directly is this file. -// unrollAssistantFromContent and unrollAssistant -// are called elsewhere in this project -// and imported in other projects. export async function unrollBlocks( assistant: ConfigYaml, registry: Registry, injectBlocks: PackageIdentifier[] | undefined, - needErrorPropagation: boolean = false, + asConfigError: boolean ): Promise> { - const configResult: ConfigResult = { - config: undefined, - errors: [], - configLoadInterrupted: false, - }; + const errors: ConfigValidationError[] = []; const unrolledAssistant: AssistantUnrolled = { name: assistant.name, @@ -399,13 +359,11 @@ export async function unrollBlocks( ); } } catch (err) { - if (needErrorPropagation) { - configResult.errors?.push({ - fatal: false, - // Using JSON.stringify to avoid printing [object Object]. - message: `Failed to unroll block ${JSON.stringify(unrolledBlock.uses)}: ${(err as Error).message}`, - }); - } + errors.push({ + fatal: false, + // Using JSON.stringify to avoid printing [object Object]. + message: `${(err as Error).message}:\n${JSON.stringify(unrolledBlock.uses)}`, + }); console.error( `Failed to unroll block ${JSON.stringify(unrolledBlock.uses)}: ${(err as Error).message}`, @@ -440,13 +398,11 @@ export async function unrollBlocks( rules.push(block); } } catch (err) { - if (needErrorPropagation) { - configResult.errors?.push({ - fatal: false, - // Using JSON.stringify to avoid printing [object Object]. - message: `Failed to unroll block ${JSON.stringify(rule.uses)}: ${(err as Error).message}`, - }); - } + errors.push({ + fatal: false, + // Using JSON.stringify to avoid printing [object Object]. + message: `${(err as Error).message}:\n${JSON.stringify(rule.uses)}`, + }); console.error( `Failed to unroll block ${JSON.stringify(rule.uses)}: ${(err as Error).message}`, @@ -480,13 +436,11 @@ export async function unrollBlocks( ); } } catch (err) { - if (needErrorPropagation) { - configResult.errors?.push({ - fatal: false, - // Using JSON.stringify to avoid printing [object Object]. - message: `Failed to unroll block ${JSON.stringify(injectBlock)}: ${(err as Error).message}`, - }); - } + errors.push({ + fatal: false, + // Using JSON.stringify to avoid printing [object Object]. + message: `${(err as Error).message}:\n${JSON.stringify(injectBlock)}`, + }); console.error( `Failed to unroll block ${JSON.stringify(injectBlock)}: ${(err as Error).message}`, @@ -494,12 +448,16 @@ export async function unrollBlocks( } } - if (needErrorPropagation) { + if (asConfigError) { + const configResult: ConfigResult = { + config: undefined, + errors: undefined, + configLoadInterrupted: false, + }; configResult.config = unrolledAssistant; - if (configResult.errors?.length == 0) { - configResult.errors = undefined; + if (errors.length > 0) { + configResult.errors = errors; } - configResult.configLoadInterrupted = false; return configResult; } From fd51701939610ae8122fc0bfe78c2752a111985d Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Thu, 5 Jun 2025 11:55:05 -0700 Subject: [PATCH 09/21] bump version --- extensions/vscode/package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 1656cee97..38efaa08a 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.43", + "version": "1.1.44", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.43", + "version": "1.1.44", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", From 36895bcea810486b3dfb357142d5c04409562fa1 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Thu, 5 Jun 2025 11:58:58 -0700 Subject: [PATCH 10/21] pass prettier checks --- core/config/yaml/loadYaml.ts | 8 ++++---- packages/config-yaml/src/load/unroll.ts | 15 +++++---------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 68f849aaf..29c6cc5dd 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -137,7 +137,7 @@ async function loadConfigYaml(options: { ), renderSecrets: true, injectBlocks: allLocalBlocks, - asConfigResult: true + asConfigResult: true, }, ); @@ -149,9 +149,9 @@ async function loadConfigYaml(options: { isAssistantUnrolledNonNullable(config) ? errors.push(...validateConfigYaml(config)) : errors.push({ - fatal: true, - message: "Assistant includes blocks that don't exist", - }); + fatal: true, + message: "Assistant includes blocks that don't exist", + }); } if (unrollResult.errors) { diff --git a/packages/config-yaml/src/load/unroll.ts b/packages/config-yaml/src/load/unroll.ts index 7d201d22b..db350052a 100644 --- a/packages/config-yaml/src/load/unroll.ts +++ b/packages/config-yaml/src/load/unroll.ts @@ -210,13 +210,13 @@ export type UnrollAssistantOptions = export async function unrollAssistant( id: PackageIdentifier, registry: Registry, - options: UnrollAssistantOptions & { asConfigResult: true } + options: UnrollAssistantOptions & { asConfigResult: true }, ): Promise>; export async function unrollAssistant( id: PackageIdentifier, registry: Registry, - options: UnrollAssistantOptions + options: UnrollAssistantOptions, ): Promise; export async function unrollAssistant( @@ -227,12 +227,7 @@ export async function unrollAssistant( // Request the content from the registry const rawContent = await registry.getContent(id); - const result = unrollAssistantFromContent( - id, - rawContent, - registry, - options, - ) + const result = unrollAssistantFromContent(id, rawContent, registry, options); return result; } @@ -268,7 +263,7 @@ export async function unrollAssistantFromContent( parsedYaml, registry, options.injectBlocks, - options.asConfigResult ?? false + options.asConfigResult ?? false, ); // Back to a string so we can fill in template variables @@ -324,7 +319,7 @@ export async function unrollBlocks( assistant: ConfigYaml, registry: Registry, injectBlocks: PackageIdentifier[] | undefined, - asConfigError: boolean + asConfigError: boolean, ): Promise> { const errors: ConfigValidationError[] = []; From 3d78ce12f36d2d1c428a1201ecce8e6c29552c27 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 5 Jun 2025 13:37:08 -0700 Subject: [PATCH 11/21] node fetch patch --- packages/fetch/package-lock.json | 203 ++++++++ packages/fetch/src/chunk-transformer.test.ts | 137 ----- packages/fetch/src/fetch.ts | 3 +- packages/fetch/src/node-fetch-bug.test.ts | 135 ----- packages/fetch/src/node-fetch-patch.js | 512 +++++++++++++++++++ packages/fetch/src/patch-test.test.js | 66 +++ packages/fetch/src/premature-close.test.ts | 405 --------------- 7 files changed, 783 insertions(+), 678 deletions(-) delete mode 100644 packages/fetch/src/chunk-transformer.test.ts delete mode 100644 packages/fetch/src/node-fetch-bug.test.ts create mode 100644 packages/fetch/src/node-fetch-patch.js create mode 100644 packages/fetch/src/patch-test.test.js delete mode 100644 packages/fetch/src/premature-close.test.ts diff --git a/packages/fetch/package-lock.json b/packages/fetch/package-lock.json index f2f55c648..087ca68a3 100644 --- a/packages/fetch/package-lock.json +++ b/packages/fetch/package-lock.json @@ -428,12 +428,79 @@ "node": ">=18" } }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", + "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.6.tgz", + "integrity": "sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25" + } + }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", "dev": true }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.41.1", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.41.1.tgz", @@ -860,6 +927,15 @@ "node": ">=12" } }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true + }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -894,10 +970,20 @@ "node": ">= 16" } }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true + }, "node_modules/data-uri-to-buffer": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "license": "MIT", "engines": { "node": ">= 12" } @@ -1005,6 +1091,7 @@ "url": "https://paypal.me/jimmywarting" } ], + "license": "MIT", "dependencies": { "node-domexception": "^1.0.0", "web-streams-polyfill": "^3.0.3" @@ -1036,6 +1123,7 @@ "version": "4.0.10", "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "license": "MIT", "dependencies": { "fetch-blob": "^3.1.2" }, @@ -1123,6 +1211,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "deprecated": "Use your platform's native DOMException instead", "funding": [ { "type": "github", @@ -1133,6 +1222,7 @@ "url": "https://paypal.me/jimmywarting" } ], + "license": "MIT", "engines": { "node": ">=10.5.0" } @@ -1141,6 +1231,7 @@ "version": "3.3.2", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "license": "MIT", "dependencies": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", @@ -1248,6 +1339,18 @@ "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", "dev": true }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "license": "BSD-3-Clause", + "optional": true, + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -1257,6 +1360,19 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, "node_modules/stackback": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", @@ -1269,6 +1385,42 @@ "integrity": "sha512-UGvjygr6F6tpH7o2qyqR6QYpwraIjKSdtzyBdyytFOHmPZY917kwdwLG0RbOjWOnKmnm3PeHjaoLLMie7kPLQw==", "dev": true }, + "node_modules/terser": { + "version": "5.41.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.41.0.tgz", + "integrity": "sha512-H406eLPXpZbAX14+B8psIuvIr8+3c+2hkuYzpMkoE0ij+NdsVATbA78vb8neA/eqrj7rywa2pIkdmWRsXW6wmw==", + "dev": true, + "license": "BSD-2-Clause", + "optional": true, + "peer": true, + "dependencies": { + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.14.0", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/terser/node_modules/acorn": { + "version": "8.14.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", + "integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/tinybench": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", @@ -1566,6 +1718,7 @@ "version": "3.3.3", "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "license": "MIT", "engines": { "node": ">= 8" } @@ -1586,6 +1739,21 @@ "node": ">=8" } }, + "node_modules/yaml": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.0.tgz", + "integrity": "sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ==", + "dev": true, + "license": "ISC", + "optional": true, + "peer": true, + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + } + }, "node_modules/zod": { "version": "3.23.8", "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", @@ -1593,6 +1761,41 @@ "funding": { "url": "https://github.com/sponsors/colinhacks" } + }, + "vendor/node-fetch": { + "version": "3.3.2", + "extraneous": true, + "license": "MIT", + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "devDependencies": { + "abort-controller": "^3.0.0", + "abortcontroller-polyfill": "^1.7.1", + "busboy": "^1.4.0", + "c8": "^7.7.2", + "chai": "^4.3.4", + "chai-as-promised": "^7.1.1", + "chai-iterator": "^3.0.2", + "chai-string": "^1.5.0", + "coveralls": "^3.1.0", + "form-data": "^4.0.0", + "formdata-node": "^4.2.4", + "mocha": "^9.1.3", + "p-timeout": "^5.0.0", + "stream-consumers": "^1.0.1", + "tsd": "^0.14.0", + "xo": "^0.39.1" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } } } } diff --git a/packages/fetch/src/chunk-transformer.test.ts b/packages/fetch/src/chunk-transformer.test.ts deleted file mode 100644 index 1f8354e62..000000000 --- a/packages/fetch/src/chunk-transformer.test.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { RequestOptions } from "@continuedev/config-types"; -import { Response } from "node-fetch"; -import { fetchwithRequestOptions } from "./fetch.js"; - -// Buffer accumulator that ensures proper chunk boundaries -class ChunkAccumulatorTransform implements Transformer { - private buffer: Uint8Array = new Uint8Array(0); - private expectedChunkSize: number | null = null; - private readonly minBufferSize = 8192; // 8KB minimum buffer - - constructor() { - this.buffer = new Uint8Array(0); - } - - private concatUint8Arrays(a: Uint8Array, b: Uint8Array): Uint8Array { - const result = new Uint8Array(a.length + b.length); - result.set(a, 0); - result.set(b, a.length); - return result; - } - - private tryParseChunkSize( - data: Uint8Array, - startIndex: number, - ): { size: number | null; endIndex: number } { - let size = 0; - let i = startIndex; - - // Look for the chunk size end marker - while (i < data.length - 1) { - // Check for CRLF - if (data[i] === 0x0d && data[i + 1] === 0x0a) { - return { size, endIndex: i + 2 }; - } - - // Parse hex digit - const char = String.fromCharCode(data[i]); - const digit = parseInt(char, 16); - if (!isNaN(digit)) { - size = (size << 4) | digit; - } - i++; - } - - return { size: null, endIndex: startIndex }; - } - - transform( - chunk: Uint8Array, - controller: TransformStreamDefaultController, - ) { - // Accumulate incoming data - this.buffer = this.concatUint8Arrays(this.buffer, chunk); - - // Process buffer while we have enough data - while (this.buffer.length > 0) { - // If we don't have a chunk size yet, try to parse it - if (this.expectedChunkSize === null) { - const { size, endIndex } = this.tryParseChunkSize(this.buffer, 0); - - if (size === null) { - // Not enough data to parse chunk size - if (this.buffer.length > this.minBufferSize) { - // Buffer is getting too large, flush it - controller.enqueue(this.buffer); - this.buffer = new Uint8Array(0); - } - return; - } - - this.expectedChunkSize = size; - this.buffer = this.buffer.slice(endIndex); - } - - // Check if we have a complete chunk - const expectedTotalSize = this.expectedChunkSize + 2; // +2 for CRLF - if (this.buffer.length < expectedTotalSize) { - return; // Wait for more data - } - - // We have a complete chunk, emit it - const chunk = this.buffer.slice(0, expectedTotalSize); - controller.enqueue(chunk); - - // Keep the rest in the buffer - this.buffer = this.buffer.slice(expectedTotalSize); - this.expectedChunkSize = null; - - // Check for end chunk - if ( - chunk.length >= 5 && - chunk[0] === 0x30 && // '0' - chunk[1] === 0x0d && // CR - chunk[2] === 0x0a && // LF - chunk[3] === 0x0d && // CR - chunk[4] === 0x0a - ) { - // LF - controller.terminate(); - return; - } - } - } - - flush(controller: TransformStreamDefaultController) { - if (this.buffer.length > 0) { - controller.enqueue(this.buffer); - } - } -} - -/** - * Creates a robust fetch function that handles ambiguous chunk boundaries - */ -export async function robustFetch( - url: string, - options?: RequestOptions, -): Promise { - const response = await fetchwithRequestOptions(url, options); - - // Only transform chunked responses - const transferEncoding = response.headers.get("transfer-encoding"); - if (transferEncoding?.toLowerCase().includes("chunked")) { - const transformStream = new TransformStream( - new ChunkAccumulatorTransform(), - ); - - // Create a new response with the transformed body - return new Response(response.body?.pipeThrough(transformStream), { - status: response.status, - statusText: response.statusText, - headers: options?.headers, - }); - } - - return response; -} diff --git a/packages/fetch/src/fetch.ts b/packages/fetch/src/fetch.ts index 9bf0d77ed..3b145012f 100644 --- a/packages/fetch/src/fetch.ts +++ b/packages/fetch/src/fetch.ts @@ -2,8 +2,9 @@ import { RequestOptions } from "@continuedev/config-types"; import * as followRedirects from "follow-redirects"; import { HttpProxyAgent } from "http-proxy-agent"; import { HttpsProxyAgent } from "https-proxy-agent"; -import fetch, { BodyInit, RequestInit, Response } from "node-fetch"; +import { BodyInit, RequestInit, Response } from "node-fetch"; import { getAgentOptions } from "./getAgentOptions.js"; +import fetch from "./node-fetch-patch.js"; import { getProxyFromEnv, shouldBypassProxy } from "./util.js"; const { http, https } = (followRedirects as any).default; diff --git a/packages/fetch/src/node-fetch-bug.test.ts b/packages/fetch/src/node-fetch-bug.test.ts deleted file mode 100644 index d1b320f75..000000000 --- a/packages/fetch/src/node-fetch-bug.test.ts +++ /dev/null @@ -1,135 +0,0 @@ -import { Buffer } from "buffer"; -import { EventEmitter } from "events"; -import { describe, expect, it } from "vitest"; - -/** - * This test reproduces the issue described in - * https://github.com/node-fetch/node-fetch/issues/1576 - * - * The issue is that node-fetch has a hard-coded assumption about how the end-of-chunked-response - * marker (0\r\n\r\n) might be split across chunks. It only handles two specific cases: - * 1. The entire marker is in the last chunk - * 2. The marker is split exactly as [0\r\n] + [\r\n] - * - * However, in real-world scenarios, the marker can be split in other ways, causing - * "Premature close" errors. - */ - -describe("node-fetch chunked encoding bug", () => { - // Mock the relevant portion of node-fetch's response handling - const LAST_CHUNK = Buffer.from("0\r\n\r\n"); - - function simulateChunkedResponseHandling(chunks: Buffer[]) { - const socket = new EventEmitter(); - let previousChunk: Buffer | undefined; - let properLastChunkReceived = false; - - // This is the problematic code from node-fetch - const onData = (buf: Buffer) => { - // Check if the entire marker is in the current chunk - properLastChunkReceived = Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0; - - // This is the limited assumption - it only handles one specific way the marker can be split - if (!properLastChunkReceived && previousChunk) { - properLastChunkReceived = - Buffer.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === - 0 && Buffer.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0; - } - - previousChunk = buf; - }; - - // Simulate receiving chunks - chunks.forEach((chunk) => { - onData(chunk); - socket.emit("data", chunk); - }); - - return properLastChunkReceived; - } - - // This is the improved code proposed in the GitHub issue by Treverix - function simulateImprovedChunkedResponseHandling(chunks: Buffer[]) { - const socket = new EventEmitter(); - let previousChunk: Buffer | undefined; - let properLastChunkReceived = false; - - const onData = (buf: Buffer) => { - // Check if the entire marker is in the current chunk - properLastChunkReceived = Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0; - - // More flexible handling of split markers - if (!properLastChunkReceived && previousChunk) { - if (buf.length < 5) { - // Create a composite buffer from the end of previous chunk and the current chunk - const composite = Buffer.from([...previousChunk.slice(-5), ...buf]); - properLastChunkReceived = - Buffer.compare(composite.slice(-5), LAST_CHUNK) === 0; - } - } - - previousChunk = buf; - }; - - // Simulate receiving chunks - chunks.forEach((chunk) => { - onData(chunk); - socket.emit("data", chunk); - }); - - return properLastChunkReceived; - } - - it("fails to detect end of chunked response when split in unexpected way", () => { - // This is the case reported in the GitHub issue - // previousChunk = [ (...), 0, 13, 10, 48, 13] - // lastChunk = [ 10, 13, 10] - // Where 13 = \r and 10 = \n - const previousChunk = Buffer.from([0, 13, 10, 48, 13]); - const lastChunk = Buffer.from([10, 13, 10]); - - // With the original implementation, it fails to detect the end marker - const originalResult = simulateChunkedResponseHandling([ - previousChunk, - lastChunk, - ]); - expect(originalResult).toBe(false); - - // With the improved implementation, it correctly detects the end marker - const improvedResult = simulateImprovedChunkedResponseHandling([ - previousChunk, - lastChunk, - ]); - expect(improvedResult).toBe(true); - }); - - it("handles various ways the end marker can be split", () => { - // Test various ways the marker can be split across chunks - const testCases = [ - // Case 1: [0] + [\r\n\r\n] - [Buffer.from([0]), Buffer.from([13, 10, 13, 10])], - - // Case 2: [0\r] + [\n\r\n] - [Buffer.from([0, 13]), Buffer.from([10, 13, 10])], - - // Case 3: [0\r\n] + [\r\n] - [Buffer.from([0, 13, 10]), Buffer.from([13, 10])], - - // Case 4: [0\r\n\r] + [\n] - [Buffer.from([0, 13, 10, 13]), Buffer.from([10])], - - // Case 5: [..., 0, \r, \n, \r] + [\n, ...] - [Buffer.from([99, 0, 13, 10, 13]), Buffer.from([10, 99])], - ]; - - testCases.forEach((chunks, index) => { - // The original implementation only handles case 3 correctly - const originalResult = simulateChunkedResponseHandling(chunks); - expect(originalResult).toBe(index === 2); - - // The improved implementation handles all cases - const improvedResult = simulateImprovedChunkedResponseHandling(chunks); - expect(improvedResult).toBe(true); - }); - }); -}); diff --git a/packages/fetch/src/node-fetch-patch.js b/packages/fetch/src/node-fetch-patch.js new file mode 100644 index 000000000..94d25c8cb --- /dev/null +++ b/packages/fetch/src/node-fetch-patch.js @@ -0,0 +1,512 @@ +/** + * Index.js + * + * a request API compatible with window.fetch + * + * All spec algorithm step numbers are based on https://fetch.spec.whatwg.org/commit-snapshots/ae716822cb3a61843226cd090eefc6589446c1d2/. + */ + +import { Buffer } from "node:buffer"; +import http from "node:http"; +import https from "node:https"; +import Stream, { PassThrough, pipeline as pump } from "node:stream"; +import zlib from "node:zlib"; + +import dataUriToBuffer from "data-uri-to-buffer"; + +import { + Blob, + blobFrom, + blobFromSync, + File, + fileFrom, + fileFromSync, +} from "fetch-blob/from.js"; +import { FormData } from "formdata-polyfill/esm.min.js"; +import { clone, writeToStream } from "node-fetch/src/body.js"; +import { AbortError } from "node-fetch/src/errors/abort-error.js"; +import { FetchError } from "node-fetch/src/errors/fetch-error.js"; +import Headers, { fromRawHeaders } from "node-fetch/src/headers.js"; +import Request, { getNodeRequestOptions } from "node-fetch/src/request.js"; +import Response from "node-fetch/src/response.js"; +import { isRedirect } from "node-fetch/src/utils/is-redirect.js"; +import { + isDomainOrSubdomain, + isSameProtocol, +} from "node-fetch/src/utils/is.js"; +import { parseReferrerPolicyFromHeader } from "node-fetch/src/utils/referrer.js"; + +export { + AbortError, + Blob, + blobFrom, + blobFromSync, + FetchError, + File, + fileFrom, + fileFromSync, + FormData, + Headers, + isRedirect, + Request, + Response, +}; + +const supportedSchemas = new Set(["data:", "http:", "https:"]); + +/** + * Fetch function + * + * @param {string | URL | import('./request').default} url - Absolute url or Request instance + * @param {*} [options_] - Fetch options + * @return {Promise} + */ +export default async function fetch(url, options_) { + return new Promise((resolve, reject) => { + // Build request object + const request = new Request(url, options_); + const { parsedURL, options } = getNodeRequestOptions(request); + if (!supportedSchemas.has(parsedURL.protocol)) { + throw new TypeError( + `node-fetch cannot load ${url}. URL scheme "${parsedURL.protocol.replace(/:$/, "")}" is not supported.`, + ); + } + + if (parsedURL.protocol === "data:") { + const data = dataUriToBuffer(request.url); + const response = new Response(data, { + headers: { "Content-Type": data.typeFull }, + }); + resolve(response); + return; + } + + // Wrap http.request into fetch + const send = (parsedURL.protocol === "https:" ? https : http).request; + const { signal } = request; + let response = null; + + const abort = () => { + const error = new AbortError("The operation was aborted."); + reject(error); + if (request.body && request.body instanceof Stream.Readable) { + request.body.destroy(error); + } + + if (!response || !response.body) { + return; + } + + response.body.emit("error", error); + }; + + if (signal && signal.aborted) { + abort(); + return; + } + + const abortAndFinalize = () => { + abort(); + finalize(); + }; + + // Send request + const request_ = send(parsedURL.toString(), options); + + if (signal) { + signal.addEventListener("abort", abortAndFinalize); + } + + const finalize = () => { + request_.abort(); + if (signal) { + signal.removeEventListener("abort", abortAndFinalize); + } + }; + + request_.on("error", (error) => { + reject( + new FetchError( + `request to ${request.url} failed, reason: ${error.message}`, + "system", + error, + ), + ); + finalize(); + }); + + fixResponseChunkedTransferBadEnding(request_, (error) => { + if (response && response.body) { + response.body.destroy(error); + } + }); + + /* c8 ignore next 18 */ + if (process.version < "v14") { + // Before Node.js 14, pipeline() does not fully support async iterators and does not always + // properly handle when the socket close/end events are out of order. + request_.on("socket", (s) => { + let endedWithEventsCount; + s.prependListener("end", () => { + endedWithEventsCount = s._eventsCount; + }); + s.prependListener("close", (hadError) => { + // if end happened before close but the socket didn't emit an error, do it now + if (response && endedWithEventsCount < s._eventsCount && !hadError) { + const error = new Error("Premature close"); + error.code = "ERR_STREAM_PREMATURE_CLOSE"; + response.body.emit("error", error); + } + }); + }); + } + + request_.on("response", (response_) => { + request_.setTimeout(0); + const headers = fromRawHeaders(response_.rawHeaders); + + // HTTP fetch step 5 + if (isRedirect(response_.statusCode)) { + // HTTP fetch step 5.2 + const location = headers.get("Location"); + + // HTTP fetch step 5.3 + let locationURL = null; + try { + locationURL = + location === null ? null : new URL(location, request.url); + } catch { + // error here can only be invalid URL in Location: header + // do not throw when options.redirect == manual + // let the user extract the errorneous redirect URL + if (request.redirect !== "manual") { + reject( + new FetchError( + `uri requested responds with an invalid redirect URL: ${location}`, + "invalid-redirect", + ), + ); + finalize(); + return; + } + } + + // HTTP fetch step 5.5 + switch (request.redirect) { + case "error": + reject( + new FetchError( + `uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, + "no-redirect", + ), + ); + finalize(); + return; + case "manual": + // Nothing to do + break; + case "follow": { + // HTTP-redirect fetch step 2 + if (locationURL === null) { + break; + } + + // HTTP-redirect fetch step 5 + if (request.counter >= request.follow) { + reject( + new FetchError( + `maximum redirect reached at: ${request.url}`, + "max-redirect", + ), + ); + finalize(); + return; + } + + // HTTP-redirect fetch step 6 (counter increment) + // Create a new Request object. + const requestOptions = { + headers: new Headers(request.headers), + follow: request.follow, + counter: request.counter + 1, + agent: request.agent, + compress: request.compress, + method: request.method, + body: clone(request), + signal: request.signal, + size: request.size, + referrer: request.referrer, + referrerPolicy: request.referrerPolicy, + }; + + // when forwarding sensitive headers like "Authorization", + // "WWW-Authenticate", and "Cookie" to untrusted targets, + // headers will be ignored when following a redirect to a domain + // that is not a subdomain match or exact match of the initial domain. + // For example, a redirect from "foo.com" to either "foo.com" or "sub.foo.com" + // will forward the sensitive headers, but a redirect to "bar.com" will not. + // headers will also be ignored when following a redirect to a domain using + // a different protocol. For example, a redirect from "https://foo.com" to "http://foo.com" + // will not forward the sensitive headers + if ( + !isDomainOrSubdomain(request.url, locationURL) || + !isSameProtocol(request.url, locationURL) + ) { + for (const name of [ + "authorization", + "www-authenticate", + "cookie", + "cookie2", + ]) { + requestOptions.headers.delete(name); + } + } + + // HTTP-redirect fetch step 9 + if ( + response_.statusCode !== 303 && + request.body && + options_.body instanceof Stream.Readable + ) { + reject( + new FetchError( + "Cannot follow redirect with body being a readable stream", + "unsupported-redirect", + ), + ); + finalize(); + return; + } + + // HTTP-redirect fetch step 11 + if ( + response_.statusCode === 303 || + ((response_.statusCode === 301 || response_.statusCode === 302) && + request.method === "POST") + ) { + requestOptions.method = "GET"; + requestOptions.body = undefined; + requestOptions.headers.delete("content-length"); + } + + // HTTP-redirect fetch step 14 + const responseReferrerPolicy = + parseReferrerPolicyFromHeader(headers); + if (responseReferrerPolicy) { + requestOptions.referrerPolicy = responseReferrerPolicy; + } + + // HTTP-redirect fetch step 15 + resolve(fetch(new Request(locationURL, requestOptions))); + finalize(); + return; + } + + default: + return reject( + new TypeError( + `Redirect option '${request.redirect}' is not a valid value of RequestRedirect`, + ), + ); + } + } + + // Prepare response + if (signal) { + response_.once("end", () => { + signal.removeEventListener("abort", abortAndFinalize); + }); + } + + let body = pump(response_, new PassThrough(), (error) => { + if (error) { + reject(error); + } + }); + // see https://github.com/nodejs/node/pull/29376 + /* c8 ignore next 3 */ + if (process.version < "v12.10") { + response_.on("aborted", abortAndFinalize); + } + + const responseOptions = { + url: request.url, + status: response_.statusCode, + statusText: response_.statusMessage, + headers, + size: request.size, + counter: request.counter, + highWaterMark: request.highWaterMark, + }; + + // HTTP-network fetch step 12.1.1.3 + const codings = headers.get("Content-Encoding"); + + // HTTP-network fetch step 12.1.1.4: handle content codings + + // in following scenarios we ignore compression support + // 1. compression support is disabled + // 2. HEAD request + // 3. no Content-Encoding header + // 4. no content response (204) + // 5. content not modified response (304) + if ( + !request.compress || + request.method === "HEAD" || + codings === null || + response_.statusCode === 204 || + response_.statusCode === 304 + ) { + response = new Response(body, responseOptions); + resolve(response); + return; + } + + // For Node v6+ + // Be less strict when decoding compressed responses, since sometimes + // servers send slightly invalid responses that are still accepted + // by common browsers. + // Always using Z_SYNC_FLUSH is what cURL does. + const zlibOptions = { + flush: zlib.Z_SYNC_FLUSH, + finishFlush: zlib.Z_SYNC_FLUSH, + }; + + // For gzip + if (codings === "gzip" || codings === "x-gzip") { + body = pump(body, zlib.createGunzip(zlibOptions), (error) => { + if (error) { + reject(error); + } + }); + response = new Response(body, responseOptions); + resolve(response); + return; + } + + // For deflate + if (codings === "deflate" || codings === "x-deflate") { + // Handle the infamous raw deflate response from old servers + // a hack for old IIS and Apache servers + const raw = pump(response_, new PassThrough(), (error) => { + if (error) { + reject(error); + } + }); + raw.once("data", (chunk) => { + // See http://stackoverflow.com/questions/37519828 + if ((chunk[0] & 0x0f) === 0x08) { + body = pump(body, zlib.createInflate(), (error) => { + if (error) { + reject(error); + } + }); + } else { + body = pump(body, zlib.createInflateRaw(), (error) => { + if (error) { + reject(error); + } + }); + } + + response = new Response(body, responseOptions); + resolve(response); + }); + raw.once("end", () => { + // Some old IIS servers return zero-length OK deflate responses, so + // 'data' is never emitted. See https://github.com/node-fetch/node-fetch/pull/903 + if (!response) { + response = new Response(body, responseOptions); + resolve(response); + } + }); + return; + } + + // For br + if (codings === "br") { + body = pump(body, zlib.createBrotliDecompress(), (error) => { + if (error) { + reject(error); + } + }); + response = new Response(body, responseOptions); + resolve(response); + return; + } + + // Otherwise, use response as-is + response = new Response(body, responseOptions); + resolve(response); + }); + + // eslint-disable-next-line promise/prefer-await-to-then + writeToStream(request_, request).catch(reject); + }); +} + +function fixResponseChunkedTransferBadEnding(request, errorCallback) { + const LAST_CHUNK = Buffer.from("0\r\n\r\n"); + + let isChunkedTransfer = false; + let properLastChunkReceived = false; + let previousChunk; + + request.on("response", (response) => { + const { headers } = response; + isChunkedTransfer = + headers["transfer-encoding"] === "chunked" && !headers["content-length"]; + }); + + request.on("socket", (socket) => { + const onSocketClose = () => { + if (isChunkedTransfer && !properLastChunkReceived) { + const error = new Error("Premature close"); + error.code = "ERR_STREAM_PREMATURE_CLOSE"; + errorCallback(error); + } + }; + + // const onData = buf => { + // properLastChunkReceived = Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0; + + // // Sometimes final 0-length chunk and end of message code are in separate packets + // if (!properLastChunkReceived && previousChunk) { + // properLastChunkReceived = ( + // Buffer.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 && + // Buffer.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0 + // ); + // } + + // previousChunk = buf; + // }; + + // VENDOR note - THIS IS THE REASON I AM PATCHING THIS PACKAGE + // See https://github.com/node-fetch/node-fetch/issues/1576 + // FIXES BOUNDARY CHUNKING ISSUE + const onData = (buf) => { + properLastChunkReceived = Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0; + + // Sometimes final 0-length chunk and end of message code are in separate packets + if (!properLastChunkReceived && previousChunk) { + if (buf.length < 5) { + properLastChunkReceived = + Buffer.compare( + Buffer.from([...previousChunk.slice(-5), ...buf]).slice(-5), + LAST_CHUNK, + ) === 0; + } + } + + previousChunk = buf; + }; + + socket.prependListener("close", onSocketClose); + socket.on("data", onData); + + request.on("close", () => { + socket.removeListener("close", onSocketClose); + socket.removeListener("data", onData); + }); + }); +} diff --git a/packages/fetch/src/patch-test.test.js b/packages/fetch/src/patch-test.test.js new file mode 100644 index 000000000..ee92e8dea --- /dev/null +++ b/packages/fetch/src/patch-test.test.js @@ -0,0 +1,66 @@ +import { Buffer } from "node:buffer"; +import { describe, expect, it } from "vitest"; + +describe("Chunked Transfer Encoding Patch Logic", () => { + // The LAST_CHUNK marker "0\r\n\r\n" + const LAST_CHUNK = Buffer.from("0\r\n\r\n"); + + it("should detect complete marker at the end (normal case)", () => { + const normalCase = Buffer.from("data data data 0\r\n\r\n"); + const result = Buffer.compare(normalCase.slice(-5), LAST_CHUNK) === 0; + expect(result).toBe(true); + }); + + it("should handle chunks split across original pattern (0\\r\\n | \\r\\n)", () => { + const previousChunk = Buffer.from("data data 0\r\n"); + const lastChunk = Buffer.from("\r\n"); + + const result = + Buffer.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 && + Buffer.compare(lastChunk.slice(-2), LAST_CHUNK.slice(3)) === 0; + + expect(result).toBe(true); + }); + + it("should handle problematic case from issue #1576 with new patch", () => { + // The problematic case: data ends with "0\r\n0\r" and the next chunk is "\n\r\n" + const previousChunk = Buffer.from([ + ...Array(10).fill(42), + 48, + 13, + 10, + 48, + 13, + ]); // some data + "0\r\n0\r" + const lastChunk = Buffer.from([10, 13, 10]); // "\n\r\n" + + // Check 1: Direct check for complete marker (should fail) + const check1 = Buffer.compare(lastChunk.slice(-5), LAST_CHUNK) === 0; + expect(check1).toBe(false); + + // Check 2: Original split pattern check (should fail) + const check2 = + Buffer.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 && + Buffer.compare(lastChunk.slice(-2), LAST_CHUNK.slice(3)) === 0; + expect(check2).toBe(false); + + // Check 3: New patch check (should pass) + const lastChunkLength = lastChunk.length; + const newPatchCheck = + lastChunkLength < 5 && + Buffer.compare( + Buffer.from([...previousChunk.slice(-5), ...lastChunk]).slice(-5), + LAST_CHUNK, + ) === 0; + expect(newPatchCheck).toBe(true); + + // Verification of the combined buffer + const combinedBuffer = Buffer.from([ + ...previousChunk.slice(-5), + ...lastChunk, + ]); + const combinedResult = + Buffer.compare(combinedBuffer.slice(-5), LAST_CHUNK) === 0; + expect(combinedResult).toBe(true); + }); +}); diff --git a/packages/fetch/src/premature-close.test.ts b/packages/fetch/src/premature-close.test.ts deleted file mode 100644 index 699dcde6c..000000000 --- a/packages/fetch/src/premature-close.test.ts +++ /dev/null @@ -1,405 +0,0 @@ -import { createServer } from "http"; -import { describe, expect, it } from "vitest"; -import { fetchwithRequestOptions } from "./fetch.js"; -import { streamResponse } from "./stream.js"; -describe("Fetch Premature Close Tests", () => { - // This test specifically forces conditions that cause premature close - it("should reproduce premature close error with chunked encoding", async () => { - // Create a server that intentionally misbehaves - const server = createServer((req, res) => { - // Set chunked transfer encoding - res.writeHead(200, { - "Content-Type": "text/plain", - "Transfer-Encoding": "chunked", - }); - - let chunk = 0; - const interval = setInterval(() => { - // Send malformed chunk sizes occasionally - if (chunk === 2) { - // Send a malformed chunk that will trigger the issue - res.write("5\r\nHello\r\n3\r"); // Intentionally incomplete chunk - clearInterval(interval); - - // Force socket closure mid-stream - setTimeout(() => { - // @ts-ignore - accessing private property for test - res.socket?.destroy(); - }, 50); - - return; - } - - res.write(`${chunk.toString(16)}\r\nChunk${chunk}\r\n`); - chunk++; - }, 10); - }); - - // Start server on random port - await new Promise((resolve) => server.listen(0, resolve)); - const port = (server.address() as any).port; - - try { - // Make request and attempt to stream response - const response = await fetchwithRequestOptions( - `http://localhost:${port}`, - { - headers: { - Connection: "keep-alive", - }, - }, - ); - - // Try to consume the stream - const chunks: string[] = []; - try { - for await (const chunk of streamResponse( - response as unknown as Response, - )) { - chunks.push(chunk); - } - // If we get here, the test failed because we expected an error - throw new Error( - "Expected premature close error but stream completed successfully", - ); - } catch (e) { - // Verify we got the expected error - expect(e).toBeTruthy(); - expect((e as Error).message).toMatch(/premature close/i); - } - } finally { - // Cleanup - server.close(); - } - }); - - // This test reproduces the issue using timing and connection pooling - it("should reproduce premature close with connection reuse", async () => { - // Create a server that intentionally causes issues with keep-alive connections - const server = createServer((req, res) => { - res.writeHead(200, { - "Content-Type": "text/plain", - Connection: "keep-alive", - "Transfer-Encoding": "chunked", - }); - - let bytesSent = 0; - const streamSize = 1024 * 1024; // 1MB - const chunkSize = 16384; // 16KB - - const writeChunk = () => { - if (bytesSent >= streamSize) { - res.end(); - return; - } - - const chunk = Buffer.alloc(chunkSize).fill("x"); - bytesSent += chunk.length; - - // Randomly corrupt the stream - if (Math.random() < 0.1) { - // @ts-ignore - accessing private property for test - res.socket?.destroy(); - return; - } - - res.write(chunk); - setImmediate(writeChunk); - }; - - writeChunk(); - }); - - await new Promise((resolve) => server.listen(0, resolve)); - const port = (server.address() as any).port; - - try { - // Make multiple concurrent requests to force connection pooling - const requests = Array(5) - .fill(null) - .map(async (_, i) => { - try { - const response = await fetchwithRequestOptions( - `http://localhost:${port}`, - { - headers: { - Connection: "keep-alive", - }, - }, - ); - - const chunks: string[] = []; - for await (const chunk of streamResponse( - response as unknown as Response, - )) { - chunks.push(chunk); - } - } catch (e) { - expect(e).toBeTruthy(); - expect((e as Error).message).toMatch( - /premature close|socket hang up/i, - ); - } - }); - - await Promise.all(requests); - } finally { - server.close(); - } - }); - - // This test reproduces the issue using a delayed response - it("should reproduce premature close with delayed response", async () => { - const server = createServer((req, res) => { - res.writeHead(200, { - "Content-Type": "text/plain", - "Transfer-Encoding": "chunked", - }); - - // Start sending data - let count = 0; - const interval = setInterval(() => { - if (count >= 5) { - clearInterval(interval); - // Delay then destroy the socket - setTimeout(() => { - // @ts-ignore - accessing private property for test - res.socket?.destroy(); - }, 100); - return; - } - - // Send a chunk with a delay - setTimeout(() => { - res.write(`chunk ${count}\n`); - }, count * 50); - - count++; - }, 10); - }); - - await new Promise((resolve) => server.listen(0, resolve)); - const port = (server.address() as any).port; - - try { - const response = await fetchwithRequestOptions( - `http://localhost:${port}`, - ); - - const chunks: string[] = []; - try { - for await (const chunk of streamResponse( - response as unknown as Response, - )) { - chunks.push(chunk); - // Optional artificial processing delay - await new Promise((resolve) => setTimeout(resolve, 20)); - } - throw new Error( - "Expected premature close error but stream completed successfully", - ); - } catch (e) { - expect(e).toBeTruthy(); - expect((e as Error).message).toMatch(/premature close/i); - } - } finally { - server.close(); - } - }); - - it("should properly handle chunk boundary in the terminating sequence", async () => { - // Flag to track if response was fully sent - let responseFullySent = false; - - const server = createServer((req, res) => { - res.writeHead(200, { - "Content-Type": "text/plain", - "Transfer-Encoding": "chunked", - }); - - // Send normal chunks directly as data (not writing the chunk headers manually) - // Node's HTTP server will handle adding the proper chunk headers - res.write("Hello"); - res.write("World!!"); - - // Now manually control the terminating sequence to split it at the boundary - // First, end the response but intercept the actual write - const originalEnd = res.end; - res.end = function () { - // Instead of letting Node send the terminating sequence normally, - // we'll send it split across a boundary - - // Manually send the first part of the termination sequence "0\r\n\r" - // @ts-ignore - accessing private property for test - const socket = res.socket; - socket?.write("0\r\n\r", "utf8"); - - // Small delay to ensure split across packets - setTimeout(() => { - // Send the final "\n" to complete the terminating sequence - socket?.write("\n", "utf8", () => { - // Mark that we've fully sent the response - responseFullySent = true; - }); - }, 20); - - // Don't call the original end since we're manually handling it - return res; - }; - }); - - await new Promise((resolve) => server.listen(0, resolve)); - const port = (server.address() as any).port; - - try { - const response = await fetchwithRequestOptions( - `http://localhost:${port}`, - { - headers: { - Connection: "keep-alive", - }, - }, - ); - - const chunks: Uint8Array[] = []; - let streamCompleted = false; - - try { - // Collect chunks as raw buffers to avoid encoding issues - for await (const chunk of streamResponse( - response as unknown as Response, - )) { - // Store the raw chunk - chunks.push(Buffer.from(chunk) as Uint8Array); - } - - // If we get here, the stream completed successfully - streamCompleted = true; - - // Wait a bit more to ensure server has time to set responseFullySent flag - await new Promise((resolve) => setTimeout(resolve, 100)); - - // Verify the response was fully sent by the server - expect(responseFullySent).toBe(true); - - // Convert all chunks to a single string and verify content - const content = Buffer.concat(chunks).toString("utf8"); - expect(content).toBe("HelloWorld!!"); - } catch (e) { - // If the server fully sent the response but we got an error, - // this confirms the client has an issue with the split boundary - if (responseFullySent) { - // This is the assertion that proves the 3/2 boundary issue exists - console.log( - "Server sent complete response but client failed to parse it properly", - ); - console.log("Error:", (e as Error).message); - expect((e as Error).message).toMatch( - /premature close|invalid chunked encoding/i, - ); - - // We should still verify we got some data before the error - const partialContent = Buffer.concat(chunks).toString("utf8"); - expect(partialContent).toContain("Hello"); - } else { - // If the server didn't fully send the response, the test is inconclusive - throw new Error( - "Test inconclusive: Server didn't complete sending response before error occurred", - ); - } - } - - // If the stream completed and the response was fully sent, - // the client correctly handled the split boundary - if (streamCompleted && responseFullySent) { - console.log("Client correctly handled split terminating sequence"); - } - } finally { - server.close(); - } - }); - - // This test reproduces the 3/2 assumption bug with multiline chunks - it("should reproduce premature close with multiline chunks containing line breaks", async () => { - const server = createServer((req, res) => { - res.writeHead(200, { - "Content-Type": "text/plain", - "Transfer-Encoding": "chunked", - }); - - // First send a normal chunk - res.write("A\r\nHello there\r\n"); - - // Send a chunk with a size that contains multiline data with \r\n inside - // This is valid chunked encoding but might confuse parsers - // The chunk size "1E" = 30 bytes - res.write("1E\r\n"); // Chunk size header - res.write("Line 1\r\nLine 2\r\nLine 3 not done yet"); // 30 bytes total - res.write("\r\n"); // Chunk terminator - - // Now send another chunk that starts with a line continuation - // This creates a situation where \r\n appears in data and as chunk boundaries - res.write("14\r\n"); // Size of 20 bytes - res.write(" continued from before\r\n"); - res.write("\r\n"); // Chunk terminator - - // Here's where we'll try to trigger the bug - // Send the final chunk marker but split across what could be mistaken for a line boundary - setTimeout(() => { - // Send "0\r" first - this could be mistaken for start of a line ending - res.write("0\r"); - - // Small delay to ensure separate TCP packets - setTimeout(() => { - // Now send "\n\r\n" - this creates ambiguous line endings - res.write("\n\r\n"); - - // Force close after a small delay to simulate network issues - setTimeout(() => { - // @ts-ignore - accessing private property for test - res.socket?.destroy(); - }, 20); - }, 10); - }, 10); - }); - - await new Promise((resolve) => server.listen(0, resolve)); - const port = (server.address() as any).port; - - try { - const response = await fetchwithRequestOptions( - `http://localhost:${port}`, - { - headers: { - Connection: "keep-alive", - }, - }, - ); - - const chunks: string[] = []; - try { - for await (const chunk of streamResponse( - response as unknown as Response, - )) { - chunks.push(chunk); - } - throw new Error( - "Expected premature close error but stream completed successfully", - ); - } catch (e) { - expect(e).toBeTruthy(); - expect((e as Error).message).toMatch(/premature close/i); - - // Verify we received the multiline data before the error - const receivedData = chunks.join(""); - expect(receivedData).toContain("Hello there"); - expect(receivedData).toContain("Line 1"); - expect(receivedData).toContain("Line 2"); - expect(receivedData).toContain("Line 3 not done yet"); - expect(receivedData).toContain("continued from before"); - } - } finally { - server.close(); - } - }); -}); From bc23d5afcc4998dd10968c0ea19567c79490016d Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Thu, 5 Jun 2025 15:13:27 -0700 Subject: [PATCH 12/21] fix a bug where rawUnrolledYaml could pass as ConfigResult --- packages/config-yaml/src/load/unroll.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/config-yaml/src/load/unroll.ts b/packages/config-yaml/src/load/unroll.ts index db350052a..1bb04e3fd 100644 --- a/packages/config-yaml/src/load/unroll.ts +++ b/packages/config-yaml/src/load/unroll.ts @@ -267,12 +267,11 @@ export async function unrollAssistantFromContent( ); // Back to a string so we can fill in template variables - const rawUnrolledYaml = YAML.stringify(unrolledAssistant); - // const rawUnrolledYaml = needErrorPropagation - // ? YAML.stringify( - // (unrolledAssistant as ConfigResult).config, - // ) - // : YAML.stringify(unrolledAssistant); + const rawUnrolledYaml = options.asConfigResult + ? YAML.stringify( + (unrolledAssistant as ConfigResult).config, + ) + : YAML.stringify(unrolledAssistant); // Convert all of the template variables to FQSNs // Secrets from the block will have the assistant slug prepended to the FQSN From ba725ea96f544b751e900b43464d8eb88dfe559e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Jun 2025 15:49:55 +0000 Subject: [PATCH 13/21] Bump django from 3.2.7 to 4.2.22 in /manual-testing-sandbox Bumps [django](https://github.com/django/django) from 3.2.7 to 4.2.22. - [Commits](https://github.com/django/django/compare/3.2.7...4.2.22) --- updated-dependencies: - dependency-name: django dependency-version: 4.2.22 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- manual-testing-sandbox/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manual-testing-sandbox/requirements.txt b/manual-testing-sandbox/requirements.txt index 44147f676..55452b992 100644 --- a/manual-testing-sandbox/requirements.txt +++ b/manual-testing-sandbox/requirements.txt @@ -5,7 +5,7 @@ scipy==1.7.1 # Web development flask==2.0.2 -django==3.2.7 +django==4.2.22 # Request handling requests==2.26.0 From 78a620662229ef4775d31aef1cc7f42e5191e719 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 6 Jun 2025 12:42:40 -0700 Subject: [PATCH 14/21] better comments --- packages/fetch/src/node-fetch-patch.js | 10 ++++++++-- .../{patch-test.test.js => node-fetch-patch.test.js} | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) rename packages/fetch/src/{patch-test.test.js => node-fetch-patch.test.js} (95%) diff --git a/packages/fetch/src/node-fetch-patch.js b/packages/fetch/src/node-fetch-patch.js index 94d25c8cb..10bb96531 100644 --- a/packages/fetch/src/node-fetch-patch.js +++ b/packages/fetch/src/node-fetch-patch.js @@ -1,3 +1,10 @@ +/* +This is a patched version of index.js from node-fetch 3.3.2 (see packages/fetch/node_modules/node-fetch/src/index.js) +This is to fix "Premature close" errors caused by chunked encoding assumptions - see https://github.com/continuedev/continue/issues/5502 +The patch adjusts boundary chunk detection logic (see "PATCH" comment next to patch) +And is based on https://github.com/node-fetch/node-fetch/issues/1576 +*/ + /** * Index.js * @@ -481,9 +488,8 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) { // previousChunk = buf; // }; - // VENDOR note - THIS IS THE REASON I AM PATCHING THIS PACKAGE + // PATCH - THIS IS WHERE THE PATCH IS - FIXES BOUNDARY CHUNKING ISSUE // See https://github.com/node-fetch/node-fetch/issues/1576 - // FIXES BOUNDARY CHUNKING ISSUE const onData = (buf) => { properLastChunkReceived = Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0; diff --git a/packages/fetch/src/patch-test.test.js b/packages/fetch/src/node-fetch-patch.test.js similarity index 95% rename from packages/fetch/src/patch-test.test.js rename to packages/fetch/src/node-fetch-patch.test.js index ee92e8dea..21f930ecb 100644 --- a/packages/fetch/src/patch-test.test.js +++ b/packages/fetch/src/node-fetch-patch.test.js @@ -1,6 +1,7 @@ import { Buffer } from "node:buffer"; import { describe, expect, it } from "vitest"; +// Tests the boundary chunking patch to node fetch made in node-fetch-patch.js (see that file for details). describe("Chunked Transfer Encoding Patch Logic", () => { // The LAST_CHUNK marker "0\r\n\r\n" const LAST_CHUNK = Buffer.from("0\r\n\r\n"); From 9a42322337f86cd9362fb655b0f479c5f8de088d Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 6 Jun 2025 12:44:25 -0700 Subject: [PATCH 15/21] restore fetch package lock --- packages/fetch/package-lock.json | 998 ++++++++++++++++++++++++------- 1 file changed, 780 insertions(+), 218 deletions(-) diff --git a/packages/fetch/package-lock.json b/packages/fetch/package-lock.json index 0b83e6377..1bf3a3a0b 100644 --- a/packages/fetch/package-lock.json +++ b/packages/fetch/package-lock.json @@ -22,18 +22,84 @@ }, "node_modules/@continuedev/config-types": { "version": "1.0.5", - "license": "Apache-2.0", + "resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.5.tgz", + "integrity": "sha512-Uv3JWKmpgSo9cMhZb2hWoJgR2ezuAn3CenEziWT/5d7mddPLzvuuHgFX6aDjLVVMojS1ul0rpfAd2LGxEb6nDQ==", "dependencies": { "zod": "^3.23.8" } }, - "node_modules/@esbuild/darwin-arm64": { + "node_modules/@esbuild/aix-ppc64": { "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.5.tgz", + "integrity": "sha512-9o3TMmpmftaCMepOdA5k/yDw8SfInyzWWTjYTFCX3kPSDJMROQTb8jg+h9Cnwnmm1vOzvxN7gIfB5V2ewpjtGA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.5.tgz", + "integrity": "sha512-AdJKSPeEHgi7/ZhuIPtcQKr5RQdo6OO2IL87JkianiMYMPbCtot9fxPbrMiBADOWWm3T2si9stAiVsGbTQFkbA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.5.tgz", + "integrity": "sha512-VGzGhj4lJO+TVGV1v8ntCZWJktV7SGCs3Pn1GRWI1SBFtRALoomm8k5E9Pmwg3HOAal2VDc2F9+PM/rEY6oIDg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.5.tgz", + "integrity": "sha512-D2GyJT1kjvO//drbRT3Hib9XPwQeWd9vZoBJn+bu/lVsOZ13cqNdDeqIF/xQ5/VmWvMduP6AmXvylO/PIc2isw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.5.tgz", + "integrity": "sha512-GtaBgammVvdF7aPIgH2jxMDdivezgFu6iKpmT+48+F8Hhg5J/sfnDieg0aeG/jfSvkYQU2/pceFPDKlqZzwnfQ==", "cpu": [ "arm64" ], "dev": true, - "license": "MIT", "optional": true, "os": [ "darwin" @@ -42,118 +108,636 @@ "node": ">=18" } }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.8", + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.5.tgz", + "integrity": "sha512-1iT4FVL0dJ76/q1wd7XDsXrSW+oLoquptvh4CLR4kITDtqi2e/xwXwdCVH8hVHU43wgJdsq7Gxuzcs6Iq/7bxQ==", + "cpu": [ + "x64" + ], "dev": true, - "license": "MIT", "optional": true, - "peer": true, - "dependencies": { - "@jridgewell/set-array": "^1.2.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.24" - }, + "os": [ + "darwin" + ], "engines": { - "node": ">=6.0.0" + "node": ">=18" } }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/set-array": { - "version": "1.2.1", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/source-map": { - "version": "0.3.6", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.25" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "dev": true, - "license": "MIT" - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.25", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, - "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.41.1", + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.5.tgz", + "integrity": "sha512-nk4tGP3JThz4La38Uy/gzyXtpkPW8zSAmoUhK9xKKXdBCzKODMc2adkB2+8om9BDYugz+uGV7sLmpTYzvmz6Sw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.5.tgz", + "integrity": "sha512-PrikaNjiXdR2laW6OIjlbeuCPrPaAl0IwPIaRv+SMV8CiM8i2LqVUHFC1+8eORgWyY7yhQY+2U2fA55mBzReaw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.5.tgz", + "integrity": "sha512-cPzojwW2okgh7ZlRpcBEtsX7WBuqbLrNXqLU89GxWbNt6uIg78ET82qifUy3W6OVww6ZWobWub5oqZOVtwolfw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.5.tgz", + "integrity": "sha512-Z9kfb1v6ZlGbWj8EJk9T6czVEjjq2ntSYLY2cw6pAZl4oKtfgQuS4HOq41M/BcoLPzrUbNd+R4BXFyH//nHxVg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.5.tgz", + "integrity": "sha512-sQ7l00M8bSv36GLV95BVAdhJ2QsIbCuCjh/uYrWiMQSUuV+LpXwIqhgJDcvMTj+VsQmqAHL2yYaasENvJ7CDKA==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.5.tgz", + "integrity": "sha512-0ur7ae16hDUC4OL5iEnDb0tZHDxYmuQyhKhsPBV8f99f6Z9KQM02g33f93rNH5A30agMS46u2HP6qTdEt6Q1kg==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.5.tgz", + "integrity": "sha512-kB/66P1OsHO5zLz0i6X0RxlQ+3cu0mkxS3TKFvkb5lin6uwZ/ttOkP3Z8lfR9mJOBk14ZwZ9182SIIWFGNmqmg==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.5.tgz", + "integrity": "sha512-UZCmJ7r9X2fe2D6jBmkLBMQetXPXIsZjQJCjgwpVDz+YMcS6oFR27alkgGv3Oqkv07bxdvw7fyB71/olceJhkQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.5.tgz", + "integrity": "sha512-kTxwu4mLyeOlsVIFPfQo+fQJAV9mh24xL+y+Bm6ej067sYANjyEw1dNHmvoqxJUCMnkBdKpvOn0Ahql6+4VyeA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.5.tgz", + "integrity": "sha512-K2dSKTKfmdh78uJ3NcWFiqyRrimfdinS5ErLSn3vluHNeHVnBAFWC8a4X5N+7FgVE1EjXS1QDZbpqZBjfrqMTQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.5.tgz", + "integrity": "sha512-uhj8N2obKTE6pSZ+aMUbqq+1nXxNjZIIjCjGLfsWvVpy7gKCOL6rsY1MhRh9zLtUtAI7vpgLMK6DxjO8Qm9lJw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.5.tgz", + "integrity": "sha512-pwHtMP9viAy1oHPvgxtOv+OkduK5ugofNTVDilIzBLpoWAM16r7b/mxBvfpuQDpRQFMfuVr5aLcn4yveGvBZvw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.5.tgz", + "integrity": "sha512-WOb5fKrvVTRMfWFNCroYWWklbnXH0Q5rZppjq0vQIdlsQKuw6mdSihwSo4RV/YdQ5UCKKvBy7/0ZZYLBZKIbwQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.5.tgz", + "integrity": "sha512-7A208+uQKgTxHd0G0uqZO8UjK2R0DDb4fDmERtARjSHWxqMTye4Erz4zZafx7Di9Cv+lNHYuncAkiGFySoD+Mw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.5.tgz", + "integrity": "sha512-G4hE405ErTWraiZ8UiSoesH8DaCsMm0Cay4fsFWOOUcz8b8rC6uCvnagr+gnioEjWn0wC+o1/TAHt+It+MpIMg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.5.tgz", + "integrity": "sha512-l+azKShMy7FxzY0Rj4RCt5VD/q8mG/e+mDivgspo+yL8zW7qEwctQ6YqKX34DTEleFAvCIUviCFX1SDZRSyMQA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.5.tgz", + "integrity": "sha512-O2S7SNZzdcFG7eFKgvwUEZ2VG9D/sn/eIiz8XRZ1Q/DO5a3s76Xv0mdBzVM5j5R639lXQmPmSo0iRpHqUUrsxw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.5.tgz", + "integrity": "sha512-onOJ02pqs9h1iMJ1PQphR+VZv8qBMQ77Klcsqv9CNW2w6yLqoURLcgERAIurY6QE63bbLuqgP9ATqajFLK5AMQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.5.tgz", + "integrity": "sha512-TXv6YnJ8ZMVdX+SXWVBo/0p8LTcrUYngpWjvm91TMjjBQii7Oz11Lw5lbDV5Y0TzuhSJHwiH4hEtC1I42mMS0g==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.41.1.tgz", + "integrity": "sha512-NELNvyEWZ6R9QMkiytB4/L4zSEaBC03KIXEghptLGLZWJ6VPrL63ooZQCOnlx36aQPGhzuOMwDerC1Eb2VmrLw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.41.1.tgz", + "integrity": "sha512-DXdQe1BJ6TK47ukAoZLehRHhfKnKg9BjnQYUu9gzhI8Mwa1d2fzxA1aw2JixHVl403bwp1+/o/NhhHtxWJBgEA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.41.1.tgz", + "integrity": "sha512-5afxvwszzdulsU2w8JKWwY8/sJOLPzf0e1bFuvcW5h9zsEg+RQAojdW0ux2zyYAz7R8HvvzKCjLNJhVq965U7w==", "cpu": [ "arm64" ], "dev": true, - "license": "MIT", "optional": true, "os": [ "darwin" ] }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.41.1.tgz", + "integrity": "sha512-egpJACny8QOdHNNMZKf8xY0Is6gIMz+tuqXlusxquWu3F833DcMwmGM7WlvCO9sB3OsPjdC4U0wHw5FabzCGZg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.41.1.tgz", + "integrity": "sha512-DBVMZH5vbjgRk3r0OzgjS38z+atlupJ7xfKIDJdZZL6sM6wjfDNo64aowcLPKIx7LMQi8vybB56uh1Ftck/Atg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.41.1.tgz", + "integrity": "sha512-3FkydeohozEskBxNWEIbPfOE0aqQgB6ttTkJ159uWOFn42VLyfAiyD9UK5mhu+ItWzft60DycIN1Xdgiy8o/SA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.41.1.tgz", + "integrity": "sha512-wC53ZNDgt0pqx5xCAgNunkTzFE8GTgdZ9EwYGVcg+jEjJdZGtq9xPjDnFgfFozQI/Xm1mh+D9YlYtl+ueswNEg==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.41.1.tgz", + "integrity": "sha512-jwKCca1gbZkZLhLRtsrka5N8sFAaxrGz/7wRJ8Wwvq3jug7toO21vWlViihG85ei7uJTpzbXZRcORotE+xyrLA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.41.1.tgz", + "integrity": "sha512-g0UBcNknsmmNQ8V2d/zD2P7WWfJKU0F1nu0k5pW4rvdb+BIqMm8ToluW/eeRmxCared5dD76lS04uL4UaNgpNA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.41.1.tgz", + "integrity": "sha512-XZpeGB5TKEZWzIrj7sXr+BEaSgo/ma/kCgrZgL0oo5qdB1JlTzIYQKel/RmhT6vMAvOdM2teYlAaOGJpJ9lahg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loongarch64-gnu": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.41.1.tgz", + "integrity": "sha512-bkCfDJ4qzWfFRCNt5RVV4DOw6KEgFTUZi2r2RuYhGWC8WhCA8lCAJhDeAmrM/fdiAH54m0mA0Vk2FGRPyzI+tw==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.41.1.tgz", + "integrity": "sha512-3mr3Xm+gvMX+/8EKogIZSIEF0WUu0HL9di+YWlJpO8CQBnoLAEL/roTCxuLncEdgcfJcvA4UMOf+2dnjl4Ut1A==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.41.1.tgz", + "integrity": "sha512-3rwCIh6MQ1LGrvKJitQjZFuQnT2wxfU+ivhNBzmxXTXPllewOF7JR1s2vMX/tWtUYFgphygxjqMl76q4aMotGw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.41.1.tgz", + "integrity": "sha512-LdIUOb3gvfmpkgFZuccNa2uYiqtgZAz3PTzjuM5bH3nvuy9ty6RGc/Q0+HDFrHrizJGVpjnTZ1yS5TNNjFlklw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.41.1.tgz", + "integrity": "sha512-oIE6M8WC9ma6xYqjvPhzZYk6NbobIURvP/lEbh7FWplcMO6gn7MM2yHKA1eC/GvYwzNKK/1LYgqzdkZ8YFxR8g==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.41.1.tgz", + "integrity": "sha512-cWBOvayNvA+SyeQMp79BHPK8ws6sHSsYnK5zDcsC3Hsxr1dgTABKjMnMslPq1DvZIp6uO7kIWhiGwaTdR4Og9A==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.41.1.tgz", + "integrity": "sha512-y5CbN44M+pUCdGDlZFzGGBSKCA4A/J2ZH4edTYSSxFg7ce1Xt3GtydbVKWLlzL+INfFIZAEg1ZV6hh9+QQf9YQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.41.1.tgz", + "integrity": "sha512-lZkCxIrjlJlMt1dLO/FbpZbzt6J/A8p4DnqzSa4PWqPEUUUnzXLeki/iyPLfV0BmHItlYgHUqJe+3KiyydmiNQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.41.1.tgz", + "integrity": "sha512-+psFT9+pIh2iuGsxFYYa/LhS5MFKmuivRsx9iPJWNSGbh2XVEjk90fmpUEjCnILPEPJnikAU6SFDiEUyOv90Pg==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.41.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.41.1.tgz", + "integrity": "sha512-Wq2zpapRYLfi4aKxf2Xff0tN+7slj2d4R87WEzqw7ZLsVvO5zwYCIuEGSZYiK41+GlwUo1HiR+GdkLEJnCKTCw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@types/chai": { "version": "5.2.2", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.2.tgz", + "integrity": "sha512-8kB30R7Hwqf40JPiKhVzodJs2Qc1ZJ5zuT3uzw5Hq/dhNCl3G3l83jfpdI1e20BP348+fV7VIL/+FxaXkqBmWg==", "dev": true, - "license": "MIT", "dependencies": { "@types/deep-eql": "*" } }, "node_modules/@types/deep-eql": { "version": "4.0.2", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true }, "node_modules/@types/estree": { "version": "1.0.7", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.7.tgz", + "integrity": "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==", + "dev": true }, "node_modules/@types/follow-redirects": { "version": "1.14.4", + "resolved": "https://registry.npmjs.org/@types/follow-redirects/-/follow-redirects-1.14.4.tgz", + "integrity": "sha512-GWXfsD0Jc1RWiFmMuMFCpXMzi9L7oPDVwxUnZdg89kDNnqsRfUKXEtUYtA98A6lig1WXH/CYY/fvPW9HuN5fTA==", "dev": true, - "license": "MIT", "dependencies": { "@types/node": "*" } }, "node_modules/@types/node": { "version": "20.14.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.10.tgz", + "integrity": "sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==", "dev": true, - "license": "MIT", "dependencies": { "undici-types": "~5.26.4" } }, "node_modules/@vitest/expect": { "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.0.tgz", + "integrity": "sha512-0v4YVbhDKX3SKoy0PHWXpKhj44w+3zZkIoVES9Ex2pq+u6+Bijijbi2ua5kE+h3qT6LBWFTNZSCOEU37H8Y5sA==", "dev": true, - "license": "MIT", "dependencies": { "@types/chai": "^5.2.2", "@vitest/spy": "3.2.0", @@ -167,8 +751,9 @@ }, "node_modules/@vitest/mocker": { "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.2.0.tgz", + "integrity": "sha512-HFcW0lAMx3eN9vQqis63H0Pscv0QcVMo1Kv8BNysZbxcmHu3ZUYv59DS6BGYiGQ8F5lUkmsfMMlPm4DJFJdf/A==", "dev": true, - "license": "MIT", "dependencies": { "@vitest/spy": "3.2.0", "estree-walker": "^3.0.3", @@ -192,8 +777,9 @@ }, "node_modules/@vitest/pretty-format": { "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.0.tgz", + "integrity": "sha512-gUUhaUmPBHFkrqnOokmfMGRBMHhgpICud9nrz/xpNV3/4OXCn35oG+Pl8rYYsKaTNd/FAIrqRHnwpDpmYxCYZw==", "dev": true, - "license": "MIT", "dependencies": { "tinyrainbow": "^2.0.0" }, @@ -203,8 +789,9 @@ }, "node_modules/@vitest/runner": { "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.2.0.tgz", + "integrity": "sha512-bXdmnHxuB7fXJdh+8vvnlwi/m1zvu+I06i1dICVcDQFhyV4iKw2RExC/acavtDn93m/dRuawUObKsrNE1gJacA==", "dev": true, - "license": "MIT", "dependencies": { "@vitest/utils": "3.2.0", "pathe": "^2.0.3" @@ -215,8 +802,9 @@ }, "node_modules/@vitest/snapshot": { "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.2.0.tgz", + "integrity": "sha512-z7P/EneBRMe7hdvWhcHoXjhA6at0Q4ipcoZo6SqgxLyQQ8KSMMCmvw1cSt7FHib3ozt0wnRHc37ivuUMbxzG/A==", "dev": true, - "license": "MIT", "dependencies": { "@vitest/pretty-format": "3.2.0", "magic-string": "^0.30.17", @@ -228,8 +816,9 @@ }, "node_modules/@vitest/spy": { "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.2.0.tgz", + "integrity": "sha512-s3+TkCNUIEOX99S0JwNDfsHRaZDDZZR/n8F0mop0PmsEbQGKZikCGpTGZ6JRiHuONKew3Fb5//EPwCP+pUX9cw==", "dev": true, - "license": "MIT", "dependencies": { "tinyspy": "^4.0.3" }, @@ -239,8 +828,9 @@ }, "node_modules/@vitest/utils": { "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.2.0.tgz", + "integrity": "sha512-gXXOe7Fj6toCsZKVQouTRLJftJwmvbhH5lKOBR6rlP950zUq9AitTUjnFoXS/CqjBC2aoejAztLPzzuva++XBw==", "dev": true, - "license": "MIT", "dependencies": { "@vitest/pretty-format": "3.2.0", "loupe": "^3.1.3", @@ -252,7 +842,8 @@ }, "node_modules/agent-base": { "version": "7.1.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", + "integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==", "dependencies": { "debug": "^4.3.4" }, @@ -262,31 +853,27 @@ }, "node_modules/assertion-error": { "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", "dev": true, - "license": "MIT", "engines": { "node": ">=12" } }, - "node_modules/buffer-from": { - "version": "1.1.2", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true - }, "node_modules/cac": { "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", "dev": true, - "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/chai": { "version": "5.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.2.0.tgz", + "integrity": "sha512-mCuXncKXk5iCLhfhwTc0izo0gtEmpz5CtG2y8GiOINBlMVS6v8TMRc5TaLWKS6692m9+dVVfzgeVxR5UxWHTYw==", "dev": true, - "license": "MIT", "dependencies": { "assertion-error": "^2.0.1", "check-error": "^2.1.1", @@ -300,29 +887,25 @@ }, "node_modules/check-error": { "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", "dev": true, - "license": "MIT", "engines": { "node": ">= 16" } }, - "node_modules/commander": { - "version": "2.20.3", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true - }, "node_modules/data-uri-to-buffer": { "version": "4.0.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", "engines": { "node": ">= 12" } }, "node_modules/debug": { "version": "4.4.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", "dependencies": { "ms": "^2.1.3" }, @@ -337,22 +920,25 @@ }, "node_modules/deep-eql": { "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", "dev": true, - "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/es-module-lexer": { "version": "1.7.0", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", + "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", + "dev": true }, "node_modules/esbuild": { "version": "0.25.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.5.tgz", + "integrity": "sha512-P8OtKZRv/5J5hhz0cUAdu/cLuPIKXpQl1R9pZtvmHWQvrAUVd0UNIPT4IB4W3rNOqVO0rlqHmCIbSwxh/c9yUQ==", "dev": true, "hasInstallScript": true, - "license": "MIT", "bin": { "esbuild": "bin/esbuild" }, @@ -389,22 +975,26 @@ }, "node_modules/estree-walker": { "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", "dev": true, - "license": "MIT", "dependencies": { "@types/estree": "^1.0.0" } }, "node_modules/expect-type": { "version": "1.2.1", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.2.1.tgz", + "integrity": "sha512-/kP8CAwxzLVEeFrMm4kMmy4CCDlpipyA7MYLVrdJIkV0fYF0UaigQHRsxHiuY/GEea+bh4KSv3TIlgr+2UL6bw==", "dev": true, - "license": "Apache-2.0", "engines": { "node": ">=12.0.0" } }, "node_modules/fetch-blob": { "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", "funding": [ { "type": "github", @@ -415,7 +1005,6 @@ "url": "https://paypal.me/jimmywarting" } ], - "license": "MIT", "dependencies": { "node-domexception": "^1.0.0", "web-streams-polyfill": "^3.0.3" @@ -426,13 +1015,14 @@ }, "node_modules/follow-redirects": { "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "funding": [ { "type": "individual", "url": "https://github.com/sponsors/RubenVerborgh" } ], - "license": "MIT", "engines": { "node": ">=4.0" }, @@ -444,7 +1034,8 @@ }, "node_modules/formdata-polyfill": { "version": "4.0.10", - "license": "MIT", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", "dependencies": { "fetch-blob": "^3.1.2" }, @@ -454,8 +1045,10 @@ }, "node_modules/fsevents": { "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, - "license": "MIT", + "hasInstallScript": true, "optional": true, "os": [ "darwin" @@ -466,7 +1059,8 @@ }, "node_modules/http-proxy-agent": { "version": "7.0.2", - "license": "MIT", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", + "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", "dependencies": { "agent-base": "^7.1.0", "debug": "^4.3.4" @@ -477,7 +1071,8 @@ }, "node_modules/https-proxy-agent": { "version": "7.0.5", - "license": "MIT", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz", + "integrity": "sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==", "dependencies": { "agent-base": "^7.0.2", "debug": "4" @@ -488,23 +1083,28 @@ }, "node_modules/loupe": { "version": "3.1.3", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.3.tgz", + "integrity": "sha512-kkIp7XSkP78ZxJEsSxW3712C6teJVoeHHwgo9zJ380de7IYyJ2ISlxojcH2pC5OFLewESmnRi/+XCDIEEVyoug==", + "dev": true }, "node_modules/magic-string": { "version": "0.30.17", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", + "integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==", "dev": true, - "license": "MIT", "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0" } }, "node_modules/ms": { "version": "2.1.3", - "license": "MIT" + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, "node_modules/nanoid": { "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", "dev": true, "funding": [ { @@ -512,7 +1112,6 @@ "url": "https://github.com/sponsors/ai" } ], - "license": "MIT", "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -522,6 +1121,8 @@ }, "node_modules/node-domexception": { "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", "funding": [ { "type": "github", @@ -532,14 +1133,14 @@ "url": "https://paypal.me/jimmywarting" } ], - "license": "MIT", "engines": { "node": ">=10.5.0" } }, "node_modules/node-fetch": { "version": "3.3.2", - "license": "MIT", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", "dependencies": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", @@ -555,24 +1156,29 @@ }, "node_modules/pathe": { "version": "2.0.3", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true }, "node_modules/pathval": { "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", + "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", "dev": true, - "license": "MIT", "engines": { "node": ">= 14.16" } }, "node_modules/picocolors": { "version": "1.1.1", - "dev": true, - "license": "ISC" + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true }, "node_modules/postcss": { "version": "8.5.4", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.4.tgz", + "integrity": "sha512-QSa9EBe+uwlGTFmHsPKokv3B/oEMQZxfqW0QqNCyhpa6mB1afzulwn8hihglqAb2pOw+BJgNlmXQ8la2VeHB7w==", "dev": true, "funding": [ { @@ -588,7 +1194,6 @@ "url": "https://github.com/sponsors/ai" } ], - "license": "MIT", "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", @@ -600,8 +1205,9 @@ }, "node_modules/rollup": { "version": "4.41.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.41.1.tgz", + "integrity": "sha512-cPmwD3FnFv8rKMBc1MxWCwVQFxwf1JEmSX3iQXrRVVG15zerAIXRjMFVWnd5Q5QvgKF7Aj+5ykXFhUl+QGnyOw==", "dev": true, - "license": "MIT", "dependencies": { "@types/estree": "1.0.7" }, @@ -638,94 +1244,48 @@ }, "node_modules/siginfo": { "version": "2.0.0", - "dev": true, - "license": "ISC" - }, - "node_modules/source-map": { - "version": "0.6.1", - "dev": true, - "license": "BSD-3-Clause", - "optional": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true }, "node_modules/source-map-js": { "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", "dev": true, - "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" } }, - "node_modules/source-map-support": { - "version": "0.5.21", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, "node_modules/stackback": { "version": "0.0.2", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true }, "node_modules/std-env": { "version": "3.9.0", - "dev": true, - "license": "MIT" - }, - "node_modules/terser": { - "version": "5.41.0", - "dev": true, - "license": "BSD-2-Clause", - "optional": true, - "peer": true, - "dependencies": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.14.0", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - }, - "bin": { - "terser": "bin/terser" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/terser/node_modules/acorn": { - "version": "8.14.1", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.9.0.tgz", + "integrity": "sha512-UGvjygr6F6tpH7o2qyqR6QYpwraIjKSdtzyBdyytFOHmPZY917kwdwLG0RbOjWOnKmnm3PeHjaoLLMie7kPLQw==", + "dev": true }, "node_modules/tinybench": { "version": "2.9.0", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true }, "node_modules/tinyexec": { "version": "0.3.2", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz", + "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==", + "dev": true }, "node_modules/tinyglobby": { "version": "0.2.14", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz", + "integrity": "sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==", "dev": true, - "license": "MIT", "dependencies": { "fdir": "^6.4.4", "picomatch": "^4.0.2" @@ -739,8 +1299,9 @@ }, "node_modules/tinyglobby/node_modules/fdir": { "version": "6.4.5", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.5.tgz", + "integrity": "sha512-4BG7puHpVsIYxZUbiUE3RqGloLaSSwzYie5jvasC4LWuBWzZawynvYouhjbQKw2JuIGYdm0DzIxl8iVidKlUEw==", "dev": true, - "license": "MIT", "peerDependencies": { "picomatch": "^3 || ^4" }, @@ -752,8 +1313,9 @@ }, "node_modules/tinyglobby/node_modules/picomatch": { "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", "dev": true, - "license": "MIT", "engines": { "node": ">=12" }, @@ -763,37 +1325,42 @@ }, "node_modules/tinypool": { "version": "1.1.0", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.0.tgz", + "integrity": "sha512-7CotroY9a8DKsKprEy/a14aCCm8jYVmR7aFy4fpkZM8sdpNJbKkixuNjgM50yCmip2ezc8z4N7k3oe2+rfRJCQ==", "dev": true, - "license": "MIT", "engines": { "node": "^18.0.0 || >=20.0.0" } }, "node_modules/tinyrainbow": { "version": "2.0.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz", + "integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==", "dev": true, - "license": "MIT", "engines": { "node": ">=14.0.0" } }, "node_modules/tinyspy": { "version": "4.0.3", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-4.0.3.tgz", + "integrity": "sha512-t2T/WLB2WRgZ9EpE4jgPJ9w+i66UZfDc8wHh0xrwiRNN+UwH98GIJkTeZqX9rg0i0ptwzqW+uYeIF0T4F8LR7A==", "dev": true, - "license": "MIT", "engines": { "node": ">=14.0.0" } }, "node_modules/undici-types": { "version": "5.26.5", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true }, "node_modules/vite": { "version": "6.3.5", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz", + "integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==", "dev": true, - "license": "MIT", "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.4.4", @@ -865,8 +1432,9 @@ }, "node_modules/vite-node": { "version": "3.2.0", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.2.0.tgz", + "integrity": "sha512-8Fc5Ko5Y4URIJkmMF/iFP1C0/OJyY+VGVe9Nw6WAdZyw4bTO+eVg9mwxWkQp/y8NnAoQY3o9KAvE1ZdA2v+Vmg==", "dev": true, - "license": "MIT", "dependencies": { "cac": "^6.7.14", "debug": "^4.4.1", @@ -886,8 +1454,9 @@ }, "node_modules/vite/node_modules/fdir": { "version": "6.4.5", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.5.tgz", + "integrity": "sha512-4BG7puHpVsIYxZUbiUE3RqGloLaSSwzYie5jvasC4LWuBWzZawynvYouhjbQKw2JuIGYdm0DzIxl8iVidKlUEw==", "dev": true, - "license": "MIT", "peerDependencies": { "picomatch": "^3 || ^4" }, @@ -899,8 +1468,9 @@ }, "node_modules/vite/node_modules/picomatch": { "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", "dev": true, - "license": "MIT", "engines": { "node": ">=12" }, @@ -910,8 +1480,9 @@ }, "node_modules/vitest": { "version": "3.2.0", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.0.tgz", + "integrity": "sha512-P7Nvwuli8WBNmeMHHek7PnGW4oAZl9za1fddfRVidZar8wDZRi7hpznLKQePQ8JPLwSBEYDK11g+++j7uFJV8Q==", "dev": true, - "license": "MIT", "dependencies": { "@types/chai": "^5.2.2", "@vitest/expect": "3.2.0", @@ -981,8 +1552,9 @@ }, "node_modules/vitest/node_modules/picomatch": { "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", "dev": true, - "license": "MIT", "engines": { "node": ">=12" }, @@ -992,15 +1564,17 @@ }, "node_modules/web-streams-polyfill": { "version": "3.3.3", - "license": "MIT", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", "engines": { "node": ">= 8" } }, "node_modules/why-is-node-running": { "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", "dev": true, - "license": "MIT", "dependencies": { "siginfo": "^2.0.0", "stackback": "0.0.2" @@ -1012,22 +1586,10 @@ "node": ">=8" } }, - "node_modules/yaml": { - "version": "2.8.0", - "dev": true, - "license": "ISC", - "optional": true, - "peer": true, - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14.6" - } - }, "node_modules/zod": { "version": "3.23.8", - "license": "MIT", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", + "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", "funding": { "url": "https://github.com/sponsors/colinhacks" } From 1dddae2381cb320fa5f0d3d05d96328057a90c79 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Fri, 6 Jun 2025 14:04:57 -0700 Subject: [PATCH 16/21] lazily unroll local assistant --- core/config/yaml/loadYaml.ts | 68 +++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 29c6cc5dd..5a0bc99ba 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -117,45 +117,49 @@ async function loadConfigYaml(options: { // `Loading config.yaml from ${JSON.stringify(packageIdentifier)} with root path ${rootPath}`, // ); - // This is how we allow use of blocks locally - const unrollResult = await unrollAssistant( - packageIdentifier, - new RegistryClient({ - accessToken: await controlPlaneClient.getAccessToken(), - apiBase: getControlPlaneEnvSync(ideSettings.continueTestEnvironment) - .CONTROL_PLANE_URL, - rootPath, - }), - { - currentUserSlug: "", - onPremProxyUrl: null, - orgScopeId, - platformClient: new LocalPlatformClient( - orgScopeId, - controlPlaneClient, - ide, - ), - renderSecrets: true, - injectBlocks: allLocalBlocks, - asConfigResult: true, - }, - ); - const errors: ConfigValidationError[] = []; - const config = overrideConfigYaml ?? unrollResult.config; + let config: AssistantUnrolled | undefined; + + if (overrideConfigYaml) { + config = overrideConfigYaml; + } else { + // This is how we allow use of blocks locally + const unrollResult = await unrollAssistant( + packageIdentifier, + new RegistryClient({ + accessToken: await controlPlaneClient.getAccessToken(), + apiBase: getControlPlaneEnvSync(ideSettings.continueTestEnvironment) + .CONTROL_PLANE_URL, + rootPath, + }), + { + currentUserSlug: "", + onPremProxyUrl: null, + orgScopeId, + platformClient: new LocalPlatformClient( + orgScopeId, + controlPlaneClient, + ide, + ), + renderSecrets: true, + injectBlocks: allLocalBlocks, + asConfigResult: true, + }, + ); + config = unrollResult.config; + if (unrollResult.errors) { + errors.push(...unrollResult.errors); + } + } if (config) { isAssistantUnrolledNonNullable(config) ? errors.push(...validateConfigYaml(config)) : errors.push({ - fatal: true, - message: "Assistant includes blocks that don't exist", - }); - } - - if (unrollResult.errors) { - errors.push(...unrollResult.errors); + fatal: true, + message: "Assistant includes blocks that don't exist", + }); } if (errors?.some((error) => error.fatal)) { From 13b4b5092f830762c3a7fa7a0d9a27efd5af6fc3 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Fri, 6 Jun 2025 14:05:12 -0700 Subject: [PATCH 17/21] better error formatting --- packages/config-yaml/src/load/unroll.ts | 80 +++++++++++++++++++------ 1 file changed, 62 insertions(+), 18 deletions(-) diff --git a/packages/config-yaml/src/load/unroll.ts b/packages/config-yaml/src/load/unroll.ts index 1bb04e3fd..7c112a108 100644 --- a/packages/config-yaml/src/load/unroll.ts +++ b/packages/config-yaml/src/load/unroll.ts @@ -1,4 +1,6 @@ +import * as path from "path"; import * as YAML from "yaml"; +import { ZodError } from "zod"; import { PlatformClient, Registry } from "../interfaces/index.js"; import { encodeSecretLocation } from "../interfaces/SecretResult.js"; import { @@ -31,16 +33,25 @@ export function parseConfigYaml(configYaml: string): ConfigYaml { if (result.success) { return result.data; } - throw new Error( - result.error.errors - .map((e) => `${e.path.join(".")}: ${e.message}`) - .join(""), - ); + + throw new Error(formatZodError(result.error), { + cause: "result.success was false", + }); } catch (e) { - console.log("Failed to parse rolled assistant:", configYaml); - throw new Error( - `Failed to parse assistant:\n${e instanceof Error ? e.message : e}`, - ); + console.error("Failed to parse rolled assistant:", configYaml); + if ( + e instanceof Error && + "cause" in e && + e.cause === "result.success was false" + ) { + throw new Error(`Failed to parse assistant: ${e.message}`); + } else if (e instanceof ZodError) { + throw new Error(`Failed to parse assistant: ${formatZodError(e)}`); + } else { + throw new Error( + `Failed to parse assistant: ${e instanceof Error ? e.message : e}`, + ); + } } } @@ -50,9 +61,10 @@ export function parseAssistantUnrolled(configYaml: string): AssistantUnrolled { const result = assistantUnrolledSchema.parse(parsed); return result; } catch (e: any) { - throw new Error( + console.error( `Failed to parse unrolled assistant: ${e.message}\n\n${configYaml}`, ); + throw new Error(`Failed to parse unrolled assistant: ${formatZodError(e)}`); } } @@ -62,7 +74,7 @@ export function parseBlock(configYaml: string): Block { const result = blockSchema.parse(parsed); return result; } catch (e: any) { - throw new Error(`Failed to parse block: ${e.message}`); + throw new Error(`Failed to parse block: ${formatZodError(e)}`); } } @@ -353,10 +365,19 @@ export async function unrollBlocks( ); } } catch (err) { + let msg = ""; + if ( + typeof unrolledBlock.uses !== "string" && + "filePath" in unrolledBlock.uses + ) { + msg = `${(err as Error).message}.\n> ${shortenedPath(unrolledBlock.uses.filePath)}`; + } else { + msg = `${(err as Error).message}.\n> ${JSON.stringify(unrolledBlock.uses)}`; + } + errors.push({ fatal: false, - // Using JSON.stringify to avoid printing [object Object]. - message: `${(err as Error).message}:\n${JSON.stringify(unrolledBlock.uses)}`, + message: msg, }); console.error( @@ -394,12 +415,11 @@ export async function unrollBlocks( } catch (err) { errors.push({ fatal: false, - // Using JSON.stringify to avoid printing [object Object]. - message: `${(err as Error).message}:\n${JSON.stringify(rule.uses)}`, + message: `${(err as Error).message}:\n${rule.uses}`, }); console.error( - `Failed to unroll block ${JSON.stringify(rule.uses)}: ${(err as Error).message}`, + `Failed to unroll block ${rule.uses}: ${(err as Error).message}`, ); rules.push(null); } @@ -430,10 +450,15 @@ export async function unrollBlocks( ); } } catch (err) { + let msg = ""; + if (injectBlock.uriType === "file") { + msg = `${(err as Error).message}.\n> ${shortenedPath(injectBlock.filePath)}`; + } else { + msg = `${(err as Error).message}.\n> ${injectBlock.fullSlug}`; + } errors.push({ fatal: false, - // Using JSON.stringify to avoid printing [object Object]. - message: `${(err as Error).message}:\n${JSON.stringify(injectBlock)}`, + message: msg, }); console.error( @@ -507,3 +532,22 @@ export function mergeOverrides>( } return block; } + +function formatZodError(error: any): string { + if (error.errors && Array.isArray(error.errors)) { + return error.errors + .map((e: any) => { + const path = e.path.length > 0 ? `${e.path.join(".")}: ` : ""; + return `${path}${e.message}`; + }) + .join(", "); + } + return error.message || "Validation failed"; +} + +function shortenedPath(filePath: string): string { + const basename = path.posix.basename(filePath); + const parent = path.posix.basename(path.posix.dirname(filePath)); + const shortenedPath = `${parent}/${basename}`; + return shortenedPath; +} From f55f79eeb45d096ee9c36814af7630994cde6684 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Fri, 6 Jun 2025 14:05:21 -0700 Subject: [PATCH 18/21] bump version --- extensions/vscode/package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 38efaa08a..349212a6a 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.44", + "version": "1.1.45", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.44", + "version": "1.1.45", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", From f5dfc4dfee6b5766005d05dab18664424adeaea0 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Fri, 6 Jun 2025 14:15:38 -0700 Subject: [PATCH 19/21] pass prettier checks --- core/config/yaml/loadYaml.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 5a0bc99ba..2217d222c 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -157,9 +157,9 @@ async function loadConfigYaml(options: { isAssistantUnrolledNonNullable(config) ? errors.push(...validateConfigYaml(config)) : errors.push({ - fatal: true, - message: "Assistant includes blocks that don't exist", - }); + fatal: true, + message: "Assistant includes blocks that don't exist", + }); } if (errors?.some((error) => error.fatal)) { From e871252ddd9d0cd4e6bcfeee7985b31aa56a1976 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Fri, 6 Jun 2025 15:20:06 -0700 Subject: [PATCH 20/21] use existing util function to resolve URIs --- packages/config-yaml/src/load/unroll.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/config-yaml/src/load/unroll.ts b/packages/config-yaml/src/load/unroll.ts index 7c112a108..8e9507b79 100644 --- a/packages/config-yaml/src/load/unroll.ts +++ b/packages/config-yaml/src/load/unroll.ts @@ -1,6 +1,7 @@ import * as path from "path"; import * as YAML from "yaml"; import { ZodError } from "zod"; +import { getLastNUriRelativePathParts } from "../../../../core/util/uri.js"; import { PlatformClient, Registry } from "../interfaces/index.js"; import { encodeSecretLocation } from "../interfaces/SecretResult.js"; import { @@ -370,7 +371,7 @@ export async function unrollBlocks( typeof unrolledBlock.uses !== "string" && "filePath" in unrolledBlock.uses ) { - msg = `${(err as Error).message}.\n> ${shortenedPath(unrolledBlock.uses.filePath)}`; + msg = `${(err as Error).message}.\n> ${getLastNUriRelativePathParts([], unrolledBlock.uses.filePath, 2)}`; } else { msg = `${(err as Error).message}.\n> ${JSON.stringify(unrolledBlock.uses)}`; } @@ -452,7 +453,7 @@ export async function unrollBlocks( } catch (err) { let msg = ""; if (injectBlock.uriType === "file") { - msg = `${(err as Error).message}.\n> ${shortenedPath(injectBlock.filePath)}`; + msg = `${(err as Error).message}.\n> ${getLastNUriRelativePathParts([], injectBlock.filePath, 2)}`; } else { msg = `${(err as Error).message}.\n> ${injectBlock.fullSlug}`; } From 6ca026852df36310e2214cd595b0277212820f71 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Fri, 6 Jun 2025 15:43:42 -0700 Subject: [PATCH 21/21] rever to printing full file path --- packages/config-yaml/src/load/unroll.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/config-yaml/src/load/unroll.ts b/packages/config-yaml/src/load/unroll.ts index 8e9507b79..9d3040721 100644 --- a/packages/config-yaml/src/load/unroll.ts +++ b/packages/config-yaml/src/load/unroll.ts @@ -1,7 +1,5 @@ -import * as path from "path"; import * as YAML from "yaml"; import { ZodError } from "zod"; -import { getLastNUriRelativePathParts } from "../../../../core/util/uri.js"; import { PlatformClient, Registry } from "../interfaces/index.js"; import { encodeSecretLocation } from "../interfaces/SecretResult.js"; import { @@ -371,7 +369,7 @@ export async function unrollBlocks( typeof unrolledBlock.uses !== "string" && "filePath" in unrolledBlock.uses ) { - msg = `${(err as Error).message}.\n> ${getLastNUriRelativePathParts([], unrolledBlock.uses.filePath, 2)}`; + msg = `${(err as Error).message}.\n> ${unrolledBlock.uses.filePath}`; } else { msg = `${(err as Error).message}.\n> ${JSON.stringify(unrolledBlock.uses)}`; } @@ -453,7 +451,7 @@ export async function unrollBlocks( } catch (err) { let msg = ""; if (injectBlock.uriType === "file") { - msg = `${(err as Error).message}.\n> ${getLastNUriRelativePathParts([], injectBlock.filePath, 2)}`; + msg = `${(err as Error).message}.\n> ${injectBlock.filePath}`; } else { msg = `${(err as Error).message}.\n> ${injectBlock.fullSlug}`; } @@ -545,10 +543,3 @@ function formatZodError(error: any): string { } return error.message || "Validation failed"; } - -function shortenedPath(filePath: string): string { - const basename = path.posix.basename(filePath); - const parent = path.posix.basename(path.posix.dirname(filePath)); - const shortenedPath = `${parent}/${basename}`; - return shortenedPath; -}