memorix 1.6.2 → 1.6.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/CHANGELOG.md +13 -0
- package/dist/cli/index.js +1015 -789
- package/dist/index.js +769 -578
- package/dist/maintenance-runner.js +1061 -1017
- package/dist/media-audio-runner.js +1052 -1009
- package/dist/media-video-runner.js +1052 -1009
- package/dist/memcode-runtime/CHANGELOG.md +13 -0
- package/dist/sdk.js +1393 -1292
- package/dist/vector-backfill-runner.js +1050 -1007
- package/package.json +1 -1
- package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
- package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
- package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
- package/plugins/copilot/memorix/plugin.json +1 -1
- package/plugins/gemini/memorix/gemini-extension.json +1 -1
- package/plugins/omp/memorix/package.json +1 -1
- package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
- package/plugins/pi/memorix/package.json +1 -1
- package/server.json +2 -2
- package/src/cli/commands/background.ts +17 -3
- package/src/cli/commands/operator-shared.ts +12 -8
- package/src/cli/commands/serve-http.ts +25 -7
- package/src/cli/commands/serve-shared.ts +49 -6
- package/src/cli/commands/serve.ts +4 -0
- package/src/memory/session.ts +13 -3
- package/src/project/launch-root.ts +115 -0
- package/src/runtime/isolated-maintenance.ts +12 -1
- package/src/server.ts +38 -5
- package/src/store/obs-store.ts +2 -2
- package/src/store/sqlite-db.ts +2 -0
- package/src/store/sqlite-store.ts +19 -4
package/src/store/obs-store.ts
CHANGED
|
@@ -59,7 +59,7 @@ export interface ObservationStore {
|
|
|
59
59
|
/** Load one project's observations without scanning the shared flat store. */
|
|
60
60
|
loadByProject(
|
|
61
61
|
projectId: string,
|
|
62
|
-
options?: { status?: string; limit?: number; offset?: number; afterId?: number },
|
|
62
|
+
options?: { status?: string; limit?: number; offset?: number; afterId?: number; newestFirst?: boolean },
|
|
63
63
|
): Promise<Observation[]>;
|
|
64
64
|
|
|
65
65
|
/** Count one project's observations without materializing the rows. */
|
|
@@ -231,7 +231,7 @@ export class DegradedBackend implements ObservationStore {
|
|
|
231
231
|
return [];
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
async loadByProject(_projectId: string, _options?: { status?: string; limit?: number; offset?: number; afterId?: number }): Promise<Observation[]> {
|
|
234
|
+
async loadByProject(_projectId: string, _options?: { status?: string; limit?: number; offset?: number; afterId?: number; newestFirst?: boolean }): Promise<Observation[]> {
|
|
235
235
|
return [];
|
|
236
236
|
}
|
|
237
237
|
|
package/src/store/sqlite-db.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { createRequire } from 'node:module';
|
|
|
16
16
|
import path from 'node:path';
|
|
17
17
|
import fs from 'node:fs';
|
|
18
18
|
import { createDatabase, loadSqlite } from './bun-sqlite-compat.js';
|
|
19
|
+
import { assertNotHomeDataDir } from '../project/launch-root.js';
|
|
19
20
|
|
|
20
21
|
// Dynamic require for SQLite (better-sqlite3, node:sqlite, or bun:sqlite)
|
|
21
22
|
let BetterSqlite3: any;
|
|
@@ -998,6 +999,7 @@ const _dbCache = new Map<string, any>();
|
|
|
998
999
|
*/
|
|
999
1000
|
export function getDatabase(dataDir: string): any {
|
|
1000
1001
|
const normalized = path.resolve(dataDir);
|
|
1002
|
+
assertNotHomeDataDir(normalized);
|
|
1001
1003
|
const existing = _dbCache.get(normalized);
|
|
1002
1004
|
if (existing) return existing;
|
|
1003
1005
|
|
|
@@ -122,6 +122,8 @@ export class SqliteBackend implements ObservationStore {
|
|
|
122
122
|
private stmtSelectByProjectStatus: any = null;
|
|
123
123
|
private stmtSelectByProjectAfterId: any = null;
|
|
124
124
|
private stmtSelectByProjectStatusAfterId: any = null;
|
|
125
|
+
private stmtSelectByProjectNewest: any = null;
|
|
126
|
+
private stmtSelectByProjectStatusNewest: any = null;
|
|
125
127
|
private stmtCountByProject: any = null;
|
|
126
128
|
private stmtCountByProjectStatus: any = null;
|
|
127
129
|
private stmtSelectByTopicKey: any = null;
|
|
@@ -175,6 +177,14 @@ export class SqliteBackend implements ObservationStore {
|
|
|
175
177
|
SELECT * FROM observations WHERE projectId = ? AND status = ? AND id > ?
|
|
176
178
|
ORDER BY id ASC LIMIT ?
|
|
177
179
|
`);
|
|
180
|
+
this.stmtSelectByProjectNewest = this.db.prepare(`
|
|
181
|
+
SELECT * FROM observations WHERE projectId = ?
|
|
182
|
+
ORDER BY createdAt DESC, id DESC LIMIT ? OFFSET ?
|
|
183
|
+
`);
|
|
184
|
+
this.stmtSelectByProjectStatusNewest = this.db.prepare(`
|
|
185
|
+
SELECT * FROM observations WHERE projectId = ? AND status = ?
|
|
186
|
+
ORDER BY createdAt DESC, id DESC LIMIT ? OFFSET ?
|
|
187
|
+
`);
|
|
178
188
|
this.stmtCountByProject = this.db.prepare(
|
|
179
189
|
`SELECT COUNT(*) AS count FROM observations WHERE projectId = ?`,
|
|
180
190
|
);
|
|
@@ -288,15 +298,20 @@ export class SqliteBackend implements ObservationStore {
|
|
|
288
298
|
|
|
289
299
|
async loadByProject(
|
|
290
300
|
projectId: string,
|
|
291
|
-
options: { status?: string; limit?: number; offset?: number; afterId?: number } = {},
|
|
301
|
+
options: { status?: string; limit?: number; offset?: number; afterId?: number; newestFirst?: boolean } = {},
|
|
292
302
|
): Promise<Observation[]> {
|
|
293
303
|
const limit = options.limit == null ? -1 : Math.max(1, Math.floor(options.limit));
|
|
294
304
|
const offset = options.offset == null ? 0 : Math.max(0, Math.floor(options.offset));
|
|
295
305
|
const afterId = options.afterId == null ? null : Math.max(0, Math.floor(options.afterId));
|
|
306
|
+
const newestFirst = options.newestFirst === true && afterId === null;
|
|
296
307
|
const rows = afterId === null
|
|
297
|
-
? (
|
|
298
|
-
?
|
|
299
|
-
|
|
308
|
+
? (newestFirst
|
|
309
|
+
? (options.status
|
|
310
|
+
? this.stmtSelectByProjectStatusNewest.all(projectId, options.status, limit, offset)
|
|
311
|
+
: this.stmtSelectByProjectNewest.all(projectId, limit, offset))
|
|
312
|
+
: (options.status
|
|
313
|
+
? this.stmtSelectByProjectStatus.all(projectId, options.status, limit, offset)
|
|
314
|
+
: this.stmtSelectByProject.all(projectId, limit, offset)))
|
|
300
315
|
: (options.status
|
|
301
316
|
? this.stmtSelectByProjectStatusAfterId.all(projectId, options.status, afterId, limit)
|
|
302
317
|
: this.stmtSelectByProjectAfterId.all(projectId, afterId, limit));
|