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
fix(cli): recognize Hermes when macOS ps prints its launcher with \012
0xdiego25d0b7589259f8
diff --git a/cli/hook/notify.mjs b/cli/hook/notify.mjsindex fee9c9d09..2b441a8ca 100644--- a/cli/hook/notify.mjs+++ b/cli/hook/notify.mjs@@ -468,8 +468,14 @@ function processEntrypoint(args) {* or run it through runpy. Require that executable prefix and actual code, never a script argument* or a quoted mention. argv[0] is authoritative here: macOS can truncate an absolute `comm` path.* Keep the standalone hook's copy in sync. */+/** macOS `ps` prints argv through vis(3): a newline as `\\012`, a backslash as `\\\\`. Read those back+ * so a multi-line `-c` source is the source it runs. Linux `ps` prints argv as it is, without them. */+function unvisArgs(args) {+ return args.replace(/\\([0-7]{3}|\\)/g, (_, code) => code === '\\' ? '\\' : String.fromCharCode(parseInt(code, 8)))+}+function hermesInlineLauncher(row) {- const args = row.args.trim()+ const args = unvisArgs(row.args).trim()if (!/^python(?:\d+(?:\.\d+)*)?$/.test(basename(argvTokens(args)[0] ?? '').toLowerCase())) return falseconst prefix = /^(?:"[^"]+"|'[^']+'|\S+)(?:\s+-(?:I|E|s|S|u|B|O{1,2}|q))*\s+-c\s+/.exec(args)if (!prefix) return falsediff --git a/cli/src/hookNotify.spec.ts b/cli/src/hookNotify.spec.tsindex 50b846a42..97ca9f2fb 100644--- a/cli/src/hookNotify.spec.ts+++ b/cli/src/hookNotify.spec.ts@@ -640,6 +640,9 @@ describe('hook notify terminal scope', () => {"import sys, runpy; sys.path.insert(0, '/opt/custom'); runpy.run_module('hermes_cli.main', run_name='__main__')","import os, re, sys; sys.path.insert(0, '/opt/custom'); import hermes_bootstrap; from hermes_cli.main import main; sys.exit(main())","import os, sys, runpy; os.environ.pop('PYTHONHOME', None); sys.path.insert(0, '/opt/custom'); os.environ['HERMES_HOME'] = os.environ.get('HERMES_HOME') or '/home/demo/.hermes'; import hermes_bootstrap; runpy.run_module('hermes_cli.main', run_name='__main__', alter_sys=True)",+ // 0.21.5's multi-line launcher as macOS `ps` prints it: every newline as the four characters `\012`.+ ["import os, re, sys", "os.environ.pop('PYTHONHOME', None)", "sys.path.insert(0, '/opt/custom')",+ 'import hermes_bootstrap', 'from hermes_cli.main import main', 'sys.exit(main())'].join('\\012') + '\\012',])('offline Hermes discovery follows a managed Python bootstrap: %s', async (source) => {const dir = mkdtempSync(join(tmpdir(), 'adapter-hook-hermes-launcher-'))tmpDirs.push(dir)diff --git a/cli/src/lib/tmux.spec.ts b/cli/src/lib/tmux.spec.tsindex ed0fad3cd..066ccb1d0 100644--- a/cli/src/lib/tmux.spec.ts+++ b/cli/src/lib/tmux.spec.ts@@ -277,6 +277,29 @@ describe('tmux process primitives', () => {expect(engineProcessMatchScore({ executable: comm, args: `${python} -m hermes_cli.main` }, 'hermes')).toBe(2)})+ it('reads Hermes out of its launcher as macOS `ps` really prints it, newlines as \\012', () => {+ // 0.21.5's launcher is a multi-line `-c` script, and macOS `ps` writes argv through vis(3): each+ // newline arrives as the four characters `\012`, a backslash as `\\`. Matching that text as Python+ // found no statement separator after `import os, re, sys`, so a running Hermes scored 0 — its pane+ // was restored as a terminal, and every hook it sent was "not a descendant of that engine process".+ const python = '/Users/demo/.hermes/tools/python-3.14.7+20260901-darwin-arm64/bin/python3'+ const source = [+ 'import os, re, sys',+ "os.environ.pop('PYTHONHOME', None)",+ "os.environ.pop('PYTHONPATH', None)",+ "sys.path.insert(0, '/Users/demo/.hermes/hermes-agent')",+ "if sys.argv[1:2] == ['--print-runtime-command']: sys.dont_write_bytecode = True",+ 'from hermes_constants import get_default_hermes_root',+ "os.environ['HERMES_HOME'] = os.environ.get('HERMES_HOME') or str(get_default_hermes_root())",+ 'import hermes_bootstrap',+ "sys.exit('a path with a \\\\ in it') if False else None",+ 'from hermes_cli.main import main',+ 'sys.exit(main())',+ ].join('\\012') + '\\012'+ expect(engineProcessMatchScore({ executable: '/Users/demo', args: `${python} -I -c ${source}` }, 'hermes')).toBe(2)+ expect(engineProcessMatchScore({ executable: '/Users/demo', args: `${python} -I -c ${source.replace('hermes_cli.main', 'acp_adapter.entry')}` }, 'hermes')).toBe(0)+ })+it('recognizes managed Hermes runpy launchers without relying on their install directory', () => {const bootstrap = "import os, sys, runpy; os.environ.pop('PYTHONHOME', None); os.environ.pop('PYTHONPATH', None); os.environ.pop('VIRTUAL_ENV', None); sys.path.insert(0, '/opt/custom install'); os.environ['HERMES_HOME'] = os.environ.get('HERMES_HOME') or str(__import__('hermes_constants').get_default_hermes_root()); import hermes_bootstrap; runpy.run_module('hermes_cli.main', run_name='__main__', alter_sys=True)"const old = "import sys, runpy; sys.path.insert(0, '/opt/hermes-agent'); runpy.run_module('hermes_cli.main', run_name='__main__')"diff --git a/cli/src/lib/tmux.ts b/cli/src/lib/tmux.tsindex 8e1024980..b06a361a0 100644--- a/cli/src/lib/tmux.ts+++ b/cli/src/lib/tmux.ts@@ -157,8 +157,14 @@ function hasCursorPackageEntrypoint(args: string): boolean {* or run it through runpy. Require that executable prefix and actual code, never a script argument* or a quoted mention. argv[0] is authoritative here: macOS can truncate an absolute `comm` path.* Keep the standalone hook's copy in sync. */+/** macOS `ps` prints argv through vis(3): a newline as `\\012`, a backslash as `\\\\`. Read those back+ * so a multi-line `-c` source is the source it runs. Linux `ps` prints argv as it is, without them. */+function unvisArgs(args: string): string {+ return args.replace(/\\([0-7]{3}|\\)/g, (_, code: string) => code === '\\' ? '\\' : String.fromCharCode(parseInt(code, 8)))+}+function hermesInlineLauncher(row: Pick<ProcessRow, 'args'>): boolean {- const args = row.args.trim()+ const args = unvisArgs(row.args).trim()if (!/^python(?:\d+(?:\.\d+)*)?$/.test(basename(argvPrefix(args)() ?? '').toLowerCase())) return falseconst prefix = /^(?:"[^"]+"|'[^']+'|\S+)(?:\s+-(?:I|E|s|S|u|B|O{1,2}|q))*\s+-c\s+/.exec(args)if (!prefix) return false