@memnexus-ai/cli 1.7.236 → 1.7.237
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/memories.d.ts +6 -0
- package/dist/commands/memories.d.ts.map +1 -1
- package/dist/commands/memories.js +72 -2
- package/dist/commands/memories.js.map +1 -1
- package/dist/lib/api-client.d.ts +17 -1
- package/dist/lib/api-client.d.ts.map +1 -1
- package/dist/lib/api-client.js +42 -11
- package/dist/lib/api-client.js.map +1 -1
- package/dist/lib/retry.d.ts +32 -0
- package/dist/lib/retry.d.ts.map +1 -1
- package/dist/lib/retry.js +89 -5
- package/dist/lib/retry.js.map +1 -1
- package/package.json +2 -2
|
@@ -27,6 +27,12 @@ export declare function recordDeletion(guardPath: string, now: number): void;
|
|
|
27
27
|
* happened and how to override.
|
|
28
28
|
*/
|
|
29
29
|
export declare function checkBulkDeleteGuard(guardPath: string, now: number): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* One-line cause for a recall/digest HTTP failure, or null when the status is
|
|
32
|
+
* not one the recall path reports itself (those fall through to handleError).
|
|
33
|
+
* `elapsedMs` covers every attempt, so "after N s" is what the caller waited.
|
|
34
|
+
*/
|
|
35
|
+
export declare function describeRecallFailure(error: unknown, elapsedMs: number): string | null;
|
|
30
36
|
/**
|
|
31
37
|
* Parse the --code-context JSON flag.
|
|
32
38
|
*
|
|
@@ -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;AAYpC,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,YAAY,EACZ,mBAAmB,EACnB,eAAe,EAGf,KAA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AO,GAAG,IAAI,CA0ErE;AAED;;;GAGG;AACH,wBAAgB,kCAAkC,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAsE1E;AA0DD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAgL7D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CA2G7D;AAgLD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CA0J5D;AAkPD;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAkPnE"}
|
|
@@ -41,6 +41,7 @@ exports.getBulkDeleteGuardPath = getBulkDeleteGuardPath;
|
|
|
41
41
|
exports.readDeleteGuardTimestamps = readDeleteGuardTimestamps;
|
|
42
42
|
exports.recordDeletion = recordDeletion;
|
|
43
43
|
exports.checkBulkDeleteGuard = checkBulkDeleteGuard;
|
|
44
|
+
exports.describeRecallFailure = describeRecallFailure;
|
|
44
45
|
exports.parseCodeContextFlag = parseCodeContextFlag;
|
|
45
46
|
exports.parseBatchIds = parseBatchIds;
|
|
46
47
|
exports.isValidIsoDate = isValidIsoDate;
|
|
@@ -196,6 +197,43 @@ const RECALL_MAX_MS = (() => {
|
|
|
196
197
|
// code needs setting.
|
|
197
198
|
const EXIT_FULL_TIMEOUT = 5;
|
|
198
199
|
const EXIT_DEGRADED_RESULT = 6;
|
|
200
|
+
/**
|
|
201
|
+
* One-line cause for a recall/digest HTTP failure, or null when the status is
|
|
202
|
+
* not one the recall path reports itself (those fall through to handleError).
|
|
203
|
+
* `elapsedMs` covers every attempt, so "after N s" is what the caller waited.
|
|
204
|
+
*/
|
|
205
|
+
function describeRecallFailure(error, elapsedMs) {
|
|
206
|
+
const status = (0, retry_1.httpStatus)(error);
|
|
207
|
+
const secs = `${(elapsedMs / 1000).toFixed(1)}s`;
|
|
208
|
+
const rawReason = (0, retry_1.errorBody)(error)?.reason;
|
|
209
|
+
const reason = typeof rawReason === 'string' ? (0, errors_1.sanitizeServerText)(rawReason, 64) : '';
|
|
210
|
+
switch (status) {
|
|
211
|
+
case 503:
|
|
212
|
+
if (reason === 'deadline_exceeded') {
|
|
213
|
+
return (`Recall failed: the server's digest deadline was exceeded after ${secs} ` +
|
|
214
|
+
`(HTTP 503 deadline_exceeded). Not retried: each retry starts another LLM synthesis.`);
|
|
215
|
+
}
|
|
216
|
+
return `Recall failed: the digest service was unavailable after ${secs} (HTTP 503${reason ? ` ${reason}` : ''}). Not retried.`;
|
|
217
|
+
case 500:
|
|
218
|
+
return (`Recall failed: the server errored while generating the digest after ${secs} (HTTP 500). ` +
|
|
219
|
+
`Not retried. A common cause is the LLM provider rate-limiting digest synthesis.`);
|
|
220
|
+
case 429: {
|
|
221
|
+
const hinted = (0, retry_1.getRetryAfterMs)(error);
|
|
222
|
+
const hint = hinted === null
|
|
223
|
+
? // Only the body field is visible: the SDK drops response headers,
|
|
224
|
+
// so a Retry-After HEADER may have been sent and is not seen here.
|
|
225
|
+
'the server sent no retryAfter in the response body'
|
|
226
|
+
: `the server asked to retry after ${Math.round(hinted / 1000)}s`;
|
|
227
|
+
return `Recall failed: rate limited after ${secs} (HTTP 429; ${hint}).`;
|
|
228
|
+
}
|
|
229
|
+
case 502:
|
|
230
|
+
case 504:
|
|
231
|
+
case 408:
|
|
232
|
+
return `Recall failed: gateway/transport error after ${secs} (HTTP ${status}).`;
|
|
233
|
+
default:
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
199
237
|
/** True when an error is the SDK aborting the digest call at the ceiling. */
|
|
200
238
|
function isRecallTimeoutError(error) {
|
|
201
239
|
const e = error;
|
|
@@ -554,6 +592,19 @@ function retryRead(fn) {
|
|
|
554
592
|
onRetry: emitRetryNotice,
|
|
555
593
|
});
|
|
556
594
|
}
|
|
595
|
+
/**
|
|
596
|
+
* Wrap the recall/digest call (POST /api/memories/digest). Every attempt runs a
|
|
597
|
+
* server-side LLM synthesis, so this uses the narrower recall policy — at most
|
|
598
|
+
* one retry, never on 503/500, 429 only with a server Retry-After — instead of
|
|
599
|
+
* retryRead. See withRecallRetry in lib/retry.ts and GH #5570.
|
|
600
|
+
*/
|
|
601
|
+
function retryRecall(fn) {
|
|
602
|
+
return (0, retry_1.withRecallRetry)(fn, {
|
|
603
|
+
sleep: retry_1.sleep,
|
|
604
|
+
maxRetries: retry_1.SINGLE_SHOT_MAX_RETRIES,
|
|
605
|
+
onRetry: emitRetryNotice,
|
|
606
|
+
});
|
|
607
|
+
}
|
|
557
608
|
/**
|
|
558
609
|
* Wrap a non-idempotent single-shot write (plain POST create, non-CAS update).
|
|
559
610
|
* Retries ONLY 429 (server rejected before processing — no duplicate risk);
|
|
@@ -3479,6 +3530,7 @@ function registerDigestCommand(memories) {
|
|
|
3479
3530
|
.option('--show-sources', 'Display source memory IDs')
|
|
3480
3531
|
.option('--format <format>', 'Output format (json|yaml|llm)')
|
|
3481
3532
|
.action(async (options) => {
|
|
3533
|
+
let callStartedAt;
|
|
3482
3534
|
try {
|
|
3483
3535
|
if (!options.query) {
|
|
3484
3536
|
throw (0, errors_1.validationError)('--query is required');
|
|
@@ -3506,13 +3558,16 @@ function registerDigestCommand(memories) {
|
|
|
3506
3558
|
// 30s default to the 180s ceiling. The SDK aborts the fetch via AbortController
|
|
3507
3559
|
// when this elapses (verified in @memnexus-ai/typescript-sdk http client), so
|
|
3508
3560
|
// the call fast-fails instead of hanging (KI-77 client half).
|
|
3509
|
-
|
|
3561
|
+
// Single-attempt transport: the SDK's own retry layer is disabled for this
|
|
3562
|
+
// call so retryRecall is the only retry policy (GH #5570).
|
|
3563
|
+
const sdk = (0, api_client_1.getSingleAttemptSdk)();
|
|
3510
3564
|
const prevTimeout = sdk.config?.timeoutMs ?? 30000;
|
|
3511
3565
|
if (sdk.config)
|
|
3512
3566
|
sdk.config.timeoutMs = RECALL_MAX_MS;
|
|
3513
3567
|
let response;
|
|
3568
|
+
callStartedAt = Date.now();
|
|
3514
3569
|
try {
|
|
3515
|
-
response = await
|
|
3570
|
+
response = await retryRecall(() => sdk.memories.generateMemoryDigest(body));
|
|
3516
3571
|
}
|
|
3517
3572
|
finally {
|
|
3518
3573
|
if (sdk.config)
|
|
@@ -3568,6 +3623,21 @@ function registerDigestCommand(memories) {
|
|
|
3568
3623
|
displayDigest(digest, metadata, sources, options, keyFacts, entities, effectiveStateBreakdown, renderable.health);
|
|
3569
3624
|
}
|
|
3570
3625
|
catch (error) {
|
|
3626
|
+
// GH #5570: name the cause of a server-side failure and point at the
|
|
3627
|
+
// retrieval path that needs no LLM synthesis. Exit 5 is the code
|
|
3628
|
+
// handleError already used for every one of these statuses. Checked
|
|
3629
|
+
// BEFORE the client-ceiling branch: an HTTP 504 carries the message
|
|
3630
|
+
// "HTTP 504: Gateway Timeout", which isRecallTimeoutError would otherwise
|
|
3631
|
+
// misreport as the CLI's own 180s ceiling (same exit code, wrong cause).
|
|
3632
|
+
const cause = callStartedAt === undefined
|
|
3633
|
+
? null
|
|
3634
|
+
: describeRecallFailure(error, Date.now() - callStartedAt);
|
|
3635
|
+
if (cause !== null) {
|
|
3636
|
+
console.error(chalk_1.default.red(`\n❌ ${cause}`));
|
|
3637
|
+
console.error(chalk_1.default.yellow('\n💡 Workaround: retrieve the memories directly, without synthesis:'));
|
|
3638
|
+
console.error(chalk_1.default.yellow(' mx memories search --query "<query>" --id-only | mx memories get --stdin'));
|
|
3639
|
+
process.exit(5);
|
|
3640
|
+
}
|
|
3571
3641
|
// KI-77: name the ceiling and give a narrower-query fix instead of the SDK's
|
|
3572
3642
|
// opaque "operation was aborted" so the user knows what happened and how to recover.
|
|
3573
3643
|
if (isRecallTimeoutError(error)) {
|