feat(honcho): Claude Code memory in luna's Honcho
mars: bearer-gated tailnet door to Honcho on :8099 (Caddy), limited to luna's workspace; Honcho itself stays on loopback with auth off, so Hermes and honcho-console are unchanged. terra: config for the claude-honcho plugin (installed via /plugin) plus a SessionStart hook that adds luna as an observer of each Claude session, so Hermes' directional recall sees what is learned here. HONCHO_* env in settings.json pins the server: the plugin's config migration otherwise drops baseUrl and falls back to Plastic Labs' cloud. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
./hermes-agent.nix
|
./hermes-agent.nix
|
||||||
./honcho.nix # luna's memory server (Postgres + Ollama embeddings)
|
./honcho.nix # luna's memory server (Postgres + Ollama embeddings)
|
||||||
./honcho-console.nix # web console for it, tailnet-only on :8095
|
./honcho-console.nix # web console for it, tailnet-only on :8095
|
||||||
|
./honcho-gate.nix # bearer-gated tailnet door to it for Claude Code, :8099
|
||||||
./livesync-bridge.nix
|
./livesync-bridge.nix
|
||||||
./luna-sites.nix # luna's LAN web apps: http://mars.sol/<name>/
|
./luna-sites.nix # luna's LAN web apps: http://mars.sol/<name>/
|
||||||
./pass-broker-gateway.nix # Telegram approvals for every host's pass-broker, tailnet :8097
|
./pass-broker-gateway.nix # Telegram approvals for every host's pass-broker, tailnet :8097
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
# Tailnet door to luna's Honcho (honcho.nix) for Claude Code on terra
|
||||||
|
# (hosts/terra/claude-honcho.nix). Honcho itself stays on loopback with auth
|
||||||
|
# off, so Hermes and honcho-console need no key; this bearer token is the only
|
||||||
|
# credential, and it reaches luna's workspace only. 8099 stays closed in the
|
||||||
|
# firewall: tailscale0 only, like honcho-console.
|
||||||
|
let
|
||||||
|
port = 8099;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [ ../../services/network/caddy.nix ];
|
||||||
|
|
||||||
|
# Fails closed: an unset token must not turn "Bearer " into the password.
|
||||||
|
services.caddy.virtualHosts.":${toString port}".extraConfig = ''
|
||||||
|
@allowed {
|
||||||
|
expression `{env.HONCHO_GATE_TOKEN} != "" && {http.request.header.Authorization} == "Bearer " + {env.HONCHO_GATE_TOKEN}`
|
||||||
|
path /v3/workspaces /v3/workspaces/luna/*
|
||||||
|
not path /v3/workspaces/luna/webhooks*
|
||||||
|
}
|
||||||
|
# Workspace get-or-create only; listing, keys and other workspaces stay out.
|
||||||
|
@workspaceCreate {
|
||||||
|
path /v3/workspaces
|
||||||
|
not method POST
|
||||||
|
}
|
||||||
|
handle @workspaceCreate {
|
||||||
|
respond 403
|
||||||
|
}
|
||||||
|
handle @allowed {
|
||||||
|
reverse_proxy 127.0.0.1:8000
|
||||||
|
}
|
||||||
|
handle {
|
||||||
|
respond 403
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
|
services.caddy.environmentFile = config.sops.templates."honcho-gate.env".path;
|
||||||
|
|
||||||
|
# Same value in secrets/terra.yaml, where the Claude Code plugin sends it.
|
||||||
|
sops.secrets.honcho_gate_token.restartUnits = [ "caddy.service" ];
|
||||||
|
sops.templates."honcho-gate.env" = {
|
||||||
|
content = "HONCHO_GATE_TOKEN=${config.sops.placeholder.honcho_gate_token}\n";
|
||||||
|
restartUnits = [ "caddy.service" ];
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
# Claude Code's long-term memory in luna's Honcho, through mars' gate
|
||||||
|
# (hosts/mars/honcho-gate.nix). The plugin itself (plastic-labs/claude-honcho)
|
||||||
|
# is installed by hand with /plugin; this wires its config and adds luna as an
|
||||||
|
# observer of every Claude session, which the plugin never does: without it
|
||||||
|
# the deriver writes only darman's self-view, and Hermes (directional) reads
|
||||||
|
# luna's view of darman, so luna would learn nothing from these sessions.
|
||||||
|
let
|
||||||
|
baseUrl = "http://mars.orbit.sol:8099";
|
||||||
|
workspace = "luna";
|
||||||
|
tokenFile = config.sops.secrets.honcho_gate_token.path;
|
||||||
|
|
||||||
|
# Get-or-create, so it doesn't race the plugin's own SessionStart; the
|
||||||
|
# plugin's later get-or-create still adds its repo/host scopes.
|
||||||
|
lunaObserver = pkgs.writeShellApplication {
|
||||||
|
name = "honcho-luna-observer";
|
||||||
|
runtimeInputs = [ pkgs.curl pkgs.jq pkgs.coreutils ];
|
||||||
|
text = ''
|
||||||
|
log="$HOME/.honcho/luna-observer.log"
|
||||||
|
sid=$(jq -r '.session_id // empty')
|
||||||
|
[ -n "$sid" ] || exit 0
|
||||||
|
# Same mapping as the plugin's getSessionName.
|
||||||
|
name=$(printf %s "$sid" | tr '[:upper:]' '[:lower:]' | tr -c 'a-z0-9_-' '-')
|
||||||
|
# Header via stdin: argv is world-readable in /proc.
|
||||||
|
if ! printf 'header = "Authorization: Bearer %s"\n' "$(cat ${tokenFile})" |
|
||||||
|
curl -fsS --max-time 8 -K - -X POST \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{"luna":{"observe_me":false,"observe_others":true}}' \
|
||||||
|
"${baseUrl}/v3/workspaces/${workspace}/sessions/$name/peers" >/dev/null 2>>"$log"; then
|
||||||
|
echo "$(date -Is) $name: adding luna failed" >>"$log"
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# Same value in secrets/mars.yaml (the gate).
|
||||||
|
sops.secrets.honcho_gate_token.owner = "darman";
|
||||||
|
|
||||||
|
home-manager.users.darman = { lib, ... }: {
|
||||||
|
# Both files are also written by Claude Code and the plugin, so only these
|
||||||
|
# keys are asserted; everything else in them stays.
|
||||||
|
home.activation.claudeHoncho = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||||
|
merge() { # file, jq filter, args…
|
||||||
|
f=$1; shift
|
||||||
|
[ -s "$f" ] || echo '{}' > "$f"
|
||||||
|
${pkgs.jq}/bin/jq "$@" "$f" > "$f.new"
|
||||||
|
chmod 600 "$f.new"
|
||||||
|
mv -f "$f.new" "$f"
|
||||||
|
}
|
||||||
|
(
|
||||||
|
umask 077
|
||||||
|
mkdir -p "$HOME/.honcho" "$HOME/.claude"
|
||||||
|
# A missing secret must not fail the whole switch. The block needs its
|
||||||
|
# own schemaVersion: without it the plugin "migrates" it and drops
|
||||||
|
# baseUrl, falling back to Plastic Labs' cloud with our token.
|
||||||
|
[ -r ${tokenFile} ] && merge "$HOME/.honcho/config.json" \
|
||||||
|
--rawfile key ${tokenFile} \
|
||||||
|
'.schemaVersion = 2
|
||||||
|
| .hosts.claude_code = ((.hosts.claude_code // {}) + {
|
||||||
|
schemaVersion: 2, baseUrl: "${baseUrl}", apiKey: ($key | rtrimstr("\n")),
|
||||||
|
workspace: "${workspace}", peerName: "darman", aiPeer: "claude" })'
|
||||||
|
# Env beats the file, so no plugin rewrite of it can reroute to the cloud.
|
||||||
|
merge "$HOME/.claude/settings.json" \
|
||||||
|
--arg cmd ${lunaObserver}/bin/honcho-luna-observer \
|
||||||
|
'.env = ((.env // {}) + {
|
||||||
|
HONCHO_BASE_URL: "${baseUrl}", HONCHO_WORKSPACE: "${workspace}",
|
||||||
|
HONCHO_PEER_NAME: "darman", HONCHO_AI_PEER: "claude" })
|
||||||
|
| .hooks.SessionStart = ([(.hooks.SessionStart // [])[]
|
||||||
|
| select([.hooks[]?.command] | any(contains("honcho-luna-observer")) | not)]
|
||||||
|
+ [{ hooks: [{ type: "command", command: $cmd, timeout: 10 }] }])'
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ in
|
|||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./disk-config.nix
|
./disk-config.nix
|
||||||
./secrets.nix
|
./secrets.nix
|
||||||
|
./claude-honcho.nix # Claude Code memory in luna's Honcho (mars :8099)
|
||||||
../../common.nix
|
../../common.nix
|
||||||
../../profiles/workstation.nix
|
../../profiles/workstation.nix
|
||||||
../../services/desktop/luna-voice.nix
|
../../services/desktop/luna-voice.nix
|
||||||
|
|||||||
+3
-2
@@ -15,6 +15,7 @@ pass_broker_pat: ENC[AES256_GCM,data:9fg2TG4RvmcAbd4xI1lPIRURVTNUrakTYsjfssa/v7s
|
|||||||
pass_broker_telegram_token: ENC[AES256_GCM,data:l50+HIyGDQ5V9S9sD/r0z5lP2krPRV1BhrWHSAK5kQoFceQLV9GRkx5JMICTww==,iv:zuL7nXGFjYmZFVqo1rjkSNFQqE1JOlybNmCBr1rirc0=,tag:ogpFMy8txSyuGfys86k9QA==,type:str]
|
pass_broker_telegram_token: ENC[AES256_GCM,data:l50+HIyGDQ5V9S9sD/r0z5lP2krPRV1BhrWHSAK5kQoFceQLV9GRkx5JMICTww==,iv:zuL7nXGFjYmZFVqo1rjkSNFQqE1JOlybNmCBr1rirc0=,tag:ogpFMy8txSyuGfys86k9QA==,type:str]
|
||||||
darman_telegram_user_id: ENC[AES256_GCM,data:jdi/eFS8ZoQ=,iv:1aFs4vJjdXA2eXKxLJymcRUQtBRFyMVBNXGaTrcToo8=,tag:zpAqSpYdgs02J3WOzJwwNg==,type:str]
|
darman_telegram_user_id: ENC[AES256_GCM,data:jdi/eFS8ZoQ=,iv:1aFs4vJjdXA2eXKxLJymcRUQtBRFyMVBNXGaTrcToo8=,tag:zpAqSpYdgs02J3WOzJwwNg==,type:str]
|
||||||
matrix_access_token: ENC[AES256_GCM,data:P/vKj7WNzZVusTlyeoUknZ5WcbCbhJJV92iSEnmUwAvxntb+AUVXFis=,iv:Pk6cZSqSG7LZ5Hs/Iir9do7SuP+cahnnZsNM9iwxi+g=,tag:6tN7Y/OrHsFUNQ5LlsLqew==,type:str]
|
matrix_access_token: ENC[AES256_GCM,data:P/vKj7WNzZVusTlyeoUknZ5WcbCbhJJV92iSEnmUwAvxntb+AUVXFis=,iv:Pk6cZSqSG7LZ5Hs/Iir9do7SuP+cahnnZsNM9iwxi+g=,tag:6tN7Y/OrHsFUNQ5LlsLqew==,type:str]
|
||||||
|
honcho_gate_token: ENC[AES256_GCM,data:nyTUDJr2+MK75QBMInMbOkRAWO1tL7MTwgC3bFLQXLbOZcmmQy30y9Vd8DyMsS6g/+0t0B9z8gvTGwufkAAELA==,iv:cQANdsBMRW6FJpqHPIRXi3Djpn3/KmoRQyVS2MQGoyM=,tag:HZ3G+saeTpmvNVGee31BZA==,type:str]
|
||||||
sops:
|
sops:
|
||||||
age:
|
age:
|
||||||
- enc: |
|
- enc: |
|
||||||
@@ -35,7 +36,7 @@ sops:
|
|||||||
oyJ7PS3lW+PxH5AZkeeU7gXO/pz2oDku0aDOds7kaD3n0+qSWicQ+Q==
|
oyJ7PS3lW+PxH5AZkeeU7gXO/pz2oDku0aDOds7kaD3n0+qSWicQ+Q==
|
||||||
-----END AGE ENCRYPTED FILE-----
|
-----END AGE ENCRYPTED FILE-----
|
||||||
recipient: age1eapjg6tdrr0fuvmgs3q3nlvnjkaxez298qynqqqxt0lpcv0lrsyq7ayxjk
|
recipient: age1eapjg6tdrr0fuvmgs3q3nlvnjkaxez298qynqqqxt0lpcv0lrsyq7ayxjk
|
||||||
lastmodified: "2026-10-21T12:19:12Z"
|
lastmodified: "2026-11-16T04:50:04Z"
|
||||||
mac: ENC[AES256_GCM,data:+JJLcpHWlQqZAfXGfSzBTxVCV2/+ADqR5v7HtwWkNPbIL5wSH5Hn40rvhuhFfhZq7rBaQQI0orri/9xbWpS3o5qC3Cfw5BYNedbs+HoG/gRO6TdY8iEwNhmioIFr13SMfJh4mji9/cA9jdliPSpeXXasmMghAT3djIjvhAZNeFg=,iv:oDszif8PrMz0bbR4Cg0Em/9pQN6zl/YGxWINVoIutg4=,tag:O7vmpT06EtQszVy9kWfeIw==,type:str]
|
mac: ENC[AES256_GCM,data:a/eVtueQofcPV1Eb58+gGGuEtmUzeHtHY4HDCEIEWv0q3vaG0+jC5kCU8W73yMeCpnDAVQBetXNI+Pt18LUz8oXL5WI4B065yEMTDZ64X/lMOn7jmuFrZRb0ji5GvGqe9IOMcK2VQBbzRx2y6Hb5cf3Tzb7Q5ErAWxhKqiSyGgM=,iv:FZ3z5Ga0LGf5GvUuIE84hHRXrs9KV1/7O+wVVJor7jE=,tag:8H+iUI1eBD3IYzoJiHg08w==,type:str]
|
||||||
unencrypted_suffix: _unencrypted
|
unencrypted_suffix: _unencrypted
|
||||||
version: 3.13.3
|
version: 3.13.3
|
||||||
|
|||||||
+3
-2
@@ -6,6 +6,7 @@ elevenlabs_api_key: ENC[AES256_GCM,data:4IBKKMxor1sJ1skh1pgLrQnNX31cgQFiy89O1TZn
|
|||||||
pass_broker_pat: ENC[AES256_GCM,data:A4NrFBQIL6waKSaVB4EZnxLp4RWkm1hGZcHGBd5qSh+BPv7gvj+g9vjFhkCwXgAinBekxo0GOhf/Ip4zK+KWZwNTzF8MXjAkSARnFQgXiFAncaEVzXGho1TVYvYAN1PRQxEu79bYS0IG5+ZOw0VVpjw=,iv:vLiojJJrl6yC83stsNoXLZX762z8nM0Jx164lx7XVjs=,tag:K8zFZ5bb8QeADmsLf0o6pw==,type:str]
|
pass_broker_pat: ENC[AES256_GCM,data:A4NrFBQIL6waKSaVB4EZnxLp4RWkm1hGZcHGBd5qSh+BPv7gvj+g9vjFhkCwXgAinBekxo0GOhf/Ip4zK+KWZwNTzF8MXjAkSARnFQgXiFAncaEVzXGho1TVYvYAN1PRQxEu79bYS0IG5+ZOw0VVpjw=,iv:vLiojJJrl6yC83stsNoXLZX762z8nM0Jx164lx7XVjs=,tag:K8zFZ5bb8QeADmsLf0o6pw==,type:str]
|
||||||
pass_broker_gateway_token: ENC[AES256_GCM,data:OSM2iCIi+GymGzIS3T2vN06H0q8GvSuQ2RWkatSfIyIrQpVKaeU/GUEkD6S4okedKBtXXYN9cnc2Ro3H7d+S0g==,iv:9hgYqlTonbDlAu8WpjUUTqhqbpfAxb1ZAuQUUac2QC4=,tag:skIctluEWh4hMnmR4Y7g6w==,type:str]
|
pass_broker_gateway_token: ENC[AES256_GCM,data:OSM2iCIi+GymGzIS3T2vN06H0q8GvSuQ2RWkatSfIyIrQpVKaeU/GUEkD6S4okedKBtXXYN9cnc2Ro3H7d+S0g==,iv:9hgYqlTonbDlAu8WpjUUTqhqbpfAxb1ZAuQUUac2QC4=,tag:skIctluEWh4hMnmR4Y7g6w==,type:str]
|
||||||
protonvpn_wg_private_key: ENC[AES256_GCM,data:aTfP7xyStfy/kmLuJA8L32J8uJ5Y0eA5c8XySiiozFLau+PxU7t8sSremQ8=,iv:pbkMKmPhRmTat5swTsjf29ZOEHSTjWvUXMsdbFgF3PY=,tag:OAyEkFthYwv6lkr6M/EWkA==,type:str]
|
protonvpn_wg_private_key: ENC[AES256_GCM,data:aTfP7xyStfy/kmLuJA8L32J8uJ5Y0eA5c8XySiiozFLau+PxU7t8sSremQ8=,iv:pbkMKmPhRmTat5swTsjf29ZOEHSTjWvUXMsdbFgF3PY=,tag:OAyEkFthYwv6lkr6M/EWkA==,type:str]
|
||||||
|
honcho_gate_token: ENC[AES256_GCM,data:rHPBC+UujQFiPAFfvNd9Zf9CmkmR1IgkuelKgfEFwPxHEWRZiiiCgUrPiFZbY/teqJ6F3j4RhFpgVNKRv8UX4g==,iv:rTI7shOVdJ0VrGzlhK5w1dnR6Q0ZcGMLOhT2ZFqb20E=,tag:UViCmLukzNFDQ5QHPp9W5Q==,type:str]
|
||||||
sops:
|
sops:
|
||||||
age:
|
age:
|
||||||
- enc: |
|
- enc: |
|
||||||
@@ -26,7 +27,7 @@ sops:
|
|||||||
sHjKfw8VrrmAR4pQf1dsY+wcyh4FsZxhP3Q+QIVq3eCIXS9PeJkGAg==
|
sHjKfw8VrrmAR4pQf1dsY+wcyh4FsZxhP3Q+QIVq3eCIXS9PeJkGAg==
|
||||||
-----END AGE ENCRYPTED FILE-----
|
-----END AGE ENCRYPTED FILE-----
|
||||||
recipient: age1rfcmu6zh40v4260l9hnf8ajs9vly0s06rx3ey76eu78dp9t7getqyhmkut
|
recipient: age1rfcmu6zh40v4260l9hnf8ajs9vly0s06rx3ey76eu78dp9t7getqyhmkut
|
||||||
lastmodified: "2026-10-21T08:28:58Z"
|
lastmodified: "2026-11-16T04:50:04Z"
|
||||||
mac: ENC[AES256_GCM,data:8p2f7x4YqO7C1p7fDmiAaiQdSdAsqL8nYUshYC1e6pj7YyZnh2mUZU2e1ZcGQbs+t0OvssRD9dyY0Np1D9GTjVfiPDYp1PIZGwoZCeH7knc2d66dUYWn92P73pOPajgYzaQqzBUMCXntt9y6eeflHcn5XjV75baRAbInuU/Y7Bc=,iv:8MfH8rQqgFl2acS0Fjs+XjNwNJHv+Kuc8uUQRbwiiF8=,tag:HcccDy0k0jTiMgmUV4M6iw==,type:str]
|
mac: ENC[AES256_GCM,data:nfT0BFIO+LcJP+GHYYeUjLsoTJIwNgtk17HTGxtswyasz2zGEKfKvTfuPkkVt4iHwzF1xYxWZXWpreACnB7pBQfFYJROkHF3YzfS/0VmpcLMyPMU1NwQKVnpMtO80fPstpV+Att1kY5Fj3VBgIOTrbI/9+/AtYVinU9ntppKgrQ=,iv:hs3REfnm67brJ4vvWYOf2BgVAuZOruaTEDCH2rBojOQ=,tag:RfsoTwBhPjKR1ddTIrq0vg==,type:str]
|
||||||
unencrypted_suffix: _unencrypted
|
unencrypted_suffix: _unencrypted
|
||||||
version: 3.13.3
|
version: 3.13.3
|
||||||
|
|||||||
Reference in New Issue
Block a user