agent-recall-mcp 3.5.2 → 3.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +254 -143
- package/dist/build-server.d.ts +28 -0
- package/dist/build-server.d.ts.map +1 -0
- package/dist/build-server.js +55 -0
- package/dist/build-server.js.map +1 -0
- package/dist/http/activity.d.ts +60 -0
- package/dist/http/activity.d.ts.map +1 -0
- package/dist/http/activity.js +254 -0
- package/dist/http/activity.js.map +1 -0
- package/dist/http/alerts.d.ts +84 -0
- package/dist/http/alerts.d.ts.map +1 -0
- package/dist/http/alerts.js +213 -0
- package/dist/http/alerts.js.map +1 -0
- package/dist/http/cli.d.ts +3 -0
- package/dist/http/cli.d.ts.map +1 -0
- package/dist/http/cli.js +515 -0
- package/dist/http/cli.js.map +1 -0
- package/dist/http/export-tar.d.ts +23 -0
- package/dist/http/export-tar.d.ts.map +1 -0
- package/dist/http/export-tar.js +264 -0
- package/dist/http/export-tar.js.map +1 -0
- package/dist/http/federation.d.ts +45 -0
- package/dist/http/federation.d.ts.map +1 -0
- package/dist/http/federation.js +185 -0
- package/dist/http/federation.js.map +1 -0
- package/dist/http/film/film.css +80 -0
- package/dist/http/film/film.js +446 -0
- package/dist/http/film/human.jpg +0 -0
- package/dist/http/film/m0.jpg +0 -0
- package/dist/http/film/m2.jpg +0 -0
- package/dist/http/film/m3.jpg +0 -0
- package/dist/http/film/wrong.jpg +0 -0
- package/dist/http/film.d.ts +16 -0
- package/dist/http/film.d.ts.map +1 -0
- package/dist/http/film.js +119 -0
- package/dist/http/film.js.map +1 -0
- package/dist/http/home/cabinet.svg +1 -0
- package/dist/http/home/drawer-project.svg +1 -0
- package/dist/http/home/drawer-rules.svg +1 -0
- package/dist/http/home/drawer-you.svg +1 -0
- package/dist/http/home/fig1.svg +242 -0
- package/dist/http/home/fig2-1.svg +61 -0
- package/dist/http/home/fig2-2.svg +92 -0
- package/dist/http/home/fig3.svg +1 -0
- package/dist/http/home/home.css +509 -0
- package/dist/http/home/home.html +517 -0
- package/dist/http/home/icons.svg +15 -0
- package/dist/http/home.d.ts +23 -0
- package/dist/http/home.d.ts.map +1 -0
- package/dist/http/home.js +295 -0
- package/dist/http/home.js.map +1 -0
- package/dist/http/identities.d.ts +29 -0
- package/dist/http/identities.d.ts.map +1 -0
- package/dist/http/identities.js +91 -0
- package/dist/http/identities.js.map +1 -0
- package/dist/http/import-memory.d.ts +161 -0
- package/dist/http/import-memory.d.ts.map +1 -0
- package/dist/http/import-memory.js +718 -0
- package/dist/http/import-memory.js.map +1 -0
- package/dist/http/jsonfile.d.ts +6 -0
- package/dist/http/jsonfile.d.ts.map +1 -0
- package/dist/http/jsonfile.js +60 -0
- package/dist/http/jsonfile.js.map +1 -0
- package/dist/http/legal/PRIVACY.md +70 -0
- package/dist/http/legal.d.ts +10 -0
- package/dist/http/legal.d.ts.map +1 -0
- package/dist/http/legal.js +35 -0
- package/dist/http/legal.js.map +1 -0
- package/dist/http/limits.d.ts +59 -0
- package/dist/http/limits.d.ts.map +1 -0
- package/dist/http/limits.js +163 -0
- package/dist/http/limits.js.map +1 -0
- package/dist/http/markdown-lite.d.ts +2 -0
- package/dist/http/markdown-lite.d.ts.map +1 -0
- package/dist/http/markdown-lite.js +86 -0
- package/dist/http/markdown-lite.js.map +1 -0
- package/dist/http/multipart.d.ts +43 -0
- package/dist/http/multipart.d.ts.map +1 -0
- package/dist/http/multipart.js +152 -0
- package/dist/http/multipart.js.map +1 -0
- package/dist/http/oauth-app.d.ts +75 -0
- package/dist/http/oauth-app.d.ts.map +1 -0
- package/dist/http/oauth-app.js +259 -0
- package/dist/http/oauth-app.js.map +1 -0
- package/dist/http/oauth-config.d.ts +46 -0
- package/dist/http/oauth-config.d.ts.map +1 -0
- package/dist/http/oauth-config.js +122 -0
- package/dist/http/oauth-config.js.map +1 -0
- package/dist/http/oauth-pages.d.ts +40 -0
- package/dist/http/oauth-pages.d.ts.map +1 -0
- package/dist/http/oauth-pages.js +97 -0
- package/dist/http/oauth-pages.js.map +1 -0
- package/dist/http/oauth-provider.d.ts +124 -0
- package/dist/http/oauth-provider.d.ts.map +1 -0
- package/dist/http/oauth-provider.js +486 -0
- package/dist/http/oauth-provider.js.map +1 -0
- package/dist/http/oauth-store.d.ts +128 -0
- package/dist/http/oauth-store.d.ts.map +1 -0
- package/dist/http/oauth-store.js +317 -0
- package/dist/http/oauth-store.js.map +1 -0
- package/dist/http/redirect-policy.d.ts +16 -0
- package/dist/http/redirect-policy.d.ts.map +1 -0
- package/dist/http/redirect-policy.js +83 -0
- package/dist/http/redirect-policy.js.map +1 -0
- package/dist/http/review-pages.d.ts +39 -0
- package/dist/http/review-pages.d.ts.map +1 -0
- package/dist/http/review-pages.js +78 -0
- package/dist/http/review-pages.js.map +1 -0
- package/dist/http/review.d.ts +36 -0
- package/dist/http/review.d.ts.map +1 -0
- package/dist/http/review.js +220 -0
- package/dist/http/review.js.map +1 -0
- package/dist/http/serve.d.ts +58 -0
- package/dist/http/serve.d.ts.map +1 -0
- package/dist/http/serve.js +324 -0
- package/dist/http/serve.js.map +1 -0
- package/dist/http/site-pages.d.ts +110 -0
- package/dist/http/site-pages.d.ts.map +1 -0
- package/dist/http/site-pages.js +630 -0
- package/dist/http/site-pages.js.map +1 -0
- package/dist/http/site-theme.d.ts +13 -0
- package/dist/http/site-theme.d.ts.map +1 -0
- package/dist/http/site-theme.js +22 -0
- package/dist/http/site-theme.js.map +1 -0
- package/dist/http/site.d.ts +52 -0
- package/dist/http/site.d.ts.map +1 -0
- package/dist/http/site.js +353 -0
- package/dist/http/site.js.map +1 -0
- package/dist/http/stats.d.ts +139 -0
- package/dist/http/stats.d.ts.map +1 -0
- package/dist/http/stats.js +599 -0
- package/dist/http/stats.js.map +1 -0
- package/dist/http/tar-import.d.ts +69 -0
- package/dist/http/tar-import.d.ts.map +1 -0
- package/dist/http/tar-import.js +234 -0
- package/dist/http/tar-import.js.map +1 -0
- package/dist/http/tenant-paths.d.ts +14 -0
- package/dist/http/tenant-paths.d.ts.map +1 -0
- package/dist/http/tenant-paths.js +42 -0
- package/dist/http/tenant-paths.js.map +1 -0
- package/dist/http/tokens.d.ts +32 -0
- package/dist/http/tokens.d.ts.map +1 -0
- package/dist/http/tokens.js +137 -0
- package/dist/http/tokens.js.map +1 -0
- package/dist/http/trial.d.ts +55 -0
- package/dist/http/trial.d.ts.map +1 -0
- package/dist/http/trial.js +218 -0
- package/dist/http/trial.js.map +1 -0
- package/dist/http/web-session.d.ts +108 -0
- package/dist/http/web-session.d.ts.map +1 -0
- package/dist/http/web-session.js +267 -0
- package/dist/http/web-session.js.map +1 -0
- package/dist/index.js +12 -65
- package/dist/index.js.map +1 -1
- package/dist/lib/ambient-capture.d.ts.map +1 -1
- package/dist/lib/ambient-capture.js +4 -1
- package/dist/lib/ambient-capture.js.map +1 -1
- package/dist/lib/bookkeeping.d.ts +26 -0
- package/dist/lib/bookkeeping.d.ts.map +1 -0
- package/dist/lib/bookkeeping.js +31 -0
- package/dist/lib/bookkeeping.js.map +1 -0
- package/dist/lib/hosted-redact.d.ts +17 -0
- package/dist/lib/hosted-redact.d.ts.map +1 -0
- package/dist/lib/hosted-redact.js +57 -0
- package/dist/lib/hosted-redact.js.map +1 -0
- package/dist/lib/lifecycle-exit.d.ts +5 -13
- package/dist/lib/lifecycle-exit.d.ts.map +1 -1
- package/dist/lib/lifecycle-exit.js +38 -16
- package/dist/lib/lifecycle-exit.js.map +1 -1
- package/dist/server.d.ts +3 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -3
- package/dist/server.js.map +1 -1
- package/dist/tools/annotations.d.ts +65 -0
- package/dist/tools/annotations.d.ts.map +1 -0
- package/dist/tools/annotations.js +4 -0
- package/dist/tools/annotations.js.map +1 -0
- package/dist/tools/check-action.d.ts.map +1 -1
- package/dist/tools/check-action.js +2 -0
- package/dist/tools/check-action.js.map +1 -1
- package/dist/tools/check.d.ts.map +1 -1
- package/dist/tools/check.js +6 -2
- package/dist/tools/check.js.map +1 -1
- package/dist/tools/digest.d.ts.map +1 -1
- package/dist/tools/digest.js +2 -0
- package/dist/tools/digest.js.map +1 -1
- package/dist/tools/pipeline-close.d.ts.map +1 -1
- package/dist/tools/pipeline-close.js +2 -0
- package/dist/tools/pipeline-close.js.map +1 -1
- package/dist/tools/pipeline-current.d.ts.map +1 -1
- package/dist/tools/pipeline-current.js +2 -0
- package/dist/tools/pipeline-current.js.map +1 -1
- package/dist/tools/pipeline-list.d.ts.map +1 -1
- package/dist/tools/pipeline-list.js +2 -0
- package/dist/tools/pipeline-list.js.map +1 -1
- package/dist/tools/pipeline-open.d.ts.map +1 -1
- package/dist/tools/pipeline-open.js +2 -0
- package/dist/tools/pipeline-open.js.map +1 -1
- package/dist/tools/pipeline-show.d.ts.map +1 -1
- package/dist/tools/pipeline-show.js +2 -0
- package/dist/tools/pipeline-show.js.map +1 -1
- package/dist/tools/recall.d.ts.map +1 -1
- package/dist/tools/recall.js +4 -1
- package/dist/tools/recall.js.map +1 -1
- package/dist/tools/register-rule.d.ts.map +1 -1
- package/dist/tools/register-rule.js +2 -0
- package/dist/tools/register-rule.js.map +1 -1
- package/dist/tools/remember.d.ts.map +1 -1
- package/dist/tools/remember.js +10 -1
- package/dist/tools/remember.js.map +1 -1
- package/dist/tools/session-end.d.ts +15 -0
- package/dist/tools/session-end.d.ts.map +1 -1
- package/dist/tools/session-end.js +13 -1
- package/dist/tools/session-end.js.map +1 -1
- package/dist/tools/session-start.d.ts +6 -1
- package/dist/tools/session-start.d.ts.map +1 -1
- package/dist/tools/session-start.js +24 -212
- package/dist/tools/session-start.js.map +1 -1
- package/package.json +11 -8
package/dist/index.js
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
-
import { VERSION, getRoot, getLegacyRoot } from "agent-recall-core";
|
|
4
|
-
import {
|
|
5
|
-
import { installAmbientCapture } from "./lib/ambient-capture.js";
|
|
3
|
+
import { VERSION, getRoot, getLegacyRoot, resolveHostProfile } from "agent-recall-core";
|
|
4
|
+
import { buildServer } from "./build-server.js";
|
|
6
5
|
import { installLifecycleExitHandlers } from "./lib/lifecycle-exit.js";
|
|
7
6
|
// ── v3.4 primary tools (5-tool surface) ──────────────────────────────────
|
|
8
|
-
import { register as registerSessionStart } from "./tools/session-start.js";
|
|
9
|
-
import { register as registerRemember } from "./tools/remember.js";
|
|
10
|
-
import { register as registerRecall } from "./tools/recall.js";
|
|
11
|
-
import { register as registerSessionEnd } from "./tools/session-end.js";
|
|
12
|
-
import { register as registerCheck } from "./tools/check.js";
|
|
13
7
|
// ── Pre-action proactive matcher (--full) ────────────────────────────────
|
|
14
|
-
import { register as registerCheckAction } from "./tools/check-action.js";
|
|
15
8
|
// ── AR_EXTRAS quarantine zone — purity-census-2026-07-05 ─────────────────
|
|
16
9
|
// These tools are ZOMBIE/low-use (pipeline: 1 organic use in 60d; register_rule: 2;
|
|
17
10
|
// digest: 0 MCP calls). Core logic files stay untouched for reversibility.
|
|
18
11
|
// Activate with: AR_EXTRAS=1 npx agent-recall-mcp --full
|
|
19
|
-
import { register as registerPipelineOpen } from "./tools/pipeline-open.js";
|
|
20
|
-
import { register as registerPipelineClose } from "./tools/pipeline-close.js";
|
|
21
|
-
import { register as registerPipelineList } from "./tools/pipeline-list.js";
|
|
22
|
-
import { register as registerPipelineCurrent } from "./tools/pipeline-current.js";
|
|
23
|
-
import { register as registerPipelineShow } from "./tools/pipeline-show.js";
|
|
24
|
-
import { register as registerRegisterRule } from "./tools/register-rule.js";
|
|
25
|
-
import { register as registerDigest } from "./tools/digest.js";
|
|
26
12
|
// ── Legacy tools (still importable for SDK/CLI, not registered by default) ──
|
|
27
13
|
// DEPRECATED v3.4: use session_start instead
|
|
28
14
|
// import { register as registerJournalColdStart } from "./tools/journal-cold-start.js";
|
|
@@ -67,9 +53,6 @@ import { register as registerDigest } from "./tools/digest.js";
|
|
|
67
53
|
// import { register as registerBrief } from "./tools/brief.js";
|
|
68
54
|
// NOTE: bootstrap CLI command STAYS (ar bootstrap); skill logic stays (palace/skills.ts);
|
|
69
55
|
// session_end_reflect logic stays (ar consolidate); project_board logic stays (ar status).
|
|
70
|
-
import { register as registerJournalResources } from "./resources/journal-resources.js";
|
|
71
|
-
import { register as registerAwarenessResource } from "./resources/awareness-resource.js";
|
|
72
|
-
import { register as registerSessionPrompts } from "./prompts/session-prompts.js";
|
|
73
56
|
const args = process.argv.slice(2);
|
|
74
57
|
if (args.includes("--help") || args.includes("-h")) {
|
|
75
58
|
process.stdout.write(`agent-recall-mcp v${VERSION}
|
|
@@ -87,7 +70,7 @@ Usage:
|
|
|
87
70
|
npx agent-recall-mcp --list-tools List available MCP tools (add --full to see full list)
|
|
88
71
|
|
|
89
72
|
Default tools (5):
|
|
90
|
-
session_start [ENTRY — call FIRST, before acting] Load project context at session start —
|
|
73
|
+
session_start [ENTRY — call FIRST, before acting] Load project context at session start — owner card, hard rules, state card (mode=cards); mode=full adds insights, warnings
|
|
91
74
|
session_end [ON SAVE/EXIT — YOU must call this; nothing auto-saves] Save journal, insights, trajectory — compounds memory over time
|
|
92
75
|
remember [MID-SESSION WRITE — single fact/decision; saying it is not saving it] Write a memory — auto-routes to the right store
|
|
93
76
|
recall [RETRIEVE — use freely, any time] Search all memory — keyword/RRF fusion + optional vector (OpenAI key)
|
|
@@ -120,7 +103,7 @@ const fullMode = args.includes("--full");
|
|
|
120
103
|
const extrasMode = fullMode && process.env.AR_EXTRAS === "1";
|
|
121
104
|
if (args.includes("--list-tools")) {
|
|
122
105
|
const coreTools = [
|
|
123
|
-
{ name: "session_start", description: "[ENTRY — call FIRST, before acting] Load project context at session start —
|
|
106
|
+
{ name: "session_start", description: "[ENTRY — call FIRST, before acting] Load project context at session start — owner card, hard rules, state card (mode=cards); mode=full adds insights, watch_for warnings" },
|
|
124
107
|
{ name: "session_end", description: "[ON SAVE/EXIT — YOU must call this; nothing auto-saves] Save journal, insights, and trajectory — compounds memory over time" },
|
|
125
108
|
{ name: "remember", description: "[MID-SESSION WRITE — single fact/decision; saying it is not saving it] Save a memory — auto-routes to the right store" },
|
|
126
109
|
{ name: "recall", description: "[RETRIEVE — use freely, any time] Search all memory stores, return ranked results with feedback" },
|
|
@@ -149,50 +132,14 @@ if (args.includes("--list-tools")) {
|
|
|
149
132
|
process.stdout.write(JSON.stringify(tools, null, 2) + "\n");
|
|
150
133
|
process.exit(0);
|
|
151
134
|
}
|
|
152
|
-
//
|
|
153
|
-
//
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
// Automaticity Law: only memory that arrives unasked gets used.
|
|
161
|
-
// Push channels (session_start/end, hooks) drive behavior; pull channels don't.
|
|
162
|
-
// Every extra tool in the default surface burns tool-definition tokens every session.
|
|
163
|
-
registerSessionStart(server);
|
|
164
|
-
registerSessionEnd(server);
|
|
165
|
-
registerRemember(server);
|
|
166
|
-
registerRecall(server);
|
|
167
|
-
registerCheck(server);
|
|
168
|
-
// ── Extended tools (--full mode only) ────────────────────────────────────────
|
|
169
|
-
// P3b purity-census-2026-07-05: stripped to check_action only.
|
|
170
|
-
// skill_write/recall/list, dashboard_export, session_end_reflect, project_board,
|
|
171
|
-
// project_status, bootstrap_scan/import, memory_query, brief all removed from MCP
|
|
172
|
-
// surface (owner-approved 2026-07-05). CLI paths for these remain intact.
|
|
173
|
-
if (fullMode) {
|
|
174
|
-
registerCheckAction(server);
|
|
175
|
-
}
|
|
176
|
-
// ── AR_EXTRAS quarantine zone (purity-census-2026-07-05) ─────────────────────
|
|
177
|
-
// Activate with: AR_EXTRAS=1 npx agent-recall-mcp --full
|
|
178
|
-
// Pipeline: 1 organic use (60d); register_rule: 2 uses; digest: 0 MCP uses.
|
|
179
|
-
// Core logic untouched for reversibility. These tools do NOT appear in the default
|
|
180
|
-
// --full listing — they are invisible until AR_EXTRAS=1 is set.
|
|
181
|
-
if (extrasMode) {
|
|
182
|
-
// Pipeline tools — project narrative spine (ZOMBIE: last used 2026-05-30)
|
|
183
|
-
registerPipelineOpen(server);
|
|
184
|
-
registerPipelineClose(server);
|
|
185
|
-
registerPipelineList(server);
|
|
186
|
-
registerPipelineCurrent(server);
|
|
187
|
-
registerPipelineShow(server);
|
|
188
|
-
// Behavior policies (ZOMBIE: 2 organic uses, last 2026-06-03)
|
|
189
|
-
registerRegisterRule(server);
|
|
190
|
-
// Context cache (DEAD via MCP: 0 MCP calls; CLI last used 2026-06-18)
|
|
191
|
-
registerDigest(server);
|
|
192
|
-
}
|
|
193
|
-
registerJournalResources(server);
|
|
194
|
-
registerAwarenessResource(server);
|
|
195
|
-
registerSessionPrompts(server);
|
|
135
|
+
// One builder for both entry points (see build-server.ts). Stdio = one local
|
|
136
|
+
// user per process: tier from the host env, ambient capture on.
|
|
137
|
+
const server = buildServer({
|
|
138
|
+
tier: resolveHostProfile().tier,
|
|
139
|
+
full: fullMode,
|
|
140
|
+
extras: extrasMode,
|
|
141
|
+
ambientCapture: true,
|
|
142
|
+
});
|
|
196
143
|
async function main() {
|
|
197
144
|
const transport = new StdioServerTransport();
|
|
198
145
|
await server.connect(transport);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB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AgGzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"ambient-capture.d.ts","sourceRoot":"","sources":["../../src/lib/ambient-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAgGzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAe7D"}
|
|
@@ -169,7 +169,10 @@ export function installAmbientCapture(server) {
|
|
|
169
169
|
return;
|
|
170
170
|
const originalRegisterTool = server.registerTool.bind(server);
|
|
171
171
|
server.registerTool = ((name, config, handler) => {
|
|
172
|
-
|
|
172
|
+
// A tool that declares readOnlyHint: true must not write: a retrieval call (session_start, recall) is not
|
|
173
|
+
// work worth crash-rescuing, and its query text must never land on disk because of a read.
|
|
174
|
+
const readOnly = config?.annotations?.readOnlyHint === true;
|
|
175
|
+
return originalRegisterTool(name, config, readOnly ? handler : withAmbientCapture(name, handler));
|
|
173
176
|
});
|
|
174
177
|
}
|
|
175
178
|
//# sourceMappingURL=ambient-capture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ambient-capture.js","sourceRoot":"","sources":["../../src/lib/ambient-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAGH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE/F;;;;;;GAMG;AACH,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B;;;;;;;;GAQG;AACH,MAAM,qBAAqB,GAAG;IAC5B,OAAO;IACP,MA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CAAC,MAAM,CAAC,CAAC;IAE9D,MAAM,CAAC,YAAY,GAAG,CAAC,CAAC,IAAY,EAAE,MAAoD,EAAE,OAA0C,EAAE,EAAE;QACxI,0GAA0G;QAC1G,2FAA2F;QAC3F,MAAM,QAAQ,GAAG,MAAM,EAAE,WAAW,EAAE,YAAY,KAAK,IAAI,CAAC;QAC5D,OAAQ,oBAA2D,CACjE,IAAI,EACJ,MAAM,EACN,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CACvD,CAAC;IACJ,CAAC,CAA+B,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bookkeeping.ts: what makes a tool annotated readOnlyHint: true actually read-only.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the server INSTANCE's registerTool once (same pattern as ambient-capture.ts), so every current and
|
|
5
|
+
* future tool is covered with no per-tool wiring:
|
|
6
|
+
* - a tool annotated readOnlyHint: true runs inside withDeferredBookkeeping(): the retrieval counters,
|
|
7
|
+
* telemetry and caches it would record are queued instead of written (see core's deferred-bookkeeping.ts);
|
|
8
|
+
* - every other tool applies this store's queue first (flushBookkeeping), so a write sees current counters,
|
|
9
|
+
* but waits at most PRE_WRITE_FLUSH_MS for it: a wedged lock or a hung op must not stall the write. The
|
|
10
|
+
* flush keeps running in the background and is never cancelled.
|
|
11
|
+
* Advisory counters: after the 1.5 s wait a slow flush may still be applying ops while the write runs, so a
|
|
12
|
+
* read-modify-write counter op on a file the write also edits can lose one update (counters may undercount
|
|
13
|
+
* after a slow flush). Nothing ranks on an exact count; no lock is taken. A queued op that never settles is
|
|
14
|
+
* cut off per op inside core's flush, so the chain behind it still advances.
|
|
15
|
+
* Never throws into the tool call. Must be installed BEFORE ambient capture and hosted redaction so it is the
|
|
16
|
+
* outermost wrapper.
|
|
17
|
+
*
|
|
18
|
+
* Ambient capture (ambient-capture.ts) skips read-only tools, so a read writes no working-memory note either.
|
|
19
|
+
*/
|
|
20
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
21
|
+
/** Longest a write tool (and each shutdown flush) waits for queued read bookkeeping. */
|
|
22
|
+
export declare const PRE_WRITE_FLUSH_MS = 1500;
|
|
23
|
+
/** Resolve when the work settles or after ms, whichever is first. Never rejects; does not cancel the work. */
|
|
24
|
+
export declare function settleWithin(work: Promise<unknown>, ms: number): Promise<void>;
|
|
25
|
+
export declare function installBookkeeping(server: McpServer): void;
|
|
26
|
+
//# sourceMappingURL=bookkeeping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bookkeeping.d.ts","sourceRoot":"","sources":["../../src/lib/bookkeeping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,wFAAwF;AACxF,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAEvC,8GAA8G;AAC9G,wBAAsB,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUpF;AAID,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAY1D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { withDeferredBookkeeping, flushBookkeeping } from "agent-recall-core";
|
|
2
|
+
/** Longest a write tool (and each shutdown flush) waits for queued read bookkeeping. */
|
|
3
|
+
export const PRE_WRITE_FLUSH_MS = 1500;
|
|
4
|
+
/** Resolve when the work settles or after ms, whichever is first. Never rejects; does not cancel the work. */
|
|
5
|
+
export async function settleWithin(work, ms) {
|
|
6
|
+
let timer;
|
|
7
|
+
try {
|
|
8
|
+
await Promise.race([
|
|
9
|
+
work.then(() => undefined, () => undefined),
|
|
10
|
+
new Promise((resolve) => { timer = setTimeout(resolve, ms); }),
|
|
11
|
+
]);
|
|
12
|
+
}
|
|
13
|
+
finally {
|
|
14
|
+
if (timer)
|
|
15
|
+
clearTimeout(timer);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function installBookkeeping(server) {
|
|
19
|
+
const original = server.registerTool.bind(server);
|
|
20
|
+
server.registerTool = ((name, config, handler) => {
|
|
21
|
+
const readOnly = config?.annotations?.readOnlyHint === true;
|
|
22
|
+
const wrapped = readOnly
|
|
23
|
+
? (...args) => withDeferredBookkeeping(() => handler(...args))
|
|
24
|
+
: async (...args) => {
|
|
25
|
+
await settleWithin(flushBookkeeping(), PRE_WRITE_FLUSH_MS);
|
|
26
|
+
return handler(...args);
|
|
27
|
+
};
|
|
28
|
+
return original(name, config, wrapped);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=bookkeeping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bookkeeping.js","sourceRoot":"","sources":["../../src/lib/bookkeeping.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,wFAAwF;AACxF,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEvC,8GAA8G;AAC9G,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAsB,EAAE,EAAU;IACnE,IAAI,KAAiC,CAAC;IACtC,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,IAAI,CAAC;YACjB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC;YAC3C,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SACrE,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;AACH,CAAC;AAID,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IAClD,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAA4E,CAAC;IAC7H,MAAM,CAAC,YAAY,GAAG,CAAC,CAAC,IAAY,EAAE,MAAoD,EAAE,OAAgB,EAAE,EAAE;QAC9G,MAAM,QAAQ,GAAG,MAAM,EAAE,WAAW,EAAE,YAAY,KAAK,IAAI,CAAC;QAC5D,MAAM,OAAO,GAAY,QAAQ;YAC/B,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,uBAAuB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;YAC9D,CAAC,CAAC,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE;gBAChB,MAAM,YAAY,CAAC,gBAAgB,EAAE,EAAE,kBAAkB,CAAC,CAAC;gBAC3D,OAAO,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;YAC1B,CAAC,CAAC;QACN,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC,CAA0C,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hosted-redact.ts — hosted backstop: no response reveals the server's filesystem.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the server INSTANCE's registerTool / registerResource / registerPrompt
|
|
5
|
+
* once (same pattern as ambient-capture.ts), so every handler — current and
|
|
6
|
+
* future — has its result strings and thrown error messages passed through
|
|
7
|
+
* core's redactTenantPaths() (tenant root → "hosted:"). Must be installed
|
|
8
|
+
* BEFORE any register*(server) call. Hosted only; stdio servers never install it.
|
|
9
|
+
*/
|
|
10
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
11
|
+
type Handler = (...args: unknown[]) => unknown;
|
|
12
|
+
/** Deep-copies plain data, redacting every string. Non-plain objects pass through. */
|
|
13
|
+
export declare function deepRedact(value: unknown, depth?: number): unknown;
|
|
14
|
+
export declare function withRedaction(handler: Handler): Handler;
|
|
15
|
+
export declare function installHostedRedaction(server: McpServer): void;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=hosted-redact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-redact.d.ts","sourceRoot":"","sources":["../../src/lib/hosted-redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,KAAK,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;AAW/C,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,OAAO,CAQ7D;AAWD,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAQvD;AAYD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAI9D"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { redactTenantPaths } from "agent-recall-core";
|
|
2
|
+
/** Beyond this nesting depth values pass through (guards against cycles; MCP results are shallow). */
|
|
3
|
+
const MAX_DEPTH = 32;
|
|
4
|
+
function isPlainObject(v) {
|
|
5
|
+
if (v === null || typeof v !== "object")
|
|
6
|
+
return false;
|
|
7
|
+
const proto = Object.getPrototypeOf(v);
|
|
8
|
+
return proto === Object.prototype || proto === null;
|
|
9
|
+
}
|
|
10
|
+
/** Deep-copies plain data, redacting every string. Non-plain objects pass through. */
|
|
11
|
+
export function deepRedact(value, depth = 0) {
|
|
12
|
+
if (typeof value === "string")
|
|
13
|
+
return redactTenantPaths(value);
|
|
14
|
+
if (depth >= MAX_DEPTH)
|
|
15
|
+
return value;
|
|
16
|
+
if (Array.isArray(value))
|
|
17
|
+
return value.map((v) => deepRedact(v, depth + 1));
|
|
18
|
+
if (isPlainObject(value)) {
|
|
19
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, deepRedact(v, depth + 1)]));
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
/** Scrubs whatever a handler threw. The SDK sends err.message (or String(err)) and McpError.data to the client. */
|
|
24
|
+
function redactThrown(err) {
|
|
25
|
+
if (!(err instanceof Error))
|
|
26
|
+
return new Error(redactTenantPaths(String(err)));
|
|
27
|
+
err.message = redactTenantPaths(err.message);
|
|
28
|
+
const withData = err;
|
|
29
|
+
if (withData.data !== undefined)
|
|
30
|
+
withData.data = deepRedact(withData.data);
|
|
31
|
+
return err;
|
|
32
|
+
}
|
|
33
|
+
export function withRedaction(handler) {
|
|
34
|
+
return async (...args) => {
|
|
35
|
+
try {
|
|
36
|
+
return deepRedact(await handler(...args));
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
throw redactThrown(err);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function wrapLastHandler(original) {
|
|
44
|
+
return (...regArgs) => {
|
|
45
|
+
const last = regArgs.length - 1;
|
|
46
|
+
if (last >= 0 && typeof regArgs[last] === "function") {
|
|
47
|
+
regArgs[last] = withRedaction(regArgs[last]);
|
|
48
|
+
}
|
|
49
|
+
return original(...regArgs);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function installHostedRedaction(server) {
|
|
53
|
+
server.registerTool = wrapLastHandler(server.registerTool.bind(server));
|
|
54
|
+
server.registerResource = wrapLastHandler(server.registerResource.bind(server));
|
|
55
|
+
server.registerPrompt = wrapLastHandler(server.registerPrompt.bind(server));
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=hosted-redact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-redact.js","sourceRoot":"","sources":["../../src/l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BAAgB,CAAC,IAAI,CAAC,MAAM,CAAY,CAAmC,CAAC;IAC7H,MAAM,CAAC,cAAc,GAAG,eAAe,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAY,CAAiC,CAAC;AACzH,CAAC"}
|
|
@@ -27,19 +27,11 @@
|
|
|
27
27
|
* registered listener a no-op, but this function itself is not meant to be
|
|
28
28
|
* (and is not) called more than once.
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* session id; this module's `distillSessionToCard(getSessionId())` targets
|
|
36
|
-
* a different, MCP-process-local random id. Post the ambient-capture gate,
|
|
37
|
-
* that id has no working-memory file to distill anyway, so this handler
|
|
38
|
-
* would already be a no-op in practice — but registering the SIGTERM/SIGINT
|
|
39
|
-
* listeners themselves is still skipped, so this MCP server process never
|
|
40
|
-
* intercepts a signal that the host's own hook/process-supervision stack
|
|
41
|
-
* expects to observe unhandled (e.g. Node's default terminate-on-SIGTERM),
|
|
42
|
-
* and never calls `process.exit(0)` on a host that did not ask for that.
|
|
30
|
+
* Hook-owned host (see `isHookOwnedHost`, agent-recall-core/host-profile.ts; ambient-capture.ts gates the
|
|
31
|
+
* same way): hook-end owns distillation for the REAL session id, so this process does NOT distill and never
|
|
32
|
+
* calls process.exit(0) on its own. It installs flush-only handlers instead (installFlushOnlyHandlers): the
|
|
33
|
+
* queued read bookkeeping belongs to this process, so it is flushed (bounded) on stdin end/close and on
|
|
34
|
+
* SIGTERM/SIGINT, and a signal is then re-raised with its handler removed so the process still dies of it.
|
|
43
35
|
*/
|
|
44
36
|
export declare function installLifecycleExitHandlers(): void;
|
|
45
37
|
//# sourceMappingURL=lifecycle-exit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-exit.d.ts","sourceRoot":"","sources":["../../src/lib/lifecycle-exit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;
|
|
1
|
+
{"version":3,"file":"lifecycle-exit.d.ts","sourceRoot":"","sources":["../../src/lib/lifecycle-exit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AA0CH;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,IAAI,IAAI,CAUnD"}
|
|
@@ -20,12 +20,13 @@
|
|
|
20
20
|
* sweep), not this module's. This module is a freshness optimization on top
|
|
21
21
|
* of that durability guarantee, never a replacement for it.
|
|
22
22
|
*/
|
|
23
|
-
import { getSessionId, distillSessionToCard, isHookOwnedHost } from "agent-recall-core";
|
|
23
|
+
import { getSessionId, distillSessionToCard, isHookOwnedHost, flushAllBookkeeping } from "agent-recall-core";
|
|
24
|
+
import { PRE_WRITE_FLUSH_MS, settleWithin } from "./bookkeeping.js";
|
|
24
25
|
/** Hard ceiling on how long this handler may delay process exit (design doc C-3 guard). */
|
|
25
26
|
const EXIT_TIMEOUT_MS = 2000;
|
|
26
27
|
/** Idempotency guard — `stdin` "end" AND "close" can both fire, and a signal could race either. */
|
|
27
28
|
let fired = false;
|
|
28
|
-
function runOnce() {
|
|
29
|
+
async function runOnce() {
|
|
29
30
|
if (fired)
|
|
30
31
|
return;
|
|
31
32
|
fired = true;
|
|
@@ -39,6 +40,8 @@ function runOnce() {
|
|
|
39
40
|
}, EXIT_TIMEOUT_MS);
|
|
40
41
|
forceExit.unref();
|
|
41
42
|
try {
|
|
43
|
+
// Queued read bookkeeping (including the working-memory notes of read-only calls) lands first, so the distill sees it.
|
|
44
|
+
await settleWithin(flushAllBookkeeping(), PRE_WRITE_FLUSH_MS);
|
|
42
45
|
// Reuses the SAME WM→card mechanism C-2's orphan-rescue sweep uses
|
|
43
46
|
// (distillOneSession, storage/working-memory.ts) for THIS process's own,
|
|
44
47
|
// still-fresh session id — no age gate, because this fires precisely
|
|
@@ -61,26 +64,45 @@ function runOnce() {
|
|
|
61
64
|
* registered listener a no-op, but this function itself is not meant to be
|
|
62
65
|
* (and is not) called more than once.
|
|
63
66
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* session id; this module's `distillSessionToCard(getSessionId())` targets
|
|
70
|
-
* a different, MCP-process-local random id. Post the ambient-capture gate,
|
|
71
|
-
* that id has no working-memory file to distill anyway, so this handler
|
|
72
|
-
* would already be a no-op in practice — but registering the SIGTERM/SIGINT
|
|
73
|
-
* listeners themselves is still skipped, so this MCP server process never
|
|
74
|
-
* intercepts a signal that the host's own hook/process-supervision stack
|
|
75
|
-
* expects to observe unhandled (e.g. Node's default terminate-on-SIGTERM),
|
|
76
|
-
* and never calls `process.exit(0)` on a host that did not ask for that.
|
|
67
|
+
* Hook-owned host (see `isHookOwnedHost`, agent-recall-core/host-profile.ts; ambient-capture.ts gates the
|
|
68
|
+
* same way): hook-end owns distillation for the REAL session id, so this process does NOT distill and never
|
|
69
|
+
* calls process.exit(0) on its own. It installs flush-only handlers instead (installFlushOnlyHandlers): the
|
|
70
|
+
* queued read bookkeeping belongs to this process, so it is flushed (bounded) on stdin end/close and on
|
|
71
|
+
* SIGTERM/SIGINT, and a signal is then re-raised with its handler removed so the process still dies of it.
|
|
77
72
|
*/
|
|
78
73
|
export function installLifecycleExitHandlers() {
|
|
79
|
-
if (isHookOwnedHost())
|
|
74
|
+
if (isHookOwnedHost()) {
|
|
75
|
+
installFlushOnlyHandlers();
|
|
80
76
|
return;
|
|
77
|
+
}
|
|
81
78
|
process.stdin.on("end", runOnce);
|
|
82
79
|
process.stdin.on("close", runOnce);
|
|
83
80
|
process.on("SIGTERM", runOnce);
|
|
84
81
|
process.on("SIGINT", runOnce);
|
|
85
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Hook-owned host (Claude Code with hooks): hook-end owns distillation, so none happens here, and this process
|
|
85
|
+
* never calls process.exit(0) on its own. But the queued read bookkeeping (counters, lifecycle telemetry, recall
|
|
86
|
+
* ratings) belongs to THIS process and nothing else will flush it, so it is flushed (bounded) on stdin end/close
|
|
87
|
+
* and on SIGTERM/SIGINT. A signal is then re-raised with the handler removed, so the process still dies of the
|
|
88
|
+
* signal exactly as it would have without a handler; stdin close just lets the process exit naturally.
|
|
89
|
+
*/
|
|
90
|
+
let flushOnlyRun;
|
|
91
|
+
/** One bounded flush shared by every trigger: a SIGTERM arriving after stdin closed waits for the SAME flush. */
|
|
92
|
+
function flushOnce() {
|
|
93
|
+
flushOnlyRun ??= settleWithin(flushAllBookkeeping(), PRE_WRITE_FLUSH_MS);
|
|
94
|
+
return flushOnlyRun;
|
|
95
|
+
}
|
|
96
|
+
function installFlushOnlyHandlers() {
|
|
97
|
+
process.stdin.on("end", () => { void flushOnce(); });
|
|
98
|
+
process.stdin.on("close", () => { void flushOnce(); });
|
|
99
|
+
for (const sig of ["SIGTERM", "SIGINT"]) {
|
|
100
|
+
const handler = () => {
|
|
101
|
+
process.removeListener(sig, handler);
|
|
102
|
+
// If the flush hangs, the bounded wait still ends and the signal is re-raised.
|
|
103
|
+
void flushOnce().finally(() => { process.kill(process.pid, sig); });
|
|
104
|
+
};
|
|
105
|
+
process.on(sig, handler);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
86
108
|
//# sourceMappingURL=lifecycle-exit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-exit.js","sourceRoot":"","sources":["../../src/lib/lifecycle-exit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"lifecycle-exit.js","sourceRoot":"","sources":["../../src/lib/lifecycle-exit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM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AC,CAAC;IAC/B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;GAMG;AACH,IAAI,YAAuC,CAAC;AAC5C,iHAAiH;AACjH,SAAS,SAAS;IAChB,YAAY,KAAK,YAAY,CAAC,mBAAmB,EAAE,EAAE,kBAAkB,CAAC,CAAC;IACzE,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,wBAAwB;IAC/B,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,KAAK,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,KAAK,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,KAAK,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAU,EAAE,CAAC;QACjD,MAAM,OAAO,GAAG,GAAS,EAAE;YACzB,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACrC,+EAA+E;YAC/E,KAAK,SAAS,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtE,CAAC,CAAC;QACF,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
import { type HostTier } from "agent-recall-core";
|
|
3
|
+
export declare function createMcpServer(tier: HostTier): McpServer;
|
|
4
|
+
export type ServerType = McpServer;
|
|
4
5
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAkC,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAMlF,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,CAKzD;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { VERSION,
|
|
2
|
+
import { VERSION, lifecycleInstructions } from "agent-recall-core";
|
|
3
3
|
// Lifecycle instructions are tier-specific (see agent-recall-core/host-profile.ts)
|
|
4
4
|
// but always derived from the single canonical source — never hardcoded here.
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// A factory, not a singleton: the hosted entry builds one server per request
|
|
6
|
+
// (an McpServer can only be connected to one transport at a time).
|
|
7
|
+
export function createMcpServer(tier) {
|
|
8
|
+
return new McpServer({ name: "agent-recall", version: VERSION, description: "AgentRecall — persistent memory for AI agents. Community & feedback: https://t.me/+ywZwoHrg3AM0NDVi" }, { instructions: lifecycleInstructions(tier) });
|
|
9
|
+
}
|
|
7
10
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAiB,MAAM,mBAAmB,CAAC;AAElF,mFAAmF;AACnF,8EAA8E;AAC9E,6EAA6E;AAC7E,mEAAmE;AACnE,MAAM,UAAU,eAAe,CAAC,IAAc;IAC5C,OAAO,IAAI,SAAS,CAClB,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,qGAAqG,EAAE,EAC9J,EAAE,YAAY,EAAE,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAC9C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool annotations: what each tool tells the client about its effects.
|
|
3
|
+
*
|
|
4
|
+
* A tool without annotations is treated by a client as the worst case
|
|
5
|
+
* (destructive, open-world write), and directories such as the Claude
|
|
6
|
+
* connectors directory reject it. Three classes cover the surface:
|
|
7
|
+
*
|
|
8
|
+
* READ the call itself writes nothing; its bookkeeping is deferred (see below).
|
|
9
|
+
* ADD writes, but nothing the user saved is replaced or dropped.
|
|
10
|
+
* OVERWRITE writes, and can replace or drop what an earlier call saved.
|
|
11
|
+
*
|
|
12
|
+
* READ:
|
|
13
|
+
* - session_start and recall. What they used to record while answering
|
|
14
|
+
* (correction "retrieved" outcomes, rule hit counts, room access counts and
|
|
15
|
+
* salience, recall `feedback`, lifecycle telemetry, crash-rescue sweeps,
|
|
16
|
+
* palace scaffolding, the cwd allowlist, the lexical index cache) is queued
|
|
17
|
+
* by core's bookkeep() and applied at exactly these flush points
|
|
18
|
+
* (lib/bookkeeping.ts, lib/lifecycle-exit.ts): before the next write tool
|
|
19
|
+
* call (which waits at most 1.5 s; a slower flush continues in the
|
|
20
|
+
* background), by the 30 s background flush, when the stdio server's stdin
|
|
21
|
+
* ends or closes or it gets SIGTERM/SIGINT (every stdio host, hook-owned
|
|
22
|
+
* included; bounded to 1.5 s), and while the HTTP server drains (within the 8 s drain window). The call
|
|
23
|
+
* itself leaves the store byte-identical, apart from the exceptions
|
|
24
|
+
* disclosed below (AR_AB_ENABLED, the hosted activity record).
|
|
25
|
+
* - Deferred, not dropped: usage counters (retrieved_count, last_retrieved,
|
|
26
|
+
* rule hits, room access_count and salience) and recall `feedback`
|
|
27
|
+
* ratings are applied after the call, so repeated reads can change what a
|
|
28
|
+
* LATER call ranks; nothing a call returns depends on its own bookkeeping.
|
|
29
|
+
* Deferred writes are best effort: a crash (kill -9, power loss) before the
|
|
30
|
+
* next flush loses the queued counters, telemetry and ratings. Counters are
|
|
31
|
+
* advisory: after a slow (over 1.5 s) flush a write tool runs alongside it,
|
|
32
|
+
* and a counter both touch may undercount.
|
|
33
|
+
* - Still written during the call, outside the read-only claim: on the
|
|
34
|
+
* hosted server the per-credential activity record (http/activity.ts:
|
|
35
|
+
* buffered in memory, flushed to the server's own _server/ directory; it
|
|
36
|
+
* describes the credential, not the memory, and feeds no ranking). The
|
|
37
|
+
* stdio ambient working-memory note is NOT written for READ tools.
|
|
38
|
+
* - Exception: with the operator's A/B experiment on (AR_AB_ENABLED=1)
|
|
39
|
+
* session_start writes an arm ledger row, so it is ADD for that process.
|
|
40
|
+
* - pipeline_list / pipeline_current / pipeline_show are not audited for this
|
|
41
|
+
* and stay ADD (extras only).
|
|
42
|
+
*
|
|
43
|
+
* OVERWRITE:
|
|
44
|
+
* - session_end rewrites the project state card.
|
|
45
|
+
* - remember can route an insight into the capped awareness set, where a
|
|
46
|
+
* new entry displaces the weakest one and the capped archive drops its
|
|
47
|
+
* oldest.
|
|
48
|
+
* - digest prunes old digests on `store` and marks them stale on
|
|
49
|
+
* `invalidate`.
|
|
50
|
+
* Size-capped telemetry logs (alignment, feedback) rotate under ADD tools;
|
|
51
|
+
* that is not counted, because no saved memory is lost.
|
|
52
|
+
*
|
|
53
|
+
* openWorldHint is false: every tool works on the caller's own memory store.
|
|
54
|
+
* The owner of a local install can opt in to Supabase sync or a remote
|
|
55
|
+
* embedding provider; both are off by default and disabled on the hosted
|
|
56
|
+
* server, and neither acts on anything outside that owner's own store.
|
|
57
|
+
*
|
|
58
|
+
* In stdio mode the ambient-capture wrapper notes each ADD/OVERWRITE call in
|
|
59
|
+
* working memory (crash survival); READ tools are skipped.
|
|
60
|
+
*/
|
|
61
|
+
import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
62
|
+
export declare const READ: ToolAnnotations;
|
|
63
|
+
export declare const ADD: ToolAnnotations;
|
|
64
|
+
export declare const OVERWRITE: ToolAnnotations;
|
|
65
|
+
//# sourceMappingURL=annotations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../src/tools/annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,eAAO,MAAM,IAAI,EAAE,eAA8D,CAAC;AAClF,eAAO,MAAM,GAAG,EAAE,eAAuF,CAAC;AAC1G,eAAO,MAAM,SAAS,EAAE,eAAsF,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const READ = { readOnlyHint: true, openWorldHint: false };
|
|
2
|
+
export const ADD = { readOnlyHint: false, destructiveHint: false, openWorldHint: false };
|
|
3
|
+
export const OVERWRITE = { readOnlyHint: false, destructiveHint: true, openWorldHint: false };
|
|
4
|
+
//# sourceMappingURL=annotations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.js","sourceRoot":"","sources":["../../src/tools/annotations.ts"],"names":[],"mappings":"AA8DA,MAAM,CAAC,MAAM,IAAI,GAAoB,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAClF,MAAM,CAAC,MAAM,GAAG,GAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAC1G,MAAM,CAAC,MAAM,SAAS,GAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-action.d.ts","sourceRoot":"","sources":["../../src/tools/check-action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"check-action.d.ts","sourceRoot":"","sources":["../../src/tools/check-action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAiEhD"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as z from "zod/v4";
|
|
2
2
|
import { checkAction, fenceMemory } from "agent-recall-core";
|
|
3
|
+
import { ADD } from "./annotations.js";
|
|
3
4
|
export function register(server) {
|
|
4
5
|
server.registerTool("check_action", {
|
|
5
6
|
title: "Pre-action Proactive Matcher",
|
|
7
|
+
annotations: ADD,
|
|
6
8
|
description: "Call BEFORE any non-trivial action (publish, push, deploy, schema change, file delete, " +
|
|
7
9
|
"send message, modify config). Pass a one-sentence description of what you're about to do. " +
|
|
8
10
|
"Returns matching behavior rules + active corrections + high-salience insights — a short " +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-action.js","sourceRoot":"","sources":["../../src/tools/check-action.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;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