dotmem 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DOTMEM-SHORT-API.md +318 -0
- package/DOTMEM-SHORT-COMPONENTS.md +129 -0
- package/agent.cjs +1 -226
- package/agent.js +1 -223
- package/bin/cli.cjs +1 -34
- package/bin/cli.js +1 -27
- package/bin/mcp.cjs +1 -21
- package/bin/mcp.js +1 -15
- package/built-in-context.json +6 -6
- package/cli.cjs +258 -19645
- package/cli.js +257 -19575
- package/context/templates/AI.md +1 -1
- package/env.cjs +1 -6
- package/env.js +1 -4
- package/global.cjs +49 -11469
- package/global.d.ts +0 -1
- package/global.js +49 -11437
- package/index.cjs +91 -15354
- package/index.d.ts +2 -0
- package/index.js +91 -15251
- package/mcp.cjs +117 -14587
- package/mcp.js +117 -14551
- package/package.json +3 -2
- package/types/exports.d.ts +43 -66
- package/types/global-types.d.ts +3652 -0
- package/types/llm-cache.d.ts +6 -6
- package/types/logic.d.ts +60 -79
- package/types/memory.d.ts +48 -92
- package/types/policy.d.ts +290 -290
- package/types/profile.d.ts +2 -2
- package/types/agent.d.ts +0 -87
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
# Dotmem Short API
|
|
2
|
+
|
|
3
|
+
Normative specification for the `short()` intent-based interface that exposes Dotmem's existing public capabilities through simple JSON input.
|
|
4
|
+
|
|
5
|
+
## Public API Contract
|
|
6
|
+
|
|
7
|
+
### Entry Points
|
|
8
|
+
|
|
9
|
+
**Standalone function:**
|
|
10
|
+
```ts
|
|
11
|
+
await short({ important: "Do not modify production" })
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
**Instance method:**
|
|
15
|
+
```ts
|
|
16
|
+
await dotmem.short({ important: "Do not modify production" })
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Both entry points accept exactly one argument: a JSON object where each key is an intent name and each value is the intent payload. Both share the same resolver, validation, dispatch, execution, and result implementation.
|
|
20
|
+
|
|
21
|
+
### Prohibited Syntax
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
short("important", "Do not modify production") // ERROR: positional arguments prohibited
|
|
25
|
+
dotmem.short("important", "Do not modify production") // ERROR: positional arguments prohibited
|
|
26
|
+
short.important("Do not modify production") // ERROR: per-intent methods prohibited
|
|
27
|
+
short.note("...") // ERROR: per-intent methods prohibited
|
|
28
|
+
dotmem.short.note("...") // ERROR: per-intent methods prohibited
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Intent Catalogue
|
|
32
|
+
|
|
33
|
+
| Category | Intent | Description | Payload Form |
|
|
34
|
+
|----------|--------|-------------|--------------|
|
|
35
|
+
| Knowledge | `note` | Store/retrieve markdown notes | string or structured object |
|
|
36
|
+
| Knowledge | `remember` | Store key/value memory | structured object |
|
|
37
|
+
| Knowledge | `recall` | Retrieve memory by query | structured object |
|
|
38
|
+
| Knowledge | `forget` | Delete key/value memory | structured object |
|
|
39
|
+
| Knowledge | `update` | Update key/value memory | structured object |
|
|
40
|
+
| Knowledge | `patch` | Patch memory entry fields | structured object |
|
|
41
|
+
| Knowledge | `acquire` | Durable knowledge acquisition | structured object |
|
|
42
|
+
| Knowledge | `verify` | Claim freshness verification | empty object |
|
|
43
|
+
| Priority | `important` | Record behavioral guidance | string or object |
|
|
44
|
+
| Priority | `avoid` | Record behavioral guidance to avoid | string or object |
|
|
45
|
+
| Priority | `prefer` | Record behavioral preference | string or object |
|
|
46
|
+
| Priority | `warning` | Record behavioral warning | string or object |
|
|
47
|
+
| Context | `context` | Provide acquired context for a situation | structured object |
|
|
48
|
+
| Context | `bootstrap` | Initialize session context | structured object |
|
|
49
|
+
| Rules | `rules` | Query iron rules reference | structured object |
|
|
50
|
+
| Governance | `policy` | Evaluate existing policies | structured object |
|
|
51
|
+
| Projects | `project` | Project discovery and management | structured object |
|
|
52
|
+
| Projects | `discover` | Experience discovery | structured object |
|
|
53
|
+
| Inspection | `inspect` | Package/store inspection | structured object |
|
|
54
|
+
| Inspection | `dump` | Memory stats listing | empty object |
|
|
55
|
+
| Inspection | `audit` | Audit trail query | empty object |
|
|
56
|
+
| Maintenance | `health` | System health check | empty object |
|
|
57
|
+
| Maintenance | `doctor` | System diagnostics | empty object |
|
|
58
|
+
| Maintenance | `repair` | Policy repair (blocked, requires confirmation) | structured object |
|
|
59
|
+
| Maintenance | `cleanup` | Clear non-durable memory | empty object |
|
|
60
|
+
| Relationships | `relate` | Claim relationships (refines/supersedes/retracts) | structured object |
|
|
61
|
+
| Relationships | `link` | Link claims via supersedes | structured object |
|
|
62
|
+
| Relationships | `unlink` | Unlink claims via retracts | structured object |
|
|
63
|
+
| Relationships | `merge` | Merge/override notes | structured object |
|
|
64
|
+
| Configuration | `configure` | Runtime configuration | structured object |
|
|
65
|
+
| Configuration | `capabilities` | Query runtime capabilities | empty object |
|
|
66
|
+
| Development | `seed` | Joy memory seed (DOTMEM_DEV_SEED=1 required) | structured object |
|
|
67
|
+
| Conversation | `capture` | Conversational capture | structured object |
|
|
68
|
+
|
|
69
|
+
## Payload Schemas
|
|
70
|
+
|
|
71
|
+
### `note`
|
|
72
|
+
```ts
|
|
73
|
+
// Plain text (auto-generates id)
|
|
74
|
+
short({ note: "The production server uses Debian 13" })
|
|
75
|
+
|
|
76
|
+
// Structured
|
|
77
|
+
short({
|
|
78
|
+
note: {
|
|
79
|
+
id: "note-1",
|
|
80
|
+
title: "Production server",
|
|
81
|
+
content: "Debian 13",
|
|
82
|
+
origin: "deployment",
|
|
83
|
+
scope: "user",
|
|
84
|
+
tag: "infra"
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### `remember`
|
|
90
|
+
```ts
|
|
91
|
+
short({ remember: { key: "dbVersion", value: "13", scope: "project" } })
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### `recall`
|
|
95
|
+
```ts
|
|
96
|
+
short({ recall: "dbVersion" })
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### `forget`
|
|
100
|
+
```ts
|
|
101
|
+
short({ forget: "oldKey" })
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### `update`
|
|
105
|
+
```ts
|
|
106
|
+
short({ update: { key: "dbVersion", value: "14" } })
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### `patch`
|
|
110
|
+
```ts
|
|
111
|
+
short({ patch: { key: "config", patches: [{ op: "set", path: "timeout", value: 30 }] } })
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### `acquire`
|
|
115
|
+
```ts
|
|
116
|
+
short({ acquire: { knowledge: { rule: "use strict" }, applicability: { situation: "new-project" } } })
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### `verify`
|
|
120
|
+
```ts
|
|
121
|
+
short({ verify: {} })
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### `important` / `avoid` / `prefer` / `warning`
|
|
125
|
+
```ts
|
|
126
|
+
short({ important: "Do not modify production" })
|
|
127
|
+
short({ avoid: { guidance: "Deploy without a backup" } })
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### `context`
|
|
131
|
+
```ts
|
|
132
|
+
short({ context: { situation: "CI pipeline configuration", maxCandidates: 5 } })
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### `bootstrap`
|
|
136
|
+
```ts
|
|
137
|
+
short({ bootstrap: { situation: "New project setup" } })
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### `rules`
|
|
141
|
+
```ts
|
|
142
|
+
short({ rules: { expand: true } })
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### `policy`
|
|
146
|
+
```ts
|
|
147
|
+
short({ policy: { event: "artifact.write", claims: [], policies: [] } })
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### `project`
|
|
151
|
+
```ts
|
|
152
|
+
short({ project: { situation: "New React project", maxCandidates: 5 } })
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### `discover`
|
|
156
|
+
```ts
|
|
157
|
+
short({ discover: { situation: "CI pipeline configuration", depth: "deep" } })
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### `inspect`
|
|
161
|
+
```ts
|
|
162
|
+
short({ inspect: { file: "/path/to/file.mem", action: "claims" } })
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### `dump`
|
|
166
|
+
```ts
|
|
167
|
+
short({ dump: {} })
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### `audit`
|
|
171
|
+
```ts
|
|
172
|
+
short({ audit: {} })
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### `health`
|
|
176
|
+
```ts
|
|
177
|
+
short({ health: {} })
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### `doctor`
|
|
181
|
+
```ts
|
|
182
|
+
short({ doctor: {} })
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### `repair`
|
|
186
|
+
```ts
|
|
187
|
+
short({ repair: { type: "policy" } })
|
|
188
|
+
// Returns blocked: requires governance authority and explicit confirmation
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### `cleanup`
|
|
192
|
+
```ts
|
|
193
|
+
short({ cleanup: {} })
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### `relate` / `link` / `unlink`
|
|
197
|
+
```ts
|
|
198
|
+
short({ relate: { kind: "supersedes", claimIds: ["claim-1", "claim-2"] } })
|
|
199
|
+
short({ link: { kind: "supersedes", claimIds: ["claim-1"] } })
|
|
200
|
+
short({ unlink: { kind: "retracts", claimIds: ["claim-1"] } })
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### `merge`
|
|
204
|
+
```ts
|
|
205
|
+
short({ merge: { id: "note-1", previousId: "note-0", title: "Updated", content: "...", origin: "short-api" } })
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### `configure`
|
|
209
|
+
```ts
|
|
210
|
+
short({ configure: { sync: { provider: "s3" } } })
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### `capabilities`
|
|
214
|
+
```ts
|
|
215
|
+
short({ capabilities: {} })
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### `seed` (dev-only)
|
|
219
|
+
```ts
|
|
220
|
+
// Requires DOTMEM_DEV_SEED=1
|
|
221
|
+
short({ seed: { id: "seed-1", title: "Dev seed", content: "...", origin: "dev" } })
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### `capture`
|
|
225
|
+
```ts
|
|
226
|
+
short({ capture: { messages: [{ role: "user", content: "Hello" }], options: { conversationId: "conv-1" } } })
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Result Contract
|
|
230
|
+
|
|
231
|
+
All calls return a `ShortAggregateResult` envelope:
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
interface ShortAggregateResult {
|
|
235
|
+
success: boolean // true only if every intent completed
|
|
236
|
+
partial: boolean // true if at least one intent failed
|
|
237
|
+
results: {
|
|
238
|
+
[intent: string]: {
|
|
239
|
+
success: boolean
|
|
240
|
+
status: 'completed' | 'failed' | 'blocked' | 'pending' | 'skipped'
|
|
241
|
+
value?: unknown
|
|
242
|
+
error?: {
|
|
243
|
+
code: string
|
|
244
|
+
message: string
|
|
245
|
+
remediation?: string
|
|
246
|
+
intent: string
|
|
247
|
+
stateChanged?: boolean
|
|
248
|
+
confirmation?: { required: boolean; reason: string; action?: string }
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
errors: Array<{ code: string; message: string; intent: string; stateChanged?: boolean }>
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Single-intent result
|
|
257
|
+
```ts
|
|
258
|
+
const result = await short({ note: "Test note" })
|
|
259
|
+
// result.success === true
|
|
260
|
+
// result.results.note.success === true
|
|
261
|
+
// result.results.note.value === "note-123"
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Multi-intent result
|
|
265
|
+
```ts
|
|
266
|
+
const result = await short({
|
|
267
|
+
important: "Do not modify production",
|
|
268
|
+
note: "Server uses Debian 13",
|
|
269
|
+
recall: "dbVersion"
|
|
270
|
+
})
|
|
271
|
+
// result.success === true if all succeeded
|
|
272
|
+
// result.results.<intent> contains per-intent results
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Partial success
|
|
276
|
+
If any intent fails, `success` is `false`, `partial` is `true`, and the `errors` array contains failed intent details. Earlier committed effects are reported accurately - no rollback is attempted.
|
|
277
|
+
|
|
278
|
+
## Error Codes
|
|
279
|
+
|
|
280
|
+
| Code | Meaning | Remediation |
|
|
281
|
+
|------|---------|-------------|
|
|
282
|
+
| `DOTMEM_INVALID_INPUT` | Input is not a JSON object | Pass a plain JSON object |
|
|
283
|
+
| `DOTMEM_UNKNOWN_INTENT` | Intent key is not recognized | Use a supported intent from catalogue |
|
|
284
|
+
| `DOTMEM_INVALID_PAYLOAD` | Payload is malformed | Check intent-specific schema |
|
|
285
|
+
| `DOTMEM_INTENT_ERROR` | Operation failed | Check error message for details |
|
|
286
|
+
| `DOTMEM_CONFIRMATION_REQUIRED` | Operation needs explicit confirmation | Authorize via governance/confirmed flow |
|
|
287
|
+
| `DOTMEM_DEV_SEED_REQUIRED` | Seed requires dev flag | Set DOTMEM_DEV_SEED=1 environment variable |
|
|
288
|
+
|
|
289
|
+
## Execution Semantics
|
|
290
|
+
|
|
291
|
+
- **Order**: Intents execute in declaration order (object key insertion order)
|
|
292
|
+
- **Execution**: Sequential by default; no parallel writes
|
|
293
|
+
- **Atomicity**: Not atomic across intents. Each intent executes independently through its existing API boundary
|
|
294
|
+
- **Rollback**: No automatic rollback. Earlier committed effects remain if a later intent fails
|
|
295
|
+
- **Idempotency**: Per-intent; `remember`/`acquire` with same key/id supersede existing values
|
|
296
|
+
- **Retry**: Non-idempotent mutations are not automatically retried
|
|
297
|
+
|
|
298
|
+
## Security, Trust, Authorization
|
|
299
|
+
|
|
300
|
+
- All mutating operations cross the existing canonical acquisition boundary
|
|
301
|
+
- Policy enforcement operates through the existing tier system (`context`/`precondition`/`hard-precondition`)
|
|
302
|
+
- Conversational overrides are rejected (same as existing `assertNoConversationalOverride`)
|
|
303
|
+
- Authorities cannot be self-granted (same as existing governance guards)
|
|
304
|
+
- Caller-controlled fields cannot self-assign authority, verification metadata, trusted provenance or policy overrides
|
|
305
|
+
- All audit events are logged via the existing security audit system
|
|
306
|
+
- Size limits prevent unbounded growth via `checkAcquireLimits`
|
|
307
|
+
|
|
308
|
+
## Limitations
|
|
309
|
+
|
|
310
|
+
- Multi-intent calls are not atomic across existing API boundaries
|
|
311
|
+
- `schedule`/`remind`/`todo`/`task`/`goal`/`deadline`/`event`/`cancel`/`reschedule` are not directly supported; use continuity/loops APIs directly
|
|
312
|
+
- `repair` with type `policy` is blocked pending governance authority and explicit confirmation
|
|
313
|
+
- `seed` requires `DOTMEM_DEV_SEED=1` environment variable
|
|
314
|
+
- `policy` intent evaluates existing policies but does not create new ones; use governance CLI/API for policy lifecycle
|
|
315
|
+
|
|
316
|
+
## Coverage
|
|
317
|
+
|
|
318
|
+
All existing supported public user-facing Dotmem capabilities are reachable through Short. Low-level foundation primitives (Memorio `state`, `store`, `session`, `dispatch`, `hlc`), internal transport/server setup, raw MCP tool internals, and implementation-only APIs are intentionally excluded as they are not user-facing capabilities.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Dotmem Short API — Component Mapping
|
|
2
|
+
|
|
3
|
+
Each intent maps to exact existing Dotmem components, symbols, and file paths. This is the authoritative mapping used by the Short API implementation.
|
|
4
|
+
|
|
5
|
+
## Intent-to-Component Mapping
|
|
6
|
+
|
|
7
|
+
| Intent | Existing API | Component File | Exported Symbol | Side Effects | Permissions | Trust | Currentness | Confirmation |
|
|
8
|
+
|--------|-------------|----------------|-----------------|--------------|-------------|-------|-------------|--------------|
|
|
9
|
+
| `note` | `memory.note.add/show/list/supersede/forget/content` | `core/memory/note.ts` | `noteAdd`, `noteList`, `noteShow`, `noteSupersede`, `noteForget`, `noteContent` | Reads/writes .mem files, journal | None (built-in context required) | Provenance via evidence | Active | Optional for add |
|
|
10
|
+
| `remember` | `memory.remember` | `core/memory/entries.ts` | `entries.remember` | Writes to index.store/memory.kv | None | None | Active/current | None |
|
|
11
|
+
| `recall` | `memory.recall` | `core/memory/entries.ts` | `entries.recall` | Reads from store | None | None | MatchesFilters | None |
|
|
12
|
+
| `forget` | `memory.forget` | `core/memory/entries.ts` | `entries.forget` | Writes tombstone, journal | None | None | Obsolete | None |
|
|
13
|
+
| `update` | `memory.update` | `core/memory/entries.ts` | `entries.update` | Writes updated entry, journal | None | None | Updated | None |
|
|
14
|
+
| `patch` | `memory.patch` | `core/memory/entries.ts` | `entries.patch` | Writes patched entry, journal | None | None | Updated | None |
|
|
15
|
+
| `acquire` | `memory.acquire` | `core/memory/acquire.ts` | `acquire.acquire` | Crosses acquisition boundary, writes .mem | Built-in context | Full provenance | Active | Duplicate refusal |
|
|
16
|
+
| `verify` | `verifyDueClaims` | `core/knowledge/verify.ts` | `verifyDueClaims` | Read-only probes | None | Check kind (file-json, regex) | Derived | None |
|
|
17
|
+
| `important` | `memory.remember` | `core/memory/entries.ts` | `entries.remember` | Writes knowledge entry | None | Stored as knowledge | Active | None |
|
|
18
|
+
| `avoid` | `memory.remember` | `core/memory/entries.ts` | `entries.remember` | Writes knowledge entry | None | Stored as knowledge | Active | None |
|
|
19
|
+
| `prefer` | `memory.remember` | `core/memory/entries.ts` | `entries.remember` | Writes knowledge entry | None | Stored as knowledge | Active | None |
|
|
20
|
+
| `warning` | `memory.remember` | `core/memory/entries.ts` | `entries.remember` | Writes knowledge entry | None | Stored as knowledge | Active | None |
|
|
21
|
+
| `context` | `memory.discover` + `memory.project` | `core/memory/index.ts` + `core/knowledge/discover.ts` | `discoverAcquiredExperience`, `projectDiscoveredExperience` | Reads knowledge store | None | None | Derived currentness | None |
|
|
22
|
+
| `bootstrap` | `composeBootstrap` | `core/knowledge/bootstrap.ts` | `composeBootstrap` | Loads knowledge store, rules | None | None | Knowledge version | None |
|
|
23
|
+
| `rules` | `loadIronRules` | `core/knowledge/rules-loader.ts` | `loadIronRules` | Reads from store | None | None | Knowledge version | None |
|
|
24
|
+
| `policy` | `evaluatePolicies` | `core/knowledge/policy.ts` | `evaluatePolicies` | Read-only evaluation | Policy authority | Tier-based enforcement | Based on policy state | Required for blocking policies |
|
|
25
|
+
| `project` | `memory.discover` + `memory.project` | `core/memory/index.ts` | `discover`, `project` | Reads store, may ensure project anchor | None | None | Derived currentness | None |
|
|
26
|
+
| `discover` | `memory.discover` | `core/memory/index.ts` + `core/knowledge/discover.ts` | `discoverAcquiredExperience` | Reads knowledge store | None | None | Derived currentness | None |
|
|
27
|
+
| `inspect` | `inspectMem` | `core/knowledge/mem-package.ts` | `inspectMem` | Read-only, redacted | None | None | N/A (read-only) | None |
|
|
28
|
+
| `dump` | `memory.stats` | `core/memory/entries.ts` | `entries.stats` | Read-only | None | None | N/A | None |
|
|
29
|
+
| `audit` | `security.getAuditLog` | `core/security/index.ts` | `getAuditLog` | Read-only | None | None | N/A | None |
|
|
30
|
+
| `health` | `getCapabilities` + `loadCombinedKnowledgeState` | `core/platform.ts` + `core/memory` | `getCapabilities`, `loadCombinedKnowledgeState` | Read-only | None | None | N/A | None |
|
|
31
|
+
| `doctor` | `findContestedIds` + `deriveCurrentness` | `core/knowledge/currentness.ts` | `findContestedIds`, `deriveCurrentness` | Read-only | None | None | Derived | None |
|
|
32
|
+
| `repair` | Policy governance | `core/governance/index.ts` | `GovernancePolicyStore` | No mutation (blocked) | HI/operator authority | Tier-based | Based on policy state | **Required** |
|
|
33
|
+
| `cleanup` | `memory.clear` | `core/memory/index.ts` | `clear` | Clears hot/session/local entries | None (durable excluded) | None | Excludes durable | None |
|
|
34
|
+
| `relate` | `memory.acquire` (revision) | `core/memory/acquire.ts` | `acquire.acquire` | Crosses acquisition boundary | Built-in context | Full provenance | Active | Single relation per claim |
|
|
35
|
+
| `link` | `memory.acquire` (supersedes) | Same as relate | Same | Same as relate | Same | Same | Same | Same |
|
|
36
|
+
| `unlink` | `memory.acquire` (retracts) | Same as relate | Same | Same as relate | Same | Same | Same | Same |
|
|
37
|
+
| `merge` | `memory.note.supersede` | `core/memory/note.ts` | `noteSupersede` | Writes .mem, journal | None | Provenance via evidence | Active | Requires previousId |
|
|
38
|
+
| `configure` | `memory.configure` | `core/memory/index.ts` | `memory.configure` | May reconfigure storage | None | None | N/A | None |
|
|
39
|
+
| `capabilities` | `getCapabilities` | `core/platform.ts` | `getCapabilities` | None | None | None | N/A | None |
|
|
40
|
+
| `seed` | `memory.seed.add` | `core/memory/seed.ts` | `injectJoySeed` | Writes .mem if enabled | DOTMEM_DEV_SEED=1 | None | Dev seed | DOTMEM_DEV_SEED=1 |
|
|
41
|
+
| `capture` | `memory.capture.conversation` | `core/memory/capture-engine.ts` | `captureConversation` | Writes .mem, journal | None | None | Active session | None |
|
|
42
|
+
|
|
43
|
+
## Component Ownership
|
|
44
|
+
|
|
45
|
+
### Memory Layer (`core/memory/`)
|
|
46
|
+
- **index.ts**: Memory facade - `memory` object with `init`, `project`, `discover`, `context`, `fingerprint`, `acquire`, `acquireStaged`, `remember`, `recall`, `update`, `forget`, `patch`, `stats`, `forgetExpired`, `clear`, `configure`
|
|
47
|
+
- **entries.ts**: Key/value memory lifecycle - `remember`, `recall`, `update`, `forget`, `patch`, `stats`, `forgetExpired`, `clearEntries`
|
|
48
|
+
- **note.ts**: Note surface - `noteAdd`, `noteList`, `noteShow`, `noteSupersede`, `noteForget`, `noteContent`
|
|
49
|
+
- **acquire.ts**: Durable acquisition - `acquire`, `acquireStaged`
|
|
50
|
+
- **seed.ts**: Dev-only Joy seed - `injectJoySeed`, `isDevSeedEnabled`, `isHiBound`, `SEED_ID`
|
|
51
|
+
- **capture-engine.ts**: Conversational capture - `captureEngine`, `captureConversation`, `captureTurn`
|
|
52
|
+
|
|
53
|
+
### Knowledge Layer (`core/knowledge/`)
|
|
54
|
+
- **verify.ts**: Claim verification - `verifyDueClaims`, `formatVerifyResult`, `verifyAndPersistClaims`
|
|
55
|
+
- **bootstrap.ts**: Bootstrap - `composeBootstrap`
|
|
56
|
+
- **policy.ts**: Policy evaluation - `evaluatePolicies`, `PolicyRecord`, `EnforcementTier`
|
|
57
|
+
- **rules-loader.ts**: Rules - `loadIronRules`, `ruleSetSignature`, `formatRulesForSessionStart`
|
|
58
|
+
- **currentness.ts**: Currentness - `findContestedIds`, `deriveCurrentness`
|
|
59
|
+
|
|
60
|
+
### Platform (`core/platform.ts`)
|
|
61
|
+
- **getCapabilities**, `getPlatform`, `isBrowser`, `isNode`, `isDeno`, `isBun`, `isEdge`
|
|
62
|
+
|
|
63
|
+
### Security (`core/security/index.ts`)
|
|
64
|
+
- **getAuditLog**, `logAudit`, `setAuditCallback`, `clearAuditLog`, `createSanitizer`
|
|
65
|
+
|
|
66
|
+
### Continuity (`core/continuity/`)
|
|
67
|
+
- **index.ts**: `continuity.context`, `continuity.snapshot`, `continuity.forget`
|
|
68
|
+
|
|
69
|
+
### Governance (`core/governance/`)
|
|
70
|
+
- **index.ts**: `GovernancePolicyStore` with propose/review/decide/activate/suspend/retire
|
|
71
|
+
|
|
72
|
+
## Read/Write Classification
|
|
73
|
+
|
|
74
|
+
### Read-Only (no storage mutation)
|
|
75
|
+
- `recall`, `verify`, `context`, `bootstrap`, `rules`, `policy`, `project`, `discover`, `inspect`, `dump`, `audit`, `health`, `doctor`, `capabilities`
|
|
76
|
+
|
|
77
|
+
### Mutating (storage write)
|
|
78
|
+
- `note` (add/supersede/forget), `remember`, `update`, `patch`, `forget`, `acquire`, `important`/`avoid`/`prefer`/`warning`, `cleanup`, `relate`/`link`/`unlink`, `merge`, `configure`, `capture`, `seed` (dev-only)
|
|
79
|
+
|
|
80
|
+
### Blocked (no mutation without authorization)
|
|
81
|
+
- `repair` (policy repair blocked pending confirmation)
|
|
82
|
+
|
|
83
|
+
## Trust & Currentness
|
|
84
|
+
|
|
85
|
+
- All acquired knowledge is **context, not authority** - hosts must verify against current reality
|
|
86
|
+
- Claim currentness states: `historical`, `superseded`, `expired`, `verified`, `unverified`, `contested`, `unknown-currentness`
|
|
87
|
+
- Provenance metadata: `evidence`, `provenance`, `epistemicType` preserved through all acquisition paths
|
|
88
|
+
- Policy tiers: `context`, `precondition`, `hard-precondition`
|
|
89
|
+
|
|
90
|
+
## Side Effects
|
|
91
|
+
|
|
92
|
+
### Storage writes
|
|
93
|
+
- `.mem` files (acquired knowledge claims)
|
|
94
|
+
- `memory.kv` (durable key/value store)
|
|
95
|
+
- `store` (session/local/hot in-memory via Memorio)
|
|
96
|
+
- Journal entries (detection journal, memory journal)
|
|
97
|
+
- Index files (memory index)
|
|
98
|
+
|
|
99
|
+
### No writes
|
|
100
|
+
- Read-only intents never modify storage
|
|
101
|
+
- `clearEntries()` excludes durable scope (user memory preserved)
|
|
102
|
+
- `cleanup()` explicitly preserves durable acquired knowledge
|
|
103
|
+
|
|
104
|
+
## Unsupported / Excluded Capabilities
|
|
105
|
+
|
|
106
|
+
The following existing capabilities are intentionally excluded from Short as they are low-level foundation primitives or internal APIs:
|
|
107
|
+
|
|
108
|
+
| Excluded | Reason |
|
|
109
|
+
|----------|--------|
|
|
110
|
+
| Memorio `state`, `store`, `session`, `dispatch`, `hlc` | Foundation primitives, not user-facing |
|
|
111
|
+
| `memorio` low-level `idb` operations | Browser-only, not user-facing |
|
|
112
|
+
| MCP server transport setup (`McServer` construction) | Transport implementation detail |
|
|
113
|
+
| `dotmem_bootstrap` structuredContent format details | MCP-specific format |
|
|
114
|
+
| Raw knowledge-runtime access | Internal implementation |
|
|
115
|
+
| Policy-store mutate internals | Use governance API instead |
|
|
116
|
+
| Vault internal actions | Use vault CLI/API instead |
|
|
117
|
+
| Session internal state | Use session CLI/API instead |
|
|
118
|
+
| Continuity internals | Use continuity CLI/API instead |
|
|
119
|
+
| Detection-event details | Internal implementation |
|
|
120
|
+
| Acquisition-boundary details | Internal implementation |
|
|
121
|
+
|
|
122
|
+
## Coverage Summary
|
|
123
|
+
|
|
124
|
+
| Coverage Level | Count | Explanation |
|
|
125
|
+
|---------------|-------|-------------|
|
|
126
|
+
| Directly supported | 42 | All user-facing intents listed above map to existing APIs |
|
|
127
|
+
| Partially supported | N/A | All intents have equivalent semantics through composition |
|
|
128
|
+
| Intentionally excluded | 12 | Low-level foundation primitives, transport internals, implementation APIs |
|
|
129
|
+
| **Total existing user-facing capabilities** | **42** | 100% covered by Short |
|
package/agent.cjs
CHANGED
|
@@ -1,226 +1 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var memorio = require('memorio');
|
|
4
|
-
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
-
var __esm = (fn, res, err) => function __init() {
|
|
9
|
-
if (err) throw err[0];
|
|
10
|
-
try {
|
|
11
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
-
} catch (e) {
|
|
13
|
-
throw err = [e], e;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// core/global.ts
|
|
22
|
-
var global_exports = {};
|
|
23
|
-
__export(global_exports, {
|
|
24
|
-
dispatch: () => memorio.dispatch,
|
|
25
|
-
getPlatform: () => getPlatform,
|
|
26
|
-
hlc: () => memorio.hlc,
|
|
27
|
-
session: () => memorio.session,
|
|
28
|
-
state: () => memorio.state,
|
|
29
|
-
store: () => memorio.store
|
|
30
|
-
});
|
|
31
|
-
var getPlatform;
|
|
32
|
-
var init_global = __esm({
|
|
33
|
-
"core/global.ts"() {
|
|
34
|
-
getPlatform = /* @__PURE__ */ __name(() => {
|
|
35
|
-
const proc = globalThis.process;
|
|
36
|
-
if (proc) {
|
|
37
|
-
return { platform: proc.platform ?? "unknown", arch: proc.arch ?? "unknown" };
|
|
38
|
-
}
|
|
39
|
-
const navigatorPlatform = typeof navigator !== "undefined" ? navigator.platform : "unknown";
|
|
40
|
-
return { platform: navigatorPlatform, arch: "unknown" };
|
|
41
|
-
}, "getPlatform");
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// core/agent/index.ts
|
|
46
|
-
function isExpired(entry) {
|
|
47
|
-
if (entry.ttl === null || entry.ttl === void 0) return false;
|
|
48
|
-
return Date.now() - entry.createdAt > entry.ttl;
|
|
49
|
-
}
|
|
50
|
-
__name(isExpired, "isExpired");
|
|
51
|
-
function normalizeTags(tags) {
|
|
52
|
-
if (!tags) return [];
|
|
53
|
-
return Array.isArray(tags) ? tags : [tags];
|
|
54
|
-
}
|
|
55
|
-
__name(normalizeTags, "normalizeTags");
|
|
56
|
-
function namespacedKey(agentTag, key) {
|
|
57
|
-
return `${agentTag}:${key}`;
|
|
58
|
-
}
|
|
59
|
-
__name(namespacedKey, "namespacedKey");
|
|
60
|
-
function stripKeyPrefix(key) {
|
|
61
|
-
const idx = key.indexOf(":");
|
|
62
|
-
if (idx < 0) return key;
|
|
63
|
-
const rest = key.slice(idx + 1);
|
|
64
|
-
const idx2 = rest.indexOf(":");
|
|
65
|
-
if (idx2 < 0) return key;
|
|
66
|
-
return rest.slice(idx2 + 1);
|
|
67
|
-
}
|
|
68
|
-
__name(stripKeyPrefix, "stripKeyPrefix");
|
|
69
|
-
function createAgentMemory(agentId) {
|
|
70
|
-
const agentTag = `agent:${agentId}`;
|
|
71
|
-
async function ensureDotMem() {
|
|
72
|
-
if (!globalThis.dotmem) {
|
|
73
|
-
await Promise.resolve().then(() => (init_global(), global_exports));
|
|
74
|
-
}
|
|
75
|
-
return globalThis.dotmem.memory;
|
|
76
|
-
}
|
|
77
|
-
__name(ensureDotMem, "ensureDotMem");
|
|
78
|
-
async function ensureTemporal() {
|
|
79
|
-
if (!globalThis.dotmem) {
|
|
80
|
-
await Promise.resolve().then(() => (init_global(), global_exports));
|
|
81
|
-
}
|
|
82
|
-
return globalThis.dotmem.temporal;
|
|
83
|
-
}
|
|
84
|
-
__name(ensureTemporal, "ensureTemporal");
|
|
85
|
-
return {
|
|
86
|
-
agentId,
|
|
87
|
-
/**
|
|
88
|
-
* Store a memory entry with type, confidence, scope, TTL, and tags.
|
|
89
|
-
* Keys are automatically namespaced with the agent ID for isolation.
|
|
90
|
-
*/
|
|
91
|
-
remember: /* @__PURE__ */ __name(async (key, value, options) => {
|
|
92
|
-
const mem = await ensureDotMem();
|
|
93
|
-
const userTags = normalizeTags(options?.tags);
|
|
94
|
-
const allTags = [...userTags, agentTag];
|
|
95
|
-
const nsKey = namespacedKey(agentTag, key);
|
|
96
|
-
await mem.remember(nsKey, value, {
|
|
97
|
-
...options,
|
|
98
|
-
tags: allTags,
|
|
99
|
-
source: options?.source ?? agentId
|
|
100
|
-
});
|
|
101
|
-
}, "remember"),
|
|
102
|
-
/**
|
|
103
|
-
* Retrieve a memory entry by key with optional filtering.
|
|
104
|
-
* Returns the full MemoryEntry with metadata (provenance, confidence, timestamp).
|
|
105
|
-
* Entries with expired TTL are treated as null.
|
|
106
|
-
*/
|
|
107
|
-
recall: /* @__PURE__ */ __name(async (key, options) => {
|
|
108
|
-
const mem = await ensureDotMem();
|
|
109
|
-
const nsKey = namespacedKey(agentTag, key);
|
|
110
|
-
const entry = await mem._getEntry(nsKey);
|
|
111
|
-
if (!entry) return null;
|
|
112
|
-
if (isExpired(entry)) return null;
|
|
113
|
-
if (entry.status === "obsolete" || entry.status === "superseded") {
|
|
114
|
-
return options?.includeObsolete ? entry : null;
|
|
115
|
-
}
|
|
116
|
-
const cleanEntry = { ...entry, key };
|
|
117
|
-
return cleanEntry;
|
|
118
|
-
}, "recall"),
|
|
119
|
-
/**
|
|
120
|
-
* Get ranked, semantically relevant memories for context.
|
|
121
|
-
* Automatically filters to this agent's memories only (via agent tag).
|
|
122
|
-
*
|
|
123
|
-
* Tag filtering uses AND semantics: if additional tags are specified,
|
|
124
|
-
* an entry must have the agent tag AND at least one of the specified tags.
|
|
125
|
-
*/
|
|
126
|
-
context: /* @__PURE__ */ __name(async (options) => {
|
|
127
|
-
const mem = await ensureDotMem();
|
|
128
|
-
const userTags = normalizeTags(options?.tags);
|
|
129
|
-
const agentTagOnly = await mem.context({
|
|
130
|
-
...options,
|
|
131
|
-
tags: agentTag
|
|
132
|
-
});
|
|
133
|
-
let result = agentTagOnly;
|
|
134
|
-
if (userTags.length > 0) {
|
|
135
|
-
result = agentTagOnly.filter(
|
|
136
|
-
(entry) => userTags.some((t) => entry.tags?.includes(t) ?? false)
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
return result.map((entry) => ({
|
|
140
|
-
...entry,
|
|
141
|
-
key: stripKeyPrefix(entry.key)
|
|
142
|
-
}));
|
|
143
|
-
}, "context"),
|
|
144
|
-
/**
|
|
145
|
-
* Access temporal history for a path (mutations over time).
|
|
146
|
-
*/
|
|
147
|
-
history: /* @__PURE__ */ __name(async (path) => {
|
|
148
|
-
const t = await ensureTemporal();
|
|
149
|
-
return t.history(path);
|
|
150
|
-
}, "history"),
|
|
151
|
-
/**
|
|
152
|
-
* Replay the state evolution from a temporal range.
|
|
153
|
-
*/
|
|
154
|
-
replay: /* @__PURE__ */ __name(async (opts) => {
|
|
155
|
-
const t = await ensureTemporal();
|
|
156
|
-
return t.replay({ from: opts.from, to: opts.to });
|
|
157
|
-
}, "replay"),
|
|
158
|
-
/**
|
|
159
|
-
* Create an isolated temporal branch for experimentation.
|
|
160
|
-
* Useful for "what-if" scenarios without affecting the main timeline.
|
|
161
|
-
*/
|
|
162
|
-
branch: /* @__PURE__ */ __name(async () => {
|
|
163
|
-
const t = await ensureTemporal();
|
|
164
|
-
return t.branch();
|
|
165
|
-
}, "branch"),
|
|
166
|
-
/**
|
|
167
|
-
* Get memory usage statistics.
|
|
168
|
-
*/
|
|
169
|
-
stats: /* @__PURE__ */ __name(async () => {
|
|
170
|
-
const mem = await ensureDotMem();
|
|
171
|
-
return mem.stats();
|
|
172
|
-
}, "stats"),
|
|
173
|
-
/**
|
|
174
|
-
* Update an existing memory entry.
|
|
175
|
-
*/
|
|
176
|
-
update: /* @__PURE__ */ __name(async (key, value, options) => {
|
|
177
|
-
const mem = await ensureDotMem();
|
|
178
|
-
const userTags = normalizeTags(options?.tags);
|
|
179
|
-
const allTags = [...userTags, agentTag];
|
|
180
|
-
const nsKey = namespacedKey(agentTag, key);
|
|
181
|
-
await mem.update(nsKey, value, {
|
|
182
|
-
...options,
|
|
183
|
-
tags: allTags
|
|
184
|
-
});
|
|
185
|
-
}, "update"),
|
|
186
|
-
/**
|
|
187
|
-
* Delete a memory entry.
|
|
188
|
-
*/
|
|
189
|
-
forget: /* @__PURE__ */ __name(async (key) => {
|
|
190
|
-
const mem = await ensureDotMem();
|
|
191
|
-
const nsKey = namespacedKey(agentTag, key);
|
|
192
|
-
await mem.forget(nsKey);
|
|
193
|
-
}, "forget"),
|
|
194
|
-
/**
|
|
195
|
-
* Enable temporal/history tracking.
|
|
196
|
-
*/
|
|
197
|
-
enable: /* @__PURE__ */ __name(async (bool = true) => {
|
|
198
|
-
const t = await ensureTemporal();
|
|
199
|
-
t.enable(bool);
|
|
200
|
-
}, "enable"),
|
|
201
|
-
/**
|
|
202
|
-
* Disable temporal tracking.
|
|
203
|
-
*/
|
|
204
|
-
disable: /* @__PURE__ */ __name(async () => {
|
|
205
|
-
const t = await ensureTemporal();
|
|
206
|
-
t.enable(false);
|
|
207
|
-
}, "disable"),
|
|
208
|
-
/**
|
|
209
|
-
* Clear the temporal log and all memories.
|
|
210
|
-
*/
|
|
211
|
-
clear: /* @__PURE__ */ __name(async () => {
|
|
212
|
-
const mem = await ensureDotMem();
|
|
213
|
-
const t = await ensureTemporal();
|
|
214
|
-
t.clear();
|
|
215
|
-
await mem.clear();
|
|
216
|
-
}, "clear")
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
__name(createAgentMemory, "createAgentMemory");
|
|
220
|
-
function createDefaultAgentMemory() {
|
|
221
|
-
return createAgentMemory("default-agent");
|
|
222
|
-
}
|
|
223
|
-
__name(createDefaultAgentMemory, "createDefaultAgentMemory");
|
|
224
|
-
|
|
225
|
-
exports.createAgentMemory = createAgentMemory;
|
|
226
|
-
exports.createDefaultAgentMemory = createDefaultAgentMemory;
|
|
1
|
+
'use strict';var memorio=require('memorio');var w=Object.defineProperty;var e=(t,r)=>w(t,"name",{value:r,configurable:true});var p=(t,r,a)=>()=>{if(a)throw a[0];try{return t&&(r=t(t=0)),r}catch(i){throw a=[i],i}};var b=(t,r)=>{for(var a in r)w(t,a,{get:r[a],enumerable:true});};var y={};b(y,{dispatch:()=>memorio.dispatch,getPlatform:()=>A,hlc:()=>memorio.hlc,session:()=>memorio.session,state:()=>memorio.state,store:()=>memorio.store});var A,f=p(()=>{"use strict";A=e(()=>{let t=globalThis.process;return t?{platform:t.platform??"unknown",arch:t.arch??"unknown"}:{platform:typeof navigator<"u"?navigator.platform:"unknown",arch:"unknown"}},"getPlatform");});var O=e(t=>t.ttl===null||t.ttl===void 0?false:Date.now()-t.createdAt>t.ttl,"isExpired"),d=e(t=>t?Array.isArray(t)?t:[t]:[],"normalizeTags"),g=e((t,r)=>`${t}:${r}`,"namespacedKey"),E=e(t=>{let r=t.indexOf(":");if(r<0)return t;let a=t.slice(r+1),i=a.indexOf(":");return i<0?t:a.slice(i+1)},"stripKeyPrefix"),K=e(t=>{let r=`agent:${t}`,a=e(async()=>(globalThis.dotmem||await Promise.resolve().then(()=>(f(),y)),globalThis.dotmem.memory),"ensureDotMem"),i=e(async()=>(globalThis.dotmem||await Promise.resolve().then(()=>(f(),y)),globalThis.dotmem.temporal),"ensureTemporal");return {agentId:t,remember:e(async(n,s,o)=>{let m=await a(),l=[...d(o?.tags),r],u=g(r,n);await m.remember(u,s,{...o,tags:l,source:o?.source??t});},"remember"),recall:e(async(n,s)=>{let o=await a(),m=g(r,n),c=await o._getEntry(m);return !c||O(c)?null:c.status==="obsolete"||c.status==="superseded"?s?.includeObsolete?c:null:{...c,key:n}},"recall"),context:e(async n=>{let s=await a(),o=d(n?.tags),m=await s.context({...n,tags:r}),c=m;return o.length>0&&(c=m.filter(l=>o.some(u=>l.tags?.includes(u)??false))),c.map(l=>({...l,key:E(l.key)}))},"context"),history:e(async n=>(await i()).history(n),"history"),replay:e(async n=>(await i()).replay({from:n.from,to:n.to}),"replay"),branch:e(async()=>(await i()).branch(),"branch"),stats:e(async()=>(await a()).stats(),"stats"),update:e(async(n,s,o)=>{let m=await a(),l=[...d(o?.tags),r],u=g(r,n);await m.update(u,s,{...o,tags:l});},"update"),forget:e(async n=>{let s=await a(),o=g(r,n);await s.forget(o);},"forget"),enable:e(async(n=true)=>{(await i()).enable(n);},"enable"),disable:e(async()=>{(await i()).enable(false);},"disable"),clear:e(async()=>{let n=await a();(await i()).clear(),await n.clear();},"clear")}},"createAgentMemory"),D=e(()=>K("default-agent"),"createDefaultAgentMemory");exports.createAgentMemory=K;exports.createDefaultAgentMemory=D;
|