@indigoai-us/hq-cli 5.345.234 → 5.345.235

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 (98) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/command-catalog.generated.d.ts +236 -7
  3. package/dist/command-catalog.generated.js +291 -7
  4. package/dist/command-registration-plan.d.ts +24 -0
  5. package/dist/command-registration-plan.js +4 -0
  6. package/dist/commands/bot-companies.d.ts +4 -1
  7. package/dist/commands/bot-companies.js +5 -1
  8. package/dist/commands/bot.d.ts +10 -0
  9. package/dist/commands/bot.js +165 -36
  10. package/dist/commands/capacity.js +1 -1
  11. package/dist/commands/core-handoff.js +2 -2
  12. package/dist/commands/core-ontology-native.js +5 -4
  13. package/dist/commands/core-pipeline-workflow-runner-native.js +4 -9
  14. package/dist/commands/deploy-app-db.d.ts +3 -0
  15. package/dist/commands/deploy-app-db.js +79 -0
  16. package/dist/commands/deploy-app-upload.d.ts +3 -0
  17. package/dist/commands/deploy-app-upload.js +120 -0
  18. package/dist/commands/deploy-comments.js +46 -1
  19. package/dist/commands/deploy-mutations.js +71 -5
  20. package/dist/commands/deploy-ssr.d.ts +3 -0
  21. package/dist/commands/deploy-ssr.js +74 -0
  22. package/dist/commands/dm.d.ts +7 -1
  23. package/dist/commands/dm.js +39 -9
  24. package/dist/commands/doctor.js +2 -10
  25. package/dist/commands/fingerprint.js +4 -9
  26. package/dist/commands/lanes-accounts.js +5 -5
  27. package/dist/commands/lanes-hold.js +1 -1
  28. package/dist/commands/lanes-message.js +3 -3
  29. package/dist/commands/lanes-move.js +1 -1
  30. package/dist/commands/lanes-resume.js +6 -6
  31. package/dist/commands/lanes-watch.js +2 -2
  32. package/dist/commands/lanes.js +21 -21
  33. package/dist/commands/work-env.d.ts +90 -0
  34. package/dist/commands/work-env.js +304 -0
  35. package/dist/lazy-commands.js +2 -10
  36. package/dist/lib/bot/api.d.ts +27 -0
  37. package/dist/lib/bot/api.js +28 -2
  38. package/dist/lib/bot/cloud-create.d.ts +46 -0
  39. package/dist/lib/bot/cloud-create.js +128 -0
  40. package/dist/lib/bot/fleet-daemon.js +4 -1
  41. package/dist/lib/bot/fleet-local.d.ts +7 -0
  42. package/dist/lib/bot/fleet-local.js +39 -3
  43. package/dist/lib/bot/fleet-owner-companies.js +2 -2
  44. package/dist/lib/bot/promote.d.ts +81 -2
  45. package/dist/lib/bot/promote.js +425 -51
  46. package/dist/lib/bot/promotion-hold.d.ts +9 -0
  47. package/dist/lib/bot/promotion-hold.js +29 -0
  48. package/dist/lib/bot/promotion-receipt.d.ts +10 -0
  49. package/dist/lib/bot/promotion-receipt.js +41 -1
  50. package/dist/lib/bot/promotion-upload.d.ts +6 -1
  51. package/dist/lib/bot/promotion-upload.js +3 -1
  52. package/dist/lib/bot/readiness.d.ts +9 -0
  53. package/dist/lib/bot/readiness.js +16 -0
  54. package/dist/lib/capacity/route.js +4 -4
  55. package/dist/lib/capacity/sign-in.js +1 -1
  56. package/dist/lib/checkpoint-ontology/entity-file.js +15 -17
  57. package/dist/lib/daemon/catalog.d.ts +2 -0
  58. package/dist/lib/daemon/catalog.js +2 -0
  59. package/dist/lib/daemon/hook-requests.js +23 -3
  60. package/dist/lib/daemon/run.d.ts +14 -0
  61. package/dist/lib/daemon/run.js +24 -14
  62. package/dist/lib/deploy-api.d.ts +2 -0
  63. package/dist/lib/deploy-api.js +9 -0
  64. package/dist/lib/environment/work-requirements.js +1 -1
  65. package/dist/lib/hot-channels/signals-pass.d.ts +0 -76
  66. package/dist/lib/hot-channels/signals-pass.js +81 -4
  67. package/dist/lib/lanes/account-company.js +1 -1
  68. package/dist/lib/lanes/account-ownership.js +1 -1
  69. package/dist/lib/lanes/accounts.js +1 -1
  70. package/dist/lib/lanes/delivery.js +7 -7
  71. package/dist/lib/lanes/dropbox.js +1 -1
  72. package/dist/lib/lanes/grants.js +3 -3
  73. package/dist/lib/lanes/hq-root.js +1 -1
  74. package/dist/lib/lanes/keep-alive-audit.js +2 -2
  75. package/dist/lib/lanes/links.js +4 -4
  76. package/dist/lib/lanes/monitor.js +3 -3
  77. package/dist/lib/lanes/quota-notice.js +1 -1
  78. package/dist/lib/lanes/reconcile.js +22 -12
  79. package/dist/lib/lanes/signal-brief-template.js +1 -1
  80. package/dist/lib/lanes/worker-continuity.js +1 -1
  81. package/dist/lib/mesh/live/direct-drain.d.ts +1 -0
  82. package/dist/lib/mesh/live/direct-drain.js +12 -1
  83. package/dist/lib/mesh/live/emit.d.ts +1 -1
  84. package/dist/lib/mesh/live/emit.js +10 -5
  85. package/dist/lib/mesh/live/flush.js +19 -4
  86. package/dist/lib/mesh/live/reporting-privacy.d.ts +9 -3
  87. package/dist/lib/mesh/live/reporting-privacy.js +27 -7
  88. package/dist/lib/mesh/live/spool.d.ts +2 -0
  89. package/dist/lib/mesh/live/spool.js +41 -0
  90. package/dist/lib/signals/sanitize.js +5 -4
  91. package/dist/lib/signals/steps/garden.js +5 -4
  92. package/dist/utils/frontmatter.d.ts +8 -0
  93. package/dist/utils/frontmatter.js +11 -2
  94. package/dist/utils/hq-roots-core.d.ts +5 -0
  95. package/dist/utils/hq-roots-core.js +18 -9
  96. package/dist/utils/owner-session.d.ts +13 -0
  97. package/dist/utils/owner-session.js +28 -0
  98. package/package.json +7 -7
