@hyperwindmill/caretaker-cli 0.23.0 → 0.25.0

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 (94) hide show
  1. package/dist/acp/index.d.ts +3 -0
  2. package/dist/acp/index.d.ts.map +1 -0
  3. package/dist/acp/index.js +2 -0
  4. package/dist/acp/install.d.ts +12 -0
  5. package/dist/acp/install.d.ts.map +1 -0
  6. package/dist/acp/install.js +110 -0
  7. package/dist/acp/registry.d.ts +10 -0
  8. package/dist/acp/registry.d.ts.map +1 -0
  9. package/dist/acp/registry.js +116 -0
  10. package/dist/cli/web/mcp_bridge.d.ts +7 -1
  11. package/dist/cli/web/mcp_bridge.d.ts.map +1 -1
  12. package/dist/cli/web/mcp_bridge.js +10 -6
  13. package/dist/cli/web/scheduler/memory_extract.d.ts +55 -0
  14. package/dist/cli/web/scheduler/memory_extract.d.ts.map +1 -0
  15. package/dist/cli/web/scheduler/memory_extract.js +112 -0
  16. package/dist/cli/web/scheduler/memory_sweep.d.ts +68 -0
  17. package/dist/cli/web/scheduler/memory_sweep.d.ts.map +1 -0
  18. package/dist/cli/web/scheduler/memory_sweep.js +330 -0
  19. package/dist/cli/web/scheduler/task_review.d.ts +3 -0
  20. package/dist/cli/web/scheduler/task_review.d.ts.map +1 -1
  21. package/dist/cli/web/scheduler/task_review.js +26 -0
  22. package/dist/cli/web/scheduler/task_roles.d.ts +1 -1
  23. package/dist/cli/web/scheduler/task_roles.d.ts.map +1 -1
  24. package/dist/cli/web/scheduler/task_roles.js +6 -6
  25. package/dist/cli/web/scheduler/task_strategy.d.ts.map +1 -1
  26. package/dist/cli/web/scheduler/task_strategy.js +27 -2
  27. package/dist/cli/web/scheduler.d.ts.map +1 -1
  28. package/dist/cli/web/scheduler.js +5 -0
  29. package/dist/cli/web/server.d.ts +1 -1
  30. package/dist/cli/web/server.d.ts.map +1 -1
  31. package/dist/cli/web/server.js +33 -6
  32. package/dist/harness/acp_policy.d.ts +41 -0
  33. package/dist/harness/acp_policy.d.ts.map +1 -0
  34. package/dist/harness/acp_policy.js +59 -0
  35. package/dist/harness/acp_pool.d.ts +33 -0
  36. package/dist/harness/acp_pool.d.ts.map +1 -0
  37. package/dist/harness/acp_pool.js +148 -0
  38. package/dist/harness/acp_runner.d.ts +4 -0
  39. package/dist/harness/acp_runner.d.ts.map +1 -0
  40. package/dist/harness/acp_runner.js +347 -0
  41. package/dist/harness/claude_code_runner.d.ts +2 -0
  42. package/dist/harness/claude_code_runner.d.ts.map +1 -1
  43. package/dist/harness/claude_code_runner.js +6 -1
  44. package/dist/harness/confirm_gate.d.ts +12 -0
  45. package/dist/harness/confirm_gate.d.ts.map +1 -0
  46. package/dist/harness/confirm_gate.js +33 -0
  47. package/dist/harness/index.d.ts +1 -0
  48. package/dist/harness/index.d.ts.map +1 -1
  49. package/dist/harness/index.js +1 -0
  50. package/dist/harness/loop.d.ts +12 -0
  51. package/dist/harness/loop.d.ts.map +1 -1
  52. package/dist/harness/loop.js +16 -0
  53. package/dist/harness/memory_recall.d.ts +28 -0
  54. package/dist/harness/memory_recall.d.ts.map +1 -0
  55. package/dist/harness/memory_recall.js +74 -0
  56. package/dist/harness/title.js +1 -1
  57. package/dist/harness/tools/builtin/index.d.ts +2 -1
  58. package/dist/harness/tools/builtin/index.d.ts.map +1 -1
  59. package/dist/harness/tools/builtin/index.js +4 -1
  60. package/dist/harness/tools/builtin/memory_tools.d.ts +3 -0
  61. package/dist/harness/tools/builtin/memory_tools.d.ts.map +1 -0
  62. package/dist/harness/tools/builtin/memory_tools.js +60 -0
  63. package/dist/harness/tools/resolve.d.ts.map +1 -1
  64. package/dist/harness/tools/resolve.js +15 -0
  65. package/dist/harness/tools/types.d.ts +6 -0
  66. package/dist/harness/tools/types.d.ts.map +1 -1
  67. package/dist/lib/project_resolve.d.ts +5 -0
  68. package/dist/lib/project_resolve.d.ts.map +1 -0
  69. package/dist/lib/project_resolve.js +23 -0
  70. package/dist/mcp/builtin_server.d.ts +2 -0
  71. package/dist/mcp/builtin_server.d.ts.map +1 -1
  72. package/dist/mcp/builtin_server.js +9 -7
  73. package/dist/mcp/run_command_tool.d.ts +13 -0
  74. package/dist/mcp/run_command_tool.d.ts.map +1 -0
  75. package/dist/mcp/run_command_tool.js +51 -0
  76. package/dist/session/store.d.ts +1 -0
  77. package/dist/session/store.d.ts.map +1 -1
  78. package/dist/session/store.js +6 -0
  79. package/dist/session/types.d.ts +3 -0
  80. package/dist/session/types.d.ts.map +1 -1
  81. package/dist/store/db.d.ts +66 -0
  82. package/dist/store/db.d.ts.map +1 -1
  83. package/dist/store/db.js +68 -0
  84. package/dist/tui/agents.d.ts.map +1 -1
  85. package/dist/tui/agents.js +62 -25
  86. package/dist/tui/chat.d.ts.map +1 -1
  87. package/dist/tui/chat.js +7 -8
  88. package/dist/tui/providers.d.ts.map +1 -1
  89. package/dist/tui/providers.js +116 -17
  90. package/dist/webview/standalone.css +18 -0
  91. package/dist/webview/standalone.css.map +2 -2
  92. package/dist/webview/standalone.js +792 -440
  93. package/dist/webview/standalone.js.map +4 -4
  94. package/package.json +8 -3
