@indigoai-us/hq-cli 5.345.226 → 5.345.228

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 (132) hide show
  1. package/CHANGELOG.md +142 -0
  2. package/dist/command-catalog.generated.d.ts +137 -0
  3. package/dist/command-catalog.generated.js +164 -0
  4. package/dist/commands/auth.d.ts +2 -2
  5. package/dist/commands/auth.js +3 -3
  6. package/dist/commands/core-delegate-w1b.js +92 -69
  7. package/dist/commands/core-delegate.d.ts +19 -1
  8. package/dist/commands/core-delegate.js +411 -6
  9. package/dist/commands/core-dm-bind-native.js +2 -1
  10. package/dist/commands/core-handoff.d.ts +5 -0
  11. package/dist/commands/core-handoff.js +1008 -14
  12. package/dist/commands/core-pin-native.d.ts +1 -0
  13. package/dist/commands/core-pin-native.js +3 -15
  14. package/dist/commands/core-register-project-native.d.ts +6 -0
  15. package/dist/commands/core-register-project-native.js +182 -52
  16. package/dist/commands/core-work-mesh-bind-trusted-native.js +4 -9
  17. package/dist/commands/daemon.js +2 -2
  18. package/dist/commands/index-cmd.d.ts +3 -1
  19. package/dist/commands/index-cmd.js +12 -0
  20. package/dist/commands/lanes-checks.js +1 -1
  21. package/dist/commands/lanes-session-start.d.ts +1 -2
  22. package/dist/commands/lanes-session-start.js +9 -145
  23. package/dist/commands/lanes-shared.d.ts +3 -0
  24. package/dist/commands/lanes.d.ts +3 -0
  25. package/dist/commands/lanes.js +94 -27
  26. package/dist/commands/link.d.ts +8 -3
  27. package/dist/commands/link.js +14 -17
  28. package/dist/commands/mcp-registration.d.ts +65 -7
  29. package/dist/commands/mcp-registration.js +289 -51
  30. package/dist/commands/mesh.d.ts +12 -0
  31. package/dist/commands/mesh.js +92 -10
  32. package/dist/commands/reindex.js +6 -0
  33. package/dist/commands/repo.d.ts +13 -0
  34. package/dist/commands/repo.js +39 -1
  35. package/dist/commands/sync-mode.d.ts +3 -1
  36. package/dist/commands/sync-mode.js +11 -1
  37. package/dist/lazy-commands.js +3 -4
  38. package/dist/lib/checkpoint-ontology/entity-file.js +4 -4
  39. package/dist/lib/checkpoint-ontology/merge-copies.js +7 -11
  40. package/dist/lib/checkpoint-ontology/plan.js +2 -1
  41. package/dist/lib/core-utils/archive-old-threads.js +5 -2
  42. package/dist/lib/core-utils/session-company.d.ts +13 -1
  43. package/dist/lib/core-utils/session-company.js +75 -4
  44. package/dist/lib/core-utils/worktree-resume.d.ts +6 -0
  45. package/dist/lib/core-utils/worktree-resume.js +8 -4
  46. package/dist/lib/daemon/background-qos.d.ts +7 -0
  47. package/dist/lib/daemon/background-qos.js +13 -0
  48. package/dist/lib/daemon/catalog.d.ts +9 -0
  49. package/dist/lib/daemon/catalog.js +8 -1
  50. package/dist/lib/daemon/hook-requests-acl-suggest.d.ts +18 -0
  51. package/dist/lib/daemon/hook-requests-acl-suggest.js +245 -0
  52. package/dist/lib/daemon/hook-requests-fleet-session-start.d.ts +32 -0
  53. package/dist/lib/daemon/hook-requests-fleet-session-start.js +214 -0
  54. package/dist/lib/daemon/hook-requests-mesh-tool-writes.d.ts +44 -0
  55. package/dist/lib/daemon/hook-requests-mesh-tool-writes.js +292 -0
  56. package/dist/lib/daemon/hook-requests-mesh.d.ts +54 -0
  57. package/dist/lib/daemon/hook-requests-mesh.js +559 -0
  58. package/dist/lib/daemon/hook-requests.d.ts +349 -8
  59. package/dist/lib/daemon/hook-requests.js +1312 -46
  60. package/dist/lib/daemon/machine-checks.d.ts +12 -2
  61. package/dist/lib/daemon/machine-checks.js +27 -10
  62. package/dist/lib/daemon/merge-sections.d.ts +24 -2
  63. package/dist/lib/daemon/merge-sections.js +58 -16
  64. package/dist/lib/daemon/ops/policy.js +4 -2
  65. package/dist/lib/daemon/resolver.js +9 -2
  66. package/dist/lib/daemon/run.d.ts +11 -7
  67. package/dist/lib/daemon/run.js +168 -24
  68. package/dist/lib/daemon/search-index-worker-v1.d.ts +2 -0
  69. package/dist/lib/daemon/search-index-worker-v1.js +25 -0
  70. package/dist/lib/daemon/session-registry.d.ts +0 -1
  71. package/dist/lib/daemon/session-registry.js +0 -3
  72. package/dist/lib/daemon/supervisor.d.ts +3 -1
  73. package/dist/lib/daemon/supervisor.js +1 -1
  74. package/dist/lib/daemon/tcc-eperm.d.ts +59 -4
  75. package/dist/lib/daemon/tcc-eperm.js +110 -8
  76. package/dist/lib/doctor/fix/process-identity.d.ts +20 -2
  77. package/dist/lib/doctor/fix/process-identity.js +48 -5
  78. package/dist/lib/hook-engine/canary-gate.js +1 -0
  79. package/dist/lib/hook-engine/native-stop-compatibility.json +2 -1
  80. package/dist/lib/hot-channels/adapters/attio.js +2 -1
  81. package/dist/lib/hot-channels/adapters/meetings.js +2 -1
  82. package/dist/lib/lanes/company-outposts.d.ts +37 -0
  83. package/dist/lib/lanes/company-outposts.js +164 -0
  84. package/dist/lib/lanes/liveness.d.ts +6 -0
  85. package/dist/lib/lanes/liveness.js +49 -8
  86. package/dist/lib/lanes/orphan-report.d.ts +15 -0
  87. package/dist/lib/lanes/orphan-report.js +223 -0
  88. package/dist/lib/lanes/orphan-sweep.d.ts +26 -0
  89. package/dist/lib/lanes/orphan-sweep.js +152 -0
  90. package/dist/lib/lanes/reaper.d.ts +2 -0
  91. package/dist/lib/lanes/reaper.js +11 -8
  92. package/dist/lib/lanes/reconcile.d.ts +8 -7
  93. package/dist/lib/lanes/reconcile.js +39 -0
  94. package/dist/lib/mesh/live/backfill-held.d.ts +13 -0
  95. package/dist/lib/mesh/live/backfill-held.js +23 -0
  96. package/dist/lib/mesh/live/daemon/mode.d.ts +8 -4
  97. package/dist/lib/mesh/live/daemon/mode.js +8 -4
  98. package/dist/lib/mesh/live/daemon/run.d.ts +14 -3
  99. package/dist/lib/mesh/live/daemon/run.js +116 -7
  100. package/dist/lib/mesh/live/direct-drain.d.ts +123 -0
  101. package/dist/lib/mesh/live/direct-drain.js +315 -0
  102. package/dist/lib/mesh/live/emit-replay.d.ts +10 -0
  103. package/dist/lib/mesh/live/emit-replay.js +10 -0
  104. package/dist/lib/mesh/live/flush.d.ts +15 -0
  105. package/dist/lib/mesh/live/flush.js +27 -0
  106. package/dist/lib/mesh/live/liveness-carry.d.ts +45 -0
  107. package/dist/lib/mesh/live/liveness-carry.js +141 -0
  108. package/dist/lib/mesh/live/spool.d.ts +19 -0
  109. package/dist/lib/mesh/live/spool.js +80 -0
  110. package/dist/lib/safe-store.d.ts +2 -0
  111. package/dist/lib/safe-store.js +8 -6
  112. package/dist/lib/search-index/index.d.ts +9 -3
  113. package/dist/lib/search-index/index.js +35 -10
  114. package/dist/lib/search-index/worker-process.d.ts +9 -0
  115. package/dist/lib/search-index/worker-process.js +171 -0
  116. package/dist/lib/session-company-lock.d.ts +3 -1
  117. package/dist/lib/session-company-lock.js +3 -2
  118. package/dist/utils/delegate-command-supervisor.d.ts +3 -0
  119. package/dist/utils/delegate-command-supervisor.js +44 -0
  120. package/dist/utils/delegate-lock.d.ts +12 -0
  121. package/dist/utils/delegate-lock.js +88 -0
  122. package/dist/utils/frontmatter.d.ts +27 -0
  123. package/dist/utils/frontmatter.js +33 -0
  124. package/dist/utils/hook-trust.d.ts +1 -0
  125. package/dist/utils/hook-trust.js +18 -2
  126. package/dist/utils/host-registration.d.ts +13 -1
  127. package/dist/utils/host-registration.js +98 -5
  128. package/dist/utils/package-use-lease.d.ts +1 -1
  129. package/dist/utils/package-use-lease.js +15 -7
  130. package/docs/anywhere-runtime.md +17 -0
  131. package/package.json +8 -7
  132. package/scripts/check-function-manifest.mjs +17 -3