@@ -62,8 +62,10 @@ export async function uploadLocalBotPromotion(input) {
62
62
  const credential = Buffer.from(JSON.stringify({ kind: "hq-bot-machine-credential-v1", agentUid: bundle.agentUid,
63
63
  ownerUid: bundle.ownerUid, digest: bundle.digest, operationId, username: machine.username, secret: machine.secret }));
64
64
  try {
65
- let state = await api.preparePromotion(bundle.agentUid, { companyUid, operationId, snapshotSha256: bundle.digest });
65
+ input.onPreparing?.();
66
+ let state = await api.preparePromotion(bundle.agentUid, { companyUid, operationId, snapshotSha256: bundle.digest, brain: input.brain });
66
67
  assertState(state, bundle, companyUid, operationId);
68
+ input.onPrepared?.();
67
69
  for (const [kind, bytes] of [["snapshot", snapshot], ["machine-credential", credential]]) {
68
70
  const signed = await api.promotionUpload(bundle.agentUid, { companyUid, operationId, kind, bytes: bytes.length, sha256: sha(bytes) });
69
71
  assertState(signed.promotion, bundle, companyUid, operationId);
@@ -73,4 +73,13 @@ export interface SetupStepReporter {
73
73
  steps(): SetupStepRecord[];
74
74
  }
75
75
  export declare function createSetupStepReporter(mode: "text" | "json" | "silent", write?: (line: string) => void): SetupStepReporter;
76
+ export type BotOnlineLabel = "cloud" | "moving to cloud" | "creating" | "installing" | "starting" | "unreachable" | "online" | "offline" | "unknown";
77
+ /** The online column of `hq bot list`. A promoted or held bot is never shown as starting here. */
78
+ export declare function botOnlineLabel(row: {
79
+ hosting: "local" | "cloud";
80
+ promotionHold?: unknown;
81
+ readiness: BotReadiness;
82
+ lastHeartbeatOk: boolean | null;
83
+ online: boolean | null;
84
+ }): BotOnlineLabel;
76
85
  //# sourceMappingURL=readiness.d.ts.map
@@ -156,4 +156,20 @@ export function createSetupStepReporter(mode, write = (line) => { process.stdout
156
156
  steps: () => records.map((entry) => ({ ...entry })),
157
157
  };
158
158
  }
159
+ /** The online column of `hq bot list`. A promoted or held bot is never shown as starting here. */
160
+ export function botOnlineLabel(row) {
161
+ if (row.hosting === "cloud")
162
+ return "cloud";
163
+ if (row.promotionHold)
164
+ return "moving to cloud";
165
+ if (row.readiness === "creating" || row.readiness === "installing" || row.readiness === "starting")
166
+ return row.readiness;
167
+ if (row.lastHeartbeatOk === false)
168
+ return "unreachable";
169
+ if (row.online === true)
170
+ return "online";
171
+ if (row.online === false)
172
+ return "offline";
173
+ return "unknown";
174
+ }
159
175
  //# sourceMappingURL=readiness.js.map
@@ -374,7 +374,7 @@ export function pickAccount(input) {
374
374
  ...base,
375
375
  reason: "held by another person, not used for lanes",
376
376
  fix: "This login is held by " + (heldConfig?.holder ?? "another person") +
377
- ". Use one of your own logins. Change the holder to owner only if this is really your own login: hq lanes accounts set-owner " +
377
+ ". Use one of your own logins. Change the holder to owner only if this is really your own login: hq runners accounts set-owner " +
378
378
  providerId + " " + laneMatch.id + " --holder owner",
379
379
  });
380
380
  continue;
@@ -389,7 +389,7 @@ export function pickAccount(input) {
389
389
  skipped.push({
390
390
  ...base,
391
391
  reason: "usage-only, lanes cannot run on it",
392
- fix: `hq lanes accounts enable ${providerId} ${laneMatch.id}`,
392
+ fix: `hq runners accounts enable ${providerId} ${laneMatch.id}`,
393
393
  });
394
394
  continue;
395
395
  }
@@ -420,7 +420,7 @@ export function pickAccount(input) {
420
420
  skipped.push({
421
421
  ...base,
422
422
  reason: "usage-only, lanes cannot run on it",
423
- fix: `hq lanes accounts enable ${providerId} ${laneMatch.id}`,
423
+ fix: `hq runners accounts enable ${providerId} ${laneMatch.id}`,
424
424
  });
425
425
  continue;
426
426
  }
@@ -671,7 +671,7 @@ export function pickAccount(input) {
671
671
  reason: bad.get(key),
672
672
  to: to?.account ?? null,
673
673
  command: to
674
- ? `hq lanes message ${lane.lane_id} --account ${to.account} --text "Continue on account ${to.account}; ${lane.account} is out of room."`
674
+ ? `hq runners message ${lane.lane_id} --account ${to.account} --text "Continue on account ${to.account}; ${lane.account} is out of room."`
675
675
  : null,
676
676
  });
677
677
  }
@@ -22,7 +22,7 @@ export function formatRefreshLine(provider, command) {
22
22
  return command;
23
23
  }
