@indigoai-us/hq-cli 5.345.263 → 5.345.267

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 (83) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/assets/scaffold/core/scripts/hq-delegate-grant.sh +4 -48
  3. package/assets/scaffold/core/scripts/hq-delegate-secrets.sh +16 -10
  4. package/assets/scaffold/core/scripts/hq-delegate-send.sh +17 -1
  5. package/contracts/host-canary-release.json +7 -7
  6. package/dist/command-catalog.generated.d.ts +67 -1
  7. package/dist/command-catalog.generated.js +83 -1
  8. package/dist/command-registration-plan.d.ts +6 -0
  9. package/dist/command-registration-plan.js +1 -0
  10. package/dist/commands/bot.d.ts +2 -0
  11. package/dist/commands/bot.js +4 -3
  12. package/dist/commands/core-delegate-w1b.js +21 -40
  13. package/dist/commands/core-delegate.js +11 -8
  14. package/dist/commands/files-browse.d.ts +83 -4
  15. package/dist/commands/files-browse.js +404 -54
  16. package/dist/commands/groups.js +2 -2
  17. package/dist/commands/skill.js +15 -0
  18. package/dist/commands/sync-held.d.ts +11 -0
  19. package/dist/commands/sync-held.js +65 -1
  20. package/dist/commands/sync-telemetry-report.d.ts +5 -0
  21. package/dist/commands/sync-telemetry-report.js +239 -0
  22. package/dist/commands/sync-telemetry.d.ts +47 -0
  23. package/dist/commands/sync-telemetry.js +309 -0
  24. package/dist/index.js +107 -43
  25. package/dist/lib/agent-kit/mcp/tools.js +2 -2
  26. package/dist/lib/agent-kit/skills.js +12 -6
  27. package/dist/lib/bot/runnable.d.ts +17 -7
  28. package/dist/lib/bot/runnable.js +17 -10
  29. package/dist/lib/capacity/available.js +6 -2
  30. package/dist/lib/capacity/collectors/claude-oauth.d.ts +10 -256
  31. package/dist/lib/capacity/collectors/claude-oauth.js +19 -1078
  32. package/dist/lib/capacity/ledger.d.ts +12 -1
  33. package/dist/lib/capacity/ledger.js +15 -5
  34. package/dist/lib/capacity/route.d.ts +2 -0
  35. package/dist/lib/capacity/route.js +21 -4
  36. package/dist/lib/capacity/scheduler.js +2 -3
  37. package/dist/lib/capacity/sign-in.js +4 -4
  38. package/dist/lib/daemon/merge-sections.d.ts +44 -9
  39. package/dist/lib/daemon/merge-sections.js +234 -37
  40. package/dist/lib/daemon/ops/skill-command.d.ts +2 -0
  41. package/dist/lib/daemon/ops/skill-command.js +7 -1
  42. package/dist/lib/daemon/run.js +1 -0
  43. package/dist/lib/doctor/checks/antigravity-wiring.d.ts +2 -1
  44. package/dist/lib/doctor/checks/antigravity-wiring.js +75 -3
  45. package/dist/lib/doctor/checks/hook-engine.d.ts +2 -0
  46. package/dist/lib/doctor/checks/hook-engine.js +100 -1
  47. package/dist/lib/doctor/checks/host-core.d.ts +1 -1
  48. package/dist/lib/doctor/checks/host-core.js +19 -7
  49. package/dist/lib/doctor/fix/process-identity.d.ts +2 -0
  50. package/dist/lib/doctor/fix/process-identity.js +5 -2
  51. package/dist/lib/hook-engine/coverage.d.ts +19 -10
  52. package/dist/lib/hook-engine/coverage.js +116 -25
  53. package/dist/lib/hook-engine/native-precompact-compatibility.json +8 -1
  54. package/dist/lib/hook-engine/native-stop-compatibility.json +8 -4
  55. package/dist/lib/hook-engine/reconcile.js +60 -2
  56. package/dist/lib/install/antigravity-targets.d.ts +22 -0
  57. package/dist/lib/install/antigravity-targets.js +82 -0
  58. package/dist/lib/signals/reply.js +25 -5
  59. package/dist/lib/signals/steps/extract.d.ts +28 -4
  60. package/dist/lib/signals/steps/extract.js +124 -10
  61. package/dist/lib/sync-core/release.d.ts +1 -1
  62. package/dist/lib/sync-core/release.js +2 -2
  63. package/dist/main.js +8 -3
  64. package/dist/sentry-init.d.ts +7 -1
  65. package/dist/sentry-init.js +6 -2
  66. package/dist/sentry.d.ts +7 -0
  67. package/dist/sentry.js +16 -1
  68. package/dist/started-version.d.ts +13 -0
  69. package/dist/started-version.js +34 -0
  70. package/dist/startup-registration.d.ts +9 -9
  71. package/dist/startup-registration.js +42 -18
  72. package/dist/utils/client-health.d.ts +1 -0
  73. package/dist/utils/client-health.js +54 -11
  74. package/dist/utils/core-next-kill.d.ts +9 -0
  75. package/dist/utils/core-next-kill.js +22 -0
  76. package/dist/utils/host-registration.d.ts +4 -2
  77. package/dist/utils/host-registration.js +55 -7
  78. package/dist/utils/install-tree-recovery-markers.d.ts +45 -0
  79. package/dist/utils/install-tree-recovery-markers.js +70 -0
  80. package/dist/utils/install-tree-torn.d.ts +102 -5
  81. package/dist/utils/install-tree-torn.js +199 -2
  82. package/dist/utils/sentry-fingerprint.js +3 -0
  83. package/package.json +7 -7
