Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
fix(assistant): accept OpenAI-shaped {content} messages and harden recall
rahmanef63e0d2edc59c59
diff --git a/app/api/assistant/route.ts b/app/api/assistant/route.tsindex d73f1bbd..86fa4195 100644--- a/app/api/assistant/route.ts+++ b/app/api/assistant/route.ts@@ -88,7 +88,15 @@ export async function POST(req: Request) {} catch {return Response.json({ error: "bad_request" }, { status: 400 });}- const rawMessages = (body.messages ?? []).slice(-40);+ // The HTTP contract is OaMsg ({text}); OpenAI-shaped callers send {content}. Normalize+ // at the trust boundary so a missing `text` can never reach recall()/the streamer.+ const rawMessages = (body.messages ?? []).slice(-40).map((message) => {+ if (!message || typeof message !== "object") return message;+ const content = (message as { content?: unknown }).content;+ return message.role === "user" && typeof message.text !== "string" && typeof content === "string"+ ? { ...message, text: content }+ : message;+ });if (!rawMessages.length)return Response.json({ error: "empty" }, { status: 400 });let sys =diff --git a/lib/agent/legacy-owner-memory.test.ts b/lib/agent/legacy-owner-memory.test.tsindex 009de739..e59a2a70 100644--- a/lib/agent/legacy-owner-memory.test.ts+++ b/lib/agent/legacy-owner-memory.test.ts@@ -21,6 +21,10 @@ describe("owner memory store + recall", () => {it("falls back to recent facts when the query has no long words", async () => {await addMemory("Keep this user fact as data"); expect(await recall("a b")).toHaveLength(1);});+ it("degrades to recent facts when the query is not a string", async () => {+ await addMemory("Survives a malformed caller");+ expect(await recall(undefined as unknown as string)).toHaveLength(1);+ });it("serializes parallel additions without losing a fact", async () => {await Promise.all(Array.from({ length: 12 }, (_, i) => addMemory(`Concurrent fact ${i}`)));const rows = await listMemories(); expect(rows).toHaveLength(12); expect(new Set(rows.map((x) => x.id)).size).toBe(12);diff --git a/lib/agent/legacy-owner-memory.ts b/lib/agent/legacy-owner-memory.tsindex 58a2b4df..ed3b5bed 100644--- a/lib/agent/legacy-owner-memory.ts+++ b/lib/agent/legacy-owner-memory.ts@@ -85,7 +85,8 @@ export async function removeMemory(id: string): Promise<void> {// Bounded substring recall, not a claim of semantic retrieval or trusted instructions.export async function recall(query: string, limit = 8): Promise<Memory[]> {const all = await read(), count = Math.max(1, Math.min(100, Math.floor(limit) || 8));- const words = query.toLowerCase().match(/[a-z0-9]{3,}/g) ?? [];+ // Callers may hand over a malformed message body; recall must degrade, never throw.+ const words = (typeof query === "string" ? query : "").toLowerCase().match(/[a-z0-9]{3,}/g) ?? [];if (!words.length) return all.slice(-count);return all.map((memory) => ({ memory, hits: words.filter((word) => memory.text.toLowerCase().includes(word)).length })).filter((row) => row.hits > 0).sort((a, b) => b.hits - a.hits).slice(0, count).map((row) => row.memory);diff --git a/scripts/cli/commands-state.sh b/scripts/cli/commands-state.shindex 7a738e0f..8578df4b 100755--- a/scripts/cli/commands-state.sh+++ b/scripts/cli/commands-state.sh@@ -8,7 +8,7 @@ mso_cmd_state() {local cmd="$1"; shift || truecase "$cmd" in# ── assistant / state ────────────────────────────────────────────────────- ai) jpost "/api/assistant" "$(jq -n --arg m "$*" '{messages:[{role:"user",content:$m}]}')" ;;+ ai) jpost "/api/assistant" "$(jq -n --arg m "$*" '{messages:[{role:"user",text:$m}]}')" ;;cockpit)case "${1:-show}" inshow)