@@ -0,0 +1,74 @@
1
+ import { listMemories } from '../store/db.js';
2
+ import { loadConfig } from '../store/json.js';
3
+ import { resolveProjectIdForDir } from '../lib/project_resolve.js';
4
+ export const RECALL_TOP_K = 5;
5
+ export const MIN_KEYWORD_LENGTH = 3;
6
+ const IMPORTANCE_WEIGHT = {
7
+ low: 0.5,
8
+ normal: 1,
9
+ high: 2,
10
+ };
11
+ /** Inverted lexical match — no query tokenization: keywords are split into
12
+ * their component words (deduped per memory), and each word contained in
13
+ * the lowercased prompt counts as a match. A multi-word keyword therefore
14
+ * fires on any of its words ("reaper linux" ← "reaper") and scores higher
15
+ * when the full phrase is present (every word matches) — graded for free,
16
+ * no phrase-special-casing. Generic components over-firing is mitigated by
17
+ * the scoring plus the top-K cut.
18
+ * score = matchedWords × importanceWeight × (1 + log2(1 + recallCount)):
19
+ * acquired strength weighs in — much-recalled memories surface more easily.
20
+ * Ties: lastRecalledAt desc, then createdAt desc. Top-K, score > 0 only. */
21
+ export function matchMemories(prompt, memories) {
22
+ const text = prompt.toLowerCase();
23
+ const scored = [];
24
+ for (const m of memories) {
25
+ const words = new Set(m.keywords.flatMap((k) => k.toLowerCase().split(/\s+/)).filter((w) => w.length >= MIN_KEYWORD_LENGTH));
26
+ let matched = 0;
27
+ for (const w of words)
28
+ if (text.includes(w))
29
+ matched++;
30
+ if (matched === 0)
31
+ continue;
32
+ const score = matched * IMPORTANCE_WEIGHT[m.importance] * (1 + Math.log2(1 + (m.recallCount ?? 0)));
33
+ scored.push({ m, score });
34
+ }
35
+ scored.sort((a, b) => b.score - a.score ||
36
+ (b.m.lastRecalledAt ?? '').localeCompare(a.m.lastRecalledAt ?? '') ||
37
+ b.m.createdAt.localeCompare(a.m.createdAt));
38
+ return scored.slice(0, RECALL_TOP_K).map((s) => s.m);
39
+ }
40
+ /** The prelude block. Titles only, never bodies: the explicit memory_read
41
+ * IS the recall event that feeds acquired strength — a system that always
42
+ * injects bodies never learns what mattered. '' when no matches. */
43
+ export function formatMemoriesBlock(matches) {
44
+ if (matches.length === 0)
45
+ return '';
46
+ return [
47
+ '<memories>',
48
+ 'Stored memories that may be relevant to the current message:',
49
+ ...matches.map((m) => `- ${m.id} — ${m.title} (${m.kind}, ${m.importance})`),
50
+ 'To read their full content, call the memory_read tool with the ids (when available).',
51
+ '</memories>',
52
+ ].join('\n');
53
+ }
54
+ /** One-stop per-turn recall: gate on MemoryConfig (present = read path on,
55
+ * same gate as the sweep), resolve the project from the run's workingDir,
56
+ * match global + project memories, format. Never throws — recall must
57
+ * never break a chat turn.
58
+ * `explicitProjectId` overrides dir resolution: task cycles run in a
59
+ * worktree (or managed repo dir) that never prefix-matches the project's
60
+ * workingDir, but the caller knows the project from the task record —
61
+ * still host-side, never the model's choice. */
62
+ export async function buildMemoriesBlock(prompt, workingDir, explicitProjectId) {
63
+ try {
64
+ const config = await loadConfig();
65
+ if (!config.memory)
66
+ return '';
67
+ const projectId = explicitProjectId ?? resolveProjectIdForDir(workingDir, config.projects ?? []);
68
+ const candidates = (await listMemories()).filter((m) => m.projectId === '' || m.projectId === projectId);
69
+ return formatMemoriesBlock(matchMemories(prompt, candidates));
70
+ }
71
+ catch {
72
+ return '';
73
+ }
74
+ }
@@ -10,7 +10,7 @@ const TITLE_INSTRUCTION = 'Summarize this conversation in 5–7 words for a chat
10
10
  * that case — title generation is best-effort. */
