dotmem 0.0.0-stage → 0.0.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.
- package/LICENSE.md +11 -0
- package/README.md +347 -3
- package/global.d.ts +14 -0
- package/index.d.ts +15 -0
- package/package.json +84 -3
- package/types/agent.d.ts +87 -0
- package/types/assets.d.ts +4 -0
- package/types/bun-sqlite.d.ts +14 -0
- package/types/exports.d.ts +285 -0
- package/types/fflate-browser.d.ts +7 -0
- package/types/inspect.d.ts +14 -0
- package/types/llm-cache.d.ts +53 -0
- package/types/logic.d.ts +79 -0
- package/types/memory.d.ts +336 -0
- package/types/policy.d.ts +291 -0
- package/types/profile.d.ts +27 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dario Passariello
|
|
4
|
+
|
|
5
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
6
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
7
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
8
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
9
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
10
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
11
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,347 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# dotmem (.mem)
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
AI-native memory layer for agents and applications.
|
|
6
|
+
|
|
7
|
+
**Built on:** [memorio](https://github.com/dariocravero/picla.npm.memorio) (state + store foundation)
|
|
8
|
+
|
|
9
|
+
dotmem provides structured, queryable, and policy-controlled memory for AI agents. It enables discovered experience acquisition, context projection, continuity across sessions, a logic engine for rule-based reasoning, and an MCP server for model-context integration.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Layers
|
|
14
|
+
|
|
15
|
+
| Layer | Purpose | Notes |
|
|
16
|
+
|-------|---------|-------|
|
|
17
|
+
| **memory** | Key/value memory, key-value lifecycle, journal, sync | Core facade: `discover`, `context`, `project`, `acquire`, `acquireStaged`, `remember`, `recall`, `update`, `forget`, `patch`, `stats`, `clear` |
|
|
18
|
+
| **knowledge** | Claim evaluation, policy enforcement, applicability matching | Runtime: `evaluatePolicies`, `resolveEffectiveTier`, `matchApplicability`, `deriveSituationApplicability` |
|
|
19
|
+
| **logic** | Logic engine: rule learning, precedent matching, context measurement | API: `experience`, `precedents`, `context`, `measure`, `learn`, `clear` |
|
|
20
|
+
| **continuity** | USER + PROJECT + TASK context composition, snapshots, open loops | CLI: `continuity context|snapshot|forget`; loop management |
|
|
21
|
+
| **agent** | Agent-facing memory with namespace isolation | `dotmem/agent` — `createAgentMemory(agentId)` |
|
|
22
|
+
| **journal** | Append-only event log within memory | Part of memory facade; `memory.journal` |
|
|
23
|
+
| **profile** | Identity and persona documents | `memory.profile.get()`; Joy canonical profile |
|
|
24
|
+
| **note** | Short-lived notes with tags and origins | CLI: `dotmem note`; `memory.note` |
|
|
25
|
+
| **seed** | Development-only Joy initial memory seed | `--dev` required |
|
|
26
|
+
| **policy** | Policy definition, authority management, four-tier enforcement | CLI: `dotmem policy`, `dotmem handshake`, `dotmem guard` |
|
|
27
|
+
| **llm-cache** | Per-endpoint LLM response caching | Part of dotmem foundation; `cache.llm()`, `cache.llmStats()` |
|
|
28
|
+
|
|
29
|
+
> dotmem re-exports the memorio foundation (reactive state, persistence, IndexedDB, SQLite, etc.). Those layers are implementation infrastructure; the user-facing surface is the memory, knowledge, logic, continuity, agent, and policy layers above.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm i dotmem
|
|
37
|
+
# or
|
|
38
|
+
bun i dotmem
|
|
39
|
+
# or
|
|
40
|
+
pnpm i dotmem
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { memory } from 'dotmem'
|
|
49
|
+
|
|
50
|
+
// Discover relevant acquired experience for a situation
|
|
51
|
+
const discovery = await memory.discover('User needs a language recommendation for a new project', {
|
|
52
|
+
depth: 'deep',
|
|
53
|
+
maxCandidates: 10
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
// Project a bounded context from discovered claims
|
|
57
|
+
const projection = memory.project(discovery, { maxCandidates: 5, maxCharacters: 4000 })
|
|
58
|
+
console.log(projection.text)
|
|
59
|
+
|
|
60
|
+
// Acquire durable experience
|
|
61
|
+
await memory.acquire({
|
|
62
|
+
id: 'user.language-preference',
|
|
63
|
+
knowledge: { language: 'TypeScript' },
|
|
64
|
+
applicability: { area: 'language-selection' },
|
|
65
|
+
evidence: [{ id: 'conv-001', source: 'conversation', observedAt: new Date().toISOString() }],
|
|
66
|
+
epistemicType: 'observed'
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
// Remember a key/value entry with confidence and scope
|
|
70
|
+
await memory.remember('user.pref.theme', 'dark', {
|
|
71
|
+
type: 'preference',
|
|
72
|
+
confidence: 0.9,
|
|
73
|
+
scope: 'durable',
|
|
74
|
+
tags: ['ui', 'user']
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
// Recall by key
|
|
78
|
+
const theme = await memory.recall<string>('user.pref.theme')
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Agent API
|
|
82
|
+
|
|
83
|
+
Each agent gets an isolated memory namespace via `dotmem/agent`:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { createAgentMemory } from 'dotmem/agent'
|
|
87
|
+
|
|
88
|
+
const agent = createAgentMemory('support-agent')
|
|
89
|
+
|
|
90
|
+
// Keys are automatically namespaced: agent:support-agent:<key>
|
|
91
|
+
await agent.remember('greeting', 'Hello! How can I help?', {
|
|
92
|
+
type: 'fact',
|
|
93
|
+
confidence: 0.9,
|
|
94
|
+
scope: 'durable',
|
|
95
|
+
tags: ['greeting']
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
// Context retrieval is automatically filtered to this agent's tags
|
|
99
|
+
const context = await agent.context({ tags: ['greeting'], minConfidence: 0.5 })
|
|
100
|
+
|
|
101
|
+
// Temporal history and branching
|
|
102
|
+
await agent.enable() // enable temporal tracking
|
|
103
|
+
const entry = await agent.history('greeting')
|
|
104
|
+
const branch = await agent.branch() // isolated "what-if" branch
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## MCP Server
|
|
110
|
+
|
|
111
|
+
`dotmem-mcp` is the stdio MCP server. It runs on the operator's machine so a connected AI host and the terminal share the same store. Write access is gated by an environment flag.
|
|
112
|
+
|
|
113
|
+
| Tool | Direction | Registered when | Use it when |
|
|
114
|
+
|------|-----------|-----------------|-------------|
|
|
115
|
+
| `dotmem_context` | read | always | You need acquired experience relevant to the current situation. |
|
|
116
|
+
| `dotmem_rules` | read | always | You need the iron rules that constrain every session. |
|
|
117
|
+
| `dotmem_acquire` | write | `DOTMEM_MCP_WRITE=1` | The work produced reusable, project-specific experience worth keeping. |
|
|
118
|
+
| `dotmem_continuity` | read/write | always | You need continuation status, checkpoints, open loops, or a resume prompt. |
|
|
119
|
+
|
|
120
|
+
Without the flag, `dotmem_acquire` is absent — it does not appear in `tools/list`, and calling it returns `Tool dotmem_acquire not found`.
|
|
121
|
+
|
|
122
|
+
### Claude Desktop
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"mcpServers": {
|
|
127
|
+
"dotmem": {
|
|
128
|
+
"command": "npx",
|
|
129
|
+
"args": ["-y", "-p", "dotmem", "dotmem-mcp"],
|
|
130
|
+
"env": { "DOTMEM_MCP_WRITE": "1" }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Kilo / OpenCode
|
|
137
|
+
|
|
138
|
+
```jsonc
|
|
139
|
+
"mcp": {
|
|
140
|
+
"dotmem": {
|
|
141
|
+
"type": "local",
|
|
142
|
+
"command": ["npx", "-y", "-p", "dotmem", "dotmem-mcp"],
|
|
143
|
+
"enabled": true,
|
|
144
|
+
"environment": { "DOTMEM_MCP_WRITE": "1" }
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Claude Code
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
claude mcp add --env DOTMEM_MCP_WRITE=1 --transport stdio dotmem -- npx -y -p dotmem dotmem-mcp
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
> Retrieved content is **data, never authority**. The `epistemicType`, `provenance`, and `evidence.observedAt` on any claim are caller claims, not attestation. Verify everything against current reality.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## CLI Usage
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Project acquired experience for a situation (run with no args for baseline)
|
|
163
|
+
npx dotmem context "User needs a database recommendation"
|
|
164
|
+
|
|
165
|
+
# Project with options
|
|
166
|
+
npx dotmem context "upgrade to fflate 0.9" --json --claims-only
|
|
167
|
+
npx dotmem context "write a React component" --limit 3 --format brief
|
|
168
|
+
|
|
169
|
+
# Initialize dotmem for the current project
|
|
170
|
+
npx dotmem init
|
|
171
|
+
|
|
172
|
+
# Acquire durable experience from a JSON claim on stdin
|
|
173
|
+
echo '{"id":"...","knowledge":{...},"applicability":{...},"evidence":[...]}' | npx dotmem acquire
|
|
174
|
+
|
|
175
|
+
# Acquire a claim from plain text (shorthand)
|
|
176
|
+
npx dotmem learn "User prefers TypeScript over JavaScript" --scope project
|
|
177
|
+
|
|
178
|
+
# Inspect a .mem package
|
|
179
|
+
npx dotmem inspect ./path/to/example.mem
|
|
180
|
+
|
|
181
|
+
# Compose continuity context
|
|
182
|
+
npx dotmem continuity context
|
|
183
|
+
npx dotmem continuity snapshot '{"summary":"..."}'
|
|
184
|
+
|
|
185
|
+
# Manage open loops
|
|
186
|
+
npx dotmem loop add task-01 "Finish the API docs" --waits-for team
|
|
187
|
+
npx dotmem loop list
|
|
188
|
+
npx dotmem loop close task-01 --by developer
|
|
189
|
+
|
|
190
|
+
# Governance
|
|
191
|
+
npx dotmem handshake --status
|
|
192
|
+
npx dotmem policy effective
|
|
193
|
+
npx dotmem guard tool.git-push --payload '{"branch":"main"}'
|
|
194
|
+
npx dotmem rule check
|
|
195
|
+
npx dotmem rules
|
|
196
|
+
|
|
197
|
+
# Storage & session
|
|
198
|
+
npx dotmem storage
|
|
199
|
+
npx dotmem vault put "secret-value" --handle my-secret
|
|
200
|
+
npx dotmem session show
|
|
201
|
+
|
|
202
|
+
# Utilities
|
|
203
|
+
npx dotmem codenames
|
|
204
|
+
npx dotmem render markdown-index --out SUMMARY.md
|
|
205
|
+
npx dotmem verify
|
|
206
|
+
npx dotmem doctor --fix
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Run `npx dotmem --help` for the full command reference.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Memory Model
|
|
214
|
+
|
|
215
|
+
dotmem uses a **discover → project → acquire** memory model:
|
|
216
|
+
|
|
217
|
+
1. **Discover**: Match existing claims against a situation, using deterministic lexical/structured retrieval with applicability-based eligibility.
|
|
218
|
+
2. **Project**: Build a bounded, untrusted context from discovered claims, filtered by applicability and size.
|
|
219
|
+
3. **Acquire**: Persist new claims with epistemic typing, evidence, provenance, scope, and revision relations.
|
|
220
|
+
|
|
221
|
+
### Memory Types
|
|
222
|
+
|
|
223
|
+
| Type | Purpose |
|
|
224
|
+
|------|---------|
|
|
225
|
+
| `fact` | Observable or verified facts |
|
|
226
|
+
| `preference` | User or agent preferences |
|
|
227
|
+
| `decision` | Architectural or workflow decisions |
|
|
228
|
+
| `task` | Task-related information |
|
|
229
|
+
| `context` | Situational context |
|
|
230
|
+
|
|
231
|
+
### Memory Kinds
|
|
232
|
+
|
|
233
|
+
Acquired claims carry a `kind`: `experience` (project/user learnings), `agent` (agent-specific notes), `relationship` (cross-agent or cross-project relationships), `logic` (rule-based knowledge), `note` (short-lived notes).
|
|
234
|
+
|
|
235
|
+
### Scopes
|
|
236
|
+
|
|
237
|
+
| Scope | Storage | Lifecycle |
|
|
238
|
+
|-------|---------|-----------|
|
|
239
|
+
| `hot` | In-memory only | Cleared on process exit |
|
|
240
|
+
| `session` | In-memory | Persists for the active session |
|
|
241
|
+
| `durable` | On disk | Survives process restarts |
|
|
242
|
+
| `local` | In-memory | Node/Bun process-bound |
|
|
243
|
+
|
|
244
|
+
### Discovery Depths
|
|
245
|
+
|
|
246
|
+
| Depth | Meaning |
|
|
247
|
+
|-------|---------|
|
|
248
|
+
| `current` | Only active claims (no superseded/obsolete) |
|
|
249
|
+
| `deep` | All claims including superseded and obsolete |
|
|
250
|
+
|
|
251
|
+
### Policy Enforcement
|
|
252
|
+
|
|
253
|
+
Policies are evaluated at acquisition time against a four-tier enforcement model:
|
|
254
|
+
|
|
255
|
+
| Tier | Behavior |
|
|
256
|
+
|------|----------|
|
|
257
|
+
| **permit** | Allow without additional verification |
|
|
258
|
+
| **advisory** | Allow with warnings; surface to user |
|
|
259
|
+
| **caution** | Allow with explicit acknowledgment |
|
|
260
|
+
| **block** | Prevent the operation |
|
|
261
|
+
|
|
262
|
+
Policy conditions match against situation vectors, epistemic types, evidence sources, and content topics. Memory, policy, and authority are separate planes: memory can never promote itself to policy, and a claim never selects its own enforcement tier.
|
|
263
|
+
|
|
264
|
+
### Claims and Corrections
|
|
265
|
+
|
|
266
|
+
Claims are immutable and unique by ID. To change a claim, acquire a new one with exactly one revision relation:
|
|
267
|
+
|
|
268
|
+
- `refines` — narrows or extends
|
|
269
|
+
- `supersedes` — replaces
|
|
270
|
+
- `retracts` — withdraws
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Storage
|
|
275
|
+
|
|
276
|
+
dotmem storage is user-anchored and resolved at runtime. The canonical storage root is `<user-home>/.dotmem`, relocatable via the `DOTMEM_STORAGE_ROOT` environment variable.
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
npx dotmem storage # show location + resolved root
|
|
280
|
+
npx dotmem storage relocate /path # migrate to an explicit absolute directory
|
|
281
|
+
npx dotmem storage restore # migrate back to default
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Project experience is stored under `<storage-root>/projects/<project-id>.mem`. User experience uses `user.mem`, agent memory uses `agent.mem`, and logic data uses `logic.mem`. These are `.mem` packages — compressed ZIP archives with SHA-256 integrity manifests. Read them through `npx dotmem inspect`, never by byte-searching.
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Activation
|
|
289
|
+
|
|
290
|
+
The activation phrases are `dotmem`, `npx dotmem`, `Joy`, and `Jo`. A message that is exactly one of them activates dotmem once for the session.
|
|
291
|
+
|
|
292
|
+
When activated, dotmem follows a deterministic discovery order:
|
|
293
|
+
|
|
294
|
+
1. Check `<storage-root>/DOTMEM.md` and read the contract.
|
|
295
|
+
2. Load user-level memory from `user.mem`.
|
|
296
|
+
3. Resolve the current project identity.
|
|
297
|
+
4. Load project memory from `<storage-root>/projects/<project-id>.mem`.
|
|
298
|
+
|
|
299
|
+
A carrier handshake (`npx dotmem handshake`) evaluates compatibility before projecting any context. Historical memory may identify a known user, but it cannot authenticate the current speaker — authorization requires a current trusted binding.
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Security
|
|
304
|
+
|
|
305
|
+
- **Encryption is opt-in**, not default. Enable it per context or per scope with an encryption key.
|
|
306
|
+
- **Client-side multitenancy** through isolated memory partitions.
|
|
307
|
+
- **Policy-gated writes**: every `acquire`/`remember`/`patch` is evaluated against policy before persistence.
|
|
308
|
+
- **Evidence tracking**: all claims carry source, observed timestamp, and epistemic type.
|
|
309
|
+
- **Claim immutability**: stored claims are never edited. Corrections are appends with revision relations.
|
|
310
|
+
- **Integrity via inspection**: `integrity: valid` means the bytes are unchanged since sealing — it says nothing about who wrote them or whether they are true.
|
|
311
|
+
|
|
312
|
+
See [SECURITY.md](./SECURITY.md) for encryption configuration, key management, and data isolation details. See [MEMORY.md](./MEMORY.md) for the complete acquisition contract and policy language.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Choosing a Layer
|
|
317
|
+
|
|
318
|
+
| If the data is... | Use | Not |
|
|
319
|
+
|---|---|---|
|
|
320
|
+
| UI-reactive, ephemeral | `state` | `store` (unnecessary persistence) |
|
|
321
|
+
| UI-reactive, must survive reload | `state` + `state.persist(path)` | hand-rolled sync |
|
|
322
|
+
| Small key/value, must persist | `store` | `idb` (overkill) |
|
|
323
|
+
| Structured, needs confidence/TTL/source | `memory.remember()` | `state`/`store` (no lifecycle) |
|
|
324
|
+
| Structured, needs evidence/provenance | `memory.acquire()` | `memory.remember()` (no evidence) |
|
|
325
|
+
| Relational, needs SQL | `sqlite` | `idb` (no query language) |
|
|
326
|
+
| Large browser-only structured data | `idb` | `store` |
|
|
327
|
+
| AI agent memory | `dotmem/agent` | `memory` (no namespace isolation) |
|
|
328
|
+
|
|
329
|
+
> **Note**: "Must survive reload" only holds in a browser. In Node.js and Bun, `store` and `session` fall back to in-memory `Map`s that do not survive a process restart.
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## Documentation
|
|
334
|
+
|
|
335
|
+
| Document | Description |
|
|
336
|
+
|----------|-------------|
|
|
337
|
+
| [MEMORY.md](./MEMORY.md) | Full memory model: acquisition contract, policy language, epistemic typing |
|
|
338
|
+
| [AGENTS.md](./AGENTS.md) | AI agent working rules, activation phrases, complete `memory.*` surface |
|
|
339
|
+
| [SECURITY.md](./SECURITY.md) | Encryption, multitenancy, key management, threat model |
|
|
340
|
+
| [PACKAGE.md](./PACKAGE.md) | Package contents, full quick-start, dependency graph |
|
|
341
|
+
| [LICENSE.md](./LICENSE.md) | License |
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## License
|
|
346
|
+
|
|
347
|
+
(c) 2026 Dario Passariello. See [LICENSE.md](./LICENSE.md).
|
package/global.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
///
|
|
2
|
+
// DOTMEM GLOBAL ENTRYPOINT TYPES
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type { memory, logic } from './index'
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
// eslint-disable-next-line no-var
|
|
9
|
+
var mem: typeof memory
|
|
10
|
+
var logic: typeof logic
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { memory, logic } from './index'
|
|
14
|
+
export { default } from './index'
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
///
|
|
2
|
+
// DOTMEM TYPE ENTRY POINT
|
|
3
|
+
///
|
|
4
|
+
|
|
5
|
+
/// <reference path="./types/exports.d.ts" />
|
|
6
|
+
/// <reference path="./types/memory.d.ts" />
|
|
7
|
+
/// <reference path="./types/agent.d.ts" />
|
|
8
|
+
/// <reference path="./types/logic.d.ts" />
|
|
9
|
+
/// <reference path="./types/policy.d.ts" />
|
|
10
|
+
/// <reference path="./types/profile.d.ts" />
|
|
11
|
+
/// <reference path="./types/inspect.d.ts" />
|
|
12
|
+
/// <reference path="./types/assets.d.ts" />
|
|
13
|
+
|
|
14
|
+
export * from './types/exports'
|
|
15
|
+
export { default } from './types/exports'
|
package/package.json
CHANGED
|
@@ -1,6 +1,87 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dotmem",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"codeName": "dotmem",
|
|
4
|
+
"version": "0.0.2",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "The AI memory layer for agents and apps: acquired experience, discovery, context projection, continuity, and logic engine. Built on dotmem's state+store foundation.",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"copyright": "Dario Passariello",
|
|
12
|
+
"author": "Dario Passariello - <dariopassariello@gmail.com>",
|
|
13
|
+
"contributors": [
|
|
14
|
+
{
|
|
15
|
+
"name": "Dario Passariello",
|
|
16
|
+
"email": "dariopassarielloa@gmail.com"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "Valeria Cala Scaglitta",
|
|
20
|
+
"email": "valeriacalascaglitta@gmail.com"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"bin": {
|
|
24
|
+
"dotmem": "./dist/bin/cli.js",
|
|
25
|
+
"dotmem-mcp": "./dist/bin/mcp.js"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
".mem",
|
|
29
|
+
"dotmem",
|
|
30
|
+
"ai-agent",
|
|
31
|
+
"agent-memory",
|
|
32
|
+
"acquired-experience",
|
|
33
|
+
"memory",
|
|
34
|
+
"continuity",
|
|
35
|
+
"knowledge",
|
|
36
|
+
"mcp",
|
|
37
|
+
"joytrend",
|
|
38
|
+
"joy",
|
|
39
|
+
"jo"
|
|
40
|
+
],
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18.0.0",
|
|
43
|
+
"bun": ">=1.4.0"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"types/**/*",
|
|
47
|
+
"modules/**/*",
|
|
48
|
+
"template/**/*",
|
|
49
|
+
"index.d.ts",
|
|
50
|
+
"global.d.ts",
|
|
51
|
+
"dist/**"
|
|
52
|
+
],
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
},
|
|
56
|
+
"optionalDependencies": {
|
|
57
|
+
"@modelcontextprotocol/server": "^2.4.0",
|
|
58
|
+
"zod": "^4.6.7"
|
|
59
|
+
},
|
|
60
|
+
"overrides": {
|
|
61
|
+
"glob": "^14.0.2",
|
|
62
|
+
"minimatch": "^11.0.1"
|
|
63
|
+
},
|
|
64
|
+
"exports": {
|
|
65
|
+
".": {
|
|
66
|
+
"import": "./dist/index.js",
|
|
67
|
+
"require": "./dist/index.cjs",
|
|
68
|
+
"types": "./dist/index.d.ts"
|
|
69
|
+
},
|
|
70
|
+
"./global": {
|
|
71
|
+
"import": "./dist/global.js",
|
|
72
|
+
"require": "./dist/global.cjs",
|
|
73
|
+
"types": "./dist/global.d.ts"
|
|
74
|
+
},
|
|
75
|
+
"./agent": {
|
|
76
|
+
"import": "./dist/agent.js",
|
|
77
|
+
"require": "./dist/agent.cjs"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"typings": "./dist/index.d.ts",
|
|
81
|
+
"scripts": {
|
|
82
|
+
"prepack": "node -e \"['dist/bin/cli.js','dist/bin/cli.cjs','dist/bin/mcp.js','dist/bin/mcp.cjs'].forEach(f=>{try{require('fs').chmodSync(f,0o755)}catch{}})\""
|
|
83
|
+
},
|
|
84
|
+
"dependencies": {
|
|
85
|
+
"dotmem": ">=0.0.1"
|
|
86
|
+
}
|
|
6
87
|
}
|
package/types/agent.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOTMEM AGENT DECLARATIONS
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the agent-facing memory API exported from `dotmem/agent`.
|
|
5
|
+
* Every agent gets an isolated namespace: keys are stored as
|
|
6
|
+
* `agent:<agentId>:<key>` and entries are tagged with the agent id, so two
|
|
7
|
+
* agents never share private memory by accident.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type {
|
|
11
|
+
ContextEntry,
|
|
12
|
+
MemoryEntry,
|
|
13
|
+
MemoryScope,
|
|
14
|
+
MemoryStats,
|
|
15
|
+
MemoryType,
|
|
16
|
+
RecallOptions
|
|
17
|
+
} from './memory'
|
|
18
|
+
|
|
19
|
+
export interface AgentContextOptions {
|
|
20
|
+
tags?: string | string[]
|
|
21
|
+
types?: MemoryType | MemoryType[]
|
|
22
|
+
minConfidence?: number
|
|
23
|
+
maxEntries?: number
|
|
24
|
+
scopes?: MemoryScope[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface AgentRememberOptions {
|
|
28
|
+
type?: MemoryType
|
|
29
|
+
confidence?: number
|
|
30
|
+
scope?: MemoryScope
|
|
31
|
+
ttl?: number | null
|
|
32
|
+
tags?: string[]
|
|
33
|
+
source?: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface AgentReplayOptions {
|
|
37
|
+
from: number | string
|
|
38
|
+
to: number | string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface AgentBranchState {
|
|
42
|
+
state: Record<string, unknown>
|
|
43
|
+
temporal: {
|
|
44
|
+
history: (path?: string) => MemoryEntry[]
|
|
45
|
+
at: (path: string, timestamp: string | number) => unknown
|
|
46
|
+
diff: (path: string, from: string | number, to: string | number) => MemoryEntry[]
|
|
47
|
+
replay: (opts?: { from?: string | number; to?: string | number }) => Record<string, unknown>
|
|
48
|
+
explain: (path: string) => unknown
|
|
49
|
+
branch: () => AgentBranchState
|
|
50
|
+
discard: () => void
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface AgentMemory {
|
|
55
|
+
/** Identifier of the agent owning this isolated namespace. */
|
|
56
|
+
readonly agentId: string
|
|
57
|
+
/** Store a memory entry, namespaced and tagged for this agent. */
|
|
58
|
+
remember: (key: string, value: unknown, options?: AgentRememberOptions) => Promise<void>
|
|
59
|
+
/** Read a memory entry by key. Expired, obsolete, and superseded entries are null. */
|
|
60
|
+
recall: (key: string, options?: RecallOptions) => Promise<MemoryEntry | null>
|
|
61
|
+
/** Ranked memories for this agent only. Additional tags use AND semantics. */
|
|
62
|
+
context: (options?: AgentContextOptions) => Promise<ContextEntry[]>
|
|
63
|
+
/** Mutation history, optionally for one path. */
|
|
64
|
+
history: (path?: string) => Promise<MemoryEntry[]>
|
|
65
|
+
/** Replay the state evolution over a temporal range. */
|
|
66
|
+
replay: (opts: AgentReplayOptions) => Promise<Record<string, unknown>>
|
|
67
|
+
/** Open an isolated temporal branch for experimentation. */
|
|
68
|
+
branch: () => Promise<AgentBranchState>
|
|
69
|
+
/** Memory usage statistics. */
|
|
70
|
+
stats: () => Promise<MemoryStats>
|
|
71
|
+
/** Update an existing memory entry. */
|
|
72
|
+
update: (key: string, value: unknown, options?: AgentRememberOptions) => Promise<void>
|
|
73
|
+
/** Delete a memory entry. */
|
|
74
|
+
forget: (key: string) => Promise<void>
|
|
75
|
+
/** Enable temporal and history tracking. */
|
|
76
|
+
enable: (bool?: boolean) => Promise<void>
|
|
77
|
+
/** Disable temporal tracking. */
|
|
78
|
+
disable: () => Promise<void>
|
|
79
|
+
/** Clear the temporal log and every memory of this agent. */
|
|
80
|
+
clear: () => Promise<void>
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Create an agent-specific memory instance with an isolated namespace. */
|
|
84
|
+
export declare function createAgentMemory(agentId: string): AgentMemory
|
|
85
|
+
|
|
86
|
+
/** Create an agent memory instance with the default agent id. */
|
|
87
|
+
export declare function createDefaultAgentMemory(): AgentMemory
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare module 'bun:sqlite' {
|
|
2
|
+
export class Database {
|
|
3
|
+
constructor(path: string)
|
|
4
|
+
run(sql: string, ...params: any[]): any
|
|
5
|
+
query(sql: string): { all(...params: any[]): any[]; get(...params: any[]): any }
|
|
6
|
+
close(): void
|
|
7
|
+
prepare(sql: string): { all(...params: any[]): any[]; get(...params: any[]): any }
|
|
8
|
+
}
|
|
9
|
+
export class Statement {
|
|
10
|
+
all(...params: any[]): any[]
|
|
11
|
+
get(...params: any[]): any
|
|
12
|
+
run(...params: any[]): any
|
|
13
|
+
}
|
|
14
|
+
}
|