service_shrimp.nu — hero_shrimp lifecycle module #155
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_skills#155
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add
service_shrimp.nuper the tracker in #75. Module exposesinstall | start [--reset] | stop | statusfor thehero_shrimpstack.Scope
tools/modules/services/service_shrimp.nunu_serviceandnu_service_useskills.service_codescalers.nu— user-level Rust multi-binary that selfstarts via hero_proc; same shape as the hero_shrimp manager.hero_shrimp.Service-specific notes
cargo build --release.~/hero/bin/:hero_shrimp,hero_shrimp_server,hero_shrimp_cli,hero_shrimp_ui(per the repo'sbuildenv.sh::BINARIES).hero_shrimpis the lifecycle manager — it registers and startshero_shrimp_server/hero_shrimp_uivia thehero_proc_service_selfstartpattern.--root.~/hero/var/sockets/hero_shrimp/(rpc.sock,admin.sock,ui.sock) — already canonical.$SHRIMP_DATA_DIR(default~/hero/var/data/hero_shrimp/).$SHRIMP_HOME/secrets.env:OPENROUTER_API_KEYSis the bundled default;OPENAI_API_KEYS,ANTHROPIC_API_KEYS,GROQ_API_KEYS,SAMBANOVA_API_KEYSare also honoured. Daemon boots without one but the first chat fails with "no providers configured".shrimp.yml(channels, models, backends) — auto-discovered, with a compiled-in default. The nu module shouldn't generate this — let users opt in.hero_shrimp/deploy/shrimp-daemon.serviceshows the lifecycle shape to mirror.Acceptance criteria
use services/mod.nu *makesservice_shrimpavailable.service_shrimp installclones the repo, runs the appropriate build, and copies binaries to~/hero/bin/.service_shrimp start [--reset]registers with hero_proc and becomes healthy.service_shrimp statusreports the state.service_shrimp stopcleanly unregisters.startoutput prints sockets / UI URL / a short test plan, per thenu_service_useskill.References
nu_service,nu_service_usehero_proc_service_selfstartservice_shrimp.nu — hero_shrimp (Bun/TS runtime) lifecycle moduleto service_shrimp.nu — hero_shrimp lifecycle moduleImplementation Spec for Issue #155
Objective
Add a new Nushell lifecycle module
service_shrimp.nutotools/modules/services/so the Hero shell exposesservice_shrimp install | start [--reset] | stop | statusfor thehero_shrimpstack. The module follows the canonicalservice_codescalers.nushape (Rust workspace, multi-binary, registered withhero_procas a single service whose CLI binaryhero_shrimpself-registershero_shrimp_serverandhero_shrimp_uiactions). The module must NOT support--root(per the issue: hero_shrimp is user-level only, no privileged ports), must NOT generateshrimp.yml(auto-discovered, has compiled-in default), and must forward LLM provider keys from the invoking shell into the action env so the daemon and any chat call have credentials at hand. Once registered, the module exits with a printed summary block (sockets, UI URL via hero_router, log tail commands) so a downstream agent can drive it pernu_service_use.Requirements
tools/modules/services/service_shrimp.nu, exportinginstall,start,stop,status.installcloneslhumina_code/hero_shrimp, runscargo buildfor the four named binaries, and copies them to~/hero/bin/.start [--reset] [--update]is idempotent: ensures binaries, drops any prior registration, registers two actions (hero_shrimp_server,hero_shrimp_ui) and thehero_shrimpservice with hero_proc, then starts.startprints a summary with the rpc/admin/ui sockets, the hero_router URL, model-key status, and a short test plan (proc service status,proc logs tail).stopcleanly drops the service and both actions.statusprints the hero_proc service record.service_codescalers.nuby removing--rootplumbing and the multi-instance machinery — hero_shrimp is single-instance, user-level.OPENROUTER_API_KEYS,OPENAI_API_KEYS,ANTHROPIC_API_KEYS,GROQ_API_KEYS,SAMBANOVA_API_KEYS,SHRIMP_HOME,SHRIMP_DATA_DIRfrom invoking env into the server action env when set.svx_check_api_keysfromservice_aibroker.nu.export use service_shrimp.nutotools/modules/services/mod.nu.Files to Modify/Create
tools/modules/services/service_shrimp.nu— NEW. The lifecycle module. Copy ofservice_codescalers.nu, edited per steps below.tools/modules/services/mod.nu— MODIFIED. Add theexport use service_shrimp.nuline.Implementation Plan
Step 1: Create the module file as a stripped-down copy of service_codescalers.nu
Files:
tools/modules/services/service_shrimp.nuservice_codescalers.nu.hero_codescalers→hero_shrimp,service_codescalers→service_shrimp.HERO_CODESCALERS_DATA_DIR/HERO_CODESCALERS_SOCK_NAME. hero_shrimp usesSHRIMP_DATA_DIRand the canonical socket dir$HERO_SOCKET_DIR/hero_shrimp/already.SVX_SERVICE_NAME = "hero_shrimp"SVX_FORGE_LOC = "lhumina_code/hero_shrimp"SVX_BINARIES = ["hero_shrimp" "hero_shrimp_server" "hero_shrimp_cli" "hero_shrimp_ui"]SVX_ACTIONS = ["hero_shrimp_server" "hero_shrimp_ui"](CLI andhero_shrimp_cliship but are not actions).SVX_DESCRIPTION = "Hero Shrimp — LLM agent runtime with admin UI".hero_shrimp: role, three sockets, SQLite data dir, LLM-key precondition, note that--rootis intentionally absent.Dependencies: none
Step 2: Strip multi-instance and --root machinery
Files:
tools/modules/services/service_shrimp.nusvx_svc_name,svx_sock_dir,svx_server_action_name,svx_ui_action_name,svx_actions,svx_data_dir).root: bool, instance: intparams.--root(-r)and--instancefrom every public command (install,start,stop,status). Do NOT include codescalers'resetsubcommand — out of scope.falseeverywhere$rootwas passed inlib.nucalls (svc_bin,svc_sock_base,svc_install,svc_drop_registration,svc_require_binary,svc_stop_service,svc_service_status,svc_start_preflight,proc action set --root=false,proc service set --root=false,proc service start --root=false).if not $root { error make ... }block and anysvc_require_sudofromstart.Dependencies: Step 1
Step 3: Wire the LLM-provider key preflight + env forwarding
Files:
tools/modules/services/service_shrimp.nusvx_check_api_keysfromservice_aibroker.nu:svx_server_action, build env from{RUST_LOG: "info,hero_shrimp_server=info"}and conditionally insert any ofSVX_PROVIDER_KEYSplusSHRIMP_HOMEandSHRIMP_DATA_DIRthat are set. Usemut envs+for var in [...]pattern:is_process: true,svc_server_timingspread,kill_other.socket = [rpc.sock, admin.sock], singlehealth_checksentry againstrpc.sockwithsvc_server_health_policy.{RUST_LOG: "info"},kill_other.socket = [ui.sock], health check onui.sockwithsvc_ui_health_policy.svx_check_provider_keysinstartimmediately aftersvc_start_preflightreturns.Dependencies: Step 2
Step 4: Rewrite the start summary block
Files:
tools/modules/services/service_shrimp.nurpc sock: $sock_base/hero_shrimp/rpc.sockadmin sock: $sock_base/hero_shrimp/admin.sockui sock: $sock_base/hero_shrimp/ui.sockui url: http://<host>:9988/hero_shrimp/ui/ (via hero_router)data dir: $SHRIMP_DATA_DIR (default ~/hero/var/data/hero_shrimp/)instanceline and theflagvariable.proc logs tail hero_shrimp_server --lines 30startup-log fallback verbatim.proc service status hero_shrimp,proc logs tail hero_shrimp_server,proc logs tail hero_shrimp_ui,proc job list --service hero_shrimp.Dependencies: Step 3
Step 5: Register the module in services/mod.nu
Files:
tools/modules/services/mod.nuexport use service_shrimp.nunext to the other lifecycle exports (append afterservice_claude.nuto follow existing append pattern).Dependencies: Step 1 (file must exist before being exported)
Step 6: Smoke-check the module can be parsed
Files: none modified
use services/mod.nu *andservice_shrimp --helpfrom a Hero shell. Confirm parse.service_shrimp install,service_shrimp start --reset, hit theui urlpernu_service_use.Dependencies: Step 5
Acceptance Criteria
use services/mod.nu *makesservice_shrimpavailable as a subcommand group withinstall,start,stop,status.service_shrimp installcloneslhumina_code/hero_shrimp, builds the four binaries, and copies them to~/hero/bin/.service_shrimp start [--reset]registershero_shrimp_serverandhero_shrimp_uiactions plus thehero_shrimpservice with hero_proc and reaches a healthy state.service_shrimp statusreports state viaproc service status.service_shrimp stopcleanly drops the service and both actions.startoutput prints sockets, hero_router UI URL, and the test-plan command list pernu_service_use.startprints a non-fatal warning.Notes
service_codescalers.nu: four binaries (only two are hero_proc actions), no--root, no--instance, noresetsubcommand. Three server-bound sockets (rpc.sock,admin.sock,ui.sock); UI action ownsui.sock.admin.sockis intentionally not health-checked (no canonical endpoint).OPENROUTER_API_KEYSis plural — daemon expects this exact name).shrimp.yml. Compiled-in default + optional auto-discovery handles channels/models/backends.SHRIMP_DATA_DIRandSHRIMP_HOMEfrom env without injecting defaults — let the daemon fall back.hero_shrimp(orchestrator CLI) andhero_shrimp_cli(operator tool) are inSVX_BINARIESbut NOT inSVX_ACTIONS— same split ashero_codescalersandhero_aibroker_services.--releasehonoured when passed.--updateflag inherited fromservice_codescalers.nu'ssvc_installwrapper — keep it on bothinstallandstart.Smoke test results
use services/mod.nu *)service_shrimp installhelpservice_shrimp starthelpservice_shrimp stophelpservice_shrimp statushelpTotal: 5 / Passed: 5 / Failed: 0
All five checks passed. The module loads cleanly and exposes the required
install | start | stop | statussubcommands.startexposes--reset(-r),--update(-u), and--release;installexposes--update(-u)and--release;stopandstatustake no flags beyond--help. No--rootor--instanceflags are present on any subcommand.Implementation summary
Added
service_shrimp.nutotools/modules/services/and registered it inservices/mod.nu. The module follows the canonical lifecycle shape (matchingservice_codescalers.nuandservice_aibroker.nu) but is single-instance and user-level — no--root, no--instance, noresetsubcommand.Files
tools/modules/services/service_shrimp.nu—install | start [--reset] [--update] [--release] | stop | statusfor the hero_shrimp stack.tools/modules/services/mod.nu— addedexport use service_shrimp.nu.Behaviour
installcloneslhumina_code/hero_shrimp, runscargo build, copies the four binaries (hero_shrimp,hero_shrimp_server,hero_shrimp_cli,hero_shrimp_ui) into~/hero/bin/.startregisters two hero_proc actions (hero_shrimp_server,hero_shrimp_ui) plus thehero_shrimpservice, then starts. Idempotent unless--resetis passed.stopcleanly drops the service and both actions.statusreports state viaproc service status.OPENROUTER_API_KEYS,OPENAI_API_KEYS,ANTHROPIC_API_KEYS,GROQ_API_KEYS,SAMBANOVA_API_KEYS) plusSHRIMP_HOMEandSHRIMP_DATA_DIRare forwarded from the invoking shell into the server action env when set. A non-fatal preflight prints a warning when none are present.startsummary block prints the three sockets (rpc.sock,admin.sock,ui.sock), the hero_router UI URL, the data dir, and a short test plan (proc service status,proc logs tail,proc job list).admin.sockis intentionally not health-checked (no canonical endpoint); server health checksrpc.sock, UI action health checksui.sock.shrimp.ymlis generated — the daemon's compiled-in default plus optional auto-discovery handles config.Test results
Parse-and-export smoke check (5/5 passed):
use services/mod.nu *parsesservice_shrimp installhelpservice_shrimp starthelpservice_shrimp stophelpservice_shrimp statushelpSubcommands expose the expected flags:
starthas--reset(-r),--update(-u),--release;installhas--update(-u),--release;stopandstatustake no flags. No--rootor--instanceanywhere.End-to-end install/start/stop on a target host is left to the operator — it requires the
lhumina_code/hero_shrimpsource to be reachable and a hero_proc daemon running.Pull request opened: #170
This PR implements the changes discussed in this issue.
End-to-end validation on host
Ran the full lifecycle against a live
hero_proc(already supervising 22 services).install
lhumina_code/hero_shrimpto~/hero/code0/hero_shrimp/.cargo build(debug) finished in 1m 12s.~/hero/bin/:hero_shrimp(105 MB),hero_shrimp_server(509 MB),hero_shrimp_cli(59 MB),hero_shrimp_ui(63 MB).start
hero_shrimp_serverandhero_shrimp_uiactions plus thehero_shrimpservice with hero_proc.rpc.sock, UI listening onui.sockand proxying to the server.status
UI reachable end-to-end:
curl --unix-socket .../ui.sock http://localhost/) →200http://localhost:9988/hero_shrimp/ui/) →308redirect (canonical trailing-slash redirect — proxy works)stop
proc service listno longer showshero_shrimp.ui.sockfile remains in~/hero/var/sockets/hero_shrimp/— expected; the UI action'skill_otherclears it on next startup before bind, which is the standard pattern across all sibling lifecycle modules.All four acceptance criteria from the issue pass.