@indigoai-us/hq-cli 5.345.208 → 5.345.210

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 (126) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/assets/scaffold/core/scripts/derive-trigger-facts.sh +22 -3
  3. package/dist/command-catalog.generated.d.ts +33 -8
  4. package/dist/command-catalog.generated.js +40 -8
  5. package/dist/command-registration-plan.d.ts +2 -2
  6. package/dist/command-registration-plan.js +1 -1
  7. package/dist/commands/access.js +11 -5
  8. package/dist/commands/agents.d.ts +8 -0
  9. package/dist/commands/agents.js +5 -0
  10. package/dist/commands/bot.d.ts +8 -0
  11. package/dist/commands/bot.js +67 -7
  12. package/dist/commands/channels.js +4 -0
  13. package/dist/commands/cloud.d.ts +83 -2
  14. package/dist/commands/cloud.js +161 -31
  15. package/dist/commands/company.d.ts +9 -0
  16. package/dist/commands/company.js +44 -14
  17. package/dist/commands/core-checkpoint-native.js +21 -0
  18. package/dist/commands/core-derive-trigger-facts-native.js +14 -3
  19. package/dist/commands/core-generate-workers-registry-fast.d.ts +1 -1
  20. package/dist/commands/core-generate-workers-registry-fast.js +7 -1
  21. package/dist/commands/core-job-run-native.d.ts +8 -0
  22. package/dist/commands/core-job-run-native.js +11 -3
  23. package/dist/commands/core-jobs-native.js +1 -1
  24. package/dist/commands/core-register-project-native.js +31 -1
  25. package/dist/commands/core-scan-packages-fast.d.ts +1 -1
  26. package/dist/commands/core-scan-packages-fast.js +8 -1
  27. package/dist/commands/core.js +12 -3
  28. package/dist/commands/dm-attach.d.ts +10 -0
  29. package/dist/commands/dm-attach.js +33 -5
  30. package/dist/commands/integrations-connect.js +47 -2
  31. package/dist/commands/lanes-session-start.d.ts +17 -0
  32. package/dist/commands/lanes-session-start.js +281 -13
  33. package/dist/commands/lanes-watch.js +11 -3
  34. package/dist/commands/lanes.d.ts +4 -0
  35. package/dist/commands/lanes.js +95 -22
  36. package/dist/commands/library.d.ts +10 -0
  37. package/dist/commands/library.js +30 -3
  38. package/dist/commands/meetings.d.ts +42 -0
  39. package/dist/commands/meetings.js +157 -12
  40. package/dist/commands/mesh.js +3 -0
  41. package/dist/commands/monitor.d.ts +6 -0
  42. package/dist/commands/monitor.js +29 -19
  43. package/dist/commands/onboard.js +8 -1
  44. package/dist/commands/sources.js +7 -3
  45. package/dist/index.js +9 -0
  46. package/dist/lanes-monitor-check-argv.d.ts +1 -1
  47. package/dist/lanes-monitor-check-argv.js +2 -2
  48. package/dist/lanes-session-start-argv.d.ts +4 -1
  49. package/dist/lanes-session-start-argv.js +5 -2
  50. package/dist/lib/bot/fleet-daemon.d.ts +101 -0
  51. package/dist/lib/bot/fleet-daemon.js +227 -0
  52. package/dist/lib/bot/fleet-local.d.ts +26 -0
  53. package/dist/lib/bot/fleet-local.js +51 -2
  54. package/dist/lib/bot/index.d.ts +1 -0
  55. package/dist/lib/bot/index.js +1 -0
  56. package/dist/lib/bot/jobs/hot-signal-sync.d.ts +4 -0
  57. package/dist/lib/bot/jobs/hot-signal-sync.js +8 -1
  58. package/dist/lib/bot/log.js +3 -1
  59. package/dist/lib/bot/probe.js +2 -0
  60. package/dist/lib/bot/run.js +28 -3
  61. package/dist/lib/bot/runtime-failure.d.ts +4 -2
  62. package/dist/lib/bot/runtime-failure.js +9 -1
  63. package/dist/lib/bot/status.d.ts +17 -0
  64. package/dist/lib/bot/status.js +53 -2
  65. package/dist/lib/capacity/collectors/claude-oauth.d.ts +5 -5
  66. package/dist/lib/capacity/collectors/claude-oauth.js +6 -6
  67. package/dist/lib/core-utils/native-scaffold-help.d.ts +16 -0
  68. package/dist/lib/core-utils/native-scaffold-help.js +26 -0
  69. package/dist/lib/core-utils/session-company.d.ts +25 -8
  70. package/dist/lib/core-utils/session-company.js +59 -17
  71. package/dist/lib/daemon/catalog.d.ts +25 -1
  72. package/dist/lib/daemon/catalog.js +29 -2
  73. package/dist/lib/daemon/run.d.ts +0 -1
  74. package/dist/lib/daemon/run.js +3 -11
  75. package/dist/lib/daemon/server.js +26 -7
  76. package/dist/lib/daemon/supervisor.js +1 -1
  77. package/dist/lib/daemon/tools.js +17 -1
  78. package/dist/lib/db/sqlite-binding.js +2 -1
  79. package/dist/lib/doctor/checks/bots.d.ts +2 -0
  80. package/dist/lib/doctor/checks/bots.js +11 -0
  81. package/dist/lib/doctor/checks/runtime-health.js +3 -2
  82. package/dist/lib/doctor/checks/work-context.js +5 -2
  83. package/dist/lib/hook-engine/resolve.d.ts +1 -1
  84. package/dist/lib/hook-engine/resolve.js +4 -1
  85. package/dist/lib/hot-channels/adapters/meeting-providers.d.ts +2 -0
  86. package/dist/lib/hot-channels/adapters/meeting-providers.js +13 -2
  87. package/dist/lib/lanes/index.d.ts +1 -1
  88. package/dist/lib/lanes/index.js +1 -1
  89. package/dist/lib/lanes/monitor.d.ts +14 -0
  90. package/dist/lib/lanes/monitor.js +51 -10
  91. package/dist/lib/lanes/outpost-dispatch.d.ts +3 -0
  92. package/dist/lib/lanes/outpost-dispatch.js +1 -0
  93. package/dist/lib/lanes/store.d.ts +1 -1
  94. package/dist/lib/lanes/store.js +2 -1
  95. package/dist/lib/mesh/client.js +7 -1
  96. package/dist/lib/mesh/live/backfill-held.d.ts +3 -0
  97. package/dist/lib/mesh/live/backfill-held.js +167 -7
  98. package/dist/lib/mesh/live/flush.d.ts +7 -0
  99. package/dist/lib/mesh/live/flush.js +10 -1
  100. package/dist/lib/monitor.d.ts +9 -0
  101. package/dist/lib/monitor.js +33 -7
  102. package/dist/lib/onboarding/orchestrator.js +269 -132
  103. package/dist/lib/onboarding/types.d.ts +2 -0
  104. package/dist/lib/scaffold-cli-floor.js +2 -1
  105. package/dist/lib/signals/failure-alert.js +3 -1
  106. package/dist/lib/work-context/organize.d.ts +6 -0
  107. package/dist/lib/work-context/organize.js +28 -0
  108. package/dist/lib/work-context/paths.d.ts +9 -0
  109. package/dist/lib/work-context/paths.js +15 -0
  110. package/dist/lib/work-context/prd-sync.js +2 -1
  111. package/dist/runners-alias.d.ts +54 -0
  112. package/dist/runners-alias.js +86 -0
  113. package/dist/utils/install-tree-torn.js +5 -3
  114. package/dist/utils/npm-install-flags.d.ts +27 -0
  115. package/dist/utils/npm-install-flags.js +68 -0
  116. package/dist/utils/package-use-lease.js +1 -1
  117. package/dist/utils/qmd-native-binding-error.js +2 -1
  118. package/dist/utils/self-update.js +2 -1
  119. package/dist/utils/staged-install.js +2 -1
  120. package/dist/utils/staged-npm-install.js +2 -1
  121. package/dist/utils/upload-author.d.ts +2 -1
  122. package/dist/utils/upload-author.js +9 -5
  123. package/dist/utils/version-check.js +2 -1
  124. package/dist/utils/version-gate.js +7 -6
  125. package/package.json +7 -7
  126. package/scripts/install-hook-engine.mjs +7 -3
