@anthropic-ai/sdk 0.105.0 → 0.106.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 (140) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/core/streaming.d.mts.map +1 -1
  3. package/core/streaming.d.ts.map +1 -1
  4. package/core/streaming.js +2 -1
  5. package/core/streaming.js.map +1 -1
  6. package/core/streaming.mjs +2 -1
  7. package/core/streaming.mjs.map +1 -1
  8. package/helpers/beta/mcp.d.mts +1 -1
  9. package/helpers/beta/mcp.d.mts.map +1 -1
  10. package/helpers/beta/mcp.d.ts +1 -1
  11. package/helpers/beta/mcp.d.ts.map +1 -1
  12. package/helpers/beta/mcp.js +1 -1
  13. package/helpers/beta/mcp.js.map +1 -1
  14. package/helpers/beta/mcp.mjs +1 -1
  15. package/helpers/beta/mcp.mjs.map +1 -1
  16. package/internal/headers.d.mts +7 -0
  17. package/internal/headers.d.mts.map +1 -1
  18. package/internal/headers.d.ts +7 -0
  19. package/internal/headers.d.ts.map +1 -1
  20. package/internal/headers.js +45 -4
  21. package/internal/headers.js.map +1 -1
  22. package/internal/headers.mjs +43 -3
  23. package/internal/headers.mjs.map +1 -1
  24. package/internal/stainless-helper-header.d.mts +60 -0
  25. package/internal/stainless-helper-header.d.mts.map +1 -0
  26. package/internal/stainless-helper-header.d.ts +60 -0
  27. package/internal/stainless-helper-header.d.ts.map +1 -0
  28. package/{lib → internal}/stainless-helper-header.js +27 -6
  29. package/internal/stainless-helper-header.js.map +1 -0
  30. package/{lib → internal}/stainless-helper-header.mjs +25 -5
  31. package/internal/stainless-helper-header.mjs.map +1 -0
  32. package/lib/BetaMessageStream.d.mts.map +1 -1
  33. package/lib/BetaMessageStream.d.ts.map +1 -1
  34. package/lib/BetaMessageStream.js +2 -1
  35. package/lib/BetaMessageStream.js.map +1 -1
  36. package/lib/BetaMessageStream.mjs +2 -1
  37. package/lib/BetaMessageStream.mjs.map +1 -1
  38. package/lib/MessageStream.d.mts.map +1 -1
  39. package/lib/MessageStream.d.ts.map +1 -1
  40. package/lib/MessageStream.js +2 -1
  41. package/lib/MessageStream.js.map +1 -1
  42. package/lib/MessageStream.mjs +2 -1
  43. package/lib/MessageStream.mjs.map +1 -1
  44. package/lib/helper-client.d.mts +2 -20
  45. package/lib/helper-client.d.mts.map +1 -1
  46. package/lib/helper-client.d.ts +2 -20
  47. package/lib/helper-client.d.ts.map +1 -1
  48. package/lib/helper-client.js +2 -1
  49. package/lib/helper-client.js.map +1 -1
  50. package/lib/helper-client.mjs +2 -1
  51. package/lib/helper-client.mjs.map +1 -1
  52. package/lib/middleware.d.mts.map +1 -1
  53. package/lib/middleware.d.ts.map +1 -1
  54. package/lib/middleware.js +7 -5
  55. package/lib/middleware.js.map +1 -1
  56. package/lib/middleware.mjs +7 -5
  57. package/lib/middleware.mjs.map +1 -1
  58. package/lib/tools/BetaToolRunner.d.mts.map +1 -1
  59. package/lib/tools/BetaToolRunner.d.ts.map +1 -1
  60. package/lib/tools/BetaToolRunner.js +11 -5
  61. package/lib/tools/BetaToolRunner.js.map +1 -1
  62. package/lib/tools/BetaToolRunner.mjs +11 -5
  63. package/lib/tools/BetaToolRunner.mjs.map +1 -1
  64. package/lib/tools/SessionToolRunner.d.mts.map +1 -1
  65. package/lib/tools/SessionToolRunner.d.ts.map +1 -1
  66. package/lib/tools/SessionToolRunner.js +2 -3
  67. package/lib/tools/SessionToolRunner.js.map +1 -1
  68. package/lib/tools/SessionToolRunner.mjs +2 -3
  69. package/lib/tools/SessionToolRunner.mjs.map +1 -1
  70. package/package.json +1 -1
  71. package/resources/beta/agents/agents.d.mts +7 -2
  72. package/resources/beta/agents/agents.d.mts.map +1 -1
  73. package/resources/beta/agents/agents.d.ts +7 -2
  74. package/resources/beta/agents/agents.d.ts.map +1 -1
  75. package/resources/beta/agents/agents.js.map +1 -1
  76. package/resources/beta/agents/agents.mjs.map +1 -1
  77. package/resources/beta/files.js +1 -1
  78. package/resources/beta/files.js.map +1 -1
  79. package/resources/beta/files.mjs +1 -1
  80. package/resources/beta/files.mjs.map +1 -1
  81. package/resources/beta/messages/batches.d.mts +8 -5
  82. package/resources/beta/messages/batches.d.mts.map +1 -1
  83. package/resources/beta/messages/batches.d.ts +8 -5
  84. package/resources/beta/messages/batches.d.ts.map +1 -1
  85. package/resources/beta/messages/batches.js +5 -2
  86. package/resources/beta/messages/batches.js.map +1 -1
  87. package/resources/beta/messages/batches.mjs +5 -2
  88. package/resources/beta/messages/batches.mjs.map +1 -1
  89. package/resources/beta/messages/messages.d.mts +11 -8
  90. package/resources/beta/messages/messages.d.mts.map +1 -1
  91. package/resources/beta/messages/messages.d.ts +11 -8
  92. package/resources/beta/messages/messages.d.ts.map +1 -1
  93. package/resources/beta/messages/messages.js +6 -3
  94. package/resources/beta/messages/messages.js.map +1 -1
  95. package/resources/beta/messages/messages.mjs +6 -3
  96. package/resources/beta/messages/messages.mjs.map +1 -1
  97. package/resources/messages/batches.d.mts +11 -3
  98. package/resources/messages/batches.d.mts.map +1 -1
  99. package/resources/messages/batches.d.ts +11 -3
  100. package/resources/messages/batches.d.ts.map +1 -1
  101. package/resources/messages/batches.js +10 -2
  102. package/resources/messages/batches.js.map +1 -1
  103. package/resources/messages/batches.mjs +10 -2
  104. package/resources/messages/batches.mjs.map +1 -1
  105. package/resources/messages/messages.d.mts +38 -26
  106. package/resources/messages/messages.d.mts.map +1 -1
  107. package/resources/messages/messages.d.ts +38 -26
  108. package/resources/messages/messages.d.ts.map +1 -1
  109. package/resources/messages/messages.js +9 -4
  110. package/resources/messages/messages.js.map +1 -1
  111. package/resources/messages/messages.mjs +9 -4
  112. package/resources/messages/messages.mjs.map +1 -1
  113. package/src/core/streaming.ts +2 -1
  114. package/src/helpers/beta/mcp.ts +1 -1
  115. package/src/internal/headers.ts +47 -4
  116. package/src/internal/stainless-helper-header.ts +122 -0
  117. package/src/lib/BetaMessageStream.ts +2 -1
  118. package/src/lib/MessageStream.ts +2 -1
  119. package/src/lib/helper-client.ts +6 -9
  120. package/src/lib/middleware.ts +10 -4
  121. package/src/lib/tools/BetaToolRunner.ts +15 -6
  122. package/src/lib/tools/SessionToolRunner.ts +2 -4
  123. package/src/resources/beta/agents/agents.ts +7 -2
  124. package/src/resources/beta/files.ts +1 -1
  125. package/src/resources/beta/messages/batches.ts +14 -8
  126. package/src/resources/beta/messages/messages.ts +17 -11
  127. package/src/resources/messages/batches.ts +21 -4
  128. package/src/resources/messages/messages.ts +48 -31
  129. package/src/version.ts +1 -1
  130. package/version.d.mts +1 -1
  131. package/version.d.ts +1 -1
  132. package/version.js +1 -1
  133. package/version.mjs +1 -1
  134. package/lib/stainless-helper-header.d.mts +0 -34
  135. package/lib/stainless-helper-header.d.mts.map +0 -1
  136. package/lib/stainless-helper-header.d.ts +0 -34
  137. package/lib/stainless-helper-header.d.ts.map +0 -1
  138. package/lib/stainless-helper-header.js.map +0 -1
  139. package/lib/stainless-helper-header.mjs.map +0 -1
  140. package/src/lib/stainless-helper-header.ts +0 -80
