@anthropic-ai/sdk 0.98.1 → 0.100.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 (109) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/client.d.mts +2 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +2 -2
  5. package/client.d.ts.map +1 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs.map +1 -1
  8. package/lib/MessageStream.d.mts.map +1 -1
  9. package/lib/MessageStream.d.ts.map +1 -1
  10. package/lib/MessageStream.js +3 -0
  11. package/lib/MessageStream.js.map +1 -1
  12. package/lib/MessageStream.mjs +3 -0
  13. package/lib/MessageStream.mjs.map +1 -1
  14. package/lib/environments/worker.d.mts +3 -0
  15. package/lib/environments/worker.d.mts.map +1 -1
  16. package/lib/environments/worker.d.ts +3 -0
  17. package/lib/environments/worker.d.ts.map +1 -1
  18. package/lib/environments/worker.js +2 -0
  19. package/lib/environments/worker.js.map +1 -1
  20. package/lib/environments/worker.mjs +2 -0
  21. package/lib/environments/worker.mjs.map +1 -1
  22. package/package.json +1 -1
  23. package/resources/beta/agents/agents.d.mts +10 -7
  24. package/resources/beta/agents/agents.d.mts.map +1 -1
  25. package/resources/beta/agents/agents.d.ts +10 -7
  26. package/resources/beta/agents/agents.d.ts.map +1 -1
  27. package/resources/beta/agents/agents.js.map +1 -1
  28. package/resources/beta/agents/agents.mjs.map +1 -1
  29. package/resources/beta/beta.d.mts +2 -2
  30. package/resources/beta/beta.d.mts.map +1 -1
  31. package/resources/beta/beta.d.ts +2 -2
  32. package/resources/beta/beta.d.ts.map +1 -1
  33. package/resources/beta/beta.js.map +1 -1
  34. package/resources/beta/beta.mjs.map +1 -1
  35. package/resources/beta/index.d.mts +1 -1
  36. package/resources/beta/index.d.mts.map +1 -1
  37. package/resources/beta/index.d.ts +1 -1
  38. package/resources/beta/index.d.ts.map +1 -1
  39. package/resources/beta/index.js.map +1 -1
  40. package/resources/beta/index.mjs.map +1 -1
  41. package/resources/beta/messages/batches.d.mts +3 -2
  42. package/resources/beta/messages/batches.d.mts.map +1 -1
  43. package/resources/beta/messages/batches.d.ts +3 -2
  44. package/resources/beta/messages/batches.d.ts.map +1 -1
  45. package/resources/beta/messages/index.d.mts +1 -1
  46. package/resources/beta/messages/index.d.mts.map +1 -1
  47. package/resources/beta/messages/index.d.ts +1 -1
  48. package/resources/beta/messages/index.d.ts.map +1 -1
  49. package/resources/beta/messages/index.js.map +1 -1
  50. package/resources/beta/messages/index.mjs.map +1 -1
  51. package/resources/beta/messages/messages.d.mts +81 -14
  52. package/resources/beta/messages/messages.d.mts.map +1 -1
  53. package/resources/beta/messages/messages.d.ts +81 -14
  54. package/resources/beta/messages/messages.d.ts.map +1 -1
  55. package/resources/beta/messages/messages.js.map +1 -1
  56. package/resources/beta/messages/messages.mjs.map +1 -1
  57. package/resources/completions.d.mts +6 -4
  58. package/resources/completions.d.mts.map +1 -1
  59. package/resources/completions.d.ts +6 -4
  60. package/resources/completions.d.ts.map +1 -1
  61. package/resources/index.d.mts +1 -1
  62. package/resources/index.d.mts.map +1 -1
  63. package/resources/index.d.ts +1 -1
  64. package/resources/index.d.ts.map +1 -1
  65. package/resources/index.js.map +1 -1
  66. package/resources/index.mjs.map +1 -1
  67. package/resources/messages/index.d.mts +1 -1
  68. package/resources/messages/index.d.mts.map +1 -1
  69. package/resources/messages/index.d.ts +1 -1
  70. package/resources/messages/index.d.ts.map +1 -1
  71. package/resources/messages/index.js.map +1 -1
  72. package/resources/messages/index.mjs.map +1 -1
  73. package/resources/messages/messages.d.mts +66 -13
  74. package/resources/messages/messages.d.mts.map +1 -1
  75. package/resources/messages/messages.d.ts +66 -13
  76. package/resources/messages/messages.d.ts.map +1 -1
  77. package/resources/messages/messages.js.map +1 -1
  78. package/resources/messages/messages.mjs.map +1 -1
  79. package/src/client.ts +4 -0
  80. package/src/lib/MessageStream.ts +3 -0
  81. package/src/lib/environments/worker.ts +5 -0
  82. package/src/resources/beta/agents/agents.ts +10 -6
  83. package/src/resources/beta/beta.ts +4 -0
  84. package/src/resources/beta/index.ts +2 -0
  85. package/src/resources/beta/messages/batches.ts +3 -2
  86. package/src/resources/beta/messages/index.ts +2 -0
  87. package/src/resources/beta/messages/messages.ts +93 -12
  88. package/src/resources/completions.ts +6 -4
  89. package/src/resources/index.ts +2 -0
  90. package/src/resources/messages/index.ts +2 -0
  91. package/src/resources/messages/messages.ts +73 -10
  92. package/src/tools/agent-toolset/node.ts +23 -10
  93. package/src/version.ts +1 -1
  94. package/tools/agent-toolset/node.d.mts +9 -0
  95. package/tools/agent-toolset/node.d.mts.map +1 -1
  96. package/tools/agent-toolset/node.d.ts +9 -0
  97. package/tools/agent-toolset/node.d.ts.map +1 -1
  98. package/tools/agent-toolset/node.js +13 -10
  99. package/tools/agent-toolset/node.js.map +1 -1
  100. package/tools/agent-toolset/node.mjs +13 -10
  101. package/tools/agent-toolset/node.mjs.map +1 -1
  102. package/version.d.mts +1 -1
  103. package/version.d.mts.map +1 -1
  104. package/version.d.ts +1 -1
  105. package/version.d.ts.map +1 -1
  106. package/version.js +1 -1
  107. package/version.js.map +1 -1
  108. package/version.mjs +1 -1
  109. package/version.mjs.map +1 -1
