@indigoai-us/hq-cli 5.345.257 → 5.345.260
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 +31 -0
- package/assets/scaffold/core/scripts/handoff-knowledge-commit.sh +163 -5
- 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 +6 -30
- 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-handoff.js +57 -14
- package/dist/commands/keyed-sync-pull.d.ts +7 -3
- package/dist/commands/keyed-sync-pull.js +90 -22
- 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/checks/replay-recorder.js +3 -3
- 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/flag-snapshot-file.d.ts +47 -1
- package/dist/lib/flag-snapshot-file.js +143 -20
- package/dist/lib/hook-engine/coverage.d.ts +115 -7
- package/dist/lib/hook-engine/coverage.js +280 -10
- package/dist/lib/mesh/live/company-flag-refresh.js +2 -2
- 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/sync-operation-lock.d.ts +2 -1
- package/dist/utils/sync-operation-lock.js +13 -2
- package/package.json +8 -8
|
@@ -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.
|
|
@@ -2046,7 +2147,13 @@ export const PRE_TOOL_USE_DISPATCHER_PINS = [
|
|
|
2046
2147
|
],
|
|
2047
2148
|
},
|
|
2048
2149
|
{ relative: '.claude/hooks/turn-timing.sh', accepted: ['97c70a3251225ba9e469e41fd3fe2341cfe2936490f54571d2ca16de8e766443'] },
|
|
2049
|
-
{
|
|
2150
|
+
{
|
|
2151
|
+
relative: 'core/scripts/hook-lib.sh',
|
|
2152
|
+
accepted: [
|
|
2153
|
+
'9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f',
|
|
2154
|
+
'436493e3325fb0cbcad651ae8ef42d89f4adf43fe38abd938ed6a39c0b6d17c1',
|
|
2155
|
+
],
|
|
2156
|
+
},
|
|
2050
2157
|
{ relative: 'core/scripts/hq-anywhere-runtime-flag.cjs', accepted: ['8a484cef83d383b440462798ac13e26d132e10bbe509b47e0eb1a3d0db76b2b4'] },
|
|
2051
2158
|
{ relative: 'core/scripts/hqd-hook-flag-cache-lib.sh', accepted: ['061d264460408e9eaf43fdf0fdde662c906a9a7dacb4e7a591e684bca28c138a'] },
|
|
2052
2159
|
{ relative: 'core/scripts/hqd-hook-shim.sh', accepted: ['ab289ac0af680fe3bcacb110302ca8b998bdc33c6f94321d42bd04a344163eed', 'ee5e9fe729eb7e51f87b5f90cdc020be865f5b6b35ac0b5758587546b35715c0'] },
|
|
@@ -2074,7 +2181,14 @@ export const PRE_TOOL_USE_CLAUDE_DISPATCHER_PINS = [
|
|
|
2074
2181
|
},
|
|
2075
2182
|
];
|
|
2076
2183
|
export const PRE_TOOL_USE_CODEX_DISPATCHER_PINS = [
|
|
2077
|
-
{
|
|
2184
|
+
{
|
|
2185
|
+
relative: 'core/scripts/lib/hook-adapter-core.sh',
|
|
2186
|
+
accepted: [
|
|
2187
|
+
'940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5',
|
|
2188
|
+
RELEASED_CLASSIFYING_ADAPTER_CORE_SHA256,
|
|
2189
|
+
CLASSIFYING_ADAPTER_CORE_SHA256,
|
|
2190
|
+
],
|
|
2191
|
+
},
|
|
2078
2192
|
];
|
|
2079
2193
|
/** The Codex adapter the model reproduces on Codex only (pre_tool_use_master.rs `CODEX_ADAPTER_PIN`). */
|
|
2080
2194
|
export const PRE_TOOL_USE_CODEX_ADAPTER_PIN = {
|
|
@@ -2104,11 +2218,34 @@ export const PRE_TOOL_USE_VAULT_GUARD_PINS = [
|
|
|
2104
2218
|
},
|
|
2105
2219
|
{ relative: '.claude/hooks/enforce-vault-write-access-flag.cjs', accepted: ['87dbddf1867296562ce76096c47869bca5c1a6a262b526421ac96aecfef90c45'] },
|
|
2106
2220
|
];
|
|
2221
|
+
/**
|
|
2222
|
+
* Claimed PreToolUse hooks whose native member answers in place of the root's script with no port
|
|
2223
|
+
* pin of its own, with the script revisions the member answers for: pre_tool_use_master.rs
|
|
2224
|
+
* `CLAIMED_SCRIPT_PINS`, where the native PreToolUse refuses any other present revision. The scope
|
|
2225
|
+
* authorizer: hq-core v16.0.45 to v16.0.52 and the prereleases core-pins.json lists. hq-core
|
|
2226
|
+
* 16.0.53-beta.1 (36312275) adds a PowerShell check the native scope member does not have, so that
|
|
2227
|
+
* root stays on the old dispatcher. A missing script is not held: the native PreToolUse refuses a
|
|
2228
|
+
* registered safety guard that is missing, as master-hook did.
|
|
2229
|
+
*/
|
|
2230
|
+
export const PRE_TOOL_USE_CLAIMED_SCRIPT_PINS = [
|
|
2231
|
+
{
|
|
2232
|
+
relative: '.claude/hooks/mandatory-scope-authorizer.sh',
|
|
2233
|
+
accepted: [
|
|
2234
|
+
'861fc09c36886e167dc837dedc69d78f7a9707f904f962770ce711dddba26083',
|
|
2235
|
+
'de22307449fa4b0a98b379e603b9f9c9aa25cf8ee79127888552695c50a88233',
|
|
2236
|
+
'bebbca28287440c42bf8b61d936e76812440dd6ea84a43a8771d812940af0cf8',
|
|
2237
|
+
'bfe9c24e9aaa6403a83a137326f43ff1eba09acd791ceae232b0b6aed315b6ef',
|
|
2238
|
+
'1b114e78a6f46a534a3cf4cba96b7d0a9ee33683e0976f9968ee0c956abe6482',
|
|
2239
|
+
'23e1ce16f323178623faae664697ea5e38e24834884cacfc0978622dad46f74f',
|
|
2240
|
+
],
|
|
2241
|
+
missing: 'allowed',
|
|
2242
|
+
},
|
|
2243
|
+
];
|
|
2107
2244
|
/**
|
|
2108
2245
|
* The credential guard's script revisions, each with the arithmetic library its port follows
|
|
2109
2246
|
* (ports.rs `HOOK_SCRIPT_SHA256`, `HOOK_COMPANION_SHA256` and `COMPANION_SCRIPT_BINDINGS`): the
|
|
2110
|
-
* 16.0.48 script 6512581d
|
|
2111
|
-
* other revision only with 0566180c.
|
|
2247
|
+
* 16.0.48 script 6512581d, its 16.0.51-beta.44 successor 5064061f and the 16.0.52 script e8f19ecc
|
|
2248
|
+
* only with e90d160f, every other revision only with 0566180c.
|
|
2112
2249
|
*/
|
|
2113
2250
|
export const PRE_TOOL_USE_CREDENTIAL_GUARD_GENERATIONS = [
|
|
2114
2251
|
['25f5507cc97bfe700a8505f59463b4f42280c60d4733110c0a5faabb87cda4f3', '0566180ce52bed559d57a08247bf39c8ec1cec6b7e271da496d0c09077fc6f57'],
|
|
@@ -2117,6 +2254,7 @@ export const PRE_TOOL_USE_CREDENTIAL_GUARD_GENERATIONS = [
|
|
|
2117
2254
|
['30015cbcae48b7227d3e271dd73235b2eac8d7b86955ac653d30ca3c377bc599', '0566180ce52bed559d57a08247bf39c8ec1cec6b7e271da496d0c09077fc6f57'],
|
|
2118
2255
|
['6512581d1200558d4ef78dfb11eca4a92f663042c6b0b11b2e6664762139e2a0', 'e90d160fed02cbcf7e33aed679233af5a9cf9f9a87dd979aba04493a37c00ec8'],
|
|
2119
2256
|
['5064061fd64da6d56c0c974c0719f6729b23dba9ab1a768e1ba70d5a9645c8ae', 'e90d160fed02cbcf7e33aed679233af5a9cf9f9a87dd979aba04493a37c00ec8'],
|
|
2257
|
+
['e8f19eccc25adfb1aa51a4d24de29714f700001a31abc21537682ee8635c76cb', 'e90d160fed02cbcf7e33aed679233af5a9cf9f9a87dd979aba04493a37c00ec8'],
|
|
2120
2258
|
];
|
|
2121
2259
|
const CREDENTIAL_GUARD = '.claude/hooks/block-credential-file-read.sh';
|
|
2122
2260
|
const CREDENTIAL_ARITH_LIB = '.claude/hooks/bash-arith-subst-guard-lib.sh';
|
|
@@ -2155,7 +2293,8 @@ const MERGED_WRITE_HELPER = '.claude/hooks/merged-write-guard-shadow.cjs';
|
|
|
2155
2293
|
* sha256 picks the set and never refuses by itself: the v16.0.49 wrapper (742870a2) picks
|
|
2156
2294
|
* `released`, any other wrapper `legacy`. In a set the helper .cjs, when listed, must match; each
|
|
2157
2295
|
* guard may be missing (bash exits 127) but not another revision; hook-lib.sh is read only once a
|
|
2158
|
-
* guard is on its pin, and must then be the set's
|
|
2296
|
+
* guard is on its pin, and must then be one of the set's libraries (the released set also takes the
|
|
2297
|
+
* v16.0.52 library 436493e3).
|
|
2159
2298
|
*/
|
|
2160
2299
|
export const MERGED_WRITE_GUARD_SETS = {
|
|
2161
2300
|
releasedWrapper: '742870a2ada4f9357320f7708fca7363be6d81fde374948b59873c327a7d7206',
|
|
@@ -2166,7 +2305,7 @@ export const MERGED_WRITE_GUARD_SETS = {
|
|
|
2166
2305
|
['.claude/hooks/block-core-writes.sh', 'a39061417bf31cf251c661ebc3e5bc87ee1bb2424a0552d2aeb266eec3d29fcc'],
|
|
2167
2306
|
['core/hooks/PreToolUse/10-Edit,Write,MultiEdit--block-repo-edits-use-worktree.sh', 'c4c0786ff75ef466f3cd6068e3d54b3fd68c3e3cfabb98debfe1de770523526c'],
|
|
2168
2307
|
],
|
|
2169
|
-
|
|
2308
|
+
hookLibs: ['9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f', '436493e3325fb0cbcad651ae8ef42d89f4adf43fe38abd938ed6a39c0b6d17c1'],
|
|
2170
2309
|
},
|
|
2171
2310
|
legacy: {
|
|
2172
2311
|
helper: null,
|
|
@@ -2175,7 +2314,7 @@ export const MERGED_WRITE_GUARD_SETS = {
|
|
|
2175
2314
|
['.claude/hooks/block-core-writes.sh', 'e6c14f48c38bd01ed0f2120fd7c18022fd7dd0dac18ed09f2307414a5646932f'],
|
|
2176
2315
|
['core/hooks/PreToolUse/10-Edit,Write,MultiEdit--block-repo-edits-use-worktree.sh', 'c4c0786ff75ef466f3cd6068e3d54b3fd68c3e3cfabb98debfe1de770523526c'],
|
|
2177
2316
|
],
|
|
2178
|
-
|
|
2317
|
+
hookLibs: ['df3d8ddc15a0c179227c9ba7f855c040973fcee249673156d08b2e2ff2c850b8'],
|
|
2179
2318
|
},
|
|
2180
2319
|
};
|
|
2181
2320
|
/** The sha256 of `relative` under `root`, or null when it is not a regular file or cannot be read. */
|
|
@@ -2210,7 +2349,132 @@ export function mergedWriteGuardHold(root, event) {
|
|
|
2210
2349
|
return guards;
|
|
2211
2350
|
if (!set.guards.some(([relative]) => regularFile(path.join(root, relative))))
|
|
2212
2351
|
return null;
|
|
2213
|
-
return pinnedFilesHold(root, event, [{ relative: HOOK_LIB, accepted: [set.
|
|
2352
|
+
return pinnedFilesHold(root, event, [{ relative: HOOK_LIB, accepted: [...set.hookLibs] }]);
|
|
2353
|
+
}
|
|
2354
|
+
/**
|
|
2355
|
+
* Why a Codex `event` must stay on the shell adapter in `root`: `.claude/settings.json` holds an
|
|
2356
|
+
* entry of that event with a non-empty `args` list (the exec form, which `hq reindex` and the
|
|
2357
|
+
* update healer write for the engine launcher). The adapter library may run such an entry as
|
|
2358
|
+
* master-hook (`hqad_classify_exec`), which the native work does not model, so the native
|
|
2359
|
+
* PreToolUse refuses every Codex tool call on such a root, whatever the tool or the entry's
|
|
2360
|
+
* matcher (pre_tool_use_master.rs `codex_exec_refusal`). Without this hold `hq reindex` would
|
|
2361
|
+
* switch the event onto that refusal, as for `codexSubagentStopHold`.
|
|
2362
|
+
*
|
|
2363
|
+
* The engine's own registration for this root is not such an entry ([`engineOwnExecEntry`]):
|
|
2364
|
+
* `hq reindex` writes it into this file for Claude Code when the new core is on, the native
|
|
2365
|
+
* PreToolUse models what the adapter did with it (fleet_settings.rs `engine_own_master`), and a
|
|
2366
|
+
* hold on it would undo reindex's own switch on the next run.
|
|
2367
|
+
*
|
|
2368
|
+
* The walk is the one in crates/hq-hook/src/host/fleet_settings.rs `unsupported_exec_form_entry`:
|
|
2369
|
+
* the event's slot and each group's `hooks` are a list's items or an object's values, as the
|
|
2370
|
+
* adapter's jq query walks them. The hold is wider than the run-time refusal in two ways, both of
|
|
2371
|
+
* which only keep the event on the shell adapter: it does not ask whether master-hook.sh and
|
|
2372
|
+
* hook-adapter-core.sh are present (without either the engine is idle before it reads the
|
|
2373
|
+
* settings; the pinned-file hold already keeps such a root), and it reads the file with
|
|
2374
|
+
* `JSON.parse`, which accepts a few files serde_json rejects (invalid UTF-8 read with replacement
|
|
2375
|
+
* characters, a lone surrogate escape, nesting deeper than 128), where the engine reads no
|
|
2376
|
+
* entry. A file that is absent or that `JSON.parse` rejects holds no such entry. Null when there
|
|
2377
|
+
* is none.
|
|
2378
|
+
*/
|
|
2379
|
+
export function codexExecFormSettingsHold(root, event) {
|
|
2380
|
+
let settings;
|
|
2381
|
+
try {
|
|
2382
|
+
settings = JSON.parse(fs.readFileSync(path.join(root, '.claude', 'settings.json'), 'utf8'));
|
|
2383
|
+
}
|
|
2384
|
+
catch {
|
|
2385
|
+
return null;
|
|
2386
|
+
}
|
|
2387
|
+
const field = (value, key) => value !== null && typeof value === 'object' && !Array.isArray(value) ? value[key] : undefined;
|
|
2388
|
+
const values = (value) => Array.isArray(value) ? value : value !== null && typeof value === 'object' ? Object.values(value) : [];
|
|
2389
|
+
const exec = values(field(field(settings, 'hooks'), event)).some((group) => values(field(group, 'hooks')).some((entry) => {
|
|
2390
|
+
const args = field(entry, 'args');
|
|
2391
|
+
return Array.isArray(args) && args.length > 0 && !engineOwnExecEntry(entry, root, event);
|
|
2392
|
+
}));
|
|
2393
|
+
return exec ? `unmodeled ${event} settings entry in .claude/settings.json (exec form)` : null;
|
|
2394
|
+
}
|
|
2395
|
+
/**
|
|
2396
|
+
* Whether `entry` is the registration `hq reindex` writes for `event` on this root when the new
|
|
2397
|
+
* core is on. Three tests, each the one the adapter library's `hqad_classify_exec` makes before it
|
|
2398
|
+
* gives the entry a master record, so no entry is exempt here that the library reads another way:
|
|
2399
|
+
* - a `command` entry whose arguments are exactly `run --host <host> <event> --hq-root <root>`, the
|
|
2400
|
+
* host a plain word;
|
|
2401
|
+
* - the command is the release-stable hq-hook as the library tests it ([`stableEngineCommand`]). A
|
|
2402
|
+
* command that only contains the stable segment somewhere is not one;
|
|
2403
|
+
* - the root value is absolute and names this root ([`ownRootValue`]).
|
|
2404
|
+
*
|
|
2405
|
+
* This is narrower than [`isCoreNextEntry`], which registration uses to find its entries: every
|
|
2406
|
+
* entry this accepts, that accepts. crates/hq-hook/src/host/fleet_settings.rs `engine_own_entry` is
|
|
2407
|
+
* the same three tests, statement for statement.
|
|
2408
|
+
*/
|
|
2409
|
+
export function engineOwnExecEntry(entry, root, event, windows = process.platform === 'win32') {
|
|
2410
|
+
if (entry === null || typeof entry !== 'object' || Array.isArray(entry))
|
|
2411
|
+
return false;
|
|
2412
|
+
const { type, command, args } = entry;
|
|
2413
|
+
if (type !== 'command' || typeof command !== 'string')
|
|
2414
|
+
return false;
|
|
2415
|
+
if (!Array.isArray(args) || args.length !== 6 || !args.every((arg) => typeof arg === 'string'))
|
|
2416
|
+
return false;
|
|
2417
|
+
const [run, flag, host, slot, rootFlag, value] = args;
|
|
2418
|
+
return run === 'run' && flag === '--host' && /^[a-z][a-z0-9-]*$/.test(host) && slot === event && rootFlag === '--hq-root'
|
|
2419
|
+
&& ownRootValue(value, root, windows) && stableEngineCommand(command, windows);
|
|
2420
|
+
}
|
|
2421
|
+
/**
|
|
2422
|
+
* Whether a `--hq-root` value names `root`. The value must be absolute (`/...`, or on Windows a
|
|
2423
|
+
* drive path; a `\\?\` verbatim path or a UNC path is not one) and, trailing separators aside,
|
|
2424
|
+
* every name in it must be a plain name: no `.`, `..` or empty segment. The separators are `/`, and
|
|
2425
|
+
* `\` on Windows only (elsewhere a backslash is part of a name). It then names the root when it is
|
|
2426
|
+
* the root's spelling, trailing separators aside, or when the operating system resolves it to the
|
|
2427
|
+
* same folder as the root (`fs.realpathSync.native`, which is realpath(3), or
|
|
2428
|
+
* `GetFinalPathNameByHandle` on Windows). Refusing `.` and `..` before resolving means no value
|
|
2429
|
+
* depends on whether `..` is applied before or after a link. fleet_settings.rs `own_root_value` is
|
|
2430
|
+
* the same function, resolving with `Path::canonicalize`; both answer
|
|
2431
|
+
* crates/hq-hook/tests/fixtures/engine-own-entry/cases.json.
|
|
2432
|
+
*/
|
|
2433
|
+
export function ownRootValue(value, root, windows) {
|
|
2434
|
+
const drive = /^[A-Za-z]:[\\/]/.test(value);
|
|
2435
|
+
if (!(value.startsWith('/') || (windows && drive)))
|
|
2436
|
+
return false;
|
|
2437
|
+
const trailing = windows ? /[\\/]+$/ : /\/+$/;
|
|
2438
|
+
const trimmed = value.replace(trailing, '');
|
|
2439
|
+
const body = windows && drive ? trimmed.slice(2) : trimmed;
|
|
2440
|
+
const names = body.slice(1);
|
|
2441
|
+
if (names === '' || names.split(windows ? /[\\/]/ : /\//).some((name) => name === '' || name === '.' || name === '..'))
|
|
2442
|
+
return false;
|
|
2443
|
+
if (trimmed === root.replace(trailing, ''))
|
|
2444
|
+
return true;
|
|
2445
|
+
try {
|
|
2446
|
+
return normalizeRealpath(fs.realpathSync.native(value)) === normalizeRealpath(fs.realpathSync.native(root));
|
|
2447
|
+
}
|
|
2448
|
+
catch {
|
|
2449
|
+
return false;
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
/** A resolved path without the `\\?\` prefix Node adds on Windows for long paths, so both sides compare alike. */
|
|
2453
|
+
function normalizeRealpath(resolved) {
|
|
2454
|
+
return resolved.startsWith('\\\\?\\') ? resolved.slice(4) : resolved;
|
|
2455
|
+
}
|
|
2456
|
+
/**
|
|
2457
|
+
* The command tests of `hqad_classify_exec` for the stable link, with `cygpath` present on Windows
|
|
2458
|
+
* (`windows`) and absent elsewhere: an absolute path with no `.`, `..` or empty segment whose
|
|
2459
|
+
* first `.hq/bin/hq-hook/` is followed by `stable/` and an engine binary name. A Windows drive path
|
|
2460
|
+
* is read with its separators swapped, and only when it is written with one kind of separator.
|
|
2461
|
+
* fleet_settings.rs `stable_engine_command`.
|
|
2462
|
+
*/
|
|
2463
|
+
export function stableEngineCommand(command, windows) {
|
|
2464
|
+
const drive = /^[A-Za-z]:[\\/]/.test(command);
|
|
2465
|
+
if (drive && windows && command.includes('/') && command.includes('\\'))
|
|
2466
|
+
return false;
|
|
2467
|
+
const posix = drive && windows ? `/${command.slice(0, 1).toLowerCase()}${command.slice(2).replaceAll('\\', '/')}` : command;
|
|
2468
|
+
if (!posix.startsWith('/'))
|
|
2469
|
+
return false;
|
|
2470
|
+
const closed = `${posix}/`;
|
|
2471
|
+
if (['/../', '/./', '//'].some((part) => closed.includes(part)))
|
|
2472
|
+
return false;
|
|
2473
|
+
const marker = '/.hq/bin/hq-hook/';
|
|
2474
|
+
const at = posix.indexOf(marker);
|
|
2475
|
+
if (at < 0)
|
|
2476
|
+
return false;
|
|
2477
|
+
return ['stable/hq-hook', 'stable/hq-hook.exe', 'stable/hq-hook.app/Contents/MacOS/hq-hook'].includes(posix.slice(at + marker.length));
|
|
2214
2478
|
}
|
|
2215
2479
|
/**
|
|
2216
2480
|
* Why PreToolUse must stay on the old dispatcher in `root` on `host` once `master-hook:PreToolUse`
|
|
@@ -2220,12 +2484,16 @@ export function mergedWriteGuardHold(root, event) {
|
|
|
2220
2484
|
* `changed_files_on`, checked by `guard_refusal_in` before any member): missing, not a regular
|
|
2221
2485
|
* file or another revision, or the credential guard's script and library not a bound pair. The
|
|
2222
2486
|
* Codex adapter is read on Codex only;
|
|
2487
|
+
* - a claimed guard script present at a revision its native member does not answer for
|
|
2488
|
+
* (`PRE_TOOL_USE_CLAIMED_SCRIPT_PINS`, pre_tool_use_master.rs `unmodelled_claimed_scripts`);
|
|
2223
2489
|
* - the policy enforcement gate beside the hook-lib.sh its revision accepts (the injector runs it
|
|
2224
2490
|
* on Bash calls whatever the registry lists), as for PostToolUse;
|
|
2225
2491
|
* - the policy-frontmatter evaluator scripts;
|
|
2226
2492
|
* - the merged-write-guard-shadow companions, where the registry lists that row;
|
|
2227
|
-
* - on Claude Code, the image rule's script
|
|
2228
|
-
*
|
|
2493
|
+
* - on Claude Code, the image rule's script;
|
|
2494
|
+
* - on Codex, a `.claude/settings.json` PreToolUse entry in the exec form
|
|
2495
|
+
* ([`codexExecFormSettingsHold`]).
|
|
2496
|
+
* Null when the native PreToolUse accepts every file and the settings.
|
|
2229
2497
|
*/
|
|
2230
2498
|
export function preToolUseHold(root, host, hooks = []) {
|
|
2231
2499
|
const files = host === 'codex'
|
|
@@ -2243,7 +2511,9 @@ export function preToolUseHold(root, host, hooks = []) {
|
|
|
2243
2511
|
return null;
|
|
2244
2512
|
};
|
|
2245
2513
|
return pinnedFilesHold(root, 'PreToolUse', files)
|
|
2514
|
+
?? (host === 'codex' ? codexExecFormSettingsHold(root, 'PreToolUse') : null)
|
|
2246
2515
|
?? pinnedFilesHold(root, 'PreToolUse', PRE_TOOL_USE_VAULT_GUARD_PINS)
|
|
2516
|
+
?? pinnedFilesHold(root, 'PreToolUse', PRE_TOOL_USE_CLAIMED_SCRIPT_PINS)
|
|
2247
2517
|
?? pinnedFilesHold(root, 'PreToolUse', [
|
|
2248
2518
|
{ relative: CREDENTIAL_GUARD, accepted: [...new Set(credential.map(([script]) => script))] },
|
|
2249
2519
|
{ relative: CREDENTIAL_ARITH_LIB, accepted: [...new Set(credential.map(([, lib]) => lib))] },
|
|
@@ -23,7 +23,7 @@ import * as fs from "node:fs";
|
|
|
23
23
|
import * as path from "node:path";
|
|
24
24
|
import { createHqFlagClient as createFlagClient } from "../../flag-client-headers.js";
|
|
25
25
|
import { resolveFlagRegistryEndpoint } from "../../flag-registry-endpoint.js";
|
|
26
|
-
import {
|
|
26
|
+
import { readCurrentFlagSnapshotFile, writeFlagSnapshotFile } from "../../flag-snapshot-file.js";
|
|
27
27
|
import { isNonCloudCompanySlug } from "../../work-context/company-rebind.js";
|
|
28
28
|
import { isWorkContextSessionStateFileName, workContextSessionsDir } from "../../work-context/paths.js";
|
|
29
29
|
import { readSessionState } from "../../work-context/state.js";
|
|
@@ -91,7 +91,7 @@ export function companiesNeedingFlagRefresh(workContextRoot, env, now = () => ne
|
|
|
91
91
|
}
|
|
92
92
|
return [...latest.values()]
|
|
93
93
|
.sort((a, b) => b.at - a.at)
|
|
94
|
-
.filter(({ uid }) =>
|
|
94
|
+
.filter(({ uid }) => readCurrentFlagSnapshotFile(uid, { env, now: nowMs, maxAgeMs: refreshAgeMs }) === null)
|
|
95
95
|
.slice(0, COMPANY_FLAG_REFRESH_MAX_COMPANIES)
|
|
96
96
|
.map(({ uid, slug }) => (slug ? { uid, slug } : { uid }));
|
|
97
97
|
}
|
|
@@ -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
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { type SyncOptions, type SyncResult } from "@indigoai-us/hq-cloud";
|
|
19
19
|
import { type LockHandle } from "@indigoai-us/hq-cloud/operation-lock";
|
|
20
|
+
import { type CompanySessionRetentionOptions } from "../lib/company-sessions.js";
|
|
20
21
|
export interface SyncUnderOperationLockDeps<Options, Result> {
|
|
21
22
|
sync: (options: Options & {
|
|
22
23
|
operationLockAlreadyHeld: true;
|
|
@@ -33,5 +34,5 @@ export declare function syncUnderOperationLock<Options extends {
|
|
|
33
34
|
* The production sync leg: hq-cloud's `sync()` under a lock this process takes
|
|
34
35
|
* itself. Every `hq sync` path in `src/commands/cloud.ts` calls this.
|
|
35
36
|
*/
|
|
36
|
-
export declare function syncLeg(options: SyncOptions): Promise<SyncResult>;
|
|
37
|
+
export declare function syncLeg(options: SyncOptions, resolveCompanySessions?: (hqRoot: string) => Promise<CompanySessionRetentionOptions | undefined>): Promise<SyncResult>;
|
|
37
38
|
//# sourceMappingURL=sync-operation-lock.d.ts.map
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
import { sync } from "@indigoai-us/hq-cloud";
|
|
19
19
|
import { acquireOperationLockAsync, } from "@indigoai-us/hq-cloud/operation-lock";
|
|
20
20
|
import { withPackageUseLeaseReleasedDuring } from "./package-use-lease.js";
|
|
21
|
+
import { withCompanySessions } from "../lib/company-sessions.js";
|
|
22
|
+
import { companySessionsForCommand } from "../lib/company-sessions-cli.js";
|
|
21
23
|
export async function syncUnderOperationLock(options, deps) {
|
|
22
24
|
const acquireLock = deps.acquireLock ?? ((hqRoot) => acquireOperationLockAsync(hqRoot, "sync"));
|
|
23
25
|
const withLeaseReleased = deps.withLeaseReleased ??
|
|
@@ -34,7 +36,16 @@ export async function syncUnderOperationLock(options, deps) {
|
|
|
34
36
|
* The production sync leg: hq-cloud's `sync()` under a lock this process takes
|
|
35
37
|
* itself. Every `hq sync` path in `src/commands/cloud.ts` calls this.
|
|
36
38
|
*/
|
|
37
|
-
export function syncLeg(options) {
|
|
38
|
-
|
|
39
|
+
export async function syncLeg(options, resolveCompanySessions = defaultCompanySessions) {
|
|
40
|
+
const companySessions = options.skipReindex === true ? undefined : await resolveCompanySessions(options.hqRoot);
|
|
41
|
+
return syncUnderOperationLock(withCompanySessions(options, companySessions), { sync });
|
|
42
|
+
}
|
|
43
|
+
async function defaultCompanySessions(hqRoot) {
|
|
44
|
+
try {
|
|
45
|
+
return await companySessionsForCommand(hqRoot, true);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
39
50
|
}
|
|
40
51
|
//# sourceMappingURL=sync-operation-lock.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indigoai-us/hq-cli",
|
|
3
|
-
"version": "5.345.
|
|
3
|
+
"version": "5.345.260",
|
|
4
4
|
"description": "HQ by Indigo management CLI — modules and cloud sync",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@aws-sdk/client-iot-data-plane": "^3.1096.0",
|
|
66
66
|
"@aws-sdk/client-s3": "^3.1049.0",
|
|
67
67
|
"@aws-sdk/dsql-signer": "^3.1146.0",
|
|
68
|
-
"@indigoai-us/hq-cloud": "6.18.
|
|
68
|
+
"@indigoai-us/hq-cloud": "6.18.127",
|
|
69
69
|
"@indigoai-us/hq-flags-client": "^0.2.0",
|
|
70
70
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
71
71
|
"@sentry/node": "^10.49.0",
|
|
@@ -128,11 +128,11 @@
|
|
|
128
128
|
"*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}": "eslint --cache --no-error-on-unmatched-pattern"
|
|
129
129
|
},
|
|
130
130
|
"optionalDependencies": {
|
|
131
|
-
"@indigoai-us/hq-hook-win32-x64": "5.345.
|
|
132
|
-
"@indigoai-us/hq-hook-win32-arm64": "5.345.
|
|
133
|
-
"@indigoai-us/hq-hook-darwin-x64": "5.345.
|
|
134
|
-
"@indigoai-us/hq-hook-darwin-arm64": "5.345.
|
|
135
|
-
"@indigoai-us/hq-hook-linux-x64": "5.345.
|
|
136
|
-
"@indigoai-us/hq-hook-linux-arm64": "5.345.
|
|
131
|
+
"@indigoai-us/hq-hook-win32-x64": "5.345.260",
|
|
132
|
+
"@indigoai-us/hq-hook-win32-arm64": "5.345.260",
|
|
133
|
+
"@indigoai-us/hq-hook-darwin-x64": "5.345.260",
|
|
134
|
+
"@indigoai-us/hq-hook-darwin-arm64": "5.345.260",
|
|
135
|
+
"@indigoai-us/hq-hook-linux-x64": "5.345.260",
|
|
136
|
+
"@indigoai-us/hq-hook-linux-arm64": "5.345.260"
|
|
137
137
|
}
|
|
138
138
|
}
|