@@ -5,7 +5,7 @@ import { APIResource } from '../../core/resource';
5
5
  import { Stream } from '../../core/streaming';
6
6
  import { buildHeaders } from '../../internal/headers';
7
7
  import { RequestOptions } from '../../internal/request-options';
8
- import { stainlessHelperHeader } from '../../lib/stainless-helper-header';
8
+ import { stainlessHelperHeader } from '../../internal/stainless-helper-header';
9
9
  import { MessageStream } from '../../lib/MessageStream';
10
10
  import {
11
11
  parseMessage,
@@ -55,19 +55,20 @@ export class Messages extends APIResource {
55
55
  * });
56
56
  * ```
57
57
  */
58
- create(body: MessageCreateParamsNonStreaming, options?: RequestOptions): APIPromise<Message>;
58
+ create(params: MessageCreateParamsNonStreaming, options?: RequestOptions): APIPromise<Message>;
59
59
  create(
60
- body: MessageCreateParamsStreaming,
60
+ params: MessageCreateParamsStreaming,
61
61
  options?: RequestOptions,
62
62
  ): APIPromise<Stream<RawMessageStreamEvent>>;
63
63
  create(
64
- body: MessageCreateParamsBase,
64
+ params: MessageCreateParamsBase,
65
65
  options?: RequestOptions,
66
66
  ): APIPromise<Stream<RawMessageStreamEvent> | Message>;
67
67
  create(
68
- body: MessageCreateParams,
68
+ params: MessageCreateParams,
69
69
  options?: RequestOptions,
70
70
  ): APIPromise<Message> | APIPromise<Stream<RawMessageStreamEvent>> {
71
+ const { user_profile_id, ...body } = params;
71
72
  if (body.model in DEPRECATED_MODELS) {
72
73
  console.warn(
73
74
  `The model '${body.model}' is deprecated and will reach end-of-life on ${
@@ -93,13 +94,16 @@ export class Messages extends APIResource {
93
94
 
94
95
  // Collect helper info from tools and messages
95
96
  const helperHeader = stainlessHelperHeader(body.tools, body.messages);
96
-
97
97
  return this._client.post('/v1/messages', {
98
98
  body,
99
99
  timeout: timeout ?? 600000,
100
100
  ...options,
101
- headers: buildHeaders([helperHeader, options?.headers]),
102
- stream: body.stream ?? false,
101
+ headers: buildHeaders([
102
+ { ...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined) },
103
+ helperHeader,
104
+ options?.headers,
105
+ ]),
106
+ stream: params.stream ?? false,
103
107
  }) as APIPromise<Message> | APIPromise<Stream<RawMessageStreamEvent>>;
104
108
  }
