@the-vibe-company/armada 0.1.15 → 0.1.17
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 +24 -7
- package/dist/armada.js +218 -45
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -97,21 +97,23 @@ armada release --reason "wrong ticket"
|
|
|
97
97
|
- `report` and `release` find the ticket from `--ticket`, then `ARMADA_TICKET`, then the current git branch (`feature/abc-12-…`).
|
|
98
98
|
- Turso is optional. When it is not configured or not reachable, the commands still write Linear and print a warning.
|
|
99
99
|
|
|
100
|
-
##
|
|
100
|
+
## Plans, questions and answers
|
|
101
101
|
|
|
102
102
|
```sh
|
|
103
103
|
armada ask "Which store keeps the sessions? I recommend SQLite." --options "SQLite | Redis" # worker
|
|
104
104
|
armada inbox # coordinator: what waits, oldest first
|
|
105
105
|
armada inbox --wait # returns when a new item arrives, or after --timeout (default 300 s)
|
|
106
106
|
armada answer 12 "SQLite, for the first slice." # after delivering it in the worker's session
|
|
107
|
+
armada answer 13 "approved" # a plan, after delivering approval
|
|
107
108
|
armada answer --note ABC-12 "main moved: rebase before you ship" # an unsolicited message, same path
|
|
108
109
|
```
|
|
109
110
|
|
|
110
111
|
- `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 in Turso. The worker then stops and waits for the answer in its session, and reports the phase it resumes. It finds the ticket like `report`.
|
|
111
|
-
- `
|
|
112
|
+
- `report awaiting-approval` adds a `plan` item with the full message 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, post the plan with `report implementing` instead: no approval item is needed.
|
|
113
|
+
- `inbox` lists the coordinator's open items (questions, plans, requests, hand-backs) and silent workers, oldest first. A worker is silent when it holds a ticket, its newest Turso event is older than `policy.silence_minutes`, and its phase does not wait on someone else. It reads Turso only (no Linear key) and records that the coordinator is at work, for the dashboard. `--wait` polls every 5 s and marks the items that were not there before with `*`; loop on it.
|
|
112
114
|
- 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.
|
|
113
|
-
- `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 Turso; a ticket id answers that ticket's open questions and also works without Turso. `--note` records a
|
|
114
|
-
- The dashboard adds two kinds of request, signed by the person who made them.
|
|
115
|
+
- `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 Turso; a ticket id answers that ticket's open questions and plans and also works without Turso. `--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. A worker that does not report within `policy.silence_minutes` of an answer shows as silent.
|
|
116
|
+
- 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.
|
|
115
117
|
|
|
116
118
|
## Merge a finished pull request (coordinator)
|
|
117
119
|
|
|
@@ -160,7 +162,7 @@ ARMADA_AUTH_URL=http://localhost:4822 ARMADA_AUTH_OWNER_EMAILS=you@example.com b
|
|
|
160
162
|
**Deploy on Vercel.** Create a project from this repository and set these options:
|
|
161
163
|
|
|
162
164
|
- Root Directory: `packages/dashboard`, with files outside the root directory included (the default). The framework preset is Next.js, and Bun installs the workspace from `bun.lock`.
|
|
163
|
-
- Environment variables: the accounts variables below (or, until they are set, `ARMADA_DASHBOARD_PASSWORD`), `LINEAR_API_KEY`, `GITHUB_TOKEN`, `ARMADA_TURSO_URL` and `ARMADA_TURSO_TOKEN`. Optional: `ARMADA_REPOSITORIES` (the `owner/name` list shown while Turso is unreachable on a fresh server), `ARMADA_DASHBOARD_LANGUAGE` (`en` or `fr`), `ARMADA_DASHBOARD_SNAPSHOT_SECONDS` (Linear and GitHub read period, default 60) and `ARMADA_DASHBOARD_AUTHOR` (the name requests are signed with until a viewer gives theirs). Never add a runtime token (Conductor or other): the coordinator carries out every request.
|
|
165
|
+
- Environment variables: the accounts variables below (or, until they are set, `ARMADA_DASHBOARD_PASSWORD`), `LINEAR_API_KEY`, `GITHUB_TOKEN`, `ARMADA_TURSO_URL` and `ARMADA_TURSO_TOKEN`. With accounts and the vault (`ARMADA_SECRETS_KEY`, see [Keys kept in Armada](#keys-kept-in-armada)), the last four move to the Keys page and are only a fallback here. Optional: `ARMADA_REPOSITORIES` (the `owner/name` list shown while Turso is unreachable on a fresh server), `ARMADA_DASHBOARD_LANGUAGE` (`en` or `fr`), `ARMADA_DASHBOARD_SNAPSHOT_SECONDS` (Linear and GitHub read period, default 60) and `ARMADA_DASHBOARD_AUTHOR` (the name requests are signed with until a viewer gives theirs). Never add a runtime token (Conductor or other): the coordinator carries out every request.
|
|
164
166
|
- The keys stay on the server; the browser only receives the fleet reading.
|
|
165
167
|
|
|
166
168
|
**Accounts.** People sign in with GitHub (or email and password where enabled) and belong to organizations, with the roles owner, admin and member. Accounts, sessions, organizations and invitations live in a libSQL database of their own, separate from the fleet's Turso database; its schema is applied on first use. Accounts turn on only when every required variable below is set. With none of them set, the shared password applies, unchanged; with some but not all, the dashboard fails closed (503, naming the missing ones) rather than fall back to a password that shows every organization's projects.
|
|
@@ -180,6 +182,19 @@ ARMADA_AUTH_URL=http://localhost:4822 ARMADA_AUTH_OWNER_EMAILS=you@example.com b
|
|
|
180
182
|
- Sessions are HttpOnly, SameSite=Lax cookies (Secure over https) valid 30 days; a revoked session can last up to five minutes (signed cookie cache). Without its accounts database the dashboard fails closed (503).
|
|
181
183
|
- Terminals sign in too (see [Sign in from a terminal](#sign-in-from-a-terminal)): `armada login` shows a code that the person confirms on the dashboard's `/device` page, and owners create API keys for headless coordinators on the Organization page. A key is shown once, belongs to the organization, and revoking it signs out whatever uses it. The CLI calls only `/api/cli/*`; without accounts those routes refuse with the next step.
|
|
182
184
|
|
|
185
|
+
**Keys kept in Armada.** With accounts, the organization's keys can live in Armada instead of on every machine: an owner or admin enters them once on the Keys page (Organization > Keys), and every signed-in terminal receives what it needs (see [Keys](#keys)). It turns on with one more variable:
|
|
186
|
+
|
|
187
|
+
| Variable | What |
|
|
188
|
+
| --- | --- |
|
|
189
|
+
| `ARMADA_SECRETS_KEY` | The vault's master key: 32 random bytes in base64 or hex, `openssl rand -base64 32`. It stays in the deployment's environment, never in a database. Changing it makes every stored key unreadable (the Keys page asks to enter them again) |
|
|
190
|
+
|
|
191
|
+
- The Keys page holds the Linear API key; the Turso access: a Platform API token (`turso auth api-tokens mint armada`) with the Turso organization and database names, or, without one, the database URL and a database token; and a GitHub token for the dashboard's own reads. Each member may add their own Linear key: their terminals use it, so the comments they post carry their name.
|
|
192
|
+
- Values are write-only: once saved, a secret is never shown again, only who set it and when. Each value is sealed with AES-256-GCM under its own data key, itself sealed by the master key, and bound to its organization, person and name.
|
|
193
|
+
- A signed-in terminal (a session of `armada login` or an organization API key) calls `POST /api/cli/credentials`. It receives the Linear key (the person's own first) and a Turso database token made for it through the Turso Platform API, which expires after 4 hours and is renewed without asking. Without a Platform token, the stored database token is handed out as is, and the audit list says so. Answers are never cached; a terminal asking more than 30 times a minute is refused for a minute.
|
|
194
|
+
- Every change and every key handed out is in the audit list at the bottom of the Keys page (owners and admins): who, which key, when; never a value.
|
|
195
|
+
- The dashboard reads each organization's fleet with that organization's keys from the vault, each missing one from its environment variables; once they are all on the Keys page, its environment shrinks to the accounts variables and `ARMADA_SECRETS_KEY`. A Turso database given on the Keys page is the organization's own: the projects registered in it belong to that organization, and, unless it is the deployment's first organization, it is read with none of the environment's keys (nor `ARMADA_REPOSITORIES`), since its registry could name any repository.
|
|
196
|
+
- Without `ARMADA_SECRETS_KEY` (or under the shared password), nothing changes: the Keys page says how to turn the vault on, the CLI's call answers 503 with that next step, and terminals keep their own keys.
|
|
197
|
+
|
|
183
198
|
**Switch from the shared password to accounts** (a deployment that runs on `ARMADA_DASHBOARD_PASSWORD` keeps working until the redeploy of step 4; set every variable before it, since a partial set locks the dashboard):
|
|
184
199
|
|
|
185
200
|
1. Create the accounts database (`turso db create armada-accounts`, then `turso db show armada-accounts --url` and `turso db tokens create armada-accounts`) and set `ARMADA_AUTH_DATABASE_URL` and `ARMADA_AUTH_DATABASE_TOKEN`.
|
|
@@ -216,7 +231,9 @@ armada logout # revokes this terminal's session and removes it from the machi
|
|
|
216
231
|
|
|
217
232
|
## Keys
|
|
218
233
|
|
|
219
|
-
Armada needs a few keys.
|
|
234
|
+
Armada needs a few keys. A terminal signed in to an Armada that keeps its organization's keys ([Keys kept in Armada](#keys-kept-in-armada)) needs none on the machine: `armada login`, then `armada status`. Otherwise set them up once per machine with `armada auth login`, or pass them as environment variables (the way to go in CI and cloud sandboxes).
|
|
235
|
+
|
|
236
|
+
Each key comes from the environment first, then from Armada when signed in, then from the credentials file. Armada is asked only for what the environment does not set, on each command that needs keys, so a key replaced on the Keys page takes effect on the next command. The Linear key it gives stays in memory; the Turso token it makes for the terminal is kept in the credentials file (`ARMADA_TURSO_LEASE`, with its expiry) and renewed when less than an hour is left. When Armada cannot be reached, the command warns and goes on with the machine's keys (and the Turso token kept earlier, until it expires). `armada logout` and `armada auth logout` remove the kept token.
|
|
220
237
|
|
|
221
238
|
| Variable | What | Needed by |
|
|
222
239
|
| --- | --- | --- |
|
|
@@ -226,7 +243,7 @@ Armada needs a few keys. Set them up once per machine with `armada auth login`,
|
|
|
226
243
|
| `GITHUB_TOKEN` or `GH_TOKEN` | GitHub token; otherwise `gh auth token` is used | pull requests and CI |
|
|
227
244
|
|
|
228
245
|
- `armada auth login` asks only for the keys that are missing, with hidden input for tokens, and stores them in `~/.config/armada/credentials` (or `$XDG_CONFIG_HOME/armada/credentials`), mode 0600 in a 0700 directory. Without a terminal it asks nothing and lists the variables to set instead.
|
|
229
|
-
- `armada auth status [--json]` shows which keys are set and where each comes from. It never prints a value.
|
|
246
|
+
- `armada auth status [--json]` shows which keys are set and where each comes from (for example `Armada: your own key`). It never prints a value.
|
|
230
247
|
- `armada auth logout` removes Armada's keys from the file.
|
|
231
248
|
|
|
232
249
|
The credentials file is a plain dotenv file (`KEY=value` lines, `#` comments) that a shell can also `source`. You may edit it by hand; Armada keeps your other lines and comments when it updates it. GitHub tokens are not stored there: use the environment or `gh auth login`.
|
package/dist/armada.js
CHANGED
|
@@ -310,10 +310,12 @@ var displayCode = (code) => code.length === 8 ? `${code.slice(0, 4)}-${code.slic
|
|
|
310
310
|
class ArmadaApiError extends Error {
|
|
311
311
|
next;
|
|
312
312
|
signedOut;
|
|
313
|
-
|
|
313
|
+
status;
|
|
314
|
+
constructor(message, next = null, signedOut = false, status = null) {
|
|
314
315
|
super(message);
|
|
315
316
|
this.next = next;
|
|
316
317
|
this.signedOut = signedOut;
|
|
318
|
+
this.status = status;
|
|
317
319
|
}
|
|
318
320
|
}
|
|
319
321
|
var LOGIN_NEXT = "armada login";
|
|
@@ -364,7 +366,7 @@ function armadaApi(opts) {
|
|
|
364
366
|
const refusal = (status, body, what) => {
|
|
365
367
|
const error = typeof body.error === "string" ? body.error : `HTTP ${status}`;
|
|
366
368
|
const next = typeof body.next === "string" ? body.next : status === 401 ? LOGIN_NEXT : null;
|
|
367
|
-
return new ArmadaApiError(what ? `${what}: ${error}` : error, next, status === 401);
|
|
369
|
+
return new ArmadaApiError(what ? `${what}: ${error}` : error, next, status === 401, status);
|
|
368
370
|
};
|
|
369
371
|
return {
|
|
370
372
|
async startDeviceLogin() {
|
|
@@ -407,6 +409,20 @@ function armadaApi(opts) {
|
|
|
407
409
|
throw refusal(status, body, status === 401 ? null : "Armada could not say who is signed in");
|
|
408
410
|
return body;
|
|
409
411
|
},
|
|
412
|
+
async credentials(signIn, held) {
|
|
413
|
+
const { status, body } = await call("POST", "credentials", { signIn, body: { turso: held } });
|
|
414
|
+
if (status !== 200)
|
|
415
|
+
throw refusal(status, body, status === 401 ? null : "Armada gave no keys");
|
|
416
|
+
const str = (v) => typeof v === "string" && v.length > 0;
|
|
417
|
+
const org = body.organization;
|
|
418
|
+
const linear = body.linear;
|
|
419
|
+
const turso = body.turso;
|
|
420
|
+
const shaped = body.schemaVersion === 1 && str(org?.id) && (linear === null || str(linear?.apiKey)) && (turso === null || turso?.kind === "kept" && str(turso.revision) && str(turso.expiresAt) || (turso?.kind === "minted" || turso?.kind === "stored") && str(turso.url) && str(turso.token));
|
|
421
|
+
if (!shaped)
|
|
422
|
+
throw new ArmadaApiError(`Armada (${host}) answered the keys in a shape this CLI does not know`);
|
|
423
|
+
const warnings = Array.isArray(body.warnings) ? body.warnings.filter((w) => typeof w === "string") : [];
|
|
424
|
+
return { ...body, warnings };
|
|
425
|
+
},
|
|
410
426
|
async signOut(signIn) {
|
|
411
427
|
const { status, body } = await call("DELETE", "session", { signIn });
|
|
412
428
|
if (status !== 200)
|
|
@@ -2476,6 +2492,15 @@ async function addInboxItem(db, item) {
|
|
|
2476
2492
|
});
|
|
2477
2493
|
return Number(rs.lastInsertRowid);
|
|
2478
2494
|
}
|
|
2495
|
+
async function putPlan(db, item) {
|
|
2496
|
+
await db.execute({
|
|
2497
|
+
sql: `INSERT INTO inbox_items (project, ticket, kind, recipient, author, body, created_at)
|
|
2498
|
+
SELECT ?, ?, 'plan', 'coordinator', ?, ?, ?
|
|
2499
|
+
WHERE NOT EXISTS (SELECT 1 FROM inbox_items
|
|
2500
|
+
WHERE project = ? AND ticket = ? AND kind = 'plan' AND resolved_at IS NULL)`,
|
|
2501
|
+
args: [item.project, item.ticket, item.author, item.body, item.at.toISOString(), item.project, item.ticket]
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2479
2504
|
async function putHandBack(db, item) {
|
|
2480
2505
|
const updated = await db.execute({
|
|
2481
2506
|
sql: `UPDATE inbox_items SET body = ?, author = ?, created_at = ?
|
|
@@ -2536,7 +2561,7 @@ async function resolveInboxItem(db, q) {
|
|
|
2536
2561
|
async function lastAnsweredAt(db, project) {
|
|
2537
2562
|
const rs = await db.execute({
|
|
2538
2563
|
sql: `SELECT ticket, max(resolved_at) AS at FROM inbox_items
|
|
2539
|
-
WHERE project = ? AND kind
|
|
2564
|
+
WHERE project = ? AND kind IN ('question', 'plan') AND ticket IS NOT NULL AND resolved_at IS NOT NULL
|
|
2540
2565
|
GROUP BY ticket`,
|
|
2541
2566
|
args: [project]
|
|
2542
2567
|
});
|
|
@@ -2559,6 +2584,24 @@ async function resolveAnswerRequests(db, q) {
|
|
|
2559
2584
|
});
|
|
2560
2585
|
return rs.rowsAffected;
|
|
2561
2586
|
}
|
|
2587
|
+
async function resolvePlans(db, input) {
|
|
2588
|
+
const args = [input.at.toISOString(), input.resolution, input.project, input.ticket];
|
|
2589
|
+
const [, resolved] = await db.batch([
|
|
2590
|
+
{
|
|
2591
|
+
sql: `UPDATE inbox_items SET resolved_at = ?, resolution = ?
|
|
2592
|
+
WHERE project = ? AND kind = 'answer-request' AND resolved_at IS NULL
|
|
2593
|
+
AND id IN (SELECT q.item FROM inbox_requests q JOIN inbox_items i ON i.id = q.question
|
|
2594
|
+
WHERE i.project = ? AND i.ticket = ? AND i.kind = 'plan' AND i.resolved_at IS NULL)`,
|
|
2595
|
+
args: [input.at.toISOString(), input.resolution, input.project, input.project, input.ticket]
|
|
2596
|
+
},
|
|
2597
|
+
{
|
|
2598
|
+
sql: `UPDATE inbox_items SET resolved_at = ?, resolution = ?
|
|
2599
|
+
WHERE project = ? AND ticket = ? AND kind = 'plan' AND resolved_at IS NULL`,
|
|
2600
|
+
args
|
|
2601
|
+
}
|
|
2602
|
+
], "write");
|
|
2603
|
+
return resolved?.rowsAffected ?? 0;
|
|
2604
|
+
}
|
|
2562
2605
|
async function acquireLease(db, l) {
|
|
2563
2606
|
const at = l.at.toISOString();
|
|
2564
2607
|
const expires = new Date(l.at.getTime() + l.ttlMs).toISOString();
|
|
@@ -2917,6 +2960,23 @@ ${body}` : statusLine);
|
|
|
2917
2960
|
headSha: sha,
|
|
2918
2961
|
at
|
|
2919
2962
|
});
|
|
2963
|
+
if (input.phase === "awaiting-approval" && ticket.agentPhase !== input.phase) {
|
|
2964
|
+
const handle = await getRuntimeHandle(db, config.project.slug, ticket.id);
|
|
2965
|
+
await putPlan(db, {
|
|
2966
|
+
project: config.project.slug,
|
|
2967
|
+
ticket: ticket.id,
|
|
2968
|
+
author: handle && !handle.releasedAt ? handle.handle : null,
|
|
2969
|
+
body: message,
|
|
2970
|
+
at
|
|
2971
|
+
});
|
|
2972
|
+
} else if (input.phase !== "awaiting-approval") {
|
|
2973
|
+
await resolvePlans(db, {
|
|
2974
|
+
project: config.project.slug,
|
|
2975
|
+
ticket: ticket.id,
|
|
2976
|
+
resolution: `worker reported ${input.phase}`,
|
|
2977
|
+
at
|
|
2978
|
+
});
|
|
2979
|
+
}
|
|
2920
2980
|
if (input.phase === "ready-to-merge")
|
|
2921
2981
|
await putHandBack(db, {
|
|
2922
2982
|
project: config.project.slug,
|
|
@@ -2948,6 +3008,12 @@ async function releaseTicket(ctx, input) {
|
|
|
2948
3008
|
await live(ctx, warnings, "record the release", async (db) => {
|
|
2949
3009
|
await ensureProject(db, projectOf(config), at);
|
|
2950
3010
|
await releaseRuntimeHandle(db, config.project.slug, ticket.id, at);
|
|
3011
|
+
await resolvePlans(db, {
|
|
3012
|
+
project: config.project.slug,
|
|
3013
|
+
ticket: ticket.id,
|
|
3014
|
+
resolution: `ticket released: ${input.reason.trim()}`,
|
|
3015
|
+
at
|
|
3016
|
+
});
|
|
2951
3017
|
await resolveInboxItems(db, {
|
|
2952
3018
|
project: config.project.slug,
|
|
2953
3019
|
ticket: ticket.id,
|
|
@@ -3243,6 +3309,23 @@ var SESSION_TOKEN_VARIABLE = "ARMADA_SESSION_TOKEN";
|
|
|
3243
3309
|
var API_KEY_VARIABLE = "ARMADA_API_KEY";
|
|
3244
3310
|
var API_URL_VARIABLE = "ARMADA_API_URL";
|
|
3245
3311
|
var SIGNED_IN_TO_VARIABLE = "ARMADA_SIGNED_IN_TO";
|
|
3312
|
+
var TURSO_LEASE_VARIABLE = "ARMADA_TURSO_LEASE";
|
|
3313
|
+
var formatLease = (lease) => Buffer.from(JSON.stringify(lease), "utf8").toString("base64url");
|
|
3314
|
+
function parseLease(value) {
|
|
3315
|
+
if (!value?.trim())
|
|
3316
|
+
return null;
|
|
3317
|
+
try {
|
|
3318
|
+
const l = JSON.parse(Buffer.from(value.trim(), "base64url").toString("utf8"));
|
|
3319
|
+
const keys = ["api", "organization", "url", "token", "expiresAt", "revision"];
|
|
3320
|
+
if (!keys.every((k) => typeof l[k] === "string" && l[k]))
|
|
3321
|
+
return null;
|
|
3322
|
+
if (Number.isNaN(Date.parse(String(l.expiresAt))))
|
|
3323
|
+
return null;
|
|
3324
|
+
return Object.fromEntries(keys.map((k) => [k, String(l[k])]));
|
|
3325
|
+
} catch {
|
|
3326
|
+
return null;
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3246
3329
|
function armadaAddress(url) {
|
|
3247
3330
|
try {
|
|
3248
3331
|
const u = new URL(url.trim());
|
|
@@ -3280,7 +3363,7 @@ var fromEnv = (env, variable) => {
|
|
|
3280
3363
|
const value = clean(env[variable]);
|
|
3281
3364
|
return value ? { value, source: { kind: "env", variable } } : null;
|
|
3282
3365
|
};
|
|
3283
|
-
function resolveCredentials({ env, store = {}, personal, ghToken }) {
|
|
3366
|
+
function resolveCredentials({ env, store = {}, personal, ghToken, armada }) {
|
|
3284
3367
|
const fromStore = (variable) => {
|
|
3285
3368
|
const value = clean(store[variable]);
|
|
3286
3369
|
return value ? { value, source: { kind: "store" } } : null;
|
|
@@ -3301,10 +3384,12 @@ function resolveCredentials({ env, store = {}, personal, ghToken }) {
|
|
|
3301
3384
|
const storedKey = fromStore(API_KEY_VARIABLE);
|
|
3302
3385
|
const armadaSignInElsewhere = !here && (session || storedKey) ? signedInTo : null;
|
|
3303
3386
|
const armadaSignIn = envKey ? { kind: "api-key", key: envKey.value, source: envKey.source } : session && here ? { kind: "session", token: session.value, source: session.source } : storedKey && here ? { kind: "api-key", key: storedKey.value, source: storedKey.source } : null;
|
|
3387
|
+
const fromArmada = (value, detail) => value && detail ? { value, source: { kind: "armada", detail } } : null;
|
|
3388
|
+
const tursoPair = armada?.turso && !fromEnv(env, "ARMADA_TURSO_URL") && !fromEnv(env, "ARMADA_TURSO_TOKEN") ? armada.turso : null;
|
|
3304
3389
|
const found = {
|
|
3305
|
-
linearApiKey:
|
|
3306
|
-
tursoUrl: stored("ARMADA_TURSO_URL") ?? (tursoUrlConfig ? { value: tursoUrlConfig, source: { kind: "config", key: "turso.url" } } : null),
|
|
3307
|
-
tursoToken: stored("ARMADA_TURSO_TOKEN"),
|
|
3390
|
+
linearApiKey: fromEnv(env, "LINEAR_API_KEY") ?? fromArmada(armada?.linearApiKey?.value, armada?.linearApiKey?.detail) ?? fromStore("LINEAR_API_KEY"),
|
|
3391
|
+
tursoUrl: fromArmada(tursoPair?.url, tursoPair?.detail) ?? stored("ARMADA_TURSO_URL") ?? (tursoUrlConfig ? { value: tursoUrlConfig, source: { kind: "config", key: "turso.url" } } : null),
|
|
3392
|
+
tursoToken: fromArmada(tursoPair?.token, tursoPair?.detail) ?? stored("ARMADA_TURSO_TOKEN"),
|
|
3308
3393
|
githubToken: fromEnv(env, "GITHUB_TOKEN") ?? fromEnv(env, "GH_TOKEN") ?? fromGh()
|
|
3309
3394
|
};
|
|
3310
3395
|
return {
|
|
@@ -3325,7 +3410,7 @@ function resolveCredentials({ env, store = {}, personal, ghToken }) {
|
|
|
3325
3410
|
}
|
|
3326
3411
|
var missingKeys = (credentials) => STORED_KEYS.filter((k) => credentials[k.name] === null);
|
|
3327
3412
|
function missingKeyMessage(key) {
|
|
3328
|
-
return `${key.variable} is not set. Set it in the environment,
|
|
3413
|
+
return `${key.variable} is not set. Set it in the environment, run \`armada auth login\` to store it on this machine (${key.hint}), or sign in with \`armada login\` to an Armada that keeps your organization's keys.`;
|
|
3329
3414
|
}
|
|
3330
3415
|
// ../core/src/dotenv.ts
|
|
3331
3416
|
var ASSIGNMENT = /^\s*(export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/;
|
|
@@ -3807,7 +3892,7 @@ function statusComment(phase, word, text, ref) {
|
|
|
3807
3892
|
|
|
3808
3893
|
${detail}` : line;
|
|
3809
3894
|
}
|
|
3810
|
-
var ANSWERABLE = ["question", "request", "answer-request", "launch-request"];
|
|
3895
|
+
var ANSWERABLE = ["question", "plan", "request", "answer-request", "launch-request"];
|
|
3811
3896
|
async function answerItem(ctx, input) {
|
|
3812
3897
|
const { config, linear } = ctx;
|
|
3813
3898
|
const project = config.project.slug;
|
|
@@ -3815,8 +3900,6 @@ async function answerItem(ctx, input) {
|
|
|
3815
3900
|
if (!text)
|
|
3816
3901
|
throw new Refusal(`the ${input.note ? "note" : "answer"} is empty`, input.note ? `armada answer --note ${input.target.trim()} "<message>"` : `armada answer ${input.target.trim()} "<answer>"`);
|
|
3817
3902
|
const idMatch = input.target.trim().match(ITEM_ID);
|
|
3818
|
-
if (input.note && idMatch)
|
|
3819
|
-
throw new Refusal("a note goes to a ticket, not to an inbox item", 'armada answer --note <ticket> "<message>"');
|
|
3820
3903
|
const warnings = [];
|
|
3821
3904
|
const lines = [];
|
|
3822
3905
|
let item = null;
|
|
@@ -3825,6 +3908,8 @@ async function answerItem(ctx, input) {
|
|
|
3825
3908
|
if (idMatch) {
|
|
3826
3909
|
itemId = Number(idMatch[1]);
|
|
3827
3910
|
item = await live(ctx, warnings, `read inbox item #${itemId}`, (db) => getInboxItem(db, project, itemId ?? 0));
|
|
3911
|
+
if (input.note && item?.kind !== "plan")
|
|
3912
|
+
throw new Refusal("a note goes to a ticket or a plan, not to another inbox item", 'armada answer --note <ticket> "<message>"');
|
|
3828
3913
|
if (!item)
|
|
3829
3914
|
throw new Refusal(warnings.length ? `inbox item #${itemId} cannot be read (${warnings.join("; ")})` : `inbox item #${itemId} does not exist in project ${project}`, warnings.length ? 'armada answer <ticket> "<answer>", to answer by ticket instead' : "armada inbox");
|
|
3830
3915
|
if (item.resolvedAt)
|
|
@@ -3838,13 +3923,15 @@ async function answerItem(ctx, input) {
|
|
|
3838
3923
|
ticketId = input.target.trim().toUpperCase();
|
|
3839
3924
|
if (!input.note) {
|
|
3840
3925
|
const open = await live(ctx, warnings, `read the open questions of ${ticketId}`, (db) => openInboxItems(db, { project, recipient: "coordinator", ticket: ticketId ?? "" }));
|
|
3841
|
-
if (open && !open.some((i) => i.kind === "question"))
|
|
3842
|
-
throw new Refusal(`${ticketId} has no open question in the inbox`, `armada answer --note ${ticketId} "<message>", for an unsolicited message`);
|
|
3926
|
+
if (open && !open.some((i) => i.kind === "question" || i.kind === "plan"))
|
|
3927
|
+
throw new Refusal(`${ticketId} has no open question or plan in the inbox`, `armada answer --note ${ticketId} "<message>", for an unsolicited message`);
|
|
3843
3928
|
}
|
|
3844
3929
|
}
|
|
3845
3930
|
if (item?.kind === "launch-request")
|
|
3846
3931
|
return declineLaunch(ctx, item, text, warnings);
|
|
3847
3932
|
const question = item?.kind === "answer-request" ? item.request?.question ?? null : null;
|
|
3933
|
+
const answered = question === null ? item : await live(ctx, warnings, `read the item answered by #${item?.id}`, (db) => getInboxItem(db, project, question));
|
|
3934
|
+
const answerKind = answered?.kind === "plan" ? "plan" : "question";
|
|
3848
3935
|
let url = "";
|
|
3849
3936
|
if (ticketId) {
|
|
3850
3937
|
const ticket = await linear.readTicket(ticketId);
|
|
@@ -3857,7 +3944,7 @@ async function answerItem(ctx, input) {
|
|
|
3857
3944
|
throw new Refusal(`${ticket.id} has no agent phase: no worker holds it, so there is no one to tell`, "armada status, to see which tickets are in flight");
|
|
3858
3945
|
warnings.push(`${ticket.id} has no agent phase (no worker holds it); the answer was not posted on the ticket`);
|
|
3859
3946
|
} else {
|
|
3860
|
-
const ref = item?.kind === "answer-request" ? `Answers ${question === null ? "the open question" :
|
|
3947
|
+
const ref = item?.kind === "answer-request" ? `Answers ${question === null ? "the open question or plan" : `${answerKind} #${question}`}, as ${item.author ?? "the owner"} asked from the dashboard (request #${item.id}).` : itemId === null ? null : `Answers ${answerKind} #${itemId}.`;
|
|
3861
3948
|
await linear.comment(ticket.uuid, statusComment(ticket.agentPhase, input.note ? "note" : "answer", text, ref));
|
|
3862
3949
|
lines.push(`${input.note ? "Note" : "Answer"} posted on ${ticket.id} (${ticket.agentPhase}).`);
|
|
3863
3950
|
}
|
|
@@ -3866,6 +3953,8 @@ async function answerItem(ctx, input) {
|
|
|
3866
3953
|
const recorded = await live(ctx, warnings, `record the ${input.note ? "note" : "answer"}`, async (db) => {
|
|
3867
3954
|
await ensureProject(db, projectOf(config), at);
|
|
3868
3955
|
if (input.note) {
|
|
3956
|
+
if (ticketId)
|
|
3957
|
+
await resolvePlans(db, { project, ticket: ticketId, resolution: text, at });
|
|
3869
3958
|
const id = await addInboxItem(db, {
|
|
3870
3959
|
project,
|
|
3871
3960
|
ticket: ticketId,
|
|
@@ -3881,17 +3970,18 @@ async function answerItem(ctx, input) {
|
|
|
3881
3970
|
if (item?.kind === "answer-request") {
|
|
3882
3971
|
await resolveInboxItem(db, { project, id: item.id, resolution: text, at });
|
|
3883
3972
|
const closed = question !== null && await resolveInboxItem(db, { project, id: question, resolution: text, at });
|
|
3884
|
-
return `Dashboard request #${item.id} delivered${closed ? `;
|
|
3973
|
+
return `Dashboard request #${item.id} delivered${closed ? `; ${answerKind} #${question} resolved` : ""}.`;
|
|
3885
3974
|
}
|
|
3886
3975
|
if (itemId !== null) {
|
|
3887
3976
|
const done = await resolveInboxItem(db, { project, id: itemId, resolution: text, at });
|
|
3888
|
-
if (item?.kind === "question")
|
|
3977
|
+
if (item?.kind === "question" || item?.kind === "plan")
|
|
3889
3978
|
await resolveAnswerRequests(db, { project, question: itemId, resolution: text, at });
|
|
3890
3979
|
return done ? `Inbox item #${itemId} resolved.` : `Inbox item #${itemId} was already resolved.`;
|
|
3891
3980
|
}
|
|
3892
3981
|
const n = await resolveInboxItems(db, { project, ticket: ticketId ?? "", kind: "question", resolution: text, at });
|
|
3982
|
+
const plans = await resolvePlans(db, { project, ticket: ticketId ?? "", resolution: text, at });
|
|
3893
3983
|
await resolveInboxItems(db, { project, ticket: ticketId ?? "", kind: "answer-request", resolution: text, at });
|
|
3894
|
-
return `${n} open question${n === 1 ? "" : "s"} of ${ticketId} resolved.`;
|
|
3984
|
+
return `${n} open question${n === 1 ? "" : "s"}${plans ? ` and ${plans} plan${plans === 1 ? "" : "s"}` : ""} of ${ticketId} resolved.`;
|
|
3895
3985
|
});
|
|
3896
3986
|
if (recorded)
|
|
3897
3987
|
lines.push(recorded);
|
|
@@ -4803,10 +4893,10 @@ A coordinator may start cold, on a laptop or in a fresh cloud session, with noth
|
|
|
4803
4893
|
|
|
4804
4894
|
## Loop
|
|
4805
4895
|
|
|
4806
|
-
1. **Read the fleet** with \`armada status\` and \`armada inbox\`, never from memory. Done when you can name every ticket in flight and its phase, every ready ticket, every pull request waiting, every silent worker and every pending question or request.
|
|
4807
|
-
2. **Answer what waits for you first.** For each question in \`armada inbox\`: decide it, or escalate it to the owner when it is a product decision and wait for theirs. Deliver the
|
|
4896
|
+
1. **Read the fleet** with \`armada status\` and \`armada inbox\`, never from memory. Done when you can name every ticket in flight and its phase, every ready ticket, every pull request waiting, every silent worker and every pending question, plan or request.
|
|
4897
|
+
2. **Answer what waits for you first.** For each question in \`armada inbox\`: decide it, or escalate it to the owner when it is a product decision and wait for theirs. For each \`plan\` item: read the full plan, approve it or give concrete amendments. Deliver the decision in the worker's session with the runtime guide's *message* section, then record it with \`armada answer <item> "approved"\` or \`armada answer <item> "<amendments and reason>"\`. The worker resumes with \`implementing\` on approval, or returns to \`planning\` and submits a revised plan. \`armada answer\` only records; it never reaches the worker. Decide reversible choices yourself and prefer the option that keeps behaviour observable. When two workers need the same shared resource (a migration slot, a generated file, a version number), set the rule once and tell both. A message the worker did not ask for (main moved, rebase needed) takes the same path: deliver it with the runtime guide, then \`armada answer --note <ticket> "<message>"\`. Done when the inbox shows no open question or plan.
|
|
4808
4898
|
3. **Carry out the owner's dashboard requests.** They are the owner's word, signed with their name; they never reached a worker.
|
|
4809
|
-
- \`answer-request\` (it names the question it answers, \`answers #<id>\`): deliver its text in the worker's session with the runtime guide's *message* section, as the owner's answer, then \`armada answer <request id> "<the text you delivered>"\`. That resolves the request and its question, and the ticket names who answered. If the
|
|
4899
|
+
- \`answer-request\` (it names the question or plan it answers, \`answers #<id>\`): deliver its text in the worker's session with the runtime guide's *message* section, as the owner's answer or plan approval, then \`armada answer <request id> "<the text you delivered>"\`. That resolves the request and its question or plan, and the ticket names who answered. If the item is gone (the worker was released or changed phase), \`armada answer <request id> "<why>"\` closes it.
|
|
4810
4900
|
- \`launch-request\` (it names the profile the owner chose): launch the ticket as in step 5, with that profile. When it differs from the routed one, the request's body gives the \`--profile\` and \`--reason\` to pass to \`armada brief\` and to the worker's claim. The worker's \`armada claim\` resolves the request and posts who asked. If the ticket must not start (it collides with work in flight, or its plan changed), decline it: \`armada answer <request id> "<why>"\`, and tell the owner in your report.
|
|
4811
4901
|
Done when the inbox shows no open request.
|
|
4812
4902
|
4. **Check silent workers** with the runtime guide's *status* section. A worker that is still working gets a nudge to report; a worker that died is relaunched or its ticket released.
|
|
@@ -4854,7 +4944,7 @@ You are a worker. You own exactly one ticket, named in your launch brief. You tu
|
|
|
4854
4944
|
|
|
4855
4945
|
1. **Claim** with the exact command your brief starts with, for example \`armada claim <ticket> --runtime conductor --handle "$CONDUCTOR_WORKSPACE_ID/$CONDUCTOR_SESSION_ID"\`. Install the Armada version the brief names first; if it gives a fallback command, use it wherever this skill says \`armada\`. It assigns the ticket, moves it to In Progress, sets \`Agent phase = planning\` and your \`Agent runtime\`, and posts the \`Agent claim\` comment. If it refuses because another claim exists, stop: the older claim wins.
|
|
4856
4946
|
2. **Branch.** Use the branch named after the ticket (the tracker suggests one, for example \`feature/abc-12-short-title\`), created from the latest default branch.
|
|
4857
|
-
3. **Plan.** Write the plan: what changes, how it is tested, and the checks a person could observe when it is done. If your brief says plans are pre-approved, post
|
|
4947
|
+
3. **Plan.** Write the plan: what changes, how it is tested, and the checks a person could observe when it is done. If the ticket's plan policy or your brief says plans are pre-approved, post the full plan with \`armada report implementing --message "<plan>"\` and go on; do not enter \`awaiting-approval\`. Otherwise post the full plan with \`armada report awaiting-approval --message "<plan>"\`: it creates a \`plan\` item in the coordinator's inbox. Push your branch and wait for the coordinator's decision in your session. On approval, report \`implementing\`; on amendments, report \`planning\`, revise the plan and submit it for approval again.
|
|
4858
4948
|
4. **Implement** test-first. A material change to the approved plan needs a new approval.
|
|
4859
4949
|
5. **Ship.** \`armada report shipping --pr <number>\`. Use the \`ship-pr-dev\` skill when the repository has it; otherwise run the repository's local checks, open the pull request with a Commitizen title (\`feat(scope): …\`), link it on the ticket, and fix CI until every required check is green.
|
|
4860
4950
|
6. **Rebase** on the latest default branch right before hand-back, and get CI green on that final head.
|
|
@@ -5235,7 +5325,7 @@ async function loadStatus(config, opts) {
|
|
|
5235
5325
|
});
|
|
5236
5326
|
}
|
|
5237
5327
|
// package.json
|
|
5238
|
-
var version = "0.1.
|
|
5328
|
+
var version = "0.1.17";
|
|
5239
5329
|
|
|
5240
5330
|
// src/io.ts
|
|
5241
5331
|
class UsageError extends Error {
|
|
@@ -5258,15 +5348,91 @@ async function loadMachine(io) {
|
|
|
5258
5348
|
]);
|
|
5259
5349
|
return { paths, store, personal };
|
|
5260
5350
|
}
|
|
5261
|
-
|
|
5351
|
+
var hhmm = (iso) => `${iso.slice(0, 16).replace("T", " ")} UTC`;
|
|
5352
|
+
var wantsArmada = (env) => !env.LINEAR_API_KEY?.trim() || !env.ARMADA_TURSO_URL?.trim() && !env.ARMADA_TURSO_TOKEN?.trim();
|
|
5353
|
+
var fromLease = (lease) => ({
|
|
5354
|
+
url: lease.url,
|
|
5355
|
+
token: lease.token,
|
|
5356
|
+
detail: `a token made for this terminal, expires ${hhmm(lease.expiresAt)}`
|
|
5357
|
+
});
|
|
5358
|
+
async function fromArmada(io, machine, credentials) {
|
|
5359
|
+
const signIn = credentials.armadaSignIn;
|
|
5360
|
+
if (!signIn)
|
|
5361
|
+
return null;
|
|
5362
|
+
const now = (io.now ?? (() => new Date))();
|
|
5363
|
+
const address = armadaAddress(credentials.armadaApi.url);
|
|
5364
|
+
const stored = parseLease(machine.store?.values[TURSO_LEASE_VARIABLE]);
|
|
5365
|
+
const lease = stored && stored.api === address && Date.parse(stored.expiresAt) > now.getTime() ? stored : null;
|
|
5366
|
+
const keep = async (next) => {
|
|
5367
|
+
if (!machine.paths || next === null && !machine.store?.assigned.includes(TURSO_LEASE_VARIABLE))
|
|
5368
|
+
return;
|
|
5369
|
+
await updateCredentialStore(machine.paths, { [TURSO_LEASE_VARIABLE]: next ? formatLease(next) : null }).catch((err) => io.stderr(`! the Turso token from Armada could not be kept in ${machine.paths?.credentials} (${err.code ?? "error"}); it is asked again next time
|
|
5370
|
+
`));
|
|
5371
|
+
};
|
|
5372
|
+
let answer;
|
|
5373
|
+
try {
|
|
5374
|
+
answer = await armadaApi({ url: credentials.armadaApi.url, ...io.fetch ? { fetch: io.fetch } : {} }).credentials(signIn, lease ? { revision: lease.revision, expiresAt: lease.expiresAt } : null);
|
|
5375
|
+
} catch (err) {
|
|
5376
|
+
if (!(err instanceof ArmadaApiError))
|
|
5377
|
+
throw err;
|
|
5378
|
+
if (err.signedOut || err.status === 403) {
|
|
5379
|
+
await keep(null);
|
|
5380
|
+
io.stderr(`! Armada gave no keys (${err.message}); using this machine's${err.next ? `. Next: ${err.next}` : ""}
|
|
5381
|
+
`);
|
|
5382
|
+
return null;
|
|
5383
|
+
}
|
|
5384
|
+
if (err.status === 503 && !lease)
|
|
5385
|
+
return null;
|
|
5386
|
+
io.stderr(`! Armada gave no keys (${err.message}); using this machine's${lease ? " and the Turso token it made earlier" : ""}${err.next ? `. Next: ${err.next}` : ""}
|
|
5387
|
+
`);
|
|
5388
|
+
return lease ? { linearApiKey: null, turso: fromLease(lease) } : null;
|
|
5389
|
+
}
|
|
5390
|
+
for (const w of answer.warnings)
|
|
5391
|
+
io.stderr(`! Armada: ${w}
|
|
5392
|
+
`);
|
|
5393
|
+
const linearApiKey = answer.linear ? {
|
|
5394
|
+
value: answer.linear.apiKey,
|
|
5395
|
+
detail: answer.linear.scope === "own" ? "your own key" : `the key of ${answer.organization.name}`
|
|
5396
|
+
} : null;
|
|
5397
|
+
const t = answer.turso;
|
|
5398
|
+
if (t?.kind === "minted") {
|
|
5399
|
+
const next = {
|
|
5400
|
+
api: address,
|
|
5401
|
+
organization: answer.organization.id,
|
|
5402
|
+
url: t.url,
|
|
5403
|
+
token: t.token,
|
|
5404
|
+
expiresAt: t.expiresAt,
|
|
5405
|
+
revision: t.revision
|
|
5406
|
+
};
|
|
5407
|
+
await keep(next);
|
|
5408
|
+
return { linearApiKey, turso: fromLease(next) };
|
|
5409
|
+
}
|
|
5410
|
+
if (t?.kind === "kept" && lease)
|
|
5411
|
+
return { linearApiKey, turso: fromLease(lease) };
|
|
5412
|
+
await keep(null);
|
|
5413
|
+
return {
|
|
5414
|
+
linearApiKey,
|
|
5415
|
+
turso: t?.kind === "stored" ? { url: t.url, token: t.token, detail: `the stored Turso access of ${answer.organization.name}` } : null
|
|
5416
|
+
};
|
|
5417
|
+
}
|
|
5418
|
+
async function loadCredentials(io, { armada = true } = {}) {
|
|
5262
5419
|
const machine = await loadMachine(io);
|
|
5263
|
-
|
|
5420
|
+
let gh;
|
|
5421
|
+
const sources = {
|
|
5264
5422
|
env: io.env,
|
|
5265
|
-
ghToken:
|
|
5423
|
+
ghToken: () => {
|
|
5424
|
+
if (gh === undefined)
|
|
5425
|
+
gh = io.ghToken();
|
|
5426
|
+
return gh;
|
|
5427
|
+
},
|
|
5266
5428
|
...machine.store ? { store: machine.store.values } : {},
|
|
5267
5429
|
...machine.personal ? { personal: machine.personal.config } : {}
|
|
5268
|
-
}
|
|
5269
|
-
|
|
5430
|
+
};
|
|
5431
|
+
const local = resolveCredentials(sources);
|
|
5432
|
+
if (!armada || !local.armadaSignIn || !wantsArmada(io.env))
|
|
5433
|
+
return { machine, credentials: local };
|
|
5434
|
+
const keys = await fromArmada(io, machine, local);
|
|
5435
|
+
return { machine, credentials: keys ? resolveCredentials({ ...sources, armada: keys }) : local };
|
|
5270
5436
|
}
|
|
5271
5437
|
var describeSource = (s) => {
|
|
5272
5438
|
switch (s.kind) {
|
|
@@ -5274,6 +5440,8 @@ var describeSource = (s) => {
|
|
|
5274
5440
|
return `environment (${s.variable})`;
|
|
5275
5441
|
case "store":
|
|
5276
5442
|
return "credentials file";
|
|
5443
|
+
case "armada":
|
|
5444
|
+
return `Armada: ${s.detail}`;
|
|
5277
5445
|
case "config":
|
|
5278
5446
|
return `personal config (${s.key})`;
|
|
5279
5447
|
case "gh":
|
|
@@ -5405,13 +5573,14 @@ async function authStatus(io, json) {
|
|
|
5405
5573
|
async function authLogout(io) {
|
|
5406
5574
|
const paths = requirePaths(machinePaths(io.env));
|
|
5407
5575
|
const store = await readCredentialStore(paths.credentials);
|
|
5408
|
-
const
|
|
5576
|
+
const variables = [...STORED_KEYS.map((k) => k.variable), TURSO_LEASE_VARIABLE];
|
|
5577
|
+
const stored = variables.filter((v) => store.assigned.includes(v));
|
|
5409
5578
|
if (!stored.length) {
|
|
5410
5579
|
io.stdout(`No Armada key is stored in ${paths.credentials}.
|
|
5411
5580
|
`);
|
|
5412
5581
|
} else {
|
|
5413
|
-
await updateCredentialStore(paths, Object.fromEntries(
|
|
5414
|
-
io.stdout(`Removed ${stored.
|
|
5582
|
+
await updateCredentialStore(paths, Object.fromEntries(variables.map((v) => [v, null])));
|
|
5583
|
+
io.stdout(`Removed ${stored.join(", ")} from ${paths.credentials}.
|
|
5415
5584
|
`);
|
|
5416
5585
|
}
|
|
5417
5586
|
const fromEnv = STORED_KEYS.filter((k) => io.env[k.variable]?.trim()).map((k) => k.variable);
|
|
@@ -5918,7 +6087,7 @@ function renderInbox(r) {
|
|
|
5918
6087
|
out.push(`${e.new ? "* " : " "}${head}`, ...e.body.split(`
|
|
5919
6088
|
`).map((l) => l ? ` ${l}` : ""));
|
|
5920
6089
|
}
|
|
5921
|
-
if (r.items.some((e) => e.kind === "question"))
|
|
6090
|
+
if (r.items.some((e) => e.kind === "question" || e.kind === "plan"))
|
|
5922
6091
|
out.push(`Deliver each answer in the worker's session with the runtime guide, then record it: armada answer <id> "<answer>".`);
|
|
5923
6092
|
if (r.items.some((e) => e.kind === "answer-request" || e.kind === "launch-request"))
|
|
5924
6093
|
out.push('Dashboard requests: deliver an answer-request, then armada answer <id> "<answer>"; launch a launch-request (its claim resolves it), or decline it with armada answer <id> "<why>".');
|
|
@@ -6214,7 +6383,8 @@ async function loginWithApiKey(io, credentials) {
|
|
|
6214
6383
|
await updateCredentialStore(p, {
|
|
6215
6384
|
[API_KEY_VARIABLE]: key,
|
|
6216
6385
|
[SESSION_TOKEN_VARIABLE]: null,
|
|
6217
|
-
[SIGNED_IN_TO_VARIABLE]: armadaAddress(url)
|
|
6386
|
+
[SIGNED_IN_TO_VARIABLE]: armadaAddress(url),
|
|
6387
|
+
[TURSO_LEASE_VARIABLE]: null
|
|
6218
6388
|
});
|
|
6219
6389
|
io.stdout(`Signed in to ${hostOf(credentials.armadaApi.url)} as ${describeIdentity(identity)}.
|
|
6220
6390
|
The key is stored in ${p.credentials}.
|
|
@@ -6222,7 +6392,7 @@ The key is stored in ${p.credentials}.
|
|
|
6222
6392
|
return 0;
|
|
6223
6393
|
}
|
|
6224
6394
|
async function login(io, apiKey) {
|
|
6225
|
-
const { machine, credentials } = await loadCredentials(io);
|
|
6395
|
+
const { machine, credentials } = await loadCredentials(io, { armada: false });
|
|
6226
6396
|
const host = hostOf(credentials.armadaApi.url);
|
|
6227
6397
|
if (credentials.armadaSignIn?.source.kind === "env")
|
|
6228
6398
|
io.stderr(`! ${API_KEY_VARIABLE} is set in the environment: it wins over what \`armada login\` stores.
|
|
@@ -6247,7 +6417,8 @@ Then confirm it at ${code.verificationUriComplete}
|
|
|
6247
6417
|
await updateCredentialStore(p, {
|
|
6248
6418
|
[SESSION_TOKEN_VARIABLE]: token,
|
|
6249
6419
|
[API_KEY_VARIABLE]: null,
|
|
6250
|
-
[SIGNED_IN_TO_VARIABLE]: armadaAddress(url)
|
|
6420
|
+
[SIGNED_IN_TO_VARIABLE]: armadaAddress(url),
|
|
6421
|
+
[TURSO_LEASE_VARIABLE]: null
|
|
6251
6422
|
});
|
|
6252
6423
|
if (previous && previous !== token)
|
|
6253
6424
|
await apiOf(io, storedAt(machine)).signOut({ kind: "session", token: previous }).catch(() => {});
|
|
@@ -6259,7 +6430,7 @@ Then confirm it at ${code.verificationUriComplete}
|
|
|
6259
6430
|
return 0;
|
|
6260
6431
|
}
|
|
6261
6432
|
async function whoami(io, json) {
|
|
6262
|
-
const { credentials } = await loadCredentials(io);
|
|
6433
|
+
const { credentials } = await loadCredentials(io, { armada: false });
|
|
6263
6434
|
const signIn = requireSignIn(credentials);
|
|
6264
6435
|
const identity = await apiOf(io, credentials.armadaApi.url).whoami(signIn);
|
|
6265
6436
|
if (json) {
|
|
@@ -6273,10 +6444,10 @@ async function whoami(io, json) {
|
|
|
6273
6444
|
return 0;
|
|
6274
6445
|
}
|
|
6275
6446
|
async function logout(io) {
|
|
6276
|
-
const { machine } = await loadCredentials(io);
|
|
6447
|
+
const { machine } = await loadCredentials(io, { armada: false });
|
|
6277
6448
|
const p = paths(io);
|
|
6278
6449
|
const at = storedAt(machine);
|
|
6279
|
-
const stored = [SESSION_TOKEN_VARIABLE, API_KEY_VARIABLE].filter((k) => machine.store?.assigned.includes(k));
|
|
6450
|
+
const stored = [SESSION_TOKEN_VARIABLE, API_KEY_VARIABLE, TURSO_LEASE_VARIABLE].filter((k) => machine.store?.assigned.includes(k));
|
|
6280
6451
|
const session = machine.store?.values[SESSION_TOKEN_VARIABLE]?.trim();
|
|
6281
6452
|
if (session) {
|
|
6282
6453
|
await apiOf(io, at).signOut({ kind: "session", token: session }).catch((err) => io.stderr(`! the session could not be revoked on Armada (${err instanceof Error ? err.message : String(err)}); it expires on its own
|
|
@@ -6286,7 +6457,8 @@ async function logout(io) {
|
|
|
6286
6457
|
await updateCredentialStore(p, {
|
|
6287
6458
|
[SESSION_TOKEN_VARIABLE]: null,
|
|
6288
6459
|
[API_KEY_VARIABLE]: null,
|
|
6289
|
-
[SIGNED_IN_TO_VARIABLE]: null
|
|
6460
|
+
[SIGNED_IN_TO_VARIABLE]: null,
|
|
6461
|
+
[TURSO_LEASE_VARIABLE]: null
|
|
6290
6462
|
});
|
|
6291
6463
|
io.stdout(`Signed out of ${hostOf(at)}: removed the sign-in from ${p.credentials}.
|
|
6292
6464
|
`);
|
|
@@ -6694,16 +6866,16 @@ var COMMAND_HELP = {
|
|
|
6694
6866
|
for the answer in your session, and report the phase you resume
|
|
6695
6867
|
`,
|
|
6696
6868
|
inbox: ` inbox [--wait [--timeout <seconds>]]
|
|
6697
|
-
Coordinator: open questions, requests, hand-backs and silent workers,
|
|
6869
|
+
Coordinator: open questions, plans, requests, hand-backs and silent workers,
|
|
6698
6870
|
oldest first; records that the coordinator is at work. --wait returns
|
|
6699
6871
|
when a new item arrives or after --timeout (default 300 s). Needs Turso
|
|
6700
6872
|
`,
|
|
6701
6873
|
answer: ` answer <item|ticket> "<answer>"
|
|
6702
6874
|
Coordinator: record an answer already delivered in the worker's
|
|
6703
|
-
session (runtime guide): resolves the question and posts it on
|
|
6704
|
-
ticket. A ticket id answers its open questions. Never calls a runtime
|
|
6705
|
-
answer --note <ticket> "<message>"
|
|
6706
|
-
Coordinator: record
|
|
6875
|
+
session (runtime guide): resolves the question or plan and posts it on
|
|
6876
|
+
the ticket. A ticket id answers its open questions and plans. Never calls a runtime
|
|
6877
|
+
answer --note <ticket|plan item> "<message>"
|
|
6878
|
+
Coordinator: record a delivered note; an open plan is resolved
|
|
6707
6879
|
`,
|
|
6708
6880
|
merge: ` merge <pr> [--ticket <id>] [--dry-run] [--no-lock]
|
|
6709
6881
|
Coordinator: check a handed-back pull request (hand-back SHA = head,
|
|
@@ -6749,7 +6921,7 @@ Options:
|
|
|
6749
6921
|
${TICKET_HELP} -h, --help Show this help; \`armada <command> --help\` shows one command
|
|
6750
6922
|
-v, --version Print the version
|
|
6751
6923
|
|
|
6752
|
-
Keys (the environment
|
|
6924
|
+
Keys (the environment first, then Armada when signed in, then the file):
|
|
6753
6925
|
LINEAR_API_KEY Linear API key (required by status, init, brief, claim, report,
|
|
6754
6926
|
release, ask and answer)
|
|
6755
6927
|
ARMADA_TURSO_URL Turso database URL (required by init, inbox and status --all;
|
|
@@ -6763,7 +6935,8 @@ Keys (the environment always wins over the file):
|
|
|
6763
6935
|
Files:
|
|
6764
6936
|
$XDG_CONFIG_HOME/armada (default ~/.config/armada)
|
|
6765
6937
|
credentials KEY=value lines, mode 0600, written by \`armada auth login\` and
|
|
6766
|
-
\`armada login\` (the sign-in: ARMADA_SESSION_TOKEN or ARMADA_API_KEY
|
|
6938
|
+
\`armada login\` (the sign-in: ARMADA_SESSION_TOKEN or ARMADA_API_KEY; the
|
|
6939
|
+
Turso token Armada made for this terminal: ARMADA_TURSO_LEASE)
|
|
6767
6940
|
config.toml personal defaults: language, [turso] url, [dashboard] url, [api] url
|
|
6768
6941
|
`;
|
|
6769
6942
|
function commandHelp(command) {
|