The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
dsh: cover manifest, launch and probe fully
dee602bc2918c80
diff --git a/cli/src/dsh/launch.spec.ts b/cli/src/dsh/launch.spec.tsindex ebe7777c9..1b8bb0b44 100644--- a/cli/src/dsh/launch.spec.ts+++ b/cli/src/dsh/launch.spec.ts@@ -30,6 +30,14 @@ describe('dshLaunch', () => {// What discovery reads back is exactly what was set.expect(dshFromEnv(launch.env)).toBe('autonomous/circuit')})++ it('a manifest with no agent section adds only the three HARNESS_ variables and no argv', () => {+ const bare: InstalledDsh = { ...installed, manifest: { spec: 1, id: 'autonomous/circuit', name: 'Circuit', engine: 'claude' } }+ expect(dshLaunch(bare, '/ws')).toEqual({+ env: { HARNESS_DSH: 'autonomous/circuit', HARNESS_DSH_DIR: '/src/circuit', HARNESS_WORKSPACE: '/ws' },+ args: [],+ })+ })})describe('buildLaunchOverrides with a DSH', () => {diff --git a/cli/src/dsh/manifest.spec.ts b/cli/src/dsh/manifest.spec.tsindex c33529c0e..63fb9a590 100644--- a/cli/src/dsh/manifest.spec.ts+++ b/cli/src/dsh/manifest.spec.ts@@ -89,6 +89,16 @@ describe('spec 1.1: package kinds and viewer.use', () => {expect(parseDshManifest(JSON.stringify({ ...base, kind: 'viewer' })).ok).toBe(false)expect(parseDshManifest(JSON.stringify({ ...base, kind: 'viewer', engine: 'claude', viewer: { command: 'v', url: 'http://127.0.0.1:${port}/' } })).ok).toBe(false)expect(parseDshManifest(JSON.stringify(base)).ok).toBe(false)+ const withAgent = parseDshManifest(JSON.stringify({ ...base, kind: 'viewer', agent: { instructions: 'AGENTS.md' }, viewer: { command: 'v', url: 'http://127.0.0.1:${port}/' } }))+ expect(withAgent).toEqual({ ok: false, error: 'harness.json is not a spec-1 manifest: agent: a viewer package has no agent' })+ })++ it('says why a manifest could not be read: the file, the JSON, or the first issues with their paths', () => {+ const missing = readDshManifest('/nonexistent/dir')+ expect(!missing.ok && missing.error).toMatch(/^no harness\.json in \/nonexistent\/dir \(ENOENT: /)+ const notJson = parseDshManifest('{"spec": 1,')+ expect(!notJson.ok && notJson.error).toMatch(/^harness\.json is not JSON: \S/)+ expect(parseDshManifest('[]')).toEqual({ ok: false, error: expect.stringMatching(/^harness\.json is not a spec-1 manifest: \(root\): /) })})it('an agent may use a viewer package instead of shipping one, and may narrow its url and extensions', () => {const used = parseDshManifest(JSON.stringify({ ...base, engine: 'claude', viewer: { use: 'autonomous/cad-viewer', artifactExtensions: ['.step'] } }))diff --git a/cli/src/dsh/manifest.ts b/cli/src/dsh/manifest.tsindex 51d9c26a2..85eb944f7 100644--- a/cli/src/dsh/manifest.ts+++ b/cli/src/dsh/manifest.ts@@ -121,7 +121,8 @@ export function parseDshManifest(text: string): ManifestResult {try {value = JSON.parse(text)} catch (error) {- return { ok: false, error: `harness.json is not JSON: ${error instanceof Error ? error.message : String(error)}` }+ // JSON.parse throws only SyntaxError.+ return { ok: false, error: `harness.json is not JSON: ${(error as Error).message}` }}const parsed = DshManifestSchema.safeParse(value)if (parsed.success) return { ok: true, manifest: parsed.data }@@ -138,7 +139,8 @@ export function readDshManifest(dir: string): ManifestResult {try {text = readFileSync(`${dir}/${DSH_MANIFEST_FILE}`, 'utf8')} catch (error) {- return { ok: false, error: `no ${DSH_MANIFEST_FILE} in ${dir} (${error instanceof Error ? error.message : String(error)})` }+ // readFileSync throws only system errors.+ return { ok: false, error: `no ${DSH_MANIFEST_FILE} in ${dir} (${(error as Error).message})` }}return parseDshManifest(text)}diff --git a/cli/src/dsh/probe.spec.ts b/cli/src/dsh/probe.spec.tsnew file mode 100644index 000000000..5671f4ca9--- /dev/null+++ b/cli/src/dsh/probe.spec.ts@@ -0,0 +1,40 @@+// probeDsh on real processes: the id a live engine carries in HARNESS_DSH, read off its environment.+import { afterEach, describe, expect, it } from 'vitest'+import { spawn, type ChildProcess } from 'node:child_process'+import { clearProcessEnvCache } from '../lib/processEnv.js'+import { probeDsh } from './probe.js'++describe('probeDsh', () => {+ const children: ChildProcess[] = []+ afterEach(() => {+ for (const child of children.splice(0)) child.kill('SIGKILL')+ clearProcessEnvCache()+ })++ const live = async (extra: Record<string, string>): Promise<ChildProcess> => {+ const env = { ...process.env, ...extra }+ if (!('HARNESS_DSH' in extra)) delete env.HARNESS_DSH+ // Node, not /bin/sleep: macOS will not show a platform binary's environment to anyone.+ const child = spawn(process.execPath, ['-e', 'setInterval(() => {}, 1000)'], { env, stdio: 'ignore' })+ children.push(child)+ await new Promise((resolve) => setTimeout(resolve, 200))+ return child+ }++ it('answers the id a harness process carries, and null for a plain engine', async () => {+ const harness = await live({ HARNESS_DSH: 'autonomous/typst' })+ expect(await probeDsh({ pid: harness.pid!, executable: 'node', startMarker: 'a' })).toBe('autonomous/typst')+ const plain = await live({ SOME_OTHER: '1' })+ expect(await probeDsh({ pid: plain.pid!, executable: 'node', startMarker: 'b' })).toBeNull()+ const spoofed = await live({ HARNESS_DSH: '../../etc' })+ expect(await probeDsh({ pid: spoofed.pid!, executable: 'node', startMarker: 'c' })).toBeNull()+ })++ it('answers undefined, never null, when the process cannot be read', async () => {+ const gone = await live({ HARNESS_DSH: 'autonomous/typst' })+ const pid = gone.pid!+ gone.kill('SIGKILL')+ await new Promise((resolve) => gone.once('exit', resolve))+ expect(await probeDsh({ pid, executable: 'node', startMarker: 'gone' })).toBeUndefined()+ })+})