@edihasaj/recall 2.0.6 → 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.
Files changed (84) hide show
  1. package/README.md +11 -0
  2. package/dist/{chunk-AMKKCXL5.js → chunk-3LL5S473.js} +2 -2
  3. package/dist/{chunk-AR37YSEM.js → chunk-3ZA4YOFN.js} +5 -5
  4. package/dist/{chunk-N235JJB2.js → chunk-4LTGMFHN.js} +3 -3
  5. package/dist/{chunk-PMMGXYBS.js → chunk-6U7YMPBE.js} +2 -2
  6. package/dist/{chunk-QRI6W7FJ.js → chunk-BOUMOPKD.js} +2 -2
  7. package/dist/{chunk-5AM6YJ23.js → chunk-HYDNV5T2.js} +351 -139
  8. package/dist/chunk-HYDNV5T2.js.map +1 -0
  9. package/dist/{chunk-I6FOUVJ6.js → chunk-J3F3CLWL.js} +7 -7
  10. package/dist/{chunk-3MCEP2MO.js → chunk-JSKYG7TC.js} +2 -2
  11. package/dist/{chunk-LZUN3MKB.js → chunk-LOWPEB72.js} +3 -3
  12. package/dist/{chunk-5TFMHIZA.js → chunk-MD2LUEVD.js} +435 -89
  13. package/dist/chunk-MD2LUEVD.js.map +1 -0
  14. package/dist/{chunk-PWF7DAPA.js → chunk-N2ONUBXR.js} +9 -9
  15. package/dist/{chunk-FT3EEFPN.js → chunk-OHWHU653.js} +843 -144
  16. package/dist/chunk-OHWHU653.js.map +1 -0
  17. package/dist/{chunk-7L4PAEIP.js → chunk-PW42PFVO.js} +7 -7
  18. package/dist/{chunk-TKBPDASJ.js → chunk-QKGE74LD.js} +8 -5
  19. package/dist/chunk-QKGE74LD.js.map +1 -0
  20. package/dist/{chunk-X2DPMIBG.js → chunk-QOMNHKYE.js} +2 -2
  21. package/dist/{chunk-D3GBCJFT.js → chunk-RSBIISGE.js} +5 -5
  22. package/dist/{chunk-7MBCHU7J.js → chunk-URQEUH7T.js} +3 -3
  23. package/dist/{chunk-UVP6BVRD.js → chunk-VV2QPDAM.js} +2 -2
  24. package/dist/{chunk-UVP6BVRD.js.map → chunk-VV2QPDAM.js.map} +1 -1
  25. package/dist/{cleanup-MYBUBFDI.js → cleanup-QC7EHMUB.js} +11 -11
  26. package/dist/cli.js +209 -162
  27. package/dist/cli.js.map +1 -1
  28. package/dist/{codex-trust-I4EO6X2D.js → codex-trust-4RI6LCAI.js} +4 -4
  29. package/dist/daemon.js +224 -49
  30. package/dist/daemon.js.map +1 -1
  31. package/dist/dispatcher-XGATH6Q5.js +22 -0
  32. package/dist/{embeddings-RI6JOHF7.js → embeddings-RS3GK3TS.js} +5 -5
  33. package/dist/ingest-RGPV5QYT.js +20 -0
  34. package/dist/{keychain-7XUE3UOM.js → keychain-BRWB5CL5.js} +3 -3
  35. package/dist/mcp.js +15 -15
  36. package/dist/{memory-value-HFKFPQYC.js → memory-value-6KDRPDXE.js} +11 -11
  37. package/dist/{provenance-JY3NQ7DC.js → provenance-NLVTH5ZK.js} +9 -9
  38. package/dist/quality-QPRUXM4B.js +25 -0
  39. package/dist/retrieval-N5FQRL2V.js +15 -0
  40. package/dist/{store-FQ5LZXHU.js → store-DXJJ7VOQ.js} +4 -4
  41. package/dist/sync-server.js +2 -2
  42. package/dist/{tasks-NZK7VQYZ.js → tasks-32RY4KNA.js} +11 -11
  43. package/dist/{usage-KRWQUZ4G.js → usage-3EMXD6MZ.js} +4 -4
  44. package/dist/webui/assets/{GraphPage-DJhwG-72.js → GraphPage-BH_Mch3C.js} +2 -2
  45. package/dist/webui/assets/{GraphPage-DJhwG-72.js.map → GraphPage-BH_Mch3C.js.map} +1 -1
  46. package/dist/webui/assets/{index-Cpn2MjW0.js → index-CPFc-fiv.js} +25 -25
  47. package/dist/webui/assets/index-CPFc-fiv.js.map +1 -0
  48. package/dist/webui/index.html +1 -1
  49. package/package.json +1 -1
  50. package/dist/chunk-5AM6YJ23.js.map +0 -1
  51. package/dist/chunk-5TFMHIZA.js.map +0 -1
  52. package/dist/chunk-FT3EEFPN.js.map +0 -1
  53. package/dist/chunk-TKBPDASJ.js.map +0 -1
  54. package/dist/dispatcher-UMZKX2AK.js +0 -22
  55. package/dist/ingest-M5PRYMU3.js +0 -20
  56. package/dist/quality-NDTZMU34.js +0 -25
  57. package/dist/retrieval-D3BTENJX.js +0 -15
  58. package/dist/webui/assets/index-Cpn2MjW0.js.map +0 -1
  59. /package/dist/{chunk-AMKKCXL5.js.map → chunk-3LL5S473.js.map} +0 -0
  60. /package/dist/{chunk-AR37YSEM.js.map → chunk-3ZA4YOFN.js.map} +0 -0
  61. /package/dist/{chunk-N235JJB2.js.map → chunk-4LTGMFHN.js.map} +0 -0
  62. /package/dist/{chunk-PMMGXYBS.js.map → chunk-6U7YMPBE.js.map} +0 -0
  63. /package/dist/{chunk-QRI6W7FJ.js.map → chunk-BOUMOPKD.js.map} +0 -0
  64. /package/dist/{chunk-I6FOUVJ6.js.map → chunk-J3F3CLWL.js.map} +0 -0
  65. /package/dist/{chunk-3MCEP2MO.js.map → chunk-JSKYG7TC.js.map} +0 -0
  66. /package/dist/{chunk-LZUN3MKB.js.map → chunk-LOWPEB72.js.map} +0 -0
  67. /package/dist/{chunk-PWF7DAPA.js.map → chunk-N2ONUBXR.js.map} +0 -0
  68. /package/dist/{chunk-7L4PAEIP.js.map → chunk-PW42PFVO.js.map} +0 -0
  69. /package/dist/{chunk-X2DPMIBG.js.map → chunk-QOMNHKYE.js.map} +0 -0
  70. /package/dist/{chunk-D3GBCJFT.js.map → chunk-RSBIISGE.js.map} +0 -0
  71. /package/dist/{chunk-7MBCHU7J.js.map → chunk-URQEUH7T.js.map} +0 -0
  72. /package/dist/{cleanup-MYBUBFDI.js.map → cleanup-QC7EHMUB.js.map} +0 -0
  73. /package/dist/{codex-trust-I4EO6X2D.js.map → codex-trust-4RI6LCAI.js.map} +0 -0
  74. /package/dist/{dispatcher-UMZKX2AK.js.map → dispatcher-XGATH6Q5.js.map} +0 -0
  75. /package/dist/{embeddings-RI6JOHF7.js.map → embeddings-RS3GK3TS.js.map} +0 -0
  76. /package/dist/{ingest-M5PRYMU3.js.map → ingest-RGPV5QYT.js.map} +0 -0
  77. /package/dist/{keychain-7XUE3UOM.js.map → keychain-BRWB5CL5.js.map} +0 -0
  78. /package/dist/{memory-value-HFKFPQYC.js.map → memory-value-6KDRPDXE.js.map} +0 -0
  79. /package/dist/{provenance-JY3NQ7DC.js.map → provenance-NLVTH5ZK.js.map} +0 -0
  80. /package/dist/{quality-NDTZMU34.js.map → quality-QPRUXM4B.js.map} +0 -0
  81. /package/dist/{retrieval-D3BTENJX.js.map → retrieval-N5FQRL2V.js.map} +0 -0
  82. /package/dist/{store-FQ5LZXHU.js.map → store-DXJJ7VOQ.js.map} +0 -0
  83. /package/dist/{tasks-NZK7VQYZ.js.map → tasks-32RY4KNA.js.map} +0 -0
  84. /package/dist/{usage-KRWQUZ4G.js.map → usage-3EMXD6MZ.js.map} +0 -0
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  resolveCodexHomes
3
- } from "./chunk-N235JJB2.js";
4
- import "./chunk-PMMGXYBS.js";
3
+ } from "./chunk-4LTGMFHN.js";
4
+ import "./chunk-6U7YMPBE.js";
5
5
  import {
6
6
  init_define_RECALL_BUILD_INFO
7
- } from "./chunk-UVP6BVRD.js";
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-I4EO6X2D.js.map
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-D3GBCJFT.js";
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-FT3EEFPN.js";
16
- import "./chunk-N235JJB2.js";
26
+ } from "./chunk-OHWHU653.js";
27
+ import "./chunk-4LTGMFHN.js";
17
28
  import {
18
29
  createRecallMcpServer
19
- } from "./chunk-PWF7DAPA.js";
30
+ } from "./chunk-N2ONUBXR.js";
20
31
  import {
21
32
  graphQuery
22
- } from "./chunk-AR37YSEM.js";
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-5AM6YJ23.js";
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-5TFMHIZA.js";
80
- import "./chunk-7L4PAEIP.js";
81
- import "./chunk-AMKKCXL5.js";
91
+ } from "./chunk-MD2LUEVD.js";
92
+ import "./chunk-PW42PFVO.js";
93
+ import "./chunk-3LL5S473.js";
82
94
  import {
83
95
  Sentry
84
- } from "./chunk-3MCEP2MO.js";
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-I6FOUVJ6.js";
102
- import "./chunk-7MBCHU7J.js";
103
- import "./chunk-PMMGXYBS.js";
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-TKBPDASJ.js";
124
+ } from "./chunk-QKGE74LD.js";
113
125
  import {
114
126
  hasProviderConfigured,
115
127
  init_keychain
116
- } from "./chunk-X2DPMIBG.js";
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-LZUN3MKB.js";
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-QRI6W7FJ.js";
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-UVP6BVRD.js";
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, text) {
336
+ function writeText(socket, text2) {
325
337
  try {
326
- writeFrame(socket, 1, Buffer.from(text, "utf8"));
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((text) => Boolean(text) && !isGeneratedCaptureContext(text));
948
- const reviews = events.filter((event) => event.event_type === "review").map((event) => String(event.request.feedback ?? "")).filter((text) => Boolean(text) && !isGeneratedCaptureContext(text));
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(([text, count]) => `- (${count}) ${text}`);
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 text = String(event.result.text ?? "").trim();
1051
- if (!text || isGeneratedCaptureContext(text)) continue;
1052
- const durable = detectCorrections(text).filter((match) => match.type === "decision").map((match) => match.text);
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(text);
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, text) {
1064
- const normalized = text.toLowerCase().replace(/\s+/g, " ").trim();
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(text);
1093
+ decisions.push(text2);
1068
1094
  }
1069
- function extractDurablePromptDirective(text) {
1070
- const compact = text.replace(/\s+/g, " ").replace(/^[-*]\s+/, "").trim();
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;
@@ -1325,12 +1351,27 @@ var ReleaseChecker = class {
1325
1351
  };
1326
1352
  }
1327
1353
  async load() {
1354
+ const controller = new AbortController();
1355
+ let timeout;
1356
+ const deadline = new Promise((_, reject) => {
1357
+ timeout = setTimeout(() => {
1358
+ controller.abort();
1359
+ reject(new Error("release check timed out"));
1360
+ }, 8e3);
1361
+ });
1362
+ try {
1363
+ return await Promise.race([this.loadRelease(controller.signal), deadline]);
1364
+ } finally {
1365
+ clearTimeout(timeout);
1366
+ }
1367
+ }
1368
+ async loadRelease(signal) {
1328
1369
  const response = await this.fetchRelease(RELEASE_API, {
1329
1370
  headers: {
1330
1371
  Accept: "application/vnd.github+json",
1331
1372
  "User-Agent": "recall-update-check"
1332
1373
  },
1333
- signal: AbortSignal.timeout(8e3)
1374
+ signal
1334
1375
  });
1335
1376
  if (!response.ok) throw new Error(`release API returned ${response.status}`);
1336
1377
  const raw = await response.json();
@@ -1358,6 +1399,75 @@ var ReleaseChecker = class {
1358
1399
  };
1359
1400
  var releaseChecker = new ReleaseChecker();
1360
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
+
1361
1471
  // src/daemon.ts
1362
1472
  function safeIngestMemory(memoryId) {
1363
1473
  safeIngestMemoryById(db, memoryId);
@@ -1594,6 +1704,33 @@ function scheduleReliabilityProbeLoop() {
1594
1704
  );
1595
1705
  timer.unref?.();
1596
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
+ }
1597
1734
  function runReliabilityProbeSubprocess(realEmbeddings) {
1598
1735
  const cliPath = fileURLToPath2(new URL("./cli.js", import.meta.url));
1599
1736
  const args = [cliPath, "reliability", "--probe"];
@@ -1639,8 +1776,10 @@ var server = createServer2(async (req, res) => {
1639
1776
  return send(res, 200, {
1640
1777
  status: "ok",
1641
1778
  version: pkg.version,
1779
+ instance_id: process.env.RECALL_INSTANCE_ID ?? null,
1642
1780
  build: recallBuildInfo,
1643
1781
  reliability_probe: lastReliabilityProbe,
1782
+ reliability_verdict: lastReliabilityVerdict,
1644
1783
  embeddings: getEmbeddingModelInfo(),
1645
1784
  retrieval_mode: loadEmbeddingConfigFromEnv() ? "hybrid" : "lexical",
1646
1785
  embedding_unavailable_reason: getEmbeddingUnavailableReason()
@@ -1653,8 +1792,52 @@ var server = createServer2(async (req, res) => {
1653
1792
  });
1654
1793
  }
1655
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
+ }
1656
1802
  return send(res, 200, await releaseChecker.check(pkg.version, url.searchParams.get("refresh") === "1"));
1657
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
+ }
1658
1841
  if (path === "/compile" && method === "POST") {
1659
1842
  const body = await parseBody(req);
1660
1843
  const repo = resolveRepo(body);
@@ -2038,21 +2221,12 @@ var server = createServer2(async (req, res) => {
2038
2221
  }
2039
2222
  if (path === "/feedback" && method === "POST") {
2040
2223
  const body = await parseBody(req);
2041
- const id = recordFeedback(
2042
- db,
2043
- body.memory_id,
2044
- body.session_id,
2045
- body.injected,
2046
- body.outcome
2047
- );
2048
- createActivityEvent(db, {
2224
+ const { feedback_id: id } = signalOutcomeFallback(db, {
2225
+ memory_id: body.memory_id,
2049
2226
  session_id: body.session_id,
2050
- source: "daemon",
2051
- event_type: "feedback",
2052
- memory_ids: [body.memory_id],
2053
- request: { injected: body.injected, outcome: body.outcome },
2054
- result: { feedback_id: id }
2055
- });
2227
+ injected: Boolean(body.injected),
2228
+ outcome: body.outcome
2229
+ }, "daemon");
2056
2230
  emit("feedback.recorded", {
2057
2231
  memory_id: body.memory_id,
2058
2232
  session_id: body.session_id,
@@ -2379,6 +2553,7 @@ async function startDaemon() {
2379
2553
  scheduleCleanupLoop();
2380
2554
  scheduleQualitySnapshotLoop();
2381
2555
  scheduleReliabilityProbeLoop();
2556
+ scheduleReliabilityVerdictLoop();
2382
2557
  });
2383
2558
  }
2384
2559
  void startDaemon().catch((error) => {