@indigoai-us/hq-cli 5.345.230 → 5.345.232

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 (106) hide show
  1. package/CHANGELOG.md +54 -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-pipeline-conductor-command.js +1 -1
  13. package/dist/commands/core-pipeline-conductor-native.js +5 -5
  14. package/dist/commands/core-pipeline-driver-native.js +5 -5
  15. package/dist/commands/crm.js +2 -1
  16. package/dist/commands/daemon.js +7 -36
  17. package/dist/commands/deploy-access.js +6 -13
  18. package/dist/commands/deploy-comments.js +5 -13
  19. package/dist/commands/deploy-domains.js +6 -13
  20. package/dist/commands/deploy-list.js +25 -11
  21. package/dist/commands/deploy-mutations.d.ts +3 -0
  22. package/dist/commands/deploy-mutations.js +147 -0
  23. package/dist/commands/link.js +29 -0
  24. package/dist/commands/mesh.js +3 -1
  25. package/dist/commands/packs.js +3 -2
  26. package/dist/commands/pkg-remove.js +2 -1
  27. package/dist/commands/report.js +12 -9
  28. package/dist/data/command-states.json +10 -7
  29. package/dist/lib/bot/fleet-bots-update-pass.d.ts +8 -0
  30. package/dist/lib/bot/fleet-bots-update-pass.js +40 -0
  31. package/dist/lib/bot/fleet-bots-update-task.d.ts +12 -0
  32. package/dist/lib/bot/fleet-bots-update-task.js +52 -0
  33. package/dist/lib/bot/fleet-bots-update-worker-v1.d.ts +2 -0
  34. package/dist/lib/bot/fleet-bots-update-worker-v1.js +5 -0
  35. package/dist/lib/daemon/catalog.d.ts +8 -5
  36. package/dist/lib/daemon/catalog.js +15 -8
  37. package/dist/lib/daemon/hook-requests-codex-settings.d.ts +26 -0
  38. package/dist/lib/daemon/hook-requests-codex-settings.js +185 -0
  39. package/dist/lib/daemon/hook-requests-conduct-link.d.ts +1 -0
  40. package/dist/lib/daemon/hook-requests-conduct-link.js +21 -4
  41. package/dist/lib/daemon/hook-requests.d.ts +3 -2
  42. package/dist/lib/daemon/hook-requests.js +16 -3
  43. package/dist/lib/daemon/lock.js +33 -37
  44. package/dist/lib/daemon/ops/skill-command.d.ts +99 -0
  45. package/dist/lib/daemon/ops/skill-command.js +260 -0
  46. package/dist/lib/daemon/protocol.d.ts +1 -1
  47. package/dist/lib/daemon/protocol.js +1 -0
  48. package/dist/lib/daemon/run.js +10 -18
  49. package/dist/lib/daemon/server.js +7 -0
  50. package/dist/lib/daemon/supervisor.d.ts +5 -0
  51. package/dist/lib/daemon/supervisor.js +17 -2
  52. package/dist/lib/db/app-ref.js +10 -15
  53. package/dist/lib/deploy-apps.d.ts +29 -0
  54. package/dist/lib/deploy-apps.js +37 -0
  55. package/dist/lib/doctor/checks/search-index.d.ts +16 -0
  56. package/dist/lib/doctor/checks/search-index.js +61 -0
  57. package/dist/lib/doctor/checks/stranded-lanes.js +1 -1
  58. package/dist/lib/doctor/registry.js +4 -0
  59. package/dist/lib/flag-registry.d.ts +7 -0
  60. package/dist/lib/flag-registry.js +20 -0
  61. package/dist/lib/hook-engine/coverage.d.ts +18 -0
  62. package/dist/lib/hook-engine/coverage.js +42 -1
  63. package/dist/lib/lanes/accounts.js +3 -3
  64. package/dist/lib/lanes/admission-host.js +1 -1
  65. package/dist/lib/lanes/admission.js +4 -4
  66. package/dist/lib/lanes/autopilot.js +2 -2
  67. package/dist/lib/lanes/blocker-freshness.js +1 -1
  68. package/dist/lib/lanes/compaction.js +5 -5
  69. package/dist/lib/lanes/delivery.js +1 -1
  70. package/dist/lib/lanes/depth-cap.js +1 -1
  71. package/dist/lib/lanes/disk-guard.js +1 -1
  72. package/dist/lib/lanes/dropbox.js +1 -1
  73. package/dist/lib/lanes/hooks-install.js +1 -1
  74. package/dist/lib/lanes/imported-question.js +1 -1
  75. package/dist/lib/lanes/keep-alive.d.ts +2 -2
  76. package/dist/lib/lanes/keep-alive.js +3 -3
  77. package/dist/lib/lanes/kr-freshness.js +1 -1
  78. package/dist/lib/lanes/links.js +92 -11
  79. package/dist/lib/lanes/loop.js +2 -2
  80. package/dist/lib/lanes/machine-identity.js +3 -3
  81. package/dist/lib/lanes/models.js +6 -6
  82. package/dist/lib/lanes/quota.js +1 -1
  83. package/dist/lib/lanes/reconcile-install.js +3 -3
  84. package/dist/lib/lanes/reconcile.js +16 -16
  85. package/dist/lib/lanes/remote-control-lane.js +6 -6
  86. package/dist/lib/lanes/reviews.js +2 -2
  87. package/dist/lib/lanes/spawn.js +24 -24
  88. package/dist/lib/lanes/status-fields.js +4 -4
  89. package/dist/lib/lanes/wait.js +4 -4
  90. package/dist/lib/lanes/watch.js +2 -2
  91. package/dist/lib/lanes/watcher-main.js +1 -1
  92. package/dist/lib/lanes/watcher.js +38 -38
  93. package/dist/lib/lanes/worker-process.js +5 -5
  94. package/dist/lib/mesh/live/daemon/pid-lock.d.ts +2 -4
  95. package/dist/lib/mesh/live/daemon/pid-lock.js +38 -55
  96. package/dist/utils/exclusive-lock.d.ts +60 -0
  97. package/dist/utils/exclusive-lock.js +65 -0
  98. package/dist/utils/exit-after-worker.d.ts +7 -0
  99. package/dist/utils/exit-after-worker.js +15 -0
  100. package/package.json +8 -7
  101. package/dist/commands/staff/listings.d.ts +0 -41
  102. package/dist/commands/staff/listings.js +0 -160
  103. package/dist/commands/staff/reset-test-account.d.ts +0 -121
  104. package/dist/commands/staff/reset-test-account.js +0 -285
  105. package/dist/commands/staff/test-account.d.ts +0 -51
  106. package/dist/commands/staff/test-account.js +0 -196
