@psiclawops/hypermem 0.9.0 → 0.9.2

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.
Files changed (43) hide show
  1. package/ARCHITECTURE.md +2 -2
  2. package/CHANGELOG.md +17 -1
  3. package/INSTALL.md +9 -0
  4. package/dist/background-indexer.js +9 -9
  5. package/dist/cross-agent.d.ts +1 -1
  6. package/dist/cross-agent.js +17 -17
  7. package/dist/dreaming-promoter.d.ts +2 -2
  8. package/dist/dreaming-promoter.js +3 -3
  9. package/dist/fact-store.js +1 -1
  10. package/dist/index.d.ts +11 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +56 -9
  13. package/dist/seed.d.ts +1 -1
  14. package/dist/seed.js +1 -1
  15. package/dist/session-flusher.d.ts +2 -2
  16. package/dist/session-flusher.js +2 -2
  17. package/dist/spawn-context.d.ts +1 -1
  18. package/dist/spawn-context.js +1 -1
  19. package/dist/topic-store.js +5 -5
  20. package/dist/topic-synthesizer.js +1 -1
  21. package/dist/trigger-registry.d.ts +1 -1
  22. package/dist/trigger-registry.js +4 -4
  23. package/dist/types.d.ts +2 -2
  24. package/docs/MEMORY_MD_AUTHORING.md +3 -3
  25. package/docs/ROADMAP.md +13 -4
  26. package/install.sh +34 -0
  27. package/memory-plugin/package.json +4 -2
  28. package/package.json +4 -1
  29. package/plugin/package.json +4 -2
  30. package/dist/compositor-utils.d.ts +0 -31
  31. package/dist/compositor-utils.d.ts.map +0 -1
  32. package/dist/compositor-utils.js +0 -47
  33. package/dist/content-hash.d.ts +0 -43
  34. package/dist/content-hash.d.ts.map +0 -1
  35. package/dist/content-hash.js +0 -75
  36. package/memory-plugin/dist/index.d.ts +0 -24
  37. package/memory-plugin/dist/index.d.ts.map +0 -1
  38. package/memory-plugin/dist/index.js +0 -350
  39. package/memory-plugin/dist/index.js.map +0 -1
  40. package/plugin/dist/index.d.ts +0 -208
  41. package/plugin/dist/index.d.ts.map +0 -1
  42. package/plugin/dist/index.js +0 -3474
  43. package/plugin/dist/index.js.map +0 -1
@@ -13,7 +13,7 @@ import { createHash } from 'node:crypto';
13
13
  export const TRIGGER_REGISTRY_VERSION = '1.0.0';
14
14
  /**
15
15
  * Default trigger registry for standard ACA collections.
16
- * Covers the core ACA offload use case from carol's spec.
16
+ * Covers the core ACA offload use case from agent6's spec.
17
17
  */
18
18
  export const TRIGGER_REGISTRY = [
19
19
  {
@@ -69,7 +69,7 @@ export const TRIGGER_REGISTRY = [
69
69
  ],
70
70
  maxTokens: 800,
71
71
  maxChunks: 2,
72
- owner: 'alice',
72
+ owner: 'agent1',
73
73
  category: 'operations',
74
74
  description: 'Agent operational procedures: boot sequence, heartbeat, work queue, session startup',
75
75
  },
@@ -106,7 +106,7 @@ export const TRIGGER_REGISTRY = [
106
106
  ],
107
107
  maxTokens: 1500,
108
108
  maxChunks: 4,
109
- owner: 'alice',
109
+ owner: 'agent1',
110
110
  category: 'memory',
111
111
  description: 'Decision history: past choices, previously agreed approaches, recalled context',
112
112
  },
@@ -132,7 +132,7 @@ export const TRIGGER_REGISTRY = [
132
132
  ],
133
133
  maxTokens: 1200,
134
134
  maxChunks: 3,
135
- owner: 'alice',
135
+ owner: 'agent1',
136
136
  category: 'operations',
137
137
  description: 'Agent tooling reference: CLI commands, config paths, deployment procedures, quick reference',
138
138
  },
