Commit Graph

1114 Commits

Author SHA1 Message Date
Alex Newman 4e4ad32f97 MAESTRO: Close PR #922 - async SessionStart hooks would break context injection
SessionStart hooks must run synchronously because the context hook's stdout
is captured and injected as Claude's system-level memory context. The Windows
blocking issue was already resolved by the fail-open approach in PRs #973,
#959, and #964.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:27:06 -05:00
Alex Newman faa1360f33 MAESTRO: Merge PR #964 - add fetch timeouts to Stop hook and health checks
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:25:49 -05:00
Rod Boev 64dc50f3fb Restructure fetchWithTimeout to clear timer on all paths
Replace Promise.race with new Promise wrapper so timeoutId is assigned
as const before fetch starts. Timer is now cleared on both fetch success
and fetch rejection, not just success.
2026-02-05 18:24:20 -05:00
Rod Boev 1ac35b5d56 Clear setTimeout when fetch wins the race
Prevents the timer callback from firing unnecessarily after a
successful fetch response.
2026-02-05 18:24:20 -05:00
Rod Boev 1dd456a6ca Add fetch timeouts to Stop hook and health checks
Replace bare fetch() calls with fetchWithTimeout() using Promise.race
instead of AbortSignal.timeout() which causes libuv assertion crashes
in Bun on Windows.

Applies the already-defined HEALTH_CHECK_TIMEOUT_MS (30s/45s) to
isWorkerHealthy() and getWorkerVersion(), and HOOK_TIMEOUTS.DEFAULT
to the summarize POST. Previously these fetches had no timeout at all,
causing the Stop hook to hang for the full hook timeout (120s) when
the worker was unreachable.

Fixes #963
2026-02-05 18:24:19 -05:00
Alex Newman be01694383 MAESTRO: Merge PR #959 - fail open on /api/context/inject during initialization
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:23:24 -05:00
Rod Boev b8b88d998c fix: fail open on /api/context/inject during initialization
The /api/context/inject endpoint previously blocked for up to 5 minutes
(300s timeout) waiting for initializationComplete, which includes MCP
connection setup. On Windows, the MCP connection can hang indefinitely,
causing the context hook to never return and blocking Claude Code startup.

This change makes the endpoint fail open: if the worker hasn't finished
initializing, return empty context immediately instead of blocking. The
hook completes fast, and context becomes available on subsequent prompts
once initialization finishes in the background.

Closes #958
2026-02-05 18:22:08 -05:00
Alex Newman bf4d9421e0 MAESTRO: Merge PR #973 - hooks fail gracefully instead of blocking prompts
session-init.ts: replaced throws on worker 500/SDK agent failure with
logger.failure() + graceful exit 0. user-message.ts: replaced throw with
graceful return, console.error → process.stderr.write, USER_MESSAGE_ONLY → SUCCESS.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:19:41 -05:00
Tafari Higgs 67f9d631bd Fix hooks to fail gracefully instead of blocking user prompts
Three issues fixed:

1. session-init handler: Worker 500 errors caused `throw`, which
   hook-command.ts caught and exited with code 2 (blocking error).
   This blocked the user's prompt entirely with:
   "Hook error: Error: Session initialization failed: 500"
   Fix: Log the failure and return SUCCESS so the prompt proceeds.

2. user-message handler: Referenced nonexistent constant
   HOOK_EXIT_CODES.USER_MESSAGE_ONLY (undefined). Also used
   console.error() for informational output, which Claude Code
   may flag as an error. Fix: Use process.stderr.write() and
   return HOOK_EXIT_CODES.SUCCESS explicitly.

3. Both handlers threw on HTTP errors from the worker, causing
   exit code 2 (blocking). Memory plugin failures should never
   prevent users from using Claude Code. All worker HTTP failures
   now log and return gracefully.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:18:36 -05:00
Alex Newman 311d62cc02 MAESTRO: Merge PR #960 removing user-message hook from SessionStart to fix startup error
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:16:15 -05:00
Rod Boev 46a75c4d98 Restore USER_MESSAGE_ONLY exit code constant
The user-message handler references HOOK_EXIT_CODES.USER_MESSAGE_ONLY
but the constant was missing from hook-constants.ts, causing it to
return exitCode: undefined. The handler is still registered for Cursor's
afterFileEdit flow.
2026-02-05 18:15:54 -05:00
Rod Boev fececc4e51 fix: remove user-message hook from SessionStart to prevent startup error
The user-message hook exits with code 3 (USER_MESSAGE_ONLY), which Claude
Code interprets as a hook failure, displaying "SessionStart:startup hook
error" on every session start. The context hook already handles injecting
context into the conversation, making the user-message hook redundant.

