A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Block a Bot on a failed turn and resume it once the model is fixed
AdamPlatin1230214bb5bc940
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 0c7d9bf8..fb6153f5 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -200,6 +200,41 @@ var ZH = {"Sign in to DeepSeek": "登录 DeepSeek 账号","Enter a DeepSeek API key": "填入 DeepSeek API key","Open settings to set up a custom model": "打开设置配置自定义模型",+ "Create a key on the DeepSeek platform ↗": "去 DeepSeek 开放平台创建 Key ↗",+ "The API is billed by usage; the account needs a balance first.": "API 按用量计费,账户里要先有余额。",+ "Models and API keys": "模型和 API Key",+ // A failed turn in a Bot's chat+ "{name}'s model has no API key yet.": "{name} 用的模型还没有 API Key。",+ "This API key is not in the right format.": "这个 API Key 的格式不对。",+ "{provider} did not accept the current API key.": "{provider} 不接受现在的 API Key。",+ "{provider} did not accept the current API key ({status}).": "{provider} 不接受现在的 API Key({status})。",+ "{provider} is out of balance or quota.": "{provider} 的余额或额度不够了。",+ "{provider} is out of balance or quota ({status}).": "{provider} 的余额或额度不够了({status})。",+ "The DeepSeek account balance is too low.": "DeepSeek 账号余额不足。",+ "The DeepSeek account sign-in has expired.": "DeepSeek 账号的登录失效了。",+ "Could not reach the model service.": "连不上模型服务。",+ "Too many requests. Wait a moment, then try again.": "请求太频繁,稍等一会儿再试。",+ "The model service failed.": "模型服务出错了。",+ "DeepSeek Harness stopped before this turn finished.": "这一轮还没完成,DeepSeek Harness 就停下了。",+ "This turn failed.": "这一轮运行失败了。",+ "The model service": "模型服务",+ "DeepSeek account": "DeepSeek 账号",+ "This Bot": "这个 Bot",+ "Enter API key": "填入 API Key",+ "Enter the key again": "重新填 Key",+ "Sign in with a DeepSeek account": "用 DeepSeek 账号登录",+ "Use a DeepSeek account instead": "改用账号登录",+ "Use the DeepSeek account": "改用 DeepSeek 账号",+ "Sign in again": "重新登录",+ "Pick another model": "换个模型",+ "Top up ↗": "去充值 ↗",+ Retry: "重试",+ "Retrying…": "正在重试…",+ "Technical details": "技术详情",+ Code: "代码",+ "HTTP status": "HTTP 状态码",+ "Request ID": "请求 ID",+ "Provider message": "原文","DS Bot": "DS Bot",// Header"Message {name}": "给 {name} 发消息",@@ -390,6 +425,7 @@ var ZH = {"Upload photo": "上传照片","A Bot named {name} already exists": "已经有叫 {name} 的 Bot 了","The Bot runs on this model. You can change it later in its details.": "Bot 会使用这个模型。以后可以在详情里修改。",+ "Pick a model here, or the Bot asks for one in its chat.": "在这里选一个模型,或者之后由 Bot 在聊天里问你。","Add a provider and a model in DeepSeek Harness first, or pick one in the Bot's chat later.": "请先在 DeepSeek Harness 里添加服务商和模型,或者稍后在 Bot 的对话里选择。","Creating…": "创建中…",Create: "创建",@@ -487,7 +523,7 @@ var ZH = {"DS Bot settings": "DS Bot 设置","Settings pages": "设置页面","Models, providers, and the rest of DeepSeek Harness": "模型、服务商和 DeepSeek Harness 的其他设置",- "Harness settings": "Harness 设置",+ "Advanced settings (DeepSeek Harness)": "高级设置(DeepSeek Harness)","Back to Bots": "返回 Bot 列表","Close settings": "关闭设置",// Context menu@@ -630,6 +666,7 @@ var ZH = {"{name} was cut off by a restart again and stopped": "{name} 的工作又被重启打断,已停下","Picked up its work after a restart": "重启后接着做之前的工作","Asked to make the tool call it wrote as text": "工具调用被写成了文字,已让它重新调用",+ "Went on after the failed turn": "上一轮失败后,已让它接着做","A Bot": "一个 Bot","{name} is waiting for your approval": "{name} 等你批准","{first} and {second} are waiting for your approval": "{first}、{second} 等你批准",@@ -970,6 +1007,11 @@ var ZH = {"Could not reach DSH. Check that it is still running.": "连不上 DSH,请确认它还在运行。","{name} could not answer: {reason}": "{name} 没能回答:{reason}","Unknown error": "未知错误",+ "The model has no API key": "模型还没有 API Key",+ "The API key is not in the right format": "API Key 格式不对",+ "The DeepSeek account needs a sign-in": "DeepSeek 账号需要登录",+ "The DeepSeek account is signed out": "DeepSeek 账号已退出登录",+ "The DeepSeek account sign-in has expired": "DeepSeek 账号的登录失效了","The API key was rejected": "API 密钥无效","The account is out of quota": "账户额度已用尽","Too many requests to the model": "模型请求太频繁",@@ -1029,8 +1071,8 @@ var ZH = {Unit: "单位","Create task": "创建任务","Turn on Automation tasks in DSH": "在 DSH 里打开「自动化任务」",- "Switch on Automation tasks on the Plugins page in Harness settings.": "在 Harness 设置的插件页启用「自动化任务」。",- "Open Harness settings": "打开 Harness 设置",+ "Switch on Automation tasks on the Plugins page in Advanced settings (DeepSeek Harness).": "在「高级设置(DeepSeek Harness)」的插件页启用「自动化任务」。",+ "Open Advanced settings (DeepSeek Harness)": "打开高级设置(DeepSeek Harness)","New task": "新建任务","No scheduled tasks yet.": "还没有定时任务。","No scheduled tasks yet. Add one": "还没有定时任务,去添加",@@ -1135,7 +1177,7 @@ var HOST_ZH = {"A name uses capitals, digits, and underscores, and starts with a letter": "名字只能用大写字母、数字和下划线,并以字母开头","No such key": "没有这个密钥","Type a question or a change first": "请先输入问题或要改的内容",- "No model is available. Add one in Harness settings.": "没有可用的模型,请先在 Harness 设置里添加模型。",+ "No model is available. Add one in Settings > Models.": "没有可用的模型,请先在 设置 → 模型 里添加。","Memory is turned off on this host": "这台主机关闭了记忆功能","The model wrote nothing": "模型没有输出内容","Write the entry to save.": "请写下要保存的内容。",@@ -1234,9 +1276,14 @@ function clientFacts() {};}var FAILURES = {+ MISSING_CREDENTIAL: "The model has no API key",+ INVALID_CREDENTIAL: "The API key is not in the right format",AUTH: "The API key was rejected",QUOTA: "The account is out of quota",ACCOUNT_QUOTA: "The account is out of quota",+ ACCOUNT_SIGN_IN_REQUIRED: "The DeepSeek account needs a sign-in",+ ACCOUNT_SIGNED_OUT: "The DeepSeek account is signed out",+ ACCOUNT_TOKEN_INVALID: "The DeepSeek account sign-in has expired",RATE_LIMIT: "Too many requests to the model",CONTEXT_WINDOW_EXCEEDED: "The conversation is too long for the model",INVALID_REQUEST: "The model service refused the request",@@ -1246,9 +1293,9 @@ var FAILURES = {SESSION: "Its group conversation could not open",SESSION_RESET: "Its group conversation could not open, so it starts a new one next time"};+var knownFailure = (code) => Object.hasOwn(FAILURES, code ?? "") ? t(FAILURES[code]) : void 0;function failureLabel(code, message) {- if (FAILURES[code]) return t(FAILURES[code]);- return message || code || t("Unknown error");+ return knownFailure(code) ?? (message || code || t("Unknown error"));}var URL_LIMIT = 7e3;var WHAT_MAX = 2e3;@@ -1412,8 +1459,8 @@ function bodyOf(def, paint, flat = false) {return "";}}-var eyeMarkup = ([cx, cy, w, h43, tilt]) => `<g transform="translate(${cx} ${cy}) rotate(${tilt})"><rect class="bt-eye" x="${-w / 2}" y="${-h43 / 2}" width="${w}" height="${h43}" rx="${w / 2}"/></g>`;-var happyEyeMarkup = ([cx, cy, w, h43, tilt]) => `<g transform="translate(${cx} ${cy}) rotate(${tilt})"><path class="bt-eye-happy" opacity="0" d="M${-w * 0.62} ${h43 * 0.14}Q0 ${-h43 * 0.42} ${w * 0.62} ${h43 * 0.14}" fill="none" stroke="#000" stroke-width="${w * 0.5}" stroke-linecap="round"/></g>`;+var eyeMarkup = ([cx, cy, w, h44, tilt]) => `<g transform="translate(${cx} ${cy}) rotate(${tilt})"><rect class="bt-eye" x="${-w / 2}" y="${-h44 / 2}" width="${w}" height="${h44}" rx="${w / 2}"/></g>`;+var happyEyeMarkup = ([cx, cy, w, h44, tilt]) => `<g transform="translate(${cx} ${cy}) rotate(${tilt})"><path class="bt-eye-happy" opacity="0" d="M${-w * 0.62} ${h44 * 0.14}Q0 ${-h44 * 0.42} ${w * 0.62} ${h44 * 0.14}" fill="none" stroke="#000" stroke-width="${w * 0.5}" stroke-linecap="round"/></g>`;var maskBox = (size) => `maskUnits="userSpaceOnUse" x="${-size}" y="${-size}" width="${size * 3}" height="${size * 3}"`;var holes = (def, eyes) => `<rect x="${-def.size}" y="${-def.size}" width="${def.size * 3}" height="${def.size * 3}" fill="#fff"/>${eyes}`;var MASK_ID = "%MASK%";@@ -1507,6 +1554,9 @@ function teamActions({ call: call2, after, partFor, roster, ui: ui2, live, cardsconst openSideChat = (sessionId, chatId) => {ui2.set((state) => ({ ...state, details: sessionId, view: "side", side: chatId ?? null, renaming: false, tab: null }));};+ const openSettings = (page = "general", id = null) => {+ ui2.set((state) => ({ ...state, settings: { page, id }, menu: null, palette: null, newChat: null }));+ };return {openNewChat: (mode) => {ui2.set((state) => ({ ...state, newChat: mode, menu: null, palette: null }));@@ -1551,10 +1601,9 @@ function teamActions({ call: call2, after, partFor, roster, ui: ui2, live, cardsrenameBot: (id) => {ui2.set((state) => ({ ...state, details: id, view: "details", renaming: true, tab: null }));},- // `id` opens one Bot (page 'bots') or one group chat (page 'groups').- openSettings: (page = "general", id = null) => {- ui2.set((state) => ({ ...state, settings: { page, id }, menu: null, palette: null, newChat: null }));- },+ openSettings,+ // DS Bot's own Models page: the providers DSH serves, their keys and models.+ openModels: () => openSettings("models"),closeSettings: () => {ui2.set((state) => state.settings ? { ...state, settings: null } : state);},@@ -1610,6 +1659,14 @@ function teamActions({ call: call2, after, partFor, roster, ui: ui2, live, cardsrefreshModels: () => after(call2("models")).catch(() => {}),efforts: (ref) => call2("efforts", { ref }),+ // Model providers and their API keys; DSH keeps them, and a key only travels to the host.+ providers: () => call2("providers"),+ setProviderKey: (provider, value) => after(call2("provider-key", { provider, value })),+ addProvider: (body) => after(call2("provider-add", body)),+ providerModels: (body) => call2("provider-models", body),+ removeProvider: (provider) => after(call2("provider-remove", { provider })),+ // After a failed turn: the Bot answers the user's last unanswered message, which is never sent again.+ resume: (botId) => after(call2("resume", { botId })),folders: () => call2("folders"),folderPick: () => call2("folder-pick"),folderList: (path) => call2("folder-list", { path: path ?? "" }),@@ -2155,12 +2212,12 @@ function liveSprings(apply2) {const dt = Math.min(0.5, Math.max(1e-3, (now - last) / 1e3));last = now;const steps = Math.ceil(dt * 240);- const h43 = dt / steps;+ const h44 = dt / steps;let moving = false;for (const value of values.values()) {for (let index = 0; index < steps; index += 1) {- value.v += (-value.k * (value.x - value.to) - value.c * value.v) * h43;- value.x += value.v * h43;+ value.v += (-value.k * (value.x - value.to) - value.c * value.v) * h44;+ value.x += value.v * h44;}if (Math.abs(value.x - value.to) < 0.05 && Math.abs(value.v) < 1) {value.x = value.to;@@ -2778,6 +2835,7 @@ body[data-ds-dark-theme] .bt-scrim{background:rgba(0,0,0,.5)}.bt-settings-nav>.bt-thumb{left:8px;right:8px;border-radius:8px;background:var(--bt-active)}.bt-settings-nav[data-glide] .bt-settings-item[aria-current=page]{background:transparent}.bt-settings-shell{margin-top:auto}+.bt-settings-item>svg{flex:none}/* Usage while another page is open: out of the flow, so it keeps its layout, and notrendered. */.bt-settings-usage[data-off]{position:absolute;top:0;left:198px;width:calc(var(--bt-set-w) - 198px);height:100%;box-sizing:border-box;content-visibility:hidden;pointer-events:none}@@ -3770,6 +3828,7 @@ var CalendarIcon = lineIcon(["M5.5 5h9A1.5 1.5 0 0 1 16 6.5v8a1.5 1.5 0 0 1-1.5var ConnectorIcon = lineIcon(["M7 10a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z", "M18 10a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z", "M7 10h6"]);var SwitchIcon = lineIcon(["M4 7h9.5M10.5 3.5L14 7l-3.5 3.5", "M16 13H6.5M9.5 9.5L6 13l3.5 3.5"]);var SignOutIcon = lineIcon(["M8.5 17H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h2.5", "M10 10h6.5", "M13.5 7l3 3-3 3"]);+var SignInIcon = lineIcon(["M11.5 3H14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2.5", "M3.5 10H10", "M7 7l3 3-3 3"]);var PaperclipIcon = lineIcon(["M15.5 9.5l-5.6 5.6a3.4 3.4 0 0 1-4.8-4.8l6.1-6.1a2.25 2.25 0 0 1 3.2 3.2l-6 6a1.1 1.1 0 0 1-1.6-1.6l5.5-5.5"]);var ClockIcon = lineIcon(["M10 3.5a6.5 6.5 0 1 1 0 13 6.5 6.5 0 0 1 0-13z", "M10 6.5V10l2.5 1.5"]);var GearIcon = lineIcon(["M10 7.4a2.6 2.6 0 1 1 0 5.2 2.6 2.6 0 0 1 0-5.2z", "M7.85 4.4l.29-1.87a7.7 7.7 0 0 1 3.72 0l.29 1.87a6 6 0 0 1 1.63.94l1.76-.69a7.7 7.7 0 0 1 1.86 3.23l-1.47 1.18a6 6 0 0 1 0 1.88l1.47 1.18a7.7 7.7 0 0 1-1.86 3.23l-1.76-.69a6 6 0 0 1-1.63.94l-.29 1.87a7.7 7.7 0 0 1-3.72 0l-.29-1.87a6 6 0 0 1-1.63-.94l-1.76.69a7.7 7.7 0 0 1-1.86-3.23l1.47-1.18a6 6 0 0 1 0-1.88L2.6 7.88a7.7 7.7 0 0 1 1.86-3.23l1.76.69a6 6 0 0 1 1.63-.94z"]);@@ -7621,6 +7680,7 @@ function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnClock, us}if (source.role === "resume" || source.resumed === true) return (0, import_react12.createElement)("div", { className: "bt-event" }, t("Picked up its work after a restart"));if (source.role === "retry" || source.retried === true) return (0, import_react12.createElement)("div", { className: "bt-event" }, t("Asked to make the tool call it wrote as text"));+ if (source.role === "continue") return (0, import_react12.createElement)("div", { className: "bt-event" }, t("Went on after the failed turn"));const run2 = relayed ? commRunOf(order.split(",").filter(Boolean).map(Number),Object.fromEntries(peers.split(",").filter(Boolean).map((pair) => [Number(pair.slice(0, pair.indexOf(":"))), pair.slice(pair.indexOf(":") + 1)])),@@ -8753,6 +8813,18 @@ function openHarnessOnboarding(id) {else openHarnessSettings();});}+var MODELS_STEP = "ds-bot-models";+var MODELS_STEP_ORDER = 1e3;+function OpenModelsStep({ explicit, complete, openSection }) {+ (0, import_react14.useEffect)(() => {+ if (explicit) {+ if (typeof openSection === "function") openSection("models");+ else openHarnessSettings();+ }+ complete();+ }, [explicit]);+ return null;+}function openThroughMenu(trigger) {const before = new Set(document.querySelectorAll('[role="menu"]'));trigger.click();@@ -8835,6 +8907,7 @@ function AccountLauncher({ seat = true, settingsOpen, openSettings, openOnboardiconst accountSource = ops.hooks?.account;const account = (0, import_react14.useSyncExternalStore)(accountSource?.subscribe ?? NO_SUBSCRIBE, accountSource ? () => accountSource.getSnapshot() : NO_SNAPSHOT);const signedIn = signIn !== null && typeof ops.signOut === "function" && account?.view?.status === "credential-stored";+ const signedOut = signIn !== null && typeof actions.signIn === "function" && account?.view?.status === "signed-out";const accountT = actions.accountT?.() ?? ((key) => key);const [confirm, setConfirm] = (0, import_react14.useState)(null);const [busy, setBusy] = (0, import_react14.useState)(false);@@ -8884,18 +8957,21 @@ function AccountLauncher({ seat = true, settingsOpen, openSettings, openOnboardisetSignOutError("");setBusy(false);}, [open]);+ const openModels = actions.providers ? actions.openModels : actions.openHarnessModels;const groups = [[[t("Usage"), GaugeIcon, () => actions.openSettings("usage")],+ openModels ? [t("Models and API keys"), SlidersIcon, () => openModels()] : null,[t("Connectors"), ConnectorIcon, () => actions.openConnectors()],[t("Automation tasks"), ClockIcon, () => actions.selectPanel("schedules")],[t("Bot settings"), GearIcon, () => actions.openSettings("general")]- ],+ ].filter(Boolean),[[t("Switch to classic Agent mode"), SwitchIcon, () => actions.setSurface("agent")]]];if (signedIn) groups.push([[accountT("signOut"), SignOutIcon, askSignOut, void 0, true]]);+ else if (signedOut) groups.push([[t("Sign in to DeepSeek"), SignInIcon, () => actions.signIn()]]);return (0, import_react14.createElement)(import_react14.Fragment,null,@@ -10161,231 +10237,8 @@ function installHeaderNavigation(slots, face, component, priority) {};}-// src/client/overlay-hooks.js-var import_react18 = require("react");-var escapeLayers = [];-var onEscapeKey = (event) => {- if (event.key === "Escape") escapeLayers.at(-1)?.current();-};-function useEscape(onClose) {- const ref = (0, import_react18.useRef)(onClose);- ref.current = onClose;- (0, import_react18.useEffect)(() => {- if (escapeLayers.length === 0) window.addEventListener("keydown", onEscapeKey);- escapeLayers.push(ref);- return () => {- escapeLayers.splice(escapeLayers.indexOf(ref), 1);- if (escapeLayers.length === 0) window.removeEventListener("keydown", onEscapeKey);- };- }, []);-}-function usePaneLeft() {- const [paneLeft, setPaneLeft] = (0, import_react18.useState)(280);- (0, import_react18.useLayoutEffect)(() => {- const column = document.querySelector('[class*="_footArea"]')?.parentElement;- if (column) setPaneLeft(Math.round(column.getBoundingClientRect().right));- }, []);- return paneLeft;-}--// src/client/palette.js-var import_react19 = require("react");-var PALETTE_EXIT_MS = 160;-function CommandPalette({ start, token, roster, actions, useSessions }) {- const [query, setQuery] = (0, import_react19.useState)(start ?? "");- const [cursor, setCursor] = (0, import_react19.useState)(0);- const [leaving, setLeaving] = (0, import_react19.useState)(false);- const wanted = query.trim().toLowerCase();- const close = () => {- if (leaving) return;- setLeaving(true);- setTimeout(() => actions.closePalette(token), PALETTE_EXIT_MS);- };- useEscape(close);- const ids = [...roster.bots.map(currentPart), ...roster.rooms.map((item) => item.id)];- const found = useSessions((list) => {- if (wanted.length < 2) return "[]";- const hits = [];- for (const id of ids) {- const outline = list.projectionsBySession?.[id]?.values?.turnOutline ?? list.byId[id]?.projectionValues?.turnOutline;- if (!Array.isArray(outline)) continue;- const hidden = roster.exchangeTurns[id] ?? [];- for (let index2 = outline.length - 1; index2 >= 0 && hits.length < 30; index2 -= 1) {- const entry = outline[index2];- if (hidden.includes(entry.turn)) continue;- for (const raw of [entry.response, entry.prompt]) {- const text = stripHeader(raw ?? "").replace(/\s+/g, " ").trim();- const at = text.toLowerCase().indexOf(wanted);- if (at < 0) continue;- const from = Math.max(0, at - 24);- hits.push([id, entry.turn, (from > 0 ? "…" : "") + text.slice(from, at + wanted.length + 60)]);- break;- }- }- }- return JSON.stringify(hits);- });- const matchesName = (...fields) => wanted === "" || fields.some((field) => (field ?? "").toLowerCase().includes(wanted));- const sections = [];- const people = [- ...roster.bots.filter((bot) => matchesName(bot.name, bot.role)).map((bot) => ({- key: bot.id,- avatar: (0, import_react19.createElement)(BotAvatar, { bot, size: 24, badge: false, live: false }),- title: bot.name,- subtitle: [bot.role, isMainOf(roster, bot.id) ? t("Main Bot") : ""].filter(Boolean).join(" · "),- badge: bot.hidden ? t("Hidden") : void 0,- run: async () => {- if (bot.hidden) await actions.setFlags(bot.id, { hidden: false });- actions.openSession(bot.id);- }- })),- ...roster.rooms.filter((room2) => matchesName(room2.name)).map((room2) => ({- key: room2.id,- avatar: (0, import_react19.createElement)(RoomAvatar, { room: room2, roster, size: 24 }),- title: room2.name,- subtitle: t("{count} members", { count: room2.members.length }),- badge: room2.hidden ? t("Hidden") : void 0,- run: async () => {- if (room2.hidden) await actions.setFlags(room2.id, { hidden: false });- actions.openSession(room2.id);- }- }))- ];- if (people.length) sections.push([t("Bots"), people]);- const agents = (roster.agents ?? []).filter(() => matchesName("DSH Agent")).map((agent) => ({- key: agent.id,- avatar: (0, import_react19.createElement)("span", { className: "bt-palette-agent" }, (0, import_react19.createElement)(import_dsh_client_ui_primitives.FishLogo, { size: 18 })),- title: "DSH Agent",- subtitle: t("Plain dsh session"),- run: () => actions.openAgent(agent.id)- }));- if (agents.length) sections.push(["DSH Agent", agents]);- const messages = JSON.parse(found).map(([id, turn, snippet]) => {- const bot = roster.byId[id];- const room2 = roster.roomsById[id];- return {- key: `${id}:${turn}`,- title: bot?.name ?? room2?.name ?? t("Bot"),- subtitle: snippet,- avatar: bot ? (0, import_react19.createElement)(BotAvatar, { bot, size: 24, badge: false, live: false }) : (0, import_react19.createElement)(RoomAvatar, { room: room2, roster, size: 24 }),- run: () => actions.openSession(id)- };- });- if (messages.length) sections.push([t("Messages"), messages]);- const commands = [- { key: "cmd:new", icon: (0, import_react19.createElement)(PlusIcon), title: t("New chat"), run: () => actions.openNewChat("new") },- { key: "cmd:bot", icon: (0, import_react19.createElement)(PlusIcon), title: t("Create Bot"), run: () => actions.openNewChat("create") },- { key: "cmd:group", icon: (0, import_react19.createElement)(PeopleIcon), title: t("Create group chat"), run: () => actions.openNewChat("group") },- { key: "cmd:settings", icon: (0, import_react19.createElement)(GearIcon), title: t("Bot settings"), run: () => actions.openSettings("general") }- ].filter((command) => matchesName(command.title));- if (commands.length) sections.push([t("Commands"), commands]);- const rows2 = sections.flatMap(([, items]) => items);- const active = Math.min(cursor, Math.max(rows2.length - 1, 0));- const shown = rows2.map((row) => row.key).join("\n");- const glide = useGlide(`${active}-${shown}`, { axis: "y", ...QUICK_EDGES });- const listRef = glide.box;- useFlip(listRef, shown, "[data-flip]");- (0, import_react19.useEffect)(() => {- listRef.current?.querySelector("[aria-selected=true]")?.scrollIntoView({ block: "nearest" });- }, [active, query]);- const choose = (row) => {- if (!row || leaving) return;- void Promise.resolve(row.run()).catch((error) => actions.reportError(error, "menu"));- close();- };- let index = -1;- return (0, import_react19.createElement)(- "div",- { className: "bt-palette-layer", "data-leaving": leaving || void 0 },- (0, import_react19.createElement)("div", { className: "bt-backdrop", onMouseDown: close }),- (0, import_react19.createElement)(- "div",- { className: "bt-palette", role: "dialog", "aria-label": t("Search"), "aria-modal": true },- (0, import_react19.createElement)(- "div",- { className: "bt-palette-head" },- (0, import_react19.createElement)("span", { className: "bt-palette-glyph", "aria-hidden": true }, (0, import_react19.createElement)(SearchIcon)),- (0, import_react19.createElement)("input", {- autoFocus: true,- value: query,- placeholder: t("Search Bots, chats and messages"),- "aria-label": t("Search"),- role: "combobox",- "aria-expanded": true,- "aria-controls": "bt-palette-list",- onChange: (event) => {- setQuery(event.target.value);- setCursor(0);- },- onKeyDown: (event) => {- if (event.nativeEvent.isComposing) return;- if (event.key === "ArrowDown") {- event.preventDefault();- setCursor(Math.min(active + 1, rows2.length - 1));- } else if (event.key === "ArrowUp") {- event.preventDefault();- setCursor(Math.max(active - 1, 0));- } else if (event.key === "Enter") {- event.preventDefault();- choose(rows2[active]);- }- }- }),- query ? (0, import_react19.createElement)("button", { type: "button", className: "bt-palette-clear", "aria-label": t("Clear search"), onClick: () => {- setQuery("");- setCursor(0);- } }, (0, import_react19.createElement)(CloseIcon)) : null- ),- (0, import_react19.createElement)(- "div",- { ref: listRef, id: "bt-palette-list", className: "bt-palette-list", role: "listbox", "aria-label": t("Results") },- (0, import_react19.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),- rows2.length === 0 ? (0, import_react19.createElement)(- "div",- { className: "bt-palette-empty" },- (0, import_react19.createElement)("span", { className: "bt-palette-empty-icon", "aria-hidden": true }, (0, import_react19.createElement)(SearchIcon)),- (0, import_react19.createElement)("span", { className: "bt-palette-empty-label" }, t("No results")),- (0, import_react19.createElement)("span", { className: "bt-palette-empty-hint" }, t("Try a Bot name or words from a message"))- ) : sections.map(([title, items]) => (0, import_react19.createElement)(- import_react19.Fragment,- { key: title },- (0, import_react19.createElement)("div", { className: "bt-palette-section", role: "presentation", "data-flip": `section:${title}` }, title),- items.map((row) => {- index += 1;- const at = index;- return (0, import_react19.createElement)(- "button",- {- key: row.key,- type: "button",- role: "option",- className: "bt-palette-row",- "aria-selected": at === active,- "data-flip": row.key,- onMouseMove: () => {- if (cursor !== at) setCursor(at);- },- onClick: () => choose(row)- },- (0, import_react19.createElement)("span", { className: "bt-palette-lead" }, row.avatar ?? (0, import_react19.createElement)("span", { className: "bt-palette-cmd" }, row.icon)),- (0, import_react19.createElement)(- "span",- { className: "bt-palette-text" },- (0, import_react19.createElement)("span", { className: "bt-palette-title" }, row.title),- row.subtitle ? (0, import_react19.createElement)("span", { className: "bt-palette-sub" }, row.subtitle) : null- ),- row.badge ? (0, import_react19.createElement)("span", { className: "bt-palette-badge" }, row.badge) : null- );- })- ))- )- )- );-}-// src/client/model-menu.js-var import_react20 = require("react");+var import_react18 = require("react");var import_react_dom6 = require("react-dom");var MENU_EXIT_MS = 120;function groupModels(models) {@@ -10415,8 +10268,8 @@ function modelOf(bot, roster) {}var effortCache = /* @__PURE__ */ new Map();function useEfforts(served, ref, actions) {- const [fetched, setFetched] = (0, import_react20.useState)(void 0);- (0, import_react20.useEffect)(() => {+ const [fetched, setFetched] = (0, import_react18.useState)(void 0);+ (0, import_react18.useEffect)(() => {setFetched(void 0);if (ref === void 0 || served?.reasoning !== void 0 || actions?.efforts === void 0) return void 0;let live = true;@@ -10441,12 +10294,12 @@ function effortRows(reasoning) {];}function EffortRows({ reasoning, current, onPick }) {- return (0, import_react20.createElement)(- import_react20.Fragment,+ return (0, import_react18.createElement)(+ import_react18.Fragment,null,- (0, import_react20.createElement)("div", { className: "bt-menu-sep", role: "separator" }),- (0, import_react20.createElement)("div", { className: "bt-model-group", role: "presentation" }, t("Thinking level")),- effortRows(reasoning).map((row) => (0, import_react20.createElement)(+ (0, import_react18.createElement)("div", { className: "bt-menu-sep", role: "separator" }),+ (0, import_react18.createElement)("div", { className: "bt-model-group", role: "presentation" }, t("Thinking level")),+ effortRows(reasoning).map((row) => (0, import_react18.createElement)("button",{key: row.effort ?? "default",@@ -10455,17 +10308,17 @@ function EffortRows({ reasoning, current, onPick }) {"aria-checked": row.effort === current,onClick: () => onPick(row.effort)},- (0, import_react20.createElement)("span", { className: "bt-menu-label" }, row.label),- (0, import_react20.createElement)("span", { className: "bt-model-tick", "aria-hidden": true }, row.effort === current ? (0, import_react20.createElement)(CheckIcon) : null)+ (0, import_react18.createElement)("span", { className: "bt-menu-label" }, row.label),+ (0, import_react18.createElement)("span", { className: "bt-model-tick", "aria-hidden": true }, row.effort === current ? (0, import_react18.createElement)(CheckIcon) : null))));}function ModelRows({ roster, current, onPick }) {- return groupModels(roster.models).map(([provider, list]) => (0, import_react20.createElement)(- import_react20.Fragment,+ return groupModels(roster.models).map(([provider, list]) => (0, import_react18.createElement)(+ import_react18.Fragment,{ key: list[0].provider ?? provider },- (0, import_react20.createElement)("div", { className: "bt-model-group", role: "presentation" }, provider),- list.map((model) => (0, import_react20.createElement)(+ (0, import_react18.createElement)("div", { className: "bt-model-group", role: "presentation" }, provider),+ list.map((model) => (0, import_react18.createElement)("button",{key: model.ref,@@ -10475,25 +10328,25 @@ function ModelRows({ roster, current, onPick }) {title: model.ref,onClick: () => onPick(model.ref)},- (0, import_react20.createElement)("span", { className: "bt-menu-label" }, model.name),- model.ref === roster.defaultModel ? (0, import_react20.createElement)("span", { className: "bt-menu-hint" }, t("Default")) : null,- (0, import_react20.createElement)("span", { className: "bt-model-tick", "aria-hidden": true }, model.ref === current ? (0, import_react20.createElement)(CheckIcon) : null)+ (0, import_react18.createElement)("span", { className: "bt-menu-label" }, model.name),+ model.ref === roster.defaultModel ? (0, import_react18.createElement)("span", { className: "bt-menu-hint" }, t("Default")) : null,+ (0, import_react18.createElement)("span", { className: "bt-model-tick", "aria-hidden": true }, model.ref === current ? (0, import_react18.createElement)(CheckIcon) : null)))));}-var Caret = () => (0, import_react20.createElement)("svg", { className: "bt-model-caret", width: 12, height: 12, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true }, (0, import_react20.createElement)("path", { d: "M5.5 8l4.5 4.5L14.5 8" }));+var Caret = () => (0, import_react18.createElement)("svg", { className: "bt-model-caret", width: 12, height: 12, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true }, (0, import_react18.createElement)("path", { d: "M5.5 8l4.5 4.5L14.5 8" }));function useAnchoredMenu() {- const [anchor, setAnchor] = (0, import_react20.useState)(null);- const [place, setPlace] = (0, import_react20.useState)(null);+ const [anchor, setAnchor] = (0, import_react18.useState)(null);+ const [place, setPlace] = (0, import_react18.useState)(null);const [shownPlace, leaving] = useLinger(place, MENU_EXIT_MS);- const button = (0, import_react20.useRef)(null);- const menu = (0, import_react20.useRef)(null);+ const button = (0, import_react18.useRef)(null);+ const menu = (0, import_react18.useRef)(null);const tick = useViewport();const close = () => {setAnchor(null);setPlace(null);};- (0, import_react20.useEffect)(() => {+ (0, import_react18.useEffect)(() => {if (place === null) return void 0;const onDown = (event) => {if (menu.current?.contains(event.target) || button.current?.contains(event.target)) return;@@ -10519,7 +10372,7 @@ function useAnchoredMenu() {};}, [place]);const open = () => setAnchor({});- (0, import_react20.useLayoutEffect)(() => {+ (0, import_react18.useLayoutEffect)(() => {if (anchor === null || !button.current) return;const rect = button.current.getBoundingClientRect();const width = Math.max(240, rect.width);@@ -10558,10 +10411,10 @@ function ModelMenu({ bot, roster, actions, run: run2, wide = false, onPick, onPi};const models = roster.models ?? [];const manage = manageModels(actions);- return (0, import_react20.createElement)(- import_react20.Fragment,+ return (0, import_react18.createElement)(+ import_react18.Fragment,null,- (0, import_react20.createElement)(+ (0, import_react18.createElement)("button",{ref: button,@@ -10574,34 +10427,34 @@ function ModelMenu({ bot, roster, actions, run: run2, wide = false, onPick, onPi"data-missing": shown !== void 0 && !shown.served && models.length > 0 ? "" : void 0,onClick: toggle},- (0, import_react20.createElement)(+ (0, import_react18.createElement)("span",{ className: "bt-model-copy" },- (0, import_react20.createElement)("span", { className: "bt-model-name" }, shown?.name ?? t("Choose a model")),- shown ? (0, import_react20.createElement)("span", { className: "bt-model-provider" }, shown.served || models.length === 0 ? effortLabel === void 0 ? shown.provider : `${shown.provider} · ${effortLabel}` : t("{provider} · not available", { provider: shown.provider })) : null+ (0, import_react18.createElement)("span", { className: "bt-model-name" }, shown?.name ?? t("Choose a model")),+ shown ? (0, import_react18.createElement)("span", { className: "bt-model-provider" }, shown.served || models.length === 0 ? effortLabel === void 0 ? shown.provider : `${shown.provider} · ${effortLabel}` : t("{provider} · not available", { provider: shown.provider })) : null),- (0, import_react20.createElement)(Caret)+ (0, import_react18.createElement)(Caret)),- shownPlace ? (0, import_react_dom6.createPortal)((0, import_react20.createElement)(+ shownPlace ? (0, import_react_dom6.createPortal)((0, import_react18.createElement)("div",{ ref: menu, className: `bt-menu bt-model-menu${shownPlace.bottom !== void 0 ? " bt-menu-up" : ""}`, role: "menu", "aria-label": t("Model for {name}", { name: bot.name }), style: shownPlace, "data-leaving": leaving || void 0 },- models.length > 0 ? (0, import_react20.createElement)(ModelRows, { roster, current, onPick: pick2 }) : (0, import_react20.createElement)("div", { className: "bt-model-none" }, t("No models are set up in DeepSeek Harness yet.")),- effortRows(reasoning).length > 0 ? (0, import_react20.createElement)(EffortRows, { reasoning, current: picked, onPick: pickEffort }) : null,- manage ? (0, import_react20.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,- manage ? (0, import_react20.createElement)("button", { type: "button", role: "menuitem", onClick: () => {+ models.length > 0 ? (0, import_react18.createElement)(ModelRows, { roster, current, onPick: pick2 }) : (0, import_react18.createElement)("div", { className: "bt-model-none" }, t("No models are set up in DeepSeek Harness yet.")),+ effortRows(reasoning).length > 0 ? (0, import_react18.createElement)(EffortRows, { reasoning, current: picked, onPick: pickEffort }) : null,+ manage ? (0, import_react18.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,+ manage ? (0, import_react18.createElement)("button", { type: "button", role: "menuitem", onClick: () => {close();manage();- } }, (0, import_react20.createElement)(SlidersIcon), (0, import_react20.createElement)("span", { className: "bt-menu-label" }, t("Models and providers…"))) : null+ } }, (0, import_react18.createElement)(SlidersIcon), (0, import_react18.createElement)("span", { className: "bt-menu-label" }, t("Models and providers…"))) : null), document.body) : null);}function ModelChoiceDock({ sessionId, useRoster, actions }) {const roster = useRoster((value) => value);const bot = roster.byId[sessionId];- const [busy, setBusy] = (0, import_react20.useState)("");- const [error, setError] = (0, import_react20.useState)("");+ const [busy, setBusy] = (0, import_react18.useState)("");+ const [error, setError] = (0, import_react18.useState)("");const shown = Boolean(bot) && currentPart(bot) === sessionId && roster.ready;- (0, import_react20.useEffect)(() => {+ (0, import_react18.useEffect)(() => {if (shown) void actions.refreshModels?.();}, [shown, sessionId]);if (!bot || currentPart(bot) !== sessionId || !roster.ready) return null;@@ -10620,12 +10473,12 @@ function ModelChoiceDock({ sessionId, useRoster, actions }) {}).finally(() => setBusy(""));};const text = lost ? t("{model} is not available anymore. Pick another model for me.", { model: bot.model.split("/").slice(1).join("/") }) : keyFor ? t("Hi, I'm {name}. I need a {provider} API key before I can start.", { name: bot.name, provider: keyFor.providerName ?? keyFor.provider }) : usable.length === 0 ? t("Hi, I'm {name}. I don't have a model yet. How do you want to set one up?", { name: bot.name }) : t("Hi, I'm {name}. Pick a model for me first. You can change it later in my details.", { name: bot.name });- const choices = usable.length === 0 ? setupChoices(actions).map(([label, run2]) => (0, import_react20.createElement)("button", { key: label, type: "button", className: "bt-model-chip", onClick: run2 }, label)) : [- ...groupModels(usable).map(([provider, list]) => (0, import_react20.createElement)(+ const choices = usable.length === 0 ? setupChoices(actions).map(([label, run2]) => (0, import_react18.createElement)("button", { key: label, type: "button", className: "bt-model-chip", onClick: run2 }, label)) : [+ ...groupModels(usable).map(([provider, list]) => (0, import_react18.createElement)("div",{ key: list[0].provider ?? provider, className: "bt-model-choice-group", role: "group", "aria-label": provider },- (0, import_react20.createElement)("div", { className: "bt-model-choice-provider", "aria-hidden": true }, provider),- (0, import_react20.createElement)("div", { className: "bt-model-choice-chips" }, list.map((model) => (0, import_react20.createElement)("button", {+ (0, import_react18.createElement)("div", { className: "bt-model-choice-provider", "aria-hidden": true }, provider),+ (0, import_react18.createElement)("div", { className: "bt-model-choice-chips" }, list.map((model) => (0, import_react18.createElement)("button", {key: model.ref,type: "button",className: "bt-model-chip",@@ -10634,77 +10487,89 @@ function ModelChoiceDock({ sessionId, useRoster, actions }) {"aria-label": `${model.name} · ${provider}`,title: model.ref === roster.defaultModel ? `${model.ref} · ${t("Harness default")}` : model.ref,onClick: () => pick2(model.ref)- }, model.name, busy === model.ref ? (0, import_react20.createElement)("span", { className: "bt-model-spin", "aria-label": t("Saving…") }) : null)))+ }, model.name, busy === model.ref ? (0, import_react18.createElement)("span", { className: "bt-model-spin", "aria-label": t("Saving…") }) : null))))),- manage ? (0, import_react20.createElement)("button", { key: "manage", type: "button", className: "bt-model-chip bt-model-chip-quiet", onClick: manage }, (0, import_react20.createElement)(SlidersIcon), t("Manage models")) : null+ manage ? (0, import_react18.createElement)("button", { key: "manage", type: "button", className: "bt-model-chip bt-model-chip-quiet", onClick: manage }, (0, import_react18.createElement)(SlidersIcon), t("Manage models")) : null];- return (0, import_react20.createElement)(+ return (0, import_react18.createElement)("div",{ className: "bt-model-dock" },- (0, import_react20.createElement)(+ (0, import_react18.createElement)("div",{ className: "bt-astack", "data-lead": "" },- (0, import_react20.createElement)(+ (0, import_react18.createElement)("div",{ className: "bt-msg" },- (0, import_react20.createElement)(+ (0, import_react18.createElement)("div",{ className: "bt-msg-line" },- (0, import_react20.createElement)(BotMark, { bot, size: 22 }),- (0, import_react20.createElement)("div", { className: "bt-bubble" }, text)+ (0, import_react18.createElement)(BotMark, { bot, size: 22 }),+ (0, import_react18.createElement)("div", { className: "bt-bubble" }, text)))),- keyFor ? (0, import_react20.createElement)(ModelKeyCard, { key: keyFor.provider, model: keyFor, actions }) : (0, import_react20.createElement)("div", { className: "bt-model-chips", role: "group", "aria-label": t("Choose a model") }, choices),- error ? (0, import_react20.createElement)("div", { className: "bt-secret-error bt-model-error", role: "alert" }, error) : null+ keyFor ? (0, import_react18.createElement)(ModelKeyCard, { key: keyFor.provider, model: keyFor, actions }) : (0, import_react18.createElement)("div", { className: "bt-model-chips", role: "group", "aria-label": t("Choose a model") }, choices),+ error ? (0, import_react18.createElement)("div", { className: "bt-secret-error bt-model-error", role: "alert" }, error) : null);}-function ModelKeyCard({ model, actions }) {- const [value, setValue] = (0, import_react20.useState)("");- const [busy, setBusy] = (0, import_react20.useState)(false);- const [error, setError] = (0, import_react20.useState)("");+var DEEPSEEK_KEYS_URL = "https://platform.deepseek.com/api_keys";+function ModelKeyCard({ model, actions, onSaved }) {+ const [value, setValue] = (0, import_react18.useState)("");+ const [busy, setBusy] = (0, import_react18.useState)(false);+ const [error, setError] = (0, import_react18.useState)("");const label = t("{provider} API key", { provider: model.providerName ?? model.provider });const ready = value.trim() !== "" && !busy;const save = () => {if (!ready) return;setBusy(true);setError("");- void Promise.resolve(actions.setProviderKey(model.provider, value)).then(() => setValue(""), (failure) => setError(hostText(failure?.message ?? String(failure)))).finally(() => setBusy(false));+ void Promise.resolve(actions.setProviderKey(model.provider, value)).then(() => {+ setValue("");+ onSaved?.();+ }, (failure) => setError(hostText(failure?.message ?? String(failure)))).finally(() => setBusy(false));};- return (0, import_react20.createElement)(+ const official = model.provider === "deepseek-official";+ return (0, import_react18.createElement)("div",{ className: "bt-q bt-model-key", role: "group", "aria-label": label },- (0, import_react20.createElement)("div", { className: "bt-model-key-title" }, (0, import_react20.createElement)(KeyIcon), label),- (0, import_react20.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react20.createElement)(MaskedInput, { value, onChange: setValue, onEnter: save, label, autoFocus: true })),- error ? (0, import_react20.createElement)("div", { className: "bt-secret-error", role: "alert" }, error) : null,- (0, import_react20.createElement)(+ (0, import_react18.createElement)("div", { className: "bt-model-key-title" }, (0, import_react18.createElement)(KeyIcon), label),+ (0, import_react18.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react18.createElement)(MaskedInput, { value, onChange: setValue, onEnter: save, label, autoFocus: true })),+ official ? (0, import_react18.createElement)(+ "div",+ { className: "bt-model-key-help" },+ (0, import_react18.createElement)("a", { className: "bt-model-key-link", href: DEEPSEEK_KEYS_URL, target: "_blank", rel: "noopener noreferrer" }, t("Create a key on the DeepSeek platform ↗")),+ (0, import_react18.createElement)("span", { className: "bt-model-key-note" }, t("The API is billed by usage; the account needs a balance first."))+ ) : null,+ error ? (0, import_react18.createElement)("div", { className: "bt-secret-error", role: "alert" }, error) : null,+ (0, import_react18.createElement)("div",{ className: "bt-q-foot" },- actions.openModels ? (0, import_react20.createElement)("button", { type: "button", className: "bt-q-btn bt-model-key-other", onClick: actions.openModels }, t("Another provider")) : null,- (0, import_react20.createElement)("button", { type: "button", className: "bt-q-submit", disabled: !ready, onClick: save }, busy ? t("Saving…") : t("Save"))+ actions.openModels ? (0, import_react18.createElement)("button", { type: "button", className: "bt-q-btn bt-model-key-other", onClick: actions.openModels }, t("Another provider")) : null,+ (0, import_react18.createElement)("button", { type: "button", className: "bt-q-submit", disabled: !ready, onClick: save }, busy ? t("Saving…") : t("Save"))));}-var manageModels = (actions) => actions.openModels ?? actions.openHarnessSettings;+var manageModels = (actions) => actions.openModels ?? actions.openHarnessModels ?? actions.openHarnessSettings;function setupChoices(actions) {+ const custom = manageModels(actions);return [actions.canSignIn?.() ? [t("Sign in to DeepSeek"), () => actions.signIn()] : null,actions.openHarnessOnboarding ? [t("Enter a DeepSeek API key"), () => actions.openHarnessOnboarding("deepseek-official")] : null,- actions.openHarnessSettings ? [t("Open settings to set up a custom model"), actions.openHarnessSettings] : null+ custom ? [t("Open settings to set up a custom model"), () => custom()] : null].filter(Boolean);}function DeepSeekSignIn({ useUi, actions }) {const open = useUi((state) => state.signIn);const entry = open ? actions.signInEntry?.() : null;if (!entry) return null;- return (0, import_react20.createElement)(SignInHost, { key: open, entry, actions });+ return (0, import_react18.createElement)(SignInHost, { key: open, entry, actions });}function SignInHost({ entry, actions }) {- const [ops] = (0, import_react20.useState)(() => entry.inject?.() ?? {});+ const [ops] = (0, import_react18.useState)(() => entry.inject?.() ?? {});const close = () => actions.closeSignIn();- const useHook = (source) => (selector) => (0, import_react20.useSyncExternalStore)(source.subscribe, () => selector(source.getSnapshot()));- const [hooks] = (0, import_react20.useState)(() => ({ useAccount: useHook(ops.hooks.account), useTheme: useHook(ops.hooks.theme) }));- return (0, import_react20.createElement)(entry.component, {+ const useHook = (source) => (selector) => (0, import_react18.useSyncExternalStore)(source.subscribe, () => selector(source.getSnapshot()));+ const [hooks] = (0, import_react18.useState)(() => ({ useAccount: useHook(ops.hooks.account), useTheme: useHook(ops.hooks.theme) }));+ return (0, import_react18.createElement)(entry.component, {...ops,...hooks,t: actions.accountT(),@@ -10750,6 +10615,10 @@ var MODEL_CSS = `.bt-model-key-title{display:flex;align-items:center;gap:6px;font-size:13px;line-height:18px;font-weight:500;color:var(--bt-ink-2)}.bt-model-key-title svg{flex:none;width:16px;height:16px}.bt-model-key .bt-q-foot{margin-top:2px}+.bt-model-key-help{display:flex;flex-direction:column;gap:2px;font-size:12px;line-height:17px;color:var(--bt-ink-2)}+.bt-model-key-link{align-self:flex-start;color:var(--bt-ink);text-decoration:underline;text-decoration-color:var(--bt-line-2);text-underline-offset:2px}+.bt-model-key-link:hover{text-decoration-color:currentColor}+.bt-model-key-link:focus-visible{outline:2px solid var(--bt-accent);outline-offset:1px;border-radius:4px}.bt-model-key-other{margin-right:auto}@keyframes bt-model-in{from{opacity:0;transform:translateY(6px)}}.bt-model-spin{flex:none;width:14px;height:14px;border-radius:50%;border:1.5px solid var(--bt-line-2);border-top-color:var(--bt-ink-2);animation:bt-model-spin .7s linear infinite}@@ -10757,32 +10626,502 @@ var MODEL_CSS = `@media (prefers-reduced-motion:reduce){.bt-model-dock{animation:none}.bt-model-spin{animation-duration:2s}.bt-model-caret{transition:none}.bt-model-tick svg{animation:none}}`;-// src/client/folder-menu.js-var import_react21 = require("react");-var import_react_dom7 = require("react-dom");-var folderName = (path) => String(path).replace(/[\\/]+$/, "").split(/[\\/]/).pop() || String(path);-var Tick = ({ on }) => (0, import_react21.createElement)("span", { className: "bt-model-tick", "aria-hidden": true }, on ? (0, import_react21.createElement)(CheckIcon) : null);-function FolderMenu({ value, group = false, team = false, actions, run: run2, onPick, wide = false, disabled = false }) {- const { isOpen, shownPlace, leaving, button, menu, open, close } = useAnchoredMenu();- const [info, setInfo] = (0, import_react21.useState)(null);- const [view, setView] = (0, import_react21.useState)("list");- const [draft, setDraft] = (0, import_react21.useState)("");- const [listing, setListing] = (0, import_react21.useState)(null);- const [problem, setProblem] = (0, import_react21.useState)("");- const fallback = group ? t("Each Bot's own folder") : t("Team workspace");- const toggle = () => {- if (isOpen) {- close();+// src/client/turn-error.js+var import_react19 = require("react");+var OFFICIAL = "deepseek-official";+var ACCOUNT = "deepseek-account";+var TOP_UP_URL = "https://platform.deepseek.com/top_up";+var ACCOUNT_MODELS_WAIT_MS = 2e4;+var SIGNED_OUT = /* @__PURE__ */ new Set(["ACCOUNT_SIGN_IN_REQUIRED", "ACCOUNT_SIGNED_OUT", "ACCOUNT_TOKEN_INVALID"]);+var KEY_CODES = /* @__PURE__ */ new Set(["MISSING_CREDENTIAL", "INVALID_CREDENTIAL", "AUTH"]);+var CREDENTIAL_CODES = /* @__PURE__ */ new Set([...KEY_CODES, ...SIGNED_OUT]);+function failureText2(code, { name, provider, status }) {+ switch (code) {+ case "MISSING_CREDENTIAL":+ return t("{name}'s model has no API key yet.", { name });+ case "INVALID_CREDENTIAL":+ return t("This API key is not in the right format.");+ case "AUTH":+ return status === void 0 ? t("{provider} did not accept the current API key.", { provider }) : t("{provider} did not accept the current API key ({status}).", { provider, status });+ case "QUOTA":+ return status === void 0 ? t("{provider} is out of balance or quota.", { provider }) : t("{provider} is out of balance or quota ({status}).", { provider, status });+ case "ACCOUNT_QUOTA":+ return t("The DeepSeek account balance is too low.");+ case "ACCOUNT_SIGN_IN_REQUIRED":+ case "ACCOUNT_SIGNED_OUT":+ case "ACCOUNT_TOKEN_INVALID":+ return t("The DeepSeek account sign-in has expired.");+ case "TRANSPORT":+ case "TIMEOUT":+ return t("Could not reach the model service.");+ case "RATE_LIMIT":+ return t("Too many requests. Wait a moment, then try again.");+ case "SERVER":+ return t("The model service failed.");+ case "INTERRUPTED":+ return t("DeepSeek Harness stopped before this turn finished.");+ default:+ return knownFailure(code) ?? t("This turn failed.");+ }+}+function fixesFor(code, { canSignIn, official, topUp, onAccount = false }) {+ if (onAccount && KEY_CODES.has(code)) return [];+ if (SIGNED_OUT.has(code)) return canSignIn ? ["sign-in-again"] : ["model"];+ switch (code) {+ case "MISSING_CREDENTIAL":+ return ["key", canSignIn ? "sign-in" : null, "model"].filter(Boolean);+ case "INVALID_CREDENTIAL":+ return ["rekey", "model"];+ case "AUTH":+ return ["rekey", canSignIn ? "use-account" : null, "model"].filter(Boolean);+ case "QUOTA":+ return official ? ["top-up"] : [];+ case "ACCOUNT_QUOTA":+ return topUp ? ["top-up"] : [];+ default:+ return [];+ }+}+var retryShown = (code, blocked) => !CREDENTIAL_CODES.has(code) || blocked === void 0;+var FIX_LABELS = {+ key: () => t("Enter API key"),+ rekey: () => t("Enter the key again"),+ "sign-in": (signedIn) => signedIn ? t("Use the DeepSeek account") : t("Sign in with a DeepSeek account"),+ "use-account": () => t("Use a DeepSeek account instead"),+ "sign-in-again": () => t("Sign in again"),+ model: () => t("Pick another model"),+ "top-up": () => t("Top up ↗")+};+var NO_SUBSCRIBE2 = () => () => {+};+var NO_VIEW = () => null;+function useAccountView(actions) {+ const entry = actions.signInEntry?.() ?? null;+ const ops = (0, import_react19.useMemo)(() => entry?.inject?.() ?? {}, [entry]);+ const source = ops.hooks?.account;+ const read = source ? () => source.getSnapshot()?.view ?? null : NO_VIEW;+ return (0, import_react19.useSyncExternalStore)(source?.subscribe ?? NO_SUBSCRIBE2, read, read);+}+var topUpOf = (view) => {+ const url = view?.links?.topUpUrl;+ return typeof url === "string" && url.startsWith("https://") ? url : void 0;+};+function accountModel(roster) {+ const models = (roster.models ?? []).filter((model) => model.provider === ACCOUNT);+ return (models.find((model) => model.ref === roster.defaultModel) ?? models[0])?.ref;+}+var providerOf = (bot, roster) => {+ const ref = bot?.model ?? bot?.appliedModel;+ if (!ref) return void 0;+ return (roster.models ?? []).find((model) => model.ref === ref)?.provider ?? ref.split("/")[0];+};+var KNOWN_PROVIDERS = { "deepseek-official": "DeepSeek", "deepseek-account": "DeepSeek account" };+var providerName = (roster, provider) => provider === void 0 ? t("The model service") : (roster.models ?? []).find((model) => model.provider === provider)?.providerName ?? (KNOWN_PROVIDERS[provider] ? t(KNOWN_PROVIDERS[provider]) : provider);+function failureFacts(data, blocked) {+ const facts = [];+ if (data.code) facts.push(["Code", t("Code"), data.code]);+ if (blocked?.status !== void 0) facts.push(["HTTP status", t("HTTP status"), String(blocked.status)]);+ if (blocked?.requestId) facts.push(["Request ID", t("Request ID"), blocked.requestId]);+ if (data.code !== "AUTH" && data.message) facts.push(["Message", t("Provider message"), data.message]);+ return facts;+}+function TechnicalDetails({ facts }) {+ const [copied, setCopied] = (0, import_react19.useState)(false);+ if (facts.length === 0) return null;+ const copy2 = () => {+ const text = facts.map(([name, , value]) => `${name}: ${value}`).join("\n");+ void navigator.clipboard?.writeText(text).then(() => {+ setCopied(true);+ setTimeout(() => setCopied(false), 1e3);+ }).catch(() => {+ });+ };+ return (0, import_react19.createElement)(+ "details",+ { className: "bt-fail-tech" },+ (0, import_react19.createElement)("summary", null, t("Technical details")),+ (0, import_react19.createElement)("dl", null, facts.map(([name, label, value]) => [(0, import_react19.createElement)("dt", { key: `${name}:t` }, label), (0, import_react19.createElement)("dd", { key: `${name}:d` }, value)])),+ (0, import_react19.createElement)("button", { type: "button", className: "bt-mini bt-fail-copy", onClick: copy2 }, copied ? (0, import_react19.createElement)(CheckIcon) : (0, import_react19.createElement)(CopyIcon), copied ? t("Copied") : t("Copy"))+ );+}+function FailureCell({ node, sessionId, useRoster, useTurnClock, actions }) {+ const roster = useRoster((value) => value);+ const data = node?.data ?? {};+ const bot = roster.byId?.[sessionId];+ const later = useTurnClock((state) => Object.keys(state[sessionId] ?? {}).some((turn) => Number(turn) > data.turn));+ const account = useAccountView(actions);+ const signedIn = account?.status === "credential-stored";+ const topUp = topUpOf(account);+ const [keying, setKeying] = (0, import_react19.useState)(false);+ const [retry, setRetry] = (0, import_react19.useState)("idle");+ const [error, setError] = (0, import_react19.useState)("");+ const [joining, setJoining] = (0, import_react19.useState)(null);+ const blocked = bot?.blocked?.code === data.code ? bot.blocked : void 0;+ const provider = blocked?.provider ?? providerOf(bot, roster);+ const text = failureText2(data.code, { name: bot?.name ?? t("This Bot"), provider: providerName(roster, provider), status: blocked?.status });+ const facts = failureFacts(data, blocked);+ const current = bot !== void 0 && currentPart(bot) === sessionId && !later;+ const moveToAccount = () => {+ const model = accountModel(roster);+ if (model === void 0) {+ actions.showDetails?.(sessionId);return;}- setView("list");- setProblem("");- void Promise.resolve(actions.folders()).then(setInfo).catch(() => setInfo((last) => last ?? { team: null, picker: null, folders: [] }));- open();+ if (model === bot.model) return;+ setError("");+ void Promise.resolve(actions.updateBot(bot.id, { model })).catch((failure) => setError(hostText(failure?.message ?? String(failure))));};- const choose = (path) => {- close();- if (path !== (value ?? "")) void onPick(path);+ const listed = accountModel(roster);+ (0, import_react19.useEffect)(() => {+ if (joining === null || !signedIn) return void 0;+ if (bot === void 0 || bot.model !== joining.from) {+ setJoining(null);+ return void 0;+ }+ if (listed !== void 0) {+ setJoining(null);+ moveToAccount();+ return void 0;+ }+ void actions.refreshModels?.();+ const timer = setTimeout(() => {+ setJoining(null);+ actions.showDetails?.(sessionId);+ }, ACCOUNT_MODELS_WAIT_MS);+ return () => clearTimeout(timer);+ }, [joining, signedIn, listed]);+ const settled = () => (0, import_react19.createElement)(+ "div",+ { className: "bt-fail", "data-settled": "", role: "status" },+ (0, import_react19.createElement)("div", { className: "bt-fail-head" }, (0, import_react19.createElement)("span", { className: "bt-fail-dot", "aria-hidden": true }), (0, import_react19.createElement)("span", { className: "bt-fail-text" }, text)),+ (0, import_react19.createElement)(TechnicalDetails, { facts })+ );+ if (!current) return settled();+ const official = provider === OFFICIAL;+ const canSignIn = typeof actions.signIn === "function" && actions.canSignIn?.() === true;+ const keyHere = typeof actions.setProviderKey === "function" && provider !== void 0;+ const keyElsewhere = official && actions.openHarnessOnboarding ? () => actions.openHarnessOnboarding(OFFICIAL) : manageModels(actions);+ const viaAccount = () => {+ if (signedIn) {+ moveToAccount();+ return;+ }+ setJoining({ from: bot.model });+ actions.signIn();+ };+ const runs = {+ key: keyHere ? () => setKeying((value) => !value) : keyElsewhere,+ rekey: keyHere ? () => setKeying((value) => !value) : keyElsewhere,+ "sign-in": viaAccount,+ "use-account": viaAccount,+ "sign-in-again": () => actions.signIn(),+ model: actions.showDetails ? () => actions.showDetails(sessionId) : void 0+ };+ const fixes = fixesFor(data.code, { canSignIn, official, topUp: topUp !== void 0, onAccount: provider === ACCOUNT }).filter((fix) => fix === "top-up" || runs[fix] !== void 0);+ const asked = isHiddenTurn(roster, sessionId, data.turn);+ const retrying = !asked && typeof actions.resume === "function" && retryShown(data.code, blocked);+ const retryFirst = retrying && (fixes.length === 0 || CREDENTIAL_CODES.has(data.code));+ const resume = () => {+ setRetry("busy");+ setError("");+ void Promise.resolve(actions.resume(bot.id)).then(() => setRetry("sent"), (failure) => {+ setRetry("idle");+ setError(hostText(failure?.message ?? String(failure)));+ });+ };+ const button = (fix, primary) => {+ const className = primary ? "bt-send bt-fail-go" : "bt-soft bt-soft-sm";+ if (fix === "top-up") {+ return (0, import_react19.createElement)("a", { key: fix, className: `${className} bt-fail-link`, href: data.code === "ACCOUNT_QUOTA" ? topUp : TOP_UP_URL, target: "_blank", rel: "noopener noreferrer" }, FIX_LABELS[fix]());+ }+ const toggles = keyHere && (fix === "key" || fix === "rekey");+ return (0, import_react19.createElement)("button", { key: fix, type: "button", className, "aria-expanded": toggles ? keying : void 0, onClick: () => runs[fix]() }, FIX_LABELS[fix](signedIn));+ };+ const retryButton = (primary) => (0, import_react19.createElement)("button", { key: "retry", type: "button", className: primary ? "bt-send bt-fail-go" : "bt-soft bt-soft-sm", disabled: retry !== "idle", onClick: resume }, retry === "idle" ? t("Retry") : t("Retrying…"));+ const row = retryFirst ? [retryButton(true), ...fixes.map((fix) => button(fix, false))] : [...fixes.map((fix, index) => button(fix, index === 0)), retrying ? retryButton(false) : null];+ if (!row.some(Boolean)) return settled();+ return (0, import_react19.createElement)(+ "div",+ { className: "bt-fail", role: "status" },+ (0, import_react19.createElement)("div", { className: "bt-fail-head" }, (0, import_react19.createElement)("span", { className: "bt-fail-dot", "aria-hidden": true }), (0, import_react19.createElement)("span", { className: "bt-fail-text" }, text)),+ (0, import_react19.createElement)("div", { className: "bt-fail-actions" }, row),+ keying && keyHere ? (0, import_react19.createElement)(ModelKeyCard, { model: { provider, providerName: providerName(roster, provider) }, actions, onSaved: () => setKeying(false) }) : null,+ error ? (0, import_react19.createElement)("div", { className: "bt-fail-error", role: "alert" }, error) : null,+ (0, import_react19.createElement)(TechnicalDetails, { facts })+ );+}+var TURN_ERROR_CSS = `+.bt-fail{display:flex;flex-direction:column;gap:10px;margin:4px 0 6px;width:max-content;max-width:min(550px,86%);padding:12px 14px;border-radius:16px;background:var(--bt-card);box-shadow:inset 0 0 0 1px var(--bt-line);box-sizing:border-box;color:var(--bt-ink);font-size:14px;line-height:20px}+.bt-fail[data-settled]{gap:4px;padding:2px 0;background:none;box-shadow:none;color:var(--bt-ink-2);font-size:13px;line-height:18px}+.bt-fail-head{display:flex;align-items:flex-start;gap:8px;min-width:0}+.bt-fail-dot{flex:none;width:7px;height:7px;margin-top:6.5px;border-radius:50%;background:var(--bt-danger)}+.bt-fail[data-settled] .bt-fail-dot{margin-top:5.5px}+.bt-fail-text{min-width:0;overflow-wrap:anywhere}+.bt-fail-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-left:15px}+.bt-fail-actions .bt-fail-go{height:28px;padding:0 12px;font:inherit;font-size:12px}+.bt-fail-link{display:inline-flex;align-items:center;box-sizing:border-box;text-decoration:none}+.bt-fail:has(.bt-model-key){width:min(480px,86%)}+.bt-fail .bt-q.bt-model-key{margin:0 0 0 15px;width:auto;padding:0;background:none;box-shadow:none;border-radius:0;animation:none}+.bt-fail-error{margin-left:15px;font-size:12px;line-height:17px;color:var(--bt-danger);overflow-wrap:anywhere}+.bt-fail-tech{margin-left:15px;font-size:12px;line-height:17px;color:var(--bt-ink-2)}+.bt-fail-tech summary{width:max-content;cursor:pointer;color:var(--bt-ink-3)}+.bt-fail-tech summary:hover{color:var(--bt-ink-2)}+.bt-fail-tech dl{display:grid;grid-template-columns:auto minmax(0,1fr);gap:2px 10px;margin:6px 0}+.bt-fail-tech dt{color:var(--bt-ink-3)}+.bt-fail-tech dd{margin:0;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11.5px;overflow-wrap:anywhere;white-space:pre-wrap;user-select:text}+.bt-fail-copy{display:inline-flex;align-items:center;gap:4px}+.bt-fail-copy svg{width:13px;height:13px}+`;++// src/client/overlay-hooks.js+var import_react20 = require("react");+var escapeLayers = [];+var onEscapeKey = (event) => {+ if (event.key === "Escape") escapeLayers.at(-1)?.current();+};+function useEscape(onClose) {+ const ref = (0, import_react20.useRef)(onClose);+ ref.current = onClose;+ (0, import_react20.useEffect)(() => {+ if (escapeLayers.length === 0) window.addEventListener("keydown", onEscapeKey);+ escapeLayers.push(ref);+ return () => {+ escapeLayers.splice(escapeLayers.indexOf(ref), 1);+ if (escapeLayers.length === 0) window.removeEventListener("keydown", onEscapeKey);+ };+ }, []);+}+function usePaneLeft() {+ const [paneLeft, setPaneLeft] = (0, import_react20.useState)(280);+ (0, import_react20.useLayoutEffect)(() => {+ const column = document.querySelector('[class*="_footArea"]')?.parentElement;+ if (column) setPaneLeft(Math.round(column.getBoundingClientRect().right));+ }, []);+ return paneLeft;+}++// src/client/palette.js+var import_react21 = require("react");+var PALETTE_EXIT_MS = 160;+function CommandPalette({ start, token, roster, actions, useSessions }) {+ const [query, setQuery] = (0, import_react21.useState)(start ?? "");+ const [cursor, setCursor] = (0, import_react21.useState)(0);+ const [leaving, setLeaving] = (0, import_react21.useState)(false);+ const wanted = query.trim().toLowerCase();+ const close = () => {+ if (leaving) return;+ setLeaving(true);+ setTimeout(() => actions.closePalette(token), PALETTE_EXIT_MS);+ };+ useEscape(close);+ const ids = [...roster.bots.map(currentPart), ...roster.rooms.map((item) => item.id)];+ const found = useSessions((list) => {+ if (wanted.length < 2) return "[]";+ const hits = [];+ for (const id of ids) {+ const outline = list.projectionsBySession?.[id]?.values?.turnOutline ?? list.byId[id]?.projectionValues?.turnOutline;+ if (!Array.isArray(outline)) continue;+ const hidden = roster.exchangeTurns[id] ?? [];+ for (let index2 = outline.length - 1; index2 >= 0 && hits.length < 30; index2 -= 1) {+ const entry = outline[index2];+ if (hidden.includes(entry.turn)) continue;+ for (const raw of [entry.response, entry.prompt]) {+ const text = stripHeader(raw ?? "").replace(/\s+/g, " ").trim();+ const at = text.toLowerCase().indexOf(wanted);+ if (at < 0) continue;+ const from = Math.max(0, at - 24);+ hits.push([id, entry.turn, (from > 0 ? "…" : "") + text.slice(from, at + wanted.length + 60)]);+ break;+ }+ }+ }+ return JSON.stringify(hits);+ });+ const matchesName = (...fields) => wanted === "" || fields.some((field) => (field ?? "").toLowerCase().includes(wanted));+ const sections = [];+ const people = [+ ...roster.bots.filter((bot) => matchesName(bot.name, bot.role)).map((bot) => ({+ key: bot.id,+ avatar: (0, import_react21.createElement)(BotAvatar, { bot, size: 24, badge: false, live: false }),+ title: bot.name,+ subtitle: [bot.role, isMainOf(roster, bot.id) ? t("Main Bot") : ""].filter(Boolean).join(" · "),+ badge: bot.hidden ? t("Hidden") : void 0,+ run: async () => {+ if (bot.hidden) await actions.setFlags(bot.id, { hidden: false });+ actions.openSession(bot.id);+ }+ })),+ ...roster.rooms.filter((room2) => matchesName(room2.name)).map((room2) => ({+ key: room2.id,+ avatar: (0, import_react21.createElement)(RoomAvatar, { room: room2, roster, size: 24 }),+ title: room2.name,+ subtitle: t("{count} members", { count: room2.members.length }),+ badge: room2.hidden ? t("Hidden") : void 0,+ run: async () => {+ if (room2.hidden) await actions.setFlags(room2.id, { hidden: false });+ actions.openSession(room2.id);+ }+ }))+ ];+ if (people.length) sections.push([t("Bots"), people]);+ const agents = (roster.agents ?? []).filter(() => matchesName("DSH Agent")).map((agent) => ({+ key: agent.id,+ avatar: (0, import_react21.createElement)("span", { className: "bt-palette-agent" }, (0, import_react21.createElement)(import_dsh_client_ui_primitives.FishLogo, { size: 18 })),+ title: "DSH Agent",+ subtitle: t("Plain dsh session"),+ run: () => actions.openAgent(agent.id)+ }));+ if (agents.length) sections.push(["DSH Agent", agents]);+ const messages = JSON.parse(found).map(([id, turn, snippet]) => {+ const bot = roster.byId[id];+ const room2 = roster.roomsById[id];+ return {+ key: `${id}:${turn}`,+ title: bot?.name ?? room2?.name ?? t("Bot"),+ subtitle: snippet,+ avatar: bot ? (0, import_react21.createElement)(BotAvatar, { bot, size: 24, badge: false, live: false }) : (0, import_react21.createElement)(RoomAvatar, { room: room2, roster, size: 24 }),+ run: () => actions.openSession(id)+ };+ });+ if (messages.length) sections.push([t("Messages"), messages]);+ const commands = [+ { key: "cmd:new", icon: (0, import_react21.createElement)(PlusIcon), title: t("New chat"), run: () => actions.openNewChat("new") },+ { key: "cmd:bot", icon: (0, import_react21.createElement)(PlusIcon), title: t("Create Bot"), run: () => actions.openNewChat("create") },+ { key: "cmd:group", icon: (0, import_react21.createElement)(PeopleIcon), title: t("Create group chat"), run: () => actions.openNewChat("group") },+ { key: "cmd:settings", icon: (0, import_react21.createElement)(GearIcon), title: t("Bot settings"), run: () => actions.openSettings("general") }+ ].filter((command) => matchesName(command.title));+ if (commands.length) sections.push([t("Commands"), commands]);+ const rows2 = sections.flatMap(([, items]) => items);+ const active = Math.min(cursor, Math.max(rows2.length - 1, 0));+ const shown = rows2.map((row) => row.key).join("\n");+ const glide = useGlide(`${active}+${shown}`, { axis: "y", ...QUICK_EDGES });+ const listRef = glide.box;+ useFlip(listRef, shown, "[data-flip]");+ (0, import_react21.useEffect)(() => {+ listRef.current?.querySelector("[aria-selected=true]")?.scrollIntoView({ block: "nearest" });+ }, [active, query]);+ const choose = (row) => {+ if (!row || leaving) return;+ void Promise.resolve(row.run()).catch((error) => actions.reportError(error, "menu"));+ close();+ };+ let index = -1;+ return (0, import_react21.createElement)(+ "div",+ { className: "bt-palette-layer", "data-leaving": leaving || void 0 },+ (0, import_react21.createElement)("div", { className: "bt-backdrop", onMouseDown: close }),+ (0, import_react21.createElement)(+ "div",+ { className: "bt-palette", role: "dialog", "aria-label": t("Search"), "aria-modal": true },+ (0, import_react21.createElement)(+ "div",+ { className: "bt-palette-head" },+ (0, import_react21.createElement)("span", { className: "bt-palette-glyph", "aria-hidden": true }, (0, import_react21.createElement)(SearchIcon)),+ (0, import_react21.createElement)("input", {+ autoFocus: true,+ value: query,+ placeholder: t("Search Bots, chats and messages"),+ "aria-label": t("Search"),+ role: "combobox",+ "aria-expanded": true,+ "aria-controls": "bt-palette-list",+ onChange: (event) => {+ setQuery(event.target.value);+ setCursor(0);+ },+ onKeyDown: (event) => {+ if (event.nativeEvent.isComposing) return;+ if (event.key === "ArrowDown") {+ event.preventDefault();+ setCursor(Math.min(active + 1, rows2.length - 1));+ } else if (event.key === "ArrowUp") {+ event.preventDefault();+ setCursor(Math.max(active - 1, 0));+ } else if (event.key === "Enter") {+ event.preventDefault();+ choose(rows2[active]);+ }+ }+ }),+ query ? (0, import_react21.createElement)("button", { type: "button", className: "bt-palette-clear", "aria-label": t("Clear search"), onClick: () => {+ setQuery("");+ setCursor(0);+ } }, (0, import_react21.createElement)(CloseIcon)) : null+ ),+ (0, import_react21.createElement)(+ "div",+ { ref: listRef, id: "bt-palette-list", className: "bt-palette-list", role: "listbox", "aria-label": t("Results") },+ (0, import_react21.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),+ rows2.length === 0 ? (0, import_react21.createElement)(+ "div",+ { className: "bt-palette-empty" },+ (0, import_react21.createElement)("span", { className: "bt-palette-empty-icon", "aria-hidden": true }, (0, import_react21.createElement)(SearchIcon)),+ (0, import_react21.createElement)("span", { className: "bt-palette-empty-label" }, t("No results")),+ (0, import_react21.createElement)("span", { className: "bt-palette-empty-hint" }, t("Try a Bot name or words from a message"))+ ) : sections.map(([title, items]) => (0, import_react21.createElement)(+ import_react21.Fragment,+ { key: title },+ (0, import_react21.createElement)("div", { className: "bt-palette-section", role: "presentation", "data-flip": `section:${title}` }, title),+ items.map((row) => {+ index += 1;+ const at = index;+ return (0, import_react21.createElement)(+ "button",+ {+ key: row.key,+ type: "button",+ role: "option",+ className: "bt-palette-row",+ "aria-selected": at === active,+ "data-flip": row.key,+ onMouseMove: () => {+ if (cursor !== at) setCursor(at);+ },+ onClick: () => choose(row)+ },+ (0, import_react21.createElement)("span", { className: "bt-palette-lead" }, row.avatar ?? (0, import_react21.createElement)("span", { className: "bt-palette-cmd" }, row.icon)),+ (0, import_react21.createElement)(+ "span",+ { className: "bt-palette-text" },+ (0, import_react21.createElement)("span", { className: "bt-palette-title" }, row.title),+ row.subtitle ? (0, import_react21.createElement)("span", { className: "bt-palette-sub" }, row.subtitle) : null+ ),+ row.badge ? (0, import_react21.createElement)("span", { className: "bt-palette-badge" }, row.badge) : null+ );+ })+ ))+ )+ )+ );+}++// src/client/folder-menu.js+var import_react22 = require("react");+var import_react_dom7 = require("react-dom");+var folderName = (path) => String(path).replace(/[\\/]+$/, "").split(/[\\/]/).pop() || String(path);+var Tick = ({ on }) => (0, import_react22.createElement)("span", { className: "bt-model-tick", "aria-hidden": true }, on ? (0, import_react22.createElement)(CheckIcon) : null);+function FolderMenu({ value, group = false, team = false, actions, run: run2, onPick, wide = false, disabled = false }) {+ const { isOpen, shownPlace, leaving, button, menu, open, close } = useAnchoredMenu();+ const [info, setInfo] = (0, import_react22.useState)(null);+ const [view, setView] = (0, import_react22.useState)("list");+ const [draft, setDraft] = (0, import_react22.useState)("");+ const [listing, setListing] = (0, import_react22.useState)(null);+ const [problem, setProblem] = (0, import_react22.useState)("");+ const fallback = group ? t("Each Bot's own folder") : t("Team workspace");+ const toggle = () => {+ if (isOpen) {+ close();+ return;+ }+ setView("list");+ setProblem("");+ void Promise.resolve(actions.folders()).then(setInfo).catch(() => setInfo((last) => last ?? { team: null, picker: null, folders: [] }));+ open();+ };+ const choose = (path) => {+ close();+ if (path !== (value ?? "")) void onPick(path);};const browse = (path) => {setProblem("");@@ -10801,35 +11140,35 @@ function FolderMenu({ value, group = false, team = false, actions, run: run2, on};const known = info?.folders ?? [];const folders = value && !known.some((folder) => folder.path === value) ? [{ path: value, title: folderName(value) }, ...known] : known;- const listView = (0, import_react21.createElement)(+ const listView = (0, import_react22.createElement)("div",{ key: "list", className: "bt-folder-view" },- team ? null : (0, import_react21.createElement)(+ team ? null : (0, import_react22.createElement)("button",{ type: "button", role: "menuitemradio", "aria-checked": !value, title: group ? void 0 : info?.team ?? void 0, onClick: () => choose("") },- (0, import_react21.createElement)("span", { className: "bt-menu-label" }, fallback),- (0, import_react21.createElement)(Tick, { on: !value })+ (0, import_react22.createElement)("span", { className: "bt-menu-label" }, fallback),+ (0, import_react22.createElement)(Tick, { on: !value })),- folders.length > 0 ? (0, import_react21.createElement)("div", { className: "bt-model-group", role: "presentation" }, t("Folders")) : null,- folders.map((folder) => (0, import_react21.createElement)(+ folders.length > 0 ? (0, import_react22.createElement)("div", { className: "bt-model-group", role: "presentation" }, t("Folders")) : null,+ folders.map((folder) => (0, import_react22.createElement)("button",{ key: folder.path, type: "button", role: "menuitemradio", "aria-checked": folder.path === value, title: folder.path, onClick: () => choose(folder.path) },- (0, import_react21.createElement)("span", { className: "bt-folder-copy" }, (0, import_react21.createElement)("span", { className: "bt-menu-label" }, folder.title), (0, import_react21.createElement)("span", { className: "bt-folder-path" }, folder.path)),- (0, import_react21.createElement)(Tick, { on: folder.path === value })+ (0, import_react22.createElement)("span", { className: "bt-folder-copy" }, (0, import_react22.createElement)("span", { className: "bt-menu-label" }, folder.title), (0, import_react22.createElement)("span", { className: "bt-folder-path" }, folder.path)),+ (0, import_react22.createElement)(Tick, { on: folder.path === value }))),- (0, import_react21.createElement)("div", { className: "bt-menu-sep", role: "separator" }),- info?.picker === "native" ? (0, import_react21.createElement)("button", { type: "button", role: "menuitem", onClick: pickNative }, (0, import_react21.createElement)(FolderIcon), (0, import_react21.createElement)("span", { className: "bt-menu-label" }, t("Choose a folder…"))) : null,- info?.picker === "browse" ? (0, import_react21.createElement)("button", { type: "button", role: "menuitem", onClick: () => browse(value) }, (0, import_react21.createElement)(FolderIcon), (0, import_react21.createElement)("span", { className: "bt-menu-label" }, t("Browse folders…"))) : null,- (0, import_react21.createElement)("button", { type: "button", role: "menuitem", onClick: () => {+ (0, import_react22.createElement)("div", { className: "bt-menu-sep", role: "separator" }),+ info?.picker === "native" ? (0, import_react22.createElement)("button", { type: "button", role: "menuitem", onClick: pickNative }, (0, import_react22.createElement)(FolderIcon), (0, import_react22.createElement)("span", { className: "bt-menu-label" }, t("Choose a folder…"))) : null,+ info?.picker === "browse" ? (0, import_react22.createElement)("button", { type: "button", role: "menuitem", onClick: () => browse(value) }, (0, import_react22.createElement)(FolderIcon), (0, import_react22.createElement)("span", { className: "bt-menu-label" }, t("Browse folders…"))) : null,+ (0, import_react22.createElement)("button", { type: "button", role: "menuitem", onClick: () => {setDraft(value ?? "");setView("type");- } }, (0, import_react21.createElement)(PencilIcon), (0, import_react21.createElement)("span", { className: "bt-menu-label" }, t("Enter a path…")))+ } }, (0, import_react22.createElement)(PencilIcon), (0, import_react22.createElement)("span", { className: "bt-menu-label" }, t("Enter a path…"))));- const typeView = (0, import_react21.createElement)(+ const typeView = (0, import_react22.createElement)("div",{ key: "type", className: "bt-folder-view" },- (0, import_react21.createElement)("button", { type: "button", className: "bt-folder-back", onClick: () => setView("list") }, (0, import_react21.createElement)(ChevronLeftIcon), (0, import_react21.createElement)("span", { className: "bt-menu-label" }, t("Back"))),- (0, import_react21.createElement)("input", {+ (0, import_react22.createElement)("button", { type: "button", className: "bt-folder-back", onClick: () => setView("list") }, (0, import_react22.createElement)(ChevronLeftIcon), (0, import_react22.createElement)("span", { className: "bt-menu-label" }, t("Back"))),+ (0, import_react22.createElement)("input", {className: "bt-folder-input",autoFocus: true,value: draft,@@ -10841,33 +11180,33 @@ function FolderMenu({ value, group = false, team = false, actions, run: run2, onif (event.key === "Enter" && !event.nativeEvent.isComposing) typed();}}),- (0, import_react21.createElement)("button", { type: "button", className: "bt-folder-use", disabled: draft.trim() === "", onClick: typed }, t("Use this folder"))+ (0, import_react22.createElement)("button", { type: "button", className: "bt-folder-use", disabled: draft.trim() === "", onClick: typed }, t("Use this folder")));const parent = listing?.crumbs?.length > 1 ? listing.crumbs.at(-2) : void 0;const inside = listing?.entries?.filter((entry) => !entry.hidden) ?? [];- const browseView = listing ? (0, import_react21.createElement)(+ const browseView = listing ? (0, import_react22.createElement)("div",{ key: `browse:${listing.path}`, className: "bt-folder-view" },- (0, import_react21.createElement)("button", { type: "button", className: "bt-folder-back", onClick: () => setView("list") }, (0, import_react21.createElement)(ChevronLeftIcon), (0, import_react21.createElement)("span", { className: "bt-menu-label" }, t("Back"))),- (0, import_react21.createElement)("div", { className: "bt-folder-path bt-folder-here" }, listing.path),- parent ? (0, import_react21.createElement)("button", { type: "button", role: "menuitem", title: parent.path, onClick: () => browse(parent.path) }, (0, import_react21.createElement)(FolderIcon), (0, import_react21.createElement)("span", { className: "bt-menu-label" }, t("Up one level"))) : null,- inside.map((entry) => (0, import_react21.createElement)(+ (0, import_react22.createElement)("button", { type: "button", className: "bt-folder-back", onClick: () => setView("list") }, (0, import_react22.createElement)(ChevronLeftIcon), (0, import_react22.createElement)("span", { className: "bt-menu-label" }, t("Back"))),+ (0, import_react22.createElement)("div", { className: "bt-folder-path bt-folder-here" }, listing.path),+ parent ? (0, import_react22.createElement)("button", { type: "button", role: "menuitem", title: parent.path, onClick: () => browse(parent.path) }, (0, import_react22.createElement)(FolderIcon), (0, import_react22.createElement)("span", { className: "bt-menu-label" }, t("Up one level"))) : null,+ inside.map((entry) => (0, import_react22.createElement)("button",{ key: entry.path, type: "button", role: "menuitem", onClick: () => browse(entry.path) },- (0, import_react21.createElement)(FolderIcon),- (0, import_react21.createElement)("span", { className: "bt-menu-label" }, entry.name),- (0, import_react21.createElement)(ChevronRightIcon)+ (0, import_react22.createElement)(FolderIcon),+ (0, import_react22.createElement)("span", { className: "bt-menu-label" }, entry.name),+ (0, import_react22.createElement)(ChevronRightIcon))),- inside.length === 0 ? (0, import_react21.createElement)("div", { className: "bt-model-none" }, t("No folders inside.")) : null,- listing.truncated ? (0, import_react21.createElement)("div", { className: "bt-folder-path bt-folder-here" }, t("Some folders are not shown.")) : null,- (0, import_react21.createElement)("div", { className: "bt-menu-sep", role: "separator" }),- (0, import_react21.createElement)("button", { type: "button", className: "bt-folder-use", onClick: () => choose(listing.path) }, t("Use this folder"))+ inside.length === 0 ? (0, import_react22.createElement)("div", { className: "bt-model-none" }, t("No folders inside.")) : null,+ listing.truncated ? (0, import_react22.createElement)("div", { className: "bt-folder-path bt-folder-here" }, t("Some folders are not shown.")) : null,+ (0, import_react22.createElement)("div", { className: "bt-menu-sep", role: "separator" }),+ (0, import_react22.createElement)("button", { type: "button", className: "bt-folder-use", onClick: () => choose(listing.path) }, t("Use this folder"))) : null;const shownView = view === "type" ? typeView : view === "browse" && browseView ? browseView : listView;- return (0, import_react21.createElement)(- import_react21.Fragment,+ return (0, import_react22.createElement)(+ import_react22.Fragment,null,- (0, import_react21.createElement)(+ (0, import_react22.createElement)("button",{ref: button,@@ -10881,19 +11220,19 @@ function FolderMenu({ value, group = false, team = false, actions, run: run2, ononClick: toggle,disabled},- (0, import_react21.createElement)(+ (0, import_react22.createElement)("span",{ className: "bt-model-copy" },- (0, import_react21.createElement)("span", { className: "bt-model-name" }, value ? folderName(value) : fallback),- value ? (0, import_react21.createElement)("span", { className: "bt-model-provider" }, value) : null+ (0, import_react22.createElement)("span", { className: "bt-model-name" }, value ? folderName(value) : fallback),+ value ? (0, import_react22.createElement)("span", { className: "bt-model-provider" }, value) : null),- (0, import_react21.createElement)(Caret)+ (0, import_react22.createElement)(Caret)),- shownPlace ? (0, import_react_dom7.createPortal)((0, import_react21.createElement)(+ shownPlace ? (0, import_react_dom7.createPortal)((0, import_react22.createElement)("div",{ ref: menu, className: `bt-menu bt-model-menu bt-folder-menu${shownPlace.bottom !== void 0 ? " bt-menu-up" : ""}`, role: "menu", "aria-label": team ? t("Team workspace") : t("Working folder"), style: shownPlace, "data-leaving": leaving || void 0 },shownView,- problem ? (0, import_react21.createElement)("div", { className: "bt-folder-error", role: "alert" }, problem) : null+ problem ? (0, import_react22.createElement)("div", { className: "bt-folder-error", role: "alert" }, problem) : null), document.body) : null);}@@ -10914,7 +11253,7 @@ var FOLDER_CSS = ``;// src/client/schedules.js-var import_react22 = require("react");+var import_react23 = require("react");var POLL_MS = 3e4;var shared = null;var listeners = /* @__PURE__ */ new Set();@@ -10923,8 +11262,8 @@ function publish(view) {for (const listener of listeners) listener(view);}function useSchedules(actions) {- const [view, setView] = (0, import_react22.useState)(shared);- (0, import_react22.useEffect)(() => {+ const [view, setView] = (0, import_react23.useState)(shared);+ (0, import_react23.useEffect)(() => {listeners.add(setView);let stopped = false;let timer;@@ -10982,9 +11321,9 @@ function timingText(task) {}var nextText = (task) => task.status === "active" ? t("Next: {time}", { time: dayAndTime(Date.parse(task.scheduledAt)) }) : t("Finished");function TaskRow({ task, actions, onView, showBot, roster }) {- const [confirming, setConfirming] = (0, import_react22.useState)(false);- const [busy, setBusy] = (0, import_react22.useState)(false);- (0, import_react22.useEffect)(() => {+ const [confirming, setConfirming] = (0, import_react23.useState)(false);+ const [busy, setBusy] = (0, import_react23.useState)(false);+ (0, import_react23.useEffect)(() => {if (!confirming) return void 0;const timer = setTimeout(() => setConfirming(false), 3e3);return () => clearTimeout(timer);@@ -10998,19 +11337,19 @@ function TaskRow({ task, actions, onView, showBot, roster }) {void actions.scheduleDelete(task.sessionId, task.id).then(onView, () => setBusy(false));};const room2 = task.roomId ? roster.roomsById[task.roomId] : void 0;- return (0, import_react22.createElement)(+ return (0, import_react23.createElement)("div",{ className: "bt-set-row bt-task", "data-done": task.status === "active" ? void 0 : "", "data-busy": busy || void 0 },- showBot ? (0, import_react22.createElement)(BotAvatar, { bot: roster.byId[task.botId], size: 28, badge: false, live: false }) : null,- (0, import_react22.createElement)(+ showBot ? (0, import_react23.createElement)(BotAvatar, { bot: roster.byId[task.botId], size: 28, badge: false, live: false }) : null,+ (0, import_react23.createElement)("span",{ className: "bt-set-copy" },- (0, import_react22.createElement)("span", { className: "bt-task-title" }, task.title),- (0, import_react22.createElement)("span", { className: "bt-set-hint" }, [timingText(task), room2 ? t("in {name}", { name: room2.name }) : ""].filter(Boolean).join(" · ")),- task.prompt && task.prompt !== task.title ? (0, import_react22.createElement)("span", { className: "bt-task-prompt" }, task.prompt) : null+ (0, import_react23.createElement)("span", { className: "bt-task-title" }, task.title),+ (0, import_react23.createElement)("span", { className: "bt-set-hint" }, [timingText(task), room2 ? t("in {name}", { name: room2.name }) : ""].filter(Boolean).join(" · ")),+ task.prompt && task.prompt !== task.title ? (0, import_react23.createElement)("span", { className: "bt-task-prompt" }, task.prompt) : null),- (0, import_react22.createElement)("span", { className: "bt-task-next" }, nextText(task)),- (0, import_react22.createElement)("button", {+ (0, import_react23.createElement)("span", { className: "bt-task-next" }, nextText(task)),+ (0, import_react23.createElement)("button", {type: "button",className: "bt-mini bt-task-remove","data-confirm": confirming || void 0,@@ -11018,7 +11357,7 @@ function TaskRow({ task, actions, onView, showBot, roster }) {"aria-label": confirming ? t("Click again to delete") : t("Delete task"),title: confirming ? void 0 : t("Delete task"),onClick: remove- }, confirming ? t("Delete") : (0, import_react22.createElement)(TrashIcon))+ }, confirming ? t("Delete") : (0, import_react23.createElement)(TrashIcon)));}var pad = (number) => String(number).padStart(2, "0");@@ -11030,17 +11369,17 @@ function inAnHour() {var KINDS = [["at", "Once"], ["daily", "Every day"], ["weekly", "Every week"], ["every", "Repeat"]];var UNITS = [["minutes", 1, "minutes"], ["hours", 60, "hours"], ["days", 1440, "days"]];function TaskForm({ roster, actions, start, onDone, onCancel }) {- const [target, setTarget] = (0, import_react22.useState)(start ?? roster.bots[0]?.id ?? "");- const [title, setTitle] = (0, import_react22.useState)("");- const [prompt, setPrompt] = (0, import_react22.useState)("");- const [kind, setKind] = (0, import_react22.useState)("daily");- const [at, setAt] = (0, import_react22.useState)(inAnHour);- const [time, setTime] = (0, import_react22.useState)("09:00");- const [weekdays, setWeekdays] = (0, import_react22.useState)([1, 2, 3, 4, 5]);- const [count, setCount] = (0, import_react22.useState)(1);- const [unit, setUnit] = (0, import_react22.useState)("hours");- const [busy, setBusy] = (0, import_react22.useState)(false);- const [error, setError] = (0, import_react22.useState)("");+ const [target, setTarget] = (0, import_react23.useState)(start ?? roster.bots[0]?.id ?? "");+ const [title, setTitle] = (0, import_react23.useState)("");+ const [prompt, setPrompt] = (0, import_react23.useState)("");+ const [kind, setKind] = (0, import_react23.useState)("daily");+ const [at, setAt] = (0, import_react23.useState)(inAnHour);+ const [time, setTime] = (0, import_react23.useState)("09:00");+ const [weekdays, setWeekdays] = (0, import_react23.useState)([1, 2, 3, 4, 5]);+ const [count, setCount] = (0, import_react23.useState)(1);+ const [unit, setUnit] = (0, import_react23.useState)("hours");+ const [busy, setBusy] = (0, import_react23.useState)(false);+ const [error, setError] = (0, import_react23.useState)("");const timing = () => {if (kind === "at") return { kind, at: new Date(at).toISOString() };if (kind === "every") return { kind, minutes: Math.round(Number(count) * UNITS.find(([id]) => id === unit)[1]) };@@ -11065,101 +11404,101 @@ function TaskForm({ roster, actions, start, onDone, onCancel }) {});};const toggleDay = (day) => setWeekdays((days) => days.includes(day) ? days.filter((item) => item !== day) : [...days, day].sort());- return (0, import_react22.createElement)(+ return (0, import_react23.createElement)("form",{ className: "bt-set-card bt-task-form", onSubmit: submit },- (0, import_react22.createElement)(+ (0, import_react23.createElement)("label",{ className: "bt-set-row bt-bs-row" },- (0, import_react22.createElement)("span", { className: "bt-set-copy" }, (0, import_react22.createElement)("span", { className: "bt-bs-label" }, t("Send to"))),- (0, import_react22.createElement)(+ (0, import_react23.createElement)("span", { className: "bt-set-copy" }, (0, import_react23.createElement)("span", { className: "bt-bs-label" }, t("Send to"))),+ (0, import_react23.createElement)("select",{ className: "bt-select bt-task-bot", value: target, onChange: (event) => setTarget(event.target.value) },- (0, import_react22.createElement)("optgroup", { label: t("Bots") }, roster.bots.map((bot) => (0, import_react22.createElement)("option", { key: bot.id, value: bot.id }, bot.name))),- roster.rooms.length > 0 ? (0, import_react22.createElement)("optgroup", { label: t("Group chats") }, roster.rooms.map((room2) => (0, import_react22.createElement)("option", { key: room2.id, value: room2.id }, room2.name))) : null+ (0, import_react23.createElement)("optgroup", { label: t("Bots") }, roster.bots.map((bot) => (0, import_react23.createElement)("option", { key: bot.id, value: bot.id }, bot.name))),+ roster.rooms.length > 0 ? (0, import_react23.createElement)("optgroup", { label: t("Group chats") }, roster.rooms.map((room2) => (0, import_react23.createElement)("option", { key: room2.id, value: room2.id }, room2.name))) : null)),- (0, import_react22.createElement)(+ (0, import_react23.createElement)("label",{ className: "bt-set-row bt-bs-row" },- (0, import_react22.createElement)("span", { className: "bt-set-copy" }, (0, import_react22.createElement)("span", { className: "bt-bs-label" }, t("Name"))),- (0, import_react22.createElement)("input", { className: "bt-bs-input", value: title, maxLength: 120, placeholder: t("Morning briefing"), autoFocus: true, onChange: (event) => setTitle(event.target.value) })+ (0, import_react23.createElement)("span", { className: "bt-set-copy" }, (0, import_react23.createElement)("span", { className: "bt-bs-label" }, t("Name"))),+ (0, import_react23.createElement)("input", { className: "bt-bs-input", value: title, maxLength: 120, placeholder: t("Morning briefing"), autoFocus: true, onChange: (event) => setTitle(event.target.value) })),- (0, import_react22.createElement)(+ (0, import_react23.createElement)("label",{ className: "bt-set-row bt-bs-row bt-bs-stack" },- (0, import_react22.createElement)("span", { className: "bt-set-copy" }, (0, import_react22.createElement)("span", { className: "bt-bs-label" }, t("What to do"))),- (0, import_react22.createElement)("textarea", { className: "bt-bs-input bt-bs-area", value: prompt, rows: 3, placeholder: t("Sum up what changed since yesterday and what needs me today."), onChange: (event) => setPrompt(event.target.value) })+ (0, import_react23.createElement)("span", { className: "bt-set-copy" }, (0, import_react23.createElement)("span", { className: "bt-bs-label" }, t("What to do"))),+ (0, import_react23.createElement)("textarea", { className: "bt-bs-input bt-bs-area", value: prompt, rows: 3, placeholder: t("Sum up what changed since yesterday and what needs me today."), onChange: (event) => setPrompt(event.target.value) })),- (0, import_react22.createElement)(+ (0, import_react23.createElement)("div",{ className: "bt-set-row bt-bs-row bt-bs-stack" },- (0, import_react22.createElement)("span", { className: "bt-set-copy" }, (0, import_react22.createElement)("span", { className: "bt-bs-label" }, t("When"))),- (0, import_react22.createElement)(Segmented, { label: t("When"), value: kind }, KINDS.map(([id, label]) => (0, import_react22.createElement)("button", { key: id, type: "button", "aria-pressed": kind === id, onClick: () => setKind(id) }, t(label)))),- (0, import_react22.createElement)(+ (0, import_react23.createElement)("span", { className: "bt-set-copy" }, (0, import_react23.createElement)("span", { className: "bt-bs-label" }, t("When"))),+ (0, import_react23.createElement)(Segmented, { label: t("When"), value: kind }, KINDS.map(([id, label]) => (0, import_react23.createElement)("button", { key: id, type: "button", "aria-pressed": kind === id, onClick: () => setKind(id) }, t(label)))),+ (0, import_react23.createElement)("div",{ key: kind, className: "bt-task-when bt-veil" },- kind === "at" ? (0, import_react22.createElement)("input", { className: "bt-input", type: "datetime-local", value: at, "aria-label": t("Date and time"), onChange: (event) => setAt(event.target.value) }) : null,- kind === "weekly" ? (0, import_react22.createElement)("div", { className: "bt-task-days", role: "group", "aria-label": t("Days") }, [1, 2, 3, 4, 5, 6, 7].map((day) => (0, import_react22.createElement)("button", {+ kind === "at" ? (0, import_react23.createElement)("input", { className: "bt-input", type: "datetime-local", value: at, "aria-label": t("Date and time"), onChange: (event) => setAt(event.target.value) }) : null,+ kind === "weekly" ? (0, import_react23.createElement)("div", { className: "bt-task-days", role: "group", "aria-label": t("Days") }, [1, 2, 3, 4, 5, 6, 7].map((day) => (0, import_react23.createElement)("button", {key: day,type: "button",className: "bt-task-day","aria-pressed": weekdays.includes(day),onClick: () => toggleDay(day)}, when2(Date.UTC(2024, 0, day), { weekday: "narrow", timeZone: "UTC" })))) : null,- kind === "daily" || kind === "weekly" ? (0, import_react22.createElement)("input", { className: "bt-input bt-task-time", type: "time", value: time, "aria-label": t("Time"), onChange: (event) => setTime(event.target.value) }) : null,- kind === "every" ? (0, import_react22.createElement)(- import_react22.Fragment,+ kind === "daily" || kind === "weekly" ? (0, import_react23.createElement)("input", { className: "bt-input bt-task-time", type: "time", value: time, "aria-label": t("Time"), onChange: (event) => setTime(event.target.value) }) : null,+ kind === "every" ? (0, import_react23.createElement)(+ import_react23.Fragment,null,- (0, import_react22.createElement)("span", { className: "bt-task-every" }, t("Every")),- (0, import_react22.createElement)("input", { className: "bt-input bt-task-count", type: "number", min: 1, value: count, "aria-label": t("How many"), onChange: (event) => setCount(event.target.value) }),- (0, import_react22.createElement)(+ (0, import_react23.createElement)("span", { className: "bt-task-every" }, t("Every")),+ (0, import_react23.createElement)("input", { className: "bt-input bt-task-count", type: "number", min: 1, value: count, "aria-label": t("How many"), onChange: (event) => setCount(event.target.value) }),+ (0, import_react23.createElement)("select",{ className: "bt-select bt-task-unit", value: unit, "aria-label": t("Unit"), onChange: (event) => setUnit(event.target.value) },- UNITS.map(([id, , label]) => (0, import_react22.createElement)("option", { key: id, value: id }, t(label)))+ UNITS.map(([id, , label]) => (0, import_react23.createElement)("option", { key: id, value: id }, t(label))))) : null)),- error ? (0, import_react22.createElement)("div", { className: "bt-set-row" }, (0, import_react22.createElement)("span", { className: "bt-danger bt-set-hint" }, error)) : null,- (0, import_react22.createElement)(+ error ? (0, import_react23.createElement)("div", { className: "bt-set-row" }, (0, import_react23.createElement)("span", { className: "bt-danger bt-set-hint" }, error)) : null,+ (0, import_react23.createElement)("div",{ className: "bt-set-row bt-task-foot" },- (0, import_react22.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onCancel }, t("Cancel")),- (0, import_react22.createElement)("button", { type: "submit", className: "bt-send bt-soft-sm", disabled: busy || !target || title.trim() === "" || prompt.trim() === "" }, busy ? t("Creating…") : t("Create task"))+ (0, import_react23.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onCancel }, t("Cancel")),+ (0, import_react23.createElement)("button", { type: "submit", className: "bt-send bt-soft-sm", disabled: busy || !target || title.trim() === "" || prompt.trim() === "" }, busy ? t("Creating…") : t("Create task"))));}function AutomationOff({ actions }) {- return (0, import_react22.createElement)(+ return (0, import_react23.createElement)("div",{ className: "bt-set-card bt-task-off" },- (0, import_react22.createElement)("span", { className: "bt-task-off-mark" }, (0, import_react22.createElement)(ClockIcon)),- (0, import_react22.createElement)("span", { className: "bt-task-off-title" }, t("Turn on Automation tasks in DSH")),- (0, import_react22.createElement)("span", { className: "bt-set-hint" }, t("Switch on Automation tasks on the Plugins page in Harness settings.")),- actions.openHarnessSettings ? (0, import_react22.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: actions.openHarnessSettings }, t("Open Harness settings")) : null+ (0, import_react23.createElement)("span", { className: "bt-task-off-mark" }, (0, import_react23.createElement)(ClockIcon)),+ (0, import_react23.createElement)("span", { className: "bt-task-off-title" }, t("Turn on Automation tasks in DSH")),+ (0, import_react23.createElement)("span", { className: "bt-set-hint" }, t("Switch on Automation tasks on the Plugins page in Advanced settings (DeepSeek Harness).")),+ actions.openHarnessSettings ? (0, import_react23.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: actions.openHarnessSettings }, t("Open Advanced settings (DeepSeek Harness)")) : null);}function SchedulesPage({ roster, actions, start }) {const view = useSchedules(actions);- const [adding, setAdding] = (0, import_react22.useState)(Boolean(start));- if (view === null) return (0, import_react22.createElement)("div", { className: "bt-set-hint" }, t("Loading…"));- if (!view.available) return (0, import_react22.createElement)(AutomationOff, { actions });+ const [adding, setAdding] = (0, import_react23.useState)(Boolean(start));+ if (view === null) return (0, import_react23.createElement)("div", { className: "bt-set-hint" }, t("Loading…"));+ if (!view.available) return (0, import_react23.createElement)(AutomationOff, { actions });const shown = (next) => {publish(next);setAdding(false);};const byChat = [- ...roster.bots.map((bot) => [bot.id, (0, import_react22.createElement)(BotAvatar, { bot, size: 18, badge: false, live: false }), bot.name, view.tasks.filter((task) => task.botId === bot.id)]),- ...roster.rooms.map((room2) => [room2.id, (0, import_react22.createElement)(RoomAvatar, { room: room2, roster, size: 18 }), room2.name, view.tasks.filter((task) => task.botId === void 0 && task.roomId === room2.id)])+ ...roster.bots.map((bot) => [bot.id, (0, import_react23.createElement)(BotAvatar, { bot, size: 18, badge: false, live: false }), bot.name, view.tasks.filter((task) => task.botId === bot.id)]),+ ...roster.rooms.map((room2) => [room2.id, (0, import_react23.createElement)(RoomAvatar, { room: room2, roster, size: 18 }), room2.name, view.tasks.filter((task) => task.botId === void 0 && task.roomId === room2.id)])].filter(([, , , tasks]) => tasks.length > 0);return [- adding ? (0, import_react22.createElement)(TaskForm, { key: "form", roster, actions, start, onDone: shown, onCancel: () => setAdding(false) }) : (0, import_react22.createElement)("div", { key: "add", className: "bt-actions" }, (0, import_react22.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-with-icon", onClick: () => setAdding(true) }, (0, import_react22.createElement)(PlusIcon), t("New task"))),- byChat.length === 0 && !adding ? (0, import_react22.createElement)("div", { key: "none", className: "bt-set-card" }, (0, import_react22.createElement)("div", { className: "bt-set-row" }, (0, import_react22.createElement)("span", { className: "bt-set-hint" }, t("No scheduled tasks yet.")))) : byChat.map(([id, avatar, name, tasks]) => (0, import_react22.createElement)(+ adding ? (0, import_react23.createElement)(TaskForm, { key: "form", roster, actions, start, onDone: shown, onCancel: () => setAdding(false) }) : (0, import_react23.createElement)("div", { key: "add", className: "bt-actions" }, (0, import_react23.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-with-icon", onClick: () => setAdding(true) }, (0, import_react23.createElement)(PlusIcon), t("New task"))),+ byChat.length === 0 && !adding ? (0, import_react23.createElement)("div", { key: "none", className: "bt-set-card" }, (0, import_react23.createElement)("div", { className: "bt-set-row" }, (0, import_react23.createElement)("span", { className: "bt-set-hint" }, t("No scheduled tasks yet.")))) : byChat.map(([id, avatar, name, tasks]) => (0, import_react23.createElement)("section",{ key: id, className: "bt-set-section" },- (0, import_react22.createElement)("h3", { className: "bt-task-head" }, avatar, name),- (0, import_react22.createElement)("div", { className: "bt-set-card" }, tasks.map((task) => (0, import_react22.createElement)(TaskRow, { key: task.id, task, actions, roster, onView: publish })))+ (0, import_react23.createElement)("h3", { className: "bt-task-head" }, avatar, name),+ (0, import_react23.createElement)("div", { className: "bt-set-card" }, tasks.map((task) => (0, import_react23.createElement)(TaskRow, { key: task.id, task, actions, roster, onView: publish })))))];}@@ -11167,21 +11506,21 @@ function BotSchedules({ bot, roster, actions }) {const view = useSchedules(actions);if (view === null) return null;const tasks = view.available ? view.tasks.filter((task) => task.botId === bot.id) : [];- return (0, import_react22.createElement)(+ return (0, import_react23.createElement)("section",{ className: "bt-set-section" },- (0, import_react22.createElement)("h3", null, t("Scheduled tasks")),- (0, import_react22.createElement)(+ (0, import_react23.createElement)("h3", null, t("Scheduled tasks")),+ (0, import_react23.createElement)("div",{ className: "bt-set-card" },- !view.available ? (0, import_react22.createElement)(+ !view.available ? (0, import_react23.createElement)("div",{ className: "bt-set-row bt-bs-row" },- (0, import_react22.createElement)("span", { className: "bt-set-copy" }, (0, import_react22.createElement)("span", { className: "bt-set-hint" }, t("Switch on Automation tasks on the Plugins page in Harness settings."))),- actions.openHarnessSettings ? (0, import_react22.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: actions.openHarnessSettings }, t("Open Harness settings")) : null+ (0, import_react23.createElement)("span", { className: "bt-set-copy" }, (0, import_react23.createElement)("span", { className: "bt-set-hint" }, t("Switch on Automation tasks on the Plugins page in Advanced settings (DeepSeek Harness)."))),+ actions.openHarnessSettings ? (0, import_react23.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: actions.openHarnessSettings }, t("Open Advanced settings (DeepSeek Harness)")) : null) : [- ...tasks.map((task) => (0, import_react22.createElement)(TaskRow, { key: task.id, task, actions, roster, onView: publish })),- (0, import_react22.createElement)("button", { key: "new", type: "button", className: "bt-set-row bt-bs-row bt-gs-add", onClick: () => actions.openSettings("schedules", bot.id) }, (0, import_react22.createElement)(PlusIcon), t("New task"))+ ...tasks.map((task) => (0, import_react23.createElement)(TaskRow, { key: task.id, task, actions, roster, onView: publish })),+ (0, import_react23.createElement)("button", { key: "new", type: "button", className: "bt-set-row bt-bs-row bt-gs-add", onClick: () => actions.openSettings("schedules", bot.id) }, (0, import_react23.createElement)(PlusIcon), t("New task"))]));@@ -11189,16 +11528,16 @@ function BotSchedules({ bot, roster, actions }) {function ScheduleSummary({ bot, actions }) {const view = useSchedules(actions);const tasks = view?.available ? view.tasks.filter((task) => task.botId === bot.id && task.status === "active") : [];- return (0, import_react22.createElement)(+ return (0, import_react23.createElement)("div",null,- (0, import_react22.createElement)("div", { className: "bt-section-title" }, t("Scheduled tasks")),- tasks.length === 0 ? (0, import_react22.createElement)("button", { type: "button", className: "bt-more", onClick: () => actions.openSettings("schedules", bot.id) }, view?.available === false ? t("Switch on Automation tasks on the Plugins page in Harness settings.") : t("No scheduled tasks yet. Add one")) : (0, import_react22.createElement)("div", { className: "bt-task-list" }, tasks.slice(0, 3).map((task) => (0, import_react22.createElement)(+ (0, import_react23.createElement)("div", { className: "bt-section-title" }, t("Scheduled tasks")),+ tasks.length === 0 ? (0, import_react23.createElement)("button", { type: "button", className: "bt-more", onClick: () => actions.openSettings("schedules", bot.id) }, view?.available === false ? t("Switch on Automation tasks on the Plugins page in Advanced settings (DeepSeek Harness).") : t("No scheduled tasks yet. Add one")) : (0, import_react23.createElement)("div", { className: "bt-task-list" }, tasks.slice(0, 3).map((task) => (0, import_react23.createElement)("button",{ key: task.id, type: "button", className: "bt-task-line", onClick: () => actions.openSettings("schedules") },- (0, import_react22.createElement)(ClockIcon),- (0, import_react22.createElement)("span", { className: "bt-task-line-title" }, task.title),- (0, import_react22.createElement)("span", { className: "bt-task-line-when" }, timingText(task))+ (0, import_react23.createElement)(ClockIcon),+ (0, import_react23.createElement)("span", { className: "bt-task-line-title" }, task.title),+ (0, import_react23.createElement)("span", { className: "bt-task-line-when" }, timingText(task))))));}@@ -11249,7 +11588,7 @@ var SCHEDULE_CSS = ``;// src/client/capability-settings.js-var import_react23 = require("react");+var import_react24 = require("react");var blank = () => ({ name: "", kind: "mcp", description: "", transport: "stdio", command: "", argsText: "", envText: "{}", url: "", headersText: "{}", content: "", items: [] });var parseMap = (text, label) => {let value;@@ -11263,11 +11602,11 @@ var parseMap = (text, label) => {};var statusText = (status) => !status ? void 0 : status.state === "ready" ? t("Ready") : status.state === "needs-approval" ? t("Needs approval") : status.state === "error" ? t("Could not connect: {error}", { error: status.error ?? "" }) : t("Connecting…");function Field({ label, value, onChange, multiline = false, disabled = false, placeholder }) {- return (0, import_react23.createElement)(+ return (0, import_react24.createElement)("label",{ className: "bt-set-row bt-bs-row bt-bs-stack" },- (0, import_react23.createElement)("span", { className: "bt-set-copy" }, (0, import_react23.createElement)("span", { className: "bt-bs-label" }, t(label))),- (0, import_react23.createElement)(multiline ? "textarea" : "input", {+ (0, import_react24.createElement)("span", { className: "bt-set-copy" }, (0, import_react24.createElement)("span", { className: "bt-bs-label" }, t(label))),+ (0, import_react24.createElement)(multiline ? "textarea" : "input", {className: multiline ? "bt-input bt-input-area" : "bt-input",value,disabled,@@ -11279,7 +11618,7 @@ function Field({ label, value, onChange, multiline = false, disabled = false, pl);}function CapabilityForm({ draft, setDraft, items, actions, onClose }) {- const [error, setError] = (0, import_react23.useState)("");+ const [error, setError] = (0, import_react24.useState)("");const set = (key, value) => setDraft((previous) => ({ ...previous, [key]: value }));const submit = async (event) => {event.preventDefault();@@ -11310,95 +11649,95 @@ function CapabilityForm({ draft, setDraft, items, actions, onClose }) {}};const available = items.filter((item) => item.name !== draft.name && ["mcp", "skill"].includes(item.kind));- return (0, import_react23.createElement)(+ return (0, import_react24.createElement)("form",{ className: "bt-connector-form", onSubmit: submit },- (0, import_react23.createElement)(Field, { label: "Name", value: draft.name, disabled: draft.originalName !== void 0, onChange: (value) => set("name", value), placeholder: "my-tool" }),- (0, import_react23.createElement)(+ (0, import_react24.createElement)(Field, { label: "Name", value: draft.name, disabled: draft.originalName !== void 0, onChange: (value) => set("name", value), placeholder: "my-tool" }),+ (0, import_react24.createElement)("label",{ className: "bt-set-row bt-bs-row bt-bs-stack" },- (0, import_react23.createElement)("span", { className: "bt-set-copy" }, (0, import_react23.createElement)("span", { className: "bt-bs-label" }, t("Type"))),- (0, import_react23.createElement)(+ (0, import_react24.createElement)("span", { className: "bt-set-copy" }, (0, import_react24.createElement)("span", { className: "bt-bs-label" }, t("Type"))),+ (0, import_react24.createElement)("select",{ className: "bt-input", value: draft.kind, disabled: draft.originalName !== void 0, onChange: (event) => set("kind", event.target.value) },- ["mcp", "skill", "pack"].map((kind) => (0, import_react23.createElement)("option", { key: kind, value: kind }, t(kind === "mcp" ? "MCP server" : kind === "skill" ? "Skill" : "Pack")))+ ["mcp", "skill", "pack"].map((kind) => (0, import_react24.createElement)("option", { key: kind, value: kind }, t(kind === "mcp" ? "MCP server" : kind === "skill" ? "Skill" : "Pack"))))),- (0, import_react23.createElement)(Field, { label: "Description", value: draft.description, onChange: (value) => set("description", value) }),- draft.kind === "mcp" ? (0, import_react23.createElement)(+ (0, import_react24.createElement)(Field, { label: "Description", value: draft.description, onChange: (value) => set("description", value) }),+ draft.kind === "mcp" ? (0, import_react24.createElement)("label",{ className: "bt-set-row bt-bs-row bt-bs-stack" },- (0, import_react23.createElement)("span", { className: "bt-set-copy" }, (0, import_react23.createElement)("span", { className: "bt-bs-label" }, t("Connection"))),- (0, import_react23.createElement)(+ (0, import_react24.createElement)("span", { className: "bt-set-copy" }, (0, import_react24.createElement)("span", { className: "bt-bs-label" }, t("Connection"))),+ (0, import_react24.createElement)("select",{ className: "bt-input", value: draft.transport, onChange: (event) => set("transport", event.target.value) },- (0, import_react23.createElement)("option", { value: "stdio" }, t("Local command")),- (0, import_react23.createElement)("option", { value: "streamable-http" }, t("HTTP server"))+ (0, import_react24.createElement)("option", { value: "stdio" }, t("Local command")),+ (0, import_react24.createElement)("option", { value: "streamable-http" }, t("HTTP server")))) : null,- draft.kind === "mcp" && draft.transport === "stdio" ? (0, import_react23.createElement)(+ draft.kind === "mcp" && draft.transport === "stdio" ? (0, import_react24.createElement)("div",null,- (0, import_react23.createElement)(Field, { label: "Command", value: draft.command, onChange: (value) => set("command", value) }),- (0, import_react23.createElement)(Field, { label: "Arguments (one per line)", value: draft.argsText, onChange: (value) => set("argsText", value), multiline: true }),- (0, import_react23.createElement)(Field, { label: "Environment (JSON)", value: draft.envText, onChange: (value) => set("envText", value), multiline: true, placeholder: t('{"API_KEY": "$DSH_SECRET_MY_KEY"}') })+ (0, import_react24.createElement)(Field, { label: "Command", value: draft.command, onChange: (value) => set("command", value) }),+ (0, import_react24.createElement)(Field, { label: "Arguments (one per line)", value: draft.argsText, onChange: (value) => set("argsText", value), multiline: true }),+ (0, import_react24.createElement)(Field, { label: "Environment (JSON)", value: draft.envText, onChange: (value) => set("envText", value), multiline: true, placeholder: t('{"API_KEY": "$DSH_SECRET_MY_KEY"}') })) : null,- draft.kind === "mcp" && draft.transport === "streamable-http" ? (0, import_react23.createElement)(+ draft.kind === "mcp" && draft.transport === "streamable-http" ? (0, import_react24.createElement)("div",null,- (0, import_react23.createElement)(Field, { label: "URL", value: draft.url, onChange: (value) => set("url", value) }),- (0, import_react23.createElement)(Field, { label: "Headers (JSON)", value: draft.headersText, onChange: (value) => set("headersText", value), multiline: true, placeholder: t('{"API_KEY": "$DSH_SECRET_MY_KEY"}') })+ (0, import_react24.createElement)(Field, { label: "URL", value: draft.url, onChange: (value) => set("url", value) }),+ (0, import_react24.createElement)(Field, { label: "Headers (JSON)", value: draft.headersText, onChange: (value) => set("headersText", value), multiline: true, placeholder: t('{"API_KEY": "$DSH_SECRET_MY_KEY"}') })) : null,- draft.kind === "skill" ? (0, import_react23.createElement)(Field, { label: "Skill instructions", value: draft.content, onChange: (value) => set("content", value), multiline: true }) : null,- draft.kind === "pack" ? (0, import_react23.createElement)(+ draft.kind === "skill" ? (0, import_react24.createElement)(Field, { label: "Skill instructions", value: draft.content, onChange: (value) => set("content", value), multiline: true }) : null,+ draft.kind === "pack" ? (0, import_react24.createElement)("div",{ className: "bt-set-card" },- available.length === 0 ? (0, import_react23.createElement)("div", { className: "bt-set-row" }, (0, import_react23.createElement)("span", { className: "bt-set-hint" }, t("Save an MCP server or skill first."))) : available.map((item) => (0, import_react23.createElement)(+ available.length === 0 ? (0, import_react24.createElement)("div", { className: "bt-set-row" }, (0, import_react24.createElement)("span", { className: "bt-set-hint" }, t("Save an MCP server or skill first."))) : available.map((item) => (0, import_react24.createElement)("label",{ key: item.name, className: "bt-set-row bt-bs-row" },- (0, import_react23.createElement)("span", { className: "bt-set-copy" }, (0, import_react23.createElement)("span", { className: "bt-bs-label" }, item.name)),- (0, import_react23.createElement)("input", { type: "checkbox", checked: draft.items.includes(item.name), onChange: (event) => set("items", event.target.checked ? [...draft.items, item.name] : draft.items.filter((name) => name !== item.name)) })+ (0, import_react24.createElement)("span", { className: "bt-set-copy" }, (0, import_react24.createElement)("span", { className: "bt-bs-label" }, item.name)),+ (0, import_react24.createElement)("input", { type: "checkbox", checked: draft.items.includes(item.name), onChange: (event) => set("items", event.target.checked ? [...draft.items, item.name] : draft.items.filter((name) => name !== item.name)) })))) : null,- error ? (0, import_react23.createElement)("div", { className: "bt-connector-error", role: "alert" }, error) : null,- (0, import_react23.createElement)(+ error ? (0, import_react24.createElement)("div", { className: "bt-connector-error", role: "alert" }, error) : null,+ (0, import_react24.createElement)("div",{ className: "bt-connector-form-row" },- (0, import_react23.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onClose }, t("Cancel")),- (0, import_react23.createElement)("button", { type: "submit", className: "bt-soft bt-soft-sm" }, draft.originalName ? t("Save changes") : t("Add capability"))+ (0, import_react24.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onClose }, t("Cancel")),+ (0, import_react24.createElement)("button", { type: "submit", className: "bt-soft bt-soft-sm" }, draft.originalName ? t("Save changes") : t("Add capability"))));}function CapabilityRow({ item, onEdit, onDelete, onApprove, confirming }) {const detail = item.kind === "pack" ? `${t("Pack")}: ${(item.items ?? []).join(", ") || t("No items")}` : item.kind === "mcp" ? item.transport === "stdio" ? t("Local command") : t("HTTP server") : t("Skill");const secondary = item.kind === "pack" ? [item.description, (item.items ?? []).join(", ") || t("No items")].filter(Boolean).join(" · ") : item.description || detail;- return (0, import_react23.createElement)(+ return (0, import_react24.createElement)("div",{ className: "bt-connector" },- (0, import_react23.createElement)(+ (0, import_react24.createElement)("div",{ className: "bt-connector-head" },- (0, import_react23.createElement)(+ (0, import_react24.createElement)("span",{ className: "bt-connector-text" },- (0, import_react23.createElement)("span", { className: "bt-connector-name" }, item.name),- (0, import_react23.createElement)("span", { className: "bt-connector-status" }, secondary)+ (0, import_react24.createElement)("span", { className: "bt-connector-name" }, item.name),+ (0, import_react24.createElement)("span", { className: "bt-connector-status" }, secondary)),- (0, import_react23.createElement)(+ (0, import_react24.createElement)("span",{ className: "bt-connector-actions" },- item.kind === "mcp" && item.transport === "stdio" && !item.approved ? (0, import_react23.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onApprove }, t("Allow")) : null,- (0, import_react23.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onEdit }, t("Edit")),- (0, import_react23.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onDelete }, confirming ? t("Click again to delete.") : t("Delete"))+ item.kind === "mcp" && item.transport === "stdio" && !item.approved ? (0, import_react24.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onApprove }, t("Allow")) : null,+ (0, import_react24.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onEdit }, t("Edit")),+ (0, import_react24.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onDelete }, confirming ? t("Click again to delete.") : t("Delete")))));}function CapabilitiesPage({ roster, actions, run: run2 }) {const items = [...roster.capabilities ?? []].sort((a, b) => a.name.localeCompare(b.name));- const [draft, setDraft] = (0, import_react23.useState)(null);- const [confirming, setConfirming] = (0, import_react23.useState)("");- (0, import_react23.useEffect)(() => {+ const [draft, setDraft] = (0, import_react24.useState)(null);+ const [confirming, setConfirming] = (0, import_react24.useState)("");+ (0, import_react24.useEffect)(() => {if (!confirming) return void 0;const timer = setTimeout(() => setConfirming(""), 4e3);return () => clearTimeout(timer);@@ -11421,20 +11760,20 @@ function CapabilitiesPage({ roster, actions, run: run2 }) {setConfirming("");void run2(actions.deleteCapability(item.name));};- return (0, import_react23.createElement)(+ return (0, import_react24.createElement)("section",{ className: "bt-set-section" },- (0, import_react23.createElement)("h3", null, t("Shared capabilities")),- (0, import_react23.createElement)(+ (0, import_react24.createElement)("h3", null, t("Shared capabilities")),+ (0, import_react24.createElement)("div",{ className: "bt-actions" },- (0, import_react23.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: startNew }, t("Add capability"))+ (0, import_react24.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: startNew }, t("Add capability"))),- draft ? (0, import_react23.createElement)(CapabilityForm, { draft, setDraft, items, actions, onClose: () => setDraft(null) }) : null,- (0, import_react23.createElement)(+ draft ? (0, import_react24.createElement)(CapabilityForm, { draft, setDraft, items, actions, onClose: () => setDraft(null) }) : null,+ (0, import_react24.createElement)("div",{ className: "bt-set-card bt-connectors-card" },- items.length === 0 ? (0, import_react23.createElement)("div", { className: "bt-set-row" }, (0, import_react23.createElement)("span", { className: "bt-set-hint" }, t("No capabilities saved"))) : items.map((item) => (0, import_react23.createElement)(CapabilityRow, {+ items.length === 0 ? (0, import_react24.createElement)("div", { className: "bt-set-row" }, (0, import_react24.createElement)("span", { className: "bt-set-hint" }, t("No capabilities saved"))) : items.map((item) => (0, import_react24.createElement)(CapabilityRow, {key: item.name,item,confirming: confirming === item.name,@@ -11450,10 +11789,10 @@ function BotCapabilitiesCard({ bot, roster, actions, run: run2, Card: Card2, Swiconst attached = new Set(bot.capabilities ?? []);const statuses = roster.capabilityStatuses?.[bot.id] ?? {};if (items.length === 0) return null;- return (0, import_react23.createElement)(+ return (0, import_react24.createElement)(Card2,{ title: t("Capabilities") },- items.map((item) => (0, import_react23.createElement)(SwitchRow2, {+ items.map((item) => (0, import_react24.createElement)(SwitchRow2, {key: item.name,label: item.name,hint: attached.has(item.name) ? statusText(statuses[item.name]) : void 0,@@ -11464,7 +11803,7 @@ function BotCapabilitiesCard({ bot, roster, actions, run: run2, Card: Card2, Swi}// src/client/memory-panel.js-var import_react24 = require("react");+var import_react25 = require("react");var POLL_MS2 = 1500;var MENU_EXIT_MS2 = 120;var counts = /* @__PURE__ */ new Map();@@ -11475,8 +11814,8 @@ function noteCount(id, count) {for (const listener of countListeners) listener();}function useMemoryCount(id, actions) {- const [count, setCount] = (0, import_react24.useState)(counts.get(id) ?? null);- (0, import_react24.useEffect)(() => {+ const [count, setCount] = (0, import_react25.useState)(counts.get(id) ?? null);+ (0, import_react25.useEffect)(() => {const listener = () => setCount(counts.get(id) ?? null);countListeners.add(listener);listener();@@ -11495,16 +11834,16 @@ function useMemoryCount(id, actions) {function MemoryRow({ owner, actions }) {const count = useMemoryCount(owner.id, actions);const label = count === null ? t("Loading…") : count === 0 ? t("Nothing saved yet") : count === 1 ? t("1 entry") : t("{count} entries", { count });- return (0, import_react24.createElement)(+ return (0, import_react25.createElement)("div",null,- (0, import_react24.createElement)("div", { className: "bt-section-title" }, t("Memory")),- (0, import_react24.createElement)(+ (0, import_react25.createElement)("div", { className: "bt-section-title" }, t("Memory")),+ (0, import_react25.createElement)("button",{ type: "button", className: "bt-mem-row", "aria-label": t("Manage {name}'s memory", { name: owner.name }), onClick: () => actions.openMemory(owner.id) },- (0, import_react24.createElement)(MemoryIcon),- (0, import_react24.createElement)("span", { className: "bt-mem-row-copy" }, label),- (0, import_react24.createElement)("span", { className: "bt-mem-row-go" }, t("Manage"), (0, import_react24.createElement)(ChevronRightIcon))+ (0, import_react25.createElement)(MemoryIcon),+ (0, import_react25.createElement)("span", { className: "bt-mem-row-copy" }, label),+ (0, import_react25.createElement)("span", { className: "bt-mem-row-go" }, t("Manage"), (0, import_react25.createElement)(ChevronRightIcon))));}@@ -11519,45 +11858,45 @@ function ago(at, now) {return format.format(-Math.round(hours / 24), "day");}function Skeleton({ label }) {- return (0, import_react24.createElement)(+ return (0, import_react25.createElement)("div",{ className: "bt-mem-skel", "aria-busy": true },- [0, 1].map((block) => (0, import_react24.createElement)(+ [0, 1].map((block) => (0, import_react25.createElement)("div",{ key: block, className: "bt-mem-skel-block" },- (0, import_react24.createElement)("span", { className: "bt-mem-skel-head" }),- (0, import_react24.createElement)("span", null),- (0, import_react24.createElement)("span", null),- (0, import_react24.createElement)("span", { style: { width: block === 0 ? "62%" : "48%" } })+ (0, import_react25.createElement)("span", { className: "bt-mem-skel-head" }),+ (0, import_react25.createElement)("span", null),+ (0, import_react25.createElement)("span", null),+ (0, import_react25.createElement)("span", { style: { width: block === 0 ? "62%" : "48%" } }))),- label ? (0, import_react24.createElement)("div", { className: "bt-mem-skel-label" }, label) : null+ label ? (0, import_react25.createElement)("div", { className: "bt-mem-skel-label" }, label) : null);}function Summary({ owner, view, regenerate }) {if (view.entries.length === 0) {- return (0, import_react24.createElement)(+ return (0, import_react25.createElement)("div",{ className: "bt-mem-empty" },- (0, import_react24.createElement)("div", { className: "bt-mem-empty-mark" }, (0, import_react24.createElement)(MemoryIcon)),- (0, import_react24.createElement)("div", { className: "bt-mem-empty-title" }, owner.group ? t("Nothing is saved for this group yet") : t("{name} has not saved anything yet", { name: owner.name })),- (0, import_react24.createElement)("div", { className: "bt-mem-empty-text" }, owner.group ? t("A group keeps the decisions, rules, and facts its work needs, for its members to read here. Tell it below, or in the group.") : t("Bots keep lasting preferences, decisions, and what you ask them to remember. Tell {name} below, or in its chat.", { name: owner.name }))+ (0, import_react25.createElement)("div", { className: "bt-mem-empty-mark" }, (0, import_react25.createElement)(MemoryIcon)),+ (0, import_react25.createElement)("div", { className: "bt-mem-empty-title" }, owner.group ? t("Nothing is saved for this group yet") : t("{name} has not saved anything yet", { name: owner.name })),+ (0, import_react25.createElement)("div", { className: "bt-mem-empty-text" }, owner.group ? t("A group keeps the decisions, rules, and facts its work needs, for its members to read here. Tell it below, or in the group.") : t("Bots keep lasting preferences, decisions, and what you ask them to remember. Tell {name} below, or in its chat.", { name: owner.name })));}- const failed = view.error && !view.summarizing ? (0, import_react24.createElement)(+ const failed = view.error && !view.summarizing ? (0, import_react25.createElement)("div",{ className: "bt-mem-failed", role: "alert" },- (0, import_react24.createElement)("span", null, view.summary ? t("The summary is out of date: {reason}", { reason: hostText(view.error) }) : t("The summary could not be written: {reason}", { reason: hostText(view.error) })),- (0, import_react24.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: regenerate }, t("Try again"))+ (0, import_react25.createElement)("span", null, view.summary ? t("The summary is out of date: {reason}", { reason: hostText(view.error) }) : t("The summary could not be written: {reason}", { reason: hostText(view.error) })),+ (0, import_react25.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: regenerate }, t("Try again"))) : null;- if (!view.summary) return (0, import_react24.createElement)(import_react24.Fragment, null, failed, failed ? null : (0, import_react24.createElement)(Skeleton, { label: t("Writing the summary…") }));- return (0, import_react24.createElement)(- import_react24.Fragment,+ if (!view.summary) return (0, import_react25.createElement)(import_react25.Fragment, null, failed, failed ? null : (0, import_react25.createElement)(Skeleton, { label: t("Writing the summary…") }));+ return (0, import_react25.createElement)(+ import_react25.Fragment,null,failed,- (0, import_react24.createElement)(+ (0, import_react25.createElement)("div",{ key: view.summary.at, className: "bt-mem-summary", "data-stale": !view.fresh || void 0 },- summaryBlocks(view.summary.text).map((block, index) => block.kind === "h" ? (0, import_react24.createElement)("h3", { key: index }, block.text) : (0, import_react24.createElement)("p", { key: index }, block.text))+ summaryBlocks(view.summary.text).map((block, index) => block.kind === "h" ? (0, import_react25.createElement)("h3", { key: index }, block.text) : (0, import_react25.createElement)("p", { key: index }, block.text))));}@@ -11569,9 +11908,9 @@ var groupEntries = (entries2) => entries2.reduce((groups, entry) => {return groups;}, []);function EntryRow({ entry, remove }) {- const [confirming, setConfirming] = (0, import_react24.useState)(false);- const [busy, setBusy] = (0, import_react24.useState)(false);- (0, import_react24.useEffect)(() => {+ const [confirming, setConfirming] = (0, import_react25.useState)(false);+ const [busy, setBusy] = (0, import_react25.useState)(false);+ (0, import_react25.useEffect)(() => {if (!confirming) return void 0;const timer = setTimeout(() => setConfirming(false), 3e3);return () => clearTimeout(timer);@@ -11586,16 +11925,16 @@ function EntryRow({ entry, remove }) {setBusy(true);if (!await remove(entry)) setBusy(false);};- return (0, import_react24.createElement)(+ return (0, import_react25.createElement)("li",{ className: "bt-mem-entry", "data-busy": busy || void 0 },- (0, import_react24.createElement)(+ (0, import_react25.createElement)("div",{ className: "bt-mem-entry-copy" },- (0, import_react24.createElement)("span", { className: "bt-mem-entry-text" }, entry.text),- meta ? (0, import_react24.createElement)("span", { className: "bt-mem-entry-meta" }, meta) : null+ (0, import_react25.createElement)("span", { className: "bt-mem-entry-text" }, entry.text),+ meta ? (0, import_react25.createElement)("span", { className: "bt-mem-entry-meta" }, meta) : null),- (0, import_react24.createElement)("button", {+ (0, import_react25.createElement)("button", {type: "button",className: "bt-mem-remove","data-confirm": confirming || void 0,@@ -11603,7 +11942,7 @@ function EntryRow({ entry, remove }) {"aria-label": confirming ? t("Click again to remove") : t("Remove from memory"),title: confirming ? void 0 : t("Remove from memory"),onClick: click- }, confirming ? t("Remove") : (0, import_react24.createElement)(TrashIcon))+ }, confirming ? t("Remove") : (0, import_react25.createElement)(TrashIcon)));}function Entries({ owner, view, remove }) {@@ -11612,25 +11951,25 @@ function Entries({ owner, view, remove }) {{ scope: "own", title: t("{name}'s memory", { name: owner.name }), size: view.sizes.own },{ scope: "team", title: t("Team memory"), hint: t("Every Bot reads it"), size: view.sizes.team }];- return (0, import_react24.createElement)(+ return (0, import_react25.createElement)("div",{ className: "bt-mem-entries" },- sections.map((section) => (0, import_react24.createElement)(+ sections.map((section) => (0, import_react25.createElement)("section",{ key: section.scope, className: "bt-mem-section" },- (0, import_react24.createElement)(+ (0, import_react25.createElement)("div",{ className: "bt-mem-section-head" },- (0, import_react24.createElement)("h3", null, section.title),- section.hint ? (0, import_react24.createElement)("span", null, section.hint) : null,- (0, import_react24.createElement)("span", { className: "bt-mem-size", title: t("MEMORY.md, which every conversation reads") }, t("{used} of {limit} characters", { used: section.size.toLocaleString(dateLocale()), limit: view.limits.main.toLocaleString(dateLocale()) }))+ (0, import_react25.createElement)("h3", null, section.title),+ section.hint ? (0, import_react25.createElement)("span", null, section.hint) : null,+ (0, import_react25.createElement)("span", { className: "bt-mem-size", title: t("MEMORY.md, which every conversation reads") }, t("{used} of {limit} characters", { used: section.size.toLocaleString(dateLocale()), limit: view.limits.main.toLocaleString(dateLocale()) }))),- groups.some((group) => group.scope === section.scope) ? groups.filter((group) => group.scope === section.scope).map((group) => (0, import_react24.createElement)(- import_react24.Fragment,+ groups.some((group) => group.scope === section.scope) ? groups.filter((group) => group.scope === section.scope).map((group) => (0, import_react25.createElement)(+ import_react25.Fragment,{ key: group.key },- group.topic ? (0, import_react24.createElement)("div", { className: "bt-mem-topic" }, group.topic) : null,- (0, import_react24.createElement)("ul", { className: "bt-mem-list" }, group.entries.map((entry) => (0, import_react24.createElement)(EntryRow, { key: `${entry.topic ?? ""}:${entry.text}`, entry, remove })))- )) : (0, import_react24.createElement)("div", { className: "bt-mem-none" }, t("Nothing saved yet"))+ group.topic ? (0, import_react25.createElement)("div", { className: "bt-mem-topic" }, group.topic) : null,+ (0, import_react25.createElement)("ul", { className: "bt-mem-list" }, group.entries.map((entry) => (0, import_react25.createElement)(EntryRow, { key: `${entry.topic ?? ""}:${entry.text}`, entry, remove })))+ )) : (0, import_react25.createElement)("div", { className: "bt-mem-none" }, t("Nothing saved yet")))));}@@ -11642,40 +11981,40 @@ function changeLine(change) {return change.scope === "team" ? t("Added to team memory: {text}", { text }) : t("Added: {text}", { text });}function Reply({ answer, dismiss }) {- return (0, import_react24.createElement)(+ return (0, import_react25.createElement)("div",{ className: "bt-mem-reply", role: "status" },- (0, import_react24.createElement)(+ (0, import_react25.createElement)("div",{ className: "bt-mem-reply-head" },- (0, import_react24.createElement)("span", { className: "bt-mem-reply-asked" }, answer.asked),- answer.pending ? null : (0, import_react24.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Dismiss"), onClick: dismiss }, (0, import_react24.createElement)(CloseIcon))+ (0, import_react25.createElement)("span", { className: "bt-mem-reply-asked" }, answer.asked),+ answer.pending ? null : (0, import_react25.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Dismiss"), onClick: dismiss }, (0, import_react25.createElement)(CloseIcon))),- answer.pending ? (0, import_react24.createElement)("div", { className: "bt-mem-reply-text bt-shimmer" }, t("Thinking…")) : answer.error ? (0, import_react24.createElement)("div", { className: "bt-mem-reply-text bt-danger" }, hostText(answer.error)) : (0, import_react24.createElement)(- import_react24.Fragment,+ answer.pending ? (0, import_react25.createElement)("div", { className: "bt-mem-reply-text bt-shimmer" }, t("Thinking…")) : answer.error ? (0, import_react25.createElement)("div", { className: "bt-mem-reply-text bt-danger" }, hostText(answer.error)) : (0, import_react25.createElement)(+ import_react25.Fragment,null,- answer.reply ? (0, import_react24.createElement)("div", { className: "bt-mem-reply-text" }, answer.reply) : null,- answer.changes.length > 0 ? (0, import_react24.createElement)("ul", { className: "bt-mem-changes" }, answer.changes.map((change, index) => (0, import_react24.createElement)(+ answer.reply ? (0, import_react25.createElement)("div", { className: "bt-mem-reply-text" }, answer.reply) : null,+ answer.changes.length > 0 ? (0, import_react25.createElement)("ul", { className: "bt-mem-changes" }, answer.changes.map((change, index) => (0, import_react25.createElement)("li",{ key: index, "data-ok": change.ok || void 0 },- change.ok ? (0, import_react24.createElement)(CheckIcon) : (0, import_react24.createElement)(CloseIcon),- (0, import_react24.createElement)("span", null, changeLine(change))+ change.ok ? (0, import_react25.createElement)(CheckIcon) : (0, import_react25.createElement)(CloseIcon),+ (0, import_react25.createElement)("span", null, changeLine(change))))) : null));}function useMemoryView(id, actions) {- const [view, setView] = (0, import_react24.useState)(null);- const [error, setError] = (0, import_react24.useState)("");- const timer = (0, import_react24.useRef)(0);- const latest = (0, import_react24.useRef)(0);- const alive = (0, import_react24.useRef)(true);- const show2 = (0, import_react24.useCallback)((next) => {+ const [view, setView] = (0, import_react25.useState)(null);+ const [error, setError] = (0, import_react25.useState)("");+ const timer = (0, import_react25.useRef)(0);+ const latest = (0, import_react25.useRef)(0);+ const alive = (0, import_react25.useRef)(true);+ const show2 = (0, import_react25.useCallback)((next) => {setView(next);setError("");noteCount(id, next.entries.length);}, [id]);- const load = (0, import_react24.useCallback)(async (flags = {}) => {+ const load = (0, import_react25.useCallback)(async (flags = {}) => {clearTimeout(timer.current);const ticket = ++latest.current;try {@@ -11687,7 +12026,7 @@ function useMemoryView(id, actions) {if (alive.current && ticket === latest.current) setError(failure?.message ?? String(failure));}}, [id]);- (0, import_react24.useEffect)(() => {+ (0, import_react25.useEffect)(() => {alive.current = true;void load({ summarize: true });return () => {@@ -11698,8 +12037,8 @@ function useMemoryView(id, actions) {return { view, error, load, show: show2 };}function useNow(every) {- const [now, setNow] = (0, import_react24.useState)(Date.now());- (0, import_react24.useEffect)(() => {+ const [now, setNow] = (0, import_react25.useState)(Date.now());+ (0, import_react25.useEffect)(() => {const id = setInterval(() => setNow(Date.now()), every);return () => clearInterval(id);}, [every]);@@ -11707,18 +12046,18 @@ function useNow(every) {}function MemoryDialog({ owner, actions, leaving = false }) {const { view, error, load, show: show2 } = useMemoryView(owner.id, actions);- const [page, setPage] = (0, import_react24.useState)("summary");- const [menu, setMenu] = (0, import_react24.useState)(false);+ const [page, setPage] = (0, import_react25.useState)("summary");+ const [menu, setMenu] = (0, import_react25.useState)(false);const [menuShown, menuLeaving] = useLinger(menu, MENU_EXIT_MS2);- const [text, setText] = (0, import_react24.useState)("");- const [answer, setAnswer] = (0, import_react24.useState)(null);- const menuRef = (0, import_react24.useRef)(null);- const dotsRef = (0, import_react24.useRef)(null);- const inputRef = (0, import_react24.useRef)(null);+ const [text, setText] = (0, import_react25.useState)("");+ const [answer, setAnswer] = (0, import_react25.useState)(null);+ const menuRef = (0, import_react25.useRef)(null);+ const dotsRef = (0, import_react25.useRef)(null);+ const inputRef = (0, import_react25.useRef)(null);const now = useNow(3e4);- const close = (0, import_react24.useCallback)(() => actions.closeMemory(), []);+ const close = (0, import_react25.useCallback)(() => actions.closeMemory(), []);useEscape(close);- (0, import_react24.useEffect)(() => {+ (0, import_react25.useEffect)(() => {if (!menu) return void 0;const onDown = (event) => {if (menuRef.current?.contains(event.target) || dotsRef.current?.contains(event.target)) return;@@ -11780,52 +12119,52 @@ function MemoryDialog({ owner, actions, leaving = false }) {const when3 = view?.summary ? ago(view.summary.at, now) : null;const status = view === null ? "" : page === "entries" ? count === 1 ? t("1 entry") : t("{count} entries", { count }) : view.summarizing && view.summary ? t("Updating…") : view.summary && view.fresh ? when3 ? t("Updated {time}", { time: when3 }) : t("Updated just now") : "";const busy = answer?.pending === true;- return (0, import_react24.createElement)(+ return (0, import_react25.createElement)("div",{ className: "bt-mem-layer", "data-leaving": leaving || void 0 },- (0, import_react24.createElement)("div", { className: "bt-scrim bt-mem-scrim", onMouseDown: close }),- (0, import_react24.createElement)(+ (0, import_react25.createElement)("div", { className: "bt-scrim bt-mem-scrim", onMouseDown: close }),+ (0, import_react25.createElement)("div",{ className: "bt-mem", role: "dialog", "aria-modal": true, "aria-label": t("{name}'s memory", { name: owner.name }) },- (0, import_react24.createElement)(+ (0, import_react25.createElement)("div",{ className: "bt-mem-head" },- page === "entries" ? (0, import_react24.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back to the summary"), onClick: backToSummary }, (0, import_react24.createElement)(ChevronLeftIcon)) : null,- (0, import_react24.createElement)("h2", null, page === "entries" ? t("All entries") : t("Memory summary")),- (0, import_react24.createElement)("span", { className: "bt-mem-status" }, page === "summary" ? [owner.name, status].filter(Boolean).join(" · ") : status),- (0, import_react24.createElement)("span", { className: "bt-mem-head-gap" }),- (0, import_react24.createElement)("button", { ref: dotsRef, type: "button", className: "bt-icon-btn", "aria-label": t("Memory options"), "aria-haspopup": "menu", "aria-expanded": menu, onClick: () => setMenu((value) => !value) }, (0, import_react24.createElement)(DotsIcon)),- (0, import_react24.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Close memory"), onClick: close }, (0, import_react24.createElement)(CloseIcon)),- menuShown ? (0, import_react24.createElement)(+ page === "entries" ? (0, import_react25.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back to the summary"), onClick: backToSummary }, (0, import_react25.createElement)(ChevronLeftIcon)) : null,+ (0, import_react25.createElement)("h2", null, page === "entries" ? t("All entries") : t("Memory summary")),+ (0, import_react25.createElement)("span", { className: "bt-mem-status" }, page === "summary" ? [owner.name, status].filter(Boolean).join(" · ") : status),+ (0, import_react25.createElement)("span", { className: "bt-mem-head-gap" }),+ (0, import_react25.createElement)("button", { ref: dotsRef, type: "button", className: "bt-icon-btn", "aria-label": t("Memory options"), "aria-haspopup": "menu", "aria-expanded": menu, onClick: () => setMenu((value) => !value) }, (0, import_react25.createElement)(DotsIcon)),+ (0, import_react25.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Close memory"), onClick: close }, (0, import_react25.createElement)(CloseIcon)),+ menuShown ? (0, import_react25.createElement)("div",{ ref: menuRef, className: "bt-menu bt-mem-menu", role: "menu", "aria-label": t("Memory options"), "data-leaving": menuLeaving || void 0 },- (0, import_react24.createElement)(+ (0, import_react25.createElement)("button",{ type: "button", role: "menuitem", onClick: openEntries },- (0, import_react24.createElement)("span", { className: "bt-menu-label" }, t("All entries")),- (0, import_react24.createElement)("span", { className: "bt-menu-hint" }, String(count))+ (0, import_react25.createElement)("span", { className: "bt-menu-label" }, t("All entries")),+ (0, import_react25.createElement)("span", { className: "bt-menu-hint" }, String(count))),- (0, import_react24.createElement)(+ (0, import_react25.createElement)("button",{ type: "button", role: "menuitem", disabled: count === 0 || view?.summarizing, onClick: regenerate },- (0, import_react24.createElement)("span", { className: "bt-menu-label" }, t("Regenerate summary"))+ (0, import_react25.createElement)("span", { className: "bt-menu-label" }, t("Regenerate summary")))) : null),- (0, import_react24.createElement)(+ (0, import_react25.createElement)("div",{ className: "bt-mem-body" },- error ? (0, import_react24.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, hostText(error)) : null,- view === null ? error ? null : (0, import_react24.createElement)(Skeleton) : page === "entries" ? (0, import_react24.createElement)(Entries, { owner, view, remove }) : (0, import_react24.createElement)(Summary, { owner, view, regenerate })+ error ? (0, import_react25.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, hostText(error)) : null,+ view === null ? error ? null : (0, import_react25.createElement)(Skeleton) : page === "entries" ? (0, import_react25.createElement)(Entries, { owner, view, remove }) : (0, import_react25.createElement)(Summary, { owner, view, regenerate })),- (0, import_react24.createElement)(+ (0, import_react25.createElement)("div",{ className: "bt-mem-foot" },- answer ? (0, import_react24.createElement)(Reply, { answer, dismiss: () => setAnswer(null) }) : null,- (0, import_react24.createElement)(+ answer ? (0, import_react25.createElement)(Reply, { answer, dismiss: () => setAnswer(null) }) : null,+ (0, import_react25.createElement)("form",{ className: "bt-mem-ask", onSubmit: ask },- (0, import_react24.createElement)("input", {+ (0, import_react25.createElement)("input", {ref: inputRef,className: "bt-mem-input",value: text,@@ -11835,10 +12174,10 @@ function MemoryDialog({ owner, actions, leaving = false }) {"aria-label": t("Ask about or update {name}'s memory", { name: owner.name }),onChange: (event) => setText(event.target.value)}),- (0, import_react24.createElement)(+ (0, import_react25.createElement)("button",{ type: "submit", className: "bt-mem-send", disabled: busy || text.trim() === "", "aria-label": t("Send") },- busy ? (0, import_react24.createElement)("span", { className: "bt-mem-spin", "aria-hidden": true }) : (0, import_react24.createElement)(ArrowUpIcon)+ busy ? (0, import_react25.createElement)("span", { className: "bt-mem-spin", "aria-hidden": true }) : (0, import_react25.createElement)(ArrowUpIcon))))@@ -11847,7 +12186,7 @@ function MemoryDialog({ owner, actions, leaving = false }) {}// src/client/bot-settings.js-var import_react25 = require("react");+var import_react26 = require("react");var capitalize = (word) => word[0].toUpperCase() + word.slice(1);async function avatarImage(file) {if (!/^image\/(png|jpeg|webp|gif)$/.test(file.type)) throw new Error(t("Choose a PNG, JPEG, WebP, or GIF image"));@@ -11871,8 +12210,8 @@ async function avatarImage(file) {throw new Error(t("That image is too large"));}function InlineText({ label, value, placeholder, required = false, maxLength, multiline = false, onSave }) {- const [draft, setDraft] = (0, import_react25.useState)(null);- const reverting = (0, import_react25.useRef)(false);+ const [draft, setDraft] = (0, import_react26.useState)(null);+ const reverting = (0, import_react26.useRef)(false);const commit = () => {const next = draft?.trim();setDraft(null);@@ -11883,7 +12222,7 @@ function InlineText({ label, value, placeholder, required = false, maxLength, muif (next === void 0 || next === (value ?? "") || required && next === "") return;void onSave(next);};- return (0, import_react25.createElement)(multiline ? "textarea" : "input", {+ return (0, import_react26.createElement)(multiline ? "textarea" : "input", {className: multiline ? "bt-bs-input bt-bs-area" : "bt-bs-input",value: draft ?? value ?? "",placeholder,@@ -11904,29 +12243,29 @@ function InlineText({ label, value, placeholder, required = false, maxLength, mu});}function Row({ label, hint, stack = false, children }) {- return (0, import_react25.createElement)(+ return (0, import_react26.createElement)("label",{ className: stack ? "bt-set-row bt-bs-row bt-bs-stack" : "bt-set-row bt-bs-row" },- (0, import_react25.createElement)("span", { className: "bt-set-copy" }, (0, import_react25.createElement)("span", { className: "bt-bs-label" }, label), hint ? (0, import_react25.createElement)("span", { className: "bt-set-hint" }, hint) : null),+ (0, import_react26.createElement)("span", { className: "bt-set-copy" }, (0, import_react26.createElement)("span", { className: "bt-bs-label" }, label), hint ? (0, import_react26.createElement)("span", { className: "bt-set-hint" }, hint) : null),children);}function Card({ title, children }) {- return (0, import_react25.createElement)("section", { className: "bt-set-section" }, title ? (0, import_react25.createElement)("h3", null, title) : null, (0, import_react25.createElement)("div", { className: "bt-set-card" }, children));+ return (0, import_react26.createElement)("section", { className: "bt-set-section" }, title ? (0, import_react26.createElement)("h3", null, title) : null, (0, import_react26.createElement)("div", { className: "bt-set-card" }, children));}function Switch({ on, label, disabled, onChange }) {- return (0, import_react25.createElement)(+ return (0, import_react26.createElement)("button",{ type: "button", role: "switch", className: "bt-switch", "aria-checked": on, "aria-label": label, disabled, onClick: () => onChange(!on) },- (0, import_react25.createElement)("span", { className: "bt-switch-knob", "aria-hidden": true })+ (0, import_react26.createElement)("span", { className: "bt-switch-knob", "aria-hidden": true }));}function SwitchRow({ label, hint, on, disabled, onChange }) {- return (0, import_react25.createElement)(+ return (0, import_react26.createElement)("div",{ className: "bt-set-row bt-bs-row" },- (0, import_react25.createElement)("span", { className: "bt-set-copy" }, (0, import_react25.createElement)("span", { className: "bt-bs-label" }, label), hint ? (0, import_react25.createElement)("span", { className: "bt-set-hint" }, hint) : null),- (0, import_react25.createElement)(Switch, { on, label, disabled, onChange })+ (0, import_react26.createElement)("span", { className: "bt-set-copy" }, (0, import_react26.createElement)("span", { className: "bt-bs-label" }, label), hint ? (0, import_react26.createElement)("span", { className: "bt-set-hint" }, hint) : null),+ (0, import_react26.createElement)(Switch, { on, label, disabled, onChange }));}function modelHint(bot, roster) {@@ -11937,22 +12276,22 @@ function modelHint(bot, roster) {return t("Applies from the next message.");}function ShapeRing({ shape, size }) {- const maskId = (0, import_react25.useRef)("");+ const maskId = (0, import_react26.useRef)("");if (maskId.current === "") maskId.current = `bt-ring-${nextMarkSerial()}`;const def = shapeOf(shape);const unit = def.size / size;const markup = `<defs><mask id="${maskId.current}" ${maskBox(def.size)}>${holes(def, `<g stroke="#000" stroke-width="${6 * unit}" stroke-linejoin="round">${bodyOf(def, "#000", true)}</g>`)}</mask></defs><g mask="url(#${maskId.current})" stroke="currentColor" stroke-width="${8 * unit}" stroke-linejoin="round">${bodyOf(def, "currentColor", true)}</g>`;- return (0, import_react25.createElement)("svg", { className: "bt-ring", viewBox: `0 0 ${def.size} ${def.size}`, "aria-hidden": true, dangerouslySetInnerHTML: { __html: markup } });+ return (0, import_react26.createElement)("svg", { className: "bt-ring", viewBox: `0 0 ${def.size} ${def.size}`, "aria-hidden": true, dangerouslySetInnerHTML: { __html: markup } });}function CharacterGrid({ look, hasPhoto = false, onShape, onColor }) {const shapes = [...PICKER_SHAPES, ...Object.keys(SHAPES).filter((id) => !Object.hasOwn(CHARACTERS, id))];if (!shapes.includes(look.shape)) shapes.push(look.shape);const rows2 = [];for (let index = 0; index < shapes.length; index += PICKER_COLUMNS) rows2.push(shapes.slice(index, index + PICKER_COLUMNS));- return (0, import_react25.createElement)(- import_react25.Fragment,+ return (0, import_react26.createElement)(+ import_react26.Fragment,null,- (0, import_react25.createElement)("div", { className: "bt-shapes", role: "group", "aria-label": t("Character shape") }, rows2.map((row, index) => (0, import_react25.createElement)("div", { key: index, className: "bt-shape-row" }, row.map((id) => (0, import_react25.createElement)("button", {+ (0, import_react26.createElement)("div", { className: "bt-shapes", role: "group", "aria-label": t("Character shape") }, rows2.map((row, index) => (0, import_react26.createElement)("div", { key: index, className: "bt-shape-row" }, row.map((id) => (0, import_react26.createElement)("button", {key: id,type: "button",className: "bt-shape",@@ -11960,8 +12299,8 @@ function CharacterGrid({ look, hasPhoto = false, onShape, onColor }) {title: t(shapeOf(id).label),"aria-pressed": !hasPhoto && look.shape === id,onClick: () => onShape(id)- }, (0, import_react25.createElement)(ShapeRing, { shape: id, size: 36 }), (0, import_react25.createElement)(BotMark, { look: { shape: id, color: look.color }, size: 36 })))))),- (0, import_react25.createElement)("div", { className: "bt-colors", role: "group", "aria-label": t("Character color") }, CHARACTER_COLORS.map((color) => (0, import_react25.createElement)("button", {+ }, (0, import_react26.createElement)(ShapeRing, { shape: id, size: 36 }), (0, import_react26.createElement)(BotMark, { look: { shape: id, color: look.color }, size: 36 })))))),+ (0, import_react26.createElement)("div", { className: "bt-colors", role: "group", "aria-label": t("Character color") }, CHARACTER_COLORS.map((color) => (0, import_react26.createElement)("button", {key: color,type: "button",className: "bt-color",@@ -11969,19 +12308,19 @@ function CharacterGrid({ look, hasPhoto = false, onShape, onColor }) {title: t(capitalize(color)),"aria-pressed": look.color === color,onClick: () => onColor(color)- }, (0, import_react25.createElement)("span", { style: { background: paintCss(color) } }))))+ }, (0, import_react26.createElement)("span", { style: { background: paintCss(color) } })))));}function AvatarEditor({ bot, actions, run: run2, onClose }) {const look = lookOf(bot);- const [tab, setTab] = (0, import_react25.useState)(look.image ? "upload" : "bot");- const [over, setOver] = (0, import_react25.useState)(false);- const ref = (0, import_react25.useRef)(null);- const fileRef = (0, import_react25.useRef)(null);+ const [tab, setTab] = (0, import_react26.useState)(look.image ? "upload" : "bot");+ const [over, setOver] = (0, import_react26.useState)(false);+ const ref = (0, import_react26.useRef)(null);+ const fileRef = (0, import_react26.useRef)(null);const upload = (file) => {if (file) void run2(avatarImage(file).then((image) => actions.updateBot(bot.id, { avatar: { ...bot.avatar ?? {}, image } })));};- (0, import_react25.useEffect)(() => {+ (0, import_react26.useEffect)(() => {const onDown = (event) => {if (!(event.target instanceof Element) || ref.current?.contains(event.target) || event.target.closest(".bt-avatar-trigger")) return;onClose();@@ -11999,7 +12338,7 @@ function AvatarEditor({ bot, actions, run: run2, onClose }) {window.removeEventListener("keydown", onKey, true);};}, [onClose]);- (0, import_react25.useEffect)(() => {+ (0, import_react26.useEffect)(() => {if (tab !== "upload") return void 0;const onPaste = (event) => {const file = [...event.clipboardData?.files ?? []].find((item) => item.type.startsWith("image/"));@@ -12013,32 +12352,32 @@ function AvatarEditor({ bot, actions, run: run2, onClose }) {}, [tab, bot]);const hasPhoto = Boolean(look.image);const glide = useGlide(tab);- return (0, import_react25.createElement)(+ return (0, import_react26.createElement)("div",{ ref, className: "bt-avedit", role: "dialog", "aria-label": t("Avatar editor") },- (0, import_react25.createElement)(+ (0, import_react26.createElement)("div",{ className: "bt-avedit-top" },- (0, import_react25.createElement)(+ (0, import_react26.createElement)("div",{ ref: glide.box, role: "tablist", "aria-label": t("Avatar source"), className: "bt-avedit-tabs" },- (0, import_react25.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),- [["bot", "Bot"], ["upload", "Upload"]].map(([id, label]) => (0, import_react25.createElement)("button", { key: id, type: "button", role: "tab", className: "bt-avedit-tab", "aria-selected": tab === id, onClick: () => setTab(id) }, t(label)))+ (0, import_react26.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),+ [["bot", "Bot"], ["upload", "Upload"]].map(([id, label]) => (0, import_react26.createElement)("button", { key: id, type: "button", role: "tab", className: "bt-avedit-tab", "aria-selected": tab === id, onClick: () => setTab(id) }, t(label)))),- (0, import_react25.createElement)("button", {+ (0, import_react26.createElement)("button", {type: "button",className: "bt-avedit-tab bt-avedit-reset",title: t("Reset character to default"),onClick: () => run2(actions.updateBot(bot.id, { avatar: null, color: null }))}, t("Reset"))),- tab === "bot" ? (0, import_react25.createElement)(CharacterGrid, {+ tab === "bot" ? (0, import_react26.createElement)(CharacterGrid, {look,hasPhoto,onShape: (shape) => run2(actions.updateBot(bot.id, { avatar: { shape } })),onColor: (color) => run2(actions.updateBot(bot.id, { color }))}) : null,- tab === "upload" ? (0, import_react25.createElement)(+ tab === "upload" ? (0, import_react26.createElement)("div",{className: "bt-dropzone",@@ -12054,15 +12393,15 @@ function AvatarEditor({ bot, actions, run: run2, onClose }) {upload(event.dataTransfer.files?.[0]);}},- hasPhoto ? (0, import_react25.createElement)("img", { src: look.image, alt: "" }) : null,- (0, import_react25.createElement)("div", null, t("Drag, drop, or paste an image")),- (0, import_react25.createElement)(+ hasPhoto ? (0, import_react26.createElement)("img", { src: look.image, alt: "" }) : null,+ (0, import_react26.createElement)("div", null, t("Drag, drop, or paste an image")),+ (0, import_react26.createElement)("div",{ className: "bt-actions", style: { justifyContent: "center" } },- (0, import_react25.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => fileRef.current?.click() }, hasPhoto ? t("Replace") : t("Browse files")),- hasPhoto ? (0, import_react25.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.updateBot(bot.id, { avatar: hasShape(bot.avatar?.shape) ? { shape: bot.avatar.shape } : null })) }, t("Remove photo")) : null+ (0, import_react26.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => fileRef.current?.click() }, hasPhoto ? t("Replace") : t("Browse files")),+ hasPhoto ? (0, import_react26.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.updateBot(bot.id, { avatar: hasShape(bot.avatar?.shape) ? { shape: bot.avatar.shape } : null })) }, t("Remove photo")) : null),- (0, import_react25.createElement)("input", { ref: fileRef, type: "file", accept: "image/png,image/jpeg,image/webp,image/gif", hidden: true, onChange: (event) => {+ (0, import_react26.createElement)("input", { ref: fileRef, type: "file", accept: "image/png,image/jpeg,image/webp,image/gif", hidden: true, onChange: (event) => {const file = event.target.files?.[0];event.target.value = "";upload(file);@@ -12073,22 +12412,22 @@ function AvatarEditor({ bot, actions, run: run2, onClose }) {function MemoryCard({ bot, actions }) {const count = useMemoryCount(bot.id, actions);const label = count === null ? t("Loading…") : count === 0 ? t("Nothing saved yet") : count === 1 ? t("1 entry") : t("{count} entries", { count });- return (0, import_react25.createElement)(+ return (0, import_react26.createElement)(Card,{ title: t("Memory") },- (0, import_react25.createElement)(+ (0, import_react26.createElement)("button",{ type: "button", className: "bt-set-row bt-bs-row", "aria-label": t("Manage {name}'s memory", { name: bot.name }), onClick: () => actions.openMemory(bot.id) },- (0, import_react25.createElement)("span", { className: "bt-set-copy" }, (0, import_react25.createElement)("span", { className: "bt-bs-label" }, label)),- (0, import_react25.createElement)("span", { className: "bt-mem-row-go" }, t("Manage"), (0, import_react25.createElement)(ChevronRightIcon))+ (0, import_react26.createElement)("span", { className: "bt-set-copy" }, (0, import_react26.createElement)("span", { className: "bt-bs-label" }, label)),+ (0, import_react26.createElement)("span", { className: "bt-mem-row-go" }, t("Manage"), (0, import_react26.createElement)(ChevronRightIcon))));}function BotSettingsForm({ bot, roster, actions, run: run2 }) {- const [editing, setEditing] = (0, import_react25.useState)(false);- const [confirming, setConfirming] = (0, import_react25.useState)(false);- const closeEditor = (0, import_react25.useCallback)(() => setEditing(false), []);- (0, import_react25.useEffect)(() => {+ const [editing, setEditing] = (0, import_react26.useState)(false);+ const [confirming, setConfirming] = (0, import_react26.useState)(false);+ const closeEditor = (0, import_react26.useCallback)(() => setEditing(false), []);+ (0, import_react26.useEffect)(() => {if (!confirming) return void 0;const timer = setTimeout(() => setConfirming(false), 4e3);return () => clearTimeout(timer);@@ -12102,112 +12441,112 @@ function BotSettingsForm({ bot, roster, actions, run: run2 }) {if (confirming) void run2(actions.deleteBot(bot.id));else setConfirming(true);};- (0, import_react25.useEffect)(() => {+ (0, import_react26.useEffect)(() => {void actions.refreshModels?.();}, [bot.id]);- return (0, import_react25.createElement)(+ return (0, import_react26.createElement)("div",{ className: "bt-bs" },- (0, import_react25.createElement)(+ (0, import_react26.createElement)("div",{ className: "bt-bs-hero" },- (0, import_react25.createElement)(+ (0, import_react26.createElement)("div",{ className: "bt-avatar-anchor" },- (0, import_react25.createElement)(+ (0, import_react26.createElement)("button",{ type: "button", className: "bt-avatar-trigger", "aria-label": t("Edit Bot avatar"), "aria-expanded": editing, onClick: () => setEditing((value) => !value) },- (0, import_react25.createElement)(BotMark, { bot, size: 64, live: true }),- (0, import_react25.createElement)("span", { className: "bt-avatar-pencil", "aria-hidden": true }, (0, import_react25.createElement)(PencilIcon))+ (0, import_react26.createElement)(BotMark, { bot, size: 64, live: true }),+ (0, import_react26.createElement)("span", { className: "bt-avatar-pencil", "aria-hidden": true }, (0, import_react26.createElement)(PencilIcon))),- editing ? (0, import_react25.createElement)(AvatarEditor, { bot, actions, run: run2, onClose: closeEditor }) : null+ editing ? (0, import_react26.createElement)(AvatarEditor, { bot, actions, run: run2, onClose: closeEditor }) : null),- (0, import_react25.createElement)(+ (0, import_react26.createElement)("div",{ className: "bt-bs-who" },- (0, import_react25.createElement)("span", { className: "bt-bs-name" }, bot.name),- (0, import_react25.createElement)("span", { className: "bt-bs-sub" }, [bot.role, isMainBot ? t("Main Bot") : ""].filter(Boolean).join(" · ") || t("Bot"))+ (0, import_react26.createElement)("span", { className: "bt-bs-name" }, bot.name),+ (0, import_react26.createElement)("span", { className: "bt-bs-sub" }, [bot.role, isMainBot ? t("Main Bot") : ""].filter(Boolean).join(" · ") || t("Bot")))),- (0, import_react25.createElement)(+ (0, import_react26.createElement)(Card,{ title: t("Profile") },- (0, import_react25.createElement)(Row, { label: t("Name") }, (0, import_react25.createElement)(InlineText, { label: t("Name"), value: bot.name, placeholder: "Bob", required: true, maxLength: 40, onSave: (name) => save({ name }) })),- (0, import_react25.createElement)(Row, { label: t("Label"), hint: t("Optional. Shown under the name.") }, (0, import_react25.createElement)(InlineText, { label: t("Label"), value: bot.role, placeholder: t("Research, admin…"), maxLength: 24, onSave: (role) => save({ role }) }))+ (0, import_react26.createElement)(Row, { label: t("Name") }, (0, import_react26.createElement)(InlineText, { label: t("Name"), value: bot.name, placeholder: "Bob", required: true, maxLength: 40, onSave: (name) => save({ name }) })),+ (0, import_react26.createElement)(Row, { label: t("Label"), hint: t("Optional. Shown under the name.") }, (0, import_react26.createElement)(InlineText, { label: t("Label"), value: bot.role, placeholder: t("Research, admin…"), maxLength: 24, onSave: (role) => save({ role }) }))),- (0, import_react25.createElement)(+ (0, import_react26.createElement)(Card,{ title: t("Model") },- (0, import_react25.createElement)(+ (0, import_react26.createElement)("div",{ className: "bt-set-row bt-bs-row" },- (0, import_react25.createElement)("span", { className: "bt-set-copy" }, (0, import_react25.createElement)("span", { className: "bt-bs-label" }, t("Model")), (0, import_react25.createElement)("span", { className: "bt-set-hint" }, modelHint(bot, roster))),- (0, import_react25.createElement)(ModelMenu, { bot, roster, actions, run: run2 })+ (0, import_react26.createElement)("span", { className: "bt-set-copy" }, (0, import_react26.createElement)("span", { className: "bt-bs-label" }, t("Model")), (0, import_react26.createElement)("span", { className: "bt-set-hint" }, modelHint(bot, roster))),+ (0, import_react26.createElement)(ModelMenu, { bot, roster, actions, run: run2 }))),- (0, import_react25.createElement)(+ (0, import_react26.createElement)(Card,{ title: t("Working folder") },- (0, import_react25.createElement)(+ (0, import_react26.createElement)("div",{ className: "bt-set-row bt-bs-row" },- (0, import_react25.createElement)("span", { className: "bt-set-copy" }, (0, import_react25.createElement)("span", { className: "bt-bs-label" }, t("Folder"))),- (0, import_react25.createElement)(FolderMenu, { value: bot.workDir, actions, run: run2, onPick: (workDir) => save({ workDir }) })+ (0, import_react26.createElement)("span", { className: "bt-set-copy" }, (0, import_react26.createElement)("span", { className: "bt-bs-label" }, t("Folder"))),+ (0, import_react26.createElement)(FolderMenu, { value: bot.workDir, actions, run: run2, onPick: (workDir) => save({ workDir }) }))),- (0, import_react25.createElement)(+ (0, import_react26.createElement)(Card,{ title: t("Instructions") },- (0, import_react25.createElement)(+ (0, import_react26.createElement)(Row,{ label: t("What this Bot does"), hint: t("Its job on the team. Part of the Bot's system prompt."), stack: true },- (0, import_react25.createElement)(InlineText, { label: t("Instructions"), value: bot.instructions, multiline: true, placeholder: t("What this Bot is responsible for…"), onSave: (instructions) => save({ instructions }) })+ (0, import_react26.createElement)(InlineText, { label: t("Instructions"), value: bot.instructions, multiline: true, placeholder: t("What this Bot is responsible for…"), onSave: (instructions) => save({ instructions }) }))),- (0, import_react25.createElement)(BotCapabilitiesCard, { bot, roster, actions, run: run2, Card, SwitchRow }),- roster.memory === false ? null : (0, import_react25.createElement)(MemoryCard, { bot, actions }),- (0, import_react25.createElement)(BotSchedules, { bot, roster, actions }),- (0, import_react25.createElement)(+ (0, import_react26.createElement)(BotCapabilitiesCard, { bot, roster, actions, run: run2, Card, SwitchRow }),+ roster.memory === false ? null : (0, import_react26.createElement)(MemoryCard, { bot, actions }),+ (0, import_react26.createElement)(BotSchedules, { bot, roster, actions }),+ (0, import_react26.createElement)(Card,{ title: t("Main Bot") },- onlyMain ? (0, import_react25.createElement)(+ onlyMain ? (0, import_react26.createElement)("div",{ className: "bt-set-row bt-bs-row" },- (0, import_react25.createElement)(+ (0, import_react26.createElement)("span",{ className: "bt-set-copy" },- (0, import_react25.createElement)("span", { className: "bt-bs-label" }, t("Main Bot")),- (0, import_react25.createElement)("span", { className: "bt-set-hint" }, t("The only Main Bot. To hand the role to another Bot, use Main Bot on the Bots page."))+ (0, import_react26.createElement)("span", { className: "bt-bs-label" }, t("Main Bot")),+ (0, import_react26.createElement)("span", { className: "bt-set-hint" }, t("The only Main Bot. To hand the role to another Bot, use Main Bot on the Bots page."))),- (0, import_react25.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.openSettings("bots") }, t("Change"))- ) : (0, import_react25.createElement)(SwitchRow, { label: t("Main Bot"), hint: t("Can create and change Bots, and runs every group chat."), on: isMainBot, onChange: (on) => run2(actions.setMain(bot.id, on)) })+ (0, import_react26.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.openSettings("bots") }, t("Change"))+ ) : (0, import_react26.createElement)(SwitchRow, { label: t("Main Bot"), hint: t("Can create and change Bots, and runs every group chat."), on: isMainBot, onChange: (on) => run2(actions.setMain(bot.id, on)) })),// The Main Bot tile is always first and always shown, like in the context menu.- isTile ? null : (0, import_react25.createElement)(+ isTile ? null : (0, import_react26.createElement)(Card,{ title: t("Sidebar") },- (0, import_react25.createElement)(SwitchRow, { label: t("Pin"), hint: t("Kept above the other chats."), on: bot.pinned === true, onChange: (pinned) => run2(actions.setFlags(bot.id, { pinned })) }),- isMainBot ? null : (0, import_react25.createElement)(SwitchRow, { label: t("Hide from sidebar"), hint: t("Search still finds it."), on: bot.hidden === true, onChange: (hidden) => run2(actions.setFlags(bot.id, { hidden })) })+ (0, import_react26.createElement)(SwitchRow, { label: t("Pin"), hint: t("Kept above the other chats."), on: bot.pinned === true, onChange: (pinned) => run2(actions.setFlags(bot.id, { pinned })) }),+ isMainBot ? null : (0, import_react26.createElement)(SwitchRow, { label: t("Hide from sidebar"), hint: t("Search still finds it."), on: bot.hidden === true, onChange: (hidden) => run2(actions.setFlags(bot.id, { hidden })) })),- (0, import_react25.createElement)(+ (0, import_react26.createElement)(Card,{ title: t("Manage") },- (0, import_react25.createElement)(+ (0, import_react26.createElement)("button",{ type: "button", className: "bt-set-row bt-bs-row", onClick: duplicate },- (0, import_react25.createElement)("span", { className: "bt-set-copy" }, (0, import_react25.createElement)("span", { className: "bt-bs-label" }, t("Duplicate")), (0, import_react25.createElement)("span", { className: "bt-set-hint" }, t("A copy with the same job and model, and fresh memory."))),- (0, import_react25.createElement)("span", { className: "bt-chevron" }, (0, import_react25.createElement)(ChevronRightIcon))+ (0, import_react26.createElement)("span", { className: "bt-set-copy" }, (0, import_react26.createElement)("span", { className: "bt-bs-label" }, t("Duplicate")), (0, import_react26.createElement)("span", { className: "bt-set-hint" }, t("A copy with the same job and model, and fresh memory."))),+ (0, import_react26.createElement)("span", { className: "bt-chevron" }, (0, import_react26.createElement)(ChevronRightIcon))),- isMainBot ? null : (0, import_react25.createElement)(+ isMainBot ? null : (0, import_react26.createElement)("button",{ type: "button", className: "bt-set-row bt-bs-row bt-bs-danger", "data-confirm": confirming || void 0, onClick: remove },- (0, import_react25.createElement)(+ (0, import_react26.createElement)("span",{ className: "bt-set-copy" },- (0, import_react25.createElement)("span", { className: "bt-bs-label" }, confirming ? t("Delete {name}?", { name: bot.name }) : t("Delete Bot")),- (0, import_react25.createElement)("span", { className: "bt-set-hint" }, confirming ? t("Click again to delete. Its chats are archived.") : t("Removes the Bot from the team."))+ (0, import_react26.createElement)("span", { className: "bt-bs-label" }, confirming ? t("Delete {name}?", { name: bot.name }) : t("Delete Bot")),+ (0, import_react26.createElement)("span", { className: "bt-set-hint" }, confirming ? t("Click again to delete. Its chats are archived.") : t("Removes the Bot from the team."))),- (0, import_react25.createElement)("span", { className: "bt-chevron" }, (0, import_react25.createElement)(ChevronRightIcon))+ (0, import_react26.createElement)("span", { className: "bt-chevron" }, (0, import_react26.createElement)(ChevronRightIcon)))));@@ -12256,8 +12595,8 @@ function freshBotName(roster, base = "New Bot") {return `${base} ${index}`;}function startModel(roster) {- const models = roster.models ?? [];- return (models.find((model) => model.ref === roster.defaultModel) ?? models[0])?.ref ?? "";+ const usable = (roster.models ?? []).filter((model) => !model.needsKey);+ return (usable.find((model) => model.ref === roster.defaultModel) ?? usable[0])?.ref ?? "";}function createPayload({ name, look, image, model, effort, brief }) {const payload = { name, color: look.color, avatar: image ? { shape: look.shape, image } : { shape: look.shape } };@@ -12268,7 +12607,7 @@ function createPayload({ name, look, image, model, effort, brief }) {}// src/client/create-bot.js-var import_react26 = require("react");+var import_react27 = require("react");var pick = (list) => list[Math.floor(Math.random() * list.length)];var randomLook = (avoid = {}) => {const shapes = DEFAULT_SHAPES.filter((shape) => shape !== avoid.shape);@@ -12276,17 +12615,17 @@ var randomLook = (avoid = {}) => {return { shape: pick(shapes), color: pick(colors) };};function CreateBot({ roster, actions, start, brief = "", onBack, canGoBack, onCreated, inline = false }) {- const [look, setLook] = (0, import_react26.useState)(() => randomLook());- const [image, setImage] = (0, import_react26.useState)(null);- const [name, setName] = (0, import_react26.useState)(start?.name ?? "");- const [model, setModel] = (0, import_react26.useState)(() => startModel(roster));- const [effort, setEffort] = (0, import_react26.useState)(void 0);- const [busy, setBusy] = (0, import_react26.useState)(false);- const [error, setError] = (0, import_react26.useState)("");- const fileRef = (0, import_react26.useRef)(null);- const frame = (0, import_react26.useRef)(null);+ const [look, setLook] = (0, import_react27.useState)(() => randomLook());+ const [image, setImage] = (0, import_react27.useState)(null);+ const [name, setName] = (0, import_react27.useState)(start?.name ?? "");+ const [model, setModel] = (0, import_react27.useState)(() => startModel(roster));+ const [effort, setEffort] = (0, import_react27.useState)(void 0);+ const [busy, setBusy] = (0, import_react27.useState)(false);+ const [error, setError] = (0, import_react27.useState)("");+ const fileRef = (0, import_react27.useRef)(null);+ const frame = (0, import_react27.useRef)(null);useEscape(onBack);- (0, import_react26.useEffect)(() => {+ (0, import_react27.useEffect)(() => {if (inline) frame.current?.scrollIntoView({ block: "start", behavior: "smooth" });}, []);const fallbackName = freshBotName(roster, t("New Bot"));@@ -12311,25 +12650,25 @@ function CreateBot({ roster, actions, start, brief = "", onBack, canGoBack, onCravatarImage(file).then(setImage, (failure) => setError(failure?.message ?? String(failure)));};const previewLook = image ? { ...look, image } : look;- const card = (0, import_react26.createElement)(+ const card = (0, import_react27.createElement)("div",{ className: "bt-create-card" },- (0, import_react26.createElement)(+ (0, import_react27.createElement)("div",{ className: "bt-create-preview" },// The key remounts the mark, so every new pick plays the pop.- (0, import_react26.createElement)(+ (0, import_react27.createElement)("span",{ key: `${look.shape}:${look.color}:${image ? "photo" : ""}`, className: "bt-create-pop" },- (0, import_react26.createElement)(BotMark, { look: previewLook, bot: { id: "new-bot" }, size: 88, live: true, gaze: true, pokeable: true })+ (0, import_react27.createElement)(BotMark, { look: previewLook, bot: { id: "new-bot" }, size: 88, live: true, gaze: true, pokeable: true })),- (0, import_react26.createElement)("span", { className: "bt-create-name" }, finalName)+ (0, import_react27.createElement)("span", { className: "bt-create-name" }, finalName)),- (0, import_react26.createElement)("div", { className: "bt-create-step" }, t("Look")),- (0, import_react26.createElement)(+ (0, import_react27.createElement)("div", { className: "bt-create-step" }, t("Look")),+ (0, import_react27.createElement)("div",{ className: "bt-create-looks" },- (0, import_react26.createElement)(CharacterGrid, {+ (0, import_react27.createElement)(CharacterGrid, {look,hasPhoto: Boolean(image),onShape: (shape) => {@@ -12341,27 +12680,27 @@ function CreateBot({ roster, actions, start, brief = "", onBack, canGoBack, onCrsetLook((current) => ({ ...current, color }));}}),- (0, import_react26.createElement)(+ (0, import_react27.createElement)("div",{ className: "bt-actions bt-create-lookbar" },- (0, import_react26.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => {+ (0, import_react27.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => {setImage(null);setLook((current) => randomLook(current));} }, t("Shuffle")),- (0, import_react26.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => fileRef.current?.click() }, image ? t("Replace photo") : t("Upload photo")),- image ? (0, import_react26.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setImage(null) }, t("Remove photo")) : null,- (0, import_react26.createElement)("input", { ref: fileRef, type: "file", accept: "image/png,image/jpeg,image/webp,image/gif", hidden: true, onChange: (event) => {+ (0, import_react27.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => fileRef.current?.click() }, image ? t("Replace photo") : t("Upload photo")),+ image ? (0, import_react27.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setImage(null) }, t("Remove photo")) : null,+ (0, import_react27.createElement)("input", { ref: fileRef, type: "file", accept: "image/png,image/jpeg,image/webp,image/gif", hidden: true, onChange: (event) => {const file = event.target.files?.[0];event.target.value = "";upload(file);} }))),- (0, import_react26.createElement)(+ (0, import_react27.createElement)("label",{ className: "bt-field" },- (0, import_react26.createElement)("span", { className: "bt-field-label" }, t("Name")),- (0, import_react26.createElement)("input", {+ (0, import_react27.createElement)("span", { className: "bt-field-label" }, t("Name")),+ (0, import_react27.createElement)("input", {className: "bt-input",autoFocus: !inline,value: name,@@ -12376,54 +12715,54 @@ function CreateBot({ roster, actions, start, brief = "", onBack, canGoBack, onCr}}}),- problem ? (0, import_react26.createElement)("span", { className: "bt-note bt-danger" }, hostText(problem)) : clash ? (0, import_react26.createElement)("span", { className: "bt-note bt-danger" }, t("A Bot named {name} already exists", { name: finalName })) : null+ problem ? (0, import_react27.createElement)("span", { className: "bt-note bt-danger" }, hostText(problem)) : clash ? (0, import_react27.createElement)("span", { className: "bt-note bt-danger" }, t("A Bot named {name} already exists", { name: finalName })) : null),- (0, import_react26.createElement)(+ (0, import_react27.createElement)("div",{ className: "bt-field" },- (0, import_react26.createElement)("span", { className: "bt-field-label" }, t("Model")),- (0, import_react26.createElement)(ModelMenu, { bot: { id: "new-bot", name: finalName, model: model || void 0, effort }, roster, actions, wide: true, onPick: (ref) => {+ (0, import_react27.createElement)("span", { className: "bt-field-label" }, t("Model")),+ (0, import_react27.createElement)(ModelMenu, { bot: { id: "new-bot", name: finalName, model: model || void 0, effort }, roster, actions, wide: true, onPick: (ref) => {setModel(ref);setEffort(void 0);}, onPickEffort: setEffort }),- (0, import_react26.createElement)("span", { className: "bt-note" }, (roster.models ?? []).length > 0 ? t("The Bot runs on this model. You can change it later in its details.") : t("Add a provider and a model in DeepSeek Harness first, or pick one in the Bot's chat later."))+ (0, import_react27.createElement)("span", { className: "bt-note" }, model ? t("The Bot runs on this model. You can change it later in its details.") : (roster.models ?? []).length > 0 ? t("Pick a model here, or the Bot asks for one in its chat.") : t("Add a provider and a model in DeepSeek Harness first, or pick one in the Bot's chat later."))),- error ? (0, import_react26.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null,- (0, import_react26.createElement)(+ error ? (0, import_react27.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null,+ (0, import_react27.createElement)("div",{ className: "bt-create-foot" },- (0, import_react26.createElement)("button", { type: "button", className: "bt-soft", onClick: onBack }, canGoBack ? t("Back") : t("Cancel")),- (0, import_react26.createElement)("button", { type: "button", className: "bt-send bt-create-go", disabled: busy || clash || Boolean(problem), onClick: () => void create() }, busy ? t("Creating…") : t("Create"))+ (0, import_react27.createElement)("button", { type: "button", className: "bt-soft", onClick: onBack }, canGoBack ? t("Back") : t("Cancel")),+ (0, import_react27.createElement)("button", { type: "button", className: "bt-send bt-create-go", disabled: busy || clash || Boolean(problem), onClick: () => void create() }, busy ? t("Creating…") : t("Create"))));- if (inline) return (0, import_react26.createElement)("div", { ref: frame, className: "bt-create-inline", role: "group", "aria-label": t("Create Bot") }, card);- return (0, import_react26.createElement)(+ if (inline) return (0, import_react27.createElement)("div", { ref: frame, className: "bt-create-inline", role: "group", "aria-label": t("Create Bot") }, card);+ return (0, import_react27.createElement)("div",{ className: "bt-create", role: "dialog", "aria-label": t("Create Bot") },- (0, import_react26.createElement)(+ (0, import_react27.createElement)("div",{ className: "bt-create-head" },- canGoBack ? (0, import_react26.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back to new chat"), onClick: onBack }, (0, import_react26.createElement)(ChevronLeftIcon)) : (0, import_react26.createElement)("span", { className: "bt-create-gap" }),- (0, import_react26.createElement)("span", { className: "bt-create-title" }, t("Create Bot")),- (0, import_react26.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Close"), onClick: () => actions.closeOverlay() }, (0, import_react26.createElement)(CloseIcon))+ canGoBack ? (0, import_react27.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back to new chat"), onClick: onBack }, (0, import_react27.createElement)(ChevronLeftIcon)) : (0, import_react27.createElement)("span", { className: "bt-create-gap" }),+ (0, import_react27.createElement)("span", { className: "bt-create-title" }, t("Create Bot")),+ (0, import_react27.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Close"), onClick: () => actions.closeOverlay() }, (0, import_react27.createElement)(CloseIcon))),- (0, import_react26.createElement)("div", { className: "bt-create-body" }, card)+ (0, import_react27.createElement)("div", { className: "bt-create-body" }, card));}// src/client/new-chat.js-var import_react27 = require("react");+var import_react28 = require("react");function NewChat({ mode, roster, actions }) {- const [query, setQuery] = (0, import_react27.useState)("");- const [picked, setPicked] = (0, import_react27.useState)([]);- const [group, setGroup] = (0, import_react27.useState)(mode === "group");- const [admin, setAdmin] = (0, import_react27.useState)(null);- const [message, setMessage] = (0, import_react27.useState)("");- const [busy, setBusy] = (0, import_react27.useState)(false);- const [error, setError] = (0, import_react27.useState)("");- const [cursor, setCursor] = (0, import_react27.useState)(0);- const [draft, setDraft] = (0, import_react27.useState)(mode === "create" ? { name: "", fromList: false } : null);- const inputRef = (0, import_react27.useRef)(null);+ const [query, setQuery] = (0, import_react28.useState)("");+ const [picked, setPicked] = (0, import_react28.useState)([]);+ const [group, setGroup] = (0, import_react28.useState)(mode === "group");+ const [admin, setAdmin] = (0, import_react28.useState)(null);+ const [message, setMessage] = (0, import_react28.useState)("");+ const [busy, setBusy] = (0, import_react28.useState)(false);+ const [error, setError] = (0, import_react28.useState)("");+ const [cursor, setCursor] = (0, import_react28.useState)(0);+ const [draft, setDraft] = (0, import_react28.useState)(mode === "create" ? { name: "", fromList: false } : null);+ const inputRef = (0, import_react28.useRef)(null);const close = () => actions.closeOverlay();useEscape(close);const paneLeft = usePaneLeft();@@ -12509,14 +12848,14 @@ function NewChat({ mode, roster, actions }) {});const options = [];if (!group && picked.length === 0 && mode !== "search" && wanted === "") {- options.push({ key: "new", icon: (0, import_react27.createElement)(PlusIcon), label: t("Create new Bot"), run: createBot });- options.push({ key: "group", icon: (0, import_react27.createElement)(PeopleIcon), label: t("Create group chat"), run: () => {+ options.push({ key: "new", icon: (0, import_react28.createElement)(PlusIcon), label: t("Create new Bot"), run: createBot });+ options.push({ key: "group", icon: (0, import_react28.createElement)(PeopleIcon), label: t("Create group chat"), run: () => {setGroup(true);setCursor(0);inputRef.current?.focus();} });if ((roster.agents ?? []).length === 0 && actions.addAgent) {- options.push({ key: "agent", icon: (0, import_react27.createElement)(import_dsh_client_ui_primitives.FishLogo, { size: 16 }), label: t("Add DSH Agent"), run: () => run2(async () => {+ options.push({ key: "agent", icon: (0, import_react28.createElement)(import_dsh_client_ui_primitives.FishLogo, { size: 16 }), label: t("Add DSH Agent"), run: () => run2(async () => {await actions.addAgent();close();}) });@@ -12525,19 +12864,19 @@ function NewChat({ mode, roster, actions }) {for (const bot of matches) {options.push({ key: bot.id, bot, label: bot.name, hint: choosingAdmin ? t("Make admin") : group || picked.length > 0 ? t("Add to group chat") : void 0, run: () => openBot(bot) });}- if (wanted !== "" && !exact && mode !== "search") options.push({ key: "create", icon: (0, import_react27.createElement)(PlusIcon), label: t("Create new Bot “{name}”", { name: query.trim() }), run: createBot });+ if (wanted !== "" && !exact && mode !== "search") options.push({ key: "create", icon: (0, import_react28.createElement)(PlusIcon), label: t("Create new Bot “{name}”", { name: query.trim() }), run: createBot });const active = Math.min(cursor, Math.max(options.length - 1, 0));const listed = options.map((option) => option.key).join("\n");const glide = useGlide(`${active}${listed}`, { axis: "y", ...QUICK_EDGES });useFlip(glide.box, listed, "[data-flip]");- const drop = (0, import_react27.useRef)(null);+ const drop = (0, import_react28.useRef)(null);useMorph(drop, listed);if (draft) {- return (0, import_react27.createElement)(+ return (0, import_react28.createElement)("div",{ className: "bt-pane", style: { left: paneLeft } },- (0, import_react27.createElement)(CreateBot, {+ (0, import_react28.createElement)(CreateBot, {roster,actions,start: draft,@@ -12558,33 +12897,33 @@ ${listed}`, { axis: "y", ...QUICK_EDGES });if (picked.length > 0) setPicked((current) => current.slice(0, -1));else if (admin !== null) setAdmin(null);};- return (0, import_react27.createElement)(+ return (0, import_react28.createElement)("div",{ className: "bt-pane", style: { left: paneLeft } },- (0, import_react27.createElement)(+ (0, import_react28.createElement)("div",{ className: "bt-newchat", role: "dialog", "aria-label": mode === "search" ? t("Search") : t("New chat") },- (0, import_react27.createElement)(+ (0, import_react28.createElement)("div",{ className: "bt-to" },- (0, import_react27.createElement)("span", { className: "bt-to-label" }, t("To:")),- adminBot ? (0, import_react27.createElement)(+ (0, import_react28.createElement)("span", { className: "bt-to-label" }, t("To:")),+ adminBot ? (0, import_react28.createElement)("span",{ key: adminBot.id, className: "bt-token bt-token-admin", title: t("Admin") },- (0, import_react27.createElement)(BotMark, { bot: adminBot, size: 16 }),+ (0, import_react28.createElement)(BotMark, { bot: adminBot, size: 16 }),adminBot.name,- (0, import_react27.createElement)(AdminStar),- (0, import_react27.createElement)("button", { type: "button", "aria-label": t("Remove {name}", { name: adminBot.name }), onClick: () => setAdmin(null) }, "×")+ (0, import_react28.createElement)(AdminStar),+ (0, import_react28.createElement)("button", { type: "button", "aria-label": t("Remove {name}", { name: adminBot.name }), onClick: () => setAdmin(null) }, "×")) : null,- choosingAdmin ? (0, import_react27.createElement)("span", { className: "bt-to-star", "aria-hidden": true }, (0, import_react27.createElement)(AdminStar)) : null,- pickedBots.map((bot) => (0, import_react27.createElement)(+ choosingAdmin ? (0, import_react28.createElement)("span", { className: "bt-to-star", "aria-hidden": true }, (0, import_react28.createElement)(AdminStar)) : null,+ pickedBots.map((bot) => (0, import_react28.createElement)("span",{ key: bot.id, className: "bt-token" },- (0, import_react27.createElement)(BotMark, { bot, size: 16 }),+ (0, import_react28.createElement)(BotMark, { bot, size: 16 }),bot.name,- (0, import_react27.createElement)("button", { type: "button", "aria-label": t("Remove {name}", { name: bot.name }), onClick: () => setPicked((current) => current.filter((id) => id !== bot.id)) }, "×")+ (0, import_react28.createElement)("button", { type: "button", "aria-label": t("Remove {name}", { name: bot.name }), onClick: () => setPicked((current) => current.filter((id) => id !== bot.id)) }, "×"))),- (0, import_react27.createElement)("input", {+ (0, import_react28.createElement)("input", {ref: inputRef,autoFocus: true,value: query,@@ -12608,20 +12947,20 @@ ${listed}`, { axis: "y", ...QUICK_EDGES });} else if (event.key === "Backspace" && query === "") unpick();}}),- group && admin !== null ? (0, import_react27.createElement)("button", {+ group && admin !== null ? (0, import_react28.createElement)("button", {type: "button",className: "bt-send bt-to-create",disabled: busy || picked.length === 0,title: picked.length === 0 ? t("Add at least one more Bot") : void 0,onClick: createGroup}, t("Create group chat")) : null,- (0, import_react27.createElement)("button", { type: "button", className: "bt-x", "aria-label": t("Close new chat"), onClick: close }, "×")+ (0, import_react28.createElement)("button", { type: "button", className: "bt-x", "aria-label": t("Close new chat"), onClick: close }, "×")),- (0, import_react27.createElement)("div", { ref: drop, className: "bt-drop" }, (0, import_react27.createElement)(+ (0, import_react28.createElement)("div", { ref: drop, className: "bt-drop" }, (0, import_react28.createElement)("div",{ ref: glide.box, role: "listbox", "aria-label": t("Recipients"), className: "bt-drop-list" },- (0, import_react27.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),- options.length === 0 ? (0, import_react27.createElement)("div", { className: "bt-hint" }, mode === "search" ? t("No Bots match") : t("Type a name to create a Bot")) : options.map((option, index) => (0, import_react27.createElement)(+ (0, import_react28.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),+ options.length === 0 ? (0, import_react28.createElement)("div", { className: "bt-hint" }, mode === "search" ? t("No Bots match") : t("Type a name to create a Bot")) : options.map((option, index) => (0, import_react28.createElement)("button",{key: option.key,@@ -12633,21 +12972,21 @@ ${listed}`, { axis: "y", ...QUICK_EDGES });onMouseEnter: () => setCursor(index),onClick: option.run},- option.bot ? (0, import_react27.createElement)(BotMark, { bot: option.bot, size: 22 }) : (0, import_react27.createElement)("span", { className: "bt-option-icon" }, option.icon),- (0, import_react27.createElement)("span", { className: "bt-option-label" }, option.label),- option.hint && index === active ? (0, import_react27.createElement)("span", { className: "bt-option-hint" }, option.hint) : null+ option.bot ? (0, import_react28.createElement)(BotMark, { bot: option.bot, size: 22 }) : (0, import_react28.createElement)("span", { className: "bt-option-icon" }, option.icon),+ (0, import_react28.createElement)("span", { className: "bt-option-label" }, option.label),+ option.hint && index === active ? (0, import_react28.createElement)("span", { className: "bt-option-hint" }, option.hint) : null)))),- (0, import_react27.createElement)("div", { className: "bt-nc-spacer" }),- error ? (0, import_react27.createElement)("div", { className: "bt-error" }, error) : null,- (0, import_react27.createElement)(+ (0, import_react28.createElement)("div", { className: "bt-nc-spacer" }),+ error ? (0, import_react28.createElement)("div", { className: "bt-error" }, error) : null,+ (0, import_react28.createElement)("div",{ className: "bt-nc-compose" },- (0, import_react27.createElement)(+ (0, import_react28.createElement)("div",{ className: "bt-nc-card" },- (0, import_react27.createElement)("span", { className: "bt-nc-plus", "aria-hidden": true }, (0, import_react27.createElement)(PlusIcon)),- (0, import_react27.createElement)("textarea", {+ (0, import_react28.createElement)("span", { className: "bt-nc-plus", "aria-hidden": true }, (0, import_react28.createElement)(PlusIcon)),+ (0, import_react28.createElement)("textarea", {rows: 1,value: message,placeholder,@@ -12660,7 +12999,7 @@ ${listed}`, { axis: "y", ...QUICK_EDGES });}}}),- (0, import_react27.createElement)("button", { type: "button", className: "bt-nc-send", "aria-label": t("Send message"), disabled: busy || message.trim() === "" || picked.length === 0, onClick: sendMessage }, (0, import_react27.createElement)(ArrowUpIcon))+ (0, import_react28.createElement)("button", { type: "button", className: "bt-nc-send", "aria-label": t("Send message"), disabled: busy || message.trim() === "" || picked.length === 0, onClick: sendMessage }, (0, import_react28.createElement)(ArrowUpIcon)))))@@ -12668,14 +13007,14 @@ ${listed}`, { axis: "y", ...QUICK_EDGES });}// src/client/exchange.js-var import_react28 = require("react");+var import_react29 = require("react");var SHEET_EXIT_MS = 220;function ExchangeDialog({ pair, roster, actions }) {- const [entries2, setEntries] = (0, import_react28.useState)(null);- const [leaving, setLeaving] = (0, import_react28.useState)(false);- const log = (0, import_react28.useRef)(null);- const atEnd = (0, import_react28.useRef)(true);- (0, import_react28.useLayoutEffect)(() => {+ const [entries2, setEntries] = (0, import_react29.useState)(null);+ const [leaving, setLeaving] = (0, import_react29.useState)(false);+ const log = (0, import_react29.useRef)(null);+ const atEnd = (0, import_react29.useRef)(true);+ (0, import_react29.useLayoutEffect)(() => {if (entries2 !== null && atEnd.current && log.current) log.current.scrollTop = log.current.scrollHeight;}, [entries2]);const close = () => {@@ -12684,7 +13023,7 @@ function ExchangeDialog({ pair, roster, actions }) {setTimeout(() => actions.closeOverlay(), SHEET_EXIT_MS);};useEscape(close);- (0, import_react28.useEffect)(() => {+ (0, import_react29.useEffect)(() => {let stop = false;let timer;let seen = null;@@ -12711,53 +13050,53 @@ function ExchangeDialog({ pair, roster, actions }) {const flat = layoutOf(roster.prefs) === "flat";let lastDay = 0;const paneLeft = usePaneLeft();- return (0, import_react28.createElement)(+ return (0, import_react29.createElement)("div",{ className: "bt-pane bt-exchange", style: { left: paneLeft }, "data-leaving": leaving || void 0 },- (0, import_react28.createElement)(+ (0, import_react29.createElement)("div",{ className: "bt-dialog", role: "dialog", "aria-label": t("Bot exchange") },- (0, import_react28.createElement)("div", { className: "bt-head" }, (0, import_react28.createElement)(+ (0, import_react29.createElement)("div", { className: "bt-head" }, (0, import_react29.createElement)("span",{ className: "bt-pill", style: { cursor: "default" } },- left ? (0, import_react28.createElement)(BotMark, { bot: left, size: 22 }) : null,+ left ? (0, import_react29.createElement)(BotMark, { bot: left, size: 22 }) : null,left?.name ?? "?",- (0, import_react28.createElement)("span", { className: "bt-swap" }, "⇄"),- right ? (0, import_react28.createElement)(BotMark, { bot: right, size: 22 }) : null,+ (0, import_react29.createElement)("span", { className: "bt-swap" }, "⇄"),+ right ? (0, import_react29.createElement)(BotMark, { bot: right, size: 22 }) : null,right?.name ?? "?")),- (0, import_react28.createElement)(+ (0, import_react29.createElement)("div",{ ref: log, className: "bt-dialog-log", role: "log", "aria-label": t("Bot exchange transcript"), onScroll: (event) => {const node = event.currentTarget;atEnd.current = node.scrollHeight - node.scrollTop - node.clientHeight < 2;} },- entries2 === null ? (0, import_react28.createElement)("div", { className: "bt-hint" }, t("Loading…")) : entries2.length === 0 ? (0, import_react28.createElement)("div", { className: "bt-hint" }, t("No messages yet")) : entries2.map((entry) => {+ entries2 === null ? (0, import_react29.createElement)("div", { className: "bt-hint" }, t("Loading…")) : entries2.length === 0 ? (0, import_react29.createElement)("div", { className: "bt-hint" }, t("No messages yet")) : entries2.map((entry) => {const bot = roster.byId[entry.from] ?? { id: entry.from, name: t("You"), color: "gray" };const showDay = entry.time - lastDay > 30 * 60 * 1e3;lastDay = entry.time;const whole = entry.length === void 0 ? void 0 : { length: entry.length, load: () => actions.exchangeText(entry.id) };- const lead = (0, import_react28.createElement)("span", { className: "bt-lead" }, (0, import_react28.createElement)(BotMark, { bot, size: 22 }));- return (0, import_react28.createElement)(- import_react28.Fragment,+ const lead = (0, import_react29.createElement)("span", { className: "bt-lead" }, (0, import_react29.createElement)(BotMark, { bot, size: 22 }));+ return (0, import_react29.createElement)(+ import_react29.Fragment,{ key: entry.id },- showDay ? (0, import_react28.createElement)("time", { className: "bt-time" }, dayLabel(entry.time)) : null,- (0, import_react28.createElement)(+ showDay ? (0, import_react29.createElement)("time", { className: "bt-time" }, dayLabel(entry.time)) : null,+ (0, import_react29.createElement)("div",{ className: "bt-group-msg" },- (0, import_react28.createElement)("span", { className: "bt-group-name", style: flat ? void 0 : { color: inkText(colorOf(bot)) } }, flat ? lead : null, bot.name),- (0, import_react28.createElement)(Bubbles, { texts: [stripLongNote(entry.text)], roster, selfId: bot.id, actions, whole, lead: flat ? null : lead })+ (0, import_react29.createElement)("span", { className: "bt-group-name", style: flat ? void 0 : { color: inkText(colorOf(bot)) } }, flat ? lead : null, bot.name),+ (0, import_react29.createElement)(Bubbles, { texts: [stripLongNote(entry.text)], roster, selfId: bot.id, actions, whole, lead: flat ? null : lead })));})),- (0, import_react28.createElement)("div", { className: "bt-dialog-foot" }, (0, import_react28.createElement)("button", { type: "button", className: "bt-soft", onClick: close }, t("Close Chat")))+ (0, import_react29.createElement)("div", { className: "bt-dialog-foot" }, (0, import_react29.createElement)("button", { type: "button", className: "bt-soft", onClick: close }, t("Close Chat")))));}// src/client/voice.js-var import_react29 = require("react");+var import_react30 = require("react");var plainSpeech = (text) => stripHeader(text).replace(/```[\s\S]*?```/g, " ").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/[*_`#>|~-]+/g, " ").replace(/\s+/g, " ").trim();var VOICE_LABELS = {listening: "Listening",@@ -12769,8 +13108,8 @@ var VOICE_LABELS = {};var CAPTURE_NOTES = { blocked: "Microphone access is blocked", unavailable: "Voice chat is not available in this browser", "too-long": "That was too long to recognize" };function useMicLevel(enabled) {- const [level, setLevel] = (0, import_react29.useState)(0);- (0, import_react29.useEffect)(() => {+ const [level, setLevel] = (0, import_react30.useState)(0);+ (0, import_react30.useEffect)(() => {if (!enabled || !navigator.mediaDevices?.getUserMedia) return void 0;let stream = null;let audio = null;@@ -12820,18 +13159,18 @@ function VoiceMode({ sessionId, roster, actions, useSessions, useSessionStatus }const entry = Array.isArray(outline) ? outline[outline.length - 1] : void 0;return entry ? `${outline.length}|${entry.response ?? ""}` : "0|";});- const [speech] = (0, import_react29.useState)(() => actions.speech());- const [phase, setPhase] = (0, import_react29.useState)(speech ? "starting" : speechApi() ? "listening" : "unsupported");- const [catalog, setCatalog] = (0, import_react29.useState)(null);- const [heard, setHeard] = (0, import_react29.useState)("");- const [said, setSaid] = (0, import_react29.useState)("");- const [note, setNote] = (0, import_react29.useState)("");- const [serviceLevel, setServiceLevel] = (0, import_react29.useState)(0);- const [cycle, setCycle] = (0, import_react29.useState)(0);- const waiting = (0, import_react29.useRef)(null);- const reply = (0, import_react29.useRef)(lastReply);+ const [speech] = (0, import_react30.useState)(() => actions.speech());+ const [phase, setPhase] = (0, import_react30.useState)(speech ? "starting" : speechApi() ? "listening" : "unsupported");+ const [catalog, setCatalog] = (0, import_react30.useState)(null);+ const [heard, setHeard] = (0, import_react30.useState)("");+ const [said, setSaid] = (0, import_react30.useState)("");+ const [note, setNote] = (0, import_react30.useState)("");+ const [serviceLevel, setServiceLevel] = (0, import_react30.useState)(0);+ const [cycle, setCycle] = (0, import_react30.useState)(0);+ const waiting = (0, import_react30.useRef)(null);+ const reply = (0, import_react30.useRef)(lastReply);reply.current = lastReply;- const turn = (0, import_react29.useRef)(0);+ const turn = (0, import_react30.useRef)(0);const paneLeft = usePaneLeft();const close = () => {turn.current += 1;@@ -12851,12 +13190,12 @@ function VoiceMode({ sessionId, roster, actions, useSessions, useSessionStatus }dictation.stop();submit(text);});- (0, import_react29.useEffect)(() => {+ (0, import_react30.useEffect)(() => {if (!note) return void 0;const timer = setTimeout(() => setNote(""), 2600);return () => clearTimeout(timer);}, [note]);- (0, import_react29.useEffect)(() => {+ (0, import_react30.useEffect)(() => {if (!speech) return void 0;let live = true;speechCatalog(speech).then(({ catalog: next, usable }) => {@@ -12871,16 +13210,16 @@ function VoiceMode({ sessionId, roster, actions, useSessions, useSessionStatus }};}, [speech]);const listen = phase === "listening";- (0, import_react29.useEffect)(() => {+ (0, import_react30.useEffect)(() => {if (speech || !listen || dictation.listening) return void 0;const timer = setTimeout(() => dictation.start({ continuous: false, onEnd: () => {} }), 250);return () => clearTimeout(timer);}, [listen, dictation.listening]);- (0, import_react29.useEffect)(() => {+ (0, import_react30.useEffect)(() => {if (phase !== "listening") dictation.stop();}, [phase]);- (0, import_react29.useEffect)(() => {+ (0, import_react30.useEffect)(() => {if (!speech || !catalog || !listen) return void 0;const own = turn.current;let capture = null;@@ -12942,7 +13281,7 @@ function VoiceMode({ sessionId, roster, actions, useSessions, useSessionStatus }setServiceLevel(0);};}, [speech, catalog, listen, cycle]);- (0, import_react29.useEffect)(() => {+ (0, import_react30.useEffect)(() => {if (phase !== "thinking" || running || waiting.current === null) return;const [count, text] = [lastReply.slice(0, lastReply.indexOf("|")), lastReply.slice(lastReply.indexOf("|") + 1)];if (count === waiting.current || !text.trim()) return;@@ -12962,7 +13301,7 @@ function VoiceMode({ sessionId, roster, actions, useSessions, useSessionStatus }window.speechSynthesis.cancel();window.speechSynthesis.speak(utterance);}, [phase, running, lastReply]);- (0, import_react29.useEffect)(() => () => window.speechSynthesis?.cancel(), []);+ (0, import_react30.useEffect)(() => () => window.speechSynthesis?.cancel(), []);const micLevel = useMicLevel(!speech && phase === "listening" && dictation.listening);const level = speech ? serviceLevel : micLevel;const markState = phase === "thinking" || phase === "transcribing" ? "thinking" : phase === "speaking" ? "sending" : "idle";@@ -12979,58 +13318,58 @@ function VoiceMode({ sessionId, roster, actions, useSessions, useSessionStatus }const openSetup = phase === "setup" ? actions.voiceSetup() : null;const caption = phase === "speaking" ? said : heard;const shownNote = note || dictation.note;- return (0, import_react29.createElement)(+ return (0, import_react30.createElement)("div",{ className: "bt-pane bt-voice-pane", style: { left: paneLeft } },- (0, import_react29.createElement)(+ (0, import_react30.createElement)("div",{ className: "bt-voice-stage", role: "dialog", "aria-label": t("Voice chat with {name}", { name }), "data-phase": phase === "transcribing" ? "thinking" : phase },- (0, import_react29.createElement)(+ (0, import_react30.createElement)("div",{ className: "bt-voice-orb", style: { "--bt-level": level } },- (0, import_react29.createElement)("span", { className: "bt-voice-ring", "aria-hidden": true }),- (0, import_react29.createElement)("span", { className: "bt-voice-ring bt-voice-ring-2", "aria-hidden": true }),- bot ? (0, import_react29.createElement)(BotMark, { bot, size: 112, state: markState, live: true, gaze: phase === "listening" }) : room2 ? (0, import_react29.createElement)(RoomAvatar, { room: room2, roster, size: 112 }) : null+ (0, import_react30.createElement)("span", { className: "bt-voice-ring", "aria-hidden": true }),+ (0, import_react30.createElement)("span", { className: "bt-voice-ring bt-voice-ring-2", "aria-hidden": true }),+ bot ? (0, import_react30.createElement)(BotMark, { bot, size: 112, state: markState, live: true, gaze: phase === "listening" }) : room2 ? (0, import_react30.createElement)(RoomAvatar, { room: room2, roster, size: 112 }) : null),- (0, import_react29.createElement)("div", { className: "bt-voice-name" }, name),- (0, import_react29.createElement)(+ (0, import_react30.createElement)("div", { className: "bt-voice-name" }, name),+ (0, import_react30.createElement)("div",{ className: "bt-voice-status", role: "status" },- phase === "thinking" ? (0, import_react29.createElement)(Shimmer, null, t("Thinking…")) : phase === "transcribing" ? (0, import_react29.createElement)(Shimmer, null, t("Recognizing…")) : VOICE_LABELS[phase] ? t(VOICE_LABELS[phase]) : ""+ phase === "thinking" ? (0, import_react30.createElement)(Shimmer, null, t("Thinking…")) : phase === "transcribing" ? (0, import_react30.createElement)(Shimmer, null, t("Recognizing…")) : VOICE_LABELS[phase] ? t(VOICE_LABELS[phase]) : ""),- (0, import_react29.createElement)("div", { className: "bt-voice-caption", key: `${phase}:${caption.slice(0, 12)}` }, caption),- openSetup ? (0, import_react29.createElement)("button", { type: "button", className: "bt-voice-setup", onClick: () => {+ (0, import_react30.createElement)("div", { className: "bt-voice-caption", key: `${phase}:${caption.slice(0, 12)}` }, caption),+ openSetup ? (0, import_react30.createElement)("button", { type: "button", className: "bt-voice-setup", onClick: () => {close();openSetup();} }, t("Set up voice input")) : null,- shownNote ? (0, import_react29.createElement)("div", { className: "bt-voice-note" }, shownNote) : null+ shownNote ? (0, import_react30.createElement)("div", { className: "bt-voice-note" }, shownNote) : null),- (0, import_react29.createElement)(+ (0, import_react30.createElement)("div",{ className: "bt-voice-bar" },- (0, import_react29.createElement)("button", {+ (0, import_react30.createElement)("button", {type: "button",className: "bt-voice-btn","aria-pressed": phase === "paused",disabled: blocked,"aria-label": phase === "paused" ? t("Resume listening") : t("Pause"),onClick: togglePause- }, (0, import_react29.createElement)(MicIcon, { size: 20 }), phase === "paused" ? (0, import_react29.createElement)("span", { className: "bt-voice-slash", "aria-hidden": true }) : null),- (0, import_react29.createElement)("button", { type: "button", className: "bt-voice-btn bt-voice-end", "aria-label": t("End voice chat"), onClick: close }, (0, import_react29.createElement)(CloseIcon))+ }, (0, import_react30.createElement)(MicIcon, { size: 20 }), phase === "paused" ? (0, import_react30.createElement)("span", { className: "bt-voice-slash", "aria-hidden": true }) : null),+ (0, import_react30.createElement)("button", { type: "button", className: "bt-voice-btn bt-voice-end", "aria-label": t("End voice chat"), onClick: close }, (0, import_react30.createElement)(CloseIcon))));}// src/client/permission-picker.js-var import_react30 = require("react");+var import_react31 = require("react");var LABELS = { "read-only": "Read only", "workspace-write": "Workspace", "danger-full-access": "Full access" };var DANGER = /* @__PURE__ */ new Set(["danger-full-access"]);var presetDanger = (value) => DANGER.has(value);var presetName = (value, catalog) => LABELS[value] ? t(LABELS[value]) : catalog?.options?.find((option) => option.value === value)?.name ?? value;function PermissionPicker({ catalog, saved, onPick, repick = false }) {- const [pending, setPending] = (0, import_react30.useState)(null);- const flight = (0, import_react30.useRef)({ value: void 0, latest: void 0 });- (0, import_react30.useEffect)(() => {+ const [pending, setPending] = (0, import_react31.useState)(null);+ const flight = (0, import_react31.useRef)({ value: void 0, latest: void 0 });+ (0, import_react31.useEffect)(() => {const flying = flight.current.value;if (pending === saved && (flying === void 0 || flying === pending)) setPending(null);}, [pending, saved]);@@ -13057,10 +13396,10 @@ function PermissionPicker({ catalog, saved, onPick, repick = false }) {}send(value);};- return (0, import_react30.createElement)(+ return (0, import_react31.createElement)(Segmented,{ label: t("Permissions"), value: current },- catalog.options.map((option) => (0, import_react30.createElement)("button", {+ catalog.options.map((option) => (0, import_react31.createElement)("button", {key: option.value,type: "button","aria-pressed": option.value === current,@@ -13072,7 +13411,7 @@ function PermissionPicker({ catalog, saved, onPick, repick = false }) {}// src/client/group-settings.js-var import_react31 = require("react");+var import_react32 = require("react");var ROOM_MODES = [["admin", "Admin leads", "Plain messages go to the admin, who calls others with @Name."],["everyone", "Everyone", "Every member answers in turn, admin first."]@@ -13083,8 +13422,8 @@ function roomSubtitle(room2, roster) {return [t("{count} members", { count: room2.members.length }), admin ? t("Admin {name}", { name: admin.name }) : t("No admin")].join(" · ");}function RelayLimitRow({ room: room2, update }) {- const [draft, setDraft] = (0, import_react31.useState)(room2.relayLimit ?? "");- (0, import_react31.useEffect)(() => setDraft(room2.relayLimit ?? ""), [room2.relayLimit]);+ const [draft, setDraft] = (0, import_react32.useState)(room2.relayLimit ?? "");+ (0, import_react32.useEffect)(() => setDraft(room2.relayLimit ?? ""), [room2.relayLimit]);const save = () => {const text = String(draft).trim();if (text === "") {@@ -13098,10 +13437,10 @@ function RelayLimitRow({ room: room2, update }) {}update({ relayLimit: limit });};- return (0, import_react31.createElement)(+ return (0, import_react32.createElement)(Row,{ label: t("Pause Bot relays after"), hint: t("Counted since your last message in this group.") },- (0, import_react31.createElement)("input", {+ (0, import_react32.createElement)("input", {className: "bt-bs-input bt-bs-num",type: "number",min: 1,@@ -13123,26 +13462,26 @@ function RelayLimitRow({ room: room2, update }) {function GroupPermission({ room: room2, catalog, update }) {if (!catalog?.options?.length) return null;const shared2 = room2.permission !== void 0;- return (0, import_react31.createElement)(+ return (0, import_react32.createElement)(Card,{ title: t("Permissions") },- (0, import_react31.createElement)(SwitchRow, {+ (0, import_react32.createElement)(SwitchRow, {label: t("Same for every member"),hint: t("Replaces each member's own permissions in this group."),on: shared2,onChange: (on) => update({ permission: on ? catalog.defaultPreset ?? catalog.options[0].value : null })}),- shared2 ? (0, import_react31.createElement)(+ shared2 ? (0, import_react32.createElement)("div",{ className: "bt-set-row bt-bs-row bt-bs-stack bt-gs-perm bt-veil" },- (0, import_react31.createElement)(PermissionPicker, { catalog, saved: room2.permission, onPick: (permission) => update({ permission }) })+ (0, import_react32.createElement)(PermissionPicker, { catalog, saved: room2.permission, onPick: (permission) => update({ permission }) })) : null);}function GroupSettingsForm({ room: room2, roster, actions, run: run2, onDeleted }) {- const [adding, setAdding] = (0, import_react31.useState)(false);- const [confirming, setConfirming] = (0, import_react31.useState)(false);- (0, import_react31.useEffect)(() => {+ const [adding, setAdding] = (0, import_react32.useState)(false);+ const [confirming, setConfirming] = (0, import_react32.useState)(false);+ (0, import_react32.useEffect)(() => {if (!confirming) return void 0;const timer = setTimeout(() => setConfirming(false), 4e3);return () => clearTimeout(timer);@@ -13166,41 +13505,41 @@ function GroupSettingsForm({ room: room2, roster, actions, run: run2, onDeletedif (done) onDeleted?.();});};- return (0, import_react31.createElement)(+ return (0, import_react32.createElement)("div",{ className: "bt-bs" },- (0, import_react31.createElement)(+ (0, import_react32.createElement)("div",{ className: "bt-bs-hero" },- (0, import_react31.createElement)(RoomAvatar, { room: room2, roster, size: 64 }),- (0, import_react31.createElement)(+ (0, import_react32.createElement)(RoomAvatar, { room: room2, roster, size: 64 }),+ (0, import_react32.createElement)("div",{ className: "bt-bs-who" },- (0, import_react31.createElement)("span", { className: "bt-bs-name" }, room2.name),- (0, import_react31.createElement)("span", { className: "bt-bs-sub" }, roomSubtitle(room2, roster))+ (0, import_react32.createElement)("span", { className: "bt-bs-name" }, room2.name),+ (0, import_react32.createElement)("span", { className: "bt-bs-sub" }, roomSubtitle(room2, roster)))),- (0, import_react31.createElement)(+ (0, import_react32.createElement)(Card,{ title: t("Profile") },- (0, import_react31.createElement)(+ (0, import_react32.createElement)(Row,{ label: t("Name"), hint: t("Leave it empty to name the group after its members.") },- (0, import_react31.createElement)(InlineText, { label: t("Group name"), value: room2.named ? room2.name : "", placeholder: t("Name after members"), maxLength: 60, onSave: (name) => update({ name }) })+ (0, import_react32.createElement)(InlineText, { label: t("Group name"), value: room2.named ? room2.name : "", placeholder: t("Name after members"), maxLength: 60, onSave: (name) => update({ name }) })),- (0, import_react31.createElement)(+ (0, import_react32.createElement)(Row,{ label: t("Notice"), hint: t("Every member reads it before speaking in this group."), stack: true },- (0, import_react31.createElement)(InlineText, { label: t("Group notice"), value: room2.notice, multiline: true, maxLength: 2e3, placeholder: t("Shared instructions every member reads before speaking…"), onSave: (notice) => update({ notice }) })+ (0, import_react32.createElement)(InlineText, { label: t("Group notice"), value: room2.notice, multiline: true, maxLength: 2e3, placeholder: t("Shared instructions every member reads before speaking…"), onSave: (notice) => update({ notice }) }))),- (0, import_react31.createElement)(+ (0, import_react32.createElement)(Card,{ title: t("Who answers") },- (0, import_react31.createElement)(+ (0, import_react32.createElement)("div",{ className: "bt-set-row bt-bs-row bt-bs-stack" },- (0, import_react31.createElement)(Segmented, { label: t("Who answers"), value: mode }, ROOM_MODES.map(([id, label]) => (0, import_react31.createElement)("button", {+ (0, import_react32.createElement)(Segmented, { label: t("Who answers"), value: mode }, ROOM_MODES.map(([id, label]) => (0, import_react32.createElement)("button", {key: id,type: "button","aria-pressed": mode === id,@@ -13210,88 +13549,88 @@ function GroupSettingsForm({ room: room2, roster, actions, run: run2, onDeletedif (mode !== id) void update({ mode: id });}}, t(label)))),- (0, import_react31.createElement)("span", { key: mode, className: "bt-set-hint bt-veil" }, `${t(modeHint)} ${t("@mentions always pick who answers.")}`)+ (0, import_react32.createElement)("span", { key: mode, className: "bt-set-hint bt-veil" }, `${t(modeHint)} ${t("@mentions always pick who answers.")}`)),- (0, import_react31.createElement)(RelayLimitRow, { room: room2, update })+ (0, import_react32.createElement)(RelayLimitRow, { room: room2, update })),- (0, import_react31.createElement)(+ (0, import_react32.createElement)(Card,{ title: t("Working folder") },- (0, import_react31.createElement)(+ (0, import_react32.createElement)("div",{ className: "bt-set-row bt-bs-row" },- (0, import_react31.createElement)("span", { className: "bt-set-copy" }, (0, import_react31.createElement)("span", { className: "bt-bs-label" }, t("Folder"))),- (0, import_react31.createElement)(FolderMenu, { value: room2.workDir, group: true, actions, run: run2, onPick: (workDir) => update({ workDir }) })+ (0, import_react32.createElement)("span", { className: "bt-set-copy" }, (0, import_react32.createElement)("span", { className: "bt-bs-label" }, t("Folder"))),+ (0, import_react32.createElement)(FolderMenu, { value: room2.workDir, group: true, actions, run: run2, onPick: (workDir) => update({ workDir }) }))),- (0, import_react31.createElement)(GroupPermission, { room: room2, catalog: roster.permissions, update }),- (0, import_react31.createElement)(+ (0, import_react32.createElement)(GroupPermission, { room: room2, catalog: roster.permissions, update }),+ (0, import_react32.createElement)(Card,{ title: t("Members · {count}", { count: members.length }) },members.map((member) => {const leads = room2.admin === member.id;- return (0, import_react31.createElement)(+ return (0, import_react32.createElement)("div",{ key: member.id, className: "bt-set-row bt-bs-row bt-gs-member" },- (0, import_react31.createElement)(+ (0, import_react32.createElement)("button",{ type: "button", className: "bt-gs-who", title: t("Open {name}'s chat", { name: member.name }), onClick: () => openBot(member.id) },- (0, import_react31.createElement)(BotAvatar, { bot: member, size: 26, main: isMainOf(roster, member.id), admin: leads, live: false }),- (0, import_react31.createElement)("span", { className: "bt-row-title" }, member.name),- leads ? (0, import_react31.createElement)("span", { className: "bt-tag" }, t("Admin")) : null+ (0, import_react32.createElement)(BotAvatar, { bot: member, size: 26, main: isMainOf(roster, member.id), admin: leads, live: false }),+ (0, import_react32.createElement)("span", { className: "bt-row-title" }, member.name),+ leads ? (0, import_react32.createElement)("span", { className: "bt-tag" }, t("Admin")) : null),- leads ? (0, import_react31.createElement)("button", { type: "button", className: "bt-mini", title: t("Leave the group without an admin"), onClick: () => update({ admin: null }) }, t("Unset")) : (0, import_react31.createElement)("button", { type: "button", className: "bt-mini", onClick: () => update({ admin: member.id }) }, t("Make admin")),- members.length > 2 ? (0, import_react31.createElement)("button", { type: "button", className: "bt-x", "aria-label": t("Remove {name} from the group", { name: member.name }), title: t("Remove from group"), onClick: () => update({ remove: [member.id] }) }, "×") : null+ leads ? (0, import_react32.createElement)("button", { type: "button", className: "bt-mini", title: t("Leave the group without an admin"), onClick: () => update({ admin: null }) }, t("Unset")) : (0, import_react32.createElement)("button", { type: "button", className: "bt-mini", onClick: () => update({ admin: member.id }) }, t("Make admin")),+ members.length > 2 ? (0, import_react32.createElement)("button", { type: "button", className: "bt-x", "aria-label": t("Remove {name} from the group", { name: member.name }), title: t("Remove from group"), onClick: () => update({ remove: [member.id] }) }, "×") : null);}),adding ? [- ...outside.map((bot) => (0, import_react31.createElement)(+ ...outside.map((bot) => (0, import_react32.createElement)("button",{ key: bot.id, type: "button", className: "bt-set-row bt-bs-row bt-gs-pick", onClick: () => {setAdding(false);void update({ add: [bot.id] });} },- (0, import_react31.createElement)(BotMark, { bot, size: 22 }),- (0, import_react31.createElement)("span", { className: "bt-set-copy" }, (0, import_react31.createElement)("span", { className: "bt-bs-label" }, bot.name)),- (0, import_react31.createElement)("span", { className: "bt-set-hint" }, t("Add"))+ (0, import_react32.createElement)(BotMark, { bot, size: 22 }),+ (0, import_react32.createElement)("span", { className: "bt-set-copy" }, (0, import_react32.createElement)("span", { className: "bt-bs-label" }, bot.name)),+ (0, import_react32.createElement)("span", { className: "bt-set-hint" }, t("Add")))),- (0, import_react31.createElement)("button", { key: "cancel", type: "button", className: "bt-set-row bt-bs-row bt-gs-add", onClick: () => setAdding(false) }, t("Cancel"))- ] : outside.length > 0 ? (0, import_react31.createElement)("button", { type: "button", className: "bt-set-row bt-bs-row bt-gs-add", onClick: () => setAdding(true) }, (0, import_react31.createElement)(PlusIcon), t("Add member")) : null,- (0, import_react31.createElement)("div", { className: "bt-set-row bt-gs-note" }, (0, import_react31.createElement)(+ (0, import_react32.createElement)("button", { key: "cancel", type: "button", className: "bt-set-row bt-bs-row bt-gs-add", onClick: () => setAdding(false) }, t("Cancel"))+ ] : outside.length > 0 ? (0, import_react32.createElement)("button", { type: "button", className: "bt-set-row bt-bs-row bt-gs-add", onClick: () => setAdding(true) }, (0, import_react32.createElement)(PlusIcon), t("Add member")) : null,+ (0, import_react32.createElement)("div", { className: "bt-set-row bt-gs-note" }, (0, import_react32.createElement)("span",{ className: "bt-set-hint" },// The host checks for two members on every change, even a rename.members.length < 2 ? t("Add a Bot first: a group chat needs at least two.") : admin ? t("{name} leads this group: it can call members with @Name, change the group, and post here.", { name: admin.name }) : t("No admin yet. An admin can call members with @Name, change the group, and post here.")))),- (0, import_react31.createElement)(+ (0, import_react32.createElement)(Card,{ title: t("Sidebar") },- (0, import_react31.createElement)(SwitchRow, { label: t("Pin"), hint: t("Kept above the other chats."), on: room2.pinned === true, onChange: (pinned) => run2(actions.setFlags(room2.id, { pinned })) }),- (0, import_react31.createElement)(SwitchRow, { label: t("Hide from sidebar"), hint: t("Search still finds it."), on: room2.hidden === true, onChange: (hidden) => run2(actions.setFlags(room2.id, { hidden })) })+ (0, import_react32.createElement)(SwitchRow, { label: t("Pin"), hint: t("Kept above the other chats."), on: room2.pinned === true, onChange: (pinned) => run2(actions.setFlags(room2.id, { pinned })) }),+ (0, import_react32.createElement)(SwitchRow, { label: t("Hide from sidebar"), hint: t("Search still finds it."), on: room2.hidden === true, onChange: (hidden) => run2(actions.setFlags(room2.id, { hidden })) })),- (0, import_react31.createElement)(+ (0, import_react32.createElement)(Card,{ title: t("Manage") },- (0, import_react31.createElement)(+ (0, import_react32.createElement)("button",{ type: "button", className: "bt-set-row bt-bs-row bt-bs-danger", "data-confirm": confirming || void 0, onClick: remove },- (0, import_react31.createElement)(+ (0, import_react32.createElement)("span",{ className: "bt-set-copy" },- (0, import_react31.createElement)("span", { className: "bt-bs-label" }, confirming ? t("Delete {name}?", { name: room2.name }) : t("Delete group")),- (0, import_react31.createElement)("span", { className: "bt-set-hint" }, confirming ? t("Click again to delete. Its history is archived.") : t("Removes the group chat. Its members stay on the team."))+ (0, import_react32.createElement)("span", { className: "bt-bs-label" }, confirming ? t("Delete {name}?", { name: room2.name }) : t("Delete group")),+ (0, import_react32.createElement)("span", { className: "bt-set-hint" }, confirming ? t("Click again to delete. Its history is archived.") : t("Removes the group chat. Its members stay on the team."))),- (0, import_react31.createElement)("span", { className: "bt-chevron" }, (0, import_react31.createElement)(ChevronRightIcon))+ (0, import_react32.createElement)("span", { className: "bt-chevron" }, (0, import_react32.createElement)(ChevronRightIcon)))));}function NewGroupForm({ roster, actions, run: run2, onCreated, onCancel }) {- const [admin, setAdmin] = (0, import_react31.useState)(null);- const [members, setMembers] = (0, import_react31.useState)([]);- const [name, setName] = (0, import_react31.useState)("");- const [busy, setBusy] = (0, import_react31.useState)(false);+ const [admin, setAdmin] = (0, import_react32.useState)(null);+ const [members, setMembers] = (0, import_react32.useState)([]);+ const [name, setName] = (0, import_react32.useState)("");+ const [busy, setBusy] = (0, import_react32.useState)(false);const toggle = (id) => setMembers((list) => list.includes(id) ? list.filter((item) => item !== id) : [...list, id]);const pickAdmin = (id) => {setAdmin(id);@@ -13307,48 +13646,48 @@ function NewGroupForm({ roster, actions, run: run2, onCreated, onCancel }) {if (done && room2) onCreated(room2);else setBusy(false);};- const chip = (bot, on, onClick, role) => (0, import_react31.createElement)("button", {+ const chip = (bot, on, onClick, role) => (0, import_react32.createElement)("button", {key: bot.id,type: "button",role,className: "bt-ng-chip","aria-checked": on,onClick- }, (0, import_react31.createElement)(BotAvatar, { bot, size: 22, badge: false, live: false }), (0, import_react31.createElement)("span", { className: "bt-ng-name" }, bot.name), on && role === "radio" ? (0, import_react31.createElement)(AdminStar) : null);- return (0, import_react31.createElement)(+ }, (0, import_react32.createElement)(BotAvatar, { bot, size: 22, badge: false, live: false }), (0, import_react32.createElement)("span", { className: "bt-ng-name" }, bot.name), on && role === "radio" ? (0, import_react32.createElement)(AdminStar) : null);+ return (0, import_react32.createElement)("div",{ className: "bt-set-card bt-ng" },- (0, import_react31.createElement)(+ (0, import_react32.createElement)("div",{ className: "bt-set-row bt-bs-row bt-bs-stack" },- (0, import_react31.createElement)("span", { className: "bt-set-copy" }, (0, import_react31.createElement)("span", { className: "bt-bs-label bt-ng-label" }, (0, import_react31.createElement)(AdminStar), t("Choose the group admin"))),- (0, import_react31.createElement)(+ (0, import_react32.createElement)("span", { className: "bt-set-copy" }, (0, import_react32.createElement)("span", { className: "bt-bs-label bt-ng-label" }, (0, import_react32.createElement)(AdminStar), t("Choose the group admin"))),+ (0, import_react32.createElement)("div",{ className: "bt-ng-picks", role: "radiogroup", "aria-label": t("Group admin") },roster.bots.map((bot) => chip(bot, admin === bot.id, () => pickAdmin(bot.id), "radio")))),- admin === null ? null : (0, import_react31.createElement)(+ admin === null ? null : (0, import_react32.createElement)("div",{ className: "bt-set-row bt-bs-row bt-bs-stack bt-ng-step" },- (0, import_react31.createElement)("span", { className: "bt-set-copy" }, (0, import_react31.createElement)("span", { className: "bt-bs-label" }, t("Who to chat with…"))),- (0, import_react31.createElement)(+ (0, import_react32.createElement)("span", { className: "bt-set-copy" }, (0, import_react32.createElement)("span", { className: "bt-bs-label" }, t("Who to chat with…"))),+ (0, import_react32.createElement)("div",{ className: "bt-ng-picks", role: "group", "aria-label": t("Members") },roster.bots.filter((bot) => bot.id !== admin).map((bot) => chip(bot, members.includes(bot.id), () => toggle(bot.id), "checkbox")))),- admin === null || members.length === 0 ? null : (0, import_react31.createElement)(+ admin === null || members.length === 0 ? null : (0, import_react32.createElement)("label",{ className: "bt-set-row bt-bs-row bt-ng-step" },- (0, import_react31.createElement)("span", { className: "bt-set-copy" }, (0, import_react31.createElement)("span", { className: "bt-bs-label" }, t("Name"))),- (0, import_react31.createElement)("input", { className: "bt-bs-input", value: name, maxLength: 60, placeholder: t("Name after members"), onChange: (event) => setName(event.target.value) })+ (0, import_react32.createElement)("span", { className: "bt-set-copy" }, (0, import_react32.createElement)("span", { className: "bt-bs-label" }, t("Name"))),+ (0, import_react32.createElement)("input", { className: "bt-bs-input", value: name, maxLength: 60, placeholder: t("Name after members"), onChange: (event) => setName(event.target.value) })),- (0, import_react31.createElement)(+ (0, import_react32.createElement)("div",{ className: "bt-set-row bt-task-foot" },- (0, import_react31.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onCancel }, t("Cancel")),- (0, import_react31.createElement)("button", { type: "button", className: "bt-send bt-soft-sm", disabled: busy || admin === null || members.length === 0, onClick: () => void create() }, t("Create group chat"))+ (0, import_react32.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onCancel }, t("Cancel")),+ (0, import_react32.createElement)("button", { type: "button", className: "bt-send bt-soft-sm", disabled: busy || admin === null || members.length === 0, onClick: () => void create() }, t("Create group chat"))));}@@ -13508,7 +13847,7 @@ function percent2(part, whole) {}// src/client/usage-page.js-var import_react32 = require("react");+var import_react33 = require("react");var HEAT_WEEKS = 53;var TOP_SERIES = 7;var RING_R = 42;@@ -13555,9 +13894,9 @@ function titleOf(range, bucket) {return dates({ year: "numeric", month: "long" }).format(bucket.start);}function useTween(value) {- const [shown, setShown] = (0, import_react32.useState)(0);- const from = (0, import_react32.useRef)(0);- (0, import_react32.useEffect)(() => {+ const [shown, setShown] = (0, import_react33.useState)(0);+ const from = (0, import_react33.useRef)(0);+ (0, import_react33.useEffect)(() => {if (reducedMotion() || typeof requestAnimationFrame !== "function") {from.current = value;setShown(value);@@ -13577,9 +13916,9 @@ function useTween(value) {}, [value]);return shown;}-var glyphBox = (size, icon2) => (0, import_react32.createElement)("span", { className: "bt-us-glyph", style: { width: size, height: size } }, (0, import_react32.createElement)(icon2));+var glyphBox = (size, icon2) => (0, import_react33.createElement)("span", { className: "bt-us-glyph", style: { width: size, height: size } }, (0, import_react33.createElement)(icon2));function ModelGlyph({ name, paint, size }) {- return (0, import_react32.createElement)("span", {+ return (0, import_react33.createElement)("span", {className: "bt-us-model","aria-hidden": true,style: { width: size, height: size, fontSize: Math.round(size * 0.42), background: `color-mix(in srgb, ${paint} 20%, var(--bt-card))`, color: `color-mix(in srgb, ${paint} 72%, var(--bt-ink))` }@@ -13596,7 +13935,7 @@ function ownerFace(owner, roster) {sub: owner.deleted ? t("Deleted") : role.toLowerCase() === name.toLowerCase() ? "" : role,paint: paintCss(colorOf(bot)),stops: GRADIENTS[colorOf(bot)],- glyph: (size) => (0, import_react32.createElement)(BotAvatar, { bot, size, badge: false, live: false })+ glyph: (size) => (0, import_react33.createElement)(BotAvatar, { bot, size, badge: false, live: false })};}if (owner.kind === "room") {@@ -13606,7 +13945,7 @@ function ownerFace(owner, roster) {name: owner.name || t("Deleted group chat"),sub: owner.deleted ? t("Deleted") : t("Group chat"),paint: "var(--bt-us-rest)",- glyph: (size) => room2 ? (0, import_react32.createElement)(RoomAvatar, { room: room2, roster, size }) : glyphBox(size, ChatsIcon)+ glyph: (size) => room2 ? (0, import_react33.createElement)(RoomAvatar, { room: room2, roster, size }) : glyphBox(size, ChatsIcon)};}if (owner.kind === "agent") {@@ -13628,30 +13967,30 @@ function Tabs({ label, value, options, onChange, boxRef }) {const names = options.map(([, text]) => text).join("\n");const glide = useGlide(`${value}${names}`, { box: boxRef });- return (0, import_react32.createElement)(+ return (0, import_react33.createElement)("div",{ ref: glide.box, className: "bt-us-tabs", role: "group", "aria-label": label },- (0, import_react32.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),- options.map(([id, text, icon2]) => (0, import_react32.createElement)("button", { key: id, type: "button", "aria-pressed": value === id, onClick: () => onChange(id) }, icon2 ? (0, import_react32.createElement)(icon2) : null, text))+ (0, import_react33.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),+ options.map(([id, text, icon2]) => (0, import_react33.createElement)("button", { key: id, type: "button", "aria-pressed": value === id, onClick: () => onChange(id) }, icon2 ? (0, import_react33.createElement)(icon2) : null, text)));}function Stats({ range, total, previous }) {const shown = useTween(total.total);const change = previous > 0 ? Math.round((total.total - previous) / previous * 100) : null;- const cell = (label, value) => (0, import_react32.createElement)("div", { className: "bt-us-stat" }, (0, import_react32.createElement)("span", { className: "bt-us-stat-label" }, label), (0, import_react32.createElement)("span", { className: "bt-us-stat-value" }, value));- return (0, import_react32.createElement)(+ const cell = (label, value) => (0, import_react33.createElement)("div", { className: "bt-us-stat" }, (0, import_react33.createElement)("span", { className: "bt-us-stat-label" }, label), (0, import_react33.createElement)("span", { className: "bt-us-stat-value" }, value));+ return (0, import_react33.createElement)("section",{ className: "bt-us-stats", style: { "--i": 0 } },- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div",{ className: "bt-us-stat bt-us-stat-main" },- (0, import_react32.createElement)("span", { className: "bt-us-stat-label" }, lastText(range)),- (0, import_react32.createElement)(+ (0, import_react33.createElement)("span", { className: "bt-us-stat-label" }, lastText(range)),+ (0, import_react33.createElement)("span",{ className: "bt-us-stat-value" },compact(shown),- (0, import_react32.createElement)("small", null, t("tokens")),- change === null ? null : (0, import_react32.createElement)(+ (0, import_react33.createElement)("small", null, t("tokens")),+ change === null ? null : (0, import_react33.createElement)("span",{ className: "bt-us-delta", title: compareText(range) },`${change >= 0 ? "↑" : "↓"} ${Math.abs(change)}%`@@ -13669,83 +14008,83 @@ function niceTop(max) {return [1, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10].map((scale) => scale * step).find((value) => value >= max);}function Chart({ range, columns: columns2, series, tipSeries, by, onBy, onPick }) {- const [hover, setHover] = (0, import_react32.useState)(null);+ const [hover, setHover] = (0, import_react33.useState)(null);const top = niceTop(Math.max(0, ...columns2.map((column) => column.total)));const count = columns2.length;const fillOf = new Map(series.map((entry) => [entry.key, entry.fill]));const tipOf = new Map(tipSeries.map((entry) => [entry.key, entry]));const tip = hover === null ? null : columns2[hover];const tipSide = hover !== null && hover >= count / 2 ? { right: `calc(${(count - hover) / count * 100}% + 8px)` } : { left: `calc(${(hover + 1) / count * 100}% + 8px)` };- return (0, import_react32.createElement)(+ return (0, import_react33.createElement)("section",{ className: "bt-us-card bt-us-chart", style: { "--i": 1 } },- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div",{ className: "bt-us-card-head" },- (0, import_react32.createElement)("h3", null, t("Tokens over time"), (0, import_react32.createElement)("span", null, unitLabel(range.unit))),- onBy ? (0, import_react32.createElement)(Tabs, { label: t("Group usage by"), value: by, onChange: onBy, options: [["bot", t("By Bot")], ["model", t("By model")]] }) : null+ (0, import_react33.createElement)("h3", null, t("Tokens over time"), (0, import_react33.createElement)("span", null, unitLabel(range.unit))),+ onBy ? (0, import_react33.createElement)(Tabs, { label: t("Group usage by"), value: by, onChange: onBy, options: [["bot", t("By Bot")], ["model", t("By model")]] }) : null),- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div",{ className: "bt-us-chart-body" },- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div",{ className: "bt-us-plot", "data-hover": hover === null ? void 0 : "", onMouseLeave: () => setHover(null) },- [1, 0.5].map((level) => (0, import_react32.createElement)("div", { key: level, className: "bt-us-grid", style: { bottom: `${level * 100}%` } }, (0, import_react32.createElement)("span", null, compact(top * level)))),- (0, import_react32.createElement)("div", { className: "bt-us-grid bt-us-base", style: { bottom: 0 } }, (0, import_react32.createElement)("span", null, "0")),- (0, import_react32.createElement)(+ [1, 0.5].map((level) => (0, import_react33.createElement)("div", { key: level, className: "bt-us-grid", style: { bottom: `${level * 100}%` } }, (0, import_react33.createElement)("span", null, compact(top * level)))),+ (0, import_react33.createElement)("div", { className: "bt-us-grid bt-us-base", style: { bottom: 0 } }, (0, import_react33.createElement)("span", null, "0")),+ (0, import_react33.createElement)("div",{ className: "bt-us-cols" },- columns2.map((column, at) => (0, import_react32.createElement)("div", {+ columns2.map((column, at) => (0, import_react33.createElement)("div", {key: `${range.from ? `${range.from}~${range.to}` : range.id}:${column.key}`,className: "bt-us-col","data-on": hover === at ? "" : void 0,onMouseEnter: () => setHover(at)- }, column.total > 0 ? (0, import_react32.createElement)(+ }, column.total > 0 ? (0, import_react33.createElement)("div",{ className: "bt-us-stack", style: { height: `${column.total / top * 100}%`, "--i": at } },- column.parts.map(([key, value]) => value > 0 ? (0, import_react32.createElement)("i", { key, style: { flexGrow: value, background: fillOf.get(key) } }) : null)- ) : (0, import_react32.createElement)("div", { className: "bt-us-stub" })))+ column.parts.map(([key, value]) => value > 0 ? (0, import_react33.createElement)("i", { key, style: { flexGrow: value, background: fillOf.get(key) } }) : null)+ ) : (0, import_react33.createElement)("div", { className: "bt-us-stub" })))),- tip ? (0, import_react32.createElement)(+ tip ? (0, import_react33.createElement)("div",{ className: "bt-us-tip", style: tipSide },- (0, import_react32.createElement)("div", { className: "bt-us-tip-title" }, tip.title),- (0, import_react32.createElement)("div", { className: "bt-us-tip-total" }, t("{count} tokens", { count: full(tip.total) })),- tip.tip.filter(([, value]) => value > 0).sort((a, b) => b[1] - a[1]).map(([key, value]) => (0, import_react32.createElement)(+ (0, import_react33.createElement)("div", { className: "bt-us-tip-title" }, tip.title),+ (0, import_react33.createElement)("div", { className: "bt-us-tip-total" }, t("{count} tokens", { count: full(tip.total) })),+ tip.tip.filter(([, value]) => value > 0).sort((a, b) => b[1] - a[1]).map(([key, value]) => (0, import_react33.createElement)("div",{ key, className: "bt-us-tip-row" },- (0, import_react32.createElement)("i", { className: "bt-us-dot", style: { background: tipOf.get(key)?.fill } }),- (0, import_react32.createElement)("span", null, tipOf.get(key)?.name),- (0, import_react32.createElement)("b", null, compact(value))+ (0, import_react33.createElement)("i", { className: "bt-us-dot", style: { background: tipOf.get(key)?.fill } }),+ (0, import_react33.createElement)("span", null, tipOf.get(key)?.name),+ (0, import_react33.createElement)("b", null, compact(value))))) : null),- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div",{ className: "bt-us-ticks", "aria-hidden": true },// A preset counts its labels back from now; a picked span forward from its first day.- columns2.map((column, at) => (0, import_react32.createElement)(+ columns2.map((column, at) => (0, import_react33.createElement)("span",{ key: column.key, "data-now": at === count - 1 && range.ends !== false ? "" : void 0 },(range.from ? at : count - 1 - at) % range.stride === 0 ? column.tick : "")))),- series.length > 1 || series[0]?.pick ? (0, import_react32.createElement)(+ series.length > 1 || series[0]?.pick ? (0, import_react33.createElement)("div",{ className: "bt-us-legend" },- series.map((entry) => (0, import_react32.createElement)(entry.pick ? "button" : "span", {+ series.map((entry) => (0, import_react33.createElement)(entry.pick ? "button" : "span", {key: entry.key,className: "bt-us-key",...entry.pick ? { type: "button", onClick: () => onPick(entry.pick) } : {}- }, (0, import_react32.createElement)("i", { className: "bt-us-dot", style: { background: entry.fill } }), entry.name))+ }, (0, import_react33.createElement)("i", { className: "bt-us-dot", style: { background: entry.fill } }), entry.name))) : null);}function Row2({ kind, glyph, name, sub, sum, whole, fill: fill2, index, onClick }) {const width = whole > 0 ? Math.max(sum.total > 0 ? 2 : 0, sum.total / whole * 100) : 0;- return (0, import_react32.createElement)(+ return (0, import_react33.createElement)(onClick ? "button" : "div",{className: "bt-us-row",@@ -13754,69 +14093,69 @@ function Row2({ kind, glyph, name, sub, sum, whole, fill: fill2, index, onClicktitle: t("{tokens} tokens · {calls} calls", { tokens: full(sum.total), calls: full(sum.calls) }),...onClick ? { type: "button", onClick } : {}},- glyph ? (0, import_react32.createElement)("span", { className: "bt-us-row-glyph" }, glyph) : null,- (0, import_react32.createElement)(+ glyph ? (0, import_react33.createElement)("span", { className: "bt-us-row-glyph" }, glyph) : null,+ (0, import_react33.createElement)("span",{ className: "bt-us-row-body" },- (0, import_react32.createElement)(+ (0, import_react33.createElement)("span",{ className: "bt-us-row-line" },- (0, import_react32.createElement)("span", { className: "bt-us-row-name" }, name),- sub ? (0, import_react32.createElement)("span", { className: "bt-us-row-sub" }, sub) : null+ (0, import_react33.createElement)("span", { className: "bt-us-row-name" }, name),+ sub ? (0, import_react33.createElement)("span", { className: "bt-us-row-sub" }, sub) : null),- (0, import_react32.createElement)("span", { className: "bt-us-track" }, (0, import_react32.createElement)("span", { style: { width: `${width}%`, background: fill2 } }))+ (0, import_react33.createElement)("span", { className: "bt-us-track" }, (0, import_react33.createElement)("span", { style: { width: `${width}%`, background: fill2 } }))),- (0, import_react32.createElement)("span", { className: "bt-us-row-num" }, (0, import_react32.createElement)("b", null, compact(sum.total)), (0, import_react32.createElement)("small", null, `${percent2(sum.total, whole)}%`))+ (0, import_react33.createElement)("span", { className: "bt-us-row-num" }, (0, import_react33.createElement)("b", null, compact(sum.total)), (0, import_react33.createElement)("small", null, `${percent2(sum.total, whole)}%`)));}function ListCard({ title, count, index, children }) {- return (0, import_react32.createElement)(+ return (0, import_react33.createElement)("section",{ className: "bt-us-card", style: { "--i": index } },- (0, import_react32.createElement)("div", { className: "bt-us-card-head" }, (0, import_react32.createElement)("h3", null, title, count === void 0 ? null : (0, import_react32.createElement)("span", null, count))),- (0, import_react32.createElement)("div", { className: "bt-us-rows" }, children)+ (0, import_react33.createElement)("div", { className: "bt-us-card-head" }, (0, import_react33.createElement)("h3", null, title, count === void 0 ? null : (0, import_react33.createElement)("span", null, count))),+ (0, import_react33.createElement)("div", { className: "bt-us-rows" }, children));}function Profile({ face, share, range }) {const arc = Math.max(0, Math.min(1, share)) * RING;- return (0, import_react32.createElement)(+ return (0, import_react33.createElement)("section",{ className: "bt-us-profile" },- (0, import_react32.createElement)(+ (0, import_react33.createElement)("span",{ className: "bt-us-ring" },- (0, import_react32.createElement)(+ (0, import_react33.createElement)("svg",{ viewBox: "0 0 96 96", "aria-hidden": true },- face.stops ? (0, import_react32.createElement)("defs", null, (0, import_react32.createElement)(+ face.stops ? (0, import_react33.createElement)("defs", null, (0, import_react33.createElement)("linearGradient",{ id: "bt-us-ring-paint", x1: 0, y1: 1, x2: 1, y2: 0 },- face.stops.map(([offset, color]) => (0, import_react32.createElement)("stop", { key: offset, offset, stopColor: color }))+ face.stops.map(([offset, color]) => (0, import_react33.createElement)("stop", { key: offset, offset, stopColor: color })))) : null,- (0, import_react32.createElement)("circle", { className: "bt-us-ring-track", cx: 48, cy: 48, r: RING_R }),- arc > 0 ? (0, import_react32.createElement)("circle", { className: "bt-us-ring-arc", cx: 48, cy: 48, r: RING_R, style: { stroke: face.stops ? "url(#bt-us-ring-paint)" : face.paint, strokeDasharray: `${arc} ${RING}` } }) : null+ (0, import_react33.createElement)("circle", { className: "bt-us-ring-track", cx: 48, cy: 48, r: RING_R }),+ arc > 0 ? (0, import_react33.createElement)("circle", { className: "bt-us-ring-arc", cx: 48, cy: 48, r: RING_R, style: { stroke: face.stops ? "url(#bt-us-ring-paint)" : face.paint, strokeDasharray: `${arc} ${RING}` } }) : null),- (0, import_react32.createElement)("span", { className: "bt-us-ring-face" }, face.glyph(64))+ (0, import_react33.createElement)("span", { className: "bt-us-ring-face" }, face.glyph(64))),- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div",{ className: "bt-us-profile-copy" },- (0, import_react32.createElement)("h3", null, face.name),- face.sub ? (0, import_react32.createElement)("span", { className: "bt-us-profile-sub" }, face.sub) : null,- (0, import_react32.createElement)("span", { className: "bt-us-profile-share" }, range.from ? t("{share}% of all usage from {span}", { share: percent2(share, 1), span: spanText(range.from, range.to) }) : t("{share}% of all usage in the last {range}", { share: percent2(share, 1), range: rangeLabel(range.id) }))+ (0, import_react33.createElement)("h3", null, face.name),+ face.sub ? (0, import_react33.createElement)("span", { className: "bt-us-profile-sub" }, face.sub) : null,+ (0, import_react33.createElement)("span", { className: "bt-us-profile-share" }, range.from ? t("{share}% of all usage from {span}", { share: percent2(share, 1), span: spanText(range.from, range.to) }) : t("{share}% of all usage in the last {range}", { share: percent2(share, 1), range: rangeLabel(range.id) }))));}var monthOf = (ms) => Date.UTC(yearOf(ms), new Date(ms).getUTCMonth(), 1);var addMonths = (ms, count) => Date.UTC(yearOf(ms), new Date(ms).getUTCMonth() + count, 1);function SpanPicker({ span, today, oldest, active, near, onPick, onClose }) {- const box = (0, import_react32.useRef)(null);+ const box = (0, import_react33.useRef)(null);const todayMs = hourMs(today);const thisMonth = monthOf(todayMs);- const [right, setRight] = (0, import_react32.useState)(() => Math.max(addMonths(oldest, 1), monthOf(hourMs(span?.to ?? today))));- const [anchor, setAnchor] = (0, import_react32.useState)(null);- const [hover, setHover] = (0, import_react32.useState)(null);- (0, import_react32.useEffect)(() => {+ const [right, setRight] = (0, import_react33.useState)(() => Math.max(addMonths(oldest, 1), monthOf(hourMs(span?.to ?? today))));+ const [anchor, setAnchor] = (0, import_react33.useState)(null);+ const [hover, setHover] = (0, import_react33.useState)(null);+ (0, import_react33.useEffect)(() => {const onDown = (event) => {if (![box, near].some((ref) => ref.current?.contains(event.target))) onClose();};@@ -13842,17 +14181,17 @@ function SpanPicker({ span, today, oldest, active, near, onPick, onClose }) {const [from, to] = [anchor, key].sort();onPick(from, to);};- const weekdays = (0, import_react32.useMemo)(() => Array.from({ length: 7 }, (_, at) => dates({ weekday: "narrow" }).format(Date.UTC(2024, 0, 1 + at))), []);+ const weekdays = (0, import_react33.useMemo)(() => Array.from({ length: 7 }, (_, at) => dates({ weekday: "narrow" }).format(Date.UTC(2024, 0, 1 + at))), []);const month = (start, side) => {const length = new Date(addMonths(start, 1) - DAY_MS).getUTCDate();const lead = (new Date(start).getUTCDay() + 6) % 7;- const cells = Array.from({ length: lead }, (_, at) => (0, import_react32.createElement)("span", { key: `b${at}` }));+ const cells = Array.from({ length: lead }, (_, at) => (0, import_react33.createElement)("span", { key: `b${at}` }));for (let day = 1; day <= length; day += 1) {const ms = start + (day - 1) * DAY_MS;const key = dayKey(ms);const weekday = (lead + day - 1) % 7;const flag = (on) => on ? "" : void 0;- cells.push((0, import_react32.createElement)("button", {+ cells.push((0, import_react33.createElement)("button", {key,type: "button",className: "bt-us-day",@@ -13868,15 +14207,15 @@ function SpanPicker({ span, today, oldest, active, near, onPick, onClose }) {"data-has": flag(active.has(key)),onMouseEnter: () => setHover(key),onClick: () => press(key)- }, (0, import_react32.createElement)("b", null, day)));+ }, (0, import_react33.createElement)("b", null, day)));}- const nav = side === "left" ? (0, import_react32.createElement)("button", { type: "button", className: "bt-us-month-nav", "data-side": "left", "aria-label": t("Previous month"), disabled: start <= oldest, onClick: () => setRight(addMonths(right, -1)) }, (0, import_react32.createElement)(ChevronLeftIcon)) : (0, import_react32.createElement)("button", { type: "button", className: "bt-us-month-nav", "data-side": "right", "aria-label": t("Next month"), disabled: start >= thisMonth, onClick: () => setRight(addMonths(right, 1)) }, (0, import_react32.createElement)(ChevronRightIcon));- return (0, import_react32.createElement)(+ const nav = side === "left" ? (0, import_react33.createElement)("button", { type: "button", className: "bt-us-month-nav", "data-side": "left", "aria-label": t("Previous month"), disabled: start <= oldest, onClick: () => setRight(addMonths(right, -1)) }, (0, import_react33.createElement)(ChevronLeftIcon)) : (0, import_react33.createElement)("button", { type: "button", className: "bt-us-month-nav", "data-side": "right", "aria-label": t("Next month"), disabled: start >= thisMonth, onClick: () => setRight(addMonths(right, 1)) }, (0, import_react33.createElement)(ChevronRightIcon));+ return (0, import_react33.createElement)("div",{ key: start, className: "bt-us-month" },- (0, import_react32.createElement)("div", { className: "bt-us-month-head" }, nav, (0, import_react32.createElement)("span", null, dates({ year: "numeric", month: "long" }).format(start))),- (0, import_react32.createElement)("div", { className: "bt-us-weekdays", "aria-hidden": true }, weekdays.map((name, at) => (0, import_react32.createElement)("span", { key: at }, name))),- (0, import_react32.createElement)("div", { className: "bt-us-days", onMouseLeave: () => setHover(null) }, cells)+ (0, import_react33.createElement)("div", { className: "bt-us-month-head" }, nav, (0, import_react33.createElement)("span", null, dates({ year: "numeric", month: "long" }).format(start))),+ (0, import_react33.createElement)("div", { className: "bt-us-weekdays", "aria-hidden": true }, weekdays.map((name, at) => (0, import_react33.createElement)("span", { key: at }, name))),+ (0, import_react33.createElement)("div", { className: "bt-us-days", onMouseLeave: () => setHover(null) }, cells));};const shortcuts = [@@ -13885,30 +14224,30 @@ function SpanPicker({ span, today, oldest, active, near, onPick, onClose }) {["year", t("This year"), `${today.slice(0, 4)}-01-01`, today]];const count = low === null ? 0 : Math.round((hourMs(high) - hourMs(low)) / DAY_MS) + 1;- return (0, import_react32.createElement)(+ return (0, import_react33.createElement)("div",{ ref: box, className: "bt-us-pick", role: "dialog", "aria-label": t("Custom range") },- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div",{ className: "bt-us-pick-quick" },- shortcuts.map(([id, label, from, to]) => (0, import_react32.createElement)("button", {+ shortcuts.map(([id, label, from, to]) => (0, import_react33.createElement)("button", {key: id,type: "button","aria-pressed": span?.from === from && span?.to === to,onClick: () => onPick(from, to)}, label))),- (0, import_react32.createElement)("div", { className: "bt-us-pick-months" }, month(addMonths(right, -1), "left"), month(right, "right")),- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div", { className: "bt-us-pick-months" }, month(addMonths(right, -1), "left"), month(right, "right")),+ (0, import_react33.createElement)("div",{ className: "bt-us-pick-foot", role: "status" },- (0, import_react32.createElement)("span", null, anchor ? t("Pick the last day") : t("Pick the first day")),- low === null ? null : (0, import_react32.createElement)("span", null, (0, import_react32.createElement)("b", null, spanText(low, high)), ` · ${daysText(count)}`)+ (0, import_react33.createElement)("span", null, anchor ? t("Pick the last day") : t("Pick the first day")),+ low === null ? null : (0, import_react33.createElement)("span", null, (0, import_react33.createElement)("b", null, spanText(low, high)), ` · ${daysText(count)}`)));}function Heat({ view, keep, paint, index }) {- const [hover, setHover] = (0, import_react32.useState)(null);+ const [hover, setHover] = (0, import_react33.useState)(null);const today = hourMs(`${view.now.slice(0, 10)} 00`);const first = mondayOf(today) - (HEAT_WEEKS - 1) * 7 * DAY_MS;const from = dayKey(first);@@ -13924,13 +14263,13 @@ function Heat({ view, keep, paint, index }) {for (let week = 0; week < HEAT_WEEKS; week += 1) {const monday = first + week * 7 * DAY_MS;if (week > 0 && new Date(monday).getUTCMonth() !== new Date(monday - 7 * DAY_MS).getUTCMonth()) {- months.push((0, import_react32.createElement)("span", { key: week, style: { gridColumn: week + 1 } }, dates({ month: "short" }).format(monday)));+ months.push((0, import_react33.createElement)("span", { key: week, style: { gridColumn: week + 1 } }, dates({ month: "short" }).format(monday)));}for (let day = 0; day < 7; day += 1) {const ms = monday + day * DAY_MS;const value = daily.get(dayKey(ms)) ?? 0;const level = value > 0 ? Math.max(1, Math.ceil(4 * Math.sqrt(value / most))) : 0;- cells.push((0, import_react32.createElement)("span", {+ cells.push((0, import_react33.createElement)("span", {key: ms,className: "bt-us-cell",style: { "--w": week },@@ -13938,7 +14277,7 @@ function Heat({ view, keep, paint, index }) {"data-future": ms > today ? "" : void 0,"data-today": ms === today ? "" : void 0,onMouseEnter: ms > today ? void 0 : () => setHover({ ms, week, day })- }, level > 0 ? (0, import_react32.createElement)("i", { style: { background: soften(paint, levels[level - 1]) } }) : null));+ }, level > 0 ? (0, import_react33.createElement)("i", { style: { background: soften(paint, levels[level - 1]) } }) : null));}}const tipSide = hover ? {@@ -13947,68 +14286,68 @@ function Heat({ view, keep, paint, index }) {} : null;const active = [...daily.values()].filter((value) => value > 0).length;const summary = active === 1 ? t("Active on 1 day in the last year") : t("Active on {count} days in the last year", { count: active });- return (0, import_react32.createElement)(+ return (0, import_react33.createElement)("section",{ className: "bt-us-card bt-us-heat", style: { "--i": index } },- (0, import_react32.createElement)("div", { className: "bt-us-card-head" }, (0, import_react32.createElement)("h3", null, t("Activity")), (0, import_react32.createElement)("span", { className: "bt-us-head-note" }, summary)),- (0, import_react32.createElement)("div", { className: "bt-us-heat-months", "aria-hidden": true }, months),- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div", { className: "bt-us-card-head" }, (0, import_react33.createElement)("h3", null, t("Activity")), (0, import_react33.createElement)("span", { className: "bt-us-head-note" }, summary)),+ (0, import_react33.createElement)("div", { className: "bt-us-heat-months", "aria-hidden": true }, months),+ (0, import_react33.createElement)("div",{ className: "bt-us-heat-plot", onMouseLeave: () => setHover(null) },- (0, import_react32.createElement)("div", { className: "bt-us-heat-grid", role: "img", "aria-label": summary }, cells),- hover ? (0, import_react32.createElement)(+ (0, import_react33.createElement)("div", { className: "bt-us-heat-grid", role: "img", "aria-label": summary }, cells),+ hover ? (0, import_react33.createElement)("div",{ className: "bt-us-tip bt-us-heat-tip", style: tipSide },- (0, import_react32.createElement)("div", { className: "bt-us-tip-title" }, dates({ month: "long", day: "numeric", weekday: "short" }).format(hover.ms)),- (0, import_react32.createElement)("div", { className: "bt-us-tip-total" }, t("{count} tokens", { count: full(daily.get(dayKey(hover.ms)) ?? 0) }))+ (0, import_react33.createElement)("div", { className: "bt-us-tip-title" }, dates({ month: "long", day: "numeric", weekday: "short" }).format(hover.ms)),+ (0, import_react33.createElement)("div", { className: "bt-us-tip-total" }, t("{count} tokens", { count: full(daily.get(dayKey(hover.ms)) ?? 0) }))) : null),- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div",{ className: "bt-us-heat-scale", "aria-hidden": true },t("Light"),- levels.map((level) => (0, import_react32.createElement)("span", { key: level, className: "bt-us-cell" }, (0, import_react32.createElement)("i", { style: { background: soften(paint, level) } }))),+ levels.map((level) => (0, import_react33.createElement)("span", { key: level, className: "bt-us-cell" }, (0, import_react33.createElement)("i", { style: { background: soften(paint, level) } }))),t("Heavy")));}function Skeleton2() {- return (0, import_react32.createElement)(+ return (0, import_react33.createElement)("div",{ className: "bt-us", "aria-busy": true },- (0, import_react32.createElement)("div", { className: "bt-us-skel", style: { height: 32, width: 320, borderRadius: 999 } }),- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div", { className: "bt-us-skel", style: { height: 32, width: 320, borderRadius: 999 } }),+ (0, import_react33.createElement)("div",{ className: "bt-us-sheet bt-us-skel-sheet" },- (0, import_react32.createElement)("div", { className: "bt-us-skel", style: { height: 94 } }),- (0, import_react32.createElement)("div", { className: "bt-us-skel", style: { height: 318 } }),- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div", { className: "bt-us-skel", style: { height: 94 } }),+ (0, import_react33.createElement)("div", { className: "bt-us-skel", style: { height: 318 } }),+ (0, import_react33.createElement)("div",{ className: "bt-us-pair" },- (0, import_react32.createElement)("div", { className: "bt-us-skel", style: { height: 200 } }),- (0, import_react32.createElement)("div", { className: "bt-us-skel", style: { height: 200 } })+ (0, import_react33.createElement)("div", { className: "bt-us-skel", style: { height: 200 } }),+ (0, import_react33.createElement)("div", { className: "bt-us-skel", style: { height: 200 } }))));}var focusOf = (id) => typeof id !== "string" ? null : id.startsWith("model:") ? { kind: "model", key: id.slice("model:".length) } : id.startsWith("owner:") ? { kind: "owner", key: id.slice("owner:".length) } : null;function UsagePage({ roster, actions, focusId }) {- const [view, setView] = (0, import_react32.useState)(null);- const [error, setError] = (0, import_react32.useState)("");- const [rangeId, setRangeId] = (0, import_react32.useState)("7d");- const [span, setSpan] = (0, import_react32.useState)(null);- const [picking, setPicking] = (0, import_react32.useState)(false);- const [by, setBy] = (0, import_react32.useState)("bot");- const tabs = (0, import_react32.useRef)(null);+ const [view, setView] = (0, import_react33.useState)(null);+ const [error, setError] = (0, import_react33.useState)("");+ const [rangeId, setRangeId] = (0, import_react33.useState)("7d");+ const [span, setSpan] = (0, import_react33.useState)(null);+ const [picking, setPicking] = (0, import_react33.useState)(false);+ const [by, setBy] = (0, import_react33.useState)("bot");+ const tabs = (0, import_react33.useRef)(null);const focus = focusOf(focusId);- (0, import_react32.useEffect)(() => {+ (0, import_react33.useEffect)(() => {let stopped = false;let timer;const load = async () => {try {const value = await actions.usage();if (stopped) return;- (0, import_react32.startTransition)(() => setView(value));+ (0, import_react33.startTransition)(() => setView(value));setError("");timer = setTimeout(load, value.scanning ? 3e3 : 2e4);} catch (failure) {@@ -14025,7 +14364,7 @@ function UsagePage({ roster, actions, focusId }) {}, []);const today = view?.now.slice(0, 10);const range = rangeId === "custom" && span ? { ...spanRange(span.from, span.to), ends: span.to >= today } : RANGES.find((item) => item.id === rangeId);- const shaped = (0, import_react32.useMemo)(() => {+ const shaped = (0, import_react33.useMemo)(() => {if (!view) return null;const faces2 = view.owners.map((owner) => ownerFace(owner, roster));const lifetime = /* @__PURE__ */ new Map();@@ -14034,7 +14373,7 @@ function UsagePage({ roster, actions, focusId }) {const models2 = view.models.map((model, at) => {const name = model.name || model.model || t("Unknown model");const paint = modelPaint.get(at) ?? "var(--bt-us-rest)";- return { kind: "model", name, sub: model.providerName ?? model.provider, paint, glyph: (size) => (0, import_react32.createElement)(ModelGlyph, { name, paint, size }) };+ return { kind: "model", name, sub: model.providerName ?? model.provider, paint, glyph: (size) => (0, import_react33.createElement)(ModelGlyph, { name, paint, size }) };});const ownerAt2 = focus?.kind === "owner" ? view.owners.findIndex((owner) => owner.key === focus.key) : -1;const modelAt = focus?.kind === "model" ? view.models.findIndex((model) => model.key === focus.key) : -1;@@ -14082,23 +14421,23 @@ function UsagePage({ roster, actions, focusId }) {});return { faces: faces2, models: models2, ownerAt: ownerAt2, modelAt, face: face2, keep: keep2, all: all2, part: part2, series: series2, tipSeries: tipSeries2, fillOf: fillOf2, columns: columns3, ranked: ranked2, isBot: isBot2, activeDays: activeDays2, oldest: oldest2 };}, [view, rangeId, span, by, focusId, roster]);- const root = (0, import_react32.useRef)(null);- (0, import_react32.useEffect)(() => {+ const root = (0, import_react33.useRef)(null);+ (0, import_react33.useEffect)(() => {root.current?.closest(".bt-settings-scroll")?.scrollTo?.({ top: 0 });}, [focusId]);if (!view) {- return error ? (0, import_react32.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : (0, import_react32.createElement)(Skeleton2);+ return error ? (0, import_react33.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : (0, import_react33.createElement)(Skeleton2);}if (view.rows.length === 0) {- return (0, import_react32.createElement)(+ return (0, import_react33.createElement)("div",{ className: "bt-us" },- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div",{ className: "bt-us-empty" },- (0, import_react32.createElement)(BotMark, { look: MAIN_LOOK, size: 56, live: true }),- (0, import_react32.createElement)("b", null, view.scanning ? t("Reading your chats…") : t("No usage yet.")),- (0, import_react32.createElement)("span", null, t("Token usage shows up here after a model is called."))+ (0, import_react33.createElement)(BotMark, { look: MAIN_LOOK, size: 56, live: true }),+ (0, import_react33.createElement)("b", null, view.scanning ? t("Reading your chats…") : t("No usage yet.")),+ (0, import_react33.createElement)("span", null, t("Token usage shows up here after a model is called."))));}@@ -14123,7 +14462,7 @@ function UsagePage({ roster, actions, focusId }) {["custom", rangeId === "custom" && span ? spanText(span.from, span.to) : t("Custom"), CalendarIcon]];const whole = part.total.total;- const ownerRow = ([at, sum], index, total = whole) => (0, import_react32.createElement)(Row2, {+ const ownerRow = ([at, sum], index, total = whole) => (0, import_react33.createElement)(Row2, {key: `o${at}`,kind: faces[at].kind,glyph: faces[at].glyph(32),@@ -14135,7 +14474,7 @@ function UsagePage({ roster, actions, focusId }) {fill: face ? soften(face.paint, 0.8) : fillOf.get(`o${at}`) ?? soften(faces[at].paint),onClick: () => pick2({ kind: "owner", key: view.owners[at].key })});- const modelRow = ([at, sum], index) => (0, import_react32.createElement)(Row2, {+ const modelRow = ([at, sum], index) => (0, import_react33.createElement)(Row2, {key: `m${at}`,kind: "model",glyph: models[at].glyph(32),@@ -14147,30 +14486,30 @@ function UsagePage({ roster, actions, focusId }) {fill: face ? soften(face.paint, 0.8) : fillOf.get(`m${at}`) ?? soften(models[at].paint),onClick: () => pick2({ kind: "model", key: view.models[at].key })});- const nothing = (0, import_react32.createElement)("div", { className: "bt-us-none" }, t("Nothing in this range."));+ const nothing = (0, import_react33.createElement)("div", { className: "bt-us-none" }, t("Nothing in this range."));let body;if (face) {const kinds = ranked(part.kinds);const usedModels = ranked(part.models);const owners = ranked(part.owners);body = [- (0, import_react32.createElement)(Profile, { key: "profile", face, range, share: all.total.total > 0 ? whole / all.total.total : 0 }),- (0, import_react32.createElement)(+ (0, import_react33.createElement)(Profile, { key: "profile", face, range, share: all.total.total > 0 ? whole / all.total.total : 0 }),+ (0, import_react33.createElement)("div",{ key: "sheet", className: "bt-us-sheet" },- (0, import_react32.createElement)(Stats, { key: "stats", range, total: part.total, previous: part.previous }),- (0, import_react32.createElement)(Chart, { key: "chart", range, columns: columns2, series, tipSeries, onPick: pick2 }),- (0, import_react32.createElement)(+ (0, import_react33.createElement)(Stats, { key: "stats", range, total: part.total, previous: part.previous }),+ (0, import_react33.createElement)(Chart, { key: "chart", range, columns: columns2, series, tipSeries, onPick: pick2 }),+ (0, import_react33.createElement)("div",{ key: "pair", className: "bt-us-pair" },- ownerAt >= 0 ? (0, import_react32.createElement)(ListCard, { title: t("Models"), count: usedModels.length, index: 2 }, usedModels.length > 0 ? usedModels.map(modelRow) : nothing) : (0, import_react32.createElement)(ListCard, { title: t("Who used it"), count: owners.length, index: 2 }, owners.length > 0 ? owners.map((entry, index) => ownerRow(entry, index)) : nothing),- (0, import_react32.createElement)(+ ownerAt >= 0 ? (0, import_react33.createElement)(ListCard, { title: t("Models"), count: usedModels.length, index: 2 }, usedModels.length > 0 ? usedModels.map(modelRow) : nothing) : (0, import_react33.createElement)(ListCard, { title: t("Who used it"), count: owners.length, index: 2 }, owners.length > 0 ? owners.map((entry, index) => ownerRow(entry, index)) : nothing),+ (0, import_react33.createElement)(ListCard,{ title: t("What for"), index: 3 },- kinds.length > 0 ? kinds.map(([at, sum], index) => (0, import_react32.createElement)(Row2, { key: at, name: kindLabel(view.kinds[at], ownerAt >= 0 && isBot(ownerAt)), sum, whole, index, fill: soften(face.paint, 0.8) })) : nothing+ kinds.length > 0 ? kinds.map(([at, sum], index) => (0, import_react33.createElement)(Row2, { key: at, name: kindLabel(view.kinds[at], ownerAt >= 0 && isBot(ownerAt)), sum, whole, index, fill: soften(face.paint, 0.8) })) : nothing)),- (0, import_react32.createElement)(Heat, { key: "heat", view, keep, paint: face.paint, index: 4 })+ (0, import_react33.createElement)(Heat, { key: "heat", view, keep, paint: face.paint, index: 4 }))];} else {@@ -14179,39 +14518,39 @@ function UsagePage({ roster, actions, focusId }) {const rest = owners.filter(([at]) => !isBot(at));const usedModels = ranked(all.models);body = [- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div",{ key: "sheet", className: "bt-us-sheet" },- (0, import_react32.createElement)(Stats, { key: "stats", range, total: all.total, previous: all.previous }),- (0, import_react32.createElement)(Chart, { key: "chart", range, columns: columns2, series, tipSeries, by, onBy: setBy, onPick: pick2 }),- (0, import_react32.createElement)(+ (0, import_react33.createElement)(Stats, { key: "stats", range, total: all.total, previous: all.previous }),+ (0, import_react33.createElement)(Chart, { key: "chart", range, columns: columns2, series, tipSeries, by, onBy: setBy, onPick: pick2 }),+ (0, import_react33.createElement)("div",{ key: "pair", className: "bt-us-pair" },- (0, import_react32.createElement)(+ (0, import_react33.createElement)(ListCard,{ title: t("Bots"), count: bots.length, index: 2 },owners.length > 0 ? null : nothing,bots.map((entry, index) => ownerRow(entry, index)),- bots.length > 0 && rest.length > 0 ? (0, import_react32.createElement)("div", { className: "bt-us-split", role: "separator" }) : null,+ bots.length > 0 && rest.length > 0 ? (0, import_react33.createElement)("div", { className: "bt-us-split", role: "separator" }) : null,rest.map((entry, index) => ownerRow(entry, bots.length + index))),- (0, import_react32.createElement)(ListCard, { title: t("Models"), count: usedModels.length, index: 3 }, usedModels.length > 0 ? usedModels.map(modelRow) : nothing)+ (0, import_react33.createElement)(ListCard, { title: t("Models"), count: usedModels.length, index: 3 }, usedModels.length > 0 ? usedModels.map(modelRow) : nothing)),- (0, import_react32.createElement)(Heat, { key: "heat", view, keep, paint: "var(--bt-accent)", index: 4 })+ (0, import_react33.createElement)(Heat, { key: "heat", view, keep, paint: "var(--bt-accent)", index: 4 }))];}- return (0, import_react32.createElement)(+ return (0, import_react33.createElement)("div",{ ref: root, className: "bt-us", key: focusId ?? "all" },- (0, import_react32.createElement)(+ (0, import_react33.createElement)("div",{ className: "bt-us-top" },- (0, import_react32.createElement)(Tabs, { label: t("Time range"), value: rangeId, onChange: chooseRange, options: rangeOptions, boxRef: tabs }),- view.scanning ? (0, import_react32.createElement)("span", { className: "bt-us-note", role: "status" }, t("Still reading older chats; totals may grow.")) : null,- picking ? (0, import_react32.createElement)(SpanPicker, { span, today, oldest, active: activeDays, near: tabs, onPick: pickSpan, onClose: () => setPicking(false) }) : null+ (0, import_react33.createElement)(Tabs, { label: t("Time range"), value: rangeId, onChange: chooseRange, options: rangeOptions, boxRef: tabs }),+ view.scanning ? (0, import_react33.createElement)("span", { className: "bt-us-note", role: "status" }, t("Still reading older chats; totals may grow.")) : null,+ picking ? (0, import_react33.createElement)(SpanPicker, { span, today, oldest, active: activeDays, near: tabs, onPick: pickSpan, onClose: () => setPicking(false) }) : null),- error ? (0, import_react32.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null,+ error ? (0, import_react33.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null,body);}@@ -14382,12 +14721,12 @@ button.bt-us-row:hover{background:var(--bt-hover)}`;// src/client/connectors.js-var import_react33 = require("react");+var import_react34 = require("react");var TOKEN_URL = "https://github.com/settings/personal-access-tokens/new";-var GitHubMark = () => (0, import_react33.createElement)(+var GitHubMark = () => (0, import_react34.createElement)("svg",{ width: 20, height: 20, viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": true },- (0, import_react33.createElement)("path", { d: "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" })+ (0, import_react34.createElement)("path", { d: "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" }));var MARKS = { github: GitHubMark };var ABOUT = { github: () => t("Repositories, issues, and pull requests") };@@ -14398,10 +14737,10 @@ function statusText2(connector) {return ABOUT[connector.id]?.() ?? "";}function ConnectorRow({ connector, actions }) {- const [form, setForm] = (0, import_react33.useState)(false);- const [token, setToken] = (0, import_react33.useState)("");- const [busy, setBusy] = (0, import_react33.useState)(false);- const [error, setError] = (0, import_react33.useState)(null);+ const [form, setForm] = (0, import_react34.useState)(false);+ const [token, setToken] = (0, import_react34.useState)("");+ const [busy, setBusy] = (0, import_react34.useState)(false);+ const [error, setError] = (0, import_react34.useState)(null);const run2 = (task, after) => {setBusy(true);setError(null);@@ -14418,58 +14757,58 @@ function ConnectorRow({ connector, actions }) {};const on = connector.state !== "off";const Mark = MARKS[connector.id];- const row = (0, import_react33.useRef)(null);+ const row = (0, import_react34.useRef)(null);useMorph(row, `${form}:${error !== null}:${connector.state}`);- return (0, import_react33.createElement)(+ return (0, import_react34.createElement)("div",{ ref: row, className: "bt-connector", "data-state": connector.state },- (0, import_react33.createElement)(+ (0, import_react34.createElement)("div",{ className: "bt-connector-head" },- (0, import_react33.createElement)("span", { className: "bt-connector-mark" }, Mark ? (0, import_react33.createElement)(Mark) : null),- (0, import_react33.createElement)(+ (0, import_react34.createElement)("span", { className: "bt-connector-mark" }, Mark ? (0, import_react34.createElement)(Mark) : null),+ (0, import_react34.createElement)("span",{ className: "bt-connector-text" },- (0, import_react33.createElement)("span", { className: "bt-connector-name" }, connector.name),- (0, import_react33.createElement)("span", { className: "bt-connector-status" }, statusText2(connector))+ (0, import_react34.createElement)("span", { className: "bt-connector-name" }, connector.name),+ (0, import_react34.createElement)("span", { className: "bt-connector-status" }, statusText2(connector))),- (0, import_react33.createElement)(+ (0, import_react34.createElement)("span",{ className: "bt-connector-actions" },- connector.state === "error" ? (0, import_react33.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy, onClick: () => void run2(actions.connectorRetry(connector.id)) }, t("Try again")) : null,- on ? (0, import_react33.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy, onClick: () => void run2(actions.connectorDisconnect(connector.id)) }, t("Disconnect")) : form ? null : (0, import_react33.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setForm(true) }, t("Connect"))+ connector.state === "error" ? (0, import_react34.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy, onClick: () => void run2(actions.connectorRetry(connector.id)) }, t("Try again")) : null,+ on ? (0, import_react34.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy, onClick: () => void run2(actions.connectorDisconnect(connector.id)) }, t("Disconnect")) : form ? null : (0, import_react34.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setForm(true) }, t("Connect")))),- !on && form ? (0, import_react33.createElement)(+ !on && form ? (0, import_react34.createElement)("div",{ className: "bt-connector-form" },- (0, import_react33.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react33.createElement)(MaskedInput, { value: token, onChange: setToken, onEnter: connect, label: t("GitHub token"), autoFocus: true })),- (0, import_react33.createElement)(+ (0, import_react34.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react34.createElement)(MaskedInput, { value: token, onChange: setToken, onEnter: connect, label: t("GitHub token"), autoFocus: true })),+ (0, import_react34.createElement)("div",{ className: "bt-connector-form-row" },- (0, import_react33.createElement)("a", { className: "bt-connector-link", href: TOKEN_URL, target: "_blank", rel: "noopener noreferrer" }, t("Create a token on GitHub")),- (0, import_react33.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy, onClick: () => {+ (0, import_react34.createElement)("a", { className: "bt-connector-link", href: TOKEN_URL, target: "_blank", rel: "noopener noreferrer" }, t("Create a token on GitHub")),+ (0, import_react34.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy, onClick: () => {setForm(false);setToken("");setError(null);} }, t("Cancel")),- (0, import_react33.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy || token.trim() === "", onClick: connect }, busy ? t("Connecting…") : t("Connect"))+ (0, import_react34.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy || token.trim() === "", onClick: connect }, busy ? t("Connecting…") : t("Connect")))) : null,- error ? (0, import_react33.createElement)("div", { className: "bt-connector-error", role: "alert" }, error) : null+ error ? (0, import_react34.createElement)("div", { className: "bt-connector-error", role: "alert" }, error) : null);}function ConnectorsPage({ roster, actions }) {const list = roster?.connectors ?? [];- return (0, import_react33.createElement)(+ return (0, import_react34.createElement)("section",{ className: "bt-set-section" },- (0, import_react33.createElement)("div", { className: "bt-set-card bt-connectors-card" }, list.length === 0 ? (0, import_react33.createElement)("div", { className: "bt-set-row" }, (0, import_react33.createElement)("span", { className: "bt-set-hint" }, t("No connectors"))) : list.map((connector) => (0, import_react33.createElement)(ConnectorRow, { key: connector.id, connector, actions })))+ (0, import_react34.createElement)("div", { className: "bt-set-card bt-connectors-card" }, list.length === 0 ? (0, import_react34.createElement)("div", { className: "bt-set-row" }, (0, import_react34.createElement)("span", { className: "bt-set-hint" }, t("No connectors"))) : list.map((connector) => (0, import_react34.createElement)(ConnectorRow, { key: connector.id, connector, actions }))));}// src/client/browser-settings.js-var import_react34 = require("react");+var import_react35 = require("react");var ACTIONS = [["post", "Post"], ["upload", "Upload"], ["download", "Download"], ["delete", "Delete"]];var DURATIONS = [["hour", "1 hour"], ["today", "Today"], ["week", "7 days"], ["permanent", "Permanent"]];var expired = (grant) => Number.isFinite(grant.until) && grant.until <= Date.now();@@ -14488,13 +14827,13 @@ function grantKinds(grant) {}function BrowserPage({ roster, actions, run: run2, Section, Row: Row3 }) {const bots = roster.bots ?? [];- const [botId, setBotId] = (0, import_react34.useState)(bots[0]?.id ?? "");- const [site, setSite] = (0, import_react34.useState)("");- const [kinds, setKinds] = (0, import_react34.useState)(["post"]);- const [duration, setDuration] = (0, import_react34.useState)("hour");- const [busy, setBusy] = (0, import_react34.useState)(false);+ const [botId, setBotId] = (0, import_react35.useState)(bots[0]?.id ?? "");+ const [site, setSite] = (0, import_react35.useState)("");+ const [kinds, setKinds] = (0, import_react35.useState)(["post"]);+ const [duration, setDuration] = (0, import_react35.useState)("hour");+ const [busy, setBusy] = (0, import_react35.useState)(false);const selectedBot = bots.find((bot) => bot.id === botId);- (0, import_react34.useEffect)(() => {+ (0, import_react35.useEffect)(() => {if (!bots.some((bot) => bot.id === botId)) setBotId(bots[0]?.id ?? "");}, [bots, botId]);const grants = bots.flatMap((bot) => (bot.browserGrants ?? []).map((grant, index) => ({@@ -14527,37 +14866,37 @@ function BrowserPage({ roster, actions, run: run2, Section, Row: Row3 }) {const toggleKind = (kind, checked) => {setKinds((current) => checked ? current.includes(kind) ? current : [...current, kind] : current.filter((value) => value !== kind));};- return (0, import_react34.createElement)(+ return (0, import_react35.createElement)("div",{ className: "bt-browser-settings" },- (0, import_react34.createElement)(+ (0, import_react35.createElement)(Section,{ title: t("Browser access") },- (0, import_react34.createElement)("p", { className: "bt-browser-note" }, t("Bots browse, click and fill in forms freely. Posting, uploading, downloading and deleting ask you first unless you allow them here. Payments are always yours: the Bot hands the page to you."))+ (0, import_react35.createElement)("p", { className: "bt-browser-note" }, t("Bots browse, click and fill in forms freely. Posting, uploading, downloading and deleting ask you first unless you allow them here. Payments are always yours: the Bot hands the page to you."))),- (0, import_react34.createElement)(+ (0, import_react35.createElement)(Section,{ title: t("Allowed actions") },- grants.length === 0 ? (0, import_react34.createElement)(Row3, { label: t("Nothing allowed yet.") }) : grants.map(({ bot, grant, index, expired: expired2 }) => (0, import_react34.createElement)(+ grants.length === 0 ? (0, import_react35.createElement)(Row3, { label: t("Nothing allowed yet.") }) : grants.map(({ bot, grant, index, expired: expired2 }) => (0, import_react35.createElement)("div",{key: `${bot.id}:${index}`,className: `bt-browser-grant${expired2 ? " bt-browser-grant-expired" : ""}`},- (0, import_react34.createElement)(+ (0, import_react35.createElement)("div",{ className: "bt-browser-grant-who" },- (0, import_react34.createElement)(BotAvatar, { bot, size: 28 }),- (0, import_react34.createElement)("span", null, bot.name)+ (0, import_react35.createElement)(BotAvatar, { bot, size: 28 }),+ (0, import_react35.createElement)("span", null, bot.name)),- (0, import_react34.createElement)(+ (0, import_react35.createElement)("div",{ className: "bt-browser-grant-meta" },- (0, import_react34.createElement)("span", { className: "bt-browser-grant-site" }, grant.site === "*" ? t("All sites") : grant.site),- (0, import_react34.createElement)("div", { className: "bt-browser-grant-kinds" }, grantKinds(grant).map((label) => (0, import_react34.createElement)("span", { key: label, className: "bt-chip" }, label))),- (0, import_react34.createElement)("span", { className: "bt-set-hint" }, grantTime(grant))+ (0, import_react35.createElement)("span", { className: "bt-browser-grant-site" }, grant.site === "*" ? t("All sites") : grant.site),+ (0, import_react35.createElement)("div", { className: "bt-browser-grant-kinds" }, grantKinds(grant).map((label) => (0, import_react35.createElement)("span", { key: label, className: "bt-chip" }, label))),+ (0, import_react35.createElement)("span", { className: "bt-set-hint" }, grantTime(grant))),- (0, import_react34.createElement)("button", {+ (0, import_react35.createElement)("button", {type: "button",className: "bt-soft bt-soft-sm",onClick: () => remove(bot, index),@@ -14565,25 +14904,25 @@ function BrowserPage({ roster, actions, run: run2, Section, Row: Row3 }) {}, t("Remove grant"))))),- (0, import_react34.createElement)(+ (0, import_react35.createElement)(Section,{ title: t("Allow an action") },- (0, import_react34.createElement)(+ (0, import_react35.createElement)("form",{ className: "bt-browser-form", onSubmit: add },- (0, import_react34.createElement)(+ (0, import_react35.createElement)(Row3,{ label: t("Bot") },- (0, import_react34.createElement)(+ (0, import_react35.createElement)("select",{ className: "bt-select", value: botId, onChange: (event) => setBotId(event.target.value), disabled: bots.length === 0 },- bots.map((bot) => (0, import_react34.createElement)("option", { key: bot.id, value: bot.id }, bot.name))+ bots.map((bot) => (0, import_react35.createElement)("option", { key: bot.id, value: bot.id }, bot.name)))),- (0, import_react34.createElement)(+ (0, import_react35.createElement)(Row3,{ label: t("Site") },- (0, import_react34.createElement)("input", {+ (0, import_react35.createElement)("input", {className: "bt-select bt-browser-site",type: "text",value: site,@@ -14591,16 +14930,16 @@ function BrowserPage({ roster, actions, run: run2, Section, Row: Row3 }) {onChange: (event) => setSite(event.target.value)})),- (0, import_react34.createElement)(+ (0, import_react35.createElement)(Row3,{ label: t("Actions") },- (0, import_react34.createElement)(+ (0, import_react35.createElement)("div",{ className: "bt-browser-action-list" },- ACTIONS.map(([kind, label]) => (0, import_react34.createElement)(+ ACTIONS.map(([kind, label]) => (0, import_react35.createElement)("label",{ key: kind, className: "bt-browser-action-choice" },- (0, import_react34.createElement)("input", {+ (0, import_react35.createElement)("input", {type: "checkbox",checked: kinds.includes(kind),onChange: (event) => toggleKind(kind, event.target.checked)@@ -14609,13 +14948,13 @@ function BrowserPage({ roster, actions, run: run2, Section, Row: Row3 }) {)))),- (0, import_react34.createElement)(+ (0, import_react35.createElement)(Row3,{ label: t("Duration") },- (0, import_react34.createElement)(+ (0, import_react35.createElement)("div",{ className: "bt-browser-duration", role: "group", "aria-label": t("Duration") },- DURATIONS.map(([key, label]) => (0, import_react34.createElement)("button", {+ DURATIONS.map(([key, label]) => (0, import_react35.createElement)("button", {key,type: "button",className: "bt-browser-duration-choice",@@ -14624,10 +14963,10 @@ function BrowserPage({ roster, actions, run: run2, Section, Row: Row3 }) {}, t(label))))),- (0, import_react34.createElement)(+ (0, import_react35.createElement)("div",{ className: "bt-browser-form-foot" },- (0, import_react34.createElement)("button", {+ (0, import_react35.createElement)("button", {type: "submit",className: "bt-soft",disabled: busy || !selectedBot || kinds.length === 0@@ -14639,12 +14978,12 @@ function BrowserPage({ roster, actions, run: run2, Section, Row: Row3 }) {}// src/client/feedback.js-var import_react35 = require("react");-var FeedbackIcon = () => (0, import_react35.createElement)(+var import_react36 = require("react");+var FeedbackIcon = () => (0, import_react36.createElement)("svg",{ width: 15, height: 15, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },- (0, import_react35.createElement)("path", { d: "M4 4.5h12a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H9l-3.5 3v-3H4a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1z" }),- (0, import_react35.createElement)("path", { d: "M10 7v2.6M10 11.4h.01" })+ (0, import_react36.createElement)("path", { d: "M4 4.5h12a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H9l-3.5 3v-3H4a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1z" }),+ (0, import_react36.createElement)("path", { d: "M10 7v2.6M10 11.4h.01" }));function download(name, text) {const url = URL.createObjectURL(new Blob([text], { type: "text/plain;charset=utf-8" }));@@ -14682,16 +15021,16 @@ function issueWindow() {};}function FeedbackPage({ actions, run: run2, Section, Row: Row3 }) {- const [what, setWhat] = (0, import_react35.useState)("");- const [report, setReport] = (0, import_react35.useState)(null);- const [preview, setPreview] = (0, import_react35.useState)(false);- const [note, setNote] = (0, import_react35.useState)("");+ const [what, setWhat] = (0, import_react36.useState)("");+ const [report, setReport] = (0, import_react36.useState)(null);+ const [preview, setPreview] = (0, import_react36.useState)(false);+ const [note, setNote] = (0, import_react36.useState)("");const fetchReport = () => actions.diagnostics({ client: clientFacts(), clientErrors: clientErrors() }).then((next) => {setReport(next);return next;});const load = () => fetchReport().then(() => void 0);- (0, import_react35.useEffect)(() => {+ (0, import_react36.useEffect)(() => {void run2(load());}, []);const copyReport = () => run2(fetchReport().then(async (next) => {@@ -14699,7 +15038,7 @@ function FeedbackPage({ actions, run: run2, Section, Row: Row3 }) {setNote(copied ? t("Copied the diagnostics.") : t("Could not copy. Select the text below and copy it."));if (!copied) setPreview(true);}));- const [issueLink, setIssueLink] = (0, import_react35.useState)(null);+ const [issueLink, setIssueLink] = (0, import_react36.useState)(null);const openIssue = () => {const target = issueWindow();run2(fetchReport().then(async (next) => {@@ -14725,59 +15064,59 @@ function FeedbackPage({ actions, run: run2, Section, Row: Row3 }) {const total = (report?.total ?? 0) + browserErrors.length;const shown = entries2.slice(0, 8);return [- (0, import_react35.createElement)(+ (0, import_react36.createElement)(Section,{ key: "report", title: t("Report a problem") },- (0, import_react35.createElement)(+ (0, import_react36.createElement)("div",{ className: "bt-set-row bt-set-paste bt-fb-what" },- (0, import_react35.createElement)(+ (0, import_react36.createElement)("label",{ className: "bt-set-copy", htmlFor: "bt-fb-what" },- (0, import_react35.createElement)("span", null, t("What happened?")),- (0, import_react35.createElement)("span", { className: "bt-set-hint" }, t("What you did, what you expected, and what happened instead. It goes into the issue."))+ (0, import_react36.createElement)("span", null, t("What happened?")),+ (0, import_react36.createElement)("span", { className: "bt-set-hint" }, t("What you did, what you expected, and what happened instead. It goes into the issue."))),- (0, import_react35.createElement)("textarea", { id: "bt-fb-what", className: "bt-input bt-input-area", value: what, maxLength: WHAT_MAX, placeholder: t("For example: I asked Writer in the group chat and it showed an error."), onChange: (event) => setWhat(event.target.value) })+ (0, import_react36.createElement)("textarea", { id: "bt-fb-what", className: "bt-input bt-input-area", value: what, maxLength: WHAT_MAX, placeholder: t("For example: I asked Writer in the group chat and it showed an error."), onChange: (event) => setWhat(event.target.value) })),- (0, import_react35.createElement)(+ (0, import_react36.createElement)(Row3,{ label: t("Diagnostics"), hint: t("Versions, system, models, and the latest errors. Saved keys, tokens, and your home folder are hidden.") },- (0, import_react35.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setPreview(!preview), "aria-expanded": preview }, preview ? t("Hide") : t("Show")),- (0, import_react35.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: copyReport }, t("Copy"))+ (0, import_react36.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setPreview(!preview), "aria-expanded": preview }, preview ? t("Hide") : t("Show")),+ (0, import_react36.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: copyReport }, t("Copy"))),- preview ? (0, import_react35.createElement)("div", { className: "bt-set-row bt-fb-preview" }, (0, import_react35.createElement)("pre", { tabIndex: 0, "aria-label": t("Diagnostics") }, report?.markdown || t("Loading…"))) : null,- (0, import_react35.createElement)(+ preview ? (0, import_react36.createElement)("div", { className: "bt-set-row bt-fb-preview" }, (0, import_react36.createElement)("pre", { tabIndex: 0, "aria-label": t("Diagnostics") }, report?.markdown || t("Loading…"))) : null,+ (0, import_react36.createElement)(Row3,{ label: t("GitHub issue"), hint: t("Opens a new issue in the DS Bot repository with all of this filled in. Nothing is sent until you submit it there.") },- (0, import_react35.createElement)("button", { type: "button", className: "bt-fb-primary", onClick: openIssue }, t("Report on GitHub"))+ (0, import_react36.createElement)("button", { type: "button", className: "bt-fb-primary", onClick: openIssue }, t("Report on GitHub")))),- note ? (0, import_react35.createElement)(+ note ? (0, import_react36.createElement)("div",{ key: "note", className: "bt-note bt-fb-note", role: "status" },note,- issueLink ? [" ", (0, import_react35.createElement)("a", { key: "link", href: issueLink, target: "_blank", rel: "noopener noreferrer" }, t("Open the issue"))] : null+ issueLink ? [" ", (0, import_react36.createElement)("a", { key: "link", href: issueLink, target: "_blank", rel: "noopener noreferrer" }, t("Open the issue"))] : null) : null,- (0, import_react35.createElement)(+ (0, import_react36.createElement)(Section,{ key: "errors", title: report ? t("Recent errors · {count}", { count: total }) : t("Recent errors") },- shown.length === 0 ? (0, import_react35.createElement)(Row3, { label: t("No errors recorded."), hint: t("Failed model calls and DS Bot problems show here, newest first.") }) : shown.map((entry, index) => (0, import_react35.createElement)(+ shown.length === 0 ? (0, import_react36.createElement)(Row3, { label: t("No errors recorded."), hint: t("Failed model calls and DS Bot problems show here, newest first.") }) : shown.map((entry, index) => (0, import_react36.createElement)("div",{ key: `${entry.time}-${index}`, className: "bt-set-row bt-fb-entry", title: entry.text },- (0, import_react35.createElement)("span", { className: "bt-fb-dot", "data-level": entry.level, "aria-hidden": true }),- (0, import_react35.createElement)(+ (0, import_react36.createElement)("span", { className: "bt-fb-dot", "data-level": entry.level, "aria-hidden": true }),+ (0, import_react36.createElement)("div",{ className: "bt-set-copy" },- (0, import_react35.createElement)("span", { className: "bt-fb-text" }, entrySummary(entry)),- (0, import_react35.createElement)("span", { className: "bt-set-hint" }, [whenText(entry.time), entry.bot, entry.where, t(SOURCES[entry.source] ?? "DS Bot")].filter(Boolean).join(" · "))+ (0, import_react36.createElement)("span", { className: "bt-fb-text" }, entrySummary(entry)),+ (0, import_react36.createElement)("span", { className: "bt-set-hint" }, [whenText(entry.time), entry.bot, entry.where, t(SOURCES[entry.source] ?? "DS Bot")].filter(Boolean).join(" · "))),- entry.code ? (0, import_react35.createElement)("span", { className: "bt-tag bt-fb-code" }, entry.status ? `${entry.code} ${entry.status}` : entry.code) : null+ entry.code ? (0, import_react36.createElement)("span", { className: "bt-tag bt-fb-code" }, entry.status ? `${entry.code} ${entry.status}` : entry.code) : null)),- (0, import_react35.createElement)(+ (0, import_react36.createElement)(Row3,{ label: t("Error log"), hint: t("Kept on this computer across restarts, up to about 1 MB.") },- (0, import_react35.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: downloadLog }, t("Download")),- (0, import_react35.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: clearLog, disabled: !report || total === 0 }, t("Clear"))+ (0, import_react36.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: downloadLog }, t("Download")),+ (0, import_react36.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: clearLog, disabled: !report || total === 0 }, t("Clear"))))];@@ -14785,8 +15124,8 @@ function FeedbackPage({ actions, run: run2, Section, Row: Row3 }) {var TOAST_MS = 6e3;function ErrorToast({ useUi, actions }) {const toast = useUi((state) => state.toast);- const [leaving, setLeaving] = (0, import_react35.useState)(false);- (0, import_react35.useEffect)(() => {+ const [leaving, setLeaving] = (0, import_react36.useState)(false);+ (0, import_react36.useEffect)(() => {if (!toast) return void 0;setLeaving(false);const fade = setTimeout(() => setLeaving(true), TOAST_MS);@@ -14797,15 +15136,15 @@ function ErrorToast({ useUi, actions }) {};}, [toast?.token]);if (!toast) return null;- return (0, import_react35.createElement)(+ return (0, import_react36.createElement)("div",{ className: "bt-toast", role: "alert", "data-leaving": leaving || void 0 },- (0, import_react35.createElement)("span", { className: "bt-toast-text" }, toast.text),- (0, import_react35.createElement)("button", { type: "button", className: "bt-toast-link", onClick: () => {+ (0, import_react36.createElement)("span", { className: "bt-toast-text" }, toast.text),+ (0, import_react36.createElement)("button", { type: "button", className: "bt-toast-link", onClick: () => {actions.dismissToast(toast.token);actions.openSettings("feedback");} }, t("Details")),- (0, import_react35.createElement)("button", { type: "button", className: "bt-icon-btn bt-toast-close", "aria-label": t("Dismiss"), onClick: () => actions.dismissToast(toast.token) }, (0, import_react35.createElement)(CloseIcon))+ (0, import_react36.createElement)("button", { type: "button", className: "bt-icon-btn bt-toast-close", "aria-label": t("Dismiss"), onClick: () => actions.dismissToast(toast.token) }, (0, import_react36.createElement)(CloseIcon)));}var FEEDBACK_CSS = `@@ -14837,7 +15176,7 @@ var FEEDBACK_CSS = ``;// src/client/about.js-var import_react36 = require("react");+var import_react37 = require("react");var CHEER_MS = 1800;var starCount = (count) => new Intl.NumberFormat(dateLocale(), { notation: "compact", maximumFractionDigits: 1 }).format(count);function botHint(update) {@@ -14885,9 +15224,9 @@ function dshHint(dsh, shown) {var linkProps = (href) => ({ className: "bt-soft bt-soft-sm bt-about-link", href, target: "_blank", rel: "noopener noreferrer" });function AboutPage({ useUpdate, actions, run: run2, Section, Row: Row3 }) {const update = useUpdate((value) => value) ?? {};- const [checking, setChecking] = (0, import_react36.useState)(false);- const [stars, setStars] = (0, import_react36.useState)(null);- (0, import_react36.useEffect)(() => {+ const [checking, setChecking] = (0, import_react37.useState)(false);+ const [stars, setStars] = (0, import_react37.useState)(null);+ (0, import_react37.useEffect)(() => {let live = true;actions.repoStars().then((count) => {if (live && Number.isInteger(count)) setStars(count);@@ -14897,8 +15236,8 @@ function AboutPage({ useUpdate, actions, run: run2, Section, Row: Row3 }) {live = false;};}, []);- const [cheer, setCheer] = (0, import_react36.useState)(true);- (0, import_react36.useEffect)(() => {+ const [cheer, setCheer] = (0, import_react37.useState)(true);+ (0, import_react37.useEffect)(() => {if (!cheer) return void 0;const timer = setTimeout(() => setCheer(false), CHEER_MS);return () => clearTimeout(timer);@@ -14913,37 +15252,37 @@ function AboutPage({ useUpdate, actions, run: run2, Section, Row: Row3 }) {const phase = update.phase ?? "idle";const dsh = update.dsh;const dshPhase = dsh?.phase ?? "idle";- (0, import_react36.useEffect)(() => {+ (0, import_react37.useEffect)(() => {if (phase === "installed" || phase === "updated" || dshPhase === "installed") setCheer(true);}, [phase, dshPhase]);const markState = checking ? "searching" : phase === "installing" || dshPhase === "installing" ? "working" : cheer ? "done" : "idle";const dshNew = showsDshRow(dsh, update.app);const dshShown = dshNew && dsh.available;const ownRow = update.source === "app" ? ownAppRow(update.ownApp) : null;- const ownControl = ownRow?.button === "restart" ? (0, import_react36.createElement)("button", { type: "button", className: "bt-fb-primary", onClick: () => run2(actions.installOwnApp()) }, t("Restart to update")) : ownRow?.button === "check" ? (0, import_react36.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.checkOwnApp()) }, t("Check for updates")) : ownRow?.button === "open" ? (0, import_react36.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.openOwnApp()) }, t("Download")) : null;- const botControl = ownRow !== null ? ownControl : phase === "installed" || phase === "updated" || update.source === "app" ? null : update.available || phase === "installing" ? (0, import_react36.createElement)(+ const ownControl = ownRow?.button === "restart" ? (0, import_react37.createElement)("button", { type: "button", className: "bt-fb-primary", onClick: () => run2(actions.installOwnApp()) }, t("Restart to update")) : ownRow?.button === "check" ? (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.checkOwnApp()) }, t("Check for updates")) : ownRow?.button === "open" ? (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.openOwnApp()) }, t("Download")) : null;+ const botControl = ownRow !== null ? ownControl : phase === "installed" || phase === "updated" || update.source === "app" ? null : update.available || phase === "installing" ? (0, import_react37.createElement)("button",{ type: "button", className: "bt-fb-primary", disabled: phase === "installing", onClick: () => run2(actions.installUpdate()) },phase === "installing" ? t("Updating…") : phase === "failed" ? t("Try again") : t("Update")- ) : (0, import_react36.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: checking || update.enabled === false, onClick: check }, checking ? t("Checking…") : t("Check for updates"));- const dshControl = !dshNew || dshPhase === "installed" ? null : dsh.kind === "app" ? dsh.available ? (0, import_react36.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.openAppUpdates(dsh.verified)) }, t("Open updates")) : null : dsh.available || dshPhase !== "idle" ? (0, import_react36.createElement)(+ ) : (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: checking || update.enabled === false, onClick: check }, checking ? t("Checking…") : t("Check for updates"));+ const dshControl = !dshNew || dshPhase === "installed" ? null : dsh.kind === "app" ? dsh.available ? (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.openAppUpdates(dsh.verified)) }, t("Open updates")) : null : dsh.available || dshPhase !== "idle" ? (0, import_react37.createElement)("button",{ type: "button", className: "bt-fb-primary", disabled: dshPhase === "installing", onClick: () => run2(actions.installDshUpdate()) },dshPhase === "installing" ? t("Updating…") : dshPhase === "failed" ? t("Try again") : t("Update")) : null;const repo = update.repoUrl;return [- (0, import_react36.createElement)(+ (0, import_react37.createElement)("div",{ key: "hero", className: "bt-about-hero" },- (0, import_react36.createElement)("span", { className: "bt-about-mark" }, (0, import_react36.createElement)(BotMark, { look: MAIN_LOOK, bot: { id: "about" }, size: 52, state: markState, live: true, gaze: true, pokeable: true })),- (0, import_react36.createElement)(+ (0, import_react37.createElement)("span", { className: "bt-about-mark" }, (0, import_react37.createElement)(BotMark, { look: MAIN_LOOK, bot: { id: "about" }, size: 52, state: markState, live: true, gaze: true, pokeable: true })),+ (0, import_react37.createElement)("div",{ className: "bt-about-copy" },- (0, import_react36.createElement)("span", { className: "bt-about-name" }, "DS Bot"),- update.current ? (0, import_react36.createElement)("span", { className: "bt-about-version" }, t("Version {version}", { version: update.current })) : null+ (0, import_react37.createElement)("span", { className: "bt-about-name" }, "DS Bot"),+ update.current ? (0, import_react37.createElement)("span", { className: "bt-about-version" }, t("Version {version}", { version: update.current })) : null),- repo ? (0, import_react36.createElement)(+ repo ? (0, import_react37.createElement)("a",{className: "bt-star",@@ -14953,23 +15292,23 @@ function AboutPage({ useUpdate, actions, run: run2, Section, Row: Row3 }) {title: t("Star DS Bot on GitHub"),"aria-label": stars === null ? t("Star DS Bot on GitHub") : `${t("Star DS Bot on GitHub")} · ${t("{count} stars", { count: stars })}`},- (0, import_react36.createElement)("span", { className: "bt-star-main" }, (0, import_react36.createElement)("span", { className: "bt-star-icon" }, (0, import_react36.createElement)(StarLineIcon)), "Star"),- stars === null ? null : (0, import_react36.createElement)("span", { className: "bt-star-count" }, starCount(stars))+ (0, import_react37.createElement)("span", { className: "bt-star-main" }, (0, import_react37.createElement)("span", { className: "bt-star-icon" }, (0, import_react37.createElement)(StarLineIcon)), "Star"),+ stars === null ? null : (0, import_react37.createElement)("span", { className: "bt-star-count" }, starCount(stars))) : null),- repo ? (0, import_react36.createElement)("p", { key: "ask", className: "bt-about-ask" }, t("If DS Bot helps you, a star on GitHub helps more people find it.")) : null,- (0, import_react36.createElement)(+ repo ? (0, import_react37.createElement)("p", { key: "ask", className: "bt-about-ask" }, t("If DS Bot helps you, a star on GitHub helps more people find it.")) : null,+ (0, import_react37.createElement)(Section,{ key: "updates", title: t("Updates") },- (0, import_react36.createElement)(Row3, { label: "DS Bot", hint: ownRow?.hint ?? botHint(update) }, botControl, update.available && update.notesUrl ? (0, import_react36.createElement)("a", linkProps(update.notesUrl), t("What's new")) : null),- dsh?.current ? (0, import_react36.createElement)(Row3, { label: "DeepSeek Harness", hint: dshHint(dsh, dshShown) }, dshControl) : null+ (0, import_react37.createElement)(Row3, { label: "DS Bot", hint: ownRow?.hint ?? botHint(update) }, botControl, update.available && update.notesUrl ? (0, import_react37.createElement)("a", linkProps(update.notesUrl), t("What's new")) : null),+ dsh?.current ? (0, import_react37.createElement)(Row3, { label: "DeepSeek Harness", hint: dshHint(dsh, dshShown) }, dshControl) : null),- (0, import_react36.createElement)(+ (0, import_react37.createElement)(Section,{ key: "links", title: t("Links") },- repo ? (0, import_react36.createElement)(Row3, { label: t("Source code"), hint: repo.replace(/^https:\/\//, "") }, (0, import_react36.createElement)("a", linkProps(repo), (0, import_react36.createElement)(GitHubMark), t("Open"))) : null,- update.notesUrl ? (0, import_react36.createElement)(Row3, { label: t("Release notes") }, (0, import_react36.createElement)("a", linkProps(update.notesUrl), t("Open"))) : null,- (0, import_react36.createElement)(Row3, { label: t("Report a problem") }, (0, import_react36.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.openSettings("feedback") }, t("Open")))+ repo ? (0, import_react37.createElement)(Row3, { label: t("Source code"), hint: repo.replace(/^https:\/\//, "") }, (0, import_react37.createElement)("a", linkProps(repo), (0, import_react37.createElement)(GitHubMark), t("Open"))) : null,+ update.notesUrl ? (0, import_react37.createElement)(Row3, { label: t("Release notes") }, (0, import_react37.createElement)("a", linkProps(update.notesUrl), t("Open"))) : null,+ (0, import_react37.createElement)(Row3, { label: t("Report a problem") }, (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.openSettings("feedback") }, t("Open"))))];}@@ -15002,7 +15341,7 @@ body:not([data-bt-motion=quiet]) .bt-about-mark:hover .bt-mark[data-live][data-s`;// src/client/providers-page.js-var import_react37 = require("react");+var import_react38 = require("react");var PROTOCOL_NAMES = { "openai-completions": "OpenAI Chat Completions", "openai-responses": "OpenAI Responses", "anthropic-messages": "Anthropic Messages" };var ENDPOINT_HINTS = { "anthropic-messages": "https://gateway.example" };var SHOWN_MODELS = 8;@@ -15010,22 +15349,22 @@ var translated = (promise) => Promise.resolve(promise).catch((failure) => {throw new Error(hostText(failure?.message ?? String(failure)));});function ProvidersPage({ actions, run: run2, Section }) {- const [view, setView] = (0, import_react37.useState)(null);- const [open, setOpen] = (0, import_react37.useState)(null);- const [adding, setAdding] = (0, import_react37.useState)(false);+ const [view, setView] = (0, import_react38.useState)(null);+ const [open, setOpen] = (0, import_react38.useState)(null);+ const [adding, setAdding] = (0, import_react38.useState)(false);const apply2 = (promise) => run2(translated(promise).then((next) => {if (next?.providers) setView(next);}));- (0, import_react37.useEffect)(() => {+ (0, import_react38.useEffect)(() => {void apply2(actions.providers());}, []);if (view === null) return null;- if (!view.available) return (0, import_react37.createElement)("p", { className: "bt-set-hint" }, t("This DSH cannot set up model providers."));+ if (!view.available) return (0, import_react38.createElement)("p", { className: "bt-set-hint" }, t("This DSH cannot set up model providers."));return [- (0, import_react37.createElement)(+ (0, import_react38.createElement)(Section,{ key: "list", title: t("Model providers · {count}", { count: view.providers.length }) },- view.providers.map((provider) => (0, import_react37.createElement)(ProviderRow, {+ view.providers.map((provider) => (0, import_react38.createElement)(ProviderRow, {key: provider.id,provider,apply: apply2,@@ -15033,9 +15372,9 @@ function ProvidersPage({ actions, run: run2, Section }) {open: open === provider.id,onToggle: () => setOpen(open === provider.id ? null : provider.id)})),- adding ? (0, import_react37.createElement)(AddProvider, { key: "add", view, apply: apply2, actions, onDone: () => setAdding(false) }) : null+ adding ? (0, import_react38.createElement)(AddProvider, { key: "add", view, apply: apply2, actions, onDone: () => setAdding(false) }) : null),- adding ? null : (0, import_react37.createElement)("div", { key: "add", className: "bt-actions" }, (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setAdding(true) }, t("Add a provider")))+ adding ? null : (0, import_react38.createElement)("div", { key: "add", className: "bt-actions" }, (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setAdding(true) }, t("Add a provider")))];}function keyState(key) {@@ -15044,58 +15383,58 @@ function keyState(key) {return key.writable ? ["set", t("Key set")] : ["outside", t("Key set outside DS Bot")];}function ProviderRow({ provider, apply: apply2, actions, open, onToggle }) {- const [confirm, setConfirm] = (0, import_react37.useState)(false);- (0, import_react37.useEffect)(() => {+ const [confirm, setConfirm] = (0, import_react38.useState)(false);+ (0, import_react38.useEffect)(() => {if (!open) setConfirm(false);}, [open]);const state = keyState(provider.key);const shown = provider.models.slice(0, SHOWN_MODELS);const hint = provider.error ?? (provider.models.length === 0 ? t("No models") : t("{count} models", { count: provider.models.length }));- return (0, import_react37.createElement)(+ return (0, import_react38.createElement)("div",{ className: "bt-secret-item bt-provider", "data-open": open ? "" : void 0 },- (0, import_react37.createElement)(+ (0, import_react38.createElement)("button",{ type: "button", className: "bt-set-row bt-secret-summary", "aria-expanded": open, onClick: onToggle },- (0, import_react37.createElement)(+ (0, import_react38.createElement)("span",{ className: "bt-set-copy" },- (0, import_react37.createElement)("span", { className: "bt-secret-title" }, provider.name, provider.name !== provider.id ? (0, import_react37.createElement)("span", { className: "bt-provider-id" }, provider.id) : null),- (0, import_react37.createElement)("span", { className: "bt-set-hint", "data-error": provider.error ? "" : void 0 }, hint)+ (0, import_react38.createElement)("span", { className: "bt-secret-title" }, provider.name, provider.name !== provider.id ? (0, import_react38.createElement)("span", { className: "bt-provider-id" }, provider.id) : null),+ (0, import_react38.createElement)("span", { className: "bt-set-hint", "data-error": provider.error ? "" : void 0 }, hint)),- state ? (0, import_react37.createElement)("span", { className: "bt-set-control" }, (0, import_react37.createElement)("span", { className: "bt-provider-state", "data-state": state[0] }, state[1])) : null+ state ? (0, import_react38.createElement)("span", { className: "bt-set-control" }, (0, import_react38.createElement)("span", { className: "bt-provider-state", "data-state": state[0] }, state[1])) : null),- open ? (0, import_react37.createElement)(+ open ? (0, import_react38.createElement)("div",{ className: "bt-secret-edit" },- provider.key?.writable ? (0, import_react37.createElement)(KeyEditor, { provider, apply: apply2, actions }) : null,- provider.key && !provider.key.writable ? (0, import_react37.createElement)("div", { className: "bt-set-hint" }, t("This key comes from outside DS Bot, such as an environment variable, and cannot be changed here.")) : null,- provider.models.length > 0 ? (0, import_react37.createElement)(+ provider.key?.writable ? (0, import_react38.createElement)(KeyEditor, { provider, apply: apply2, actions }) : null,+ provider.key && !provider.key.writable ? (0, import_react38.createElement)("div", { className: "bt-set-hint" }, t("This key comes from outside DS Bot, such as an environment variable, and cannot be changed here.")) : null,+ provider.models.length > 0 ? (0, import_react38.createElement)("div",{ className: "bt-secret-edit-block" },- (0, import_react37.createElement)("div", { className: "bt-secret-edit-label" }, t("Models")),- (0, import_react37.createElement)(+ (0, import_react38.createElement)("div", { className: "bt-secret-edit-label" }, t("Models")),+ (0, import_react38.createElement)("div",{ className: "bt-provider-models" },- shown.map((model) => (0, import_react37.createElement)("span", { key: model.ref, className: "bt-tag", title: model.ref }, model.name)),- provider.models.length > shown.length ? (0, import_react37.createElement)("span", { className: "bt-set-hint" }, t("and {count} more", { count: provider.models.length - shown.length })) : null+ shown.map((model) => (0, import_react38.createElement)("span", { key: model.ref, className: "bt-tag", title: model.ref }, model.name)),+ provider.models.length > shown.length ? (0, import_react38.createElement)("span", { className: "bt-set-hint" }, t("and {count} more", { count: provider.models.length - shown.length })) : null)) : null,- provider.removable ? (0, import_react37.createElement)(+ provider.removable ? (0, import_react38.createElement)("div",{ className: "bt-secret-row-actions" },confirm ? [- (0, import_react37.createElement)("span", { key: "q", className: "bt-set-hint" }, t("Remove {name}? Bots on its models need another model.", { name: provider.name })),- (0, import_react37.createElement)("button", { key: "no", type: "button", className: "bt-soft bt-soft-sm", onClick: () => setConfirm(false) }, t("Keep")),- (0, import_react37.createElement)("button", { key: "yes", type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => apply2(actions.removeProvider(provider.id)) }, t("Remove"))- ] : (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => setConfirm(true) }, (0, import_react37.createElement)(TrashIcon), t("Remove provider"))+ (0, import_react38.createElement)("span", { key: "q", className: "bt-set-hint" }, t("Remove {name}? Bots on its models need another model.", { name: provider.name })),+ (0, import_react38.createElement)("button", { key: "no", type: "button", className: "bt-soft bt-soft-sm", onClick: () => setConfirm(false) }, t("Keep")),+ (0, import_react38.createElement)("button", { key: "yes", type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => apply2(actions.removeProvider(provider.id)) }, t("Remove"))+ ] : (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => setConfirm(true) }, (0, import_react38.createElement)(TrashIcon), t("Remove provider"))) : null) : null);}function KeyEditor({ provider, apply: apply2, actions }) {- const [value, setValue] = (0, import_react37.useState)("");- const [saved, setSaved] = (0, import_react37.useState)(false);+ const [value, setValue] = (0, import_react38.useState)("");+ const [saved, setSaved] = (0, import_react38.useState)(false);const ready = value.trim() !== "";const save = () => {if (!ready) return;@@ -15111,29 +15450,29 @@ function KeyEditor({ provider, apply: apply2, actions }) {setSaved(false);};const label = t("{provider} API key", { provider: provider.name });- return (0, import_react37.createElement)(+ return (0, import_react38.createElement)("div",{ className: "bt-secret-edit-block" },- (0, import_react37.createElement)("div", { className: "bt-secret-edit-label" }, provider.key.configured ? t("Replace the API key") : t("API key")),- (0, import_react37.createElement)(+ (0, import_react38.createElement)("div", { className: "bt-secret-edit-label" }, provider.key.configured ? t("Replace the API key") : t("API key")),+ (0, import_react38.createElement)("div",{ className: "bt-secret-inline" },- (0, import_react37.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react37.createElement)(KeyIcon), (0, import_react37.createElement)(MaskedInput, { value, onChange: edit, onEnter: save, label })),- (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: !ready, onClick: save }, t("Save")),- provider.key.configured ? (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => apply2(actions.setProviderKey(provider.id, null)) }, t("Remove key")) : null+ (0, import_react38.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react38.createElement)(KeyIcon), (0, import_react38.createElement)(MaskedInput, { value, onChange: edit, onEnter: save, label })),+ (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: !ready, onClick: save }, t("Save")),+ provider.key.configured ? (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => apply2(actions.setProviderKey(provider.id, null)) }, t("Remove key")) : null),- saved ? (0, import_react37.createElement)("div", { className: "bt-set-hint bt-secret-ok", role: "status" }, (0, import_react37.createElement)(CheckIcon), t("Saved.")) : null+ saved ? (0, import_react38.createElement)("div", { className: "bt-set-hint bt-secret-ok", role: "status" }, (0, import_react38.createElement)(CheckIcon), t("Saved.")) : null);}function AddProvider({ view, apply: apply2, actions, onDone }) {- const [mode, setMode] = (0, import_react37.useState)(view.addable.length > 0 ? "known" : "custom");- return (0, import_react37.createElement)(+ const [mode, setMode] = (0, import_react38.useState)(view.addable.length > 0 ? "known" : "custom");+ return (0, import_react38.createElement)("div",{ className: "bt-set-row bt-set-paste bt-provider-add" },- (0, import_react37.createElement)(+ (0, import_react38.createElement)(Segmented,{ label: t("Kind of provider"), value: mode },- [["known", t("Known provider")], ["custom", t("Custom API")]].map(([id, label]) => (0, import_react37.createElement)("button", {+ [["known", t("Known provider")], ["custom", t("Custom API")]].map(([id, label]) => (0, import_react38.createElement)("button", {key: id,type: "button","aria-pressed": mode === id,@@ -15142,13 +15481,13 @@ function AddProvider({ view, apply: apply2, actions, onDone }) {}, label))),// Both forms stay mounted, so switching keeps what is typed in the other.- (0, import_react37.createElement)("div", { hidden: mode !== "known" }, (0, import_react37.createElement)(KnownForm, { view, apply: apply2, actions, onDone })),- (0, import_react37.createElement)("div", { hidden: mode !== "custom" }, (0, import_react37.createElement)(CustomForm, { view, apply: apply2, actions, onDone }))+ (0, import_react38.createElement)("div", { hidden: mode !== "known" }, (0, import_react38.createElement)(KnownForm, { view, apply: apply2, actions, onDone })),+ (0, import_react38.createElement)("div", { hidden: mode !== "custom" }, (0, import_react38.createElement)(CustomForm, { view, apply: apply2, actions, onDone })));}function KnownForm({ view, apply: apply2, actions, onDone }) {- const [provider, setProvider] = (0, import_react37.useState)("");- const [key, setKey] = (0, import_react37.useState)("");+ const [provider, setProvider] = (0, import_react38.useState)("");+ const [key, setKey] = (0, import_react38.useState)("");const options = [...view.addable].sort((a, b) => a.name.localeCompare(b.name));const add = () => {if (provider === "") return;@@ -15156,24 +15495,24 @@ function KnownForm({ view, apply: apply2, actions, onDone }) {if (ok) onDone();});};- return (0, import_react37.createElement)(+ return (0, import_react38.createElement)("div",{ className: "bt-provider-form" },- (0, import_react37.createElement)(+ (0, import_react38.createElement)("select",{ className: "bt-select", "aria-label": t("Provider"), value: provider, onChange: (event) => setProvider(event.target.value) },- (0, import_react37.createElement)("option", { value: "", disabled: true }, t("Choose a provider")),- options.map((option) => (0, import_react37.createElement)("option", { key: option.id, value: option.id }, option.name))+ (0, import_react38.createElement)("option", { value: "", disabled: true }, t("Choose a provider")),+ options.map((option) => (0, import_react38.createElement)("option", { key: option.id, value: option.id }, option.name))),- (0, import_react37.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react37.createElement)(KeyIcon), (0, import_react37.createElement)(MaskedInput, { value: key, onChange: setKey, onEnter: add, label: t("API key") })),- (0, import_react37.createElement)(FormActions, { onCancel: onDone, onAdd: add, ready: provider !== "" })+ (0, import_react38.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react38.createElement)(KeyIcon), (0, import_react38.createElement)(MaskedInput, { value: key, onChange: setKey, onEnter: add, label: t("API key") })),+ (0, import_react38.createElement)(FormActions, { onCancel: onDone, onAdd: add, ready: provider !== "" }));}function CustomForm({ view, apply: apply2, actions, onDone }) {- const [draft, setDraft] = (0, import_react37.useState)({ provider: "", name: "", baseURL: "", api: view.protocols[0], key: "", typed: "" });- const [found, setFound] = (0, import_react37.useState)(null);- const [picked, setPicked] = (0, import_react37.useState)([]);- const [asking, setAsking] = (0, import_react37.useState)(false);+ const [draft, setDraft] = (0, import_react38.useState)({ provider: "", name: "", baseURL: "", api: view.protocols[0], key: "", typed: "" });+ const [found, setFound] = (0, import_react38.useState)(null);+ const [picked, setPicked] = (0, import_react38.useState)([]);+ const [asking, setAsking] = (0, import_react38.useState)(false);const set = (field, value) => setDraft((current) => ({ ...current, [field]: value }));const typed = draft.typed.split(/[\s,]+/).map((id) => id.trim()).filter(Boolean);const models = [...(found ?? []).filter((model) => picked.includes(model.id)), ...typed.filter((id) => !picked.includes(id)).map((id) => ({ id }))];@@ -15192,7 +15531,7 @@ function CustomForm({ view, apply: apply2, actions, onDone }) {if (ok) onDone();});};- const input = (field, label, placeholder) => (0, import_react37.createElement)("input", {+ const input = (field, label, placeholder) => (0, import_react38.createElement)("input", {className: "bt-input","aria-label": label,placeholder,@@ -15201,55 +15540,55 @@ function CustomForm({ view, apply: apply2, actions, onDone }) {autoComplete: "off",onChange: (event) => set(field, event.target.value)});- return (0, import_react37.createElement)(+ return (0, import_react38.createElement)("div",{ className: "bt-provider-form" },- (0, import_react37.createElement)(+ (0, import_react38.createElement)("div",{ className: "bt-provider-pair" },input("provider", t("Provider ID"), t("Provider ID, e.g. my-gateway")),input("name", t("Name"), t("Name (optional)"))),- (0, import_react37.createElement)(+ (0, import_react38.createElement)("div",{ className: "bt-provider-pair" },input("baseURL", t("Endpoint"), ENDPOINT_HINTS[draft.api] ?? "https://gateway.example/v1"),- (0, import_react37.createElement)(+ (0, import_react38.createElement)("select",{ className: "bt-select", "aria-label": t("Protocol"), value: draft.api, onChange: (event) => set("api", event.target.value) },- view.protocols.map((api) => (0, import_react37.createElement)("option", { key: api, value: api }, PROTOCOL_NAMES[api] ?? api))+ view.protocols.map((api) => (0, import_react38.createElement)("option", { key: api, value: api }, PROTOCOL_NAMES[api] ?? api)))),- (0, import_react37.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react37.createElement)(KeyIcon), (0, import_react37.createElement)(MaskedInput, { value: draft.key, onChange: (value) => set("key", value), label: t("API key") })),- (0, import_react37.createElement)(+ (0, import_react38.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react38.createElement)(KeyIcon), (0, import_react38.createElement)(MaskedInput, { value: draft.key, onChange: (value) => set("key", value), label: t("API key") })),+ (0, import_react38.createElement)("div",{ className: "bt-secret-edit-block" },- (0, import_react37.createElement)(+ (0, import_react38.createElement)("div",{ className: "bt-provider-models-head" },- (0, import_react37.createElement)("span", { className: "bt-secret-edit-label" }, t("Models")),- (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: asking || draft.baseURL.trim() === "", onClick: fetchModels }, asking ? t("Asking…") : t("Fetch models"))+ (0, import_react38.createElement)("span", { className: "bt-secret-edit-label" }, t("Models")),+ (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: asking || draft.baseURL.trim() === "", onClick: fetchModels }, asking ? t("Asking…") : t("Fetch models"))),- found !== null && found.length === 0 ? (0, import_react37.createElement)("div", { className: "bt-set-hint" }, t("The endpoint lists no models. Enter their ids below.")) : null,- found !== null && found.length > 0 ? (0, import_react37.createElement)("div", { className: "bt-secret-bots bt-provider-found" }, found.map((model) => (0, import_react37.createElement)("button", {+ found !== null && found.length === 0 ? (0, import_react38.createElement)("div", { className: "bt-set-hint" }, t("The endpoint lists no models. Enter their ids below.")) : null,+ found !== null && found.length > 0 ? (0, import_react38.createElement)("div", { className: "bt-secret-bots bt-provider-found" }, found.map((model) => (0, import_react38.createElement)("button", {key: model.id,type: "button",className: "bt-secret-bot","aria-pressed": picked.includes(model.id),title: model.name && model.name !== model.id ? model.name : void 0,onClick: () => toggle(model.id)- }, (0, import_react37.createElement)("code", null, model.id), picked.includes(model.id) ? (0, import_react37.createElement)(CheckIcon) : null))) : null,+ }, (0, import_react38.createElement)("code", null, model.id), picked.includes(model.id) ? (0, import_react38.createElement)(CheckIcon) : null))) : null,input("typed", t("Model ids"), t("Model ids, separated by commas"))),- (0, import_react37.createElement)(FormActions, { onCancel: onDone, onAdd: add, ready })+ (0, import_react38.createElement)(FormActions, { onCancel: onDone, onAdd: add, ready }));}function FormActions({ onCancel, onAdd, ready }) {- return (0, import_react37.createElement)(+ return (0, import_react38.createElement)("div",{ className: "bt-secret-row-actions" },- (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onCancel }, t("Cancel")),- (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: !ready, onClick: onAdd }, t("Add"))+ (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onCancel }, t("Cancel")),+ (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: !ready, onClick: onAdd }, t("Add")));}var PROVIDERS_CSS = `@@ -15279,24 +15618,24 @@ var PROVIDERS_CSS = ``;// src/client/settings.js-var import_react38 = require("react");+var import_react39 = require("react");var capitalize2 = (word) => word[0].toUpperCase() + word.slice(1);var SETTINGS_PAGES = [["general", "General"], ["models", "Models"], ["bots", "Bots"], ["groups", "Group chats"], ["connectors", "Connectors"], ["capabilities", "Capabilities"], ["browser", "Browser"], ["schedules", "Scheduled tasks"], ["usage", "Usage"], ["secrets", "Secrets"], ["feedback", "Feedback"], ["about", "About DS Bot"]];var PAGE_ICONS = { ...SETTINGS_ICONS, models: SlidersIcon, connectors: ConnectorIcon, capabilities: PlugIcon, browser: ConnectorIcon, schedules: ClockIcon, secrets: KeyIcon, feedback: FeedbackIcon, about: InfoIcon };function SetSection({ title, className = "", children }) {- return (0, import_react38.createElement)("section", { className: `bt-set-section ${className}`.trim() }, (0, import_react38.createElement)("h3", null, title), (0, import_react38.createElement)("div", { className: "bt-set-card" }, children));+ return (0, import_react39.createElement)("section", { className: `bt-set-section ${className}`.trim() }, (0, import_react39.createElement)("h3", null, title), (0, import_react39.createElement)("div", { className: "bt-set-card" }, children));}function SetRow({ label, hint, children, className = "" }) {- return (0, import_react38.createElement)(+ return (0, import_react39.createElement)("div",{ className: `bt-set-row ${className}`.trim() },- (0, import_react38.createElement)("div", { className: "bt-set-copy" }, (0, import_react38.createElement)("span", null, label), hint ? (0, import_react38.createElement)("span", { className: "bt-set-hint" }, hint) : null),- children ? (0, import_react38.createElement)("div", { className: "bt-set-control" }, children) : null+ (0, import_react39.createElement)("div", { className: "bt-set-copy" }, (0, import_react39.createElement)("span", null, label), hint ? (0, import_react39.createElement)("span", { className: "bt-set-hint" }, hint) : null),+ children ? (0, import_react39.createElement)("div", { className: "bt-set-control" }, children) : null);}var LAYOUTS = [["bubble", "Bubble"], ["flat", "Flat"]];function Choice({ label, value, options, pick: pick2 }) {- return (0, import_react38.createElement)(Segmented, { label, value, className: "bt-look-seg" }, options.map(([id, text]) => (0, import_react38.createElement)("button", {+ return (0, import_react39.createElement)(Segmented, { label, value, className: "bt-look-seg" }, options.map(([id, text]) => (0, import_react39.createElement)("button", {key: id,type: "button","aria-pressed": value === id,@@ -15306,12 +15645,12 @@ function Choice({ label, value, options, pick: pick2 }) {}, t(text))));}function WidthSlider({ label, value, save }) {- const [width, setWidth] = (0, import_react38.useState)(value);- const pending = (0, import_react38.useRef)(null);- const timer = (0, import_react38.useRef)(0);- const saveRef = (0, import_react38.useRef)(save);+ const [width, setWidth] = (0, import_react39.useState)(value);+ const pending = (0, import_react39.useRef)(null);+ const timer = (0, import_react39.useRef)(0);+ const saveRef = (0, import_react39.useRef)(save);saveRef.current = save;- (0, import_react38.useEffect)(() => {+ (0, import_react39.useEffect)(() => {if (pending.current === null) setWidth(value);}, [value]);const flush = () => {@@ -15319,7 +15658,7 @@ function WidthSlider({ label, value, save }) {pending.current = null;if (next !== null) saveRef.current(next);};- (0, import_react38.useEffect)(() => () => {+ (0, import_react39.useEffect)(() => () => {clearTimeout(timer.current);flush();}, []);@@ -15330,46 +15669,46 @@ function WidthSlider({ label, value, save }) {timer.current = setTimeout(flush, 350);};const { min, max, step } = MESSAGE_WIDTH;- return (0, import_react38.createElement)(+ return (0, import_react39.createElement)("div",{ className: "bt-range", style: { "--bt-fill": `${(width - min) / (max - min) * 100}%` } },- (0, import_react38.createElement)("input", { type: "range", min, max, step, value: width, "aria-label": label, "aria-valuetext": `${width}%`, onChange: (event) => pick2(Number(event.target.value)) }),- (0, import_react38.createElement)("output", null, `${width}%`)+ (0, import_react39.createElement)("input", { type: "range", min, max, step, value: width, "aria-label": label, "aria-valuetext": `${width}%`, onChange: (event) => pick2(Number(event.target.value)) }),+ (0, import_react39.createElement)("output", null, `${width}%`));}function GeneralPage({ roster, actions, run: run2 }) {const prefs = roster.prefs ?? {};const themes = allThemes();const current = themes[prefs.theme] ? prefs.theme : "deepseek";- const [custom, setCustom] = (0, import_react38.useState)(prefs.accent ?? "#4d6bfe");- const timer = (0, import_react38.useRef)(0);- (0, import_react38.useEffect)(() => () => clearTimeout(timer.current), []);+ const [custom, setCustom] = (0, import_react39.useState)(prefs.accent ?? "#4d6bfe");+ const timer = (0, import_react39.useRef)(0);+ (0, import_react39.useEffect)(() => () => clearTimeout(timer.current), []);const pickCustom = (value) => {setCustom(value);clearTimeout(timer.current);timer.current = setTimeout(() => run2(actions.setPrefs({ accent: value })), 350);};return [- (0, import_react38.createElement)(+ (0, import_react39.createElement)(SetSection,{ key: "look", title: t("Appearance") },- (0, import_react38.createElement)(+ (0, import_react39.createElement)(SetRow,{ label: t("Theme"), hint: t("Colors for the whole team, on every device.") },- (0, import_react38.createElement)(+ (0, import_react39.createElement)("select",{ className: "bt-select", "aria-label": t("Theme"), value: current, onChange: (event) => run2(actions.setPrefs({ theme: event.target.value })) },- Object.entries(themes).map(([id, theme]) => (0, import_react38.createElement)("option", { key: id, value: id }, t(theme.label)))+ Object.entries(themes).map(([id, theme]) => (0, import_react39.createElement)("option", { key: id, value: id }, t(theme.label))))),- (0, import_react38.createElement)(+ (0, import_react39.createElement)(SetRow,{ label: t("Accent"), hint: t("Unread marks, badges, and the brand mark.") },- (0, import_react38.createElement)(+ (0, import_react39.createElement)("div",{ className: "bt-swatches" },- (0, import_react38.createElement)("button", { type: "button", className: "bt-swatch bt-swatch-default", title: t("Theme accent"), "aria-label": t("Theme accent"), "aria-pressed": !prefs.accent, onClick: () => run2(actions.setPrefs({ accent: null })) }),- ACCENT_INKS.map((ink) => (0, import_react38.createElement)("button", {+ (0, import_react39.createElement)("button", { type: "button", className: "bt-swatch bt-swatch-default", title: t("Theme accent"), "aria-label": t("Theme accent"), "aria-pressed": !prefs.accent, onClick: () => run2(actions.setPrefs({ accent: null })) }),+ ACCENT_INKS.map((ink) => (0, import_react39.createElement)("button", {key: ink,type: "button",className: "bt-swatch",@@ -15379,38 +15718,38 @@ function GeneralPage({ roster, actions, run: run2 }) {style: { background: INKS[ink][0] },onClick: () => run2(actions.setPrefs({ accent: INKS[ink][0] }))})),- (0, import_react38.createElement)(+ (0, import_react39.createElement)("label",{ className: "bt-swatch bt-swatch-custom", title: t("Custom accent"), "data-on": Boolean(prefs.accent) && !ACCENT_INKS.some((ink) => INKS[ink][0] === prefs.accent) },- (0, import_react38.createElement)("input", { type: "color", value: custom, "aria-label": t("Custom accent"), onChange: (event) => pickCustom(event.target.value) })+ (0, import_react39.createElement)("input", { type: "color", value: custom, "aria-label": t("Custom accent"), onChange: (event) => pickCustom(event.target.value) })))),- (0, import_react38.createElement)(SetRow, { label: t("Message layout") }, (0, import_react38.createElement)(Choice, { label: t("Message layout"), value: layoutOf(prefs), options: LAYOUTS, pick: (id) => run2(actions.setPrefs({ layout: id })) })),+ (0, import_react39.createElement)(SetRow, { label: t("Message layout") }, (0, import_react39.createElement)(Choice, { label: t("Message layout"), value: layoutOf(prefs), options: LAYOUTS, pick: (id) => run2(actions.setPrefs({ layout: id })) })),// The flat layout's text has a width of its own; the bubble width stays for the user's messages.- layoutOf(prefs) === "flat" ? (0, import_react38.createElement)(SetRow, { label: t("Text width") }, (0, import_react38.createElement)(WidthSlider, { label: t("Text width"), value: flatWidthOf(prefs), save: (flatWidth) => run2(actions.setPrefs({ flatWidth })) })) : null,- (0, import_react38.createElement)(SetRow, { label: t("Bubble width") }, (0, import_react38.createElement)(WidthSlider, { label: t("Bubble width"), value: widthOf(prefs), save: (width) => run2(actions.setPrefs({ width })) })),- (0, import_react38.createElement)(SetRow, { label: t("Show thinking") }, (0, import_react38.createElement)(Switch, { label: t("Show thinking"), on: thinkingShown(prefs), onChange: (thinking) => run2(actions.setPrefs({ thinking })) }))+ layoutOf(prefs) === "flat" ? (0, import_react39.createElement)(SetRow, { label: t("Text width") }, (0, import_react39.createElement)(WidthSlider, { label: t("Text width"), value: flatWidthOf(prefs), save: (flatWidth) => run2(actions.setPrefs({ flatWidth })) })) : null,+ (0, import_react39.createElement)(SetRow, { label: t("Bubble width") }, (0, import_react39.createElement)(WidthSlider, { label: t("Bubble width"), value: widthOf(prefs), save: (width) => run2(actions.setPrefs({ width })) })),+ (0, import_react39.createElement)(SetRow, { label: t("Show thinking") }, (0, import_react39.createElement)(Switch, { label: t("Show thinking"), on: thinkingShown(prefs), onChange: (thinking) => run2(actions.setPrefs({ thinking })) }))),- actions.setSurface ? (0, import_react38.createElement)(+ actions.setSurface ? (0, import_react39.createElement)(SetSection,{ key: "mode", title: t("Mode") },- (0, import_react38.createElement)(+ (0, import_react39.createElement)(SetRow,{ label: t("Classic Agent mode") },- (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.setSurface("agent") }, t("Switch"))+ (0, import_react39.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.setSurface("agent") }, t("Switch")))) : null,- (0, import_react38.createElement)(LocationsSection, { key: "places", actions, run: run2 })+ (0, import_react39.createElement)(LocationsSection, { key: "places", actions, run: run2 })];}function LocationsSection({ actions, run: run2 }) {const app = globalThis.dsBotApp;- const [team, setTeam] = (0, import_react38.useState)(null);- const [data, setData] = (0, import_react38.useState)(null);- const [moving, setMoving] = (0, import_react38.useState)(false);- const busy = (0, import_react38.useRef)(false);- (0, import_react38.useEffect)(() => {+ const [team, setTeam] = (0, import_react39.useState)(null);+ const [data, setData] = (0, import_react39.useState)(null);+ const [moving, setMoving] = (0, import_react39.useState)(false);+ const busy = (0, import_react39.useRef)(false);+ (0, import_react39.useEffect)(() => {void Promise.resolve(actions.folders()).then((info) => setTeam(info?.team ?? null)).catch(() => {});if (app !== void 0) void Promise.resolve(app.dataLocation()).then(setData).catch(() => {@@ -15428,18 +15767,18 @@ function LocationsSection({ actions, run: run2 }) {setMoving(false);}));};- return (0, import_react38.createElement)(+ return (0, import_react39.createElement)(SetSection,{ title: t("Locations"), className: "bt-set-places" },- (0, import_react38.createElement)(+ (0, import_react39.createElement)(SetRow,{ label: t("Team workspace"), hint: t("Where Bots without a folder of their own work.") },- team === null ? null : (0, import_react38.createElement)(FolderMenu, { value: team, team: true, actions, run: run2, onPick: pickTeam, disabled: moving })+ team === null ? null : (0, import_react39.createElement)(FolderMenu, { value: team, team: true, actions, run: run2, onPick: pickTeam, disabled: moving })),- data === null ? null : (0, import_react38.createElement)(+ data === null ? null : (0, import_react39.createElement)(SetRow,{ label: t("Data location"), hint: data.path },- data.fixed ? null : (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: moving, onClick: () => {+ data.fixed ? null : (0, import_react39.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: moving, onClick: () => {if (!busy.current) void run2(app.moveData(team ?? void 0));} }, t("Change…")))@@ -15449,52 +15788,52 @@ function MainBotsSection({ roster, actions, run: run2 }) {const mains = (roster.mainBotIds ?? []).map((id) => roster.byId[id]).filter(Boolean);const [first, ...others] = mains;const candidates = roster.bots.filter((bot) => !isMainOf(roster, bot.id));- return (0, import_react38.createElement)(+ return (0, import_react39.createElement)(SetSection,{ title: t("Main Bot") },- (0, import_react38.createElement)(+ (0, import_react39.createElement)(SetRow,{label: t("Main Bot"),hint: first ? t("First in the sidebar. Pick another Bot to hand it the role; {name} then stops being a Main Bot.", { name: first.name }) : void 0},- (0, import_react38.createElement)("select", {+ (0, import_react39.createElement)("select", {className: "bt-select","aria-label": t("Main Bot"),value: first?.id ?? "",onChange: (event) => run2(actions.setMain(event.target.value, true, first ? { replace: first.id } : {}))- }, first ? null : (0, import_react38.createElement)("option", { value: "" }, t("Choose a Bot…")), roster.bots.map((bot) => (0, import_react38.createElement)("option", { key: bot.id, value: bot.id }, bot.name)))+ }, first ? null : (0, import_react39.createElement)("option", { value: "" }, t("Choose a Bot…")), roster.bots.map((bot) => (0, import_react39.createElement)("option", { key: bot.id, value: bot.id }, bot.name)))),- others.map((bot) => (0, import_react38.createElement)(+ others.map((bot) => (0, import_react39.createElement)(SetRow,{ key: bot.id, label: bot.name, hint: t("Also a Main Bot.") },- (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.setMain(bot.id, true, { primary: true })) }, t("Move to first")),- (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.setMain(bot.id, false)) }, t("Remove Main Bot role"))+ (0, import_react39.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.setMain(bot.id, true, { primary: true })) }, t("Move to first")),+ (0, import_react39.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.setMain(bot.id, false)) }, t("Remove Main Bot role")))),- candidates.length > 0 ? (0, import_react38.createElement)(+ candidates.length > 0 ? (0, import_react39.createElement)(SetRow,{ label: t("Add a Main Bot"), hint: t("Main Bots can create and change Bots, and run every group chat.") },- (0, import_react38.createElement)("select", {+ (0, import_react39.createElement)("select", {className: "bt-select","aria-label": t("Add a Main Bot"),value: "",onChange: (event) => {if (event.target.value) void run2(actions.setMain(event.target.value, true));}- }, (0, import_react38.createElement)("option", { value: "" }, t("Choose a Bot…")), candidates.map((bot) => (0, import_react38.createElement)("option", { key: bot.id, value: bot.id }, bot.name)))+ }, (0, import_react39.createElement)("option", { value: "" }, t("Choose a Bot…")), candidates.map((bot) => (0, import_react39.createElement)("option", { key: bot.id, value: bot.id }, bot.name)))) : null);}var MOTIONS = [["quiet", "Quiet"], ["normal", "Normal"], ["lively", "Lively"]];function MotionSection({ roster, actions, run: run2 }) {const motion = roster.prefs?.motion === "quiet" || roster.prefs?.motion === "lively" ? roster.prefs.motion : "normal";- return (0, import_react38.createElement)(+ return (0, import_react39.createElement)(SetSection,{ title: t("Animation") },- (0, import_react38.createElement)(+ (0, import_react39.createElement)(SetRow,{ label: t("Bot animation") },- (0, import_react38.createElement)(Segmented, { label: t("Bot animation"), value: motion, className: "bt-motion-seg" }, MOTIONS.map(([id, label]) => (0, import_react38.createElement)("button", {+ (0, import_react39.createElement)(Segmented, { label: t("Bot animation"), value: motion, className: "bt-motion-seg" }, MOTIONS.map(([id, label]) => (0, import_react39.createElement)("button", {key: id,type: "button","aria-pressed": motion === id,@@ -15506,69 +15845,69 @@ function MotionSection({ roster, actions, run: run2 }) {);}function BotsPage({ roster, actions, run: run2 }) {- const [creating, setCreating] = (0, import_react38.useState)(false);+ const [creating, setCreating] = (0, import_react39.useState)(false);return [- (0, import_react38.createElement)(MainBotsSection, { key: "main", roster, actions, run: run2 }),- (0, import_react38.createElement)(MotionSection, { key: "motion", roster, actions, run: run2 }),- creating ? (0, import_react38.createElement)(CreateBot, { key: "create", roster, actions, inline: true, onBack: () => setCreating(false), onCreated: (bot) => actions.openSettings("bots", bot.id) }) : (0, import_react38.createElement)(+ (0, import_react39.createElement)(MainBotsSection, { key: "main", roster, actions, run: run2 }),+ (0, import_react39.createElement)(MotionSection, { key: "motion", roster, actions, run: run2 }),+ creating ? (0, import_react39.createElement)(CreateBot, { key: "create", roster, actions, inline: true, onBack: () => setCreating(false), onCreated: (bot) => actions.openSettings("bots", bot.id) }) : (0, import_react39.createElement)("div",{ key: "new", className: "bt-actions" },- (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-with-icon", onClick: () => setCreating(true) }, (0, import_react38.createElement)(PlusIcon), t("New Bot"))+ (0, import_react39.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-with-icon", onClick: () => setCreating(true) }, (0, import_react39.createElement)(PlusIcon), t("New Bot"))),- (0, import_react38.createElement)(+ (0, import_react39.createElement)(SetSection,{ key: "bots", title: t("Bots · {count}", { count: roster.bots.length }) },- roster.bots.map((bot) => (0, import_react38.createElement)(+ roster.bots.map((bot) => (0, import_react39.createElement)("button",{ key: bot.id, type: "button", className: "bt-set-row", onClick: () => actions.openSettings("bots", bot.id) },- (0, import_react38.createElement)(+ (0, import_react39.createElement)("span",{ className: "bt-set-bot" },- (0, import_react38.createElement)(BotAvatar, { bot, size: 28, badge: false, live: false }),- (0, import_react38.createElement)("span", { className: "bt-row-title" }, bot.name),- bot.role ? (0, import_react38.createElement)("span", { className: "bt-tag" }, bot.role) : null,- isMainOf(roster, bot.id) ? (0, import_react38.createElement)("span", { className: "bt-tag" }, t("Main Bot")) : null,- bot.hidden && !isMainOf(roster, bot.id) ? (0, import_react38.createElement)("span", { className: "bt-tag" }, t("Hidden")) : null+ (0, import_react39.createElement)(BotAvatar, { bot, size: 28, badge: false, live: false }),+ (0, import_react39.createElement)("span", { className: "bt-row-title" }, bot.name),+ bot.role ? (0, import_react39.createElement)("span", { className: "bt-tag" }, bot.role) : null,+ isMainOf(roster, bot.id) ? (0, import_react39.createElement)("span", { className: "bt-tag" }, t("Main Bot")) : null,+ bot.hidden && !isMainOf(roster, bot.id) ? (0, import_react39.createElement)("span", { className: "bt-tag" }, t("Hidden")) : null),- (0, import_react38.createElement)("span", { className: "bt-chevron" }, (0, import_react38.createElement)(ChevronRightIcon))+ (0, import_react39.createElement)("span", { className: "bt-chevron" }, (0, import_react39.createElement)(ChevronRightIcon)))))];}function GroupsPage({ roster, actions, run: run2 }) {- const [creating, setCreating] = (0, import_react38.useState)(false);+ const [creating, setCreating] = (0, import_react39.useState)(false);return [- creating ? (0, import_react38.createElement)(NewGroupForm, { key: "create", roster, actions, run: run2, onCancel: () => setCreating(false), onCreated: (room2) => actions.openSettings("groups", room2.id) }) : (0, import_react38.createElement)(+ creating ? (0, import_react39.createElement)(NewGroupForm, { key: "create", roster, actions, run: run2, onCancel: () => setCreating(false), onCreated: (room2) => actions.openSettings("groups", room2.id) }) : (0, import_react39.createElement)("div",{ key: "new", className: "bt-actions" },- (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-with-icon", disabled: roster.bots.length < 2, title: roster.bots.length < 2 ? t("A group chat needs at least two Bots") : void 0, onClick: () => setCreating(true) }, (0, import_react38.createElement)(PlusIcon), t("Create group chat"))+ (0, import_react39.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-with-icon", disabled: roster.bots.length < 2, title: roster.bots.length < 2 ? t("A group chat needs at least two Bots") : void 0, onClick: () => setCreating(true) }, (0, import_react39.createElement)(PlusIcon), t("Create group chat"))),- (0, import_react38.createElement)(+ (0, import_react39.createElement)(SetSection,{ key: "groups", title: t("Group chats · {count}", { count: roster.rooms.length }) },- roster.rooms.length === 0 ? (0, import_react38.createElement)(SetRow, { label: t("No group chats yet."), hint: t("A group chat lets several Bots work on one thing with you.") }) : roster.rooms.map((room2) => {+ roster.rooms.length === 0 ? (0, import_react39.createElement)(SetRow, { label: t("No group chats yet."), hint: t("A group chat lets several Bots work on one thing with you.") }) : roster.rooms.map((room2) => {const admin = roster.byId[room2.admin];- return (0, import_react38.createElement)(+ return (0, import_react39.createElement)("button",{ key: room2.id, type: "button", className: "bt-set-row", onClick: () => actions.openSettings("groups", room2.id) },- (0, import_react38.createElement)(+ (0, import_react39.createElement)("span",{ className: "bt-set-bot" },- (0, import_react38.createElement)(RoomAvatar, { room: room2, roster, size: 28 }),- (0, import_react38.createElement)("span", { className: "bt-row-title" }, room2.name),- (0, import_react38.createElement)("span", { className: "bt-tag" }, t("{count} members", { count: room2.members.length })),- admin ? (0, import_react38.createElement)("span", { className: "bt-tag bt-tag-admin" }, (0, import_react38.createElement)(AdminStar), admin.name) : null,- room2.hidden ? (0, import_react38.createElement)("span", { className: "bt-tag" }, t("Hidden")) : null+ (0, import_react39.createElement)(RoomAvatar, { room: room2, roster, size: 28 }),+ (0, import_react39.createElement)("span", { className: "bt-row-title" }, room2.name),+ (0, import_react39.createElement)("span", { className: "bt-tag" }, t("{count} members", { count: room2.members.length })),+ admin ? (0, import_react39.createElement)("span", { className: "bt-tag bt-tag-admin" }, (0, import_react39.createElement)(AdminStar), admin.name) : null,+ room2.hidden ? (0, import_react39.createElement)("span", { className: "bt-tag" }, t("Hidden")) : null),- (0, import_react38.createElement)("span", { className: "bt-chevron" }, (0, import_react38.createElement)(ChevronRightIcon))+ (0, import_react39.createElement)("span", { className: "bt-chevron" }, (0, import_react39.createElement)(ChevronRightIcon)));}))];}function SettingsDialog({ page, id, roster, actions, useUpdate, leaving = false }) {- const [error, setError] = (0, import_react38.useState)("");- const close = (0, import_react38.useCallback)(() => actions.closeSettings(), []);+ const [error, setError] = (0, import_react39.useState)("");+ const close = (0, import_react39.useCallback)(() => actions.closeSettings(), []);useEscape(close);const run2 = (promise) => Promise.resolve(promise).then(() => {setError("");@@ -15587,100 +15926,100 @@ function SettingsDialog({ page, id, roster, actions, useUpdate, leaving = falseconst nav = useGlide(shown, { axis: "y" });const pageKey = `${shown}:${bot?.id ?? room2?.id ?? ""}`;const depth = bot || room2 ? 1 : 0;- const last = (0, import_react38.useRef)({ key: pageKey, depth, move: "up" });+ const last = (0, import_react39.useRef)({ key: pageKey, depth, move: "up" });if (last.current.key !== pageKey) {last.current = { key: pageKey, depth, move: depth > last.current.depth ? "in" : depth < last.current.depth ? "out" : "up" };}- const [usageOpened, setUsageOpened] = (0, import_react38.useState)(shown === "usage");+ const [usageOpened, setUsageOpened] = (0, import_react39.useState)(shown === "usage");if (shown === "usage" && !usageOpened) setUsageOpened(true);- const errorLine = error ? (0, import_react38.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null;- return (0, import_react38.createElement)(+ const errorLine = error ? (0, import_react39.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null;+ return (0, import_react39.createElement)("div",{ className: "bt-settings-layer", "data-leaving": leaving || void 0 },- (0, import_react38.createElement)("div", { className: "bt-scrim", onMouseDown: close }),- (0, import_react38.createElement)(+ (0, import_react39.createElement)("div", { className: "bt-scrim", onMouseDown: close }),+ (0, import_react39.createElement)("div",{ className: "bt-settings", role: "dialog", "aria-modal": true, "aria-label": t("DS Bot settings") },- (0, import_react38.createElement)(+ (0, import_react39.createElement)("nav",{ ref: nav.box, className: "bt-settings-nav", "aria-label": t("Settings pages") },- (0, import_react38.createElement)("span", { ref: nav.thumb, className: "bt-thumb", "aria-hidden": true }),- pages.map(([key, text]) => (0, import_react38.createElement)("button", {+ (0, import_react39.createElement)("span", { ref: nav.thumb, className: "bt-thumb", "aria-hidden": true }),+ pages.map(([key, text]) => (0, import_react39.createElement)("button", {key,type: "button",className: "bt-settings-item","aria-current": shown === key ? "page" : void 0,onClick: () => actions.openSettings(key)- }, (0, import_react38.createElement)(PAGE_ICONS[key]), t(text))),- actions.openHarnessSettings ? (0, import_react38.createElement)("button", {+ }, (0, import_react39.createElement)(PAGE_ICONS[key]), t(text))),+ actions.openHarnessSettings ? (0, import_react39.createElement)("button", {type: "button",className: "bt-settings-item bt-settings-shell",title: t("Models, providers, and the rest of DeepSeek Harness"),onClick: () => {close();- actions.openHarnessSettings();+ (actions.openHarnessModels ?? actions.openHarnessSettings)();}- }, (0, import_react38.createElement)(SlidersIcon), t("Harness settings")) : null+ }, (0, import_react39.createElement)(SlidersIcon), t("Advanced settings (DeepSeek Harness)")) : null),- (0, import_react38.createElement)(+ (0, import_react39.createElement)("div",{ className: "bt-settings-main" },- (0, import_react38.createElement)(+ (0, import_react39.createElement)("div",{ className: "bt-settings-head" },- back ? (0, import_react38.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": back, title: back, onClick: () => actions.openSettings(shown) }, (0, import_react38.createElement)(ChevronLeftIcon)) : null,- (0, import_react38.createElement)("h2", { key: bot?.id ?? room2?.id ?? shown }, bot?.name ?? room2?.name ?? label)+ back ? (0, import_react39.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": back, title: back, onClick: () => actions.openSettings(shown) }, (0, import_react39.createElement)(ChevronLeftIcon)) : null,+ (0, import_react39.createElement)("h2", { key: bot?.id ?? room2?.id ?? shown }, bot?.name ?? room2?.name ?? label)),- shown === "usage" ? null : (0, import_react38.createElement)(+ shown === "usage" ? null : (0, import_react39.createElement)("div",{ key: pageKey, className: "bt-settings-scroll bt-settings-page", "data-move": last.current.move },errorLine,- shown === "general" ? (0, import_react38.createElement)(GeneralPage, { roster, actions, run: run2 }) : null,- shown === "models" ? (0, import_react38.createElement)(ProvidersPage, { actions, run: run2, Section: SetSection }) : null,- bot ? (0, import_react38.createElement)("div", { className: "bt-settings-form" }, (0, import_react38.createElement)(BotSettingsForm, { key: bot.id, bot, roster, actions, run: run2 })) : null,- shown === "bots" && !bot ? (0, import_react38.createElement)(BotsPage, { roster, actions, run: run2 }) : null,- room2 ? (0, import_react38.createElement)("div", { className: "bt-settings-form" }, (0, import_react38.createElement)(GroupSettingsForm, { key: room2.id, room: room2, roster, actions, run: run2 })) : null,- shown === "groups" && !room2 ? (0, import_react38.createElement)(GroupsPage, { roster, actions, run: run2 }) : null,- shown === "connectors" ? (0, import_react38.createElement)(ConnectorsPage, { roster, actions }) : null,- shown === "capabilities" ? (0, import_react38.createElement)(CapabilitiesPage, { roster, actions, run: run2 }) : null,- shown === "browser" ? (0, import_react38.createElement)(BrowserPage, { roster, actions, run: run2, Section: SetSection, Row: SetRow }) : null,- shown === "schedules" ? (0, import_react38.createElement)(SchedulesPage, { roster, actions, start: id ?? void 0 }) : null,- shown === "secrets" ? (0, import_react38.createElement)(SecretsPage, { roster, actions, run: run2, Section: SetSection }) : null,- shown === "feedback" ? (0, import_react38.createElement)(FeedbackPage, { actions, run: run2, Section: SetSection, Row: SetRow }) : null,- shown === "about" ? (0, import_react38.createElement)(AboutPage, { useUpdate, actions, run: run2, Section: SetSection, Row: SetRow }) : null+ shown === "general" ? (0, import_react39.createElement)(GeneralPage, { roster, actions, run: run2 }) : null,+ shown === "models" ? (0, import_react39.createElement)(ProvidersPage, { actions, run: run2, Section: SetSection }) : null,+ bot ? (0, import_react39.createElement)("div", { className: "bt-settings-form" }, (0, import_react39.createElement)(BotSettingsForm, { key: bot.id, bot, roster, actions, run: run2 })) : null,+ shown === "bots" && !bot ? (0, import_react39.createElement)(BotsPage, { roster, actions, run: run2 }) : null,+ room2 ? (0, import_react39.createElement)("div", { className: "bt-settings-form" }, (0, import_react39.createElement)(GroupSettingsForm, { key: room2.id, room: room2, roster, actions, run: run2 })) : null,+ shown === "groups" && !room2 ? (0, import_react39.createElement)(GroupsPage, { roster, actions, run: run2 }) : null,+ shown === "connectors" ? (0, import_react39.createElement)(ConnectorsPage, { roster, actions }) : null,+ shown === "capabilities" ? (0, import_react39.createElement)(CapabilitiesPage, { roster, actions, run: run2 }) : null,+ shown === "browser" ? (0, import_react39.createElement)(BrowserPage, { roster, actions, run: run2, Section: SetSection, Row: SetRow }) : null,+ shown === "schedules" ? (0, import_react39.createElement)(SchedulesPage, { roster, actions, start: id ?? void 0 }) : null,+ shown === "secrets" ? (0, import_react39.createElement)(SecretsPage, { roster, actions, run: run2, Section: SetSection }) : null,+ shown === "feedback" ? (0, import_react39.createElement)(FeedbackPage, { actions, run: run2, Section: SetSection, Row: SetRow }) : null,+ shown === "about" ? (0, import_react39.createElement)(AboutPage, { useUpdate, actions, run: run2, Section: SetSection, Row: SetRow }) : null),- usageOpened ? (0, import_react38.createElement)(+ usageOpened ? (0, import_react39.createElement)("div",{ key: "usage", className: "bt-settings-scroll bt-settings-usage", "data-off": shown === "usage" ? void 0 : "", "aria-hidden": shown === "usage" ? void 0 : true },shown === "usage" ? errorLine : null,- (0, import_react38.createElement)(UsagePage, { roster, actions, focusId: usageFocus })+ (0, import_react39.createElement)(UsagePage, { roster, actions, focusId: usageFocus })) : null),- (0, import_react38.createElement)("button", { type: "button", className: "bt-settings-close", "aria-label": t("Close settings"), onClick: close }, (0, import_react38.createElement)(CloseIcon))+ (0, import_react39.createElement)("button", { type: "button", className: "bt-settings-close", "aria-label": t("Close settings"), onClick: close }, (0, import_react39.createElement)(CloseIcon))));}// src/client/context-menu.js-var import_react39 = require("react");+var import_react40 = require("react");function ContextMenu({ menu, roster, actions, leaving = false }) {useEscape(() => actions.closeMenu());- (0, import_react39.useEffect)(() => {+ (0, import_react40.useEffect)(() => {const onDown = (event) => {if (!(event.target instanceof Element) || !event.target.closest(".bt-menu")) actions.closeMenu();};window.addEventListener("mousedown", onDown);return () => window.removeEventListener("mousedown", onDown);}, []);- const ref = (0, import_react39.useRef)(null);- const [place, setPlace] = (0, import_react39.useState)({ left: menu.x, top: menu.y });+ const ref = (0, import_react40.useRef)(null);+ const [place, setPlace] = (0, import_react40.useState)({ left: menu.x, top: menu.y });const tick = useViewport();- (0, import_react39.useLayoutEffect)(() => {+ (0, import_react40.useLayoutEffect)(() => {const box = ref.current?.getBoundingClientRect();if (!box) return;setPlace({ left: Math.max(8, Math.min(menu.x, window.innerWidth - box.width - 8)), top: Math.max(8, Math.min(menu.y, viewBottom() - box.height - 8)) });}, [menu.x, menu.y, tick]);- if (menu.kind === "agent" || menu.kind === "agent-session") return (0, import_react39.createElement)(AgentMenu, { menu, roster, actions, leaving });+ if (menu.kind === "agent" || menu.kind === "agent-session") return (0, import_react40.createElement)(AgentMenu, { menu, roster, actions, leaving });const bot = roster.byId[menu.id];const room2 = roster.roomsById[menu.id];const entry = bot ?? room2;@@ -15711,14 +16050,14 @@ function ContextMenu({ menu, roster, actions, leaving = false }) {isMainBot ? null : [room2 ? t("Delete group") : t("Delete"), TrashIcon, () => bot ? actions.deleteBot(bot.id) : actions.deleteRoom(menu.id), true]]].map((group) => group.filter(Boolean)).filter((group) => group.length > 0);- return (0, import_react39.createElement)(+ return (0, import_react40.createElement)("div",{ ref, className: "bt-menu", role: "menu", "aria-label": t("{name} actions", { name: bot?.name ?? room2.name }), style: place, "data-leaving": leaving || void 0 },- groups.map((group, index) => (0, import_react39.createElement)(- import_react39.Fragment,+ groups.map((group, index) => (0, import_react40.createElement)(+ import_react40.Fragment,{ key: index },- index > 0 ? (0, import_react39.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,- group.map(([label, Icon, run2, danger]) => (0, import_react39.createElement)("button", {+ index > 0 ? (0, import_react40.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,+ group.map(([label, Icon, run2, danger]) => (0, import_react40.createElement)("button", {key: label,type: "button",role: "menuitem",@@ -15727,15 +16066,15 @@ function ContextMenu({ menu, roster, actions, leaving = false }) {actions.closeMenu();void Promise.resolve(run2()).catch((error) => actions.reportError(error, "menu"));}- }, (0, import_react39.createElement)(Icon), label))+ }, (0, import_react40.createElement)(Icon), label)))));}function AgentMenu({ menu, roster, actions, leaving }) {- const ref = (0, import_react39.useRef)(null);- const [place, setPlace] = (0, import_react39.useState)({ left: menu.x, top: menu.y });+ const ref = (0, import_react40.useRef)(null);+ const [place, setPlace] = (0, import_react40.useState)({ left: menu.x, top: menu.y });const tick = useViewport();- (0, import_react39.useLayoutEffect)(() => {+ (0, import_react40.useLayoutEffect)(() => {const box = ref.current?.getBoundingClientRect();if (!box) return;setPlace({ left: Math.max(8, Math.min(menu.x, window.innerWidth - box.width - 8)), top: Math.max(8, Math.min(menu.y, viewBottom() - box.height - 8)) });@@ -15757,14 +16096,14 @@ function AgentMenu({ menu, roster, actions, leaving }) {[t("Archive"), TrashIcon, () => actions.archiveAgentSession(agent.id, menu.id), true]]];- return (0, import_react39.createElement)(+ return (0, import_react40.createElement)("div",{ ref, className: "bt-menu", role: "menu", "aria-label": menu.kind === "agent" ? "DSH Agent" : t("Session actions"), style: place, "data-leaving": leaving || void 0 },- groups.map((group, index) => (0, import_react39.createElement)(- import_react39.Fragment,+ groups.map((group, index) => (0, import_react40.createElement)(+ import_react40.Fragment,{ key: index },- index > 0 ? (0, import_react39.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,- group.map(([label, Icon, run2, danger]) => (0, import_react39.createElement)("button", {+ index > 0 ? (0, import_react40.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,+ group.map(([label, Icon, run2, danger]) => (0, import_react40.createElement)("button", {key: label,type: "button",role: "menuitem",@@ -15773,13 +16112,13 @@ function AgentMenu({ menu, roster, actions, leaving }) {actions.closeMenu();void Promise.resolve(run2()).catch((error) => console.warn("[ds-bot]", error));}- }, (0, import_react39.createElement)(Icon), label))+ }, (0, import_react40.createElement)(Icon), label)))));}// src/client/member-status.js-var import_react40 = require("react");+var import_react41 = require("react");var NO_WORK = { bots: {}, rooms: {}, approvals: [] };var FACES_MAX = 3;var DOCK_EXIT_MS = 160;@@ -15840,15 +16179,15 @@ function dockModel(sessionId, roster, work) {};}function Face({ bot, ask, state }) {- return (0, import_react40.createElement)(+ return (0, import_react41.createElement)("span",{ className: "bt-mw-face", "data-ask": ask || void 0 },- (0, import_react40.createElement)(BotMark, { bot, size: 20, state: ask ? "alert" : state })+ (0, import_react41.createElement)(BotMark, { bot, size: 20, state: ask ? "alert" : state }));}function useFitWidth(inner, key) {- const [width, setWidth] = (0, import_react40.useState)(null);- (0, import_react40.useLayoutEffect)(() => {+ const [width, setWidth] = (0, import_react41.useState)(null);+ (0, import_react41.useLayoutEffect)(() => {setWidth(key && inner.current ? inner.current.offsetWidth : null);}, [key]);return width;@@ -15859,61 +16198,61 @@ function MemberDock({ sessionId, useRoster, useWork, actions }) {const live = dockModel(sessionId, roster, work);const [kept, leaving] = useLinger(live ? JSON.stringify(live) : null, DOCK_EXIT_MS);const model = kept ? JSON.parse(kept) : null;- const inner = (0, import_react40.useRef)(null);+ const inner = (0, import_react41.useRef)(null);const width = useFitWidth(inner, kept);if (!model) return null;const faces = model.faces.map((face) => ({ ...face, bot: roster.byId[face.id] })).filter((face) => face.bot);const label = [model.waiting, model.doing].filter(Boolean).join(" · ");const open = () => model.open.details ? actions.showDetails(model.open.details) : actions.openSession(model.open.session);- return (0, import_react40.createElement)(+ return (0, import_react41.createElement)("div",{ className: "bt-mw-dock", "data-leaving": leaving || void 0 },- (0, import_react40.createElement)(+ (0, import_react41.createElement)("button",{ type: "button", className: "bt-mw-pill", "aria-label": label, onClick: open, disabled: leaving, style: width ? { width } : void 0 },- (0, import_react40.createElement)(+ (0, import_react41.createElement)("span",{ ref: inner, className: "bt-mw-pill-in" },- (0, import_react40.createElement)("span", { className: "bt-mw-faces", "aria-hidden": true }, faces.map((face) => (0, import_react40.createElement)(Face, { key: face.id, ...face }))),- (0, import_react40.createElement)(+ (0, import_react41.createElement)("span", { className: "bt-mw-faces", "aria-hidden": true }, faces.map((face) => (0, import_react41.createElement)(Face, { key: face.id, ...face }))),+ (0, import_react41.createElement)("span",{ key: label, className: "bt-mw-label", "aria-hidden": true },- model.waiting ? (0, import_react40.createElement)("span", { className: "bt-mw-ask" }, model.waiting) : null,- model.waiting && model.doing ? (0, import_react40.createElement)("span", { className: "bt-mw-dot" }, "·") : null,- model.doing ? (0, import_react40.createElement)("span", { className: "bt-mw-doing" }, (0, import_react40.createElement)(Shimmer, null, model.doing)) : null+ model.waiting ? (0, import_react41.createElement)("span", { className: "bt-mw-ask" }, model.waiting) : null,+ model.waiting && model.doing ? (0, import_react41.createElement)("span", { className: "bt-mw-dot" }, "·") : null,+ model.doing ? (0, import_react41.createElement)("span", { className: "bt-mw-doing" }, (0, import_react41.createElement)(Shimmer, null, model.doing)) : null))));}-var stateLine = (className, at, ...what) => (0, import_react40.createElement)(+var stateLine = (className, at, ...what) => (0, import_react41.createElement)("span",{ className },- (0, import_react40.createElement)("span", { className: "bt-member-what" }, ...what),- typeof at === "number" ? (0, import_react40.createElement)(Elapsed, { at, className: "bt-member-time" }) : null+ (0, import_react41.createElement)("span", { className: "bt-member-what" }, ...what),+ typeof at === "number" ? (0, import_react41.createElement)(Elapsed, { at, className: "bt-member-time" }) : null);function ApprovalCard({ approval, bot, actions }) {- const [busy, setBusy] = (0, import_react40.useState)(false);+ const [busy, setBusy] = (0, import_react41.useState)(false);const answer = (choice) => {setBusy(true);void Promise.resolve(actions.answerApproval(approval.id, choice)).catch((error) => actions.reportError(error, "approval")).finally(() => setBusy(false));};- return (0, import_react40.createElement)(+ return (0, import_react41.createElement)("div",{ className: "bt-mw-card", role: "group", "aria-label": t("{name} is waiting for your approval", { name: bot.name }) },- (0, import_react40.createElement)("div", { className: "bt-mw-tool" }, approval.tool),- approval.detail?.text ? (0, import_react40.createElement)("div", { className: "bt-mw-text" }, approval.detail.text) : null,- approval.reason ? (0, import_react40.createElement)("div", { className: "bt-mw-reason" }, approval.reason) : null,- approval.detail?.code ? (0, import_react40.createElement)("code", { className: "bt-mw-code", title: approval.detail.code }, approval.detail.code) : null,- approval.answerable ? (0, import_react40.createElement)(+ (0, import_react41.createElement)("div", { className: "bt-mw-tool" }, approval.tool),+ approval.detail?.text ? (0, import_react41.createElement)("div", { className: "bt-mw-text" }, approval.detail.text) : null,+ approval.reason ? (0, import_react41.createElement)("div", { className: "bt-mw-reason" }, approval.reason) : null,+ approval.detail?.code ? (0, import_react41.createElement)("code", { className: "bt-mw-code", title: approval.detail.code }, approval.detail.code) : null,+ approval.answerable ? (0, import_react41.createElement)("div",{ className: "bt-mw-actions" },- (0, import_react40.createElement)("button", { type: "button", className: "bt-q-btn", disabled: busy, onClick: () => answer("reject") }, t("Reject")),- (0, import_react40.createElement)("button", { type: "button", className: "bt-q-submit", disabled: busy, onClick: () => answer("allow") }, t("Allow once"))- ) : (0, import_react40.createElement)(+ (0, import_react41.createElement)("button", { type: "button", className: "bt-q-btn", disabled: busy, onClick: () => answer("reject") }, t("Reject")),+ (0, import_react41.createElement)("button", { type: "button", className: "bt-q-submit", disabled: busy, onClick: () => answer("allow") }, t("Allow once"))+ ) : (0, import_react41.createElement)("div",{ className: "bt-mw-actions" },- (0, import_react40.createElement)("button", { type: "button", className: "bt-q-btn", onClick: () => actions.openSession(bot.id) }, t("Open {name}'s chat", { name: bot.name }))+ (0, import_react41.createElement)("button", { type: "button", className: "bt-q-btn", onClick: () => actions.openSession(bot.id) }, t("Open {name}'s chat", { name: bot.name }))));}@@ -15921,20 +16260,20 @@ function MemberState({ entry, bot, room: room2, roster }) {if (entry?.state === "ask") return stateLine("bt-member-state bt-mw-ask", entry.approvals[0].at, t("Waiting for your approval"));if (entry?.state !== "work") return bot.role ? stateLine("bt-member-state", void 0, bot.role) : null;const where = entry.doing.roomId === room2.id ? "" : entry.doing.roomId ? t("in {name}", { name: roster.roomsById[entry.doing.roomId]?.name ?? t("a group chat") }) : t("in its own chat");- return stateLine("bt-member-state", entry.doing.since, (0, import_react40.createElement)(Shimmer, null, `${workPhrase(entry.doing)}…`), where ? ` ${where}` : "");+ return stateLine("bt-member-state", entry.doing.since, (0, import_react41.createElement)(Shimmer, null, `${workPhrase(entry.doing)}…`), where ? ` ${where}` : "");}function StopMemberWork({ entry, bot, room: room2, actions }) {- const [stopping, setStopping] = (0, import_react40.useState)(false);+ const [stopping, setStopping] = (0, import_react41.useState)(false);if (!entry?.here || entry.state !== "work" && entry.state !== "ask") return null;const stop = () => {setStopping(true);void Promise.resolve(actions.stopMemberWork(room2.id, bot.id)).catch((error) => actions.reportError(error, "stop")).finally(() => setStopping(false));};- return (0, import_react40.createElement)("button", { type: "button", className: "bt-member-stop", disabled: stopping, "aria-label": `${t("Stop")} · ${bot.name}`, onClick: stop }, t("Stop"));+ return (0, import_react41.createElement)("button", { type: "button", className: "bt-member-stop", disabled: stopping, "aria-label": `${t("Stop")} · ${bot.name}`, onClick: stop }, t("Stop"));}function MemberApprovals({ entry, bot, actions }) {if (entry?.state !== "ask") return null;- return (0, import_react40.createElement)("div", { className: "bt-member-cards" }, entry.approvals.map((approval) => (0, import_react40.createElement)(ApprovalCard, { key: approval.id, approval, bot, actions })));+ return (0, import_react41.createElement)("div", { className: "bt-member-cards" }, entry.approvals.map((approval) => (0, import_react41.createElement)(ApprovalCard, { key: approval.id, approval, bot, actions })));}function useMemberWork(room2, useWork) {const work = useWork?.((value) => value) ?? NO_WORK;@@ -15993,7 +16332,7 @@ body[data-ds-dark-theme] .bt-member-state.bt-mw-ask{color:#f0b84a}`;// src/client/details-drawer.js-var import_react41 = require("react");+var import_react42 = require("react");function transcriptOf(list, id, name, hiddenTurns = []) {const outline = list.projectionsBySession?.[id]?.values?.turnOutline ?? list.byId[id]?.projectionValues?.turnOutline;if (!Array.isArray(outline)) return "";@@ -16018,17 +16357,17 @@ var EMPTY_TABS = { ids: [], active: null };function PermissionRow({ bot, roster, actions, run: run2 }) {const catalog = roster.permissions;if (!catalog?.options?.length) return null;- return (0, import_react41.createElement)(+ return (0, import_react42.createElement)("div",{ className: "bt-drawer-permission" },- (0, import_react41.createElement)("div", { className: "bt-section-title" }, t("Permissions")),+ (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Permissions")),// A Bot without its own preset may run on another one set in DSH, so its first pick always applies.- (0, import_react41.createElement)(PermissionPicker, { catalog, saved: bot.permission ?? catalog.defaultPreset, repick: bot.permission === void 0, onPick: (permission) => run2(actions.updateBot(bot.id, { permission })) })+ (0, import_react42.createElement)(PermissionPicker, { catalog, saved: bot.permission ?? catalog.defaultPreset, repick: bot.permission === void 0, onPick: (permission) => run2(actions.updateBot(bot.id, { permission })) }));}function RunStats({ bot, part, running, actions }) {- const [values, setValues] = (0, import_react41.useState)(null);- (0, import_react41.useEffect)(() => {+ const [values, setValues] = (0, import_react42.useState)(null);+ (0, import_react42.useEffect)(() => {if (!actions.runStats) return void 0;let current = true;actions.runStats(bot.id).then(@@ -16045,56 +16384,56 @@ function RunStats({ bot, part, running, actions }) {}, [bot.id, part, running]);const shown = runStatsOf(values);if (shown.length === 0) return null;- return (0, import_react41.createElement)(+ return (0, import_react42.createElement)("div",{ className: "bt-run-stats" },- shown.map((entry, index) => (0, import_react41.createElement)(- import_react41.Fragment,+ shown.map((entry, index) => (0, import_react42.createElement)(+ import_react42.Fragment,{ key: entry.key },- index > 0 ? (0, import_react41.createElement)("span", { className: "bt-run-sep", "aria-hidden": true }, "·") : null,- (0, import_react41.createElement)("span", { title: entry.title }, entry.text)+ index > 0 ? (0, import_react42.createElement)("span", { className: "bt-run-sep", "aria-hidden": true }, "·") : null,+ (0, import_react42.createElement)("span", { title: entry.title }, entry.text))));}function BrowserCards({ bot, sessionId, roster, actions, useBrowserTabs, useBrowserPages }) {const state = useBrowserTabs((map) => map[bot.id] ?? EMPTY_TABS);const pages = useBrowserPages((map) => map);- (0, import_react41.useEffect)(() => {+ (0, import_react42.useEffect)(() => {actions.browserEnsure?.(bot.id);}, [bot.id]);if (roster.browser !== true || !actions.browserShow) {- return (0, import_react41.createElement)("div", { className: "bt-muted" }, t("The browser is in DSH Desktop and the DeepSeek Bot app."));+ return (0, import_react42.createElement)("div", { className: "bt-muted" }, t("The browser is in DSH Desktop and the DeepSeek Bot app."));}if (state.ids.length === 0) {- return (0, import_react41.createElement)(+ return (0, import_react42.createElement)("div",{ className: "bt-browser-empty-mark" },- (0, import_react41.createElement)(BotMark, { bot, size: 40, state: "idle", live: true }),- (0, import_react41.createElement)("div", { className: "bt-browser-empty-title" }, t("{name}'s browser", { name: bot.name })),- (0, import_react41.createElement)("div", { className: "bt-muted" }, t("Open a page here and {name} can read it with you. Logins and cookies stay with {name}; other Bots never see them.", { name: bot.name })),- (0, import_react41.createElement)("button", { type: "button", className: "bt-browser-retry", onClick: () => actions.openBrowser(sessionId) }, t("Open browser"))+ (0, import_react42.createElement)(BotMark, { bot, size: 40, state: "idle", live: true }),+ (0, import_react42.createElement)("div", { className: "bt-browser-empty-title" }, t("{name}'s browser", { name: bot.name })),+ (0, import_react42.createElement)("div", { className: "bt-muted" }, t("Open a page here and {name} can read it with you. Logins and cookies stay with {name}; other Bots never see them.", { name: bot.name })),+ (0, import_react42.createElement)("button", { type: "button", className: "bt-browser-retry", onClick: () => actions.openBrowser(sessionId) }, t("Open browser")));}- return (0, import_react41.createElement)(+ return (0, import_react42.createElement)("div",{ className: "bt-bcards" },state.ids.map((tabId, index) => {const page = pages[tabId] ?? {};const label = page.title || shortUrl(page.url) || t("New tab");- return (0, import_react41.createElement)(+ return (0, import_react42.createElement)("div",{ key: tabId, className: "bt-bcard", "data-active": state.active === tabId || void 0, style: { animationDelay: `${index * 30}ms` } },- (0, import_react41.createElement)(+ (0, import_react42.createElement)("button",{ type: "button", className: "bt-bcard-shot", "aria-label": t("Open {title}", { title: label }), title: page.url, onClick: () => actions.browserPick(sessionId, tabId) },- page.excerpt ? (0, import_react41.createElement)(+ page.excerpt ? (0, import_react42.createElement)("span",{ className: "bt-bcard-preview" },- (0, import_react41.createElement)("span", { className: "bt-bcard-ptitle" }, label),- (0, import_react41.createElement)("span", { className: "bt-bcard-excerpt" }, page.excerpt)- ) : (0, import_react41.createElement)("span", { className: "bt-bcard-blank" }, (0, import_react41.createElement)(GlobeIcon), (0, import_react41.createElement)("span", null, label))+ (0, import_react42.createElement)("span", { className: "bt-bcard-ptitle" }, label),+ (0, import_react42.createElement)("span", { className: "bt-bcard-excerpt" }, page.excerpt)+ ) : (0, import_react42.createElement)("span", { className: "bt-bcard-blank" }, (0, import_react42.createElement)(GlobeIcon), (0, import_react42.createElement)("span", null, label))),- (0, import_react41.createElement)("button", {+ (0, import_react42.createElement)("button", {type: "button",className: "bt-bcard-x","aria-label": t("Close tab"),@@ -16103,29 +16442,29 @@ function BrowserCards({ bot, sessionId, roster, actions, useBrowserTabs, useBrowvoid actions.browserCloseTab(bot.id, tabId);}}, "×"),- (0, import_react41.createElement)(+ (0, import_react42.createElement)("div",{ className: "bt-bcard-row" },- (0, import_react41.createElement)(Favicon, { src: page.favicon, className: "bt-bcard-fav" }),- (0, import_react41.createElement)("span", { className: "bt-bcard-title" }, label),- page.url ? (0, import_react41.createElement)("span", { className: "bt-bcard-host" }, hostOf(page.url)) : null+ (0, import_react42.createElement)(Favicon, { src: page.favicon, className: "bt-bcard-fav" }),+ (0, import_react42.createElement)("span", { className: "bt-bcard-title" }, label),+ page.url ? (0, import_react42.createElement)("span", { className: "bt-bcard-host" }, hostOf(page.url)) : null));}),- (0, import_react41.createElement)("button", { type: "button", className: "bt-bcard-new", style: { animationDelay: `${state.ids.length * 30}ms` }, onClick: () => actions.browserNewTab(sessionId) }, (0, import_react41.createElement)(PlusIcon), t("New tab"))+ (0, import_react42.createElement)("button", { type: "button", className: "bt-bcard-new", style: { animationDelay: `${state.ids.length * 30}ms` }, onClick: () => actions.browserNewTab(sessionId) }, (0, import_react42.createElement)(PlusIcon), t("New tab")));}function About({ text, title = "About" }) {- const [open, setOpen] = (0, import_react41.useState)(false);+ const [open, setOpen] = (0, import_react42.useState)(false);const long = text.split("\n").length > 5 || text.length > 240;- const body = (0, import_react41.useRef)(null);+ const body = (0, import_react42.useRef)(null);useMorph(body, open);- return (0, import_react41.createElement)(+ return (0, import_react42.createElement)("div",null,- (0, import_react41.createElement)("div", { className: "bt-section-title" }, t(title)),- (0, import_react41.createElement)("div", { ref: body, className: "bt-about", "data-open": open || void 0 }, text),- long ? (0, import_react41.createElement)("button", { type: "button", className: "bt-more", onClick: () => setOpen((value) => !value) }, open ? t("Show less") : t("Show more")) : null+ (0, import_react42.createElement)("div", { className: "bt-section-title" }, t(title)),+ (0, import_react42.createElement)("div", { ref: body, className: "bt-about", "data-open": open || void 0 }, text),+ long ? (0, import_react42.createElement)("button", { type: "button", className: "bt-more", onClick: () => setOpen((value) => !value) }, open ? t("Show less") : t("Show more")) : null);}var PILE_MAX = 4;@@ -16133,52 +16472,52 @@ function MemberPile({ room: room2, roster }) {const members = room2.members.map((id) => roster.byId[id]).filter(Boolean);const shown = members.length > PILE_MAX ? members.slice(0, PILE_MAX - 1) : members;const more = members.length - shown.length;- return (0, import_react41.createElement)(+ return (0, import_react42.createElement)("span",{ className: "bt-pile", "aria-hidden": true },- shown.map((bot, index) => (0, import_react41.createElement)("span", { key: bot.id, className: "bt-pile-face", style: { animationDelay: `${index * 40}ms` } }, (0, import_react41.createElement)(BotMark, { bot, size: 44, live: true }))),- more > 0 ? (0, import_react41.createElement)("span", { key: "more", className: "bt-pile-face bt-pile-more", style: { animationDelay: `${shown.length * 40}ms` } }, `+${more}`) : null+ shown.map((bot, index) => (0, import_react42.createElement)("span", { key: bot.id, className: "bt-pile-face", style: { animationDelay: `${index * 40}ms` } }, (0, import_react42.createElement)(BotMark, { bot, size: 44, live: true }))),+ more > 0 ? (0, import_react42.createElement)("span", { key: "more", className: "bt-pile-face bt-pile-more", style: { animationDelay: `${shown.length * 40}ms` } }, `+${more}`) : null);}var markOf = (entry) => entry?.state === "ask" ? "alert" : entry?.state === "work" ? workState(entry.doing) : "idle";function MemberRow({ member, entry, room: room2, roster, actions }) {- return (0, import_react41.createElement)(+ return (0, import_react42.createElement)("div",{ role: "listitem", className: "bt-member" },- (0, import_react41.createElement)(+ (0, import_react42.createElement)("div",{ className: "bt-member-row" },- (0, import_react41.createElement)(+ (0, import_react42.createElement)("button",{ type: "button", className: "bt-member-open", title: t("Open {name}'s chat", { name: member.name }), onClick: () => actions.openSession(member.id) },- (0, import_react41.createElement)(BotMark, { bot: member, size: 32, state: markOf(entry) }),- (0, import_react41.createElement)(+ (0, import_react42.createElement)(BotMark, { bot: member, size: 32, state: markOf(entry) }),+ (0, import_react42.createElement)("span",{ className: "bt-member-text" },- (0, import_react41.createElement)(+ (0, import_react42.createElement)("span",{ className: "bt-member-line" },- (0, import_react41.createElement)("span", { className: "bt-member-name" }, member.name),- room2.admin === member.id ? (0, import_react41.createElement)("span", { className: "bt-tag" }, t("Admin")) : null+ (0, import_react42.createElement)("span", { className: "bt-member-name" }, member.name),+ room2.admin === member.id ? (0, import_react42.createElement)("span", { className: "bt-tag" }, t("Admin")) : null),- (0, import_react41.createElement)(MemberState, { entry, bot: member, room: room2, roster })+ (0, import_react42.createElement)(MemberState, { entry, bot: member, room: room2, roster }))),- (0, import_react41.createElement)(StopMemberWork, { entry, bot: member, room: room2, actions })+ (0, import_react42.createElement)(StopMemberWork, { entry, bot: member, room: room2, actions })),- (0, import_react41.createElement)(MemberApprovals, { entry, bot: member, actions })+ (0, import_react42.createElement)(MemberApprovals, { entry, bot: member, actions }));}function GroupOverview({ room: room2, roster, actions, usage, useWork, openSettings }) {const members = room2.members.map((id) => roster.byId[id]).filter(Boolean);const { entries: entries2 } = useMemberWork(room2, useWork);return [- room2.notice ? (0, import_react41.createElement)(About, { key: "notice", title: "Notice", text: room2.notice }) : (0, import_react41.createElement)("button", { key: "notice", type: "button", className: "bt-more", onClick: openSettings }, t("Add a notice in group settings")),- (0, import_react41.createElement)(+ room2.notice ? (0, import_react42.createElement)(About, { key: "notice", title: "Notice", text: room2.notice }) : (0, import_react42.createElement)("button", { key: "notice", type: "button", className: "bt-more", onClick: openSettings }, t("Add a notice in group settings")),+ (0, import_react42.createElement)("div",{ key: "members" },- (0, import_react41.createElement)("div", { className: "bt-section-title" }, t("Members · {count}", { count: members.length })),- (0, import_react41.createElement)("div", { className: "bt-members", role: "list" }, members.map((member) => (0, import_react41.createElement)(MemberRow, {+ (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Members · {count}", { count: members.length })),+ (0, import_react42.createElement)("div", { className: "bt-members", role: "list" }, members.map((member) => (0, import_react42.createElement)(MemberRow, {key: member.id,member,entry: entries2.find((item) => item.id === member.id),@@ -16187,24 +16526,24 @@ function GroupOverview({ room: room2, roster, actions, usage, useWork, openSettiactions})))),- (0, import_react41.createElement)(+ (0, import_react42.createElement)("div",{ key: "mode" },- (0, import_react41.createElement)("div", { className: "bt-section-title" }, t("Who answers")),- (0, import_react41.createElement)("div", { className: "bt-kv" }, (0, import_react41.createElement)("span", null, t(ROOM_MODES.find(([id]) => id === shownMode(room2, roster))?.[1] ?? "Everyone")))+ (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Who answers")),+ (0, import_react42.createElement)("div", { className: "bt-kv" }, (0, import_react42.createElement)("span", null, t(ROOM_MODES.find(([id]) => id === shownMode(room2, roster))?.[1] ?? "Everyone")))),- room2.permission ? (0, import_react41.createElement)(+ room2.permission ? (0, import_react42.createElement)("div",{ key: "permission" },- (0, import_react41.createElement)("div", { className: "bt-section-title" }, t("Permissions")),- (0, import_react41.createElement)("div", { className: "bt-kv" }, (0, import_react41.createElement)("span", { className: presetDanger(room2.permission) ? "bt-perm-danger" : void 0 }, presetName(room2.permission, roster.permissions)))+ (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Permissions")),+ (0, import_react42.createElement)("div", { className: "bt-kv" }, (0, import_react42.createElement)("span", { className: presetDanger(room2.permission) ? "bt-perm-danger" : void 0 }, presetName(room2.permission, roster.permissions)))) : null,- roster.memory === false ? null : (0, import_react41.createElement)(MemoryRow, { key: "memory", owner: { id: room2.id, name: room2.name, group: true }, actions }),- usage ? (0, import_react41.createElement)(+ roster.memory === false ? null : (0, import_react42.createElement)(MemoryRow, { key: "memory", owner: { id: room2.id, name: room2.name, group: true }, actions }),+ usage ? (0, import_react42.createElement)("div",{ key: "usage" },- (0, import_react41.createElement)("div", { className: "bt-section-title" }, t("Usage")),- (0, import_react41.createElement)("div", { className: "bt-kv" }, (0, import_react41.createElement)("span", null, room2.name), (0, import_react41.createElement)("span", null, usage))+ (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Usage")),+ (0, import_react42.createElement)("div", { className: "bt-kv" }, (0, import_react42.createElement)("span", null, room2.name), (0, import_react42.createElement)("span", null, usage))) : null];}@@ -16212,15 +16551,15 @@ function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, roster, aconst owner = roster.byId[sessionId];const part = owner ? currentPart(owner) : sessionId;const isMainBot = isMainOf(roster, owner?.id);- const [tab, setTab] = (0, import_react41.useState)("details");+ const [tab, setTab] = (0, import_react42.useState)("details");const room2 = roster.roomsById[sessionId];- const [view, setView] = (0, import_react41.useState)(startTab === "settings" && (owner || room2) ? "settings" : "overview");- const [editing, setEditing] = (0, import_react41.useState)(Boolean(startRenaming && (roster.byId[sessionId] || roster.roomsById[sessionId])));- const [draftName, setDraftName] = (0, import_react41.useState)(roster.byId[sessionId]?.name ?? (roster.roomsById[sessionId]?.named ? roster.roomsById[sessionId].name : ""));- const [copied, setCopied] = (0, import_react41.useState)(false);- const [error, setError] = (0, import_react41.useState)("");+ const [view, setView] = (0, import_react42.useState)(startTab === "settings" && (owner || room2) ? "settings" : "overview");+ const [editing, setEditing] = (0, import_react42.useState)(Boolean(startRenaming && (roster.byId[sessionId] || roster.roomsById[sessionId])));+ const [draftName, setDraftName] = (0, import_react42.useState)(roster.byId[sessionId]?.name ?? (roster.roomsById[sessionId]?.named ? roster.roomsById[sessionId].name : ""));+ const [copied, setCopied] = (0, import_react42.useState)(false);+ const [error, setError] = (0, import_react42.useState)("");const glide = useGlide(tab);- const last = (0, import_react41.useRef)({ view, tab, move: void 0 });+ const last = (0, import_react42.useRef)({ view, tab, move: void 0 });if (last.current.view !== view) last.current = { view, tab, move: view === "settings" ? "in" : "out" };else if (last.current.tab !== tab) last.current = { view, tab, move: "tab" };const move = last.current.move;@@ -16245,21 +16584,21 @@ function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, roster, asetTimeout(() => setCopied(false), 1600);});};- const errorLine = error ? (0, import_react41.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null;+ const errorLine = error ? (0, import_react42.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null;if ((bot || room2) && view === "settings") {return [- (0, import_react41.createElement)(+ (0, import_react42.createElement)("div",{ key: "head", className: "bt-subhead", "data-move": move },- (0, import_react41.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back to details"), onClick: () => setView("overview") }, (0, import_react41.createElement)(ChevronLeftIcon)),- (0, import_react41.createElement)("span", { className: "bt-subhead-title" }, bot ? t("Settings") : t("Group settings")),- hasStrip ? null : (0, import_react41.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Close details"), onClick: close }, (0, import_react41.createElement)(CloseIcon))+ (0, import_react42.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back to details"), onClick: () => setView("overview") }, (0, import_react42.createElement)(ChevronLeftIcon)),+ (0, import_react42.createElement)("span", { className: "bt-subhead-title" }, bot ? t("Settings") : t("Group settings")),+ hasStrip ? null : (0, import_react42.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Close details"), onClick: close }, (0, import_react42.createElement)(CloseIcon))),- (0, import_react41.createElement)(+ (0, import_react42.createElement)("div",{ key: "set-body", className: "bt-drawer-body bt-set-body", "data-move": move },errorLine,- bot ? (0, import_react41.createElement)(BotSettingsForm, { bot, roster, actions, run: run2 }) : (0, import_react41.createElement)(GroupSettingsForm, { room: room2, roster, actions, run: run2, onDeleted: close })+ bot ? (0, import_react42.createElement)(BotSettingsForm, { bot, roster, actions, run: run2 }) : (0, import_react42.createElement)(GroupSettingsForm, { room: room2, roster, actions, run: run2, onDeleted: close }))];}@@ -16270,18 +16609,18 @@ function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, roster, acanTerminal: actions.canOpenTerminal?.() === true,canFiles: actions.canOpenFiles?.() === true}).map((key) => menuItemFor(key, actions, sessionId));- const top = (0, import_react41.createElement)(+ const top = (0, import_react42.createElement)("div",{ className: "bt-drawer-top", "data-move": side },- bot || room2 ? (0, import_react41.createElement)("button", { type: "button", className: "bt-round", "aria-label": bot ? t("Edit Bot") : t("Group settings"), title: bot ? t("Edit Bot") : t("Group settings"), "data-info-row": "settings", onClick: () => setView("settings") }, (0, import_react41.createElement)(GearIcon)) : null,- more.length > 0 ? (0, import_react41.createElement)("span", { "data-info-row": "more" }, (0, import_react41.createElement)(PanelMenu, { items: more, className: "bt-round", "aria-label": t("More") })) : null,- bot || room2 ? (0, import_react41.createElement)("button", { type: "button", className: "bt-round", "aria-label": copied ? t("Copied conversation") : t("Share conversation"), title: copied ? t("Copied") : t("Copy conversation as Markdown"), onClick: share }, copied ? (0, import_react41.createElement)("span", { key: "copied", className: "bt-pop-in" }, "✓") : (0, import_react41.createElement)(ShareIcon)) : null,- hasStrip ? null : (0, import_react41.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("Close details"), onClick: close }, (0, import_react41.createElement)(CloseIcon))+ bot || room2 ? (0, import_react42.createElement)("button", { type: "button", className: "bt-round", "aria-label": bot ? t("Edit Bot") : t("Group settings"), title: bot ? t("Edit Bot") : t("Group settings"), "data-info-row": "settings", onClick: () => setView("settings") }, (0, import_react42.createElement)(GearIcon)) : null,+ more.length > 0 ? (0, import_react42.createElement)("span", { "data-info-row": "more" }, (0, import_react42.createElement)(PanelMenu, { items: more, className: "bt-round", "aria-label": t("More") })) : null,+ bot || room2 ? (0, import_react42.createElement)("button", { type: "button", className: "bt-round", "aria-label": copied ? t("Copied conversation") : t("Share conversation"), title: copied ? t("Copied") : t("Copy conversation as Markdown"), onClick: share }, copied ? (0, import_react42.createElement)("span", { key: "copied", className: "bt-pop-in" }, "✓") : (0, import_react42.createElement)(ShareIcon)) : null,+ hasStrip ? null : (0, import_react42.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("Close details"), onClick: close }, (0, import_react42.createElement)(CloseIcon)));if (!bot && !room2) {return [- (0, import_react41.createElement)(import_react41.Fragment, { key: "top" }, top),- (0, import_react41.createElement)("div", { key: "body", className: "bt-drawer-body" }, (0, import_react41.createElement)("div", { className: "bt-muted" }, t("This conversation is not part of your Bot team.")))+ (0, import_react42.createElement)(import_react42.Fragment, { key: "top" }, top),+ (0, import_react42.createElement)("div", { key: "body", className: "bt-drawer-body" }, (0, import_react42.createElement)("div", { className: "bt-muted" }, t("This conversation is not part of your Bot team.")))];}const current = bot?.name ?? room2.name;@@ -16295,12 +16634,12 @@ function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, roster, aconst subtitle = bot ? bot.role : roomSubtitle(room2, roster);const tabs = bot ? ["details", "browser"] : ["details"];return [- (0, import_react41.createElement)(import_react41.Fragment, { key: "top" }, top),- (0, import_react41.createElement)(+ (0, import_react42.createElement)(import_react42.Fragment, { key: "top" }, top),+ (0, import_react42.createElement)("div",{ key: "id", className: "bt-drawer-id", "data-move": side },- bot ? (0, import_react41.createElement)(BotAvatar, { bot, size: 64, state: botState(running, doing, roster.questions?.[part] !== void 0), main: isMainBot, badge: false, gaze: true, pokeable: true }) : (0, import_react41.createElement)(MemberPile, { room: room2, roster }),- editing ? (0, import_react41.createElement)("input", {+ bot ? (0, import_react42.createElement)(BotAvatar, { bot, size: 64, state: botState(running, doing, roster.questions?.[part] !== void 0), main: isMainBot, badge: false, gaze: true, pokeable: true }) : (0, import_react42.createElement)(MemberPile, { room: room2, roster }),+ editing ? (0, import_react42.createElement)("input", {className: "bt-drawer-name-input",autoFocus: true,value: draftName,@@ -16315,50 +16654,50 @@ function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, roster, asetEditing(false);}}- }) : (0, import_react41.createElement)("button", { type: "button", className: "bt-drawer-name", "aria-label": t("Rename {name}", { name: current }), title: t("Rename"), onClick: () => {+ }) : (0, import_react42.createElement)("button", { type: "button", className: "bt-drawer-name", "aria-label": t("Rename {name}", { name: current }), title: t("Rename"), onClick: () => {setDraftName(room2 && !room2.named ? "" : current);setEditing(true);} }, current),- subtitle ? (0, import_react41.createElement)("span", { className: "bt-drawer-role" }, subtitle) : null+ subtitle ? (0, import_react42.createElement)("span", { className: "bt-drawer-role" }, subtitle) : null),- tabs.length > 1 ? (0, import_react41.createElement)(+ tabs.length > 1 ? (0, import_react42.createElement)("div",{ key: "tabs", ref: glide.box, className: "bt-tabs", role: "tablist", "data-move": side },- (0, import_react41.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),- tabs.map((key) => (0, import_react41.createElement)("button", { key, type: "button", role: "tab", className: "bt-tab", "aria-selected": tab === key, onClick: () => setTab(key) }, t(TAB_LABELS[key])))+ (0, import_react42.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),+ tabs.map((key) => (0, import_react42.createElement)("button", { key, type: "button", role: "tab", className: "bt-tab", "aria-selected": tab === key, onClick: () => setTab(key) }, t(TAB_LABELS[key])))) : null,- (0, import_react41.createElement)(+ (0, import_react42.createElement)("div",{ key: `body:${tab}`, className: "bt-drawer-body", "data-move": move },errorLine,- room2 && tab === "details" ? (0, import_react41.createElement)(GroupOverview, { room: room2, roster, actions, usage, useWork, openSettings: () => setView("settings") }) : null,+ room2 && tab === "details" ? (0, import_react42.createElement)(GroupOverview, { room: room2, roster, actions, usage, useWork, openSettings: () => setView("settings") }) : null,bot && tab === "details" ? [- (0, import_react41.createElement)(RunStats, { key: "stats", bot, part, running, actions }),- (0, import_react41.createElement)(+ (0, import_react42.createElement)(RunStats, { key: "stats", bot, part, running, actions }),+ (0, import_react42.createElement)("div",{ key: "model", className: "bt-drawer-model" },- (0, import_react41.createElement)("div", { className: "bt-section-title" }, t("Model")),- (0, import_react41.createElement)(ModelMenu, { bot, roster, actions, run: run2, wide: true }),- modelOf(bot, roster) ? null : (0, import_react41.createElement)("div", { className: "bt-note" }, t("Pick a model and {name} can start.", { name: bot.name }))+ (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Model")),+ (0, import_react42.createElement)(ModelMenu, { bot, roster, actions, run: run2, wide: true }),+ modelOf(bot, roster) ? null : (0, import_react42.createElement)("div", { className: "bt-note" }, t("Pick a model and {name} can start.", { name: bot.name }))),- (0, import_react41.createElement)(PermissionRow, { key: "permission", bot, roster, actions, run: run2 }),- (0, import_react41.createElement)(+ (0, import_react42.createElement)(PermissionRow, { key: "permission", bot, roster, actions, run: run2 }),+ (0, import_react42.createElement)("div",{ key: "folder", className: "bt-drawer-model" },- (0, import_react41.createElement)("div", { className: "bt-section-title" }, t("Working folder")),- (0, import_react41.createElement)(FolderMenu, { value: bot.workDir, actions, run: run2, wide: true, onPick: (workDir) => run2(actions.updateBot(bot.id, { workDir })) })+ (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Working folder")),+ (0, import_react42.createElement)(FolderMenu, { value: bot.workDir, actions, run: run2, wide: true, onPick: (workDir) => run2(actions.updateBot(bot.id, { workDir })) })),- bot.instructions ? (0, import_react41.createElement)(About, { key: "about", text: bot.instructions }) : (0, import_react41.createElement)("button", { key: "about", type: "button", className: "bt-more", onClick: () => setView("settings") }, t("Add instructions in Bot settings")),- roster.memory === false ? null : (0, import_react41.createElement)(MemoryRow, { key: "memory", owner: { id: bot.id, name: bot.name }, actions }),- usage ? (0, import_react41.createElement)(+ bot.instructions ? (0, import_react42.createElement)(About, { key: "about", text: bot.instructions }) : (0, import_react42.createElement)("button", { key: "about", type: "button", className: "bt-more", onClick: () => setView("settings") }, t("Add instructions in Bot settings")),+ roster.memory === false ? null : (0, import_react42.createElement)(MemoryRow, { key: "memory", owner: { id: bot.id, name: bot.name }, actions }),+ usage ? (0, import_react42.createElement)("div",{ key: "usage" },- (0, import_react41.createElement)("div", { className: "bt-section-title" }, t("Usage")),- (0, import_react41.createElement)("div", { className: "bt-kv" }, (0, import_react41.createElement)("span", null, bot.name), (0, import_react41.createElement)("span", null, usage))+ (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Usage")),+ (0, import_react42.createElement)("div", { className: "bt-kv" }, (0, import_react42.createElement)("span", null, bot.name), (0, import_react42.createElement)("span", null, usage))) : null,- (0, import_react41.createElement)(ScheduleSummary, { key: "routines", bot, actions })+ (0, import_react42.createElement)(ScheduleSummary, { key: "routines", bot, actions })] : null,- bot && tab === "browser" ? (0, import_react41.createElement)(BrowserCards, { bot, sessionId, roster, actions, useBrowserTabs, useBrowserPages }) : null+ bot && tab === "browser" ? (0, import_react42.createElement)(BrowserCards, { bot, sessionId, roster, actions, useBrowserTabs, useBrowserPages }) : null)];}@@ -16369,7 +16708,7 @@ function rectsOverlap(a, b) {}// src/client/browser-pane.js-var import_react42 = require("react");+var import_react43 = require("react");var import_react_dom8 = require("react-dom");var PANEL_LINGER_MS = 300;var WIDTH_KEY = STORAGE.browserWidth;@@ -16386,10 +16725,10 @@ var EMPTY_TABS2 = { ids: [], active: null };var SPRING_LEAD2 = springEasing(576, 39.4);var SPRING_TRAIL2 = springEasing(144, 19.7);var icon = (paths) => function BrowserIcon() {- return (0, import_react42.createElement)(+ return (0, import_react43.createElement)("svg",{ width: 16, height: 16, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },- paths.map((d, index) => (0, import_react42.createElement)("path", { key: index, d }))+ paths.map((d, index) => (0, import_react43.createElement)("path", { key: index, d })));};var GlobeIcon = icon(["M10 3a7 7 0 1 0 0 14 7 7 0 0 0 0-14z", "M3 10h14", "M10 3c2 2.2 2.9 4.5 2.9 7S12 14.8 10 17c-2-2.2-2.9-4.5-2.9-7S8 5.2 10 3z"]);@@ -16404,9 +16743,9 @@ var ImportIcon = icon(["M10 3.5v8.5", "M6 8.5l4 4 4-4", "M4.5 14v1.5a1.5 1.5 0 0var FileIcon = icon(["M6 3.5h5.5L14.5 6.5v10H6z", "M11 3.5v3.5h3.5"]);var WindowIcon = icon(["M4 5h12v9.5H4z", "M4 7.5h12"]);function Favicon({ src, className }) {- const [failed, setFailed] = (0, import_react42.useState)(null);- if (!src || failed === src) return (0, import_react42.createElement)("span", { className: `${className} bt-ptab-globe` }, (0, import_react42.createElement)(GlobeIcon));- return (0, import_react42.createElement)("img", { className, src, alt: "", "aria-hidden": true, onError: () => setFailed(src) });+ const [failed, setFailed] = (0, import_react43.useState)(null);+ if (!src || failed === src) return (0, import_react43.createElement)("span", { className: `${className} bt-ptab-globe` }, (0, import_react43.createElement)(GlobeIcon));+ return (0, import_react43.createElement)("img", { className, src, alt: "", "aria-hidden": true, onError: () => setFailed(src) });}var savedWidth = () => {try {@@ -16461,9 +16800,9 @@ var shortAddress = (url) => String(url ?? "").replace(/^https?:\/\//i, "").replavar reducedMotion2 = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;var tabLabel = (page) => page.title || shortAddress(page.url) || t("New tab");function PanelMenu({ items, className, "aria-label": label }) {- const [open, setOpen] = (0, import_react42.useState)(false);- const wrap = (0, import_react42.useRef)(null);- (0, import_react42.useEffect)(() => {+ const [open, setOpen] = (0, import_react43.useState)(false);+ const wrap = (0, import_react43.useRef)(null);+ (0, import_react43.useEffect)(() => {if (!open) return void 0;const onDown = (event) => {if (wrap.current && !wrap.current.contains(event.target)) setOpen(false);@@ -16481,10 +16820,10 @@ function PanelMenu({ items, className, "aria-label": label }) {};}, [open]);if (items.length === 0) return null;- return (0, import_react42.createElement)(+ return (0, import_react43.createElement)("span",{ className: "bt-pmenu", ref: wrap },- (0, import_react42.createElement)("button", {+ (0, import_react43.createElement)("button", {type: "button",className,"aria-label": label,@@ -16492,11 +16831,11 @@ function PanelMenu({ items, className, "aria-label": label }) {"aria-haspopup": "menu","aria-expanded": open,onClick: () => setOpen((value) => !value)- }, (0, import_react42.createElement)(DotsIcon)),- open ? (0, import_react42.createElement)(+ }, (0, import_react43.createElement)(DotsIcon)),+ open ? (0, import_react43.createElement)("div",{ className: "bt-pmenu-pop", role: "menu" },- items.map((item, index) => item.sep ? (0, import_react42.createElement)("span", { key: `sep-${index}`, className: "bt-pmenu-sep", role: "separator" }) : (0, import_react42.createElement)("button", {+ items.map((item, index) => item.sep ? (0, import_react43.createElement)("span", { key: `sep-${index}`, className: "bt-pmenu-sep", role: "separator" }) : (0, import_react43.createElement)("button", {key: item.key,type: "button",role: "menuitem",@@ -16505,7 +16844,7 @@ function PanelMenu({ items, className, "aria-label": label }) {setOpen(false);item.onPick();}- }, (0, import_react42.createElement)(item.icon), (0, import_react42.createElement)("span", null, item.label)))+ }, (0, import_react43.createElement)(item.icon), (0, import_react43.createElement)("span", null, item.label)))) : null);}@@ -16531,12 +16870,12 @@ function menuItemFor(key, actions, subject) {var sideTitle = (chat) => chat?.entries?.[0]?.question?.trim() || t("Side chat");function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, reading, onView, actions, useBrowserPages }) {const pages = useBrowserPages((map) => map);- const wrap = (0, import_react42.useRef)(null);- const ind = (0, import_react42.useRef)(null);- const spot = (0, import_react42.useRef)(null);- const under = (0, import_react42.useRef)(null);- const watcher = (0, import_react42.useRef)(null);- (0, import_react42.useLayoutEffect)(() => {+ const wrap = (0, import_react43.useRef)(null);+ const ind = (0, import_react43.useRef)(null);+ const spot = (0, import_react43.useRef)(null);+ const under = (0, import_react43.useRef)(null);+ const watcher = (0, import_react43.useRef)(null);+ (0, import_react43.useLayoutEffect)(() => {const box = wrap.current;const capsule = ind.current;if (!box || !capsule) return void 0;@@ -16569,7 +16908,7 @@ function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, rtrail.cancel();};});- (0, import_react42.useEffect)(() => {+ (0, import_react43.useEffect)(() => {const box = wrap.current;if (!box) return void 0;const observer = new ResizeObserver(() => {@@ -16593,13 +16932,13 @@ function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, rcanTerminal: actions.canOpenTerminal?.() === true,canFiles: actions.canOpenFiles?.() === true}).map((key) => menuItemFor(key, actions, subject));- return (0, import_react42.createElement)(+ return (0, import_react43.createElement)("div",{ className: "bt-ptabs", role: "tablist", "aria-label": t("Panel tabs") },- (0, import_react42.createElement)(+ (0, import_react43.createElement)("div",{ className: "bt-ptabs-in", ref: wrap },- (0, import_react42.createElement)(+ (0, import_react43.createElement)("button",{type: "button",@@ -16609,13 +16948,13 @@ function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, rtitle: bot.name,onClick: () => onView("details")},- (0, import_react42.createElement)(BotMark, { bot, size: 20, state: reading ? "searching" : "idle" }),- view === "details" ? (0, import_react42.createElement)("span", { className: "bt-ptab-name" }, bot.name) : null+ (0, import_react43.createElement)(BotMark, { bot, size: 20, state: reading ? "searching" : "idle" }),+ view === "details" ? (0, import_react43.createElement)("span", { className: "bt-ptab-name" }, bot.name) : null),ids.map((tabId) => {const page = pages[tabId] ?? EMPTY_PAGE;const on = view === "browser" && tabId === active;- return (0, import_react42.createElement)(+ return (0, import_react43.createElement)("button",{key: tabId,@@ -16636,9 +16975,9 @@ function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, r}}},- (0, import_react42.createElement)(Favicon, { src: page.favicon, className: "bt-ptab-fav" }),- (0, import_react42.createElement)("span", { className: "bt-ptab-title" }, tabLabel(page)),- (0, import_react42.createElement)("span", {+ (0, import_react43.createElement)(Favicon, { src: page.favicon, className: "bt-ptab-fav" }),+ (0, import_react43.createElement)("span", { className: "bt-ptab-title" }, tabLabel(page)),+ (0, import_react43.createElement)("span", {className: "bt-ptab-x",role: "button","aria-label": t("Close tab"),@@ -16652,7 +16991,7 @@ function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, r}),sides.map((chat) => {const on = view === "side" && chat.id === side;- return (0, import_react42.createElement)(+ return (0, import_react43.createElement)("button",{key: chat.id,@@ -16670,9 +17009,9 @@ function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, r}}},- (0, import_react42.createElement)("span", { className: "bt-ptab-globe", "aria-hidden": true }, (0, import_react42.createElement)(SideIcon)),- (0, import_react42.createElement)("span", { className: "bt-ptab-title" }, sideTitle(chat)),- (0, import_react42.createElement)("span", {+ (0, import_react43.createElement)("span", { className: "bt-ptab-globe", "aria-hidden": true }, (0, import_react43.createElement)(SideIcon)),+ (0, import_react43.createElement)("span", { className: "bt-ptab-title" }, sideTitle(chat)),+ (0, import_react43.createElement)("span", {className: "bt-ptab-x",role: "button","aria-label": t("Close side chat"),@@ -16684,30 +17023,30 @@ function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, r}, "×"));}),- (0, import_react42.createElement)("span", { ref: ind, className: "bt-ptab-ind", "aria-hidden": true })+ (0, import_react43.createElement)("span", { ref: ind, className: "bt-ptab-ind", "aria-hidden": true })),// The `···` and Close stay outside the scrolling tabs, so a narrow panel keeps both.- (0, import_react42.createElement)(PanelMenu, { items, className: "bt-ptab-new", "aria-label": t("More") }),- (0, import_react42.createElement)("button", { type: "button", className: "bt-icon-btn bt-ptab-close", "aria-label": t("Close panel"), title: t("Close panel"), onClick: () => actions.closePanel() }, (0, import_react42.createElement)(CloseIcon2))+ (0, import_react43.createElement)(PanelMenu, { items, className: "bt-ptab-new", "aria-label": t("More") }),+ (0, import_react43.createElement)("button", { type: "button", className: "bt-icon-btn bt-ptab-close", "aria-label": t("Close panel"), title: t("Close panel"), onClick: () => actions.closePanel() }, (0, import_react43.createElement)(CloseIcon2)));}function BrowserView({ bot, tabId, leaving, landed, actions, useBrowserPages, hold }) {const page = useBrowserPages((pages) => pages[tabId ?? ""]) ?? EMPTY_PAGE;- const frame = (0, import_react42.useRef)(null);- const input = (0, import_react42.useRef)(null);- const [draft, setDraft] = (0, import_react42.useState)(null);- const [covered, setCovered] = (0, import_react42.useState)(false);+ const frame = (0, import_react43.useRef)(null);+ const input = (0, import_react43.useRef)(null);+ const [draft, setDraft] = (0, import_react43.useState)(null);+ const [covered, setCovered] = (0, import_react43.useState)(false);const imports = actions.browserImport;- const [flow, setFlow] = (0, import_react42.useState)(null);- const flowRef = (0, import_react42.useRef)(null);- const [sources, setSources] = (0, import_react42.useState)(null);- const [busy, setBusy] = (0, import_react42.useState)(false);+ const [flow, setFlow] = (0, import_react43.useState)(null);+ const flowRef = (0, import_react43.useRef)(null);+ const [sources, setSources] = (0, import_react43.useState)(null);+ const [busy, setBusy] = (0, import_react43.useState)(false);const setFlowTracked = (next) => {flowRef.current = typeof next === "function" ? next(flowRef.current) : next;setFlow(flowRef.current);};const showGuest = landed && !leaving && !covered && Boolean(page.url) && !page.error && flow === null;- (0, import_react42.useEffect)(() => {+ (0, import_react43.useEffect)(() => {const update = () => {const panel = frame.current?.getBoundingClientRect();const overlaps2 = panel && [...document.querySelectorAll('[role="dialog"],[role="menu"],[role="listbox"]')].some((element) => rectsOverlap(panel, element.getBoundingClientRect()));@@ -16722,7 +17061,7 @@ function BrowserView({ bot, tabId, leaving, landed, actions, useBrowserPages, howindow.removeEventListener("resize", update);};}, []);- (0, import_react42.useEffect)(() => {+ (0, import_react43.useEffect)(() => {setFlowTracked(null);return () => {const id = typeof flowRef.current === "object" && flowRef.current !== null ? flowRef.current.id : null;@@ -16766,7 +17105,7 @@ function BrowserView({ bot, tabId, leaving, landed, actions, useBrowserPages, hoif (id) void imports?.cancel(id).catch(() => {});};- (0, import_react42.useLayoutEffect)(() => {+ (0, import_react43.useLayoutEffect)(() => {const element = frame.current;if (!element || leaving || !tabId) {void actions.browserShow(null);@@ -16792,7 +17131,7 @@ function BrowserView({ bot, tabId, leaving, landed, actions, useBrowserPages, howindow.removeEventListener("resize", schedule);};}, [tabId, showGuest, leaving]);- (0, import_react42.useEffect)(() => {+ (0, import_react43.useEffect)(() => {setDraft(null);if (landed && !page.url) input.current?.focus();}, [tabId, landed]);@@ -16808,38 +17147,38 @@ function BrowserView({ bot, tabId, leaving, landed, actions, useBrowserPages, ho};const editing = draft !== null;const secure = /^https:/i.test(page.url);- return (0, import_react42.createElement)(+ return (0, import_react43.createElement)("div",{ className: "bt-panel-view bt-panel-browser", "aria-label": t("{name}'s browser", { name: bot.name }) },- actions.browserTakeover ? (0, import_react42.createElement)(+ actions.browserTakeover ? (0, import_react43.createElement)("div",{ className: "bt-browser-takeover", "data-held": hold?.by === "user" || void 0 },- (0, import_react42.createElement)("span", null, hold?.by === "user" ? t("You control this browser") : hold?.by === "bot" ? t("The Bot handed this browser to you: {reason}", { reason: hold.reason }) : t("The Bot controls this browser")),- hold?.by ? (0, import_react42.createElement)("button", { type: "button", onClick: () => void actions.browserGiveBack(bot.id) }, t("Give back")) : (0, import_react42.createElement)(+ (0, import_react43.createElement)("span", null, hold?.by === "user" ? t("You control this browser") : hold?.by === "bot" ? t("The Bot handed this browser to you: {reason}", { reason: hold.reason }) : t("The Bot controls this browser")),+ hold?.by ? (0, import_react43.createElement)("button", { type: "button", onClick: () => void actions.browserGiveBack(bot.id) }, t("Give back")) : (0, import_react43.createElement)("span",{ className: "bt-browser-takeover-actions" },- (0, import_react42.createElement)("button", { type: "button", onClick: () => void actions.browserTakeover(bot.id) }, t("Take over")),- (0, import_react42.createElement)("button", { type: "button", onClick: () => void actions.browserStop(bot.id) }, t("Stop"))+ (0, import_react43.createElement)("button", { type: "button", onClick: () => void actions.browserTakeover(bot.id) }, t("Take over")),+ (0, import_react43.createElement)("button", { type: "button", onClick: () => void actions.browserStop(bot.id) }, t("Stop")))) : null,- (0, import_react42.createElement)(+ (0, import_react43.createElement)("div",{ className: "bt-browser-bar" },- (0, import_react42.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back"), title: t("Back"), disabled: !page.canGoBack, onClick: () => actions.browserCommand(tabId, "back") }, (0, import_react42.createElement)(BackIcon)),- (0, import_react42.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Forward"), title: t("Forward"), disabled: !page.canGoForward, onClick: () => actions.browserCommand(tabId, "forward") }, (0, import_react42.createElement)(ForwardIcon)),- (0, import_react42.createElement)("button", {+ (0, import_react43.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back"), title: t("Back"), disabled: !page.canGoBack, onClick: () => actions.browserCommand(tabId, "back") }, (0, import_react43.createElement)(BackIcon)),+ (0, import_react43.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Forward"), title: t("Forward"), disabled: !page.canGoForward, onClick: () => actions.browserCommand(tabId, "forward") }, (0, import_react43.createElement)(ForwardIcon)),+ (0, import_react43.createElement)("button", {type: "button",className: "bt-icon-btn",disabled: !page.url,"aria-label": page.loading ? t("Stop") : t("Reload"),title: page.loading ? t("Stop") : t("Reload"),onClick: () => actions.browserCommand(tabId, page.loading ? "stop" : "reload")- }, (0, import_react42.createElement)(page.loading ? StopIcon : ReloadIcon)),- (0, import_react42.createElement)(+ }, (0, import_react43.createElement)(page.loading ? StopIcon : ReloadIcon)),+ (0, import_react43.createElement)("form",{ className: "bt-browser-address", onSubmit: go, "data-editing": editing || void 0 },- (0, import_react42.createElement)("span", { className: "bt-browser-scheme", "aria-hidden": true }, (0, import_react42.createElement)(secure && !editing ? LockIcon2 : GlobeIcon)),- (0, import_react42.createElement)("input", {+ (0, import_react43.createElement)("span", { className: "bt-browser-scheme", "aria-hidden": true }, (0, import_react43.createElement)(secure && !editing ? LockIcon2 : GlobeIcon)),+ (0, import_react43.createElement)("input", {ref: input,type: "text",spellCheck: false,@@ -16863,14 +17202,14 @@ function BrowserView({ bot, tabId, leaving, landed, actions, useBrowserPages, ho}})),- (0, import_react42.createElement)("button", {+ (0, import_react43.createElement)("button", {type: "button",className: "bt-icon-btn","aria-label": t("New browser tab"),title: t("New browser tab"),onClick: () => actions.browserNewTab(bot.id)- }, (0, import_react42.createElement)(PlusTabIcon)),- imports ? (0, import_react42.createElement)("button", {+ }, (0, import_react43.createElement)(PlusTabIcon)),+ imports ? (0, import_react43.createElement)("button", {type: "button",className: "bt-icon-btn bt-import-btn","aria-label": t("Import cookies"),@@ -16881,29 +17220,29 @@ function BrowserView({ bot, tabId, leaving, landed, actions, useBrowserPages, hoif (flow === "menu") setFlowTracked(null);else openImport();}- }, (0, import_react42.createElement)(ImportIcon)) : null,- page.loading ? (0, import_react42.createElement)("span", { className: "bt-browser-progress", "aria-hidden": true }) : null+ }, (0, import_react43.createElement)(ImportIcon)) : null,+ page.loading ? (0, import_react43.createElement)("span", { className: "bt-browser-progress", "aria-hidden": true }) : null),- (0, import_react42.createElement)(+ (0, import_react43.createElement)("div",{ ref: frame, className: "bt-browser-frame", "data-guest": showGuest || void 0 },- flow === "menu" ? (0, import_react42.createElement)(ImportMenu, { sources, busy, onFile: pickFile, onSource: pickSource, onClose: () => setFlowTracked(null) }) : null,- typeof flow === "object" && flow !== null ? (0, import_react42.createElement)(ImportCard, { flow, page, busy, onApply: applyImport, onCancel: cancelImport, onCloseAndImport: closeAndImport, onDone: () => setFlowTracked(null), onReload: () => actions.browserCommand(tabId, "reload") }) : null,- flow === null && page.error ? (0, import_react42.createElement)(+ flow === "menu" ? (0, import_react43.createElement)(ImportMenu, { sources, busy, onFile: pickFile, onSource: pickSource, onClose: () => setFlowTracked(null) }) : null,+ typeof flow === "object" && flow !== null ? (0, import_react43.createElement)(ImportCard, { flow, page, busy, onApply: applyImport, onCancel: cancelImport, onCloseAndImport: closeAndImport, onDone: () => setFlowTracked(null), onReload: () => actions.browserCommand(tabId, "reload") }) : null,+ flow === null && page.error ? (0, import_react43.createElement)("div",{ className: "bt-browser-empty" },- (0, import_react42.createElement)("div", { className: "bt-browser-empty-title" }, t("This page didn’t load")),- (0, import_react42.createElement)("div", { className: "bt-browser-empty-text" }, t(page.error)),- page.url ? (0, import_react42.createElement)("button", { type: "button", className: "bt-browser-retry", onClick: () => {+ (0, import_react43.createElement)("div", { className: "bt-browser-empty-title" }, t("This page didn’t load")),+ (0, import_react43.createElement)("div", { className: "bt-browser-empty-text" }, t(page.error)),+ page.url ? (0, import_react43.createElement)("button", { type: "button", className: "bt-browser-retry", onClick: () => {void actions.browserNavigate(tabId, page.url);} }, t("Try again")) : null- ) : flow === null && !page.url ? (0, import_react42.createElement)(+ ) : flow === null && !page.url ? (0, import_react43.createElement)("div",{ className: "bt-browser-empty" },- (0, import_react42.createElement)(BotMark, { bot, size: 48, state: "idle", live: true }),- (0, import_react42.createElement)("div", { className: "bt-browser-empty-title" }, t("{name}'s browser", { name: bot.name })),- (0, import_react42.createElement)("div", { className: "bt-browser-empty-text" }, t("Open a page here and {name} can read it with you. Logins and cookies stay with {name}; other Bots never see them.", { name: bot.name })),- imports ? (0, import_react42.createElement)("button", { type: "button", className: "bt-browser-retry", onClick: openImport }, t("Import cookies")) : null+ (0, import_react43.createElement)(BotMark, { bot, size: 48, state: "idle", live: true }),+ (0, import_react43.createElement)("div", { className: "bt-browser-empty-title" }, t("{name}'s browser", { name: bot.name })),+ (0, import_react43.createElement)("div", { className: "bt-browser-empty-text" }, t("Open a page here and {name} can read it with you. Logins and cookies stay with {name}; other Bots never see them.", { name: bot.name })),+ imports ? (0, import_react43.createElement)("button", { type: "button", className: "bt-browser-retry", onClick: openImport }, t("Import cookies")) : null) : null));@@ -16915,25 +17254,25 @@ function importError(error) {return String(error);}function ImportMenu({ sources, busy, onFile, onSource, onClose }) {- (0, import_react42.useEffect)(() => {+ (0, import_react43.useEffect)(() => {const close = (event) => {if (event.key === "Escape") onClose();};window.addEventListener("keydown", close);return () => window.removeEventListener("keydown", close);}, [onClose]);- return (0, import_react42.createElement)(+ return (0, import_react43.createElement)("div",{ className: "bt-import-menu", role: "menu", "aria-label": t("Import cookies") },- (0, import_react42.createElement)("div", { className: "bt-import-menu-title" }, t("Import cookies")),- (0, import_react42.createElement)(+ (0, import_react43.createElement)("div", { className: "bt-import-menu-title" }, t("Import cookies")),+ (0, import_react43.createElement)("button",{ type: "button", className: "bt-import-item", role: "menuitem", disabled: busy, onClick: onFile },- (0, import_react42.createElement)(FileIcon, { className: "bt-import-item-icon" }),- (0, import_react42.createElement)("span", { className: "bt-import-item-name" }, t("From a file…")),- (0, import_react42.createElement)("span", { className: "bt-import-item-sub" }, t("cookies.txt, JSON, storageState"))+ (0, import_react43.createElement)(FileIcon, { className: "bt-import-item-icon" }),+ (0, import_react43.createElement)("span", { className: "bt-import-item-name" }, t("From a file…")),+ (0, import_react43.createElement)("span", { className: "bt-import-item-sub" }, t("cookies.txt, JSON, storageState"))),- sources === null ? (0, import_react42.createElement)("div", { className: "bt-import-menu-note" }, t("Loading…")) : sources.length === 0 ? (0, import_react42.createElement)("div", { className: "bt-import-menu-note" }, t("No browsers found")) : sources.map((source) => (0, import_react42.createElement)(+ sources === null ? (0, import_react43.createElement)("div", { className: "bt-import-menu-note" }, t("Loading…")) : sources.length === 0 ? (0, import_react43.createElement)("div", { className: "bt-import-menu-note" }, t("No browsers found")) : sources.map((source) => (0, import_react43.createElement)("button",{key: source.id,@@ -16943,83 +17282,83 @@ function ImportMenu({ sources, busy, onFile, onSource, onClose }) {disabled: busy,onClick: () => onSource(source)},- (0, import_react42.createElement)(WindowIcon, { className: "bt-import-item-icon" }),- (0, import_react42.createElement)("span", { className: "bt-import-item-name" }, source.label),- (0, import_react42.createElement)("span", { className: "bt-import-item-sub" }, t("Copy of its cookies"))+ (0, import_react43.createElement)(WindowIcon, { className: "bt-import-item-icon" }),+ (0, import_react43.createElement)("span", { className: "bt-import-item-name" }, source.label),+ (0, import_react43.createElement)("span", { className: "bt-import-item-sub" }, t("Copy of its cookies")))));}function ImportCard({ flow, page, busy, onApply, onCancel, onCloseAndImport, onDone, onReload }) {const { stage } = flow;if (stage === "running") {- return (0, import_react42.createElement)("div", { className: "bt-import-card" }, (0, import_react42.createElement)(+ return (0, import_react43.createElement)("div", { className: "bt-import-card" }, (0, import_react43.createElement)("div",{ className: "bt-import-box" },- (0, import_react42.createElement)("div", { className: "bt-import-title" }, t("{name} is running", { name: flow.source.name })),- (0, import_react42.createElement)("div", { className: "bt-import-text" }, t("It must close for a moment so its cookies can be copied. It will reopen with your tabs.")),- (0, import_react42.createElement)(+ (0, import_react43.createElement)("div", { className: "bt-import-title" }, t("{name} is running", { name: flow.source.name })),+ (0, import_react43.createElement)("div", { className: "bt-import-text" }, t("It must close for a moment so its cookies can be copied. It will reopen with your tabs.")),+ (0, import_react43.createElement)("div",{ className: "bt-import-actions" },- (0, import_react42.createElement)("button", { type: "button", className: "bt-import-primary", disabled: busy, onClick: onCloseAndImport }, busy ? t("Closing…") : t("Close {name} and import", { name: flow.source.name })),- (0, import_react42.createElement)("button", { type: "button", className: "bt-import-plain", disabled: busy, onClick: onCancel }, t("Cancel"))+ (0, import_react43.createElement)("button", { type: "button", className: "bt-import-primary", disabled: busy, onClick: onCloseAndImport }, busy ? t("Closing…") : t("Close {name} and import", { name: flow.source.name })),+ (0, import_react43.createElement)("button", { type: "button", className: "bt-import-plain", disabled: busy, onClick: onCancel }, t("Cancel")))));}if (stage === "error") {- return (0, import_react42.createElement)("div", { className: "bt-import-card" }, (0, import_react42.createElement)(+ return (0, import_react43.createElement)("div", { className: "bt-import-card" }, (0, import_react43.createElement)("div",{ className: "bt-import-box" },- (0, import_react42.createElement)("div", { className: "bt-import-title" }, t("Import failed")),- (0, import_react42.createElement)("div", { className: "bt-import-text" }, flow.message),- (0, import_react42.createElement)("div", { className: "bt-import-actions" }, (0, import_react42.createElement)("button", { type: "button", className: "bt-import-plain", onClick: onCancel }, t("Close")))+ (0, import_react43.createElement)("div", { className: "bt-import-title" }, t("Import failed")),+ (0, import_react43.createElement)("div", { className: "bt-import-text" }, flow.message),+ (0, import_react43.createElement)("div", { className: "bt-import-actions" }, (0, import_react43.createElement)("button", { type: "button", className: "bt-import-plain", onClick: onCancel }, t("Close")))));}if (stage === "result") {const { report } = flow;const problems = [...report.dropped ?? [], ...report.failed ?? []];- return (0, import_react42.createElement)("div", { className: "bt-import-card" }, (0, import_react42.createElement)(+ return (0, import_react43.createElement)("div", { className: "bt-import-card" }, (0, import_react43.createElement)("div",{ className: "bt-import-box" },- (0, import_react42.createElement)("div", { className: "bt-import-title" }, report.stored > 0 ? t("Imported {count} cookies", { count: report.stored }) : t("No cookies were stored")),- flow.label ? (0, import_react42.createElement)("div", { className: "bt-import-sub" }, flow.label) : null,- problems.length ? (0, import_react42.createElement)(+ (0, import_react43.createElement)("div", { className: "bt-import-title" }, report.stored > 0 ? t("Imported {count} cookies", { count: report.stored }) : t("No cookies were stored")),+ flow.label ? (0, import_react43.createElement)("div", { className: "bt-import-sub" }, flow.label) : null,+ problems.length ? (0, import_react43.createElement)("div",{ className: "bt-import-list" },- problems.slice(0, 8).map((item, index) => (0, import_react42.createElement)(+ problems.slice(0, 8).map((item, index) => (0, import_react43.createElement)("div",{ key: index, className: "bt-import-line" },- (0, import_react42.createElement)("span", { className: "bt-import-line-name" }, item.name ?? "—"),- (0, import_react42.createElement)("span", { className: "bt-import-line-reason" }, item.reason)+ (0, import_react43.createElement)("span", { className: "bt-import-line-name" }, item.name ?? "—"),+ (0, import_react43.createElement)("span", { className: "bt-import-line-reason" }, item.reason))),- problems.length > 8 ? (0, import_react42.createElement)("div", { className: "bt-import-line" }, (0, import_react42.createElement)("span", { className: "bt-import-line-reason" }, t("and {count} more", { count: problems.length - 8 }))) : null+ problems.length > 8 ? (0, import_react43.createElement)("div", { className: "bt-import-line" }, (0, import_react43.createElement)("span", { className: "bt-import-line-reason" }, t("and {count} more", { count: problems.length - 8 }))) : null) : null,- (0, import_react42.createElement)(+ (0, import_react43.createElement)("div",{ className: "bt-import-actions" },- page.url ? (0, import_react42.createElement)("button", { type: "button", className: "bt-import-plain", onClick: onReload }, t("Reload the page")) : null,- (0, import_react42.createElement)("button", { type: "button", className: "bt-import-primary", onClick: onDone }, t("Done"))+ page.url ? (0, import_react43.createElement)("button", { type: "button", className: "bt-import-plain", onClick: onReload }, t("Reload the page")) : null,+ (0, import_react43.createElement)("button", { type: "button", className: "bt-import-primary", onClick: onDone }, t("Done")))));}const { preview } = flow;- return (0, import_react42.createElement)("div", { className: "bt-import-card" }, (0, import_react42.createElement)(+ return (0, import_react43.createElement)("div", { className: "bt-import-card" }, (0, import_react43.createElement)("div",{ className: "bt-import-box" },- (0, import_react42.createElement)("div", { className: "bt-import-title" }, t("Import {count} cookies", { count: preview.cookies })),- (0, import_react42.createElement)(+ (0, import_react43.createElement)("div", { className: "bt-import-title" }, t("Import {count} cookies", { count: preview.cookies })),+ (0, import_react43.createElement)("div",{ className: "bt-import-sub" },preview.source?.label ?? "",flow.restarted ? ` · ${t("the browser was restarted")}` : ""),- preview.sites.length ? (0, import_react42.createElement)(+ preview.sites.length ? (0, import_react43.createElement)("div",{ className: "bt-import-list" },- preview.sites.map((site) => (0, import_react42.createElement)(+ preview.sites.map((site) => (0, import_react43.createElement)("div",{ key: site.site, className: "bt-import-line" },- (0, import_react42.createElement)("span", { className: "bt-import-line-name" }, site.site),- (0, import_react42.createElement)(+ (0, import_react43.createElement)("span", { className: "bt-import-line-name" }, site.site),+ (0, import_react43.createElement)("span",{ className: "bt-import-line-count" },t("{count}", { count: site.cookies }),@@ -17027,35 +17366,35 @@ function ImportCard({ flow, page, busy, onApply, onCancel, onCloseAndImport, onD)))) : null,- preview.skipped.length ? (0, import_react42.createElement)(+ preview.skipped.length ? (0, import_react43.createElement)("div",{ className: "bt-import-list" },- (0, import_react42.createElement)("div", { className: "bt-import-note" }, t("{count} skipped", { count: preview.skipped.length })),- preview.skipped.slice(0, 5).map((item, index) => (0, import_react42.createElement)(+ (0, import_react43.createElement)("div", { className: "bt-import-note" }, t("{count} skipped", { count: preview.skipped.length })),+ preview.skipped.slice(0, 5).map((item, index) => (0, import_react43.createElement)("div",{ key: index, className: "bt-import-line" },- (0, import_react42.createElement)("span", { className: "bt-import-line-name" }, item.name ?? item.where),- (0, import_react42.createElement)("span", { className: "bt-import-line-reason" }, item.reason)+ (0, import_react43.createElement)("span", { className: "bt-import-line-name" }, item.name ?? item.where),+ (0, import_react43.createElement)("span", { className: "bt-import-line-reason" }, item.reason))),- preview.skipped.length > 5 ? (0, import_react42.createElement)("div", { className: "bt-import-line" }, (0, import_react42.createElement)("span", { className: "bt-import-line-reason" }, t("and {count} more", { count: preview.skipped.length - 5 }))) : null+ preview.skipped.length > 5 ? (0, import_react43.createElement)("div", { className: "bt-import-line" }, (0, import_react43.createElement)("span", { className: "bt-import-line-reason" }, t("and {count} more", { count: preview.skipped.length - 5 }))) : null) : null,- preview.warnings.length ? (0, import_react42.createElement)(+ preview.warnings.length ? (0, import_react43.createElement)("details",{ className: "bt-import-warns" },- (0, import_react42.createElement)("summary", null, t("{count} adjusted", { count: preview.warnings.reduce((n, w) => n + w.count, 0) })),- preview.warnings.map((w, index) => (0, import_react42.createElement)(+ (0, import_react43.createElement)("summary", null, t("{count} adjusted", { count: preview.warnings.reduce((n, w) => n + w.count, 0) })),+ preview.warnings.map((w, index) => (0, import_react43.createElement)("div",{ key: index, className: "bt-import-line" },- (0, import_react42.createElement)("span", { className: "bt-import-line-reason" }, `${w.count} × ${w.message}`)+ (0, import_react43.createElement)("span", { className: "bt-import-line-reason" }, `${w.count} × ${w.message}`)))) : null,- preview.notes.includes("session-cookies") ? (0, import_react42.createElement)("div", { className: "bt-import-note" }, t("Cookies without an expiry stay until the app closes.")) : null,- preview.notes.includes("local-storage-left") ? (0, import_react42.createElement)("div", { className: "bt-import-note" }, t("Some sites also keep sign-in outside cookies; you may need to sign in again there.")) : null,- (0, import_react42.createElement)(+ preview.notes.includes("session-cookies") ? (0, import_react43.createElement)("div", { className: "bt-import-note" }, t("Cookies without an expiry stay until the app closes.")) : null,+ preview.notes.includes("local-storage-left") ? (0, import_react43.createElement)("div", { className: "bt-import-note" }, t("Some sites also keep sign-in outside cookies; you may need to sign in again there.")) : null,+ (0, import_react43.createElement)("div",{ className: "bt-import-actions" },- (0, import_react42.createElement)("button", { type: "button", className: "bt-import-primary", disabled: busy, onClick: onApply }, busy ? t("Importing…") : t("Import")),- (0, import_react42.createElement)("button", { type: "button", className: "bt-import-plain", disabled: busy, onClick: onCancel }, t("Cancel"))+ (0, import_react43.createElement)("button", { type: "button", className: "bt-import-primary", disabled: busy, onClick: onApply }, busy ? t("Importing…") : t("Import")),+ (0, import_react43.createElement)("button", { type: "button", className: "bt-import-plain", disabled: busy, onClick: onCancel }, t("Cancel")))));}@@ -17069,42 +17408,42 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatuconst active = tabState.active;const page = useBrowserPages((pages) => (active ? pages[active] : null) ?? EMPTY_PAGE);const hold = useBrowserHolds?.((map) => bot ? map[bot.id] ?? null : null) ?? null;- const root = (0, import_react42.useRef)(null);- const fly = (0, import_react42.useRef)(null);- const [landed, setLanded] = (0, import_react42.useState)(false);- const [settling, setSettling] = (0, import_react42.useState)(false);- const [width, setWidth] = (0, import_react42.useState)(savedWidth);- const [viewport, setViewport] = (0, import_react42.useState)(() => window.innerWidth);- const [dragging, setDragging] = (0, import_react42.useState)(false);- const [resizing, setResizing] = (0, import_react42.useState)(false);+ const root = (0, import_react43.useRef)(null);+ const fly = (0, import_react43.useRef)(null);+ const [landed, setLanded] = (0, import_react43.useState)(false);+ const [settling, setSettling] = (0, import_react43.useState)(false);+ const [width, setWidth] = (0, import_react43.useState)(savedWidth);+ const [viewport, setViewport] = (0, import_react43.useState)(() => window.innerWidth);+ const [dragging, setDragging] = (0, import_react43.useState)(false);+ const [resizing, setResizing] = (0, import_react43.useState)(false);const instant = dragging || resizing;- const [reading, setReading] = (0, import_react42.useState)(false);+ const [reading, setReading] = (0, import_react43.useState)(false);const overlay = overlayAt(view, viewport);const panelWidth = fitWidth(width ?? (view === "browser" ? DEFAULT_WIDTH : DETAILS_WIDTH), widthRange(view, viewport));- (0, import_react42.useLayoutEffect)(() => {+ (0, import_react43.useLayoutEffect)(() => {if (view === "browser" && width === null) setWidth(DEFAULT_WIDTH);}, [view, width]);- (0, import_react42.useLayoutEffect)(() => {+ (0, import_react43.useLayoutEffect)(() => {chatRoom.hold(instant);}, [instant]);- const [last, setLast] = (0, import_react42.useState)({ view, width: panelWidth });+ const [last, setLast] = (0, import_react43.useState)({ view, width: panelWidth });if (last.view !== view || last.width !== panelWidth) {setLast({ view, width: panelWidth });if (last.view !== view) setSettling(last.width !== panelWidth && !instant);}- const shownView = (0, import_react42.useRef)(view);- (0, import_react42.useLayoutEffect)(() => {+ const shownView = (0, import_react43.useRef)(view);+ (0, import_react43.useLayoutEffect)(() => {const switched = settling && shownView.current !== view;shownView.current = view;if (switched) chatRoom.hold(true);chatRoom.set(leaving || overlay ? null : panelWidth);if (switched) chatRoom.hold(false);}, [view, panelWidth, leaving, overlay]);- (0, import_react42.useEffect)(() => () => {+ (0, import_react43.useEffect)(() => () => {chatRoom.set(null);chatRoom.hold(false);}, []);- (0, import_react42.useEffect)(() => {+ (0, import_react43.useEffect)(() => {let timer;const onResize = () => {setResizing(true);@@ -17118,31 +17457,31 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatuwindow.removeEventListener("resize", onResize);};}, []);- (0, import_react42.useEffect)(() => {+ (0, import_react43.useEffect)(() => {if (!settling) return void 0;const timer = setTimeout(() => setSettling(false), SPRING_SHAPE.duration + 40);return () => clearTimeout(timer);}, [settling, view]);- (0, import_react42.useEffect)(() => {+ (0, import_react43.useEffect)(() => {const timer = setTimeout(() => setLanded(true), 360);return () => clearTimeout(timer);}, []);- (0, import_react42.useEffect)(() => {+ (0, import_react43.useEffect)(() => {if (canBrowse) actions.browserEnsure(bot.id);}, [bot?.id, canBrowse]);- (0, import_react42.useEffect)(() => {+ (0, import_react43.useEffect)(() => {if (view === "browser" && (active === null || !tabState.ids.includes(active))) actions.setPanelView("details");}, [view, active, tabState.ids.length]);- (0, import_react42.useEffect)(() => {+ (0, import_react43.useEffect)(() => {if (pane.view === "side" && sideChat === void 0) actions.setPanelView("details");}, [pane.view, sideChat]);- (0, import_react42.useEffect)(() => {+ (0, import_react43.useEffect)(() => {if (view !== "browser" || leaving) void actions.browserShow?.(null);}, [view, leaving]);- (0, import_react42.useEffect)(() => () => {+ (0, import_react43.useEffect)(() => () => {void actions.browserShow?.(null);}, []);- (0, import_react42.useEffect)(() => {+ (0, import_react43.useEffect)(() => {if (!page.readAt || Date.now() - page.readAt > READ_FLASH_MS) return void 0;setReading(true);const timer = setTimeout(() => setReading(false), READ_FLASH_MS);@@ -17185,7 +17524,7 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatureturn actions[name](...args);};}- (0, import_react42.useLayoutEffect)(() => {+ (0, import_react43.useLayoutEffect)(() => {const move = fly.current;if (!move) return;fly.current = null;@@ -17268,7 +17607,7 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatufor (const name of ends) grip.addEventListener(name, onEnd);};const hasStrip = panelHasStrip(canBrowse, tabState.ids.length, sideChats.length);- return (0, import_react42.createElement)(+ return (0, import_react43.createElement)("aside",{ref: root,@@ -17286,15 +17625,15 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatuif (event.target === event.currentTarget) setLanded(true);}},- leaving || overlay ? null : (0, import_react42.createElement)("div", { className: "bt-panel-grip", role: "separator", "aria-orientation": "vertical", "aria-label": t("Resize panel"), onPointerDown: startResize }),+ leaving || overlay ? null : (0, import_react43.createElement)("div", { className: "bt-panel-grip", role: "separator", "aria-orientation": "vertical", "aria-label": t("Resize panel"), onPointerDown: startResize }),// Over the whole window while dragging: the cursor stays a resize cursor and the// pages underneath (the chat, the guest) see no pointer.- dragging ? (0, import_react_dom8.createPortal)((0, import_react42.createElement)("div", { className: "bt-drag-shield", "aria-hidden": true }), document.body) : null,- hasStrip ? (0, import_react42.createElement)(PanelStrip, { bot, subject: pane.id, view, ids: tabState.ids, active, sides: sideChats, side: pane.side, canBrowse, reading, onView: switchView, actions: panelActions, useBrowserPages }) : null,- view === "browser" && bot ? (0, import_react42.createElement)(BrowserView, { key: `browser:${active}`, bot, tabId: active, leaving, landed: landed && !settling, actions, useBrowserPages, hold }) : view === "side" && sideChat ? (0, import_react42.createElement)("div", { key: `side:${sideChat.id}`, className: "bt-panel-view" }, (0, import_react42.createElement)(SideChatView, { subject: pane.id, chat: sideChat, actions: panelActions })) : (0, import_react42.createElement)(+ dragging ? (0, import_react_dom8.createPortal)((0, import_react43.createElement)("div", { className: "bt-drag-shield", "aria-hidden": true }), document.body) : null,+ hasStrip ? (0, import_react43.createElement)(PanelStrip, { bot, subject: pane.id, view, ids: tabState.ids, active, sides: sideChats, side: pane.side, canBrowse, reading, onView: switchView, actions: panelActions, useBrowserPages }) : null,+ view === "browser" && bot ? (0, import_react43.createElement)(BrowserView, { key: `browser:${active}`, bot, tabId: active, leaving, landed: landed && !settling, actions, useBrowserPages, hold }) : view === "side" && sideChat ? (0, import_react43.createElement)("div", { key: `side:${sideChat.id}`, className: "bt-panel-view" }, (0, import_react43.createElement)(SideChatView, { subject: pane.id, chat: sideChat, actions: panelActions })) : (0, import_react43.createElement)("div",{ key: `details:${pane.id}:${pane.renaming ? "rename" : ""}:${pane.tab ?? ""}`, className: "bt-panel-view" },- (0, import_react42.createElement)(DetailsDrawer, {+ (0, import_react43.createElement)(DetailsDrawer, {sessionId: pane.id,startRenaming: pane.renaming,startTab: pane.tab,@@ -17435,7 +17774,7 @@ var BROWSER_CSS = ``;// src/client/overlays.js-var import_react43 = require("react");+var import_react44 = require("react");var import_react_dom9 = require("react-dom");var DIALOG_EXIT_MS = 160;var MENU_EXIT_MS3 = 120;@@ -17444,15 +17783,15 @@ function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useActivityconst ui2 = useUi((value) => value);useRegistry((value) => value);const current = useSessions((list) => Object.values(list.byId).find((session) => (session?.retainedBy?.mainView ?? 0) > 0)?.id ?? null);- const previous = (0, import_react43.useRef)(current);- (0, import_react43.useEffect)(() => {+ const previous = (0, import_react44.useRef)(current);+ (0, import_react44.useEffect)(() => {if (previous.current === current) return;previous.current = current;if (current) actions.followPanel?.(current);}, [current]);const open = ui2.details ? { id: ui2.details, view: ui2.view ?? "details", renaming: ui2.renaming, tab: ui2.tab, side: ui2.side } : null;- const [kept, setKept] = (0, import_react43.useState)(open);- (0, import_react43.useEffect)(() => {+ const [kept, setKept] = (0, import_react44.useState)(open);+ (0, import_react44.useEffect)(() => {if (open) {setKept(open);return void 0;@@ -17471,17 +17810,17 @@ function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useActivityconst [memory, memoryLeaving] = useLinger(ui2.memory && memoryOwner(ui2.memory) ? ui2.memory : null, DIALOG_EXIT_MS);const owner = memory ? memoryOwner(memory) : null;const [menu, menuLeaving] = useLinger(ui2.menu, MENU_EXIT_MS3);- return (0, import_react43.createElement)(- import_react43.Fragment,+ return (0, import_react44.createElement)(+ import_react44.Fragment,null,- pane ? (0, import_react_dom9.createPortal)((0, import_react43.createElement)(BotPanel, { pane, leaving: open === null, roster, actions, useSessions, useSessionStatus, useActivity, useWork, useBrowserTabs, useBrowserPages, useBrowserHolds }), document.body) : null,- ui2.newChat ? (0, import_react_dom9.createPortal)((0, import_react43.createElement)(NewChat, { key: ui2.newChat, mode: ui2.newChat, roster, actions }), document.body) : null,- ui2.palette ? (0, import_react_dom9.createPortal)((0, import_react43.createElement)(CommandPalette, { key: ui2.palette.token, start: ui2.palette.query, token: ui2.palette.token, roster, actions, useSessions }), document.body) : null,- ui2.exchange ? (0, import_react_dom9.createPortal)((0, import_react43.createElement)(ExchangeDialog, { pair: ui2.exchange, roster, actions }), document.body) : null,- ui2.voice ? (0, import_react_dom9.createPortal)((0, import_react43.createElement)(VoiceMode, { key: ui2.voice, sessionId: ui2.voice, roster, actions, useSessions, useSessionStatus }), document.body) : null,- menu ? (0, import_react_dom9.createPortal)((0, import_react43.createElement)(ContextMenu, { key: `${menu.kind ?? ""}:${menu.id}:${menu.x}:${menu.y}`, menu, roster, actions, leaving: menuLeaving }), document.body) : null,- settings ? (0, import_react_dom9.createPortal)((0, import_react43.createElement)(SettingsDialog, { page: settings.page, id: settings.id, roster, actions, useUpdate, leaving: settingsLeaving }), document.body) : null,- owner ? (0, import_react_dom9.createPortal)((0, import_react43.createElement)(MemoryDialog, { key: owner.id, owner, actions, leaving: memoryLeaving }), document.body) : null+ pane ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(BotPanel, { pane, leaving: open === null, roster, actions, useSessions, useSessionStatus, useActivity, useWork, useBrowserTabs, useBrowserPages, useBrowserHolds }), document.body) : null,+ ui2.newChat ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(NewChat, { key: ui2.newChat, mode: ui2.newChat, roster, actions }), document.body) : null,+ ui2.palette ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(CommandPalette, { key: ui2.palette.token, start: ui2.palette.query, token: ui2.palette.token, roster, actions, useSessions }), document.body) : null,+ ui2.exchange ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(ExchangeDialog, { pair: ui2.exchange, roster, actions }), document.body) : null,+ ui2.voice ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(VoiceMode, { key: ui2.voice, sessionId: ui2.voice, roster, actions, useSessions, useSessionStatus }), document.body) : null,+ menu ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(ContextMenu, { key: `${menu.kind ?? ""}:${menu.id}:${menu.x}:${menu.y}`, menu, roster, actions, leaving: menuLeaving }), document.body) : null,+ settings ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(SettingsDialog, { page: settings.page, id: settings.id, roster, actions, useUpdate, leaving: settingsLeaving }), document.body) : null,+ owner ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(MemoryDialog, { key: owner.id, owner, actions, leaving: memoryLeaving }), document.body) : null);}@@ -18504,7 +18843,7 @@ function createSwitchWindow(settle) {}// src/client/user-message.js-var import_react44 = require("react");+var import_react45 = require("react");var ui = __toESM(require("@deepseek-ai/dsh-client-ui-primitives"), 1);var canDrawUserMessages = () => typeof ui.projectUserText === "function";function contentParts(content) {@@ -18536,38 +18875,38 @@ function userTextParts(text, bots, referenceLabels = []) {return parts;}function UserText({ text, bots, referenceLabels, skillNames, references, actions }) {- return userTextParts(text, bots, referenceLabels).map((part, index) => part.bot ? (0, import_react44.createElement)(+ return userTextParts(text, bots, referenceLabels).map((part, index) => part.bot ? (0, import_react45.createElement)("button",{ key: index, type: "button", className: "bt-umention", title: `@${part.bot.name}`, onClick: () => actions.openSession(part.bot.id) },- (0, import_react44.createElement)(BotMark, { bot: part.bot, size: 16 }),+ (0, import_react45.createElement)(BotMark, { bot: part.bot, size: 16 }),part.label- ) : (0, import_react44.createElement)(import_react44.Fragment, { key: index }, ui.projectUserText(part.text, referenceLabels, skillNames, "skill", references)));+ ) : (0, import_react45.createElement)(import_react45.Fragment, { key: index }, ui.projectUserText(part.text, referenceLabels, skillNames, "skill", references)));}function Attachments({ attachments, renderMessageImages }) {const compact2 = attachments.length > 1;- return (0, import_react44.createElement)("div", { className: "bt-uattach" }, attachments.map((block, index) => {+ return (0, import_react45.createElement)("div", { className: "bt-uattach" }, attachments.map((block, index) => {if (block.type === "image") {- return renderMessageImages ? (0, import_react44.createElement)(import_react44.Fragment, { key: index }, renderMessageImages({ images: [{ attachment: block.attachment }], align: "end", compact: compact2 })) : null;+ return renderMessageImages ? (0, import_react45.createElement)(import_react45.Fragment, { key: index }, renderMessageImages({ images: [{ attachment: block.attachment }], align: "end", compact: compact2 })) : null;}const file = block.attachment;const meta = [ui.fileExtension?.(file.name)?.toUpperCase().slice(0, 8), ui.fileSizeText?.(file.bytes)].filter(Boolean).join(" · ");- return (0, import_react44.createElement)(+ return (0, import_react45.createElement)("span",{ key: index, className: "bt-ufile", title: file.name },- ui.FileTypeIcon ? (0, import_react44.createElement)(ui.FileTypeIcon, { path: file.name, className: "bt-ufile-icon" }) : null,- (0, import_react44.createElement)("span", { className: "bt-ufile-text" }, (0, import_react44.createElement)("span", { className: "bt-ufile-name" }, file.name), meta ? (0, import_react44.createElement)("span", { className: "bt-ufile-meta" }, meta) : null)+ ui.FileTypeIcon ? (0, import_react45.createElement)(ui.FileTypeIcon, { path: file.name, className: "bt-ufile-icon" }) : null,+ (0, import_react45.createElement)("span", { className: "bt-ufile-text" }, (0, import_react45.createElement)("span", { className: "bt-ufile-name" }, file.name), meta ? (0, import_react45.createElement)("span", { className: "bt-ufile-meta" }, meta) : null));}));}function CopyButton({ text }) {- const [copied, setCopied] = (0, import_react44.useState)(false);+ const [copied, setCopied] = (0, import_react45.useState)(false);const copy2 = () => {void navigator.clipboard?.writeText(text).then(() => {setCopied(true);setTimeout(() => setCopied(false), 1e3);});};- return (0, import_react44.createElement)("button", { type: "button", className: "bt-tool", "aria-label": copied ? t("Copied") : t("Copy"), title: copied ? t("Copied") : t("Copy"), onClick: copy2 }, copied ? (0, import_react44.createElement)(CheckIcon) : (0, import_react44.createElement)(CopyIcon));+ return (0, import_react45.createElement)("button", { type: "button", className: "bt-tool", "aria-label": copied ? t("Copied") : t("Copy"), title: copied ? t("Copied") : t("Copy"), onClick: copy2 }, copied ? (0, import_react45.createElement)(CheckIcon) : (0, import_react45.createElement)(CopyIcon));}var clock3 = (time) => typeof time === "number" ? new Date(time).toLocaleTimeString(dateLocale(), { hour: "numeric", minute: "2-digit" }) : void 0;function UserMessageCell({ node, sessionId, useRoster, actions, renderMessageImages, openFile, openSkill }) {@@ -18579,10 +18918,10 @@ function UserMessageCell({ node, sessionId, useRoster, actions, renderMessageImaconst steering = node.kind === "steering";const groupTime = roster.roomsById?.[sessionId] && Number.isFinite(data.time) ? messageClock(data.time) : void 0;const { shown, folded, control } = useFold(text, { markdown: false });- const body = (0, import_react44.createElement)(UserText, { text: shown, bots: mentionableBots(roster, sessionId), referenceLabels, skillNames: data.skillNames ?? [], references, actions });- const row = (0, import_react44.useRef)(null);- const [toolsOpen, setToolsOpen] = (0, import_react44.useState)(false);- (0, import_react44.useEffect)(() => {+ const body = (0, import_react45.createElement)(UserText, { text: shown, bots: mentionableBots(roster, sessionId), referenceLabels, skillNames: data.skillNames ?? [], references, actions });+ const row = (0, import_react45.useRef)(null);+ const [toolsOpen, setToolsOpen] = (0, import_react45.useState)(false);+ (0, import_react45.useEffect)(() => {if (!toolsOpen) return void 0;const onDown = (event) => {if (!row.current?.contains(event.target)) setToolsOpen(false);@@ -18598,24 +18937,24 @@ function UserMessageCell({ node, sessionId, useRoster, actions, renderMessageImaif (!noHover() || event.target instanceof Element && event.target.closest("a,button,input,textarea,select,pre,code,[role=button],[role=link]")) return;setToolsOpen((value) => !value);};- return (0, import_react44.createElement)(+ return (0, import_react45.createElement)("div",{ ref: row, className: "bt-umsg", "data-steering": steering || void 0 },- (0, import_react44.createElement)(+ (0, import_react45.createElement)("div",{ className: "bt-ustack" },- attachments.length > 0 ? (0, import_react44.createElement)(Attachments, { attachments, renderMessageImages }) : null,- text !== "" || rest.length > 0 ? (0, import_react44.createElement)(+ attachments.length > 0 ? (0, import_react45.createElement)(Attachments, { attachments, renderMessageImages }) : null,+ text !== "" || rest.length > 0 ? (0, import_react45.createElement)("div",{ className: "bt-ubody", title: clock3(data.time), "data-folded": folded || void 0, onClick: tapTools },- control ? (0, import_react44.createElement)("div", { className: "bt-fold-body" }, body) : body,+ control ? (0, import_react45.createElement)("div", { className: "bt-fold-body" }, body) : body,control,- rest.map((block, index) => ui.JsonBlock ? (0, import_react44.createElement)(ui.JsonBlock, { key: index, label: t("Content"), payload: block }) : null)+ rest.map((block, index) => ui.JsonBlock ? (0, import_react45.createElement)(ui.JsonBlock, { key: index, label: t("Content"), payload: block }) : null)) : null,- referenceLabels.length > 0 ? (0, import_react44.createElement)("div", { className: "bt-urefs" }, t("Referenced {labels}", { labels: referenceLabels.join(t(", ")) })) : null,- groupTime ? (0, import_react44.createElement)("div", { className: "bt-utime", title: clockLabel(data.time) }, groupTime) : null+ referenceLabels.length > 0 ? (0, import_react45.createElement)("div", { className: "bt-urefs" }, t("Referenced {labels}", { labels: referenceLabels.join(t(", ")) })) : null,+ groupTime ? (0, import_react45.createElement)("div", { className: "bt-utime", title: clockLabel(data.time) }, groupTime) : null),- text === "" ? null : (0, import_react44.createElement)("div", { className: "bt-utools", "data-open": toolsOpen || void 0 }, (0, import_react44.createElement)(CopyButton, { text }))+ text === "" ? null : (0, import_react45.createElement)("div", { className: "bt-utools", "data-open": toolsOpen || void 0 }, (0, import_react45.createElement)(CopyButton, { text })));}var USER_MESSAGE_CSS = `@@ -19251,6 +19590,11 @@ function apply(ctx) {actions.speech = () => ctx.get("remote.speech") ?? void 0;actions.openHarnessSettings = openHarnessSettings;actions.openHarnessOnboarding = openHarnessOnboarding;+ actions.openHarnessModels = () => {+ const step = (ctx.slots.entries?.("settings.onboarding") ?? []).some((entry) => entry.options?.id === MODELS_STEP);+ if (step) openHarnessOnboarding(MODELS_STEP);+ else openHarnessSettings();+ };actions.voiceSetup = () => {const navigation = ctx.get("pluginNavigation");return navigation ? () => navigation.openBundle(VOICE_BUNDLE) : null;@@ -19457,12 +19801,14 @@ function apply(ctx) {// The whale wins the seat over a shell account plugin's own launcher (the// Desktop's "··· More"), which comes back in Agent mode.() => shadow("settings.launcher", { priority: BOT_PRIORITY, inject: face }, AccountLauncher),+ () => shadow("settings.onboarding", { id: MODELS_STEP, order: MODELS_STEP_ORDER }, OpenModelsStep),() => shadow("shell.overlay", { id: "bot", order: 50, inject: face }, Overlays),() => shadow("shell.overlay", { id: "bot-signin", order: 55, inject: face }, DeepSeekSignIn),() => shadow("shell.overlay", { id: "bot-toast", order: 60, inject: face }, ErrorToast)];const installConversation = () => [() => installCompiledStyles(CONVERSATION_CSS, "conversation"),+ () => installCompiledStyles(TURN_ERROR_CSS, "turn-errors"),() => installMentions(),() => installAtMenu(),installHeader,@@ -19470,6 +19816,8 @@ function apply(ctx) {() => shadow("conversation.chat.node", { key: "turn-trigger", priority: BOT_PRIORITY, locale: "chat", inject: face }, TriggerCell),() => shadow("conversation.chat.node", { key: "tool-call", priority: BOT_PRIORITY, locale: "chat", inject: face }, ToolCell),() => shadow("conversation.chat.node", { key: "turn-process", priority: BOT_PRIORITY, locale: "chat", inject: face }, TurnProcessCell),+ // A failed turn shows what the user can do about it instead of the provider's raw text.+ () => shadow("conversation.chat.node", { key: "turn-error", priority: BOT_PRIORITY, locale: "chat", inject: face }, FailureCell),// DSH's own turn tail stays, so what other plugins add there shows, such as the// cards of the files a turn delivered; its copy and branch row is hidden.() => shadow("conversation.chat.turnTail", { id: "bot-turn-separators", order: 1e3, inject: face }, TurnTailCell),diff --git a/ds-bot/src/client/bot-draft.js b/ds-bot/src/client/bot-draft.jsindex bc8d5645..245537c6 100644--- a/ds-bot/src/client/bot-draft.js+++ b/ds-bot/src/client/bot-draft.js@@ -8,13 +8,15 @@ export function freshBotName(roster, base = 'New Bot') {return `${base} ${index}`}-// The form starts on the DSH default model when it is served, else the first one.+// The form starts on the DSH default model when it is usable, else the first usable+// one. A model whose provider has no key fails every turn, so with none usable the form+// starts on none and the new Bot waits for a pick.export function startModel(roster) {- const models = roster.models ?? []- return (models.find(model => model.ref === roster.defaultModel) ?? models[0])?.ref ?? ''+ const usable = (roster.models ?? []).filter(model => !model.needsKey)+ return (usable.find(model => model.ref === roster.defaultModel) ?? usable[0])?.ref ?? ''}-// The model is always sent: the host fixes it on the Bot at creation.+// A chosen model is always sent: the host fixes it on the Bot at creation.export function createPayload({ name, look, image, model, effort, brief }) {const payload = { name, color: look.color, avatar: image ? { shape: look.shape, image } : { shape: look.shape } }if (model) payload.model = modeldiff --git a/ds-bot/src/client/cells.js b/ds-bot/src/client/cells.jsindex 81377b96..f299fa70 100644--- a/ds-bot/src/client/cells.js+++ b/ds-bot/src/client/cells.js@@ -609,6 +609,8 @@ export function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnCl// A request carried on keeps its role, but its message line was shown already.if (source.role === 'resume' || source.resumed === true) return h('div', { className: 'bt-event' }, t('Picked up its work after a restart'))if (source.role === 'retry' || source.retried === true) return h('div', { className: 'bt-event' }, t('Asked to make the tool call it wrote as text'))+ // The repair card's Retry: the user's message is not sent again, nor is the note to the Bot.+ if (source.role === 'continue') return h('div', { className: 'bt-event' }, t('Went on after the failed turn'))const run = relayed ? commRunOf(order.split(',').filter(Boolean).map(Number),Object.fromEntries(peers.split(',').filter(Boolean).map(pair => [Number(pair.slice(0, pair.indexOf(':'))), pair.slice(pair.indexOf(':') + 1)])),diff --git a/ds-bot/src/client/create-bot.js b/ds-bot/src/client/create-bot.jsindex 5c53b75a..81ea6f0f 100644--- a/ds-bot/src/client/create-bot.js+++ b/ds-bot/src/client/create-bot.js@@ -83,9 +83,11 @@ export function CreateBot({ roster, actions, start, brief = '', onBack, canGoBach('div', { className: 'bt-field' },h('span', { className: 'bt-field-label' }, t('Model')),h(ModelMenu, { bot: { id: 'new-bot', name: finalName, model: model || undefined, effort }, roster, actions, wide: true, onPick: ref => { setModel(ref); setEffort(undefined) }, onPickEffort: setEffort }),- h('span', { className: 'bt-note' }, (roster.models ?? []).length > 0+ h('span', { className: 'bt-note' }, model? t('The Bot runs on this model. You can change it later in its details.')- : t('Add a provider and a model in DeepSeek Harness first, or pick one in the Bot\'s chat later.'))),+ : (roster.models ?? []).length > 0+ ? t('Pick a model here, or the Bot asks for one in its chat.')+ : t('Add a provider and a model in DeepSeek Harness first, or pick one in the Bot\'s chat later.'))),error ? h('div', { className: 'bt-error', role: 'alert', style: { padding: 0 } }, error) : null,h('div', { className: 'bt-create-foot' },h('button', { type: 'button', className: 'bt-soft', onClick: onBack }, canGoBack ? t('Back') : t('Cancel')),diff --git a/ds-bot/src/client/diagnostics.js b/ds-bot/src/client/diagnostics.jsindex 31258896..6c9902de 100644--- a/ds-bot/src/client/diagnostics.js+++ b/ds-bot/src/client/diagnostics.js@@ -49,9 +49,14 @@ export function clientFacts() {// Short words for the provider-neutral failure codes of DSH's LLM layer.const FAILURES = {+ MISSING_CREDENTIAL: 'The model has no API key',+ INVALID_CREDENTIAL: 'The API key is not in the right format',AUTH: 'The API key was rejected',QUOTA: 'The account is out of quota',ACCOUNT_QUOTA: 'The account is out of quota',+ ACCOUNT_SIGN_IN_REQUIRED: 'The DeepSeek account needs a sign-in',+ ACCOUNT_SIGNED_OUT: 'The DeepSeek account is signed out',+ ACCOUNT_TOKEN_INVALID: 'The DeepSeek account sign-in has expired',RATE_LIMIT: 'Too many requests to the model',CONTEXT_WINDOW_EXCEEDED: 'The conversation is too long for the model',INVALID_REQUEST: 'The model service refused the request',@@ -62,9 +67,11 @@ const FAILURES = {SESSION_RESET: 'Its group conversation could not open, so it starts a new one next time',}+// The short words for a known code, or undefined.+export const knownFailure = code => (Object.hasOwn(FAILURES, code ?? '') ? t(FAILURES[code]) : undefined)+export function failureLabel(code, message) {- if (FAILURES[code]) return t(FAILURES[code])- return message || code || t('Unknown error')+ return knownFailure(code) ?? (message || code || t('Unknown error'))}// GitHub refuses very long addresses; past this the diagnostics go by the clipboard.diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.jsindex 3eb93caa..3dd210f2 100644--- a/ds-bot/src/client/i18n.js+++ b/ds-bot/src/client/i18n.js@@ -164,6 +164,41 @@ const ZH = {'Sign in to DeepSeek': '登录 DeepSeek 账号','Enter a DeepSeek API key': '填入 DeepSeek API key','Open settings to set up a custom model': '打开设置配置自定义模型',+ 'Create a key on the DeepSeek platform ↗': '去 DeepSeek 开放平台创建 Key ↗',+ 'The API is billed by usage; the account needs a balance first.': 'API 按用量计费,账户里要先有余额。',+ 'Models and API keys': '模型和 API Key',+ // A failed turn in a Bot's chat+ "{name}'s model has no API key yet.": '{name} 用的模型还没有 API Key。',+ 'This API key is not in the right format.': '这个 API Key 的格式不对。',+ '{provider} did not accept the current API key.': '{provider} 不接受现在的 API Key。',+ '{provider} did not accept the current API key ({status}).': '{provider} 不接受现在的 API Key({status})。',+ '{provider} is out of balance or quota.': '{provider} 的余额或额度不够了。',+ '{provider} is out of balance or quota ({status}).': '{provider} 的余额或额度不够了({status})。',+ 'The DeepSeek account balance is too low.': 'DeepSeek 账号余额不足。',+ 'The DeepSeek account sign-in has expired.': 'DeepSeek 账号的登录失效了。',+ 'Could not reach the model service.': '连不上模型服务。',+ 'Too many requests. Wait a moment, then try again.': '请求太频繁,稍等一会儿再试。',+ 'The model service failed.': '模型服务出错了。',+ 'DeepSeek Harness stopped before this turn finished.': '这一轮还没完成,DeepSeek Harness 就停下了。',+ 'This turn failed.': '这一轮运行失败了。',+ 'The model service': '模型服务',+ 'DeepSeek account': 'DeepSeek 账号',+ 'This Bot': '这个 Bot',+ 'Enter API key': '填入 API Key',+ 'Enter the key again': '重新填 Key',+ 'Sign in with a DeepSeek account': '用 DeepSeek 账号登录',+ 'Use a DeepSeek account instead': '改用账号登录',+ 'Use the DeepSeek account': '改用 DeepSeek 账号',+ 'Sign in again': '重新登录',+ 'Pick another model': '换个模型',+ 'Top up ↗': '去充值 ↗',+ Retry: '重试',+ 'Retrying…': '正在重试…',+ 'Technical details': '技术详情',+ Code: '代码',+ 'HTTP status': 'HTTP 状态码',+ 'Request ID': '请求 ID',+ 'Provider message': '原文','DS Bot': 'DS Bot',// Header@@ -361,6 +396,7 @@ const ZH = {'Upload photo': '上传照片','A Bot named {name} already exists': '已经有叫 {name} 的 Bot 了','The Bot runs on this model. You can change it later in its details.': 'Bot 会使用这个模型。以后可以在详情里修改。',+ 'Pick a model here, or the Bot asks for one in its chat.': '在这里选一个模型,或者之后由 Bot 在聊天里问你。',"Add a provider and a model in DeepSeek Harness first, or pick one in the Bot's chat later.": '请先在 DeepSeek Harness 里添加服务商和模型,或者稍后在 Bot 的对话里选择。','Creating…': '创建中…',Create: '创建',@@ -426,7 +462,7 @@ const ZH = {'DS Bot settings': 'DS Bot 设置','Settings pages': '设置页面','Models, providers, and the rest of DeepSeek Harness': '模型、服务商和 DeepSeek Harness 的其他设置',- 'Harness settings': 'Harness 设置',+ 'Advanced settings (DeepSeek Harness)': '高级设置(DeepSeek Harness)','Back to Bots': '返回 Bot 列表','Close settings': '关闭设置',@@ -575,6 +611,7 @@ const ZH = {'{name} was cut off by a restart again and stopped': '{name} 的工作又被重启打断,已停下','Picked up its work after a restart': '重启后接着做之前的工作','Asked to make the tool call it wrote as text': '工具调用被写成了文字,已让它重新调用',+ 'Went on after the failed turn': '上一轮失败后,已让它接着做','A Bot': '一个 Bot','{name} is waiting for your approval': '{name} 等你批准','{first} and {second} are waiting for your approval': '{first}、{second} 等你批准',@@ -922,6 +959,11 @@ const ZH = {'Could not reach DSH. Check that it is still running.': '连不上 DSH,请确认它还在运行。','{name} could not answer: {reason}': '{name} 没能回答:{reason}','Unknown error': '未知错误',+ 'The model has no API key': '模型还没有 API Key',+ 'The API key is not in the right format': 'API Key 格式不对',+ 'The DeepSeek account needs a sign-in': 'DeepSeek 账号需要登录',+ 'The DeepSeek account is signed out': 'DeepSeek 账号已退出登录',+ 'The DeepSeek account sign-in has expired': 'DeepSeek 账号的登录失效了','The API key was rejected': 'API 密钥无效','The account is out of quota': '账户额度已用尽','Too many requests to the model': '模型请求太频繁',@@ -981,8 +1023,8 @@ const ZH = {Unit: '单位','Create task': '创建任务','Turn on Automation tasks in DSH': '在 DSH 里打开「自动化任务」',- 'Switch on Automation tasks on the Plugins page in Harness settings.': '在 Harness 设置的插件页启用「自动化任务」。',- 'Open Harness settings': '打开 Harness 设置',+ 'Switch on Automation tasks on the Plugins page in Advanced settings (DeepSeek Harness).': '在「高级设置(DeepSeek Harness)」的插件页启用「自动化任务」。',+ 'Open Advanced settings (DeepSeek Harness)': '打开高级设置(DeepSeek Harness)','New task': '新建任务','No scheduled tasks yet.': '还没有定时任务。','No scheduled tasks yet. Add one': '还没有定时任务,去添加',@@ -1090,7 +1132,7 @@ const HOST_ZH = {'A name uses capitals, digits, and underscores, and starts with a letter': '名字只能用大写字母、数字和下划线,并以字母开头','No such key': '没有这个密钥','Type a question or a change first': '请先输入问题或要改的内容',- 'No model is available. Add one in Harness settings.': '没有可用的模型,请先在 Harness 设置里添加模型。',+ 'No model is available. Add one in Settings > Models.': '没有可用的模型,请先在 设置 → 模型 里添加。','Memory is turned off on this host': '这台主机关闭了记忆功能','The model wrote nothing': '模型没有输出内容','Write the entry to save.': '请写下要保存的内容。',diff --git a/ds-bot/src/client/icons.js b/ds-bot/src/client/icons.jsindex 7def6333..02889645 100644--- a/ds-bot/src/client/icons.js+++ b/ds-bot/src/client/icons.js@@ -66,6 +66,7 @@ export const CalendarIcon = lineIcon(['M5.5 5h9A1.5 1.5 0 0 1 16 6.5v8a1.5 1.5 0export const ConnectorIcon = lineIcon(['M7 10a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z', 'M18 10a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z', 'M7 10h6'])export const SwitchIcon = lineIcon(['M4 7h9.5M10.5 3.5L14 7l-3.5 3.5', 'M16 13H6.5M9.5 9.5L6 13l3.5 3.5'])export const SignOutIcon = lineIcon(['M8.5 17H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h2.5', 'M10 10h6.5', 'M13.5 7l3 3-3 3'])+export const SignInIcon = lineIcon(['M11.5 3H14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2.5', 'M3.5 10H10', 'M7 7l3 3-3 3'])export const PaperclipIcon = lineIcon(['M15.5 9.5l-5.6 5.6a3.4 3.4 0 0 1-4.8-4.8l6.1-6.1a2.25 2.25 0 0 1 3.2 3.2l-6 6a1.1 1.1 0 0 1-1.6-1.6l5.5-5.5'])export const ClockIcon = lineIcon(['M10 3.5a6.5 6.5 0 1 1 0 13 6.5 6.5 0 0 1 0-13z', 'M10 6.5V10l2.5 1.5'])// Six broad, shallow teeth around a wide hub: it reads as a gear even at 15px.diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.jsindex 6b8b5589..2b5370b1 100644--- a/ds-bot/src/client/index.js+++ b/ds-bot/src/client/index.js@@ -7,7 +7,7 @@ import { themeCss, shellTokens, registry, registerShape, registerTheme, allThemeimport { MENTION_ORIGIN, currentPart } from './text.js'import { SHELL_CSS, CONVERSATION_CSS, installStyles, installCompiledStyles } from './styles.js'import { lookOf } from './mark.js'-import { TeamSidebar, ConnectPlugins, YouAvatar, AccountLauncher, FooterAccount, BrandMark, BrandName, BotReturn, SIDEBAR_CSS, RETURN_CSS, holdShellShortcuts, openHarnessOnboarding, openHarnessSettings } from './sidebar.js'+import { TeamSidebar, ConnectPlugins, YouAvatar, AccountLauncher, FooterAccount, BrandMark, BrandName, BotReturn, SIDEBAR_CSS, RETURN_CSS, holdShellShortcuts, openHarnessOnboarding, openHarnessSettings, MODELS_STEP, MODELS_STEP_ORDER, OpenModelsStep } from './sidebar.js'import { HeaderPill } from './header.js'import { ComposerPlus, ComposerVoice, menuIcons } from './composer.js'import { CHATS_SOURCE, atSources } from './at-menu.js'@@ -19,6 +19,7 @@ import { QuestionCard, QuestionDock } from './questions.js'import { AnsweredReply, WidgetDock, WIDGET_CSS } from './widget-cell.js'import { installHeaderNavigation } from './header-navigation.js'import { AssistantCell, TriggerCell, TurnProcessCell, Nothing, TurnTailCell, ToolCell } from './cells.js'+import { FailureCell, TURN_ERROR_CSS } from './turn-error.js'import { Overlays } from './overlays.js'import { createBotBrowsers, serveBrowserReads } from './bot-browsers.js'import { BROWSER_CSS } from './browser-pane.js'@@ -579,6 +580,12 @@ export function apply(ctx) {// DSH's own settings: models, providers, keys and its plugins.actions.openHarnessSettings = openHarnessSettingsactions.openHarnessOnboarding = openHarnessOnboarding+ // DSH's Models page, through DS Bot's own onboarding step while it is registered.+ actions.openHarnessModels = () => {+ const step = (ctx.slots.entries?.('settings.onboarding') ?? []).some(entry => entry.options?.id === MODELS_STEP)+ if (step) openHarnessOnboarding(MODELS_STEP)+ else openHarnessSettings()+ }actions.voiceSetup = () => {const navigation = ctx.get('pluginNavigation')return navigation ? () => navigation.openBundle(VOICE_BUNDLE) : null@@ -799,12 +806,14 @@ export function apply(ctx) {// The whale wins the seat over a shell account plugin's own launcher (the// Desktop's "··· More"), which comes back in Agent mode.() => shadow('settings.launcher', { priority: BOT_PRIORITY, inject: face }, AccountLauncher),+ () => shadow('settings.onboarding', { id: MODELS_STEP, order: MODELS_STEP_ORDER }, OpenModelsStep),() => shadow('shell.overlay', { id: 'bot', order: 50, inject: face }, Overlays),() => shadow('shell.overlay', { id: 'bot-signin', order: 55, inject: face }, DeepSeekSignIn),() => shadow('shell.overlay', { id: 'bot-toast', order: 60, inject: face }, ErrorToast),]const installConversation = () => [() => installCompiledStyles(CONVERSATION_CSS, 'conversation'),+ () => installCompiledStyles(TURN_ERROR_CSS, 'turn-errors'),() => installMentions(),() => installAtMenu(),installHeader,@@ -812,6 +821,8 @@ export function apply(ctx) {() => shadow('conversation.chat.node', { key: 'turn-trigger', priority: BOT_PRIORITY, locale: 'chat', inject: face }, TriggerCell),() => shadow('conversation.chat.node', { key: 'tool-call', priority: BOT_PRIORITY, locale: 'chat', inject: face }, ToolCell),() => shadow('conversation.chat.node', { key: 'turn-process', priority: BOT_PRIORITY, locale: 'chat', inject: face }, TurnProcessCell),+ // A failed turn shows what the user can do about it instead of the provider's raw text.+ () => shadow('conversation.chat.node', { key: 'turn-error', priority: BOT_PRIORITY, locale: 'chat', inject: face }, FailureCell),// DSH's own turn tail stays, so what other plugins add there shows, such as the// cards of the files a turn delivered; its copy and branch row is hidden.() => shadow('conversation.chat.turnTail', { id: 'bot-turn-separators', order: 1000, inject: face }, TurnTailCell),diff --git a/ds-bot/src/client/model-menu.js b/ds-bot/src/client/model-menu.jsindex 6980767a..7dffeb62 100644--- a/ds-bot/src/client/model-menu.js+++ b/ds-bot/src/client/model-menu.js@@ -210,7 +210,7 @@ export function ModelChoiceDock({ sessionId, useRoster, actions }) {const lost = bot.model ? !models.some(model => model.ref === bot.model) : false// An unknown catalog (none listed) cannot tell a lost model from a slow provider.if (bot.model && (!lost || models.length === 0)) return null- // A window without DSH's own settings takes the missing key here.+ // The missing key is taken here, through the host.const keyFor = usable.length === 0 && actions.setProviderKey ? models.find(model => model.needsKey) : undefinedconst manage = manageModels(actions)const pick = (ref) => {@@ -253,9 +253,11 @@ export function ModelChoiceDock({ sessionId, useRoster, actions }) {error ? h('div', { className: 'bt-secret-error bt-model-error', role: 'alert' }, error) : null)}+const DEEPSEEK_KEYS_URL = 'https://platform.deepseek.com/api_keys'+// The provider's API key, saved through the host; once it is set, the provider's-// models become the choices.-function ModelKeyCard({ model, actions }) {+// models become the choices. `onSaved` runs once the host took the key.+export function ModelKeyCard({ model, actions, onSaved }) {const [value, setValue] = useState('')const [busy, setBusy] = useState(false)const [error, setError] = useState('')@@ -266,29 +268,33 @@ function ModelKeyCard({ model, actions }) {setBusy(true)setError('')void Promise.resolve(actions.setProviderKey(model.provider, value))- .then(() => setValue(''), failure => setError(hostText(failure?.message ?? String(failure))))+ .then(() => { setValue(''); onSaved?.() }, failure => setError(hostText(failure?.message ?? String(failure)))).finally(() => setBusy(false))}+ const official = model.provider === 'deepseek-official'return h('div', { className: 'bt-q bt-model-key', role: 'group', 'aria-label': label },h('div', { className: 'bt-model-key-title' }, h(KeyIcon), label),h('label', { className: 'bt-q-field bt-secret-field' }, h(MaskedInput, { value, onChange: setValue, onEnter: save, label, autoFocus: true })),+ official ? h('div', { className: 'bt-model-key-help' },+ h('a', { className: 'bt-model-key-link', href: DEEPSEEK_KEYS_URL, target: '_blank', rel: 'noopener noreferrer' }, t('Create a key on the DeepSeek platform ↗')),+ h('span', { className: 'bt-model-key-note' }, t('The API is billed by usage; the account needs a balance first.'))) : null,error ? h('div', { className: 'bt-secret-error', role: 'alert' }, error) : null,h('div', { className: 'bt-q-foot' },actions.openModels ? h('button', { type: 'button', className: 'bt-q-btn bt-model-key-other', onClick: actions.openModels }, t('Another provider')) : null,h('button', { type: 'button', className: 'bt-q-submit', disabled: !ready, onClick: save }, busy ? t('Saving…') : t('Save'))))}-// Where the providers are set up: the window's own Models page, else DSH's settings.-const manageModels = actions => actions.openModels ?? actions.openHarnessSettings+// Where the providers are set up: DS Bot's Models page, else DSH's own.+export const manageModels = actions => actions.openModels ?? actions.openHarnessModels ?? actions.openHarnessSettings// Ways to get a first model. The DeepSeek sign-in exists only where the shell carries-// its account plugin (the Desktop); the API key and custom models use the shell's-// own editors.+// its account plugin; the API key uses the shell's own editor.function setupChoices(actions) {+ const custom = manageModels(actions)return [actions.canSignIn?.() ? [t('Sign in to DeepSeek'), () => actions.signIn()] : null,actions.openHarnessOnboarding ? [t('Enter a DeepSeek API key'), () => actions.openHarnessOnboarding('deepseek-official')] : null,- actions.openHarnessSettings ? [t('Open settings to set up a custom model'), actions.openHarnessSettings] : null,+ custom ? [t('Open settings to set up a custom model'), () => custom()] : null,].filter(Boolean)}@@ -350,6 +356,10 @@ export const MODEL_CSS = `.bt-model-key-title{display:flex;align-items:center;gap:6px;font-size:13px;line-height:18px;font-weight:500;color:var(--bt-ink-2)}.bt-model-key-title svg{flex:none;width:16px;height:16px}.bt-model-key .bt-q-foot{margin-top:2px}+.bt-model-key-help{display:flex;flex-direction:column;gap:2px;font-size:12px;line-height:17px;color:var(--bt-ink-2)}+.bt-model-key-link{align-self:flex-start;color:var(--bt-ink);text-decoration:underline;text-decoration-color:var(--bt-line-2);text-underline-offset:2px}+.bt-model-key-link:hover{text-decoration-color:currentColor}+.bt-model-key-link:focus-visible{outline:2px solid var(--bt-accent);outline-offset:1px;border-radius:4px}.bt-model-key-other{margin-right:auto}@keyframes bt-model-in{from{opacity:0;transform:translateY(6px)}}.bt-model-spin{flex:none;width:14px;height:14px;border-radius:50%;border:1.5px solid var(--bt-line-2);border-top-color:var(--bt-ink-2);animation:bt-model-spin .7s linear infinite}diff --git a/ds-bot/src/client/schedules.js b/ds-bot/src/client/schedules.jsindex 8e79ca3d..6e686ac9 100644--- a/ds-bot/src/client/schedules.js+++ b/ds-bot/src/client/schedules.js@@ -173,8 +173,8 @@ function AutomationOff({ actions }) {return h('div', { className: 'bt-set-card bt-task-off' },h('span', { className: 'bt-task-off-mark' }, h(ClockIcon)),h('span', { className: 'bt-task-off-title' }, t('Turn on Automation tasks in DSH')),- h('span', { className: 'bt-set-hint' }, t('Switch on Automation tasks on the Plugins page in Harness settings.')),- actions.openHarnessSettings ? h('button', { type: 'button', className: 'bt-soft bt-soft-sm', onClick: actions.openHarnessSettings }, t('Open Harness settings')) : null)+ h('span', { className: 'bt-set-hint' }, t('Switch on Automation tasks on the Plugins page in Advanced settings (DeepSeek Harness).')),+ actions.openHarnessSettings ? h('button', { type: 'button', className: 'bt-soft bt-soft-sm', onClick: actions.openHarnessSettings }, t('Open Advanced settings (DeepSeek Harness)')) : null)}export function SchedulesPage({ roster, actions, start }) {@@ -209,8 +209,8 @@ export function BotSchedules({ bot, roster, actions }) {h('div', { className: 'bt-set-card' },!view.available? h('div', { className: 'bt-set-row bt-bs-row' },- h('span', { className: 'bt-set-copy' }, h('span', { className: 'bt-set-hint' }, t('Switch on Automation tasks on the Plugins page in Harness settings.'))),- actions.openHarnessSettings ? h('button', { type: 'button', className: 'bt-soft bt-soft-sm', onClick: actions.openHarnessSettings }, t('Open Harness settings')) : null)+ h('span', { className: 'bt-set-copy' }, h('span', { className: 'bt-set-hint' }, t('Switch on Automation tasks on the Plugins page in Advanced settings (DeepSeek Harness).'))),+ actions.openHarnessSettings ? h('button', { type: 'button', className: 'bt-soft bt-soft-sm', onClick: actions.openHarnessSettings }, t('Open Advanced settings (DeepSeek Harness)')) : null): [...tasks.map(task => h(TaskRow, { key: task.id, task, actions, roster, onView: publish })),h('button', { key: 'new', type: 'button', className: 'bt-set-row bt-bs-row bt-gs-add', onClick: () => actions.openSettings('schedules', bot.id) }, h(PlusIcon), t('New task')),@@ -224,7 +224,7 @@ export function ScheduleSummary({ bot, actions }) {return h('div', null,h('div', { className: 'bt-section-title' }, t('Scheduled tasks')),tasks.length === 0- ? h('button', { type: 'button', className: 'bt-more', onClick: () => actions.openSettings('schedules', bot.id) }, view?.available === false ? t('Switch on Automation tasks on the Plugins page in Harness settings.') : t('No scheduled tasks yet. Add one'))+ ? h('button', { type: 'button', className: 'bt-more', onClick: () => actions.openSettings('schedules', bot.id) }, view?.available === false ? t('Switch on Automation tasks on the Plugins page in Advanced settings (DeepSeek Harness).') : t('No scheduled tasks yet. Add one')): h('div', { className: 'bt-task-list' }, tasks.slice(0, 3).map(task => h('button', { key: task.id, type: 'button', className: 'bt-task-line', onClick: () => actions.openSettings('schedules') },h(ClockIcon), h('span', { className: 'bt-task-line-title' }, task.title), h('span', { className: 'bt-task-line-when' }, timingText(task))))))}diff --git a/ds-bot/src/client/settings.js b/ds-bot/src/client/settings.jsindex b1e36f37..03ff283f 100644--- a/ds-bot/src/client/settings.js+++ b/ds-bot/src/client/settings.js@@ -25,7 +25,7 @@ const capitalize = word => word[0].toUpperCase() + word.slice(1)// Settings dialog: a 198px page list beside the page. Bots and group chats each list// their members, and one opens on its own settings form. Usage widens the dialog.-// Models is there only in a window without DSH's own settings, which carry the providers.+// Models is there wherever the host serves the model providers, beside DSH's own settings.const SETTINGS_PAGES = [['general', 'General'], ['models', 'Models'], ['bots', 'Bots'], ['groups', 'Group chats'], ['connectors', 'Connectors'], ['capabilities', 'Capabilities'], ['browser', 'Browser'], ['schedules', 'Scheduled tasks'], ['usage', 'Usage'], ['secrets', 'Secrets'], ['feedback', 'Feedback'], ['about', 'About DS Bot']]const PAGE_ICONS = { ...SETTINGS_ICONS, models: SlidersIcon, connectors: ConnectorIcon, capabilities: PlugIcon, browser: ConnectorIcon, schedules: ClockIcon, secrets: KeyIcon, feedback: FeedbackIcon, about: InfoIcon }@@ -268,8 +268,8 @@ export function SettingsDialog({ page, id, roster, actions, useUpdate, leaving =}, h(PAGE_ICONS[key]), t(text))),actions.openHarnessSettings ? h('button', {type: 'button', className: 'bt-settings-item bt-settings-shell', title: t('Models, providers, and the rest of DeepSeek Harness'),- onClick: () => { close(); actions.openHarnessSettings() },- }, h(SlidersIcon), t('Harness settings')) : null),+ onClick: () => { close(); (actions.openHarnessModels ?? actions.openHarnessSettings)() },+ }, h(SlidersIcon), t('Advanced settings (DeepSeek Harness)')) : null),h('div', { className: 'bt-settings-main' },h('div', { className: 'bt-settings-head' },back ? h('button', { type: 'button', className: 'bt-icon-btn', 'aria-label': back, title: back, onClick: () => actions.openSettings(shown) }, h(ChevronLeftIcon)) : null,diff --git a/ds-bot/src/client/sidebar.js b/ds-bot/src/client/sidebar.jsindex b6c7c7a1..62a34ece 100644--- a/ds-bot/src/client/sidebar.js+++ b/ds-bot/src/client/sidebar.js@@ -3,7 +3,7 @@ import { createPortal } from 'react-dom'import { FishLogo } from './dsh-primitives.js'import { isMainOf } from './sources.js'import { currentPart, previewOf, relativeShort } from './text.js'-import { PlusIcon, SearchIcon, SidebarIcon, GaugeIcon, PlugIcon, ClockIcon, GearIcon, PinMarkIcon, ConnectorIcon, SwitchIcon, CloudDownloadIcon, SignOutIcon } from './icons.js'+import { PlusIcon, SearchIcon, SidebarIcon, GaugeIcon, PlugIcon, ClockIcon, GearIcon, PinMarkIcon, ConnectorIcon, SwitchIcon, CloudDownloadIcon, SignInIcon, SignOutIcon, SlidersIcon } from './icons.js'import { MAIN_LOOK } from './characters.js'import { botState, BotMark, BotAvatar, RoomAvatar } from './mark.js'import { reducedMotion } from './activity-row.js'@@ -462,6 +462,23 @@ export function openHarnessOnboarding(id) {})}+// The launcher seat can only open DSH's settings on their first section. This onboarding+// step of DS Bot's own, opened by id, hands the shell's openSection the Models page; the+// first-run pass meets it last and it steps aside at once.+export const MODELS_STEP = 'ds-bot-models'+export const MODELS_STEP_ORDER = 1000++export function OpenModelsStep({ explicit, complete, openSection }) {+ useEffect(() => {+ if (explicit) {+ if (typeof openSection === 'function') openSection('models')+ else openHarnessSettings()+ }+ complete()+ }, [explicit])+ return null+}+function openThroughMenu(trigger) {const before = new Set(document.querySelectorAll('[role="menu"]'))trigger.click()@@ -534,6 +551,7 @@ export function AccountLauncher({ seat = true, settingsOpen, openSettings, openOconst accountSource = ops.hooks?.accountconst account = useSyncExternalStore(accountSource?.subscribe ?? NO_SUBSCRIBE, accountSource ? () => accountSource.getSnapshot() : NO_SNAPSHOT)const signedIn = signIn !== null && typeof ops.signOut === 'function' && account?.view?.status === 'credential-stored'+ const signedOut = signIn !== null && typeof actions.signIn === 'function' && account?.view?.status === 'signed-out'const accountT = actions.accountT?.() ?? (key => key)const [confirm, setConfirm] = useState(null)const [busy, setBusy] = useState(false)@@ -574,18 +592,22 @@ export function AccountLauncher({ seat = true, settingsOpen, openSettings, openOsetSignOutError('')setBusy(false)}, [open])+ // DS Bot's Models page where the host serves the providers, else DSH's own.+ const openModels = actions.providers ? actions.openModels : actions.openHarnessModelsconst groups = [[[t('Usage'), GaugeIcon, () => actions.openSettings('usage')],+ openModels ? [t('Models and API keys'), SlidersIcon, () => openModels()] : null,[t('Connectors'), ConnectorIcon, () => actions.openConnectors()],[t('Automation tasks'), ClockIcon, () => actions.selectPanel('schedules')],[t('Bot settings'), GearIcon, () => actions.openSettings('general')],- ],+ ].filter(Boolean),[[t('Switch to classic Agent mode'), SwitchIcon, () => actions.setSurface('agent')],],]if (signedIn) groups.push([[accountT('signOut'), SignOutIcon, askSignOut, undefined, true]])+ else if (signedOut) groups.push([[t('Sign in to DeepSeek'), SignInIcon, () => actions.signIn()]])return h(Fragment, null,h('button', { ref: button, type: 'button', className: 'bt-account', 'aria-label': t('Account'), 'aria-haspopup': 'menu', 'aria-expanded': open, onClick: toggle },h('span', { className: 'bt-you', 'aria-hidden': true }, h(BotMark, { look: MAIN_LOOK, size: 24 }))),diff --git a/ds-bot/src/client/styles.js b/ds-bot/src/client/styles.jsindex 94125e68..0648233f 100644--- a/ds-bot/src/client/styles.js+++ b/ds-bot/src/client/styles.js@@ -464,6 +464,7 @@ body[data-ds-dark-theme] .bt-scrim{background:rgba(0,0,0,.5)}.bt-settings-nav>.bt-thumb{left:8px;right:8px;border-radius:8px;background:var(--bt-active)}.bt-settings-nav[data-glide] .bt-settings-item[aria-current=page]{background:transparent}.bt-settings-shell{margin-top:auto}+.bt-settings-item>svg{flex:none}/* Usage while another page is open: out of the flow, so it keeps its layout, and notrendered. */.bt-settings-usage[data-off]{position:absolute;top:0;left:198px;width:calc(var(--bt-set-w) - 198px);height:100%;box-sizing:border-box;content-visibility:hidden;pointer-events:none}diff --git a/ds-bot/src/client/team-actions.js b/ds-bot/src/client/team-actions.jsindex d8ada868..06111120 100644--- a/ds-bot/src/client/team-actions.js+++ b/ds-bot/src/client/team-actions.js@@ -12,6 +12,8 @@ export function teamActions({ call, after, partFor, roster, ui, live, cards, helconst openSideChat = (sessionId, chatId) => {ui.set(state => ({ ...state, details: sessionId, view: 'side', side: chatId ?? null, renaming: false, tab: null }))}+ // `id` opens one Bot (page 'bots') or one group chat (page 'groups').+ const openSettings = (page = 'general', id = null) => { ui.set(state => ({ ...state, settings: { page, id }, menu: null, palette: null, newChat: null })) }return {openNewChat: (mode) => { ui.set(state => ({ ...state, newChat: mode, menu: null, palette: null })) },openPalette: (query = '') => { ui.set(state => ({ ...state, palette: { query, token: Date.now() }, newChat: null, menu: null })) },@@ -42,8 +44,9 @@ export function teamActions({ call, after, partFor, roster, ui, live, cards, helshowDetails: (id, tab = null) => { ui.set(state => ({ ...state, details: id, view: 'details', renaming: false, tab })) },// Opening the conversation would move focus to its composer and blur the name field.renameBot: (id) => { ui.set(state => ({ ...state, details: id, view: 'details', renaming: true, tab: null })) },- // `id` opens one Bot (page 'bots') or one group chat (page 'groups').- openSettings: (page = 'general', id = null) => { ui.set(state => ({ ...state, settings: { page, id }, menu: null, palette: null, newChat: null })) },+ openSettings,+ // DS Bot's own Models page: the providers DSH serves, their keys and models.+ openModels: () => openSettings('models'),closeSettings: () => { ui.set(state => (state.settings ? { ...state, settings: null } : state)) },openMemory: (id) => { ui.set(state => ({ ...state, memory: id, menu: null, palette: null })) },closeMemory: () => { ui.set(state => (state.memory ? { ...state, memory: null } : state)) },@@ -82,6 +85,14 @@ export function teamActions({ call, after, partFor, roster, ui, live, cards, helupdateBot: (id, patch) => after(call('update-bot', { id, ...patch })),refreshModels: () => after(call('models')).catch(() => {}),efforts: ref => call('efforts', { ref }),+ // Model providers and their API keys; DSH keeps them, and a key only travels to the host.+ providers: () => call('providers'),+ setProviderKey: (provider, value) => after(call('provider-key', { provider, value })),+ addProvider: body => after(call('provider-add', body)),+ providerModels: body => call('provider-models', body),+ removeProvider: provider => after(call('provider-remove', { provider })),+ // After a failed turn: the Bot answers the user's last unanswered message, which is never sent again.+ resume: botId => after(call('resume', { botId })),folders: () => call('folders'),folderPick: () => call('folder-pick'),folderList: path => call('folder-list', { path: path ?? '' }),diff --git a/ds-bot/src/client/turn-error.js b/ds-bot/src/client/turn-error.jsnew file mode 100644index 00000000..eba687ab--- /dev/null+++ b/ds-bot/src/client/turn-error.js@@ -0,0 +1,260 @@+import { createElement as h, useEffect, useMemo, useState, useSyncExternalStore } from 'react'+import { currentPart, isHiddenTurn } from './text.js'+import { CheckIcon, CopyIcon } from './icons.js'+import { ModelKeyCard, manageModels } from './model-menu.js'+import { knownFailure } from './diagnostics.js'+import { hostText, t } from './i18n.js'++// -------------------------------------------------------------------------+// A failed turn in a Bot's chat: what went wrong and what the user can do about it,+// in place of DSH's row. The copy and the fixes go by DSH's stable failure code, never+// by the provider's message, which shows only under Technical details. The chat node+// carries no HTTP status or request id; the host keeps them, with the failing route's+// provider, on the Bot as `blocked` while a credential or balance failure stands.++const OFFICIAL = 'deepseek-official'+const ACCOUNT = 'deepseek-account'+const TOP_UP_URL = 'https://platform.deepseek.com/top_up'+// How long a sign-in started here waits for the account's models before the user picks.+const ACCOUNT_MODELS_WAIT_MS = 20_000+const SIGNED_OUT = new Set(['ACCOUNT_SIGN_IN_REQUIRED', 'ACCOUNT_SIGNED_OUT', 'ACCOUNT_TOKEN_INVALID'])+// Failures of an API key route; the account route never has them.+const KEY_CODES = new Set(['MISSING_CREDENTIAL', 'INVALID_CREDENTIAL', 'AUTH'])+// Until the credentials change the host keeps these on the Bot, and a retry would fail+// the same way, so Retry waits for the fix.+const CREDENTIAL_CODES = new Set([...KEY_CODES, ...SIGNED_OUT])++// The sentence for one failure. `status` is the HTTP status, when the host has it.+export function failureText(code, { name, provider, status }) {+ switch (code) {+ case 'MISSING_CREDENTIAL': return t("{name}'s model has no API key yet.", { name })+ case 'INVALID_CREDENTIAL': return t('This API key is not in the right format.')+ case 'AUTH': return status === undefined+ ? t('{provider} did not accept the current API key.', { provider })+ : t('{provider} did not accept the current API key ({status}).', { provider, status })+ case 'QUOTA': return status === undefined+ ? t('{provider} is out of balance or quota.', { provider })+ : t('{provider} is out of balance or quota ({status}).', { provider, status })+ case 'ACCOUNT_QUOTA': return t('The DeepSeek account balance is too low.')+ case 'ACCOUNT_SIGN_IN_REQUIRED':+ case 'ACCOUNT_SIGNED_OUT':+ case 'ACCOUNT_TOKEN_INVALID': return t('The DeepSeek account sign-in has expired.')+ case 'TRANSPORT':+ case 'TIMEOUT': return t('Could not reach the model service.')+ case 'RATE_LIMIT': return t('Too many requests. Wait a moment, then try again.')+ case 'SERVER': return t('The model service failed.')+ case 'INTERRUPTED': return t('DeepSeek Harness stopped before this turn finished.')+ default: return knownFailure(code) ?? t('This turn failed.')+ }+}++// The fixes one failure offers, the one to try first leading. Each is offered only+// where this window can carry it out. A Bot moved onto the account route since a key+// failure has nothing left to fix there.+export function fixesFor(code, { canSignIn, official, topUp, onAccount = false }) {+ if (onAccount && KEY_CODES.has(code)) return []+ if (SIGNED_OUT.has(code)) return canSignIn ? ['sign-in-again'] : ['model']+ switch (code) {+ case 'MISSING_CREDENTIAL': return ['key', canSignIn ? 'sign-in' : null, 'model'].filter(Boolean)+ case 'INVALID_CREDENTIAL': return ['rekey', 'model']+ case 'AUTH': return ['rekey', canSignIn ? 'use-account' : null, 'model'].filter(Boolean)+ case 'QUOTA': return official ? ['top-up'] : []+ case 'ACCOUNT_QUOTA': return topUp ? ['top-up'] : []+ default: return []+ }+}++export const retryShown = (code, blocked) => !CREDENTIAL_CODES.has(code) || blocked === undefined++const FIX_LABELS = {+ key: () => t('Enter API key'),+ rekey: () => t('Enter the key again'),+ 'sign-in': signedIn => (signedIn ? t('Use the DeepSeek account') : t('Sign in with a DeepSeek account')),+ 'use-account': () => t('Use a DeepSeek account instead'),+ 'sign-in-again': () => t('Sign in again'),+ model: () => t('Pick another model'),+ 'top-up': () => t('Top up ↗'),+}++const NO_SUBSCRIBE = () => () => {}+const NO_VIEW = () => null++// The shell account plugin's view of the DeepSeek account: its sign-in status and links.+function useAccountView(actions) {+ const entry = actions.signInEntry?.() ?? null+ const ops = useMemo(() => entry?.inject?.() ?? {}, [entry])+ const source = ops.hooks?.account+ const read = source ? () => source.getSnapshot()?.view ?? null : NO_VIEW+ return useSyncExternalStore(source?.subscribe ?? NO_SUBSCRIBE, read, read)+}++// The DeepSeek account's own top-up page.+const topUpOf = (view) => {+ const url = view?.links?.topUpUrl+ return typeof url === 'string' && url.startsWith('https://') ? url : undefined+}++// The account route's model for a Bot moved onto it: the DSH default when it is one,+// else the first one listed. The account lists its models only once it is signed in,+// a moment after the sign-in itself.+export function accountModel(roster) {+ const models = (roster.models ?? []).filter(model => model.provider === ACCOUNT)+ return (models.find(model => model.ref === roster.defaultModel) ?? models[0])?.ref+}++const providerOf = (bot, roster) => {+ const ref = bot?.model ?? bot?.appliedModel+ if (!ref) return undefined+ return (roster.models ?? []).find(model => model.ref === ref)?.provider ?? ref.split('/')[0]+}+// A provider without a key may not be in the catalog yet, so DeepSeek's own two routes+// keep a readable name instead of their id.+const KNOWN_PROVIDERS = { 'deepseek-official': 'DeepSeek', 'deepseek-account': 'DeepSeek account' }+const providerName = (roster, provider) => (provider === undefined+ ? t('The model service')+ : (roster.models ?? []).find(model => model.provider === provider)?.providerName+ ?? (KNOWN_PROVIDERS[provider] ? t(KNOWN_PROVIDERS[provider]) : provider))++// What Technical details lists, and copies in English for a report.+export function failureFacts(data, blocked) {+ const facts = []+ if (data.code) facts.push(['Code', t('Code'), data.code])+ if (blocked?.status !== undefined) facts.push(['HTTP status', t('HTTP status'), String(blocked.status)])+ if (blocked?.requestId) facts.push(['Request ID', t('Request ID'), blocked.requestId])+ // DSH already blanks an AUTH message; it never shows here either way.+ if (data.code !== 'AUTH' && data.message) facts.push(['Message', t('Provider message'), data.message])+ return facts+}++function TechnicalDetails({ facts }) {+ const [copied, setCopied] = useState(false)+ if (facts.length === 0) return null+ const copy = () => {+ const text = facts.map(([name, , value]) => `${name}: ${value}`).join('\n')+ void navigator.clipboard?.writeText(text).then(() => { setCopied(true); setTimeout(() => setCopied(false), 1000) }).catch(() => {})+ }+ return h('details', { className: 'bt-fail-tech' },+ h('summary', null, t('Technical details')),+ h('dl', null, facts.map(([name, label, value]) => [h('dt', { key: `${name}:t` }, label), h('dd', { key: `${name}:d` }, value)])),+ h('button', { type: 'button', className: 'bt-mini bt-fail-copy', onClick: copy }, copied ? h(CheckIcon) : h(CopyIcon), copied ? t('Copied') : t('Copy')))+}++export function FailureCell({ node, sessionId, useRoster, useTurnClock, actions }) {+ const roster = useRoster(value => value)+ const data = node?.data ?? {}+ const bot = roster.byId?.[sessionId]+ // A later turn, or a later part of the Bot's chat, has moved past this failure.+ const later = useTurnClock(state => Object.keys(state[sessionId] ?? {}).some(turn => Number(turn) > data.turn))+ const account = useAccountView(actions)+ const signedIn = account?.status === 'credential-stored'+ const topUp = topUpOf(account)+ const [keying, setKeying] = useState(false)+ const [retry, setRetry] = useState('idle')+ const [error, setError] = useState('')+ // A sign-in started here to leave a failing key route, with the model the Bot was on.+ const [joining, setJoining] = useState(null)+ const blocked = bot?.blocked?.code === data.code ? bot.blocked : undefined+ const provider = blocked?.provider ?? providerOf(bot, roster)+ const text = failureText(data.code, { name: bot?.name ?? t('This Bot'), provider: providerName(roster, provider), status: blocked?.status })+ const facts = failureFacts(data, blocked)+ const current = bot !== undefined && currentPart(bot) === sessionId && !later+ // The key route never takes the account's credential, so a sign-in alone leaves the Bot+ // failing; it moves onto the account route. With no account model listed yet, the+ // user picks one.+ const moveToAccount = () => {+ const model = accountModel(roster)+ if (model === undefined) { actions.showDetails?.(sessionId); return }+ if (model === bot.model) return+ setError('')+ void Promise.resolve(actions.updateBot(bot.id, { model })).catch(failure => setError(hostText(failure?.message ?? String(failure))))+ }+ const listed = accountModel(roster)+ useEffect(() => {+ if (joining === null || !signedIn) return undefined+ // A model the user picked meanwhile stands.+ if (bot === undefined || bot.model !== joining.from) { setJoining(null); return undefined }+ if (listed !== undefined) { setJoining(null); moveToAccount(); return undefined }+ // The account's models come with the next listing; without them for a while, the+ // user picks.+ void actions.refreshModels?.()+ const timer = setTimeout(() => { setJoining(null); actions.showDetails?.(sessionId) }, ACCOUNT_MODELS_WAIT_MS)+ return () => clearTimeout(timer)+ }, [joining, signedIn, listed])+ const settled = () => h('div', { className: 'bt-fail', 'data-settled': '', role: 'status' },+ h('div', { className: 'bt-fail-head' }, h('span', { className: 'bt-fail-dot', 'aria-hidden': true }), h('span', { className: 'bt-fail-text' }, text)),+ h(TechnicalDetails, { facts }))+ if (!current) return settled()+ const official = provider === OFFICIAL+ const canSignIn = typeof actions.signIn === 'function' && actions.canSignIn?.() === true+ const keyHere = typeof actions.setProviderKey === 'function' && provider !== undefined+ const keyElsewhere = official && actions.openHarnessOnboarding ? () => actions.openHarnessOnboarding(OFFICIAL) : manageModels(actions)+ const viaAccount = () => {+ if (signedIn) { moveToAccount(); return }+ setJoining({ from: bot.model })+ actions.signIn()+ }+ const runs = {+ key: keyHere ? () => setKeying(value => !value) : keyElsewhere,+ rekey: keyHere ? () => setKeying(value => !value) : keyElsewhere,+ 'sign-in': viaAccount,+ 'use-account': viaAccount,+ 'sign-in-again': () => actions.signIn(),+ model: actions.showDetails ? () => actions.showDetails(sessionId) : undefined,+ }+ const fixes = fixesFor(data.code, { canSignIn, official, topUp: topUp !== undefined, onAccount: provider === ACCOUNT }).filter(fix => fix === 'top-up' || runs[fix] !== undefined)+ // A turn another Bot asked for answers that Bot, which was already told it failed.+ // Retry would answer the user's last message instead, so it is not offered.+ const asked = isHiddenTurn(roster, sessionId, data.turn)+ const retrying = !asked && typeof actions.resume === 'function' && retryShown(data.code, blocked)+ // Once a credential failure is fixed, going on is the next step.+ const retryFirst = retrying && (fixes.length === 0 || CREDENTIAL_CODES.has(data.code))+ const resume = () => {+ setRetry('busy')+ setError('')+ void Promise.resolve(actions.resume(bot.id))+ .then(() => setRetry('sent'), (failure) => { setRetry('idle'); setError(hostText(failure?.message ?? String(failure))) })+ }+ const button = (fix, primary) => {+ const className = primary ? 'bt-send bt-fail-go' : 'bt-soft bt-soft-sm'+ if (fix === 'top-up') {+ return h('a', { key: fix, className: `${className} bt-fail-link`, href: data.code === 'ACCOUNT_QUOTA' ? topUp : TOP_UP_URL, target: '_blank', rel: 'noopener noreferrer' }, FIX_LABELS[fix]())+ }+ const toggles = keyHere && (fix === 'key' || fix === 'rekey')+ return h('button', { key: fix, type: 'button', className, 'aria-expanded': toggles ? keying : undefined, onClick: () => runs[fix]() }, FIX_LABELS[fix](signedIn))+ }+ const retryButton = primary => h('button', { key: 'retry', type: 'button', className: primary ? 'bt-send bt-fail-go' : 'bt-soft bt-soft-sm', disabled: retry !== 'idle', onClick: resume }, retry === 'idle' ? t('Retry') : t('Retrying…'))+ const row = retryFirst+ ? [retryButton(true), ...fixes.map(fix => button(fix, false))]+ : [...fixes.map((fix, index) => button(fix, index === 0)), retrying ? retryButton(false) : null]+ // With nothing to do here the card reads as one a later turn moved past.+ if (!row.some(Boolean)) return settled()+ return h('div', { className: 'bt-fail', role: 'status' },+ h('div', { className: 'bt-fail-head' }, h('span', { className: 'bt-fail-dot', 'aria-hidden': true }), h('span', { className: 'bt-fail-text' }, text)),+ h('div', { className: 'bt-fail-actions' }, row),+ keying && keyHere ? h(ModelKeyCard, { model: { provider, providerName: providerName(roster, provider) }, actions, onSaved: () => setKeying(false) }) : null,+ error ? h('div', { className: 'bt-fail-error', role: 'alert' }, error) : null,+ h(TechnicalDetails, { facts }))+}++export const TURN_ERROR_CSS = `+.bt-fail{display:flex;flex-direction:column;gap:10px;margin:4px 0 6px;width:max-content;max-width:min(550px,86%);padding:12px 14px;border-radius:16px;background:var(--bt-card);box-shadow:inset 0 0 0 1px var(--bt-line);box-sizing:border-box;color:var(--bt-ink);font-size:14px;line-height:20px}+.bt-fail[data-settled]{gap:4px;padding:2px 0;background:none;box-shadow:none;color:var(--bt-ink-2);font-size:13px;line-height:18px}+.bt-fail-head{display:flex;align-items:flex-start;gap:8px;min-width:0}+.bt-fail-dot{flex:none;width:7px;height:7px;margin-top:6.5px;border-radius:50%;background:var(--bt-danger)}+.bt-fail[data-settled] .bt-fail-dot{margin-top:5.5px}+.bt-fail-text{min-width:0;overflow-wrap:anywhere}+.bt-fail-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-left:15px}+.bt-fail-actions .bt-fail-go{height:28px;padding:0 12px;font:inherit;font-size:12px}+.bt-fail-link{display:inline-flex;align-items:center;box-sizing:border-box;text-decoration:none}+.bt-fail:has(.bt-model-key){width:min(480px,86%)}+.bt-fail .bt-q.bt-model-key{margin:0 0 0 15px;width:auto;padding:0;background:none;box-shadow:none;border-radius:0;animation:none}+.bt-fail-error{margin-left:15px;font-size:12px;line-height:17px;color:var(--bt-danger);overflow-wrap:anywhere}+.bt-fail-tech{margin-left:15px;font-size:12px;line-height:17px;color:var(--bt-ink-2)}+.bt-fail-tech summary{width:max-content;cursor:pointer;color:var(--bt-ink-3)}+.bt-fail-tech summary:hover{color:var(--bt-ink-2)}+.bt-fail-tech dl{display:grid;grid-template-columns:auto minmax(0,1fr);gap:2px 10px;margin:6px 0}+.bt-fail-tech dt{color:var(--bt-ink-3)}+.bt-fail-tech dd{margin:0;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11.5px;overflow-wrap:anywhere;white-space:pre-wrap;user-select:text}+.bt-fail-copy{display:inline-flex;align-items:center;gap:4px}+.bt-fail-copy svg{width:13px;height:13px}+`diff --git a/ds-bot/src/host/channel.js b/ds-bot/src/host/channel.jsindex 83064f3f..433433ee 100644--- a/ds-bot/src/host/channel.js+++ b/ds-bot/src/host/channel.js@@ -42,7 +42,8 @@ export function install(rt) {mainBotId: state.mainBotIds[0] ?? null,mainBotIds: state.mainBotIds,// `sessionId` is the Bot's current own-chat part; `parts` its earlier ones.- // `waiting`: the Bot holds its greeting until the user picks its model.+ // `waiting`: the Bot holds its greeting until the user picks its model or fixes+ // what failed it. `blocked`: the facts of a failure only the user can fix (turns.js).bots: Object.values(state.bots).map(({ segments, kickoff, ...bot }) => ({...bot, sessionId: rt.chatOf(bot.id), parts: (segments ?? []).map(segment => segment.sessionId), ...(kickoff ? { waiting: true } : {}),})),@@ -232,6 +233,14 @@ export function install(rt) {case 'update-bot':await rt.load()return ok(await rt.updateBot(body.id, body))+ // The repair card's Retry, once the user fixed what failed the Bot's turn.+ case 'resume': {+ await rt.load()+ const bot = rt.botOf(String(body.botId ?? ''))+ if (bot === undefined) return fail('Unknown Bot', 'bot/not-found')+ await rt.resumeBot(bot)+ return ok(true)+ }case 'delete-bot':await rt.load()await rt.deleteBot(body.id)diff --git a/ds-bot/src/host/delivery.js b/ds-bot/src/host/delivery.jsindex 96220244..1cae9ae0 100644--- a/ds-bot/src/host/delivery.js+++ b/ds-bot/src/host/delivery.js@@ -28,6 +28,7 @@ export function install(rt) {if (role === 'room') return `[Group chat "${roomName}" · ${note}]`if (role === 'report') return `[Group chat "${roomName}" · replies to your post${goesOn}]`if (role === 'kickoff') return '[Bot team setup]'+ if (role === 'continue') return '[Retry after a failed turn]'if (role === 'secret') return '[Secret card]'if (audience === 'user') return `[Message from ${fromName} · the user sees your reply here]`return `[Message from ${fromName}]`diff --git a/ds-bot/src/host/memory.js b/ds-bot/src/host/memory.jsindex de583e91..3b65ea32 100644--- a/ds-bot/src/host/memory.js+++ b/ds-bot/src/host/memory.js@@ -1236,7 +1236,7 @@ export function install(rt) {async function modelFor(bot) {const route = splitRef(await rt.desiredModel(bot) ?? await rt.defaultModel())- if (route === undefined) throw new Error('No model is available. Add one in Harness settings.')+ if (route === undefined) throw new Error('No model is available. Add one in Settings > Models.')return route}// The panel's model calls belong to the Bot or group whose memory they serve;diff --git a/ds-bot/src/host/models.js b/ds-bot/src/host/models.jsindex 3bb8474a..fb8e4f0a 100644--- a/ds-bot/src/host/models.js+++ b/ds-bot/src/host/models.js@@ -5,6 +5,8 @@ import { normalize, splitRef } from './text.js'const CATALOG_TTL_MS = 10_000const ROUTE_WAIT_MS = 30_000+// The DeepSeek account's sign-in grant (dsh-deepseek-account-platform).+const ACCOUNT_RECORD = 'deepseek-account-platform/default'export function install(rt) {const { ctx, state } = rt@@ -14,8 +16,32 @@ export function install(rt) {// A model's thinking levels, resolved once and kept for a short while: they change// only with the provider, which also drops the catalog cache.const reasoningCache = new Map()- ctx.on?.('llm/adapters-updated', () => { catalogCache = { at: 0, value: [] }; reasoningCache.clear() })- for (const name of ['credentials/reference-updated', 'settings/document-updated']) ctx.on?.(name, () => { catalogCache = { at: 0, value: [] } })+ const dropCatalog = () => { catalogCache = { at: 0, value: [] } }+ // A key set or a sign-in may be the user's fix for a Bot's failed turn (turns.js); a+ // key removed or a sign-out is not. A provider that registers or changes fixes+ // nothing by itself: providers register late at every start.+ ctx.on?.('llm/adapters-updated', () => { dropCatalog(); reasoningCache.clear() })+ ctx.on?.('credentials/reference-updated', async (ref) => {+ dropCatalog()+ if (await inPlace(credentials => credentials.describe(ref))) rt.unblockBots?.({ ref })+ })+ // A sign-in writes the account's record. A sign-out removes it, and so does a token+ // the provider refused, while the turn that failed on it still runs. Other plugins'+ // records (an OAuth token refresh) say nothing about the account.+ ctx.on?.('credentials/record-updated', async (key) => {+ dropCatalog()+ if (String(key) !== ACCOUNT_RECORD) return+ if (await inPlace(credentials => credentials.describeRecord(key))) rt.unblockBots?.({ signedIn: true })+ })+ ctx.on?.('settings/document-updated', dropCatalog)++ // Whether a credential is there after a change. One that cannot be read counts as+ // there, so a fix is not missed.+ async function inPlace(describe) {+ const credentials = ctx.get?.('credentials')+ if (credentials === undefined) return true+ try { return (await describe(credentials))?.configured !== false } catch { return true }+ }// The thinking levels a model serves: `{efforts: [{id, name, description?}],// defaultEffort?}`, or undefined when it has none or the provider cannot say.@@ -56,6 +82,9 @@ export function install(rt) {// turn on them fails.const missing = await rt.missingKeys?.([...new Set(entries.map(entry => entry.provider))]) ?? new Set()for (const entry of entries) if (missing.has(entry.provider)) entry.needsKey = true+ // A key can arrive without an event (an environment variable at the next start), so+ // a provider listed with its key again lifts what its missing key blocked.+ rt.unblockBots?.({ keyed: new Set(entries.filter(entry => !entry.needsKey).map(entry => entry.provider)) })const used = new Set(Object.values(state.bots ?? {}).flatMap(bot => [bot.model, bot.appliedModel].filter(Boolean)))await Promise.all(entries.filter(entry => used.has(entry.ref)).map(async (entry) => {const reasoning = await reasoningOf(entry.ref)@@ -70,10 +99,16 @@ export function install(rt) {const selection = ctx.get?.('agentDefaultModel')?.currentSelection?.()return selection?.provider && selection?.model ? `${selection.provider}/${selection.model}` : undefined}- // The profile default model of DSH, when it is served; else the first served model.+ // A model whose provider has no key fails every turn, so no Bot is given one unasked.+ const usableOf = entries => entries.filter(entry => entry.needsKey !== true)+ // By the catalog as last listed, without waiting for a fresh one.+ const isUsable = ref => usableOf(catalogCache.value).some(entry => entry.ref === ref)+ // The profile default model of DSH, when it is served and usable; else the first+ // usable model; else none.function pickDefault(entries) {+ const usable = usableOf(entries)const ref = defaultRef()- return entries.find(entry => entry.ref === ref)?.ref ?? entries[0]?.ref+ return usable.find(entry => entry.ref === ref)?.ref ?? usable[0]?.ref}const defaultModel = async () => pickDefault(await catalog())@@ -93,12 +128,13 @@ export function install(rt) {}// A Bot with no model yet waits for the user to pick one and changes nothing. A- // model that is no longer served falls back to the last one it ran on, then the default.+ // model that is no longer served falls back to the last one it ran on, then the+ // default; a fallback is never one that needs a key.async function desiredModel(bot) {if (!bot.model) return undefinedconst entries = await catalog()- const served = new Set(entries.map(entry => entry.ref))- return [bot.model, bot.appliedModel].find(ref => ref && served.has(ref)) ?? pickDefault(entries)+ if (entries.some(entry => entry.ref === bot.model)) return bot.model+ return usableOf(entries).some(entry => entry.ref === bot.appliedModel) ? bot.appliedModel : pickDefault(entries)}// The thinking level a Bot asked for, when the model it runs on serves it; else the@@ -201,8 +237,7 @@ export function install(rt) {Object.assign(rt, {catalog, cachedCatalog: () => catalogCache.value, cachedDefault: () => pickDefault(catalogCache.value),- defaultRef, defaultModel, resolveModel, desiredModel, reasoningOf, resolveEffort, desiredEffort,- selectSessionModel, applyModel, waitForModel, syncModels,- dropCatalog: () => { catalogCache = { at: 0, value: [] } },+ defaultRef, defaultModel, isUsable, resolveModel, desiredModel, reasoningOf, resolveEffort, desiredEffort,+ selectSessionModel, applyModel, waitForModel, syncModels, dropCatalog,})}diff --git a/ds-bot/src/host/roster.js b/ds-bot/src/host/roster.jsindex b4b79a9d..1f433973 100644--- a/ds-bot/src/host/roster.js+++ b/ds-bot/src/host/roster.js@@ -8,6 +8,11 @@ import { nameProblem } from '../shared/mentions.js'const BROWSER_GRANT_KINDS = new Set(['post', 'upload', 'download', 'delete', '*'])const HOSTNAME = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?))*$/+const OWN_RULES = 'Where your instructions say otherwise, follow them.'+const writeIn = language => `Write in ${language ?? 'the user\'s language if known; otherwise Chinese'}.`+// The first Main Bot's greeting when the user wrote before it had a model that works.+const AFTER_USER = 'You were just set up as the user\'s Main Bot. The user wrote to you before your model could answer; their message above has no answer yet. Answer it now, and say in one short sentence that you run their Bot team.'+function cleanBrowserGrants(input) {if (input === null) return nullif (!Array.isArray(input) || input.length > 50) throw new Error('Browser grants must be an array of at most 50 entries')@@ -128,7 +133,8 @@ export function install(rt) {}// `pickModel` leaves the model to the user: the chat opens on a model card, and the- // greeting waits until a model is chosen. So does a Bot made when no model is served.+ // greeting waits until a model is chosen. So does a Bot made when no model it can+ // run on is served.async function createBot(options) {const cleanName = String(options.name ?? '').trim().slice(0, 40)const problem = nameProblem(cleanName)@@ -170,7 +176,7 @@ export function install(rt) {// The kickoff arrives as a user message, so it outranks the Bot's instructions// unless it gives way to them, and it names no tool those instructions may rule out.const kickoff = main- ? `You were just set up as the user's Main Bot. Greet the user in one or two short messages: say you will run their Bot team and that they can come to you for anything that needs a decision. Then ask in one short question what they want the team to help with first. Write in ${language ?? 'the user\'s language if known; otherwise Chinese'}.`+ ? `You were just set up as the user's Main Bot. Greet the user in one or two short messages: say you will run their Bot team and that they can come to you for anything that needs a decision. Then ask in one short question what they want the team to help with first. ${writeIn(language)}`: original? `The user just made you as a copy of ${original.name}: same job, fresh memory. Greet the user in one short message, then ask in one short question what this copy should focus on.`: creator@@ -178,11 +184,12 @@ export function install(rt) {: brief? `The user just created you and sent this first message:\n\n${brief}\n\nIntroduce yourself in one short line, then help with it.`: 'The user just created you. Greet the user in one short message, then ask in one short question what you should focus on.'- const opener = `${kickoff}\nWhere your instructions say otherwise, follow them.`+ const opener = `${kickoff}\n${OWN_RULES}`const text = !main && language ? `${opener}\nWrite in ${language}.` : openerconst bot = state.bots[id]+ const greeting = { text, from: createdBy ?? null, ...(main ? { main: true } : {}) }if (modelRef === undefined) {- bot.kickoff = { text, from: createdBy ?? null, ...(main ? { main: true } : {}) }+ bot.kickoff = greetingawait rt.save()return bot}@@ -190,7 +197,7 @@ export function install(rt) {// The greeting runs on the Bot's own model, once its provider is registered.void rt.waitForModel(bot).then(() => rt.applyModel(bot).catch(error => rt.warn('ds-bot: model for %s not applied: %s', cleanName, error)))- .then(() => sendKickoff(bot, { text, from: createdBy }))+ .then(() => sendKickoff(bot, greeting))return bot} catch (error) {// The Bot's Session was already made: archive it instead of leaving an orphan.@@ -206,15 +213,65 @@ export function install(rt) {}}- function sendKickoff(bot, { text, from }) {- void rt.deliver({ fromId: from ?? undefined, toId: bot.id, text, role: 'kickoff' })+ // Greetings sent, by Bot: one whose turn a key, a sign-in or a balance stops is held+ // again (turns.js), to go out once the user has fixed that.+ const sentKickoffs = new Map()+ function sendKickoff(bot, greeting) {+ sentKickoffs.set(bot.id, greeting)+ const text = greeting.afterUser ? `${AFTER_USER} ${writeIn(rt.uiLanguage?.())}\n${OWN_RULES}` : greeting.text+ void rt.deliver({ fromId: greeting.from ?? undefined, toId: bot.id, text, role: 'kickoff' }).catch(error => rt.warn('ds-bot: kickoff failed: %s', error))}- // The user wrote first, so the held greeting would only interrupt.- function dropKickoff(botId) {+ // A held greeting goes out once its Bot has a model, on that model once its provider+ // is registered. False while the Bot has none.+ const releasing = new Set()+ async function releaseKickoff(bot) {+ const greeting = bot.kickoff+ if (greeting === undefined || !bot.model) return false+ delete bot.kickoff+ releasing.add(bot.id)+ await rt.save().catch((error) => { releasing.delete(bot.id); throw error })+ const send = () => { releasing.delete(bot.id); sendKickoff(bot, greeting) }+ void rt.waitForModel(bot).then(send, send)+ return true+ }++ // A greeting on its way to a Bot: released and waiting for its model, or sent to its+ // chat and not yet taken up by a turn there (resume.js notes what no turn took up).+ const greetingOut = botId => releasing.has(botId)+ || (rt.unreadOf?.(rt.chatOf(botId)) ?? []).some(args => args.role === 'kickoff')++ function holdKickoffAgain(botId) {const bot = rt.botOf(botId)- if (bot?.kickoff === undefined) return+ const greeting = sentKickoffs.get(botId)+ sentKickoffs.delete(botId)+ if (bot === undefined || greeting === undefined || bot.kickoff !== undefined) return+ // "You are the Main Bot" must not go out after a demotion.+ if (greeting.main && !rt.isMain(botId)) return+ bot.kickoff = greeting+ void rt.save().catch(() => {})+ }++ // The user wrote in a Bot's own chat, so a held greeting would only interrupt. The+ // first Main Bot's stays while that Bot has no model it can run on, and a Bot that a+ // key, a sign-in or a balance blocks has none: once it has one, it answers the message+ // first, unless a turn answered it meanwhile (userAnswered). Read from the catalog as+ // last listed, so it is marked before that turn can end.+ function userWrote(botId) {+ const bot = rt.botOf(botId)+ const greeting = bot?.kickoff+ if (greeting === undefined || greeting.afterUser) return+ if (greeting.main && (bot.blocked !== undefined || !rt.isUsable(bot.model))) greeting.afterUser = true+ else delete bot.kickoff+ void rt.save().catch(() => {})+ }++ // A turn that answered the user in a Bot's own chat leaves nothing for a greeting held+ // for that message to answer.+ function userAnswered(botId) {+ const bot = rt.botOf(botId)+ if (bot?.kickoff?.afterUser !== true) returndelete bot.kickoffvoid rt.save().catch(() => {})}@@ -290,6 +347,8 @@ export function install(rt) {else delete bot.avatar}if (patch.model !== undefined) {+ // A failure that blocked the Bot was its old model's (turns.js).+ if ((modelRef ?? undefined) !== bot.model) delete bot.blockedif (modelRef === null) delete bot.modelelse bot.model = modelRefmodelChanged = true@@ -312,12 +371,8 @@ export function install(rt) {await rt.save()if (modelChanged) await rt.applyModel(bot, { force: true })if (moved) void rt.followFolder(bot.id)- if (bot.model && bot.kickoff !== undefined) {- const held = bot.kickoff- delete bot.kickoff- await rt.save()- sendKickoff(bot, held)- }+ // A new model lifted what blocked the Bot; a new thinking level alone fixes nothing.+ if (modelChanged && bot.blocked === undefined) await releaseKickoff(bot)return bot}@@ -649,6 +704,6 @@ export function install(rt) {Object.assign(rt, {ensureWorkspace, keepTeamFolder, createSession, createBot, duplicateBot, updateBot, setFlags,roomBusy, autoRoomName, retitleRoom, createRoom, updateRoom, deleteRoom,- setMain, deleteBot, bootstrap, dropKickoff,+ setMain, deleteBot, bootstrap, releaseKickoff, greetingOut, holdKickoffAgain, userWrote, userAnswered,})}diff --git a/ds-bot/src/host/tools.js b/ds-bot/src/host/tools.jsindex 7a7942f8..2f586b4b 100644--- a/ds-bot/src/host/tools.js+++ b/ds-bot/src/host/tools.js@@ -318,8 +318,8 @@ export function install(rt) {// Without a named model the new Bot takes its creator's: the DSH default may be// a provider that has no key, and then the new Bot fails on its first reply.const creator = callerBot(exec)- const served = creator?.model && (await rt.catalog()).some(entry => entry.ref === creator.model)- const model = args.model || (served ? creator.model : undefined)+ const usable = creator?.model && (await rt.catalog()).some(entry => entry.ref === creator.model && !entry.needsKey)+ const model = args.model || (usable ? creator.model : undefined)const bot = await rt.createBot({ ...args, avatar: avatar === undefined ? undefined : { image: avatar }, model, workDir, effort: args.effort, createdBy: creator?.id })return `Created ${bot.name}${workDir ? `, working in ${workDir}` : ''}. It is greeting the user now.`} catch (error) {diff --git a/ds-bot/src/host/turns.js b/ds-bot/src/host/turns.jsindex a0e31295..64839bc5 100644--- a/ds-bot/src/host/turns.js+++ b/ds-bot/src/host/turns.js@@ -4,9 +4,17 @@// Turn tracking: which turns were triggered by another Bot, and what they said.import { HANDOFF_ACK, MESSAGE_INLINE_MAX, REFERENCE_KIND, REPLY_KIND, SOURCE_KIND } from './constants.js'import { absoluteLinks } from './links.js'-import { textOf } from './text.js'+import { splitRef, textOf } from './text.js'import { reminderText } from './schedules.js'+// Failures only the user can fix: a key, a sign-in, a balance. They block the Bot+// until it is fixed (`bot.blocked`, for the repair card).+export const BLOCKING_CODES = new Set(['MISSING_CREDENTIAL', 'INVALID_CREDENTIAL', 'AUTH', 'QUOTA', 'ACCOUNT_QUOTA', 'ACCOUNT_SIGN_IN_REQUIRED', 'ACCOUNT_SIGNED_OUT', 'ACCOUNT_TOKEN_INVALID'])+// The ones a key set outside a turn can fix, and the ones a sign-in can (unblockBots).+// A balance only a turn that completes shows fixed, as Retry runs one.+const KEY_CODES = new Set(['MISSING_CREDENTIAL', 'INVALID_CREDENTIAL', 'AUTH'])+const SIGN_IN_CODES = new Set(['ACCOUNT_SIGN_IN_REQUIRED', 'ACCOUNT_SIGNED_OUT', 'ACCOUNT_TOKEN_INVALID'])+// A failed turn's `LlmFailure`, kept to what can be shown and logged. Like DSH's own// error row, an AUTH failure loses its message: providers may echo part of the key.export function turnFailure(error) {@@ -357,6 +365,65 @@ export function install(rt) {})}+ // The facts of a blocking failure stay on its Bot, from any of its Sessions, until a+ // turn of it completes, a change that can fix it (unblockBots), or its model changes+ // (roster.js). Never the message: a provider may echo part of the key. The provider+ // is the failing route's, which is the Session's last request, else the model the+ // Bot runs on.+ const blockBot = (id, session, failure) => {+ const bot = rt.botOf(rt.selfOf(id))+ if (bot === undefined || !BLOCKING_CODES.has(failure.code)) return false+ const provider = session?.requestHeader?.()?.config?.provider ?? splitRef(bot.appliedModel)?.provider+ bot.blocked = {+ code: failure.code,+ ...(failure.status === undefined ? {} : { status: failure.status }),+ ...(failure.requestId === undefined ? {} : { requestId: failure.requestId }),+ ...(provider ? { provider } : {}),+ at: Date.now(),+ }+ void rt.save().catch(() => {})+ return true+ }+ const unblockBot = (botId) => {+ const bot = rt.botOf(botId)+ if (bot?.blocked === undefined) return+ delete bot.blocked+ void rt.save().catch(() => {})+ }++ // A key set (`ref`) or a sign-in may be the user's fix (models.js): the blocks it can+ // fix lift, and a greeting held for one goes out again. A key lifts the key failures+ // of the providers that read it; one whose provider names no key, or that failed on+ // a provider not known, lifts on any key. A host that only reads the team leaves it+ // to the one that holds it.+ function unblockBots({ ref, signedIn = false, keyed } = {}) {+ if (rt.readOnly?.() !== undefined) return+ let refs+ try { refs = ref === undefined ? undefined : rt.keyRefs?.() } catch {}+ const fixes = ({ code, provider }) => (signedIn && SIGN_IN_CODES.has(code))+ || (ref !== undefined && KEY_CODES.has(code) && (refs?.get(provider) ?? ref) === ref)+ || (code === 'MISSING_CREDENTIAL' && provider !== undefined && keyed?.has(provider) === true)+ const lifted = Object.values(state.bots ?? {}).filter(bot => bot.blocked !== undefined && fixes(bot.blocked))+ if (lifted.length === 0) return+ for (const bot of lifted) delete bot.blocked+ void rt.save().catch(() => {})+ for (const bot of lifted) void rt.releaseKickoff(bot).catch(error => rt.warn('ds-bot: greeting of %s not sent again: %s', bot.name, error))+ }++ // The repair card's Retry. A greeting that failed goes out again; otherwise the Bot+ // answers the user's last message, which is not sent again. A greeting on its way, or+ // a turn under way in the Bot's chat, answers already: a turn on top answers twice.+ async function resumeBot(bot) {+ if (await rt.releaseKickoff(bot)) return+ if (rt.greetingOut?.(bot.id) || live.get(rt.chatOf(bot.id))?.turn !== undefined) return+ const code = bot.blocked?.code+ await rt.deliver({+ toId: bot.id,+ role: 'continue',+ text: `Your last turn failed${code ? ` (${code})` : ''} and the user has fixed it. Answer the user's last unanswered message.`,+ })+ }+ctx.on('session/event', (session, event) => {const id = session?.idif (id === undefined) return@@ -492,7 +559,7 @@ export function install(rt) {queueRoomMessage(id, { text: textOf(event.data.content), ...(images.length > 0 ? { images } : {}), ...(files.length > 0 ? { files } : {}) })}const own = rt.chatOwners.get(id)- if (own !== undefined) rt.dropKickoff(own)+ if (own !== undefined) rt.userWrote(own)// Any user message answers or supersedes the open question card and view card.let dropped = falseif (state.questions[id] !== undefined) {@@ -563,6 +630,14 @@ export function install(rt) {if (failure !== undefined) noteTurnFailure(id, failure)const held = rt.groupOwners.has(id) ? rt.takeRoomSteps?.(id) ?? '' : ''if (switched) break+ const owner = rt.chatOwners.get(id)+ if (failure !== undefined) {+ if (blockBot(id, session, failure) && owner !== undefined && info?.role === 'kickoff') rt.holdKickoffAgain(owner)+ } else if (reason?.kind === 'completed') {+ unblockBot(rt.selfOf(id))+ // A turn the user opened, or the Retry that answers the user.+ if (owner !== undefined && (info === undefined || info.role === 'continue')) rt.userAnswered(owner)+ }// A model that writes its tool call as text ends the turn as if it were done,// though nothing ran. It gets one more turn on the same trigger, so a waiting// round or sender gets the real answer; a second time, the text goes on without@@ -650,5 +725,5 @@ export function install(rt) {}})- Object.assign(rt, { live, liveOf, roomWaiters, roomProgress, roomInbox, activityView, workView, roomWorkView, turnsView, callDetail, doingOf, stopRoomTurn, releaseBot })+ Object.assign(rt, { live, liveOf, roomWaiters, roomProgress, roomInbox, activityView, workView, roomWorkView, turnsView, callDetail, doingOf, stopRoomTurn, releaseBot, unblockBots, resumeBot })}diff --git a/ds-bot/test/account-sign-out.test.js b/ds-bot/test/account-sign-out.test.jsindex 4c3403e5..4b6f343d 100644--- a/ds-bot/test/account-sign-out.test.js+++ b/ds-bot/test/account-sign-out.test.js@@ -54,7 +54,7 @@ const textOf = (node) => {// `status` is what the account plugin's snapshot reports; `running` is what its// hasRunningAccountTasks answers (or throws); `fail` makes signOut reject.-function launcher({ status = 'credential-stored', running = false, runningError = false, fail = '', withEntry = true } = {}) {+function launcher({ status = 'credential-stored', running = false, runningError = false, fail = '', withEntry = true, more = {} } = {}) {const calls = []slots.length = 0const ops = {@@ -68,6 +68,7 @@ function launcher({ status = 'credential-stored', running = false, runningErrorsignInEntry: () => ((typeof withEntry === 'function' ? withEntry() : withEntry) ? { inject: () => ops } : null),accountT: () => key => `acc:${key}`,reportError: () => {},+ ...more,},}const render = () => { cursor = 0; return AccountLauncher(props) }@@ -157,3 +158,31 @@ test('cancel closes the confirm without signing out', async () => {assert.equal(walk(tree, node => node.props?.className === 'bt-confirm').length, 0)assert.deepEqual(side.calls, ['hasRunningAccountTasks'])})++test('Models and API keys opens DS Bot\'s Models page, or DSH\'s own where the host serves no providers', () => {+ const opened = []+ const page = launcher({ more: { providers: () => {}, openModels: () => opened.push('models'), openHarnessModels: () => opened.push('harness') } })+ page.item(page.open(), 'Models and API keys').props.onClick()+ const shell = launcher({ more: { openHarnessModels: () => opened.push('harness') } })+ shell.item(shell.open(), 'Models and API keys').props.onClick()+ assert.deepEqual(opened, ['models', 'harness'])+ const none = launcher()+ assert.equal(none.item(none.open(), 'Models and API keys'), undefined)+})++test('Sign in to DeepSeek shows only while the account plugin says signed out', () => {+ const signIns = []+ const more = { signIn: () => signIns.push('signIn') }+ const out = launcher({ status: 'signed-out', more })+ const item = out.item(out.open(), 'Sign in to DeepSeek')+ assert.ok(item !== undefined)+ item.props.onClick()+ assert.deepEqual(signIns, ['signIn'])+ const inside = launcher({ more })+ assert.equal(inside.item(inside.open(), 'Sign in to DeepSeek'), undefined)+ // An account snapshot that has not answered yet is no sign-out.+ const loading = launcher({ status: undefined, more })+ assert.equal(loading.item(loading.open(), 'Sign in to DeepSeek'), undefined)+ const entryless = launcher({ status: 'signed-out', withEntry: false, more })+ assert.equal(entryless.item(entryless.open(), 'Sign in to DeepSeek'), undefined)+})diff --git a/ds-bot/test/bot-messages.test.js b/ds-bot/test/bot-messages.test.jsindex b7afecc0..a5f5d253 100644--- a/ds-bot/test/bot-messages.test.js+++ b/ds-bot/test/bot-messages.test.js@@ -325,7 +325,7 @@ function turnsHost() {noteFailure() {},warn() {},switchJobs: () => [],- dropKickoff() {},+ userWrote() {},}installTurns(rt)let seq = 0diff --git a/ds-bot/test/create-bot.test.js b/ds-bot/test/create-bot.test.jsindex bceaf803..1a2a1ce6 100644--- a/ds-bot/test/create-bot.test.js+++ b/ds-bot/test/create-bot.test.js@@ -14,6 +14,17 @@ test('the form starts on the DSH default model, else the first served one', () =assert.equal(startModel({ models: [], defaultModel: 'cloud/qwen-max' }), '')})+test('the form never starts on a model whose provider has no key, and starts on none when no model is usable', () => {+ const keyless = [{ ...models[0], needsKey: true }, models[1]]+ assert.equal(startModel({ models: keyless, defaultModel: 'ollama/ds-flash' }), 'cloud/qwen-max')+ assert.equal(startModel({ models: keyless, defaultModel: null }), 'cloud/qwen-max')+ const none = models.map(model => ({ ...model, needsKey: true }))+ assert.equal(startModel({ models: none, defaultModel: null }), '')+ assert.equal(startModel({ models: none, defaultModel: 'cloud/qwen-max' }), '')+ // With no model the payload leaves it out, and the host lets the new Bot wait for a pick.+ assert.equal('model' in createPayload({ name: 'A', look: { shape: 'star', color: 'blue' }, model: startModel({ models: none, defaultModel: null }) }), false)+})+test('the payload carries the look, the chosen model, and the brief', () => {const look = { shape: 'star', color: 'blue' }assert.deepEqual(createPayload({ name: 'A', look, model: 'cloud/qwen-max' }), { name: 'A', color: 'blue', avatar: { shape: 'star' }, model: 'cloud/qwen-max' })diff --git a/ds-bot/test/diagnostics.test.js b/ds-bot/test/diagnostics.test.jsindex 2ada6d01..17916668 100644--- a/ds-bot/test/diagnostics.test.js+++ b/ds-bot/test/diagnostics.test.js@@ -6,7 +6,7 @@ import { homedir, tmpdir } from 'node:os'import { join } from 'node:path'import { test } from 'node:test'import { cleanText, install as installDiagnostics, reportMarkdown } from '../src/host/diagnostics.js'-import { failureLine, install as installTurns, turnFailure } from '../src/host/turns.js'+import { BLOCKING_CODES, failureLine, install as installTurns, turnFailure } from '../src/host/turns.js'import { errorCode } from '../src/host/channel.js'import { SOURCE_KIND } from '../src/host/constants.js'@@ -224,11 +224,11 @@ function turnsHost() {noteFailure: entry => noted.push(entry),warn() {},switchJobs: () => [],- dropKickoff() {},+ userWrote() {},}installTurns(rt)let seq = 0- const emit = (id, type, data) => listener({ id }, { type, seq: ++seq, data })+ const emit = (id, type, data, session = { id }) => listener(session, { type, seq: ++seq, data })return { rt, emit, delivered, noted }}@@ -263,6 +263,135 @@ test('a failed group turn fails its waiter; a stopped one counts as no answer',assert.equal(value, null)})+// The failures the repair card is for, as the client reads them from `bot.blocked`.+test('the failures that block a Bot are the ones only the user can fix', () => {+ assert.deepEqual([...BLOCKING_CODES], ['MISSING_CREDENTIAL', 'INVALID_CREDENTIAL', 'AUTH', 'QUOTA', 'ACCOUNT_QUOTA', 'ACCOUNT_SIGN_IN_REQUIRED', 'ACCOUNT_SIGNED_OUT', 'ACCOUNT_TOKEN_INVALID'])+})++test('a failure only the user can fix blocks its Bot with the facts, never the message, until a turn completes', () => {+ const { rt, emit } = turnsHost()+ const fail = (turn, error, session) => {+ emit('b', 'turn/start', { turn }, session)+ emit('b', 'turn/end', { turn, reason: { kind: 'error', error } }, session)+ }+ rt.bots.b.appliedModel = 'deepseek-official/deepseek-v4-flash'+ fail(1, { code: 'AUTH', message: 'bad key sk-12***34', status: 401, requestId: 'r1' })+ const { at, ...facts } = rt.bots.b.blocked+ assert.deepEqual(facts, { code: 'AUTH', status: 401, requestId: 'r1', provider: 'deepseek-official' })+ assert.equal(typeof at, 'number')+ // The route of the request that failed names the provider.+ const account = { id: 'b', requestHeader: () => ({ config: { provider: 'deepseek-account', model: 'deepseek-v4-flash' } }) }+ fail(2, { code: 'ACCOUNT_TOKEN_INVALID', message: '' }, account)+ assert.deepEqual(Object.keys(rt.bots.b.blocked), ['code', 'provider', 'at'])+ assert.equal(rt.bots.b.blocked.provider, 'deepseek-account')+ // A failure a retry can fix, or a stopped turn, leaves the block as it is.+ fail(3, { code: 'SERVER', message: 'busy', status: 503 })+ emit('b', 'turn/start', { turn: 4 })+ emit('b', 'turn/end', { turn: 4, reason: { kind: 'aborted', reason: { kind: 'user' } } })+ assert.equal(rt.bots.b.blocked.code, 'ACCOUNT_TOKEN_INVALID')+ emit('b', 'turn/start', { turn: 5 })+ emit('b', 'turn/end', { turn: 5, reason: { kind: 'completed' } })+ assert.equal(rt.bots.b.blocked, undefined)+})++test('a greeting a key, a sign-in or a balance stopped is held again; one that failed otherwise is not', () => {+ const { rt, emit } = turnsHost()+ const held = []+ rt.chatOwners.set('b', 'b')+ rt.holdKickoffAgain = id => held.push(id)+ rt.userAnswered = () => {}+ const greet = (turn, error) => {+ emit('b', 'turn/start', { turn })+ emit('b', 'user/message', { content: [{ type: 'text', text: '[Bot team setup]\nhi' }], source: { kind: SOURCE_KIND, role: 'kickoff', exchangeId: `k${turn}` } })+ emit('b', 'turn/end', { turn, reason: { kind: 'error', error } })+ }+ greet(1, { code: 'QUOTA', message: 'Insufficient Balance', status: 402 })+ greet(2, { code: 'SERVER', message: 'busy', status: 503 })+ assert.deepEqual(held, ['b'])+})++test('a completed turn the user opened, or a Retry, answers the message a greeting was held for', () => {+ const { rt, emit } = turnsHost()+ const answered = []+ rt.chatOwners.set('b', 'b')+ rt.userAnswered = id => answered.push(id)+ const run = (turn, source) => {+ emit('b', 'turn/start', { turn })+ emit('b', 'user/message', { content: [{ type: 'text', text: 'hi' }], source })+ emit('b', 'turn/end', { turn, reason: { kind: 'completed' } })+ }+ run(1, { kind: 'user' })+ run(2, { kind: SOURCE_KIND, role: 'request', senderSessionId: 'a', exchangeId: 'x1' })+ run(3, { kind: SOURCE_KIND, role: 'continue', exchangeId: 'c1' })+ assert.deepEqual(answered, ['b', 'b'])+})++test('a key lifts the key failures of the providers that read it, a sign-in the account ones, nothing a balance', () => {+ const { rt } = turnsHost()+ const blocked = {+ official: { code: 'AUTH', provider: 'deepseek-official' },+ stepfun: { code: 'MISSING_CREDENTIAL', provider: 'stepfun' },+ unknown: { code: 'INVALID_CREDENTIAL' },+ keyless: { code: 'AUTH', provider: 'ollama' },+ account: { code: 'ACCOUNT_TOKEN_INVALID', provider: 'deepseek-account' },+ lapsed: { code: 'ACCOUNT_SIGNED_OUT', provider: 'deepseek-account' },+ balance: { code: 'QUOTA', provider: 'deepseek-official' },+ accountBalance: { code: 'ACCOUNT_QUOTA', provider: 'deepseek-account' },+ }+ const reset = () => {+ rt.state.bots = Object.fromEntries(Object.entries(blocked).map(([id, facts]) => [id, { id, name: id, blocked: { ...facts, at: 1 } }]))+ }+ const released = []+ rt.releaseKickoff = async (bot) => { released.push(bot.id); return false }+ rt.keyRefs = () => new Map([['deepseek-official', 'DEEPSEEK_API_KEY'], ['stepfun', 'STEPFUN_API_KEY']])+ const still = () => Object.values(rt.state.bots).filter(bot => bot.blocked !== undefined).map(bot => bot.id)++ reset()+ rt.unblockBots({ ref: 'DEEPSEEK_API_KEY' })+ assert.deepEqual(released, ['official', 'unknown', 'keyless'])+ assert.deepEqual(still(), ['stepfun', 'account', 'lapsed', 'balance', 'accountBalance'])++ released.length = 0+ reset()+ rt.unblockBots({ signedIn: true })+ assert.deepEqual(released, ['account', 'lapsed'])++ // With no provider map to read, any key may be the fix.+ released.length = 0+ reset()+ rt.keyRefs = () => { throw new Error('no settings') }+ rt.unblockBots({ ref: 'DEEPSEEK_API_KEY' })+ assert.deepEqual(released, ['official', 'stepfun', 'unknown', 'keyless'])++ // A provider listed with its key again lifts only what its missing key blocked.+ released.length = 0+ reset()+ rt.unblockBots({ keyed: new Set(['stepfun', 'deepseek-official', 'ollama']) })+ assert.deepEqual(released, ['stepfun'])++ released.length = 0+ reset()+ rt.unblockBots()+ assert.deepEqual(released, [])+ assert.equal(still().length, Object.keys(blocked).length)+})++test('Retry adds no turn while a greeting is on its way or a turn runs in the Bot\'s chat', async () => {+ const { rt, emit, delivered } = turnsHost()+ rt.chatOf = id => id+ rt.releaseKickoff = async () => false+ let out = true+ rt.greetingOut = () => out+ await rt.resumeBot(rt.bots.b)+ out = false+ emit('b', 'turn/start', { turn: 1 })+ await rt.resumeBot(rt.bots.b)+ assert.equal(delivered.length, 0)+ emit('b', 'turn/end', { turn: 1, reason: { kind: 'completed' } })+ await rt.resumeBot(rt.bots.b)+ assert.deepEqual(delivered.map(args => args.role), ['continue'])+})+test('issueUrl fills the issue form, keeps the versions when the errors are too long, and falls back to the clipboard', async () => {const { issueUrl } = await import('../src/client/diagnostics.js')const base = 'https://github.com/Fei2411/DS-Bot/issues/new'diff --git a/ds-bot/test/failure-labels.test.js b/ds-bot/test/failure-labels.test.jsnew file mode 100644index 00000000..25687ac7--- /dev/null+++ b/ds-bot/test/failure-labels.test.js@@ -0,0 +1,26 @@+import assert from 'node:assert/strict'+import { test } from 'node:test'+import { DICTIONARY } from '../src/client/i18n.js'+import { failureLabel, knownFailure } from '../src/client/diagnostics.js'++test('credential and account failures have short words, in both languages', () => {+ const labels = {+ MISSING_CREDENTIAL: 'The model has no API key',+ INVALID_CREDENTIAL: 'The API key is not in the right format',+ ACCOUNT_SIGN_IN_REQUIRED: 'The DeepSeek account needs a sign-in',+ ACCOUNT_SIGNED_OUT: 'The DeepSeek account is signed out',+ ACCOUNT_TOKEN_INVALID: 'The DeepSeek account sign-in has expired',+ }+ for (const [code, label] of Object.entries(labels)) {+ assert.equal(failureLabel(code, 'llm-deepseek: no API key for provider route'), label)+ assert.ok(Object.hasOwn(DICTIONARY.zh, label), label)+ }+})++test('an unknown code has no short words, and its label falls back to the message', () => {+ assert.equal(knownFailure('SOMETHING_NEW'), undefined)+ assert.equal(knownFailure(undefined), undefined)+ assert.equal(knownFailure('toString'), undefined)+ assert.equal(failureLabel('SOMETHING_NEW', 'raw text'), 'raw text')+ assert.equal(failureLabel('SOMETHING_NEW', ''), 'SOMETHING_NEW')+})diff --git a/ds-bot/test/install.test.js b/ds-bot/test/install.test.jsindex c437e04c..10672def 100644--- a/ds-bot/test/install.test.js+++ b/ds-bot/test/install.test.js@@ -38,6 +38,7 @@ test('apply registers listeners, tools, and effects in a fixed order', (t) => {'effect ds-bot: state lock','on llm/adapters-updated','on credentials/reference-updated',+ 'on credentials/record-updated','on settings/document-updated','on session/event','effect ds-bot: agent tool restrict retry',diff --git a/ds-bot/test/model-menu.test.js b/ds-bot/test/model-menu.test.jsindex 128e5a02..4fa15269 100644--- a/ds-bot/test/model-menu.test.js+++ b/ds-bot/test/model-menu.test.js@@ -26,7 +26,7 @@ runInNewContext(bundle.outputFiles[0].text, {return platform[name]},})-const { groupModels, ModelChoiceDock, effortRows } = module.exports+const { groupModels, ModelChoiceDock, ModelKeyCard, effortRows } = module.exportsfunction nodes(tree, match) {if (!tree || typeof tree !== 'object') return []@@ -119,11 +119,11 @@ const keyless = [test('models that need an API key are no choice', () => {const buttons = tree => nodes(tree, node => node.type === 'button').map(button => button.children[0])assert.deepEqual(buttons(dock([...keyless, models[1]], { harness: false }).tree), ['DeepSeek Flash'])- // Where DSH's own settings are, they take the key.+ // Without the host's key endpoint, DSH's own settings take the key.assert.deepEqual(buttons(dock(keyless).tree), ['Enter a DeepSeek API key', 'Open settings to set up a custom model'])})-test('a window without DSH settings asks for the missing API key in the first choice', () => {+test('the first choice asks for the missing API key through the host', () => {const saved = []const bot = { id: 'chief', name: 'Chief' }const tree = ModelChoiceDock({@@ -136,3 +136,28 @@ test('a window without DSH settings asks for the missing API key in the first chassert.equal(card.props.model.provider, 'official')assert.equal(nodes(tree, node => node.props.className === 'bt-model-chips').length, 0)})++test('the DeepSeek API key card links to the key page and says the API is billed by usage', () => {+ const card = model => ModelKeyCard({ model, actions: { setProviderKey: () => {} } })+ const official = card({ provider: 'deepseek-official', providerName: 'DeepSeek' })+ const [link] = nodes(official, node => node.type === 'a')+ assert.equal(link.props.href, 'https://platform.deepseek.com/api_keys')+ assert.equal(link.props.target, '_blank')+ assert.match(link.props.rel, /noopener/)+ assert.deepEqual(link.children, ['Create a key on the DeepSeek platform ↗'])+ assert.ok(nodes(official, node => node.children.includes('The API is billed by usage; the account needs a balance first.')).length === 1)+ const other = card({ provider: 'router', providerName: 'Router' })+ assert.equal(nodes(other, node => node.type === 'a').length, 0)+ assert.equal(nodes(other, node => node.props.className === 'bt-model-key-help').length, 0)+})++test('setting up a custom model opens DS Bot\'s Models page, else DSH\'s own Models page', () => {+ const opened = []+ const choices = actions => nodes(ModelChoiceDock({+ sessionId: 'chief', useRoster: select => select({ ready: true, byId: { chief: { id: 'chief', name: 'Chief' } }, models: [] }), actions,+ }), node => node.type === 'button')+ const custom = list => list.find(button => button.children[0] === 'Open settings to set up a custom model')+ custom(choices({ openModels: () => opened.push('models'), openHarnessModels: () => opened.push('harness models'), openHarnessSettings: () => opened.push('harness') })).props.onClick()+ custom(choices({ openHarnessModels: () => opened.push('harness models'), openHarnessSettings: () => opened.push('harness') })).props.onClick()+ assert.deepEqual(opened, ['models', 'harness models'])+})diff --git a/ds-bot/test/models-step.test.js b/ds-bot/test/models-step.test.jsnew file mode 100644index 00000000..84ae7ed8--- /dev/null+++ b/ds-bot/test/models-step.test.js@@ -0,0 +1,120 @@+import { test } from 'node:test'+import assert from 'node:assert/strict'+import { fileURLToPath } from 'node:url'+import { runInNewContext } from 'node:vm'+import { build } from 'esbuild'++// DS Bot's settings.onboarding step that opens DSH's settings on Models. Rendered with a+// stand-in React whose effects run at once, as the mounted step's would.+const { outputFiles } = await build({+ stdin: {+ contents: "export { MODELS_STEP, MODELS_STEP_ORDER, OpenModelsStep } from './src/client/sidebar.js'",+ resolveDir: fileURLToPath(new URL('..', import.meta.url)),+ },+ bundle: true, format: 'cjs', platform: 'browser', write: false, logLevel: 'silent',+ external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],+})+const frames = []+const react = {+ createElement: (type, props, ...children) => ({ type, props: { ...props, children } }), Fragment: Symbol('Fragment'),+ useEffect: (effect) => { effect() }, useLayoutEffect() {}, useState: initial => [initial, () => {}],+ useMemo: make => make(), useRef: current => ({ current }), useId: () => 'id',+}+const module = { exports: {} }+runInNewContext(outputFiles[0].text, {+ module, exports: module.exports,+ window: { innerWidth: 1280 },+ requestAnimationFrame: (fn) => { frames.push(fn); return frames.length },+ require: name => (name === 'react' ? react : {}),+})+const { MODELS_STEP, MODELS_STEP_ORDER, OpenModelsStep } = module.exports++function step(props) {+ const calls = []+ const tree = OpenModelsStep({+ stepId: MODELS_STEP,+ complete: () => calls.push('complete'),+ openSection: id => calls.push(['openSection', id]),+ ...props,+ })+ return { tree, calls }+}++test('in the first-run pass the step draws nothing and steps aside at once', () => {+ const { tree, calls } = step({ explicit: false })+ assert.equal(tree, null)+ assert.deepEqual(calls, ['complete'])+})++test('opened by its id, the step opens DSH settings on Models and completes', () => {+ const { tree, calls } = step({ explicit: true })+ assert.equal(tree, null)+ assert.deepEqual(calls, [['openSection', 'models'], 'complete'])+})++test('a shell without openSection still opens its settings and completes the step', () => {+ frames.length = 0+ const { calls } = step({ explicit: true, openSection: undefined })+ assert.deepEqual(calls, ['complete'])+ // The fallback is the plain settings opener, a frame later.+ assert.equal(frames.length, 1)+})++// The shell's own steps are the welcome notice (-100) and the DeepSeek key step (0).+test('the step comes after the shell\'s own onboarding steps', () => {+ assert.equal(MODELS_STEP, 'ds-bot-models')+ assert.ok(MODELS_STEP_ORDER > 0)+})++// The DS Bot settings dialog, drawn once with effects left out: its Advanced settings+// entry is the way to DSH's own Models page.+const dialog = await build({+ stdin: {+ contents: "export { SettingsDialog } from './src/client/settings.js'",+ resolveDir: fileURLToPath(new URL('..', import.meta.url)),+ },+ bundle: true, format: 'cjs', platform: 'browser', write: false, logLevel: 'silent',+ external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],+})+const still = {+ ...react, useEffect() {}, useCallback: fn => fn, useRef: current => ({ current }),+ useState: initial => [typeof initial === 'function' ? initial() : initial, () => {}],+}+const settings = { exports: {} }+runInNewContext(dialog.outputFiles[0].text, {+ module: settings, exports: settings.exports,+ window: { innerWidth: 1280, matchMedia: () => ({ matches: false }) },+ requestAnimationFrame: () => 0, cancelAnimationFrame() {},+ require: name => (name === 'react' ? still : name === 'react-dom' ? { createPortal: node => node } : {}),+})+const { SettingsDialog } = settings.exports+const walk = (node, match, out = []) => {+ if (Array.isArray(node)) { node.forEach(child => walk(child, match, out)); return out }+ if (!node || typeof node !== 'object') return out+ if (match(node)) out.push(node)+ walk(node.props?.children, match, out)+ return out+}+const textOf = node => (typeof node === 'string' ? node : Array.isArray(node) ? node.map(textOf).join('') : node?.props ? textOf(node.props.children) : '')++function advanced(actions) {+ const calls = []+ const all = {+ closeSettings: () => calls.push('close'), openSettings() {},+ openHarnessSettings: () => calls.push('settings'),+ ...actions(calls),+ }+ const roster = { byId: {}, roomsById: {}, bots: [], rooms: [], models: [], prefs: {} }+ const tree = SettingsDialog({ page: 'general', id: null, roster, actions: all, useUpdate: pick => pick({}) })+ const [button] = walk(tree, node => node.type === 'button' && textOf(node) === 'Advanced settings (DeepSeek Harness)')+ return { button, calls }+}++test('Advanced settings opens DSH settings on Models, or on their first page without that opener', () => {+ const models = advanced(calls => ({ openHarnessModels: () => calls.push('models') }))+ models.button.props.onClick()+ assert.deepEqual(models.calls, ['close', 'models'])+ const plain = advanced(() => ({}))+ plain.button.props.onClick()+ assert.deepEqual(plain.calls, ['close', 'settings'])+})diff --git a/ds-bot/test/models.test.js b/ds-bot/test/models.test.jsindex 248b3b6f..8236c9f6 100644--- a/ds-bot/test/models.test.js+++ b/ds-bot/test/models.test.js@@ -26,6 +26,32 @@ test('the default model is the DSH default when served, else the first served moassert.equal(await runtime(undefined).defaultModel(), 'deepseek/deepseek-v4.1-flash')})+// DSH serves the models of a provider whose key is not set; every turn on them fails.+function withoutKeys(defaultSelection, providers) {+ const rt = runtime(defaultSelection)+ rt.missingKeys = async () => new Set(providers)+ return rt+}++test('a model that needs a key is never a default or a fallback, though a Bot keeps its own', async () => {+ const rt = withoutKeys({ provider: 'deepseek', model: 'deepseek-v4-pro' }, ['deepseek'])+ assert.equal(await rt.defaultModel(), 'ollama/kimi-k3')+ assert.equal(rt.cachedDefault(), 'ollama/kimi-k3')+ assert.equal(rt.isUsable('ollama/kimi-k3'), true)+ assert.equal(rt.isUsable('deepseek/deepseek-v4-pro'), false)+ assert.equal(rt.isUsable(undefined), false)+ assert.equal(await rt.desiredModel({ model: 'deepseek/deepseek-v4-pro' }), 'deepseek/deepseek-v4-pro')+ assert.equal(await rt.desiredModel({ model: 'gone/model', appliedModel: 'deepseek/deepseek-v4-pro' }), 'ollama/kimi-k3')+ assert.equal(await rt.desiredModel({ model: 'gone/model', appliedModel: 'ollama/deepseek-v4-pro' }), 'ollama/deepseek-v4-pro')+})++test('with every model needing a key, nothing is picked', async () => {+ const rt = withoutKeys({ provider: 'ollama', model: 'kimi-k3' }, ['deepseek', 'ollama'])+ assert.equal(await rt.defaultModel(), undefined)+ assert.equal(rt.cachedDefault(), undefined)+ assert.equal(await rt.desiredModel({ model: 'gone/model', appliedModel: 'ollama/kimi-k3' }), undefined)+})+test('a model is named by its ref, or by an id or name only one provider serves', async () => {const rt = runtime(undefined)assert.equal(await rt.resolveModel('ollama/kimi-k3'), 'ollama/kimi-k3')@@ -76,7 +102,7 @@ test('a Bot with no model yet changes nothing until the user picks one', async (// A runtime with two providers, a DSH default, and a session controller that, like// DSH, saves every Session selection as the default.-function bench({ providers = { deepseek: ['v4-flash'], stepfun: ['step-5'] }, fallback = { provider: 'stepfun', model: 'step-5' }, reasoning = {} } = {}) {+function bench({ providers = { deepseek: ['v4-flash'], stepfun: ['step-5'] }, fallback = { provider: 'stepfun', model: 'step-5' }, reasoning = {}, services = {} } = {}) {let current = { ...fallback }const selected = []const saved = []@@ -85,7 +111,7 @@ function bench({ providers = { deepseek: ['v4-flash'], stepfun: ['step-5'] }, faon(name, listener) { listeners.set(name, listener); return () => listeners.delete(name) },get: name => (name === 'agentDefaultModel'? { currentSelection: () => ({ ...current }), saveSelection: async (next) => { saved.push(next); current = { ...next } } }- : undefined),+ : services[name]),llm: {listProviders: () => Object.keys(providers).map(id => ({ id, name: id.toUpperCase() })),listModels: async id => providers[id].map(model => ({ id: model, name: model, inputModalities: ['text'] })),@@ -175,6 +201,58 @@ test('a greeting waits for the provider of its Bot model to register', async ()assert.equal(await rt.waitForModel({}, 5000), undefined)})+test('a key set or a sign-in lifts what blocked a Bot; a key removed, a sign-out, a provider or a settings change only re-reads', async () => {+ const keys = new Set(['DEEPSEEK_API_KEY'])+ const records = new Set(['deepseek-account-platform/default'])+ const credentials = {+ describe: async ref => ({ configured: keys.has(ref), writable: true }),+ describeRecord: async key => ({ configured: records.has(key), writable: true }),+ }+ const { rt, listeners, providers } = bench({ services: { credentials } })+ const lifted = []+ // Each listing also passes the providers listed with their key (the next test).+ rt.unblockBots = fix => { if (fix.keyed === undefined) lifted.push(fix) }+ await rt.catalog()+ providers.deepseek = ['v4-pro']+ await listeners.get('credentials/reference-updated')('DEEPSEEK_API_KEY')+ assert.ok((await rt.catalog()).some(entry => entry.ref === 'deepseek/v4-pro'))+ await listeners.get('credentials/reference-updated')('STEPFUN_API_KEY')+ // Another plugin's record, such as an OAuth token refresh, is no sign-in.+ await listeners.get('credentials/record-updated')('llm-pi-ai/github-copilot')+ providers.deepseek = ['v4-flash']+ await listeners.get('credentials/record-updated')('deepseek-account-platform/default')+ assert.ok((await rt.catalog()).some(entry => entry.ref === 'deepseek/v4-flash'))+ // The provider refused the token and its record went.+ records.clear()+ await listeners.get('credentials/record-updated')('deepseek-account-platform/default')+ listeners.get('llm/adapters-updated')()+ listeners.get('settings/document-updated')()+ assert.deepEqual(lifted, [{ ref: 'DEEPSEEK_API_KEY' }, { signedIn: true }])+})++test('every listing passes the providers listed with their key, so a key that came without an event still lifts', async () => {+ const { rt, providers } = bench()+ providers.stepfun = ['step-5']+ rt.missingKeys = async () => new Set(['stepfun'])+ const passed = []+ rt.unblockBots = fix => passed.push([...fix.keyed].sort())+ await rt.catalog({ fresh: true })+ rt.missingKeys = async () => new Set()+ await rt.catalog({ fresh: true })+ assert.equal(passed.length, 2)+ assert.equal(passed[0].includes('stepfun'), false)+ assert.equal(passed[1].includes('stepfun'), true)+})++test('a credential DSH cannot describe counts as there, so its fix still lifts', async () => {+ const { rt, listeners } = bench({ services: { credentials: { describe: async () => { throw new Error('locked') } } } })+ const lifted = []+ rt.unblockBots = fix => { if (fix.keyed === undefined) lifted.push(fix) }+ await listeners.get('credentials/reference-updated')('DEEPSEEK_API_KEY')+ await listeners.get('credentials/record-updated')('deepseek-account-platform/default')+ assert.deepEqual(lifted, [{ ref: 'DEEPSEEK_API_KEY' }, { signedIn: true }])+})+test('a Bot on the default model with its own thinking level leaves the default level as it was', async () => {const fallback = { provider: 'deepseek', model: 'v4-flash', reasoningEffort: 'high' }const { rt, current } = bench({ fallback, reasoning: { 'deepseek/v4-flash': { reasoning: { efforts: [{ id: 'low', name: 'Low' }, { id: 'high', name: 'High' }], defaultEffort: 'high' } } } })diff --git a/ds-bot/test/roster.test.js b/ds-bot/test/roster.test.jsindex d9e47c6d..4162404d 100644--- a/ds-bot/test/roster.test.js+++ b/ds-bot/test/roster.test.js@@ -9,11 +9,30 @@ import { format } from 'node:util'import { apply } from '../index.js'import { fakeContext } from './fake-ctx.js'+// DSH's settings and credentials for a DeepSeek route that takes an API key. A key set+// or removed is announced the way DSH announces it. `records` are the stored records+// (an account sign-in's), announced by the test.+function keyed(ctx, stored, records) {+ return {+ settings: { describe: () => [{ ns: 'llm-deepseek', revision: 0, value: { apiKeyEnv: 'DEEPSEEK_API_KEY' }, user: {}, base: {} }] },+ credentials: {+ describe: async ref => ({ configured: stored.has(ref), writable: true }),+ set: async (ref) => { stored.add(ref); ctx.emit('credentials/reference-updated', ref) },+ unset: async (ref) => { stored.delete(ref); ctx.emit('credentials/reference-updated', ref) },+ describeRecord: async key => ({ configured: records.has(key), writable: true }),+ },+ }+}+// Enough of the dsh services for the roster to make Sessions; kickoff messages are dropped.-function start(team, { models = [], reasoning = {}, archiveError } = {}) {+// With `keys`, the models' route takes an API key and these are the ones set.+function start(team, { models = [], reasoning = {}, archiveError, keys } = {}) {const home = mkdtempSync(join(tmpdir(), 'ds-bot-roster-'))if (team !== undefined) writeFileSync(join(home, 'state.json'), JSON.stringify(team))- const ctx = fakeContext()+ const services = {}+ const ctx = fakeContext({ services })+ const records = new Set()+ if (keys !== undefined) Object.assign(services, keyed(ctx, new Set(keys), records))const workspaces = new Map()const sent = []const selected = []@@ -26,6 +45,7 @@ function start(team, { models = [], reasoning = {}, archiveError } = {}) {listProviders: () => (models.length > 0 ? [{ id: 'deepseek', name: 'DeepSeek' }] : []),listModels: async () => models.map(id => ({ id })),resolveModelInfo: async (provider, model) => reasoning[`${provider}/${model}`] ?? {},+ ...(keys === undefined ? {} : { listConfigurableProviders: () => [{ provider: 'deepseek', displayName: 'DeepSeek', settingsNs: 'llm-deepseek', settingsPath: [] }] }),},workspaceRegistry: {get: id => workspaces.get(id),@@ -63,7 +83,7 @@ function start(team, { models = [], reasoning = {}, archiveError } = {}) {await ctx.dispose()rmSync(home, { recursive: true, force: true, maxRetries: 5 })}- return { call, stop, home, sent, selected, ctx, archived, warnings }+ return { call, stop, home, sent, selected, ctx, archived, warnings, records }}const settle = () => new Promise(resolve => setTimeout(resolve, 20))@@ -417,6 +437,293 @@ test('a hidden Bot made Main Bot shows again, and a replaced Chief drops its helassert.equal(toChief(), greeted)})+// A turn in a Bot Session as DSH reports it, to every listener.+const emitIn = (ctx, sessionId, event) => { for (const listener of ctx.listeners.get('session/event')) listener({ id: sessionId }, event) }+function runTurn(ctx, sessionId, turn, message, reason) {+ emitIn(ctx, sessionId, { type: 'turn/start', data: { turn } })+ emitIn(ctx, sessionId, { type: 'user/message', data: message })+ emitIn(ctx, sessionId, { type: 'turn/end', data: { turn, reason } })+}+const typed = text => ({ source: { kind: 'user' }, content: [{ type: 'text', text }] })+const failed = (code, extra = {}) => ({ kind: 'error', error: { code, message: `${code}: sk-12***34 was refused`, ...extra } })+const botIn = async (call, id) => (await call('state', {})).value.bots.find(bot => bot.id === id)++test('a model whose provider has no key is never given to a new Bot', async (t) => {+ const { call, stop, sent, ctx } = start(undefined, { models: ['deepseek-v4-flash'], keys: [] })+ t.after(stop)+ const team = (await call('state', {})).value+ assert.equal(team.models[0].needsKey, true)+ assert.equal(team.defaultModel, null)+ const writer = (await call('create-bot', { name: 'Writer' })).value+ assert.equal(writer.model, undefined)+ // A Main Bot on such a model passes it on to no Bot it creates.+ await call('update-bot', { id: team.mainBotId, model: 'deepseek/deepseek-v4-flash' })+ await ctx.registeredTools.get('create_bot').execute({ name: 'Editor', role: 'Editor', instructions: 'Edit.' }, { agent: { id: team.mainBotId } })+ await settle()+ const editor = (await call('state', {})).value.bots.find(bot => bot.name === 'Editor')+ assert.equal(editor.model, undefined)+ assert.deepEqual(sent.map(entry => entry.sessionId), [team.mainBotId])+ assert.equal((await botIn(call, writer.id)).waiting, true)++ assert.equal((await call('provider-key', { provider: 'deepseek', value: 'sk-test-ok' })).ok, true)+ assert.equal((await call('state', {})).value.defaultModel, 'deepseek/deepseek-v4-flash')+ assert.equal((await call('create-bot', { name: 'Critic' })).value.model, 'deepseek/deepseek-v4-flash')+})++test('a message the user writes before the first Main Bot has a model is answered once it has one', async (t) => {+ const { call, stop, sent, ctx } = start(undefined, { models: ['deepseek-v4-flash'], keys: [] })+ t.after(stop)+ const chief = (await call('state', { locale: 'zh-CN' })).value.mainBotId+ // The Session's own route has no key either, so that turn fails.+ runTurn(ctx, chief, 1, typed('hello?'), failed('MISSING_CREDENTIAL'))+ await settle()+ let main = await botIn(call, chief)+ assert.equal(main.waiting, true)+ assert.equal(main.blocked.code, 'MISSING_CREDENTIAL')++ // The key lifts the block; the greeting still waits for a model.+ await call('provider-key', { provider: 'deepseek', value: 'sk-test-ok' })+ await settle()+ main = await botIn(call, chief)+ assert.equal(main.blocked, undefined)+ assert.equal(main.waiting, true)+ assert.equal(sent.length, 0)++ await call('update-bot', { id: chief, model: 'deepseek/deepseek-v4-flash' })+ await until(() => sent.length > 0)+ assert.equal(sent.length, 1)+ assert.equal(sent[0].message.source.role, 'kickoff')+ assert.equal(sent[0].message.content[0].text, [+ '[Bot team setup]',+ 'You were just set up as the user\'s Main Bot. The user wrote to you before your model could answer; their message above has no answer yet. Answer it now, and say in one short sentence that you run their Bot team. Write in Chinese (简体中文).',+ 'Where your instructions say otherwise, follow them.',+ ].join('\n'))+})++test('a held greeting goes once a turn answered the user, and a Bot that can answer drops its own', async (t) => {+ const { call, stop, sent, ctx } = start(undefined, { models: ['deepseek-v4-flash'], keys: [] })+ t.after(stop)+ const chief = (await call('state', {})).value.mainBotId+ const writer = (await call('create-bot', { name: 'Writer' })).value+ // DSH's own default route answered the first Main Bot.+ runTurn(ctx, chief, 1, typed('hello?'), { kind: 'completed' })+ emitIn(ctx, writer.id, { type: 'user/message', data: typed('hi') })+ await settle()+ assert.equal((await botIn(call, chief)).waiting, undefined)+ assert.equal((await botIn(call, writer.id)).waiting, undefined)+ await call('update-bot', { id: chief, model: 'deepseek/deepseek-v4-flash' })+ await call('update-bot', { id: writer.id, model: 'deepseek/deepseek-v4-flash' })+ await settle()+ assert.equal(sent.length, 0)+})++test('a greeting that fails on a key is held again and goes out once the key is set', async (t) => {+ const { call, stop, sent, ctx } = start(undefined, { models: ['deepseek-v4-flash'], keys: [] })+ t.after(stop)+ const chief = (await call('state', {})).value.mainBotId+ await call('update-bot', { id: chief, model: 'deepseek/deepseek-v4-flash' })+ await until(() => sent.length === 1)+ runTurn(ctx, chief, 1, sent[0].message, failed('MISSING_CREDENTIAL'))+ await settle()+ const main = await botIn(call, chief)+ assert.equal(main.waiting, true)+ assert.deepEqual(Object.keys(main.blocked).sort(), ['at', 'code', 'provider'])+ assert.equal(main.blocked.provider, 'deepseek')+ // Setting the same model again (or only a thinking level) fixes nothing, so the+ // greeting stays held.+ const same = await call('update-bot', { id: chief, model: 'deepseek/deepseek-v4-flash' })+ await settle()+ assert.equal(same.ok, true)+ assert.equal(sent.length, 1)+ assert.equal((await botIn(call, chief)).waiting, true)++ await call('provider-key', { provider: 'deepseek', value: 'sk-test-ok' })+ await until(() => sent.length === 2)+ assert.equal(sent[1].message.source.role, 'kickoff')+ assert.equal(sent[1].message.content[0].text, sent[0].message.content[0].text)+ const after = await botIn(call, chief)+ assert.equal(after.blocked, undefined)+ assert.equal(after.waiting, undefined)+})++test('a Bot is blocked by the facts of a failure only the user can fix, until it is fixed', async (t) => {+ const { call, stop, ctx } = start(undefined, { models: ['deepseek-v4-flash', 'deepseek-v4-pro'] })+ t.after(stop)+ const chief = (await call('state', {})).value.mainBotId+ await call('update-bot', { id: chief, model: 'deepseek/deepseek-v4-flash' })+ runTurn(ctx, chief, 1, typed('hi'), failed('QUOTA', { status: 402, requestId: 'req-1' }))+ await settle()+ const { blocked } = await botIn(call, chief)+ assert.deepEqual({ ...blocked, at: typeof blocked.at }, { code: 'QUOTA', status: 402, requestId: 'req-1', provider: 'deepseek', at: 'number' })+ // A failure a retry can fix leaves it as it is.+ runTurn(ctx, chief, 2, typed('again'), failed('SERVER', { status: 503 }))+ await settle()+ assert.equal((await botIn(call, chief)).blocked.code, 'QUOTA')++ runTurn(ctx, chief, 3, typed('again'), { kind: 'completed' })+ await settle()+ assert.equal((await botIn(call, chief)).blocked, undefined)++ runTurn(ctx, chief, 4, typed('more'), failed('AUTH', { status: 401 }))+ await settle()+ assert.equal((await botIn(call, chief)).blocked.code, 'AUTH')+ // A provider that registers or changes is no fix; a key is.+ ctx.emit('llm/adapters-updated')+ await settle()+ assert.equal((await botIn(call, chief)).blocked.code, 'AUTH')+ ctx.emit('credentials/reference-updated', 'DEEPSEEK_API_KEY')+ await settle()+ assert.equal((await botIn(call, chief)).blocked, undefined)++ runTurn(ctx, chief, 5, typed('more'), failed('ACCOUNT_SIGNED_OUT'))+ await settle()+ assert.equal((await botIn(call, chief)).blocked.code, 'ACCOUNT_SIGNED_OUT')+ await call('update-bot', { id: chief, model: 'deepseek/deepseek-v4-pro' })+ assert.equal((await botIn(call, chief)).blocked, undefined)+})++test('Retry has the Bot answer the user\'s last message without sending it again, or sends a failed greeting again', async (t) => {+ const { call, stop, sent, ctx } = start(undefined, { models: ['deepseek-v4-flash'] })+ t.after(stop)+ const chief = (await call('state', {})).value.mainBotId+ await call('update-bot', { id: chief, model: 'deepseek/deepseek-v4-flash' })+ await until(() => sent.length === 1)+ runTurn(ctx, chief, 1, sent[0].message, failed('QUOTA', { status: 402 }))+ await settle()+ assert.equal((await call('resume', { botId: 'nobody' })).error.code, 'bot/not-found')+ assert.equal((await call('resume', { botId: chief })).ok, true)+ await until(() => sent.length === 2)+ assert.equal(sent[1].message.source.role, 'kickoff')+ assert.equal(sent[1].message.content[0].text, sent[0].message.content[0].text)++ runTurn(ctx, chief, 2, sent[1].message, { kind: 'completed' })+ runTurn(ctx, chief, 3, typed('Plan my week'), failed('QUOTA', { status: 402 }))+ await settle()+ assert.equal((await call('resume', { botId: chief })).ok, true)+ assert.equal(sent.length, 3)+ assert.equal(sent[2].sessionId, chief)+ assert.equal(sent[2].message.source.role, 'continue')+ assert.equal(sent[2].message.content[0].text, '[Retry after a failed turn]\nYour last turn failed (QUOTA) and the user has fixed it. Answer the user\'s last unanswered message.')+ assert.equal((await botIn(call, chief)).waiting, undefined)+})++// The record a DeepSeek account sign-in writes.+const ACCOUNT_RECORD = 'deepseek-account-platform/default'++test('a sign-in lifts what a lapsed sign-in blocked and sends the held greeting; a sign-out, a key or a provider does not', async (t) => {+ const { call, stop, sent, ctx, records } = start(undefined, { models: ['deepseek-v4-flash'], keys: ['DEEPSEEK_API_KEY'] })+ t.after(stop)+ const chief = (await call('state', {})).value.mainBotId+ await call('update-bot', { id: chief, model: 'deepseek/deepseek-v4-flash' })+ await until(() => sent.length === 1)+ // The provider refuses the token, and its record goes while the turn still runs.+ records.add(ACCOUNT_RECORD)+ emitIn(ctx, chief, { type: 'turn/start', data: { turn: 1 } })+ emitIn(ctx, chief, { type: 'user/message', data: sent[0].message })+ records.delete(ACCOUNT_RECORD)+ ctx.emit('credentials/record-updated', ACCOUNT_RECORD)+ emitIn(ctx, chief, { type: 'turn/end', data: { turn: 1, reason: failed('ACCOUNT_TOKEN_INVALID') } })+ await settle()+ ctx.emit('credentials/record-updated', ACCOUNT_RECORD)+ ctx.emit('credentials/reference-updated', 'DEEPSEEK_API_KEY')+ ctx.emit('llm/adapters-updated')+ await settle()+ let main = await botIn(call, chief)+ assert.equal(main.blocked.code, 'ACCOUNT_TOKEN_INVALID')+ assert.equal(main.waiting, true)+ assert.equal(sent.length, 1)++ records.add(ACCOUNT_RECORD)+ ctx.emit('credentials/record-updated', ACCOUNT_RECORD)+ await until(() => sent.length === 2)+ assert.equal(sent[1].message.source.role, 'kickoff')+ assert.equal(sent[1].message.content[0].text, sent[0].message.content[0].text)+ main = await botIn(call, chief)+ assert.equal(main.blocked, undefined)+ assert.equal(main.waiting, undefined)+})++test('a held greeting goes out again only on a change that can fix its block: never a balance, a key another provider reads or a key removed', async (t) => {+ const { call, stop, sent, ctx, records } = start(undefined, { models: ['deepseek-v4-flash'], keys: ['DEEPSEEK_API_KEY', 'OTHER_API_KEY'] })+ t.after(stop)+ const chief = (await call('state', {})).value.mainBotId+ await call('update-bot', { id: chief, model: 'deepseek/deepseek-v4-flash' })+ await until(() => sent.length === 1)+ runTurn(ctx, chief, 1, sent[0].message, failed('QUOTA', { status: 402 }))+ await settle()+ // A key, a sign-in, a provider registering: none of it tops up a balance.+ records.add(ACCOUNT_RECORD)+ for (const ref of ['OTHER_API_KEY', 'DEEPSEEK_API_KEY']) ctx.emit('credentials/reference-updated', ref)+ ctx.emit('credentials/record-updated', ACCOUNT_RECORD)+ ctx.emit('llm/adapters-updated')+ await settle()+ assert.equal(sent.length, 1)+ assert.equal((await botIn(call, chief)).blocked.code, 'QUOTA')++ // Retry sends it again, and this time the key is refused.+ await call('resume', { botId: chief })+ await until(() => sent.length === 2)+ runTurn(ctx, chief, 2, sent[1].message, failed('AUTH', { status: 401 }))+ await settle()+ ctx.emit('credentials/reference-updated', 'OTHER_API_KEY')+ await ctx.get('credentials').unset('DEEPSEEK_API_KEY')+ await settle()+ const main = await botIn(call, chief)+ assert.equal(main.blocked.code, 'AUTH')+ assert.equal(main.waiting, true)+ assert.equal(sent.length, 2)++ await call('provider-key', { provider: 'deepseek', value: 'sk-test-ok' })+ await until(() => sent.length === 3)+ assert.equal(sent[2].message.source.role, 'kickoff')+ assert.equal((await botIn(call, chief)).blocked, undefined)+})++test('the first Main Bot keeps its greeting when the user writes while a key blocks it, and answers once the key is fixed', async (t) => {+ // The key is set but wrong, so its model counts as usable until a turn fails on it.+ const { call, stop, sent, ctx } = start(undefined, { models: ['deepseek-v4-flash'], keys: ['DEEPSEEK_API_KEY'] })+ t.after(stop)+ const chief = (await call('state', {})).value.mainBotId+ await call('update-bot', { id: chief, model: 'deepseek/deepseek-v4-flash' })+ await until(() => sent.length === 1)+ runTurn(ctx, chief, 1, sent[0].message, failed('AUTH', { status: 401 }))+ runTurn(ctx, chief, 2, typed('hello?'), failed('AUTH', { status: 401 }))+ await settle()+ assert.equal((await botIn(call, chief)).waiting, true)++ await call('provider-key', { provider: 'deepseek', value: 'sk-test-ok' })+ await until(() => sent.length === 2)+ assert.equal(sent[1].message.source.role, 'kickoff')+ assert.match(sent[1].message.content[0].text, /^\[Bot team setup\]\nYou were just set up as the user's Main Bot\. The user wrote to you before your model could answer; their message above has no answer yet\./)+})++test('Retry right after a fix adds no turn while the greeting it released waits for its model, is queued or runs', async (t) => {+ const { call, stop, sent, ctx } = start(undefined, { models: ['deepseek-v4-flash'], keys: [] })+ t.after(stop)+ const chief = (await call('state', {})).value.mainBotId+ await call('update-bot', { id: chief, model: 'deepseek/deepseek-v4-flash' })+ await until(() => sent.length === 1)+ runTurn(ctx, chief, 1, sent[0].message, failed('MISSING_CREDENTIAL'))+ await settle()+ // The route is slow to list, so the greeting the key releases waits for its model.+ const listModels = ctx.llm.listModels+ let open+ const listed = new Promise((resolve) => { open = resolve })+ ctx.llm.listModels = async (id) => { await listed; return listModels(id) }+ await ctx.get('credentials').set('DEEPSEEK_API_KEY', 'sk-test-ok')+ await settle()+ assert.equal((await call('resume', { botId: chief })).ok, true)+ open()+ await until(() => sent.length === 2)+ assert.equal((await call('resume', { botId: chief })).ok, true)+ emitIn(ctx, chief, { type: 'turn/start', data: { turn: 2 } })+ emitIn(ctx, chief, { type: 'user/message', data: sent[1].message })+ assert.equal((await call('resume', { botId: chief })).ok, true)+ emitIn(ctx, chief, { type: 'turn/end', data: { turn: 2, reason: { kind: 'completed' } } })+ await settle()+ assert.deepEqual(sent.map(entry => entry.message.source.role), ['kickoff', 'kickoff'])+})+const takeover = (home, team) => {writeFileSync(join(home, 'state.lock'), JSON.stringify({ pid: process.ppid, host: hostname(), token: 'new-owner' }))if (team !== undefined) writeFileSync(join(home, 'state.json'), JSON.stringify(team))diff --git a/ds-bot/test/team-actions.test.js b/ds-bot/test/team-actions.test.jsnew file mode 100644index 00000000..10b79883--- /dev/null+++ b/ds-bot/test/team-actions.test.js@@ -0,0 +1,51 @@+import assert from 'node:assert/strict'+import { test } from 'node:test'+import { createSource } from '../src/client/sources.js'+import { teamActions } from '../src/client/team-actions.js'++// The requests the actions send, and how many of them read the team again after.+function bench() {+ const sent = []+ let pulls = 0+ const call = async (name, body) => { sent.push([name, body]); return { ok: name } }+ const after = promise => promise.then((value) => { pulls++; return value })+ const ui = createSource({ settings: null, menu: 'open', palette: null, newChat: null })+ const actions = teamActions({ call, after, partFor: id => id, roster: createSource({}), ui })+ return { actions, sent, ui, pulls: () => pulls }+}++test('every window reaches the host model providers, and key changes read the team again', async () => {+ const { actions, sent, pulls } = bench()+ await actions.providers()+ await actions.setProviderKey('deepseek-official', 'sk-test-ok')+ await actions.setProviderKey('deepseek-official', null)+ await actions.addProvider({ provider: 'router', key: 'k' })+ await actions.providerModels({ baseURL: 'https://gateway.example/v1', api: 'openai-completions', key: '' })+ await actions.removeProvider('router')+ assert.deepEqual(sent, [+ ['providers', undefined],+ ['provider-key', { provider: 'deepseek-official', value: 'sk-test-ok' }],+ ['provider-key', { provider: 'deepseek-official', value: null }],+ ['provider-add', { provider: 'router', key: 'k' }],+ ['provider-models', { baseURL: 'https://gateway.example/v1', api: 'openai-completions', key: '' }],+ ['provider-remove', { provider: 'router' }],+ ])+ // Reads (the list and a model discovery) leave the team as it is.+ assert.equal(pulls(), 4)+})++test('Retry after a failed turn asks the host to resume the Bot, with nothing but its id', async () => {+ const { actions, sent, pulls } = bench()+ await actions.resume('chief')+ assert.deepEqual(sent, [['resume', { botId: 'chief' }]])+ assert.equal(pulls(), 1)+})++test('openModels opens DS Bot settings on the Models page and closes the menus', () => {+ const { actions, ui } = bench()+ actions.openModels()+ assert.deepEqual(ui.getSnapshot().settings, { page: 'models', id: null })+ assert.equal(ui.getSnapshot().menu, null)+ actions.openSettings()+ assert.deepEqual(ui.getSnapshot().settings, { page: 'general', id: null })+})diff --git a/ds-bot/test/tool-cells.test.js b/ds-bot/test/tool-cells.test.jsindex 3af2be17..113aa901 100644--- a/ds-bot/test/tool-cells.test.js+++ b/ds-bot/test/tool-cells.test.js@@ -812,3 +812,16 @@ test('a view works its formulas out, draws a chart, and keeps html in a sandboxeassert.ok(frame.props.srcDoc.indexOf('Content-Security-Policy') < frame.props.srcDoc.indexOf('<b>hi</b>'), 'the policy comes before the markup')assert.equal(frame.props.title, 'A greeting')})++// The repair card's Retry reaches the Bot as a plugin trigger; the chat shows that it went+// on, never the note to the Bot or the user's message again.+test('a Retry after a failed turn shows as one event line', () => {+ const out = expand(TriggerCell({+ node: { key: 'trigger', kind: 'turn-trigger', location: { turn: { turn: 4 } }, data: { seq: 9, time: 1, content: text$('[Retry after a failed turn]\nYour last turn failed (AUTH) and the user has fixed it.'), source: { kind: 'bot', role: 'continue', exchangeId: 'c1' } } },+ sessionId: chief.id, actions: {},+ useRoster: select => select(team()), useSessions: select => select({ byId: {} }),+ useTurnClock: select => select({}), useUi: select => select({ visits: {}, reactions: {} }),+ }))+ assert.equal(text(out), 'Went on after the failed turn')+ effects = []+})diff --git a/ds-bot/test/turn-error.test.js b/ds-bot/test/turn-error.test.jsnew file mode 100644index 00000000..87bfa843--- /dev/null+++ b/ds-bot/test/turn-error.test.js@@ -0,0 +1,477 @@+import { test } from 'node:test'+import assert from 'node:assert/strict'+import { fileURLToPath } from 'node:url'+import { runInNewContext } from 'node:vm'+import { build } from 'esbuild'++// The repair card of a failed Bot turn, bundled once and rendered with a stateful+// stand-in React: useState slots persist across renders, so a click and the next render+// see the same state the real React would keep. Effects run after each render, when+// their dependencies changed, as the real React would run them.+const { outputFiles } = await build({+ stdin: {+ contents: [+ "export { FailureCell, accountModel, failureText, fixesFor, retryShown } from './src/client/turn-error.js'",+ "export { installLocale } from './src/client/i18n.js'",+ ].join('\n'),+ resolveDir: fileURLToPath(new URL('..', import.meta.url)),+ },+ bundle: true, format: 'cjs', platform: 'browser', write: false, logLevel: 'silent',+ external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],+})+// Hook slots per component, by its place among the components above it.+const slots = new Map()+let scope = ''+let cursor = 0+const hook = (make) => {+ if (!slots.has(scope)) slots.set(scope, [])+ const list = slots.get(scope)+ const i = cursor+++ if (list[i] === undefined) list[i] = make()+ return list[i]+}+const effects = []+const react = {+ createElement: (type, props, ...children) => ({ type, props: { ...props, children } }), Fragment: Symbol('Fragment'),+ useState(initial) {+ const slot = hook(() => ({ v: typeof initial === 'function' ? initial() : initial }))+ return [slot.v, (v) => { slot.v = typeof v === 'function' ? v(slot.v) : v }]+ },+ useRef: initial => hook(() => ({ current: initial })),+ useEffect(effect, deps) {+ const slot = hook(() => ({ deps: null }))+ if (deps === undefined || slot.deps === null || deps.some((dep, i) => !Object.is(dep, slot.deps[i]))) {+ slot.deps = deps ?? null+ effects.push(effect)+ }+ },+ useMemo: make => make(), useLayoutEffect() {}, useSyncExternalStore: (subscribe, get) => get(), useId: () => 'id',+}+const copied = []+// Timers the card set, for a test to run.+const timers = []+const module = { exports: {} }+runInNewContext(outputFiles[0].text, {+ module, exports: module.exports,+ navigator: { clipboard: { writeText: async (text) => { copied.push(text) } } },+ setTimeout: (run) => { timers.push(run); return timers.length },+ clearTimeout: () => {},+ require: name => (name === 'react' ? react : name === 'react-dom' ? { createPortal: node => node } : {}),+})+const { FailureCell, accountModel, failureText, fixesFor, retryShown, installLocale } = module.exports++const tick = () => new Promise(resolve => setTimeout(resolve, 0))+const walk = (node, match, out = []) => {+ if (Array.isArray(node)) { node.forEach(child => walk(child, match, out)); return out }+ if (!node || typeof node !== 'object') return out+ if (match(node)) out.push(node)+ walk(node.props?.children, match, out)+ return out+}+// Runs the function components in a tree, keeping each element with its output.+const expand = (node) => {+ if (Array.isArray(node)) return node.map(expand)+ if (!node || typeof node !== 'object') return node+ if (typeof node.type !== 'function') return { ...node, props: { ...node.props, children: expand(node.props?.children) } }+ const outer = [scope, cursor]+ scope = `${scope}/${node.type.name}:${node.props.key ?? ''}`+ cursor = 0+ try {+ return { ...node, props: { ...node.props, children: [expand(node.type(node.props))] } }+ } finally {+ [scope, cursor] = outer+ }+}+const textOf = (node) => {+ if (node === null || node === undefined || typeof node === 'boolean') return ''+ if (typeof node === 'string' || typeof node === 'number') return String(node)+ if (Array.isArray(node)) return node.map(textOf).join('')+ return textOf(node.props?.children)+}++const models = [+ { ref: 'deepseek-official/deepseek-chat', provider: 'deepseek-official', providerName: 'DeepSeek', name: 'DeepSeek Chat' },+ { ref: 'router/flash', provider: 'router', providerName: 'Router', name: 'Flash' },+]++// `blocked` is what the host's state view carries on the Bot; `later` adds a turn after+// the failed one; `account` is the shell account snapshot's view, which a test may change+// between renders; `asked` marks the failed turn, or the turns listed, as ones another+// Bot asked for.+function cell({ code, message = '', turn = 3, blocked, model = models[0].ref, later = false, signIn = true, account, sessionId = 'chief-part', bot: botPatch = {}, catalog = models, defaultModel = null, asked = false } = {}) {+ slots.clear()+ effects.length = 0+ const calls = []+ const bot = { id: 'chief', name: 'Chief', model, sessionId: 'chief-part', blocked, ...botPatch }+ const byId = Object.fromEntries([...(bot.parts ?? []), 'chief-part', 'chief'].map(id => [id, bot]))+ const roster = { ready: true, byId, roomsById: {}, models: catalog, defaultModel, exchangeTurns: asked ? { [sessionId]: asked === true ? [turn] : asked } : {} }+ const ops = account ? { hooks: { account: { subscribe: () => () => {}, getSnapshot: () => ({ view: account }) } } } : {}+ const actions = {+ resume: async (id) => { calls.push(['resume', id]); if (actions.failResume) throw new Error(actions.failResume) },+ updateBot: async (id, patch) => { calls.push(['updateBot', id, { ...patch }]); if (actions.failUpdate) throw new Error(actions.failUpdate) },+ signIn: () => calls.push(['signIn']),+ canSignIn: () => signIn,+ signInEntry: () => (signIn ? { inject: () => ops } : null),+ showDetails: id => calls.push(['showDetails', id]),+ setProviderKey: (provider, value) => { calls.push(['key', provider, value]) },+ openModels: () => calls.push(['openModels']),+ openHarnessOnboarding: id => calls.push(['onboarding', id]),+ }+ const clock = later ? { [sessionId]: { [turn]: { first: 1 }, [turn + 1]: { first: 2 } } } : { [sessionId]: { [turn]: { first: 1 } } }+ const props = {+ node: { data: { kind: 'turn-error', seq: 9, time: 5, turn, step: 0, message, ...(code ? { code } : {}) } },+ sessionId, actions,+ useRoster: pick => pick(roster), useTurnClock: pick => pick(clock),+ }+ const render = () => {+ scope = ''+ cursor = 0+ const tree = expand(FailureCell(props))+ for (const effect of effects.splice(0)) effect()+ return tree+ }+ const buttons = tree => walk(tree, node => node.type === 'button' || node.type === 'a').map(node => ({ node, label: textOf(node), primary: String(node.props.className).includes('bt-send') }))+ const tech = tree => walk(tree, node => node.type === 'dd').map(textOf)+ return { render, buttons, tech, calls, actions, bot, roster }+}+const labels = list => list.filter(entry => !entry.node.props.className?.includes('bt-fail-copy')).map(entry => entry.label)++test('a missing key offers the key first, the sign-in and another model, but no retry while the host holds it', () => {+ const side = cell({ code: 'MISSING_CREDENTIAL', message: 'llm-deepseek: no API key for provider route', blocked: { code: 'MISSING_CREDENTIAL', provider: 'deepseek-official', at: 1 } })+ const tree = side.render()+ assert.match(textOf(walk(tree, node => node.props?.className === 'bt-fail-text')[0]), /^Chief's model has no API key yet\.$/)+ const list = side.buttons(tree)+ assert.deepEqual(labels(list), ['Enter API key', 'Sign in with a DeepSeek account', 'Pick another model'])+ assert.equal(list[0].primary, true)+ assert.equal(list.filter(entry => entry.primary).length, 1)+ // The raw text is only under Technical details.+ assert.equal(walk(tree, node => node.props?.className === 'bt-fail-text').some(node => textOf(node).includes('no API key for provider')), false)+ assert.ok(side.tech(tree).includes('llm-deepseek: no API key for provider route'))+ list[1].node.props.onClick()+ list[2].node.props.onClick()+ assert.deepEqual(side.calls, [['signIn'], ['showDetails', 'chief-part']])+})++test('Enter API key opens the key card for the failing provider, with the DeepSeek link', () => {+ const side = cell({ code: 'MISSING_CREDENTIAL', blocked: { code: 'MISSING_CREDENTIAL', provider: 'deepseek-official', at: 1 } })+ side.buttons(side.render())[0].node.props.onClick()+ const [card] = walk(side.render(), node => node.props?.model !== undefined)+ assert.equal(card.props.model.provider, 'deepseek-official')+ assert.equal(card.props.model.providerName, 'DeepSeek')+ const [link] = walk(card, node => node.type === 'a')+ assert.equal(link.props.href, 'https://platform.deepseek.com/api_keys')+ assert.equal(link.props.target, '_blank')+ assert.match(textOf(card), /billed by usage; the account needs a balance first/)+ // The key goes to the failing provider.+ const [input] = walk(card, node => typeof node.props?.onChange === 'function' && node.props?.label !== undefined)+ input.props.onChange('sk-test-ok')+ const [save] = walk(side.render(), node => node.type === 'button' && textOf(node) === 'Save')+ save.props.onClick()+ assert.deepEqual(side.calls, [['key', 'deepseek-official', 'sk-test-ok']])+ // Saving closes the card again.+ card.props.onSaved()+ assert.equal(walk(side.render(), node => node.props?.model !== undefined).length, 0)+})++test('without the host key endpoint, Enter API key goes to the shell key editor of the official route', () => {+ const side = cell({ code: 'MISSING_CREDENTIAL', blocked: { code: 'MISSING_CREDENTIAL', provider: 'deepseek-official', at: 1 } })+ delete side.actions.setProviderKey+ side.buttons(side.render())[0].node.props.onClick()+ assert.deepEqual(side.calls, [['onboarding', 'deepseek-official']])+})++test('once the host no longer holds the failure, Retry leads and asks the Bot to go on once', async () => {+ const side = cell({ code: 'MISSING_CREDENTIAL' })+ const list = side.buttons(side.render())+ assert.equal(list[0].label, 'Retry')+ assert.equal(list[0].primary, true)+ list[0].node.props.onClick()+ await tick()+ const [again] = side.buttons(side.render())+ assert.equal(again.label, 'Retrying…')+ assert.equal(again.node.props.disabled, true)+ assert.deepEqual(side.calls, [['resume', 'chief']])+})++test('a failed retry says why and can be tried again', async () => {+ const side = cell({ code: 'SERVER' })+ side.actions.failResume = 'DS Bot is still loading this chat.'+ side.buttons(side.render())[0].node.props.onClick()+ await tick()+ const tree = side.render()+ assert.match(textOf(walk(tree, node => node.props?.className === 'bt-fail-error')[0]), /still loading/)+ assert.equal(side.buttons(tree)[0].node.props.disabled, false)+})++test('AUTH names the provider and status from the host, and never shows the raw message', () => {+ const side = cell({ code: 'AUTH', message: 'Authentication Fails (sk-... is invalid)', blocked: { code: 'AUTH', status: 401, requestId: 'req-1', provider: 'deepseek-official', at: 1 } })+ const tree = side.render()+ assert.equal(textOf(walk(tree, node => node.props?.className === 'bt-fail-text')[0]), 'DeepSeek did not accept the current API key (401).')+ assert.deepEqual(labels(side.buttons(tree)), ['Enter the key again', 'Use a DeepSeek account instead', 'Pick another model'])+ assert.deepEqual(side.tech(tree), ['AUTH', '401', 'req-1'])+ assert.equal(JSON.stringify(tree).includes('Authentication Fails'), false)+})++test('QUOTA takes its provider and status from the failure, and tops up only the official route', () => {+ const router = cell({ code: 'QUOTA', model: models[1].ref, blocked: { code: 'QUOTA', provider: 'router', at: 1 } })+ let tree = router.render()+ assert.equal(textOf(walk(tree, node => node.props?.className === 'bt-fail-text')[0]), 'Router is out of balance or quota.')+ assert.deepEqual(labels(router.buttons(tree)), ['Retry'])+ const official = cell({ code: 'QUOTA', blocked: { code: 'QUOTA', status: 402, provider: 'deepseek-official', at: 1 } })+ tree = official.render()+ assert.equal(textOf(walk(tree, node => node.props?.className === 'bt-fail-text')[0]), 'DeepSeek is out of balance or quota (402).')+ const list = official.buttons(tree)+ assert.deepEqual(labels(list), ['Top up ↗', 'Retry'])+ assert.equal(list[0].node.props.href, 'https://platform.deepseek.com/top_up')+ assert.equal(list[0].node.props.target, '_blank')+ assert.deepEqual(list.map(entry => entry.primary).slice(0, 2), [true, false])+})++test('the account balance tops up on the account plugin page, when it gives one', () => {+ const linked = cell({ code: 'ACCOUNT_QUOTA', account: { status: 'credential-stored', links: { topUpUrl: 'https://platform.example/top_up', usageUrl: 'https://platform.example/usage' }, attempt: null } })+ const list = linked.buttons(linked.render())+ assert.deepEqual(labels(list), ['Top up ↗', 'Retry'])+ assert.equal(list[0].node.props.href, 'https://platform.example/top_up')+ const bare = cell({ code: 'ACCOUNT_QUOTA' })+ assert.deepEqual(labels(bare.buttons(bare.render())), ['Retry'])+})++test('an account sign-in failure asks to sign in again, or offers another model without the account plugin', () => {+ for (const code of ['ACCOUNT_SIGN_IN_REQUIRED', 'ACCOUNT_SIGNED_OUT', 'ACCOUNT_TOKEN_INVALID']) {+ const side = cell({ code, blocked: { code, provider: 'deepseek-account', at: 1 } })+ const tree = side.render()+ assert.equal(textOf(walk(tree, node => node.props?.className === 'bt-fail-text')[0]), 'The DeepSeek account sign-in has expired.')+ const list = side.buttons(tree)+ assert.deepEqual(labels(list), ['Sign in again'])+ list[0].node.props.onClick()+ assert.deepEqual(side.calls, [['signIn']])+ const alone = cell({ code, signIn: false, blocked: { code, at: 1 } })+ assert.deepEqual(labels(alone.buttons(alone.render())), ['Pick another model'])+ }+})++// The account route next to the failing key route, as the account plugin lists it.+const withAccount = [+ ...models,+ { ref: 'deepseek-account/deepseek-v4-flash', provider: 'deepseek-account', providerName: 'DeepSeek account', name: 'V4 Flash' },+ { ref: 'deepseek-account/deepseek-v4-pro', provider: 'deepseek-account', providerName: 'DeepSeek account', name: 'V4 Pro' },+]++test('a sign-in started from the card moves the Bot onto the account route once the account is signed in', () => {+ for (const [code, label] of [['MISSING_CREDENTIAL', 'Sign in with a DeepSeek account'], ['AUTH', 'Use a DeepSeek account instead']]) {+ const view = { status: 'signed-out', links: null }+ const side = cell({ code, blocked: { code, provider: 'deepseek-official', at: 1 }, account: view, catalog: withAccount })+ side.buttons(side.render()).find(entry => entry.label === label).node.props.onClick()+ assert.deepEqual(side.calls, [['signIn']], code)+ // Nothing moves while the sign-in is under way, or after one that did not finish.+ view.status = 'signing-in'+ side.render()+ assert.deepEqual(side.calls, [['signIn']], code)+ view.status = 'credential-stored'+ side.render()+ side.render()+ assert.deepEqual(side.calls, [['signIn'], ['updateBot', 'chief', { model: 'deepseek-account/deepseek-v4-flash' }]], code)+ // The host lifts the block with the new model; going on is all that is left.+ side.bot.model = 'deepseek-account/deepseek-v4-flash'+ side.bot.blocked = undefined+ const list = side.buttons(side.render())+ assert.deepEqual(labels(list), ['Retry'], code)+ assert.equal(list[0].primary, true, code)+ }+})++test('the Bot takes the DSH default model when it is an account model', () => {+ const view = { status: 'signed-out' }+ const side = cell({ code: 'MISSING_CREDENTIAL', blocked: { code: 'MISSING_CREDENTIAL', provider: 'deepseek-official', at: 1 }, account: view, catalog: withAccount, defaultModel: 'deepseek-account/deepseek-v4-pro' })+ side.buttons(side.render()).find(entry => entry.label === 'Sign in with a DeepSeek account').node.props.onClick()+ view.status = 'credential-stored'+ side.render()+ assert.deepEqual(side.calls.at(-1), ['updateBot', 'chief', { model: 'deepseek-account/deepseek-v4-pro' }])+ assert.equal(accountModel({ models: withAccount, defaultModel: 'router/flash' }), 'deepseek-account/deepseek-v4-flash')+ assert.equal(accountModel({ models, defaultModel: null }), undefined)+})++test('already signed in, the card moves the Bot onto the account at once', () => {+ const side = cell({ code: 'MISSING_CREDENTIAL', blocked: { code: 'MISSING_CREDENTIAL', provider: 'deepseek-official', at: 1 }, account: { status: 'credential-stored' }, catalog: withAccount })+ const list = side.buttons(side.render())+ assert.deepEqual(labels(list), ['Enter API key', 'Use the DeepSeek account', 'Pick another model'])+ list[1].node.props.onClick()+ assert.deepEqual(side.calls, [['updateBot', 'chief', { model: 'deepseek-account/deepseek-v4-flash' }]])+})++test('the account models listed a moment after the sign-in still move the Bot; none for a while, the user picks', () => {+ const view = { status: 'signed-out' }+ const side = cell({ code: 'AUTH', blocked: { code: 'AUTH', provider: 'deepseek-official', at: 1 }, account: view })+ side.actions.refreshModels = () => side.calls.push(['refreshModels'])+ side.buttons(side.render()).find(entry => entry.label === 'Use a DeepSeek account instead').node.props.onClick()+ view.status = 'credential-stored'+ side.render()+ assert.deepEqual(side.calls, [['signIn'], ['refreshModels']])+ side.roster.models = withAccount+ side.render()+ assert.deepEqual(side.calls.at(-1), ['updateBot', 'chief', { model: 'deepseek-account/deepseek-v4-flash' }])++ const slow = cell({ code: 'AUTH', blocked: { code: 'AUTH', provider: 'deepseek-official', at: 1 }, account: view })+ view.status = 'signed-out'+ slow.buttons(slow.render()).find(entry => entry.label === 'Use a DeepSeek account instead').node.props.onClick()+ view.status = 'credential-stored'+ timers.length = 0+ slow.render()+ assert.deepEqual(slow.calls, [['signIn']])+ for (const run of timers.splice(0)) run()+ assert.deepEqual(slow.calls, [['signIn'], ['showDetails', 'chief-part']])+})++test('a model the user picked during the sign-in stands, and a failed move says why', async () => {+ const view = { status: 'signed-out' }+ const side = cell({ code: 'MISSING_CREDENTIAL', blocked: { code: 'MISSING_CREDENTIAL', provider: 'deepseek-official', at: 1 }, account: view, catalog: withAccount })+ side.buttons(side.render()).find(entry => entry.label === 'Sign in with a DeepSeek account').node.props.onClick()+ side.bot.model = 'router/flash'+ view.status = 'credential-stored'+ side.render()+ assert.deepEqual(side.calls, [['signIn']])++ const failing = cell({ code: 'MISSING_CREDENTIAL', blocked: { code: 'MISSING_CREDENTIAL', provider: 'deepseek-official', at: 1 }, account: { status: 'credential-stored' }, catalog: withAccount })+ failing.actions.failUpdate = 'Model deepseek-account/deepseek-v4-flash is not available.'+ failing.buttons(failing.render()).find(entry => entry.label === 'Use the DeepSeek account').node.props.onClick()+ await tick()+ assert.match(textOf(walk(failing.render(), node => node.props?.className === 'bt-fail-error')[0]), /not available/)+})++test('a failed turn another Bot asked for offers its fixes but no Retry', () => {+ const server = cell({ code: 'SERVER', asked: true })+ const tree = server.render()+ assert.deepEqual(labels(server.buttons(tree)), [])+ assert.equal(tree.props['data-settled'], '')+ assert.equal(textOf(walk(tree, node => node.props?.className === 'bt-fail-text')[0]), 'The model service failed.')+ const key = cell({ code: 'MISSING_CREDENTIAL', asked: true })+ const list = key.buttons(key.render())+ assert.deepEqual(labels(list), ['Enter API key', 'Sign in with a DeepSeek account', 'Pick another model'])+ assert.equal(list[0].primary, true)+ // A turn of the user's own in the same chat keeps its Retry.+ const own = cell({ code: 'SERVER', asked: [2] })+ assert.deepEqual(labels(own.buttons(own.render())), ['Retry'])+})++test('connection, rate and server failures retry; other codes keep a short line, not the raw text', () => {+ const cases = [+ ['TRANSPORT', 'Could not reach the model service.'],+ ['TIMEOUT', 'Could not reach the model service.'],+ ['RATE_LIMIT', 'Too many requests. Wait a moment, then try again.'],+ ['SERVER', 'The model service failed.'],+ ['CONTEXT_WINDOW_EXCEEDED', 'The conversation is too long for the model'],+ ['SOMETHING_NEW', 'This turn failed.'],+ [undefined, 'This turn failed.'],+ ]+ for (const [code, text] of cases) {+ const side = cell({ code, message: 'socket hang up at 10.0.0.1' })+ const tree = side.render()+ assert.equal(textOf(walk(tree, node => node.props?.className === 'bt-fail-text')[0]), text, code)+ assert.deepEqual(labels(side.buttons(tree)), ['Retry'], code)+ assert.ok(side.tech(tree).includes('socket hang up at 10.0.0.1'), code)+ }+})++test('every failure code a Bot chat can show offers at least one button', () => {+ for (const code of ['MISSING_CREDENTIAL', 'INVALID_CREDENTIAL', 'AUTH', 'QUOTA', 'ACCOUNT_QUOTA', 'ACCOUNT_SIGN_IN_REQUIRED', 'ACCOUNT_SIGNED_OUT', 'ACCOUNT_TOKEN_INVALID', 'TRANSPORT', 'TIMEOUT', 'RATE_LIMIT', 'SERVER', 'INTERRUPTED', 'INVALID_REQUEST', 'OTHER']) {+ for (const blocked of [undefined, { code, at: 1 }]) {+ const side = cell({ code, blocked })+ assert.ok(labels(side.buttons(side.render())).length > 0, `${code} ${blocked ? 'blocked' : 'free'}`)+ }+ }+})++test('a failure a later turn or part moved past keeps its line and details, without buttons', () => {+ const later = cell({ code: 'AUTH', later: true, blocked: { code: 'AUTH', status: 401, at: 1 } })+ let tree = later.render()+ assert.equal(walk(tree, node => node.props?.className === 'bt-fail-actions').length, 0)+ assert.equal(tree.props['data-settled'], '')+ const older = cell({ code: 'SERVER', sessionId: 'chief-old', bot: { parts: ['chief-old', 'chief-part'] } })+ tree = older.render()+ assert.equal(walk(tree, node => node.props?.className === 'bt-fail-actions').length, 0)+ assert.equal(textOf(walk(tree, node => node.props?.className === 'bt-fail-text')[0]), 'The model service failed.')+ const outside = cell({ code: 'MISSING_CREDENTIAL', sessionId: 'room-1' })+ tree = outside.render()+ assert.equal(walk(tree, node => node.props?.className === 'bt-fail-actions').length, 0)+ assert.equal(textOf(walk(tree, node => node.props?.className === 'bt-fail-text')[0]), "This Bot's model has no API key yet.")+})++test('the host facts of another failure are not this one', () => {+ const side = cell({ code: 'QUOTA', blocked: { code: 'AUTH', status: 401, requestId: 'req-2', provider: 'router', at: 1 } })+ const tree = side.render()+ assert.equal(textOf(walk(tree, node => node.props?.className === 'bt-fail-text')[0]), 'DeepSeek is out of balance or quota.')+ assert.deepEqual(side.tech(tree), ['QUOTA'])+})++test('Copy puts the technical details on the clipboard in English', async () => {+ copied.length = 0+ const side = cell({ code: 'SERVER', message: 'upstream 503', blocked: undefined })+ const [copy] = walk(side.render(), node => String(node.props?.className).includes('bt-fail-copy'))+ copy.props.onClick()+ await tick()+ assert.deepEqual(copied, ['Code: SERVER\nMessage: upstream 503'])+})++test('the copy and fix tables go by code alone', () => {+ assert.equal(failureText('QUOTA', { provider: 'X', status: 429 }), 'X is out of balance or quota (429).')+ assert.equal(failureText('INVALID_CREDENTIAL', {}), 'This API key is not in the right format.')+ assert.deepEqual(Array.from(fixesFor('MISSING_CREDENTIAL', { canSignIn: false })), ['key', 'model'])+ assert.deepEqual(Array.from(fixesFor('INVALID_CREDENTIAL', {})), ['rekey', 'model'])+ assert.deepEqual(Array.from(fixesFor('QUOTA', { official: false })), [])+ assert.deepEqual(Array.from(fixesFor('AUTH', { canSignIn: true, onAccount: true })), [])+ assert.deepEqual(Array.from(fixesFor('ACCOUNT_SIGNED_OUT', { canSignIn: true, onAccount: true })), ['sign-in-again'])+ assert.equal(retryShown('AUTH', { code: 'AUTH' }), false)+ assert.equal(retryShown('AUTH', undefined), true)+ assert.equal(retryShown('QUOTA', { code: 'QUOTA' }), true)+})++// The words a Chinese interface may still show in English (design note, 用词).+const ENGLISH_ALLOWED = /\b(DeepSeek|DS Bot|Bot|API|Key|Harness|DSH|HTTP|Router|Chief)\b/gi++test('in a Chinese interface every repair card state reads in Chinese, outside Technical details', () => {+ const dicts = new Map()+ const off = installLocale({+ register: (ns, locale, dict) => { dicts.set(`${ns}:${locale}`, dict); return () => dicts.delete(`${ns}:${locale}`) },+ bind: ns => (key, params) => {+ const text = dicts.get(`${ns}:zh`)?.[key] ?? key+ return params ? text.replace(/\{(\w+)\}/g, (match, name) => (name in params ? String(params[name]) : match)) : text+ },+ getLocale: () => ({ active: 'zh' }),+ })+ // Text shown to the user, leaving out the Technical details, which keep the raw facts.+ const shown = (node) => {+ if (node === null || node === undefined || typeof node === 'boolean') return ''+ if (typeof node === 'string' || typeof node === 'number') return String(node)+ if (Array.isArray(node)) return node.map(shown).join(' ')+ if (node.type === 'details') return ''+ return shown(node.props?.children)+ }+ try {+ const codes = ['MISSING_CREDENTIAL', 'INVALID_CREDENTIAL', 'AUTH', 'QUOTA', 'ACCOUNT_QUOTA', 'ACCOUNT_SIGN_IN_REQUIRED', 'ACCOUNT_SIGNED_OUT', 'ACCOUNT_TOKEN_INVALID', 'TRANSPORT', 'TIMEOUT', 'RATE_LIMIT', 'SERVER', 'INTERRUPTED', 'CONTEXT_WINDOW_EXCEEDED', 'OTHER']+ const account = { status: 'credential-stored', links: { topUpUrl: 'https://platform.example/top_up' }, attempt: null }+ for (const code of codes) {+ for (const blocked of [undefined, { code, status: 401, requestId: 'req-1', provider: 'deepseek-official', at: 1 }]) {+ for (const later of [false, true]) {+ const side = cell({ code, blocked, later, account, message: 'raw provider text' })+ let tree = side.render()+ const key = side.buttons(tree).find(entry => entry.label === '填入 API Key' || entry.label === '重新填 Key')+ if (key) { key.node.props.onClick(); tree = side.render() }+ const left = shown(tree).replace(ENGLISH_ALLOWED, '')+ assert.doesNotMatch(left, /[A-Za-z]{2,}/, `${code} ${blocked ? 'blocked' : 'free'} ${later ? 'settled' : 'current'}: ${shown(tree)}`)+ const [summary] = walk(tree, node => node.type === 'summary')+ if (summary) assert.equal(textOf(summary), '技术详情')+ }+ }+ }+ } finally {+ off()+ }+})++test('a provider that is not in the catalog yet keeps a readable name in the key card', () => {+ const side = cell({ code: 'MISSING_CREDENTIAL', blocked: { code: 'MISSING_CREDENTIAL', provider: 'deepseek-official', at: 1 }, catalog: [models[1]] })+ side.buttons(side.render())[0].node.props.onClick()+ const [card] = walk(side.render(), node => node.props?.model !== undefined)+ assert.equal(card.props.model.provider, 'deepseek-official')+ assert.equal(card.props.model.providerName, 'DeepSeek')+})