Commit Graph
185 Commits
Author SHA1 Message Date
weishu e53abfb840 refactor: consolidate permission handler auto-approval logic into base class
Extract auto-approval decision resolution and common RPC handler registration into BasePermissionHandler to eliminate duplication across Claude, Codex, and Gemini implementations. Make handlePermissionResponse async throughout the hierarchy to properly support awaitable permission completions.
2026-01-23 16:04:37 +08:00
weishu c78ba1da1a refactor: consolidate hook settings generation into shared common module 2026-01-23 16:04:37 +08:00
weishu 6567f22978 refactor: remove passthrough() from zod schemas and make validation explicit
- 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
2026-01-23 16:04:37 +08:00
weishu 6f8f44a314 refactor: move attachment metadata schema to shared protocol package 2026-01-23 16:04:37 +08:00
weishu 78f56ad0f7 refactor: migrate socket types and payloads to shared protocol package
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.
2026-01-23 16:04:37 +08:00
weishu 9922588c6f refactor: consolidate utility functions into shared package
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.
2026-01-23 16:04:37 +08:00
weishu a41d6aa662 feat: add --model parameter support to command handlers
Pass model selection through command pipeline to enable model switching during runtime

close #83, close #64
2026-01-23 11:55:40 +08:00
weishu e130dfd24b feat: add model selection for AI agents (claude, codex, gemini)
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
2026-01-23 11:55:29 +08:00
weishu 4852362e3c Release version 0.12.0 2026-01-22 20:33:11 +08:00
weishu 442f6765b3 fix: prevent Gemini orphan processes when switching modes
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.
2026-01-22 20:17:26 +08:00
weishu 2c1179baf7 feat: gemini local/remote mode 2026-01-22 17:07:54 +08:00
weishu e36759115c feat: improve ACP stability and UX with initialization retry and error handling
- 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
2026-01-22 11:53:17 +08:00
weishu ca63984f7e Release version 0.11.1 2026-01-21 20:11:06 +08:00
freespace8andGitHub 2cb8727874 feat: expose skills and $ autocomplete (#92) 2026-01-21 16:28:15 +08:00
instartloveandGitHub 8b368024e3 feat(cli): support HAPI_HOSTNAME env to override machine hostname (#94) 2026-01-21 16:05:51 +08:00
NieiRandGitHub 835133519e fix: prevent model parameter from being set to arbitrary strings (#93) 2026-01-21 15:59:38 +08:00
weishu 55dbfa397b Release version 0.11.0 2026-01-19 19:17:26 +08:00
weishu 53fff54c84 Release version 0.10.0 2026-01-19 13:07:25 +08:00
weishu 9e335fa305 refactor: rename configuration variables for clarity
Standardize naming across CLI and server components:
- CLI: serverUrl → apiUrl, HAPI_SERVER_URL → HAPI_API_URL
- Server: webapp* → listen*, miniAppUrl → publicUrl, WEBAPP_* → HAPI_LISTEN_*, WEBAPP_URL → HAPI_PUBLIC_URL
- Rename serverUrlInit.ts → apiUrlInit.ts with updated logic for backward compatibility
- Update all imports, function calls, and documentation accordingly
2026-01-19 12:57:37 +08:00
weishu 0228146b99 refactor: rename daemon to runner throughout codebase 2026-01-19 11:12:48 +08:00
weishu ccdcb3d75d feat: add attachment support for Codex and Gemini agents
close #84
2026-01-18 20:30:09 +08:00
weishu 662ed952a3 Release version 0.9.2 2026-01-18 12:34:18 +08:00
weishu f00c290204 fix: add postinstall script to set bin/hapi.cjs executable permission (#78)
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.
2026-01-18 12:27:43 +08:00
weishu 0d80e9245d Release version 0.9.0 2026-01-17 20:08:07 +08:00
weishu 3f465cd47d fix: escape newlines in shell arguments on Windows
close #70
2026-01-17 19:59:59 +08:00
weishu c44eae0b17 fix: use --add-dir flag for granting Claude read access to uploads 2026-01-17 19:38:12 +08:00
weishu 53e4de6684 feat: add file upload support 2026-01-17 19:38:12 +08:00
weishu f33d142446 fix: send session-alive signal immediately on socket connect to prevent initial offline flicker 2026-01-15 22:21:03 +08:00
weishu f11db23d9e Release version 0.8.2 2026-01-14 12:34:28 +08:00
weishu 860124a772 fix: require runtime assets for server command 2026-01-14 12:22:15 +08:00
weishu 659ccc7023 Release version 0.8.1 2026-01-14 11:58:23 +08:00
weishu f138bbf469 Release version 0.8.0 2026-01-14 10:53:58 +08:00
weishu e0c36b71e6 Remove env-based tunnel toggle 2026-01-13 20:32:47 +08:00
weishu 5defb6dbfc feat: add wireguard relay integration for public server access with End-to-End Encryption
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
2026-01-13 20:18:11 +08:00
weishu 942f98f60a Release version 0.7.3 2026-01-13 12:31:38 +08:00
weishu 75de3cd1cb feat: add session resume capability via 'codex resume' command
close #51
2026-01-13 12:29:30 +08:00
weishu b5e90f1f50 fix: prevent auto-resume of old Codex sessions from before startup
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
2026-01-13 11:59:34 +08:00
weishu 251b04ec2d fix: use message field for Codex permission card subtitle
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.
2026-01-13 11:06:50 +08:00
weishu 41d8844c00 fix: implement permission handler callbacks and add CodexPermission UI support
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.
2026-01-13 11:06:50 +08:00
weishu 9f2da5f8ae fix: suppress git stderr when running in non-git directory 2026-01-12 17:59:52 +08:00
weishu 045379874a Release version 0.7.2 2026-01-10 22:17:47 +08:00
weishu c659446fc1 fix: enable shell option for Windows process spawning in ACP transport
close #49
2026-01-10 21:53:53 +08:00
weishu c13eb5356f Release version 0.7.1 2026-01-08 14:45:45 +08:00
weishu 1665c63d95 fix: add retry logic to daemon machine registration for transient connection errors
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
2026-01-08 11:37:29 +08:00
zrq8andGitHub 2646df346e fix: start codex on Windows by using shell; keep mcp args parseable (#40)
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.
2026-01-08 10:44:01 +08:00
weishu 9dc69d1e80 feat: add serverUrl configuration support with settings.json fallback
Implement serverUrl initialization following the cliApiToken design pattern:
- Environment variable HAPI_SERVER_URL (highest priority, allows temporary override)
- settings.json serverUrl field (user persistent configuration)
- Default value 'http://localhost:3006' (fallback)

Changes:
- Add serverUrl field to Settings interface (persistence.ts)
- Convert serverUrl to private property with getter/setter (configuration.ts)
- Create initializeServerUrl module to load from settings (serverUrlInit.ts)
- Integrate serverUrl initialization in tokenInit flow (tokenInit.ts)
- Skip auto-start when serverUrl is configured in settings (autoStartServer.ts)
2026-01-08 10:37:37 +08:00
weishu 9dd83f4300 Release version 0.7.0 2026-01-07 19:01:01 +08:00
weishu a627b085c8 feat: add --host and --port CLI arguments to hapi server command. fix #37
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
2026-01-07 14:39:54 +08:00
weishu 605d44f3ac chore(codex): log MCP wrapper event types 2026-01-06 18:38:22 +08:00
weishu ff35c52160 Release version 0.6.0 2026-01-05 18:42:37 +08:00