@memnexus-ai/cli 1.7.214 → 1.7.216
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/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +43 -0
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/memories.d.ts +115 -0
- package/dist/commands/memories.d.ts.map +1 -1
- package/dist/commands/memories.js +578 -8
- package/dist/commands/memories.js.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsQ3D"}
|
package/dist/commands/auth.js
CHANGED
|
@@ -201,5 +201,48 @@ function registerAuthCommands(program) {
|
|
|
201
201
|
(0, errors_1.handleError)(error);
|
|
202
202
|
}
|
|
203
203
|
});
|
|
204
|
+
/**
|
|
205
|
+
* mx auth whoami [--format <format>]
|
|
206
|
+
* Show the authenticated ACCOUNT IDENTITY (server-authoritative), including the
|
|
207
|
+
* `isTestUser` / `isInternalUser` markers and the active endpoint. Unlike
|
|
208
|
+
* `auth status` (which only reflects local config), this calls
|
|
209
|
+
* GET /api/users/me, so it is the authoritative source for destructive-tool
|
|
210
|
+
* safety gates (e.g. dev-tools/scripts/cli-bulk-benchmark.sh) that must refuse
|
|
211
|
+
* to run against a non-test account. Only prefixes/flags are shown — no secret
|
|
212
|
+
* material is emitted.
|
|
213
|
+
*/
|
|
214
|
+
auth
|
|
215
|
+
.command('whoami')
|
|
216
|
+
.description('Show the authenticated account identity (email, isTestUser, plan, endpoint)')
|
|
217
|
+
.option('--format <format>', 'Output format (json|table|yaml)')
|
|
218
|
+
.action(async (options) => {
|
|
219
|
+
try {
|
|
220
|
+
const apiUrl = config_1.config.getApiUrl();
|
|
221
|
+
const response = await (0, api_client_1.getSdk)().users.getCurrentUser();
|
|
222
|
+
const result = (0, api_client_1.extractResponseData)(response);
|
|
223
|
+
const user = result?.data;
|
|
224
|
+
if (!user?.email) {
|
|
225
|
+
console.error(chalk_1.default.red('Could not resolve the current user from /api/users/me'));
|
|
226
|
+
process.exitCode = 1;
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
// Server-authoritative identity. isTestUser/isInternalUser are the fields
|
|
230
|
+
// destructive dev-tools gate on.
|
|
231
|
+
const identity = {
|
|
232
|
+
id: user.id,
|
|
233
|
+
email: user.email,
|
|
234
|
+
plan: user.plan,
|
|
235
|
+
status: user.status,
|
|
236
|
+
isTestUser: user.isTestUser === true,
|
|
237
|
+
isInternalUser: user.isInternalUser === true,
|
|
238
|
+
isPreviewUser: user.isPreviewUser === true,
|
|
239
|
+
apiUrl,
|
|
240
|
+
};
|
|
241
|
+
(0, formatters_1.printOutput)(identity, options.format);
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
(0, errors_1.handleError)(error);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
204
247
|
}
|
|
205
248
|
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":";;;;;AAgBA,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":";;;;;AAgBA,oDAsQC;AArRD,wDAAgC;AAChC,kDAA0B;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AC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
/** Number of deletions within the window that triggers the guard. */
|
|
3
|
+
export declare const BULK_DELETE_GUARD_THRESHOLD = 5;
|
|
4
|
+
/** Rolling window in milliseconds (60 seconds). */
|
|
5
|
+
export declare const BULK_DELETE_GUARD_WINDOW_MS = 60000;
|
|
6
|
+
/** Path to the guard file for the current user. */
|
|
7
|
+
export declare function getBulkDeleteGuardPath(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Read recent deletion timestamps from the guard file, pruning entries
|
|
10
|
+
* older than the window. Returns the count of recent deletions.
|
|
11
|
+
*
|
|
12
|
+
* The file format is one timestamp (ms since epoch) per line. Malformed
|
|
13
|
+
* lines are silently dropped — the file is advisory, not critical.
|
|
14
|
+
*/
|
|
15
|
+
export declare function readDeleteGuardTimestamps(guardPath: string, now: number): number[];
|
|
16
|
+
/**
|
|
17
|
+
* Record a deletion timestamp in the guard file. Prunes old entries
|
|
18
|
+
* on write to keep the file small.
|
|
19
|
+
*/
|
|
20
|
+
export declare function recordDeletion(guardPath: string, now: number): void;
|
|
21
|
+
/**
|
|
22
|
+
* Check whether the bulk-delete guard should block. Returns true if the
|
|
23
|
+
* caller should proceed, false if it should abort.
|
|
24
|
+
*
|
|
25
|
+
* When the guard fires, it prints a warning to stderr explaining what
|
|
26
|
+
* happened and how to override.
|
|
27
|
+
*/
|
|
28
|
+
export declare function checkBulkDeleteGuard(guardPath: string, now: number): boolean;
|
|
2
29
|
/**
|
|
3
30
|
* Parse the --code-context JSON flag.
|
|
4
31
|
*
|
|
@@ -7,6 +34,94 @@ import { Command } from 'commander';
|
|
|
7
34
|
* product/service/team/role are present, they must be strings.
|
|
8
35
|
*/
|
|
9
36
|
export declare function parseCodeContextFlag(raw: string): Record<string, unknown>;
|
|
37
|
+
/** Max ids the server accepts per bulk-delete request (bulk-operations.schema.ts). */
|
|
38
|
+
export declare const BULK_DELETE_MAX_IDS = 100;
|
|
39
|
+
/** Pause between sequential 100-id pages, keeps request cadence gentle. */
|
|
40
|
+
export declare const BULK_DELETE_PAGE_PAUSE_MS = 250;
|
|
41
|
+
/** Max retries per page on 429 before giving up. */
|
|
42
|
+
export declare const BULK_DELETE_MAX_RETRIES = 3;
|
|
43
|
+
/** Page size when listing memories for --all. */
|
|
44
|
+
export declare const BULK_DELETE_LIST_PAGE_SIZE = 100;
|
|
45
|
+
export interface BulkDeleteResult {
|
|
46
|
+
deleted: number;
|
|
47
|
+
failed: number;
|
|
48
|
+
errors: {
|
|
49
|
+
id: string;
|
|
50
|
+
error: string;
|
|
51
|
+
}[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Parse `--batch <ids...>` values into a flat, de-duplicated id list.
|
|
55
|
+
* Commander collects the variadic option into a string[]; each element may
|
|
56
|
+
* itself be comma- or space-separated, so we split again and trim.
|
|
57
|
+
*/
|
|
58
|
+
export declare function parseBatchIds(values: string[] | undefined): string[];
|
|
59
|
+
/**
|
|
60
|
+
* True when `value` is a parseable ISO 8601 date. Used to validate the
|
|
61
|
+
* `--after`/`--before` filters on `--all` before they count as filters — a
|
|
62
|
+
* malformed date must be rejected, not silently treated as a real filter that
|
|
63
|
+
* bypasses the delete-everything gate. Requires a date-shaped prefix
|
|
64
|
+
* (YYYY-MM-DD…) so lenient locale strings like "notadate" or "July" are refused.
|
|
65
|
+
*/
|
|
66
|
+
export declare function isValidIsoDate(value: string): boolean;
|
|
67
|
+
/** Split ids into pages of at most `size` (default 100). */
|
|
68
|
+
export declare function chunkIds(ids: string[], size?: number): string[][];
|
|
69
|
+
/** True when an error is an HTTP 429 (rate limited). */
|
|
70
|
+
export declare function isRateLimitError(error: any): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Extract the server's Retry-After hint in milliseconds, or null if absent.
|
|
73
|
+
* The API surfaces it as a body field (`retryAfter`, seconds) on 429s
|
|
74
|
+
* (see lib/errors.ts) and may also send a Retry-After header; we honor both.
|
|
75
|
+
*/
|
|
76
|
+
export declare function getRetryAfterMs(error: any): number | null;
|
|
77
|
+
/** Promise-based sleep. Extracted so tests can inject a no-op/spy. */
|
|
78
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
79
|
+
export interface BulkDeleteDeps {
|
|
80
|
+
/** Deletes one page (≤100 ids) and returns the server's counts. */
|
|
81
|
+
deleteFn: (ids: string[]) => Promise<BulkDeleteResult>;
|
|
82
|
+
/** Sleep function (injectable for tests). */
|
|
83
|
+
sleep: (ms: number) => Promise<void>;
|
|
84
|
+
maxRetries?: number;
|
|
85
|
+
/** Fallback backoff (ms) when the server gives no Retry-After hint. */
|
|
86
|
+
defaultRetryMs?: number;
|
|
87
|
+
/** 429 counter (incremented once per rate-limited attempt). */
|
|
88
|
+
onRateLimited?: (waitMs: number) => void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Delete a single page, retrying on 429 up to `maxRetries` times. Honors the
|
|
92
|
+
* server's Retry-After hint; falls back to a linear backoff otherwise.
|
|
93
|
+
*/
|
|
94
|
+
export declare function bulkDeleteWithRetry(ids: string[], deps: BulkDeleteDeps): Promise<BulkDeleteResult>;
|
|
95
|
+
export interface PagedBulkDeleteResult extends BulkDeleteResult {
|
|
96
|
+
/** Number of bulk requests issued (pages) — the rate-limiter's unit. */
|
|
97
|
+
requestCount: number;
|
|
98
|
+
/** Number of 429 responses observed across all pages. */
|
|
99
|
+
rateLimitedCount: number;
|
|
100
|
+
/** True when a page exhausted retries / errored and paging stopped early. */
|
|
101
|
+
aborted: boolean;
|
|
102
|
+
/** Ids in pages that were never attempted because paging aborted early. */
|
|
103
|
+
notAttempted: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Delete `ids` in sequential ≤100-id pages with a brief pause between pages and
|
|
107
|
+
* per-page 429 retry. Aggregates per-page results.
|
|
108
|
+
*
|
|
109
|
+
* A page that exhausts its 429 retries (or hits a non-429 error) is CAUGHT here
|
|
110
|
+
* rather than allowed to throw past the aggregation (QA MAJOR #2): every id in
|
|
111
|
+
* the failed page is recorded as a failure, `aborted` is set, remaining pages
|
|
112
|
+
* are counted in `notAttempted`, and paging stops. This guarantees the caller
|
|
113
|
+
* always receives a structured partial result — earlier pages' real deletions
|
|
114
|
+
* are never lost, and json-mode callers still get their JSON document.
|
|
115
|
+
*/
|
|
116
|
+
export declare function runBulkDeletePaged(ids: string[], deps: Omit<BulkDeleteDeps, 'onRateLimited'> & {
|
|
117
|
+
pagePauseMs?: number;
|
|
118
|
+
onPage?: (pageIndex: number, totalPages: number, result: BulkDeleteResult) => void;
|
|
119
|
+
}): Promise<PagedBulkDeleteResult>;
|
|
120
|
+
/**
|
|
121
|
+
* Page through the caller's memories (optionally filtered) and collect every
|
|
122
|
+
* id. Used by `--all`. Stops when a page returns fewer than the page size.
|
|
123
|
+
*/
|
|
124
|
+
export declare function collectAllMemoryIds(listFn: (params: any) => Promise<any>, filterParams?: Record<string, unknown>, pageSize?: number): Promise<string[]>;
|
|
10
125
|
/**
|
|
11
126
|
* Register memory management commands
|
|
12
127
|
* @param program - Commander program instance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memories.d.ts","sourceRoot":"","sources":["../../src/commands/memories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"memories.d.ts","sourceRoot":"","sources":["../../src/commands/memories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0BpC,qEAAqE;AACrE,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C,mDAAmD;AACnD,eAAO,MAAM,2BAA2B,QAAS,CAAC;AAElD,mDAAmD;AACnD,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,GA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