feat(cli): pass detected agent_caller to backend on Agent Mode bootstrap

The CLI's detect_agent_caller() already canonicalizes the caller (env-var
sniff returning "claude-code", "cursor", etc.) and reports it to PostHog —
but the value never reached the backend, so APIKey.agent_caller stayed
NULL. Join: send it in the bootstrap request body so the platform can
persist it (see mem0ai/platform#2784).

Wire-up:
- bootstrap_via_backend / bootstrapViaBackend gain an agent_caller kwarg,
  pass it as request body field "agent_caller"
- init_cmd / init.ts call detect_agent_caller() once and forward
- platform.agent_caller persisted to ~/.mem0/config.json so the local
  view matches what the backend stored

No change to created_via — that stays the channel enum ("agent_mode" /
"email" / "api_key"). agent_caller is the orthogonal "who started this".
This commit is contained in:
Mgeeeek
2026-05-14 17:24:12 +05:30
parent bac961bc8d
commit d54dad265d
6 changed files with 29 additions and 4 deletions
+3
View File
@@ -31,6 +31,7 @@ class PlatformConfig:
# Agent Mode (unclaimed-shadow signup)
agent_mode: bool = False # True while the key is an unclaimed agent-mode key
created_via: str = "" # "agent_mode" | "email" | "api_key" | "existing_key"
agent_caller: str = "" # canonical agent name when created_via == "agent_mode" (e.g. "claude-code")
claimed_at: str = "" # ISO timestamp once the agent has been claimed by a human
default_user_id: str = "" # `user_<slug>` returned by bootstrap; used as auto-default
@@ -90,6 +91,7 @@ def load_config() -> Mem0Config:
config.platform.user_email = plat.get("user_email", "")
config.platform.agent_mode = bool(plat.get("agent_mode", False))
config.platform.created_via = plat.get("created_via", "")
config.platform.agent_caller = plat.get("agent_caller", "")
config.platform.claimed_at = plat.get("claimed_at", "")
config.platform.default_user_id = plat.get("default_user_id", "")
@@ -147,6 +149,7 @@ def save_config(config: Mem0Config) -> None:
"user_email": config.platform.user_email,
"agent_mode": config.platform.agent_mode,
"created_via": config.platform.created_via,
"agent_caller": config.platform.agent_caller,
"claimed_at": config.platform.claimed_at,
"default_user_id": config.platform.default_user_id,
},