@the-vibe-company/armada 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +22 -4
  2. package/dist/armada.js +30 -15
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -155,8 +155,9 @@ armada merge 34 # or the pull request URL; --ticket ABC-12 when the
155
155
  - **At work** has one row per ticket in flight. A row shows the project, the runtime and session, the six-step phase pipeline, time in phase, the last report, the pull request with its CI, and the flags (red CI, conflict, double claim).
156
156
  - A filter shows one project. Each project shows whether its coordinator is active, from its last inbox read.
157
157
  - **Answer** a question from its line in Waiting for you (an option of the question fills the answer in). **Ready to launch** lists the frontier with a Launch button and a profile picker, the routed profile preselected. Neither reaches a worker: each becomes a request in that project's coordinator inbox, signed with the signed-in person's name and address (with accounts) or with the name the viewer gives (under the shared password; remembered in a cookie, default `ARMADA_DASHBOARD_AUTHOR`), and shows as pending until the coordinator carries it out. The dashboard holds no runtime credential.
158
- - It stays live without a reload. Linear and GitHub are read at most once a minute per project. The fleet's live data (events, claims, inboxes, coordinator activity) is read from the app's own Postgres database on every 5-second poll, so a recorded report shows within seconds.
159
- - When that database is unreachable, a banner says so and the view falls back to Linear and GitHub.
158
+ - It stays live without a reload, and no page waits for Linear or GitHub. Each project's last reading of Linear and GitHub is kept in the app's Postgres database, and every page and poll reads only that database: the reading, plus the fleet's live data (events, claims, inboxes, coordinator activity), so a recorded report shows within seconds. A reading older than a minute (ten minutes for a project both [webhooks](#webhooks) reached within the last day) is served as is and refreshed in the background, reading only what changed in Linear since and the pull requests; Linear is read whole every 30 minutes at most, and only while someone looks. The top bar says how old the oldest reading on the page is, so a stale view never passes for a live one. A new project shows "reading Linear and GitHub for the first time" for a few seconds.
159
+ - The page polls every 5 s while work is in flight (a worker, a request waiting for the coordinator, a first reading), every 30 s when the fleet is quiet, and not at all while its tab is hidden. The server answers 304 while nothing changed. Answer, Approve and Launch show as sent on the click; a refusal puts the form back with the reason.
160
+ - When that database is unreachable, a banner says so and the view falls back to the last readings the server holds, refreshed from Linear and GitHub.
160
161
  - The interface is in English or French (`ARMADA_DASHBOARD_LANGUAGE`, or the EN/FR switch).
161
162
 
162
163
  Try it locally with synthetic data and no key:
