The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(build): win32 get-windows staging must skip the tarball's bundled darwin binding
Brooklyn Nicholson0c2cdccccc80
diff --git a/apps/desktop/scripts/stage-native-deps.mjs b/apps/desktop/scripts/stage-native-deps.mjsindex d56977c90a4..987d37946cd 100644--- a/apps/desktop/scripts/stage-native-deps.mjs+++ b/apps/desktop/scripts/stage-native-deps.mjs@@ -364,7 +364,7 @@ export function stageNodePty({ platform = process.platform, arch = process.arch// behavior).const STAGED_WINDOWS_JS = `// Rewritten by stage-native-deps.mjs: resolves the staged prebuilt binding-// directly instead of through @mapbox/node-pre-gyp (see stageGetWindowsInto).+// directly instead of through the pre-gyp locator (see stageGetWindowsInto).import path from 'node:path';import fs from 'node:fs';import {fileURLToPath} from 'node:url';@@ -424,13 +424,36 @@ function resolveGetWindowsRoot() {* a Windows host — cross-platform packs already can't happen, see* stageNodePtyInto), Linux nothing (it shells out to xprop at runtime).*/+const GET_WINDOWS_VERSION = '9.3.0'+export function stageGetWindowsInto(srcRoot, destRoot, { platform = process.platform } = {}) {+ // The STAGED_WINDOWS_JS rewrite mirrors this exact version's export surface.+ // A version bump must fail the build here until the rewrite is re-verified —+ // otherwise it ships stale and fails soft as a generic "unavailable".+ const srcVersion = JSON.parse(readFileSync(join(srcRoot, 'package.json'), 'utf8')).version+ if (srcVersion !== GET_WINDOWS_VERSION) {+ throw new Error(+ `[stage-native-deps] get-windows is ${srcVersion} but the staged lib/windows.js ` ++ `rewrite was verified against ${GET_WINDOWS_VERSION}. Re-verify the rewrite ` ++ `(STAGED_WINDOWS_JS) against the new version, then update GET_WINDOWS_VERSION.`+ )+ }+rmSync(destRoot, { recursive: true, force: true })mkdirSync(destRoot, { recursive: true })cpSync(join(srcRoot, 'package.json'), join(destRoot, 'package.json'))cpSync(join(srcRoot, 'index.js'), join(destRoot, 'index.js'))- copyGlobByExt(join(srcRoot, 'lib'), join(destRoot, 'lib'), ['.js'])++ // lib/*.js only — NOT copyGlobByExt, which recurses into lib/binding and+ // stages empty dirs for every prebuilt slot (including the darwin one the+ // tarball bundles on all platforms). Bindings are staged explicitly below.+ mkdirSync(join(destRoot, 'lib'), { recursive: true })+ for (const entry of readdirSync(join(srcRoot, 'lib'), { withFileTypes: true })) {+ if (entry.isFile() && entry.name.endsWith('.js')) {+ cpSync(join(srcRoot, 'lib', entry.name), join(destRoot, 'lib', entry.name))+ }+ }writeFileSync(join(destRoot, 'lib', 'windows.js'), STAGED_WINDOWS_JS)@@ -444,10 +467,17 @@ export function stageGetWindowsInto(srcRoot, destRoot, { platform = process.plat}if (platform === 'win32') {+ // The published tarball bundles a darwin binding dir on EVERY platform+ // (its `files` includes lib/), so a Windows host's lib/binding holds both+ // that and the win32 dir node-pre-gyp downloaded. Stage only dirs naming+ // the target platform; the classify gate below still catches a dir that+ // claims win32 but holds a foreign binary.const bindingRoot = join(srcRoot, 'lib', 'binding')const bindingDirs = existsSync(bindingRoot)- ? readdirSync(bindingRoot).filter((dir) =>- existsSync(join(bindingRoot, dir, 'node-get-windows.node'))+ ? readdirSync(bindingRoot).filter(+ (dir) =>+ dir.includes(`-${platform}-`) &&+ existsSync(join(bindingRoot, dir, 'node-get-windows.node'))): []if (bindingDirs.length === 0) {diff --git a/apps/desktop/scripts/stage-native-deps.test.mjs b/apps/desktop/scripts/stage-native-deps.test.mjsindex ec163b29ac6..dfd06bb25c5 100644--- a/apps/desktop/scripts/stage-native-deps.test.mjs+++ b/apps/desktop/scripts/stage-native-deps.test.mjs@@ -6,6 +6,7 @@ import { pathToFileURL } from 'node:url'import { test } from 'vitest'import {+ stageGetWindowsInto,stageNodePtyInto,classifyNativeBinary} from '../scripts/stage-native-deps.mjs'@@ -357,3 +358,117 @@ test('validation rejects a staged binary with the wrong platform magic', () => {fs.rmSync(tmp, { recursive: true, force: true })}})++// ─── stageGetWindowsInto tests ──────────────────────────────────────++/** Create a minimal fake get-windows source tree in a temp dir. */+function makeFakeGetWindows(srcRoot, { version = '9.3.0', bindings = [] } = {}) {+ fs.mkdirSync(join(srcRoot, 'lib'), { recursive: true })+ fs.writeFileSync(join(srcRoot, 'package.json'), JSON.stringify({ name: 'get-windows', version, main: 'index.js' }))+ fs.writeFileSync(join(srcRoot, 'index.js'), 'export {};')+ fs.writeFileSync(join(srcRoot, 'lib', 'windows.js'), '// upstream pre-gyp loader')+ fs.writeFileSync(join(srcRoot, 'main'), '#!/bin/sh\n')++ for (const { dir, platform } of bindings) {+ makeFakeNode(join(srcRoot, 'lib', 'binding', dir, 'node-get-windows.node'), platform)+ }+}++test('win32 staging skips the darwin binding the tarball bundles on every platform', () => {+ const tmp = fs.mkdtempSync(join(os.tmpdir(), 'hermes-stage-'))+ try {+ const srcRoot = join(tmp, 'get-windows')+ const destRoot = join(tmp, 'dest')++ // The shape every real Windows build host has: the darwin binding+ // committed into the published tarball PLUS the win32 binding+ // node-pre-gyp downloaded at install time.+ makeFakeGetWindows(srcRoot, {+ bindings: [+ { dir: 'napi-9-darwin-unknown-arm64', platform: 'darwin' },+ { dir: 'napi-9-win32-unknown-x64', platform: 'win32' }+ ]+ })++ stageGetWindowsInto(srcRoot, destRoot, { platform: 'win32' })++ assert.ok(existsSync(join(destRoot, 'lib', 'binding', 'napi-9-win32-unknown-x64', 'node-get-windows.node')))+ assert.ok(!existsSync(join(destRoot, 'lib', 'binding', 'napi-9-darwin-unknown-arm64')))+ } finally {+ fs.rmSync(tmp, { recursive: true, force: true })+ }+})++test('win32 staging rejects a binding dir that claims win32 but holds a foreign binary', () => {+ const tmp = fs.mkdtempSync(join(os.tmpdir(), 'hermes-stage-'))+ try {+ const srcRoot = join(tmp, 'get-windows')+ const destRoot = join(tmp, 'dest')++ makeFakeGetWindows(srcRoot, {+ bindings: [{ dir: 'napi-9-win32-unknown-x64', platform: 'darwin' }]+ })++ assert.throws(+ () => stageGetWindowsInto(srcRoot, destRoot, { platform: 'win32' }),+ /expected win32, got darwin/+ )+ } finally {+ fs.rmSync(tmp, { recursive: true, force: true })+ }+})++test('win32 staging fails when only foreign bindings exist', () => {+ const tmp = fs.mkdtempSync(join(os.tmpdir(), 'hermes-stage-'))+ try {+ const srcRoot = join(tmp, 'get-windows')+ const destRoot = join(tmp, 'dest')++ makeFakeGetWindows(srcRoot, {+ bindings: [{ dir: 'napi-9-darwin-unknown-arm64', platform: 'darwin' }]+ })++ assert.throws(+ () => stageGetWindowsInto(srcRoot, destRoot, { platform: 'win32' }),+ /no win32 prebuilt binding/+ )+ } finally {+ fs.rmSync(tmp, { recursive: true, force: true })+ }+})++test('staging refuses a get-windows version the lib/windows.js rewrite was not verified against', () => {+ const tmp = fs.mkdtempSync(join(os.tmpdir(), 'hermes-stage-'))+ try {+ const srcRoot = join(tmp, 'get-windows')+ const destRoot = join(tmp, 'dest')++ makeFakeGetWindows(srcRoot, { version: '9.4.0' })++ assert.throws(+ () => stageGetWindowsInto(srcRoot, destRoot, { platform: 'darwin' }),+ /verified against 9\.3\.0/+ )+ } finally {+ fs.rmSync(tmp, { recursive: true, force: true })+ }+})++test('darwin staging ships the Swift helper executable and the rewritten windows.js', () => {+ const tmp = fs.mkdtempSync(join(os.tmpdir(), 'hermes-stage-'))+ try {+ const srcRoot = join(tmp, 'get-windows')+ const destRoot = join(tmp, 'dest')++ makeFakeGetWindows(srcRoot)++ stageGetWindowsInto(srcRoot, destRoot, { platform: 'darwin' })++ assert.equal(fs.statSync(join(destRoot, 'main')).mode & 0o777, 0o755)+ const staged = fs.readFileSync(join(destRoot, 'lib', 'windows.js'), 'utf8')+ assert.match(staged, /Rewritten by stage-native-deps\.mjs/)+ assert.ok(!staged.includes('node-pre-gyp'), 'pre-gyp loader must not survive staging')+ } finally {+ fs.rmSync(tmp, { recursive: true, force: true })+ }+})diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event.ts b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event.tsindex 2089766568a..2389b17ca1a 100644--- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event.ts+++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event.ts@@ -1087,12 +1087,17 @@ export function useGatewayEventHandler(deps: GatewayEventDeps) {if (requestId) {const read = window.hermesDesktop?.readWindowBelow- void Promise.resolve(read ? read() : null).then(result => {- void $gateway.get()?.request('window.read.respond', {++ const answer = (result: unknown) =>+ $gateway.get()?.request('window.read.respond', {request_id: requestId,text: result ? JSON.stringify(result) : ''})- })++ // .catch: ipcRenderer.invoke rejects on an older shell without the+ // handler or a main-side throw — without an empty answer the tool+ // would stall its full 30s timeout.+ void Promise.resolve(read ? read() : null).then(answer, () => answer(null))}} else if (event.type === 'agent.terminal.output') {// Live chunk from a background process → its read-only agent terminal tab.diff --git a/tools/read_window_tool.py b/tools/read_window_tool.pyindex 8dc57253942..2db6252b939 100644--- a/tools/read_window_tool.py+++ b/tools/read_window_tool.py@@ -48,8 +48,9 @@ READ_WINDOW_BELOW_SCHEMA = {"Returns JSON: {window: {app, title, bounds{x,y,width,height}, id}, ""frontmost: {app, title}, platform}. `title` may be empty when the OS ""withholds window titles (e.g. macOS without the Screen Recording "- "permission — never prompted for, noted in `note`). Metadata only; "- "this never captures pixels or content of other windows."+ "permission — never prompted for, noted in `note`). Other Hermes "+ "windows are skipped: the nearest non-Hermes window is reported. "+ "Metadata only; this never captures pixels or content of other windows."),"parameters": {"type": "object",diff --git a/website/docs/reference/tools-reference.md b/website/docs/reference/tools-reference.mdindex 8305c552960..c05f93e1934 100644--- a/website/docs/reference/tools-reference.md+++ b/website/docs/reference/tools-reference.md@@ -8,7 +8,7 @@ description: "Authoritative reference for Hermes built-in tools, grouped by toolThis page documents Hermes' built-in tools, grouped by toolset. Availability varies by platform, credentials, and enabled toolsets.-**Quick counts (current registry):** ~82 tools — 10 browser tools (core) + 2 CDP-gated browser tools, 4 file tools, 4 Home Assistant tools, 2 terminal tools (`terminal`, `process`), 6 desktop-GUI tools (`read_terminal`, `close_terminal`, `open_preview`, `read_preview`, `focus_pane`, `react_to_message` — desktop-app sessions only), 2 web tools, 5 Feishu tools, 7 Spotify tools (registered by the bundled `spotify` plugin), 5 Yuanbao tools, 12 kanban tools (registered when the kanban dispatcher spawns the agent), 3 project tools (desktop/GUI sessions), 2 Discord tools, 3 video tools (`video_generate`, `xai_video_edit`, `xai_video_extend`), and a handful of standalone tools (`memory`, `clarify`, `delegate_task`, `execute_code`, `cronjob`, `session_search`, `skill_view`/`skill_manage`/`skills_list`, `text_to_speech`, `image_generate`, `vision_analyze`, `video_analyze`, `todo`, `computer_use`, `x_search`).+**Quick counts (current registry):** ~83 tools — 10 browser tools (core) + 2 CDP-gated browser tools, 4 file tools, 4 Home Assistant tools, 2 terminal tools (`terminal`, `process`), 7 desktop-GUI tools (`read_terminal`, `close_terminal`, `open_preview`, `read_preview`, `read_window_below`, `focus_pane`, `react_to_message` — desktop-app sessions only), 2 web tools, 5 Feishu tools, 7 Spotify tools (registered by the bundled `spotify` plugin), 5 Yuanbao tools, 12 kanban tools (registered when the kanban dispatcher spawns the agent), 3 project tools (desktop/GUI sessions), 2 Discord tools, 3 video tools (`video_generate`, `xai_video_edit`, `xai_video_extend`), and a handful of standalone tools (`memory`, `clarify`, `delegate_task`, `execute_code`, `cronjob`, `session_search`, `skill_view`/`skill_manage`/`skills_list`, `text_to_speech`, `image_generate`, `vision_analyze`, `video_analyze`, `todo`, `computer_use`, `x_search`).:::tip MCP ToolsIn addition to built-in tools, Hermes can load tools dynamically from MCP servers. MCP tools appear with the prefix `mcp__<server>__` (e.g., `mcp__github__create_issue` for the `github` MCP server). See [MCP Integration](/user-guide/features/mcp) for configuration.@@ -184,6 +184,7 @@ messaging, and cron sessions.| `close_terminal` | Close the read-only terminal tab for a background process in the Hermes desktop GUI. Does NOT kill the process — only drops the tab/view; use process(action='kill') to stop it. | — || `open_preview` | Open a web URL, localhost dev-server URL, or file path in the preview pane beside the chat in the Hermes desktop app. | — || `read_preview` | Read what's currently shown in the preview pane of the Hermes desktop GUI — the in-app Browser's page text (URL + title + rendered text, pageable with `start`/`count`), or a file/artifact tab's identity. | — |+| `read_window_below` | Identify the OS window directly underneath the Hermes desktop window — app name, title, bounds (metadata only, never pixels). On macOS, other apps' titles appear only when Screen Recording is already granted; the tool never prompts for it. | — || `focus_pane` | Reveal and focus a pane in the Hermes desktop app (chat, files, terminal, review, sessions). | — || `react_to_message` | React to a message with a single emoji, iMessage-tapback style. Opt-in via Settings → Appearance (`display.message_reactions`). | — |diff --git a/website/docs/reference/toolsets-reference.md b/website/docs/reference/toolsets-reference.mdindex 7d660200526..fc92521ad90 100644--- a/website/docs/reference/toolsets-reference.md+++ b/website/docs/reference/toolsets-reference.md@@ -71,7 +71,7 @@ Or in-session:| `video_gen` | `video_generate`, `xai_video_edit`, `xai_video_extend` | Text-to-video and image-to-video via plugin-registered backends (xAI Grok-Imagine, FAL.ai Veo 3.1 / Pixverse v6 / Kling O3). Pass `image_url` to animate an image; omit it for text-to-video. `xai_video_edit` / `xai_video_extend` are provider-specific edit/extend tools, gated on xAI Imagine credentials. || `kanban` | `kanban_attach`, `kanban_attach_url`, `kanban_attachments`, `kanban_block`, `kanban_comment`, `kanban_complete`, `kanban_create`, `kanban_heartbeat`, `kanban_link`, `kanban_list`, `kanban_show`, `kanban_unblock` | Multi-agent coordination tools. Registered for dispatcher-spawned task workers (`HERMES_KANBAN_TASK`) and for profiles that explicitly list the `kanban` toolset by name (the `all`/`*` wildcard does **not** enable it). Workers mark tasks done, block, heartbeat, comment, and create/link follow-up tasks; orchestrator profiles additionally get board-routing tools like list/unblock. `delegate_task` children are not Kanban run owners: their schema strips/disables this toolset and runtime guards reject direct board mutations, even if parent `HERMES_KANBAN_*` env vars are present. || `memory` | `memory` | Persistent cross-session memory management. |-| `desktop_ui` | `close_terminal`, `focus_pane`, `open_preview`, `react_to_message`, `read_preview`, `read_terminal` | Affordances that act on the Hermes desktop app itself — read/close the embedded terminal pane, open and read the in-app browser, reveal a pane, react to a message. Enabled for sessions whose source is the desktop app, whichever backend it's connected to (local, SSH, URL, or Hermes Cloud). Never present on CLI, TUI, messaging, or cron sessions. |+| `desktop_ui` | `close_terminal`, `focus_pane`, `open_preview`, `react_to_message`, `read_preview`, `read_terminal`, `read_window_below` | Affordances that act on the Hermes desktop app itself — read/close the embedded terminal pane, open and read the in-app browser, identify the OS window behind the app, reveal a pane, react to a message. Enabled for sessions whose source is the desktop app, whichever backend it's connected to (local, SSH, URL, or Hermes Cloud). Never present on CLI, TUI, messaging, or cron sessions. || `project` | `project_create`, `project_list`, `project_switch` | Create and switch desktop [Projects](../user-guide/cli.md) (named, multi-folder workspaces). GUI / desktop sessions only. || `safe` | `image_generate`, `vision_analyze`, `web_extract`, `web_search` (via `includes`) | Read-only research + media generation. No file writes, no terminal, no code execution. || `search` | `web_search` | Web search only (without extract). |