dotmem 0.0.1 → 0.0.3
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/AGENTS.md +464 -0
- package/CHANGELOG.md +0 -0
- package/COPYRIGHT.md +4 -0
- package/DOTMEM.md +42 -0
- package/LICENSE.md +11 -0
- package/MEMORY.md +518 -0
- package/PACKAGE.md +59 -0
- package/README.md +347 -0
- package/SECURITY.md +524 -0
- package/agent.cjs +221 -0
- package/agent.js +218 -0
- package/bin/cli.cjs +35 -0
- package/bin/cli.js +28 -0
- package/bin/mcp.cjs +22 -0
- package/bin/mcp.js +16 -0
- package/cli.cjs +15482 -0
- package/cli.js +15350 -0
- package/global.cjs +7827 -0
- package/global.d.ts +14 -0
- package/global.js +7808 -0
- package/index.cjs +29855 -0
- package/index.d.ts +15 -0
- package/index.js +29617 -0
- package/llms.txt +295 -0
- package/mcp.cjs +45234 -0
- package/mcp.js +45207 -0
- package/package.json +73 -53
- 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/types/reattach.d.ts +0 -87
package/agent.cjs
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('memorio/global');
|
|
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
|
+
getPlatform: () => getPlatform
|
|
25
|
+
});
|
|
26
|
+
var getPlatform;
|
|
27
|
+
var init_global = __esm({
|
|
28
|
+
"core/global.ts"() {
|
|
29
|
+
getPlatform = /* @__PURE__ */ __name(() => {
|
|
30
|
+
const proc = globalThis.process;
|
|
31
|
+
if (proc) {
|
|
32
|
+
return { platform: proc.platform ?? "unknown", arch: proc.arch ?? "unknown" };
|
|
33
|
+
}
|
|
34
|
+
const navigatorPlatform = typeof navigator !== "undefined" ? navigator.platform : "unknown";
|
|
35
|
+
return { platform: navigatorPlatform, arch: "unknown" };
|
|
36
|
+
}, "getPlatform");
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// core/agent/index.ts
|
|
41
|
+
function isExpired(entry) {
|
|
42
|
+
if (entry.ttl === null || entry.ttl === void 0) return false;
|
|
43
|
+
return Date.now() - entry.createdAt > entry.ttl;
|
|
44
|
+
}
|
|
45
|
+
__name(isExpired, "isExpired");
|
|
46
|
+
function normalizeTags(tags) {
|
|
47
|
+
if (!tags) return [];
|
|
48
|
+
return Array.isArray(tags) ? tags : [tags];
|
|
49
|
+
}
|
|
50
|
+
__name(normalizeTags, "normalizeTags");
|
|
51
|
+
function namespacedKey(agentTag, key) {
|
|
52
|
+
return `${agentTag}:${key}`;
|
|
53
|
+
}
|
|
54
|
+
__name(namespacedKey, "namespacedKey");
|
|
55
|
+
function stripKeyPrefix(key) {
|
|
56
|
+
const idx = key.indexOf(":");
|
|
57
|
+
if (idx < 0) return key;
|
|
58
|
+
const rest = key.slice(idx + 1);
|
|
59
|
+
const idx2 = rest.indexOf(":");
|
|
60
|
+
if (idx2 < 0) return key;
|
|
61
|
+
return rest.slice(idx2 + 1);
|
|
62
|
+
}
|
|
63
|
+
__name(stripKeyPrefix, "stripKeyPrefix");
|
|
64
|
+
function createAgentMemory(agentId) {
|
|
65
|
+
const agentTag = `agent:${agentId}`;
|
|
66
|
+
async function ensureDotMem() {
|
|
67
|
+
if (!globalThis.dotmem) {
|
|
68
|
+
await Promise.resolve().then(() => (init_global(), global_exports));
|
|
69
|
+
}
|
|
70
|
+
return globalThis.dotmem.memory;
|
|
71
|
+
}
|
|
72
|
+
__name(ensureDotMem, "ensureDotMem");
|
|
73
|
+
async function ensureTemporal() {
|
|
74
|
+
if (!globalThis.dotmem) {
|
|
75
|
+
await Promise.resolve().then(() => (init_global(), global_exports));
|
|
76
|
+
}
|
|
77
|
+
return globalThis.dotmem.temporal;
|
|
78
|
+
}
|
|
79
|
+
__name(ensureTemporal, "ensureTemporal");
|
|
80
|
+
return {
|
|
81
|
+
agentId,
|
|
82
|
+
/**
|
|
83
|
+
* Store a memory entry with type, confidence, scope, TTL, and tags.
|
|
84
|
+
* Keys are automatically namespaced with the agent ID for isolation.
|
|
85
|
+
*/
|
|
86
|
+
remember: /* @__PURE__ */ __name(async (key, value, options) => {
|
|
87
|
+
const mem = await ensureDotMem();
|
|
88
|
+
const userTags = normalizeTags(options?.tags);
|
|
89
|
+
const allTags = [...userTags, agentTag];
|
|
90
|
+
const nsKey = namespacedKey(agentTag, key);
|
|
91
|
+
await mem.remember(nsKey, value, {
|
|
92
|
+
...options,
|
|
93
|
+
tags: allTags,
|
|
94
|
+
source: options?.source ?? agentId
|
|
95
|
+
});
|
|
96
|
+
}, "remember"),
|
|
97
|
+
/**
|
|
98
|
+
* Retrieve a memory entry by key with optional filtering.
|
|
99
|
+
* Returns the full MemoryEntry with metadata (provenance, confidence, timestamp).
|
|
100
|
+
* Entries with expired TTL are treated as null.
|
|
101
|
+
*/
|
|
102
|
+
recall: /* @__PURE__ */ __name(async (key, options) => {
|
|
103
|
+
const mem = await ensureDotMem();
|
|
104
|
+
const nsKey = namespacedKey(agentTag, key);
|
|
105
|
+
const entry = await mem._getEntry(nsKey);
|
|
106
|
+
if (!entry) return null;
|
|
107
|
+
if (isExpired(entry)) return null;
|
|
108
|
+
if (entry.status === "obsolete" || entry.status === "superseded") {
|
|
109
|
+
return options?.includeObsolete ? entry : null;
|
|
110
|
+
}
|
|
111
|
+
const cleanEntry = { ...entry, key };
|
|
112
|
+
return cleanEntry;
|
|
113
|
+
}, "recall"),
|
|
114
|
+
/**
|
|
115
|
+
* Get ranked, semantically relevant memories for context.
|
|
116
|
+
* Automatically filters to this agent's memories only (via agent tag).
|
|
117
|
+
*
|
|
118
|
+
* Tag filtering uses AND semantics: if additional tags are specified,
|
|
119
|
+
* an entry must have the agent tag AND at least one of the specified tags.
|
|
120
|
+
*/
|
|
121
|
+
context: /* @__PURE__ */ __name(async (options) => {
|
|
122
|
+
const mem = await ensureDotMem();
|
|
123
|
+
const userTags = normalizeTags(options?.tags);
|
|
124
|
+
const agentTagOnly = await mem.context({
|
|
125
|
+
...options,
|
|
126
|
+
tags: agentTag
|
|
127
|
+
});
|
|
128
|
+
let result = agentTagOnly;
|
|
129
|
+
if (userTags.length > 0) {
|
|
130
|
+
result = agentTagOnly.filter(
|
|
131
|
+
(entry) => userTags.some((t) => entry.tags?.includes(t) ?? false)
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
return result.map((entry) => ({
|
|
135
|
+
...entry,
|
|
136
|
+
key: stripKeyPrefix(entry.key)
|
|
137
|
+
}));
|
|
138
|
+
}, "context"),
|
|
139
|
+
/**
|
|
140
|
+
* Access temporal history for a path (mutations over time).
|
|
141
|
+
*/
|
|
142
|
+
history: /* @__PURE__ */ __name(async (path) => {
|
|
143
|
+
const t = await ensureTemporal();
|
|
144
|
+
return t.history(path);
|
|
145
|
+
}, "history"),
|
|
146
|
+
/**
|
|
147
|
+
* Replay the state evolution from a temporal range.
|
|
148
|
+
*/
|
|
149
|
+
replay: /* @__PURE__ */ __name(async (opts) => {
|
|
150
|
+
const t = await ensureTemporal();
|
|
151
|
+
return t.replay({ from: opts.from, to: opts.to });
|
|
152
|
+
}, "replay"),
|
|
153
|
+
/**
|
|
154
|
+
* Create an isolated temporal branch for experimentation.
|
|
155
|
+
* Useful for "what-if" scenarios without affecting the main timeline.
|
|
156
|
+
*/
|
|
157
|
+
branch: /* @__PURE__ */ __name(async () => {
|
|
158
|
+
const t = await ensureTemporal();
|
|
159
|
+
return t.branch();
|
|
160
|
+
}, "branch"),
|
|
161
|
+
/**
|
|
162
|
+
* Get memory usage statistics.
|
|
163
|
+
*/
|
|
164
|
+
stats: /* @__PURE__ */ __name(async () => {
|
|
165
|
+
const mem = await ensureDotMem();
|
|
166
|
+
return mem.stats();
|
|
167
|
+
}, "stats"),
|
|
168
|
+
/**
|
|
169
|
+
* Update an existing memory entry.
|
|
170
|
+
*/
|
|
171
|
+
update: /* @__PURE__ */ __name(async (key, value, options) => {
|
|
172
|
+
const mem = await ensureDotMem();
|
|
173
|
+
const userTags = normalizeTags(options?.tags);
|
|
174
|
+
const allTags = [...userTags, agentTag];
|
|
175
|
+
const nsKey = namespacedKey(agentTag, key);
|
|
176
|
+
await mem.update(nsKey, value, {
|
|
177
|
+
...options,
|
|
178
|
+
tags: allTags
|
|
179
|
+
});
|
|
180
|
+
}, "update"),
|
|
181
|
+
/**
|
|
182
|
+
* Delete a memory entry.
|
|
183
|
+
*/
|
|
184
|
+
forget: /* @__PURE__ */ __name(async (key) => {
|
|
185
|
+
const mem = await ensureDotMem();
|
|
186
|
+
const nsKey = namespacedKey(agentTag, key);
|
|
187
|
+
await mem.forget(nsKey);
|
|
188
|
+
}, "forget"),
|
|
189
|
+
/**
|
|
190
|
+
* Enable temporal/history tracking.
|
|
191
|
+
*/
|
|
192
|
+
enable: /* @__PURE__ */ __name(async (bool = true) => {
|
|
193
|
+
const t = await ensureTemporal();
|
|
194
|
+
t.enable(bool);
|
|
195
|
+
}, "enable"),
|
|
196
|
+
/**
|
|
197
|
+
* Disable temporal tracking.
|
|
198
|
+
*/
|
|
199
|
+
disable: /* @__PURE__ */ __name(async () => {
|
|
200
|
+
const t = await ensureTemporal();
|
|
201
|
+
t.enable(false);
|
|
202
|
+
}, "disable"),
|
|
203
|
+
/**
|
|
204
|
+
* Clear the temporal log and all memories.
|
|
205
|
+
*/
|
|
206
|
+
clear: /* @__PURE__ */ __name(async () => {
|
|
207
|
+
const mem = await ensureDotMem();
|
|
208
|
+
const t = await ensureTemporal();
|
|
209
|
+
t.clear();
|
|
210
|
+
await mem.clear();
|
|
211
|
+
}, "clear")
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
__name(createAgentMemory, "createAgentMemory");
|
|
215
|
+
function createDefaultAgentMemory() {
|
|
216
|
+
return createAgentMemory("default-agent");
|
|
217
|
+
}
|
|
218
|
+
__name(createDefaultAgentMemory, "createDefaultAgentMemory");
|
|
219
|
+
|
|
220
|
+
exports.createAgentMemory = createAgentMemory;
|
|
221
|
+
exports.createDefaultAgentMemory = createDefaultAgentMemory;
|
package/agent.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import 'memorio/global';
|
|
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
|
+
getPlatform: () => getPlatform
|
|
23
|
+
});
|
|
24
|
+
var getPlatform;
|
|
25
|
+
var init_global = __esm({
|
|
26
|
+
"core/global.ts"() {
|
|
27
|
+
getPlatform = /* @__PURE__ */ __name(() => {
|
|
28
|
+
const proc = globalThis.process;
|
|
29
|
+
if (proc) {
|
|
30
|
+
return { platform: proc.platform ?? "unknown", arch: proc.arch ?? "unknown" };
|
|
31
|
+
}
|
|
32
|
+
const navigatorPlatform = typeof navigator !== "undefined" ? navigator.platform : "unknown";
|
|
33
|
+
return { platform: navigatorPlatform, arch: "unknown" };
|
|
34
|
+
}, "getPlatform");
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// core/agent/index.ts
|
|
39
|
+
function isExpired(entry) {
|
|
40
|
+
if (entry.ttl === null || entry.ttl === void 0) return false;
|
|
41
|
+
return Date.now() - entry.createdAt > entry.ttl;
|
|
42
|
+
}
|
|
43
|
+
__name(isExpired, "isExpired");
|
|
44
|
+
function normalizeTags(tags) {
|
|
45
|
+
if (!tags) return [];
|
|
46
|
+
return Array.isArray(tags) ? tags : [tags];
|
|
47
|
+
}
|
|
48
|
+
__name(normalizeTags, "normalizeTags");
|
|
49
|
+
function namespacedKey(agentTag, key) {
|
|
50
|
+
return `${agentTag}:${key}`;
|
|
51
|
+
}
|
|
52
|
+
__name(namespacedKey, "namespacedKey");
|
|
53
|
+
function stripKeyPrefix(key) {
|
|
54
|
+
const idx = key.indexOf(":");
|
|
55
|
+
if (idx < 0) return key;
|
|
56
|
+
const rest = key.slice(idx + 1);
|
|
57
|
+
const idx2 = rest.indexOf(":");
|
|
58
|
+
if (idx2 < 0) return key;
|
|
59
|
+
return rest.slice(idx2 + 1);
|
|
60
|
+
}
|
|
61
|
+
__name(stripKeyPrefix, "stripKeyPrefix");
|
|
62
|
+
function createAgentMemory(agentId) {
|
|
63
|
+
const agentTag = `agent:${agentId}`;
|
|
64
|
+
async function ensureDotMem() {
|
|
65
|
+
if (!globalThis.dotmem) {
|
|
66
|
+
await Promise.resolve().then(() => (init_global(), global_exports));
|
|
67
|
+
}
|
|
68
|
+
return globalThis.dotmem.memory;
|
|
69
|
+
}
|
|
70
|
+
__name(ensureDotMem, "ensureDotMem");
|
|
71
|
+
async function ensureTemporal() {
|
|
72
|
+
if (!globalThis.dotmem) {
|
|
73
|
+
await Promise.resolve().then(() => (init_global(), global_exports));
|
|
74
|
+
}
|
|
75
|
+
return globalThis.dotmem.temporal;
|
|
76
|
+
}
|
|
77
|
+
__name(ensureTemporal, "ensureTemporal");
|
|
78
|
+
return {
|
|
79
|
+
agentId,
|
|
80
|
+
/**
|
|
81
|
+
* Store a memory entry with type, confidence, scope, TTL, and tags.
|
|
82
|
+
* Keys are automatically namespaced with the agent ID for isolation.
|
|
83
|
+
*/
|
|
84
|
+
remember: /* @__PURE__ */ __name(async (key, value, options) => {
|
|
85
|
+
const mem = await ensureDotMem();
|
|
86
|
+
const userTags = normalizeTags(options?.tags);
|
|
87
|
+
const allTags = [...userTags, agentTag];
|
|
88
|
+
const nsKey = namespacedKey(agentTag, key);
|
|
89
|
+
await mem.remember(nsKey, value, {
|
|
90
|
+
...options,
|
|
91
|
+
tags: allTags,
|
|
92
|
+
source: options?.source ?? agentId
|
|
93
|
+
});
|
|
94
|
+
}, "remember"),
|
|
95
|
+
/**
|
|
96
|
+
* Retrieve a memory entry by key with optional filtering.
|
|
97
|
+
* Returns the full MemoryEntry with metadata (provenance, confidence, timestamp).
|
|
98
|
+
* Entries with expired TTL are treated as null.
|
|
99
|
+
*/
|
|
100
|
+
recall: /* @__PURE__ */ __name(async (key, options) => {
|
|
101
|
+
const mem = await ensureDotMem();
|
|
102
|
+
const nsKey = namespacedKey(agentTag, key);
|
|
103
|
+
const entry = await mem._getEntry(nsKey);
|
|
104
|
+
if (!entry) return null;
|
|
105
|
+
if (isExpired(entry)) return null;
|
|
106
|
+
if (entry.status === "obsolete" || entry.status === "superseded") {
|
|
107
|
+
return options?.includeObsolete ? entry : null;
|
|
108
|
+
}
|
|
109
|
+
const cleanEntry = { ...entry, key };
|
|
110
|
+
return cleanEntry;
|
|
111
|
+
}, "recall"),
|
|
112
|
+
/**
|
|
113
|
+
* Get ranked, semantically relevant memories for context.
|
|
114
|
+
* Automatically filters to this agent's memories only (via agent tag).
|
|
115
|
+
*
|
|
116
|
+
* Tag filtering uses AND semantics: if additional tags are specified,
|
|
117
|
+
* an entry must have the agent tag AND at least one of the specified tags.
|
|
118
|
+
*/
|
|
119
|
+
context: /* @__PURE__ */ __name(async (options) => {
|
|
120
|
+
const mem = await ensureDotMem();
|
|
121
|
+
const userTags = normalizeTags(options?.tags);
|
|
122
|
+
const agentTagOnly = await mem.context({
|
|
123
|
+
...options,
|
|
124
|
+
tags: agentTag
|
|
125
|
+
});
|
|
126
|
+
let result = agentTagOnly;
|
|
127
|
+
if (userTags.length > 0) {
|
|
128
|
+
result = agentTagOnly.filter(
|
|
129
|
+
(entry) => userTags.some((t) => entry.tags?.includes(t) ?? false)
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return result.map((entry) => ({
|
|
133
|
+
...entry,
|
|
134
|
+
key: stripKeyPrefix(entry.key)
|
|
135
|
+
}));
|
|
136
|
+
}, "context"),
|
|
137
|
+
/**
|
|
138
|
+
* Access temporal history for a path (mutations over time).
|
|
139
|
+
*/
|
|
140
|
+
history: /* @__PURE__ */ __name(async (path) => {
|
|
141
|
+
const t = await ensureTemporal();
|
|
142
|
+
return t.history(path);
|
|
143
|
+
}, "history"),
|
|
144
|
+
/**
|
|
145
|
+
* Replay the state evolution from a temporal range.
|
|
146
|
+
*/
|
|
147
|
+
replay: /* @__PURE__ */ __name(async (opts) => {
|
|
148
|
+
const t = await ensureTemporal();
|
|
149
|
+
return t.replay({ from: opts.from, to: opts.to });
|
|
150
|
+
}, "replay"),
|
|
151
|
+
/**
|
|
152
|
+
* Create an isolated temporal branch for experimentation.
|
|
153
|
+
* Useful for "what-if" scenarios without affecting the main timeline.
|
|
154
|
+
*/
|
|
155
|
+
branch: /* @__PURE__ */ __name(async () => {
|
|
156
|
+
const t = await ensureTemporal();
|
|
157
|
+
return t.branch();
|
|
158
|
+
}, "branch"),
|
|
159
|
+
/**
|
|
160
|
+
* Get memory usage statistics.
|
|
161
|
+
*/
|
|
162
|
+
stats: /* @__PURE__ */ __name(async () => {
|
|
163
|
+
const mem = await ensureDotMem();
|
|
164
|
+
return mem.stats();
|
|
165
|
+
}, "stats"),
|
|
166
|
+
/**
|
|
167
|
+
* Update an existing memory entry.
|
|
168
|
+
*/
|
|
169
|
+
update: /* @__PURE__ */ __name(async (key, value, options) => {
|
|
170
|
+
const mem = await ensureDotMem();
|
|
171
|
+
const userTags = normalizeTags(options?.tags);
|
|
172
|
+
const allTags = [...userTags, agentTag];
|
|
173
|
+
const nsKey = namespacedKey(agentTag, key);
|
|
174
|
+
await mem.update(nsKey, value, {
|
|
175
|
+
...options,
|
|
176
|
+
tags: allTags
|
|
177
|
+
});
|
|
178
|
+
}, "update"),
|
|
179
|
+
/**
|
|
180
|
+
* Delete a memory entry.
|
|
181
|
+
*/
|
|
182
|
+
forget: /* @__PURE__ */ __name(async (key) => {
|
|
183
|
+
const mem = await ensureDotMem();
|
|
184
|
+
const nsKey = namespacedKey(agentTag, key);
|
|
185
|
+
await mem.forget(nsKey);
|
|
186
|
+
}, "forget"),
|
|
187
|
+
/**
|
|
188
|
+
* Enable temporal/history tracking.
|
|
189
|
+
*/
|
|
190
|
+
enable: /* @__PURE__ */ __name(async (bool = true) => {
|
|
191
|
+
const t = await ensureTemporal();
|
|
192
|
+
t.enable(bool);
|
|
193
|
+
}, "enable"),
|
|
194
|
+
/**
|
|
195
|
+
* Disable temporal tracking.
|
|
196
|
+
*/
|
|
197
|
+
disable: /* @__PURE__ */ __name(async () => {
|
|
198
|
+
const t = await ensureTemporal();
|
|
199
|
+
t.enable(false);
|
|
200
|
+
}, "disable"),
|
|
201
|
+
/**
|
|
202
|
+
* Clear the temporal log and all memories.
|
|
203
|
+
*/
|
|
204
|
+
clear: /* @__PURE__ */ __name(async () => {
|
|
205
|
+
const mem = await ensureDotMem();
|
|
206
|
+
const t = await ensureTemporal();
|
|
207
|
+
t.clear();
|
|
208
|
+
await mem.clear();
|
|
209
|
+
}, "clear")
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
__name(createAgentMemory, "createAgentMemory");
|
|
213
|
+
function createDefaultAgentMemory() {
|
|
214
|
+
return createAgentMemory("default-agent");
|
|
215
|
+
}
|
|
216
|
+
__name(createDefaultAgentMemory, "createDefaultAgentMemory");
|
|
217
|
+
|
|
218
|
+
export { createAgentMemory, createDefaultAgentMemory };
|
package/bin/cli.cjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
})();
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import process from 'process';
|
|
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
|
+
})();
|
package/bin/mcp.cjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
}
|
package/bin/mcp.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import process from 'process';
|
|
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
|
+
}
|