@@ -181,7 +182,7 @@ ARMADA_AUTH_URL=http://localhost:4822 ARMADA_AUTH_OWNER_EMAILS=you@example.com b
181
182
  - 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`.
182
183
  - Functions run in the region `packages/dashboard/vercel.json` names (`fra1`, Frankfurt): keep them next to the database, or change it to your database's region. Every poll makes a few database round trips, so the distance between the two is what the dashboard's speed depends on.
183
184
  - The database: one Postgres database holds everything (accounts, organizations, the vault, the workers, the fleet's live data). [Neon](https://neon.com) works well: create a project in the region of the functions (`aws-eu-central-1` for `fra1`) and set its pooled connection string as `ARMADA_DATABASE_URL` (`DATABASE_URL`, which Neon's Vercel integration sets, is read too). A remote database is reached over verified TLS unless its URL says otherwise: a Postgres without TLS on a private network needs `?sslmode=disable`. The schema is applied on first use; `ARMADA_DATABASE_URL=<direct URL> bun run db migrate` (in `packages/dashboard`) applies it beforehand. Accounts are Better Auth run by the app on that database, not Neon's managed auth, which offers neither the device sign-in of `armada login` nor organization API keys, nor a way to keep sign-up by invitation only.
184
- - Environment variables: `ARMADA_DATABASE_URL`, the accounts variables below (or, until they are set, `ARMADA_DASHBOARD_PASSWORD`), the [GitHub App](#github-app)'s `ARMADA_GITHUB_APP_ID` and `ARMADA_GITHUB_APP_PRIVATE_KEY`, and `LINEAR_API_KEY`. With accounts and the vault (`ARMADA_SECRETS_KEY`, see [Keys kept in Armada](#keys-kept-in-armada)), `LINEAR_API_KEY` moves to the Keys page and is only a fallback here, for the deployment's first organization. `GITHUB_TOKEN` is read only without the GitHub App, or for a repository it cannot read. Optional: `ARMADA_REPOSITORIES` (the `owner/name` list shown while the database 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.
185
+ - Environment variables: `ARMADA_DATABASE_URL`, the accounts variables below (or, until they are set, `ARMADA_DASHBOARD_PASSWORD`), the [GitHub App](#github-app)'s `ARMADA_GITHUB_APP_ID` and `ARMADA_GITHUB_APP_PRIVATE_KEY`, and `LINEAR_API_KEY`. With accounts and the vault (`ARMADA_SECRETS_KEY`, see [Keys kept in Armada](#keys-kept-in-armada)), `LINEAR_API_KEY` moves to the Keys page and is only a fallback here, for the deployment's first organization. `GITHUB_TOKEN` is read only without the GitHub App, or for a repository it cannot read. Optional: `ARMADA_REPOSITORIES` (the `owner/name` list shown while the database is unreachable on a fresh server), `ARMADA_DASHBOARD_LANGUAGE` (`en` or `fr`), `ARMADA_LINEAR_WEBHOOK_SECRET` and `ARMADA_GITHUB_WEBHOOK_SECRET` (the [webhooks](#webhooks)), `ARMADA_DASHBOARD_SNAPSHOT_SECONDS` (how old a reading may get before a view refreshes it: default 60; a project both webhooks reached within the last day waits 10 minutes) 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.
185
186
  - The keys stay on the server; the browser only receives the fleet reading.
186
187
 
187
188
  **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 the app's database (`ARMADA_DATABASE_URL`), with the fleet's data; 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.
@@ -245,7 +246,7 @@ Create the app once, under the GitHub organization that owns the projects (its S
245
246
  | Expire user authorization tokens | on (the default): Armada refreshes them |
246
247
  | Request user authorization (OAuth) during installation | off |
247
248
  | Setup URL | `<ARMADA_AUTH_URL>/organization/github`, with Redirect on update: GitHub sends whoever clicks Install on GitHub in Armada back to the page, which links the installation in the same step |
248
- | Webhook | off (clear Active): Armada reads, it does not listen |
249
+ | Webhook | Active, URL `<ARMADA_AUTH_URL>/api/webhooks/github`, secret the value of `ARMADA_GITHUB_WEBHOOK_SECRET` (see [Webhooks](#webhooks)); subscribe to Pull request, Check suite, Check run and Status |
249
250
  | Repository permissions | all **Read-only**: Actions, Checks, Commit statuses, Contents, Metadata, Pull requests. Nothing else, and no write access |
250
251
  | Account permissions | Email addresses: **Read-only** (sign-in reads the verified address) |
251
252
  | Where can this GitHub App be installed? | Only on this account; Any account if the projects live under several GitHub accounts |
@@ -270,6 +271,23 @@ Then:
270
271
  - Without `ARMADA_GITHUB_APP_ID` and `ARMADA_GITHUB_APP_PRIVATE_KEY`, nothing changes: the dashboard reads GitHub with the Keys page's GitHub token or `GITHUB_TOKEN`. With the app, that token is only the fallback for a repository the app cannot read, and the Fleet view says why the app could not (not installed there, or not linked).
271
272
  - Terminals do not change: `armada` reads GitHub with `GITHUB_TOKEN`, `GH_TOKEN` or `gh auth token`, and the coordinator merges with its own `gh`.
272
273
 
274
+ ## Webhooks
275
+
276
+ Two webhooks bring a change in Linear or on a pull request to the dashboard within seconds; without them, a reading is refreshed when someone looks and it is older than a minute.
277
+
278
+ | Variable | What |
279
+ | --- | --- |
280
+ | `ARMADA_LINEAR_WEBHOOK_SECRET` | The signing secret Linear shows for the webhook below |
281
+ | `ARMADA_GITHUB_WEBHOOK_SECRET` | A random secret (`openssl rand -hex 32`), also pasted in the GitHub App's webhook settings |
282
+
283
+ 1. **Linear:** Settings > API > Webhooks > New webhook, URL `<ARMADA_AUTH_URL>/api/webhooks/linear`, data change events Issues, Comments, Issue attachments and Issue labels, for all public teams (or the program's teams). Copy its signing secret into `ARMADA_LINEAR_WEBHOOK_SECRET`.
284
+ 2. **GitHub:** on the [GitHub App](#github-app)'s settings, turn the webhook on with the URL `<ARMADA_AUTH_URL>/api/webhooks/github` and the secret of `ARMADA_GITHUB_WEBHOOK_SECRET`; under Permissions & events > Subscribe to events, tick Pull request, Check suite, Check run and Status.
285
+ 3. Set both variables for Production (and Preview if it has its own database), and redeploy.
286
+
287
+ - Each delivery is checked (Linear's `Linear-Signature` and a timestamp within a minute; GitHub's `X-Hub-Signature-256`), marks the projects it concerns in one statement, and is answered at once; the refresh runs after the answer. A delivery only says which projects to read again: nothing in it is stored or shown, and the reading always comes from Linear and GitHub with the project's own keys.
288
+ - A Linear delivery concerns the projects whose reading holds its ticket (or the ticket's parent, for a new ticket); a GitHub delivery, the projects of its repository. A burst of deliveries (a CI run) makes one read every 10 s at most, not one each; a mark left by the burst waits for the next view or delivery, and stays until a reading that saw it is written, even if a refresh fails or is cut short. A label renamed in Linear asks every project for a whole read on its next view.
289
+ - Until a variable is set, its webhook answers 503 and the dashboard refreshes on view as before.
290
+
273
291
  ## Sign in from a terminal
274
292
 
275
293
  The CLI knows who is acting, and for which organization, by signing in to Armada, the way `gh auth login` does:
package/dist/armada.js CHANGED
@@ -220,6 +220,19 @@ function networkReason(err, timeoutMs) {
220
220
  }
221
221
  var chunks = (xs, n) => Array.from({ length: Math.ceil(xs.length / n) }, (_, k) => xs.slice(k * n, k * n + n));
222
222
  var CLOSED = new Set(["completed", "canceled"]);
223
+ var isCandidate = (i, rootId) => i.id !== rootId && !CLOSED.has(i.statusType) && (i.agentPhase !== null || i.statusType === "started");
224
+ async function readComments(opts, issues, warnings) {
225
+ const comments = [];
226
+ for (const batch of chunks(issues.map((i) => i.uuid), COMMENT_BATCH)) {
227
+ const data = await gql(opts, COMMENTS_QUERY, { ids: batch });
228
+ for (const n of data.issues.nodes) {
229
+ await readRest(opts, n.identifier, MORE.comments, n.comments, warnings);
230
+ for (const c of n.comments.nodes)
231
+ comments.push(normalizeComment(c, n.identifier));
232
+ }
233
+ }
234
+ return comments;
235
+ }
223
236
  async function fetchProgram(opts) {
224
237
  try {
225
238
  return await fetchTree(opts, true);
@@ -260,16 +273,7 @@ async function fetchTree(opts, delegate) {
260
273
  for (const field of ["inverseRelations", "labels", "attachments"])
261
274
  await readRest(opts, r.identifier, MORE[field], r[field], warnings);
262
275
  const issues = all.map((r) => normalizeIssue(r, opts.labels));
263
- const candidates = issues.filter((i) => i.id !== root.identifier && !CLOSED.has(i.statusType) && (i.agentPhase || i.statusType === "started"));
264
- const comments = [];
265
- for (const batch of chunks(candidates.map((i) => i.uuid), COMMENT_BATCH)) {
266
- const data = await gql(opts, COMMENTS_QUERY, { ids: batch });
267
- for (const n of data.issues.nodes) {
268
- await readRest(opts, n.identifier, MORE.comments, n.comments, warnings);
269
- for (const c of n.comments.nodes)
270
- comments.push(normalizeComment(c, n.identifier));
271
- }
272
- }
276
+ const comments = await readComments(opts, issues.filter((i) => isCandidate(i, root.identifier)), warnings);
273
277
  return {
274
278
  rootId: root.identifier,
275
279
  fetchedAt: (opts.now?.() ?? new Date).toISOString(),
@@ -303,6 +307,13 @@ async function readRest(opts, identifier, more, conn, warnings) {
303
307
  }
304
308
  }
305
309
  }
310
+ var CHANGED_COMMENTS_QUERY = `
311
+ query ChangedComments($filter: CommentFilter, $after: String) {
312
+ comments(first: ${MORE_PAGE}, after: $after, filter: $filter) {
313
+ pageInfo { hasNextPage endCursor }
314
+ nodes { ${MORE.comments.nodes} issue { identifier } }
315
+ }
316
+ }`;
306
317
 
307
318
  // ../core/src/armada-api.ts
308
319
  var displayCode = (code) => code.length === 8 ? `${code.slice(0, 4)}-${code.slice(4)}` : code;
@@ -4983,14 +4994,18 @@ async function readStatusSources(config, opts) {
4983
4994
  ...opts.fetch ? { fetch: opts.fetch } : {},
4984
4995
  now
4985
4996
  });
4986
- const forgeP = opts.githubToken ? fetchForge({
4997
+ const [program, forge] = await Promise.all([programP, readForge(config, opts, now)]);
4998
+ return { program, ...forge };
4999
+ }
5000
+ function readForge(config, opts, now) {
5001
+ if (!opts.githubToken)
5002
+ return Promise.resolve({ forge: null, forgeError: "no GitHub token (set GITHUB_TOKEN or run gh auth login)" });
5003
+ return fetchForge({
4987
5004
  token: opts.githubToken,
4988
5005
  repository: config.github.repository,
4989
5006
  ...opts.fetch ? { fetch: opts.fetch } : {},
4990
5007
  now
4991
- }).then((forge) => ({ forge, forgeError: null }), (err) => ({ forge: null, forgeError: err instanceof Error ? err.message : String(err) })) : Promise.resolve({ forge: null, forgeError: "no GitHub token (set GITHUB_TOKEN or run gh auth login)" });
4992
- const [program, forge] = await Promise.all([programP, forgeP]);
4993
- return { program, ...forge };
5008
+ }).then((forge) => ({ forge, forgeError: null }), (err) => ({ forge: null, forgeError: err instanceof Error ? err.message : String(err) }));
4994
5009
  }
4995
5010
  async function loadStatus(config, opts) {
4996
5011
  const now = opts.now ?? (() => new Date);
@@ -5009,7 +5024,7 @@ async function loadStatus(config, opts) {
5009
5024
  });
5010
5025
  }
5011
5026
  // package.json
5012
- var version = "0.2.2";
5027
+ var version = "0.2.3";
5013
5028
 
5014
5029
  // src/io.ts
5015
5030
  class UsageError extends Error {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-vibe-company/armada",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "description": "Run a fleet of coding agents on one project: the armada command line.",
6
6
  "license": "MIT",