@the-vibe-company/armada 0.1.17 → 0.1.19

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 (3) hide show
  1. package/README.md +21 -8
  2. package/dist/armada.js +471 -196
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -17,13 +17,21 @@ npm install -g @the-vibe-company/armada # then: armada status
17
17
 
18
18
  `armada --version` prints the installed version, `armada --help` every command and `armada <command> --help` one. When a command cannot continue, it prints the reason and a `Next:` line with the command to run, for example `armada init` in a repository without `armada.toml`. Each release is listed on [GitHub releases](https://github.com/The-Vibe-Company/armada/releases) with its changelog.
19
19
 
20
- ## Try it
20
+ ## Set up
21
+
22
+ 1. **Create the organization.** Sign in to Armada ([armada.thevibecompany.co](https://armada.thevibecompany.co), or [your own deployment](#watch-the-fleet-dashboard)) with GitHub, create your organization and invite the others.
23
+ 2. **Enter the keys** once, on Organization > Keys: the Linear API key and the Turso access. They stay sealed in Armada: no laptop or runtime needs them ([Keys](#keys)).
24
+ 3. **Sign in from the terminal**: `armada login`, then approve the code in the browser. A headless coordinator sets `ARMADA_API_KEY` to an organization API key instead ([Sign in from a terminal](#sign-in-from-a-terminal)).
25
+ 4. **Set up the repository**: `armada doctor` lists what it lacks, `armada init --program-root ABC-1` opens one pull request that adds it all ([Set up a repository](#set-up-a-repository)); merge it.
21
26
 
22
27
  ```sh
23
- armada auth login # once per machine: asks for the missing keys, input hidden
28
+ armada login
29
+ armada init --program-root ABC-1
24
30
  armada status # or: armada status --json
25
31
  ```
26
32
 
33
+ Workers then need no key either: each one's launch message carries a one-time token, and Armada gives it its keys ([Launch a worker](#launch-a-worker-coordinators)). Without an Armada that keeps keys (a self-hosted one without accounts, CI), set the keys in the environment or run `armada auth login` ([Keys](#keys)).
34
+
27
35
  `armada status` reads the `armada.toml` of the current repository (or the nearest parent directory) and prints:
28
36
 
29
37
  - **In flight**: tickets an agent holds, with their phase, runtime, last report and pull request. A worker with no report (an `armada report` event in Turso, an `Agent status:` comment or its claim) for longer than `policy.silence_minutes` is flagged `silent`, unless it is waiting on a human (`awaiting-approval`, `blocked`, `ready-to-merge`). A ticket that never had a report falls back to its last sign of life (ticket edit, comment or pull request update).
@@ -45,9 +53,11 @@ armada init --program-root ABC-1 # one pull request that adds it all
45
53
  - the Armada skills (`armada-coordinator`, `armada-worker`, `armada-runtime-conductor`) are in `.agents/skills`, linked from `.claude/skills`, recorded in `skills-lock.json` (the [`npx skills`](https://github.com/vercel-labs/skills) format), and match this version of Armada;
46
54
  - `.conductor/settings.toml` has a `[scripts] setup` command;
47
55
  - `.gitignore` ignores `plans/ship-pr-dev/`;
48
- - the Linear label groups `Agent phase` and `Agent runtime` exist with every value (needs `LINEAR_API_KEY`).
56
+ - this terminal is signed in to Armada, and to which organization: without a sign-in, `armada brief` gives workers no launch token, so each would need the keys in its environment;
57
+ - no key is left in the credentials file that Armada now gives this terminal (`armada auth logout` removes them, the sign-in stays);
58
+ - the Linear label groups `Agent phase` and `Agent runtime` exist with every value (needs a Linear key, from Armada or `LINEAR_API_KEY`).
49
59
 
50
- Each problem is an error or a warning, with its fix. A missing skill is an error: workers cannot run without it. A skill that differs from this Armada version, or a missing ignore line, is a warning. Doctor exits 1 when there is an error. `--json` prints the same report as JSON.
60
+ Each problem is an error or a warning, with its fix. A missing skill is an error: workers cannot run without it. A skill that differs from this Armada version, a missing ignore line, a missing sign-in or a leftover key is a warning. Doctor exits 1 when there is an error. `--json` prints the same report as JSON.
51
61
 
52
62
  `armada init` fixes everything doctor reports in one go:
53
63
 
@@ -55,7 +65,7 @@ Each problem is an error or a warning, with its fix. A missing skill is an error
55
65
  2. It builds the missing or outdated files on a fresh checkout of the default branch, commits them on the branch `armada/init-<version>` and opens a pull request with `gh`. Your own checkout is not touched. Running it again rebuilds that branch and updates the same pull request. When the default branch already has everything, no pull request is opened.
56
66
  3. It registers the project (slug, name, repository, program root) in the Turso database, so `armada status --all` and the dashboard list it.
57
67
 
58
- On a repository without `armada.toml`, pass `--program-root <ISSUE-ID>`; the name comes from the GitHub repository unless you pass `--name`, and the slug from the name unless you pass `--slug`. An existing `armada.toml` is never replaced. `init` needs `git`, the GitHub CLI logged in (`gh auth login`), `LINEAR_API_KEY` and `ARMADA_TURSO_URL`; on a terminal it asks for missing keys first.
68
+ On a repository without `armada.toml`, pass `--program-root <ISSUE-ID>`; the name comes from the GitHub repository unless you pass `--name`, and the slug from the name unless you pass `--slug`. An existing `armada.toml` is never replaced. `init` needs `git`, the GitHub CLI logged in (`gh auth login`), and the Linear key and Turso database URL, from Armada when signed in or from `LINEAR_API_KEY` and `ARMADA_TURSO_URL`; on a terminal it asks for missing keys first.
59
69
 
60
70
  `armada status --all` prints the status of every registered project, each read with the `armada.toml` on its repository's default branch. A project that cannot be read shows its error without hiding the others.
61
71
 
@@ -69,8 +79,9 @@ armada brief ABC-12 --prompt # only the prompt, to pipe into the runti
69
79
  armada brief ABC-12 --profile codex --reason "a back-end bug behind a web label" --json
70
80
  ```
71
81
 
72
- - The prompt names the ticket and its Linear branch, starts by installing the coordinator's Armada version (`npm install -g`, with an `npm exec` fallback) and running `armada claim` with the handle `$CONDUCTOR_WORKSPACE_ID/$CONDUCTOR_SESSION_ID`, and carries the blockers with their hand-back notes, the comments already on the ticket and the workers in flight.
73
- - The settings give the profile's agent, model and effort from `[conductor]` in `armada.toml`, and the environment variables to pass: `LINEAR_API_KEY` (required), `ARMADA_TURSO_URL` and `ARMADA_TURSO_TOKEN` (optional), `ARMADA_TICKET=<ticket>`. Each shows whether this shell has it. No value is ever printed.
82
+ - The prompt names the ticket and its Linear branch, starts by installing the coordinator's Armada version (`npm install -g`, with an `npm exec` fallback), signing in with `armada login --launch-token <token>` and running `armada claim` with the handle `$CONDUCTOR_WORKSPACE_ID/$CONDUCTOR_SESSION_ID`, and carries the blockers with their hand-back notes, the comments already on the ticket and the workers in flight.
83
+ - **Workers need no key.** When the coordinator is signed in to an Armada that keeps the organization's keys, the brief asks it for a launch token: one ticket, used once, valid one hour. The worker exchanges it for a session limited to its ticket's `claim`, `report`, `ask` and `release`, and Armada gives each of those commands its keys. The `Launch:` line says whether the prompt carries one, and when there is none, why (not signed in, or an Armada without accounts or keys). Make the brief right before the launch; the token is the only secret a prompt ever holds, useless once used. Merging or releasing the ticket ends the worker's session, and Organization > Workers on the dashboard revokes one.
84
+ - The settings give the profile's agent, model and effort from `[conductor]` in `armada.toml`, and the environment variables: `ARMADA_TICKET=<ticket>`, and, only without a launch token, `LINEAR_API_KEY` (required), `ARMADA_TURSO_URL` and `ARMADA_TURSO_TOKEN` (optional). Each shows whether this shell has it. No value is ever printed.
74
85
  - The profile follows the ticket's Linear labels: the first `[[conductor.routing]]` rule with a label the ticket carries (case, spaces and punctuation ignored), else `conductor.default_profile`, else the only profile. The settings say which rule chose it.
75
86
  - `--profile` overrides that choice. When `armada.toml` has routing rules and the profile differs from the routed one, `--reason` is required. The reason travels into the claim command, so the claim comment records the profile and why. An unknown profile exits 2.
76
87
 
@@ -79,6 +90,7 @@ armada brief ABC-12 --profile codex --reason "a back-end bug behind a web label"
79
90
  A worker writes to the tracker only through three commands. They set the labels and write the comments in the protocol format, and record each event in Turso.
80
91
 
81
92
  ```sh
93
+ armada login --launch-token <token> # the first line of the launch message: no key needed after it
82
94
  armada claim ABC-12 --runtime conductor --handle <workspace>/<session>
83
95
  armada report awaiting-approval --message-file plan.md # first line = summary
84
96
  armada report implementing --message "plan approved, writing the parser"
@@ -225,13 +237,14 @@ armada logout # revokes this terminal's session and removes it from the machi
225
237
 
226
238
  - A coordinator without a browser (a cloud workspace, CI) uses an organization API key instead: an owner creates it on the Organization page (it is shown once), and the coordinator sets `ARMADA_API_KEY`, or stores it with `armada login --api-key` (hidden prompt, or standard input: `printf %s "$KEY" | armada login --api-key`; never on the command line). `ARMADA_API_KEY` in the environment wins over what `armada login` stored. Revoking the key signs the coordinator out.
227
239
  - The session token or key is kept in the credentials file below (mode 0600) and never printed; `armada auth status` says how the terminal is signed in, without it. A session lasts 30 days and is renewed while in use.
240
+ - A worker signs in with the launch token of its launch message, as its first command: `armada login --launch-token <token>` (plus `--api-url <url>` for a self-hosted Armada, which the brief adds). The worker session it gets is kept per ticket in the credentials file and signs in that ticket's `claim`, `report`, `ask` and `release` only; each of them asks Armada for its keys, and stops with Armada's reason once the session is revoked (Organization > Workers) or ended (`armada release`, or the coordinator's `armada merge`). It lasts while the worker keeps reporting, up to three days idle.
228
241
  - Commands that need a sign-in say so and name `armada login` as the next step; so does an expired session or a revoked key.
229
242
  - The CLI talks to `https://armada.thevibecompany.co`. A self-hosted Armada is named by `ARMADA_API_URL`, or `[api] url` in `config.toml` (https; plain http only for `localhost`). A stored sign-in is sent only to the Armada that issued it: pointing the CLI at another one asks for `armada login` there.
230
243
  - Until an Armada has accounts (it runs on the shared dashboard password), it refuses terminal sign-ins and says so; the keys below keep working as they do today.
231
244
 
232
245
  ## Keys
233
246
 
234
- Armada needs a few keys. A terminal signed in to an Armada that keeps its organization's keys ([Keys kept in Armada](#keys-kept-in-armada)) needs none on the machine: `armada login`, then `armada status`. Otherwise set them up once per machine with `armada auth login`, or pass them as environment variables (the way to go in CI and cloud sandboxes).
247
+ Armada needs a few keys. A terminal signed in to an Armada that keeps its organization's keys ([Keys kept in Armada](#keys-kept-in-armada)) needs none on the machine: `armada login`, then `armada status`. Otherwise set them up once per machine with `armada auth login`, or pass them as environment variables (the way to go in CI and with an Armada without accounts): a key in the environment wins over Armada's.
235
248
 
236
249
  Each key comes from the environment first, then from Armada when signed in, then from the credentials file. Armada is asked only for what the environment does not set, on each command that needs keys, so a key replaced on the Keys page takes effect on the next command. The Linear key it gives stays in memory; the Turso token it makes for the terminal is kept in the credentials file (`ARMADA_TURSO_LEASE`, with its expiry) and renewed when less than an hour is left. When Armada cannot be reached, the command warns and goes on with the machine's keys (and the Turso token kept earlier, until it expires). `armada logout` and `armada auth logout` remove the kept token.
237
250
 
package/dist/armada.js CHANGED
@@ -346,7 +346,7 @@ function armadaApi(opts) {
346
346
  const headers = { Accept: "application/json" };
347
347
  if (init.body)
348
348
  headers["Content-Type"] = "application/json";
349
- if (init.signIn?.kind === "session")
349
+ if (init.signIn?.kind === "session" || init.signIn?.kind === "worker")
350
350
  headers.Authorization = `Bearer ${init.signIn.token}`;
351
351
  if (init.signIn?.kind === "api-key")
352
352
  headers["x-api-key"] = init.signIn.key;
@@ -409,8 +409,11 @@ function armadaApi(opts) {
409
409
  throw refusal(status, body, status === 401 ? null : "Armada could not say who is signed in");
410
410
  return body;
411
411
  },
412
- async credentials(signIn, held) {
413
- const { status, body } = await call("POST", "credentials", { signIn, body: { turso: held } });
412
+ async credentials(signIn, held, purpose = null) {
413
+ const { status, body } = await call("POST", "credentials", {
414
+ signIn,
415
+ body: purpose ? { turso: held, purpose } : { turso: held }
416
+ });
414
417
  if (status !== 200)
415
418
  throw refusal(status, body, status === 401 ? null : "Armada gave no keys");
416
419
  const str = (v) => typeof v === "string" && v.length > 0;
@@ -423,6 +426,31 @@ function armadaApi(opts) {
423
426
  const warnings = Array.isArray(body.warnings) ? body.warnings.filter((w) => typeof w === "string") : [];
424
427
  return { ...body, warnings };
425
428
  },
429
+ async launchToken(signIn, target) {
430
+ const { status, body } = await call("POST", "launch-tokens", { signIn, body: target });
431
+ if (status !== 200)
432
+ throw refusal(status, body, status === 401 ? null : "Armada made no launch token");
433
+ const w = body.worker;
434
+ if (typeof body.token !== "string" || typeof body.expiresAt !== "string" || !w?.ticket)
435
+ throw new ArmadaApiError(`Armada (${host}) answered the launch token in a shape this CLI does not know`);
436
+ return body;
437
+ },
438
+ async exchangeLaunchToken(token) {
439
+ const { status, body } = await call("POST", "launch-tokens/exchange", { body: { token } });
440
+ if (status !== 200)
441
+ throw refusal(status, body, null);
442
+ const w = body.worker;
443
+ const org = body.organization;
444
+ if (typeof body.token !== "string" || !w?.ticket || !w.project || !org?.id)
445
+ throw new ArmadaApiError(`Armada (${host}) answered the launch token in a shape this CLI does not know`);
446
+ return body;
447
+ },
448
+ async endWorkers(signIn, target) {
449
+ const { status, body } = await call("POST", "workers/end", { signIn, body: target });
450
+ if (status !== 200)
451
+ throw refusal(status, body, "Armada did not end the ticket's workers");
452
+ return typeof body.ended === "number" ? body.ended : 0;
453
+ },
426
454
  async signOut(signIn) {
427
455
  const { status, body } = await call("DELETE", "session", { signIn });
428
456
  if (status !== 200)
@@ -3174,9 +3202,11 @@ function buildBrief(input) {
3174
3202
  choice?.reason ? ` --reason ${shellWord(choice.reason)}` : ""
3175
3203
  ].join("");
3176
3204
  const has = (name) => !!input.env[name]?.trim();
3205
+ const launch = input.launch ?? null;
3177
3206
  const environment = [
3178
3207
  ...VARIABLES.map((v) => ({
3179
3208
  ...v,
3209
+ ...launch ? { required: false, purpose: `${v.purpose}; not needed: the launch token signs the worker in` } : {},
3180
3210
  value: null,
3181
3211
  inShell: has(v.name),
3182
3212
  inStore: !has(v.name) && !!input.stored?.includes(v.name)
@@ -3207,6 +3237,11 @@ function buildBrief(input) {
3207
3237
  install: `npm install -g ${pkg}`,
3208
3238
  fallback: `npm exec --yes --package=${pkg} -- armada`,
3209
3239
  claimCommand,
3240
+ launch: launch ? {
3241
+ command: `armada login --launch-token ${shellWord(launch.token)}${launch.apiUrl ? ` --api-url ${shellWord(launch.apiUrl)}` : ""}`,
3242
+ expiresAt: launch.expiresAt
3243
+ } : null,
3244
+ noLaunch: launch ? null : input.noLaunch ?? null,
3210
3245
  environment,
3211
3246
  blockers: ticket.blockers.map(({ notes, ...b }) => ({ ...b, handBack: handBackNote(notes) })),
3212
3247
  notes: ticket.notes.slice(0, MAX_NOTES),
@@ -3233,10 +3268,15 @@ function renderPrompt(b) {
3233
3268
  "",
3234
3269
  "```sh",
3235
3270
  b.install,
3271
+ ...b.launch ? [b.launch.command] : [],
3236
3272
  b.claimCommand,
3237
3273
  "```",
3238
3274
  "",
3239
3275
  `This installs the coordinator's Armada version. If the global install is refused, use \`${b.fallback}\` wherever this brief or the skill says \`armada\`.`,
3276
+ ...b.launch ? [
3277
+ "",
3278
+ `\`armada login --launch-token\` signs this workspace in to Armada as the worker of ${t.id}, with a one-time token valid until ${b.launch.expiresAt.slice(0, 16).replace("T", " ")} UTC. Run it first, once.`
3279
+ ] : [],
3240
3280
  "",
3241
3281
  "If the claim is refused, stop and quote the refusal in your reply (usually another worker holds the ticket).",
3242
3282
  "",
@@ -3270,7 +3310,7 @@ ${quote(x.handBack.body)}` : "No hand-back note.", "");
3270
3310
  out.push(`- ${w.id} — ${w.title} (${w.phase})${w.branch ? `, branch \`${w.branch}\`` : ""}${w.pr ? `, ${w.pr}` : ""}`);
3271
3311
  } else
3272
3312
  out.push("None.");
3273
- out.push("", "## Environment", "", `The coordinator set ${b.environment.map((v) => `\`${v.name}\``).join(", ")} in this workspace. Never print, commit or log their values.`);
3313
+ out.push("", "## Environment", "", b.launch ? `No key is needed in this workspace: once signed in, Armada hands each command the keys it needs, for ${t.id} only. If a command says this worker was cut off from Armada, stop and say so in your reply. Never print, commit or log a token or a key.` : `The coordinator set ${b.environment.map((v) => `\`${v.name}\``).join(", ")} in this workspace. Never print, commit or log their values.`);
3274
3314
  return `${out.join(`
3275
3315
  `)}
3276
3316
  `;
@@ -3291,6 +3331,12 @@ async function loadBrief(config, opts) {
3291
3331
  ]);
3292
3332
  if (!ticket)
3293
3333
  throw new Refusal(`ticket ${opts.ticket} not found in Linear`, "armada status, to see the tickets of the program");
3334
+ const open = ticket.statusType !== "completed" && ticket.statusType !== "canceled";
3335
+ const launch = open && opts.launch ? await opts.launch(ticket.id) : null;
3336
+ const made = launch && "token" in launch ? launch : null;
3337
+ const missed = launch && "reason" in launch ? launch : null;
3338
+ if (missed?.warn)
3339
+ ticket.warnings.push(`no launch token: ${missed.reason}`);
3294
3340
  return buildBrief({
3295
3341
  config,
3296
3342
  ticket,
@@ -3300,6 +3346,8 @@ async function loadBrief(config, opts) {
3300
3346
  version: opts.version,
3301
3347
  env: opts.env,
3302
3348
  ...opts.stored ? { stored: opts.stored } : {},
3349
+ launch: made,
3350
+ noLaunch: missed?.reason ?? null,
3303
3351
  now: now()
3304
3352
  });
3305
3353
  }
@@ -3310,22 +3358,38 @@ var API_KEY_VARIABLE = "ARMADA_API_KEY";
3310
3358
  var API_URL_VARIABLE = "ARMADA_API_URL";
3311
3359
  var SIGNED_IN_TO_VARIABLE = "ARMADA_SIGNED_IN_TO";
3312
3360
  var TURSO_LEASE_VARIABLE = "ARMADA_TURSO_LEASE";
3313
- var formatLease = (lease) => Buffer.from(JSON.stringify(lease), "utf8").toString("base64url");
3314
- function parseLease(value) {
3361
+ var WORKER_SESSION_PREFIX = "ARMADA_WORKER_SESSION_";
3362
+ var workerSessionVariable = (ticket) => `${WORKER_SESSION_PREFIX}${ticket.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`;
3363
+ var formatRecord = (record) => Buffer.from(JSON.stringify(record), "utf8").toString("base64url");
3364
+ function parseRecord(value, keys) {
3315
3365
  if (!value?.trim())
3316
3366
  return null;
3317
3367
  try {
3318
- const l = JSON.parse(Buffer.from(value.trim(), "base64url").toString("utf8"));
3319
- const keys = ["api", "organization", "url", "token", "expiresAt", "revision"];
3320
- if (!keys.every((k) => typeof l[k] === "string" && l[k]))
3368
+ const r = JSON.parse(Buffer.from(value.trim(), "base64url").toString("utf8"));
3369
+ if (!keys.every((k) => typeof r[k] === "string" && r[k]))
3321
3370
  return null;
3322
- if (Number.isNaN(Date.parse(String(l.expiresAt))))
3323
- return null;
3324
- return Object.fromEntries(keys.map((k) => [k, String(l[k])]));
3371
+ return Object.fromEntries(keys.map((k) => [k, String(r[k])]));
3325
3372
  } catch {
3326
3373
  return null;
3327
3374
  }
3328
3375
  }
3376
+ var formatLease = (lease) => formatRecord(lease);
3377
+ function parseLease(value) {
3378
+ const l = parseRecord(value, ["api", "organization", "url", "token", "expiresAt", "revision"]);
3379
+ return l && !Number.isNaN(Date.parse(l.expiresAt)) ? l : null;
3380
+ }
3381
+ var formatWorkerSession = (worker) => formatRecord(worker);
3382
+ function parseWorkerSession(value) {
3383
+ return parseRecord(value, ["api", "token", "ticket", "project", "organization", "id"]);
3384
+ }
3385
+ function storedWorkers(store) {
3386
+ return Object.entries(store).flatMap(([variable, value]) => {
3387
+ if (!variable.startsWith(WORKER_SESSION_PREFIX))
3388
+ return [];
3389
+ const w = parseWorkerSession(value);
3390
+ return w && workerSessionVariable(w.ticket) === variable ? [w] : [];
3391
+ });
3392
+ }
3329
3393
  function armadaAddress(url) {
3330
3394
  try {
3331
3395
  const u = new URL(url.trim());
@@ -3363,7 +3427,14 @@ var fromEnv = (env, variable) => {
3363
3427
  const value = clean(env[variable]);
3364
3428
  return value ? { value, source: { kind: "env", variable } } : null;
3365
3429
  };
3366
- function resolveCredentials({ env, store = {}, personal, ghToken, armada }) {
3430
+ function resolveCredentials({
3431
+ env,
3432
+ store = {},
3433
+ personal,
3434
+ ghToken,
3435
+ armada,
3436
+ ticket
3437
+ }) {
3367
3438
  const fromStore = (variable) => {
3368
3439
  const value = clean(store[variable]);
3369
3440
  return value ? { value, source: { kind: "store" } } : null;
@@ -3376,14 +3447,23 @@ function resolveCredentials({ env, store = {}, personal, ghToken, armada }) {
3376
3447
  const tursoUrlConfig = clean(personal?.turso.url);
3377
3448
  const apiUrlConfig = clean(personal?.api.url);
3378
3449
  const apiUrl = fromEnv(env, API_URL_VARIABLE);
3379
- const armadaApi = apiUrl ? { url: apiUrl.value, source: apiUrl.source } : apiUrlConfig ? { url: apiUrlConfig, source: { kind: "config", key: "api.url" } } : { url: DEFAULT_ARMADA_API_URL, source: { kind: "default" } };
3450
+ const workers = storedWorkers(store);
3451
+ const worker = ticket ? workers.find((w) => w.ticket === ticket.toUpperCase()) : undefined;
3452
+ const armadaApi = apiUrl ? { url: apiUrl.value, source: apiUrl.source } : apiUrlConfig ? { url: apiUrlConfig, source: { kind: "config", key: "api.url" } } : worker ? { url: worker.api, source: { kind: "store" } } : { url: DEFAULT_ARMADA_API_URL, source: { kind: "default" } };
3453
+ const workerHere = worker && armadaAddress(worker.api) === armadaAddress(armadaApi.url) ? worker : null;
3380
3454
  const envKey = fromEnv(env, API_KEY_VARIABLE);
3381
3455
  const signedInTo = armadaAddress(clean(store[SIGNED_IN_TO_VARIABLE]) ?? DEFAULT_ARMADA_API_URL);
3382
3456
  const here = signedInTo === armadaAddress(armadaApi.url);
3383
3457
  const session = fromStore(SESSION_TOKEN_VARIABLE);
3384
3458
  const storedKey = fromStore(API_KEY_VARIABLE);
3385
3459
  const armadaSignInElsewhere = !here && (session || storedKey) ? signedInTo : null;
3386
- const armadaSignIn = envKey ? { kind: "api-key", key: envKey.value, source: envKey.source } : session && here ? { kind: "session", token: session.value, source: session.source } : storedKey && here ? { kind: "api-key", key: storedKey.value, source: storedKey.source } : null;
3460
+ const armadaSignIn = workerHere ? {
3461
+ kind: "worker",
3462
+ token: workerHere.token,
3463
+ ticket: workerHere.ticket,
3464
+ project: workerHere.project,
3465
+ source: { kind: "store" }
3466
+ } : envKey ? { kind: "api-key", key: envKey.value, source: envKey.source } : session && here ? { kind: "session", token: session.value, source: session.source } : storedKey && here ? { kind: "api-key", key: storedKey.value, source: storedKey.source } : null;
3387
3467
  const fromArmada = (value, detail) => value && detail ? { value, source: { kind: "armada", detail } } : null;
3388
3468
  const tursoPair = armada?.turso && !fromEnv(env, "ARMADA_TURSO_URL") && !fromEnv(env, "ARMADA_TURSO_TOKEN") ? armada.turso : null;
3389
3469
  const found = {
@@ -3405,7 +3485,8 @@ function resolveCredentials({ env, store = {}, personal, ghToken, armada }) {
3405
3485
  },
3406
3486
  armadaApi,
3407
3487
  armadaSignIn,
3408
- armadaSignInElsewhere: envKey ? null : armadaSignInElsewhere
3488
+ workerTickets: workers.map((w) => w.ticket),
3489
+ armadaSignInElsewhere: envKey || workerHere ? null : armadaSignInElsewhere
3409
3490
  };
3410
3491
  }
3411
3492
  var missingKeys = (credentials) => STORED_KEYS.filter((k) => credentials[k.name] === null);
@@ -4883,13 +4964,14 @@ The coordinator turns the owner's intent into merged pull requests. Each worker
4883
4964
 
4884
4965
  ## Take over a run
4885
4966
 
4886
- A coordinator may start cold, on a laptop or in a fresh cloud session, with nothing but the repository and its keys. Everything it needs is in the tracker, GitHub and Turso; the Armada [runbook](https://github.com/The-Vibe-Company/armada/blob/main/docs/runbook.md) says how to start one.
4967
+ A coordinator may start cold, on a laptop or in a fresh cloud session, with nothing but the repository and a sign-in to Armada. Everything it needs is in the tracker, GitHub and Turso; the Armada [runbook](https://github.com/The-Vibe-Company/armada/blob/main/docs/runbook.md) says how to start one.
4887
4968
 
4888
- 1. **Find your coordination ticket.** When the owner gives the coordinator a ticket of its own (a run to carry out, for example "run this ticket end to end"), that ticket holds the run's history. Read its comments, newest first. A last comment \`Agent status: released — <text>\` is a hand-over: the previous coordinator stopped on purpose, \`<text>\` is the state it left (who runs, what was asked and answered, what remains), and the ticket is back without agent labels, waiting for you.
4889
- 2. **Claim it with your own handle**, never the previous coordinator's: \`armada claim <ticket> --runtime <your runtime> --handle <your handle> --branch <default branch>\`. In a Conductor workspace the runtime is \`conductor\` and the handle \`"$CONDUCTOR_WORKSPACE_ID/$CONDUCTOR_SESSION_ID"\`; on a laptop, the runtime you run in (a value of the runtime label group, for example \`claude-code\`) and a handle that names your session. The claim is refused while the previous coordinator still holds the ticket: ask the owner whether it stopped before releasing it for them. Without a coordination ticket, skip this step.
4890
- 3. **Read the fleet** (step 1 of the loop): \`armada status\` and \`armada inbox\` give each worker's handle, phase, question and hand-back. Trust them over the hand-over comment where they disagree: the comment is older.
4891
- 4. **Report on your ticket** as a worker would, \`armada report implementing --ticket <ticket> --message "<what you found and do next>"\`, at least every \`policy.silence_minutes\`, and post the run's evidence there when it ends.
4892
- 5. **Hand over** when you stop before the run ends: \`armada release --ticket <ticket> --reason "<state so far and what remains>"\`. It posts the \`released\` comment the next coordinator reads. Write it for a reader with none of your context.
4969
+ 1. **Sign in to Armada.** \`armada doctor\` (or \`armada whoami\`) says whether this terminal is signed in and to which organization. If not: a person runs \`armada login\` and approves the code in the browser; a headless coordinator (a cloud workspace, CI) sets \`ARMADA_API_KEY\` to an organization API key an owner created on the Organization page. Signed in, Armada gives your commands the organization's keys, and every brief carries a one-time launch token, so no worker needs a key in its environment. Keys set in the environment still win over Armada's: they are the override for CI and a self-hosted Armada without accounts.
4970
+ 2. **Find your coordination ticket.** When the owner gives the coordinator a ticket of its own (a run to carry out, for example "run this ticket end to end"), that ticket holds the run's history. Read its comments, newest first. A last comment \`Agent status: released — <text>\` is a hand-over: the previous coordinator stopped on purpose, \`<text>\` is the state it left (who runs, what was asked and answered, what remains), and the ticket is back without agent labels, waiting for you.
4971
+ 3. **Claim it with your own handle**, never the previous coordinator's: \`armada claim <ticket> --runtime <your runtime> --handle <your handle> --branch <default branch>\`. In a Conductor workspace the runtime is \`conductor\` and the handle \`"$CONDUCTOR_WORKSPACE_ID/$CONDUCTOR_SESSION_ID"\`; on a laptop, the runtime you run in (a value of the runtime label group, for example \`claude-code\`) and a handle that names your session. The claim is refused while the previous coordinator still holds the ticket: ask the owner whether it stopped before releasing it for them. Without a coordination ticket, skip this step.
4972
+ 4. **Read the fleet** (step 1 of the loop): \`armada status\` and \`armada inbox\` give each worker's handle, phase, question and hand-back. Trust them over the hand-over comment where they disagree: the comment is older.
4973
+ 5. **Report on your ticket** as a worker would, \`armada report implementing --ticket <ticket> --message "<what you found and do next>"\`, at least every \`policy.silence_minutes\`, and post the run's evidence there when it ends.
4974
+ 6. **Hand over** when you stop before the run ends: \`armada release --ticket <ticket> --reason "<state so far and what remains>"\`. It posts the \`released\` comment the next coordinator reads. Write it for a reader with none of your context.
4893
4975
 
4894
4976
  ## Loop
4895
4977
 
@@ -4904,7 +4986,7 @@ A coordinator may start cold, on a laptop or in a fresh cloud session, with noth
4904
4986
  - pick the ticket from the frontier in \`armada status\`;
4905
4987
  - run \`armada brief <ticket>\` and resolve its warnings. The profile (agent, model, effort) is routed from the ticket's labels by \`[[conductor.routing]]\` in \`armada.toml\`, else \`default_profile\`, and the brief says which rule chose it. Follow it. Override it only when the ticket's labels mislead (for example a \`web\` ticket that is really a tricky back-end bug): \`armada brief <ticket> --profile <name> --reason "<why>"\`. The reason lands in the worker's claim comment;
4906
4988
  - write the prompt with \`armada brief <ticket> --prompt > <file>\` and add what only you know: which parallel workers touch neighbouring code and where the boundary is, and decisions not yet on the ticket;
4907
- - launch it with the runtime guide's *launch* section, passing the profile's values and the environment variables the brief names;
4989
+ - launch it with the runtime guide's *launch* section, passing the profile's values. When the brief's \`Launch:\` line says the prompt carries a one-time token, pass no key: the worker signs in with it. When it says there is none, fix the reason (usually your sign-in) and brief again, rather than pass keys; the token works once, within the hour, so brief right before the launch;
4908
4990
  - check the claim: \`armada status\` shows the ticket in flight, phase \`planning\`, with the handle the runtime returned. Done when every launched ticket is In Progress with a claim.
4909
4991
  6. **Merge handed-back pull requests** one at a time with \`armada merge <pr>\`, following [MERGE.md](MERGE.md). Done when the pull request is merged, the ticket is Done with its agent labels removed, and every in-flight worker affected by what landed has been told. When the repository's rules (\`AGENTS.md\`) ask you to ship each merge through its release pull request (release-please's \`chore(main): release …\`), merge that one next, as "The release pull request" in [MERGE.md](MERGE.md) describes.
4910
4992
  7. **Turn findings into tickets.** A gap a worker reports or a bug you see becomes a ticket under the right spec, with blocked-by relations, and is launched when ready. No finding lives only in a transcript.
@@ -4921,7 +5003,7 @@ Repeat from step 1. Between rounds, \`armada inbox --wait\` blocks until a new i
4921
5003
  `;
4922
5004
 
4923
5005
  // ../../skills/armada-runtime-conductor/SKILL.md
4924
- var SKILL_default2 = "---\nname: armada-runtime-conductor\ndescription: Runtime guide for running Armada workers on Conductor Cloud. Use when an Armada coordinator must launch a worker on a ticket, send it a message, check whether a silent worker is still alive, or stop and archive it. Four fixed sections, each with the exact conductor command and how to read its output.\n---\n\nArmada never calls a runtime. This guide tells the coordinator how to launch, message, check and stop a worker with the `conductor` command line tool, and what to record in Armada afterwards. It was checked against `conductor` 0.89.x (the desktop app's CLI, macOS) and 0.1.x (the CLI inside a Conductor Cloud workspace, Linux); every command below works in both. `conductor --version` prints yours; if a flag is refused, compare with `conductor <command> --help`.\n\n- Always pass `--json` and read fields with `jq`. Exit codes: 0 ok, 1 runtime error, 2 usage error, 3 authentication, 4 server error.\n- On exit code 3, `conductor auth whoami` checks the token the CLI uses (it exits 0 when the token works). Do not rely on `conductor auth status`: it only looks for a macOS Keychain entry and fails on Linux (\"Keychain storage is only supported on macOS\"). In a Conductor Cloud workspace the CLI reads `CONDUCTOR_API_KEY` from the environment and needs no login; on a Mac, `conductor auth login` stores a token in the Keychain.\n- A worker is one workspace with one session. Its Armada handle is `<workspaceId>/<sessionId>`; the worker's claim comment carries it, so `armada status` and the ticket always lead back to the session.\n- Never type a secret value into a command, a file or a message: name the variable and let your shell expand it. The expanded value is still in the `conductor` process's arguments while it runs, so launch from a machine only you use.\n\n## Launch\n\n1. Pick a ready ticket from `armada status` that does not collide with work in flight.\n2. Run `armada brief ABC-12` (with `--profile <name> --reason \"<why>\"` when you override the routed profile). Read the profile (agent, model, effort, fast mode), the environment table and the warnings. Resolve every warning first: an open blocker, a ticket already in flight. Export each required variable the table marks `NOT set in this shell`. One marked `in credentials file` is in Armada's machine store: keep the `set -a` line of the launch command below, which loads that file without printing it.\n3. Write the prompt to a file, and add what only you know (the boundary with a parallel worker, a decision not yet on the ticket):\n\n```sh\narmada brief ABC-12 --prompt > /tmp/abc-12-brief.md\n```\n\n4. Create the workspace with every value from the profile. Never leave the agent, model or effort to Conductor's defaults. Add `--fast-mode` when the profile says fast mode; drop an optional `--env` line whose variable you do not have. Run the whole block as one command: shell state does not carry over between separate calls, and the subshell keeps the keys out of the rest of your session. Drop the `set -a` line when every variable is set in your shell.\n\n```sh\n(\n set -a; . \"${XDG_CONFIG_HOME:-$HOME/.config}/armada/credentials\"; set +a\n [ -n \"$LINEAR_API_KEY\" ] || { echo \"LINEAR_API_KEY is missing\" >&2; exit 1; }\n conductor --json workspace create \\\n --repo-url https://github.com/<owner>/<name> \\\n --branch main \\\n --name \"ABC-12 <short title>\" \\\n --agent claude --model opus-5-5-1m --effort high \\\n --message-file - \\\n --env ARMADA_TICKET=ABC-12 \\\n --env LINEAR_API_KEY=\"$LINEAR_API_KEY\" \\\n --env ARMADA_TURSO_URL=\"$ARMADA_TURSO_URL\" \\\n --env ARMADA_TURSO_TOKEN=\"$ARMADA_TURSO_TOKEN\" \\\n < /tmp/abc-12-brief.md > /tmp/abc-12-launch.json\n)\njq -r '\"\\(.workspaceId)/\\(.sessionId)\"' /tmp/abc-12-launch.json\n```\n\n- `--branch` is the base branch (the default branch). Conductor creates a branch named `conductor/<slug of --name>`; the brief tells the worker to rename it to the ticket's branch.\n- The output has `workspaceId`, `sessionId`, `deepLink` and `initialMessage` (`messageId`, `state: \"queued\"`). Keep the handle the `jq` line prints, and give the owner the `deepLink` when they want to watch.\n- Conductor sets `CONDUCTOR_WORKSPACE_ID` and `CONDUCTOR_SESSION_ID` inside the workspace. The brief's first commands install your Armada version (`npm install -g`) and claim the ticket with them. `--env` values are not shown back by `workspace get`.\n- An unknown agent, model or effort fails the command. Check the ids with `conductor model` (each agent's models, efforts and defaults) and fix the profile in `armada.toml`.\n\n5. **Check the claim.** Within a few minutes, `armada status` lists the ticket in flight, phase `planning`, runtime `Conductor`, and the ticket's claim comment reads `session: <workspaceId>/<sessionId>` and `profile: <name>`. No claim after ten minutes: read the transcript (Status section). If the worker cannot claim (for example a missing key), fix the cause and message it; as a last resort record the handle yourself with `armada claim ABC-12 --runtime conductor --handle <workspaceId>/<sessionId> --profile <name>`, adding the brief's `--reason` for an override.\n\n## Message\n\n```sh\nprintf '%s\\n' \"Plan approved. Go on.\" | conductor --json message create --session <sessionId> --message-file -\nconductor --json message create --session <sessionId> --message-file - < /tmp/abc-12-answer.md\n```\n\nThe output is `{\"messageId\": …, \"state\": \"sent\"}`. Exit code 0 means Conductor accepted the message, not that the worker read it: check that the session turns `working`, then read its reply in the transcript. Use it to deliver an answer, a plan approval, or a heads-up that the default branch moved. Then record it in Armada: `armada answer <item> \"<answer>\"` for a question from `armada inbox`, `armada answer --note ABC-12 \"<message>\"` for a message the worker did not ask for.\n\n## Status\n\n```sh\nconductor --json session status <sessionId>\n```\n\nThe output is `{\"workspaceId\", \"sessionId\", \"status\", \"updatedAt\"}`. For a worker:\n\n- `working`: a turn is running. A silent worker that is `working` is busy (a long build or test run): leave it, and read the transcript if it stays silent past twice `policy.silence_minutes`.\n- `idle`: no turn is running. The worker finished its turn: it handed back, it waits for an answer, or it stopped without finishing. If `armada status` does not show it `ready-to-merge`, `awaiting-approval` or `blocked`, it has stopped: read its last reply, then message it to go on, or release and relaunch the ticket.\n- `error`: the last turn failed (agent or provider failure). Read the transcript and message it to resume; if it fails again, cancel, archive, release and relaunch.\n- Right after launch the session is `idle` for a few seconds while the workspace is initializing and the first message is queued; it turns `working` when the agent starts.\n\nThe workspace itself: `conductor --json workspace status <workspaceId>` gives `status` `initializing`, `ready` or `archived`.\n\n**Read the transcript** to see what a worker did or said. Events come oldest first, 100 per page; `hasMore` tells when to fetch the next page with `--after` the last event id. Keep the last id you read and poll from it.\n\n```sh\nconductor --json session message <sessionId> --limit 100 > /tmp/abc-12-events.json\njq -r '.hasMore, .data[-1].id' /tmp/abc-12-events.json\nconductor --json session message <sessionId> --after <lastEventId> --limit 100\n```\n\nThe second line prints whether more pages exist and the id to continue from. `.content.rawPayload` is the agent's own event format, so the filters depend on the worker's agent (the `agent` of its profile in `armada.toml`).\n\nA `claude` worker: each turn's final reply, then the commands and tools it ran.\n\n```sh\njq -r '.data[] | select(.content.rawPayload.type == \"result\") | .content.rawPayload | \"error=\\(.is_error)\\n\\(.result)\"' /tmp/abc-12-events.json\njq -r '.data[] | select(.content.rawPayload.type == \"assistant\") | .content.rawPayload.message.content[] | select(.type == \"tool_use\") | .input.command // .name' /tmp/abc-12-events.json\n```\n\nA `codex` worker: its events are `.content.rawPayload.event`, each item once as `item.started` and once as `item.completed`; read the completed ones. Its messages (`phase` is `commentary` along the way, `final_answer` at the end of a turn), then each command with its exit code, and its tool calls (Linear and other MCP servers).\n\n```sh\njq -r '.data[] | .content.rawPayload.event | select(.type == \"item.completed\") | .item | select(.type == \"agentMessage\") | \"[\\(.phase)] \\(.text)\"' /tmp/abc-12-events.json\njq -r '.data[] | .content.rawPayload.event | select(.type == \"item.completed\") | .item | select(.type == \"commandExecution\") | \"exit=\\(.exitCode) \\(.command)\"' /tmp/abc-12-events.json\njq -r '.data[] | .content.rawPayload.event | select(.type == \"item.completed\") | .item | select(.type == \"mcpToolCall\") | \"\\(.server) \\(.tool)\"' /tmp/abc-12-events.json\n```\n\nAnother agent, or a filter that prints nothing: count the event types, look at one event of the type you need, and adapt the filter.\n\n```sh\njq -r '.data[].content.rawPayload | .type // .event.type // \"(no payload)\"' /tmp/abc-12-events.json | sort | uniq -c\n```\n\n## Stop and archive\n\n```sh\nconductor --json session cancel <sessionId>\nconductor --json workspace archive <workspaceId>\n```\n\n- `session cancel` stops the running turn: `{\"status\", \"canceledQueuedMessages\"}`, and the session is `idle` within seconds. The workspace stays; a message starts a new turn. Use it on a worker that runs the wrong thing.\n- `workspace archive` answers `{\"status\": \"archived\"}`. Archive a worker's workspace after its pull request is merged, or after `armada release --ticket ABC-12 --reason \"<why>\"` for a worker that stops without handing back. The branch and the pull request stay on GitHub.\n- **Wait for `idle` before archiving.** A hand-back often arrives while the worker's session is still `working`: `armada report ready-to-merge` runs inside its last turn, which then writes its final reply. Archive only once `session status` answers `idle`. Poll it every 15 seconds; if it is still `working` after 10 minutes, cancel the turn and archive (the transcript keeps what it was doing). Run the whole block as one command; it can take up to 10 minutes, so run it in the background or give it a longer command timeout:\n\n```sh\nfor i in $(seq 40); do\n [ \"$(conductor --json session status <sessionId> | jq -r .status)\" = working ] || break\n sleep 15\ndone\n[ \"$(conductor --json session status <sessionId> | jq -r .status)\" = working ] && conductor --json session cancel <sessionId>\nconductor --json workspace archive <workspaceId>\n```\n- After an archive, `session status` still answers `idle`; `workspace status` says `archived`.\n";
5006
+ var SKILL_default2 = "---\nname: armada-runtime-conductor\ndescription: Runtime guide for running Armada workers on Conductor Cloud. Use when an Armada coordinator must launch a worker on a ticket, send it a message, check whether a silent worker is still alive, or stop and archive it. Four fixed sections, each with the exact conductor command and how to read its output.\n---\n\nArmada never calls a runtime. This guide tells the coordinator how to launch, message, check and stop a worker with the `conductor` command line tool, and what to record in Armada afterwards. It was checked against `conductor` 0.89.x (the desktop app's CLI, macOS) and 0.1.x (the CLI inside a Conductor Cloud workspace, Linux); every command below works in both. `conductor --version` prints yours; if a flag is refused, compare with `conductor <command> --help`.\n\n- Always pass `--json` and read fields with `jq`. Exit codes: 0 ok, 1 runtime error, 2 usage error, 3 authentication, 4 server error.\n- On exit code 3, `conductor auth whoami` checks the token the CLI uses (it exits 0 when the token works). Do not rely on `conductor auth status`: it only looks for a macOS Keychain entry and fails on Linux (\"Keychain storage is only supported on macOS\"). In a Conductor Cloud workspace the CLI reads `CONDUCTOR_API_KEY` from the environment and needs no login; on a Mac, `conductor auth login` stores a token in the Keychain.\n- A worker is one workspace with one session. Its Armada handle is `<workspaceId>/<sessionId>`; the worker's claim comment carries it, so `armada status` and the ticket always lead back to the session.\n- A worker needs no key in its workspace: the prompt of `armada brief` carries a one-time launch token, and the worker's first command exchanges it for a session limited to its ticket, through which Armada gives each command its keys. The token works once, within the hour, so a copy left in a transcript is useless once used.\n- Never type a secret value into a command, a file or a message: name the variable and let your shell expand it. The expanded value is still in the `conductor` process's arguments while it runs, so launch from a machine only you use.\n\n## Launch\n\n1. Pick a ready ticket from `armada status` that does not collide with work in flight.\n2. Run `armada brief ABC-12` (with `--profile <name> --reason \"<why>\"` when you override the routed profile), right before the launch. Read the profile (agent, model, effort, fast mode), the `Launch:` line and the warnings. Resolve every warning first: an open blocker, a ticket already in flight.\n - `Launch: one-time token in the prompt` is the normal case: the worker signs in to Armada with it and fetches its own keys. Its workspace receives no key at all.\n - `Launch: no launch token (…)` says why. Not signed in: `armada login` (a headless coordinator sets `ARMADA_API_KEY`), then brief again; `armada doctor` checks the sign-in. Launch with keys (step 4, second block) only on an Armada that keeps no keys yet (no accounts or no vault: a self-hosted one, CI, or before the owner's switch to the Keys page).\n3. Write the prompt to a file only you can read, and add what only you know (the boundary with a parallel worker, a decision not yet on the ticket). The token in it works once, within the hour: brief again when that hour has passed before the launch.\n\n```sh\n(umask 077; armada brief ABC-12 --prompt > /tmp/abc-12-brief.md)\n```\n\n4. Create the workspace with every value from the profile. Never leave the agent, model or effort to Conductor's defaults. Add `--fast-mode` when the profile says fast mode. Run the whole block as one command: shell state does not carry over between separate calls.\n\n```sh\nconductor --json workspace create \\\n --repo-url https://github.com/<owner>/<name> \\\n --branch main \\\n --name \"ABC-12 <short title>\" \\\n --agent claude --model opus-5-5-1m --effort high \\\n --message-file - \\\n --env ARMADA_TICKET=ABC-12 \\\n < /tmp/abc-12-brief.md > /tmp/abc-12-launch.json\nrm -f /tmp/abc-12-brief.md\njq -r '\"\\(.workspaceId)/\\(.sessionId)\"' /tmp/abc-12-launch.json\n```\n\nWithout a launch token (an Armada that keeps no keys), pass the keys the brief's environment table marks `required` or `optional`, from your shell or from Armada's credentials file (`in credentials file`: the `set -a` line loads it without printing it; drop it when every variable is set in your shell). The subshell keeps the keys out of the rest of your session; drop an optional `--env` line whose variable you do not have. When Conductor's organization environment still holds the keys, every workspace already has them: use the first block.\n\n```sh\n(\n set -a; . \"${XDG_CONFIG_HOME:-$HOME/.config}/armada/credentials\"; set +a\n [ -n \"$LINEAR_API_KEY\" ] || { echo \"LINEAR_API_KEY is missing\" >&2; exit 1; }\n conductor --json workspace create \\\n --repo-url https://github.com/<owner>/<name> \\\n --branch main \\\n --name \"ABC-12 <short title>\" \\\n --agent claude --model opus-5-5-1m --effort high \\\n --message-file - \\\n --env ARMADA_TICKET=ABC-12 \\\n --env LINEAR_API_KEY=\"$LINEAR_API_KEY\" \\\n --env ARMADA_TURSO_URL=\"$ARMADA_TURSO_URL\" \\\n --env ARMADA_TURSO_TOKEN=\"$ARMADA_TURSO_TOKEN\" \\\n < /tmp/abc-12-brief.md > /tmp/abc-12-launch.json\n)\nrm -f /tmp/abc-12-brief.md\n```\n\n- `--branch` is the base branch (the default branch). Conductor creates a branch named `conductor/<slug of --name>`; the brief tells the worker to rename it to the ticket's branch.\n- The output has `workspaceId`, `sessionId`, `deepLink` and `initialMessage` (`messageId`, `state: \"queued\"`). Keep the handle the `jq` line prints, and give the owner the `deepLink` when they want to watch.\n- Conductor sets `CONDUCTOR_WORKSPACE_ID` and `CONDUCTOR_SESSION_ID` inside the workspace, and signs `gh` in for the worker's pushes. The brief's first commands install your Armada version (`npm install -g`), sign in with the launch token (`armada login --launch-token`) and claim the ticket. `--env` values are not shown back by `workspace get`.\n- Keys in Conductor's organization environment reach every workspace, workers included: once Armada keeps the organization's keys, they belong on Armada's Keys page, not there.\n- An unknown agent, model or effort fails the command. Check the ids with `conductor model` (each agent's models, efforts and defaults) and fix the profile in `armada.toml`.\n\n5. **Check the claim.** Within a few minutes, `armada status` lists the ticket in flight, phase `planning`, runtime `Conductor`, and the ticket's claim comment reads `session: <workspaceId>/<sessionId>` and `profile: <name>`. No claim after ten minutes: read the transcript (Status section). A worker whose launch token was refused (already used, or more than an hour old) needs a new one: `armada brief ABC-12 --prompt` again, and message it only the `armada login --launch-token …` line of the new prompt (Message section). A worker cut off from Armada was revoked on the dashboard (Organization > Workers says by whom) or left idle for three days: ask the owner before you give a revoked worker a new token. If the worker cannot claim for another reason, fix the cause and message it; as a last resort record the handle yourself with `armada claim ABC-12 --runtime conductor --handle <workspaceId>/<sessionId> --profile <name>`, adding the brief's `--reason` for an override.\n\n## Message\n\n```sh\nprintf '%s\\n' \"Plan approved. Go on.\" | conductor --json message create --session <sessionId> --message-file -\nconductor --json message create --session <sessionId> --message-file - < /tmp/abc-12-answer.md\n```\n\nThe output is `{\"messageId\": …, \"state\": \"sent\"}`. Exit code 0 means Conductor accepted the message, not that the worker read it: check that the session turns `working`, then read its reply in the transcript. Use it to deliver an answer, a plan approval, or a heads-up that the default branch moved. Then record it in Armada: `armada answer <item> \"<answer>\"` for a question from `armada inbox`, `armada answer --note ABC-12 \"<message>\"` for a message the worker did not ask for.\n\n## Status\n\n```sh\nconductor --json session status <sessionId>\n```\n\nThe output is `{\"workspaceId\", \"sessionId\", \"status\", \"updatedAt\"}`. For a worker:\n\n- `working`: a turn is running. A silent worker that is `working` is busy (a long build or test run): leave it, and read the transcript if it stays silent past twice `policy.silence_minutes`.\n- `idle`: no turn is running. The worker finished its turn: it handed back, it waits for an answer, or it stopped without finishing. If `armada status` does not show it `ready-to-merge`, `awaiting-approval` or `blocked`, it has stopped: read its last reply, then message it to go on, or release and relaunch the ticket.\n- `error`: the last turn failed (agent or provider failure). Read the transcript and message it to resume; if it fails again, cancel, archive, release and relaunch.\n- Right after launch the session is `idle` for a few seconds while the workspace is initializing and the first message is queued; it turns `working` when the agent starts.\n\nThe workspace itself: `conductor --json workspace status <workspaceId>` gives `status` `initializing`, `ready` or `archived`.\n\n**Read the transcript** to see what a worker did or said. Events come oldest first, 100 per page; `hasMore` tells when to fetch the next page with `--after` the last event id. Keep the last id you read and poll from it.\n\n```sh\nconductor --json session message <sessionId> --limit 100 > /tmp/abc-12-events.json\njq -r '.hasMore, .data[-1].id' /tmp/abc-12-events.json\nconductor --json session message <sessionId> --after <lastEventId> --limit 100\n```\n\nThe second line prints whether more pages exist and the id to continue from. `.content.rawPayload` is the agent's own event format, so the filters depend on the worker's agent (the `agent` of its profile in `armada.toml`).\n\nA `claude` worker: each turn's final reply, then the commands and tools it ran.\n\n```sh\njq -r '.data[] | select(.content.rawPayload.type == \"result\") | .content.rawPayload | \"error=\\(.is_error)\\n\\(.result)\"' /tmp/abc-12-events.json\njq -r '.data[] | select(.content.rawPayload.type == \"assistant\") | .content.rawPayload.message.content[] | select(.type == \"tool_use\") | .input.command // .name' /tmp/abc-12-events.json\n```\n\nA `codex` worker: its events are `.content.rawPayload.event`, each item once as `item.started` and once as `item.completed`; read the completed ones. Its messages (`phase` is `commentary` along the way, `final_answer` at the end of a turn), then each command with its exit code, and its tool calls (Linear and other MCP servers).\n\n```sh\njq -r '.data[] | .content.rawPayload.event | select(.type == \"item.completed\") | .item | select(.type == \"agentMessage\") | \"[\\(.phase)] \\(.text)\"' /tmp/abc-12-events.json\njq -r '.data[] | .content.rawPayload.event | select(.type == \"item.completed\") | .item | select(.type == \"commandExecution\") | \"exit=\\(.exitCode) \\(.command)\"' /tmp/abc-12-events.json\njq -r '.data[] | .content.rawPayload.event | select(.type == \"item.completed\") | .item | select(.type == \"mcpToolCall\") | \"\\(.server) \\(.tool)\"' /tmp/abc-12-events.json\n```\n\nAnother agent, or a filter that prints nothing: count the event types, look at one event of the type you need, and adapt the filter.\n\n```sh\njq -r '.data[].content.rawPayload | .type // .event.type // \"(no payload)\"' /tmp/abc-12-events.json | sort | uniq -c\n```\n\n## Stop and archive\n\n```sh\nconductor --json session cancel <sessionId>\nconductor --json workspace archive <workspaceId>\n```\n\n- `session cancel` stops the running turn: `{\"status\", \"canceledQueuedMessages\"}`, and the session is `idle` within seconds. The workspace stays; a message starts a new turn. Use it on a worker that runs the wrong thing.\n- `workspace archive` answers `{\"status\": \"archived\"}`. Archive a worker's workspace after its pull request is merged, or after `armada release --ticket ABC-12 --reason \"<why>\"` for a worker that stops without handing back. The branch and the pull request stay on GitHub.\n- **Wait for `idle` before archiving.** A hand-back often arrives while the worker's session is still `working`: `armada report ready-to-merge` runs inside its last turn, which then writes its final reply. Archive only once `session status` answers `idle`. Poll it every 15 seconds; if it is still `working` after 10 minutes, cancel the turn and archive (the transcript keeps what it was doing). Run the whole block as one command; it can take up to 10 minutes, so run it in the background or give it a longer command timeout:\n\n```sh\nfor i in $(seq 40); do\n [ \"$(conductor --json session status <sessionId> | jq -r .status)\" = working ] || break\n sleep 15\ndone\n[ \"$(conductor --json session status <sessionId> | jq -r .status)\" = working ] && conductor --json session cancel <sessionId>\nconductor --json workspace archive <workspaceId>\n```\n- After an archive, `session status` still answers `idle`; `workspace status` says `archived`.\n";
4925
5007
 
4926
5008
  // ../../skills/armada-worker/SKILL.md
4927
5009
  var SKILL_default3 = `---
@@ -4942,7 +5024,7 @@ You are a worker. You own exactly one ticket, named in your launch brief. You tu
4942
5024
 
4943
5025
  ## Steps
4944
5026
 
4945
- 1. **Claim** with the exact command your brief starts with, for example \`armada claim <ticket> --runtime conductor --handle "$CONDUCTOR_WORKSPACE_ID/$CONDUCTOR_SESSION_ID"\`. Install the Armada version the brief names first; if it gives a fallback command, use it wherever this skill says \`armada\`. It assigns the ticket, moves it to In Progress, sets \`Agent phase = planning\` and your \`Agent runtime\`, and posts the \`Agent claim\` comment. If it refuses because another claim exists, stop: the older claim wins.
5027
+ 1. **Claim** with the exact commands your brief starts with, for example \`armada claim <ticket> --runtime conductor --handle "$CONDUCTOR_WORKSPACE_ID/$CONDUCTOR_SESSION_ID"\`. Install the Armada version the brief names first; if it gives a fallback command, use it wherever this skill says \`armada\`. When the brief has an \`armada login --launch-token <token>\` line, run it once, right after the install and before the claim: it signs your workspace in to Armada for your ticket only, and Armada then gives your \`claim\`, \`report\`, \`ask\` and \`release\` their keys, so none is needed in your environment (do not ask for one; \`armada whoami\` shows the sign-in). The token works once, within the hour; never copy it anywhere else. If it is refused, or a later command says you were cut off from Armada, stop and say so in your reply: the coordinator decides whether you get a new one. The claim assigns the ticket, moves it to In Progress, sets \`Agent phase = planning\` and your \`Agent runtime\`, and posts the \`Agent claim\` comment. If it refuses because another claim exists, stop: the older claim wins.
4946
5028
  2. **Branch.** Use the branch named after the ticket (the tracker suggests one, for example \`feature/abc-12-short-title\`), created from the latest default branch.
4947
5029
  3. **Plan.** Write the plan: what changes, how it is tested, and the checks a person could observe when it is done. If the ticket's plan policy or your brief says plans are pre-approved, post the full plan with \`armada report implementing --message "<plan>"\` and go on; do not enter \`awaiting-approval\`. Otherwise post the full plan with \`armada report awaiting-approval --message "<plan>"\`: it creates a \`plan\` item in the coordinator's inbox. Push your branch and wait for the coordinator's decision in your session. On approval, report \`implementing\`; on amendments, report \`planning\`, revise the plan and submit it for approval again.
4948
5030
  4. **Implement** test-first. A material change to the approved plan needs a new approval.
@@ -5325,7 +5407,7 @@ async function loadStatus(config, opts) {
5325
5407
  });
5326
5408
  }
5327
5409
  // package.json
5328
- var version = "0.1.17";
5410
+ var version = "0.1.19";
5329
5411
 
5330
5412
  // src/io.ts
5331
5413
  class UsageError extends Error {
@@ -5355,7 +5437,7 @@ var fromLease = (lease) => ({
5355
5437
  token: lease.token,
5356
5438
  detail: `a token made for this terminal, expires ${hhmm(lease.expiresAt)}`
5357
5439
  });
5358
- async function fromArmada(io, machine, credentials) {
5440
+ async function fromArmada(io, machine, credentials, purpose) {
5359
5441
  const signIn = credentials.armadaSignIn;
5360
5442
  if (!signIn)
5361
5443
  return null;
@@ -5371,12 +5453,14 @@ async function fromArmada(io, machine, credentials) {
5371
5453
  };
5372
5454
  let answer;
5373
5455
  try {
5374
- answer = await armadaApi({ url: credentials.armadaApi.url, ...io.fetch ? { fetch: io.fetch } : {} }).credentials(signIn, lease ? { revision: lease.revision, expiresAt: lease.expiresAt } : null);
5456
+ answer = await armadaApi({ url: credentials.armadaApi.url, ...io.fetch ? { fetch: io.fetch } : {} }).credentials(signIn, lease ? { revision: lease.revision, expiresAt: lease.expiresAt } : null, purpose);
5375
5457
  } catch (err) {
5376
5458
  if (!(err instanceof ArmadaApiError))
5377
5459
  throw err;
5378
5460
  if (err.signedOut || err.status === 403) {
5379
5461
  await keep(null);
5462
+ if (signIn.kind === "worker")
5463
+ throw err;
5380
5464
  io.stderr(`! Armada gave no keys (${err.message}); using this machine's${err.next ? `. Next: ${err.next}` : ""}
5381
5465
  `);
5382
5466
  return null;
@@ -5415,8 +5499,15 @@ async function fromArmada(io, machine, credentials) {
5415
5499
  turso: t?.kind === "stored" ? { url: t.url, token: t.token, detail: `the stored Turso access of ${answer.organization.name}` } : null
5416
5500
  };
5417
5501
  }
5418
- async function loadCredentials(io, { armada = true } = {}) {
5502
+ async function loadCredentials(io, { armada = true, worker } = {}) {
5419
5503
  const machine = await loadMachine(io);
5504
+ let ticket = null;
5505
+ if (worker)
5506
+ try {
5507
+ ticket = worker.ticket(storedWorkers(machine.store?.values ?? {}).map((w) => w.ticket));
5508
+ } catch {
5509
+ ticket = null;
5510
+ }
5420
5511
  let gh;
5421
5512
  const sources = {
5422
5513
  env: io.env,
@@ -5426,12 +5517,21 @@ async function loadCredentials(io, { armada = true } = {}) {
5426
5517
  return gh;
5427
5518
  },
5428
5519
  ...machine.store ? { store: machine.store.values } : {},
5429
- ...machine.personal ? { personal: machine.personal.config } : {}
5520
+ ...machine.personal ? { personal: machine.personal.config } : {},
5521
+ ticket
5430
5522
  };
5431
5523
  const local = resolveCredentials(sources);
5432
- if (!armada || !local.armadaSignIn || !wantsArmada(io.env))
5524
+ const signIn = local.armadaSignIn;
5525
+ const purpose = worker && ticket ? { command: worker.command, project: worker.project, ticket } : null;
5526
+ if (signIn?.kind === "worker" && armada) {
5527
+ if (signIn.project !== worker?.project)
5528
+ throw new UsageError(`the worker session of ${signIn.ticket} is for the project ${signIn.project}, not ${worker?.project} (armada.toml): this repository is not its own`, `cd into the repository of ${signIn.project}`);
5529
+ const keys = await fromArmada(io, machine, local, purpose);
5530
+ return { machine, credentials: keys ? resolveCredentials({ ...sources, armada: keys }) : local };
5531
+ }
5532
+ if (!armada || !signIn || !wantsArmada(io.env))
5433
5533
  return { machine, credentials: local };
5434
- const keys = await fromArmada(io, machine, local);
5534
+ const keys = await fromArmada(io, machine, local, purpose);
5435
5535
  return { machine, credentials: keys ? resolveCredentials({ ...sources, armada: keys }) : local };
5436
5536
  }
5437
5537
  var describeSource = (s) => {
@@ -5535,8 +5635,9 @@ function buildAuthStatus(machine, credentials) {
5535
5635
  personalConfig: machine.paths && machine.personal ? { path: machine.paths.config, exists: machine.personal.exists } : null,
5536
5636
  signIn: {
5537
5637
  api: credentials.armadaApi,
5538
- method: credentials.armadaSignIn?.kind ?? null,
5539
- source: credentials.armadaSignIn?.source ?? null
5638
+ method: credentials.armadaSignIn?.kind === "worker" ? null : credentials.armadaSignIn?.kind ?? null,
5639
+ source: credentials.armadaSignIn?.kind === "worker" ? null : credentials.armadaSignIn?.source ?? null,
5640
+ workers: credentials.workerTickets
5540
5641
  },
5541
5642
  warnings: storeWarnings(machine)
5542
5643
  };
@@ -5559,6 +5660,8 @@ function renderAuthStatus(status) {
5559
5660
  const api = signIn.api.source.kind === "default" ? "built in" : describeSource(signIn.api.source);
5560
5661
  lines.push("", "Armada sign-in", ` API ${signIn.api.url} (${api})`);
5561
5662
  lines.push(signIn.method && signIn.source ? ` Signed in with ${signIn.method === "session" ? "the session of `armada login`" : "an organization API key"}, from the ${describeSource(signIn.source)}; \`armada whoami\` shows who` : " Signed in no: run `armada login`, or set ARMADA_API_KEY on a headless coordinator");
5663
+ if (signIn.workers.length)
5664
+ lines.push(` Workers ${signIn.workers.join(", ")}: the worker session of \`armada login --launch-token\` signs in that ticket's claim, report, ask and release`);
5562
5665
  return `${lines.join(`
5563
5666
  `)}
5564
5667
  `;
@@ -5603,6 +5706,7 @@ function renderBrief(b) {
5603
5706
  ...b.routing ? [`Chosen by: ${b.routing.why}`] : [],
5604
5707
  `Repository: ${b.repository.url}`,
5605
5708
  `Branch: ${b.ticket.branch ?? "none suggested by Linear"} (the worker renames its workspace branch to it)`,
5709
+ `Launch: ${b.launch ? `one-time token in the prompt, valid until ${b.launch.expiresAt.slice(0, 16).replace("T", " ")} UTC: the worker needs no key` : `no launch token${b.noLaunch ? ` (${b.noLaunch})` : ""}: pass the keys below in the worker's environment`}`,
5606
5710
  "",
5607
5711
  "Environment to pass (values are never printed):",
5608
5712
  ...b.environment.map((v) => {
@@ -5617,6 +5721,29 @@ function renderBrief(b) {
5617
5721
  return out.join(`
5618
5722
  `);
5619
5723
  }
5724
+ function launcher(io, config, credentials) {
5725
+ return async (ticket) => {
5726
+ const signIn = credentials.armadaSignIn;
5727
+ if (!signIn)
5728
+ return {
5729
+ reason: "launch tokens need this terminal signed in to an Armada with accounts: armada login",
5730
+ warn: false
5731
+ };
5732
+ const url = credentials.armadaApi.url;
5733
+ try {
5734
+ const t = await armadaApi({ url, ...io.fetch ? { fetch: io.fetch } : {} }).launchToken(signIn, {
5735
+ project: config.project.slug,
5736
+ ticket
5737
+ });
5738
+ const builtIn = armadaAddress(url) === armadaAddress(DEFAULT_ARMADA_API_URL);
5739
+ return { token: t.token, expiresAt: t.expiresAt, apiUrl: builtIn ? null : armadaAddress(url) };
5740
+ } catch (err) {
5741
+ if (!(err instanceof ArmadaApiError))
5742
+ throw err;
5743
+ return { reason: err.message, warn: true };
5744
+ }
5745
+ };
5746
+ }
5620
5747
  async function brief2(io, config, credentials, a, version) {
5621
5748
  const [ticket, ...extra] = a.rest;
5622
5749
  if (!ticket)
@@ -5649,6 +5776,7 @@ async function brief2(io, config, credentials, a, version) {
5649
5776
  version,
5650
5777
  env: io.env,
5651
5778
  stored: STORED_KEYS.filter((k) => credentials.sources[k.name]?.kind === "store").map((k) => k.variable),
5779
+ launch: launcher(io, config, credentials),
5652
5780
  ...io.fetch ? { fetch: io.fetch } : {},
5653
5781
  ...io.now ? { now: io.now } : {}
5654
5782
  });
@@ -5670,6 +5798,198 @@ async function brief2(io, config, credentials, a, version) {
5670
5798
  return 0;
5671
5799
  }
5672
5800
 
5801
+ // src/login.ts
5802
+ var hostOf = (url) => {
5803
+ try {
5804
+ return new URL(url).host;
5805
+ } catch {
5806
+ return url;
5807
+ }
5808
+ };
5809
+ var apiOf = (io, url) => armadaApi({ url, ...io.fetch ? { fetch: io.fetch } : {} });
5810
+ var storedAt = (machine) => armadaAddress(machine.store?.values[SIGNED_IN_TO_VARIABLE]?.trim() || DEFAULT_ARMADA_API_URL);
5811
+ var sleepOf = (io) => io.sleep ?? ((ms) => new Promise((done) => setTimeout(done, ms)));
5812
+ function requireSignIn(credentials) {
5813
+ if (credentials.armadaSignIn)
5814
+ return credentials.armadaSignIn;
5815
+ const elsewhere = credentials.armadaSignInElsewhere;
5816
+ if (elsewhere)
5817
+ throw new UsageError(`this terminal is signed in to ${hostOf(elsewhere)}, not to ${hostOf(credentials.armadaApi.url)} (named by ARMADA_API_URL or [api] url); its sign-in is never sent to another Armada`, `armada login to sign in to ${hostOf(credentials.armadaApi.url)}, or point ARMADA_API_URL back to ${elsewhere}`);
5818
+ throw new UsageError(`not signed in to Armada (${hostOf(credentials.armadaApi.url)}). A person signs in with \`armada login\`; a headless coordinator sets ${API_KEY_VARIABLE} to an organization API key`, LOGIN_NEXT);
5819
+ }
5820
+ function describeIdentity(identity) {
5821
+ const org = identity.organization ? `${identity.organization.name}${identity.organization.role ? ` (${identity.organization.role})` : ""}` : "no organization yet";
5822
+ if (identity.via === "api-key") {
5823
+ const key = identity.apiKey?.name ?? identity.apiKey?.start ?? "an API key";
5824
+ return `the API key "${key}" of ${org}`;
5825
+ }
5826
+ if (identity.via === "worker") {
5827
+ const w = identity.worker;
5828
+ return w ? `the worker of ${w.ticket} (${w.project}), launched by ${w.launchedBy}, in ${org}` : `a worker of ${org}`;
5829
+ }
5830
+ const who = identity.user ? identity.user.name ? `${identity.user.name} <${identity.user.email}>` : identity.user.email : "?";
5831
+ return `${who}, ${org}`;
5832
+ }
5833
+ function paths(io) {
5834
+ const p = machinePaths(io.env);
5835
+ if (p)
5836
+ return p;
5837
+ throw new UsageError(`neither HOME nor XDG_CONFIG_HOME is set, so this machine has no place to keep a sign-in. Set ${API_KEY_VARIABLE} in the environment instead.`);
5838
+ }
5839
+ async function readApiKey(io) {
5840
+ if (io.interactive && io.prompt)
5841
+ return io.prompt("Armada API key (hidden): ", { hidden: true });
5842
+ if (io.readStdin)
5843
+ return io.readStdin();
5844
+ return null;
5845
+ }
5846
+ async function loginWithApiKey(io, credentials) {
5847
+ const p = paths(io);
5848
+ const answer = await readApiKey(io);
5849
+ if (answer === null) {
5850
+ io.stderr(`Cancelled. Nothing was saved.
5851
+ `);
5852
+ return 130;
5853
+ }
5854
+ const key = answer.trim();
5855
+ if (!key)
5856
+ throw new UsageError('no API key given. Paste it at the prompt, or pipe it in: printf %s "$KEY" | armada login --api-key', "the Organization page of Armada, where an owner creates one");
5857
+ const url = credentials.armadaApi.url;
5858
+ const identity = await apiOf(io, url).whoami({ kind: "api-key", key });
5859
+ await updateCredentialStore(p, {
5860
+ [API_KEY_VARIABLE]: key,
5861
+ [SESSION_TOKEN_VARIABLE]: null,
5862
+ [SIGNED_IN_TO_VARIABLE]: armadaAddress(url),
5863
+ [TURSO_LEASE_VARIABLE]: null
5864
+ });
5865
+ io.stdout(`Signed in to ${hostOf(credentials.armadaApi.url)} as ${describeIdentity(identity)}.
5866
+ The key is stored in ${p.credentials}.
5867
+ `);
5868
+ return 0;
5869
+ }
5870
+ async function loginWithLaunchToken(io, credentials, token, apiUrl) {
5871
+ const p = paths(io);
5872
+ let url = credentials.armadaApi.url;
5873
+ if (apiUrl) {
5874
+ apiBaseUrl(apiUrl);
5875
+ if (credentials.armadaApi.source.kind !== "default" && armadaAddress(apiUrl) !== armadaAddress(url))
5876
+ throw new UsageError(`the launch message names ${hostOf(apiUrl)}, but ARMADA_API_URL or [api] url names ${hostOf(url)}`, "unset ARMADA_API_URL, or ask the coordinator for a launch from that Armada");
5877
+ url = apiUrl;
5878
+ }
5879
+ const session = await apiOf(io, url).exchangeLaunchToken(token.trim());
5880
+ const w = session.worker;
5881
+ await updateCredentialStore(p, {
5882
+ [workerSessionVariable(w.ticket)]: formatWorkerSession({
5883
+ api: armadaAddress(url),
5884
+ token: session.token,
5885
+ ticket: w.ticket,
5886
+ project: w.project,
5887
+ organization: session.organization.id,
5888
+ id: w.id
5889
+ })
5890
+ });
5891
+ io.stdout(`Signed in to ${hostOf(url)} as the worker of ${w.ticket} (${w.project}) in ${session.organization.name}, launched by ${w.launchedBy}.
5892
+ This terminal claims, reports, asks and releases ${w.ticket} only; Armada gives each of those commands its keys.
5893
+ `);
5894
+ return 0;
5895
+ }
5896
+ async function login(io, o) {
5897
+ if (o.apiUrl !== null && o.launchToken === null)
5898
+ throw new UsageError("--api-url goes with --launch-token: it names the Armada of the launch message");
5899
+ if (o.launchToken !== null && o.apiKey)
5900
+ throw new UsageError("pass --api-key or --launch-token, not both");
5901
+ const { machine, credentials } = await loadCredentials(io, { armada: false });
5902
+ if (o.launchToken !== null) {
5903
+ if (!o.launchToken.trim())
5904
+ throw new UsageError("--launch-token needs the token of the launch message");
5905
+ return loginWithLaunchToken(io, credentials, o.launchToken, o.apiUrl);
5906
+ }
5907
+ const host = hostOf(credentials.armadaApi.url);
5908
+ if (credentials.armadaSignIn?.source.kind === "env")
5909
+ io.stderr(`! ${API_KEY_VARIABLE} is set in the environment: it wins over what \`armada login\` stores.
5910
+ `);
5911
+ if (o.apiKey)
5912
+ return loginWithApiKey(io, credentials);
5913
+ const p = paths(io);
5914
+ const url = credentials.armadaApi.url;
5915
+ const api = apiOf(io, url);
5916
+ const code = await api.startDeviceLogin();
5917
+ io.stderr(`First copy your one-time code: ${displayCode(code.userCode)}
5918
+ Then confirm it at ${code.verificationUriComplete}
5919
+ `);
5920
+ if (io.interactive && io.openUrl?.(code.verificationUriComplete))
5921
+ io.stderr(`Opening it in your browser.
5922
+ `);
5923
+ io.stderr(`Waiting for the confirmation (the code expires in ${Math.round(code.expiresInSeconds / 60)} minutes)…
5924
+ `);
5925
+ const token = await waitForApproval({ api, code, sleep: sleepOf(io), now: io.now ?? (() => new Date) });
5926
+ const identity = await api.whoami({ kind: "session", token });
5927
+ const previous = machine.store?.values[SESSION_TOKEN_VARIABLE]?.trim();
5928
+ await updateCredentialStore(p, {
5929
+ [SESSION_TOKEN_VARIABLE]: token,
5930
+ [API_KEY_VARIABLE]: null,
5931
+ [SIGNED_IN_TO_VARIABLE]: armadaAddress(url),
5932
+ [TURSO_LEASE_VARIABLE]: null
5933
+ });
5934
+ if (previous && previous !== token)
5935
+ await apiOf(io, storedAt(machine)).signOut({ kind: "session", token: previous }).catch(() => {});
5936
+ io.stdout(`Signed in to ${host} as ${describeIdentity(identity)}.
5937
+ `);
5938
+ if (!identity.organization)
5939
+ io.stdout(`Next: accept an invitation, or create an organization, at ${new URL("welcome", apiBaseUrl(credentials.armadaApi.url))}
5940
+ `);
5941
+ return 0;
5942
+ }
5943
+ async function whoami(io, json) {
5944
+ let { credentials } = await loadCredentials(io, { armada: false });
5945
+ const [only] = credentials.workerTickets;
5946
+ if (!credentials.armadaSignIn && only && credentials.workerTickets.length === 1)
5947
+ ({ credentials } = await loadCredentials(io, {
5948
+ armada: false,
5949
+ worker: { command: "whoami", project: "", ticket: () => only }
5950
+ }));
5951
+ const signIn = requireSignIn(credentials);
5952
+ const identity = await apiOf(io, credentials.armadaApi.url).whoami(signIn);
5953
+ if (json) {
5954
+ const out = { ...identity, api: credentials.armadaApi.url, source: signIn.source };
5955
+ io.stdout(`${JSON.stringify(out, null, 2)}
5956
+ `);
5957
+ return 0;
5958
+ }
5959
+ io.stdout(`Signed in to ${hostOf(credentials.armadaApi.url)} as ${describeIdentity(identity)}.
5960
+ `);
5961
+ return 0;
5962
+ }
5963
+ async function logout(io) {
5964
+ const { machine } = await loadCredentials(io, { armada: false });
5965
+ const p = paths(io);
5966
+ const at = storedAt(machine);
5967
+ const workers = (machine.store?.assigned ?? []).filter((k) => k.startsWith(WORKER_SESSION_PREFIX));
5968
+ const stored = [SESSION_TOKEN_VARIABLE, API_KEY_VARIABLE, TURSO_LEASE_VARIABLE, ...workers].filter((k) => machine.store?.assigned.includes(k));
5969
+ const session = machine.store?.values[SESSION_TOKEN_VARIABLE]?.trim();
5970
+ if (session) {
5971
+ await apiOf(io, at).signOut({ kind: "session", token: session }).catch((err) => io.stderr(`! the session could not be revoked on Armada (${err instanceof Error ? err.message : String(err)}); it expires on its own
5972
+ `));
5973
+ }
5974
+ if (stored.length) {
5975
+ await updateCredentialStore(p, {
5976
+ [SESSION_TOKEN_VARIABLE]: null,
5977
+ [API_KEY_VARIABLE]: null,
5978
+ [SIGNED_IN_TO_VARIABLE]: null,
5979
+ [TURSO_LEASE_VARIABLE]: null,
5980
+ ...Object.fromEntries(workers.map((k) => [k, null]))
5981
+ });
5982
+ io.stdout(`Signed out of ${hostOf(at)}: removed the sign-in from ${p.credentials}.
5983
+ `);
5984
+ } else
5985
+ io.stdout(`This terminal was not signed in to Armada (nothing in ${p.credentials}).
5986
+ `);
5987
+ if (io.env[API_KEY_VARIABLE]?.trim())
5988
+ io.stdout(`${API_KEY_VARIABLE} is still set in the environment, and still signs this terminal in. Unset it to stop.
5989
+ `);
5990
+ return 0;
5991
+ }
5992
+
5673
5993
  // src/repo.ts
5674
5994
  import { lstat, mkdir as mkdir2, readdir, readFile as readFile2, readlink, rm as rm2, symlink, writeFile } from "node:fs/promises";
5675
5995
  import { dirname, join as join2, relative, sep } from "node:path";
@@ -5761,7 +6081,54 @@ async function gitRoot(exec, cwd) {
5761
6081
  }
5762
6082
 
5763
6083
  // src/doctor.ts
5764
- async function labelChecks(io, root) {
6084
+ var SIGN_IN_FIX = `\`armada login\`; a headless coordinator sets ${API_KEY_VARIABLE} to an organization API key`;
6085
+ async function signInChecks(io, credentials) {
6086
+ const host = hostOf(credentials.armadaApi.url);
6087
+ const signIn = credentials.armadaSignIn;
6088
+ const warning = (message, fix) => [{ id: "sign-in", level: "warning", message, fix }];
6089
+ if (!signIn) {
6090
+ const elsewhere = credentials.armadaSignInElsewhere;
6091
+ if (elsewhere)
6092
+ return warning(`this terminal is signed in to ${hostOf(elsewhere)}, not to ${host} (named by ARMADA_API_URL or [api] url)`, `\`armada login\` to sign in to ${host}, or point ARMADA_API_URL back to ${elsewhere}`);
6093
+ const workers = credentials.workerTickets.length ? `
6094
+ The worker session${credentials.workerTickets.length === 1 ? "" : "s"} of ${credentials.workerTickets.join(", ")} sign${credentials.workerTickets.length === 1 ? "s" : ""} in only that ticket's claim, report, ask and release.` : "";
6095
+ return warning(`not signed in to Armada (${host}): \`armada brief\` gives workers no launch token, so each worker needs the fleet's keys in its environment${workers}`, SIGN_IN_FIX);
6096
+ }
6097
+ try {
6098
+ const identity = await armadaApi({
6099
+ url: credentials.armadaApi.url,
6100
+ ...io.fetch ? { fetch: io.fetch } : {}
6101
+ }).whoami(signIn);
6102
+ if (!identity.organization)
6103
+ return warning(`signed in to ${host} as ${describeIdentity(identity)}: launch tokens need an organization`, `create or join an organization on ${credentials.armadaApi.url}`);
6104
+ return [
6105
+ { id: "sign-in", level: "ok", message: `signed in to ${host} as ${describeIdentity(identity)}`, fix: null }
6106
+ ];
6107
+ } catch (err) {
6108
+ if (!(err instanceof ArmadaApiError))
6109
+ throw err;
6110
+ if (err.signedOut)
6111
+ return warning(`the Armada sign-in of this terminal no longer works: ${err.message}`, signIn.kind === "api-key" && signIn.source.kind === "env" ? `replace ${API_KEY_VARIABLE} with a valid organization API key` : SIGN_IN_FIX);
6112
+ return warning(`Armada sign-in not checked: ${err.message}`, err.next ?? "run doctor again once Armada answers");
6113
+ }
6114
+ }
6115
+ function keyFileChecks(machine, credentials) {
6116
+ const store = machine.store;
6117
+ if (!store?.exists || !credentials.armadaSignIn)
6118
+ return [];
6119
+ const unneeded = STORED_KEYS.filter((k) => store.values[k.variable]?.trim() && credentials.sources[k.name]?.kind === "armada").map((k) => k.variable);
6120
+ if (!unneeded.length)
6121
+ return [];
6122
+ return [
6123
+ {
6124
+ id: "local-keys",
6125
+ level: "warning",
6126
+ message: `${store.path} still holds ${unneeded.join(", ")}, which Armada now gives this terminal: ${unneeded.length === 1 ? "it is" : "they are"} no longer needed`,
6127
+ fix: `\`armada auth logout\` removes ${unneeded.length === 1 ? "it" : "them"} from this machine; the sign-in to Armada stays`
6128
+ }
6129
+ ];
6130
+ }
6131
+ async function labelChecks(io, root, credentials) {
5765
6132
  const text = await fsRepoView(root).readFile(CONFIG_FILE);
5766
6133
  if (text === null)
5767
6134
  return [];
@@ -5773,14 +6140,14 @@ async function labelChecks(io, root) {
5773
6140
  return [];
5774
6141
  throw err;
5775
6142
  }
5776
- const { linearApiKey } = (await loadCredentials(io)).credentials;
6143
+ const { linearApiKey } = credentials;
5777
6144
  if (!linearApiKey)
5778
6145
  return [
5779
6146
  {
5780
6147
  id: "labels",
5781
6148
  level: "warning",
5782
- message: `Linear labels not checked: ${LINEAR_KEY.variable} is not set`,
5783
- fix: `set ${LINEAR_KEY.variable} or run \`armada auth login\`, then run doctor again`
6149
+ message: `Linear labels not checked: no Linear key (${LINEAR_KEY.variable})`,
6150
+ fix: `\`armada login\` to an Armada that keeps your organization's keys, or set ${LINEAR_KEY.variable}, then run doctor again`
5784
6151
  }
5785
6152
  ];
5786
6153
  try {
@@ -5799,7 +6166,13 @@ async function labelChecks(io, root) {
5799
6166
  }
5800
6167
  async function buildDoctor(io, armadaVersion) {
5801
6168
  const root = (io.exec ? await gitRoot(io.exec, io.cwd) : null) ?? io.cwd;
5802
- const checks = [...await checkRepository(fsRepoView(root), armadaVersion), ...await labelChecks(io, root)];
6169
+ const { machine, credentials } = await loadCredentials(io);
6170
+ const checks = [
6171
+ ...await checkRepository(fsRepoView(root), armadaVersion),
6172
+ ...await signInChecks(io, credentials),
6173
+ ...keyFileChecks(machine, credentials),
6174
+ ...await labelChecks(io, root, credentials)
6175
+ ];
5803
6176
  return {
5804
6177
  schemaVersion: 1,
5805
6178
  root,
@@ -5877,12 +6250,12 @@ function statusEvents(config, credentials) {
5877
6250
  }
5878
6251
  };
5879
6252
  }
5880
- function currentTicket(io, config, explicit) {
6253
+ function currentTicket(io, config, explicit, workers = []) {
5881
6254
  const fromEnv = io.env.ARMADA_TICKET?.trim();
5882
6255
  const id = explicit?.trim() || fromEnv || (() => {
5883
6256
  const branch = io.gitBranch?.();
5884
6257
  return branch ? ticketFromBranch(branch, config.tracker.programRoot) : null;
5885
- })();
6258
+ })() || (workers.length === 1 ? workers[0] : null);
5886
6259
  if (!id)
5887
6260
  throw new UsageError("which ticket? pass --ticket <id>, set ARMADA_TICKET, or run on the ticket's branch");
5888
6261
  return id.toUpperCase();
@@ -6010,7 +6383,7 @@ async function report(io, config, credentials, a) {
6010
6383
  const message = await readMessage(io, a.options);
6011
6384
  if (!message?.trim() && phase !== "ready-to-merge")
6012
6385
  throw new UsageError("--message is required: what you did or what you are doing (first line = summary)");
6013
- const ticket = currentTicket(io, config, a.options.ticket);
6386
+ const ticket = currentTicket(io, config, a.options.ticket, credentials.workerTickets);
6014
6387
  return withContext(io, config, credentials, a.json, (ctx) => reportPhase(ctx, {
6015
6388
  ticket,
6016
6389
  phase,
@@ -6025,8 +6398,35 @@ async function release(io, config, credentials, a) {
6025
6398
  const reason = a.options.reason?.trim();
6026
6399
  if (!reason)
6027
6400
  throw new UsageError("--reason is required: why the ticket is given back");
6028
- const ticket = currentTicket(io, config, a.options.ticket);
6029
- return withContext(io, config, credentials, a.json, (ctx) => releaseTicket(ctx, { ticket, reason }));
6401
+ const ticket = currentTicket(io, config, a.options.ticket, credentials.workerTickets);
6402
+ const code = await withContext(io, config, credentials, a.json, (ctx) => releaseTicket(ctx, { ticket, reason }));
6403
+ await endWorkerSessions(io, config, credentials, ticket, "released", a.json);
6404
+ return code;
6405
+ }
6406
+ async function endWorkerSessions(io, config, credentials, ticket, reason, quiet) {
6407
+ const signIn = credentials.armadaSignIn;
6408
+ if (!signIn)
6409
+ return;
6410
+ const api = armadaApi({ url: credentials.armadaApi.url, ...io.fetch ? { fetch: io.fetch } : {} });
6411
+ try {
6412
+ if (signIn.kind === "worker") {
6413
+ const paths = machinePaths(io.env);
6414
+ if (paths)
6415
+ await updateCredentialStore(paths, { [workerSessionVariable(signIn.ticket)]: null });
6416
+ await api.signOut(signIn);
6417
+ if (!quiet)
6418
+ io.stdout(`Signed out of Armada: the worker session of ${signIn.ticket} has ended.
6419
+ `);
6420
+ return;
6421
+ }
6422
+ const ended = await api.endWorkers(signIn, { project: config.project.slug, ticket, reason });
6423
+ if (ended && !quiet)
6424
+ io.stdout(`Ended ${ended === 1 ? "the worker session" : `${ended} worker sessions`} of ${ticket} on Armada.
6425
+ `);
6426
+ } catch (err) {
6427
+ io.stderr(`armada: warning: the worker session of ${ticket} was not ended on Armada (${err instanceof Error ? err.message : String(err)}); it ends on its own after 72 hours without a command, and the Workers page revokes it
6428
+ `);
6429
+ }
6030
6430
  }
6031
6431
 
6032
6432
  // src/inbox.ts
@@ -6042,7 +6442,7 @@ async function ask(io, config, credentials, a) {
6042
6442
  if (!question?.trim())
6043
6443
  throw new UsageError('ask needs a question: armada ask "<question, the options, your recommendation>"');
6044
6444
  const options = (a.options.options ?? "").split("|").map((o) => o.trim()).filter(Boolean);
6045
- const ticket = currentTicket(io, config, a.options.ticket);
6445
+ const ticket = currentTicket(io, config, a.options.ticket, credentials.workerTickets);
6046
6446
  return withContext(io, config, credentials, a.json, (ctx) => askCoordinator(ctx, { ticket, question, options }));
6047
6447
  }
6048
6448
  async function answer(io, config, credentials, a) {
@@ -6326,151 +6726,6 @@ async function init(io, opts) {
6326
6726
  }
6327
6727
  }
6328
6728
 
6329
- // src/login.ts
6330
- var hostOf = (url) => {
6331
- try {
6332
- return new URL(url).host;
6333
- } catch {
6334
- return url;
6335
- }
6336
- };
6337
- var apiOf = (io, url) => armadaApi({ url, ...io.fetch ? { fetch: io.fetch } : {} });
6338
- var storedAt = (machine) => armadaAddress(machine.store?.values[SIGNED_IN_TO_VARIABLE]?.trim() || DEFAULT_ARMADA_API_URL);
6339
- var sleepOf = (io) => io.sleep ?? ((ms) => new Promise((done) => setTimeout(done, ms)));
6340
- function requireSignIn(credentials) {
6341
- if (credentials.armadaSignIn)
6342
- return credentials.armadaSignIn;
6343
- const elsewhere = credentials.armadaSignInElsewhere;
6344
- if (elsewhere)
6345
- throw new UsageError(`this terminal is signed in to ${hostOf(elsewhere)}, not to ${hostOf(credentials.armadaApi.url)} (named by ARMADA_API_URL or [api] url); its sign-in is never sent to another Armada`, `armada login to sign in to ${hostOf(credentials.armadaApi.url)}, or point ARMADA_API_URL back to ${elsewhere}`);
6346
- throw new UsageError(`not signed in to Armada (${hostOf(credentials.armadaApi.url)}). A person signs in with \`armada login\`; a headless coordinator sets ${API_KEY_VARIABLE} to an organization API key`, LOGIN_NEXT);
6347
- }
6348
- function describeIdentity(identity) {
6349
- const org = identity.organization ? `${identity.organization.name}${identity.organization.role ? ` (${identity.organization.role})` : ""}` : "no organization yet";
6350
- if (identity.via === "api-key") {
6351
- const key = identity.apiKey?.name ?? identity.apiKey?.start ?? "an API key";
6352
- return `the API key "${key}" of ${org}`;
6353
- }
6354
- const who = identity.user ? identity.user.name ? `${identity.user.name} <${identity.user.email}>` : identity.user.email : "?";
6355
- return `${who}, ${org}`;
6356
- }
6357
- function paths(io) {
6358
- const p = machinePaths(io.env);
6359
- if (p)
6360
- return p;
6361
- throw new UsageError(`neither HOME nor XDG_CONFIG_HOME is set, so this machine has no place to keep a sign-in. Set ${API_KEY_VARIABLE} in the environment instead.`);
6362
- }
6363
- async function readApiKey(io) {
6364
- if (io.interactive && io.prompt)
6365
- return io.prompt("Armada API key (hidden): ", { hidden: true });
6366
- if (io.readStdin)
6367
- return io.readStdin();
6368
- return null;
6369
- }
6370
- async function loginWithApiKey(io, credentials) {
6371
- const p = paths(io);
6372
- const answer = await readApiKey(io);
6373
- if (answer === null) {
6374
- io.stderr(`Cancelled. Nothing was saved.
6375
- `);
6376
- return 130;
6377
- }
6378
- const key = answer.trim();
6379
- if (!key)
6380
- throw new UsageError('no API key given. Paste it at the prompt, or pipe it in: printf %s "$KEY" | armada login --api-key', "the Organization page of Armada, where an owner creates one");
6381
- const url = credentials.armadaApi.url;
6382
- const identity = await apiOf(io, url).whoami({ kind: "api-key", key });
6383
- await updateCredentialStore(p, {
6384
- [API_KEY_VARIABLE]: key,
6385
- [SESSION_TOKEN_VARIABLE]: null,
6386
- [SIGNED_IN_TO_VARIABLE]: armadaAddress(url),
6387
- [TURSO_LEASE_VARIABLE]: null
6388
- });
6389
- io.stdout(`Signed in to ${hostOf(credentials.armadaApi.url)} as ${describeIdentity(identity)}.
6390
- The key is stored in ${p.credentials}.
6391
- `);
6392
- return 0;
6393
- }
6394
- async function login(io, apiKey) {
6395
- const { machine, credentials } = await loadCredentials(io, { armada: false });
6396
- const host = hostOf(credentials.armadaApi.url);
6397
- if (credentials.armadaSignIn?.source.kind === "env")
6398
- io.stderr(`! ${API_KEY_VARIABLE} is set in the environment: it wins over what \`armada login\` stores.
6399
- `);
6400
- if (apiKey)
6401
- return loginWithApiKey(io, credentials);
6402
- const p = paths(io);
6403
- const url = credentials.armadaApi.url;
6404
- const api = apiOf(io, url);
6405
- const code = await api.startDeviceLogin();
6406
- io.stderr(`First copy your one-time code: ${displayCode(code.userCode)}
6407
- Then confirm it at ${code.verificationUriComplete}
6408
- `);
6409
- if (io.interactive && io.openUrl?.(code.verificationUriComplete))
6410
- io.stderr(`Opening it in your browser.
6411
- `);
6412
- io.stderr(`Waiting for the confirmation (the code expires in ${Math.round(code.expiresInSeconds / 60)} minutes)…
6413
- `);
6414
- const token = await waitForApproval({ api, code, sleep: sleepOf(io), now: io.now ?? (() => new Date) });
6415
- const identity = await api.whoami({ kind: "session", token });
6416
- const previous = machine.store?.values[SESSION_TOKEN_VARIABLE]?.trim();
6417
- await updateCredentialStore(p, {
6418
- [SESSION_TOKEN_VARIABLE]: token,
6419
- [API_KEY_VARIABLE]: null,
6420
- [SIGNED_IN_TO_VARIABLE]: armadaAddress(url),
6421
- [TURSO_LEASE_VARIABLE]: null
6422
- });
6423
- if (previous && previous !== token)
6424
- await apiOf(io, storedAt(machine)).signOut({ kind: "session", token: previous }).catch(() => {});
6425
- io.stdout(`Signed in to ${host} as ${describeIdentity(identity)}.
6426
- `);
6427
- if (!identity.organization)
6428
- io.stdout(`Next: accept an invitation, or create an organization, at ${new URL("welcome", apiBaseUrl(credentials.armadaApi.url))}
6429
- `);
6430
- return 0;
6431
- }
6432
- async function whoami(io, json) {
6433
- const { credentials } = await loadCredentials(io, { armada: false });
6434
- const signIn = requireSignIn(credentials);
6435
- const identity = await apiOf(io, credentials.armadaApi.url).whoami(signIn);
6436
- if (json) {
6437
- const out = { ...identity, api: credentials.armadaApi.url, source: signIn.source };
6438
- io.stdout(`${JSON.stringify(out, null, 2)}
6439
- `);
6440
- return 0;
6441
- }
6442
- io.stdout(`Signed in to ${hostOf(credentials.armadaApi.url)} as ${describeIdentity(identity)}.
6443
- `);
6444
- return 0;
6445
- }
6446
- async function logout(io) {
6447
- const { machine } = await loadCredentials(io, { armada: false });
6448
- const p = paths(io);
6449
- const at = storedAt(machine);
6450
- const stored = [SESSION_TOKEN_VARIABLE, API_KEY_VARIABLE, TURSO_LEASE_VARIABLE].filter((k) => machine.store?.assigned.includes(k));
6451
- const session = machine.store?.values[SESSION_TOKEN_VARIABLE]?.trim();
6452
- if (session) {
6453
- await apiOf(io, at).signOut({ kind: "session", token: session }).catch((err) => io.stderr(`! the session could not be revoked on Armada (${err instanceof Error ? err.message : String(err)}); it expires on its own
6454
- `));
6455
- }
6456
- if (stored.length) {
6457
- await updateCredentialStore(p, {
6458
- [SESSION_TOKEN_VARIABLE]: null,
6459
- [API_KEY_VARIABLE]: null,
6460
- [SIGNED_IN_TO_VARIABLE]: null,
6461
- [TURSO_LEASE_VARIABLE]: null
6462
- });
6463
- io.stdout(`Signed out of ${hostOf(at)}: removed the sign-in from ${p.credentials}.
6464
- `);
6465
- } else
6466
- io.stdout(`This terminal was not signed in to Armada (nothing in ${p.credentials}).
6467
- `);
6468
- if (io.env[API_KEY_VARIABLE]?.trim())
6469
- io.stdout(`${API_KEY_VARIABLE} is still set in the environment, and still signs this terminal in. Unset it to stop.
6470
- `);
6471
- return 0;
6472
- }
6473
-
6474
6729
  // src/merge.ts
6475
6730
  import { randomUUID } from "node:crypto";
6476
6731
  import { rm as rm4 } from "node:fs/promises";
@@ -6673,6 +6928,8 @@ async function merge2(io, config, credentials, a, configPath) {
6673
6928
  for (const w of o.warnings)
6674
6929
  io.stderr(`armada: warning: ${w}
6675
6930
  `);
6931
+ if (o.merged)
6932
+ await endWorkerSessions(io, config, credentials, o.ticket.id, "merged", a.json);
6676
6933
  return 0;
6677
6934
  } finally {
6678
6935
  (await turso.live)?.db?.close();
@@ -6837,7 +7094,8 @@ var COMMAND_HELP = {
6837
7094
  status: ` status Tickets in flight, tickets ready to start and pull requests waiting
6838
7095
  status --all The same for every project registered by \`armada init\`
6839
7096
  `,
6840
- doctor: ` doctor What this repository lacks to be run by Armada, with the fix for each
7097
+ doctor: ` doctor What this repository lacks to be run by Armada, with the fix for each,
7098
+ and whether this terminal is signed in to Armada
6841
7099
  `,
6842
7100
  init: ` init [--program-root <ISSUE-ID>] [--name <name>] [--slug <slug>]
6843
7101
  Open one pull request that installs or updates it all, create the
@@ -6890,11 +7148,15 @@ var COMMAND_HELP = {
6890
7148
  effort) and the environment variables to pass, named, never shown.
6891
7149
  The profile follows [[conductor.routing]] on the ticket's labels, then
6892
7150
  default_profile; --profile overrides it, with --reason when it differs.
6893
- --prompt prints only the prompt, for \`--message-file -\`
7151
+ Signed in to Armada, the prompt starts with a one-time launch token, so
7152
+ the worker needs no key. --prompt prints only the prompt, for \`--message-file -\`
6894
7153
  `,
6895
7154
  login: ` login Sign this terminal in to Armada: confirm the code it shows in the browser
6896
7155
  login --api-key Sign a headless coordinator in with an organization API key, read from a
6897
7156
  hidden prompt or standard input (ARMADA_API_KEY in the environment also works)
7157
+ login --launch-token <token> [--api-url <url>]
7158
+ Worker: exchange the one-time token of the launch message for a worker
7159
+ session, which claims, reports, asks and releases that ticket only
6898
7160
  `,
6899
7161
  whoami: ` whoami The person or API key this terminal is signed in as, and its organization
6900
7162
  `,
@@ -6972,7 +7234,9 @@ var VALUE_OPTIONS = [
6972
7234
  "slug",
6973
7235
  "profile",
6974
7236
  "options",
6975
- "timeout"
7237
+ "timeout",
7238
+ "launch-token",
7239
+ "api-url"
6976
7240
  ];
6977
7241
  var FLAG_OPTIONS = ["dry-run", "no-lock", "prompt", "wait", "note", "api-key"];
6978
7242
  var COMMAND_OPTIONS = {
@@ -6985,8 +7249,9 @@ var COMMAND_OPTIONS = {
6985
7249
  init: ["program-root", "name", "slug"],
6986
7250
  merge: ["ticket", "dry-run", "no-lock"],
6987
7251
  brief: ["profile", "reason", "prompt"],
6988
- login: ["api-key"]
7252
+ login: ["api-key", "launch-token", "api-url"]
6989
7253
  };
7254
+ var WORKER_COMMANDS = new Set(["claim", "report", "release", "ask"]);
6990
7255
  function parseArgs(argv) {
6991
7256
  const args = {
6992
7257
  command: null,
@@ -7124,7 +7389,13 @@ async function run(argv, io) {
7124
7389
  if (worker) {
7125
7390
  const { path, text } = await findConfig(io, args.config, args.command);
7126
7391
  const config = parseConfig(text, path);
7127
- const { credentials } = await loadCredentials(io);
7392
+ const command = args.command;
7393
+ const scope = WORKER_COMMANDS.has(command) ? {
7394
+ command,
7395
+ project: config.project.slug,
7396
+ ticket: (stored) => command === "claim" ? args.rest[0]?.toUpperCase() ?? null : currentTicket(io, config, args.options.ticket, stored)
7397
+ } : undefined;
7398
+ const { credentials } = await loadCredentials(io, scope ? { worker: scope } : {});
7128
7399
  return await worker(io, config, credentials, args);
7129
7400
  }
7130
7401
  if (args.command === "merge") {
@@ -7158,7 +7429,11 @@ async function run(argv, io) {
7158
7429
  if (args.rest.length)
7159
7430
  throw new UsageError(`${args.command} takes no argument${args.command === "login" ? ": an API key is read from a hidden prompt or standard input, never from the command line" : ""}`);
7160
7431
  if (args.command === "login")
7161
- return await login(io, args.options["api-key"] === "true");
7432
+ return await login(io, {
7433
+ apiKey: args.options["api-key"] === "true",
7434
+ launchToken: args.options["launch-token"] ?? null,
7435
+ apiUrl: args.options["api-url"] ?? null
7436
+ });
7162
7437
  if (args.command === "logout")
7163
7438
  return await logout(io);
7164
7439
  return await whoami(io, args.json);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-vibe-company/armada",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "type": "module",
5
5
  "description": "Run a fleet of coding agents on one project: the armada command line.",
6
6
  "license": "MIT",