claude-memory-layer 1.0.36 → 1.0.37
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/cli/index.js +280 -43
- package/dist/cli/index.js.map +2 -2
- package/dist/core/index.js +68 -1
- package/dist/core/index.js.map +2 -2
- package/dist/hooks/post-tool-use.js +71 -1
- package/dist/hooks/post-tool-use.js.map +2 -2
- package/dist/hooks/semantic-daemon.js +71 -1
- package/dist/hooks/semantic-daemon.js.map +2 -2
- package/dist/hooks/session-end.js +71 -1
- package/dist/hooks/session-end.js.map +2 -2
- package/dist/hooks/session-start.js +71 -1
- package/dist/hooks/session-start.js.map +2 -2
- package/dist/hooks/stop.js +71 -1
- package/dist/hooks/stop.js.map +2 -2
- package/dist/hooks/user-prompt-submit.js +71 -1
- package/dist/hooks/user-prompt-submit.js.map +2 -2
- package/dist/index.js +71 -1
- package/dist/index.js.map +2 -2
- package/dist/mcp/index.js +71 -1
- package/dist/mcp/index.js.map +2 -2
- package/dist/server/api/index.js +271 -41
- package/dist/server/api/index.js.map +2 -2
- package/dist/server/index.js +271 -41
- package/dist/server/index.js.map +2 -2
- package/dist/services/memory-service.js +71 -1
- package/dist/services/memory-service.js.map +2 -2
- package/dist/ui/assets/js/chat.js +21 -3
- package/package.json +1 -1
|
@@ -2322,6 +2322,14 @@ function normalizeQueryRewriteKind(value) {
|
|
|
2322
2322
|
return "none";
|
|
2323
2323
|
}
|
|
2324
2324
|
var REWRITTEN_QUERY_REWRITE_KIND_SQL = `LOWER(TRIM(COALESCE(query_rewrite_kind, 'none'))) IN ('follow-up-context', 'intent-rewrite')`;
|
|
2325
|
+
var DEFAULT_OUTBOX_STUCK_THRESHOLD_MS = 5 * 60 * 1e3;
|
|
2326
|
+
var DEFAULT_OUTBOX_MAX_RETRIES = 3;
|
|
2327
|
+
function emptyOutboxRecoveryResult() {
|
|
2328
|
+
return {
|
|
2329
|
+
embedding: { recoveredProcessing: 0, retriedFailed: 0 },
|
|
2330
|
+
vector: { recoveredProcessing: 0, retriedFailed: 0 }
|
|
2331
|
+
};
|
|
2332
|
+
}
|
|
2325
2333
|
var SQLiteEventStore = class {
|
|
2326
2334
|
db;
|
|
2327
2335
|
initialized = false;
|
|
@@ -3072,7 +3080,9 @@ var SQLiteEventStore = class {
|
|
|
3072
3080
|
const placeholders = ids.map(() => "?").join(",");
|
|
3073
3081
|
sqliteRun(
|
|
3074
3082
|
this.db,
|
|
3075
|
-
`UPDATE embedding_outbox
|
|
3083
|
+
`UPDATE embedding_outbox
|
|
3084
|
+
SET status = 'processing', processed_at = datetime('now'), error_message = NULL
|
|
3085
|
+
WHERE id IN (${placeholders})`,
|
|
3076
3086
|
ids
|
|
3077
3087
|
);
|
|
3078
3088
|
return pending.map((row) => ({
|
|
@@ -3142,6 +3152,58 @@ var SQLiteEventStore = class {
|
|
|
3142
3152
|
[error, ...ids]
|
|
3143
3153
|
);
|
|
3144
3154
|
}
|
|
3155
|
+
/**
|
|
3156
|
+
* Recover abandoned outbox work after a worker/process crash.
|
|
3157
|
+
*
|
|
3158
|
+
* Rows in `processing` are claimed work. If the process exits before marking
|
|
3159
|
+
* them done/failed, they otherwise remain invisible to future processing.
|
|
3160
|
+
* Recovery is deliberately age-gated so an active worker is not disturbed.
|
|
3161
|
+
*/
|
|
3162
|
+
async recoverStuckOutboxItems(options = {}) {
|
|
3163
|
+
await this.initialize();
|
|
3164
|
+
const thresholdMs = Number.isFinite(options.stuckThresholdMs) && (options.stuckThresholdMs ?? 0) >= 0 ? options.stuckThresholdMs : DEFAULT_OUTBOX_STUCK_THRESHOLD_MS;
|
|
3165
|
+
const maxRetries = Number.isFinite(options.maxRetries) && (options.maxRetries ?? 0) > 0 ? options.maxRetries : DEFAULT_OUTBOX_MAX_RETRIES;
|
|
3166
|
+
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
3167
|
+
const threshold = new Date(now.getTime() - thresholdMs).toISOString();
|
|
3168
|
+
const result = emptyOutboxRecoveryResult();
|
|
3169
|
+
const embeddingRecovered = sqliteRun(
|
|
3170
|
+
this.db,
|
|
3171
|
+
`UPDATE embedding_outbox
|
|
3172
|
+
SET status = 'pending', processed_at = NULL, error_message = NULL
|
|
3173
|
+
WHERE status = 'processing'
|
|
3174
|
+
AND datetime(COALESCE(processed_at, created_at)) < datetime(?)`,
|
|
3175
|
+
[threshold]
|
|
3176
|
+
);
|
|
3177
|
+
result.embedding.recoveredProcessing = Number(embeddingRecovered.changes ?? 0);
|
|
3178
|
+
const embeddingRetried = sqliteRun(
|
|
3179
|
+
this.db,
|
|
3180
|
+
`UPDATE embedding_outbox
|
|
3181
|
+
SET status = 'pending', error_message = NULL
|
|
3182
|
+
WHERE status = 'failed'
|
|
3183
|
+
AND retry_count < ?`,
|
|
3184
|
+
[maxRetries]
|
|
3185
|
+
);
|
|
3186
|
+
result.embedding.retriedFailed = Number(embeddingRetried.changes ?? 0);
|
|
3187
|
+
const vectorRecovered = sqliteRun(
|
|
3188
|
+
this.db,
|
|
3189
|
+
`UPDATE vector_outbox
|
|
3190
|
+
SET status = 'pending', updated_at = ?, error = NULL
|
|
3191
|
+
WHERE status = 'processing'
|
|
3192
|
+
AND datetime(updated_at) < datetime(?)`,
|
|
3193
|
+
[now.toISOString(), threshold]
|
|
3194
|
+
);
|
|
3195
|
+
result.vector.recoveredProcessing = Number(vectorRecovered.changes ?? 0);
|
|
3196
|
+
const vectorRetried = sqliteRun(
|
|
3197
|
+
this.db,
|
|
3198
|
+
`UPDATE vector_outbox
|
|
3199
|
+
SET status = 'pending', updated_at = ?, error = NULL
|
|
3200
|
+
WHERE status = 'failed'
|
|
3201
|
+
AND retry_count < ?`,
|
|
3202
|
+
[now.toISOString(), maxRetries]
|
|
3203
|
+
);
|
|
3204
|
+
result.vector.retriedFailed = Number(vectorRetried.changes ?? 0);
|
|
3205
|
+
return result;
|
|
3206
|
+
}
|
|
3145
3207
|
/**
|
|
3146
3208
|
* Get embedding/vector outbox health statistics
|
|
3147
3209
|
*/
|
|
@@ -4013,6 +4075,7 @@ var VectorStore = class {
|
|
|
4013
4075
|
* Get total count of vectors
|
|
4014
4076
|
*/
|
|
4015
4077
|
async count() {
|
|
4078
|
+
await this.initialize();
|
|
4016
4079
|
if (!this.table)
|
|
4017
4080
|
return 0;
|
|
4018
4081
|
const result = await this.table.countRows();
|
|
@@ -4451,6 +4514,10 @@ var MemoryQueryService = class {
|
|
|
4451
4514
|
await this.initialize();
|
|
4452
4515
|
return this.getMaintenanceStore("getOutboxStats").getOutboxStats();
|
|
4453
4516
|
}
|
|
4517
|
+
async recoverStuckOutboxItems(options) {
|
|
4518
|
+
await this.initialize();
|
|
4519
|
+
return this.getMaintenanceStore("recoverStuckOutboxItems").recoverStuckOutboxItems(options);
|
|
4520
|
+
}
|
|
4454
4521
|
async getStats() {
|
|
4455
4522
|
await this.initialize();
|
|
4456
4523
|
const deps = this.getStatsDeps();
|
|
@@ -7719,6 +7786,9 @@ var MemoryService = class {
|
|
|
7719
7786
|
async getOutboxStats() {
|
|
7720
7787
|
return this.queryService.getOutboxStats();
|
|
7721
7788
|
}
|
|
7789
|
+
async recoverStuckOutboxItems(options) {
|
|
7790
|
+
return this.queryService.recoverStuckOutboxItems(options);
|
|
7791
|
+
}
|
|
7722
7792
|
async getRetrievalTraceStats() {
|
|
7723
7793
|
return this.retrievalAnalyticsService.getRetrievalTraceStats();
|
|
7724
7794
|
}
|