@indigoai-us/hq-cli 5.345.254 → 5.345.257
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 +68 -0
- package/README.md +29 -0
- package/assets/scaffold/core/scripts/handoff-finalize.sh +981 -46
- package/assets/scaffold/core/scripts/hq-delegate-bundle.sh +51 -2
- package/assets/scaffold/core/scripts/hq-delegate-send.sh +49 -6
- package/assets/scaffold/core/scripts/hq-delegate-transfer.sh +20 -0
- package/assets/scaffold/core/scripts/hq-delegate-verify.sh +56 -10
- package/assets/scaffold/core/scripts/lib/fingerprint.sh +423 -0
- package/assets/scaffold/core/scripts/rebuild-companies-index.sh +10 -1
- package/assets/scaffold/core/scripts/rebuild-company-knowledge-index.sh +10 -1
- package/assets/scaffold/core/scripts/rebuild-projects-index.sh +10 -1
- package/assets/scaffold/core/scripts/register-project.sh +110 -19
- package/contracts/host-canary-release.json +7 -7
- package/dist/command-catalog.generated.d.ts +1 -1
- package/dist/command-catalog.generated.js +1 -1
- package/dist/commands/core-delegate-w1b.js +107 -16
- package/dist/commands/core-delegate.d.ts +7 -0
- package/dist/commands/core-delegate.js +66 -2
- package/dist/commands/core-handoff-fast.d.ts +1 -1
- package/dist/commands/core-handoff-fast.js +2 -2
- package/dist/commands/core-handoff.d.ts +3 -1
- package/dist/commands/core-handoff.js +1407 -177
- package/dist/commands/core-register-project-native.js +1 -1
- package/dist/commands/core.js +2 -2
- package/dist/commands/files.d.ts +2 -0
- package/dist/commands/files.js +34 -5
- package/dist/commands/team-sync.js +1 -1
- package/dist/lib/company-skill-wrapper.js +72 -4
- package/dist/lib/daemon/requests.d.ts +14 -1
- package/dist/lib/daemon/requests.js +17 -3
- package/dist/lib/daemon/run.js +44 -2
- package/dist/lib/daemon/supervisor.d.ts +11 -0
- package/dist/lib/daemon/supervisor.js +33 -0
- package/dist/lib/daemon/sync-perf-telemetry.d.ts +85 -0
- package/dist/lib/daemon/sync-perf-telemetry.js +206 -0
- package/dist/lib/daemon/windows-relaunch.d.ts +55 -0
- package/dist/lib/daemon/windows-relaunch.js +72 -0
- package/dist/lib/hook-engine/coverage.d.ts +10 -1
- package/dist/lib/hook-engine/coverage.js +41 -5
- package/dist/lib/index-render/companies.js +3 -2
- package/dist/lib/index-render/index.js +2 -1
- package/dist/lib/index-render/session-scope.d.ts +2 -3
- package/dist/lib/index-render/session-scope.js +2 -5
- package/dist/lib/index-render/shared.d.ts +7 -0
- package/dist/lib/index-render/shared.js +9 -0
- package/dist/lib/work-context/windows-acl.d.ts +14 -0
- package/dist/lib/work-context/windows-acl.js +26 -0
- package/dist/utils/cli-telemetry.d.ts +26 -7
- package/dist/utils/cli-telemetry.js +70 -13
- package/dist/utils/git.js +1 -1
- package/dist/utils/resident-package-preload.js +4 -0
- package/dist/utils/sync-perf-telemetry-flag.d.ts +26 -0
- package/dist/utils/sync-perf-telemetry-flag.js +32 -0
- package/dist/utils/telemetry-opt-out.d.ts +13 -0
- package/dist/utils/telemetry-opt-out.js +19 -0
- package/package.json +8 -8
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sampled perf events from the sync engine (hq-syncd), forwarded to HQ telemetry.
|
|
3
|
+
*
|
|
4
|
+
* Under `HQ_SYNC_PROTOCOL=1` the engine writes `{"type":"perf","v":1,...}` lines on
|
|
5
|
+
* the protocol stdout the supervisor already reads (hq-sync-core
|
|
6
|
+
* `crates/hq-sync-daemon/src/perf_telemetry.rs`). This module validates a line
|
|
7
|
+
* strictly against that v1 schema and queues valid events for an asynchronous,
|
|
8
|
+
* batched send. Nothing here blocks or throws into the supervisor's line loop.
|
|
9
|
+
*
|
|
10
|
+
* A valid event holds only an operation name from a closed set, a duration, the
|
|
11
|
+
* sample rate, size buckets from a closed set, small counts and booleans. Any
|
|
12
|
+
* other key, any other string, or any out-of-range number rejects the whole line.
|
|
13
|
+
*/
|
|
14
|
+
export const SYNC_PERF_EVENT_VERSION = 1;
|
|
15
|
+
export const SYNC_PERF_OPS = ["plan", "snapshot_ingest", "index_open", "first_sync"];
|
|
16
|
+
export const SYNC_PERF_SIZE_BUCKETS = ["0-1k", "1k-10k", "10k-100k", "100k+"];
|
|
17
|
+
/** A day, in milliseconds. A longer sampled operation is not a plausible measurement. */
|
|
18
|
+
export const SYNC_PERF_MAX_DURATION_MS = 86_400_000;
|
|
19
|
+
/** Upper bound for `pages` and `migrationBatches` (u32 on the engine side; real values are tens). */
|
|
20
|
+
export const SYNC_PERF_MAX_COUNT = 100_000;
|
|
21
|
+
/** The company UID of a sync-core engine unit for a company vault, else undefined. */
|
|
22
|
+
export function syncPerfCompanyUid(unitId) {
|
|
23
|
+
const match = /^sync-core:(cmp_[A-Za-z0-9][A-Za-z0-9_-]*)$/.exec(unitId);
|
|
24
|
+
return match?.[1];
|
|
25
|
+
}
|
|
26
|
+
/** The optional fields each operation may carry (the `PerfFields` constructors in perf_telemetry.rs). */
|
|
27
|
+
const FIELDS_BY_OP = {
|
|
28
|
+
plan: new Set(["files", "actions"]),
|
|
29
|
+
snapshot_ingest: new Set(["files", "pages", "resumed"]),
|
|
30
|
+
index_open: new Set(["files", "migrationBatches", "created"]),
|
|
31
|
+
first_sync: new Set(["actions", "placed"]),
|
|
32
|
+
};
|
|
33
|
+
const REQUIRED_KEYS = new Set(["type", "v", "op", "durationMs", "sampleRate"]);
|
|
34
|
+
const BUCKET_FIELDS = new Set(["files", "actions", "placed"]);
|
|
35
|
+
const COUNT_FIELDS = new Set(["pages", "migrationBatches"]);
|
|
36
|
+
const BOOLEAN_FIELDS = new Set(["resumed", "created"]);
|
|
37
|
+
const OPS = new Set(SYNC_PERF_OPS);
|
|
38
|
+
const BUCKETS = new Set(SYNC_PERF_SIZE_BUCKETS);
|
|
39
|
+
function isIntegerIn(value, min, max) {
|
|
40
|
+
return typeof value === "number" && Number.isInteger(value) && value >= min && value <= max;
|
|
41
|
+
}
|
|
42
|
+
/** Validate one parsed protocol event against the v1 perf schema. Never throws. */
|
|
43
|
+
export function validateSyncPerfEvent(raw) {
|
|
44
|
+
try {
|
|
45
|
+
if (raw.type !== "perf")
|
|
46
|
+
return { ok: false, reason: "not a perf event" };
|
|
47
|
+
if (raw.v !== SYNC_PERF_EVENT_VERSION)
|
|
48
|
+
return { ok: false, reason: "unsupported version" };
|
|
49
|
+
if (typeof raw.op !== "string" || !OPS.has(raw.op))
|
|
50
|
+
return { ok: false, reason: "unknown op" };
|
|
51
|
+
const op = raw.op;
|
|
52
|
+
const allowed = FIELDS_BY_OP[op];
|
|
53
|
+
for (const key of Object.keys(raw)) {
|
|
54
|
+
if (REQUIRED_KEYS.has(key))
|
|
55
|
+
continue;
|
|
56
|
+
if (!allowed.has(key))
|
|
57
|
+
return { ok: false, reason: `unexpected key for op ${op}` };
|
|
58
|
+
}
|
|
59
|
+
const durationMs = raw.durationMs;
|
|
60
|
+
if (!isIntegerIn(durationMs, 0, SYNC_PERF_MAX_DURATION_MS)) {
|
|
61
|
+
return { ok: false, reason: "durationMs out of range" };
|
|
62
|
+
}
|
|
63
|
+
const sampleRate = raw.sampleRate;
|
|
64
|
+
if (typeof sampleRate !== "number" || !Number.isFinite(sampleRate) || sampleRate <= 0 || sampleRate > 1) {
|
|
65
|
+
return { ok: false, reason: "sampleRate out of range" };
|
|
66
|
+
}
|
|
67
|
+
const event = { op, durationMs, sampleRate };
|
|
68
|
+
for (const field of allowed) {
|
|
69
|
+
if (!Object.prototype.hasOwnProperty.call(raw, field))
|
|
70
|
+
continue;
|
|
71
|
+
const value = raw[field];
|
|
72
|
+
if (BUCKET_FIELDS.has(field)) {
|
|
73
|
+
if (typeof value !== "string" || !BUCKETS.has(value))
|
|
74
|
+
return { ok: false, reason: `${field} is not a size bucket` };
|
|
75
|
+
event[field] = value;
|
|
76
|
+
}
|
|
77
|
+
else if (COUNT_FIELDS.has(field)) {
|
|
78
|
+
if (!isIntegerIn(value, 0, SYNC_PERF_MAX_COUNT))
|
|
79
|
+
return { ok: false, reason: `${field} out of range` };
|
|
80
|
+
event[field] = value;
|
|
81
|
+
}
|
|
82
|
+
else if (BOOLEAN_FIELDS.has(field)) {
|
|
83
|
+
if (typeof value !== "boolean")
|
|
84
|
+
return { ok: false, reason: `${field} is not a boolean` };
|
|
85
|
+
event[field] = value;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return { ok: true, event };
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return { ok: false, reason: "unreadable event" };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** Rows per POST /v1/usage request (cli-telemetry SYNC_PERF_USAGE_MAX_ROWS). */
|
|
95
|
+
export const SYNC_PERF_MAX_BATCH = 50;
|
|
96
|
+
/** Events held while a send is pending; newer events are dropped past this. */
|
|
97
|
+
export const SYNC_PERF_MAX_QUEUE = 200;
|
|
98
|
+
/** How long queued events wait for more to join their batch. */
|
|
99
|
+
export const SYNC_PERF_FLUSH_DELAY_MS = 30_000;
|
|
100
|
+
/** A send still pending after this stops holding the queue (the send itself times out sooner). */
|
|
101
|
+
export const SYNC_PERF_SEND_STALL_MS = 60_000;
|
|
102
|
+
function unrefTimeout(fn, ms) {
|
|
103
|
+
const handle = setTimeout(fn, ms);
|
|
104
|
+
handle.unref?.();
|
|
105
|
+
return handle;
|
|
106
|
+
}
|
|
107
|
+
export function createSyncPerfForwarder(deps) {
|
|
108
|
+
const setT = deps.setTimeout ?? unrefTimeout;
|
|
109
|
+
const clearT = deps.clearTimeout ?? ((handle) => clearTimeout(handle));
|
|
110
|
+
const flushDelayMs = deps.flushDelayMs ?? SYNC_PERF_FLUSH_DELAY_MS;
|
|
111
|
+
const maxBatch = Math.max(1, Math.min(deps.maxBatch ?? SYNC_PERF_MAX_BATCH, SYNC_PERF_MAX_BATCH));
|
|
112
|
+
const maxQueue = Math.max(maxBatch, deps.maxQueue ?? SYNC_PERF_MAX_QUEUE);
|
|
113
|
+
const sendStallMs = deps.sendStallMs ?? SYNC_PERF_SEND_STALL_MS;
|
|
114
|
+
const queue = [];
|
|
115
|
+
let flushTimer;
|
|
116
|
+
let stallTimer;
|
|
117
|
+
let inFlight = 0; // generation of the pending send; 0 when none
|
|
118
|
+
let generation = 0;
|
|
119
|
+
let droppedCount = 0;
|
|
120
|
+
let stopped = false;
|
|
121
|
+
const isEnabled = () => {
|
|
122
|
+
try {
|
|
123
|
+
return deps.enabled();
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const schedule = (ms) => {
|
|
130
|
+
if (stopped || flushTimer !== undefined || queue.length === 0)
|
|
131
|
+
return;
|
|
132
|
+
flushTimer = setT(() => {
|
|
133
|
+
flushTimer = undefined;
|
|
134
|
+
flush();
|
|
135
|
+
}, ms);
|
|
136
|
+
};
|
|
137
|
+
const settle = (gen) => {
|
|
138
|
+
if (inFlight !== gen)
|
|
139
|
+
return;
|
|
140
|
+
inFlight = 0;
|
|
141
|
+
if (stallTimer !== undefined) {
|
|
142
|
+
clearT(stallTimer);
|
|
143
|
+
stallTimer = undefined;
|
|
144
|
+
}
|
|
145
|
+
schedule(queue.length >= maxBatch ? 0 : flushDelayMs);
|
|
146
|
+
};
|
|
147
|
+
const flush = () => {
|
|
148
|
+
if (stopped || inFlight !== 0 || queue.length === 0)
|
|
149
|
+
return;
|
|
150
|
+
if (!isEnabled()) {
|
|
151
|
+
queue.length = 0;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const batch = queue.splice(0, maxBatch);
|
|
155
|
+
const gen = ++generation;
|
|
156
|
+
inFlight = gen;
|
|
157
|
+
stallTimer = setT(() => {
|
|
158
|
+
stallTimer = undefined;
|
|
159
|
+
settle(gen);
|
|
160
|
+
}, sendStallMs);
|
|
161
|
+
let pending;
|
|
162
|
+
try {
|
|
163
|
+
pending = Promise.resolve(deps.send(batch));
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
pending = Promise.resolve();
|
|
167
|
+
}
|
|
168
|
+
pending.then(() => settle(gen), () => settle(gen));
|
|
169
|
+
};
|
|
170
|
+
return {
|
|
171
|
+
push(event) {
|
|
172
|
+
if (stopped || !isEnabled())
|
|
173
|
+
return;
|
|
174
|
+
if (queue.length >= maxQueue) {
|
|
175
|
+
droppedCount++;
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
queue.push(event);
|
|
179
|
+
if (inFlight !== 0)
|
|
180
|
+
return;
|
|
181
|
+
if (queue.length >= maxBatch) {
|
|
182
|
+
if (flushTimer !== undefined) {
|
|
183
|
+
clearT(flushTimer);
|
|
184
|
+
flushTimer = undefined;
|
|
185
|
+
}
|
|
186
|
+
schedule(0);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
schedule(flushDelayMs);
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
stop() {
|
|
193
|
+
stopped = true;
|
|
194
|
+
queue.length = 0;
|
|
195
|
+
if (flushTimer !== undefined)
|
|
196
|
+
clearT(flushTimer);
|
|
197
|
+
if (stallTimer !== undefined)
|
|
198
|
+
clearT(stallTimer);
|
|
199
|
+
flushTimer = undefined;
|
|
200
|
+
stallTimer = undefined;
|
|
201
|
+
},
|
|
202
|
+
queued: () => queue.length,
|
|
203
|
+
dropped: () => droppedCount,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=sync-perf-telemetry.js.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Start the Windows Scheduled Task again after a managed daemon exits to
|
|
3
|
+
* restart (RESTART_EXIT_CODE, for example onto an updated CLI).
|
|
4
|
+
*
|
|
5
|
+
* launchd (KeepAlive) and systemd (Restart=) start the daemon again when it
|
|
6
|
+
* exits. The Scheduled Task does not: its only trigger is logon, and
|
|
7
|
+
* RestartOnFailure fires when the task fails to start, not when the started
|
|
8
|
+
* process exits with a non-zero code. Without this the daemon stayed down
|
|
9
|
+
* until the next logon (feedback_a89efa81).
|
|
10
|
+
*
|
|
11
|
+
* The task's MultipleInstancesPolicy is IgnoreNew, so `schtasks /Run` while
|
|
12
|
+
* this daemon is still running is dropped. A small detached node process waits
|
|
13
|
+
* for this daemon's pid to exit, waits a little longer for the task's launcher
|
|
14
|
+
* to finish, and then runs the task. Services handed over on restart already
|
|
15
|
+
* outlive the daemon the same way, so the helper does too.
|
|
16
|
+
*/
|
|
17
|
+
import { type SpawnOptions } from "node:child_process";
|
|
18
|
+
/** Polls the daemon pid, then runs the command once; exits on its own after the deadline. */
|
|
19
|
+
export declare const WINDOWS_RELAUNCH_HELPER = "\nconst [pidArg, settleArg, deadlineArg, command, argsJson] = process.argv.slice(1);\nconst pid = Number(pidArg);\nconst settleMs = Number(settleArg);\nconst deadline = Date.now() + Number(deadlineArg);\nconst alive = () => { try { process.kill(pid, 0); return true; } catch (err) { return err && err.code === \"EPERM\"; } };\nconst run = () => {\n const r = require(\"node:child_process\").spawnSync(command, JSON.parse(argsJson), { windowsHide: true, stdio: \"ignore\" });\n process.exit(r.status === 0 ? 0 : 1);\n};\nconst tick = () => {\n if (alive() && Date.now() < deadline) { setTimeout(tick, 250); return; }\n setTimeout(run, settleMs);\n};\ntick();\n";
|
|
20
|
+
export interface WindowsRelaunchOptions {
|
|
21
|
+
/** The per-user daemon task name (install.ts currentDaemonWindowsTaskName). */
|
|
22
|
+
taskName: string;
|
|
23
|
+
/** The exiting daemon's pid; the helper waits for it to be gone. */
|
|
24
|
+
daemonPid?: number;
|
|
25
|
+
/** Extra wait after the pid is gone, for the task's launcher (conhost) to exit. */
|
|
26
|
+
settleMs?: number;
|
|
27
|
+
/** Longest wait for the pid before running the task anyway. */
|
|
28
|
+
deadlineMs?: number;
|
|
29
|
+
execPath?: string;
|
|
30
|
+
/** schtasks.exe; System32's by default. */
|
|
31
|
+
schtasks?: string;
|
|
32
|
+
env?: NodeJS.ProcessEnv;
|
|
33
|
+
spawn?: (command: string, args: string[], options: SpawnOptions) => {
|
|
34
|
+
unref(): void;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export declare function system32Schtasks(env?: NodeJS.ProcessEnv): string;
|
|
38
|
+
/** The command line the detached helper runs; exported for tests. */
|
|
39
|
+
export declare function windowsRelaunchCommand(opts: WindowsRelaunchOptions): {
|
|
40
|
+
command: string;
|
|
41
|
+
args: string[];
|
|
42
|
+
};
|
|
43
|
+
/** Spawns the detached helper. Never throws: a failure is returned for the caller to log. */
|
|
44
|
+
export declare function scheduleWindowsTaskRelaunch(opts: WindowsRelaunchOptions): {
|
|
45
|
+
ok: true;
|
|
46
|
+
} | {
|
|
47
|
+
ok: false;
|
|
48
|
+
error: string;
|
|
49
|
+
};
|
|
50
|
+
/** Only the Windows Scheduled Task needs the helper; an app that hosts the daemon relaunches it itself. */
|
|
51
|
+
export declare function needsWindowsTaskRelaunch(platform: NodeJS.Platform, opts: {
|
|
52
|
+
managed?: boolean;
|
|
53
|
+
host?: unknown;
|
|
54
|
+
}): boolean;
|
|
55
|
+
//# sourceMappingURL=windows-relaunch.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Start the Windows Scheduled Task again after a managed daemon exits to
|
|
3
|
+
* restart (RESTART_EXIT_CODE, for example onto an updated CLI).
|
|
4
|
+
*
|
|
5
|
+
* launchd (KeepAlive) and systemd (Restart=) start the daemon again when it
|
|
6
|
+
* exits. The Scheduled Task does not: its only trigger is logon, and
|
|
7
|
+
* RestartOnFailure fires when the task fails to start, not when the started
|
|
8
|
+
* process exits with a non-zero code. Without this the daemon stayed down
|
|
9
|
+
* until the next logon (feedback_a89efa81).
|
|
10
|
+
*
|
|
11
|
+
* The task's MultipleInstancesPolicy is IgnoreNew, so `schtasks /Run` while
|
|
12
|
+
* this daemon is still running is dropped. A small detached node process waits
|
|
13
|
+
* for this daemon's pid to exit, waits a little longer for the task's launcher
|
|
14
|
+
* to finish, and then runs the task. Services handed over on restart already
|
|
15
|
+
* outlive the daemon the same way, so the helper does too.
|
|
16
|
+
*/
|
|
17
|
+
import { spawn as nodeSpawn } from "node:child_process";
|
|
18
|
+
import * as path from "node:path";
|
|
19
|
+
/** Polls the daemon pid, then runs the command once; exits on its own after the deadline. */
|
|
20
|
+
export const WINDOWS_RELAUNCH_HELPER = `
|
|
21
|
+
const [pidArg, settleArg, deadlineArg, command, argsJson] = process.argv.slice(1);
|
|
22
|
+
const pid = Number(pidArg);
|
|
23
|
+
const settleMs = Number(settleArg);
|
|
24
|
+
const deadline = Date.now() + Number(deadlineArg);
|
|
25
|
+
const alive = () => { try { process.kill(pid, 0); return true; } catch (err) { return err && err.code === "EPERM"; } };
|
|
26
|
+
const run = () => {
|
|
27
|
+
const r = require("node:child_process").spawnSync(command, JSON.parse(argsJson), { windowsHide: true, stdio: "ignore" });
|
|
28
|
+
process.exit(r.status === 0 ? 0 : 1);
|
|
29
|
+
};
|
|
30
|
+
const tick = () => {
|
|
31
|
+
if (alive() && Date.now() < deadline) { setTimeout(tick, 250); return; }
|
|
32
|
+
setTimeout(run, settleMs);
|
|
33
|
+
};
|
|
34
|
+
tick();
|
|
35
|
+
`;
|
|
36
|
+
export function system32Schtasks(env = process.env) {
|
|
37
|
+
const root = env.SystemRoot?.trim() || env.windir?.trim() || "C:\\Windows";
|
|
38
|
+
return path.win32.join(root, "System32", "schtasks.exe");
|
|
39
|
+
}
|
|
40
|
+
/** The command line the detached helper runs; exported for tests. */
|
|
41
|
+
export function windowsRelaunchCommand(opts) {
|
|
42
|
+
const schtasks = opts.schtasks ?? system32Schtasks(opts.env);
|
|
43
|
+
return {
|
|
44
|
+
command: opts.execPath ?? process.execPath,
|
|
45
|
+
args: [
|
|
46
|
+
"-e",
|
|
47
|
+
WINDOWS_RELAUNCH_HELPER,
|
|
48
|
+
String(opts.daemonPid ?? process.pid),
|
|
49
|
+
String(opts.settleMs ?? 3_000),
|
|
50
|
+
String(opts.deadlineMs ?? 60_000),
|
|
51
|
+
schtasks,
|
|
52
|
+
JSON.stringify(["/Run", "/TN", opts.taskName]),
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Spawns the detached helper. Never throws: a failure is returned for the caller to log. */
|
|
57
|
+
export function scheduleWindowsTaskRelaunch(opts) {
|
|
58
|
+
const { command, args } = windowsRelaunchCommand(opts);
|
|
59
|
+
try {
|
|
60
|
+
const child = (opts.spawn ?? nodeSpawn)(command, args, { detached: true, stdio: "ignore", windowsHide: true });
|
|
61
|
+
child.unref();
|
|
62
|
+
return { ok: true };
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
return { ok: false, error: err.message };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** Only the Windows Scheduled Task needs the helper; an app that hosts the daemon relaunches it itself. */
|
|
69
|
+
export function needsWindowsTaskRelaunch(platform, opts) {
|
|
70
|
+
return platform === "win32" && opts.managed === true && opts.host === undefined;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=windows-relaunch.js.map
|
|
@@ -281,11 +281,20 @@ export declare function grokPreToolUseHold(root: string, shadow: boolean): strin
|
|
|
281
281
|
/**
|
|
282
282
|
* The dispatcher files the native PreToolUse master model reproduces, in its check order:
|
|
283
283
|
* crates/hq-hook/src/pre_tool_use_master.rs `DISPATCHER_PINS`. master-hook.sh is v16.0.48 (1a2439ae),
|
|
284
|
-
* v16.0.50 (774bca73)
|
|
284
|
+
* v16.0.50 (774bca73), v16.0.49 (d5049d5f), v16.0.51 (443272ef) or v16.0.52 (ab46ebdf; v16.0.51 plus a PostToolUse-only
|
|
285
|
+
* prefilter text for MCP tools), whose session-id alias record the native bind writes too; hook-adapter-core.sh is held per host below; hqd-hook-shim.sh is the released ab289ac0 or the
|
|
285
286
|
* hq-core-staging fd709b39a ee5e9fe7, and session-id.sh the released 2ebbc508 or the fd709b39a
|
|
286
287
|
* d6a04155; every other file is one revision.
|
|
287
288
|
*/
|
|
288
289
|
export declare const PRE_TOOL_USE_DISPATCHER_PINS: readonly PinnedFile[];
|
|
290
|
+
/**
|
|
291
|
+
* hook-adapter-core.sh, held per host (pre_tool_use_master.rs `HOST_DISPATCHER_PINS`). On Claude
|
|
292
|
+
* Code master-hook.sh calls only `hqad_registry_prefilter_match` from it, byte-equal with its
|
|
293
|
+
* helpers in v16.0.50 (940bb5a0), v16.0.51 (09f5a3e0) and v16.0.52 (cf1abd5c, a comment change), so all three are accepted; on Codex the
|
|
294
|
+
* adapter runs the functions v16.0.51 changed, so only 940bb5a0 is.
|
|
295
|
+
*/
|
|
296
|
+
export declare const PRE_TOOL_USE_CLAUDE_DISPATCHER_PINS: readonly PinnedFile[];
|
|
297
|
+
export declare const PRE_TOOL_USE_CODEX_DISPATCHER_PINS: readonly PinnedFile[];
|
|
289
298
|
/** The Codex adapter the model reproduces on Codex only (pre_tool_use_master.rs `CODEX_ADAPTER_PIN`). */
|
|
290
299
|
export declare const PRE_TOOL_USE_CODEX_ADAPTER_PIN: PinnedFile;
|
|
291
300
|
/**
|
|
@@ -2012,7 +2012,8 @@ export function grokPreToolUseHold(root, shadow) {
|
|
|
2012
2012
|
/**
|
|
2013
2013
|
* The dispatcher files the native PreToolUse master model reproduces, in its check order:
|
|
2014
2014
|
* crates/hq-hook/src/pre_tool_use_master.rs `DISPATCHER_PINS`. master-hook.sh is v16.0.48 (1a2439ae),
|
|
2015
|
-
* v16.0.50 (774bca73)
|
|
2015
|
+
* v16.0.50 (774bca73), v16.0.49 (d5049d5f), v16.0.51 (443272ef) or v16.0.52 (ab46ebdf; v16.0.51 plus a PostToolUse-only
|
|
2016
|
+
* prefilter text for MCP tools), whose session-id alias record the native bind writes too; hook-adapter-core.sh is held per host below; hqd-hook-shim.sh is the released ab289ac0 or the
|
|
2016
2017
|
* hq-core-staging fd709b39a ee5e9fe7, and session-id.sh the released 2ebbc508 or the fd709b39a
|
|
2017
2018
|
* d6a04155; every other file is one revision.
|
|
2018
2019
|
*/
|
|
@@ -2025,7 +2026,13 @@ export const PRE_TOOL_USE_DISPATCHER_PINS = [
|
|
|
2025
2026
|
'4dd7f5296934d4488c137c9a485d4c9d55b597ee3aa2ceb6dbc3afdb0d3c1a74',
|
|
2026
2027
|
],
|
|
2027
2028
|
},
|
|
2028
|
-
{
|
|
2029
|
+
{
|
|
2030
|
+
relative: '.claude/hooks/hook-timeout-probe.sh',
|
|
2031
|
+
accepted: [
|
|
2032
|
+
'ae5c40212c088044205e246a5715a53f52c28f4021e798bd7a74df6ba570113b',
|
|
2033
|
+
'ed0daf8c9b2cf9c8f44c67db5e5666ac75307df1be512b89eb0f4ccca4ed823e',
|
|
2034
|
+
],
|
|
2035
|
+
},
|
|
2029
2036
|
{ relative: '.claude/hooks/hook-timeout-watchdog.sh', accepted: ['3017517bbcd618be5162c621105c229aeba66fea1c39f6dd744416029f0448b5'] },
|
|
2030
2037
|
{ relative: '.claude/hooks/machine-check-owner.sh', accepted: ['04ee93b3669470930732a2f6f7d9f0011fe7221d3ee0fe706b8f468cd30da16d'] },
|
|
2031
2038
|
{
|
|
@@ -2034,6 +2041,8 @@ export const PRE_TOOL_USE_DISPATCHER_PINS = [
|
|
|
2034
2041
|
'1a2439aee50652c5143ccd18561a0aa84a1e94848d02c1aa1c99157f70023f29',
|
|
2035
2042
|
'774bca73a2e806b4d9ad96b803525bdf25afd2265d63c9216881aa4ced403f16',
|
|
2036
2043
|
'd5049d5fb38d2b33467d493a4a136df8f6d9021c29e722df0d1e6a17d7f452ab',
|
|
2044
|
+
'443272ef7642d87b6833bc97b71350502491445cd09b26be9f45140804368b00',
|
|
2045
|
+
'ab46ebdf0cc84a90dd95a54417817f9f9023b109d5b3710c472a8f5e89061592',
|
|
2037
2046
|
],
|
|
2038
2047
|
},
|
|
2039
2048
|
{ relative: '.claude/hooks/turn-timing.sh', accepted: ['97c70a3251225ba9e469e41fd3fe2341cfe2936490f54571d2ca16de8e766443'] },
|
|
@@ -2043,16 +2052,38 @@ export const PRE_TOOL_USE_DISPATCHER_PINS = [
|
|
|
2043
2052
|
{ relative: 'core/scripts/hqd-hook-shim.sh', accepted: ['ab289ac0af680fe3bcacb110302ca8b998bdc33c6f94321d42bd04a344163eed', 'ee5e9fe729eb7e51f87b5f90cdc020be865f5b6b35ac0b5758587546b35715c0'] },
|
|
2044
2053
|
{ relative: 'core/scripts/lib/advisory-cap.sh', accepted: ['ab80b2a3f63a5955db392eaff4e54fed88d20130e96ca5c2a0945a3ea146d39b'] },
|
|
2045
2054
|
{ relative: 'core/scripts/lib/epochrealtime.sh', accepted: ['4c9205520dba31533c95eea145f6068ba626885c342c2aa1f232a7237d046cdf'] },
|
|
2046
|
-
{ relative: 'core/scripts/lib/hook-adapter-core.sh', accepted: ['940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'] },
|
|
2047
2055
|
{ relative: 'core/scripts/lib/perl-child-locale.sh', accepted: ['18e6b9d0e22874eea00ecc868b4dcfebbc3bb42434d8d0c81b20baec1194df2e'] },
|
|
2048
2056
|
{ relative: 'core/scripts/lib/session-id.sh', accepted: ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d', 'd6a04155571ec53edd853878cebaba5a5bab93801a73e356499440c1cd009c71'] },
|
|
2049
2057
|
{ relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead'] },
|
|
2050
2058
|
{ relative: 'core/scripts/resolve-hq-root.sh', accepted: ['188e99c7c60bc9909290a666d6f3b93387ae6cf68f2eeb41fd24c2dea62a5240'] },
|
|
2051
2059
|
];
|
|
2060
|
+
/**
|
|
2061
|
+
* hook-adapter-core.sh, held per host (pre_tool_use_master.rs `HOST_DISPATCHER_PINS`). On Claude
|
|
2062
|
+
* Code master-hook.sh calls only `hqad_registry_prefilter_match` from it, byte-equal with its
|
|
2063
|
+
* helpers in v16.0.50 (940bb5a0), v16.0.51 (09f5a3e0) and v16.0.52 (cf1abd5c, a comment change), so all three are accepted; on Codex the
|
|
2064
|
+
* adapter runs the functions v16.0.51 changed, so only 940bb5a0 is.
|
|
2065
|
+
*/
|
|
2066
|
+
export const PRE_TOOL_USE_CLAUDE_DISPATCHER_PINS = [
|
|
2067
|
+
{
|
|
2068
|
+
relative: 'core/scripts/lib/hook-adapter-core.sh',
|
|
2069
|
+
accepted: [
|
|
2070
|
+
'940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5',
|
|
2071
|
+
RELEASED_CLASSIFYING_ADAPTER_CORE_SHA256,
|
|
2072
|
+
CLASSIFYING_ADAPTER_CORE_SHA256,
|
|
2073
|
+
],
|
|
2074
|
+
},
|
|
2075
|
+
];
|
|
2076
|
+
export const PRE_TOOL_USE_CODEX_DISPATCHER_PINS = [
|
|
2077
|
+
{ relative: 'core/scripts/lib/hook-adapter-core.sh', accepted: ['940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'] },
|
|
2078
|
+
];
|
|
2052
2079
|
/** The Codex adapter the model reproduces on Codex only (pre_tool_use_master.rs `CODEX_ADAPTER_PIN`). */
|
|
2053
2080
|
export const PRE_TOOL_USE_CODEX_ADAPTER_PIN = {
|
|
2054
2081
|
relative: '.codex/hooks/hq-codex-hook-adapter.sh',
|
|
2055
|
-
|
|
2082
|
+
// a3178b59: v16.0.48-beta.124 to v16.0.50. a905f518: v16.0.51 and v16.0.52.
|
|
2083
|
+
accepted: [
|
|
2084
|
+
'a3178b59e633310f3cc39a8c257ff58863169696ffda04dc6ea93a34a5db05ef',
|
|
2085
|
+
'a905f51887c497165df1e46e703a504fee7dbc6c879ebcec845d585b13151f52',
|
|
2086
|
+
],
|
|
2056
2087
|
};
|
|
2057
2088
|
/**
|
|
2058
2089
|
* The claimed vault-write guard's script and the companions it reads (crates/hq-hook/src/ports.rs
|
|
@@ -2068,6 +2099,7 @@ export const PRE_TOOL_USE_VAULT_GUARD_PINS = [
|
|
|
2068
2099
|
'9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f',
|
|
2069
2100
|
'df3d8ddc15a0c179227c9ba7f855c040973fcee249673156d08b2e2ff2c850b8',
|
|
2070
2101
|
'b971dae4a2b82bfa5b31782e54717115abaf052457fb1a546893d04cae43adbb',
|
|
2102
|
+
'436493e3325fb0cbcad651ae8ef42d89f4adf43fe38abd938ed6a39c0b6d17c1',
|
|
2071
2103
|
],
|
|
2072
2104
|
},
|
|
2073
2105
|
{ relative: '.claude/hooks/enforce-vault-write-access-flag.cjs', accepted: ['87dbddf1867296562ce76096c47869bca5c1a6a262b526421ac96aecfef90c45'] },
|
|
@@ -2110,6 +2142,7 @@ export const PRE_TOOL_USE_IMAGE_GUARD_PINS = [
|
|
|
2110
2142
|
'c5c8153f1e6cead7a2cbfc9085788f26970efc79752660ff2c308112622a5c8e',
|
|
2111
2143
|
'b971dae4a2b82bfa5b31782e54717115abaf052457fb1a546893d04cae43adbb',
|
|
2112
2144
|
'9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f',
|
|
2145
|
+
'436493e3325fb0cbcad651ae8ef42d89f4adf43fe38abd938ed6a39c0b6d17c1',
|
|
2113
2146
|
],
|
|
2114
2147
|
missing: 'allowed',
|
|
2115
2148
|
},
|
|
@@ -2195,7 +2228,9 @@ export function mergedWriteGuardHold(root, event) {
|
|
|
2195
2228
|
* Null when the native PreToolUse accepts every file.
|
|
2196
2229
|
*/
|
|
2197
2230
|
export function preToolUseHold(root, host, hooks = []) {
|
|
2198
|
-
const files = host === 'codex'
|
|
2231
|
+
const files = host === 'codex'
|
|
2232
|
+
? [...PRE_TOOL_USE_DISPATCHER_PINS, ...PRE_TOOL_USE_CODEX_DISPATCHER_PINS, PRE_TOOL_USE_CODEX_ADAPTER_PIN]
|
|
2233
|
+
: [...PRE_TOOL_USE_DISPATCHER_PINS, ...PRE_TOOL_USE_CLAUDE_DISPATCHER_PINS];
|
|
2199
2234
|
const credential = PRE_TOOL_USE_CREDENTIAL_GUARD_GENERATIONS;
|
|
2200
2235
|
const evaluator = () => {
|
|
2201
2236
|
for (const pin of PRE_TOOL_USE_FRONTMATTER_EVALUATOR_PINS) {
|
|
@@ -2258,6 +2293,7 @@ export function promptCompanyBindHold(root) {
|
|
|
2258
2293
|
* (crates/hq-hook/src/gate/facts.rs `accepted_hook_lib_sha256`).
|
|
2259
2294
|
*/
|
|
2260
2295
|
export const POLICY_GATE_REVISIONS = [
|
|
2296
|
+
{ revision: 'Core16_0_52', gate: 'ecdbab7c2e0a1d94eb9c98f15e760390f215bc7115a217ded24b4275322722d2', hookLibs: ['436493e3325fb0cbcad651ae8ef42d89f4adf43fe38abd938ed6a39c0b6d17c1'] },
|
|
2261
2297
|
{ revision: 'Core16_0_51', gate: 'ca58a94859eae0a345c11c8d9c59303eb76350dc1cf223391037d21979c28718', hookLibs: ['9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f'] },
|
|
2262
2298
|
{ revision: 'Staging2018', gate: '1bc4df8eaabded175804d2effba704c93b439df05c0867f85bb27f5dcfbc7914', hookLibs: ['9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f'] },
|
|
2263
2299
|
{ revision: 'Core16_0_48Beta90', gate: 'a2879dfe692233f5953bac86672947bbd82f3c5247292f3efcb80f16c3d2c6b1', hookLibs: ['9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f', '49c337ceccf0a2d7c2a64f6b1de8c3c4d1da507bc5d7afcd01ed292e1f25abf7', 'be7ca74b2524afba56fefd530bf46cbd1dd39a4c181b6a64c87e124b29bdebe7'] },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
|
-
import { basename, countImmediate, exists, immediateEntries, isHidden, log, prdProjectStatus, readJson, sanitize, titleize, truncate, writeIfChanged } from "./shared.js";
|
|
3
|
+
import { basename, countImmediate, exists, immediateEntries, isHidden, log, prdProjectStatus, readJson, sanitize, SESSION_SCOPE_HELP, titleize, truncate, writeIfChanged } from "./shared.js";
|
|
4
4
|
export class CompanyIndexUserError extends Error {
|
|
5
5
|
constructor(message) {
|
|
6
6
|
super(message);
|
|
@@ -38,7 +38,8 @@ export function renderCompanies(context, args = []) {
|
|
|
38
38
|
(context.output ?? ((message) => process.stdout.write(message)))("Usage: hq core rebuild-index companies [--company <slug>]\n\n" +
|
|
39
39
|
"Regenerate company root INDEX.md files. Without --company, all companies are regenerated.\n" +
|
|
40
40
|
"--company <slug> regenerates only that company's index.\n" +
|
|
41
|
-
"Company-scoped writes require the cli.rebuild-index-company-scope flag.\n"
|
|
41
|
+
"Company-scoped writes require the cli.rebuild-index-company-scope flag.\n" +
|
|
42
|
+
SESSION_SCOPE_HELP);
|
|
42
43
|
return { written: [] };
|
|
43
44
|
}
|
|
44
45
|
let selectedCompany;
|
|
@@ -7,6 +7,7 @@ import { renderProjects } from "./projects.js";
|
|
|
7
7
|
import { renderPublicKnowledge } from "./public-knowledge.js";
|
|
8
8
|
import { renderReports } from "./reports.js";
|
|
9
9
|
import { renderSocialDrafts } from "./social-drafts.js";
|
|
10
|
+
import { SESSION_SCOPE_HELP } from "./shared.js";
|
|
10
11
|
import { renderThreads } from "./threads.js";
|
|
11
12
|
import { renderWorkers } from "./workers.js";
|
|
12
13
|
const allOrder = ["threads", "orchestrator", "companies", "projects", "company-knowledge", "public-knowledge", "workers", "reports", "social-drafts"];
|
|
@@ -110,7 +111,7 @@ function isHelp(args) {
|
|
|
110
111
|
export function renderIndexTarget(target, context, args = []) {
|
|
111
112
|
if (target === "company-knowledge" || target === "projects") {
|
|
112
113
|
if (isHelp(args)) {
|
|
113
|
-
(context.output ?? ((message) => process.stdout.write(message)))(`Usage: hq core rebuild-index ${target} [<company> | --company <company>] [--accept]\n\nWith a company, rebuild only that company's index. Without a company, retain the all-company rebuild. Help performs no writes.\n`);
|
|
114
|
+
(context.output ?? ((message) => process.stdout.write(message)))(`Usage: hq core rebuild-index ${target} [<company> | --company <company>] [--accept]\n\nWith a company, rebuild only that company's index. Without a company, retain the all-company rebuild. Help performs no writes.\n${SESSION_SCOPE_HELP}`);
|
|
114
115
|
return { written: [] };
|
|
115
116
|
}
|
|
116
117
|
const company = companyScope(target, context, args);
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* CompanyIndexUserError raised before the first renderer call.
|
|
23
23
|
*/
|
|
24
24
|
import { type IndexTarget } from "./index.js";
|
|
25
|
+
import { ALL_COMPANIES_FLAG, SESSION_SCOPE_HELP } from "./shared.js";
|
|
25
26
|
export interface PlannedRebuild {
|
|
26
27
|
target: IndexTarget;
|
|
27
28
|
args: string[];
|
|
@@ -37,9 +38,7 @@ export type SessionCompanyState = {
|
|
|
37
38
|
kind: "bound";
|
|
38
39
|
companies: string[];
|
|
39
40
|
};
|
|
40
|
-
export
|
|
41
|
-
/** Appended to the help of the company targets (projects, company-knowledge, companies). */
|
|
42
|
-
export declare const SESSION_SCOPE_HELP: string;
|
|
41
|
+
export { ALL_COMPANIES_FLAG, SESSION_SCOPE_HELP };
|
|
43
42
|
export declare const UNBOUND_ALL_COMPANIES_WARNING = "hq: rebuild-index: this session is not bound to a company, so every company's index is rebuilt. Pass --company <slug> to rebuild one.";
|
|
44
43
|
export declare const COMPANY_SCOPE_FLAG_OFF_WARNING = "hq: rebuild-index: cli.rebuild-index-company-scope is off, so the company root indexes (companies/<slug>/INDEX.md) are rebuilt for every company, as before scoping.";
|
|
45
44
|
export declare const PERSONAL_ALL_NOTE = "hq: rebuild-index all: this session is bound to personal; company indexes are skipped and the rest are rebuilt.";
|
|
@@ -28,12 +28,9 @@ import { sessionIdFromEnv, validSessionId } from "../core-utils/session-id.js";
|
|
|
28
28
|
import { resolveBundledAsset } from "../../utils/hq-roots-core.js";
|
|
29
29
|
import { CompanyIndexUserError } from "./companies.js";
|
|
30
30
|
import { SKIP_COMPANY_INDEXES, UNSCOPED_COMPANIES_INDEX } from "./index.js";
|
|
31
|
+
import { ALL_COMPANIES_FLAG, SESSION_SCOPE_HELP } from "./shared.js";
|
|
31
32
|
const COMPANY_TARGETS = new Set(["all", "companies", "company-knowledge", "projects"]);
|
|
32
|
-
export
|
|
33
|
-
/** Appended to the help of the company targets (projects, company-knowledge, companies). */
|
|
34
|
-
export const SESSION_SCOPE_HELP = "\nCompany scope: in a company-bound session, a run with no company rebuilds only the bound companies\n" +
|
|
35
|
-
"(core/scripts/hq-session.sh get company_slugs), and a company outside that set is refused.\n" +
|
|
36
|
-
`An unbound session keeps the every-company rebuild (or pass --company <slug>); ${ALL_COMPANIES_FLAG} states that explicitly.\n`;
|
|
33
|
+
export { ALL_COMPANIES_FLAG, SESSION_SCOPE_HELP };
|
|
37
34
|
export const UNBOUND_ALL_COMPANIES_WARNING = "hq: rebuild-index: this session is not bound to a company, so every company's index is rebuilt. Pass --company <slug> to rebuild one.";
|
|
38
35
|
export const COMPANY_SCOPE_FLAG_OFF_WARNING = "hq: rebuild-index: cli.rebuild-index-company-scope is off, so the company root indexes (companies/<slug>/INDEX.md) are rebuilt for every company, as before scoping.";
|
|
39
36
|
export const PERSONAL_ALL_NOTE = "hq: rebuild-index all: this session is bound to personal; company indexes are skipped and the rest are rebuilt.";
|
|
@@ -13,6 +13,13 @@ export type RenderResult = {
|
|
|
13
13
|
/** Relative paths whose rendered content matched the file on disk, so no write happened. */
|
|
14
14
|
unchanged?: string[];
|
|
15
15
|
};
|
|
16
|
+
export declare const ALL_COMPANIES_FLAG = "--all-companies";
|
|
17
|
+
/**
|
|
18
|
+
* Last paragraph of the --help text of the company targets (projects,
|
|
19
|
+
* company-knowledge, companies). The renderers print it, so the renderer, the
|
|
20
|
+
* `hq core rebuild-index` command and the bundled script print one help text.
|
|
21
|
+
*/
|
|
22
|
+
export declare const SESSION_SCOPE_HELP: string;
|
|
16
23
|
export declare function rel(root: string, file: string): string;
|
|
17
24
|
export declare function at(root: string, relative: string): string;
|
|
18
25
|
export declare function exists(root: string, relative: string): boolean;
|
|
@@ -2,6 +2,15 @@ import { createHash } from "crypto";
|
|
|
2
2
|
import * as fs from "fs";
|
|
3
3
|
import * as os from "os";
|
|
4
4
|
import * as path from "path";
|
|
5
|
+
export const ALL_COMPANIES_FLAG = "--all-companies";
|
|
6
|
+
/**
|
|
7
|
+
* Last paragraph of the --help text of the company targets (projects,
|
|
8
|
+
* company-knowledge, companies). The renderers print it, so the renderer, the
|
|
9
|
+
* `hq core rebuild-index` command and the bundled script print one help text.
|
|
10
|
+
*/
|
|
11
|
+
export const SESSION_SCOPE_HELP = "\nCompany scope: in a company-bound session, a run with no company rebuilds only the bound companies\n" +
|
|
12
|
+
"(core/scripts/hq-session.sh get company_slugs), and a company outside that set is refused.\n" +
|
|
13
|
+
`An unbound session keeps the every-company rebuild (or pass --company <slug>); ${ALL_COMPANIES_FLAG} states that explicitly.\n`;
|
|
5
14
|
export function rel(root, file) {
|
|
6
15
|
return path.relative(root, file).split(path.sep).join("/");
|
|
7
16
|
}
|
|
@@ -19,6 +19,20 @@
|
|
|
19
19
|
* S-1-3-0 (CREATOR OWNER), S-1-3-4 (OWNER RIGHTS), the current user's SID and
|
|
20
20
|
* the owner's SID when known.
|
|
21
21
|
*
|
|
22
|
+
* One principal is trusted by its SDDL abbreviation instead: `LA`. Microsoft's
|
|
23
|
+
* SID Strings page defines it as SDDL_LOCAL_ADMIN, "Local administrator", with
|
|
24
|
+
* RID DOMAIN_USER_RID_ADMIN (500). On a standalone hosted Windows runner
|
|
25
|
+
* icacls writes the built-in Administrator account's grant as `LA` (seen in
|
|
26
|
+
* CI); the machine part of that SID is not available here without another
|
|
27
|
+
* process spawn. Microsoft's Local accounts page says the Administrator
|
|
28
|
+
* account cannot be removed from the Administrators group, which is already
|
|
29
|
+
* trusted, so a grant to `LA` gives nothing a grant to `BA` does not. This is
|
|
30
|
+
* the normal DACL of a profile directory when the signed-in user is the
|
|
31
|
+
* built-in Administrator (GitHub's hosted Windows runners, some single-user
|
|
32
|
+
* machines): `(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)(A;OICIID;FA;;;LA)`.
|
|
33
|
+
* Not tested: a domain-joined machine. The documentation does not say which
|
|
34
|
+
* domain's RID 500 account a tool may print as `LA` there.
|
|
35
|
+
*
|
|
22
36
|
* Reduced-guarantee path (explicit, documented): the check does NOT throw and
|
|
23
37
|
* instead emits one stderr diagnostic that the config is unprotected on this
|
|
24
38
|
* platform when, and only when, the DACL cannot be evaluated:
|
|
@@ -19,6 +19,20 @@
|
|
|
19
19
|
* S-1-3-0 (CREATOR OWNER), S-1-3-4 (OWNER RIGHTS), the current user's SID and
|
|
20
20
|
* the owner's SID when known.
|
|
21
21
|
*
|
|
22
|
+
* One principal is trusted by its SDDL abbreviation instead: `LA`. Microsoft's
|
|
23
|
+
* SID Strings page defines it as SDDL_LOCAL_ADMIN, "Local administrator", with
|
|
24
|
+
* RID DOMAIN_USER_RID_ADMIN (500). On a standalone hosted Windows runner
|
|
25
|
+
* icacls writes the built-in Administrator account's grant as `LA` (seen in
|
|
26
|
+
* CI); the machine part of that SID is not available here without another
|
|
27
|
+
* process spawn. Microsoft's Local accounts page says the Administrator
|
|
28
|
+
* account cannot be removed from the Administrators group, which is already
|
|
29
|
+
* trusted, so a grant to `LA` gives nothing a grant to `BA` does not. This is
|
|
30
|
+
* the normal DACL of a profile directory when the signed-in user is the
|
|
31
|
+
* built-in Administrator (GitHub's hosted Windows runners, some single-user
|
|
32
|
+
* machines): `(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)(A;OICIID;FA;;;LA)`.
|
|
33
|
+
* Not tested: a domain-joined machine. The documentation does not say which
|
|
34
|
+
* domain's RID 500 account a tool may print as `LA` there.
|
|
35
|
+
*
|
|
22
36
|
* Reduced-guarantee path (explicit, documented): the check does NOT throw and
|
|
23
37
|
* instead emits one stderr diagnostic that the config is unprotected on this
|
|
24
38
|
* platform when, and only when, the DACL cannot be evaluated:
|
|
@@ -65,6 +79,13 @@ const SDDL_SID_ABBREVIATIONS = {
|
|
|
65
79
|
LA: "S-1-5-21-<domain>-500", // Local Administrator account
|
|
66
80
|
LG: "S-1-5-21-<domain>-501", // Local Guest account
|
|
67
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* Domain-relative abbreviations trusted without a concrete SID. Only the
|
|
84
|
+
* built-in Administrator account: it is always a member of Administrators
|
|
85
|
+
* (see the module header). The other domain-relative abbreviations (LG, DA,
|
|
86
|
+
* DU) stay unresolvable.
|
|
87
|
+
*/
|
|
88
|
+
const TRUSTED_SDDL_ABBREVIATIONS = new Set(["LA"]);
|
|
68
89
|
/** Resolve an SDDL account field to a SID, or null when unknown. */
|
|
69
90
|
export function sddlAccountToSid(account) {
|
|
70
91
|
const a = account.trim();
|
|
@@ -329,6 +350,11 @@ export function evaluateDacl(aces, opts) {
|
|
|
329
350
|
}
|
|
330
351
|
if ((mask & WRITE_MASK) === 0)
|
|
331
352
|
continue;
|
|
353
|
+
// Trusted, so go on to the next entry. A resolved untrusted writer after
|
|
354
|
+
// this one is still reported; an unresolvable entry after it still ends
|
|
355
|
+
// the scan with the reduced-guarantee diagnostic, as for any other DACL.
|
|
356
|
+
if (TRUSTED_SDDL_ABBREVIATIONS.has(ace.account.toUpperCase()))
|
|
357
|
+
continue;
|
|
332
358
|
const sid = sddlAccountToSid(ace.account);
|
|
333
359
|
if (!sid) {
|
|
334
360
|
return { kind: "unresolvable", reason: `cannot resolve principal "${ace.account}" to a SID` };
|