@mem0/cli 0.1.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/README.md +75 -0
- package/development.md +91 -0
- package/dist/chunk-EJ5AQPMT.js +120 -0
- package/dist/chunk-I7ABQZUR.js +111 -0
- package/dist/chunk-J7DYZDMM.js +187 -0
- package/dist/chunk-O3XZVUUX.js +252 -0
- package/dist/config-WKOCXNAS.js +86 -0
- package/dist/entities-XPRXH4X4.js +119 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +523 -0
- package/dist/init-N25QFHYP.js +161 -0
- package/dist/memory-JYJGE4VO.js +387 -0
- package/dist/utils-BAMFZ5H5.js +124 -0
- package/package.json +42 -0
- package/src/backend/base.ts +115 -0
- package/src/backend/index.ts +7 -0
- package/src/backend/platform.ts +303 -0
- package/src/branding.ts +145 -0
- package/src/commands/config.ts +90 -0
- package/src/commands/entities.ts +139 -0
- package/src/commands/init.ts +182 -0
- package/src/commands/memory.ts +487 -0
- package/src/commands/utils.ts +139 -0
- package/src/config.ts +159 -0
- package/src/help.ts +374 -0
- package/src/index.ts +501 -0
- package/src/output.ts +230 -0
- package/tests/branding.test.ts +98 -0
- package/tests/cli-integration.test.ts +156 -0
- package/tests/commands.test.ts +221 -0
- package/tests/config.test.ts +113 -0
- package/tests/output.test.ts +115 -0
- package/tests/setup.ts +75 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// src/backend/base.ts
|
|
2
|
+
var AuthError = class extends Error {
|
|
3
|
+
constructor(message = "Authentication failed. Your API key may be invalid or expired.") {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "AuthError";
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
var NotFoundError = class extends Error {
|
|
9
|
+
constructor(path) {
|
|
10
|
+
super(`Resource not found: ${path}`);
|
|
11
|
+
this.name = "NotFoundError";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var APIError = class extends Error {
|
|
15
|
+
constructor(path, detail) {
|
|
16
|
+
super(`Bad request to ${path}: ${detail}`);
|
|
17
|
+
this.name = "APIError";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function getBackend(config) {
|
|
21
|
+
return new PlatformBackend(config.platform);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/backend/platform.ts
|
|
25
|
+
var PlatformBackend = class {
|
|
26
|
+
baseUrl;
|
|
27
|
+
headers;
|
|
28
|
+
constructor(config) {
|
|
29
|
+
this.baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
30
|
+
this.headers = {
|
|
31
|
+
Authorization: `Token ${config.apiKey}`,
|
|
32
|
+
"Content-Type": "application/json"
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async _request(method, path, opts) {
|
|
36
|
+
let url = `${this.baseUrl}${path}`;
|
|
37
|
+
if (opts?.params) {
|
|
38
|
+
const qs = new URLSearchParams(opts.params).toString();
|
|
39
|
+
url += `?${qs}`;
|
|
40
|
+
}
|
|
41
|
+
const fetchOpts = {
|
|
42
|
+
method,
|
|
43
|
+
headers: this.headers,
|
|
44
|
+
signal: AbortSignal.timeout(3e4)
|
|
45
|
+
};
|
|
46
|
+
if (opts?.json) {
|
|
47
|
+
fetchOpts.body = JSON.stringify(opts.json);
|
|
48
|
+
}
|
|
49
|
+
const resp = await fetch(url, fetchOpts);
|
|
50
|
+
if (resp.status === 401) {
|
|
51
|
+
throw new AuthError();
|
|
52
|
+
}
|
|
53
|
+
if (resp.status === 404) {
|
|
54
|
+
throw new NotFoundError(path);
|
|
55
|
+
}
|
|
56
|
+
if (resp.status === 400) {
|
|
57
|
+
let detail;
|
|
58
|
+
try {
|
|
59
|
+
const body = await resp.json();
|
|
60
|
+
detail = body.detail ?? resp.statusText;
|
|
61
|
+
} catch {
|
|
62
|
+
detail = resp.statusText;
|
|
63
|
+
}
|
|
64
|
+
throw new APIError(path, detail);
|
|
65
|
+
}
|
|
66
|
+
if (!resp.ok) {
|
|
67
|
+
throw new Error(`HTTP ${resp.status}: ${resp.statusText}`);
|
|
68
|
+
}
|
|
69
|
+
if (resp.status === 204) {
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
return resp.json();
|
|
73
|
+
}
|
|
74
|
+
async add(content, messages, opts = {}) {
|
|
75
|
+
const payload = {};
|
|
76
|
+
if (messages) {
|
|
77
|
+
payload.messages = messages;
|
|
78
|
+
} else if (content) {
|
|
79
|
+
payload.messages = [{ role: "user", content }];
|
|
80
|
+
}
|
|
81
|
+
if (opts.userId) payload.user_id = opts.userId;
|
|
82
|
+
if (opts.agentId) payload.agent_id = opts.agentId;
|
|
83
|
+
if (opts.appId) payload.app_id = opts.appId;
|
|
84
|
+
if (opts.runId) payload.run_id = opts.runId;
|
|
85
|
+
if (opts.metadata) payload.metadata = opts.metadata;
|
|
86
|
+
if (opts.immutable) payload.immutable = true;
|
|
87
|
+
if (opts.infer === false) payload.infer = false;
|
|
88
|
+
if (opts.expires) payload.expiration_date = opts.expires;
|
|
89
|
+
if (opts.categories) payload.categories = opts.categories;
|
|
90
|
+
if (opts.enableGraph) payload.enable_graph = true;
|
|
91
|
+
return await this._request("POST", "/v1/memories/", { json: payload });
|
|
92
|
+
}
|
|
93
|
+
_buildFilters(opts) {
|
|
94
|
+
if (opts.extraFilters && ("AND" in opts.extraFilters || "OR" in opts.extraFilters)) {
|
|
95
|
+
return opts.extraFilters;
|
|
96
|
+
}
|
|
97
|
+
const andConditions = [];
|
|
98
|
+
if (opts.userId) andConditions.push({ user_id: opts.userId });
|
|
99
|
+
if (opts.agentId) andConditions.push({ agent_id: opts.agentId });
|
|
100
|
+
if (opts.appId) andConditions.push({ app_id: opts.appId });
|
|
101
|
+
if (opts.runId) andConditions.push({ run_id: opts.runId });
|
|
102
|
+
if (opts.extraFilters) {
|
|
103
|
+
for (const [k, v] of Object.entries(opts.extraFilters)) {
|
|
104
|
+
andConditions.push({ [k]: v });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (andConditions.length === 1) return andConditions[0];
|
|
108
|
+
if (andConditions.length > 1) return { AND: andConditions };
|
|
109
|
+
return void 0;
|
|
110
|
+
}
|
|
111
|
+
async search(query, opts = {}) {
|
|
112
|
+
const payload = {
|
|
113
|
+
query,
|
|
114
|
+
top_k: opts.topK ?? 10,
|
|
115
|
+
threshold: opts.threshold ?? 0.3
|
|
116
|
+
};
|
|
117
|
+
const apiFilters = this._buildFilters({
|
|
118
|
+
userId: opts.userId,
|
|
119
|
+
agentId: opts.agentId,
|
|
120
|
+
appId: opts.appId,
|
|
121
|
+
runId: opts.runId,
|
|
122
|
+
extraFilters: opts.filters
|
|
123
|
+
});
|
|
124
|
+
if (apiFilters) payload.filters = apiFilters;
|
|
125
|
+
if (opts.rerank) payload.rerank = true;
|
|
126
|
+
if (opts.keyword) payload.keyword_search = true;
|
|
127
|
+
if (opts.fields) payload.fields = opts.fields;
|
|
128
|
+
if (opts.enableGraph) payload.enable_graph = true;
|
|
129
|
+
const result = await this._request("POST", "/v2/memories/search/", {
|
|
130
|
+
json: payload
|
|
131
|
+
});
|
|
132
|
+
if (Array.isArray(result)) return result;
|
|
133
|
+
const obj = result;
|
|
134
|
+
return obj.results ?? obj.memories ?? [];
|
|
135
|
+
}
|
|
136
|
+
async get(memoryId) {
|
|
137
|
+
return await this._request("GET", `/v1/memories/${memoryId}/`);
|
|
138
|
+
}
|
|
139
|
+
async listMemories(opts = {}) {
|
|
140
|
+
const payload = {};
|
|
141
|
+
const params = {
|
|
142
|
+
page: String(opts.page ?? 1),
|
|
143
|
+
page_size: String(opts.pageSize ?? 100)
|
|
144
|
+
};
|
|
145
|
+
const extra = {};
|
|
146
|
+
if (opts.category) {
|
|
147
|
+
extra.categories = { contains: opts.category };
|
|
148
|
+
}
|
|
149
|
+
if (opts.after) {
|
|
150
|
+
extra.created_at = { ...extra.created_at, gte: opts.after };
|
|
151
|
+
}
|
|
152
|
+
if (opts.before) {
|
|
153
|
+
extra.created_at = { ...extra.created_at, lte: opts.before };
|
|
154
|
+
}
|
|
155
|
+
const apiFilters = this._buildFilters({
|
|
156
|
+
userId: opts.userId,
|
|
157
|
+
agentId: opts.agentId,
|
|
158
|
+
appId: opts.appId,
|
|
159
|
+
runId: opts.runId,
|
|
160
|
+
extraFilters: Object.keys(extra).length > 0 ? extra : void 0
|
|
161
|
+
});
|
|
162
|
+
if (apiFilters) payload.filters = apiFilters;
|
|
163
|
+
if (opts.enableGraph) payload.enable_graph = true;
|
|
164
|
+
const result = await this._request("POST", "/v2/memories/", { json: payload, params });
|
|
165
|
+
if (Array.isArray(result)) return result;
|
|
166
|
+
const obj = result;
|
|
167
|
+
return obj.results ?? obj.memories ?? [];
|
|
168
|
+
}
|
|
169
|
+
async update(memoryId, content, metadata) {
|
|
170
|
+
const payload = {};
|
|
171
|
+
if (content) payload.text = content;
|
|
172
|
+
if (metadata) payload.metadata = metadata;
|
|
173
|
+
return await this._request("PUT", `/v1/memories/${memoryId}/`, {
|
|
174
|
+
json: payload
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
async delete(memoryId, opts = {}) {
|
|
178
|
+
if (opts.all) {
|
|
179
|
+
const params = {};
|
|
180
|
+
if (opts.userId) params.user_id = opts.userId;
|
|
181
|
+
if (opts.agentId) params.agent_id = opts.agentId;
|
|
182
|
+
if (opts.appId) params.app_id = opts.appId;
|
|
183
|
+
if (opts.runId) params.run_id = opts.runId;
|
|
184
|
+
return await this._request("DELETE", "/v1/memories/", { params });
|
|
185
|
+
}
|
|
186
|
+
if (memoryId) {
|
|
187
|
+
return await this._request("DELETE", `/v1/memories/${memoryId}/`);
|
|
188
|
+
}
|
|
189
|
+
throw new Error("Either memoryId or --all is required");
|
|
190
|
+
}
|
|
191
|
+
async deleteEntities(opts) {
|
|
192
|
+
const params = {};
|
|
193
|
+
if (opts.userId) params.user_id = opts.userId;
|
|
194
|
+
if (opts.agentId) params.agent_id = opts.agentId;
|
|
195
|
+
if (opts.appId) params.app_id = opts.appId;
|
|
196
|
+
if (opts.runId) params.run_id = opts.runId;
|
|
197
|
+
if (Object.keys(params).length === 0) {
|
|
198
|
+
throw new Error("At least one entity ID is required for deleteEntities.");
|
|
199
|
+
}
|
|
200
|
+
return await this._request("DELETE", "/v1/entities/", { params });
|
|
201
|
+
}
|
|
202
|
+
async status(opts = {}) {
|
|
203
|
+
try {
|
|
204
|
+
if (opts.userId || opts.agentId) {
|
|
205
|
+
const payload = {};
|
|
206
|
+
const statusParams = { page: "1", page_size: "1" };
|
|
207
|
+
const apiFilters = this._buildFilters({
|
|
208
|
+
userId: opts.userId,
|
|
209
|
+
agentId: opts.agentId
|
|
210
|
+
});
|
|
211
|
+
if (apiFilters) payload.filters = apiFilters;
|
|
212
|
+
await this._request("POST", "/v2/memories/", { json: payload, params: statusParams });
|
|
213
|
+
} else {
|
|
214
|
+
await this._request("GET", "/v1/entities/");
|
|
215
|
+
}
|
|
216
|
+
return { connected: true, backend: "platform", base_url: this.baseUrl };
|
|
217
|
+
} catch (e) {
|
|
218
|
+
return {
|
|
219
|
+
connected: false,
|
|
220
|
+
backend: "platform",
|
|
221
|
+
error: e instanceof Error ? e.message : String(e)
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async entities(entityType) {
|
|
226
|
+
const result = await this._request("GET", "/v1/entities/");
|
|
227
|
+
let items;
|
|
228
|
+
if (Array.isArray(result)) {
|
|
229
|
+
items = result;
|
|
230
|
+
} else {
|
|
231
|
+
items = result.results ?? [];
|
|
232
|
+
}
|
|
233
|
+
const typeMap = {
|
|
234
|
+
users: "user",
|
|
235
|
+
agents: "agent",
|
|
236
|
+
apps: "app",
|
|
237
|
+
runs: "run"
|
|
238
|
+
};
|
|
239
|
+
const targetType = typeMap[entityType];
|
|
240
|
+
if (targetType) {
|
|
241
|
+
items = items.filter(
|
|
242
|
+
(e) => e.type?.toLowerCase() === targetType
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
return items;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export {
|
|
250
|
+
PlatformBackend,
|
|
251
|
+
getBackend
|
|
252
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getNestedValue,
|
|
3
|
+
loadConfig,
|
|
4
|
+
redactKey,
|
|
5
|
+
saveConfig,
|
|
6
|
+
setNestedValue
|
|
7
|
+
} from "./chunk-EJ5AQPMT.js";
|
|
8
|
+
import {
|
|
9
|
+
formatJsonEnvelope
|
|
10
|
+
} from "./chunk-J7DYZDMM.js";
|
|
11
|
+
import {
|
|
12
|
+
colors,
|
|
13
|
+
printError,
|
|
14
|
+
printSuccess
|
|
15
|
+
} from "./chunk-I7ABQZUR.js";
|
|
16
|
+
|
|
17
|
+
// src/commands/config.ts
|
|
18
|
+
import Table from "cli-table3";
|
|
19
|
+
var { brand, accent, dim } = colors;
|
|
20
|
+
function cmdConfigShow(opts = {}) {
|
|
21
|
+
const config = loadConfig();
|
|
22
|
+
if (opts.output === "json") {
|
|
23
|
+
formatJsonEnvelope({
|
|
24
|
+
command: "config show",
|
|
25
|
+
data: {
|
|
26
|
+
defaults: {
|
|
27
|
+
user_id: config.defaults.userId || null,
|
|
28
|
+
agent_id: config.defaults.agentId || null,
|
|
29
|
+
app_id: config.defaults.appId || null,
|
|
30
|
+
run_id: config.defaults.runId || null,
|
|
31
|
+
enable_graph: config.defaults.enableGraph
|
|
32
|
+
},
|
|
33
|
+
platform: {
|
|
34
|
+
api_key: redactKey(config.platform.apiKey),
|
|
35
|
+
base_url: config.platform.baseUrl
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
console.log();
|
|
42
|
+
console.log(` ${brand("\u25C6 mem0 Configuration")}
|
|
43
|
+
`);
|
|
44
|
+
const table = new Table({
|
|
45
|
+
head: [accent("Key"), accent("Value")],
|
|
46
|
+
style: { head: [], border: [] }
|
|
47
|
+
});
|
|
48
|
+
table.push(["defaults.user_id", config.defaults.userId || dim("(not set)")]);
|
|
49
|
+
table.push(["defaults.agent_id", config.defaults.agentId || dim("(not set)")]);
|
|
50
|
+
table.push(["defaults.app_id", config.defaults.appId || dim("(not set)")]);
|
|
51
|
+
table.push(["defaults.run_id", config.defaults.runId || dim("(not set)")]);
|
|
52
|
+
table.push(["defaults.enable_graph", String(config.defaults.enableGraph)]);
|
|
53
|
+
table.push(["", ""]);
|
|
54
|
+
table.push(["platform.api_key", redactKey(config.platform.apiKey)]);
|
|
55
|
+
table.push(["platform.base_url", config.platform.baseUrl]);
|
|
56
|
+
console.log(table.toString());
|
|
57
|
+
console.log();
|
|
58
|
+
}
|
|
59
|
+
function cmdConfigGet(key) {
|
|
60
|
+
const config = loadConfig();
|
|
61
|
+
const value = getNestedValue(config, key);
|
|
62
|
+
if (value === void 0) {
|
|
63
|
+
printError(`Unknown config key: ${key}`);
|
|
64
|
+
} else {
|
|
65
|
+
if (key.includes("api_key") || key.split(".").pop() === "key") {
|
|
66
|
+
console.log(redactKey(String(value)));
|
|
67
|
+
} else {
|
|
68
|
+
console.log(String(value));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function cmdConfigSet(key, value) {
|
|
73
|
+
const config = loadConfig();
|
|
74
|
+
if (setNestedValue(config, key, value)) {
|
|
75
|
+
saveConfig(config);
|
|
76
|
+
const display = key.includes("key") ? redactKey(value) : value;
|
|
77
|
+
printSuccess(`${key} = ${display}`);
|
|
78
|
+
} else {
|
|
79
|
+
printError(`Unknown config key: ${key}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
cmdConfigGet,
|
|
84
|
+
cmdConfigSet,
|
|
85
|
+
cmdConfigShow
|
|
86
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatJson
|
|
3
|
+
} from "./chunk-J7DYZDMM.js";
|
|
4
|
+
import {
|
|
5
|
+
colors,
|
|
6
|
+
printError,
|
|
7
|
+
printInfo,
|
|
8
|
+
printSuccess,
|
|
9
|
+
timedStatus
|
|
10
|
+
} from "./chunk-I7ABQZUR.js";
|
|
11
|
+
|
|
12
|
+
// src/commands/entities.ts
|
|
13
|
+
import readline from "readline";
|
|
14
|
+
import Table from "cli-table3";
|
|
15
|
+
var { brand, accent, dim } = colors;
|
|
16
|
+
var VALID_TYPES = /* @__PURE__ */ new Set(["users", "agents", "apps", "runs"]);
|
|
17
|
+
async function cmdEntitiesList(backend, entityType, opts) {
|
|
18
|
+
if (!VALID_TYPES.has(entityType)) {
|
|
19
|
+
printError(`Invalid entity type: ${entityType}. Use: ${[...VALID_TYPES].join(", ")}`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
const start = performance.now();
|
|
23
|
+
let results;
|
|
24
|
+
try {
|
|
25
|
+
results = await timedStatus(`Fetching ${entityType}...`, async () => {
|
|
26
|
+
return backend.entities(entityType);
|
|
27
|
+
});
|
|
28
|
+
} catch (e) {
|
|
29
|
+
printError(
|
|
30
|
+
e instanceof Error ? e.message : String(e),
|
|
31
|
+
"This feature may require the mem0 Platform."
|
|
32
|
+
);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
const elapsed = (performance.now() - start) / 1e3;
|
|
36
|
+
if (opts.output === "json") {
|
|
37
|
+
formatJson(results);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!results.length) {
|
|
41
|
+
printInfo(`No ${entityType} found.`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const table = new Table({
|
|
45
|
+
head: [accent("Name / ID"), accent("Created")],
|
|
46
|
+
style: { head: [], border: [] }
|
|
47
|
+
});
|
|
48
|
+
for (const entity of results) {
|
|
49
|
+
const name = String(entity.name ?? entity.id ?? "\u2014");
|
|
50
|
+
const created = String(entity.created_at ?? "\u2014").slice(0, 10);
|
|
51
|
+
table.push([name, created]);
|
|
52
|
+
}
|
|
53
|
+
console.log();
|
|
54
|
+
console.log(table.toString());
|
|
55
|
+
console.log(` ${dim(`${results.length} ${entityType} (${elapsed.toFixed(2)}s)`)}`);
|
|
56
|
+
console.log();
|
|
57
|
+
}
|
|
58
|
+
async function cmdEntitiesDelete(backend, opts) {
|
|
59
|
+
if (!opts.userId && !opts.agentId && !opts.appId && !opts.runId) {
|
|
60
|
+
printError("Provide at least one of --user-id, --agent-id, --app-id, --run-id.");
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
if (opts.dryRun) {
|
|
64
|
+
const scopeParts = [];
|
|
65
|
+
if (opts.userId) scopeParts.push(`user=${opts.userId}`);
|
|
66
|
+
if (opts.agentId) scopeParts.push(`agent=${opts.agentId}`);
|
|
67
|
+
if (opts.appId) scopeParts.push(`app=${opts.appId}`);
|
|
68
|
+
if (opts.runId) scopeParts.push(`run=${opts.runId}`);
|
|
69
|
+
printInfo(`Would delete entity ${scopeParts.join(", ")} and all its memories.`);
|
|
70
|
+
printInfo("No changes made.");
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!opts.force) {
|
|
74
|
+
const scopeParts = [];
|
|
75
|
+
if (opts.userId) scopeParts.push(`user=${opts.userId}`);
|
|
76
|
+
if (opts.agentId) scopeParts.push(`agent=${opts.agentId}`);
|
|
77
|
+
if (opts.appId) scopeParts.push(`app=${opts.appId}`);
|
|
78
|
+
if (opts.runId) scopeParts.push(`run=${opts.runId}`);
|
|
79
|
+
const scope = scopeParts.join(", ");
|
|
80
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
81
|
+
const answer = await new Promise((resolve) => {
|
|
82
|
+
rl.question(
|
|
83
|
+
`
|
|
84
|
+
\u26A0 Delete entity ${scope} AND all its memories? This cannot be undone. [y/N] `,
|
|
85
|
+
resolve
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
rl.close();
|
|
89
|
+
if (answer.toLowerCase() !== "y") {
|
|
90
|
+
printInfo("Cancelled.");
|
|
91
|
+
process.exit(0);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const start = performance.now();
|
|
95
|
+
let result;
|
|
96
|
+
try {
|
|
97
|
+
result = await timedStatus("Deleting entity...", async () => {
|
|
98
|
+
return backend.deleteEntities({
|
|
99
|
+
userId: opts.userId,
|
|
100
|
+
agentId: opts.agentId,
|
|
101
|
+
appId: opts.appId,
|
|
102
|
+
runId: opts.runId
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
} catch (e) {
|
|
106
|
+
printError(e instanceof Error ? e.message : String(e));
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
const elapsed = (performance.now() - start) / 1e3;
|
|
110
|
+
if (opts.output === "json") {
|
|
111
|
+
formatJson(result);
|
|
112
|
+
} else if (opts.output !== "quiet") {
|
|
113
|
+
printSuccess(`Entity deleted with all memories (${elapsed.toFixed(2)}s)`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
cmdEntitiesDelete,
|
|
118
|
+
cmdEntitiesList
|
|
119
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|