@snack-kit/porygon 0.3.0 → 0.4.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.
package/README.md CHANGED
@@ -551,6 +551,13 @@ npm run playground # 启动 Playground
551
551
 
552
552
  ## Changelog
553
553
 
554
+ ### v0.4.0
555
+
556
+ #### Bug Fixes
557
+
558
+ - **Claude adapter**: 修复 `result` 事件中 `inputTokens` 和 `outputTokens` 始终为 0 的问题。Claude CLI 的 token 统计位于 `event.usage.input_tokens` / `event.usage.output_tokens`,而非顶层的 `event.input_tokens` / `event.output_tokens`
559
+ - **Claude adapter**: 修复 `costUsd` 始终为 `undefined` 的问题。Claude CLI 使用 `total_cost_usd` 字段名,而非 `cost_usd`
560
+
554
561
  ### v0.3.0
555
562
 
556
563
  #### Bug Fixes
package/dist/index.cjs CHANGED
@@ -859,14 +859,15 @@ function mapClaudeEvent(event, sessionId) {
859
859
  return [];
860
860
  }
861
861
  if (isResultEvent(event)) {
862
+ const usage = event.usage;
862
863
  return [{
863
864
  ...baseFields,
864
865
  type: "result",
865
866
  text: event.result,
866
- costUsd: event.cost_usd,
867
+ costUsd: event.total_cost_usd ?? event.cost_usd,
867
868
  durationMs: event.duration_ms,
868
- inputTokens: event.input_tokens,
869
- outputTokens: event.output_tokens
869
+ inputTokens: usage?.input_tokens ?? event.input_tokens,
870
+ outputTokens: usage?.output_tokens ?? event.output_tokens
870
871
  }];
871
872
  }
872
873
  return [];