New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

@n-dx/hench

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@n-dx/hench

> **This is an internal package of [`@n-dx/core`](https://www.npmjs.com/package/@n-dx/core).** Install `@n-dx/core` instead — it includes this package and registers all CLI commands.

latest
Source
npmnpm
Version
0.7.1
Version published
Maintainers
2
Created
Source

@n-dx/hench

This is an internal package of @n-dx/core. Install @n-dx/core instead — it includes this package and registers all CLI commands.

Hench

Autonomous AI agent for executing Rex PRD tasks. Picks the next actionable task, builds a brief, runs a Claude tool-use loop, and records results.

Quick Start

hench init .
hench run .

Commands

hench init [dir]

Create .hench/ with default config and runs directory.

hench run [dir]

Execute tasks from the Rex PRD. By default, presents an interactive task picker sorted by priority. Use --auto to skip selection and autoselect the highest-priority task.

hench run .                    # interactive task selection (TTY)
hench run --task=<id> .        # run specific task
hench run --auto .             # autoselect highest-priority task
hench run --iterations=5 .     # run 5 tasks sequentially
hench run --dry-run .          # print brief, no API calls
hench run --max-turns=20 .     # limit turns
hench run --model=<model> .    # override model
hench run --provider=cli .     # use Claude CLI instead of API

Task selection precedence: --task=<id> > interactive picker (TTY) > autoselect. When using --iterations, the first iteration uses the selected task; subsequent iterations autoselect the next task by priority. Iteration stops early on failure or timeout.

The agent loop:

  • Reads the Rex PRD and picks the next actionable task
  • Assembles a task brief with parent chain, siblings, and project context
  • Runs a tool-use loop until the task is complete or turns are exhausted
  • Records the run with full metadata to .hench/runs/

hench status [dir]

Show recent run history.

hench status .
hench status --last=20 .       # show more runs
hench status --format=json .

hench show <run-id> [dir]

Display full details of a specific run including tool calls, token usage, and output.

Configuration

.hench/config.json:

{
  "schema": "hench/v1",
  "provider": "cli",
  "maxTurns": 50,
  "maxTokens": 8192,
  "rexDir": ".rex"
}
FieldDefaultDescription
provider"cli""cli" (Claude CLI) or "api" (Anthropic SDK)
model—Model override (omit to use provider default)
maxTurns50Maximum agent turns per run
maxTokens8192Max tokens per turn
rexDir".rex"Path to Rex directory
apiKeyEnv"ANTHROPIC_API_KEY"Env var for API key (api provider only)

Agent Tools

ToolDescription
read_fileRead file contents
write_fileWrite/create files
list_directoryList files and directories
search_filesRegex search across files
run_commandExecute shell commands
gitRun git operations
rex_update_statusMark task in_progress/completed
rex_append_logLog actions to Rex execution log
rex_add_subtaskBreak down tasks into subtasks

Security

Hench enforces multi-layered guardrails on the autonomous agent. All defaults are restrictive and configurable via .hench/config.json under the guard key.

Filesystem

All file operations (read, write, list, search) pass through guard.checkPath() before any I/O. The validation chain:

  • Null-byte rejection — prevents poison-null-byte path truncation attacks
  • Directory escape detection — path.relative() rejects any resolved path outside the project directory
  • Glob blocklist — configurable patterns for off-limits paths
SettingDefaultDescription
blockedPaths.hench/**, .rex/**, .git/**, node_modules/**Glob patterns the agent cannot read or write
maxFileSize1 MBMaximum file size for read/write operations

Shell execution

SettingDefaultDescription
allowedCommandsnpm, npx, node, git, tsc, vitestExecutable allowlist (base name matched)
allowedGitSubcommandsstatus, add, commit, diff, log, branch, checkout, stash, show, rev-parseGit subcommand allowlist
commandTimeout30sPer-command timeout
spawnTimeout5 minLong-running spawn timeout
maxConcurrentProcesses3Concurrent child process limit

Shell metacharacters (;, &, |, `, $) are rejected before the allowlist is checked. Dangerous patterns (sudo, chmod 777, rm with absolute paths, eval, exec) are blocked even for allowed executables.

Rate limiting

The policy engine enforces sliding-window and cumulative limits:

SettingDefaultDescription
policy.maxCommandsPerMinute60Sliding-window command rate limit
policy.maxWritesPerMinute30Sliding-window file write rate limit
policy.maxTotalBytesWritten0 (unlimited)Cumulative bytes written per run
policy.maxTotalCommands0 (unlimited)Cumulative commands per run

All guard decisions are recorded in an audit log accessible after each run.

Network

The only outbound network access is to the configured LLM API through @n-dx/llm-client. No other HTTP clients or socket connections exist in the agent runtime.

Development

npm run build       # tsc
npm test            # vitest
npm run dev         # tsc --watch

FAQs

Package last updated on 25 Sep 2026

Related posts