@@ -1,6 +1,7 @@
1
1
  /** Native implementations of the second Wave 1 delegate command family. */
2
2
  import { daemonWhoamiOutput } from "../lib/daemon/whoami-cache.js";
3
3
  import { createHash, randomInt } from "node:crypto";
4
+ import { acquireDelegateLock } from "../utils/delegate-lock.js";
4
5
  import * as fs from "node:fs";
5
6
  import * as os from "node:os";
6
7
  import * as path from "node:path";
@@ -459,8 +460,11 @@ function writeBundle(context, input) {
459
460
  bundleFileSystem.rmSync(stage, { recursive: true, force: true });
460
461
  }
461
462
  }
462
- function runHq(args, context, stdout = "capture") {
463
- return subprocess("hq", args, context.cwd, { stdout });
463
+ function runHq(args, context, stdout = "capture", timeout) {
464
+ return subprocess("hq", args, context.cwd, { stdout, timeout });
465
+ }
466
+ function delegateLockBusy() {
467
+ return "verification or delivery is active; retry after it finishes";
464
468
  }
465
469
  const runJq = createShellCompatibleJqInvoker((args, input, cwd, options) => subprocess("jq", args, cwd, { input, ...options }), process.platform, process.env, (cwd) => {
466
470
  const bash = resolveWindowsBash(process.env).executable;
@@ -521,14 +525,10 @@ function runGrant(args, context) {
521
525
  if (!fs.existsSync(manifestPath) || !fs.statSync(manifestPath).isFile())
522
526
  return fail("grant", `manifest not found: ${delegateDiagnosticPath(manifestPath)}`);
523
527
  const lock = `${manifestPath}.send-lock`;
524
- if (yes) {
525
- try {
526
- fs.mkdirSync(lock);
527
- }
528
- catch {
529
- return fail("grant", "verification or delivery is active; retry after it finishes");
530
- }
531
- }
528
+ const held = yes ? acquireDelegateLock(lock) : null;
529
+ if (yes && !held)
530
+ return fail("grant", delegateLockBusy());
531
+ const grantHq = (args, ctx, stdout = "capture") => runHq(args, ctx, stdout, 120_000);
532
532
  try {
533
533
  let manifest;
534
534
  try {
@@ -585,7 +585,7 @@ function runGrant(args, context) {
585
585
  err("hq-delegate-grant: confirmation required — re-run with --yes after the user approves\n");
586
586
  return 2;
587
587
  }
588
- let result = runHq(["sync", "push", `companies/${company}/projects/${project}/`, "--company", company, "--on-conflict", "keep"], context, "inherit");
588
+ let result = grantHq(["sync", "push", `companies/${company}/projects/${project}/`, "--company", company, "--on-conflict", "keep"], context, "inherit");
589
589
  if (result.code !== 0)
590
590
  return fail("grant", `vault push failed for companies/${company}/projects/${project}/`);
591
591
  const referencePaths = [
@@ -594,7 +594,7 @@ function runGrant(args, context) {
594
594
  ].filter((entry) => typeof entry === "string" && entry.startsWith(`companies/${company}/`));
595
595
  for (const reference of referencePaths) {
596
596
  if (fs.existsSync(path.join(context.root ?? context.cwd, reference))) {
597
- result = runHq(["sync", "push", reference, "--company", company, "--on-conflict", "keep"], context, "inherit");
597
+ result = grantHq(["sync", "push", reference, "--company", company, "--on-conflict", "keep"], context, "inherit");
598
598
  if (result.code !== 0)
599
599
  return fail("grant", `vault push failed for referenced knowledge: ${reference}`);
600
600
  }
@@ -603,13 +603,17 @@ function runGrant(args, context) {
603
603
  }
604
604
  }
605
605
  if (grantPrincipal !== principal) {
606
- result = runHq(["groups", "create", grantPrincipal, "--name", `Delegation: ${display}`, "--company", company], context, "inherit");
606
+ result = grantHq(["groups", "create", grantPrincipal, "--name", `Delegation: ${display}`, "--company", company], context, "inherit");
607
+ if (result.timedOut)
608
+ return fail("grant", "group creation timed out; retain this manifest and resume");
607
609
  if (result.code !== 0)
608
610
  err("hq-delegate-grant: group create reported an error (may already exist) — continuing\n");
609
- result = runHq(["groups", "add", grantPrincipal, principal, "--company", company], context, "inherit");
611
+ result = grantHq(["groups", "add", grantPrincipal, principal, "--company", company], context, "inherit");
612
+ if (result.timedOut)
613
+ return fail("grant", "group membership update timed out; retain this manifest and resume");
610
614
  if (result.code !== 0)
611
615
  err("hq-delegate-grant: group add reported an error (may already be a member) — continuing\n");
612
- const members = subprocess("hq", ["groups", "members", grantPrincipal, "--company", company], context.cwd, { env: { NO_COLOR: "1", FORCE_COLOR: "0" } });
616
+ const members = subprocess("hq", ["groups", "members", grantPrincipal, "--company", company], context.cwd, { env: { NO_COLOR: "1", FORCE_COLOR: "0" }, timeout: 120_000 });
613
617
  if (members.code !== 0)
614
618
  return fail("grant", "could not verify delegation group membership");
615
619
  const memberIds = groupMemberIds(members.stdout ?? "");
@@ -628,7 +632,7 @@ function runGrant(args, context) {
628
632
  expectedType = "company-wide";
629
633
  }
630
634
  else {
631
- const resolved = runHq(["people", "resolve", principal, "--company", company, "--json", "--membership-only"], context);
635
+ const resolved = grantHq(["people", "resolve", principal, "--company", company, "--json", "--membership-only"], context);
632
636
  let response;
633
637
  try {
634
638
  response = JSON.parse(resolved.stdout ?? "");
@@ -660,7 +664,7 @@ function runGrant(args, context) {
660
664
  return fail("grant", "authoritative recipient lookup failed; update hq-cli if --membership-only is unsupported");
661
665
  }
662
666
  const readAcl = (prefix) => {
663
- const response = runHq(["files", "acl", prefix, "--company", company, "--json"], context);
667
+ const response = grantHq(["files", "acl", prefix, "--company", company, "--json"], context);
664
668
  if (response.code !== 0)
665
669
  return { ok: false };
666
670
  let value;
@@ -694,8 +698,10 @@ function runGrant(args, context) {
694
698
  if (!before.ok || !before.value)
695
699
  return fail("grant", `ACL preflight failed; no share attempted for ${prefix}`);
696
700
  expectedCompany = text(before.value.companyUid);
697
- const share = runHq(["files", "share", aclPattern, "--with", grantPrincipal, "--permission", permission, "--company", company], context, "inherit");
701
+ const share = grantHq(["files", "share", aclPattern, "--with", grantPrincipal, "--permission", permission, "--company", company], context, "inherit");
698
702
  const shareRc = share.code;
703
+ if (share.timedOut)
704
+ return fail("grant", `share timed out for ${prefix}; retain this manifest and resume`);
699
705
  if (shareRc !== 0)
700
706
  err(`hq-delegate-grant: share reported an error on ${prefix}; checking exact grant\n`);
701
707
  let landed = false;
@@ -726,12 +732,7 @@ function runGrant(args, context) {
726
732
  return 0;
727
733
  }
728
734
  finally {
729
- if (yes) {
730
- try {
731
- fs.rmdirSync(lock);
732
- }
733
- catch { /* Preserve the grant result. */ }
734
- }
735
+ held?.release();
735
736
  }
736
737
  }
737
738
  function atomicCopy(source, target, mode) {
@@ -755,12 +756,12 @@ function atomicCopy(source, target, mode) {
755
756
  }
756
757
  }
757
758
  function fileRecord(key, value) { return serializeJqJson({ key, value }, "compact"); }
758
- function runPublish(args, context) {
759
+ function runPublish(args, context, legacyHandoff, nativeLock) {
759
760
  if (args[0] !== "--manifest" || !args[1] || !fs.existsSync(args[1]) || !fs.statSync(args[1]).isFile())
760
761
  return fail("publish", "usage: --manifest <path>");
761
762
  const manifestPath = args[1];
762
763
  if (malformedJsonFile(manifestPath))
763
- return runShellFallback("publish", args, context);
764
+ return legacyHandoff ? legacyHandoff() : runShellFallback("publish", args, context);
764
765
  let preflightManifest;
765
766
  try {
766
767
  preflightManifest = readJsonFile(manifestPath);
@@ -772,26 +773,22 @@ function runPublish(args, context) {
772
773
  const root = context.root ?? context.cwd;
773
774
  const prd = path.join(root, "companies", jqRawPath(preflightManifest, "company"), "projects", jqRawPath(preflightManifest, "project.name"), "prd.json");
774
775
  if (fs.existsSync(prd) && fs.statSync(prd).isFile() && malformedJsonFile(prd)) {
775
- return runShellFallback("publish", args, context);
776
+ return legacyHandoff ? legacyHandoff() : runShellFallback("publish", args, context);
776
777
  }
777
778
  }
778
779
  const lock = `${manifestPath}.send-lock`;
779
780
  const lockHeld = args[2] === "--lock-held";
780
- let ownLock = false;
781
+ let ownedLock = null;
781
782
  if (lockHeld) {
782
- if (!fs.existsSync(lock) || !fs.statSync(lock).isDirectory())
783
+ if (!fs.existsSync(lock) || fs.lstatSync(lock).isSymbolicLink() || !(fs.statSync(lock).isDirectory() || (nativeLock && fs.statSync(lock).isFile())))
783
784
  return fail("publish", "verification lock missing");
784
785
  }
785
786
  else {
786
- try {
787
- fs.mkdirSync(lock);
788
- ownLock = true;
789
- }
790
- catch {
791
- return fail("publish", "verification or delivery is active; retry after it finishes");
792
- }
787
+ ownedLock = acquireDelegateLock(lock);
788
+ if (!ownedLock)
789
+ return fail("publish", delegateLockBusy());
793
790
  if (args.length !== 2) {
794
- fs.rmdirSync(lock);
791
+ ownedLock.release();
795
792
  return fail("publish", "usage: --manifest <path>");
796
793
  }
797
794
  }
@@ -799,12 +796,7 @@ function runPublish(args, context) {
799
796
  const cleanup = () => {
800
797
  if (stage)
801
798
  fs.rmSync(stage, { recursive: true, force: true });
802
- if (ownLock) {
803
- try {
804
- fs.rmdirSync(lock);
805
- }
806
- catch { /* a concurrent actor may have removed the lock */ }
807
- }
799
+ ownedLock?.release();
808
800
  };
809
801
  try {
810
802
  const manifest = jsonFile(manifestPath);
@@ -932,12 +924,42 @@ function sortedJson(value) {
932
924
  };
933
925
  return serializeJqJson(sort(value), "compact").replace(/\n+$/, "");
934
926
  }
927
+ /**
928
+ * `hq-delegate-send.sh --manifest <path> --reconcile <eventId>`: record a
929
+ * handoff DM delivered outside the helper. Sends nothing, takes no send lock,
930
+ * starts no program and writes no PICKUP-PROMPT.md.
931
+ */
932
+ function reconcileSend(manifestPath, eventId, context) {
933
+ const manifest = jsonFile(manifestPath);
934
+ if (!manifest)
935
+ return fail("send", `manifest is not valid JSON: ${delegateDiagnosticPath(manifestPath)}`);
936
+ if (!/^[A-Za-z0-9_-]+$/.test(eventId))
937
+ return fail("send", "--reconcile needs a DM eventId (letters, digits, _ and -)");
938
+ const current = jqRawPath(manifest, "status");
939
+ if (current === "sent" || current === "picked-up")
940
+ return fail("send", `manifest status is '${current}' - already recorded as sent`);
941
+ if (current !== "granted" && current !== "verified" && current !== "sending") {
942
+ return fail("send", `manifest status is '${current}' - only granted, verified, or sending can be reconciled`);
943
+ }
944
+ manifest.status = "sent";
945
+ manifest.sentAt = currentTime();
946
+ manifest.dmEventId = eventId;
947
+ manifest.sentVia = "reconcile";
948
+ try {
949
+ writeJsonAtomically(manifestPath, manifest, true, context.atomicWriteFileSystem);
950
+ }
951
+ catch {
952
+ return fail("send", "could not save reconciled send receipt");
953
+ }
954
+ out(`hq-delegate-send: recorded existing DM (eventId ${eventId}) - status advanced to 'sent'\n`);
955
+ return 0;
956
+ }
935
957
  function runSend(args, context) {
936
958
  // The shell shifts two arguments for value options. Under `set -e`, a
937
959
  // trailing option without its value exits 1 before printing diagnostics.
938
- if (["--manifest", "--headline", "--note"].includes(args.at(-1) ?? ""))
960
+ if (["--manifest", "--headline", "--note", "--reconcile"].includes(args.at(-1) ?? ""))
939
961
  return 1;
940
- const parsed = parseFlags(args, ["--manifest", "--send", "--headline", "--note"]);
962
+ const parsed = parseFlags(args, ["--manifest", "--send", "--headline", "--note", "--reconcile"]);
941
963
  if (parsed.help) {
942
964
  out(usage("send"));
943
965
  return 0;
@@ -948,28 +970,26 @@ function runSend(args, context) {
948
970
  const send = parsed.values["--send"] === true;
949
971
  let headline = text(parsed.values["--headline"]);
950
972
  const note = text(parsed.values["--note"]);
973
+ const reconcile = text(parsed.values["--reconcile"]);
951
974
  if (!manifestPath)
952
975
  return fail("send", "--manifest is required");
953
976
  if (!fs.existsSync(manifestPath) || !fs.statSync(manifestPath).isFile())
954
977
  return fail("send", `manifest not found: ${delegateDiagnosticPath(manifestPath)}`);
978
+ // The shell tests `[ -n "$RECONCILE" ]` before the send lock and the send
979
+ // path, so a non-empty --reconcile wins over --send and never reaches the
980
+ // bundled fallback (whose older copy rejects the flag).
981
+ if (reconcile)
982
+ return reconcileSend(manifestPath, reconcile, context);
955
983
  const lock = `${manifestPath}.send-lock`;
956
- if (send) {
957
- try {
958
- fs.mkdirSync(lock);
959
- }
960
- catch {
961
- return fail("send", "verification or delivery is active; retry after it finishes");
962
- }
963
- }
984
+ const held = send ? acquireDelegateLock(lock) : null;
985
+ if (send && !held)
986
+ return fail("send", delegateLockBusy());
964
987
  let lockRemoved = false;
965
988
  const removeLock = () => {
966
989
  if (!send || lockRemoved)
967
990
  return;
968
- try {
969
- fs.rmdirSync(lock);
970
- lockRemoved = true;
971
- }
972
- catch { /* Preserve the command result if a concurrent process removed it. */ }
991
+ held?.release();
992
+ lockRemoved = true;
973
993
  };
974
994
  try {
975
995
  const manifest = jsonFile(manifestPath);
@@ -1248,12 +1268,9 @@ function runVerify(args, context) {
1248
1268
  if (!manifest)
1249
1269
  return fail("verify", `jq: error: ${delegateDiagnosticPath(manifestPath)}: Invalid JSON`);
1250
1270
  const lock = `${manifestPath}.send-lock`;
1251
- try {
1252
- fs.mkdirSync(lock);
1253
- }
1254
- catch {
1255
- return fail("verify", "verification or delivery is active; retry after it finishes");
1256
- }
1271
+ const held = acquireDelegateLock(lock);
1272
+ if (!held)
1273
+ return fail("verify", delegateLockBusy());
1257
1274
  let cache = "";
1258
1275
  try {
1259
1276
  const company = jqRawPath(manifest, "company");
@@ -1326,7 +1343,16 @@ function runVerify(args, context) {
1326
1343
  err(`hq-delegate-verify: probe FAILED — the DM must not be sent; fix the failing prefix(es) above and re-run (manifest status left at '${status}')\n`);
1327
1344
  return 1;
1328
1345
  }
1329
- const publishCode = runPublish(["--manifest", manifestPath, "--lock-held"], context);
1346
+ let handedOff = false;
1347
+ const publishCode = runPublish(["--manifest", manifestPath, "--lock-held"], context, () => {
1348
+ // Legacy publication requires a directory lock. Restart legacy verify
1349
+ // after releasing ours so it acquires ownership and rereads all state.
1350
+ held.release();
1351
+ handedOff = true;
1352
+ return runShellFallback("verify", args, context);
1353
+ }, held);
1354
+ if (handedOff)
1355
+ return publishCode;
1330
1356
  if (publishCode !== 0)
1331
1357
  return fail("verify", "final dossier publication failed; notification blocked");
1332
1358
  // Publish rewrote the manifest with its checksums and publication receipt,
@@ -1344,10 +1370,7 @@ function runVerify(args, context) {
1344
1370
  finally {
1345
1371
  if (cache)
1346
1372
  fs.rmSync(cache, { recursive: true, force: true });
1347
- try {
1348
- fs.rmdirSync(lock);
1349
- }
1350
- catch { /* Keep the primary command result. */ }
1373
+ held.release();
1351
1374
  }
1352
1375
  }
1353
1376
  export function runNativeDelegateW1b(name, args, context) {
@@ -1,8 +1,9 @@
1
- /** Native implementations of the five `hq core delegate` shell companions. */
1
+ /** Native implementations of `hq core delegate`, including the one-process `run` flow. */
2
2
  import * as fs from "node:fs";
3
3
  import { Command } from "commander";
4
4
  import { type SpawnPlan } from "../utils/windows-spawn.js";
5
5
  export declare const CORE_NATIVE_DELEGATE_FLAG = "core-native-delegate";
6
+ type DelegateName = "resolve" | "pickup" | "repo" | "secrets" | "transfer";
6
7
  export type DelegateContext = {
7
8
  cwd: string;
8
9
  root?: string;
@@ -22,6 +23,7 @@ type CommandResult = {
22
23
  stderr?: string;
23
24
  stdoutBytes?: Buffer;
24
25
  stderrBytes?: Buffer;
26
+ timedOut?: boolean;
25
27
  };
26
28
  export type CommandExistsOptions = {
27
29
  platform?: NodeJS.Platform;
@@ -37,6 +39,7 @@ export declare function subprocess(command: string, args: string[], cwd: string,
37
39
  stdout?: "capture" | "inherit" | "ignore";
38
40
  env?: NodeJS.ProcessEnv;
39
41
  maxBuffer?: number;
42
+ timeout?: number;
40
43
  }): CommandResult;
41
44
  type JsonRecord = Record<string, unknown>;
42
45
  export declare function isRecord(value: unknown): value is JsonRecord;
@@ -52,8 +55,23 @@ export declare function moveFile(source: string, target: string, fileSystem?: Pi
52
55
  export declare function writeJsonAtomically(target: string, value: unknown, siblingTemp?: boolean, fileSystem?: DelegateAtomicWriteFileSystem): void;
53
56
  export declare function delegateDiagnosticPath(argument: string): string;
54
57
  export declare function scanSecretFiles(file: string): string[] | undefined;
58
+ export declare function runNative(name: DelegateName, args: string[], context: DelegateContext): number;
55
59
  /** Fast-entry adapter; family gating and shell fallback happen before import. */
56
60
  export declare function runDelegateFast(args: readonly string[], _stdin: string, cwd: string, hqRoot: string | undefined, commandName: string): number;
61
+ export type DelegateRunOptions = {
62
+ company: string;
63
+ project: string;
64
+ to: string;
65
+ share?: boolean;
66
+ noSecrets?: boolean;
67
+ dryRun?: boolean;
68
+ manifest?: string;
69
+ headline?: string;
70
+ note?: string;
71
+ githubUser?: string;
72
+ };
73
+ /** Run the /delegate flow in one process. Returns the process exit code. */
74
+ export declare function runDelegateFlow(options: DelegateRunOptions, context: DelegateContext): Promise<number>;
57
75
  /** Register the Wave 1a delegate commands and preserve the shell rollback path. */
58
76
  export declare function registerCoreDelegateCommand(core: Command, registerWave1b?: (delegate: Command, core: Command) => void): void;
59
77
  export {};