432
const signals: AgentSignal[] = [];
433
if (message.subtype === 'success') {
435
>
// reported model. Phase 6 turns are single-model; multi-model
436
>
// attribution is a Phase 7+ concern.
437
>
const modelKey = Object.keys(message.modelUsage)[0];
438
>
// Per-turn credits are deliberately NOT derived from
439
>
// `total_cost_usd`: that is the SDK's Anthropic-list-price USD
440
>
// estimate, not what CAPI actually bills. Real Copilot credits come
441
>
// from CAPI's `copilot_usage.total_nano_aiu`, which the proxy
442
>
// captures and `ClaudeAgentSession` attaches to this action as
443
>
// `_meta.copilotUsage.totalNanoAiu` (the key the workbench reads).
444
>
signals.push({
445
>
kind: 'action',
446
>
resource: session,
447
>
action: {
448
>
type: ActionType.ChatUsage,
449
>
turnId,
450
>
usage: {
451
>
inputTokens: message.usage.input_tokens,
452
>
outputTokens: message.usage.output_tokens,
453
>
cacheReadTokens: message.usage.cache_read_input_tokens,
454
>
...(modelKey ? { model: modelKey } : {}),
455
>
},
456
>
},
457
>
});
458
>
}
459
460
// Surface execution errors (e.g. an upstream CAPI failure relayed by the