Phase 1: Agent Identity Fix

Branch: agent-identity on c15r/sync-mcp

Changes

auth.ts

  • resolveToken: inverted preference from room > agent > view to agent > room > view
  • Added resolveAdminToken(userId, room): returns room admin token for privilege escalation

tools.ts

  • ToolContext: added resolveAdminToken function
  • Added withAdminEscalation helper: retries with admin token on scope_denied errors
  • sync_register_action: uses escalation (agent token first, room token fallback)
  • sync_register_view: uses escalation
  • sync_join_room: uses escalation (creating agents needs admin authority)

main.ts

  • Updated context construction to pass resolveAdminToken

What this fixes

  • from: null on messages → now shows agent identity
  • ${self} scope writes → now resolve to agent ID
  • set_status, update_objective → work via agent token
  • Vocabulary registration → transparent escalation to admin token

What this doesn't fix (deferred to merge)

  • Auto-join (MCP client as agent)
  • Multi-client identity (separate agents per MCP client)
  • HTTP proxy overhead (still round-trips to sync.parc.land)
  • Vault as shadow of agents table