@@ -0,0 +1,147 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readFile } from "node:fs/promises";
3
+ import { deployApiRequest } from "../lib/deploy-api.js";
4
+ import { ensureCognitoToken } from "../utils/cognito-session.js";
5
+ import { displayText } from "./deploy-comments.js";
6
+ class DeployMutationError extends Error {
7
+ }
8
+ function headers(options) {
9
+ if (Boolean(options.company) === Boolean(options.personal))
10
+ throw new DeployMutationError("Choose exactly one of --company <slug> or --personal.");
11
+ if (options.company && !/^[a-z0-9][a-z0-9-]{0,62}$/.test(options.company))
12
+ throw new DeployMutationError("Invalid company slug.");
13
+ return options.company ? { "X-Org-Slug": options.company } : { "X-HQ-Deploy-Scope": "personal" };
14
+ }
15
+ function id(value) {
16
+ if (!/^[A-Za-z0-9_-]+$/.test(value))
17
+ throw new DeployMutationError("Invalid app or deployment identifier.");
18
+ return encodeURIComponent(value);
19
+ }
20
+ async function signIn() {
21
+ try {
22
+ return await ensureCognitoToken();
23
+ }
24
+ catch {
25
+ throw new DeployMutationError("Could not get an HQ sign-in for hq-deploy. Run hq login and retry.");
26
+ }
27
+ }
28
+ async function readLocal(path, what) {
29
+ try {
30
+ return await readFile(path);
31
+ }
32
+ catch {
33
+ throw new DeployMutationError(`Could not read the ${what} at ${path}. Nothing was sent.`);
34
+ }
35
+ }
36
+ async function request(token, route, method, body, scope) {
37
+ let response;
38
+ try {
39
+ response = await deployApiRequest(token, route, method, body, scope);
40
+ }
41
+ catch {
42
+ throw new DeployMutationError("Could not reach hq-deploy. Retry the operation.");
43
+ }
44
+ if (!response.ok) {
45
+ if (response.status === 401)
46
+ throw new DeployMutationError("hq-deploy rejected your sign-in. Run hq login and retry.");
47
+ throw new DeployMutationError(`hq-deploy rejected the operation (HTTP ${response.status}).`);
48
+ }
49
+ if (response.status === 204)
50
+ return {};
51
+ try {
52
+ return await response.json();
53
+ }
54
+ catch {
55
+ throw new DeployMutationError("hq-deploy returned an invalid response.");
56
+ }
57
+ }
58
+ function requiredText(record, key) {
59
+ if (typeof record[key] !== "string" || !record[key])
60
+ throw new DeployMutationError(`hq-deploy response is missing ${key}.`);
61
+ return record[key];
62
+ }
63
+ function output(value, options, text = "Deploy operation completed.") {
64
+ console.log(options.json ? JSON.stringify(value) : text);
65
+ }
66
+ function scope(command) {
67
+ return command.option("--company <slug>", "company owning the app").option("--personal", "use personal scope").option("--json", "print JSON");
68
+ }
69
+ function action(fn) {
70
+ return async (...args) => {
71
+ try {
72
+ await fn(...args);
73
+ }
74
+ catch (error) {
75
+ console.error(error instanceof DeployMutationError ? error.message : "Deploy operation failed.");
76
+ process.exitCode = 1;
77
+ }
78
+ };
79
+ }
80
+ export function registerDeployMutationsCommand(deploy) {
81
+ scope(deploy.command("inspect <app>").description("Read app access mode, password protection and private mode state"))
82
+ .action(action(async (app, options) => {
83
+ const context = headers(options);
84
+ const record = await request(await signIn(), `/api/apps/${id(app)}`, "GET", undefined, context);
85
+ output({ id: app, accessMode: record.accessMode ?? null, passwordProtected: record.passwordProtected === true, privateMode: record.privateMode === true }, options);
86
+ }));
87
+ scope(deploy.command("create <name>").description("Create a deploy app").option("--type <type>", "static, app or ssr", "static"))
88
+ .action(action(async (name, options) => {
89
+ const context = headers(options);
90
+ if (!name.trim() || !["static", "app", "ssr"].includes(options.type))
91
+ throw new DeployMutationError("Provide a name and type static, app or ssr.");
92
+ const created = await request(await signIn(), "/api/apps", "POST", { name, type: options.type }, context);
93
+ const appId = requiredText(created, "id");
94
+ const appUrl = typeof created.url === "string" && created.url ? created.url : "not returned";
95
+ output(created, options, `Created app ${displayText(appId)}. URL: ${displayText(appUrl)}`);
96
+ }));
97
+ scope(deploy.command("takedown <app>").description("Deactivate a deploy app"))
98
+ .action(action(async (app, options) => {
99
+ const context = headers(options);
100
+ await request(await signIn(), `/api/apps/${id(app)}`, "PATCH", { active: false }, context);
101
+ output({ app, active: false }, options);
102
+ }));
103
+ scope(deploy.command("password-gate <app>").description("Set a password gate using a file").requiredOption("--password-file <path>", "file containing the password"))
104
+ .action(action(async (app, options) => {
105
+ const context = headers(options);
106
+ const password = (await readLocal(options.passwordFile, "password file")).toString("utf8").replace(/\r?\n$/, "");
107
+ if (!password || password.length > 4096)
108
+ throw new DeployMutationError("Password file must contain 1–4096 characters.");
109
+ await request(await signIn(), `/api/apps/${id(app)}/access-mode`, "POST", { mode: "password", password }, context);
110
+ output({ app, mode: "password" }, options);
111
+ }));
112
+ scope(deploy.command("private-gate <app>").description("Set a private gate and grant email patterns").option("--email <pattern>", "email pattern to grant", (value, values) => [...values, value], []))
113
+ .action(action(async (app, options) => {
114
+ const context = headers(options);
115
+ const token = await signIn();
116
+ const route = `/api/apps/${id(app)}`;
117
+ await request(token, `${route}/access-mode`, "POST", { mode: "private" }, context);
118
+ for (const email of options.email)
119
+ await request(token, `${route}/allowed-emails`, "POST", { email }, context);
120
+ output({ app, mode: "private" }, options);
121
+ }));
122
+ scope(deploy.command("upload <app> <archive>").description("Upload an existing gzip deployment archive").option("--manifest-org", "include the legacy informational org field in the manifest request"))
123
+ .action(action(async (app, archive, options) => {
124
+ const context = headers(options);
125
+ id(app);
126
+ const bytes = await readLocal(archive, "archive file");
127
+ const token = await signIn();
128
+ const initialized = await request(token, "/api/deploys", "POST", { appSlug: app, ...(options.manifestOrg ? { org: options.company ?? "" } : {}), manifest: { files: [], size: bytes.length, sha256: createHash("sha256").update(bytes).digest("hex") } }, context);
129
+ const deployment = id(requiredText(initialized, "deployId"));
130
+ const signed = new URL(requiredText(initialized, "presignedUrl"));
131
+ if (signed.protocol !== "https:" || signed.username || signed.password)
132
+ throw new DeployMutationError("hq-deploy returned an invalid upload URL.");
133
+ let uploaded;
134
+ try {
135
+ uploaded = await fetch(signed, { method: "PUT", headers: { "Content-Type": "application/gzip" }, body: bytes, redirect: "error", signal: AbortSignal.timeout(30_000) });
136
+ }
137
+ catch {
138
+ throw new DeployMutationError("Archive upload failed. Deployment was not completed.");
139
+ }
140
+ if (!uploaded.ok)
141
+ throw new DeployMutationError(`Archive upload failed (HTTP ${uploaded.status}). Deployment was not completed.`);
142
+ const completed = await request(token, `/api/deploys/${deployment}/complete`, "POST", { appSlug: app }, context);
143
+ const liveUrl = requiredText(completed, "url");
144
+ output({ ...completed, deployId: decodeURIComponent(deployment) }, options, `Deployed app ${displayText(app)} (deployment ${displayText(decodeURIComponent(deployment))}). Live URL: ${displayText(liveUrl)}`);
145
+ }));
146
+ }
147
+ //# sourceMappingURL=deploy-mutations.js.map
@@ -15,6 +15,8 @@ import { createResolver } from "../lib/daemon/resolver.js";
15
15
  import { readCompaniesManifestMap } from "../lib/work-context/repo-remote.js";