@@ -162,22 +162,10 @@ function quoteBash(value) {
162
162
  return value;
163
163
  return `'${value.replaceAll("'", `'\\''`)}'`;
164
164
  }
165
- function delegationGroupId(principal) {
166
- return "grp_dlg" + createHash("sha256").update(principal).digest("hex").slice(0, 32);
167
- }
168
165
  function stripAnsiSequences(value) {
169
166
  const escape = String.fromCharCode(27);
170
167
  return value.replace(new RegExp(`${escape}\\[[0-?]*[ -/]*[@-~]`, "g"), "");
171
168
  }
172
- function groupMemberIds(output) {
173
- const plainOutput = stripAnsiSequences(output);
174
- const lines = plainOutput.split(/\r?\n/);
175
- const header = lines.findIndex((line) => /^PERSON_UID(?:\s|$)/.test(line.trimStart()));
176
- if (header < 0)
177
- return null;
178
- return lines.slice(header + 1).filter((line) => line.trim() !== "")
179
- .map((line) => line.trim().split(/\s{2,}/, 1)[0] ?? "");
180
- }
181
169
  /**
182
170
  * Creator-row ACL label in any hq-cli wording: bare "creator access", the older
183
171
  * "creator access — creator-only", or "creator access (<note>)". The listing
@@ -767,12 +755,6 @@ function runGrant(args, context) {
767
755
  if (!principal)
768
756
  return fail("grant", "manifest has no to.principal");
769
757
  let grantPrincipal = principal;
770
- if (principal.startsWith("agt_")) {
771
- const legacyGroup = "grp_dlg-" + principal.slice(-9).toLowerCase();
772
- const nextGroup = delegationGroupId(principal);
773
- const recordedGroup = text(getPath(manifest, "grantPrincipal"));
774
- grantPrincipal = recordedGroup === legacyGroup || recordedGroup === nextGroup ? recordedGroup : nextGroup;
775
- }
776
758
  if (status !== "building" && status !== "granted")
777
759
  return fail("grant", `manifest status is '${status}' — grants run from 'building' (or re-run from 'granted'), not from there`);
778
760
  const prefixes = list(getPath(manifest, "vaultPrefixes"));
@@ -800,7 +782,7 @@ function runGrant(args, context) {
800
782
  if (principal.startsWith("prs_"))
801
783
  out(` 0. Person recipient: personUid ${principal} maps to ${grantPrincipal}; grants are shared to that email\n`);
802
784
  if (principal.startsWith("agt_"))
803
- out(` 0. Agent recipient: grants flow through group ${grantPrincipal} (created if absent, containing exactly ${display})\n`);
785
+ out(` 0. Agent recipient: grants are shared directly to ${principal} (${display})\n`);
804
786
  out(` 1. Push companies/${company}/projects/${project}/ to the vault (on-conflict keep); where the sync engine owns the vault, pin it in .hq/pins.json and wait for its upload after the grants instead\n`);
805
787
  for (const entry of prefixes)
806
788
  out(` 2. Grant ${jqRawPath(entry, "permission")} on ${jqRawPath(entry, "prefix")} — ${jqRawPath(entry, "reason")}\n`);
@@ -860,25 +842,6 @@ function runGrant(args, context) {
860
842
  }
861
843
  }
862
844
  }
863
- if (principal.startsWith("agt_")) {
864
- result = grantHq(["groups", "create", grantPrincipal, "--name", `Delegation: ${display}`, "--company", company], context, "inherit");
865
- if (result.timedOut)
866
- return fail("grant", "group creation timed out; retain this manifest and resume");
867
- if (result.code !== 0)
868
- err("hq-delegate-grant: group create reported an error (may already exist) — continuing\n");
869
- result = grantHq(["groups", "add", grantPrincipal, principal, "--company", company], context, "inherit");
870
- if (result.timedOut)
871
- return fail("grant", "group membership update timed out; retain this manifest and resume");
872
- if (result.code !== 0)
873
- err("hq-delegate-grant: group add reported an error (may already be a member) — continuing\n");
874
- const members = subprocess("hq", ["groups", "members", grantPrincipal, "--company", company], context.cwd, { env: { NO_COLOR: "1", FORCE_COLOR: "0" }, timeout: 120_000 });
875
- if (members.code !== 0)
876
- return fail("grant", "could not verify delegation group membership");
877
- const memberIds = groupMemberIds(members.stdout ?? "");
878
- if (memberIds === null || memberIds.length !== 1 || memberIds[0] !== principal) {
879
- return fail("grant", "delegation group membership does not exactly match recipient");
880
- }
881
- }
882
845
  let expectedType = "";
883
846
  let expectedId = "";
884
847
  let expectedCompany = "";
@@ -886,6 +849,10 @@ function runGrant(args, context) {
886
849
  expectedType = "group";
887
850
  expectedId = grantPrincipal;
888
851
  }
852
+ else if (grantPrincipal.startsWith("agt_")) {
853
+ expectedType = "person";
854
+ expectedId = grantPrincipal;
855
+ }
889
856
  else if (grantPrincipal === "@all") {
890
857
  expectedType = "company-wide";
891
858
  }
@@ -1404,7 +1371,18 @@ function runSend(args, context) {
1404
1371
  .map((entry, index) => `${index + 1}. **${text(getPath(entry, "id"))}: ${text(getPath(entry, "title"))}** — ${text(getPath(entry, "description"))}`)
1405
1372
  .join("\n");
1406
1373
  }
1407
- const getLines = list(getPath(manifest, "vaultPrefixes", [])).map((entry) => "hq files get " + quoteBash(jqRawPath(entry, "prefix")) + " --company " + quoteBash(company)).join("\n");
1374
+ const getLines = list(getPath(manifest, "vaultPrefixes", [])).map((entry) => "hq files get " + quoteBash(typeof getPath(entry, "prefix") === "string" ? text(getPath(entry, "prefix")) : jqRawPath(entry, "prefix")) + " --company " + quoteBash(company)).join("\n");
1375
+ const delegationDir = `projects/${project}/delegation/${delegationId}/`;
1376
+ const fixedPaths = delegationId ? [`${delegationDir}BRIEF.md`, `${delegationDir}manifest.json`] : [];
1377
+ const publishedFileMap = getPath(manifest, "publication.files");
1378
+ const companyPrefix = `companies/${company}/`;
1379
+ const publishedPaths = (isRecord(publishedFileMap) ? Object.keys(publishedFileMap) : [])
1380
+ .map((file) => file.startsWith(companyPrefix) ? file.slice(companyPrefix.length) : file)
1381
+ .filter((file) => !fixedPaths.includes(file))
1382
+ .sort((a, b) => Buffer.compare(Buffer.from(a), Buffer.from(b)));
1383
+ const exactLines = [...fixedPaths, ...publishedPaths]
1384
+ .map((file) => ["hq", "files", "get", quoteBash(file), "--company", quoteBash(company)].join(" "))
1385
+ .join("\n");
1408
1386
  let repoSection = "";
1409
1387
  const repoValue = getPath(manifest, "repo");
1410
1388
  if (repoValue !== null && repoValue !== undefined) {
@@ -1434,7 +1412,10 @@ function runSend(args, context) {
1434
1412
  body += `## The goal\n\n${goal}\n\n`;
1435
1413
  if (stateLine)
1436
1414
  body += `## Where things stand\n\n${stateLine}\n\n`;
1437
- body += `## Pull the files (on demand — no sync)\n\nRun these from your HQ root; each materializes exactly that path locally:\n\n\`\`\`bash\n${getLines}\n\`\`\`\n\n${dossierLine}\n\n`;
1415
+ body += `## Pull the files (on demand — no sync)\n\nRun these from your HQ root; each materializes exactly that path locally:\n\n\`\`\`bash\n${getLines}\n\`\`\`\n\n`;
1416
+ if (exactLines)
1417
+ body += `The delegation brief, manifest and dossier files are at these exact vault paths. Fetch them directly; do not search the vault for them (\`hq files search\` lists the whole company vault and can take minutes):\n\n\`\`\`bash\n${exactLines}\n\`\`\`\n\n`;
1418
+ body += `${dossierLine}\n\n`;
1438
1419
  if (repoSection)
1439
1420
  body += `${repoSection}\n\n`;
1440
1421
  if (secretsSection)
@@ -794,18 +794,21 @@ export { delegateBoardPath, delegateRepoDirectory, secretsSourcePaths };
794
794
  const SECRET_NAME_PATTERN = /^[A-Z][A-Z0-9_]*(\/[A-Z][A-Z0-9_]+)*$/;
795
795
  /**
796
796
  * The principal `hq secrets share` accepts for this recipient. Secret ACLs
797
- * take an email, grp_<id>, out_<id> or @all, so an agent or person uid shares
798
- * through the principal the grant step recorded: the per-agent delegation
799
- * group for an agent, the mapped email for a person uid. Empty when none is
800
- * recorded, so the caller refuses before any share.
797
+ * accept an email, agt_<id> (translated to its machine email on the wire),
798
+ * grp_<id>, out_<id> or @all. Only a person uid (prs_<id>) must share through
799
+ * the mapped email the grant step recorded in `grantPrincipal`. For an agent
800
+ * recipient, a legacy `grp_dlg*` recorded in an older manifest is still
801
+ * honored; otherwise the `agt_<id>` is shared directly.
801
802
  */
802
803
  function secretSharePrincipal(principal, document) {
803
- if (!principal.startsWith("agt_") && !principal.startsWith("prs_"))
804
+ if (principal.startsWith("agt_")) {
805
+ const recorded = jqRawPath(document, "grantPrincipal").replaceAll("\r", "");
806
+ return recorded.startsWith("grp_dlg") ? recorded : principal;
807
+ }
808
+ if (!principal.startsWith("prs_"))
804
809
  return principal;
805
810
  const recorded = jqRawPath(document, "grantPrincipal").replaceAll("\r", "");
806
- if (principal.startsWith("agt_") && recorded.startsWith("grp_dlg"))
807
- return recorded;
808
- if (principal.startsWith("prs_") && /^.+@.+$/s.test(recorded))
811
+ if (/^.+@.+$/s.test(recorded))
809
812
  return recorded;
810
813
  return "";
811
814
  }
@@ -193,6 +193,9 @@ export declare function assertOutPathOutsideCompanies(outPath: string, hqRoot: s
193
193
  * stylistically consistent.
194
194
  */
195
195
  export declare function formatBrowseTable(rows: BrowseRow[]): string;
196
+ export declare function formatSearchTable(rows: SearchRow[], acl: boolean): string;
197
+ export declare function formatSearchResults(rows: SearchRow[], query: string, acl?: boolean): string;
198
+ export declare function formatLocalSearchResults(found: LocalSearchResult, query: string): string;
196
199
  export interface RunBrowseInput {
197
200
  /**
198
201
  * Vault path prefix.
@@ -344,6 +347,18 @@ export declare function runSharedWithMe(input: RunSharedWithMeInput): Promise<Sh
344
347
  * Render `shared-with-me` rows as a padded table. Mirrors `formatBrowseTable`.
345
348
  */
346
349
  export declare function formatSharedWithMeTable(rows: SharedWithMeRow[]): string;
350
+ export interface SearchRow {
351
+ key: string;
352
+ size: number;
353
+ lastModified: Date | undefined;
354
+ aclSource?: AclSource;
355
+ }
356
+ export interface SearchProgress {
357
+ pages: number;
358
+ objects: number;
359
+ matches: number;
360
+ elapsedMs: number;
361
+ }
347
362
  export interface RunSearchInput {
348
363
  /** Case-insensitive substring matched against each object's full key. */
349
364
  query: string;
@@ -357,16 +372,80 @@ export interface RunSearchInput {
357
372
  /** COMPANY mode (HQ-59): presign/list client factory. */
358
373
  companyClient?: CompanyBrowseClientFactory;
359
374
  region: string;
375
+ prefix?: string;
376
+ includeAcl?: boolean;
377
+ onPage?: (progress: SearchProgress) => void;
378
+ now?: () => number;
360
379
  }
380
+ export declare function createSearchMatcher(query: string): (lowerKey: string) => boolean;
361
381
  /**
362
382
  * `hq files search <query>` orchestrator. Lists the company (or personal)
363
- * vault under its root via `runBrowse`, then filters to keys containing the
383
+ * vault under its root, then filters to keys containing the
364
384
  * query (case-insensitive). v1 is a name/path search over the listing — no
365
- * content search. Rows carry the same ACL-source classification as browse.
385
+ * content search.
366
386
  *
367
- * Pure-ish: no console output. The caller renders with `formatBrowseTable`.
387
+ * Pure-ish: no console output. The caller renders with `formatSearchResults`.
368
388
  */
369
- export declare function runSearch(input: RunSearchInput): Promise<BrowseRow[]>;
389
+ export declare function runSearch(input: RunSearchInput): Promise<SearchRow[]>;
390
+ export declare function assertSafeCompanySlug(slug: string): void;
391
+ export declare function resolveSearchPrefix(raw: string | undefined, companySlug: string): string;
392
+ export interface LocalSearchResult {
393
+ root: string;
394
+ available: boolean;
395
+ rows: SearchRow[];
396
+ warning?: string;
397
+ }
398
+ export declare function searchLocalCompanyFiles(input: {
399
+ hqRoot: string;
400
+ companySlug: string;
401
+ prefix: string;
402
+ query: string;
403
+ shouldSync?: (absPath: string, isDir?: boolean) => boolean;
404
+ }): LocalSearchResult;
405
+ export interface SearchProgressStream {
406
+ write(chunk: string): unknown;
407
+ isTTY?: boolean;
408
+ }
409
+ export interface SearchProgressReporter {
410
+ start(scope: string): void;
411
+ page(progress: SearchProgress): void;
412
+ done(): void;
413
+ }
414
+ export declare function createSearchProgressReporter(input: {
415
+ stream: SearchProgressStream;
416
+ force?: boolean;
417
+ quiet?: boolean;
418
+ }): SearchProgressReporter;
419
+ export declare function personLocalSearchAllowed(input: {
420
+ credentialKind: "api-key" | "cognito";
421
+ vars?: NodeJS.ProcessEnv;
422
+ describeIdentity?: (vars: NodeJS.ProcessEnv) => {
423
+ tokenSource: string;
424
+ actorKind: string;
425
+ };
426
+ }): boolean;
427
+ export interface RunCompanySearchCommandInput {
428
+ query: string;
429
+ companySlug: string;
430
+ hqRoot: string;
431
+ prefix?: string;
432
+ local?: boolean;
433
+ localOnly?: boolean;
434
+ acl?: boolean;
435
+ progress?: boolean;
436
+ quiet?: boolean;
437
+ region: string;
438
+ connect: () => Promise<{
439
+ vaultClient: FilesBrowseVaultClient;
440
+ companyClient: CompanyBrowseClientFactory;
441
+ localAllowed: boolean;
442
+ }>;
443
+ stdout: (text: string) => void;
444
+ stderr: SearchProgressStream;
445
+ now?: () => number;
446
+ shouldSync?: (absPath: string, isDir?: boolean) => boolean;
447
+ }
448
+ export declare function runCompanySearchCommand(input: RunCompanySearchCommandInput): Promise<void>;
370
449
  interface PinFile {
371
450
  version: number;
372
451
  /** companySlug → sorted list of company-relative pinned prefixes. */