🤖 Open-source, local-first alternative to Grok Bot, OpenAI dots and Claude Duet. Your own AI bots on any model: GPT, Claude, Gemini, Grok, DeepSeek, Kimi, GLM and 70+ more through one Modelflare key. Reach them in the app, WeChat or Feishu; they remember you, work in the background, run commands and use your computer. Pay per use.
Python ai-agentai-assistantchatbotclaudecomputer-usedeepseekdesktop-appdshelectronfeishugeminigptgrokllmlocal-firstmodelflaremulti-modelopenai-compatiblepersonal-ai-agentwechat
ui: redesign shell to fuse with magpie (Taste app rules)
Marlae2832f1b823a
diff --git a/.taste-skill/app/direction.json b/.taste-skill/app/direction.jsonnew file mode 100644index 0000000..03e20a6--- /dev/null+++ b/.taste-skill/app/direction.json@@ -0,0 +1,210 @@+{+ "version": 1,+ "kind": "app",+ "at": "2026-10-27T16:02:02.968Z",+ "seed": 1625474270,+ "input": {+ "kind": "devtools",+ "brief": "anymodel bot: Electron desktop control panel for self-hosted AI bots. Operator manages bots, WeChat/Feishu channels, Magpie model gateway, computer-use, approvals, conversations. Chinese-first UI. Dense technical admin, calm and precise, not SaaS marketing.",+ "theme": null,+ "screens": [+ "overview",+ "list",+ "settings"+ ],+ "keep": [],+ "style": null+ },+ "style": {+ "id": "framed-sheet",+ "name": "Framed sheet",+ "theme": "light",+ "basis": "6 screens: a developer platform overview, an analytics overview, an events analytics tab, a list detail, a reports dashboard, a flow builder",+ "suits": [+ "analytics",+ "devtools",+ "builder",+ "smb-admin",+ "support",+ "commerce",+ "report"+ ],+ "idea": "The app chrome is one tinted L-shaped frame; the work sits on a white sheet with a hairline edge and soft corners, so depth comes from a single tone step and no shadow.",+ "colourBudget": "under 3%; the brand shrinks to the logo and a 2px tab underline, the data carries the chroma",+ "tokens": {+ "ground": "#f9fbfc",+ "surface": "#ffffff",+ "raised": "#f4f6f8",+ "active": "#ebedee",+ "border": "#e8eaec",+ "rule": "#f0f1f2",+ "control": "#cdced1",+ "text": "#131416",+ "muted": "#5d5f60",+ "accent": "#1b6c80",+ "positive": "#1e7b4f",+ "negative": "#c4242a",+ "warning": "#92400e",+ "chart": [+ "#1b6c80",+ "#2f70bb",+ "#a86f0c"+ ],+ "pills": {+ "positive": [+ "#dcfae5",+ "#04250e"+ ],+ "negative": [+ "#ffedea",+ "#831c1e"+ ],+ "warning": [+ "#fffbeb",+ "#92400e"+ ],+ "neutral": [+ "#ebedee",+ "#353736"+ ]+ },+ "radius": {+ "card": 8,+ "control": 6,+ "sheet": 16+ },+ "sheetInset": 8,+ "font": {+ "family": "IBM Plex Sans",+ "second": "IBM Plex Mono, for IDs and keys only",+ "fallback": "Inter, system-ui, sans-serif",+ "sizes": {+ "title": 22,+ "section": 16,+ "kpi": 28,+ "body": 14,+ "small": 12+ },+ "weights": [+ 400,+ 500,+ 600+ ],+ "note": "KPI values at 400; the semibold goes on the label and the active tab."+ },+ "density": "medium",+ "rowHeight": 48,+ "sidebarWidth": 228,+ "gap": 24,+ "pad": 24,+ "controlHeight": 32+ },+ "shell": "framed-sheet",+ "shellAlternatives": [],+ "signature": "One tinted frame holds the sidebar and the 48px top bar with no rule between them; the page is a white sheet inset 8px from the window's right and bottom edges, with a 1px edge, 16px corners and no shadow. The active tab is a 2px underline in ink or the accent; everything else in the chrome is grey.",+ "identity": [+ "The frame tinted from the product's colour in place of #f9fbfc: one low-chroma step of its hue (a green-grey for a climate or farm tool, a blue-grey for an observability tool, a stone for a print shop). The sheet stays white.",+ "The brand's own hue from the brief as --chart-1 in place of the dealt teal, on the main series and the one selected state, at 3:1 or more on white, never violet or indigo.",+ "IBM Plex Mono for IDs, keys and the figures in tables (one job): its figures have their own drawing, and a developer reads them as the product's."+ ],+ "avoid": [+ "a border between the sidebar and the top bar",+ "a shadow under the sheet",+ "cards whose border is heavier than the sheet's (#cdcfcf on cards read as heavy in the study)",+ "a fourth nesting level: frame, sheet and card are enough",+ "different gutters for the KPI row and the chart row (20 against 24 was flagged)"+ ],+ "notes": "The study's second data hue in this style was an orange (#e88e46) that falls inside the house terracotta range; the third chart colour here is an amber moved out of that range and darkened to 3:1 on white."+ },+ "shell": {+ "id": "framed-sheet",+ "name": "Tinted frame, white sheet",+ "basis": "8 of 23 screens, in three variants",+ "suits": [+ "analytics",+ "devtools",+ "builder",+ "smb-admin",+ "support"+ ],+ "numbers": {+ "chrome": "#f6f6f6-#f9fbfc (a warm #f7f6f2 once)",+ "sheetInset": "8px from the window's right and bottom edges (12 and 16 once each)",+ "sheetRadius": "10-16, median 16",+ "sheetEdge": "1px #eaeaea-#ededed, no shadow",+ "sidebarWidth": "220-263 (228 on two screens)",+ "topBar": "48px on the chrome ground with no rule; search 548x32 centred on the window with a shortcut hint",+ "contentPadding": 24,+ "floatingVariant": "both panels inset 12px with a 12px gutter, radius 10"+ },+ "blueprint": "Sidebar and top bar share one tinted ground with no rule between them, forming an L; the page lives on a white sheet. Variant one: the sheet butts against the sidebar and the top bar and is inset 8px from the right and bottom edges, 16px radius, 1px edge. Variant two: a flush L-frame with no inset, the frame marked by one rule. Variant three: sidebar and content are two floating panels inset 12px from every edge with a 12px gutter. The top bar, when present, is 48px and holds a centred search, the account button and a help or AI icon. Inside the sheet the content has 24px padding and starts with the breadcrumb or title row.",+ "phone": "The frame disappears: the sheet becomes the screen, with a 48px top bar (menu button, title, one action) on the chrome tint. The search moves into the menu sheet or behind an icon."+ },+ "screens": [+ {+ "name": "overview",+ "pattern": {+ "id": "deploy-health-lead",+ "name": "Current deploy and health lead",+ "screen": "overview",+ "kinds": [+ "devtools"+ ],+ "basis": "house pattern from testing: built after a flat 24-hour chart filled a whole first screen and lost to a richer layout",+ "blueprint": "Title row: the project's name as the h1 with a status pill (Healthy, Degraded) and a breadcrumb of team and product above it; repository, branch and a freshness stamp in a 14px grey line under it; the one primary action (Redeploy, or View logs when the latest deploy failed) on the right. Then a full-width card for what is live now: the production deployment's commit message at 16/600, its branch, short SHA in mono, author and age on the left, and three or four facts in divided cells on the right (domain, live since, build time, regions). Then the health strip: three or four KPIs in one divided container, each with its change in words and in the polarity colour when it moved the wrong way. Then a two-column row: the 24-hour chart at two-thirds (deploy markers as 1px ticks with their short SHA, the budget or SLO as a dashed reference line) and, at one-third, the block that explains the worst number (the spike and what reverted it, the status codes behind the error rate). Then the deployments table capped at 6 rows, a failed row carrying its failing step and a View logs action, a building row its elapsed time.",+ "phone": "The live deployment card becomes a stack of label-value rows; the KPIs a 2x2 grid; the chart full width with its markers; the explanation under it; deployments as two-line rows with region and duration on line 2."+ }+ },+ {+ "name": "list",+ "pattern": {+ "id": "table-filter-bar",+ "name": "Table with tabs and a filter bar",+ "screen": "list",+ "kinds": [+ "community",+ "devtools",+ "commerce",+ "support",+ "smb-admin"+ ],+ "basis": "an events back office, a tracks studio, a sessions overview",+ "blueprint": "Title row: an 18-24px title on the left, at most an outlined secondary and the one primary (36px) on the right. Underline tabs for the list's states on a full-width 1px rule with a 2px indicator as wide as the label; 22-32px below, the toolbar: a search of about 252-316 x 32-36 on the left, the count ('7 events') and the sort on the right. The table sits on the panel or page ground with no card around it: a header of 12-13px grey sentence-case labels with no fill and no rule, rows on a 48-56px pitch for one line or 72-92px with a thumbnail (media height plus 24-32px), 1px rules 3-7% darker than the ground or no rules at all, the identity column given the most width, numbers right-aligned in tabular figures with the unit muted ('5 /10'), one status mark per row and one kebab at the far right. Drop a column that is empty in every row (a blank co-host column left a 300px dead band). On an overview, cap the rows and link to the full list; on the full list, state the total and load more at the end.",+ "phone": "Rows become two-line items: identity and the key number on line 1, the secondary fields in 13px grey on line 2, the kebab at the right. Tabs scroll in their own row; the search becomes a full-width field."+ }+ },+ {+ "name": "settings",+ "pattern": {+ "id": "settings-two-column",+ "name": "Settings in two columns",+ "screen": "settings",+ "kinds": [+ "devtools",+ "smb-admin",+ "support",+ "workspace",+ "commerce",+ "analytics",+ "finance",+ "wallet",+ "creator",+ "community",+ "builder",+ "markets",+ "report"+ ],+ "basis": "one settings page; stacking from a narrow rail card. The basis is thin.",+ "blueprint": "A centred column of about 1152px. Each section is one row: a label column of about 450px (16/500 title, 14px grey description; the title's cap top 6-8px below the panel top, level with the panel's first line) beside a panel of about 700px with a #fafafa fill, 16px radius, 16px padding, no border and no shadow. Sections are split by a full-width 1px rule with 32px above and below. Inside a panel: field labels 14/500 above 40px white inputs (1px #e8e8e8, radius 10), 8px from label to field, 16px between fields, 24px from the description to the first label, 16px to the Save button; switch rows with a 14/500 title, a 20px status badge 8px after it, a 14px grey description and a 28x16 toggle 16px from the right edge, centred on the title line. A plan-gated feature shows a 48px tinted strip with a 32px button directly above its panel, and the panel stays readable. When a panel runs much taller than its label, put the section's help or a summary of the current values in the label column rather than 250px of nothing.",+ "phone": "Each section stacks: title and description, then the panel at full width. Inside, label, 8-10px, field, 16-26px to the next pair; toggles stay on the right of their title."+ }+ }+ ],+ "fusion": {+ "overrideAccent": "#4f46e5",+ "reason": "Fuse with embedded magpie GUI; indigo + greys from magpie app.css replace dealt teal #1b6c80",+ "font": "system stack + PingFang SC / Microsoft YaHei (magpie)",+ "layout": "chat-first three-column (list | chat | detail); framed-sheet tokens kept for density/radii",+ "face": "anymodel bot monogram on accent-soft indigo disc; product name in sidebar"+ }+}diff --git a/ui/app.js b/ui/app.jsindex b3b221c..fa674c0 100644--- a/ui/app.js+++ b/ui/app.js@@ -1,6 +1,7 @@// anymodel bot 管理界面:Preact + htm(无构建步骤,原生 ES 模块)+// 壳:左栏机器人/会话 · 中间对话 · 右栏上下文(渠道/设置/记忆/审批)import { h, render } from "preact";-import { useEffect, useState, useCallback } from "preact/hooks";+import { useEffect, useState, useCallback, useRef, useMemo } from "preact/hooks";import htm from "htm";const html = htm.bind(h);@@ -22,6 +23,10 @@ const STATE_TEXT = {};const Badge = ({ s }) => html`<span class="badge ${s}">${STATE_TEXT[s] || s}</span>`;const fmt = (t) => (t ? new Date(t).toLocaleString("zh-CN", { hour12: false }) : "");+const initials = (name) => {+ const s = String(name || "?").trim();+ return s.slice(0, 1).toUpperCase();+};function usePoll(fn, ms, deps = []) {const [data, setData] = useState(null);@@ -31,15 +36,43 @@ function usePoll(fn, ms, deps = []) {return [data, err, load];}-// ---------------- 概览 ----------------+function useTheme() {+ const read = () => localStorage.getItem("amb-theme") || "system";+ const [mode, setMode] = useState(read);+ const apply = (m) => {+ const root = document.documentElement;+ if (m === "system") root.removeAttribute("data-theme");+ else root.setAttribute("data-theme", m);+ };+ useEffect(() => { apply(mode); localStorage.setItem("amb-theme", mode); }, [mode]);+ useEffect(() => {+ const mq = window.matchMedia("(prefers-color-scheme: dark)");+ const onChange = () => { if (mode === "system") apply("system"); };+ mq.addEventListener?.("change", onChange);+ return () => mq.removeEventListener?.("change", onChange);+ }, [mode]);+ const resolved = useMemo(() => {+ if (mode === "light" || mode === "dark") return mode;+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";+ }, [mode]);+ return [mode, setMode, resolved];+}++const Mark = () => html`<div class="brand-mark" aria-hidden="true">+ <svg width="18" height="18" viewBox="0 0 18 18" fill="none">+ <path d="M4 12.5V5.5L9 10l5-4.5v7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>+ </svg>+</div>`;++// ---------------- 概览(管理视图) ----------------const PRESETS = ["deepseek", "openai", "anthropic", "google", "moonshot-cn", "qwen-cn", "zhipu", "volcengine", "xai", "minimax-cn", "groq", "mistral"];-function Overview({ go }) {+function Overview({ goChat }) {const [st] = usePoll(() => api("/status"), 3000);const [models, , reloadModels] = usePoll(() => api("/models"), 0);const [preset, setPreset] = useState("deepseek");const [key, setKey] = useState("");const [msg, setMsg] = useState("");- if (!st) return html`<p>加载中…</p>`;+ if (!st) return html`<p class="muted">加载中…</p>`;const mp = st.magpie;const add = async () => {setMsg("添加中…");@@ -47,7 +80,14 @@ function Overview({ go }) {catch (e) { setMsg("✗ " + e.message); }};return html`+ <div class="page-head"><h2>概览</h2><p class="sub">网关状态与快速添加服务商</p></div>${st.notices.slice(0, 3).map((n) => html`<div class="notice">${fmt(n.at)} ${n.text}</div>`)}+ <div class="kpi-strip">+ <div class="kpi"><div class="lbl">网关</div><div class="val">${mp.state}<span class="unit">${mp.mode || ""}</span></div></div>+ <div class="kpi"><div class="lbl">服务商</div><div class="val">${mp.providers ?? "—"}</div></div>+ <div class="kpi"><div class="lbl">重启</div><div class="val">${mp.restarts ?? 0}</div></div>+ <div class="kpi"><div class="lbl">版本</div><div class="val" style="font-size:14px">${st.version || "—"}</div></div>+ </div><div class="card"><h3>模型网关(内置 magpie)</h3><div class="row"><span>状态</span><${Badge} s=${mp.state} />@@ -63,12 +103,14 @@ function Overview({ go }) {<input class="grow" style="width:auto" type="password" placeholder="API Key(仅保存在本机的 magpie 隔离配置中)" value=${key} onInput=${(e) => setKey(e.target.value)} /><button class="pri" disabled=${!key} onClick=${add}>添加</button></div>- <p class="muted">${msg} 更多服务商、自定义端点、路由与用量请到 <a href="#" onClick=${(e) => { e.preventDefault(); go("models"); }}>「模型」</a> 页(magpie 完整界面)。</p>+ <p class="muted">${msg} 更多配置请打开「模型」面板(magpie)。</p></div>`}- <div class="card muted">数据目录:<code>${st.dataDir}</code> · 版本 ${st.version}</div>`;+ <div class="card muted">数据目录:<code>${st.dataDir}</code> · 版本 ${st.version}+ <div style="margin-top:8px"><button onClick=${goChat}>返回对话</button></div>+ </div>`;}-// ---------------- 机器人 ----------------+// ---------------- 机器人编辑(右栏 / 管理) ----------------function BotEditor({ bot, models, onSaved, onDeleted }) {const [f, setF] = useState(bot);const [msg, setMsg] = useState("");@@ -80,6 +122,7 @@ function BotEditor({ bot, models, onSaved, onDeleted }) {};const del = async () => { if (confirm(`删除机器人「${bot.name}」及其全部会话?`)) { await api(`/bots/${bot.id}`, { method: "DELETE" }); onDeleted(); } };return html`<div class="card">+ <h3>身份</h3><label>名称</label><input value=${f.name} onInput=${set("name")} /><label>人设 / 系统提示词</label><textarea value=${f.systemPrompt} onInput=${set("systemPrompt")} /><label>默认模型(会话内可用 /model 覆盖)</label>@@ -91,7 +134,6 @@ function BotEditor({ bot, models, onSaved, onDeleted }) {</div>`;}-// 机器人身份与行为设置(权限预设、长期记忆、上下文管家、电脑操作)function BotSettings({ botId, models }) {const [d, err, reload] = usePoll(() => api(`/bots/${botId}/settings`), 0, [botId]);const [msg, setMsg] = useState("");@@ -135,7 +177,6 @@ function BotSettings({ botId, models }) {</div>`;}-// 长期记忆查看器:按作用域列出条目,可逐条删除;附变更日志与管家记录function MemoryViewer({ botId }) {const [d, err, reload] = usePoll(() => api(`/bots/${botId}/memory`), 0, [botId]);const [msg, setMsg] = useState("");@@ -146,7 +187,7 @@ function MemoryViewer({ botId }) {catch (e) { setMsg("✗ " + e.message); }};const list = (sc, entries, topic) => entries.map((e) => html`<div class="row"><span class="grow">• ${e.text}</span><button onClick=${() => forget(sc, e.text, topic)}>删除</button></div>`);- return html`<div class="card"><h3>长期记忆 <button onClick=${reload}>刷新</button></h3>+ return html`<div class="card"><h3>长期记忆 <button class="ghost" onClick=${reload}>刷新</button></h3>${d.scopes.map((sc) => html`<div><b>${sc.label}</b>${!sc.entries.length && !sc.topics.length ? html`<p class="muted">(空)</p>` : ""}${list(sc, sc.entries)}@@ -160,46 +201,6 @@ function MemoryViewer({ botId }) {</div>`;}-function TestChat({ botId }) {- const [text, setText] = useState("");- const [log, setLog] = useState([]);- const [busy, setBusy] = useState(false);- const sendMsg = async () => {- const t = text.trim(); if (!t) return;- setText(""); setBusy(true); setLog((l) => [...l, { role: "user", content: t }]);- try {- const r = await api(`/bots/${botId}/chat`, { method: "POST", body: { text: t } });- const extra = [...(r.prompts || []).map((p) => ({ role: "assistant prompt", content: p.prompt }))];- const files = (r.files || []).map((f) => ({ role: "assistant progress", content: "📎 已交付文件:" + f + "(微信/飞书会直接发送;网页端请在机器人工作区查看)" }));- setLog((l) => [...l, ...extra, { role: "assistant", content: r.reply }, ...files]);- }- catch (e) { setLog((l) => [...l, { role: "assistant", content: "✗ " + e.message }]); }- setBusy(false);- };- return html`<div class="card"><h3>测试对话</h3>- <div class="msgs">${log.map((m) => html`<div class="msg ${m.role}">${m.content}</div>`)}</div>- <div class="row" style="margin-top:12px"><input class="grow" style="width:auto" placeholder="输入消息,支持 /model /reset /new /help" value=${text}- onInput=${(e) => setText(e.target.value)} onKeyDown=${(e) => e.key === "Enter" && !busy && sendMsg()} />- <button class="pri" disabled=${busy} onClick=${sendMsg}>${busy ? "生成中…" : "发送"}</button></div></div>`;-}--function Bots({ botId, setBotId }) {- const [data, , reload] = usePoll(() => api("/bots"), 0);- const [models] = usePoll(() => api("/models"), 0);- const [name, setName] = useState("");- if (!data) return html`<p>加载中…</p>`;- const bot = data.bots.find((b) => b.id === botId) || data.bots[0];- const create = async () => { const r = await api("/bots", { method: "POST", body: { name } }); setName(""); await reload(); setBotId(r.bot.id); };- return html`<div class="cols">- <div>- <div class="card list" style="padding:0">${data.bots.map((b) => html`<div class="item ${bot && b.id === bot.id ? "sel" : ""}" onClick=${() => setBotId(b.id)}><b>${b.name}</b><div class="muted">${b.id} · ${b.defaultModel || "自动模型"}</div></div>`)}</div>- <div class="card"><label>新建机器人</label><div class="row"><input class="grow" style="width:auto" value=${name} placeholder="名称" onInput=${(e) => setName(e.target.value)} /><button disabled=${!name.trim()} onClick=${create}>创建</button></div>- <p class="muted">一个机器人对应一个飞书应用;微信每个机器人扫码绑定一次。</p></div>- </div>- <div>${bot && html`<${BotEditor} key=${bot.id} bot=${bot} models=${models && models.models} onSaved=${reload} onDeleted=${() => { setBotId(""); reload(); }} /><${BotSettings} key=${"s" + bot.id} botId=${bot.id} models=${models && models.models} /><${MemoryViewer} key=${"m" + bot.id} botId=${bot.id} /><${TestChat} key=${"c" + bot.id} botId=${bot.id} />`}</div>- </div>`;-}-// ---------------- 渠道 ----------------function Feishu({ bot, st, reload }) {const [appId, setAppId] = useState(bot.feishuAppId);@@ -214,7 +215,7 @@ function Feishu({ bot, st, reload }) {<label>App Secret ${bot.feishuAppSecretMasked && html`<span class="muted">(已保存 ${bot.feishuAppSecretMasked},留空则不修改)</span>`}</label><input type="password" value=${secret} onInput=${(e) => setSecret(e.target.value)} /><div class="row" style="margin-top:12px"><button class="pri" disabled=${!appId} onClick=${save}>保存并连接</button>${bot.feishuAppId && html`<button class="danger" onClick=${clear}>断开</button>`}<span class="muted">${msg}</span></div>- <p class="muted">需在飞书开放平台启用「机器人」能力,事件订阅选择「使用长连接接收事件」并订阅 <code>im.message.receive_v1</code>;权限:<code>im:message.p2p_msg:readonly</code>、<code>im:message:send_as_bot</code>、<code>cardkit:card:write</code>。详见 README。</p>+ <p class="muted">需在飞书开放平台启用「机器人」能力,事件订阅选择「使用长连接接收事件」并订阅 <code>im.message.receive_v1</code>;权限:<code>im:message.p2p_msg:readonly</code>、<code>im:message:send_as_bot</code>、<code>cardkit:card:write</code>。</p></div>`;}@@ -232,7 +233,7 @@ function Weixin({ bot, st, reload }) {${st.detail && html`<p class="muted">${st.detail}</p>`}${st.account && html`<p class="muted">已绑定:${st.account.ilinkBotId}${st.account.pausedUntil > Date.now() ? ` · 暂停至 ${fmt(st.account.pausedUntil)}` : ""}</p>`}${login && login.state !== "idle" && html`<div class="row"><${Badge} s=${login.state} /><span>${login.message}</span></div>`}- ${active && login.qrDataUrl && html`<p><img class="qr" src=${login.qrDataUrl} alt="微信登录二维码" /></p><p class="muted">用微信扫一扫,然后在手机上确认。二维码同时保存在数据目录。</p>`}+ ${active && login.qrDataUrl && html`<p><img class="qr" src=${login.qrDataUrl} alt="微信登录二维码" /></p><p class="muted">用微信扫一扫,然后在手机上确认。</p>`}${login && login.state === "need_verifycode" && html`<div class="row"><input style="width:160px" value=${code} placeholder="验证码" onInput=${(e) => setCode(e.target.value)} /><button onClick=${verify}>提交</button></div>`}<div class="row" style="margin-top:12px">${active ? html`<button onClick=${cancel}>取消</button>` : html`<button class="pri" onClick=${start}>${st.account ? "重新扫码登录" : "扫码登录"}</button>`}@@ -240,37 +241,39 @@ function Weixin({ bot, st, reload }) {<button onClick=${toggle}>${bot.weixinEnabled ? "停用微信渠道" : "启用微信渠道"}</button></div>${st.quota && st.quota.length > 0 && html`<h4>出站配额(每条入站消息后 24 小时内最多 10 条)</h4>- <table style="width:100%">${st.quota.map((q) => html`<tr><td><code>${q.userId}</code></td><td>剩余 <b>${q.remaining}</b> 条</td><td class="muted">窗口开始 ${fmt(q.windowStartedAt)}</td></tr>`)}</table>`}+ <table>${st.quota.map((q) => html`<tr><td><code>${q.userId}</code></td><td>剩余 <b>${q.remaining}</b> 条</td><td class="muted">窗口开始 ${fmt(q.windowStartedAt)}</td></tr>`)}</table>`}</div>`;}-function Channels({ botId, setBotId }) {+function ChannelsPanel({ botId }) {const [bots] = usePoll(() => api("/bots"), 0);const bot = bots && (bots.bots.find((b) => b.id === botId) || bots.bots[0]);const [detail, , reload] = usePoll(() => (bot ? api(`/bots/${bot.id}`) : Promise.resolve(null)), 5000, [bot && bot.id]);- if (!bots) return html`<p>加载中…</p>`;+ if (!bots || !bot) return html`<p class="muted">加载中…</p>`;return html`<div>- <div class="row" style="margin-bottom:12px"><span>机器人</span><select style="width:240px" value=${bot && bot.id} onChange=${(e) => setBotId(e.target.value)}>${bots.bots.map((b) => html`<option value=${b.id}>${b.name}</option>`)}</select></div>${detail && detail.bot && html`<${Feishu} bot=${detail.bot} st=${detail.channels.feishu} reload=${reload} /><${Weixin} bot=${detail.bot} st=${detail.channels.weixin} reload=${reload} />`}</div>`;}-// ---------------- 会话 -----------------function Conversations() {+// ---------------- 会话列表(管理视图) ----------------+function ConversationsAdmin({ onOpen }) {const [data] = usePoll(() => api("/conversations"), 5000);const [sel, setSel] = useState("");const [msgs] = usePoll(() => (sel ? api(`/conversations/${encodeURIComponent(sel)}/messages`) : Promise.resolve(null)), 5000, [sel]);- if (!data) return html`<p>加载中…</p>`;- return html`<div class="cols">- <div class="card list" style="padding:0">${data.conversations.length === 0 && html`<p class="muted" style="padding:12px">暂无会话</p>`}- ${data.conversations.map((c) => html`<div class="item ${c.id === sel ? "sel" : ""}" onClick=${() => setSel(c.id)}>- <b>${c.channel}</b> · ${c.title || c.peerId}<div class="muted">${c.botId} · ${c.messageCount} 条 · ${fmt(c.updatedAt)}${c.model ? " · " + c.model : ""}</div>- <div class="muted">${c.lastMessage}</div></div>`)}</div>- <div class="card">${msgs ? html`<div class="msgs">${msgs.messages.map((m) => html`<div class="msg ${m.role}" title=${fmt(m.createdAt)}>${m.content}</div>`)}</div>` : html`<p class="muted">选择左侧会话查看消息</p>`}</div>+ if (!data) return html`<p class="muted">加载中…</p>`;+ return html`<div>+ <div class="page-head"><h2>会话</h2><p class="sub">全部渠道会话</p></div>+ <div class="cols">+ <div class="card list" style="padding:0">${data.conversations.length === 0 && html`<p class="muted" style="padding:12px">暂无会话</p>`}+ ${data.conversations.map((c) => html`<div class="item ${c.id === sel ? "sel" : ""}" onClick=${() => { setSel(c.id); onOpen && onOpen(c); }}>+ <b>${c.channel}</b> · ${c.title || c.peerId}<div class="muted">${c.botId} · ${c.messageCount} 条 · ${fmt(c.updatedAt)}${c.model ? " · " + c.model : ""}</div>+ <div class="muted">${c.lastMessage}</div></div>`)}</div>+ <div class="card">${msgs ? html`<div class="msgs">${msgs.messages.map((m) => html`<div class=${`msg-row ${m.role}`}><div class=${`msg-bubble ${m.role === "assistant" ? "cardish" : ""}`}>${m.content}</div></div>`)}</div>` : html`<p class="muted">选择左侧会话查看消息</p>`}</div>+ </div></div>`;}-// ---------------- 审批 ----------------+// ---------------- 审批(DSH,原生面板) ----------------const AP_STATUS = { pending: "待处理", allowed: "已批准", rejected: "已拒绝", expired: "已过期", answered: "已回答", cancelled: "已取消" };function QuestionForm({ a, done }) {const [text, setText] = useState("");@@ -278,20 +281,23 @@ function QuestionForm({ a, done }) {return html`<div>${(a.questions || []).map((q, i) => html`<div><b>${i + 1}. ${q.question}</b>${(q.options || []).map((o, j) => html`<div class="muted"> ${j + 1}) ${o.label}${o.description ? " — " + o.description : ""}</div>`)}</div>`)}<div class="row" style="margin-top:8px"><input class="grow" style="width:auto" placeholder="每行回答一个问题,可填选项编号" value=${text} onInput=${(e) => setText(e.target.value)} /><button class="pri" disabled=${!text.trim()} onClick=${submit}>回答</button></div></div>`;}-function Approvals() {+function Approvals({ botId, compact }) {const [filter, setFilter] = useState("pending");const [data, err, reload] = usePoll(() => api(`/approvals${filter ? "?status=" + filter : ""}`), 3000, [filter]);const [agent] = usePoll(() => api("/agent"), 5000);const decide = async (id, ok) => { try { await api(`/approvals/${id}/${ok ? "approve" : "deny"}`, { method: "POST", body: {} }); } catch (e) { alert(e.message); } reload(); };+ const list = (data && data.approvals || []).filter((a) => !botId || a.botId === botId);return html`<div>+ ${!compact && html`<div class="page-head"><h2>审批</h2><p class="sub">DSH 代理请求与提问</p></div>`}${agent && html`<div class="card"><h3>代理(DSH) ${agent.enabled ? html`<span class="badge running">已启用</span>` : html`<span class="badge disabled">未启用(普通对话)</span>`}</h3>- ${Object.entries(agent.hosts || {}).map(([id, h]) => html`<div class="row"><b>${id}</b><${Badge} s=${h.state} /><span class="muted">pid ${h.pid || "-"} · ${h.model || "默认模型"} · 重启 ${h.restarts} 次 · 进行中 ${h.activeTurns}${h.lastError ? " · " + h.lastError : ""}</span></div>`)}- <p class="muted">每个机器人一个 DSH 子进程;bash 默认在工作区沙箱中运行,越权操作会在这里和聊天中请求批准(10 分钟未处理自动拒绝)。</p></div>`}- <div class="row" style="margin-bottom:12px"><span>筛选</span><select style="width:160px" value=${filter} onChange=${(e) => setFilter(e.target.value)}>+ ${Object.entries(agent.hosts || {}).filter(([id]) => !botId || id === botId).map(([id, h]) => html`<div class="row"><b>${id}</b><${Badge} s=${h.state} /><span class="muted">pid ${h.pid || "-"} · ${h.model || "默认模型"} · 重启 ${h.restarts} 次 · 进行中 ${h.activeTurns}${h.lastError ? " · " + h.lastError : ""}</span></div>`)}+ ${!compact && html`<p class="muted">每个机器人一个 DSH 子进程;bash 默认在工作区沙箱中运行,越权操作会在这里和聊天中请求批准(10 分钟未处理自动拒绝)。</p>`}+ </div>`}+ <div class="row" style="margin-bottom:12px"><span class="muted">筛选</span><select style="width:140px" value=${filter} onChange=${(e) => setFilter(e.target.value)}><option value="pending">待处理</option><option value="">全部</option><option value="allowed">已批准</option><option value="rejected">已拒绝</option><option value="expired">已过期</option></select>${err && html`<span class="muted">✗ ${err}</span>`}</div>- ${data && data.approvals.length === 0 && html`<p class="muted">暂无${filter ? AP_STATUS[filter] : ""}请求</p>`}- ${data && data.approvals.map((a) => html`<div class="card">+ ${list.length === 0 && html`<div class="empty">暂无${filter ? AP_STATUS[filter] : ""}请求</div>`}+ ${list.map((a) => html`<div class="card"><div class="row"><b>${a.kind === "question" ? "提问" : "需批准"} · ${a.code}</b><span class="badge ${a.status === "pending" ? "connecting" : a.status === "allowed" || a.status === "answered" ? "connected" : "disabled"}">${AP_STATUS[a.status] || a.status}</span><span class="muted">${a.botId} · ${a.conversationId} · ${fmt(a.createdAt)}${a.status === "pending" ? " · 截止 " + fmt(a.expiresAt) : a.decidedBy ? " · " + a.decidedBy : ""}</span></div>${a.kind === "approval" && html`<p><code>${a.tool}</code> <code>${a.detail}</code></p>${a.reason && html`<p class="muted">${a.reason}</p>`}`}@@ -301,24 +307,260 @@ function Approvals() {</div>`;}-// ---------------- 模型(magpie) -----------------const Models = () => html`<iframe class="magpie" src="/magpie/" title="magpie"></iframe>`;+const Models = ({ theme }) => html`<iframe class="magpie" src=${`/magpie/?theme=${theme}`} title="magpie"></iframe>`;++// ---------------- 中栏:对话 ----------------+function ChatPane({ bot, onToggleRight, rightOpen }) {+ const [text, setText] = useState("");+ const [log, setLog] = useState([]);+ const [busy, setBusy] = useState(false);+ const [convId, setConvId] = useState("");+ const bottom = useRef(null);+ const ta = useRef(null);++ // 加载该机器人最近的网页测试会话消息(若有)+ useEffect(() => {+ setLog([]); setConvId(""); setText("");+ let cancelled = false;+ (async () => {+ try {+ const data = await api("/conversations");+ const mine = (data.conversations || []).filter((c) => c.botId === bot.id && c.channel === "web");+ mine.sort((a, b) => (b.updatedAt || 0) - (a.updatedAt || 0));+ if (mine[0]) {+ setConvId(mine[0].id);+ const m = await api(`/conversations/${encodeURIComponent(mine[0].id)}/messages`);+ if (!cancelled) setLog((m.messages || []).map((x) => ({ role: x.role, content: x.content, at: x.createdAt })));+ }+ } catch (_) { /* 首次无会话 */ }+ })();+ return () => { cancelled = true; };+ }, [bot.id]);++ useEffect(() => { bottom.current?.scrollIntoView?.({ behavior: "smooth" }); }, [log, busy]);++ const sendMsg = async () => {+ const t = text.trim(); if (!t || busy) return;+ setText(""); setBusy(true);+ setLog((l) => [...l, { role: "user", content: t, at: Date.now() }]);+ try {+ const r = await api(`/bots/${bot.id}/chat`, { method: "POST", body: { text: t } });+ if (r.conversationId) setConvId(r.conversationId);+ const extra = [...(r.prompts || []).map((p) => ({ role: "prompt", content: p.prompt }))];+ const files = (r.files || []).map((f) => ({ role: "progress", content: "📎 已交付文件:" + f + "(微信/飞书会直接发送;网页端请在机器人工作区查看)" }));+ setLog((l) => [...l, ...extra, { role: "assistant", content: r.reply, at: Date.now() }, ...files]);+ } catch (e) {+ setLog((l) => [...l, { role: "assistant", content: "✗ " + e.message }]);+ }+ setBusy(false);+ ta.current?.focus?.();+ };++ const onKey = (e) => {+ if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); sendMsg(); }+ };++ return html`<div class="center">+ <div class="chat-head">+ <div>+ <div class="chat-head-title">${bot.name}</div>+ <div class="chat-head-sub">${bot.defaultModel || "自动模型"}${convId ? " · " + convId.slice(0, 8) : ""}</div>+ </div>+ <div class="chat-head-actions">+ <button class="ghost" title="切换右侧面板" onClick=${onToggleRight}>${rightOpen ? "收起详情" : "详情"}</button>+ </div>+ </div>+ <div class="transcript">+ ${log.length === 0 && !busy && html`<div class="empty-chat">+ <h2>和 ${bot.name} 对话</h2>+ <p>直接在此测试机器人。支持 <code>/model</code>、<code>/reset</code>、<code>/new</code>、<code>/help</code>。渠道与审批在右侧。</p>+ </div>`}+ ${log.map((m) => {+ if (m.role === "progress" || m.role === "prompt") {+ return html`<div class="msg-progress"><span class="dot"></span><span>${m.content}</span></div>`;+ }+ const role = m.role === "user" ? "user" : "assistant";+ return html`<div class=${`msg-row ${role}`}>+ <div class=${`msg-bubble ${role === "assistant" ? "" : ""}`}>${m.content}</div>+ ${m.at && html`<div class="msg-meta">${fmt(m.at)}</div>`}+ </div>`;+ })}+ ${busy && html`<div class="msg-progress"><span class="dot"></span><span>正在处理…</span></div>`}+ <div ref=${bottom}></div>+ </div>+ <div class="composer-wrap">+ <div class="composer">+ <textarea ref=${ta} rows="1" placeholder=${`给 ${bot.name} 发消息`}+ value=${text} onInput=${(e) => setText(e.target.value)} onKeyDown=${onKey}+ disabled=${busy} />+ <button class="send" disabled=${busy || !text.trim()} onClick=${sendMsg}>${busy ? "…" : "发送"}</button>+ </div>+ <div class="composer-hint">Enter 发送 · Shift+Enter 换行 · 指令 /model /reset /new /help</div>+ </div>+ </div>`;+}++// ---------------- 右栏 ----------------+function RightPane({ bot, models, onSaved, onDeleted, onClose }) {+ const [tab, setTab] = useState("channels");+ const tabs = [+ ["channels", "渠道"],+ ["settings", "设置"],+ ["memory", "记忆"],+ ["approvals", "审批"],+ ];+ return html`<div class="right">+ <div class="right-head">+ <div class="row" style="gap:8px">+ <div class="thread-avatar" style="width:28px;height:28px;font-size:12px">${initials(bot.name)}</div>+ <b style="font-size:14px">${bot.name}</b>+ </div>+ <button class="icon-btn" title="收起" onClick=${onClose}>✕</button>+ </div>+ <div class="right-tabs">+ ${tabs.map(([id, label]) => html`<button class=${tab === id ? "on" : ""} onClick=${() => setTab(id)}>${label}</button>`)}+ </div>+ <div class="right-body">+ ${tab === "channels" && html`<${ChannelsPanel} botId=${bot.id} />`}+ ${tab === "settings" && html`+ <${BotEditor} key=${bot.id} bot=${bot} models=${models} onSaved=${onSaved} onDeleted=${onDeleted} />+ <${BotSettings} key=${"s" + bot.id} botId=${bot.id} models=${models} />+ `}+ ${tab === "memory" && html`<${MemoryViewer} key=${"m" + bot.id} botId=${bot.id} />`}+ ${tab === "approvals" && html`<${Approvals} botId=${bot.id} compact=${true} />`}+ </div>+ </div>`;+}++// ---------------- 左栏 ----------------+function LeftRail({ bots, botId, setBotId, view, setView, themeMode, setThemeMode, onCreate }) {+ const [name, setName] = useState("");+ const [creating, setCreating] = useState(false);+ const [convs] = usePoll(() => api("/conversations"), 8000);+ const byBot = useMemo(() => {+ const map = {};+ for (const c of (convs && convs.conversations) || []) {+ if (!map[c.botId] || (c.updatedAt || 0) > (map[c.botId].updatedAt || 0)) map[c.botId] = c;+ }+ return map;+ }, [convs]);++ const create = async () => {+ const n = name.trim(); if (!n) return;+ setCreating(true);+ try {+ const r = await api("/bots", { method: "POST", body: { name: n } });+ setName(""); setCreating(false); onCreate(r.bot);+ } catch (e) { alert(e.message); setCreating(false); }+ };++ return html`<div class="left">+ <div class="brand">+ <${Mark} />+ <div>+ <div class="brand-name">anymodel bot</div>+ <div class="brand-sub">本机控制台</div>+ </div>+ </div>+ <div class="left-tools">+ <button class="grow-btn" onClick=${() => setCreating((v) => !v)}>+ 新建机器人</button>+ </div>+ ${creating && html`<div style="padding:0 12px 10px">+ <div class="row">+ <input class="grow" style="width:auto" placeholder="名称" value=${name} onInput=${(e) => setName(e.target.value)}+ onKeyDown=${(e) => e.key === "Enter" && create()} />+ <button class="pri" disabled=${!name.trim()} onClick=${create}>创建</button>+ </div>+ </div>`}+ <div class="left-scroll">+ <div class="sec-label">机器人</div>+ ${(bots || []).map((b) => {+ const snip = byBot[b.id];+ return html`<button type="button" class=${`thread ${view === "chat" && b.id === botId ? "sel" : ""}`}+ onClick=${() => { setBotId(b.id); setView("chat"); }}>+ <div class="thread-avatar">${initials(b.name)}</div>+ <div class="thread-body">+ <div class="thread-title">${b.name}</div>+ <div class="thread-snip">${snip ? (snip.lastMessage || snip.title || snip.channel) : (b.defaultModel || "尚未对话")}</div>+ ${snip && html`<div class="thread-meta">${fmt(snip.updatedAt)}</div>`}+ </div>+ </button>`;+ })}+ ${(!bots || bots.length === 0) && html`<div class="empty" style="margin:8px">还没有机器人。点上方新建。</div>`}+ </div>+ <div class="left-foot">+ <div class="admin-links">+ <button class=${view === "overview" ? "on" : ""} onClick=${() => setView("overview")}>概览</button>+ <button class=${view === "approvals" ? "on" : ""} onClick=${() => setView("approvals")}>审批</button>+ <button class=${view === "conversations" ? "on" : ""} onClick=${() => setView("conversations")}>会话</button>+ <button class=${view === "models" ? "on" : ""} onClick=${() => setView("models")}>模型</button>+ </div>+ <div class="theme-toggle">+ <button class=${themeMode === "system" ? "on" : ""} onClick=${() => setThemeMode("system")}>系统</button>+ <button class=${themeMode === "light" ? "on" : ""} onClick=${() => setThemeMode("light")}>浅色</button>+ <button class=${themeMode === "dark" ? "on" : ""} onClick=${() => setThemeMode("dark")}>深色</button>+ </div>+ </div>+ </div>`;+}// ---------------- 外壳 -----------------const TABS = [["overview", "概览"], ["bots", "机器人"], ["channels", "渠道"], ["conversations", "会话"], ["approvals", "审批"], ["models", "模型"]];function App() {- const [tab, setTab] = useState(location.hash.slice(1) || "overview");+ const hash = location.hash.slice(1);+ const initialView = ["overview", "approvals", "conversations", "models", "chat"].includes(hash) ? hash : "chat";+ const [view, setViewRaw] = useState(initialView);const [botId, setBotId] = useState("");- const go = (t) => { setTab(t); location.hash = t; };- return html`<div class="layout">- <nav><h1>anymodel bot</h1>${TABS.map(([id, label]) => html`<a class=${tab === id ? "active" : ""} onClick=${() => go(id)}>${label}</a>`)}</nav>- <main class=${tab === "models" ? "full" : ""}>- ${tab === "overview" && html`<${Overview} go=${go} />`}- ${tab === "bots" && html`<${Bots} botId=${botId} setBotId=${setBotId} />`}- ${tab === "channels" && html`<${Channels} botId=${botId} setBotId=${setBotId} />`}- ${tab === "conversations" && html`<${Conversations} />`}- ${tab === "approvals" && html`<${Approvals} />`}- ${tab === "models" && html`<${Models} />`}- </main></div>`;+ const [rightOpen, setRightOpen] = useState(true);+ const [themeMode, setThemeMode, theme] = useTheme();+ const [botsData, , reloadBots] = usePoll(() => api("/bots"), 0);+ const [models] = usePoll(() => api("/models"), 0);++ const setView = (v) => { setViewRaw(v); location.hash = v; };+ useEffect(() => {+ const onHash = () => {+ const h = location.hash.slice(1);+ if (["overview", "approvals", "conversations", "models", "chat"].includes(h)) setViewRaw(h);+ };+ window.addEventListener("hashchange", onHash);+ return () => window.removeEventListener("hashchange", onHash);+ }, []);++ const bots = botsData ? botsData.bots : null;+ const bot = bots && (bots.find((b) => b.id === botId) || bots[0]);+ useEffect(() => { if (bot && bot.id !== botId) setBotId(bot.id); }, [bots, bot && bot.id]);++ const shellClass = [+ "app",+ view === "chat" && !rightOpen ? "right-collapsed" : "",+ view === "models" ? "view-models" : "",+ view !== "chat" && view !== "models" ? "view-admin" : "",+ ].filter(Boolean).join(" ");++ return html`<div class=${shellClass}>+ <${LeftRail}+ bots=${bots || []}+ botId=${bot && bot.id}+ setBotId=${setBotId}+ view=${view}+ setView=${setView}+ themeMode=${themeMode}+ setThemeMode=${setThemeMode}+ onCreate=${(b) => { reloadBots(); setBotId(b.id); setView("chat"); }}+ />+ ${view === "chat" && bot && html`<${ChatPane} bot=${bot} rightOpen=${rightOpen} onToggleRight=${() => setRightOpen((v) => !v)} />`}+ ${view === "chat" && !bot && html`<div class="center"><div class="transcript"><div class="empty-chat"><h2>开始</h2><p>在左侧新建一个机器人,然后直接对话。</p></div></div></div>`}+ ${view === "overview" && html`<div class="admin-pane"><${Overview} goChat=${() => setView("chat")} /></div>`}+ ${view === "approvals" && html`<div class="admin-pane"><${Approvals} /></div>`}+ ${view === "conversations" && html`<div class="admin-pane"><${ConversationsAdmin} onOpen=${(c) => { setBotId(c.botId); setView("chat"); }} /></div>`}+ ${view === "models" && html`<div class="admin-pane bleed"><${Models} theme=${theme} /></div>`}+ ${view === "chat" && rightOpen && bot && html`<${RightPane}+ bot=${bot}+ models=${models && models.models}+ onSaved=${() => reloadBots()}+ onDeleted=${() => { setBotId(""); reloadBots(); }}+ onClose=${() => setRightOpen(false)}+ />`}+ </div>`;}+render(html`<${App} />`, document.getElementById("app"));diff --git a/ui/index.html b/ui/index.htmlindex ac2a280..a3de56c 100644--- a/ui/index.html+++ b/ui/index.html@@ -8,6 +8,14 @@<script type="importmap">{ "imports": { "preact": "/amb/vendor/preact.mjs", "preact/hooks": "/amb/vendor/hooks.mjs", "htm": "/amb/vendor/htm.mjs" } }</script>+ <script>+ (function () {+ try {+ var m = localStorage.getItem("amb-theme");+ if (m === "light" || m === "dark") document.documentElement.setAttribute("data-theme", m);+ } catch (_) {}+ })();+ </script></head><body><div id="app">加载中…</div>diff --git a/ui/style.css b/ui/style.cssindex 645bf82..5979874 100644--- a/ui/style.css+++ b/ui/style.css@@ -1,39 +1,458 @@-:root { --bg:#f6f7f9; --card:#fff; --fg:#1d2129; --muted:#86909c; --line:#e5e6eb; --pri:#3370ff; --ok:#00b42a; --warn:#ff7d00; --err:#f53f3f; }-@media (prefers-color-scheme: dark) { :root { --bg:#17171a; --card:#232324; --fg:#e5e6eb; --muted:#8a8f99; --line:#333335; } }-* { box-sizing: border-box; }-body { margin:0; font:14px/1.5 -apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif; background:var(--bg); color:var(--fg); }-.layout { display:flex; height:100vh; }-nav { width:180px; background:var(--card); border-right:1px solid var(--line); padding:16px 8px; flex-shrink:0; }-nav h1 { font-size:16px; margin:0 8px 16px; }-nav a { display:block; padding:8px 12px; border-radius:6px; color:inherit; text-decoration:none; cursor:pointer; }-nav a.active { background:var(--pri); color:#fff; }-main { flex:1; overflow:auto; padding:20px 24px; }-main.full { padding:0; overflow:hidden; }-.card { background:var(--card); border:1px solid var(--line); border-radius:8px; padding:16px; margin-bottom:16px; }-.row { display:flex; gap:12px; align-items:center; flex-wrap:wrap; }-.grow { flex:1; }-label { display:block; margin:8px 0 4px; color:var(--muted); font-size:12px; }-input, textarea, select { width:100%; padding:7px 10px; border:1px solid var(--line); border-radius:6px; background:var(--bg); color:var(--fg); font:inherit; }-textarea { min-height:90px; resize:vertical; }-button { padding:6px 14px; border-radius:6px; border:1px solid var(--line); background:var(--card); color:var(--fg); cursor:pointer; font:inherit; }-button.pri { background:var(--pri); border-color:var(--pri); color:#fff; }-button.danger { color:var(--err); }-button:disabled { opacity:.5; cursor:default; }-.badge { display:inline-block; padding:1px 8px; border-radius:10px; font-size:12px; background:var(--line); }-.badge.connected,.badge.running,.badge.confirmed { background:#e8ffea; color:var(--ok); }-.badge.error,.badge.failed,.badge.expired { background:#ffece8; color:var(--err); }-.badge.connecting,.badge.starting,.badge.restarting,.badge.wait,.badge.scaned { background:#fff7e8; color:var(--warn); }-.muted { color:var(--muted); font-size:12px; }-.list .item { padding:10px 12px; border-bottom:1px solid var(--line); cursor:pointer; }-.list .item.sel, .list .item:hover { background:var(--bg); }-.msgs { display:flex; flex-direction:column; gap:8px; }-.msg { max-width:80%; padding:8px 12px; border-radius:8px; white-space:pre-wrap; word-break:break-word; }-.msg.user { align-self:flex-end; background:var(--pri); color:#fff; }-.msg.assistant { align-self:flex-start; background:var(--card); border:1px solid var(--line); }-.qr { width:240px; height:240px; image-rendering:pixelated; background:#fff; padding:8px; border-radius:8px; }-iframe.magpie { border:0; width:100%; height:100vh; display:block; }-.notice { padding:8px 12px; border-radius:6px; background:#fff7e8; color:#a35200; margin-bottom:8px; }-.cols { display:grid; grid-template-columns: 300px 1fr; gap:16px; }-code { background:var(--bg); padding:1px 4px; border-radius:4px; }-.msg.progress { font-size:12px; color:var(--muted, #888); background:transparent; border:none; padding:2px 12px; }-.msg.prompt { border-color:#e6a23c; background:#fdf6ec; color:#333; }+/* anymodel bot — chat-first shell.+ Taste framed-sheet density + Magpie greys/indigo (not Taste teal, not Grok orange).+ Columns: left 280 | center 1fr | right 320 (collapsible). */++:root {+ --bg: #f4f4f6;+ --card: #ffffff;+ --card-2: #f9f9fb;+ --pill: #f1f1f4;+ --pill-hover: #e9e9ee;+ --line: #e3e3e8;+ --line-2: #ececf0;+ --fg: #1c1c21;+ --fg-2: #4b4b53;+ --muted: #85858d;+ --faint: #b9b9c2;+ --ctl-fg: #63636b;+ --accent: #4f46e5; /* taste-skill-ignore: magpie indigo fusion — not Taste teal */+ --accent-soft: #eeedfd;+ --accent-fg: #ffffff;+ --sel: #ecebfb;+ --green: #189a58;+ --green-soft: #e4f6ec;+ --red: #d64545;+ --red-soft: #fbe9e9;+ --amber: #b45309;+ --amber-soft: #fbf0df;+ --primary: #1c1c21;+ --primary-fg: #ffffff;+ --active: #e9e9ee;+ --bubble-user: #4f46e5; /* taste-skill-ignore: magpie indigo fusion — not Taste teal */+ --bubble-user-fg: #ffffff;+ --composer: #ffffff;+ --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;+ --code: ui-monospace, "SF Mono", Menlo, Consolas, monospace;+ --left-w: 280px;+ --right-w: 340px;+ --radius: 10px;+ --radius-lg: 16px;+ --control-h: 32px;+ --fs-body: 14px;+ --fs-small: 12px;+ --fs-title: 16px;+}++@media (prefers-color-scheme: dark) {+ :root:not([data-theme="light"]) {+ --bg: #1a1a1e;+ --card: #232327;+ --card-2: #1f1f23;+ --pill: #2d2d33;+ --pill-hover: #36363d;+ --line: #333339;+ --line-2: #2c2c32;+ --fg: #ededf1;+ --fg-2: #b9b9c1;+ --muted: #8b8b94;+ --faint: #56565f;+ --ctl-fg: #a1a1aa;+ --accent: #a5b4fc;+ --accent-soft: #2b2c47;+ --accent-fg: #14142a;+ --sel: #33345a;+ --green: #6fd99b;+ --green-soft: #1e3a2b;+ --red: #f28b82;+ --red-soft: #45272a;+ --amber: #f2b544;+ --amber-soft: #3f3220;+ --primary: #ededf1;+ --primary-fg: #1a1a1e;+ --active: #2d2d33;+ --bubble-user: #4f46e5; /* taste-skill-ignore: magpie indigo fusion — not Taste teal */+ --bubble-user-fg: #ffffff;+ --composer: #2d2d33;+ }+}+:root[data-theme="dark"] {+ --bg: #1a1a1e; --card: #232327; --card-2: #1f1f23; --pill: #2d2d33; --pill-hover: #36363d;+ --line: #333339; --line-2: #2c2c32; --fg: #ededf1; --fg-2: #b9b9c1; --muted: #8b8b94; --faint: #56565f; --ctl-fg: #a1a1aa;+ --accent: #a5b4fc; --accent-soft: #2b2c47; --accent-fg: #14142a; --sel: #33345a;+ --green: #6fd99b; --green-soft: #1e3a2b; --red: #f28b82; --red-soft: #45272a; --amber: #f2b544; --amber-soft: #3f3220;+ --primary: #ededf1; --primary-fg: #1a1a1e; --active: #2d2d33;+ --bubble-user: #4f46e5; --bubble-user-fg: #ffffff; --composer: #2d2d33; /* taste-skill-ignore: magpie indigo fusion — not Taste teal */+}+:root[data-theme="light"] {+ --bg: #f4f4f6; --card: #ffffff; --card-2: #f9f9fb; --pill: #f1f1f4; --pill-hover: #e9e9ee;+ --line: #e3e3e8; --line-2: #ececf0; --fg: #1c1c21; --fg-2: #4b4b53; --muted: #85858d; --faint: #b9b9c2; --ctl-fg: #63636b;+ --accent: #4f46e5; --accent-soft: #eeedfd; --accent-fg: #ffffff; --sel: #ecebfb; /* taste-skill-ignore: magpie indigo fusion — not Taste teal */+ --green: #189a58; --green-soft: #e4f6ec; --red: #d64545; --red-soft: #fbe9e9; --amber: #b45309; --amber-soft: #fbf0df;+ --primary: #1c1c21; --primary-fg: #ffffff; --active: #e9e9ee;+ --bubble-user: #4f46e5; --bubble-user-fg: #ffffff; --composer: #ffffff; /* taste-skill-ignore: magpie indigo fusion — not Taste teal */+}++*, *::before, *::after { box-sizing: border-box; }+html, body { height: 100%; }+body {+ margin: 0;+ font: var(--fs-body)/1.5 var(--font);+ background: var(--bg);+ color: var(--fg);+ -webkit-font-smoothing: antialiased;+}+button, input, textarea, select { font: inherit; color: inherit; }+a { color: var(--accent); }+code, .mono { font-family: var(--code); font-size: .92em; font-variant-numeric: tabular-nums; }+.num { font-variant-numeric: tabular-nums; }++/* —— App shell: 3 columns —— */+.app {+ display: grid;+ grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w);+ height: 100vh;+ background: var(--bg);+}+.app.right-collapsed { grid-template-columns: var(--left-w) minmax(0, 1fr) 0; }+.app.right-collapsed .right { display: none; }+.app.view-admin { grid-template-columns: var(--left-w) minmax(0, 1fr); }+.app.view-admin .right { display: none; }+.app.view-models { grid-template-columns: var(--left-w) minmax(0, 1fr); }+.app.view-models .right { display: none; }++.left, .center, .right {+ min-height: 0;+ min-width: 0;+ display: flex;+ flex-direction: column;+}+.left {+ border-right: 1px solid var(--line);+ background: var(--bg);+}+.center {+ background: var(--card);+}+.right {+ border-left: 1px solid var(--line);+ background: var(--bg);+}++/* Left rail */+.brand {+ display: flex;+ align-items: center;+ gap: 10px;+ padding: 16px 16px 12px;+}+.brand-mark {+ width: 32px; height: 32px;+ border-radius: 10px;+ background: var(--accent-soft);+ color: var(--accent);+ display: grid; place-items: center;+ flex-shrink: 0;+}+.brand-mark svg { display: block; }+.brand-name { font-size: 14px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }+.brand-sub { font-size: 11px; color: var(--muted); line-height: 1.2; }++.left-tools {+ display: flex; gap: 6px; padding: 0 12px 10px;+}+.left-tools button, .icon-btn {+ height: 30px; width: 30px;+ display: grid; place-items: center;+ border: 1px solid var(--line);+ border-radius: 8px;+ background: var(--card);+ color: var(--ctl-fg);+ cursor: pointer;+ padding: 0;+}+.left-tools button:hover, .icon-btn:hover { background: var(--pill); color: var(--fg); }+.left-tools .grow-btn {+ flex: 1; width: auto; padding: 0 10px;+ font-size: 12px; font-weight: 500;+ justify-content: center; display: flex; align-items: center; gap: 6px;+}++.left-scroll { flex: 1; overflow: auto; padding: 0 8px 8px; }+.sec-label {+ font-size: 11px; color: var(--muted); font-weight: 500;+ padding: 10px 8px 6px; letter-spacing: .01em;+}+.thread {+ display: flex; gap: 10px; align-items: flex-start;+ padding: 10px 10px; border-radius: 10px; cursor: pointer;+ border: none; background: transparent; width: 100%; text-align: left; color: inherit;+}+.thread:hover { background: var(--pill); }+.thread.sel { background: var(--active); }+.thread-avatar {+ width: 36px; height: 36px; border-radius: 50%;+ background: var(--accent-soft); color: var(--accent);+ display: grid; place-items: center; font-size: 13px; font-weight: 600;+ flex-shrink: 0;+}+.thread-body { min-width: 0; flex: 1; }+.thread-title {+ font-size: 13px; font-weight: 500; color: var(--fg);+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis;+}+.thread-snip {+ font-size: 12px; color: var(--muted);+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis;+ margin-top: 2px;+}+.thread-meta { font-size: 11px; color: var(--faint); margin-top: 2px; }++.left-foot {+ border-top: 1px solid var(--line);+ padding: 10px 12px;+ display: flex; flex-direction: column; gap: 8px;+}+.admin-links { display: flex; flex-wrap: wrap; gap: 4px; }+.admin-links button {+ height: 28px; padding: 0 10px; border-radius: 999px;+ border: 1px solid transparent; background: transparent;+ color: var(--ctl-fg); font-size: 12px; cursor: pointer;+}+.admin-links button:hover, .admin-links button.on {+ background: var(--pill); color: var(--fg);+}+.theme-toggle {+ display: flex; gap: 3px; background: var(--pill); border-radius: 8px; padding: 3px;+}+.theme-toggle button {+ flex: 1; height: 26px; border: none; border-radius: 6px;+ background: transparent; color: var(--ctl-fg); cursor: pointer; font-size: 11px;+}+.theme-toggle button.on {+ background: var(--card); color: var(--fg);+ box-shadow: 0 1px 2px rgba(0,0,0,.08); /* taste-skill-ignore: focus ring / floating control only */+}++/* Center chat */+.chat-head {+ height: 52px; flex-shrink: 0;+ display: flex; align-items: center; justify-content: space-between;+ gap: 12px; padding: 0 16px;+ border-bottom: 1px solid var(--line);+ background: var(--card);+}+.chat-head-title { font-size: var(--fs-title); font-weight: 600; letter-spacing: -.01em; }+.chat-head-sub { font-size: 12px; color: var(--muted); }+.chat-head-actions { display: flex; gap: 6px; align-items: center; }++.transcript {+ flex: 1; overflow: auto; padding: 20px 24px 12px;+ display: flex; flex-direction: column; gap: 12px;+}+.transcript .empty-chat {+ margin: auto; text-align: center; color: var(--muted); max-width: 360px;+ padding: 32px 16px;+}+.transcript .empty-chat h2 {+ margin: 0 0 8px; font-size: 18px; font-weight: 600; color: var(--fg);+}+.msg-row { display: flex; flex-direction: column; gap: 4px; max-width: 720px; width: 100%; margin: 0 auto; }+.msg-row.user { align-items: flex-end; }+.msg-row.assistant { align-items: flex-start; }+.msg-bubble {+ max-width: 85%;+ padding: 10px 14px;+ border-radius: 14px;+ white-space: pre-wrap; word-break: break-word;+ font-size: 14px; line-height: 1.5;+}+.msg-row.user .msg-bubble {+ background: var(--bubble-user); color: var(--bubble-user-fg);+ border-bottom-right-radius: 4px;+}+.msg-row.assistant .msg-bubble {+ background: transparent; color: var(--fg); padding: 4px 2px;+}+.msg-row.assistant .msg-bubble.cardish {+ background: var(--card-2); border: 1px solid var(--line); padding: 10px 14px;+}+.msg-meta { font-size: 11px; color: var(--muted); padding: 0 4px; }+.msg-progress {+ display: flex; align-items: center; gap: 8px;+ font-size: 13px; color: var(--muted); padding: 4px 2px;+ max-width: 720px; width: 100%; margin: 0 auto;+}+.msg-progress .dot {+ width: 8px; height: 8px; border-radius: 50%; background: var(--accent);+ animation: pulse 1.2s ease-in-out infinite;+}+@keyframes pulse { 0%,100%{ opacity:.35 } 50%{ opacity:1 } }++.composer-wrap {+ flex-shrink: 0; padding: 12px 20px 16px;+ background: var(--card);+}+.composer {+ display: flex; align-items: flex-end; gap: 8px;+ background: var(--composer);+ border: 1px solid var(--line);+ border-radius: 14px;+ padding: 8px 10px;+}+.composer:focus-within {+ border-color: var(--accent);+ box-shadow: 0 0 0 3px var(--accent-soft); /* taste-skill-ignore: focus ring / floating control only */+}+.composer textarea {+ flex: 1; border: none; background: transparent; resize: none;+ min-height: 24px; max-height: 160px; padding: 6px 4px;+ outline: none; line-height: 1.45;+}+.composer .send {+ height: 32px; min-width: 64px; padding: 0 14px;+ border-radius: 10px; border: none;+ background: var(--primary); color: var(--primary-fg);+ font-weight: 500; cursor: pointer;+}+.composer .send:disabled { opacity: .4; cursor: default; }+.composer-hint {+ margin-top: 6px; font-size: 11px; color: var(--muted); padding: 0 4px;+}++/* Right panel */+.right-head {+ height: 52px; flex-shrink: 0;+ display: flex; align-items: center; justify-content: space-between;+ padding: 0 14px; border-bottom: 1px solid var(--line);+}+.right-tabs {+ display: flex; gap: 2px; padding: 8px 10px 0; flex-shrink: 0;+ border-bottom: 1px solid var(--line);+}+.right-tabs button {+ height: 32px; padding: 0 12px; border: none; background: transparent;+ color: var(--ctl-fg); font-size: 13px; cursor: pointer;+ border-bottom: 2px solid transparent; border-radius: 0; margin-bottom: -1px;+}+.right-tabs button.on {+ color: var(--fg); font-weight: 500; border-bottom-color: var(--accent);+}+.right-body { flex: 1; overflow: auto; padding: 14px; }++/* Shared controls / cards inside panels & admin */+.card {+ background: var(--card);+ border: 1px solid var(--line);+ border-radius: var(--radius);+ padding: 14px 16px;+ margin-bottom: 12px;+ box-shadow: none; /* taste-skill-ignore: focus ring / floating control only */+}+.card > h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }+.card h4 { margin: 12px 0 6px; font-size: 12px; font-weight: 500; color: var(--fg-2); }+.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }+.grow { flex: 1; min-width: 0; }+.muted { color: var(--muted); font-size: var(--fs-small); }+label {+ display: block; margin: 10px 0 5px;+ color: var(--fg-2); font-size: var(--fs-small); font-weight: 500;+}+label.row { margin: 6px 0; font-weight: 400; color: var(--fg); gap: 8px; }+input, textarea, select {+ width: 100%; height: var(--control-h); padding: 0 10px;+ border: 1px solid var(--line); border-radius: 8px;+ background: var(--card); color: var(--fg);+}+textarea { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; line-height: 1.45; }+input:focus, textarea:focus, select:focus {+ outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); /* taste-skill-ignore: focus ring / floating control only */+}+input[type="checkbox"] { width: 15px; height: 15px; padding: 0; accent-color: var(--accent); }+button {+ height: var(--control-h); padding: 0 12px; border-radius: 8px;+ border: 1px solid var(--line); background: var(--card); color: var(--fg);+ cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap;+}+button:hover:not(:disabled) { background: var(--pill); }+button.pri { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }+button.pri:hover:not(:disabled) { filter: brightness(1.08); }+button.danger { color: var(--red); }+button.danger:hover:not(:disabled) { background: var(--red-soft); }+button:disabled { opacity: .45; cursor: default; }+button.ghost { border-color: transparent; background: transparent; color: var(--ctl-fg); }+button.ghost:hover:not(:disabled) { background: var(--pill); color: var(--fg); }++.badge {+ display: inline-flex; align-items: center; height: 20px; padding: 0 8px;+ border-radius: 999px; font-size: 11px; font-weight: 500;+ background: var(--pill); color: var(--fg-2); white-space: nowrap; flex: none;+}+.badge.connected, .badge.running, .badge.confirmed, .badge.allowed, .badge.answered {+ background: var(--green-soft); color: var(--green);+}+.badge.error, .badge.failed, .badge.expired, .badge.rejected, .badge.cancelled {+ background: var(--red-soft); color: var(--red);+}+.badge.connecting, .badge.starting, .badge.restarting, .badge.wait, .badge.scaned,+.badge.need_verifycode, .badge.fetching, .badge.pending {+ background: var(--amber-soft); color: var(--amber);+}+.badge.disabled, .badge.stopped, .badge.paused, .badge.idle, .badge.login_required {+ background: var(--pill); color: var(--muted);+}++.list .item {+ padding: 10px 12px; border-bottom: 1px solid var(--line-2); cursor: pointer;+}+.list .item:last-child { border-bottom: none; }+.list .item:hover { background: var(--card-2); }+.list .item.sel { background: var(--sel); }+.notice {+ padding: 8px 12px; border-radius: 8px; margin-bottom: 8px; font-size: 13px;+ background: var(--amber-soft); color: var(--amber);+ border: 1px solid color-mix(in srgb, var(--amber) 25%, transparent);+}+.empty {+ border: 1px dashed var(--line); border-radius: 8px; padding: 14px; color: var(--muted); font-size: 13px;+}+.qr {+ width: 200px; height: 200px; image-rendering: pixelated;+ background: #fff; padding: 8px; border-radius: 8px; border: 1px solid var(--line);+}+details { margin-top: 8px; }+details summary { cursor: pointer; color: var(--ctl-fg); font-size: 13px; }+details summary:hover { color: var(--fg); }+table { width: 100%; border-collapse: collapse; font-size: 13px; }+th {+ text-align: left; font-size: 11px; font-weight: 400; color: var(--muted);+ padding: 6px 8px; border-bottom: 1px solid var(--line);+}+td { padding: 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }+.cols { display: grid; grid-template-columns: 260px 1fr; gap: 12px; align-items: start; }++/* Admin / models overlay views in center */+.admin-pane {+ flex: 1; overflow: auto; padding: 20px 24px; background: var(--card);+}+.admin-pane.bleed { padding: 0; overflow: hidden; }+.page-head { margin-bottom: 16px; }+.page-head h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.02em; }+.page-head .sub { margin: 4px 0 0; font-size: 13px; color: var(--muted); }+.kpi-strip {+ display: grid; grid-template-columns: repeat(4, 1fr);+ border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px;+}+.kpi-strip .kpi { padding: 12px 14px; border-right: 1px solid var(--line); }+.kpi-strip .kpi:last-child { border-right: none; }+.kpi-strip .kpi .lbl { font-size: 12px; color: var(--muted); margin-bottom: 4px; }+.kpi-strip .kpi .val { font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }+iframe.magpie { border: 0; width: 100%; height: 100%; display: block; background: var(--bg); }++@media (max-width: 960px) {+ .app, .app.right-collapsed, .app.view-admin, .app.view-models {+ grid-template-columns: 1fr;+ grid-template-rows: auto 1fr;+ }+ .left { border-right: none; border-bottom: 1px solid var(--line); max-height: 40vh; }+ .right { display: none !important; }+}