@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/storage.js
CHANGED
|
@@ -39,6 +39,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
exports.FTS_MATCH_MAX_TOKENS = void 0;
|
|
41
41
|
exports.embedToBlob = embedToBlob;
|
|
42
|
+
exports.normalizeStoredPrivacy = normalizeStoredPrivacy;
|
|
42
43
|
exports.sanitizeSourceMachine = sanitizeSourceMachine;
|
|
43
44
|
exports.insertMemory = insertMemory;
|
|
44
45
|
exports.resolveMemoryId = resolveMemoryId;
|
|
@@ -89,6 +90,17 @@ function embedToBlob(embedding) {
|
|
|
89
90
|
function rowToMemory(row) {
|
|
90
91
|
return row;
|
|
91
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Normalize any wire/unknown privacy value into the #332 classification
|
|
95
|
+
* vocabulary — the insert-boundary guard that keeps legacy values ('WORK',
|
|
96
|
+
* 'PERSONAL', blank, NULL, wrong type) out of the column after migration
|
|
97
|
+
* v27 normalized history. 'confidential' passes through (it is only ever
|
|
98
|
+
* server-derived by the time it reaches storage); everything else becomes
|
|
99
|
+
* 'standard' (the fail-closed default class).
|
|
100
|
+
*/
|
|
101
|
+
function normalizeStoredPrivacy(v) {
|
|
102
|
+
return v === "confidential" ? "confidential" : "standard";
|
|
103
|
+
}
|
|
92
104
|
// ---------------------------------------------------------------------------
|
|
93
105
|
// Single memory CRUD
|
|
94
106
|
// ---------------------------------------------------------------------------
|
|
@@ -124,7 +136,12 @@ function insertMemory(db, content, embedding, opts = {}) {
|
|
|
124
136
|
created_at, ingested_at, source_agent, source_agent_id, source_session,
|
|
125
137
|
source_domain, project, privacy, memory_type, source_machine)
|
|
126
138
|
VALUES (?, ?, ?, ?, 0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
127
|
-
.run(id, content, opts.baseStrength ?? 0.5, ts, ts, ingestedTs, opts.sourceAgent ?? "default", opts.sourceAgentId ?? null, sourceSession, opts.sourceDomain ?? null, opts.project ?? null,
|
|
139
|
+
.run(id, content, opts.baseStrength ?? 0.5, ts, ts, ingestedTs, opts.sourceAgent ?? "default", opts.sourceAgentId ?? null, sourceSession, opts.sourceDomain ?? null, opts.project ?? null,
|
|
140
|
+
// #332: 'standard' is the fail-closed default class — a NULL here would
|
|
141
|
+
// pre-date migration v27's normalization and force every read gate to
|
|
142
|
+
// keep a NULL arm forever. Confidential rows always carry an explicit
|
|
143
|
+
// server-derived 'confidential'.
|
|
144
|
+
opts.privacy ?? "standard", opts.memoryType ?? "experience", opts.sourceMachine ?? null);
|
|
128
145
|
if (result.changes > 0) {
|
|
129
146
|
// New row — store its vector.
|
|
130
147
|
db.prepare("INSERT INTO memory_vectors (id, embedding) VALUES (?, ?)").run(id, embedToBlob(embedding));
|
|
@@ -641,9 +658,8 @@ function deleteLinks(db, memoryId) {
|
|
|
641
658
|
* Batch insert memories. Returns count inserted.
|
|
642
659
|
*/
|
|
643
660
|
function insertMemoriesBatch(db, memories) {
|
|
644
|
-
// privacy
|
|
645
|
-
//
|
|
646
|
-
// an explicit value).
|
|
661
|
+
// #332: privacy defaults to 'standard' (the class carrier) — same default
|
|
662
|
+
// as insertMemory; see the comment there.
|
|
647
663
|
const insertMem = db.prepare(`INSERT INTO memories
|
|
648
664
|
(id, content, base_strength, last_accessed, access_count,
|
|
649
665
|
created_at, ingested_at, source_agent, source_agent_id, source_session,
|
|
@@ -655,7 +671,7 @@ function insertMemoriesBatch(db, memories) {
|
|
|
655
671
|
for (const mem of memories) {
|
|
656
672
|
const id = (0, node_crypto_1.randomUUID)();
|
|
657
673
|
const ts = nowIso();
|
|
658
|
-
insertMem.run(id, mem.content, mem.baseStrength ?? 0.5, ts, ts, ts, mem.sourceAgent ?? "default", mem.sourceAgentId ?? null, mem.sourceSession ?? null, mem.sourceDomain ?? null, mem.project ?? null, mem.privacy ??
|
|
674
|
+
insertMem.run(id, mem.content, mem.baseStrength ?? 0.5, ts, ts, ts, mem.sourceAgent ?? "default", mem.sourceAgentId ?? null, mem.sourceSession ?? null, mem.sourceDomain ?? null, mem.project ?? null, mem.privacy ?? "standard", mem.memoryType ?? "experience");
|
|
659
675
|
insertVec.run(id, embedToBlob(mem.embedding));
|
|
660
676
|
count++;
|
|
661
677
|
}
|
|
@@ -696,20 +712,33 @@ function getMemoriesSince(db, sinceIso) {
|
|
|
696
712
|
}
|
|
697
713
|
/**
|
|
698
714
|
* Get lesson-type memories from the last N days.
|
|
699
|
-
|
|
700
|
-
|
|
715
|
+
*
|
|
716
|
+
* #332: lessons inherit their pool's classification (confidential-pool
|
|
717
|
+
* reflection stamps them confidential at birth), and the SAME membership gate
|
|
718
|
+
* applies — `includeConfidential` defaults to FALSE (fail-closed: the
|
|
719
|
+
* agent-facing consumers — /learnings, the MCP lessons tools — serve standard
|
|
720
|
+
* lessons only unless the requester is a circle member). Server-internal
|
|
721
|
+
* consumers (nightly telemetry, the seed check, the recall-precision standing
|
|
722
|
+
* basis) pass true explicitly: they run inside the server, on the whole store.
|
|
723
|
+
*/
|
|
724
|
+
function getLessons(db, days = 7, project, opts) {
|
|
701
725
|
const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000).toISOString();
|
|
726
|
+
// The hard-omit predicate — NULL-safe by construction (NULL privacy, the
|
|
727
|
+
// pre-v27 population, reads standard).
|
|
728
|
+
const classPredicate = opts?.includeConfidential === true
|
|
729
|
+
? ""
|
|
730
|
+
: " AND (privacy IS NULL OR privacy != 'confidential')";
|
|
702
731
|
if (project) {
|
|
703
732
|
const rows = db
|
|
704
733
|
.prepare(`SELECT * FROM memories
|
|
705
|
-
WHERE memory_type = 'learnings' AND created_at > ? AND project =
|
|
734
|
+
WHERE memory_type = 'learnings' AND created_at > ? AND project = ?${classPredicate}
|
|
706
735
|
ORDER BY created_at DESC`)
|
|
707
736
|
.all(cutoff, project);
|
|
708
737
|
return rows.map(rowToMemory);
|
|
709
738
|
}
|
|
710
739
|
const rows = db
|
|
711
740
|
.prepare(`SELECT * FROM memories
|
|
712
|
-
WHERE memory_type = 'learnings' AND created_at >
|
|
741
|
+
WHERE memory_type = 'learnings' AND created_at > ?${classPredicate}
|
|
713
742
|
ORDER BY created_at DESC`)
|
|
714
743
|
.all(cutoff);
|
|
715
744
|
return rows.map(rowToMemory);
|
package/dist/type-classify.js
CHANGED
|
@@ -44,7 +44,7 @@ const node_fs_1 = require("node:fs");
|
|
|
44
44
|
const node_path_1 = require("node:path");
|
|
45
45
|
const db_js_1 = require("./db.js");
|
|
46
46
|
const state_js_1 = require("./state.js");
|
|
47
|
-
const
|
|
47
|
+
const classification_js_1 = require("./classification.js");
|
|
48
48
|
const type_labels_js_1 = require("./type-labels.js");
|
|
49
49
|
const HICORTEX_HOME = (0, paths_js_1.hicortexHome)();
|
|
50
50
|
/** Max chars of memory content fed to the classify prompt. */
|
|
@@ -194,17 +194,22 @@ async function runClassifyTypes(options = {}) {
|
|
|
194
194
|
throw new Error("[hicortex] classify-types is server-mode only (it needs the local DB). " +
|
|
195
195
|
`This machine is a client of ${config.serverUrl ?? "a remote server"} — run it on the server.`);
|
|
196
196
|
}
|
|
197
|
-
// Resolve the LLM (one model serves all phases — #231).
|
|
197
|
+
// Resolve the LLM (one model serves all phases — #231). #332: plus the
|
|
198
|
+
// confidential client — the type-classify prompt carries memory content, so
|
|
199
|
+
// each row picks the client matching its stamp; a confidential row without
|
|
200
|
+
// a client holds (infra-abort posture).
|
|
198
201
|
let llm;
|
|
202
|
+
let confidentialLlm = null;
|
|
199
203
|
if (options.llm) {
|
|
200
204
|
llm = options.llm;
|
|
201
205
|
}
|
|
202
206
|
else {
|
|
203
|
-
const resolved = (0,
|
|
204
|
-
if (!resolved.
|
|
207
|
+
const resolved = (0, classification_js_1.resolveLlmPair)(config);
|
|
208
|
+
if (!resolved.pair) {
|
|
205
209
|
throw new Error("[hicortex] classify-types: no LLM configured — run `npx @gamaze/hicortex init`.");
|
|
206
210
|
}
|
|
207
|
-
llm =
|
|
211
|
+
llm = resolved.pair.standard;
|
|
212
|
+
confidentialLlm = resolved.pair.confidential;
|
|
208
213
|
}
|
|
209
214
|
const dbPath = (0, db_js_1.resolveDbPath)(options.dbPath);
|
|
210
215
|
const db = (0, db_js_1.initDb)(dbPath);
|
|
@@ -233,7 +238,7 @@ async function runClassifyTypes(options = {}) {
|
|
|
233
238
|
const scopeSql = all
|
|
234
239
|
? "rowid > ? AND (memory_type IS NULL OR memory_type != 'learnings')"
|
|
235
240
|
: "rowid > ? AND memory_type = 'experience'";
|
|
236
|
-
const batchStmt = db.prepare(`SELECT rowid AS __rowid, id, content, memory_type FROM memories
|
|
241
|
+
const batchStmt = db.prepare(`SELECT rowid AS __rowid, id, content, memory_type, privacy FROM memories
|
|
237
242
|
WHERE ${scopeSql} ORDER BY rowid ASC LIMIT ?`);
|
|
238
243
|
// Set true when the classifier returns null (infra error): finish the
|
|
239
244
|
// current batch's already-classified writes, commit, advance cursor to the
|
|
@@ -254,7 +259,17 @@ async function runClassifyTypes(options = {}) {
|
|
|
254
259
|
// Classify (network) OUTSIDE the write transaction; collect results.
|
|
255
260
|
const writes = [];
|
|
256
261
|
for (const row of rows) {
|
|
257
|
-
|
|
262
|
+
// #332: per-row client selection — the classify prompt carries this
|
|
263
|
+
// row's content; a confidential row without a confidential client
|
|
264
|
+
// holds (infra-abort posture: untouched, retried).
|
|
265
|
+
const rowLlm = row.privacy === "confidential" ? confidentialLlm : llm;
|
|
266
|
+
if (!rowLlm) {
|
|
267
|
+
console.warn(`[hicortex] classify-types: confidential row ${row.id.slice(0, 8)} held — ` +
|
|
268
|
+
`no confidential model configured (llmConfidentialBaseUrl/ApiKey)`);
|
|
269
|
+
infraAbort = true;
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
const result = await classifyMemoryType(row.content, rowLlm);
|
|
258
273
|
if (result === null) {
|
|
259
274
|
// Infra error OR two unparseable replies — stop scanning; leave this
|
|
260
275
|
// row untouched for retry. (Two unparseable replies is rare; treating
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
* Type definitions for Hicortex OpenClaw plugin.
|
|
3
3
|
* Ported from the Python hicortex codebase.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* The two-level memory classification (#332), carried by `memories.privacy`
|
|
7
|
+
* (resurrected from its vestigial 0.16.x role — the legacy PUBLIC/WORK/
|
|
8
|
+
* PERSONAL/SENSITIVE vocabulary is dead; migration v27 maps every legacy
|
|
9
|
+
* value and NULL to 'standard'). 'confidential' is ONLY ever set by the
|
|
10
|
+
* server: derived at intake from `source_agent` × the `confidentialAgents`
|
|
11
|
+
* config roster, or stamped by the `backfill-privacy` owner command — never
|
|
12
|
+
* client-declared. The class is a hard gate on every agent-facing read path
|
|
13
|
+
* (absent/unknown requester = non-member = confidential rows omitted, single
|
|
14
|
+
* fetch 404) and routes every LLM touch of confidential text to the
|
|
15
|
+
* separately configured confidential model.
|
|
16
|
+
*/
|
|
17
|
+
export type MemoryPrivacy = "standard" | "confidential";
|
|
5
18
|
/** A stored memory record. */
|
|
6
19
|
export interface Memory {
|
|
7
20
|
id: string;
|
|
@@ -29,7 +42,14 @@ export interface Memory {
|
|
|
29
42
|
* above). NULL when the client declares none. Echoed back on /memory GET.
|
|
30
43
|
*/
|
|
31
44
|
source_domain: string | null;
|
|
32
|
-
|
|
45
|
+
/**
|
|
46
|
+
* The #332 two-level classification ('standard' | 'confidential'; see
|
|
47
|
+
* MemoryPrivacy). NULL only on rows written before migration v27 — the
|
|
48
|
+
* migration maps every legacy value to 'standard', and every insert site
|
|
49
|
+
* defaults to it, so a NULL-safe read gate (`privacy IS NULL OR
|
|
50
|
+
* privacy != 'confidential'`) treats them as standard.
|
|
51
|
+
*/
|
|
52
|
+
privacy: MemoryPrivacy | null;
|
|
33
53
|
memory_type: "experience" | "learnings" | "knowledge" | "decisions";
|
|
34
54
|
updated_at: string | null;
|
|
35
55
|
/**
|
|
@@ -162,6 +182,13 @@ export interface DeterministicMergeZoneReport {
|
|
|
162
182
|
links_repointed: number;
|
|
163
183
|
/** Clusters skipped — members disagree on project (#206 decision 2: the source_agent rail is removed). */
|
|
164
184
|
skipped_project_mismatch: number;
|
|
185
|
+
/**
|
|
186
|
+
* #332: clusters skipped — members disagree on the standard|confidential
|
|
187
|
+
* classification (the pools never cross; the classification rail re-added
|
|
188
|
+
* where #206 removed the old privacy-value rail). Optional because
|
|
189
|
+
* pre-#332 reports predate it.
|
|
190
|
+
*/
|
|
191
|
+
skipped_classification_mismatch?: number;
|
|
165
192
|
/**
|
|
166
193
|
* #393 guard-C: clusters skipped because a member pair holds a `conflicts`
|
|
167
194
|
* link — a judge-flagged genuine conflict is never blended, both records
|
|
@@ -549,23 +576,23 @@ export interface HicortexConfig {
|
|
|
549
576
|
*/
|
|
550
577
|
domains?: DomainDef[];
|
|
551
578
|
/**
|
|
552
|
-
* Success-cooldown (hours) for the
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
579
|
+
* Success-cooldown (hours) for capture-watchdog runs of the nightly (0.17,
|
|
580
|
+
* #239). The watchdog TIMER was retired in #596 — obsolete since the distill
|
|
581
|
+
* queue (#529): distillation runs on the server's scheduled drains, so
|
|
582
|
+
* capture-arrival latency serves nothing. The `--watchdog` flag remains a
|
|
583
|
+
* manual mode: when used, it captures only if MORE than this many hours have
|
|
584
|
+
* passed since the last SUCCESSFUL capture (state `lastNightly`); a failed
|
|
585
|
+
* preflight simply retries on the next manual run. Default 6. Read at
|
|
586
|
+
* runtime by the nightly, not by `init`.
|
|
559
587
|
*/
|
|
560
588
|
captureCooldownHours?: number;
|
|
561
589
|
/**
|
|
562
590
|
* Hours (0–23, local time) for the CONSOLIDATION timer — the full nightly
|
|
563
591
|
* (capture + distill + score + reflect + link), installed by `init` for
|
|
564
592
|
* server/co-located mode ONLY (0.17). Default [10, 22]: the 22:00 evening
|
|
565
|
-
* slot
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
* parseHours.
|
|
593
|
+
* slot distills the day's sessions the same day; the 10:00 morning slot
|
|
594
|
+
* catches the night's and the previous evening's tail. Omitted on client
|
|
595
|
+
* installs (no local DB → no timer). Validated by parseHours.
|
|
569
596
|
*/
|
|
570
597
|
consolidationHours?: number[];
|
|
571
598
|
/**
|
|
@@ -812,6 +839,41 @@ export interface HicortexConfig {
|
|
|
812
839
|
orgName?: string;
|
|
813
840
|
/** Plan/tier label rendered as a small badge (e.g. "Cloud · Early bird"). */
|
|
814
841
|
planLabel?: string;
|
|
842
|
+
/**
|
|
843
|
+
* #332 — the confidential-circle roster: agent ids (the same sanitized id
|
|
844
|
+
* namespace as `identityAgents` / `?agent=`) whose captures are stamped
|
|
845
|
+
* `confidential` at intake (matched by `source_agent` with the first
|
|
846
|
+
* `<harness>/` segment stripped, so a Hermes profile `nano` capturing as
|
|
847
|
+
* `hermes/nano` matches the roster entry `nano`) and whose read requests
|
|
848
|
+
* (the optional `agent` param on every agent-facing read path) see both
|
|
849
|
+
* pools. Absent/empty (the default) = no circle: every capture is
|
|
850
|
+
* standard, nothing is ever omitted, zero behavior change. Deploy-time
|
|
851
|
+
* CONTENT — the mechanism ships in code, the roster is the operator's.
|
|
852
|
+
* Boot-time (restart to apply).
|
|
853
|
+
*/
|
|
854
|
+
confidentialAgents?: string[];
|
|
855
|
+
/**
|
|
856
|
+
* #332 — the confidential model's endpoint. With `llmConfidentialApiKey`
|
|
857
|
+
* (both required; `llmConfidentialModel` optional, `llmConfidentialProvider`
|
|
858
|
+
* selects the request dialect like `llmProvider`), this configures the
|
|
859
|
+
* second LLM client that handles EVERY touch of confidential text:
|
|
860
|
+
* distillation, importance scoring, reflection, contradiction checks, domain
|
|
861
|
+
* classification, and reconsolidation verdicts. When absent while the circle
|
|
862
|
+
* is active, confidential work HOLDS (queued deliveries stay queued,
|
|
863
|
+
* sync-mode deliveries answer 503) — it never falls back to the main model.
|
|
864
|
+
* Env mirrors: HICORTEX_LLM_CONFIDENTIAL_BASE_URL/API_KEY/MODEL.
|
|
865
|
+
*/
|
|
866
|
+
llmConfidentialBaseUrl?: string;
|
|
867
|
+
/** #332 — the confidential model's API key (see llmConfidentialBaseUrl). */
|
|
868
|
+
llmConfidentialApiKey?: string;
|
|
869
|
+
/** #332 — the confidential model's id (see llmConfidentialBaseUrl). */
|
|
870
|
+
llmConfidentialModel?: string;
|
|
871
|
+
/**
|
|
872
|
+
* #332 — explicit request dialect for the confidential model's
|
|
873
|
+
* OpenAI-compatible path (the `llmProvider` precedent; today only "azure").
|
|
874
|
+
* Absent/empty → URL detection.
|
|
875
|
+
*/
|
|
876
|
+
llmConfidentialProvider?: string;
|
|
815
877
|
}
|
|
816
878
|
/** A config-owned life-sphere domain (see HicortexConfig.domains). */
|
|
817
879
|
export interface DomainDef {
|
|
@@ -878,9 +940,13 @@ export interface InsertMemoryOptions {
|
|
|
878
940
|
* accepted optionally from /distill + /ingest. Null on pre-v15 rows. */
|
|
879
941
|
sourceMachine?: string | null;
|
|
880
942
|
project?: string | null;
|
|
881
|
-
/**
|
|
882
|
-
*
|
|
883
|
-
|
|
943
|
+
/**
|
|
944
|
+
* #332 classification stamp. Absent → 'standard' (the fail-closed default;
|
|
945
|
+
* callers that distill a confidential pool pass 'confidential' explicitly).
|
|
946
|
+
* Server-derived only — the intake handlers pass the source_agent × roster
|
|
947
|
+
* derivation, never a client-declared value.
|
|
948
|
+
*/
|
|
949
|
+
privacy?: MemoryPrivacy | null;
|
|
884
950
|
memoryType?: string;
|
|
885
951
|
baseStrength?: number;
|
|
886
952
|
createdAt?: string;
|
package/dist/uninstall.js
CHANGED
|
@@ -124,11 +124,12 @@ async function runUninstall() {
|
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
126
|
console.log();
|
|
127
|
-
// 1. Stop and remove daemon +
|
|
128
|
-
//
|
|
129
|
-
// scheduled
|
|
130
|
-
//
|
|
131
|
-
//
|
|
127
|
+
// 1. Stop and remove the daemon + every Hicortex timer (or a timer keeps
|
|
128
|
+
// firing against a half-removed install). Current installs have one
|
|
129
|
+
// scheduled job — the consolidation timer (hicortex-nightly; server /
|
|
130
|
+
// co-located only). Legacy units are removed too: the capture watchdog
|
|
131
|
+
// (hicortex-capture, retired #596 — an old install keeps it until its
|
|
132
|
+
// next init/uninstall) and the pre-0.17 single nightly.
|
|
132
133
|
const os = (0, node_os_1.platform)();
|
|
133
134
|
if (os === "darwin") {
|
|
134
135
|
for (const name of ["com.gamaze.hicortex.plist", "com.gamaze.hicortex-nightly.plist", "com.gamaze.hicortex-capture.plist"]) {
|
|
@@ -27,6 +27,10 @@ The plugin warns once at startup when `hicortex_url` is plain `http://` on a non
|
|
|
27
27
|
|
|
28
28
|
That's the whole surface. No `sync_turn`, no compaction/session-end capture — those are intentionally absent.
|
|
29
29
|
|
|
30
|
+
### Confidential-circle membership on every read (0.7.11, server ≥ 0.27)
|
|
31
|
+
|
|
32
|
+
Servers with a `confidentialAgents` roster (the #332 classification) serve the **confidential pool** only to requests that identify a rostered agent — every other caller gets a hard omit (a confidential memory's single fetch answers 404). The plugin threads its already-resolved profile id (the same `agent_name` / `HERMES_PROFILE` / `HERMES_HOME` resolution as the standing-context layer) into **every read call**: the per-turn `/recall-index`, the legacy `/search` fallback, the session-start lessons fetch, and the `hicortex_search` / `hicortex_get` / `hicortex_recent` / `hicortex_lessons` / `hicortex_graph` tools. A rostered profile therefore sees its own confidential memories and confidential lessons end-to-end; an unrostered profile sees exactly what it saw before. Servers without the feature ignore the parameter — the plugin change is invisible on old servers, and nothing changes on servers with no roster configured.
|
|
33
|
+
|
|
30
34
|
### Pushed recall index (0.7.0, server ≥ 0.14)
|
|
31
35
|
|
|
32
36
|
Instead of injecting full memory content every turn, `prefetch` sends the user's message to the server's `POST /recall-index` and injects the returned **index block** verbatim — one line per memory (id, title, date), capped and relevance-gated server-side. The agent fetches full content with `hicortex_get(id)` only when a line is actually relevant; that fetch is what strengthens the memory (exposure ≠ use). All tuning knobs (`recallMaxItems`, `recallMinSimilarity`, `recallReshowTurns`, `recallMinPromptChars`, …) are release-managed constants on the server (they ship with each release and change only with published eval evidence) — the plugin carries none, and neither does the server's config. Dedup is turn-based and server-side per session; the plugin resets it at `initialize` (the Hermes `MemoryProvider` interface exposes no compaction signal, so a mid-session context rebuild cannot trigger a reset — the server's turn-based re-show window covers that gap). Against a pre-0.14 server (404) the plugin falls back to the 0.6.x `GET /search` full-content prefetch, fail-soft, re-probing the endpoint every 10 minutes so a later server upgrade is picked up without a gateway restart. The recall calls carry the profile's configured `default_project` (and `mission_domains`) and use a short dedicated timeout (1.5 s) so a slow server can never stall a turn. (`privacy_filter` is deprecated since 0.7.2 — the server ignores privacy; see [Configuration](#configure-activate).)
|
|
@@ -176,10 +176,15 @@ class HicortexClient:
|
|
|
176
176
|
limit: int = 5,
|
|
177
177
|
project: Optional[str] = None,
|
|
178
178
|
privacy: Optional[str] = None,
|
|
179
|
+
agent: Optional[str] = None,
|
|
179
180
|
) -> list[dict]:
|
|
181
|
+
"""Search shared memory. ``agent`` (plugin 0.7.11, server ≥ #332) is
|
|
182
|
+
this profile's id — a server-rostered id also sees the confidential
|
|
183
|
+
pool; absent/unknown stays non-member (the server hard-omits
|
|
184
|
+
confidential rows). Older servers ignore the parameter."""
|
|
180
185
|
return self._get(
|
|
181
186
|
"/search",
|
|
182
|
-
{"query": query, "limit": limit, "project": project, "privacy": privacy},
|
|
187
|
+
{"query": query, "limit": limit, "project": project, "privacy": privacy, "agent": agent},
|
|
183
188
|
).get("results", [])
|
|
184
189
|
|
|
185
190
|
def recent(
|
|
@@ -187,13 +192,18 @@ class HicortexClient:
|
|
|
187
192
|
project: Optional[str] = None,
|
|
188
193
|
limit: int = 10,
|
|
189
194
|
privacy: Optional[str] = None,
|
|
195
|
+
agent: Optional[str] = None,
|
|
190
196
|
) -> list[dict]:
|
|
197
|
+
"""Recent memories. ``agent`` — see :meth:`search` (#332 membership)."""
|
|
191
198
|
return self._get(
|
|
192
|
-
"/recent",
|
|
199
|
+
"/recent",
|
|
200
|
+
{"project": project, "limit": limit, "privacy": privacy, "agent": agent},
|
|
193
201
|
).get("results", [])
|
|
194
202
|
|
|
195
|
-
def lessons(self) -> dict[str, Any]:
|
|
196
|
-
|
|
203
|
+
def lessons(self, agent: Optional[str] = None) -> dict[str, Any]:
|
|
204
|
+
"""Lessons + memory index. ``agent`` — see :meth:`search` (#332:
|
|
205
|
+
confidential lessons serve to rostered agents only)."""
|
|
206
|
+
return self._get("/lessons", {"agent": agent})
|
|
197
207
|
|
|
198
208
|
def context(self, agent: Optional[str] = None) -> dict[str, Any]:
|
|
199
209
|
"""Standing context layer (L2). When ``agent`` is set, the server
|
|
@@ -213,7 +223,10 @@ class HicortexClient:
|
|
|
213
223
|
limit: Optional[int] = None,
|
|
214
224
|
domain: Optional[str] = None,
|
|
215
225
|
relationship: Optional[str] = None,
|
|
226
|
+
agent: Optional[str] = None,
|
|
216
227
|
) -> dict[str, Any]:
|
|
228
|
+
"""Graph query (neighbors/hubs/path). ``agent`` — see :meth:`search`
|
|
229
|
+
(#332 membership; the export op is the ungated owner surface)."""
|
|
217
230
|
return self._get(
|
|
218
231
|
"/graph",
|
|
219
232
|
{
|
|
@@ -223,6 +236,7 @@ class HicortexClient:
|
|
|
223
236
|
"limit": limit,
|
|
224
237
|
"domain": domain,
|
|
225
238
|
"relationship": relationship,
|
|
239
|
+
"agent": agent,
|
|
226
240
|
},
|
|
227
241
|
)
|
|
228
242
|
|
|
@@ -281,6 +295,7 @@ class HicortexClient:
|
|
|
281
295
|
project: Optional[str] = None,
|
|
282
296
|
privacy: Optional[str] = None,
|
|
283
297
|
mission_domains: Optional[list[str]] = None,
|
|
298
|
+
agent: Optional[str] = None,
|
|
284
299
|
) -> tuple[int, dict[str, Any]]:
|
|
285
300
|
"""Pushed recall index (0.14). ``prompt`` → ``{block, shown, turn}``
|
|
286
301
|
where ``block`` is None when nothing is new/relevant; ``reset=True``
|
|
@@ -288,7 +303,11 @@ class HicortexClient:
|
|
|
288
303
|
``privacy`` (CSV accepted server-side), and ``mission_domains`` (list)
|
|
289
304
|
scope the recall — all SOFT on a 0.16+ server (affinity boosts, never
|
|
290
305
|
hard filters); ``project``/``privacy`` stay hard on older servers.
|
|
291
|
-
|
|
306
|
+
``agent`` (plugin 0.7.11, server ≥ #332) is this profile's id for the
|
|
307
|
+
confidential-circle membership gate (rostered ids see both pools in
|
|
308
|
+
the index; absent/unknown hard-omits confidential rows). Older servers
|
|
309
|
+
ignore the field. Returns the status so the caller can old-server-guard
|
|
310
|
+
on 404."""
|
|
292
311
|
body: dict[str, Any] = {"session_id": session_id}
|
|
293
312
|
if reset:
|
|
294
313
|
body["reset"] = True
|
|
@@ -300,16 +319,24 @@ class HicortexClient:
|
|
|
300
319
|
body["privacy"] = privacy
|
|
301
320
|
if mission_domains:
|
|
302
321
|
body["mission_domains"] = mission_domains
|
|
322
|
+
if agent:
|
|
323
|
+
body["agent"] = agent
|
|
303
324
|
return self._post("/recall-index", body, timeout=self.RECALL_TIMEOUT)
|
|
304
325
|
|
|
305
326
|
def get_memory(
|
|
306
|
-
self,
|
|
327
|
+
self,
|
|
328
|
+
id: str,
|
|
329
|
+
privacy: Optional[str] = None,
|
|
330
|
+
agent: Optional[str] = None,
|
|
307
331
|
) -> tuple[int, dict[str, Any]]:
|
|
308
332
|
"""Fetch ONE memory's full content (lazy-load counterpart of the recall
|
|
309
333
|
index). The server marks it as USED (access_count + 1) and returns
|
|
310
334
|
``{memory, citation}`` — citation is server-rendered so every harness
|
|
311
|
-
surfaces the same provenance norm. ``
|
|
312
|
-
|
|
335
|
+
surfaces the same provenance norm. ``agent`` (plugin 0.7.11, server ≥
|
|
336
|
+
#332) is the membership gate: a confidential memory fetched by a
|
|
337
|
+
non-member answers 404 (the server never reveals existence)."""
|
|
313
338
|
return self._get_with_status(
|
|
314
|
-
"/memory",
|
|
339
|
+
"/memory",
|
|
340
|
+
{"id": id, "privacy": privacy, "agent": agent},
|
|
341
|
+
timeout=self.RECALL_TIMEOUT,
|
|
315
342
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
name: hicortex
|
|
2
|
-
version: 0.7.
|
|
2
|
+
version: 0.7.11
|
|
3
3
|
description: "Self-learning memory for Hermes agents — every session is distilled into lessons overnight, and your agent wakes up wiser. Pushes a compact per-turn recall index (lazy-loaded with hicortex_get), injects fresh lessons plus a per-agent standing context block, and exposes the full 9-tool memory surface (search, get, recent, ingest, lessons, index, graph, update, delete) via a shared Hicortex server. Stdlib-only. AFTER INSTALL: run `hermes memory setup`, select hicortex, enter the server URL + token (see the token env var description for where to find it)."
|
|
4
4
|
pip_dependencies: []
|
|
5
5
|
hooks: []
|
|
@@ -333,6 +333,11 @@ class HicortexProvider(MemoryProvider):
|
|
|
333
333
|
project=self._project,
|
|
334
334
|
privacy=self._privacy,
|
|
335
335
|
mission_domains=self._mission_domains,
|
|
336
|
+
# #332: the profile's id rides every read call — the
|
|
337
|
+
# server's confidential-circle gate keys on it (rostered
|
|
338
|
+
# ids see both pools; absent/unknown hard-omits). Old
|
|
339
|
+
# servers ignore the field.
|
|
340
|
+
agent=self._agent_name,
|
|
336
341
|
)
|
|
337
342
|
if status == 404:
|
|
338
343
|
# Old-server guard: pre-0.14 has no /recall-index. Latch
|
|
@@ -385,7 +390,11 @@ class HicortexProvider(MemoryProvider):
|
|
|
385
390
|
return cached
|
|
386
391
|
try:
|
|
387
392
|
hits = client.search(
|
|
388
|
-
query,
|
|
393
|
+
query,
|
|
394
|
+
limit=self._recall_limit,
|
|
395
|
+
project=self._project,
|
|
396
|
+
privacy=self._privacy,
|
|
397
|
+
agent=self._agent_name,
|
|
389
398
|
)
|
|
390
399
|
return self._format_hits(hits)
|
|
391
400
|
except Exception as e:
|
|
@@ -408,7 +417,11 @@ class HicortexProvider(MemoryProvider):
|
|
|
408
417
|
def _bg() -> None:
|
|
409
418
|
try:
|
|
410
419
|
hits = client.search(
|
|
411
|
-
query,
|
|
420
|
+
query,
|
|
421
|
+
limit=self._recall_limit,
|
|
422
|
+
project=self._project,
|
|
423
|
+
privacy=self._privacy,
|
|
424
|
+
agent=self._agent_name,
|
|
412
425
|
)
|
|
413
426
|
self._prefetch_cache[key] = self._format_hits(hits)
|
|
414
427
|
except Exception as e:
|
|
@@ -467,7 +480,9 @@ class HicortexProvider(MemoryProvider):
|
|
|
467
480
|
|
|
468
481
|
def _lessons_block(self, client: HicortexClient) -> str:
|
|
469
482
|
try:
|
|
470
|
-
|
|
483
|
+
# #332: the profile id threads into the lessons fetch too —
|
|
484
|
+
# confidential lessons serve to rostered agents only.
|
|
485
|
+
data = client.lessons(agent=self._agent_name)
|
|
471
486
|
except Exception as e:
|
|
472
487
|
logger.debug("hicortex lessons fetch failed: %s", e)
|
|
473
488
|
return ""
|
|
@@ -690,6 +705,7 @@ class HicortexProvider(MemoryProvider):
|
|
|
690
705
|
args.get("query", ""),
|
|
691
706
|
limit=int(args.get("limit", 5)),
|
|
692
707
|
project=args.get("project") or self._project,
|
|
708
|
+
agent=self._agent_name,
|
|
693
709
|
)
|
|
694
710
|
return json.dumps(hits)
|
|
695
711
|
|
|
@@ -698,8 +714,12 @@ class HicortexProvider(MemoryProvider):
|
|
|
698
714
|
if not id_val:
|
|
699
715
|
return json.dumps({"error": "id is required"})
|
|
700
716
|
# The configured privacy filter rides along (review F1): an
|
|
701
|
-
# out-of-scope memory reads as 404 server-side.
|
|
702
|
-
|
|
717
|
+
# out-of-scope memory reads as 404 server-side. #332: so does
|
|
718
|
+
# the profile id — a confidential memory is a clean 404 for a
|
|
719
|
+
# non-member (existence never revealed).
|
|
720
|
+
status, resp = client.get_memory(
|
|
721
|
+
id_val, privacy=self._privacy, agent=self._agent_name
|
|
722
|
+
)
|
|
703
723
|
if status == 404:
|
|
704
724
|
# Either no such memory (0.14+) or a pre-0.14 server with
|
|
705
725
|
# no /memory endpoint — the id hint covers the common case.
|
|
@@ -720,6 +740,7 @@ class HicortexProvider(MemoryProvider):
|
|
|
720
740
|
hits = client.recent(
|
|
721
741
|
project=args.get("project") or self._project,
|
|
722
742
|
limit=int(args.get("limit", 10)),
|
|
743
|
+
agent=self._agent_name,
|
|
723
744
|
)
|
|
724
745
|
return json.dumps(hits)
|
|
725
746
|
|
|
@@ -739,7 +760,7 @@ class HicortexProvider(MemoryProvider):
|
|
|
739
760
|
return json.dumps({"id": id_val, "message": f"Memory stored (id: {id_val[:8]})"})
|
|
740
761
|
|
|
741
762
|
elif tool_name == "hicortex_lessons":
|
|
742
|
-
data = client.lessons()
|
|
763
|
+
data = client.lessons(agent=self._agent_name)
|
|
743
764
|
lessons = (data.get("lessons") or [])
|
|
744
765
|
if not lessons:
|
|
745
766
|
return json.dumps({"message": "No Learnings found."})
|
|
@@ -757,6 +778,7 @@ class HicortexProvider(MemoryProvider):
|
|
|
757
778
|
limit=args.get("limit"),
|
|
758
779
|
domain=args.get("domain"),
|
|
759
780
|
relationship=args.get("relationship"),
|
|
781
|
+
agent=self._agent_name,
|
|
760
782
|
)
|
|
761
783
|
return json.dumps(result)
|
|
762
784
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gamaze/hicortex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Persistent agent identity for AI agents \u2014 a hand-edited identity layer, nightly-distilled experience, and lessons injected every session, shared across your whole fleet. Works with Hermes, OpenClaw, Claude Code, Pi, and opencode.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
package/server.json
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
"name": "io.github.gamaze-labs/hicortex",
|
|
4
4
|
"title": "Hicortex \u2014 AI Fleet Memory",
|
|
5
5
|
"description": "Shared fleet memory for AI agents: nightly self-correction, recall every prompt (supported agents).",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.27.0",
|
|
7
7
|
"packages": [
|
|
8
8
|
{
|
|
9
9
|
"registryType": "npm",
|
|
10
10
|
"identifier": "@gamaze/hicortex",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.27.0",
|
|
12
12
|
"transport": {
|
|
13
13
|
"type": "stdio",
|
|
14
14
|
"command": "npx",
|