Expand description
Adoption of a provider session the node did not spawn: the node gives it a per-session m4a
account and puts the node’s own m4a MCP server (m4a-agent mcp, stdio) in the provider’s
config, removing a stale standalone mailbox MCP entry (a loopback HTTP url) with a backup.
POST /m4a/adopt?provider=<id>&session=<provider session id>[&stale=<entry name>] (owner
token, same policy as /m4a/attach):
- provisions the account under the same key
/m4a/attachuses for that session, so the MCP server’s own attach later gets the same nick; - records a pending adoption, so an attach whose caller carries no session id (an MCP child of a shared provider backend) is bound to this session and not to the backend’s pid;
- for grok: rewrites
<grok home>/config.toml(backup first) and returns themcpServersentry an ACPsession/loadcan carry, which grok reads when the session is (re)loaded.
The MCP entry in the shared config names no account: each MCP process attaches by its own ancestry and session, so every session gets its own nick from one config.
Structs§
Constants§
Functions§
- add_
pending - apply_
grok_ config - Applies
rewrite_grok_configto a file: writes<file>.bak-<unix secs>first, then the new text through a temp file and rename. A missing file is created (nothing to back up). - claim_
pending - Takes the oldest live pending adoption of
provider(one attach binds one session). - client_
adopt - Client side (
gate4agent-node m4a-adopt): owner token from the file/healthnames. - grok_
config_ path <grok home>/config.toml:GROK_HOME, else~/.grok.- handle
- Handles
/m4a/adopt. - is_
loopback_ http - Is
urla loopback HTTP endpoint (a standalone local mailbox daemon)? - mcp_
args - MCP server args the node’s own entry uses (no account, no secret: identity comes from attach).
- process_
cmdline - Command line of a live process (argv), best effort.
- resolve_
session - Session key resolution for an attach: explicit > provider command line > pending adoption.
- rewrite_
grok_ config - Pure edit of a grok
config.toml: dropsmcp_servers.<stale>when it is a loopback HTTP url, and setsmcp_servers.m4ato the node’s stdio server. Other content is kept verbatim. - session_
from_ cmdline - Session id named on a provider command line (
--resume <id>,--session <id>,=forms). - split_
windows_ cmdline - Minimal Windows command-line split (quotes group, backslashes kept).