@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
@@ -4,7 +4,7 @@
4
4
  * searched, so a name never resolves to another company's app.
5
5
  */
6
6
  import { deployApiRequest } from "../deploy-api.js";
7
- import { listDeployApps } from "../deploy-apps.js";
7
+ import { findDeployApp, matchDeployApp } from "../deploy-apps.js";
8
8
  export class AppRefError extends Error {
9
9
  constructor(message) {
10
10
  super(message);
@@ -13,17 +13,13 @@ export class AppRefError extends Error {
13
13
  }
14
14
  const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
15
15
  export function matchAppRef(apps, ref) {
16
- const ids = (rows) => [
17
- ...new Set(rows.map((row) => row.id).filter((id) => typeof id === "string")),
18
- ];
19
- const byId = ids(apps.filter((row) => row.id === ref));
20
- if (byId.length === 1)
21
- return byId[0];
22
- const byName = ids(apps.filter((row) => row.name === ref || row.subdomain === ref));
23
- if (byName.length === 1)
24
- return byName[0];
25
- if (byName.length > 1) {
26
- throw new AppRefError(`More than one app in this company is called "${ref}" (${byName.join(", ")}). Use the app id.`);
16
+ return appRefId(matchDeployApp(apps, ref), ref);
17
+ }
18
+ function appRefId(match, ref) {
19
+ if (match.kind === "found")
20
+ return match.id;
21
+ if (match.kind === "many") {
22
+ throw new AppRefError(`More than one app in this company is called "${ref}" (${match.ids.join(", ")}). Use the app id.`);
27
23
  }
28
24
  throw new AppRefError(`No app called "${ref}" was found in this company.`);
29
25
  }
@@ -32,14 +28,13 @@ export async function resolveAppRef(input, request = deployApiRequest) {
32
28
  if (UUID_RE.test(ref))
33
29
  return ref;
34
30
  const headers = { "X-Org-Slug": input.companySlug };
35
- const apps = await listDeployApps(async (cursor) => {
36
- const route = cursor ? `/api/apps?cursor=${encodeURIComponent(cursor)}` : "/api/apps";
31
+ const match = await findDeployApp(ref, async (route) => {
37
32
  const res = await request(input.token, route, "GET", undefined, headers);
38
33
  if (!res.ok) {
39
34
  throw new AppRefError(`Could not look up the app "${ref}" (hq-deploy returned ${res.status}). Use the app id.`);
40
35
  }
41
36
  return (await res.json());
42
37
  });
43
- return matchAppRef(apps, ref);
38
+ return appRefId(match, ref);
44
39
  }
45
40
  //# sourceMappingURL=app-ref.js.map
@@ -10,4 +10,33 @@ export interface DeployAppsPage<T> {
10
10
  * bad cursor response from creating an unbounded CLI request loop.
11
11
  */
12
12
  export declare function listDeployApps<T>(fetchPage: (cursor?: string) => Promise<DeployAppsPage<T>>): Promise<T[]>;
13
+ /**
14
+ * Every app in the caller's scope. `getPage` sends GET for the given route with
15
+ * the caller's own headers and error handling, and returns the parsed body.
16
+ */
17
+ export declare function listAllDeployApps<T = unknown>(getPage: (route: string) => Promise<DeployAppsPage<T>>): Promise<T[]>;
18
+ export type DeployAppMatch = {
19
+ kind: "found";
20
+ id: string;
21
+ record: Record<string, unknown>;
22
+ } | {
23
+ kind: "none";
24
+ } | {
25
+ kind: "many";
26
+ ids: string[];
27
+ };
28
+ /**
29
+ * The one rule the CLI uses to turn an app id, subdomain or name into an app:
30
+ * equal to the row's id, subdomain or name, ignoring case. A value that fits
31
+ * more than one app is refused (the caller asks for the app id).
32
+ *
33
+ * `exact` is for write paths that reuse an app by its own slug (report
34
+ * publishing): only a subdomain or name equal to the value, case included,
35
+ * fits; the id never does.
36
+ */
37
+ export declare function matchDeployApp(apps: readonly unknown[], ref: string, options?: {
38
+ exact?: boolean;
39
+ }): DeployAppMatch;
40
+ /** List the caller's apps and match `ref` against them (see matchDeployApp). */
41
+ export declare function findDeployApp(ref: string, getPage: (route: string) => Promise<DeployAppsPage<unknown>>): Promise<DeployAppMatch>;
13
42
  //# sourceMappingURL=deploy-apps.d.ts.map
@@ -26,4 +26,41 @@ export async function listDeployApps(fetchPage) {
26
26
  }
27
27
  throw new Error(`hq-deploy apps list exceeded the ${MAX_DEPLOY_APPS_PAGES}-page safety cap.`);
28
28
  }
29
+ /** The route for one page of GET /api/apps. */
30
+ function appsRoute(cursor) {
31
+ return cursor ? `/api/apps?cursor=${encodeURIComponent(cursor)}` : "/api/apps";
32
+ }
33
+ /**
34
+ * Every app in the caller's scope. `getPage` sends GET for the given route with
35
+ * the caller's own headers and error handling, and returns the parsed body.
36
+ */
37
+ export function listAllDeployApps(getPage) {
38
+ return listDeployApps((cursor) => getPage(appsRoute(cursor)));
39
+ }
40
+ /**
41
+ * The one rule the CLI uses to turn an app id, subdomain or name into an app:
42
+ * equal to the row's id, subdomain or name, ignoring case. A value that fits
43
+ * more than one app is refused (the caller asks for the app id).
44
+ *
45
+ * `exact` is for write paths that reuse an app by its own slug (report
46
+ * publishing): only a subdomain or name equal to the value, case included,
47
+ * fits; the id never does.
48
+ */
49
+ export function matchDeployApp(apps, ref, options = {}) {
50
+ const needle = options.exact ? ref : ref.toLowerCase();
51
+ const matches = apps
52
+ .filter((row) => typeof row === "object" && row !== null)
53
+ .filter((row) => typeof row.id === "string")
54
+ .filter((row) => (options.exact ? [row.subdomain, row.name] : [row.id, row.subdomain, row.name]).some((field) => typeof field === "string" && (options.exact ? field : field.toLowerCase()) === needle));
55
+ const ids = [...new Set(matches.map((row) => row.id))];
56
+ if (ids.length === 0)
57
+ return { kind: "none" };
58
+ if (ids.length > 1)
59
+ return { kind: "many", ids };
60
+ return { kind: "found", id: ids[0], record: matches[0] };
61
+ }
62
+ /** List the caller's apps and match `ref` against them (see matchDeployApp). */
63
+ export async function findDeployApp(ref, getPage) {
64
+ return matchDeployApp(await listAllDeployApps(getPage), ref);
65
+ }
29
66
  //# sourceMappingURL=deploy-apps.js.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Search index schedule: does the daemon refresh the HQ search index?
3
+ *
4
+ * The daemon refreshes the index with an in-process worker on a timer. When
5
+ * the worker cannot run, the timer starts nothing (it never falls back to
6
+ * starting `hq index sync`, hq-core-rust US-051) and the daemon plans the
7
+ * search-index unit as unavailable with a reason. This check reads that unit
8
+ * from the daemon's state file, so the user sees why the index is not being
9
+ * refreshed. It starts no process and makes no network call.
10
+ */
11
+ import type { CheckFamily, CheckResult } from "../types.js";
12
+ export declare const SEARCH_INDEX_FAMILY_ID = "search-index";
13
+ export declare const SEARCH_INDEX_FAMILY_TITLE = "Search index schedule";
14
+ export declare function checkSearchIndexSchedule(env?: NodeJS.ProcessEnv): CheckResult[];
15
+ export declare const searchIndexFamily: CheckFamily;
16
+ //# sourceMappingURL=search-index.d.ts.map
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Search index schedule: does the daemon refresh the HQ search index?
3
+ *
4
+ * The daemon refreshes the index with an in-process worker on a timer. When
5
+ * the worker cannot run, the timer starts nothing (it never falls back to
6
+ * starting `hq index sync`, hq-core-rust US-051) and the daemon plans the
7
+ * search-index unit as unavailable with a reason. This check reads that unit
8
+ * from the daemon's state file, so the user sees why the index is not being
9
+ * refreshed. It starts no process and makes no network call.
10
+ */
11
+ import * as fs from "node:fs";
12
+ import { daemonPaths } from "../../daemon/paths.js";
13
+ export const SEARCH_INDEX_FAMILY_ID = "search-index";
14
+ export const SEARCH_INDEX_FAMILY_TITLE = "Search index schedule";
15
+ const CHECK_ID = "search-index.schedule";
16
+ const UNIT_ID = "search-index";
17
+ export function checkSearchIndexSchedule(env = process.env) {
18
+ const statePath = daemonPaths(env.HOME || env.USERPROFILE || undefined, env).statePath;
19
+ let raw;
20
+ try {
21
+ raw = fs.readFileSync(statePath, "utf8");
22
+ }
23
+ catch (error) {
24
+ if (error.code === "ENOENT") {
25
+ return [{ status: "NA", checkId: CHECK_ID, message: "hq daemon has written no state on this machine, so it schedules no search index refresh." }];
26
+ }
27
+ return [unknown(`could not read the daemon state (${error.code ?? "error"})`)];
28
+ }
29
+ let units;
30
+ try {
31
+ units = JSON.parse(raw).units;
32
+ }
33
+ catch {
34
+ return [unknown("the daemon state file is not valid JSON")];
35
+ }
36
+ if (!Array.isArray(units))
37
+ return [unknown("the daemon state file has no unit list")];
38
+ const unit = units.find((u) => u && typeof u === "object" && u.id === UNIT_ID);
39
+ if (!unit) {
40
+ return [{ status: "NA", checkId: CHECK_ID, message: "hq daemon does not run a search-index unit on this machine (not enabled, or the sync runner indexes)." }];
41
+ }
42
+ if (unit.status === "unavailable") {
43
+ const reason = typeof unit.reason === "string" && unit.reason ? unit.reason : "no reason recorded";
44
+ return [{
45
+ status: "WARN",
46
+ checkId: CHECK_ID,
47
+ message: `The HQ search index is not refreshed on a timer: ${reason}`,
48
+ remediation: "hq daemon restart --daemon, or run `hq index sync` by hand",
49
+ }];
50
+ }
51
+ return [{ status: "PASS", checkId: CHECK_ID, message: "hq daemon refreshes the search index with its worker on a timer." }];
52
+ }
53
+ function unknown(why) {
54
+ return { status: "UNKNOWN", checkId: CHECK_ID, message: `Could not tell whether the search index is refreshed: ${why}.` };
55
+ }
56
+ export const searchIndexFamily = {
57
+ id: SEARCH_INDEX_FAMILY_ID,
58
+ title: SEARCH_INDEX_FAMILY_TITLE,
59
+ run: () => Promise.resolve(checkSearchIndexSchedule()),
60
+ };
61
+ //# sourceMappingURL=search-index.js.map
@@ -38,7 +38,7 @@ export function checkStrandedLanes(context) {
38
38
  ...(lane.terminal_reason ? { terminal_reason: lane.terminal_reason } : {}),
39
39
  },
40
40
  message: `Keep-alive lead lane ${lane.lane_id} is ${state}${quotaExhausted ? " after account quota exhaustion" : ""}.`,
41
- remediation: `Ask the senior to recover it with: hq lanes resume ${lane.lane_id} --from-failed --reason "recover stranded keep-alive lane"`,
41
+ remediation: `Ask the senior to recover it with: hq runners resume ${lane.lane_id} --from-failed --reason "recover stranded keep-alive lane"`,
42
42
  };
43
43
  });
44
44
  }
@@ -34,6 +34,7 @@ import { ps1ShimsFamily } from "./checks/ps1-shims.js";
34
34
  import { tempHomesFamily } from "./checks/temp-homes.js";
35
35
  import { replayRecorderFamily } from "./checks/replay-recorder.js";
36
36
  import { machineChecksFamily } from "./checks/machine-checks.js";
37
+ import { searchIndexFamily } from "./checks/search-index.js";
37
38
  import { fixtureCoverageFamily } from "./fixtures/discover.js";
38
39
  import { checkClaudeWiring } from "./checks/claude-wiring.js";
39
40
  /**
@@ -297,6 +298,9 @@ export function createDefaultRegistry() {
297
298
  // Machine checks (US-016): the scripts the daemon runs on its schedule,
298
299
  // run now for this HQ root; no daemon or socket needed.
299
300
  registry.register(machineChecksFamily);
301
+ // Search index schedule (US-051): the daemon timer never starts `hq index
302
+ // sync`; when its worker cannot run, say so. Reads the daemon state file.
303
+ registry.register(searchIndexFamily);
300
304
  return registry;
301
305
  }
302
306
  //# sourceMappingURL=registry.js.map