@indigoai-us/hq-cli 5.345.237 → 5.345.241

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 (115) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/assets/scaffold/core/scripts/hq-delegate-repo.sh +7 -1
  3. package/assets/scaffold/core/scripts/hq-delegate-secrets.sh +95 -20
  4. package/assets/scaffold/core/scripts/hq-delegate-transfer.sh +57 -9
  5. package/dist/command-catalog.generated.d.ts +185 -3
  6. package/dist/command-catalog.generated.js +228 -3
  7. package/dist/command-registration-plan.d.ts +6 -0
  8. package/dist/command-registration-plan.js +1 -0
  9. package/dist/commands/bot.d.ts +2 -0
  10. package/dist/commands/bot.js +23 -0
  11. package/dist/commands/cloud-off-gate.d.ts +2 -1
  12. package/dist/commands/cloud-off-gate.js +17 -4
  13. package/dist/commands/cloud.d.ts +17 -2
  14. package/dist/commands/cloud.js +126 -24
  15. package/dist/commands/core-delegate-w1b.js +35 -10
  16. package/dist/commands/core-delegate.d.ts +2 -1
  17. package/dist/commands/core-delegate.js +207 -48
  18. package/dist/commands/deploy-comments.js +8 -2
  19. package/dist/commands/deploy-events.d.ts +40 -0
  20. package/dist/commands/deploy-events.js +300 -0
  21. package/dist/commands/doctor.d.ts +4 -4
  22. package/dist/commands/doctor.js +2 -2
  23. package/dist/commands/feedback.js +2 -3
  24. package/dist/commands/keyed-sync-pull.d.ts +12 -0
  25. package/dist/commands/keyed-sync-pull.js +151 -0
  26. package/dist/commands/library-add.d.ts +5 -2
  27. package/dist/commands/library-add.js +22 -9
  28. package/dist/commands/mcp-registration.d.ts +4 -18
  29. package/dist/commands/mcp-registration.js +9 -29
  30. package/dist/commands/mesh.d.ts +4 -0
  31. package/dist/commands/mesh.js +25 -5
  32. package/dist/commands/pack-install.d.ts +2 -3
  33. package/dist/commands/pack-install.js +6 -8
  34. package/dist/commands/secrets.d.ts +3 -4
  35. package/dist/commands/secrets.js +3 -20
  36. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +307 -232
  37. package/dist/hq-cloud-sync-runner/package.json +1 -1
  38. package/dist/lib/agent-kit/inbox-state.d.ts +2 -1
  39. package/dist/lib/agent-kit/inbox-state.js +27 -3
  40. package/dist/lib/bot/api.d.ts +2 -1
  41. package/dist/lib/bot/api.js +2 -15
  42. package/dist/lib/bot/promote.d.ts +23 -0
  43. package/dist/lib/bot/promote.js +73 -0
  44. package/dist/lib/bot/promotion-hold-reconcile.d.ts +56 -0
  45. package/dist/lib/bot/promotion-hold-reconcile.js +155 -0
  46. package/dist/lib/capacity/collectors/claude-oauth.d.ts +0 -2
  47. package/dist/lib/capacity/collectors/claude-oauth.js +0 -5
  48. package/dist/lib/core-utils/delegate-helper-paths.d.ts +26 -0
  49. package/dist/lib/core-utils/delegate-helper-paths.js +33 -0
  50. package/dist/lib/daemon/jq-provision.d.ts +63 -0
  51. package/dist/lib/daemon/jq-provision.js +155 -0
  52. package/dist/lib/daemon/lanes-reconcile-guard.d.ts +4 -3
  53. package/dist/lib/daemon/lanes-reconcile-guard.js +4 -4
  54. package/dist/lib/daemon/mesh-owner.d.ts +4 -0
  55. package/dist/lib/daemon/mesh-owner.js +20 -0
  56. package/dist/lib/daemon/ops/policy.d.ts +3 -0
  57. package/dist/lib/daemon/ops/policy.js +32 -4
  58. package/dist/lib/daemon/run.d.ts +17 -1
  59. package/dist/lib/daemon/run.js +24 -3
  60. package/dist/lib/daemon/server.d.ts +6 -0
  61. package/dist/lib/daemon/server.js +5 -0
  62. package/dist/lib/daemon/verified-jq.d.ts +96 -0
  63. package/dist/lib/daemon/verified-jq.js +337 -0
  64. package/dist/lib/doctor/checks/jq.js +16 -0
  65. package/dist/lib/doctor/deep/executor.d.ts +7 -0
  66. package/dist/lib/doctor/deep/executor.js +1 -1
  67. package/dist/lib/doctor/deep/parity.js +1 -27
  68. package/dist/lib/doctor/deep/sandbox.d.ts +2 -2
  69. package/dist/lib/doctor/deep/sandbox.js +3 -19
  70. package/dist/lib/doctor/fix/refresh-sync-handoff.js +52 -21
  71. package/dist/lib/doctor/fixtures/discover.d.ts +2 -0
  72. package/dist/lib/doctor/fixtures/discover.js +1 -1
  73. package/dist/lib/doctor/json-output.d.ts +1 -1
  74. package/dist/lib/doctor/registry.d.ts +6 -7
  75. package/dist/lib/doctor/registry.js +6 -7
  76. package/dist/lib/doctor/report.d.ts +9 -10
  77. package/dist/lib/doctor/report.js +4 -4
  78. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  79. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  80. package/dist/lib/jq/install.d.ts +27 -0
  81. package/dist/lib/jq/install.js +156 -0
  82. package/dist/lib/lanes/outpost-dispatch.d.ts +1 -1
  83. package/dist/lib/lanes/outpost-dispatch.js +13 -13
  84. package/dist/lib/lanes/outpost-pruner-install.js +1 -1
  85. package/dist/lib/mesh/live/daemon/doctor.js +7 -1
  86. package/dist/lib/mesh/live/daemon/install.d.ts +4 -0
  87. package/dist/lib/mesh/live/daemon/install.js +10 -0
  88. package/dist/lib/mesh/live/daemon/run.js +17 -0
  89. package/dist/lib/mesh/live/emit-retry.d.ts +20 -2
  90. package/dist/lib/mesh/live/emit-retry.js +57 -4
  91. package/dist/lib/mesh/live/emit.js +25 -4
  92. package/dist/lib/mesh/live/flush.d.ts +2 -0
  93. package/dist/lib/mesh/live/flush.js +21 -8
  94. package/dist/lib/mesh/live/spool.d.ts +9 -1
  95. package/dist/lib/mesh/live/spool.js +41 -29
  96. package/dist/lib/sync-core/rollout-state.d.ts +9 -1
  97. package/dist/lib/sync-core/rollout-state.js +34 -4
  98. package/dist/lib/windows/jq.d.ts +4 -0
  99. package/dist/lib/windows/jq.js +10 -39
  100. package/dist/lib/workers-registry/index.js +7 -11
  101. package/dist/utils/callback-port-busy.d.ts +2 -2
  102. package/dist/utils/callback-port-busy.js +2 -2
  103. package/dist/utils/cli-network-lifecycle.js +1 -0
  104. package/dist/utils/client-health-contract.d.ts +2 -0
  105. package/dist/utils/client-health-contract.js +1 -1
  106. package/dist/utils/client-health.js +1 -9
  107. package/dist/utils/cognito-config.js +5 -0
  108. package/dist/utils/cognito-session.d.ts +4 -6
  109. package/dist/utils/cognito-session.js +4 -24
  110. package/dist/utils/incomplete-install-error.js +1 -11
  111. package/dist/utils/install-tree-torn.d.ts +11 -0
  112. package/dist/utils/install-tree-torn.js +1 -1
  113. package/dist/utils/resident-package-preload.js +2 -1
  114. package/docs/anywhere-runtime.md +8 -0
  115. package/package.json +9 -9
