commonswarm 0.1.36 → 0.1.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cswarm.cjs +199 -45
  2. package/package.json +1 -1
package/cswarm.cjs CHANGED
@@ -28940,6 +28940,21 @@ function parseMemberRow(value) {
28940
28940
  display_name: row.display_name
28941
28941
  };
28942
28942
  }
28943
+ function parseAgentIdentity(value) {
28944
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
28945
+ throw new Error("member read returned a malformed credential identity");
28946
+ }
28947
+ const row = value;
28948
+ if (row.credential_valid !== true) {
28949
+ throw new Error("member read returned a malformed credential validity");
28950
+ }
28951
+ return {
28952
+ credential_valid: true,
28953
+ owner_user_id: checkedUuid2(row.owner_user_id, "identity owner_user_id"),
28954
+ principal_id: checkedUuid2(row.principal_id, "identity principal_id"),
28955
+ workspace_id: checkedUuid2(row.workspace_id, "identity workspace_id")
28956
+ };
28957
+ }
28943
28958
  async function readAgentSignalDirectory(target2, token, workspaceId2, fetcherOrOptions = fetch) {
28944
28959
  const options = normalizeReadOptions(fetcherOrOptions);
28945
28960
  let result;
@@ -28983,7 +28998,8 @@ async function readAgentSignalDirectory(target2, token, workspaceId2, fetcherOrO
28983
28998
  })();
28984
28999
  return {
28985
29000
  members: payload.members.map(parseMemberRow),
28986
- agents
29001
+ agents,
29002
+ ...payload.identity === void 0 ? {} : { identity: parseAgentIdentity(payload.identity) }
28987
29003
  };
28988
29004
  }
28989
29005
  function resolveSignalRecipient(selector, directory) {
@@ -29218,14 +29234,16 @@ function askReplyReadFailureMessage(workspaceId2, error) {
29218
29234
  return `Your message was posted, but its reply could not be fetched (${failure.detail}). Do not resend this ask. Check with: cswarm inbox --workspace-id ${workspaceId2}`;
29219
29235
  }
29220
29236
  function renderSignals(signals, options) {
29237
+ const feedScopeGuidance = "This feed shows broadcast signals only. It omits directed messages, including messages you sent. Read messages directed to you with: cswarm inbox";
29221
29238
  if (signals.length === 0) {
29222
29239
  return [
29223
- options.inbox ? "Inbox:" : "Recent signals:",
29224
- options.inbox ? "Nothing is waiting for you." : options.includeStale ? "No signals have been shared in this workspace yet." : "No live signals in this workspace yet."
29240
+ options.inbox ? "Inbox:" : "Recent broadcast signals:",
29241
+ options.inbox ? "Nothing is waiting for you." : options.includeStale ? "No broadcast signals have been shared in this workspace yet." : "No live broadcast signals in this workspace yet.",
29242
+ ...options.inbox ? [] : [feedScopeGuidance]
29225
29243
  ].join("\n");
29226
29244
  }
29227
29245
  const now = options.now ?? Date.now();
29228
- const lines = [options.inbox ? "Inbox:" : "Recent signals:"];
29246
+ const lines = [options.inbox ? "Inbox:" : "Recent broadcast signals:"];
29229
29247
  for (const signal of signals) {
29230
29248
  const authorKind = signal.from_kind === "agent" ? "agent" : "member";
29231
29249
  const authorName = signal.from_kind === "agent" ? options.authors?.agents.get(signal.from) : options.authors?.users.get(signal.from);
@@ -29253,6 +29271,7 @@ function renderSignals(signals, options) {
29253
29271
  );
29254
29272
  }
29255
29273
  }
29274
+ if (!options.inbox) lines.push(feedScopeGuidance);
29256
29275
  return lines.join("\n");
29257
29276
  }
