@opencode-ai/ai 0.0.0-next-16051 → 0.0.0-next-16058

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.
@@ -339,22 +339,19 @@ const mapFinishReason = (reason) => {
339
339
  return "content-filter";
340
340
  return "unknown";
341
341
  };
342
- // AWS Bedrock Converse reports `inputTokens` (inclusive total) with
343
- // `cacheReadInputTokens` and `cacheWriteInputTokens` as subsets. Pass
344
- // the total through and derive the non-cached breakdown. Bedrock does
345
- // not break reasoning out of `outputTokens` for any current model.
342
+ // AWS reports inputTokens separately from cache reads and writes.
343
+ // Bedrock does not break reasoning out of outputTokens for current models.
346
344
  const mapUsage = (usage) => {
347
345
  if (!usage)
348
346
  return undefined;
349
- const cacheTotal = (usage.cacheReadInputTokens ?? 0) + (usage.cacheWriteInputTokens ?? 0);
350
- const nonCached = ProviderShared.subtractTokens(usage.inputTokens, cacheTotal);
347
+ const inputTokens = ProviderShared.sumTokens(usage.inputTokens, usage.cacheReadInputTokens, usage.cacheWriteInputTokens);
351
348
  return new Usage({
352
- inputTokens: usage.inputTokens,
349
+ inputTokens,
353
350
  outputTokens: usage.outputTokens,
354
- nonCachedInputTokens: nonCached,
351
+ nonCachedInputTokens: usage.inputTokens,
355
352
  cacheReadInputTokens: usage.cacheReadInputTokens,
356
353
  cacheWriteInputTokens: usage.cacheWriteInputTokens,
357
- totalTokens: ProviderShared.totalTokens(usage.inputTokens, usage.outputTokens, usage.totalTokens),
354
+ totalTokens: ProviderShared.totalTokens(inputTokens, usage.outputTokens, usage.totalTokens),
358
355
  providerMetadata: { bedrock: usage },
359
356
  });
360
357
  };
@@ -41,11 +41,12 @@ declare const Usage_base: Schema.Class<Usage, Schema.Struct<{
41
41
  *
42
42
  * **Semantics by provider**:
43
43
  *
44
- * - OpenAI Chat / Responses / Gemini / Bedrock: provider reports inclusive
44
+ * - OpenAI Chat / Responses / Gemini: provider reports inclusive
45
45
  * `inputTokens` and an inclusive `outputTokens`; mapper subtracts to
46
46
  * derive the breakdown.
47
- * - Anthropic: provider reports the breakdown natively (`input_tokens` is
48
- * non-cached only); mapper sums to derive the inclusive `inputTokens`.
47
+ * - Anthropic and Bedrock report the input breakdown natively: Anthropic's
48
+ * `input_tokens` and Bedrock's `inputTokens` are non-cached only. Their
49
+ * mappers sum the breakdown to derive the inclusive `inputTokens`.
49
50
  * Anthropic does *not* break extended-thinking out of `output_tokens`, so
50
51
  * `reasoningTokens` is `undefined` and `outputTokens` carries the
51
52
  * combined total — a documented limitation of the Anthropic API.
@@ -33,11 +33,12 @@ import { ProviderFailureClassification } from "./errors";
33
33
  *
34
34
  * **Semantics by provider**:
35
35
  *
36
- * - OpenAI Chat / Responses / Gemini / Bedrock: provider reports inclusive
36
+ * - OpenAI Chat / Responses / Gemini: provider reports inclusive
37
37
  * `inputTokens` and an inclusive `outputTokens`; mapper subtracts to
38
38
  * derive the breakdown.
39
- * - Anthropic: provider reports the breakdown natively (`input_tokens` is
40
- * non-cached only); mapper sums to derive the inclusive `inputTokens`.
39
+ * - Anthropic and Bedrock report the input breakdown natively: Anthropic's
40
+ * `input_tokens` and Bedrock's `inputTokens` are non-cached only. Their
41
+ * mappers sum the breakdown to derive the inclusive `inputTokens`.
41
42
  * Anthropic does *not* break extended-thinking out of `output_tokens`, so
42
43
  * `reasoningTokens` is `undefined` and `outputTokens` carries the
43
44
  * combined total — a documented limitation of the Anthropic API.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-next-16051",
3
+ "version": "0.0.0-next-16058",
4
4
  "name": "@opencode-ai/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "devDependencies": {
27
27
  "@clack/prompts": "1.0.0-alpha.1",
28
28
  "@effect/platform-node": "4.0.0-beta.98",
29
- "@opencode-ai/http-recorder": "0.0.0-next-16051",
29
+ "@opencode-ai/http-recorder": "0.0.0-next-16058",
30
30
  "@tsconfig/bun": "1.0.9",
31
31
  "@types/bun": "1.3.13",
32
32
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -35,7 +35,7 @@
35
35
  "dependencies": {
36
36
  "@smithy/eventstream-codec": "4.2.14",
37
37
  "@smithy/util-utf8": "4.2.2",
38
- "@opencode-ai/schema": "0.0.0-next-16051",
38
+ "@opencode-ai/schema": "0.0.0-next-16058",
39
39
  "aws4fetch": "1.0.20",
40
40
  "effect": "4.0.0-beta.98",
41
41
  "google-auth-library": "10.5.0"