@beeos-ai/bma-sdk 1.0.0 → 2.0.0

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.
Files changed (79) hide show
  1. package/README.md +65 -132
  2. package/dist/beta.d.ts +55 -0
  3. package/dist/beta.js +69 -0
  4. package/dist/beta.js.map +1 -0
  5. package/dist/client.d.ts +32 -0
  6. package/dist/client.js +50 -0
  7. package/dist/client.js.map +1 -0
  8. package/dist/errors.d.ts +6 -75
  9. package/dist/errors.js +11 -105
  10. package/dist/errors.js.map +1 -1
  11. package/dist/extensions.d.ts +80 -0
  12. package/dist/extensions.js +24 -0
  13. package/dist/extensions.js.map +1 -0
  14. package/dist/generated/extensions-resources.d.ts +271 -0
  15. package/dist/generated/extensions-resources.js +255 -0
  16. package/dist/generated/extensions-resources.js.map +1 -0
  17. package/dist/generated/extensions.d.ts +3727 -0
  18. package/dist/generated/{rest.js → extensions.js} +1 -1
  19. package/dist/generated/extensions.js.map +1 -0
  20. package/dist/idempotency.d.ts +4 -0
  21. package/dist/idempotency.js +7 -0
  22. package/dist/idempotency.js.map +1 -0
  23. package/dist/index.d.ts +9 -55
  24. package/dist/index.js +9 -57
  25. package/dist/index.js.map +1 -1
  26. package/dist/internal.d.ts +9 -0
  27. package/dist/internal.js +32 -0
  28. package/dist/internal.js.map +1 -0
  29. package/dist/resume.d.ts +22 -0
  30. package/dist/resume.js +122 -0
  31. package/dist/resume.js.map +1 -0
  32. package/dist/version.d.ts +1 -1
  33. package/dist/version.js +3 -3
  34. package/dist/version.js.map +1 -1
  35. package/package.json +6 -12
  36. package/dist/core.d.ts +0 -105
  37. package/dist/core.js +0 -406
  38. package/dist/core.js.map +0 -1
  39. package/dist/facade-extensions.d.ts +0 -27
  40. package/dist/facade-extensions.js +0 -47
  41. package/dist/facade-extensions.js.map +0 -1
  42. package/dist/generated/facade-extensions-operations.d.ts +0 -133
  43. package/dist/generated/facade-extensions-operations.js +0 -11
  44. package/dist/generated/facade-extensions-operations.js.map +0 -1
  45. package/dist/generated/facade-extensions-resources.d.ts +0 -34
  46. package/dist/generated/facade-extensions-resources.js +0 -47
  47. package/dist/generated/facade-extensions-resources.js.map +0 -1
  48. package/dist/generated/facade-extensions-types.d.ts +0 -14
  49. package/dist/generated/facade-extensions-types.js +0 -2
  50. package/dist/generated/facade-extensions-types.js.map +0 -1
  51. package/dist/generated/facade-extensions.d.ts +0 -507
  52. package/dist/generated/facade-extensions.js +0 -6
  53. package/dist/generated/facade-extensions.js.map +0 -1
  54. package/dist/generated/rest-operations.d.ts +0 -4079
  55. package/dist/generated/rest-operations.js +0 -234
  56. package/dist/generated/rest-operations.js.map +0 -1
  57. package/dist/generated/rest-resources.d.ts +0 -666
  58. package/dist/generated/rest-resources.js +0 -1124
  59. package/dist/generated/rest-resources.js.map +0 -1
  60. package/dist/generated/rest-types.d.ts +0 -572
  61. package/dist/generated/rest-types.js +0 -2
  62. package/dist/generated/rest-types.js.map +0 -1
  63. package/dist/generated/rest.d.ts +0 -18519
  64. package/dist/generated/rest.js.map +0 -1
  65. package/dist/lib/artifacts.d.ts +0 -14
  66. package/dist/lib/artifacts.js +0 -56
  67. package/dist/lib/artifacts.js.map +0 -1
  68. package/dist/lib/tool-runner.d.ts +0 -99
  69. package/dist/lib/tool-runner.js +0 -140
  70. package/dist/lib/tool-runner.js.map +0 -1
  71. package/dist/pagination.d.ts +0 -31
  72. package/dist/pagination.js +0 -66
  73. package/dist/pagination.js.map +0 -1
  74. package/dist/resource.d.ts +0 -8
  75. package/dist/resource.js +0 -9
  76. package/dist/resource.js.map +0 -1
  77. package/dist/streaming.d.ts +0 -27
  78. package/dist/streaming.js +0 -89
  79. package/dist/streaming.js.map +0 -1