@@ -134,25 +134,6 @@ export class PartialRegistrationError extends McpRegistrationError {
134
134
  this.backupDir = backupDir;
135
135
  }
136
136
  }
137
- /**
138
- * Thrown by not-yet-implemented seams (the US-007/US-008 Claude/Codex emitters).
139
- * Carries a stable `code` so callers/tests can identify it without string-
140
- * matching the message, and a `story` for at-a-glance attribution. KEPT from the
141
- * US-005 seam: the merge EMITTERS are still pending after US-006 (which ships the
142
- * safe-write substrate beneath them).
143
- */
144
- export class NotImplementedError extends Error {
145
- /** Stable, machine-checkable discriminator. */
146
- code = 'NotImplemented';
147
- /** The PRD story that lands the real implementation. */
148
- story;
149
- constructor(message, story = 'US-007') {
150
- super(message);
151
- this.name = 'NotImplementedError';
152
- this.story = story;
153
- Object.setPrototypeOf(this, NotImplementedError.prototype);
154
- }
155
- }
156
137
  /** Resolve the env, defaulting `home` to the real `os.homedir()` for production callers. */
157
138
  export function resolveEnv(env) {
158
139
  const home = env?.home ?? os.homedir();
@@ -1078,12 +1059,11 @@ function restoreSafely(realTarget, backupDir) {
1078
1059
  // merges exactly ONE `mcpServers.<name>` entry into the PINNED single Claude
1079
1060
  // surface (top-level `~/.claude.json` `mcpServers`) via {@link writeConfigAtomic}.
1080
1061
  //
1081
- // The Codex/TOML emitter is US-008; this story does NOT implement it. The
1082
- // {@link registerServer} fan-out wires the Claude arm and leaves the Codex arm a
1083
- // FIRST-CLASS SKIP (the substrate's {@link isCodexInstalled} branch) — never a
1084
- // crash, never a fabricated `~/.codex`. So a re-run after US-008 lands simply
1085
- // gains the second surface; US-007 already self-heals per surface (US-006
1086
- // desired-state-convergence).
1062
+ // The Codex/TOML emitter is {@link registerCodexServer} (US-008). The
1063
+ // {@link registerServer} fan-out runs both arms; on a host without Codex the
1064
+ // Codex arm is a first-class skip (the substrate's {@link isCodexInstalled}
1065
+ // branch), never a crash and never a fabricated `~/.codex`. Each surface
1066
+ // self-heals on re-run (US-006 desired-state convergence).
1087
1067
  //
1088
1068
  // SECRET SAFETY (the hard rule from the PRD authModel / US-002 AC):
1089
1069
  // - `${secret:NAME}` resolves ONLY here, at emit, via the injected
@@ -1491,10 +1471,10 @@ export function isMcpRegistrationEnabled(env = process.env) {
1491
1471
  * `pack-install` routes `wire:'merge'` keys to). For each declared server name it
1492
1472
  * loads + shape-checks the manifest, then fans out via {@link registerServer}.
1493
1473
  *
1494
- * US-007 wires the Claude/JSON surface; the Codex/TOML surface (US-008) is a
1495
- * first-class skip until that story lands. Manifests are loaded with a caller-
1496
- * supplied loader so this stays decoupled from `pack-install`'s payload layout and
1497
- * fully testable in isolation.
1474
+ * It wires the Claude/JSON surface (US-007) and the Codex/TOML surface (US-008);
1475
+ * on a host without Codex the Codex surface is a first-class skip. Manifests are
1476
+ * loaded with a caller-supplied loader so this stays decoupled from
1477
+ * `pack-install`'s payload layout and fully testable in isolation.
1498
1478
  *
1499
1479
  * @param pkg the pack name (e.g. `hq-pack-vyg-shopify`) — stamped as provenance
1500
1480
  * @param names the bare server names from `contributes.mcp`
@@ -92,6 +92,10 @@ export declare function runDaemonStatus(opts: {
92
92
  /** launchctl/systemctl runner for the loaded probe (tests inject). */
93
93
  run?: RunCommand;
94
94
  uid?: number;
95
+ hqDaemonMesh?: () => {
96
+ daemonPid: number;
97
+ pid?: number;
98
+ } | null;
95
99
  }): Promise<void>;
96
100
  /** Work Mesh health report: `hq daemon doctor` (and the retiring `hq mesh daemon doctor`). */
97
101
  export declare function runMeshDaemonDoctor(opts: {
@@ -35,7 +35,7 @@ import { appendHeldLine } from "../lib/mesh/live/spool.js";
35
35
  import { createEmitPoster, buildMeshEmitEvent } from "../lib/mesh/live/emit-client.js";
36
36
  import { enrichSessionEndEvent } from "../lib/mesh/live/report-summary.js";
37
37
  import { emitEvents, formatEmitRejectionLines } from "../lib/mesh/live/emit.js";
38
- import { readEmitRetry, writeEmitRetry } from "../lib/mesh/live/emit-retry.js";
38
+ import { appendEmitRetry, readEmitRetry, writeEmitRetry } from "../lib/mesh/live/emit-retry.js";
39
39
  import { generateUlid } from "../lib/mesh/live/ulid.js";
40
40
  import { readLegacyBacklogForMode } from "../lib/mesh/live/emit-replay.js";
41
41
  import { resolveMeshEmitMode, writeMeshConfigMode, } from "../lib/mesh/live/daemon/mode.js";
@@ -63,7 +63,7 @@ import { deriveRemoteOwnerSlug, deriveRepoIdentityKey, } from "../lib/work-conte
63
63
  import { promptRepoCompany, } from "../lib/work-context/repo-prompt.js";
64
64
  import { requeueQuarantinedOutbox } from "../lib/work-context/outbox.js";
65
65
  import { handOffInstallHere } from "../lib/daemon/handoff.js";
66
- import { repairServiceUnitsFromOtherHome } from "../lib/daemon/mesh-owner.js";
66
+ import { hqDaemonMeshService, repairServiceUnitsFromOtherHome } from "../lib/daemon/mesh-owner.js";
67
67
  import { runResidentCommandWithPackageLease } from "../utils/resident-package-preload.js";
68
68
  import { exitCli } from "../utils/exit-after-worker.js";
69
69
  export function formatCheckLines(threads, company, projectId) {
@@ -1166,7 +1166,16 @@ async function runPrdSync(opts) {
1166
1166
  console.error(line);
1167
1167
  }
1168
1168
  const blocked = new Set(emitted.rejections.map((row) => row.eventId));
1169
- for (const pending of readEmitRetry(meshRoot)) {
1169
+ let retryPending;
1170
+ try {
1171
+ retryPending = readEmitRetry(meshRoot);
1172
+ }
1173
+ catch (err) {
1174
+ // Unknown which events still wait for retry: advance none of them.
1175
+ console.error(`work-mesh: prd-sync could not read the emit retry file; no stories advanced: ${(err instanceof Error ? err.message : String(err)).slice(0, 120)}`);
1176
+ retryPending = events;
1177
+ }
1178
+ for (const pending of retryPending) {
1170
1179
  const id = typeof pending.eventId === "string" ? pending.eventId : "";
1171
1180
  if (id)
1172
1181
  blocked.add(id);
@@ -2630,8 +2639,18 @@ async function runSessionEnqueue(cliKind, opts) {
2630
2639
  token = null;
2631
2640
  }
2632
2641
  if (!token) {
2633
- const pending = readEmitRetry(meshRoot);
2634
- const { written } = writeEmitRetry(meshRoot, [...pending, event]);
2642
+ let pending;
2643
+ try {
2644
+ pending = readEmitRetry(meshRoot);
2645
+ }
2646
+ catch (err) {
2647
+ // Never replace a retry file that could not be read; add this event to it.
2648
+ console.error(`work-mesh: emit retry file unreadable; appending without rewrite: ${(err instanceof Error ? err.message : String(err)).slice(0, 120)}`);
2649
+ pending = null;
2650
+ }
2651
+ const written = pending
2652
+ ? writeEmitRetry(meshRoot, [...pending, event]).written
2653
+ : appendEmitRetry(meshRoot, [event]);
2635
2654
  if (opts.json) {
2636
2655
  console.log(JSON.stringify({ ok: true, action: "emit", kind, deferred: true, retryDepth: written }, null, 2));
2637
2656
  return;
@@ -3340,6 +3359,7 @@ export async function runDaemonStatus(opts, deps = {}) {
3340
3359
  platform: deps.platform ?? detectPlatform(),
3341
3360
  paths,
3342
3361
  isLoaded: daemonServiceIsLoaded(deps.run ?? defaultRunCommand, deps.uid),
3362
+ hqDaemonMesh: (deps.hqDaemonMesh ?? (() => hqDaemonMeshService(paths.home)))(),
3343
3363
  });
3344
3364
  const state = readDaemonState(paths.daemonDir);
3345
3365
  const presenceRefusal = state?.presenceRefusal ?? null;
@@ -271,9 +271,8 @@ export declare function computeArtifactHash(tarballBytes: Uint8Array): string;
271
271
  */
272
272
  export declare function verifyArtifact(input: VerifyArtifactInput): void;
273
273
  /**
274
- * Parse + shape-validate one pack's per-server MCP manifest (`mcp/{item}.json`),
275
- * mirroring the bash `validate_mcp_manifest` arm. EXPORTED so the acceptance
276
- * test (and US-006's registration engine) can call it directly.
274
+ * Parse + shape-validate one pack's per-server MCP manifest (`mcp/{item}.json`).
275
+ * EXPORTED so the acceptance test (and US-006's registration engine) can call it directly.
277
276
  *
278
277
  * Throws an `Error` (whose message names the pack-relative payload path, e.g.
279
278
  * `mcp/foo.json`) when the file does not parse as JSON or violates a transport
@@ -864,13 +864,12 @@ export function verifyArtifact(input) {
864
864
  }
865
865
  }
866
866
  // ---------------------------------------------------------------------------
867
- // MCP per-server manifest validation (US-005, the TS counterpart of the bash
868
- // `validate_mcp_manifest` arm in core/scripts/scan-packages.sh).
867
+ // MCP per-server manifest validation (US-005).
869
868
  //
870
869
  // The `mcp` contributes key is `wire: 'merge'` — its per-server manifests are
871
870
  // NEVER symlinked; they are validated here and (US-006) merged into the agent
872
- // configs via registerMcpServers. This function MIRRORS the bash transport
873
- // rules hand-coded against the draft-07 schema
871
+ // configs via registerMcpServers. This function implements the transport
872
+ // rules by hand against the draft-07 schema
874
873
  // (repos/public/knowledge-hq-core/mcp-manifest.schema.json). There is no `ajv`
875
874
  // dependency in hq-cli; the schema file is single-source documentation, so the
876
875
  // rules are replicated here (dependency-free, robust if the schema is absent).
@@ -900,9 +899,8 @@ function checkStringMap(errs, label, value) {
900
899
  }
901
900
  }
902
901
  /**
903
- * Parse + shape-validate one pack's per-server MCP manifest (`mcp/{item}.json`),
904
- * mirroring the bash `validate_mcp_manifest` arm. EXPORTED so the acceptance
905
- * test (and US-006's registration engine) can call it directly.
902
+ * Parse + shape-validate one pack's per-server MCP manifest (`mcp/{item}.json`).
903
+ * EXPORTED so the acceptance test (and US-006's registration engine) can call it directly.
906
904
  *
907
905
  * Throws an `Error` (whose message names the pack-relative payload path, e.g.
908
906
  * `mcp/foo.json`) when the file does not parse as JSON or violates a transport
@@ -1110,7 +1108,7 @@ export function validateManifest(payloadDir, hqVersion, options = {}) {
1110
1108
  }
1111
1109
  // The `mcp` key (wire: 'merge') is NOT existsSync-only: after the file is
1112
1110
  // confirmed present it must PARSE + SHAPE-validate against the per-server
1113
- // MCP schema (US-005), mirroring the bash validate_mcp_manifest arm. Other
1111
+ // MCP schema (US-005) via validateMcpManifest. Other
1114
1112
  // (symlink) keys keep their existsSync-only behavior. We dispatch on the
1115
1113
  // ROUTE from the single-source table (not a hardcoded key) so the merge
1116
1114
  // path is table-driven; the merge itself (registering into the agent
@@ -25,11 +25,10 @@ import { vaultApiFetch, getCompanyUid, getEntityUid } from "../utils/vault-api.j
25
25
  export type { VaultApiOptions } from "../utils/vault-api.js";
26
26
  export { vaultApiFetch, getCompanyUid, getEntityUid };
27
27
  /**
28
- * Mirrors `RESOURCE_SURFACES` in hq-pro
29
- * `src/journey/limited-resource-telemetry.ts`. Keep this list in sync with
30
- * the server so CLI telemetry cannot silently fall back to `api`.
28
+ * Telemetry surface sent with `hq secrets set`. hq-pro accepts it because it is
29
+ * listed in `RESOURCE_SURFACES` in `src/journey/limited-resource-telemetry.ts`;
30
+ * an unlisted surface falls back to the server default.
31
31
  */
32
- export declare const HQ_PRO_RESOURCE_SURFACES: readonly ["api", "bot_invite", "bot_join_now", "calendar_auto_schedule", "calendar_preferences", "cli_secrets_set", "console_secrets_form", "deploy_precheck", "external_connection", "factory_install", "integrations_connect", "oauth_callback", "plan_limit_check", "secrets_input_link", "web"];
33
32
  export declare const CLI_SECRETS_SET_SURFACE = "cli_secrets_set";
34
33
  /**
35
34
  * Shown when `secrets share` / `unshare` gets a 403. Changing a secret's
@@ -107,27 +107,10 @@ import { runSandboxJobAfterSubmission } from "../utils/secrets-sandbox-resident.
107
107
  import { renderSecretInputLink, SECRET_LINK_FORMATS, } from "../lib/secret-input-link.js";
108
108
  export { vaultApiFetch, getCompanyUid, getEntityUid };
109
109
  /**
110
- * Mirrors `RESOURCE_SURFACES` in hq-pro
111
- * `src/journey/limited-resource-telemetry.ts`. Keep this list in sync with
112
- * the server so CLI telemetry cannot silently fall back to `api`.
110
+ * Telemetry surface sent with `hq secrets set`. hq-pro accepts it because it is
111
+ * listed in `RESOURCE_SURFACES` in `src/journey/limited-resource-telemetry.ts`;
112
+ * an unlisted surface falls back to the server default.
113
113
  */
114
- export const HQ_PRO_RESOURCE_SURFACES = [
115
- "api",
116
- "bot_invite",
117
- "bot_join_now",
118
- "calendar_auto_schedule",
119
- "calendar_preferences",
120
- "cli_secrets_set",
121
- "console_secrets_form",
122
- "deploy_precheck",
123
- "external_connection",
124
- "factory_install",
125
- "integrations_connect",
126
- "oauth_callback",
127
- "plan_limit_check",
128
- "secrets_input_link",
129
- "web",
130
- ];
131
114
  export const CLI_SECRETS_SET_SURFACE = "cli_secrets_set";
132
115
  /**
133
116
  * Cognito session for secrets surfaces hq-pro serves on the JWT routes only —