@gamaze/hicortex 0.24.0 → 0.25.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 +6 -2
- package/assets/dashboard.html +142 -44
- package/dist/calibration.d.ts +21 -0
- package/dist/calibration.js +23 -2
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +32 -0
- package/dist/config-read.d.ts +11 -0
- package/dist/config-read.js +21 -0
- package/dist/distill-queue.d.ts +8 -0
- package/dist/distill-queue.js +7 -2
- package/dist/learnings-identity.d.ts +16 -0
- package/dist/learnings-identity.js +19 -1
- package/dist/llm.d.ts +4 -0
- package/dist/llm.js +23 -4
- package/dist/mcp-server.d.ts +28 -0
- package/dist/mcp-server.js +123 -20
- package/dist/nightly.js +5 -0
- package/dist/project-canonicalize.d.ts +71 -0
- package/dist/project-canonicalize.js +133 -0
- package/dist/recall-index.d.ts +44 -7
- package/dist/recall-index.js +61 -10
- package/dist/reconcile-projects.d.ts +99 -0
- package/dist/reconcile-projects.js +200 -0
- package/dist/types.d.ts +20 -0
- package/package.json +1 -1
- package/server.json +2 -2
package/README.md
CHANGED
|
@@ -259,7 +259,8 @@ Config at `~/.hicortex/config.json`. Created by `init`. Key options:
|
|
|
259
259
|
| `mode` | `"server"` (default) or `"client"` |
|
|
260
260
|
| `serverUrl` | Remote server URL (client mode) |
|
|
261
261
|
| `llmModel` | The one model used by all phases (distill, score, classify, reflect). Set via `init`. |
|
|
262
|
-
| `
|
|
262
|
+
| `llmProvider` | Explicit request dialect for the OpenAI-compatible path. The only recognized value today: `"azure"` — requests send `max_completion_tokens` instead of `max_tokens` (Azure rejects the latter) and never the local-only `chat_template_kwargs` field. Absent/empty → the provider is detected from the base URL; the dialect is never inferred from the URL. |
|
|
263
|
+
| `enableThinking` | Toggle the model's internal reasoning ("thinking") stream for OpenAI-compatible endpoints (default false). Only meaningful for local chat-template-aware servers (ollama, mlx-lm); leave unset for cloud OpenAI/OpenRouter/Groq endpoints (they 400 on the unknown `chat_template_kwargs` field). With `llmProvider: "azure"` the key is ignored (one warning per boot) — always leave it unset there. |
|
|
263
264
|
| `maxTokens` | Max output tokens for all phases (default 8192). A ceiling, not a target — the model stops early when done. |
|
|
264
265
|
| `llmTimeoutMs` | The ONE timeout ceiling on every LLM call in every phase (default 900000 = 15 min). The LLM request paths disable the HTTP client's hidden 5-minute response-header timer, so this knob is the only bound — one place to tune when the endpoint is slow, no per-phase special cases. |
|
|
265
266
|
| `llmProbeTimeoutMs` | Patience of the readiness probe — one minimal 1-token generation request the daemon sends before distilling (default 60000 = 1 min). Catches a gateway that answers health/model-list queries while generation is dead; a failed probe answers `/distill` with a 503 so capture holds its cursor. The nightly no longer probes — its dead-endpoint signal is the circuit breaker (`endpoint_down`, retried next run) |
|
|
@@ -272,12 +273,14 @@ Config at `~/.hicortex/config.json`. Created by `init`. Key options:
|
|
|
272
273
|
| _env_ `HICORTEX_DISTILL_BODY_LIMIT_MB` | Environment override for the `/distill` body limit — **wins over the `distillBodyLimitMb` config key in every mode** (that is the point: a deployment operator pins it so tenant-writable config cannot raise it). Unset = config/default applies. |
|
|
273
274
|
| _env_ `HICORTEX_MEMORY_CAP` | Environment override for the memory soft cap — a **positive** value wins over the `memorySoftCap` config key in every mode; `0`/negative/malformed fall through to the config key, then the 10000 default (an env can pin a cap, never disable one — config `memorySoftCap: 0` still disables when the env is unset). Mode-agnostic operator knob: nightly eviction, the dashboard-snapshot capacity stamp, and the live dashboard gauge all resolve through the same resolver, so the enforced and displayed caps can never disagree. Drives `nightly --evict-only` the same way. |
|
|
274
275
|
| `domains` | Your memory domain list (`[{name, description}]`). Scaffolded by `init`; edit freely — see [Memory Domains & Tags](#memory-domains--tags) |
|
|
276
|
+
| `projectAliases` | Explicit project-label synonyms (`{ "raw": "canonical" }`), applied on top of the automatic case fold (every project string is trimmed + lowercased at every entry point — ingest, distill, search, recall). Single-hop: point every synonym directly at its canonical label. Keys and targets are folded at read (case/whitespace insensitive); an alias cycle rejects the whole map with a warning (mechanical fold still applies); a blank target drops just that entry. **Never scaffolded by `init`** — the map is yours to curate; `hicortex reconcile-projects` (dry run by default, `--apply` after review) renames existing rows to match. Boot-time (restart to apply) |
|
|
275
277
|
| `lessonsLimit` | Max lessons injected into an agent's session-start context (default: 10). Lessons are ranked per session by project/domain affinity + recency + strength + access, so each session sees its most-relevant slice. Lower = leaner system prompts. |
|
|
276
278
|
| `identityClients` | Which harnesses inject the [identity layer](#identity-layer) at session start (default `["cc"]`; `"all"` or any subset of `cc`/`hermes`/`oc`/`pi`/`opencode`) |
|
|
277
279
|
| `identityAgents` | Per-agent identity modes (0.13): `{ "<id>": "override" \| "global" \| "off" }`. Absent + no `agents/<id>/` dir → every agent gets the global set. Boot-time (restart to apply) — see [Per-agent identity](#per-agent-identity-013) |
|
|
278
280
|
| `agentName` | This install's per-agent identity id sent as `?agent=`. **Unset by default** (CC shares the global identity — no `?agent=` sent). Explicit opt-in via `init --agent-name <name>`; `init --agent-name ""` clears it. An empty/whitespace value equals unset |
|
|
279
281
|
| `captureCooldownHours` | Success-cooldown (hours) for the **capture watchdog** (0.17). The capture timer polls every ~20 min; the watchdog captures only if more than this has elapsed since the last *successful* capture (`state.lastNightly`). Default `6` (≈4 captures/day). A failed preflight retries on the next poll (~20 min) — so a transient fire-instant network miss costs minutes, not a day (#239) |
|
|
280
282
|
| `firstRunLookbackDays` | Days of session history the FIRST nightly run discovers (default `7`). A long-term AI user's entire session store is deliberately not distilled on night one — the first watermark is `now − this many days`, not the beginning of time. Already-running installs are unaffected (they have a real watermark). To import more history, run `hicortex nightly --recapture-window <days>` once — widening-only, per-session cursors keep the re-scan cheap. Invalid value → warn + default (#436) |
|
|
283
|
+
| `recallCrossProjectMinSimilarity` | The cross-project recall fence bar (default `0.72`, fence **ON when the key is absent**). When a recall or search request carries a project, a memory from a *different* project must clear this similarity on a measured cosine to be admitted — pushed recall (`/recall-index`), `GET /search`, and the `hicortex_search` tool all fence identically; same-project and unscoped recall are unchanged. `0` or any value ≤ the recall floor (`0.62`) turns the fence off (today's scope-blind behavior). Clamped to `[0,1]`; a wrong type → warn + default. Boot-time (restart to apply) |
|
|
281
284
|
| `consolidationHours` | Hours (0–23, local) for the **consolidation** timer — the full nightly (capture + distill + score + reflect + link). Installed for **server/co-located only** (clients have no local DB). Default `[10, 22]`: the 22:00 evening slot runs after the day's capture waves (same-day results); the 10:00 morning slot runs *after* the morning capture so wake-up pushes are caught. Omitted on clients |
|
|
282
285
|
| `timerJitterSeconds` | Max random delay (seconds) added to **generated** consolidation timers (#256), so a fleet doesn't all fire on the same minute (thundering-herd → LLM-backend contention). systemd: a single `RandomizedDelaySec=<n>`; launchd has no native equivalent so a per-install randomized `Minute` offset is baked into every `StartCalendarInterval` dict (sub-60s values no-op on launchd). Default `3600` (≈±30 min spread on the 2-slot/day cadence); `0` disables. Affects timers on the next `init` (re-init rewrites the unit files; installs that don't re-init keep their existing timers) |
|
|
283
286
|
| `nightlyTimeBudgetMinutes` | The ONE wall-clock budget (minutes) for a nightly run: capture and every consolidation stage share one cooperative deadline, checked at safe boundaries (capture segments, stage boundaries, item loops, the merge zone). A run whose deadline fires reports consolidation `deferred` and resumes from its cursors next run — no work lost, none redone. Default `240`; `0`/invalid → default (a deadline always exists — there is no "off"). The systemd unit's `TimeoutStartSec` is derived from this (+60 min slack) at `init` |
|
|
@@ -287,7 +290,7 @@ Config at `~/.hicortex/config.json`. Created by `init`. Key options:
|
|
|
287
290
|
| `nightlyHour` | **Deprecated (0.17) single-slot fallback.** Local hour (0–23) honoured only when `consolidationHours` is absent — yields one daily consolidation slot at that hour (preserves the pre-0.17 "one daily job" intent). New installs should use `consolidationHours` |
|
|
288
291
|
| `telemetry` | Anonymous usage telemetry. **On by default and not written into config by `init`** — add `"telemetry": false` yourself (or set `HICORTEX_TELEMETRY=off`) to opt out. Inspect exactly what is sent with `hicortex telemetry` |
|
|
289
292
|
|
|
290
|
-
**Calibration is release-managed.** The ~35 tuning keys earlier releases exposed (recall breadth, relevance floors, ranking weights, decay speed, dedup/supersession/correction thresholds, the weak-primary floor) are no longer config: they are constants that ship with each release and change only in releases, with the eval evidence linked in the changelog. Config values for them are ignored — the server prints a one-time boot warning naming each ignored key. Your config file now describes your *install* (mode, model, schedules, identity, budgets), not the brain's tuning.
|
|
293
|
+
**Calibration is release-managed.** The ~35 tuning keys earlier releases exposed (recall breadth, relevance floors, ranking weights, decay speed, dedup/supersession/correction thresholds, the weak-primary floor) are no longer config: they are constants that ship with each release and change only in releases, with the eval evidence linked in the changelog. Config values for them are ignored — the server prints a one-time boot warning naming each ignored key. Your config file now describes your *install* (mode, model, schedules, identity, budgets), not the brain's tuning. The one deliberate exception is `recallCrossProjectMinSimilarity` — on the `firstRunLookbackDays` precedent, it is a per-install posture dial rather than corpus calibration, so it stayed a live config key.
|
|
291
294
|
|
|
292
295
|
**Diagnostic tier (environment).** Three niche, ollama-only operational values moved from config to environment variables: `HICORTEX_NUM_CTX` (context window for ollama, default 8192), `HICORTEX_OLLAMA_FLUSH_EVERY` (flush ollama's accumulated memory every N LLM calls; default 0 = off), and `HICORTEX_OLLAMA_FLUSH_WAIT_MS` (post-flush wait, default 180000). Pin them in a service unit's environment when needed; the old config keys are ignored with a boot warning naming the replacement.
|
|
293
296
|
|
|
@@ -348,6 +351,7 @@ LLM selection is **user-controlled**: `npx @gamaze/hicortex init` detects candid
|
|
|
348
351
|
| Ollama (local) | `llmBackend: "ollama"` | Set by init; no API key needed |
|
|
349
352
|
| Claude CLI | `llmBackend: "claude-cli"` | Uses CC subscription; no API key needed |
|
|
350
353
|
| Custom provider | `llmBaseUrl` + `llmApiKey` | Any OpenAI-compatible endpoint |
|
|
354
|
+
| Azure OpenAI (AI Foundry) | `llmProvider: "azure"` + `llmBaseUrl` + `llmApiKey` (+ `llmModel`) | The OpenAI-compatible path with the Azure dialect: requests carry `max_completion_tokens` (Azure 400s on `max_tokens`) and Bearer auth; `enableThinking` is ignored — leave it unset |
|
|
351
355
|
| Hicortex env vars | `HICORTEX_LLM_BASE_URL` + `HICORTEX_LLM_API_KEY` | Override at runtime |
|
|
352
356
|
|
|
353
357
|
If no LLM is configured, the server starts in **recall-only mode**: search, lessons, and identity work; `/distill` and consolidation are disabled. Run `npx @gamaze/hicortex init` to configure.
|
package/assets/dashboard.html
CHANGED
|
@@ -1032,6 +1032,9 @@
|
|
|
1032
1032
|
#plan-overlay .po-head b{ font-family:var(--serif); font-weight:500; font-size:17px; letter-spacing:.06em; text-transform:uppercase; }
|
|
1033
1033
|
#plan-overlay .po-body{ padding:14px 16px 16px; display:flex; flex-direction:column; gap:10px; }
|
|
1034
1034
|
#plan-overlay .po-current{ font-size:12.5px; color:var(--dim); }
|
|
1035
|
+
/* #411: the currency toggle pill — the site's #cur-toggle idiom (small,
|
|
1036
|
+
accent-bordered pill above the cards). */
|
|
1037
|
+
#plan-overlay .po-cur{ align-self:flex-start; margin:0; padding:3px 12px; font-size:11px; font-weight:700; color:var(--green); background:rgba(61,255,122,0.08); border:1px solid rgba(61,255,122,0.35); border-radius:100px; cursor:pointer; }
|
|
1035
1038
|
.po-opts{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
|
|
1036
1039
|
#acct-options[hidden]{ display:none; } /* author grid beats [hidden] (renderPlanOverlay hides it when a plan is set) */
|
|
1037
1040
|
.po-opt{ background:var(--panel); border:1px solid var(--line2); border-radius:12px; padding:14px 16px 13px; display:flex; flex-direction:column; gap:5px; min-width:0; }
|
|
@@ -1039,6 +1042,13 @@
|
|
|
1039
1042
|
.po-opt .po-price{ font-size:26px; font-weight:640; font-variant-numeric:tabular-nums; letter-spacing:.01em; color:var(--green); }
|
|
1040
1043
|
html:not([data-theme="light"]) .po-opt .po-price{ text-shadow:0 0 12px rgba(61,255,122,.35); }
|
|
1041
1044
|
.po-opt .po-note{ font-size:11px; color:var(--dim); }
|
|
1045
|
+
/* #411 tax wording: the price's tax qualifier renders small + muted next
|
|
1046
|
+
to the amount (the .period idiom of the site's pricing card). */
|
|
1047
|
+
.po-opt .po-price .po-price-x{ font-size:12px; font-weight:500; letter-spacing:0; color:var(--dim); text-shadow:none; }
|
|
1048
|
+
/* #411 tax brief: the USD checkout footnote — small print under the plan
|
|
1049
|
+
cards, shown only while the selected currency is USD (setPlanCur). No
|
|
1050
|
+
display rule of its own, so the UA [hidden] hides it. */
|
|
1051
|
+
#plan-overlay .po-tax{ font-size:11px; color:var(--dim); }
|
|
1042
1052
|
/* what's included (round 3, owner: "NO info on what is included in the
|
|
1043
1053
|
plan") — the marketing site's Cloud feature lines, verbatim, per card. */
|
|
1044
1054
|
.po-opt .po-feat{ list-style:none; margin-top:7px; display:flex; flex-direction:column; gap:3px; }
|
|
@@ -1427,19 +1437,24 @@
|
|
|
1427
1437
|
the dash (not dimmed-partial). × / cover-click / ESC close and return
|
|
1428
1438
|
where the user was. The option cards are GENERATED from the
|
|
1429
1439
|
PLAN_OPTIONS data array (round 3: N-driven — a future plan is a data
|
|
1430
|
-
entry + a router price id, not a page rework); prices
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1440
|
+
entry + a router price id, not a page rework); #411: prices are
|
|
1441
|
+
PER-CURRENCY data (USD + EUR, whole-number mirrors of each other), the
|
|
1442
|
+
included-features bullets stay shared, and both are aligned with the
|
|
1443
|
+
marketing site (lockstep-pinned by tests). The currency toggle pill
|
|
1444
|
+
(#po-cur, the site's #cur-toggle idiom) re-renders the cards, and
|
|
1445
|
+
checkout posts the displayed currency so the charge matches the
|
|
1446
|
+
display. The router deliberately knows only Stripe price ids, so
|
|
1447
|
+
there is no server-side amount to read; the Stripe Checkout page
|
|
1448
|
+
shows the authoritative amount before payment. ============ -->
|
|
1436
1449
|
<div id="plan-overlay" hidden>
|
|
1437
1450
|
<div class="po-cover" id="po-cover"></div>
|
|
1438
1451
|
<div class="po-card" role="dialog" aria-modal="true" aria-labelledby="po-title">
|
|
1439
1452
|
<div class="po-head"><b id="po-title">Plan & billing</b><button class="pm-close" id="po-close" aria-label="Close">✕</button></div>
|
|
1440
1453
|
<div class="po-body">
|
|
1441
1454
|
<div class="po-current" id="po-current"></div>
|
|
1455
|
+
<button id="po-cur" type="button" class="po-cur" aria-label="Toggle currency USD/EUR">$ USD</button>
|
|
1442
1456
|
<div class="po-opts" id="acct-options"></div>
|
|
1457
|
+
<div class="po-tax" id="po-tax" hidden>No sales tax is currently collected. State sales tax or use tax may apply in your state.</div>
|
|
1443
1458
|
</div>
|
|
1444
1459
|
</div>
|
|
1445
1460
|
</div>
|
|
@@ -4614,28 +4629,66 @@ function acctMenuPlan(a) {
|
|
|
4614
4629
|
avatar: ((typeof a.name === "string" && a.name) ? a.name : "?").slice(0, 2).toUpperCase(),
|
|
4615
4630
|
};
|
|
4616
4631
|
}
|
|
4632
|
+
/* #411 — the overlay's currency state (owner rulings 2026-10-12): exactly
|
|
4633
|
+
USD + EUR; the first-visit default follows the browser timezone (an
|
|
4634
|
+
explicit US IANA zone list — exact zones + the Indiana/Kentucky/
|
|
4635
|
+
North_Dakota prefixes — → usd, anything else → eur, ANY error or
|
|
4636
|
+
unrecognized zone fails open to eur); a stored hctx-cur choice is
|
|
4637
|
+
validated and always wins. This duplicates the marketing site's rule on
|
|
4638
|
+
purpose: web/ and this package asset are separate surfaces that share no
|
|
4639
|
+
code — the SAME key keeps the two toggles converged. */
|
|
4640
|
+
const US_ZONES = ["America/New_York","America/Chicago","America/Denver","America/Phoenix","America/Los_Angeles","America/Anchorage","America/Juneau","America/Sitka","America/Metlakatla","America/Nome","America/Yakutat","America/Adak","America/Boise","America/Detroit","America/Menominee","America/Puerto_Rico","America/St_Thomas","Pacific/Honolulu","Pacific/Guam","Pacific/Saipan","Pacific/Pago_Pago","America/Indiana/","America/Kentucky/","America/North_Dakota/"];
|
|
4641
|
+
function isUsTz(z) {
|
|
4642
|
+
for (const u of US_ZONES) {
|
|
4643
|
+
if (u.slice(-1) === "/") { if (z.slice(0, u.length) === u) return true; }
|
|
4644
|
+
else if (z === u) return true;
|
|
4645
|
+
}
|
|
4646
|
+
return false;
|
|
4647
|
+
}
|
|
4648
|
+
function tzDefaultCur() {
|
|
4649
|
+
try { return isUsTz(Intl.DateTimeFormat().resolvedOptions().timeZone || "") ? "usd" : "eur"; } catch { return "eur"; }
|
|
4650
|
+
}
|
|
4651
|
+
let PLAN_CUR = tzDefaultCur();
|
|
4652
|
+
try { const saved = localStorage.getItem("hctx-cur"); if (saved === "usd" || saved === "eur") PLAN_CUR = saved; } catch {}
|
|
4617
4653
|
/* Pure decision (#371) — the purchasable periods. Decided pricing (owner
|
|
4618
4654
|
2026-08-19): ONE price, TWO periods — €12/mo and €108/yr. ANNUAL FIRST:
|
|
4619
4655
|
annual is the stated product default; its note is the numeric savings
|
|
4620
4656
|
sub-line (round-4 addendum 2026-09-24: it replaces the retired
|
|
4621
4657
|
words-only annual tagline — same fact, numbers not words; effective
|
|
4622
4658
|
monthly 108/12 = €9, discount (144−108)/144 = 25%, derived-pinned by
|
|
4623
|
-
tests so a price change forces the sub-line update).
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4659
|
+
tests so a price change forces the sub-line update). #411 (rulings
|
|
4660
|
+
2026-10-12): the price/note literals are PER-CURRENCY data — USD
|
|
4661
|
+
MIRRORS the EUR whole numbers ($12/mo, $108/yr), and the savings pair
|
|
4662
|
+
is derived per currency from the same-currency bases (never converted;
|
|
4663
|
+
no exchange-rate arithmetic anywhere). The router deliberately knows
|
|
4664
|
+
only Stripe price ids (no server-side amount exists to read), and the
|
|
4665
|
+
Stripe Checkout page shows the authoritative amount before payment.
|
|
4666
|
+
Round 3: a PURE DATA ARRAY and the single source of truth — the overlay
|
|
4667
|
+
cards are GENERATED from it (renderPlanCards) and the wiring loops it
|
|
4668
|
+
(wireChooseButtons); no two-plan hardcoding anywhere. #411 tax wording
|
|
4669
|
+
(tax research brief, 2026-10-12): the price strings carry the VERBATIM
|
|
4670
|
+
pricing-card wording — EUR consumer prices read VAT-inclusive ("incl.
|
|
4671
|
+
25.5% VAT"), USD tax-exclusive ("excl. tax"); fixed wording, the 25.5%
|
|
4672
|
+
inside it is never a computed value. The savings note is a derived
|
|
4673
|
+
ANNOTATION, not a price point — it carries no qualifier. The bullets
|
|
4674
|
+
are the marketing site's Cloud feature lines, verbatim (lockstep-
|
|
4675
|
+
pinned against web/index.html) — the seven owner-decided lines
|
|
4676
|
+
(amendment 4, 2026-09-24: copy-first ruling; the agent-cap enforcement
|
|
4677
|
+
rides its own issue); both periods are the same Cloud product, so both
|
|
4678
|
+
carry the same seven. */
|
|
4635
4679
|
const PLAN_OPTIONS = [
|
|
4636
|
-
{ id: "annual", posts: "annual", name: "Annual", price: "€108/year", note: "€9/mo · 25% off", cta: "Choose annual", bullets: ["Fully managed — no API keys needed", "Claude Code, Hermes, OpenClaw, Pi, OpenCode", "10,000 memories included", "Up to 10 agents", "Learnings & nightly reflection", "Semantic search + knowledge graph", "Multi-machine support"] },
|
|
4637
|
-
{ id: "monthly", posts: "monthly", name: "Monthly", price: "€12/
|
|
4680
|
+
{ id: "annual", posts: "annual", name: "Annual", prices: { eur: { price: "€108/year (incl. 25.5% VAT)", note: "€9/mo · 25% off" }, usd: { price: "$108/year (excl. tax)", note: "$9/mo · 25% off" } }, cta: "Choose annual", bullets: ["Fully managed — no API keys needed", "Claude Code, Hermes, OpenClaw, Pi, OpenCode", "10,000 memories included", "Up to 10 agents", "Learnings & nightly reflection", "Semantic search + knowledge graph", "Multi-machine support"] },
|
|
4681
|
+
{ id: "monthly", posts: "monthly", name: "Monthly", prices: { eur: { price: "€12/month (incl. 25.5% VAT)", note: "" }, usd: { price: "$12/month (excl. tax)", note: "" } }, cta: "Choose monthly", bullets: ["Fully managed — no API keys needed", "Claude Code, Hermes, OpenClaw, Pi, OpenCode", "10,000 memories included", "Up to 10 agents", "Learnings & nightly reflection", "Semantic search + knowledge graph", "Multi-machine support"] },
|
|
4638
4682
|
];
|
|
4683
|
+
/* #411 tax brief — presentation split for the big price line: the amount
|
|
4684
|
+
renders at full size, the tax qualifier in the smaller muted style.
|
|
4685
|
+
Pure, and the DATA string stays the brief's verbatim wording either
|
|
4686
|
+
way (the 25.5% lives only inside the fixed wording strings, never as a
|
|
4687
|
+
computed value). */
|
|
4688
|
+
function priceParts(s) {
|
|
4689
|
+
const at = s.indexOf(" (");
|
|
4690
|
+
return at === -1 ? [s, ""] : [s.slice(0, at), s.slice(at + 1)];
|
|
4691
|
+
}
|
|
4639
4692
|
/* Pure decision (#371) — the Stripe return parameter (?billing=…, the
|
|
4640
4693
|
success_url/cancel_url the router stamps on every checkout) → the
|
|
4641
4694
|
acknowledgment banner spec, or null when there is nothing to acknowledge
|
|
@@ -4737,24 +4790,69 @@ function closeConnectOverlay() {
|
|
|
4737
4790
|
const ov = $("connect-overlay");
|
|
4738
4791
|
if (ov) ov.hidden = true;
|
|
4739
4792
|
}
|
|
4740
|
-
/* N-driven card render (#371 round 3): the option cards
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4793
|
+
/* N-driven card render (#371 round 3, #411 per-currency): the option cards
|
|
4794
|
+
are GENERATED from PLAN_OPTIONS at the CURRENT currency — N entries, N
|
|
4795
|
+
cards, no per-plan or per-currency literals anywhere in the markup or
|
|
4796
|
+
this template (a future plan is a data entry + a router price id, not a
|
|
4797
|
+
page rework). Runs at script init AND on every currency toggle
|
|
4798
|
+
(setPlanCur); account data only toggles visibility (renderPlanOverlay). */
|
|
4745
4799
|
function renderPlanCards() {
|
|
4746
4800
|
const host = $("acct-options");
|
|
4747
4801
|
if (!host) return;
|
|
4748
|
-
host.innerHTML = PLAN_OPTIONS.map((o) =>
|
|
4802
|
+
host.innerHTML = PLAN_OPTIONS.map((o) => {
|
|
4803
|
+
const p = o.prices[PLAN_CUR];
|
|
4804
|
+
const [main, tax] = priceParts(p.price);
|
|
4805
|
+
return `
|
|
4749
4806
|
<div class="po-opt" id="acct-opt-${o.id}">
|
|
4750
4807
|
<div class="po-name">${esc(o.name)}</div>
|
|
4751
|
-
<div class="po-price">${esc(
|
|
4752
|
-
${
|
|
4808
|
+
<div class="po-price">${esc(main)}${tax ? ` <span class="po-price-x">${esc(tax)}</span>` : ""}</div>
|
|
4809
|
+
${p.note ? `<div class="po-note">${esc(p.note)}</div>` : ""}
|
|
4753
4810
|
<ul class="po-feat">${o.bullets.map((b) => `<li>${esc(b)}</li>`).join("")}</ul>
|
|
4754
4811
|
<button id="acct-buy-${o.id}" type="button" class="po-choose">${esc(o.cta)}</button>
|
|
4755
|
-
</div
|
|
4812
|
+
</div>`;
|
|
4813
|
+
}).join("");
|
|
4756
4814
|
}
|
|
4757
4815
|
renderPlanCards();
|
|
4816
|
+
/* #411 — bind each card's Choose button from the entry's id (N buttons,
|
|
4817
|
+
one loop). Extracted from wireSubscription because the currency toggle
|
|
4818
|
+
REGENERATES the cards' innerHTML, which drops the listeners — every
|
|
4819
|
+
re-render re-binds through here. */
|
|
4820
|
+
function wireChooseButtons() {
|
|
4821
|
+
for (const o of PLAN_OPTIONS) {
|
|
4822
|
+
const buy = $("acct-buy-" + o.id);
|
|
4823
|
+
if (!buy) continue;
|
|
4824
|
+
buy.addEventListener("click", () => { startCheckout(o.posts, PLAN_CUR, buy); });
|
|
4825
|
+
}
|
|
4826
|
+
}
|
|
4827
|
+
/* #411 — the overlay's currency toggle (the site's #cur-toggle idiom):
|
|
4828
|
+
swap the current currency, persist the choice under the SAME hctx-cur
|
|
4829
|
+
key the site uses, repaint the pill label, and re-render + re-bind the
|
|
4830
|
+
cards (the prices are per-currency data). */
|
|
4831
|
+
function setPlanCur(c) {
|
|
4832
|
+
PLAN_CUR = c;
|
|
4833
|
+
try { localStorage.setItem("hctx-cur", c); } catch {}
|
|
4834
|
+
const t = $("po-cur");
|
|
4835
|
+
if (t) t.textContent = c === "usd" ? "$ USD" : "€ EUR";
|
|
4836
|
+
// #411 tax brief: the USD checkout footnote shows ONLY on USD (the
|
|
4837
|
+
// Stripe-hosted page cannot carry custom copy — this overlay is the
|
|
4838
|
+
// checkout surface we own). EUR needs no note: its compliance wording
|
|
4839
|
+
// rides the price strings ("incl. 25.5% VAT").
|
|
4840
|
+
const note = $("po-tax");
|
|
4841
|
+
if (note) note.hidden = c !== "usd";
|
|
4842
|
+
renderPlanCards();
|
|
4843
|
+
wireChooseButtons();
|
|
4844
|
+
}
|
|
4845
|
+
function wirePlanCurrency() {
|
|
4846
|
+
// Footnote visibility at INIT too — a US-timezone first visit starts on
|
|
4847
|
+
// USD with no toggle ever firing.
|
|
4848
|
+
const note = $("po-tax");
|
|
4849
|
+
if (note) note.hidden = PLAN_CUR !== "usd";
|
|
4850
|
+
const t = $("po-cur");
|
|
4851
|
+
if (!t) return;
|
|
4852
|
+
t.textContent = PLAN_CUR === "usd" ? "$ USD" : "€ EUR";
|
|
4853
|
+
t.addEventListener("click", () => { setPlanCur(PLAN_CUR === "usd" ? "eur" : "usd"); });
|
|
4854
|
+
}
|
|
4855
|
+
wirePlanCurrency();
|
|
4758
4856
|
function wireSubscription() {
|
|
4759
4857
|
const btn = $("acct-subscription");
|
|
4760
4858
|
if (!btn) return;
|
|
@@ -4766,11 +4864,9 @@ function wireSubscription() {
|
|
|
4766
4864
|
closeAcctMenu();
|
|
4767
4865
|
openPlanOverlay();
|
|
4768
4866
|
});
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
buy.addEventListener("click", () => { startCheckout(o.posts, buy); });
|
|
4773
|
-
}
|
|
4867
|
+
// #411: the Choose-button binding lives in wireChooseButtons (the
|
|
4868
|
+
// currency toggle re-binds through it after every re-render).
|
|
4869
|
+
wireChooseButtons();
|
|
4774
4870
|
}
|
|
4775
4871
|
/* #506: the menu's Connect-an-agent entry opens the full-cover connect
|
|
4776
4872
|
overlay — the same launch idiom as wireSubscription (#371): the menu
|
|
@@ -4785,21 +4881,23 @@ function wireConnectEntry() {
|
|
|
4785
4881
|
openConnectOverlay();
|
|
4786
4882
|
});
|
|
4787
4883
|
}
|
|
4788
|
-
/** POST /stripe/checkout for ONE plan
|
|
4789
|
-
* URL (#371 — each period's action posts
|
|
4790
|
-
* annual-only body was the defect
|
|
4791
|
-
*
|
|
4792
|
-
*
|
|
4793
|
-
*
|
|
4794
|
-
*
|
|
4795
|
-
*
|
|
4796
|
-
|
|
4884
|
+
/** POST /stripe/checkout for ONE plan at the DISPLAYED currency, then
|
|
4885
|
+
* navigate to the returned Stripe URL (#371 — each period's action posts
|
|
4886
|
+
* its own plan; the hardcoded annual-only body was the defect. #411 — the
|
|
4887
|
+
* body now carries the currency the buyer saw, so the charge matches the
|
|
4888
|
+
* display; the router maps (plan, currency) → its configured price id).
|
|
4889
|
+
* The failure seams are the shipped checkout-handler contract, kept
|
|
4890
|
+
* verbatim for EVERY action: 401 → Google re-auth where the probe says
|
|
4891
|
+
* OAuth exists, else the expired-session alert; non-ok → the unavailable
|
|
4892
|
+
* alert; network error → the unreachable alert. Each button is disabled
|
|
4893
|
+
* independently while its own request is in flight. */
|
|
4894
|
+
async function startCheckout(plan, currency, btn) {
|
|
4797
4895
|
btn.disabled = true;
|
|
4798
4896
|
try {
|
|
4799
4897
|
const resp = await fetch("/stripe/checkout", {
|
|
4800
4898
|
method: "POST",
|
|
4801
4899
|
headers: { "content-type": "application/json" },
|
|
4802
|
-
body: JSON.stringify({ plan }),
|
|
4900
|
+
body: JSON.stringify({ plan, currency }),
|
|
4803
4901
|
});
|
|
4804
4902
|
if (resp.status === 401) {
|
|
4805
4903
|
// Never hard-redirect to Google on a daemon (dead end / loop) — only
|
package/dist/calibration.d.ts
CHANGED
|
@@ -77,6 +77,27 @@ export declare const SESSION_INTENT_WEIGHT = 0.33;
|
|
|
77
77
|
* rewritten corpus): steady ~3:1 noise:signal removal with no knee; sits
|
|
78
78
|
* below the 0.63 local pessimum. FTS-matched candidates pass regardless. */
|
|
79
79
|
export declare const RECALL_MIN_SIMILARITY = 0.62;
|
|
80
|
+
/**
|
|
81
|
+
* Cross-project recall fence bar (#566) — a memory from a DIFFERENT project
|
|
82
|
+
* than the request's must clear this on a MEASURED cosine to be admitted
|
|
83
|
+
* into recall/search results; same-project and no-scope candidates keep the
|
|
84
|
+
* RECALL_MIN_SIMILARITY floor above, byte-identical.
|
|
85
|
+
*
|
|
86
|
+
* Measured 2026-10-28 on the #565 WS2 snapshot bar sweep: at 0.72 a
|
|
87
|
+
* scope-conditional bar keeps ~18% of today's cross-project admissions
|
|
88
|
+
* (projected multi-project cross-share ~29%, audit target ≤35%); a GLOBAL
|
|
89
|
+
* 0.72 floor would kill 91% of same-project admissions, which is why the bar
|
|
90
|
+
* is scope-conditional. Owner ruling 2026-10-28: 0.72 now, 0.75 (the stricter
|
|
91
|
+
* option, keeps ~7.5%) one config edit away.
|
|
92
|
+
*
|
|
93
|
+
* Unlike every other constant in the recall family, this one KEEPS a config
|
|
94
|
+
* override (`recallCrossProjectMinSimilarity`, resolved once at server boot)
|
|
95
|
+
* — the ONE deliberate #408 exception, on the DEFAULT_FIRST_RUN_LOOKBACK_DAYS
|
|
96
|
+
* precedent: a posture dial the owner tunes per install, not corpus
|
|
97
|
+
* calibration. 0 or any value ≤ the recall floor (0.62) disarms the fence
|
|
98
|
+
* (today's scope-blind behavior).
|
|
99
|
+
*/
|
|
100
|
+
export declare const CROSS_PROJECT_MIN_SIMILARITY = 0.72;
|
|
80
101
|
/** Max lines in the pushed recall index. 5 (lowered from 6 on 2026-08-03):
|
|
81
102
|
* per-slot decomposition at floor 0.62 showed slot 6 gives NO prompt its
|
|
82
103
|
* first relevant memory. The K-sweep is monotone toward 4, but the 4-vs-5
|
package/dist/calibration.js
CHANGED
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
* the removal is never silent.
|
|
25
25
|
*/
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.
|
|
28
|
-
exports.DRAIN_QUEUE_WARN_AGE_HOURS = exports.DRAIN_YIELD_PROBE_TIMEOUT_MS = exports.DRAIN_YIELD_WAIT_CAP_MS = exports.DRAIN_YIELD_POLL_MS = exports.DIAGNOSTIC_ENV_TIER = exports.OLLAMA_FLUSH_WAIT_MS = exports.OLLAMA_FLUSH_EVERY = exports.NUM_CTX = exports.DEFAULT_FIRST_RUN_LOOKBACK_DAYS = exports.ENRICH_STRENGTH_DELTA = exports.STAGE_TRUTH_STRENGTH = void 0;
|
|
27
|
+
exports.STAGE_FADING_STRENGTH = exports.STAGE_FADING_DAYS = exports.WEAK_PRIMARY_FLOOR = exports.CORRECTION_REWRITE_MIN_CONFIDENCE = exports.CORRECTION_MIN_SIMILARITY = exports.DEDUP_AUTO_MERGE_THRESHOLD = exports.IMPORTANCE_SETTLE_WINDOW_DAYS = exports.IMPORTANCE_CEILING = exports.BM25_WEIGHT_DOMAIN = exports.BM25_WEIGHT_PROJECT = exports.BM25_WEIGHT_BODY = exports.BOTH_CHANNEL_BOOST = exports.RRF_VECTOR_WEIGHT = exports.RRF_FTS_WEIGHT = exports.RRF_COMPOSITE_WEIGHT = exports.RRF_K = exports.SCOPE_AFFINITY_WEIGHT = exports.SUPERSEDED_DEMOTION = exports.RECENCY_HEAD_DAYS = exports.RECENCY_HEAD_WEIGHT = exports.RECENCY_HOURLY_DECAY = exports.SCORE_RECENCY_WEIGHT = exports.CONNECTIONS_SATURATION_DEGREE = exports.SCORE_CONNECTIONS_WEIGHT = exports.SCORE_STRENGTH_WEIGHT = exports.SCORE_SIMILARITY_WEIGHT = exports.VOLATILE_GATE_MAX_CHARS = exports.VOLATILE_STATUS_FILTER = exports.MEMORY_PRECISION_PROMPT_EXCERPT_CHARS = exports.MEMORY_PRECISION_DIVERGENCE_MIN_SHOWN = exports.MEMORY_PRECISION_REDUNDANT_ABOVE = exports.MEMORY_PRECISION_WINDOW_DAYS = exports.RECALL_USES_AXIS_MAX = exports.RECALL_USES_NORMAL_MAX = exports.RECALL_USES_LOW_MAX = exports.RECALL_RESHOW_TURNS = exports.NOVELTY_FLOOR_SLOTS = exports.RECALL_TITLE_CHARS = exports.RECALL_MIN_PROMPT_CHARS = exports.RECALL_MAX_ITEMS = exports.CROSS_PROJECT_MIN_SIMILARITY = exports.RECALL_MIN_SIMILARITY = exports.SESSION_INTENT_WEIGHT = exports.COLD_EXPOSURE_SLOTS = exports.RECENT_WINDOW_DAYS = exports.RECENT_LIMIT = exports.SEARCH_LIMIT = exports.PROMOTION_STRENGTH_FLOOR = exports.PROMOTION_RATE = exports.DECAY_HALF_LIFE_DAYS = void 0;
|
|
28
|
+
exports.DRAIN_QUEUE_WARN_AGE_HOURS = exports.DRAIN_YIELD_PROBE_TIMEOUT_MS = exports.DRAIN_YIELD_WAIT_CAP_MS = exports.DRAIN_YIELD_POLL_MS = exports.DIAGNOSTIC_ENV_TIER = exports.OLLAMA_FLUSH_WAIT_MS = exports.OLLAMA_FLUSH_EVERY = exports.NUM_CTX = exports.DEFAULT_FIRST_RUN_LOOKBACK_DAYS = exports.ENRICH_STRENGTH_DELTA = exports.STAGE_TRUTH_STRENGTH = exports.STAGE_BELIEF_STRENGTH = void 0;
|
|
29
29
|
exports.resolveNumCtx = resolveNumCtx;
|
|
30
30
|
exports.resolveOllamaFlushEvery = resolveOllamaFlushEvery;
|
|
31
31
|
exports.resolveOllamaFlushWaitMs = resolveOllamaFlushWaitMs;
|
|
@@ -89,6 +89,27 @@ exports.SESSION_INTENT_WEIGHT = 0.33;
|
|
|
89
89
|
* rewritten corpus): steady ~3:1 noise:signal removal with no knee; sits
|
|
90
90
|
* below the 0.63 local pessimum. FTS-matched candidates pass regardless. */
|
|
91
91
|
exports.RECALL_MIN_SIMILARITY = 0.62;
|
|
92
|
+
/**
|
|
93
|
+
* Cross-project recall fence bar (#566) — a memory from a DIFFERENT project
|
|
94
|
+
* than the request's must clear this on a MEASURED cosine to be admitted
|
|
95
|
+
* into recall/search results; same-project and no-scope candidates keep the
|
|
96
|
+
* RECALL_MIN_SIMILARITY floor above, byte-identical.
|
|
97
|
+
*
|
|
98
|
+
* Measured 2026-10-28 on the #565 WS2 snapshot bar sweep: at 0.72 a
|
|
99
|
+
* scope-conditional bar keeps ~18% of today's cross-project admissions
|
|
100
|
+
* (projected multi-project cross-share ~29%, audit target ≤35%); a GLOBAL
|
|
101
|
+
* 0.72 floor would kill 91% of same-project admissions, which is why the bar
|
|
102
|
+
* is scope-conditional. Owner ruling 2026-10-28: 0.72 now, 0.75 (the stricter
|
|
103
|
+
* option, keeps ~7.5%) one config edit away.
|
|
104
|
+
*
|
|
105
|
+
* Unlike every other constant in the recall family, this one KEEPS a config
|
|
106
|
+
* override (`recallCrossProjectMinSimilarity`, resolved once at server boot)
|
|
107
|
+
* — the ONE deliberate #408 exception, on the DEFAULT_FIRST_RUN_LOOKBACK_DAYS
|
|
108
|
+
* precedent: a posture dial the owner tunes per install, not corpus
|
|
109
|
+
* calibration. 0 or any value ≤ the recall floor (0.62) disarms the fence
|
|
110
|
+
* (today's scope-blind behavior).
|
|
111
|
+
*/
|
|
112
|
+
exports.CROSS_PROJECT_MIN_SIMILARITY = 0.72;
|
|
92
113
|
/** Max lines in the pushed recall index. 5 (lowered from 6 on 2026-08-03):
|
|
93
114
|
* per-slot decomposition at floor 0.62 showed slot 6 gives NO prompt its
|
|
94
115
|
* first relevant memory. The K-sweep is monotone toward 4, but the 4-vs-5
|
package/dist/cli.d.ts
CHANGED
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
* dedup --apply Execute the merge (default: dry run);
|
|
17
17
|
* losers are absorbed (kept as evidence,
|
|
18
18
|
* hidden from recall), not deleted
|
|
19
|
+
* reconcile-projects One-shot project-label reconciliation (issue #567)
|
|
20
|
+
* reconcile-projects --apply Execute the renames (default: dry
|
|
21
|
+
* run); canonicalizes existing rows via
|
|
22
|
+
* the case fold + the projectAliases map
|
|
19
23
|
* sweep-volatile One-shot sweep of volatile GH-status/version rows (#489)
|
|
20
24
|
* sweep-volatile --apply Demote matches via absorb (default:
|
|
21
25
|
* dry run; backup first, audit trail)
|
package/dist/cli.js
CHANGED
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
* dedup --apply Execute the merge (default: dry run);
|
|
18
18
|
* losers are absorbed (kept as evidence,
|
|
19
19
|
* hidden from recall), not deleted
|
|
20
|
+
* reconcile-projects One-shot project-label reconciliation (issue #567)
|
|
21
|
+
* reconcile-projects --apply Execute the renames (default: dry
|
|
22
|
+
* run); canonicalizes existing rows via
|
|
23
|
+
* the case fold + the projectAliases map
|
|
20
24
|
* sweep-volatile One-shot sweep of volatile GH-status/version rows (#489)
|
|
21
25
|
* sweep-volatile --apply Demote matches via absorb (default:
|
|
22
26
|
* dry run; backup first, audit trail)
|
|
@@ -309,6 +313,30 @@ switch (command) {
|
|
|
309
313
|
});
|
|
310
314
|
break;
|
|
311
315
|
}
|
|
316
|
+
case "reconcile-projects": {
|
|
317
|
+
// One-shot project-label reconciliation (#567): canonicalize EXISTING
|
|
318
|
+
// rows under the case fold + the projectAliases map. Mirrors `dedup`:
|
|
319
|
+
// dry-run default, --apply explicit (backup first, one transaction per
|
|
320
|
+
// rename group); flags parsed here, the runner lives in
|
|
321
|
+
// reconcile-projects.ts so this switch stays thin.
|
|
322
|
+
const args = process.argv.slice(3);
|
|
323
|
+
let dbPath;
|
|
324
|
+
try {
|
|
325
|
+
dbPath = (0, cli_args_js_1.readValueFlag)(args, "--db");
|
|
326
|
+
}
|
|
327
|
+
catch {
|
|
328
|
+
console.error("[hicortex] reconcile-projects: --db requires a path value");
|
|
329
|
+
process.exit(1);
|
|
330
|
+
}
|
|
331
|
+
const reconcileOptions = { apply: args.includes("--apply"), dbPath };
|
|
332
|
+
import("./reconcile-projects.js").then(({ runReconcileProjects }) => {
|
|
333
|
+
runReconcileProjects(reconcileOptions).catch((err) => {
|
|
334
|
+
console.error(err instanceof Error ? err.message : `[hicortex] reconcile-projects failed: ${err}`);
|
|
335
|
+
process.exit(1);
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
312
340
|
case "sweep-volatile": {
|
|
313
341
|
// One-shot store sweep of volatile GH-status/version rows (#489,
|
|
314
342
|
// deliverable iii): reuses the distill path's deterministic gate over the
|
|
@@ -471,6 +499,7 @@ Commands:
|
|
|
471
499
|
nightly Run nightly denoise + capture + consolidate
|
|
472
500
|
relink Resumable link-discovery pass over the ENTIRE corpus (server mode)
|
|
473
501
|
dedup Cluster + merge near-duplicate memories (server mode; dry run by default)
|
|
502
|
+
reconcile-projects Canonicalize existing project labels (server mode; dry run by default)
|
|
474
503
|
history Show a memory's rewrite history, or roll one back (server mode)
|
|
475
504
|
history <id> List rewrite events (read-only)
|
|
476
505
|
history --rollback <row> Undo one rewrite + un-absorb its triggers
|
|
@@ -506,6 +535,9 @@ Options:
|
|
|
506
535
|
dedup --threshold <t> Override the threshold for one run (default: the
|
|
507
536
|
release-managed calibration ceiling, 0.92)
|
|
508
537
|
dedup --db <path> DB path override (defaults to the configured DB)
|
|
538
|
+
reconcile-projects --apply Execute the project renames (default: dry run, report only)
|
|
539
|
+
Backup first; renames memories + distill_queue only
|
|
540
|
+
reconcile-projects --db <path> DB path override (defaults to the configured DB)
|
|
509
541
|
history --rollback <row> Roll back history row <row>: restores prior content/status, un-absorbs triggers
|
|
510
542
|
history --db <path> DB path override (defaults to the configured DB)
|
|
511
543
|
backup --out <dir> Write the artifact into <dir> as hicortex-<ISO>.tar.gz (default: <home>/backups)
|
package/dist/config-read.d.ts
CHANGED
|
@@ -30,6 +30,17 @@ export declare function readStrictBoolean(config: Record<string, unknown>, key:
|
|
|
30
30
|
* value (e.g. memorySoftCap's eviction opt-out, timerJitterSeconds).
|
|
31
31
|
*/
|
|
32
32
|
export declare function readNonNegativeConfig(config: Record<string, unknown>, key: string, def: number): number;
|
|
33
|
+
/**
|
|
34
|
+
* Read a finite number clamped into the unit interval [0, 1] (#566 — the
|
|
35
|
+
* similarity-bar keys). 0 is a VALID value here (the deliberate "off"
|
|
36
|
+
* setting — unlike readPositiveConfig, which rejects it), and out-of-range
|
|
37
|
+
* numbers CLAMP rather than warn: the caller's contract is a similarity bar,
|
|
38
|
+
* and 1.5 / -0.2 carry the same intent as 1 / 0 (full fence / off), not a
|
|
39
|
+
* typo class the operator must notice. Only a wrong TYPE (string, null,
|
|
40
|
+
* NaN, …) warns and keeps `def` — the readPositiveConfig boundary posture
|
|
41
|
+
* against silent coercion.
|
|
42
|
+
*/
|
|
43
|
+
export declare function readUnitIntervalConfig(config: Record<string, unknown>, key: string, def: number): number;
|
|
33
44
|
/**
|
|
34
45
|
* Read + validate an array of scheduling hours (integers 0–23, local time) for
|
|
35
46
|
* the capture/consolidation timers (0.17). Returns the validated, de-duped,
|
package/dist/config-read.js
CHANGED
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.readPositiveConfig = readPositiveConfig;
|
|
18
18
|
exports.readStrictBoolean = readStrictBoolean;
|
|
19
19
|
exports.readNonNegativeConfig = readNonNegativeConfig;
|
|
20
|
+
exports.readUnitIntervalConfig = readUnitIntervalConfig;
|
|
20
21
|
exports.parseHours = parseHours;
|
|
21
22
|
exports.readStringConfig = readStringConfig;
|
|
22
23
|
exports.readAccount = readAccount;
|
|
@@ -63,6 +64,26 @@ function readNonNegativeConfig(config, key, def) {
|
|
|
63
64
|
console.warn(`[hicortex] config "${key}" = ${String(v)} is not a non-negative finite number — using default ${def}.`);
|
|
64
65
|
return def;
|
|
65
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Read a finite number clamped into the unit interval [0, 1] (#566 — the
|
|
69
|
+
* similarity-bar keys). 0 is a VALID value here (the deliberate "off"
|
|
70
|
+
* setting — unlike readPositiveConfig, which rejects it), and out-of-range
|
|
71
|
+
* numbers CLAMP rather than warn: the caller's contract is a similarity bar,
|
|
72
|
+
* and 1.5 / -0.2 carry the same intent as 1 / 0 (full fence / off), not a
|
|
73
|
+
* typo class the operator must notice. Only a wrong TYPE (string, null,
|
|
74
|
+
* NaN, …) warns and keeps `def` — the readPositiveConfig boundary posture
|
|
75
|
+
* against silent coercion.
|
|
76
|
+
*/
|
|
77
|
+
function readUnitIntervalConfig(config, key, def) {
|
|
78
|
+
const v = config[key];
|
|
79
|
+
if (v === undefined)
|
|
80
|
+
return def;
|
|
81
|
+
if (typeof v === "number" && Number.isFinite(v)) {
|
|
82
|
+
return Math.min(1, Math.max(0, v));
|
|
83
|
+
}
|
|
84
|
+
console.warn(`[hicortex] config "${key}" = ${String(v)} is not a finite number — using default ${def}.`);
|
|
85
|
+
return def;
|
|
86
|
+
}
|
|
66
87
|
/**
|
|
67
88
|
* Read + validate an array of scheduling hours (integers 0–23, local time) for
|
|
68
89
|
* the capture/consolidation timers (0.17). Returns the validated, de-duped,
|
package/dist/distill-queue.d.ts
CHANGED
|
@@ -168,6 +168,14 @@ export interface DrainOptions {
|
|
|
168
168
|
* real detectChunkSize, cached per endpoint like the /distill handler).
|
|
169
169
|
*/
|
|
170
170
|
detectChunkSize?: typeof detectChunkSize;
|
|
171
|
+
/**
|
|
172
|
+
* #567: the project-identity alias map — the drain folds `item.project`
|
|
173
|
+
* once per item (the queue kept the wire project verbatim, so rows queued
|
|
174
|
+
* before the canonicalization deploy still distill + store canonical;
|
|
175
|
+
* defense-in-depth beside the /distill handler's own fold). null/absent →
|
|
176
|
+
* mechanical fold only. The nightly passes the boot-resolved config value.
|
|
177
|
+
*/
|
|
178
|
+
projectAliases?: Readonly<Record<string, string>> | null;
|
|
171
179
|
}
|
|
172
180
|
export interface DrainReport {
|
|
173
181
|
/**
|
package/dist/distill-queue.js
CHANGED
|
@@ -79,6 +79,7 @@ const distiller_js_1 = require("./distiller.js");
|
|
|
79
79
|
const calibration_js_1 = require("./calibration.js");
|
|
80
80
|
const storage = __importStar(require("./storage.js"));
|
|
81
81
|
const dedup_js_1 = require("./dedup.js");
|
|
82
|
+
const project_canonicalize_js_1 = require("./project-canonicalize.js");
|
|
82
83
|
/** Normalize an unknown wire value into a nullable string column. */
|
|
83
84
|
function str(v) {
|
|
84
85
|
return typeof v === "string" && v.length > 0 ? v : null;
|
|
@@ -360,10 +361,14 @@ async function drainDistillQueue(db, opts) {
|
|
|
360
361
|
// BEFORE distillation — see resolveDrainCreatedAt: a throwing date
|
|
361
362
|
// computation after the LLM calls is the poison row.
|
|
362
363
|
const createdAt = resolveDrainCreatedAt(item);
|
|
364
|
+
// #567: fold the queued project ONCE per item — both the distill
|
|
365
|
+
// prompt and the insert opts below carry the canonical value (the
|
|
366
|
+
// queue row keeps the raw wire label verbatim by design).
|
|
367
|
+
const canonProject = (0, project_canonicalize_js_1.canonicalizeProject)(item.project, opts.projectAliases);
|
|
363
368
|
try {
|
|
364
369
|
// Cast: DrainLlm is the structural surface distillSession uses.
|
|
365
370
|
const llm = opts.llm;
|
|
366
|
-
const entries = await (0, distiller_js_1.distillSession)(llm, item.text,
|
|
371
|
+
const entries = await (0, distiller_js_1.distillSession)(llm, item.text, canonProject ?? "unknown", item.session_date ?? new Date().toISOString().slice(0, 10), chunkSize, [], (u) => {
|
|
367
372
|
usage.prompt += u.prompt_tokens ?? 0;
|
|
368
373
|
usage.completion += u.completion_tokens ?? 0;
|
|
369
374
|
usage.total += u.total_tokens ?? 0;
|
|
@@ -398,7 +403,7 @@ async function drainDistillQueue(db, opts) {
|
|
|
398
403
|
sourceDomain: item.source_domain,
|
|
399
404
|
sourceMachine: storage.sanitizeSourceMachine(item.source_machine),
|
|
400
405
|
sourceSession: sourcePrefix ? `${sourcePrefix}#${i}` : undefined,
|
|
401
|
-
project:
|
|
406
|
+
project: canonProject ?? undefined,
|
|
402
407
|
memoryType,
|
|
403
408
|
privacy: item.privacy,
|
|
404
409
|
createdAt,
|
|
@@ -47,6 +47,11 @@ export interface ResolvedConfig {
|
|
|
47
47
|
agentName: string | null;
|
|
48
48
|
/** Max lessons to inject (config.lessonsLimit, default 10). */
|
|
49
49
|
lessonsLimit?: number;
|
|
50
|
+
/** #567: the project-identity alias map (config `projectAliases`, folded
|
|
51
|
+
* at read) — the client-side fold of the cwd-derived project uses it so
|
|
52
|
+
* the lesson-selection comparison converges with the canonical server
|
|
53
|
+
* corpus. null when the key is absent (mechanical fold only). */
|
|
54
|
+
projectAliases?: Readonly<Record<string, string>> | null;
|
|
50
55
|
}
|
|
51
56
|
/**
|
|
52
57
|
* Read ~/.hicortex/config.json and resolve the server URL + auth token, or
|
|
@@ -55,6 +60,17 @@ export interface ResolvedConfig {
|
|
|
55
60
|
* never resolve the server differently.
|
|
56
61
|
*/
|
|
57
62
|
export declare function resolveConfig(): ResolvedConfig | null;
|
|
63
|
+
/**
|
|
64
|
+
* #567: the client-side project fold for lesson selection. The SessionStart
|
|
65
|
+
* hook derives its comparison project LOCALLY (basename of the session's
|
|
66
|
+
* cwd — the capture-side convention), while the server stores canonical
|
|
67
|
+
* labels; without folding the local label through the SAME function the
|
|
68
|
+
* `lesson.project === targetProject` affinity would silently miss on every
|
|
69
|
+
* case variant. Pure — exported so the fold is testable without stubbing
|
|
70
|
+
* fetchLessonsBlock's HTTP path (the resolveConfig/parseProjectAliases pair
|
|
71
|
+
* plus this function are the whole client-side seam).
|
|
72
|
+
*/
|
|
73
|
+
export declare function deriveHookProject(cwd: string, aliases?: Readonly<Record<string, string>> | null): string | null;
|
|
58
74
|
/**
|
|
59
75
|
* Title-case a section name for its heading: split on `-`/`_`, capitalize each
|
|
60
76
|
* word ("user" → "User", "my_notes" → "My Notes").
|