105
109
 
@@ -289,7 +293,9 @@ export interface CacheControlEphemeral {
289
293
  * - `5m`: 5 minutes
290
294
  * - `1h`: 1 hour
291
295
  *
292
- * Defaults to `5m`.
296
+ * Defaults to `5m`. See
297
+ * [prompt caching pricing](https://docs.claude.com/en/docs/build-with-claude/prompt-caching)
298
+ * for details.
293
299
  */
294
300
  ttl?: '5m' | '1h';
295
301
  }
@@ -1443,7 +1449,7 @@ export interface RefusalStopDetails {
1443
1449
  /**
1444
1450
  * The policy category that triggered a refusal.
1445
1451
  */
1446
- category: 'cyber' | 'bio' | 'frontier_llm' | 'reasoning_extraction' | null;
1452
+ category: 'cyber' | 'bio' | 'frontier_llm' | 'reasoning_extraction' | 'military_weapons' | null;
1447
1453
 
1448
1454
  /**
1449
1455
  * Human-readable explanation of the refusal.
@@ -2883,7 +2889,7 @@ export type MessageCreateParams = MessageCreateParamsNonStreaming | MessageCreat
2883
2889
 
2884
2890
  export interface MessageCreateParamsBase {
2885
2891
  /**
2886
- * The maximum number of tokens to generate before stopping.
2892
+ * Body param: The maximum number of tokens to generate before stopping.
2887
2893
  *
2888
2894
  * Note that our models may stop _before_ reaching this maximum. This parameter
2889
2895
  * only specifies the absolute maximum number of tokens to generate.
@@ -2898,7 +2904,7 @@ export interface MessageCreateParamsBase {
2898
2904
  max_tokens: number;
2899
2905
 
2900
2906
  /**
2901
- * Input messages.
2907
+ * Body param: Input messages.
2902
2908
  *
2903
2909
  * Our models are trained to operate on alternating `user` and `assistant`
2904
2910
  * conversational turns. When creating a new `Message`, you specify the prior
@@ -2967,7 +2973,7 @@ export interface MessageCreateParamsBase {
2967
2973
  messages: Array<MessageParam>;
2968
2974
 
2969
2975
  /**
2970
- * The model that will complete your prompt.
2976
+ * Body param: The model that will complete your prompt.
2971
2977
  *
2972
2978
  * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
2973
2979
  * details and options.
@@ -2975,35 +2981,36 @@ export interface MessageCreateParamsBase {
2975
2981
  model: Model;
2976
2982
 
2977
2983
  /**
2978
- * Top-level cache control automatically applies a cache_control marker to the last
2979
- * cacheable block in the request.
2984
+ * Body param: Top-level cache control automatically applies a cache_control marker
2985
+ * to the last cacheable block in the request.
2980
2986
  */
2981
2987
  cache_control?: CacheControlEphemeral | null;
2982
2988
 
2983
2989
  /**
2984
- * Container identifier for reuse across requests.
2990
+ * Body param: Container identifier for reuse across requests.
2985
2991
  */
2986
2992
  container?: string | null;
2987
2993
 
2988
2994
  /**
2989
- * Specifies the geographic region for inference processing. If not specified, the
2990
- * workspace's `default_inference_geo` is used.
2995
+ * Body param: Specifies the geographic region for inference processing. If not
2996
+ * specified, the workspace's `default_inference_geo` is used.
2991
2997
  */
2992
2998
  inference_geo?: string | null;
2993
2999
 
2994
3000
  /**
2995
- * An object describing metadata about the request.
3001
+ * Body param: An object describing metadata about the request.
2996
3002
  */
2997
3003
  metadata?: Metadata;
2998
3004
 
2999
3005
  /**
3000
- * Configuration options for the model's output, such as the output format.
3006
+ * Body param: Configuration options for the model's output, such as the output
3007
+ * format.
3001
3008
  */
3002
3009
  output_config?: OutputConfig;
3003
3010
 
3004
3011
  /**
3005
- * Determines whether to use priority capacity (if available) or standard capacity
3006
- * for this request.
3012
+ * Body param: Determines whether to use priority capacity (if available) or
3013
+ * standard capacity for this request.
3007
3014
  *
3008
3015
  * Anthropic offers different levels of service for your API requests. See
3009
3016
  * [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.
@@ -3011,7 +3018,7 @@ export interface MessageCreateParamsBase {
3011
3018
  service_tier?: 'auto' | 'standard_only';
3012
3019
 
3013
3020
  /**
3014
- * Custom text sequences that will cause the model to stop generating.
3021
+ * Body param: Custom text sequences that will cause the model to stop generating.
3015
3022
  *
3016
3023
  * Our models will normally stop when they have naturally completed their turn,
3017
3024
  * which will result in a response `stop_reason` of `"end_turn"`.
@@ -3024,14 +3031,15 @@ export interface MessageCreateParamsBase {
3024
3031
  stop_sequences?: Array<string>;
3025
3032
 
3026
3033
  /**
3027
- * Whether to incrementally stream the response using server-sent events.
3034
+ * Body param: Whether to incrementally stream the response using server-sent
3035
+ * events.
3028
3036
  *
3029
3037
  * See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
3030
3038
  */
3031
3039
  stream?: boolean;
3032
3040
 
3033
3041
  /**
3034
- * System prompt.
3042
+ * Body param: System prompt.
3035
3043
  *
3036
3044
  * A system prompt is a way of providing context and instructions to Claude, such
3037
3045
  * as specifying a particular goal or role. See our
@@ -3047,7 +3055,7 @@ export interface MessageCreateParamsBase {
3047
3055
  temperature?: number;
3048
3056
 
3049
3057
  /**
3050
- * Configuration for enabling Claude's extended thinking.
3058
+ * Body param: Configuration for enabling Claude's extended thinking.
3051
3059
  *
3052
3060
  * When enabled, responses include `thinking` content blocks showing Claude's
3053
3061
  * thinking process before the final answer. Requires a minimum budget of 1,024
@@ -3060,13 +3068,13 @@ export interface MessageCreateParamsBase {
3060
3068
  thinking?: ThinkingConfigParam;
3061
3069
 
3062
3070
  /**
3063
- * How the model should use the provided tools. The model can use a specific tool,
3064
- * any available tool, decide by itself, or not use tools at all.
3071
+ * Body param: How the model should use the provided tools. The model can use a
3072
+ * specific tool, any available tool, decide by itself, or not use tools at all.
3065
3073
  */
3066
3074
  tool_choice?: ToolChoice;
3067
3075
 
3068
3076
  /**
3069
- * Definitions of tools that the model may use.
3077
+ * Body param: Definitions of tools that the model may use.
3070
3078
  *
3071
3079
  * If you include `tools` in your API request, the model may return `tool_use`
3072
3080
  * content blocks that represent the model's use of those tools. You can then run
@@ -3156,6 +3164,13 @@ export interface MessageCreateParamsBase {
3156
3164
  * other values will be rejected with a 400 error.
3157
3165
  */
3158
3166
  top_p?: number;
3167
+
3168
+ /**
3169
+ * Header param: The user profile ID to attribute this request to. Use when acting
3170
+ * on behalf of a party other than your organization. Requires the `user-profiles`
3171
+ * beta header.
3172
+ */
3173
+ user_profile_id?: string;
3159
3174
  }
3160
3175
 
3161
3176
  export namespace MessageCreateParams {
@@ -3165,7 +3180,8 @@ export namespace MessageCreateParams {
3165
3180
 
3166
3181
  export interface MessageCreateParamsNonStreaming extends MessageCreateParamsBase {
3167
3182
  /**
3168
- * Whether to incrementally stream the response using server-sent events.
3183
+ * Body param: Whether to incrementally stream the response using server-sent
3184
+ * events.
3169
3185
  *
3170
3186
  * See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
3171
3187
  */
@@ -3174,7 +3190,8 @@ export interface MessageCreateParamsNonStreaming extends MessageCreateParamsBase
3174
3190
 
3175
3191
  export interface MessageCreateParamsStreaming extends MessageCreateParamsBase {
3176
3192
  /**
3177
- * Whether to incrementally stream the response using server-sent events.
3193
+ * Body param: Whether to incrementally stream the response using server-sent
3194
+ * events.
3178
3195
  *
3179
3196
  * See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
3180
3197
  */
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.105.0'; // x-release-please-version
1
+ export const VERSION = '0.106.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.105.0";
1
+ export declare const VERSION = "0.106.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.105.0";
1
+ export declare const VERSION = "0.106.0";
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.105.0'; // x-release-please-version
4
+ exports.VERSION = '0.106.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.105.0'; // x-release-please-version
1
+ export const VERSION = '0.106.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map
@@ -1,34 +0,0 @@
1
- /**
2
- * Shared utilities for tracking SDK helper usage.
3
- */
4
- import type { BetaMessageParam, BetaToolUnion } from "../resources/beta.mjs";
5
- /**
6
- * Symbol used to mark objects created by SDK helpers for tracking.
7
- * The value is the helper name (e.g., 'mcpTool', 'betaZodTool').
8
- */
9
- export declare const SDK_HELPER_SYMBOL: unique symbol;
10
- type StainlessHelperObject = {
11
- [SDK_HELPER_SYMBOL]: string;
12
- };
13
- export declare function wasCreatedByStainlessHelper(value: unknown): value is StainlessHelperObject;
14
- /**
15
- * Collects helper names from tools and messages arrays.
16
- * Returns a deduplicated array of helper names found.
17
- */
18
- export declare function collectStainlessHelpers(tools: BetaToolUnion[] | undefined, messages: BetaMessageParam[] | undefined): string[];
19
- /**
20
- * Builds x-stainless-helper header value from tools and messages.
21
- * Returns an empty object if no helpers are found.
22
- */
23
- export declare function stainlessHelperHeader(tools: BetaToolUnion[] | undefined, messages: BetaMessageParam[] | undefined): {
24
- 'x-stainless-helper'?: string;
25
- };
26
- /**
27
- * Builds x-stainless-helper header value from a file object.
28
- * Returns an empty object if the file is not marked with a helper.
29
- */
30
- export declare function stainlessHelperHeaderFromFile(file: unknown): {
31
- 'x-stainless-helper'?: string;
32
- };
33
- export {};
34
- //# sourceMappingURL=stainless-helper-header.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stainless-helper-header.d.mts","sourceRoot":"","sources":["../src/lib/stainless-helper-header.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,8BAA0B;AAEzE;;;GAGG;AACH,eAAO,MAAM,iBAAiB,eAA0C,CAAC;AAEzE,KAAK,qBAAqB,GAAG;IAAE,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB,CAE1F;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,aAAa,EAAE,GAAG,SAAS,EAClC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,SAAS,GACvC,MAAM,EAAE,CA8BV;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,aAAa,EAAE,GAAG,SAAS,EAClC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,SAAS,GACvC;IAAE,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAAE,CAInC;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,OAAO,GAAG;IAAE,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAAE,CAK9F"}
@@ -1,34 +0,0 @@
1
- /**
2
- * Shared utilities for tracking SDK helper usage.
3
- */
4
- import type { BetaMessageParam, BetaToolUnion } from "../resources/beta.js";
5
- /**
6
- * Symbol used to mark objects created by SDK helpers for tracking.
7
- * The value is the helper name (e.g., 'mcpTool', 'betaZodTool').
8
- */
9
- export declare const SDK_HELPER_SYMBOL: unique symbol;
10
- type StainlessHelperObject = {
11
- [SDK_HELPER_SYMBOL]: string;
12
- };
13
- export declare function wasCreatedByStainlessHelper(value: unknown): value is StainlessHelperObject;
14
- /**
15
- * Collects helper names from tools and messages arrays.
16
- * Returns a deduplicated array of helper names found.
17
- */
18
- export declare function collectStainlessHelpers(tools: BetaToolUnion[] | undefined, messages: BetaMessageParam[] | undefined): string[];
19
- /**
20
- * Builds x-stainless-helper header value from tools and messages.
21
- * Returns an empty object if no helpers are found.
22
- */
23
- export declare function stainlessHelperHeader(tools: BetaToolUnion[] | undefined, messages: BetaMessageParam[] | undefined): {
24
- 'x-stainless-helper'?: string;
25
- };
26
- /**
27
- * Builds x-stainless-helper header value from a file object.
28
- * Returns an empty object if the file is not marked with a helper.
29
- */
30
- export declare function stainlessHelperHeaderFromFile(file: unknown): {
31
- 'x-stainless-helper'?: string;
32
- };
33
- export {};
34
- //# sourceMappingURL=stainless-helper-header.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stainless-helper-header.d.ts","sourceRoot":"","sources":["../src/lib/stainless-helper-header.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,6BAA0B;AAEzE;;;GAGG;AACH,eAAO,MAAM,iBAAiB,eAA0C,CAAC;AAEzE,KAAK,qBAAqB,GAAG;IAAE,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB,CAE1F;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,aAAa,EAAE,GAAG,SAAS,EAClC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,SAAS,GACvC,MAAM,EAAE,CA8BV;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,aAAa,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G;AACH,MAAM,UAAU,6BAA6B,CAAC,IAAa;IACzD,IAAI,2BAA2B,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,OAAO,EAAE,oBAAoB,EAAE,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC;IAC3D,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -1,80 +0,0 @@
1
- /**
2
- * Shared utilities for tracking SDK helper usage.
3
- */
4
-
5
- import type { BetaMessageParam, BetaToolUnion } from '../resources/beta';
6
-
7
- /**
8
- * Symbol used to mark objects created by SDK helpers for tracking.
9
- * The value is the helper name (e.g., 'mcpTool', 'betaZodTool').
10
- */
11
- export const SDK_HELPER_SYMBOL = Symbol('anthropic.sdk.stainlessHelper');
12
-
13
- type StainlessHelperObject = { [SDK_HELPER_SYMBOL]: string };
14
-
15
- export function wasCreatedByStainlessHelper(value: unknown): value is StainlessHelperObject {
16
- return typeof value === 'object' && value !== null && SDK_HELPER_SYMBOL in value;
17
- }
18
-
19
- /**
20
- * Collects helper names from tools and messages arrays.
21
- * Returns a deduplicated array of helper names found.
22
- */
23
- export function collectStainlessHelpers(
24
- tools: BetaToolUnion[] | undefined,
25
- messages: BetaMessageParam[] | undefined,
26
- ): string[] {
27
- const helpers = new Set<string>();
28
-
29
- // Collect from tools
30
- if (tools) {
31
- for (const tool of tools) {
32
- if (wasCreatedByStainlessHelper(tool)) {
33
- helpers.add(tool[SDK_HELPER_SYMBOL]);
34
- }
35
- }
36
- }
37
-
38
- // Collect from messages and their content blocks
39
- if (messages) {
40
- for (const message of messages) {
41
- if (wasCreatedByStainlessHelper(message)) {
42
- helpers.add(message[SDK_HELPER_SYMBOL]);
43
- }
44
-
45
- if (Array.isArray(message.content)) {
46
- for (const block of message.content) {
47
- if (wasCreatedByStainlessHelper(block)) {
48
- helpers.add(block[SDK_HELPER_SYMBOL]);
49
- }
50
- }
51
- }
52
- }
53
- }
54
-
55
- return Array.from(helpers);
56
- }
57
-
58
- /**
59
- * Builds x-stainless-helper header value from tools and messages.
60
- * Returns an empty object if no helpers are found.
61
- */
62
- export function stainlessHelperHeader(
63
- tools: BetaToolUnion[] | undefined,
64
- messages: BetaMessageParam[] | undefined,
65
- ): { 'x-stainless-helper'?: string } {
66
- const helpers = collectStainlessHelpers(tools, messages);
67
- if (helpers.length === 0) return {};
68
- return { 'x-stainless-helper': helpers.join(', ') };
69
- }
70
-
71
- /**
72
- * Builds x-stainless-helper header value from a file object.
73
- * Returns an empty object if the file is not marked with a helper.
74
- */
75
- export function stainlessHelperHeaderFromFile(file: unknown): { 'x-stainless-helper'?: string } {
76
- if (wasCreatedByStainlessHelper(file)) {
77
- return { 'x-stainless-helper': file[SDK_HELPER_SYMBOL] };
78
- }
79
- return {};
80
- }