feat(companion): Dross persona (Cradle) + migration 008 rename; remove dead API-key path

- system prompt = Dross (Ozriel's construct fragment, per Void 1.0), with tool guidance
- migration 008 renames the seeded agent 'companion' → display name 'Dross'
- removed lib/ai/anthropic.js + lib/ai/agent/runtime.js + tests + @anthropic-ai/sdk dep (companion now runs via the claude CLI; kept lib/ai/secret.js for the Vaultwarden roadmap)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-01 22:58:43 +10:00
parent d35e43a8ad
commit 8ce97bbacc
8 changed files with 29 additions and 500 deletions

View File

@@ -1,58 +0,0 @@
// Tool-use loop. callModel + registry injected (no network here).
// Emits: { type:'tool', tool, args, status } | { type:'delta', text }
// | { type:'draft', pending_change_id, summary }
// Returns: { text, toolTrace, draftIds, usage, stoppedOnGuard }
export async function runTurn({ callModel, registry, system, messages, ctx, onEvent, maxIterations = 6 }) {
const convo = [...messages];
const toolTrace = [];
const draftIds = [];
let usage = {};
let stoppedOnGuard = false;
for (let i = 0; i < maxIterations; i++) {
const res = await callModel({
system,
messages: convo,
tools: registry.toAnthropicTools(),
onTextDelta: (t) => onEvent?.({ type: 'delta', text: t })
});
usage = res.usage || usage;
if (!res.toolUses?.length) {
return { text: res.text, toolTrace, draftIds, usage, stoppedOnGuard };
}
// Record the assistant turn (text + tool_use blocks) for the next round.
convo.push({
role: 'assistant',
content: [
...(res.text ? [{ type: 'text', text: res.text }] : []),
...res.toolUses.map(t => ({ type: 'tool_use', id: t.id, name: t.name, input: t.input }))
]
});
const toolResults = [];
for (const call of res.toolUses) {
const tool = registry.getTool(call.name);
let result;
try {
result = tool ? await tool.handler(call.input, ctx) : { error: `unknown tool ${call.name}` };
} catch (e) {
result = { error: String(e?.message || e) };
}
const status = result?.error ? 'error' : 'done';
toolTrace.push({ tool: call.name, args: call.input, ok: !result?.error });
onEvent?.({ type: 'tool', tool: call.name, args: call.input, status });
if (result?.pending_change_id) {
draftIds.push(result.pending_change_id);
onEvent?.({ type: 'draft', pending_change_id: result.pending_change_id, summary: result.summary });
}
toolResults.push({ type: 'tool_result', tool_use_id: call.id, content: JSON.stringify(result) });
}
convo.push({ role: 'user', content: toolResults });
if (i === maxIterations - 1) stoppedOnGuard = true;
}
return { text: '', toolTrace, draftIds, usage, stoppedOnGuard };
}