24
24
  export function laneEnableCommand(provider, label) {
25
- return `hq lanes accounts enable ${provider} ${label}`;
25
+ return `hq runners accounts enable ${provider} ${label}`;
26
26
  }
27
27
  export class SignInUsageError extends Error {
28
28
  constructor(message) {
@@ -13,28 +13,26 @@
13
13
  */
14
14
  import { isDeepStrictEqual } from "node:util";
15
15
  import yaml from "js-yaml";
16
- import { splitFrontmatterBlock } from "../../utils/frontmatter.js";
16
+ import { splitFrontmatterBlock, splitFrontmatterBody } from "../../utils/frontmatter.js";
17
17
  import { entityId } from "./identity.js";
18
- // Same delimiters as hq-pro `parser.ts`.
19
- const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
20
18
  /**
21
19
  * Parse with the YAML 1.2 core schema, as the cloud's `yaml` package does.
22
20
  * js-yaml's default schema would turn unquoted timestamps into Date objects.
23
21
  */
24
22
  export function parseEntityFile(content) {
25
- const match = FRONTMATTER_RE.exec(content);
26
- if (!match)
23
+ const block = splitFrontmatterBody(content);
24
+ if (!block)
27
25
  return null;
28
26
  let raw;
29
27
  try {
30
- raw = yaml.load(match[1], { schema: yaml.CORE_SCHEMA });
28
+ raw = yaml.load(block.yaml, { schema: yaml.CORE_SCHEMA });
31
29
  }
32
30
  catch {
33
31
  return null;
34
32
  }
35
33
  if (!raw || typeof raw !== "object" || Array.isArray(raw))
36
34
  return null;
37
- return { frontmatter: raw, body: match[2] };
35
+ return { frontmatter: raw, body: block.body };
38
36
  }
39
37
  function isStringArray(value) {
40
38
  return Array.isArray(value) && value.every((item) => typeof item === "string");
@@ -151,9 +149,9 @@ function appendAliases(lines, all, added) {
151
149
  * unchanged so a rerun writes nothing.
152
150
  */
153
151
  export function patchEntityFile(content, patch) {
154
- const match = FRONTMATTER_RE.exec(content);
152
+ const block = splitFrontmatterBody(content);
155
153
  const parsed = parseEntityFile(content);
156
- if (!match || !parsed)
154
+ if (!block || !parsed)
157
155
  return { ok: false, reason: "unparseable" };
158
156
  const before = validateEntityFrontmatter(parsed.frontmatter);
159
157
  if (typeof before === "string")
@@ -172,7 +170,7 @@ export function patchEntityFile(content, patch) {
172
170
  if (!aliasesChanged && !countChanged && !patch.bodyChanged)
173
171
  return { ok: true, content, changed: false };
174
172
  const newline = content.includes("\r\n") ? "\r\n" : "\n";
175
- let lines = match[1].split(/\r?\n/);
173
+ let lines = block.yaml.split(/\r?\n/);
176
174
  if (removed)
177
175
  lines = replaceTopLevelKey(lines, "aliases", renderAliases(aliases));
178
176
  else if (aliasesChanged)
@@ -183,8 +181,8 @@ export function patchEntityFile(content, patch) {
183
181
  lines = replaceTopLevelKey(lines, "last_updated", `last_updated: ${patch.lastUpdated}`);
184
182
  if (!lines)
185
183
  return { ok: false, reason: "missing_owned_key" };
186
- const head = content.slice(0, content.indexOf(match[1]));
187
- const tail = content.slice(content.indexOf(match[1]) + match[1].length);
184
+ const head = content.slice(0, content.indexOf(block.yaml));
185
+ const tail = content.slice(content.indexOf(block.yaml) + block.yaml.length);
188
186
  const next = `${head}${lines.join(newline)}${tail}`;
189
187
  const check = checkPatched(parsed.frontmatter, next, aliases, signalCount, patch.lastUpdated);
190
188
  if (check)
@@ -243,9 +241,9 @@ function renderWebDomains(domains) {
243
241
  * `last_updated`. When neither key changes the file is returned unchanged.
244
242
  */
245
243
  export function setIdentityKeys(content, patch) {
246
- const match = FRONTMATTER_RE.exec(content);
244
+ const block = splitFrontmatterBody(content);
247
245
  const parsed = parseEntityFile(content);
248
- if (!match || !parsed)
246
+ if (!block || !parsed)
249
247
  return { ok: false, reason: "unparseable" };
250
248
  const before = validateEntityFrontmatter(parsed.frontmatter);
251
249
  if (typeof before === "string")
@@ -263,7 +261,7 @@ export function setIdentityKeys(content, patch) {
263
261
  if (!idsChanged && !domainsChanged && !refsChanged)
264
262
  return { ok: true, content, changed: false };
265
263
  const newline = content.includes("\r\n") ? "\r\n" : "\n";
266
- let lines = match[1].split(/\r?\n/);
264
+ let lines = block.yaml.split(/\r?\n/);
267
265
  if (idsChanged) {
268
266
  const rendered = renderExternalIds(patch.externalIds);
269
267
  lines = replaceTopLevelKey(lines, "external_ids", rendered) ?? [...lines, ...rendered.split("\n")];
@@ -280,8 +278,8 @@ export function setIdentityKeys(content, patch) {
280
278
  if (!stamped)
281
279
  return { ok: false, reason: "missing_owned_key" };
282
280
  lines = stamped;
283
- const head = content.slice(0, content.indexOf(match[1]));
284
- const tail = content.slice(content.indexOf(match[1]) + match[1].length);
281
+ const head = content.slice(0, content.indexOf(block.yaml));
282
+ const tail = content.slice(content.indexOf(block.yaml) + block.yaml.length);
285
283
  const next = `${head}${lines.join(newline)}${tail}`;
286
284
  const reparsed = parseEntityFile(next);
287
285
  if (!reparsed)
@@ -122,6 +122,8 @@ export interface FleetBotPlan {
122
122
  authPending: boolean;
123
123
  /** `hq bot start <name>` has not run yet. */
124
124
  installPending: boolean;
125
+ /** The bot runs in the cloud, or is held for a move there; it must not run on this machine. */
126
+ promotion?: "cloud" | "moving";
125
127
  /** The runtime's own LaunchAgent still exists (it could not be retired), by label. */
126
128
  legacyAgent?: string;
127
129
  /** A gateway for this bot started outside the daemon is still running; it has been asked to exit. */
@@ -404,6 +404,8 @@ function planService(service, ctx) {
404
404
  // The gateway finishes the reply it is sending before it exits; its own LaunchAgent gave it 25 s.
405
405
  stopGraceMs: FLEET_BOT_STOP_GRACE_MS,
406
406
  blocked: firstBlock([
407
+ [bot.promotion === "cloud", "moved to the cloud; it no longer runs on this computer"],
408
+ [bot.promotion === "moving", `held for its move to the cloud (finish with \`hq bot promote ${bot.name} --company <uid>\`, or add --cancel)`],
407
409
  [bot.authPending, `not signed in (run \`hq bot auth ${bot.name}\`)`],
408
410
  [bot.installPending, `waiting for \`hq bot start ${bot.name}\``],
409
411
  [bot.gateway === null, `the HQ Fleet runtime is not installed for ${bot.name} (run \`hq bot start ${bot.name}\`)`],
@@ -54,6 +54,10 @@ import * as fs from "node:fs";
54
54
  import * as os from "node:os";
55
55
  import * as path from "node:path";
56
56
  import { openStoreDir } from "../safe-store.js";
57
+ import { hasWorkMeshCompanyBinding, workMeshSwitchDisabled } from "../mesh/live/reporting-privacy.js";
58
+ import { readMetaCompanySlug } from "../work-context/company.js";
59
+ import { workContextRoot } from "../work-context/paths.js";
60
+ import { readSessionState } from "../work-context/state.js";
57
61
  import { executeAclSuggestion, parseShareCandidates } from "./hook-requests-acl-suggest.js";
58
62
  import { parseMeshOperation, runMeshReconcile, runMeshRegisterRetry } from "./hook-requests-mesh.js";
59
63
  import { MACHINE_CHECKS, machineCheckCollectOnlySupported, runMachineChecks } from "./machine-checks.js";
@@ -1430,9 +1434,20 @@ async function runFleetLocalSettings(request, operation, base, options) {
1430
1434
  * (the shell's redirection failed and the hook did not run).
1431
1435
  */
1432
1436
  async function runMeshSessionBind(request, operation, base, options) {
1433
- if (operation.disabled !== undefined) {
1434
- options.log?.(`${operation.kind}: ${operation.disabled} switched the Work Mesh hook off in session ${operation.sessionId}; not bound`);
1435
- return { code: 0 };
1437
+ const switchOn = operation.disabled !== undefined || workMeshSwitchDisabled(base);
1438
+ if (switchOn) {
1439
+ const contextRoot = workContextRoot(base.HOME, base);
1440
+ const state = readSessionState(operation.sessionId, contextRoot);
1441
+ const metaCompany = readMetaCompanySlug(operation.sessionId, request.root);
1442
+ const bound = hasWorkMeshCompanyBinding(state) &&
1443
+ (metaCompany === undefined || metaCompany === state.companySlug) &&
1444
+ (operation.kind === "mesh-session-register" || operation.company === state.companySlug);
1445
+ if (!bound) {
1446
+ if (operation.disabled !== undefined) {
1447
+ options.log?.(`${operation.kind}: ${operation.disabled} switched the Work Mesh hook off in session ${operation.sessionId}; not bound`);
1448
+ }
1449
+ return { code: 0 };
1450
+ }
1436
1451
  }
1437
1452
  const hook = path.join(request.root, MESH_SESSION_BIND_HOOK);
1438
1453
  try {
@@ -1449,6 +1464,11 @@ async function runMeshSessionBind(request, operation, base, options) {
1449
1464
  const env = { ...base };
1450
1465
  for (const name of MESH_SESSION_BIND_UNSET)
1451
1466
  delete env[name];
1467
+ if (switchOn) {
1468
+ delete env.HQ_WORK_MESH_DISABLED;
1469
+ env.HQ_DISABLED_HOOKS = env.HQ_DISABLED_HOOKS?.split(",")
1470
+ .filter(value => !["*", "work-mesh", "work-mesh-live"].includes(value.trim())).join(",");
1471
+ }
1452
1472
  Object.assign(env, { HQ_ROOT: request.root, CLAUDE_CODE_SESSION_ID: operation.sessionId, HQ_HOOK_REQUEST_ID: request.id });
1453
1473
  let cwd = request.root;
1454
1474
  try {
@@ -8,6 +8,7 @@
8
8
  import { acquirePackageUseLease } from "../../utils/package-use-lease.js";
9
9
  import { type LegacySyncHolder, type PlanContext, type ServiceName, type UnitPlan } from "./catalog.js";
10
10
  import { type SyncCoreVaultPlan } from "../sync-core/engine-home.js";
11
+ import { type DaemonFlagRegistryRead, type DaemonFlagSnapshotSource } from "./flag.js";
11
12
  import { type LegacyUnit, type WindowsTaskOwner } from "./legacy.js";
12
13
  import { type DaemonLockResult } from "./lock.js";
13
14
  import { removeMeshUnitFromOtherHome, type LaunchctlRunner } from "../mesh/live/daemon/unit-home.js";
@@ -46,6 +47,19 @@ export declare function shouldStartHqd(anywhereEnabled: boolean): boolean;
46
47
  * revocation stays in place.
47
48
  */
48
49
  export declare function refreshHqdRuntimeDecision(readDecision: () => Promise<boolean>, home: string, env: NodeJS.ProcessEnv, onMarkerError?: (error: unknown) => void, syncEnabledMarker?: (enabled: boolean) => void): Promise<boolean>;
50
+ /**
51
+ * The daemon's one flag poller (US-036): the source every timed flag read
52
+ * shares. Each shared registry request also writes the on-disk flag snapshot
53
+ * (shared-flag-reads.ts), then tells the observers in order, so the state file
54
+ * and the hqd runtime events cost no request of their own.
55
+ */
56
+ export declare function createDaemonRunFlagReads(observers: ReadonlyArray<(read: DaemonFlagRegistryRead, env: NodeJS.ProcessEnv) => void>): DaemonFlagSnapshotSource;
57
+ /**
58
+ * The hqd listener's runtime decision (US-036): the HQ Anywhere flag as the
59
+ * shared read last wrote it to the on-disk snapshot, then the person setting.
60
+ * It makes no registry request of its own.
61
+ */
62
+ export declare function hqdListenerRuntimeAllowed(env: NodeJS.ProcessEnv, readSetting: () => Promise<boolean | null>): Promise<boolean>;
49
63
  /** Route an updater request through the daemon's existing graceful handoff. */
50
64
  export declare function handoffForPackageUpdateRequest(requested: boolean, restartDaemon: () => void): void;
51
65
  export interface RunDaemonOptions {
@@ -38,7 +38,8 @@ import { daemonLanesReconcileHandler } from "../lanes/daemon-reconcile.js";
38
38
  import { computeLanesMonitorSection } from "./lanes-monitor-state.js";
39
39
  import { ensureDaemonLanesReconcileHandler, runDaemonLanesReconcileInProcess } from "./lanes-reconcile-loader.js";
40
40
  import { startWhoamiCacheWriter } from "./whoami-cache.js";
41
- import { SUPERVISOR_HANDOFF_FLAG, createDaemonFlagSnapshotSource, readDaemonFlag } from "./flag.js";
41
+ import { SUPERVISOR_HANDOFF_FLAG, readDaemonFlag } from "./flag.js";
42
+ import { createDaemonSharedFlagReads, hqdListenerFlagGate } from "./shared-flag-reads.js";
42
43
  import { createDaemonKillSwitchMonitors } from "./timed-flag-monitors.js";
43
44
  import { MACHINE_CHECKS_RESULT_FILE, readMachineCheckResults, startMachineCheckSchedule } from "./machine-checks.js";
44
45
  import { createLanesReconcileWatcher } from "./lanes-reconcile-watcher.js";
@@ -288,6 +289,23 @@ export async function refreshHqdRuntimeDecision(readDecision, home, env, onMarke
288
289
  }
289
290
  return enabled;
290
291
  }
292
+ /**
293
+ * The daemon's one flag poller (US-036): the source every timed flag read
294
+ * shares. Each shared registry request also writes the on-disk flag snapshot
295
+ * (shared-flag-reads.ts), then tells the observers in order, so the state file
296
+ * and the hqd runtime events cost no request of their own.
297
+ */
298
+ export function createDaemonRunFlagReads(observers) {
299
+ return createDaemonSharedFlagReads({ observers });
300
+ }
301
+ /**
302
+ * The hqd listener's runtime decision (US-036): the HQ Anywhere flag as the
303
+ * shared read last wrote it to the on-disk snapshot, then the person setting.
304
+ * It makes no registry request of its own.
305
+ */
306
+ export function hqdListenerRuntimeAllowed(env, readSetting) {
307
+ return anywhereRuntimeAllowed(env, { ...hqdListenerFlagGate(), readSetting });
308
+ }
291
309
  /** Route an updater request through the daemon's existing graceful handoff. */
292
310
  export function handoffForPackageUpdateRequest(requested, restartDaemon) {
293
311
  if (requested)
@@ -1131,12 +1149,10 @@ export async function runDaemon(opts) {
1131
1149
  // its own beyond a rare fallback (anywhere-listener.ts).
1132
1150
  const hqdRuntimeEvents = createHqdRuntimeEvents();
1133
1151
  const observeHqdRuntime = observeHqdRuntimeFlag(() => hqdRuntimeEvents.emit());
1134
- const flagSnapshots = createDaemonFlagSnapshotSource({
1135
- onRead: (read, readEnv) => {
1136
- observeHqdRuntime(read, readEnv);
1137
- stateWriter.onRegistryRead(read, readEnv);
1138
- },
1139
- });
1152
+ const flagSnapshots = createDaemonRunFlagReads([
1153
+ observeHqdRuntime,
1154
+ (read, readEnv) => stateWriter.onRegistryRead(read, readEnv),
1155
+ ]);
1140
1156
  const killSwitches = createDaemonKillSwitchMonitors({ env, log, snapshots: flagSnapshots });
1141
1157
  const childBootstrapHandoffWatchFlag = killSwitches.childBootstrapHandoffWatch;
1142
1158
  const lanesReconcileFileWatchFlag = killSwitches.lanesReconcileFileWatch;
@@ -1856,13 +1872,7 @@ export async function runDaemon(opts) {
1856
1872
  exit: (code) => tccEpermExit(code),
1857
1873
  });
1858
1874
  const hqdListener = await startHqdRuntimeListener({
1859
- isEnabled: async () => refreshHqdRuntimeDecision(async () => shouldStartHqd(await anywhereRuntimeAllowed(env, {
1860
- refreshFlag: async () => {
1861
- const { refreshFlagRegistrySnapshot } = await import("../flag-registry.js");
1862
- await refreshFlagRegistrySnapshot(5_000);
1863
- },
1864
- readSetting: readPersonSetting,
1865
- })), home, env, (error) => log("warn", `hqd runtime marker update failed: ${error.message ?? String(error)}`), (enabled) => syncHqdEnabledMarker(hqdSocketPath(home, env), enabled)),
1875
+ isEnabled: async () => refreshHqdRuntimeDecision(async () => shouldStartHqd(await hqdListenerRuntimeAllowed(env, readPersonSetting)), home, env, (error) => log("warn", `hqd runtime marker update failed: ${error.message ?? String(error)}`), (enabled) => syncHqdEnabledMarker(hqdSocketPath(home, env), enabled)),
1866
1876
  startServer: async () => {
1867
1877
  const startConfig = readDaemonConfig(paths.configPath);
1868
1878
  const hqRoot = startConfig.hqRoot ?? (env.HQ_ROOT?.trim() || undefined);
@@ -2,4 +2,6 @@
2
2
  export declare const DEPLOY_API_URL: string;
3
3
  export declare function deployHeaders(token: string, json?: boolean, extra?: Record<string, string>): Record<string, string>;
4
4
  export declare function deployApiRequest(token: string, route: string, method: string, body?: unknown, extraHeaders?: Record<string, string>): Promise<Response>;
5
+ /** Submit an app archive on the authenticated multipart route. Fetch owns the boundary. */
6
+ export declare function deployApiFormRequest(token: string, route: string, body: FormData, extraHeaders: Record<string, string>): Promise<Response>;
5
7
  //# sourceMappingURL=deploy-api.d.ts.map
@@ -20,4 +20,13 @@ export async function deployApiRequest(token, route, method, body, extraHeaders
20
20
  signal: AbortSignal.timeout(DEPLOY_API_REQUEST_TIMEOUT_MS),
21
21
  });
22
22
  }
23
+ /** Submit an app archive on the authenticated multipart route. Fetch owns the boundary. */
24
+ export function deployApiFormRequest(token, route, body, extraHeaders) {
25
+ return fetch(deployApiUrl(route), {
26
+ method: "POST",
27
+ headers: deployHeaders(token, false, extraHeaders),
28
+ body,
29
+ redirect: "error",
30
+ });
31
+ }
23
32
  //# sourceMappingURL=deploy-api.js.map
@@ -382,7 +382,7 @@ export function withRepairedCompany(document, company) {
382
382
  return {
383
383
  ...document,
384
384
  company,
385
- origin: { ...document.origin, derived_from: ["company: the work's own company (set by hq lanes repair-company)", ...derivedFrom] },
385
+ origin: { ...document.origin, derived_from: ["company: the work's own company (set by hq runners repair-company)", ...derivedFrom] },
386
386
  assumptions: (document.assumptions ?? []).filter((entry) => !entry.startsWith("No company on the work")),
387
387
  };
388
388
  }
@@ -1,79 +1,3 @@
1
- /**
2
- * The local signals pass (US-011). After each hot-channel adapter run, the
3
- * pass takes the adapter's channel through the ontology worklist, asks
4
- * `claude -p` for signals one document at a time, and writes those signals to
5
- * `companies/{co}/signals/`. It returns the count for the run ledger.
6
- *
7
- * Work comes from the worklist, not only from this run's landings: when the
8
- * worklist script exits 0, the pass takes the channel's unprocessed items in
9
- * the worklist's order (newest first) up to the run's document cap. Items the
10
- * cap leaves over stay unmarked, and a later run picks them up, including a
11
- * run that landed nothing (a bounded backlog drain: at most
12
- * DEFAULT_MAX_SIGNAL_DOCS claude calls per run, and no claude call at all when
13
- * the backlog is empty). A channel with no source.yaml (worklist exit 2, the
14
- * usual case for a hot channel such as `meeting-events`) has no worklist, so
15
- * the pass keeps its own backlog: landed documents it has not processed yet
16
- * are listed in `sources/_signals-pending/{channel}.json` and drained, newest
17
- * first by `when` (else `created_at`), on later runs under the same cap. A
18
- * cloud-run source (exit 4) is skipped.
19
- *
20
- * A landed document with both `payload_ref` and `raw_ref` is a pointer (the
21
- * meetings, Slack and Attio adapters land these). For it, claude gets the
22
- * pointer followed by the document `payload_ref` names, capped at
23
- * MAX_PAYLOAD_BYTES. A payload outside `sources/`, missing or unreadable falls
24
- * back to the pointer alone, and the reason is warned and kept on the signal.
25
- *
26
- * Runtime: Claude Code (`claude -p`) by default, exactly as before. When the
27
- * Executive bot (the bot whose runtime the pass already reads for its
28
- * signed-out wording) is a Codex bot with `signalsRuntime: "bot"` in bot.json
29
- * (`hq bot set <name> --signals-runtime bot`), the pass runs on Codex
30
- * instead, through `runRuntimeTurn`, the turn runner a Daily Brief job uses.
31
- * The argv and environment differ from a DM turn on purpose, because the
32
- * documents are untrusted (see codexSignalsArgs and codexSignalsEnv). The
33
- * opt-in defaults off so the first Codex runs can be compared with Claude's.
34
- * When it is on, a failed Codex run is a Codex failure (`codex-*` codes); it
35
- * never falls back to Claude.
36
- *
37
- * Billing: policy hq-no-headless-print-subscription-billing forbids headless
38
- * `claude -p` / `codex exec` in general.
39
- * - Claude: this is its allowed case, per the owner decision of 2026-10-21:
40
- * the owner's own `claude` login, on their own machine, in a bounded
41
- * single-turn call.
42
- * - Codex: narrow exception hq-signals-pass-codex-exec-narrow-exception (owner
43
- * decision 2026-11-15). It holds only while the Codex call is
44
- * 1. a single bounded turn (one `codex exec`, a per-document timeout),
45
- * 2. with every Codex tool and feature off (codexLockdownFlags in
46
- * signals/codex-lockdown.ts: shell, apps, plugins, hooks, multi-agent,
47
- * web search, browser and computer use, bundled skills),
48
- * 3. with no network (`permissions.*.network.enabled=false`),
49
- * 4. with read access limited to the empty temp dir plus the codex install
50
- * dir, never $HOME, ~/.hq, or a parent of either
51
- * (resolveCodexLockdownTarget),
52
- * 5. under an environment allowlist (CODEX_SIGNALS_ENV_ALLOWLIST).
53
- * The login is the bot's own Codex login dir (never the owner's ~/.codex,
54
- * and not available for an HQ Fleet Runtime bot), used in place so Codex's
55
- * own refresh lock applies; the pass never copies or writes it.
56
- * A change that loosens any of these is outside the exception;
57
- * signals-pass.codex.test.ts pins all five.
58
- * Cloud Claude is not the bot brain, and no model is called from the poller
59
- * itself. Do not reuse this pass for a shared, fleet or hosted identity.
60
- *
61
- * Failures: a pass that fails keeps the real class as its ledger code (see
62
- * SignalsPassErrorCode), and writes the provider's own reason, redacted and
63
- * cut, to `warn`. The reason stays out of the ledger because the ledger syncs
64
- * with the company vault. A failed document is never marked done, so a later
65
- * run picks it up. No account is picked and no other provider is called here.
66
- *
67
- * Unusable replies: a document whose reply is `claude-bad-output` is sent
68
- * again, up to BAD_OUTPUT_ATTEMPTS calls in all. If every reply is unusable the
69
- * pass leaves that document for a later run, goes on to the next one, and
70
- * fails with `claude-bad-output` at the end. Every other failure class stops
71
- * the pass at once, because it would fail the next document the same way. A
72
- * reply with no stdout is not sent again, and BAD_OUTPUT_STOP_AFTER documents
73
- * in a row with unusable replies stop the pass, for the same reason. So a run
74
- * makes at most the document cap (`maxDocs`) × BAD_OUTPUT_ATTEMPTS calls, and
75
- * BAD_OUTPUT_STOP_AFTER × BAD_OUTPUT_ATTEMPTS when every reply is unusable.
76
- */
77
1
  import type { BotRuntimeId } from "../bot/config.js";
78
2
  import { type SpawnLike } from "../bot/runtime/index.js";
79
3
  import type { HotChannelRunResult, WriteGuard } from "./loop.js";
@@ -1,4 +1,81 @@
1
1
  import { prepareSignalPublication, flushSignalPublications } from "../bot/jobs/signal-to-lane.js";
2
+ /**
3
+ * The local signals pass (US-011). After each hot-channel adapter run, the
4
+ * pass takes the adapter's channel through the ontology worklist, asks
5
+ * `claude -p` for signals one document at a time, and writes those signals to
6
+ * `companies/{co}/signals/`. It returns the count for the run ledger.
7
+ *
8
+ * Work comes from the worklist, not only from this run's landings: when the
9
+ * worklist script exits 0, the pass takes the channel's unprocessed items in
10
+ * the worklist's order (newest first) up to the run's document cap. Items the
11
+ * cap leaves over stay unmarked, and a later run picks them up, including a
12
+ * run that landed nothing (a bounded backlog drain: at most
13
+ * DEFAULT_MAX_SIGNAL_DOCS claude calls per run, and no claude call at all when
14
+ * the backlog is empty). A channel with no source.yaml (worklist exit 2, the
15
+ * usual case for a hot channel such as `meeting-events`) has no worklist, so
16
+ * the pass keeps its own backlog: landed documents it has not processed yet
17
+ * are listed in `sources/_signals-pending/{channel}.json` and drained, newest
18
+ * first by `when` (else `created_at`), on later runs under the same cap. A
19
+ * cloud-run source (exit 4) is skipped.
20
+ *
21
+ * A landed document with both `payload_ref` and `raw_ref` is a pointer (the
22
+ * meetings, Slack and Attio adapters land these). For it, claude gets the
23
+ * pointer followed by the document `payload_ref` names, capped at
24
+ * MAX_PAYLOAD_BYTES. A payload outside `sources/`, missing or unreadable falls
25
+ * back to the pointer alone, and the reason is warned and kept on the signal.
26
+ *
27
+ * Runtime: Claude Code (`claude -p`) by default, exactly as before. When the
28
+ * Executive bot (the bot whose runtime the pass already reads for its
29
+ * signed-out wording) is a Codex bot with `signalsRuntime: "bot"` in bot.json
30
+ * (`hq bot set <name> --signals-runtime bot`), the pass runs on Codex
31
+ * instead, through `runRuntimeTurn`, the turn runner a Daily Brief job uses.
32
+ * The argv and environment differ from a DM turn on purpose, because the
33
+ * documents are untrusted (see codexSignalsArgs and codexSignalsEnv). The
34
+ * opt-in defaults off so the first Codex runs can be compared with Claude's.
35
+ * When it is on, a failed Codex run is a Codex failure (`codex-*` codes); it
36
+ * never falls back to Claude.
37
+ *
38
+ * Billing: policy hq-no-headless-print-subscription-billing forbids headless
39
+ * `claude -p` / `codex exec` in general.
40
+ * - Claude: this is its allowed case, per the owner decision of 2026-10-21:
41
+ * the owner's own `claude` login, on their own machine, in a bounded
42
+ * single-turn call.
43
+ * - Codex: narrow exception hq-signals-pass-codex-exec-narrow-exception (owner
44
+ * decision 2026-11-15). It holds only while the Codex call is
45
+ * 1. a single bounded turn (one `codex exec`, a per-document timeout),
46
+ * 2. with every Codex tool and feature off (codexLockdownFlags in
47
+ * signals/codex-lockdown.ts: shell, apps, plugins, hooks, multi-agent,
48
+ * web search, browser and computer use, bundled skills),
49
+ * 3. with no network (`permissions.*.network.enabled=false`),
50
+ * 4. with read access limited to the empty temp dir plus the codex install
51
+ * dir, never $HOME, ~/.hq, or a parent of either
52
+ * (resolveCodexLockdownTarget),
53
+ * 5. under an environment allowlist (CODEX_SIGNALS_ENV_ALLOWLIST).
54
+ * The login is the bot's own Codex login dir (never the owner's ~/.codex,
55
+ * and not available for an HQ Fleet Runtime bot), used in place so Codex's
56
+ * own refresh lock applies; the pass never copies or writes it.
57
+ * A change that loosens any of these is outside the exception;
58
+ * signals-pass.codex.test.ts pins all five.
59
+ * Cloud Claude is not the bot brain, and no model is called from the poller
60
+ * itself. Do not reuse this pass for a shared, fleet or hosted identity.
61
+ *
62
+ * Failures: a pass that fails keeps the real class as its ledger code (see
63
+ * SignalsPassErrorCode), and writes the provider's own reason, redacted and
64
+ * cut, to `warn`. The reason stays out of the ledger because the ledger syncs
65
+ * with the company vault. A failed document is never marked done, so a later
66
+ * run picks it up. No account is picked and no other provider is called here.
67
+ *
68
+ * Unusable replies: a document whose reply is `claude-bad-output` is sent
69
+ * again, up to BAD_OUTPUT_ATTEMPTS calls in all. If every reply is unusable the
70
+ * pass leaves that document for a later run, goes on to the next one, and
71
+ * fails with `claude-bad-output` at the end. Every other failure class stops
72
+ * the pass at once, because it would fail the next document the same way. A
73
+ * reply with no stdout is not sent again, and BAD_OUTPUT_STOP_AFTER documents
74
+ * in a row with unusable replies stop the pass, for the same reason. So a run
75
+ * makes at most the document cap (`maxDocs`) × BAD_OUTPUT_ATTEMPTS calls, and
76
+ * BAD_OUTPUT_STOP_AFTER × BAD_OUTPUT_ATTEMPTS when every reply is unusable.
77
+ */
78
+ import { splitFrontmatterBody } from "../../utils/frontmatter.js";
2
79
  import { isRuntimeUsageLimit } from "../bot/runtime-failure.js";
3
80
  import { createCodexRuntime, defaultSpawn, runRuntimeTurn, RuntimeError } from "../bot/runtime/index.js";
4
81
  import { CODEX_LOCKDOWN_DISABLED_FEATURES, CODEX_LOCKDOWN_ENV_ALLOWLIST, codexLockdownEnv, codexLockdownFilesystem, codexLockdownFlags, lockdownHomes, resolveCodexLockdownTarget, } from "../signals/codex-lockdown.js";
@@ -296,13 +373,13 @@ function isSafeChannel(channel) {
296
373
  }
297
374
  }
298
375
  export function splitFrontmatter(text) {
299
- const match = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(text);
300
- if (!match)
376
+ const block = splitFrontmatterBody(text, "lf");
377
+ if (!block)
301
378
  return { frontmatter: {}, body: text };
302
- const parsed = yaml.load(match[1]);
379
+ const parsed = yaml.load(block.yaml);
303
380
  return {
304
381
  frontmatter: parsed && typeof parsed === "object" ? parsed : {},
305
- body: match[2],
382
+ body: block.body,
306
383
  };
307
384
  }
308
385
  function isMissing(err) {
@@ -50,7 +50,7 @@ export function companyMismatchError(input) {
50
50
  return new LanesError("account_held_by_other", `Every enabled ${input.provider} account is held by another person and is not used for lanes: ` +
51
51
  `${held.map((row) => `${row.account} (${row.holder})`).join(", ")}. ` +
52
52
  "Sign in with one of your own logins. Change a holder to owner only if that login is really yours: " +
53
- `hq lanes accounts set-owner ${input.provider} <id> --holder owner`, { provider: input.provider, held_accounts: held, config_key: `providers.${input.provider}.accounts.<id>.holder`, config_file: "personal/lanes/config.json" });
53
+ `hq runners accounts set-owner ${input.provider} <id> --holder owner`, { provider: input.provider, held_accounts: held, config_key: `providers.${input.provider}.accounts.<id>.holder`, config_file: "personal/lanes/config.json" });
54
54
  }
55
55
  if (!companyEnforcementActive(input.providerAccounts))
56
56
  return undefined;
@@ -115,7 +115,7 @@ export function heldByOwner(account) {
115
115
  return !accountHeldByOther(account);
116
116
  }
117
117
  export function setOwnerCommand(provider, id) {
118
- return `hq lanes accounts set-owner ${provider} ${id} --owning-company <slug|personal|unknown> --holder <owner|name>`;
118
+ return `hq runners accounts set-owner ${provider} ${id} --owning-company <slug|personal|unknown> --holder <owner|name>`;
119
119
  }
120
120
  /** Warning for an enabled account missing either field; undefined when nothing is missing. */
121
121
  export function ownershipWarning(provider, id, account) {
@@ -89,7 +89,7 @@ export function claudeIdentityDiffers(a, b) {
89
89
  }
90
90
  /** The operator command that lifts a recorded quota hold. */
91
91
  export function clearQuotaCommand(provider, accountId) {
92
- return `hq lanes accounts clear-quota ${provider} ${accountId}`;
92
+ return `hq runners accounts clear-quota ${provider} ${accountId}`;
93
93
  }
94
94
  export const AUTH_JSON_NAME = "auth.json";
95
95
  export const CLAUDE_CREDENTIALS_NAME = ".credentials.json";