@the-vibe-company/armada 0.2.18 → 0.2.20
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.
- package/README.md +18 -7
- package/dist/armada.js +527 -45
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ Workers then need no key either: each one's launch message carries a one-time to
|
|
|
34
34
|
|
|
35
35
|
`armada status` reads the `armada.toml` of the current repository (or the nearest parent directory) and prints:
|
|
36
36
|
|
|
37
|
-
- **In flight**: tickets an agent holds, with their phase, runtime, last report and pull request. A worker with no
|
|
37
|
+
- **In flight**: tickets an agent holds, with their phase, runtime, last report and pull request. A worker with no heartbeat for longer than `policy.silence_minutes` is flagged `silent`, unless it is waiting on a human (`awaiting-approval`, `blocked`, `ready-to-merge`). Older workers without heartbeats fall back to reports (an `armada report` event recorded through Armada, an `Agent status:` comment or its claim), then the ticket's last sign of life (ticket edit, comment or pull request update). A live worker without a report for `policy.quiet_minutes` gets a coordinator-only inbox note, not a red dashboard state.
|
|
38
38
|
- **Launched, not started**: signed in to Armada, the workers launched with a launch token that have not claimed their ticket after `policy.not_started_minutes`, each saying whether the token was never used (the worker never reached its `armada login` line) or used without a claim.
|
|
39
39
|
- **Ready to start**: tickets without sub-issues that are not started, not held by an agent, have no open pull request, and whose blocked-by tickets are all closed, ranked by what they unlock. Tickets without the ready label, or still in triage, are listed separately.
|
|
40
40
|
- **Pull requests waiting**: open pull requests with their CI state and mergeability.
|
|
@@ -77,15 +77,18 @@ On a repository without `armada.toml`, pass `--program-root <ISSUE-ID>`; the nam
|
|
|
77
77
|
Armada prepares a launch; it never starts a runtime itself. The `armada-runtime-conductor` skill gives the exact Conductor Cloud commands; the `armada-runtime-claude-code` skill launches a worker as a background subagent of a coordinator running in Claude Code, in its own git worktree (it dies with the coordinator's session, so long runs go to Conductor). [`docs/runbook.md`](docs/runbook.md) says how to start a coordinator on a laptop or in Conductor Cloud, what the owner sets up once, and how one coordinator hands over to the next.
|
|
78
78
|
|
|
79
79
|
```sh
|
|
80
|
-
armada brief ABC-12 #
|
|
81
|
-
armada brief ABC-12 --prompt
|
|
80
|
+
armada brief ABC-12 # read-only settings and prompt preview; no launch
|
|
81
|
+
armada brief ABC-12 --prompt --profile-line # prompt on stdout; profile and reason on stderr
|
|
82
82
|
armada brief ABC-12 --profile codex --reason "a back-end bug behind a web label" --json
|
|
83
|
+
armada launch revoke ABC-12 # cancel the newest pending launch through Armada
|
|
83
84
|
```
|
|
84
85
|
|
|
85
86
|
- 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.
|
|
86
87
|
- **Plan rule.** A "Plan" section says in one line whether the worker waits for approval: "post your plan with `armada report implementing --plan-file -` and go on" when plans are pre-approved, "post your plan with `armada report awaiting-approval --plan-file -` and wait for approval" otherwise. `[policy] plans` decides (`approve` by default, or `pre-approved`); a ticket labelled `plan-approved` (`policy.pre_approved_label`) is pre-approved, and one labelled `needs-plan-approval` (`policy.approval_label`) waits for approval, which wins when a ticket has both. The settings show the rule and where it comes from (`Plans:`), and `--json` carries it as `plans`.
|
|
87
88
|
- **Project conventions.** `[brief] extra = "<path>"` names a file of the repository (relative to `armada.toml`) that every prompt ends with, under "Project conventions": the checks to run, the generated files to refresh, how to bring main in. A missing file is a brief warning, and `armada doctor` checks it.
|
|
88
|
-
- **Workers need no key.**
|
|
89
|
+
- **Workers need no key.** Only `brief --prompt` asks Armada for a launch token: one ticket, used once, valid one hour. Human and `--json` views are read-only, mint no token and add no worker to watch state; they show `Launch: a one-time token is made when you print the prompt (--prompt)`. With `--prompt --profile-line`, stdout remains the exact worker prompt and stderr gives the selected profile, agent, model, effort, runtime and reason: one call supplies both the prompt and runtime settings. The worker exchanges the token for a session limited to its ticket's `claim`, `report`, `ask` and `release`, and Armada gives each command its keys. Make the prompt right before the launch; its token is the only secret a prompt ever holds, useless once used. The launch message is the `--prompt` output only, never either preview. Without a token, the profile line's `Launch:` summary says why (not signed in, or an Armada without accounts or keys).
|
|
90
|
+
- **Cancel a launch.** `armada launch revoke <ticket>` ends the newest pending launch through the API and records the same revocation audit as Organization > Workers. It also cancels a worker that signed in but never claimed; a claimed worker is refused with the `armada release` hint. Owners and admins can revoke, including an organization API key whose creator still has that role. `armada status` lists pending launches with the cancel command.
|
|
91
|
+
- **Unused launches clear.** Once an unused launch token expired more than an hour ago, it stops being followed. The next coordinator inbox read ends it server-side, shows one `not started (token expired)` notice, then clears it. Exchanged-but-unclaimed launches remain revocable and stop being followed after the existing 24-hour window from their launch.
|
|
89
92
|
- **A version npm serves.** The brief pins the coordinator's Armada version, after one request to npm (3 s at most, beside the Linear reads). When npm does not serve it yet (a release still publishing, a checkout ahead of npm), the brief pins the newest published version and warns; offline, it only warns. Merging or releasing the ticket ends the worker's session, and Organization > Workers on the dashboard revokes one.
|
|
90
93
|
- 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). Each shows whether this shell has it. No value is ever printed.
|
|
91
94
|
- A profile with `runtime = "claude-code"` routes the launch to the `armada-runtime-claude-code` skill: the `Runtime:` line names the skill, the claim runs `--runtime claude-code` with the subagent's name as its handle (the ticket id in lowercase), and the prompt first makes the worker check it runs in its own worktree. The Agent tool applies no effort; the brief says so.
|
|
@@ -101,12 +104,15 @@ armada login --launch-token <token> # the first line of the launch messag
|
|
|
101
104
|
armada claim ABC-12 --runtime conductor --handle <workspace>/<session>
|
|
102
105
|
armada report awaiting-approval --plan-file plan.md # the plan as its own block, one-line status
|
|
103
106
|
armada report implementing --message "plan approved, writing the parser"
|
|
107
|
+
armada attach ABC-12 .context/overview.png https://example.com/design --caption "Check the new overview"
|
|
104
108
|
armada report implementing --message "parser done, wiring the CLI" # same phase = status update
|
|
105
109
|
armada report shipping --message "PR open" --pr 34
|
|
106
110
|
armada report ready-to-merge --pr 34 --sha <full 40-character head SHA>
|
|
107
111
|
armada release --reason "wrong ticket"
|
|
108
112
|
```
|
|
109
113
|
|
|
114
|
+
`armada attach <ticket> <file|url>... [--caption "<text>"] [--for <item>]` keeps visual evidence out of git. It uploads byte-checked PNG, JPEG, WebP or GIF images (at most 2 MB each) and records HTTPS links, then prints private dashboard URLs. An organization member can inspect them in the agent's **Attachments** tab, enlarge images, and follow links. The bytes stay in the app's Postgres and are served only after organization/project access checks; signed-out callers and other organizations receive 403. Worker sessions attach only to their own ticket; coordinators attach to any ticket in their project's cached reading. Refresh the dashboard first if a new ticket is missing there. `--for` stores a free validation reference. Identical content on a ticket is stored once (a later `--for` can bind it to a validation). Each ticket defaults to 20 images/links, the project to 200 MB of image bytes, and evidence is deleted by the next successful project refresh at least 30 days after completion or cancellation; reopening resets that window. Configure these limits in `[policy]` below. Never include credentials or secrets in linked URLs or screenshots.
|
|
115
|
+
|
|
110
116
|
- `claim` re-reads the ticket and refuses it when another worker holds it; if two claims race, the older comment wins and the other withdraws. It assigns the ticket to the Linear key's user, moves it to the team's first started state, sets the `planning` phase label and the runtime label (matched by name, so `conductor` finds `Conductor`), and posts an `Agent claim — runtime · session · branch · started` line. The handle is kept in that comment and on Armada, so a coordinator finds the session either way. Claiming again with the same handle repairs labels and state. It reads every comment and label of the ticket, however many.
|
|
111
117
|
- `report <phase>` accepts: planning → awaiting-approval or implementing; awaiting-approval → planning or implementing; implementing → shipping; shipping → implementing or ready-to-merge; ready-to-merge → shipping; blocked from anywhere and back to any phase; the current phase again as a status update. Anything else exits 1 with the reason. The output lists what waits in the worker's inbox.
|
|
112
118
|
- `report`, `ask` and `answer` accept `--message-file -` to read standard input to EOF, including a pipe or a shell heredoc. For example: `printf 'line one\nline two' | bun run armada report implementing --ticket ABC-12 --message-file -`. An explicitly empty or whitespace-only message file or stdin exits 2 before any tracker or database write, with a retry naming `--message` or a non-empty pipe. A `ready-to-merge` report may still omit the message option.
|
|
@@ -131,13 +137,14 @@ armada answer --note ABC-12 "main moved: bring it in before you ship" # an unso
|
|
|
131
137
|
|
|
132
138
|
- `ask` reports the `blocked` phase with `Agent status: blocked — question: <first line>` (the rest and the numbered options below it) and adds a `question` item to the coordinator's inbox on Armada. The worker then stops and waits for the answer in its session, and reports the phase it resumes. It finds the ticket like `report`.
|
|
133
139
|
- `report awaiting-approval` adds a `plan` item with the full message (and the `--plan` block) and worker handle to the coordinator's inbox. Same-phase heartbeats neither duplicate nor reopen it. Answering it, recording a note, leaving the phase or releasing the ticket closes the plan and any pending approval request. For a pre-approved plan (the brief's "Plan" line says which), post the plan with `report implementing --plan-file -` instead: no approval item is needed.
|
|
134
|
-
- `
|
|
140
|
+
- `heartbeat --every 5m --parent <agent-pid>` pings Armada without reading keys from the vault or writing Linear. The brief starts it immediately after claim: Conductor uses `--background` (detached process group and PID file), Claude Code uses the subagent's background Bash. It survives between turns on Cloud and stops when its persistent parent exits or the current worker session ends (release, merge, revoke). If background startup is unsupported or fails, keep manual reports at least every 15 minutes. `[policy] silence_minutes` defaults to 15: no heartbeat means probably stopped; old clients use reports. `quiet_minutes` defaults to 45: alive without a progress report creates a coordinator-only `quiet` inbox note, never an owner item or red dashboard state. Heartbeats draw the timeline's session line; actual reports remain dots.
|
|
141
|
+
- `inbox` lists the coordinator's open items (questions, plans, requests, hand-backs), silent workers and workers that never started, oldest first. A worker never started (`not-started`) was launched with a launch token and has not claimed its ticket after `policy.not_started_minutes`; the entry says whether the token was never used or used without a claim, names the worker's session when its sign-in gave one, and clears on the claim, when the launch ends (release, merge, revoke) or when a newer launch of the ticket replaces it. A launch on a ticket a session still holds is not followed (a brief made to read a running worker's prompt again launches nobody; a relaunch releases the old claim first). A launched worker counts as in flight from its launch until it shows as not started, so `armada watch` waits for its claim; past that, its entry carries it. A worker is silent when it holds a ticket, its last heartbeat (or newest report for an older client) is older than `policy.silence_minutes`, and its phase does not wait on someone else. A live worker with no report for `policy.quiet_minutes` gets a softer `quiet` entry here only. It reads Armada only (a sign-in, no Linear key) and records that the coordinator is at work, for the dashboard. `--wait` asks Armada every 15 s until `--timeout`; Armada answers "not modified" (HTTP 304, no body) while the inbox holds the same entries, so a waiting coordinator costs one short request per ask and holds nothing open. It marks the items that were not there before with `*`; loop on it. A hand-back handed back again on a new head (or a plan rewritten in place) counts as new.
|
|
135
142
|
- `watch` is how a coordinator keeps listening, run in the background while a worker is in flight. It asks Armada like `inbox --wait` (every 15 s, every 60 s when no worker is in flight, 304 while nothing changed) with no time limit of its own, and exits as soon as something needs the coordinator that it has not been shown yet by `inbox` or `watch` on this machine: it prints the inbox, new items marked `*`. It exits with "nothing to watch" when no worker is in flight and nothing is open. Armada unreachable or answering 5xx only prints a warning and it keeps going, waiting longer each time; a refusal (signed out) ends it. One watch per project and machine: a second one says the first is running. Its state (a lock, the entries shown, the tickets in flight at the last read, the checkout it ran in) lives in `~/.config/armada/watch/`, no secret.
|
|
136
143
|
- The last line of `inbox`, `watch`, `merge` and `brief` (not `brief --prompt`) says whether to start watching again, for example `2 workers in flight (ABC-1, ABC-2) — keep watching: armada watch`; with `--json`, the same is the `watch` field.
|
|
137
144
|
- `armada hook stop` is the Claude Code Stop hook `armada init` adds to `.claude/settings.json` (it asks; `--no-stop-hook` leaves it out; `armada doctor` shows it). It reads only armada.toml and the watch state, so it answers at once without the network. It refuses to end the turn, and tells the agent to start `armada watch` in the background, only in the checkout where `armada watch` ran (never a worker's), while the last read had workers in flight and no watch runs. A watch that ended on a refusal lets the turn end, and `ARMADA_STOP_HOOK=off` turns the hook off.
|
|
138
145
|
- On the dashboard, an item open in the coordinator's inbox for longer than `policy.coordinator_minutes` (default 10) shows "waiting for the coordinator for N min" in "Waiting for you".
|
|
139
146
|
- A coordinator's own claim is never listed as silent in its inbox: only an exact, nonempty handle match is excluded, not its questions, requests or hand-backs. `inbox` takes the reading coordinator's handle from `ARMADA_COORDINATOR_HANDLE` first, otherwise from both `CONDUCTOR_WORKSPACE_ID` and `CONDUCTOR_SESSION_ID` joined as `workspace/session`. Blank values are ignored; with no complete identity, silence detection is unchanged. Local coordinators should set `ARMADA_COORDINATOR_HANDLE` to the handle used for their claim. The same identity is used for every `--wait` poll and the dashboard presence record; the fleet-wide `status` and dashboard silence rules are unchanged.
|
|
140
|
-
- `answer` never calls a runtime: deliver the answer first with the runtime guide's message section. It posts `Agent status: <current phase> — answer: …` on the ticket and resolves the item. An item id needs Armada; a ticket id answers that ticket's open questions and plans and also works without it. `--note` records a delivered note as `Agent status: <phase> — note: …`; it accepts a ticket or plan item id and resolves open plans, not questions. These two are the coordinator's records: Armada never reads them as the worker's phase, hand-back or sign of life. Questions, plans and requests can be answered; `merge` resolves hand-backs, and `release` and `merge` resolve the ticket's open questions.
|
|
147
|
+
- `answer` never calls a runtime: deliver the answer first with the runtime guide's message section. It posts `Agent status: <current phase> — answer: …` on the ticket and resolves the item. An item id needs Armada; a ticket id answers that ticket's open questions and plans and also works without it. `--note` records a delivered note as `Agent status: <phase> — note: …`; it accepts a ticket or plan item id and resolves open plans, not questions. These two are the coordinator's records: Armada never reads them as the worker's phase, hand-back or sign of life. Questions, plans and requests can be answered; `merge` resolves hand-backs, and `release` and `merge` resolve the ticket's open questions. For older clients without heartbeats, no report within `policy.silence_minutes` of an answer shows as silent. With heartbeats, the report reminder uses `policy.quiet_minutes` instead.
|
|
141
148
|
- The dashboard adds two kinds of request, signed by the person who made them. In "Waiting for you", **Approve** opens an editable approval (`approved` by default); sending it creates an `answer-request`, just like answering a question. Deliver its text, then `armada answer <request id> "<answer>"`, which resolves the request and its question or plan and names the requester on the ticket (answering the item itself also closes a waiting request). A `launch-request` asks to launch a ready ticket on a profile: launch it as usual; the worker's `armada claim` resolves it and posts who asked. To decline one, `armada answer <request id> "<why>"`: it is closed with the reason and nothing is posted on the ticket.
|
|
142
149
|
|
|
143
150
|
## Merge a finished pull request (coordinator)
|
|
@@ -390,7 +397,11 @@ required_checks = ["test"] # CI checks that must be green before a hand-ba
|
|
|
390
397
|
local_commands = ["npm ci", "npm test"] # run by `armada merge` on a test merge of a head behind its base (default: none: the worker brings the base branch in instead)
|
|
391
398
|
|
|
392
399
|
[policy]
|
|
393
|
-
|
|
400
|
+
attachments_per_ticket = 20 # images and links together (default 20)
|
|
401
|
+
attachments_project_mb = 200 # private image bytes per project, MB = 1024² bytes (default 200)
|
|
402
|
+
attachments_retention_days = 30 # deleted after completion/cancellation by the next project refresh (default 30)
|
|
403
|
+
silence_minutes = 15 # no heartbeat for longer flags a worker silent (default 15; reports for older clients)
|
|
404
|
+
quiet_minutes = 45 # live without a report for longer adds a coordinator-only note (default 45)
|
|
394
405
|
coordinator_minutes = 10 # an inbox item open longer shows "waiting for the coordinator" (default 10)
|
|
395
406
|
not_started_minutes = 10 # a launched worker that has not claimed after this long shows as not started (default 10; a CLI older than this setting refuses it)
|
|
396
407
|
plans = "approve" # or "pre-approved": workers post their plan and go on (default "approve")
|
package/dist/armada.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
// src/main.ts
|
|
4
4
|
import { spawn as spawn2, spawnSync } from "node:child_process";
|
|
5
5
|
import { createReadStream } from "node:fs";
|
|
6
|
-
import { readFile as readFile3 } from "node:fs/promises";
|
|
6
|
+
import { open as open2, readFile as readFile3 } from "node:fs/promises";
|
|
7
7
|
import { hostname as hostname2 } from "node:os";
|
|
8
8
|
import { isatty } from "node:tty";
|
|
9
9
|
|
|
10
10
|
// src/cli.ts
|
|
11
|
-
import { dirname as dirname7, join as join6, resolve as
|
|
11
|
+
import { dirname as dirname7, join as join6, resolve as resolve3 } from "node:path";
|
|
12
12
|
|
|
13
13
|
// ../core/src/live.ts
|
|
14
14
|
import { createHash } from "node:crypto";
|
|
@@ -993,11 +993,15 @@ var CONFIG_DEFAULTS = {
|
|
|
993
993
|
runtimeGroup: "Agent runtime",
|
|
994
994
|
runtimes: ["Claude Code", "Codex", "Conductor"],
|
|
995
995
|
silentAfterMinutes: 15,
|
|
996
|
+
quietAfterMinutes: 45,
|
|
996
997
|
coordinatorMinutes: 10,
|
|
997
998
|
notStartedMinutes: 10,
|
|
998
999
|
plans: "approve",
|
|
999
1000
|
preApprovedLabel: "plan-approved",
|
|
1000
|
-
approvalLabel: "needs-plan-approval"
|
|
1001
|
+
approvalLabel: "needs-plan-approval",
|
|
1002
|
+
attachmentsPerTicket: 20,
|
|
1003
|
+
attachmentsProjectMb: 200,
|
|
1004
|
+
attachmentsRetentionDays: 30
|
|
1001
1005
|
};
|
|
1002
1006
|
|
|
1003
1007
|
class ConfigError extends Error {
|
|
@@ -1107,12 +1111,16 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
1107
1111
|
policyT,
|
|
1108
1112
|
[
|
|
1109
1113
|
"silence_minutes",
|
|
1114
|
+
"quiet_minutes",
|
|
1110
1115
|
"silent_after_minutes",
|
|
1111
1116
|
"coordinator_minutes",
|
|
1112
1117
|
"not_started_minutes",
|
|
1113
1118
|
"plans",
|
|
1114
1119
|
"pre_approved_label",
|
|
1115
|
-
"approval_label"
|
|
1120
|
+
"approval_label",
|
|
1121
|
+
"attachments_per_ticket",
|
|
1122
|
+
"attachments_project_mb",
|
|
1123
|
+
"attachments_retention_days"
|
|
1116
1124
|
]
|
|
1117
1125
|
],
|
|
1118
1126
|
["brief", briefT, ["extra"]],
|
|
@@ -1201,6 +1209,14 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
1201
1209
|
problems.push(`"policy.${silenceKey}" must be a positive number`);
|
|
1202
1210
|
}
|
|
1203
1211
|
let coordinatorMinutes = CONFIG_DEFAULTS.coordinatorMinutes;
|
|
1212
|
+
let quietAfterMinutes = CONFIG_DEFAULTS.quietAfterMinutes;
|
|
1213
|
+
if (policyT.quiet_minutes !== undefined) {
|
|
1214
|
+
const value = policyT.quiet_minutes;
|
|
1215
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0)
|
|
1216
|
+
quietAfterMinutes = value;
|
|
1217
|
+
else
|
|
1218
|
+
problems.push('"policy.quiet_minutes" must be a positive number');
|
|
1219
|
+
}
|
|
1204
1220
|
if (policyT.coordinator_minutes !== undefined) {
|
|
1205
1221
|
const v = policyT.coordinator_minutes;
|
|
1206
1222
|
if (typeof v === "number" && Number.isFinite(v) && v > 0)
|
|
@@ -1225,6 +1241,18 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
1225
1241
|
problems.push(`"policy.plans" must be ${PLAN_POLICIES.map((p) => `"${p}"`).join(" or ")}`);
|
|
1226
1242
|
}
|
|
1227
1243
|
const preApprovedLabel = str(policyT, "policy", "pre_approved_label", { default: CONFIG_DEFAULTS.preApprovedLabel });
|
|
1244
|
+
const quota = (key, fallback) => {
|
|
1245
|
+
const value = policyT[key];
|
|
1246
|
+
if (value === undefined)
|
|
1247
|
+
return fallback;
|
|
1248
|
+
if (typeof value === "number" && Number.isSafeInteger(value) && value > 0)
|
|
1249
|
+
return value;
|
|
1250
|
+
problems.push(`"policy.${key}" must be a positive integer`);
|
|
1251
|
+
return fallback;
|
|
1252
|
+
};
|
|
1253
|
+
const attachmentsPerTicket = quota("attachments_per_ticket", CONFIG_DEFAULTS.attachmentsPerTicket);
|
|
1254
|
+
const attachmentsProjectMb = quota("attachments_project_mb", CONFIG_DEFAULTS.attachmentsProjectMb);
|
|
1255
|
+
const attachmentsRetentionDays = quota("attachments_retention_days", CONFIG_DEFAULTS.attachmentsRetentionDays);
|
|
1228
1256
|
const approvalLabel = str(policyT, "policy", "approval_label", { default: CONFIG_DEFAULTS.approvalLabel });
|
|
1229
1257
|
if (preApprovedLabel && approvalLabel && routingLabelKey(preApprovedLabel) === routingLabelKey(approvalLabel))
|
|
1230
1258
|
problems.push(`"policy.pre_approved_label" and "policy.approval_label" must name different labels`);
|
|
@@ -1282,7 +1310,18 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
1282
1310
|
repository: str(github, "github", "repository", { pattern: REPOSITORY, hint: "owner/name" })
|
|
1283
1311
|
},
|
|
1284
1312
|
gates: { requiredChecks, localCommands },
|
|
1285
|
-
policy: {
|
|
1313
|
+
policy: {
|
|
1314
|
+
silentAfterMinutes,
|
|
1315
|
+
quietAfterMinutes,
|
|
1316
|
+
coordinatorMinutes,
|
|
1317
|
+
notStartedMinutes,
|
|
1318
|
+
plans,
|
|
1319
|
+
preApprovedLabel,
|
|
1320
|
+
approvalLabel,
|
|
1321
|
+
attachmentsPerTicket,
|
|
1322
|
+
attachmentsProjectMb,
|
|
1323
|
+
attachmentsRetentionDays
|
|
1324
|
+
},
|
|
1286
1325
|
brief: { extra },
|
|
1287
1326
|
secrets: { names: secretNames },
|
|
1288
1327
|
conductor: { defaultProfile, profiles, routing }
|
|
@@ -1318,10 +1357,14 @@ repository = ${q(p.repository)}
|
|
|
1318
1357
|
# required_checks = ["test"] # CI checks that must be green before a hand-back (default: every check)
|
|
1319
1358
|
|
|
1320
1359
|
[policy]
|
|
1321
|
-
silence_minutes = 15 # a worker with no
|
|
1360
|
+
silence_minutes = 15 # a worker with no heartbeat for longer than this shows as silent
|
|
1361
|
+
quiet_minutes = 45 # alive but without a report: a coordinator-only note
|
|
1322
1362
|
coordinator_minutes = 10 # an inbox item open longer than this shows "waiting for the coordinator"
|
|
1323
1363
|
# not_started_minutes = 10 # a launched worker that has not claimed after this long shows as not started
|
|
1324
1364
|
# plans = "approve" # or "pre-approved": workers post their plan and go on without waiting
|
|
1365
|
+
# attachments_per_ticket = 20
|
|
1366
|
+
# attachments_project_mb = 200
|
|
1367
|
+
# attachments_retention_days = 30
|
|
1325
1368
|
# pre_approved_label = "plan-approved" # a ticket with this label skips the approval
|
|
1326
1369
|
# approval_label = "needs-plan-approval" # a ticket with this label waits for it; wins over the other
|
|
1327
1370
|
|
|
@@ -1607,7 +1650,8 @@ function buildLane(m, allComments, issue, opts) {
|
|
|
1607
1650
|
const agent = issue.delegate ?? issue.assignee;
|
|
1608
1651
|
const flags = [];
|
|
1609
1652
|
const waitingOnHuman = NEEDS_HUMAN.includes(phase) || phase === "merged";
|
|
1610
|
-
const
|
|
1653
|
+
const lastHeartbeat = opts.heartbeats?.[issue.id] ?? opts.live?.handles?.[issue.id]?.lastHeartbeatAt ?? null;
|
|
1654
|
+
const alive = lastHeartbeat ?? lastReport ?? lastUpdate;
|
|
1611
1655
|
if (!waitingOnHuman && opts.now - Date.parse(alive) > opts.silentAfterMinutes * MIN)
|
|
1612
1656
|
flags.push("silent");
|
|
1613
1657
|
if (pr?.state === "open" && pr.ci === "failure")
|
|
@@ -1637,6 +1681,7 @@ function buildLane(m, allComments, issue, opts) {
|
|
|
1637
1681
|
since,
|
|
1638
1682
|
lastUpdate,
|
|
1639
1683
|
lastReport,
|
|
1684
|
+
lastHeartbeat,
|
|
1640
1685
|
statusLine: fresh?.message && phaseSource === "live" ? { summary: fresh.message, at: fresh.at, author: null, url: issue.url, plan: false } : withStatus?.status ? {
|
|
1641
1686
|
summary: withStatus.status.summary,
|
|
1642
1687
|
at: withStatus.createdAt,
|
|
@@ -1698,17 +1743,20 @@ function waitingPullRequests(m, prs) {
|
|
|
1698
1743
|
|
|
1699
1744
|
// ../core/src/live.ts
|
|
1700
1745
|
var LAUNCH_WINDOW_MS = 24 * 60 * 60000;
|
|
1746
|
+
var UNUSED_LAUNCH_GRACE_MS = 60 * 60000;
|
|
1747
|
+
var unusedLaunchExpired = (launch, now) => !launch.tokenUsedAt && now.getTime() > (launch.tokenExpiresAt ? Date.parse(launch.tokenExpiresAt) : Date.parse(launch.launchedAt) + 60 * 60000) + UNUSED_LAUNCH_GRACE_MS;
|
|
1748
|
+
var followedLaunches = (launches, now) => launches.filter((launch) => now.getTime() - Date.parse(launch.launchedAt) <= LAUNCH_WINDOW_MS && !unusedLaunchExpired(launch, now));
|
|
1701
1749
|
var MIN2 = 60000;
|
|
1702
1750
|
var REWRITTEN = ["hand-back", "plan"];
|
|
1703
1751
|
var digest = (text) => createHash("sha256").update(text).digest("base64url").slice(0, 12);
|
|
1704
|
-
var entryKey = (e) => e.id !== null ? REWRITTEN.includes(e.kind) ? `#${e.id}@${digest(e.body)}` : `#${e.id}` : e.version ? `version:${e.version}` : `${e.kind}:${e.ticket}`;
|
|
1752
|
+
var entryKey = (e) => e.id !== null ? REWRITTEN.includes(e.kind) ? `#${e.id}@${digest(e.body)}` : `#${e.id}` : e.version ? `version:${e.version}` : e.kind === "not-started" && e.body.startsWith("not started (token expired)") ? `not-started:${e.ticket}:expired@${digest(e.body)}` : `${e.kind}:${e.ticket}`;
|
|
1705
1753
|
var hhmm = (iso) => `${iso.slice(11, 16)} UTC`;
|
|
1706
1754
|
function notStartedBody(l, now) {
|
|
1707
1755
|
const minutes = Math.floor((now.getTime() - Date.parse(l.launchedAt)) / MIN2);
|
|
1708
1756
|
const why = l.tokenUsedAt ? `the worker signed in with its launch token at ${hhmm(l.tokenUsedAt)}, then stopped before \`armada claim\`` : "its launch token was never used: the worker never reached its `armada login` line (an install that failed, a prompt cut short)";
|
|
1709
|
-
return `launched ${minutes} min ago and never claimed; ${why}${l.handle ? ` (session ${l.handle})` : ""}. Check its session with the runtime guide's status section; launch it again with armada brief, or revoke
|
|
1757
|
+
return `launched ${minutes} min ago and never claimed; ${why}${l.handle ? ` (session ${l.handle})` : ""}. Check its session with the runtime guide's status section; launch it again with armada brief ${l.ticket} --prompt, or revoke it with armada launch revoke ${l.ticket}`;
|
|
1710
1758
|
}
|
|
1711
|
-
var notStartedLaunches = (launches, now, minutes) => launches.filter((l) => now.getTime() - Date.parse(l.launchedAt) > minutes * MIN2);
|
|
1759
|
+
var notStartedLaunches = (launches, now, minutes) => followedLaunches(launches, now).filter((l) => now.getTime() - Date.parse(l.launchedAt) > minutes * MIN2);
|
|
1712
1760
|
|
|
1713
1761
|
// ../core/src/activity.ts
|
|
1714
1762
|
var SAME_MS = 10 * 60000;
|
|
@@ -2249,6 +2297,15 @@ function armadaApi(opts) {
|
|
|
2249
2297
|
warnings: strings(body.warnings)
|
|
2250
2298
|
};
|
|
2251
2299
|
},
|
|
2300
|
+
async attach(signIn, target) {
|
|
2301
|
+
const { status, body } = await call("POST", "attachments", { signIn, body: target });
|
|
2302
|
+
if (status !== 200)
|
|
2303
|
+
throw refusal(status, body, "Armada did not attach this item");
|
|
2304
|
+
const attachment = body.attachment;
|
|
2305
|
+
if (!attachment || typeof attachment.id !== "string" || typeof body.url !== "string")
|
|
2306
|
+
throw new ArmadaApiError("Armada answered the attachment in an unknown shape");
|
|
2307
|
+
return { attachment, url: body.url };
|
|
2308
|
+
},
|
|
2252
2309
|
async setSecret(signIn, target) {
|
|
2253
2310
|
const { status, body } = await call("POST", "secrets/set", { signIn, body: target });
|
|
2254
2311
|
if (status !== 200)
|
|
@@ -2287,6 +2344,14 @@ function armadaApi(opts) {
|
|
|
2287
2344
|
throw refusal(status, body, "Armada did not end the ticket's workers");
|
|
2288
2345
|
return typeof body.ended === "number" ? body.ended : 0;
|
|
2289
2346
|
},
|
|
2347
|
+
async revokeLaunch(signIn, target) {
|
|
2348
|
+
const { status, body } = await call("POST", "workers/revoke", { signIn, body: target });
|
|
2349
|
+
if (status !== 200)
|
|
2350
|
+
throw refusal(status, body, "Armada did not revoke the launch");
|
|
2351
|
+
if (typeof body.id !== "string" || typeof body.ticket !== "string")
|
|
2352
|
+
throw new ArmadaApiError(`Armada (${host}) answered the revoked launch in a shape this CLI does not know`);
|
|
2353
|
+
return { id: body.id, ticket: body.ticket };
|
|
2354
|
+
},
|
|
2290
2355
|
async signOut(signIn) {
|
|
2291
2356
|
const { status, body } = await call("DELETE", "session", { signIn });
|
|
2292
2357
|
if (status !== 200)
|
|
@@ -2321,6 +2386,45 @@ async function waitForApproval({ api, code, sleep, now }) {
|
|
|
2321
2386
|
}
|
|
2322
2387
|
throw new ArmadaApiError("the code expired before it was approved", LOGIN_NEXT);
|
|
2323
2388
|
}
|
|
2389
|
+
// ../core/src/attachments.ts
|
|
2390
|
+
var MAX_ATTACHMENT_BYTES = 2 * 1024 * 1024;
|
|
2391
|
+
function attachmentImageType(bytes) {
|
|
2392
|
+
const starts = (signature) => signature.every((value, index) => bytes[index] === value);
|
|
2393
|
+
if (starts([137, 80, 78, 71, 13, 10, 26, 10]))
|
|
2394
|
+
return "image/png";
|
|
2395
|
+
if (starts([255, 216, 255]))
|
|
2396
|
+
return "image/jpeg";
|
|
2397
|
+
const text = (start, end) => String.fromCharCode(...bytes.slice(start, end));
|
|
2398
|
+
if (["GIF87a", "GIF89a"].includes(text(0, 6)))
|
|
2399
|
+
return "image/gif";
|
|
2400
|
+
if (bytes.length >= 16 && text(0, 4) === "RIFF" && text(8, 12) === "WEBP" && ["VP8 ", "VP8L", "VP8X"].includes(text(12, 16)))
|
|
2401
|
+
return "image/webp";
|
|
2402
|
+
return null;
|
|
2403
|
+
}
|
|
2404
|
+
function checkAttachment(input) {
|
|
2405
|
+
if (input.kind === "image") {
|
|
2406
|
+
if (input.bytes.length > MAX_ATTACHMENT_BYTES)
|
|
2407
|
+
return "attachment size limit: images must be at most 2 MB each";
|
|
2408
|
+
const type = attachmentImageType(input.bytes);
|
|
2409
|
+
if (!type || type !== input.contentType)
|
|
2410
|
+
return "attachment type limit: only PNG, JPEG, WebP and GIF images matching their bytes are accepted";
|
|
2411
|
+
return null;
|
|
2412
|
+
}
|
|
2413
|
+
try {
|
|
2414
|
+
if ([...input.url].some((character) => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127))
|
|
2415
|
+
return "attachment link type limit: a valid HTTPS URL without control characters is required";
|
|
2416
|
+
const url = new URL(input.url);
|
|
2417
|
+
if (url.protocol !== "https:")
|
|
2418
|
+
return "attachment link type limit: HTTPS only";
|
|
2419
|
+
if (url.username || url.password)
|
|
2420
|
+
return "attachment links must not contain credentials";
|
|
2421
|
+
if (input.url.length > 4096)
|
|
2422
|
+
return "attachment link size limit: 4096 characters";
|
|
2423
|
+
return null;
|
|
2424
|
+
} catch {
|
|
2425
|
+
return "attachment link type limit: a valid HTTPS URL is required";
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2324
2428
|
// ../core/src/phases.ts
|
|
2325
2429
|
var TRANSITIONS = {
|
|
2326
2430
|
planning: ["awaiting-approval", "implementing"],
|
|
@@ -3059,12 +3163,19 @@ function renderPrompt(b) {
|
|
|
3059
3163
|
] : [],
|
|
3060
3164
|
subagent ? "## Then: install Armada and claim the ticket" : "## First: install Armada and claim the ticket",
|
|
3061
3165
|
"",
|
|
3166
|
+
...subagent ? [
|
|
3167
|
+
"Run install, login and claim first. Immediately after claim, run the final heartbeat line as a separate Bash tool call with `run_in_background: true`; keep that Bash owned by this subagent.",
|
|
3168
|
+
""
|
|
3169
|
+
] : [],
|
|
3062
3170
|
"```sh",
|
|
3063
3171
|
b.install,
|
|
3064
3172
|
...b.launch ? [b.launch.command] : [],
|
|
3065
3173
|
b.claimCommand,
|
|
3174
|
+
`armada heartbeat --every 5m --ticket ${t.id} --handle ${subagent ? subagentName(t.id) : CONDUCTOR_HANDLE} --parent "$PPID"${subagent ? "" : " --background"}`,
|
|
3066
3175
|
"```",
|
|
3067
3176
|
"",
|
|
3177
|
+
subagent ? "Keep this Bash heartbeat in the subagent's background: it dies with the subagent, which is intended. Do not detach it from the subagent. If background processes are unavailable, report manually at least every 15 minutes." : "The heartbeat detaches from the short-lived command shell (a new process group, like nohup + setsid), keeps a PID file under ~/.config/armada/watch/, and stays alive between turns and while waiting for messages. Its parent is the persistent agent PID ($PPID in the command shell), never the shell PID ($$). If startup fails or the runtime cannot keep a background process, report manually at least every 15 minutes instead.",
|
|
3178
|
+
"",
|
|
3068
3179
|
`${b.armadaVersion.pinned === b.armadaVersion.coordinator ? "This installs the coordinator's Armada version." : `This installs Armada ${b.armadaVersion.pinned}, the newest on npm (the coordinator runs ${b.armadaVersion.coordinator}, not published yet).`} If the global install is refused, use \`${b.fallback}\` wherever this brief or the skill says \`armada\`.`,
|
|
3069
3180
|
...b.launch ? [
|
|
3070
3181
|
"",
|
|
@@ -3116,6 +3227,7 @@ ${quote(x.handBack.body)}` : "No hand-back note.", "");
|
|
|
3116
3227
|
`;
|
|
3117
3228
|
}
|
|
3118
3229
|
async function loadBrief(config, opts) {
|
|
3230
|
+
const launchHint = "a one-time token is made when you print the prompt (--prompt)";
|
|
3119
3231
|
const now = opts.now ?? (() => new Date);
|
|
3120
3232
|
const linear = { apiKey: opts.linearApiKey, ...opts.fetch ? { fetch: opts.fetch } : {} };
|
|
3121
3233
|
try {
|
|
@@ -3134,6 +3246,7 @@ async function loadBrief(config, opts) {
|
|
|
3134
3246
|
throw new Refusal(`ticket ${opts.ticket} not found in Linear`, "armada status, to see the tickets of the program");
|
|
3135
3247
|
if (opts.profile === null && hasProfileRules(config) && !routeProfile(config, ticket.labels))
|
|
3136
3248
|
return {
|
|
3249
|
+
launchHint,
|
|
3137
3250
|
ticket: {
|
|
3138
3251
|
id: ticket.id,
|
|
3139
3252
|
title: ticket.title,
|
|
@@ -3162,12 +3275,12 @@ async function loadBrief(config, opts) {
|
|
|
3162
3275
|
throw new BriefError(err.message);
|
|
3163
3276
|
throw err;
|
|
3164
3277
|
}
|
|
3165
|
-
const launch = await launchForBrief(ticket, opts.launch);
|
|
3278
|
+
const launch = await launchForBrief(ticket, opts.prompt === true ? opts.launch : undefined);
|
|
3166
3279
|
const made = launch && "token" in launch ? launch : null;
|
|
3167
3280
|
const missed = launch && "reason" in launch ? launch : null;
|
|
3168
3281
|
if (missed?.warn)
|
|
3169
3282
|
ticket.warnings.push(`no launch token: ${missed.reason}`);
|
|
3170
|
-
|
|
3283
|
+
const brief = buildBrief({
|
|
3171
3284
|
config,
|
|
3172
3285
|
ticket,
|
|
3173
3286
|
program,
|
|
@@ -3182,6 +3295,7 @@ async function loadBrief(config, opts) {
|
|
|
3182
3295
|
conventions: opts.conventions ?? null,
|
|
3183
3296
|
now: now()
|
|
3184
3297
|
});
|
|
3298
|
+
return opts.prompt ? brief : { ...brief, launchHint };
|
|
3185
3299
|
}
|
|
3186
3300
|
async function launchForBrief(ticket, launch) {
|
|
3187
3301
|
return ticket.statusType !== "completed" && ticket.statusType !== "canceled" && launch ? launch(ticket.id) : null;
|
|
@@ -3411,13 +3525,14 @@ function updateDotenv(text, updates) {
|
|
|
3411
3525
|
` : "";
|
|
3412
3526
|
}
|
|
3413
3527
|
// ../core/src/fleet-api.ts
|
|
3414
|
-
var WORKER_FLEET_OPS = ["claim", "report", "ask", "release"];
|
|
3528
|
+
var WORKER_FLEET_OPS = ["claim", "report", "ask", "release", "heartbeat"];
|
|
3415
3529
|
var FLEET_OPS = [
|
|
3416
3530
|
...WORKER_FLEET_OPS,
|
|
3417
3531
|
"register",
|
|
3418
3532
|
"coordinator",
|
|
3419
3533
|
"request",
|
|
3420
3534
|
"events/latest",
|
|
3535
|
+
"heartbeats/latest",
|
|
3421
3536
|
"launches",
|
|
3422
3537
|
"inbox",
|
|
3423
3538
|
"inbox/item",
|
|
@@ -3443,6 +3558,8 @@ function fleetClient(o) {
|
|
|
3443
3558
|
return;
|
|
3444
3559
|
}),
|
|
3445
3560
|
lastEventTimes: () => call("events/latest", {}),
|
|
3561
|
+
heartbeatTimes: () => call("heartbeats/latest", {}),
|
|
3562
|
+
heartbeat: (input) => call("heartbeat", input),
|
|
3446
3563
|
pendingLaunches: () => call("launches", {}),
|
|
3447
3564
|
claim: (c) => call("claim", c),
|
|
3448
3565
|
report: (r) => call("report", r),
|
|
@@ -3720,6 +3837,34 @@ async function fetchCommit(opts) {
|
|
|
3720
3837
|
return null;
|
|
3721
3838
|
return { sha: c.oid, tree: c.tree.oid, parents: c.parents.nodes.map((p) => p.oid) };
|
|
3722
3839
|
}
|
|
3840
|
+
// ../core/src/heartbeat.ts
|
|
3841
|
+
async function heartbeatLoop(options) {
|
|
3842
|
+
let claimedAt = null;
|
|
3843
|
+
let next = options.now().getTime();
|
|
3844
|
+
while (options.parentAlive()) {
|
|
3845
|
+
const remaining = next - options.now().getTime();
|
|
3846
|
+
if (remaining > 0) {
|
|
3847
|
+
await options.sleep(Math.min(1000, remaining));
|
|
3848
|
+
continue;
|
|
3849
|
+
}
|
|
3850
|
+
let result = null;
|
|
3851
|
+
try {
|
|
3852
|
+
result = await options.ping({ ticket: options.ticket, handle: options.handle, claimedAt });
|
|
3853
|
+
} catch (error) {
|
|
3854
|
+
if (error instanceof ArmadaApiError && error.status !== null && error.status >= 400 && error.status < 500 && error.status !== 429)
|
|
3855
|
+
return "session-ended";
|
|
3856
|
+
}
|
|
3857
|
+
if (result) {
|
|
3858
|
+
if (!result.active || !result.claimedAt)
|
|
3859
|
+
return "session-ended";
|
|
3860
|
+
if (!claimedAt && options.ready && !await options.ready(result))
|
|
3861
|
+
return "already-running";
|
|
3862
|
+
claimedAt = result.claimedAt;
|
|
3863
|
+
}
|
|
3864
|
+
next = options.now().getTime() + options.everyMs;
|
|
3865
|
+
}
|
|
3866
|
+
return "parent-exited";
|
|
3867
|
+
}
|
|
3723
3868
|
// ../core/src/inbox.ts
|
|
3724
3869
|
function questionBody(question, options = []) {
|
|
3725
3870
|
const listed = options.map((o) => o.trim()).filter(Boolean);
|
|
@@ -3749,6 +3894,7 @@ async function checkInbox(fleet, o) {
|
|
|
3749
3894
|
const query = {
|
|
3750
3895
|
coordinator: o.coordinator ?? null,
|
|
3751
3896
|
silentAfterMinutes: o.silentAfterMinutes,
|
|
3897
|
+
quietAfterMinutes: o.quietAfterMinutes,
|
|
3752
3898
|
...o.facts ? { facts: o.facts } : {},
|
|
3753
3899
|
...o.notStartedMinutes !== undefined ? { notStartedMinutes: o.notStartedMinutes } : {}
|
|
3754
3900
|
};
|
|
@@ -4136,6 +4282,7 @@ async function watchInbox(fleet, o) {
|
|
|
4136
4282
|
const query = {
|
|
4137
4283
|
coordinator: o.coordinator,
|
|
4138
4284
|
silentAfterMinutes: o.silentAfterMinutes,
|
|
4285
|
+
quietAfterMinutes: o.quietAfterMinutes,
|
|
4139
4286
|
...o.facts ? { facts: o.facts } : {},
|
|
4140
4287
|
...o.notStartedMinutes !== undefined ? { notStartedMinutes: o.notStartedMinutes } : {}
|
|
4141
4288
|
};
|
|
@@ -5206,7 +5353,7 @@ A coordinator may start cold, on a laptop or in a fresh cloud session, with noth
|
|
|
5206
5353
|
5. **Launch ready tickets** that do not collide with work in flight, one at a time:
|
|
5207
5354
|
- pick the ticket from the frontier in \`armada status\`;
|
|
5208
5355
|
- run \`armada brief <ticket>\` and resolve its warnings. A matching \`[[conductor.routing]]\` label rule wins. Otherwise, when profiles have \`when\` rules, the brief prints **Choose a profile** and mints no launch token. Read the ticket and its parent spec; match each profile's plain-language rule and prefer the one covering most files the ticket will change. If it spans front end and back end, choose where most of the work is and say so. Run \`armada brief <ticket> --profile <name> --reason "<why>"\`, naming the files or work that justify the choice. Armada never calls a model to classify tickets. Only projects without \`when\` rules fall back to \`default_profile\` (or their only profile). Override a matching label rule only when the labels mislead, with the same reasoned command. Keep \`--profile\` and \`--reason\` on every subsequent \`--prompt\` call; the reason reaches the worker's claim, status and agent page;
|
|
5209
|
-
- write the prompt with \`armada brief <ticket> --prompt > <file
|
|
5356
|
+
- write the prompt with one launch call: \`armada brief <ticket> --prompt --profile-line > <file>\`, keeping the chosen \`--profile\` and \`--reason\` flags. Stdout is the exact prompt; stderr gives the selected profile, agent, model, effort, runtime and reason for the runtime's launch settings. Human and \`--json\` previews are read-only and create no token or launch row. **The launch message is that \`--prompt\` output, never text cut from either preview**. Cancel a minted launch with \`armada launch revoke <ticket>\` if the runtime launch fails or you change your mind; a worker that has claimed must use \`armada release\` instead. Add what only you know: which parallel workers touch neighbouring code and where the boundary is, and decisions not yet on the ticket. The brief already says whether the plan needs approval (\`[policy] plans\`, or the ticket's label) and ends with the project's conventions (\`[brief] extra\`): put a note every worker needs in that file, not in each prompt;
|
|
5210
5357
|
- 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;
|
|
5211
5358
|
- 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.
|
|
5212
5359
|
6. **Merge handed-back pull requests** one at a time with \`armada merge <pr>\` (\`--wait\` when main moved since the hand-back, \`--no-ticket\` for a pull request no ticket owns), 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.
|
|
@@ -5229,6 +5376,8 @@ You only learn of something new when a command you run ends. So while a worker i
|
|
|
5229
5376
|
|
|
5230
5377
|
## Rules of thumb
|
|
5231
5378
|
|
|
5379
|
+
- When asking the owner to validate a design or change, attach what they must see with \`armada attach <ticket> <files|https-urls>... --caption "<what to check>" [--for <item>]\` and include the returned private dashboard URLs in the request. Keep screenshots out of git. Only organization members can open the evidence; each image is at most 2 MB.
|
|
5380
|
+
|
|
5232
5381
|
- Merge only after the worker's hand-back; a green pull request can still get one more push that brings the default branch in.
|
|
5233
5382
|
- Parallel workers in one area collide: stagger them, or give each a disjoint area and tell them the boundary.
|
|
5234
5383
|
- Everything that must survive your session goes to the tracker or the repository. The next coordinator may be a fresh cloud session with none of your context: it resumes from \`armada status\` and \`armada inbox\`.
|
|
@@ -5251,10 +5400,11 @@ Armada never calls a runtime. This guide tells a coordinator running inside Clau
|
|
|
5251
5400
|
|
|
5252
5401
|
## Launch
|
|
5253
5402
|
|
|
5403
|
+
The brief starts a heartbeat immediately after claim. Run the heartbeat command in the subagent's **background Bash** (\`run_in_background: true\`), with \`--parent "$PPID"\` and its claim's \`--handle\`; do not use \`--background\`, \`nohup\` or \`setsid\` here. A subagent's background Bash dies with the subagent, which is the intended behaviour: detaching it could falsely keep a finished subagent alive while the coordinator's process still runs. It also stops when Armada ends its session (release, merge, revoke). If a runtime cannot keep any background Bash, report the fallback on the ticket and keep today's manual reports at least every 15 minutes. Report actual progress at meaningful steps even when heartbeats run.
|
|
5404
|
+
|
|
5254
5405
|
1. Pick a ready ticket from \`armada status\` that does not collide with work in flight.
|
|
5255
|
-
2.
|
|
5256
|
-
|
|
5257
|
-
3. Read the prompt: \`armada brief ABC-12 --prompt\`. **The launch message is that \`--prompt\` output, and only it**: the human view and \`--json\` mask the token as \`armada_launch_••••\`, which signs nobody in. The token in it works once, within the hour: brief again when that hour has passed before the launch. Add what only you know (the boundary with a parallel worker, a decision not yet on the ticket) at the end.
|
|
5406
|
+
2. Read the ticket and parent, then choose its profile. A matching label rule wins; otherwise match the profiles' \`when\` rules by most files/work and pass \`--profile <name> --reason "<why>"\`. Mixed front-end/back-end work: choose the larger part and say why. An optional \`armada brief ABC-12\` or \`--json\` preview is read-only: neither mints a token nor marks a worker in flight. The profile must have \`runtime = "claude-code"\` in \`armada.toml\`. The profile's effort is not applied by the Agent tool; a worker that needs a set effort goes to Conductor.
|
|
5407
|
+
3. **Make one brief call for the launch:** \`armada brief ABC-12 --prompt --profile-line\`, keeping the chosen \`--profile\` and \`--reason\` flags. Stdout is the exact worker prompt; stderr names the profile, agent, model, effort, runtime and reason, so no second brief is needed for the model. Resolve warnings before launching. If the choice is still needed, \`--prompt\` refuses without minting anything. **The launch message is that \`--prompt\` output, and only it**: the human view and \`--json\` carry no token. The token works once, within the hour; generate a fresh prompt if it has expired. If you cancel or launching the subagent fails, use \`armada launch revoke ABC-12\`. Add what only you know (the boundary with a parallel worker, a decision not yet on the ticket) at the end. Without a launch token, stderr says why: usually \`armada login\`, then generate a new prompt.
|
|
5258
5408
|
4. Launch with the Agent tool, every value set:
|
|
5259
5409
|
|
|
5260
5410
|
\`\`\`json
|
|
@@ -5345,12 +5495,12 @@ A subagent launched without \`isolation: "worktree"\` runs in your checkout. The
|
|
|
5345
5495
|
`;
|
|
5346
5496
|
|
|
5347
5497
|
// ../../skills/armada-runtime-conductor/SKILL.md
|
|
5348
|
-
var SKILL_default3 = "---\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- On a Mac, the app ships the CLI at `/Applications/Conductor.app/Contents/Resources/bin/conductor`, which is not on PATH. `armada doctor` looks for it and prints the fix: a link from a directory already on PATH (`ln -s \"/Applications/Conductor.app/Contents/Resources/bin/conductor\" ~/.local/bin/conductor`), or a PATH line for your shell profile.\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`, right before the launch. A matching label rule wins. If it prints **Choose a profile**, read the ticket and parent, match the profiles' `when` rules by most files/work and rerun with `--profile <name> --reason \"<why>\"`. Mixed front-end/back-end work: choose the larger part and say why. Use those flags also for a label-route override and keep them on every subsequent `--prompt` call. 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. This view and `--json` show the token as `armada_launch_••••`; only `--prompt` prints it.\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. **The launch message is the `--prompt` output, and only it.** Never cut the prompt out of the human view of `armada brief` or its `--json`: they mask the token as `armada_launch_••••`, which signs nobody in, and the worker's `armada login` stops on it. Write the prompt to a file only you can read with `--prompt`, 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`, 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. Without a launch token the worker is not signed in to Armada: its claims and reports reach Linear only, with a warning. 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 < /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 `[policy] not_started_minutes` (ten by default): `armada watch` and `armada inbox` show a `not-started` entry, and `armada status` lists the ticket under \"Launched, not started\". It says whether the worker never used its launch token (it never reached its login line) or signed in and stopped before its claim. 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` output (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";
|
|
5498
|
+
var SKILL_default3 = "---\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- On a Mac, the app ships the CLI at `/Applications/Conductor.app/Contents/Resources/bin/conductor`, which is not on PATH. `armada doctor` looks for it and prints the fix: a link from a directory already on PATH (`ln -s \"/Applications/Conductor.app/Contents/Resources/bin/conductor\" ~/.local/bin/conductor`), or a PATH line for your shell profile.\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\nThe brief starts `armada heartbeat --every 5m --parent \"$PPID\" --background` immediately after claim. It creates a detached process group (like `nohup` + `setsid`) with closed terminal streams and a PID file under `~/.config/armada/watch/`. Plain `&` and `nohup` alone can be killed by command-tool cleanup on Cloud; detached startup survives between turns and while waiting for a message. `$PPID` in the agent's command shell must be the persistent agent process, never `$$` (the shell). The heartbeat stops with that parent or when Armada ends the current session (release, merge, revoke). If startup fails or the runtime cannot retain any background process, fall back to manual reports at least every 15 minutes and record that fallback on the ticket. Reports remain progress dots, not liveness.\n\n1. Pick a ready ticket from `armada status` that does not collide with work in flight.\n2. Read the ticket and parent, then choose its profile. A matching label rule wins; otherwise match the profiles' `when` rules by most files/work. Mixed front-end/back-end work: choose the larger part and say why with `--profile <name> --reason \"<why>\"`. An optional `armada brief ABC-12` or `--json` preview helps resolve the choice and warnings, but is read-only: neither creates a launch token nor marks a worker in flight. If the choice is still needed, `--prompt` refuses before minting anything.\n3. **Make one brief call for the launch:** `--prompt --profile-line` writes only the worker prompt to stdout and the selected profile (agent, model, effort, fast mode, runtime and reason) to stderr. Read that line to configure Conductor; no second brief is needed for the profile. Keep any `--profile` and `--reason` flags on this call. Resolve warnings before launching. Never cut a launch message from the human view or `--json`: they carry no token. Write the prompt to a file only you can read, then add what only you know (the boundary with a parallel worker, a decision not yet on the ticket). The token works once, within the hour; if you cancel or the runtime launch fails, use `armada launch revoke ABC-12`. Generate a fresh prompt if its token has expired.\n\n```sh\n(umask 077; armada brief ABC-12 --prompt --profile-line > /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\nIf the prompt has no launch token, its stderr warning says why. Not signed in: `armada login` (a headless coordinator sets `ARMADA_API_KEY`), then generate a new prompt; `armada doctor` checks the sign-in. Only on an Armada that keeps no keys yet (no accounts or no vault), pass the keys the read-only brief's environment table marks `required`, 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. Without a launch token the worker is not signed in to Armada: its claims and reports reach Linear only, with a warning. 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 < /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 `[policy] not_started_minutes` (ten by default): `armada watch` and `armada inbox` show a `not-started` entry; status lists it under \"Pending launches\" with `armada launch revoke ABC-12`. It says whether the worker never used its launch token (it never reached its login line) or signed in and stopped before its claim. An unused token expired more than an hour ago produces one `not started (token expired)` inbox notice, then clears. Exchanged launches without a claim stop being followed after 24 hours and remain revocable. 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 --profile-line` again, and message it only the `armada login --launch-token …` line of the new `--prompt` output (Message section). A worker cut off from Armada was revoked (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";
|
|
5349
5499
|
|
|
5350
5500
|
// ../../skills/armada-worker/SKILL.md
|
|
5351
5501
|
var SKILL_default4 = `---
|
|
5352
5502
|
name: armada-worker
|
|
5353
|
-
description: Working one ticket as an Armada worker agent. Use when you were launched on a ticket by an Armada coordinator, or asked to claim, plan, implement and ship one ticket of a project that has an armada.toml. Covers the claim,
|
|
5503
|
+
description: Working one ticket as an Armada worker agent. Use when you were launched on a ticket by an Armada coordinator, or asked to claim, plan, implement and ship one ticket of a project that has an armada.toml. Covers the claim, background liveness, progress reports, questions to the coordinator, the green pull request and the hand-back. A worker never merges.
|
|
5354
5504
|
---
|
|
5355
5505
|
|
|
5356
5506
|
You are a worker. You own exactly one ticket, named in your launch brief. You turn it into one green pull request and hand it back to the coordinator, who merges. \`armada.toml\` at the repository root names the tracker program, the label groups and the policy; \`AGENTS.md\` (or \`CLAUDE.md\`) holds the repository's own rules, and they win over this skill where they are stricter.
|
|
@@ -5358,12 +5508,14 @@ You are a worker. You own exactly one ticket, named in your launch brief. You tu
|
|
|
5358
5508
|
## Rules
|
|
5359
5509
|
|
|
5360
5510
|
- **Never merge**, never enable auto-merge, never approve your own plan. The coordinator merges.
|
|
5361
|
-
- **
|
|
5511
|
+
- **Start the heartbeat right after claim**, using the line in your brief. It pings Armada only, never Linear. Conductor's \`--background\` detaches it and keeps a PID file: it survives between turns and while waiting for a message. Pass the persistent agent PID, \`$PPID\` in its command shell, not the short-lived shell \`$$\`. On Claude Code use the subagent's background Bash without \`--background\`: it dies with the subagent, as intended. If startup fails or the runtime cannot retain any background process, fall back to manual reports at least every 15 minutes and say so on the ticket. Older CLIs keep that manual rule too.
|
|
5512
|
+
- **Report at each real step** with \`armada report <phase> --message "<what changed, what is next>"\`: the plan, meaningful implementation progress, blockers, tests, shipping and hand-back. The same phase is allowed. Reports are progress, not liveness: \`policy.silence_minutes\` measures missing heartbeats (15 by default); \`policy.quiet_minutes\` is a coordinator-only reminder for a live worker without a report (45 by default). Never post empty reports just to look alive.
|
|
5362
5513
|
- **Keep going on setup choices.** When setup needs a choice (an install fallback, a retry, a missing tool), pick the safe option, say which in your next report, and keep going: never stop to ask about it. Ask only for product decisions.
|
|
5363
5514
|
- **Ask instead of guessing** when a choice changes the ticket's outcome: \`armada ask "<question and your recommendation>" --options "<a> | <b>"\`. Your phase becomes \`blocked\` and the question reaches the coordinator's inbox. Then **stop and end your turn**: the answer arrives as a message in this session, not in a command's output. When it arrives, report the phase you resume, for example \`armada report implementing --message "resumed: <the decision>"\`. Decide reversible technical choices yourself and record each one, with its reason, on the ticket and in the pull request.
|
|
5364
5515
|
- **The ticket is the source of truth.** Read it, its parent spec and the hand-back comments of its merged blockers in full before planning.
|
|
5365
5516
|
- Work only in your own branch and worktree. Never touch another agent's checkout, and stop only the processes you started.
|
|
5366
5517
|
- Never print, commit or log a secret.
|
|
5518
|
+
- For every visible change, capture screenshots under a gitignored directory, then \`armada attach <ticket> <files|https-urls>... --caption "<what to check>"\`. Link the returned private dashboard URLs in the pull request description. Never commit screenshots to show a change. PNG, JPEG, WebP and GIF images are limited to 2 MB each; only the project's organization members may open them. \`--for <item>\` associates evidence with an owner's validation reference when one exists.
|
|
5367
5519
|
- **The project's secrets** (an LLM provider key, a test database URL) come from Armada, never from your launch environment; \`armada secrets\` lists their names. Use them, in this order: \`armada run -- <command>\` for tests, builds and dev servers (they go in that command's environment only); \`armada secrets export --file <path>\` for a tool that reads a dotenv file, at a path git ignores (e.g. \`.env.local\`). Never run \`armada secrets get\`, and never echo, \`env\` or \`printenv\` a value: your command output is your transcript. A secret you need and do not have: ask the coordinator for it by name.
|
|
5368
5520
|
|
|
5369
5521
|
## Steps
|
|
@@ -5765,6 +5917,7 @@ function buildStatus({
|
|
|
5765
5917
|
forge,
|
|
5766
5918
|
forgeError = null,
|
|
5767
5919
|
lastEvents,
|
|
5920
|
+
heartbeats,
|
|
5768
5921
|
live,
|
|
5769
5922
|
launches = [],
|
|
5770
5923
|
extraWarnings = [],
|
|
@@ -5776,6 +5929,7 @@ function buildStatus({
|
|
|
5776
5929
|
now: now.getTime(),
|
|
5777
5930
|
silentAfterMinutes: config.policy.silentAfterMinutes,
|
|
5778
5931
|
...lastEvents ? { lastEvents } : {},
|
|
5932
|
+
...heartbeats ? { heartbeats } : {},
|
|
5779
5933
|
...live ? { live } : {}
|
|
5780
5934
|
});
|
|
5781
5935
|
const phaseOf = new Map(lanes.map((l) => [l.issue.id, l.phase]));
|
|
@@ -5825,12 +5979,14 @@ function buildStatus({
|
|
|
5825
5979
|
since: l.since,
|
|
5826
5980
|
lastUpdate: l.lastUpdate,
|
|
5827
5981
|
lastReport: l.lastReport,
|
|
5982
|
+
lastHeartbeat: l.lastHeartbeat,
|
|
5828
5983
|
silent: l.flags.includes("silent"),
|
|
5829
5984
|
statusLine: l.statusLine ? { summary: l.statusLine.summary, at: l.statusLine.at, url: l.statusLine.url, plan: l.statusLine.plan } : null,
|
|
5830
5985
|
pr: l.pr ? prRef(l.pr) : null,
|
|
5831
5986
|
openBlockers: l.openBlockers,
|
|
5832
5987
|
flags: l.flags
|
|
5833
5988
|
})),
|
|
5989
|
+
pendingLaunches: followedLaunches(launches, now),
|
|
5834
5990
|
notStarted: notStartedLaunches(launches, now, config.policy.notStartedMinutes).map((l) => {
|
|
5835
5991
|
const issue = issues.find((i) => i.id === l.ticket);
|
|
5836
5992
|
return { ...l, title: issue?.title ?? null, url: issue?.url ?? null, detail: notStartedBody(l, now) };
|
|
@@ -5887,10 +6043,13 @@ async function loadStatus(config, opts) {
|
|
|
5887
6043
|
const launchesP = opts.launches ? opts.launches().then((launches) => ({ launches }), (err) => ({
|
|
5888
6044
|
warning: `Armada's launches could not be read (${err instanceof Error ? err.message : String(err)}); workers launched that never started are not listed`
|
|
5889
6045
|
})) : Promise.resolve({});
|
|
5890
|
-
const [{ program, forge, forgeError }, events, launches] = await Promise.all([
|
|
6046
|
+
const [{ program, forge, forgeError }, events, launches, heartbeats] = await Promise.all([
|
|
5891
6047
|
readStatusSources(config, opts),
|
|
5892
6048
|
eventsP,
|
|
5893
|
-
launchesP
|
|
6049
|
+
launchesP,
|
|
6050
|
+
opts.heartbeats?.().catch(() => {
|
|
6051
|
+
return;
|
|
6052
|
+
})
|
|
5894
6053
|
]);
|
|
5895
6054
|
return buildStatus({
|
|
5896
6055
|
config,
|
|
@@ -5898,13 +6057,17 @@ async function loadStatus(config, opts) {
|
|
|
5898
6057
|
forge,
|
|
5899
6058
|
forgeError,
|
|
5900
6059
|
...events.events ? { lastEvents: events.events } : {},
|
|
6060
|
+
...heartbeats ? { heartbeats } : {},
|
|
5901
6061
|
...launches.launches ? { launches: launches.launches } : {},
|
|
5902
6062
|
extraWarnings: [events.warning, launches.warning].filter((w) => !!w),
|
|
5903
6063
|
now: now()
|
|
5904
6064
|
});
|
|
5905
6065
|
}
|
|
5906
6066
|
// package.json
|
|
5907
|
-
var version = "0.2.
|
|
6067
|
+
var version = "0.2.20";
|
|
6068
|
+
|
|
6069
|
+
// src/attach.ts
|
|
6070
|
+
import { resolve } from "node:path";
|
|
5908
6071
|
|
|
5909
6072
|
// src/api.ts
|
|
5910
6073
|
var runs = new WeakMap;
|
|
@@ -5935,6 +6098,67 @@ class UsageError extends Error {
|
|
|
5935
6098
|
}
|
|
5936
6099
|
var missingKey = (key) => new UsageError(missingKeyMessage(key), "armada auth login");
|
|
5937
6100
|
|
|
6101
|
+
// src/attach.ts
|
|
6102
|
+
async function attachItems(io, config, credentials, target) {
|
|
6103
|
+
const ticket = target.ticket.toUpperCase();
|
|
6104
|
+
if (!/^[A-Z][A-Z0-9]*-\d+$/.test(ticket))
|
|
6105
|
+
throw new UsageError("attachment ticket limit: use a ticket identifier, e.g. WID-15");
|
|
6106
|
+
if (!target.items.length)
|
|
6107
|
+
throw new UsageError("attach needs at least one file or HTTPS URL");
|
|
6108
|
+
const signIn = credentials.armadaSignIn;
|
|
6109
|
+
if (!signIn)
|
|
6110
|
+
throw new UsageError("attachments need a sign-in to Armada", "armada login");
|
|
6111
|
+
if (signIn.kind === "worker" && (signIn.ticket !== ticket || signIn.project !== config.project.slug))
|
|
6112
|
+
throw new UsageError(`attachment ticket limit: this worker session acts on ${signIn.project}/${signIn.ticket} only`);
|
|
6113
|
+
const api = apiOf(io, credentials.armadaApi.url);
|
|
6114
|
+
const uploaded = [];
|
|
6115
|
+
for (const item of target.items) {
|
|
6116
|
+
let input;
|
|
6117
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(item)) {
|
|
6118
|
+
const link = { kind: "link", url: item };
|
|
6119
|
+
const refusal = checkAttachment(link);
|
|
6120
|
+
if (refusal)
|
|
6121
|
+
throw new UsageError(refusal);
|
|
6122
|
+
input = link;
|
|
6123
|
+
} else {
|
|
6124
|
+
if (!io.readBinaryFile)
|
|
6125
|
+
throw new UsageError("this CLI cannot read attachment files");
|
|
6126
|
+
const bytes = await io.readBinaryFile(resolve(io.cwd, item), MAX_ATTACHMENT_BYTES);
|
|
6127
|
+
if (!bytes)
|
|
6128
|
+
throw new UsageError(`attachment file not found: ${item}`);
|
|
6129
|
+
const contentType = attachmentImageType(bytes) ?? "";
|
|
6130
|
+
const refusal = checkAttachment({ kind: "image", contentType, bytes });
|
|
6131
|
+
if (refusal)
|
|
6132
|
+
throw new UsageError(refusal);
|
|
6133
|
+
input = { kind: "image", contentType, data: Buffer.from(bytes).toString("base64") };
|
|
6134
|
+
}
|
|
6135
|
+
const saved = await api.attach(signIn, {
|
|
6136
|
+
project: projectOf(config),
|
|
6137
|
+
ticket,
|
|
6138
|
+
input,
|
|
6139
|
+
caption: target.caption ?? null,
|
|
6140
|
+
reference: target.reference ?? null
|
|
6141
|
+
});
|
|
6142
|
+
uploaded.push(saved);
|
|
6143
|
+
target.onAttached?.(saved);
|
|
6144
|
+
}
|
|
6145
|
+
return uploaded;
|
|
6146
|
+
}
|
|
6147
|
+
async function attachCommand(io, config, credentials, args) {
|
|
6148
|
+
const [ticket, ...items] = args.rest;
|
|
6149
|
+
if (!ticket)
|
|
6150
|
+
throw new UsageError("attach needs a ticket and at least one file or HTTPS URL");
|
|
6151
|
+
await attachItems(io, config, credentials, {
|
|
6152
|
+
ticket,
|
|
6153
|
+
items,
|
|
6154
|
+
caption: args.options.caption,
|
|
6155
|
+
reference: args.options.for,
|
|
6156
|
+
onAttached: (saved) => io.stdout(`${saved.url}
|
|
6157
|
+
`)
|
|
6158
|
+
});
|
|
6159
|
+
return 0;
|
|
6160
|
+
}
|
|
6161
|
+
|
|
5938
6162
|
// src/auth.ts
|
|
5939
6163
|
async function loadMachine(io) {
|
|
5940
6164
|
const paths = machinePaths(io.env);
|
|
@@ -6397,7 +6621,11 @@ function liveFleet(io, config, credentials) {
|
|
|
6397
6621
|
}
|
|
6398
6622
|
function statusLive(io, config, credentials) {
|
|
6399
6623
|
const { fleet } = liveFleet(io, config, credentials);
|
|
6400
|
-
return fleet ? {
|
|
6624
|
+
return fleet ? {
|
|
6625
|
+
lastEvents: () => fleet.lastEventTimes(),
|
|
6626
|
+
heartbeats: () => fleet.heartbeatTimes(),
|
|
6627
|
+
launches: () => fleet.pendingLaunches()
|
|
6628
|
+
} : undefined;
|
|
6401
6629
|
}
|
|
6402
6630
|
function currentTicket(io, config, explicit, workers = []) {
|
|
6403
6631
|
const fromEnv = io.env.ARMADA_TICKET?.trim();
|
|
@@ -6683,6 +6911,7 @@ async function inbox2(io, config, credentials, a) {
|
|
|
6683
6911
|
coordinator: coordinatorHandle(io),
|
|
6684
6912
|
facts: detectCoordinator(io),
|
|
6685
6913
|
silentAfterMinutes: config.policy.silentAfterMinutes,
|
|
6914
|
+
quietAfterMinutes: config.policy.quietAfterMinutes,
|
|
6686
6915
|
notStartedMinutes: config.policy.notStartedMinutes,
|
|
6687
6916
|
now: io.now ?? (() => new Date),
|
|
6688
6917
|
...wait ? { wait: { timeoutMs, sleep: io.sleep ?? ((ms) => new Promise((done) => setTimeout(done, ms))) } } : {}
|
|
@@ -6702,7 +6931,7 @@ async function inbox2(io, config, credentials, a) {
|
|
|
6702
6931
|
}
|
|
6703
6932
|
|
|
6704
6933
|
// src/release.ts
|
|
6705
|
-
var NOTICE_COMMANDS = new Set(["status", "inbox", "watch", "brief", "merge", "doctor"]);
|
|
6934
|
+
var NOTICE_COMMANDS = new Set(["status", "inbox", "watch", "brief", "launch", "merge", "doctor"]);
|
|
6706
6935
|
function newer(io, running) {
|
|
6707
6936
|
const server = heard(io).server;
|
|
6708
6937
|
if (io.env.ARMADA_TICKET?.trim() || !server || compareVersions(running, server.minimum) < 0)
|
|
@@ -6812,6 +7041,7 @@ async function watchUntil(io, config, credentials, json, configPath) {
|
|
|
6812
7041
|
coordinator: coordinatorHandle(io),
|
|
6813
7042
|
facts: detectCoordinator(io),
|
|
6814
7043
|
silentAfterMinutes: config.policy.silentAfterMinutes,
|
|
7044
|
+
quietAfterMinutes: config.policy.quietAfterMinutes,
|
|
6815
7045
|
notStartedMinutes: config.policy.notStartedMinutes,
|
|
6816
7046
|
seen: before?.seen ?? [],
|
|
6817
7047
|
now: io.now ?? (() => new Date),
|
|
@@ -6892,8 +7122,8 @@ function renderBrief(b) {
|
|
|
6892
7122
|
...b.conventions ? [`Conventions: ${b.conventions.path} (under "Project conventions" in the prompt)`] : [],
|
|
6893
7123
|
`Repository: ${b.repository.url}`,
|
|
6894
7124
|
`Branch: ${b.ticket.branch ?? "none suggested by Linear"} (the worker renames its workspace branch to it)`,
|
|
6895
|
-
`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
|
|
6896
|
-
(shown as ${HIDDEN_LAUNCH_TOKEN} here; \`${promptCommand}\` prints it)` : `no launch token${b.noLaunch ? ` (${b.noLaunch})` : ""}: pass the keys below in the worker's environment`}`,
|
|
7125
|
+
`Launch: ${b.launchHint ?? (b.launch ? `one-time token in the prompt, valid until ${b.launch.expiresAt.slice(0, 16).replace("T", " ")} UTC: the worker needs no key
|
|
7126
|
+
(shown as ${HIDDEN_LAUNCH_TOKEN} here; \`${promptCommand}\` prints it)` : `no launch token${b.noLaunch ? ` (${b.noLaunch})` : ""}: pass the keys below in the worker's environment`)}`,
|
|
6897
7127
|
"",
|
|
6898
7128
|
"Environment to pass (values are never printed):",
|
|
6899
7129
|
...b.environment.map((v) => {
|
|
@@ -6920,6 +7150,7 @@ function renderProfileSelection(b) {
|
|
|
6920
7150
|
...b.selection.profiles.map((profile) => ` ${profile.name}: ${profile.when ?? "no when rule; choose only with a reason"}`),
|
|
6921
7151
|
"",
|
|
6922
7152
|
b.selection.hint,
|
|
7153
|
+
...b.launchHint ? [`Launch: ${b.launchHint}`] : [],
|
|
6923
7154
|
...b.warnings.map((warning) => `Warning: ${warning}`)
|
|
6924
7155
|
].join(`
|
|
6925
7156
|
`);
|
|
@@ -6954,6 +7185,8 @@ async function brief2(io, config, credentials, a, version, configPath) {
|
|
|
6954
7185
|
if (extra.length)
|
|
6955
7186
|
throw new UsageError(`unexpected argument ${extra[0]}`);
|
|
6956
7187
|
const promptOnly = a.options.prompt === "true";
|
|
7188
|
+
if (a.options["profile-line"] && !promptOnly)
|
|
7189
|
+
throw new UsageError("--profile-line goes with --prompt");
|
|
6957
7190
|
if (a.json && promptOnly)
|
|
6958
7191
|
throw new UsageError("pass --json or --prompt, not both");
|
|
6959
7192
|
const profile = a.options.profile?.trim() || null;
|
|
@@ -6981,6 +7214,7 @@ async function brief2(io, config, credentials, a, version, configPath) {
|
|
|
6981
7214
|
version,
|
|
6982
7215
|
env: io.env,
|
|
6983
7216
|
stored: STORED_KEYS.filter((k) => credentials.sources[k.name]?.kind === "store").map((k) => k.variable),
|
|
7217
|
+
prompt: promptOnly,
|
|
6984
7218
|
launch: launcher(io, config, credentials),
|
|
6985
7219
|
npm: (v) => checkPublished(v, io.fetch ?? fetch),
|
|
6986
7220
|
conventions,
|
|
@@ -7001,16 +7235,23 @@ async function brief2(io, config, credentials, a, version, configPath) {
|
|
|
7001
7235
|
}
|
|
7002
7236
|
const project = config.project.slug;
|
|
7003
7237
|
const known = (await watchOf(io, project)).state?.inFlight ?? [];
|
|
7004
|
-
const inFlight = [...new Set([...known, b.ticket.id])].sort((x, y) => x.localeCompare(y, "en", { numeric: true }));
|
|
7005
|
-
await remember(io, project, { inFlight, readAt: (io.now ?? (() => new Date))().toISOString() });
|
|
7006
7238
|
if (promptOnly) {
|
|
7239
|
+
const inFlight = [...new Set([...known, b.ticket.id])].sort((x, y) => x.localeCompare(y, "en", { numeric: true }));
|
|
7240
|
+
await remember(io, project, { inFlight, readAt: (io.now ?? (() => new Date))().toISOString() });
|
|
7241
|
+
if (a.options["profile-line"]) {
|
|
7242
|
+
const profile = b.profile;
|
|
7243
|
+
io.stderr(`Profile: ${profile ? `${profile.name}: agent ${profile.agent}, model ${profile.model}, effort ${profile.effort}${profile.fastMode ? ", fast mode" : ""}` : "none declared in armada.toml"}, runtime ${b.runtime}${b.routing ? ` — ${b.routing.why}` : ""}
|
|
7244
|
+
`);
|
|
7245
|
+
io.stderr(`Launch: ${b.launch ? `one-time token made, valid until ${b.launch.expiresAt}` : `no launch token${b.noLaunch ? ` (${b.noLaunch})` : ""}`}
|
|
7246
|
+
`);
|
|
7247
|
+
}
|
|
7007
7248
|
io.stdout(b.prompt);
|
|
7008
7249
|
for (const w of b.warnings)
|
|
7009
7250
|
io.stderr(`armada: warning: ${w}
|
|
7010
7251
|
`);
|
|
7011
7252
|
return 0;
|
|
7012
7253
|
}
|
|
7013
|
-
const next = await rearmFor(io, project, { inFlight, open: null });
|
|
7254
|
+
const next = await rearmFor(io, project, { inFlight: known, open: null });
|
|
7014
7255
|
const shown = hideLaunchToken(b);
|
|
7015
7256
|
if (a.json)
|
|
7016
7257
|
io.stdout(`${JSON.stringify({ ...shown, watch: next }, null, 2)}
|
|
@@ -7374,6 +7615,93 @@ async function doctor(io, json, armadaVersion) {
|
|
|
7374
7615
|
return report.errors ? 1 : 0;
|
|
7375
7616
|
}
|
|
7376
7617
|
|
|
7618
|
+
// src/heartbeat.ts
|
|
7619
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
7620
|
+
async function heartbeat2(io, config, credentials, args) {
|
|
7621
|
+
if (args.rest.length)
|
|
7622
|
+
throw new UsageError("heartbeat takes no positional argument");
|
|
7623
|
+
const interval = args.options.every ?? "5m";
|
|
7624
|
+
const match = interval.match(/^(\d+(?:\.\d+)?)(s|m)$/);
|
|
7625
|
+
const everyMs = match ? Number(match[1]) * (match[2] === "m" ? 60000 : 1000) : 0;
|
|
7626
|
+
if (!Number.isFinite(everyMs) || everyMs < 1000 || everyMs > config.policy.silentAfterMinutes * 60000)
|
|
7627
|
+
throw new UsageError("--every needs seconds or minutes, at least 1s and no longer than policy.silence_minutes");
|
|
7628
|
+
const parent = Number(args.options.parent);
|
|
7629
|
+
if (!Number.isSafeInteger(parent) || parent <= 1)
|
|
7630
|
+
throw new UsageError('--parent needs the persistent agent PID (pass --parent "$PPID" from its command shell)');
|
|
7631
|
+
const ticket = currentTicket(io, config, args.options.ticket, credentials.armadaSignIn?.kind === "worker" ? [credentials.armadaSignIn.ticket] : []);
|
|
7632
|
+
const handle = args.options.handle || (io.env.CONDUCTOR_WORKSPACE_ID && io.env.CONDUCTOR_SESSION_ID ? `${io.env.CONDUCTOR_WORKSPACE_ID}/${io.env.CONDUCTOR_SESSION_ID}` : null);
|
|
7633
|
+
if (!handle)
|
|
7634
|
+
throw new UsageError("heartbeat needs --handle <claim-handle> outside Conductor");
|
|
7635
|
+
const alive = () => !io.stopped?.() && (io.processAlive ?? processAlive)(parent);
|
|
7636
|
+
if (!alive())
|
|
7637
|
+
throw new UsageError("the heartbeat parent no longer runs");
|
|
7638
|
+
const { fleet } = liveFleet(io, config, credentials);
|
|
7639
|
+
if (!fleet)
|
|
7640
|
+
throw new UsageError("heartbeat needs an Armada sign-in; use manual reports at least every 15 minutes");
|
|
7641
|
+
if (args.options.background === "true") {
|
|
7642
|
+
let started = false;
|
|
7643
|
+
try {
|
|
7644
|
+
started = await io.startBackground?.([
|
|
7645
|
+
"heartbeat",
|
|
7646
|
+
"--ticket",
|
|
7647
|
+
ticket,
|
|
7648
|
+
"--handle",
|
|
7649
|
+
handle,
|
|
7650
|
+
"--every",
|
|
7651
|
+
interval,
|
|
7652
|
+
"--parent",
|
|
7653
|
+
String(parent),
|
|
7654
|
+
...args.config ? ["--config", args.config] : []
|
|
7655
|
+
]) ?? false;
|
|
7656
|
+
} catch {}
|
|
7657
|
+
if (!started) {
|
|
7658
|
+
io.stderr(`armada: background heartbeat unavailable; report manually at least every 15 minutes.
|
|
7659
|
+
`);
|
|
7660
|
+
return 1;
|
|
7661
|
+
}
|
|
7662
|
+
io.stdout(`Heartbeat running in the background for ${ticket} (every ${interval}, parent ${parent}).
|
|
7663
|
+
`);
|
|
7664
|
+
return 0;
|
|
7665
|
+
}
|
|
7666
|
+
const paths = machinePaths(io.env);
|
|
7667
|
+
if (!paths)
|
|
7668
|
+
throw new UsageError("heartbeat needs HOME or XDG_CONFIG_HOME for its PID file");
|
|
7669
|
+
const pid = io.pid ?? process.pid;
|
|
7670
|
+
let lock = null;
|
|
7671
|
+
let ready = false;
|
|
7672
|
+
try {
|
|
7673
|
+
const result = await heartbeatLoop({
|
|
7674
|
+
ticket,
|
|
7675
|
+
handle,
|
|
7676
|
+
everyMs,
|
|
7677
|
+
now: io.now ?? (() => new Date),
|
|
7678
|
+
sleep: io.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms))),
|
|
7679
|
+
parentAlive: alive,
|
|
7680
|
+
ping: (input) => fleet.heartbeat(input),
|
|
7681
|
+
ready: async (session) => {
|
|
7682
|
+
const name = `${config.project.slug}-heartbeat-${ticket.toLowerCase()}-${createHash3("sha256").update(`${handle}/${session.claimedAt}`).digest("hex").slice(0, 12)}`;
|
|
7683
|
+
const acquired = await takeWatchLock(paths, name, pid, io.processAlive ?? processAlive);
|
|
7684
|
+
if (acquired.taken)
|
|
7685
|
+
lock = name;
|
|
7686
|
+
ready = true;
|
|
7687
|
+
io.backgroundReady?.(true);
|
|
7688
|
+
return acquired.taken;
|
|
7689
|
+
}
|
|
7690
|
+
});
|
|
7691
|
+
if (!ready)
|
|
7692
|
+
io.backgroundReady?.(false);
|
|
7693
|
+
return result === "session-ended" && !ready ? 1 : 0;
|
|
7694
|
+
} catch {
|
|
7695
|
+
io.backgroundReady?.(false);
|
|
7696
|
+
io.stderr(`armada: heartbeat unavailable; report manually at least every 15 minutes.
|
|
7697
|
+
`);
|
|
7698
|
+
return 1;
|
|
7699
|
+
} finally {
|
|
7700
|
+
if (lock)
|
|
7701
|
+
await releaseWatchLock(paths, lock, pid);
|
|
7702
|
+
}
|
|
7703
|
+
}
|
|
7704
|
+
|
|
7377
7705
|
// src/init.ts
|
|
7378
7706
|
import { mkdtemp, realpath, rm as rm3 } from "node:fs/promises";
|
|
7379
7707
|
import { tmpdir } from "node:os";
|
|
@@ -7583,6 +7911,27 @@ async function init(io, opts) {
|
|
|
7583
7911
|
}
|
|
7584
7912
|
}
|
|
7585
7913
|
|
|
7914
|
+
// src/launch.ts
|
|
7915
|
+
async function launch(io, config, credentials, args) {
|
|
7916
|
+
const [operation, ticket, ...extra] = args.rest;
|
|
7917
|
+
if (operation !== "revoke" || !ticket || extra.length || !/^[A-Za-z][A-Za-z0-9]{0,15}-\d{1,9}$/.test(ticket))
|
|
7918
|
+
throw new UsageError("launch needs a ticket to revoke: armada launch revoke <ticket>");
|
|
7919
|
+
const revoked = await apiOf(io, credentials.armadaApi.url).revokeLaunch(requireSignIn(credentials), {
|
|
7920
|
+
project: config.project.slug,
|
|
7921
|
+
ticket: ticket.toUpperCase()
|
|
7922
|
+
});
|
|
7923
|
+
const known = (await watchOf(io, config.project.slug)).state?.inFlight;
|
|
7924
|
+
const inFlight = known?.filter((held) => held !== revoked.ticket) ?? null;
|
|
7925
|
+
if (inFlight)
|
|
7926
|
+
await remember(io, config.project.slug, { inFlight, readAt: (io.now ?? (() => new Date))().toISOString() });
|
|
7927
|
+
const watch = await rearmFor(io, config.project.slug, { inFlight, open: null });
|
|
7928
|
+
io.stdout(args.json ? `${JSON.stringify({ ...revoked, watch }, null, 2)}
|
|
7929
|
+
` : `Revoked the pending launch of ${revoked.ticket}.
|
|
7930
|
+
${watch.line}
|
|
7931
|
+
`);
|
|
7932
|
+
return 0;
|
|
7933
|
+
}
|
|
7934
|
+
|
|
7586
7935
|
// src/merge.ts
|
|
7587
7936
|
import { randomUUID } from "node:crypto";
|
|
7588
7937
|
import { rm as rm4 } from "node:fs/promises";
|
|
@@ -7888,13 +8237,16 @@ function renderStatus(r) {
|
|
|
7888
8237
|
if (t.flags.length)
|
|
7889
8238
|
out.push(`${indent}! ${t.flags.join(", ")}`);
|
|
7890
8239
|
}
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
8240
|
+
const pending = r.pendingLaunches ?? r.notStarted;
|
|
8241
|
+
if (pending.length) {
|
|
8242
|
+
out.push("", `Pending launches (${pending.length})`);
|
|
8243
|
+
for (const l of pending) {
|
|
7894
8244
|
out.push(` ${pad(l.ticket, idWidth)} launched ${relative2(l.launchedAt, now)} · ${l.tokenUsedAt ? `signed in ${relative2(l.tokenUsedAt, now)}, no claim` : "launch token never used"}${l.handle ? ` · ${l.handle}` : ""}`);
|
|
7895
|
-
|
|
7896
|
-
|
|
8245
|
+
const title = r.notStarted.find((launch) => launch.ticket === l.ticket)?.title;
|
|
8246
|
+
if (title)
|
|
8247
|
+
out.push(`${indent}${truncate(title, 90)}`);
|
|
7897
8248
|
out.push(`${indent}! check its session with the runtime guide's status section`);
|
|
8249
|
+
out.push(`${indent}Cancel: armada launch revoke ${l.ticket}`);
|
|
7898
8250
|
}
|
|
7899
8251
|
}
|
|
7900
8252
|
const ready = r.frontier.filter((t) => t.readyForAgent);
|
|
@@ -7993,7 +8345,7 @@ ${"─".repeat(60)}
|
|
|
7993
8345
|
}
|
|
7994
8346
|
|
|
7995
8347
|
// src/secrets.ts
|
|
7996
|
-
import { dirname as dirname6, relative as relative3, resolve } from "node:path";
|
|
8348
|
+
import { dirname as dirname6, relative as relative3, resolve as resolve2 } from "node:path";
|
|
7997
8349
|
var NAME_HINT = "upper snake case, e.g. OPENAI_API_KEY";
|
|
7998
8350
|
var hhmm2 = (iso) => `${iso.slice(0, 16).replace("T", " ")} UTC`;
|
|
7999
8351
|
function signInOf(config, credentials) {
|
|
@@ -8156,7 +8508,7 @@ async function secretsCommand(io, config, credentials, args) {
|
|
|
8156
8508
|
const file = args.options.file;
|
|
8157
8509
|
if (!file)
|
|
8158
8510
|
throw new UsageError("secrets export needs --file <path>, a file git ignores (e.g. .env.local)");
|
|
8159
|
-
const path =
|
|
8511
|
+
const path = resolve2(io.cwd, file);
|
|
8160
8512
|
const refusal = await exportRefusal(io, path);
|
|
8161
8513
|
if (refusal)
|
|
8162
8514
|
throw new UsageError(refusal, "a path git ignores, e.g. .env.local listed in .gitignore");
|
|
@@ -8210,6 +8562,16 @@ async function runCommand(io, config, credentials, args) {
|
|
|
8210
8562
|
|
|
8211
8563
|
// src/cli.ts
|
|
8212
8564
|
var COMMAND_HELP = {
|
|
8565
|
+
attach: ` attach <ticket> <file|url>... [--caption <text>] [--for <item>]
|
|
8566
|
+
Privately attach PNG, JPEG, WebP or GIF images (up to 2 MB each),
|
|
8567
|
+
or HTTPS links. Prints a dashboard URL for each attachment.
|
|
8568
|
+
--for keeps a free reference for an owner validation item
|
|
8569
|
+
`,
|
|
8570
|
+
heartbeat: ` heartbeat --every 5m --parent <agent-pid> [--background] [--ticket <id>] [--handle <id>]
|
|
8571
|
+
Keep the current worker session alive through Armada only, with no
|
|
8572
|
+
Linear comment. Stops with the parent or the released/revoked session.
|
|
8573
|
+
--background detaches from the command shell and keeps a PID file
|
|
8574
|
+
`,
|
|
8213
8575
|
status: ` status Tickets in flight, tickets ready to start and pull requests waiting
|
|
8214
8576
|
status --all The same for every project registered by \`armada init\`
|
|
8215
8577
|
`,
|
|
@@ -8282,7 +8644,11 @@ var COMMAND_HELP = {
|
|
|
8282
8644
|
--no-ticket: a pull request no ticket owns (armada init, a release);
|
|
8283
8645
|
nothing is written to Linear.
|
|
8284
8646
|
`,
|
|
8285
|
-
|
|
8647
|
+
launch: ` launch revoke <ticket>
|
|
8648
|
+
Cancel the newest pending launch through Armada, including a worker
|
|
8649
|
+
signed in but not claimed. A claimed launch needs armada release instead
|
|
8650
|
+
`,
|
|
8651
|
+
brief: ` brief <ticket> [--profile <name> [--reason <why>]] [--prompt [--profile-line]]
|
|
8286
8652
|
A new worker's launch prompt, the Conductor profile (agent, model,
|
|
8287
8653
|
effort) and the environment variables to pass, named, never shown.
|
|
8288
8654
|
The profile follows [[conductor.routing]] on the ticket's labels, then
|
|
@@ -8290,6 +8656,8 @@ var COMMAND_HELP = {
|
|
|
8290
8656
|
--reason. Only projects without when fall back to default_profile.
|
|
8291
8657
|
Signed in to Armada, the prompt starts with a one-time launch token, so
|
|
8292
8658
|
the worker needs no key. --prompt prints only the prompt, for \`--message-file -\`
|
|
8659
|
+
Human and --json views mint nothing. --prompt --profile-line also
|
|
8660
|
+
prints the profile and its reason on stderr, leaving stdout unchanged
|
|
8293
8661
|
`,
|
|
8294
8662
|
secrets: ` secrets The project's secrets for workers: names, project or organization,
|
|
8295
8663
|
who set each and when; never a value. Needs a sign-in to Armada
|
|
@@ -8334,6 +8702,7 @@ var COMMAND_HELP = {
|
|
|
8334
8702
|
};
|
|
8335
8703
|
var TICKET_OPTION = new Set(["report", "release", "ask", "merge", "secrets", "run"]);
|
|
8336
8704
|
var CONFIG_OPTION = new Set([
|
|
8705
|
+
"attach",
|
|
8337
8706
|
"status",
|
|
8338
8707
|
"secrets",
|
|
8339
8708
|
"run",
|
|
@@ -8345,9 +8714,15 @@ var CONFIG_OPTION = new Set([
|
|
|
8345
8714
|
"watch",
|
|
8346
8715
|
"answer",
|
|
8347
8716
|
"merge",
|
|
8348
|
-
"brief"
|
|
8717
|
+
"brief",
|
|
8718
|
+
"launch"
|
|
8719
|
+
]);
|
|
8720
|
+
var JSON_OPTION = new Set([
|
|
8721
|
+
...[...CONFIG_OPTION].filter((c) => c !== "run" && c !== "attach"),
|
|
8722
|
+
"doctor",
|
|
8723
|
+
"auth",
|
|
8724
|
+
"whoami"
|
|
8349
8725
|
]);
|
|
8350
|
-
var JSON_OPTION = new Set([...[...CONFIG_OPTION].filter((c) => c !== "run"), "doctor", "auth", "whoami"]);
|
|
8351
8726
|
var TICKET_HELP = ` --ticket <id> Ticket for report, release and ask (default ARMADA_TICKET, then the git
|
|
8352
8727
|
branch) and for merge (default: the ticket the PR branch names)
|
|
8353
8728
|
`;
|
|
@@ -8402,6 +8777,8 @@ Options:
|
|
|
8402
8777
|
${options.join("")}`;
|
|
8403
8778
|
}
|
|
8404
8779
|
var VALUE_OPTIONS = [
|
|
8780
|
+
"every",
|
|
8781
|
+
"parent",
|
|
8405
8782
|
"runtime",
|
|
8406
8783
|
"handle",
|
|
8407
8784
|
"branch",
|
|
@@ -8423,13 +8800,17 @@ var VALUE_OPTIONS = [
|
|
|
8423
8800
|
"api-url",
|
|
8424
8801
|
"only",
|
|
8425
8802
|
"file",
|
|
8426
|
-
"from-env"
|
|
8803
|
+
"from-env",
|
|
8804
|
+
"caption",
|
|
8805
|
+
"for"
|
|
8427
8806
|
];
|
|
8428
8807
|
var FLAG_OPTIONS = [
|
|
8808
|
+
"background",
|
|
8429
8809
|
"dry-run",
|
|
8430
8810
|
"no-lock",
|
|
8431
8811
|
"no-ticket",
|
|
8432
8812
|
"prompt",
|
|
8813
|
+
"profile-line",
|
|
8433
8814
|
"wait",
|
|
8434
8815
|
"note",
|
|
8435
8816
|
"api-key",
|
|
@@ -8438,6 +8819,8 @@ var FLAG_OPTIONS = [
|
|
|
8438
8819
|
"value-stdin"
|
|
8439
8820
|
];
|
|
8440
8821
|
var COMMAND_OPTIONS = {
|
|
8822
|
+
attach: ["caption", "for"],
|
|
8823
|
+
heartbeat: ["every", "parent", "background", "ticket", "handle"],
|
|
8441
8824
|
claim: ["runtime", "handle", "branch", "profile", "reason"],
|
|
8442
8825
|
report: ["ticket", "message", "message-file", "plan", "plan-file", "pr", "sha"],
|
|
8443
8826
|
release: ["ticket", "reason"],
|
|
@@ -8446,7 +8829,7 @@ var COMMAND_OPTIONS = {
|
|
|
8446
8829
|
answer: ["note", "message", "message-file"],
|
|
8447
8830
|
init: ["program-root", "name", "slug", "no-stop-hook"],
|
|
8448
8831
|
merge: ["ticket", "no-ticket", "dry-run", "no-lock", "wait", "timeout"],
|
|
8449
|
-
brief: ["profile", "reason", "prompt"],
|
|
8832
|
+
brief: ["profile", "reason", "prompt", "profile-line"],
|
|
8450
8833
|
login: ["api-key", "launch-token", "api-url"],
|
|
8451
8834
|
secrets: ["ticket", "org", "value-stdin", "from-env", "file", "only"],
|
|
8452
8835
|
run: ["ticket", "only"]
|
|
@@ -8501,13 +8884,13 @@ function parseArgs(argv) {
|
|
|
8501
8884
|
}
|
|
8502
8885
|
async function findConfig(io, explicit, command = "status") {
|
|
8503
8886
|
if (explicit) {
|
|
8504
|
-
const path =
|
|
8887
|
+
const path = resolve3(io.cwd, explicit);
|
|
8505
8888
|
const text = await io.readFile(path);
|
|
8506
8889
|
if (text === null)
|
|
8507
8890
|
throw new UsageError(`${path} does not exist`, `armada ${command} --config <file>, with the path of an ${CONFIG_FILE}`);
|
|
8508
8891
|
return { path, text };
|
|
8509
8892
|
}
|
|
8510
|
-
for (let dir =
|
|
8893
|
+
for (let dir = resolve3(io.cwd);; dir = dirname7(dir)) {
|
|
8511
8894
|
const path = join6(dir, CONFIG_FILE);
|
|
8512
8895
|
const text = await io.readFile(path);
|
|
8513
8896
|
if (text !== null)
|
|
@@ -8619,6 +9002,28 @@ async function dispatch(argv, io) {
|
|
|
8619
9002
|
});
|
|
8620
9003
|
return await (args.command === "run" ? runCommand : secretsCommand)(io, config, credentials, args);
|
|
8621
9004
|
}
|
|
9005
|
+
if (args.command === "attach") {
|
|
9006
|
+
const { path, text } = await findConfig(io, args.config, "attach");
|
|
9007
|
+
const config = parseConfig(text, path);
|
|
9008
|
+
const { credentials } = await loadCredentials(io, {
|
|
9009
|
+
armada: false,
|
|
9010
|
+
worker: { command: "attach", project: config.project.slug, ticket: () => args.rest[0]?.toUpperCase() ?? null }
|
|
9011
|
+
});
|
|
9012
|
+
return await attachCommand(io, config, credentials, args);
|
|
9013
|
+
}
|
|
9014
|
+
if (args.command === "heartbeat") {
|
|
9015
|
+
const { path, text } = await findConfig(io, args.config, "heartbeat");
|
|
9016
|
+
const config = parseConfig(text, path);
|
|
9017
|
+
const { credentials } = await loadCredentials(io, {
|
|
9018
|
+
armada: false,
|
|
9019
|
+
worker: {
|
|
9020
|
+
command: "heartbeat",
|
|
9021
|
+
project: config.project.slug,
|
|
9022
|
+
ticket: (stored) => currentTicket(io, config, args.options.ticket, stored)
|
|
9023
|
+
}
|
|
9024
|
+
});
|
|
9025
|
+
return await heartbeat2(io, config, credentials, args);
|
|
9026
|
+
}
|
|
8622
9027
|
const worker = { claim, report, release, ask, inbox: inbox2, answer }[args.command];
|
|
8623
9028
|
if (worker) {
|
|
8624
9029
|
const { path, text } = await findConfig(io, args.config, args.command);
|
|
@@ -8654,9 +9059,16 @@ async function dispatch(argv, io) {
|
|
|
8654
9059
|
const { path, text } = await findConfig(io, args.config, "brief");
|
|
8655
9060
|
const config = parseConfig(text, path);
|
|
8656
9061
|
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
8657
|
-
|
|
9062
|
+
if (args.options.prompt === "true")
|
|
9063
|
+
await recordPresence(io, config, credentials);
|
|
8658
9064
|
return await brief2(io, config, credentials, args, version, path);
|
|
8659
9065
|
}
|
|
9066
|
+
if (args.command === "launch") {
|
|
9067
|
+
const { path, text } = await findConfig(io, args.config, "launch");
|
|
9068
|
+
const config = parseConfig(text, path);
|
|
9069
|
+
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
9070
|
+
return await launch(io, config, credentials, args);
|
|
9071
|
+
}
|
|
8660
9072
|
if (args.command === "status") {
|
|
8661
9073
|
noExtra(args.rest);
|
|
8662
9074
|
return await (args.all ? statusAll(io, args.json) : status2(io, args));
|
|
@@ -8769,6 +9181,33 @@ var spawnInherited = (command, args, { cwd, env }) => new Promise((done, fail) =
|
|
|
8769
9181
|
done(code ?? 128 + (signal ? constants.signals[signal] ?? 0 : 0));
|
|
8770
9182
|
});
|
|
8771
9183
|
});
|
|
9184
|
+
var startBackground = (args) => new Promise((resolve) => {
|
|
9185
|
+
if (process.platform === "win32")
|
|
9186
|
+
return resolve(false);
|
|
9187
|
+
const child = spawn(process.execPath, [...process.execArgv, process.argv[1], ...args], {
|
|
9188
|
+
cwd: process.cwd(),
|
|
9189
|
+
env: process.env,
|
|
9190
|
+
detached: true,
|
|
9191
|
+
stdio: ["ignore", "ignore", "ignore", "ipc"]
|
|
9192
|
+
});
|
|
9193
|
+
let settled = false;
|
|
9194
|
+
const finish = (ready) => {
|
|
9195
|
+
if (settled)
|
|
9196
|
+
return;
|
|
9197
|
+
settled = true;
|
|
9198
|
+
clearTimeout(timeout);
|
|
9199
|
+
if (!ready)
|
|
9200
|
+
child.kill("SIGTERM");
|
|
9201
|
+
if (child.connected)
|
|
9202
|
+
child.disconnect();
|
|
9203
|
+
child.unref();
|
|
9204
|
+
resolve(ready);
|
|
9205
|
+
};
|
|
9206
|
+
const timeout = setTimeout(() => finish(false), 20000);
|
|
9207
|
+
child.once("error", () => finish(false));
|
|
9208
|
+
child.once("exit", () => finish(false));
|
|
9209
|
+
child.once("message", (message) => finish(typeof message === "object" && message !== null && "ready" in message && message.ready === true));
|
|
9210
|
+
});
|
|
8772
9211
|
|
|
8773
9212
|
// src/main.ts
|
|
8774
9213
|
function gitBranch() {
|
|
@@ -8848,6 +9287,12 @@ var exec = (command, args, { cwd }) => new Promise((done, fail) => {
|
|
|
8848
9287
|
child.on("error", fail);
|
|
8849
9288
|
child.on("close", (code) => done({ code: code ?? 1, stdout, stderr }));
|
|
8850
9289
|
});
|
|
9290
|
+
var stopped = false;
|
|
9291
|
+
if (process.argv.includes("heartbeat") && !process.argv.includes("--background"))
|
|
9292
|
+
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"])
|
|
9293
|
+
process.on(signal, () => {
|
|
9294
|
+
stopped = true;
|
|
9295
|
+
});
|
|
8851
9296
|
var code = await run(process.argv.slice(2), {
|
|
8852
9297
|
machineName: hostname2(),
|
|
8853
9298
|
ttyName: process.stdin.isTTY ? spawnSync("tty", [], { encoding: "utf8", stdio: ["inherit", "pipe", "ignore"] }).stdout?.trim() || null : null,
|
|
@@ -8859,6 +9304,35 @@ var code = await run(process.argv.slice(2), {
|
|
|
8859
9304
|
throw err;
|
|
8860
9305
|
}),
|
|
8861
9306
|
stdout: (t) => process.stdout.write(t),
|
|
9307
|
+
readBinaryFile: async (path, maxBytes) => {
|
|
9308
|
+
const file = await open2(path, "r").catch((err) => {
|
|
9309
|
+
if (err.code === "ENOENT" || err.code === "ENOTDIR")
|
|
9310
|
+
return null;
|
|
9311
|
+
throw err;
|
|
9312
|
+
});
|
|
9313
|
+
if (!file)
|
|
9314
|
+
return null;
|
|
9315
|
+
try {
|
|
9316
|
+
const stat = await file.stat();
|
|
9317
|
+
if (!stat.isFile())
|
|
9318
|
+
throw new UsageError("attachment must be a regular image file");
|
|
9319
|
+
if (stat.size > maxBytes)
|
|
9320
|
+
throw new UsageError("attachment size limit: images must be at most 2 MB each");
|
|
9321
|
+
const buffer = Buffer.alloc(maxBytes + 1);
|
|
9322
|
+
let size = 0;
|
|
9323
|
+
while (size < buffer.length) {
|
|
9324
|
+
const { bytesRead } = await file.read(buffer, size, buffer.length - size, null);
|
|
9325
|
+
if (!bytesRead)
|
|
9326
|
+
break;
|
|
9327
|
+
size += bytesRead;
|
|
9328
|
+
}
|
|
9329
|
+
if (size > maxBytes)
|
|
9330
|
+
throw new UsageError("attachment size limit: images must be at most 2 MB each");
|
|
9331
|
+
return buffer.subarray(0, size);
|
|
9332
|
+
} finally {
|
|
9333
|
+
await file.close();
|
|
9334
|
+
}
|
|
9335
|
+
},
|
|
8862
9336
|
stderr: (t) => process.stderr.write(t),
|
|
8863
9337
|
ghToken,
|
|
8864
9338
|
interactive: isatty(0) && isatty(2),
|
|
@@ -8867,6 +9341,14 @@ var code = await run(process.argv.slice(2), {
|
|
|
8867
9341
|
readStdin,
|
|
8868
9342
|
exec,
|
|
8869
9343
|
spawn: spawnInherited,
|
|
9344
|
+
startBackground,
|
|
9345
|
+
stopped: () => stopped,
|
|
9346
|
+
backgroundReady: (ready) => {
|
|
9347
|
+
if (process.connected)
|
|
9348
|
+
process.send?.({ ready });
|
|
9349
|
+
},
|
|
8870
9350
|
openUrl
|
|
8871
9351
|
});
|
|
8872
9352
|
process.exitCode = code;
|
|
9353
|
+
if (process.connected)
|
|
9354
|
+
process.disconnect?.();
|