package/dist/types.d.ts CHANGED
@@ -72,7 +72,7 @@ export type FactScope = 'agent' | 'session' | 'user';
72
72
  /**
73
73
  * Memory visibility levels:
74
74
  * - private: Only the owning agent can read. Identity, SOUL, personal reflections.
75
- * - org: Agents in the same org (e.g., alice's directors: Hank, Jack, Irene).
75
+ * - org: Agents in the same org (e.g., agent1's directors: Pylon, Vigil, Plane).
76
76
  * - council: All council seats can read.
77
77
  * - fleet: Any agent in the fleet can read.
78
78
  */
@@ -646,7 +646,7 @@ export interface ProviderMessage {
646
646
  * to identify high-signal unprocessed messages.
647
647
  *
648
648
  * Stored in Redis (hm:{a}:s:{s}:cursor) with dual-write to SQLite for
649
- * durability across Redis eviction (bob Gate 2).
649
+ * durability across Redis eviction (agent2 Gate 2).
650
650
  */
651
651
  export interface SessionCursor {
652
652
  /** StoredMessage.id of the newest message included in the last window */
@@ -123,14 +123,14 @@ A simple operating rule works well:
123
123
  Bad:
124
124
 
125
125
  ```md
126
- - Forge runs copilot-local/claude-sonnet-4.6
126
+ - Agent runs provider/model-X
127
127
  ```
128
128
 
129
129
  Better:
130
130
 
131
131
  ```md
132
- - Forge standard model was copilot-local/claude-sonnet-4.6 as of 2026-04-11; recheck after provider routing changes
133
- → memory_search("Forge standard model 2026-04-11 provider routing")
132
+ - Agent standard model was provider/model-X as of YYYY-MM-DD; recheck after provider routing changes
133
+ → memory_search("agent standard model YYYY-MM-DD provider routing")
134
134
  ```
135
135
 
136
136
  ## Relationship to daily memory files
package/docs/ROADMAP.md CHANGED
@@ -12,7 +12,15 @@ For shipped capabilities, see [CHANGELOG.md](../CHANGELOG.md) and [ARCHITECTURE.
12
12
  ## Current state
13
13
 
14
14
  ### Released
15
- - Current release: **0.8.6**
15
+ - Current release: **0.9.0** — adaptive context lifecycle. Published 2026-04-25.
16
+ - Internal `main`: `8f805b8`
17
+ - Public `main`: `25dd469`
18
+ - Public tag `v0.9.0`: pushed
19
+ - Public CI: green (`24942512824`)
20
+ - GitHub Release: https://github.com/PsiClawOps/hypermem/releases/tag/v0.9.0
21
+ - npm at 0.9.0: `@psiclawops/hypermem`, `@psiclawops/hypercompositor`, `@psiclawops/hypermem-memory`
22
+ - New install validator shipped: `hypermem-doctor`
23
+ - Previous release: **0.8.6**
16
24
 
17
25
  ### Landed on `main` after 0.8.6
18
26
  In the order work actually landed:
@@ -84,7 +92,7 @@ Final closeout work now complete:
84
92
  Rule going forward: do not reopen warm restore from historical planning notes. New warm-restore work needs a fresh defect, measurement gap, or roadmap item.
85
93
 
86
94
  ## 2. HyperMem 0.9.0 adaptive context lifecycle
87
- Status: **OPEN, release-candidate pending tag validation.**
95
+ Status: **CLOSED — shipped 2026-04-25.** Public tag `v0.9.0` (`25dd469`), GitHub Release published, all three npm packages at 0.9.0. `hypermem-doctor` shipped as part of this release.
88
96
 
89
97
  The core runtime slices have landed: the pure adaptive lifecycle policy kernel, compose diagnostics wiring, afterTurn Redis gradient-cap wiring, adaptive recall breadth, adaptive eviction ordering, lifecycle telemetry, report tooling, forked-context lifecycle integration, and metadata-only topic-signal report classification. The first live telemetry baseline is populated; it shows steady/warmup behavior with zero lifecycle-band divergence, so no threshold tuning is warranted from the current evidence.
90
98
 
@@ -168,7 +176,7 @@ Phase 5 stays important, but it is not the next sprint until the higher-priority
168
176
  |---|---|---|
169
177
  | Runtime diagnostics API allowlist defect | ✅ CLOSED | Verified installed OpenClaw runtime can reach `memory-core/runtime-api.js`; re-open only with a fresh public-surface failure trace. |
170
178
  | Topic synthesis bridge defect | ✅ CLOSED | Fixed in `8b9f928`; CI `24917765384` passed. |
171
- | Adaptive context lifecycle (0.9.0) | 🟡 OPEN | Kernel, compose diagnostics, afterTurn gradient cap, recall breadth, eviction order, lifecycle telemetry, report tooling, forked-context integration, and topic-signal report classification are landed; vector coverage, first live lifecycle baseline, and the 0.9.0 topic-bearing compose evidence gate are closed; threshold tuning remains deferred until future live evidence warrants it. |
179
+ | Adaptive context lifecycle (0.9.0) | SHIPPED | Released 2026-04-25 as 0.9.0. Threshold tuning remains deferred until future live evidence warrants it. |
172
180
  | Vector coverage repair gate | ✅ CLOSED | `embed-existing` now supports knowledge and eligibility-aware coverage reporting; production vectors reached facts 113/113, knowledge 85/85, episodes 30,121/30,121 eligible coverage on 2026-04-24. |
173
181
  | Contradiction-aware decay | 🟡 OPEN | Prevents stale-fact poisoning after architectural pivots. |
174
182
  | Turn DAG Phase 5 storage/perf | 🟡 OPEN | Important, but later than the items above. |
@@ -189,7 +197,8 @@ Phase 5 stays important, but it is not the next sprint until the higher-priority
189
197
  | Strict topic mode legacy NULL backfill | 🟡 DEFERRED | Wait for stable topic coverage before running the migration/backfill. |
190
198
  | ACA Step 4 retrieval stubs replace static files | 🔲 PENDING | Still relevant, but downstream of lifecycle/diagnostics stability. Do not start from older ACA notes. |
191
199
  | ACA Step 5 governance context assembly | 🔲 PENDING | Still relevant, but depends on Step 4. Do not start until Step 4 has an accepted implementation contract. |
192
- | Codex harness compatibility for HyperMem hooks | 🔲 TRIAGE | OpenClaw is generalizing the embedded executor (PI stays default; Codex is a registered plugin harness via `agents.defaults.embeddedHarness`). When a turn runs through the Codex harness, OpenClaw owns mirror transcript + tool dispatch but Codex owns the agent loop and native compaction. Investigate before any agent moves off PI: (1) whether HyperMem's `before_prompt_build`, `before_compaction`, `after_compaction`, `before_message_write`, `llm_input`, `llm_output`, `agent_end`, `after_tool_call` hooks fire with the same timing on Codex turns; (2) collision between HyperCompositor compaction and Codex native app-server compaction (need an explicit disable on one side or a coordination contract); (3) whether the locally mirrored transcript loses any content the indexer assumes is present; (4) `subagent` `context: "fork"` behavior when parent runs on Codex (parent JSONL is mirror, not source of truth); (5) keep `openai-codex/*` provider routes (PI under the hood) distinct from `codex/*` runtime selection (Codex harness). Pilot on one non-critical agent with `runtime: "codex"`, `fallback: "pi"` once the parity gap closes; do not adopt fleet-wide before then. Surfaced 2026-04-24 by ragesaq. |
200
+ | Tokenjuice + HyperMem tool-result pipeline integration | 🔲 TRIAGE | OpenClaw 2026.4.24 ships `tokenjuice`, a deterministic rule-based tool-result pre-trim hook (collapses ANSI/build noise/repeated frames). It and HyperMem's size-based `tool_result_trim` both fire on tool results. Three integration concerns before fleet-wide enable: (1) **Hook ordering**: tokenjuice must run before HyperMem trim so HyperMem only collapses what tokenjuice cannot already remove deterministically. Reverse order wastes savings. (2) **Tool-artifact store**: HyperMem's L4 durable artifact store must capture the **untransformed** tool result, not the tokenjuice-trimmed one. The hook chain should pass `{ raw, transformed }` so artifacts get `raw` while message stream gets `transformed`. (3) **Telemetry**: unify `tool_result_trim_event` schema with `source: "tokenjuice" \| "hypermem"` and per-turn rollup so operators see one report. Sequencing: pilot tokenjuice standalone on one heavy-exec agent (HyperBuilder generator candidate) to measure rule-trim savings on our actual workloads before formalizing the contract. Do not write the contract before we have numbers. Surfaced 2026-04-25 during operator review. |
201
+ | Codex harness compatibility for HyperMem hooks | 🔲 TRIAGE | OpenClaw is generalizing the embedded executor (PI stays default; Codex is a registered plugin harness via `agents.defaults.embeddedHarness`). When a turn runs through the Codex harness, OpenClaw owns mirror transcript + tool dispatch but Codex owns the agent loop and native compaction. Investigate before any agent moves off PI: (1) whether HyperMem's `before_prompt_build`, `before_compaction`, `after_compaction`, `before_message_write`, `llm_input`, `llm_output`, `agent_end`, `after_tool_call` hooks fire with the same timing on Codex turns; (2) collision between HyperCompositor compaction and Codex native app-server compaction (need an explicit disable on one side or a coordination contract); (3) whether the locally mirrored transcript loses any content the indexer assumes is present; (4) `subagent` `context: "fork"` behavior when parent runs on Codex (parent JSONL is mirror, not source of truth); (5) keep `openai-codex/*` provider routes (PI under the hood) distinct from `codex/*` runtime selection (Codex harness). Pilot on one non-critical agent with `runtime: "codex"`, `fallback: "pi"` once the parity gap closes; do not adopt fleet-wide before then. Surfaced 2026-04-24 during operator review. |
193
202
 
194
203
  ---
195
204
 
package/install.sh CHANGED
@@ -18,6 +18,7 @@ CONFIG_FILE="$HOME/.openclaw/hypermem/config.json"
18
18
  ASSUME_YES=false
19
19
  SKIP_NPM=false
20
20
  SKIP_STAGE=false
21
+ DRY_RUN=false
21
22
 
22
23
  usage() {
23
24
  cat <<EOF
@@ -32,6 +33,7 @@ Options:
32
33
  --runtime-dir <p> staged OpenClaw runtime dir, default: ~/.openclaw/plugins/hypermem
33
34
  --skip-npm use existing package in install dir
34
35
  --skip-stage install package only, do not run hypermem-install
36
+ --dry-run print planned actions without installing, staging, or writing config
35
37
  --help show this help
36
38
 
37
39
  Environment overrides:
@@ -49,6 +51,7 @@ while [[ $# -gt 0 ]]; do
49
51
  --runtime-dir) RUNTIME_DIR="$2"; shift 2 ;;
50
52
  --skip-npm) SKIP_NPM=true; shift ;;
51
53
  --skip-stage) SKIP_STAGE=true; shift ;;
54
+ --dry-run) DRY_RUN=true; shift ;;
52
55
  --help|-h) usage; exit 0 ;;
53
56
  *) echo -e "${RED}Unknown option:${NC} $1" >&2; usage; exit 1 ;;
