modelmix 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +2 -0
- package/README.md +147 -0
- package/demo/default.env +3 -0
- package/demo/demo.mjs +49 -0
- package/demo/node_modules/.package-lock.json +272 -0
- package/demo/node_modules/@anthropic-ai/sdk/CHANGELOG.md +859 -0
- package/demo/node_modules/@anthropic-ai/sdk/LICENSE +8 -0
- package/demo/node_modules/@anthropic-ai/sdk/README.md +424 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/MultipartBody.d.ts +9 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/MultipartBody.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/MultipartBody.js +16 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/MultipartBody.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/MultipartBody.mjs +12 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/MultipartBody.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/README.md +46 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-bun.d.ts +5 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-bun.js +21 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-bun.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-bun.mjs +2 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-bun.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-node.d.ts +5 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-node.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-node.js +21 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-node.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-node.mjs +2 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime-node.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime.d.ts +5 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime.js +21 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime.mjs +2 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/runtime.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types-node.d.ts +5 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types-node.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types-node.js +21 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types-node.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types-node.mjs +2 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types-node.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types.d.ts +101 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types.js +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/auto/types.mjs +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/bun-runtime.d.ts +6 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/bun-runtime.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/bun-runtime.js +14 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/bun-runtime.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/bun-runtime.mjs +10 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/bun-runtime.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/index.d.ts +81 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/index.js +13 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/index.mjs +7 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/manual-types.d.ts +12 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/manual-types.js +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/manual-types.mjs +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-runtime.d.ts +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-runtime.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-runtime.js +90 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-runtime.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-runtime.mjs +56 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-runtime.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-types.d.ts +42 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-types.js +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/node-types.mjs +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/registry.d.ts +37 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/registry.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/registry.js +41 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/registry.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/registry.mjs +37 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/registry.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-runtime.d.ts +5 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-runtime.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-runtime.js +78 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-runtime.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-runtime.mjs +71 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-runtime.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-types.d.ts +83 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-types.js +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/_shims/web-types.mjs +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/core.d.ts +239 -0
- package/demo/node_modules/@anthropic-ai/sdk/core.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/core.js +879 -0
- package/demo/node_modules/@anthropic-ai/sdk/core.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/core.mjs +848 -0
- package/demo/node_modules/@anthropic-ai/sdk/core.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/error.d.ts +53 -0
- package/demo/node_modules/@anthropic-ai/sdk/error.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/error.js +143 -0
- package/demo/node_modules/@anthropic-ai/sdk/error.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/error.mjs +127 -0
- package/demo/node_modules/@anthropic-ai/sdk/error.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/index.d.mts +147 -0
- package/demo/node_modules/@anthropic-ai/sdk/index.d.ts +147 -0
- package/demo/node_modules/@anthropic-ai/sdk/index.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/index.js +149 -0
- package/demo/node_modules/@anthropic-ai/sdk/index.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/index.mjs +121 -0
- package/demo/node_modules/@anthropic-ai/sdk/index.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/lib/MessageStream.d.ts +94 -0
- package/demo/node_modules/@anthropic-ai/sdk/lib/MessageStream.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/lib/MessageStream.js +436 -0
- package/demo/node_modules/@anthropic-ai/sdk/lib/MessageStream.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs +432 -0
- package/demo/node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/package.json +104 -0
- package/demo/node_modules/@anthropic-ai/sdk/resource.d.ts +6 -0
- package/demo/node_modules/@anthropic-ai/sdk/resource.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resource.js +11 -0
- package/demo/node_modules/@anthropic-ai/sdk/resource.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resource.mjs +7 -0
- package/demo/node_modules/@anthropic-ai/sdk/resource.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.ts +9 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/beta.js +40 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/beta.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/beta.mjs +13 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/beta.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/index.d.ts +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/index.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/index.js +9 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/index.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/index.mjs +4 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/index.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/index.d.ts +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/index.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/index.js +9 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/index.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/index.mjs +4 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/index.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/messages.d.ts +462 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/messages.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/messages.js +20 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/messages.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/messages.mjs +16 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/messages.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/tools.d.ts +19 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/tools.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/tools.js +40 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/tools.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/tools.mjs +13 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/beta/tools/tools.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/completions.d.ts +184 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/completions.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/completions.js +19 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/completions.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/completions.mjs +15 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/completions.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/index.d.ts +4 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/index.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/index.js +11 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/index.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/index.mjs +5 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/index.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/messages.d.ts +619 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/messages.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/messages.js +28 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/messages.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/messages.mjs +23 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/messages.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/top-level.d.ts +2 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/top-level.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/top-level.js +4 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/top-level.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/top-level.mjs +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/resources/top-level.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/shims/node.d.ts +29 -0
- package/demo/node_modules/@anthropic-ai/sdk/shims/node.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/shims/node.js +31 -0
- package/demo/node_modules/@anthropic-ai/sdk/shims/node.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/shims/node.mjs +5 -0
- package/demo/node_modules/@anthropic-ai/sdk/shims/node.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/shims/web.d.ts +26 -0
- package/demo/node_modules/@anthropic-ai/sdk/shims/web.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/shims/web.js +31 -0
- package/demo/node_modules/@anthropic-ai/sdk/shims/web.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/shims/web.mjs +5 -0
- package/demo/node_modules/@anthropic-ai/sdk/shims/web.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/MultipartBody.ts +9 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/README.md +46 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/auto/runtime-bun.ts +4 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/auto/runtime-node.ts +4 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/auto/runtime.ts +4 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/auto/types-node.ts +4 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/auto/types.d.ts +101 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/auto/types.js +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/auto/types.mjs +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/bun-runtime.ts +14 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/index.d.ts +81 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/index.js +13 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/index.mjs +7 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/manual-types.d.ts +12 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/manual-types.js +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/manual-types.mjs +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/node-runtime.ts +83 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/node-types.d.ts +42 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/node-types.js +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/node-types.mjs +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/registry.ts +67 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/web-runtime.ts +103 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/web-types.d.ts +83 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/web-types.js +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/_shims/web-types.mjs +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/core.ts +1162 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/error.ts +146 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/index.ts +264 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/lib/.keep +4 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/lib/MessageStream.ts +535 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/resource.ts +11 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/beta/beta.ts +12 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/beta/index.ts +4 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/beta/tools/index.ts +16 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/beta/tools/messages.ts +531 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/beta/tools/tools.ts +22 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/completions.ts +223 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/index.ts +33 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/messages.ts +729 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/resources/top-level.ts +3 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/shims/node.ts +50 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/shims/web.ts +50 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/streaming.ts +509 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/tsconfig.json +11 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/uploads.ts +248 -0
- package/demo/node_modules/@anthropic-ai/sdk/src/version.ts +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/streaming.d.ts +41 -0
- package/demo/node_modules/@anthropic-ai/sdk/streaming.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/streaming.js +431 -0
- package/demo/node_modules/@anthropic-ai/sdk/streaming.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/streaming.mjs +424 -0
- package/demo/node_modules/@anthropic-ai/sdk/streaming.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/uploads.d.ts +75 -0
- package/demo/node_modules/@anthropic-ai/sdk/uploads.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/uploads.js +165 -0
- package/demo/node_modules/@anthropic-ai/sdk/uploads.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/uploads.mjs +152 -0
- package/demo/node_modules/@anthropic-ai/sdk/uploads.mjs.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/version.d.ts +2 -0
- package/demo/node_modules/@anthropic-ai/sdk/version.d.ts.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/version.js +5 -0
- package/demo/node_modules/@anthropic-ai/sdk/version.js.map +1 -0
- package/demo/node_modules/@anthropic-ai/sdk/version.mjs +2 -0
- package/demo/node_modules/@anthropic-ai/sdk/version.mjs.map +1 -0
- package/demo/node_modules/@types/node/LICENSE +21 -0
- package/demo/node_modules/@types/node/README.md +15 -0
- package/demo/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/demo/node_modules/@types/node/assert.d.ts +985 -0
- package/demo/node_modules/@types/node/async_hooks.d.ts +522 -0
- package/demo/node_modules/@types/node/buffer.d.ts +2353 -0
- package/demo/node_modules/@types/node/child_process.d.ts +1544 -0
- package/demo/node_modules/@types/node/cluster.d.ts +578 -0
- package/demo/node_modules/@types/node/console.d.ts +452 -0
- package/demo/node_modules/@types/node/constants.d.ts +19 -0
- package/demo/node_modules/@types/node/crypto.d.ts +4457 -0
- package/demo/node_modules/@types/node/dgram.d.ts +596 -0
- package/demo/node_modules/@types/node/diagnostics_channel.d.ts +546 -0
- package/demo/node_modules/@types/node/dns/promises.d.ts +473 -0
- package/demo/node_modules/@types/node/dns.d.ts +853 -0
- package/demo/node_modules/@types/node/dom-events.d.ts +124 -0
- package/demo/node_modules/@types/node/domain.d.ts +170 -0
- package/demo/node_modules/@types/node/events.d.ts +819 -0
- package/demo/node_modules/@types/node/fs/promises.d.ts +1205 -0
- package/demo/node_modules/@types/node/fs.d.ts +4237 -0
- package/demo/node_modules/@types/node/globals.d.ts +377 -0
- package/demo/node_modules/@types/node/globals.global.d.ts +1 -0
- package/demo/node_modules/@types/node/http.d.ts +1803 -0
- package/demo/node_modules/@types/node/http2.d.ts +2392 -0
- package/demo/node_modules/@types/node/https.d.ts +544 -0
- package/demo/node_modules/@types/node/index.d.ts +88 -0
- package/demo/node_modules/@types/node/inspector.d.ts +2738 -0
- package/demo/node_modules/@types/node/module.d.ts +298 -0
- package/demo/node_modules/@types/node/net.d.ts +918 -0
- package/demo/node_modules/@types/node/os.d.ts +473 -0
- package/demo/node_modules/@types/node/package.json +222 -0
- package/demo/node_modules/@types/node/path.d.ts +191 -0
- package/demo/node_modules/@types/node/perf_hooks.d.ts +626 -0
- package/demo/node_modules/@types/node/process.d.ts +1548 -0
- package/demo/node_modules/@types/node/punycode.d.ts +117 -0
- package/demo/node_modules/@types/node/querystring.d.ts +141 -0
- package/demo/node_modules/@types/node/readline/promises.d.ts +143 -0
- package/demo/node_modules/@types/node/readline.d.ts +666 -0
- package/demo/node_modules/@types/node/repl.d.ts +430 -0
- package/demo/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/demo/node_modules/@types/node/stream/promises.d.ts +83 -0
- package/demo/node_modules/@types/node/stream/web.d.ts +352 -0
- package/demo/node_modules/@types/node/stream.d.ts +1731 -0
- package/demo/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/demo/node_modules/@types/node/test.d.ts +1113 -0
- package/demo/node_modules/@types/node/timers/promises.d.ts +93 -0
- package/demo/node_modules/@types/node/timers.d.ts +126 -0
- package/demo/node_modules/@types/node/tls.d.ts +1203 -0
- package/demo/node_modules/@types/node/trace_events.d.ts +171 -0
- package/demo/node_modules/@types/node/tty.d.ts +206 -0
- package/demo/node_modules/@types/node/url.d.ts +954 -0
- package/demo/node_modules/@types/node/util.d.ts +2075 -0
- package/demo/node_modules/@types/node/v8.d.ts +753 -0
- package/demo/node_modules/@types/node/vm.d.ts +667 -0
- package/demo/node_modules/@types/node/wasi.d.ts +160 -0
- package/demo/node_modules/@types/node/worker_threads.d.ts +692 -0
- package/demo/node_modules/@types/node/zlib.d.ts +517 -0
- package/demo/node_modules/@types/node-fetch/LICENSE +21 -0
- package/demo/node_modules/@types/node-fetch/README.md +15 -0
- package/demo/node_modules/@types/node-fetch/externals.d.ts +32 -0
- package/demo/node_modules/@types/node-fetch/index.d.ts +238 -0
- package/demo/node_modules/@types/node-fetch/package.json +83 -0
- package/demo/node_modules/abort-controller/LICENSE +21 -0
- package/demo/node_modules/abort-controller/README.md +98 -0
- package/demo/node_modules/abort-controller/browser.js +13 -0
- package/demo/node_modules/abort-controller/browser.mjs +11 -0
- package/demo/node_modules/abort-controller/package.json +97 -0
- package/demo/node_modules/abort-controller/polyfill.js +21 -0
- package/demo/node_modules/abort-controller/polyfill.mjs +19 -0
- package/demo/node_modules/agentkeepalive/History.md +268 -0
- package/demo/node_modules/agentkeepalive/LICENSE +23 -0
- package/demo/node_modules/agentkeepalive/README.md +256 -0
- package/demo/node_modules/agentkeepalive/browser.js +5 -0
- package/demo/node_modules/agentkeepalive/index.d.ts +65 -0
- package/demo/node_modules/agentkeepalive/index.js +5 -0
- package/demo/node_modules/agentkeepalive/lib/agent.js +402 -0
- package/demo/node_modules/agentkeepalive/lib/constants.js +14 -0
- package/demo/node_modules/agentkeepalive/lib/https_agent.js +51 -0
- package/demo/node_modules/agentkeepalive/package.json +56 -0
- package/demo/node_modules/asynckit/LICENSE +21 -0
- package/demo/node_modules/asynckit/README.md +233 -0
- package/demo/node_modules/asynckit/bench.js +76 -0
- package/demo/node_modules/asynckit/index.js +6 -0
- package/demo/node_modules/asynckit/lib/abort.js +29 -0
- package/demo/node_modules/asynckit/lib/async.js +34 -0
- package/demo/node_modules/asynckit/lib/defer.js +26 -0
- package/demo/node_modules/asynckit/lib/iterate.js +75 -0
- package/demo/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/demo/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/demo/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/demo/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/demo/node_modules/asynckit/lib/state.js +37 -0
- package/demo/node_modules/asynckit/lib/streamify.js +141 -0
- package/demo/node_modules/asynckit/lib/terminator.js +29 -0
- package/demo/node_modules/asynckit/package.json +63 -0
- package/demo/node_modules/asynckit/parallel.js +43 -0
- package/demo/node_modules/asynckit/serial.js +17 -0
- package/demo/node_modules/asynckit/serialOrdered.js +75 -0
- package/demo/node_modules/asynckit/stream.js +21 -0
- package/demo/node_modules/combined-stream/License +19 -0
- package/demo/node_modules/combined-stream/Readme.md +138 -0
- package/demo/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/demo/node_modules/combined-stream/package.json +25 -0
- package/demo/node_modules/combined-stream/yarn.lock +17 -0
- package/demo/node_modules/delayed-stream/License +19 -0
- package/demo/node_modules/delayed-stream/Makefile +7 -0
- package/demo/node_modules/delayed-stream/Readme.md +141 -0
- package/demo/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/demo/node_modules/delayed-stream/package.json +27 -0
- package/demo/node_modules/dotenv/CHANGELOG.md +475 -0
- package/demo/node_modules/dotenv/LICENSE +23 -0
- package/demo/node_modules/dotenv/README-es.md +448 -0
- package/demo/node_modules/dotenv/README.md +728 -0
- package/demo/node_modules/dotenv/config.d.ts +1 -0
- package/demo/node_modules/dotenv/config.js +9 -0
- package/demo/node_modules/dotenv/lib/cli-options.js +11 -0
- package/demo/node_modules/dotenv/lib/env-options.js +24 -0
- package/demo/node_modules/dotenv/lib/main.d.ts +153 -0
- package/demo/node_modules/dotenv/lib/main.js +361 -0
- package/demo/node_modules/dotenv/package.json +65 -0
- package/demo/node_modules/event-target-shim/LICENSE +22 -0
- package/demo/node_modules/event-target-shim/README.md +293 -0
- package/demo/node_modules/event-target-shim/index.d.ts +399 -0
- package/demo/node_modules/event-target-shim/package.json +82 -0
- package/demo/node_modules/form-data/License +19 -0
- package/demo/node_modules/form-data/README.md.bak +358 -0
- package/demo/node_modules/form-data/Readme.md +358 -0
- package/demo/node_modules/form-data/index.d.ts +62 -0
- package/demo/node_modules/form-data/lib/browser.js +2 -0
- package/demo/node_modules/form-data/lib/form_data.js +501 -0
- package/demo/node_modules/form-data/lib/populate.js +10 -0
- package/demo/node_modules/form-data/package.json +68 -0
- package/demo/node_modules/form-data-encoder/@type/FileLike.d.ts +23 -0
- package/demo/node_modules/form-data-encoder/@type/FormDataEncoder.d.ts +160 -0
- package/demo/node_modules/form-data-encoder/@type/FormDataLike.d.ts +40 -0
- package/demo/node_modules/form-data-encoder/@type/index.d.ts +5 -0
- package/demo/node_modules/form-data-encoder/@type/util/createBoundary.d.ts +13 -0
- package/demo/node_modules/form-data-encoder/@type/util/escapeName.d.ts +11 -0
- package/demo/node_modules/form-data-encoder/@type/util/isFileLike.d.ts +28 -0
- package/demo/node_modules/form-data-encoder/@type/util/isFormData.d.ts +15 -0
- package/demo/node_modules/form-data-encoder/@type/util/isFunction.d.ts +7 -0
- package/demo/node_modules/form-data-encoder/@type/util/isPlainObject.d.ts +2 -0
- package/demo/node_modules/form-data-encoder/@type/util/normalizeValue.d.ts +11 -0
- package/demo/node_modules/form-data-encoder/lib/cjs/FileLike.js +2 -0
- package/demo/node_modules/form-data-encoder/lib/cjs/FormDataEncoder.js +126 -0
- package/demo/node_modules/form-data-encoder/lib/cjs/FormDataLike.js +2 -0
- package/demo/node_modules/form-data-encoder/lib/cjs/index.js +17 -0
- package/demo/node_modules/form-data-encoder/lib/cjs/package.json +3 -0
- package/demo/node_modules/form-data-encoder/lib/cjs/util/createBoundary.js +12 -0
- package/demo/node_modules/form-data-encoder/lib/cjs/util/escapeName.js +7 -0
- package/demo/node_modules/form-data-encoder/lib/cjs/util/isFileLike.js +16 -0
- package/demo/node_modules/form-data-encoder/lib/cjs/util/isFormData.js +16 -0
- package/demo/node_modules/form-data-encoder/lib/cjs/util/isFunction.js +4 -0
- package/demo/node_modules/form-data-encoder/lib/cjs/util/isPlainObject.js +15 -0
- package/demo/node_modules/form-data-encoder/lib/cjs/util/normalizeValue.js +11 -0
- package/demo/node_modules/form-data-encoder/lib/esm/FileLike.js +1 -0
- package/demo/node_modules/form-data-encoder/lib/esm/FormDataEncoder.js +119 -0
- package/demo/node_modules/form-data-encoder/lib/esm/FormDataLike.js +1 -0
- package/demo/node_modules/form-data-encoder/lib/esm/index.js +5 -0
- package/demo/node_modules/form-data-encoder/lib/esm/package.json +3 -0
- package/demo/node_modules/form-data-encoder/lib/esm/util/createBoundary.js +10 -0
- package/demo/node_modules/form-data-encoder/lib/esm/util/escapeName.js +5 -0
- package/demo/node_modules/form-data-encoder/lib/esm/util/isFileLike.js +9 -0
- package/demo/node_modules/form-data-encoder/lib/esm/util/isFormData.js +9 -0
- package/demo/node_modules/form-data-encoder/lib/esm/util/isFunction.js +2 -0
- package/demo/node_modules/form-data-encoder/lib/esm/util/isPlainObject.js +13 -0
- package/demo/node_modules/form-data-encoder/lib/esm/util/normalizeValue.js +9 -0
- package/demo/node_modules/form-data-encoder/license +21 -0
- package/demo/node_modules/form-data-encoder/package.json +63 -0
- package/demo/node_modules/form-data-encoder/readme.md +366 -0
- package/demo/node_modules/formdata-node/@type/Blob.d.ts +66 -0
- package/demo/node_modules/formdata-node/@type/BlobPart.d.ts +2 -0
- package/demo/node_modules/formdata-node/@type/File.d.ts +53 -0
- package/demo/node_modules/formdata-node/@type/FormData.d.ts +105 -0
- package/demo/node_modules/formdata-node/@type/blobHelpers.d.ts +9 -0
- package/demo/node_modules/formdata-node/@type/browser.d.ts +10 -0
- package/demo/node_modules/formdata-node/@type/deprecateConstructorEntries.d.ts +1 -0
- package/demo/node_modules/formdata-node/@type/fileFromPath.d.ts +55 -0
- package/demo/node_modules/formdata-node/@type/index.d.ts +3 -0
- package/demo/node_modules/formdata-node/@type/isBlob.d.ts +2 -0
- package/demo/node_modules/formdata-node/@type/isFile.d.ts +7 -0
- package/demo/node_modules/formdata-node/@type/isFunction.d.ts +1 -0
- package/demo/node_modules/formdata-node/@type/isPlainObject.d.ts +2 -0
- package/demo/node_modules/formdata-node/lib/cjs/Blob.js +122 -0
- package/demo/node_modules/formdata-node/lib/cjs/BlobPart.js +2 -0
- package/demo/node_modules/formdata-node/lib/cjs/File.js +52 -0
- package/demo/node_modules/formdata-node/lib/cjs/FormData.js +148 -0
- package/demo/node_modules/formdata-node/lib/cjs/blobHelpers.js +80 -0
- package/demo/node_modules/formdata-node/lib/cjs/browser.js +13 -0
- package/demo/node_modules/formdata-node/lib/cjs/deprecateConstructorEntries.js +6 -0
- package/demo/node_modules/formdata-node/lib/cjs/fileFromPath.js +97 -0
- package/demo/node_modules/formdata-node/lib/cjs/index.js +15 -0
- package/demo/node_modules/formdata-node/lib/cjs/isBlob.js +6 -0
- package/demo/node_modules/formdata-node/lib/cjs/isFile.js +6 -0
- package/demo/node_modules/formdata-node/lib/cjs/isFunction.js +5 -0
- package/demo/node_modules/formdata-node/lib/cjs/isPlainObject.js +15 -0
- package/demo/node_modules/formdata-node/lib/cjs/package.json +3 -0
- package/demo/node_modules/formdata-node/lib/esm/Blob.js +118 -0
- package/demo/node_modules/formdata-node/lib/esm/BlobPart.js +1 -0
- package/demo/node_modules/formdata-node/lib/esm/File.js +48 -0
- package/demo/node_modules/formdata-node/lib/esm/FormData.js +144 -0
- package/demo/node_modules/formdata-node/lib/esm/blobHelpers.js +75 -0
- package/demo/node_modules/formdata-node/lib/esm/browser.js +10 -0
- package/demo/node_modules/formdata-node/lib/esm/deprecateConstructorEntries.js +3 -0
- package/demo/node_modules/formdata-node/lib/esm/fileFromPath.js +79 -0
- package/demo/node_modules/formdata-node/lib/esm/index.js +3 -0
- package/demo/node_modules/formdata-node/lib/esm/isBlob.js +2 -0
- package/demo/node_modules/formdata-node/lib/esm/isFile.js +2 -0
- package/demo/node_modules/formdata-node/lib/esm/isFunction.js +1 -0
- package/demo/node_modules/formdata-node/lib/esm/isPlainObject.js +13 -0
- package/demo/node_modules/formdata-node/lib/esm/package.json +3 -0
- package/demo/node_modules/formdata-node/lib/node-domexception.d.ts +5 -0
- package/demo/node_modules/formdata-node/license +21 -0
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/LICENSE +22 -0
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/README.md +135 -0
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/es5/package.json +6 -0
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/package.json +101 -0
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/polyfill/es5/package.json +5 -0
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/polyfill/package.json +5 -0
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/types/polyfill.d.ts +62 -0
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/types/ponyfill.d.ts +775 -0
- package/demo/node_modules/formdata-node/node_modules/web-streams-polyfill/types/tsdoc-metadata.json +11 -0
- package/demo/node_modules/formdata-node/package.json +94 -0
- package/demo/node_modules/formdata-node/readme.md +444 -0
- package/demo/node_modules/humanize-ms/History.md +25 -0
- package/demo/node_modules/humanize-ms/LICENSE +17 -0
- package/demo/node_modules/humanize-ms/README.md +40 -0
- package/demo/node_modules/humanize-ms/index.js +24 -0
- package/demo/node_modules/humanize-ms/package.json +37 -0
- package/demo/node_modules/mime-db/HISTORY.md +507 -0
- package/demo/node_modules/mime-db/LICENSE +23 -0
- package/demo/node_modules/mime-db/README.md +100 -0
- package/demo/node_modules/mime-db/db.json +8519 -0
- package/demo/node_modules/mime-db/index.js +12 -0
- package/demo/node_modules/mime-db/package.json +60 -0
- package/demo/node_modules/mime-types/HISTORY.md +397 -0
- package/demo/node_modules/mime-types/LICENSE +23 -0
- package/demo/node_modules/mime-types/README.md +113 -0
- package/demo/node_modules/mime-types/index.js +188 -0
- package/demo/node_modules/mime-types/package.json +44 -0
- package/demo/node_modules/ms/index.js +162 -0
- package/demo/node_modules/ms/license.md +21 -0
- package/demo/node_modules/ms/package.json +38 -0
- package/demo/node_modules/ms/readme.md +59 -0
- package/demo/node_modules/node-domexception/.history/README_20210527203617.md +2 -0
- package/demo/node_modules/node-domexception/.history/README_20210527212714.md +41 -0
- package/demo/node_modules/node-domexception/.history/README_20210527213345.md +36 -0
- package/demo/node_modules/node-domexception/.history/README_20210527213411.md +36 -0
- package/demo/node_modules/node-domexception/.history/README_20210527213803.md +36 -0
- package/demo/node_modules/node-domexception/.history/README_20210527214323.md +38 -0
- package/demo/node_modules/node-domexception/.history/README_20210527214408.md +38 -0
- package/demo/node_modules/node-domexception/.history/index_20210527203842.js +0 -0
- package/demo/node_modules/node-domexception/.history/index_20210527203947.js +8 -0
- package/demo/node_modules/node-domexception/.history/index_20210527204259.js +9 -0
- package/demo/node_modules/node-domexception/.history/index_20210527204418.js +9 -0
- package/demo/node_modules/node-domexception/.history/index_20210527204756.js +11 -0
- package/demo/node_modules/node-domexception/.history/index_20210527204833.js +11 -0
- package/demo/node_modules/node-domexception/.history/index_20210527211208.js +15 -0
- package/demo/node_modules/node-domexception/.history/index_20210527211248.js +15 -0
- package/demo/node_modules/node-domexception/.history/index_20210527212722.js +23 -0
- package/demo/node_modules/node-domexception/.history/index_20210527212731.js +23 -0
- package/demo/node_modules/node-domexception/.history/index_20210527212746.js +15 -0
- package/demo/node_modules/node-domexception/.history/index_20210527212900.js +16 -0
- package/demo/node_modules/node-domexception/.history/index_20210527213022.js +16 -0
- package/demo/node_modules/node-domexception/.history/index_20210527213822.js +16 -0
- package/demo/node_modules/node-domexception/.history/index_20210527213843.js +17 -0
- package/demo/node_modules/node-domexception/.history/index_20210527213852.js +17 -0
- package/demo/node_modules/node-domexception/.history/index_20210527213910.js +16 -0
- package/demo/node_modules/node-domexception/.history/index_20210527214034.js +16 -0
- package/demo/node_modules/node-domexception/.history/index_20210527214643.js +41 -0
- package/demo/node_modules/node-domexception/.history/index_20210527214654.js +41 -0
- package/demo/node_modules/node-domexception/.history/index_20210527214700.js +16 -0
- package/demo/node_modules/node-domexception/.history/package_20210527203733.json +19 -0
- package/demo/node_modules/node-domexception/.history/package_20210527203825.json +16 -0
- package/demo/node_modules/node-domexception/.history/package_20210527204621.json +19 -0
- package/demo/node_modules/node-domexception/.history/package_20210527204913.json +25 -0
- package/demo/node_modules/node-domexception/.history/package_20210527204925.json +25 -0
- package/demo/node_modules/node-domexception/.history/package_20210527205145.json +29 -0
- package/demo/node_modules/node-domexception/.history/package_20210527205156.json +29 -0
- package/demo/node_modules/node-domexception/.history/test_20210527205603.js +0 -0
- package/demo/node_modules/node-domexception/.history/test_20210527205957.js +3 -0
- package/demo/node_modules/node-domexception/.history/test_20210527210021.js +3 -0
- package/demo/node_modules/node-domexception/LICENSE +21 -0
- package/demo/node_modules/node-domexception/README.md +46 -0
- package/demo/node_modules/node-domexception/index.js +16 -0
- package/demo/node_modules/node-domexception/package.json +29 -0
- package/demo/node_modules/node-fetch/LICENSE.md +22 -0
- package/demo/node_modules/node-fetch/README.md +634 -0
- package/demo/node_modules/node-fetch/browser.js +25 -0
- package/demo/node_modules/node-fetch/lib/index.es.js +1777 -0
- package/demo/node_modules/node-fetch/lib/index.js +1787 -0
- package/demo/node_modules/node-fetch/lib/index.mjs +1775 -0
- package/demo/node_modules/node-fetch/package.json +89 -0
- package/demo/node_modules/openai/CHANGELOG.md +1176 -0
- package/demo/node_modules/openai/LICENSE +201 -0
- package/demo/node_modules/openai/README.md +616 -0
- package/demo/node_modules/openai/_shims/MultipartBody.d.ts +9 -0
- package/demo/node_modules/openai/_shims/MultipartBody.d.ts.map +1 -0
- package/demo/node_modules/openai/_shims/MultipartBody.js +16 -0
- package/demo/node_modules/openai/_shims/MultipartBody.js.map +1 -0
- package/demo/node_modules/openai/_shims/MultipartBody.mjs +12 -0
- package/demo/node_modules/openai/_shims/MultipartBody.mjs.map +1 -0
- package/demo/node_modules/openai/_shims/README.md +46 -0
- package/demo/node_modules/openai/_shims/auto/runtime-bun.d.ts +5 -0
- package/demo/node_modules/openai/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/demo/node_modules/openai/_shims/auto/runtime-bun.js +21 -0
- package/demo/node_modules/openai/_shims/auto/runtime-bun.js.map +1 -0
- package/demo/node_modules/openai/_shims/auto/runtime-bun.mjs +2 -0
- package/demo/node_modules/openai/_shims/auto/runtime-bun.mjs.map +1 -0
- package/demo/node_modules/openai/_shims/auto/runtime-node.d.ts +5 -0
- package/demo/node_modules/openai/_shims/auto/runtime-node.d.ts.map +1 -0
- package/demo/node_modules/openai/_shims/auto/runtime-node.js +21 -0
- package/demo/node_modules/openai/_shims/auto/runtime-node.js.map +1 -0
- package/demo/node_modules/openai/_shims/auto/runtime-node.mjs +2 -0
- package/demo/node_modules/openai/_shims/auto/runtime-node.mjs.map +1 -0
- package/demo/node_modules/openai/_shims/auto/runtime.d.ts +5 -0
- package/demo/node_modules/openai/_shims/auto/runtime.d.ts.map +1 -0
- package/demo/node_modules/openai/_shims/auto/runtime.js +21 -0
- package/demo/node_modules/openai/_shims/auto/runtime.js.map +1 -0
- package/demo/node_modules/openai/_shims/auto/runtime.mjs +2 -0
- package/demo/node_modules/openai/_shims/auto/runtime.mjs.map +1 -0
- package/demo/node_modules/openai/_shims/auto/types-node.d.ts +5 -0
- package/demo/node_modules/openai/_shims/auto/types-node.d.ts.map +1 -0
- package/demo/node_modules/openai/_shims/auto/types-node.js +21 -0
- package/demo/node_modules/openai/_shims/auto/types-node.js.map +1 -0
- package/demo/node_modules/openai/_shims/auto/types-node.mjs +2 -0
- package/demo/node_modules/openai/_shims/auto/types-node.mjs.map +1 -0
- package/demo/node_modules/openai/_shims/auto/types.d.ts +101 -0
- package/demo/node_modules/openai/_shims/auto/types.js +3 -0
- package/demo/node_modules/openai/_shims/auto/types.mjs +3 -0
- package/demo/node_modules/openai/_shims/bun-runtime.d.ts +6 -0
- package/demo/node_modules/openai/_shims/bun-runtime.d.ts.map +1 -0
- package/demo/node_modules/openai/_shims/bun-runtime.js +14 -0
- package/demo/node_modules/openai/_shims/bun-runtime.js.map +1 -0
- package/demo/node_modules/openai/_shims/bun-runtime.mjs +10 -0
- package/demo/node_modules/openai/_shims/bun-runtime.mjs.map +1 -0
- package/demo/node_modules/openai/_shims/index.d.ts +81 -0
- package/demo/node_modules/openai/_shims/index.js +13 -0
- package/demo/node_modules/openai/_shims/index.mjs +7 -0
- package/demo/node_modules/openai/_shims/manual-types.d.ts +12 -0
- package/demo/node_modules/openai/_shims/manual-types.js +3 -0
- package/demo/node_modules/openai/_shims/manual-types.mjs +3 -0
- package/demo/node_modules/openai/_shims/node-runtime.d.ts +3 -0
- package/demo/node_modules/openai/_shims/node-runtime.d.ts.map +1 -0
- package/demo/node_modules/openai/_shims/node-runtime.js +90 -0
- package/demo/node_modules/openai/_shims/node-runtime.js.map +1 -0
- package/demo/node_modules/openai/_shims/node-runtime.mjs +56 -0
- package/demo/node_modules/openai/_shims/node-runtime.mjs.map +1 -0
- package/demo/node_modules/openai/_shims/node-types.d.ts +42 -0
- package/demo/node_modules/openai/_shims/node-types.js +3 -0
- package/demo/node_modules/openai/_shims/node-types.mjs +3 -0
- package/demo/node_modules/openai/_shims/registry.d.ts +37 -0
- package/demo/node_modules/openai/_shims/registry.d.ts.map +1 -0
- package/demo/node_modules/openai/_shims/registry.js +41 -0
- package/demo/node_modules/openai/_shims/registry.js.map +1 -0
- package/demo/node_modules/openai/_shims/registry.mjs +37 -0
- package/demo/node_modules/openai/_shims/registry.mjs.map +1 -0
- package/demo/node_modules/openai/_shims/web-runtime.d.ts +5 -0
- package/demo/node_modules/openai/_shims/web-runtime.d.ts.map +1 -0
- package/demo/node_modules/openai/_shims/web-runtime.js +78 -0
- package/demo/node_modules/openai/_shims/web-runtime.js.map +1 -0
- package/demo/node_modules/openai/_shims/web-runtime.mjs +71 -0
- package/demo/node_modules/openai/_shims/web-runtime.mjs.map +1 -0
- package/demo/node_modules/openai/_shims/web-types.d.ts +83 -0
- package/demo/node_modules/openai/_shims/web-types.js +3 -0
- package/demo/node_modules/openai/_shims/web-types.mjs +3 -0
- package/demo/node_modules/openai/bin/cli +49 -0
- package/demo/node_modules/openai/core.d.ts +239 -0
- package/demo/node_modules/openai/core.d.ts.map +1 -0
- package/demo/node_modules/openai/core.js +879 -0
- package/demo/node_modules/openai/core.js.map +1 -0
- package/demo/node_modules/openai/core.mjs +848 -0
- package/demo/node_modules/openai/core.mjs.map +1 -0
- package/demo/node_modules/openai/error.d.ts +57 -0
- package/demo/node_modules/openai/error.d.ts.map +1 -0
- package/demo/node_modules/openai/error.js +148 -0
- package/demo/node_modules/openai/error.js.map +1 -0
- package/demo/node_modules/openai/error.mjs +132 -0
- package/demo/node_modules/openai/error.mjs.map +1 -0
- package/demo/node_modules/openai/index.d.mts +267 -0
- package/demo/node_modules/openai/index.d.ts +267 -0
- package/demo/node_modules/openai/index.d.ts.map +1 -0
- package/demo/node_modules/openai/index.js +262 -0
- package/demo/node_modules/openai/index.js.map +1 -0
- package/demo/node_modules/openai/index.mjs +232 -0
- package/demo/node_modules/openai/index.mjs.map +1 -0
- package/demo/node_modules/openai/lib/AbstractAssistantStreamRunner.d.ts +74 -0
- package/demo/node_modules/openai/lib/AbstractAssistantStreamRunner.d.ts.map +1 -0
- package/demo/node_modules/openai/lib/AbstractAssistantStreamRunner.js +246 -0
- package/demo/node_modules/openai/lib/AbstractAssistantStreamRunner.js.map +1 -0
- package/demo/node_modules/openai/lib/AbstractAssistantStreamRunner.mjs +242 -0
- package/demo/node_modules/openai/lib/AbstractAssistantStreamRunner.mjs.map +1 -0
- package/demo/node_modules/openai/lib/AbstractChatCompletionRunner.d.ts +114 -0
- package/demo/node_modules/openai/lib/AbstractChatCompletionRunner.d.ts.map +1 -0
- package/demo/node_modules/openai/lib/AbstractChatCompletionRunner.js +519 -0
- package/demo/node_modules/openai/lib/AbstractChatCompletionRunner.js.map +1 -0
- package/demo/node_modules/openai/lib/AbstractChatCompletionRunner.mjs +515 -0
- package/demo/node_modules/openai/lib/AbstractChatCompletionRunner.mjs.map +1 -0
- package/demo/node_modules/openai/lib/AssistantStream.d.ts +58 -0
- package/demo/node_modules/openai/lib/AssistantStream.d.ts.map +1 -0
- package/demo/node_modules/openai/lib/AssistantStream.js +548 -0
- package/demo/node_modules/openai/lib/AssistantStream.js.map +1 -0
- package/demo/node_modules/openai/lib/AssistantStream.mjs +521 -0
- package/demo/node_modules/openai/lib/AssistantStream.mjs.map +1 -0
- package/demo/node_modules/openai/lib/ChatCompletionRunFunctions.test.d.ts +2 -0
- package/demo/node_modules/openai/lib/ChatCompletionRunFunctions.test.d.ts.map +1 -0
- package/demo/node_modules/openai/lib/ChatCompletionRunFunctions.test.js +2177 -0
- package/demo/node_modules/openai/lib/ChatCompletionRunFunctions.test.js.map +1 -0
- package/demo/node_modules/openai/lib/ChatCompletionRunFunctions.test.mjs +2172 -0
- package/demo/node_modules/openai/lib/ChatCompletionRunFunctions.test.mjs.map +1 -0
- package/demo/node_modules/openai/lib/ChatCompletionRunner.d.ts +19 -0
- package/demo/node_modules/openai/lib/ChatCompletionRunner.d.ts.map +1 -0
- package/demo/node_modules/openai/lib/ChatCompletionRunner.js +34 -0
- package/demo/node_modules/openai/lib/ChatCompletionRunner.js.map +1 -0
- package/demo/node_modules/openai/lib/ChatCompletionRunner.mjs +30 -0
- package/demo/node_modules/openai/lib/ChatCompletionRunner.mjs.map +1 -0
- package/demo/node_modules/openai/lib/ChatCompletionStream.d.ts +149 -0
- package/demo/node_modules/openai/lib/ChatCompletionStream.d.ts.map +1 -0
- package/demo/node_modules/openai/lib/ChatCompletionStream.js +312 -0
- package/demo/node_modules/openai/lib/ChatCompletionStream.js.map +1 -0
- package/demo/node_modules/openai/lib/ChatCompletionStream.mjs +308 -0
- package/demo/node_modules/openai/lib/ChatCompletionStream.mjs.map +1 -0
- package/demo/node_modules/openai/lib/ChatCompletionStreamingRunner.d.ts +22 -0
- package/demo/node_modules/openai/lib/ChatCompletionStreamingRunner.d.ts.map +1 -0
- package/demo/node_modules/openai/lib/ChatCompletionStreamingRunner.js +32 -0
- package/demo/node_modules/openai/lib/ChatCompletionStreamingRunner.js.map +1 -0
- package/demo/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs +28 -0
- package/demo/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs.map +1 -0
- package/demo/node_modules/openai/lib/RunnableFunction.d.ts +95 -0
- package/demo/node_modules/openai/lib/RunnableFunction.d.ts.map +1 -0
- package/demo/node_modules/openai/lib/RunnableFunction.js +35 -0
- package/demo/node_modules/openai/lib/RunnableFunction.js.map +1 -0
- package/demo/node_modules/openai/lib/RunnableFunction.mjs +29 -0
- package/demo/node_modules/openai/lib/RunnableFunction.mjs.map +1 -0
- package/demo/node_modules/openai/lib/Util.d.ts +5 -0
- package/demo/node_modules/openai/lib/Util.d.ts.map +1 -0
- package/demo/node_modules/openai/lib/Util.js +26 -0
- package/demo/node_modules/openai/lib/Util.js.map +1 -0
- package/demo/node_modules/openai/lib/Util.mjs +22 -0
- package/demo/node_modules/openai/lib/Util.mjs.map +1 -0
- package/demo/node_modules/openai/lib/chatCompletionUtils.d.ts +6 -0
- package/demo/node_modules/openai/lib/chatCompletionUtils.d.ts.map +1 -0
- package/demo/node_modules/openai/lib/chatCompletionUtils.js +20 -0
- package/demo/node_modules/openai/lib/chatCompletionUtils.js.map +1 -0
- package/demo/node_modules/openai/lib/chatCompletionUtils.mjs +13 -0
- package/demo/node_modules/openai/lib/chatCompletionUtils.mjs.map +1 -0
- package/demo/node_modules/openai/lib/jsonschema.d.ts +106 -0
- package/demo/node_modules/openai/lib/jsonschema.d.ts.map +1 -0
- package/demo/node_modules/openai/lib/jsonschema.js +11 -0
- package/demo/node_modules/openai/lib/jsonschema.js.map +1 -0
- package/demo/node_modules/openai/lib/jsonschema.mjs +10 -0
- package/demo/node_modules/openai/lib/jsonschema.mjs.map +1 -0
- package/demo/node_modules/openai/package.json +105 -0
- package/demo/node_modules/openai/pagination.d.ts +37 -0
- package/demo/node_modules/openai/pagination.d.ts.map +1 -0
- package/demo/node_modules/openai/pagination.js +64 -0
- package/demo/node_modules/openai/pagination.js.map +1 -0
- package/demo/node_modules/openai/pagination.mjs +59 -0
- package/demo/node_modules/openai/pagination.mjs.map +1 -0
- package/demo/node_modules/openai/resource.d.ts +6 -0
- package/demo/node_modules/openai/resource.d.ts.map +1 -0
- package/demo/node_modules/openai/resource.js +11 -0
- package/demo/node_modules/openai/resource.js.map +1 -0
- package/demo/node_modules/openai/resource.mjs +7 -0
- package/demo/node_modules/openai/resource.mjs.map +1 -0
- package/demo/node_modules/openai/resources/audio/audio.d.ts +20 -0
- package/demo/node_modules/openai/resources/audio/audio.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/audio/audio.js +46 -0
- package/demo/node_modules/openai/resources/audio/audio.js.map +1 -0
- package/demo/node_modules/openai/resources/audio/audio.mjs +19 -0
- package/demo/node_modules/openai/resources/audio/audio.mjs.map +1 -0
- package/demo/node_modules/openai/resources/audio/index.d.ts +5 -0
- package/demo/node_modules/openai/resources/audio/index.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/audio/index.js +13 -0
- package/demo/node_modules/openai/resources/audio/index.js.map +1 -0
- package/demo/node_modules/openai/resources/audio/index.mjs +6 -0
- package/demo/node_modules/openai/resources/audio/index.mjs.map +1 -0
- package/demo/node_modules/openai/resources/audio/speech.d.ts +42 -0
- package/demo/node_modules/openai/resources/audio/speech.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/audio/speech.js +17 -0
- package/demo/node_modules/openai/resources/audio/speech.js.map +1 -0
- package/demo/node_modules/openai/resources/audio/speech.mjs +13 -0
- package/demo/node_modules/openai/resources/audio/speech.mjs.map +1 -0
- package/demo/node_modules/openai/resources/audio/transcriptions.d.ts +71 -0
- package/demo/node_modules/openai/resources/audio/transcriptions.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/audio/transcriptions.js +18 -0
- package/demo/node_modules/openai/resources/audio/transcriptions.js.map +1 -0
- package/demo/node_modules/openai/resources/audio/transcriptions.mjs +14 -0
- package/demo/node_modules/openai/resources/audio/transcriptions.mjs.map +1 -0
- package/demo/node_modules/openai/resources/audio/translations.d.ts +50 -0
- package/demo/node_modules/openai/resources/audio/translations.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/audio/translations.js +18 -0
- package/demo/node_modules/openai/resources/audio/translations.js.map +1 -0
- package/demo/node_modules/openai/resources/audio/translations.mjs +14 -0
- package/demo/node_modules/openai/resources/audio/translations.mjs.map +1 -0
- package/demo/node_modules/openai/resources/batches.d.ts +189 -0
- package/demo/node_modules/openai/resources/batches.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/batches.js +65 -0
- package/demo/node_modules/openai/resources/batches.js.map +1 -0
- package/demo/node_modules/openai/resources/batches.mjs +37 -0
- package/demo/node_modules/openai/resources/batches.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/assistants.d.ts +1048 -0
- package/demo/node_modules/openai/resources/beta/assistants.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/assistants.js +89 -0
- package/demo/node_modules/openai/resources/beta/assistants.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/assistants.mjs +61 -0
- package/demo/node_modules/openai/resources/beta/assistants.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/beta.d.ts +53 -0
- package/demo/node_modules/openai/resources/beta/beta.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/beta.js +51 -0
- package/demo/node_modules/openai/resources/beta/beta.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/beta.mjs +24 -0
- package/demo/node_modules/openai/resources/beta/beta.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/chat/chat.d.ts +9 -0
- package/demo/node_modules/openai/resources/beta/chat/chat.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/chat/chat.js +40 -0
- package/demo/node_modules/openai/resources/beta/chat/chat.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/chat/chat.mjs +13 -0
- package/demo/node_modules/openai/resources/beta/chat/chat.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/chat/completions.d.ts +37 -0
- package/demo/node_modules/openai/resources/beta/chat/completions.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/chat/completions.js +39 -0
- package/demo/node_modules/openai/resources/beta/chat/completions.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/chat/completions.mjs +30 -0
- package/demo/node_modules/openai/resources/beta/chat/completions.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/chat/index.d.ts +3 -0
- package/demo/node_modules/openai/resources/beta/chat/index.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/chat/index.js +9 -0
- package/demo/node_modules/openai/resources/beta/chat/index.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/chat/index.mjs +4 -0
- package/demo/node_modules/openai/resources/beta/chat/index.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/index.d.ts +6 -0
- package/demo/node_modules/openai/resources/beta/index.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/index.js +17 -0
- package/demo/node_modules/openai/resources/beta/index.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/index.mjs +7 -0
- package/demo/node_modules/openai/resources/beta/index.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/index.d.ts +4 -0
- package/demo/node_modules/openai/resources/beta/threads/index.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/index.js +13 -0
- package/demo/node_modules/openai/resources/beta/threads/index.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/index.mjs +5 -0
- package/demo/node_modules/openai/resources/beta/threads/index.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/messages.d.ts +552 -0
- package/demo/node_modules/openai/resources/beta/threads/messages.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/messages.js +89 -0
- package/demo/node_modules/openai/resources/beta/threads/messages.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/messages.mjs +61 -0
- package/demo/node_modules/openai/resources/beta/threads/messages.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/index.d.ts +3 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/index.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/index.js +11 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/index.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/index.mjs +4 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/index.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/runs.d.ts +1194 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/runs.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/runs.js +190 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/runs.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/runs.mjs +162 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/runs.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/steps.d.ts +520 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/steps.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/steps.js +60 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/steps.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/steps.mjs +32 -0
- package/demo/node_modules/openai/resources/beta/threads/runs/steps.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/threads.d.ts +1240 -0
- package/demo/node_modules/openai/resources/beta/threads/threads.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/threads.js +108 -0
- package/demo/node_modules/openai/resources/beta/threads/threads.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/threads/threads.mjs +81 -0
- package/demo/node_modules/openai/resources/beta/threads/threads.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/file-batches.d.ts +142 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/file-batches.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/file-batches.js +129 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/file-batches.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/file-batches.mjs +125 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/file-batches.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/files.d.ts +154 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/files.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/files.js +149 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/files.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/files.mjs +121 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/files.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/index.d.ts +4 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/index.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/index.js +13 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/index.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/index.mjs +5 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/index.mjs.map +1 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/vector-stores.d.ts +233 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/vector-stores.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/vector-stores.js +99 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/vector-stores.js.map +1 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/vector-stores.mjs +71 -0
- package/demo/node_modules/openai/resources/beta/vector-stores/vector-stores.mjs.map +1 -0
- package/demo/node_modules/openai/resources/chat/chat.d.ts +42 -0
- package/demo/node_modules/openai/resources/chat/chat.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/chat/chat.js +40 -0
- package/demo/node_modules/openai/resources/chat/chat.js.map +1 -0
- package/demo/node_modules/openai/resources/chat/chat.mjs +13 -0
- package/demo/node_modules/openai/resources/chat/chat.mjs.map +1 -0
- package/demo/node_modules/openai/resources/chat/completions.d.ts +845 -0
- package/demo/node_modules/openai/resources/chat/completions.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/chat/completions.js +14 -0
- package/demo/node_modules/openai/resources/chat/completions.js.map +1 -0
- package/demo/node_modules/openai/resources/chat/completions.mjs +10 -0
- package/demo/node_modules/openai/resources/chat/completions.mjs.map +1 -0
- package/demo/node_modules/openai/resources/chat/index.d.ts +3 -0
- package/demo/node_modules/openai/resources/chat/index.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/chat/index.js +9 -0
- package/demo/node_modules/openai/resources/chat/index.js.map +1 -0
- package/demo/node_modules/openai/resources/chat/index.mjs +4 -0
- package/demo/node_modules/openai/resources/chat/index.mjs.map +1 -0
- package/demo/node_modules/openai/resources/completions.d.ts +272 -0
- package/demo/node_modules/openai/resources/completions.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/completions.js +14 -0
- package/demo/node_modules/openai/resources/completions.js.map +1 -0
- package/demo/node_modules/openai/resources/completions.mjs +10 -0
- package/demo/node_modules/openai/resources/completions.mjs.map +1 -0
- package/demo/node_modules/openai/resources/embeddings.d.ts +103 -0
- package/demo/node_modules/openai/resources/embeddings.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/embeddings.js +17 -0
- package/demo/node_modules/openai/resources/embeddings.js.map +1 -0
- package/demo/node_modules/openai/resources/embeddings.mjs +13 -0
- package/demo/node_modules/openai/resources/embeddings.mjs.map +1 -0
- package/demo/node_modules/openai/resources/files.d.ts +140 -0
- package/demo/node_modules/openai/resources/files.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/files.js +120 -0
- package/demo/node_modules/openai/resources/files.js.map +1 -0
- package/demo/node_modules/openai/resources/files.mjs +92 -0
- package/demo/node_modules/openai/resources/files.mjs.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/fine-tuning.d.ts +19 -0
- package/demo/node_modules/openai/resources/fine-tuning/fine-tuning.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/fine-tuning.js +42 -0
- package/demo/node_modules/openai/resources/fine-tuning/fine-tuning.js.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/fine-tuning.mjs +15 -0
- package/demo/node_modules/openai/resources/fine-tuning/fine-tuning.mjs.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/index.d.ts +3 -0
- package/demo/node_modules/openai/resources/fine-tuning/index.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/index.js +11 -0
- package/demo/node_modules/openai/resources/fine-tuning/index.js.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/index.mjs +4 -0
- package/demo/node_modules/openai/resources/fine-tuning/index.mjs.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/checkpoints.d.ts +69 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/checkpoints.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/checkpoints.js +47 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/checkpoints.js.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs +19 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/index.d.ts +3 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/index.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/index.js +12 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/index.js.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/index.mjs +4 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/index.mjs.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/jobs.d.ts +362 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/jobs.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/jobs.js +93 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/jobs.js.map +1 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs +64 -0
- package/demo/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs.map +1 -0
- package/demo/node_modules/openai/resources/images.d.ts +174 -0
- package/demo/node_modules/openai/resources/images.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/images.js +30 -0
- package/demo/node_modules/openai/resources/images.js.map +1 -0
- package/demo/node_modules/openai/resources/images.mjs +26 -0
- package/demo/node_modules/openai/resources/images.mjs.map +1 -0
- package/demo/node_modules/openai/resources/index.d.ts +13 -0
- package/demo/node_modules/openai/resources/index.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/index.js +44 -0
- package/demo/node_modules/openai/resources/index.js.map +1 -0
- package/demo/node_modules/openai/resources/index.mjs +14 -0
- package/demo/node_modules/openai/resources/index.mjs.map +1 -0
- package/demo/node_modules/openai/resources/models.d.ts +58 -0
- package/demo/node_modules/openai/resources/models.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/models.js +64 -0
- package/demo/node_modules/openai/resources/models.js.map +1 -0
- package/demo/node_modules/openai/resources/models.mjs +36 -0
- package/demo/node_modules/openai/resources/models.mjs.map +1 -0
- package/demo/node_modules/openai/resources/moderations.d.ts +176 -0
- package/demo/node_modules/openai/resources/moderations.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/moderations.js +17 -0
- package/demo/node_modules/openai/resources/moderations.js.map +1 -0
- package/demo/node_modules/openai/resources/moderations.mjs +13 -0
- package/demo/node_modules/openai/resources/moderations.mjs.map +1 -0
- package/demo/node_modules/openai/resources/shared.d.ts +39 -0
- package/demo/node_modules/openai/resources/shared.d.ts.map +1 -0
- package/demo/node_modules/openai/resources/shared.js +4 -0
- package/demo/node_modules/openai/resources/shared.js.map +1 -0
- package/demo/node_modules/openai/resources/shared.mjs +3 -0
- package/demo/node_modules/openai/resources/shared.mjs.map +1 -0
- package/demo/node_modules/openai/shims/node.d.ts +29 -0
- package/demo/node_modules/openai/shims/node.d.ts.map +1 -0
- package/demo/node_modules/openai/shims/node.js +31 -0
- package/demo/node_modules/openai/shims/node.js.map +1 -0
- package/demo/node_modules/openai/shims/node.mjs +5 -0
- package/demo/node_modules/openai/shims/node.mjs.map +1 -0
- package/demo/node_modules/openai/shims/web.d.ts +26 -0
- package/demo/node_modules/openai/shims/web.d.ts.map +1 -0
- package/demo/node_modules/openai/shims/web.js +31 -0
- package/demo/node_modules/openai/shims/web.js.map +1 -0
- package/demo/node_modules/openai/shims/web.mjs +5 -0
- package/demo/node_modules/openai/shims/web.mjs.map +1 -0
- package/demo/node_modules/openai/src/_shims/MultipartBody.ts +9 -0
- package/demo/node_modules/openai/src/_shims/README.md +46 -0
- package/demo/node_modules/openai/src/_shims/auto/runtime-bun.ts +4 -0
- package/demo/node_modules/openai/src/_shims/auto/runtime-node.ts +4 -0
- package/demo/node_modules/openai/src/_shims/auto/runtime.ts +4 -0
- package/demo/node_modules/openai/src/_shims/auto/types-node.ts +4 -0
- package/demo/node_modules/openai/src/_shims/auto/types.d.ts +101 -0
- package/demo/node_modules/openai/src/_shims/auto/types.js +3 -0
- package/demo/node_modules/openai/src/_shims/auto/types.mjs +3 -0
- package/demo/node_modules/openai/src/_shims/bun-runtime.ts +14 -0
- package/demo/node_modules/openai/src/_shims/index.d.ts +81 -0
- package/demo/node_modules/openai/src/_shims/index.js +13 -0
- package/demo/node_modules/openai/src/_shims/index.mjs +7 -0
- package/demo/node_modules/openai/src/_shims/manual-types.d.ts +12 -0
- package/demo/node_modules/openai/src/_shims/manual-types.js +3 -0
- package/demo/node_modules/openai/src/_shims/manual-types.mjs +3 -0
- package/demo/node_modules/openai/src/_shims/node-runtime.ts +83 -0
- package/demo/node_modules/openai/src/_shims/node-types.d.ts +42 -0
- package/demo/node_modules/openai/src/_shims/node-types.js +3 -0
- package/demo/node_modules/openai/src/_shims/node-types.mjs +3 -0
- package/demo/node_modules/openai/src/_shims/registry.ts +65 -0
- package/demo/node_modules/openai/src/_shims/web-runtime.ts +103 -0
- package/demo/node_modules/openai/src/_shims/web-types.d.ts +83 -0
- package/demo/node_modules/openai/src/_shims/web-types.js +3 -0
- package/demo/node_modules/openai/src/_shims/web-types.mjs +3 -0
- package/demo/node_modules/openai/src/core.ts +1162 -0
- package/demo/node_modules/openai/src/error.ts +158 -0
- package/demo/node_modules/openai/src/index.ts +502 -0
- package/demo/node_modules/openai/src/lib/.keep +4 -0
- package/demo/node_modules/openai/src/lib/AbstractAssistantStreamRunner.ts +340 -0
- package/demo/node_modules/openai/src/lib/AbstractChatCompletionRunner.ts +682 -0
- package/demo/node_modules/openai/src/lib/AssistantStream.ts +723 -0
- package/demo/node_modules/openai/src/lib/ChatCompletionRunFunctions.test.ts +2328 -0
- package/demo/node_modules/openai/src/lib/ChatCompletionRunner.ts +68 -0
- package/demo/node_modules/openai/src/lib/ChatCompletionStream.ts +494 -0
- package/demo/node_modules/openai/src/lib/ChatCompletionStreamingRunner.ts +68 -0
- package/demo/node_modules/openai/src/lib/RunnableFunction.ts +134 -0
- package/demo/node_modules/openai/src/lib/Util.ts +23 -0
- package/demo/node_modules/openai/src/lib/chatCompletionUtils.ts +28 -0
- package/demo/node_modules/openai/src/lib/jsonschema.ts +148 -0
- package/demo/node_modules/openai/src/pagination.ts +98 -0
- package/demo/node_modules/openai/src/resource.ts +11 -0
- package/demo/node_modules/openai/src/resources/audio/audio.ts +23 -0
- package/demo/node_modules/openai/src/resources/audio/index.ts +6 -0
- package/demo/node_modules/openai/src/resources/audio/speech.ts +52 -0
- package/demo/node_modules/openai/src/resources/audio/transcriptions.ts +84 -0
- package/demo/node_modules/openai/src/resources/audio/translations.ts +61 -0
- package/demo/node_modules/openai/src/resources/batches.ts +252 -0
- package/demo/node_modules/openai/src/resources/beta/assistants.ts +1315 -0
- package/demo/node_modules/openai/src/resources/beta/beta.ts +56 -0
- package/demo/node_modules/openai/src/resources/beta/chat/chat.ts +12 -0
- package/demo/node_modules/openai/src/resources/beta/chat/completions.ts +106 -0
- package/demo/node_modules/openai/src/resources/beta/chat/index.ts +4 -0
- package/demo/node_modules/openai/src/resources/beta/index.ts +48 -0
- package/demo/node_modules/openai/src/resources/beta/threads/index.ts +72 -0
- package/demo/node_modules/openai/src/resources/beta/threads/messages.ts +706 -0
- package/demo/node_modules/openai/src/resources/beta/threads/runs/index.ts +44 -0
- package/demo/node_modules/openai/src/resources/beta/threads/runs/runs.ts +1627 -0
- package/demo/node_modules/openai/src/resources/beta/threads/runs/steps.ts +641 -0
- package/demo/node_modules/openai/src/resources/beta/threads/threads.ts +1536 -0
- package/demo/node_modules/openai/src/resources/beta/vector-stores/file-batches.ts +293 -0
- package/demo/node_modules/openai/src/resources/beta/vector-stores/files.ts +284 -0
- package/demo/node_modules/openai/src/resources/beta/vector-stores/index.ts +25 -0
- package/demo/node_modules/openai/src/resources/beta/vector-stores/vector-stores.ts +318 -0
- package/demo/node_modules/openai/src/resources/chat/chat.ts +67 -0
- package/demo/node_modules/openai/src/resources/chat/completions.ts +996 -0
- package/demo/node_modules/openai/src/resources/chat/index.ts +33 -0
- package/demo/node_modules/openai/src/resources/completions.ts +329 -0
- package/demo/node_modules/openai/src/resources/embeddings.ts +125 -0
- package/demo/node_modules/openai/src/resources/files.ts +214 -0
- package/demo/node_modules/openai/src/resources/fine-tuning/fine-tuning.ts +22 -0
- package/demo/node_modules/openai/src/resources/fine-tuning/index.ts +16 -0
- package/demo/node_modules/openai/src/resources/fine-tuning/jobs/checkpoints.ts +108 -0
- package/demo/node_modules/openai/src/resources/fine-tuning/jobs/index.ts +21 -0
- package/demo/node_modules/openai/src/resources/fine-tuning/jobs/jobs.ts +458 -0
- package/demo/node_modules/openai/src/resources/images.ts +215 -0
- package/demo/node_modules/openai/src/resources/index.ts +45 -0
- package/demo/node_modules/openai/src/resources/models.ts +76 -0
- package/demo/node_modules/openai/src/resources/moderations.ts +214 -0
- package/demo/node_modules/openai/src/resources/shared.ts +47 -0
- package/demo/node_modules/openai/src/shims/node.ts +50 -0
- package/demo/node_modules/openai/src/shims/web.ts +50 -0
- package/demo/node_modules/openai/src/streaming.ts +508 -0
- package/demo/node_modules/openai/src/tsconfig.json +11 -0
- package/demo/node_modules/openai/src/uploads.ts +248 -0
- package/demo/node_modules/openai/src/version.ts +1 -0
- package/demo/node_modules/openai/streaming.d.ts +41 -0
- package/demo/node_modules/openai/streaming.d.ts.map +1 -0
- package/demo/node_modules/openai/streaming.js +433 -0
- package/demo/node_modules/openai/streaming.js.map +1 -0
- package/demo/node_modules/openai/streaming.mjs +426 -0
- package/demo/node_modules/openai/streaming.mjs.map +1 -0
- package/demo/node_modules/openai/uploads.d.ts +75 -0
- package/demo/node_modules/openai/uploads.d.ts.map +1 -0
- package/demo/node_modules/openai/uploads.js +165 -0
- package/demo/node_modules/openai/uploads.js.map +1 -0
- package/demo/node_modules/openai/uploads.mjs +152 -0
- package/demo/node_modules/openai/uploads.mjs.map +1 -0
- package/demo/node_modules/openai/version.d.ts +2 -0
- package/demo/node_modules/openai/version.d.ts.map +1 -0
- package/demo/node_modules/openai/version.js +5 -0
- package/demo/node_modules/openai/version.js.map +1 -0
- package/demo/node_modules/openai/version.mjs +2 -0
- package/demo/node_modules/openai/version.mjs.map +1 -0
- package/demo/node_modules/tr46/index.js +193 -0
- package/demo/node_modules/tr46/lib/.gitkeep +0 -0
- package/demo/node_modules/tr46/lib/mappingTable.json +1 -0
- package/demo/node_modules/tr46/package.json +31 -0
- package/demo/node_modules/undici-types/README.md +6 -0
- package/demo/node_modules/undici-types/agent.d.ts +31 -0
- package/demo/node_modules/undici-types/api.d.ts +43 -0
- package/demo/node_modules/undici-types/balanced-pool.d.ts +18 -0
- package/demo/node_modules/undici-types/cache.d.ts +36 -0
- package/demo/node_modules/undici-types/client.d.ts +97 -0
- package/demo/node_modules/undici-types/connector.d.ts +34 -0
- package/demo/node_modules/undici-types/content-type.d.ts +21 -0
- package/demo/node_modules/undici-types/cookies.d.ts +28 -0
- package/demo/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
- package/demo/node_modules/undici-types/dispatcher.d.ts +241 -0
- package/demo/node_modules/undici-types/errors.d.ts +128 -0
- package/demo/node_modules/undici-types/fetch.d.ts +209 -0
- package/demo/node_modules/undici-types/file.d.ts +39 -0
- package/demo/node_modules/undici-types/filereader.d.ts +54 -0
- package/demo/node_modules/undici-types/formdata.d.ts +108 -0
- package/demo/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/demo/node_modules/undici-types/global-origin.d.ts +7 -0
- package/demo/node_modules/undici-types/handlers.d.ts +9 -0
- package/demo/node_modules/undici-types/header.d.ts +4 -0
- package/demo/node_modules/undici-types/index.d.ts +63 -0
- package/demo/node_modules/undici-types/interceptors.d.ts +5 -0
- package/demo/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/demo/node_modules/undici-types/mock-client.d.ts +25 -0
- package/demo/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/demo/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/demo/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/demo/node_modules/undici-types/package.json +55 -0
- package/demo/node_modules/undici-types/patch.d.ts +71 -0
- package/demo/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/demo/node_modules/undici-types/pool.d.ts +28 -0
- package/demo/node_modules/undici-types/proxy-agent.d.ts +30 -0
- package/demo/node_modules/undici-types/readable.d.ts +61 -0
- package/demo/node_modules/undici-types/webidl.d.ts +220 -0
- package/demo/node_modules/undici-types/websocket.d.ts +131 -0
- package/demo/node_modules/web-streams-polyfill/LICENSE +22 -0
- package/demo/node_modules/web-streams-polyfill/README.md +110 -0
- package/demo/node_modules/web-streams-polyfill/es2018/package.json +14 -0
- package/demo/node_modules/web-streams-polyfill/es6/package.json +14 -0
- package/demo/node_modules/web-streams-polyfill/package.json +83 -0
- package/demo/node_modules/web-streams-polyfill/ponyfill/es2018/package.json +13 -0
- package/demo/node_modules/web-streams-polyfill/ponyfill/es6/package.json +13 -0
- package/demo/node_modules/web-streams-polyfill/ponyfill/package.json +13 -0
- package/demo/node_modules/webidl-conversions/LICENSE.md +12 -0
- package/demo/node_modules/webidl-conversions/README.md +53 -0
- package/demo/node_modules/webidl-conversions/lib/index.js +189 -0
- package/demo/node_modules/webidl-conversions/package.json +23 -0
- package/demo/node_modules/whatwg-url/LICENSE.txt +21 -0
- package/demo/node_modules/whatwg-url/README.md +67 -0
- package/demo/node_modules/whatwg-url/lib/URL-impl.js +200 -0
- package/demo/node_modules/whatwg-url/lib/URL.js +196 -0
- package/demo/node_modules/whatwg-url/lib/public-api.js +11 -0
- package/demo/node_modules/whatwg-url/lib/url-state-machine.js +1297 -0
- package/demo/node_modules/whatwg-url/lib/utils.js +20 -0
- package/demo/node_modules/whatwg-url/package.json +32 -0
- package/demo/package-lock.json +282 -0
- package/demo/package.json +16 -0
- package/index.js +171 -0
- package/package.json +34 -0
|
@@ -0,0 +1,1162 @@
|
|
|
1
|
+
import { VERSION } from './version';
|
|
2
|
+
import { Stream } from './streaming';
|
|
3
|
+
import {
|
|
4
|
+
AnthropicError,
|
|
5
|
+
APIError,
|
|
6
|
+
APIConnectionError,
|
|
7
|
+
APIConnectionTimeoutError,
|
|
8
|
+
APIUserAbortError,
|
|
9
|
+
} from './error';
|
|
10
|
+
import {
|
|
11
|
+
kind as shimsKind,
|
|
12
|
+
type Readable,
|
|
13
|
+
getDefaultAgent,
|
|
14
|
+
type Agent,
|
|
15
|
+
fetch,
|
|
16
|
+
type RequestInfo,
|
|
17
|
+
type RequestInit,
|
|
18
|
+
type Response,
|
|
19
|
+
type HeadersInit,
|
|
20
|
+
} from './_shims/index';
|
|
21
|
+
export { type Response };
|
|
22
|
+
import { isMultipartBody } from './uploads';
|
|
23
|
+
export {
|
|
24
|
+
maybeMultipartFormRequestOptions,
|
|
25
|
+
multipartFormRequestOptions,
|
|
26
|
+
createForm,
|
|
27
|
+
type Uploadable,
|
|
28
|
+
} from './uploads';
|
|
29
|
+
|
|
30
|
+
export type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
31
|
+
|
|
32
|
+
type PromiseOrValue<T> = T | Promise<T>;
|
|
33
|
+
|
|
34
|
+
type APIResponseProps = {
|
|
35
|
+
response: Response;
|
|
36
|
+
options: FinalRequestOptions;
|
|
37
|
+
controller: AbortController;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
|
|
41
|
+
const { response } = props;
|
|
42
|
+
if (props.options.stream) {
|
|
43
|
+
debug('response', response.status, response.url, response.headers, response.body);
|
|
44
|
+
|
|
45
|
+
// Note: there is an invariant here that isn't represented in the type system
|
|
46
|
+
// that if you set `stream: true` the response type must also be `Stream<T>`
|
|
47
|
+
|
|
48
|
+
if (props.options.__streamClass) {
|
|
49
|
+
return props.options.__streamClass.fromSSEResponse(response, props.controller) as any;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return Stream.fromSSEResponse(response, props.controller) as any;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// fetch refuses to read the body when the status code is 204.
|
|
56
|
+
if (response.status === 204) {
|
|
57
|
+
return null as T;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (props.options.__binaryResponse) {
|
|
61
|
+
return response as unknown as T;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const contentType = response.headers.get('content-type');
|
|
65
|
+
const isJSON =
|
|
66
|
+
contentType?.includes('application/json') || contentType?.includes('application/vnd.api+json');
|
|
67
|
+
if (isJSON) {
|
|
68
|
+
const json = await response.json();
|
|
69
|
+
|
|
70
|
+
debug('response', response.status, response.url, response.headers, json);
|
|
71
|
+
|
|
72
|
+
return json as T;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const text = await response.text();
|
|
76
|
+
debug('response', response.status, response.url, response.headers, text);
|
|
77
|
+
|
|
78
|
+
// TODO handle blob, arraybuffer, other content types, etc.
|
|
79
|
+
return text as unknown as T;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A subclass of `Promise` providing additional helper methods
|
|
84
|
+
* for interacting with the SDK.
|
|
85
|
+
*/
|
|
86
|
+
export class APIPromise<T> extends Promise<T> {
|
|
87
|
+
private parsedPromise: Promise<T> | undefined;
|
|
88
|
+
|
|
89
|
+
constructor(
|
|
90
|
+
private responsePromise: Promise<APIResponseProps>,
|
|
91
|
+
private parseResponse: (props: APIResponseProps) => PromiseOrValue<T> = defaultParseResponse,
|
|
92
|
+
) {
|
|
93
|
+
super((resolve) => {
|
|
94
|
+
// this is maybe a bit weird but this has to be a no-op to not implicitly
|
|
95
|
+
// parse the response body; instead .then, .catch, .finally are overridden
|
|
96
|
+
// to parse the response
|
|
97
|
+
resolve(null as any);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
_thenUnwrap<U>(transform: (data: T) => U): APIPromise<U> {
|
|
102
|
+
return new APIPromise(this.responsePromise, async (props) => transform(await this.parseResponse(props)));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Gets the raw `Response` instance instead of parsing the response
|
|
107
|
+
* data.
|
|
108
|
+
*
|
|
109
|
+
* If you want to parse the response body but still get the `Response`
|
|
110
|
+
* instance, you can use {@link withResponse()}.
|
|
111
|
+
*
|
|
112
|
+
* 👋 Getting the wrong TypeScript type for `Response`?
|
|
113
|
+
* Try setting `"moduleResolution": "NodeNext"` if you can,
|
|
114
|
+
* or add one of these imports before your first `import … from '@anthropic-ai/sdk'`:
|
|
115
|
+
* - `import '@anthropic-ai/sdk/shims/node'` (if you're running on Node)
|
|
116
|
+
* - `import '@anthropic-ai/sdk/shims/web'` (otherwise)
|
|
117
|
+
*/
|
|
118
|
+
asResponse(): Promise<Response> {
|
|
119
|
+
return this.responsePromise.then((p) => p.response);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Gets the parsed response data and the raw `Response` instance.
|
|
123
|
+
*
|
|
124
|
+
* If you just want to get the raw `Response` instance without parsing it,
|
|
125
|
+
* you can use {@link asResponse()}.
|
|
126
|
+
*
|
|
127
|
+
*
|
|
128
|
+
* 👋 Getting the wrong TypeScript type for `Response`?
|
|
129
|
+
* Try setting `"moduleResolution": "NodeNext"` if you can,
|
|
130
|
+
* or add one of these imports before your first `import … from '@anthropic-ai/sdk'`:
|
|
131
|
+
* - `import '@anthropic-ai/sdk/shims/node'` (if you're running on Node)
|
|
132
|
+
* - `import '@anthropic-ai/sdk/shims/web'` (otherwise)
|
|
133
|
+
*/
|
|
134
|
+
async withResponse(): Promise<{ data: T; response: Response }> {
|
|
135
|
+
const [data, response] = await Promise.all([this.parse(), this.asResponse()]);
|
|
136
|
+
return { data, response };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private parse(): Promise<T> {
|
|
140
|
+
if (!this.parsedPromise) {
|
|
141
|
+
this.parsedPromise = this.responsePromise.then(this.parseResponse);
|
|
142
|
+
}
|
|
143
|
+
return this.parsedPromise;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
override then<TResult1 = T, TResult2 = never>(
|
|
147
|
+
onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
|
|
148
|
+
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null,
|
|
149
|
+
): Promise<TResult1 | TResult2> {
|
|
150
|
+
return this.parse().then(onfulfilled, onrejected);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
override catch<TResult = never>(
|
|
154
|
+
onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null,
|
|
155
|
+
): Promise<T | TResult> {
|
|
156
|
+
return this.parse().catch(onrejected);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
override finally(onfinally?: (() => void) | undefined | null): Promise<T> {
|
|
160
|
+
return this.parse().finally(onfinally);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export abstract class APIClient {
|
|
165
|
+
baseURL: string;
|
|
166
|
+
maxRetries: number;
|
|
167
|
+
timeout: number;
|
|
168
|
+
httpAgent: Agent | undefined;
|
|
169
|
+
|
|
170
|
+
private fetch: Fetch;
|
|
171
|
+
protected idempotencyHeader?: string;
|
|
172
|
+
|
|
173
|
+
constructor({
|
|
174
|
+
baseURL,
|
|
175
|
+
maxRetries = 2,
|
|
176
|
+
timeout = 600000, // 10 minutes
|
|
177
|
+
httpAgent,
|
|
178
|
+
fetch: overridenFetch,
|
|
179
|
+
}: {
|
|
180
|
+
baseURL: string;
|
|
181
|
+
maxRetries?: number | undefined;
|
|
182
|
+
timeout: number | undefined;
|
|
183
|
+
httpAgent: Agent | undefined;
|
|
184
|
+
fetch: Fetch | undefined;
|
|
185
|
+
}) {
|
|
186
|
+
this.baseURL = baseURL;
|
|
187
|
+
this.maxRetries = validatePositiveInteger('maxRetries', maxRetries);
|
|
188
|
+
this.timeout = validatePositiveInteger('timeout', timeout);
|
|
189
|
+
this.httpAgent = httpAgent;
|
|
190
|
+
|
|
191
|
+
this.fetch = overridenFetch ?? fetch;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
protected authHeaders(opts: FinalRequestOptions): Headers {
|
|
195
|
+
return {};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Override this to add your own default headers, for example:
|
|
200
|
+
*
|
|
201
|
+
* {
|
|
202
|
+
* ...super.defaultHeaders(),
|
|
203
|
+
* Authorization: 'Bearer 123',
|
|
204
|
+
* }
|
|
205
|
+
*/
|
|
206
|
+
protected defaultHeaders(opts: FinalRequestOptions): Headers {
|
|
207
|
+
return {
|
|
208
|
+
Accept: 'application/json',
|
|
209
|
+
'Content-Type': 'application/json',
|
|
210
|
+
'User-Agent': this.getUserAgent(),
|
|
211
|
+
...getPlatformHeaders(),
|
|
212
|
+
...this.authHeaders(opts),
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
protected abstract defaultQuery(): DefaultQuery | undefined;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Override this to add your own headers validation:
|
|
220
|
+
*/
|
|
221
|
+
protected validateHeaders(headers: Headers, customHeaders: Headers) {}
|
|
222
|
+
|
|
223
|
+
protected defaultIdempotencyKey(): string {
|
|
224
|
+
return `stainless-node-retry-${uuid4()}`;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
get<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
|
|
228
|
+
return this.methodRequest('get', path, opts);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
post<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
|
|
232
|
+
return this.methodRequest('post', path, opts);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
patch<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
|
|
236
|
+
return this.methodRequest('patch', path, opts);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
put<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
|
|
240
|
+
return this.methodRequest('put', path, opts);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
delete<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
|
|
244
|
+
return this.methodRequest('delete', path, opts);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
private methodRequest<Req, Rsp>(
|
|
248
|
+
method: HTTPMethod,
|
|
249
|
+
path: string,
|
|
250
|
+
opts?: PromiseOrValue<RequestOptions<Req>>,
|
|
251
|
+
): APIPromise<Rsp> {
|
|
252
|
+
return this.request(Promise.resolve(opts).then((opts) => ({ method, path, ...opts })));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
getAPIList<Item, PageClass extends AbstractPage<Item> = AbstractPage<Item>>(
|
|
256
|
+
path: string,
|
|
257
|
+
Page: new (...args: any[]) => PageClass,
|
|
258
|
+
opts?: RequestOptions<any>,
|
|
259
|
+
): PagePromise<PageClass, Item> {
|
|
260
|
+
return this.requestAPIList(Page, { method: 'get', path, ...opts });
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
private calculateContentLength(body: unknown): string | null {
|
|
264
|
+
if (typeof body === 'string') {
|
|
265
|
+
if (typeof Buffer !== 'undefined') {
|
|
266
|
+
return Buffer.byteLength(body, 'utf8').toString();
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (typeof TextEncoder !== 'undefined') {
|
|
270
|
+
const encoder = new TextEncoder();
|
|
271
|
+
const encoded = encoder.encode(body);
|
|
272
|
+
return encoded.length.toString();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
buildRequest<Req>(options: FinalRequestOptions<Req>): { req: RequestInit; url: string; timeout: number } {
|
|
280
|
+
const { method, path, query, headers: headers = {} } = options;
|
|
281
|
+
|
|
282
|
+
const body =
|
|
283
|
+
isMultipartBody(options.body) ? options.body.body
|
|
284
|
+
: options.body ? JSON.stringify(options.body, null, 2)
|
|
285
|
+
: null;
|
|
286
|
+
const contentLength = this.calculateContentLength(body);
|
|
287
|
+
|
|
288
|
+
const url = this.buildURL(path!, query);
|
|
289
|
+
if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
|
|
290
|
+
const timeout = options.timeout ?? this.timeout;
|
|
291
|
+
const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
|
|
292
|
+
const minAgentTimeout = timeout + 1000;
|
|
293
|
+
if (
|
|
294
|
+
typeof (httpAgent as any)?.options?.timeout === 'number' &&
|
|
295
|
+
minAgentTimeout > ((httpAgent as any).options.timeout ?? 0)
|
|
296
|
+
) {
|
|
297
|
+
// Allow any given request to bump our agent active socket timeout.
|
|
298
|
+
// This may seem strange, but leaking active sockets should be rare and not particularly problematic,
|
|
299
|
+
// and without mutating agent we would need to create more of them.
|
|
300
|
+
// This tradeoff optimizes for performance.
|
|
301
|
+
(httpAgent as any).options.timeout = minAgentTimeout;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (this.idempotencyHeader && method !== 'get') {
|
|
305
|
+
if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey();
|
|
306
|
+
headers[this.idempotencyHeader] = options.idempotencyKey;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const reqHeaders = this.buildHeaders({ options, headers, contentLength });
|
|
310
|
+
|
|
311
|
+
const req: RequestInit = {
|
|
312
|
+
method,
|
|
313
|
+
...(body && { body: body as any }),
|
|
314
|
+
headers: reqHeaders,
|
|
315
|
+
...(httpAgent && { agent: httpAgent }),
|
|
316
|
+
// @ts-ignore node-fetch uses a custom AbortSignal type that is
|
|
317
|
+
// not compatible with standard web types
|
|
318
|
+
signal: options.signal ?? null,
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
return { req, url, timeout };
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
private buildHeaders({
|
|
325
|
+
options,
|
|
326
|
+
headers,
|
|
327
|
+
contentLength,
|
|
328
|
+
}: {
|
|
329
|
+
options: FinalRequestOptions;
|
|
330
|
+
headers: Record<string, string | null | undefined>;
|
|
331
|
+
contentLength: string | null | undefined;
|
|
332
|
+
}): Record<string, string> {
|
|
333
|
+
const reqHeaders: Record<string, string> = {};
|
|
334
|
+
if (contentLength) {
|
|
335
|
+
reqHeaders['content-length'] = contentLength;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
const defaultHeaders = this.defaultHeaders(options);
|
|
339
|
+
applyHeadersMut(reqHeaders, defaultHeaders);
|
|
340
|
+
applyHeadersMut(reqHeaders, headers);
|
|
341
|
+
|
|
342
|
+
// let builtin fetch set the Content-Type for multipart bodies
|
|
343
|
+
if (isMultipartBody(options.body) && shimsKind !== 'node') {
|
|
344
|
+
delete reqHeaders['content-type'];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
this.validateHeaders(reqHeaders, headers);
|
|
348
|
+
|
|
349
|
+
return reqHeaders;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Used as a callback for mutating the given `FinalRequestOptions` object.
|
|
354
|
+
*/
|
|
355
|
+
protected async prepareOptions(options: FinalRequestOptions): Promise<void> {}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Used as a callback for mutating the given `RequestInit` object.
|
|
359
|
+
*
|
|
360
|
+
* This is useful for cases where you want to add certain headers based off of
|
|
361
|
+
* the request properties, e.g. `method` or `url`.
|
|
362
|
+
*/
|
|
363
|
+
protected async prepareRequest(
|
|
364
|
+
request: RequestInit,
|
|
365
|
+
{ url, options }: { url: string; options: FinalRequestOptions },
|
|
366
|
+
): Promise<void> {}
|
|
367
|
+
|
|
368
|
+
protected parseHeaders(headers: HeadersInit | null | undefined): Record<string, string> {
|
|
369
|
+
return (
|
|
370
|
+
!headers ? {}
|
|
371
|
+
: Symbol.iterator in headers ?
|
|
372
|
+
Object.fromEntries(Array.from(headers as Iterable<string[]>).map((header) => [...header]))
|
|
373
|
+
: { ...headers }
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
protected makeStatusError(
|
|
378
|
+
status: number | undefined,
|
|
379
|
+
error: Object | undefined,
|
|
380
|
+
message: string | undefined,
|
|
381
|
+
headers: Headers | undefined,
|
|
382
|
+
) {
|
|
383
|
+
return APIError.generate(status, error, message, headers);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
request<Req, Rsp>(
|
|
387
|
+
options: PromiseOrValue<FinalRequestOptions<Req>>,
|
|
388
|
+
remainingRetries: number | null = null,
|
|
389
|
+
): APIPromise<Rsp> {
|
|
390
|
+
return new APIPromise(this.makeRequest(options, remainingRetries));
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
private async makeRequest<Req>(
|
|
394
|
+
optionsInput: PromiseOrValue<FinalRequestOptions<Req>>,
|
|
395
|
+
retriesRemaining: number | null,
|
|
396
|
+
): Promise<APIResponseProps> {
|
|
397
|
+
const options = await optionsInput;
|
|
398
|
+
if (retriesRemaining == null) {
|
|
399
|
+
retriesRemaining = options.maxRetries ?? this.maxRetries;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
await this.prepareOptions(options);
|
|
403
|
+
|
|
404
|
+
const { req, url, timeout } = this.buildRequest(options);
|
|
405
|
+
|
|
406
|
+
await this.prepareRequest(req, { url, options });
|
|
407
|
+
|
|
408
|
+
debug('request', url, options, req.headers);
|
|
409
|
+
|
|
410
|
+
if (options.signal?.aborted) {
|
|
411
|
+
throw new APIUserAbortError();
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const controller = new AbortController();
|
|
415
|
+
const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
|
|
416
|
+
|
|
417
|
+
if (response instanceof Error) {
|
|
418
|
+
if (options.signal?.aborted) {
|
|
419
|
+
throw new APIUserAbortError();
|
|
420
|
+
}
|
|
421
|
+
if (retriesRemaining) {
|
|
422
|
+
return this.retryRequest(options, retriesRemaining);
|
|
423
|
+
}
|
|
424
|
+
if (response.name === 'AbortError') {
|
|
425
|
+
throw new APIConnectionTimeoutError();
|
|
426
|
+
}
|
|
427
|
+
throw new APIConnectionError({ cause: response });
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
const responseHeaders = createResponseHeaders(response.headers);
|
|
431
|
+
|
|
432
|
+
if (!response.ok) {
|
|
433
|
+
if (retriesRemaining && this.shouldRetry(response)) {
|
|
434
|
+
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
435
|
+
debug(`response (error; ${retryMessage})`, response.status, url, responseHeaders);
|
|
436
|
+
return this.retryRequest(options, retriesRemaining, responseHeaders);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const errText = await response.text().catch((e) => castToError(e).message);
|
|
440
|
+
const errJSON = safeJSON(errText);
|
|
441
|
+
const errMessage = errJSON ? undefined : errText;
|
|
442
|
+
const retryMessage = retriesRemaining ? `(error; no more retries left)` : `(error; not retryable)`;
|
|
443
|
+
|
|
444
|
+
debug(`response (error; ${retryMessage})`, response.status, url, responseHeaders, errMessage);
|
|
445
|
+
|
|
446
|
+
const err = this.makeStatusError(response.status, errJSON, errMessage, responseHeaders);
|
|
447
|
+
throw err;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
return { response, options, controller };
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
requestAPIList<Item = unknown, PageClass extends AbstractPage<Item> = AbstractPage<Item>>(
|
|
454
|
+
Page: new (...args: ConstructorParameters<typeof AbstractPage>) => PageClass,
|
|
455
|
+
options: FinalRequestOptions,
|
|
456
|
+
): PagePromise<PageClass, Item> {
|
|
457
|
+
const request = this.makeRequest(options, null);
|
|
458
|
+
return new PagePromise<PageClass, Item>(this, request, Page);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
buildURL<Req>(path: string, query: Req | null | undefined): string {
|
|
462
|
+
const url =
|
|
463
|
+
isAbsoluteURL(path) ?
|
|
464
|
+
new URL(path)
|
|
465
|
+
: new URL(this.baseURL + (this.baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
466
|
+
|
|
467
|
+
const defaultQuery = this.defaultQuery();
|
|
468
|
+
if (!isEmptyObj(defaultQuery)) {
|
|
469
|
+
query = { ...defaultQuery, ...query } as Req;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (typeof query === 'object' && query && !Array.isArray(query)) {
|
|
473
|
+
url.search = this.stringifyQuery(query as Record<string, unknown>);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return url.toString();
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
protected stringifyQuery(query: Record<string, unknown>): string {
|
|
480
|
+
return Object.entries(query)
|
|
481
|
+
.filter(([_, value]) => typeof value !== 'undefined')
|
|
482
|
+
.map(([key, value]) => {
|
|
483
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
484
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
485
|
+
}
|
|
486
|
+
if (value === null) {
|
|
487
|
+
return `${encodeURIComponent(key)}=`;
|
|
488
|
+
}
|
|
489
|
+
throw new AnthropicError(
|
|
490
|
+
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
|
|
491
|
+
);
|
|
492
|
+
})
|
|
493
|
+
.join('&');
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
async fetchWithTimeout(
|
|
497
|
+
url: RequestInfo,
|
|
498
|
+
init: RequestInit | undefined,
|
|
499
|
+
ms: number,
|
|
500
|
+
controller: AbortController,
|
|
501
|
+
): Promise<Response> {
|
|
502
|
+
const { signal, ...options } = init || {};
|
|
503
|
+
if (signal) signal.addEventListener('abort', () => controller.abort());
|
|
504
|
+
|
|
505
|
+
const timeout = setTimeout(() => controller.abort(), ms);
|
|
506
|
+
|
|
507
|
+
return (
|
|
508
|
+
this.getRequestClient()
|
|
509
|
+
// use undefined this binding; fetch errors if bound to something else in browser/cloudflare
|
|
510
|
+
.fetch.call(undefined, url, { signal: controller.signal as any, ...options })
|
|
511
|
+
.finally(() => {
|
|
512
|
+
clearTimeout(timeout);
|
|
513
|
+
})
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
protected getRequestClient(): RequestClient {
|
|
518
|
+
return { fetch: this.fetch };
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
private shouldRetry(response: Response): boolean {
|
|
522
|
+
// Note this is not a standard header.
|
|
523
|
+
const shouldRetryHeader = response.headers.get('x-should-retry');
|
|
524
|
+
|
|
525
|
+
// If the server explicitly says whether or not to retry, obey.
|
|
526
|
+
if (shouldRetryHeader === 'true') return true;
|
|
527
|
+
if (shouldRetryHeader === 'false') return false;
|
|
528
|
+
|
|
529
|
+
// Retry on request timeouts.
|
|
530
|
+
if (response.status === 408) return true;
|
|
531
|
+
|
|
532
|
+
// Retry on lock timeouts.
|
|
533
|
+
if (response.status === 409) return true;
|
|
534
|
+
|
|
535
|
+
// Retry on rate limits.
|
|
536
|
+
if (response.status === 429) return true;
|
|
537
|
+
|
|
538
|
+
// Retry internal errors.
|
|
539
|
+
if (response.status >= 500) return true;
|
|
540
|
+
|
|
541
|
+
return false;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
private async retryRequest(
|
|
545
|
+
options: FinalRequestOptions,
|
|
546
|
+
retriesRemaining: number,
|
|
547
|
+
responseHeaders?: Headers | undefined,
|
|
548
|
+
): Promise<APIResponseProps> {
|
|
549
|
+
let timeoutMillis: number | undefined;
|
|
550
|
+
|
|
551
|
+
// Note the `retry-after-ms` header may not be standard, but is a good idea and we'd like proactive support for it.
|
|
552
|
+
const retryAfterMillisHeader = responseHeaders?.['retry-after-ms'];
|
|
553
|
+
if (retryAfterMillisHeader) {
|
|
554
|
+
const timeoutMs = parseFloat(retryAfterMillisHeader);
|
|
555
|
+
if (!Number.isNaN(timeoutMs)) {
|
|
556
|
+
timeoutMillis = timeoutMs;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
561
|
+
const retryAfterHeader = responseHeaders?.['retry-after'];
|
|
562
|
+
if (retryAfterHeader && !timeoutMillis) {
|
|
563
|
+
const timeoutSeconds = parseFloat(retryAfterHeader);
|
|
564
|
+
if (!Number.isNaN(timeoutSeconds)) {
|
|
565
|
+
timeoutMillis = timeoutSeconds * 1000;
|
|
566
|
+
} else {
|
|
567
|
+
timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// If the API asks us to wait a certain amount of time (and it's a reasonable amount),
|
|
572
|
+
// just do what it says, but otherwise calculate a default
|
|
573
|
+
if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
|
|
574
|
+
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
575
|
+
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
576
|
+
}
|
|
577
|
+
await sleep(timeoutMillis);
|
|
578
|
+
|
|
579
|
+
return this.makeRequest(options, retriesRemaining - 1);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
private calculateDefaultRetryTimeoutMillis(retriesRemaining: number, maxRetries: number): number {
|
|
583
|
+
const initialRetryDelay = 0.5;
|
|
584
|
+
const maxRetryDelay = 8.0;
|
|
585
|
+
|
|
586
|
+
const numRetries = maxRetries - retriesRemaining;
|
|
587
|
+
|
|
588
|
+
// Apply exponential backoff, but not more than the max.
|
|
589
|
+
const sleepSeconds = Math.min(initialRetryDelay * Math.pow(2, numRetries), maxRetryDelay);
|
|
590
|
+
|
|
591
|
+
// Apply some jitter, take up to at most 25 percent of the retry time.
|
|
592
|
+
const jitter = 1 - Math.random() * 0.25;
|
|
593
|
+
|
|
594
|
+
return sleepSeconds * jitter * 1000;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
private getUserAgent(): string {
|
|
598
|
+
return `${this.constructor.name}/JS ${VERSION}`;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
export type PageInfo = { url: URL } | { params: Record<string, unknown> | null };
|
|
603
|
+
|
|
604
|
+
export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
|
|
605
|
+
#client: APIClient;
|
|
606
|
+
protected options: FinalRequestOptions;
|
|
607
|
+
|
|
608
|
+
protected response: Response;
|
|
609
|
+
protected body: unknown;
|
|
610
|
+
|
|
611
|
+
constructor(client: APIClient, response: Response, body: unknown, options: FinalRequestOptions) {
|
|
612
|
+
this.#client = client;
|
|
613
|
+
this.options = options;
|
|
614
|
+
this.response = response;
|
|
615
|
+
this.body = body;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* @deprecated Use nextPageInfo instead
|
|
620
|
+
*/
|
|
621
|
+
abstract nextPageParams(): Partial<Record<string, unknown>> | null;
|
|
622
|
+
abstract nextPageInfo(): PageInfo | null;
|
|
623
|
+
|
|
624
|
+
abstract getPaginatedItems(): Item[];
|
|
625
|
+
|
|
626
|
+
hasNextPage(): boolean {
|
|
627
|
+
const items = this.getPaginatedItems();
|
|
628
|
+
if (!items.length) return false;
|
|
629
|
+
return this.nextPageInfo() != null;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
async getNextPage(): Promise<this> {
|
|
633
|
+
const nextInfo = this.nextPageInfo();
|
|
634
|
+
if (!nextInfo) {
|
|
635
|
+
throw new AnthropicError(
|
|
636
|
+
'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.',
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
const nextOptions = { ...this.options };
|
|
640
|
+
if ('params' in nextInfo && typeof nextOptions.query === 'object') {
|
|
641
|
+
nextOptions.query = { ...nextOptions.query, ...nextInfo.params };
|
|
642
|
+
} else if ('url' in nextInfo) {
|
|
643
|
+
const params = [...Object.entries(nextOptions.query || {}), ...nextInfo.url.searchParams.entries()];
|
|
644
|
+
for (const [key, value] of params) {
|
|
645
|
+
nextInfo.url.searchParams.set(key, value as any);
|
|
646
|
+
}
|
|
647
|
+
nextOptions.query = undefined;
|
|
648
|
+
nextOptions.path = nextInfo.url.toString();
|
|
649
|
+
}
|
|
650
|
+
return await this.#client.requestAPIList(this.constructor as any, nextOptions);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
async *iterPages() {
|
|
654
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
655
|
+
let page: AbstractPage<Item> = this;
|
|
656
|
+
yield page;
|
|
657
|
+
while (page.hasNextPage()) {
|
|
658
|
+
page = await page.getNextPage();
|
|
659
|
+
yield page;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
async *[Symbol.asyncIterator]() {
|
|
664
|
+
for await (const page of this.iterPages()) {
|
|
665
|
+
for (const item of page.getPaginatedItems()) {
|
|
666
|
+
yield item;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* This subclass of Promise will resolve to an instantiated Page once the request completes.
|
|
674
|
+
*
|
|
675
|
+
* It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg:
|
|
676
|
+
*
|
|
677
|
+
* for await (const item of client.items.list()) {
|
|
678
|
+
* console.log(item)
|
|
679
|
+
* }
|
|
680
|
+
*/
|
|
681
|
+
export class PagePromise<
|
|
682
|
+
PageClass extends AbstractPage<Item>,
|
|
683
|
+
Item = ReturnType<PageClass['getPaginatedItems']>[number],
|
|
684
|
+
>
|
|
685
|
+
extends APIPromise<PageClass>
|
|
686
|
+
implements AsyncIterable<Item>
|
|
687
|
+
{
|
|
688
|
+
constructor(
|
|
689
|
+
client: APIClient,
|
|
690
|
+
request: Promise<APIResponseProps>,
|
|
691
|
+
Page: new (...args: ConstructorParameters<typeof AbstractPage>) => PageClass,
|
|
692
|
+
) {
|
|
693
|
+
super(
|
|
694
|
+
request,
|
|
695
|
+
async (props) => new Page(client, props.response, await defaultParseResponse(props), props.options),
|
|
696
|
+
);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Allow auto-paginating iteration on an unawaited list call, eg:
|
|
701
|
+
*
|
|
702
|
+
* for await (const item of client.items.list()) {
|
|
703
|
+
* console.log(item)
|
|
704
|
+
* }
|
|
705
|
+
*/
|
|
706
|
+
async *[Symbol.asyncIterator]() {
|
|
707
|
+
const page = await this;
|
|
708
|
+
for await (const item of page) {
|
|
709
|
+
yield item;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
export const createResponseHeaders = (
|
|
715
|
+
headers: Awaited<ReturnType<Fetch>>['headers'],
|
|
716
|
+
): Record<string, string> => {
|
|
717
|
+
return new Proxy(
|
|
718
|
+
Object.fromEntries(
|
|
719
|
+
// @ts-ignore
|
|
720
|
+
headers.entries(),
|
|
721
|
+
),
|
|
722
|
+
{
|
|
723
|
+
get(target, name) {
|
|
724
|
+
const key = name.toString();
|
|
725
|
+
return target[key.toLowerCase()] || target[key];
|
|
726
|
+
},
|
|
727
|
+
},
|
|
728
|
+
);
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
type HTTPMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
732
|
+
|
|
733
|
+
export type RequestClient = { fetch: Fetch };
|
|
734
|
+
export type Headers = Record<string, string | null | undefined>;
|
|
735
|
+
export type DefaultQuery = Record<string, string | undefined>;
|
|
736
|
+
export type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
|
737
|
+
|
|
738
|
+
export type RequestOptions<Req = unknown | Record<string, unknown> | Readable> = {
|
|
739
|
+
method?: HTTPMethod;
|
|
740
|
+
path?: string;
|
|
741
|
+
query?: Req | undefined;
|
|
742
|
+
body?: Req | null | undefined;
|
|
743
|
+
headers?: Headers | undefined;
|
|
744
|
+
|
|
745
|
+
maxRetries?: number;
|
|
746
|
+
stream?: boolean | undefined;
|
|
747
|
+
timeout?: number;
|
|
748
|
+
httpAgent?: Agent;
|
|
749
|
+
signal?: AbortSignal | undefined | null;
|
|
750
|
+
idempotencyKey?: string;
|
|
751
|
+
|
|
752
|
+
__binaryResponse?: boolean | undefined;
|
|
753
|
+
__streamClass?: typeof Stream;
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
// This is required so that we can determine if a given object matches the RequestOptions
|
|
757
|
+
// type at runtime. While this requires duplication, it is enforced by the TypeScript
|
|
758
|
+
// compiler such that any missing / extraneous keys will cause an error.
|
|
759
|
+
const requestOptionsKeys: KeysEnum<RequestOptions> = {
|
|
760
|
+
method: true,
|
|
761
|
+
path: true,
|
|
762
|
+
query: true,
|
|
763
|
+
body: true,
|
|
764
|
+
headers: true,
|
|
765
|
+
|
|
766
|
+
maxRetries: true,
|
|
767
|
+
stream: true,
|
|
768
|
+
timeout: true,
|
|
769
|
+
httpAgent: true,
|
|
770
|
+
signal: true,
|
|
771
|
+
idempotencyKey: true,
|
|
772
|
+
|
|
773
|
+
__binaryResponse: true,
|
|
774
|
+
__streamClass: true,
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
export const isRequestOptions = (obj: unknown): obj is RequestOptions => {
|
|
778
|
+
return (
|
|
779
|
+
typeof obj === 'object' &&
|
|
780
|
+
obj !== null &&
|
|
781
|
+
!isEmptyObj(obj) &&
|
|
782
|
+
Object.keys(obj).every((k) => hasOwn(requestOptionsKeys, k))
|
|
783
|
+
);
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
export type FinalRequestOptions<Req = unknown | Record<string, unknown> | Readable> = RequestOptions<Req> & {
|
|
787
|
+
method: HTTPMethod;
|
|
788
|
+
path: string;
|
|
789
|
+
};
|
|
790
|
+
|
|
791
|
+
declare const Deno: any;
|
|
792
|
+
declare const EdgeRuntime: any;
|
|
793
|
+
type Arch = 'x32' | 'x64' | 'arm' | 'arm64' | `other:${string}` | 'unknown';
|
|
794
|
+
type PlatformName =
|
|
795
|
+
| 'MacOS'
|
|
796
|
+
| 'Linux'
|
|
797
|
+
| 'Windows'
|
|
798
|
+
| 'FreeBSD'
|
|
799
|
+
| 'OpenBSD'
|
|
800
|
+
| 'iOS'
|
|
801
|
+
| 'Android'
|
|
802
|
+
| `Other:${string}`
|
|
803
|
+
| 'Unknown';
|
|
804
|
+
type Browser = 'ie' | 'edge' | 'chrome' | 'firefox' | 'safari';
|
|
805
|
+
type PlatformProperties = {
|
|
806
|
+
'X-Stainless-Lang': 'js';
|
|
807
|
+
'X-Stainless-Package-Version': string;
|
|
808
|
+
'X-Stainless-OS': PlatformName;
|
|
809
|
+
'X-Stainless-Arch': Arch;
|
|
810
|
+
'X-Stainless-Runtime': 'node' | 'deno' | 'edge' | `browser:${Browser}` | 'unknown';
|
|
811
|
+
'X-Stainless-Runtime-Version': string;
|
|
812
|
+
};
|
|
813
|
+
const getPlatformProperties = (): PlatformProperties => {
|
|
814
|
+
if (typeof Deno !== 'undefined' && Deno.build != null) {
|
|
815
|
+
return {
|
|
816
|
+
'X-Stainless-Lang': 'js',
|
|
817
|
+
'X-Stainless-Package-Version': VERSION,
|
|
818
|
+
'X-Stainless-OS': normalizePlatform(Deno.build.os),
|
|
819
|
+
'X-Stainless-Arch': normalizeArch(Deno.build.arch),
|
|
820
|
+
'X-Stainless-Runtime': 'deno',
|
|
821
|
+
'X-Stainless-Runtime-Version':
|
|
822
|
+
typeof Deno.version === 'string' ? Deno.version : Deno.version?.deno ?? 'unknown',
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
if (typeof EdgeRuntime !== 'undefined') {
|
|
826
|
+
return {
|
|
827
|
+
'X-Stainless-Lang': 'js',
|
|
828
|
+
'X-Stainless-Package-Version': VERSION,
|
|
829
|
+
'X-Stainless-OS': 'Unknown',
|
|
830
|
+
'X-Stainless-Arch': `other:${EdgeRuntime}`,
|
|
831
|
+
'X-Stainless-Runtime': 'edge',
|
|
832
|
+
'X-Stainless-Runtime-Version': process.version,
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
// Check if Node.js
|
|
836
|
+
if (Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]') {
|
|
837
|
+
return {
|
|
838
|
+
'X-Stainless-Lang': 'js',
|
|
839
|
+
'X-Stainless-Package-Version': VERSION,
|
|
840
|
+
'X-Stainless-OS': normalizePlatform(process.platform),
|
|
841
|
+
'X-Stainless-Arch': normalizeArch(process.arch),
|
|
842
|
+
'X-Stainless-Runtime': 'node',
|
|
843
|
+
'X-Stainless-Runtime-Version': process.version,
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
const browserInfo = getBrowserInfo();
|
|
848
|
+
if (browserInfo) {
|
|
849
|
+
return {
|
|
850
|
+
'X-Stainless-Lang': 'js',
|
|
851
|
+
'X-Stainless-Package-Version': VERSION,
|
|
852
|
+
'X-Stainless-OS': 'Unknown',
|
|
853
|
+
'X-Stainless-Arch': 'unknown',
|
|
854
|
+
'X-Stainless-Runtime': `browser:${browserInfo.browser}`,
|
|
855
|
+
'X-Stainless-Runtime-Version': browserInfo.version,
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// TODO add support for Cloudflare workers, etc.
|
|
860
|
+
return {
|
|
861
|
+
'X-Stainless-Lang': 'js',
|
|
862
|
+
'X-Stainless-Package-Version': VERSION,
|
|
863
|
+
'X-Stainless-OS': 'Unknown',
|
|
864
|
+
'X-Stainless-Arch': 'unknown',
|
|
865
|
+
'X-Stainless-Runtime': 'unknown',
|
|
866
|
+
'X-Stainless-Runtime-Version': 'unknown',
|
|
867
|
+
};
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
type BrowserInfo = {
|
|
871
|
+
browser: Browser;
|
|
872
|
+
version: string;
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
declare const navigator: { userAgent: string } | undefined;
|
|
876
|
+
|
|
877
|
+
// Note: modified from https://github.com/JS-DevTools/host-environment/blob/b1ab79ecde37db5d6e163c050e54fe7d287d7c92/src/isomorphic.browser.ts
|
|
878
|
+
function getBrowserInfo(): BrowserInfo | null {
|
|
879
|
+
if (typeof navigator === 'undefined' || !navigator) {
|
|
880
|
+
return null;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
// NOTE: The order matters here!
|
|
884
|
+
const browserPatterns = [
|
|
885
|
+
{ key: 'edge' as const, pattern: /Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
886
|
+
{ key: 'ie' as const, pattern: /MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
887
|
+
{ key: 'ie' as const, pattern: /Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
888
|
+
{ key: 'chrome' as const, pattern: /Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
889
|
+
{ key: 'firefox' as const, pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
890
|
+
{ key: 'safari' as const, pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/ },
|
|
891
|
+
];
|
|
892
|
+
|
|
893
|
+
// Find the FIRST matching browser
|
|
894
|
+
for (const { key, pattern } of browserPatterns) {
|
|
895
|
+
const match = pattern.exec(navigator.userAgent);
|
|
896
|
+
if (match) {
|
|
897
|
+
const major = match[1] || 0;
|
|
898
|
+
const minor = match[2] || 0;
|
|
899
|
+
const patch = match[3] || 0;
|
|
900
|
+
|
|
901
|
+
return { browser: key, version: `${major}.${minor}.${patch}` };
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
return null;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
const normalizeArch = (arch: string): Arch => {
|
|
909
|
+
// Node docs:
|
|
910
|
+
// - https://nodejs.org/api/process.html#processarch
|
|
911
|
+
// Deno docs:
|
|
912
|
+
// - https://doc.deno.land/deno/stable/~/Deno.build
|
|
913
|
+
if (arch === 'x32') return 'x32';
|
|
914
|
+
if (arch === 'x86_64' || arch === 'x64') return 'x64';
|
|
915
|
+
if (arch === 'arm') return 'arm';
|
|
916
|
+
if (arch === 'aarch64' || arch === 'arm64') return 'arm64';
|
|
917
|
+
if (arch) return `other:${arch}`;
|
|
918
|
+
return 'unknown';
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
const normalizePlatform = (platform: string): PlatformName => {
|
|
922
|
+
// Node platforms:
|
|
923
|
+
// - https://nodejs.org/api/process.html#processplatform
|
|
924
|
+
// Deno platforms:
|
|
925
|
+
// - https://doc.deno.land/deno/stable/~/Deno.build
|
|
926
|
+
// - https://github.com/denoland/deno/issues/14799
|
|
927
|
+
|
|
928
|
+
platform = platform.toLowerCase();
|
|
929
|
+
|
|
930
|
+
// NOTE: this iOS check is untested and may not work
|
|
931
|
+
// Node does not work natively on IOS, there is a fork at
|
|
932
|
+
// https://github.com/nodejs-mobile/nodejs-mobile
|
|
933
|
+
// however it is unknown at the time of writing how to detect if it is running
|
|
934
|
+
if (platform.includes('ios')) return 'iOS';
|
|
935
|
+
if (platform === 'android') return 'Android';
|
|
936
|
+
if (platform === 'darwin') return 'MacOS';
|
|
937
|
+
if (platform === 'win32') return 'Windows';
|
|
938
|
+
if (platform === 'freebsd') return 'FreeBSD';
|
|
939
|
+
if (platform === 'openbsd') return 'OpenBSD';
|
|
940
|
+
if (platform === 'linux') return 'Linux';
|
|
941
|
+
if (platform) return `Other:${platform}`;
|
|
942
|
+
return 'Unknown';
|
|
943
|
+
};
|
|
944
|
+
|
|
945
|
+
let _platformHeaders: PlatformProperties;
|
|
946
|
+
const getPlatformHeaders = () => {
|
|
947
|
+
return (_platformHeaders ??= getPlatformProperties());
|
|
948
|
+
};
|
|
949
|
+
|
|
950
|
+
export const safeJSON = (text: string) => {
|
|
951
|
+
try {
|
|
952
|
+
return JSON.parse(text);
|
|
953
|
+
} catch (err) {
|
|
954
|
+
return undefined;
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
// https://stackoverflow.com/a/19709846
|
|
959
|
+
const startsWithSchemeRegexp = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
960
|
+
const isAbsoluteURL = (url: string): boolean => {
|
|
961
|
+
return startsWithSchemeRegexp.test(url);
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
965
|
+
|
|
966
|
+
const validatePositiveInteger = (name: string, n: unknown): number => {
|
|
967
|
+
if (typeof n !== 'number' || !Number.isInteger(n)) {
|
|
968
|
+
throw new AnthropicError(`${name} must be an integer`);
|
|
969
|
+
}
|
|
970
|
+
if (n < 0) {
|
|
971
|
+
throw new AnthropicError(`${name} must be a positive integer`);
|
|
972
|
+
}
|
|
973
|
+
return n;
|
|
974
|
+
};
|
|
975
|
+
|
|
976
|
+
export const castToError = (err: any): Error => {
|
|
977
|
+
if (err instanceof Error) return err;
|
|
978
|
+
return new Error(err);
|
|
979
|
+
};
|
|
980
|
+
|
|
981
|
+
export const ensurePresent = <T>(value: T | null | undefined): T => {
|
|
982
|
+
if (value == null) throw new AnthropicError(`Expected a value to be given but received ${value} instead.`);
|
|
983
|
+
return value;
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Read an environment variable.
|
|
988
|
+
*
|
|
989
|
+
* Trims beginning and trailing whitespace.
|
|
990
|
+
*
|
|
991
|
+
* Will return undefined if the environment variable doesn't exist or cannot be accessed.
|
|
992
|
+
*/
|
|
993
|
+
export const readEnv = (env: string): string | undefined => {
|
|
994
|
+
if (typeof process !== 'undefined') {
|
|
995
|
+
return process.env?.[env]?.trim() ?? undefined;
|
|
996
|
+
}
|
|
997
|
+
if (typeof Deno !== 'undefined') {
|
|
998
|
+
return Deno.env?.get?.(env)?.trim();
|
|
999
|
+
}
|
|
1000
|
+
return undefined;
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
export const coerceInteger = (value: unknown): number => {
|
|
1004
|
+
if (typeof value === 'number') return Math.round(value);
|
|
1005
|
+
if (typeof value === 'string') return parseInt(value, 10);
|
|
1006
|
+
|
|
1007
|
+
throw new AnthropicError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
export const coerceFloat = (value: unknown): number => {
|
|
1011
|
+
if (typeof value === 'number') return value;
|
|
1012
|
+
if (typeof value === 'string') return parseFloat(value);
|
|
1013
|
+
|
|
1014
|
+
throw new AnthropicError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
export const coerceBoolean = (value: unknown): boolean => {
|
|
1018
|
+
if (typeof value === 'boolean') return value;
|
|
1019
|
+
if (typeof value === 'string') return value === 'true';
|
|
1020
|
+
return Boolean(value);
|
|
1021
|
+
};
|
|
1022
|
+
|
|
1023
|
+
export const maybeCoerceInteger = (value: unknown): number | undefined => {
|
|
1024
|
+
if (value === undefined) {
|
|
1025
|
+
return undefined;
|
|
1026
|
+
}
|
|
1027
|
+
return coerceInteger(value);
|
|
1028
|
+
};
|
|
1029
|
+
|
|
1030
|
+
export const maybeCoerceFloat = (value: unknown): number | undefined => {
|
|
1031
|
+
if (value === undefined) {
|
|
1032
|
+
return undefined;
|
|
1033
|
+
}
|
|
1034
|
+
return coerceFloat(value);
|
|
1035
|
+
};
|
|
1036
|
+
|
|
1037
|
+
export const maybeCoerceBoolean = (value: unknown): boolean | undefined => {
|
|
1038
|
+
if (value === undefined) {
|
|
1039
|
+
return undefined;
|
|
1040
|
+
}
|
|
1041
|
+
return coerceBoolean(value);
|
|
1042
|
+
};
|
|
1043
|
+
|
|
1044
|
+
// https://stackoverflow.com/a/34491287
|
|
1045
|
+
export function isEmptyObj(obj: Object | null | undefined): boolean {
|
|
1046
|
+
if (!obj) return true;
|
|
1047
|
+
for (const _k in obj) return false;
|
|
1048
|
+
return true;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// https://eslint.org/docs/latest/rules/no-prototype-builtins
|
|
1052
|
+
export function hasOwn(obj: Object, key: string): boolean {
|
|
1053
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Copies headers from "newHeaders" onto "targetHeaders",
|
|
1058
|
+
* using lower-case for all properties,
|
|
1059
|
+
* ignoring any keys with undefined values,
|
|
1060
|
+
* and deleting any keys with null values.
|
|
1061
|
+
*/
|
|
1062
|
+
function applyHeadersMut(targetHeaders: Headers, newHeaders: Headers): void {
|
|
1063
|
+
for (const k in newHeaders) {
|
|
1064
|
+
if (!hasOwn(newHeaders, k)) continue;
|
|
1065
|
+
const lowerKey = k.toLowerCase();
|
|
1066
|
+
if (!lowerKey) continue;
|
|
1067
|
+
|
|
1068
|
+
const val = newHeaders[k];
|
|
1069
|
+
|
|
1070
|
+
if (val === null) {
|
|
1071
|
+
delete targetHeaders[lowerKey];
|
|
1072
|
+
} else if (val !== undefined) {
|
|
1073
|
+
targetHeaders[lowerKey] = val;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
export function debug(action: string, ...args: any[]) {
|
|
1079
|
+
if (typeof process !== 'undefined' && process?.env?.['DEBUG'] === 'true') {
|
|
1080
|
+
console.log(`Anthropic:DEBUG:${action}`, ...args);
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* https://stackoverflow.com/a/2117523
|
|
1086
|
+
*/
|
|
1087
|
+
const uuid4 = () => {
|
|
1088
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
1089
|
+
const r = (Math.random() * 16) | 0;
|
|
1090
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
1091
|
+
return v.toString(16);
|
|
1092
|
+
});
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
export const isRunningInBrowser = () => {
|
|
1096
|
+
return (
|
|
1097
|
+
// @ts-ignore
|
|
1098
|
+
typeof window !== 'undefined' &&
|
|
1099
|
+
// @ts-ignore
|
|
1100
|
+
typeof window.document !== 'undefined' &&
|
|
1101
|
+
// @ts-ignore
|
|
1102
|
+
typeof navigator !== 'undefined'
|
|
1103
|
+
);
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
export interface HeadersProtocol {
|
|
1107
|
+
get: (header: string) => string | null | undefined;
|
|
1108
|
+
}
|
|
1109
|
+
export type HeadersLike = Record<string, string | string[] | undefined> | HeadersProtocol;
|
|
1110
|
+
|
|
1111
|
+
export const isHeadersProtocol = (headers: any): headers is HeadersProtocol => {
|
|
1112
|
+
return typeof headers?.get === 'function';
|
|
1113
|
+
};
|
|
1114
|
+
|
|
1115
|
+
export const getRequiredHeader = (headers: HeadersLike, header: string): string => {
|
|
1116
|
+
const lowerCasedHeader = header.toLowerCase();
|
|
1117
|
+
if (isHeadersProtocol(headers)) {
|
|
1118
|
+
// to deal with the case where the header looks like Stainless-Event-Id
|
|
1119
|
+
const intercapsHeader =
|
|
1120
|
+
header[0]?.toUpperCase() +
|
|
1121
|
+
header.substring(1).replace(/([^\w])(\w)/g, (_m, g1, g2) => g1 + g2.toUpperCase());
|
|
1122
|
+
for (const key of [header, lowerCasedHeader, header.toUpperCase(), intercapsHeader]) {
|
|
1123
|
+
const value = headers.get(key);
|
|
1124
|
+
if (value) {
|
|
1125
|
+
return value;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
1131
|
+
if (key.toLowerCase() === lowerCasedHeader) {
|
|
1132
|
+
if (Array.isArray(value)) {
|
|
1133
|
+
if (value.length <= 1) return value[0];
|
|
1134
|
+
console.warn(`Received ${value.length} entries for the ${header} header, using the first entry.`);
|
|
1135
|
+
return value[0];
|
|
1136
|
+
}
|
|
1137
|
+
return value;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
throw new Error(`Could not find ${header} header`);
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* Encodes a string to Base64 format.
|
|
1146
|
+
*/
|
|
1147
|
+
export const toBase64 = (str: string | null | undefined): string => {
|
|
1148
|
+
if (!str) return '';
|
|
1149
|
+
if (typeof Buffer !== 'undefined') {
|
|
1150
|
+
return Buffer.from(str).toString('base64');
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
if (typeof btoa !== 'undefined') {
|
|
1154
|
+
return btoa(str);
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
throw new AnthropicError('Cannot generate b64 string; Expected `Buffer` or `btoa` to be defined');
|
|
1158
|
+
};
|
|
1159
|
+
|
|
1160
|
+
export function isObj(obj: unknown): obj is Record<string, unknown> {
|
|
1161
|
+
return obj != null && typeof obj === 'object' && !Array.isArray(obj);
|
|
1162
|
+
}
|