agent-nuvira 3.3.7 → 3.3.9

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 (257) hide show
  1. package/README.md +57 -50
  2. package/dist/agents/agents/planner.d.ts.map +1 -1
  3. package/dist/agents/agents/planner.js +41 -0
  4. package/dist/agents/agents/planner.js.map +1 -1
  5. package/dist/agents/agents/reasoner.d.ts.map +1 -1
  6. package/dist/agents/agents/reasoner.js +6 -0
  7. package/dist/agents/agents/reasoner.js.map +1 -1
  8. package/dist/agents/agents/runner.d.ts +6 -0
  9. package/dist/agents/agents/runner.d.ts.map +1 -1
  10. package/dist/agents/agents/runner.js +82 -5
  11. package/dist/agents/agents/runner.js.map +1 -1
  12. package/dist/agents/agents/writer-tool-calling.d.ts.map +1 -1
  13. package/dist/agents/agents/writer-tool-calling.js +5 -2
  14. package/dist/agents/agents/writer-tool-calling.js.map +1 -1
  15. package/dist/agents/agents/writer.d.ts.map +1 -1
  16. package/dist/agents/agents/writer.js +8 -4
  17. package/dist/agents/agents/writer.js.map +1 -1
  18. package/dist/agents/fanout-scheduler.d.ts +72 -0
  19. package/dist/agents/fanout-scheduler.d.ts.map +1 -0
  20. package/dist/agents/fanout-scheduler.js +100 -0
  21. package/dist/agents/fanout-scheduler.js.map +1 -0
  22. package/dist/agents/orchestrator.d.ts.map +1 -1
  23. package/dist/agents/orchestrator.js +30 -1
  24. package/dist/agents/orchestrator.js.map +1 -1
  25. package/dist/agents/plan-quality.d.ts +58 -0
  26. package/dist/agents/plan-quality.d.ts.map +1 -0
  27. package/dist/agents/plan-quality.js +152 -0
  28. package/dist/agents/plan-quality.js.map +1 -0
  29. package/dist/agents/prompt-assembly.d.ts +8 -0
  30. package/dist/agents/prompt-assembly.d.ts.map +1 -1
  31. package/dist/agents/prompt-assembly.js +18 -0
  32. package/dist/agents/prompt-assembly.js.map +1 -1
  33. package/dist/agents/step-handoff.d.ts +12 -2
  34. package/dist/agents/step-handoff.d.ts.map +1 -1
  35. package/dist/agents/step-handoff.js +65 -8
  36. package/dist/agents/step-handoff.js.map +1 -1
  37. package/dist/agents/tool-calling-agent.d.ts.map +1 -1
  38. package/dist/agents/tool-calling-agent.js +18 -0
  39. package/dist/agents/tool-calling-agent.js.map +1 -1
  40. package/dist/cli/cache.d.ts.map +1 -1
  41. package/dist/cli/cache.js +34 -4
  42. package/dist/cli/cache.js.map +1 -1
  43. package/dist/cli/chat.d.ts +6 -0
  44. package/dist/cli/chat.d.ts.map +1 -1
  45. package/dist/cli/chat.js +79 -18
  46. package/dist/cli/chat.js.map +1 -1
  47. package/dist/cli/cli-program.d.ts.map +1 -1
  48. package/dist/cli/cli-program.js +6 -0
  49. package/dist/cli/cli-program.js.map +1 -1
  50. package/dist/cli/config.d.ts +10 -0
  51. package/dist/cli/config.d.ts.map +1 -1
  52. package/dist/cli/config.js +179 -1
  53. package/dist/cli/config.js.map +1 -1
  54. package/dist/cli/continuity.d.ts +61 -0
  55. package/dist/cli/continuity.d.ts.map +1 -0
  56. package/dist/cli/continuity.js +112 -0
  57. package/dist/cli/continuity.js.map +1 -0
  58. package/dist/cli/dashboard.d.ts +3 -1
  59. package/dist/cli/dashboard.d.ts.map +1 -1
  60. package/dist/cli/dashboard.js +5 -16
  61. package/dist/cli/dashboard.js.map +1 -1
  62. package/dist/cli/doctor.d.ts.map +1 -1
  63. package/dist/cli/doctor.js +48 -1
  64. package/dist/cli/doctor.js.map +1 -1
  65. package/dist/cli/execute.d.ts +8 -0
  66. package/dist/cli/execute.d.ts.map +1 -1
  67. package/dist/cli/execute.js +34 -1
  68. package/dist/cli/execute.js.map +1 -1
  69. package/dist/cli/loop-executor.d.ts +24 -0
  70. package/dist/cli/loop-executor.d.ts.map +1 -1
  71. package/dist/cli/loop-executor.js +134 -13
  72. package/dist/cli/loop-executor.js.map +1 -1
  73. package/dist/cli/website.d.ts +25 -0
  74. package/dist/cli/website.d.ts.map +1 -0
  75. package/dist/cli/website.js +58 -0
  76. package/dist/cli/website.js.map +1 -0
  77. package/dist/config/manager.d.ts.map +1 -1
  78. package/dist/config/manager.js +35 -0
  79. package/dist/config/manager.js.map +1 -1
  80. package/dist/config/process-env.d.ts.map +1 -1
  81. package/dist/config/process-env.js +20 -0
  82. package/dist/config/process-env.js.map +1 -1
  83. package/dist/config/provider-env.d.ts +2 -1
  84. package/dist/config/provider-env.d.ts.map +1 -1
  85. package/dist/config/provider-env.js +19 -2
  86. package/dist/config/provider-env.js.map +1 -1
  87. package/dist/config/service-catalog.d.ts +81 -0
  88. package/dist/config/service-catalog.d.ts.map +1 -0
  89. package/dist/config/service-catalog.js +286 -0
  90. package/dist/config/service-catalog.js.map +1 -0
  91. package/dist/config/service-probe.d.ts +27 -0
  92. package/dist/config/service-probe.d.ts.map +1 -0
  93. package/dist/config/service-probe.js +104 -0
  94. package/dist/config/service-probe.js.map +1 -0
  95. package/dist/config/types.d.ts +63 -0
  96. package/dist/config/types.d.ts.map +1 -1
  97. package/dist/context/cache.d.ts +46 -2
  98. package/dist/context/cache.d.ts.map +1 -1
  99. package/dist/context/cache.js +85 -7
  100. package/dist/context/cache.js.map +1 -1
  101. package/dist/findings/verdicts.d.ts +59 -0
  102. package/dist/findings/verdicts.d.ts.map +1 -1
  103. package/dist/findings/verdicts.js +117 -0
  104. package/dist/findings/verdicts.js.map +1 -1
  105. package/dist/forwarded.d.ts +2 -0
  106. package/dist/forwarded.d.ts.map +1 -0
  107. package/dist/forwarded.js +2 -0
  108. package/dist/forwarded.js.map +1 -0
  109. package/dist/gateway/registry.d.ts.map +1 -1
  110. package/dist/gateway/registry.js +9 -0
  111. package/dist/gateway/registry.js.map +1 -1
  112. package/dist/learning/auto-router.d.ts +30 -0
  113. package/dist/learning/auto-router.d.ts.map +1 -1
  114. package/dist/learning/auto-router.js +69 -12
  115. package/dist/learning/auto-router.js.map +1 -1
  116. package/dist/learning/context-assembly.d.ts +37 -0
  117. package/dist/learning/context-assembly.d.ts.map +1 -0
  118. package/dist/learning/context-assembly.js +63 -0
  119. package/dist/learning/context-assembly.js.map +1 -0
  120. package/dist/learning/reasoning-trace.d.ts +26 -5
  121. package/dist/learning/reasoning-trace.d.ts.map +1 -1
  122. package/dist/learning/reasoning-trace.js +21 -1
  123. package/dist/learning/reasoning-trace.js.map +1 -1
  124. package/dist/learning/session-digest.d.ts +78 -0
  125. package/dist/learning/session-digest.d.ts.map +1 -0
  126. package/dist/learning/session-digest.js +185 -0
  127. package/dist/learning/session-digest.js.map +1 -0
  128. package/dist/learning/session-recall.d.ts +135 -0
  129. package/dist/learning/session-recall.d.ts.map +1 -0
  130. package/dist/learning/session-recall.js +305 -0
  131. package/dist/learning/session-recall.js.map +1 -0
  132. package/dist/learning/session-store.d.ts +172 -0
  133. package/dist/learning/session-store.d.ts.map +1 -0
  134. package/dist/learning/session-store.js +424 -0
  135. package/dist/learning/session-store.js.map +1 -0
  136. package/dist/learning/step-checkpoint.d.ts +28 -0
  137. package/dist/learning/step-checkpoint.d.ts.map +1 -1
  138. package/dist/learning/step-checkpoint.js +90 -6
  139. package/dist/learning/step-checkpoint.js.map +1 -1
  140. package/dist/learning/working-state.d.ts +19 -0
  141. package/dist/learning/working-state.d.ts.map +1 -1
  142. package/dist/learning/working-state.js +34 -1
  143. package/dist/learning/working-state.js.map +1 -1
  144. package/dist/parity/drivers.d.ts.map +1 -1
  145. package/dist/parity/drivers.js +29 -0
  146. package/dist/parity/drivers.js.map +1 -1
  147. package/dist/parity/wire-fixtures.d.ts +88 -0
  148. package/dist/parity/wire-fixtures.d.ts.map +1 -0
  149. package/dist/parity/wire-fixtures.js +405 -0
  150. package/dist/parity/wire-fixtures.js.map +1 -0
  151. package/dist/tools/artifact-append.d.ts +23 -0
  152. package/dist/tools/artifact-append.d.ts.map +1 -1
  153. package/dist/tools/artifact-append.js +28 -0
  154. package/dist/tools/artifact-append.js.map +1 -1
  155. package/dist/tools/ask-user.d.ts +5 -0
  156. package/dist/tools/ask-user.d.ts.map +1 -1
  157. package/dist/tools/ask-user.js +51 -5
  158. package/dist/tools/ask-user.js.map +1 -1
  159. package/dist/tools/child-agent-entry.js +1 -0
  160. package/dist/tools/child-agent-entry.js.map +1 -1
  161. package/dist/tools/child-agent-runtime.d.ts +7 -0
  162. package/dist/tools/child-agent-runtime.d.ts.map +1 -1
  163. package/dist/tools/child-agent-runtime.js +116 -6
  164. package/dist/tools/child-agent-runtime.js.map +1 -1
  165. package/dist/tools/child-agent-worker.d.ts +15 -0
  166. package/dist/tools/child-agent-worker.d.ts.map +1 -0
  167. package/dist/tools/child-agent-worker.js.map +1 -0
  168. package/dist/tools/coding-tools.d.ts.map +1 -1
  169. package/dist/tools/coding-tools.js +11 -0
  170. package/dist/tools/coding-tools.js.map +1 -1
  171. package/dist/tools/finding-tool.d.ts +6 -1
  172. package/dist/tools/finding-tool.d.ts.map +1 -1
  173. package/dist/tools/finding-tool.js +15 -2
  174. package/dist/tools/finding-tool.js.map +1 -1
  175. package/dist/tools/followup-utils.d.ts +35 -0
  176. package/dist/tools/followup-utils.d.ts.map +1 -1
  177. package/dist/tools/followup-utils.js +36 -0
  178. package/dist/tools/followup-utils.js.map +1 -1
  179. package/dist/tools/loop-project-context.d.ts +4 -1
  180. package/dist/tools/loop-project-context.d.ts.map +1 -1
  181. package/dist/tools/loop-project-context.js +48 -1
  182. package/dist/tools/loop-project-context.js.map +1 -1
  183. package/dist/tools/loop-skill-hint.d.ts.map +1 -1
  184. package/dist/tools/loop-skill-hint.js +7 -0
  185. package/dist/tools/loop-skill-hint.js.map +1 -1
  186. package/dist/tools/modality/image-gen.d.ts +25 -6
  187. package/dist/tools/modality/image-gen.d.ts.map +1 -1
  188. package/dist/tools/modality/image-gen.js +46 -27
  189. package/dist/tools/modality/image-gen.js.map +1 -1
  190. package/dist/tools/modality/image-providers.d.ts +71 -0
  191. package/dist/tools/modality/image-providers.d.ts.map +1 -0
  192. package/dist/tools/modality/image-providers.js +277 -0
  193. package/dist/tools/modality/image-providers.js.map +1 -0
  194. package/dist/tools/registry.d.ts +10 -1
  195. package/dist/tools/registry.d.ts.map +1 -1
  196. package/dist/tools/registry.js +35 -8
  197. package/dist/tools/registry.js.map +1 -1
  198. package/dist/tools/run-cli.d.ts.map +1 -1
  199. package/dist/tools/run-cli.js +39 -1
  200. package/dist/tools/run-cli.js.map +1 -1
  201. package/dist/tools/run-terminal.d.ts.map +1 -1
  202. package/dist/tools/run-terminal.js +50 -6
  203. package/dist/tools/run-terminal.js.map +1 -1
  204. package/dist/tools/subagent-spawner.d.ts +8 -0
  205. package/dist/tools/subagent-spawner.d.ts.map +1 -1
  206. package/dist/tools/subagent-spawner.js +3 -0
  207. package/dist/tools/subagent-spawner.js.map +1 -1
  208. package/dist/tools/tool-loop.d.ts +55 -0
  209. package/dist/tools/tool-loop.d.ts.map +1 -1
  210. package/dist/tools/tool-loop.js +136 -0
  211. package/dist/tools/tool-loop.js.map +1 -1
  212. package/dist/tools/untrusted-content.d.ts +29 -0
  213. package/dist/tools/untrusted-content.d.ts.map +1 -0
  214. package/dist/tools/untrusted-content.js +53 -0
  215. package/dist/tools/untrusted-content.js.map +1 -0
  216. package/dist/tools/web-research.d.ts +76 -14
  217. package/dist/tools/web-research.d.ts.map +1 -1
  218. package/dist/tools/web-research.js +280 -35
  219. package/dist/tools/web-research.js.map +1 -1
  220. package/dist/utils/effect-verification.d.ts +115 -0
  221. package/dist/utils/effect-verification.d.ts.map +1 -0
  222. package/dist/utils/effect-verification.js +337 -0
  223. package/dist/utils/effect-verification.js.map +1 -0
  224. package/dist/utils/open-url.d.ts +16 -0
  225. package/dist/utils/open-url.d.ts.map +1 -0
  226. package/dist/utils/open-url.js +32 -0
  227. package/dist/utils/open-url.js.map +1 -0
  228. package/dist/utils/project-env.d.ts +146 -0
  229. package/dist/utils/project-env.d.ts.map +1 -0
  230. package/dist/utils/project-env.js +584 -0
  231. package/dist/utils/project-env.js.map +1 -0
  232. package/dist/utils/shell.d.ts +7 -0
  233. package/dist/utils/shell.d.ts.map +1 -1
  234. package/dist/utils/shell.js +2 -0
  235. package/dist/utils/shell.js.map +1 -1
  236. package/dist/web-dashboard/chat-console.d.ts +2 -0
  237. package/dist/web-dashboard/chat-console.d.ts.map +1 -1
  238. package/dist/web-dashboard/chat-console.js +7 -0
  239. package/dist/web-dashboard/chat-console.js.map +1 -1
  240. package/dist/web-dashboard/server.d.ts +3 -1
  241. package/dist/web-dashboard/server.d.ts.map +1 -1
  242. package/dist/web-dashboard/server.js +534 -8
  243. package/dist/web-dashboard/server.js.map +1 -1
  244. package/dist/web-dashboard/src/types.d.ts +150 -1
  245. package/dist/web-dashboard/src/types.d.ts.map +1 -1
  246. package/dist/web-dashboard/workspace-guard.d.ts +40 -0
  247. package/dist/web-dashboard/workspace-guard.d.ts.map +1 -0
  248. package/dist/web-dashboard/workspace-guard.js +92 -0
  249. package/dist/web-dashboard/workspace-guard.js.map +1 -0
  250. package/package.json +4 -1
  251. package/src/web-dashboard/public/assets/index-Beportyl.js +207 -0
  252. package/src/web-dashboard/public/assets/index-Beportyl.js.map +1 -0
  253. package/src/web-dashboard/public/assets/index-gtQyg9nm.css +1 -0
  254. package/src/web-dashboard/public/index.html +2 -2
  255. package/src/web-dashboard/public/assets/index-D1YFCcIZ.js +0 -207
  256. package/src/web-dashboard/public/assets/index-D1YFCcIZ.js.map +0 -1
  257. package/src/web-dashboard/public/assets/index-jkW5qcf-.css +0 -1
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Session digest — the per-project memory of what RECENT ASKS did, across
3
+ * sessions (Phase 4 / G6, the DETERMINISTIC branch).
4
+ *
5
+ * WHY THIS EXISTS (and why it is not an LLM summary)
6
+ * ---------------------------------------------------
7
+ * Two continuity needs sit next to each other:
8
+ * - `working-state.ts` remembers the WORK (files touched, verification debt,
9
+ * user-reported regressions) but NOT what was ASKED or how it ended; and
10
+ * - a cross-session "what happened recently" memory, which the plan flagged as
11
+ * a possible LLM-compaction target.
12
+ *
13
+ * The plan left that second one as an OPEN DECISION (LLM summary vs deterministic).
14
+ * This module makes the DETERMINISTIC choice, deliberately:
15
+ * - a model-written summary can assert "the build works" and re-introduce the
16
+ * exact false-success class Parts 1/2 closed;
17
+ * - a digest of FACTS (goal, outcome, tools, whether anything was verified)
18
+ * cannot lie about completion because it does not judge it.
19
+ *
20
+ * So the digest is ADVISORY CONTEXT ONLY. It is never read to decide whether a
21
+ * step is done — completion still derives from artifacts on disk. A test pins
22
+ * that (a digest claiming success cannot flip a completion).
23
+ *
24
+ * Deterministic, LLM-free, best-effort (never throws), and bounded so it adds a
25
+ * fixed, small weight to the prompt.
26
+ */
27
+ /** One finished turn, as recorded by the caller. */
28
+ export interface SessionTurn {
29
+ /** Epoch ms the turn ended. */
30
+ at: number;
31
+ /** The ask, truncated. */
32
+ goal: string;
33
+ /** The turn's outcome kind (`acted` / `incomplete` / `failed` / `cancelled`). */
34
+ outcome: string;
35
+ /** Tools that ran (deduped, capped). */
36
+ tools: string[];
37
+ /** A verification tool ran successfully this turn. */
38
+ verified: boolean;
39
+ }
40
+ /** What a caller records when a turn ends. */
41
+ export interface SessionTurnInput {
42
+ projectPath: string;
43
+ goal: string;
44
+ outcome: string;
45
+ tools?: readonly string[];
46
+ verified?: boolean;
47
+ }
48
+ export interface ProjectSessionDigest {
49
+ projectPath: string;
50
+ /** Newest last. */
51
+ turns: SessionTurn[];
52
+ updatedAt: number;
53
+ }
54
+ /** Cap on remembered turns per project (oldest drop first). */
55
+ export declare const MAX_TURNS = 12;
56
+ /** Cap on remembered tools per turn. */
57
+ export declare const MAX_TOOLS_PER_TURN = 8;
58
+ /** Cap on the goal text kept per turn. */
59
+ export declare const MAX_GOAL_CHARS = 160;
60
+ /** Cap on the rendered block — it rides in prompts, so it stays small. */
61
+ export declare const MAX_BLOCK_CHARS = 1600;
62
+ /**
63
+ * Record a finished turn and return the updated digest. Best-effort: never throws.
64
+ */
65
+ export declare function recordSessionTurn(input: SessionTurnInput): ProjectSessionDigest;
66
+ /** Read one project's digest, or null. */
67
+ export declare function getSessionDigest(projectPath: string): ProjectSessionDigest | null;
68
+ /**
69
+ * Format a project's digest as a bounded, model-readable block ('' when there is
70
+ * nothing to show — a clean project adds no prompt weight).
71
+ *
72
+ * ADVISORY ONLY: the header says outright that this is history, not a status —
73
+ * so a model cannot read an old "completed" line as proof the work is done now.
74
+ */
75
+ export declare function formatSessionDigest(projectPath: string, now?: number): string;
76
+ /** Forget one project's digest. */
77
+ export declare function clearSessionDigest(projectPath: string): void;
78
+ //# sourceMappingURL=session-digest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-digest.d.ts","sourceRoot":"","sources":["../../src/learning/session-digest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAMH,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,+BAA+B;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,sDAAsD;IACtD,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB;IACnB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAUD,+DAA+D;AAC/D,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,wCAAwC;AACxC,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,0CAA0C;AAC1C,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,0EAA0E;AAC1E,eAAO,MAAM,eAAe,OAAQ,CAAC;AAmDrC;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,oBAAoB,CA8B/E;AAED,0CAA0C;AAC1C,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CAMjF;AAYD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,GAAE,MAAmB,GAAG,MAAM,CAqBzF;AAED,mCAAmC;AACnC,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAU5D"}
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Session digest — the per-project memory of what RECENT ASKS did, across
3
+ * sessions (Phase 4 / G6, the DETERMINISTIC branch).
4
+ *
5
+ * WHY THIS EXISTS (and why it is not an LLM summary)
6
+ * ---------------------------------------------------
7
+ * Two continuity needs sit next to each other:
8
+ * - `working-state.ts` remembers the WORK (files touched, verification debt,
9
+ * user-reported regressions) but NOT what was ASKED or how it ended; and
10
+ * - a cross-session "what happened recently" memory, which the plan flagged as
11
+ * a possible LLM-compaction target.
12
+ *
13
+ * The plan left that second one as an OPEN DECISION (LLM summary vs deterministic).
14
+ * This module makes the DETERMINISTIC choice, deliberately:
15
+ * - a model-written summary can assert "the build works" and re-introduce the
16
+ * exact false-success class Parts 1/2 closed;
17
+ * - a digest of FACTS (goal, outcome, tools, whether anything was verified)
18
+ * cannot lie about completion because it does not judge it.
19
+ *
20
+ * So the digest is ADVISORY CONTEXT ONLY. It is never read to decide whether a
21
+ * step is done — completion still derives from artifacts on disk. A test pins
22
+ * that (a digest claiming success cannot flip a completion).
23
+ *
24
+ * Deterministic, LLM-free, best-effort (never throws), and bounded so it adds a
25
+ * fixed, small weight to the prompt.
26
+ */
27
+ import { envBuff, resolveNuviraHome } from '../config/paths.js';
28
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
29
+ import { join, resolve } from 'node:path';
30
+ // ─── Constants ──────────────────────────────────────────────────────────────
31
+ const CURRENT_VERSION = 1;
32
+ /** Cap on remembered turns per project (oldest drop first). */
33
+ export const MAX_TURNS = 12;
34
+ /** Cap on remembered tools per turn. */
35
+ export const MAX_TOOLS_PER_TURN = 8;
36
+ /** Cap on the goal text kept per turn. */
37
+ export const MAX_GOAL_CHARS = 160;
38
+ /** Cap on the rendered block — it rides in prompts, so it stays small. */
39
+ export const MAX_BLOCK_CHARS = 1_600;
40
+ /** Turns shown in the block (newest last). */
41
+ const SHOWN_TURNS = 8;
42
+ // ─── Storage ────────────────────────────────────────────────────────────────
43
+ function memoryDir() {
44
+ return envBuff('MEMORY_DIR') || join(resolveNuviraHome(), 'memory');
45
+ }
46
+ function storePath() {
47
+ return join(memoryDir(), 'session-digests.json');
48
+ }
49
+ function normalizeProjectPath(projectPath) {
50
+ try {
51
+ return resolve(projectPath);
52
+ }
53
+ catch {
54
+ return projectPath;
55
+ }
56
+ }
57
+ function readFileSafe() {
58
+ try {
59
+ if (!existsSync(storePath()))
60
+ return { version: CURRENT_VERSION, projects: {} };
61
+ const data = JSON.parse(readFileSync(storePath(), 'utf-8'));
62
+ if (!data || typeof data !== 'object' || !data.projects || typeof data.projects !== 'object') {
63
+ return { version: CURRENT_VERSION, projects: {} };
64
+ }
65
+ return data;
66
+ }
67
+ catch {
68
+ return { version: CURRENT_VERSION, projects: {} };
69
+ }
70
+ }
71
+ function writeFileSafe(data) {
72
+ try {
73
+ if (!existsSync(memoryDir()))
74
+ mkdirSync(memoryDir(), { recursive: true });
75
+ writeFileSync(storePath(), JSON.stringify(data, null, 2), 'utf-8');
76
+ }
77
+ catch {
78
+ // Best-effort — a digest write must never break a turn.
79
+ }
80
+ }
81
+ function clip(text, max) {
82
+ const flat = (text || '').replace(/\s+/g, ' ').trim();
83
+ return flat.length > max ? `${flat.slice(0, max - 1)}…` : flat;
84
+ }
85
+ // ─── API ────────────────────────────────────────────────────────────────────
86
+ /**
87
+ * Record a finished turn and return the updated digest. Best-effort: never throws.
88
+ */
89
+ export function recordSessionTurn(input) {
90
+ const projectPath = normalizeProjectPath(input.projectPath);
91
+ const now = Date.now();
92
+ try {
93
+ const data = readFileSafe();
94
+ const prev = data.projects[projectPath] ?? {
95
+ projectPath,
96
+ turns: [],
97
+ updatedAt: now,
98
+ };
99
+ const tools = [...new Set((input.tools ?? []).filter((t) => typeof t === 'string' && t))].slice(0, MAX_TOOLS_PER_TURN);
100
+ const turn = {
101
+ at: now,
102
+ goal: clip(input.goal, MAX_GOAL_CHARS),
103
+ outcome: clip(input.outcome || 'unknown', 24),
104
+ tools,
105
+ verified: input.verified === true,
106
+ };
107
+ const turns = [...prev.turns, turn];
108
+ if (turns.length > MAX_TURNS)
109
+ turns.splice(0, turns.length - MAX_TURNS);
110
+ const next = { projectPath, turns, updatedAt: now };
111
+ data.projects[projectPath] = next;
112
+ writeFileSafe(data);
113
+ return next;
114
+ }
115
+ catch {
116
+ return { projectPath, turns: [], updatedAt: now };
117
+ }
118
+ }
119
+ /** Read one project's digest, or null. */
120
+ export function getSessionDigest(projectPath) {
121
+ try {
122
+ return readFileSafe().projects[normalizeProjectPath(projectPath)] ?? null;
123
+ }
124
+ catch {
125
+ return null;
126
+ }
127
+ }
128
+ /** Relative age, spelled for a human reader. */
129
+ function relativeAge(ts, now) {
130
+ const mins = Math.max(0, Math.round((now - ts) / 60_000));
131
+ if (mins < 1)
132
+ return 'just now';
133
+ if (mins < 60)
134
+ return `${mins}m ago`;
135
+ const hours = Math.round(mins / 60);
136
+ if (hours < 24)
137
+ return `${hours}h ago`;
138
+ return `${Math.round(hours / 24)}d ago`;
139
+ }
140
+ /**
141
+ * Format a project's digest as a bounded, model-readable block ('' when there is
142
+ * nothing to show — a clean project adds no prompt weight).
143
+ *
144
+ * ADVISORY ONLY: the header says outright that this is history, not a status —
145
+ * so a model cannot read an old "completed" line as proof the work is done now.
146
+ */
147
+ export function formatSessionDigest(projectPath, now = Date.now()) {
148
+ try {
149
+ const digest = getSessionDigest(projectPath);
150
+ if (!digest || digest.turns.length === 0)
151
+ return '';
152
+ const shown = digest.turns.slice(-SHOWN_TURNS);
153
+ const lines = [
154
+ '[Recent sessions in THIS project — history for context only. This is NOT a status of the current work; verify artifacts on disk before assuming anything is done.]',
155
+ ];
156
+ for (const turn of shown) {
157
+ const verified = turn.verified ? ', verified' : '';
158
+ const tools = turn.tools.length > 0 ? ` (tools: ${turn.tools.join(', ')}${verified})` : verified ? ` (${verified.slice(2)})` : '';
159
+ lines.push(`• ${relativeAge(turn.at, now)} — ${turn.outcome}: "${turn.goal}"${tools}`);
160
+ }
161
+ let block = lines.join('\n');
162
+ if (block.length > MAX_BLOCK_CHARS) {
163
+ block = `${block.slice(0, MAX_BLOCK_CHARS)}\n[digest truncated to fit the context budget]`;
164
+ }
165
+ return block;
166
+ }
167
+ catch {
168
+ return '';
169
+ }
170
+ }
171
+ /** Forget one project's digest. */
172
+ export function clearSessionDigest(projectPath) {
173
+ try {
174
+ const data = readFileSafe();
175
+ const key = normalizeProjectPath(projectPath);
176
+ if (!(key in data.projects))
177
+ return;
178
+ delete data.projects[key];
179
+ writeFileSafe(data);
180
+ }
181
+ catch {
182
+ // Best-effort.
183
+ }
184
+ }
185
+ //# sourceMappingURL=session-digest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-digest.js","sourceRoot":"","sources":["../../src/learning/session-digest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqC1C,+EAA+E;AAE/E,MAAM,eAAe,GAAG,CAAC,CAAC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Y,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAClI,KAAK,CAAC,IAAI,CAAC,KAAK,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,MAAM,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;QACzF,CAAC;QACD,IAAI,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,KAAK,CAAC,MAAM,GAAG,eAAe,EAAE,CAAC;YACnC,KAAK,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC,gDAAgD,CAAC;QAC7F,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,mCAAmC;AACnC,MAAM,UAAU,kBAAkB,CAAC,WAAmB;IACpD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,YAAY,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;QAC9C,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC;YAAE,OAAO;QACpC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC1B,aAAa,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,eAAe;IACjB,CAAC;AACH,CAAC"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Session recall (Phase 4 follow-on) — SEMANTIC recall across past asks.
3
+ *
4
+ * WHY THIS EXISTS, AND WHY IT IS OPT-IN.
5
+ * The deterministic session digest (`session-digest.ts`) shows the LAST few asks
6
+ * in a project. That is good for continuity, but it is recency-based: an ask from
7
+ * three weeks ago about the SAME subject is invisible if ten unrelated asks
8
+ * happened since. This module adds *semantic* recall — embed each finished ask,
9
+ * and at the start of a new turn retrieve the past asks that mean the same thing,
10
+ * above an explicit cosine THRESHOLD, so relevance is by meaning rather than by
11
+ * a literal token overlap (`goalsLookSame`) or by recency.
12
+ *
13
+ * It is deliberately OFF unless asked for (`NUVIRA_SESSION_RECALL=1`). Semantics
14
+ * introduce an embedding dependency whose tiers can be slow to fail over; a
15
+ * feature that makes an ordinary turn wait on a model download would be a worse
16
+ * bug than the recall it buys. So, exactly like `--resume`, an ordinary run pays
17
+ * nothing: no read, no embed, no query.
18
+ *
19
+ * WHY IT CANNOT RE-OPEN FALSE SUCCESS. A recalled ask is HISTORY, presented as
20
+ * however it ENDED (`acted` / `incomplete` / `failed` / `cancelled`) — never as a
21
+ * completion the current work inherits. The block says so outright, and nothing
22
+ * here is read to decide whether a step is done: completion still derives from
23
+ * artifacts on disk. A recalled "the build works" is a sentence the past model
24
+ * wrote, quoted, not a fact the framework adopts.
25
+ *
26
+ * Bounded + best-effort throughout: a fixed entry cap, a fixed top-k, a fixed
27
+ * block size, and every read/write/embed wrapped so a corrupt index or a missing
28
+ * embedding tier degrades to "no recall", never a broken turn.
29
+ */
30
+ /** The environment key that turns semantic recall on (`1`/`true`/`yes`). */
31
+ export declare const SESSION_RECALL_ENV = "NUVIRA_SESSION_RECALL";
32
+ /** Cosine floor a past ask must clear to be recalled (0-1). */
33
+ export declare const DEFAULT_RECALL_THRESHOLD = 0.5;
34
+ /** How many past asks to surface at most. */
35
+ export declare const DEFAULT_RECALL_TOP_K = 3;
36
+ /** Hard cap on the index (oldest dropped) — recall must never grow unbounded. */
37
+ export declare const MAX_INDEX_ENTRIES = 500;
38
+ /** Hard cap on the rendered block — it rides in prompts. */
39
+ export declare const MAX_RECALL_BLOCK_CHARS = 1200;
40
+ /** An embedding function (injectable for tests / deterministic callers). */
41
+ export type EmbedFn = (text: string) => Promise<number[]>;
42
+ /** One indexed past ask. */
43
+ export interface RecallEntry {
44
+ id: string;
45
+ projectPath: string;
46
+ goal: string;
47
+ outcome: string;
48
+ savedAt: number;
49
+ vector: number[];
50
+ }
51
+ /** A recalled past ask with its similarity. */
52
+ export interface RecallHit {
53
+ entry: RecallEntry;
54
+ similarity: number;
55
+ }
56
+ /**
57
+ * Is semantic recall on? DEFAULT ON — like checkpointing, an operator can turn
58
+ * it off, but a fresh install gets the feature rather than a switch that does
59
+ * nothing until someone reads the docs. `0`/`false`/`off`/`no` turn it off;
60
+ * unset (or any other value) leaves it ON.
61
+ */
62
+ export declare function sessionRecallEnabled(env?: NodeJS.ProcessEnv): boolean;
63
+ /** The config/env shape a resolver reads (structural, so no import cycle). */
64
+ export interface RecallConfigSource {
65
+ getAll(): {
66
+ memory?: {
67
+ sessionRecall?: boolean;
68
+ };
69
+ };
70
+ }
71
+ /**
72
+ * Resolve whether semantic recall is on, with the repo's precedence:
73
+ * an explicit FLAG wins, then the environment, then config, then the default
74
+ * (ON). This is the single place the decision is made, so the CLI, the loop and
75
+ * the dashboard cannot disagree.
76
+ */
77
+ export declare function resolveSessionRecall(input?: {
78
+ flag?: boolean;
79
+ configManager?: RecallConfigSource | null;
80
+ }): boolean;
81
+ /**
82
+ * Index one finished ask for later semantic recall. Returns whether an entry was
83
+ * written. Best-effort and NO-OP when recall is off or embeddings are
84
+ * unavailable (a zero vector is never stored — it would only ever be a
85
+ * meaningless match).
86
+ */
87
+ export declare function indexSessionTurn(input: {
88
+ projectPath: string;
89
+ goal: string;
90
+ outcome?: string;
91
+ savedAt?: number;
92
+ }, opts?: {
93
+ embedFn?: EmbedFn;
94
+ force?: boolean;
95
+ enabled?: boolean;
96
+ }): Promise<boolean>;
97
+ /**
98
+ * The past asks semantically closest to `query`, above the threshold.
99
+ *
100
+ * `scope: 'project'` (default) limits recall to the current project directory —
101
+ * the same scoping the rest of the continuity stack uses, so a new task is not
102
+ * handed another project's history. `scope: 'all'` searches every project and
103
+ * names each hit's project in the block.
104
+ */
105
+ export declare function recallPastSessions(query: string, opts?: {
106
+ projectPath?: string;
107
+ scope?: 'project' | 'all';
108
+ topK?: number;
109
+ threshold?: number;
110
+ embedFn?: EmbedFn;
111
+ force?: boolean;
112
+ enabled?: boolean;
113
+ }): Promise<RecallHit[]>;
114
+ /**
115
+ * Render recall hits as a bounded, model-readable block ('' when there are none).
116
+ *
117
+ * The header is load-bearing: it states that these are PAST asks — history for
118
+ * context only, NOT a status — so a recalled line cannot be read as proof the
119
+ * current work is done. Each hit carries how it ENDED and its project when the
120
+ * recall crossed projects.
121
+ */
122
+ export declare function formatSessionRecall(hits: readonly RecallHit[], opts?: {
123
+ projectPath?: string;
124
+ now?: number;
125
+ }): string;
126
+ /**
127
+ * List every indexed past ask, newest first. Best-effort. The vectors are part of
128
+ * each entry; a caller that only needs a summary maps them away.
129
+ */
130
+ export declare function listRecallEntries(): RecallEntry[];
131
+ /** Remove one indexed past ask by id. Returns whether it was present. */
132
+ export declare function removeRecallEntry(id: string): boolean;
133
+ /** Remove the recall index (used by `nuvira retrieval clear`-style resets / tests). */
134
+ export declare function clearSessionRecallIndex(): boolean;
135
+ //# sourceMappingURL=session-recall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-recall.d.ts","sourceRoot":"","sources":["../../src/learning/session-recall.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAeH,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,+DAA+D;AAC/D,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,6CAA6C;AAC7C,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,iFAAiF;AACjF,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,4DAA4D;AAC5D,eAAO,MAAM,sBAAsB,OAAQ,CAAC;AAE5C,4EAA4E;AAC5E,MAAM,MAAM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