@anthropic-ai/claude-code 0.2.9
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/LICENSE.md +3 -0
- package/README.md +55 -0
- package/cli.mjs +1398 -0
- package/package.json +31 -0
- package/vendor/ripgrep/COPYING +3 -0
- package/vendor/ripgrep/arm64-darwin/rg +0 -0
- package/vendor/ripgrep/arm64-linux/rg +0 -0
- package/vendor/ripgrep/x64-darwin/rg +0 -0
- package/vendor/ripgrep/x64-linux/rg +0 -0
- package/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/vendor/sdk/CHANGELOG.md +1421 -0
- package/vendor/sdk/LICENSE +8 -0
- package/vendor/sdk/README.md +536 -0
- package/vendor/sdk/_shims/MultipartBody.d.ts +9 -0
- package/vendor/sdk/_shims/MultipartBody.d.ts.map +1 -0
- package/vendor/sdk/_shims/MultipartBody.js +16 -0
- package/vendor/sdk/_shims/MultipartBody.js.map +1 -0
- package/vendor/sdk/_shims/MultipartBody.mjs +12 -0
- package/vendor/sdk/_shims/MultipartBody.mjs.map +1 -0
- package/vendor/sdk/_shims/README.md +46 -0
- package/vendor/sdk/_shims/auto/runtime-bun.d.ts +5 -0
- package/vendor/sdk/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/vendor/sdk/_shims/auto/runtime-bun.js +21 -0
- package/vendor/sdk/_shims/auto/runtime-bun.js.map +1 -0
- package/vendor/sdk/_shims/auto/runtime-bun.mjs +2 -0
- package/vendor/sdk/_shims/auto/runtime-bun.mjs.map +1 -0
- package/vendor/sdk/_shims/auto/runtime-node.d.ts +5 -0
- package/vendor/sdk/_shims/auto/runtime-node.d.ts.map +1 -0
- package/vendor/sdk/_shims/auto/runtime-node.js +21 -0
- package/vendor/sdk/_shims/auto/runtime-node.js.map +1 -0
- package/vendor/sdk/_shims/auto/runtime-node.mjs +2 -0
- package/vendor/sdk/_shims/auto/runtime-node.mjs.map +1 -0
- package/vendor/sdk/_shims/auto/runtime.d.ts +5 -0
- package/vendor/sdk/_shims/auto/runtime.d.ts.map +1 -0
- package/vendor/sdk/_shims/auto/runtime.js +21 -0
- package/vendor/sdk/_shims/auto/runtime.js.map +1 -0
- package/vendor/sdk/_shims/auto/runtime.mjs +2 -0
- package/vendor/sdk/_shims/auto/runtime.mjs.map +1 -0
- package/vendor/sdk/_shims/auto/types-node.d.ts +5 -0
- package/vendor/sdk/_shims/auto/types-node.d.ts.map +1 -0
- package/vendor/sdk/_shims/auto/types-node.js +21 -0
- package/vendor/sdk/_shims/auto/types-node.js.map +1 -0
- package/vendor/sdk/_shims/auto/types-node.mjs +2 -0
- package/vendor/sdk/_shims/auto/types-node.mjs.map +1 -0
- package/vendor/sdk/_shims/auto/types.d.ts +101 -0
- package/vendor/sdk/_shims/auto/types.js +3 -0
- package/vendor/sdk/_shims/auto/types.mjs +3 -0
- package/vendor/sdk/_shims/bun-runtime.d.ts +6 -0
- package/vendor/sdk/_shims/bun-runtime.d.ts.map +1 -0
- package/vendor/sdk/_shims/bun-runtime.js +14 -0
- package/vendor/sdk/_shims/bun-runtime.js.map +1 -0
- package/vendor/sdk/_shims/bun-runtime.mjs +10 -0
- package/vendor/sdk/_shims/bun-runtime.mjs.map +1 -0
- package/vendor/sdk/_shims/index.d.ts +81 -0
- package/vendor/sdk/_shims/index.js +13 -0
- package/vendor/sdk/_shims/index.mjs +7 -0
- package/vendor/sdk/_shims/manual-types.d.ts +12 -0
- package/vendor/sdk/_shims/manual-types.js +3 -0
- package/vendor/sdk/_shims/manual-types.mjs +3 -0
- package/vendor/sdk/_shims/node-runtime.d.ts +3 -0
- package/vendor/sdk/_shims/node-runtime.d.ts.map +1 -0
- package/vendor/sdk/_shims/node-runtime.js +89 -0
- package/vendor/sdk/_shims/node-runtime.js.map +1 -0
- package/vendor/sdk/_shims/node-runtime.mjs +56 -0
- package/vendor/sdk/_shims/node-runtime.mjs.map +1 -0
- package/vendor/sdk/_shims/node-types.d.ts +42 -0
- package/vendor/sdk/_shims/node-types.js +3 -0
- package/vendor/sdk/_shims/node-types.mjs +3 -0
- package/vendor/sdk/_shims/registry.d.ts +37 -0
- package/vendor/sdk/_shims/registry.d.ts.map +1 -0
- package/vendor/sdk/_shims/registry.js +41 -0
- package/vendor/sdk/_shims/registry.js.map +1 -0
- package/vendor/sdk/_shims/registry.mjs +37 -0
- package/vendor/sdk/_shims/registry.mjs.map +1 -0
- package/vendor/sdk/_shims/web-runtime.d.ts +5 -0
- package/vendor/sdk/_shims/web-runtime.d.ts.map +1 -0
- package/vendor/sdk/_shims/web-runtime.js +78 -0
- package/vendor/sdk/_shims/web-runtime.js.map +1 -0
- package/vendor/sdk/_shims/web-runtime.mjs +71 -0
- package/vendor/sdk/_shims/web-runtime.mjs.map +1 -0
- package/vendor/sdk/_shims/web-types.d.ts +83 -0
- package/vendor/sdk/_shims/web-types.js +3 -0
- package/vendor/sdk/_shims/web-types.mjs +3 -0
- package/vendor/sdk/_vendor/partial-json-parser/parser.d.ts +3 -0
- package/vendor/sdk/_vendor/partial-json-parser/parser.d.ts.map +1 -0
- package/vendor/sdk/_vendor/partial-json-parser/parser.js +226 -0
- package/vendor/sdk/_vendor/partial-json-parser/parser.js.map +1 -0
- package/vendor/sdk/_vendor/partial-json-parser/parser.mjs +223 -0
- package/vendor/sdk/_vendor/partial-json-parser/parser.mjs.map +1 -0
- package/vendor/sdk/core.d.ts +248 -0
- package/vendor/sdk/core.d.ts.map +1 -0
- package/vendor/sdk/core.js +935 -0
- package/vendor/sdk/core.js.map +1 -0
- package/vendor/sdk/core.mjs +903 -0
- package/vendor/sdk/core.mjs.map +1 -0
- package/vendor/sdk/error.d.ts +48 -0
- package/vendor/sdk/error.d.ts.map +1 -0
- package/vendor/sdk/error.js +114 -0
- package/vendor/sdk/error.js.map +1 -0
- package/vendor/sdk/error.mjs +98 -0
- package/vendor/sdk/error.mjs.map +1 -0
- package/vendor/sdk/index.d.mts +152 -0
- package/vendor/sdk/index.d.ts +152 -0
- package/vendor/sdk/index.d.ts.map +1 -0
- package/vendor/sdk/index.js +179 -0
- package/vendor/sdk/index.js.map +1 -0
- package/vendor/sdk/index.mjs +136 -0
- package/vendor/sdk/index.mjs.map +1 -0
- package/vendor/sdk/internal/decoders/jsonl.d.ts +12 -0
- package/vendor/sdk/internal/decoders/jsonl.d.ts.map +1 -0
- package/vendor/sdk/internal/decoders/jsonl.js +35 -0
- package/vendor/sdk/internal/decoders/jsonl.js.map +1 -0
- package/vendor/sdk/internal/decoders/jsonl.mjs +31 -0
- package/vendor/sdk/internal/decoders/jsonl.mjs.map +1 -0
- package/vendor/sdk/internal/decoders/line.d.ts +20 -0
- package/vendor/sdk/internal/decoders/line.d.ts.map +1 -0
- package/vendor/sdk/internal/decoders/line.js +123 -0
- package/vendor/sdk/internal/decoders/line.js.map +1 -0
- package/vendor/sdk/internal/decoders/line.mjs +119 -0
- package/vendor/sdk/internal/decoders/line.mjs.map +1 -0
- package/vendor/sdk/internal/stream-utils.d.ts +8 -0
- package/vendor/sdk/internal/stream-utils.d.ts.map +1 -0
- package/vendor/sdk/internal/stream-utils.js +39 -0
- package/vendor/sdk/internal/stream-utils.js.map +1 -0
- package/vendor/sdk/internal/stream-utils.mjs +35 -0
- package/vendor/sdk/internal/stream-utils.mjs.map +1 -0
- package/vendor/sdk/lib/BetaMessageStream.d.ts +114 -0
- package/vendor/sdk/lib/BetaMessageStream.d.ts.map +1 -0
- package/vendor/sdk/lib/BetaMessageStream.js +547 -0
- package/vendor/sdk/lib/BetaMessageStream.js.map +1 -0
- package/vendor/sdk/lib/BetaMessageStream.mjs +543 -0
- package/vendor/sdk/lib/BetaMessageStream.mjs.map +1 -0
- package/vendor/sdk/lib/MessageStream.d.ts +114 -0
- package/vendor/sdk/lib/MessageStream.d.ts.map +1 -0
- package/vendor/sdk/lib/MessageStream.js +547 -0
- package/vendor/sdk/lib/MessageStream.js.map +1 -0
- package/vendor/sdk/lib/MessageStream.mjs +543 -0
- package/vendor/sdk/lib/MessageStream.mjs.map +1 -0
- package/vendor/sdk/node_modules/@types/node/LICENSE +21 -0
- package/vendor/sdk/node_modules/@types/node/README.md +15 -0
- package/vendor/sdk/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/vendor/sdk/node_modules/@types/node/assert.d.ts +985 -0
- package/vendor/sdk/node_modules/@types/node/async_hooks.d.ts +522 -0
- package/vendor/sdk/node_modules/@types/node/buffer.buffer.d.ts +385 -0
- package/vendor/sdk/node_modules/@types/node/buffer.d.ts +1903 -0
- package/vendor/sdk/node_modules/@types/node/child_process.d.ts +1549 -0
- package/vendor/sdk/node_modules/@types/node/cluster.d.ts +578 -0
- package/vendor/sdk/node_modules/@types/node/compatibility/disposable.d.ts +14 -0
- package/vendor/sdk/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/vendor/sdk/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
- package/vendor/sdk/node_modules/@types/node/compatibility/iterators.d.ts +20 -0
- package/vendor/sdk/node_modules/@types/node/console.d.ts +452 -0
- package/vendor/sdk/node_modules/@types/node/constants.d.ts +19 -0
- package/vendor/sdk/node_modules/@types/node/crypto.d.ts +4453 -0
- package/vendor/sdk/node_modules/@types/node/dgram.d.ts +596 -0
- package/vendor/sdk/node_modules/@types/node/diagnostics_channel.d.ts +546 -0
- package/vendor/sdk/node_modules/@types/node/dns/promises.d.ts +475 -0
- package/vendor/sdk/node_modules/@types/node/dns.d.ts +853 -0
- package/vendor/sdk/node_modules/@types/node/dom-events.d.ts +124 -0
- package/vendor/sdk/node_modules/@types/node/domain.d.ts +170 -0
- package/vendor/sdk/node_modules/@types/node/events.d.ts +819 -0
- package/vendor/sdk/node_modules/@types/node/fs/promises.d.ts +1205 -0
- package/vendor/sdk/node_modules/@types/node/fs.d.ts +4237 -0
- package/vendor/sdk/node_modules/@types/node/globals.d.ts +442 -0
- package/vendor/sdk/node_modules/@types/node/globals.typedarray.d.ts +21 -0
- package/vendor/sdk/node_modules/@types/node/http.d.ts +1839 -0
- package/vendor/sdk/node_modules/@types/node/http2.d.ts +2517 -0
- package/vendor/sdk/node_modules/@types/node/https.d.ts +544 -0
- package/vendor/sdk/node_modules/@types/node/index.d.ts +90 -0
- package/vendor/sdk/node_modules/@types/node/inspector.d.ts +2775 -0
- package/vendor/sdk/node_modules/@types/node/module.d.ts +291 -0
- package/vendor/sdk/node_modules/@types/node/net.d.ts +924 -0
- package/vendor/sdk/node_modules/@types/node/os.d.ts +473 -0
- package/vendor/sdk/node_modules/@types/node/package.json +225 -0
- package/vendor/sdk/node_modules/@types/node/path.d.ts +191 -0
- package/vendor/sdk/node_modules/@types/node/perf_hooks.d.ts +753 -0
- package/vendor/sdk/node_modules/@types/node/process.d.ts +1553 -0
- package/vendor/sdk/node_modules/@types/node/punycode.d.ts +117 -0
- package/vendor/sdk/node_modules/@types/node/querystring.d.ts +141 -0
- package/vendor/sdk/node_modules/@types/node/readline/promises.d.ts +154 -0
- package/vendor/sdk/node_modules/@types/node/readline.d.ts +715 -0
- package/vendor/sdk/node_modules/@types/node/repl.d.ts +430 -0
- package/vendor/sdk/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/vendor/sdk/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/vendor/sdk/node_modules/@types/node/stream/web.d.ts +523 -0
- package/vendor/sdk/node_modules/@types/node/stream.d.ts +1731 -0
- package/vendor/sdk/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/vendor/sdk/node_modules/@types/node/test.d.ts +1245 -0
- package/vendor/sdk/node_modules/@types/node/timers/promises.d.ts +93 -0
- package/vendor/sdk/node_modules/@types/node/timers.d.ts +126 -0
- package/vendor/sdk/node_modules/@types/node/tls.d.ts +1203 -0
- package/vendor/sdk/node_modules/@types/node/trace_events.d.ts +171 -0
- package/vendor/sdk/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +385 -0
- package/vendor/sdk/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +19 -0
- package/vendor/sdk/node_modules/@types/node/ts5.6/index.d.ts +90 -0
- package/vendor/sdk/node_modules/@types/node/tty.d.ts +206 -0
- package/vendor/sdk/node_modules/@types/node/url.d.ts +957 -0
- package/vendor/sdk/node_modules/@types/node/util.d.ts +2083 -0
- package/vendor/sdk/node_modules/@types/node/v8.d.ts +753 -0
- package/vendor/sdk/node_modules/@types/node/vm.d.ts +666 -0
- package/vendor/sdk/node_modules/@types/node/wasi.d.ts +160 -0
- package/vendor/sdk/node_modules/@types/node/worker_threads.d.ts +695 -0
- package/vendor/sdk/node_modules/@types/node/zlib.d.ts +517 -0
- package/vendor/sdk/node_modules/undici-types/README.md +6 -0
- package/vendor/sdk/node_modules/undici-types/agent.d.ts +31 -0
- package/vendor/sdk/node_modules/undici-types/api.d.ts +43 -0
- package/vendor/sdk/node_modules/undici-types/balanced-pool.d.ts +18 -0
- package/vendor/sdk/node_modules/undici-types/cache.d.ts +36 -0
- package/vendor/sdk/node_modules/undici-types/client.d.ts +97 -0
- package/vendor/sdk/node_modules/undici-types/connector.d.ts +34 -0
- package/vendor/sdk/node_modules/undici-types/content-type.d.ts +21 -0
- package/vendor/sdk/node_modules/undici-types/cookies.d.ts +28 -0
- package/vendor/sdk/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
- package/vendor/sdk/node_modules/undici-types/dispatcher.d.ts +241 -0
- package/vendor/sdk/node_modules/undici-types/errors.d.ts +128 -0
- package/vendor/sdk/node_modules/undici-types/fetch.d.ts +209 -0
- package/vendor/sdk/node_modules/undici-types/file.d.ts +39 -0
- package/vendor/sdk/node_modules/undici-types/filereader.d.ts +54 -0
- package/vendor/sdk/node_modules/undici-types/formdata.d.ts +108 -0
- package/vendor/sdk/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/vendor/sdk/node_modules/undici-types/global-origin.d.ts +7 -0
- package/vendor/sdk/node_modules/undici-types/handlers.d.ts +9 -0
- package/vendor/sdk/node_modules/undici-types/header.d.ts +4 -0
- package/vendor/sdk/node_modules/undici-types/index.d.ts +63 -0
- package/vendor/sdk/node_modules/undici-types/interceptors.d.ts +5 -0
- package/vendor/sdk/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/vendor/sdk/node_modules/undici-types/mock-client.d.ts +25 -0
- package/vendor/sdk/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/vendor/sdk/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/vendor/sdk/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/vendor/sdk/node_modules/undici-types/package.json +55 -0
- package/vendor/sdk/node_modules/undici-types/patch.d.ts +71 -0
- package/vendor/sdk/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/vendor/sdk/node_modules/undici-types/pool.d.ts +28 -0
- package/vendor/sdk/node_modules/undici-types/proxy-agent.d.ts +30 -0
- package/vendor/sdk/node_modules/undici-types/readable.d.ts +61 -0
- package/vendor/sdk/node_modules/undici-types/webidl.d.ts +220 -0
- package/vendor/sdk/node_modules/undici-types/websocket.d.ts +131 -0
- package/vendor/sdk/package.json +124 -0
- package/vendor/sdk/pagination.d.ts +27 -0
- package/vendor/sdk/pagination.d.ts.map +1 -0
- package/vendor/sdk/pagination.js +60 -0
- package/vendor/sdk/pagination.js.map +1 -0
- package/vendor/sdk/pagination.mjs +56 -0
- package/vendor/sdk/pagination.mjs.map +1 -0
- package/vendor/sdk/resource.d.ts +6 -0
- package/vendor/sdk/resource.d.ts.map +1 -0
- package/vendor/sdk/resource.js +11 -0
- package/vendor/sdk/resource.js.map +1 -0
- package/vendor/sdk/resource.mjs +7 -0
- package/vendor/sdk/resource.mjs.map +1 -0
- package/vendor/sdk/resources/beta/beta.d.ts +57 -0
- package/vendor/sdk/resources/beta/beta.d.ts.map +1 -0
- package/vendor/sdk/resources/beta/beta.js +44 -0
- package/vendor/sdk/resources/beta/beta.js.map +1 -0
- package/vendor/sdk/resources/beta/beta.mjs +17 -0
- package/vendor/sdk/resources/beta/beta.mjs.map +1 -0
- package/vendor/sdk/resources/beta/index.d.ts +4 -0
- package/vendor/sdk/resources/beta/index.d.ts.map +1 -0
- package/vendor/sdk/resources/beta/index.js +12 -0
- package/vendor/sdk/resources/beta/index.js.map +1 -0
- package/vendor/sdk/resources/beta/index.mjs +5 -0
- package/vendor/sdk/resources/beta/index.mjs.map +1 -0
- package/vendor/sdk/resources/beta/messages/batches.d.ts +289 -0
- package/vendor/sdk/resources/beta/messages/batches.d.ts.map +1 -0
- package/vendor/sdk/resources/beta/messages/batches.js +112 -0
- package/vendor/sdk/resources/beta/messages/batches.js.map +1 -0
- package/vendor/sdk/resources/beta/messages/batches.mjs +107 -0
- package/vendor/sdk/resources/beta/messages/batches.mjs.map +1 -0
- package/vendor/sdk/resources/beta/messages/index.d.ts +3 -0
- package/vendor/sdk/resources/beta/messages/index.d.ts.map +1 -0
- package/vendor/sdk/resources/beta/messages/index.js +10 -0
- package/vendor/sdk/resources/beta/messages/index.js.map +1 -0
- package/vendor/sdk/resources/beta/messages/index.mjs +4 -0
- package/vendor/sdk/resources/beta/messages/index.mjs.map +1 -0
- package/vendor/sdk/resources/beta/messages/messages.d.ts +1038 -0
- package/vendor/sdk/resources/beta/messages/messages.d.ts.map +1 -0
- package/vendor/sdk/resources/beta/messages/messages.js +93 -0
- package/vendor/sdk/resources/beta/messages/messages.js.map +1 -0
- package/vendor/sdk/resources/beta/messages/messages.mjs +66 -0
- package/vendor/sdk/resources/beta/messages/messages.mjs.map +1 -0
- package/vendor/sdk/resources/beta/models.d.ts +49 -0
- package/vendor/sdk/resources/beta/models.d.ts.map +1 -0
- package/vendor/sdk/resources/beta/models.js +30 -0
- package/vendor/sdk/resources/beta/models.js.map +1 -0
- package/vendor/sdk/resources/beta/models.mjs +25 -0
- package/vendor/sdk/resources/beta/models.mjs.map +1 -0
- package/vendor/sdk/resources/completions.d.ts +166 -0
- package/vendor/sdk/resources/completions.d.ts.map +1 -0
- package/vendor/sdk/resources/completions.js +17 -0
- package/vendor/sdk/resources/completions.js.map +1 -0
- package/vendor/sdk/resources/completions.mjs +13 -0
- package/vendor/sdk/resources/completions.mjs.map +1 -0
- package/vendor/sdk/resources/index.d.ts +6 -0
- package/vendor/sdk/resources/index.d.ts.map +1 -0
- package/vendor/sdk/resources/index.js +29 -0
- package/vendor/sdk/resources/index.js.map +1 -0
- package/vendor/sdk/resources/index.mjs +7 -0
- package/vendor/sdk/resources/index.mjs.map +1 -0
- package/vendor/sdk/resources/messages/batches.d.ts +253 -0
- package/vendor/sdk/resources/messages/batches.d.ts.map +1 -0
- package/vendor/sdk/resources/messages/batches.js +102 -0
- package/vendor/sdk/resources/messages/batches.js.map +1 -0
- package/vendor/sdk/resources/messages/batches.mjs +97 -0
- package/vendor/sdk/resources/messages/batches.mjs.map +1 -0
- package/vendor/sdk/resources/messages/index.d.ts +3 -0
- package/vendor/sdk/resources/messages/index.d.ts.map +1 -0
- package/vendor/sdk/resources/messages/index.js +10 -0
- package/vendor/sdk/resources/messages/index.js.map +1 -0
- package/vendor/sdk/resources/messages/index.mjs +4 -0
- package/vendor/sdk/resources/messages/index.mjs.map +1 -0
- package/vendor/sdk/resources/messages/messages.d.ts +1028 -0
- package/vendor/sdk/resources/messages/messages.d.ts.map +1 -0
- package/vendor/sdk/resources/messages/messages.js +82 -0
- package/vendor/sdk/resources/messages/messages.js.map +1 -0
- package/vendor/sdk/resources/messages/messages.mjs +54 -0
- package/vendor/sdk/resources/messages/messages.mjs.map +1 -0
- package/vendor/sdk/resources/models.d.ts +49 -0
- package/vendor/sdk/resources/models.d.ts.map +1 -0
- package/vendor/sdk/resources/models.js +30 -0
- package/vendor/sdk/resources/models.js.map +1 -0
- package/vendor/sdk/resources/models.mjs +25 -0
- package/vendor/sdk/resources/models.mjs.map +1 -0
- package/vendor/sdk/resources/shared.d.ts +42 -0
- package/vendor/sdk/resources/shared.d.ts.map +1 -0
- package/vendor/sdk/resources/shared.js +4 -0
- package/vendor/sdk/resources/shared.js.map +1 -0
- package/vendor/sdk/resources/shared.mjs +3 -0
- package/vendor/sdk/resources/shared.mjs.map +1 -0
- package/vendor/sdk/resources/top-level.d.ts +2 -0
- package/vendor/sdk/resources/top-level.d.ts.map +1 -0
- package/vendor/sdk/resources/top-level.js +4 -0
- package/vendor/sdk/resources/top-level.js.map +1 -0
- package/vendor/sdk/resources/top-level.mjs +3 -0
- package/vendor/sdk/resources/top-level.mjs.map +1 -0
- package/vendor/sdk/shims/node.d.ts +30 -0
- package/vendor/sdk/shims/node.d.ts.map +1 -0
- package/vendor/sdk/shims/node.js +31 -0
- package/vendor/sdk/shims/node.js.map +1 -0
- package/vendor/sdk/shims/node.mjs +5 -0
- package/vendor/sdk/shims/node.mjs.map +1 -0
- package/vendor/sdk/shims/web.d.ts +26 -0
- package/vendor/sdk/shims/web.d.ts.map +1 -0
- package/vendor/sdk/shims/web.js +31 -0
- package/vendor/sdk/shims/web.js.map +1 -0
- package/vendor/sdk/shims/web.mjs +5 -0
- package/vendor/sdk/shims/web.mjs.map +1 -0
- package/vendor/sdk/src/_shims/MultipartBody.ts +9 -0
- package/vendor/sdk/src/_shims/README.md +46 -0
- package/vendor/sdk/src/_shims/auto/runtime-bun.ts +4 -0
- package/vendor/sdk/src/_shims/auto/runtime-node.ts +4 -0
- package/vendor/sdk/src/_shims/auto/runtime.ts +4 -0
- package/vendor/sdk/src/_shims/auto/types-node.ts +4 -0
- package/vendor/sdk/src/_shims/auto/types.d.ts +101 -0
- package/vendor/sdk/src/_shims/auto/types.js +3 -0
- package/vendor/sdk/src/_shims/auto/types.mjs +3 -0
- package/vendor/sdk/src/_shims/bun-runtime.ts +14 -0
- package/vendor/sdk/src/_shims/index.d.ts +81 -0
- package/vendor/sdk/src/_shims/index.js +13 -0
- package/vendor/sdk/src/_shims/index.mjs +7 -0
- package/vendor/sdk/src/_shims/manual-types.d.ts +12 -0
- package/vendor/sdk/src/_shims/manual-types.js +3 -0
- package/vendor/sdk/src/_shims/manual-types.mjs +3 -0
- package/vendor/sdk/src/_shims/node-runtime.ts +81 -0
- package/vendor/sdk/src/_shims/node-types.d.ts +42 -0
- package/vendor/sdk/src/_shims/node-types.js +3 -0
- package/vendor/sdk/src/_shims/node-types.mjs +3 -0
- package/vendor/sdk/src/_shims/registry.ts +67 -0
- package/vendor/sdk/src/_shims/web-runtime.ts +103 -0
- package/vendor/sdk/src/_shims/web-types.d.ts +83 -0
- package/vendor/sdk/src/_shims/web-types.js +3 -0
- package/vendor/sdk/src/_shims/web-types.mjs +3 -0
- package/vendor/sdk/src/_vendor/partial-json-parser/README.md +3 -0
- package/vendor/sdk/src/_vendor/partial-json-parser/parser.ts +264 -0
- package/vendor/sdk/src/core.ts +1250 -0
- package/vendor/sdk/src/error.ts +133 -0
- package/vendor/sdk/src/index.ts +465 -0
- package/vendor/sdk/src/internal/decoders/jsonl.ts +41 -0
- package/vendor/sdk/src/internal/decoders/line.ts +145 -0
- package/vendor/sdk/src/internal/stream-utils.ts +32 -0
- package/vendor/sdk/src/lib/.keep +4 -0
- package/vendor/sdk/src/lib/BetaMessageStream.ts +661 -0
- package/vendor/sdk/src/lib/MessageStream.ts +662 -0
- package/vendor/sdk/src/pagination.ts +92 -0
- package/vendor/sdk/src/resource.ts +11 -0
- package/vendor/sdk/src/resources/beta/beta.ts +249 -0
- package/vendor/sdk/src/resources/beta/index.ts +83 -0
- package/vendor/sdk/src/resources/beta/messages/batches.ts +486 -0
- package/vendor/sdk/src/resources/beta/messages/index.ts +87 -0
- package/vendor/sdk/src/resources/beta/messages/messages.ts +1444 -0
- package/vendor/sdk/src/resources/beta/models.ts +78 -0
- package/vendor/sdk/src/resources/completions.ts +210 -0
- package/vendor/sdk/src/resources/index.ts +95 -0
- package/vendor/sdk/src/resources/messages/batches.ts +352 -0
- package/vendor/sdk/src/resources/messages/index.ts +85 -0
- package/vendor/sdk/src/resources/messages/messages.ts +1412 -0
- package/vendor/sdk/src/resources/models.ts +75 -0
- package/vendor/sdk/src/resources/shared.ts +72 -0
- package/vendor/sdk/src/resources/top-level.ts +3 -0
- package/vendor/sdk/src/shims/node.ts +50 -0
- package/vendor/sdk/src/shims/web.ts +50 -0
- package/vendor/sdk/src/streaming.ts +372 -0
- package/vendor/sdk/src/tsconfig.json +11 -0
- package/vendor/sdk/src/uploads.ts +255 -0
- package/vendor/sdk/src/version.ts +1 -0
- package/vendor/sdk/streaming.d.ts +36 -0
- package/vendor/sdk/streaming.d.ts.map +1 -0
- package/vendor/sdk/streaming.js +316 -0
- package/vendor/sdk/streaming.js.map +1 -0
- package/vendor/sdk/streaming.mjs +310 -0
- package/vendor/sdk/streaming.mjs.map +1 -0
- package/vendor/sdk/uploads.d.ts +75 -0
- package/vendor/sdk/uploads.d.ts.map +1 -0
- package/vendor/sdk/uploads.js +171 -0
- package/vendor/sdk/uploads.js.map +1 -0
- package/vendor/sdk/uploads.mjs +158 -0
- package/vendor/sdk/uploads.mjs.map +1 -0
- package/vendor/sdk/version.d.ts +2 -0
- package/vendor/sdk/version.d.ts.map +1 -0
- package/vendor/sdk/version.js +5 -0
- package/vendor/sdk/version.js.map +1 -0
- package/vendor/sdk/version.mjs +2 -0
- package/vendor/sdk/version.mjs.map +1 -0
- package/yoga.wasm +0 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { type Agent } from "./_shims/index.js";
|
|
2
|
+
import * as Core from "./core.js";
|
|
3
|
+
import * as Errors from "./error.js";
|
|
4
|
+
import * as Pagination from "./pagination.js";
|
|
5
|
+
import { type PageParams, PageResponse } from "./pagination.js";
|
|
6
|
+
import * as Uploads from "./uploads.js";
|
|
7
|
+
import * as API from "./resources/index.js";
|
|
8
|
+
import { Completion, CompletionCreateParams, CompletionCreateParamsNonStreaming, CompletionCreateParamsStreaming, Completions } from "./resources/completions.js";
|
|
9
|
+
import { ModelInfo, ModelInfosPage, ModelListParams, Models } from "./resources/models.js";
|
|
10
|
+
import { AnthropicBeta, Beta, BetaAPIError, BetaAuthenticationError, BetaBillingError, BetaError, BetaErrorResponse, BetaGatewayTimeoutError, BetaInvalidRequestError, BetaNotFoundError, BetaOverloadedError, BetaPermissionError, BetaRateLimitError } from "./resources/beta/beta.js";
|
|
11
|
+
import { Base64PDFSource, CacheControlEphemeral, CitationCharLocation, CitationCharLocationParam, CitationContentBlockLocation, CitationContentBlockLocationParam, CitationPageLocation, CitationPageLocationParam, CitationsConfigParam, CitationsDelta, ContentBlock, ContentBlockDeltaEvent, ContentBlockParam, ContentBlockSource, ContentBlockSourceContent, ContentBlockStartEvent, ContentBlockStopEvent, DocumentBlockParam, ImageBlockParam, InputJSONDelta, Message, MessageCountTokensParams, MessageCreateParams, MessageCreateParamsNonStreaming, MessageCreateParamsStreaming, MessageDeltaEvent, MessageDeltaUsage, MessageParam, MessageStartEvent, MessageStopEvent, MessageStreamEvent, MessageStreamParams, MessageTokensCount, Messages, Metadata, Model, PlainTextSource, RawContentBlockDeltaEvent, RawContentBlockStartEvent, RawContentBlockStopEvent, RawMessageDeltaEvent, RawMessageStartEvent, RawMessageStopEvent, RawMessageStreamEvent, RedactedThinkingBlock, RedactedThinkingBlockParam, SignatureDelta, TextBlock, TextBlockParam, TextCitation, TextCitationParam, TextDelta, ThinkingBlock, ThinkingBlockParam, ThinkingConfigDisabled, ThinkingConfigEnabled, ThinkingDelta, Tool, ToolChoice, ToolChoiceAny, ToolChoiceAuto, ToolChoiceTool, ToolResultBlockParam, ToolUseBlock, ToolUseBlockParam, Usage } from "./resources/messages/messages.js";
|
|
12
|
+
export interface ClientOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Defaults to process.env['ANTHROPIC_API_KEY'].
|
|
15
|
+
*/
|
|
16
|
+
apiKey?: string | null | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Defaults to process.env['ANTHROPIC_AUTH_TOKEN'].
|
|
19
|
+
*/
|
|
20
|
+
authToken?: string | null | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
23
|
+
*
|
|
24
|
+
* Defaults to process.env['ANTHROPIC_BASE_URL'].
|
|
25
|
+
*/
|
|
26
|
+
baseURL?: string | null | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
29
|
+
* from the server before timing out a single request.
|
|
30
|
+
*
|
|
31
|
+
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
32
|
+
* much longer than this timeout before the promise succeeds or fails.
|
|
33
|
+
*/
|
|
34
|
+
timeout?: number | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* An HTTP agent used to manage HTTP(S) connections.
|
|
37
|
+
*
|
|
38
|
+
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
39
|
+
* otherwise no agent is used.
|
|
40
|
+
*/
|
|
41
|
+
httpAgent?: Agent | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Specify a custom `fetch` function implementation.
|
|
44
|
+
*
|
|
45
|
+
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
46
|
+
* defined globally.
|
|
47
|
+
*/
|
|
48
|
+
fetch?: Core.Fetch | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* The maximum number of times that the client will retry a request in case of a
|
|
51
|
+
* temporary failure, like a network error or a 5XX error from the server.
|
|
52
|
+
*
|
|
53
|
+
* @default 2
|
|
54
|
+
*/
|
|
55
|
+
maxRetries?: number | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Default headers to include with every request to the API.
|
|
58
|
+
*
|
|
59
|
+
* These can be removed in individual requests by explicitly setting the
|
|
60
|
+
* header to `undefined` or `null` in request options.
|
|
61
|
+
*/
|
|
62
|
+
defaultHeaders?: Core.Headers | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Default query parameters to include with every request to the API.
|
|
65
|
+
*
|
|
66
|
+
* These can be removed in individual requests by explicitly setting the
|
|
67
|
+
* param to `undefined` in request options.
|
|
68
|
+
*/
|
|
69
|
+
defaultQuery?: Core.DefaultQuery | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
|
|
72
|
+
* Only set this option to `true` if you understand the risks and have appropriate mitigations in place.
|
|
73
|
+
*/
|
|
74
|
+
dangerouslyAllowBrowser?: boolean | undefined;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* API Client for interfacing with the Anthropic API.
|
|
78
|
+
*/
|
|
79
|
+
export declare class Anthropic extends Core.APIClient {
|
|
80
|
+
apiKey: string | null;
|
|
81
|
+
authToken: string | null;
|
|
82
|
+
private _options;
|
|
83
|
+
/**
|
|
84
|
+
* API Client for interfacing with the Anthropic API.
|
|
85
|
+
*
|
|
86
|
+
* @param {string | null | undefined} [opts.apiKey=process.env['ANTHROPIC_API_KEY'] ?? null]
|
|
87
|
+
* @param {string | null | undefined} [opts.authToken=process.env['ANTHROPIC_AUTH_TOKEN'] ?? null]
|
|
88
|
+
* @param {string} [opts.baseURL=process.env['ANTHROPIC_BASE_URL'] ?? https://api.anthropic.com] - Override the default base URL for the API.
|
|
89
|
+
* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
90
|
+
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
91
|
+
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
92
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
93
|
+
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
94
|
+
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
95
|
+
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
|
|
96
|
+
*/
|
|
97
|
+
constructor({ baseURL, apiKey, authToken, ...opts }?: ClientOptions);
|
|
98
|
+
completions: API.Completions;
|
|
99
|
+
messages: API.Messages;
|
|
100
|
+
models: API.Models;
|
|
101
|
+
beta: API.Beta;
|
|
102
|
+
protected defaultQuery(): Core.DefaultQuery | undefined;
|
|
103
|
+
protected defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers;
|
|
104
|
+
protected validateHeaders(headers: Core.Headers, customHeaders: Core.Headers): void;
|
|
105
|
+
protected authHeaders(opts: Core.FinalRequestOptions): Core.Headers;
|
|
106
|
+
protected apiKeyAuth(opts: Core.FinalRequestOptions): Core.Headers;
|
|
107
|
+
protected bearerAuth(opts: Core.FinalRequestOptions): Core.Headers;
|
|
108
|
+
static Anthropic: typeof Anthropic;
|
|
109
|
+
static HUMAN_PROMPT: string;
|
|
110
|
+
static AI_PROMPT: string;
|
|
111
|
+
static DEFAULT_TIMEOUT: number;
|
|
112
|
+
static AnthropicError: typeof Errors.AnthropicError;
|
|
113
|
+
static APIError: typeof Errors.APIError;
|
|
114
|
+
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
115
|
+
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
116
|
+
static APIUserAbortError: typeof Errors.APIUserAbortError;
|
|
117
|
+
static NotFoundError: typeof Errors.NotFoundError;
|
|
118
|
+
static ConflictError: typeof Errors.ConflictError;
|
|
119
|
+
static RateLimitError: typeof Errors.RateLimitError;
|
|
120
|
+
static BadRequestError: typeof Errors.BadRequestError;
|
|
121
|
+
static AuthenticationError: typeof Errors.AuthenticationError;
|
|
122
|
+
static InternalServerError: typeof Errors.InternalServerError;
|
|
123
|
+
static PermissionDeniedError: typeof Errors.PermissionDeniedError;
|
|
124
|
+
static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
125
|
+
static toFile: typeof Uploads.toFile;
|
|
126
|
+
static fileFromPath: typeof Uploads.fileFromPath;
|
|
127
|
+
}
|
|
128
|
+
export declare namespace Anthropic {
|
|
129
|
+
export type RequestOptions = Core.RequestOptions;
|
|
130
|
+
export import Page = Pagination.Page;
|
|
131
|
+
export { type PageParams as PageParams, type PageResponse as PageResponse };
|
|
132
|
+
export { Completions as Completions, type Completion as Completion, type CompletionCreateParams as CompletionCreateParams, type CompletionCreateParamsNonStreaming as CompletionCreateParamsNonStreaming, type CompletionCreateParamsStreaming as CompletionCreateParamsStreaming, };
|
|
133
|
+
export { Messages as Messages, type Base64PDFSource as Base64PDFSource, type CacheControlEphemeral as CacheControlEphemeral, type CitationCharLocation as CitationCharLocation, type CitationCharLocationParam as CitationCharLocationParam, type CitationContentBlockLocation as CitationContentBlockLocation, type CitationContentBlockLocationParam as CitationContentBlockLocationParam, type CitationPageLocation as CitationPageLocation, type CitationPageLocationParam as CitationPageLocationParam, type CitationsConfigParam as CitationsConfigParam, type CitationsDelta as CitationsDelta, type ContentBlock as ContentBlock, type ContentBlockDeltaEvent as ContentBlockDeltaEvent, type ContentBlockParam as ContentBlockParam, type ContentBlockSource as ContentBlockSource, type ContentBlockSourceContent as ContentBlockSourceContent, type ContentBlockStartEvent as ContentBlockStartEvent, type ContentBlockStopEvent as ContentBlockStopEvent, type DocumentBlockParam as DocumentBlockParam, type ImageBlockParam as ImageBlockParam, type InputJSONDelta as InputJSONDelta, type Message as Message, type MessageDeltaEvent as MessageDeltaEvent, type MessageDeltaUsage as MessageDeltaUsage, type MessageParam as MessageParam, type MessageStartEvent as MessageStartEvent, type MessageStopEvent as MessageStopEvent, type MessageStreamEvent as MessageStreamEvent, type MessageTokensCount as MessageTokensCount, type Metadata as Metadata, type Model as Model, type PlainTextSource as PlainTextSource, type RawContentBlockDeltaEvent as RawContentBlockDeltaEvent, type RawContentBlockStartEvent as RawContentBlockStartEvent, type RawContentBlockStopEvent as RawContentBlockStopEvent, type RawMessageDeltaEvent as RawMessageDeltaEvent, type RawMessageStartEvent as RawMessageStartEvent, type RawMessageStopEvent as RawMessageStopEvent, type RawMessageStreamEvent as RawMessageStreamEvent, type RedactedThinkingBlock as RedactedThinkingBlock, type RedactedThinkingBlockParam as RedactedThinkingBlockParam, type SignatureDelta as SignatureDelta, type TextBlock as TextBlock, type TextBlockParam as TextBlockParam, type TextCitation as TextCitation, type TextCitationParam as TextCitationParam, type TextDelta as TextDelta, type ThinkingBlock as ThinkingBlock, type ThinkingBlockParam as ThinkingBlockParam, type ThinkingConfigDisabled as ThinkingConfigDisabled, type ThinkingConfigEnabled as ThinkingConfigEnabled, type ThinkingDelta as ThinkingDelta, type Tool as Tool, type ToolChoice as ToolChoice, type ToolChoiceAny as ToolChoiceAny, type ToolChoiceAuto as ToolChoiceAuto, type ToolChoiceTool as ToolChoiceTool, type ToolResultBlockParam as ToolResultBlockParam, type ToolUseBlock as ToolUseBlock, type ToolUseBlockParam as ToolUseBlockParam, type Usage as Usage, type MessageCreateParams as MessageCreateParams, type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming, type MessageCreateParamsStreaming as MessageCreateParamsStreaming, type MessageStreamParams as MessageStreamParams, type MessageCountTokensParams as MessageCountTokensParams, };
|
|
134
|
+
export { Models as Models, type ModelInfo as ModelInfo, ModelInfosPage as ModelInfosPage, type ModelListParams as ModelListParams, };
|
|
135
|
+
export { Beta as Beta, type AnthropicBeta as AnthropicBeta, type BetaAPIError as BetaAPIError, type BetaAuthenticationError as BetaAuthenticationError, type BetaBillingError as BetaBillingError, type BetaError as BetaError, type BetaErrorResponse as BetaErrorResponse, type BetaGatewayTimeoutError as BetaGatewayTimeoutError, type BetaInvalidRequestError as BetaInvalidRequestError, type BetaNotFoundError as BetaNotFoundError, type BetaOverloadedError as BetaOverloadedError, type BetaPermissionError as BetaPermissionError, type BetaRateLimitError as BetaRateLimitError, };
|
|
136
|
+
export type APIErrorObject = API.APIErrorObject;
|
|
137
|
+
export type AuthenticationError = API.AuthenticationError;
|
|
138
|
+
export type BillingError = API.BillingError;
|
|
139
|
+
export type ErrorObject = API.ErrorObject;
|
|
140
|
+
export type ErrorResponse = API.ErrorResponse;
|
|
141
|
+
export type GatewayTimeoutError = API.GatewayTimeoutError;
|
|
142
|
+
export type InvalidRequestError = API.InvalidRequestError;
|
|
143
|
+
export type NotFoundError = API.NotFoundError;
|
|
144
|
+
export type OverloadedError = API.OverloadedError;
|
|
145
|
+
export type PermissionError = API.PermissionError;
|
|
146
|
+
export type RateLimitError = API.RateLimitError;
|
|
147
|
+
}
|
|
148
|
+
export declare const HUMAN_PROMPT: string, AI_PROMPT: string;
|
|
149
|
+
export { toFile, fileFromPath } from "./uploads.js";
|
|
150
|
+
export { AnthropicError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./error.js";
|
|
151
|
+
export default Anthropic;
|
|
152
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,SAAS,CAAC;AAClC,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAC;AACzC,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,kCAAkC,EAClC,+BAA+B,EAC/B,WAAW,EACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,EACL,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,uBAAuB,EACvB,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,yB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@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var _a;
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.AnthropicError = exports.fileFromPath = exports.toFile = exports.AI_PROMPT = exports.HUMAN_PROMPT = exports.Anthropic = void 0;
|
|
29
|
+
const Core = __importStar(require("./core.js"));
|
|
30
|
+
const Errors = __importStar(require("./error.js"));
|
|
31
|
+
const Pagination = __importStar(require("./pagination.js"));
|
|
32
|
+
const Uploads = __importStar(require("./uploads.js"));
|
|
33
|
+
const API = __importStar(require("./resources/index.js"));
|
|
34
|
+
const completions_1 = require("./resources/completions.js");
|
|
35
|
+
const models_1 = require("./resources/models.js");
|
|
36
|
+
const beta_1 = require("./resources/beta/beta.js");
|
|
37
|
+
const messages_1 = require("./resources/messages/messages.js");
|
|
38
|
+
/**
|
|
39
|
+
* API Client for interfacing with the Anthropic API.
|
|
40
|
+
*/
|
|
41
|
+
class Anthropic extends Core.APIClient {
|
|
42
|
+
/**
|
|
43
|
+
* API Client for interfacing with the Anthropic API.
|
|
44
|
+
*
|
|
45
|
+
* @param {string | null | undefined} [opts.apiKey=process.env['ANTHROPIC_API_KEY'] ?? null]
|
|
46
|
+
* @param {string | null | undefined} [opts.authToken=process.env['ANTHROPIC_AUTH_TOKEN'] ?? null]
|
|
47
|
+
* @param {string} [opts.baseURL=process.env['ANTHROPIC_BASE_URL'] ?? https://api.anthropic.com] - Override the default base URL for the API.
|
|
48
|
+
* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
49
|
+
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
50
|
+
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
51
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
52
|
+
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
53
|
+
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
54
|
+
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
|
|
55
|
+
*/
|
|
56
|
+
constructor({ baseURL = Core.readEnv('ANTHROPIC_BASE_URL'), apiKey = Core.readEnv('ANTHROPIC_API_KEY') ?? null, authToken = Core.readEnv('ANTHROPIC_AUTH_TOKEN') ?? null, ...opts } = {}) {
|
|
57
|
+
const options = {
|
|
58
|
+
apiKey,
|
|
59
|
+
authToken,
|
|
60
|
+
...opts,
|
|
61
|
+
baseURL: baseURL || `https://api.anthropic.com`,
|
|
62
|
+
};
|
|
63
|
+
if (!options.dangerouslyAllowBrowser && Core.isRunningInBrowser()) {
|
|
64
|
+
throw new Errors.AnthropicError("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew Anthropic({ apiKey, dangerouslyAllowBrowser: true });\n");
|
|
65
|
+
}
|
|
66
|
+
super({
|
|
67
|
+
baseURL: options.baseURL,
|
|
68
|
+
timeout: options.timeout ?? 600000 /* 10 minutes */,
|
|
69
|
+
httpAgent: options.httpAgent,
|
|
70
|
+
maxRetries: options.maxRetries,
|
|
71
|
+
fetch: options.fetch,
|
|
72
|
+
});
|
|
73
|
+
this.completions = new API.Completions(this);
|
|
74
|
+
this.messages = new API.Messages(this);
|
|
75
|
+
this.models = new API.Models(this);
|
|
76
|
+
this.beta = new API.Beta(this);
|
|
77
|
+
this._options = options;
|
|
78
|
+
this.apiKey = apiKey;
|
|
79
|
+
this.authToken = authToken;
|
|
80
|
+
}
|
|
81
|
+
defaultQuery() {
|
|
82
|
+
return this._options.defaultQuery;
|
|
83
|
+
}
|
|
84
|
+
defaultHeaders(opts) {
|
|
85
|
+
return {
|
|
86
|
+
...super.defaultHeaders(opts),
|
|
87
|
+
...(this._options.dangerouslyAllowBrowser ?
|
|
88
|
+
{ 'anthropic-dangerous-direct-browser-access': 'true' }
|
|
89
|
+
: undefined),
|
|
90
|
+
'anthropic-version': '2023-06-01',
|
|
91
|
+
...this._options.defaultHeaders,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
validateHeaders(headers, customHeaders) {
|
|
95
|
+
if (this.apiKey && headers['x-api-key']) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (customHeaders['x-api-key'] === null) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (this.authToken && headers['authorization']) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (customHeaders['authorization'] === null) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
throw new Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted');
|
|
108
|
+
}
|
|
109
|
+
authHeaders(opts) {
|
|
110
|
+
const apiKeyAuth = this.apiKeyAuth(opts);
|
|
111
|
+
const bearerAuth = this.bearerAuth(opts);
|
|
112
|
+
if (apiKeyAuth != null && !Core.isEmptyObj(apiKeyAuth)) {
|
|
113
|
+
return apiKeyAuth;
|
|
114
|
+
}
|
|
115
|
+
if (bearerAuth != null && !Core.isEmptyObj(bearerAuth)) {
|
|
116
|
+
return bearerAuth;
|
|
117
|
+
}
|
|
118
|
+
return {};
|
|
119
|
+
}
|
|
120
|
+
apiKeyAuth(opts) {
|
|
121
|
+
if (this.apiKey == null) {
|
|
122
|
+
return {};
|
|
123
|
+
}
|
|
124
|
+
return { 'X-Api-Key': this.apiKey };
|
|
125
|
+
}
|
|
126
|
+
bearerAuth(opts) {
|
|
127
|
+
if (this.authToken == null) {
|
|
128
|
+
return {};
|
|
129
|
+
}
|
|
130
|
+
return { Authorization: `Bearer ${this.authToken}` };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.Anthropic = Anthropic;
|
|
134
|
+
_a = Anthropic;
|
|
135
|
+
Anthropic.Anthropic = _a;
|
|
136
|
+
Anthropic.HUMAN_PROMPT = '\n\nHuman:';
|
|
137
|
+
Anthropic.AI_PROMPT = '\n\nAssistant:';
|
|
138
|
+
Anthropic.DEFAULT_TIMEOUT = 600000; // 10 minutes
|
|
139
|
+
Anthropic.AnthropicError = Errors.AnthropicError;
|
|
140
|
+
Anthropic.APIError = Errors.APIError;
|
|
141
|
+
Anthropic.APIConnectionError = Errors.APIConnectionError;
|
|
142
|
+
Anthropic.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
143
|
+
Anthropic.APIUserAbortError = Errors.APIUserAbortError;
|
|
144
|
+
Anthropic.NotFoundError = Errors.NotFoundError;
|
|
145
|
+
Anthropic.ConflictError = Errors.ConflictError;
|
|
146
|
+
Anthropic.RateLimitError = Errors.RateLimitError;
|
|
147
|
+
Anthropic.BadRequestError = Errors.BadRequestError;
|
|
148
|
+
Anthropic.AuthenticationError = Errors.AuthenticationError;
|
|
149
|
+
Anthropic.InternalServerError = Errors.InternalServerError;
|
|
150
|
+
Anthropic.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
151
|
+
Anthropic.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
152
|
+
Anthropic.toFile = Uploads.toFile;
|
|
153
|
+
Anthropic.fileFromPath = Uploads.fileFromPath;
|
|
154
|
+
Anthropic.Completions = completions_1.Completions;
|
|
155
|
+
Anthropic.Messages = messages_1.Messages;
|
|
156
|
+
Anthropic.Models = models_1.Models;
|
|
157
|
+
Anthropic.ModelInfosPage = models_1.ModelInfosPage;
|
|
158
|
+
Anthropic.Beta = beta_1.Beta;
|
|
159
|
+
exports.HUMAN_PROMPT = Anthropic.HUMAN_PROMPT, exports.AI_PROMPT = Anthropic.AI_PROMPT;
|
|
160
|
+
var uploads_1 = require("./uploads.js");
|
|
161
|
+
Object.defineProperty(exports, "toFile", { enumerable: true, get: function () { return uploads_1.toFile; } });
|
|
162
|
+
Object.defineProperty(exports, "fileFromPath", { enumerable: true, get: function () { return uploads_1.fileFromPath; } });
|
|
163
|
+
var error_1 = require("./error.js");
|
|
164
|
+
Object.defineProperty(exports, "AnthropicError", { enumerable: true, get: function () { return error_1.AnthropicError; } });
|
|
165
|
+
Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return error_1.APIError; } });
|
|
166
|
+
Object.defineProperty(exports, "APIConnectionError", { enumerable: true, get: function () { return error_1.APIConnectionError; } });
|
|
167
|
+
Object.defineProperty(exports, "APIConnectionTimeoutError", { enumerable: true, get: function () { return error_1.APIConnectionTimeoutError; } });
|
|
168
|
+
Object.defineProperty(exports, "APIUserAbortError", { enumerable: true, get: function () { return error_1.APIUserAbortError; } });
|
|
169
|
+
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return error_1.NotFoundError; } });
|
|
170
|
+
Object.defineProperty(exports, "ConflictError", { enumerable: true, get: function () { return error_1.ConflictError; } });
|
|
171
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return error_1.RateLimitError; } });
|
|
172
|
+
Object.defineProperty(exports, "BadRequestError", { enumerable: true, get: function () { return error_1.BadRequestError; } });
|
|
173
|
+
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return error_1.AuthenticationError; } });
|
|
174
|
+
Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return error_1.InternalServerError; } });
|
|
175
|
+
Object.defineProperty(exports, "PermissionDeniedError", { enumerable: true, get: function () { return error_1.PermissionDeniedError; } });
|
|
176
|
+
Object.defineProperty(exports, "UnprocessableEntityError", { enumerable: true, get: function () { return error_1.UnprocessableEntityError; } });
|
|
177
|
+
exports = module.exports = Anthropic;
|
|
178
|
+
exports.default = Anthropic;
|
|
179
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGtF,gDAA+B;AAC/B,mDAAkC;AAClC,4DAA2C;AAE3C,sDAAqC;AACrC,0DAAyC;AACzC,4DAMiC;AACjC,kDAAwF;AACxF,mDAc+B;AAC/B,+DAmEuC;AA4EvC;;GAEG;AACH,MAAa,SAAU,SAAQ,IAAI,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BAAQ,CAAC;AAC9B,SAAS,CAAC,MAAM,GAAG,eAAM,CAAC;AAC1B,SAAS,CAAC,cAAc,GAAG,uBAAc,CAAC;AAC1C,SAAS,CAAC,IAAI,GAAG,WAAI,CAAC;AAuHP,oBAAY,GAAgB,SAAS,eAAvB,iBAAS,GAAK,SAAS,WAAC;AAErD,wCAAiD;AAAxC,iGAAA,MAAM,OAAA;AAAE,uGAAA,YAAY,OAAA;AAC7B,oCAciB;AAbf,uGAAA,cAAc,OAAA;AACd,iGAAA,QAAQ,OAAA;AACR,2GAAA,kBAAkB,OAAA;AAClB,kHAAA,yBAAyB,OAAA;AACzB,0GAAA,iBAAiB,OAAA;AACjB,sGAAA,aAAa,OAAA;AACb,sGAAA,aAAa,OAAA;AACb,uGAAA,cAAc,OAAA;AACd,wGAAA,eAAe,OAAA;AACf,4GAAA,mBAAmB,OAAA;AACnB,4GAAA,mBAAmB,OAAA;AACnB,8GAAA,qBAAqB,OAAA;AACrB,iHAAA,wBAAwB,OAAA;AAG1B,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
var _a;
|
|
3
|
+
import * as Core from "./core.mjs";
|
|
4
|
+
import * as Errors from "./error.mjs";
|
|
5
|
+
import * as Pagination from "./pagination.mjs";
|
|
6
|
+
import * as Uploads from "./uploads.mjs";
|
|
7
|
+
import * as API from "./resources/index.mjs";
|
|
8
|
+
import { Completions, } from "./resources/completions.mjs";
|
|
9
|
+
import { ModelInfosPage, Models } from "./resources/models.mjs";
|
|
10
|
+
import { Beta, } from "./resources/beta/beta.mjs";
|
|
11
|
+
import { Messages, } from "./resources/messages/messages.mjs";
|
|
12
|
+
/**
|
|
13
|
+
* API Client for interfacing with the Anthropic API.
|
|
14
|
+
*/
|
|
15
|
+
export class Anthropic extends Core.APIClient {
|
|
16
|
+
/**
|
|
17
|
+
* API Client for interfacing with the Anthropic API.
|
|
18
|
+
*
|
|
19
|
+
* @param {string | null | undefined} [opts.apiKey=process.env['ANTHROPIC_API_KEY'] ?? null]
|
|
20
|
+
* @param {string | null | undefined} [opts.authToken=process.env['ANTHROPIC_AUTH_TOKEN'] ?? null]
|
|
21
|
+
* @param {string} [opts.baseURL=process.env['ANTHROPIC_BASE_URL'] ?? https://api.anthropic.com] - Override the default base URL for the API.
|
|
22
|
+
* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
23
|
+
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
24
|
+
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
25
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
26
|
+
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
27
|
+
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
28
|
+
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
|
|
29
|
+
*/
|
|
30
|
+
constructor({ baseURL = Core.readEnv('ANTHROPIC_BASE_URL'), apiKey = Core.readEnv('ANTHROPIC_API_KEY') ?? null, authToken = Core.readEnv('ANTHROPIC_AUTH_TOKEN') ?? null, ...opts } = {}) {
|
|
31
|
+
const options = {
|
|
32
|
+
apiKey,
|
|
33
|
+
authToken,
|
|
34
|
+
...opts,
|
|
35
|
+
baseURL: baseURL || `https://api.anthropic.com`,
|
|
36
|
+
};
|
|
37
|
+
if (!options.dangerouslyAllowBrowser && Core.isRunningInBrowser()) {
|
|
38
|
+
throw new Errors.AnthropicError("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew Anthropic({ apiKey, dangerouslyAllowBrowser: true });\n");
|
|
39
|
+
}
|
|
40
|
+
super({
|
|
41
|
+
baseURL: options.baseURL,
|
|
42
|
+
timeout: options.timeout ?? 600000 /* 10 minutes */,
|
|
43
|
+
httpAgent: options.httpAgent,
|
|
44
|
+
maxRetries: options.maxRetries,
|
|
45
|
+
fetch: options.fetch,
|
|
46
|
+
});
|
|
47
|
+
this.completions = new API.Completions(this);
|
|
48
|
+
this.messages = new API.Messages(this);
|
|
49
|
+
this.models = new API.Models(this);
|
|
50
|
+
this.beta = new API.Beta(this);
|
|
51
|
+
this._options = options;
|
|
52
|
+
this.apiKey = apiKey;
|
|
53
|
+
this.authToken = authToken;
|
|
54
|
+
}
|
|
55
|
+
defaultQuery() {
|
|
56
|
+
return this._options.defaultQuery;
|
|
57
|
+
}
|
|
58
|
+
defaultHeaders(opts) {
|
|
59
|
+
return {
|
|
60
|
+
...super.defaultHeaders(opts),
|
|
61
|
+
...(this._options.dangerouslyAllowBrowser ?
|
|
62
|
+
{ 'anthropic-dangerous-direct-browser-access': 'true' }
|
|
63
|
+
: undefined),
|
|
64
|
+
'anthropic-version': '2023-06-01',
|
|
65
|
+
...this._options.defaultHeaders,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
validateHeaders(headers, customHeaders) {
|
|
69
|
+
if (this.apiKey && headers['x-api-key']) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (customHeaders['x-api-key'] === null) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (this.authToken && headers['authorization']) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (customHeaders['authorization'] === null) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
throw new Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted');
|
|
82
|
+
}
|
|
83
|
+
authHeaders(opts) {
|
|
84
|
+
const apiKeyAuth = this.apiKeyAuth(opts);
|
|
85
|
+
const bearerAuth = this.bearerAuth(opts);
|
|
86
|
+
if (apiKeyAuth != null && !Core.isEmptyObj(apiKeyAuth)) {
|
|
87
|
+
return apiKeyAuth;
|
|
88
|
+
}
|
|
89
|
+
if (bearerAuth != null && !Core.isEmptyObj(bearerAuth)) {
|
|
90
|
+
return bearerAuth;
|
|
91
|
+
}
|
|
92
|
+
return {};
|
|
93
|
+
}
|
|
94
|
+
apiKeyAuth(opts) {
|
|
95
|
+
if (this.apiKey == null) {
|
|
96
|
+
return {};
|
|
97
|
+
}
|
|
98
|
+
return { 'X-Api-Key': this.apiKey };
|
|
99
|
+
}
|
|
100
|
+
bearerAuth(opts) {
|
|
101
|
+
if (this.authToken == null) {
|
|
102
|
+
return {};
|
|
103
|
+
}
|
|
104
|
+
return { Authorization: `Bearer ${this.authToken}` };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
_a = Anthropic;
|
|
108
|
+
Anthropic.Anthropic = _a;
|
|
109
|
+
Anthropic.HUMAN_PROMPT = '\n\nHuman:';
|
|
110
|
+
Anthropic.AI_PROMPT = '\n\nAssistant:';
|
|
111
|
+
Anthropic.DEFAULT_TIMEOUT = 600000; // 10 minutes
|
|
112
|
+
Anthropic.AnthropicError = Errors.AnthropicError;
|
|
113
|
+
Anthropic.APIError = Errors.APIError;
|
|
114
|
+
Anthropic.APIConnectionError = Errors.APIConnectionError;
|
|
115
|
+
Anthropic.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
116
|
+
Anthropic.APIUserAbortError = Errors.APIUserAbortError;
|
|
117
|
+
Anthropic.NotFoundError = Errors.NotFoundError;
|
|
118
|
+
Anthropic.ConflictError = Errors.ConflictError;
|
|
119
|
+
Anthropic.RateLimitError = Errors.RateLimitError;
|
|
120
|
+
Anthropic.BadRequestError = Errors.BadRequestError;
|
|
121
|
+
Anthropic.AuthenticationError = Errors.AuthenticationError;
|
|
122
|
+
Anthropic.InternalServerError = Errors.InternalServerError;
|
|
123
|
+
Anthropic.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
124
|
+
Anthropic.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
125
|
+
Anthropic.toFile = Uploads.toFile;
|
|
126
|
+
Anthropic.fileFromPath = Uploads.fileFromPath;
|
|
127
|
+
Anthropic.Completions = Completions;
|
|
128
|
+
Anthropic.Messages = Messages;
|
|
129
|
+
Anthropic.Models = Models;
|
|
130
|
+
Anthropic.ModelInfosPage = ModelInfosPage;
|
|
131
|
+
Anthropic.Beta = Beta;
|
|
132
|
+
export const { HUMAN_PROMPT, AI_PROMPT } = Anthropic;
|
|
133
|
+
export { toFile, fileFromPath } from "./uploads.mjs";
|
|
134
|
+
export { AnthropicError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./error.mjs";
|
|
135
|
+
export default Anthropic;
|
|
136
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;;OAG/E,KAAK,IAAI;OACT,KAAK,MAAM;OACX,KAAK,UAAU;OAEf,KAAK,OAAO;OACZ,KAAK,GAAG;OACR,EAKL,WAAW,GACZ;OACM,EAAa,cAAc,EAAmB,MAAM,EAAE;OACtD,EAEL,IAAI,GAYL;OACM,EAkCL,QAAQ,GAiCT;AA4ED;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,IAAI,CAAC,SAAS;IAM3C;;;;;;;;;;;;;OAaG;IACH,YAAY,EACV,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAC5C,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,IAAI,EAClD,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,IAAI,IAAI,EACxD,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c,EACd,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
import { type Response } from "../../_shims/index.js";
|
|
3
|
+
import { type Bytes } from "./line.js";
|
|
4
|
+
export declare class JSONLDecoder<T> {
|
|
5
|
+
private iterator;
|
|
6
|
+
controller: AbortController;
|
|
7
|
+
constructor(iterator: AsyncIterableIterator<Bytes>, controller: AbortController);
|
|
8
|
+
private decoder;
|
|
9
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
10
|
+
static fromResponse<T>(response: Response, controller: AbortController): JSONLDecoder<T>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=jsonl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../src/internal/decoders/jsonl.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEjD,qBAAa,YAAY,CAAC,CAAC;IAIvB,OAAO,CAAC,QAAQ;IAHlB,UAAU,EAAE,eAAe,CAAC;gBAGlB,QAAQ,EAAE,qBAAqB,CAAC,KAAK,CAAC,EAC9C,UAAU,EAAE,eAAe;YAKd,OAAO;IAatB,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;IAI1C,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,GAAG,YAAY,CAAC,CAAC,CAAC;CAQzF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JSONLDecoder = void 0;
|
|
4
|
+
const error_1 = require("../../error.js");
|
|
5
|
+
const stream_utils_1 = require("../stream-utils.js");
|
|
6
|
+
const line_1 = require("./line.js");
|
|
7
|
+
class JSONLDecoder {
|
|
8
|
+
constructor(iterator, controller) {
|
|
9
|
+
this.iterator = iterator;
|
|
10
|
+
this.controller = controller;
|
|
11
|
+
}
|
|
12
|
+
async *decoder() {
|
|
13
|
+
const lineDecoder = new line_1.LineDecoder();
|
|
14
|
+
for await (const chunk of this.iterator) {
|
|
15
|
+
for (const line of lineDecoder.decode(chunk)) {
|
|
16
|
+
yield JSON.parse(line);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
for (const line of lineDecoder.flush()) {
|
|
20
|
+
yield JSON.parse(line);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
[Symbol.asyncIterator]() {
|
|
24
|
+
return this.decoder();
|
|
25
|
+
}
|
|
26
|
+
static fromResponse(response, controller) {
|
|
27
|
+
if (!response.body) {
|
|
28
|
+
controller.abort();
|
|
29
|
+
throw new error_1.AnthropicError(`Attempted to iterate over a response with no body`);
|
|
30
|
+
}
|
|
31
|
+
return new JSONLDecoder((0, stream_utils_1.ReadableStreamToAsyncIterable)(response.body), controller);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.JSONLDecoder = JSONLDecoder;
|
|
35
|
+
//# sourceMappingURL=jsonl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonl.js","sourceRoot":"","sources":["../../src/internal/decoders/jsonl.ts"],"names":[],"mappings":";;;AAAA,0CAA6C;AAC7C,qDAAgE;AAEhE,oCAAiD;AAEjD,MAAa,YAAY;IAGvB,YACU,QAAsC,EAC9C,UAA2B;QADnB,aAAQ,GAAR,QAAQ,CAA8B;QAG9C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEO,KAAK,CAAC,CAAC,OAAO;QACpB,MAAM,WAAW,GAAG,IAAI,kBAAW,EAAE,CAAC;QACtC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE;YACvC,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;gBAC5C,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aACxB;SACF;QAED,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,KAAK,EAAE,EAAE;YACtC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACxB;IACH,CAAC;IAED,CAAC,MAAM,CAAC,aAAa,CAAC;QACpB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,YAAY,CAAI,QAAkB,EAAE,UAA2B;QACpE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;YAClB,UAAU,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,IAAI,sBAAc,CAAC,mDAAmD,CAAC,CAAC;SAC/E;QAED,OAAO,IAAI,YAAY,CAAC,IAAA,4CAA6B,EAAQ,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC;IAC3F,CAAC;CACF;AAnCD,oCAmCC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AnthropicError } from "../../error.mjs";
|
|
2
|
+
import { ReadableStreamToAsyncIterable } from "../stream-utils.mjs";
|
|
3
|
+
import { LineDecoder } from "./line.mjs";
|
|
4
|
+
export class JSONLDecoder {
|
|
5
|
+
constructor(iterator, controller) {
|
|
6
|
+
this.iterator = iterator;
|
|
7
|
+
this.controller = controller;
|
|
8
|
+
}
|
|
9
|
+
async *decoder() {
|
|
10
|
+
const lineDecoder = new LineDecoder();
|
|
11
|
+
for await (const chunk of this.iterator) {
|
|
12
|
+
for (const line of lineDecoder.decode(chunk)) {
|
|
13
|
+
yield JSON.parse(line);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
for (const line of lineDecoder.flush()) {
|
|
17
|
+
yield JSON.parse(line);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
[Symbol.asyncIterator]() {
|
|
21
|
+
return this.decoder();
|
|
22
|
+
}
|
|
23
|
+
static fromResponse(response, controller) {
|
|
24
|
+
if (!response.body) {
|
|
25
|
+
controller.abort();
|
|
26
|
+
throw new AnthropicError(`Attempted to iterate over a response with no body`);
|
|
27
|
+
}
|
|
28
|
+
return new JSONLDecoder(ReadableStreamToAsyncIterable(response.body), controller);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=jsonl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonl.mjs","sourceRoot":"","sources":["../../src/internal/decoders/jsonl.ts"],"names":[],"mappings":"OAAO,EAAE,cAAc,EAAE;OAClB,EAAE,6BAA6B,EAAE;OAEjC,EAAE,WAAW,EAAc;AAElC,MAAM,OAAO,YAAY;IAGvB,YACU,QAAsC,EAC9C,UAA2B;QADnB,aAAQ,GAAR,QAAQ,CAA8B;QAG9C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEO,KAAK,CAAC,CAAC,OAAO;QACpB,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;QACtC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE;YACvC,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;gBAC5C,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aACxB;SACF;QAED,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,KAAK,EAAE,EAAE;YACtC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACxB;IACH,CAAC;IAED,CAAC,MAAM,CAAC,aAAa,CAAC;QACpB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,YAAY,CAAI,QAAkB,EAAE,UAA2B;QACpE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;YAClB,UAAU,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,IAAI,cAAc,CAAC,mDAAmD,CAAC,CAAC;SAC/E;QAED,OAAO,IAAI,YAAY,CAAC,6BAA6B,CAAQ,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC;IAC3F,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
export type Bytes = string | ArrayBuffer | Uint8Array | Buffer | null | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
|
|
5
|
+
* reading lines from text.
|
|
6
|
+
*
|
|
7
|
+
* https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
|
|
8
|
+
*/
|
|
9
|
+
export declare class LineDecoder {
|
|
10
|
+
#private;
|
|
11
|
+
static NEWLINE_CHARS: Set<string>;
|
|
12
|
+
static NEWLINE_REGEXP: RegExp;
|
|
13
|
+
buffer: Uint8Array;
|
|
14
|
+
textDecoder: any;
|
|
15
|
+
constructor();
|
|
16
|
+
decode(chunk: Bytes): string[];
|
|
17
|
+
decodeText(bytes: Bytes): string;
|
|
18
|
+
flush(): string[];
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=line.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../src/internal/decoders/line.ts"],"names":[],"mappings":";AAEA,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAElF;;;;;GAKG;AACH,qBAAa,WAAW;;IAEtB,MAAM,CAAC,aAAa,cAAyB;IAC7C,MAAM,CAAC,cAAc,SAAkB;IAEvC,MAAM,EAAE,UAAU,CAAC;IAEnB,WAAW,EAAE,GAAG,CAAC;;IAOjB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE;IAgD9B,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM;IAqChC,KAAK,IAAI,MAAM,EAAE;CAMlB"}
|