@hasna/mementos 0.14.62 → 0.14.64
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/commands/agent.d.ts.map +1 -1
- package/dist/cli/commands/system-doctor.d.ts.map +1 -1
- package/dist/cli/helpers.d.ts.map +1 -1
- package/dist/cli/index.js +184 -13
- package/dist/db/memories.d.ts.map +1 -1
- package/dist/index.js +47 -3
- package/dist/lib/consolidation.d.ts.map +1 -1
- package/dist/lib/reflection.d.ts.map +1 -1
- package/dist/mcp/index.js +48 -4
- package/dist/server/index.js +58 -7
- package/dist/server/router.d.ts.map +1 -1
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +15 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgBzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkN5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-doctor.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/system-doctor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"system-doctor.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/system-doctor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2CzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAwP5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/cli/helpers.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EACV,MAAM,EACN,cAAc,EACd,WAAW,EAEZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAM5D,wBAAgB,iBAAiB,IAAI,MAAM,CAe1C;AAsBD,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAKzE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAErD;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAE9D;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE1D;AAaD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/cli/helpers.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EACV,MAAM,EACN,cAAc,EACd,WAAW,EAEZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAM5D,wBAAgB,iBAAiB,IAAI,MAAM,CAe1C;AAsBD,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAKzE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE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AC;AACvE,eAAO,MAAM,gBAAgB,UAAiD,CAAC;AAE/E,2DAA2D;AAC3D,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAQlF;AAED,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAW/F;AAED,sDAAsD;AACtD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAShF;AAED,yFAAyF;AACzF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAMrD;AAED,iEAAiE;AACjE,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CA0C1G;AAED,wBAAgB,aAAa,IAAI,MAAM,CAGtC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASxD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAMnE"}
|
package/dist/cli/index.js
CHANGED
|
@@ -2181,6 +2181,7 @@ function translateSql(sql) {
|
|
|
2181
2181
|
const op = parsed < 0 ? "-" : "+";
|
|
2182
2182
|
return `to_char((now() ${op} INTERVAL '${absolute} ${pluralUnit}') AT TIME ZONE 'UTC', ${ISO_FMT})`;
|
|
2183
2183
|
});
|
|
2184
|
+
translated = translated.replace(/COALESCE\s*\(\s*accessed_at\s*,\s*created_at\s*\)/gi, `COALESCE(accessed_at, to_char(created_at AT TIME ZONE 'UTC', ${ISO_FMT}))`);
|
|
2184
2185
|
translated = translated.replace(/lower\s*\(\s*hex\s*\(\s*randomblob\s*\(\s*\d+\s*\)\s*\)\s*\)/gi, "gen_random_uuid()::text");
|
|
2185
2186
|
translated = translated.replace(/\bIFNULL\s*\(/gi, "COALESCE(");
|
|
2186
2187
|
translated = translated.replace(/\bINSTR\s*\(/gi, "STRPOS(");
|
|
@@ -2190,8 +2191,20 @@ function translateSql(sql) {
|
|
|
2190
2191
|
}
|
|
2191
2192
|
translated = translated.replace(/INSERT\s+OR\s+REPLACE\s+INTO/gi, "INSERT INTO");
|
|
2192
2193
|
translated = translated.replace(/COALESCE\s*\(\s*pinned\s*,\s*0\s*\)/gi, "COALESCE(pinned, FALSE)");
|
|
2193
|
-
|
|
2194
|
-
|
|
2194
|
+
const BOOLEAN_COLUMNS = [
|
|
2195
|
+
"pinned",
|
|
2196
|
+
"success",
|
|
2197
|
+
"is_primary",
|
|
2198
|
+
"blocking",
|
|
2199
|
+
"enabled",
|
|
2200
|
+
"useful",
|
|
2201
|
+
"dry_run",
|
|
2202
|
+
"applied"
|
|
2203
|
+
];
|
|
2204
|
+
for (const col of BOOLEAN_COLUMNS) {
|
|
2205
|
+
translated = translated.replace(new RegExp(`\\b${col}\\s*=\\s*1\\b`, "gi"), `${col} = TRUE`);
|
|
2206
|
+
translated = translated.replace(new RegExp(`\\b${col}\\s*=\\s*0\\b`, "gi"), `${col} = FALSE`);
|
|
2207
|
+
}
|
|
2195
2208
|
return translated;
|
|
2196
2209
|
}
|
|
2197
2210
|
function shouldUsePgSsl(connectionString) {
|
|
@@ -4670,7 +4683,8 @@ function getMemory(id, db) {
|
|
|
4670
4683
|
return status === 404 ? null : data ?? null;
|
|
4671
4684
|
}
|
|
4672
4685
|
const d = db || getDatabase();
|
|
4673
|
-
const
|
|
4686
|
+
const resolvedId = resolvePartialId(d, "memories", id) ?? id;
|
|
4687
|
+
const row = d.query("SELECT * FROM memories WHERE id = ?").get(resolvedId);
|
|
4674
4688
|
if (!row)
|
|
4675
4689
|
return null;
|
|
4676
4690
|
return parseMemoryRow(row);
|
|
@@ -5603,6 +5617,14 @@ function resolveEntityArg(nameOrId, type) {
|
|
|
5603
5617
|
const byName = getEntityByName(nameOrId, type);
|
|
5604
5618
|
if (byName)
|
|
5605
5619
|
return byName;
|
|
5620
|
+
if (isApiMode()) {
|
|
5621
|
+
try {
|
|
5622
|
+
return getEntity(nameOrId);
|
|
5623
|
+
} catch {
|
|
5624
|
+
console.error(chalk.red(`Entity not found: ${nameOrId}`));
|
|
5625
|
+
process.exit(1);
|
|
5626
|
+
}
|
|
5627
|
+
}
|
|
5606
5628
|
const db = getDatabase();
|
|
5607
5629
|
const id = resolvePartialId(db, "entities", nameOrId);
|
|
5608
5630
|
if (id)
|
|
@@ -62471,6 +62493,7 @@ function registerIoCommands(program2) {
|
|
|
62471
62493
|
|
|
62472
62494
|
// src/cli/commands/agent.ts
|
|
62473
62495
|
init_agents();
|
|
62496
|
+
init_projects();
|
|
62474
62497
|
import chalk22 from "chalk";
|
|
62475
62498
|
|
|
62476
62499
|
// src/lib/focus.ts
|
|
@@ -62625,18 +62648,28 @@ function registerAgentCommands(program2) {
|
|
|
62625
62648
|
console.log(chalk22.green(`\u2665 ${agent.name} (${agent.id}) \u2014 heartbeat sent`));
|
|
62626
62649
|
});
|
|
62627
62650
|
program2.command("set-focus [project]").description("Focus this agent on a project (or clear focus if no project given)").option("--agent <id>", "Agent ID").action((project, opts) => {
|
|
62628
|
-
|
|
62629
|
-
|
|
62630
|
-
|
|
62631
|
-
|
|
62651
|
+
try {
|
|
62652
|
+
const globalOpts = program2.opts();
|
|
62653
|
+
const agentId = opts?.agent || globalOpts.agent;
|
|
62654
|
+
if (!agentId) {
|
|
62655
|
+
process.stderr.write(`Agent ID required. Use --agent.
|
|
62632
62656
|
`);
|
|
62633
|
-
|
|
62657
|
+
process.exit(1);
|
|
62658
|
+
}
|
|
62659
|
+
let target = project ?? null;
|
|
62660
|
+
if (project) {
|
|
62661
|
+
const proj = getProject(project);
|
|
62662
|
+
if (proj)
|
|
62663
|
+
target = proj.id;
|
|
62664
|
+
}
|
|
62665
|
+
setFocus(agentId, target);
|
|
62666
|
+
if (project)
|
|
62667
|
+
console.log(chalk22.green(`Focused: ${agentId} \u2192 project ${project}`));
|
|
62668
|
+
else
|
|
62669
|
+
console.log(chalk22.dim(`Focus cleared for ${agentId}`));
|
|
62670
|
+
} catch (e) {
|
|
62671
|
+
handleError(e);
|
|
62634
62672
|
}
|
|
62635
|
-
setFocus(agentId, project ?? null);
|
|
62636
|
-
if (project)
|
|
62637
|
-
console.log(chalk22.green(`Focused: ${agentId} \u2192 project ${project}`));
|
|
62638
|
-
else
|
|
62639
|
-
console.log(chalk22.dim(`Focus cleared for ${agentId}`));
|
|
62640
62673
|
});
|
|
62641
62674
|
program2.command("get-focus").description("Show the current project focus for an agent").option("--agent <id>", "Agent ID").action((opts) => {
|
|
62642
62675
|
const globalOpts = program2.opts();
|
|
@@ -63530,6 +63563,7 @@ import {
|
|
|
63530
63563
|
statSync as statSync3,
|
|
63531
63564
|
constants as fsConstants
|
|
63532
63565
|
} from "fs";
|
|
63566
|
+
init_api_mode();
|
|
63533
63567
|
init_helpers();
|
|
63534
63568
|
async function runCommandWithTimeout(args, timeoutMs) {
|
|
63535
63569
|
const proc = Bun.spawn(args, { stdout: "pipe", stderr: "pipe" });
|
|
@@ -63551,6 +63585,10 @@ function registerDoctorCommand(program2) {
|
|
|
63551
63585
|
program2.command("doctor").description("Diagnose common issues with the mementos installation").action(async () => {
|
|
63552
63586
|
const globalOpts = program2.opts();
|
|
63553
63587
|
const checks = [];
|
|
63588
|
+
if (isApiMode()) {
|
|
63589
|
+
await runCloudDoctor(globalOpts, checks);
|
|
63590
|
+
return;
|
|
63591
|
+
}
|
|
63554
63592
|
const version = getPackageVersion();
|
|
63555
63593
|
checks.push({ name: "Version", status: "ok", detail: version });
|
|
63556
63594
|
const dbPath = getDbPath();
|
|
@@ -63737,6 +63775,109 @@ function registerDoctorCommand(program2) {
|
|
|
63737
63775
|
outputDoctorResults(globalOpts, checks);
|
|
63738
63776
|
});
|
|
63739
63777
|
}
|
|
63778
|
+
async function runCloudDoctor(globalOpts, checks) {
|
|
63779
|
+
checks.push({ name: "Version", status: "ok", detail: getPackageVersion() });
|
|
63780
|
+
const cfg = getApiConfig();
|
|
63781
|
+
checks.push({
|
|
63782
|
+
name: "Storage mode",
|
|
63783
|
+
status: "ok",
|
|
63784
|
+
detail: `self-hosted API (${cfg?.baseUrl ?? "unknown endpoint"})`
|
|
63785
|
+
});
|
|
63786
|
+
let healthy = false;
|
|
63787
|
+
try {
|
|
63788
|
+
const { status, data } = apiJson("GET", "/health");
|
|
63789
|
+
healthy = status >= 200 && status < 300 && !!data;
|
|
63790
|
+
if (healthy && data) {
|
|
63791
|
+
const serverStatus = data.status === "warn" ? "warn" : "ok";
|
|
63792
|
+
checks.push({
|
|
63793
|
+
name: "Cloud connection",
|
|
63794
|
+
status: serverStatus,
|
|
63795
|
+
detail: `reachable \u2014 server v${data.version ?? "?"} (${data.status ?? "ok"})`
|
|
63796
|
+
});
|
|
63797
|
+
const total = data.memories?.total ?? 0;
|
|
63798
|
+
const expired = data.memories?.expired ?? 0;
|
|
63799
|
+
checks.push({ name: "Memories", status: "ok", detail: `${total} total` });
|
|
63800
|
+
checks.push({
|
|
63801
|
+
name: " Expired",
|
|
63802
|
+
status: expired > 10 ? "warn" : "ok",
|
|
63803
|
+
detail: expired > 10 ? `${expired} (run 'mementos clean' to remove)` : String(expired)
|
|
63804
|
+
});
|
|
63805
|
+
checks.push({ name: "Agents", status: "ok", detail: String(data.agents ?? 0) });
|
|
63806
|
+
checks.push({ name: "Projects", status: "ok", detail: String(data.projects ?? 0) });
|
|
63807
|
+
} else {
|
|
63808
|
+
checks.push({ name: "Cloud connection", status: "fail", detail: "health endpoint returned no data" });
|
|
63809
|
+
}
|
|
63810
|
+
} catch (e) {
|
|
63811
|
+
checks.push({
|
|
63812
|
+
name: "Cloud connection",
|
|
63813
|
+
status: "fail",
|
|
63814
|
+
detail: e instanceof Error ? e.message : String(e)
|
|
63815
|
+
});
|
|
63816
|
+
}
|
|
63817
|
+
try {
|
|
63818
|
+
loadConfig();
|
|
63819
|
+
checks.push({ name: "Config", status: "ok", detail: "valid" });
|
|
63820
|
+
} catch (e) {
|
|
63821
|
+
checks.push({ name: "Config", status: "fail", detail: e instanceof Error ? e.message : String(e) });
|
|
63822
|
+
}
|
|
63823
|
+
try {
|
|
63824
|
+
const activeProfile = getActiveProfile();
|
|
63825
|
+
const profiles = listProfiles();
|
|
63826
|
+
checks.push({
|
|
63827
|
+
name: "Active profile",
|
|
63828
|
+
status: "ok",
|
|
63829
|
+
detail: activeProfile ? `${activeProfile} (${profiles.length} total)` : `default \u2014 ${profiles.length} profile(s) available`
|
|
63830
|
+
});
|
|
63831
|
+
} catch (e) {
|
|
63832
|
+
checks.push({ name: "Active profile", status: "warn", detail: e instanceof Error ? e.message : String(e) });
|
|
63833
|
+
}
|
|
63834
|
+
try {
|
|
63835
|
+
const { stdout: mcpOut, exitCode: mcpExit, timedOut } = await runCommandWithTimeout(["claude", "mcp", "list"], 1500);
|
|
63836
|
+
if (timedOut) {
|
|
63837
|
+
checks.push({ name: "MCP server", status: "warn", detail: "health check timed out" });
|
|
63838
|
+
} else if (mcpExit === 0 && mcpOut.includes("mementos")) {
|
|
63839
|
+
checks.push({ name: "MCP server", status: "ok", detail: "registered with Claude Code" });
|
|
63840
|
+
} else if (mcpExit !== 0) {
|
|
63841
|
+
checks.push({ name: "MCP server", status: "warn", detail: "claude not installed or not accessible" });
|
|
63842
|
+
} else {
|
|
63843
|
+
checks.push({ name: "MCP server", status: "warn", detail: "not registered \u2192 run: mementos init" });
|
|
63844
|
+
}
|
|
63845
|
+
} catch {
|
|
63846
|
+
checks.push({ name: "MCP server", status: "warn", detail: "could not check (is claude CLI installed?)" });
|
|
63847
|
+
}
|
|
63848
|
+
try {
|
|
63849
|
+
const settingsFilePath = join7(homedir4(), ".claude", "settings.json");
|
|
63850
|
+
if (existsSync7(settingsFilePath)) {
|
|
63851
|
+
const settings = JSON.parse(readFileSync5(settingsFilePath, "utf-8"));
|
|
63852
|
+
const hooksObj = settings["hooks"] || {};
|
|
63853
|
+
const stopHooks = hooksObj["Stop"] || [];
|
|
63854
|
+
const hasMementos = stopHooks.some((e) => e.hooks?.some((h) => h.command && h.command.includes("mementos")));
|
|
63855
|
+
checks.push({
|
|
63856
|
+
name: "Stop hook",
|
|
63857
|
+
status: hasMementos ? "ok" : "warn",
|
|
63858
|
+
detail: hasMementos ? "installed (sessions \u2192 memories)" : "not installed \u2192 run: mementos init"
|
|
63859
|
+
});
|
|
63860
|
+
} else {
|
|
63861
|
+
checks.push({ name: "Stop hook", status: "warn", detail: "~/.claude/settings.json not found \u2192 run: mementos init" });
|
|
63862
|
+
}
|
|
63863
|
+
} catch {
|
|
63864
|
+
checks.push({ name: "Stop hook", status: "warn", detail: "could not check stop hook" });
|
|
63865
|
+
}
|
|
63866
|
+
if (process.platform === "darwin") {
|
|
63867
|
+
const plistFilePath = join7(homedir4(), "Library", "LaunchAgents", "com.hasna.mementos.plist");
|
|
63868
|
+
checks.push({
|
|
63869
|
+
name: "Auto-start",
|
|
63870
|
+
status: existsSync7(plistFilePath) ? "ok" : "warn",
|
|
63871
|
+
detail: existsSync7(plistFilePath) ? "configured (starts on login)" : "not configured \u2192 run: mementos init"
|
|
63872
|
+
});
|
|
63873
|
+
} else {
|
|
63874
|
+
checks.push({ name: "Auto-start", status: "ok", detail: `n/a on ${process.platform}` });
|
|
63875
|
+
}
|
|
63876
|
+
outputDoctorResults(globalOpts, checks);
|
|
63877
|
+
if (checks.some((c) => c.status === "fail")) {
|
|
63878
|
+
process.exitCode = 1;
|
|
63879
|
+
}
|
|
63880
|
+
}
|
|
63740
63881
|
function outputDoctorResults(globalOpts, checks) {
|
|
63741
63882
|
if (globalOpts.json) {
|
|
63742
63883
|
outputJson({ checks, healthy: checks.every((c) => c.status === "ok") });
|
|
@@ -65795,6 +65936,7 @@ import { resolve as resolve21 } from "path";
|
|
|
65795
65936
|
|
|
65796
65937
|
// src/lib/consolidation.ts
|
|
65797
65938
|
init_database();
|
|
65939
|
+
init_api_mode();
|
|
65798
65940
|
init_memories();
|
|
65799
65941
|
|
|
65800
65942
|
// src/db/memory-links.ts
|
|
@@ -66287,6 +66429,19 @@ function buildSummary2(actions) {
|
|
|
66287
66429
|
};
|
|
66288
66430
|
}
|
|
66289
66431
|
async function runConsolidation(options = {}) {
|
|
66432
|
+
if (!options.db && isApiMode()) {
|
|
66433
|
+
const { data } = apiJson("POST", "/consolidate", {
|
|
66434
|
+
dry_run: options.dryRun ?? false,
|
|
66435
|
+
scope: options.scope,
|
|
66436
|
+
project_id: options.projectId,
|
|
66437
|
+
agent_id: options.agentId,
|
|
66438
|
+
duplicate_threshold: options.duplicateThreshold,
|
|
66439
|
+
stale_days: options.staleDays,
|
|
66440
|
+
decay_threshold: options.decayThreshold,
|
|
66441
|
+
limit: options.limit
|
|
66442
|
+
});
|
|
66443
|
+
return data;
|
|
66444
|
+
}
|
|
66290
66445
|
const db = options.db || getDatabase();
|
|
66291
66446
|
const dryRun = options.dryRun ?? false;
|
|
66292
66447
|
let run = createRun({ ...options, dryRun }, db);
|
|
@@ -66330,6 +66485,7 @@ async function runConsolidation(options = {}) {
|
|
|
66330
66485
|
// src/lib/reflection.ts
|
|
66331
66486
|
init_zod();
|
|
66332
66487
|
init_database();
|
|
66488
|
+
init_api_mode();
|
|
66333
66489
|
init_memories();
|
|
66334
66490
|
var DEFAULT_REFLECTION_PROVIDER = "anthropic";
|
|
66335
66491
|
var DEFAULT_REFLECTION_MODEL = "claude-fable-5";
|
|
@@ -66682,6 +66838,21 @@ Return concise lessons. Each lesson must be actionable, evidence-backed, and use
|
|
|
66682
66838
|
};
|
|
66683
66839
|
}
|
|
66684
66840
|
async function reflectOnTrajectory(options) {
|
|
66841
|
+
if (!options.db && isApiMode()) {
|
|
66842
|
+
const { data } = apiJson("POST", "/reflect", {
|
|
66843
|
+
on: options.on,
|
|
66844
|
+
source: options.source,
|
|
66845
|
+
dry_run: options.dryRun ?? false,
|
|
66846
|
+
project_id: options.projectId,
|
|
66847
|
+
agent_id: options.agentId,
|
|
66848
|
+
since: options.since,
|
|
66849
|
+
until: options.until,
|
|
66850
|
+
provider: options.provider,
|
|
66851
|
+
model: options.model,
|
|
66852
|
+
max_tokens: options.maxTokens
|
|
66853
|
+
});
|
|
66854
|
+
return data;
|
|
66855
|
+
}
|
|
66685
66856
|
const db = options.db || getDatabase();
|
|
66686
66857
|
const dryRun = options.dryRun ?? false;
|
|
66687
66858
|
const provider = options.provider ?? process.env["MEMENTOS_REFLECT_PROVIDER"] ?? DEFAULT_REFLECTION_PROVIDER;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memories.d.ts","sourceRoot":"","sources":["../../src/db/memories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,MAAM,EACN,YAAY,EACZ,aAAa,EACb,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAsD3B,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAqCnE;AAMD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,iBAAiB,EACxB,UAAU,GAAE,UAAoB,EAChC,EAAE,CAAC,EAAE,QAAQ,GACZ,MAAM,CAqNR;AAMD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO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,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAcvG;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IACP,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;CACpB,EACN,EAAE,CAAC,EAAE,QAAQ,GACZ,OAAO,CAAC,oBAAoB,EAAE,CAAC,CA4DjC"}
|
package/dist/index.js
CHANGED
|
@@ -131,6 +131,7 @@ function translateSql(sql) {
|
|
|
131
131
|
const op = parsed < 0 ? "-" : "+";
|
|
132
132
|
return `to_char((now() ${op} INTERVAL '${absolute} ${pluralUnit}') AT TIME ZONE 'UTC', ${ISO_FMT})`;
|
|
133
133
|
});
|
|
134
|
+
translated = translated.replace(/COALESCE\s*\(\s*accessed_at\s*,\s*created_at\s*\)/gi, `COALESCE(accessed_at, to_char(created_at AT TIME ZONE 'UTC', ${ISO_FMT}))`);
|
|
134
135
|
translated = translated.replace(/lower\s*\(\s*hex\s*\(\s*randomblob\s*\(\s*\d+\s*\)\s*\)\s*\)/gi, "gen_random_uuid()::text");
|
|
135
136
|
translated = translated.replace(/\bIFNULL\s*\(/gi, "COALESCE(");
|
|
136
137
|
translated = translated.replace(/\bINSTR\s*\(/gi, "STRPOS(");
|
|
@@ -140,8 +141,20 @@ function translateSql(sql) {
|
|
|
140
141
|
}
|
|
141
142
|
translated = translated.replace(/INSERT\s+OR\s+REPLACE\s+INTO/gi, "INSERT INTO");
|
|
142
143
|
translated = translated.replace(/COALESCE\s*\(\s*pinned\s*,\s*0\s*\)/gi, "COALESCE(pinned, FALSE)");
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
const BOOLEAN_COLUMNS = [
|
|
145
|
+
"pinned",
|
|
146
|
+
"success",
|
|
147
|
+
"is_primary",
|
|
148
|
+
"blocking",
|
|
149
|
+
"enabled",
|
|
150
|
+
"useful",
|
|
151
|
+
"dry_run",
|
|
152
|
+
"applied"
|
|
153
|
+
];
|
|
154
|
+
for (const col of BOOLEAN_COLUMNS) {
|
|
155
|
+
translated = translated.replace(new RegExp(`\\b${col}\\s*=\\s*1\\b`, "gi"), `${col} = TRUE`);
|
|
156
|
+
translated = translated.replace(new RegExp(`\\b${col}\\s*=\\s*0\\b`, "gi"), `${col} = FALSE`);
|
|
157
|
+
}
|
|
145
158
|
return translated;
|
|
146
159
|
}
|
|
147
160
|
function shouldUsePgSsl(connectionString) {
|
|
@@ -50239,7 +50252,8 @@ function getMemory(id, db) {
|
|
|
50239
50252
|
return status === 404 ? null : data ?? null;
|
|
50240
50253
|
}
|
|
50241
50254
|
const d = db || getDatabase();
|
|
50242
|
-
const
|
|
50255
|
+
const resolvedId = resolvePartialId(d, "memories", id) ?? id;
|
|
50256
|
+
const row = d.query("SELECT * FROM memories WHERE id = ?").get(resolvedId);
|
|
50243
50257
|
if (!row)
|
|
50244
50258
|
return null;
|
|
50245
50259
|
return parseMemoryRow(row);
|
|
@@ -54409,6 +54423,7 @@ function jaccardSimilarity(a, b) {
|
|
|
54409
54423
|
}
|
|
54410
54424
|
// src/lib/consolidation.ts
|
|
54411
54425
|
init_database();
|
|
54426
|
+
init_api_mode();
|
|
54412
54427
|
var STOP_WORDS2 = new Set([
|
|
54413
54428
|
"about",
|
|
54414
54429
|
"after",
|
|
@@ -54862,6 +54877,19 @@ function buildSummary(actions) {
|
|
|
54862
54877
|
};
|
|
54863
54878
|
}
|
|
54864
54879
|
async function runConsolidation(options = {}) {
|
|
54880
|
+
if (!options.db && isApiMode()) {
|
|
54881
|
+
const { data } = apiJson("POST", "/consolidate", {
|
|
54882
|
+
dry_run: options.dryRun ?? false,
|
|
54883
|
+
scope: options.scope,
|
|
54884
|
+
project_id: options.projectId,
|
|
54885
|
+
agent_id: options.agentId,
|
|
54886
|
+
duplicate_threshold: options.duplicateThreshold,
|
|
54887
|
+
stale_days: options.staleDays,
|
|
54888
|
+
decay_threshold: options.decayThreshold,
|
|
54889
|
+
limit: options.limit
|
|
54890
|
+
});
|
|
54891
|
+
return data;
|
|
54892
|
+
}
|
|
54865
54893
|
const db = options.db || getDatabase();
|
|
54866
54894
|
const dryRun = options.dryRun ?? false;
|
|
54867
54895
|
let run = createRun({ ...options, dryRun }, db);
|
|
@@ -54904,6 +54932,7 @@ async function runConsolidation(options = {}) {
|
|
|
54904
54932
|
// src/lib/reflection.ts
|
|
54905
54933
|
init_zod();
|
|
54906
54934
|
init_database();
|
|
54935
|
+
init_api_mode();
|
|
54907
54936
|
var DEFAULT_REFLECTION_PROVIDER = "anthropic";
|
|
54908
54937
|
var DEFAULT_REFLECTION_MODEL = "claude-fable-5";
|
|
54909
54938
|
var CriticSchema = exports_external.object({
|
|
@@ -55255,6 +55284,21 @@ Return concise lessons. Each lesson must be actionable, evidence-backed, and use
|
|
|
55255
55284
|
};
|
|
55256
55285
|
}
|
|
55257
55286
|
async function reflectOnTrajectory(options) {
|
|
55287
|
+
if (!options.db && isApiMode()) {
|
|
55288
|
+
const { data } = apiJson("POST", "/reflect", {
|
|
55289
|
+
on: options.on,
|
|
55290
|
+
source: options.source,
|
|
55291
|
+
dry_run: options.dryRun ?? false,
|
|
55292
|
+
project_id: options.projectId,
|
|
55293
|
+
agent_id: options.agentId,
|
|
55294
|
+
since: options.since,
|
|
55295
|
+
until: options.until,
|
|
55296
|
+
provider: options.provider,
|
|
55297
|
+
model: options.model,
|
|
55298
|
+
max_tokens: options.maxTokens
|
|
55299
|
+
});
|
|
55300
|
+
return data;
|
|
55301
|
+
}
|
|
55258
55302
|
const db = options.db || getDatabase();
|
|
55259
55303
|
const dryRun = options.dryRun ?? false;
|
|
55260
55304
|
const provider = options.provider ?? process.env["MEMENTOS_REFLECT_PROVIDER"] ?? DEFAULT_REFLECTION_PROVIDER;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consolidation.d.ts","sourceRoot":"","sources":["../../src/lib/consolidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAU,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"consolidation.d.ts","sourceRoot":"","sources":["../../src/lib/consolidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAU,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAS7D,MAAM,MAAM,uBAAuB,GAC/B,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,GACnB,cAAc,CAAC;AAEnB,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IACvD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,uBAAuB,CAAC;IAC9B,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,EAAE,MAAM,GAAG,IAA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,OAAO,CAAC;IAChB,UAAU,EAAE;QACV,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,cAAc,EAAE,MAAM,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AA0SD,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,oBAAoB,GAAG,sBAAsB,CAoClG;AA+BD,wBAAgB,2BAA2B,CAAC,OAAO,GAAE;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,gBAAgB,CAsCxB;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA0E/F"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -216,6 +216,7 @@ function translateSql(sql) {
|
|
|
216
216
|
const op = parsed < 0 ? "-" : "+";
|
|
217
217
|
return `to_char((now() ${op} INTERVAL '${absolute} ${pluralUnit}') AT TIME ZONE 'UTC', ${ISO_FMT})`;
|
|
218
218
|
});
|
|
219
|
+
translated = translated.replace(/COALESCE\s*\(\s*accessed_at\s*,\s*created_at\s*\)/gi, `COALESCE(accessed_at, to_char(created_at AT TIME ZONE 'UTC', ${ISO_FMT}))`);
|
|
219
220
|
translated = translated.replace(/lower\s*\(\s*hex\s*\(\s*randomblob\s*\(\s*\d+\s*\)\s*\)\s*\)/gi, "gen_random_uuid()::text");
|
|
220
221
|
translated = translated.replace(/\bIFNULL\s*\(/gi, "COALESCE(");
|
|
221
222
|
translated = translated.replace(/\bINSTR\s*\(/gi, "STRPOS(");
|
|
@@ -225,8 +226,20 @@ function translateSql(sql) {
|
|
|
225
226
|
}
|
|
226
227
|
translated = translated.replace(/INSERT\s+OR\s+REPLACE\s+INTO/gi, "INSERT INTO");
|
|
227
228
|
translated = translated.replace(/COALESCE\s*\(\s*pinned\s*,\s*0\s*\)/gi, "COALESCE(pinned, FALSE)");
|
|
228
|
-
|
|
229
|
-
|
|
229
|
+
const BOOLEAN_COLUMNS = [
|
|
230
|
+
"pinned",
|
|
231
|
+
"success",
|
|
232
|
+
"is_primary",
|
|
233
|
+
"blocking",
|
|
234
|
+
"enabled",
|
|
235
|
+
"useful",
|
|
236
|
+
"dry_run",
|
|
237
|
+
"applied"
|
|
238
|
+
];
|
|
239
|
+
for (const col of BOOLEAN_COLUMNS) {
|
|
240
|
+
translated = translated.replace(new RegExp(`\\b${col}\\s*=\\s*1\\b`, "gi"), `${col} = TRUE`);
|
|
241
|
+
translated = translated.replace(new RegExp(`\\b${col}\\s*=\\s*0\\b`, "gi"), `${col} = FALSE`);
|
|
242
|
+
}
|
|
230
243
|
return translated;
|
|
231
244
|
}
|
|
232
245
|
function shouldUsePgSsl(connectionString) {
|
|
@@ -2671,7 +2684,8 @@ function getMemory(id, db) {
|
|
|
2671
2684
|
return status === 404 ? null : data ?? null;
|
|
2672
2685
|
}
|
|
2673
2686
|
const d = db || getDatabase();
|
|
2674
|
-
const
|
|
2687
|
+
const resolvedId = resolvePartialId(d, "memories", id) ?? id;
|
|
2688
|
+
const row = d.query("SELECT * FROM memories WHERE id = ?").get(resolvedId);
|
|
2675
2689
|
if (!row)
|
|
2676
2690
|
return null;
|
|
2677
2691
|
return parseMemoryRow(row);
|
|
@@ -58150,7 +58164,7 @@ function getMemoryHealth(filter = {}, db) {
|
|
|
58150
58164
|
ORDER BY importance DESC, COALESCE(accessed_at, created_at) ASC LIMIT ?`).all(...scopeParams, forgottenCutoff, limit);
|
|
58151
58165
|
const dupes = d.prepare(`SELECT key, COUNT(*) as cnt, MAX(updated_at) as latest, MIN(created_at) as oldest
|
|
58152
58166
|
FROM memories WHERE ${base}
|
|
58153
|
-
GROUP BY key HAVING
|
|
58167
|
+
GROUP BY key HAVING COUNT(*) > 1
|
|
58154
58168
|
ORDER BY cnt DESC LIMIT ?`).all(...scopeParams, limit);
|
|
58155
58169
|
return { stale, forgotten, dupes };
|
|
58156
58170
|
}
|
|
@@ -64833,6 +64847,7 @@ init_zod();
|
|
|
64833
64847
|
|
|
64834
64848
|
// src/lib/consolidation.ts
|
|
64835
64849
|
init_database();
|
|
64850
|
+
init_api_mode();
|
|
64836
64851
|
init_memories();
|
|
64837
64852
|
|
|
64838
64853
|
// src/db/memory-links.ts
|
|
@@ -65325,6 +65340,19 @@ function buildSummary2(actions) {
|
|
|
65325
65340
|
};
|
|
65326
65341
|
}
|
|
65327
65342
|
async function runConsolidation(options = {}) {
|
|
65343
|
+
if (!options.db && isApiMode()) {
|
|
65344
|
+
const { data } = apiJson("POST", "/consolidate", {
|
|
65345
|
+
dry_run: options.dryRun ?? false,
|
|
65346
|
+
scope: options.scope,
|
|
65347
|
+
project_id: options.projectId,
|
|
65348
|
+
agent_id: options.agentId,
|
|
65349
|
+
duplicate_threshold: options.duplicateThreshold,
|
|
65350
|
+
stale_days: options.staleDays,
|
|
65351
|
+
decay_threshold: options.decayThreshold,
|
|
65352
|
+
limit: options.limit
|
|
65353
|
+
});
|
|
65354
|
+
return data;
|
|
65355
|
+
}
|
|
65328
65356
|
const db = options.db || getDatabase();
|
|
65329
65357
|
const dryRun = options.dryRun ?? false;
|
|
65330
65358
|
let run = createRun({ ...options, dryRun }, db);
|
|
@@ -65368,6 +65396,7 @@ async function runConsolidation(options = {}) {
|
|
|
65368
65396
|
// src/lib/reflection.ts
|
|
65369
65397
|
init_zod();
|
|
65370
65398
|
init_database();
|
|
65399
|
+
init_api_mode();
|
|
65371
65400
|
init_memories();
|
|
65372
65401
|
var DEFAULT_REFLECTION_PROVIDER = "anthropic";
|
|
65373
65402
|
var DEFAULT_REFLECTION_MODEL = "claude-fable-5";
|
|
@@ -65720,6 +65749,21 @@ Return concise lessons. Each lesson must be actionable, evidence-backed, and use
|
|
|
65720
65749
|
};
|
|
65721
65750
|
}
|
|
65722
65751
|
async function reflectOnTrajectory(options) {
|
|
65752
|
+
if (!options.db && isApiMode()) {
|
|
65753
|
+
const { data } = apiJson("POST", "/reflect", {
|
|
65754
|
+
on: options.on,
|
|
65755
|
+
source: options.source,
|
|
65756
|
+
dry_run: options.dryRun ?? false,
|
|
65757
|
+
project_id: options.projectId,
|
|
65758
|
+
agent_id: options.agentId,
|
|
65759
|
+
since: options.since,
|
|
65760
|
+
until: options.until,
|
|
65761
|
+
provider: options.provider,
|
|
65762
|
+
model: options.model,
|
|
65763
|
+
max_tokens: options.maxTokens
|
|
65764
|
+
});
|
|
65765
|
+
return data;
|
|
65766
|
+
}
|
|
65723
65767
|
const db = options.db || getDatabase();
|
|
65724
65768
|
const dryRun = options.dryRun ?? false;
|
|
65725
65769
|
const provider = options.provider ?? process.env["MEMENTOS_REFLECT_PROVIDER"] ?? DEFAULT_REFLECTION_PROVIDER;
|
package/dist/server/index.js
CHANGED
|
@@ -150,6 +150,7 @@ function translateSql(sql) {
|
|
|
150
150
|
const op = parsed < 0 ? "-" : "+";
|
|
151
151
|
return `to_char((now() ${op} INTERVAL '${absolute} ${pluralUnit}') AT TIME ZONE 'UTC', ${ISO_FMT})`;
|
|
152
152
|
});
|
|
153
|
+
translated = translated.replace(/COALESCE\s*\(\s*accessed_at\s*,\s*created_at\s*\)/gi, `COALESCE(accessed_at, to_char(created_at AT TIME ZONE 'UTC', ${ISO_FMT}))`);
|
|
153
154
|
translated = translated.replace(/lower\s*\(\s*hex\s*\(\s*randomblob\s*\(\s*\d+\s*\)\s*\)\s*\)/gi, "gen_random_uuid()::text");
|
|
154
155
|
translated = translated.replace(/\bIFNULL\s*\(/gi, "COALESCE(");
|
|
155
156
|
translated = translated.replace(/\bINSTR\s*\(/gi, "STRPOS(");
|
|
@@ -159,8 +160,20 @@ function translateSql(sql) {
|
|
|
159
160
|
}
|
|
160
161
|
translated = translated.replace(/INSERT\s+OR\s+REPLACE\s+INTO/gi, "INSERT INTO");
|
|
161
162
|
translated = translated.replace(/COALESCE\s*\(\s*pinned\s*,\s*0\s*\)/gi, "COALESCE(pinned, FALSE)");
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
const BOOLEAN_COLUMNS = [
|
|
164
|
+
"pinned",
|
|
165
|
+
"success",
|
|
166
|
+
"is_primary",
|
|
167
|
+
"blocking",
|
|
168
|
+
"enabled",
|
|
169
|
+
"useful",
|
|
170
|
+
"dry_run",
|
|
171
|
+
"applied"
|
|
172
|
+
];
|
|
173
|
+
for (const col of BOOLEAN_COLUMNS) {
|
|
174
|
+
translated = translated.replace(new RegExp(`\\b${col}\\s*=\\s*1\\b`, "gi"), `${col} = TRUE`);
|
|
175
|
+
translated = translated.replace(new RegExp(`\\b${col}\\s*=\\s*0\\b`, "gi"), `${col} = FALSE`);
|
|
176
|
+
}
|
|
164
177
|
return translated;
|
|
165
178
|
}
|
|
166
179
|
function shouldUsePgSsl(connectionString) {
|
|
@@ -2456,7 +2469,8 @@ function getMemory(id, db) {
|
|
|
2456
2469
|
return status === 404 ? null : data ?? null;
|
|
2457
2470
|
}
|
|
2458
2471
|
const d = db || getDatabase();
|
|
2459
|
-
const
|
|
2472
|
+
const resolvedId = resolvePartialId(d, "memories", id) ?? id;
|
|
2473
|
+
const row = d.query("SELECT * FROM memories WHERE id = ?").get(resolvedId);
|
|
2460
2474
|
if (!row)
|
|
2461
2475
|
return null;
|
|
2462
2476
|
return parseMemoryRow(row);
|
|
@@ -5675,6 +5689,13 @@ function addRoute(method, path, handler) {
|
|
|
5675
5689
|
handler
|
|
5676
5690
|
});
|
|
5677
5691
|
}
|
|
5692
|
+
function safeDecodeParam(value) {
|
|
5693
|
+
try {
|
|
5694
|
+
return decodeURIComponent(value);
|
|
5695
|
+
} catch {
|
|
5696
|
+
return value;
|
|
5697
|
+
}
|
|
5698
|
+
}
|
|
5678
5699
|
function matchRoute(method, pathname) {
|
|
5679
5700
|
let bestMatch = null;
|
|
5680
5701
|
for (const route of routes) {
|
|
@@ -5684,7 +5705,7 @@ function matchRoute(method, pathname) {
|
|
|
5684
5705
|
if (match) {
|
|
5685
5706
|
const params = {};
|
|
5686
5707
|
route.paramNames.forEach((name, i) => {
|
|
5687
|
-
params[name] = match[i + 1];
|
|
5708
|
+
params[name] = safeDecodeParam(match[i + 1]);
|
|
5688
5709
|
});
|
|
5689
5710
|
if (!bestMatch || route.specificity > bestMatch.route.specificity || route.specificity === bestMatch.route.specificity && route.order < bestMatch.route.order) {
|
|
5690
5711
|
bestMatch = { route, params };
|
|
@@ -55616,7 +55637,7 @@ function getMemoryHealth(filter = {}, db) {
|
|
|
55616
55637
|
ORDER BY importance DESC, COALESCE(accessed_at, created_at) ASC LIMIT ?`).all(...scopeParams, forgottenCutoff, limit);
|
|
55617
55638
|
const dupes = d.prepare(`SELECT key, COUNT(*) as cnt, MAX(updated_at) as latest, MIN(created_at) as oldest
|
|
55618
55639
|
FROM memories WHERE ${base}
|
|
55619
|
-
GROUP BY key HAVING
|
|
55640
|
+
GROUP BY key HAVING COUNT(*) > 1
|
|
55620
55641
|
ORDER BY cnt DESC LIMIT ?`).all(...scopeParams, limit);
|
|
55621
55642
|
return { stale, forgotten, dupes };
|
|
55622
55643
|
}
|
|
@@ -58683,7 +58704,7 @@ function registerSystemToolRoutes() {
|
|
|
58683
58704
|
});
|
|
58684
58705
|
addRoute("GET", "/api/tool-insights/:tool_name", (_req, url, params) => {
|
|
58685
58706
|
const q = getSearchParams(url);
|
|
58686
|
-
const toolName =
|
|
58707
|
+
const toolName = params["tool_name"];
|
|
58687
58708
|
const projectId = q["project_id"];
|
|
58688
58709
|
const lessonsLimit = q["limit"] ? parseInt(q["limit"], 10) : 20;
|
|
58689
58710
|
const stats = getToolStats(toolName, projectId || undefined);
|
|
@@ -58698,7 +58719,7 @@ init_memories();
|
|
|
58698
58719
|
init_router();
|
|
58699
58720
|
function registerSystemChainRoutes() {
|
|
58700
58721
|
addRoute("GET", "/api/chains/:sequence_group", (_req, url, params) => {
|
|
58701
|
-
const sequenceGroup =
|
|
58722
|
+
const sequenceGroup = params["sequence_group"];
|
|
58702
58723
|
const projectId = getSearchParams(url)["project_id"];
|
|
58703
58724
|
const chain = getMemoryChain(sequenceGroup, projectId, getDatabase());
|
|
58704
58725
|
return json({ chain, count: chain.length, sequence_group: sequenceGroup });
|
|
@@ -58707,6 +58728,7 @@ function registerSystemChainRoutes() {
|
|
|
58707
58728
|
|
|
58708
58729
|
// src/lib/consolidation.ts
|
|
58709
58730
|
init_database();
|
|
58731
|
+
init_api_mode();
|
|
58710
58732
|
init_memories();
|
|
58711
58733
|
|
|
58712
58734
|
// src/db/memory-links.ts
|
|
@@ -59199,6 +59221,19 @@ function buildSummary2(actions) {
|
|
|
59199
59221
|
};
|
|
59200
59222
|
}
|
|
59201
59223
|
async function runConsolidation(options = {}) {
|
|
59224
|
+
if (!options.db && isApiMode()) {
|
|
59225
|
+
const { data } = apiJson("POST", "/consolidate", {
|
|
59226
|
+
dry_run: options.dryRun ?? false,
|
|
59227
|
+
scope: options.scope,
|
|
59228
|
+
project_id: options.projectId,
|
|
59229
|
+
agent_id: options.agentId,
|
|
59230
|
+
duplicate_threshold: options.duplicateThreshold,
|
|
59231
|
+
stale_days: options.staleDays,
|
|
59232
|
+
decay_threshold: options.decayThreshold,
|
|
59233
|
+
limit: options.limit
|
|
59234
|
+
});
|
|
59235
|
+
return data;
|
|
59236
|
+
}
|
|
59202
59237
|
const db = options.db || getDatabase();
|
|
59203
59238
|
const dryRun = options.dryRun ?? false;
|
|
59204
59239
|
let run = createRun({ ...options, dryRun }, db);
|
|
@@ -59242,6 +59277,7 @@ async function runConsolidation(options = {}) {
|
|
|
59242
59277
|
// src/lib/reflection.ts
|
|
59243
59278
|
init_zod();
|
|
59244
59279
|
init_database();
|
|
59280
|
+
init_api_mode();
|
|
59245
59281
|
init_memories();
|
|
59246
59282
|
var DEFAULT_REFLECTION_PROVIDER = "anthropic";
|
|
59247
59283
|
var DEFAULT_REFLECTION_MODEL = "claude-fable-5";
|
|
@@ -59594,6 +59630,21 @@ Return concise lessons. Each lesson must be actionable, evidence-backed, and use
|
|
|
59594
59630
|
};
|
|
59595
59631
|
}
|
|
59596
59632
|
async function reflectOnTrajectory(options) {
|
|
59633
|
+
if (!options.db && isApiMode()) {
|
|
59634
|
+
const { data } = apiJson("POST", "/reflect", {
|
|
59635
|
+
on: options.on,
|
|
59636
|
+
source: options.source,
|
|
59637
|
+
dry_run: options.dryRun ?? false,
|
|
59638
|
+
project_id: options.projectId,
|
|
59639
|
+
agent_id: options.agentId,
|
|
59640
|
+
since: options.since,
|
|
59641
|
+
until: options.until,
|
|
59642
|
+
provider: options.provider,
|
|
59643
|
+
model: options.model,
|
|
59644
|
+
max_tokens: options.maxTokens
|
|
59645
|
+
});
|
|
59646
|
+
return data;
|
|
59647
|
+
}
|
|
59597
59648
|
const db = options.db || getDatabase();
|
|
59598
59649
|
const dryRun = options.dryRun ?? false;
|
|
59599
59650
|
const provider = options.provider ?? process.env["MEMENTOS_REFLECT_PROVIDER"] ?? DEFAULT_REFLECTION_PROVIDER;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/server/router.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GAAG,CACzB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AAElC,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,EAAO,CAAC;AAUlC,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,YAAY,GACpB,IAAI,CAeN;
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/server/router.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GAAG,CACzB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AAElC,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,EAAO,CAAC;AAUlC,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,YAAY,GACpB,IAAI,CAeN;AAWD,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf;IAAE,OAAO,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,IAAI,CAiClE"}
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOtC,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAiB3C,sFAAsF;AACtF,wBAAgB,iBAAiB,IAAI,IAAI,C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EAAE,SAAS,EAChB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,GAAE,sBAA2B,GACnC,oBAAoB,EAAE,CAExB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,GAAE,sBAA2B,GACnC,oBAAoB,EAAE,CAExB;AA2ED,wBAAgB,cAAc,CAAC,EAAE,EAAE,SAAS,GAAG,QAAQ,EAAE,CAKxD;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAEjF;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAGhE;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,CAGpD"}
|
package/dist/storage.js
CHANGED
|
@@ -131,6 +131,7 @@ function translateSql(sql) {
|
|
|
131
131
|
const op = parsed < 0 ? "-" : "+";
|
|
132
132
|
return `to_char((now() ${op} INTERVAL '${absolute} ${pluralUnit}') AT TIME ZONE 'UTC', ${ISO_FMT})`;
|
|
133
133
|
});
|
|
134
|
+
translated = translated.replace(/COALESCE\s*\(\s*accessed_at\s*,\s*created_at\s*\)/gi, `COALESCE(accessed_at, to_char(created_at AT TIME ZONE 'UTC', ${ISO_FMT}))`);
|
|
134
135
|
translated = translated.replace(/lower\s*\(\s*hex\s*\(\s*randomblob\s*\(\s*\d+\s*\)\s*\)\s*\)/gi, "gen_random_uuid()::text");
|
|
135
136
|
translated = translated.replace(/\bIFNULL\s*\(/gi, "COALESCE(");
|
|
136
137
|
translated = translated.replace(/\bINSTR\s*\(/gi, "STRPOS(");
|
|
@@ -140,8 +141,20 @@ function translateSql(sql) {
|
|
|
140
141
|
}
|
|
141
142
|
translated = translated.replace(/INSERT\s+OR\s+REPLACE\s+INTO/gi, "INSERT INTO");
|
|
142
143
|
translated = translated.replace(/COALESCE\s*\(\s*pinned\s*,\s*0\s*\)/gi, "COALESCE(pinned, FALSE)");
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
const BOOLEAN_COLUMNS = [
|
|
145
|
+
"pinned",
|
|
146
|
+
"success",
|
|
147
|
+
"is_primary",
|
|
148
|
+
"blocking",
|
|
149
|
+
"enabled",
|
|
150
|
+
"useful",
|
|
151
|
+
"dry_run",
|
|
152
|
+
"applied"
|
|
153
|
+
];
|
|
154
|
+
for (const col of BOOLEAN_COLUMNS) {
|
|
155
|
+
translated = translated.replace(new RegExp(`\\b${col}\\s*=\\s*1\\b`, "gi"), `${col} = TRUE`);
|
|
156
|
+
translated = translated.replace(new RegExp(`\\b${col}\\s*=\\s*0\\b`, "gi"), `${col} = FALSE`);
|
|
157
|
+
}
|
|
145
158
|
return translated;
|
|
146
159
|
}
|
|
147
160
|
function shouldUsePgSsl(connectionString) {
|