16
16
  import { canonicalDir, keyForDir, readRegistry, registryDir, registryFile, removeEntriesForDir, seedFromManifest, setEntry, wouldBindEnclosingRemote, writeRegistry, } from "../lib/registry/registry.js";
17
17
  import { readHqRoot } from "./mcp-serve.js";
18
+ import { resolveCompany as resolveActiveCompany } from "./core-resolve-company-native.js";
19
+ import { resolveLiveRoot } from "../utils/hq-roots.js";
18
20
  async function requireAnywhereRuntime(deps) {
19
21
  if (!(await (deps.runtimeAllowed ?? (() => anywhereRuntimeAllowed()))())) {
20
22
  throw new Error("HQ Anywhere is disabled until both the runtime flag and your person setting are on.");
@@ -172,7 +174,34 @@ export function registerResolveCompanyCommand(program, deps = {}) {
172
174
  .description("Print the HQ company linked to this folder (never guesses)")
173
175
  .option("--path <dir>", "Folder to resolve (default: current directory)")
174
176
  .option("--json", "Print JSON output")
177
+ .option("--prompt <text>", "Resolve the active company for skills and routing: whole-token manifest slug in <text>, then session, then device default; prints JSON and exits 0")
178
+ .option("--root <dir>", "HQ root for --prompt (default: the live HQ root)")
175
179
  .action(async (opts) => {
180
+ if (opts.prompt !== undefined) {
181
+ if (opts.path !== undefined) {
182
+ console.error("hq resolve-company: --prompt and --path cannot be used together");
183
+ process.exitCode = 1;
184
+ return;
185
+ }
186
+ // US-030 c1: one resolver. This is the same function behind
187
+ // `hq core resolve-company --prompt`; it reads no anywhere registry,
188
+ // so it is not behind the anywhere runtime gate.
189
+ let hqRoot;
190
+ try {
191
+ hqRoot = resolveLiveRoot({ hqRoot: opts.root });
192
+ }
193
+ catch (err) {
194
+ fail(err);
195
+ return;
196
+ }
197
+ const result = await resolveActiveCompany(opts.root !== undefined ? ["--root", opts.root, "--prompt", opts.prompt] : ["--prompt", opts.prompt], { cwd: process.cwd(), hqRoot, stdinIsTty: true });
198
+ process.stdout.write(result.stdout);
199
+ if (result.stderr.length)
200
+ process.stderr.write(result.stderr);
201
+ if (result.code !== 0)
202
+ process.exitCode = result.code;
203
+ return;
204
+ }
176
205
  try {
177
206
  await requireAnywhereRuntime(deps);
178
207
  }
@@ -65,6 +65,7 @@ import { requeueQuarantinedOutbox } from "../lib/work-context/outbox.js";
65
65
  import { handOffInstallHere } from "../lib/daemon/handoff.js";
66
66
  import { repairServiceUnitsFromOtherHome } from "../lib/daemon/mesh-owner.js";
67
67
  import { runResidentCommandWithPackageLease } from "../utils/resident-package-preload.js";
68
+ import { exitCli } from "../utils/exit-after-worker.js";
68
69
  export function formatCheckLines(threads, company, projectId) {
69
70
  if (threads.length === 0) {
70
71
  return ["Work mesh: no active project threads found."];
@@ -2801,7 +2802,8 @@ function wrap(action) {
2801
2802
  await action();
2802
2803
  }
2803
2804
  catch (err) {
2804
- fail(err instanceof Error ? err.message : String(err));
2805
+ console.error(chalk.red(err instanceof Error ? err.message : String(err)));
2806
+ return await exitCli(1);
2805
2807
  }
2806
2808
  };
2807
2809
  }
@@ -32,6 +32,7 @@ import { classify, PINNED_HQ_ANYWHERE_SOURCE, resolveLatest, parseMarketplaceSou
32
32
  import { contributionLinks, linkStatus, listInstalledPacks, findDependentPacks, readPackManifest, unwirePack, unwireNamespacedSkills, unwirePackMcp, readHqVersion, readRecommendedPackages, packagesDir, } from '../utils/pack-contributions.js';
33
33
  import { readInstalledPackSetup } from '../lib/packages/setup-block.js';
34
34
  import { syncCodexPackHooks, syncCodexPackSkills } from '../lib/install/codex-pack-contributions.js';
35
+ import { exitCli } from '../utils/exit-after-worker.js';
35
36
  function resolveRoot(opts) {
36
37
  return opts.hqRoot ? path.resolve(opts.hqRoot) : findHqRoot();
37
38
  }
@@ -450,7 +451,7 @@ export function registerPacksListCommand(parent) {
450
451
  }
451
452
  catch (e) {
452
453
  console.error(chalk.red('packs list failed:'), e.message);
453
- process.exit(1);
454
+ await exitCli(1);
454
455
  }
455
456
  });
456
457
  }
@@ -550,7 +551,7 @@ export function registerPacksCommand(parent) {
550
551
  }
551
552
  catch (e) {
552
553
  console.error(chalk.red('packs uninstall failed:'), e.message);
553
- process.exit(1);
554
+ await exitCli(1);
554
555
  }
555
556
  });
556
557
  }
