@indigoai-us/hq-cli 5.345.245 → 5.345.247
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.
- package/CHANGELOG.md +91 -0
- package/dist/command-catalog.generated.d.ts +96 -9
- package/dist/command-catalog.generated.js +117 -9
- package/dist/commands/bot.js +1 -1
- package/dist/commands/core-checkpoint-native.d.ts +5 -1
- package/dist/commands/core-checkpoint-native.js +13 -5
- package/dist/commands/deploy-comments.js +139 -0
- package/dist/commands/deploy-list.d.ts +5 -0
- package/dist/commands/deploy-list.js +8 -0
- package/dist/commands/dm.d.ts +4 -1
- package/dist/commands/dm.js +11 -2
- package/dist/commands/files.d.ts +11 -2
- package/dist/commands/files.js +48 -3
- package/dist/commands/install-global.d.ts +15 -0
- package/dist/commands/install-global.js +98 -4
- package/dist/commands/lanes-loop.js +4 -1
- package/dist/commands/lanes.js +16 -5
- package/dist/commands/mcp-registration.d.ts +17 -0
- package/dist/commands/mcp-registration.js +119 -0
- package/dist/commands/mesh.d.ts +2 -0
- package/dist/commands/mesh.js +26 -6
- package/dist/commands/pkg-install.js +1 -1
- package/dist/commands/reindex.js +3 -2
- package/dist/commands/rescue.d.ts +22 -1
- package/dist/commands/rescue.js +56 -9
- package/dist/commands/sources.d.ts +1 -1
- package/dist/commands/sources.js +1 -1
- package/dist/commands/storage.d.ts +15 -2
- package/dist/commands/storage.js +74 -7
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +232 -225
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/agent-kit/mcp/tools.js +22 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +4 -1
- package/dist/lib/daemon/fleet-members-cache.d.ts +55 -0
- package/dist/lib/daemon/fleet-members-cache.js +266 -0
- package/dist/lib/daemon/handoff.d.ts +4 -0
- package/dist/lib/daemon/handoff.js +2 -1
- package/dist/lib/daemon/hook-requests.d.ts +2 -1
- package/dist/lib/daemon/hook-requests.js +19 -2
- package/dist/lib/daemon/install.d.ts +9 -1
- package/dist/lib/daemon/install.js +11 -2
- package/dist/lib/daemon/ops/policy.d.ts +23 -3
- package/dist/lib/daemon/ops/policy.js +62 -15
- package/dist/lib/daemon/run.js +12 -0
- package/dist/lib/daemon/server.d.ts +5 -0
- package/dist/lib/daemon/server.js +1 -1
- package/dist/lib/daemon/supervisor.d.ts +6 -0
- package/dist/lib/daemon/supervisor.js +31 -2
- package/dist/lib/doctor/checks/antigravity-wiring.d.ts +21 -0
- package/dist/lib/doctor/checks/antigravity-wiring.js +75 -0
- package/dist/lib/doctor/checks/anywhere.js +30 -0
- package/dist/lib/doctor/checks/runtime-probe.js +13 -0
- package/dist/lib/doctor/checks/sync-runtime.js +8 -1
- package/dist/lib/doctor/platform.d.ts +1 -1
- package/dist/lib/doctor/platform.js +5 -0
- package/dist/lib/doctor/registry.js +3 -0
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/hook-engine/coverage.d.ts +159 -0
- package/dist/lib/hook-engine/coverage.js +347 -0
- package/dist/lib/hook-engine/native-precompact-compatibility.json +1 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +52 -2
- package/dist/lib/hot-channels/signals-pass.js +65 -3
- package/dist/lib/install/antigravity-targets.d.ts +39 -0
- package/dist/lib/install/antigravity-targets.js +122 -0
- package/dist/lib/install/claude-targets.d.ts +6 -0
- package/dist/lib/install/claude-targets.js +9 -1
- package/dist/lib/lanes/reconcile-result.d.ts +1 -1
- package/dist/lib/lanes/reconcile.js +19 -4
- package/dist/lib/lanes/remote-control-lane.d.ts +6 -0
- package/dist/lib/lanes/remote-control-lane.js +10 -1
- package/dist/lib/lanes/spawn.d.ts +2 -0
- package/dist/lib/lanes/spawn.js +19 -3
- package/dist/lib/lanes/worker-env-scrub.d.ts +48 -0
- package/dist/lib/lanes/worker-env-scrub.js +146 -0
- package/dist/lib/lanes/worker-process.js +4 -1
- package/dist/lib/mesh/client.js +5 -1
- package/dist/lib/mesh/live/daemon/doctor.d.ts +9 -0
- package/dist/lib/mesh/live/daemon/doctor.js +51 -6
- package/dist/lib/mesh/live/daemon/install.d.ts +39 -0
- package/dist/lib/mesh/live/daemon/install.js +70 -0
- package/dist/lib/mesh/live/daemon/outbox-company.d.ts +47 -0
- package/dist/lib/mesh/live/daemon/outbox-company.js +77 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +2 -0
- package/dist/lib/mesh/live/daemon/run.js +48 -3
- package/dist/lib/mesh/live/daemon/state.d.ts +5 -0
- package/dist/lib/mesh/live/daemon/system-unit.d.ts +21 -0
- package/dist/lib/mesh/live/daemon/system-unit.js +80 -0
- package/dist/lib/mesh/live/daemon/transcript-watch.d.ts +4 -1
- package/dist/lib/mesh/live/daemon/transcript-watch.js +42 -38
- package/dist/lib/mesh/live/direct-drain.js +3 -1
- package/dist/lib/mesh/live/emit.js +4 -2
- package/dist/lib/mesh/live/flush.d.ts +61 -0
- package/dist/lib/mesh/live/flush.js +434 -114
- package/dist/lib/mesh/live/paths.d.ts +10 -0
- package/dist/lib/mesh/live/paths.js +14 -0
- package/dist/lib/mesh/live/reporting-privacy.d.ts +41 -1
- package/dist/lib/mesh/live/reporting-privacy.js +81 -7
- package/dist/lib/mesh/live/spool.d.ts +171 -17
- package/dist/lib/mesh/live/spool.js +777 -62
- package/dist/lib/signals/engine.d.ts +82 -2
- package/dist/lib/signals/engine.js +389 -53
- package/dist/lib/signals/steps/extract.js +5 -0
- package/dist/lib/work-context/organize.d.ts +22 -4
- package/dist/lib/work-context/organize.js +50 -21
- package/dist/lib/work-context/paths.d.ts +6 -0
- package/dist/lib/work-context/paths.js +9 -0
- package/dist/lib/work-context/reconcile.d.ts +1 -1
- package/dist/lib/work-context/reconcile.js +1 -1
- package/dist/startup-registration.d.ts +14 -0
- package/dist/startup-registration.js +26 -0
- package/dist/utils/cli-telemetry.d.ts +6 -0
- package/dist/utils/cli-telemetry.js +154 -9
- package/dist/utils/github-tag-fallback.d.ts +7 -2
- package/dist/utils/github-tag-fallback.js +17 -8
- package/dist/utils/hq-core-source.d.ts +31 -0
- package/dist/utils/hq-core-source.js +144 -0
- package/dist/utils/interactive-caller.d.ts +6 -0
- package/dist/utils/interactive-caller.js +8 -0
- package/dist/utils/shipped-codex-hooks.d.ts +6 -4
- package/dist/utils/shipped-codex-hooks.js +22 -10
- package/dist/utils/vault-api.js +1 -0
- package/dist/utils/version-report.d.ts +3 -1
- package/dist/utils/version-report.js +13 -5
- package/docs/anywhere-runtime.md +2 -2
- package/package.json +8 -8
- package/scripts/check-function-manifest.mjs +99 -18
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The box-level Work Mesh unit at /etc/systemd/system/hq-mesh-daemon.service.
|
|
3
|
+
*
|
|
4
|
+
* Hosted agent boxes run the daemon from this system unit (installed by the
|
|
5
|
+
* box's own tooling with `hq mesh daemon install --system-user ...`). A
|
|
6
|
+
* per-user unit next to it starts a second daemon that cannot take the pid
|
|
7
|
+
* lock and restarts every few seconds, so install, status and the daemon's
|
|
8
|
+
* start path all need to see the system unit.
|
|
9
|
+
*/
|
|
10
|
+
import * as fs from "node:fs";
|
|
11
|
+
import * as path from "node:path";
|
|
12
|
+
import { SYSTEMD_UNIT_NAME } from "./paths.js";
|
|
13
|
+
export const SYSTEMD_SYSTEM_UNIT_DIR = "/etc/systemd/system";
|
|
14
|
+
export function meshSystemUnitPath(systemUnitDir = SYSTEMD_SYSTEM_UNIT_DIR) {
|
|
15
|
+
return path.join(systemUnitDir, SYSTEMD_UNIT_NAME);
|
|
16
|
+
}
|
|
17
|
+
export function meshSystemUnitPresent(systemUnitDir = SYSTEMD_SYSTEM_UNIT_DIR, existsSync = fs.existsSync) {
|
|
18
|
+
return existsSync(meshSystemUnitPath(systemUnitDir));
|
|
19
|
+
}
|
|
20
|
+
/** Parse `systemctl show -p LoadState -p ActiveState -p SubState -p UnitFileState` output. */
|
|
21
|
+
export function parseSystemctlShow(stdout) {
|
|
22
|
+
const values = new Map();
|
|
23
|
+
for (const line of stdout.split(/\r?\n/)) {
|
|
24
|
+
const eq = line.indexOf("=");
|
|
25
|
+
if (eq <= 0)
|
|
26
|
+
continue;
|
|
27
|
+
values.set(line.slice(0, eq).trim(), line.slice(eq + 1).trim());
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
loadState: values.get("LoadState") ?? "",
|
|
31
|
+
activeState: values.get("ActiveState") ?? "",
|
|
32
|
+
subState: values.get("SubState") ?? "",
|
|
33
|
+
unitFileState: values.get("UnitFileState") ?? "",
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Read the system unit's state from the system manager. Reading needs no root.
|
|
38
|
+
* Returns null when systemctl cannot answer (no systemd, no bus).
|
|
39
|
+
*/
|
|
40
|
+
export function readMeshSystemUnitState(run) {
|
|
41
|
+
let result;
|
|
42
|
+
try {
|
|
43
|
+
result = run("systemctl", [
|
|
44
|
+
"show",
|
|
45
|
+
"-p",
|
|
46
|
+
"LoadState",
|
|
47
|
+
"-p",
|
|
48
|
+
"ActiveState",
|
|
49
|
+
"-p",
|
|
50
|
+
"SubState",
|
|
51
|
+
"-p",
|
|
52
|
+
"UnitFileState",
|
|
53
|
+
SYSTEMD_UNIT_NAME,
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
if (result.status !== 0)
|
|
60
|
+
return null;
|
|
61
|
+
const state = parseSystemctlShow(result.stdout);
|
|
62
|
+
if (!state.loadState && !state.activeState)
|
|
63
|
+
return null;
|
|
64
|
+
return state;
|
|
65
|
+
}
|
|
66
|
+
/** One plain phrase for the state, for example "active (running), enabled". */
|
|
67
|
+
export function describeSystemUnitState(state) {
|
|
68
|
+
if (!state)
|
|
69
|
+
return "state unknown (systemctl did not answer)";
|
|
70
|
+
const active = state.subState && state.subState !== state.activeState
|
|
71
|
+
? `${state.activeState} (${state.subState})`
|
|
72
|
+
: state.activeState || "unknown";
|
|
73
|
+
const parts = [active];
|
|
74
|
+
if (state.loadState && state.loadState !== "loaded")
|
|
75
|
+
parts.push(state.loadState);
|
|
76
|
+
if (state.unitFileState)
|
|
77
|
+
parts.push(state.unitFileState);
|
|
78
|
+
return parts.join(", ");
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=system-unit.js.map
|
|
@@ -253,9 +253,12 @@ export declare function resolveTranscriptRegistration(input: {
|
|
|
253
253
|
}): SessionStateFile;
|
|
254
254
|
/**
|
|
255
255
|
* Scan a spool/held jsonl for hook-emitted session ids (not transcript-watch).
|
|
256
|
-
* Reads spool metadata only — never a transcript file.
|
|
256
|
+
* Reads spool metadata only — never a transcript file. The file is streamed
|
|
257
|
+
* line by line: a spool past V8's ~512 MB string limit cannot be read whole.
|
|
258
|
+
* Returns each noted session id once.
|
|
257
259
|
*/
|
|
258
260
|
export declare function noteHookSessionsFromSpoolFile(spoolPath: string, lastHookEventAt: Map<string, number>, atMs: number, tfs?: Pick<TranscriptFs, "existsSync"> & {
|
|
261
|
+
/** Unused: kept so existing callers still type-check. The file is streamed. */
|
|
259
262
|
readFileSync?: (p: string, enc: "utf8") => string;
|
|
260
263
|
}, lastHookTurnEndAt?: Map<string, number>): string[];
|
|
261
264
|
export declare class TranscriptWatcher {
|
|
@@ -50,6 +50,7 @@ import { isHookWrittenSessionState, readSessionState, writeSessionState, } from
|
|
|
50
50
|
import { enqueueSessionEvent } from "../enqueue.js";
|
|
51
51
|
import { isValidSessionId } from "../session-identity.js";
|
|
52
52
|
import { reserveSessionSeq } from "../session-seq.js";
|
|
53
|
+
import { forEachJsonlLine } from "../spool.js";
|
|
53
54
|
export const TRANSCRIPT_WATCH_INTERVAL_MS = 30_000;
|
|
54
55
|
/** Ceiling for adaptive backoff after heavy ticks. */
|
|
55
56
|
export const TRANSCRIPT_WATCH_INTERVAL_MAX_MS = 120_000;
|
|
@@ -516,55 +517,58 @@ export function resolveTranscriptRegistration(input) {
|
|
|
516
517
|
}
|
|
517
518
|
/**
|
|
518
519
|
* Scan a spool/held jsonl for hook-emitted session ids (not transcript-watch).
|
|
519
|
-
* Reads spool metadata only — never a transcript file.
|
|
520
|
+
* Reads spool metadata only — never a transcript file. The file is streamed
|
|
521
|
+
* line by line: a spool past V8's ~512 MB string limit cannot be read whole.
|
|
522
|
+
* Returns each noted session id once.
|
|
520
523
|
*/
|
|
521
524
|
export function noteHookSessionsFromSpoolFile(spoolPath, lastHookEventAt, atMs, tfs = defaultTranscriptFs, lastHookTurnEndAt) {
|
|
522
525
|
if (!tfs.existsSync(spoolPath))
|
|
523
526
|
return [];
|
|
524
|
-
const
|
|
525
|
-
let text;
|
|
527
|
+
const noted = new Set();
|
|
526
528
|
try {
|
|
527
|
-
|
|
529
|
+
forEachJsonlLine(spoolPath, (rawLine) => {
|
|
530
|
+
const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
|
|
531
|
+
noteHookSessionLine(line, lastHookEventAt, atMs, noted, lastHookTurnEndAt);
|
|
532
|
+
});
|
|
528
533
|
}
|
|
529
534
|
catch {
|
|
530
|
-
|
|
535
|
+
// A read error mid-file: keep what was noted.
|
|
531
536
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
const prev = lastHookEventAt.get(ev.sessionId);
|
|
552
|
-
if (prev === undefined || eventAt > prev) {
|
|
553
|
-
lastHookEventAt.set(ev.sessionId, eventAt);
|
|
554
|
-
}
|
|
555
|
-
if (ev.kind === "turn_end" && lastHookTurnEndAt) {
|
|
556
|
-
const prevEnd = lastHookTurnEndAt.get(ev.sessionId);
|
|
557
|
-
if (prevEnd === undefined || eventAt > prevEnd) {
|
|
558
|
-
lastHookTurnEndAt.set(ev.sessionId, eventAt);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
noted.push(ev.sessionId);
|
|
537
|
+
return [...noted];
|
|
538
|
+
}
|
|
539
|
+
function noteHookSessionLine(line, lastHookEventAt, atMs, noted, lastHookTurnEndAt) {
|
|
540
|
+
if (!line.trim())
|
|
541
|
+
return;
|
|
542
|
+
try {
|
|
543
|
+
const raw = JSON.parse(line);
|
|
544
|
+
const ev = raw.event && typeof raw.event === "object" ? raw.event : raw;
|
|
545
|
+
if (typeof ev.sessionId !== "string" || !ev.sessionId)
|
|
546
|
+
return;
|
|
547
|
+
// Synthesized transcript events carry source=transcript — not hooks.
|
|
548
|
+
if (ev.source === TRANSCRIPT_EVENT_SOURCE)
|
|
549
|
+
return;
|
|
550
|
+
let eventAt = atMs;
|
|
551
|
+
const atRaw = typeof ev.at === "string" ? ev.at : undefined;
|
|
552
|
+
if (atRaw) {
|
|
553
|
+
const parsed = Date.parse(atRaw);
|
|
554
|
+
if (Number.isFinite(parsed))
|
|
555
|
+
eventAt = parsed;
|
|
562
556
|
}
|
|
563
|
-
|
|
564
|
-
|
|
557
|
+
const prev = lastHookEventAt.get(ev.sessionId);
|
|
558
|
+
if (prev === undefined || eventAt > prev) {
|
|
559
|
+
lastHookEventAt.set(ev.sessionId, eventAt);
|
|
560
|
+
}
|
|
561
|
+
if (ev.kind === "turn_end" && lastHookTurnEndAt) {
|
|
562
|
+
const prevEnd = lastHookTurnEndAt.get(ev.sessionId);
|
|
563
|
+
if (prevEnd === undefined || eventAt > prevEnd) {
|
|
564
|
+
lastHookTurnEndAt.set(ev.sessionId, eventAt);
|
|
565
|
+
}
|
|
565
566
|
}
|
|
567
|
+
noted.add(ev.sessionId);
|
|
568
|
+
}
|
|
569
|
+
catch {
|
|
570
|
+
/* ignore malformed */
|
|
566
571
|
}
|
|
567
|
-
return noted;
|
|
568
572
|
}
|
|
569
573
|
export class TranscriptWatcher {
|
|
570
574
|
tracked = new Map();
|
|
@@ -34,7 +34,7 @@ export const DIRECT_DEAD_LETTER_MAX_LINES = 5_000;
|
|
|
34
34
|
/** A spool line is far longer than this, so a smaller file is under the cap. */
|
|
35
35
|
const MIN_SPOOL_LINE_BYTES = 64;
|
|
36
36
|
/** Queue files that exist before the first run: the live files and any claim. */
|
|
37
|
-
const PRE_EXISTING_QUEUE_RE = /^(spool\.jsonl|held\.jsonl|(spool|held)\..+\.claimed)$/;
|
|
37
|
+
const PRE_EXISTING_QUEUE_RE = /^(spool\.jsonl|held\.jsonl|spool\.parked\.jsonl|(spool|held)\..+\.claimed)$/;
|
|
38
38
|
export function directDrainMarkerPath(root) {
|
|
39
39
|
return path.join(root, DIRECT_DRAIN_MARKER_BASENAME);
|
|
40
40
|
}
|
|
@@ -217,6 +217,8 @@ export function directFlushDeps(base, now = () => new Date()) {
|
|
|
217
217
|
...base,
|
|
218
218
|
companyEvidence: "own_session",
|
|
219
219
|
authorizeDeviceDefaultTenant: undefined,
|
|
220
|
+
// Lines a flush may not act on stay on the spool, under capSpool's bound.
|
|
221
|
+
parkUnbound: false,
|
|
220
222
|
onSpoolLinesClaimed: (lines) => {
|
|
221
223
|
updateLivenessCarry(base.workMeshRoot, (ingest) => {
|
|
222
224
|
for (const line of lines)
|
|
@@ -124,10 +124,12 @@ export async function emitEvents(deps) {
|
|
|
124
124
|
// Events stored before this machine first saw HQ Anywhere off were held
|
|
125
125
|
// back by the member's opt-out; while it stays off they wait.
|
|
126
126
|
let bound = [];
|
|
127
|
-
|
|
127
|
+
const confirmed = operatorAllowsHqAnywhere(env)
|
|
128
|
+
? combined.filter(event => hasWorkMeshEventCompanyBinding(event, env)) : [];
|
|
129
|
+
if (confirmed.length > 0) {
|
|
128
130
|
const offSinceMs = anywhereOffSince(deps.workMeshRoot, now);
|
|
129
131
|
logAnywhereOffSinceAhead(deps.workMeshRoot, offSinceMs, now().getTime(), deps.log);
|
|
130
|
-
bound =
|
|
132
|
+
bound = confirmed.filter(event => eventDatedSince(event, offSinceMs));
|
|
131
133
|
}
|
|
132
134
|
if (bound.length === 0) {
|
|
133
135
|
const written = persistRetry(combined);
|
|
@@ -22,6 +22,49 @@ export declare const HELD_MAX_LINES = 20000;
|
|
|
22
22
|
* The catalog itself is also cached inside bind-best.
|
|
23
23
|
*/
|
|
24
24
|
export declare const PROJECT_REBIND_INTERVAL_MS = 60000;
|
|
25
|
+
/**
|
|
26
|
+
* Most claimed events one flush keeps in memory to act on. Lines past it go
|
|
27
|
+
* back on the spool as they were, for a later flush, so a claim of any size is
|
|
28
|
+
* read with bounded memory. Far above a normal spool, so ordinary flushes are
|
|
29
|
+
* unchanged.
|
|
30
|
+
*/
|
|
31
|
+
export declare const FLUSH_MAX_EVENTS_IN_MEMORY = 200000;
|
|
32
|
+
/**
|
|
33
|
+
* Most bytes of claimed lines one flush keeps in memory to act on, next to
|
|
34
|
+
* the event count: a few very large events reach the heap limit long before
|
|
35
|
+
* 200,000 of them. Lines past it go back on the spool like lines past the
|
|
36
|
+
* count. The first event is always kept, so one oversized line cannot stall
|
|
37
|
+
* the queue.
|
|
38
|
+
*/
|
|
39
|
+
export declare const FLUSH_MAX_BYTES_IN_MEMORY: number;
|
|
40
|
+
/**
|
|
41
|
+
* A line in the parked file (see workMeshParkedPath) is dropped once it was
|
|
42
|
+
* parked longer ago than this, with a dropped receipt and a log line, so the
|
|
43
|
+
* parked file does not grow for ever on a machine that stays off. The age is
|
|
44
|
+
* the time since the line was parked, never the event's own time, and only
|
|
45
|
+
* lines read back from the parked file are dropped: a line read from the
|
|
46
|
+
* spool or a spool claim is parked, never dropped, however old its event.
|
|
47
|
+
*/
|
|
48
|
+
export declare const PARKED_LINE_MAX_AGE_MS: number;
|
|
49
|
+
/**
|
|
50
|
+
* How far a recorded parked-at time may be ahead of the clock before the
|
|
51
|
+
* clock is taken to be wrong (behind the time lines were parked), in which
|
|
52
|
+
* case nothing is dropped.
|
|
53
|
+
*/
|
|
54
|
+
export declare const PARKED_CLOCK_SKEW_MS: number;
|
|
55
|
+
/**
|
|
56
|
+
* The smallest spool the first bound-only flush parks with no bound session's
|
|
57
|
+
* event in it. Below one read chunk, scanning the spool costs little, and the
|
|
58
|
+
* flush leaves it exactly as it is (the usual rule with HQ Anywhere off).
|
|
59
|
+
*/
|
|
60
|
+
export declare const PARK_BACKLOG_MIN_BYTES: number;
|
|
61
|
+
/** Test hook: forget which roots had their first bound-only flush. */
|
|
62
|
+
export declare function resetFirstBoundOnlyFlushes(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Most distinct eventIds one flush remembers to collapse repeated lines of the
|
|
65
|
+
* same event. Past it, ids already remembered are still collapsed.
|
|
66
|
+
*/
|
|
67
|
+
export declare const FLUSH_DEDUPE_MAX_IDS = 1000000;
|
|
25
68
|
export type HeldReason = "STATE_ABSENT" | "NEEDS_COMPANY" | "COMPANY_CONFLICT" | "NEEDS_PROJECT" | "HELD_EXPIRED" | "HELD_OVERFLOW";
|
|
26
69
|
export interface FlushDeps {
|
|
27
70
|
/**
|
|
@@ -86,6 +129,18 @@ export interface FlushDeps {
|
|
|
86
129
|
* drain records session liveness from them (lanes reads it).
|
|
87
130
|
*/
|
|
88
131
|
onSpoolLinesClaimed?: (lines: string[]) => void;
|
|
132
|
+
/** Default FLUSH_MAX_EVENTS_IN_MEMORY (tests pass a small value). */
|
|
133
|
+
maxEventsInMemory?: number;
|
|
134
|
+
/** Default FLUSH_DEDUPE_MAX_IDS. */
|
|
135
|
+
dedupeMaxIds?: number;
|
|
136
|
+
/** Default FLUSH_MAX_BYTES_IN_MEMORY (tests pass a small value). */
|
|
137
|
+
maxBytesInMemory?: number;
|
|
138
|
+
/**
|
|
139
|
+
* With HQ Anywhere off, park the lines this flush may not act on instead of
|
|
140
|
+
* putting them back on the spool. Default true. The direct-mode drain passes
|
|
141
|
+
* false: its spool cap must keep bounding those lines.
|
|
142
|
+
*/
|
|
143
|
+
parkUnbound?: boolean;
|
|
89
144
|
}
|
|
90
145
|
export type FlushNoClaimReason = "operator_switch_off" | "anywhere_off_no_company_session_event";
|
|
91
146
|
export interface FlushSummary {
|
|
@@ -101,6 +156,12 @@ export interface FlushSummary {
|
|
|
101
156
|
/** Oldest held lines dead-lettered this flush due to HELD_MAX_LINES. */
|
|
102
157
|
heldOverflow?: number;
|
|
103
158
|
noClaimReason?: FlushNoClaimReason;
|
|
159
|
+
/** Repeated lines of an event already read this flush, collapsed to one. */
|
|
160
|
+
duplicates?: number;
|
|
161
|
+
/** Lines parked with HQ Anywhere off (see workMeshParkedPath). */
|
|
162
|
+
parked?: number;
|
|
163
|
+
/** Lines read from the parked file and dropped: parked longer ago than PARKED_LINE_MAX_AGE_MS. */
|
|
164
|
+
parkedExpired?: number;
|
|
104
165
|
}
|
|
105
166
|
/**
|
|
106
167
|
* Flush spool + held. Safe to call concurrently with enqueue (claim-by-rename).
|