Skip to content

An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.

feat(agents): DeepSeek Harness is ready only from 0.2.1, signed in, and on a release whose plugin tree the patch still keeps to the browser

Shahriarff061dbf5ea8
diff --git a/src/daemon/agent/runners/deepseek.test.ts b/src/daemon/agent/runners/deepseek.test.ts
index 12d5bcb..59de9bb 100644
--- a/src/daemon/agent/runners/deepseek.test.ts
+++ b/src/daemon/agent/runners/deepseek.test.ts
@@ -1,9 +1,9 @@
-import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { homedir, tmpdir } from 'node:os';
import { join } from 'node:path';
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
-import { deepseekRunner } from './deepseek';
-import { jsonContext, readThrough, streamContext, transcript, type Call } from './fixtures/support';
+import { deepseekRunner, rowsOfTree, unvetted } from './deepseek';
+import { jsonContext, readThrough, streamContext, stubCli, transcript, type Call } from './fixtures/support';
import type { Conversation, StreamContext, StreamSink } from './types';
const SESSION = '942f4fe8-050b-49f9-8426-40bef1b73a35';
@@ -236,13 +236,37 @@ describe('plans', () => {
});
});
+describe('the plugin tree a release composes', () => {
+ const tree = readFileSync(new URL('./fixtures/deepseek/0.2.1-rc.2-tree.yml', import.meta.url), 'utf8');
+
+ test('is read row by row, and 0.2.1-rc.2’s leaves no tool on that Browsentic has not vetted', () => {
+ const rows = rowsOfTree(tree);
+ expect(rows.find((row) => row.id === 'tool-bash')).toEqual({ id: 'tool-bash', name: '@deepseek-ai/dsh-tool-bash', on: false });
+ expect(rows.find((row) => row.id === 'tool-web')).toEqual({ id: 'tool-web', name: '@deepseek-ai/dsh-tool-web', on: true });
+ expect(unvetted(rows)).toEqual([]);
+ });
+
+ test('a tool row a later release adds, left on, is found', () => {
+ const later = `${tree}- id: tool-terminal\n name: '@deepseek-ai/dsh-tool-terminal'\n`;
+ expect(unvetted(rowsOfTree(later))).toEqual(['tool-terminal']);
+ });
+});
+
describe('readiness', () => {
const was = { home: process.env.DSH_HOME, key: process.env.DEEPSEEK_API_KEY };
+ const tree = readFileSync(new URL('./fixtures/deepseek/0.2.1-rc.2-tree.yml', import.meta.url), 'utf8');
let home: string;
+ let SETTINGS: { bin: string };
+ /** A stand-in dsh that prints this tree for `--dump-config`. */
+ const printing = (name: string, printed: string) => ({
+ bin: stubCli(join(home, name), `process.stdout.write(${JSON.stringify(printed)});`),
+ });
beforeEach(() => {
home = mkdtempSync(join(tmpdir(), 'dsh-home-'));
process.env.DSH_HOME = home;
delete process.env.DEEPSEEK_API_KEY;
+ SETTINGS = printing('dsh', tree);
+ vi.useRealTimers();
});
afterEach(() => {
rmSync(home, { recursive: true, force: true });
@@ -265,4 +289,16 @@ describe('readiness', () => {
test('no sign-in at all asks for one', async () => {
expect(await deepseekRunner.check?.(SETTINGS)).toMatchObject({ code: 'AGENT_NEEDS_PERMISSION', fix: 'dsh web' });
});
+
+ test('a release whose tree leaves a tool on that the patch does not cover is not used', async () => {
+ process.env.DEEPSEEK_API_KEY = 'sk-x';
+ const later = printing('dsh-later', `${tree}- id: tool-terminal\n name: '@deepseek-ai/dsh-tool-terminal'\n`);
+ expect(await deepseekRunner.check?.(later, '0.3.0')).toMatchObject({ code: 'AGENT_UNUSABLE', message: expect.stringContaining('tool-terminal') });
+ expect(await deepseekRunner.check?.(SETTINGS, '0.2.1-rc.2')).toBeNull();
+ });
+
+ test('a release older than the one this runner was written against is not used', async () => {
+ process.env.DEEPSEEK_API_KEY = 'sk-x';
+ expect(await deepseekRunner.check?.(SETTINGS, '0.1.9')).toMatchObject({ code: 'AGENT_UNUSABLE', fix: 'npm i -g @deepseek-ai/dsh' });
+ });
});
diff --git a/src/daemon/agent/runners/deepseek.ts b/src/daemon/agent/runners/deepseek.ts
index 65dd9e8..efa636d 100644
--- a/src/daemon/agent/runners/deepseek.ts
+++ b/src/daemon/agent/runners/deepseek.ts
@@ -1,10 +1,13 @@
-import { mkdirSync, readdirSync, readFileSync } from 'node:fs';
+import { mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
import { homedir } from 'node:os';
import { join } from 'node:path';
import type { AgentProblem } from '@/lib/agents/catalog';
import { stateDir } from '../../lockfile';
+import type { AgentSettings } from '../config';
import { acpConversation, type ConfigOption, type ModelEntry, type Update } from './acp';
import { MCP_SERVER_NAME } from './claude';
+import { spawnCli, stopTree, type CliProcess } from './command';
+import { childEnv } from './drive';
import { conversationDir, effortOf, parseJsonLine, sweepRunDirs } from './util';
import type { JsonContext, McpServer, Plan, Runner, RunMode, StreamContext, StreamReader, StreamSink } from './types';
@@ -122,7 +125,7 @@ export const deepseekRunner: Runner = {
return {
...turn,
files: [
- { path: PATCH, content: patch([...runRows(context, chosen), insertServer(context.mcp)]) },
+ { path: PATCH, content: patch([...runRows(context.research, chosen), insertServer(context.mcp)]) },
{ path: INSTRUCTIONS, content: context.systemPrompt },
],
args: ['--profile', 'headless', '--patch', join(turn.cwd, PATCH), ...resume, '--json', '-'],
@@ -139,7 +142,7 @@ export const deepseekRunner: Runner = {
const plan: Plan = {
...turn,
files: [
- { path: PATCH, content: patch([...runRows(context, opening), { id: 'acp', config: { provider: opening.provider, model: opening.model } }]) },
+ { path: PATCH, content: patch([...runRows(context.research, opening), { id: 'acp', config: { provider: opening.provider, model: opening.model } }]) },
{ path: INSTRUCTIONS, content: context.systemPrompt },
],
args: ['--profile', 'acp', '--patch', join(turn.cwd, PATCH)],
@@ -242,16 +245,112 @@ export const deepseekRunner: Runner = {
return said ? explain(said[2]) : null;
},
- async check(): Promise<AgentProblem | null> {
- if (signedIn('account') || signedIn('key') || process.env.DEEPSEEK_API_KEY) return null;
- return {
- code: 'AGENT_NEEDS_PERMISSION',
- message: 'DeepSeek Harness is not signed in to a DeepSeek account, and no DEEPSEEK_API_KEY is set.',
- fix: SIGN_IN,
- };
+ async check(settings: AgentSettings, version?: string): Promise<AgentProblem | null> {
+ if (tooOld(version)) {
+ return { code: 'AGENT_UNUSABLE', message: `Browsentic needs DeepSeek Harness ${FLOOR.join('.')} or later; this one is ${version?.trim()}.`, fix: INSTALL };
+ }
+ if (!signedIn('account') && !signedIn('key') && !process.env.DEEPSEEK_API_KEY) {
+ return {
+ code: 'AGENT_NEEDS_PERMISSION',
+ message: 'DeepSeek Harness is not signed in to a DeepSeek account, and no DEEPSEEK_API_KEY is set.',
+ fix: SIGN_IN,
+ };
+ }
+ return vetted(settings.bin, version);
},
};
+/** The first release measured: its ACP server, patch rows and headless events are what this runner is written against. */
+const FLOOR = [0, 2, 1];
+
+function tooOld(version: string | undefined): boolean {
+ const parts = /^v?(\d+)\.(\d+)\.(\d+)/.exec(version?.trim() ?? '');
+ if (!parts) return false;
+ const [major, minor, patch] = parts.slice(1).map(Number);
+ return major !== FLOOR[0] ? major < FLOOR[0] : minor !== FLOOR[1] ? minor < FLOOR[1] : patch < FLOOR[2];
+}
+
+/** Tool plugins a run may keep on: the to-do list, the timeout every call runs under, and the web on research. */
+const VETTED = ['@deepseek-ai/dsh-tool-todo', '@deepseek-ai/dsh-tool-call-timeout-policy', '@deepseek-ai/dsh-tool-web'];
+
+/** Plugins that hand the model a tool of their own, by the package they come from. */
+const TOOLISH = /^@deepseek-ai\/dsh-(tool-|mcp-client|browser-use|computer-use|terminal|ptc|workflow)/;
+
+const DUMP_TIMEOUT_MS = 10_000;
+
+/** The tree each dsh a run would compose was last found in, by bin and version: a release can add a tool row that starts on. */
+const trees = new Map<string, Promise<AgentProblem | null>>();
+
+/**
+ * The plugin tree a research turn would run on, as this dsh composes it with the patch: any tool
+ * plugin left on that Browsentic has not vetted means the patch no longer covers this release.
+ * An answer that cannot be read is no objection; the plan is still vetted, and the run tripped.
+ */
+function vetted(bin: string, version?: string): Promise<AgentProblem | null> {
+ const key = `${bin}|${version ?? ''}`;
+ let asked = trees.get(key);
+ if (!asked) {
+ asked = composedTree(bin).then((tree) => {
+ const left = tree ? unvetted(tree) : [];
+ if (!left.length) return null;
+ return {
+ code: 'AGENT_UNUSABLE',
+ message: `This DeepSeek Harness has tool plugins Browsentic has not checked, so it would not keep a run to the browser: ${left.join(', ')}. Update Browsentic, or install the DeepSeek Harness it was checked against.`,
+ } satisfies AgentProblem;
+ });
+ trees.set(key, asked);
+ }
+ return asked;
+}
+
+interface TreeRow {
+ id: string;
+ name: string;
+ on: boolean;
+}
+
+function composedTree(bin: string): Promise<TreeRow[] | null> {
+ const cwd = join(root(), 'check');
+ mkdirSync(cwd, { recursive: true });
+ writeFileSync(join(cwd, PATCH), patch([...runRows(true, { provider: provider(), model: DEFAULT_MODEL }), { id: 'acp', config: { provider: provider(), model: DEFAULT_MODEL } }]));
+ let child: CliProcess;
+ try {
+ child = spawnCli(bin, ['--profile', 'acp', '--patch', join(cwd, PATCH), '--dump-config'], { cwd, env: { ...childEnv('deepseek'), ...environment(cwd, runHome()) } });
+ } catch {
+ return Promise.resolve(null);
+ }
+ return new Promise((resolve) => {
+ let output = '';
+ const timer = setTimeout(() => {
+ stopTree(child, 'SIGKILL');
+ resolve(null);
+ }, DUMP_TIMEOUT_MS);
+ child.stdout.on('data', (chunk: Buffer) => (output += chunk.toString('utf8')));
+ child.on('error', () => {
+ clearTimeout(timer);
+ resolve(null);
+ });
+ child.on('close', (code) => {
+ clearTimeout(timer);
+ resolve(code === 0 ? rowsOfTree(output) : null);
+ });
+ });
+}
+
+/** The tool rows a composed tree leaves on that Browsentic has not vetted. */
+export const unvetted = (tree: TreeRow[]): string[] => tree.filter((row) => row.on && TOOLISH.test(row.name) && !VETTED.includes(row.name)).map((row) => row.id);
+
+/** The rows of a `--dump-config` tree: each starts `- id:` at the margin, and is off only where it says `disabled: true`. */
+export function rowsOfTree(yaml: string): TreeRow[] {
+ return yaml
+ .split(/\n(?=- )/)
+ .flatMap((block) => {
+ const id = /^- id: (\S+)/.exec(block)?.[1];
+ const name = /^\s+name: '?([^'\s]+)'?/m.exec(block)?.[1];
+ return id && name ? [{ id, name, on: !/^\s+disabled: true$/m.test(block) }] : [];
+ });
+}
+
/** What every streamed turn starts from: its conversation's folder, and the run's own dsh home. */
function turnOf(context: StreamContext): Omit<Plan, 'args' | 'files'> {
const base = deepseekRunner.workspace('run');
@@ -292,9 +391,9 @@ const signIn = (): Row[] => [
...SIGN_IN_ROWS.map((id) => ({ id, disabled: false })),
];
-function runRows(context: StreamContext, turn: Route): Row[] {
+function runRows(research: boolean, turn: Route): Row[] {
return [
- ...[...SWITCHED_OFF, ...(context.research ? [] : [WEB])].map((id) => ({ id, disabled: true })),
+ ...[...SWITCHED_OFF, ...(research ? [] : [WEB])].map((id) => ({ id, disabled: true })),
...signIn(),
defaultModel(turn),
instructionsRow(PATCH),
diff --git a/src/daemon/agent/runners/fixtures/deepseek/0.2.1-rc.2-tree.yml b/src/daemon/agent/runners/fixtures/deepseek/0.2.1-rc.2-tree.yml
new file mode 100644
index 0000000..6758afb
--- /dev/null
+++ b/src/daemon/agent/runners/fixtures/deepseek/0.2.1-rc.2-tree.yml
@@ -0,0 +1,435 @@
+# Printed by `dsh --profile acp --patch <a research turn's patch> --dump-config` 0.2.1-rc.2, paths made /Users/you.
+# == @deepseek-ai/dsh-base
+- id: tool-plugin-manager
+ name: '@deepseek-ai/dsh-plugin-manager/tools'
+ disabled: true
+- id: plugin-manager
+ name: '@deepseek-ai/dsh-plugin-manager'
+ disabled: !!js '!ctx.get(''profileContext'')'
+- id: timer
+ name: '@deepseek-ai/cordis-plugin-timer'
+# == @deepseek-ai/dsh-base, patched by @deepseek-ai/dsh-acp-app
+- id: hmr
+ name: '@deepseek-ai/dsh-hmr'
+ disabled: true
+ config:
+ root: []
+# == @deepseek-ai/dsh-base
+- id: llm
+ name: '@deepseek-ai/dsh-llm'
+- id: deepseek-llm-api-extensions
+ name: '@deepseek-ai/dsh-deepseek-llm-api-extensions'
+- id: session
+ name: '@deepseek-ai/dsh-session'
+- id: session-log-deepseek
+ name: '@deepseek-ai/dsh-session-log-deepseek'
+- id: typert
+ name: '@deepseek-ai/dsh-typert-registry'
+- id: typert-loader
+ name: '@deepseek-ai/dsh-typert-loader'
+- id: typert-gateway
+ name: '@deepseek-ai/dsh-api-gateway'
+- id: remote-access
+ name: '@deepseek-ai/dsh-api-remote-access'
+- id: session-title
+ name: '@deepseek-ai/dsh-session-title'
+ config:
+ fallbackMaxWords: 5
+ fallbackMaxBytes: 40
+ maxTitleBytes: 80
+# == @deepseek-ai/dsh-base, patched by @deepseek-ai/dsh-acp-app
+- id: session-title-llm
+ name: '@deepseek-ai/dsh-session-title-first-prompt-llm'
+ config:
+ targetWords: 5
+ targetCjkCharacters: 10
+ maxInputBytes: 4096
+ maxOutputTokens: 4096
+ timeoutMs: 60000
+ disabled: true
+# == @deepseek-ai/dsh-base, patched by /Users/you/.browsentic/agents/deepseek/check/browsentic.patch.yml
+- id: user-questions
+ name: '@deepseek-ai/dsh-user-questions'
+ disabled: true
+# == @deepseek-ai/dsh-base
+- id: agent
+ name: '@deepseek-ai/dsh-agent'
+- id: plugin-package-inventory-deepseek
+ name: '@deepseek-ai/dsh-plugin-package-inventory-deepseek'
+- id: agent-default-model
+ name: '@deepseek-ai/dsh-agent-default-model'
+ config:
+ provider: deepseek-official
+ model: deepseek-flash
+- id: jobs
+ name: '@deepseek-ai/dsh-jobs-local'
+- id: llm-retry
+ name: '@deepseek-ai/dsh-llm-retry'
+- id: config-editor
+ name: '@deepseek-ai/dsh-config-editor'
+ disabled: !!js '!ctx.get(''profileContext'')'
+- id: settings
+ name: '@deepseek-ai/dsh-settings'
+ disabled: !!js '!ctx.get(''profileContext'')'
+# == @deepseek-ai/dsh-base, patched by /Users/you/.browsentic/agents/deepseek/check/browsentic.patch.yml
+- id: authorization
+ name: '@deepseek-ai/dsh-authorization'
+ disabled: false
+- id: deepseek-account
+ name: '@deepseek-ai/dsh-deepseek-account-platform'
+ config:
+ desktopPlatform: !!js >-
+ ctx.get('profileContext')?.name === 'desktop' && ['darwin',
+ 'win32'].includes(process.platform) ? process.platform : null
+ disabled: false
+- id: credentials
+ name: '@deepseek-ai/dsh-credentials-local'
+ disabled: false
+ config:
+ path: >-
+ /private/var/folders/ry/gt_fsv717y94__g66vz08x_h0000gn/T/browsentic-test-imQa3R/.dsh/.credentials.yaml
+# == @deepseek-ai/dsh-base
+- id: llm-pi-ai
+ name: '@deepseek-ai/dsh-llm-pi-ai'
+- id: session-persistence-jsonl
+ name: '@deepseek-ai/dsh-session-persistence-jsonl'
+ config:
+ root: !!js dshHomePath('sessions')
+- id: attachment-local
+ name: '@deepseek-ai/dsh-attachment-local'
+- id: session-query-sqlite
+ name: '@deepseek-ai/dsh-session-query-sqlite'
+ config:
+ path: ':memory:'
+ openAt: never
+- id: working-directory
+ name: '@deepseek-ai/dsh-working-directory'
+# == @deepseek-ai/dsh-base, patched by /Users/you/.browsentic/agents/deepseek/check/browsentic.patch.yml
+- id: tool-working-directory
+ name: '@deepseek-ai/dsh-tool-working-directory'
+ disabled: true
+# == @deepseek-ai/dsh-base
+- id: session-projection
+ name: '@deepseek-ai/dsh-session-projection'
+- id: storage
+ name: '@deepseek-ai/dsh-storage'
+- id: storage-json
+ name: '@deepseek-ai/dsh-storage-json'
+ config:
+ root: !!js dshHomePath('storages')
+- id: storage-domain
+ name: '@deepseek-ai/dsh-storage-domain'
+ config:
+ backend: json
+- id: session-projection-cache
+ name: '@deepseek-ai/dsh-session-projection-cache'
+ config:
+ writeEveryEvents: 200
+ writeIntervalMs: 5000
+# == @deepseek-ai/dsh-base, patched by /Users/you/.browsentic/agents/deepseek/check/browsentic.patch.yml
+- id: otel
+ name: '@deepseek-ai/dsh-otel'
+ disabled: true
+- id: session-telemetry-otel
+ name: '@deepseek-ai/dsh-session-telemetry-otel'
+ config:
+ mode: !!js process.env.DSH_TELEMETRY_MODE || 'FEEDBACK_ONLY'
+ shutdownTimeoutMillis: 3000
+ maxRequestBytes: 4000000
+ exporter:
+ url: !!js >-
+ process.env.DSH_TELEMETRY_OTLP_URL ??
+ 'https://dsh-otel-collector.deepseeksvc.com/v1/logs'
+ compression: gzip
+ timeoutMillis: 1000
+ processor:
+ scheduledDelayMillis: 10000
+ maxQueueSize: 2048
+ maxExportBatchSize: 2048
+ exportTimeoutMillis: 1500
+ disabled: true
+# == @deepseek-ai/dsh-base
+- id: subprocess
+ name: '@deepseek-ai/dsh-subprocess-local'
+- id: sandbox
+ name: '@deepseek-ai/dsh-sandbox-local'
+- id: sandbox-policy
+ name: '@deepseek-ai/dsh-sandbox-policy'
+ config:
+ mode: !!js process.env.DSH_PERMISSION_MODE ?? 'workspace-write'
+ workspaceRoot: !!js process.cwd()
+- id: bash-sandbox
+ name: '@deepseek-ai/dsh-bash-sandbox'
+ disabled: !!js process.platform === 'win32'
+ config:
+ timeoutMs: 60000
+- id: pwsh-sandbox
+ name: '@deepseek-ai/dsh-pwsh-sandbox'
+ disabled: !!js process.platform !== 'win32'
+- id: approval
+ name: '@deepseek-ai/dsh-user-approval'
+ config:
+ policy: !!js >-
+ (process.env.DSH_PERMISSION_MODE ?? 'workspace-write') ===
+ 'danger-full-access' ? 'never' : 'ask'
+- id: permission
+ name: '@deepseek-ai/dsh-permission-presets'
+ config:
+ presets:
+ read-only:
+ sandbox: read-only
+ approval: ask
+ workspace-write:
+ sandbox: workspace-write
+ approval: ask
+ danger-full-access:
+ sandbox: danger-full-access
+ approval: never
+- id: shell-env
+ name: '@deepseek-ai/dsh-shell-env'
+# == @deepseek-ai/dsh-base, patched by /Users/you/.browsentic/agents/deepseek/check/browsentic.patch.yml
+- id: tool-bash
+ name: '@deepseek-ai/dsh-tool-bash'
+ disabled: true
+- id: tool-pwsh
+ name: '@deepseek-ai/dsh-tool-pwsh'
+ disabled: true
+- id: tool-jobs
+ name: '@deepseek-ai/dsh-tool-jobs'
+ disabled: true
+# == @deepseek-ai/dsh-base
+- id: fs-observation-policy
+ name: '@deepseek-ai/dsh-fs-observation-policy'
+# == @deepseek-ai/dsh-base, patched by /Users/you/.browsentic/agents/deepseek/check/browsentic.patch.yml
+- id: tool-fs
+ name: '@deepseek-ai/dsh-tool-fs'
+ disabled: true
+- id: tool-fs-search
+ name: '@deepseek-ai/dsh-tool-fs-search'
+ config:
+ sampleOverCapGlobResults: false
+ disabled: true
+- id: agent-instructions
+ name: '@deepseek-ai/dsh-agent-instructions'
+ config:
+ maxBytes: 262144
+ projectRootMarkers:
+ - browsentic.patch.yml
+ localInstructionFileCandidates: []
+- id: skill
+ name: '@deepseek-ai/dsh-skill'
+ disabled: true
+- id: skill-filesystem
+ name: '@deepseek-ai/dsh-skill-filesystem'
+ disabled: true
+- id: tool-skill
+ name: '@deepseek-ai/dsh-tool-skill'
+ disabled: true
+- id: commands
+ name: '@deepseek-ai/dsh-commands'
+ disabled: true
+- id: command-feedback
+ name: '@deepseek-ai/dsh-command-feedback'
+ disabled: true
+- id: goal
+ name: '@deepseek-ai/dsh-goal'
+ disabled: true
+- id: goal-round-driver
+ name: '@deepseek-ai/dsh-goal-round-driver'
+ disabled: true
+- id: command-goal
+ name: '@deepseek-ai/dsh-command-goal'
+ disabled: true
+- id: plan-mode
+ name: '@deepseek-ai/dsh-plan-mode'
+ config:
+ section: >
+ You are in plan mode. Stay in plan mode until the user approves your plan
+ through exit_plan_mode or switches the session mode. Imperative language
+ to implement changes means plan the implementation, not execute it. A
+ user's conversational agreement — including an answer confirming something
+ you asked — approves nothing and does not end plan mode; fold the
+ confirmed decision into the plan and submit it through exit_plan_mode.
+
+
+ Explore first. Use non-mutating reads, searches, static analysis, and
+ checks to ground the plan in the actual repository. Do not edit or write
+ files, change configuration, run formatters or code generation that
+ rewrites tracked files, commit, or otherwise carry out the plan. Prefer
+ existing functions and patterns over new machinery.
+
+
+ The tool catalog stays the same across modes for request-cache stability.
+ These plan-mode rules override any later tool description or guidance that
+ suggests using mutation tools; those tools remain listed only to keep the
+ request shape stable. Do not use todo_write to track this planning phase:
+ it tracks implementation after an approved plan, while the plan itself
+ belongs in exit_plan_mode.
+
+
+ Resolve discoverable facts by inspection. Use ask_user_question only for
+ user-owned choices or material ambiguity that inspection cannot answer. Do
+ not ask the user where code lives or how current behavior works when you
+ can find out.
+
+
+ Make the plan decision-complete: state the goal and success criteria;
+ group implementation changes by subsystem; identify public API, schema,
+ and data-flow changes; cover edge cases, failure modes, tests, acceptance
+ criteria, and explicit assumptions. Keep it concise enough to review but
+ detailed enough that another engineer can implement it without making
+ design decisions.
+
+
+ When ready, call exit_plan_mode with the complete plan markdown, starting
+ with a # title. Make exit_plan_mode the only and final tool call in that
+ assistant response: it presents the plan for approval, and implementation
+ begins only in a later step after approval. Do not paste the final plan as
+ a plain reply or ask "should I proceed?" through prose or
+ ask_user_question. If review rejects it, incorporate the feedback and
+ present again. If the review channel is unavailable or aborted, stay in
+ plan mode and ask the user to switch modes manually; do not proceed with
+ implementation.
+ disabled: true
+# == @deepseek-ai/dsh-base
+- id: token-meter
+ name: '@deepseek-ai/dsh-token-meter'
+- id: compaction-basic
+ name: '@deepseek-ai/dsh-compaction-basic'
+# == @deepseek-ai/dsh-base, patched by /Users/you/.browsentic/agents/deepseek/check/browsentic.patch.yml
+- id: command-compact
+ name: '@deepseek-ai/dsh-command-compact'
+ disabled: true
+# == @deepseek-ai/dsh-base
+- id: subagent
+ name: '@deepseek-ai/dsh-subagent'
+- id: subagent-spawn-in-process
+ name: '@deepseek-ai/dsh-subagent-spawn-in-process'
+ config:
+ providerName: spawn
+- id: subagent-fork-in-process
+ name: '@deepseek-ai/dsh-subagent-fork-in-process'
+ config:
+ providerName: fork
+# == @deepseek-ai/dsh-base, patched by /Users/you/.browsentic/agents/deepseek/check/browsentic.patch.yml
+- id: tool-subagent-control
+ name: '@deepseek-ai/dsh-tool-subagent-control'
+ disabled: true
+- id: tool-subagent-list-agents
+ name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
+ disabled: true
+- id: tool-subagent
+ name: '@deepseek-ai/dsh-tool-subagent'
+ config:
+ provider: spawn
+ toolName: subagent
+ disabled: true
+- id: tool-subagent-fork
+ name: '@deepseek-ai/dsh-tool-subagent'
+ config:
+ provider: fork
+ toolName: subagent_fork
+ disabled: true
+- id: ptc-runtime
+ name: '@deepseek-ai/dsh-ptc-runtime-node'
+ disabled: true
+- id: workflow-ptc
+ name: '@deepseek-ai/dsh-workflow-ptc'
+ config:
+ provider: spawn
+ disabled: true
+- id: tool-workflow
+ name: '@deepseek-ai/dsh-tool-workflow'
+ disabled: true
+# == @deepseek-ai/dsh-base
+- id: timeout-policy
+ name: '@deepseek-ai/dsh-tool-call-timeout-policy'
+- id: spill-local
+ name: '@deepseek-ai/dsh-spill-local'
+# == @deepseek-ai/dsh-base, patched by /Users/you/.browsentic/agents/deepseek/check/browsentic.patch.yml
+- id: spill-policy
+ name: '@deepseek-ai/dsh-spill-policy'
+ config:
+ maxInlineTokens: 25000
+# == @deepseek-ai/dsh-base
+- id: session-checkpoint-policy
+ name: '@deepseek-ai/dsh-session-checkpoint-policy'
+- id: tool-result-pruner
+ name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
+ config:
+ thresholdChars: 8192
+ headChars: 4096
+ tailChars: 1024
+- id: image-offload
+ name: '@deepseek-ai/dsh-compaction-image-offload'
+- id: tool-todo
+ name: '@deepseek-ai/dsh-tool-todo'
+ config:
+ allowParallelInProgress: true
+# == @deepseek-ai/dsh-base, patched by /Users/you/.browsentic/agents/deepseek/check/browsentic.patch.yml
+- id: tool-goal
+ name: '@deepseek-ai/dsh-tool-goal'
+ disabled: true
+# == @deepseek-ai/dsh-base
+- id: repeat-tool-reminder
+ name: '@deepseek-ai/dsh-repeat-tool-reminder'
+ config:
+ thresholds:
+ - 3
+ - 5
+ - 8
+ argumentsPreviewChars: 500
+- id: web
+ name: '@deepseek-ai/dsh-web'
+ config:
+ searchProvider: deepseek-official
+ fetchProvider: http
+- id: web-search-deepseek
+ name: '@deepseek-ai/dsh-web-search-deepseek'
+ config:
+ apiKeyEnv: DEEPSEEK_API_KEY
+- id: web-deepseek-api
+ name: '@deepseek-ai/dsh-web-deepseek-api'
+ config:
+ apiKeyEnv: DEEPSEEK_API_KEY
+- id: web-fetch-http
+ name: '@deepseek-ai/dsh-web-fetch-http'
+- id: tool-web
+ name: '@deepseek-ai/dsh-tool-web'
+ config:
+ fetch: true
+ searchTimeoutMs: 60000
+# == @deepseek-ai/dsh-base, patched by /Users/you/.browsentic/agents/deepseek/check/browsentic.patch.yml
+- id: mcp-resources
+ name: '@deepseek-ai/dsh-mcp-resources'
+ disabled: true
+# == @deepseek-ai/dsh-base
+- id: tools
+ name: '@deepseek-ai/dsh-tools'
+# == @deepseek-ai/dsh-base, patched by @deepseek-ai/dsh-acp-app, /Users/you/.browsentic/agents/deepseek/check/browsentic.patch.yml
+- id: system-prompt
+ name: '@deepseek-ai/dsh-system-prompt'
+ config:
+ personaPrefix: You are Browsentic's browser agent, powered by the {{model}} model.
+# == @deepseek-ai/dsh-base
+- id: agent-loop
+ name: '@deepseek-ai/dsh-agent-loop'
+ config:
+ agents: []
+- id: fs-sandbox
+ name: '@deepseek-ai/dsh-fs-sandbox'
+- id: llm-deepseek
+ name: '@deepseek-ai/dsh-llm-deepseek-api-key'
+- id: llm-deepseek-account
+ name: '@deepseek-ai/dsh-llm-deepseek-account'
+# == @deepseek-ai/dsh-acp-app
+- id: acp-app-startup
+ name: '@deepseek-ai/dsh-acp-app'
+# == @deepseek-ai/dsh-acp-app, patched by /Users/you/.browsentic/agents/deepseek/check/browsentic.patch.yml
+- id: acp
+ name: '@deepseek-ai/dsh-acp'
+ inject:
+ - acpAppStartup
+ config:
+ provider: deepseek-official
+ model: deepseek-flash
diff --git a/src/daemon/agent/service-deepseek.test.ts b/src/daemon/agent/service-deepseek.test.ts
new file mode 100644
index 0000000..d6b24a4
--- /dev/null
+++ b/src/daemon/agent/service-deepseek.test.ts
@@ -0,0 +1,66 @@
+import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { dirname, join } from 'node:path';
+import { afterEach, describe, expect, test, vi } from 'vitest';
+import type { RunEvent } from '@/lib/actions/protocol';
+import { failure } from '@/lib/actions/protocol';
+import { configPath } from './config';
+import { stubCli } from './runners/fixtures/support';
+import { AgentSession } from './service';
+
+// The whole way a side-panel turn takes to DeepSeek Harness: the plan vetted and written, the CLI
+// held over ACP with the run's browser server in its session, and its words back in the panel.
+describe('a DeepSeek Harness turn', () => {
+ afterEach(() => vi.unstubAllEnvs());
+
+ test('starts dsh on its patch in a home of its own, hands it the run’s browser server, and brings its answer back', async () => {
+ vi.stubEnv('DEEPSEEK_API_KEY', 'sk-test');
+ mkdirSync(dirname(configPath), { recursive: true });
+ const heard = join(dirname(configPath), 'dsh-heard.log');
+ rmSync(heard, { force: true });
+ const bin = stubCli(
+ join(dirname(configPath), 'dsh-acp'),
+ `const fs = require('node:fs');
+const note = (line) => fs.appendFileSync(${JSON.stringify(heard)}, JSON.stringify(line) + '\\n');
+const args = process.argv.slice(2);
+if (args[0] === '--version') { console.log('0.2.1-rc.2'); process.exit(0); }
+if (args.includes('--dump-config')) { process.stdout.write("- id: tool-bash\\n name: '@deepseek-ai/dsh-tool-bash'\\n disabled: true\\n"); process.exit(0); }
+note({ args, home: process.env.DSH_HOME, sandbox: process.env.DSH_PERMISSION_MODE, files: fs.readdirSync(process.cwd()).sort() });
+const send = (message) => process.stdout.write(JSON.stringify(message) + '\\n');
+require('node:readline').createInterface({ input: process.stdin }).on('line', (line) => {
+ const message = JSON.parse(line);
+ note({ method: message.method, mcpServers: message.params && message.params.mcpServers });
+ if (message.method === 'initialize') send({ jsonrpc: '2.0', id: message.id, result: { protocolVersion: 1 } });
+ if (message.method === 'session/new') send({ jsonrpc: '2.0', id: message.id, result: { sessionId: 'ds-1', configOptions: [] } });
+ if (message.method === 'session/prompt') {
+ send({ jsonrpc: '2.0', method: 'session/update', params: { sessionId: 'ds-1', update: { sessionUpdate: 'agent_message_chunk', messageId: 'm1', content: { type: 'text', text: 'It costs $4.' } } } });
+ send({ jsonrpc: '2.0', id: message.id, result: { stopReason: 'end_turn' } });
+ }
+});`,
+ );
+ writeFileSync(configPath, JSON.stringify({ agent: 'deepseek', agents: { deepseek: { bin } } }));
+ const events: RunEvent[] = [];
+ const session = new AgentSession({
+ invoke: async () => failure('EXTENSION_OFFLINE', 'no browser'),
+ emit: (_runId: string, event: RunEvent) => void events.push(event),
+ draft: () => {},
+ actionNames: () => [],
+ });
+ session.handle({ t: 'instruct', id: 'r1', text: 'what does this cost', context: { sessionId: 's1' } });
+ // dsh starts the run's browser server while it opens the session, and the server lists its tools then.
+ await vi.waitFor(() => expect(readFileSync(heard, 'utf8')).toContain('session/new'), { timeout: 15_000 });
+ session.described('r1');
+ await vi.waitFor(() => expect(events.some((event) => event.kind === 'done' || event.kind === 'error')).toBe(true), { timeout: 15_000 });
+
+ expect(events.filter((event) => event.kind === 'error')).toEqual([]);
+ expect(events).toContainEqual(expect.objectContaining({ kind: 'text', delta: 'It costs $4.' }));
+ const said = readFileSync(heard, 'utf8').trim().split('\n').map((line) => JSON.parse(line) as Record<string, unknown>);
+ expect(said[0]).toMatchObject({
+ args: ['--profile', 'acp', '--patch', expect.stringMatching(/browsentic\.patch\.yml$/)],
+ home: expect.stringMatching(/agents[\\/]deepseek[\\/]home$/),
+ sandbox: 'read-only',
+ files: ['AGENTS.md', 'browsentic.patch.yml'],
+ });
+ const opened = said.find((line) => line.method === 'session/new') as { mcpServers: { name: string; env: { name: string; value: string }[] }[] };
+ expect(opened.mcpServers).toEqual([expect.objectContaining({ name: 'browsentic', env: expect.arrayContaining([{ name: 'BROWSENTIC_AGENT_RUN', value: 'r1' }]) })]);
+ }, 30_000);
+});