Files
humanlayer/hld
Sundeep Malladi ad48d78d5d Automate Brew Cask Nightly Releases with Side-by-Side Support (#404)
* Phase 1: Build-Time Version Injection in Daemon

- Create internal/version package for build-time version management
- Update RPC server to use version.GetVersion() instead of hardcoded constant
- Update HTTP API handlers to use version package
- Configure workflow to inject version during build with -ldflags
- Update tests to use version package

This allows nightly builds to report version as "0.1.0-YYYYMMDD-nightly"
while dev builds show "0.1.0".

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Phase 2: Dynamic Tauri App Configuration

- Create nightly Tauri config with distinct productName and identifier
- Update workflow to use nightly config for scheduled builds
- Nightly builds will create CodeLayer-Nightly.app with separate identifier

This enables side-by-side installation of stable and nightly builds.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add pre-generated nightly icons with color rotation

* Phase 3: Update workflow to use nightly icons for scheduled builds

* Phase 4: Configure Daemon Paths and Ports via Build Flags

Configure the nightly daemon to use different default paths and ports by injecting them at build time using ldflags.

Changes:
- Make DefaultDatabasePath, DefaultSocketPath, and DefaultHTTPPort injectable via ldflags in hld/config/config.go
- Add setDefaults() function to handle string-to-int conversion for HTTP port
- Update release workflow to inject nightly configuration for scheduled builds:
  - Database: ~/.humanlayer/daemon-nightly.db
  - Socket: ~/.humanlayer/daemon-nightly.sock
  - HTTP Port: 7778
- Regular builds continue to use standard defaults

This allows nightly and stable daemons to run side-by-side without conflicts.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Phase 5: Update Homebrew Cask for Side-by-Side Support

- Add automated nightly cask updates to release workflow
  - Calculate SHA256 and construct release URLs
  - Checkout homebrew tap repository
  - Generate codelayer-nightly.rb with proper configuration
  - Commit and push updates automatically
- Update nightly cask to support side-by-side installation
  - Renamed binaries with -nightly suffix
  - Uses nightly-specific data paths
  - No conflicts declared with stable cask
- Add TODO for future stable release automation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add test_nightly mode to workflow for testing nightly build behavior

* Fix nightly icons: Convert 32x32.png and Square30x30Logo.png to RGBA format

* Use HUMANLAYER_HOMEBREW_CASK_WRITE_GITHUB_PAT for homebrew tap authentication

* change test_nightly to release_nightly

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-05 14:08:29 -05:00
..
2025-06-13 10:39:33 -07:00

HumanLayer Daemon (hld)

Overview

The HumanLayer Daemon (hld) provides a REST API and JSON-RPC interface for managing Claude Code sessions, approvals, and real-time event streaming.

Configuration

The daemon supports the following environment variables:

  • HUMANLAYER_DAEMON_HTTP_PORT: HTTP server port (default: 7777, set to 0 to disable)
  • HUMANLAYER_DAEMON_HTTP_HOST: HTTP server host (default: 127.0.0.1)

Disabling HTTP Server

To disable the HTTP server (for example, if you only want to use Unix sockets):

export HUMANLAYER_DAEMON_HTTP_PORT=0
hld start

End-to-End Testing

The HLD includes comprehensive e2e tests for the REST API:

# Run all e2e tests
make e2e-test

# Run with verbose output for debugging
make e2e-test-verbose

# Run with manual approval interaction
make e2e-test-manual

# Keep test artifacts for debugging
KEEP_TEST_ARTIFACTS=true make e2e-test

The e2e test suite:

  • Tests all 16 REST API endpoints
  • Validates SSE event streams
  • Exercises approval workflows (deny → retry → approve)
  • Tests session lifecycle operations
  • Verifies error handling
  • Runs in isolation with its own daemon instance

Test Structure

The e2e tests are located in hld/e2e/ and consist of:

  • test-rest-api.ts - Main test script with 6 test phases
  • test-utils.ts - Utilities for test environment setup and assertions
  • package.json - Test dependencies

Known Issues

During e2e test development, we discovered some potential upstream bugs:

  1. The list sessions API defaults to leafOnly which filters out parent sessions
  2. Error handling returns 500 instead of 404 for non-existent sessions
  3. Error handling for invalid requests might not be returning proper 400 errors

These issues are documented in the test code with TODO comments.