@gamaze/hicortex 0.26.3 → 0.27.0
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/README.md +7 -2
- package/dist/backfill-privacy.d.ts +82 -0
- package/dist/backfill-privacy.js +193 -0
- package/dist/classification.d.ts +153 -0
- package/dist/classification.js +265 -0
- package/dist/classify-domains.js +24 -7
- package/dist/cli.js +31 -0
- package/dist/cluster.d.ts +15 -8
- package/dist/cluster.js +10 -3
- package/dist/consolidate.d.ts +31 -2
- package/dist/consolidate.js +193 -40
- package/dist/db.js +26 -1
- package/dist/dedup.d.ts +5 -3
- package/dist/dedup.js +26 -12
- package/dist/distill-queue.d.ts +25 -1
- package/dist/distill-queue.js +47 -7
- package/dist/graph.d.ts +28 -3
- package/dist/graph.js +46 -4
- package/dist/init.d.ts +18 -9
- package/dist/init.js +111 -81
- package/dist/mcp-server.js +186 -32
- package/dist/nightly.js +33 -7
- package/dist/recall-index.d.ts +19 -9
- package/dist/recall-index.js +14 -4
- package/dist/recall-precision.js +3 -1
- package/dist/reconsolidation.d.ts +10 -0
- package/dist/reconsolidation.js +80 -17
- package/dist/redact.d.ts +9 -1
- package/dist/redact.js +32 -1
- package/dist/rescore-importance.js +21 -4
- package/dist/retrieval.d.ts +23 -6
- package/dist/retrieval.js +41 -15
- package/dist/seed-lesson.js +3 -1
- package/dist/storage.d.ts +23 -4
- package/dist/storage.js +38 -9
- package/dist/type-classify.js +22 -7
- package/dist/types.d.ts +81 -15
- package/dist/uninstall.js +6 -5
- package/hermes-plugin/hicortex/README.md +4 -0
- package/hermes-plugin/hicortex/client.py +36 -9
- package/hermes-plugin/hicortex/plugin.yaml +1 -1
- package/hermes-plugin/hicortex/provider.py +28 -6
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/init.js
CHANGED
|
@@ -53,6 +53,7 @@ exports.resolveNightlyHour = resolveNightlyHour;
|
|
|
53
53
|
exports.formatOnCalendarLines = formatOnCalendarLines;
|
|
54
54
|
exports.formatLaunchdIntervals = formatLaunchdIntervals;
|
|
55
55
|
exports.formatSystemdTimerBody = formatSystemdTimerBody;
|
|
56
|
+
exports.removeCaptureWatchdogTimer = removeCaptureWatchdogTimer;
|
|
56
57
|
exports.installConsolidationTimer = installConsolidationTimer;
|
|
57
58
|
const paths_js_1 = require("./paths.js");
|
|
58
59
|
const localhost_bypass_js_1 = require("./localhost-bypass.js");
|
|
@@ -1894,12 +1895,12 @@ async function runInit(options = {}) {
|
|
|
1894
1895
|
console.log(` ✓ Agent name set to '${decision.value}'`);
|
|
1895
1896
|
}
|
|
1896
1897
|
}
|
|
1897
|
-
// Install the scheduling
|
|
1898
|
-
//
|
|
1899
|
-
//
|
|
1900
|
-
//
|
|
1901
|
-
// via
|
|
1902
|
-
|
|
1898
|
+
// Install the scheduling timer: the CONSOLIDATION timer (full nightly — its
|
|
1899
|
+
// capture phase IS the capture mechanism; #596 retired the separate capture
|
|
1900
|
+
// watchdog as obsolete since the distill queue #529). A leftover watchdog
|
|
1901
|
+
// unit from a 0.17–0.26 install is removed so re-init never resurrects it;
|
|
1902
|
+
// customize the consolidation slots via consolidationHours in config.json.
|
|
1903
|
+
removeCaptureWatchdogTimer();
|
|
1903
1904
|
installConsolidationTimer(resolveConsolidationHours("server") ?? DEFAULT_CONSOLIDATION_HOURS);
|
|
1904
1905
|
// Install daemon if needed
|
|
1905
1906
|
if (!d.localServer && !d.remoteServer) {
|
|
@@ -2122,11 +2123,14 @@ async function runClientInit(serverUrl, agentName) {
|
|
|
2122
2123
|
if ((0, claude_md_js_1.removeLessonsBlock)(claudeMdPath)) {
|
|
2123
2124
|
console.log(` ✓ Removed old static lessons block from CLAUDE.md — lessons now injected at session start`);
|
|
2124
2125
|
}
|
|
2125
|
-
// Step 7:
|
|
2126
|
-
//
|
|
2127
|
-
//
|
|
2128
|
-
//
|
|
2129
|
-
|
|
2126
|
+
// Step 7: Scheduling cleanup — clients have no local DB → no consolidation
|
|
2127
|
+
// timer. Remove the RETIRED capture watchdog (#596 — obsolete since the
|
|
2128
|
+
// distill queue #529) and any legacy full-nightly timer a pre-0.17 install
|
|
2129
|
+
// left behind, so re-init never resurrects either. Client capture runs
|
|
2130
|
+
// whenever `hicortex nightly` fires on the machine (the nightly's capture
|
|
2131
|
+
// phase; no separate capture timer exists — see the #596 note for the
|
|
2132
|
+
// stock-npx-client scheduling story).
|
|
2133
|
+
removeCaptureWatchdogTimer();
|
|
2130
2134
|
removeConsolidationTimer();
|
|
2131
2135
|
// Step 8: Setup Hermes if detected
|
|
2132
2136
|
if ((0, node_fs_1.existsSync)(HERMES_HOME)) {
|
|
@@ -2172,30 +2176,30 @@ async function runClientInit(serverUrl, agentName) {
|
|
|
2172
2176
|
console.log("Restart your agents to activate.");
|
|
2173
2177
|
}
|
|
2174
2178
|
/**
|
|
2175
|
-
* Scheduling
|
|
2176
|
-
*
|
|
2179
|
+
* Scheduling: ONE scheduled unit — the CONSOLIDATION timer
|
|
2180
|
+
* (`hicortex-nightly`): full `nightly` (capture + distill + score + reflect +
|
|
2181
|
+
* link). Server/co-located ONLY — clients have no local DB, so no
|
|
2182
|
+
* consolidation timer is installed (and a legacy one left by a pre-0.17
|
|
2183
|
+
* install is removed). Fixed slots (default [10, 22]).
|
|
2177
2184
|
*
|
|
2178
|
-
*
|
|
2179
|
-
*
|
|
2180
|
-
*
|
|
2181
|
-
*
|
|
2182
|
-
*
|
|
2183
|
-
*
|
|
2184
|
-
*
|
|
2185
|
-
*
|
|
2186
|
-
*
|
|
2187
|
-
*
|
|
2188
|
-
*
|
|
2189
|
-
* distill + score + reflect + link). Server/co-located ONLY — clients have
|
|
2190
|
-
* no local DB, so no consolidation timer is installed (and a legacy one
|
|
2191
|
-
* left by a pre-0.17 install is removed). Fixed slots (default [10, 22]).
|
|
2185
|
+
* The CAPTURE WATCHDOG (`hicortex-capture`, 0.17 #239 — a short-interval
|
|
2186
|
+
* timer firing `nightly --capture-only --watchdog`) is RETIRED (#596): since
|
|
2187
|
+
* the distill queue (#529) distillation runs on the server's scheduled drains
|
|
2188
|
+
* regardless of when captures arrive, the watchdog only shortened
|
|
2189
|
+
* inbox-arrival latency, which nothing consumes. init no longer generates or
|
|
2190
|
+
* enables `hicortex-capture` units and instead REMOVES a leftover pair from a
|
|
2191
|
+
* 0.17–0.26 install (so an old install is cleaned by its next init, and a
|
|
2192
|
+
* re-init can never resurrect the unit). The watchdog's latent self-seed
|
|
2193
|
+
* failure (a unit replaced mid-boot keeps a stale OnBootSec anchor and never
|
|
2194
|
+
* elapses again) dies with it — if a timer of this shape is ever rebuilt for a
|
|
2195
|
+
* real need, anchor it with OnActiveSec, not OnBootSec.
|
|
2192
2196
|
*
|
|
2193
|
-
* Customize: `consolidationHours` (the consolidation slots)
|
|
2194
|
-
*
|
|
2195
|
-
*
|
|
2196
|
-
*
|
|
2197
|
-
*
|
|
2198
|
-
*
|
|
2197
|
+
* Customize: `consolidationHours` (the consolidation slots) in config.json.
|
|
2198
|
+
* Re-init rewrites the timer to the resolved standard (the pre-0.17 "never
|
|
2199
|
+
* overwrite" contract is intentionally relaxed so the fleet adopts the
|
|
2200
|
+
* standard). The legacy single `nightlyHour` is honoured as a one-slot
|
|
2201
|
+
* consolidation fallback only when `consolidationHours` is absent (preserves
|
|
2202
|
+
* "one daily job at H").
|
|
2199
2203
|
*/
|
|
2200
2204
|
const DEFAULT_CONSOLIDATION_HOURS = [10, 22];
|
|
2201
2205
|
/**
|
|
@@ -2248,19 +2252,8 @@ function randomMinuteOffset(jitterSec, rand = Math.random) {
|
|
|
2248
2252
|
return Math.floor(rand() * (max + 1));
|
|
2249
2253
|
}
|
|
2250
2254
|
/**
|
|
2251
|
-
*
|
|
2252
|
-
*
|
|
2253
|
-
* by the success-cooldown (`captureCooldownHours`, read at runtime). Short so a
|
|
2254
|
-
* transient fire-instant network miss retries in minutes, not at the next daily
|
|
2255
|
-
* slot (#239). Cheap: a tick against a down server is one 5s preflight.
|
|
2256
|
-
*/
|
|
2257
|
-
const CAPTURE_WATCHDOG_INTERVAL_MIN = 20;
|
|
2258
|
-
/**
|
|
2259
|
-
* Resolve the CONSOLIDATION hours (the only slot-based timer in 0.17). The
|
|
2260
|
-
* CAPTURE mechanism is the watchdog (an interval timer, not slots) — uniform
|
|
2261
|
-
* across client + server/co-located — so this function no longer returns a
|
|
2262
|
-
* capture schedule. Returns null in client mode (no local DB → no
|
|
2263
|
-
* consolidation timer).
|
|
2255
|
+
* Resolve the CONSOLIDATION hours (the only scheduled timer). Returns null in
|
|
2256
|
+
* client mode (no local DB → no consolidation timer).
|
|
2264
2257
|
*
|
|
2265
2258
|
* Priority: `consolidationHours` array → legacy `nightlyHour` (single int, only
|
|
2266
2259
|
* when the array key is absent → one consolidation slot at H, preserving the
|
|
@@ -2336,10 +2329,11 @@ function formatLaunchdIntervals(hours, minuteOffset = 0) {
|
|
|
2336
2329
|
}
|
|
2337
2330
|
/**
|
|
2338
2331
|
* The systemd `[Timer]` body (everything between `[Timer]` and the next stanza).
|
|
2339
|
-
* Exported for testing the #256 jitter line. `isInterval` selects the
|
|
2340
|
-
* poll form (OnBootSec + OnUnitActiveSec
|
|
2341
|
-
*
|
|
2342
|
-
*
|
|
2332
|
+
* Exported for testing the #256 jitter line. `isInterval` selects the interval
|
|
2333
|
+
* poll form (OnBootSec + OnUnitActiveSec — no current caller since the capture
|
|
2334
|
+
* watchdog retired, #596); otherwise one `OnCalendar` line per hour. When
|
|
2335
|
+
* `jitterSec > 0` a single `RandomizedDelaySec=<n>` is appended — it applies to
|
|
2336
|
+
* every OnCalendar entry AND to OnUnitActiveSec (systemd semantics).
|
|
2343
2337
|
*/
|
|
2344
2338
|
function formatSystemdTimerBody(isInterval, intervalSec, hours, jitterSec) {
|
|
2345
2339
|
const base = isInterval
|
|
@@ -2350,10 +2344,11 @@ function formatSystemdTimerBody(isInterval, intervalSec, hours, jitterSec) {
|
|
|
2350
2344
|
}
|
|
2351
2345
|
/**
|
|
2352
2346
|
* Write + enable one schedule unit (timer + service on Linux, plist on macOS),
|
|
2353
|
-
* multi-slot.
|
|
2354
|
-
*
|
|
2355
|
-
*
|
|
2356
|
-
* edited unit files).
|
|
2347
|
+
* multi-slot. Used by the consolidation installer (the only generated unit
|
|
2348
|
+
* since the capture watchdog retired, #596). Always rewrites both files (the
|
|
2349
|
+
* 0.17 migration decision: re-init brings an install up to the resolved
|
|
2350
|
+
* standard; customization is via config keys, not hand-edited unit files).
|
|
2351
|
+
* Logs the resolved slots.
|
|
2357
2352
|
*/
|
|
2358
2353
|
function writeScheduleUnit(opts) {
|
|
2359
2354
|
const binaryArgs = resolveBinaryArgs();
|
|
@@ -2380,18 +2375,18 @@ function writeScheduleUnit(opts) {
|
|
|
2380
2375
|
const programArgs = [...binaryArgs, ...opts.nightlyArgs]
|
|
2381
2376
|
.map((a) => ` <string>${a}</string>`)
|
|
2382
2377
|
.join("\n");
|
|
2383
|
-
// Schedule block: StartInterval (seconds) for
|
|
2378
|
+
// Schedule block: StartInterval (seconds) for an interval poll (no current
|
|
2379
|
+
// caller — the capture watchdog that used it is retired, #596), or
|
|
2384
2380
|
// StartCalendarInterval as an ARRAY of dicts (one per hour) for slots.
|
|
2385
|
-
// RunAtLoad ONLY on the interval
|
|
2386
|
-
//
|
|
2387
|
-
//
|
|
2388
|
-
// if a capture ran recently.
|
|
2381
|
+
// RunAtLoad ONLY on the interval plist — so a Mac that reboots gets a first
|
|
2382
|
+
// tick on load (~parity with systemd's OnBootSec=2min), not one interval
|
|
2383
|
+
// later; a cooldown gate would make a load-time fire a cheap no-op.
|
|
2389
2384
|
//
|
|
2390
2385
|
// #256 — jitter: launchd has no native RandomizedDelaySec, so the slot
|
|
2391
2386
|
// plist bakes a per-install randomized Minute offset into every dict
|
|
2392
|
-
// (generated here, stable across reboots). The interval
|
|
2393
|
-
//
|
|
2394
|
-
//
|
|
2387
|
+
// (generated here, stable across reboots). The interval plist keeps its
|
|
2388
|
+
// StartInterval untouched — interval timers drift naturally and don't
|
|
2389
|
+
// share the fixed-slot thundering-herd risk.
|
|
2395
2390
|
const jitterSec = opts.jitterSec ?? resolveTimerJitterSeconds();
|
|
2396
2391
|
const minuteOffset = !isInterval ? randomMinuteOffset(jitterSec) : 0;
|
|
2397
2392
|
const scheduleBlock = isInterval
|
|
@@ -2452,7 +2447,7 @@ StandardError=append:${logPath}
|
|
|
2452
2447
|
Environment=PATH=${supervisorPath}
|
|
2453
2448
|
Environment=HOME=${(0, node_os_1.homedir)()}
|
|
2454
2449
|
WorkingDirectory=${(0, node_os_1.homedir)()}`;
|
|
2455
|
-
// Timer body: OnUnitActiveSec (interval
|
|
2450
|
+
// Timer body: OnUnitActiveSec (interval poll) or one OnCalendar line
|
|
2456
2451
|
// per hour (multi-slot). systemd ORs multiple OnCalendar entries.
|
|
2457
2452
|
// #256 — a single RandomizedDelaySec=<jitterSec> applies to all entries.
|
|
2458
2453
|
const jitterSec = opts.jitterSec ?? resolveTimerJitterSeconds();
|
|
@@ -2483,23 +2478,58 @@ WantedBy=timers.target`;
|
|
|
2483
2478
|
}
|
|
2484
2479
|
}
|
|
2485
2480
|
/**
|
|
2486
|
-
*
|
|
2487
|
-
*
|
|
2488
|
-
*
|
|
2489
|
-
*
|
|
2490
|
-
*
|
|
2491
|
-
*
|
|
2481
|
+
* Remove the CAPTURE WATCHDOG timer (retired, #596 — obsolete since the
|
|
2482
|
+
* distill queue #529: distillation runs on the server's scheduled drains, so
|
|
2483
|
+
* shortening capture-arrival latency served nothing; see the scheduling doc
|
|
2484
|
+
* above, incl. the OnActiveSec note if a timer of this shape is ever rebuilt).
|
|
2485
|
+
* Stops + deletes a `hicortex-capture` timer/service pair (or the macOS plist)
|
|
2486
|
+
* left by a 0.17–0.26 install, so an old install is cleaned by its next init
|
|
2487
|
+
* and a re-init can never resurrect the unit. Fail-soft: nothing installed →
|
|
2488
|
+
* silent no-op. Exported for the #596 retirement tests.
|
|
2492
2489
|
*/
|
|
2493
|
-
function
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2490
|
+
function removeCaptureWatchdogTimer() {
|
|
2491
|
+
const os = (0, node_os_1.platform)();
|
|
2492
|
+
if (os === "darwin") {
|
|
2493
|
+
const plistPath = (0, node_path_1.join)((0, node_os_1.homedir)(), "Library", "LaunchAgents", "com.gamaze.hicortex-capture.plist");
|
|
2494
|
+
if ((0, node_fs_1.existsSync)(plistPath)) {
|
|
2495
|
+
try {
|
|
2496
|
+
(0, node_child_process_1.execSync)(`launchctl unload ${plistPath} 2>/dev/null`, { stdio: "pipe" });
|
|
2497
|
+
}
|
|
2498
|
+
catch { /* not loaded */ }
|
|
2499
|
+
try {
|
|
2500
|
+
(0, node_fs_1.rmSync)(plistPath);
|
|
2501
|
+
console.log(" ✓ Removed retired capture watchdog timer (#596)");
|
|
2502
|
+
}
|
|
2503
|
+
catch { /* leave it */ }
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
else if (os === "linux") {
|
|
2507
|
+
// Stop before delete — a live timer keeps firing against a half-removed
|
|
2508
|
+
// unit. Unconditional + swallowed: a fresh install has nothing to disable.
|
|
2509
|
+
try {
|
|
2510
|
+
(0, node_child_process_1.execSync)("systemctl --user disable --now hicortex-capture.timer 2>/dev/null", { stdio: "pipe" });
|
|
2511
|
+
}
|
|
2512
|
+
catch { /* not installed */ }
|
|
2513
|
+
const unitDir = (0, node_path_1.join)((0, node_os_1.homedir)(), ".config", "systemd", "user");
|
|
2514
|
+
let removed = false;
|
|
2515
|
+
for (const name of ["hicortex-capture.timer", "hicortex-capture.service"]) {
|
|
2516
|
+
const p = (0, node_path_1.join)(unitDir, name);
|
|
2517
|
+
if ((0, node_fs_1.existsSync)(p)) {
|
|
2518
|
+
try {
|
|
2519
|
+
(0, node_fs_1.rmSync)(p);
|
|
2520
|
+
removed = true;
|
|
2521
|
+
}
|
|
2522
|
+
catch { /* leave it */ }
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
if (removed) {
|
|
2526
|
+
try {
|
|
2527
|
+
(0, node_child_process_1.execSync)("systemctl --user daemon-reload 2>/dev/null", { stdio: "pipe" });
|
|
2528
|
+
}
|
|
2529
|
+
catch { /* fine */ }
|
|
2530
|
+
console.log(" ✓ Removed retired capture watchdog timer (#596)");
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2503
2533
|
}
|
|
2504
2534
|
/**
|
|
2505
2535
|
* Install the CONSOLIDATION timer (full `nightly`). Reuses the existing
|
|
@@ -2563,8 +2593,8 @@ function warnSystemdDropInShadow(unitBase, derivedTimeoutMin) {
|
|
|
2563
2593
|
/**
|
|
2564
2594
|
* Remove the consolidation timer + service (and the macOS plist). Used on
|
|
2565
2595
|
* CLIENT installs: clients have no local DB, so a pre-0.17 `hicortex-nightly`
|
|
2566
|
-
* timer (which auto-capture-onlys on clients) is redundant with the
|
|
2567
|
-
*
|
|
2596
|
+
* timer (which auto-capture-onlys on clients) is redundant with the nightly
|
|
2597
|
+
* their host already runs — remove it so it doesn't double-fire.
|
|
2568
2598
|
*/
|
|
2569
2599
|
function removeConsolidationTimer() {
|
|
2570
2600
|
const os = (0, node_os_1.platform)();
|