@puku-ai/sdk 3.0.4 → 3.0.5

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 (6) hide show
  1. package/package.json +2 -1
  2. package/sdk.cjs +65 -72
  3. package/sdk.cjs.map +34 -34
  4. package/sdk.d.ts +198 -228
  5. package/sdk.mjs +21 -21
  6. package/sdk.mjs.map +34 -34
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puku-ai/sdk",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "PukuAI client SDK",
5
5
  "type": "module",
6
6
  "main": "./sdk.cjs",
@@ -55,6 +55,7 @@
55
55
  "scripts": {
56
56
  "build": "bun run scripts/build.ts",
57
57
  "smoke": "node scripts/smoke-offline.mjs",
58
+ "smoke:brand": "node scripts/smoke-anthropic-free.mjs",
58
59
  "smoke:live": "bun run build && node --experimental-vm-modules scripts/smoke.mjs",
59
60
  "integration": "bun run build && node scripts/integration.mjs",
60
61
  "parity": "bun run build && node tests/parity/run-all.mjs",
package/sdk.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- // Auto-generated by scripts/build.ts — Anthropic-style callable shim.
2
+ // Auto-generated by scripts/build.ts — puku callable shim.
3
3
  // Wraps the bun CJS bundle so `require("@puku-ai/sdk")(opts)` calls
4
- // `new module.exports.default(opts)` — matching `@anthropic-ai/sdk`.
4
+ // `new module.exports.default(opts)`.
5
5
 
6
6
  var __create = Object.create;
7
7
  var __getProtoOf = Object.getPrototypeOf;
@@ -111,7 +111,6 @@ __export(__pukuExports, {
111
111
  BasePuku: () => BasePuku,
112
112
  BadRequestError: () => BadRequestError,
113
113
  AuthenticationError: () => AuthenticationError,
114
- AnthropicError: () => AnthropicError,
115
114
  APIUserAbortError: () => APIUserAbortError,
116
115
  APIPromise: () => APIPromise,
117
116
  APIError: () => APIError,
@@ -160,10 +159,7 @@ var castToError = (err) => {
160
159
  };
161
160
 
162
161
  // src/vendor/core/error.ts
163
- class AnthropicError extends Error {
164
- }
165
-
166
- class PukuError extends AnthropicError {
162
+ class PukuError extends Error {
167
163
  constructor(message) {
168
164
  super(message);
169
165
  this.name = "PukuError";
@@ -300,10 +296,10 @@ function hasOwn(obj, key) {
300
296
  }
301
297
  var validatePositiveInteger = (name, n) => {
302
298
  if (typeof n !== "number" || !Number.isInteger(n)) {
303
- throw new AnthropicError(`${name} must be an integer`);
299
+ throw new PukuError(`${name} must be an integer`);
304
300
  }
305
301
  if (n < 0) {
306
- throw new AnthropicError(`${name} must be a positive integer`);
302
+ throw new PukuError(`${name} must be a positive integer`);
307
303
  }
308
304
  return n;
309
305
  };
@@ -460,7 +456,7 @@ function getDefaultFetch() {
460
456
  if (typeof fetch !== "undefined") {
461
457
  return fetch;
462
458
  }
463
- throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`");
459
+ throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new PukuAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`");
464
460
  }
465
461
  function makeReadableStream(...args) {
466
462
  const ReadableStream = globalThis.ReadableStream;
@@ -545,7 +541,7 @@ function stringifyQuery(query) {
545
541
  if (value === null) {
546
542
  return `${encodeURIComponent(key)}=`;
547
543
  }
548
- throw new AnthropicError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
544
+ throw new PukuError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
549
545
  }).join("&");
550
546
  }
551
547
 
@@ -737,7 +733,7 @@ class Stream {
737
733
  const logger = client ? loggerFor(client) : console;
738
734
  async function* iterator() {
739
735
  if (consumed) {
740
- throw new AnthropicError("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
736
+ throw new PukuError("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
741
737
  }
742
738
  consumed = true;
743
739
  let done = false;
@@ -798,7 +794,7 @@ class Stream {
798
794
  }
799
795
  async function* iterator() {
800
796
  if (consumed) {
801
- throw new AnthropicError("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
797
+ throw new PukuError("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
802
798
  }
803
799
  consumed = true;
804
800
  let done = false;
@@ -874,9 +870,9 @@ async function* _iterSSEMessages(response, controller) {
874
870
  if (!response.body) {
875
871
  controller.abort();
876
872
  if (typeof globalThis.navigator !== "undefined" && globalThis.navigator.product === "ReactNative") {
877
- throw new AnthropicError(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`);
873
+ throw new PukuError(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`);
878
874
  }
879
- throw new AnthropicError(`Attempted to iterate over a response with no body`);
875
+ throw new PukuError(`Attempted to iterate over a response with no body`);
880
876
  }
881
877
  const sseDecoder = new SSEDecoder;
882
878
  const lineDecoder = new LineDecoder;
@@ -1079,7 +1075,7 @@ class AbstractPage {
1079
1075
  async getNextPage() {
1080
1076
  const nextOptions = this.nextPageRequestOptions();
1081
1077
  if (!nextOptions) {
1082
- throw new AnthropicError("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");
1078
+ throw new PukuError("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");
1083
1079
  }
1084
1080
  return await this.#client.requestAPIList(this.constructor, nextOptions);
1085
1081
  }
@@ -1485,7 +1481,7 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path(stati
1485
1481
  lastEnd = segment.start + segment.length;
1486
1482
  return acc + spaces + arrows;
1487
1483
  }, "");
1488
- throw new AnthropicError(`Path parameters result in path with invalid segments:
1484
+ throw new PukuError(`Path parameters result in path with invalid segments:
1489
1485
  ${invalidSegments.map((e) => e.error).join(`
1490
1486
  `)}
1491
1487
  ${path2}
@@ -1661,7 +1657,7 @@ function parseBetaOutputFormat(params, content) {
1661
1657
  }
1662
1658
  return JSON.parse(content);
1663
1659
  } catch (error2) {
1664
- throw new AnthropicError(`Failed to parse structured output: ${error2}`);
1660
+ throw new PukuError(`Failed to parse structured output: ${error2}`);
1665
1661
  }
1666
1662
  }
1667
1663
 
@@ -2053,7 +2049,7 @@ class BetaMessageStream {
2053
2049
  }
2054
2050
  #getFinalMessage() {
2055
2051
  if (this.receivedMessages.length === 0) {
2056
- throw new AnthropicError("stream ended without producing a Message with role=assistant");
2052
+ throw new PukuError("stream ended without producing a Message with role=assistant");
2057
2053
  }
2058
2054
  return this.receivedMessages.at(-1);
2059
2055
  }
@@ -2063,11 +2059,11 @@ class BetaMessageStream {
2063
2059
  }
2064
2060
  #getFinalText() {
2065
2061
  if (this.receivedMessages.length === 0) {
2066
- throw new AnthropicError("stream ended without producing a Message with role=assistant");
2062
+ throw new PukuError("stream ended without producing a Message with role=assistant");
2067
2063
  }
2068
2064
  const textBlocks = this.receivedMessages.at(-1).content.filter((block) => block.type === "text").map((block) => block.text);
2069
2065
  if (textBlocks.length === 0) {
2070
- throw new AnthropicError("stream ended without producing a content block with type=text");
2066
+ throw new PukuError("stream ended without producing a content block with type=text");
2071
2067
  }
2072
2068
  return textBlocks.join(" ");
2073
2069
  }
@@ -2084,15 +2080,15 @@ class BetaMessageStream {
2084
2080
  this.#aborted = true;
2085
2081
  return this._emit("abort", error2);
2086
2082
  }
2087
- if (error2 instanceof AnthropicError) {
2083
+ if (error2 instanceof PukuError) {
2088
2084
  return this._emit("error", error2);
2089
2085
  }
2090
2086
  if (error2 instanceof Error) {
2091
- const anthropicError = new AnthropicError(error2.message);
2092
- anthropicError.cause = error2;
2093
- return this._emit("error", anthropicError);
2087
+ const pukuError = new PukuError(error2.message);
2088
+ pukuError.cause = error2;
2089
+ return this._emit("error", pukuError);
2094
2090
  }
2095
- return this._emit("error", new AnthropicError(String(error2)));
2091
+ return this._emit("error", new PukuError(String(error2)));
2096
2092
  };
2097
2093
  _emit(event, ...args) {
2098
2094
  if (this.#ended)
@@ -2207,11 +2203,11 @@ class BetaMessageStream {
2207
2203
  }
2208
2204
  #endRequest() {
2209
2205
  if (this.ended) {
2210
- throw new AnthropicError(`stream has ended, this shouldn't happen`);
2206
+ throw new PukuError(`stream has ended, this shouldn't happen`);
2211
2207
  }
2212
2208
  const snapshot = this.#currentMessageSnapshot;
2213
2209
  if (!snapshot) {
2214
- throw new AnthropicError(`request ended without sending any chunks`);
2210
+ throw new PukuError(`request ended without sending any chunks`);
2215
2211
  }
2216
2212
  this.#currentMessageSnapshot = undefined;
2217
2213
  return maybeParseBetaMessage(snapshot, this.#params, { logger: this.#logger });
@@ -2246,12 +2242,12 @@ class BetaMessageStream {
2246
2242
  let snapshot = this.#currentMessageSnapshot;
2247
2243
  if (event.type === "message_start") {
2248
2244
  if (snapshot) {
2249
- throw new AnthropicError(`Unexpected event order, got ${event.type} before receiving "message_stop"`);
2245
+ throw new PukuError(`Unexpected event order, got ${event.type} before receiving "message_stop"`);
2250
2246
  }
2251
2247
  return event.message;
2252
2248
  }
2253
2249
  if (!snapshot) {
2254
- throw new AnthropicError(`Unexpected event order, got ${event.type} before "message_start"`);
2250
+ throw new PukuError(`Unexpected event order, got ${event.type} before "message_start"`);
2255
2251
  }
2256
2252
  switch (event.type) {
2257
2253
  case "message_stop":
@@ -2316,7 +2312,7 @@ class BetaMessageStream {
2316
2312
  try {
2317
2313
  newContent.input = partialParse(jsonBuf);
2318
2314
  } catch (err) {
2319
- const error2 = new AnthropicError(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${err}. JSON: ${jsonBuf}`);
2315
+ const error2 = new PukuError(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${err}. JSON: ${jsonBuf}`);
2320
2316
  this.#handleError(error2);
2321
2317
  }
2322
2318
  }
@@ -2547,7 +2543,7 @@ class BetaToolRunner {
2547
2543
  headers: { "x-stainless-helper": "compaction" }
2548
2544
  });
2549
2545
  if (response.content[0]?.type !== "text") {
2550
- throw new AnthropicError("Expected text response for compaction");
2546
+ throw new PukuError("Expected text response for compaction");
2551
2547
  }
2552
2548
  this.#state.params.messages = [
2553
2549
  {
@@ -2559,7 +2555,7 @@ class BetaToolRunner {
2559
2555
  }
2560
2556
  async* [Symbol.asyncIterator]() {
2561
2557
  if (this.#consumed) {
2562
- throw new AnthropicError("Cannot iterate over a consumed stream");
2558
+ throw new PukuError("Cannot iterate over a consumed stream");
2563
2559
  }
2564
2560
  this.#consumed = true;
2565
2561
  this.#mutated = true;
@@ -2605,7 +2601,7 @@ class BetaToolRunner {
2605
2601
  }
2606
2602
  }
2607
2603
  if (!this.#message) {
2608
- throw new AnthropicError("ToolRunner concluded without a message from the server");
2604
+ throw new PukuError("ToolRunner concluded without a message from the server");
2609
2605
  }
2610
2606
  this.#completion.resolve(await this.#message);
2611
2607
  } catch (error2) {
@@ -2731,9 +2727,9 @@ class JSONLDecoder {
2731
2727
  if (!response.body) {
2732
2728
  controller.abort();
2733
2729
  if (typeof globalThis.navigator !== "undefined" && globalThis.navigator.product === "ReactNative") {
2734
- throw new AnthropicError(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`);
2730
+ throw new PukuError(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`);
2735
2731
  }
2736
- throw new AnthropicError(`Attempted to iterate over a response with no body`);
2732
+ throw new PukuError(`Attempted to iterate over a response with no body`);
2737
2733
  }
2738
2734
  return new JSONLDecoder(ReadableStreamToAsyncIterable(response.body), controller);
2739
2735
  }
@@ -2796,7 +2792,7 @@ class Batches extends APIResource {
2796
2792
  async results(messageBatchID, params = {}, options) {
2797
2793
  const batch = await this.retrieve(messageBatchID);
2798
2794
  if (!batch.results_url) {
2799
- throw new AnthropicError(`No batch \`results_url\`; Has it finished processing? ${batch.processing_status} - ${batch.id}`);
2795
+ throw new PukuError(`No batch \`results_url\`; Has it finished processing? ${batch.processing_status} - ${batch.id}`);
2800
2796
  }
2801
2797
  const { betas } = params ?? {};
2802
2798
  return this._client.get(batch.results_url, {
@@ -2837,10 +2833,10 @@ class Messages extends APIResource {
2837
2833
  const { betas, ...body } = modifiedParams;
2838
2834
  if (body.model in DEPRECATED_MODELS) {
2839
2835
  console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${DEPRECATED_MODELS[body.model]}
2840
- Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);
2836
+ Please migrate to a newer model. Contact your Puku account representative for supported alternatives.`);
2841
2837
  }
2842
2838
  if (body.model in MODELS_TO_WARN_WITH_THINKING_ENABLED && body.thinking && body.thinking.type === "enabled") {
2843
- console.warn(`Using Claude with ${body.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);
2839
+ console.warn(`Using ${body.model} with 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead for better model performance.`);
2844
2840
  }
2845
2841
  let timeout = this._client._options.timeout;
2846
2842
  if (!body.stream && timeout == null) {
@@ -2894,7 +2890,7 @@ function transformOutputFormat(params) {
2894
2890
  return params;
2895
2891
  }
2896
2892
  if (params.output_config?.format) {
2897
- throw new AnthropicError("Both output_format and output_config.format were provided. " + "Please use only output_config.format (output_format is deprecated).");
2893
+ throw new PukuError("Both output_format and output_config.format were provided. " + "Please use only output_config.format (output_format is deprecated).");
2898
2894
  }
2899
2895
  const { output_format, ...rest } = params;
2900
2896
  return {
@@ -3087,7 +3083,7 @@ function parseOutputFormat(params, content) {
3087
3083
  }
3088
3084
  return JSON.parse(content);
3089
3085
  } catch (error2) {
3090
- throw new AnthropicError(`Failed to parse structured output: ${error2}`);
3086
+ throw new PukuError(`Failed to parse structured output: ${error2}`);
3091
3087
  }
3092
3088
  }
3093
3089
 
@@ -3260,7 +3256,7 @@ class MessageStream {
3260
3256
  }
3261
3257
  #getFinalMessage() {
3262
3258
  if (this.receivedMessages.length === 0) {
3263
- throw new AnthropicError("stream ended without producing a Message with role=assistant");
3259
+ throw new PukuError("stream ended without producing a Message with role=assistant");
3264
3260
  }
3265
3261
  return this.receivedMessages.at(-1);
3266
3262
  }
@@ -3270,11 +3266,11 @@ class MessageStream {
3270
3266
  }
3271
3267
  #getFinalText() {
3272
3268
  if (this.receivedMessages.length === 0) {
3273
- throw new AnthropicError("stream ended without producing a Message with role=assistant");
3269
+ throw new PukuError("stream ended without producing a Message with role=assistant");
3274
3270
  }
3275
3271
  const textBlocks = this.receivedMessages.at(-1).content.filter((block) => block.type === "text").map((block) => block.text);
3276
3272
  if (textBlocks.length === 0) {
3277
- throw new AnthropicError("stream ended without producing a content block with type=text");
3273
+ throw new PukuError("stream ended without producing a content block with type=text");
3278
3274
  }
3279
3275
  return textBlocks.join(" ");
3280
3276
  }
@@ -3291,15 +3287,15 @@ class MessageStream {
3291
3287
  this.#aborted = true;
3292
3288
  return this._emit("abort", error2);
3293
3289
  }
3294
- if (error2 instanceof AnthropicError) {
3290
+ if (error2 instanceof PukuError) {
3295
3291
  return this._emit("error", error2);
3296
3292
  }
3297
3293
  if (error2 instanceof Error) {
3298
- const anthropicError = new AnthropicError(error2.message);
3299
- anthropicError.cause = error2;
3300
- return this._emit("error", anthropicError);
3294
+ const pukuError = new PukuError(error2.message);
3295
+ pukuError.cause = error2;
3296
+ return this._emit("error", pukuError);
3301
3297
  }
3302
- return this._emit("error", new AnthropicError(String(error2)));
3298
+ return this._emit("error", new PukuError(String(error2)));
3303
3299
  };
3304
3300
  _emit(event, ...args) {
3305
3301
  if (this.#ended)
@@ -3410,11 +3406,11 @@ class MessageStream {
3410
3406
  }
3411
3407
  #endRequest() {
3412
3408
  if (this.ended) {
3413
- throw new AnthropicError(`stream has ended, this shouldn't happen`);
3409
+ throw new PukuError(`stream has ended, this shouldn't happen`);
3414
3410
  }
3415
3411
  const snapshot = this.#currentMessageSnapshot;
3416
3412
  if (!snapshot) {
3417
- throw new AnthropicError(`request ended without sending any chunks`);
3413
+ throw new PukuError(`request ended without sending any chunks`);
3418
3414
  }
3419
3415
  this.#currentMessageSnapshot = undefined;
3420
3416
  return maybeParseMessage(snapshot, this.#params, { logger: this.#logger });
@@ -3449,12 +3445,12 @@ class MessageStream {
3449
3445
  let snapshot = this.#currentMessageSnapshot;
3450
3446
  if (event.type === "message_start") {
3451
3447
  if (snapshot) {
3452
- throw new AnthropicError(`Unexpected event order, got ${event.type} before receiving "message_stop"`);
3448
+ throw new PukuError(`Unexpected event order, got ${event.type} before receiving "message_stop"`);
3453
3449
  }
3454
3450
  return event.message;
3455
3451
  }
3456
3452
  if (!snapshot) {
3457
- throw new AnthropicError(`Unexpected event order, got ${event.type} before "message_start"`);
3453
+ throw new PukuError(`Unexpected event order, got ${event.type} before "message_start"`);
3458
3454
  }
3459
3455
  switch (event.type) {
3460
3456
  case "message_stop":
@@ -3621,7 +3617,7 @@ class Batches2 extends APIResource {
3621
3617
  async results(messageBatchID, options) {
3622
3618
  const batch = await this.retrieve(messageBatchID);
3623
3619
  if (!batch.results_url) {
3624
- throw new AnthropicError(`No batch \`results_url\`; Has it finished processing? ${batch.processing_status} - ${batch.id}`);
3620
+ throw new PukuError(`No batch \`results_url\`; Has it finished processing? ${batch.processing_status} - ${batch.id}`);
3625
3621
  }
3626
3622
  return this._client.get(batch.results_url, {
3627
3623
  ...options,
@@ -3638,10 +3634,10 @@ class Messages2 extends APIResource {
3638
3634
  create(body, options) {
3639
3635
  if (body.model in DEPRECATED_MODELS2) {
3640
3636
  console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${DEPRECATED_MODELS2[body.model]}
3641
- Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);
3637
+ Please migrate to a newer model. Contact your Puku account representative for supported alternatives.`);
3642
3638
  }
3643
3639
  if (body.model in MODELS_TO_WARN_WITH_THINKING_ENABLED2 && body.thinking && body.thinking.type === "enabled") {
3644
- console.warn(`Using Claude with ${body.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);
3640
+ console.warn(`Using ${body.model} with 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead for better model performance.`);
3645
3641
  }
3646
3642
  let timeout = this._client._options.timeout;
3647
3643
  if (!body.stream && timeout == null) {
@@ -3749,13 +3745,13 @@ class BasePuku {
3749
3745
  baseURL
3750
3746
  };
3751
3747
  if (!options.dangerouslyAllowBrowser && isRunningInBrowser()) {
3752
- throw new AnthropicError(`It looks like you're running in a browser-like environment.
3748
+ throw new PukuError(`It looks like you're running in a browser-like environment.
3753
3749
 
3754
3750
  This is disabled by default, as it risks exposing your secret API credentials to attackers.
3755
3751
  If you understand the risks and have appropriate mitigations in place,
3756
3752
  you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
3757
3753
 
3758
- new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
3754
+ new PukuAI({ apiKey, dangerouslyAllowBrowser: true });
3759
3755
  `);
3760
3756
  }
3761
3757
  this.baseURL = options.baseURL;
@@ -3845,7 +3841,7 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
3845
3841
  const defaultTimeout = 10 * 60;
3846
3842
  const expectedTimeout = 60 * 60 * maxTokens / 128000;
3847
3843
  if (expectedTimeout > defaultTimeout) {
3848
- throw new AnthropicError("Streaming is required for operations that may take longer than 10 minutes. " + "See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");
3844
+ throw new PukuError("Streaming is required for operations that may take longer than 10 minutes. " + "See the @puku-ai/sdk README for more details");
3849
3845
  }
3850
3846
  return defaultTimeout * 1000;
3851
3847
  }
@@ -4055,7 +4051,7 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
4055
4051
  const defaultTime = 60 * 10 * 1000;
4056
4052
  const expectedTime = maxTime * maxTokens / 128000;
4057
4053
  if (expectedTime > defaultTime || maxNonstreamingTokens != null && maxTokens > maxNonstreamingTokens) {
4058
- throw new AnthropicError("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");
4054
+ throw new PukuError("Streaming is required for operations that may take longer than 10 minutes. See the @puku-ai/sdk README for more details");
4059
4055
  }
4060
4056
  return defaultTime;
4061
4057
  }
@@ -4131,12 +4127,10 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
4131
4127
  return this.#encoder({ body, headers });
4132
4128
  }
4133
4129
  }
4134
- static Anthropic = this;
4135
4130
  static PukuAI = this;
4136
4131
  static HUMAN_PROMPT = HUMAN_PROMPT;
4137
4132
  static AI_PROMPT = AI_PROMPT;
4138
4133
  static DEFAULT_TIMEOUT = 600000;
4139
- static AnthropicError = AnthropicError;
4140
4134
  static PukuError = PukuError;
4141
4135
  static APIError = APIError;
4142
4136
  static APIConnectionError = APIConnectionError;
@@ -4163,7 +4157,6 @@ PukuAI.Completions = Completions;
4163
4157
  PukuAI.Messages = Messages2;
4164
4158
  PukuAI.Models = Models2;
4165
4159
  PukuAI.Beta = Beta;
4166
- PukuAI.Anthropic = PukuAI;
4167
4160
  // src/vendor/internal/utils/base64.ts
4168
4161
  var fromBase64 = (str) => {
4169
4162
  if (typeof globalThis.Buffer !== "undefined") {
@@ -4178,7 +4171,7 @@ var fromBase64 = (str) => {
4178
4171
  }
4179
4172
  return buf;
4180
4173
  }
4181
- throw new AnthropicError("Cannot decode base64 string; Expected `Buffer` or `atob` to be defined");
4174
+ throw new PukuError("Cannot decode base64 string; Expected `Buffer` or `atob` to be defined");
4182
4175
  };
4183
4176
  // src/vendor/lib/transform-json-schema.ts
4184
4177
  var SUPPORTED_STRING_FORMATS = new Set([
@@ -4309,14 +4302,14 @@ function betaJSONSchemaOutputFormat(jsonSchema, options) {
4309
4302
  try {
4310
4303
  return JSON.parse(content);
4311
4304
  } catch (error2) {
4312
- throw new AnthropicError(`Failed to parse structured output: ${error2}`);
4305
+ throw new PukuError(`Failed to parse structured output: ${error2}`);
4313
4306
  }
4314
4307
  }
4315
4308
  };
4316
4309
  }
4317
4310
  // src/vendor/helpers/beta/zod.ts
4318
4311
  function requireZod(importName) {
4319
- throw new AnthropicError(`${importName} is provided by @puku-ai/sdk as a stub. ` + "Install the `zod` peer dependency to use this helper at runtime.");
4312
+ throw new PukuError(`${importName} is provided by @puku-ai/sdk as a stub. ` + "Install the `zod` peer dependency to use this helper at runtime.");
4320
4313
  }
4321
4314
  function betaZodOutputFormat(_zodObject) {
4322
4315
  requireZod("betaZodOutputFormat");
@@ -4639,7 +4632,7 @@ var import_node_child_process = require("node:child_process");
4639
4632
  var import_node_util = require("node:util");
4640
4633
  var execFileAsync = import_node_util.promisify(import_node_child_process.execFile);
4641
4634
  function notVendored(name) {
4642
- throw new AnthropicError(`${name} requires the upstream /v1/skills/{id}/versions/{version} and/or /v1/sessions/{id} resources. ` + "@puku-ai/sdk does not yet vendor those endpoints — the agent-toolset ships without skill auto-download. " + "Use betaAgentToolset20260401({ workdir }) without client/sessionId to get the bare tools.");
4635
+ throw new PukuError(`${name} requires the upstream /v1/skills/{id}/versions/{version} and/or /v1/sessions/{id} resources. ` + "@puku-ai/sdk does not yet vendor those endpoints — the agent-toolset ships without skill auto-download. " + "Use betaAgentToolset20260401({ workdir }) without client/sessionId to get the bare tools.");
4643
4636
  }
4644
4637
  async function setupSkills(ctx) {
4645
4638
  const { client, sessionId } = ctx;
@@ -4664,7 +4657,7 @@ var GREP_OUTPUT_LIMIT = 100 * 1024;
4664
4657
  var GREP_MAX_LINE_LENGTH = 2000;
4665
4658
  var GLOB_RESULT_LIMIT = 200;
4666
4659
 
4667
- class BashTimeoutError extends AnthropicError {
4660
+ class BashTimeoutError extends PukuError {
4668
4661
  timeoutMs;
4669
4662
  constructor(timeoutMs) {
4670
4663
  super(`bash command timed out after ${timeoutMs}ms`);
@@ -4693,7 +4686,7 @@ function resolvePath(ctx, p) {
4693
4686
  function scrubbedShellEnv() {
4694
4687
  const env2 = {};
4695
4688
  for (const [key, value] of Object.entries(process.env)) {
4696
- if (key.startsWith("ANTHROPIC_"))
4689
+ if (key.startsWith("PUKU_"))
4697
4690
  continue;
4698
4691
  env2[key] = value;
4699
4692
  }
@@ -4741,7 +4734,7 @@ class BashSession {
4741
4734
  }
4742
4735
  async exec(command, opts = {}) {
4743
4736
  if (this.#closed) {
4744
- throw new AnthropicError("bash session terminated");
4737
+ throw new PukuError("bash session terminated");
4745
4738
  }
4746
4739
  const timeoutMs = opts.timeoutMs ?? BASH_DEFAULT_TIMEOUT_MS;
4747
4740
  const signal = opts.signal;
@@ -4782,7 +4775,7 @@ class BashSession {
4782
4775
  }
4783
4776
  const idx = this.#buf.indexOf(sentinel);
4784
4777
  if (idx < 0) {
4785
- throw new AnthropicError("bash session terminated");
4778
+ throw new PukuError("bash session terminated");
4786
4779
  }
4787
4780
  const tail = this.#buf.slice(idx + sentinel.length);
4788
4781
  const m = tail.match(/^(-?\d+)/);
@@ -5221,7 +5214,7 @@ async function findRg() {
5221
5214
  return null;
5222
5215
  }
5223
5216
 
5224
- //# debugId=E40F809F89B47F8464756E2164756E21
5217
+ //# debugId=CC32801D4B7FA93E64756E2164756E21
5225
5218
 
5226
5219
 
5227
5220
  // Capture in a closure so the callable shim doesn't lose the export