54
57
  esac
@@ -57,6 +60,7 @@ done
57
60
  info() { echo -e " ${CYAN}→${NC} $*"; }
58
61
  success() { echo -e " ${GREEN}✓${NC} $*"; }
59
62
  warn() { echo -e " ${YELLOW}⚠${NC} $*"; }
63
+ dryrun() { echo -e " ${YELLOW}DRY-RUN${NC} $*"; }
60
64
  die() { echo -e " ${RED}✗${NC} $*" >&2; exit 1; }
61
65
 
62
66
  confirm() {
@@ -86,6 +90,10 @@ preflight() {
86
90
  command -v npm >/dev/null 2>&1 || die "npm is required"
87
91
  success "npm $(npm --version)"
88
92
 
93
+ if $DRY_RUN; then
94
+ warn "dry-run mode: no package install, runtime staging, config write, or gateway change will be performed"
95
+ fi
96
+
89
97
  if command -v openclaw >/dev/null 2>&1; then
90
98
  success "openclaw CLI found"
91
99
  openclaw gateway status >/dev/null 2>&1 || warn "OpenClaw gateway is not running or not onboarded yet. Complete OpenClaw setup before activation."
@@ -96,6 +104,12 @@ preflight() {
96
104
 
97
105
  install_package() {
98
106
  echo -e "\n${BOLD} Package install${NC}"
107
+ if $DRY_RUN; then
108
+ dryrun "would create/install package directory: $INSTALL_DIR"
109
+ dryrun "would install package: $PACKAGE"
110
+ return
111
+ fi
112
+
99
113
  mkdir -p "$INSTALL_DIR"
100
114
  if [[ ! -f "$INSTALL_DIR/package.json" ]]; then
101
115
  info "initializing $INSTALL_DIR"
@@ -114,6 +128,11 @@ install_package() {
114
128
  }
115
129
 
116
130
  backup_runtime() {
131
+ if $DRY_RUN; then
132
+ dryrun "would check for existing runtime and optionally back up: $RUNTIME_DIR"
133
+ return 0
134
+ fi
135
+
117
136
  [[ -e "$RUNTIME_DIR" ]] || return 0
118
137
  local backup
119
138
  backup="${RUNTIME_DIR}.backup.$(date +%Y%m%d-%H%M%S)"
@@ -132,6 +151,11 @@ stage_runtime() {
132
151
  return
133
152
  fi
134
153
 
154
+ if $DRY_RUN; then
155
+ dryrun "would run runtime installer into: $RUNTIME_DIR"
156
+ return
157
+ fi
158
+
135
159
  local installer="$INSTALL_DIR/node_modules/@psiclawops/hypermem/scripts/install-runtime.mjs"
136
160
  [[ -f "$installer" ]] || die "missing runtime installer: $installer"
137
161
  backup_runtime
@@ -141,6 +165,11 @@ stage_runtime() {
141
165
 
142
166
  write_minimal_config_if_missing() {
143
167
  echo -e "\n${BOLD} Config check${NC}"
168
+ if $DRY_RUN; then
169
+ dryrun "would preserve existing config or write lightweight starter config: $CONFIG_FILE"
170
+ return
171
+ fi
172
+
144
173
  if [[ -f "$CONFIG_FILE" ]]; then
145
174
  success "existing config preserved: $CONFIG_FILE"
146
175
  return
@@ -210,6 +239,11 @@ JSON
210
239
 
211
240
  verify_stage() {
212
241
  echo -e "\n${BOLD} Stage verification${NC}"
242
+ if $DRY_RUN; then
243
+ dryrun "would verify runtime payload under: $RUNTIME_DIR"
244
+ return
245
+ fi
246
+
213
247
  [[ -d "$RUNTIME_DIR/dist" ]] || die "missing $RUNTIME_DIR/dist"
214
248
  [[ -d "$RUNTIME_DIR/plugin/dist" ]] || die "missing $RUNTIME_DIR/plugin/dist"
215
249
  [[ -d "$RUNTIME_DIR/memory-plugin/dist" ]] || die "missing $RUNTIME_DIR/memory-plugin/dist"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@psiclawops/hypermem-memory",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "HyperMem memory plugin for OpenClaw — bridges HyperMem retrieval into the memory slot",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -35,10 +35,12 @@
35
35
  },
36
36
  "scripts": {
37
37
  "build": "tsc",
38
+ "prepublishOnly": "npm run build",
39
+ "prepack": "npm run build",
38
40
  "typecheck": "tsc --noEmit"
39
41
  },
40
42
  "dependencies": {
41
- "@psiclawops/hypermem": "0.9.0"
43
+ "@psiclawops/hypermem": "0.9.2"
42
44
  },
43
45
  "devDependencies": {
44
46
  "openclaw": "*",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@psiclawops/hypermem",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Agent-centric memory and context composition engine for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,6 +24,8 @@
24
24
  },
25
25
  "scripts": {
26
26
  "build": "tsc",
27
+ "prepublishOnly": "npm run build",
28
+ "prepack": "npm run build",
27
29
  "health": "node bin/hypermem-status.mjs --master",
28
30
  "health:master": "node bin/hypermem-status.mjs --master",
29
31
  "install:runtime": "node scripts/install-runtime.mjs",
@@ -40,6 +42,7 @@
40
42
  "validate:docs": "node scripts/validate-docs.mjs",
41
43
  "validate:config": "node scripts/validate-config-surface.mjs",
42
44
  "validate:version-parity": "node scripts/validate-version-parity.mjs",
45
+ "validate:public-surface": "node scripts/validate-public-surface.mjs",
43
46
  "bench:memory": "node bench/data-access-bench.mjs --iterations 1000 --warmup 50",
44
47
  "validate:doctor": "node test/doctor-cli.mjs"
45
48
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@psiclawops/hypercompositor",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "HyperCompositor — context engine plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -35,10 +35,12 @@
35
35
  },
36
36
  "scripts": {
37
37
  "build": "tsc",
38
+ "prepublishOnly": "npm run build",
39
+ "prepack": "npm run build",
38
40
  "typecheck": "tsc --noEmit"
39
41
  },
40
42
  "dependencies": {
41
- "@psiclawops/hypermem": "0.9.0",
43
+ "@psiclawops/hypermem": "0.9.2",
42
44
  "zod": "^4.0.0"
43
45
  },
44
46
  "devDependencies": {
@@ -1,31 +0,0 @@
1
- /**
2
- * compositor-utils.ts — Utility functions for context window composition.
3
- *
4
- * Provides ordering strategies that improve LLM attention over retrieved
5
- * documents placed into a prompt.
6
- */
7
- /**
8
- * Reorder documents using zigzag placement to mitigate
9
- * "Lost in the Middle" attention degradation in LLMs.
10
- *
11
- * LLMs exhibit a U-shaped attention curve: items at the beginning and end
12
- * of context receive ~30% more attention than items in the middle.
13
- * This function places the most relevant items at the edges and the least
14
- * relevant items near the center, maximising effective attention on the
15
- * information that matters most.
16
- *
17
- * Reference: Liu et al., "Lost in the Middle: How Language Models Use Long
18
- * Contexts", ICLR 2025. https://arxiv.org/abs/2307.03172
19
- *
20
- * Input: [d1, d2, d3, d4, d5] (sorted by relevance, descending)
21
- * Output: [d1, d3, d5, d4, d2] (most relevant at edges, least in middle)
22
- *
23
- * Algorithm:
24
- * - Items at even positions in the input (0, 2, 4, …) fill from the front.
25
- * - Items at odd positions in the input (1, 3, 5, …) fill from the back.
26
- *
27
- * @param docs - Array sorted by relevance (most relevant first).
28
- * @returns A new array reordered so the most relevant items sit at the edges.
29
- */
30
- export declare function zigzagOrder<T>(docs: T[]): T[];
31
- //# sourceMappingURL=compositor-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compositor-utils.d.ts","sourceRoot":"","sources":["../src/compositor-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAkB7C"}
@@ -1,47 +0,0 @@
1
- /**
2
- * compositor-utils.ts — Utility functions for context window composition.
3
- *
4
- * Provides ordering strategies that improve LLM attention over retrieved
5
- * documents placed into a prompt.
6
- */
7
- /**
8
- * Reorder documents using zigzag placement to mitigate
9
- * "Lost in the Middle" attention degradation in LLMs.
10
- *
11
- * LLMs exhibit a U-shaped attention curve: items at the beginning and end
12
- * of context receive ~30% more attention than items in the middle.
13
- * This function places the most relevant items at the edges and the least
14
- * relevant items near the center, maximising effective attention on the
15
- * information that matters most.
16
- *
17
- * Reference: Liu et al., "Lost in the Middle: How Language Models Use Long
18
- * Contexts", ICLR 2025. https://arxiv.org/abs/2307.03172
19
- *
20
- * Input: [d1, d2, d3, d4, d5] (sorted by relevance, descending)
21
- * Output: [d1, d3, d5, d4, d2] (most relevant at edges, least in middle)
22
- *
23
- * Algorithm:
24
- * - Items at even positions in the input (0, 2, 4, …) fill from the front.
25
- * - Items at odd positions in the input (1, 3, 5, …) fill from the back.
26
- *
27
- * @param docs - Array sorted by relevance (most relevant first).
28
- * @returns A new array reordered so the most relevant items sit at the edges.
29
- */
30
- export function zigzagOrder(docs) {
31
- if (docs.length <= 2) {
32
- return docs.slice();
33
- }
34
- const result = new Array(docs.length);
35
- let front = 0;
36
- let back = docs.length - 1;
37
- for (let i = 0; i < docs.length; i++) {
38
- if (i % 2 === 0) {
39
- result[front++] = docs[i];
40
- }
41
- else {
42
- result[back--] = docs[i];
43
- }
44
- }
45
- return result;
46
- }
47
- //# sourceMappingURL=compositor-utils.js.map
@@ -1,43 +0,0 @@
1
- /**
2
- * hypermem Content Hash
3
- *
4
- * Content-addressed hashing for fact/knowledge deduplication.
5
- * Uses BLAKE3 (via @noble/hashes) for fast, collision-resistant fingerprints.
6
- *
7
- * Dedup semantics are per-agent: the same content stored by two different
8
- * agents is intentional and should not be merged. Check with:
9
- * WHERE content_hash = ? AND agent_id = ?
10
- */
11
- import type { DatabaseSync } from 'node:sqlite';
12
- /**
13
- * Compute a BLAKE3 content hash for deduplication.
14
- * Returns a 64-character hex string (32 bytes).
15
- *
16
- * Normalization: collapses whitespace, trims, lowercases
17
- * before hashing. This catches trivial reformatting differences
18
- * that shouldn't create duplicate facts.
19
- */
20
- export declare function contentHash(text: string): string;
21
- /**
22
- * SQL migration statements for adding content_hash columns and indexes.
23
- *
24
- * Use non-unique indexes — different agents may legitimately store identical
25
- * facts. Dedup check is always scoped per agent:
26
- * WHERE content_hash = ? AND agent_id = ?
27
- */
28
- export declare const SCHEMA_MIGRATIONS: {
29
- addFactsContentHash: string;
30
- addKnowledgeContentHash: string;
31
- indexFactsContentHash: string;
32
- indexKnowledgeContentHash: string;
33
- };
34
- /**
35
- * Backfill content_hash for existing rows that have NULL hashes.
36
- * Meant to run once after schema migration.
37
- * Returns count of rows updated.
38
- *
39
- * Defensive: returns 0 if the content_hash column does not exist on the
40
- * target table (e.g. migration hasn't run yet or table is missing).
41
- */
42
- export declare function backfillContentHashes(db: DatabaseSync, table: 'facts' | 'knowledge'): number;
43
- //# sourceMappingURL=content-hash.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-hash.d.ts","sourceRoot":"","sources":["../src/content-hash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;;;;CAK7B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,YAAY,EAChB,KAAK,EAAE,OAAO,GAAG,WAAW,GAC3B,MAAM,CAgCR"}
@@ -1,75 +0,0 @@
1
- /**
2
- * hypermem Content Hash
3
- *
4
- * Content-addressed hashing for fact/knowledge deduplication.
5
- * Uses BLAKE3 (via @noble/hashes) for fast, collision-resistant fingerprints.
6
- *
7
- * Dedup semantics are per-agent: the same content stored by two different
8
- * agents is intentional and should not be merged. Check with:
9
- * WHERE content_hash = ? AND agent_id = ?
10
- */
11
- import { blake3 } from '@noble/hashes/blake3.js';
12
- /**
13
- * Compute a BLAKE3 content hash for deduplication.
14
- * Returns a 64-character hex string (32 bytes).
15
- *
16
- * Normalization: collapses whitespace, trims, lowercases
17
- * before hashing. This catches trivial reformatting differences
18
- * that shouldn't create duplicate facts.
19
- */
20
- export function contentHash(text) {
21
- const normalized = text.toLowerCase().replace(/\s+/g, ' ').trim();
22
- const bytes = new TextEncoder().encode(normalized);
23
- return Buffer.from(blake3(bytes)).toString('hex');
24
- }
25
- /**
26
- * SQL migration statements for adding content_hash columns and indexes.
27
- *
28
- * Use non-unique indexes — different agents may legitimately store identical
29
- * facts. Dedup check is always scoped per agent:
30
- * WHERE content_hash = ? AND agent_id = ?
31
- */
32
- export const SCHEMA_MIGRATIONS = {
33
- addFactsContentHash: `ALTER TABLE facts ADD COLUMN content_hash TEXT`,
34
- addKnowledgeContentHash: `ALTER TABLE knowledge ADD COLUMN content_hash TEXT`,
35
- indexFactsContentHash: `CREATE INDEX IF NOT EXISTS idx_facts_content_hash ON facts(content_hash)`,
36
- indexKnowledgeContentHash: `CREATE INDEX IF NOT EXISTS idx_knowledge_content_hash ON knowledge(content_hash)`,
37
- };
38
- /**
39
- * Backfill content_hash for existing rows that have NULL hashes.
40
- * Meant to run once after schema migration.
41
- * Returns count of rows updated.
42
- *
43
- * Defensive: returns 0 if the content_hash column does not exist on the
44
- * target table (e.g. migration hasn't run yet or table is missing).
45
- */
46
- export function backfillContentHashes(db, table) {
47
- // Defensive: verify the column exists before querying it.
48
- const pragmaRows = db
49
- .prepare(`PRAGMA table_info(${table})`)
50
- .all();
51
- const hasColumn = pragmaRows.some((r) => r['name'] === 'content_hash');
52
- if (!hasColumn)
53
- return 0;
54
- const rows = db
55
- .prepare(`SELECT id, content FROM ${table} WHERE content_hash IS NULL`)
56
- .all();
57
- if (rows.length === 0)
58
- return 0;
59
- const update = db.prepare(`UPDATE ${table} SET content_hash = ? WHERE id = ?`);
60
- // Single transaction for the entire batch — much faster than autocommit per row.
61
- // Node 22 DatabaseSync does not have .transaction(); use manual BEGIN/COMMIT.
62
- db.exec('BEGIN');
63
- try {
64
- for (const row of rows) {
65
- update.run(contentHash(row.content), row.id);
66
- }
67
- db.exec('COMMIT');
68
- }
69
- catch (err) {
70
- db.exec('ROLLBACK');
71
- throw err;
72
- }
73
- return rows.length;
74
- }
75
- //# sourceMappingURL=content-hash.js.map
@@ -1,24 +0,0 @@
1
- /**
2
- * HyperMem Memory Plugin
3
- *
4
- * Thin adapter that bridges HyperMem's retrieval capabilities into
5
- * OpenClaw's memory slot contract (`kind: "memory"`).
6
- *
7
- * The context engine plugin (hypercompositor) owns the full lifecycle:
8
- * ingest, assemble, compact, afterTurn, bootstrap, dispose.
9
- *
10
- * This plugin owns the memory slot contract:
11
- * - registerMemoryCapability() with runtime + publicArtifacts
12
- * - memory_search tool backing via MemorySearchManager
13
- * - Public artifacts for memory-wiki bridge
14
- *
15
- * Both plugins share the same HyperMem singleton (loaded from repo dist).
16
- */
17
- declare const _default: {
18
- id: string;
19
- name: string;
20
- description: string;
21
- configSchema: import("openclaw/plugin-sdk").OpenClawPluginConfigSchema;
22
- register: NonNullable<import("openclaw/plugin-sdk/plugin-entry").OpenClawPluginDefinition["register"]>;
23
- } & Pick<import("openclaw/plugin-sdk/plugin-entry").OpenClawPluginDefinition, "kind" | "reload" | "nodeHostCommands" | "securityAuditCollectors">;
24
- export default _default;
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;;;;;;;;AA0VH,wBAmBG"}