A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Merge dev into feat/windows-onboarding-m4-start-window
AdamPlatin123af4717456a66
diff --cc ds-bot/client.jsindex 0256a5af,2948695e..c0009ba0--- a/ds-bot/client.js+++ b/ds-bot/client.js@@@ -14386,9 -14078,28 +14428,28 @@@ var VOICE_LABELS =unsupported: "Voice chat is not available in this browser"};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 watchReply(read, watch, consume) {+ let off = () => {+ };+ let consumed = false;+ const attempt = () => {+ if (consumed) return;+ const text = read();+ if (text === void 0) return;+ consumed = true;+ off();+ consume(text);+ };+ off = watch(attempt);+ attempt();+ return () => {+ consumed = true;+ off();+ };+ }function useMicLevel(enabled) {- const [level, setLevel] = (0, import_react34.useState)(0);- (0, import_react34.useEffect)(() => {+ const [level, setLevel] = (0, import_react35.useState)(0);+ (0, import_react35.useEffect)(() => {if (!enabled || !navigator.mediaDevices?.getUserMedia) return void 0;let stream = null;let audio = null;@@@ -14436,20 -14147,20 +14497,20 @@@ function VoiceMode({ sessionId, rosterconst lastReply = useSessions((list) => {const outline = list.projectionsBySession?.[sessionId]?.values?.turnOutline ?? list.byId[sessionId]?.projectionValues?.turnOutline;const entry = Array.isArray(outline) ? outline[outline.length - 1] : void 0;- return entry ? `${outline.length}|${entry.response ?? ""}` : "0|";+ return entry ? `${outline.length}|${entry.turn}` : "0|";});- const [speech] = (0, import_react34.useState)(() => actions.speech());- const [phase, setPhase] = (0, import_react34.useState)(speech ? "starting" : speechApi() ? "listening" : "unsupported");- const [catalog, setCatalog] = (0, import_react34.useState)(null);- const [heard, setHeard] = (0, import_react34.useState)("");- const [said, setSaid] = (0, import_react34.useState)("");- const [note, setNote] = (0, import_react34.useState)("");- const [serviceLevel, setServiceLevel] = (0, import_react34.useState)(0);- const [cycle, setCycle] = (0, import_react34.useState)(0);- const waiting = (0, import_react34.useRef)(null);- const reply = (0, import_react34.useRef)(lastReply);+ const [speech] = (0, import_react35.useState)(() => actions.speech());+ const [phase, setPhase] = (0, import_react35.useState)(speech ? "starting" : speechApi() ? "listening" : "unsupported");+ const [catalog, setCatalog] = (0, import_react35.useState)(null);+ const [heard, setHeard] = (0, import_react35.useState)("");+ const [said, setSaid] = (0, import_react35.useState)("");+ const [note, setNote] = (0, import_react35.useState)("");+ const [serviceLevel, setServiceLevel] = (0, import_react35.useState)(0);+ const [cycle, setCycle] = (0, import_react35.useState)(0);+ const waiting = (0, import_react35.useRef)(null);+ const reply = (0, import_react35.useRef)(lastReply);reply.current = lastReply;- const turn = (0, import_react34.useRef)(0);+ const turn = (0, import_react35.useRef)(0);const paneLeft = usePaneLeft();const close = () => {turn.current += 1;@@@ -14560,27 -14271,42 +14621,42 @@@setServiceLevel(0);};}, [speech, catalog, listen, cycle]);- (0, import_react34.useEffect)(() => {+ (0, import_react35.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;- waiting.current = null;- const spoken = plainSpeech(text);- setSaid(spoken);- setHeard("");- if (!window.speechSynthesis || !spoken) {- setPhase("listening");- return;- }- const utterance = new SpeechSynthesisUtterance(spoken);- utterance.lang = /[\u3400-\u9fff]/.test(spoken) ? "zh-CN" : "en-US";- utterance.onend = () => setPhase((current) => current === "speaking" ? "listening" : current);- utterance.onerror = utterance.onend;- setPhase("speaking");- window.speechSynthesis.cancel();- window.speechSynthesis.speak(utterance);+ if (phase !== "thinking" || running || waiting.current === null) return void 0;+ const count = lastReply.slice(0, lastReply.indexOf("|"));+ const turn2 = Number(lastReply.slice(lastReply.indexOf("|") + 1));+ if (count === waiting.current) return void 0;+ const speak = (text) => {+ waiting.current = null;+ const spoken = plainSpeech(text);+ setSaid(spoken);+ setHeard("");+ if (!window.speechSynthesis || !spoken) {+ setPhase("listening");+ return;+ }+ const utterance = new SpeechSynthesisUtterance(spoken);+ utterance.lang = /[\u3400-\u9fff]/.test(spoken) ? "zh-CN" : "en-US";+ utterance.onend = () => setPhase((current) => current === "speaking" ? "listening" : current);+ utterance.onerror = utterance.onend;+ setPhase("speaking");+ window.speechSynthesis.cancel();+ window.speechSynthesis.speak(utterance);+ };+ return watchReply(+ () => actions.closingReply(sessionId, turn2),+ (listener) => actions.watchTurns(sessionId, listener),+ (text) => {+ if (text === null) {+ waiting.current = null;+ setPhase("listening");+ return;+ }+ speak(text);+ }+ );}, [phase, running, lastReply]);- (0, import_react34.useEffect)(() => () => window.speechSynthesis?.cancel(), []);+ (0, import_react35.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";@@@ -14594,39 -14320,85 +14670,85 @@@window.speechSynthesis?.cancel();setPhase("paused");};- const openSetup = phase === "setup" ? actions.voiceSetup() : null;- (0, import_react34.useEffect)(() => {++ (0, import_react35.useEffect)(() => {+ if (phase !== "preparing" || !speech) return void 0;+ let stopped = false;+ let timer;+ const tick = async () => {+ try {+ const { catalog: next } = await speechCatalog(speech);+ if (stopped) return;+ setCatalog(next);+ const step = preparationStep(next);+ if (step.state === "usable") {+ setPhase("listening");+ return;+ }+ if (step.state === "done") {+ setPhase("setup");+ if (step.failed) setNote(t("Couldn't prepare voice input"));+ return;+ }+ setNote(step.pct === void 0 ? "" : t("Downloading the speech model… {pct}%", { pct: step.pct }));+ } catch {+ if (!stopped) {+ setPhase("setup");+ return;+ }+ }+ timer = setTimeout(tick, 1500);+ };+ timer = setTimeout(tick, 800);+ return () => {+ stopped = true;+ clearTimeout(timer);+ };+ }, [phase, speech]);+ const openSetup = phase === "setup" ? actions.voiceSetup(catalog?.selection?.providerId) : null;+ const startSetup = () => {+ if (openSetup?.navigate) {+ close();+ openSetup.navigate();+ return;+ }+ turn.current += 1;+ setPhase("preparing");+ void Promise.resolve(openSetup.prepare()).then((started) => {+ if (started === false) {+ setPhase("setup");+ setNote(t("Couldn't prepare voice input"));+ }+ });+ };const caption = phase === "speaking" ? said : heard;const shownNote = note || dictation.note;- return (0, import_react34.createElement)(+ return (0, import_react35.createElement)("div",{ className: "bt-pane bt-voice-pane", style: { left: paneLeft } },- (0, import_react34.createElement)(+ (0, import_react35.createElement)("div",{ className: "bt-voice-stage", role: "dialog", "aria-label": t("Voice chat with {name}", { name }), "data-phase": phase === "transcribing" ? "thinking" : phase },- (0, import_react34.createElement)(+ (0, import_react35.createElement)("div",{ className: "bt-voice-orb", style: { "--bt-level": level } },- (0, import_react34.createElement)("span", { className: "bt-voice-ring", "aria-hidden": true }),- (0, import_react34.createElement)("span", { className: "bt-voice-ring bt-voice-ring-2", "aria-hidden": true }),- bot ? (0, import_react34.createElement)(BotMark, { bot, size: 112, state: markState, live: true, gaze: phase === "listening" }) : room2 ? (0, import_react34.createElement)(RoomAvatar, { room: room2, roster, size: 112 }) : null+ (0, import_react35.createElement)("span", { className: "bt-voice-ring", "aria-hidden": true }),+ (0, import_react35.createElement)("span", { className: "bt-voice-ring bt-voice-ring-2", "aria-hidden": true }),+ bot ? (0, import_react35.createElement)(BotMark, { bot, size: 112, state: markState, live: true, gaze: phase === "listening" }) : room2 ? (0, import_react35.createElement)(RoomAvatar, { room: room2, roster, size: 112 }) : null),- (0, import_react34.createElement)("div", { className: "bt-voice-name" }, name),- (0, import_react34.createElement)(+ (0, import_react35.createElement)("div", { className: "bt-voice-name" }, name),+ (0, import_react35.createElement)("div",{ className: "bt-voice-status", role: "status" },- phase === "thinking" ? (0, import_react34.createElement)(Shimmer, null, t("Thinking…")) : phase === "transcribing" ? (0, import_react34.createElement)(Shimmer, null, t("Recognizing…")) : VOICE_LABELS[phase] ? t(VOICE_LABELS[phase]) : ""+ phase === "thinking" ? (0, import_react35.createElement)(Shimmer, null, t("Thinking…")) : phase === "transcribing" ? (0, import_react35.createElement)(Shimmer, null, t("Recognizing…")) : VOICE_LABELS[phase] ? t(VOICE_LABELS[phase]) : ""),- (0, import_react34.createElement)("div", { className: "bt-voice-caption", key: `${phase}:${caption.slice(0, 12)}` }, caption),- openSetup ? (0, import_react34.createElement)("button", { type: "button", className: "bt-voice-setup", onClick: startSetup }, t("Set up voice input")) : null,- shownNote ? (0, import_react34.createElement)("div", { className: "bt-voice-note" }, shownNote) : null+ (0, import_react35.createElement)("div", { className: "bt-voice-caption", key: `${phase}:${caption.slice(0, 12)}` }, caption),- openSetup ? (0, import_react35.createElement)("button", { type: "button", className: "bt-voice-setup", onClick: () => {- close();- openSetup();- } }, t("Set up voice input")) : null,++ openSetup ? (0, import_react35.createElement)("button", { type: "button", className: "bt-voice-setup", onClick: startSetup }, t("Set up voice input")) : null,+ shownNote ? (0, import_react35.createElement)("div", { className: "bt-voice-note" }, shownNote) : null),- (0, import_react34.createElement)(+ (0, import_react35.createElement)("div",{ className: "bt-voice-bar" },- (0, import_react34.createElement)("button", {+ (0, import_react35.createElement)("button", {type: "button",className: "bt-voice-btn","aria-pressed": phase === "paused",@@@ -21209,14 -20990,20 +21340,25 @@@ 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 = () => {+ actions.voiceSetup = (providerId) => {const navigation = ctx.get("pluginNavigation");- return navigation ? () => navigation.openBundle(VOICE_BUNDLE) : null;+ if (navigation !== void 0) return { navigate: () => navigation.openBundle(VOICE_BUNDLE) };+ const speech = ctx.get("remote.speech");+ return speech === void 0 || providerId === void 0 ? null : { prepare: () => requestPreparation(speech, providerId) };+ };+ actions.closingReply = (sessionId, turn) => {+ try {+ const binding = ctx.sessions.binding(sessionId);+ if (binding === void 0) return null;+ return closingReplyText(ctx.uiConversation.binding(binding).target("chat").getSnapshot(), turn);+ } catch {+ return null;+ }};actions.seatAccount = (on) => ui2.set((state) => state.accountSeated === on ? state : { ...state, accountSeated: on });actions.installUpdate = async () => {diff --cc ds-bot/src/client/index.jsindex 71e84e07,15ba3b56..4dbefa21--- a/ds-bot/src/client/index.js+++ b/ds-bot/src/client/index.js@@@ -634,15 -650,27 +651,33 @@@ 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 = () => {+ // With the plugin manager mounted, setup is its bundle page (the model's size+ // and download notes live there). Where it is not mounted — the desktop app's+ // profile has no plugin manager — the speech Remote prepares the provider+ // itself, and the voice pane follows its progress.+ actions.voiceSetup = (providerId) => {const navigation = ctx.get('pluginNavigation')- return navigation ? () => navigation.openBundle(VOICE_BUNDLE) : null+ if (navigation !== undefined) return { navigate: () => navigation.openBundle(VOICE_BUNDLE) }+ const speech = ctx.get('remote.speech')+ return speech === undefined || providerId === undefined ? null : { prepare: () => requestPreparation(speech, providerId) }+ }+ // The full text the voice chat reads aloud: the turn's closing Assistant+ // message, not the turn outline's bounded preview. undefined while the chat+ // view has not materialized the turn; null when the Session is not bound.+ actions.closingReply = (sessionId, turn) => {+ try {+ const binding = ctx.sessions.binding(sessionId)+ if (binding === undefined) return null+ return closingReplyText(ctx.uiConversation.binding(binding).target('chat').getSnapshot(), turn)+ } catch {+ return null+ }}actions.seatAccount = on => ui.set(state => (state.accountSeated === on ? state : { ...state, accountSeated: on }))// The install runs on the host; the check loop follows it every two seconds.diff --cc ds-bot/src/client/sidebar.jsindex 539e436d,e372e16c..a74a47ac--- a/ds-bot/src/client/sidebar.js+++ b/ds-bot/src/client/sidebar.js@@@ -10,8 -10,8 +10,9 @@@ import { reducedMotion } from './activiimport { 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 { quietly } from './diagnostics.js'import { frameLayout, dragColumn, RAIL_WIDTH, FALLBACK_SIDEBAR_WIDTH, userSidebarToggle } from './frame-layout.js'import { chatRoom, dshCollapsed } from './frame-watch.js'diff --cc ds-bot/src/host/turns.jsindex 7f797d10,ea2846f1..c61910fe--- a/ds-bot/src/host/turns.js+++ b/ds-bot/src/host/turns.js@@@ -2,19 -2,12 +2,20 @@@// triggered, the waiters and inboxes of group rounds, and routing a finished turn's reply.//// Turn tracking: which turns were triggered by another Bot, and what they said.+ import { randomUUID } from 'node:crypto'import { HANDOFF_ACK, MESSAGE_INLINE_MAX, REFERENCE_KIND, REPLY_KIND, SOURCE_KIND, STEER_CUT } 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) {