@hyperwindmill/caretaker-cli 0.23.0 → 0.24.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.
- package/dist/cli/web/scheduler/memory_extract.d.ts +55 -0
- package/dist/cli/web/scheduler/memory_extract.d.ts.map +1 -0
- package/dist/cli/web/scheduler/memory_extract.js +112 -0
- package/dist/cli/web/scheduler/memory_sweep.d.ts +68 -0
- package/dist/cli/web/scheduler/memory_sweep.d.ts.map +1 -0
- package/dist/cli/web/scheduler/memory_sweep.js +329 -0
- package/dist/cli/web/scheduler/task_review.d.ts +3 -0
- package/dist/cli/web/scheduler/task_review.d.ts.map +1 -1
- package/dist/cli/web/scheduler/task_review.js +1 -0
- package/dist/cli/web/scheduler/task_strategy.d.ts.map +1 -1
- package/dist/cli/web/scheduler/task_strategy.js +4 -0
- package/dist/cli/web/scheduler.d.ts.map +1 -1
- package/dist/cli/web/scheduler.js +5 -0
- package/dist/cli/web/server.d.ts.map +1 -1
- package/dist/cli/web/server.js +6 -1
- package/dist/harness/claude_code_runner.d.ts.map +1 -1
- package/dist/harness/claude_code_runner.js +5 -0
- package/dist/harness/loop.d.ts +9 -0
- package/dist/harness/loop.d.ts.map +1 -1
- package/dist/harness/loop.js +10 -0
- package/dist/harness/memory_recall.d.ts +23 -0
- package/dist/harness/memory_recall.d.ts.map +1 -0
- package/dist/harness/memory_recall.js +70 -0
- package/dist/harness/tools/builtin/index.d.ts +2 -1
- package/dist/harness/tools/builtin/index.d.ts.map +1 -1
- package/dist/harness/tools/builtin/index.js +4 -1
- package/dist/harness/tools/builtin/memory_tools.d.ts +3 -0
- package/dist/harness/tools/builtin/memory_tools.d.ts.map +1 -0
- package/dist/harness/tools/builtin/memory_tools.js +60 -0
- package/dist/harness/tools/resolve.d.ts.map +1 -1
- package/dist/harness/tools/resolve.js +15 -0
- package/dist/harness/tools/types.d.ts +6 -0
- package/dist/harness/tools/types.d.ts.map +1 -1
- package/dist/lib/project_resolve.d.ts +5 -0
- package/dist/lib/project_resolve.d.ts.map +1 -0
- package/dist/lib/project_resolve.js +23 -0
- package/dist/mcp/builtin_server.d.ts +1 -0
- package/dist/mcp/builtin_server.d.ts.map +1 -1
- package/dist/mcp/builtin_server.js +6 -5
- package/dist/store/db.d.ts +66 -0
- package/dist/store/db.d.ts.map +1 -1
- package/dist/store/db.js +68 -0
- package/dist/tui/agents.js +5 -2
- package/dist/webview/standalone.js +557 -415
- package/dist/webview/standalone.js.map +4 -4
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/cli/web/server.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AA0ClD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAgC,MAAM,gBAAgB,CAAC;AAChG,OAAO,KAAK,EAAE,eAAe,EAA0B,MAAM,mBAAmB,CAAC;AAgBjF,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC9D,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IACtF,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAA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AM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,EACtE,iBAAiB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,IAAI,CAAC;IAgFhB,KAAK,IAAI,IAAI;CAGd;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgoC3E"}
|
package/dist/cli/web/server.js
CHANGED
|
@@ -864,7 +864,12 @@ export async function startServer(port, host) {
|
|
|
864
864
|
// Collapse every builtin `mcp__<ns>__` namespace (task, email, …) into a
|
|
865
865
|
// single wildcard entry: the picker offers the namespace, so a namespace
|
|
866
866
|
// gaining a tool needs no config change. resolveAgentTools expands it.
|
|
867
|
-
|
|
867
|
+
// Hidden tools (memory_read) are harness infrastructure, auto-included
|
|
868
|
+
// by resolveAgentTools behind their own gate — never a picker choice.
|
|
869
|
+
const toolNames = harness.tools
|
|
870
|
+
.list()
|
|
871
|
+
.filter((t) => !t.hidden)
|
|
872
|
+
.map((t) => t.name);
|
|
868
873
|
const namespaces = [
|
|
869
874
|
...new Set(toolNames.map((name) => /^mcp__[a-z]+__/.exec(name)?.[0]).filter((p) => !!p)),
|
|
870
875
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude_code_runner.d.ts","sourceRoot":"","sources":["../../src/harness/claude_code_runner.ts"],"names":[],"mappings":"AAMA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAM3E,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"claude_code_runner.d.ts","sourceRoot":"","sources":["../../src/harness/claude_code_runner.ts"],"names":[],"mappings":"AAMA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAM3E,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,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AAgB,iCAAiC,CAC/C,YAAY,GAAE,MAA4D,GACzE,MAAM,GAAG,IAAI,CAQf;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;kFAC8E;IAC9E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,EAAE,CAe5D;AAED,uEAAuE;AACvE,wBAAgB,oBAAoB,CAAC,CAAC,EAAE;IACtC,QAAQ,EAAE,OAAO,CAAC;IAClB,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACzC,GAAG,mBAAmB,CAwBtB;AAsMD,wBAAsB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,GAAE,YAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,CA2I/F"}
|
|
@@ -11,6 +11,7 @@ import os from 'node:os';
|
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { parseClaudeStreamLine } from './claude_code_stream.js';
|
|
13
13
|
import { loadContextFiles, formatContextBlock, resolveFileReferences } from './context_files.js';
|
|
14
|
+
import { buildMemoriesBlock } from './memory_recall.js';
|
|
14
15
|
import { VOICE_CONVERSATION_PRELUDE } from './prelude.js';
|
|
15
16
|
import { readSession, updateClaudeSessionId, assistantMessage, toolMessage, } from '../session/store.js';
|
|
16
17
|
import { loadMcpServers } from '../store/json.js';
|
|
@@ -271,9 +272,13 @@ export async function runClaudeCode(opts, cb = {}) {
|
|
|
271
272
|
// ~/.caretaker/AGENTS.md it does not — verified on CLI 2.1.207).
|
|
272
273
|
const sys = await resolveFileReferences(agent.systemPrompt ?? '', workingDir);
|
|
273
274
|
const ctxEntries = (await loadContextFiles(workingDir)).filter((e) => path.basename(e.path) !== 'CLAUDE.md');
|
|
275
|
+
const memoriesBlock = opts.skipMemoryRecall
|
|
276
|
+
? ''
|
|
277
|
+
: await buildMemoriesBlock(opts.prompt, workingDir, opts.memoryProjectId);
|
|
274
278
|
const appendSystemPrompt = [
|
|
275
279
|
sys,
|
|
276
280
|
ctxEntries.length ? formatContextBlock(ctxEntries) : '',
|
|
281
|
+
memoriesBlock,
|
|
277
282
|
opts.voiceConversation ? VOICE_CONVERSATION_PRELUDE : '',
|
|
278
283
|
]
|
|
279
284
|
.filter(Boolean)
|
package/dist/harness/loop.d.ts
CHANGED
|
@@ -62,6 +62,15 @@ export interface RunOptions {
|
|
|
62
62
|
/** The turn came from voice conversation mode; append the spoken-reply
|
|
63
63
|
* block to the system prompt so the agent writes speakable prose. */
|
|
64
64
|
voiceConversation?: boolean;
|
|
65
|
+
/** Skip the per-turn <memories> recall block. Set by the memory sweep's
|
|
66
|
+
* own summarize runs: injecting recalled memories into the call that
|
|
67
|
+
* extracts memories would pollute its carefully-shaped prompt. */
|
|
68
|
+
skipMemoryRecall?: boolean;
|
|
69
|
+
/** Explicit project scope for the recall block. Set by autonomous task
|
|
70
|
+
* runs, whose workingDir is a worktree (or managed repo dir) that never
|
|
71
|
+
* prefix-matches the project's workingDir — the task record already
|
|
72
|
+
* knows the project. Host-side, never the model's choice. */
|
|
73
|
+
memoryProjectId?: string;
|
|
65
74
|
}
|
|
66
75
|
export interface RunResult {
|
|
67
76
|
/** Concatenated assistant text across all turns. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources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AoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,KAAK,EAAE,cAAc,CAAC;IACtB,qEAAqE;IACrE,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;CACxC;AAED,wBAAsB,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,GAAE,YAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,CA+VrF"}
|
package/dist/harness/loop.js
CHANGED
|
@@ -17,6 +17,7 @@ import { buildRequestBody, readStream } from './provider.js';
|
|
|
17
17
|
import { mapMessagesToChat } from './history.js';
|
|
18
18
|
import { toOpenAiTool, } from './tools/index.js';
|
|
19
19
|
import { withHarnessPrelude, VOICE_CONVERSATION_PRELUDE } from './prelude.js';
|
|
20
|
+
import { buildMemoriesBlock } from './memory_recall.js';
|
|
20
21
|
import { formatRuntimeInfoBlock } from './runtime_info.js';
|
|
21
22
|
import { loadContextFiles, formatContextBlock, resolveFileReferences } from './context_files.js';
|
|
22
23
|
let fetchImpl = globalThis.fetch.bind(globalThis);
|
|
@@ -78,6 +79,15 @@ export async function run(opts, cb = {}) {
|
|
|
78
79
|
workingDir: toolCtx.workingDir,
|
|
79
80
|
});
|
|
80
81
|
effectiveSystemPrompt = `${effectiveSystemPrompt}\n\n${runtimeBlock}`.trim();
|
|
82
|
+
// Memory recall (read path): per-turn <memories> block — titles matched
|
|
83
|
+
// host-side against the user prompt, zero model calls. '' when memory is
|
|
84
|
+
// unconfigured or nothing matches.
|
|
85
|
+
if (!opts.skipMemoryRecall) {
|
|
86
|
+
const memoriesBlock = await buildMemoriesBlock(prompt, toolCtx.workingDir, opts.memoryProjectId);
|
|
87
|
+
if (memoriesBlock) {
|
|
88
|
+
effectiveSystemPrompt = `${effectiveSystemPrompt}\n\n${memoriesBlock}`.trim();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
81
91
|
// Voice-conversation block is appended last (strongest recency) and only
|
|
82
92
|
// on voice turns — the same session mixes typed and spoken turns.
|
|
83
93
|
if (opts.voiceConversation) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Memory } from '../store/db.js';
|
|
2
|
+
export declare const RECALL_TOP_K = 5;
|
|
3
|
+
export declare const MIN_KEYWORD_LENGTH = 3;
|
|
4
|
+
/** Inverted lexical match — no query tokenization: a stored keyword matches
|
|
5
|
+
* when the lowercased prompt contains it (multi-word keywords work free).
|
|
6
|
+
* score = matched × importanceWeight × (1 + log2(1 + recallCount)):
|
|
7
|
+
* acquired strength weighs in — much-recalled memories surface more easily.
|
|
8
|
+
* Ties: lastRecalledAt desc, then createdAt desc. Top-K, score > 0 only. */
|
|
9
|
+
export declare function matchMemories(prompt: string, memories: Memory[]): Memory[];
|
|
10
|
+
/** The prelude block. Titles only, never bodies: the explicit memory_read
|
|
11
|
+
* IS the recall event that feeds acquired strength — a system that always
|
|
12
|
+
* injects bodies never learns what mattered. '' when no matches. */
|
|
13
|
+
export declare function formatMemoriesBlock(matches: Memory[]): string;
|
|
14
|
+
/** One-stop per-turn recall: gate on MemoryConfig (present = read path on,
|
|
15
|
+
* same gate as the sweep), resolve the project from the run's workingDir,
|
|
16
|
+
* match global + project memories, format. Never throws — recall must
|
|
17
|
+
* never break a chat turn.
|
|
18
|
+
* `explicitProjectId` overrides dir resolution: task cycles run in a
|
|
19
|
+
* worktree (or managed repo dir) that never prefix-matches the project's
|
|
20
|
+
* workingDir, but the caller knows the project from the task record —
|
|
21
|
+
* still host-side, never the model's choice. */
|
|
22
|
+
export declare function buildMemoriesBlock(prompt: string, workingDir: string, explicitProjectId?: string): Promise<string>;
|
|
23
|
+
//# sourceMappingURL=memory_recall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory_recall.d.ts","sourceRoot":"","sources":["../../src/harness/memory_recall.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAK7C,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAOpC;;;;6EAI6E;AAC7E,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAqB1E;AAED;;qEAEqE;AACrE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAS7D;AAED;;;;;;;iDAOiD;AACjD,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,MAAM,CAAC,CAajB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
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: a stored keyword matches
|
|
12
|
+
* when the lowercased prompt contains it (multi-word keywords work free).
|
|
13
|
+
* score = matched × importanceWeight × (1 + log2(1 + recallCount)):
|
|
14
|
+
* acquired strength weighs in — much-recalled memories surface more easily.
|
|
15
|
+
* Ties: lastRecalledAt desc, then createdAt desc. Top-K, score > 0 only. */
|
|
16
|
+
export function matchMemories(prompt, memories) {
|
|
17
|
+
const text = prompt.toLowerCase();
|
|
18
|
+
const scored = [];
|
|
19
|
+
for (const m of memories) {
|
|
20
|
+
let matched = 0;
|
|
21
|
+
for (const k of m.keywords) {
|
|
22
|
+
const kw = k.trim().toLowerCase();
|
|
23
|
+
if (kw.length >= MIN_KEYWORD_LENGTH && text.includes(kw))
|
|
24
|
+
matched++;
|
|
25
|
+
}
|
|
26
|
+
if (matched === 0)
|
|
27
|
+
continue;
|
|
28
|
+
const score = matched * IMPORTANCE_WEIGHT[m.importance] * (1 + Math.log2(1 + (m.recallCount ?? 0)));
|
|
29
|
+
scored.push({ m, score });
|
|
30
|
+
}
|
|
31
|
+
scored.sort((a, b) => b.score - a.score ||
|
|
32
|
+
(b.m.lastRecalledAt ?? '').localeCompare(a.m.lastRecalledAt ?? '') ||
|
|
33
|
+
b.m.createdAt.localeCompare(a.m.createdAt));
|
|
34
|
+
return scored.slice(0, RECALL_TOP_K).map((s) => s.m);
|
|
35
|
+
}
|
|
36
|
+
/** The prelude block. Titles only, never bodies: the explicit memory_read
|
|
37
|
+
* IS the recall event that feeds acquired strength — a system that always
|
|
38
|
+
* injects bodies never learns what mattered. '' when no matches. */
|
|
39
|
+
export function formatMemoriesBlock(matches) {
|
|
40
|
+
if (matches.length === 0)
|
|
41
|
+
return '';
|
|
42
|
+
return [
|
|
43
|
+
'<memories>',
|
|
44
|
+
'Stored memories that may be relevant to the current message:',
|
|
45
|
+
...matches.map((m) => `- ${m.id} — ${m.title} (${m.kind}, ${m.importance})`),
|
|
46
|
+
'To read their full content, call the memory_read tool with the ids (when available).',
|
|
47
|
+
'</memories>',
|
|
48
|
+
].join('\n');
|
|
49
|
+
}
|
|
50
|
+
/** One-stop per-turn recall: gate on MemoryConfig (present = read path on,
|
|
51
|
+
* same gate as the sweep), resolve the project from the run's workingDir,
|
|
52
|
+
* match global + project memories, format. Never throws — recall must
|
|
53
|
+
* never break a chat turn.
|
|
54
|
+
* `explicitProjectId` overrides dir resolution: task cycles run in a
|
|
55
|
+
* worktree (or managed repo dir) that never prefix-matches the project's
|
|
56
|
+
* workingDir, but the caller knows the project from the task record —
|
|
57
|
+
* still host-side, never the model's choice. */
|
|
58
|
+
export async function buildMemoriesBlock(prompt, workingDir, explicitProjectId) {
|
|
59
|
+
try {
|
|
60
|
+
const config = await loadConfig();
|
|
61
|
+
if (!config.memory)
|
|
62
|
+
return '';
|
|
63
|
+
const projectId = explicitProjectId ?? resolveProjectIdForDir(workingDir, config.projects ?? []);
|
|
64
|
+
const candidates = (await listMemories()).filter((m) => m.projectId === '' || m.projectId === projectId);
|
|
65
|
+
return formatMemoriesBlock(matchMemories(prompt, candidates));
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return '';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -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,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,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ACf,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 @@
|
|
|
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":"
|
|
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,QAAQ,CAAC,EAAE,cAAc,CAAC;QAAC,UAAU,EAAE,cAAc,CAAA;KAAE,CAAC;IACtE,yFAAyF;IACzF,SAA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BAIkB;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,6 +3,7 @@ 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;
|
|
@@ -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;
|
|
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,CAAA;CAAO,GACvC,MAAM,CAoCR"}
|
|
@@ -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.
|
|
5
|
-
// machine)
|
|
6
|
-
//
|
|
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
|
|
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]+__/, '');
|
package/dist/store/db.d.ts
CHANGED
|
@@ -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
|
package/dist/store/db.d.ts.map
CHANGED
|
@@ -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;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