🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@opencode-ai/ai

Package Overview
Dependencies
Maintainers
2
Versions
213
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opencode-ai/ai - npm Package Compare versions

Comparing version
0.0.0-next-16048
to
0.0.0-next-16052
+6
-9
dist/protocols/bedrock-converse.js

@@ -342,18 +342,15 @@ import { Effect, Schema } from "effect";

};
// AWS Bedrock Converse reports `inputTokens` (inclusive total) with
// `cacheReadInputTokens` and `cacheWriteInputTokens` as subsets. Pass
// the total through and derive the non-cached breakdown. Bedrock does
// not break reasoning out of `outputTokens` for any current model.
// AWS reports inputTokens separately from cache reads and writes.
// Bedrock does not break reasoning out of outputTokens for current models.
const mapUsage = (usage) => {
if (!usage)
return undefined;
const cacheTotal = (usage.cacheReadInputTokens ?? 0) + (usage.cacheWriteInputTokens ?? 0);
const nonCached = ProviderShared.subtractTokens(usage.inputTokens, cacheTotal);
const inputTokens = ProviderShared.sumTokens(usage.inputTokens, usage.cacheReadInputTokens, usage.cacheWriteInputTokens);
return new Usage({
inputTokens: usage.inputTokens,
inputTokens,
outputTokens: usage.outputTokens,
nonCachedInputTokens: nonCached,
nonCachedInputTokens: usage.inputTokens,
cacheReadInputTokens: usage.cacheReadInputTokens,
cacheWriteInputTokens: usage.cacheWriteInputTokens,
totalTokens: ProviderShared.totalTokens(usage.inputTokens, usage.outputTokens, usage.totalTokens),
totalTokens: ProviderShared.totalTokens(inputTokens, usage.outputTokens, usage.totalTokens),
providerMetadata: { bedrock: usage },

@@ -360,0 +357,0 @@ });

+3
-3

@@ -237,5 +237,5 @@ import { Schema } from "effect";

readonly service_tier?: string | null | undefined;
readonly incomplete_details?: Schema.Struct.ReadonlySide<{
readonly reason: Schema.String;
}, "Type"> | null | undefined;
readonly incomplete_details?: {
readonly reason?: string | undefined;
} | null | undefined;
} | undefined;

@@ -242,0 +242,0 @@ readonly message?: string | undefined;

@@ -197,3 +197,3 @@ import { Effect, Encoding, Schema } from "effect";

service_tier: optionalNull(Schema.String),
incomplete_details: optionalNull(Schema.Struct({ reason: Schema.String })),
incomplete_details: optionalNull(Schema.Struct({ reason: Schema.optional(Schema.String) })),
usage: optionalNull(OpenAIResponsesUsage),

@@ -493,3 +493,3 @@ error: optionalNull(OpenAIResponsesErrorPayload),

if (reason === undefined || reason === null)
return hasFunctionCall ? "tool-calls" : "stop";
return hasFunctionCall ? "tool-calls" : event.type === "response.incomplete" ? "unknown" : "stop";
if (reason === "max_output_tokens")

@@ -496,0 +496,0 @@ return "length";

@@ -36,7 +36,8 @@ import { Schema } from "effect";

*
* - OpenAI Chat / Responses / Gemini / Bedrock: provider reports inclusive
* - OpenAI Chat / Responses / Gemini: provider reports inclusive
* `inputTokens` and an inclusive `outputTokens`; mapper subtracts to
* derive the breakdown.
* - Anthropic: provider reports the breakdown natively (`input_tokens` is
* non-cached only); mapper sums to derive the inclusive `inputTokens`.
* - Anthropic and Bedrock report the input breakdown natively: Anthropic's
* `input_tokens` and Bedrock's `inputTokens` are non-cached only. Their
* mappers sum the breakdown to derive the inclusive `inputTokens`.
* Anthropic does *not* break extended-thinking out of `output_tokens`, so

@@ -43,0 +44,0 @@ * `reasoningTokens` is `undefined` and `outputTokens` carries the

{
"$schema": "https://json.schemastore.org/package.json",
"version": "0.0.0-next-16048",
"version": "0.0.0-next-16052",
"name": "@opencode-ai/ai",

@@ -29,3 +29,3 @@ "type": "module",

"@effect/platform-node": "4.0.0-beta.98",
"@opencode-ai/http-recorder": "0.0.0-next-16048",
"@opencode-ai/http-recorder": "0.0.0-next-16052",
"@tsconfig/bun": "1.0.9",

@@ -39,3 +39,3 @@ "@types/bun": "1.3.13",

"@smithy/util-utf8": "4.2.2",
"@opencode-ai/schema": "0.0.0-next-16048",
"@opencode-ai/schema": "0.0.0-next-16052",
"aws4fetch": "1.0.20",

@@ -42,0 +42,0 @@ "effect": "4.0.0-beta.98",

Sorry, the diff of this file is too big to display