A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Carry the engine log into the fatal box, and tell the truth in the sidebar
Fei241156635a6db711
diff --git a/app/src/host-process.mjs b/app/src/host-process.mjsindex dba66e5c..eb54c5bb 100644--- a/app/src/host-process.mjs+++ b/app/src/host-process.mjs@@ -7,6 +7,13 @@ const STDERR_TAIL_CHARS = 8 * 1024// The web server prints its launch URL, and the launch token in it opens the Host.const redact = (text) => text.replace(/([?&]token=)[^&\s]+/gu, '$1<hidden>')+// The engine's own report of a failure is on the Host's stderr; the error box+// gets its tail with the message so the real cause reaches the user.+export const withLogTail = (message, stderr) => {+ const tail = redact(stderr.trim())+ return tail === '' ? message : `${message}:\n${tail}`+}+const settlesWithin = (promise, ms) => new Promise((resolve) => {const timer = setTimeout(() => { resolve(false) }, ms)void promise.then(() => { clearTimeout(timer); resolve(true) })@@ -50,13 +57,12 @@ export class HostProcess {for (const listener of this.#messageListeners) listener(message)if (message?.type === 'ready') resolve({ url: message.url, injections: message.injections })else if (message?.type === 'checked') resolve({ unreadable: message.unreadable })- else if (message?.type === 'fatal') this.#fail(new Error(message.message), reject)+ else if (message?.type === 'fatal') this.#fail(new Error(withLogTail(message.message, this.#stderr)), reject)})child.once('error', (error) => { this.#fail(error, reject) })this.#exit = new Promise((done) => {child.once('close', (code) => {- const tail = redact(this.#stderr.trim())- this.#fail(new Error(`The DSH Host stopped (exit ${String(code)})${tail === '' ? '' : `:\n${tail}`}`), reject)+ this.#fail(new Error(withLogTail(`The DSH Host stopped (exit ${String(code)})`, this.#stderr)), reject)done()})})diff --git a/app/src/host.mjs b/app/src/host.mjsindex cf46cd96..18eafc3a 100644--- a/app/src/host.mjs+++ b/app/src/host.mjs@@ -57,12 +57,13 @@ async function main() {}const [webServer, connection] = [ctx.get('webServer'), ctx.get('connection')]// A profile patch can turn these rows off; then the window has nothing to talk to.- if (webServer === undefined || connection === undefined) throw new Error(`The profile in ${profile.dir} does not start the engine's web server and connection.`)+ if (webServer === undefined || connection === undefined) throw new Error(`The profile in ${profile.dir} does not start the engine's web server and connection`)// ds-bot waits on these before it registers its API. A Session-store failure// must reach the shell's error box here, not read as an endless- // "Setting up your Main Bot…" in a window that looks ready (#516).+ // "Setting up your Main Bot…" in a window that looks ready (#516). The Host+ // process attaches the engine log tail — the real cause — to this message.const missing = ['sessionController', 'workspaceRegistry'].filter(name => ctx.get(name) === undefined)- if (missing.length > 0) throw new Error(`The profile in ${profile.dir} did not start ${missing.join(', ')}; the engine log has the cause.`)+ if (missing.length > 0) throw new Error(`The profile in ${profile.dir} did not start ${missing.join(', ')}; the engine log has the cause`)const url = connection.authenticatedUrl(`http://127.0.0.1:${String(webServer.port)}`)await send({ type: 'ready', url, injections: webServer.collectIndexInjections() })}diff --git a/app/test/host-process.test.mjs b/app/test/host-process.test.mjsnew file mode 100644index 00000000..bc4ad2e8--- /dev/null+++ b/app/test/host-process.test.mjs@@ -0,0 +1,21 @@+import { test } from 'node:test'+import assert from 'node:assert/strict'+import { withLogTail } from '../src/host-process.mjs'++// The engine's own report of a failed start is on the Host's stderr; the+// error box gets its tail with the message (#516).+test('withLogTail attaches the stderr tail so the real cause reaches the box', () => {+ const stderr = 'dsh: warning: 7 entries did not activate\n'+ + ' workspace (@deepseek-ai/dsh-workspace): Error: corrupt session log "/data/sessions/_deleted/s1/session.v4.jsonl.zstd": header id "s1" and cwd identify "/data/sessions/ws/s1/session.v4.jsonl.zstd"\n'+ + ' session-controller: pending (waiting for service: workspaceRegistry)\n'+ const message = withLogTail('The profile in /data did not start sessionController, workspaceRegistry; the engine log has the cause', stderr)+ assert.match(message, /^The profile in \/data did not start sessionController, workspaceRegistry/)+ assert.match(message, /corrupt session log "\/data\/sessions\/_deleted\/s1\/session\.v4\.jsonl\.zstd"/)+})++test('withLogTail redacts launch tokens and skips an empty tail', () => {+ assert.equal(+ withLogTail('The DSH Host stopped (exit 1)', 'launch http://127.0.0.1:43117/?token=abc123 other'),+ 'The DSH Host stopped (exit 1):\nlaunch http://127.0.0.1:43117/?token=<hidden> other')+ assert.equal(withLogTail('The DSH Host stopped (exit 0)', ' \n'), 'The DSH Host stopped (exit 0)')+})diff --git a/ds-bot/client.js b/ds-bot/client.jsindex db0d318b..bd9eab07 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -96,7 +96,8 @@ var ZH = {// Sidebar and account menu"Bot list": "Bot 列表","Setting up your Main Bot…": "正在设置你的主 Bot…",- "The Bot team could not start. Settings → Feedback has the details.": "Bot 团队启动失败,详情见「设置 → 反馈」。",+ "The Bot team could not start. The engine’s startup output — its console, or the app’s startup error box — has the cause.": "Bot 团队启动失败。原因在引擎的启动输出里——它的控制台,或应用的启动错误框。",+ "The Bot team could not start. {error}. The engine’s startup output — its console, or the app’s startup error box — has the cause.": "Bot 团队启动失败。{error}。原因在引擎的启动输出里——它的控制台,或应用的启动错误框。","Automation tasks": "自动化任务",Connectors: "连接器","Search connectors": "搜索连接器",@@ -9507,6 +9508,10 @@ function TitleToggle({ hidden, onToggle }) {onClick: onToggle}, (0, import_react18.createElement)(SidebarIcon)), document.body);}+var bootHint = () => {+ const last = clientErrors().at(-1)?.text;+ return last === void 0 ? t("The Bot team could not start. The engine’s startup output — its console, or the app’s startup error box — has the cause.") : t("The Bot team could not start. {error}. The engine’s startup output — its console, or the app’s startup error box — has the cause.", { error: last });+};function TeamSidebar(props) {const { wide, useRoster, useUi, useSessions, actions } = props;const listRef = (0, import_react18.useRef)(null);@@ -9701,7 +9706,7 @@ function TeamSidebar(props) {{ className: "bt-rail-top" },(0, import_react18.createElement)(UpdateButton, { useUpdate: props.useUpdate, actions }),(0, import_react18.createElement)("button", { type: "button", className: "bt-round bt-side-collapse", "aria-label": t("Collapse sidebar"), title: t("Collapse sidebar"), onClick: onToggle }, (0, import_react18.createElement)(SidebarIcon)),- main ? (0, import_react18.createElement)(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : (0, import_react18.createElement)("div", { className: "bt-hint" }, t(uiNow.bootFailed ? "The Bot team could not start. Settings → Feedback has the details." : "Setting up your Main Bot…")),+ main ? (0, import_react18.createElement)(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : (0, import_react18.createElement)("div", { className: "bt-hint" }, uiNow.bootFailed ? bootHint() : t("Setting up your Main Bot…")),(0, import_react18.createElement)("span", { className: "bt-rail-sep", "aria-hidden": true }));const foot = wideContent ? (0, import_react18.createElement)("div", { className: "bt-leftcol-foot" }, (0, import_react18.createElement)(AccountLauncher, { seat: false, actions })) : (0, import_react18.createElement)(@@ -9718,7 +9723,7 @@ function TeamSidebar(props) {(0, import_react18.createElement)("div",{ ref: listRef, className: "bt-list", role: "region", "aria-label": t("Bot list") },- wideContent ? main ? (0, import_react18.createElement)(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : (0, import_react18.createElement)("div", { className: "bt-hint" }, t(uiNow.bootFailed ? "The Bot team could not start. Settings → Feedback has the details." : "Setting up your Main Bot…")) : null,+ wideContent ? main ? (0, import_react18.createElement)(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : (0, import_react18.createElement)("div", { className: "bt-hint" }, uiNow.bootFailed ? bootHint() : t("Setting up your Main Bot…")) : null,order.map((entry) => entry.kind === "bot" ? (0, import_react18.createElement)(BotRow, { key: entry.item.id, ...rowProps, bot: entry.item, marked: markedUnread[entry.item.id] === true }) : entry.kind === "room" ? (0, import_react18.createElement)(RoomRow, { key: entry.item.id, ...rowProps, room: entry.item, marked: markedUnread[entry.item.id] === true }) : (0, import_react18.createElement)(AgentRow, { key: entry.item.id, ...rowProps, agent: entry.item, marked: markedUnread[entry.item.id] === true }))),foot@@ -16019,7 +16024,7 @@ function FeedbackPage({ actions, run: run2, Section, Row: Row3 }) {setNote(t("Downloaded the log. Keys, tokens, and your home folder are hidden in it."));}));const clearLog = () => run2(actions.diagnosticsClear().then(clearClientErrors).then(load).then(() => setNote(t("Cleared the error log."))));- const browserErrors = report ? clientErrors().map((entry) => ({ ...entry, source: "browser" })) : [];+ const browserErrors = clientErrors().map((entry) => ({ ...entry, source: "browser" }));const entries2 = [...report?.entries ?? [], ...browserErrors].sort((a, b) => new Date(b.time) - new Date(a.time));const total = (report?.total ?? 0) + browserErrors.length;const shown = entries2.slice(0, 8);@@ -20413,11 +20418,14 @@ function apply(ctx) {try {await pull();misses = 0;+ ui2.set((state) => state.bootFailed ? { ...state, bootFailed: false } : state);} catch (error) {if (!stopped) {console.warn("[ds-bot] state", error);- misses += 1;- if (misses >= 10 && !roster.getSnapshot().ready) ui2.set((state) => state.bootFailed ? state : { ...state, bootFailed: true });+ if (error?.code === "HTTP_404") {+ misses += 1;+ if (misses >= 10 && !roster.getSnapshot().ready) ui2.set((state) => state.bootFailed ? state : { ...state, bootFailed: true });+ }}} finally {running = false;diff --git a/ds-bot/src/client/feedback.js b/ds-bot/src/client/feedback.jsindex a296b927..7f073acf 100644--- a/ds-bot/src/client/feedback.js+++ b/ds-bot/src/client/feedback.js@@ -98,7 +98,8 @@ export function FeedbackPage({ actions, run, Section, Row }) {}))const clearLog = () => run(actions.diagnosticsClear().then(clearClientErrors).then(load).then(() => setNote(t('Cleared the error log.'))))- const browserErrors = report ? clientErrors().map(entry => ({ ...entry, source: 'browser' })) : []+ // The report needs the Bot API; this window's own errors show without it.+ const browserErrors = clientErrors().map(entry => ({ ...entry, source: 'browser' }))const entries = [...(report?.entries ?? []), ...browserErrors].sort((a, b) => new Date(b.time) - new Date(a.time))const total = (report?.total ?? 0) + browserErrors.lengthconst shown = entries.slice(0, 8)diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.jsindex 81086ea9..507a4ecb 100644--- a/ds-bot/src/client/i18n.js+++ b/ds-bot/src/client/i18n.js@@ -60,7 +60,8 @@ const ZH = {// Sidebar and account menu'Bot list': 'Bot 列表','Setting up your Main Bot…': '正在设置你的主 Bot…',- 'The Bot team could not start. Settings → Feedback has the details.': 'Bot 团队启动失败,详情见「设置 → 反馈」。',+ 'The Bot team could not start. The engine’s startup output — its console, or the app’s startup error box — has the cause.': 'Bot 团队启动失败。原因在引擎的启动输出里——它的控制台,或应用的启动错误框。',+ 'The Bot team could not start. {error}. The engine’s startup output — its console, or the app’s startup error box — has the cause.': 'Bot 团队启动失败。{error}。原因在引擎的启动输出里——它的控制台,或应用的启动错误框。','Automation tasks': '自动化任务',Connectors: '连接器','Search connectors': '搜索连接器',diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.jsindex 70d2396e..6424d3f9 100644--- a/ds-bot/src/client/index.js+++ b/ds-bot/src/client/index.js@@ -205,14 +205,18 @@ export function apply(ctx) {try {await pull()misses = 0+ // A late-arriving API clears the failure the misses reported.+ ui.set(state => (state.bootFailed ? { ...state, bootFailed: false } : state))} catch (error) {if (!stopped) {console.warn('[ds-bot] state', error)- // The Bot API never comes up when the host plugin did not activate- // (e.g. the Session store failed); "Setting up your Main Bot…" alone- // would spin forever, so the sidebar says the start-up failed (#516).- misses += 1- if (misses >= 10 && !roster.getSnapshot().ready) ui.set(state => (state.bootFailed ? state : { ...state, bootFailed: true }))+ // Only a missing Bot API counts toward a failed start: while the+ // host plugin stays unmounted the route answers 404. A network miss+ // is the host reconnecting, not a start-up failure (#516).+ if (error?.code === 'HTTP_404') {+ misses += 1+ if (misses >= 10 && !roster.getSnapshot().ready) ui.set(state => (state.bootFailed ? state : { ...state, bootFailed: true }))+ }}} finally { running = false }if (!stopped) timer = setTimeout(loop, document.hidden ? 10000 : 1500)diff --git a/ds-bot/src/client/sidebar.js b/ds-bot/src/client/sidebar.jsindex 00e0bd3a..e372e16c 100644--- a/ds-bot/src/client/sidebar.js+++ b/ds-bot/src/client/sidebar.js@@ -10,6 +10,7 @@ import { reducedMotion } from './activity-row.js'import { Shimmer, workPhrase } from './cells.js'import { springEasing, SPRING_SHAPE, useViewport, viewBottom } from './motion.js'import { hostText, t } from './i18n.js'+import { clientErrors } from './diagnostics.js'import { showsDshRow } from './dsh-offer.js'import { frameLayout, dragColumn, RAIL_WIDTH, FALLBACK_SIDEBAR_WIDTH, userSidebarToggle } from './frame-layout.js'import { chatRoom, dshCollapsed } from './frame-watch.js'@@ -286,6 +287,17 @@ function TitleToggle({ hidden, onToggle }) {}, h(SidebarIcon)), document.body)}+// The Bot-API-down hint cannot send the user to Settings → Feedback: its+// diagnostics request needs the same API. What still works in this state is+// the last error this window recorded, and the engine's own startup output —+// its console, or the app's startup error box (#516).+const bootHint = () => {+ const last = clientErrors().at(-1)?.text+ return last === undefined+ ? t('The Bot team could not start. The engine’s startup output — its console, or the app’s startup error box — has the cause.')+ : t('The Bot team could not start. {error}. The engine’s startup output — its console, or the app’s startup error box — has the cause.', { error: last })+}+export function TeamSidebar(props) {const { wide, useRoster, useUi, useSessions, actions } = propsconst listRef = useRef(null)@@ -483,7 +495,7 @@ export function TeamSidebar(props) {: h('div', { className: 'bt-rail-top' },h(UpdateButton, { useUpdate: props.useUpdate, actions }),h('button', { type: 'button', className: 'bt-round bt-side-collapse', 'aria-label': t('Collapse sidebar'), title: t('Collapse sidebar'), onClick: onToggle }, h(SidebarIcon)),- main ? h(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : h('div', { className: 'bt-hint' }, t(uiNow.bootFailed ? 'The Bot team could not start. Settings → Feedback has the details.' : 'Setting up your Main Bot…')),+ main ? h(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : h('div', { className: 'bt-hint' }, uiNow.bootFailed ? bootHint() : t('Setting up your Main Bot…')),h('span', { className: 'bt-rail-sep', 'aria-hidden': true }))// The foot stands in for the shell's hidden footer: the account avatar, and on// the rail the new-chat button above it.@@ -496,7 +508,7 @@ export function TeamSidebar(props) {top,wideContent && roster.readOnly ? h('div', { className: 'bt-hint bt-read-only', role: 'status' }, hostText(roster.readOnly)) : null,h('div', { ref: listRef, className: 'bt-list', role: 'region', 'aria-label': t('Bot list') },- wideContent ? (main ? h(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : h('div', { className: 'bt-hint' }, t(uiNow.bootFailed ? 'The Bot team could not start. Settings → Feedback has the details.' : 'Setting up your Main Bot…'))) : null,+ wideContent ? (main ? h(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : h('div', { className: 'bt-hint' }, uiNow.bootFailed ? bootHint() : t('Setting up your Main Bot…'))) : null,order.map(entry => (entry.kind === 'bot'? h(BotRow, { key: entry.item.id, ...rowProps, bot: entry.item, marked: markedUnread[entry.item.id] === true }): entry.kind === 'room'