@@ -10,6 +10,7 @@ import * as path from 'path';
10
10
  import chalk from 'chalk';
11
11
  import { resolveDefaultHqRoot } from '../utils/cognito-session.js';
12
12
  import { removeFromRegistry, readRegistry } from '../utils/registry.js';
13
+ import { exitCli } from '../utils/exit-after-worker.js';
13
14
  export function registerPackageRemoveCommand(parent) {
14
15
  parent
15
16
  .command('remove <slug>')
@@ -20,7 +21,7 @@ export function registerPackageRemoveCommand(parent) {
20
21
  }
21
22
  catch (error) {
22
23
  console.error(chalk.red('Remove failed:'), error instanceof Error ? error.message : 'Unknown error');
23
- process.exit(1);
24
+ await exitCli(1);
24
25
  }
25
26
  });
26
27
  }
@@ -6,8 +6,9 @@ import * as path from "node:path";
6
6
  import { ensureCognitoToken, } from "../utils/cognito-session.js";
7
7
  import { vaultApiFetch } from "../utils/vault-api.js";
8
8
  import { DEPLOY_API_URL, deployApiRequest, deployHeaders } from "../lib/deploy-api.js";
9
- import { listDeployApps } from "../lib/deploy-apps.js";
9
+ import { listAllDeployApps, matchDeployApp } from "../lib/deploy-apps.js";
10
10
  import { listReportTemplates } from "../lib/report-templates.js";
