fix(companion): emit draft from user-turn tool_result + stamp space_id on created entities
- driver: tool_results arrive as type:'user' content blocks (not bare); parse them - route: tool_result content is a JSON string; parse it for pending_change_id → draft event - propose_change: inject ctx.space_id into create payloads (model can't know the uuid; tables require it) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -222,13 +222,26 @@ export async function runClaudeTurn(opts) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (t === 'user') {
|
||||
// Tool results arrive as a synthetic user turn:
|
||||
// { type:"user", message:{ role:"user", content:[{ type:"tool_result", tool_use_id, content }] } }
|
||||
const blocks = raw.message?.content;
|
||||
if (Array.isArray(blocks)) {
|
||||
for (const b of blocks) {
|
||||
if (b?.type === 'tool_result') {
|
||||
const name = toolById.get(b.tool_use_id) || null;
|
||||
emit({ type: 'tool_result', name, result: b.content });
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (t === 'tool_result') {
|
||||
// { type: "tool_result", tool_use_id: "...", content: [...] }
|
||||
// Bare top-level variant (older/alt shape): { type:"tool_result", tool_use_id, content }
|
||||
const id = raw.tool_use_id;
|
||||
const name = toolById.get(id) || null;
|
||||
const result = raw.content;
|
||||
const ev = { type: 'tool_result', name, result };
|
||||
emit(ev);
|
||||
emit({ type: 'tool_result', name, result: raw.content });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user