Fix: Bridge --verbose Flag + korrekte Event-Extraktion
- --verbose ist Pflicht für --output-format stream-json - total_cost_usd statt cost_usd für Kosten - usage.input_tokens/output_tokens + Cache-Info - Session-ID aus system.init Events - rate_limit_event ignorieren - allowedTools entfernt (Claude entscheidet selbst) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e48519fff4
commit
3e5021dbf0
1 changed files with 12 additions and 6 deletions
|
|
@ -51,8 +51,7 @@ function spawnClaude(message, requestId) {
|
|||
const args = [
|
||||
'-p', // Print-Modus (nicht interaktiv)
|
||||
'--output-format', 'stream-json', // Streaming JSON Events
|
||||
'--allowedTools', 'Read', 'Glob', 'Grep', 'Bash', 'Edit', 'Write',
|
||||
'WebFetch', 'WebSearch', 'Agent',
|
||||
'--verbose', // Pflicht für stream-json
|
||||
];
|
||||
|
||||
// Bei Fortsetzung letzte Session verwenden
|
||||
|
|
@ -147,11 +146,15 @@ function handleClaudeEvent(event, agentId, requestId, textState) {
|
|||
|
||||
switch (type) {
|
||||
case 'system':
|
||||
if (event.subtype === 'session_id' && event.session_id) {
|
||||
if (event.session_id) {
|
||||
currentSessionId = event.session_id;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'rate_limit_event':
|
||||
// Ignorieren
|
||||
break;
|
||||
|
||||
case 'assistant':
|
||||
// Vollständige Nachricht — Inhalt extrahieren
|
||||
if (event.message?.content) {
|
||||
|
|
@ -204,13 +207,16 @@ function handleClaudeEvent(event, agentId, requestId, textState) {
|
|||
// Endergebnis mit Kosten
|
||||
sendEvent('result', {
|
||||
text: event.result || '',
|
||||
cost: event.cost_usd || event.cost || 0,
|
||||
cost: event.total_cost_usd || event.cost_usd || 0,
|
||||
tokens: {
|
||||
input: event.input_tokens || 0,
|
||||
output: event.output_tokens || 0,
|
||||
input: event.usage?.input_tokens || 0,
|
||||
output: event.usage?.output_tokens || 0,
|
||||
cache_read: event.usage?.cache_read_input_tokens || 0,
|
||||
cache_create: event.usage?.cache_creation_input_tokens || 0,
|
||||
},
|
||||
session_id: event.session_id || currentSessionId,
|
||||
duration_ms: event.duration_ms || 0,
|
||||
num_turns: event.num_turns || 0,
|
||||
});
|
||||
|
||||
// Session-ID für Fortsetzung merken
|
||||
|
|
|
|||
Loading…
Reference in a new issue