@indigoai-us/hq-cli 5.345.226 → 5.345.230

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 (138) hide show
  1. package/CHANGELOG.md +156 -0
  2. package/dist/command-catalog.generated.d.ts +376 -11
  3. package/dist/command-catalog.generated.js +451 -11
  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/hq-cloud-sync-runner/bin/sync-runner.js +1473 -1043
  38. package/dist/hq-cloud-sync-runner/package.json +1 -1
  39. package/dist/lazy-commands.js +3 -4
  40. package/dist/lib/checkpoint-ontology/entity-file.js +4 -4
  41. package/dist/lib/checkpoint-ontology/merge-copies.js +7 -11
  42. package/dist/lib/checkpoint-ontology/plan.js +2 -1
  43. package/dist/lib/core-utils/archive-old-threads.js +5 -2
  44. package/dist/lib/core-utils/session-company.d.ts +13 -1
  45. package/dist/lib/core-utils/session-company.js +75 -4
  46. package/dist/lib/core-utils/worktree-resume.d.ts +6 -0
  47. package/dist/lib/core-utils/worktree-resume.js +8 -4
  48. package/dist/lib/daemon/background-qos.d.ts +7 -0
  49. package/dist/lib/daemon/background-qos.js +13 -0
  50. package/dist/lib/daemon/catalog.d.ts +9 -0
  51. package/dist/lib/daemon/catalog.js +8 -1
  52. package/dist/lib/daemon/hook-requests-acl-suggest.d.ts +18 -0
  53. package/dist/lib/daemon/hook-requests-acl-suggest.js +245 -0
  54. package/dist/lib/daemon/hook-requests-conduct-link.d.ts +20 -0
  55. package/dist/lib/daemon/hook-requests-conduct-link.js +105 -0
  56. package/dist/lib/daemon/hook-requests-fleet-session-start.d.ts +32 -0
  57. package/dist/lib/daemon/hook-requests-fleet-session-start.js +214 -0
  58. package/dist/lib/daemon/hook-requests-mesh-tool-writes.d.ts +44 -0
  59. package/dist/lib/daemon/hook-requests-mesh-tool-writes.js +292 -0
  60. package/dist/lib/daemon/hook-requests-mesh.d.ts +54 -0
  61. package/dist/lib/daemon/hook-requests-mesh.js +559 -0
  62. package/dist/lib/daemon/hook-requests.d.ts +354 -8
  63. package/dist/lib/daemon/hook-requests.js +1330 -46
  64. package/dist/lib/daemon/machine-checks.d.ts +12 -2
  65. package/dist/lib/daemon/machine-checks.js +27 -10
  66. package/dist/lib/daemon/merge-sections.d.ts +24 -2
  67. package/dist/lib/daemon/merge-sections.js +58 -16
  68. package/dist/lib/daemon/ops/policy.js +4 -2
  69. package/dist/lib/daemon/resolver.js +9 -2
  70. package/dist/lib/daemon/run.d.ts +11 -7
  71. package/dist/lib/daemon/run.js +168 -24
  72. package/dist/lib/daemon/search-index-worker-v1.d.ts +2 -0
  73. package/dist/lib/daemon/search-index-worker-v1.js +25 -0
  74. package/dist/lib/daemon/session-registry.d.ts +0 -1
  75. package/dist/lib/daemon/session-registry.js +0 -3
  76. package/dist/lib/daemon/supervisor.d.ts +3 -1
  77. package/dist/lib/daemon/supervisor.js +1 -1
  78. package/dist/lib/daemon/tcc-eperm.d.ts +59 -4
  79. package/dist/lib/daemon/tcc-eperm.js +110 -8
  80. package/dist/lib/doctor/fix/process-identity.d.ts +20 -2
  81. package/dist/lib/doctor/fix/process-identity.js +48 -5
  82. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  83. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  84. package/dist/lib/hook-engine/canary-gate.js +1 -0
  85. package/dist/lib/hook-engine/native-stop-compatibility.json +2 -1
  86. package/dist/lib/hot-channels/adapters/attio.js +2 -1
  87. package/dist/lib/hot-channels/adapters/meetings.js +2 -1
  88. package/dist/lib/lanes/company-outposts.d.ts +37 -0
  89. package/dist/lib/lanes/company-outposts.js +164 -0
  90. package/dist/lib/lanes/liveness.d.ts +6 -0
  91. package/dist/lib/lanes/liveness.js +49 -8
  92. package/dist/lib/lanes/orphan-report.d.ts +15 -0
  93. package/dist/lib/lanes/orphan-report.js +223 -0
  94. package/dist/lib/lanes/orphan-sweep.d.ts +26 -0
  95. package/dist/lib/lanes/orphan-sweep.js +152 -0
  96. package/dist/lib/lanes/reaper.d.ts +2 -0
  97. package/dist/lib/lanes/reaper.js +11 -8
  98. package/dist/lib/lanes/reconcile.d.ts +8 -7
  99. package/dist/lib/lanes/reconcile.js +39 -0
  100. package/dist/lib/mesh/live/backfill-held.d.ts +13 -0
  101. package/dist/lib/mesh/live/backfill-held.js +23 -0
  102. package/dist/lib/mesh/live/daemon/mode.d.ts +8 -4
  103. package/dist/lib/mesh/live/daemon/mode.js +8 -4
  104. package/dist/lib/mesh/live/daemon/run.d.ts +14 -3
  105. package/dist/lib/mesh/live/daemon/run.js +116 -7
  106. package/dist/lib/mesh/live/direct-drain.d.ts +123 -0
  107. package/dist/lib/mesh/live/direct-drain.js +315 -0
  108. package/dist/lib/mesh/live/emit-replay.d.ts +10 -0
  109. package/dist/lib/mesh/live/emit-replay.js +10 -0
  110. package/dist/lib/mesh/live/flush.d.ts +15 -0
  111. package/dist/lib/mesh/live/flush.js +27 -0
  112. package/dist/lib/mesh/live/liveness-carry.d.ts +45 -0
  113. package/dist/lib/mesh/live/liveness-carry.js +141 -0
  114. package/dist/lib/mesh/live/spool.d.ts +19 -0
  115. package/dist/lib/mesh/live/spool.js +80 -0
  116. package/dist/lib/safe-store.d.ts +2 -0
  117. package/dist/lib/safe-store.js +8 -6
  118. package/dist/lib/search-index/index.d.ts +9 -3
  119. package/dist/lib/search-index/index.js +35 -10
  120. package/dist/lib/search-index/worker-process.d.ts +9 -0
  121. package/dist/lib/search-index/worker-process.js +171 -0
  122. package/dist/lib/session-company-lock.d.ts +3 -1
  123. package/dist/lib/session-company-lock.js +3 -2
  124. package/dist/utils/delegate-command-supervisor.d.ts +3 -0
  125. package/dist/utils/delegate-command-supervisor.js +44 -0
  126. package/dist/utils/delegate-lock.d.ts +12 -0
  127. package/dist/utils/delegate-lock.js +88 -0
  128. package/dist/utils/frontmatter.d.ts +27 -0
  129. package/dist/utils/frontmatter.js +33 -0
  130. package/dist/utils/hook-trust.d.ts +1 -0
  131. package/dist/utils/hook-trust.js +18 -2
  132. package/dist/utils/host-registration.d.ts +13 -1
  133. package/dist/utils/host-registration.js +98 -5
  134. package/dist/utils/package-use-lease.d.ts +1 -1
  135. package/dist/utils/package-use-lease.js +15 -7
  136. package/docs/anywhere-runtime.md +17 -0
  137. package/package.json +9 -8
  138. package/scripts/check-function-manifest.mjs +17 -3
