@edihasaj/recall 2.0.7 → 2.0.8
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/README.md +11 -0
- package/dist/{chunk-W75S5CK3.js → chunk-3LL5S473.js} +2 -2
- package/dist/{chunk-YDVBXHX2.js → chunk-3ZA4YOFN.js} +5 -5
- package/dist/{chunk-QPOOF2GK.js → chunk-4LTGMFHN.js} +3 -3
- package/dist/{chunk-S46JVROA.js → chunk-6U7YMPBE.js} +2 -2
- package/dist/{chunk-BTD3BYVV.js → chunk-BOUMOPKD.js} +2 -2
- package/dist/{chunk-63H4ENYA.js → chunk-HYDNV5T2.js} +351 -139
- package/dist/chunk-HYDNV5T2.js.map +1 -0
- package/dist/{chunk-BJZCBMU4.js → chunk-J3F3CLWL.js} +7 -7
- package/dist/{chunk-MZTZKBRL.js → chunk-JSKYG7TC.js} +2 -2
- package/dist/{chunk-M5MPUMCJ.js → chunk-LOWPEB72.js} +3 -3
- package/dist/{chunk-DQMKYMUS.js → chunk-MD2LUEVD.js} +435 -89
- package/dist/chunk-MD2LUEVD.js.map +1 -0
- package/dist/{chunk-EX5UTOIU.js → chunk-N2ONUBXR.js} +9 -9
- package/dist/{chunk-VH3FI2X3.js → chunk-OHWHU653.js} +843 -144
- package/dist/chunk-OHWHU653.js.map +1 -0
- package/dist/{chunk-MQPMF5F3.js → chunk-PW42PFVO.js} +7 -7
- package/dist/{chunk-2WBJWKIK.js → chunk-QKGE74LD.js} +8 -5
- package/dist/chunk-QKGE74LD.js.map +1 -0
- package/dist/{chunk-FOJHR4JJ.js → chunk-QOMNHKYE.js} +2 -2
- package/dist/{chunk-AVUTQWZE.js → chunk-RSBIISGE.js} +5 -5
- package/dist/{chunk-V3MYT3AT.js → chunk-URQEUH7T.js} +3 -3
- package/dist/{chunk-EDUIDJWZ.js → chunk-VV2QPDAM.js} +2 -2
- package/dist/{chunk-EDUIDJWZ.js.map → chunk-VV2QPDAM.js.map} +1 -1
- package/dist/{cleanup-EDWLCJPH.js → cleanup-QC7EHMUB.js} +11 -11
- package/dist/cli.js +209 -162
- package/dist/cli.js.map +1 -1
- package/dist/{codex-trust-H6KNABHV.js → codex-trust-4RI6LCAI.js} +4 -4
- package/dist/daemon.js +208 -48
- package/dist/daemon.js.map +1 -1
- package/dist/dispatcher-XGATH6Q5.js +22 -0
- package/dist/{embeddings-W24SA6R3.js → embeddings-RS3GK3TS.js} +5 -5
- package/dist/ingest-RGPV5QYT.js +20 -0
- package/dist/{keychain-LVWMAS7D.js → keychain-BRWB5CL5.js} +3 -3
- package/dist/mcp.js +15 -15
- package/dist/{memory-value-GMYJ5NGO.js → memory-value-6KDRPDXE.js} +11 -11
- package/dist/{provenance-KSBMVJO5.js → provenance-NLVTH5ZK.js} +9 -9
- package/dist/quality-QPRUXM4B.js +25 -0
- package/dist/retrieval-N5FQRL2V.js +15 -0
- package/dist/{store-QYLHMBPE.js → store-DXJJ7VOQ.js} +4 -4
- package/dist/sync-server.js +2 -2
- package/dist/{tasks-7P7XOGSC.js → tasks-32RY4KNA.js} +11 -11
- package/dist/{usage-KVVZQTZA.js → usage-3EMXD6MZ.js} +4 -4
- package/dist/webui/assets/{GraphPage-DJhwG-72.js → GraphPage-BH_Mch3C.js} +2 -2
- package/dist/webui/assets/{GraphPage-DJhwG-72.js.map → GraphPage-BH_Mch3C.js.map} +1 -1
- package/dist/webui/assets/{index-Cpn2MjW0.js → index-CPFc-fiv.js} +25 -25
- package/dist/webui/assets/index-CPFc-fiv.js.map +1 -0
- package/dist/webui/index.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-2WBJWKIK.js.map +0 -1
- package/dist/chunk-63H4ENYA.js.map +0 -1
- package/dist/chunk-DQMKYMUS.js.map +0 -1
- package/dist/chunk-VH3FI2X3.js.map +0 -1
- package/dist/dispatcher-W3PTGEKN.js +0 -22
- package/dist/ingest-FF67DX3F.js +0 -20
- package/dist/quality-6BN2ERKC.js +0 -25
- package/dist/retrieval-QLC3DNMW.js +0 -15
- package/dist/webui/assets/index-Cpn2MjW0.js.map +0 -1
- /package/dist/{chunk-W75S5CK3.js.map → chunk-3LL5S473.js.map} +0 -0
- /package/dist/{chunk-YDVBXHX2.js.map → chunk-3ZA4YOFN.js.map} +0 -0
- /package/dist/{chunk-QPOOF2GK.js.map → chunk-4LTGMFHN.js.map} +0 -0
- /package/dist/{chunk-S46JVROA.js.map → chunk-6U7YMPBE.js.map} +0 -0
- /package/dist/{chunk-BTD3BYVV.js.map → chunk-BOUMOPKD.js.map} +0 -0
- /package/dist/{chunk-BJZCBMU4.js.map → chunk-J3F3CLWL.js.map} +0 -0
- /package/dist/{chunk-MZTZKBRL.js.map → chunk-JSKYG7TC.js.map} +0 -0
- /package/dist/{chunk-M5MPUMCJ.js.map → chunk-LOWPEB72.js.map} +0 -0
- /package/dist/{chunk-EX5UTOIU.js.map → chunk-N2ONUBXR.js.map} +0 -0
- /package/dist/{chunk-MQPMF5F3.js.map → chunk-PW42PFVO.js.map} +0 -0
- /package/dist/{chunk-FOJHR4JJ.js.map → chunk-QOMNHKYE.js.map} +0 -0
- /package/dist/{chunk-AVUTQWZE.js.map → chunk-RSBIISGE.js.map} +0 -0
- /package/dist/{chunk-V3MYT3AT.js.map → chunk-URQEUH7T.js.map} +0 -0
- /package/dist/{cleanup-EDWLCJPH.js.map → cleanup-QC7EHMUB.js.map} +0 -0
- /package/dist/{codex-trust-H6KNABHV.js.map → codex-trust-4RI6LCAI.js.map} +0 -0
- /package/dist/{dispatcher-W3PTGEKN.js.map → dispatcher-XGATH6Q5.js.map} +0 -0
- /package/dist/{embeddings-W24SA6R3.js.map → embeddings-RS3GK3TS.js.map} +0 -0
- /package/dist/{ingest-FF67DX3F.js.map → ingest-RGPV5QYT.js.map} +0 -0
- /package/dist/{keychain-LVWMAS7D.js.map → keychain-BRWB5CL5.js.map} +0 -0
- /package/dist/{memory-value-GMYJ5NGO.js.map → memory-value-6KDRPDXE.js.map} +0 -0
- /package/dist/{provenance-KSBMVJO5.js.map → provenance-NLVTH5ZK.js.map} +0 -0
- /package/dist/{quality-6BN2ERKC.js.map → quality-QPRUXM4B.js.map} +0 -0
- /package/dist/{retrieval-QLC3DNMW.js.map → retrieval-N5FQRL2V.js.map} +0 -0
- /package/dist/{store-QYLHMBPE.js.map → store-DXJJ7VOQ.js.map} +0 -0
- /package/dist/{tasks-7P7XOGSC.js.map → tasks-32RY4KNA.js.map} +0 -0
- /package/dist/{usage-KVVZQTZA.js.map → usage-3EMXD6MZ.js.map} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveCodexHomes
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-4LTGMFHN.js";
|
|
4
|
+
import "./chunk-6U7YMPBE.js";
|
|
5
5
|
import {
|
|
6
6
|
init_define_RECALL_BUILD_INFO
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VV2QPDAM.js";
|
|
8
8
|
|
|
9
9
|
// src/doctor/codex-trust.ts
|
|
10
10
|
init_define_RECALL_BUILD_INFO();
|
|
@@ -71,4 +71,4 @@ function probeCodexHome(home) {
|
|
|
71
71
|
export {
|
|
72
72
|
inspectCodexTrust
|
|
73
73
|
};
|
|
74
|
-
//# sourceMappingURL=codex-trust-
|
|
74
|
+
//# sourceMappingURL=codex-trust-4RI6LCAI.js.map
|
package/dist/daemon.js
CHANGED
|
@@ -2,24 +2,35 @@ import {
|
|
|
2
2
|
computeQualityReport,
|
|
3
3
|
listQualitySnapshots,
|
|
4
4
|
recordQualitySnapshot
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-RSBIISGE.js";
|
|
6
6
|
import {
|
|
7
7
|
ensureDailyBackup,
|
|
8
|
+
extractCodexSessionId,
|
|
9
|
+
formatInjectionContext,
|
|
10
|
+
formatMaintenanceBacklogContext,
|
|
11
|
+
formatPendingConfirmationsContext,
|
|
8
12
|
getDoctorStatusReport,
|
|
9
13
|
handleAssistantCompletionHook,
|
|
10
14
|
handlePromptHook,
|
|
11
15
|
handleSessionEndHook,
|
|
12
16
|
handleSessionStartHook,
|
|
13
17
|
handleToolHook,
|
|
18
|
+
loadReliabilityVerdictConfigFromEnv,
|
|
19
|
+
notifyMacOS,
|
|
20
|
+
readReliabilityVerdict,
|
|
21
|
+
reliabilityVerdictDataDir,
|
|
22
|
+
resolveCodexSessionEndSessionId,
|
|
23
|
+
runReliabilityVerdictCycle,
|
|
24
|
+
toolOutcomeFromPayload,
|
|
14
25
|
writeRepoContextArtifact
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
26
|
+
} from "./chunk-OHWHU653.js";
|
|
27
|
+
import "./chunk-4LTGMFHN.js";
|
|
17
28
|
import {
|
|
18
29
|
createRecallMcpServer
|
|
19
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-N2ONUBXR.js";
|
|
20
31
|
import {
|
|
21
32
|
graphQuery
|
|
22
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-3ZA4YOFN.js";
|
|
23
34
|
import {
|
|
24
35
|
bootstrapHistoryEmbeddings,
|
|
25
36
|
compileContext,
|
|
@@ -52,13 +63,14 @@ import {
|
|
|
52
63
|
resolveApproval,
|
|
53
64
|
runValueRetrievalEval,
|
|
54
65
|
scanAndStore,
|
|
66
|
+
signalOutcomeFallback,
|
|
55
67
|
startEvalSession,
|
|
56
68
|
startSessionLifecycle,
|
|
57
69
|
summarizeValueRetrievalEval,
|
|
58
70
|
syncHistoryFtsIndex,
|
|
59
71
|
updateHistorySnippet,
|
|
60
72
|
verifyHistoryEmbeddings
|
|
61
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-HYDNV5T2.js";
|
|
62
74
|
import {
|
|
63
75
|
DEFAULT_ENQUEUE_CONFIG,
|
|
64
76
|
autoResolveContradictions,
|
|
@@ -76,14 +88,15 @@ import {
|
|
|
76
88
|
processReviewFeedback,
|
|
77
89
|
resolveContradiction,
|
|
78
90
|
runDeterministicCleanup
|
|
79
|
-
} from "./chunk-
|
|
80
|
-
import "./chunk-
|
|
81
|
-
import "./chunk-
|
|
91
|
+
} from "./chunk-MD2LUEVD.js";
|
|
92
|
+
import "./chunk-PW42PFVO.js";
|
|
93
|
+
import "./chunk-3LL5S473.js";
|
|
82
94
|
import {
|
|
83
95
|
Sentry
|
|
84
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-JSKYG7TC.js";
|
|
85
97
|
import {
|
|
86
98
|
confirmMemory,
|
|
99
|
+
createMemory,
|
|
87
100
|
getAuditTrail,
|
|
88
101
|
getMemory,
|
|
89
102
|
getRecentAudit,
|
|
@@ -93,14 +106,13 @@ import {
|
|
|
93
106
|
queryMemories,
|
|
94
107
|
recordAudit,
|
|
95
108
|
recordAuditWithSnapshot,
|
|
96
|
-
recordFeedback,
|
|
97
109
|
rejectMemory,
|
|
98
110
|
rollbackMemory,
|
|
99
111
|
safeIngestMemoryById,
|
|
100
112
|
statusFromConfidence
|
|
101
|
-
} from "./chunk-
|
|
102
|
-
import "./chunk-
|
|
103
|
-
import "./chunk-
|
|
113
|
+
} from "./chunk-J3F3CLWL.js";
|
|
114
|
+
import "./chunk-URQEUH7T.js";
|
|
115
|
+
import "./chunk-6U7YMPBE.js";
|
|
104
116
|
import {
|
|
105
117
|
bootstrapEmbeddings,
|
|
106
118
|
getEmbeddingModelInfo,
|
|
@@ -109,11 +121,11 @@ import {
|
|
|
109
121
|
queueMemoryEmbeddingSync,
|
|
110
122
|
rebuildEmbeddingIndexResponsive,
|
|
111
123
|
verifyEmbeddings
|
|
112
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-QKGE74LD.js";
|
|
113
125
|
import {
|
|
114
126
|
hasProviderConfigured,
|
|
115
127
|
init_keychain
|
|
116
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-QOMNHKYE.js";
|
|
117
129
|
import {
|
|
118
130
|
clearGraph,
|
|
119
131
|
countEntities,
|
|
@@ -124,7 +136,7 @@ import {
|
|
|
124
136
|
listEntitiesForMemory,
|
|
125
137
|
listMemoryIdsForEntity,
|
|
126
138
|
neighborsOf
|
|
127
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-LOWPEB72.js";
|
|
128
140
|
import {
|
|
129
141
|
activityEvents,
|
|
130
142
|
eq,
|
|
@@ -134,11 +146,11 @@ import {
|
|
|
134
146
|
implicitSignals,
|
|
135
147
|
lt,
|
|
136
148
|
memories
|
|
137
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-BOUMOPKD.js";
|
|
138
150
|
import {
|
|
139
151
|
define_RECALL_BUILD_INFO_default,
|
|
140
152
|
init_define_RECALL_BUILD_INFO
|
|
141
|
-
} from "./chunk-
|
|
153
|
+
} from "./chunk-VV2QPDAM.js";
|
|
142
154
|
|
|
143
155
|
// src/daemon.ts
|
|
144
156
|
init_define_RECALL_BUILD_INFO();
|
|
@@ -229,7 +241,7 @@ function writeMarker(path, version) {
|
|
|
229
241
|
// src/webui/server.ts
|
|
230
242
|
init_define_RECALL_BUILD_INFO();
|
|
231
243
|
import { createServer } from "http";
|
|
232
|
-
import { createReadStream, existsSync as existsSync2, statSync } from "fs";
|
|
244
|
+
import { createReadStream, existsSync as existsSync2, readFileSync as readFileSync2, statSync } from "fs";
|
|
233
245
|
import { extname, join as join2, normalize, resolve, sep } from "path";
|
|
234
246
|
import { fileURLToPath } from "url";
|
|
235
247
|
|
|
@@ -321,9 +333,9 @@ function ensurePingLoop() {
|
|
|
321
333
|
}, 3e4);
|
|
322
334
|
pingTimer.unref?.();
|
|
323
335
|
}
|
|
324
|
-
function writeText(socket,
|
|
336
|
+
function writeText(socket, text2) {
|
|
325
337
|
try {
|
|
326
|
-
writeFrame(socket, 1, Buffer.from(
|
|
338
|
+
writeFrame(socket, 1, Buffer.from(text2, "utf8"));
|
|
327
339
|
} catch {
|
|
328
340
|
}
|
|
329
341
|
}
|
|
@@ -541,6 +553,20 @@ function serveFile(res, file, head = false) {
|
|
|
541
553
|
res.end();
|
|
542
554
|
return;
|
|
543
555
|
}
|
|
556
|
+
if (extname(file).toLowerCase() === ".html" && process.env.RECALL_PORT) {
|
|
557
|
+
const port = Number(process.env.RECALL_PORT);
|
|
558
|
+
if (Number.isInteger(port) && port > 0 && port <= 65535) {
|
|
559
|
+
try {
|
|
560
|
+
const html = readFileSync2(file, "utf8");
|
|
561
|
+
const meta = `<meta name="recall-daemon-url" content="http://127.0.0.1:${port}">`;
|
|
562
|
+
res.end(html.replace(/<head(?:\s[^>]*)?>/i, (head2) => head2 + meta));
|
|
563
|
+
} catch {
|
|
564
|
+
res.statusCode = 503;
|
|
565
|
+
res.end("Dashboard asset unavailable.");
|
|
566
|
+
}
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
544
570
|
const stream = createReadStream(file);
|
|
545
571
|
const abort = () => stream.destroy();
|
|
546
572
|
res.once("close", abort);
|
|
@@ -944,8 +970,8 @@ function cleanupSessionHistory(db2, retentionDays) {
|
|
|
944
970
|
function summarizeSessionEvents(events) {
|
|
945
971
|
const repo = events.find((event) => event.repo)?.repo ?? "unknown";
|
|
946
972
|
const eventTypes = [...new Set(events.map((event) => event.event_type))];
|
|
947
|
-
const corrections = events.filter((event) => event.event_type === "correction").map((event) => String(event.request.text ?? "")).filter((
|
|
948
|
-
const reviews = events.filter((event) => event.event_type === "review").map((event) => String(event.request.feedback ?? "")).filter((
|
|
973
|
+
const corrections = events.filter((event) => event.event_type === "correction").map((event) => String(event.request.text ?? "")).filter((text2) => Boolean(text2) && !isGeneratedCaptureContext(text2));
|
|
974
|
+
const reviews = events.filter((event) => event.event_type === "review").map((event) => String(event.request.feedback ?? "")).filter((text2) => Boolean(text2) && !isGeneratedCaptureContext(text2));
|
|
949
975
|
const decisions = extractPromptDecisions(events);
|
|
950
976
|
const compileEvents = events.filter((event) => event.event_type === "compile");
|
|
951
977
|
const lines = [
|
|
@@ -1034,7 +1060,7 @@ function aggregateRepoHistory(repo, snippets) {
|
|
|
1034
1060
|
}
|
|
1035
1061
|
function renderSummary(repo, heading, counts) {
|
|
1036
1062
|
if (counts.size === 0) return "";
|
|
1037
|
-
const top = [...counts.entries()].sort((a, b) => b[1] - a[1]).slice(0, 5).map(([
|
|
1063
|
+
const top = [...counts.entries()].sort((a, b) => b[1] - a[1]).slice(0, 5).map(([text2, count]) => `- (${count}) ${text2}`);
|
|
1038
1064
|
return [
|
|
1039
1065
|
`Repo: ${repo}`,
|
|
1040
1066
|
`${heading}:`,
|
|
@@ -1047,27 +1073,27 @@ function extractPromptDecisions(events) {
|
|
|
1047
1073
|
for (const event of events) {
|
|
1048
1074
|
if (event.event_type !== "session_event") continue;
|
|
1049
1075
|
if (event.request.name !== "prompt_submitted") continue;
|
|
1050
|
-
const
|
|
1051
|
-
if (!
|
|
1052
|
-
const durable = detectCorrections(
|
|
1076
|
+
const text2 = String(event.result.text ?? "").trim();
|
|
1077
|
+
if (!text2 || isGeneratedCaptureContext(text2)) continue;
|
|
1078
|
+
const durable = detectCorrections(text2).filter((match) => match.type === "decision").map((match) => match.text);
|
|
1053
1079
|
for (const item of durable) {
|
|
1054
1080
|
addUniqueDecision(seen, decisions, item);
|
|
1055
1081
|
}
|
|
1056
|
-
const directive = extractDurablePromptDirective(
|
|
1082
|
+
const directive = extractDurablePromptDirective(text2);
|
|
1057
1083
|
if (directive) {
|
|
1058
1084
|
addUniqueDecision(seen, decisions, directive);
|
|
1059
1085
|
}
|
|
1060
1086
|
}
|
|
1061
1087
|
return decisions;
|
|
1062
1088
|
}
|
|
1063
|
-
function addUniqueDecision(seen, decisions,
|
|
1064
|
-
const normalized =
|
|
1089
|
+
function addUniqueDecision(seen, decisions, text2) {
|
|
1090
|
+
const normalized = text2.toLowerCase().replace(/\s+/g, " ").trim();
|
|
1065
1091
|
if (!normalized || seen.has(normalized)) return;
|
|
1066
1092
|
seen.add(normalized);
|
|
1067
|
-
decisions.push(
|
|
1093
|
+
decisions.push(text2);
|
|
1068
1094
|
}
|
|
1069
|
-
function extractDurablePromptDirective(
|
|
1070
|
-
const compact =
|
|
1095
|
+
function extractDurablePromptDirective(text2) {
|
|
1096
|
+
const compact = text2.replace(/\s+/g, " ").replace(/^[-*]\s+/, "").trim();
|
|
1071
1097
|
const phaseDirective = /\b(?:do\s+phase|phase\s+\d+)\b/i.test(compact);
|
|
1072
1098
|
if (!phaseDirective && compact.length < 14 || compact.length > 240) return null;
|
|
1073
1099
|
if (!DURABLE_PROMPT_DIRECTIVE.test(compact)) return null;
|
|
@@ -1373,6 +1399,75 @@ var ReleaseChecker = class {
|
|
|
1373
1399
|
};
|
|
1374
1400
|
var releaseChecker = new ReleaseChecker();
|
|
1375
1401
|
|
|
1402
|
+
// src/hooks/http-agent.ts
|
|
1403
|
+
init_define_RECALL_BUILD_INFO();
|
|
1404
|
+
var HTTP_HOOK_EVENTS = [
|
|
1405
|
+
"SessionStart",
|
|
1406
|
+
"UserPromptSubmit",
|
|
1407
|
+
"PostToolUse",
|
|
1408
|
+
"PostToolUseFailure",
|
|
1409
|
+
"Stop",
|
|
1410
|
+
"SessionEnd"
|
|
1411
|
+
];
|
|
1412
|
+
function text(payload, key) {
|
|
1413
|
+
const value = payload[key];
|
|
1414
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
1415
|
+
}
|
|
1416
|
+
async function handleAgentHttpHook(db2, agent, event, payload) {
|
|
1417
|
+
let session = agent === "codex" ? extractCodexSessionId(payload)?.session_id : text(payload, "session_id");
|
|
1418
|
+
if (!session && agent === "codex" && (event === "Stop" || event === "SessionEnd")) {
|
|
1419
|
+
const resolved = resolveCodexSessionEndSessionId(payload, { agent, getDb: () => db2 });
|
|
1420
|
+
if (resolved.status === "unresolved") return {};
|
|
1421
|
+
session = resolved.session_id;
|
|
1422
|
+
}
|
|
1423
|
+
if (!session) throw new Error("session_id required");
|
|
1424
|
+
const common = { agent, session_id: session, repo: text(payload, "repo"), repo_path: text(payload, "cwd") };
|
|
1425
|
+
let result;
|
|
1426
|
+
switch (event) {
|
|
1427
|
+
case "SessionStart":
|
|
1428
|
+
result = await handleSessionStartHook(common, { db: db2, source: "daemon" });
|
|
1429
|
+
break;
|
|
1430
|
+
case "UserPromptSubmit": {
|
|
1431
|
+
const prompt = text(payload, "prompt") ?? text(payload, "user_prompt");
|
|
1432
|
+
if (!prompt) throw new Error("prompt required");
|
|
1433
|
+
result = await handlePromptHook({ ...common, text: prompt }, { db: db2, source: "daemon" });
|
|
1434
|
+
break;
|
|
1435
|
+
}
|
|
1436
|
+
case "PostToolUse":
|
|
1437
|
+
case "PostToolUseFailure": {
|
|
1438
|
+
const name = text(payload, "tool_name");
|
|
1439
|
+
if (!name) throw new Error("tool_name required");
|
|
1440
|
+
const outcome = toolOutcomeFromPayload({ ...payload, hook_event_name: event });
|
|
1441
|
+
const input = payload.tool_input;
|
|
1442
|
+
const path = input && typeof input === "object" && !Array.isArray(input) ? text(input, "file_path") ?? text(input, "path") : void 0;
|
|
1443
|
+
result = await handleToolHook({
|
|
1444
|
+
...common,
|
|
1445
|
+
...outcome,
|
|
1446
|
+
name,
|
|
1447
|
+
path,
|
|
1448
|
+
input_summary: input ? JSON.stringify(input).slice(0, 1024) : void 0
|
|
1449
|
+
}, { db: db2, source: "daemon" });
|
|
1450
|
+
break;
|
|
1451
|
+
}
|
|
1452
|
+
case "Stop":
|
|
1453
|
+
case "SessionEnd":
|
|
1454
|
+
result = await handleSessionEndHook({
|
|
1455
|
+
...common,
|
|
1456
|
+
last_assistant_turn: text(payload, "last_assistant_message")
|
|
1457
|
+
}, { db: db2, source: "daemon" });
|
|
1458
|
+
break;
|
|
1459
|
+
}
|
|
1460
|
+
if (event !== "SessionStart" && event !== "UserPromptSubmit") return {};
|
|
1461
|
+
const context = [
|
|
1462
|
+
result.injection ? formatInjectionContext(result.injection) : "",
|
|
1463
|
+
event === "SessionStart" && result.maintenance_backlog ? formatMaintenanceBacklogContext(result.maintenance_backlog) : "",
|
|
1464
|
+
event === "SessionStart" && result.pending_confirmations ? formatPendingConfirmationsContext(result.pending_confirmations) : ""
|
|
1465
|
+
].filter(Boolean).join("\n\n");
|
|
1466
|
+
return context ? {
|
|
1467
|
+
hookSpecificOutput: { hookEventName: event, additionalContext: context }
|
|
1468
|
+
} : {};
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1376
1471
|
// src/daemon.ts
|
|
1377
1472
|
function safeIngestMemory(memoryId) {
|
|
1378
1473
|
safeIngestMemoryById(db, memoryId);
|
|
@@ -1609,6 +1704,33 @@ function scheduleReliabilityProbeLoop() {
|
|
|
1609
1704
|
);
|
|
1610
1705
|
timer.unref?.();
|
|
1611
1706
|
}
|
|
1707
|
+
var lastReliabilityVerdict = null;
|
|
1708
|
+
var reliabilityVerdictRunning = false;
|
|
1709
|
+
function scheduleReliabilityVerdictLoop() {
|
|
1710
|
+
const config = loadReliabilityVerdictConfigFromEnv();
|
|
1711
|
+
const dataDir = reliabilityVerdictDataDir();
|
|
1712
|
+
lastReliabilityVerdict = readReliabilityVerdict(dataDir);
|
|
1713
|
+
if (!config.enabled) return;
|
|
1714
|
+
const run = async () => {
|
|
1715
|
+
if (reliabilityVerdictRunning) return;
|
|
1716
|
+
reliabilityVerdictRunning = true;
|
|
1717
|
+
try {
|
|
1718
|
+
lastReliabilityVerdict = await runReliabilityVerdictCycle(db, dataDir, {
|
|
1719
|
+
notify: config.notify ? notifyMacOS : void 0
|
|
1720
|
+
});
|
|
1721
|
+
console.log(
|
|
1722
|
+
`[recall] reliability verdict overall=${lastReliabilityVerdict.overall} fail_days=${lastReliabilityVerdict.consecutive_fail_days} sustained=${lastReliabilityVerdict.sustained_fail}`
|
|
1723
|
+
);
|
|
1724
|
+
} catch (error) {
|
|
1725
|
+
console.error(`[recall] reliability verdict failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1726
|
+
} finally {
|
|
1727
|
+
reliabilityVerdictRunning = false;
|
|
1728
|
+
}
|
|
1729
|
+
};
|
|
1730
|
+
setTimeout(() => void run(), config.delayMs).unref?.();
|
|
1731
|
+
const timer = setInterval(() => void run(), config.intervalMs);
|
|
1732
|
+
timer.unref?.();
|
|
1733
|
+
}
|
|
1612
1734
|
function runReliabilityProbeSubprocess(realEmbeddings) {
|
|
1613
1735
|
const cliPath = fileURLToPath2(new URL("./cli.js", import.meta.url));
|
|
1614
1736
|
const args = [cliPath, "reliability", "--probe"];
|
|
@@ -1654,8 +1776,10 @@ var server = createServer2(async (req, res) => {
|
|
|
1654
1776
|
return send(res, 200, {
|
|
1655
1777
|
status: "ok",
|
|
1656
1778
|
version: pkg.version,
|
|
1779
|
+
instance_id: process.env.RECALL_INSTANCE_ID ?? null,
|
|
1657
1780
|
build: recallBuildInfo,
|
|
1658
1781
|
reliability_probe: lastReliabilityProbe,
|
|
1782
|
+
reliability_verdict: lastReliabilityVerdict,
|
|
1659
1783
|
embeddings: getEmbeddingModelInfo(),
|
|
1660
1784
|
retrieval_mode: loadEmbeddingConfigFromEnv() ? "hybrid" : "lexical",
|
|
1661
1785
|
embedding_unavailable_reason: getEmbeddingUnavailableReason()
|
|
@@ -1668,8 +1792,52 @@ var server = createServer2(async (req, res) => {
|
|
|
1668
1792
|
});
|
|
1669
1793
|
}
|
|
1670
1794
|
if (path === "/update" && method === "GET") {
|
|
1795
|
+
if (process.env.RECALL_DISTRIBUTION === "mac-app-store") {
|
|
1796
|
+
return send(res, 200, {
|
|
1797
|
+
current_version: pkg.version,
|
|
1798
|
+
update_available: false,
|
|
1799
|
+
managed_by: "mac-app-store"
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1671
1802
|
return send(res, 200, await releaseChecker.check(pkg.version, url.searchParams.get("refresh") === "1"));
|
|
1672
1803
|
}
|
|
1804
|
+
if (path === "/store/memory" && method === "POST" && process.env.RECALL_DISTRIBUTION === "mac-app-store") {
|
|
1805
|
+
const body = await parseBody(req);
|
|
1806
|
+
if (typeof body.text !== "string" || !body.text.trim() || body.text.length > 8192) {
|
|
1807
|
+
return send(res, 400, { error: "A memory must contain 1 to 8192 characters." });
|
|
1808
|
+
}
|
|
1809
|
+
const repo = typeof body.repo === "string" && body.repo.trim() ? body.repo.trim() : null;
|
|
1810
|
+
const id = createMemory(db, {
|
|
1811
|
+
text: body.text.trim(),
|
|
1812
|
+
type: "rule",
|
|
1813
|
+
scope: repo ? "repo" : "global",
|
|
1814
|
+
repo,
|
|
1815
|
+
source: "user_correction",
|
|
1816
|
+
confidence: 1
|
|
1817
|
+
});
|
|
1818
|
+
safeIngestMemory(id);
|
|
1819
|
+
emit("memory.created", { memory_id: id, repo, source: "manual" });
|
|
1820
|
+
return send(res, 201, { id });
|
|
1821
|
+
}
|
|
1822
|
+
if (path.startsWith("/hook/agent/") && method === "POST") {
|
|
1823
|
+
const segments = path.split("/");
|
|
1824
|
+
const agent = segments[3];
|
|
1825
|
+
const event = segments[4];
|
|
1826
|
+
if (segments.length !== 5 || agent !== "codex" && agent !== "claude-code" || !HTTP_HOOK_EVENTS.includes(event)) {
|
|
1827
|
+
return send(res, 400, { error: "unsupported agent or hook event" });
|
|
1828
|
+
}
|
|
1829
|
+
const body = await parseBody(req);
|
|
1830
|
+
try {
|
|
1831
|
+
return send(res, 200, await handleAgentHttpHook(
|
|
1832
|
+
db,
|
|
1833
|
+
agent,
|
|
1834
|
+
event,
|
|
1835
|
+
body
|
|
1836
|
+
));
|
|
1837
|
+
} catch (error) {
|
|
1838
|
+
return send(res, 400, { error: error instanceof Error ? error.message : "invalid hook" });
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1673
1841
|
if (path === "/compile" && method === "POST") {
|
|
1674
1842
|
const body = await parseBody(req);
|
|
1675
1843
|
const repo = resolveRepo(body);
|
|
@@ -2053,21 +2221,12 @@ var server = createServer2(async (req, res) => {
|
|
|
2053
2221
|
}
|
|
2054
2222
|
if (path === "/feedback" && method === "POST") {
|
|
2055
2223
|
const body = await parseBody(req);
|
|
2056
|
-
const id =
|
|
2057
|
-
|
|
2058
|
-
body.memory_id,
|
|
2059
|
-
body.session_id,
|
|
2060
|
-
body.injected,
|
|
2061
|
-
body.outcome
|
|
2062
|
-
);
|
|
2063
|
-
createActivityEvent(db, {
|
|
2224
|
+
const { feedback_id: id } = signalOutcomeFallback(db, {
|
|
2225
|
+
memory_id: body.memory_id,
|
|
2064
2226
|
session_id: body.session_id,
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
request: { injected: body.injected, outcome: body.outcome },
|
|
2069
|
-
result: { feedback_id: id }
|
|
2070
|
-
});
|
|
2227
|
+
injected: Boolean(body.injected),
|
|
2228
|
+
outcome: body.outcome
|
|
2229
|
+
}, "daemon");
|
|
2071
2230
|
emit("feedback.recorded", {
|
|
2072
2231
|
memory_id: body.memory_id,
|
|
2073
2232
|
session_id: body.session_id,
|
|
@@ -2394,6 +2553,7 @@ async function startDaemon() {
|
|
|
2394
2553
|
scheduleCleanupLoop();
|
|
2395
2554
|
scheduleQualitySnapshotLoop();
|
|
2396
2555
|
scheduleReliabilityProbeLoop();
|
|
2556
|
+
scheduleReliabilityVerdictLoop();
|
|
2397
2557
|
});
|
|
2398
2558
|
}
|
|
2399
2559
|
void startDaemon().catch((error) => {
|