@@ -3,4 +3,4 @@
3
3
  * Do not make direct changes to the file.
4
4
  */
5
5
  export {};
6
- //# sourceMappingURL=rest.js.map
6
+ //# sourceMappingURL=extensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensions.js","sourceRoot":"","sources":["../../src/generated/extensions.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,4 @@
1
+ /** A random Idempotency-Key for one extension create. It is computed once per
2
+ * call, so the official client's automatic retries resend the same key and the
3
+ * server replays the first result. */
4
+ export declare function newIdempotencyKey(): string;
@@ -0,0 +1,7 @@
1
+ /** A random Idempotency-Key for one extension create. It is computed once per
2
+ * call, so the official client's automatic retries resend the same key and the
3
+ * server replays the first result. */
4
+ export function newIdempotencyKey() {
5
+ return globalThis.crypto.randomUUID();
6
+ }
7
+ //# sourceMappingURL=idempotency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idempotency.js","sourceRoot":"","sources":["../src/idempotency.ts"],"names":[],"mappings":"AAAA;;sCAEsC;AACtC,MAAM,UAAU,iBAAiB;IAC/B,OAAO,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;AACxC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,55 +1,9 @@
1
- import { type Client } from "openapi-fetch";
2
- import type { components, operations, paths } from "./generated/rest.js";
3
- import { RestClientBase } from "./generated/rest-resources.js";
4
- import { SDK_VERSION } from "./version.js";
5
- export { SDK_VERSION };
6
- export type { components, operations, paths };
7
- export type * from "./generated/rest-types.js";
8
- export type * from "./generated/rest-operations.js";
9
- export * as Resources from "./generated/rest-resources.js";
10
- export { APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, AuthenticationError, BadRequestError, BmaApiError, BmaError, ConflictError, ContentTooLargeError, EventStreamError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, RequestTimeoutError, ServiceUnavailableError, UnprocessableEntityError, type ErrorCode, } from "./errors.js";
11
- export { DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, type RequestOptions, type Uploadable } from "./core.js";
12
- export { PagePromise, type CursorPageBody, type Page, type PageItem } from "./pagination.js";
13
- export { Stream } from "./streaming.js";
14
- export { defineTool, ToolError, type RunnableTool, type ToolOutput, type ToolRunContext, type ToolRunner, type ToolRunnerParams } from "./lib/tool-runner.js";
15
- export type { DownloadArtifactOptions } from "./lib/artifacts.js";
16
- export type { StreamEventsEvent as AgentStreamEvent } from "./generated/rest-operations.js";
17
- /** Hosted BMA origin; the client adds the /api/v1 prefix. */
18
- export declare const DEFAULT_BASE_URL = "https://api.bma.beeos.ai";
19
- export interface BmaClientOptions {
20
- /** BMA personal or organization bearer token; env BMA_TOKEN. */
21
- token?: string;
22
- /**
23
- * Deployment origin, for example https://api.bma.beeos.ai; env BMA_BASE_URL.
24
- * The client adds /api/v1; a value that already ends with /api/v1 is accepted.
25
- */
26
- baseUrl?: string;
27
- /** Default organization (org_...) for org- and project-scoped methods; env BMA_ORG_ID. */
28
- orgId?: string;
29
- /** Default project (prj_...) for project-scoped methods; env BMA_PROJECT_ID. */
30
- projectId?: string;
31
- /**
32
- * Per-attempt timeout in milliseconds until the response headers arrive
33
- * (default 60 000; 0 disables it). Uploads have no default timeout.
34
- */
35
- timeout?: number;
36
- /** Retries after the first attempt (default 2). */
37
- maxRetries?: number;
38
- /** Optional fetch implementation; defaults to globalThis.fetch. */
39
- fetch?: typeof globalThis.fetch;
40
- }
41
- /** Authenticated BMA REST client. */
42
- export declare class BmaClient extends RestClientBase {
43
- /**
44
- * Escape hatch: the openapi-fetch client typed by contract path, for
45
- * operations without a resource method (Machine Daemon). Pair with unwrap().
46
- */
47
- readonly rest: Client<paths>;
48
- constructor(options?: BmaClientOptions);
49
- }
50
- /** Escape hatch companion of `bma.rest`: returns `data` or throws the typed error. */
51
- export declare function unwrap<T>(result: {
52
- data?: T;
53
- error?: unknown;
54
- response: Response;
55
- }): T;
1
+ export { BmaClient, DEFAULT_BASE_URL, type BmaClientOptions } from './client.js';
2
+ export { BmaClient as default } from './client.js';
3
+ export { SDK_VERSION } from './version.js';
4
+ export { errorCode } from './errors.js';
5
+ export { agentExtensions, environmentExtensions, eventExtensions, sessionExtensions, type AgentExt, type AgentExtParams, type AgentModelOverride, type AgentModelOverrideInput, type AgentModelOverridePatch, type EnvironmentDesktop, type EnvironmentExt, type EnvironmentExtParams, type EnvironmentMachine, type EventExt, type Harness, type SessionCreateExt, type SessionExt, type SessionUpdateExt, } from './extensions.js';
6
+ export * from './generated/extensions-resources.js';
7
+ export type { components } from './generated/extensions.js';
8
+ export { BmaBeta, BmaEvents, BmaSessions } from './beta.js';
9
+ export { AnthropicError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, AuthenticationError, BadRequestError, ConflictError, ContentTooLargeError, GatewayTimeoutError, InternalServerError, NotFoundError, OverloadedError, PermissionDeniedError, PreconditionFailedError, RateLimitError, RequestTimeoutError, ServiceUnavailableError, UnprocessableEntityError, } from '@anthropic-ai/sdk';
package/dist/index.js CHANGED
@@ -1,58 +1,10 @@
1
- // TypeScript client for the BMA REST API.
2
- //
3
- // const bma = new BmaClient({ token, baseUrl, orgId, projectId });
4
- // const { session } = await bma.agents.sessions.create(agentId);
5
- //
6
- // Resource classes, request descriptors and params types are generated by
7
- // tools/sdkgen/sdkgen.py from contracts/bma/rest.openapi.yaml and
8
- // contracts/bma/sdk.resources.yaml; schema types by openapi-typescript.
9
- import createClient from "openapi-fetch";
10
- import { BmaApiError, BmaError } from "./errors.js";
11
- import { bmaOrigin } from "./core.js";
12
- import { RestClientBase } from "./generated/rest-resources.js";
13
- import { SDK_VERSION } from "./version.js";
14
- export { SDK_VERSION };
15
- export * as Resources from "./generated/rest-resources.js";
16
- export { APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, AuthenticationError, BadRequestError, BmaApiError, BmaError, ConflictError, ContentTooLargeError, EventStreamError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, RequestTimeoutError, ServiceUnavailableError, UnprocessableEntityError, } from "./errors.js";
17
- export { DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS } from "./core.js";
18
- export { PagePromise } from "./pagination.js";
19
- export { Stream } from "./streaming.js";
20
- export { defineTool, ToolError } from "./lib/tool-runner.js";
21
- /** Hosted BMA origin; the client adds the /api/v1 prefix. */
22
- export const DEFAULT_BASE_URL = "https://api.bma.beeos.ai";
23
- function env(name) {
24
- const value = typeof process === "undefined" ? undefined : process.env?.[name]?.trim();
25
- return value || undefined;
26
- }
27
- /** Authenticated BMA REST client. */
28
- export class BmaClient extends RestClientBase {
29
- /**
30
- * Escape hatch: the openapi-fetch client typed by contract path, for
31
- * operations without a resource method (Machine Daemon). Pair with unwrap().
32
- */
33
- rest;
34
- constructor(options = {}) {
35
- const token = options.token?.trim() || env("BMA_TOKEN");
36
- if (!token)
37
- throw new BmaError("bma: token is required; pass token or set BMA_TOKEN");
38
- const baseUrl = `${bmaOrigin(options.baseUrl?.trim() || env("BMA_BASE_URL") || DEFAULT_BASE_URL)}/api/v1`;
39
- const headers = { Authorization: `Bearer ${token}`, "User-Agent": `bma-sdk-typescript/${SDK_VERSION}` };
40
- super({
41
- baseUrl,
42
- fetch: options.fetch,
43
- timeout: options.timeout,
44
- maxRetries: options.maxRetries,
45
- headers,
46
- scope: { org_id: options.orgId ?? env("BMA_ORG_ID"), project_id: options.projectId ?? env("BMA_PROJECT_ID") },
47
- scopeOption: { org_id: "orgId", project_id: "projectId" },
48
- });
49
- this.rest = createClient({ baseUrl: this.baseUrl, fetch: options.fetch ?? globalThis.fetch, headers });
50
- }
51
- }
52
- /** Escape hatch companion of `bma.rest`: returns `data` or throws the typed error. */
53
- export function unwrap(result) {
54
- if (result.response.ok)
55
- return result.data;
56
- throw BmaApiError.generate(result.response.status, result.error, result.response.headers);
57
- }
1
+ export { BmaClient, DEFAULT_BASE_URL } from './client.js';
2
+ export { BmaClient as default } from './client.js';
3
+ export { SDK_VERSION } from './version.js';
4
+ export { errorCode } from './errors.js';
5
+ export { agentExtensions, environmentExtensions, eventExtensions, sessionExtensions, } from './extensions.js';
6
+ export * from './generated/extensions-resources.js';
7
+ export { BmaBeta, BmaEvents, BmaSessions } from './beta.js';
8
+ // The official error classes, so one import serves error handling.
9
+ export { AnthropicError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, AuthenticationError, BadRequestError, ConflictError, ContentTooLargeError, GatewayTimeoutError, InternalServerError, NotFoundError, OverloadedError, PermissionDeniedError, PreconditionFailedError, RateLimitError, RequestTimeoutError, ServiceUnavailableError, UnprocessableEntityError, } from '@anthropic-ai/sdk';
58
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,qEAAqE;AACrE,mEAAmE;AACnE,EAAE;AACF,0EAA0E;AAC1E,kEAAkE;AAClE,wEAAwE;AACxE,OAAO,YAA6B,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,CAAC;AAKvB,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,QAAQ,EACR,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,GAEzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAwC,MAAM,WAAW,CAAC;AAC1G,OAAO,EAAE,WAAW,EAAiD,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,SAAS,EA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B,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Anthropic } from '@anthropic-ai/sdk';
2
+ /** The per-request options of the official client (its type is not exported). */
3
+ export type RequestOptions = NonNullable<Parameters<Anthropic['beta']['sessions']['events']['stream']>[2]>;
4
+ type HeadersLike = RequestOptions['headers'];
5
+ /** Merges header sets; a later one wins. Explicit nulls (unset a default) are kept. */
6
+ export declare function mergeHeaders(sets: HeadersLike[]): Headers;
7
+ /** Tagged template for a URL path: every interpolated segment is checked and percent-encoded. */
8
+ export declare function path(strings: TemplateStringsArray, ...segments: string[]): string;
9
+ export {};
@@ -0,0 +1,32 @@
1
+ /** Merges header sets; a later one wins. Explicit nulls (unset a default) are kept. */
2
+ export function mergeHeaders(sets) {
3
+ const out = new Headers();
4
+ for (const set of sets) {
5
+ if (!set)
6
+ continue;
7
+ const entries = set instanceof Headers ? set.entries()
8
+ : Array.isArray(set) ? set
9
+ : 'values' in set && set.values instanceof Headers ? set.values.entries()
10
+ : Object.entries(set);
11
+ for (const [name, value] of entries) {
12
+ if (value === undefined || value === null)
13
+ out.delete(name);
14
+ else
15
+ out.set(name, value);
16
+ }
17
+ }
18
+ return out;
19
+ }
20
+ /** Tagged template for a URL path: every interpolated segment is checked and percent-encoded. */
21
+ export function path(strings, ...segments) {
22
+ return strings.reduce((url, text, i) => {
23
+ if (i === 0)
24
+ return text;
25
+ const segment = segments[i - 1];
26
+ if (segment === '' || segment === '.' || segment === '..') {
27
+ throw new TypeError(`Expected a valid path segment but received ${JSON.stringify(segment)}`);
28
+ }
29
+ return url + encodeURIComponent(segment) + text;
30
+ }, '');
31
+ }
32
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAOA,uFAAuF;AACvF,MAAM,UAAU,YAAY,CAAC,IAAmB;IAC9C,MAAM,GAAG,GAAG,IAAI,O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,OAAO,GAAG,GAAG,kBAAkB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IAClD,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { Stream } from '@anthropic-ai/sdk/core/streaming';
2
+ import type { BaseAnthropic } from '@anthropic-ai/sdk/client';
3
+ /** Stream resumption: a dropped stream reconnects with Last-Event-ID, up to
4
+ * `maxReconnects` attempts in a row with exponential backoff from `backoffMs`
5
+ * to `maxBackoffMs`. Exported for the tests; not part of the public API. */
6
+ export declare const streamResume: {
7
+ maxReconnects: number;
8
+ backoffMs: number;
9
+ maxBackoffMs: number;
10
+ };
11
+ /**
12
+ * resumable wraps the official, non-resuming event stream `first`. When the
13
+ * connection drops or the server ends the stream, it calls `connect` with the
14
+ * Last-Event-ID to send and carries on with the new stream, so no event is lost
15
+ * or repeated. One durable BMA event (a `bma_sequence`) projects into several
16
+ * frames that share its sequence and the server resumes after a whole
17
+ * sequence: it resumes after the previous sequence and skips the frames it
18
+ * already returned. It stops when the stream is aborted, after `maxReconnects`
19
+ * failed attempts in a row, or on an API error other than 408, 409, 429 and
20
+ * 5xx (which the official client retries first).
21
+ */
22
+ export declare function resumable<Item extends object>(first: Stream<Item>, connect: (lastEventID: string | undefined) => Promise<Stream<Item>>, client: BaseAnthropic, signal?: AbortSignal | null): Stream<Item>;
package/dist/resume.js ADDED
@@ -0,0 +1,122 @@
1
+ import { APIConnectionError, APIError } from '@anthropic-ai/sdk/core/error';
2
+ import { Stream } from '@anthropic-ai/sdk/core/streaming';
3
+ /** Stream resumption: a dropped stream reconnects with Last-Event-ID, up to
4
+ * `maxReconnects` attempts in a row with exponential backoff from `backoffMs`
5
+ * to `maxBackoffMs`. Exported for the tests; not part of the public API. */
6
+ export const streamResume = { maxReconnects: 5, backoffMs: 500, maxBackoffMs: 8000 };
7
+ function retryableStatus(status) {
8
+ return status === 408 || status === 409 || status === 429 || (status !== undefined && status >= 500);
9
+ }
10
+ function isAbort(error) {
11
+ return error instanceof Error && (error.name === 'AbortError' || error.name === 'APIUserAbortError');
12
+ }
13
+ function sleep(ms, signal) {
14
+ return new Promise((resolve) => {
15
+ const timer = setTimeout(done, ms);
16
+ signal.addEventListener('abort', done, { once: true });
17
+ function done() {
18
+ clearTimeout(timer);
19
+ signal.removeEventListener('abort', done);
20
+ resolve();
21
+ }
22
+ });
23
+ }
24
+ /**
25
+ * resumable wraps the official, non-resuming event stream `first`. When the
26
+ * connection drops or the server ends the stream, it calls `connect` with the
27
+ * Last-Event-ID to send and carries on with the new stream, so no event is lost
28
+ * or repeated. One durable BMA event (a `bma_sequence`) projects into several
29
+ * frames that share its sequence and the server resumes after a whole
30
+ * sequence: it resumes after the previous sequence and skips the frames it
31
+ * already returned. It stops when the stream is aborted, after `maxReconnects`
32
+ * failed attempts in a row, or on an API error other than 408, 409, 429 and
33
+ * 5xx (which the official client retries first).
34
+ */
35
+ export function resumable(first, connect, client, signal) {
36
+ const master = new AbortController();
37
+ let current = first;
38
+ master.signal.addEventListener('abort', () => current?.controller.abort());
39
+ signal?.addEventListener('abort', () => master.abort(), { once: true });
40
+ let consumed = false;
41
+ async function* iterate() {
42
+ if (consumed) {
43
+ throw new Error('Cannot iterate over a consumed stream, use `.tee()` to split the stream.');
44
+ }
45
+ consumed = true;
46
+ let sequence = 0; // bma_sequence of the last durable frame
47
+ const seen = new Set(); // frame ids returned at `sequence`
48
+ let failures = 0;
49
+ try {
50
+ for (;;) {
51
+ let cause = new Error('stream ended');
52
+ try {
53
+ for await (const frame of current) {
54
+ const { id = '', bma_sequence: seq = 0 } = frame;
55
+ if (seq > 0) {
56
+ if (seq < sequence)
57
+ continue; // replayed after a reconnect
58
+ if (seq === sequence) {
59
+ if (seen.has(id))
60
+ continue;
61
+ }
62
+ else {
63
+ sequence = seq;
64
+ seen.clear();
65
+ }
66
+ seen.add(id);
67
+ }
68
+ else if (id !== '') {
69
+ // An announcement ahead of its durable copy (such as the
70
+ // session.status_idle of requires_action): a replay of the
71
+ // current sequence must not return it twice.
72
+ if (seen.has(id))
73
+ continue;
74
+ seen.add(id);
75
+ }
76
+ failures = 0;
77
+ yield frame;
78
+ }
79
+ }
80
+ catch (error) {
81
+ if (master.signal.aborted || isAbort(error))
82
+ return;
83
+ if (error instanceof APIError && !(error instanceof APIConnectionError))
84
+ throw error;
85
+ cause = error;
86
+ }
87
+ current?.controller.abort();
88
+ for (;;) {
89
+ if (master.signal.aborted)
90
+ return;
91
+ if (failures >= streamResume.maxReconnects) {
92
+ throw new Error(`bma-sdk: event stream not resumed after ${failures} attempts`, { cause });
93
+ }
94
+ const delay = Math.min(streamResume.backoffMs * 2 ** failures, streamResume.maxBackoffMs);
95
+ failures++;
96
+ await sleep(delay, master.signal);
97
+ if (master.signal.aborted)
98
+ return;
99
+ try {
100
+ // Resume after the previous sequence; none yet means the server's
101
+ // default position (new events only).
102
+ current = await connect(sequence >= 1 ? String(sequence - 1) : undefined);
103
+ break;
104
+ }
105
+ catch (error) {
106
+ if (master.signal.aborted || isAbort(error))
107
+ return;
108
+ if (error instanceof APIError && !(error instanceof APIConnectionError) && !retryableStatus(error.status)) {
109
+ throw error;
110
+ }
111
+ cause = error;
112
+ }
113
+ }
114
+ }
115
+ }
116
+ finally {
117
+ master.abort();
118
+ }
119
+ }
120
+ return new Stream(iterate, master, client);
121
+ }
122
+ //# sourceMappingURL=resume.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resume.js","sourceRoot":"","sources":["../src/resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAG1D;;4EAE4E;AAC5E,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,aAAa,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AAOrF,SAAS,eAAe,CAAC,MAA0B;IACj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AK,YAAY,QAAQ,IAAI,CAAC,CAAC,KAAK,YAAY,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;4BAC1G,MAAM,KAAK,CAAC;wBACd,CAAC;wBACD,KAAK,GAAG,KAAK,CAAC;oBAChB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC"}
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.0.0";
1
+ export declare const SDK_VERSION = "2.0.0";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
- // The package version, sent in User-Agent. tools/check_versions.sh keeps it
2
- // equal to package.json (CI) and to the release tag (release.yaml).
3
- export const SDK_VERSION = "1.0.0";
1
+ // The version of this package, sent as X-BMA-SDK; tools/check_versions.sh keeps
2
+ // it equal to package.json.
3
+ export const SDK_VERSION = "2.0.0";
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,oEAAoE;AACpE,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,4BAA4B;AAC5B,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@beeos-ai/bma-sdk",
3
- "version": "1.0.0",
4
- "description": "TypeScript client for the BMA REST API and the BMA extensions to the Anthropic Managed Agents API.",
3
+ "version": "2.0.0",
4
+ "description": "TypeScript client for BMA: the official Anthropic SDK with the BMA extensions (machines, machine pools, desktop and terminal sessions) under client.beta.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -13,10 +13,6 @@
13
13
  ".": {
14
14
  "types": "./dist/index.d.ts",
15
15
  "import": "./dist/index.js"
16
- },
17
- "./facade-extensions": {
18
- "types": "./dist/facade-extensions.d.ts",
19
- "import": "./dist/facade-extensions.js"
20
16
  }