@@ -576,6 +576,9 @@ export class MessageStream<ParsedT = null> implements AsyncIterable<MessageStrea
576
576
  case 'message_delta':
577
577
  snapshot.stop_reason = event.delta.stop_reason;
578
578
  snapshot.stop_sequence = event.delta.stop_sequence;
579
+ if (event.delta.stop_details != null) {
580
+ snapshot.stop_details = event.delta.stop_details;
581
+ }
579
582
  snapshot.usage.output_tokens = event.usage.output_tokens;
580
583
 
581
584
  // Update other usage fields if they exist in the event
@@ -57,6 +57,8 @@ export interface EnvironmentWorkerOptions {
57
57
  workdir?: string;
58
58
  /** Forwarded to the per-session {@link AgentToolContext}. */
59
59
  unrestrictedPaths?: boolean;
60
+ /** Forwarded to the per-session {@link AgentToolContext} (`maxFileBytes`). */
61
+ maxFileBytes?: number | null;
60
62
  /** Forwarded to {@link SessionToolRunner} (`maxIdleMs`). */
61
63
  maxIdleMs?: number;
62
64
  /** Forwarded to the {@link WorkPoller}. */
@@ -138,6 +140,7 @@ export class EnvironmentWorker {
138
140
  readonly tools: EnvironmentWorkerTools | undefined;
139
141
  readonly workdir: string;
140
142
  readonly unrestrictedPaths: boolean | undefined;
143
+ readonly maxFileBytes: number | null | undefined;
141
144
  readonly maxIdleMs: number | undefined;
142
145
  readonly workerId: string | undefined;
143
146
  readonly requestOptions: BetaToolRunnerRequestOptions | undefined;
@@ -150,6 +153,7 @@ export class EnvironmentWorker {
150
153
  this.tools = opts.tools;
151
154
  this.workdir = opts.workdir ?? process.cwd();
152
155
  this.unrestrictedPaths = opts.unrestrictedPaths;
156
+ this.maxFileBytes = opts.maxFileBytes;
153
157
  this.maxIdleMs = opts.maxIdleMs;
154
158
  this.workerId = opts.workerId;
155
159
  this.requestOptions = opts.requestOptions;
@@ -268,6 +272,7 @@ export class EnvironmentWorker {
268
272
  client: this.client,
269
273
  sessionId,
270
274
  ...(this.unrestrictedPaths !== undefined ? { unrestrictedPaths: this.unrestrictedPaths } : {}),
275
+ ...(this.maxFileBytes !== undefined ? { maxFileBytes: this.maxFileBytes } : {}),
271
276
  };
272
277
  // Lazily load the Node-only toolset module — see the import note at the top.
273
278
  const agentToolset = await import('../../tools/agent-toolset/node');
@@ -671,11 +671,13 @@ export interface BetaManagedAgentsMCPToolsetParams {
671
671
  }
672
672
 
673
673
  /**
674
- * The model that will power your agent.\n\nSee
675
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
674
+ * The model that will power your agent.
675
+ *
676
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
676
677
  * details and options.
677
678
  */
678
679
  export type BetaManagedAgentsModel =
680
+ | 'claude-opus-4-8'
679
681
  | 'claude-opus-4-7'
680
682
  | 'claude-opus-4-6'
681
683
  | 'claude-sonnet-4-6'
@@ -692,8 +694,9 @@ export type BetaManagedAgentsModel =
692
694
  */
693
695
  export interface BetaManagedAgentsModelConfig {
694
696
  /**
695
- * The model that will power your agent.\n\nSee
696
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
697
+ * The model that will power your agent.
698
+ *
699
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
697
700
  * details and options.
698
701
  */
699
702
  id: BetaManagedAgentsModel;
@@ -711,8 +714,9 @@ export interface BetaManagedAgentsModelConfig {
711
714
  */
712
715
  export interface BetaManagedAgentsModelConfigParams {
713
716
  /**
714
- * The model that will power your agent.\n\nSee
715
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
717
+ * The model that will power your agent.
718
+ *
719
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
716
720
  * details and options.
717
721
  */
718
722
  id: BetaManagedAgentsModel;
@@ -264,7 +264,9 @@ import {
264
264
  BetaMessageParam,
265
265
  BetaMessageTokensCount,
266
266
  BetaMetadata,
267
+ BetaMidConversationSystemBlockParam,
267
268
  BetaOutputConfig,
269
+ BetaOutputTokensDetails,
268
270
  BetaPlainTextSource,
269
271
  BetaRawContentBlockDelta,
270
272
  BetaRawContentBlockDeltaEvent,
@@ -698,7 +700,9 @@ export declare namespace Beta {
698
700
  type BetaMessageParam as BetaMessageParam,
699
701
  type BetaMessageTokensCount as BetaMessageTokensCount,
700
702
  type BetaMetadata as BetaMetadata,
703
+ type BetaMidConversationSystemBlockParam as BetaMidConversationSystemBlockParam,
701
704
  type BetaOutputConfig as BetaOutputConfig,
705
+ type BetaOutputTokensDetails as BetaOutputTokensDetails,
702
706
  type BetaPlainTextSource as BetaPlainTextSource,
703
707
  type BetaRawContentBlockDelta as BetaRawContentBlockDelta,
704
708
  type BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent,
@@ -220,7 +220,9 @@ export {
220
220
  type BetaMessageParam,
221
221
  type BetaMessageTokensCount,
222
222
  type BetaMetadata,
223
+ type BetaMidConversationSystemBlockParam,
223
224
  type BetaOutputConfig,
225
+ type BetaOutputTokensDetails,
224
226
  type BetaPlainTextSource,
225
227
  type BetaRawContentBlockDelta,
226
228
  type BetaRawContentBlockDeltaEvent,
@@ -538,8 +538,9 @@ export namespace BatchCreateParams {
538
538
  messages: Array<BetaMessagesAPI.BetaMessageParam>;
539
539
 
540
540
  /**
541
- * The model that will complete your prompt.\n\nSee
542
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
541
+ * The model that will complete your prompt.
542
+ *
543
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
543
544
  * details and options.
544
545
  */
545
546
  model: MessagesApi.Model;
@@ -129,7 +129,9 @@ export {
129
129
  type BetaMessageParam,
130
130
  type BetaMessageTokensCount,
131
131
  type BetaMetadata,
132
+ type BetaMidConversationSystemBlockParam,
132
133
  type BetaOutputConfig,
134
+ type BetaOutputTokensDetails,
133
135
  type BetaPlainTextSource,
134
136
  type BetaRawContentBlockDelta,
135
137
  type BetaRawContentBlockDeltaEvent,
@@ -289,8 +289,9 @@ export interface BetaAdvisorMessageIterationUsage {
289
289
  input_tokens: number;
290
290
 
291
291
  /**
292
- * The model that will complete your prompt.\n\nSee
293
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
292
+ * The model that will complete your prompt.
293
+ *
294
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
294
295
  * details and options.
295
296
  */
296
297
  model: MessagesAPI.Model;
@@ -313,6 +314,12 @@ export interface BetaAdvisorRedactedResultBlock {
313
314
  */
314
315
  encrypted_content: string;
315
316
 
317
+ /**
318
+ * The advisor sub-inference's stop reason (same values as the top-level message
319
+ * `stop_reason`).
320
+ */
321
+ stop_reason: string | null;
322
+
316
323
  type: 'advisor_redacted_result';
317
324
  }
318
325
 
@@ -323,9 +330,18 @@ export interface BetaAdvisorRedactedResultBlockParam {
323
330
  encrypted_content: string;
324
331
 
325
332
  type: 'advisor_redacted_result';
333
+
334
+ stop_reason?: string | null;
326
335
  }
327
336
 
328
337
  export interface BetaAdvisorResultBlock {
338
+ /**
339
+ * The advisor sub-inference's stop reason (same values as the top-level message
340
+ * `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the
341
+ * tool's `max_tokens` value or the advisor model's policy cap.
342
+ */
343
+ stop_reason: string | null;
344
+
329
345
  text: string;
330
346
 
331
347
  type: 'advisor_result';
@@ -335,12 +351,15 @@ export interface BetaAdvisorResultBlockParam {
335
351
  text: string;
336
352
 
337
353
  type: 'advisor_result';
354
+
355
+ stop_reason?: string | null;
338
356
  }
339
357
 
340
358
  export interface BetaAdvisorTool20260301 {
341
359
  /**
342
- * The model that will complete your prompt.\n\nSee
343
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
360
+ * The model that will complete your prompt.
361
+ *
362
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
344
363
  * details and options.
345
364
  */
346
365
  model: MessagesAPI.Model;
@@ -1347,7 +1366,8 @@ export type BetaContentBlockParam =
1347
1366
  | BetaMCPToolUseBlockParam
1348
1367
  | BetaRequestMCPToolResultBlockParam
1349
1368
  | BetaContainerUploadBlockParam
1350
- | BetaCompactionBlockParam;
1369
+ | BetaCompactionBlockParam
1370
+ | BetaMidConversationSystemBlockParam;
1351
1371
 
1352
1372
  export interface BetaContentBlockSource {
1353
1373
  content: string | Array<BetaContentBlockSourceContent>;
@@ -1837,8 +1857,9 @@ export interface BetaMessage {
1837
1857
  diagnostics: BetaDiagnostics | null;
1838
1858
 
1839
1859
  /**
1840
- * The model that will complete your prompt.\n\nSee
1841
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
1860
+ * The model that will complete your prompt.
1861
+ *
1862
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
1842
1863
  * details and options.
1843
1864
  */
1844
1865
  model: MessagesAPI.Model;
@@ -1942,6 +1963,16 @@ export interface BetaMessageDeltaUsage {
1942
1963
  */
1943
1964
  output_tokens: number;
1944
1965
 
1966
+ /**
1967
+ * Breakdown of output tokens by category.
1968
+ *
1969
+ * `output_tokens` remains the inclusive, authoritative total used for billing.
1970
+ * This object provides a read-only decomposition for observability — for example,
1971
+ * how many of the billed output tokens were spent on internal reasoning that may
1972
+ * have been summarized before being returned to you.
1973
+ */
1974
+ output_tokens_details: BetaOutputTokensDetails | null;
1975
+
1945
1976
  /**
1946
1977
  * The number of server tool requests.
1947
1978
  */
@@ -1986,7 +2017,7 @@ export interface BetaMessageIterationUsage {
1986
2017
  export interface BetaMessageParam {
1987
2018
  content: string | Array<BetaContentBlockParam>;
1988
2019
 
1989
- role: 'user' | 'assistant';
2020
+ role: 'user' | 'assistant' | 'system';
1990
2021
  }
1991
2022
 
1992
2023
  export interface BetaMessageTokensCount {
@@ -2013,6 +2044,27 @@ export interface BetaMetadata {
2013
2044
  user_id?: string | null;
2014
2045
  }
2015
2046
 
2047
+ /**
2048
+ * System instructions that appear mid-conversation.
2049
+ *
2050
+ * Use this block to provide or update system-level instructions at a specific
2051
+ * point in the conversation, rather than only via the top-level `system`
2052
+ * parameter.
2053
+ */
2054
+ export interface BetaMidConversationSystemBlockParam {
2055
+ /**
2056
+ * System instruction text blocks.
2057
+ */
2058
+ content: Array<BetaTextBlockParam>;
2059
+
2060
+ type: 'mid_conv_system';
2061
+
2062
+ /**
2063
+ * Create a cache control breakpoint at this content block.
2064
+ */
2065
+ cache_control?: BetaCacheControlEphemeral | null;
2066
+ }
2067
+
2016
2068
  export interface BetaOutputConfig {
2017
2069
  /**
2018
2070
  * All possible effort levels.
@@ -2031,6 +2083,20 @@ export interface BetaOutputConfig {
2031
2083
  task_budget?: BetaTokenTaskBudget | null;
2032
2084
  }
2033
2085
 
2086
+ export interface BetaOutputTokensDetails {
2087
+ /**
2088
+ * Number of output tokens the model generated as internal reasoning, including the
2089
+ * thinking-block delimiter tokens.
2090
+ *
2091
+ * Reflects the raw reasoning the model produced, not the (possibly shorter)
2092
+ * summarized thinking text returned in the response body. Computed by
2093
+ * re-tokenizing the raw reasoning text, so it may differ from the model's exact
2094
+ * generation count by a small number of tokens. Always ≤ `output_tokens`;
2095
+ * `output_tokens - thinking_tokens` approximates the non-reasoning output.
2096
+ */
2097
+ thinking_tokens: number;
2098
+ }
2099
+
2034
2100
  export interface BetaPlainTextSource {
2035
2101
  data: string;
2036
2102
 
@@ -3439,6 +3505,16 @@ export interface BetaUsage {
3439
3505
  */
3440
3506
  output_tokens: number;
3441
3507
 
3508
+ /**
3509
+ * Breakdown of output tokens by category.
3510
+ *
3511
+ * `output_tokens` remains the inclusive, authoritative total used for billing.
3512
+ * This object provides a read-only decomposition for observability — for example,
3513
+ * how many of the billed output tokens were spent on internal reasoning that may
3514
+ * have been summarized before being returned to you.
3515
+ */
3516
+ output_tokens_details: BetaOutputTokensDetails | null;
3517
+
3442
3518
  /**
3443
3519
  * The number of server tool requests.
3444
3520
  */
@@ -3738,6 +3814,7 @@ export type BetaWebFetchToolResultErrorCode =
3738
3814
  | 'invalid_tool_input'
3739
3815
  | 'url_too_long'
3740
3816
  | 'url_not_allowed'
3817
+ | 'url_not_in_prior_context'
3741
3818
  | 'url_not_accessible'
3742
3819
  | 'unsupported_content_type'
3743
3820
  | 'too_many_requests'
@@ -4024,8 +4101,9 @@ export interface MessageCreateParamsBase {
4024
4101
  messages: Array<BetaMessageParam>;
4025
4102
 
4026
4103
  /**
4027
- * Body param: The model that will complete your prompt.\n\nSee
4028
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
4104
+ * Body param: The model that will complete your prompt.
4105
+ *
4106
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
4029
4107
  * details and options.
4030
4108
  */
4031
4109
  model: MessagesAPI.Model;
@@ -4357,8 +4435,9 @@ export interface MessageCountTokensParams {
4357
4435
  messages: Array<BetaMessageParam>;
4358
4436
 
4359
4437
  /**
4360
- * Body param: The model that will complete your prompt.\n\nSee
4361
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
4438
+ * Body param: The model that will complete your prompt.
4439
+ *
4440
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
4362
4441
  * details and options.
4363
4442
  */
4364
4443
  model: MessagesAPI.Model;
@@ -4660,7 +4739,9 @@ export declare namespace Messages {
4660
4739
  type BetaMessageParam as BetaMessageParam,
4661
4740
  type BetaMessageTokensCount as BetaMessageTokensCount,
4662
4741
  type BetaMetadata as BetaMetadata,
4742
+ type BetaMidConversationSystemBlockParam as BetaMidConversationSystemBlockParam,
4663
4743
  type BetaOutputConfig as BetaOutputConfig,
4744
+ type BetaOutputTokensDetails as BetaOutputTokensDetails,
4664
4745
  type BetaPlainTextSource as BetaPlainTextSource,
4665
4746
  type BetaRawContentBlockDelta as BetaRawContentBlockDelta,
4666
4747
  type BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent,
@@ -67,8 +67,9 @@ export interface Completion {
67
67
  completion: string;
68
68
 
69
69
  /**
70
- * The model that will complete your prompt.\n\nSee
71
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
70
+ * The model that will complete your prompt.
71
+ *
72
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
72
73
  * details and options.
73
74
  */
74
75
  model: MessagesAPI.Model;
@@ -104,8 +105,9 @@ export interface CompletionCreateParamsBase {
104
105
  max_tokens_to_sample: number;
105
106
 
106
107
  /**
107
- * Body param: The model that will complete your prompt.\n\nSee
108
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
108
+ * Body param: The model that will complete your prompt.
109
+ *
110
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
109
111
  * details and options.
110
112
  */
111
113
  model: MessagesAPI.Model;
@@ -91,8 +91,10 @@ export {
91
91
  type MessageStreamParams,
92
92
  type MessageTokensCount,
93
93
  type Metadata,
94
+ type MidConversationSystemBlockParam,
94
95
  type Model,
95
96
  type OutputConfig,
97
+ type OutputTokensDetails,
96
98
  type PlainTextSource,
97
99
  type RawContentBlockDelta,
98
100
  type RawContentBlockDeltaEvent,
@@ -82,8 +82,10 @@ export {
82
82
  type MessageParam,
83
83
  type MessageTokensCount,
84
84
  type Metadata,
85
+ type MidConversationSystemBlockParam,
85
86
  type Model,
86
87
  type OutputConfig,
88
+ type OutputTokensDetails,
87
89
  type PlainTextSource,
88
90
  type RawContentBlockDelta,
89
91
  type RawContentBlockDeltaEvent,
@@ -823,7 +823,8 @@ export type ContentBlockParam =
823
823
  | BashCodeExecutionToolResultBlockParam
824
824
  | TextEditorCodeExecutionToolResultBlockParam
825
825
  | ToolSearchToolResultBlockParam
826
- | ContainerUploadBlockParam;
826
+ | ContainerUploadBlockParam
827
+ | MidConversationSystemBlockParam;
827
828
 
828
829
  export interface ContentBlockSource {
829
830
  content: string | Array<ContentBlockSourceContent>;
@@ -1011,8 +1012,9 @@ export interface Message {
1011
1012
  content: Array<ContentBlock>;
1012
1013
 
1013
1014
  /**
1014
- * The model that will complete your prompt.\n\nSee
1015
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
1015
+ * The model that will complete your prompt.
1016
+ *
1017
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
1016
1018
  * details and options.
1017
1019
  */
1018
1020
  model: Model;
@@ -1126,6 +1128,16 @@ export interface MessageDeltaUsage {
1126
1128
  */
1127
1129
  output_tokens: number;
1128
1130
 
1131
+ /**
1132
+ * Breakdown of output tokens by category.
1133
+ *
1134
+ * `output_tokens` remains the inclusive, authoritative total used for billing.
1135
+ * This object provides a read-only decomposition for observability — for example,
1136
+ * how many of the billed output tokens were spent on internal reasoning that may
1137
+ * have been summarized before being returned to you.
1138
+ */
1139
+ output_tokens_details: OutputTokensDetails | null;
1140
+
1129
1141
  /**
1130
1142
  * The number of server tool requests.
1131
1143
  */
@@ -1135,7 +1147,7 @@ export interface MessageDeltaUsage {
1135
1147
  export interface MessageParam {
1136
1148
  content: string | Array<ContentBlockParam>;
1137
1149
 
1138
- role: 'user' | 'assistant';
1150
+ role: 'user' | 'assistant' | 'system';
1139
1151
  }
1140
1152
 
1141
1153
  export interface MessageTokensCount {
@@ -1158,11 +1170,34 @@ export interface Metadata {
1158
1170
  }
1159
1171
 
1160
1172
  /**
1161
- * The model that will complete your prompt.\n\nSee
1162
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
1173
+ * System instructions that appear mid-conversation.
1174
+ *
1175
+ * Use this block to provide or update system-level instructions at a specific
1176
+ * point in the conversation, rather than only via the top-level `system`
1177
+ * parameter.
1178
+ */
1179
+ export interface MidConversationSystemBlockParam {
1180
+ /**
1181
+ * System instruction text blocks.
1182
+ */
1183
+ content: Array<TextBlockParam>;
1184
+
1185
+ type: 'mid_conv_system';
1186
+
1187
+ /**
1188
+ * Create a cache control breakpoint at this content block.
1189
+ */
1190
+ cache_control?: CacheControlEphemeral | null;
1191
+ }
1192
+
1193
+ /**
1194
+ * The model that will complete your prompt.
1195
+ *
1196
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
1163
1197
  * details and options.
1164
1198
  */
1165
1199
  export type Model =
1200
+ | 'claude-opus-4-8'
1166
1201
  | 'claude-opus-4-7'
1167
1202
  | 'claude-mythos-preview'
1168
1203
  | 'claude-opus-4-6'
@@ -1195,6 +1230,19 @@ export interface OutputConfig {
1195
1230
  format?: JSONOutputFormat | null;
1196
1231
  }
1197
1232
 
1233
+ export interface OutputTokensDetails {
1234
+ /**
1235
+ * Number of output tokens the model generated as internal reasoning, including the
1236
+ * thinking-block delimiter tokens.
1237
+ *
1238
+ * Reflects the raw reasoning the model produced, not the (possibly shorter)
1239
+ * summarized thinking text returned in the response body. Computed by
1240
+ * re-tokenizing the raw reasoning text, so it may differ from the model's exact
1241
+ * generation count by a small number of tokens. Always ≤ `output_tokens`;
1242
+ * `output_tokens - thinking_tokens` approximates the non-reasoning output.
1243
+ */
1244
+ thinking_tokens: number;
1245
+ }
1198
1246
  const DEPRECATED_MODELS: {
1199
1247
  [K in Model]?: string;
1200
1248
  } = {
@@ -2235,6 +2283,16 @@ export interface Usage {
2235
2283
  */
2236
2284
  output_tokens: number;
2237
2285
 
2286
+ /**
2287
+ * Breakdown of output tokens by category.
2288
+ *
2289
+ * `output_tokens` remains the inclusive, authoritative total used for billing.
2290
+ * This object provides a read-only decomposition for observability — for example,
2291
+ * how many of the billed output tokens were spent on internal reasoning that may
2292
+ * have been summarized before being returned to you.
2293
+ */
2294
+ output_tokens_details: OutputTokensDetails | null;
2295
+
2238
2296
  /**
2239
2297
  * The number of server tool requests.
2240
2298
  */
@@ -2529,6 +2587,7 @@ export type WebFetchToolResultErrorCode =
2529
2587
  | 'invalid_tool_input'
2530
2588
  | 'url_too_long'
2531
2589
  | 'url_not_allowed'
2590
+ | 'url_not_in_prior_context'
2532
2591
  | 'url_not_accessible'
2533
2592
  | 'unsupported_content_type'
2534
2593
  | 'too_many_requests'
@@ -2840,8 +2899,9 @@ export interface MessageCreateParamsBase {
2840
2899
  messages: Array<MessageParam>;
2841
2900
 
2842
2901
  /**
2843
- * The model that will complete your prompt.\n\nSee
2844
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
2902
+ * The model that will complete your prompt.
2903
+ *
2904
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
2845
2905
  * details and options.
2846
2906
  */
2847
2907
  model: Model;
@@ -3126,8 +3186,9 @@ export interface MessageCountTokensParams {
3126
3186
  messages: Array<MessageParam>;
3127
3187
 
3128
3188
  /**
3129
- * The model that will complete your prompt.\n\nSee
3130
- * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
3189
+ * The model that will complete your prompt.
3190
+ *
3191
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
3131
3192
  * details and options.
3132
3193
  */
3133
3194
  model: Model;
@@ -3320,8 +3381,10 @@ export declare namespace Messages {
3320
3381
  type MessageParam as MessageParam,
3321
3382
  type MessageTokensCount as MessageTokensCount,
3322
3383
  type Metadata as Metadata,
3384
+ type MidConversationSystemBlockParam as MidConversationSystemBlockParam,
3323
3385
  type Model as Model,
3324
3386
  type OutputConfig as OutputConfig,
3387
+ type OutputTokensDetails as OutputTokensDetails,
3325
3388
  type PlainTextSource as PlainTextSource,
3326
3389
  type RawContentBlockDelta as RawContentBlockDelta,
3327
3390
  type RawContentBlockDeltaEvent as RawContentBlockDeltaEvent,
@@ -47,12 +47,10 @@ export { setupSkills, resolveSkillVersion, extractSkillArchive } from './skills'
47
47
 
48
48
  const BASH_OUTPUT_LIMIT = 100 * 1024;
49
49
  const BASH_DEFAULT_TIMEOUT_MS = 120_000;
50
- const READ_MAX_BYTES = 256 * 1024;
51
- // `edit` reads the whole file before rewriting it, so it carries the same
52
- // OOM/FIFO exposure as `read`. Kept as a symmetric alias for now; the cap value
53
- // (and reject-vs-truncate behaviour) is intentionally a separate knob pending
54
- // validation with the CMA team.
55
- const EDIT_MAX_BYTES = READ_MAX_BYTES;
50
+ // Default size cap for the read/edit tools (both load the whole file into
51
+ // memory) when AgentToolContext.maxFileBytes is unset. The reject-vs-truncate
52
+ // behaviour remains a separate question pending CMA validation.
53
+ const DEFAULT_MAX_FILE_BYTES = 256 * 1024;
56
54
  const GREP_OUTPUT_LIMIT = 100 * 1024;
57
55
  const GREP_MAX_LINE_LENGTH = 2000;
58
56
  const GLOB_RESULT_LIMIT = 200;
@@ -72,6 +70,10 @@ type GlobFn = (
72
70
  ) => AsyncIterable<fssync.Dirent>;
73
71
  const fsGlob = (fs as unknown as { glob: GlobFn }).glob;
74
72
 
73
+ function resolveMaxBytes(configured: number | null | undefined): number | null {
74
+ return configured === undefined ? DEFAULT_MAX_FILE_BYTES : configured;
75
+ }
76
+
75
77
  /**
76
78
  * Workdir + path-policy for the agent toolset.
77
79
  *
@@ -116,6 +118,15 @@ export interface AgentToolContext {
116
118
  * build the combined mapping yourself before passing it.
117
119
  */
118
120
  env?: NodeJS.ProcessEnv;
121
+ /**
122
+ * Size cap for the `read` and `edit` tools, which both load the whole file into
123
+ * memory. `undefined` (default) uses the built-in 256 KiB cap; a positive number
124
+ * sets a custom cap; `null` disables the cap entirely. Disabling it reintroduces
125
+ * the OOM risk on a model-controlled path, so pass `null` only when the sandbox
126
+ * can absorb arbitrarily large files. The non-regular-file (FIFO/device) guard
127
+ * always applies regardless of this value.
128
+ */
129
+ maxFileBytes?: number | null;
119
130
  }
120
131
 
121
132
  /**
@@ -435,9 +446,10 @@ export function betaReadTool(ctx: AgentToolContext): BetaRunnableTool {
435
446
  if (!st.isFile()) {
436
447
  throw new ToolError(`read: ${file_path} is not a regular file`);
437
448
  }
438
- if (st.size > READ_MAX_BYTES) {
449
+ const limit = resolveMaxBytes(ctx.maxFileBytes);
450
+ if (limit !== null && st.size > limit) {
439
451
  throw new ToolError(
440
- `read: ${file_path} is ${st.size} bytes, exceeds ${READ_MAX_BYTES}-byte limit. ` +
452
+ `read: ${file_path} is ${st.size} bytes, exceeds ${limit}-byte limit. ` +
441
453
  'Use bash (head/tail/sed) to read a slice.',
442
454
  );
443
455
  }
@@ -510,9 +522,10 @@ export function betaEditTool(ctx: AgentToolContext): BetaRunnableTool {
510
522
  if (!st.isFile()) {
511
523
  throw new ToolError(`edit: ${file_path} is not a regular file`);
512
524
  }
513
- if (st.size > EDIT_MAX_BYTES) {
525
+ const limit = resolveMaxBytes(ctx.maxFileBytes);
526
+ if (limit !== null && st.size > limit) {
514
527
  throw new ToolError(
515
- `edit: ${file_path} is ${st.size} bytes, exceeds ${EDIT_MAX_BYTES}-byte limit. ` +
528
+ `edit: ${file_path} is ${st.size} bytes, exceeds ${limit}-byte limit. ` +
516
529
  'Use bash (sed/awk) to edit a large file.',
517
530
  );
518
531
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.98.1'; // x-release-please-version
1
+ export const VERSION = '0.100.0'; // x-release-please-version
@@ -75,6 +75,15 @@ export interface AgentToolContext {
75
75
  * build the combined mapping yourself before passing it.
76
76
  */
77
77
  env?: NodeJS.ProcessEnv;
78
+ /**
79
+ * Size cap for the `read` and `edit` tools, which both load the whole file into
80
+ * memory. `undefined` (default) uses the built-in 256 KiB cap; a positive number
81
+ * sets a custom cap; `null` disables the cap entirely. Disabling it reintroduces
82
+ * the OOM risk on a model-controlled path, so pass `null` only when the sandbox
83
+ * can absorb arbitrarily large files. The non-regular-file (FIFO/device) guard
84
+ * always applies regardless of this value.
85
+ */
86
+ maxFileBytes?: number | null;
78
87
  }
79
88
  /**
80
89
  * Returns the `agent_toolset_20260401` implementations bound to `ctx`. The
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.mts","sourceRoot":"","sources":["../../src/tools/agent-toolset/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAQH,OAAO,KAAK,EAAE,SAAS,EAAE,yBAAqB;AAE9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,6CAAyC;AAMzE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,qBAAiB;AA6BjF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;OAOG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CASlF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,gBAAgB,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE7E;AA0BD;;;GAGG;AACH,qBAAa,WAAW;;gBASV,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAA+B;IAyBpE,uDAAuD;IACvD,IAAI,MAAM,IAAI,OAAO,CAEpB;IAkBK,IAAI,CACR,OAAO,EAAE,MAAM,EACf,IAAI,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