@indigoai-us/hq-cli 5.345.258 → 5.345.261
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 +58 -0
- package/assets/scaffold/core/scripts/handoff-knowledge-commit.sh +163 -5
- package/assets/scaffold/core/scripts/handoff-post.sh +30 -0
- package/assets/scaffold/core/scripts/handoff-sync-prefetch.sh +39 -0
- package/assets/scaffold/core/scripts/handoff-sync-publish.sh +51 -3
- package/contracts/host-canary-release.json +7 -7
- package/dist/commands/cloud.d.ts +2 -7
- package/dist/commands/cloud.js +2 -29
- package/dist/commands/core-bucket-c-handoff-knowledge-native.d.ts +24 -2
- package/dist/commands/core-bucket-c-handoff-knowledge-native.js +170 -19
- package/dist/commands/core-bucket-c-handoff-sync-native.d.ts +4 -2
- package/dist/commands/core-bucket-c-handoff-sync-native.js +153 -34
- package/dist/commands/core-bucket-c-handoff-sync-worker.cjs +201 -0
- package/dist/commands/core-delegate-w1b.js +17 -16
- package/dist/commands/core-delegate.js +5 -4
- package/dist/commands/core-handoff.d.ts +10 -0
- package/dist/commands/core-handoff.js +138 -16
- package/dist/commands/reindex.d.ts +3 -0
- package/dist/commands/reindex.js +11 -5
- package/dist/commands/rescue.js +7 -2
- package/dist/commands/sync-core.js +24 -7
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +3227 -2138
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/canonical-person.d.ts +19 -0
- package/dist/lib/canonical-person.js +30 -0
- package/dist/lib/company-sessions-cli.d.ts +12 -0
- package/dist/lib/company-sessions-cli.js +54 -0
- package/dist/lib/company-sessions.d.ts +31 -0
- package/dist/lib/company-sessions.js +304 -0
- package/dist/lib/doctor/fix/process-identity.d.ts +13 -0
- package/dist/lib/doctor/fix/process-identity.js +63 -7
- 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 +44 -1
- package/dist/lib/hook-engine/coverage.js +129 -1
- package/dist/lib/onboarding/orchestrator.js +4 -2
- package/dist/lib/sync-core/engine-home.d.ts +5 -1
- package/dist/lib/sync-core/engine-home.js +6 -2
- package/dist/lib/sync-core/reconcile.d.ts +5 -0
- package/dist/lib/sync-core/reconcile.js +21 -1
- package/dist/lib/sync-core/vault-uid.d.ts +2 -0
- package/dist/lib/sync-core/vault-uid.js +4 -0
- package/dist/utils/delegate-lock.d.ts +18 -0
- package/dist/utils/delegate-lock.js +149 -37
- package/dist/utils/sync-operation-lock.d.ts +2 -1
- package/dist/utils/sync-operation-lock.js +13 -2
- package/package.json +8 -8
|
@@ -168,6 +168,20 @@ export declare function coversKey(key: string): {
|
|
|
168
168
|
export declare function coveredOn(covers: Readonly<Record<string, readonly string[]>> | undefined, event: string, host: CoreNextHost): string[];
|
|
169
169
|
/** The old dispatcher's hooks for `event` on `host` that the engine does not cover. */
|
|
170
170
|
export declare function uncoveredHooks(root: string, host: CoreNextHost, event: string, covers: Readonly<Record<string, readonly string[]>> | undefined, env?: NodeJS.ProcessEnv): string[];
|
|
171
|
+
/**
|
|
172
|
+
* The two script revision sets the native `merged-write-guard-shadow` port rebuilds:
|
|
173
|
+
* legacy (`v16.0.48-beta.109`, constants in `crates/hq-hook/src/merged_write_guard.rs`) and
|
|
174
|
+
* released (`v16.0.49` / `v16.0.50`, constants in `crates/hq-hook/src/merged_write_guard/release_1649.rs`
|
|
175
|
+
* plus `Revision::Beta124` in `crates/hq-hook/src/block_core_writes.rs`).
|
|
176
|
+
*/
|
|
177
|
+
export declare const MERGED_WRITE_GUARD_PINS_LEGACY: ReadonlyArray<readonly [string, string]>;
|
|
178
|
+
export declare const MERGED_WRITE_GUARD_PINS_1649: ReadonlyArray<readonly [string, string]>;
|
|
179
|
+
/**
|
|
180
|
+
* Why `merged-write-guard-shadow` must stay on the shell registration in `root`: the wrapper
|
|
181
|
+
* script is present on disk and either the wrapper or one of its companion scripts does not match
|
|
182
|
+
* the pinned revision set that `crates/hq-hook/src/merged_write_guard.rs` rebuilds.
|
|
183
|
+
*/
|
|
184
|
+
export declare function fleetLocalMergedWriteGuardHold(root: string): string | null;
|
|
171
185
|
/**
|
|
172
186
|
* The script revisions the native SessionStart master rebuilds (hq-core v16.0.48 through v16.0.50,
|
|
173
187
|
* and the hq-core-staging fd709b39a shim and hq-session.sh):
|
|
@@ -200,6 +214,23 @@ export declare const MIGRATE_POLICY_TRIGGERS_PINS: ReadonlyArray<readonly [strin
|
|
|
200
214
|
* does not hold. Null when every present pinned file matches.
|
|
201
215
|
*/
|
|
202
216
|
export declare function migratePolicyTriggersHold(root: string): string | null;
|
|
217
|
+
/**
|
|
218
|
+
* The script revisions the native fleet-local PreToolUse adapter port models (hq-core v16.0.48
|
|
219
|
+
* through v16.0.50): `host::fleet::local_pre::RELEASED_CORE_SHA256` (`hook-adapter-core.sh`)
|
|
220
|
+
* and `host::fleet::inherit_scope::RELEASED_LIB_SHA256` (`session-scope-capability.sh`).
|
|
221
|
+
* `FleetLocalPre` matches the shell adapter when either file is absent (`DISPATCHER_UNAVAILABLE`
|
|
222
|
+
* / skip scope inheritance), and refuses any other revision present on disk.
|
|
223
|
+
* `RELEASED_CORE_SHA256` also accepts the two classifying cores of hq-core-staging #2119. This
|
|
224
|
+
* list accepts only the bd733f7b core, the one the fleet-local parity tests run against, so a
|
|
225
|
+
* root on a classifying core keeps fleet-local PreToolUse on the shell adapter.
|
|
226
|
+
*/
|
|
227
|
+
export declare const FLEET_LOCAL_PRE_TOOL_USE_PINS: readonly PinnedFile[];
|
|
228
|
+
/**
|
|
229
|
+
* Why fleet-local PreToolUse must stay on the shell adapter in `root`: a present file of
|
|
230
|
+
* [`FLEET_LOCAL_PRE_TOOL_USE_PINS`] cannot be read or is not the pinned revision. Uses the shared
|
|
231
|
+
* [`pinnedFilesHold`] helper. Null when every present file matches.
|
|
232
|
+
*/
|
|
233
|
+
export declare function fleetLocalPreToolUseHold(root: string): string | null;
|
|
203
234
|
/**
|
|
204
235
|
* The one Codex adapter pair the native Codex SubagentStop is modelled on (hq-core v16.0.47):
|
|
205
236
|
* `ADAPTER_RELEASES` and `ADAPTER_CORE_RELEASES` in crates/hq-hook/src/post_hooks/codex.rs.
|
|
@@ -281,7 +312,7 @@ export declare function grokPreToolUseHold(root: string, shadow: boolean): strin
|
|
|
281
312
|
/**
|
|
282
313
|
* The dispatcher files the native PreToolUse master model reproduces, in its check order:
|
|
283
314
|
* crates/hq-hook/src/pre_tool_use_master.rs `DISPATCHER_PINS`. master-hook.sh is v16.0.48 (1a2439ae),
|
|
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
|
|
315
|
+
* v16.0.50 (774bca73), v16.0.49 (d5049d5f), v16.0.51 (443272ef) or v16.0.52 (ab46ebdf, and hq-core-staging #2152's f9a32c25, which only scopes the folder hook limit by event; v16.0.51 plus a PostToolUse-only
|
|
285
316
|
* 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
|
|
286
317
|
* hq-core-staging fd709b39a ee5e9fe7, and session-id.sh the released 2ebbc508 or the fd709b39a
|
|
287
318
|
* d6a04155; every other file is one revision.
|
|
@@ -304,6 +335,16 @@ export declare const PRE_TOOL_USE_CODEX_ADAPTER_PIN: PinnedFile;
|
|
|
304
335
|
* credential guard holds that file.
|
|
305
336
|
*/
|
|
306
337
|
export declare const PRE_TOOL_USE_VAULT_GUARD_PINS: readonly PinnedFile[];
|
|
338
|
+
/**
|
|
339
|
+
* Claimed PreToolUse hooks whose native member answers in place of the root's script with no port
|
|
340
|
+
* pin of its own, with the script revisions the member answers for: pre_tool_use_master.rs
|
|
341
|
+
* `CLAIMED_SCRIPT_PINS`, where the native PreToolUse refuses any other present revision. The scope
|
|
342
|
+
* authorizer: hq-core v16.0.45 to v16.0.52 and the prereleases core-pins.json lists. hq-core
|
|
343
|
+
* 16.0.53-beta.1 (36312275) adds a PowerShell check the native scope member does not have, so that
|
|
344
|
+
* root stays on the old dispatcher. A missing script is not held: the native PreToolUse refuses a
|
|
345
|
+
* registered safety guard that is missing, as master-hook did.
|
|
346
|
+
*/
|
|
347
|
+
export declare const PRE_TOOL_USE_CLAIMED_SCRIPT_PINS: readonly PinnedFile[];
|
|
307
348
|
/**
|
|
308
349
|
* The credential guard's script revisions, each with the arithmetic library its port follows
|
|
309
350
|
* (ports.rs `HOOK_SCRIPT_SHA256`, `HOOK_COMPANION_SHA256` and `COMPANION_SCRIPT_BINDINGS`): the
|
|
@@ -420,6 +461,8 @@ export declare function stableEngineCommand(command: string, windows: boolean):
|
|
|
420
461
|
* `changed_files_on`, checked by `guard_refusal_in` before any member): missing, not a regular
|
|
421
462
|
* file or another revision, or the credential guard's script and library not a bound pair. The
|
|
422
463
|
* Codex adapter is read on Codex only;
|
|
464
|
+
* - a claimed guard script present at a revision its native member does not answer for
|
|
465
|
+
* (`PRE_TOOL_USE_CLAIMED_SCRIPT_PINS`, pre_tool_use_master.rs `unmodelled_claimed_scripts`);
|
|
423
466
|
* - the policy enforcement gate beside the hook-lib.sh its revision accepts (the injector runs it
|
|
424
467
|
* on Bash calls whatever the registry lists), as for PostToolUse;
|
|
425
468
|
* - the policy-frontmatter evaluator scripts;
|
|
@@ -1748,13 +1748,92 @@ export function uncoveredHooks(root, host, event, covers, env = process.env) {
|
|
|
1748
1748
|
if (hold)
|
|
1749
1749
|
missing.push(`(native SessionStart compatibility: ${hold})`);
|
|
1750
1750
|
}
|
|
1751
|
+
if (host === 'fleet-local' && event === 'PreToolUse' && covered.includes('fleet-local-adapter:PreToolUse')) {
|
|
1752
|
+
const hold = fleetLocalPreToolUseHold(root);
|
|
1753
|
+
if (hold)
|
|
1754
|
+
missing.push(`(native PreToolUse compatibility: ${hold})`);
|
|
1755
|
+
}
|
|
1751
1756
|
if (host === 'agents-v2' && event === 'PreToolUse' && covered.includes('agents-v2-adapter:PreToolUse')) {
|
|
1752
1757
|
const hold = sessionStartHold(root);
|
|
1753
1758
|
if (hold)
|
|
1754
1759
|
missing.push(`(native PreToolUse compatibility: ${hold})`);
|
|
1755
1760
|
}
|
|
1761
|
+
if ((host === 'fleet-local' || host === 'agents-v2')
|
|
1762
|
+
&& event === 'PreToolUse'
|
|
1763
|
+
&& hooks.includes('merged-write-guard-shadow')
|
|
1764
|
+
&& covered.includes('merged-write-guard-shadow')) {
|
|
1765
|
+
const hold = fleetLocalMergedWriteGuardHold(root);
|
|
1766
|
+
if (hold)
|
|
1767
|
+
missing.push(`(native merged-write-guard-shadow compatibility: ${hold})`);
|
|
1768
|
+
}
|
|
1756
1769
|
return missing;
|
|
1757
1770
|
}
|
|
1771
|
+
/**
|
|
1772
|
+
* The two script revision sets the native `merged-write-guard-shadow` port rebuilds:
|
|
1773
|
+
* legacy (`v16.0.48-beta.109`, constants in `crates/hq-hook/src/merged_write_guard.rs`) and
|
|
1774
|
+
* released (`v16.0.49` / `v16.0.50`, constants in `crates/hq-hook/src/merged_write_guard/release_1649.rs`
|
|
1775
|
+
* plus `Revision::Beta124` in `crates/hq-hook/src/block_core_writes.rs`).
|
|
1776
|
+
*/
|
|
1777
|
+
export const MERGED_WRITE_GUARD_PINS_LEGACY = [
|
|
1778
|
+
['.claude/hooks/merged-write-guard-shadow.sh', '63ddff4a40e861d8d922b0701863259a3cedbffaf6d44a94d837865e62cca6ac'],
|
|
1779
|
+
['.claude/hooks/merged-write-guard-shadow.cjs', '225e5c89501ab87965db46e6520c0fd8d08ec5e9745068a2e7324e64f7360884'],
|
|
1780
|
+
['.claude/hooks/block-core-writes.sh', 'e6c14f48c38bd01ed0f2120fd7c18022fd7dd0dac18ed09f2307414a5646932f'],
|
|
1781
|
+
['.claude/hooks/block-core-writes-bash.sh', '1c52342ab3030c1ee5540341dd1c8f6dbe7721c300d900c4947d98f1407638b2'],
|
|
1782
|
+
['core/hooks/PreToolUse/10-Edit,Write,MultiEdit--block-repo-edits-use-worktree.sh', 'c4c0786ff75ef466f3cd6068e3d54b3fd68c3e3cfabb98debfe1de770523526c'],
|
|
1783
|
+
['core/scripts/hook-lib.sh', 'df3d8ddc15a0c179227c9ba7f855c040973fcee249673156d08b2e2ff2c850b8'],
|
|
1784
|
+
];
|
|
1785
|
+
export const MERGED_WRITE_GUARD_PINS_1649 = [
|
|
1786
|
+
['.claude/hooks/merged-write-guard-shadow.sh', '742870a2ada4f9357320f7708fca7363be6d81fde374948b59873c327a7d7206'],
|
|
1787
|
+
['.claude/hooks/merged-write-guard-shadow.cjs', '6f65f2b9425612f9b2ec2590dace82585230210dcd69a124a9cdeb0116ea7f30'],
|
|
1788
|
+
['.claude/hooks/block-core-writes.sh', 'a39061417bf31cf251c661ebc3e5bc87ee1bb2424a0552d2aeb266eec3d29fcc'],
|
|
1789
|
+
['.claude/hooks/block-core-writes-bash.sh', '0b4ce070ef18595bd8ee794e2f364720854170a63eb0eb5999e135ada4d1b497'],
|
|
1790
|
+
['core/hooks/PreToolUse/10-Edit,Write,MultiEdit--block-repo-edits-use-worktree.sh', 'c4c0786ff75ef466f3cd6068e3d54b3fd68c3e3cfabb98debfe1de770523526c'],
|
|
1791
|
+
['core/scripts/hook-lib.sh', '9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f'],
|
|
1792
|
+
];
|
|
1793
|
+
/**
|
|
1794
|
+
* Why `merged-write-guard-shadow` must stay on the shell registration in `root`: the wrapper
|
|
1795
|
+
* script is present on disk and either the wrapper or one of its companion scripts does not match
|
|
1796
|
+
* the pinned revision set that `crates/hq-hook/src/merged_write_guard.rs` rebuilds.
|
|
1797
|
+
*/
|
|
1798
|
+
export function fleetLocalMergedWriteGuardHold(root) {
|
|
1799
|
+
const wrapperRel = '.claude/hooks/merged-write-guard-shadow.sh';
|
|
1800
|
+
const wrapperFile = path.join(root, wrapperRel);
|
|
1801
|
+
let wrapperBytes;
|
|
1802
|
+
try {
|
|
1803
|
+
if (!fs.statSync(wrapperFile).isFile())
|
|
1804
|
+
return `unreadable merged-write-guard-shadow file ${wrapperRel}`;
|
|
1805
|
+
wrapperBytes = fs.readFileSync(wrapperFile);
|
|
1806
|
+
}
|
|
1807
|
+
catch (err) {
|
|
1808
|
+
if (err?.code === 'ENOENT')
|
|
1809
|
+
return null;
|
|
1810
|
+
return `unreadable merged-write-guard-shadow file ${wrapperRel}`;
|
|
1811
|
+
}
|
|
1812
|
+
const wrapperSha = createHash('sha256').update(wrapperBytes).digest('hex');
|
|
1813
|
+
const pins = wrapperSha === MERGED_WRITE_GUARD_PINS_1649[0][1]
|
|
1814
|
+
? MERGED_WRITE_GUARD_PINS_1649
|
|
1815
|
+
: wrapperSha === MERGED_WRITE_GUARD_PINS_LEGACY[0][1]
|
|
1816
|
+
? MERGED_WRITE_GUARD_PINS_LEGACY
|
|
1817
|
+
: null;
|
|
1818
|
+
if (!pins)
|
|
1819
|
+
return `unmodeled merged-write-guard-shadow file ${wrapperRel}`;
|
|
1820
|
+
for (const [relative, sha] of pins.slice(1)) {
|
|
1821
|
+
let bytes;
|
|
1822
|
+
try {
|
|
1823
|
+
const file = path.join(root, relative);
|
|
1824
|
+
if (!fs.statSync(file).isFile())
|
|
1825
|
+
return `unreadable merged-write-guard-shadow file ${relative}`;
|
|
1826
|
+
bytes = fs.readFileSync(file);
|
|
1827
|
+
}
|
|
1828
|
+
catch {
|
|
1829
|
+
return `unreadable merged-write-guard-shadow file ${relative}`;
|
|
1830
|
+
}
|
|
1831
|
+
if (createHash('sha256').update(bytes).digest('hex') !== sha) {
|
|
1832
|
+
return `unmodeled merged-write-guard-shadow file ${relative}`;
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
return null;
|
|
1836
|
+
}
|
|
1758
1837
|
/**
|
|
1759
1838
|
* The script revisions the native SessionStart master rebuilds (hq-core v16.0.48 through v16.0.50,
|
|
1760
1839
|
* and the hq-core-staging fd709b39a shim and hq-session.sh):
|
|
@@ -1848,6 +1927,28 @@ export function migratePolicyTriggersHold(root) {
|
|
|
1848
1927
|
}
|
|
1849
1928
|
return null;
|
|
1850
1929
|
}
|
|
1930
|
+
/**
|
|
1931
|
+
* The script revisions the native fleet-local PreToolUse adapter port models (hq-core v16.0.48
|
|
1932
|
+
* through v16.0.50): `host::fleet::local_pre::RELEASED_CORE_SHA256` (`hook-adapter-core.sh`)
|
|
1933
|
+
* and `host::fleet::inherit_scope::RELEASED_LIB_SHA256` (`session-scope-capability.sh`).
|
|
1934
|
+
* `FleetLocalPre` matches the shell adapter when either file is absent (`DISPATCHER_UNAVAILABLE`
|
|
1935
|
+
* / skip scope inheritance), and refuses any other revision present on disk.
|
|
1936
|
+
* `RELEASED_CORE_SHA256` also accepts the two classifying cores of hq-core-staging #2119. This
|
|
1937
|
+
* list accepts only the bd733f7b core, the one the fleet-local parity tests run against, so a
|
|
1938
|
+
* root on a classifying core keeps fleet-local PreToolUse on the shell adapter.
|
|
1939
|
+
*/
|
|
1940
|
+
export const FLEET_LOCAL_PRE_TOOL_USE_PINS = [
|
|
1941
|
+
{ relative: 'core/scripts/lib/hook-adapter-core.sh', accepted: ['940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'], missing: 'allowed' },
|
|
1942
|
+
{ relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead'], missing: 'allowed' },
|
|
1943
|
+
];
|
|
1944
|
+
/**
|
|
1945
|
+
* Why fleet-local PreToolUse must stay on the shell adapter in `root`: a present file of
|
|
1946
|
+
* [`FLEET_LOCAL_PRE_TOOL_USE_PINS`] cannot be read or is not the pinned revision. Uses the shared
|
|
1947
|
+
* [`pinnedFilesHold`] helper. Null when every present file matches.
|
|
1948
|
+
*/
|
|
1949
|
+
export function fleetLocalPreToolUseHold(root) {
|
|
1950
|
+
return pinnedFilesHold(root, 'fleet-local PreToolUse', FLEET_LOCAL_PRE_TOOL_USE_PINS);
|
|
1951
|
+
}
|
|
1851
1952
|
/**
|
|
1852
1953
|
* The one Codex adapter pair the native Codex SubagentStop is modelled on (hq-core v16.0.47):
|
|
1853
1954
|
* `ADAPTER_RELEASES` and `ADAPTER_CORE_RELEASES` in crates/hq-hook/src/post_hooks/codex.rs.
|
|
@@ -2012,7 +2113,7 @@ export function grokPreToolUseHold(root, shadow) {
|
|
|
2012
2113
|
/**
|
|
2013
2114
|
* The dispatcher files the native PreToolUse master model reproduces, in its check order:
|
|
2014
2115
|
* crates/hq-hook/src/pre_tool_use_master.rs `DISPATCHER_PINS`. master-hook.sh is v16.0.48 (1a2439ae),
|
|
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
|
|
2116
|
+
* v16.0.50 (774bca73), v16.0.49 (d5049d5f), v16.0.51 (443272ef) or v16.0.52 (ab46ebdf, and hq-core-staging #2152's f9a32c25, which only scopes the folder hook limit by event; v16.0.51 plus a PostToolUse-only
|
|
2016
2117
|
* 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
|
|
2017
2118
|
* hq-core-staging fd709b39a ee5e9fe7, and session-id.sh the released 2ebbc508 or the fd709b39a
|
|
2018
2119
|
* d6a04155; every other file is one revision.
|
|
@@ -2043,6 +2144,7 @@ export const PRE_TOOL_USE_DISPATCHER_PINS = [
|
|
|
2043
2144
|
'd5049d5fb38d2b33467d493a4a136df8f6d9021c29e722df0d1e6a17d7f452ab',
|
|
2044
2145
|
'443272ef7642d87b6833bc97b71350502491445cd09b26be9f45140804368b00',
|
|
2045
2146
|
'ab46ebdf0cc84a90dd95a54417817f9f9023b109d5b3710c472a8f5e89061592',
|
|
2147
|
+
'f9a32c25f5984856a1bb91a7914495577e505c42a8c02831acf8faf049a9a806',
|
|
2046
2148
|
],
|
|
2047
2149
|
},
|
|
2048
2150
|
{ relative: '.claude/hooks/turn-timing.sh', accepted: ['97c70a3251225ba9e469e41fd3fe2341cfe2936490f54571d2ca16de8e766443'] },
|
|
@@ -2117,6 +2219,29 @@ export const PRE_TOOL_USE_VAULT_GUARD_PINS = [
|
|
|
2117
2219
|
},
|
|
2118
2220
|
{ relative: '.claude/hooks/enforce-vault-write-access-flag.cjs', accepted: ['87dbddf1867296562ce76096c47869bca5c1a6a262b526421ac96aecfef90c45'] },
|
|
2119
2221
|
];
|
|
2222
|
+
/**
|
|
2223
|
+
* Claimed PreToolUse hooks whose native member answers in place of the root's script with no port
|
|
2224
|
+
* pin of its own, with the script revisions the member answers for: pre_tool_use_master.rs
|
|
2225
|
+
* `CLAIMED_SCRIPT_PINS`, where the native PreToolUse refuses any other present revision. The scope
|
|
2226
|
+
* authorizer: hq-core v16.0.45 to v16.0.52 and the prereleases core-pins.json lists. hq-core
|
|
2227
|
+
* 16.0.53-beta.1 (36312275) adds a PowerShell check the native scope member does not have, so that
|
|
2228
|
+
* root stays on the old dispatcher. A missing script is not held: the native PreToolUse refuses a
|
|
2229
|
+
* registered safety guard that is missing, as master-hook did.
|
|
2230
|
+
*/
|
|
2231
|
+
export const PRE_TOOL_USE_CLAIMED_SCRIPT_PINS = [
|
|
2232
|
+
{
|
|
2233
|
+
relative: '.claude/hooks/mandatory-scope-authorizer.sh',
|
|
2234
|
+
accepted: [
|
|
2235
|
+
'861fc09c36886e167dc837dedc69d78f7a9707f904f962770ce711dddba26083',
|
|
2236
|
+
'de22307449fa4b0a98b379e603b9f9c9aa25cf8ee79127888552695c50a88233',
|
|
2237
|
+
'bebbca28287440c42bf8b61d936e76812440dd6ea84a43a8771d812940af0cf8',
|
|
2238
|
+
'bfe9c24e9aaa6403a83a137326f43ff1eba09acd791ceae232b0b6aed315b6ef',
|
|
2239
|
+
'1b114e78a6f46a534a3cf4cba96b7d0a9ee33683e0976f9968ee0c956abe6482',
|
|
2240
|
+
'23e1ce16f323178623faae664697ea5e38e24834884cacfc0978622dad46f74f',
|
|
2241
|
+
],
|
|
2242
|
+
missing: 'allowed',
|
|
2243
|
+
},
|
|
2244
|
+
];
|
|
2120
2245
|
/**
|
|
2121
2246
|
* The credential guard's script revisions, each with the arithmetic library its port follows
|
|
2122
2247
|
* (ports.rs `HOOK_SCRIPT_SHA256`, `HOOK_COMPANION_SHA256` and `COMPANION_SCRIPT_BINDINGS`): the
|
|
@@ -2360,6 +2485,8 @@ export function stableEngineCommand(command, windows) {
|
|
|
2360
2485
|
* `changed_files_on`, checked by `guard_refusal_in` before any member): missing, not a regular
|
|
2361
2486
|
* file or another revision, or the credential guard's script and library not a bound pair. The
|
|
2362
2487
|
* Codex adapter is read on Codex only;
|
|
2488
|
+
* - a claimed guard script present at a revision its native member does not answer for
|
|
2489
|
+
* (`PRE_TOOL_USE_CLAIMED_SCRIPT_PINS`, pre_tool_use_master.rs `unmodelled_claimed_scripts`);
|
|
2363
2490
|
* - the policy enforcement gate beside the hook-lib.sh its revision accepts (the injector runs it
|
|
2364
2491
|
* on Bash calls whatever the registry lists), as for PostToolUse;
|
|
2365
2492
|
* - the policy-frontmatter evaluator scripts;
|
|
@@ -2387,6 +2514,7 @@ export function preToolUseHold(root, host, hooks = []) {
|
|
|
2387
2514
|
return pinnedFilesHold(root, 'PreToolUse', files)
|
|
2388
2515
|
?? (host === 'codex' ? codexExecFormSettingsHold(root, 'PreToolUse') : null)
|
|
2389
2516
|
?? pinnedFilesHold(root, 'PreToolUse', PRE_TOOL_USE_VAULT_GUARD_PINS)
|
|
2517
|
+
?? pinnedFilesHold(root, 'PreToolUse', PRE_TOOL_USE_CLAIMED_SCRIPT_PINS)
|
|
2390
2518
|
?? pinnedFilesHold(root, 'PreToolUse', [
|
|
2391
2519
|
{ relative: CREDENTIAL_GUARD, accepted: [...new Set(credential.map(([script]) => script))] },
|
|
2392
2520
|
{ relative: CREDENTIAL_ARITH_LIB, accepted: [...new Set(credential.map(([, lib]) => lib))] },
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
import { writeFile, mkdir } from "node:fs/promises";
|
|
15
15
|
import { join, dirname } from "node:path";
|
|
16
16
|
import { VaultClient, VaultConflictError, VaultNotFoundError, resolveEntityContext, sync, parseToken, } from "@indigoai-us/hq-cloud";
|
|
17
|
+
import { withCompanySessions } from "../company-sessions.js";
|
|
18
|
+
import { companySessionsForCommand } from "../company-sessions-cli.js";
|
|
17
19
|
import { PersonCreationError, CompanyCreationError, ProvisioningError, MembershipBootstrapError, StsVerifyError, InviteAcceptError, FirstSyncError, } from "./errors.js";
|
|
18
20
|
import { readCheckpoint, writeCheckpoint, isStepComplete, deleteCheckpoint, CHECKPOINT_VERSION, } from "./checkpoint.js";
|
|
19
21
|
// ---------------------------------------------------------------------------
|
|
@@ -406,11 +408,11 @@ export async function joinCompanyFlow(input, config, onProgress, { resumed = fal
|
|
|
406
408
|
if (!isStepComplete(checkpoint, "first-sync")) {
|
|
407
409
|
emit(onProgress, "first-sync", "running");
|
|
408
410
|
try {
|
|
409
|
-
await sync({
|
|
411
|
+
await sync(withCompanySessions({
|
|
410
412
|
company: checkpoint.companyUid,
|
|
411
413
|
hqRoot: config.hqRoot,
|
|
412
414
|
vaultConfig: config.vaultConfig,
|
|
413
|
-
});
|
|
415
|
+
}, await companySessionsForCommand(config.hqRoot, true)));
|
|
414
416
|
checkpoint.completedSteps.push("first-sync");
|
|
415
417
|
await writeCheckpoint(config.hqRoot, checkpoint);
|
|
416
418
|
emit(onProgress, "first-sync", "done");
|
|
@@ -24,7 +24,9 @@ export declare function syncCoreUnitId(vaultUid: string): string;
|
|
|
24
24
|
export { isSyncCoreVaultUid } from "./vault-uid.js";
|
|
25
25
|
export declare function engineConfigToml(vault: SyncCoreVault, hqRoot: string, phase: SyncCoreVaultPhase, tokenPath?: string,
|
|
26
26
|
/** The engine release this vault runs. Not given: treated as an engine that still counts requests. */
|
|
27
|
-
release?: string
|
|
27
|
+
release?: string,
|
|
28
|
+
/** This account's `prs_` person uid, the only `sessions/<uid>/` folder a company vault uploads. Omitted when not a valid uid. */
|
|
29
|
+
personUid?: string): string;
|
|
28
30
|
export interface WriteEngineHomeOptions {
|
|
29
31
|
home: string;
|
|
30
32
|
hqRoot: string;
|
|
@@ -34,6 +36,8 @@ export interface WriteEngineHomeOptions {
|
|
|
34
36
|
platform?: NodeJS.Platform;
|
|
35
37
|
/** The engine release this vault runs; decides whether the config carries `requests_per_day`. */
|
|
36
38
|
release?: string;
|
|
39
|
+
/** This account's `prs_` person uid, written as `sync.person_uid`. */
|
|
40
|
+
personUid?: string;
|
|
37
41
|
}
|
|
38
42
|
export declare function writeEngineHome(opts: WriteEngineHomeOptions): {
|
|
39
43
|
engineHome: string;
|
|
@@ -2,6 +2,7 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { parse as parseToml } from "smol-toml";
|
|
4
4
|
import { compareSyncCoreReleases } from "./release-compare.js";
|
|
5
|
+
import { isPersonUid } from "./vault-uid.js";
|
|
5
6
|
import { CLIENT_HEALTH_MAX_SYNC_ENGINE_COUNT, } from "../../utils/client-health-contract.js";
|
|
6
7
|
export const SYNC_CORE_REQUESTS_PER_DAY = 20_000;
|
|
7
8
|
// The first engine release with no daily request count; it ignores `requests_per_day`.
|
|
@@ -15,7 +16,9 @@ export function syncCoreUnitId(vaultUid) {
|
|
|
15
16
|
export { isSyncCoreVaultUid } from "./vault-uid.js";
|
|
16
17
|
export function engineConfigToml(vault, hqRoot, phase, tokenPath,
|
|
17
18
|
/** The engine release this vault runs. Not given: treated as an engine that still counts requests. */
|
|
18
|
-
release
|
|
19
|
+
release,
|
|
20
|
+
/** This account's `prs_` person uid, the only `sessions/<uid>/` folder a company vault uploads. Omitted when not a valid uid. */
|
|
21
|
+
personUid) {
|
|
19
22
|
// Engines before the removal fall back to 10,000 a day when the line is missing.
|
|
20
23
|
// A release that is not a plain vX.Y.Z (a pre-release, a mislabelled marker) keeps the line too.
|
|
21
24
|
const countsRequests = release === undefined ||
|
|
@@ -30,6 +33,7 @@ release) {
|
|
|
30
33
|
`hq_root = ${JSON.stringify(hqRoot)}`,
|
|
31
34
|
...(countsRequests ? [`requests_per_day = ${SYNC_CORE_REQUESTS_PER_DAY}`] : []),
|
|
32
35
|
...(tokenPath ? [`token_path = ${JSON.stringify(tokenPath)}`] : []),
|
|
36
|
+
...(isPersonUid(personUid) ? [`person_uid = ${JSON.stringify(personUid)}`] : []),
|
|
33
37
|
];
|
|
34
38
|
if (vault.kind === "company") {
|
|
35
39
|
lines.push("[sync.roots]", `${vault.uid} = ${JSON.stringify(`companies/${vault.slug}`)}`);
|
|
@@ -79,7 +83,7 @@ export function writeEngineHome(opts) {
|
|
|
79
83
|
replaceSymlink(path.join(hq, "work-mesh"), path.join(opts.home, ".hq", "work-mesh"));
|
|
80
84
|
replaceSymlink(path.join(hq, "cognito-tokens.json"), opts.tokenFile);
|
|
81
85
|
}
|
|
82
|
-
const configChanged = writeIfChanged(path.join(root, "config.toml"), engineConfigToml(opts.vault, opts.hqRoot, opts.phase, windows ? opts.tokenFile : undefined, opts.release));
|
|
86
|
+
const configChanged = writeIfChanged(path.join(root, "config.toml"), engineConfigToml(opts.vault, opts.hqRoot, opts.phase, windows ? opts.tokenFile : undefined, opts.release, opts.personUid));
|
|
83
87
|
const ownedPath = path.join(root, "owned", `${opts.vault.uid}.json`);
|
|
84
88
|
let ownedChanged = false;
|
|
85
89
|
if (opts.phase === "full") {
|
|
@@ -15,6 +15,11 @@ export interface SyncCoreReconcileDeps {
|
|
|
15
15
|
companiesOnly: boolean;
|
|
16
16
|
listMemberships: () => Promise<SyncCoreMembership[]>;
|
|
17
17
|
resolvePersonUid: () => Promise<string | null>;
|
|
18
|
+
/**
|
|
19
|
+
* This account's person uid from the local cache, used for `sync.person_uid` when
|
|
20
|
+
* resolvePersonUid is not called or fails. Omitted: no cached uid.
|
|
21
|
+
*/
|
|
22
|
+
cachedPersonUid?: () => string | null;
|
|
18
23
|
readRolloutFlag: (companyUid: string) => Promise<boolean>;
|
|
19
24
|
/**
|
|
20
25
|
* The company's parallel download stream count from the flag registry, or
|
|
@@ -6,6 +6,7 @@ import { engineOwnsVault } from "./hand-back.js";
|
|
|
6
6
|
import { clearEngineStatus, engineFirstCycle, isSyncCoreVaultUid, removeEngineOwnership, syncCoreEngineHome, writeEngineHome, } from "./engine-home.js";
|
|
7
7
|
import { SYNC_CORE_FULL_RELEASE, SYNC_CORE_RELEASE, compareSyncCoreReleases, fullModeAllowed, installedSyncCoreRelease, syncCoreBinaryPath, windowsFullRelease, } from "./release.js";
|
|
8
8
|
import { readSyncCoreSkips } from "./skip.js";
|
|
9
|
+
import { isPersonUid } from "./vault-uid.js";
|
|
9
10
|
import { isLiveCompanyEntity, joinedCompanySlug, setUpJoinedCompany } from "./company-adoption.js";
|
|
10
11
|
import { heldDeletesHandoverLine, heldLocalBodiesHandoverLine, readEngineHeldDeletes, readEngineHeldLocalBodies, writeHandbackKeep } from "./engine-holds.js";
|
|
11
12
|
import { dropStaleLegacyJournalExport, legacyJournalDirs, legacyJournalExportState, markLegacyJournalExportStale, removeLegacyJournalExport, writeLegacyJournalExport, } from "./legacy-journal-export.js";
|
|
@@ -204,6 +205,7 @@ export async function reconcileSyncCore(deps) {
|
|
|
204
205
|
desired.push(company);
|
|
205
206
|
}
|
|
206
207
|
}
|
|
208
|
+
let sessionPersonUid = null;
|
|
207
209
|
if (!deps.companiesOnly && anyCompanyOn) {
|
|
208
210
|
let personUid = null;
|
|
209
211
|
try {
|
|
@@ -216,6 +218,15 @@ export async function reconcileSyncCore(deps) {
|
|
|
216
218
|
}
|
|
217
219
|
if (personUid)
|
|
218
220
|
desired.push({ uid: personUid, kind: "personal" });
|
|
221
|
+
sessionPersonUid = personUid;
|
|
222
|
+
}
|
|
223
|
+
if (!isPersonUid(sessionPersonUid)) {
|
|
224
|
+
try {
|
|
225
|
+
sessionPersonUid = deps.cachedPersonUid?.() ?? null;
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
sessionPersonUid = null;
|
|
229
|
+
}
|
|
219
230
|
}
|
|
220
231
|
let skips;
|
|
221
232
|
try {
|
|
@@ -296,7 +307,16 @@ export async function reconcileSyncCore(deps) {
|
|
|
296
307
|
if (!before)
|
|
297
308
|
clearEngineStatus(deps.home, vault.uid);
|
|
298
309
|
const dropFailed = !before && !pending && !dropLegacyJournalExport(deps.home, vault, warnings);
|
|
299
|
-
writeEngineHome({
|
|
310
|
+
writeEngineHome({
|
|
311
|
+
home: deps.home,
|
|
312
|
+
hqRoot: deps.hqRoot,
|
|
313
|
+
vault,
|
|
314
|
+
phase: "full",
|
|
315
|
+
tokenFile: deps.tokenFile,
|
|
316
|
+
platform,
|
|
317
|
+
release: engineRelease,
|
|
318
|
+
...(isPersonUid(sessionPersonUid) ? { personUid: sessionPersonUid } : {}),
|
|
319
|
+
});
|
|
300
320
|
const wasFull = before?.phase === "full";
|
|
301
321
|
const alreadyOff = vault.kind === "personal"
|
|
302
322
|
? switchesBefore.personalOff
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export function isSyncCoreVaultUid(value) {
|
|
2
2
|
return typeof value === "string" && /^(prs|cmp)_[A-Za-z0-9][A-Za-z0-9_-]*$/.test(value);
|
|
3
3
|
}
|
|
4
|
+
export const PERSON_UID_PATTERN = /^prs_[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
5
|
+
export function isPersonUid(value) {
|
|
6
|
+
return typeof value === "string" && PERSON_UID_PATTERN.test(value);
|
|
7
|
+
}
|
|
4
8
|
//# sourceMappingURL=vault-uid.js.map
|
|
@@ -2,10 +2,28 @@ export interface DelegateLockOptions {
|
|
|
2
2
|
now?: () => number;
|
|
3
3
|
startOf?: (pid: number) => string | null;
|
|
4
4
|
alive?: (pid: number) => boolean;
|
|
5
|
+
platform?: NodeJS.Platform;
|
|
5
6
|
}
|
|
6
7
|
export interface DelegateLock {
|
|
7
8
|
release(): void;
|
|
8
9
|
}
|
|
10
|
+
export type DelegateLockFailureReason = 'busy' | 'identity-unavailable' | 'error';
|
|
11
|
+
export type DelegateLockResult = {
|
|
12
|
+
ok: true;
|
|
13
|
+
lock: DelegateLock;
|
|
14
|
+
} | {
|
|
15
|
+
ok: false;
|
|
16
|
+
reason: DelegateLockFailureReason;
|
|
17
|
+
timedOut?: boolean;
|
|
18
|
+
detail?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function formatDelegateLockError(failure: Extract<DelegateLockResult, {
|
|
21
|
+
ok: false;
|
|
22
|
+
}>): string;
|
|
23
|
+
/** A complete owner file is linked into place atomically. Legacy mkdir writers
|
|
24
|
+
* see EEXIST; unknown legacy directories stay held. Returns a structured result
|
|
25
|
+
* so callers can tell a held lock apart from a probe timeout or I/O error. */
|
|
26
|
+
export declare function acquireDelegateLockDetailed(lock: string, options?: DelegateLockOptions): DelegateLockResult;
|
|
9
27
|
/** A complete owner file is linked into place atomically. Legacy mkdir writers
|
|
10
28
|
* see EEXIST; unknown legacy directories stay held. */
|
|
11
29
|
export declare function acquireDelegateLock(lock: string, options?: DelegateLockOptions): DelegateLock | null;
|