dotmem 0.1.8 → 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/CHANGELOG.md +75 -75
- package/DOTMEM-SHORT-API.md +318 -0
- package/DOTMEM-SHORT-COMPONENTS.md +129 -0
- package/README.md +456 -339
- 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/build-config.json +10 -10
- package/built-in-context.json +6 -6
- package/cli.cjs +182 -18866
- package/cli.js +181 -18796
- package/context/templates/AI.md +104 -104
- package/env.cjs +1 -6
- package/env.js +1 -4
- package/global.cjs +49 -11252
- package/global.d.ts +0 -1
- package/global.js +49 -11218
- package/index.cjs +95 -15141
- package/index.d.ts +2 -0
- package/index.js +95 -15036
- package/llms.txt +10 -4
- package/mcp.cjs +123 -13594
- package/mcp.js +123 -13564
- package/package.json +3 -2
- package/types/exports.d.ts +64 -69
- 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 +347 -391
- package/types/policy.d.ts +290 -290
- package/types/profile.d.ts +34 -34
- package/types/agent.d.ts +0 -87
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;
|
package/agent.js
CHANGED
|
@@ -1,223 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
var __esm = (fn, res, err) => function __init() {
|
|
7
|
-
if (err) throw err[0];
|
|
8
|
-
try {
|
|
9
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
-
} catch (e) {
|
|
11
|
-
throw err = [e], e;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// core/global.ts
|
|
20
|
-
var global_exports = {};
|
|
21
|
-
__export(global_exports, {
|
|
22
|
-
dispatch: () => dispatch,
|
|
23
|
-
getPlatform: () => getPlatform,
|
|
24
|
-
hlc: () => hlc,
|
|
25
|
-
session: () => session,
|
|
26
|
-
state: () => state,
|
|
27
|
-
store: () => store
|
|
28
|
-
});
|
|
29
|
-
var getPlatform;
|
|
30
|
-
var init_global = __esm({
|
|
31
|
-
"core/global.ts"() {
|
|
32
|
-
getPlatform = /* @__PURE__ */ __name(() => {
|
|
33
|
-
const proc = globalThis.process;
|
|
34
|
-
if (proc) {
|
|
35
|
-
return { platform: proc.platform ?? "unknown", arch: proc.arch ?? "unknown" };
|
|
36
|
-
}
|
|
37
|
-
const navigatorPlatform = typeof navigator !== "undefined" ? navigator.platform : "unknown";
|
|
38
|
-
return { platform: navigatorPlatform, arch: "unknown" };
|
|
39
|
-
}, "getPlatform");
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// core/agent/index.ts
|
|
44
|
-
function isExpired(entry) {
|
|
45
|
-
if (entry.ttl === null || entry.ttl === void 0) return false;
|
|
46
|
-
return Date.now() - entry.createdAt > entry.ttl;
|
|
47
|
-
}
|
|
48
|
-
__name(isExpired, "isExpired");
|
|
49
|
-
function normalizeTags(tags) {
|
|
50
|
-
if (!tags) return [];
|
|
51
|
-
return Array.isArray(tags) ? tags : [tags];
|
|
52
|
-
}
|
|
53
|
-
__name(normalizeTags, "normalizeTags");
|
|
54
|
-
function namespacedKey(agentTag, key) {
|
|
55
|
-
return `${agentTag}:${key}`;
|
|
56
|
-
}
|
|
57
|
-
__name(namespacedKey, "namespacedKey");
|
|
58
|
-
function stripKeyPrefix(key) {
|
|
59
|
-
const idx = key.indexOf(":");
|
|
60
|
-
if (idx < 0) return key;
|
|
61
|
-
const rest = key.slice(idx + 1);
|
|
62
|
-
const idx2 = rest.indexOf(":");
|
|
63
|
-
if (idx2 < 0) return key;
|
|
64
|
-
return rest.slice(idx2 + 1);
|
|
65
|
-
}
|
|
66
|
-
__name(stripKeyPrefix, "stripKeyPrefix");
|
|
67
|
-
function createAgentMemory(agentId) {
|
|
68
|
-
const agentTag = `agent:${agentId}`;
|
|
69
|
-
async function ensureDotMem() {
|
|
70
|
-
if (!globalThis.dotmem) {
|
|
71
|
-
await Promise.resolve().then(() => (init_global(), global_exports));
|
|
72
|
-
}
|
|
73
|
-
return globalThis.dotmem.memory;
|
|
74
|
-
}
|
|
75
|
-
__name(ensureDotMem, "ensureDotMem");
|
|
76
|
-
async function ensureTemporal() {
|
|
77
|
-
if (!globalThis.dotmem) {
|
|
78
|
-
await Promise.resolve().then(() => (init_global(), global_exports));
|
|
79
|
-
}
|
|
80
|
-
return globalThis.dotmem.temporal;
|
|
81
|
-
}
|
|
82
|
-
__name(ensureTemporal, "ensureTemporal");
|
|
83
|
-
return {
|
|
84
|
-
agentId,
|
|
85
|
-
/**
|
|
86
|
-
* Store a memory entry with type, confidence, scope, TTL, and tags.
|
|
87
|
-
* Keys are automatically namespaced with the agent ID for isolation.
|
|
88
|
-
*/
|
|
89
|
-
remember: /* @__PURE__ */ __name(async (key, value, options) => {
|
|
90
|
-
const mem = await ensureDotMem();
|
|
91
|
-
const userTags = normalizeTags(options?.tags);
|
|
92
|
-
const allTags = [...userTags, agentTag];
|
|
93
|
-
const nsKey = namespacedKey(agentTag, key);
|
|
94
|
-
await mem.remember(nsKey, value, {
|
|
95
|
-
...options,
|
|
96
|
-
tags: allTags,
|
|
97
|
-
source: options?.source ?? agentId
|
|
98
|
-
});
|
|
99
|
-
}, "remember"),
|
|
100
|
-
/**
|
|
101
|
-
* Retrieve a memory entry by key with optional filtering.
|
|
102
|
-
* Returns the full MemoryEntry with metadata (provenance, confidence, timestamp).
|
|
103
|
-
* Entries with expired TTL are treated as null.
|
|
104
|
-
*/
|
|
105
|
-
recall: /* @__PURE__ */ __name(async (key, options) => {
|
|
106
|
-
const mem = await ensureDotMem();
|
|
107
|
-
const nsKey = namespacedKey(agentTag, key);
|
|
108
|
-
const entry = await mem._getEntry(nsKey);
|
|
109
|
-
if (!entry) return null;
|
|
110
|
-
if (isExpired(entry)) return null;
|
|
111
|
-
if (entry.status === "obsolete" || entry.status === "superseded") {
|
|
112
|
-
return options?.includeObsolete ? entry : null;
|
|
113
|
-
}
|
|
114
|
-
const cleanEntry = { ...entry, key };
|
|
115
|
-
return cleanEntry;
|
|
116
|
-
}, "recall"),
|
|
117
|
-
/**
|
|
118
|
-
* Get ranked, semantically relevant memories for context.
|
|
119
|
-
* Automatically filters to this agent's memories only (via agent tag).
|
|
120
|
-
*
|
|
121
|
-
* Tag filtering uses AND semantics: if additional tags are specified,
|
|
122
|
-
* an entry must have the agent tag AND at least one of the specified tags.
|
|
123
|
-
*/
|
|
124
|
-
context: /* @__PURE__ */ __name(async (options) => {
|
|
125
|
-
const mem = await ensureDotMem();
|
|
126
|
-
const userTags = normalizeTags(options?.tags);
|
|
127
|
-
const agentTagOnly = await mem.context({
|
|
128
|
-
...options,
|
|
129
|
-
tags: agentTag
|
|
130
|
-
});
|
|
131
|
-
let result = agentTagOnly;
|
|
132
|
-
if (userTags.length > 0) {
|
|
133
|
-
result = agentTagOnly.filter(
|
|
134
|
-
(entry) => userTags.some((t) => entry.tags?.includes(t) ?? false)
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
return result.map((entry) => ({
|
|
138
|
-
...entry,
|
|
139
|
-
key: stripKeyPrefix(entry.key)
|
|
140
|
-
}));
|
|
141
|
-
}, "context"),
|
|
142
|
-
/**
|
|
143
|
-
* Access temporal history for a path (mutations over time).
|
|
144
|
-
*/
|
|
145
|
-
history: /* @__PURE__ */ __name(async (path) => {
|
|
146
|
-
const t = await ensureTemporal();
|
|
147
|
-
return t.history(path);
|
|
148
|
-
}, "history"),
|
|
149
|
-
/**
|
|
150
|
-
* Replay the state evolution from a temporal range.
|
|
151
|
-
*/
|
|
152
|
-
replay: /* @__PURE__ */ __name(async (opts) => {
|
|
153
|
-
const t = await ensureTemporal();
|
|
154
|
-
return t.replay({ from: opts.from, to: opts.to });
|
|
155
|
-
}, "replay"),
|
|
156
|
-
/**
|
|
157
|
-
* Create an isolated temporal branch for experimentation.
|
|
158
|
-
* Useful for "what-if" scenarios without affecting the main timeline.
|
|
159
|
-
*/
|
|
160
|
-
branch: /* @__PURE__ */ __name(async () => {
|
|
161
|
-
const t = await ensureTemporal();
|
|
162
|
-
return t.branch();
|
|
163
|
-
}, "branch"),
|
|
164
|
-
/**
|
|
165
|
-
* Get memory usage statistics.
|
|
166
|
-
*/
|
|
167
|
-
stats: /* @__PURE__ */ __name(async () => {
|
|
168
|
-
const mem = await ensureDotMem();
|
|
169
|
-
return mem.stats();
|
|
170
|
-
}, "stats"),
|
|
171
|
-
/**
|
|
172
|
-
* Update an existing memory entry.
|
|
173
|
-
*/
|
|
174
|
-
update: /* @__PURE__ */ __name(async (key, value, options) => {
|
|
175
|
-
const mem = await ensureDotMem();
|
|
176
|
-
const userTags = normalizeTags(options?.tags);
|
|
177
|
-
const allTags = [...userTags, agentTag];
|
|
178
|
-
const nsKey = namespacedKey(agentTag, key);
|
|
179
|
-
await mem.update(nsKey, value, {
|
|
180
|
-
...options,
|
|
181
|
-
tags: allTags
|
|
182
|
-
});
|
|
183
|
-
}, "update"),
|
|
184
|
-
/**
|
|
185
|
-
* Delete a memory entry.
|
|
186
|
-
*/
|
|
187
|
-
forget: /* @__PURE__ */ __name(async (key) => {
|
|
188
|
-
const mem = await ensureDotMem();
|
|
189
|
-
const nsKey = namespacedKey(agentTag, key);
|
|
190
|
-
await mem.forget(nsKey);
|
|
191
|
-
}, "forget"),
|
|
192
|
-
/**
|
|
193
|
-
* Enable temporal/history tracking.
|
|
194
|
-
*/
|
|
195
|
-
enable: /* @__PURE__ */ __name(async (bool = true) => {
|
|
196
|
-
const t = await ensureTemporal();
|
|
197
|
-
t.enable(bool);
|
|
198
|
-
}, "enable"),
|
|
199
|
-
/**
|
|
200
|
-
* Disable temporal tracking.
|
|
201
|
-
*/
|
|
202
|
-
disable: /* @__PURE__ */ __name(async () => {
|
|
203
|
-
const t = await ensureTemporal();
|
|
204
|
-
t.enable(false);
|
|
205
|
-
}, "disable"),
|
|
206
|
-
/**
|
|
207
|
-
* Clear the temporal log and all memories.
|
|
208
|
-
*/
|
|
209
|
-
clear: /* @__PURE__ */ __name(async () => {
|
|
210
|
-
const mem = await ensureDotMem();
|
|
211
|
-
const t = await ensureTemporal();
|
|
212
|
-
t.clear();
|
|
213
|
-
await mem.clear();
|
|
214
|
-
}, "clear")
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
__name(createAgentMemory, "createAgentMemory");
|
|
218
|
-
function createDefaultAgentMemory() {
|
|
219
|
-
return createAgentMemory("default-agent");
|
|
220
|
-
}
|
|
221
|
-
__name(createDefaultAgentMemory, "createDefaultAgentMemory");
|
|
222
|
-
|
|
223
|
-
export { createAgentMemory, createDefaultAgentMemory };
|
|
1
|
+
import {store,state,session,hlc,dispatch}from'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:()=>dispatch,getPlatform:()=>A,hlc:()=>hlc,session:()=>session,state:()=>state,store:()=>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");export{K as createAgentMemory,D as createDefaultAgentMemory};
|
package/bin/cli.cjs
CHANGED
|
@@ -1,35 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var process = require('process');
|
|
5
|
-
var url = require('url');
|
|
6
|
-
|
|
7
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
8
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
|
|
10
|
-
var process__default = /*#__PURE__*/_interopDefault(process);
|
|
11
|
-
|
|
12
|
-
var rawArgs = process__default.default.argv.slice(2);
|
|
13
|
-
var storageRootFlagIndex = rawArgs.indexOf("--storage-root");
|
|
14
|
-
var hasStorageRootFlag = storageRootFlagIndex !== -1;
|
|
15
|
-
var storageRootFlagValue = hasStorageRootFlag ? rawArgs[storageRootFlagIndex + 1] : void 0;
|
|
16
|
-
if (hasStorageRootFlag && (storageRootFlagValue === void 0 || storageRootFlagValue.startsWith("--"))) {
|
|
17
|
-
console.error("Usage: npx dotmem <command> --storage-root <absolute-directory>");
|
|
18
|
-
process__default.default.exit(1);
|
|
19
|
-
}
|
|
20
|
-
var args = hasStorageRootFlag ? rawArgs.filter((_, index) => index !== storageRootFlagIndex && index !== storageRootFlagIndex + 1) : rawArgs;
|
|
21
|
-
var command = args[0];
|
|
22
|
-
var dispatchArgs = args.slice(1);
|
|
23
|
-
void (async () => {
|
|
24
|
-
const cliModule = await import('../cli.js');
|
|
25
|
-
if (hasStorageRootFlag) {
|
|
26
|
-
try {
|
|
27
|
-
cliModule.noteDotMemPackageInstallPath(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))));
|
|
28
|
-
cliModule.setDotMemStorageRootOverride(storageRootFlagValue);
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error(`Invalid --storage-root: ${error instanceof Error ? error.message : String(error)}`);
|
|
31
|
-
process__default.default.exit(1);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
cliModule.dispatch(command, dispatchArgs);
|
|
35
|
-
})();
|
|
2
|
+
'use strict';var n=require('process'),url=require('url');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var n__default=/*#__PURE__*/_interopDefault(n);var l=console.warn;console.warn=(...o)=>{typeof o[0]=="string"&&o[0].includes("Memorio IDB: IndexedDB is not available")||l(...o);};var e=n__default.default.argv.slice(2),r=e.indexOf("--storage-root"),s=r!==-1,a=s?e[r+1]:void 0;s&&(a===void 0||a.startsWith("--"))&&(console.error("Usage: npx dotmem <command> --storage-root <absolute-directory>"),n__default.default.exit(1));var i=s?e.filter((o,t)=>t!==r&&t!==r+1):e,d=i[0],g=i.slice(1);(async()=>{let o=await import('../cli.js');if(s)try{o.noteDotMemPackageInstallPath(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)))),o.setDotMemStorageRootOverride(a);}catch(t){console.error(`Invalid --storage-root: ${t instanceof Error?t.message:String(t)}`),n__default.default.exit(1);}o.dispatch(d,g);})();
|
package/bin/cli.js
CHANGED
|
@@ -1,28 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import process from '
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
|
|
5
|
-
var rawArgs = process.argv.slice(2);
|
|
6
|
-
var storageRootFlagIndex = rawArgs.indexOf("--storage-root");
|
|
7
|
-
var hasStorageRootFlag = storageRootFlagIndex !== -1;
|
|
8
|
-
var storageRootFlagValue = hasStorageRootFlag ? rawArgs[storageRootFlagIndex + 1] : void 0;
|
|
9
|
-
if (hasStorageRootFlag && (storageRootFlagValue === void 0 || storageRootFlagValue.startsWith("--"))) {
|
|
10
|
-
console.error("Usage: npx dotmem <command> --storage-root <absolute-directory>");
|
|
11
|
-
process.exit(1);
|
|
12
|
-
}
|
|
13
|
-
var args = hasStorageRootFlag ? rawArgs.filter((_, index) => index !== storageRootFlagIndex && index !== storageRootFlagIndex + 1) : rawArgs;
|
|
14
|
-
var command = args[0];
|
|
15
|
-
var dispatchArgs = args.slice(1);
|
|
16
|
-
void (async () => {
|
|
17
|
-
const cliModule = await import('../cli.js');
|
|
18
|
-
if (hasStorageRootFlag) {
|
|
19
|
-
try {
|
|
20
|
-
cliModule.noteDotMemPackageInstallPath(fileURLToPath(import.meta.url));
|
|
21
|
-
cliModule.setDotMemStorageRootOverride(storageRootFlagValue);
|
|
22
|
-
} catch (error) {
|
|
23
|
-
console.error(`Invalid --storage-root: ${error instanceof Error ? error.message : String(error)}`);
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
cliModule.dispatch(command, dispatchArgs);
|
|
28
|
-
})();
|
|
2
|
+
import n from'process';import {fileURLToPath}from'url';var l=console.warn;console.warn=(...o)=>{typeof o[0]=="string"&&o[0].includes("Memorio IDB: IndexedDB is not available")||l(...o);};var e=n.argv.slice(2),r=e.indexOf("--storage-root"),s=r!==-1,a=s?e[r+1]:void 0;s&&(a===void 0||a.startsWith("--"))&&(console.error("Usage: npx dotmem <command> --storage-root <absolute-directory>"),n.exit(1));var i=s?e.filter((o,t)=>t!==r&&t!==r+1):e,d=i[0],g=i.slice(1);(async()=>{let o=await import('../cli.js');if(s)try{o.noteDotMemPackageInstallPath(fileURLToPath(import.meta.url)),o.setDotMemStorageRootOverride(a);}catch(t){console.error(`Invalid --storage-root: ${t instanceof Error?t.message:String(t)}`),n.exit(1);}o.dispatch(d,g);})();
|
package/bin/mcp.cjs
CHANGED
|
@@ -1,22 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var process = require('process');
|
|
5
|
-
|
|
6
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
-
|
|
8
|
-
var process__default = /*#__PURE__*/_interopDefault(process);
|
|
9
|
-
|
|
10
|
-
var nodeMajorVersion = Number.parseInt(process__default.default.versions.node.split(".")[0] ?? "", 10);
|
|
11
|
-
if (!Number.isInteger(nodeMajorVersion) || nodeMajorVersion < 20) {
|
|
12
|
-
console.error("dotmem-mcp requires Node.js >=20; the normal dotmem runtime remains compatible with its declared Node.js version.");
|
|
13
|
-
process__default.default.exitCode = 1;
|
|
14
|
-
} else {
|
|
15
|
-
void (async () => {
|
|
16
|
-
const mcpModule = await import('../mcp.js');
|
|
17
|
-
await mcpModule.startDotMemMcpServer();
|
|
18
|
-
})().catch((error) => {
|
|
19
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
20
|
-
process__default.default.exitCode = 1;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
2
|
+
'use strict';var o=require('process');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var o__default=/*#__PURE__*/_interopDefault(o);var r=console.warn;console.warn=(...e)=>{typeof e[0]=="string"&&e[0].includes("Memorio IDB: IndexedDB is not available")||r(...e);};var n=Number.parseInt(o__default.default.versions.node.split(".")[0]??"",10);!Number.isInteger(n)||n<20?(console.error("dotmem-mcp requires Node.js >=20; the normal dotmem runtime remains compatible with its declared Node.js version."),o__default.default.exitCode=1):(async()=>{await(await import('../mcp.js')).startDotMemMcpServer();})().catch(e=>{console.error(e instanceof Error?e.message:String(e)),o__default.default.exitCode=1;});
|
package/bin/mcp.js
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
var nodeMajorVersion = Number.parseInt(process.versions.node.split(".")[0] ?? "", 10);
|
|
5
|
-
if (!Number.isInteger(nodeMajorVersion) || nodeMajorVersion < 20) {
|
|
6
|
-
console.error("dotmem-mcp requires Node.js >=20; the normal dotmem runtime remains compatible with its declared Node.js version.");
|
|
7
|
-
process.exitCode = 1;
|
|
8
|
-
} else {
|
|
9
|
-
void (async () => {
|
|
10
|
-
const mcpModule = await import('../mcp.js');
|
|
11
|
-
await mcpModule.startDotMemMcpServer();
|
|
12
|
-
})().catch((error) => {
|
|
13
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
14
|
-
process.exitCode = 1;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
2
|
+
import o from'process';var r=console.warn;console.warn=(...e)=>{typeof e[0]=="string"&&e[0].includes("Memorio IDB: IndexedDB is not available")||r(...e);};var n=Number.parseInt(o.versions.node.split(".")[0]??"",10);!Number.isInteger(n)||n<20?(console.error("dotmem-mcp requires Node.js >=20; the normal dotmem runtime remains compatible with its declared Node.js version."),o.exitCode=1):(async()=>{await(await import('../mcp.js')).startDotMemMcpServer();})().catch(e=>{console.error(e instanceof Error?e.message:String(e)),o.exitCode=1;});
|
package/build-config.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
{
|
|
2
|
-
"profile": "joy",
|
|
3
|
-
"branding": {
|
|
4
|
-
"productName": "dotmem",
|
|
5
|
-
"mcpServerName": "dotmem",
|
|
6
|
-
"mcpServerDescription": "The AI memory layer for agents and apps.",
|
|
7
|
-
"cliName": "dotmem",
|
|
8
|
-
"cliMcpName": "dotmem-mcp"
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"profile": "joy",
|
|
3
|
+
"branding": {
|
|
4
|
+
"productName": "dotmem",
|
|
5
|
+
"mcpServerName": "dotmem",
|
|
6
|
+
"mcpServerDescription": "The AI memory layer for agents and apps.",
|
|
7
|
+
"cliName": "dotmem",
|
|
8
|
+
"cliMcpName": "dotmem-mcp"
|
|
9
|
+
}
|
|
10
|
+
}
|