29258
29277
  function renderSignalStatus(recent, waitingAsks, options = {}) {
@@ -38740,6 +38759,7 @@ async function runListenerHookCheck(options = {}) {
38740
38759
  var import_meta = {};
38741
38760
  var KNOWN_FLAGS = /* @__PURE__ */ new Set([
38742
38761
  "about",
38762
+ "agent-token-file",
38743
38763
  "agent-token-stdin",
38744
38764
  "all-devices",
38745
38765
  "anon-key",
@@ -38829,8 +38849,8 @@ var ACCEPTED_AGENT_CREDENTIAL_MESSAGES = [
38829
38849
  AGENT_CREDENTIAL_MESSAGE_D088
38830
38850
  ];
38831
38851
  function packageVersion() {
38832
- if ("0.1.36".length > 0) {
38833
- return "0.1.36";
38852
+ if ("0.1.38".length > 0) {
38853
+ return "0.1.38";
38834
38854
  }
38835
38855
  try {
38836
38856
  const value = JSON.parse(
@@ -38919,7 +38939,7 @@ var Arguments = class {
38919
38939
  };
38920
38940
  var TARGET_FLAGS = ["url", "anon-key", "force-file-store"];
38921
38941
  var ROUTE_FLAGS = ["workspace-id", "repo-mapping-id"];
38922
- var CREDENTIAL_FLAGS = ["agent-token-stdin"];
38942
+ var CREDENTIAL_FLAGS = ["agent-token-file", "agent-token-stdin"];
38923
38943
  var TASK_FLAGS = [
38924
38944
  "task-id",
38925
38945
  "slug",
@@ -38935,6 +38955,8 @@ var TASK_FLAGS = [
38935
38955
  var UsageError = class extends Error {
38936
38956
  };
38937
38957
  function usage() {
38958
+ const agentCredential2 = "[--agent-token-file <path> | --agent-token-stdin]";
38959
+ const requiredAgentCredential = "(--agent-token-file <path> | --agent-token-stdin)";
38938
38960
  return `cswarm ${CLI_BUILD_VERSION} (protocol ${CLIENT_PROTOCOL_VERSION})
38939
38961
 
38940
38962
  Usage:
@@ -38944,23 +38966,24 @@ Usage:
38944
38966
  cswarm target set --url <project-url> --anon-key <key> [--json]
38945
38967
  cswarm target clear [--json]
38946
38968
  cswarm status [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--json]
38947
- cswarm members [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--agent-token-stdin] [--json]
38948
- cswarm working-on "<what>" [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--about <ref>] [--until <dur>] [--json]
38949
- cswarm note "<text>" [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--to <member|agent>] [--about <ref>] [--until <dur>] [--json] # text: 1..8000 characters
38950
- cswarm ask "<text>" [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--to <member|agent>] [--about <ref>] [--until <dur>] [--wait <seconds>] [--json] # text: 1..8000 characters
38951
- cswarm reply <signal-id> "<text>" [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--until <dur>] [--json]
38952
- cswarm receipt <signal-id> --agent-token-stdin [--url <url> --anon-key <key>] --workspace-id <uuid> [--json]
38953
- cswarm feed [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--about <ref>] [--kind <kind>] [--since <timestamp>] [--limit <n>] [--include-stale] [--json]
38954
- cswarm inbox [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--kind <kind>] [--about <ref>] [--since <timestamp>] [--limit <n>] [--include-stale] [--wait <seconds>] [--json]
38955
- cswarm inbox --notify --agent-token-stdin [--url <url> --anon-key <key>] --workspace-id <uuid> [--json]
38956
- cswarm inbox --follow --ndjson [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--kind <kind>] [--about <ref>] [--since <timestamp>] [--limit <n>] [--include-stale]
38957
- cswarm file put <local-path> [--name <name>] [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--agent-token-stdin] [--json]
38958
- cswarm file ls [--include-tombstoned] [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--agent-token-stdin] [--json]
38959
- cswarm file get <name|file-id> [--version <n>] [--out <local-path>] [--force] [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--agent-token-stdin] [--json]
38960
- cswarm file rm <name|file-id> [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--agent-token-stdin] [--json]
38961
- cswarm file restore <name|file-id> [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--agent-token-stdin] [--json]
38962
- cswarm feedback "<text>" --kind bug|idea|friction [--about <ref>] [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--agent-token-stdin] [--json]
38963
- cswarm listen start --agent-token-stdin [--url <url> --anon-key <key>] --workspace-id <uuid> --provider grok|opencode|claude|codex [--cwd <absolute-path>] [--model <model>] [--effort <level>] [--permissions deny|allow] [--grok-executable <path>] [--opencode-executable <path>] [--claude-executable <path>] [--codex-executable <path>] [--turn-budget <duration>] [--route worker|main|split] [--defer-over <chars>] [--foreground] [--json]
38969
+ cswarm whoami ${requiredAgentCredential} [--url <url> --anon-key <key>] [--workspace-id <uuid>] [--json]
38970
+ cswarm members [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [--json]
38971
+ cswarm working-on "<what>" [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [--about <ref>] [--until <dur>] [--json]
38972
+ cswarm note "<text>" [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [--to <member|agent>] [--about <ref>] [--until <dur>] [--json] # text: 1..8000 characters
38973
+ cswarm ask "<text>" [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [--to <member|agent>] [--about <ref>] [--until <dur>] [--wait <seconds>] [--json] # text: 1..8000 characters
38974
+ cswarm reply <signal-id> "<text>" [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [--until <dur>] [--json]
38975
+ cswarm receipt <signal-id> ${requiredAgentCredential} [--url <url> --anon-key <key>] --workspace-id <uuid> [--json]
38976
+ cswarm feed [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [--about <ref>] [--kind <kind>] [--since <timestamp>] [--limit <n>] [--include-stale] [--json]
38977
+ cswarm inbox [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [--kind <kind>] [--about <ref>] [--since <timestamp>] [--limit <n>] [--include-stale] [--wait <seconds>] [--json]
38978
+ cswarm inbox --notify ${requiredAgentCredential} [--url <url> --anon-key <key>] --workspace-id <uuid> [--json]
38979
+ cswarm inbox --follow --ndjson [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [--kind <kind>] [--about <ref>] [--since <timestamp>] [--limit <n>] [--include-stale]
38980
+ cswarm file put <local-path> [--name <name>] [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [--json]
38981
+ cswarm file ls [--include-tombstoned] [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [--json]
38982
+ cswarm file get <name|file-id> [--version <n>] [--out <local-path>] [--force] [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [--json]
38983
+ cswarm file rm <name|file-id> [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [--json]
38984
+ cswarm file restore <name|file-id> [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [--json]
38985
+ cswarm feedback "<text>" --kind bug|idea|friction [--about <ref>] [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [--json]
38986
+ cswarm listen start ${requiredAgentCredential} [--url <url> --anon-key <key>] --workspace-id <uuid> --provider grok|opencode|claude|codex [--cwd <absolute-path>] [--model <model>] [--effort <level>] [--permissions deny|allow] [--grok-executable <path>] [--opencode-executable <path>] [--claude-executable <path>] [--codex-executable <path>] [--turn-budget <duration>] [--route worker|main|split] [--defer-over <chars>] [--foreground] [--json]
38964
38987
  cswarm listen status [--url <url> --anon-key <key>] --workspace-id <uuid> --principal-id <uuid> [--json]
38965
38988
  cswarm listen stop [--url <url> --anon-key <key>] --workspace-id <uuid> --principal-id <uuid> [--json]
38966
38989
  cswarm hook check [--cooldown <seconds>]
@@ -38982,26 +39005,33 @@ Usage:
38982
39005
  cswarm principal revoke [--url <url> --anon-key <key>] [--workspace-id <uuid>] --principal-id <uuid>
38983
39006
  cswarm token mint [--url <url> --anon-key <key>] [--workspace-id <uuid>] --principal-id <uuid> --run-id <uuid> --task-id <uuid> --epoch <n> [--ttl-ms <ms>]
38984
39007
  cswarm token revoke [--url <url> --anon-key <key>] [--workspace-id <uuid>] --token-id <uuid>
38985
- cswarm token revoke --agent-token-stdin [--url <url> --anon-key <key>] --workspace-id <uuid> [--token-id <uuid>]
39008
+ cswarm token revoke ${requiredAgentCredential} [--url <url> --anon-key <key>] --workspace-id <uuid> [--token-id <uuid>]
38986
39009
  cswarm link new [--url <url> --anon-key <key>] [--workspace-id <uuid>] --task-id <uuid> [--ttl-ms <ms>] [--site <origin>] [--json]
38987
39010
  cswarm link revoke [--url <url> --anon-key <key>] [--workspace-id <uuid>] --capability-id <uuid> [--json]
38988
- cswarm command <kind> [--url <url> --anon-key <key>] [--workspace-id <uuid>] [command fields]
38989
- cswarm dogfood [--url <url> --anon-key <key>] [--workspace-id <uuid>] --slug <slug> --branch <branch> --head-sha <sha> --evidence <ref>
39011
+ cswarm command <kind> [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [command fields]
39012
+ cswarm dogfood [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} --slug <slug> --branch <branch> --head-sha <sha> --evidence <ref>
38990
39013
  cswarm seed-fixture --uid <auth-user-uuid> [--device-id <uuid>] [--workspace-id <uuid>]
38991
39014
 
38992
39015
  Credential selection for command/dogfood:
38993
39016
  default refresh the human login from secure storage
39017
+ --agent-token-file read the credential from an owned 0600 regular file in an owned
39018
+ 0700 directory. The path may appear in argv; the secret never does.
38994
39019
  --agent-token-stdin read a mint/seed credential artifact, or a bare swm_agt_ token, from
38995
39020
  stdin. WHICH FORMS ARE ACCEPTED DEPENDS ON WHAT THE SUBCOMMAND DOES
38996
39021
  WITH THE CREDENTIAL. A subcommand that only reads takes either form.
38997
39022
  One that persists or references the credential needs the complete
38998
39023
  JSON artifact, because it needs a field a bare secret does not carry:
39024
+ whoami reads server-proven identity -- complete or bare form
38999
39025
  members reads only -- either form
39026
+ working-on, note, ask, reply, feed, inbox
39027
+ signal command/read only -- either form
39000
39028
  receipt reads only -- either form
39001
39029
  inbox --notify persists a per-agent cursor -- needs principal_id
39002
39030
  file put, file ls, file get, file rm, file restore
39003
39031
  read and command, nothing persisted -- either form
39004
39032
  feedback command only, nothing persisted -- either form
39033
+ command, dogfood
39034
+ task protocol commands -- either form
39005
39035
  listen start persists durable state, rotates -- needs expires_at
39006
39036
  hook check reads the listener's owned 0600 credential state;
39007
39037
  never accepts or prints a credential
@@ -39041,7 +39071,7 @@ hook install claude prints the UserPromptSubmit JSON by default and changes the
39041
39071
  project's .claude/settings.json only with --write; uninstall also requires --write.
39042
39072
 
39043
39073
  Invite, legacy token accept, principal create/revoke, human token mint/revoke, link, new, and workspace close require a
39044
- stored human login. Agent self-surrender of a token uses --agent-token-stdin and never takes the secret on argv. Invite-link accept signs in when needed, then accepts and
39074
+ stored human login. Agent self-surrender of a token uses --agent-token-file or --agent-token-stdin and never takes the secret on argv. Invite-link accept signs in when needed, then accepts and
39045
39075
  registers one principal. Invitation links, agent credentials, and capability links
39046
39076
  appear only in fresh success responses.
39047
39077
 
@@ -39084,7 +39114,7 @@ workspace only for callers who already hold that full-database credential; it
39084
39114
  grants no new authority and is not a governed product workspace-creation path.`;
39085
39115
  }
39086
39116
  async function target(args) {
39087
- const mode3 = args.has("agent-token-stdin") ? "agent" : "human";
39117
+ const mode3 = hasAgentCredential(args) ? "agent" : "human";
39088
39118
  try {
39089
39119
  return await resolveCloudTarget({
39090
39120
  explicitUrl: args.optional("url"),
@@ -39208,6 +39238,51 @@ async function stdinCredential() {
39208
39238
  const credential = value.trim();
39209
39239
  return parsedAgentCredential(credential);
39210
39240
  }
39241
+ var AgentTokenFileError = class extends Error {
39242
+ constructor(code, message) {
39243
+ super(`[${code}] ${message}`);
39244
+ this.code = code;
39245
+ }
39246
+ code;
39247
+ name = "AgentTokenFileError";
39248
+ };
39249
+ function hasAgentCredential(args) {
39250
+ return CREDENTIAL_FLAGS.some((flag) => args.has(flag));
39251
+ }
39252
+ async function agentCredential(args, options = {}) {
39253
+ const fromFile = args.optional("agent-token-file");
39254
+ const fromStdin = args.has("agent-token-stdin");
39255
+ if (fromFile !== void 0 && fromStdin) {
39256
+ throw new Error(
39257
+ "use exactly one agent credential source: --agent-token-file or --agent-token-stdin"
39258
+ );
39259
+ }
39260
+ if (fromFile !== void 0) {
39261
+ let value;
39262
+ try {
39263
+ value = await readSecureJsonFile(fromFile, 4096);
39264
+ } catch (error) {
39265
+ const detail = error instanceof Error ? error.message : "unknown read failure";
39266
+ throw new AgentTokenFileError(
39267
+ "agent_token_file_unreadable",
39268
+ `could not read --agent-token-file securely: ${detail}`
39269
+ );
39270
+ }
39271
+ if (value === null) {
39272
+ throw new AgentTokenFileError(
39273
+ "agent_token_file_missing",
39274
+ `--agent-token-file does not exist: ${fromFile}`
39275
+ );
39276
+ }
39277
+ return parsedAgentCredential(value.trim());
39278
+ }
39279
+ if (fromStdin || options.implicitStdin === true) {
39280
+ return await stdinCredential();
39281
+ }
39282
+ throw new Error(
39283
+ "provide the agent credential with --agent-token-file <path> or --agent-token-stdin"
39284
+ );
39285
+ }
39211
39286
  async function invitationCredential(args) {
39212
39287
  if (args.has("invitation-token-stdin")) {
39213
39288
  args.assertShape([...TARGET_FLAGS, "invitation-token-stdin"], 1);
@@ -40056,13 +40131,13 @@ async function runToken(args) {
40056
40131
  }));
40057
40132
  }
40058
40133
  async function runTokenRevoke(args) {
40059
- if (args.has("agent-token-stdin")) {
40134
+ if (hasAgentCredential(args)) {
40060
40135
  args.assertShape(
40061
- [...TARGET_FLAGS, "workspace-id", "token-id", "agent-token-stdin", "json"],
40136
+ [...TARGET_FLAGS, "workspace-id", "token-id", ...CREDENTIAL_FLAGS, "json"],
40062
40137
  2
40063
40138
  );
40064
40139
  const cloud2 = await target(args);
40065
- const agent = await stdinCredential();
40140
+ const agent = await agentCredential(args);
40066
40141
  const override = workspaceOverride(
40067
40142
  args.optional("workspace-id"),
40068
40143
  process.env.SWARM_CLOUD_WORKSPACE_ID
@@ -40074,13 +40149,13 @@ async function runTokenRevoke(args) {
40074
40149
  }
40075
40150
  if (agent.tokenId === null) {
40076
40151
  throw new Error(
40077
- "agent credential on stdin has no token_id; pipe the JSON artifact from token mint, not a bare secret"
40152
+ "agent credential has no token_id; use the JSON artifact from token mint, not a bare secret"
40078
40153
  );
40079
40154
  }
40080
40155
  const requested = args.optional("token-id");
40081
40156
  if (requested !== void 0 && requested.toLowerCase() !== agent.tokenId) {
40082
40157
  throw new Error(
40083
- "token-id does not match the credential on stdin; no request was sent"
40158
+ "token-id does not match the credential; no request was sent"
40084
40159
  );
40085
40160
  }
40086
40161
  const tokenId2 = agent.tokenId;
@@ -40396,13 +40471,13 @@ async function commandWorkspaceAndCredential(args, cloud, options = {}) {
40396
40471
  args.optional("workspace-id"),
40397
40472
  process.env.SWARM_CLOUD_WORKSPACE_ID
40398
40473
  );
40399
- if (args.has("agent-token-stdin")) {
40474
+ if (hasAgentCredential(args)) {
40400
40475
  if (override === null) {
40401
40476
  throw new Error(
40402
40477
  "not logged in; agent credentials require --workspace-id or SWARM_CLOUD_WORKSPACE_ID because they never infer a human's workspace selection"
40403
40478
  );
40404
40479
  }
40405
- const agent = await stdinCredential();
40480
+ const agent = await agentCredential(args);
40406
40481
  const session = await agentSession(cloud, override, agent);
40407
40482
  return {
40408
40483
  selectedWorkspace: override,
@@ -40960,6 +41035,80 @@ async function runMembers(args) {
40960
41035
  }
40961
41036
  process.stdout.write(renderRoster(directory, memberNames));
40962
41037
  }
41038
+ async function runWhoami(args) {
41039
+ args.assertShape([
41040
+ ...TARGET_FLAGS,
41041
+ "workspace-id",
41042
+ ...CREDENTIAL_FLAGS,
41043
+ "json"
41044
+ ], 1);
41045
+ if (!hasAgentCredential(args)) {
41046
+ throw new UsageError(
41047
+ "cswarm whoami needs --agent-token-file <path> or --agent-token-stdin"
41048
+ );
41049
+ }
41050
+ const cloud = await target(args);
41051
+ const selected = await commandWorkspaceAndCredential(args, cloud, {
41052
+ validateHumanWorkspace: true
41053
+ });
41054
+ const directory = await readAgentSignalDirectory(
41055
+ cloud,
41056
+ selected.bearer,
41057
+ selected.selectedWorkspace
41058
+ );
41059
+ const identity = directory.identity;
41060
+ if (identity === void 0) {
41061
+ throw new Error(
41062
+ "this deployment authenticated the credential but did not return its identity; update the read service before using cswarm whoami"
41063
+ );
41064
+ }
41065
+ const principal = directory.agents.find(
41066
+ (agent) => agent.principal_id === identity.principal_id
41067
+ );
41068
+ if (principal === void 0 || principal.owner_user_id !== identity.owner_user_id) {
41069
+ throw new Error(
41070
+ "the read service authenticated this credential but returned no matching live principal; identity was not shown"
41071
+ );
41072
+ }
41073
+ const owner = directory.members.find(
41074
+ (member) => member.user_id === identity.owner_user_id
41075
+ );
41076
+ if (owner === void 0) {
41077
+ throw new Error(
41078
+ "the read service authenticated this credential but returned no matching owner; identity was not shown"
41079
+ );
41080
+ }
41081
+ const displayName = sanitizeDisplayLabel(principal.name, "Unnamed agent");
41082
+ const ownerName = sanitizeDisplayLabel(owner.display_name, "Unnamed member");
41083
+ const artifactPrincipalId = selected.agent?.principalId ?? null;
41084
+ const artifactMatches = artifactPrincipalId === null || artifactPrincipalId === identity.principal_id;
41085
+ if (!artifactMatches) {
41086
+ process.stderr.write(
41087
+ `WARNING: the credential authenticated as ${displayName} (${identity.principal_id}), but its JSON metadata names ${artifactPrincipalId}. Trust the authenticated identity shown here and replace the inconsistent artifact.
41088
+ `
41089
+ );
41090
+ }
41091
+ const output = {
41092
+ credential_valid: identity.credential_valid,
41093
+ principal_id: identity.principal_id,
41094
+ display_name: displayName,
41095
+ workspace_id: identity.workspace_id,
41096
+ owner_user_id: identity.owner_user_id,
41097
+ owner_display_name: ownerName,
41098
+ credential_metadata_match: artifactMatches
41099
+ };
41100
+ if (args.has("json")) {
41101
+ printJson(output);
41102
+ return;
41103
+ }
41104
+ process.stdout.write(
41105
+ `You are ${displayName} (${identity.principal_id}).
41106
+ Credential valid now: yes.
41107
+ Workspace: ${identity.workspace_id}.
41108
+ Owner: ${ownerName} (${identity.owner_user_id}).
41109
+ `
41110
+ );
41111
+ }
40963
41112
  async function runSignalRead(args, inbox) {
40964
41113
  const notify = inbox && args.has("notify");
40965
41114
  args.assertShape(notify ? [
@@ -41070,9 +41219,9 @@ async function writeMonitorLine(line) {
41070
41219
  });
41071
41220
  }
41072
41221
  async function runInboxNotifyCommand(args) {
41073
- if (!args.has("agent-token-stdin")) {
41222
+ if (!hasAgentCredential(args)) {
41074
41223
  throw new Error(
41075
- "inbox --notify is for one agent; provide its JSON credential with --agent-token-stdin"
41224
+ "inbox --notify is for one agent; provide its JSON credential with --agent-token-file or --agent-token-stdin"
41076
41225
  );
41077
41226
  }
41078
41227
  const cloud = await target(args);
@@ -41154,9 +41303,9 @@ async function runReceipt(args) {
41154
41303
  if (!UUID_RE19.test(signalId)) {
41155
41304
  throw new Error("signal-id must be a UUID");
41156
41305
  }
41157
- if (!args.has("agent-token-stdin")) {
41306
+ if (!hasAgentCredential(args)) {
41158
41307
  throw new Error(
41159
- "receipt reads signals sent by an agent; provide --agent-token-stdin and --workspace-id"
41308
+ "receipt reads signals sent by an agent; provide --agent-token-file or --agent-token-stdin, and --workspace-id"
41160
41309
  );
41161
41310
  }
41162
41311
  const cloud = await target(args);
@@ -41879,7 +42028,7 @@ async function runListenStart(args) {
41879
42028
  args.assertShape([
41880
42029
  ...TARGET_FLAGS,
41881
42030
  "workspace-id",
41882
- "agent-token-stdin",
42031
+ ...CREDENTIAL_FLAGS,
41883
42032
  "provider",
41884
42033
  "cwd",
41885
42034
  "model",
@@ -41896,9 +42045,9 @@ async function runListenStart(args) {
41896
42045
  "foreground",
41897
42046
  "json"
41898
42047
  ], 2);
41899
- if (!args.has("agent-token-stdin")) {
42048
+ if (!hasAgentCredential(args)) {
41900
42049
  throw new Error(
41901
- "listen start requires --agent-token-stdin; credentials are never accepted on argv"
42050
+ "listen start requires --agent-token-file or --agent-token-stdin; credentials are never accepted on argv"
41902
42051
  );
41903
42052
  }
41904
42053
  const provider = listenerProvider(args);
@@ -41913,7 +42062,7 @@ async function runListenStart(args) {
41913
42062
  args.optional("workspace-id") ?? process.env.SWARM_CLOUD_WORKSPACE_ID,
41914
42063
  "workspace-id"
41915
42064
  );
41916
- const agent = await stdinCredential();
42065
+ const agent = await agentCredential(args);
41917
42066
  assertDurableListenerCredential(agent);
41918
42067
  const principalId = agent.principalId;
41919
42068
  const cwd = args.optional("cwd") ?? process.cwd();
@@ -42063,6 +42212,7 @@ The short credential rotates while this process remains alive and secure local s
42063
42212
  async function runListenSupervisor(args) {
42064
42213
  args.assertShape([
42065
42214
  ...TARGET_FLAGS,
42215
+ ...CREDENTIAL_FLAGS,
42066
42216
  "workspace-id",
42067
42217
  "principal-id",
42068
42218
  "cwd",
@@ -42089,7 +42239,7 @@ async function runListenSupervisor(args) {
42089
42239
  const cloud = await target(args);
42090
42240
  const workspaceId2 = listenerUuid(args.optional("workspace-id"), "workspace-id");
42091
42241
  const principalId = listenerUuid(args.optional("principal-id"), "principal-id");
42092
- const agent = await stdinCredential();
42242
+ const agent = await agentCredential(args, { implicitStdin: true });
42093
42243
  assertDurableListenerCredential(agent, principalId);
42094
42244
  const cwd = args.required("cwd");
42095
42245
  if (!(0, import_node_path20.isAbsolute)(cwd)) throw new Error("--cwd must be an absolute path");
@@ -42844,6 +42994,10 @@ async function main() {
42844
42994
  await runStatus(args);
42845
42995
  return;
42846
42996
  }
42997
+ if (verb === "whoami") {
42998
+ await runWhoami(args);
42999
+ return;
43000
+ }
42847
43001
  if (verb === "feedback") {
42848
43002
  await runFeedback(args);
42849
43003
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commonswarm",
3
- "version": "0.1.36",
3
+ "version": "0.1.38",
4
4
  "description": "CommonSwarm CLI — coordination for teams where people and AI agents work side by side.",
5
5
  "bin": {
6
6
  "cswarm": "cswarm.cjs"