@@ -12,12 +12,12 @@ function workTrackingFromBody(body) {
12
12
  : null;
13
13
  }
14
14
  /**
15
- * Read both switches from GET /company-settings (owner or admin only). The
16
- * server returns effective values, so an absent field means the default
17
- * (registry off, live on).
15
+ * Read the owner/admin settings from GET /company-settings. The server returns
16
+ * effective values, so an absent field means the default (registry off, live
17
+ * on, ontology gardener off).
18
18
  * A refused or failed read returns null rather than a guess.
19
19
  */
20
- async function readWorkTrackingSettings(token, companyUid) {
20
+ async function readOwnerSettings(token, companyUid) {
21
21
  try {
22
22
  const res = await vaultApiFetch({
23
23
  token,
@@ -30,12 +30,30 @@ async function readWorkTrackingSettings(token, companyUid) {
30
30
  return {
31
31
  workRegistryEnabled: body.workRegistryEnabled === true,
32
32
  workMeshLiveEnabled: body.workMeshLiveEnabled !== false,
33
+ ontologyEnabled: body.ontologyEnabled === true,
33
34
  };
34
35
  }
35
36
  catch {
36
37
  return null;
37
38
  }
38
39
  }
40
+ /**
41
+ * What to tell the reader when the cloud ontology gardener is off. The
42
+ * gardener is opt-in per company (default off), and while it is off every
43
+ * scheduled or knowledge-push run is a silent no-op: no `ontology/`,
44
+ * `signals/` or `company-brief.md` is ever built in the company vault.
45
+ * Nothing else tells an owner that, so `settings get` says it and names the
46
+ * command that turns it on.
47
+ */
48
+ export function ontologyNextSteps(companySlug, ontologyEnabled) {
49
+ if (ontologyEnabled)
50
+ return [];
51
+ return [
52
+ `The cloud ontology gardener is off for ${companySlug}, so HQ does not build a cloud ontology ` +
53
+ "or company brief from its knowledge. An owner can turn it on with: " +
54
+ `hq company --company ${companySlug} settings set --ontology-enabled true`,
55
+ ];
56
+ }
39
57
  /** Plain next steps after a work tracking switch was set, from the effective settings. */
40
58
  export function workTrackingNextSteps(companySlug, settings) {
41
59
  const command = `hq company --company ${companySlug} settings`;
@@ -177,7 +195,7 @@ export function registerCompanyCommand(program) {
177
195
  // from the PUT response when it echoes both, otherwise from a GET.
178
196
  const resBody = (await res.json().catch(() => ({})));
179
197
  const effective = workTrackingFromBody(resBody) ??
180
- (await readWorkTrackingSettings(token, companyUid));
198
+ (await readOwnerSettings(token, companyUid));
181
199
  for (const line of workTrackingNextSteps(companySlug, effective)) {
182
200
  console.log(line);
183
201
  }
@@ -192,7 +210,8 @@ export function registerCompanyCommand(program) {
192
210
  .command("get")
193
211
  .description("Show whether the checkpoint Stop gate is on for this company " +
194
212
  "(GET /company-settings/checkpoint-gate; any member may read it) and, " +
195
- "for an owner or admin, the two work tracking switches (GET /company-settings).")
213
+ "for an owner or admin, the two work tracking switches and whether the " +
214
+ "cloud ontology gardener is on (GET /company-settings).")
196
215
  .option("--json", "Print the result as JSON")
197
216
  .action(async (opts) => {
198
217
  try {
@@ -222,24 +241,35 @@ export function registerCompanyCommand(program) {
222
241
  console.error(chalk.red("Failed to read company settings: no checkpointGateEnabled in the response."));
223
242
  process.exit(1);
224
243
  }
225
- // The work tracking switches are only on the owner/admin settings
226
- // route. A refused or failed read is reported as unknown, not guessed.
227
- const workTracking = await readWorkTrackingSettings(token, companyUid);
244
+ // The work tracking switches and the ontology gardener switch are only
245
+ // on the owner/admin settings route. A refused or failed read is
246
+ // reported as unknown, not guessed.
247
+ const ownerSettings = await readOwnerSettings(token, companyUid);
228
248
  if (opts.json) {
229
249
  console.log(JSON.stringify({
230
250
  company: companySlug,
231
251
  checkpointGateEnabled: enabled,
232
- workRegistryEnabled: workTracking?.workRegistryEnabled ?? null,
233
- workMeshLiveEnabled: workTracking?.workMeshLiveEnabled ?? null,
252
+ workRegistryEnabled: ownerSettings?.workRegistryEnabled ?? null,
253
+ workMeshLiveEnabled: ownerSettings?.workMeshLiveEnabled ?? null,
254
+ ontologyEnabled: ownerSettings?.ontologyEnabled ?? null,
234
255
  }));
235
256
  }
236
257
  else {
237
258
  console.log(`checkpointGateEnabled=${enabled}`);
238
- for (const key of ["workRegistryEnabled", "workMeshLiveEnabled"]) {
239
- console.log(workTracking
240
- ? `${key}=${workTracking[key]}`
259
+ for (const key of [
260
+ "workRegistryEnabled",
261
+ "workMeshLiveEnabled",
262
+ "ontologyEnabled",
263
+ ]) {
264
+ console.log(ownerSettings
265
+ ? `${key}=${ownerSettings[key]}`
241
266
  : `${key}=unknown (only the company owner or an admin can read this setting)`);
242
267
  }
268
+ if (ownerSettings) {
269
+ for (const line of ontologyNextSteps(companySlug, ownerSettings.ontologyEnabled)) {
270
+ console.log(line);
271
+ }
272
+ }
243
273
  }
244
274
  }
245
275
  catch (err) {
@@ -22,6 +22,23 @@ const CODEX_SIBLING_MODEL = "gpt-5.6-terra";
22
22
  const CODEX_SIBLING_REASONING_EFFORT = "medium";
23
23
  const CLAUDE_SIBLING_MODEL = "claude-sonnet-5";
24
24
  const CLAUDE_SIBLING_EFFORT = "medium";
25
+ /**
26
+ * Context a headless maintenance run never uses. A `claude -p` sibling at the
27
+ * HQ root otherwise starts with the whole interactive context: the listing of
28
+ * every skill (~30 KB at a 255-skill HQ), every MCP connector's deferred-tool
29
+ * names and server instructions (~24 KB), and the chat output style meant for
30
+ * a human reader (~16 KB). The sibling then pays for that context again on
31
+ * every one of its ~50-80 model calls, which made it about 17% of a team-plan
32
+ * user's token use (feedback_8e62a685). It reads skill files by path, calls no
33
+ * MCP tool, and has no chat reader, so these flags drop only dead weight.
34
+ * Settings files, CLAUDE.md and hooks (the HQ safety boundary) still load.
35
+ */
36
+ const CLAUDE_SIBLING_LEAN_CONTEXT_ARGS = [
37
+ "--disable-slash-commands",
38
+ "--strict-mcp-config",
39
+ "--settings",
40
+ JSON.stringify({ outputStyle: "default" }),
41
+ ];
25
42
  const GROK_SIBLING_MODEL = "grok-4.6";
26
43
  const GROK_SIBLING_EFFORT = "medium";
27
44
  /**
@@ -172,6 +189,9 @@ report instead of guessing.
172
189
  or tokens from the transcript. If .claude/skills/checkpoint/SKILL.md exists
173
190
  under this HQ root, read it and follow it wherever it goes beyond these instructions;
174
191
  the write bounds below always win over the skill text.
192
+ Slash commands are unavailable in this run. Where that skill says to call
193
+ /learn or run /document-release, do not try the command; do that work by
194
+ path as steps 3 and 6 describe.
175
195
  2. Upgrade the thread file named in the payload IN PLACE: verify/repair its
176
196
  JSON; fill git.remote_url, git.initial_commit, git.commits_made, and
177
197
  git.knowledge_repos by scanning core/knowledge/public/*,
@@ -1012,6 +1032,7 @@ export function siblingArgs(backend, prompt) {
1012
1032
  CLAUDE_SIBLING_MODEL,
1013
1033
  "--effort",
1014
1034
  CLAUDE_SIBLING_EFFORT,
1035
+ ...CLAUDE_SIBLING_LEAN_CONTEXT_ARGS,
1015
1036
  // `acceptEdits` auto-approves edits only. At the HQ root the scaffold
1016
1037
  // settings make Bash "ask", so a terminal command — the git scan, the
1017
1038
  // journal helper, the queue-draining `mv` — hits an approval gate with
@@ -453,11 +453,15 @@ function computeOutput(options) {
453
453
  throw new ShellFallbackRequired("unsupported argv");
454
454
  const event = args[0] ?? "";
455
455
  const withAssistantIntent = args[1] === "--with-assistant-intent";
456
- if (args.length === 2 && !withAssistantIntent)
456
+ const withCommandFacts = args[1] === "--with-command-facts";
457
+ if (args.length === 2 && !withAssistantIntent && !withCommandFacts)
457
458
  throw new ShellFallbackRequired("unsupported argv");
458
459
  // The shell accepts unknown event names and emits the baseline `always`
459
460
  // fact (plus any static session facts); it does not validate the event.
460
461
  const paired = withAssistantIntent && (event === "PreToolUse" || event === "UserPromptSubmit");
462
+ // PostToolUse with its command facts (the PreToolUse set of the same
463
+ // payload) in one call, so the policy hook needs one launch (feedback_45868a9c).
464
+ const pairedCommand = withCommandFacts && event === "PostToolUse";
461
465
  const env = effectiveEnvironment(options);
462
466
  const initialEnv = { ...process.env, ...(options.env ?? {}) };
463
467
  const jqAvailable = options.jqAvailable ?? commandOnPath("jq", env);
@@ -469,6 +473,8 @@ function computeOutput(options) {
469
473
  payload = parsePayload(options.stdin || "{}");
470
474
  const payloadCwd = payload.cwd || env.CLAUDE_PROJECT_DIR || options.cwd;
471
475
  const company = resolveCompanyFact(payload.cwd, payload.sessionId, options.hqRoot, options.cwd, env);
476
+ // Both records of a paired call read the same cwd, so the branch is read once.
477
+ let cwdBranch;
472
478
  const derive = (kind) => {
473
479
  const facts = ["always"];
474
480
  let branch = "";
@@ -518,12 +524,17 @@ function computeOutput(options) {
518
524
  const shellCwd = usesPwdFallback ? payloadCwd.replaceAll("\\", "/") : payloadCwd;
519
525
  if (shellCwd.includes("repos/public/") || shellCwd.includes("repos/private/"))
520
526
  facts.push("repo");
521
- branch = options.gitBranch ?? readBranch(payloadCwd, env);
527
+ cwdBranch ??= options.gitBranch ?? readBranch(payloadCwd, env);
528
+ branch = cwdBranch;
522
529
  }
523
530
  return normalizeFacts(facts, branch, options.cwd, env);
524
531
  };
525
532
  const primary = derive(event);
526
- return paired ? `${primary}\n${derive("AssistantIntent")}\n` : `${primary}\n`;
533
+ if (paired)
534
+ return `${primary}\n${derive("AssistantIntent")}\n`;
535
+ if (pairedCommand)
536
+ return `${primary}\n${derive("PreToolUse")}\n`;
537
+ return `${primary}\n`;
527
538
  }
528
539
  function shellFallback(options) {
529
540
  const env = { ...process.env, ...(options.env ?? {}) };
@@ -1,2 +1,2 @@
1
- export declare function runGenerateWorkersRegistryFast(_args: string[], _stdin: string, _cwd: string, hqRoot?: string): number;
1
+ export declare function runGenerateWorkersRegistryFast(args: string[], _stdin: string, _cwd: string, hqRoot?: string): number;
2
2
  //# sourceMappingURL=core-generate-workers-registry-fast.d.ts.map
@@ -1,5 +1,11 @@
1
1
  import { generateWorkersRegistry } from "../lib/workers-registry/index.js";
2
- export function runGenerateWorkersRegistryFast(_args, _stdin, _cwd, hqRoot) {
2
+ import { GENERATE_WORKERS_REGISTRY_SUMMARY, isNativeScaffoldHelpRequest, nativeScaffoldUsage, } from "../lib/core-utils/native-scaffold-help.js";
3
+ export function runGenerateWorkersRegistryFast(args, _stdin, _cwd, hqRoot) {
4
+ // `--help` must not regenerate registry.yaml (feedback_83ae2e72).
5
+ if (isNativeScaffoldHelpRequest(args)) {
6
+ process.stdout.write(nativeScaffoldUsage("generate-workers-registry", GENERATE_WORKERS_REGISTRY_SUMMARY));
7
+ return 0;
8
+ }
3
9
  return generateWorkersRegistry(hqRoot ?? process.cwd()).status;
4
10
  }
5
11
  //# sourceMappingURL=core-generate-workers-registry-fast.js.map
@@ -42,6 +42,14 @@ export type JobRunDependencies = {
42
42
  export declare function spawnProcess(request: ProcessRequest): Promise<ProcessResult>;
43
43
  /** Holds the same kernel flock(2) lock used by the shell companion. */
44
44
  export declare function acquireFlock(file: string, env?: NodeJS.ProcessEnv): Promise<LockLease>;
45
+ /**
46
+ * feedback_65ee9e51: a scheduled job runs with nobody watching, so any `hq sync`
47
+ * it starts (the agent's own tool calls, remediation pulls) must not delete a
48
+ * file another member created. hq-cloud reads this variable.
49
+ */
50
+ export declare const JOB_UNATTENDED_SYNC_ENV: {
51
+ readonly HQ_SYNC_UNATTENDED: "1";
52
+ };
45
53
  export declare function runJob(argv: string[], hqRootOverride?: string, injected?: Partial<JobRunDependencies>): Promise<number>;
46
54
  export declare function registerCoreJobRunCommand(job: Command): void;
47
55
  export {};
@@ -933,7 +933,9 @@ async function runRemoteClaude(jobId, runtime, prompt, runCwd, timeoutSeconds, s
933
933
  }
934
934
  deps.appendFile(logFile, `surface=remote remote_name=${remoteName} tmux_session=${session} done_file=${doneFile}\n`);
935
935
  const remoteArgs = ["--remote-control", remoteName, "--permission-mode", "bypassPermissions", "--dangerously-skip-permissions", remotePrompt];
936
- const tmuxCommand = [process.execPath, REMOTE_LAUNCHER, exitFile, ...remoteArgs].map(bashPrintfQuote).join(" ");
936
+ // An already-running tmux server does not pass our env to the pane, so the
937
+ // unattended-sync marker rides on the command itself.
938
+ const tmuxCommand = `HQ_SYNC_UNATTENDED=1 ${[process.execPath, REMOTE_LAUNCHER, exitFile, ...remoteArgs].map(bashPrintfQuote).join(" ")}`;
937
939
  const tmuxEnv = deps.env.HQ_JOB_RUN_STUBS === "1"
938
940
  ? { ...deps.env, HQ_JOB_RUN_REMOTE_DONE_FILE: doneFile, HQ_JOB_RUN_REMOTE_EXIT_FILE: exitFile }
939
941
  : deps.env;
@@ -1052,9 +1054,15 @@ async function recordSkip(jobId, jobName, runtime, skipReason, failureClass, act
1052
1054
  void logDir;
1053
1055
  return 0;
1054
1056
  }
1057
+ /**
1058
+ * feedback_65ee9e51: a scheduled job runs with nobody watching, so any `hq sync`
1059
+ * it starts (the agent's own tool calls, remediation pulls) must not delete a
1060
+ * file another member created. hq-cloud reads this variable.
1061
+ */
1062
+ export const JOB_UNATTENDED_SYNC_ENV = { HQ_SYNC_UNATTENDED: "1" };
1055
1063
  export async function runJob(argv, hqRootOverride, injected) {
1056
- const env = injected?.env ?? process.env;
1057
- const deps = { ...defaultDependencies(env), ...injected };
1064
+ const env = { ...(injected?.env ?? process.env), ...JOB_UNATTENDED_SYNC_ENV };
1065
+ const deps = { ...defaultDependencies(env), ...injected, env };
1058
1066
  const args = parseArgs(argv);
1059
1067
  if (args.help) {
1060
1068
  emitUsage();
@@ -769,7 +769,7 @@ function systemdQuote(value) {
769
769
  function serviceUnit(root, id) {
770
770
  const pathValue = systemdQuote(`PATH=${servicePathValue()}`);
771
771
  const runner = path.resolve(root, "core/scripts/hq-job-run.sh");
772
- return `# Generated by outpost-jobs-reconcile.sh — disposable derived state. Do not edit.\n[Unit]\nDescription=HQ Outpost scheduled job: ${id}\nDocumentation=file://${root}/core/knowledge/public/hq-core/outpost-jobs-spec.md\nAfter=network-online.target\nWants=network-online.target\n\n[Service]\nType=oneshot\nEnvironment=HQ_ROOT=${root}\nEnvironment=${pathValue}\nExecStart=${runner} --hq-root ${root} --job-id ${id}\nNice=10\n\n[Install]\nWantedBy=default.target\n`;
772
+ return `# Generated by outpost-jobs-reconcile.sh — disposable derived state. Do not edit.\n[Unit]\nDescription=HQ Outpost scheduled job: ${id}\nDocumentation=file://${root}/core/knowledge/public/hq-core/outpost-jobs-spec.md\nAfter=network-online.target\nWants=network-online.target\n\n[Service]\nType=oneshot\nEnvironment=HQ_ROOT=${root}\nEnvironment=${pathValue}\nEnvironment=HQ_SYNC_UNATTENDED=1\nExecStart=${runner} --hq-root ${root} --job-id ${id}\nNice=10\n\n[Install]\nWantedBy=default.target\n`;
773
773
  }
774
774
  function timerUnit(id, onCalendar, randomize, root) {
775
775
  return `# Generated by outpost-jobs-reconcile.sh — disposable derived state. Do not edit.\n[Unit]\nDescription=HQ Outpost scheduled job timer: ${id}\nDocumentation=file://${root}/core/knowledge/public/hq-core/outpost-jobs-spec.md\n\n[Timer]\nOnCalendar=${onCalendar}\nPersistent=true\nRandomizedDelaySec=${randomize}\nUnit=hq-job-${id}.service\n\n[Install]\nWantedBy=timers.target\n`;
@@ -168,10 +168,38 @@ function markPending(company, project, deps) {
168
168
  }
169
169
  atomicJqWrite(board, document, deps, true);
170
170
  }
171
+ // Refuse when more than one Board entry matches the project being registered.
172
+ // Updating every match used to keep a duplicate id alive on the board
173
+ // (feedback_2b8e4bc8). Mirrors refuse_ambiguous_board_match in
174
+ // core/scripts/register-project.sh, which prints the same message.
175
+ function ambiguousBoardMatch(company, project, deps, matches) {
176
+ const board = boardPath(company, deps);
177
+ if (!deps.fs.existsSync(board))
178
+ return null;
179
+ let rows;
180
+ // The shell skips the check when jq cannot read the board; later steps report that error.
181
+ try {
182
+ rows = projectRows(boardData(company, board, deps));
183
+ }
184
+ catch {
185
+ return null;
186
+ }
187
+ const ids = rows.filter(matches)
188
+ .map((row) => (row.id === null || row.id === undefined || row.id === false ? "(no id)" : typeof row.id === "string" ? row.id : JSON.stringify(row.id)).replace(/\r/gu, ""))
189
+ .filter((id) => id !== "");
190
+ if (ids.length <= 1)
191
+ return null;
192
+ return errorResult(`registration refused: ${ids.length} Board entries in companies/${company}/board.json match ${project} (ids: ${ids.join(", ")}). Remove or renumber the duplicates so one entry remains, then re-run. \`bash core/scripts/board-project-id.sh check ${company}\` lists every duplicate id.`);
193
+ }
171
194
  function ensureOne(company, project, deps) {
172
195
  const prd = path.join(deps.root, "companies", company, "projects", project, "prd.json");
196
+ const meshProject = meshProjectIdForPrd(company, project, deps);
173
197
  if (!deps.fs.existsSync(prd))
174
198
  return errorResult(`registration incomplete: missing ${prd}`);
199
+ const prdRel = `companies/${company}/projects/${project}/prd.json`;
200
+ const ambiguous = ambiguousBoardMatch(company, project, deps, (row) => matchesProject(row, project, prdRel, meshProject));
201
+ if (ambiguous)
202
+ return ambiguous;
175
203
  if (!runHelpProbe(deps)) {
176
204
  try {
177
205
  markPending(company, project, deps);
@@ -179,7 +207,6 @@ function ensureOne(company, project, deps) {
179
207
  catch { /* legacy jq/write errors remain a failed registration */ }
180
208
  return errorResult(`hq-cli ${MIN_HQ_CLI} or newer is required; ${company}/${project} stays local until then`);
181
209
  }
182
- const meshProject = meshProjectIdForPrd(company, project, deps);
183
210
  // The shell builds this argument from its raw HQ_ROOT plus POSIX separators.
184
211
  // On Git Bash that preserves a Win32 drive prefix and appends `/companies/...`.
185
212
  const hqPrd = process.platform === "win32"
@@ -248,6 +275,9 @@ function registerBrainstorm(company, project, deps) {
248
275
  const board = boardPath(company, deps);
249
276
  if (!deps.fs.existsSync(board))
250
277
  return errorResult(`registration incomplete: missing ${board}`);
278
+ const ambiguous = ambiguousBoardMatch(company, project, deps, (item) => item.id === project || item.mesh_project_id === project);
279
+ if (ambiguous)
280
+ return ambiguous;
251
281
  const document = boardData(company, board, deps);
252
282
  const row = projectRows(document).find((item) => item.id === project || item.mesh_project_id === project);
253
283
  const title = jqString(jqOr(asRecord(row)?.title, ""));
@@ -1,2 +1,2 @@
1
- export declare function runScanPackagesFast(_args: string[], _stdin: string, _cwd: string, hqRoot?: string): number;
1
+ export declare function runScanPackagesFast(args: string[], _stdin: string, _cwd: string, hqRoot?: string): number;
2
2
  //# sourceMappingURL=core-scan-packages-fast.d.ts.map
@@ -1,5 +1,12 @@
1
1
  import { scanPackages } from "../lib/scan-packages/index.js";
2
- export function runScanPackagesFast(_args, _stdin, _cwd, hqRoot) {
2
+ import { isNativeScaffoldHelpRequest, nativeScaffoldUsage, SCAN_PACKAGES_SUMMARY, } from "../lib/core-utils/native-scaffold-help.js";
3
+ export function runScanPackagesFast(args, _stdin, _cwd, hqRoot) {
4
+ // `--help` used to run the scan (and re-create pack links) because neither
5
+ // route looked at its arguments (feedback_83ae2e72).
6
+ if (isNativeScaffoldHelpRequest(args)) {
7
+ process.stdout.write(nativeScaffoldUsage("scan-packages", SCAN_PACKAGES_SUMMARY));
8
+ return 0;
9
+ }
3
10
  return scanPackages(hqRoot ?? process.cwd(), { quiet: process.env.HQ_SCAN_QUIET === "1" }).status;
4
11
  }
5
12
  //# sourceMappingURL=core-scan-packages-fast.js.map
@@ -60,6 +60,7 @@ import { CompanyIndexUserError, renderIndexTarget } from "../lib/index-render/in
60
60
  import { planScopedRebuild, SESSION_SCOPE_HELP } from "../lib/index-render/session-scope.js";
61
61
  import { generateWorkersRegistry } from "../lib/workers-registry/index.js";
62
62
  import { scanPackages } from "../lib/scan-packages/index.js";
63
+ import { GENERATE_WORKERS_REGISTRY_SUMMARY, isNativeScaffoldHelpRequest, nativeScaffoldUsage, SCAN_PACKAGES_SUMMARY, } from "../lib/core-utils/native-scaffold-help.js";
63
64
  import { detectStaleCorePolicyMirror } from "../lib/core-utils/detect-stale-core-policy-mirror.js";
64
65
  import { summarizeHqStatus } from "../lib/core-utils/hq-status-summary.js";
65
66
  import { ontologyReadmeDrift } from "../lib/core-utils/ontology-readme-drift.js";
@@ -114,13 +115,13 @@ export const NATIVE_SCAFFOLD_COMMANDS = [
114
115
  name: "generate-workers-registry",
115
116
  asset: "core/scripts/generate-workers-registry.sh",
116
117
  root: "live",
117
- summary: "Regenerate the derived workers registry",
118
+ summary: GENERATE_WORKERS_REGISTRY_SUMMARY,
118
119
  },
119
120
  {
120
121
  name: "scan-packages",
121
122
  asset: "core/scripts/scan-packages.sh",
122
123
  root: "live",
123
- summary: "Wire installed content-pack contributions",
124
+ summary: SCAN_PACKAGES_SUMMARY,
124
125
  },
125
126
  ];
126
127
  /**
@@ -574,7 +575,15 @@ export function registerCoreCommands(program) {
574
575
  .allowExcessArguments()
575
576
  .helpOption(false)
576
577
  .argument("[args...]", "arguments accepted for shell ABI compatibility")
577
- .action(() => {
578
+ .action((args = [], _opts, cmd) => {
579
+ // helpOption(false) keeps shell-ABI flags flowing through, so `--help`
580
+ // must be caught here or it runs the command (feedback_83ae2e72).
581
+ // `cmd.args` keeps unknown flags in order, as runCommand below relies on.
582
+ const operands = cmd.args.length > 0 ? cmd.args : args;
583
+ if (isNativeScaffoldHelpRequest(operands)) {
584
+ process.stdout.write(nativeScaffoldUsage(entry.name, entry.summary));
585
+ return;
586
+ }
578
587
  const scope = core.opts();
579
588
  const hqRoot = resolveLiveRoot({ hqRoot: scope.hqRoot });
580
589
  const result = entry.name === "generate-workers-registry"
@@ -56,6 +56,16 @@ export declare function buildChatAttachmentKey(args: {
56
56
  name: string;
57
57
  now: Date;
58
58
  }): string;
59
+ /**
60
+ * SHA-256 of the bytes that will be PUT. hq-pro signs `x-amz-checksum-sha256`
61
+ * only when `checksumSha256` (base64) matches `hq-content-sha256` (hex). Vault
62
+ * buckets use S3 Object Lock, which refuses a PUT without that signed checksum
63
+ * ("Content-MD5 OR x-amz-checksum- HTTP header is required").
64
+ */
65
+ export declare function attachmentPutIntegrity(bytes: Buffer): {
66
+ checksumSha256: string;
67
+ contentSha256: string;
68
+ };
59
69
  /**
60
70
  * Check every `--attach` path before anything touches the network: it must
61
71
  * exist, be a regular file, and fit the server cap; at most five per message.
@@ -18,11 +18,13 @@
18
18
  *
19
19
  * Network is injected (`presign`, `put`) so the sequence is unit-testable.
20
20
  */
21
+ import { createHash } from "node:crypto";
21
22
  import { readFileSync, statSync } from "node:fs";
22
23
  import { Readable } from "node:stream";
23
24
  import path from "node:path";
24
25
  import { vaultApiFetch } from "../utils/vault-api.js";
25
26
  import { contentTypeFor, streamPut } from "./library-add.js";
27
+ import { CONTENT_SHA256_METADATA_KEY } from "./storage-offload.js";
26
28
  export const MAX_DM_ATTACHMENTS = 5;
27
29
  export const MAX_DM_ATTACHMENT_BYTES = 25 * 1024 * 1024;
28
30
  /** Reduce a local file name to one safe path component (mirrors the desktop app). */
@@ -56,6 +58,19 @@ function formatBytes(n) {
56
58
  return `${(n / 1024).toFixed(1)} KB`;
57
59
  return `${n} B`;
58
60
  }
61
+ /**
62
+ * SHA-256 of the bytes that will be PUT. hq-pro signs `x-amz-checksum-sha256`
63
+ * only when `checksumSha256` (base64) matches `hq-content-sha256` (hex). Vault
64
+ * buckets use S3 Object Lock, which refuses a PUT without that signed checksum
65
+ * ("Content-MD5 OR x-amz-checksum- HTTP header is required").
66
+ */
67
+ export function attachmentPutIntegrity(bytes) {
68
+ const contentSha256 = createHash("sha256").update(bytes).digest("hex");
69
+ return {
70
+ contentSha256,
71
+ checksumSha256: Buffer.from(contentSha256, "hex").toString("base64"),
72
+ };
73
+ }
59
74
  /**
60
75
  * Check every `--attach` path before anything touches the network: it must
61
76
  * exist, be a regular file, and fit the server cap; at most five per message.
@@ -113,13 +128,26 @@ export async function uploadDmAttachments(args) {
113
128
  const now = args.now ?? new Date();
114
129
  if (args.files.length === 0)
115
130
  return [];
116
- const planned = args.files.map((file) => ({
117
- file,
118
- key: buildChatAttachmentKey({ target: args.target, name: file.name, now }),
119
- }));
131
+ const planned = args.files.map((file) => {
132
+ const bytes = readFileSync(file.path);
133
+ if (bytes.length > MAX_DM_ATTACHMENT_BYTES) {
134
+ throw new Error(`Attachment too large: ${file.path} grew past the 25 MB limit after it was checked.`);
135
+ }
136
+ return {
137
+ file,
138
+ key: buildChatAttachmentKey({ target: args.target, name: file.name, now }),
139
+ integrity: attachmentPutIntegrity(bytes),
140
+ };
141
+ });
120
142
  const res = await deps.presign(args.token, {
121
143
  company: args.scopeUid,
122
- keys: planned.map((p) => ({ key: p.key, op: "put", contentType: p.file.contentType })),
144
+ keys: planned.map((p) => ({
145
+ key: p.key,
146
+ op: "put",
147
+ contentType: p.file.contentType,
148
+ checksumSha256: p.integrity.checksumSha256,
149
+ metadata: { [CONTENT_SHA256_METADATA_KEY]: p.integrity.contentSha256 },
150
+ })),
123
151
  });
124
152
  if (!res.ok) {
125
153
  const err = (await res.json().catch(() => ({})));
@@ -70,6 +70,19 @@ function isAccessKeyRequiredError(err) {
70
70
  err.code === DIRECT_MCP_AUTH_REJECTED_CODE &&
71
71
  err.oauthProtected !== true);
72
72
  }
73
+ /** Caller forced a non-OAuth mode; do not auto-switch into the browser flow. */
74
+ function forcedNonOAuthAuth(opts) {
75
+ return opts.auth === "key" || opts.auth === "none" || Boolean(opts.authHeader);
76
+ }
77
+ function oauthDespiteForcedKey(target, opts, err) {
78
+ const forced = opts.auth === "none" ? "--auth none" : opts.auth === "key" ? "--auth key" : "--auth-header";
79
+ return new IntegrationsCliError(`${target.label} did not accept an API key (${err.message}). ${forced} was set, so HQ did not start a browser sign-in. Re-run without ${forced} to use OAuth, or use a key this endpoint accepts.`, {
80
+ expected: true,
81
+ code: err.code,
82
+ status: err.status,
83
+ oauthProtected: err.oauthProtected,
84
+ });
85
+ }
73
86
  /**
74
87
  * hq-pro will not take our loopback callback, for either of the two reasons it
75
88
  * can refuse one:
@@ -1200,8 +1213,14 @@ async function connectApp(token, companyUid, app, opts, expectedRevivedConnectio
1200
1213
  }
1201
1214
  // Server-authoritative detection: the endpoint turned out to be
1202
1215
  // OAuth-protected, so run the browser flow instead of making the
1203
- // caller re-issue the command with --auth oauth.
1216
+ // caller re-issue the command with --auth oauth. An explicit --auth
1217
+ // key/none or --auth-header must not be silently overridden: the
1218
+ // Brandsearch connect (feedback_0bdcfff1) printed an OAuth URL after
1219
+ // --auth key --token-stdin, so the key path never finished.
1204
1220
  if (isOAuthRequiredError(err)) {
1221
+ if (forcedNonOAuthAuth(opts)) {
1222
+ throw oauthDespiteForcedKey(target, opts, err);
1223
+ }
1205
1224
  try {
1206
1225
  const result = await connectViaOAuth(token, companyUid, target, opts);
1207
1226
  if (result)
@@ -1542,6 +1561,7 @@ export function registerConnectCommands(integrations) {
1542
1561
  .option("--connect", "For a revoked row, run `connect <domain>` to re-add and revive it")
1543
1562
  .option("--personal", "With --connect: re-add it as your own personal connection")
1544
1563
  .option("--company-owned", "With --connect: re-add it as a connection the whole company owns")
1564
+ .option("--mcp-url <url>", "MCP endpoint for a custom app whose install never finished (no saved endpoint)")
1545
1565
  .option("--json", "Machine-readable output")
1546
1566
  .action(async (app, opts) => {
1547
1567
  // Same validation as `connect`. Without it a typo like `--auth oauth2`
@@ -1576,8 +1596,30 @@ export function registerConnectCommands(integrations) {
1576
1596
  await connectApp(token, companyUid, connectionDomain(connection), opts, connection.id);
1577
1597
  return;
1578
1598
  }
1579
- const url = connection.installation?.surface?.url;
1599
+ // A custom MCP connection (factory:<slug>) whose install failed keeps no
1600
+ // installation, so it has no saved endpoint. Refusing it outright left
1601
+ // the broken row with no CLI repair (feedback_558830a4). Re-installing
1602
+ // the same provider slug with the endpoint the caller supplies reuses
1603
+ // that row, the same way a saved endpoint does below.
1604
+ const savedUrl = connection.installation?.surface?.url;
1605
+ const factoryConnection = connection.provider.startsWith("factory:");
1606
+ if (opts.mcpUrl && savedUrl && opts.mcpUrl !== savedUrl) {
1607
+ throw new IntegrationsCliError(`${bareProvider(connection.provider)} already has a saved endpoint, so --mcp-url does not apply. ` +
1608
+ "Run the reconnect again without --mcp-url.", { expected: true });
1609
+ }
1610
+ if (opts.mcpUrl && !savedUrl && !factoryConnection) {
1611
+ throw new IntegrationsCliError(`${bareProvider(connection.provider)} is not a custom MCP connection, so --mcp-url does not apply.`, { expected: true });
1612
+ }
1613
+ const url = savedUrl ?? opts.mcpUrl;
1580
1614
  if (!url) {
1615
+ if (factoryConnection) {
1616
+ const arg = (value) => (/^[A-Za-z0-9_.:-]+$/.test(value) ? value : shellQuote(value));
1617
+ const selector = opts.connection
1618
+ ? `--connection ${arg(opts.connection)}`
1619
+ : `--provider ${arg(bareProvider(connection.provider))}`;
1620
+ throw new IntegrationsCliError(`${bareProvider(connection.provider)} has no saved MCP endpoint because its install never finished. ` +
1621
+ `Reconnect it with: hq integrations reconnect ${selector} --mcp-url <endpoint>`, { expected: true });
1622
+ }
1581
1623
  throw new IntegrationsCliError(`${bareProvider(connection.provider)} was not installed through the app catalog, so it cannot be reconnected from here.`, { expected: true });
1582
1624
  }
1583
1625
  // Re-installing the same endpoint is the reconnect: hq-pro serializes it
@@ -1623,6 +1665,9 @@ export function registerConnectCommands(integrations) {
1623
1665
  }
1624
1666
  catch (err) {
1625
1667
  if (isOAuthRequiredError(err)) {
1668
+ if (forcedNonOAuthAuth(opts)) {
1669
+ throw oauthDespiteForcedKey(target, opts, err);
1670
+ }
1626
1671
  const result = await connectViaOAuth(token, companyUid, target, opts);
1627
1672
  if (result)
1628
1673
  reportInstall(result, opts);
@@ -13,6 +13,23 @@ export interface SessionStartOptions {
13
13
  }
14
14
  /** Offline flag values older than this trigger one background registry read. */
15
15
  export declare const SESSION_START_FLAG_REFRESH_AFTER_MS: number;
16
+ /** How conduct runs lanes: in-session subagents, or detached CLI runners. */
17
+ export type ConductRunner = "subagent" | "runner";
18
+ /**
19
+ * Resolve `conduct.runner` from settings, personal then core per key. A missing
20
+ * file, a missing key, or an unknown value resolves to `subagent`.
21
+ */
22
+ export declare function conductRunnerFromSettings(root: string): ConductRunner;
23
+ /** True when the installed hq-core reads `conduct_runner: subagent|runner`. */
24
+ export declare function hqCoreReadsRunnerPin(root: string): boolean;
25
+ /** Logged once when conduct.runner is runner and the conduct-runners skill is not installed. */
26
+ export declare const CONDUCT_RUNNERS_CORE_MISSING_LINE = "hq runners session-start: conduct.runner is runner but .claude/skills/conduct-runners/conductor-core.md is missing; using .claude/skills/conduct/conductor-core.md";
27
+ /**
28
+ * Upper bound on one run of hq-core's conduct-runner-resolve.sh. hq-core's
29
+ * SessionStart hook gives the whole CLI 2 s, so the resolver gets a fraction of
30
+ * that: a stalled resolver costs the pin, and the inject block still prints.
31
+ */
32
+ export declare const CONDUCT_RUNNER_RESOLVE_TIMEOUT_MS = 500;
16
33
  /** Starts the CL-4 read-only orphan report once per host, without holding SessionStart open. */
17
34
  export declare function startSessionStartOrphanSweep(root: string, env?: NodeJS.ProcessEnv, spawnDetached?: typeof spawn, rootScoped?: boolean): void;
18
35
  /**