11
+ import { stopFlagRegistryWorker } from "../lib/flag-registry.js";
11
12
  import { adoptReport, buildReportTarball, conventionReportDir, deployOrgContext, ReportPublishError, plainFailureReason, publishReport, } from "../lib/report-publish.js";
12
13
  const REPORT_CHANNEL_STATE_FILE = "report-channels.json";
13
14
  const REPORT_UPLOAD_TIMEOUT_MS = 120_000;
@@ -262,16 +263,15 @@ async function orgFor(token, report) {
262
263
  return deployOrgContext(report, slug);
263
264
  }
264
265
  export async function findOrCreateApp(token, slug, org) {
265
- const apps = await listDeployApps((cursor) => {
266
- const route = cursor ? `/api/apps?cursor=${encodeURIComponent(cursor)}` : "/api/apps";
267
- return deployJson(token, route, "GET", undefined, org.headers);
268
- });
269
- const mine = (name) => apps.find((app) => !!app && typeof app === "object" && (app.subdomain === name || app.name === name));
266
+ const apps = await listAllDeployApps((route) => deployJson(token, route, "GET", undefined, org.headers));
270
267
  let app;
271
268
  for (const name of candidateSlugs(slug)) {
272
- const existing = mine(name);
273
- if (existing) {
274
- app = existing;
269
+ const existing = matchDeployApp(apps, name, { exact: true });
270
+ if (existing.kind === "many") {
271
+ throw new ReportPublishError(`More than one hq-deploy app is called '${name}'. Remove the extra app and retry.`);
272
+ }
273
+ if (existing.kind === "found") {
274
+ app = existing.record;
275
275
  break;
276
276
  }
277
277
  try {
@@ -536,6 +536,9 @@ async function runReportCommand(action) {
536
536
  catch (error) {
537
537
  console.error(errorMessage(error));
538
538
  process.exitCode = 1;
539
+ // The CLI still ends through main's normal finish; the flag-registry
540
+ // worker must not be running when it does.
541
+ await stopFlagRegistryWorker();
539
542
  }
540
543
  }
541
544
  //# sourceMappingURL=report.js.map
@@ -27,12 +27,15 @@
27
27
  "report discard-draft": { "state": "retiring" },
28
28
  "report promote": { "state": "retiring" },
29
29
  "report templates": { "state": "retiring" },
30
- "staff listings approve": { "state": "retiring", "replacedBy": "the staff-only hq-staff script outside the public CLI" },
31
- "staff listings queue": { "state": "retiring", "replacedBy": "the staff-only hq-staff script outside the public CLI" },
32
- "staff listings reject": { "state": "retiring", "replacedBy": "the staff-only hq-staff script outside the public CLI" },
33
- "staff reset-test-account": { "state": "retiring", "replacedBy": "the staff-only hq-staff script outside the public CLI" },
34
- "staff test-account add": { "state": "retiring", "replacedBy": "the staff-only hq-staff script outside the public CLI" },
35
- "staff test-account list": { "state": "retiring", "replacedBy": "the staff-only hq-staff script outside the public CLI" },
36
- "staff test-account remove": { "state": "retiring", "replacedBy": "the staff-only hq-staff script outside the public CLI" }
30
+ "staff": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
31
+ "staff listings": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
32
+ "staff listings approve": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
33
+ "staff listings queue": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
34
+ "staff listings reject": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
35
+ "staff reset-test-account": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
36
+ "staff test-account": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
37
+ "staff test-account add": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
38
+ "staff test-account list": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
39
+ "staff test-account remove": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" }
37
40
  }
38
41
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * One fleet-bots-update pass: move each installed HQ Fleet bot to the current
3
+ * runtime release while it is idle, and restart it. Shared by
4
+ * `hq daemon service fleet-bots-update` and the daemon's internal task, so the
5
+ * update eligibility and the update steps are the same code on both paths.
6
+ */
7
+ export declare function runInstalledFleetBotsUpdate(log: (line: string) => void): Promise<void>;
8
+ //# sourceMappingURL=fleet-bots-update-pass.d.ts.map
@@ -0,0 +1,40 @@
1
+ /**
2
+ * One fleet-bots-update pass: move each installed HQ Fleet bot to the current
3
+ * runtime release while it is idle, and restart it. Shared by
4
+ * `hq daemon service fleet-bots-update` and the daemon's internal task, so the
5
+ * update eligibility and the update steps are the same code on both paths.
6
+ */
7
+ export async function runInstalledFleetBotsUpdate(log) {
8
+ const [{ runFleetBotsUpdate, listFleetBots }, local, bot, { botsRoot }, { hasPromotionHold }] = await Promise.all([
9
+ import("./fleet-watch.js"),
10
+ import("./fleet-local.js"),
11
+ import("../../commands/bot.js"),
12
+ import("./paths.js"),
13
+ import("./promotion-hold.js"),
14
+ ]);
15
+ const alive = (pid) => {
16
+ try {
17
+ process.kill(pid, 0);
18
+ return true;
19
+ }
20
+ catch (error) {
21
+ return error.code === "EPERM";
22
+ }
23
+ };
24
+ await runFleetBotsUpdate({
25
+ listBots: () => listFleetBots(botsRoot()),
26
+ target: () => local.resolveFleetLocalPointerTarget(),
27
+ installed: (b) => {
28
+ if (b.config.enabled === false)
29
+ return false;
30
+ const pid = local.fleetLocalGatewayPid(b.config.agentUid);
31
+ return pid !== null && alive(pid);
32
+ },
33
+ heldForPromotion: (b) => hasPromotionHold(b.dir),
34
+ needsAdoption: (b, release) => local.fleetLocalProfileNeedsAdoption(b.config.agentUid, { release }),
35
+ busy: (b) => local.fleetLocalBusyReason(b.config.agentUid),
36
+ update: (b) => bot.updateFleetRuntimeBot(b.name, { busy: () => local.fleetLocalBusyReason(b.config.agentUid) }),
37
+ log,
38
+ });
39
+ }
40
+ //# sourceMappingURL=fleet-bots-update-pass.js.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Run one fleet-bots-update pass for the daemon without starting a process.
3
+ * The pass runs on a worker thread, so its synchronous runtime helper calls
4
+ * stay off the supervisor thread and anything it throws (or a crash of the
5
+ * thread) ends only this pass: the promise resolves false or rejects, and the
6
+ * supervisor records the run as failed. Resolves true when the pass finished.
7
+ */
8
+ export declare function runFleetBotsUpdateWorker(options: {
9
+ env: NodeJS.ProcessEnv;
10
+ log: (line: string) => void;
11
+ }, entry?: URL): Promise<boolean>;
12
+ //# sourceMappingURL=fleet-bots-update-task.d.ts.map
@@ -0,0 +1,52 @@
1
+ import { Worker } from "node:worker_threads";
2
+ // The pass itself (runInstalledFleetBotsUpdate) lives in fleet-bots-update-pass.ts,
3
+ // so the supervisor, which imports this module, reaches no lazy package import.
4
+ const fleetBotsUpdateWorkerEntry = new URL("./fleet-bots-update-worker-v1.js", import.meta.url);
5
+ /**
6
+ * Run one fleet-bots-update pass for the daemon without starting a process.
7
+ * The pass runs on a worker thread, so its synchronous runtime helper calls
8
+ * stay off the supervisor thread and anything it throws (or a crash of the
9
+ * thread) ends only this pass: the promise resolves false or rejects, and the
10
+ * supervisor records the run as failed. Resolves true when the pass finished.
11
+ */
12
+ export function runFleetBotsUpdateWorker(options, entry = fleetBotsUpdateWorkerEntry) {
13
+ return new Promise((resolve, reject) => {
14
+ let worker;
15
+ try {
16
+ worker = new Worker(entry, { env: options.env, stdout: true, stderr: true });
17
+ }
18
+ catch (error) {
19
+ reject(error);
20
+ return;
21
+ }
22
+ let failure;
23
+ const lines = (stream) => {
24
+ let rest = "";
25
+ stream.setEncoding("utf8");
26
+ stream.on("data", (chunk) => {
27
+ const parts = (rest + chunk).split("\n");
28
+ rest = parts.pop() ?? "";
29
+ for (const line of parts)
30
+ if (line)
31
+ options.log(line);
32
+ });
33
+ stream.on("end", () => {
34
+ if (rest)
35
+ options.log(rest);
36
+ rest = "";
37
+ });
38
+ };
39
+ lines(worker.stdout);
40
+ lines(worker.stderr);
41
+ worker.once("error", (err) => {
42
+ failure ??= err;
43
+ });
44
+ worker.once("exit", (code) => {
45
+ if (failure)
46
+ reject(failure);
47
+ else
48
+ resolve(code === 0);
49
+ });
50
+ });
51
+ }
52
+ //# sourceMappingURL=fleet-bots-update-task.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=fleet-bots-update-worker-v1.d.ts.map
@@ -0,0 +1,5 @@
1
+ // Worker-thread entry for the daemon's fleet-bots-update internal task.
2
+ // It starts no process of its own; see runFleetBotsUpdateWorker.
3
+ import { runInstalledFleetBotsUpdate } from "./fleet-bots-update-pass.js";
4
+ await runInstalledFleetBotsUpdate((line) => console.log(line));
5
+ //# sourceMappingURL=fleet-bots-update-worker-v1.js.map
@@ -47,11 +47,14 @@ type UnitCommand = {
47
47
  task: "search-index";
48
48
  };
49
49
  /** Work the daemon does in its own process on a schedule, without starting a child. */
50
- export type InternalTask = "rotate-logs" | "lanes-reconcile";
51
- /** Compatibility path for installations that do not contain the versioned worker. */
52
- export declare function legacySearchIndexCommand(root: string | undefined): Extract<UnitCommand, {
53
- type: "hq";
54
- }>;
50
+ export type InternalTask = "rotate-logs" | "lanes-reconcile" | "fleet-bots-update";
51
+ /**
52
+ * Why the daemon schedules no search-index pass. The timer never starts `hq`
53
+ * (hq-core-rust US-051): when the in-process worker cannot run, the unit is
54
+ * planned unavailable with this reason, which `hq daemon status` and
55
+ * `hq doctor` show. `hq index sync` still works by hand.
56
+ */
57
+ export declare const SEARCH_INDEX_WORKER_UNAVAILABLE: string;
55
58
  interface UnitBlock {
56
59
  /** `waiting` clears when requirements appear; `unavailable` needs a newer CLI; `paused` needs an explicit resume. */
57
60
  state: "waiting" | "unavailable" | "paused";
@@ -93,10 +93,14 @@ export function enabledServices(machineType, overrides) {
93
93
  };
94
94
  return SERVICE_NAMES.filter((s) => wanted(s) || implied(s));
95
95
  }
96
- /** Compatibility path for installations that do not contain the versioned worker. */
97
- export function legacySearchIndexCommand(root) {
98
- return { type: "hq", args: ["index", "sync", "--hq-root", root ?? ""] };
99
- }
96
+ /**
97
+ * Why the daemon schedules no search-index pass. The timer never starts `hq`
98
+ * (hq-core-rust US-051): when the in-process worker cannot run, the unit is
99
+ * planned unavailable with this reason, which `hq daemon status` and
100
+ * `hq doctor` show. `hq index sync` still works by hand.
101
+ */
102
+ export const SEARCH_INDEX_WORKER_UNAVAILABLE = "this daemon cannot run the search index worker (the installed CLI has no worker, or the daemon could not hand its package lease to it), " +
103
+ "so it does not refresh the HQ search index on a timer; restart the daemon (`hq daemon restart --daemon`) or run `hq index sync` by hand";
100
104
  export const FLEET_BOT_STOP_GRACE_MS = 30_000;
101
105
  export const FLEET_BOTS_UPDATE_UNIT = "fleet-bots-update";
102
106
  export const FLEET_BOTS_UPDATE_INTERVAL_SEC = 30 * 60;
@@ -378,7 +382,9 @@ function planService(service, ctx) {
378
382
  kind: "scheduled",
379
383
  intervalSec: FLEET_BOTS_UPDATE_INTERVAL_SEC,
380
384
  initialDelaySec: FLEET_BOTS_UPDATE_INITIAL_DELAY_SEC,
381
- command: { type: "hq", args: ["daemon", "service", "fleet-bots-update"] },
385
+ // Runs in the daemon's own process (on a worker thread) instead of
386
+ // starting a fresh `hq` every 30 minutes (hq-core-rust US-051).
387
+ command: { type: "internal", task: "fleet-bots-update" },
382
388
  env: { HQ_NO_UPDATE_CHECK: "1" },
383
389
  blocked: firstBlock([[!ctx.signedIn, NOT_SIGNED_IN]]),
384
390
  }),
@@ -459,14 +465,15 @@ function planService(service, ctx) {
459
465
  case "search-index":
460
466
  if (ctx.searchIndexOwnedBySyncRunner)
461
467
  return [];
468
+ // No `hq index sync` fallback: the timer never starts hq (US-051).
469
+ if (ctx.searchIndexWorkerAvailable === false)
470
+ return [unavailable(service, SEARCH_INDEX_WORKER_UNAVAILABLE)];
462
471
  return [
463
472
  base(service, {
464
473
  kind: "scheduled",
465
474
  intervalSec: 900,
466
475
  initialDelaySec: 120,
467
- command: ctx.searchIndexWorkerAvailable === false
468
- ? legacySearchIndexCommand(ctx.hqRoot)
469
- : { type: "worker", task: "search-index" },
476
+ command: { type: "worker", task: "search-index" },
470
477
  env: ctx.hqRoot ? { HQ_ROOT: ctx.hqRoot } : {},
471
478
  // A full qmd pass rereads every indexed file; at default priority it
472
479
  // got HQ listed under macOS "Using Significant Energy".
@@ -0,0 +1,26 @@
1
+ import { type FleetLocalSettingsCommand, type HookRequest, type HookRequestResult } from "./hook-requests.js";
2
+ export type CodexSettingsOperation = {
3
+ kind: "codex-settings";
4
+ event: "PostToolUse";
5
+ commands: FleetLocalSettingsCommand[];
6
+ };
7
+ /** What the released Codex adapter exported for the hooks it started (v16.0.47 adapter lines 5, 86-100). */
8
+ export declare const CODEX_SETTINGS_RUNTIME = "codex";
9
+ /** The args of a `codex-settings` note: exactly `event` (PostToolUse) and 1 to 64 typed commands. Anything else: refused. */
10
+ export declare function parseCodexSettings(kind: unknown, args: Record<string, unknown>): CodexSettingsOperation | undefined;
11
+ /** The environment the released Codex adapter gave its settings hooks, over the daemon's own. */
12
+ export declare function codexSettingsEnv(base: NodeJS.ProcessEnv, root: string, session: string, id: string): NodeJS.ProcessEnv;
13
+ /**
14
+ * Run the commands of a `codex-settings` note in order. Before any starts, the root's settings file is read again: a
15
+ * command runs only if it is still listed there for the note's event and every file it starts resolves to a real path
16
+ * under the HQ root. A refused command is not started, is logged, and does not stop the rest. A command still running
17
+ * at the limit is ended with its process group and the commands after it are skipped.
18
+ */
19
+ export declare function runCodexSettings(request: HookRequest, operation: CodexSettingsOperation, options: {
20
+ env?: NodeJS.ProcessEnv;
21
+ signal?: AbortSignal;
22
+ timeoutMs: number;
23
+ killGraceMs: number;
24
+ log?: (message: string) => void;
25
+ }): Promise<HookRequestResult>;
26
+ //# sourceMappingURL=hook-requests-codex-settings.d.ts.map