11
11
  export async function generateTitle(input) {
12
12
  const { agent, provider, firstUserPrompt, firstAssistantText, signal } = input;
13
- if (input.provider.type === 'claude-code')
13
+ if (input.provider.type === 'claude-code' || input.provider.type === 'acp')
14
14
  return null; // no HTTP endpoint; keep fallback title
15
15
  if (!firstUserPrompt.trim() && !firstAssistantText.trim())
16
16
  return null;
@@ -18,7 +18,8 @@ import { listCommandsTool } from './list_commands.js';
18
18
  import { invokeCommandTool } from './invoke_command.js';
19
19
  import { getAgentContextTool } from './get_agent_context.js';
20
20
  import { emailListAccountsTool, emailSendTool, emailFetchTool } from './email_tools.js';
21
+ import { memoryReadTool } from './memory_tools.js';
21
22
  import { getTaskStateTool, updateChecklistItemTool, updateChecklistTool, addMessageTool, completeTaskTool, blockTaskTool, yieldTaskTool, projectListTool, taskCreateTool, taskSearchTool, taskUnblockTool, taskActivateTool, taskUnpauseTool, taskDiscardWorktreeTool, taskArchiveTool, taskUnarchiveTool, taskDeleteTool, taskSetAgentTool, submitPlanTool, taskUpdateDetailsTool } from './task_tools.js';
22
23
  export declare function registerBuiltins(registry: ToolRegistry): void;
23
- export { readFileTool, readDocumentTool, readImageTool, readAttachmentTool, writeTool, editTool, multieditTool, globTool, grepTool, fetchTool, bashTool, listSkillsTool, readSkillTool, listAgentsTool, invokeAgentTool, listCommandsTool, invokeCommandTool, getAgentContextTool, getTaskStateTool, updateChecklistItemTool, updateChecklistTool, addMessageTool, completeTaskTool, blockTaskTool, yieldTaskTool, projectListTool, taskCreateTool, taskSearchTool, taskUnblockTool, taskActivateTool, taskUnpauseTool, taskDiscardWorktreeTool, taskArchiveTool, taskUnarchiveTool, taskDeleteTool, taskSetAgentTool, submitPlanTool, taskUpdateDetailsTool, emailListAccountsTool, emailSendTool, emailFetchTool, };
24
+ export { readFileTool, readDocumentTool, readImageTool, readAttachmentTool, writeTool, editTool, multieditTool, globTool, grepTool, fetchTool, bashTool, listSkillsTool, readSkillTool, listAgentsTool, invokeAgentTool, listCommandsTool, invokeCommandTool, getAgentContextTool, getTaskStateTool, updateChecklistItemTool, updateChecklistTool, addMessageTool, completeTaskTool, blockTaskTool, yieldTaskTool, projectListTool, taskCreateTool, taskSearchTool, taskUnblockTool, taskActivateTool, taskUnpauseTool, taskDiscardWorktreeTool, taskArchiveTool, taskUnarchiveTool, taskDeleteTool, taskSetAgentTool, submitPlanTool, taskUpdateDetailsTool, emailListAccountsTool, emailSendTool, emailFetchTool, memoryReadTool, };
24
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/harness/tools/builtin/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,E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AE,qBAAqB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CA6D7D;AAED,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,cAAc,EACd,aAAa,EACb,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,cAAc,GACf,CAAC"}
@@ -20,6 +20,7 @@ import { listCommandsTool } from './list_commands.js';
20
20
  import { invokeCommandTool } from './invoke_command.js';
21
21
  import { getAgentContextTool } from './get_agent_context.js';
22
22
  import { emailListAccountsTool, emailSendTool, emailFetchTool } from './email_tools.js';
23
+ import { memoryReadTool } from './memory_tools.js';
23
24
  import { getTaskStateTool, updateChecklistItemTool, updateChecklistTool, addMessageTool, completeTaskTool, blockTaskTool, yieldTaskTool, projectListTool, taskCreateTool, taskSearchTool, taskUnblockTool, taskActivateTool, taskUnpauseTool, taskDiscardWorktreeTool, taskArchiveTool, taskUnarchiveTool, taskDeleteTool, taskSetAgentTool, submitPlanTool, taskUpdateDetailsTool, } from './task_tools.js';
24
25
  export function registerBuiltins(registry) {
25
26
  // Filesystem (sandboxed to ctx.workingDir).
@@ -77,5 +78,7 @@ export function registerBuiltins(registry) {
77
78
  registry.register(emailListAccountsTool);
78
79
  registry.register(emailSendTool);
79
80
  registry.register(emailFetchTool);
81
+ // Memory subsystem read path (recall accounting lives in the tool).
82
+ registry.register(memoryReadTool);
80
83
  }
81
- export { readFileTool, readDocumentTool, readImageTool, readAttachmentTool, writeTool, editTool, multieditTool, globTool, grepTool, fetchTool, bashTool, listSkillsTool, readSkillTool, listAgentsTool, invokeAgentTool, listCommandsTool, invokeCommandTool, getAgentContextTool, getTaskStateTool, updateChecklistItemTool, updateChecklistTool, addMessageTool, completeTaskTool, blockTaskTool, yieldTaskTool, projectListTool, taskCreateTool, taskSearchTool, taskUnblockTool, taskActivateTool, taskUnpauseTool, taskDiscardWorktreeTool, taskArchiveTool, taskUnarchiveTool, taskDeleteTool, taskSetAgentTool, submitPlanTool, taskUpdateDetailsTool, emailListAccountsTool, emailSendTool, emailFetchTool, };
84
+ export { readFileTool, readDocumentTool, readImageTool, readAttachmentTool, writeTool, editTool, multieditTool, globTool, grepTool, fetchTool, bashTool, listSkillsTool, readSkillTool, listAgentsTool, invokeAgentTool, listCommandsTool, invokeCommandTool, getAgentContextTool, getTaskStateTool, updateChecklistItemTool, updateChecklistTool, addMessageTool, completeTaskTool, blockTaskTool, yieldTaskTool, projectListTool, taskCreateTool, taskSearchTool, taskUnblockTool, taskActivateTool, taskUnpauseTool, taskDiscardWorktreeTool, taskArchiveTool, taskUnarchiveTool, taskDeleteTool, taskSetAgentTool, submitPlanTool, taskUpdateDetailsTool, emailListAccountsTool, emailSendTool, emailFetchTool, memoryReadTool, };
@@ -0,0 +1,3 @@
1
+ import type { Tool } from '../types.js';
2
+ export declare const memoryReadTool: Tool;
3
+ //# sourceMappingURL=memory_tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory_tools.d.ts","sourceRoot":"","sources":["../../../../src/harness/tools/builtin/memory_tools.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,aAAa,CAAC;AAGpD,eAAO,MAAM,cAAc,EAAE,IAgD5B,CAAC"}
@@ -0,0 +1,60 @@
1
+ // Agent-facing memory tools. Named `mcp__memory__*` so the shared builtin MCP
2
+ // server (mcp/builtin_server.ts) picks them up by prefix and serves them over
3
+ // both the stdio subcommand and the per-task HTTP bridge, exactly like the
4
+ // `mcp__task__*` set. Native agents opt in via allowedTools (the
5
+ // `mcp__<ns>__*` wildcard is generic in resolveAgentTools and the pickers).
6
+ //
7
+ // memory_read is THE recall event of the memory subsystem: every delivered id
8
+ // bumps the memory's acquired strength (recallCount / lastRecalledAt) — the
9
+ // signal the future consolidation/decay feeds on. That is why the prelude
10
+ // injects titles only: a system that always injects bodies never learns what
11
+ // mattered. Read-only w.r.t. content — no planner deny needed.
12
+ // See docs/superpowers/specs/2026-08-25-memory-daemon-step3-recall-design.md
13
+ import { listMemories, bumpMemoryRecall } from '../../../store/db.js';
14
+ export const memoryReadTool = {
15
+ name: 'mcp__memory__memory_read',
16
+ // Auto-included by resolveAgentTools when MemoryConfig is present (the
17
+ // same gate as the <memories> prelude block) — never a picker choice.
18
+ hidden: true,
19
+ description: 'Read the full content of stored memories by id. Ids come from the <memories> block in the system prompt. Reading a memory reinforces it (recall statistics are updated), so read the ones actually relevant, not all of them.',
20
+ parameters: {
21
+ type: 'object',
22
+ properties: {
23
+ ids: {
24
+ type: 'array',
25
+ items: { type: 'string' },
26
+ description: 'Memory ids to read.',
27
+ },
28
+ },
29
+ required: ['ids'],
30
+ additionalProperties: false,
31
+ },
32
+ execute: async (args, _ctx) => {
33
+ const ids = Array.isArray(args?.ids)
34
+ ? args.ids.filter((v) => typeof v === 'string' && v.trim() !== '')
35
+ : [];
36
+ if (ids.length === 0)
37
+ throw new Error('memory_read requires a non-empty `ids` array');
38
+ const byId = new Map((await listMemories()).map((m) => [m.id, m]));
39
+ const memories = [];
40
+ const missing = [];
41
+ for (const id of ids) {
42
+ const m = byId.get(id);
43
+ if (!m) {
44
+ missing.push(id);
45
+ continue;
46
+ }
47
+ await bumpMemoryRecall(id);
48
+ memories.push({
49
+ id: m.id,
50
+ title: m.title,
51
+ body: m.body,
52
+ kind: m.kind,
53
+ importance: m.importance,
54
+ projectId: m.projectId,
55
+ createdAt: m.createdAt,
56
+ });
57
+ }
58
+ return { content: JSON.stringify({ memories, missing }) };
59
+ },
60
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/resolve.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAgBvC,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,IAAI,EAAE,CAAC,CA+BjB"}
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/resolve.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAkBvC,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,IAAI,EAAE,CAAC,CAqCjB"}
@@ -8,6 +8,12 @@
8
8
  // (`list_commands`/`invoke_command`) access tools are added even if
9
9
  // the user did not list them in allowedTools — they are useless
10
10
  // without an active plugin and noisy if shown without one.
11
+ // - Memory-gated builtin: when `MemoryConfig` is present in caretaker.json,
12
+ // `mcp__memory__memory_read` is added. Same gate as the `<memories>`
13
+ // prelude block — the tool is the other half of that harness channel,
14
+ // not an agent capability. It is hidden from the pickers (Tool.hidden),
15
+ // so there is no user-chosen off state to contradict; the user-visible
16
+ // switch is MemoryConfig itself.
11
17
  // - MCP tools: when the agent references MCP servers, their tools/list
12
18
  // output is fetched via the adapter and appended (names already
13
19
  // namespaced as `mcp__<id>__<toolName>`).
@@ -22,9 +28,11 @@
22
28
  // them per-run because the remote tool list can change between runs and we
23
29
  // don't want stale entries cluttering autocomplete or test fixtures.
24
30
  import { mcpToolsForServers } from '../../mcp/adapter.js';
31
+ import { loadConfig } from '../../store/json.js';
25
32
  const SKILL_TOOL_NAMES = ['list_skills', 'read_skill'];
26
33
  const COMMAND_TOOL_NAMES = ['list_commands', 'invoke_command'];
27
34
  const ALWAYS_ON_TOOL_NAMES = ['get_agent_context'];
35
+ const MEMORY_TOOL_NAMES = ['mcp__memory__memory_read'];
28
36
  function autoInclude(tools, registry, names) {
29
37
  const have = new Set(tools.map((t) => t.name));
30
38
  for (const name of names) {
@@ -56,6 +64,13 @@ export async function resolveAgentTools(agent, registry) {
56
64
  autoInclude(tools, registry, SKILL_TOOL_NAMES);
57
65
  autoInclude(tools, registry, COMMAND_TOOL_NAMES);
58
66
  }
67
+ try {
68
+ if ((await loadConfig()).memory)
69
+ autoInclude(tools, registry, MEMORY_TOOL_NAMES);
70
+ }
71
+ catch {
72
+ // Unreadable config → no memory tier this run; never fail tool resolution.
73
+ }
59
74
  const mcpIds = agent.mcpServers ?? [];
60
75
  if (mcpIds.length > 0) {
61
76
  const mcp = await mcpToolsForServers(mcpIds);
@@ -65,6 +65,12 @@ export interface Tool {
65
65
  /** Resolves the tool. Throws are caught by the loop and surfaced as
66
66
  * "Error: <msg>" tool results. */
67
67
  execute: (args: unknown, ctx: ToolContext) => Promise<ToolResult>;
68
+ /** Harness infrastructure, not an agent capability: excluded from the
69
+ * tool pickers because resolveAgentTools auto-includes it behind its own
70
+ * gate (e.g. memory_read behind MemoryConfig) — offering a checkbox the
71
+ * runtime overrides would be the UI/runtime mismatch the pickers exist
72
+ * to prevent. */
73
+ hidden?: boolean;
68
74
  /** Marks tools whose action mutates the system or has side effects
69
75
  * (file write, command exec, network mutation). The harness may surface
70
76
  * a confirm prompt for these in a future iteration; today purely
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC3D,MAAM,MAAM,WAAW,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;AAoBhG,MAAM,WAAW,WAAW;IAC1B;6EACyE;IACzE,MAAM,EAAE,WAAW,CAAC;IACpB,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB;;;yCAGqC;IACrC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB;;;kFAG8E;IAC9E,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;gFAG4E;IAC5E,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;kDAE8C;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;oCAEgC;IAChC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;wEAEoE;IACpE,SAAS,CAAC,EAAE;QAAE,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,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAClE;;;;sBAIkB;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;yBAGqB;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,CAAC;CACH;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAS3D"}
@@ -0,0 +1,5 @@
1
+ import type { ProjectConfig } from '../types.js';
2
+ /** Path-aware prefix match of `dir` against the configured projects'
3
+ * workingDir. Longest match wins (nested projects). '' = no project. */
4
+ export declare function resolveProjectIdForDir(dir: string, projects: ProjectConfig[]): string;
5
+ //# sourceMappingURL=project_resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project_resolve.d.ts","sourceRoot":"","sources":["../../src/lib/project_resolve.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;yEACyE;AACzE,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,CAYrF"}
@@ -0,0 +1,23 @@
1
+ // Host-side project resolution — scope ids are never chosen by a model.
2
+ // Shared by the memory write path (sweep extraction, via the session agent's
3
+ // workingDir) and the read path (recall, via the run's workingDir).
4
+ // See docs/superpowers/specs/2026-08-25-memory-daemon-step3-recall-design.md
5
+ import { isAbsolute, resolve, sep } from 'node:path';
6
+ /** Path-aware prefix match of `dir` against the configured projects'
7
+ * workingDir. Longest match wins (nested projects). '' = no project. */
8
+ export function resolveProjectIdForDir(dir, projects) {
9
+ if (!dir || !isAbsolute(dir))
10
+ return '';
11
+ const target = resolve(dir);
12
+ let best = null;
13
+ for (const p of projects) {
14
+ if (!p.workingDir || !isAbsolute(p.workingDir))
15
+ continue;
16
+ const projDir = resolve(p.workingDir);
17
+ if (target === projDir || target.startsWith(projDir + sep)) {
18
+ if (!best || projDir.length > best.len)
19
+ best = { id: p.id, len: projDir.length };
20
+ }
21
+ }
22
+ return best?.id ?? '';
23
+ }
@@ -3,11 +3,13 @@ import type { Tool } from '../harness/tools/index.js';
3
3
  import type { AgentConfig } from '../types.js';
4
4
  export declare const TASK_PREFIX = "mcp__task__";
5
5
  export declare const EMAIL_PREFIX = "mcp__email__";
6
+ export declare const MEMORY_PREFIX = "mcp__memory__";
6
7
  export declare function builtinMcpTools(): Tool[];
7
8
  export declare function buildBuiltinMcpServer(info?: {
8
9
  name: string;
9
10
  version: string;
10
11
  }, opts?: {
11
12
  callerAgent?: AgentConfig;
13
+ tools?: Tool[];
12
14
  }): Server;
13
15
  //# sourceMappingURL=builtin_server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"builtin_server.d.ts","sourceRoot":"","sources":["../../src/mcp/builtin_server.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAQ3C,wBAAgB,eAAe,IAAI,IAAI,EAAE,CAExC;AAED,wBAAgB,qBAAqB,CACnC,IAAI,GAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAiD,EACtF,IAAI,GAAE;IAAE,WAAW,CAAC,EAAE,WAAW,CAAA;CAAO,GACvC,MAAM,CAoCR"}
1
+ {"version":3,"file":"builtin_server.d.ts","sourceRoot":"","sources":["../../src/mcp/builtin_server.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAQ7C,wBAAgB,eAAe,IAAI,IAAI,EAAE,CAExC;AAED,wBAAgB,qBAAqB,CACnC,IAAI,GAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAiD,EACtF,IAAI,GAAE;IAAE,WAAW,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAA;CAAO,GACvD,MAAM,CAqCR"}
@@ -1,10 +1,10 @@
1
1
  // Shared builder: wraps the built-in `mcp__<ns>__*` registry tools as an MCP
2
2
  // Server. Used by BOTH the per-task HTTP bridge (cli/web/mcp_bridge.ts) and the
3
3
  // general stdio subcommand (cli/mcp.ts) so this surface has one definition and
4
- // one wrapping. Two namespaces today — `task` (drive the autonomous task state
5
- // machine) and `email` (send mail through a configured account); a new tool in
6
- // either is picked up by both consumers through the prefix filter, never a
7
- // second allowlist.
4
+ // one wrapping. Three namespaces today — `task` (drive the autonomous task state
5
+ // machine), `email` (send mail through a configured account), and `memory`
6
+ // (read stored memories, bumping recall accounting); a new tool in either is
7
+ // picked up by both consumers through the prefix filter, never a second allowlist.
8
8
  //
9
9
  // The tools are context-free (they take task_id / account by argument), so a
10
10
  // stub ToolContext is sufficient — except for the caller's identity, which the
@@ -17,7 +17,8 @@ import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprot
17
17
  import { tools as registry } from '../harness/tools/instance.js';
18
18
  export const TASK_PREFIX = 'mcp__task__';
19
19
  export const EMAIL_PREFIX = 'mcp__email__';
20
- const SERVED_PREFIXES = [TASK_PREFIX, EMAIL_PREFIX];
20
+ export const MEMORY_PREFIX = 'mcp__memory__';
21
+ const SERVED_PREFIXES = [TASK_PREFIX, EMAIL_PREFIX, MEMORY_PREFIX];
21
22
  /** `mcp__task__task_complete` → `task_complete`, `mcp__email__email_send` → `email_send`. */
22
23
  function externalName(name) {
23
24
  return name.replace(/^mcp__[a-z]+__/, '');
@@ -26,16 +27,17 @@ export function builtinMcpTools() {
26
27
  return registry.list().filter((t) => SERVED_PREFIXES.some((p) => t.name.startsWith(p)));
27
28
  }
28
29
  export function buildBuiltinMcpServer(info = { name: 'caretaker-task', version: '0.0.0' }, opts = {}) {
30
+ const served = () => opts.tools ?? builtinMcpTools();
29
31
  const server = new Server(info, { capabilities: { tools: {} } });
30
32
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
31
- tools: builtinMcpTools().map((t) => ({
33
+ tools: served().map((t) => ({
32
34
  name: externalName(t.name),
33
35
  description: t.description,
34
36
  inputSchema: t.parameters,
35
37
  })),
36
38
  }));
37
39
  server.setRequestHandler(CallToolRequestSchema, async (req) => {
38
- const tool = builtinMcpTools().find((t) => externalName(t.name) === req.params.name);
40
+ const tool = served().find((t) => externalName(t.name) === req.params.name);
39
41
  if (!tool) {
40
42
  return {
41
43
  content: [{ type: 'text', text: `Error: unknown tool "${req.params.name}"` }],
@@ -0,0 +1,13 @@
1
+ import type { Tool } from '../harness/tools/index.js';
2
+ type ExecFn = (cmd: string, args: string[], opts: object) => Promise<{
3
+ stdout: string;
4
+ stderr: string;
5
+ }>;
6
+ export declare function __setExec(fn: ExecFn): void;
7
+ export declare function __resetExec(): void;
8
+ export declare function makeRunCommandTool(bind: {
9
+ container: string;
10
+ workdir: string;
11
+ }): Tool;
12
+ export {};
13
+ //# sourceMappingURL=run_command_tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run_command_tool.d.ts","sourceRoot":"","sources":["../../src/mcp/run_command_tool.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAOtD,KAAK,MAAM,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAGzG,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE1C;AACD,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAMD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA+BrF"}
@@ -0,0 +1,51 @@
1
+ // Per-task shell tool for ACP runs under Docker confinement: the ACP policy
2
+ // denies every kind:'execute' tool call, and this bridge-injected tool is the
3
+ // only shell path — confined to the task's container by construction. Built
4
+ // per token (bound container), so it is never part of the registry and never
5
+ // served by the stdio `caretaker-cli mcp` server (no container to bind there).
6
+ import { execFile } from 'node:child_process';
7
+ import { promisify } from 'node:util';
8
+ import { containerExecArgs } from '../lib/docker.js';
9
+ import { commandEnv } from '../harness/tools/builtin/shell-env.js';
10
+ const TIMEOUT_MS = 5 * 60_000;
11
+ const MAX_OUTPUT_CHARS = 30_000;
12
+ const realExec = promisify(execFile);
13
+ let execImpl = realExec;
14
+ export function __setExec(fn) {
15
+ execImpl = fn;
16
+ }
17
+ export function __resetExec() {
18
+ execImpl = realExec;
19
+ }
20
+ function cap(s) {
21
+ return s.length > MAX_OUTPUT_CHARS ? s.slice(0, MAX_OUTPUT_CHARS) + '\n…[truncated]' : s;
22
+ }
23
+ export function makeRunCommandTool(bind) {
24
+ return {
25
+ name: 'mcp__task__run_command',
26
+ description: "Run a shell command inside this task's Docker container (the only way to execute " +
27
+ 'commands in this run — direct shell tool calls are denied). Runs from the task ' +
28
+ `working directory. 5-minute timeout, output capped at ${MAX_OUTPUT_CHARS} chars.`,
29
+ parameters: {
30
+ type: 'object',
31
+ properties: {
32
+ command: { type: 'string', description: 'The shell command to run (sh -c syntax).' },
33
+ },
34
+ required: ['command'],
35
+ },
36
+ execute: async (args) => {
37
+ const command = String(args?.command ?? '').trim();
38
+ if (!command)
39
+ return { content: 'Error: command is required' };
40
+ try {
41
+ const { stdout, stderr } = await execImpl('docker', containerExecArgs(bind.container, bind.workdir, command), { env: commandEnv(), timeout: TIMEOUT_MS, maxBuffer: 10 * 1024 * 1024 });
42
+ return { content: cap([stdout, stderr].filter(Boolean).join('\n')) || '(no output)' };
43
+ }
44
+ catch (err) {
45
+ const out = [err?.stdout, err?.stderr].filter(Boolean).join('\n');
46
+ const code = err?.code ?? 'unknown';
47
+ return { content: cap(`Error: exit code ${code}\n${out || err?.message || ''}`) };
48
+ }
49
+ },
50
+ };
51
+ }
@@ -42,6 +42,7 @@ export declare function updateTitle(meta: Pick<SessionMetaRecord, 'agentId' | 'i
42
42
  /** Persist the Claude Code session id by appending a fresh meta line
43
43
  * (readSession picks the latest meta; listForAgent keeps using the first). */
44
44
  export declare function updateClaudeSessionId(meta: Pick<SessionMetaRecord, 'agentId' | 'id'>, claudeSessionId: string): Promise<void>;
45
+ export declare function updateAcpSessionId(meta: Pick<SessionMetaRecord, 'agentId' | 'id'>, acpSessionId: string): Promise<void>;
45
46
  export declare function deleteSession(agentId: string, sessionId: string): Promise<void>;
46
47
  export declare function userMessage(content: string, opts?: {
47
48
  id?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/session/store.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AA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EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGnF;AAED,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,oBAAoB,EAAE,EACpC,IAAI,CAAC,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACzC,aAAa,CAWf;AAID,eAAO,MAAM,YAAY;;;;CAA2C,CAAC"}
@@ -205,6 +205,12 @@ export async function updateClaudeSessionId(meta, claudeSessionId) {
205
205
  const path = sessionPath(meta.agentId, meta.id);
206
206
  await appendFile(path, serialize(record), { mode: 0o600 });
207
207
  }
208
+ export async function updateAcpSessionId(meta, acpSessionId) {
209
+ const current = await readSession(meta.agentId, meta.id);
210
+ const record = { ...current.meta, acpSessionId };
211
+ const path = sessionPath(meta.agentId, meta.id);
212
+ await appendFile(path, serialize(record), { mode: 0o600 });
213
+ }
208
214
  export async function deleteSession(agentId, sessionId) {
209
215
  const path = sessionPath(agentId, sessionId);
210
216
  await rm(path, { force: true });
@@ -27,6 +27,9 @@ export interface SessionMetaRecord {
27
27
  /** Claude Code CLI session id for claude-code runner agents; the next
28
28
  * turn resumes it via `claude -p --resume <id>`. */
29
29
  claudeSessionId?: string;
30
+ /** ACP session id for acp runner agents; reused across turns and offered
31
+ * to session/load when the agent supports it. */
32
+ acpSessionId?: string;
30
33
  }
31
34
  export type Role = 'user' | 'assistant' | 'tool';
32
35
  export interface ToolAttachmentRecord {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/session/types.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,aAAa,GACrB;IAAE,IA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AM,CAAC;AAEjD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,CAAC,CAAC;IACL,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX;;2DAEuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IACxB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,aAAa,CAAC;AAE9D,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,iBAAiB,CAAC;IACxB,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B"}
@@ -75,4 +75,70 @@ export declare function createTask(task: Omit<Task, 'id' | 'seq' | 'createdAt' |
75
75
  export declare function addTaskMessage(msg: Omit<TaskMessage, 'id' | 'createdAt'>): Promise<TaskMessage>;
76
76
  export declare function updateTaskMessageContent(id: number, content: string, type?: TaskMessage['messageType']): Promise<void>;
77
77
  export declare function deleteTask(taskId: string): Promise<void>;
78
+ /** Per-session memory digest: cursor + rolling summary maintained by the
79
+ * memory sweep daemon. The whole collection is a regenerable cache — never
80
+ * a source of truth; deleting it costs one full re-scan.
81
+ * See docs/superpowers/specs/2026-08-24-memory-daemon-step1-design.md */
82
+ export interface SessionDigest {
83
+ /** = sessionId (uuid of the JSONL session file). */
84
+ id: string;
85
+ agentId: string;
86
+ /** Cursor: last processed MessageRecord.id. '' = nothing processed yet. */
87
+ lastMessageId: string;
88
+ /** Messages processed so far (O(1) "how many new?" check). */
89
+ messageCount: number;
90
+ /** Rolling summary, standalone text. '' until the first summarize call. */
91
+ summary: string;
92
+ /** Model that produced the current summary. '' until then. */
93
+ model: string;
94
+ /** Start of the last *fully caught-up* scan. INVARIANT: written only when
95
+ * the digest covers everything read at this timestamp; the sweep's mtime
96
+ * gate (skip when file mtime < scannedAt) is only sound because of that. */
97
+ scannedAt: string;
98
+ updatedAt: string;
99
+ }
100
+ export declare function getSessionDigest(sessionId: string): Promise<SessionDigest | null>;
101
+ export declare function listSessionDigests(): Promise<SessionDigest[]>;
102
+ export declare function saveSessionDigest(d: SessionDigest): Promise<void>;
103
+ export declare function deleteSessionDigest(sessionId: string): Promise<void>;
104
+ /** One durable memory extracted by the sweep's combined call. Unlike the
105
+ * digests this is NOT a regenerable cache — it is the first durable store
106
+ * of the memory subsystem. Append-only at write time; merge/supersede/decay
107
+ * are the future consolidation's job.
108
+ * See docs/superpowers/specs/2026-08-24-memory-daemon-step2-extraction-design.md */
109
+ export interface Memory {
110
+ /** crypto.randomUUID() — passes safeId. */
111
+ id: string;
112
+ /** '' = global (user/machine level). Resolved host-side, never by the model. */
113
+ projectId: string;
114
+ /** Semantic/episodic split: timeless knowledge vs a dated event. */
115
+ kind: 'fact' | 'episode';
116
+ /** Initial strength, derived from the tone of the conversation at write
117
+ * time (the tone is unrecoverable later). Ordinal on purpose — models
118
+ * calibrate numeric scales poorly. */
119
+ importance: 'low' | 'normal' | 'high';
120
+ title: string;
121
+ /** Markdown, self-contained. */
122
+ body: string;
123
+ /** Associative base for the future read path, emitted at write time. */
124
+ keywords: string[];
125
+ /** Times delivered by memory_read. Absent on pre-step-3 records = 0. */
126
+ recallCount?: number;
127
+ /** ISO timestamp of the last memory_read delivery. */
128
+ lastRecalledAt?: string;
129
+ sourceSessionId: string;
130
+ /** The session's agent directory — NOT a scope; mined by a future
131
+ * personality step. */
132
+ sourceAgentId: string;
133
+ /** Extraction model. */
134
+ model: string;
135
+ createdAt: string;
136
+ }
137
+ export declare function saveMemory(m: Memory): Promise<void>;
138
+ export declare function listMemories(): Promise<Memory[]>;
139
+ export declare function deleteMemory(id: string): Promise<void>;
140
+ /** Recall event: memory_read delivered this memory to an agent. Delete +
141
+ * insert (saveSessionDigest pattern — the store has no UPDATE). No-op on
142
+ * unknown ids: a stale id in a prelude block is not an error. */
143
+ export declare function bumpMemoryRecall(id: string): Promise<void>;
78
144
  //# sourceMappingURL=db.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/store/db.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAIvC,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,MAAM,GAAG,SAAS,CAAC;IACvD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,aAAa,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,IAAI;IACnB;;kFAE8E;IAC9E,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,C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