Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(wrapper): never check for updates or download on the hook path
AkitaOnRailsd408450d0157
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2b32b824..318fa324 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -33,8 +33,10 @@ and [0.x](docs/changelog/0.x.md).`127.0.0.1` server URL pointed at the container instead of the host server.The wrapper now runs `hook` and `hook-drain` through the samechecksum-verified native host client as `mcp-bridge` and `install-hooks`.- When that client is unavailable, the wrapper reports why on stderr, skips- the event and exits 0, so the agent is never blocked.+ A hook only reuses the installed client, with no update check or download+ on the hook path. When no client is installed yet, the wrapper says to run+ `ai-memory install-hooks` once, skips the event and exits 0, so the agent+ is never blocked.## [2.6.6] - 2026-10-13diff --git a/bin/ai-memory b/bin/ai-memoryindex 0298e425..03568e85 100755--- a/bin/ai-memory+++ b/bin/ai-memory@@ -474,7 +474,13 @@ cmd_upgrade() {# Managed launch/discovery commands must execute on the host: checkouts, harnesses,# and native transcript stores are host resources, not contents of the helper# container. Keep a checksum-verified release client under NATIVE_RUNNER_DIR.+# Print the native host client's path. `native_host_binary cached` (the hook+# path) only reuses an installed client: no daily update check and no download,+# since either can take seconds or hang on a bad network, and a hook must stay+# within its time bound. install-hooks, mcp-bridge and run install and refresh+# the client, so a wired setup always has one cached.native_host_binary() {+ local mode="${1:-}"if [ -n "${AI_MEMORY_NATIVE_BIN:-}" ]; then[ -x "${AI_MEMORY_NATIVE_BIN}" ] || {echo "ai-memory: AI_MEMORY_NATIVE_BIN is not executable: ${AI_MEMORY_NATIVE_BIN}" >&2@@ -512,6 +518,14 @@ native_host_binary() {binary="${native_dir}/ai-memory"archive="${native_dir}/${artifact}.tar.gz"check_file="${native_dir}/last-check"+ if [ "${mode}" = "cached" ]; then+ [ -x "${binary}" ] || {+ echo "ai-memory: the native host client is not installed yet; run \`ai-memory install-hooks\` once to install it" >&2+ return 1+ }+ printf '%s\n' "${binary}"+ return 0+ fimkdir -p "${native_dir}"need_refresh=0@@ -609,11 +623,12 @@ case "${1:-}" in# default hook URL is the host's loopback server, and the cwd, marker# files, capture exclusions and hook spool all live on the host. A helper# container would also cost ~280 ms per event, past the hook time bound.- # Resolve the same native client mcp-bridge uses and never fall back to the- # container. If that client is unavailable, native_host_binary has already- # said why on stderr; drop this one event and exit 0 so the agent is never- # blocked or shown a failing hook.- if NATIVE_HOST_BIN=$(native_host_binary) && [ -x "${NATIVE_HOST_BIN}" ]; then+ # Reuse the native client mcp-bridge installs (cached only: no update check+ # or download on the hook path) and never fall back to the container. If+ # that client is unavailable, native_host_binary has already said why on+ # stderr; drop this one event and exit 0 so the agent is never blocked or+ # shown a failing hook.+ if NATIVE_HOST_BIN=$(native_host_binary cached) && [ -x "${NATIVE_HOST_BIN}" ]; thenexec "${NATIVE_HOST_BIN}" "$@"fiecho "ai-memory: native host client unavailable; lifecycle hook event not captured" >&2diff --git a/docs/install.md b/docs/install.mdindex aa2a8210..0607d231 100644--- a/docs/install.md+++ b/docs/install.md@@ -2721,9 +2721,11 @@ checksum-verified native client underon the host and enforces capture exclusions before spooling. A hook commandthat calls the wrapper (`ai-memory hook --event …`) therefore runs natively ina few milliseconds and posts to the host's `127.0.0.1:49374`; it never starts a-container. If the native client is missing and cannot be installed, the wrapper-prints the reason on stderr, drops that one event, and exits 0 so the agent is-not blocked. For local loopback+container. A hook only reuses the installed client: `install-hooks` and+`mcp-bridge` install and refresh it, while the hook path never checks for an+update or downloads. If no client is installed yet, the wrapper says to run+`ai-memory install-hooks` once, drops that one event, and exits 0 so the agent+is not blocked. For local loopbackservers, the wrapper automatically bridgesthat helper back to the host's `127.0.0.1:49374`, so `ai-memory status`,`ai-memory search`, and `ai-memory bootstrap` work with the same defaultdiff --git a/tests/wrapper_upgrade.sh b/tests/wrapper_upgrade.shindex f1e0e18e..305d3a98 100755--- a/tests/wrapper_upgrade.sh+++ b/tests/wrapper_upgrade.sh@@ -348,6 +348,42 @@ printf '{}' | run_hook_case "${HOOK_CASE_DIR}/missing-ai-memory" \assert_contains "${HOOK_CASE_DIR}/missing.err" "AI_MEMORY_NATIVE_BIN is not executable"assert_contains "${HOOK_CASE_DIR}/missing.err" "lifecycle hook event not captured"assert_no_container "hook without a native client"++# On the hook path the wrapper only reuses an installed client: no update check+# and no download, which could take seconds or hang. With nothing installed it+# never runs curl; with a client installed it execs it without asking GitHub.+cat >"${HOOK_CASE_DIR}/path/curl" <<'CURL'+#!/usr/bin/env bash+printf 'curl %s\n' "$*" >>"${AI_MEMORY_DOCKER_TEST_LOG}"+exit 1+CURL+chmod 0755 "${HOOK_CASE_DIR}/path/curl"+run_cached_hook_case() {+ HOME="${HOOK_CASE_DIR}/home" \+ XDG_CACHE_HOME="${HOOK_CASE_DIR}/cache" \+ XDG_DATA_HOME="${HOOK_CASE_DIR}/data" \+ PATH="${HOOK_CASE_DIR}/path:${PATH}" \+ AI_MEMORY_DOCKER="${HOOK_CASE_DIR}/path/docker" \+ AI_MEMORY_WRAPPER_TEST_LOG="${HOOK_CASE_DIR}/native.log" \+ AI_MEMORY_DOCKER_TEST_LOG="${HOOK_CASE_DIR}/docker.log" \+ "${ROOT}/bin/ai-memory" "$@"+}+: >"${HOOK_CASE_DIR}/docker.log"+hook_status=0+printf '{}' | run_cached_hook_case hook --agent claude-code --event session-start \+ 2>"${HOOK_CASE_DIR}/uncached.err" || hook_status=$?+[ "${hook_status}" -eq 0 ] || fail "hook with no installed client exited ${hook_status}, want 0"+assert_contains "${HOOK_CASE_DIR}/uncached.err" "not installed yet"+assert_no_container "hook with no installed client (no curl, no engine)"++mkdir -p "${HOOK_CASE_DIR}/data/ai-memory/native-runner"+cp "${HOOK_NATIVE}" "${HOOK_CASE_DIR}/data/ai-memory/native-runner/ai-memory"+: >"${HOOK_CASE_DIR}/native.log"+: >"${HOOK_CASE_DIR}/docker.log"+printf '{"session_id":"s-2"}' \+ | run_cached_hook_case hook --agent claude-code --event user-prompt-submit+assert_contains "${HOOK_CASE_DIR}/native.log" "argv: hook --agent claude-code --event user-prompt-submit"+assert_no_container "hook with an installed client (no update check)"printf 'wrapper hook native routing checks passed\n'printf 'wrapper upgrade ownership checks passed\n'