Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
Fix agent chat on Linux and Mac: keep the Harness's own dsh-* packages when pruning other-OS binaries, verify imports at staging, plain start-failure message
Niko1221f95fb3e0743a
diff --git a/apps/desktop/scripts/harness-prune.mjs b/apps/desktop/scripts/harness-prune.mjsnew file mode 100644index 000000000..35b811244--- /dev/null+++ b/apps/desktop/scripts/harness-prune.mjs@@ -0,0 +1,79 @@+/**+ * Which files and folders of the staged Harness are dropped, and the check that nothing the Harness imports is gone.+ *+ * The 2026-10-17 tester report: on Linux and Mac every agent chat failed ("session/create ... waiting for workflowEngine").+ * Cause: the old rule "drop any folder named after another operating system" also removed the Harness's own JavaScript package+ * `@deepseek-ai/dsh-win32-process`. It is plain JS (no binary), and `dsh-subprocess-local` and `dsh-sandbox-local` import it by+ * name on every platform, so those two plugins failed to load, and everything waiting on them (shell, subprocess, ptcRuntime,+ * workflowEngine) never started. Windows kept it (the rule differs there), so the Windows tests passed.+ */+import { existsSync, readFileSync, readdirSync } from 'node:fs';+import { join, sep } from 'node:path';++export const OTHER_OS = {+ win32: /(^|[\\/._-])(darwin|linux|android|freebsd|musl)([\\/._-]|$)/i,+ darwin: /(^|[\\/._-])(win32|linux|android|freebsd|musl)([\\/._-]|$)/i,+ // Linux: the AppImage bundler (linuxdeploy) resolves the libraries of every ELF file under resources and stops on one it+ // cannot satisfy (koffi's musl build wants libc.musl). The app is glibc x86_64, so musl and other-CPU builds are dropped.+ linux: /(^|[\\/._-])(win32|darwin|android|freebsd|musl|arm64|aarch64|armv7|arm|ia32|riscv64|ppc64|s390x|loong64)([\\/._-]|$)/i,+};+const NATIVE_FOLDER = /prebuild|bin|native|platform|-(win32|darwin|linux)/i;++/** The Harness's own JavaScript packages (`@deepseek-ai/dsh-*`) are code every platform imports by name; never drop one. */+export function isHarnessCodePackage(path) {+ const parts = path.split(sep);+ const i = parts.lastIndexOf('@deepseek-ai');+ return i >= 0 && i === parts.length - 2 && parts[i + 1].startsWith('dsh-');+}++/** True when the folder `path` (a directory named `name`) is another operating system's prebuilt binary and can go. */+export function isOtherOsBinaryFolder(platform, name, path) {+ const rule = OTHER_OS[platform] ?? OTHER_OS.linux;+ if (isHarnessCodePackage(path)) return false;+ return rule.test(name) && NATIVE_FOLDER.test(path);+}++/** Imports the Windows copy (which works) is also without: browser-side or dev-only bundles, and the document converter the app drops on purpose. */+const KNOWN_ABSENT = new Set([+ '@deepseek-ai/libreoffice-kit', '@deepseek-ai/dsh-client-ui-dockkit', '@deepseek-ai/dsh-client-web',+ '@deepseek-ai/dsh-experimental-webworker-runtime', '@deepseek-ai/dsh-remote-mock', '@deepseek-ai/dsh-client-test-runtime',+]);++function jsFiles(dir, out = []) {+ for (const e of readdirSync(dir, { withFileTypes: true })) {+ const p = join(dir, e.name);+ if (e.isSymbolicLink()) continue;+ if (e.isDirectory()) jsFiles(p, out);+ else if (/\.(m?js|cjs)$/.test(e.name)) out.push(p);+ }+ return out;+}++/**+ * Every bare `@deepseek-ai/<package>` the staged Harness's own packages import (static `from "x"` and `import("x")`) must exist+ * in the staged node_modules. Returns the list of `{from, missing}` problems (empty = good). Plugins that are only loaded on+ * another platform still count: Node resolves a static import whether or not the code runs.+ */+export function missingHarnessImports(harnessDir) {+ const scope = join(harnessDir, 'node_modules', '@deepseek-ai');+ if (!existsSync(scope)) return [{ from: scope, missing: '@deepseek-ai (no installed packages)' }];+ const problems = [];+ const seen = new Set();+ const re = /(?:from|import)\s*\(?\s*["'](@deepseek-ai\/[^"'/]+)(?:\/[^"']*)?["']/g;+ for (const pkg of readdirSync(scope)) {+ const lib = join(scope, pkg, 'lib');+ if (!existsSync(lib)) continue;+ for (const file of jsFiles(lib)) {+ const text = readFileSync(file, 'utf8');+ for (const m of text.matchAll(re)) {+ const name = m[1];+ const key = `${pkg}>${name}`;+ if (seen.has(key) || KNOWN_ABSENT.has(name)) continue;+ seen.add(key);+ if (!existsSync(join(harnessDir, 'node_modules', ...name.split('/')))+ && !existsSync(join(scope, pkg, 'node_modules', ...name.split('/')))) problems.push({ from: `${pkg}`, missing: name });+ }+ }+ }+ return problems;+}diff --git a/apps/desktop/scripts/stage-harness.mjs b/apps/desktop/scripts/stage-harness.mjsindex 7ea86c34d..74d9b960b 100644--- a/apps/desktop/scripts/stage-harness.mjs+++ b/apps/desktop/scripts/stage-harness.mjs@@ -18,6 +18,7 @@ import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync,import { join, relative, resolve, sep } from 'node:path';import { createHash } from 'node:crypto';import { flattenPnpm } from './flatten-pnpm.mjs';+import { isOtherOsBinaryFolder, missingHarnessImports } from './harness-prune.mjs';const args = process.argv.slice(2);const opt = (name, fallback) => { const i = args.indexOf(`--${name}`); return i >= 0 ? args[i + 1] : fallback; };@@ -118,11 +119,6 @@ const flat = flattenPnpm(out, { skip: /libreoffice-kit|sherpa-onnx/i });console.log(`flattened: ${flat.packages} placed (${flat.nested} nested for a second version)`);// --- prune -------------------------------------------------------------------------------------------------------------const OTHER_OS = platform === 'win32' ? /(^|[\\/._-])(darwin|linux|android|freebsd|musl)([\\/._-]|$)/i- : platform === 'darwin' ? /(^|[\\/._-])(win32|linux|android|freebsd|musl)([\\/._-]|$)/i- : /(^|[\\/._-])(win32|darwin|android|freebsd|musl|arm64|aarch64|armv7|arm|ia32|riscv64|ppc64|s390x|loong64)([\\/._-]|$)/i;-// Linux: the AppImage bundler (linuxdeploy) resolves the libraries of every ELF file under resources and stops on one it-// cannot satisfy (koffi's musl build wants libc.musl). The app is glibc x86_64, so musl and other-CPU builds are dropped./** Whole packages the app never loads: office-document conversion (hundreds of MB) and speech input. */const DROP_PACKAGES = [/libreoffice-kit/i, /sherpa-onnx/i];/** Only when sitting directly in a package's root (a library may have a runtime folder called `doc`, e.g. yaml/dist/doc). */@@ -137,7 +133,7 @@ function prune(dir) {if (e.isSymbolicLink()) continue;if (e.isDirectory()) {const inLib = p.split(sep).includes('lib');- if ((DROP_DIRS.has(e.name) && !inLib && existsSync(join(dir, 'package.json'))) || DROP_PACKAGES.some(r => r.test(e.name)) || (OTHER_OS.test(e.name) && /prebuild|bin|native|platform|-(win32|darwin|linux)/i.test(p))) {+ if ((DROP_DIRS.has(e.name) && !inLib && existsSync(join(dir, 'package.json'))) || DROP_PACKAGES.some(r => r.test(e.name)) || isOtherOsBinaryFolder(platform, e.name, p)) {rmSync(p, { recursive: true, force: true }); removed++; continue;}prune(p);@@ -165,7 +161,15 @@ writeFileSync(join(out, 'BUNDLE.json'), JSON.stringify({if (keepIgnore) writeFileSync(join(out, '.gitignore'), keepIgnore);-// --- proof: the staged copy answers --version and boots the web profile once ----------------------------------------+// --- proof 1: nothing the Harness imports by name was pruned ------------------------------------------------------------+// (2026-10-17: the other-OS rule once removed @deepseek-ai/dsh-win32-process, which every platform imports; Linux/Mac agent chats died.)+const lost = missingHarnessImports(out);+if (lost.length) { console.error('staged Harness is missing imported packages:+' + lost.map(l => ` ${l.from} -> ${l.missing}`).join('+')); process.exit(1); }+console.log('import check: every @deepseek-ai package the Harness imports is staged');++// --- proof 2: the staged copy answers --version and boots the web profile once ----------------------------------------const bin = join(out, 'apps', 'cli', 'lib', 'bin.js');const entry = existsSync(bin) ? bin : join(out, 'lib', 'bin.js');const v = spawnSync(process.execPath, [entry, '--version'], { encoding: 'utf8' });diff --git a/apps/host/server/agent/agent-bridge.mjs b/apps/host/server/agent/agent-bridge.mjsindex 07ceed363..e3e2c308c 100644--- a/apps/host/server/agent/agent-bridge.mjs+++ b/apps/host/server/agent/agent-bridge.mjs@@ -44,6 +44,24 @@ export function plainAgentFailure(raw) {return text;}+/**+ * A failure thrown while a turn starts, as `{ message, details, code }` for the chat's error card. The agent's own errors read like+ * `session/create: tool-bash (...): waiting for shell ...` (a plugin chain that never started): never shown raw. The plain sentence+ * goes in `message`; the technical text goes in `details`, which the app shows only behind Details.+ */+export function plainTurnFailure(err) {+ const raw = String(err?.message ?? err ?? '');+ const details = typeof err?.details === 'string' && err.details ? err.details : raw;+ if (err instanceof AgentUnavailable) return { message: err.message, details, code: err.code ?? 'AGENT_ERROR' };+ if (err?.code === 'agent-preset/invalid' || /waiting for (shell|subprocess|ptcRuntime|workflowEngine|sandbox)|failed to import|did not activate/i.test(raw)) {+ return { message: 'The coding assistant is missing a part it needs, so it cannot work on files yet. Close and reopen Strata. If it keeps happening, reinstall Strata. Chatting without tools still works.', details, code: 'AGENT_INCOMPLETE' };+ }+ if (/^[a-z][a-z-]*\/[a-z][a-z-]*: /i.test(raw) || /^(gateway|rpc)/i.test(raw)) {+ return { message: 'The coding assistant could not start this message. Try again. If it keeps happening, close and reopen Strata.', details, code: err?.code ?? 'AGENT_ERROR' };+ }+ return { message: plainAgentFailure(raw), details, code: err?.code ?? 'AGENT_ERROR' };+}+/** Attached pictures (data addresses) as the Harness's image prompt parts. */export function imageParts(images) {return (Array.isArray(images) ? images : []).map(i => {diff --git a/apps/host/server/index.mjs b/apps/host/server/index.mjsindex c7ed4a888..dae322222 100644--- a/apps/host/server/index.mjs+++ b/apps/host/server/index.mjs@@ -13,7 +13,7 @@ import { skillEdit } from './skill-edits.mjs';import { materializeSkills, parseSkillFile, skillSlug, writeCreatedSkill } from './skill-files.mjs';import { systemFonts } from './fonts.mjs';import { tuningDir } from './platform-paths.mjs';-import { createAgentBridge } from './agent/agent-bridge.mjs';+import { createAgentBridge, plainTurnFailure } from './agent/agent-bridge.mjs';import { createAgentTools } from './agent/tools-settings.mjs';import { withPlainStatus } from './agent/status.mjs';import { findBrowser, findPlaywrightMcp } from './agent/browser-probe.mjs';@@ -563,8 +563,9 @@ async function runAgentTurn({ res, controller, chatId, body, message, workspaceIif (result?.detached) void result.ended.then(r => settle(r?.tokensOut ?? null), () => settle(null));else settle(result?.tokensOut ?? null, result?.error ? 'The agent turn failed.' : undefined);} catch (err) {- write({ type: 'error', message: err.message, ...(err.details ? { details: err.details } : {}), code: err.code ?? 'AGENT_ERROR' });- settle(null, err.message);+ const plain = plainTurnFailure(err);+ write({ type: 'error', message: plain.message, ...(plain.details ? { details: plain.details } : {}), code: plain.code });+ settle(null, plain.message);}}diff --git a/apps/host/tests/agent-status.test.mjs b/apps/host/tests/agent-status.test.mjsindex 5ebd2cd9e..db6f5b5a1 100644--- a/apps/host/tests/agent-status.test.mjs+++ b/apps/host/tests/agent-status.test.mjs@@ -176,3 +176,14 @@ test('a goal step is always sent, even right after another status (it used to beadvance(400);assert.ok(frames.some(f => f.phase === 'goal' && f.args.round === 1), frames.map(f => f.phase).join(','));});++import { plainTurnFailure } from '../server/agent/agent-bridge.mjs';+test('a start failure from the agent reads in plain words and keeps the raw text for Details', () => {+ const raw = new Error('session/create: tool-bash (@deepseek-ai/dsh-tool-bash): waiting for shell\ntool-workflow: waiting for workflowEngine');+ raw.code = 'agent-preset/invalid';+ const f = plainTurnFailure(raw);+ assert.doesNotMatch(f.message, /session\/create|waiting for|@deepseek-ai|workflowEngine/);+ assert.match(f.message, /reinstall|reopen/i);+ assert.match(f.details, /waiting for workflowEngine/);+ assert.doesNotMatch(plainTurnFailure(new Error('turn/start: boom')).message, /turn\/start/);+});diff --git a/apps/host/tests/harness-staging.test.mjs b/apps/host/tests/harness-staging.test.mjsnew file mode 100644index 000000000..70993fe00--- /dev/null+++ b/apps/host/tests/harness-staging.test.mjs@@ -0,0 +1,48 @@+/**+ * The staged Harness keeps every package its plugins import (tester report 2026-10-17: Linux and Mac agent chats failed with+ * "session/create ... waiting for workflowEngine" because the other-OS prune removed @deepseek-ai/dsh-win32-process).+ */+import test from 'node:test';+import assert from 'node:assert/strict';+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join, sep } from 'node:path';+import { isHarnessCodePackage, isOtherOsBinaryFolder, missingHarnessImports } from '../../desktop/scripts/harness-prune.mjs';++const nm = (...p) => ['harness', 'node_modules', ...p].join(sep);++test('the Harness own code packages are never pruned, on any platform', () => {+ for (const platform of ['linux', 'darwin', 'win32']) {+ for (const name of ['dsh-win32-process', 'dsh-darwin-thing', 'dsh-linux-thing', 'dsh-sandbox-windows-acl']) {+ assert.equal(isOtherOsBinaryFolder(platform, name, nm('@deepseek-ai', name)), false, `${platform}: ${name}`);+ }+ }+ assert.equal(isHarnessCodePackage(nm('@deepseek-ai', 'dsh-win32-process')), true);+ assert.equal(isHarnessCodePackage(nm('@deepseek-ai', 'dsh-win32-process', 'lib')), false);+});++test('other systems prebuilt binaries are still dropped', () => {+ assert.equal(isOtherOsBinaryFolder('linux', 'sharp-win32-x64', nm('@img', 'sharp-win32-x64')), true);+ assert.equal(isOtherOsBinaryFolder('linux', 'musl', nm('@deepseek-ai', 'node-addon-system-linux-x64', 'bin', 'musl')), true);+ assert.equal(isOtherOsBinaryFolder('darwin', 'win32-x64', nm('node-pty', 'prebuilds', 'win32-x64')), true);+ assert.equal(isOtherOsBinaryFolder('win32', 'linux-x64', nm('node-pty', 'prebuilds', 'linux-x64')), true);+ // this platform's own binaries stay+ assert.equal(isOtherOsBinaryFolder('linux', 'linux-x64', nm('node-pty', 'prebuilds', 'linux-x64')), false);+});++test('missingHarnessImports names a package a plugin imports that is not staged', () => {+ const root = mkdtempSync(join(tmpdir(), 'strata-stage-'));+ try {+ const scope = join(root, 'node_modules', '@deepseek-ai');+ mkdirSync(join(scope, 'dsh-subprocess-local', 'lib'), { recursive: true });+ writeFileSync(join(scope, 'dsh-subprocess-local', 'lib', 'index.js'), 'import { x } from "@deepseek-ai/dsh-win32-process";\nawait import("@deepseek-ai/dsh-here");\n');+ mkdirSync(join(scope, 'dsh-here'), { recursive: true });+ assert.deepEqual(missingHarnessImports(root), [{ from: 'dsh-subprocess-local', missing: '@deepseek-ai/dsh-win32-process' }]);+ mkdirSync(join(scope, 'dsh-win32-process'), { recursive: true });+ assert.deepEqual(missingHarnessImports(root), []);+ } finally { rmSync(root, { recursive: true, force: true }); }+});++test('a staged Harness (STRATA_HARNESS_DIR) has every package its plugins import', { skip: !process.env.STRATA_HARNESS_DIR }, () => {+ assert.deepEqual(missingHarnessImports(process.env.STRATA_HARNESS_DIR), []);+});