@anthropic-ai/sdk 0.21.0 → 0.21.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.21.1 (2024-05-21)
4
+
5
+ Full Changelog: [sdk-v0.21.0...sdk-v0.21.1](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.21.0...sdk-v0.21.1)
6
+
7
+ ### Chores
8
+
9
+ * **docs:** fix typo ([#423](https://github.com/anthropics/anthropic-sdk-typescript/issues/423)) ([d42f458](https://github.com/anthropics/anthropic-sdk-typescript/commit/d42f45820347171bd456b0038406a53b098a4fa2))
10
+ * **internal:** run build script over sub-packages ([6f04f66](https://github.com/anthropics/anthropic-sdk-typescript/commit/6f04f6689603ef5a59ce15f490d74392241694c3))
11
+
3
12
  ## 0.21.0 (2024-05-16)
4
13
 
5
14
  Full Changelog: [sdk-v0.20.9...sdk-v0.21.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.20.9...sdk-v0.21.0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anthropic-ai/sdk",
3
- "version": "0.21.0",
3
+ "version": "0.21.1",
4
4
  "description": "The official TypeScript library for the Anthropic API",
5
5
  "author": "Anthropic <support@anthropic.com>",
6
6
  "types": "./index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "private": false,
16
16
  "scripts": {
17
17
  "test": "./scripts/test",
18
- "build": "./scripts/build",
18
+ "build": "./scripts/build-all",
19
19
  "format": "prettier --write --cache --cache-strategy metadata . !dist",
20
20
  "tsn": "ts-node -r tsconfig-paths/register",
21
21
  "lint": "./scripts/lint",
@@ -13,8 +13,8 @@ export declare class Messages extends APIResource {
13
13
  * Send a structured list of input messages with text and/or image content, and the
14
14
  * model will generate the next message in the conversation.
15
15
  *
16
- * The Messages API can be used for for either single queries or stateless
17
- * multi-turn conversations.
16
+ * The Messages API can be used for either single queries or stateless multi-turn
17
+ * conversations.
18
18
  */
19
19
  create(body: MessageCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<ToolsBetaMessage>;
20
20
  create(body: MessageCreateParamsStreaming, options?: Core.RequestOptions): APIPromise<Stream<ToolsBetaMessageStreamEvent>>;
@@ -12,8 +12,8 @@ export declare class Messages extends APIResource {
12
12
  * Send a structured list of input messages with text and/or image content, and the
13
13
  * model will generate the next message in the conversation.
14
14
  *
15
- * The Messages API can be used for for either single queries or stateless
16
- * multi-turn conversations.
15
+ * The Messages API can be used for either single queries or stateless multi-turn
16
+ * conversations.
17
17
  */
18
18
  create(body: MessageCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<Message>;
19
19
  create(body: MessageCreateParamsStreaming, options?: Core.RequestOptions): APIPromise<Stream<MessageStreamEvent>>;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
3
  */
4
- export * from '../bun-runtime';
4
+ export * from "../bun-runtime.js";
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
3
  */
4
- export * from '../node-runtime';
4
+ export * from "../node-runtime.js";
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
3
  */
4
- export * from '../web-runtime';
4
+ export * from "../web-runtime.js";
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
3
  */
4
- export * from '../node-types';
4
+ export * from "../node-types.js";
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
3
  */
4
- import { type Shims } from './registry';
5
- import { getRuntime as getWebRuntime } from './web-runtime';
4
+ import { type Shims } from "./registry.js";
5
+ import { getRuntime as getWebRuntime } from "./web-runtime.js";
6
6
  import { ReadStream as FsReadStream } from 'node:fs';
7
7
 
8
8
  export function getRuntime(): Shims {
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
3
  */
4
- import { manual } from './manual-types';
5
- import * as auto from "./auto/types";
6
- import { type RequestOptions } from '../core';
4
+ import { manual } from "./manual-types.js";
5
+ import * as auto from "./auto/types.js";
6
+ import { type RequestOptions } from "../core.js";
7
7
 
8
8
  type SelectType<Manual, Auto> = unknown extends Manual ? Auto : Manual;
9
9
 
@@ -2,6 +2,6 @@
2
2
  * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
3
  */
4
4
  import * as shims from './registry.mjs';
5
- import * as auto from "./auto/runtime";
5
+ import * as auto from "./auto/runtime.mjs";
6
6
  if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
7
7
  export * from './registry.mjs';
@@ -10,9 +10,9 @@ import { ReadStream as FsReadStream } from 'node:fs';
10
10
  import { type Agent } from 'node:http';
11
11
  import { FormDataEncoder } from 'form-data-encoder';
12
12
  import { Readable } from 'node:stream';
13
- import { type RequestOptions } from '../core';
14
- import { MultipartBody } from './MultipartBody';
15
- import { type Shims } from './registry';
13
+ import { type RequestOptions } from "../core.js";
14
+ import { MultipartBody } from "./MultipartBody.js";
15
+ import { type Shims } from "./registry.js";
16
16
 
17
17
  // @ts-ignore (this package does not have proper export maps for this export)
18
18
  import { ReadableStream } from 'web-streams-polyfill/dist/ponyfill.es2018.js';
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
3
  */
4
- import { type RequestOptions } from '../core';
4
+ import { type RequestOptions } from "../core.js";
5
5
 
6
6
  export interface Shims {
7
7
  kind: string;
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
3
  */
4
- import { MultipartBody } from './MultipartBody';
5
- import { type RequestOptions } from '../core';
6
- import { type Shims } from './registry';
4
+ import { MultipartBody } from "./MultipartBody.js";
5
+ import { type RequestOptions } from "../core.js";
6
+ import { type Shims } from "./registry.js";
7
7
 
8
8
  export function getRuntime({ manuallyImported }: { manuallyImported?: boolean } = {}): Shims {
9
9
  const recommendation =
package/src/core.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { VERSION } from './version';
2
- import { Stream } from './streaming';
1
+ import { VERSION } from "./version.js";
2
+ import { Stream } from "./streaming.js";
3
3
  import {
4
4
  AnthropicError,
5
5
  APIError,
6
6
  APIConnectionError,
7
7
  APIConnectionTimeoutError,
8
8
  APIUserAbortError,
9
- } from './error';
9
+ } from "./error.js";
10
10
  import {
11
11
  kind as shimsKind,
12
12
  type Readable,
@@ -17,15 +17,15 @@ import {
17
17
  type RequestInit,
18
18
  type Response,
19
19
  type HeadersInit,
20
- } from './_shims/index';
20
+ } from "./_shims/index.js";
21
21
  export { type Response };
22
- import { isMultipartBody } from './uploads';
22
+ import { isMultipartBody } from "./uploads.js";
23
23
  export {
24
24
  maybeMultipartFormRequestOptions,
25
25
  multipartFormRequestOptions,
26
26
  createForm,
27
27
  type Uploadable,
28
- } from './uploads';
28
+ } from "./uploads.js";
29
29
 
30
30
  export type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;
31
31
 
package/src/error.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { castToError, Headers } from './core';
3
+ import { castToError, Headers } from "./core.js";
4
4
 
5
5
  export class AnthropicError extends Error {}
6
6
 
package/src/index.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import * as Core from './core';
4
- import * as Errors from './error';
5
- import { type Agent } from './_shims/index';
6
- import * as Uploads from './uploads';
7
- import * as API from "./resources/index";
3
+ import * as Core from "./core.js";
4
+ import * as Errors from "./error.js";
5
+ import { type Agent } from "./_shims/index.js";
6
+ import * as Uploads from "./uploads.js";
7
+ import * as API from "./resources/index.js";
8
8
 
9
9
  export interface ClientOptions {
10
10
  /**
@@ -1,5 +1,5 @@
1
- import * as Core from "../core";
2
- import { AnthropicError, APIUserAbortError } from "../error";
1
+ import * as Core from "../core.js";
2
+ import { AnthropicError, APIUserAbortError } from "../error.js";
3
3
  import {
4
4
  ContentBlock,
5
5
  Messages,
@@ -8,9 +8,9 @@ import {
8
8
  MessageParam,
9
9
  MessageCreateParams,
10
10
  MessageStreamParams,
11
- } from "../resources/messages";
12
- import { type ReadableStream } from "../_shims/index";
13
- import { Stream } from "../streaming";
11
+ } from "../resources/messages.js";
12
+ import { type ReadableStream } from "../_shims/index.js";
13
+ import { Stream } from "../streaming.js";
14
14
 
15
15
  export interface MessageStreamEvents {
16
16
  connect: () => void;
@@ -1,5 +1,5 @@
1
- import * as Core from "../core";
2
- import { AnthropicError, APIUserAbortError } from "../error";
1
+ import * as Core from "../core.js";
2
+ import { AnthropicError, APIUserAbortError } from "../error.js";
3
3
  import {
4
4
  ToolsBetaContentBlock,
5
5
  Messages,
@@ -8,11 +8,11 @@ import {
8
8
  ToolsBetaMessageParam,
9
9
  MessageCreateParams,
10
10
  MessageCreateParamsBase,
11
- } from "../resources/beta/tools/messages";
12
- import { type ReadableStream } from "../_shims/index";
13
- import { Stream } from "../streaming";
14
- import { TextBlock } from "../resources";
15
- import { partialParse } from '../_vendor/partial-json-parser/parser';
11
+ } from "../resources/beta/tools/messages.js";
12
+ import { type ReadableStream } from "../_shims/index.js";
13
+ import { Stream } from "../streaming.js";
14
+ import { TextBlock } from "../resources.js";
15
+ import { partialParse } from "../_vendor/partial-json-parser/parser.js";
16
16
 
17
17
  export interface MessageStreamEvents {
18
18
  connect: () => void;
package/src/resource.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import * as Core from "./core";
3
+ import * as Core from "./core.js";
4
4
 
5
5
  export class APIResource {
6
6
  protected _client: Core.APIClient;
@@ -1,7 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from "../../resource";
4
- import * as ToolsAPI from "./tools/tools";
3
+ import { APIResource } from "../../resource.js";
4
+ import * as ToolsAPI from "./tools/tools.js";
5
5
 
6
6
  export class Beta extends APIResource {
7
7
  tools: ToolsAPI.Tools = new ToolsAPI.Tools(this._client);
@@ -1,4 +1,4 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- export { Beta } from './beta';
4
- export { Tools } from './tools/index';
3
+ export { Beta } from "./beta.js";
4
+ export { Tools } from "./tools/index.js";
@@ -17,5 +17,5 @@ export {
17
17
  MessageCreateParamsStreaming,
18
18
  MessageStreamParams,
19
19
  Messages,
20
- } from './messages';
21
- export { Tools } from './tools';
20
+ } from "./messages.js";
21
+ export { Tools } from "./tools.js";
@@ -1,13 +1,13 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import * as Core from "../../../core";
4
- import { APIPromise } from "../../../core";
5
- import { APIResource } from "../../../resource";
6
- import { ToolsBetaMessageStream } from "../../../lib/ToolsBetaMessageStream";
7
- export { ToolsBetaMessageStream } from "../../../lib/ToolsBetaMessageStream";
8
- import * as ToolsMessagesAPI from "./messages";
9
- import * as MessagesAPI from "../../messages";
10
- import { Stream } from "../../../streaming";
3
+ import * as Core from "../../../core.js";
4
+ import { APIPromise } from "../../../core.js";
5
+ import { APIResource } from "../../../resource.js";
6
+ import { ToolsBetaMessageStream } from "../../../lib/ToolsBetaMessageStream.js";
7
+ export { ToolsBetaMessageStream } from "../../../lib/ToolsBetaMessageStream.js";
8
+ import * as ToolsMessagesAPI from "./messages.js";
9
+ import * as MessagesAPI from "../../messages.js";
10
+ import { Stream } from "../../../streaming.js";
11
11
 
12
12
  export class Messages extends APIResource {
13
13
  /**
@@ -16,8 +16,8 @@ export class Messages extends APIResource {
16
16
  * Send a structured list of input messages with text and/or image content, and the
17
17
  * model will generate the next message in the conversation.
18
18
  *
19
- * The Messages API can be used for for either single queries or stateless
20
- * multi-turn conversations.
19
+ * The Messages API can be used for either single queries or stateless multi-turn
20
+ * conversations.
21
21
  */
22
22
  create(body: MessageCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<ToolsBetaMessage>;
23
23
  create(
@@ -1,7 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from "../../../resource";
4
- import * as MessagesAPI from "./messages";
3
+ import { APIResource } from "../../../resource.js";
4
+ import * as MessagesAPI from "./messages.js";
5
5
 
6
6
  export class Tools extends APIResource {
7
7
  messages: MessagesAPI.Messages = new MessagesAPI.Messages(this._client);
@@ -1,10 +1,10 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import * as Core from "../core";
4
- import { APIPromise } from "../core";
5
- import { APIResource } from "../resource";
6
- import * as CompletionsAPI from "./completions";
7
- import { Stream } from "../streaming";
3
+ import * as Core from "../core.js";
4
+ import { APIPromise } from "../core.js";
5
+ import { APIResource } from "../resource.js";
6
+ import * as CompletionsAPI from "./completions.js";
7
+ import { Stream } from "../streaming.js";
8
8
 
9
9
  export class Completions extends APIResource {
10
10
  /**
@@ -1,13 +1,13 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- export { Beta } from './beta/beta';
3
+ export { Beta } from "./beta/beta.js";
4
4
  export {
5
5
  Completion,
6
6
  CompletionCreateParams,
7
7
  CompletionCreateParamsNonStreaming,
8
8
  CompletionCreateParamsStreaming,
9
9
  Completions,
10
- } from './completions';
10
+ } from "./completions.js";
11
11
  export {
12
12
  ContentBlock,
13
13
  ContentBlockDeltaEvent,
@@ -30,4 +30,4 @@ export {
30
30
  MessageCreateParamsStreaming,
31
31
  MessageStreamParams,
32
32
  Messages,
33
- } from './messages';
33
+ } from "./messages.js";
@@ -1,12 +1,12 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import * as Core from "../core";
4
- import { APIPromise } from "../core";
5
- import { APIResource } from "../resource";
6
- import { MessageStream } from "../lib/MessageStream";
7
- export { MessageStream } from "../lib/MessageStream";
8
- import * as MessagesAPI from "./messages";
9
- import { Stream } from "../streaming";
3
+ import * as Core from "../core.js";
4
+ import { APIPromise } from "../core.js";
5
+ import { APIResource } from "../resource.js";
6
+ import { MessageStream } from "../lib/MessageStream.js";
7
+ export { MessageStream } from "../lib/MessageStream.js";
8
+ import * as MessagesAPI from "./messages.js";
9
+ import { Stream } from "../streaming.js";
10
10
 
11
11
  export class Messages extends APIResource {
12
12
  /**
@@ -15,8 +15,8 @@ export class Messages extends APIResource {
15
15
  * Send a structured list of input messages with text and/or image content, and the
16
16
  * model will generate the next message in the conversation.
17
17
  *
18
- * The Messages API can be used for for either single queries or stateless
19
- * multi-turn conversations.
18
+ * The Messages API can be used for either single queries or stateless multi-turn
19
+ * conversations.
20
20
  */
21
21
  create(body: MessageCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<Message>;
22
22
  create(
package/src/shims/node.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // @ts-ignore
2
- import * as types from '../_shims/node-types';
3
- import { setShims } from '../_shims/registry';
4
- import { getRuntime } from '../_shims/node-runtime';
2
+ import * as types from "../_shims/node-types.js";
3
+ import { setShims } from "../_shims/registry.js";
4
+ import { getRuntime } from "../_shims/node-runtime.js";
5
5
  setShims(getRuntime());
6
6
 
7
7
  declare module '../_shims/manual-types' {
package/src/shims/web.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // @ts-ignore
2
- import * as types from '../_shims/web-types';
3
- import { setShims } from '../_shims/registry';
4
- import { getRuntime } from '../_shims/web-runtime';
2
+ import * as types from "../_shims/web-types.js";
3
+ import { setShims } from "../_shims/registry.js";
4
+ import { getRuntime } from "../_shims/web-runtime.js";
5
5
  setShims(getRuntime({ manuallyImported: true }));
6
6
 
7
7
  declare module '../_shims/manual-types' {
package/src/streaming.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { ReadableStream, type Response } from './_shims/index';
2
- import { AnthropicError } from './error';
1
+ import { ReadableStream, type Response } from "./_shims/index.js";
2
+ import { AnthropicError } from "./error.js";
3
3
 
4
- import { safeJSON, createResponseHeaders } from "./core";
5
- import { APIError } from "./error";
4
+ import { safeJSON, createResponseHeaders } from "./core.js";
5
+ import { APIError } from "./error.js";
6
6
 
7
7
  type Bytes = string | ArrayBuffer | Uint8Array | Buffer | null | undefined;
8
8
 
package/src/uploads.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type RequestOptions } from './core';
1
+ import { type RequestOptions } from "./core.js";
2
2
  import {
3
3
  FormData,
4
4
  File,
@@ -7,9 +7,9 @@ import {
7
7
  getMultipartRequestOptions,
8
8
  type FsReadStream,
9
9
  isFsReadStream,
10
- } from './_shims/index';
11
- import { MultipartBody } from './_shims/MultipartBody';
12
- export { fileFromPath } from './_shims/index';
10
+ } from "./_shims/index.js";
11
+ import { MultipartBody } from "./_shims/MultipartBody.js";
12
+ export { fileFromPath } from "./_shims/index.js";
13
13
 
14
14
  type BlobLikePart = string | ArrayBuffer | ArrayBufferView | BlobLike | Uint8Array | DataView;
15
15
  export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | Uint8Array | DataView;
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.21.0'; // x-release-please-version
1
+ export const VERSION = '0.21.1'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.21.0";
1
+ export declare const VERSION = "0.21.1";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.21.0'; // x-release-please-version
4
+ exports.VERSION = '0.21.1'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.21.0'; // x-release-please-version
1
+ export const VERSION = '0.21.1'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map