Console Registration, Service Execution, and Shell Flow
Explain console registry write timing, how agent runtime executes services, and how agent shell session/env injection works
Console Registration, Service Execution, and Shell Flow
This page covers three things:
- how console agent registration works
- how agent runtime executes services
- how agent shell actually works
1) Console registration logic
Core takeaways
- console registry file is
~/.ship/console/agents.json - registry stores “known agents + last known pid”, not live health probes
- daemon startup must successfully upsert registry, otherwise startup is rolled back
Trigger timing
When running sma agent on (daemon mode):
- verify console is running
- verify project init files (
PROFILE.md/ship.json) - start detached child process
- write
.ship/debug/*(pid/meta/log) - call
upsertConsoleAgentEntryto registry
If step 5 fails, daemon is killed and pid/meta are cleaned up.
Data semantics
Each registry entry includes:
projectRootpidstartedAtupdatedAt
sma console agents / sma console status still perform pid liveness checks per project, and stale entries are cleaned.
2) How agent runtime executes services
Core takeaways
- one agent process binds to one
rootPath - service calls use the current runtime-injected
context/config/model/logger service -> extensionis also in-runtime dispatch by default
Runtime assembly (RuntimeState)
initRuntimeState(cwd) does:
- resolve
rootPathand validate project structure - load config and write runtime base state
- create model (
createModel) - create
ContextManager(session/persistor/dispatcher) - assemble
ServiceRuntime(includinginvokeandextensions.invoke)
So service execution is naturally bound to the current agent context.
Execution path
sma service ... -> daemon API -> service manager:
/api/services/list->listServiceRuntimes/api/services/control->controlServiceRuntime/api/services/command->runServiceCommand
runServiceCommand resolves service/action, executes with runtime context, and returns runtime snapshots.
3) Agent shell mechanism
Core takeaways
- shell is session-based, not single-shot exec
- default workdir is runtime
rootPath - subprocess env includes context/server vars so commands route back to current runtime
How it works
Shell toolset provides:
exec_commandwrite_stdinclose_shell
exec_command creates a shell session; write_stdin appends input and polls output pages; output is buffered and paginated until close.
Env injection
Shell subprocess gets:
SMA_CTX_CONTEXT_IDSMA_CTX_REQUEST_IDSMA_CTX_SERVER_HOSTSMA_CTX_SERVER_PORT
So sma ... calls from shell usually target the current runtime server.
Command bridge
For sma|shipmyagent commands, shell bridge can:
- accumulate output
- parse
__shipprotocol block - inject user messages back into conversation
- suppress raw tool output and return bridge summary
This is the standard loop from shell command back to dialog context.