@indigoai-us/hq-cli 5.345.225 → 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.
- package/CHANGELOG.md +174 -0
- package/dist/command-catalog.generated.d.ts +215 -0
- package/dist/command-catalog.generated.js +261 -0
- package/dist/commands/auth.d.ts +2 -2
- package/dist/commands/auth.js +3 -3
- package/dist/commands/core-delegate-w1b.js +92 -69
- package/dist/commands/core-delegate.d.ts +19 -1
- package/dist/commands/core-delegate.js +411 -6
- package/dist/commands/core-dm-bind-native.js +2 -1
- package/dist/commands/core-handoff.d.ts +5 -0
- package/dist/commands/core-handoff.js +1008 -14
- package/dist/commands/core-pin-native.d.ts +1 -0
- package/dist/commands/core-pin-native.js +3 -15
- package/dist/commands/core-register-project-native.d.ts +6 -0
- package/dist/commands/core-register-project-native.js +182 -52
- package/dist/commands/core-work-mesh-bind-trusted-native.js +4 -9
- package/dist/commands/daemon.js +3 -3
- package/dist/commands/deploy-domains.js +38 -2
- package/dist/commands/index-cmd.d.ts +3 -1
- package/dist/commands/index-cmd.js +12 -0
- package/dist/commands/lanes-accounts.d.ts +14 -0
- package/dist/commands/lanes-accounts.js +119 -0
- package/dist/commands/lanes-checks.js +1 -1
- package/dist/commands/lanes-move.js +10 -0
- package/dist/commands/lanes-session-start.d.ts +1 -2
- package/dist/commands/lanes-session-start.js +9 -145
- package/dist/commands/lanes-shared.d.ts +3 -0
- package/dist/commands/lanes-shared.js +9 -0
- package/dist/commands/lanes.d.ts +3 -0
- package/dist/commands/lanes.js +231 -39
- package/dist/commands/link.d.ts +8 -3
- package/dist/commands/link.js +14 -17
- package/dist/commands/mcp-registration.d.ts +65 -7
- package/dist/commands/mcp-registration.js +289 -51
- package/dist/commands/mesh.d.ts +12 -0
- package/dist/commands/mesh.js +92 -10
- package/dist/commands/reindex.js +6 -0
- package/dist/commands/repo.d.ts +13 -0
- package/dist/commands/repo.js +39 -1
- package/dist/commands/sync-held.d.ts +22 -0
- package/dist/commands/sync-held.js +167 -18
- package/dist/commands/sync-mode.d.ts +3 -1
- package/dist/commands/sync-mode.js +11 -1
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +4845 -2524
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lazy-commands.js +3 -4
- package/dist/lib/capacity/accounts.d.ts +4 -0
- package/dist/lib/capacity/accounts.js +4 -0
- package/dist/lib/capacity/route.js +14 -0
- package/dist/lib/capacity/sign-in.d.ts +18 -0
- package/dist/lib/capacity/sign-in.js +34 -1
- package/dist/lib/checkpoint-ontology/entity-file.js +4 -4
- package/dist/lib/checkpoint-ontology/merge-copies.js +7 -11
- package/dist/lib/checkpoint-ontology/plan.js +2 -1
- package/dist/lib/core-utils/archive-old-threads.js +5 -2
- package/dist/lib/core-utils/session-company.d.ts +13 -1
- package/dist/lib/core-utils/session-company.js +75 -4
- package/dist/lib/core-utils/worktree-resume.d.ts +6 -0
- package/dist/lib/core-utils/worktree-resume.js +8 -4
- package/dist/lib/daemon/background-qos.d.ts +7 -0
- package/dist/lib/daemon/background-qos.js +13 -0
- package/dist/lib/daemon/catalog.d.ts +10 -0
- package/dist/lib/daemon/catalog.js +9 -2
- package/dist/lib/daemon/hook-requests-acl-suggest.d.ts +18 -0
- package/dist/lib/daemon/hook-requests-acl-suggest.js +245 -0
- package/dist/lib/daemon/hook-requests-fleet-session-start.d.ts +32 -0
- package/dist/lib/daemon/hook-requests-fleet-session-start.js +214 -0
- package/dist/lib/daemon/hook-requests-mesh-tool-writes.d.ts +44 -0
- package/dist/lib/daemon/hook-requests-mesh-tool-writes.js +292 -0
- package/dist/lib/daemon/hook-requests-mesh.d.ts +54 -0
- package/dist/lib/daemon/hook-requests-mesh.js +559 -0
- package/dist/lib/daemon/hook-requests.d.ts +417 -0
- package/dist/lib/daemon/hook-requests.js +1747 -0
- package/dist/lib/daemon/lanes-reconcile-status.d.ts +35 -0
- package/dist/lib/daemon/lanes-reconcile-status.js +86 -0
- package/dist/lib/daemon/machine-checks.d.ts +12 -2
- package/dist/lib/daemon/machine-checks.js +27 -10
- package/dist/lib/daemon/merge-sections.d.ts +24 -2
- package/dist/lib/daemon/merge-sections.js +58 -16
- package/dist/lib/daemon/ops/policy.d.ts +1 -1
- package/dist/lib/daemon/ops/policy.js +47 -6
- package/dist/lib/daemon/resolver.js +9 -2
- package/dist/lib/daemon/run.d.ts +11 -7
- package/dist/lib/daemon/run.js +195 -18
- package/dist/lib/daemon/search-index-worker-v1.d.ts +2 -0
- package/dist/lib/daemon/search-index-worker-v1.js +25 -0
- package/dist/lib/daemon/server.js +6 -1
- package/dist/lib/daemon/session-registry.d.ts +0 -1
- package/dist/lib/daemon/session-registry.js +0 -3
- package/dist/lib/daemon/supervisor.d.ts +5 -1
- package/dist/lib/daemon/supervisor.js +1 -1
- package/dist/lib/daemon/tcc-eperm.d.ts +59 -4
- package/dist/lib/daemon/tcc-eperm.js +110 -8
- package/dist/lib/doctor/fix/process-identity.d.ts +20 -2
- package/dist/lib/doctor/fix/process-identity.js +48 -5
- 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/canary-gate.js +1 -0
- package/dist/lib/hook-engine/native-stop-compatibility.json +2 -1
- package/dist/lib/hot-channels/adapters/attio.js +2 -1
- package/dist/lib/hot-channels/adapters/meetings.js +2 -1
- package/dist/lib/lanes/account-company.d.ts +7 -1
- package/dist/lib/lanes/account-company.js +22 -4
- package/dist/lib/lanes/account-ownership.d.ts +65 -0
- package/dist/lib/lanes/account-ownership.js +134 -0
- package/dist/lib/lanes/accounts.js +9 -2
- package/dist/lib/lanes/claude-balance.js +9 -3
- package/dist/lib/lanes/company-outposts.d.ts +37 -0
- package/dist/lib/lanes/company-outposts.js +164 -0
- package/dist/lib/lanes/config.js +17 -0
- package/dist/lib/lanes/host-capacity.d.ts +19 -0
- package/dist/lib/lanes/host-capacity.js +37 -0
- package/dist/lib/lanes/liveness.d.ts +6 -0
- package/dist/lib/lanes/liveness.js +49 -8
- package/dist/lib/lanes/orphan-report.d.ts +15 -0
- package/dist/lib/lanes/orphan-report.js +223 -0
- package/dist/lib/lanes/orphan-sweep.d.ts +26 -0
- package/dist/lib/lanes/orphan-sweep.js +152 -0
- package/dist/lib/lanes/reaper.d.ts +2 -0
- package/dist/lib/lanes/reaper.js +11 -8
- package/dist/lib/lanes/reconcile.d.ts +8 -7
- package/dist/lib/lanes/reconcile.js +83 -3
- package/dist/lib/lanes/spawn.d.ts +0 -10
- package/dist/lib/lanes/spawn.js +51 -1
- package/dist/lib/lanes/types.d.ts +12 -0
- package/dist/lib/mesh/live/backfill-held.d.ts +13 -0
- package/dist/lib/mesh/live/backfill-held.js +23 -0
- package/dist/lib/mesh/live/daemon/mode.d.ts +8 -4
- package/dist/lib/mesh/live/daemon/mode.js +8 -4
- package/dist/lib/mesh/live/daemon/run.d.ts +14 -3
- package/dist/lib/mesh/live/daemon/run.js +116 -7
- package/dist/lib/mesh/live/direct-drain.d.ts +123 -0
- package/dist/lib/mesh/live/direct-drain.js +315 -0
- package/dist/lib/mesh/live/emit-replay.d.ts +10 -0
- package/dist/lib/mesh/live/emit-replay.js +10 -0
- package/dist/lib/mesh/live/flush.d.ts +15 -0
- package/dist/lib/mesh/live/flush.js +27 -0
- package/dist/lib/mesh/live/liveness-carry.d.ts +45 -0
- package/dist/lib/mesh/live/liveness-carry.js +141 -0
- package/dist/lib/mesh/live/spool.d.ts +19 -0
- package/dist/lib/mesh/live/spool.js +80 -0
- package/dist/lib/safe-store.d.ts +2 -0
- package/dist/lib/safe-store.js +8 -6
- package/dist/lib/search-index/index.d.ts +9 -3
- package/dist/lib/search-index/index.js +35 -10
- package/dist/lib/search-index/worker-process.d.ts +9 -0
- package/dist/lib/search-index/worker-process.js +171 -0
- package/dist/lib/session-company-lock.d.ts +3 -1
- package/dist/lib/session-company-lock.js +3 -2
- package/dist/utils/delegate-command-supervisor.d.ts +3 -0
- package/dist/utils/delegate-command-supervisor.js +44 -0
- package/dist/utils/delegate-lock.d.ts +12 -0
- package/dist/utils/delegate-lock.js +88 -0
- package/dist/utils/frontmatter.d.ts +27 -0
- package/dist/utils/frontmatter.js +33 -0
- package/dist/utils/hook-trust.d.ts +1 -0
- package/dist/utils/hook-trust.js +18 -2
- package/dist/utils/host-registration.d.ts +13 -1
- package/dist/utils/host-registration.js +98 -5
- package/dist/utils/package-use-lease.d.ts +1 -1
- package/dist/utils/package-use-lease.js +15 -7
- package/docs/anywhere-runtime.md +17 -0
- package/package.json +9 -8
- package/scripts/check-function-manifest.mjs +17 -3
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
/** Consumer for the request notes hq-hook leaves on PostToolUse
|
|
2
|
+
* (crates/hq-hook/src/daemon_req.rs; hq-core-rust owner decision 26).
|
|
3
|
+
*
|
|
4
|
+
* Kinds: `reindex`, `autocommit` (decision 48 for its failure file),
|
|
5
|
+
* `plan-sync`, `pr-footer` (decision 47), `session-close`, `mesh-session-bind`
|
|
6
|
+
* (decision 36), `fleet-local-settings` (US-050 c2, conductor ruling on #3042), and the mesh kinds
|
|
7
|
+
* `mesh-reconcile` and `mesh-register-retry` (hook-requests-mesh.ts).
|
|
8
|
+
* Also `fleet-session-start`, US-050 c2 (hook-requests-fleet-session-start.ts).
|
|
9
|
+
*
|
|
10
|
+
* A hook that used to re-index, commit, copy a plan or edit a pull request
|
|
11
|
+
* now only decides that the work is due and leaves one small file in
|
|
12
|
+
* `~/.hq/daemon/hook-requests/<root key>/<kind>-<key>.json`. This module is
|
|
13
|
+
* the other half: the running daemon takes the notes of its own HQ root,
|
|
14
|
+
* oldest first, and does the work. No process is added: the drainer runs in
|
|
15
|
+
* the daemon, beside the Stop job drainer, under the same lease.
|
|
16
|
+
*
|
|
17
|
+
* A note is data, never a command. Only the kinds listed here are accepted,
|
|
18
|
+
* each with its own typed fields, and the arguments of the program that is
|
|
19
|
+
* started are built here from the validated fields.
|
|
20
|
+
*
|
|
21
|
+
* Life of a note `X.json`:
|
|
22
|
+
* - Invalid (version, kind, fields, size, another HQ root): deleted, one log line, nothing runs.
|
|
23
|
+
* - Older than a day: deleted, one log line, never run (for an autosave the
|
|
24
|
+
* session's failure file is left, as for a note that is given up). The age is counted
|
|
25
|
+
* from the note's own time, and the hook writes a waiting note again on
|
|
26
|
+
* every new request for the same thing, so it is the age of the newest
|
|
27
|
+
* request, not of the first.
|
|
28
|
+
* - A folder, link or FIFO where a note or a claimed note should be is never
|
|
29
|
+
* run. It is deleted; one that cannot be deleted (a folder) is reported
|
|
30
|
+
* once per daemon run and left.
|
|
31
|
+
* - Claimed by renaming it to `X.run` before the work starts, so a request
|
|
32
|
+
* made during the work is a new `X.json` and runs afterwards.
|
|
33
|
+
* - A kind with text (plan-sync, fleet-local-settings) has it in `X.body`, written before the note.
|
|
34
|
+
* A claimed note whose body is missing or too long is deleted with one log
|
|
35
|
+
* line and nothing runs: the same request, made again while its first copy
|
|
36
|
+
* ran, loses its body when that copy finishes, and its text was just filed.
|
|
37
|
+
* When the first copy fails instead, its text was not filed: the body stays
|
|
38
|
+
* for the newer note. A body with no note and no claimed note, a day old,
|
|
39
|
+
* was left by a hook that died between its two writes and is deleted.
|
|
40
|
+
* - Done: `X.run` and its side files are deleted.
|
|
41
|
+
* - Not started because the work's own lock is held (`later`): put back as
|
|
42
|
+
* it was, no try counted, looked at again after 5 s. Only the day limit
|
|
43
|
+
* ends such a note.
|
|
44
|
+
* - Failed, or found as `X.run` at the start of a pass (the daemon stopped
|
|
45
|
+
* mid-work): the count in `X.attempts` goes up and the note is put back,
|
|
46
|
+
* unless a newer `X.json` is already there. It runs again after 5 s, then
|
|
47
|
+
* after 30 s. After the third failure it is deleted with one log line.
|
|
48
|
+
*/
|
|
49
|
+
import { type ChildProcess, type SpawnOptions } from "node:child_process";
|
|
50
|
+
import { type ShareCandidate } from "./hook-requests-acl-suggest.js";
|
|
51
|
+
import { type MeshOperation } from "./hook-requests-mesh.js";
|
|
52
|
+
import { type MachineCheckResult, type RunMachineChecksOptions } from "./machine-checks.js";
|
|
53
|
+
import { type MeshToolWritesOperation } from "./hook-requests-mesh-tool-writes.js";
|
|
54
|
+
import { type FleetSessionStartOperation } from "./hook-requests-fleet-session-start.js";
|
|
55
|
+
/** What the daemon is asked to do. A closed list, the same as `Kind` in daemon_req.rs. */
|
|
56
|
+
export type HookOperation = {
|
|
57
|
+
kind: "reindex";
|
|
58
|
+
} | {
|
|
59
|
+
kind: "acl-suggest";
|
|
60
|
+
candidates: ShareCandidate[];
|
|
61
|
+
} | {
|
|
62
|
+
kind: "autocommit";
|
|
63
|
+
path: string;
|
|
64
|
+
}
|
|
65
|
+
/** intent-hint's `/startwork <argument>` company prefetch (`startwork_prefetch` note, prompt_up6/intent_hint.rs): the prompt is the note's `.body` file. */
|
|
66
|
+
| {
|
|
67
|
+
kind: "startwork-prefetch";
|
|
68
|
+
sessionId: string;
|
|
69
|
+
}
|
|
70
|
+
/** File a plan under a project: `project` is a path under the HQ root, the plan text is the note's `.body` file. */
|
|
71
|
+
| {
|
|
72
|
+
kind: "plan-sync";
|
|
73
|
+
project: string;
|
|
74
|
+
} | {
|
|
75
|
+
kind: "pr-footer";
|
|
76
|
+
url: string;
|
|
77
|
+
}
|
|
78
|
+
/** hqd's `session.close`, done in the daemon's own session registry (master-hook's SessionEnd shim call). */
|
|
79
|
+
| {
|
|
80
|
+
kind: "session-close";
|
|
81
|
+
runtime: "claude";
|
|
82
|
+
sessionId: string;
|
|
83
|
+
}
|
|
84
|
+
/** The fleet-local adapter's `.claude/settings.json` PostToolUse commands for one tool call, as the hook read them; the
|
|
85
|
+
* adapter's payload is the note's `.body` file (`host::fleet_settings`). */
|
|
86
|
+
| {
|
|
87
|
+
kind: "fleet-local-settings";
|
|
88
|
+
event: "PostToolUse";
|
|
89
|
+
commands: FleetLocalSettingsCommand[];
|
|
90
|
+
}
|
|
91
|
+
/** The Work Mesh register step of a mid-session company bind (`spawn_work_mesh_register`, owner decision 36). */
|
|
92
|
+
| {
|
|
93
|
+
kind: "mesh-session-bind";
|
|
94
|
+
sessionId: string;
|
|
95
|
+
cwd: string;
|
|
96
|
+
company: string;
|
|
97
|
+
disabled?: MeshSessionBindSwitch;
|
|
98
|
+
}
|
|
99
|
+
/** The company-less Work Mesh register of `hq-session.sh add company` (`spawn_work_mesh_register "$sid"`, no company). */
|
|
100
|
+
| {
|
|
101
|
+
kind: "mesh-session-register";
|
|
102
|
+
sessionId: string;
|
|
103
|
+
cwd: string;
|
|
104
|
+
disabled?: MeshSessionBindSwitch;
|
|
105
|
+
}
|
|
106
|
+
/** One machine check run by the daemon for a SessionStart where the hooks own the checks (the machine-check notes at the end of this file). */
|
|
107
|
+
| MachineCheckOperation | MeshOperation | MeshToolWritesOperation | FleetSessionStartOperation;
|
|
108
|
+
/**
|
|
109
|
+
* One command of a `fleet-local-settings` note, a record of the adapter's `hqad_iter_settings`. Typed fields only: the
|
|
110
|
+
* daemon builds the program and its arguments (`fleetLocalSettingsProgram`).
|
|
111
|
+
* - `gate`: the root's `.claude/hooks/hook-gate.sh <id> <script> [args]`.
|
|
112
|
+
* - `master`: `bash <root>/.claude/hooks/master-hook.sh <event>`, for a settings entry naming another event's master-hook.
|
|
113
|
+
* - `script`: `<script>`, with no arguments.
|
|
114
|
+
*/
|
|
115
|
+
export type FleetLocalSettingsCommand = {
|
|
116
|
+
type: "gate";
|
|
117
|
+
id: string;
|
|
118
|
+
script: string;
|
|
119
|
+
args: string[];
|
|
120
|
+
} | {
|
|
121
|
+
type: "master";
|
|
122
|
+
event: string;
|
|
123
|
+
} | {
|
|
124
|
+
type: "script";
|
|
125
|
+
script: string;
|
|
126
|
+
};
|
|
127
|
+
export interface HookRequest {
|
|
128
|
+
/** The note's file name without `.json`. */
|
|
129
|
+
stem: string;
|
|
130
|
+
id: string;
|
|
131
|
+
/** When the hook left the note (ms since the epoch). */
|
|
132
|
+
at: number;
|
|
133
|
+
/** The HQ root the note names. */
|
|
134
|
+
root: string;
|
|
135
|
+
session: string;
|
|
136
|
+
operation: HookOperation;
|
|
137
|
+
/** The note's `.body` file, read by the drainer after it claims a note whose kind carries one. */
|
|
138
|
+
body?: Buffer;
|
|
139
|
+
}
|
|
140
|
+
/** The longest note the Rust writer leaves (`NOTE_MAX_BYTES`). */
|
|
141
|
+
export declare const HOOK_REQUEST_MAX_BYTES = 4096;
|
|
142
|
+
/** The longest `.body` file the Rust writer leaves (`BODY_MAX_BYTES`). */
|
|
143
|
+
export declare const HOOK_REQUEST_BODY_MAX_BYTES: number;
|
|
144
|
+
/** A note older than this is deleted and never run. */
|
|
145
|
+
export declare const HOOK_REQUEST_MAX_AGE_MS: number;
|
|
146
|
+
/** Tries per note, and the waits before the second and third. */
|
|
147
|
+
export declare const HOOK_REQUEST_MAX_ATTEMPTS = 3;
|
|
148
|
+
export declare const HOOK_REQUEST_RETRY_DELAYS_MS: readonly number[];
|
|
149
|
+
/** The longest a request's program runs before it is told to end (SIGTERM to its process group). */
|
|
150
|
+
export declare const HOOK_REQUEST_KILL_MS = 60000;
|
|
151
|
+
/** How long after that the whole process group is killed. */
|
|
152
|
+
export declare const HOOK_REQUEST_KILL_GRACE_MS = 5000;
|
|
153
|
+
/** The wait before a note whose work could not start is looked at again. */
|
|
154
|
+
export declare const HOOK_REQUEST_LATER_MS = 5000;
|
|
155
|
+
/** The lock folder of `hq-autocommit.sh`, under the script's `${TMPDIR:-/tmp}`. */
|
|
156
|
+
export declare const AUTOCOMMIT_LOCK = "hq-autocommit.lock";
|
|
157
|
+
/** Failure files and shown marks older than this are removed when a new one is written. */
|
|
158
|
+
export declare const AUTOCOMMIT_WARNING_MAX_AGE_MS: number;
|
|
159
|
+
/** The longest path an `autocommit` note carries (`PATH_MAX_BYTES` in post_m5/autocommit.rs). */
|
|
160
|
+
export declare const HOOK_REQUEST_PATH_MAX_BYTES = 3500;
|
|
161
|
+
/** The autosave script of an HQ root, which the daemon runs for an `autocommit` note. */
|
|
162
|
+
export declare const AUTOCOMMIT_SCRIPT = ".claude/hooks/hq-autocommit.sh";
|
|
163
|
+
/** The script of an HQ root that prints the fingerprint for a `pr-footer` note (its fingerprint-only mode). */
|
|
164
|
+
export declare const PR_FOOTER_SCRIPT = "core/scripts/hq-pr-create.sh";
|
|
165
|
+
/** The only shape of `args.url` in a `pr-footer` note (`pull_url` in post_m5/pr_footer.rs). */
|
|
166
|
+
export declare const PR_FOOTER_URL: RegExp;
|
|
167
|
+
/** The longest URL a `pr-footer` note carries. */
|
|
168
|
+
export declare const PR_FOOTER_URL_MAX_BYTES = 512;
|
|
169
|
+
/** The footer is added no sooner than this after the hook left the note (owner decision 47: "a few seconds after the PR opens"). */
|
|
170
|
+
export declare const PR_FOOTER_DELAY_MS = 3000;
|
|
171
|
+
/** The longest each program of a `pr-footer` request runs (the script, `gh pr view`, `gh pr edit`). */
|
|
172
|
+
export declare const PR_FOOTER_PROGRAM_MS = 20000;
|
|
173
|
+
/** How often the body is read again when it changed between the read and the write, before the try fails. */
|
|
174
|
+
export declare const PR_FOOTER_ROUNDS = 3;
|
|
175
|
+
/** The most commands one `fleet-local-settings` note carries (the note itself is at most 4096 bytes). */
|
|
176
|
+
export declare const FLEET_LOCAL_SETTINGS_MAX_COMMANDS = 64;
|
|
177
|
+
/** The hook-gate and master-hook of an HQ root, which `gate` and `master` commands start. */
|
|
178
|
+
export declare const FLEET_LOCAL_HOOK_GATE = ".claude/hooks/hook-gate.sh";
|
|
179
|
+
export declare const FLEET_LOCAL_MASTER_HOOK = ".claude/hooks/master-hook.sh";
|
|
180
|
+
/** The hook a `mesh-session-bind` note runs, inside the HQ root (`spawn_work_mesh_register` in hq-session.sh). */
|
|
181
|
+
export declare const MESH_SESSION_BIND_HOOK = "core/hooks/SessionStart/35-work-mesh-session-start.sh";
|
|
182
|
+
/** Where that hook's output goes, inside the HQ root, as when hq-session.sh started it. */
|
|
183
|
+
export declare const MESH_SESSION_BIND_LOG = "workspace/logs/work-mesh-hook.log";
|
|
184
|
+
/** The longest `cwd` a `mesh-session-bind` note carries (`MESH_SESSION_BIND_CWD_MAX_BYTES` in daemon_req.rs). */
|
|
185
|
+
export declare const MESH_SESSION_BIND_CWD_MAX_BYTES = 3500;
|
|
186
|
+
/** The session switches that turn the Work Mesh hook off (`MeshBindSwitch` in daemon_req.rs); a note naming one starts nothing. */
|
|
187
|
+
export type MeshSessionBindSwitch = "HQ_WORK_MESH_DISABLED" | "HQ_DISABLED_HOOKS";
|
|
188
|
+
/** The script a `startwork-prefetch` note runs, inside the HQ root (`PREFETCH_SCRIPT` in prompt_up6/intent_hint.rs). */
|
|
189
|
+
export declare const STARTWORK_PREFETCH_SCRIPT = "core/scripts/startwork-prefetch.sh";
|
|
190
|
+
/** The hook leaves a prefetch note only for a prompt shorter than this (`PREFETCH_PROMPT_LIMIT` in prompt_up6/intent_hint.rs). */
|
|
191
|
+
export declare const STARTWORK_PREFETCH_PROMPT_LIMIT = 65536;
|
|
192
|
+
/** Notes handled per pass; the drainer schedules another pass at once when reached. */
|
|
193
|
+
export declare const HOOK_REQUEST_PASS_LIMIT = 64;
|
|
194
|
+
/** The folder name for an HQ root: 32 hex characters of SHA-256 over its real path (`root_key` in daemon_req.rs). */
|
|
195
|
+
export declare function hookRequestRootKey(root: string): string;
|
|
196
|
+
/** The request folder of `root` under `home`. */
|
|
197
|
+
export declare function hookRequestDir(home: string, root: string): string;
|
|
198
|
+
/** Where the daemon leaves a session's "autosave failed" file for the native hq-autocommit hook
|
|
199
|
+
* (`WARNING_PARTS` in post_m5/autocommit.rs; owner decision 48). */
|
|
200
|
+
export declare function autocommitWarningDir(home: string, root: string): string;
|
|
201
|
+
/** The name part for a session (`session_key` in post_m5/autocommit.rs). */
|
|
202
|
+
export declare function autocommitWarningKey(session: string): string;
|
|
203
|
+
/**
|
|
204
|
+
* Record that an autosave failed for `session`, so the native hook shows its
|
|
205
|
+
* warning on that session's next Write or Edit. One file per session; nothing
|
|
206
|
+
* is written once the hook has shown it (`.shown`). True when a file was made.
|
|
207
|
+
*/
|
|
208
|
+
export declare function leaveAutocommitFailure(home: string, root: string, session: string, now?: number): boolean;
|
|
209
|
+
/** Read one note. `stem` is its file name without `.json`. Undefined for anything the writer does not produce. */
|
|
210
|
+
export declare function parseHookRequest(text: string, stem: string): HookRequest | undefined;
|
|
211
|
+
/** Whether a note of this kind has its text in a `.body` file beside it. */
|
|
212
|
+
export declare function hookRequestHasBody(operation: HookOperation): boolean;
|
|
213
|
+
/** The helper a plan-sync request runs, inside the HQ root. */
|
|
214
|
+
export declare const PLAN_SYNC_HELPER = "core/scripts/session-project.sh";
|
|
215
|
+
/**
|
|
216
|
+
* The CLI arguments for a validated request (plan-sync: the helper's arguments). Nothing from the note is passed through as an argument except its checked root.
|
|
217
|
+
* Undefined for a request the daemon does in process (`session-close`), which never starts a program.
|
|
218
|
+
*/
|
|
219
|
+
export declare function hookRequestArguments(request: HookRequest): string[] | undefined;
|
|
220
|
+
export interface HookRequestResult {
|
|
221
|
+
code: number;
|
|
222
|
+
later?: boolean;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Do a `session-close` request in the running hqd's session registry, as its `session.close` op does (allowed while HQ
|
|
226
|
+
* Anywhere is off). With no hqd running there is no session to close, which is done too: a retry would find the same.
|
|
227
|
+
* The note's root must be this daemon's root, as for every request.
|
|
228
|
+
*/
|
|
229
|
+
export declare function executeSessionClose(request: HookRequest, options: {
|
|
230
|
+
sessions: {
|
|
231
|
+
close(runtime: string, sessionId: string): boolean;
|
|
232
|
+
} | undefined;
|
|
233
|
+
allowedRoot: string | undefined;
|
|
234
|
+
}): Promise<{
|
|
235
|
+
code: number;
|
|
236
|
+
}>;
|
|
237
|
+
export interface HookRequestDrainOptions {
|
|
238
|
+
home: string;
|
|
239
|
+
/** The HQ root this daemon serves, read on every pass. */
|
|
240
|
+
root: () => string | undefined;
|
|
241
|
+
/** Must prove ownership of the canonical per-user daemon lease. */
|
|
242
|
+
ownsQueue: () => boolean;
|
|
243
|
+
/** Runs a validated request. No shell evaluation. `later` says the work could not start and is not a try. */
|
|
244
|
+
execute: (request: HookRequest) => Promise<HookRequestResult>;
|
|
245
|
+
log: (message: string) => void;
|
|
246
|
+
/** Clock (tests). */
|
|
247
|
+
now?: () => number;
|
|
248
|
+
/** Waits before the second and third try (tests). */
|
|
249
|
+
retryDelaysMs?: readonly number[];
|
|
250
|
+
/** The wait before a note whose work could not start is looked at again (tests). */
|
|
251
|
+
laterDelayMs?: number;
|
|
252
|
+
/** The wait between fallback scans (tests). */
|
|
253
|
+
scanIntervalMs?: number;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* One pass over the request folder of this daemon's HQ root. Returns the
|
|
257
|
+
* number of notes settled or tried. Notes of another HQ root are in another
|
|
258
|
+
* folder and are not touched.
|
|
259
|
+
*/
|
|
260
|
+
export declare function drainHookRequests(options: HookRequestDrainOptions): Promise<number>;
|
|
261
|
+
/** Startup scan plus folder notifications, with a 5 s fallback scan when a
|
|
262
|
+
* watcher is unavailable or an event was missed. Close waits for the request
|
|
263
|
+
* in progress. */
|
|
264
|
+
export declare function startHookRequestDrainer(options: HookRequestDrainOptions): {
|
|
265
|
+
close(): Promise<void>;
|
|
266
|
+
};
|
|
267
|
+
/** What `hq-autocommit.sh` reads on stdin for a validated `autocommit` request: the payload fields the script uses, built here. */
|
|
268
|
+
export declare function autocommitInput(request: HookRequest): string;
|
|
269
|
+
/** What `spawnRequestProgram` returns. */
|
|
270
|
+
export interface RequestProgram {
|
|
271
|
+
child: ChildProcess;
|
|
272
|
+
/** Signal the program and everything it started (its process group; the program alone on Windows). */
|
|
273
|
+
signalAll(signal: NodeJS.Signals): void;
|
|
274
|
+
/**
|
|
275
|
+
* Call once, when the program has closed or failed to start: clears the
|
|
276
|
+
* timers and the abort listener. When the program was stopped (limit or
|
|
277
|
+
* abort), SIGKILL goes to its group once more, so nothing it started
|
|
278
|
+
* outlives it, and the answer is true.
|
|
279
|
+
*/
|
|
280
|
+
settle(): boolean;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* The one stop model of every request kind. `program` is started without a
|
|
284
|
+
* shell in its own process group (not on Windows, where the program alone is
|
|
285
|
+
* signalled). At `timeoutMs`, or when `signal` aborts, the group is sent
|
|
286
|
+
* SIGTERM, so a script can run its exit trap and the programs it started end
|
|
287
|
+
* with it, and SIGKILL after `killGraceMs` (default 5 s).
|
|
288
|
+
*/
|
|
289
|
+
export declare function spawnRequestProgram(program: string, args: string[], spawnOptions: Omit<SpawnOptions, "shell" | "detached">, stop: {
|
|
290
|
+
timeoutMs: number;
|
|
291
|
+
killGraceMs?: number;
|
|
292
|
+
signal?: AbortSignal;
|
|
293
|
+
}): RequestProgram;
|
|
294
|
+
/**
|
|
295
|
+
* The body `pr-fingerprint-footer.sh` wrote for a pull request whose body is
|
|
296
|
+
* `body` (trailing newlines already removed), or undefined when a line of
|
|
297
|
+
* it already starts with `HQ-Fingerprint:`.
|
|
298
|
+
*/
|
|
299
|
+
export declare function prFooterBody(body: string, fingerprint: string): string | undefined;
|
|
300
|
+
/**
|
|
301
|
+
* The words `eval "toks=( $rest )"` gives with `CLAUDE_PROJECT_DIR` set to `root`, for the shapes hq-hook models
|
|
302
|
+
* (`shell_words` in `host::fleet_settings`): blanks, single and double quotes, backslash escapes, and
|
|
303
|
+
* `$CLAUDE_PROJECT_DIR` or `${CLAUDE_PROJECT_DIR}`. Undefined for anything else the shell would expand or treat as syntax.
|
|
304
|
+
*/
|
|
305
|
+
export declare function fleetLocalSettingsWords(text: string, root: string): string[] | undefined;
|
|
306
|
+
/**
|
|
307
|
+
* `hqad_classify_command` for one settings command, as hq-hook's `fleet_settings::classify` reads it: the record the
|
|
308
|
+
* hook would put in a note, or undefined for a command that gives none or that hq-hook does not model.
|
|
309
|
+
*/
|
|
310
|
+
export declare function fleetLocalSettingsRecord(command: string, root: string): FleetLocalSettingsCommand | undefined;
|
|
311
|
+
/**
|
|
312
|
+
* The records the root's `.claude/settings.json` lists for `event` right now (any matcher), for the drain-time check
|
|
313
|
+
* that a note's command is still listed there. Exec-form entries give none (the hook puts none in a note). An absent
|
|
314
|
+
* or unreadable file lists nothing.
|
|
315
|
+
*/
|
|
316
|
+
export declare function fleetLocalSettingsListed(root: string, event: string): FleetLocalSettingsCommand[];
|
|
317
|
+
/** Whether `file`'s real path (every symlink in its whole parent chain resolved) is inside the real HQ root. */
|
|
318
|
+
export declare function fleetLocalSettingsUnderRoot(root: string, file: string): boolean;
|
|
319
|
+
/**
|
|
320
|
+
* Why the daemon refuses one note command at drain, or undefined to run it. A note is only what a hook said a moment
|
|
321
|
+
* ago, so the daemon re-checks it against the root: the command must still be listed in the root's
|
|
322
|
+
* `.claude/settings.json` for the note's event, and every file it would start (the gate and its script, master-hook,
|
|
323
|
+
* the script) must resolve, with its whole parent chain, to a real path under the HQ root.
|
|
324
|
+
*/
|
|
325
|
+
export declare function fleetLocalSettingsRefusal(root: string, command: FleetLocalSettingsCommand, listed: FleetLocalSettingsCommand[]): string | undefined;
|
|
326
|
+
/**
|
|
327
|
+
* The program and arguments for one `fleet-local-settings` command, as the adapter (and `child::Runner` in hq-hook)
|
|
328
|
+
* starts it: an executable file is started itself, any other with `bash`; master-hook always with `bash`. No shell
|
|
329
|
+
* reads the words. Undefined for a master command whose master-hook is not a file (the hook skipped it too).
|
|
330
|
+
*/
|
|
331
|
+
export declare function fleetLocalSettingsProgram(root: string, command: FleetLocalSettingsCommand): {
|
|
332
|
+
program: string;
|
|
333
|
+
args: string[];
|
|
334
|
+
bashEnv: boolean;
|
|
335
|
+
} | undefined;
|
|
336
|
+
/**
|
|
337
|
+
* Run a validated request: the daemon's own CLI entry point, for `autocommit` the HQ root's own autosave
|
|
338
|
+
* script, for `plan-sync` the HQ root's own helper with the plan on stdin, as the shell hook did, for
|
|
339
|
+
* `pr-footer` the root's fingerprint script and `gh` (`addPrFooter`), for `mesh-session-bind` the root's
|
|
340
|
+
* SessionStart Work Mesh hook (`runMeshSessionBind`).
|
|
341
|
+
*
|
|
342
|
+
* Every program runs in its own process group (`spawnRequestProgram`, through
|
|
343
|
+
* `runRequestProgram`). At the limit the group is sent SIGTERM, so a script
|
|
344
|
+
* can run its exit trap and the programs it started end with it, and SIGKILL
|
|
345
|
+
* after the grace time. Both count as a failed try.
|
|
346
|
+
*
|
|
347
|
+
* `autocommit` only. The script exits 0 without a word when another autosave
|
|
348
|
+
* holds its lock, which is not a commit: a lock that is held is answered with
|
|
349
|
+
* `later` (the note is kept and no try is counted), without starting the
|
|
350
|
+
* script while the lock is younger than the script's own takeover age. The
|
|
351
|
+
* script's warning line on stderr ("WARNING: HQ autosave ...", once per
|
|
352
|
+
* session and cause) becomes the session's failure file.
|
|
353
|
+
*
|
|
354
|
+
* `plan-sync` only. A helper that is not an executable file is done (code 0),
|
|
355
|
+
* as the shell hook skipped it. The helper's own exit status is ignored when
|
|
356
|
+
* it ended by itself (the shell hook's `|| true`); a run that had to be
|
|
357
|
+
* stopped at the limit still counts as a failed try.
|
|
358
|
+
*/
|
|
359
|
+
export declare function executeHookRequest(request: HookRequest, options: {
|
|
360
|
+
nodeBinary: string;
|
|
361
|
+
hqBinary: string;
|
|
362
|
+
allowedRoot: string | undefined;
|
|
363
|
+
env?: NodeJS.ProcessEnv;
|
|
364
|
+
signal?: AbortSignal;
|
|
365
|
+
timeoutMs?: number;
|
|
366
|
+
killGraceMs?: number;
|
|
367
|
+
home?: string;
|
|
368
|
+
log?: (message: string) => void;
|
|
369
|
+
/** `pr-footer` (tests): the wait after the note's time, the limit of each program, and the rounds. */
|
|
370
|
+
prFooterDelayMs?: number;
|
|
371
|
+
prFooterProgramMs?: number;
|
|
372
|
+
prFooterRounds?: number;
|
|
373
|
+
}): Promise<HookRequestResult>;
|
|
374
|
+
/** The `check-hq-update` and `check-client-health` request notes
|
|
375
|
+
* (crates/hq-hook/src/daemon_req.rs, `Kind::CheckHqUpdate` and
|
|
376
|
+
* `Kind::CheckClientHealth`; hq-core-rust decision 19 with standing rule (b)).
|
|
377
|
+
*
|
|
378
|
+
* The native SessionStart rows for these two machine checks start no program.
|
|
379
|
+
* When the hooks own the machine checks (master-hook's helper answers legacy)
|
|
380
|
+
* the row leaves one note instead, and the daemon runs that one check here on
|
|
381
|
+
* its next pass over the notes.
|
|
382
|
+
*
|
|
383
|
+
* The check runs through the machine-check runner (machine-checks.ts): the
|
|
384
|
+
* same script rules, environment and time limit as the daemon's batch. Like
|
|
385
|
+
* the batch it runs collect-only when the installed core advertises the mode,
|
|
386
|
+
* so a show-once message nobody has seen is not marked as shown; the work
|
|
387
|
+
* itself (the update, the bounded repair, their cooldowns) is done. Its result
|
|
388
|
+
* is not written to the results file: that file is the batch's, and its age is
|
|
389
|
+
* what the owner decision reads, so a single check must not refresh it. It runs
|
|
390
|
+
* as a single run (`single: true`): it never takes the batch's in-flight slot,
|
|
391
|
+
* so a batch tick during it runs the full batch and writes that file.
|
|
392
|
+
*/
|
|
393
|
+
/** The request kinds these notes carry: each is the id of one machine check. */
|
|
394
|
+
export declare const MACHINE_CHECK_REQUEST_KINDS: readonly ["check-hq-update", "check-client-health"];
|
|
395
|
+
export type MachineCheckRequestKind = (typeof MACHINE_CHECK_REQUEST_KINDS)[number];
|
|
396
|
+
export type MachineCheckOperation = {
|
|
397
|
+
kind: MachineCheckRequestKind;
|
|
398
|
+
};
|
|
399
|
+
export declare function isMachineCheckRequestKind(kind: unknown): kind is MachineCheckRequestKind;
|
|
400
|
+
/** A note of one of these kinds carries no fields. Undefined for anything else. */
|
|
401
|
+
export declare function parseMachineCheckOperation(kind: unknown, args: Record<string, unknown>): MachineCheckOperation | undefined;
|
|
402
|
+
/**
|
|
403
|
+
* Run the note's check once in `root` (already checked to be the daemon's own
|
|
404
|
+
* root). Done (0) when the check ran to an answer, or when nothing is to run
|
|
405
|
+
* (inside a machine check); a failed try (1) when its answer is `unknown`
|
|
406
|
+
* (missing or refused script, timeout, crash, non-zero exit), which the
|
|
407
|
+
* drainer retries as any failed note.
|
|
408
|
+
*/
|
|
409
|
+
export declare function runMachineCheckRequest(root: string, operation: MachineCheckOperation, options?: {
|
|
410
|
+
env?: NodeJS.ProcessEnv;
|
|
411
|
+
/** Test seams. */
|
|
412
|
+
run?: (options: RunMachineChecksOptions) => Promise<MachineCheckResult[]>;
|
|
413
|
+
collectOnlySupported?: (hqRoot: string) => boolean;
|
|
414
|
+
}): Promise<{
|
|
415
|
+
code: number;
|
|
416
|
+
}>;
|
|
417
|
+
//# sourceMappingURL=hook-requests.d.ts.map
|