@@ -0,0 +1,292 @@
1
+ /** The daemon half of the native Work Mesh tool-writes hook
2
+ * (crates/hq-hook/src/post_mesh_tool_writes.rs, US-049 M5).
3
+ *
4
+ * `core/hooks/PostToolUse/35-work-mesh-tool-writes.sh` started two kinds of
5
+ * background flight with `nohup bash -c`: `hq mesh context bind-project`
6
+ * once per session and project, and `hq mesh context prd-sync` once per
7
+ * session with a dirty file for one more run. The native hook starts no
8
+ * program: it does the file checks, takes the same flight lock in
9
+ * `<work mesh home>/.hq/work-context/sessions/` and leaves a
10
+ * `mesh-tool-writes` note. This module runs that note with the shell
11
+ * flight's protocol:
12
+ *
13
+ * - The flight's pid file holds the daemon's pid while it runs, so the hook
14
+ * sees a live flight as busy. The lock is removed when the flight ends, as
15
+ * the flight's `trap ... EXIT` did.
16
+ * - bind: success leaves the empty success marker and removes the back-off
17
+ * file; a failure (or a run stopped at the time limit) writes the back-off
18
+ * epoch `now + backoffSec`.
19
+ * - prd-sync: the probe the shell hook ran in the session (`hq --version`,
20
+ * then `hq mesh context prd-sync --help`, cached per version in
21
+ * `prd-sync-probe-<version>`) runs here. Without prd-sync the dirty file
22
+ * and the lock are removed. Otherwise the dirty path is synced, and synced
23
+ * again while a write during the run left a new one (at most
24
+ * {@link MESH_TOOL_WRITES_MAX_RUNS} runs).
25
+ * - The dirty path is synced only when it resolves to a real file under the
26
+ * HQ root at `companies/<co>/projects/<p>/prd.json` (see
27
+ * {@link prdFileUnderRoot}); any other path is refused and logged, and
28
+ * `prd-sync` is not started for it.
29
+ * - The programs' output goes to `<sid>.wm-mesh.log`, as the flights' did.
30
+ *
31
+ * A flight never fails the note (code 0): the shell flights had no retry
32
+ * either, and a failed bind has its own back-off.
33
+ */
34
+ import { spawn } from "node:child_process";
35
+ import * as fs from "node:fs";
36
+ import * as path from "node:path";
37
+ import { openStoreDir } from "../safe-store.js";
38
+ /** The session ids and slugs the hook leaves (`spool_session_id`, `plain_name` and the hook's slug check). */
39
+ const SESSION = /^[A-Za-z0-9._-]{1,512}$/;
40
+ const SLUG = /^[A-Za-z0-9._-]{1,255}$/;
41
+ /** prd-sync runs per flight, a bound on a dirty file rewritten forever. */
42
+ export const MESH_TOOL_WRITES_MAX_RUNS = 64;
43
+ /** The longest a program of a flight runs before its group is told to end. */
44
+ export const MESH_TOOL_WRITES_KILL_MS = 60_000;
45
+ const KILL_GRACE_MS = 5_000;
46
+ /** The most of `hq --version` read for the probe's cache name. */
47
+ const VERSION_MAX_CHARS = 200;
48
+ const keysAre = (args, keys) => {
49
+ const have = Object.keys(args).sort();
50
+ const want = [...keys].sort();
51
+ return have.length === want.length && have.every((key, i) => key === want[i]);
52
+ };
53
+ function plainHome(value) {
54
+ return typeof value === "string" && value.length > 0 && value.length <= 1024 && !value.includes("\0")
55
+ && path.posix.isAbsolute(value) && !value.split("/").includes("..");
56
+ }
57
+ /** The operation of a `mesh-tool-writes` note's `args`, or undefined for anything the hook does not write. */
58
+ export function parseMeshToolWrites(args, session) {
59
+ const { sessionId, workMeshHome } = args;
60
+ if (typeof sessionId !== "string" || !SESSION.test(sessionId) || sessionId === "." || sessionId === ".."
61
+ || sessionId !== session || !plainHome(workMeshHome))
62
+ return undefined;
63
+ if (args.action === "bind") {
64
+ const { slug, backoffSec } = args;
65
+ if (!keysAre(args, ["action", "sessionId", "slug", "workMeshHome", "backoffSec"]))
66
+ return undefined;
67
+ if (typeof slug !== "string" || !SLUG.test(slug) || slug === "." || slug === "..")
68
+ return undefined;
69
+ if (typeof backoffSec !== "number" || !Number.isSafeInteger(backoffSec) || backoffSec < 0 || backoffSec > 999_999_999)
70
+ return undefined;
71
+ return { kind: "mesh-tool-writes", action: "bind", sessionId, slug, workMeshHome, backoffSec };
72
+ }
73
+ if (args.action === "prd-sync") {
74
+ if (!keysAre(args, ["action", "sessionId", "workMeshHome"]))
75
+ return undefined;
76
+ return { kind: "mesh-tool-writes", action: "prd-sync", sessionId, workMeshHome };
77
+ }
78
+ return undefined;
79
+ }
80
+ /** `node <hq> <args>` in its own process group, output to `logFd` (stdout also kept when `keep`). */
81
+ function runHq(options, args, logFd, keep = false) {
82
+ return new Promise(resolve => {
83
+ if (options.signal?.aborted) {
84
+ resolve({ code: 1, stdout: "" });
85
+ return;
86
+ }
87
+ const env = { ...(options.env ?? process.env), HQ_ROOT: options.root, HQ_NO_UPDATE_CHECK: "1" };
88
+ const out = logFd === undefined ? "ignore" : logFd;
89
+ const grouped = process.platform !== "win32";
90
+ let child;
91
+ try {
92
+ child = spawn(options.nodeBinary, [options.hqBinary, ...args], {
93
+ cwd: options.root, env, shell: false, windowsHide: true, detached: grouped,
94
+ stdio: ["ignore", keep ? "pipe" : out, out],
95
+ });
96
+ }
97
+ catch {
98
+ resolve({ code: 1, stdout: "" });
99
+ return;
100
+ }
101
+ let stdout = "";
102
+ child.stdout?.setEncoding("utf8");
103
+ child.stdout?.on("data", (text) => {
104
+ if (stdout.length < 4096)
105
+ stdout += text;
106
+ if (logFd !== undefined) {
107
+ try {
108
+ fs.writeSync(logFd, text);
109
+ }
110
+ catch { /* The log is best effort, as `>>log` was. */ }
111
+ }
112
+ });
113
+ child.stdout?.on("error", () => undefined);
114
+ const signalAll = (signal) => {
115
+ try {
116
+ if (grouped && child.pid !== undefined)
117
+ process.kill(-child.pid, signal);
118
+ else
119
+ child.kill(signal);
120
+ }
121
+ catch { /* The group is already gone. */ }
122
+ };
123
+ let ended = false;
124
+ let killTimer;
125
+ const end = () => {
126
+ if (ended)
127
+ return;
128
+ ended = true;
129
+ signalAll("SIGTERM");
130
+ killTimer = setTimeout(() => signalAll("SIGKILL"), options.killGraceMs ?? KILL_GRACE_MS);
131
+ };
132
+ options.signal?.addEventListener("abort", end, { once: true });
133
+ const timer = setTimeout(end, options.timeoutMs ?? MESH_TOOL_WRITES_KILL_MS);
134
+ let settled = false;
135
+ const finish = (code) => {
136
+ if (settled)
137
+ return;
138
+ settled = true;
139
+ clearTimeout(timer);
140
+ if (killTimer)
141
+ clearTimeout(killTimer);
142
+ options.signal?.removeEventListener("abort", end);
143
+ if (ended) {
144
+ signalAll("SIGKILL");
145
+ resolve({ code: code === 0 ? 1 : code, stdout });
146
+ return;
147
+ }
148
+ resolve({ code, stdout });
149
+ };
150
+ child.on("error", () => finish(1));
151
+ child.on("close", (code) => finish(code ?? 1));
152
+ });
153
+ }
154
+ /**
155
+ * The path `prd-sync --file` may be given for a dirty file's text: the
156
+ * text must be an absolute path with no `..` segment that resolves (links
157
+ * followed) to an existing file under the real HQ root at
158
+ * `companies/<co>/projects/<p>/prd.json`, with plain company and project
159
+ * names. The answer is that file under `root` as given; undefined (refuse)
160
+ * for anything else or anything that cannot be resolved.
161
+ */
162
+ export function prdFileUnderRoot(file, root) {
163
+ if (!file || file.includes("\0") || !path.isAbsolute(file) || file.split(/[\\/]/).includes(".."))
164
+ return undefined;
165
+ let real;
166
+ let realRoot;
167
+ try {
168
+ real = fs.realpathSync(file);
169
+ realRoot = fs.realpathSync(root);
170
+ if (!fs.statSync(real).isFile())
171
+ return undefined;
172
+ }
173
+ catch {
174
+ return undefined;
175
+ }
176
+ const rel = path.relative(realRoot, real);
177
+ if (!rel || path.isAbsolute(rel))
178
+ return undefined;
179
+ const parts = rel.split(path.sep);
180
+ if (parts.length !== 5 || parts[0] !== "companies" || parts[2] !== "projects" || parts[4] !== "prd.json")
181
+ return undefined;
182
+ if (![parts[1], parts[3]].every(part => SLUG.test(part) && part !== "." && part !== ".."))
183
+ return undefined;
184
+ return path.join(root, ...parts);
185
+ }
186
+ /** One line in the flight's log; best effort, as `>>log` was. */
187
+ function logLine(logFd, line) {
188
+ if (logFd === undefined)
189
+ return;
190
+ try {
191
+ fs.writeSync(logFd, `${line}\n`);
192
+ }
193
+ catch { /* The log is best effort. */ }
194
+ }
195
+ /** `$(cat file)`: the text with its trailing line breaks cut, empty when absent or refused. */
196
+ function cat(store, name) {
197
+ const read = store.read(name, { maxBytes: 8192 });
198
+ return read.ok ? read.value.toString("utf8").replace(/\n+$/, "") : "";
199
+ }
200
+ /** The flight's log, opened for appending without following a link. */
201
+ function openLog(store, sid) {
202
+ try {
203
+ const flags = fs.constants.O_WRONLY | fs.constants.O_APPEND | fs.constants.O_CREAT | (fs.constants.O_NOFOLLOW ?? 0);
204
+ return fs.openSync(path.join(store.path, `${sid}.wm-mesh.log`), flags, 0o600);
205
+ }
206
+ catch {
207
+ return undefined;
208
+ }
209
+ }
210
+ /** `_wm_prd_sync_supported`: the probe, cached per `hq --version`. */
211
+ async function prdSyncSupported(op, options) {
212
+ const version = await runHq(options, ["--version"], undefined, true);
213
+ let ver = (version.stdout.split("\n")[0] ?? "").replace(/[^A-Za-z0-9._-]/g, "_").slice(0, VERSION_MAX_CHARS);
214
+ if (!ver)
215
+ ver = "unknown";
216
+ const opened = openStoreDir(path.join(op.workMeshHome, ".hq/work-context"), { create: true, home: op.workMeshHome });
217
+ if (!opened.ok)
218
+ return false;
219
+ const store = opened.value;
220
+ try {
221
+ const cache = `prd-sync-probe-${ver}`;
222
+ const held = store.read(cache, { maxBytes: 64 });
223
+ if (held.ok)
224
+ return held.value.toString("utf8").replace(/\n+$/, "") === "yes";
225
+ // `hq mesh context prd-sync --help >/dev/null 2>&1`.
226
+ const help = await runHq(options, ["mesh", "context", "prd-sync", "--help"], undefined);
227
+ const yes = help.code === 0;
228
+ store.writeAtomic(cache, yes ? "yes\n" : "no\n");
229
+ return yes;
230
+ }
231
+ finally {
232
+ store.close();
233
+ }
234
+ }
235
+ /** Run one `mesh-tool-writes` note. Always done (code 0); see the module comment. */
236
+ export async function runMeshToolWrites(operation, options) {
237
+ const now = options.now ?? Date.now;
238
+ const opened = openStoreDir(path.join(operation.workMeshHome, ".hq/work-context/sessions"), { create: true, home: operation.workMeshHome });
239
+ if (!opened.ok)
240
+ return { code: 0 };
241
+ const store = opened.value;
242
+ const sid = operation.sessionId;
243
+ const flight = operation.action === "bind" ? `${sid}.wm-bind-${operation.slug}` : `${sid}.wm-prd`;
244
+ const logFd = openLog(store, sid);
245
+ try {
246
+ store.writeAtomic(`${flight}.pid`, `${process.pid}\n`);
247
+ if (operation.action === "bind") {
248
+ const ran = await runHq(options, ["mesh", "context", "bind-project", operation.slug, "--session", sid, "--json"], logFd);
249
+ if (ran.code === 0) {
250
+ store.writeAtomic(flight, "");
251
+ store.remove(`${flight}.backoff`);
252
+ }
253
+ else {
254
+ store.writeAtomic(`${flight}.backoff`, `${Math.floor(now() / 1000) + operation.backoffSec}\n`);
255
+ }
256
+ return { code: 0 };
257
+ }
258
+ if (!await prdSyncSupported(operation, options)) {
259
+ store.remove(`${flight}.dirty`);
260
+ return { code: 0 };
261
+ }
262
+ for (let run = 0; run < MESH_TOOL_WRITES_MAX_RUNS; run++) {
263
+ const file = cat(store, `${flight}.dirty`);
264
+ store.remove(`${flight}.dirty`);
265
+ if (!file)
266
+ break;
267
+ const checked = prdFileUnderRoot(file, options.root);
268
+ if (checked === undefined) {
269
+ logLine(logFd, `hq-daemon mesh-tool-writes: refused prd-sync for ${JSON.stringify(file.slice(0, 1024))}: not a companies/<co>/projects/<p>/prd.json file under the HQ root`);
270
+ }
271
+ else {
272
+ await runHq(options, ["mesh", "context", "prd-sync", "--session", sid, "--file", checked], logFd);
273
+ }
274
+ if (options.signal?.aborted)
275
+ break;
276
+ if (!store.stat(`${flight}.dirty`).ok)
277
+ break;
278
+ }
279
+ return { code: 0 };
280
+ }
281
+ finally {
282
+ store.remove(`${flight}.lock`);
283
+ if (logFd !== undefined) {
284
+ try {
285
+ fs.closeSync(logFd);
286
+ }
287
+ catch { /* Already closed. */ }
288
+ }
289
+ store.close();
290
+ }
291
+ }
292
+ //# sourceMappingURL=hook-requests-mesh-tool-writes.js.map
@@ -0,0 +1,54 @@
1
+ export type MeshOperation = {
2
+ kind: "mesh-reconcile";
3
+ observation: string;
4
+ seq: string;
5
+ } | {
6
+ kind: "mesh-register-retry";
7
+ company: string;
8
+ uid: string;
9
+ };
10
+ export declare const MESH_RECONCILE_KILL_MS = 10000;
11
+ export declare const MESH_ENSURE_KILL_MS = 5000;
12
+ /** `retry_pending` registers at most this many entries per pass. */
13
+ export declare const MESH_RETRY_LIMIT = 3;
14
+ /** The operation in a note's `kind` and `args`, or undefined for anything the writer does not produce. */
15
+ export declare function parseMeshOperation(kind: unknown, args: Record<string, unknown>, session: string): MeshOperation | undefined;
16
+ export interface MeshRunOptions {
17
+ nodeBinary: string;
18
+ hqBinary: string;
19
+ env?: NodeJS.ProcessEnv;
20
+ signal?: AbortSignal;
21
+ log?: (message: string) => void;
22
+ /** Clock (tests). */
23
+ now?: () => number;
24
+ /** Limits (tests): SIGTERM to the call's process group at the limit. */
25
+ reconcileKillMs?: number;
26
+ ensureKillMs?: number;
27
+ /** SIGKILL to the group this long after the SIGTERM (default `HOOK_REQUEST_KILL_GRACE_MS`). */
28
+ killGraceMs?: number;
29
+ }
30
+ /** `_wm_tmp_sweep` for `workspace/tmp/work-mesh`, at most once an hour per root. The legacy folders in the system temp folder are not swept here. */
31
+ export declare function sweepMeshTmp(root: string, now: number): boolean;
32
+ /** `_wm_reconcile_drain` for one session's newest observation. */
33
+ export declare function runMeshReconcile(root: string, session: string, operation: Extract<MeshOperation, {
34
+ kind: "mesh-reconcile";
35
+ }>, options: MeshRunOptions): Promise<{
36
+ code: number;
37
+ }>;
38
+ /** `recorded_uid`: `.company-uid`, then the manifest's `cloud_uid`. */
39
+ export declare function recordedUid(root: string, company: string): string;
40
+ /**
41
+ * True when every number in valid JSON `source` has the same value after
42
+ * `JSON.parse` and `JSON.stringify`. The spelling may change (`1.0` to `1`);
43
+ * the value may not (an integer past 2^53, more digits than a double holds,
44
+ * a number too large for one).
45
+ */
46
+ export declare function numbersSurvive(source: string): boolean;
47
+ /** `retry_pending <company>`. */
48
+ export declare function runMeshRegisterRetry(root: string, operation: Extract<MeshOperation, {
49
+ kind: "mesh-register-retry";
50
+ }>, options: MeshRunOptions): Promise<{
51
+ code: number;
52
+ registered: number;
53
+ }>;
54
+ //# sourceMappingURL=hook-requests-mesh.d.ts.map