@askexenow/exe-os 0.8.83 → 0.8.85
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/bin/backfill-conversations.js +746 -595
- package/dist/bin/backfill-responses.js +745 -594
- package/dist/bin/backfill-vectors.js +312 -226
- package/dist/bin/cleanup-stale-review-tasks.js +97 -2
- package/dist/bin/cli.js +14350 -12518
- package/dist/bin/exe-agent.js +97 -88
- package/dist/bin/exe-assign.js +1003 -854
- package/dist/bin/exe-boot.js +1257 -320
- package/dist/bin/exe-call.js +10 -0
- package/dist/bin/exe-cloud.js +29 -6
- package/dist/bin/exe-dispatch.js +210 -34
- package/dist/bin/exe-doctor.js +403 -6
- package/dist/bin/exe-export-behaviors.js +175 -72
- package/dist/bin/exe-forget.js +97 -2
- package/dist/bin/exe-gateway.js +550 -171
- package/dist/bin/exe-healthcheck.js +1 -0
- package/dist/bin/exe-heartbeat.js +100 -5
- package/dist/bin/exe-kill.js +175 -72
- package/dist/bin/exe-launch-agent.js +189 -76
- package/dist/bin/exe-link.js +902 -80
- package/dist/bin/exe-new-employee.js +38 -8
- package/dist/bin/exe-pending-messages.js +96 -2
- package/dist/bin/exe-pending-notifications.js +97 -2
- package/dist/bin/exe-pending-reviews.js +98 -3
- package/dist/bin/exe-rename.js +564 -23
- package/dist/bin/exe-review.js +231 -73
- package/dist/bin/exe-search.js +989 -226
- package/dist/bin/exe-session-cleanup.js +4806 -1665
- package/dist/bin/exe-settings.js +20 -5
- package/dist/bin/exe-status.js +97 -2
- package/dist/bin/exe-team.js +97 -2
- package/dist/bin/git-sweep.js +899 -207
- package/dist/bin/graph-backfill.js +175 -72
- package/dist/bin/graph-export.js +175 -72
- package/dist/bin/install.js +38 -7
- package/dist/bin/list-providers.js +1 -0
- package/dist/bin/scan-tasks.js +904 -211
- package/dist/bin/setup.js +867 -268
- package/dist/bin/shard-migrate.js +175 -72
- package/dist/bin/update.js +1 -0
- package/dist/bin/wiki-sync.js +175 -72
- package/dist/gateway/index.js +548 -166
- package/dist/hooks/bug-report-worker.js +208 -23
- package/dist/hooks/commit-complete.js +897 -205
- package/dist/hooks/error-recall.js +988 -226
- package/dist/hooks/ingest-worker.js +1638 -1194
- package/dist/hooks/ingest.js +3 -0
- package/dist/hooks/instructions-loaded.js +707 -97
- package/dist/hooks/notification.js +699 -89
- package/dist/hooks/post-compact.js +714 -104
- package/dist/hooks/pre-compact.js +897 -205
- package/dist/hooks/pre-tool-use.js +742 -123
- package/dist/hooks/prompt-ingest-worker.js +242 -101
- package/dist/hooks/prompt-submit.js +995 -233
- package/dist/hooks/response-ingest-worker.js +242 -101
- package/dist/hooks/session-end.js +3941 -400
- package/dist/hooks/session-start.js +1001 -226
- package/dist/hooks/stop.js +725 -115
- package/dist/hooks/subagent-stop.js +714 -104
- package/dist/hooks/summary-worker.js +1964 -1330
- package/dist/index.js +1651 -1053
- package/dist/lib/cloud-sync.js +907 -86
- package/dist/lib/consolidation.js +2 -1
- package/dist/lib/database.js +642 -87
- package/dist/lib/db-daemon-client.js +503 -0
- package/dist/lib/device-registry.js +547 -7
- package/dist/lib/embedder.js +14 -28
- package/dist/lib/employee-templates.js +84 -74
- package/dist/lib/employees.js +9 -0
- package/dist/lib/exe-daemon-client.js +16 -29
- package/dist/lib/exe-daemon.js +1955 -922
- package/dist/lib/hybrid-search.js +988 -226
- package/dist/lib/identity.js +87 -67
- package/dist/lib/keychain.js +9 -1
- package/dist/lib/messaging.js +8 -1
- package/dist/lib/reminders.js +91 -74
- package/dist/lib/schedules.js +96 -2
- package/dist/lib/skill-learning.js +103 -85
- package/dist/lib/store.js +234 -73
- package/dist/lib/tasks.js +111 -22
- package/dist/lib/tmux-routing.js +120 -31
- package/dist/lib/token-spend.js +273 -0
- package/dist/lib/ws-client.js +11 -0
- package/dist/mcp/server.js +5222 -475
- package/dist/mcp/tools/complete-reminder.js +94 -77
- package/dist/mcp/tools/create-reminder.js +94 -77
- package/dist/mcp/tools/create-task.js +120 -22
- package/dist/mcp/tools/deactivate-behavior.js +95 -77
- package/dist/mcp/tools/list-reminders.js +94 -77
- package/dist/mcp/tools/list-tasks.js +31 -1
- package/dist/mcp/tools/send-message.js +8 -1
- package/dist/mcp/tools/update-task.js +39 -10
- package/dist/runtime/index.js +911 -219
- package/dist/tui/App.js +997 -295
- package/package.json +6 -1
|
@@ -390,6 +390,12 @@ function getClient() {
|
|
|
390
390
|
if (!_resilientClient) {
|
|
391
391
|
throw new Error("Database client not initialized. Call initDatabase() first.");
|
|
392
392
|
}
|
|
393
|
+
if (process.env.EXE_IS_DAEMON === "1") {
|
|
394
|
+
return _resilientClient;
|
|
395
|
+
}
|
|
396
|
+
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
397
|
+
return _daemonClient;
|
|
398
|
+
}
|
|
393
399
|
return _resilientClient;
|
|
394
400
|
}
|
|
395
401
|
function getRawClient() {
|
|
@@ -878,6 +884,12 @@ async function ensureSchema() {
|
|
|
878
884
|
} catch {
|
|
879
885
|
}
|
|
880
886
|
}
|
|
887
|
+
try {
|
|
888
|
+
await client.execute(
|
|
889
|
+
`CREATE INDEX IF NOT EXISTS idx_memories_content_hash ON memories(content_hash, agent_id)`
|
|
890
|
+
);
|
|
891
|
+
} catch {
|
|
892
|
+
}
|
|
881
893
|
await client.executeMultiple(`
|
|
882
894
|
CREATE TABLE IF NOT EXISTS entities (
|
|
883
895
|
id TEXT PRIMARY KEY,
|
|
@@ -930,7 +942,30 @@ async function ensureSchema() {
|
|
|
930
942
|
entity_id TEXT NOT NULL,
|
|
931
943
|
PRIMARY KEY (hyperedge_id, entity_id)
|
|
932
944
|
);
|
|
945
|
+
|
|
946
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS entities_fts USING fts5(
|
|
947
|
+
name,
|
|
948
|
+
content=entities,
|
|
949
|
+
content_rowid=rowid
|
|
950
|
+
);
|
|
951
|
+
|
|
952
|
+
CREATE TRIGGER IF NOT EXISTS entities_fts_ai AFTER INSERT ON entities BEGIN
|
|
953
|
+
INSERT INTO entities_fts(rowid, name) VALUES (new.rowid, new.name);
|
|
954
|
+
END;
|
|
955
|
+
|
|
956
|
+
CREATE TRIGGER IF NOT EXISTS entities_fts_ad AFTER DELETE ON entities BEGIN
|
|
957
|
+
INSERT INTO entities_fts(entities_fts, rowid, name) VALUES('delete', old.rowid, old.name);
|
|
958
|
+
END;
|
|
959
|
+
|
|
960
|
+
CREATE TRIGGER IF NOT EXISTS entities_fts_au AFTER UPDATE ON entities BEGIN
|
|
961
|
+
INSERT INTO entities_fts(entities_fts, rowid, name) VALUES('delete', old.rowid, old.name);
|
|
962
|
+
INSERT INTO entities_fts(rowid, name) VALUES (new.rowid, new.name);
|
|
963
|
+
END;
|
|
933
964
|
`);
|
|
965
|
+
try {
|
|
966
|
+
await client.execute("INSERT INTO entities_fts(entities_fts) VALUES('rebuild')");
|
|
967
|
+
} catch {
|
|
968
|
+
}
|
|
934
969
|
await client.executeMultiple(`
|
|
935
970
|
CREATE TABLE IF NOT EXISTS entity_aliases (
|
|
936
971
|
alias TEXT NOT NULL PRIMARY KEY,
|
|
@@ -1111,6 +1146,33 @@ async function ensureSchema() {
|
|
|
1111
1146
|
CREATE INDEX IF NOT EXISTS idx_conversations_channel
|
|
1112
1147
|
ON conversations(channel_id);
|
|
1113
1148
|
`);
|
|
1149
|
+
await client.executeMultiple(`
|
|
1150
|
+
CREATE TABLE IF NOT EXISTS session_agent_map (
|
|
1151
|
+
session_uuid TEXT PRIMARY KEY,
|
|
1152
|
+
agent_id TEXT NOT NULL,
|
|
1153
|
+
session_name TEXT,
|
|
1154
|
+
task_id TEXT,
|
|
1155
|
+
project_name TEXT,
|
|
1156
|
+
started_at TEXT NOT NULL
|
|
1157
|
+
);
|
|
1158
|
+
|
|
1159
|
+
CREATE INDEX IF NOT EXISTS idx_session_agent_map_agent
|
|
1160
|
+
ON session_agent_map(agent_id);
|
|
1161
|
+
`);
|
|
1162
|
+
try {
|
|
1163
|
+
const mapCount = await client.execute({ sql: `SELECT COUNT(*) as cnt FROM session_agent_map`, args: [] });
|
|
1164
|
+
if (Number(mapCount.rows[0]?.cnt ?? 0) === 0) {
|
|
1165
|
+
await client.execute({
|
|
1166
|
+
sql: `INSERT OR IGNORE INTO session_agent_map (session_uuid, agent_id, session_name, started_at)
|
|
1167
|
+
SELECT session_id, agent_id, '', MIN(timestamp)
|
|
1168
|
+
FROM memories
|
|
1169
|
+
WHERE session_id IS NOT NULL AND session_id != '' AND agent_id IS NOT NULL AND agent_id != ''
|
|
1170
|
+
GROUP BY session_id, agent_id`,
|
|
1171
|
+
args: []
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
} catch {
|
|
1175
|
+
}
|
|
1114
1176
|
try {
|
|
1115
1177
|
await client.execute({
|
|
1116
1178
|
sql: `ALTER TABLE tasks ADD COLUMN budget_tokens INTEGER`,
|
|
@@ -1244,8 +1306,30 @@ async function ensureSchema() {
|
|
|
1244
1306
|
});
|
|
1245
1307
|
} catch {
|
|
1246
1308
|
}
|
|
1309
|
+
for (const col of [
|
|
1310
|
+
"ALTER TABLE memories ADD COLUMN intent TEXT",
|
|
1311
|
+
"ALTER TABLE memories ADD COLUMN outcome TEXT",
|
|
1312
|
+
"ALTER TABLE memories ADD COLUMN domain TEXT",
|
|
1313
|
+
"ALTER TABLE memories ADD COLUMN referenced_entities TEXT",
|
|
1314
|
+
"ALTER TABLE memories ADD COLUMN retrieval_count INTEGER DEFAULT 0",
|
|
1315
|
+
"ALTER TABLE memories ADD COLUMN chain_position TEXT",
|
|
1316
|
+
"ALTER TABLE memories ADD COLUMN review_status TEXT",
|
|
1317
|
+
"ALTER TABLE memories ADD COLUMN context_window_pct INTEGER",
|
|
1318
|
+
"ALTER TABLE memories ADD COLUMN file_paths TEXT",
|
|
1319
|
+
"ALTER TABLE memories ADD COLUMN commit_hash TEXT",
|
|
1320
|
+
"ALTER TABLE memories ADD COLUMN duration_ms INTEGER",
|
|
1321
|
+
"ALTER TABLE memories ADD COLUMN token_cost REAL",
|
|
1322
|
+
"ALTER TABLE memories ADD COLUMN audience TEXT",
|
|
1323
|
+
"ALTER TABLE memories ADD COLUMN language_type TEXT",
|
|
1324
|
+
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
|
|
1325
|
+
]) {
|
|
1326
|
+
try {
|
|
1327
|
+
await client.execute(col);
|
|
1328
|
+
} catch {
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1247
1331
|
}
|
|
1248
|
-
var _client, _resilientClient, initTurso;
|
|
1332
|
+
var _client, _resilientClient, _daemonClient, initTurso;
|
|
1249
1333
|
var init_database = __esm({
|
|
1250
1334
|
"src/lib/database.ts"() {
|
|
1251
1335
|
"use strict";
|
|
@@ -1253,6 +1337,7 @@ var init_database = __esm({
|
|
|
1253
1337
|
init_employees();
|
|
1254
1338
|
_client = null;
|
|
1255
1339
|
_resilientClient = null;
|
|
1340
|
+
_daemonClient = null;
|
|
1256
1341
|
initTurso = initDatabase;
|
|
1257
1342
|
}
|
|
1258
1343
|
});
|
|
@@ -1703,10 +1788,12 @@ function handleData(chunk) {
|
|
|
1703
1788
|
if (!line) continue;
|
|
1704
1789
|
try {
|
|
1705
1790
|
const response = JSON.parse(line);
|
|
1706
|
-
const
|
|
1791
|
+
const id = response.id;
|
|
1792
|
+
if (!id) continue;
|
|
1793
|
+
const entry = _pending.get(id);
|
|
1707
1794
|
if (entry) {
|
|
1708
1795
|
clearTimeout(entry.timer);
|
|
1709
|
-
_pending.delete(
|
|
1796
|
+
_pending.delete(id);
|
|
1710
1797
|
entry.resolve(response);
|
|
1711
1798
|
}
|
|
1712
1799
|
} catch {
|
|
@@ -1877,6 +1964,9 @@ async function connectEmbedDaemon() {
|
|
|
1877
1964
|
return false;
|
|
1878
1965
|
}
|
|
1879
1966
|
function sendRequest(texts, priority) {
|
|
1967
|
+
return sendDaemonRequest({ texts, priority });
|
|
1968
|
+
}
|
|
1969
|
+
function sendDaemonRequest(payload, timeoutMs = REQUEST_TIMEOUT_MS) {
|
|
1880
1970
|
return new Promise((resolve) => {
|
|
1881
1971
|
if (!_socket || !_connected) {
|
|
1882
1972
|
resolve({ error: "Not connected" });
|
|
@@ -1886,10 +1976,10 @@ function sendRequest(texts, priority) {
|
|
|
1886
1976
|
const timer = setTimeout(() => {
|
|
1887
1977
|
_pending.delete(id);
|
|
1888
1978
|
resolve({ error: "Request timeout" });
|
|
1889
|
-
},
|
|
1979
|
+
}, timeoutMs);
|
|
1890
1980
|
_pending.set(id, { resolve, timer });
|
|
1891
1981
|
try {
|
|
1892
|
-
_socket.write(JSON.stringify({ id,
|
|
1982
|
+
_socket.write(JSON.stringify({ id, ...payload }) + "\n");
|
|
1893
1983
|
} catch {
|
|
1894
1984
|
clearTimeout(timer);
|
|
1895
1985
|
_pending.delete(id);
|
|
@@ -1899,30 +1989,11 @@ function sendRequest(texts, priority) {
|
|
|
1899
1989
|
}
|
|
1900
1990
|
async function pingDaemon() {
|
|
1901
1991
|
if (!_socket || !_connected) return null;
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
}, 5e3);
|
|
1908
|
-
_pending.set(id, {
|
|
1909
|
-
resolve: (data) => {
|
|
1910
|
-
if (data.health) {
|
|
1911
|
-
resolve(data.health);
|
|
1912
|
-
} else {
|
|
1913
|
-
resolve(null);
|
|
1914
|
-
}
|
|
1915
|
-
},
|
|
1916
|
-
timer
|
|
1917
|
-
});
|
|
1918
|
-
try {
|
|
1919
|
-
_socket.write(JSON.stringify({ id, type: "health" }) + "\n");
|
|
1920
|
-
} catch {
|
|
1921
|
-
clearTimeout(timer);
|
|
1922
|
-
_pending.delete(id);
|
|
1923
|
-
resolve(null);
|
|
1924
|
-
}
|
|
1925
|
-
});
|
|
1992
|
+
const response = await sendDaemonRequest({ type: "health" }, 5e3);
|
|
1993
|
+
if (response.health) {
|
|
1994
|
+
return response.health;
|
|
1995
|
+
}
|
|
1996
|
+
return null;
|
|
1926
1997
|
}
|
|
1927
1998
|
function killAndRespawnDaemon() {
|
|
1928
1999
|
process.stderr.write("[exed-client] Killing daemon for restart...\n");
|
|
@@ -2507,6 +2578,7 @@ function getProjectName(cwd) {
|
|
|
2507
2578
|
// src/lib/store.ts
|
|
2508
2579
|
init_memory();
|
|
2509
2580
|
init_database();
|
|
2581
|
+
import { createHash } from "crypto";
|
|
2510
2582
|
|
|
2511
2583
|
// src/lib/keychain.ts
|
|
2512
2584
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
@@ -2541,12 +2613,20 @@ async function getMasterKey() {
|
|
|
2541
2613
|
}
|
|
2542
2614
|
const keyPath = getKeyPath();
|
|
2543
2615
|
if (!existsSync3(keyPath)) {
|
|
2616
|
+
process.stderr.write(
|
|
2617
|
+
`[keychain] Key not found at ${keyPath} (HOME=${os3.homedir()}, EXE_OS_DIR=${process.env.EXE_OS_DIR ?? "unset"})
|
|
2618
|
+
`
|
|
2619
|
+
);
|
|
2544
2620
|
return null;
|
|
2545
2621
|
}
|
|
2546
2622
|
try {
|
|
2547
2623
|
const content = await readFile3(keyPath, "utf-8");
|
|
2548
2624
|
return Buffer.from(content.trim(), "base64");
|
|
2549
|
-
} catch {
|
|
2625
|
+
} catch (err) {
|
|
2626
|
+
process.stderr.write(
|
|
2627
|
+
`[keychain] Key read failed at ${keyPath}: ${err instanceof Error ? err.message : String(err)}
|
|
2628
|
+
`
|
|
2629
|
+
);
|
|
2550
2630
|
return null;
|
|
2551
2631
|
}
|
|
2552
2632
|
}
|
|
@@ -2685,12 +2765,52 @@ function classifyTier(record) {
|
|
|
2685
2765
|
if (["store_memory", "manual"].includes(record.tool_name ?? "") && (record.importance ?? 0) >= 5) return 2;
|
|
2686
2766
|
return 3;
|
|
2687
2767
|
}
|
|
2768
|
+
function inferFilePaths(record) {
|
|
2769
|
+
if (!["Read", "Write", "Edit"].includes(record.tool_name)) return null;
|
|
2770
|
+
const firstLine = record.raw_text.split("\n")[0] ?? "";
|
|
2771
|
+
const match = firstLine.match(/(\/[\w./-]+\.\w+)/);
|
|
2772
|
+
return match ? JSON.stringify([match[1]]) : null;
|
|
2773
|
+
}
|
|
2774
|
+
function inferCommitHash(record) {
|
|
2775
|
+
if (record.tool_name !== "Bash") return null;
|
|
2776
|
+
const match = record.raw_text.match(/\b([a-f0-9]{7,40})\b/);
|
|
2777
|
+
return match ? match[1] : null;
|
|
2778
|
+
}
|
|
2779
|
+
function inferLanguageType(record) {
|
|
2780
|
+
const text = record.raw_text;
|
|
2781
|
+
if (!text || text.length < 10) return null;
|
|
2782
|
+
const trimmed = text.trimStart();
|
|
2783
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) return "json";
|
|
2784
|
+
if (/\b(SELECT|INSERT|UPDATE|DELETE|CREATE TABLE|ALTER TABLE)\b/i.test(text)) return "sql";
|
|
2785
|
+
if (/\b(function |const |import |export |class |def |async |=>)\b/.test(text)) return "code";
|
|
2786
|
+
if (trimmed.startsWith("#") || trimmed.startsWith("*")) return "prose";
|
|
2787
|
+
return "mixed";
|
|
2788
|
+
}
|
|
2789
|
+
function inferDomain(record) {
|
|
2790
|
+
const proj = (record.project_name ?? "").toLowerCase();
|
|
2791
|
+
if (proj.includes("marketing") || proj.includes("content")) return "marketing";
|
|
2792
|
+
if (proj.includes("crm") || proj.includes("customer")) return "customer";
|
|
2793
|
+
return null;
|
|
2794
|
+
}
|
|
2688
2795
|
async function writeMemory(record) {
|
|
2689
2796
|
if (record.vector !== null && record.vector.length !== EMBEDDING_DIM) {
|
|
2690
2797
|
throw new Error(
|
|
2691
2798
|
`Expected ${EMBEDDING_DIM}-dim vector, got ${record.vector.length}`
|
|
2692
2799
|
);
|
|
2693
2800
|
}
|
|
2801
|
+
const contentHash = createHash("md5").update(record.raw_text).digest("hex");
|
|
2802
|
+
if (_pendingRecords.some((r) => r.content_hash === contentHash && r.agent_id === record.agent_id)) {
|
|
2803
|
+
return;
|
|
2804
|
+
}
|
|
2805
|
+
try {
|
|
2806
|
+
const client = getClient();
|
|
2807
|
+
const existing = await client.execute({
|
|
2808
|
+
sql: "SELECT id FROM memories WHERE content_hash = ? AND agent_id = ? LIMIT 1",
|
|
2809
|
+
args: [contentHash, record.agent_id]
|
|
2810
|
+
});
|
|
2811
|
+
if (existing.rows.length > 0) return;
|
|
2812
|
+
} catch {
|
|
2813
|
+
}
|
|
2694
2814
|
const dbRow = {
|
|
2695
2815
|
id: record.id,
|
|
2696
2816
|
agent_id: record.agent_id,
|
|
@@ -2720,7 +2840,23 @@ async function writeMemory(record) {
|
|
|
2720
2840
|
supersedes_id: record.supersedes_id ?? null,
|
|
2721
2841
|
draft: record.draft ? 1 : 0,
|
|
2722
2842
|
memory_type: record.memory_type ?? "raw",
|
|
2723
|
-
trajectory: record.trajectory ? JSON.stringify(record.trajectory) : null
|
|
2843
|
+
trajectory: record.trajectory ? JSON.stringify(record.trajectory) : null,
|
|
2844
|
+
content_hash: contentHash,
|
|
2845
|
+
intent: record.intent ?? null,
|
|
2846
|
+
outcome: record.outcome ?? null,
|
|
2847
|
+
domain: record.domain ?? inferDomain(record),
|
|
2848
|
+
referenced_entities: record.referenced_entities ?? null,
|
|
2849
|
+
retrieval_count: record.retrieval_count ?? 0,
|
|
2850
|
+
chain_position: record.chain_position ?? null,
|
|
2851
|
+
review_status: record.review_status ?? null,
|
|
2852
|
+
context_window_pct: record.context_window_pct ?? null,
|
|
2853
|
+
file_paths: record.file_paths ?? inferFilePaths(record),
|
|
2854
|
+
commit_hash: record.commit_hash ?? inferCommitHash(record),
|
|
2855
|
+
duration_ms: record.duration_ms ?? null,
|
|
2856
|
+
token_cost: record.token_cost ?? null,
|
|
2857
|
+
audience: record.audience ?? null,
|
|
2858
|
+
language_type: record.language_type ?? inferLanguageType(record),
|
|
2859
|
+
parent_memory_id: record.parent_memory_id ?? null
|
|
2724
2860
|
};
|
|
2725
2861
|
_pendingRecords.push(dbRow);
|
|
2726
2862
|
orgBus.emit({
|
|
@@ -2778,80 +2914,85 @@ async function flushBatch() {
|
|
|
2778
2914
|
const draft = row.draft ? 1 : 0;
|
|
2779
2915
|
const memoryType = row.memory_type ?? "raw";
|
|
2780
2916
|
const trajectory = row.trajectory ?? null;
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2917
|
+
const contentHash = row.content_hash ?? null;
|
|
2918
|
+
const intent = row.intent ?? null;
|
|
2919
|
+
const outcome = row.outcome ?? null;
|
|
2920
|
+
const domain = row.domain ?? null;
|
|
2921
|
+
const referencedEntities = row.referenced_entities ?? null;
|
|
2922
|
+
const retrievalCount = row.retrieval_count ?? 0;
|
|
2923
|
+
const chainPosition = row.chain_position ?? null;
|
|
2924
|
+
const reviewStatus = row.review_status ?? null;
|
|
2925
|
+
const contextWindowPct = row.context_window_pct ?? null;
|
|
2926
|
+
const filePaths = row.file_paths ?? null;
|
|
2927
|
+
const commitHash = row.commit_hash ?? null;
|
|
2928
|
+
const durationMs = row.duration_ms ?? null;
|
|
2929
|
+
const tokenCost = row.token_cost ?? null;
|
|
2930
|
+
const audience = row.audience ?? null;
|
|
2931
|
+
const languageType = row.language_type ?? null;
|
|
2932
|
+
const parentMemoryId = row.parent_memory_id ?? null;
|
|
2933
|
+
const cols = `id, agent_id, agent_role, session_id, timestamp,
|
|
2784
2934
|
tool_name, project_name,
|
|
2785
2935
|
has_error, raw_text, vector, version, task_id, importance, status,
|
|
2786
2936
|
confidence, last_accessed,
|
|
2787
2937
|
workspace_id, document_id, user_id, char_offset, page_number,
|
|
2788
|
-
source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
pageNumber,
|
|
2847
|
-
sourcePath,
|
|
2848
|
-
sourceType,
|
|
2849
|
-
tier,
|
|
2850
|
-
supersedesId,
|
|
2851
|
-
draft,
|
|
2852
|
-
memoryType,
|
|
2853
|
-
trajectory
|
|
2854
|
-
]
|
|
2938
|
+
source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory, content_hash,
|
|
2939
|
+
intent, outcome, domain, referenced_entities, retrieval_count,
|
|
2940
|
+
chain_position, review_status, context_window_pct, file_paths, commit_hash,
|
|
2941
|
+
duration_ms, token_cost, audience, language_type, parent_memory_id`;
|
|
2942
|
+
const metaArgs = [
|
|
2943
|
+
intent,
|
|
2944
|
+
outcome,
|
|
2945
|
+
domain,
|
|
2946
|
+
referencedEntities,
|
|
2947
|
+
retrievalCount,
|
|
2948
|
+
chainPosition,
|
|
2949
|
+
reviewStatus,
|
|
2950
|
+
contextWindowPct,
|
|
2951
|
+
filePaths,
|
|
2952
|
+
commitHash,
|
|
2953
|
+
durationMs,
|
|
2954
|
+
tokenCost,
|
|
2955
|
+
audience,
|
|
2956
|
+
languageType,
|
|
2957
|
+
parentMemoryId
|
|
2958
|
+
];
|
|
2959
|
+
const baseArgs = [
|
|
2960
|
+
row.id,
|
|
2961
|
+
row.agent_id,
|
|
2962
|
+
row.agent_role,
|
|
2963
|
+
row.session_id,
|
|
2964
|
+
row.timestamp,
|
|
2965
|
+
row.tool_name,
|
|
2966
|
+
row.project_name,
|
|
2967
|
+
row.has_error,
|
|
2968
|
+
row.raw_text
|
|
2969
|
+
];
|
|
2970
|
+
const sharedArgs = [
|
|
2971
|
+
row.version,
|
|
2972
|
+
taskId,
|
|
2973
|
+
importance,
|
|
2974
|
+
status,
|
|
2975
|
+
confidence,
|
|
2976
|
+
lastAccessed,
|
|
2977
|
+
workspaceId,
|
|
2978
|
+
documentId,
|
|
2979
|
+
userId,
|
|
2980
|
+
charOffset,
|
|
2981
|
+
pageNumber,
|
|
2982
|
+
sourcePath,
|
|
2983
|
+
sourceType,
|
|
2984
|
+
tier,
|
|
2985
|
+
supersedesId,
|
|
2986
|
+
draft,
|
|
2987
|
+
memoryType,
|
|
2988
|
+
trajectory,
|
|
2989
|
+
contentHash
|
|
2990
|
+
];
|
|
2991
|
+
return {
|
|
2992
|
+
sql: hasVector ? `INSERT OR IGNORE INTO memories (${cols})
|
|
2993
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories (${cols})
|
|
2994
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
2995
|
+
args: hasVector ? [...baseArgs, vectorToBlob(row.vector), ...sharedArgs, ...metaArgs] : [...baseArgs, ...sharedArgs, ...metaArgs]
|
|
2855
2996
|
};
|
|
2856
2997
|
};
|
|
2857
2998
|
const globalClient = getClient();
|