- Replace .passthrough() with explicit field definitions across all schemas
- Add missing optional fields (homeDir, happyHomeDir, happyLibDir, displayName)
- Refactor RawJSONLinesSchema to use structured base schema for clarity
- Improve schema validation strictness and type safety
- Update Machine interface to reflect explicit fields instead of index signature
Move socket-related type definitions and schemas from cli and server packages
into a shared @hapi/protocol package for centralized type management. This
includes migrating Update types, socket event interfaces (ClientToServerEvents,
ServerToClientEvents), and terminal payload schemas. Add strongly-typed socket
handlers that reference the protocol package instead of duplicating definitions.
Move duplicate isObject, asString, asNumber, and safeStringify functions from multiple modules into a centralized shared/src/utils.ts module and update imports across cli, server, and web packages. This eliminates code duplication and improves maintainability.
Add a new ModelSelector component that allows users to choose specific model variants for different AI agents. This includes:
- ModelSelector UI component with agent-specific model options
- Model parameter propagation through API, RPC, and spawning layers
- Support for auto model selection (default behavior)
- Localization strings for English and Chinese
- Type definitions for model options per agent
Kill entire process tree instead of just the direct child to prevent
orphans when Gemini CLI ignores SIGTERM. Implements killProcessTree that
collects all PIDs synchronously, signals children first, then waits for
termination with auto-escalation to SIGKILL after 2 seconds. Also removes
Node.js signal option from spawn since built-in abort handling doesn't
handle grandchildren.
- AcpStdioTransport: Fix stdout JSON validation to filter non-object JSON (numbers, strings, booleans) that could break protocol
- AcpStdioTransport: Add request timeout with 2-minute default, properly cleared on settle, using unref() for graceful shutdown
- AcpStdioTransport: Add stderr error parsing for rate limit (429), model not found (404), auth errors, quota exceeded
- AcpSdkBackend: Add initialization retry mechanism using withRetry() for initialize and session/new (3 attempts, 1-5s backoff)
- AcpSdkBackend: Add waitForResponseComplete() for safe session swaps and preventing race conditions
- AcpSdkBackend: Add onStderrError() handler and processingMessage getter for error reporting
- AcpSdkBackend: Use Infinity timeout for session/prompt to support long-running tasks
This fixes an issue where npx @twsxtd/hapi fails because npm doesn't create
bin symlinks for packages with optionalDependencies. The postinstall script
ensures bin/hapi.cjs has executable permission.
Integrates tunwg (WireGuard tunnel) to enable optional public access
to the hapi server. Tunnel is disabled by default and enabled via
--relay flag or HAPI_TUNNEL=true environment variable.
Users can now run 'hapi server --relay' and get a direct link like:
https://app.hapi.run/?server=https://xxx.relay.hapi.run&token=xxx
CODEX_SESSION_SCANNER was incorrectly auto-resuming old sessions because
session files persist after Codex exits. Fixed by:
1. Only matching sessions created AFTER hapi startup (reject if
sessionTimestamp < referenceTimestampMs)
2. Snapshot resumeSessionId at startup so scanner callbacks don't
affect codexLocal's launch parameters
3. Updated session timestamp test to verify boundary conditions
Codex elicitation requests from MCP use the 'message' field (from
ElicitRequest schema), not 'command' or 'cwd'. Update the permission
handler to extract and pass this field, and display it as the card
subtitle with fallback to command.
Adds onRequest and onComplete callbacks to CodexPermissionHandler to track
permission request/response lifecycle. Includes helper functions to normalize
command and cwd inputs, and displays permission requests in the web UI.
Add exponential backoff retry mechanism to handle ECONNREFUSED errors when the
server isn't ready yet during daemon startup. This includes:
- New errorUtils module with error classification helpers
- withRetry function in time.ts supporting configurable exponential backoff
- Machine registration retry with sensible defaults (60 attempts, 1-30s delays)
- Error refactoring to consolidate extractErrorInfo utility
close#35
Windows global installs expose codex as codex.cmd; spawning 'codex' without shell hits ENOENT.
Enable shell to align with Claude's Windows behavior and resolve PATH lookup.
Shell spawn makes cmd.exe strip TOML double quotes in -c arrays, so args become a string.
Switch mcp args to TOML literal (single-quoted) arrays to preserve types; update tests.
Add configurable host binding for the Mini App HTTP server through:
- New `webappHost` configuration (defaults to 127.0.0.1 for security)
- CLI arguments `--host` and `--port` with flexible parsing (--host=value or --host value)
- Priority order: CLI args > env vars > settings.json > defaults
- Updated Bun.serve() to bind to the configured hostname
Modified:
- server/src/config/settings.ts
- server/src/config/serverSettings.ts
- server/src/configuration.ts
- server/src/web/server.ts
- server/src/index.ts
- cli/src/commands/server.ts
Extract duplicate MCP bridge initialization code from codexLocalLauncher and
codexRemoteLauncher into a new buildHapiMcpBridge utility. This ensures both
modes use identical server setup logic and provides a single source of truth
for MCP configuration.
Update codexStartConfig to deliver system prompt via developer_instructions
instead of appending to the user message. This ensures consistent behavior
between local and remote modes and properly separates system guidance from
user intent.
Implements MCP server configuration and developer instructions support in
Codex local mode, bringing it to parity with remote mode.
Key additions:
- buildMcpServerConfigArgs() and buildDeveloperInstructionsArg() utilities
to construct -c config arguments for passing MCP servers and instructions
to the Codex CLI at runtime
- TITLE_INSTRUCTION for Codex to call hapi__change_title to update chat
session titles dynamically
- Codex local mode now starts hapi MCP bridge server and passes both MCP
configuration and developer instructions to Claude, enabling full feature
parity with remote mode
Files changed:
- New: codexMcpConfig.ts (utilities), systemPrompt.ts (prompt definition),
codexMcpConfig.test.ts (comprehensive tests)
- Updated: codexLocal.ts (accepts mcpServers, builds config args),
codexLocalLauncher.ts (starts hapi server, passes config),
codexStartConfig.ts (imports TITLE_INSTRUCTION)