@indigoai-us/hq-cli 5.345.231 → 5.345.233

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 (107) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +3 -2
  3. package/assets/lanes-reconcile/hq-lanes-reconcile.service +1 -1
  4. package/assets/scaffold/core/scripts/pipeline-conductor.sh +14 -14
  5. package/assets/scaffold/core/scripts/pipeline-driver.sh +7 -7
  6. package/assets/scaffold/core/scripts/session-project.sh +19 -4
  7. package/dist/command-catalog.generated.d.ts +213 -177
  8. package/dist/command-catalog.generated.js +263 -212
  9. package/dist/command-registration-plan.d.ts +6 -24
  10. package/dist/command-registration-plan.js +4 -8
  11. package/dist/commands/auth.js +3 -2
  12. package/dist/commands/core-handoff.d.ts +1 -0
  13. package/dist/commands/core-handoff.js +2 -28
  14. package/dist/commands/core-pipeline-conductor-command.js +1 -1
  15. package/dist/commands/core-pipeline-conductor-native.js +5 -5
  16. package/dist/commands/core-pipeline-driver-native.js +5 -5
  17. package/dist/commands/daemon.js +7 -36
  18. package/dist/commands/deploy-access.js +6 -13
  19. package/dist/commands/deploy-comments.js +5 -13
  20. package/dist/commands/deploy-domains.js +6 -13
  21. package/dist/commands/deploy-list.js +25 -11
  22. package/dist/commands/deploy-mutations.d.ts +3 -0
  23. package/dist/commands/deploy-mutations.js +147 -0
  24. package/dist/commands/link.js +29 -0
  25. package/dist/commands/mcp-serve-gate.d.ts +22 -0
  26. package/dist/commands/mcp-serve-gate.js +37 -0
  27. package/dist/commands/mcp-serve.js +2 -8
  28. package/dist/commands/mesh.js +3 -1
  29. package/dist/commands/report.js +8 -9
  30. package/dist/data/command-states.json +10 -7
  31. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +257 -214
  32. package/dist/hq-cloud-sync-runner/package.json +1 -1
  33. package/dist/index.js +6 -1
  34. package/dist/lib/bot/fleet-bots-update-pass.d.ts +8 -0
  35. package/dist/lib/bot/fleet-bots-update-pass.js +40 -0
  36. package/dist/lib/bot/fleet-bots-update-task.d.ts +12 -0
  37. package/dist/lib/bot/fleet-bots-update-task.js +52 -0
  38. package/dist/lib/bot/fleet-bots-update-worker-v1.d.ts +2 -0
  39. package/dist/lib/bot/fleet-bots-update-worker-v1.js +5 -0
  40. package/dist/lib/daemon/catalog.d.ts +8 -5
  41. package/dist/lib/daemon/catalog.js +15 -8
  42. package/dist/lib/daemon/flag.d.ts +2 -0
  43. package/dist/lib/daemon/flag.js +6 -4
  44. package/dist/lib/daemon/lock.js +33 -37
  45. package/dist/lib/daemon/ops/skill-command.d.ts +99 -0
  46. package/dist/lib/daemon/ops/skill-command.js +260 -0
  47. package/dist/lib/daemon/protocol.d.ts +1 -1
  48. package/dist/lib/daemon/protocol.js +1 -0
  49. package/dist/lib/daemon/run.js +10 -18
  50. package/dist/lib/daemon/server.js +7 -0
  51. package/dist/lib/daemon/shared-flag-reads.d.ts +70 -0
  52. package/dist/lib/daemon/shared-flag-reads.js +173 -0
  53. package/dist/lib/daemon/supervisor.d.ts +5 -0
  54. package/dist/lib/daemon/supervisor.js +17 -2
  55. package/dist/lib/db/app-ref.js +10 -15
  56. package/dist/lib/deploy-apps.d.ts +29 -0
  57. package/dist/lib/deploy-apps.js +37 -0
  58. package/dist/lib/doctor/checks/search-index.d.ts +16 -0
  59. package/dist/lib/doctor/checks/search-index.js +61 -0
  60. package/dist/lib/doctor/checks/stranded-lanes.js +1 -1
  61. package/dist/lib/doctor/registry.js +4 -0
  62. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  63. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  64. package/dist/lib/lanes/accounts.js +3 -3
  65. package/dist/lib/lanes/admission-host.js +1 -1
  66. package/dist/lib/lanes/admission.js +4 -4
  67. package/dist/lib/lanes/autopilot.js +2 -2
  68. package/dist/lib/lanes/blocker-freshness.js +1 -1
  69. package/dist/lib/lanes/compaction.js +5 -5
  70. package/dist/lib/lanes/delivery.js +1 -1
  71. package/dist/lib/lanes/depth-cap.js +1 -1
  72. package/dist/lib/lanes/disk-guard.js +1 -1
  73. package/dist/lib/lanes/dropbox.js +1 -1
  74. package/dist/lib/lanes/hooks-install.js +1 -1
  75. package/dist/lib/lanes/imported-question.js +1 -1
  76. package/dist/lib/lanes/keep-alive.d.ts +2 -2
  77. package/dist/lib/lanes/keep-alive.js +3 -3
  78. package/dist/lib/lanes/kr-freshness.js +1 -1
  79. package/dist/lib/lanes/links.js +4 -4
  80. package/dist/lib/lanes/loop.js +2 -2
  81. package/dist/lib/lanes/machine-identity.js +3 -3
  82. package/dist/lib/lanes/models.js +6 -6
  83. package/dist/lib/lanes/quota.js +1 -1
  84. package/dist/lib/lanes/reconcile-install.js +3 -3
  85. package/dist/lib/lanes/reconcile.js +16 -16
  86. package/dist/lib/lanes/remote-control-lane.js +6 -6
  87. package/dist/lib/lanes/reviews.js +2 -2
  88. package/dist/lib/lanes/spawn.js +24 -24
  89. package/dist/lib/lanes/status-fields.js +4 -4
  90. package/dist/lib/lanes/wait.js +4 -4
  91. package/dist/lib/lanes/watch.js +2 -2
  92. package/dist/lib/lanes/watcher-main.js +1 -1
  93. package/dist/lib/lanes/watcher.js +38 -38
  94. package/dist/lib/lanes/worker-process.js +5 -5
  95. package/dist/lib/mesh/live/daemon/pid-lock.d.ts +2 -4
  96. package/dist/lib/mesh/live/daemon/pid-lock.js +38 -55
  97. package/dist/utils/cognito-session.d.ts +2 -56
  98. package/dist/utils/cognito-session.js +6 -164
  99. package/dist/utils/exclusive-lock.d.ts +60 -0
  100. package/dist/utils/exclusive-lock.js +65 -0
  101. package/package.json +9 -8
  102. package/dist/commands/staff/listings.d.ts +0 -41
  103. package/dist/commands/staff/listings.js +0 -160
  104. package/dist/commands/staff/reset-test-account.d.ts +0 -121
  105. package/dist/commands/staff/reset-test-account.js +0 -285
  106. package/dist/commands/staff/test-account.d.ts +0 -51
  107. package/dist/commands/staff/test-account.js +0 -196
@@ -14,6 +14,7 @@ import { enqueueSessionEvent } from "../lib/mesh/live/enqueue.js";
14
14
  import { renderIndexTarget } from "../lib/index-render/index.js";
15
15
  import { defaultBackgroundDependencies, runBackgroundLauncher, } from "../lib/search-index/background.js";
16
16
  import { resolveLiveRoot } from "../utils/hq-roots.js";
17
+ import { resolveSessionId } from "../lib/core-utils/session-id.js";
17
18
  import { runBundledScript } from "../utils/run-bundled-script.js";
18
19
  import { describeCoreCommand } from "./core-command-catalog.js";
19
20
  import { subprocess } from "./core-delegate.js";
