diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index aeb498ba..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:prettier/recommended" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 12, - "sourceType": "module" - }, - "plugins": ["simple-import-sort", "import", "@typescript-eslint", "prettier"], - "settings": { - "import/resolver": { - "node": { - "extensions": [".js", ".jsx", ".ts", ".tsx"] - } - } - }, - "packageManager": "npm", - "rules": { - "prettier/prettier": "error", - "no-console": "error", - "import/order": "off", - "sort-imports": "off", - "simple-import-sort/imports": "error", - "simple-import-sort/exports": "error", - "import/first": "error", - "import/newline-after-import": "error", - "import/no-duplicates": "error", - "@typescript-eslint/no-non-null-assertion": "off" - } -} diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml index 0ddd69b7..b69c29bb 100644 --- a/.github/ISSUE_TEMPLATE/bug.yaml +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -1,7 +1,7 @@ name: 🐞 Bug Report description: File a bug report -title: "[Bug]: " -labels: ["bug", "triage"] +title: '[Bug]: ' +labels: ['bug', 'triage'] assignees: - octocat body: @@ -48,7 +48,7 @@ body: label: What happened? description: Also tell us, what did you expect to happen? placeholder: Tell us what you see! - value: "A bug happened!" + value: 'A bug happened!' validations: required: true - type: textarea @@ -58,7 +58,7 @@ body: description: Also tell us, what did you expect to happen? placeholder: Tell us what you expected to happen! validations: - required: true + required: true - type: textarea id: current-behavior attributes: @@ -88,4 +88,4 @@ body: attributes: label: Relevant log output description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. - render: shell \ No newline at end of file + render: shell diff --git a/.github/ISSUE_TEMPLATE/featureRequest.yaml b/.github/ISSUE_TEMPLATE/featureRequest.yaml index e4f930d3..f4da125b 100644 --- a/.github/ISSUE_TEMPLATE/featureRequest.yaml +++ b/.github/ISSUE_TEMPLATE/featureRequest.yaml @@ -1,9 +1,9 @@ --- name: đŸ› ī¸ Feature Request description: Suggest an idea to help us improve Opencommit -title: "[Feature]: " +title: '[Feature]: ' labels: - - "feature_request" + - 'feature_request' body: - type: markdown @@ -45,4 +45,4 @@ body: description: | Add any other context about the problem here. validations: - required: false \ No newline at end of file + required: false diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index aa42aa6b..fdbf0118 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -9,14 +9,14 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL" +name: 'CodeQL' on: push: - branches: [ "master" ] + branches: ['master'] pull_request: # The branches below must be a subset of the branches above - branches: [ "master" ] + branches: ['master'] schedule: - cron: '21 16 * * 0' @@ -32,45 +32,44 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'javascript' ] + language: ['javascript'] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Use only 'java' to analyze code written in Java, Kotlin or both # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v3 - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v3 + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # â„šī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{matrix.language}}" + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: '/language:${{matrix.language}}' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c2b9df2a..14dfb67b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,52 +11,38 @@ jobs: linux-tests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: '20.x' - cache: 'npm' - - name: Setup git - run: | - git config --global user.email "test@example.com" - git config --global user.name "Test User" - - name: Install dependencies - run: npm ci - - name: Run Unit Tests - run: npm run test:unit - - name: Run Core E2E Tests - run: npm run test:e2e:core - - name: Run Prompt Module E2E Tests - run: npm run test:e2e:prompt-module + - uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'npm' + - name: Setup git + run: | + git config --global user.email "test@example.com" + git config --global user.name "Test User" + - name: Install dependencies + run: npm ci + - name: Run Lint + run: npm run lint + - name: Run Format Check + run: npm run format:check + - name: Run Unit Tests + run: npm run test:unit + - name: Run Core E2E Tests + run: npm run test:e2e:core + - name: Run Prompt Module E2E Tests + run: npm run test:e2e:prompt-module macos-smoke: runs-on: macos-latest steps: - - uses: actions/checkout@v4 - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: '20.x' - cache: 'npm' - - name: Install dependencies - run: npm ci - - name: Run Smoke E2E Tests - run: npm run test:e2e:smoke - prettier: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: '20.x' - cache: 'npm' - - name: Install dependencies - run: npm ci - - name: Run Prettier - run: npm run format:check - - name: Prettier Output - if: failure() - run: | - echo "Prettier check failed. Please run 'npm run format' to fix formatting issues." - exit 1 + - uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Run Smoke E2E Tests + run: npm run test:e2e:smoke diff --git a/biome.json b/biome.json index 4f0057d6..f4535052 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/2.4.10/schema.json", + "$schema": "https://biomejs.dev/schemas/2.4.11/schema.json", "vcs": { "enabled": true, @@ -13,7 +13,7 @@ }, "formatter": { - "enabled": true, + "enabled": false, "indentStyle": "space", "indentWidth": 2, "lineEnding": "lf" @@ -33,7 +33,12 @@ "rules": { "recommended": true, "suspicious": { - "noConsole": "error" + "noConsole": "off", + "noImplicitAnyLet": "off", + "useIterableCallbackReturn": "off" + }, + "correctness": { + "noSwitchDeclarations": "off" }, "style": { "noNonNullAssertion": "off" @@ -42,10 +47,10 @@ }, "assist": { - "enabled": true, + "enabled": false, "actions": { "source": { - "organizeImports": "on" + "organizeImports": "off" } } } diff --git a/jest.config.ts b/jest.config.ts index b71693ee..bd828222 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -15,9 +15,7 @@ const config: Config = { testRegex: ['.*\\.test\\.ts$'], // Tell Jest to ignore the specific duplicate package.json files // that are causing Haste module naming collisions - modulePathIgnorePatterns: [ - '/test/e2e/prompt-module/data/' - ], + modulePathIgnorePatterns: ['/test/e2e/prompt-module/data/'], transformIgnorePatterns: [ 'node_modules/(?!(cli-testing-library|@clack|cleye|chalk)/.*)' ], diff --git a/out/cli.cjs b/out/cli.cjs index f57e61e7..7707d046 100755 --- a/out/cli.cjs +++ b/out/cli.cjs @@ -1545,7 +1545,7 @@ var require_signal_exit = __commonJS({ }; }; } else { - assert = require("assert"); + assert2 = require("assert"); signals = require_signals(); isWin = /^win/i.test(process9.platform); EE = require("events"); @@ -1568,7 +1568,7 @@ var require_signal_exit = __commonJS({ return function() { }; } - assert.equal(typeof cb, "function", "a callback must be provided for exit handler"); + assert2.equal(typeof cb, "function", "a callback must be provided for exit handler"); if (loaded === false) { load(); } @@ -1674,7 +1674,7 @@ var require_signal_exit = __commonJS({ } }; } - var assert; + var assert2; var signals; var isWin; var EE; @@ -2043,11 +2043,11 @@ var require_main = __commonJS({ function configDotenv(options) { const dotenvPath = path5.resolve(process.cwd(), ".env"); let encoding = "utf8"; - const debug3 = Boolean(options && options.debug); + const debug5 = Boolean(options && options.debug); if (options && options.encoding) { encoding = options.encoding; } else { - if (debug3) { + if (debug5) { _debug("No encoding is specified. UTF-8 is used by default"); } } @@ -2069,7 +2069,7 @@ var require_main = __commonJS({ const parsed = DotenvModule.parse(fs7.readFileSync(path6, { encoding })); DotenvModule.populate(parsedAll, parsed, options); } catch (e3) { - if (debug3) { + if (debug5) { _debug(`Failed to load ${path6} ${e3.message}`); } lastError = e3; @@ -2125,7 +2125,7 @@ var require_main = __commonJS({ } } function populate(processEnv, parsed, options = {}) { - const debug3 = Boolean(options && options.debug); + const debug5 = Boolean(options && options.debug); const override = Boolean(options && options.override); if (typeof parsed !== "object") { const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate"); @@ -2137,7 +2137,7 @@ var require_main = __commonJS({ if (override === true) { processEnv[key] = parsed[key]; } - if (debug3) { + if (debug5) { if (override === true) { _debug(`"${key}" is already defined and WAS overwritten`); } else { @@ -5581,7 +5581,7 @@ var require_URL = __commonJS({ return; } const ctorRegistry = utils.initCtorRegistry(globalObject); - class URL2 { + class URL3 { constructor(url2) { if (arguments.length < 1) { throw new globalObject.TypeError( @@ -5874,7 +5874,7 @@ var require_URL = __commonJS({ return Impl.implementation.canParse(...args); } } - Object.defineProperties(URL2.prototype, { + Object.defineProperties(URL3.prototype, { toJSON: { enumerable: true }, href: { enumerable: true }, toString: { enumerable: true }, @@ -5891,18 +5891,18 @@ var require_URL = __commonJS({ hash: { enumerable: true }, [Symbol.toStringTag]: { value: "URL", configurable: true } }); - Object.defineProperties(URL2, { parse: { enumerable: true }, canParse: { enumerable: true } }); - ctorRegistry[interfaceName] = URL2; + Object.defineProperties(URL3, { parse: { enumerable: true }, canParse: { enumerable: true } }); + ctorRegistry[interfaceName] = URL3; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: URL2 + value: URL3 }); if (globalNames.includes("Window")) { Object.defineProperty(globalObject, "webkitURL", { configurable: true, writable: true, - value: URL2 + value: URL3 }); } }; @@ -5914,9 +5914,9 @@ var require_URL = __commonJS({ var require_webidl2js_wrapper = __commonJS({ "node_modules/whatwg-url/webidl2js-wrapper.js"(exports2) { "use strict"; - var URL2 = require_URL(); + var URL3 = require_URL(); var URLSearchParams2 = require_URLSearchParams(); - exports2.URL = URL2; + exports2.URL = URL3; exports2.URLSearchParams = URLSearchParams2; } }); @@ -5925,11 +5925,11 @@ var require_webidl2js_wrapper = __commonJS({ var require_whatwg_url = __commonJS({ "node_modules/whatwg-url/index.js"(exports2) { "use strict"; - var { URL: URL2, URLSearchParams: URLSearchParams2 } = require_webidl2js_wrapper(); + var { URL: URL3, URLSearchParams: URLSearchParams2 } = require_webidl2js_wrapper(); var urlStateMachine = require_url_state_machine(); var percentEncoding = require_percent_encoding(); var sharedGlobalObject = { Array, Object, Promise, String, TypeError }; - URL2.install(sharedGlobalObject, ["Window"]); + URL3.install(sharedGlobalObject, ["Window"]); URLSearchParams2.install(sharedGlobalObject, ["Window"]); exports2.URL = sharedGlobalObject.URL; exports2.URLSearchParams = sharedGlobalObject.URLSearchParams; @@ -5958,7 +5958,7 @@ var require_lib2 = __commonJS({ return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex; } var Stream3 = _interopDefault(require("stream")); - var http3 = _interopDefault(require("http")); + var http4 = _interopDefault(require("http")); var Url = _interopDefault(require("url")); var whatwgUrl = _interopDefault(require_whatwg_url()); var https3 = _interopDefault(require("https")); @@ -6628,10 +6628,10 @@ var require_lib2 = __commonJS({ return [k7.toLowerCase(), headers[MAP][k7].join(", ")]; }); } - var INTERNAL = Symbol("internal"); + var INTERNAL2 = Symbol("internal"); function createHeadersIterator(target, kind3) { const iterator2 = Object.create(HeadersIteratorPrototype); - iterator2[INTERNAL] = { + iterator2[INTERNAL2] = { target, kind: kind3, index: 0 @@ -6643,7 +6643,7 @@ var require_lib2 = __commonJS({ if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { throw new TypeError("Value of `this` is not a HeadersIterator"); } - var _INTERNAL = this[INTERNAL]; + var _INTERNAL = this[INTERNAL2]; const target = _INTERNAL.target, kind3 = _INTERNAL.kind, index = _INTERNAL.index; const values = getHeaders2(target, kind3); const len = values.length; @@ -6653,7 +6653,7 @@ var require_lib2 = __commonJS({ done: true }; } - this[INTERNAL].index = index + 1; + this[INTERNAL2].index = index + 1; return { value: values[index], done: false @@ -6698,7 +6698,7 @@ var require_lib2 = __commonJS({ return headers; } var INTERNALS$1 = Symbol("Response internals"); - var STATUS_CODES = http3.STATUS_CODES; + var STATUS_CODES = http4.STATUS_CODES; var Response6 = class _Response { constructor() { let body = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null; @@ -6774,12 +6774,12 @@ var require_lib2 = __commonJS({ configurable: true }); var INTERNALS$2 = Symbol("Request internals"); - var URL2 = Url.URL || whatwgUrl.URL; + var URL3 = Url.URL || whatwgUrl.URL; var parse_url = Url.parse; var format_url = Url.format; function parseURL(urlStr) { if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) { - urlStr = new URL2(urlStr).toString(); + urlStr = new URL3(urlStr).toString(); } return parse_url(urlStr); } @@ -6951,7 +6951,7 @@ var require_lib2 = __commonJS({ return new fetch4.Promise(function(resolve, reject) { const request3 = new Request6(url2, opts); const options = getNodeRequestOptions(request3); - const send = (options.protocol === "https:" ? https3 : http3).request; + const send = (options.protocol === "https:" ? https3 : http4).request; const signal = request3.signal; let response = null; const abort = function abort2() { @@ -9409,7 +9409,7 @@ var require_agent = __commonJS({ "use strict"; var OriginalAgent = require("http").Agent; var ms = require_humanize_ms(); - var debug3 = require("util").debuglog("agentkeepalive"); + var debug5 = require("util").debuglog("agentkeepalive"); var { INIT_SOCKET, CURRENT_ID, @@ -9429,7 +9429,7 @@ var require_agent = __commonJS({ function deprecate2(message) { console.log("[agentkeepalive:deprecated] %s", message); } - var Agent4 = class extends OriginalAgent { + var Agent6 = class extends OriginalAgent { constructor(options) { options = options || {}; options.keepAlive = options.keepAlive !== false; @@ -9511,7 +9511,7 @@ var require_agent = __commonJS({ return true; } if (customTimeout <= 0) { - debug3( + debug5( "%s(requests: %s, finished: %s) free but need to destroy by TTL, request count %s, diff is %s", socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], @@ -9534,10 +9534,10 @@ var require_agent = __commonJS({ const agentTimeout = this.options.timeout; if (getSocketTimeout(socket) !== agentTimeout) { socket.setTimeout(agentTimeout); - debug3("%s reset timeout to %sms", socket[SOCKET_NAME], agentTimeout); + debug5("%s reset timeout to %sms", socket[SOCKET_NAME], agentTimeout); } socket[SOCKET_REQUEST_COUNT]++; - debug3( + debug5( "%s(requests: %s, finished: %s) reuse on addRequest, timeout %sms", socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], @@ -9615,12 +9615,12 @@ var require_agent = __commonJS({ return socket.timeout || socket._idleTimeout; } function installListeners(agent, socket, options) { - debug3("%s create, timeout %sms", socket[SOCKET_NAME], getSocketTimeout(socket)); + debug5("%s create, timeout %sms", socket[SOCKET_NAME], getSocketTimeout(socket)); function onFree() { if (!socket._httpMessage && socket[SOCKET_REQUEST_COUNT] === 1) return; socket[SOCKET_REQUEST_FINISHED_COUNT]++; agent.requestCount++; - debug3( + debug5( "%s(requests: %s, finished: %s) free", socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], @@ -9629,7 +9629,7 @@ var require_agent = __commonJS({ const name = agent.getName(options); if (socket.writable && agent.requests[name] && agent.requests[name].length) { socket[SOCKET_REQUEST_COUNT]++; - debug3( + debug5( "%s(requests: %s, finished: %s) will be reuse on agent free event", socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], @@ -9639,7 +9639,7 @@ var require_agent = __commonJS({ } socket.on("free", onFree); function onClose(isError2) { - debug3( + debug5( "%s(requests: %s, finished: %s) close, isError: %s", socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], @@ -9654,7 +9654,7 @@ var require_agent = __commonJS({ const timeout = getSocketTimeout(socket); const req = socket._httpMessage; const reqTimeoutListenerCount = req && req.listeners("timeout").length || 0; - debug3( + debug5( "%s(requests: %s, finished: %s) timeout after %sms, listeners %s, defaultTimeoutListenerCount %s, hasHttpRequest %s, HttpRequest timeoutListenerCount %s", socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], @@ -9665,15 +9665,15 @@ var require_agent = __commonJS({ !!req, reqTimeoutListenerCount ); - if (debug3.enabled) { - debug3("timeout listeners: %s", socket.listeners("timeout").map((f4) => f4.name).join(", ")); + if (debug5.enabled) { + debug5("timeout listeners: %s", socket.listeners("timeout").map((f4) => f4.name).join(", ")); } agent.timeoutSocketCount++; const name = agent.getName(options); if (agent.freeSockets[name] && agent.freeSockets[name].indexOf(socket) !== -1) { socket.destroy(); agent.removeSocket(socket, options); - debug3("%s is free, destroy quietly", socket[SOCKET_NAME]); + debug5("%s is free, destroy quietly", socket[SOCKET_NAME]); } else { if (reqTimeoutListenerCount === 0) { const error = new Error("Socket timeout"); @@ -9681,14 +9681,14 @@ var require_agent = __commonJS({ error.timeout = timeout; socket.destroy(error); agent.removeSocket(socket, options); - debug3("%s destroy with timeout error", socket[SOCKET_NAME]); + debug5("%s destroy with timeout error", socket[SOCKET_NAME]); } } } socket.on("timeout", onTimeout); function onError(err) { const listenerCount = socket.listeners("error").length; - debug3( + debug5( "%s(requests: %s, finished: %s) error: %s, listenerCount: %s", socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], @@ -9698,14 +9698,14 @@ var require_agent = __commonJS({ ); agent.errorSocketCount++; if (listenerCount === 1) { - debug3("%s emit uncaught error event", socket[SOCKET_NAME]); + debug5("%s emit uncaught error event", socket[SOCKET_NAME]); socket.removeListener("error", onError); socket.emit("error", err); } } socket.on("error", onError); function onRemove() { - debug3( + debug5( "%s(requests: %s, finished: %s) agentRemove", socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], @@ -9719,7 +9719,7 @@ var require_agent = __commonJS({ } socket.on("agentRemove", onRemove); } - module2.exports = Agent4; + module2.exports = Agent6; function inspect3(obj) { const res = {}; for (const key in obj) { @@ -9740,7 +9740,7 @@ var require_https_agent = __commonJS({ INIT_SOCKET, CREATE_HTTPS_CONNECTION } = require_constants(); - var HttpsAgent = class extends HttpAgent { + var HttpsAgent2 = class extends HttpAgent { constructor(options) { super(options); this.defaultPort = 443; @@ -9760,7 +9760,7 @@ var require_https_agent = __commonJS({ return socket; } }; - HttpsAgent.prototype[CREATE_HTTPS_CONNECTION] = OriginalHttpsAgent.prototype.createConnection; + HttpsAgent2.prototype[CREATE_HTTPS_CONNECTION] = OriginalHttpsAgent.prototype.createConnection; [ "getName", "_getSession", @@ -9769,10 +9769,10 @@ var require_https_agent = __commonJS({ "_evictSession" ].forEach(function(method) { if (typeof OriginalHttpsAgent.prototype[method] === "function") { - HttpsAgent.prototype[method] = OriginalHttpsAgent.prototype[method]; + HttpsAgent2.prototype[method] = OriginalHttpsAgent.prototype[method]; } }); - module2.exports = HttpsAgent; + module2.exports = HttpsAgent2; } }); @@ -14857,46 +14857,46 @@ var init_fileFromPath = __esm({ var require_common = __commonJS({ "node_modules/debug/src/common.js"(exports2, module2) { function setup(env2) { - createDebug.debug = createDebug; - createDebug.default = createDebug; - createDebug.coerce = coerce; - createDebug.disable = disable2; - createDebug.enable = enable2; - createDebug.enabled = enabled2; - createDebug.humanize = require_ms(); - createDebug.destroy = destroy2; + createDebug3.debug = createDebug3; + createDebug3.default = createDebug3; + createDebug3.coerce = coerce; + createDebug3.disable = disable2; + createDebug3.enable = enable2; + createDebug3.enabled = enabled2; + createDebug3.humanize = require_ms(); + createDebug3.destroy = destroy2; Object.keys(env2).forEach((key) => { - createDebug[key] = env2[key]; + createDebug3[key] = env2[key]; }); - createDebug.names = []; - createDebug.skips = []; - createDebug.formatters = {}; + createDebug3.names = []; + createDebug3.skips = []; + createDebug3.formatters = {}; function selectColor(namespace) { let hash = 0; for (let i3 = 0; i3 < namespace.length; i3++) { hash = (hash << 5) - hash + namespace.charCodeAt(i3); hash |= 0; } - return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; + return createDebug3.colors[Math.abs(hash) % createDebug3.colors.length]; } - createDebug.selectColor = selectColor; - function createDebug(namespace) { + createDebug3.selectColor = selectColor; + function createDebug3(namespace) { let prevTime; let enableOverride = null; let namespacesCache; let enabledCache; - function debug3(...args) { - if (!debug3.enabled) { + function debug5(...args) { + if (!debug5.enabled) { return; } - const self2 = debug3; + const self2 = debug5; const curr = Number(/* @__PURE__ */ new Date()); const ms = curr - (prevTime || curr); self2.diff = ms; self2.prev = prevTime; self2.curr = curr; prevTime = curr; - args[0] = createDebug.coerce(args[0]); + args[0] = createDebug3.coerce(args[0]); if (typeof args[0] !== "string") { args.unshift("%O"); } @@ -14906,7 +14906,7 @@ var require_common = __commonJS({ return "%"; } index++; - const formatter = createDebug.formatters[format]; + const formatter = createDebug3.formatters[format]; if (typeof formatter === "function") { const val = args[index]; match = formatter.call(self2, val); @@ -14915,25 +14915,25 @@ var require_common = __commonJS({ } return match; }); - createDebug.formatArgs.call(self2, args); - const logFn = self2.log || createDebug.log; + createDebug3.formatArgs.call(self2, args); + const logFn = self2.log || createDebug3.log; logFn.apply(self2, args); } - debug3.namespace = namespace; - debug3.useColors = createDebug.useColors(); - debug3.color = createDebug.selectColor(namespace); - debug3.extend = extend3; - debug3.destroy = createDebug.destroy; - Object.defineProperty(debug3, "enabled", { + debug5.namespace = namespace; + debug5.useColors = createDebug3.useColors(); + debug5.color = createDebug3.selectColor(namespace); + debug5.extend = extend3; + debug5.destroy = createDebug3.destroy; + Object.defineProperty(debug5, "enabled", { enumerable: true, configurable: false, get: () => { if (enableOverride !== null) { return enableOverride; } - if (namespacesCache !== createDebug.namespaces) { - namespacesCache = createDebug.namespaces; - enabledCache = createDebug.enabled(namespace); + if (namespacesCache !== createDebug3.namespaces) { + namespacesCache = createDebug3.namespaces; + enabledCache = createDebug3.enabled(namespace); } return enabledCache; }, @@ -14941,21 +14941,21 @@ var require_common = __commonJS({ enableOverride = v5; } }); - if (typeof createDebug.init === "function") { - createDebug.init(debug3); + if (typeof createDebug3.init === "function") { + createDebug3.init(debug5); } - return debug3; + return debug5; } function extend3(namespace, delimiter) { - const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace); + const newDebug = createDebug3(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace); newDebug.log = this.log; return newDebug; } function enable2(namespaces) { - createDebug.save(namespaces); - createDebug.namespaces = namespaces; - createDebug.names = []; - createDebug.skips = []; + createDebug3.save(namespaces); + createDebug3.namespaces = namespaces; + createDebug3.names = []; + createDebug3.skips = []; let i3; const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/); const len = split.length; @@ -14965,18 +14965,18 @@ var require_common = __commonJS({ } namespaces = split[i3].replace(/\*/g, ".*?"); if (namespaces[0] === "-") { - createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$")); + createDebug3.skips.push(new RegExp("^" + namespaces.slice(1) + "$")); } else { - createDebug.names.push(new RegExp("^" + namespaces + "$")); + createDebug3.names.push(new RegExp("^" + namespaces + "$")); } } } function disable2() { const namespaces = [ - ...createDebug.names.map(toNamespace), - ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace) + ...createDebug3.names.map(toNamespace), + ...createDebug3.skips.map(toNamespace).map((namespace) => "-" + namespace) ].join(","); - createDebug.enable(""); + createDebug3.enable(""); return namespaces; } function enabled2(name) { @@ -14985,13 +14985,13 @@ var require_common = __commonJS({ } let i3; let len; - for (i3 = 0, len = createDebug.skips.length; i3 < len; i3++) { - if (createDebug.skips[i3].test(name)) { + for (i3 = 0, len = createDebug3.skips.length; i3 < len; i3++) { + if (createDebug3.skips[i3].test(name)) { return false; } } - for (i3 = 0, len = createDebug.names.length; i3 < len; i3++) { - if (createDebug.names[i3].test(name)) { + for (i3 = 0, len = createDebug3.names.length; i3 < len; i3++) { + if (createDebug3.names[i3].test(name)) { return true; } } @@ -15009,8 +15009,8 @@ var require_common = __commonJS({ function destroy2() { console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); } - createDebug.enable(createDebug.load()); - return createDebug; + createDebug3.enable(createDebug3.load()); + return createDebug3; } module2.exports = setup; } @@ -15454,11 +15454,11 @@ var require_node = __commonJS({ function load() { return process.env.DEBUG; } - function init(debug3) { - debug3.inspectOpts = {}; + function init(debug5) { + debug5.inspectOpts = {}; const keys = Object.keys(exports2.inspectOpts); for (let i3 = 0; i3 < keys.length; i3++) { - debug3.inspectOpts[keys[i3]] = exports2.inspectOpts[keys[i3]]; + debug5.inspectOpts[keys[i3]] = exports2.inspectOpts[keys[i3]]; } } module2.exports = require_common()(exports2); @@ -15485,471 +15485,6 @@ var require_src2 = __commonJS({ } }); -// node_modules/agent-base/dist/helpers.js -var require_helpers = __commonJS({ - "node_modules/agent-base/dist/helpers.js"(exports2) { - "use strict"; - var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o3, m5, k7, k22) { - if (k22 === void 0) k22 = k7; - var desc = Object.getOwnPropertyDescriptor(m5, k7); - if (!desc || ("get" in desc ? !m5.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { - return m5[k7]; - } }; - } - Object.defineProperty(o3, k22, desc); - } : function(o3, m5, k7, k22) { - if (k22 === void 0) k22 = k7; - o3[k22] = m5[k7]; - }); - var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o3, v5) { - Object.defineProperty(o3, "default", { enumerable: true, value: v5 }); - } : function(o3, v5) { - o3["default"] = v5; - }); - var __importStar = exports2 && exports2.__importStar || function(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) { - for (var k7 in mod) if (k7 !== "default" && Object.prototype.hasOwnProperty.call(mod, k7)) __createBinding(result, mod, k7); - } - __setModuleDefault(result, mod); - return result; - }; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.req = exports2.json = exports2.toBuffer = void 0; - var http3 = __importStar(require("http")); - var https3 = __importStar(require("https")); - async function toBuffer(stream4) { - let length = 0; - const chunks = []; - for await (const chunk of stream4) { - length += chunk.length; - chunks.push(chunk); - } - return Buffer.concat(chunks, length); - } - exports2.toBuffer = toBuffer; - async function json(stream4) { - const buf = await toBuffer(stream4); - const str2 = buf.toString("utf8"); - try { - return JSON.parse(str2); - } catch (_err) { - const err = _err; - err.message += ` (input: ${str2})`; - throw err; - } - } - exports2.json = json; - function req(url2, opts = {}) { - const href = typeof url2 === "string" ? url2 : url2.href; - const req2 = (href.startsWith("https:") ? https3 : http3).request(url2, opts); - const promise = new Promise((resolve, reject) => { - req2.once("response", resolve).once("error", reject).end(); - }); - req2.then = promise.then.bind(promise); - return req2; - } - exports2.req = req; - } -}); - -// node_modules/agent-base/dist/index.js -var require_dist = __commonJS({ - "node_modules/agent-base/dist/index.js"(exports2) { - "use strict"; - var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o3, m5, k7, k22) { - if (k22 === void 0) k22 = k7; - var desc = Object.getOwnPropertyDescriptor(m5, k7); - if (!desc || ("get" in desc ? !m5.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { - return m5[k7]; - } }; - } - Object.defineProperty(o3, k22, desc); - } : function(o3, m5, k7, k22) { - if (k22 === void 0) k22 = k7; - o3[k22] = m5[k7]; - }); - var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o3, v5) { - Object.defineProperty(o3, "default", { enumerable: true, value: v5 }); - } : function(o3, v5) { - o3["default"] = v5; - }); - var __importStar = exports2 && exports2.__importStar || function(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) { - for (var k7 in mod) if (k7 !== "default" && Object.prototype.hasOwnProperty.call(mod, k7)) __createBinding(result, mod, k7); - } - __setModuleDefault(result, mod); - return result; - }; - var __exportStar = exports2 && exports2.__exportStar || function(m5, exports3) { - for (var p4 in m5) if (p4 !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p4)) __createBinding(exports3, m5, p4); - }; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.Agent = void 0; - var net = __importStar(require("net")); - var http3 = __importStar(require("http")); - var https_1 = require("https"); - __exportStar(require_helpers(), exports2); - var INTERNAL = Symbol("AgentBaseInternalState"); - var Agent4 = class extends http3.Agent { - constructor(opts) { - super(opts); - this[INTERNAL] = {}; - } - /** - * Determine whether this is an `http` or `https` request. - */ - isSecureEndpoint(options) { - if (options) { - if (typeof options.secureEndpoint === "boolean") { - return options.secureEndpoint; - } - if (typeof options.protocol === "string") { - return options.protocol === "https:"; - } - } - const { stack } = new Error(); - if (typeof stack !== "string") - return false; - return stack.split("\n").some((l3) => l3.indexOf("(https.js:") !== -1 || l3.indexOf("node:https:") !== -1); - } - // In order to support async signatures in `connect()` and Node's native - // connection pooling in `http.Agent`, the array of sockets for each origin - // has to be updated synchronously. This is so the length of the array is - // accurate when `addRequest()` is next called. We achieve this by creating a - // fake socket and adding it to `sockets[origin]` and incrementing - // `totalSocketCount`. - incrementSockets(name) { - if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) { - return null; - } - if (!this.sockets[name]) { - this.sockets[name] = []; - } - const fakeSocket = new net.Socket({ writable: false }); - this.sockets[name].push(fakeSocket); - this.totalSocketCount++; - return fakeSocket; - } - decrementSockets(name, socket) { - if (!this.sockets[name] || socket === null) { - return; - } - const sockets = this.sockets[name]; - const index = sockets.indexOf(socket); - if (index !== -1) { - sockets.splice(index, 1); - this.totalSocketCount--; - if (sockets.length === 0) { - delete this.sockets[name]; - } - } - } - // In order to properly update the socket pool, we need to call `getName()` on - // the core `https.Agent` if it is a secureEndpoint. - getName(options) { - const secureEndpoint = typeof options.secureEndpoint === "boolean" ? options.secureEndpoint : this.isSecureEndpoint(options); - if (secureEndpoint) { - return https_1.Agent.prototype.getName.call(this, options); - } - return super.getName(options); - } - createSocket(req, options, cb) { - const connectOpts = { - ...options, - secureEndpoint: this.isSecureEndpoint(options) - }; - const name = this.getName(connectOpts); - const fakeSocket = this.incrementSockets(name); - Promise.resolve().then(() => this.connect(req, connectOpts)).then((socket) => { - this.decrementSockets(name, fakeSocket); - if (socket instanceof http3.Agent) { - return socket.addRequest(req, connectOpts); - } - this[INTERNAL].currentSocket = socket; - super.createSocket(req, options, cb); - }, (err) => { - this.decrementSockets(name, fakeSocket); - cb(err); - }); - } - createConnection() { - const socket = this[INTERNAL].currentSocket; - this[INTERNAL].currentSocket = void 0; - if (!socket) { - throw new Error("No socket was returned in the `connect()` function"); - } - return socket; - } - get defaultPort() { - return this[INTERNAL].defaultPort ?? (this.protocol === "https:" ? 443 : 80); - } - set defaultPort(v5) { - if (this[INTERNAL]) { - this[INTERNAL].defaultPort = v5; - } - } - get protocol() { - return this[INTERNAL].protocol ?? (this.isSecureEndpoint() ? "https:" : "http:"); - } - set protocol(v5) { - if (this[INTERNAL]) { - this[INTERNAL].protocol = v5; - } - } - }; - exports2.Agent = Agent4; - } -}); - -// node_modules/https-proxy-agent/dist/parse-proxy-response.js -var require_parse_proxy_response = __commonJS({ - "node_modules/https-proxy-agent/dist/parse-proxy-response.js"(exports2) { - "use strict"; - var __importDefault = exports2 && exports2.__importDefault || function(mod) { - return mod && mod.__esModule ? mod : { "default": mod }; - }; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.parseProxyResponse = void 0; - var debug_1 = __importDefault(require_src2()); - var debug3 = (0, debug_1.default)("https-proxy-agent:parse-proxy-response"); - function parseProxyResponse(socket) { - return new Promise((resolve, reject) => { - let buffersLength = 0; - const buffers = []; - function read() { - const b7 = socket.read(); - if (b7) - ondata(b7); - else - socket.once("readable", read); - } - function cleanup() { - socket.removeListener("end", onend); - socket.removeListener("error", onerror); - socket.removeListener("readable", read); - } - function onend() { - cleanup(); - debug3("onend"); - reject(new Error("Proxy connection ended before receiving CONNECT response")); - } - function onerror(err) { - cleanup(); - debug3("onerror %o", err); - reject(err); - } - function ondata(b7) { - buffers.push(b7); - buffersLength += b7.length; - const buffered = Buffer.concat(buffers, buffersLength); - const endOfHeaders = buffered.indexOf("\r\n\r\n"); - if (endOfHeaders === -1) { - debug3("have not received end of HTTP headers yet..."); - read(); - return; - } - const headerParts = buffered.slice(0, endOfHeaders).toString("ascii").split("\r\n"); - const firstLine = headerParts.shift(); - if (!firstLine) { - socket.destroy(); - return reject(new Error("No header received from proxy CONNECT response")); - } - const firstLineParts = firstLine.split(" "); - const statusCode = +firstLineParts[1]; - const statusText = firstLineParts.slice(2).join(" "); - const headers = {}; - for (const header of headerParts) { - if (!header) - continue; - const firstColon = header.indexOf(":"); - if (firstColon === -1) { - socket.destroy(); - return reject(new Error(`Invalid header from proxy CONNECT response: "${header}"`)); - } - const key = header.slice(0, firstColon).toLowerCase(); - const value = header.slice(firstColon + 1).trimStart(); - const current = headers[key]; - if (typeof current === "string") { - headers[key] = [current, value]; - } else if (Array.isArray(current)) { - current.push(value); - } else { - headers[key] = value; - } - } - debug3("got proxy server response: %o %o", firstLine, headers); - cleanup(); - resolve({ - connect: { - statusCode, - statusText, - headers - }, - buffered - }); - } - socket.on("error", onerror); - socket.on("end", onend); - read(); - }); - } - exports2.parseProxyResponse = parseProxyResponse; - } -}); - -// node_modules/https-proxy-agent/dist/index.js -var require_dist2 = __commonJS({ - "node_modules/https-proxy-agent/dist/index.js"(exports2) { - "use strict"; - var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o3, m5, k7, k22) { - if (k22 === void 0) k22 = k7; - var desc = Object.getOwnPropertyDescriptor(m5, k7); - if (!desc || ("get" in desc ? !m5.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { - return m5[k7]; - } }; - } - Object.defineProperty(o3, k22, desc); - } : function(o3, m5, k7, k22) { - if (k22 === void 0) k22 = k7; - o3[k22] = m5[k7]; - }); - var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o3, v5) { - Object.defineProperty(o3, "default", { enumerable: true, value: v5 }); - } : function(o3, v5) { - o3["default"] = v5; - }); - var __importStar = exports2 && exports2.__importStar || function(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) { - for (var k7 in mod) if (k7 !== "default" && Object.prototype.hasOwnProperty.call(mod, k7)) __createBinding(result, mod, k7); - } - __setModuleDefault(result, mod); - return result; - }; - var __importDefault = exports2 && exports2.__importDefault || function(mod) { - return mod && mod.__esModule ? mod : { "default": mod }; - }; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.HttpsProxyAgent = void 0; - var net = __importStar(require("net")); - var tls = __importStar(require("tls")); - var assert_1 = __importDefault(require("assert")); - var debug_1 = __importDefault(require_src2()); - var agent_base_1 = require_dist(); - var url_1 = require("url"); - var parse_proxy_response_1 = require_parse_proxy_response(); - var debug3 = (0, debug_1.default)("https-proxy-agent"); - var HttpsProxyAgent5 = class extends agent_base_1.Agent { - constructor(proxy, opts) { - super(opts); - this.options = { path: void 0 }; - this.proxy = typeof proxy === "string" ? new url_1.URL(proxy) : proxy; - this.proxyHeaders = opts?.headers ?? {}; - debug3("Creating new HttpsProxyAgent instance: %o", this.proxy.href); - const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, ""); - const port = this.proxy.port ? parseInt(this.proxy.port, 10) : this.proxy.protocol === "https:" ? 443 : 80; - this.connectOpts = { - // Attempt to negotiate http/1.1 for proxy servers that support http/2 - ALPNProtocols: ["http/1.1"], - ...opts ? omit(opts, "headers") : null, - host, - port - }; - } - /** - * Called when the node-core HTTP client library is creating a - * new HTTP request. - */ - async connect(req, opts) { - const { proxy } = this; - if (!opts.host) { - throw new TypeError('No "host" provided'); - } - let socket; - if (proxy.protocol === "https:") { - debug3("Creating `tls.Socket`: %o", this.connectOpts); - const servername = this.connectOpts.servername || this.connectOpts.host; - socket = tls.connect({ - ...this.connectOpts, - servername: servername && net.isIP(servername) ? void 0 : servername - }); - } else { - debug3("Creating `net.Socket`: %o", this.connectOpts); - socket = net.connect(this.connectOpts); - } - const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders }; - const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host; - let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r -`; - if (proxy.username || proxy.password) { - const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`; - headers["Proxy-Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`; - } - headers.Host = `${host}:${opts.port}`; - if (!headers["Proxy-Connection"]) { - headers["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close"; - } - for (const name of Object.keys(headers)) { - payload += `${name}: ${headers[name]}\r -`; - } - const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket); - socket.write(`${payload}\r -`); - const { connect, buffered } = await proxyResponsePromise; - req.emit("proxyConnect", connect); - this.emit("proxyConnect", connect, req); - if (connect.statusCode === 200) { - req.once("socket", resume); - if (opts.secureEndpoint) { - debug3("Upgrading socket connection to TLS"); - const servername = opts.servername || opts.host; - return tls.connect({ - ...omit(opts, "host", "path", "port"), - socket, - servername: net.isIP(servername) ? void 0 : servername - }); - } - return socket; - } - socket.destroy(); - const fakeSocket = new net.Socket({ writable: false }); - fakeSocket.readable = true; - req.once("socket", (s2) => { - debug3("Replaying proxy buffer for failed request"); - (0, assert_1.default)(s2.listenerCount("data") > 0); - s2.push(buffered); - s2.push(null); - }); - return fakeSocket; - } - }; - HttpsProxyAgent5.protocols = ["http", "https"]; - exports2.HttpsProxyAgent = HttpsProxyAgent5; - function resume(socket) { - socket.resume(); - } - function omit(obj, ...keys) { - const ret = {}; - let key; - for (key in obj) { - if (!keys.includes(key)) { - ret[key] = obj[key]; - } - } - return ret; - } - } -}); - // node_modules/delayed-stream/lib/delayed_stream.js var require_delayed_stream = __commonJS({ "node_modules/delayed-stream/lib/delayed_stream.js"(exports2, module2) { @@ -25059,7 +24594,7 @@ var require_form_data = __commonJS({ var CombinedStream = require_combined_stream(); var util4 = require("util"); var path5 = require("path"); - var http3 = require("http"); + var http4 = require("http"); var https3 = require("https"); var parseUrl = require("url").parse; var fs7 = require("fs"); @@ -25329,7 +24864,7 @@ var require_form_data = __commonJS({ if (options.protocol == "https:") { request3 = https3.request(options); } else { - request3 = http3.request(options); + request3 = http4.request(options); } this.getLength(function(err, length) { if (err && err !== "Unknown stream") { @@ -25440,19 +24975,19 @@ var require_proxy_from_env = __commonJS({ // node_modules/follow-redirects/debug.js var require_debug = __commonJS({ "node_modules/follow-redirects/debug.js"(exports2, module2) { - var debug3; + var debug5; module2.exports = function() { - if (!debug3) { + if (!debug5) { try { - debug3 = require_src2()("follow-redirects"); + debug5 = require_src2()("follow-redirects"); } catch (error) { } - if (typeof debug3 !== "function") { - debug3 = function() { + if (typeof debug5 !== "function") { + debug5 = function() { }; } } - debug3.apply(null, arguments); + debug5.apply(null, arguments); }; } }); @@ -25461,15 +24996,15 @@ var require_debug = __commonJS({ var require_follow_redirects = __commonJS({ "node_modules/follow-redirects/index.js"(exports2, module2) { var url2 = require("url"); - var URL2 = url2.URL; - var http3 = require("http"); + var URL3 = url2.URL; + var http4 = require("http"); var https3 = require("https"); var Writable = require("stream").Writable; - var assert = require("assert"); - var debug3 = require_debug(); + var assert2 = require("assert"); + var debug5 = require_debug(); var useNativeURL = false; try { - assert(new URL2()); + assert2(new URL3()); } catch (error) { useNativeURL = error.code === "ERR_INVALID_URL"; } @@ -25775,7 +25310,7 @@ var require_follow_redirects = __commonJS({ var currentHost = currentHostHeader || currentUrlParts.host; var currentUrl = /^\w+:/.test(location) ? this._currentUrl : url2.format(Object.assign(currentUrlParts, { host: currentHost })); var redirectUrl = resolveUrl(location, currentUrl); - debug3("redirecting to", redirectUrl.href); + debug5("redirecting to", redirectUrl.href); this._isRedirect = true; spreadUrlObject(redirectUrl, this._options); if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) { @@ -25828,8 +25363,8 @@ var require_follow_redirects = __commonJS({ if (!isString2(options.host) && !isString2(options.hostname)) { options.hostname = "::1"; } - assert.equal(options.protocol, protocol, "protocol mismatch"); - debug3("options", options); + assert2.equal(options.protocol, protocol, "protocol mismatch"); + debug5("options", options); return new RedirectableRequest(options, callback); } function get(input, options, callback) { @@ -25849,7 +25384,7 @@ var require_follow_redirects = __commonJS({ function parseUrl(input) { var parsed; if (useNativeURL) { - parsed = new URL2(input); + parsed = new URL3(input); } else { parsed = validateUrl(url2.parse(input)); if (!isString2(parsed.protocol)) { @@ -25859,7 +25394,7 @@ var require_follow_redirects = __commonJS({ return parsed; } function resolveUrl(relative, base) { - return useNativeURL ? new URL2(relative, base) : parseUrl(url2.resolve(base, relative)); + return useNativeURL ? new URL3(relative, base) : parseUrl(url2.resolve(base, relative)); } function validateUrl(input) { if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) { @@ -25922,7 +25457,7 @@ var require_follow_redirects = __commonJS({ request3.destroy(error); } function isSubdomain(subdomain, domain) { - assert(isString2(subdomain) && isString2(domain)); + assert2(isString2(subdomain) && isString2(domain)); var dot = subdomain.length - domain.length - 1; return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain); } @@ -25936,9 +25471,9 @@ var require_follow_redirects = __commonJS({ return typeof value === "object" && "length" in value; } function isURL(value) { - return URL2 && value instanceof URL2; + return URL3 && value instanceof URL3; } - module2.exports = wrap({ http: http3, https: https3 }); + module2.exports = wrap({ http: http4, https: https3 }); module2.exports.wrap = wrap; } }); @@ -26324,6 +25859,478 @@ var require_tiktoken = __commonJS({ } }); +// node_modules/agent-base/dist/helpers.js +var require_helpers = __commonJS({ + "node_modules/agent-base/dist/helpers.js"(exports2) { + "use strict"; + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o3, m5, k7, k22) { + if (k22 === void 0) k22 = k7; + var desc = Object.getOwnPropertyDescriptor(m5, k7); + if (!desc || ("get" in desc ? !m5.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { + return m5[k7]; + } }; + } + Object.defineProperty(o3, k22, desc); + } : function(o3, m5, k7, k22) { + if (k22 === void 0) k22 = k7; + o3[k22] = m5[k7]; + }); + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o3, v5) { + Object.defineProperty(o3, "default", { enumerable: true, value: v5 }); + } : function(o3, v5) { + o3["default"] = v5; + }); + var __importStar = exports2 && exports2.__importStar || function(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) { + for (var k7 in mod) if (k7 !== "default" && Object.prototype.hasOwnProperty.call(mod, k7)) __createBinding(result, mod, k7); + } + __setModuleDefault(result, mod); + return result; + }; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.req = exports2.json = exports2.toBuffer = void 0; + var http4 = __importStar(require("http")); + var https3 = __importStar(require("https")); + async function toBuffer(stream4) { + let length = 0; + const chunks = []; + for await (const chunk of stream4) { + length += chunk.length; + chunks.push(chunk); + } + return Buffer.concat(chunks, length); + } + exports2.toBuffer = toBuffer; + async function json(stream4) { + const buf = await toBuffer(stream4); + const str2 = buf.toString("utf8"); + try { + return JSON.parse(str2); + } catch (_err) { + const err = _err; + err.message += ` (input: ${str2})`; + throw err; + } + } + exports2.json = json; + function req(url2, opts = {}) { + const href = typeof url2 === "string" ? url2 : url2.href; + const req2 = (href.startsWith("https:") ? https3 : http4).request(url2, opts); + const promise = new Promise((resolve, reject) => { + req2.once("response", resolve).once("error", reject).end(); + }); + req2.then = promise.then.bind(promise); + return req2; + } + exports2.req = req; + } +}); + +// node_modules/agent-base/dist/index.js +var require_dist = __commonJS({ + "node_modules/agent-base/dist/index.js"(exports2) { + "use strict"; + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o3, m5, k7, k22) { + if (k22 === void 0) k22 = k7; + var desc = Object.getOwnPropertyDescriptor(m5, k7); + if (!desc || ("get" in desc ? !m5.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { + return m5[k7]; + } }; + } + Object.defineProperty(o3, k22, desc); + } : function(o3, m5, k7, k22) { + if (k22 === void 0) k22 = k7; + o3[k22] = m5[k7]; + }); + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o3, v5) { + Object.defineProperty(o3, "default", { enumerable: true, value: v5 }); + } : function(o3, v5) { + o3["default"] = v5; + }); + var __importStar = exports2 && exports2.__importStar || function(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) { + for (var k7 in mod) if (k7 !== "default" && Object.prototype.hasOwnProperty.call(mod, k7)) __createBinding(result, mod, k7); + } + __setModuleDefault(result, mod); + return result; + }; + var __exportStar = exports2 && exports2.__exportStar || function(m5, exports3) { + for (var p4 in m5) if (p4 !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p4)) __createBinding(exports3, m5, p4); + }; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.Agent = void 0; + var net3 = __importStar(require("net")); + var http4 = __importStar(require("http")); + var https_1 = require("https"); + __exportStar(require_helpers(), exports2); + var INTERNAL2 = Symbol("AgentBaseInternalState"); + var Agent6 = class extends http4.Agent { + constructor(opts) { + super(opts); + this[INTERNAL2] = {}; + } + /** + * Determine whether this is an `http` or `https` request. + */ + isSecureEndpoint(options) { + if (options) { + if (typeof options.secureEndpoint === "boolean") { + return options.secureEndpoint; + } + if (typeof options.protocol === "string") { + return options.protocol === "https:"; + } + } + const { stack } = new Error(); + if (typeof stack !== "string") + return false; + return stack.split("\n").some((l3) => l3.indexOf("(https.js:") !== -1 || l3.indexOf("node:https:") !== -1); + } + // In order to support async signatures in `connect()` and Node's native + // connection pooling in `http.Agent`, the array of sockets for each origin + // has to be updated synchronously. This is so the length of the array is + // accurate when `addRequest()` is next called. We achieve this by creating a + // fake socket and adding it to `sockets[origin]` and incrementing + // `totalSocketCount`. + incrementSockets(name) { + if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) { + return null; + } + if (!this.sockets[name]) { + this.sockets[name] = []; + } + const fakeSocket = new net3.Socket({ writable: false }); + this.sockets[name].push(fakeSocket); + this.totalSocketCount++; + return fakeSocket; + } + decrementSockets(name, socket) { + if (!this.sockets[name] || socket === null) { + return; + } + const sockets = this.sockets[name]; + const index = sockets.indexOf(socket); + if (index !== -1) { + sockets.splice(index, 1); + this.totalSocketCount--; + if (sockets.length === 0) { + delete this.sockets[name]; + } + } + } + // In order to properly update the socket pool, we need to call `getName()` on + // the core `https.Agent` if it is a secureEndpoint. + getName(options) { + const secureEndpoint = this.isSecureEndpoint(options); + if (secureEndpoint) { + return https_1.Agent.prototype.getName.call(this, options); + } + return super.getName(options); + } + createSocket(req, options, cb) { + const connectOpts = { + ...options, + secureEndpoint: this.isSecureEndpoint(options) + }; + const name = this.getName(connectOpts); + const fakeSocket = this.incrementSockets(name); + Promise.resolve().then(() => this.connect(req, connectOpts)).then((socket) => { + this.decrementSockets(name, fakeSocket); + if (socket instanceof http4.Agent) { + try { + return socket.addRequest(req, connectOpts); + } catch (err) { + return cb(err); + } + } + this[INTERNAL2].currentSocket = socket; + super.createSocket(req, options, cb); + }, (err) => { + this.decrementSockets(name, fakeSocket); + cb(err); + }); + } + createConnection() { + const socket = this[INTERNAL2].currentSocket; + this[INTERNAL2].currentSocket = void 0; + if (!socket) { + throw new Error("No socket was returned in the `connect()` function"); + } + return socket; + } + get defaultPort() { + return this[INTERNAL2].defaultPort ?? (this.protocol === "https:" ? 443 : 80); + } + set defaultPort(v5) { + if (this[INTERNAL2]) { + this[INTERNAL2].defaultPort = v5; + } + } + get protocol() { + return this[INTERNAL2].protocol ?? (this.isSecureEndpoint() ? "https:" : "http:"); + } + set protocol(v5) { + if (this[INTERNAL2]) { + this[INTERNAL2].protocol = v5; + } + } + }; + exports2.Agent = Agent6; + } +}); + +// node_modules/@azure/core-rest-pipeline/node_modules/https-proxy-agent/dist/parse-proxy-response.js +var require_parse_proxy_response = __commonJS({ + "node_modules/@azure/core-rest-pipeline/node_modules/https-proxy-agent/dist/parse-proxy-response.js"(exports2) { + "use strict"; + var __importDefault = exports2 && exports2.__importDefault || function(mod) { + return mod && mod.__esModule ? mod : { "default": mod }; + }; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.parseProxyResponse = void 0; + var debug_1 = __importDefault(require_src2()); + var debug5 = (0, debug_1.default)("https-proxy-agent:parse-proxy-response"); + function parseProxyResponse2(socket) { + return new Promise((resolve, reject) => { + let buffersLength = 0; + const buffers = []; + function read() { + const b7 = socket.read(); + if (b7) + ondata(b7); + else + socket.once("readable", read); + } + function cleanup() { + socket.removeListener("end", onend); + socket.removeListener("error", onerror); + socket.removeListener("readable", read); + } + function onend() { + cleanup(); + debug5("onend"); + reject(new Error("Proxy connection ended before receiving CONNECT response")); + } + function onerror(err) { + cleanup(); + debug5("onerror %o", err); + reject(err); + } + function ondata(b7) { + buffers.push(b7); + buffersLength += b7.length; + const buffered = Buffer.concat(buffers, buffersLength); + const endOfHeaders = buffered.indexOf("\r\n\r\n"); + if (endOfHeaders === -1) { + debug5("have not received end of HTTP headers yet..."); + read(); + return; + } + const headerParts = buffered.slice(0, endOfHeaders).toString("ascii").split("\r\n"); + const firstLine = headerParts.shift(); + if (!firstLine) { + socket.destroy(); + return reject(new Error("No header received from proxy CONNECT response")); + } + const firstLineParts = firstLine.split(" "); + const statusCode = +firstLineParts[1]; + const statusText = firstLineParts.slice(2).join(" "); + const headers = {}; + for (const header of headerParts) { + if (!header) + continue; + const firstColon = header.indexOf(":"); + if (firstColon === -1) { + socket.destroy(); + return reject(new Error(`Invalid header from proxy CONNECT response: "${header}"`)); + } + const key = header.slice(0, firstColon).toLowerCase(); + const value = header.slice(firstColon + 1).trimStart(); + const current = headers[key]; + if (typeof current === "string") { + headers[key] = [current, value]; + } else if (Array.isArray(current)) { + current.push(value); + } else { + headers[key] = value; + } + } + debug5("got proxy server response: %o %o", firstLine, headers); + cleanup(); + resolve({ + connect: { + statusCode, + statusText, + headers + }, + buffered + }); + } + socket.on("error", onerror); + socket.on("end", onend); + read(); + }); + } + exports2.parseProxyResponse = parseProxyResponse2; + } +}); + +// node_modules/@azure/core-rest-pipeline/node_modules/https-proxy-agent/dist/index.js +var require_dist2 = __commonJS({ + "node_modules/@azure/core-rest-pipeline/node_modules/https-proxy-agent/dist/index.js"(exports2) { + "use strict"; + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o3, m5, k7, k22) { + if (k22 === void 0) k22 = k7; + var desc = Object.getOwnPropertyDescriptor(m5, k7); + if (!desc || ("get" in desc ? !m5.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { + return m5[k7]; + } }; + } + Object.defineProperty(o3, k22, desc); + } : function(o3, m5, k7, k22) { + if (k22 === void 0) k22 = k7; + o3[k22] = m5[k7]; + }); + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o3, v5) { + Object.defineProperty(o3, "default", { enumerable: true, value: v5 }); + } : function(o3, v5) { + o3["default"] = v5; + }); + var __importStar = exports2 && exports2.__importStar || function(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) { + for (var k7 in mod) if (k7 !== "default" && Object.prototype.hasOwnProperty.call(mod, k7)) __createBinding(result, mod, k7); + } + __setModuleDefault(result, mod); + return result; + }; + var __importDefault = exports2 && exports2.__importDefault || function(mod) { + return mod && mod.__esModule ? mod : { "default": mod }; + }; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.HttpsProxyAgent = void 0; + var net3 = __importStar(require("net")); + var tls2 = __importStar(require("tls")); + var assert_1 = __importDefault(require("assert")); + var debug_1 = __importDefault(require_src2()); + var agent_base_1 = require_dist(); + var url_1 = require("url"); + var parse_proxy_response_1 = require_parse_proxy_response(); + var debug5 = (0, debug_1.default)("https-proxy-agent"); + var setServernameFromNonIpHost2 = (options) => { + if (options.servername === void 0 && options.host && !net3.isIP(options.host)) { + return { + ...options, + servername: options.host + }; + } + return options; + }; + var HttpsProxyAgent3 = class extends agent_base_1.Agent { + constructor(proxy, opts) { + super(opts); + this.options = { path: void 0 }; + this.proxy = typeof proxy === "string" ? new url_1.URL(proxy) : proxy; + this.proxyHeaders = opts?.headers ?? {}; + debug5("Creating new HttpsProxyAgent instance: %o", this.proxy.href); + const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, ""); + const port = this.proxy.port ? parseInt(this.proxy.port, 10) : this.proxy.protocol === "https:" ? 443 : 80; + this.connectOpts = { + // Attempt to negotiate http/1.1 for proxy servers that support http/2 + ALPNProtocols: ["http/1.1"], + ...opts ? omit2(opts, "headers") : null, + host, + port + }; + } + /** + * Called when the node-core HTTP client library is creating a + * new HTTP request. + */ + async connect(req, opts) { + const { proxy } = this; + if (!opts.host) { + throw new TypeError('No "host" provided'); + } + let socket; + if (proxy.protocol === "https:") { + debug5("Creating `tls.Socket`: %o", this.connectOpts); + socket = tls2.connect(setServernameFromNonIpHost2(this.connectOpts)); + } else { + debug5("Creating `net.Socket`: %o", this.connectOpts); + socket = net3.connect(this.connectOpts); + } + const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders }; + const host = net3.isIPv6(opts.host) ? `[${opts.host}]` : opts.host; + let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r +`; + if (proxy.username || proxy.password) { + const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`; + headers["Proxy-Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`; + } + headers.Host = `${host}:${opts.port}`; + if (!headers["Proxy-Connection"]) { + headers["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close"; + } + for (const name of Object.keys(headers)) { + payload += `${name}: ${headers[name]}\r +`; + } + const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket); + socket.write(`${payload}\r +`); + const { connect: connect3, buffered } = await proxyResponsePromise; + req.emit("proxyConnect", connect3); + this.emit("proxyConnect", connect3, req); + if (connect3.statusCode === 200) { + req.once("socket", resume2); + if (opts.secureEndpoint) { + debug5("Upgrading socket connection to TLS"); + return tls2.connect({ + ...omit2(setServernameFromNonIpHost2(opts), "host", "path", "port"), + socket + }); + } + return socket; + } + socket.destroy(); + const fakeSocket = new net3.Socket({ writable: false }); + fakeSocket.readable = true; + req.once("socket", (s2) => { + debug5("Replaying proxy buffer for failed request"); + (0, assert_1.default)(s2.listenerCount("data") > 0); + s2.push(buffered); + s2.push(null); + }); + return fakeSocket; + } + }; + HttpsProxyAgent3.protocols = ["http", "https"]; + exports2.HttpsProxyAgent = HttpsProxyAgent3; + function resume2(socket) { + socket.resume(); + } + function omit2(obj, ...keys) { + const ret = {}; + let key; + for (key in obj) { + if (!keys.includes(key)) { + ret[key] = obj[key]; + } + } + return ret; + } + } +}); + // node_modules/http-proxy-agent/dist/index.js var require_dist3 = __commonJS({ "node_modules/http-proxy-agent/dist/index.js"(exports2) { @@ -26360,23 +26367,23 @@ var require_dist3 = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.HttpProxyAgent = void 0; - var net = __importStar(require("net")); - var tls = __importStar(require("tls")); + var net3 = __importStar(require("net")); + var tls2 = __importStar(require("tls")); var debug_1 = __importDefault(require_src2()); var events_1 = require("events"); var agent_base_1 = require_dist(); var url_1 = require("url"); - var debug3 = (0, debug_1.default)("http-proxy-agent"); + var debug5 = (0, debug_1.default)("http-proxy-agent"); var HttpProxyAgent2 = class extends agent_base_1.Agent { constructor(proxy, opts) { super(opts); this.proxy = typeof proxy === "string" ? new url_1.URL(proxy) : proxy; this.proxyHeaders = opts?.headers ?? {}; - debug3("Creating new HttpProxyAgent instance: %o", this.proxy.href); + debug5("Creating new HttpProxyAgent instance: %o", this.proxy.href); const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, ""); const port = this.proxy.port ? parseInt(this.proxy.port, 10) : this.proxy.protocol === "https:" ? 443 : 80; this.connectOpts = { - ...opts ? omit(opts, "headers") : null, + ...opts ? omit2(opts, "headers") : null, host, port }; @@ -26418,22 +26425,22 @@ var require_dist3 = __commonJS({ } let first; let endOfHeaders; - debug3("Regenerating stored HTTP header string for request"); + debug5("Regenerating stored HTTP header string for request"); req._implicitHeader(); if (req.outputData && req.outputData.length > 0) { - debug3("Patching connection write() output buffer with updated header"); + debug5("Patching connection write() output buffer with updated header"); first = req.outputData[0].data; endOfHeaders = first.indexOf("\r\n\r\n") + 4; req.outputData[0].data = req._header + first.substring(endOfHeaders); - debug3("Output buffer: %o", req.outputData[0].data); + debug5("Output buffer: %o", req.outputData[0].data); } let socket; if (this.proxy.protocol === "https:") { - debug3("Creating `tls.Socket`: %o", this.connectOpts); - socket = tls.connect(this.connectOpts); + debug5("Creating `tls.Socket`: %o", this.connectOpts); + socket = tls2.connect(this.connectOpts); } else { - debug3("Creating `net.Socket`: %o", this.connectOpts); - socket = net.connect(this.connectOpts); + debug5("Creating `net.Socket`: %o", this.connectOpts); + socket = net3.connect(this.connectOpts); } await (0, events_1.once)(socket, "connect"); return socket; @@ -26441,7 +26448,7 @@ var require_dist3 = __commonJS({ }; HttpProxyAgent2.protocols = ["http", "https"]; exports2.HttpProxyAgent = HttpProxyAgent2; - function omit(obj, ...keys) { + function omit2(obj, ...keys) { const ret = {}; let key; for (key in obj) { @@ -47752,11 +47759,11 @@ var require_constants2 = __commonJS({ var require_util2 = __commonJS({ "node_modules/undici/lib/core/util.js"(exports2, module2) { "use strict"; - var assert = require("assert"); + var assert2 = require("assert"); var { kDestroyed, kBodyUsed } = require_symbols(); var { IncomingMessage } = require("http"); var stream4 = require("stream"); - var net = require("net"); + var net3 = require("net"); var { InvalidArgumentError } = require_errors3(); var { Blob: Blob5 } = require("buffer"); var nodeUtil = require("util"); @@ -47834,7 +47841,7 @@ var require_util2 = __commonJS({ function getHostname(host) { if (host[0] === "[") { const idx2 = host.indexOf("]"); - assert(idx2 !== -1); + assert2(idx2 !== -1); return host.substring(1, idx2); } const idx = host.indexOf(":"); @@ -47845,9 +47852,9 @@ var require_util2 = __commonJS({ if (!host) { return null; } - assert.strictEqual(typeof host, "string"); + assert2.strictEqual(typeof host, "string"); const servername = getHostname(host); - if (net.isIP(servername)) { + if (net3.isIP(servername)) { return ""; } return servername; @@ -50448,7 +50455,7 @@ var require_util3 = __commonJS({ var { getGlobalOrigin } = require_global(); var { performance: performance2 } = require("perf_hooks"); var { isBlobLike: isBlobLike3, toUSVString, ReadableStreamFrom } = require_util2(); - var assert = require("assert"); + var assert2 = require("assert"); var { isUint8Array } = require("util/types"); var supportedHashes = []; var crypto3; @@ -50638,7 +50645,7 @@ var require_util3 = __commonJS({ } function determineRequestsReferrer(request3) { const policy = request3.referrerPolicy; - assert(policy); + assert2(policy); let referrerSource = null; if (request3.referrer === "client") { const globalOrigin = getGlobalOrigin(); @@ -50696,7 +50703,7 @@ var require_util3 = __commonJS({ } } function stripURLForReferrer(url2, originOnly) { - assert(url2 instanceof URL); + assert2(url2 instanceof URL); if (url2.protocol === "file:" || url2.protocol === "about:" || url2.protocol === "blank:") { return "no-referrer"; } @@ -50875,7 +50882,7 @@ var require_util3 = __commonJS({ if (result === void 0) { throw new TypeError("Value is not JSON serializable"); } - assert(typeof result === "string"); + assert2(typeof result === "string"); return result; } var esIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())); @@ -50969,7 +50976,7 @@ var require_util3 = __commonJS({ } function isomorphicEncode(input) { for (let i3 = 0; i3 < input.length; i3++) { - assert(input.charCodeAt(i3) <= 255); + assert2(input.charCodeAt(i3) <= 255); } return input; } @@ -50989,7 +50996,7 @@ var require_util3 = __commonJS({ } } function urlIsLocal(url2) { - assert("protocol" in url2); + assert2("protocol" in url2); const protocol = url2.protocol; return protocol === "about:" || protocol === "blob:" || protocol === "data:"; } @@ -51000,7 +51007,7 @@ var require_util3 = __commonJS({ return url2.protocol === "https:"; } function urlIsHttpHttpsScheme(url2) { - assert("protocol" in url2); + assert2("protocol" in url2); const protocol = url2.protocol; return protocol === "http:" || protocol === "https:"; } @@ -51442,7 +51449,7 @@ var require_webidl = __commonJS({ // node_modules/undici/lib/fetch/dataURL.js var require_dataURL = __commonJS({ "node_modules/undici/lib/fetch/dataURL.js"(exports2, module2) { - var assert = require("assert"); + var assert2 = require("assert"); var { atob: atob2 } = require("buffer"); var { isomorphicDecode } = require_util3(); var encoder = new TextEncoder(); @@ -51450,7 +51457,7 @@ var require_dataURL = __commonJS({ var HTTP_WHITESPACE_REGEX = /(\u000A|\u000D|\u0009|\u0020)/; var HTTP_QUOTED_STRING_TOKENS = /[\u0009|\u0020-\u007E|\u0080-\u00FF]/; function dataURLProcessor(dataURL) { - assert(dataURL.protocol === "data:"); + assert2(dataURL.protocol === "data:"); let input = URLSerializer(dataURL, true); input = input.slice(5); const position = { position: 0 }; @@ -51636,7 +51643,7 @@ var require_dataURL = __commonJS({ function collectAnHTTPQuotedString(input, position, extractValue) { const positionStart = position.position; let value = ""; - assert(input[position.position] === '"'); + assert2(input[position.position] === '"'); position.position++; while (true) { value += collectASequenceOfCodePoints( @@ -51657,7 +51664,7 @@ var require_dataURL = __commonJS({ value += input[position.position]; position.position++; } else { - assert(quoteOrBackslash === '"'); + assert2(quoteOrBackslash === '"'); break; } } @@ -51667,7 +51674,7 @@ var require_dataURL = __commonJS({ return input.slice(positionStart, position.position); } function serializeAMimeType(mimeType) { - assert(mimeType !== "failure"); + assert2(mimeType !== "failure"); const { parameters, essence } = mimeType; let serialization = essence; for (let [name, value] of parameters.entries()) { @@ -52086,7 +52093,7 @@ var require_body = __commonJS({ var { DOMException: DOMException3, structuredClone: structuredClone2 } = require_constants3(); var { Blob: Blob5, File: NativeFile } = require("buffer"); var { kBodyUsed } = require_symbols(); - var assert = require("assert"); + var assert2 = require("assert"); var { isErrored } = require_util2(); var { isUint8Array, isArrayBuffer: isArrayBuffer3 } = require("util/types"); var { File: UndiciFile } = require_file(); @@ -52124,7 +52131,7 @@ var require_body = __commonJS({ type: void 0 }); } - assert(isReadableStreamLike(stream4)); + assert2(isReadableStreamLike(stream4)); let action = null; let source = null; let length = null; @@ -52240,8 +52247,8 @@ Content-Type: ${value.type || "application/octet-stream"}\r ReadableStream7 = require("stream/web").ReadableStream; } if (object instanceof ReadableStream7) { - assert(!util4.isDisturbed(object), "The body has already been consumed."); - assert(!object.locked, "The stream is locked."); + assert2(!util4.isDisturbed(object), "The body has already been consumed."); + assert2(!object.locked, "The stream is locked."); } return extractBody(object, keepalive); } @@ -52452,7 +52459,7 @@ var require_request = __commonJS({ InvalidArgumentError, NotSupportedError } = require_errors3(); - var assert = require("assert"); + var assert2 = require("assert"); var { kHTTP2BuildRequest, kHTTP2CopyHeaders, kHTTP1BuildRequest } = require_symbols(); var util4 = require_util2(); var tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/; @@ -52633,8 +52640,8 @@ var require_request = __commonJS({ } } onConnect(abort) { - assert(!this.aborted); - assert(!this.completed); + assert2(!this.aborted); + assert2(!this.completed); if (this.error) { abort(this.error); } else { @@ -52642,21 +52649,21 @@ var require_request = __commonJS({ return this[kHandler].onConnect(abort); } } - onHeaders(statusCode, headers, resume, statusText) { - assert(!this.aborted); - assert(!this.completed); + onHeaders(statusCode, headers, resume2, statusText) { + assert2(!this.aborted); + assert2(!this.completed); if (channels.headers.hasSubscribers) { channels.headers.publish({ request: this, response: { statusCode, headers, statusText } }); } try { - return this[kHandler].onHeaders(statusCode, headers, resume, statusText); + return this[kHandler].onHeaders(statusCode, headers, resume2, statusText); } catch (err) { this.abort(err); } } onData(chunk) { - assert(!this.aborted); - assert(!this.completed); + assert2(!this.aborted); + assert2(!this.completed); try { return this[kHandler].onData(chunk); } catch (err) { @@ -52665,13 +52672,13 @@ var require_request = __commonJS({ } } onUpgrade(statusCode, headers, socket) { - assert(!this.aborted); - assert(!this.completed); + assert2(!this.aborted); + assert2(!this.completed); return this[kHandler].onUpgrade(statusCode, headers, socket); } onComplete(trailers) { this.onFinally(); - assert(!this.aborted); + assert2(!this.aborted); this.completed = true; if (channels.trailers.hasSubscribers) { channels.trailers.publish({ request: this, trailers }); @@ -53001,11 +53008,11 @@ var require_dispatcher_base = __commonJS({ var require_connect = __commonJS({ "node_modules/undici/lib/core/connect.js"(exports2, module2) { "use strict"; - var net = require("net"); - var assert = require("assert"); + var net3 = require("net"); + var assert2 = require("assert"); var util4 = require_util2(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors3(); - var tls; + var tls2; var SessionCache; if (global.FinalizationRegistry && !process.env.NODE_V8_COVERAGE) { SessionCache = class WeakSessionCache { @@ -53063,17 +53070,17 @@ var require_connect = __commonJS({ const sessionCache = new SessionCache(maxCachedSessions == null ? 100 : maxCachedSessions); timeout = timeout == null ? 1e4 : timeout; allowH2 = allowH2 != null ? allowH2 : false; - return function connect({ hostname, host, protocol, port, servername, localAddress, httpSocket }, callback) { + return function connect3({ hostname, host, protocol, port, servername, localAddress, httpSocket }, callback) { let socket; if (protocol === "https:") { - if (!tls) { - tls = require("tls"); + if (!tls2) { + tls2 = require("tls"); } servername = servername || options.servername || util4.getServerName(host) || null; const sessionKey = servername || hostname; const session = sessionCache.get(sessionKey) || null; - assert(sessionKey); - socket = tls.connect({ + assert2(sessionKey); + socket = tls2.connect({ highWaterMark: 16384, // TLS in node can't have bigger HWM anyway... ...options, @@ -53091,8 +53098,8 @@ var require_connect = __commonJS({ sessionCache.set(sessionKey, session2); }); } else { - assert(!httpSocket, "httpSocket can only be sent on TLS update"); - socket = net.connect({ + assert2(!httpSocket, "httpSocket can only be sent on TLS update"); + socket = net3.connect({ highWaterMark: 64 * 1024, // Same as nodejs fs streams. ...options, @@ -53500,7 +53507,7 @@ var require_RedirectHandler = __commonJS({ "use strict"; var util4 = require_util2(); var { kBodyUsed } = require_symbols(); - var assert = require("assert"); + var assert2 = require("assert"); var { InvalidArgumentError } = require_errors3(); var EE = require("events"); var redirectableStatusCodes = [300, 301, 302, 303, 307, 308]; @@ -53511,7 +53518,7 @@ var require_RedirectHandler = __commonJS({ this[kBodyUsed] = false; } async *[Symbol.asyncIterator]() { - assert(!this[kBodyUsed], "disturbed"); + assert2(!this[kBodyUsed], "disturbed"); this[kBodyUsed] = true; yield* this[kBody]; } @@ -53532,7 +53539,7 @@ var require_RedirectHandler = __commonJS({ if (util4.isStream(this.opts.body)) { if (util4.bodyLength(this.opts.body) === 0) { this.opts.body.on("data", function() { - assert(false); + assert2(false); }); } if (typeof this.opts.body.readableDidRead !== "boolean") { @@ -53557,13 +53564,13 @@ var require_RedirectHandler = __commonJS({ onError(error) { this.handler.onError(error); } - onHeaders(statusCode, headers, resume, statusText) { + onHeaders(statusCode, headers, resume2, statusText) { this.location = this.history.length >= this.maxRedirections || util4.isDisturbed(this.opts.body) ? null : parseLocation(statusCode, headers); if (this.opts.origin) { this.history.push(new URL(this.opts.path, this.opts.origin)); } if (!this.location) { - return this.handler.onHeaders(statusCode, headers, resume, statusText); + return this.handler.onHeaders(statusCode, headers, resume2, statusText); } const { origin: origin2, pathname, search } = util4.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin))); const path5 = search ? `${pathname}${search}` : pathname; @@ -53636,7 +53643,7 @@ var require_RedirectHandler = __commonJS({ } } } else { - assert(headers == null, "headers must be an object or an array"); + assert2(headers == null, "headers must be an object or an array"); } return ret; } @@ -53684,9 +53691,9 @@ var require_llhttp_simd_wasm = __commonJS({ var require_client = __commonJS({ "node_modules/undici/lib/client.js"(exports2, module2) { "use strict"; - var assert = require("assert"); - var net = require("net"); - var http3 = require("http"); + var assert2 = require("assert"); + var net3 = require("net"); + var http4 = require("http"); var { pipeline } = require("stream"); var util4 = require_util2(); var timers = require_timers(); @@ -53814,11 +53821,11 @@ var require_client = __commonJS({ keepAliveTimeoutThreshold, socketPath, pipelining, - tls, + tls: tls2, strictContentLength, maxCachedSessions, maxRedirections, - connect: connect2, + connect: connect4, maxRequestsPerClient, localAddress, maxResponseSize, @@ -53868,7 +53875,7 @@ var require_client = __commonJS({ if (bodyTimeout != null && (!Number.isInteger(bodyTimeout) || bodyTimeout < 0)) { throw new InvalidArgumentError("bodyTimeout must be a positive integer or zero"); } - if (connect2 != null && typeof connect2 !== "function" && typeof connect2 !== "object") { + if (connect4 != null && typeof connect4 !== "function" && typeof connect4 !== "object") { throw new InvalidArgumentError("connect must be a function or an object"); } if (maxRedirections != null && (!Number.isInteger(maxRedirections) || maxRedirections < 0)) { @@ -53877,7 +53884,7 @@ var require_client = __commonJS({ if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) { throw new InvalidArgumentError("maxRequestsPerClient must be a positive number"); } - if (localAddress != null && (typeof localAddress !== "string" || net.isIP(localAddress) === 0)) { + if (localAddress != null && (typeof localAddress !== "string" || net3.isIP(localAddress) === 0)) { throw new InvalidArgumentError("localAddress must be valid string IP address"); } if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) { @@ -53892,23 +53899,23 @@ var require_client = __commonJS({ if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== "number" || maxConcurrentStreams < 1)) { throw new InvalidArgumentError("maxConcurrentStreams must be a possitive integer, greater than 0"); } - if (typeof connect2 !== "function") { - connect2 = buildConnector({ - ...tls, + if (typeof connect4 !== "function") { + connect4 = buildConnector({ + ...tls2, maxCachedSessions, allowH2, socketPath, timeout: connectTimeout, ...util4.nodeHasAutoSelectFamily && autoSelectFamily ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0, - ...connect2 + ...connect4 }); } this[kInterceptors] = interceptors && interceptors.Client && Array.isArray(interceptors.Client) ? interceptors.Client : [createRedirectInterceptor({ maxRedirections })]; this[kUrl] = util4.parseOrigin(url2); - this[kConnector] = connect2; + this[kConnector] = connect4; this[kSocket] = null; this[kPipelining] = pipelining != null ? pipelining : 1; - this[kMaxHeadersSize] = maxHeaderSize || http3.maxHeaderSize; + this[kMaxHeadersSize] = maxHeaderSize || http4.maxHeaderSize; this[kKeepAliveDefaultTimeout] = keepAliveTimeout == null ? 4e3 : keepAliveTimeout; this[kKeepAliveMaxTimeout] = keepAliveMaxTimeout == null ? 6e5 : keepAliveMaxTimeout; this[kKeepAliveTimeoutThreshold] = keepAliveTimeoutThreshold == null ? 1e3 : keepAliveTimeoutThreshold; @@ -53945,7 +53952,7 @@ var require_client = __commonJS({ } set pipelining(value) { this[kPipelining] = value; - resume(this, true); + resume2(this, true); } get [kPending]() { return this[kQueue].length - this[kPendingIdx]; @@ -53965,7 +53972,7 @@ var require_client = __commonJS({ } /* istanbul ignore: only used for test */ [kConnect](cb) { - connect(this); + connect3(this); this.once("connect", cb); } [kDispatch](opts, handler) { @@ -53975,9 +53982,9 @@ var require_client = __commonJS({ if (this[kResuming]) { } else if (util4.bodyLength(request3.body) == null && util4.isIterable(request3.body)) { this[kResuming] = 1; - process.nextTick(resume, this); + process.nextTick(resume2, this); } else { - resume(this, true); + resume2(this, true); } if (this[kResuming] && this[kNeedDrain] !== 2 && this[kBusy]) { this[kNeedDrain] = 2; @@ -54017,12 +54024,12 @@ var require_client = __commonJS({ } else { util4.destroy(this[kSocket].on("close", callback), err); } - resume(this); + resume2(this); }); } }; function onHttp2SessionError(err) { - assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + assert2(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); this[kSocket][kError] = err; onError(this[kClient], err); } @@ -54043,7 +54050,7 @@ var require_client = __commonJS({ client[kSocket] = null; client[kHTTP2Session] = null; if (client.destroyed) { - assert(this[kPending] === 0); + assert2(this[kPending] === 0); const requests = client[kQueue].splice(client[kRunningIdx]); for (let i3 = 0; i3 < requests.length; i3++) { const request3 = requests[i3]; @@ -54055,14 +54062,14 @@ var require_client = __commonJS({ errorRequest(client, request3, err); } client[kPendingIdx] = client[kRunningIdx]; - assert(client[kRunning] === 0); + assert2(client[kRunning] === 0); client.emit( "disconnect", client[kUrl], [client], err ); - resume(client); + resume2(client); } var constants3 = require_constants4(); var createRedirectInterceptor = require_redirectInterceptor(); @@ -54082,35 +54089,35 @@ var require_client = __commonJS({ return 0; }, wasm_on_status: (p4, at2, len) => { - assert.strictEqual(currentParser.ptr, p4); + assert2.strictEqual(currentParser.ptr, p4); const start = at2 - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_begin: (p4) => { - assert.strictEqual(currentParser.ptr, p4); + assert2.strictEqual(currentParser.ptr, p4); return currentParser.onMessageBegin() || 0; }, wasm_on_header_field: (p4, at2, len) => { - assert.strictEqual(currentParser.ptr, p4); + assert2.strictEqual(currentParser.ptr, p4); const start = at2 - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_header_value: (p4, at2, len) => { - assert.strictEqual(currentParser.ptr, p4); + assert2.strictEqual(currentParser.ptr, p4); const start = at2 - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_headers_complete: (p4, statusCode, upgrade, shouldKeepAlive) => { - assert.strictEqual(currentParser.ptr, p4); + assert2.strictEqual(currentParser.ptr, p4); return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0; }, wasm_on_body: (p4, at2, len) => { - assert.strictEqual(currentParser.ptr, p4); + assert2.strictEqual(currentParser.ptr, p4); const start = at2 - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_complete: (p4) => { - assert.strictEqual(currentParser.ptr, p4); + assert2.strictEqual(currentParser.ptr, p4); return currentParser.onMessageComplete() || 0; } /* eslint-enable camelcase */ @@ -54129,7 +54136,7 @@ var require_client = __commonJS({ var TIMEOUT_IDLE = 3; var Parser = class { constructor(client, socket, { exports: exports3 }) { - assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); + assert2(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); this.llhttp = exports3; this.ptr = this.llhttp.llhttp_alloc(constants3.TYPE.RESPONSE); this.client = client; @@ -54175,10 +54182,10 @@ var require_client = __commonJS({ if (this.socket.destroyed || !this.paused) { return; } - assert(this.ptr != null); - assert(currentParser == null); + assert2(this.ptr != null); + assert2(currentParser == null); this.llhttp.llhttp_resume(this.ptr); - assert(this.timeoutType === TIMEOUT_BODY); + assert2(this.timeoutType === TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); @@ -54198,9 +54205,9 @@ var require_client = __commonJS({ } } execute(data) { - assert(this.ptr != null); - assert(currentParser == null); - assert(!this.paused); + assert2(this.ptr != null); + assert2(currentParser == null); + assert2(!this.paused); const { socket, llhttp } = this; if (data.length > currentBufferSize) { if (currentBufferPtr) { @@ -54242,8 +54249,8 @@ var require_client = __commonJS({ } } destroy() { - assert(this.ptr != null); - assert(currentParser == null); + assert2(this.ptr != null); + assert2(currentParser == null); this.llhttp.llhttp_free(this.ptr); this.ptr = null; timers.clearTimeout(this.timeout); @@ -54300,17 +54307,17 @@ var require_client = __commonJS({ } onUpgrade(head) { const { upgrade, client, socket, headers, statusCode } = this; - assert(upgrade); + assert2(upgrade); const request3 = client[kQueue][client[kRunningIdx]]; - assert(request3); - assert(!socket.destroyed); - assert(socket === client[kSocket]); - assert(!this.paused); - assert(request3.upgrade || request3.method === "CONNECT"); + assert2(request3); + assert2(!socket.destroyed); + assert2(socket === client[kSocket]); + assert2(!this.paused); + assert2(request3.upgrade || request3.method === "CONNECT"); this.statusCode = null; this.statusText = ""; this.shouldKeepAlive = null; - assert(this.headers.length % 2 === 0); + assert2(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; socket.unshift(head); @@ -54327,7 +54334,7 @@ var require_client = __commonJS({ } catch (err) { util4.destroy(socket, err); } - resume(client); + resume2(client); } onHeadersComplete(statusCode, upgrade, shouldKeepAlive) { const { client, socket, headers, statusText } = this; @@ -54338,8 +54345,8 @@ var require_client = __commonJS({ if (!request3) { return -1; } - assert(!this.upgrade); - assert(this.statusCode < 200); + assert2(!this.upgrade); + assert2(this.statusCode < 200); if (statusCode === 100) { util4.destroy(socket, new SocketError("bad response", util4.getSocketInfo(socket))); return -1; @@ -54348,7 +54355,7 @@ var require_client = __commonJS({ util4.destroy(socket, new SocketError("bad upgrade", util4.getSocketInfo(socket))); return -1; } - assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS); + assert2.strictEqual(this.timeoutType, TIMEOUT_HEADERS); this.statusCode = statusCode; this.shouldKeepAlive = shouldKeepAlive || // Override llhttp value which does not allow keepAlive for HEAD. request3.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive"; @@ -54361,16 +54368,16 @@ var require_client = __commonJS({ } } if (request3.method === "CONNECT") { - assert(client[kRunning] === 1); + assert2(client[kRunning] === 1); this.upgrade = true; return 2; } if (upgrade) { - assert(client[kRunning] === 1); + assert2(client[kRunning] === 1); this.upgrade = true; return 2; } - assert(this.headers.length % 2 === 0); + assert2(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { @@ -54403,7 +54410,7 @@ var require_client = __commonJS({ } if (socket[kBlocking]) { socket[kBlocking] = false; - resume(client); + resume2(client); } return pause ? constants3.ERROR.PAUSED : 0; } @@ -54413,14 +54420,14 @@ var require_client = __commonJS({ return -1; } const request3 = client[kQueue][client[kRunningIdx]]; - assert(request3); - assert.strictEqual(this.timeoutType, TIMEOUT_BODY); + assert2(request3); + assert2.strictEqual(this.timeoutType, TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); } } - assert(statusCode >= 200); + assert2(statusCode >= 200); if (maxResponseSize > -1 && this.bytesRead + buf.length > maxResponseSize) { util4.destroy(socket, new ResponseExceededMaxSizeError()); return -1; @@ -54439,15 +54446,15 @@ var require_client = __commonJS({ return; } const request3 = client[kQueue][client[kRunningIdx]]; - assert(request3); - assert(statusCode >= 100); + assert2(request3); + assert2(statusCode >= 100); this.statusCode = null; this.statusText = ""; this.bytesRead = 0; this.contentLength = ""; this.keepAlive = ""; this.connection = ""; - assert(this.headers.length % 2 === 0); + assert2(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (statusCode < 200) { @@ -54460,7 +54467,7 @@ var require_client = __commonJS({ request3.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { - assert.strictEqual(client[kRunning], 0); + assert2.strictEqual(client[kRunning], 0); util4.destroy(socket, new InformationalError("reset")); return constants3.ERROR.PAUSED; } else if (!shouldKeepAlive) { @@ -54470,9 +54477,9 @@ var require_client = __commonJS({ util4.destroy(socket, new InformationalError("reset")); return constants3.ERROR.PAUSED; } else if (client[kPipelining] === 1) { - setImmediate(resume, client); + setImmediate(resume2, client); } else { - resume(client); + resume2(client); } } }; @@ -54480,7 +54487,7 @@ var require_client = __commonJS({ const { socket, timeoutType, client } = parser; if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { - assert(!parser.paused, "cannot be paused while waiting for headers"); + assert2(!parser.paused, "cannot be paused while waiting for headers"); util4.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { @@ -54488,7 +54495,7 @@ var require_client = __commonJS({ util4.destroy(socket, new BodyTimeoutError()); } } else if (timeoutType === TIMEOUT_IDLE) { - assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); + assert2(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); util4.destroy(socket, new InformationalError("socket idle timeout")); } } @@ -54500,7 +54507,7 @@ var require_client = __commonJS({ } function onSocketError(err) { const { [kClient]: client, [kParser]: parser } = this; - assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + assert2(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); if (client[kHTTPConnVersion] !== "h2") { if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) { parser.onMessageComplete(); @@ -54512,13 +54519,13 @@ var require_client = __commonJS({ } function onError(client, err) { if (client[kRunning] === 0 && err.code !== "UND_ERR_INFO" && err.code !== "UND_ERR_SOCKET") { - assert(client[kPendingIdx] === client[kRunningIdx]); + assert2(client[kPendingIdx] === client[kRunningIdx]); const requests = client[kQueue].splice(client[kRunningIdx]); for (let i3 = 0; i3 < requests.length; i3++) { const request3 = requests[i3]; errorRequest(client, request3, err); } - assert(client[kSize] === 0); + assert2(client[kSize] === 0); } } function onSocketEnd() { @@ -54543,7 +54550,7 @@ var require_client = __commonJS({ const err = this[kError] || new SocketError("closed", util4.getSocketInfo(this)); client[kSocket] = null; if (client.destroyed) { - assert(client[kPending] === 0); + assert2(client[kPending] === 0); const requests = client[kQueue].splice(client[kRunningIdx]); for (let i3 = 0; i3 < requests.length; i3++) { const request3 = requests[i3]; @@ -54555,19 +54562,19 @@ var require_client = __commonJS({ errorRequest(client, request3, err); } client[kPendingIdx] = client[kRunningIdx]; - assert(client[kRunning] === 0); + assert2(client[kRunning] === 0); client.emit("disconnect", client[kUrl], [client], err); - resume(client); + resume2(client); } - async function connect(client) { - assert(!client[kConnecting]); - assert(!client[kSocket]); + async function connect3(client) { + assert2(!client[kConnecting]); + assert2(!client[kSocket]); let { host, hostname, protocol, port } = client[kUrl]; if (hostname[0] === "[") { const idx = hostname.indexOf("]"); - assert(idx !== -1); + assert2(idx !== -1); const ip = hostname.substring(1, idx); - assert(net.isIP(ip)); + assert2(net3.isIP(ip)); hostname = ip; } client[kConnecting] = true; @@ -54607,7 +54614,7 @@ var require_client = __commonJS({ return; } client[kConnecting] = false; - assert(socket); + assert2(socket); const isH2 = socket.alpnProtocol === "h2"; if (isH2) { if (!h2ExperimentalWarned) { @@ -54683,7 +54690,7 @@ var require_client = __commonJS({ }); } if (err.code === "ERR_TLS_CERT_ALTNAME_INVALID") { - assert(client[kRunning] === 0); + assert2(client[kRunning] === 0); while (client[kPending] > 0 && client[kQueue][client[kPendingIdx]].servername === client[kServerName]) { const request3 = client[kQueue][client[kPendingIdx]++]; errorRequest(client, request3, err); @@ -54693,13 +54700,13 @@ var require_client = __commonJS({ } client.emit("connectionError", client[kUrl], [client], err); } - resume(client); + resume2(client); } function emitDrain(client) { client[kNeedDrain] = 0; client.emit("drain", client[kUrl], [client]); } - function resume(client, sync) { + function resume2(client, sync) { if (client[kResuming] === 2) { return; } @@ -54715,7 +54722,7 @@ var require_client = __commonJS({ function _resume(client, sync) { while (true) { if (client.destroyed) { - assert(client[kPending] === 0); + assert2(client[kPending] === 0); return; } if (client[kClosedResolve] && !client[kSize]) { @@ -54778,7 +54785,7 @@ var require_client = __commonJS({ return; } if (!socket && !client[kHTTP2Session]) { - connect(client); + connect3(client); return; } if (socket.destroyed || socket[kWriting] || socket[kReset] || socket[kBlocking]) { @@ -54887,13 +54894,13 @@ upgrade: ${upgrade}\r \r `, "latin1"); } else { - assert(contentLength === null, "no body must not have content length"); + assert2(contentLength === null, "no body must not have content length"); socket.write(`${header}\r `, "latin1"); } request3.onRequestSent(); } else if (util4.isBuffer(body)) { - assert(contentLength === body.byteLength, "buffer body must have content length"); + assert2(contentLength === body.byteLength, "buffer body must have content length"); socket.cork(); socket.write(`${header}content-length: ${contentLength}\r \r @@ -54916,7 +54923,7 @@ upgrade: ${upgrade}\r } else if (util4.isIterable(body)) { writeIterable({ body, client, request: request3, socket, contentLength, header, expectsPayload }); } else { - assert(false); + assert2(false); } return true; } @@ -54985,7 +54992,7 @@ upgrade: ${upgrade}\r process.emitWarning(new RequestContentLengthMismatchError()); } if (contentLength != null) { - assert(body, "no body must not have content length"); + assert2(body, "no body must not have content length"); headers[HTTP2_HEADER_CONTENT_LENGTH] = `${contentLength}`; } session.ref(); @@ -55041,7 +55048,7 @@ upgrade: ${upgrade}\r if (!body) { request3.onRequestSent(); } else if (util4.isBuffer(body)) { - assert(contentLength === body.byteLength, "buffer body must have content length"); + assert2(contentLength === body.byteLength, "buffer body must have content length"); stream4.cork(); stream4.write(body); stream4.uncork(); @@ -55095,12 +55102,12 @@ upgrade: ${upgrade}\r socket: client[kSocket] }); } else { - assert(false); + assert2(false); } } } function writeStream({ h2stream, body, client, request: request3, socket, contentLength, header, expectsPayload }) { - assert(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined"); + assert2(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined"); if (client[kHTTPConnVersion] === "h2") { let onPipeData = function(chunk) { request3.onBodySent(chunk); @@ -55158,7 +55165,7 @@ upgrade: ${upgrade}\r return; } finished = true; - assert(socket.destroyed || socket[kWriting] && client[kRunning] <= 1); + assert2(socket.destroyed || socket[kWriting] && client[kRunning] <= 1); socket.off("drain", onDrain).off("error", onFinished); body.removeListener("data", onData).removeListener("end", onFinished).removeListener("error", onFinished).removeListener("close", onAbort); if (!err) { @@ -55182,7 +55189,7 @@ upgrade: ${upgrade}\r socket.on("drain", onDrain).on("error", onFinished); } async function writeBlob({ h2stream, body, client, request: request3, socket, contentLength, header, expectsPayload }) { - assert(contentLength === body.size, "blob body must have content length"); + assert2(contentLength === body.size, "blob body must have content length"); const isH2 = client[kHTTPConnVersion] === "h2"; try { if (contentLength != null && contentLength !== body.size) { @@ -55206,13 +55213,13 @@ upgrade: ${upgrade}\r if (!expectsPayload) { socket[kReset] = true; } - resume(client); + resume2(client); } catch (err) { util4.destroy(isH2 ? h2stream : socket, err); } } async function writeIterable({ h2stream, body, client, request: request3, socket, contentLength, header, expectsPayload }) { - assert(contentLength !== 0 || client[kRunning] === 0, "iterator body cannot be pipelined"); + assert2(contentLength !== 0 || client[kRunning] === 0, "iterator body cannot be pipelined"); let callback = null; function onDrain() { if (callback) { @@ -55222,7 +55229,7 @@ upgrade: ${upgrade}\r } } const waitForDrain = () => new Promise((resolve, reject) => { - assert(callback === null); + assert2(callback === null); if (socket[kError]) { reject(socket[kError]); } else { @@ -55364,13 +55371,13 @@ ${len.toString(16)}\r socket[kParser].timeout.refresh(); } } - resume(client); + resume2(client); } destroy(err) { const { socket, client } = this; socket[kWriting] = false; if (err) { - assert(client[kRunning] <= 1, "pipeline should only contain this request"); + assert2(client[kRunning] <= 1, "pipeline should only contain this request"); util4.destroy(socket, err); } } @@ -55378,7 +55385,7 @@ ${len.toString(16)}\r function errorRequest(client, request3, err) { try { request3.onError(err); - assert(request3.aborted); + assert2(request3.aborted); } catch (err2) { client.emit("error", err2); } @@ -55659,9 +55666,9 @@ var require_pool = __commonJS({ constructor(origin2, { connections, factory = defaultFactory, - connect, + connect: connect3, connectTimeout, - tls, + tls: tls2, maxCachedSessions, socketPath, autoSelectFamily, @@ -55676,24 +55683,24 @@ var require_pool = __commonJS({ if (typeof factory !== "function") { throw new InvalidArgumentError("factory must be a function."); } - if (connect != null && typeof connect !== "function" && typeof connect !== "object") { + if (connect3 != null && typeof connect3 !== "function" && typeof connect3 !== "object") { throw new InvalidArgumentError("connect must be a function or an object"); } - if (typeof connect !== "function") { - connect = buildConnector({ - ...tls, + if (typeof connect3 !== "function") { + connect3 = buildConnector({ + ...tls2, maxCachedSessions, allowH2, socketPath, timeout: connectTimeout, ...util4.nodeHasAutoSelectFamily && autoSelectFamily ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0, - ...connect + ...connect3 }); } this[kInterceptors] = options.interceptors && options.interceptors.Pool && Array.isArray(options.interceptors.Pool) ? options.interceptors.Pool : []; this[kConnections] = connections || null; this[kUrl] = util4.parseOrigin(origin2); - this[kOptions] = { ...util4.deepClone(options), connect, allowH2 }; + this[kOptions] = { ...util4.deepClone(options), connect: connect3, allowH2 }; this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0; this[kFactory] = factory; this.on("connectionError", (origin3, targets, error) => { @@ -55921,23 +55928,23 @@ var require_agent2 = __commonJS({ function defaultFactory(origin2, opts) { return opts && opts.connections === 1 ? new Client(origin2, opts) : new Pool(origin2, opts); } - var Agent4 = class extends DispatcherBase { - constructor({ factory = defaultFactory, maxRedirections = 0, connect, ...options } = {}) { + var Agent6 = class extends DispatcherBase { + constructor({ factory = defaultFactory, maxRedirections = 0, connect: connect3, ...options } = {}) { super(); if (typeof factory !== "function") { throw new InvalidArgumentError("factory must be a function."); } - if (connect != null && typeof connect !== "function" && typeof connect !== "object") { + if (connect3 != null && typeof connect3 !== "function" && typeof connect3 !== "object") { throw new InvalidArgumentError("connect must be a function or an object"); } if (!Number.isInteger(maxRedirections) || maxRedirections < 0) { throw new InvalidArgumentError("maxRedirections must be a positive number"); } - if (connect && typeof connect !== "function") { - connect = { ...connect }; + if (connect3 && typeof connect3 !== "function") { + connect3 = { ...connect3 }; } this[kInterceptors] = options.interceptors && options.interceptors.Agent && Array.isArray(options.interceptors.Agent) ? options.interceptors.Agent : [createRedirectInterceptor({ maxRedirections })]; - this[kOptions] = { ...util4.deepClone(options), connect }; + this[kOptions] = { ...util4.deepClone(options), connect: connect3 }; this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0; this[kMaxRedirections] = maxRedirections; this[kFactory] = factory; @@ -56012,7 +56019,7 @@ var require_agent2 = __commonJS({ await Promise.all(destroyPromises); } }; - module2.exports = Agent4; + module2.exports = Agent6; } }); @@ -56020,7 +56027,7 @@ var require_agent2 = __commonJS({ var require_readable = __commonJS({ "node_modules/undici/lib/api/readable.js"(exports2, module2) { "use strict"; - var assert = require("assert"); + var assert2 = require("assert"); var { Readable: Readable5 } = require("stream"); var { RequestAbortedError, NotSupportedError, InvalidArgumentError } = require_errors3(); var util4 = require_util2(); @@ -56035,7 +56042,7 @@ var require_readable = __commonJS({ }; module2.exports = class BodyReadable extends Readable5 { constructor({ - resume, + resume: resume2, abort, contentType = "", highWaterMark = 64 * 1024 @@ -56043,7 +56050,7 @@ var require_readable = __commonJS({ }) { super({ autoDestroy: true, - read: resume, + read: resume2, highWaterMark }); this._readableState.dataEmitted = false; @@ -56129,7 +56136,7 @@ var require_readable = __commonJS({ this[kBody] = ReadableStreamFrom(this); if (this[kConsume]) { this[kBody].getReader(); - assert(this[kBody].locked); + assert2(this[kBody].locked); } } return this[kBody]; @@ -56180,7 +56187,7 @@ var require_readable = __commonJS({ if (isUnusable(stream4)) { throw new TypeError("unusable"); } - assert(!stream4[kConsume]); + assert2(!stream4[kConsume]); return new Promise((resolve, reject) => { stream4[kConsume] = { type: type2, @@ -56271,13 +56278,13 @@ var require_readable = __commonJS({ // node_modules/undici/lib/api/util.js var require_util4 = __commonJS({ "node_modules/undici/lib/api/util.js"(exports2, module2) { - var assert = require("assert"); + var assert2 = require("assert"); var { ResponseStatusCodeError } = require_errors3(); var { toUSVString } = require_util2(); async function getResolveErrorBodyCallback({ callback, body, contentType, statusCode, statusMessage, headers }) { - assert(body); + assert2(body); let chunks = []; let limit = 0; for await (const chunk of body) { @@ -56427,7 +56434,7 @@ var require_api_request = __commonJS({ this.abort = abort; this.context = context; } - onHeaders(statusCode, rawHeaders, resume, statusMessage) { + onHeaders(statusCode, rawHeaders, resume2, statusMessage) { const { callback, opaque, abort, context, responseHeaders, highWaterMark } = this; const headers = responseHeaders === "raw" ? util4.parseRawHeaders(rawHeaders) : util4.parseHeaders(rawHeaders); if (statusCode < 200) { @@ -56438,7 +56445,7 @@ var require_api_request = __commonJS({ } const parsedHeaders = responseHeaders === "raw" ? util4.parseHeaders(rawHeaders) : headers; const contentType = parsedHeaders["content-type"]; - const body = new Readable5({ resume, abort, contentType, highWaterMark }); + const body = new Readable5({ resume: resume2, abort, contentType, highWaterMark }); this.callback = null; this.res = body; if (callback !== null) { @@ -56582,7 +56589,7 @@ var require_api_stream = __commonJS({ this.abort = abort; this.context = context; } - onHeaders(statusCode, rawHeaders, resume, statusMessage) { + onHeaders(statusCode, rawHeaders, resume2, statusMessage) { const { factory, opaque, context, callback, responseHeaders } = this; const headers = responseHeaders === "raw" ? util4.parseRawHeaders(rawHeaders) : util4.parseHeaders(rawHeaders); if (statusCode < 200) { @@ -56629,7 +56636,7 @@ var require_api_stream = __commonJS({ } }); } - res.on("drain", resume); + res.on("drain", resume2); this.res = res; const needDrain = res.writableNeedDrain !== void 0 ? res.writableNeedDrain : res._writableState && res._writableState.needDrain; return needDrain !== true; @@ -56705,7 +56712,7 @@ var require_api_pipeline = __commonJS({ var util4 = require_util2(); var { AsyncResource } = require("async_hooks"); var { addSignal, removeSignal } = require_abort_signal(); - var assert = require("assert"); + var assert2 = require("assert"); var kResume = Symbol("resume"); var PipelineRequest = class extends Readable5 { constructor() { @@ -56713,10 +56720,10 @@ var require_api_pipeline = __commonJS({ this[kResume] = null; } _read() { - const { [kResume]: resume } = this; - if (resume) { + const { [kResume]: resume2 } = this; + if (resume2) { this[kResume] = null; - resume(); + resume2(); } } _destroy(err, callback) { @@ -56725,9 +56732,9 @@ var require_api_pipeline = __commonJS({ } }; var PipelineResponse = class extends Readable5 { - constructor(resume) { + constructor(resume2) { super({ autoDestroy: true }); - this[kResume] = resume; + this[kResume] = resume2; } _read() { this[kResume](); @@ -56805,14 +56812,14 @@ var require_api_pipeline = __commonJS({ } onConnect(abort, context) { const { ret, res } = this; - assert(!res, "pipeline cannot be retried"); + assert2(!res, "pipeline cannot be retried"); if (ret.destroyed) { throw new RequestAbortedError(); } this.abort = abort; this.context = context; } - onHeaders(statusCode, rawHeaders, resume) { + onHeaders(statusCode, rawHeaders, resume2) { const { opaque, handler, context } = this; if (statusCode < 200) { if (this.onInfo) { @@ -56821,7 +56828,7 @@ var require_api_pipeline = __commonJS({ } return; } - this.res = new PipelineResponse(resume); + this.res = new PipelineResponse(resume2); let body; try { this.handler = null; @@ -56894,7 +56901,7 @@ var require_api_upgrade = __commonJS({ var { AsyncResource } = require("async_hooks"); var util4 = require_util2(); var { addSignal, removeSignal } = require_abort_signal(); - var assert = require("assert"); + var assert2 = require("assert"); var UpgradeHandler = class extends AsyncResource { constructor(opts, callback) { if (!opts || typeof opts !== "object") { @@ -56927,7 +56934,7 @@ var require_api_upgrade = __commonJS({ } onUpgrade(statusCode, rawHeaders, socket) { const { callback, opaque, context } = this; - assert.strictEqual(statusCode, 101); + assert2.strictEqual(statusCode, 101); removeSignal(this); this.callback = null; const headers = this.responseHeaders === "raw" ? util4.parseRawHeaders(rawHeaders) : util4.parseHeaders(rawHeaders); @@ -57040,10 +57047,10 @@ var require_api_connect = __commonJS({ } } }; - function connect(opts, callback) { + function connect3(opts, callback) { if (callback === void 0) { return new Promise((resolve, reject) => { - connect.call(this, opts, (err, data) => { + connect3.call(this, opts, (err, data) => { return err ? reject(err) : resolve(data); }); }); @@ -57059,7 +57066,7 @@ var require_api_connect = __commonJS({ queueMicrotask(() => callback(err, { opaque })); } } - module2.exports = connect; + module2.exports = connect3; } }); @@ -57332,12 +57339,12 @@ var require_mock_utils = __commonJS({ const responseHeaders = generateKeyValues(headers); const responseTrailers = generateKeyValues(trailers); handler.abort = nop; - handler.onHeaders(statusCode, responseHeaders, resume, getStatusText(statusCode)); + handler.onHeaders(statusCode, responseHeaders, resume2, getStatusText(statusCode)); handler.onData(Buffer.from(responseData)); handler.onComplete(responseTrailers); deleteMockDispatch(mockDispatches, key); } - function resume() { + function resume2() { } return true; } @@ -57745,7 +57752,7 @@ var require_mock_agent = __commonJS({ "node_modules/undici/lib/mock/mock-agent.js"(exports2, module2) { "use strict"; var { kClients } = require_symbols(); - var Agent4 = require_agent2(); + var Agent6 = require_agent2(); var { kAgent, kMockAgentSet, @@ -57780,7 +57787,7 @@ var require_mock_agent = __commonJS({ if (opts && opts.agent && typeof opts.agent.dispatch !== "function") { throw new InvalidArgumentError("Argument opts.agent must implement Agent"); } - const agent = opts && opts.agent ? opts.agent : new Agent4(opts); + const agent = opts && opts.agent ? opts.agent : new Agent6(opts); this[kAgent] = agent; this[kClients] = agent[kClients]; this[kOptions] = buildMockOptions(opts); @@ -57884,8 +57891,8 @@ var require_proxy_agent = __commonJS({ "node_modules/undici/lib/proxy-agent.js"(exports2, module2) { "use strict"; var { kProxy, kClose, kDestroy, kInterceptors } = require_symbols(); - var { URL: URL2 } = require("url"); - var Agent4 = require_agent2(); + var { URL: URL3 } = require("url"); + var Agent6 = require_agent2(); var Pool = require_pool(); var DispatcherBase = require_dispatcher_base(); var { InvalidArgumentError, RequestAbortedError } = require_errors3(); @@ -57918,7 +57925,7 @@ var require_proxy_agent = __commonJS({ constructor(opts) { super(opts); this[kProxy] = buildProxyOptions(opts); - this[kAgent] = new Agent4(opts); + this[kAgent] = new Agent6(opts); this[kInterceptors] = opts.interceptors && opts.interceptors.ProxyAgent && Array.isArray(opts.interceptors.ProxyAgent) ? opts.interceptors.ProxyAgent : []; if (typeof opts === "string") { opts = { uri: opts }; @@ -57933,7 +57940,7 @@ var require_proxy_agent = __commonJS({ this[kRequestTls] = opts.requestTls; this[kProxyTls] = opts.proxyTls; this[kProxyHeaders] = opts.headers || {}; - const resolvedUrl = new URL2(opts.uri); + const resolvedUrl = new URL3(opts.uri); const { origin: origin2, port, host, username, password } = resolvedUrl; if (opts.auth && opts.token) { throw new InvalidArgumentError("opts.auth cannot be used in combination with opts.token"); @@ -57944,10 +57951,10 @@ var require_proxy_agent = __commonJS({ } else if (username && password) { this[kProxyHeaders]["proxy-authorization"] = `Basic ${Buffer.from(`${decodeURIComponent(username)}:${decodeURIComponent(password)}`).toString("base64")}`; } - const connect = buildConnector({ ...opts.proxyTls }); + const connect3 = buildConnector({ ...opts.proxyTls }); this[kConnectEndpoint] = buildConnector({ ...opts.requestTls }); - this[kClient] = clientFactory(resolvedUrl, { connect }); - this[kAgent] = new Agent4({ + this[kClient] = clientFactory(resolvedUrl, { connect: connect3 }); + this[kAgent] = new Agent6({ ...opts, connect: async (opts2, callback) => { let requestedHost = opts2.host; @@ -57988,7 +57995,7 @@ var require_proxy_agent = __commonJS({ }); } dispatch(opts, handler) { - const { host } = new URL2(opts.origin); + const { host } = new URL3(opts.origin); const headers = buildHeaders(opts.headers); throwIfProxyAuthIsSent(headers); return this[kAgent].dispatch( @@ -58034,7 +58041,7 @@ var require_proxy_agent = __commonJS({ // node_modules/undici/lib/handler/RetryHandler.js var require_RetryHandler = __commonJS({ "node_modules/undici/lib/handler/RetryHandler.js"(exports2, module2) { - var assert = require("assert"); + var assert2 = require("assert"); var { kRetryHandlerDefaultRetry } = require_symbols(); var { RequestRetryError } = require_errors3(); var { isDisturbed, parseHeaders, parseRangeHeader } = require_util2(); @@ -58162,7 +58169,7 @@ var require_RetryHandler = __commonJS({ state2.currentTimeout = retryTimeout; setTimeout(() => cb(null), retryTimeout); } - onHeaders(statusCode, rawHeaders, resume, statusMessage) { + onHeaders(statusCode, rawHeaders, resume2, statusMessage) { const headers = parseHeaders(rawHeaders); this.retryCount += 1; if (statusCode >= 300) { @@ -58199,9 +58206,9 @@ var require_RetryHandler = __commonJS({ return false; } const { start, size, end = size } = contentRange; - assert(this.start === start, "content-range mismatch"); - assert(this.end == null || this.end === end, "content-range mismatch"); - this.resume = resume; + assert2(this.start === start, "content-range mismatch"); + assert2(this.end == null || this.end === end, "content-range mismatch"); + this.resume = resume2; return true; } if (this.end == null) { @@ -58211,17 +58218,17 @@ var require_RetryHandler = __commonJS({ return this.handler.onHeaders( statusCode, rawHeaders, - resume, + resume2, statusMessage ); } const { start, size, end = size } = range; - assert( + assert2( start != null && Number.isFinite(start) && this.start !== start, "content-range mismatch" ); - assert(Number.isFinite(start)); - assert( + assert2(Number.isFinite(start)); + assert2( end != null && Number.isFinite(end) && this.end !== end, "invalid content-length" ); @@ -58232,17 +58239,17 @@ var require_RetryHandler = __commonJS({ const contentLength = headers["content-length"]; this.end = contentLength != null ? Number(contentLength) : null; } - assert(Number.isFinite(this.start)); - assert( + assert2(Number.isFinite(this.start)); + assert2( this.end == null || Number.isFinite(this.end), "invalid content-length" ); - this.resume = resume; + this.resume = resume2; this.etag = headers.etag != null ? headers.etag : null; return this.handler.onHeaders( statusCode, rawHeaders, - resume, + resume2, statusMessage ); } @@ -58304,9 +58311,9 @@ var require_global2 = __commonJS({ "use strict"; var globalDispatcher = Symbol.for("undici.globalDispatcher.1"); var { InvalidArgumentError } = require_errors3(); - var Agent4 = require_agent2(); + var Agent6 = require_agent2(); if (getGlobalDispatcher() === void 0) { - setGlobalDispatcher2(new Agent4()); + setGlobalDispatcher2(new Agent6()); } function setGlobalDispatcher2(agent) { if (!agent || typeof agent.dispatch !== "function") { @@ -58376,7 +58383,7 @@ var require_headers = __commonJS({ } = require_util3(); var util4 = require("util"); var { webidl } = require_webidl(); - var assert = require("assert"); + var assert2 = require("assert"); var kHeadersMap = Symbol("headers map"); var kHeadersSortedMap = Symbol("headers map sorted"); function isHTTPWhiteSpaceCharCode(code) { @@ -58634,7 +58641,7 @@ var require_headers = __commonJS({ headers.push([name, cookies[j4]]); } } else { - assert(value !== null); + assert2(value !== null); headers.push([name, value]); } } @@ -58780,7 +58787,7 @@ var require_response = __commonJS({ var { getGlobalOrigin } = require_global(); var { URLSerializer } = require_dataURL(); var { kHeadersList, kConstruct } = require_symbols(); - var assert = require("assert"); + var assert2 = require("assert"); var { types } = require("util"); var ReadableStream7 = globalThis.ReadableStream || require("stream/web").ReadableStream; var textEncoder2 = new TextEncoder("utf-8"); @@ -58996,7 +59003,7 @@ var require_response = __commonJS({ return p4 in state2 ? state2[p4] : target[p4]; }, set(target, p4, value) { - assert(!(p4 in state2)); + assert2(!(p4 in state2)); target[p4] = value; return true; } @@ -59030,11 +59037,11 @@ var require_response = __commonJS({ body: null }); } else { - assert(false); + assert2(false); } } function makeAppropriateNetworkError(fetchParams, err = null) { - assert(isCancelled(fetchParams)); + assert2(isCancelled(fetchParams)); return isAborted(fetchParams) ? makeNetworkError(Object.assign(new DOMException3("The operation was aborted.", "AbortError"), { cause: err })) : makeNetworkError(Object.assign(new DOMException3("Request was cancelled."), { cause: err })); } function initializeResponse(response, init, body) { @@ -59162,7 +59169,7 @@ var require_request2 = __commonJS({ var { getGlobalOrigin } = require_global(); var { URLSerializer } = require_dataURL(); var { kHeadersList, kConstruct } = require_symbols(); - var assert = require("assert"); + var assert2 = require("assert"); var { getMaxListeners, setMaxListeners, getEventListeners, defaultMaxListeners } = require("events"); var TransformStream3 = globalThis.TransformStream; var kAbortController = Symbol("abortController"); @@ -59206,7 +59213,7 @@ var require_request2 = __commonJS({ request3 = makeRequest2({ urlList: [parsedURL] }); fallbackMode = "cors"; } else { - assert(input instanceof _Request); + assert2(input instanceof _Request); request3 = input[kState]; signal = input[kSignal]; } @@ -59815,7 +59822,7 @@ var require_fetch = __commonJS({ urlHasHttpsScheme } = require_util3(); var { kState, kHeaders, kGuard, kRealm } = require_symbols2(); - var assert = require("assert"); + var assert2 = require("assert"); var { safelyExtractBody } = require_body(); var { redirectStatusSet, @@ -59895,7 +59902,7 @@ var require_fetch = __commonJS({ requestObject.signal, () => { locallyAborted = true; - assert(controller != null); + assert2(controller != null); controller.abort(requestObject.signal.reason); abortFetch(p4, request3, responseObject, requestObject.signal.reason); } @@ -60028,7 +60035,7 @@ var require_fetch = __commonJS({ taskDestination, crossOriginIsolatedCapability }; - assert(!request3.body || request3.body.stream); + assert2(!request3.body || request3.body.stream); if (request3.window === "client") { request3.window = request3.client?.globalObject?.constructor?.name === "Window" ? request3.client : "no-window"; } @@ -60121,7 +60128,7 @@ var require_fetch = __commonJS({ } else if (request3.responseTainting === "opaque") { response = filterResponse(response, "opaque"); } else { - assert(false); + assert2(false); } } let internalResponse = response.status === 0 ? response : response.internalResponse; @@ -60313,7 +60320,7 @@ var require_fetch = __commonJS({ } else if (request3.redirect === "follow") { response = await httpRedirectFetch(fetchParams, response); } else { - assert(false); + assert2(false); } } response.timingInfo = timingInfo; @@ -60366,7 +60373,7 @@ var require_fetch = __commonJS({ request3.headersList.delete("host"); } if (request3.body != null) { - assert(request3.body.source != null); + assert2(request3.body.source != null); request3.body = safelyExtractBody(request3.body.source)[0]; } const timingInfo = fetchParams.timingInfo; @@ -60499,7 +60506,7 @@ var require_fetch = __commonJS({ return response; } async function httpNetworkFetch(fetchParams, includeCredentials = false, forceNewConnection = false) { - assert(!fetchParams.controller.connection || fetchParams.controller.connection.destroyed); + assert2(!fetchParams.controller.connection || fetchParams.controller.connection.destroyed); fetchParams.controller.connection = { abort: null, destroyed: false, @@ -60688,7 +60695,7 @@ var require_fetch = __commonJS({ this.abort = connection.abort = abort; } }, - onHeaders(status, headersList, resume, statusText) { + onHeaders(status, headersList, resume2, statusText) { if (status < 200) { return; } @@ -60718,7 +60725,7 @@ var require_fetch = __commonJS({ headers[kHeadersList].append(key, val); } } - this.body = new Readable5({ read: resume }); + this.body = new Readable5({ read: resume2 }); const decoders = []; const willFollow = request3.redirect === "follow" && location && redirectStatusSet.has(status); if (request3.method !== "HEAD" && request3.method !== "CONNECT" && !nullBodyStatus.includes(status) && !willFollow) { @@ -61634,7 +61641,7 @@ var require_symbols4 = __commonJS({ var require_util6 = __commonJS({ "node_modules/undici/lib/cache/util.js"(exports2, module2) { "use strict"; - var assert = require("assert"); + var assert2 = require("assert"); var { URLSerializer } = require_dataURL(); var { isValidHeaderName: isValidHeaderName2 } = require_util3(); function urlEquals(A5, B3, excludeFragment = false) { @@ -61643,7 +61650,7 @@ var require_util6 = __commonJS({ return serializedA === serializedB; } function fieldValues(header) { - assert(header !== null); + assert2(header !== null); const values = []; for (let value of header.split(",")) { value = value.trim(); @@ -61677,7 +61684,7 @@ var require_cache = __commonJS({ var { kState, kHeaders, kGuard, kRealm } = require_symbols2(); var { fetching } = require_fetch(); var { urlIsHttpHttpsScheme, createDeferredPromise, readAllBytes } = require_util3(); - var assert = require("assert"); + var assert2 = require("assert"); var { getGlobalDispatcher } = require_global2(); var Cache = class _Cache { /** @@ -61938,7 +61945,7 @@ var require_cache = __commonJS({ return false; } } else { - assert(typeof request3 === "string"); + assert2(typeof request3 === "string"); r3 = new Request6(request3)[kState]; } const operations = []; @@ -62047,7 +62054,7 @@ var require_cache = __commonJS({ } for (const requestResponse of requestResponses) { const idx = cache.indexOf(requestResponse); - assert(idx !== -1); + assert2(idx !== -1); cache.splice(idx, 1); } } else if (operation.type === "put") { @@ -62079,7 +62086,7 @@ var require_cache = __commonJS({ requestResponses = this.#queryCache(operation.request); for (const requestResponse of requestResponses) { const idx = cache.indexOf(requestResponse); - assert(idx !== -1); + assert2(idx !== -1); cache.splice(idx, 1); } cache.push([operation.request, operation.response]); @@ -62466,7 +62473,7 @@ var require_parse3 = __commonJS({ var { maxNameValuePairSize, maxAttributeValueSize } = require_constants5(); var { isCTLExcludingHtab } = require_util7(); var { collectASequenceOfCodePointsFast } = require_dataURL(); - var assert = require("assert"); + var assert2 = require("assert"); function parseSetCookie(header) { if (isCTLExcludingHtab(header)) { return null; @@ -62508,7 +62515,7 @@ var require_parse3 = __commonJS({ if (unparsedAttributes.length === 0) { return cookieAttributeList; } - assert(unparsedAttributes[0] === ";"); + assert2(unparsedAttributes[0] === ";"); unparsedAttributes = unparsedAttributes.slice(1); let cookieAv = ""; if (unparsedAttributes.includes(";")) { @@ -63976,7 +63983,7 @@ var require_undici = __commonJS({ var errors = require_errors3(); var Pool = require_pool(); var BalancedPool = require_balanced_pool(); - var Agent4 = require_agent2(); + var Agent6 = require_agent2(); var util4 = require_util2(); var { InvalidArgumentError } = errors; var api = require_api(); @@ -64003,7 +64010,7 @@ var require_undici = __commonJS({ module2.exports.Client = Client; module2.exports.Pool = Pool; module2.exports.BalancedPool = BalancedPool; - module2.exports.Agent = Agent4; + module2.exports.Agent = Agent6; module2.exports.ProxyAgent = ProxyAgent2; module2.exports.RetryHandler = RetryHandler; module2.exports.DecoratorHandler = DecoratorHandler; @@ -65315,9 +65322,10 @@ var package_default = { deploy: "npm publish --tag latest", "deploy:build": "npm run build:push && git push --tags && npm run deploy", "deploy:patch": "npm version patch && npm run deploy:build", - lint: "eslint src --ext ts && tsc --noEmit", - format: "prettier --write src", - "format:check": "prettier --check src", + lint: "biome check . --diagnostic-level=error && tsc --noEmit", + typecheck: "tsc --noEmit", + format: 'prettier --write "src/**/*.{ts,js,json,md}" "test/**/*.{ts,js,json,md}" ".github/**/*.{yml,yaml}" "*.{js,json,ts,md,yml,yaml}"', + "format:check": 'prettier --check "src/**/*.{ts,js,json,md}" "test/**/*.{ts,js,json,md}" ".github/**/*.{yml,yaml}" "*.{js,json,ts,md,yml,yaml}"', test: "node --no-warnings --experimental-vm-modules $( [ -f ./node_modules/.bin/jest ] && echo ./node_modules/.bin/jest || which jest ) test/unit", "test:all": "npm run test:unit:docker && npm run test:e2e:docker", "test:docker-build": "docker build -t oco-test -f test/Dockerfile .", @@ -65327,7 +65335,7 @@ var package_default = { "test:e2e:smoke": "npm run build && npm run test:e2e:smoke:run", "test:e2e:smoke:run": "OCO_TEST_SKIP_VERSION_CHECK=true jest test/e2e/smoke.test.ts", "test:e2e:core": "npm run build && npm run test:e2e:core:run", - "test:e2e:core:run": "OCO_TEST_SKIP_VERSION_CHECK=true jest test/e2e/cliBehavior.test.ts test/e2e/gitPush.test.ts test/e2e/oneFile.test.ts test/e2e/noChanges.test.ts", + "test:e2e:core:run": "OCO_TEST_SKIP_VERSION_CHECK=true jest test/e2e/cliBehavior.test.ts test/e2e/geminiBehavior.test.ts test/e2e/gitPush.test.ts test/e2e/oneFile.test.ts test/e2e/noChanges.test.ts", "test:e2e:setup": "npm run test:e2e:prompt-module:setup", "test:e2e:prompt-module:setup": "sh test/e2e/setup.sh", "test:e2e:prompt-module": "npm run build && npm run test:e2e:prompt-module:run", @@ -65336,17 +65344,15 @@ var package_default = { "mlx:start": "OCO_AI_PROVIDER='mlx' node ./out/cli.cjs" }, devDependencies: { + "@biomejs/biome": "2.4.11", "@commitlint/types": "^17.4.4", "@types/ini": "^1.3.31", "@types/inquirer": "^9.0.3", "@types/jest": "^29.5.12", "@types/node": "^16.18.14", - "@typescript-eslint/eslint-plugin": "^8.29.0", - "@typescript-eslint/parser": "^8.29.0", "cli-testing-library": "^2.0.2", dotenv: "^16.0.3", esbuild: "^0.25.5", - eslint: "^9.24.0", jest: "^29.7.0", prettier: "^2.8.4", rimraf: "^6.0.1", @@ -70700,8 +70706,321 @@ var { AnthropicError: AnthropicError2, APIError: APIError2, APIConnectionError: })(Anthropic || (Anthropic = {})); var sdk_default = Anthropic; -// src/engine/anthropic.ts -var import_https_proxy_agent = __toESM(require_dist2(), 1); +// node_modules/https-proxy-agent/dist/index.js +var net2 = __toESM(require("net"), 1); +var tls = __toESM(require("tls"), 1); +var import_assert = __toESM(require("assert"), 1); +var import_debug2 = __toESM(require_src2(), 1); + +// node_modules/https-proxy-agent/node_modules/agent-base/dist/index.js +var net = __toESM(require("net"), 1); +var http = __toESM(require("http"), 1); +var import_https = require("https"); +var INTERNAL = Symbol("AgentBaseInternalState"); +var Agent2 = class extends http.Agent { + constructor(opts) { + super(opts); + this[INTERNAL] = {}; + } + /** + * Determine whether this is an `http` or `https` request. + */ + isSecureEndpoint(options) { + if (options) { + if (typeof options.secureEndpoint === "boolean") { + return options.secureEndpoint; + } + if (typeof options.protocol === "string") { + return options.protocol === "https:"; + } + } + const { stack } = new Error(); + if (typeof stack !== "string") + return false; + return stack.split("\n").some((l3) => l3.indexOf("(https.js:") !== -1 || l3.indexOf("node:https:") !== -1); + } + // In order to support async signatures in `connect()` and Node's native + // connection pooling in `http.Agent`, the array of sockets for each origin + // has to be updated synchronously. This is so the length of the array is + // accurate when `addRequest()` is next called. We achieve this by creating a + // fake socket and adding it to `sockets[origin]` and incrementing + // `totalSocketCount`. + incrementSockets(name) { + if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) { + return null; + } + if (!this.sockets[name]) { + this.sockets[name] = []; + } + const fakeSocket = new net.Socket({ writable: false }); + this.sockets[name].push(fakeSocket); + this.totalSocketCount++; + return fakeSocket; + } + decrementSockets(name, socket) { + if (!this.sockets[name] || socket === null) { + return; + } + const sockets = this.sockets[name]; + const index = sockets.indexOf(socket); + if (index !== -1) { + sockets.splice(index, 1); + this.totalSocketCount--; + if (sockets.length === 0) { + delete this.sockets[name]; + } + } + } + // In order to properly update the socket pool, we need to call `getName()` on + // the core `https.Agent` if it is a secureEndpoint. + getName(options) { + const secureEndpoint = this.isSecureEndpoint(options); + if (secureEndpoint) { + return import_https.Agent.prototype.getName.call(this, options); + } + return super.getName(options); + } + createSocket(req, options, cb) { + const connectOpts = { + ...options, + secureEndpoint: this.isSecureEndpoint(options) + }; + const name = this.getName(connectOpts); + const fakeSocket = this.incrementSockets(name); + Promise.resolve().then(() => this.connect(req, connectOpts)).then((socket) => { + this.decrementSockets(name, fakeSocket); + if (socket instanceof http.Agent) { + try { + return socket.addRequest(req, connectOpts); + } catch (err) { + return cb(err); + } + } + this[INTERNAL].currentSocket = socket; + super.createSocket(req, options, cb); + }, (err) => { + this.decrementSockets(name, fakeSocket); + cb(err); + }); + } + createConnection() { + const socket = this[INTERNAL].currentSocket; + this[INTERNAL].currentSocket = void 0; + if (!socket) { + throw new Error("No socket was returned in the `connect()` function"); + } + return socket; + } + get defaultPort() { + return this[INTERNAL].defaultPort ?? (this.protocol === "https:" ? 443 : 80); + } + set defaultPort(v5) { + if (this[INTERNAL]) { + this[INTERNAL].defaultPort = v5; + } + } + get protocol() { + return this[INTERNAL].protocol ?? (this.isSecureEndpoint() ? "https:" : "http:"); + } + set protocol(v5) { + if (this[INTERNAL]) { + this[INTERNAL].protocol = v5; + } + } +}; + +// node_modules/https-proxy-agent/dist/index.js +var import_url = require("url"); + +// node_modules/https-proxy-agent/dist/parse-proxy-response.js +var import_debug = __toESM(require_src2(), 1); +var debug2 = (0, import_debug.default)("https-proxy-agent:parse-proxy-response"); +function parseProxyResponse(socket) { + return new Promise((resolve, reject) => { + let buffersLength = 0; + const buffers = []; + function read() { + const b7 = socket.read(); + if (b7) + ondata(b7); + else + socket.once("readable", read); + } + function cleanup() { + socket.removeListener("end", onend); + socket.removeListener("error", onerror); + socket.removeListener("readable", read); + } + function onend() { + cleanup(); + debug2("onend"); + reject(new Error("Proxy connection ended before receiving CONNECT response")); + } + function onerror(err) { + cleanup(); + debug2("onerror %o", err); + reject(err); + } + function ondata(b7) { + buffers.push(b7); + buffersLength += b7.length; + const buffered = Buffer.concat(buffers, buffersLength); + const endOfHeaders = buffered.indexOf("\r\n\r\n"); + if (endOfHeaders === -1) { + debug2("have not received end of HTTP headers yet..."); + read(); + return; + } + const headerParts = buffered.slice(0, endOfHeaders).toString("ascii").split("\r\n"); + const firstLine = headerParts.shift(); + if (!firstLine) { + socket.destroy(); + return reject(new Error("No header received from proxy CONNECT response")); + } + const firstLineParts = firstLine.split(" "); + const statusCode = +firstLineParts[1]; + const statusText = firstLineParts.slice(2).join(" "); + const headers = {}; + for (const header of headerParts) { + if (!header) + continue; + const firstColon = header.indexOf(":"); + if (firstColon === -1) { + socket.destroy(); + return reject(new Error(`Invalid header from proxy CONNECT response: "${header}"`)); + } + const key = header.slice(0, firstColon).toLowerCase(); + const value = header.slice(firstColon + 1).trimStart(); + const current = headers[key]; + if (typeof current === "string") { + headers[key] = [current, value]; + } else if (Array.isArray(current)) { + current.push(value); + } else { + headers[key] = value; + } + } + debug2("got proxy server response: %o %o", firstLine, headers); + cleanup(); + resolve({ + connect: { + statusCode, + statusText, + headers + }, + buffered + }); + } + socket.on("error", onerror); + socket.on("end", onend); + read(); + }); +} + +// node_modules/https-proxy-agent/dist/index.js +var debug3 = (0, import_debug2.default)("https-proxy-agent"); +var setServernameFromNonIpHost = (options) => { + if (options.servername === void 0 && options.host && !net2.isIP(options.host)) { + return { + ...options, + servername: options.host + }; + } + return options; +}; +var HttpsProxyAgent = class extends Agent2 { + constructor(proxy, opts) { + super(opts); + this.options = { path: void 0 }; + this.proxy = typeof proxy === "string" ? new import_url.URL(proxy) : proxy; + this.proxyHeaders = opts?.headers ?? {}; + debug3("Creating new HttpsProxyAgent instance: %o", this.proxy.href); + const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, ""); + const port = this.proxy.port ? parseInt(this.proxy.port, 10) : this.proxy.protocol === "https:" ? 443 : 80; + this.connectOpts = { + // Attempt to negotiate http/1.1 for proxy servers that support http/2 + ALPNProtocols: ["http/1.1"], + ...opts ? omit(opts, "headers") : null, + host, + port + }; + } + /** + * Called when the node-core HTTP client library is creating a + * new HTTP request. + */ + async connect(req, opts) { + const { proxy } = this; + if (!opts.host) { + throw new TypeError('No "host" provided'); + } + let socket; + if (proxy.protocol === "https:") { + debug3("Creating `tls.Socket`: %o", this.connectOpts); + socket = tls.connect(setServernameFromNonIpHost(this.connectOpts)); + } else { + debug3("Creating `net.Socket`: %o", this.connectOpts); + socket = net2.connect(this.connectOpts); + } + const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders }; + const host = net2.isIPv6(opts.host) ? `[${opts.host}]` : opts.host; + let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r +`; + if (proxy.username || proxy.password) { + const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`; + headers["Proxy-Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`; + } + headers.Host = `${host}:${opts.port}`; + if (!headers["Proxy-Connection"]) { + headers["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close"; + } + for (const name of Object.keys(headers)) { + payload += `${name}: ${headers[name]}\r +`; + } + const proxyResponsePromise = parseProxyResponse(socket); + socket.write(`${payload}\r +`); + const { connect: connect3, buffered } = await proxyResponsePromise; + req.emit("proxyConnect", connect3); + this.emit("proxyConnect", connect3, req); + if (connect3.statusCode === 200) { + req.once("socket", resume); + if (opts.secureEndpoint) { + debug3("Upgrading socket connection to TLS"); + return tls.connect({ + ...omit(setServernameFromNonIpHost(opts), "host", "path", "port"), + socket + }); + } + return socket; + } + socket.destroy(); + const fakeSocket = new net2.Socket({ writable: false }); + fakeSocket.readable = true; + req.once("socket", (s2) => { + debug3("Replaying proxy buffer for failed request"); + (0, import_assert.default)(s2.listenerCount("data") > 0); + s2.push(buffered); + s2.push(null); + }); + return fakeSocket; + } +}; +HttpsProxyAgent.protocols = ["http", "https"]; +function resume(socket) { + socket.resume(); +} +function omit(obj, ...keys) { + const ret = {}; + let key; + for (key in obj) { + if (!keys.includes(key)) { + ret[key] = obj[key]; + } + } + return ret; +} // node_modules/axios/lib/helpers/bind.js function bind(fn, thisArg) { @@ -71405,8 +71724,8 @@ var transitional_default = { var import_crypto = __toESM(require("crypto"), 1); // node_modules/axios/lib/platform/node/classes/URLSearchParams.js -var import_url = __toESM(require("url"), 1); -var URLSearchParams_default = import_url.default.URLSearchParams; +var import_url2 = __toESM(require("url"), 1); +var URLSearchParams_default = import_url2.default.URLSearchParams; // node_modules/axios/lib/platform/node/index.js var ALPHA = "abcdefghijklmnopqrstuvwxyz"; @@ -71977,7 +72296,7 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) { // node_modules/axios/lib/adapters/http.js var import_proxy_from_env = __toESM(require_proxy_from_env(), 1); var import_http = __toESM(require("http"), 1); -var import_https = __toESM(require("https"), 1); +var import_https2 = __toESM(require("https"), 1); var import_util4 = __toESM(require("util"), 1); var import_follow_redirects = __toESM(require_follow_redirects(), 1); var import_zlib = __toESM(require("zlib"), 1); @@ -72690,7 +73009,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config8) { if (config8.transport) { transport = config8.transport; } else if (config8.maxRedirects === 0) { - transport = isHttpsRequest ? import_https.default : import_http.default; + transport = isHttpsRequest ? import_https2.default : import_http.default; } else { if (config8.maxRedirects) { options.maxRedirects = config8.maxRedirects; @@ -74513,7 +74832,7 @@ var AnthropicEngine = class { const clientOptions = { apiKey: this.config.apiKey }; const proxy = config8.proxy; if (proxy) { - clientOptions.httpAgent = new import_https_proxy_agent.HttpsProxyAgent(proxy); + clientOptions.httpAgent = new HttpsProxyAgent(proxy); } this.client = new sdk_default(clientOptions); } @@ -74667,11 +74986,11 @@ function __asyncGenerator(thisArg, _arguments, generator) { function verb(n2) { if (g5[n2]) i3[n2] = function(v5) { return new Promise(function(a4, b7) { - q6.push([n2, v5, a4, b7]) > 1 || resume(n2, v5); + q6.push([n2, v5, a4, b7]) > 1 || resume2(n2, v5); }); }; } - function resume(n2, v5) { + function resume2(n2, v5) { try { step(g5[n2](v5)); } catch (e3) { @@ -74682,13 +75001,13 @@ function __asyncGenerator(thisArg, _arguments, generator) { r3.value instanceof __await ? Promise.resolve(r3.value.v).then(fulfill, reject) : settle2(q6[0][2], r3); } function fulfill(value) { - resume("next", value); + resume2("next", value); } function reject(value) { - resume("throw", value); + resume2("throw", value); } function settle2(f4, v5) { - if (f4(v5), q6.shift(), q6.length) resume(q6[0][0], q6[0][1]); + if (f4(v5), q6.shift(), q6.length) resume2(q6[0][0], q6[0][1]); } } function __asyncValues(o3) { @@ -74956,14 +75275,14 @@ function disable() { return result; } function createDebugger(namespace) { - const newDebugger = Object.assign(debug3, { + const newDebugger = Object.assign(debug5, { enabled: enabled(namespace), destroy, log: debugObj.log, namespace, extend: extend2 }); - function debug3(...args) { + function debug5(...args) { if (!newDebugger.enabled) { return; } @@ -76324,7 +76643,7 @@ function createPipelineFromOptions(options) { } // node_modules/@azure/core-rest-pipeline/dist/esm/nodeHttpClient.js -var http2 = __toESM(require("node:http"), 1); +var http3 = __toESM(require("node:http"), 1); var https2 = __toESM(require("node:https"), 1); var zlib2 = __toESM(require("node:zlib"), 1); var import_node_stream3 = require("node:stream"); @@ -76481,7 +76800,7 @@ var NodeHttpClient = class { headers: request3.headers.toJSON({ preserveCase: true }) }; return new Promise((resolve, reject) => { - const req = isInsecure ? http2.request(options, resolve) : https2.request(options, resolve); + const req = isInsecure ? http3.request(options, resolve) : https2.request(options, resolve); req.once("error", (err) => { var _a6; reject(new RestError(err.message, { code: (_a6 = err.code) !== null && _a6 !== void 0 ? _a6 : RestError.REQUEST_SEND_ERROR, request: request3 })); @@ -76512,10 +76831,10 @@ var NodeHttpClient = class { const disableKeepAlive = request3.disableKeepAlive; if (isInsecure) { if (disableKeepAlive) { - return http2.globalAgent; + return http3.globalAgent; } if (!this.cachedHttpAgent) { - this.cachedHttpAgent = new http2.Agent({ keepAlive: true }); + this.cachedHttpAgent = new http3.Agent({ keepAlive: true }); } return this.cachedHttpAgent; } else { @@ -78387,6 +78706,27 @@ var FlowiseEngine = class { }; // node_modules/@google/generative-ai/dist/index.mjs +var SchemaType; +(function(SchemaType2) { + SchemaType2["STRING"] = "string"; + SchemaType2["NUMBER"] = "number"; + SchemaType2["INTEGER"] = "integer"; + SchemaType2["BOOLEAN"] = "boolean"; + SchemaType2["ARRAY"] = "array"; + SchemaType2["OBJECT"] = "object"; +})(SchemaType || (SchemaType = {})); +var ExecutableCodeLanguage; +(function(ExecutableCodeLanguage2) { + ExecutableCodeLanguage2["LANGUAGE_UNSPECIFIED"] = "language_unspecified"; + ExecutableCodeLanguage2["PYTHON"] = "python"; +})(ExecutableCodeLanguage || (ExecutableCodeLanguage = {})); +var Outcome; +(function(Outcome2) { + Outcome2["OUTCOME_UNSPECIFIED"] = "outcome_unspecified"; + Outcome2["OUTCOME_OK"] = "outcome_ok"; + Outcome2["OUTCOME_FAILED"] = "outcome_failed"; + Outcome2["OUTCOME_DEADLINE_EXCEEDED"] = "outcome_deadline_exceeded"; +})(Outcome || (Outcome = {})); var POSSIBLE_ROLES = ["user", "model", "function", "system"]; var HarmCategory; (function(HarmCategory2) { @@ -78395,6 +78735,7 @@ var HarmCategory; HarmCategory2["HARM_CATEGORY_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_SEXUALLY_EXPLICIT"; HarmCategory2["HARM_CATEGORY_HARASSMENT"] = "HARM_CATEGORY_HARASSMENT"; HarmCategory2["HARM_CATEGORY_DANGEROUS_CONTENT"] = "HARM_CATEGORY_DANGEROUS_CONTENT"; + HarmCategory2["HARM_CATEGORY_CIVIC_INTEGRITY"] = "HARM_CATEGORY_CIVIC_INTEGRITY"; })(HarmCategory || (HarmCategory = {})); var HarmBlockThreshold; (function(HarmBlockThreshold2) { @@ -78425,6 +78766,11 @@ var FinishReason; FinishReason2["MAX_TOKENS"] = "MAX_TOKENS"; FinishReason2["SAFETY"] = "SAFETY"; FinishReason2["RECITATION"] = "RECITATION"; + FinishReason2["LANGUAGE"] = "LANGUAGE"; + FinishReason2["BLOCKLIST"] = "BLOCKLIST"; + FinishReason2["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT"; + FinishReason2["SPII"] = "SPII"; + FinishReason2["MALFORMED_FUNCTION_CALL"] = "MALFORMED_FUNCTION_CALL"; FinishReason2["OTHER"] = "OTHER"; })(FinishReason || (FinishReason = {})); var TaskType; @@ -78443,15 +78789,11 @@ var FunctionCallingMode; FunctionCallingMode2["ANY"] = "ANY"; FunctionCallingMode2["NONE"] = "NONE"; })(FunctionCallingMode || (FunctionCallingMode = {})); -var FunctionDeclarationSchemaType; -(function(FunctionDeclarationSchemaType2) { - FunctionDeclarationSchemaType2["STRING"] = "STRING"; - FunctionDeclarationSchemaType2["NUMBER"] = "NUMBER"; - FunctionDeclarationSchemaType2["INTEGER"] = "INTEGER"; - FunctionDeclarationSchemaType2["BOOLEAN"] = "BOOLEAN"; - FunctionDeclarationSchemaType2["ARRAY"] = "ARRAY"; - FunctionDeclarationSchemaType2["OBJECT"] = "OBJECT"; -})(FunctionDeclarationSchemaType || (FunctionDeclarationSchemaType = {})); +var DynamicRetrievalMode; +(function(DynamicRetrievalMode2) { + DynamicRetrievalMode2["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED"; + DynamicRetrievalMode2["MODE_DYNAMIC"] = "MODE_DYNAMIC"; +})(DynamicRetrievalMode || (DynamicRetrievalMode = {})); var GoogleGenerativeAIError = class extends Error { constructor(message) { super(`[GoogleGenerativeAI Error]: ${message}`); @@ -78473,9 +78815,11 @@ var GoogleGenerativeAIFetchError = class extends GoogleGenerativeAIError { }; var GoogleGenerativeAIRequestInputError = class extends GoogleGenerativeAIError { }; +var GoogleGenerativeAIAbortError = class extends GoogleGenerativeAIError { +}; var DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com"; var DEFAULT_API_VERSION = "v1beta"; -var PACKAGE_VERSION = "0.11.4"; +var PACKAGE_VERSION = "0.24.1"; var PACKAGE_LOG_HEADER = "genai-js"; var Task; (function(Task2) { @@ -78513,11 +78857,12 @@ function getClientHeaders(requestOptions) { return clientHeaders.join(" "); } async function getHeaders(url2) { + var _a5; const headers = new Headers(); headers.append("Content-Type", "application/json"); headers.append("x-goog-api-client", getClientHeaders(url2.requestOptions)); headers.append("x-goog-api-key", url2.apiKey); - let customHeaders = url2.requestOptions.customHeaders; + let customHeaders = (_a5 = url2.requestOptions) === null || _a5 === void 0 ? void 0 : _a5.customHeaders; if (customHeaders) { if (!(customHeaders instanceof Headers)) { try { @@ -78537,53 +78882,67 @@ async function getHeaders(url2) { } return headers; } -async function constructRequest(model, task, apiKey, stream4, body, requestOptions) { +async function constructModelRequest(model, task, apiKey, stream4, body, requestOptions) { const url2 = new RequestUrl(model, task, apiKey, stream4, requestOptions); return { url: url2.toString(), fetchOptions: Object.assign(Object.assign({}, buildFetchOptions(requestOptions)), { method: "POST", headers: await getHeaders(url2), body }) }; } -async function makeRequest(model, task, apiKey, stream4, body, requestOptions) { - return _makeRequestInternal(model, task, apiKey, stream4, body, requestOptions, fetch); +async function makeModelRequest(model, task, apiKey, stream4, body, requestOptions = {}, fetchFn = fetch) { + const { url: url2, fetchOptions } = await constructModelRequest(model, task, apiKey, stream4, body, requestOptions); + return makeRequest(url2, fetchOptions, fetchFn); } -async function _makeRequestInternal(model, task, apiKey, stream4, body, requestOptions, fetchFn = fetch) { - const url2 = new RequestUrl(model, task, apiKey, stream4, requestOptions); +async function makeRequest(url2, fetchOptions, fetchFn = fetch) { let response; try { - const request3 = await constructRequest(model, task, apiKey, stream4, body, requestOptions); - response = await fetchFn(request3.url, request3.fetchOptions); - if (!response.ok) { - let message = ""; - let errorDetails; - try { - const json = await response.json(); - message = json.error.message; - if (json.error.details) { - message += ` ${JSON.stringify(json.error.details)}`; - errorDetails = json.error.details; - } - } catch (e3) { - } - throw new GoogleGenerativeAIFetchError(`Error fetching from ${url2.toString()}: [${response.status} ${response.statusText}] ${message}`, response.status, response.statusText, errorDetails); - } + response = await fetchFn(url2, fetchOptions); } catch (e3) { - let err = e3; - if (!(e3 instanceof GoogleGenerativeAIFetchError || e3 instanceof GoogleGenerativeAIRequestInputError)) { - err = new GoogleGenerativeAIError(`Error fetching from ${url2.toString()}: ${e3.message}`); - err.stack = e3.stack; - } - throw err; + handleResponseError(e3, url2); + } + if (!response.ok) { + await handleResponseNotOk(response, url2); } return response; } +function handleResponseError(e3, url2) { + let err = e3; + if (err.name === "AbortError") { + err = new GoogleGenerativeAIAbortError(`Request aborted when fetching ${url2.toString()}: ${e3.message}`); + err.stack = e3.stack; + } else if (!(e3 instanceof GoogleGenerativeAIFetchError || e3 instanceof GoogleGenerativeAIRequestInputError)) { + err = new GoogleGenerativeAIError(`Error fetching from ${url2.toString()}: ${e3.message}`); + err.stack = e3.stack; + } + throw err; +} +async function handleResponseNotOk(response, url2) { + let message = ""; + let errorDetails; + try { + const json = await response.json(); + message = json.error.message; + if (json.error.details) { + message += ` ${JSON.stringify(json.error.details)}`; + errorDetails = json.error.details; + } + } catch (e3) { + } + throw new GoogleGenerativeAIFetchError(`Error fetching from ${url2.toString()}: [${response.status} ${response.statusText}] ${message}`, response.status, response.statusText, errorDetails); +} function buildFetchOptions(requestOptions) { const fetchOptions = {}; - if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeout) >= 0) { - const abortController = new AbortController(); - const signal = abortController.signal; - setTimeout(() => abortController.abort(), requestOptions.timeout); - fetchOptions.signal = signal; + if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.signal) !== void 0 || (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeout) >= 0) { + const controller = new AbortController(); + if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeout) >= 0) { + setTimeout(() => controller.abort(), requestOptions.timeout); + } + if (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.signal) { + requestOptions.signal.addEventListener("abort", () => { + controller.abort(); + }); + } + fetchOptions.signal = controller.signal; } return fetchOptions; } @@ -78641,6 +79000,12 @@ function getText(response) { if (part.text) { textStrings.push(part.text); } + if (part.executableCode) { + textStrings.push("\n```" + part.executableCode.language + "\n" + part.executableCode.code + "\n```\n"); + } + if (part.codeExecutionResult) { + textStrings.push("\n```\n" + part.codeExecutionResult.output + "\n```\n"); + } } } if (textStrings.length > 0) { @@ -78665,7 +79030,11 @@ function getFunctionCalls(response) { return void 0; } } -var badFinishReasons = [FinishReason.RECITATION, FinishReason.SAFETY]; +var badFinishReasons = [ + FinishReason.RECITATION, + FinishReason.SAFETY, + FinishReason.LANGUAGE +]; function hadBadFinishReason(candidate) { return !!candidate.finishReason && badFinishReasons.includes(candidate.finishReason); } @@ -78703,11 +79072,11 @@ function __asyncGenerator2(thisArg, _arguments, generator) { function verb(n2) { if (g5[n2]) i3[n2] = function(v5) { return new Promise(function(a4, b7) { - q6.push([n2, v5, a4, b7]) > 1 || resume(n2, v5); + q6.push([n2, v5, a4, b7]) > 1 || resume2(n2, v5); }); }; } - function resume(n2, v5) { + function resume2(n2, v5) { try { step(g5[n2](v5)); } catch (e3) { @@ -78718,13 +79087,13 @@ function __asyncGenerator2(thisArg, _arguments, generator) { r3.value instanceof __await2 ? Promise.resolve(r3.value.v).then(fulfill, reject) : settle2(q6[0][2], r3); } function fulfill(value) { - resume("next", value); + resume2("next", value); } function reject(value) { - resume("throw", value); + resume2("throw", value); } function settle2(f4, v5) { - if (f4(v5), q6.shift(), q6.length) resume(q6[0][0], q6[0][1]); + if (f4(v5), q6.shift(), q6.length) resume2(q6[0][0], q6[0][1]); } } var responseLineRE = /^data\: (.*)(?:\n\n|\r\r|\r\n\r\n)/; @@ -78791,6 +79160,15 @@ function getResponseStream(inputStream) { match = currentText.match(responseLineRE); } return pump(); + }).catch((e3) => { + let err = e3; + err.stack = e3.stack; + if (err.name === "AbortError") { + err = new GoogleGenerativeAIAbortError("Request aborted when reading from the stream"); + } else { + err = new GoogleGenerativeAIError("Error reading from the stream"); + } + throw err; }); } } @@ -78804,23 +79182,24 @@ function aggregateResponses(responses) { }; for (const response of responses) { if (response.candidates) { + let candidateIndex = 0; for (const candidate of response.candidates) { - const i3 = candidate.index; if (!aggregatedResponse.candidates) { aggregatedResponse.candidates = []; } - if (!aggregatedResponse.candidates[i3]) { - aggregatedResponse.candidates[i3] = { - index: candidate.index + if (!aggregatedResponse.candidates[candidateIndex]) { + aggregatedResponse.candidates[candidateIndex] = { + index: candidateIndex }; } - aggregatedResponse.candidates[i3].citationMetadata = candidate.citationMetadata; - aggregatedResponse.candidates[i3].finishReason = candidate.finishReason; - aggregatedResponse.candidates[i3].finishMessage = candidate.finishMessage; - aggregatedResponse.candidates[i3].safetyRatings = candidate.safetyRatings; + aggregatedResponse.candidates[candidateIndex].citationMetadata = candidate.citationMetadata; + aggregatedResponse.candidates[candidateIndex].groundingMetadata = candidate.groundingMetadata; + aggregatedResponse.candidates[candidateIndex].finishReason = candidate.finishReason; + aggregatedResponse.candidates[candidateIndex].finishMessage = candidate.finishMessage; + aggregatedResponse.candidates[candidateIndex].safetyRatings = candidate.safetyRatings; if (candidate.content && candidate.content.parts) { - if (!aggregatedResponse.candidates[i3].content) { - aggregatedResponse.candidates[i3].content = { + if (!aggregatedResponse.candidates[candidateIndex].content) { + aggregatedResponse.candidates[candidateIndex].content = { role: candidate.content.role || "user", parts: [] }; @@ -78833,19 +79212,29 @@ function aggregateResponses(responses) { if (part.functionCall) { newPart.functionCall = part.functionCall; } + if (part.executableCode) { + newPart.executableCode = part.executableCode; + } + if (part.codeExecutionResult) { + newPart.codeExecutionResult = part.codeExecutionResult; + } if (Object.keys(newPart).length === 0) { newPart.text = ""; } - aggregatedResponse.candidates[i3].content.parts.push(newPart); + aggregatedResponse.candidates[candidateIndex].content.parts.push(newPart); } } } + candidateIndex++; + } + if (response.usageMetadata) { + aggregatedResponse.usageMetadata = response.usageMetadata; } } return aggregatedResponse; } async function generateContentStream(apiKey, model, params, requestOptions) { - const response = await makeRequest( + const response = await makeModelRequest( model, Task.STREAM_GENERATE_CONTENT, apiKey, @@ -78857,7 +79246,7 @@ async function generateContentStream(apiKey, model, params, requestOptions) { return processStream(response); } async function generateContent(apiKey, model, params, requestOptions) { - const response = await makeRequest( + const response = await makeModelRequest( model, Task.GENERATE_CONTENT, apiKey, @@ -78927,6 +79316,32 @@ function assignRoleToPartsAndValidateSendMessageRequest(parts) { } return functionContent; } +function formatCountTokensInput(params, modelParams) { + var _a5; + let formattedGenerateContentRequest = { + model: modelParams === null || modelParams === void 0 ? void 0 : modelParams.model, + generationConfig: modelParams === null || modelParams === void 0 ? void 0 : modelParams.generationConfig, + safetySettings: modelParams === null || modelParams === void 0 ? void 0 : modelParams.safetySettings, + tools: modelParams === null || modelParams === void 0 ? void 0 : modelParams.tools, + toolConfig: modelParams === null || modelParams === void 0 ? void 0 : modelParams.toolConfig, + systemInstruction: modelParams === null || modelParams === void 0 ? void 0 : modelParams.systemInstruction, + cachedContent: (_a5 = modelParams === null || modelParams === void 0 ? void 0 : modelParams.cachedContent) === null || _a5 === void 0 ? void 0 : _a5.name, + contents: [] + }; + const containsGenerateContentRequest = params.generateContentRequest != null; + if (params.contents) { + if (containsGenerateContentRequest) { + throw new GoogleGenerativeAIRequestInputError("CountTokensRequest must have one of contents or generateContentRequest, not both."); + } + formattedGenerateContentRequest.contents = params.contents; + } else if (containsGenerateContentRequest) { + formattedGenerateContentRequest = Object.assign(Object.assign({}, formattedGenerateContentRequest), params.generateContentRequest); + } else { + const content = formatNewContent(params); + formattedGenerateContentRequest.contents = [content]; + } + return { generateContentRequest: formattedGenerateContentRequest }; +} function formatGenerateContentInput(params) { let formattedRequest; if (params.contents) { @@ -78951,12 +79366,14 @@ var VALID_PART_FIELDS = [ "text", "inlineData", "functionCall", - "functionResponse" + "functionResponse", + "executableCode", + "codeExecutionResult" ]; var VALID_PARTS_PER_ROLE = { user: ["text", "inlineData"], function: ["functionResponse"], - model: ["text", "functionCall"], + model: ["text", "functionCall", "executableCode", "codeExecutionResult"], // System instructions shouldn't be in history anyway. system: ["text"] }; @@ -78981,7 +79398,9 @@ function validateChatHistory(history) { inlineData: 0, functionCall: 0, functionResponse: 0, - fileData: 0 + fileData: 0, + executableCode: 0, + codeExecutionResult: 0 }; for (const part of parts) { for (const key of VALID_PART_FIELDS) { @@ -78999,12 +79418,34 @@ function validateChatHistory(history) { prevContent = true; } } +function isValidResponse(response) { + var _a5; + if (response.candidates === void 0 || response.candidates.length === 0) { + return false; + } + const content = (_a5 = response.candidates[0]) === null || _a5 === void 0 ? void 0 : _a5.content; + if (content === void 0) { + return false; + } + if (content.parts === void 0 || content.parts.length === 0) { + return false; + } + for (const part of content.parts) { + if (part === void 0 || Object.keys(part).length === 0) { + return false; + } + if (part.text !== void 0 && part.text === "") { + return false; + } + } + return true; +} var SILENT_ERROR = "SILENT_ERROR"; var ChatSession = class { - constructor(apiKey, model, params, requestOptions) { + constructor(apiKey, model, params, _requestOptions = {}) { this.model = model; this.params = params; - this.requestOptions = requestOptions; + this._requestOptions = _requestOptions; this._history = []; this._sendPromise = Promise.resolve(); this._apiKey = apiKey; @@ -79024,10 +79465,14 @@ var ChatSession = class { } /** * Sends a chat message and receives a non-streaming - * {@link GenerateContentResult} + * {@link GenerateContentResult}. + * + * Fields set in the optional {@link SingleRequestOptions} parameter will + * take precedence over the {@link RequestOptions} values provided to + * {@link GoogleGenerativeAI.getGenerativeModel }. */ - async sendMessage(request3) { - var _a5, _b2, _c2, _d2, _e2; + async sendMessage(request3, requestOptions = {}) { + var _a5, _b2, _c2, _d2, _e2, _f; await this._sendPromise; const newContent = formatNewContent(request3); const generateContentRequest = { @@ -79036,12 +79481,14 @@ var ChatSession = class { tools: (_c2 = this.params) === null || _c2 === void 0 ? void 0 : _c2.tools, toolConfig: (_d2 = this.params) === null || _d2 === void 0 ? void 0 : _d2.toolConfig, systemInstruction: (_e2 = this.params) === null || _e2 === void 0 ? void 0 : _e2.systemInstruction, + cachedContent: (_f = this.params) === null || _f === void 0 ? void 0 : _f.cachedContent, contents: [...this._history, newContent] }; + const chatSessionRequestOptions = Object.assign(Object.assign({}, this._requestOptions), requestOptions); let finalResult; - this._sendPromise = this._sendPromise.then(() => generateContent(this._apiKey, this.model, generateContentRequest, this.requestOptions)).then((result) => { + this._sendPromise = this._sendPromise.then(() => generateContent(this._apiKey, this.model, generateContentRequest, chatSessionRequestOptions)).then((result) => { var _a6; - if (result.response.candidates && result.response.candidates.length > 0) { + if (isValidResponse(result.response)) { this._history.push(newContent); const responseContent = Object.assign({ parts: [], @@ -79056,6 +79503,9 @@ var ChatSession = class { } } finalResult = result; + }).catch((e3) => { + this._sendPromise = Promise.resolve(); + throw e3; }); await this._sendPromise; return finalResult; @@ -79064,9 +79514,13 @@ var ChatSession = class { * Sends a chat message and receives the response as a * {@link GenerateContentStreamResult} containing an iterable stream * and a response promise. + * + * Fields set in the optional {@link SingleRequestOptions} parameter will + * take precedence over the {@link RequestOptions} values provided to + * {@link GoogleGenerativeAI.getGenerativeModel }. */ - async sendMessageStream(request3) { - var _a5, _b2, _c2, _d2, _e2; + async sendMessageStream(request3, requestOptions = {}) { + var _a5, _b2, _c2, _d2, _e2, _f; await this._sendPromise; const newContent = formatNewContent(request3); const generateContentRequest = { @@ -79075,13 +79529,15 @@ var ChatSession = class { tools: (_c2 = this.params) === null || _c2 === void 0 ? void 0 : _c2.tools, toolConfig: (_d2 = this.params) === null || _d2 === void 0 ? void 0 : _d2.toolConfig, systemInstruction: (_e2 = this.params) === null || _e2 === void 0 ? void 0 : _e2.systemInstruction, + cachedContent: (_f = this.params) === null || _f === void 0 ? void 0 : _f.cachedContent, contents: [...this._history, newContent] }; - const streamPromise = generateContentStream(this._apiKey, this.model, generateContentRequest, this.requestOptions); + const chatSessionRequestOptions = Object.assign(Object.assign({}, this._requestOptions), requestOptions); + const streamPromise = generateContentStream(this._apiKey, this.model, generateContentRequest, chatSessionRequestOptions); this._sendPromise = this._sendPromise.then(() => streamPromise).catch((_ignored) => { throw new Error(SILENT_ERROR); }).then((streamResult) => streamResult.response).then((response) => { - if (response.candidates && response.candidates.length > 0) { + if (isValidResponse(response)) { this._history.push(newContent); const responseContent = Object.assign({}, response.candidates[0].content); if (!responseContent.role) { @@ -79102,24 +79558,25 @@ var ChatSession = class { return streamPromise; } }; -async function countTokens(apiKey, model, params, requestOptions) { - const response = await makeRequest(model, Task.COUNT_TOKENS, apiKey, false, JSON.stringify(Object.assign(Object.assign({}, params), { model })), requestOptions); +async function countTokens(apiKey, model, params, singleRequestOptions) { + const response = await makeModelRequest(model, Task.COUNT_TOKENS, apiKey, false, JSON.stringify(params), singleRequestOptions); return response.json(); } async function embedContent(apiKey, model, params, requestOptions) { - const response = await makeRequest(model, Task.EMBED_CONTENT, apiKey, false, JSON.stringify(params), requestOptions); + const response = await makeModelRequest(model, Task.EMBED_CONTENT, apiKey, false, JSON.stringify(params), requestOptions); return response.json(); } async function batchEmbedContents(apiKey, model, params, requestOptions) { const requestsWithModel = params.requests.map((request3) => { return Object.assign(Object.assign({}, request3), { model }); }); - const response = await makeRequest(model, Task.BATCH_EMBED_CONTENTS, apiKey, false, JSON.stringify({ requests: requestsWithModel }), requestOptions); + const response = await makeModelRequest(model, Task.BATCH_EMBED_CONTENTS, apiKey, false, JSON.stringify({ requests: requestsWithModel }), requestOptions); return response.json(); } var GenerativeModel = class { - constructor(apiKey, modelParams, requestOptions) { + constructor(apiKey, modelParams, _requestOptions = {}) { this.apiKey = apiKey; + this._requestOptions = _requestOptions; if (modelParams.model.includes("/")) { this.model = modelParams.model; } else { @@ -79130,52 +79587,88 @@ var GenerativeModel = class { this.tools = modelParams.tools; this.toolConfig = modelParams.toolConfig; this.systemInstruction = formatSystemInstruction(modelParams.systemInstruction); - this.requestOptions = requestOptions || {}; + this.cachedContent = modelParams.cachedContent; } /** * Makes a single non-streaming call to the model * and returns an object containing a single {@link GenerateContentResponse}. + * + * Fields set in the optional {@link SingleRequestOptions} parameter will + * take precedence over the {@link RequestOptions} values provided to + * {@link GoogleGenerativeAI.getGenerativeModel }. */ - async generateContent(request3) { + async generateContent(request3, requestOptions = {}) { + var _a5; const formattedParams = formatGenerateContentInput(request3); - return generateContent(this.apiKey, this.model, Object.assign({ generationConfig: this.generationConfig, safetySettings: this.safetySettings, tools: this.tools, toolConfig: this.toolConfig, systemInstruction: this.systemInstruction }, formattedParams), this.requestOptions); + const generativeModelRequestOptions = Object.assign(Object.assign({}, this._requestOptions), requestOptions); + return generateContent(this.apiKey, this.model, Object.assign({ generationConfig: this.generationConfig, safetySettings: this.safetySettings, tools: this.tools, toolConfig: this.toolConfig, systemInstruction: this.systemInstruction, cachedContent: (_a5 = this.cachedContent) === null || _a5 === void 0 ? void 0 : _a5.name }, formattedParams), generativeModelRequestOptions); } /** - * Makes a single streaming call to the model - * and returns an object containing an iterable stream that iterates - * over all chunks in the streaming response as well as - * a promise that returns the final aggregated response. + * Makes a single streaming call to the model and returns an object + * containing an iterable stream that iterates over all chunks in the + * streaming response as well as a promise that returns the final + * aggregated response. + * + * Fields set in the optional {@link SingleRequestOptions} parameter will + * take precedence over the {@link RequestOptions} values provided to + * {@link GoogleGenerativeAI.getGenerativeModel }. */ - async generateContentStream(request3) { + async generateContentStream(request3, requestOptions = {}) { + var _a5; const formattedParams = formatGenerateContentInput(request3); - return generateContentStream(this.apiKey, this.model, Object.assign({ generationConfig: this.generationConfig, safetySettings: this.safetySettings, tools: this.tools, toolConfig: this.toolConfig, systemInstruction: this.systemInstruction }, formattedParams), this.requestOptions); + const generativeModelRequestOptions = Object.assign(Object.assign({}, this._requestOptions), requestOptions); + return generateContentStream(this.apiKey, this.model, Object.assign({ generationConfig: this.generationConfig, safetySettings: this.safetySettings, tools: this.tools, toolConfig: this.toolConfig, systemInstruction: this.systemInstruction, cachedContent: (_a5 = this.cachedContent) === null || _a5 === void 0 ? void 0 : _a5.name }, formattedParams), generativeModelRequestOptions); } /** * Gets a new {@link ChatSession} instance which can be used for * multi-turn chats. */ startChat(startChatParams) { - return new ChatSession(this.apiKey, this.model, Object.assign({ generationConfig: this.generationConfig, safetySettings: this.safetySettings, tools: this.tools, toolConfig: this.toolConfig, systemInstruction: this.systemInstruction }, startChatParams), this.requestOptions); + var _a5; + return new ChatSession(this.apiKey, this.model, Object.assign({ generationConfig: this.generationConfig, safetySettings: this.safetySettings, tools: this.tools, toolConfig: this.toolConfig, systemInstruction: this.systemInstruction, cachedContent: (_a5 = this.cachedContent) === null || _a5 === void 0 ? void 0 : _a5.name }, startChatParams), this._requestOptions); } /** * Counts the tokens in the provided request. + * + * Fields set in the optional {@link SingleRequestOptions} parameter will + * take precedence over the {@link RequestOptions} values provided to + * {@link GoogleGenerativeAI.getGenerativeModel }. */ - async countTokens(request3) { - const formattedParams = formatGenerateContentInput(request3); - return countTokens(this.apiKey, this.model, formattedParams, this.requestOptions); + async countTokens(request3, requestOptions = {}) { + const formattedParams = formatCountTokensInput(request3, { + model: this.model, + generationConfig: this.generationConfig, + safetySettings: this.safetySettings, + tools: this.tools, + toolConfig: this.toolConfig, + systemInstruction: this.systemInstruction, + cachedContent: this.cachedContent + }); + const generativeModelRequestOptions = Object.assign(Object.assign({}, this._requestOptions), requestOptions); + return countTokens(this.apiKey, this.model, formattedParams, generativeModelRequestOptions); } /** * Embeds the provided content. + * + * Fields set in the optional {@link SingleRequestOptions} parameter will + * take precedence over the {@link RequestOptions} values provided to + * {@link GoogleGenerativeAI.getGenerativeModel }. */ - async embedContent(request3) { + async embedContent(request3, requestOptions = {}) { const formattedParams = formatEmbedContentInput(request3); - return embedContent(this.apiKey, this.model, formattedParams, this.requestOptions); + const generativeModelRequestOptions = Object.assign(Object.assign({}, this._requestOptions), requestOptions); + return embedContent(this.apiKey, this.model, formattedParams, generativeModelRequestOptions); } /** * Embeds an array of {@link EmbedContentRequest}s. + * + * Fields set in the optional {@link SingleRequestOptions} parameter will + * take precedence over the {@link RequestOptions} values provided to + * {@link GoogleGenerativeAI.getGenerativeModel }. */ - async batchEmbedContents(batchEmbedContentRequest) { - return batchEmbedContents(this.apiKey, this.model, batchEmbedContentRequest, this.requestOptions); + async batchEmbedContents(batchEmbedContentRequest, requestOptions = {}) { + const generativeModelRequestOptions = Object.assign(Object.assign({}, this._requestOptions), requestOptions); + return batchEmbedContents(this.apiKey, this.model, batchEmbedContentRequest, generativeModelRequestOptions); } }; var GoogleGenerativeAI = class { @@ -79191,9 +79684,67 @@ var GoogleGenerativeAI = class { } return new GenerativeModel(this.apiKey, modelParams, requestOptions); } + /** + * Creates a {@link GenerativeModel} instance from provided content cache. + */ + getGenerativeModelFromCachedContent(cachedContent, modelParams, requestOptions) { + if (!cachedContent.name) { + throw new GoogleGenerativeAIRequestInputError("Cached content must contain a `name` field."); + } + if (!cachedContent.model) { + throw new GoogleGenerativeAIRequestInputError("Cached content must contain a `model` field."); + } + const disallowedDuplicates = ["model", "systemInstruction"]; + for (const key of disallowedDuplicates) { + if ((modelParams === null || modelParams === void 0 ? void 0 : modelParams[key]) && cachedContent[key] && (modelParams === null || modelParams === void 0 ? void 0 : modelParams[key]) !== cachedContent[key]) { + if (key === "model") { + const modelParamsComp = modelParams.model.startsWith("models/") ? modelParams.model.replace("models/", "") : modelParams.model; + const cachedContentComp = cachedContent.model.startsWith("models/") ? cachedContent.model.replace("models/", "") : cachedContent.model; + if (modelParamsComp === cachedContentComp) { + continue; + } + } + throw new GoogleGenerativeAIRequestInputError(`Different value for "${key}" specified in modelParams (${modelParams[key]}) and cachedContent (${cachedContent[key]})`); + } + } + const modelParamsFromCache = Object.assign(Object.assign({}, modelParams), { model: cachedContent.model, tools: cachedContent.tools, toolConfig: cachedContent.toolConfig, systemInstruction: cachedContent.systemInstruction, cachedContent }); + return new GenerativeModel(this.apiKey, modelParamsFromCache, requestOptions); + } }; // src/engine/gemini.ts +var GEMINI_BLOCKING_FINISH_REASONS = /* @__PURE__ */ new Set([ + FinishReason.RECITATION, + FinishReason.SAFETY, + FinishReason.LANGUAGE +]); +var formatGeminiBlockMessage = (response) => { + const promptFeedback = response.promptFeedback; + if (promptFeedback?.blockReason) { + return promptFeedback.blockReasonMessage ? `Gemini response was blocked due to ${promptFeedback.blockReason}: ${promptFeedback.blockReasonMessage}` : `Gemini response was blocked due to ${promptFeedback.blockReason}`; + } + const firstCandidate = response.candidates?.[0]; + if (firstCandidate?.finishReason) { + return firstCandidate.finishMessage ? `Gemini response was blocked due to ${firstCandidate.finishReason}: ${firstCandidate.finishMessage}` : `Gemini response was blocked due to ${firstCandidate.finishReason}`; + } + return "Gemini response did not contain usable text"; +}; +var extractGeminiText = (response) => { + const firstCandidate = response.candidates?.[0]; + if (firstCandidate?.finishReason && GEMINI_BLOCKING_FINISH_REASONS.has(firstCandidate.finishReason)) { + throw new Error(formatGeminiBlockMessage(response)); + } + const text = firstCandidate?.content?.parts?.flatMap( + (part) => "text" in part && typeof part.text === "string" ? [part.text] : [] + ).join(""); + if (typeof text === "string" && text.length > 0) { + return text; + } + if (response.promptFeedback?.blockReason) { + throw new Error(formatGeminiBlockMessage(response)); + } + return ""; +}; var GeminiEngine = class { constructor(config8) { this.client = new GoogleGenerativeAI(config8.apiKey); @@ -79243,7 +79794,7 @@ var GeminiEngine = class { topP: 0.1 } }); - const content = result.response.text(); + const content = extractGeminiText(result.response); return removeContentTags(content, "think"); } catch (error) { throw normalizeEngineError(error, "gemini", this.config.model); @@ -79881,7 +80432,7 @@ var _AbstractPage_client2; async function defaultParseResponse2(props) { const { response } = props; if (props.options.stream) { - debug2("response", response.status, response.url, response.headers, response.body); + debug4("response", response.status, response.url, response.headers, response.body); if (props.options.__streamClass) { return props.options.__streamClass.fromSSEResponse(response, props.controller); } @@ -79897,11 +80448,11 @@ async function defaultParseResponse2(props) { const isJSON = contentType?.includes("application/json") || contentType?.includes("application/vnd.api+json"); if (isJSON) { const json = await response.json(); - debug2("response", response.status, response.url, response.headers, json); + debug4("response", response.status, response.url, response.headers, json); return json; } const text = await response.text(); - debug2("response", response.status, response.url, response.headers, text); + debug4("response", response.status, response.url, response.headers, text); return text; } var APIPromise2 = class _APIPromise extends Promise { @@ -80120,7 +80671,7 @@ var APIClient2 = class { await this.prepareOptions(options); const { req, url: url2, timeout } = this.buildRequest(options); await this.prepareRequest(req, { url: url2, options }); - debug2("request", url2, options, req.headers); + debug4("request", url2, options, req.headers); if (options.signal?.aborted) { throw new APIUserAbortError3(); } @@ -80142,14 +80693,14 @@ var APIClient2 = class { if (!response.ok) { if (retriesRemaining && this.shouldRetry(response)) { const retryMessage2 = `retrying, ${retriesRemaining} attempts remaining`; - debug2(`response (error; ${retryMessage2})`, response.status, url2, responseHeaders); + debug4(`response (error; ${retryMessage2})`, response.status, url2, responseHeaders); return this.retryRequest(options, retriesRemaining, responseHeaders); } const errText = await response.text().catch((e3) => castToError2(e3).message); const errJSON = safeJSON2(errText); const errMessage = errJSON ? void 0 : errText; const retryMessage = retriesRemaining ? `(error; no more retries left)` : `(error; not retryable)`; - debug2(`response (error; ${retryMessage})`, response.status, url2, responseHeaders, errMessage); + debug4(`response (error; ${retryMessage})`, response.status, url2, responseHeaders, errMessage); const err = this.makeStatusError(response.status, errJSON, errMessage, responseHeaders); throw err; } @@ -80513,7 +81064,7 @@ function applyHeadersMut2(targetHeaders, newHeaders) { } } } -function debug2(action, ...args) { +function debug4(action, ...args) { if (typeof process !== "undefined" && process?.env?.["DEBUG"] === "true") { console.log(`OpenAI:DEBUG:${action}`, ...args); } @@ -83990,9 +84541,6 @@ var { OpenAIError: OpenAIError2, APIError: APIError4, APIConnectionError: APICon OpenAI2.Uploads = Uploads; })(OpenAI || (OpenAI = {})); -// src/engine/openAi.ts -var import_https_proxy_agent3 = __toESM(require_dist2(), 1); - // src/utils/customHeaders.ts function parseCustomHeaders(headers) { let parsedHeaders = {}; @@ -84050,7 +84598,7 @@ var OpenAiEngine = class { } const proxy = config8.proxy; if (proxy) { - clientOptions.httpAgent = new import_https_proxy_agent3.HttpsProxyAgent(proxy); + clientOptions.httpAgent = new HttpsProxyAgent(proxy); } if (config8.customHeaders) { const headers = parseCustomHeaders(config8.customHeaders); @@ -84231,7 +84779,6 @@ var OpenRouterEngine = class { }; // src/utils/proxy.ts -var import_https_proxy_agent4 = __toESM(require_dist2(), 1); var import_undici = __toESM(require_undici(), 1); function resolveProxy(proxySetting) { if (proxySetting === null) { @@ -84260,7 +84807,7 @@ function setupProxy(proxySetting) { } const dispatcher = new import_undici.ProxyAgent(proxySetting); (0, import_undici.setGlobalDispatcher)(dispatcher); - const agent = new import_https_proxy_agent4.HttpsProxyAgent(proxySetting); + const agent = new HttpsProxyAgent(proxySetting); axios_default.defaults.httpAgent = agent; axios_default.defaults.httpsAgent = agent; axios_default.defaults.proxy = false; diff --git a/package-lock.json b/package-lock.json index b8177592..65b43ec9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,17 +38,15 @@ "opencommit": "out/cli.cjs" }, "devDependencies": { + "@biomejs/biome": "2.4.11", "@commitlint/types": "^17.4.4", "@types/ini": "^1.3.31", "@types/inquirer": "^9.0.3", "@types/jest": "^29.5.12", "@types/node": "^16.18.14", - "@typescript-eslint/eslint-plugin": "^8.29.0", - "@typescript-eslint/parser": "^8.29.0", "cli-testing-library": "^2.0.2", "dotenv": "^16.0.3", "esbuild": "^0.25.5", - "eslint": "^9.24.0", "jest": "^29.7.0", "prettier": "^2.8.4", "rimraf": "^6.0.1", @@ -736,6 +734,169 @@ "dev": true, "license": "MIT" }, + "node_modules/@biomejs/biome": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.4.11.tgz", + "integrity": "sha512-nWxHX8tf3Opb/qRgZpBbsTOqOodkbrkJ7S+JxJAruxOReaDPPmPuLBAGQ8vigyUgo0QBB+oQltNEAvalLcjggA==", + "dev": true, + "license": "MIT OR Apache-2.0", + "bin": { + "biome": "bin/biome" + }, + "engines": { + "node": ">=14.21.3" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/biome" + }, + "optionalDependencies": { + "@biomejs/cli-darwin-arm64": "2.4.11", + "@biomejs/cli-darwin-x64": "2.4.11", + "@biomejs/cli-linux-arm64": "2.4.11", + "@biomejs/cli-linux-arm64-musl": "2.4.11", + "@biomejs/cli-linux-x64": "2.4.11", + "@biomejs/cli-linux-x64-musl": "2.4.11", + "@biomejs/cli-win32-arm64": "2.4.11", + "@biomejs/cli-win32-x64": "2.4.11" + } + }, + "node_modules/@biomejs/cli-darwin-arm64": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.4.11.tgz", + "integrity": "sha512-wOt+ed+L2dgZanWyL6i29qlXMc088N11optzpo10peayObBaAshbTcxKUchzEMp9QSY8rh5h6VfAFE3WTS1rqg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-darwin-x64": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.4.11.tgz", + "integrity": "sha512-gZ6zR8XmZlExfi/Pz/PffmdpWOQ8Qhy7oBztgkR8/ylSRyLwfRPSadmiVCV8WQ8PoJ2MWUy2fgID9zmtgUUJmw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.4.11.tgz", + "integrity": "sha512-avdJaEElXrKceK0va9FkJ4P5ci3N01TGkc6ni3P8l3BElqbOz42Wg2IyX3gbh0ZLEd4HVKEIrmuVu/AMuSeFFA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64-musl": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.4.11.tgz", + "integrity": "sha512-+Sbo1OAmlegtdwqFE8iOxFIWLh1B3OEgsuZfBpyyN/kWuqZ8dx9ZEes6zVnDMo+zRHF2wLynRVhoQmV7ohxl2Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-2.4.11.tgz", + "integrity": "sha512-TagWV0iomp5LnEnxWFg4nQO+e52Fow349vaX0Q/PIcX6Zhk4GGBgp3qqZ8PVkpC+cuehRctMf3+6+FgQ8jCEFQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64-musl": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.4.11.tgz", + "integrity": "sha512-bexd2IklK7ZgPhrz6jXzpIL6dEAH9MlJU1xGTrypx+FICxrXUp4CqtwfiuoDKse+UlgAlWtzML3jrMqeEAHEhA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-arm64": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.4.11.tgz", + "integrity": "sha512-RJhaTnY8byzxDt4bDVb7AFPHkPcjOPK3xBip4ZRTrN3TEfyhjLRm3r3mqknqydgVTB74XG8l4jMLwEACEeihVg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-x64": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.4.11.tgz", + "integrity": "sha512-A8D3JM/00C2KQgUV3oj8Ba15EHEYwebAGCy5Sf9GAjr5Y3+kJIYOiESoqRDeuRZueuMdCsbLZIUqmPhpYXJE9A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, "node_modules/@clack/core": { "version": "0.3.4", "license": "MIT", @@ -1273,134 +1434,6 @@ "node": ">=18" } }, - "node_modules/@eslint-community/eslint-utils": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.7.0.tgz", - "integrity": "sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==", - "dev": true, - "license": "MIT", - "dependencies": { - "eslint-visitor-keys": "^3.4.3" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" - } - }, - "node_modules/@eslint-community/regexpp": { - "version": "4.12.1", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", - "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.0.0 || ^14.0.0 || >=16.0.0" - } - }, - "node_modules/@eslint/config-array": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.20.0.tgz", - "integrity": "sha512-fxlS1kkIjx8+vy2SjuCB94q3htSNrufYTXubwiBFeaQHbH6Ipi43gFJq2zCMt6PHhImH3Xmr0NksKDvchWlpQQ==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@eslint/object-schema": "^2.1.6", - "debug": "^4.3.1", - "minimatch": "^3.1.2" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@eslint/config-helpers": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.2.2.tgz", - "integrity": "sha512-+GPzk8PlG0sPpzdU5ZvIRMPidzAnZDl/s9L+y13iodqvb8leL53bTannOrQ/Im7UkpsmFU5Ily5U60LWixnmLg==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@eslint/core": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.14.0.tgz", - "integrity": "sha512-qIbV0/JZr7iSDjqAc60IqbLdsj9GDt16xQtWD+B78d/HAlvysGdZZ6rpJHGAc2T0FQx1X6thsSPdnoiGKdNtdg==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@types/json-schema": "^7.0.15" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@eslint/eslintrc": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.1.tgz", - "integrity": "sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^10.0.1", - "globals": "^14.0.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/@eslint/js": { - "version": "9.28.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.28.0.tgz", - "integrity": "sha512-fnqSjGWd/CoIp4EXIxWVK/sHA6DOHN4+8Ix2cX5ycOY7LG0UY8nHCU5pIp2eaE1Mc7Qd8kHspYNzYXT2ojPLzg==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://eslint.org/donate" - } - }, - "node_modules/@eslint/object-schema": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.6.tgz", - "integrity": "sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@eslint/plugin-kit": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.3.1.tgz", - "integrity": "sha512-0J+zgWxHN+xXONWIyPWKFMgVuJoZuGiIFu8yxk7RJjxkzpGmyja5wRFqZIVtjDVOQpV+Rw0iOAjYPE2eQyjr0w==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@eslint/core": "^0.14.0", - "levn": "^0.4.1" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, "node_modules/@fastify/busboy": { "version": "2.1.1", "license": "MIT", @@ -1417,72 +1450,6 @@ "node": ">=18.0.0" } }, - "node_modules/@humanfs/core": { - "version": "0.19.1", - "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", - "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=18.18.0" - } - }, - "node_modules/@humanfs/node": { - "version": "0.16.6", - "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.6.tgz", - "integrity": "sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@humanfs/core": "^0.19.1", - "@humanwhocodes/retry": "^0.3.0" - }, - "engines": { - "node": ">=18.18.0" - } - }, - "node_modules/@humanfs/node/node_modules/@humanwhocodes/retry": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz", - "integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=18.18" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } - }, - "node_modules/@humanwhocodes/module-importer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", - "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=12.22" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } - }, - "node_modules/@humanwhocodes/retry": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", - "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=18.18" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } - }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -2235,44 +2202,6 @@ "zod": ">= 3" } }, - "node_modules/@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/@octokit/auth-token": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz", @@ -2517,13 +2446,6 @@ "@babel/types": "^7.20.7" } }, - "node_modules/@types/estree": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", - "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/graceful-fs": { "version": "4.1.9", "dev": true, @@ -2576,13 +2498,6 @@ "pretty-format": "^29.0.0" } }, - "node_modules/@types/json-schema": { - "version": "7.0.15", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", - "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/node": { "version": "16.18.93", "license": "MIT" @@ -2625,311 +2540,31 @@ "dev": true, "license": "MIT" }, - "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.33.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.33.1.tgz", - "integrity": "sha512-TDCXj+YxLgtvxvFlAvpoRv9MAncDLBV2oT9Bd7YBGC/b/sEURoOYuIwLI99rjWOfY3QtDzO+mk0n4AmdFExW8A==", - "dev": true, + "node_modules/abort-controller": { + "version": "3.0.0", "license": "MIT", "dependencies": { - "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.33.1", - "@typescript-eslint/type-utils": "8.33.1", - "@typescript-eslint/utils": "8.33.1", - "@typescript-eslint/visitor-keys": "8.33.1", - "graphemer": "^1.4.0", - "ignore": "^7.0.0", - "natural-compare": "^1.4.0", - "ts-api-utils": "^2.1.0" + "event-target-shim": "^5.0.0" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "@typescript-eslint/parser": "^8.33.1", - "eslint": "^8.57.0 || ^9.0.0", - "typescript": ">=4.8.4 <5.9.0" + "node": ">=6.5" } }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz", - "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", + "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", + "bin": { + "acorn": "bin/acorn" + }, "engines": { - "node": ">= 4" + "node": ">=0.4.0" } }, - "node_modules/@typescript-eslint/parser": { - "version": "8.33.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.33.1.tgz", - "integrity": "sha512-qwxv6dq682yVvgKKp2qWwLgRbscDAYktPptK4JPojCwwi3R9cwrvIxS4lvBpzmcqzR4bdn54Z0IG1uHFskW4dA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/scope-manager": "8.33.1", - "@typescript-eslint/types": "8.33.1", - "@typescript-eslint/typescript-estree": "8.33.1", - "@typescript-eslint/visitor-keys": "8.33.1", - "debug": "^4.3.4" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0", - "typescript": ">=4.8.4 <5.9.0" - } - }, - "node_modules/@typescript-eslint/project-service": { - "version": "8.33.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.33.1.tgz", - "integrity": "sha512-DZR0efeNklDIHHGRpMpR5gJITQpu6tLr9lDJnKdONTC7vvzOlLAG/wcfxcdxEWrbiZApcoBCzXqU/Z458Za5Iw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.33.1", - "@typescript-eslint/types": "^8.33.1", - "debug": "^4.3.4" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "typescript": ">=4.8.4 <5.9.0" - } - }, - "node_modules/@typescript-eslint/scope-manager": { - "version": "8.33.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.33.1.tgz", - "integrity": "sha512-dM4UBtgmzHR9bS0Rv09JST0RcHYearoEoo3pG5B6GoTR9XcyeqX87FEhPo+5kTvVfKCvfHaHrcgeJQc6mrDKrA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/types": "8.33.1", - "@typescript-eslint/visitor-keys": "8.33.1" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.33.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.33.1.tgz", - "integrity": "sha512-STAQsGYbHCF0/e+ShUQ4EatXQ7ceh3fBCXkNU7/MZVKulrlq1usH7t2FhxvCpuCi5O5oi1vmVaAjrGeL71OK1g==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "typescript": ">=4.8.4 <5.9.0" - } - }, - "node_modules/@typescript-eslint/type-utils": { - "version": "8.33.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.33.1.tgz", - "integrity": "sha512-1cG37d9xOkhlykom55WVwG2QRNC7YXlxMaMzqw2uPeJixBFfKWZgaP/hjAObqMN/u3fr5BrTwTnc31/L9jQ2ww==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/typescript-estree": "8.33.1", - "@typescript-eslint/utils": "8.33.1", - "debug": "^4.3.4", - "ts-api-utils": "^2.1.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0", - "typescript": ">=4.8.4 <5.9.0" - } - }, - "node_modules/@typescript-eslint/types": { - "version": "8.33.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.33.1.tgz", - "integrity": "sha512-xid1WfizGhy/TKMTwhtVOgalHwPtV8T32MS9MaH50Cwvz6x6YqRIPdD2WvW0XaqOzTV9p5xdLY0h/ZusU5Lokg==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.33.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.33.1.tgz", - "integrity": "sha512-+s9LYcT8LWjdYWu7IWs7FvUxpQ/DGkdjZeE/GGulHvv8rvYwQvVaUZ6DE+j5x/prADUgSbbCWZ2nPI3usuVeOA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/project-service": "8.33.1", - "@typescript-eslint/tsconfig-utils": "8.33.1", - "@typescript-eslint/types": "8.33.1", - "@typescript-eslint/visitor-keys": "8.33.1", - "debug": "^4.3.4", - "fast-glob": "^3.3.2", - "is-glob": "^4.0.3", - "minimatch": "^9.0.4", - "semver": "^7.6.0", - "ts-api-utils": "^2.1.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "typescript": ">=4.8.4 <5.9.0" - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/@typescript-eslint/utils": { - "version": "8.33.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.33.1.tgz", - "integrity": "sha512-52HaBiEQUaRYqAXpfzWSR2U3gxk92Kw006+xZpElaPMg3C4PgM+A5LqwoQI1f9E5aZ/qlxAZxzm42WX+vn92SQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@eslint-community/eslint-utils": "^4.7.0", - "@typescript-eslint/scope-manager": "8.33.1", - "@typescript-eslint/types": "8.33.1", - "@typescript-eslint/typescript-estree": "8.33.1" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0", - "typescript": ">=4.8.4 <5.9.0" - } - }, - "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.33.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.33.1.tgz", - "integrity": "sha512-3i8NrFcZeeDHJ+7ZUuDkGT+UHq+XoFGsymNK2jZCOHcfEzRQ0BdpRtdpSx/Iyf3MHLWIcLS0COuOPibKQboIiQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/types": "8.33.1", - "eslint-visitor-keys": "^4.2.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/abort-controller": { - "version": "3.0.0", - "license": "MIT", - "dependencies": { - "event-target-shim": "^5.0.0" - }, - "engines": { - "node": ">=6.5" - } - }, - "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", - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-jsx": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", - "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "license": "MIT", - "peerDependencies": { - "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" - } - }, - "node_modules/acorn-walk": { - "version": "8.3.2", + "node_modules/acorn-walk": { + "version": "8.3.2", "dev": true, "license": "MIT", "engines": { @@ -2955,23 +2590,6 @@ "node": ">= 8.0.0" } }, - "node_modules/ajv": { - "version": "8.17.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", - "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.3", - "fast-uri": "^3.0.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, "node_modules/ansi-escapes": { "version": "4.3.2", "license": "MIT", @@ -3030,13 +2648,6 @@ "dev": true, "license": "MIT" }, - "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true, - "license": "Python-2.0" - }, "node_modules/astral-regex": { "version": "2.0.0", "dev": true, @@ -3732,13 +3343,6 @@ } } }, - "node_modules/deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true, - "license": "MIT" - }, "node_modules/deepmerge": { "version": "4.3.1", "dev": true, @@ -3921,207 +3525,6 @@ "node": ">=6" } }, - "node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/eslint": { - "version": "9.28.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.28.0.tgz", - "integrity": "sha512-ocgh41VhRlf9+fVpe7QKzwLj9c92fDiqOj8Y3Sd4/ZmVA4Btx4PlUYPq4pp9JDyupkf1upbEXecxL2mwNV7jPQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.12.1", - "@eslint/config-array": "^0.20.0", - "@eslint/config-helpers": "^0.2.1", - "@eslint/core": "^0.14.0", - "@eslint/eslintrc": "^3.3.1", - "@eslint/js": "9.28.0", - "@eslint/plugin-kit": "^0.3.1", - "@humanfs/node": "^0.16.6", - "@humanwhocodes/module-importer": "^1.0.1", - "@humanwhocodes/retry": "^0.4.2", - "@types/estree": "^1.0.6", - "@types/json-schema": "^7.0.15", - "ajv": "^6.12.4", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.6", - "debug": "^4.3.2", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^8.3.0", - "eslint-visitor-keys": "^4.2.0", - "espree": "^10.3.0", - "esquery": "^1.5.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^8.0.0", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "ignore": "^5.2.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", - "natural-compare": "^1.4.0", - "optionator": "^0.9.3" - }, - "bin": { - "eslint": "bin/eslint.js" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://eslint.org/donate" - }, - "peerDependencies": { - "jiti": "*" - }, - "peerDependenciesMeta": { - "jiti": { - "optional": true - } - } - }, - "node_modules/eslint-scope": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.3.0.tgz", - "integrity": "sha512-pUNxi75F8MJ/GdeKtVLSbYg4ZI34J6C0C7sbL4YOp2exGwen7ZsuBqKzUhXd0qMQ362yET3z+uPwKeg/0C2XCQ==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/eslint/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/eslint/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/eslint/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, - "license": "MIT" - }, - "node_modules/eslint/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/espree": { - "version": "10.3.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-10.3.0.tgz", - "integrity": "sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "acorn": "^8.14.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^4.2.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/espree/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, "node_modules/esprima": { "version": "4.0.1", "dev": true, @@ -4134,52 +3537,6 @@ "node": ">=4" } }, - "node_modules/esquery": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", - "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "estraverse": "^5.1.0" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/esrecurse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "estraverse": "^5.2.0" - }, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=4.0" - } - }, - "node_modules/esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/event-target-shim": { "version": "5.0.1", "license": "MIT", @@ -4333,79 +3690,10 @@ "node": ">=4" } }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "dev": true, - "license": "MIT" - }, - "node_modules/fast-glob": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", - "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.8" - }, - "engines": { - "node": ">=8.6.0" - } - }, - "node_modules/fast-glob/node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "dev": true, - "license": "MIT" - }, - "node_modules/fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", - "dev": true, - "license": "MIT" - }, - "node_modules/fast-uri": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.6.tgz", - "integrity": "sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fastify" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fastify" - } - ], - "license": "BSD-3-Clause" - }, - "node_modules/fastq": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz", - "integrity": "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "reusify": "^1.0.4" - } + "license": "MIT" }, "node_modules/fb-watchman": { "version": "2.0.2", @@ -4435,19 +3723,6 @@ "node": ">=0.8.0" } }, - "node_modules/file-entry-cache": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", - "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "flat-cache": "^4.0.0" - }, - "engines": { - "node": ">=16.0.0" - } - }, "node_modules/fill-range": { "version": "7.1.1", "dev": true, @@ -4459,44 +3734,6 @@ "node": ">=8" } }, - "node_modules/find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "license": "MIT", - "dependencies": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/flat-cache": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", - "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", - "dev": true, - "license": "MIT", - "dependencies": { - "flatted": "^3.2.9", - "keyv": "^4.5.4" - }, - "engines": { - "node": ">=16" - } - }, - "node_modules/flatted": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz", - "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", - "dev": true, - "license": "ISC" - }, "node_modules/follow-redirects": { "version": "1.15.6", "funding": [ @@ -4673,32 +3910,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", - "dev": true, - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.3" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/globals": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", - "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/gopd": { "version": "1.0.1", "license": "MIT", @@ -4714,13 +3925,6 @@ "dev": true, "license": "ISC" }, - "node_modules/graphemer": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", - "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", - "dev": true, - "license": "MIT" - }, "node_modules/has-flag": { "version": "4.0.0", "license": "MIT", @@ -4855,23 +4059,6 @@ "node": ">= 4" } }, - "node_modules/import-fresh": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", - "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/import-local": { "version": "3.1.0", "dev": true, @@ -4966,16 +4153,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "license": "MIT", @@ -4991,19 +4168,6 @@ "node": ">=6" } }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-interactive": { "version": "1.0.0", "license": "MIT", @@ -6479,19 +5643,6 @@ "version": "4.0.0", "license": "MIT" }, - "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/jsesc": { "version": "2.5.2", "dev": true, @@ -6503,32 +5654,11 @@ "node": ">=4" } }, - "node_modules/json-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", - "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", - "dev": true, - "license": "MIT" - }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "dev": true, "license": "MIT" }, - "node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true, - "license": "MIT" - }, - "node_modules/json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", - "dev": true, - "license": "MIT" - }, "node_modules/json5": { "version": "2.2.3", "dev": true, @@ -6540,16 +5670,6 @@ "node": ">=6" } }, - "node_modules/keyv": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", - "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", - "dev": true, - "license": "MIT", - "dependencies": { - "json-buffer": "3.0.1" - } - }, "node_modules/kleur": { "version": "3.0.3", "dev": true, @@ -6566,41 +5686,11 @@ "node": ">=6" } }, - "node_modules/levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/lines-and-columns": { "version": "1.2.4", "dev": true, "license": "MIT" }, - "node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-locate": "^5.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/lodash": { "version": "4.17.21", "license": "MIT" @@ -6610,13 +5700,6 @@ "dev": true, "license": "MIT" }, - "node_modules/lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", - "dev": true, - "license": "MIT" - }, "node_modules/log-symbols": { "version": "4.1.0", "license": "MIT", @@ -6730,16 +5813,6 @@ "version": "2.0.0", "license": "MIT" }, - "node_modules/merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, "node_modules/micromatch": { "version": "4.0.8", "dev": true, @@ -6963,24 +6036,6 @@ "undici-types": "~5.26.4" } }, - "node_modules/optionator": { - "version": "0.9.4", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", - "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", - "dev": true, - "license": "MIT", - "dependencies": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.5" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/ora": { "version": "5.4.1", "license": "MIT", @@ -7064,22 +6119,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-limit": "^3.0.2" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/p-try": { "version": "2.2.0", "dev": true, @@ -7095,19 +6134,6 @@ "dev": true, "license": "BlueOak-1.0.0" }, - "node_modules/parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dev": true, - "license": "MIT", - "dependencies": { - "callsites": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/parse-json": { "version": "5.2.0", "dev": true, @@ -7264,16 +6290,6 @@ "node": ">=8" } }, - "node_modules/prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/prettier": { "version": "2.8.8", "dev": true, @@ -7352,27 +6368,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "node_modules/react": { "version": "18.3.1", "license": "MIT", @@ -7433,16 +6428,6 @@ "node": ">=0.10.0" } }, - "node_modules/require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/resolve": { "version": "1.22.8", "dev": true, @@ -7478,16 +6463,6 @@ "node": ">=8" } }, - "node_modules/resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/resolve.exports": { "version": "2.0.2", "dev": true, @@ -7527,17 +6502,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/reusify": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", - "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", - "dev": true, - "license": "MIT", - "engines": { - "iojs": ">=1.0.0", - "node": ">=0.10.0" - } - }, "node_modules/rimraf": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.0.1.tgz", @@ -7615,30 +6579,6 @@ "node": ">=0.12.0" } }, - "node_modules/run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "queue-microtask": "^1.2.2" - } - }, "node_modules/rxjs": { "version": "7.8.1", "license": "Apache-2.0", @@ -8053,19 +6993,6 @@ "tree-kill": "cli.js" } }, - "node_modules/ts-api-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", - "integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18.12" - }, - "peerDependencies": { - "typescript": ">=4.8.4" - } - }, "node_modules/ts-jest": { "version": "29.1.2", "dev": true, @@ -8161,19 +7088,6 @@ "node": ">=0.6.11 <=0.7.0 || >=0.7.3" } }, - "node_modules/type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", - "dev": true, - "license": "MIT", - "dependencies": { - "prelude-ls": "^1.2.1" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/type-detect": { "version": "4.0.8", "dev": true, @@ -8338,16 +7252,6 @@ "node": ">= 8" } }, - "node_modules/word-wrap": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", - "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/wrap-ansi": { "version": "6.2.0", "license": "MIT", diff --git a/package.json b/package.json index 3675ab9c..a77628c3 100644 --- a/package.json +++ b/package.json @@ -49,9 +49,10 @@ "deploy": "npm publish --tag latest", "deploy:build": "npm run build:push && git push --tags && npm run deploy", "deploy:patch": "npm version patch && npm run deploy:build", - "lint": "eslint src --ext ts && tsc --noEmit", - "format": "prettier --write src", - "format:check": "prettier --check src", + "lint": "biome check . --diagnostic-level=error && tsc --noEmit", + "typecheck": "tsc --noEmit", + "format": "prettier --write \"src/**/*.{ts,js,json,md}\" \"test/**/*.{ts,js,json,md}\" \".github/**/*.{yml,yaml}\" \"*.{js,json,ts,md,yml,yaml}\"", + "format:check": "prettier --check \"src/**/*.{ts,js,json,md}\" \"test/**/*.{ts,js,json,md}\" \".github/**/*.{yml,yaml}\" \"*.{js,json,ts,md,yml,yaml}\"", "test": "node --no-warnings --experimental-vm-modules $( [ -f ./node_modules/.bin/jest ] && echo ./node_modules/.bin/jest || which jest ) test/unit", "test:all": "npm run test:unit:docker && npm run test:e2e:docker", "test:docker-build": "docker build -t oco-test -f test/Dockerfile .", @@ -61,7 +62,7 @@ "test:e2e:smoke": "npm run build && npm run test:e2e:smoke:run", "test:e2e:smoke:run": "OCO_TEST_SKIP_VERSION_CHECK=true jest test/e2e/smoke.test.ts", "test:e2e:core": "npm run build && npm run test:e2e:core:run", - "test:e2e:core:run": "OCO_TEST_SKIP_VERSION_CHECK=true jest test/e2e/cliBehavior.test.ts test/e2e/gitPush.test.ts test/e2e/oneFile.test.ts test/e2e/noChanges.test.ts", + "test:e2e:core:run": "OCO_TEST_SKIP_VERSION_CHECK=true jest test/e2e/cliBehavior.test.ts test/e2e/geminiBehavior.test.ts test/e2e/gitPush.test.ts test/e2e/oneFile.test.ts test/e2e/noChanges.test.ts", "test:e2e:setup": "npm run test:e2e:prompt-module:setup", "test:e2e:prompt-module:setup": "sh test/e2e/setup.sh", "test:e2e:prompt-module": "npm run build && npm run test:e2e:prompt-module:run", @@ -70,17 +71,15 @@ "mlx:start": "OCO_AI_PROVIDER='mlx' node ./out/cli.cjs" }, "devDependencies": { + "@biomejs/biome": "2.4.11", "@commitlint/types": "^17.4.4", "@types/ini": "^1.3.31", "@types/inquirer": "^9.0.3", "@types/jest": "^29.5.12", "@types/node": "^16.18.14", - "@typescript-eslint/eslint-plugin": "^8.29.0", - "@typescript-eslint/parser": "^8.29.0", "cli-testing-library": "^2.0.2", "dotenv": "^16.0.3", "esbuild": "^0.25.5", - "eslint": "^9.24.0", "jest": "^29.7.0", "prettier": "^2.8.4", "rimraf": "^6.0.1", diff --git a/src/engine/gemini.ts b/src/engine/gemini.ts index 5d6760e7..e16d5f3f 100644 --- a/src/engine/gemini.ts +++ b/src/engine/gemini.ts @@ -1,5 +1,7 @@ import { Content, + FinishReason, + GenerateContentResponse, GoogleGenerativeAI, HarmBlockThreshold, HarmCategory, @@ -12,6 +14,59 @@ import { AiEngine, AiEngineConfig } from './Engine'; interface GeminiConfig extends AiEngineConfig {} +const GEMINI_BLOCKING_FINISH_REASONS = new Set([ + FinishReason.RECITATION, + FinishReason.SAFETY, + FinishReason.LANGUAGE +]); + +const formatGeminiBlockMessage = ( + response: GenerateContentResponse +): string => { + const promptFeedback = response.promptFeedback; + if (promptFeedback?.blockReason) { + return promptFeedback.blockReasonMessage + ? `Gemini response was blocked due to ${promptFeedback.blockReason}: ${promptFeedback.blockReasonMessage}` + : `Gemini response was blocked due to ${promptFeedback.blockReason}`; + } + + const firstCandidate = response.candidates?.[0]; + if (firstCandidate?.finishReason) { + return firstCandidate.finishMessage + ? `Gemini response was blocked due to ${firstCandidate.finishReason}: ${firstCandidate.finishMessage}` + : `Gemini response was blocked due to ${firstCandidate.finishReason}`; + } + + return 'Gemini response did not contain usable text'; +}; + +const extractGeminiText = (response: GenerateContentResponse): string => { + const firstCandidate = response.candidates?.[0]; + + if ( + firstCandidate?.finishReason && + GEMINI_BLOCKING_FINISH_REASONS.has(firstCandidate.finishReason) + ) { + throw new Error(formatGeminiBlockMessage(response)); + } + + const text = firstCandidate?.content?.parts + ?.flatMap((part) => + 'text' in part && typeof part.text === 'string' ? [part.text] : [] + ) + .join(''); + + if (typeof text === 'string' && text.length > 0) { + return text; + } + + if (response.promptFeedback?.blockReason) { + throw new Error(formatGeminiBlockMessage(response)); + } + + return ''; +}; + export class GeminiEngine implements AiEngine { config: GeminiConfig; client: GoogleGenerativeAI; @@ -77,7 +132,7 @@ export class GeminiEngine implements AiEngine { } }); - const content = result.response.text(); + const content = extractGeminiText(result.response); return removeContentTags(content, 'think'); } catch (error) { throw normalizeEngineError(error, 'gemini', this.config.model); diff --git a/test/e2e/cliBehavior.test.ts b/test/e2e/cliBehavior.test.ts index f1d6d8e4..dbad5a54 100644 --- a/test/e2e/cliBehavior.test.ts +++ b/test/e2e/cliBehavior.test.ts @@ -53,7 +53,6 @@ it('cli flow passes --context through to the model prompt and skips confirmation expect( await oco.queryByText('Do you want to run `git push`?') ).not.toBeInTheConsole(); - expect(await oco.findByText('Successfully committed')).toBeInTheConsole(); expect(await waitForExit(oco)).toBe(0); await assertHeadCommit(gitDir, 'fix(context): handle production incident'); @@ -64,9 +63,7 @@ it('cli flow passes --context through to the model prompt and skips confirmation .map((message) => message.content) .join('\n'); - expect(requestContents).toContain( - 'production-incident' - ); + expect(requestContents).toContain('production-incident'); expect(requestContents).toContain('console.log("Hello World");'); expect(server.authHeaders).toContain('Bearer test-openai-key'); } finally { @@ -95,7 +92,6 @@ it('cli flow passes --fgm through to the full GitMoji prompt', async () => { env: getMockOpenAiEnv(server.baseUrl) }); - expect(await oco.findByText('Successfully committed')).toBeInTheConsole(); expect(await waitForExit(oco)).toBe(0); await assertHeadCommit( gitDir, @@ -139,7 +135,9 @@ it('cli flow allows editing the generated commit message before committing', asy env: getMockOpenAiEnv(server.baseUrl) }); - expect(await oco.findByText('Confirm the commit message?')).toBeInTheConsole(); + expect( + await oco.findByText('Confirm the commit message?') + ).toBeInTheConsole(); oco.userEvent.keyboard('[ArrowDown][ArrowDown][Enter]'); expect( @@ -192,7 +190,9 @@ it('cli flow regenerates the message when the user rejects the first suggestion' env: getMockOpenAiEnv(server.baseUrl) }); - expect(await oco.findByText('Confirm the commit message?')).toBeInTheConsole(); + expect( + await oco.findByText('Confirm the commit message?') + ).toBeInTheConsole(); oco.userEvent.keyboard('[ArrowDown][Enter]'); expect( @@ -204,15 +204,14 @@ it('cli flow regenerates the message when the user rejects the first suggestion' expect( await oco.findByText('fix(cli): regenerated message after retry') ).toBeInTheConsole(); - expect(await oco.findByText('Confirm the commit message?')).toBeInTheConsole(); + expect( + await oco.findByText('Confirm the commit message?') + ).toBeInTheConsole(); oco.userEvent.keyboard('[Enter]'); expect(await oco.findByText('Successfully committed')).toBeInTheConsole(); expect(await waitForExit(oco)).toBe(0); - await assertHeadCommit( - gitDir, - 'fix(cli): regenerated message after retry' - ); + await assertHeadCommit(gitDir, 'fix(cli): regenerated message after retry'); expect(server.requestBodies).toHaveLength(2); } finally { await server.cleanup(); @@ -250,7 +249,9 @@ it('cli flow lets the user select only specific unstaged files', async () => { ).toBeInTheConsole(); oco.userEvent.keyboard('[Space][Enter]'); - expect(await oco.findByText('Confirm the commit message?')).toBeInTheConsole(); + expect( + await oco.findByText('Confirm the commit message?') + ).toBeInTheConsole(); oco.userEvent.keyboard('[Enter]'); expect(await oco.findByText('Successfully committed')).toBeInTheConsole(); @@ -283,12 +284,17 @@ it('cli applies the documented message template placeholder from extra args', as env: getMockOpenAiEnv(server.baseUrl) }); - expect(await oco.findByText('Confirm the commit message?')).toBeInTheConsole(); + expect( + await oco.findByText('Confirm the commit message?') + ).toBeInTheConsole(); oco.userEvent.keyboard('[Enter]'); expect(await oco.findByText('Successfully committed')).toBeInTheConsole(); expect(await waitForExit(oco)).toBe(0); - await assertHeadCommit(gitDir, 'feat(template): keep generated subject #205'); + await assertHeadCommit( + gitDir, + 'feat(template): keep generated subject #205' + ); } finally { await server.cleanup(); await cleanup(); @@ -406,7 +412,9 @@ it('cli flow prompts for a missing API key, saves it, and completes the commit', oco.userEvent.keyboard('test-openai-key[Enter]'); expect(await oco.findByText('API key saved')).toBeInTheConsole(); - expect(await oco.findByText('Confirm the commit message?')).toBeInTheConsole(); + expect( + await oco.findByText('Confirm the commit message?') + ).toBeInTheConsole(); oco.userEvent.keyboard('[Enter]'); expect(await oco.findByText('Successfully committed')).toBeInTheConsole(); @@ -485,7 +493,9 @@ it('cli excludes .opencommitignore files from the generated prompt while still c env: getMockOpenAiEnv(server.baseUrl) }); - expect(await oco.findByText('Confirm the commit message?')).toBeInTheConsole(); + expect( + await oco.findByText('Confirm the commit message?') + ).toBeInTheConsole(); oco.userEvent.keyboard('[Enter]'); expect(await oco.findByText('Successfully committed')).toBeInTheConsole(); @@ -553,7 +563,9 @@ it('first run launches setup, saves config, and completes a commit with the conf expect( await oco.findByText('Configuration saved to ~/.opencommit') ).toBeInTheConsole(); - expect(await oco.findByText('Confirm the commit message?')).toBeInTheConsole(); + expect( + await oco.findByText('Confirm the commit message?') + ).toBeInTheConsole(); oco.userEvent.keyboard('[Enter]'); expect(await oco.findByText('Successfully committed')).toBeInTheConsole(); @@ -562,7 +574,9 @@ it('first run launches setup, saves config, and completes a commit with the conf gitDir, 'feat(setup): finish first run successfully' ); - expect(readFileSync(configPath, 'utf8')).toContain('OCO_AI_PROVIDER=openai'); + expect(readFileSync(configPath, 'utf8')).toContain( + 'OCO_AI_PROVIDER=openai' + ); expect(readFileSync(configPath, 'utf8')).toContain( 'OCO_API_KEY=first-run-openai-key' ); @@ -642,7 +656,9 @@ it('cli recovers from a missing model by prompting for an alternative and retryi oco.userEvent.keyboard('[Enter]'); expect(await oco.findByText('Model saved as default')).toBeInTheConsole(); - expect(await oco.findByText('Confirm the commit message?')).toBeInTheConsole(); + expect( + await oco.findByText('Confirm the commit message?') + ).toBeInTheConsole(); oco.userEvent.keyboard('[Enter]'); expect(await oco.findByText('Successfully committed')).toBeInTheConsole(); @@ -675,7 +691,8 @@ it('cli excludes lockfiles and assets from the generated prompt while still comm { 'kept.ts': 'console.log("kept");\n', 'package-lock.json': '{"name":"opencommit","lockfileVersion":3}\n', - 'logo.svg': '\n' + 'logo.svg': + '\n' }, { stage: true } ); @@ -685,7 +702,9 @@ it('cli excludes lockfiles and assets from the generated prompt while still comm env: getMockOpenAiEnv(server.baseUrl) }); - expect(await oco.findByText('Confirm the commit message?')).toBeInTheConsole(); + expect( + await oco.findByText('Confirm the commit message?') + ).toBeInTheConsole(); oco.userEvent.keyboard('[Enter]'); expect(await oco.findByText('Successfully committed')).toBeInTheConsole(); @@ -729,7 +748,9 @@ it('fails with a non-zero exit code outside a git repository', async () => { }); expect(await waitForExit(oco)).toBe(1); - expect(oco.getStdallStr()).toMatch(/No changes detected|not a git repository/); + expect(oco.getStdallStr()).toMatch( + /No changes detected|not a git repository/ + ); } finally { rmSync(tempDir, { force: true, recursive: true }); } diff --git a/test/e2e/geminiBehavior.test.ts b/test/e2e/geminiBehavior.test.ts new file mode 100644 index 00000000..c32441c6 --- /dev/null +++ b/test/e2e/geminiBehavior.test.ts @@ -0,0 +1,108 @@ +import 'cli-testing-library/extend-expect'; +import { + assertHeadCommit, + getHeadCommitMessage, + getMockGeminiEnv, + prepareEnvironment, + prepareRepo, + runCli, + startMockGeminiServer, + waitForExit +} from './utils'; + +it('built CLI ignores Gemini executable code parts when creating the commit message', async () => { + const { gitDir, cleanup } = await prepareEnvironment({ remotes: 0 }); + const server = await startMockGeminiServer({ + candidates: [ + { + index: 0, + content: { + role: 'model', + parts: [ + { text: 'feat(gemini): keep text output only' }, + { + executableCode: { + language: 'python', + code: 'print("debug")' + } + }, + { + codeExecutionResult: { + outcome: 'outcome_ok', + output: 'debug' + } + } + ] + }, + finishReason: 'STOP' + } + ] + }); + + try { + await prepareRepo( + gitDir, + { + 'index.ts': 'console.log("Hello World");\n' + }, + { stage: true } + ); + + const oco = await runCli(['--yes'], { + cwd: gitDir, + env: getMockGeminiEnv(server.baseUrl) + }); + + expect(await waitForExit(oco)).toBe(0); + await assertHeadCommit(gitDir, 'feat(gemini): keep text output only'); + expect(await getHeadCommitMessage(gitDir)).toBe( + 'feat(gemini): keep text output only' + ); + expect(server.apiKeys).toContain('test-gemini-key'); + } finally { + await server.cleanup(); + await cleanup(); + } +}); + +it('built CLI surfaces Gemini LANGUAGE finish reasons as errors', async () => { + const { gitDir, cleanup } = await prepareEnvironment({ remotes: 0 }); + const server = await startMockGeminiServer({ + candidates: [ + { + index: 0, + content: { + role: 'model', + parts: [{ text: 'feat(gemini): should not commit' }] + }, + finishReason: 'LANGUAGE', + finishMessage: 'Unsupported language' + } + ] + }); + + try { + await prepareRepo( + gitDir, + { + 'index.ts': 'console.log("Hello World");\n' + }, + { stage: true } + ); + + const oco = await runCli(['--yes'], { + cwd: gitDir, + env: getMockGeminiEnv(server.baseUrl) + }); + + expect( + await oco.findByText( + 'Gemini response was blocked due to LANGUAGE: Unsupported language' + ) + ).toBeInTheConsole(); + expect(await waitForExit(oco)).toBe(1); + } finally { + await server.cleanup(); + await cleanup(); + } +}); diff --git a/test/e2e/gitPush.test.ts b/test/e2e/gitPush.test.ts index 143ab868..5e1e95df 100644 --- a/test/e2e/gitPush.test.ts +++ b/test/e2e/gitPush.test.ts @@ -12,13 +12,6 @@ import { waitForExit } from './utils'; -const waitForCommitConfirmation = async ( - findByText: (text: string) => Promise -) => { - expect(await findByText('Generating the commit message')).toBeInTheConsole(); - expect(await findByText('Confirm the commit message?')).toBeInTheConsole(); -}; - describe('cli flow to push git branch', () => { it('does nothing when OCO_GITPUSH is set to false', async () => { const { gitDir, cleanup } = await prepareEnvironment({ remotes: 0 }); @@ -35,29 +28,13 @@ describe('cli flow to push git branch', () => { { stage: true } ); - const oco = await runCli([], { + const oco = await runCli(['--yes'], { cwd: gitDir, env: getMockOpenAiEnv(server.baseUrl, { OCO_GITPUSH: 'false' }) }); - await waitForCommitConfirmation(oco.findByText); - oco.userEvent.keyboard('[Enter]'); - - expect(await oco.findByText('Successfully committed')).toBeInTheConsole(); - expect( - await oco.queryByText('Choose a remote to push to') - ).not.toBeInTheConsole(); - expect( - await oco.queryByText('Do you want to run `git push`?') - ).not.toBeInTheConsole(); - expect( - await oco.queryByText('Successfully pushed all commits to origin') - ).not.toBeInTheConsole(); - expect( - await oco.queryByText('Command failed with exit code 1') - ).not.toBeInTheConsole(); expect(await waitForExit(oco)).toBe(0); await assertHeadCommit( gitDir, @@ -84,28 +61,13 @@ describe('cli flow to push git branch', () => { { stage: true } ); - const oco = await runCli([], { + const oco = await runCli(['--yes'], { cwd: gitDir, env: getMockOpenAiEnv(server.baseUrl, { OCO_GITPUSH: 'true' }) }); - await waitForCommitConfirmation(oco.findByText); - oco.userEvent.keyboard('[Enter]'); - - expect( - await oco.queryByText('Choose a remote to push to') - ).not.toBeInTheConsole(); - expect( - await oco.queryByText('Do you want to run `git push`?') - ).not.toBeInTheConsole(); - expect( - await oco.queryByText('Successfully pushed all commits to origin') - ).not.toBeInTheConsole(); - expect( - await oco.findByText('Command failed with exit code 1') - ).toBeInTheConsole(); expect(await waitForExit(oco)).toBe(1); await assertHeadCommit( gitDir, @@ -134,24 +96,18 @@ describe('cli flow to push git branch', () => { { stage: true } ); - const oco = await runCli([], { + const oco = await runCli(['--yes'], { cwd: gitDir, env: getMockOpenAiEnv(server.baseUrl, { OCO_GITPUSH: 'true' }) }); - await waitForCommitConfirmation(oco.findByText); - oco.userEvent.keyboard('[Enter]'); - expect( await oco.findByText('Do you want to run `git push`?') ).toBeInTheConsole(); oco.userEvent.keyboard('[Enter]'); - expect( - await oco.findByText('Successfully pushed all commits to origin') - ).toBeInTheConsole(); expect(await waitForExit(oco)).toBe(0); await assertHeadCommit( gitDir, @@ -186,22 +142,18 @@ describe('cli flow to push git branch', () => { { stage: true } ); - const oco = await runCli([], { + const oco = await runCli(['--yes'], { cwd: gitDir, env: getMockOpenAiEnv(server.baseUrl, { OCO_GITPUSH: 'true' }) }); - await waitForCommitConfirmation(oco.findByText); - oco.userEvent.keyboard('[Enter]'); - - expect(await oco.findByText('Choose a remote to push to')).toBeInTheConsole(); - oco.userEvent.keyboard('[Enter]'); - expect( - await oco.findByText('Successfully pushed all commits to origin') + await oco.findByText('Choose a remote to push to') ).toBeInTheConsole(); + oco.userEvent.keyboard('[Enter]'); + expect(await waitForExit(oco)).toBe(0); await assertHeadCommit( gitDir, @@ -235,22 +187,18 @@ describe('cli flow to push git branch', () => { { stage: true } ); - const oco = await runCli([], { + const oco = await runCli(['--yes'], { cwd: gitDir, env: getMockOpenAiEnv(server.baseUrl, { OCO_GITPUSH: 'true' }) }); - await waitForCommitConfirmation(oco.findByText); - oco.userEvent.keyboard('[Enter]'); - - expect(await oco.findByText('Choose a remote to push to')).toBeInTheConsole(); + expect( + await oco.findByText('Choose a remote to push to') + ).toBeInTheConsole(); oco.userEvent.keyboard('[ArrowDown][ArrowDown][Enter]'); - expect( - await oco.queryByText('Successfully pushed all commits to origin') - ).not.toBeInTheConsole(); expect(await waitForExit(oco)).toBe(0); await assertHeadCommit( gitDir, diff --git a/test/e2e/oneFile.test.ts b/test/e2e/oneFile.test.ts index 417a44bf..ee43f47d 100644 --- a/test/e2e/oneFile.test.ts +++ b/test/e2e/oneFile.test.ts @@ -27,7 +27,7 @@ it('cli flow to generate commit message for 1 new file (staged)', async () => { { stage: true } ); - const oco = await runCli([], { + const oco = await runCli(['--yes'], { cwd: gitDir, env: getMockOpenAiEnv(server.baseUrl, { OCO_GITPUSH: 'true' @@ -41,16 +41,11 @@ it('cli flow to generate commit message for 1 new file (staged)', async () => { ) ).not.toBeInTheConsole(); - expect(await oco.findByText('Generating the commit message')).toBeInTheConsole(); - expect(await oco.findByText('Confirm the commit message?')).toBeInTheConsole(); - oco.userEvent.keyboard('[Enter]'); - - expect(await oco.findByText('Do you want to run `git push`?')).toBeInTheConsole(); - oco.userEvent.keyboard('[Enter]'); - expect( - await oco.findByText('Successfully pushed all commits to origin') + await oco.findByText('Do you want to run `git push`?') ).toBeInTheConsole(); + oco.userEvent.keyboard('[Enter]'); + expect(await waitForExit(oco)).toBe(0); await assertHeadCommit( gitDir, @@ -87,7 +82,7 @@ it('cli flow to generate commit message for 1 changed file (not staged)', async ); appendRepoFile(gitDir, 'index.ts', 'console.log("Good night World");\n'); - const oco = await runCli([], { + const oco = await runCli(['--yes'], { cwd: gitDir, env: getMockOpenAiEnv(server.baseUrl, { OCO_GITPUSH: 'true' @@ -102,17 +97,16 @@ it('cli flow to generate commit message for 1 changed file (not staged)', async ).toBeInTheConsole(); oco.userEvent.keyboard('[Enter]'); - expect(await oco.findByText('Generating the commit message')).toBeInTheConsole(); - expect(await oco.findByText('Confirm the commit message?')).toBeInTheConsole(); - oco.userEvent.keyboard('[Enter]'); - - expect(await oco.findByText('Successfully committed')).toBeInTheConsole(); - expect(await oco.findByText('Do you want to run `git push`?')).toBeInTheConsole(); + expect( + await oco.findByText('Confirm the commit message?') + ).toBeInTheConsole(); oco.userEvent.keyboard('[Enter]'); expect( - await oco.findByText('Successfully pushed all commits to origin') + await oco.findByText('Do you want to run `git push`?') ).toBeInTheConsole(); + oco.userEvent.keyboard('[Enter]'); + expect(await waitForExit(oco)).toBe(0); await assertHeadCommit( gitDir, diff --git a/test/e2e/prompt-module/commitlint.test.ts b/test/e2e/prompt-module/commitlint.test.ts index e38032bb..9368c05e 100644 --- a/test/e2e/prompt-module/commitlint.test.ts +++ b/test/e2e/prompt-module/commitlint.test.ts @@ -29,10 +29,17 @@ const getPromptModuleEnv = ( }); async function setupCommitlint(dir: string, version: 9 | 18 | 19) { - cpSync(getFixturePath(version, 'node_modules'), path.join(dir, 'node_modules'), { - recursive: true - }); - cpSync(getFixturePath(version, 'package.json'), path.join(dir, 'package.json')); + cpSync( + getFixturePath(version, 'node_modules'), + path.join(dir, 'node_modules'), + { + recursive: true + } + ); + cpSync( + getFixturePath(version, 'package.json'), + path.join(dir, 'package.json') + ); cpSync( getFixturePath(version, 'commitlint.config.js'), path.join(dir, 'commitlint.config.js') @@ -71,7 +78,9 @@ describe('cli flow to run "oco commitlint force"', () => { await oco.findByText('Read @commitlint configuration') ).toBeInTheConsole(); expect( - await oco.findByText('Generating consistency with given @commitlint rules') + await oco.findByText( + 'Generating consistency with given @commitlint rules' + ) ).toBeInTheConsole(); expect( await oco.findByText('Done - please review contents of') @@ -101,7 +110,9 @@ describe('cli flow to run "oco commitlint force"', () => { await oco.findByText('Read @commitlint configuration') ).toBeInTheConsole(); expect( - await oco.findByText('Generating consistency with given @commitlint rules') + await oco.findByText( + 'Generating consistency with given @commitlint rules' + ) ).toBeInTheConsole(); expect( await oco.findByText('Done - please review contents of') @@ -131,7 +142,9 @@ describe('cli flow to run "oco commitlint force"', () => { await oco.findByText('Read @commitlint configuration') ).toBeInTheConsole(); expect( - await oco.findByText('Generating consistency with given @commitlint rules') + await oco.findByText( + 'Generating consistency with given @commitlint rules' + ) ).toBeInTheConsole(); expect( await oco.findByText('Done - please review contents of') @@ -183,7 +196,9 @@ describe('cli flow to generate commit message using @commitlint prompt-module', expect( await oco.findByText('Generating the commit message') ).toBeInTheConsole(); - expect(await oco.findByText('Confirm the commit message?')).toBeInTheConsole(); + expect( + await oco.findByText('Confirm the commit message?') + ).toBeInTheConsole(); oco.userEvent.keyboard('[Enter]'); expect( diff --git a/test/e2e/smoke.test.ts b/test/e2e/smoke.test.ts index 4f4308cd..78279544 100644 --- a/test/e2e/smoke.test.ts +++ b/test/e2e/smoke.test.ts @@ -10,7 +10,9 @@ it('prints help without entering the interactive flow', async () => { expect(await help.findByText('opencommit')).toBeInTheConsole(); expect(await help.findByText('--context')).toBeInTheConsole(); expect(await help.findByText('--yes')).toBeInTheConsole(); - expect(await help.queryByText('Select your AI provider:')).not.toBeInTheConsole(); + expect( + await help.queryByText('Select your AI provider:') + ).not.toBeInTheConsole(); expect(await help.queryByText('Enter your API key:')).not.toBeInTheConsole(); expect(await waitForExit(help)).toBe(0); }); @@ -21,6 +23,8 @@ it('prints the current version without booting the CLI runtime', async () => { }); expect(await version.findByText(packageJson.version)).toBeInTheConsole(); - expect(await version.queryByText('Generating the commit message')).not.toBeInTheConsole(); + expect( + await version.queryByText('Generating the commit message') + ).not.toBeInTheConsole(); expect(await waitForExit(version)).toBe(0); }); diff --git a/test/e2e/utils.ts b/test/e2e/utils.ts index 8ac935cf..c795d1a6 100644 --- a/test/e2e/utils.ts +++ b/test/e2e/utils.ts @@ -150,10 +150,10 @@ export const prepareRepo = async ( options.stage === true ? Object.keys(files) : Array.isArray(options.stage) - ? options.stage - : options.commitMessage - ? Object.keys(files) - : []; + ? options.stage + : options.commitMessage + ? Object.keys(files) + : []; if (stageFiles.length > 0) { await runGit(['add', ...stageFiles], gitDir); @@ -184,10 +184,7 @@ export const appendRepoFile = ( appendFileSync(filePath, content); }; -export const writeGlobalConfig = ( - homeDir: string, - lines: string[] -): string => { +export const writeGlobalConfig = (homeDir: string, lines: string[]): string => { const configPath = path.resolve(homeDir, '.opencommit'); writeFileSync(configPath, lines.join('\n')); return configPath; @@ -232,12 +229,24 @@ export const getMockOpenAiEnv = ( ...overrides }); +export const getMockGeminiEnv = ( + baseUrl: string, + overrides: NodeJS.ProcessEnv = {} +): NodeJS.ProcessEnv => ({ + OCO_AI_PROVIDER: 'gemini', + OCO_API_KEY: 'test-gemini-key', + OCO_MODEL: 'gemini-1.5-flash', + OCO_API_URL: baseUrl, + OCO_GITPUSH: 'false', + ...overrides +}); + export const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); export const waitForExit = async ( instance: RenderResult, - timeoutMs: number = 10_000 + timeoutMs: number = 20_000 ): Promise => { const startedAt = Date.now(); @@ -257,6 +266,11 @@ export const getHeadCommitSubject = async (gitDir: string): Promise => { return stdout.trim(); }; +export const getHeadCommitMessage = async (gitDir: string): Promise => { + const { stdout } = await runGit(['log', '-1', '--pretty=%B'], gitDir); + return stdout.trim(); +}; + export const getHeadCommitFiles = async (gitDir: string): Promise => { const { stdout } = await runGit( ['diff-tree', '--root', '--no-commit-id', '--name-only', '-r', 'HEAD'], @@ -286,7 +300,14 @@ export const getRemoteBranchHeadSubject = async ( ): Promise => { const { stdout = '' } = await fsExecFile( 'git', - ['--git-dir', remoteGitDir, 'log', '-1', '--pretty=%s', `refs/heads/${branchName}`], + [ + '--git-dir', + remoteGitDir, + 'log', + '-1', + '--pretty=%s', + `refs/heads/${branchName}` + ], { cwd: process.cwd() } ); @@ -439,3 +460,99 @@ export const startMockOpenAiServer = async ( }) }; }; + +export const startMockGeminiServer = async ( + response: + | Record + | ((request: { + apiKey?: string; + body: Record | undefined; + requestIndex: number; + }) => { + status?: number; + body: Record; + headers?: Record; + }) +): Promise<{ + apiKeys: string[]; + requestBodies: Array>; + baseUrl: string; + cleanup: () => Promise; +}> => { + const apiKeys: string[] = []; + const requestBodies: Array> = []; + + const server = http.createServer((req, res) => { + const apiKeyHeader = req.headers['x-goog-api-key']; + if (apiKeyHeader) { + apiKeys.push( + Array.isArray(apiKeyHeader) ? apiKeyHeader[0] : apiKeyHeader + ); + } + + const chunks: Buffer[] = []; + req.on('data', (chunk) => { + chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)); + }); + req.on('end', () => { + const rawBody = Buffer.concat(chunks).toString('utf8'); + let parsedBody: Record | undefined; + if (rawBody) { + try { + parsedBody = JSON.parse(rawBody); + requestBodies.push(parsedBody); + } catch { + requestBodies.push({ rawBody }); + } + } + + if (req.method === 'POST' && req.url?.includes(':generateContent')) { + const payload = + typeof response === 'function' + ? response({ + apiKey: Array.isArray(apiKeyHeader) + ? apiKeyHeader[0] + : apiKeyHeader, + body: parsedBody, + requestIndex: requestBodies.length - 1 + }) + : { + status: 200, + body: response + }; + + res.writeHead(payload.status ?? 200, { + 'Content-Type': 'application/json', + ...payload.headers + }); + res.end(JSON.stringify(payload.body)); + return; + } + + res.writeHead(404, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ error: 'not found' })); + }); + }); + + await new Promise((resolve) => { + server.listen(0, '127.0.0.1', () => resolve()); + }); + + const { port } = server.address() as AddressInfo; + + return { + apiKeys, + requestBodies, + baseUrl: `http://127.0.0.1:${port}`, + cleanup: () => + new Promise((resolve, reject) => { + server.close((error) => { + if (error) { + reject(error); + return; + } + resolve(); + }); + }) + }; +}; diff --git a/test/jest-setup.ts b/test/jest-setup.ts index e524b92d..bebceaf8 100644 --- a/test/jest-setup.ts +++ b/test/jest-setup.ts @@ -9,4 +9,4 @@ global.jest = jest; * CLI rendering gets noticeably slower under coverage and on CI, so keep a * slightly roomier timeout than the library default. */ -configure({ asyncUtilTimeout: 5000 }); +configure({ asyncUtilTimeout: 10000 }); diff --git a/test/unit/config.test.ts b/test/unit/config.test.ts index 5b3e44fc..6accb45a 100644 --- a/test/unit/config.test.ts +++ b/test/unit/config.test.ts @@ -122,14 +122,15 @@ describe('config', () => { expect(config.OCO_ONE_LINE_COMMIT).toEqual(false); expect(config.OCO_OMIT_SCOPE).toEqual(true); }); - + it('should handle custom HTTP headers correctly', async () => { globalConfigFile = await generateConfig('.opencommit', { OCO_API_CUSTOM_HEADERS: '{"X-Global-Header": "global-value"}' }); envConfigFile = await generateConfig('.env', { - OCO_API_CUSTOM_HEADERS: '{"Authorization": "Bearer token123", "X-Custom-Header": "test-value"}' + OCO_API_CUSTOM_HEADERS: + '{"Authorization": "Bearer token123", "X-Custom-Header": "test-value"}' }); const config = getConfig({ @@ -138,8 +139,11 @@ describe('config', () => { }); expect(config).not.toEqual(null); - expect(config.OCO_API_CUSTOM_HEADERS).toEqual({"Authorization": "Bearer token123", "X-Custom-Header": "test-value"}); - + expect(config.OCO_API_CUSTOM_HEADERS).toEqual({ + Authorization: 'Bearer token123', + 'X-Custom-Header': 'test-value' + }); + // No need to parse JSON again since it's already an object const parsedHeaders = config.OCO_API_CUSTOM_HEADERS; expect(parsedHeaders).toHaveProperty('Authorization', 'Bearer token123'); diff --git a/test/unit/gemini.test.ts b/test/unit/gemini.test.ts index ed1d6a94..dd5daa62 100644 --- a/test/unit/gemini.test.ts +++ b/test/unit/gemini.test.ts @@ -1,8 +1,9 @@ +import { FinishReason, Outcome } from '@google/generative-ai'; import { OpenAI } from 'openai'; import { GeminiEngine } from '../../src/engine/gemini'; describe('GeminiEngine', () => { - it('maps OpenAI-style chat messages into Gemini request payloads', async () => { + it('maps OpenAI-style chat messages into Gemini request payloads and ignores non-text parts', async () => { const engine = new GeminiEngine({ apiKey: 'mock-api-key', model: 'gemini-1.5-flash', @@ -13,7 +14,32 @@ describe('GeminiEngine', () => { const generateContent = jest.fn().mockResolvedValue({ response: { - text: () => 'feat(gemini): translate the diffhidden' + candidates: [ + { + index: 0, + content: { + role: 'model', + parts: [ + { + text: 'feat(gemini): translate the diffhidden' + }, + { + executableCode: { + language: 'python', + code: 'print("hidden")' + } + }, + { + codeExecutionResult: { + outcome: Outcome.OUTCOME_OK, + output: 'hidden' + } + } + ] + }, + finishReason: FinishReason.STOP + } + ] } }); const getGenerativeModel = jest.fn().mockReturnValue({ @@ -24,11 +50,12 @@ describe('GeminiEngine', () => { getGenerativeModel } as any; - const messages: Array = [ - { role: 'system', content: 'system message' }, - { role: 'assistant', content: 'assistant guidance' }, - { role: 'user', content: 'diff --git a/file b/file' } - ]; + const messages: Array = + [ + { role: 'system', content: 'system message' }, + { role: 'assistant', content: 'assistant guidance' }, + { role: 'user', content: 'diff --git a/file b/file' } + ]; const result = await engine.generateCommitMessage(messages); @@ -62,4 +89,45 @@ describe('GeminiEngine', () => { }) ); }); + + it('fails when Gemini reports a blocked finish reason', async () => { + const engine = new GeminiEngine({ + apiKey: 'mock-api-key', + model: 'gemini-1.5-flash', + baseURL: 'http://127.0.0.1:8080/v1', + maxTokensOutput: 256, + maxTokensInput: 4096 + }); + + const generateContent = jest.fn().mockResolvedValue({ + response: { + candidates: [ + { + index: 0, + content: { + role: 'model', + parts: [{ text: 'feat(gemini): should not pass' }] + }, + finishReason: FinishReason.LANGUAGE, + finishMessage: 'Unsupported language' + } + ] + } + }); + + engine.client = { + getGenerativeModel: jest.fn().mockReturnValue({ + generateContent + }) + } as any; + + await expect( + engine.generateCommitMessage([ + { role: 'system', content: 'system message' }, + { role: 'user', content: 'diff --git a/file b/file' } + ]) + ).rejects.toThrow( + 'Gemini response was blocked due to LANGUAGE: Unsupported language' + ); + }); }); diff --git a/test/unit/removeContentTags.test.ts b/test/unit/removeContentTags.test.ts index 96f28fa1..6c411c65 100644 --- a/test/unit/removeContentTags.test.ts +++ b/test/unit/removeContentTags.test.ts @@ -8,7 +8,8 @@ describe('removeContentTags', () => { }); it('should handle multiple tag occurrences', () => { - const content = 'hidden visible also hidden text'; + const content = + 'hidden visible also hidden text'; const result = removeContentTags(content, 'think'); expect(result).toBe('visible text'); }); @@ -26,7 +27,8 @@ describe('removeContentTags', () => { }); it('should work with different tag names', () => { - const content = 'This is something to hide visible content'; + const content = + 'This is something to hide visible content'; const result = removeContentTags(content, 'custom'); expect(result).toBe('This is visible content'); });