21
17
  },
22
18
  "files": [
@@ -27,18 +23,16 @@
27
23
  "node": ">=20"
28
24
  },
29
25
  "scripts": {
30
- "generate": "openapi-typescript ../contracts/bma/rest.openapi.yaml -o src/generated/rest.ts && openapi-typescript ../contracts/bma/facade-extensions.openapi.yaml -o src/generated/facade-extensions.ts",
26
+ "generate": "openapi-typescript ../.build/extensions.openapi.ts.yaml --default-non-nullable=false -o src/generated/extensions.ts",
31
27
  "build": "tsc -p tsconfig.json",
32
28
  "test": "tsc -p tsconfig.test.json && node --test build-test/test/*.test.js"
33
29
  },
34
30
  "dependencies": {
35
- "openapi-fetch": "0.17.0"
31
+ "@anthropic-ai/sdk": "1.6.0"
36
32
  },
37
33
  "devDependencies": {
38
- "@types/node": "^22.0.0",
39
- "expect-type": "1.4.0",
34
+ "@types/node": "^26.6.6",
40
35
  "openapi-typescript": "7.13.0",
41
- "typescript": "5.9.3",
42
- "zod": "4.6.7"
36
+ "typescript": "5.9.3"
43
37
  }
44
38
  }
package/dist/core.d.ts DELETED
@@ -1,105 +0,0 @@
1
- import { PagePromise, type CursorPageBody } from "./pagination.js";
2
- import { Stream } from "./streaming.js";
3
- /**
4
- * Default per-attempt timeout (D3), measured until the response headers
5
- * arrive. Uploads (binary and multipart bodies) have no default timeout;
6
- * event streams and downloads are bounded only until the headers arrive.
7
- */
8
- export declare const DEFAULT_TIMEOUT_MS = 60000;
9
- /** Default retries after the first attempt (D3; @anthropic-ai/sdk uses 2). */
10
- export declare const DEFAULT_MAX_RETRIES = 2;
11
- /** Generated description of one contract operation. */
12
- export interface OperationDescriptor {
13
- readonly id: string;
14
- readonly method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
15
- readonly path: string;
16
- /** Path template name -> params key (scope params) or positional name. */
17
- readonly pathParams?: Readonly<Record<string, string>>;
18
- /** Query name -> serialization style. */
19
- readonly query?: Readonly<Record<string, string>>;
20
- /** Header name -> params key. */
21
- readonly headers?: Readonly<Record<string, string>>;
22
- readonly body?: "json" | "binary" | "multipart";
23
- readonly bodyRequired?: boolean;
24
- readonly multipartJSON?: readonly string[];
25
- readonly response: "json" | "void" | "binary" | "sse";
26
- /** The operation accepts an Idempotency-Key header. */
27
- readonly idempotency?: boolean;
28
- /**
29
- * Paginated list: [query parameter, response field] pairs, the default
30
- * direction first, e.g. [["cursor", "next_cursor"]].
31
- */
32
- readonly page?: readonly (readonly [string, string])[];
33
- }
34
- /** Per-request options; every resource method takes them last. */
35
- export interface RequestOptions {
36
- /**
37
- * Per-attempt timeout in milliseconds, until the response headers arrive;
38
- * 0 means none. Uploads use only this per-call value (no client default).
39
- */
40
- timeout?: number;
41
- /** Retries after the first attempt; for event streams, reconnects in a row without receiving data. */
42
- maxRetries?: number;
43
- signal?: AbortSignal;
44
- /**
45
- * Idempotency-Key for operations that declare it. When omitted the SDK
46
- * generates one and reuses it across the retries of this call.
47
- */
48
- idempotencyKey?: string;
49
- headers?: Record<string, string>;
50
- }
51
- /** A raw request body: file contents or bytes. */
52
- export type Uploadable = Blob | ArrayBuffer | ArrayBufferView | string;
53
- /** @internal A body that may be omitted entirely. */
54
- export type OptionalBody<B> = B | {
55
- [K in keyof B]?: never;
56
- };
57
- /** @internal A multipart body whose binary fields take a Blob or File. */
58
- export type MultipartBody<B, Files extends PropertyKey> = B extends unknown ? {
59
- [K in keyof B]: K extends Files ? Blob : B[K];
60
- } : never;
61
- /** @internal */
62
- export interface ClientCoreOptions {
63
- baseUrl: string;
64
- fetch?: typeof globalThis.fetch;
65
- timeout?: number;
66
- maxRetries?: number;
67
- /** Authentication and other headers sent on every request. */
68
- headers: Record<string, string>;
69
- /** Scope defaults keyed by params name (org_id, project_id). */
70
- scope: Record<string, string | undefined>;
71
- /** Client option that sets each scope default, for error messages. */
72
- scopeOption: Record<string, string>;
73
- }
74
- /**
75
- * The deployment origin of a BMA base URL (BMA_BASE_URL): trailing slashes and
76
- * a trailing /api/v1 (the pre-1.0 API-root form) are removed, so the SDK adds
77
- * each API prefix exactly once.
78
- */
79
- export declare function bmaOrigin(baseUrl: string): string;
80
- /** @internal The transport every resource calls. */
81
- export declare class ClientCore {
82
- #private;
83
- readonly baseUrl: string;
84
- constructor(options: ClientCoreOptions);
85
- /** @internal */
86
- _request<T>(op: OperationDescriptor, path: Record<string, string>, params: object, options?: RequestOptions): Promise<T>;
87
- /**
88
- * @internal A paginated list. The cursor parameter is the one of
89
- * `op.page` the caller passed (e.g. before_sequence), else the default.
90
- */
91
- _page<R extends CursorPageBody>(op: OperationDescriptor, path: Record<string, string>, params: object, options?: RequestOptions): PagePromise<R>;
92
- /**
93
- * @internal Event stream with EventSource reconnection: when the
94
- * connection drops or the server ends the response (a rolling restart), or
95
- * sends an `error` frame with code `service_unavailable`, the stream
96
- * reconnects with Last-Event-ID set to the last durable frame. A frame not
97
- * terminated before the end is discarded. Reconnects are bounded by
98
- * `maxReconnects` (default `maxRetries`) attempts in a row that receive no
99
- * data; any other error frame ends the stream with EventStreamError.
100
- */
101
- _stream<T>(op: OperationDescriptor, path: Record<string, string>, params: object, options?: RequestOptions, hooks?: {
102
- onOpen?: () => void;
103
- maxReconnects?: number;
104
- }): Stream<T>;
105
- }