Skip to content

CLI commands should default to session wallet + support identity aliases #16

@hanwencheng

Description

@hanwencheng

Problem

Every credential command requires an explicit wallet address:

agentkeys store 0xcd144766356997205470121b46e6c9914eae9636 openrouter sk-xxx
agentkeys read 0xcd144766356997205470121b46e6c9914eae9636 openrouter
agentkeys run 0xcd144766356997205470121b46e6c9914eae9636 -- python agent.py

This is unfriendly for non-crypto users and redundant when the CLI already has an active session in the keychain containing the wallet address. Currently each machine has one CLI session (multi-session is planned in #12).

Proposed fix

Default to session wallet

The wallet argument should be optional. When omitted, use the active session's wallet:

Current (required) Proposed (optional)
agentkeys store 0xABC openrouter sk-xxx agentkeys store openrouter sk-xxx
agentkeys read 0xABC openrouter agentkeys read openrouter
agentkeys run 0xABC -- cmd agentkeys run -- cmd
agentkeys usage 0xABC agentkeys usage (already optional)
agentkeys revoke 0xABC agentkeys revoke (self-revoke)

When a wallet IS specified, it's for managing a child agent's credentials from the master session.

Support identity aliases

Users who have linked an alias via agentkeys link should be able to use it everywhere:

agentkeys store my-bot openrouter sk-xxx
agentkeys read my-bot openrouter
agentkeys run my-bot -- python agent.py
agentkeys revoke my-bot

The CLI resolves the alias to a wallet via /identity/resolve before calling the backend.

Argument parsing

For commands that take both an optional agent and a required service:

agentkeys store openrouter sk-xxx          # 2 args -> wallet=default, service=openrouter, key=sk-xxx
agentkeys store my-bot openrouter sk-xxx   # 3 args -> wallet=resolve(my-bot), service=openrouter, key=sk-xxx
agentkeys store 0xABC openrouter sk-xxx    # 3 args -> wallet=0xABC, service=openrouter, key=sk-xxx

Disambiguation: if the first arg starts with 0x or is a known alias (resolvable via backend), treat it as a wallet/identity. Otherwise treat it as a service name.

Files to change

  • crates/agentkeys-cli/src/main.rs -- make wallet arg optional in Store, Read, Run, Revoke
  • crates/agentkeys-cli/src/lib.rs -- add identity resolution helper, default wallet from session
  • crates/agentkeys-core/src/mock_client.rs -- may need resolve_identity in trait

References

  • Gmail default account UX as inspiration
  • agentkeys link already supports alias and email linking
  • /identity/resolve endpoint already exists in mock server

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions