SwarmOps
ReferenceCommandsswarmops whoami
View as Markdown

swarmops whoami#

Show the identity this caller's changes carry.

An identified caller gets its agent, its run id when it has one, and auth "trust"; a caller without an identity gets auth "anonymous" and no agent field at all.

Metadata
Group
store
Since
0.1.0
Mutates
no
Identity required
no
MCP tool
none
Envelope op
whoami
Exit codes
02

Syntax#

swarmops whoami [OPTIONS]

Required arguments#

None.

Optional arguments#

The command also takes the global options.

Examples#

swarmops whoami
{
  "ok": true,
  "op": "whoami",
  "api": 1,
  "result": {
    "auth": "anonymous"
  },
  "meta": {
    "elapsed_ms": "[elapsed_ms]",
    "resolved": {},
    "auth": "trust"
  }
}

Exit code 0. Recorded by the CLI tests. A name in square brackets, such as [tmp] or [c1], stands for what differs from run to run: the test's temporary directory, an id, a time.

Details#

whoami prints the identity your mutations would carry, worked out exactly as commit, land and the other mutations work it out, and does nothing else. It opens no store: --repo and SWARMOPS_REPO are not read, and the envelope has no meta.repo. It has no MCP tool; an MCP server's identity is the one its command line or environment gave it when it started (Identity: one per agent process).

Where the identity comes from#

  1. --as <family>/<instance>, when given.
  2. Else SWARMOPS_AGENT.
  3. SWARMOPS_RUN_ID, when set, is the run the agent acts in, whichever of the two named the agent.

A variable set to the empty string counts as unset. With neither --as nor SWARMOPS_AGENT, the caller is anonymous: {"auth": "anonymous"}, with agent and run_id left out rather than null. Reads work anonymously; the seven commands that change the store (commit, land, blob put, ref set, ref delete, op undo, git import) refuse an anonymous caller with E_IDENTITY_REQUIRED (exit 5).

The agent name#

<family>/<instance>: a family of a-z, 0-9 and -, then /, then an instance of letters, digits, ., _ and - that does not start with ., at most 255 bytes in all, such as agent/worker-17 or operator/ada. Anything else is E_INVALID_ARG (exit 2), its message prefixed with where the name came from (--as, SWARMOPS_AGENT), which details.source holds too. A variable that is not UTF-8 is refused the same way.

What auth means#

trust says the name is taken as claimed: this release verifies no identity, and any process that can write the store's files may claim any name. The name is still recorded on everything the caller writes: a commit's author and committer are the agent name with the email <instance>@<family>.swarmops.local, its metadata holds agent and, when set, run_id, and every ref move records the agent.

Patterns#

  • Check the identity once, at an agent's start, before its first mutation: swarmops whoami exits 2 on a malformed name, and its result.agent should be the name the agent was given.
  • Give every agent process its own instance, and a run id per task or job, so that op log, show and log tell their writes apart. Say who you are and Identities give the conventions.

Return information#

result is a IdentityInfo (swarmops schema IdentityInfo prints its JSON Schema).

FieldTypeRequiredDescription
agentstring or nullno<family>/<instance>; omitted for an anonymous caller.
authstringyesHow this caller's identity was established: trust (claimed, not verified) or anonymous.
run_idstring or nullnoThe run the agent acts in, when it has one.

Envelope op: whoami.

Exit codes:

  • 0: Success.
  • 2: The request or the command line is malformed.

Errors#

  • E_INVALID_ARG (exit 2): A malformed argument or request, including a command-line usage error.

Any command that opens a store may also fail with a store error, such as E_NOT_A_REPO, E_IO or E_STORE_CORRUPT; a command line the grammar refuses is E_INVALID_ARG (exit 2).

See also#

Edit on GitHub

On this page