Removing it eliminates the spurious error message and saves ~60 seconds
of potential timeout on systems where the worker is slow to respond.

Closes #905
2026-02-05 18:15:54 -05:00
Alex Newman d0b4c7ee59 MAESTRO: Add DOMPurify XSS defense-in-depth to TerminalPreview (closes PR #896)
PR #896 identified a valid XSS concern in TerminalPreview.tsx but was
broken (missing DOMPurify import and dependency). The existing
escapeXML:true on AnsiToHtml already mitigates the vector, but
DOMPurify adds defense-in-depth sanitization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:14:46 -05:00
Alex Newman e6af8d207a MAESTRO: Close duplicate CORS PR #926 in favor of merged PR #917
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:11:51 -05:00
Alex Newman 75b9930ee4 MAESTRO: Mark PR #917 CORS restriction as merged in triage document
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:11:12 -05:00
OpenCode User 86b1d7fad9 fix: restrict CORS to localhost origins only
Prevents cross-origin attacks from malicious websites by restricting
CORS to only allow:
- Requests without Origin header (hooks, curl, CLI tools)
- Requests from localhost / 127.0.0.1 origins

Previously, CORS was completely open (cors() without configuration),
allowing any website to access the local API and read session data.
2026-02-05 18:10:50 -05:00
Alex Newman 2aab998b62 MAESTRO: Close duplicate PR #875 (CLAUDE_MEM_DISABLE_SUBDIRECTORY_CLAUDE_MD, keeping #913)
PR #875 used negative logic naming (DISABLE instead of ENABLED), superseded
by PR #913 which uses the established CLAUDE_MEM_FOLDER_CLAUDEMD_ENABLED setting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:09:17 -05:00
Alex Newman 6b22017721 MAESTRO: Close duplicate PR #589 (CLAUDE_MEM_FOLDER_CLAUDEMD_ENABLED, keeping #913)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:08:40 -05:00
Alex Newman 34aef1aa18 MAESTRO: Close duplicate PR #823 (CLAUDE_MEM_FOLDER_CLAUDEMD_ENABLED, keeping #913)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:08:03 -05:00
Alex Newman d00762d1f7 MAESTRO: Close duplicate PR #908 (Windows npm docs note, keeping #919)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:07:27 -05:00
Alex Newman 400f08c20d MAESTRO: Close duplicate PR #905 (user-message hook removal, keeping #960)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:06:54 -05:00
Alex Newman 18c7f1cd76 MAESTRO: Close bot-generated PR #754 (copilot-swe-agent MCP documentation PR)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:06:21 -05:00
Alex Newman 74506dd4e6 MAESTRO: Close suspicious PR #904 (replaces repo URL with external download link)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:05:48 -05:00
Alex Newman 0f72356cb1 MAESTRO: Close junk PR #770 (bot-generated install/build with no source changes)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:05:06 -05:00
Alex Newman 121fb24705 MAESTRO: Close junk PR #546 (accidental main branch push with no clear purpose)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:04:36 -05:00
Alex Newman 867c658f4f MAESTRO: Close stale PR #521 (fresh install timeout fix already shipped in v9.0.16 and v9.0.17)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:04:02 -05:00
Alex Newman 0704355a7f MAESTRO: Close stale PR #700 (Windows Terminal popup fix already shipped in v9.0.6)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:03:29 -05:00
Alex Newman 6930a38997 MAESTRO: Close stale PR #933 (WMIC replacement already fixed in v9.0.2)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:02:58 -05:00
Alex Newman e218dc5947 MAESTRO: Close stale PR #840 (WMIC replacement already fixed in v9.0.2)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:02:26 -05:00
Alex Newman 7e1c13c6c2 MAESTRO: Close stale PR #735 (isolated credentials already fixed in v9.0.15)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:01:54 -05:00
Alex Newman e87701228d MAESTRO: Close stale PR #848 (zombie observer prevention already fixed in v9.0.13)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:01:20 -05:00
Alex Newman d6751e0f07 MAESTRO: Close stale PR #861 (zombie observer prevention already fixed in v9.0.13)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:00:49 -05:00
Alex Newman b04a041c2d MAESTRO: Close stale PR #773 (health check endpoint already fixed in v9.0.16)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 18:00:14 -05:00
Alex Newman 8218fcb17b MAESTRO: Close stale PR #774 (health check endpoint already fixed in v9.0.16)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 17:59:43 -05:00
Alex Newman 86bdb036bd MAESTRO: Close stale PR #820 (health check endpoint already fixed in v9.0.16)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 17:59:10 -05:00
Alex Newman eefc2eaf0f docs: update CHANGELOG.md for v9.0.17
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 15:56:35 -05:00
Alex Newman ebed56674e chore: bump version to 9.0.17
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
v9.0.17
2026-02-05 15:56:04 -05:00
Alex Newman ce4cab0a23 MAESTRO: Mark PR #827 bun-runner merge tasks complete
All tasks completed: rebased onto main, resolved hooks.json conflicts
(preserved Setup hook, applied bun-runner pattern), verified build,
merged to main, and confirmed bun-runner finds Bun correctly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 01:49:43 -05:00
Alex Newman 9913820366 Merge PR #827: fix: use bun-runner to find Bun on fresh install (#818) 2026-02-05 01:48:54 -05:00
bigphoot 640053d727 fix: use bun-runner to find Bun on fresh install (#818)
On fresh installations, smart-install.js installs Bun to ~/.bun/bin/bun
but Bun isn't in PATH until terminal restart. Subsequent hooks fail
because they try to run `bun ...` directly.

This fix introduces bun-runner.js - a Node.js script that finds Bun
in common install locations (not just PATH) and runs commands with it.
All hooks now use `node bun-runner.js ...` instead of `bun ...`.

The bun-runner checks:
- PATH (via which/where)
- ~/.bun/bin/bun (default install location)
- /usr/local/bin/bun
- /opt/homebrew/bin/bun (macOS Homebrew)
- /home/linuxbrew/.linuxbrew/bin/bun (Linuxbrew)
- Windows: %LOCALAPPDATA%\bun or fallback paths

Fixes #818

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 01:47:11 -05:00
Alex Newman aaf00829d3 docs: update CHANGELOG.md for v9.0.16
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 01:44:00 -05:00
Alex Newman 094f5ab1b4 chore: bump version to 9.0.16
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
v9.0.16
2026-02-05 01:43:27 -05:00
Alex Newman a0380fe1f7 MAESTRO: Mark PR #820 manual verification task complete
Health check endpoint fix verified working:
- /api/health responds in ~12ms (well under 15s timeout)
- No timeout errors in worker logs
- Both worker-utils.ts and HealthMonitor.ts use /api/health

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 20:33:30 -05:00
Alex Newman 9864410eb8 MAESTRO: Mark PR #820 test and merge tasks complete
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 20:31:53 -05:00
Alex Newman 450b2135b6 MAESTRO: Mark PR #820 build verification task complete
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 20:30:35 -05:00
Alex Newman a58a22cc6a MAESTRO: Mark PR #820 code review task complete
Reviewed health check endpoint logic in worker-utils.ts and HealthMonitor.ts.
Both correctly use /api/health (liveness) instead of /api/readiness to avoid
15-second hook timeout during MCP initialization.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 20:29:46 -05:00
Alex Newman 0c9b8826c9 MAESTRO: Mark PR #820 rebase task complete
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 20:28:57 -05:00
bigphoot 74f6b75db2 fix: use /api/health instead of /api/readiness for hook health checks
Fixes the "Worker did not become ready within 15 seconds" timeout issue.

Root cause: isWorkerHealthy() and waitForHealth() were checking /api/readiness
which returns 503 until full initialization completes (including MCP connection
which can take 5+ minutes). Hooks only have 15 seconds timeout.

Solution: Use /api/health (liveness check) which returns 200 as soon as the
HTTP server is listening. This is sufficient for hook communication since
the worker can accept requests while background initialization continues.

Changes:
- src/shared/worker-utils.ts: Change /api/readiness to /api/health in isWorkerHealthy()
- src/services/infrastructure/HealthMonitor.ts: Change /api/readiness to /api/health in waitForHealth()
- tests/infrastructure/health-monitor.test.ts: Update test to expect /api/health

Fixes #811, #772, #729

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 20:28:38 -05:00
Alex Newman b8821f5ea3 docs: update CHANGELOG.md for v9.0.15 2026-02-04 20:21:31 -05:00
Alex Newman 8f1a260d96 chore: bump version to 9.0.15
Includes PR #745 isolated credentials fix - prevents API key hijacking
from random project .env files by using centralized credentials from
~/.claude-mem/.env

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
v9.0.15
2026-02-04 20:21:01 -05:00