mohdel 0.102.0 → 0.103.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.
@@ -203,12 +203,18 @@ export async function * anthropic (envelope, deps = {}) {
203
203
  }
204
204
 
205
205
  const end = String(process.hrtime.bigint())
206
- // Estimate thinking tokens from streamed thinking_delta char count
207
- // (Anthropic API doesn't report them separately). Cap at total
208
- // output tokens reported by usage.
206
+ // Estimate thinking tokens. Primary path: count streamed thinking_delta
207
+ // chars (sonnet emits these). Fallback: gap between Anthropic's reported
208
+ // output_tokens and what actually streamed as visible output (text +
209
+ // tool input JSON) — catches redacted_thinking blocks (opus 4.7 default)
210
+ // that consume output tokens but emit no streaming deltas.
211
+ const streamedOutput = currentOutput()
212
+ const streamedOutputChars = streamedOutput.length +
213
+ [...toolBlocks.values()].reduce((s, b) => s + b.inputJson.length, 0)
214
+ const streamedOutputTokens = Math.ceil(streamedOutputChars / ANTHROPIC_THINKING_CHARS_PER_TOKEN)
209
215
  const estimatedThinkingTokens = thinkingChars > 0
210
216
  ? Math.min(Math.ceil(thinkingChars / ANTHROPIC_THINKING_CHARS_PER_TOKEN), outputTokens)
211
- : 0
217
+ : Math.max(0, outputTokens - streamedOutputTokens)
212
218
  const messageOutputTokens = Math.max(0, outputTokens - estimatedThinkingTokens)
213
219
 
214
220
  /** @type {import('#core/events.js').DoneEvent} */
@@ -216,7 +222,7 @@ export async function * anthropic (envelope, deps = {}) {
216
222
  type: 'done',
217
223
  result: {
218
224
  status,
219
- output: currentOutput() || null,
225
+ output: streamedOutput || null,
220
226
  inputTokens,
221
227
  outputTokens: messageOutputTokens,
222
228
  thinkingTokens: estimatedThinkingTokens,
package/js/session/run.js CHANGED
@@ -264,12 +264,16 @@ export async function * run (envelope, {
264
264
  function normalizeModelEffort (envelope, resolveSpec) {
265
265
  const candidate = effortOf(envelope.model)
266
266
  if (!candidate) return { envelope }
267
- if (envelope.outputEffort) return { envelope } // explicit wins
268
267
 
269
268
  const base = catalogKey(envelope.model)
270
269
  const baseSpec = resolveSpec(base)
271
270
  if (!baseSpec) return { envelope } // base not known — let full string fall through to not-found
272
271
 
272
+ // Explicit outputEffort wins; still strip the suffix so spans/logs see the canonical id.
273
+ if (envelope.outputEffort) {
274
+ return { envelope: { ...envelope, model: base } }
275
+ }
276
+
273
277
  if (!baseSpec.thinkingEffortLevels) {
274
278
  return {
275
279
  envelope,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mohdel",
3
- "version": "0.102.0",
3
+ "version": "0.103.0",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Christophe Le Bars",
@@ -87,7 +87,7 @@
87
87
  "@opentelemetry/exporter-trace-otlp-grpc": "^0.217.0",
88
88
  "@opentelemetry/sdk-node": "^0.217.0",
89
89
  "chalk": "^5.4.0",
90
- "mohdel-thin-gate-linux-x64-gnu": "0.102.0"
90
+ "mohdel-thin-gate-linux-x64-gnu": "0.103.0"
91
91
  },
92
92
  "dependencies": {
93
93
  "@anthropic-ai/sdk": "^0.95.1",