@@ -33,34 +34,7 @@ const DESCRIPTIONS = {
33
34
  post: "Run best-effort post-handoff maintenance",
34
35
  openSteps: "List and update open handoff steps",
35
36
  };
36
- const SESSION_ID_ENV_KEYS = [
37
- "HQ_SESSION_ID",
38
- "CLAUDE_CODE_SESSION_ID",
39
- "CLAUDE_SESSION_ID",
40
- "CODEX_SESSION_ID",
41
- "CODEX_THREAD_ID",
42
- "GROK_SESSION_ID",
43
- "HQ_FLEET_SESSION_ID",
44
- ];
45
- function validSessionId(value) {
46
- return value !== "" && value !== "." && value !== ".." && /^[A-Za-z0-9._-]+$/.test(value);
47
- }
48
- function resolveSessionId(root) {
49
- for (const key of SESSION_ID_ENV_KEYS) {
50
- const value = (process.env[key] ?? "").replace(/\s/g, "");
51
- if (validSessionId(value))
52
- return value;
53
- }
54
- const current = path.join(root, "workspace/sessions/.current");
55
- try {
56
- const value = fs.readFileSync(current, "utf8").replace(/\s/g, "");
57
- return validSessionId(value) ? value : "";
58
- }
59
- catch {
60
- return "";
61
- }
62
- }
63
- function boundSessionCompany(root) {
37
+ export function boundSessionCompany(root) {
64
38
  const sessionId = resolveSessionId(root);
65
39
  if (!sessionId)
66
40
  return "";
@@ -6,7 +6,7 @@ import { describeCoreCommand } from "./core-command-catalog.js";
6
6
  import { coreNativePipelineEnabled } from "./core-native-pipeline-flag.js";
7
7
  export const PIPELINE_CONDUCTOR_ASSET = "core/scripts/pipeline-conductor.sh";
8
8
  export const PIPELINE_DRIVER_ASSET = "core/scripts/pipeline-driver.sh";
9
- const CONDUCTOR_USAGE = "# pipeline-conductor.sh - deterministic helpers for the pipeline-conductor\n# worker (/run-project --pipeline). The conductor owns a story queue and routes\n# each phase of each story to an hq-cli loop lane. It never spawns a child\n# agent: every phase runs in a lane the loop controller owns.\n#\n# Usage (every subcommand takes --state <dir>; most take --prd <prd.json>):\n# next --prd P --state S [--limit N] eligible story ids, one per line\n# classify --prd P --state S --story ID [--worktree DIR | --worktree REPO=DIR ...]\n# [--overlay F] [--table T] write stories/<id>.json (phases, repo,\n# worktree, classified_by); print phases\n# classify --prd P --state S [--overlay F] [--table T]\n# (no --story) check every story that is not\n# passing or skipped, write nothing; prints\n# OK/WARN/ERROR lines, exit 1 on any ERROR\n# overlay set --state S --story ID --sequence a,b,c | overlay show --state S\n# the run's classification overlay\n# (<state>/overlay.json); the prd is not edited\n# skip --state S --story ID [--note TEXT] [--force] [--prd P]\n# unskip --state S --story ID leave a story out of the run (skips.json)\n# worktree --state S --repo R --shared [--prd P] [--story ID] [--story-branches]\n# [--worktree DIR | --worktree R=DIR] [--allow-repos-worktree]\n# cut the run's worktree for repo R: one per\n# repo on the run's feature branch (default),\n# or one per story with --story-branches.\n# Default target, every mode:\n# <HQ>/workspace/worktrees/<project>/<repo-name>/\n# (<repo-name>-<story> with --story-branches)\n# worktree --state S --repo R [--prd P] without --shared: with --prd, the same cut\n# at the default target; without it, the repo\n# itself (refused under repos/, see below)\n# route --prd P --state S --story ID queue the story's current phase\n# accept --state S --story ID --handoff F record a phase handoff and advance\n# recheck --prd P --state S --story ID re-read literal ACs against ac_evidence\n# gate tick|status --state S\n# gate result --state S pass|fail [--note TEXT]\n# release --state S (--story ID [--worker W] | --worker W)\n# resolve an approval decision item\n# report story --state S --story ID | report final --state S\n# tick --prd P --state S [--worktree DIR | --worktree REPO=DIR ...] [--story-branches]\n# [--table T] (the confirmed worker table; recorded in run.json)\n# one routing pass over the queue\n# go --state S --story ID [--note TEXT] release a story held awaiting_go\n# interrupt --state S [--story ID] [--note TEXT] mark every (or one) in_flight story interrupted (phase,\n# time) and withdraw its envelope from the lane\n# queue when no lane picked it up; prints\n# INTERRUPTED <id> <phase> withdrawn|picked_up\n# stop --state S [--note TEXT] ask the run's driver to stop (driver/stop.json);\n# with no live driver, runs interrupt itself\n#\n# Run worktrees under repos/: the core Write/Edit guard blocks editor-tool writes\n# under <HQ>/repos/, so a lane that edits with Write or Edit stalls there. An\n# explicit --worktree (any command) that resolves under repos/ is refused\n# (exit 2) unless --allow-repos-worktree is passed; with it, every phase\n# envelope routed into that tree carries one constraint line telling the worker\n# to edit through the shell or apply_patch. A worktree must still sit inside\n# the HQ root for lanes to cd into it.\n#\n# Owner resolutions (the parent runs these after the owner answers; the\n# conductor and the driver never apply one on their own):\n# resolve --state S --story ID --as accepted-partial --note TEXT [--prd P]\n# accept a blocked story as a partial\n# draft; dependents may route; passes\n# is never set for it\n# resolve --state S --story ID --as retry [--note TEXT] [--prd P]\n# route the blocked phase again as a\n# fresh call; the note reaches the worker;\n# re-reads the story's phases from the prd\n# (P, else the prd run.json records), resumes\n# at the first phase without a passed handoff,\n# and starts the failed-attempt count over\n# failcap --state S --story ID the current phase returned failed too often:\n# hold the story as blocked_needs_owner and write\n# decisions/<id>-blocked-<phase>.md with each\n# failed handoff's text (exit 10)\n# park --state S --story ID [--note TEXT] [--prd P] [--force]\n# set the story aside; every story that\n# depends on it is held as parked_dependency.\n# Prints PARK_CLOSURE <id> <n>: <ids> first; more\n# than PC_PARK_CONFIRM (default 5) dependents\n# needs --force\n# unpark --state S --story ID [--prd P] reverse park; prints UNPARK_RELEASES <id> <n>: <ids>\n# park, unpark, skip and unskip each append a line to <state>/decisions.log.\n# reopen --state S --story ID --note TEXT [--from-phase PHASE] [--prd P]\n# send a verified or accepted_partial story\n# back: queued at PHASE (default: the first\n# phase whose worker is not a reviewer or\n# tester), handoffs from PHASE on archived as\n# handoffs/<id>-<phase>.reopened.<n>.json, the\n# attempt count starts over, the note reaches\n# the worker in the envelope. Clears passes:true\n# in the prd. Verified dependents are not\n# reopened; the final summary lists them.\n# gate result --state S fail --story ID --note TEXT [--from-phase PHASE] [--prd P]\n# record a failed gate that names the story that\n# caused it: reopen that story (as above) and set\n# the gate to `reopened`, so routing goes on and\n# the reopened story routes first; the gate is due\n# again once every reopened story verifies\n# Each refuses a story in a state it does not apply to (exit 1) and is\n# idempotent: repeating it prints ALREADY and exits 0.\n#\n# State dir layout:\n# stories/<id>.json phases, current index, state, reroutes, worktree\n# envelopes/<id>-<phase>.json envelopes queued to hq lanes\n# handoffs/<id>-<phase>.json accepted phase handoffs\n# decisions/<id>-<worker>.md approval items for the parent session\n# decisions/<id>-blocked-<phase>.md a worker returned status blocked\n# run.json the prd path the last tick used (for park and report)\n# approvals.json workers released for the whole run / per story\n# gate.json regression gate cadence and state\n# report.md one line per finished story + one final summary\n#\n# Classification (classify, and tick when a story first starts): the story's worker\n# sequence is its full phase sequence, in order: the overlay entry, else\n# worker_preference, else the keyword fallback (classified_by records which).\n# classify refuses (exit 1, every problem listed) when:\n# - a worker id has no worker.yaml under PC_WORKERS_ROOT (the message names the\n# roots and the nearest known ids);\n# - a story that declares code files (anything but docs/, markdown, text, yaml)\n# starts with a verifier or reader (is_implementer below reads worker.role,\n# else worker.type, from worker.yaml); prepend an implementer or set\n# \"docs_only\": true;\n# - a run with a worker table (--table, recorded by tick in run.json) has a\n# sequence worker with no row in it.\n# It warns (stderr, once per story) on a one-worker sequence, on a model_hint\n# (a table pin wins: \"hint ignored, table pins <model>\"; a bare alias opus,\n# sonnet, haiku or fable is never used), and on the dependency lint (dep_lint).\n# route prints NO_LANE <id> <phase> <worker> and exits 12 when the current\n# phase's worker has no table row; the story stays queued.\n#\n# Skip list: a skipped story (<state>/skips.json, stories/<id>.json state skipped)\n# is not selected, routed, gated or counted; FINAL lists it with its note.\n# Skipping a story others depend on prints SKIP_STRANDS and needs --force.\n#\n# Repo per story: classify resolves each story's repo, in this order:\n# 1. the story's `repoPath`;\n# 2. when the prd lists more than one repo, the repo that owns the story's first\n# declared file (`files[0]`): an absolute path under the repo, a path from\n# the HQ root, a path that starts with the repo's directory name, or a path\n# that exists inside exactly one repo. The repo list is `metadata.repos[]`\n# (canonical; each entry a path string or an object with `path` or\n# `repoPath`); `metadata.repoPaths[]` (path strings) is read as an alias;\n# 3. `metadata.repoPath`.\n# Relative repo paths are read from the HQ root. stories/<id>.json records\n# the resolved `repo`. `tick --worktree <repo>=<worktree>` (repeatable) maps\n# each repo to its worktree and every phase of a story goes to the worktree of\n# its repo; the bare `--worktree <dir>` form serves a prd with at most one\n# repo. A story whose repo has no worktree is held blocked_needs_owner with a\n# decision item naming the repo; it is never routed to another repo's tree.\n# The envelope carries `repo`, `worktree` and, for a git worktree, `branch`.\n#\n# Branches: `metadata.baseBranch` (default main) is the base. Every cut starts\n# from origin/<baseBranch> when that ref exists after `git fetch origin\n# <baseBranch>`, else from local <baseBranch>, never from the repo's HEAD; the\n# exact ref is printed (CUT <branch> from <ref> <sha>). Neither ref: exit 1.\n# Default mode: one feature branch per repo for the run (`metadata.branchName`,\n# else feature/<project>) in one worktree per repo; every story of that repo\n# commits on it in dependency order, one story in flight per repo branch.\n# `--story-branches` (tick and worktree): one branch and worktree per story\n# (pipeline/<id>), cut when the story first routes from the branch of the last\n# verified story it depends on in the same repo (stacked), else from the base.\n# A story whose dependency branch is missing is held blocked_needs_owner.\n#\n# Concurrency: in the default mode PC_MAX_STORIES is lowered to the number of\n# worktrees in play (one story per repo branch at a time) and tick prints\n# MAX_STORIES <n> with the reason when it lowers it.\n#\n# Story-level go: a story with `approval: \"explicit\"` (canonical; the alias\n# `needsApproval: true` is read too), or one the release detector flags (its\n# declared files or acceptance criteria mention deploy, release, production,\n# or merging to the base branch; patterns in RELEASE_PATTERNS below), is held\n# awaiting_go before its first implementing phase, whatever the worker's\n# approval_required says, with decisions/<id>-go.md. Only `go` releases it;\n# `release --worker` (whole-run approval) does not. resolve and park apply.\n#\n# Story states: queued, in_flight, held, awaiting_go, awaiting_recheck, verified, failed_report,\n# blocked_needs_owner (a phase handoff said blocked; never retried on its own),\n# accepted_partial (owner accepted a blocked story as a partial draft; counts as\n# done for dependsOn, passes is never set), parked (owner set it aside),\n# parked_dependency (depends, directly or not, on a parked story).\n# A reopened story is queued again with a `reopen` record (note, phase, the\n# verified dependents at the time); report.md drops its earlier line.\n#\n# Back-pressure hint: when a story's `files` include a data store or schema path\n# (contains store, schema, migration or db/), every envelope of that story\n# carries a constraint asking the worker to run the repo's schema-contract\n# tests, if present.\n#\n# A handoff with status `failed` re-queues the phase (the driver allows one\n# route-back). A handoff with status `blocked` holds the story as\n# blocked_needs_owner and writes one decision item: a rerun cannot help.\n# A state dir from the previous version (a queued story whose newest archived\n# handoff, handoffs/<id>-<phase>.failed.<n>.json, says blocked) is read as\n# blocked_needs_owner, so resolve works on it without hand edits.\n#\n# Exit codes: 0 ok; 1 refused or failed; 2 usage; 3 lane capacity/admission (retry next tick);\n# 10 held for a parent decision (approval hold, or a blocked handoff on accept);\n# 11 lane down: `hq lanes enqueue` returned `loop_not_running` or a terminal\n# lane state. The worker mapping is dropped, the story stays queued, and\n# route prints LANE_DOWN <id> <phase> <worker> ...; tick stops there.\n# 12 no lane: the phase's worker has no row in the run's worker table (NO_LANE);\n# tick stops there.\n#\n# Env: PC_HQ (default hq), PC_ENVELOPE (default\n# core/scripts/pipeline-envelope.sh), PC_WORKERS_ROOT (colon-separated worker\n# roots, default below), PC_GATE_EVERY (default 3,\n# the /run-project regression cadence), PC_NOW (epoch seconds, for tests),\n# PC_DEADLINE_MIN (default 120), PC_MAX_STORIES (default 3), PC_HQ_ROOT,\n# PC_PARK_CONFIRM (default 5). PC_WORKERS_ROOT defaults to core/workers, every\n# companies/*/workers and personal/workers.\n#\n# The conductor never writes `passes` into prd.json. A verified story is\n# reported; the parent session decides what to record.\n#\n# bash 3.2 portable; JSON and YAML work is done by node.\n";
9
+ const CONDUCTOR_USAGE = "# pipeline-conductor.sh - deterministic helpers for the pipeline-conductor\n# worker (/run-project --pipeline). The conductor owns a story queue and routes\n# each phase of each story to an hq-cli loop lane. It never spawns a child\n# agent: every phase runs in a lane the loop controller owns.\n#\n# Usage (every subcommand takes --state <dir>; most take --prd <prd.json>):\n# next --prd P --state S [--limit N] eligible story ids, one per line\n# classify --prd P --state S --story ID [--worktree DIR | --worktree REPO=DIR ...]\n# [--overlay F] [--table T] write stories/<id>.json (phases, repo,\n# worktree, classified_by); print phases\n# classify --prd P --state S [--overlay F] [--table T]\n# (no --story) check every story that is not\n# passing or skipped, write nothing; prints\n# OK/WARN/ERROR lines, exit 1 on any ERROR\n# overlay set --state S --story ID --sequence a,b,c | overlay show --state S\n# the run's classification overlay\n# (<state>/overlay.json); the prd is not edited\n# skip --state S --story ID [--note TEXT] [--force] [--prd P]\n# unskip --state S --story ID leave a story out of the run (skips.json)\n# worktree --state S --repo R --shared [--prd P] [--story ID] [--story-branches]\n# [--worktree DIR | --worktree R=DIR] [--allow-repos-worktree]\n# cut the run's worktree for repo R: one per\n# repo on the run's feature branch (default),\n# or one per story with --story-branches.\n# Default target, every mode:\n# <HQ>/workspace/worktrees/<project>/<repo-name>/\n# (<repo-name>-<story> with --story-branches)\n# worktree --state S --repo R [--prd P] without --shared: with --prd, the same cut\n# at the default target; without it, the repo\n# itself (refused under repos/, see below)\n# route --prd P --state S --story ID queue the story's current phase\n# accept --state S --story ID --handoff F record a phase handoff and advance\n# recheck --prd P --state S --story ID re-read literal ACs against ac_evidence\n# gate tick|status --state S\n# gate result --state S pass|fail [--note TEXT]\n# release --state S (--story ID [--worker W] | --worker W)\n# resolve an approval decision item\n# report story --state S --story ID | report final --state S\n# tick --prd P --state S [--worktree DIR | --worktree REPO=DIR ...] [--story-branches]\n# [--table T] (the confirmed worker table; recorded in run.json)\n# one routing pass over the queue\n# go --state S --story ID [--note TEXT] release a story held awaiting_go\n# interrupt --state S [--story ID] [--note TEXT] mark every (or one) in_flight story interrupted (phase,\n# time) and withdraw its envelope from the lane\n# queue when no lane picked it up; prints\n# INTERRUPTED <id> <phase> withdrawn|picked_up\n# stop --state S [--note TEXT] ask the run's driver to stop (driver/stop.json);\n# with no live driver, runs interrupt itself\n#\n# Run worktrees under repos/: the core Write/Edit guard blocks editor-tool writes\n# under <HQ>/repos/, so a lane that edits with Write or Edit stalls there. An\n# explicit --worktree (any command) that resolves under repos/ is refused\n# (exit 2) unless --allow-repos-worktree is passed; with it, every phase\n# envelope routed into that tree carries one constraint line telling the worker\n# to edit through the shell or apply_patch. A worktree must still sit inside\n# the HQ root for lanes to cd into it.\n#\n# Owner resolutions (the parent runs these after the owner answers; the\n# conductor and the driver never apply one on their own):\n# resolve --state S --story ID --as accepted-partial --note TEXT [--prd P]\n# accept a blocked story as a partial\n# draft; dependents may route; passes\n# is never set for it\n# resolve --state S --story ID --as retry [--note TEXT] [--prd P]\n# route the blocked phase again as a\n# fresh call; the note reaches the worker;\n# re-reads the story's phases from the prd\n# (P, else the prd run.json records), resumes\n# at the first phase without a passed handoff,\n# and starts the failed-attempt count over\n# failcap --state S --story ID the current phase returned failed too often:\n# hold the story as blocked_needs_owner and write\n# decisions/<id>-blocked-<phase>.md with each\n# failed handoff's text (exit 10)\n# park --state S --story ID [--note TEXT] [--prd P] [--force]\n# set the story aside; every story that\n# depends on it is held as parked_dependency.\n# Prints PARK_CLOSURE <id> <n>: <ids> first; more\n# than PC_PARK_CONFIRM (default 5) dependents\n# needs --force\n# unpark --state S --story ID [--prd P] reverse park; prints UNPARK_RELEASES <id> <n>: <ids>\n# park, unpark, skip and unskip each append a line to <state>/decisions.log.\n# reopen --state S --story ID --note TEXT [--from-phase PHASE] [--prd P]\n# send a verified or accepted_partial story\n# back: queued at PHASE (default: the first\n# phase whose worker is not a reviewer or\n# tester), handoffs from PHASE on archived as\n# handoffs/<id>-<phase>.reopened.<n>.json, the\n# attempt count starts over, the note reaches\n# the worker in the envelope. Clears passes:true\n# in the prd. Verified dependents are not\n# reopened; the final summary lists them.\n# gate result --state S fail --story ID --note TEXT [--from-phase PHASE] [--prd P]\n# record a failed gate that names the story that\n# caused it: reopen that story (as above) and set\n# the gate to `reopened`, so routing goes on and\n# the reopened story routes first; the gate is due\n# again once every reopened story verifies\n# Each refuses a story in a state it does not apply to (exit 1) and is\n# idempotent: repeating it prints ALREADY and exits 0.\n#\n# State dir layout:\n# stories/<id>.json phases, current index, state, reroutes, worktree\n# envelopes/<id>-<phase>.json envelopes queued to hq runners\n# handoffs/<id>-<phase>.json accepted phase handoffs\n# decisions/<id>-<worker>.md approval items for the parent session\n# decisions/<id>-blocked-<phase>.md a worker returned status blocked\n# run.json the prd path the last tick used (for park and report)\n# approvals.json workers released for the whole run / per story\n# gate.json regression gate cadence and state\n# report.md one line per finished story + one final summary\n#\n# Classification (classify, and tick when a story first starts): the story's worker\n# sequence is its full phase sequence, in order: the overlay entry, else\n# worker_preference, else the keyword fallback (classified_by records which).\n# classify refuses (exit 1, every problem listed) when:\n# - a worker id has no worker.yaml under PC_WORKERS_ROOT (the message names the\n# roots and the nearest known ids);\n# - a story that declares code files (anything but docs/, markdown, text, yaml)\n# starts with a verifier or reader (is_implementer below reads worker.role,\n# else worker.type, from worker.yaml); prepend an implementer or set\n# \"docs_only\": true;\n# - a run with a worker table (--table, recorded by tick in run.json) has a\n# sequence worker with no row in it.\n# It warns (stderr, once per story) on a one-worker sequence, on a model_hint\n# (a table pin wins: \"hint ignored, table pins <model>\"; a bare alias opus,\n# sonnet, haiku or fable is never used), and on the dependency lint (dep_lint).\n# route prints NO_LANE <id> <phase> <worker> and exits 12 when the current\n# phase's worker has no table row; the story stays queued.\n#\n# Skip list: a skipped story (<state>/skips.json, stories/<id>.json state skipped)\n# is not selected, routed, gated or counted; FINAL lists it with its note.\n# Skipping a story others depend on prints SKIP_STRANDS and needs --force.\n#\n# Repo per story: classify resolves each story's repo, in this order:\n# 1. the story's `repoPath`;\n# 2. when the prd lists more than one repo, the repo that owns the story's first\n# declared file (`files[0]`): an absolute path under the repo, a path from\n# the HQ root, a path that starts with the repo's directory name, or a path\n# that exists inside exactly one repo. The repo list is `metadata.repos[]`\n# (canonical; each entry a path string or an object with `path` or\n# `repoPath`); `metadata.repoPaths[]` (path strings) is read as an alias;\n# 3. `metadata.repoPath`.\n# Relative repo paths are read from the HQ root. stories/<id>.json records\n# the resolved `repo`. `tick --worktree <repo>=<worktree>` (repeatable) maps\n# each repo to its worktree and every phase of a story goes to the worktree of\n# its repo; the bare `--worktree <dir>` form serves a prd with at most one\n# repo. A story whose repo has no worktree is held blocked_needs_owner with a\n# decision item naming the repo; it is never routed to another repo's tree.\n# The envelope carries `repo`, `worktree` and, for a git worktree, `branch`.\n#\n# Branches: `metadata.baseBranch` (default main) is the base. Every cut starts\n# from origin/<baseBranch> when that ref exists after `git fetch origin\n# <baseBranch>`, else from local <baseBranch>, never from the repo's HEAD; the\n# exact ref is printed (CUT <branch> from <ref> <sha>). Neither ref: exit 1.\n# Default mode: one feature branch per repo for the run (`metadata.branchName`,\n# else feature/<project>) in one worktree per repo; every story of that repo\n# commits on it in dependency order, one story in flight per repo branch.\n# `--story-branches` (tick and worktree): one branch and worktree per story\n# (pipeline/<id>), cut when the story first routes from the branch of the last\n# verified story it depends on in the same repo (stacked), else from the base.\n# A story whose dependency branch is missing is held blocked_needs_owner.\n#\n# Concurrency: in the default mode PC_MAX_STORIES is lowered to the number of\n# worktrees in play (one story per repo branch at a time) and tick prints\n# MAX_STORIES <n> with the reason when it lowers it.\n#\n# Story-level go: a story with `approval: \"explicit\"` (canonical; the alias\n# `needsApproval: true` is read too), or one the release detector flags (its\n# declared files or acceptance criteria mention deploy, release, production,\n# or merging to the base branch; patterns in RELEASE_PATTERNS below), is held\n# awaiting_go before its first implementing phase, whatever the worker's\n# approval_required says, with decisions/<id>-go.md. Only `go` releases it;\n# `release --worker` (whole-run approval) does not. resolve and park apply.\n#\n# Story states: queued, in_flight, held, awaiting_go, awaiting_recheck, verified, failed_report,\n# blocked_needs_owner (a phase handoff said blocked; never retried on its own),\n# accepted_partial (owner accepted a blocked story as a partial draft; counts as\n# done for dependsOn, passes is never set), parked (owner set it aside),\n# parked_dependency (depends, directly or not, on a parked story).\n# A reopened story is queued again with a `reopen` record (note, phase, the\n# verified dependents at the time); report.md drops its earlier line.\n#\n# Back-pressure hint: when a story's `files` include a data store or schema path\n# (contains store, schema, migration or db/), every envelope of that story\n# carries a constraint asking the worker to run the repo's schema-contract\n# tests, if present.\n#\n# A handoff with status `failed` re-queues the phase (the driver allows one\n# route-back). A handoff with status `blocked` holds the story as\n# blocked_needs_owner and writes one decision item: a rerun cannot help.\n# A state dir from the previous version (a queued story whose newest archived\n# handoff, handoffs/<id>-<phase>.failed.<n>.json, says blocked) is read as\n# blocked_needs_owner, so resolve works on it without hand edits.\n#\n# Exit codes: 0 ok; 1 refused or failed; 2 usage; 3 lane capacity/admission (retry next tick);\n# 10 held for a parent decision (approval hold, or a blocked handoff on accept);\n# 11 lane down: `hq runners enqueue` returned `loop_not_running` or a terminal\n# lane state. The worker mapping is dropped, the story stays queued, and\n# route prints LANE_DOWN <id> <phase> <worker> ...; tick stops there.\n# 12 no lane: the phase's worker has no row in the run's worker table (NO_LANE);\n# tick stops there.\n#\n# Env: PC_HQ (default hq), PC_ENVELOPE (default\n# core/scripts/pipeline-envelope.sh), PC_WORKERS_ROOT (colon-separated worker\n# roots, default below), PC_GATE_EVERY (default 3,\n# the /run-project regression cadence), PC_NOW (epoch seconds, for tests),\n# PC_DEADLINE_MIN (default 120), PC_MAX_STORIES (default 3), PC_HQ_ROOT,\n# PC_PARK_CONFIRM (default 5). PC_WORKERS_ROOT defaults to core/workers, every\n# companies/*/workers and personal/workers.\n#\n# The conductor never writes `passes` into prd.json. A verified story is\n# reported; the parent session decides what to record.\n#\n# bash 3.2 portable; JSON and YAML work is done by node.\n";
10
10
  const valueArgs = {
11
11
  "--prd": "PC_PRD", "--state": "PC_STATE", "--story": "PC_STORY", "--handoff": "PC_HANDOFF",
12
12
  "--repo": "PC_REPO", "--worker": "PC_WORKER", "--worktree": "PC_WT", "--limit": "PC_LIMIT",
@@ -1686,10 +1686,10 @@ function do_route(p, sid) {
1686
1686
  rows = Array.isArray(listed) ? listed : get(listed, "lanes", null);
1687
1687
  }
1688
1688
  catch (e) {
1689
- die("cannot verify mapped pipeline lane ownership: hq lanes list returned invalid JSON");
1689
+ die("cannot verify mapped pipeline lane ownership: hq runners list returned invalid JSON");
1690
1690
  }
1691
1691
  if (!Array.isArray(rows))
1692
- die("cannot verify mapped pipeline lane ownership: hq lanes list omitted lanes");
1692
+ die("cannot verify mapped pipeline lane ownership: hq runners list omitted lanes");
1693
1693
  const row = rows.find((x) => isDict(x) && get(x, "lane_id") === lane);
1694
1694
  if (!row) {
1695
1695
  delete laneMap[ph.worker];
@@ -1738,11 +1738,11 @@ function do_route(p, sid) {
1738
1738
  print("RETRY " + sid + " " + S(ph.phase) + " lanes-" + code);
1739
1739
  exit(3);
1740
1740
  }
1741
- die("hq lanes create refused pipeline phase: " + code + " " + strip(created.stderr));
1741
+ die("hq runners create refused pipeline phase: " + code + " " + strip(created.stderr));
1742
1742
  }
1743
1743
  lane = get(answer, "lane_id", get(answer, "lane"));
1744
1744
  if (!T(lane))
1745
- die("hq lanes create returned no lane_id");
1745
+ die("hq runners create returned no lane_id");
1746
1746
  laneMap[ph.worker] = lane;
1747
1747
  jsave(lanesFile, laneMap);
1748
1748
  }
@@ -1789,7 +1789,7 @@ function do_route(p, sid) {
1789
1789
  print("LANE_DOWN " + sid + " " + S(ph.phase) + " " + S(ph.worker) + " lanes-" + code);
1790
1790
  exit(11);
1791
1791
  }
1792
- die("hq lanes enqueue failed for " + sid + "/" + S(ph.phase) + ": " + code + " " + strip(r.stderr));
1792
+ die("hq runners enqueue failed for " + sid + "/" + S(ph.phase) + ": " + code + " " + strip(r.stderr));
1793
1793
  }
1794
1794
  st.state = "in_flight";
1795
1795
  st.started = true;
@@ -429,7 +429,7 @@ export function releasePipelineDriverLock(driverDir) {
429
429
  fs.rmSync(path.join(driverDir, "lock"), { recursive: true, force: true });
430
430
  }
431
431
  // Exact `usage()` output from the pinned pipeline-driver.sh companion.
432
- const DRIVER_USAGE = inflateRawSync(Buffer.from("lVptcxu3Ef7OX7FDfjDZ4VG2kiYppWom4yiNWtd2bCdNJ82Q0N1ShwgHnAFQFCfNf+/sLnB3pCRPyi+27w6Lxb48++zCE2h1i0ZbLCqv79AvQg0FxBqhwqjKGiswzrVwjbW2FZz4rS1a737FMkJR5MWL0WQ0ga/BKItQKmtdhFvEFhSUtTYVKKPvEFoVIugYwO0soL3R/LUxcwiO9+StYq3iaAKNu8MAqlMQNs7vlK+gchiAdmCZ2oLifRfwoaYtPNoIAUPQzkKIyscwmkCsdYBQet1GiLV325sa6o+FHJIOrWwFyje0407piB6cBR0XcBWhUbe8ZdJ5NGGtwwIuVVnTqQLouBxNAODFolM8RGUQamUrt9mA24ACj8XHLW6xgrZWAUEFXSFM0zfh5FxXF8U5v7tYbJQ2WC3O7cXi1+DsbM4bnC5AlSW2MbDFsngltmMH7LyLCNGBx7A1cdWqWJP1QNk9aFtsjL6pI0sDSJpMuzgona22ZXQcCrJV2vqzBfitDeCxrLG8ZZF4h34PITq/B0WG0/YGdJQFny8g6vJWNO3ksmZuSyrWCBbvY9LBefFX/5zlkizyDt5T6OxqtPxB8rQOYBErrGg5PfdbSw8dBXMKy2yknY41bRG3AdZi3jV9y9pUoG6UtrC1URvZgbWqVQD5djSBomjUfcEvCnoYIOoGw+KpTa6NK2/TLpZslfaiI9FuyyPT1M5UgTMg2zRAkrGiY4aV21n0bI+d15ECbTSBCkvN8a4jNnN+yynMKc2ZKIck5ww9xht1+VRhi5ZU6yNfbH76gn1NIpMyab2zZi8esS7WLN0ERgDOArH/D0HdoGTHY2BTtL6C89ZXHOUXUBRkPITzSvuLHKTHv5+LYuf8bfSYPoT/wvCRx9Zd/FXeLBaLXz4hh09SXHtlyxrDL/QoqmuDcM5/LGK4u+Cn2kb0d8rAeUDyWLj4lNjjODm3IoVQwRQ7bSu3+2OSlDFu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I9pM/lreI8E+IIvfFnSfdR5w1i5WJm+l5qmpkJqM10Vto2IFw89m9BCB0oxOX6kLHR5OuqcDSIJWtp6MaSxjtquKfRVSLt2tQLUMwits5ieCXixHVa700oVjSAEI6xNnMgxrIQMVp0VuSmOzfpnPTmj9+eScAiatTi2kR11dNZhQbXU5jpZ/WO3tTwDJowlHSNu08eYHFBiC3Jsqac6kUnRxXZS1QJo4yeXpxFNrz0k/2Y4W6Y+fGnqsjn0G/pUdN19jABWOrz3lCv5ejONDqY5+toDwNfMjt6NEjjjs5AIeqXXE5GeeB0iZ6jV12SjVRGZYCnbRbsgSygcOrsFcsTXUkwSUsVjuKobZolilLbstYoi9Bx+izmPxOm8tAb40ezyMe8YX/MOKDYSIHA6yyhVwdohZTkTUQB+SDYhWt2Ez1Gd8REWd4StTQ1HerVJL9ZO6DoDhIPkpKv+iI421SrFp1xUISTloL6Mt7mK34HrzKiexhjo7Bmm88ZCS1CeuSrodbXlHd01RlnykRo+Dq4dlrVyK18P8JNhhjlXTtcmBw2iv3MLSyh1rdPn8b6PCS4MG+v3l6+unp9Of3r9dXPl9fTdzcvXr2avrt8+Y7uGED7b9J0Qum/MrLC8v85IPWDhsqEUw9aPr391pLHAtMJuGRp7ReQV+6t9DgF4wnvLy0TmTVaSabXEcLw0DV8m3sTSY/4fe7JfOzy2eojVx1XB0mO0YikzlhSn0mXrCE9hNkDgJqVArdwC5naMKrJjRSUO2MJrcMJCwWo54jsOrBerz0pCkCaWxqfo9T6O6WZqczKiWWQgrNiL27Shb01SYfuTOixkXoKixq8MhFK+V9S8HkO+pIv3HwHDY9cYugXySTKWMv7yYOYefnm9V9/ennz5jrF2cQcT30hUZ7HZ3JEvkwanJm3L6c//NhZv/qIh5LXePUHc2/rnKnt/ixQdN2/ohNN3755d/ULXVr1MxtWI3IDdVDXaMbZfx8+mv7f3715rSL4mmbNg5cMZh0I9vnMffU/", "base64")).toString("utf8");
433
433
  function parseDriverArgs(args) {
434
434
  const values = { prd: "", state: "", worktrees: [], storyBranches: false, allowReposWorktree: false,
435
435
  table: "", interval: "15", maxFails: "2", stallWindow: process.env.PIPELINE_DRIVER_STALL_SECS || "600" };
@@ -631,7 +631,7 @@ function driverTimestamp() {
631
631
  function laneRowsFromHq(hq) {
632
632
  const result = driverRun(hq, ["runners", "list", "--json"]);
633
633
  if (result.code !== 0)
634
- throw new Error(`hq lanes list --json exited ${result.code}: ${result.stderr.trim()}`);
634
+ throw new Error(`hq runners list --json exited ${result.code}: ${result.stderr.trim()}`);
635
635
  return extractLaneRows(result.stdout);
636
636
  }
637
637
  function extractLaneRows(text) {
@@ -640,7 +640,7 @@ function extractLaneRows(text) {
640
640
  return parsed;
641
641
  if (parsed && Array.isArray(parsed.lanes))
642
642
  return parsed.lanes;
643
- throw new Error("hq lanes list --json returned an unexpected JSON shape");
643
+ throw new Error("hq runners list --json returned an unexpected JSON shape");
644
644
  }
645
645
  export async function stopDriverLanes(state, hq, logFile, options = {}) {
646
646
  const laneFile = path.join(state, "lanes.json");
@@ -842,7 +842,7 @@ export async function runPipelineDriverNative(args, hqRoot = "") {
842
842
  else if (action === "DEADLINE")
843
843
  return finish(22, `phase ${a}/${b} passed its deadline ${c} with no handoff`);
844
844
  else if (action === "QUEUED_TOO_LONG")
845
- return finish(22, `phase ${a}/${b} waited ${c}s in the queue of lane ${d} without being picked up (limit PC_QUEUE_MAX_MIN=${queueMaxSeconds() / 60} min); check lane admission (hq lanes list), then restart the driver`);
845
+ return finish(22, `phase ${a}/${b} waited ${c}s in the queue of lane ${d} without being picked up (limit PC_QUEUE_MAX_MIN=${queueMaxSeconds() / 60} min); check lane admission (hq runners list), then restart the driver`);
846
846
  else if (action === "HELD")
847
847
  held = `${a} ${b}`;
848
848
  else if (action === "BLOCKED")
@@ -872,7 +872,7 @@ export async function runPipelineDriverNative(args, hqRoot = "") {
872
872
  }
873
873
  const detail = question || "no pending question returned";
874
874
  writeDriverLog(logFile, `LANE_QUESTION story=${a} phase=${b} lane=${lane} question=${detail}`);
875
- return finish(28, `loop lane ${lane} parked after repeated stalls for ${a}/${b}; answer its pending question with hq lanes questions answer, then restart the driver: ${detail}`);
875
+ return finish(28, `loop lane ${lane} parked after repeated stalls for ${a}/${b}; answer its pending question with hq runners questions answer, then restart the driver: ${detail}`);
876
876
  }
877
877
  else
878
878
  return finish(23, `scan printed an unknown line: ${action}`);
@@ -1070,7 +1070,7 @@ async function knownClaudeAccountIds(d) {
1070
1070
  const host = currentHost(d);
1071
1071
  const root = readDaemonConfig(host.paths.configPath).hqRoot ?? d.resolveHqRoot(undefined);
1072
1072
  if (!root)
1073
- throw new DaemonCommandError("Could not resolve the HQ folder needed to validate hq lanes Claude account IDs.");
1073
+ throw new DaemonCommandError("Could not resolve the HQ folder needed to validate hq runners Claude account IDs.");
1074
1074
  const { loadLanesConfig } = await import("../lib/lanes/config.js");
1075
1075
  return Object.keys(loadLanesConfig(root).providers.claude.accounts);
1076
1076
  }
@@ -1923,37 +1923,8 @@ export function registerDaemonCommand(program, over = {}) {
1923
1923
  .command("fleet-bots-update")
1924
1924
  .description("Move each installed HQ Fleet bot to the current runtime release while it is idle, and restart it")
1925
1925
  .action(wrap(async (d) => {
1926
- const [{ runFleetBotsUpdate, listFleetBots }, local, bot, { botsRoot }, { hasPromotionHold }] = await Promise.all([
1927
- import("../lib/bot/fleet-watch.js"),
1928
- import("../lib/bot/fleet-local.js"),
1929
- import("./bot.js"),
1930
- import("../lib/bot/paths.js"),
1931
- import("../lib/bot/promotion-hold.js"),
1932
- ]);
1933
- const alive = (pid) => {
1934
- try {
1935
- process.kill(pid, 0);
1936
- return true;
1937
- }
1938
- catch (error) {
1939
- return error.code === "EPERM";
1940
- }
1941
- };
1942
- await runFleetBotsUpdate({
1943
- listBots: () => listFleetBots(botsRoot()),
1944
- target: () => local.resolveFleetLocalPointerTarget(),
1945
- installed: (b) => {
1946
- if (b.config.enabled === false)
1947
- return false;
1948
- const pid = local.fleetLocalGatewayPid(b.config.agentUid);
1949
- return pid !== null && alive(pid);
1950
- },
1951
- heldForPromotion: (b) => hasPromotionHold(b.dir),
1952
- needsAdoption: (b, release) => local.fleetLocalProfileNeedsAdoption(b.config.agentUid, { release }),
1953
- busy: (b) => local.fleetLocalBusyReason(b.config.agentUid),
1954
- update: (b) => bot.updateFleetRuntimeBot(b.name, { busy: () => local.fleetLocalBusyReason(b.config.agentUid) }),
1955
- log: (line) => d.out(line),
1956
- });
1926
+ const { runInstalledFleetBotsUpdate } = await import("../lib/bot/fleet-bots-update-pass.js");
1927
+ await runInstalledFleetBotsUpdate((line) => d.out(line));
1957
1928
  }));
1958
1929
  service
1959
1930
  .command("sync-core-reconcile")
@@ -2044,22 +2015,22 @@ export function registerDaemonCommand(program, over = {}) {
2044
2015
  service
2045
2016
  .command("remote-control-pool")
2046
2017
  .description("Keep one configured Claude Remote Control account pool running in its private mount namespace")
2047
- .requiredOption("--account-id <id>", "Claude account ID from hq lanes accounts")
2018
+ .requiredOption("--account-id <id>", "Claude account ID from hq runners accounts")
2048
2019
  .action(wrap((d, opts) => runServiceRemoteControlPool(d, opts.accountId)));
2049
2020
  service
2050
2021
  .command("remote-control-pool-host")
2051
2022
  .description("Run one pool's forwarder and Claude host inside its private namespace")
2052
- .requiredOption("--account-id <id>", "Claude account ID from hq lanes accounts")
2023
+ .requiredOption("--account-id <id>", "Claude account ID from hq runners accounts")
2053
2024
  .action(wrap((d, opts) => runServiceRemoteControlPoolHost(d, opts.accountId)));
2054
2025
  service
2055
2026
  .command("remote-control-pool-forwarder-host")
2056
2027
  .description("Supervise one pool's personal HQ Secret injected inference forwarder")
2057
- .requiredOption("--account-id <id>", "Claude account ID from hq lanes accounts")
2028
+ .requiredOption("--account-id <id>", "Claude account ID from hq runners accounts")
2058
2029
  .action(wrap((d, opts) => runServiceRemoteControlPoolForwarderHost(d, opts.accountId)));
2059
2030
  service
2060
2031
  .command("remote-control-pool-forwarder")
2061
2032
  .description("Run the loopback-only /v1/messages inference forwarder")
2062
- .requiredOption("--account-id <id>", "Claude account ID from hq lanes accounts")
2033
+ .requiredOption("--account-id <id>", "Claude account ID from hq runners accounts")
2063
2034
  .requiredOption("--port <port>", "loopback listener port")
2064
2035
  .requiredOption("--secret-env <name>", "HQ Secrets injected environment variable name")
2065
2036
  .requiredOption("--ready-file <path>", "private daemon state file for listener ownership")
@@ -1,6 +1,6 @@
1
1
  import { createInterface } from "node:readline/promises";
2
2
  import { deployApiRequest } from "../lib/deploy-api.js";
3
- import { listDeployApps } from "../lib/deploy-apps.js";
3
+ import { findDeployApp } from "../lib/deploy-apps.js";
4
4
  import { DEFAULT_HQ_ROOT, ensureCognitoToken } from "../utils/cognito-session.js";
5
5
  import { getCompanyUid, looksLikeCompanyUid } from "../utils/vault-api.js";
6
6
  import { displayText, safeJson } from "./deploy-comments.js";
@@ -140,25 +140,18 @@ async function readJson(response) {
140
140
  async function resolveApp(token, slug, app) {
141
141
  if (/^app_[A-Za-z0-9_-]+$/.test(app))
142
142
  return { id: app, record: null };
143
- const apps = await listDeployApps(async (cursor) => {
144
- const route = cursor ? `/api/apps?cursor=${encodeURIComponent(cursor)}` : "/api/apps";
143
+ const match = await findDeployApp(app, async (route) => {
145
144
  const response = await request(token, slug, route, "GET");
146
145
  if (!response.ok)
147
146
  throw await errorFor(response, slug, "list deploy apps");
148
147
  return readJson(response);
149
148
  });
150
- const needle = app.toLowerCase();
151
- const matches = apps
152
- .filter((item) => typeof item === "object" && item !== null)
153
- .filter((item) => [item.id, item.subdomain, item.name].some((field) => typeof field === "string" && field.toLowerCase() === needle));
154
- const ids = [...new Set(matches.map((item) => str(item.id)).filter((id) => id !== null))];
155
- if (ids.length === 0)
149
+ if (match.kind === "none")
156
150
  throw new DeployAccessError(`No deploy app '${displayText(app)}' in '${slug}'.`);
157
- if (ids.length > 1) {
158
- throw new DeployAccessError(`'${displayText(app)}' matches ${ids.length} apps in '${slug}'. Use the app id.`);
151
+ if (match.kind === "many") {
152
+ throw new DeployAccessError(`'${displayText(app)}' matches ${match.ids.length} apps in '${slug}'. Use the app id.`);
159
153
  }
160
- const id = ids[0];
161
- return { id, record: matches.find((item) => item.id === id) ?? null };
154
+ return { id: match.id, record: match.record };
162
155
  }
163
156
  async function resolveAppId(token, slug, app) {
164
157
  return (await resolveApp(token, slug, app)).id;
@@ -1,5 +1,5 @@
1
1
  import { deployApiRequest } from "../lib/deploy-api.js";
2
- import { listDeployApps } from "../lib/deploy-apps.js";
2
+ import { findDeployApp } from "../lib/deploy-apps.js";
3
3
  import { DEFAULT_HQ_ROOT, ensureCognitoToken } from "../utils/cognito-session.js";
4
4
  import { readActiveCompanySlug } from "./skill.js";
5
5
  class DeployCommentsError extends Error {
@@ -51,20 +51,12 @@ async function deployJson(token, route, orgHeaders) {
51
51
  }
52
52
  }
53
53
  async function resolveAppId(token, appNameOrId, orgHeaders) {
54
- const apps = await listDeployApps((cursor) => {
55
- const route = cursor ? `/api/apps?cursor=${encodeURIComponent(cursor)}` : "/api/apps";
56
- return deployJson(token, route, orgHeaders);
57
- });
58
- const byId = apps.find((app) => app && typeof app.id === "string" && app.id === appNameOrId);
59
- const matches = byId
60
- ? [byId]
61
- : apps.filter((app) => app && typeof app.id === "string" && app.name === appNameOrId);
62
- const ids = [...new Set(matches.map((app) => app.id).filter((id) => typeof id === "string"))];
63
- if (ids.length === 0)
54
+ const match = await findDeployApp(appNameOrId, (route) => deployJson(token, route, orgHeaders));
55
+ if (match.kind === "none")
64
56
  throw new DeployCommentsError("App was not found in the current org.");
65
- if (ids.length > 1)
57
+ if (match.kind === "many")
66
58
  throw new DeployCommentsError("More than one app has that name in the current org; use its app id.");
67
- return ids[0];
59
+ return match.id;
68
60
  }
69
61
  async function listComments(token, appId, orgHeaders) {
70
62
  const route = `/api/apps/${encodeURIComponent(appId)}/manage/comments`;
@@ -4,7 +4,7 @@ import * as path from "node:path";
4
4
  import { createInterface } from "node:readline/promises";
5
5
  import { domainToASCII } from "node:url";
6
6
  import { deployApiRequest } from "../lib/deploy-api.js";
7
- import { listDeployApps } from "../lib/deploy-apps.js";
7
+ import { findDeployApp } from "../lib/deploy-apps.js";
8
8
  import { DEFAULT_HQ_ROOT, ensureCognitoToken } from "../utils/cognito-session.js";
9
9
  import { getCompanyUid, vaultApiFetch, vaultApiFetchPublic } from "../utils/vault-api.js";
10
10
  import { displayText, safeJson } from "./deploy-comments.js";
@@ -288,25 +288,18 @@ async function request(token, orgSlug, route, method, body) {
288
288
  async function resolveAppId(token, orgSlug, app) {
289
289
  if (APP_ID_PATTERN.test(app))
290
290
  return app;
291
- const apps = await listDeployApps(async (cursor) => {
292
- const route = cursor ? `/api/apps?cursor=${encodeURIComponent(cursor)}` : "/api/apps";
291
+ const match = await findDeployApp(app, async (route) => {
293
292
  const response = await request(token, orgSlug, route, "GET");
294
293
  if (!response.ok)
295
294
  throw await deployError(response, orgSlug);
296
295
  return readBody(response);
297
296
  });
298
- const needle = app.toLowerCase();
299
- const ids = [...new Set(apps
300
- .filter((item) => typeof item === "object" && item !== null)
301
- .filter((item) => [item.id, item.subdomain, item.name].some((field) => typeof field === "string" && field.toLowerCase() === needle))
302
- .map((item) => item.id)
303
- .filter((id) => typeof id === "string"))];
304
- if (ids.length === 0)
297
+ if (match.kind === "none")
305
298
  throw new DeployDomainsError(`No deploy app '${displayText(app)}' in '${orgSlug}'.`, "APP_NOT_FOUND");
306
- if (ids.length > 1) {
307
- throw new DeployDomainsError(`'${displayText(app)}' matches ${ids.length} apps in '${orgSlug}'. Use the app id.`, "APP_AMBIGUOUS");
299
+ if (match.kind === "many") {
300
+ throw new DeployDomainsError(`'${displayText(app)}' matches ${match.ids.length} apps in '${orgSlug}'. Use the app id.`, "APP_AMBIGUOUS");
308
301
  }
309
- return ids[0];
302
+ return match.id;
310
303
  }
311
304
  async function resolveTarget(token, options) {
312
305
  if (options.app) {
@@ -57,32 +57,45 @@ export function matchesQuery(app, query) {
57
57
  const needle = query.toLowerCase();
58
58
  return [app.name, app.subdomain, app.title].some((field) => field?.toLowerCase().includes(needle) ?? false);
59
59
  }
60
- async function responseError(response, slug) {
60
+ /** --personal lists the caller's personal deploy scope; otherwise one company. */
61
+ function resolveScope(options) {
62
+ if (options.personal) {
63
+ if (options.company !== undefined)
64
+ throw new DeployListError("Choose one of --company <slug> or --personal.");
65
+ return { label: "your personal scope", company: null, headers: { "X-HQ-Deploy-Scope": "personal" } };
66
+ }
67
+ const slug = resolveCompany(options.company);
68
+ return { label: `'${slug}'`, company: slug, headers: { "X-Org-Slug": slug } };
69
+ }
70
+ async function responseError(response, scope) {
61
71
  const body = await response.json().catch(() => ({}));
62
72
  const raw = body.error?.code;
63
73
  const code = typeof raw === "string" && /^[A-Z0-9_]+$/.test(raw) ? raw : `HTTP_${response.status}`;
64
74
  if (response.status === 401) {
65
75
  return new DeployListError(`hq-deploy rejected your sign-in. Run 'hq login' and retry. (${code})`);
66
76
  }
77
+ if (scope.company === null) {
78
+ return new DeployListError(`Could not list your personal deploy apps (HTTP ${response.status}, ${code}).`);
79
+ }
67
80
  if (response.status === 403) {
68
- return new DeployListError(`Company '${slug}' was not found in hq-deploy, or you do not have access to it. (${code})`);
81
+ return new DeployListError(`Company '${scope.company}' was not found in hq-deploy, or you do not have access to it. (${code})`);
69
82
  }
70
83
  if (response.status === 404) {
71
- return new DeployListError(`Company '${slug}' was not found in hq-deploy. (${code})`);
84
+ return new DeployListError(`Company '${scope.company}' was not found in hq-deploy. (${code})`);
72
85
  }
73
86
  return new DeployListError(`Could not list deploy apps (HTTP ${response.status}, ${code}).`);
74
87
  }
75
- async function fetchPage(token, slug, cursor) {
88
+ async function fetchPage(token, scope, cursor) {
76
89
  const route = cursor ? `/api/apps?cursor=${encodeURIComponent(cursor)}` : "/api/apps";
77
90
  let response;
78
91
  try {
79
- response = await deployApiRequest(token, route, "GET", undefined, { "X-Org-Slug": slug });
92
+ response = await deployApiRequest(token, route, "GET", undefined, scope.headers);
80
93
  }
81
94
  catch {
82
95
  throw new DeployListError("Could not reach hq-deploy.");
83
96
  }
84
97
  if (!response.ok)
85
- throw await responseError(response, slug);
98
+ throw await responseError(response, scope);
86
99
  try {
87
100
  return await response.json();
88
101
  }
@@ -101,11 +114,11 @@ function printApp(app) {
101
114
  ].join(" | "));
102
115
  }
103
116
  async function listAction(query, options) {
104
- const slug = resolveCompany(options.company);
117
+ const scope = resolveScope(options);
105
118
  const token = await ensureCognitoToken();
106
119
  let raw;
107
120
  try {
108
- raw = await listDeployApps((cursor) => fetchPage(token, slug, cursor));
121
+ raw = await listDeployApps((cursor) => fetchPage(token, scope, cursor));
109
122
  }
110
123
  catch (error) {
111
124
  if (error instanceof DeployListError)
@@ -117,15 +130,15 @@ async function listAction(query, options) {
117
130
  .map(summarizeApp)
118
131
  .filter((app) => matchesQuery(app, query));
119
132
  if (options.json) {
120
- console.log(safeJson({ company: slug, query: query ?? null, apps }));
133
+ console.log(safeJson({ company: scope.company, ...(scope.company === null ? { scope: "personal" } : {}), query: query ?? null, apps }));
121
134
  return;
122
135
  }
123
136
  if (apps.length === 0) {
124
137
  if (query) {
125
- console.log(`No deploy apps in '${slug}' matched '${displayText(query)}'.`);
138
+ console.log(`No deploy apps in ${scope.label} matched '${displayText(query)}'.`);
126
139
  }
127
140
  else {
128
- console.log(`hq-deploy returned no apps for '${slug}'.`);
141
+ console.log(`hq-deploy returned no apps for ${scope.label}.`);
129
142
  console.log("Hint: this list can come back empty while the org still has apps. "
130
143
  + "Check the HQ console before concluding none exist.");
131
144
  }
@@ -139,6 +152,7 @@ export function registerDeployListCommand(deploy) {
139
152
  .command("list [query]")
140
153
  .description("List deploy apps in your company, optionally filtered by name or subdomain")
141
154
  .option("--company <slug>", "use this company instead of the active company")
155
+ .option("--personal", "list your personal deploy scope instead of a company")
142
156
  .option("--json", "print the matching apps as JSON")
143
157
  .action(async (query, options) => {
144
158
  try {
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function registerDeployMutationsCommand(deploy: Command): void;
3
+ //# sourceMappingURL=deploy-mutations.d.ts.map