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
RDKit: load and export molecules with punctuation and Unicode names (#230)
Deed488ceae06ec
diff --git a/store/agents/rdkit/pane/app.js b/store/agents/rdkit/pane/app.jsindex 3f8eb1a3b..c28c48b87 100644--- a/store/agents/rdkit/pane/app.js+++ b/store/agents/rdkit/pane/app.js@@ -4,6 +4,7 @@// RDKit worker. Bond scans run a native calculation and keep its source without changing the molecule./* global $3Dmol */import { installTorsionPane } from './torsion-pane.mjs'+import { workspaceFileUrl } from './files.mjs'const Mol3D = window.$3Dmol// ---------------------------------------------------------------------------------------------------@@ -938,7 +939,7 @@ function entryParent(entry) {}function thumbSrc(entry) {const rec = state.records.get(recordKey(entry))?.value- if (entry.svg && !entry.legacy && !entry.stale) return `/${state.dir}/${entry.svg}?v=${Math.round(entry.mtime)}`+ if (entry.svg && !entry.legacy && !entry.stale) return workspaceFileUrl(`${state.dir}/${entry.svg}`, { v: Math.round(entry.mtime) })if (rec?.svgText) return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(rec.svgText)return null}@@ -1023,7 +1024,7 @@ async function getJson(url) {async function getText(path, version) {const key = `${path}@${version}`if (!state.texts.has(key)) {- state.texts.set(key, fetch(`/${path}?v=${version}`, { cache: 'no-store' }).then((r) => { if (!r.ok) throw new Error(`${path}: ${r.status}`); return r.text() }))+ state.texts.set(key, fetch(workspaceFileUrl(path, { v: version }), { cache: 'no-store' }).then((r) => { if (!r.ok) throw new Error(`${path}: ${r.status}`); return r.text() }))state.texts.get(key).catch(() => state.texts.delete(key))}return state.texts.get(key)@@ -1458,8 +1459,8 @@ function openExportMenu() {{ label: 'Copy image', icon: ICON.copy, disabled: !mol, run: copyPng },{ label: 'Save 2D depiction (SVG)', icon: ICON.image, disabled: !rec?.svgText, run: () => { const url = URL.createObjectURL(new Blob([rec.svgText], { type: 'image/svg+xml' })); download(url, `${e.name}.svg`); setTimeout(() => URL.revokeObjectURL(url), 4000) } },{ header: mol?.torsionPreview ? 'Use Keep study for scan structures' : 'Structure' },- { label: 'SDF — lowest conformer', icon: ICON.file, disabled: !e || mol?.torsionPreview, run: () => download(`/${e.sdf}?download=1`, basename(e.sdf)) },- { label: `SDF — all ${rec?.conformers?.count || ''} conformers`, icon: ICON.file, disabled: !confFile || mol?.torsionPreview, run: () => download(`/${confFile}?download=1`, basename(confFile)) },+ { label: 'SDF — lowest conformer', icon: ICON.file, disabled: !e || mol?.torsionPreview, run: () => download(workspaceFileUrl(e.sdf, { download: 1 }), basename(e.sdf)) },+ { label: `SDF — all ${rec?.conformers?.count || ''} conformers`, icon: ICON.file, disabled: !confFile || mol?.torsionPreview, run: () => download(workspaceFileUrl(confFile, { download: 1 }), basename(confFile)) },{ label: 'MOL file', icon: ICON.file, disabled: !e || mol?.torsionPreview, run: () => download(`/api/mol?path=${encodeURIComponent(e.sdf)}`, `${e.name}.mol`) },'-',{ label: 'Copy SMILES', icon: ICON.copy, disabled: !rec?.smiles, run: () => copyText(rec.smiles) },diff --git a/store/agents/rdkit/pane/files.mjs b/store/agents/rdkit/pane/files.mjsnew file mode 100644index 000000000..7741263d4--- /dev/null+++ b/store/agents/rdkit/pane/files.mjs@@ -0,0 +1,5 @@+// Workspace paths are filenames, not URLs: #, ? and % must reach the server literally.+export function workspaceFileUrl(path, parameters = {}) {+ const query = new URLSearchParams(parameters).toString()+ return '/' + path.split('/').map(encodeURIComponent).join('/') + (query ? '?' + query : '')+}diff --git a/store/agents/rdkit/test/viewer.test.mjs b/store/agents/rdkit/test/viewer.test.mjsindex de4c8680b..7cd6928dd 100644--- a/store/agents/rdkit/test/viewer.test.mjs+++ b/store/agents/rdkit/test/viewer.test.mjs@@ -12,6 +12,7 @@ import { tmpdir } from 'node:os'import { dirname, join } from 'node:path'import { after, before, describe, test } from 'node:test'import { fileURLToPath } from 'node:url'+import { workspaceFileUrl } from '../pane/files.mjs'const PKG = join(dirname(fileURLToPath(import.meta.url)), '..')const VIEWER = join(PKG, 'viewer.mjs')@@ -149,6 +150,7 @@ describe('files', () => {assert.equal(head.body, '')assert.ok(Number(head.headers['content-length']) > 1000)assert.equal(head.headers['content-type'], 'text/javascript; charset=utf-8')+ assert.equal((await v.get('/files.mjs')).headers['content-type'], 'text/javascript; charset=utf-8')})test('3Dmol.js from this package, cached, and nothing else under /vendor/', async () => {@@ -190,7 +192,7 @@ describe('files', () => {assert.equal(json.headers['cache-control'], 'no-store')assert.equal((await v.get('/out/blob.bin')).headers['content-type'], 'application/octet-stream')const download = await v.get('/out/a%22b.sdf?download')- assert.equal(download.headers['content-disposition'], 'attachment; filename="ab.sdf"')+ assert.equal(download.headers['content-disposition'], `attachment; filename="ab.sdf"; filename*=UTF-8''a%22b.sdf`)assert.equal(download.headers['content-type'], 'chemical/x-mdl-sdfile')assert.equal((await v.get('/out')).status, 404)assert.equal((await v.get('/out/missing.sdf')).status, 404)@@ -198,6 +200,32 @@ describe('files', () => {assert.deepEqual([outside.status, JSON.parse(outside.body)], [404, { error: 'not found' }])})+ test('pane URLs load and download exact filenames containing URL punctuation', async () => {+ for (const name of ['candidate #1', 'candidate ?2', 'candidate %3', 'α "lead" & analogue']) {+ const folder = 'out/series #1'+ for (const extension of ['.sdf', '.conformers.sdf', '.svg']) {+ const path = `${folder}/${name}${extension}`+ const content = `${name}${extension}\nexact workspace bytes`+ put(v.ws, path, content)+ const source = workspaceFileUrl(path, { v: 123 })+ const url = new URL(source, `http://127.0.0.1:${v.port}`)+ assert.equal(url.hash, '')+ assert.equal(url.searchParams.get('v'), '123')+ const loaded = await v.get(url.pathname + url.search)+ assert.equal(loaded.status, 200, path)+ assert.equal(loaded.body, content, path)+ const saved = await v.get(workspaceFileUrl(path, { download: 1 }))+ assert.equal(saved.status, 200, path)+ assert.equal(saved.body, content, path)+ assert.match(saved.headers['content-disposition'], /^attachment;/)+ if (name.startsWith('α')) {+ const encodedName = saved.headers['content-disposition'].split("filename*=UTF-8''")[1]+ assert.equal(decodeURIComponent(encodedName), name + extension)+ }+ }+ }+ })+test('a malformed URL is an error answer, not a dead pane', async () => {const bad = await v.get('/%E0%A4%A')assert.equal(bad.status, 500)@@ -228,6 +256,15 @@ describe('/api/mol', () => {before(async () => { v = await viewer() })after(() => v.stop())+ test('MOL exports retain Unicode and quoted molecule names', async () => {+ const name = 'α "lead" #1'+ put(v.ws, `out/${name}.sdf`, 'molecule\nM END\n$$$$\n')+ const mol = await v.get('/api/mol?path=' + encodeURIComponent(`out/${name}.sdf`))+ assert.equal(mol.status, 200)+ assert.equal(mol.body, 'molecule\nM END\n')+ assert.equal(decodeURIComponent(mol.headers['content-disposition'].split("filename*=UTF-8''")[1]), name + '.mol')+ })+test('the first record as a MOL file, named for the molecule', async () => {put(v.ws, 'out/x.conformers.sdf', 'x\n RDKit\n\n 0 0\nM END\n> <energy>\n1\n\n$$$$\nsecond\nM END\n')const mol = await v.get('/api/mol?path=out/x.conformers.sdf')diff --git a/store/agents/rdkit/viewer.mjs b/store/agents/rdkit/viewer.mjsindex 75d05be62..3ccd5daa6 100644--- a/store/agents/rdkit/viewer.mjs+++ b/store/agents/rdkit/viewer.mjs@@ -30,7 +30,7 @@ const TYPES = {'.mol': 'chemical/x-mdl-molfile', '.mol2': 'chemical/x-mol2', '.pdb': 'chemical/x-pdb', '.xyz': 'chemical/x-xyz','.smi': 'text/plain; charset=utf-8', '.md': 'text/markdown; charset=utf-8', '.txt': 'text/plain; charset=utf-8',}-const PANE = { '/app.js': 'app.js', '/app.css': 'app.css', '/torsion-pane.mjs': 'torsion-pane.mjs' }+const PANE = { '/app.js': 'app.js', '/app.css': 'app.css', '/torsion-pane.mjs': 'torsion-pane.mjs', '/files.mjs': 'files.mjs' }const VENDOR = { '3Dmol-min.js': join(here, 'node_modules/3dmol/build/3Dmol-min.js') }const STRUCTURE = new Set(['.sdf', '.mol', '.pdb', '.mol2'])@@ -41,6 +41,13 @@ function safe(rel) {}function stat(full) { try { return statSync(full) } catch { return null } }function readJson(full) { try { return JSON.parse(readFileSync(full, 'utf8')) } catch { return null } }+function attachment(name) {+ const fallback = name.replace(/["\\]/g, '').replace(/[^\x20-\x7e]/g, '_') || 'download'+ const header = `attachment; filename="${fallback}"`+ if (fallback === name) return header+ const encoded = encodeURIComponent(name).replace(/['()*]/g, (c) => '%' + c.charCodeAt(0).toString(16).toUpperCase())+ return `${header}; filename*=UTF-8''${encoded}`+}function send(res, code, body) {res.writeHead(code, { 'content-type': 'application/json', 'cache-control': 'no-store' })res.end(JSON.stringify(body))@@ -63,7 +70,7 @@ function file(req, res, full, { download = false, cache = false } = {}) {const st = full && stat(full)if (!st || !st.isFile()) { send(res, 404, { error: 'not found' }); return }const headers = { 'content-type': TYPES[extname(full).toLowerCase()] ?? 'application/octet-stream', 'cache-control': cache ? 'max-age=3600' : 'no-store' }- if (download) headers['content-disposition'] = `attachment; filename="${basename(full).replace(/"/g, '')}"`+ if (download) headers['content-disposition'] = attachment(basename(full))if (req.method === 'HEAD') { res.writeHead(200, { ...headers, 'content-length': st.size }); res.end(); return }const body = readFileSync(full) // before the head: a file that cannot be read is still answered, with a 500res.writeHead(200, headers); res.end(body)@@ -255,7 +262,7 @@ createServer(async (req, res) => {const full = safe(url.searchParams.get('path'))if (!full || !stat(full)?.isFile()) { send(res, 404, { error: 'not found' }); return }const block = molBlock(readFileSync(full, 'utf8'))- res.writeHead(200, { 'content-type': 'chemical/x-mdl-molfile', 'content-disposition': `attachment; filename="${stemOf(basename(full))}.mol"`, 'cache-control': 'no-store' })+ res.writeHead(200, { 'content-type': 'chemical/x-mdl-molfile', 'content-disposition': attachment(`${stemOf(basename(full))}.mol`), 'cache-control': 'no-store' })res.end(block); return}file(req, res, safe(path), { download: url.searchParams.has('download') })diff --git a/work/playtests/2026-09-22-rdkit.md b/work/playtests/2026-09-22-rdkit.mdnew file mode 100644index 000000000..c1f28bbb2--- /dev/null+++ b/work/playtests/2026-09-22-rdkit.md@@ -0,0 +1,37 @@+# RDKit playtest handoff — 2026-09-22++Branch: `codex/rdkit-user-playtest`. [Draft PR 230](https://github.com/autonomous-ai/openharness/pull/230). No merge. Code fix: `4770d670`; subsequent changes only document the handoff.++## Fixed and verified++Molecule names containing `#`, `?` or `%` broke model, ensemble and thumbnail URLs; Unicode download names could fail while writing the HTTP header. The pane now encodes each filename component and sends safe, UTF-8-aware attachment names.++- In real Chrome with pinned native RDKit output, the old pane displayed “Waiting for … 404” and broken thumbnails. The fixed pane opened `candidate #1`, `candidate ?2`, `candidate %3` and `α lead #4`, including the latter's five-conformer ensemble.+- Clicked the Unicode SDF export; download SHA-256 matched the source: `b805b416f334b96685589e8589377e34edd8b8d91702dfbe12182212fbe68a13`.+- Used the actual bond-scan controls for a 25-pose O3–C4–C5–C6 rigid MMFF94 scan, selected −165° (ΔE 0.29), kept the named study and note, then reloaded and reopened it. The standalone reproducer reported zero energy and coordinate difference.+- `npm test` in `store/agents/rdkit`: 29/29 pass. `harness dsh check store/agents/rdkit`, JavaScript syntax and `git diff --check` pass. All 138 Python baseline checks were covered across the main run and two explicit native-runtime reruns. GitHub `models-and-viewer` passed for the code change.++The browser journey used a separately generated scratch workspace, not an embedded-agent prompt.++## Actual Harness prompt completed; native output interaction pending++Opened Store → RDKit → Try this prompt → Start Harness with the installed review branch. The actual embedded Codex built butane and phenethyl acetate and visibly updated the model. Submitted a follow-up requesting a butyl/methyl/ethyl paraben series with explicit hydrogens and computed-only properties.++Continue in tab **Build conformers and compare**, project `~/harnesses/rdkit-2026-09-22-13-10`. The generated names are `candidate #1`, `candidate ?2` and `lead #4`. Greek alpha did not survive the native input/agent result; Unicode evidence belongs to the browser check above.++Read-only native chemistry checks confirm formulas C11H14O3 / C8H8O3 / C9H10O3, explicit hydrogens and finite coordinates across 23 / 5 / 5 samples. The agent explicitly labels the small analogues' extra samples as potentially symmetry-equivalent, not five unique minima. All 18 pre-series artifact/script hashes remain unchanged.++## Resume++1. Select the prompted paraben series in native Harness; check its model, thumbnails and conformer controls.+2. Scan a flexible lead bond, select and keep a pose with a note, reload and reopen the study. Then ask the embedded agent to continue from that exact saved study while preserving it.+3. Reserve preview/desktop/browser interaction for the tester in any follow-up prompt; the embedded agent should author files and inspect artifacts. Other agents' desktop control caused focus interference during this session.+4. Capture and publish final evidence; keep the native interaction/revision boundary explicit until completed.++Installed package is a self-contained official-repository clone at `4770d670`, not a linked worktree. Reinstall command:++```sh+harness dsh install https://github.com/autonomous-ai/openharness --ref codex/rdkit-user-playtest --path store/agents/rdkit+```++Local evidence: `/private/tmp/openharness-rdkit-user-playtest/.scratch/filename-regression/workspace`. Kept study: `out/torsions/485a194c-1527-4571-a5cf-f8c6b983124d/`, including `study.zip`, `selected.sdf`, `reproduce.py` and `reproduced.json`. Detailed chronology: `.scratch/playtest/journeys.md`. Recovery packages: `/private/tmp/openharness-rdkit-typst-recovery`. Old Chrome screenshots remain in the test session and were not uploaded to the PR. Pause requested by the user before the next native lease; no output-use pass is implied.