UNPKG

@flatfile/improv

Version:

A powerful TypeScript library for building AI agents with multi-threaded conversations, tool execution, and event handling capabilities

1 lines 2.27 MB
{"version":3,"sources":["../src/tracing/tracer.ts","../src/tracing/registry.ts","../src/tracing/index.ts","../node_modules/retry/lib/retry_operation.js","../node_modules/retry/lib/retry.js","../node_modules/retry/index.js","../node_modules/p-retry/index.js","../node_modules/eventemitter3/index.js","../node_modules/p-finally/index.js","../node_modules/p-timeout/index.js","../node_modules/p-queue/dist/lower-bound.js","../node_modules/p-queue/dist/priority-queue.js","../node_modules/p-queue/dist/index.js","../node_modules/langsmith/dist/singletons/fetch.cjs","../node_modules/langsmith/dist/utils/async_caller.cjs","../node_modules/langsmith/dist/utils/messages.cjs","../node_modules/langsmith/dist/utils/_uuid.cjs","../node_modules/langsmith/dist/utils/warn.cjs","../node_modules/semver/internal/constants.js","../node_modules/semver/internal/debug.js","../node_modules/semver/internal/re.js","../node_modules/semver/internal/parse-options.js","../node_modules/semver/internal/identifiers.js","../node_modules/semver/classes/semver.js","../node_modules/semver/functions/parse.js","../node_modules/semver/functions/valid.js","../node_modules/semver/functions/clean.js","../node_modules/semver/functions/inc.js","../node_modules/semver/functions/diff.js","../node_modules/semver/functions/major.js","../node_modules/semver/functions/minor.js","../node_modules/semver/functions/patch.js","../node_modules/semver/functions/prerelease.js","../node_modules/semver/functions/compare.js","../node_modules/semver/functions/rcompare.js","../node_modules/semver/functions/compare-loose.js","../node_modules/semver/functions/compare-build.js","../node_modules/semver/functions/sort.js","../node_modules/semver/functions/rsort.js","../node_modules/semver/functions/gt.js","../node_modules/semver/functions/lt.js","../node_modules/semver/functions/eq.js","../node_modules/semver/functions/neq.js","../node_modules/semver/functions/gte.js","../node_modules/semver/functions/lte.js","../node_modules/semver/functions/cmp.js","../node_modules/semver/functions/coerce.js","../node_modules/semver/internal/lrucache.js","../node_modules/semver/classes/range.js","../node_modules/semver/classes/comparator.js","../node_modules/semver/functions/satisfies.js","../node_modules/semver/ranges/to-comparators.js","../node_modules/semver/ranges/max-satisfying.js","../node_modules/semver/ranges/min-satisfying.js","../node_modules/semver/ranges/min-version.js","../node_modules/semver/ranges/valid.js","../node_modules/semver/ranges/outside.js","../node_modules/semver/ranges/gtr.js","../node_modules/semver/ranges/ltr.js","../node_modules/semver/ranges/intersects.js","../node_modules/semver/ranges/simplify.js","../node_modules/semver/ranges/subset.js","../node_modules/semver/index.js","../node_modules/langsmith/dist/utils/prompts.cjs","../node_modules/langsmith/dist/utils/error.cjs","../node_modules/langsmith/dist/utils/fast-safe-stringify/index.cjs","../node_modules/langsmith/dist/client.cjs","../node_modules/langsmith/dist/index.cjs","../node_modules/langsmith/dist/utils/env.cjs","../node_modules/langsmith/dist/env.cjs","../node_modules/langsmith/dist/singletons/constants.cjs","../node_modules/langsmith/dist/run_trees.cjs","../node_modules/langsmith/dist/singletons/traceable.cjs","../node_modules/langsmith/dist/utils/asserts.cjs","../node_modules/langsmith/dist/traceable.cjs","../node_modules/langsmith/traceable.cjs","../node_modules/ms/index.js","../node_modules/debug/src/common.js","../node_modules/debug/src/browser.js","../node_modules/has-flag/index.js","../node_modules/supports-color/index.js","../node_modules/debug/src/node.js","../node_modules/debug/src/index.js","../node_modules/@kwsites/file-exists/src/index.ts","../node_modules/@kwsites/file-exists/index.ts","../node_modules/@kwsites/promise-deferred/src/index.ts","../node_modules/simple-git/src/lib/args/pathspec.ts","../node_modules/simple-git/src/lib/errors/git-error.ts","../node_modules/simple-git/src/lib/errors/git-response-error.ts","../node_modules/simple-git/src/lib/errors/task-configuration-error.ts","../node_modules/simple-git/src/lib/utils/util.ts","../node_modules/simple-git/src/lib/utils/argument-filters.ts","../node_modules/simple-git/src/lib/utils/exit-codes.ts","../node_modules/simple-git/src/lib/utils/git-output-streams.ts","../node_modules/simple-git/src/lib/utils/line-parser.ts","../node_modules/simple-git/src/lib/utils/simple-git-options.ts","../node_modules/simple-git/src/lib/utils/task-options.ts","../node_modules/simple-git/src/lib/utils/task-parser.ts","../node_modules/simple-git/src/lib/utils/index.ts","../node_modules/simple-git/src/lib/tasks/check-is-repo.ts","../node_modules/simple-git/src/lib/responses/CleanSummary.ts","../node_modules/simple-git/src/lib/tasks/task.ts","../node_modules/simple-git/src/lib/tasks/clean.ts","../node_modules/simple-git/src/lib/responses/ConfigList.ts","../node_modules/simple-git/src/lib/tasks/config.ts","../node_modules/simple-git/src/lib/tasks/diff-name-status.ts","../node_modules/simple-git/src/lib/tasks/grep.ts","../node_modules/simple-git/src/lib/tasks/reset.ts","../node_modules/simple-git/src/lib/git-logger.ts","../node_modules/simple-git/src/lib/runners/tasks-pending-queue.ts","../node_modules/simple-git/src/lib/runners/git-executor-chain.ts","../node_modules/simple-git/src/lib/runners/git-executor.ts","../node_modules/simple-git/src/lib/task-callback.ts","../node_modules/simple-git/src/lib/tasks/change-working-directory.ts","../node_modules/simple-git/src/lib/tasks/checkout.ts","../node_modules/simple-git/src/lib/tasks/count-objects.ts","../node_modules/simple-git/src/lib/parsers/parse-commit.ts","../node_modules/simple-git/src/lib/tasks/commit.ts","../node_modules/simple-git/src/lib/tasks/first-commit.ts","../node_modules/simple-git/src/lib/tasks/hash-object.ts","../node_modules/simple-git/src/lib/responses/InitSummary.ts","../node_modules/simple-git/src/lib/tasks/init.ts","../node_modules/simple-git/src/lib/args/log-format.ts","../node_modules/simple-git/src/lib/responses/DiffSummary.ts","../node_modules/simple-git/src/lib/parsers/parse-diff-summary.ts","../node_modules/simple-git/src/lib/parsers/parse-list-log-summary.ts","../node_modules/simple-git/src/lib/tasks/diff.ts","../node_modules/simple-git/src/lib/tasks/log.ts","../node_modules/simple-git/src/lib/responses/MergeSummary.ts","../node_modules/simple-git/src/lib/responses/PullSummary.ts","../node_modules/simple-git/src/lib/parsers/parse-remote-objects.ts","../node_modules/simple-git/src/lib/parsers/parse-remote-messages.ts","../node_modules/simple-git/src/lib/parsers/parse-pull.ts","../node_modules/simple-git/src/lib/parsers/parse-merge.ts","../node_modules/simple-git/src/lib/tasks/merge.ts","../node_modules/simple-git/src/lib/parsers/parse-push.ts","../node_modules/simple-git/src/lib/tasks/push.ts","../node_modules/simple-git/src/lib/tasks/show.ts","../node_modules/simple-git/src/lib/responses/FileStatusSummary.ts","../node_modules/simple-git/src/lib/responses/StatusSummary.ts","../node_modules/simple-git/src/lib/tasks/status.ts","../node_modules/simple-git/src/lib/tasks/version.ts","../node_modules/simple-git/src/lib/simple-git-api.ts","../node_modules/simple-git/src/lib/runners/scheduler.ts","../node_modules/simple-git/src/lib/tasks/apply-patch.ts","../node_modules/simple-git/src/lib/responses/BranchDeleteSummary.ts","../node_modules/simple-git/src/lib/parsers/parse-branch-delete.ts","../node_modules/simple-git/src/lib/responses/BranchSummary.ts","../node_modules/simple-git/src/lib/parsers/parse-branch.ts","../node_modules/simple-git/src/lib/tasks/branch.ts","../node_modules/simple-git/src/lib/responses/CheckIgnore.ts","../node_modules/simple-git/src/lib/tasks/check-ignore.ts","../node_modules/simple-git/src/lib/tasks/clone.ts","../node_modules/simple-git/src/lib/parsers/parse-fetch.ts","../node_modules/simple-git/src/lib/tasks/fetch.ts","../node_modules/simple-git/src/lib/parsers/parse-move.ts","../node_modules/simple-git/src/lib/tasks/move.ts","../node_modules/simple-git/src/lib/tasks/pull.ts","../node_modules/simple-git/src/lib/responses/GetRemoteSummary.ts","../node_modules/simple-git/src/lib/tasks/remote.ts","../node_modules/simple-git/src/lib/tasks/stash-list.ts","../node_modules/simple-git/src/lib/tasks/sub-module.ts","../node_modules/simple-git/src/lib/responses/TagList.ts","../node_modules/simple-git/src/lib/tasks/tag.ts","../node_modules/simple-git/src/git.js","../node_modules/simple-git/src/lib/api.ts","../node_modules/simple-git/src/lib/errors/git-construct-error.ts","../node_modules/simple-git/src/lib/errors/git-plugin-error.ts","../node_modules/simple-git/src/lib/plugins/abort-plugin.ts","../node_modules/simple-git/src/lib/plugins/block-unsafe-operations-plugin.ts","../node_modules/simple-git/src/lib/plugins/command-config-prefixing-plugin.ts","../node_modules/simple-git/src/lib/plugins/completion-detection.plugin.ts","../node_modules/simple-git/src/lib/plugins/custom-binary.plugin.ts","../node_modules/simple-git/src/lib/plugins/error-detection.plugin.ts","../node_modules/simple-git/src/lib/plugins/plugin-store.ts","../node_modules/simple-git/src/lib/plugins/progress-monitor-plugin.ts","../node_modules/simple-git/src/lib/plugins/spawn-options-plugin.ts","../node_modules/simple-git/src/lib/plugins/timout-plugin.ts","../node_modules/simple-git/src/lib/plugins/suffix-paths.plugin.ts","../node_modules/simple-git/src/lib/git-factory.ts","../node_modules/simple-git/src/lib/runners/promise-wrapped.ts","../node_modules/simple-git/src/esm.mjs","../node_modules/@braintrust/core/dist/index.mjs","../node_modules/@asteasolutions/zod-to-openapi/dist/lib/zod-is-type.js","../node_modules/@asteasolutions/zod-to-openapi/dist/zod-extensions.js","../node_modules/@asteasolutions/zod-to-openapi/dist/lib/object-set.js","../node_modules/@asteasolutions/zod-to-openapi/dist/lib/lodash.js","../node_modules/@asteasolutions/zod-to-openapi/dist/openapi-metadata.js","../node_modules/@asteasolutions/zod-to-openapi/dist/openapi-registry.js","../node_modules/@asteasolutions/zod-to-openapi/dist/errors.js","../node_modules/@asteasolutions/zod-to-openapi/dist/lib/enum-info.js","../node_modules/@asteasolutions/zod-to-openapi/dist/openapi-generator.js","../node_modules/@asteasolutions/zod-to-openapi/dist/v3.0/specifics.js","../node_modules/@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator.js","../node_modules/@asteasolutions/zod-to-openapi/dist/v3.1/specifics.js","../node_modules/@asteasolutions/zod-to-openapi/dist/v3.1/openapi-generator.js","../node_modules/@asteasolutions/zod-to-openapi/dist/index.js","../node_modules/@braintrust/core/typespecs/dist/index.mjs","../node_modules/@vercel/functions/headers.js","../node_modules/@vercel/functions/get-env.js","../node_modules/@vercel/functions/get-context.js","../node_modules/@vercel/functions/wait-until.js","../node_modules/@vercel/functions/middleware.js","../node_modules/@vercel/functions/index.js","../node_modules/mustache/mustache.mjs","../node_modules/eventsource-parser/src/parse.ts","../node_modules/color-name/index.js","../node_modules/color-convert/conversions.js","../node_modules/color-convert/route.js","../node_modules/color-convert/index.js","../node_modules/ansi-styles/index.js","../node_modules/chalk/source/util.js","../node_modules/chalk/source/templates.js","../node_modules/chalk/source/index.js","../node_modules/pluralize/pluralize.js","../node_modules/cli-progress/lib/eta.js","../node_modules/cli-progress/lib/terminal.js","../node_modules/ansi-regex/index.js","../node_modules/strip-ansi/index.js","../node_modules/is-fullwidth-code-point/index.js","../node_modules/emoji-regex/index.js","../node_modules/string-width/index.js","../node_modules/cli-progress/lib/format-value.js","../node_modules/cli-progress/lib/format-bar.js","../node_modules/cli-progress/lib/format-time.js","../node_modules/cli-progress/lib/formatter.js","../node_modules/cli-progress/lib/options.js","../node_modules/cli-progress/lib/generic-bar.js","../node_modules/cli-progress/lib/single-bar.js","../node_modules/cli-progress/lib/multi-bar.js","../node_modules/cli-progress/presets/legacy.js","../node_modules/cli-progress/presets/shades-classic.js","../node_modules/cli-progress/presets/shades-grey.js","../node_modules/cli-progress/presets/rect.js","../node_modules/cli-progress/presets/index.js","../node_modules/cli-progress/cli-progress.js","../node_modules/slugify/slugify.js","../node_modules/braintrust/dist/index.mjs","../src/index.ts","../src/tool.ts","../src/event-source.ts","../src/message.ts","../src/decorators.ts","../src/thread.ts","../src/agent.ts","../src/agent.tool.ts","../src/evaluator.ts","../src/evaluators/three-keyed-lock.ts","../src/evaluators/agent-tool.evaluator.ts","../src/model.drivers/gemini.ts","../src/model.drivers/base.ts","../src/model.drivers/cohere.ts","../src/model.drivers/openai.ts","../src/model.drivers/bedrock.ts","../src/model.drivers/cerebras.ts","../src/model.drivers/huggingface.ts","../src/model.drivers/groq.ts","../src/model.drivers/anthropic.ts","../src/tracing/api.ts","../src/tracing/adapters/index.ts","../src/tracing/adapters/langsmith.ts","../src/tracing/adapters/braintrust.ts"],"sourcesContent":["/**\n * Interface for tracing function executions in Improv\n */\nexport interface Tracer {\n /**\n * Trace a function execution\n * @param fn The function to trace\n * @param metadata Metadata about the trace\n * @returns The wrapped function that will be traced\n */\n traceable<T extends (...args: any[]) => any>(\n fn: T,\n metadata: TraceMetadata\n ): T;\n}\n\n/**\n * Metadata for a trace\n */\nexport interface TraceMetadata {\n /** The name of the trace */\n name: string;\n /** The type of run (e.g., \"tool\", \"llm\", \"agent\") */\n run_type?: string;\n /** Any additional metadata */\n [key: string]: unknown;\n}\n\n/**\n * A tracer that does nothing\n */\nexport class NullTracer implements Tracer {\n traceable<T extends (...args: any[]) => any>(fn: T, _metadata: TraceMetadata): T {\n // Simply returns the original function without any tracing\n return fn;\n }\n}\n\n// The default tracer does nothing\nexport const defaultTracer = new NullTracer(); ","import { Tracer, defaultTracer } from \"./tracer\";\n\n/**\n * Registry for managing tracers in the system\n */\nexport class TracerRegistry {\n private static instance: TracerRegistry;\n private tracers: Map<string, Tracer> = new Map();\n private activeTracer: string = \"null\";\n\n private constructor() {\n // Register the default null tracer\n this.register(\"null\", defaultTracer);\n }\n\n /**\n * Get the singleton instance of the registry\n */\n public static getInstance(): TracerRegistry {\n if (!TracerRegistry.instance) {\n TracerRegistry.instance = new TracerRegistry();\n }\n return TracerRegistry.instance;\n }\n\n /**\n * Register a tracer with the registry\n * @param name Name of the tracer\n * @param tracer The tracer implementation\n */\n public register(name: string, tracer: Tracer): void {\n this.tracers.set(name, tracer);\n }\n\n /**\n * Set the active tracer by name\n * @param name Name of the tracer to activate\n * @throws Error if the tracer doesn't exist\n */\n public setActiveTracer(name: string): void {\n if (!this.tracers.has(name)) {\n throw new Error(`Tracer '${name}' is not registered`);\n }\n this.activeTracer = name;\n }\n\n /**\n * Get the currently active tracer\n */\n public getActiveTracer(): Tracer {\n return this.tracers.get(this.activeTracer) || defaultTracer;\n }\n\n /**\n * Check if tracing is enabled (i.e., active tracer is not the null tracer)\n */\n public isTracingEnabled(): boolean {\n return this.activeTracer !== \"null\";\n }\n}\n\n// Export a convenience function to get the active tracer\nexport function getTracer(): Tracer {\n return TracerRegistry.getInstance().getActiveTracer();\n}\n\n// Export a convenience function to check if tracing is enabled\nexport function isTracingEnabled(): boolean {\n return TracerRegistry.getInstance().isTracingEnabled();\n} ","import { Tracer, TraceMetadata, NullTracer, defaultTracer } from \"./tracer\";\nimport { TracerRegistry, getTracer, isTracingEnabled } from \"./registry\";\n\n/**\n * Make a function traceable using the currently active tracer\n * \n * @param fn The function to trace\n * @param metadata Metadata about the trace\n * @returns The traced function\n */\nexport function traceable<T extends (...args: any[]) => any>(\n fn: T,\n metadata: TraceMetadata\n): T {\n // Only trace if tracing is enabled\n if (!isTracingEnabled()) {\n return fn;\n }\n\n // Get the active tracer and trace the function\n return getTracer().traceable(fn, metadata);\n}\n\n// Export everything from the tracer module\nexport { NullTracer, defaultTracer, TracerRegistry, getTracer, isTracingEnabled };\nexport type { Tracer, TraceMetadata }; ","function RetryOperation(timeouts, options) {\n // Compatibility for the old (timeouts, retryForever) signature\n if (typeof options === 'boolean') {\n options = { forever: options };\n }\n\n this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));\n this._timeouts = timeouts;\n this._options = options || {};\n this._maxRetryTime = options && options.maxRetryTime || Infinity;\n this._fn = null;\n this._errors = [];\n this._attempts = 1;\n this._operationTimeout = null;\n this._operationTimeoutCb = null;\n this._timeout = null;\n this._operationStart = null;\n this._timer = null;\n\n if (this._options.forever) {\n this._cachedTimeouts = this._timeouts.slice(0);\n }\n}\nmodule.exports = RetryOperation;\n\nRetryOperation.prototype.reset = function() {\n this._attempts = 1;\n this._timeouts = this._originalTimeouts.slice(0);\n}\n\nRetryOperation.prototype.stop = function() {\n if (this._timeout) {\n clearTimeout(this._timeout);\n }\n if (this._timer) {\n clearTimeout(this._timer);\n }\n\n this._timeouts = [];\n this._cachedTimeouts = null;\n};\n\nRetryOperation.prototype.retry = function(err) {\n if (this._timeout) {\n clearTimeout(this._timeout);\n }\n\n if (!err) {\n return false;\n }\n var currentTime = new Date().getTime();\n if (err && currentTime - this._operationStart >= this._maxRetryTime) {\n this._errors.push(err);\n this._errors.unshift(new Error('RetryOperation timeout occurred'));\n return false;\n }\n\n this._errors.push(err);\n\n var timeout = this._timeouts.shift();\n if (timeout === undefined) {\n if (this._cachedTimeouts) {\n // retry forever, only keep last error\n this._errors.splice(0, this._errors.length - 1);\n timeout = this._cachedTimeouts.slice(-1);\n } else {\n return false;\n }\n }\n\n var self = this;\n this._timer = setTimeout(function() {\n self._attempts++;\n\n if (self._operationTimeoutCb) {\n self._timeout = setTimeout(function() {\n self._operationTimeoutCb(self._attempts);\n }, self._operationTimeout);\n\n if (self._options.unref) {\n self._timeout.unref();\n }\n }\n\n self._fn(self._attempts);\n }, timeout);\n\n if (this._options.unref) {\n this._timer.unref();\n }\n\n return true;\n};\n\nRetryOperation.prototype.attempt = function(fn, timeoutOps) {\n this._fn = fn;\n\n if (timeoutOps) {\n if (timeoutOps.timeout) {\n this._operationTimeout = timeoutOps.timeout;\n }\n if (timeoutOps.cb) {\n this._operationTimeoutCb = timeoutOps.cb;\n }\n }\n\n var self = this;\n if (this._operationTimeoutCb) {\n this._timeout = setTimeout(function() {\n self._operationTimeoutCb();\n }, self._operationTimeout);\n }\n\n this._operationStart = new Date().getTime();\n\n this._fn(this._attempts);\n};\n\nRetryOperation.prototype.try = function(fn) {\n console.log('Using RetryOperation.try() is deprecated');\n this.attempt(fn);\n};\n\nRetryOperation.prototype.start = function(fn) {\n console.log('Using RetryOperation.start() is deprecated');\n this.attempt(fn);\n};\n\nRetryOperation.prototype.start = RetryOperation.prototype.try;\n\nRetryOperation.prototype.errors = function() {\n return this._errors;\n};\n\nRetryOperation.prototype.attempts = function() {\n return this._attempts;\n};\n\nRetryOperation.prototype.mainError = function() {\n if (this._errors.length === 0) {\n return null;\n }\n\n var counts = {};\n var mainError = null;\n var mainErrorCount = 0;\n\n for (var i = 0; i < this._errors.length; i++) {\n var error = this._errors[i];\n var message = error.message;\n var count = (counts[message] || 0) + 1;\n\n counts[message] = count;\n\n if (count >= mainErrorCount) {\n mainError = error;\n mainErrorCount = count;\n }\n }\n\n return mainError;\n};\n","var RetryOperation = require('./retry_operation');\n\nexports.operation = function(options) {\n var timeouts = exports.timeouts(options);\n return new RetryOperation(timeouts, {\n forever: options && (options.forever || options.retries === Infinity),\n unref: options && options.unref,\n maxRetryTime: options && options.maxRetryTime\n });\n};\n\nexports.timeouts = function(options) {\n if (options instanceof Array) {\n return [].concat(options);\n }\n\n var opts = {\n retries: 10,\n factor: 2,\n minTimeout: 1 * 1000,\n maxTimeout: Infinity,\n randomize: false\n };\n for (var key in options) {\n opts[key] = options[key];\n }\n\n if (opts.minTimeout > opts.maxTimeout) {\n throw new Error('minTimeout is greater than maxTimeout');\n }\n\n var timeouts = [];\n for (var i = 0; i < opts.retries; i++) {\n timeouts.push(this.createTimeout(i, opts));\n }\n\n if (options && options.forever && !timeouts.length) {\n timeouts.push(this.createTimeout(i, opts));\n }\n\n // sort the array numerically ascending\n timeouts.sort(function(a,b) {\n return a - b;\n });\n\n return timeouts;\n};\n\nexports.createTimeout = function(attempt, opts) {\n var random = (opts.randomize)\n ? (Math.random() + 1)\n : 1;\n\n var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));\n timeout = Math.min(timeout, opts.maxTimeout);\n\n return timeout;\n};\n\nexports.wrap = function(obj, options, methods) {\n if (options instanceof Array) {\n methods = options;\n options = null;\n }\n\n if (!methods) {\n methods = [];\n for (var key in obj) {\n if (typeof obj[key] === 'function') {\n methods.push(key);\n }\n }\n }\n\n for (var i = 0; i < methods.length; i++) {\n var method = methods[i];\n var original = obj[method];\n\n obj[method] = function retryWrapper(original) {\n var op = exports.operation(options);\n var args = Array.prototype.slice.call(arguments, 1);\n var callback = args.pop();\n\n args.push(function(err) {\n if (op.retry(err)) {\n return;\n }\n if (err) {\n arguments[0] = op.mainError();\n }\n callback.apply(this, arguments);\n });\n\n op.attempt(function() {\n original.apply(obj, args);\n });\n }.bind(obj, original);\n obj[method].options = options;\n }\n};\n","module.exports = require('./lib/retry');","'use strict';\nconst retry = require('retry');\n\nconst networkErrorMsgs = [\n\t'Failed to fetch', // Chrome\n\t'NetworkError when attempting to fetch resource.', // Firefox\n\t'The Internet connection appears to be offline.', // Safari\n\t'Network request failed' // `cross-fetch`\n];\n\nclass AbortError extends Error {\n\tconstructor(message) {\n\t\tsuper();\n\n\t\tif (message instanceof Error) {\n\t\t\tthis.originalError = message;\n\t\t\t({message} = message);\n\t\t} else {\n\t\t\tthis.originalError = new Error(message);\n\t\t\tthis.originalError.stack = this.stack;\n\t\t}\n\n\t\tthis.name = 'AbortError';\n\t\tthis.message = message;\n\t}\n}\n\nconst decorateErrorWithCounts = (error, attemptNumber, options) => {\n\t// Minus 1 from attemptNumber because the first attempt does not count as a retry\n\tconst retriesLeft = options.retries - (attemptNumber - 1);\n\n\terror.attemptNumber = attemptNumber;\n\terror.retriesLeft = retriesLeft;\n\treturn error;\n};\n\nconst isNetworkError = errorMessage => networkErrorMsgs.includes(errorMessage);\n\nconst pRetry = (input, options) => new Promise((resolve, reject) => {\n\toptions = {\n\t\tonFailedAttempt: () => {},\n\t\tretries: 10,\n\t\t...options\n\t};\n\n\tconst operation = retry.operation(options);\n\n\toperation.attempt(async attemptNumber => {\n\t\ttry {\n\t\t\tresolve(await input(attemptNumber));\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof Error)) {\n\t\t\t\treject(new TypeError(`Non-error was thrown: \"${error}\". You should only throw errors.`));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (error instanceof AbortError) {\n\t\t\t\toperation.stop();\n\t\t\t\treject(error.originalError);\n\t\t\t} else if (error instanceof TypeError && !isNetworkError(error.message)) {\n\t\t\t\toperation.stop();\n\t\t\t\treject(error);\n\t\t\t} else {\n\t\t\t\tdecorateErrorWithCounts(error, attemptNumber, options);\n\n\t\t\t\ttry {\n\t\t\t\t\tawait options.onFailedAttempt(error);\n\t\t\t\t} catch (error) {\n\t\t\t\t\treject(error);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (!operation.retry(error)) {\n\t\t\t\t\treject(operation.mainError());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n});\n\nmodule.exports = pRetry;\n// TODO: remove this in the next major version\nmodule.exports.default = pRetry;\n\nmodule.exports.AbortError = AbortError;\n","'use strict';\n\nvar has = Object.prototype.hasOwnProperty\n , prefix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n Events.prototype = Object.create(null);\n\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @private\n */\nfunction EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n\n/**\n * Add a listener for a given event.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} once Specify if the listener is a one-time listener.\n * @returns {EventEmitter}\n * @private\n */\nfunction addListener(emitter, event, fn, context, once) {\n if (typeof fn !== 'function') {\n throw new TypeError('The listener must be a function');\n }\n\n var listener = new EE(fn, context || emitter, once)\n , evt = prefix ? prefix + event : event;\n\n if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;\n else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);\n else emitter._events[evt] = [emitter._events[evt], listener];\n\n return emitter;\n}\n\n/**\n * Clear event by name.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} evt The Event name.\n * @private\n */\nfunction clearEvent(emitter, evt) {\n if (--emitter._eventsCount === 0) emitter._events = new Events();\n else delete emitter._events[evt];\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @public\n */\nfunction EventEmitter() {\n this._events = new Events();\n this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n var names = []\n , events\n , name;\n\n if (this._eventsCount === 0) return names;\n\n for (name in (events = this._events)) {\n if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n }\n\n if (Object.getOwnPropertySymbols) {\n return names.concat(Object.getOwnPropertySymbols(events));\n }\n\n return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Array} The registered listeners.\n * @public\n */\nEventEmitter.prototype.listeners = function listeners(event) {\n var evt = prefix ? prefix + event : event\n , handlers = this._events[evt];\n\n if (!handlers) return [];\n if (handlers.fn) return [handlers.fn];\n\n for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {\n ee[i] = handlers[i].fn;\n }\n\n return ee;\n};\n\n/**\n * Return the number of listeners listening to a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Number} The number of listeners.\n * @public\n */\nEventEmitter.prototype.listenerCount = function listenerCount(event) {\n var evt = prefix ? prefix + event : event\n , listeners = this._events[evt];\n\n if (!listeners) return 0;\n if (listeners.fn) return 1;\n return listeners.length;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return false;\n\n var listeners = this._events[evt]\n , len = arguments.length\n , args\n , i;\n\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n switch (len) {\n case 1: return listeners.fn.call(listeners.context), true;\n case 2: return listeners.fn.call(listeners.context, a1), true;\n case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n\n for (i = 1, args = new Array(len -1); i < len; i++) {\n args[i - 1] = arguments[i];\n }\n\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length\n , j;\n\n for (i = 0; i < length; i++) {\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n switch (len) {\n case 1: listeners[i].fn.call(listeners[i].context); break;\n case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n default:\n if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n args[j - 1] = arguments[j];\n }\n\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n\n return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n return addListener(this, event, fn, context, false);\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n return addListener(this, event, fn, context, true);\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {*} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return this;\n if (!fn) {\n clearEvent(this, evt);\n return this;\n }\n\n var listeners = this._events[evt];\n\n if (listeners.fn) {\n if (\n listeners.fn === fn &&\n (!once || listeners.once) &&\n (!context || listeners.context === context)\n ) {\n clearEvent(this, evt);\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (\n listeners[i].fn !== fn ||\n (once && !listeners[i].once) ||\n (context && listeners[i].context !== context)\n ) {\n events.push(listeners[i]);\n }\n }\n\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else clearEvent(this, evt);\n }\n\n return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {(String|Symbol)} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n\n if (event) {\n evt = prefix ? prefix + event : event;\n if (this._events[evt]) clearEvent(this, evt);\n } else {\n this._events = new Events();\n this._eventsCount = 0;\n }\n\n return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n module.exports = EventEmitter;\n}\n","'use strict';\nmodule.exports = (promise, onFinally) => {\n\tonFinally = onFinally || (() => {});\n\n\treturn promise.then(\n\t\tval => new Promise(resolve => {\n\t\t\tresolve(onFinally());\n\t\t}).then(() => val),\n\t\terr => new Promise(resolve => {\n\t\t\tresolve(onFinally());\n\t\t}).then(() => {\n\t\t\tthrow err;\n\t\t})\n\t);\n};\n","'use strict';\n\nconst pFinally = require('p-finally');\n\nclass TimeoutError extends Error {\n\tconstructor(message) {\n\t\tsuper(message);\n\t\tthis.name = 'TimeoutError';\n\t}\n}\n\nconst pTimeout = (promise, milliseconds, fallback) => new Promise((resolve, reject) => {\n\tif (typeof milliseconds !== 'number' || milliseconds < 0) {\n\t\tthrow new TypeError('Expected `milliseconds` to be a positive number');\n\t}\n\n\tif (milliseconds === Infinity) {\n\t\tresolve(promise);\n\t\treturn;\n\t}\n\n\tconst timer = setTimeout(() => {\n\t\tif (typeof fallback === 'function') {\n\t\t\ttry {\n\t\t\t\tresolve(fallback());\n\t\t\t} catch (error) {\n\t\t\t\treject(error);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst message = typeof fallback === 'string' ? fallback : `Promise timed out after ${milliseconds} milliseconds`;\n\t\tconst timeoutError = fallback instanceof Error ? fallback : new TimeoutError(message);\n\n\t\tif (typeof promise.cancel === 'function') {\n\t\t\tpromise.cancel();\n\t\t}\n\n\t\treject(timeoutError);\n\t}, milliseconds);\n\n\t// TODO: Use native `finally` keyword when targeting Node.js 10\n\tpFinally(\n\t\t// eslint-disable-next-line promise/prefer-await-to-then\n\t\tpromise.then(resolve, reject),\n\t\t() => {\n\t\t\tclearTimeout(timer);\n\t\t}\n\t);\n});\n\nmodule.exports = pTimeout;\n// TODO: Remove this for the next major release\nmodule.exports.default = pTimeout;\n\nmodule.exports.TimeoutError = TimeoutError;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n// Port of lower_bound from https://en.cppreference.com/w/cpp/algorithm/lower_bound\n// Used to compute insertion index to keep queue sorted after insertion\nfunction lowerBound(array, value, comparator) {\n let first = 0;\n let count = array.length;\n while (count > 0) {\n const step = (count / 2) | 0;\n let it = first + step;\n if (comparator(array[it], value) <= 0) {\n first = ++it;\n count -= step + 1;\n }\n else {\n count = step;\n }\n }\n return first;\n}\nexports.default = lowerBound;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst lower_bound_1 = require(\"./lower-bound\");\nclass PriorityQueue {\n constructor() {\n this._queue = [];\n }\n enqueue(run, options) {\n options = Object.assign({ priority: 0 }, options);\n const element = {\n priority: options.priority,\n run\n };\n if (this.size && this._queue[this.size - 1].priority >= options.priority) {\n this._queue.push(element);\n return;\n }\n const index = lower_bound_1.default(this._queue, element, (a, b) => b.priority - a.priority);\n this._queue.splice(index, 0, element);\n }\n dequeue() {\n const item = this._queue.shift();\n return item === null || item === void 0 ? void 0 : item.run;\n }\n filter(options) {\n return this._queue.filter((element) => element.priority === options.priority).map((element) => element.run);\n }\n get size() {\n return this._queue.length;\n }\n}\nexports.default = PriorityQueue;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst EventEmitter = require(\"eventemitter3\");\nconst p_timeout_1 = require(\"p-timeout\");\nconst priority_queue_1 = require(\"./priority-queue\");\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst empty = () => { };\nconst timeoutError = new p_timeout_1.TimeoutError();\n/**\nPromise queue with concurrency control.\n*/\nclass PQueue extends EventEmitter {\n constructor(options) {\n var _a, _b, _c, _d;\n super();\n this._intervalCount = 0;\n this._intervalEnd = 0;\n this._pendingCount = 0;\n this._resolveEmpty = empty;\n this._resolveIdle = empty;\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n options = Object.assign({ carryoverConcurrencyCount: false, intervalCap: Infinity, interval: 0, concurrency: Infinity, autoStart: true, queueClass: priority_queue_1.default }, options);\n if (!(typeof options.intervalCap === 'number' && options.intervalCap >= 1)) {\n throw new TypeError(`Expected \\`intervalCap\\` to be a number from 1 and up, got \\`${(_b = (_a = options.intervalCap) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ''}\\` (${typeof options.intervalCap})`);\n }\n if (options.interval === undefined || !(Number.isFinite(options.interval) && options.interval >= 0)) {\n throw new TypeError(`Expected \\`interval\\` to be a finite number >= 0, got \\`${(_d = (_c = options.interval) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : ''}\\` (${typeof options.interval})`);\n }\n this._carryoverConcurrencyCount = options.carryoverConcurrencyCount;\n this._isIntervalIgnored = options.intervalCap === Infinity || options.interval === 0;\n this._intervalCap = options.intervalCap;\n this._interval = options.interval;\n this._queue = new options.queueClass();\n this._queueClass = options.queueClass;\n this.concurrency = options.concurrency;\n this._timeout = options.timeout;\n this._throwOnTimeout = options.throwOnTimeout === true;\n this._isPaused = options.autoStart === false;\n }\n get _doesIntervalAllowAnother() {\n return this._isIntervalIgnored || this._intervalCount < this._intervalCap;\n }\n get _doesConcurrentAllowAnother() {\n return this._pendingCount < this._concurrency;\n }\n _next() {\n this._pendingCount--;\n this._tryToStartAnother();\n this.emit('next');\n }\n _resolvePromises() {\n this._resolveEmpty();\n this._resolveEmpty = empty;\n if (this._pendingCount === 0) {\n this._resolveIdle();\n this._resolveIdle = empty;\n this.emit('idle');\n }\n }\n _onResumeInterval() {\n this._onInterval();\n this._initializeIntervalIfNeeded();\n this._timeoutId = undefined;\n }\n _isIntervalPaused() {\n const now = Date.now();\n if (this._intervalId === undefined) {\n const delay = this._intervalEnd - now;\n if (delay < 0) {\n // Act as the interval was done\n // We don't need to resume it here because it will be resumed on line 160\n this._intervalCount = (this._carryoverConcurrencyCount) ? this._pendingCount : 0;\n }\n else {\n // Act as the interval is pending\n if (this._timeoutId === undefined) {\n this._timeoutId = setTimeout(() => {\n this._onResumeInterval();\n }, delay);\n }\n return true;\n }\n }\n return false;\n }\n _tryToStartAnother() {\n if (this._queue.size === 0) {\n // We can clear the interval (\"pause\")\n // Because we can redo it later (\"resume\")\n if (this._intervalId) {\n clearInterval(this._intervalId);\n }\n this._intervalId = undefined;\n this._resolvePromises();\n return false;\n }\n if (!this._isPaused) {\n const canInitializeInterval = !this._isIntervalPaused();\n if (this._doesIntervalAllowAnother && this._doesConcurrentAllowAnother) {\n const job = this._queue.dequeue();\n if (!job) {\n return false;\n }\n this.emit('active');\n job();\n if (canInitializeInterval) {\n this._initializeIntervalIfNeeded();\n }\n return true;\n }\n }\n return false;\n }\n _initializeIntervalIfNeeded() {\n if (this._isIntervalIgnored || this._intervalId !== undefined) {\n return;\n }\n this._intervalId = setInterval(() => {\n this._onInterval();\n }, this._interval);\n this._intervalEnd = Date.now() + this._interval;\n }\n _onInterval() {\n if (this._intervalCount === 0 && this._pendingCount === 0 && this._intervalId) {\n clearInterval(this._intervalId);\n this._intervalId = undefined;\n }\n this._intervalCount = this._carryoverConcurrencyCount ? this._pendingCount : 0;\n this._processQueue();\n }\n /**\n Executes all queued functions until it reaches the limit.\n */\n _processQueue() {\n // eslint-disable-next-line no-empty\n while (this._tryToStartAnother()) { }\n }\n get concurrency() {\n return this._concurrency;\n }\n set concurrency(newConcurrency) {\n if (!(typeof newConcurrency === 'number' && newConcurrency >= 1)) {\n throw new TypeError(`Expected \\`concurrency\\` to be a number from 1 and up, got \\`${newConcurrency}\\` (${typeof newConcurrency})`);\n }\n this._concurrency = newConcurrency;\n this._processQueue();\n }\n /**\n Adds a sync or async task to the queue. Always returns a promise.\n */\n async add(fn, options = {}) {\n return new Promise((resolve, reject) => {\n const run = async () => {\n this._pendingCount++;\n this._intervalCount++;\n try {\n const operation = (this._timeout === undefined && options.timeout === undefined) ? fn() : p_timeout_1.default(Promise.resolve(fn()), (options.timeout === undefined ? this._timeout : options.timeout), () => {\n if (options.throwOnTimeout === undefined ? this._throwOnTimeout : options.throwOnTimeout) {\n reject(timeoutError);\n }\n return undefined;\n });\n resolve(await operation);\n }\n catch (error) {\n reject(error);\n }\n this._next();\n };\n this._queue.enqueue(run, options);\n this._tryToStartAnother();\n this.emit('add');\n });\n }\n /**\n Same as `.add()`, but accepts an array of sync or async functions.\n\n @returns A promise that resolves when all functions are resolved.\n */\n async addAll(functions, options) {\n return Promise.all(functions.map(async (function_) => this.add(function_, options)));\n }\n /**\n Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)\n */\n start() {\n if (!this._isPaused) {\n return this;\n }\n this._isPaused = false;\n this._processQueue();\n return this;\n }\n /**\n Put queue execution on hold.\n */\n pause() {\n this._isPaused = true;\n }\n /**\n Clear the queue.\n */\n clear() {\n this._queue = new this._queueClass();\n }\n /**\n Can be called multiple times. Useful if you for example add additional items at a later time.\n\n @returns A promise that settles when the queue becomes empty.\n */\n async onEmpty() {\n // Instantly resolve if the queue is empty\n if (this._queue.size === 0) {\n return;\n }\n return new Promise(resolve => {\n const existingResolve = this._resolveEmpty;\n this._resolveEmpty = () => {\n existingResolve();\n resolve();\n };\n });\n }\n /**\n The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.\n\n @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.\n */\n async onIdle() {\n // Instantly resolve if none pending and if nothing else is queued\n if (this._pendingCount === 0 && this._queue.size === 0) {\n return;\n }\n return new Promise(resolve => {\n const existingResolve = this._resolveIdle;\n this._resolveIdle = () => {\n existingResolve();\n resolve();\n };\n });\n }\n /**\n Size of the queue.\n */\n get size() {\n return this._queue.size;\n }\n /**\n Size of the queue, filtered by the given options.\n\n For example, this can be used to find the number of items remaining in the queue with a specific priority level.\n */\n sizeBy(options) {\n // eslint-disable-next-line unicorn/no-fn-reference-in-iterator\n return this._queue.filter(options).length;\n }\n /**\n Number of pending promises.\n */\n get pending() {\n return this._pendingCount;\n }\n /**\n Whether the queue is currently paused.\n */\n get isPaused() {\n return this._isPaused;\n }\n get timeout() {\n return this._timeout;\n }\n /**\n Set the timeout for future operations.\n */\n set timeout(milliseconds) {\n this._timeout = milliseconds;\n }\n}\nexports.default = PQueue;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports._getFetchImplementation = exports.overrideFetchImplementation = void 0;\n// Wrap the default fetch call due to issues with illegal invocations\n// in some environments:\n// https://stackoverflow.com/questions/69876859/why-does-bind-fix-failed-to-execute-fetch-on-window-illegal-invocation-err\n// @ts-expect-error Broad typing to support a range of fetch implementations\nconst DEFAULT_FETCH_IMPLEMENTATION = (...args) => fetch(...args);\nconst LANGSMITH_FETCH_IMPLEMENTATION_KEY = Symbol.for(\"ls:fetch_implementation\");\n/**\n * Overrides the fetch implementation used for LangSmith calls.\n * You should use this if you need to use an implementation of fetch\n * other than the default global (e.g. for dealin