abmind 0.1.3 → 0.1.5-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/README.md +90 -61
- package/config/.env.memory.example +114 -0
- package/dist/cli/abmind-backup.js +10 -10
- package/dist/cli/abmind-backup.js.map +1 -1
- package/dist/cli/abmind-bundle.js +4 -0
- package/dist/cli/abmind-bundle.js.map +1 -1
- package/dist/cli/abmind-hook-notification.d.ts +6 -0
- package/dist/cli/abmind-hook-notification.d.ts.map +1 -0
- package/dist/cli/abmind-hook-notification.js +56 -0
- package/dist/cli/abmind-hook-notification.js.map +1 -0
- package/dist/cli/abmind-hook-postToolUse.d.ts +10 -0
- package/dist/cli/abmind-hook-postToolUse.d.ts.map +1 -0
- package/dist/cli/abmind-hook-postToolUse.js +85 -0
- package/dist/cli/abmind-hook-postToolUse.js.map +1 -0
- package/dist/cli/abmind-hook-postcompact.d.ts +9 -0
- package/dist/cli/abmind-hook-postcompact.d.ts.map +1 -0
- package/dist/cli/abmind-hook-postcompact.js +64 -0
- package/dist/cli/abmind-hook-postcompact.js.map +1 -0
- package/dist/cli/abmind-hook-postuserprompt.d.ts +7 -0
- package/dist/cli/abmind-hook-postuserprompt.d.ts.map +1 -0
- package/dist/cli/abmind-hook-postuserprompt.js +69 -0
- package/dist/cli/abmind-hook-postuserprompt.js.map +1 -0
- package/dist/cli/abmind-hook-preToolUse.d.ts +10 -0
- package/dist/cli/abmind-hook-preToolUse.d.ts.map +1 -0
- package/dist/cli/abmind-hook-preToolUse.js +61 -0
- package/dist/cli/abmind-hook-preToolUse.js.map +1 -0
- package/dist/cli/abmind-hook-precompact.d.ts +7 -0
- package/dist/cli/abmind-hook-precompact.d.ts.map +1 -0
- package/dist/cli/abmind-hook-precompact.js +63 -0
- package/dist/cli/abmind-hook-precompact.js.map +1 -0
- package/dist/cli/abmind-hook-preuserprompt.d.ts +16 -0
- package/dist/cli/abmind-hook-preuserprompt.d.ts.map +1 -0
- package/dist/cli/abmind-hook-preuserprompt.js +125 -0
- package/dist/cli/abmind-hook-preuserprompt.js.map +1 -0
- package/dist/cli/abmind-hook-store.js +26 -3
- package/dist/cli/abmind-hook-store.js.map +1 -1
- package/dist/cli/abmind-hook-subagentstart.d.ts +6 -0
- package/dist/cli/abmind-hook-subagentstart.d.ts.map +1 -0
- package/dist/cli/abmind-hook-subagentstart.js +56 -0
- package/dist/cli/abmind-hook-subagentstart.js.map +1 -0
- package/dist/cli/abmind-hook-subagentstop.d.ts +6 -0
- package/dist/cli/abmind-hook-subagentstop.d.ts.map +1 -0
- package/dist/cli/abmind-hook-subagentstop.js +58 -0
- package/dist/cli/abmind-hook-subagentstop.js.map +1 -0
- package/dist/cli/abmind-hook-toolfailure.d.ts +7 -0
- package/dist/cli/abmind-hook-toolfailure.d.ts.map +1 -0
- package/dist/cli/abmind-hook-toolfailure.js +66 -0
- package/dist/cli/abmind-hook-toolfailure.js.map +1 -0
- package/dist/cli/abmind-hook-wakeup.js +10 -0
- package/dist/cli/abmind-hook-wakeup.js.map +1 -1
- package/dist/cli/abmind-install.js +251 -11
- package/dist/cli/abmind-install.js.map +1 -1
- package/dist/cli/abmind-restore.d.ts +1 -1
- package/dist/cli/abmind-restore.js +14 -36
- package/dist/cli/abmind-restore.js.map +1 -1
- package/dist/cli/abmind-retro-extract.js +41 -5
- package/dist/cli/abmind-retro-extract.js.map +1 -1
- package/dist/cli/abmind-sleep-state.js +1 -1
- package/dist/cli/abmind-sleep-state.js.map +1 -1
- package/dist/cli/abmind.js +2 -0
- package/dist/cli/abmind.js.map +1 -1
- package/dist/src/backup.d.ts +3 -1
- package/dist/src/backup.d.ts.map +1 -1
- package/dist/src/backup.js +11 -4
- package/dist/src/backup.js.map +1 -1
- package/dist/src/context-engine.d.ts +1 -1
- package/dist/src/context-engine.d.ts.map +1 -1
- package/dist/src/context-engine.js +1 -1
- package/dist/src/context-engine.js.map +1 -1
- package/dist/src/context-orchestrator.js +3 -3
- package/dist/src/context-orchestrator.js.map +1 -1
- package/dist/src/crypto.d.ts +6 -0
- package/dist/src/crypto.d.ts.map +1 -1
- package/dist/src/crypto.js +100 -17
- package/dist/src/crypto.js.map +1 -1
- package/dist/src/ensure-initialized.d.ts +1 -1
- package/dist/src/ensure-initialized.js +1 -1
- package/dist/src/env-schema.d.ts +2 -0
- package/dist/src/env-schema.d.ts.map +1 -1
- package/dist/src/env-schema.js +3 -1
- package/dist/src/env-schema.js.map +1 -1
- package/dist/src/index.d.ts +5 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/keyring.d.ts +9 -0
- package/dist/src/keyring.d.ts.map +1 -0
- package/dist/src/keyring.js +60 -0
- package/dist/src/keyring.js.map +1 -0
- package/dist/src/mem-types.d.ts +1 -1
- package/dist/src/mem-types.d.ts.map +1 -1
- package/dist/src/memory-backend.d.ts +3 -0
- package/dist/src/memory-backend.d.ts.map +1 -1
- package/dist/src/memory-config.js +1 -1
- package/dist/src/memory-config.js.map +1 -1
- package/dist/src/memory-db.d.ts +1 -6
- package/dist/src/memory-db.d.ts.map +1 -1
- package/dist/src/memory-db.js +7 -1
- package/dist/src/memory-db.js.map +1 -1
- package/dist/src/memory-editor.d.ts +1 -0
- package/dist/src/memory-editor.d.ts.map +1 -1
- package/dist/src/memory-editor.js +17 -16
- package/dist/src/memory-editor.js.map +1 -1
- package/dist/src/memory-ipc-client.d.ts +3 -0
- package/dist/src/memory-ipc-client.d.ts.map +1 -1
- package/dist/src/memory-ipc-client.js +4 -0
- package/dist/src/memory-ipc-client.js.map +1 -1
- package/dist/src/message-store.js +1 -1
- package/dist/src/message-store.js.map +1 -1
- package/dist/src/recall-benchmark.js +4 -2
- package/dist/src/recall-benchmark.js.map +1 -1
- package/dist/src/redact-secrets.d.ts.map +1 -1
- package/dist/src/redact-secrets.js +3 -0
- package/dist/src/redact-secrets.js.map +1 -1
- package/dist/src/session-context.d.ts +6 -5
- package/dist/src/session-context.d.ts.map +1 -1
- package/dist/src/session-context.js +134 -66
- package/dist/src/session-context.js.map +1 -1
- package/dist/src/sleep/levels.d.ts +7 -6
- package/dist/src/sleep/levels.d.ts.map +1 -1
- package/dist/src/sleep/levels.js.map +1 -1
- package/dist/src/sleep/orchestrator.d.ts +1 -1
- package/dist/src/sleep/orchestrator.d.ts.map +1 -1
- package/dist/src/sleep/orchestrator.js +80 -38
- package/dist/src/sleep/orchestrator.js.map +1 -1
- package/dist/src/sleep/sleep-daily-summary.d.ts +6 -2
- package/dist/src/sleep/sleep-daily-summary.d.ts.map +1 -1
- package/dist/src/sleep/sleep-daily-summary.js +34 -12
- package/dist/src/sleep/sleep-daily-summary.js.map +1 -1
- package/dist/src/sleep/sleep-extract-daily.d.ts.map +1 -1
- package/dist/src/sleep/sleep-extract-daily.js +3 -0
- package/dist/src/sleep/sleep-extract-daily.js.map +1 -1
- package/dist/src/sleep/sleep-prompt-loader.js +3 -3
- package/dist/src/sleep/sleep-prompt-loader.js.map +1 -1
- package/dist/src/sleep-data-access.d.ts +4 -2
- package/dist/src/sleep-data-access.d.ts.map +1 -1
- package/dist/src/sleep-data-access.js +49 -13
- package/dist/src/sleep-data-access.js.map +1 -1
- package/dist/src/sqlite-backend.d.ts +3 -0
- package/dist/src/sqlite-backend.d.ts.map +1 -1
- package/dist/src/sqlite-backend.js +3 -0
- package/dist/src/sqlite-backend.js.map +1 -1
- package/dist/src/status-block.d.ts +7 -0
- package/dist/src/status-block.d.ts.map +1 -0
- package/dist/src/status-block.js +67 -0
- package/dist/src/status-block.js.map +1 -0
- package/dist/src/wake-up-renderer.d.ts +0 -5
- package/dist/src/wake-up-renderer.d.ts.map +1 -1
- package/dist/src/wake-up-renderer.js +0 -34
- package/dist/src/wake-up-renderer.js.map +1 -1
- package/package.json +6 -3
- package/prompts/sleep/03-retrospective.md +23 -0
- package/prompts/sleep/04-extract-memories.md +3 -0
- package/prompts/sleep/06-retro-derive.md +39 -0
- package/prompts/sleep/08-memory-maintenance.md +39 -0
- package/prompts/sleep/{13-consolidation.md → 11-consolidation.md} +4 -1
- package/templates/core/SOUL.md +24 -0
- package/templates/core/agent_notes.md +7 -0
- package/templates/core/core_facts.md +10 -0
- package/templates/core/memory-tools.md +43 -0
- package/templates/core/user_profile.md +7 -0
- package/templates/with-abmind-hooks.json +26 -0
- package/dist/cli/abmind-backfill.d.ts +0 -3
- package/dist/cli/abmind-backfill.d.ts.map +0 -1
- package/dist/cli/abmind-backfill.js +0 -64
- package/dist/cli/abmind-backfill.js.map +0 -1
- package/dist/cli/abmind-memory-stats.d.ts +0 -3
- package/dist/cli/abmind-memory-stats.d.ts.map +0 -1
- package/dist/cli/abmind-memory-stats.js +0 -45
- package/dist/cli/abmind-memory-stats.js.map +0 -1
- package/dist/cli/abmind-reset.d.ts +0 -11
- package/dist/cli/abmind-reset.d.ts.map +0 -1
- package/dist/cli/abmind-reset.js +0 -143
- package/dist/cli/abmind-reset.js.map +0 -1
- package/dist/cli/abmind-status.d.ts +0 -3
- package/dist/cli/abmind-status.d.ts.map +0 -1
- package/dist/cli/abmind-status.js +0 -45
- package/dist/cli/abmind-status.js.map +0 -1
- package/prompts/sleep/03-extract-from-daily.md +0 -3
- package/prompts/sleep/04-retrospective.md +0 -30
- package/prompts/sleep/07-topic-assignment.md +0 -23
- package/prompts/sleep/08-core-promotion.md +0 -26
- package/prompts/sleep/09-merge.md +0 -19
- package/prompts/sleep/12-core-knowledge.md +0 -14
- package/prompts/sleep/14-emotion-context.md +0 -17
- /package/prompts/sleep/{15-contradiction-and-graph.md → 05-contradiction-and-graph.md} +0 -0
- /package/prompts/sleep/{06-feedback.md → 07-feedback.md} +0 -0
- /package/prompts/sleep/{10-translation.md → 09-translation.md} +0 -0
- /package/prompts/sleep/{11-skill-review.md → 10-skill-review.md} +0 -0
- /package/prompts/sleep/{16-rem-synthesis.md → 12-rem-synthesis.md} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to abmind. Follows [Keep a Changelog](https://keepachangelog.com/).
|
|
4
4
|
|
|
5
|
+
## [0.1.5] — 2026-06-01
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **abmind install** — full onboard: native deps, ollama check, encryption passphrase, memory DB init, user_profile.md seeding, install log
|
|
9
|
+
- **Agent name** — install asks agent name, writes to SOUL.md template (`<agentName>` placeholder)
|
|
10
|
+
- **`--agent-name`** flag for non-interactive installs
|
|
11
|
+
- **`rebuildFtsIndexes()`** on MemoryBackend interface
|
|
12
|
+
- **Block system/agent** from storing memories + 24h TTL cleanup (#701)
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- SOUL template: "I am <agentName>, an autonomous agent. abtars is my runtime — it gives me voice and hands."
|
|
16
|
+
- `seedCoreFiles` reads from `templates/core/SOUL.md` (was `core/SOUL.md`)
|
|
17
|
+
- Sleep budget raised to 18 + reset llmCalls on resume (#684)
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
- `abmind bundle --help` exits with usage instead of running bundle
|
|
21
|
+
- Scope sleep message query to primary user_id (#696)
|
|
22
|
+
- Lazy-load better-sqlite3 — no top-level require (#713)
|
|
23
|
+
|
|
24
|
+
## [0.1.4] — 2026-05-31
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
- **Backup** — `abmind backup --database` flag + auto key-file fallback (#707)
|
|
28
|
+
- **FTS self-heal** — `rebuildFtsIndexes()` exposed on MemoryBackend interface (#706)
|
|
29
|
+
- **Session context** — `skipDailies` + `maxAgeMs` options (#658)
|
|
30
|
+
- **SESSION_HISTORY_CAP** — cap history budget at 25000 chars (#656)
|
|
31
|
+
- **buildStatusBlock** — compact system status for session-start (#646)
|
|
32
|
+
- **Curation counter** — skip candidates after 3 failures with same model (#639)
|
|
33
|
+
- **Wiki** — 13 pages (recall, classification, configuration, backup, troubleshooting + rewrites)
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- Sleep pipeline: merge core-promotion into retro-derive (two-stage knowledge funnel, #630)
|
|
37
|
+
- Consolidation writes to `weekly/` not `daily/` (#640)
|
|
38
|
+
- Exclude non-numbered files from sleep step loader (#637)
|
|
39
|
+
- [RECENT] shows newest messages, not oldest (#654)
|
|
40
|
+
- README rewrite: selling points, badges, agglutinating language examples
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
- `[NO-REPLY]` renamed to `[NO_REPLY]` (underscore) matching bridge filter
|
|
44
|
+
|
|
45
|
+
## [0.1.3] — 2026-05-20
|
|
46
|
+
|
|
47
|
+
### Added
|
|
48
|
+
- Dreaming pipeline — multi-step sleep with per-step retry
|
|
49
|
+
- CI/CD — GitHub Actions build + test
|
|
50
|
+
- Community templates — SOUL.md, user_profile.md, agent_notes.md
|
|
51
|
+
|
|
5
52
|
## [0.1.2] — 2026-05-07
|
|
6
53
|
|
|
7
54
|
### Added
|
package/README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# abmind
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/abmind) [](LICENSE) []()
|
|
4
|
+
|
|
3
5
|
Persistent memory system for AI agents — store, recall, consolidate, and forget.
|
|
4
6
|
|
|
5
|
-
SQLite-backed, 4-layer recall (FTS5 + trigram + embeddings + consolidated summaries), overnight sleep maintenance, injection detection, context orchestration, and a classification system inspired by NATO Admiralty Codes.
|
|
7
|
+
**Built for multilingual agents that run 24/7 — not a vector DB wrapper.** SQLite-backed, 4-layer recall (FTS5 + trigram + embeddings + consolidated summaries), overnight sleep maintenance, injection detection, context orchestration, and a classification system inspired by NATO Admiralty Codes.
|
|
6
8
|
|
|
7
|
-
**Version:** 0.1.
|
|
9
|
+
**Version:** 0.1.4 | **Docs:** [Wiki](https://github.com/aksika/abmind/tree/dev/docs/wiki) | **License:** Apache 2.0
|
|
8
10
|
|
|
9
11
|
## Install
|
|
10
12
|
|
|
@@ -13,38 +15,7 @@ npm install abmind
|
|
|
13
15
|
abmind install
|
|
14
16
|
```
|
|
15
17
|
|
|
16
|
-
Requires Node 22+. Full guide: [
|
|
17
|
-
|
|
18
|
-
## Library Usage
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
import { MemoryManager, loadMemoryConfig, recallSearch, buildWakeUp } from "abmind";
|
|
22
|
-
|
|
23
|
-
// Initialize
|
|
24
|
-
const config = loadMemoryConfig(); // reads ABMIND_HOME, defaults to ~/.abmind
|
|
25
|
-
const memory = new MemoryManager(config);
|
|
26
|
-
|
|
27
|
-
// Store a message
|
|
28
|
-
memory.recordMessage({
|
|
29
|
-
role: "user",
|
|
30
|
-
content: "I prefer dark mode and hate notifications",
|
|
31
|
-
timestamp: Date.now(),
|
|
32
|
-
userId: "alice",
|
|
33
|
-
sessionId: "alice:telegram",
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// Recall relevant memories
|
|
37
|
-
const results = await recallSearch(memory.getRecallDeps(), {
|
|
38
|
-
translated: ["dark mode", "preferences"],
|
|
39
|
-
userId: "alice",
|
|
40
|
-
limit: 5,
|
|
41
|
-
});
|
|
42
|
-
console.log(results.memories); // ranked by relevance across all 4 layers
|
|
43
|
-
|
|
44
|
-
// Build wake-up context for a new session
|
|
45
|
-
const wakeUp = buildWakeUp(memory, "alice");
|
|
46
|
-
// → structured context: recent topics, key facts, emotional state, pending items
|
|
47
|
-
```
|
|
18
|
+
Requires Node 22+. Full guide: [Installation](https://github.com/aksika/abmind/blob/dev/docs/wiki/install.md)
|
|
48
19
|
|
|
49
20
|
## Architecture
|
|
50
21
|
|
|
@@ -77,38 +48,75 @@ const wakeUp = buildWakeUp(memory, "alice");
|
|
|
77
48
|
|
|
78
49
|
## Features
|
|
79
50
|
|
|
80
|
-
###
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
51
|
+
### Agglutinating Language Support
|
|
52
|
+
|
|
53
|
+
Most memory systems tokenize on word boundaries — catastrophic for Japanese, Turkish, Hungarian, and other languages where a single word carries dense meaning. Japanese has no spaces ("食べさせられなかった" = "was not able to be made to eat"), Turkish compounds freely ("yapabildiklerimizdenmişsinizcesine" = "as if you were among those we could do"), Hungarian packs sentences into one word ("megcsináltattam" = "I had it done by someone"). abmind uses **trigram fuzzy search** alongside FTS5, so recall works regardless of morphology, word boundaries, or compounding. Store in any language, recall in any language.
|
|
54
|
+
|
|
55
|
+
### Credential Vault
|
|
56
|
+
|
|
57
|
+
When your agent receives a secret (API key, token, password):
|
|
58
|
+
1. Encrypts it at rest (AES-256-GCM) as a SECRET memory (class 3)
|
|
59
|
+
2. Immediately redacts the raw credential from conversation history
|
|
60
|
+
3. Only the owner can retrieve it (classification-gated recall)
|
|
61
|
+
4. Backups and exports never contain raw credentials
|
|
62
|
+
|
|
63
|
+
Your agent remembers secrets without leaking them.
|
|
64
|
+
|
|
65
|
+
### Multi-Resolution Context
|
|
66
|
+
|
|
67
|
+
Context assembly at three zoom levels — 3× more coverage in the same token budget:
|
|
68
|
+
- **Recent** — full verbatim conversation (last N turns)
|
|
69
|
+
- **Session** — compressed per-turn atoms (ABM-L format, 3× token reduction)
|
|
70
|
+
- **Long-term** — thematic summaries + recalled memories from weeks/months ago
|
|
71
|
+
|
|
72
|
+
The agent remembers last week's decisions AND this morning's details.
|
|
73
|
+
|
|
74
|
+
### Sleep Maintenance (Dreamy)
|
|
75
|
+
|
|
76
|
+
Nightly background process that curates memory like human sleep:
|
|
77
|
+
- Extracts facts, decisions, preferences from the day's conversations
|
|
78
|
+
- Consolidates daily → weekly → quarterly summaries
|
|
79
|
+
- Detects contradictions ("you said X last week but Y today")
|
|
80
|
+
- Prunes stale memories (Memory Darwinism — unused memories fade)
|
|
81
|
+
- Promotes frequently-recalled memories, demotes stale ones
|
|
82
|
+
- 10-14 LLM calls per cycle, fully autonomous
|
|
83
|
+
|
|
84
|
+
### Recall (4 layers, ranked)
|
|
84
85
|
|
|
85
|
-
### Recall (4 layers)
|
|
86
86
|
- **FTS5** — full-text search on English and original content
|
|
87
|
-
- **Trigram** — fuzzy matching for typos, partial words,
|
|
87
|
+
- **Trigram** — fuzzy matching for typos, partial words, agglutinating morphology
|
|
88
88
|
- **Embeddings** — semantic similarity via Ollama or any OpenAI-compatible endpoint
|
|
89
89
|
- **Consolidated summaries** — weekly/quarterly rollups searchable as memories
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
- **Classification** — 0 (public) → 1 (internal) → 2 (confidential) → 3 (secret)
|
|
93
|
-
- **Trust / Integrity / Credibility** — per-memory quality scores
|
|
94
|
-
- **Access control** — recall filters by user clearance level automatically
|
|
91
|
+
Results ranked by relevance across all layers. No single layer is a bottleneck.
|
|
95
92
|
|
|
96
|
-
###
|
|
97
|
-
- Slot-based compression format for context-window efficiency
|
|
98
|
-
- 3× token reduction vs raw prose, preserving semantic atoms
|
|
99
|
-
- Render-only — stored data stays as clean prose, ABM-L is ephemeral
|
|
93
|
+
### Classification (NATO Admiralty Codes)
|
|
100
94
|
|
|
101
|
-
|
|
102
|
-
- **
|
|
103
|
-
- **
|
|
104
|
-
- **
|
|
105
|
-
- **Forget** — memories below threshold eventually pruned
|
|
95
|
+
- **Classification** — 0 (public) → 1 (internal) → 2 (confidential) → 3 (secret/encrypted)
|
|
96
|
+
- **Trust / Integrity / Credibility** — per-memory quality scores
|
|
97
|
+
- **Access control** — recall filters by user clearance level automatically
|
|
98
|
+
- **Multi-user isolation** — each user's memories scoped, no cross-user leakage
|
|
106
99
|
|
|
107
100
|
### Injection Detection
|
|
101
|
+
|
|
108
102
|
- 14 detection categories (prompt injection, jailbreak, role hijack, etc.)
|
|
109
103
|
- Blocks malicious input before it enters the memory store
|
|
110
104
|
- Configurable sensitivity per category
|
|
111
105
|
|
|
106
|
+
### Works Everywhere
|
|
107
|
+
|
|
108
|
+
Not locked to one CLI or framework:
|
|
109
|
+
|
|
110
|
+
| Path | Use for |
|
|
111
|
+
|---|---|
|
|
112
|
+
| **abTARS** | In-process memory for the autonomous bridge |
|
|
113
|
+
| **Hermes Agent** | Plugin-compatible memory backend |
|
|
114
|
+
| **OpenClaw** | Native memory slot replacement |
|
|
115
|
+
| **Library** (`import { MemoryManager } from "abmind"`) | Any Node.js agent |
|
|
116
|
+
| **MCP server** (`abmind mcp`) | Editors + hosts with MCP support |
|
|
117
|
+
| **CLI** (`abmind store/recall/...`) | Shell scripts, automation |
|
|
118
|
+
| **Agent hooks** | Kiro CLI, Claude Code, Gemini CLI, Codex |
|
|
119
|
+
|
|
112
120
|
## CLI
|
|
113
121
|
|
|
114
122
|
```bash
|
|
@@ -153,15 +161,36 @@ Add to your host's MCP config:
|
|
|
153
161
|
|
|
154
162
|
Works with kiro-cli, Claude Code, Codex CLI, Gemini CLI, Cursor, OpenCode, and any MCP-compatible host.
|
|
155
163
|
|
|
156
|
-
##
|
|
164
|
+
## Library Usage
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
import { MemoryManager, loadMemoryConfig, recallSearch, buildWakeUp } from "abmind";
|
|
157
168
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
// Initialize
|
|
170
|
+
const config = loadMemoryConfig(); // reads ABMIND_HOME, defaults to ~/.abmind
|
|
171
|
+
const memory = new MemoryManager(config);
|
|
172
|
+
|
|
173
|
+
// Store a message
|
|
174
|
+
memory.recordMessage({
|
|
175
|
+
role: "user",
|
|
176
|
+
content: "I prefer dark mode and hate notifications",
|
|
177
|
+
timestamp: Date.now(),
|
|
178
|
+
userId: "alice",
|
|
179
|
+
sessionId: "alice:telegram",
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Recall relevant memories
|
|
183
|
+
const results = await recallSearch(memory.getRecallDeps(), {
|
|
184
|
+
translated: ["dark mode", "preferences"],
|
|
185
|
+
userId: "alice",
|
|
186
|
+
limit: 5,
|
|
187
|
+
});
|
|
188
|
+
console.log(results.memories); // ranked by relevance across all 4 layers
|
|
189
|
+
|
|
190
|
+
// Build wake-up context for a new session
|
|
191
|
+
const wakeUp = buildWakeUp(memory, "alice");
|
|
192
|
+
// → structured context: recent topics, key facts, emotional state, pending items
|
|
193
|
+
```
|
|
165
194
|
|
|
166
195
|
## Data Location
|
|
167
196
|
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# abmind memory configuration
|
|
2
|
+
# Copied to ~/.abmind/config/.env.memory by `abmind install`.
|
|
3
|
+
#
|
|
4
|
+
# Lines starting with `#VAR=value` show the DEFAULT — uncomment to override.
|
|
5
|
+
# Lines with `VAR=` (no leading #) are REQUIRED — fill in.
|
|
6
|
+
|
|
7
|
+
# === OPTIONAL — commented lines show defaults ===
|
|
8
|
+
|
|
9
|
+
# Enable memory subsystem (default: true)
|
|
10
|
+
#MEMORY_ENABLED=true
|
|
11
|
+
|
|
12
|
+
# Memory data directory (default: ~/.abmind/memory)
|
|
13
|
+
#MEMORY_DIR=~/.abmind/memory
|
|
14
|
+
|
|
15
|
+
# Search strategy: hybrid | embedding | signature (default: hybrid)
|
|
16
|
+
#MEMORY_SEARCH_MODE=hybrid
|
|
17
|
+
|
|
18
|
+
# Max messages retained per chat (default: 1000)
|
|
19
|
+
#MEMORY_MAX_MESSAGES_PER_CHAT=1000
|
|
20
|
+
|
|
21
|
+
# Disk budget for memory data in MB (default: 500)
|
|
22
|
+
#MEMORY_DISK_BUDGET_MB=500
|
|
23
|
+
|
|
24
|
+
# Max SQLite DB size in MB (default: 200)
|
|
25
|
+
#MEMORY_MAX_DB_SIZE_MB=200
|
|
26
|
+
|
|
27
|
+
# TTL for original-language messages in days (default: 90)
|
|
28
|
+
#MEMORY_ORIGINAL_TTL_DAYS=90
|
|
29
|
+
|
|
30
|
+
# TTL for English-translated messages in days (default: 365)
|
|
31
|
+
#MEMORY_ENGLISH_TTL_DAYS=365
|
|
32
|
+
|
|
33
|
+
# Enable memory aging (decay of old messages) (default: true)
|
|
34
|
+
#MEMORY_AGING_ENABLED=true
|
|
35
|
+
|
|
36
|
+
# Signature bits for fingerprinting (default: 256)
|
|
37
|
+
#SIGNATURE_BITS=256
|
|
38
|
+
|
|
39
|
+
# === EMBEDDING (optional — ollama or OpenAI-compatible) ===
|
|
40
|
+
|
|
41
|
+
# Enable semantic embedding search (default: true)
|
|
42
|
+
#EMBEDDING_ENABLED=true
|
|
43
|
+
|
|
44
|
+
# Embedding provider. "ollama" (default) or "openai" (covers OpenAI, Voyage,
|
|
45
|
+
# Together, any OpenAI-compatible endpoint via URL swap).
|
|
46
|
+
#EMBEDDING_PROVIDER=ollama
|
|
47
|
+
|
|
48
|
+
# Embedding model name (default: nomic-embed-text for ollama; text-embedding-3-small for openai)
|
|
49
|
+
#EMBEDDING_MODEL=nomic-embed-text
|
|
50
|
+
|
|
51
|
+
# Provider endpoint. Ollama: http://localhost:11434. OpenAI: https://api.openai.com/v1
|
|
52
|
+
#EMBEDDING_URL=http://localhost:11434
|
|
53
|
+
|
|
54
|
+
# API key — required for openai provider, ignored for ollama. Masked in all logs/status.
|
|
55
|
+
#EMBEDDING_API_KEY=
|
|
56
|
+
|
|
57
|
+
# Vector dimensions. Ollama nomic-embed-text=768, OpenAI text-embedding-3-small=1536.
|
|
58
|
+
# Switching providers with a different value requires `abmind embed --reset` — the
|
|
59
|
+
# memory system refuses to start on dimension mismatch (#173).
|
|
60
|
+
#EMBEDDING_DIMENSIONS=768
|
|
61
|
+
|
|
62
|
+
# Minimum similarity score to count as a match (default: 0.5)
|
|
63
|
+
#EMBEDDING_SIMILARITY_THRESHOLD=0.5
|
|
64
|
+
|
|
65
|
+
# === ABM-L RENDERING (memory-renderer.ts, #236) ===
|
|
66
|
+
|
|
67
|
+
# ABM-L codec version for memory + context rendering (default: plain)
|
|
68
|
+
# plain: full English with prefix, universal compatibility
|
|
69
|
+
# v0: legacy positional format
|
|
70
|
+
# v1: slot-based structured format (for experienced users)
|
|
71
|
+
#ABML_VERSION=plain
|
|
72
|
+
|
|
73
|
+
# Minimum chars before ABM-L compression kicks in for v0 (default: 100)
|
|
74
|
+
#ABML_MIN_CHARS=100
|
|
75
|
+
|
|
76
|
+
# === THREE-TIER CONTEXT ASSEMBLY (#348) ===
|
|
77
|
+
|
|
78
|
+
# Enable three-tier context assembly (default: true)
|
|
79
|
+
# When false, falls back to legacy binary (raw messages + summary head).
|
|
80
|
+
# The heuristic classifier still runs at write time regardless.
|
|
81
|
+
#CONTEXT_TIER_ENABLED=true
|
|
82
|
+
|
|
83
|
+
# Tail boundary — last N turns kept verbatim (default: 20)
|
|
84
|
+
#CONTEXT_TIER_TAIL=20
|
|
85
|
+
|
|
86
|
+
# Middle boundary — next M turns rendered via ABM-L from hints (default: 50)
|
|
87
|
+
#CONTEXT_TIER_MIDDLE=50
|
|
88
|
+
|
|
89
|
+
# Enable LLM refinement for middle-tier rendering (default: false)
|
|
90
|
+
# When true, the main chat model refines heuristic output asynchronously.
|
|
91
|
+
# Heuristic always remains the fallback. Costs ~$0.02-0.05/chat/day at cheap model.
|
|
92
|
+
#COMPACTION_LLM_ENABLED=false
|
|
93
|
+
|
|
94
|
+
# === SESSION-START CONTEXT (#615) ===
|
|
95
|
+
|
|
96
|
+
# Percentage of maxContext budget for session-start history (default: 3)
|
|
97
|
+
#SESSION_HISTORY_PCT=3
|
|
98
|
+
|
|
99
|
+
# Minimum messages always included regardless of budget (default: 8)
|
|
100
|
+
#SESSION_HISTORY_MIN_MSGS=8
|
|
101
|
+
|
|
102
|
+
# Max chars for session-start context (default: 25000)
|
|
103
|
+
#SESSION_HISTORY_CAP=25000
|
|
104
|
+
|
|
105
|
+
# === SLEEP / DREAMY ===
|
|
106
|
+
|
|
107
|
+
# Sleep quality tier: basic | budget | normal | ultimate (default: normal)
|
|
108
|
+
#SLEEP_QUALITY=normal
|
|
109
|
+
|
|
110
|
+
# Day of week for weekly curation steps (default: sunday)
|
|
111
|
+
#SLEEP_CURATION_DAY=sunday
|
|
112
|
+
|
|
113
|
+
# Max LLM calls per sleep cycle, hard safety cap (default: 15, max: 50)
|
|
114
|
+
#SLEEP_MAX_LLM_CALLS=15
|
|
@@ -10,33 +10,33 @@ const FLAGS = [
|
|
|
10
10
|
{ name: "output", type: "string" },
|
|
11
11
|
{ name: "passphrase", type: "string" },
|
|
12
12
|
{ name: "passphrase-env", type: "string" },
|
|
13
|
+
{ name: "database", type: "boolean" },
|
|
13
14
|
];
|
|
14
15
|
await runCli(import.meta.url, {
|
|
15
16
|
name: "abmind-backup",
|
|
16
17
|
help: `Usage:
|
|
17
|
-
abmind backup [--output <path>] [--passphrase <p> | --passphrase-env <VAR>]
|
|
18
|
+
abmind backup [--database] [--output <path>] [--passphrase <p> | --passphrase-env <VAR>]
|
|
18
19
|
|
|
19
20
|
Options:
|
|
21
|
+
--database DB-only backup (no core/weekly/config files)
|
|
20
22
|
--output <path> Output file (default: ~/.abmind/backups/abmind-<timestamp>.abm)
|
|
21
|
-
--passphrase <p> Encryption passphrase
|
|
23
|
+
--passphrase <p> Encryption passphrase (default: derived from ~/.abmind/secret/abmind.key)
|
|
22
24
|
--passphrase-env <VAR> Read passphrase from env var (default: ABMIND_BACKUP_PASSPHRASE)`,
|
|
23
25
|
flags: FLAGS,
|
|
24
26
|
handler: async ({ args }) => {
|
|
25
27
|
const memoryDir = join(abmindHome(), "memory");
|
|
26
28
|
const db = initializeDatabase(join(memoryDir, "memory.db"));
|
|
27
|
-
// Resolve passphrase
|
|
29
|
+
// Resolve passphrase (optional — falls back to ~/.abmind/secret/abmind.key)
|
|
28
30
|
const envVar = args["passphrase-env"] ?? "ABMIND_BACKUP_PASSPHRASE";
|
|
29
|
-
const passphrase = args["passphrase"] ?? process.env[envVar];
|
|
30
|
-
if (!passphrase) {
|
|
31
|
-
console.error(`Error: passphrase required. Use --passphrase, --passphrase-env, or set ${envVar}`);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
31
|
+
const passphrase = args["passphrase"] ?? process.env[envVar] ?? undefined;
|
|
34
32
|
// Resolve output path
|
|
35
33
|
const now = new Date();
|
|
36
34
|
const ts = `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, "0")}${String(now.getDate()).padStart(2, "0")}-${String(now.getHours()).padStart(2, "0")}${String(now.getMinutes()).padStart(2, "0")}`;
|
|
37
|
-
const
|
|
35
|
+
const dbOnly = !!args["database"];
|
|
36
|
+
const defaultName = dbOnly ? `abmind-db-${ts}.abm` : `abmind-${ts}.abm`;
|
|
37
|
+
const defaultPath = join(abmindHome(), "backups", defaultName);
|
|
38
38
|
const outputPath = args["output"] ?? defaultPath;
|
|
39
|
-
const result = createBackup(db, memoryDir, passphrase, outputPath);
|
|
39
|
+
const result = createBackup(db, memoryDir, passphrase, outputPath, { dbOnly });
|
|
40
40
|
console.log(`✅ Backup: ${result.memories} memories, ${result.files} files → ${result.path} (${Math.round(result.sizeBytes / 1024)}KB)`);
|
|
41
41
|
db.close();
|
|
42
42
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abmind-backup.js","sourceRoot":"","sources":["../../cli/abmind-backup.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,KAAK,GAAwB;IACjC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IAClC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE;IACtC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"abmind-backup.js","sourceRoot":"","sources":["../../cli/abmind-backup.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,I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QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;QAChN,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClC,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC;QACxE,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;QAC/D,MAAM,UAAU,GAAI,IAAI,CAAC,QAAQ,CAAY,IAAI,WAAW,CAAC;QAE7D,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QAC/E,OAAO,CAAC,GAAG,CAAC,aAAa,MAAM,CAAC,QAAQ,cAAc,MAAM,CAAC,KAAK,YAAY,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACxI,EAAE,CAAC,KAAK,EAAE,CAAC;IACb,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* abmind bundle — Print session bundle (SOUL + profile + notes + memory-tools) to stdout.
|
|
4
4
|
* For kiro-cli, claude_code, or any host that needs the bundle via execute_bash.
|
|
5
5
|
*/
|
|
6
|
+
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
|
7
|
+
console.log("Usage: abmind bundle\n\nPrint session bundle (SOUL + profile + notes + memory-tools) to stdout.");
|
|
8
|
+
process.exit(0);
|
|
9
|
+
}
|
|
6
10
|
import { loadMemoryConfig } from "../src/memory-config.js";
|
|
7
11
|
import { MemoryManager } from "../src/memory-manager.js";
|
|
8
12
|
const config = loadMemoryConfig();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abmind-bundle.js","sourceRoot":"","sources":["../../cli/abmind-bundle.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;AAClC,MAAM,EAAE,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;AACrC,MAAM,MAAM,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAC;AACrC,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC9F,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IACvB,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,MAAM,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC;IACrF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"abmind-bundle.js","sourceRoot":"","sources":["../../cli/abmind-bundle.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IACnE,OAAO,CAAC,GAAG,CAAC,iGAAiG,CAAC,CAAC;IAC/G,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;AAClC,MAAM,EAAE,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;AACrC,MAAM,MAAM,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAC;AACrC,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC9F,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IACvB,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,MAAM,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC;IACrF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abmind-hook-notification.d.ts","sourceRoot":"","sources":["../../cli/abmind-hook-notification.ts"],"names":[],"mappings":";AACA;;GAEG"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* abmind hook Notification — log as session breadcrumb for retrospective.
|
|
4
|
+
*/
|
|
5
|
+
import { runCliRaw } from "../src/cli-runner-raw.js";
|
|
6
|
+
import { loadMemoryConfig } from "../src/memory-config.js";
|
|
7
|
+
import { MemoryManager } from "../src/memory-manager.js";
|
|
8
|
+
import { SleepDataAccess } from "../src/sleep-data-access.js";
|
|
9
|
+
import { hooksDisabled, logHookError, readStdinJson, ensureHooksDir } from "../src/hook-helpers.js";
|
|
10
|
+
await runCliRaw(import.meta.url, {
|
|
11
|
+
name: "abmind-hook-notification",
|
|
12
|
+
help: "Notification hook — log as session breadcrumb.",
|
|
13
|
+
flags: [],
|
|
14
|
+
handler: async () => {
|
|
15
|
+
ensureHooksDir();
|
|
16
|
+
if (hooksDisabled()) {
|
|
17
|
+
process.exit(0);
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const payload = await readStdinJson();
|
|
21
|
+
const message = payload?.message?.trim();
|
|
22
|
+
if (!message) {
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
const memory = new MemoryManager(loadMemoryConfig());
|
|
26
|
+
await memory.initialize({ skipEmbeddingCheck: true });
|
|
27
|
+
try {
|
|
28
|
+
const db = memory.getDatabase();
|
|
29
|
+
if (!db) {
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
32
|
+
const sleepData = new SleepDataAccess(db);
|
|
33
|
+
let userId;
|
|
34
|
+
try {
|
|
35
|
+
userId = sleepData.getPrimaryUserId();
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
memory.recordMessage({
|
|
41
|
+
userId, sessionId: "_S_breadcrumb", role: "assistant",
|
|
42
|
+
content: `[NOTIFICATION] ${message.slice(0, 200)}`,
|
|
43
|
+
timestamp: Date.now(),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
memory.close();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
logHookError("notification", err);
|
|
52
|
+
}
|
|
53
|
+
process.exit(0);
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=abmind-hook-notification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abmind-hook-notification.js","sourceRoot":"","sources":["../../cli/abmind-hook-notification.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAOpG,MAAM,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;IAC/B,IAAI,EAAE,0BAA0B;IAChC,IAAI,EAAE,gDAAgD;IACtD,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,KAAK,IAAI,EAAE;QAClB,cAAc,EAAE,CAAC;QACjB,IAAI,aAAa,EAAE,EAAE,CAAC;YAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAAC,CAAC;QAEzC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,aAAa,EAAuB,CAAC;YAC3D,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YACzC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAAC,CAAC;YAElC,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,gBAAgB,EAAE,CAAC,CAAC;YACrD,MAAM,MAAM,CAAC,UAAU,CAAC,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;YACtD,IAAI,CAAC;gBACH,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;gBAChC,IAAI,CAAC,EAAE,EAAE,CAAC;oBAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAAC,CAAC;gBAC7B,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,EAAE,CAAC,CAAC;gBAC1C,IAAI,MAAc,CAAC;gBACnB,IAAI,CAAC;oBAAC,MAAM,GAAG,SAAS,CAAC,gBAAgB,EAAE,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC;oBAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAAC,CAAC;gBAEzE,MAAM,CAAC,aAAa,CAAC;oBACnB,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW;oBACrD,OAAO,EAAE,kBAAkB,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE;oBAClD,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;iBACtB,CAAC,CAAC;YACL,CAAC;oBAAS,CAAC;gBAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YAAC,YAAY,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;QAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* abmind hook-postToolUse — Kiro CLI postToolUse hook (#634).
|
|
4
|
+
*
|
|
5
|
+
* Captures tool usage summaries into a sidecar file for richer memory.
|
|
6
|
+
* The stop hook reads this sidecar and includes it in the recorded turn.
|
|
7
|
+
* Exit 0 always — never blocks.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=abmind-hook-postToolUse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abmind-hook-postToolUse.d.ts","sourceRoot":"","sources":["../../cli/abmind-hook-postToolUse.ts"],"names":[],"mappings":";AACA;;;;;;GAMG"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* abmind hook-postToolUse — Kiro CLI postToolUse hook (#634).
|
|
4
|
+
*
|
|
5
|
+
* Captures tool usage summaries into a sidecar file for richer memory.
|
|
6
|
+
* The stop hook reads this sidecar and includes it in the recorded turn.
|
|
7
|
+
* Exit 0 always — never blocks.
|
|
8
|
+
*/
|
|
9
|
+
import { runCliRaw } from "../src/cli-runner-raw.js";
|
|
10
|
+
import { hooksDisabled, logHookError, readStdinJson, ensureHooksDir } from "../src/hook-helpers.js";
|
|
11
|
+
import { abmindHooksDir, hookSidecarKey } from "../src/mem-paths.js";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import { appendFileSync, readFileSync, writeFileSync } from "node:fs";
|
|
14
|
+
const MAX_ENTRIES = 50;
|
|
15
|
+
const MAX_LINE = 120;
|
|
16
|
+
function toolsSidecarPath() {
|
|
17
|
+
return join(abmindHooksDir(), `tools-${hookSidecarKey()}.sidecar`);
|
|
18
|
+
}
|
|
19
|
+
function truncate(s, max) {
|
|
20
|
+
return s.length <= max ? s : s.slice(0, max - 3) + "...";
|
|
21
|
+
}
|
|
22
|
+
await runCliRaw(import.meta.url, {
|
|
23
|
+
name: "abmind-hook-postToolUse",
|
|
24
|
+
help: `Usage:
|
|
25
|
+
abmind hook-postToolUse
|
|
26
|
+
|
|
27
|
+
Kiro CLI postToolUse hook. Captures tool usage into a sidecar file.
|
|
28
|
+
The stop hook includes this in the recorded turn for richer memory.
|
|
29
|
+
|
|
30
|
+
Env var: ABMIND_HOOKS_DISABLED=true disables all hooks.`,
|
|
31
|
+
flags: [],
|
|
32
|
+
handler: async () => {
|
|
33
|
+
ensureHooksDir();
|
|
34
|
+
if (hooksDisabled()) {
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const payload = await readStdinJson();
|
|
39
|
+
if (!payload?.tool_name) {
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
const toolName = payload.tool_name;
|
|
43
|
+
const input = payload.tool_input ?? {};
|
|
44
|
+
let line = null;
|
|
45
|
+
if (toolName === "execute_bash" || toolName === "shell") {
|
|
46
|
+
const cmd = String(input.command ?? "").replace(/\s+/g, " ").trim();
|
|
47
|
+
if (cmd)
|
|
48
|
+
line = `bash: ${truncate(cmd, MAX_LINE)}`;
|
|
49
|
+
}
|
|
50
|
+
else if (toolName === "fs_write" || toolName === "write") {
|
|
51
|
+
const path = String(input.path ?? "");
|
|
52
|
+
const op = String(input.command ?? "write");
|
|
53
|
+
if (path)
|
|
54
|
+
line = `write: ${path} (${op})`;
|
|
55
|
+
}
|
|
56
|
+
else if (toolName === "use_aws" || toolName === "aws") {
|
|
57
|
+
const svc = String(input.service_name ?? "");
|
|
58
|
+
const op = String(input.operation_name ?? "");
|
|
59
|
+
if (svc)
|
|
60
|
+
line = `aws: ${svc} ${op}`;
|
|
61
|
+
}
|
|
62
|
+
else if (toolName === "use_subagent") {
|
|
63
|
+
const content = input.content;
|
|
64
|
+
const query = content?.subagents?.[0]?.query ?? "";
|
|
65
|
+
if (query)
|
|
66
|
+
line = `subagent: ${truncate(query.replace(/\s+/g, " ").trim(), MAX_LINE)}`;
|
|
67
|
+
}
|
|
68
|
+
if (line) {
|
|
69
|
+
const sidecar = toolsSidecarPath();
|
|
70
|
+
appendFileSync(sidecar, line + "\n", "utf-8");
|
|
71
|
+
// Cap at MAX_ENTRIES
|
|
72
|
+
const content = readFileSync(sidecar, "utf-8");
|
|
73
|
+
const lines = content.split("\n").filter(Boolean);
|
|
74
|
+
if (lines.length > MAX_ENTRIES) {
|
|
75
|
+
writeFileSync(sidecar, lines.slice(-MAX_ENTRIES).join("\n") + "\n", "utf-8");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
logHookError("postToolUse", err);
|
|
81
|
+
}
|
|
82
|
+
process.exit(0);
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=abmind-hook-postToolUse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abmind-hook-postToolUse.js","sourceRoot":"","sources":["../../cli/abmind-hook-postToolUse.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAc,MAAM,SAAS,CAAC;AAElF,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,QAAQ,GAAG,GAAG,CAAC;AAQrB,SAAS,gBAAgB;IACvB,OAAO,IAAI,CAAC,cAAc,EAAE,EAAE,SAAS,cAAc,EAAE,UAAU,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS,EAAE,GAAW;IACtC,OAAO,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;AAC3D,CAAC;AAED,MAAM,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;IAC/B,IAAI,EAAE,yBAAyB;IAC/B,IAAI,EAAE;;;;;;wDAMgD;IACtD,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,KAAK,IAAI,EAAE;QAClB,cAAc,EAAE,CAAC;QACjB,IAAI,aAAa,EAAE,EAAE,CAAC;Y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+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* abmind hook PostCompact — inject fresh recall after context compaction.
|
|
4
|
+
* Re-grounds the agent with relevant memories after context was trimmed.
|
|
5
|
+
* NOTE: Claude Code does not officially support this event yet.
|
|
6
|
+
* When it does, this hook activates automatically.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=abmind-hook-postcompact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abmind-hook-postcompact.d.ts","sourceRoot":"","sources":["../../cli/abmind-hook-postcompact.ts"],"names":[],"mappings":";AACA;;;;;GAKG"}
|