From 8e0f0ef9aadd78dc92438dc04731c06baf17b294 Mon Sep 17 00:00:00 2001 From: 4 Bytes Robby Date: Mon, 15 Jun 2026 09:04:14 +0200 Subject: [PATCH] fix: brain status transitions + app.log instead of console.warn #149 --- package.json | 2 +- src/four-opencode-brain.ts | 7 +++---- src/status.ts | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 1ce5cb1..32fd053 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@four-bytes/four-opencode-brain", - "version": "1.7.6", + "version": "1.7.7", "description": "Unified brain plugin — single SQLite DB for RAG search, memory, and knowledge base", "license": "Apache-2.0", "type": "module", diff --git a/src/four-opencode-brain.ts b/src/four-opencode-brain.ts index 38e204e..714db4f 100644 --- a/src/four-opencode-brain.ts +++ b/src/four-opencode-brain.ts @@ -221,10 +221,9 @@ const _serverPlugin = async (input: PluginInput) => { firstRunDb.close(); } - // Init complete — only set idle if NOT auto-ingesting - if (!autoIngest) { - updateStatus("ready"); // init complete, no auto-ingest - } + // Init complete — plugin is ready for tool calls. Auto-ingest (if any) runs in background + // and will transition to "busy" → "ready" on its own. + updateStatus("ready"); // ---- Tool definitions ---- diff --git a/src/status.ts b/src/status.ts index 3d7c8c1..946518e 100644 --- a/src/status.ts +++ b/src/status.ts @@ -80,7 +80,7 @@ export function initStatus(client: PluginInput["client"], directory: string): vo function getBus(): Promise { if (!_busPromise) { _busPromise = BusClient.connect().catch((err) => { - console.warn("[brain] BusClient connect failed:", (err as Error).message); + _client?.app?.log({ body: { service: "brain", level: "warn", message: "BusClient connect failed", extra: { error: String(err) } } }).catch(() => {}); _busPromise = null; // allow retry on next call throw err; }); @@ -150,7 +150,7 @@ function write(data: Record): void { await target.publish("status", payload); }) .catch((err) => { - console.warn("[brain] Bus publish failed:", (err as Error).message); + _client?.app?.log({ body: { service: "brain", level: "warn", message: "Bus publish failed", extra: { error: String(err) } } }).catch(() => {}); _busPromise = null; // reset to allow reconnect }); }