@agentmemory/agentmemory 0.7.0 → 0.7.3

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 (218) hide show
  1. package/AGENTS.md +2 -2
  2. package/README.md +76 -82
  3. package/dist/cli.mjs +99 -32
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/index.mjs +4 -2
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/{src-QxitMPfJ.mjs → src-sYZDDbiA.mjs} +5 -3
  8. package/dist/src-sYZDDbiA.mjs.map +1 -0
  9. package/dist/standalone.mjs +1 -1
  10. package/dist/standalone.mjs.map +1 -1
  11. package/package.json +11 -1
  12. package/plugin/.claude-plugin/plugin.json +1 -1
  13. package/plugin/scripts/notification.d.mts +1 -0
  14. package/plugin/scripts/notification.mjs.map +1 -0
  15. package/plugin/scripts/post-tool-failure.d.mts +1 -0
  16. package/plugin/scripts/post-tool-failure.mjs.map +1 -0
  17. package/plugin/scripts/post-tool-use.d.mts +1 -0
  18. package/plugin/scripts/post-tool-use.mjs.map +1 -0
  19. package/plugin/scripts/pre-compact.d.mts +1 -0
  20. package/plugin/scripts/pre-compact.mjs.map +1 -0
  21. package/plugin/scripts/pre-tool-use.d.mts +1 -0
  22. package/plugin/scripts/pre-tool-use.mjs.map +1 -0
  23. package/plugin/scripts/prompt-submit.d.mts +1 -0
  24. package/plugin/scripts/prompt-submit.mjs.map +1 -0
  25. package/plugin/scripts/session-end.d.mts +1 -0
  26. package/plugin/scripts/session-end.mjs.map +1 -0
  27. package/plugin/scripts/session-start.d.mts +1 -0
  28. package/plugin/scripts/session-start.mjs.map +1 -0
  29. package/plugin/scripts/stop.d.mts +1 -0
  30. package/plugin/scripts/stop.mjs.map +1 -0
  31. package/plugin/scripts/subagent-start.d.mts +1 -0
  32. package/plugin/scripts/subagent-start.mjs.map +1 -0
  33. package/plugin/scripts/subagent-stop.d.mts +1 -0
  34. package/plugin/scripts/subagent-stop.mjs.map +1 -0
  35. package/plugin/scripts/task-completed.d.mts +1 -0
  36. package/plugin/scripts/task-completed.mjs.map +1 -0
  37. package/.claude-plugin/marketplace.json +0 -14
  38. package/.github/workflows/ci.yml +0 -22
  39. package/.github/workflows/publish.yml +0 -28
  40. package/assets/banner.png +0 -0
  41. package/assets/demo.gif +0 -0
  42. package/assets/demo.mp4 +0 -0
  43. package/benchmark/QUALITY.md +0 -73
  44. package/benchmark/REAL-EMBEDDINGS.md +0 -67
  45. package/benchmark/SCALE.md +0 -110
  46. package/benchmark/dataset.ts +0 -293
  47. package/benchmark/quality-eval.ts +0 -643
  48. package/benchmark/real-embeddings-eval.ts +0 -405
  49. package/benchmark/scale-eval.ts +0 -398
  50. package/dist/src-QxitMPfJ.mjs.map +0 -1
  51. package/src/auth.ts +0 -12
  52. package/src/cli.ts +0 -159
  53. package/src/config.ts +0 -221
  54. package/src/eval/metrics-store.ts +0 -65
  55. package/src/eval/quality.ts +0 -51
  56. package/src/eval/schemas.ts +0 -124
  57. package/src/eval/self-correct.ts +0 -28
  58. package/src/eval/validator.ts +0 -31
  59. package/src/functions/actions.ts +0 -288
  60. package/src/functions/audit.ts +0 -61
  61. package/src/functions/auto-forget.ts +0 -169
  62. package/src/functions/branch-aware.ts +0 -169
  63. package/src/functions/cascade.ts +0 -80
  64. package/src/functions/checkpoints.ts +0 -209
  65. package/src/functions/claude-bridge.ts +0 -161
  66. package/src/functions/compress.ts +0 -194
  67. package/src/functions/consolidate.ts +0 -212
  68. package/src/functions/consolidation-pipeline.ts +0 -258
  69. package/src/functions/context.ts +0 -169
  70. package/src/functions/crystallize.ts +0 -293
  71. package/src/functions/dedup.ts +0 -57
  72. package/src/functions/diagnostics.ts +0 -785
  73. package/src/functions/enrich.ts +0 -132
  74. package/src/functions/evict.ts +0 -163
  75. package/src/functions/export-import.ts +0 -508
  76. package/src/functions/facets.ts +0 -248
  77. package/src/functions/file-index.ts +0 -106
  78. package/src/functions/flow-compress.ts +0 -214
  79. package/src/functions/frontier.ts +0 -196
  80. package/src/functions/governance.ts +0 -131
  81. package/src/functions/graph-retrieval.ts +0 -277
  82. package/src/functions/graph.ts +0 -275
  83. package/src/functions/leases.ts +0 -216
  84. package/src/functions/lessons.ts +0 -253
  85. package/src/functions/mesh.ts +0 -434
  86. package/src/functions/migrate.ts +0 -165
  87. package/src/functions/observe.ts +0 -144
  88. package/src/functions/obsidian-export.ts +0 -310
  89. package/src/functions/patterns.ts +0 -138
  90. package/src/functions/privacy.ts +0 -39
  91. package/src/functions/profile.ts +0 -155
  92. package/src/functions/query-expansion.ts +0 -186
  93. package/src/functions/relations.ts +0 -237
  94. package/src/functions/remember.ts +0 -162
  95. package/src/functions/retention.ts +0 -235
  96. package/src/functions/routines.ts +0 -289
  97. package/src/functions/search.ts +0 -80
  98. package/src/functions/sentinels.ts +0 -417
  99. package/src/functions/signals.ts +0 -186
  100. package/src/functions/sketches.ts +0 -274
  101. package/src/functions/sliding-window.ts +0 -257
  102. package/src/functions/smart-search.ts +0 -115
  103. package/src/functions/snapshot.ts +0 -219
  104. package/src/functions/summarize.ts +0 -155
  105. package/src/functions/team.ts +0 -147
  106. package/src/functions/temporal-graph.ts +0 -476
  107. package/src/functions/timeline.ts +0 -138
  108. package/src/functions/verify.ts +0 -117
  109. package/src/health/monitor.ts +0 -110
  110. package/src/health/thresholds.ts +0 -73
  111. package/src/hooks/notification.ts +0 -52
  112. package/src/hooks/post-tool-failure.ts +0 -58
  113. package/src/hooks/post-tool-use.ts +0 -62
  114. package/src/hooks/pre-compact.ts +0 -60
  115. package/src/hooks/pre-tool-use.ts +0 -72
  116. package/src/hooks/prompt-submit.ts +0 -46
  117. package/src/hooks/session-end.ts +0 -71
  118. package/src/hooks/session-start.ts +0 -48
  119. package/src/hooks/stop.ts +0 -39
  120. package/src/hooks/subagent-start.ts +0 -49
  121. package/src/hooks/subagent-stop.ts +0 -54
  122. package/src/hooks/task-completed.ts +0 -54
  123. package/src/index.ts +0 -342
  124. package/src/mcp/in-memory-kv.ts +0 -61
  125. package/src/mcp/server.ts +0 -1455
  126. package/src/mcp/standalone.ts +0 -177
  127. package/src/mcp/tools-registry.ts +0 -769
  128. package/src/mcp/transport.ts +0 -91
  129. package/src/prompts/compression.ts +0 -67
  130. package/src/prompts/consolidation.ts +0 -48
  131. package/src/prompts/graph-extraction.ts +0 -35
  132. package/src/prompts/summary.ts +0 -38
  133. package/src/prompts/xml.ts +0 -26
  134. package/src/providers/agent-sdk.ts +0 -34
  135. package/src/providers/anthropic.ts +0 -35
  136. package/src/providers/circuit-breaker.ts +0 -82
  137. package/src/providers/embedding/cohere.ts +0 -46
  138. package/src/providers/embedding/gemini.ts +0 -54
  139. package/src/providers/embedding/index.ts +0 -39
  140. package/src/providers/embedding/local.ts +0 -52
  141. package/src/providers/embedding/openai.ts +0 -45
  142. package/src/providers/embedding/openrouter.ts +0 -51
  143. package/src/providers/embedding/voyage.ts +0 -46
  144. package/src/providers/fallback-chain.ts +0 -31
  145. package/src/providers/index.ts +0 -84
  146. package/src/providers/openrouter.ts +0 -71
  147. package/src/providers/resilient.ts +0 -37
  148. package/src/state/hybrid-search.ts +0 -295
  149. package/src/state/index-persistence.ts +0 -63
  150. package/src/state/keyed-mutex.ts +0 -18
  151. package/src/state/kv.ts +0 -33
  152. package/src/state/schema.ts +0 -71
  153. package/src/state/search-index.ts +0 -245
  154. package/src/state/stemmer.ts +0 -104
  155. package/src/state/synonyms.ts +0 -63
  156. package/src/state/vector-index.ts +0 -130
  157. package/src/telemetry/setup.ts +0 -116
  158. package/src/triggers/api.ts +0 -1904
  159. package/src/triggers/events.ts +0 -71
  160. package/src/types.ts +0 -769
  161. package/src/version.ts +0 -1
  162. package/src/viewer/index.html +0 -2497
  163. package/src/viewer/server.ts +0 -207
  164. package/src/xenova.d.ts +0 -3
  165. package/test/actions.test.ts +0 -490
  166. package/test/audit.test.ts +0 -108
  167. package/test/auto-forget.test.ts +0 -188
  168. package/test/cascade.test.ts +0 -277
  169. package/test/checkpoints.test.ts +0 -493
  170. package/test/circuit-breaker.test.ts +0 -107
  171. package/test/claude-bridge.test.ts +0 -178
  172. package/test/confidence.test.ts +0 -247
  173. package/test/consistency.test.ts +0 -61
  174. package/test/consolidation-pipeline.test.ts +0 -251
  175. package/test/crystallize.test.ts +0 -521
  176. package/test/diagnostics.test.ts +0 -638
  177. package/test/embedding-provider.test.ts +0 -49
  178. package/test/enrich.test.ts +0 -209
  179. package/test/eval.test.ts +0 -300
  180. package/test/export-import.test.ts +0 -251
  181. package/test/facets.test.ts +0 -448
  182. package/test/fallback-chain.test.ts +0 -93
  183. package/test/frontier.test.ts +0 -485
  184. package/test/governance.test.ts +0 -147
  185. package/test/graph-retrieval.test.ts +0 -186
  186. package/test/graph.test.ts +0 -160
  187. package/test/helpers/mocks.ts +0 -40
  188. package/test/hybrid-search.test.ts +0 -145
  189. package/test/index-persistence.test.ts +0 -124
  190. package/test/integration.test.ts +0 -265
  191. package/test/leases.test.ts +0 -399
  192. package/test/mcp-prompts.test.ts +0 -218
  193. package/test/mcp-resources.test.ts +0 -286
  194. package/test/mcp-standalone.test.ts +0 -113
  195. package/test/mesh.test.ts +0 -700
  196. package/test/privacy.test.ts +0 -87
  197. package/test/profile.test.ts +0 -161
  198. package/test/query-expansion.test.ts +0 -154
  199. package/test/relations.test.ts +0 -198
  200. package/test/retention.test.ts +0 -245
  201. package/test/routines.test.ts +0 -497
  202. package/test/schema-fingerprint.test.ts +0 -81
  203. package/test/schema.test.ts +0 -42
  204. package/test/search-index.test.ts +0 -128
  205. package/test/sentinels.test.ts +0 -626
  206. package/test/signals.test.ts +0 -410
  207. package/test/sketches.test.ts +0 -549
  208. package/test/sliding-window.test.ts +0 -199
  209. package/test/smart-search.test.ts +0 -169
  210. package/test/snapshot.test.ts +0 -165
  211. package/test/team.test.ts +0 -156
  212. package/test/temporal-graph.test.ts +0 -378
  213. package/test/timeline.test.ts +0 -148
  214. package/test/vector-index.test.ts +0 -79
  215. package/test/verify.test.ts +0 -209
  216. package/test/xml.test.ts +0 -65
  217. package/tsconfig.json +0 -22
  218. package/tsdown.config.ts +0 -62
@@ -1,117 +0,0 @@
1
- import type { ISdk } from "iii-sdk";
2
- import type { StateKV } from "../state/kv.js";
3
- import { KV } from "../state/schema.js";
4
- import type {
5
- Memory,
6
- CompressedObservation,
7
- Session,
8
- } from "../types.js";
9
-
10
- export function registerVerifyFunction(sdk: ISdk, kv: StateKV): void {
11
- sdk.registerFunction(
12
- { id: "mem::verify" },
13
- async (data: { id: string }) => {
14
- if (!data.id || typeof data.id !== "string") {
15
- return { success: false, error: "id is required" };
16
- }
17
-
18
- const memory = await kv.get<Memory>(KV.memories, data.id);
19
- if (memory) {
20
- const observationIds = memory.sourceObservationIds || [];
21
- const observations: Array<{
22
- observation: CompressedObservation;
23
- session?: Session;
24
- }> = [];
25
-
26
- for (const obsId of observationIds) {
27
- const obs = await findObservation(kv, obsId, memory.sessionIds);
28
- if (obs) {
29
- const session = await kv.get<Session>(KV.sessions, obs.sessionId);
30
- observations.push({ observation: obs, session: session || undefined });
31
- }
32
- }
33
-
34
- return {
35
- success: true,
36
- type: "memory",
37
- memory: {
38
- id: memory.id,
39
- title: memory.title,
40
- type: memory.type,
41
- version: memory.version,
42
- strength: memory.strength,
43
- isLatest: memory.isLatest,
44
- createdAt: memory.createdAt,
45
- updatedAt: memory.updatedAt,
46
- supersedes: memory.supersedes,
47
- parentId: memory.parentId,
48
- },
49
- citations: observations.map((o) => ({
50
- observationId: o.observation.id,
51
- title: o.observation.title,
52
- type: o.observation.type,
53
- confidence: o.observation.confidence,
54
- timestamp: o.observation.timestamp,
55
- sessionId: o.observation.sessionId,
56
- sessionProject: o.session?.project,
57
- sessionStatus: o.session?.status,
58
- })),
59
- citationCount: observations.length,
60
- };
61
- }
62
-
63
- const obs = await findObservation(kv, data.id);
64
- if (obs) {
65
- const session = await kv.get<Session>(KV.sessions, obs.sessionId);
66
- return {
67
- success: true,
68
- type: "observation",
69
- observation: {
70
- id: obs.id,
71
- title: obs.title,
72
- type: obs.type,
73
- confidence: obs.confidence,
74
- importance: obs.importance,
75
- timestamp: obs.timestamp,
76
- sessionId: obs.sessionId,
77
- },
78
- session: session
79
- ? {
80
- id: session.id,
81
- project: session.project,
82
- status: session.status,
83
- startedAt: session.startedAt,
84
- }
85
- : null,
86
- citationCount: 0,
87
- citations: [],
88
- };
89
- }
90
-
91
- return { success: false, error: "not found" };
92
- },
93
- );
94
- }
95
-
96
- async function findObservation(
97
- kv: StateKV,
98
- obsId: string,
99
- hintSessionIds?: string[],
100
- ): Promise<CompressedObservation | null> {
101
- if (hintSessionIds) {
102
- for (const sid of hintSessionIds) {
103
- const obs = await kv.get<CompressedObservation>(KV.observations(sid), obsId);
104
- if (obs) return obs;
105
- }
106
- }
107
- const sessions = await kv.list<Session>(KV.sessions);
108
- for (const session of sessions) {
109
- if (hintSessionIds?.includes(session.id)) continue;
110
- const obs = await kv.get<CompressedObservation>(
111
- KV.observations(session.id),
112
- obsId,
113
- );
114
- if (obs) return obs;
115
- }
116
- return null;
117
- }
@@ -1,110 +0,0 @@
1
- import type { ISdk } from "iii-sdk";
2
- import type { HealthSnapshot } from "../types.js";
3
- import type { StateKV } from "../state/kv.js";
4
- import { KV } from "../state/schema.js";
5
- import { evaluateHealth } from "./thresholds.js";
6
-
7
- export function registerHealthMonitor(
8
- sdk: ISdk,
9
- kv: StateKV,
10
- ): { stop: () => void } {
11
- let connectionState = "connected";
12
- let prevCpuUsage = process.cpuUsage();
13
- let prevCpuTime = Date.now();
14
-
15
- if (typeof sdk.on === "function") {
16
- sdk.on("connection_state", (state?: unknown) => {
17
- connectionState = state as string;
18
- });
19
- }
20
-
21
- async function collectHealth(): Promise<HealthSnapshot> {
22
- const mem = process.memoryUsage();
23
- const currentCpu = process.cpuUsage();
24
- const now = Date.now();
25
- const uptime = process.uptime();
26
-
27
- const elapsedMs = now - prevCpuTime;
28
- const userDelta = currentCpu.user - prevCpuUsage.user;
29
- const systemDelta = currentCpu.system - prevCpuUsage.system;
30
- const cpuPercent =
31
- elapsedMs > 0 ? ((userDelta + systemDelta) / 1000 / elapsedMs) * 100 : 0;
32
- prevCpuUsage = currentCpu;
33
- prevCpuTime = now;
34
-
35
- const startMark = performance.now();
36
- await new Promise((resolve) => setImmediate(resolve));
37
- const eventLoopLagMs = performance.now() - startMark;
38
-
39
- let workers: HealthSnapshot["workers"] = [];
40
- try {
41
- const result = await sdk.trigger<
42
- unknown,
43
- { workers?: HealthSnapshot["workers"] }
44
- >("engine::workers::list", {});
45
- if (result?.workers) workers = result.workers;
46
- } catch {}
47
-
48
- const KV_PROBE_TIMEOUT = 5000;
49
- let kvConnectivity: { status: string; latencyMs?: number; error?: string };
50
- const kvStart = performance.now();
51
- try {
52
- await Promise.race([
53
- (async () => {
54
- await kv.set(KV.health, "_probe", { ts: Date.now() });
55
- await kv.get(KV.health, "_probe");
56
- })(),
57
- new Promise<never>((_, reject) =>
58
- setTimeout(() => reject(new Error("timeout")), KV_PROBE_TIMEOUT),
59
- ),
60
- ]);
61
- kvConnectivity = { status: "ok", latencyMs: Math.round((performance.now() - kvStart) * 100) / 100 };
62
- } catch {
63
- kvConnectivity = { status: "error", error: "kv_probe_failed", latencyMs: Math.round((performance.now() - kvStart) * 100) / 100 };
64
- }
65
-
66
- const snapshot: HealthSnapshot = {
67
- connectionState,
68
- workers,
69
- memory: {
70
- heapUsed: mem.heapUsed,
71
- heapTotal: mem.heapTotal,
72
- rss: mem.rss,
73
- external: mem.external,
74
- },
75
- cpu: {
76
- userMicros: currentCpu.user,
77
- systemMicros: currentCpu.system,
78
- percent: Math.round(cpuPercent * 100) / 100,
79
- },
80
- eventLoopLagMs,
81
- uptimeSeconds: uptime,
82
- kvConnectivity,
83
- status: "healthy",
84
- alerts: [],
85
- };
86
-
87
- const evaluated = evaluateHealth(snapshot);
88
- snapshot.status = evaluated.status;
89
- snapshot.alerts = evaluated.alerts;
90
-
91
- await kv.set(KV.health, "latest", snapshot).catch(() => {});
92
- return snapshot;
93
- }
94
-
95
- collectHealth().catch(() => {});
96
- const interval = setInterval(() => {
97
- collectHealth().catch(() => {});
98
- }, 30_000);
99
- interval.unref();
100
-
101
- return {
102
- stop: () => clearInterval(interval),
103
- };
104
- }
105
-
106
- export async function getLatestHealth(
107
- kv: StateKV,
108
- ): Promise<HealthSnapshot | null> {
109
- return kv.get<HealthSnapshot>(KV.health, "latest");
110
- }
@@ -1,73 +0,0 @@
1
- import type { HealthSnapshot } from "../types.js";
2
-
3
- interface ThresholdConfig {
4
- eventLoopLagWarnMs: number;
5
- eventLoopLagCriticalMs: number;
6
- cpuWarnPercent: number;
7
- cpuCriticalPercent: number;
8
- memoryWarnPercent: number;
9
- memoryCriticalPercent: number;
10
- }
11
-
12
- const DEFAULTS: ThresholdConfig = {
13
- eventLoopLagWarnMs: 100,
14
- eventLoopLagCriticalMs: 500,
15
- cpuWarnPercent: 80,
16
- cpuCriticalPercent: 90,
17
- memoryWarnPercent: 80,
18
- memoryCriticalPercent: 95,
19
- };
20
-
21
- export function evaluateHealth(
22
- snapshot: HealthSnapshot,
23
- config: Partial<ThresholdConfig> = {},
24
- ): { status: "healthy" | "degraded" | "critical"; alerts: string[] } {
25
- const cfg = { ...DEFAULTS, ...config };
26
- const alerts: string[] = [];
27
- let critical = false;
28
- let degraded = false;
29
-
30
- if (
31
- snapshot.connectionState === "disconnected" ||
32
- snapshot.connectionState === "failed"
33
- ) {
34
- alerts.push(`connection_${snapshot.connectionState}`);
35
- critical = true;
36
- } else if (snapshot.connectionState === "reconnecting") {
37
- alerts.push("connection_reconnecting");
38
- degraded = true;
39
- }
40
-
41
- if (snapshot.eventLoopLagMs > cfg.eventLoopLagCriticalMs) {
42
- alerts.push(
43
- `event_loop_lag_critical_${Math.round(snapshot.eventLoopLagMs)}ms`,
44
- );
45
- critical = true;
46
- } else if (snapshot.eventLoopLagMs > cfg.eventLoopLagWarnMs) {
47
- alerts.push(`event_loop_lag_warn_${Math.round(snapshot.eventLoopLagMs)}ms`);
48
- degraded = true;
49
- }
50
-
51
- if (snapshot.cpu.percent > cfg.cpuCriticalPercent) {
52
- alerts.push(`cpu_critical_${Math.round(snapshot.cpu.percent)}%`);
53
- critical = true;
54
- } else if (snapshot.cpu.percent > cfg.cpuWarnPercent) {
55
- alerts.push(`cpu_warn_${Math.round(snapshot.cpu.percent)}%`);
56
- degraded = true;
57
- }
58
-
59
- const memPercent =
60
- snapshot.memory.heapTotal > 0
61
- ? (snapshot.memory.heapUsed / snapshot.memory.heapTotal) * 100
62
- : 0;
63
- if (memPercent > cfg.memoryCriticalPercent) {
64
- alerts.push(`memory_critical_${Math.round(memPercent)}%`);
65
- critical = true;
66
- } else if (memPercent > cfg.memoryWarnPercent) {
67
- alerts.push(`memory_warn_${Math.round(memPercent)}%`);
68
- degraded = true;
69
- }
70
-
71
- const status = critical ? "critical" : degraded ? "degraded" : "healthy";
72
- return { status, alerts };
73
- }
@@ -1,52 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const REST_URL = process.env["AGENTMEMORY_URL"] || "http://localhost:3111";
4
- const SECRET = process.env["AGENTMEMORY_SECRET"] || "";
5
-
6
- function authHeaders(): Record<string, string> {
7
- const h: Record<string, string> = { "Content-Type": "application/json" };
8
- if (SECRET) h["Authorization"] = `Bearer ${SECRET}`;
9
- return h;
10
- }
11
-
12
- async function main() {
13
- let input = "";
14
- for await (const chunk of process.stdin) {
15
- input += chunk;
16
- }
17
-
18
- let data: Record<string, unknown>;
19
- try {
20
- data = JSON.parse(input);
21
- } catch {
22
- return;
23
- }
24
-
25
- if (data.notification_type !== "permission_prompt") return;
26
-
27
- const sessionId = (data.session_id as string) || "unknown";
28
-
29
- try {
30
- await fetch(`${REST_URL}/agentmemory/observe`, {
31
- method: "POST",
32
- headers: authHeaders(),
33
- body: JSON.stringify({
34
- hookType: "notification",
35
- sessionId,
36
- project: data.cwd || process.cwd(),
37
- cwd: data.cwd || process.cwd(),
38
- timestamp: new Date().toISOString(),
39
- data: {
40
- notification_type: data.notification_type,
41
- title: data.title,
42
- message: data.message,
43
- },
44
- }),
45
- signal: AbortSignal.timeout(2000),
46
- });
47
- } catch {
48
- // fire and forget
49
- }
50
- }
51
-
52
- main();
@@ -1,58 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const REST_URL = process.env["AGENTMEMORY_URL"] || "http://localhost:3111";
4
- const SECRET = process.env["AGENTMEMORY_SECRET"] || "";
5
-
6
- function authHeaders(): Record<string, string> {
7
- const h: Record<string, string> = { "Content-Type": "application/json" };
8
- if (SECRET) h["Authorization"] = `Bearer ${SECRET}`;
9
- return h;
10
- }
11
-
12
- async function main() {
13
- let input = "";
14
- for await (const chunk of process.stdin) {
15
- input += chunk;
16
- }
17
-
18
- let data: Record<string, unknown>;
19
- try {
20
- data = JSON.parse(input);
21
- } catch {
22
- return;
23
- }
24
-
25
- if (data.is_interrupt) return;
26
-
27
- const sessionId = (data.session_id as string) || "unknown";
28
-
29
- try {
30
- await fetch(`${REST_URL}/agentmemory/observe`, {
31
- method: "POST",
32
- headers: authHeaders(),
33
- body: JSON.stringify({
34
- hookType: "post_tool_failure",
35
- sessionId,
36
- project: data.cwd || process.cwd(),
37
- cwd: data.cwd || process.cwd(),
38
- timestamp: new Date().toISOString(),
39
- data: {
40
- tool_name: data.tool_name,
41
- tool_input:
42
- typeof data.tool_input === "string"
43
- ? data.tool_input.slice(0, 4000)
44
- : JSON.stringify(data.tool_input ?? "").slice(0, 4000),
45
- error:
46
- typeof data.error === "string"
47
- ? data.error.slice(0, 4000)
48
- : JSON.stringify(data.error ?? "").slice(0, 4000),
49
- },
50
- }),
51
- signal: AbortSignal.timeout(3000),
52
- });
53
- } catch {
54
- // fire and forget
55
- }
56
- }
57
-
58
- main();
@@ -1,62 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const REST_URL = process.env["AGENTMEMORY_URL"] || "http://localhost:3111";
4
- const SECRET = process.env["AGENTMEMORY_SECRET"] || "";
5
-
6
- function authHeaders(): Record<string, string> {
7
- const h: Record<string, string> = { "Content-Type": "application/json" };
8
- if (SECRET) h["Authorization"] = `Bearer ${SECRET}`;
9
- return h;
10
- }
11
-
12
- async function main() {
13
- let input = "";
14
- for await (const chunk of process.stdin) {
15
- input += chunk;
16
- }
17
-
18
- let data: Record<string, unknown>;
19
- try {
20
- data = JSON.parse(input);
21
- } catch {
22
- return;
23
- }
24
-
25
- const sessionId = (data.session_id as string) || "unknown";
26
-
27
- try {
28
- await fetch(`${REST_URL}/agentmemory/observe`, {
29
- method: "POST",
30
- headers: authHeaders(),
31
- body: JSON.stringify({
32
- hookType: "post_tool_use",
33
- sessionId,
34
- project: data.cwd || process.cwd(),
35
- cwd: data.cwd || process.cwd(),
36
- timestamp: new Date().toISOString(),
37
- data: {
38
- tool_name: data.tool_name,
39
- tool_input: data.tool_input,
40
- tool_output: truncate(data.tool_output, 8000),
41
- },
42
- }),
43
- signal: AbortSignal.timeout(3000),
44
- });
45
- } catch {
46
- // fire and forget
47
- }
48
- }
49
-
50
- function truncate(value: unknown, max: number): unknown {
51
- if (typeof value === "string" && value.length > max) {
52
- return value.slice(0, max) + "\n[...truncated]";
53
- }
54
- if (typeof value === "object" && value !== null) {
55
- const str = JSON.stringify(value);
56
- if (str.length > max) return str.slice(0, max) + "...[truncated]";
57
- return value;
58
- }
59
- return value;
60
- }
61
-
62
- main();
@@ -1,60 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const REST_URL = process.env["AGENTMEMORY_URL"] || "http://localhost:3111";
4
- const SECRET = process.env["AGENTMEMORY_SECRET"] || "";
5
-
6
- function authHeaders(): Record<string, string> {
7
- const h: Record<string, string> = { "Content-Type": "application/json" };
8
- if (SECRET) h["Authorization"] = `Bearer ${SECRET}`;
9
- return h;
10
- }
11
-
12
- async function main() {
13
- let input = "";
14
- for await (const chunk of process.stdin) {
15
- input += chunk;
16
- }
17
-
18
- let data: Record<string, unknown>;
19
- try {
20
- data = JSON.parse(input);
21
- } catch {
22
- return;
23
- }
24
-
25
- const sessionId = (data.session_id as string) || "unknown";
26
- const project = (data.cwd as string) || process.cwd();
27
-
28
- if (process.env["CLAUDE_MEMORY_BRIDGE"] === "true") {
29
- try {
30
- await fetch(`${REST_URL}/agentmemory/claude-bridge/sync`, {
31
- method: "POST",
32
- headers: authHeaders(),
33
- body: JSON.stringify({}),
34
- signal: AbortSignal.timeout(5000),
35
- });
36
- } catch {
37
- // best-effort
38
- }
39
- }
40
-
41
- try {
42
- const res = await fetch(`${REST_URL}/agentmemory/context`, {
43
- method: "POST",
44
- headers: authHeaders(),
45
- body: JSON.stringify({ sessionId, project, budget: 1500 }),
46
- signal: AbortSignal.timeout(5000),
47
- });
48
-
49
- if (res.ok) {
50
- const result = (await res.json()) as { context?: string };
51
- if (result.context) {
52
- process.stdout.write(result.context);
53
- }
54
- }
55
- } catch {
56
- // best effort -- don't block compaction
57
- }
58
- }
59
-
60
- main();
@@ -1,72 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const REST_URL = process.env["AGENTMEMORY_URL"] || "http://localhost:3111";
4
- const SECRET = process.env["AGENTMEMORY_SECRET"] || "";
5
-
6
- function authHeaders(): Record<string, string> {
7
- const h: Record<string, string> = { "Content-Type": "application/json" };
8
- if (SECRET) h["Authorization"] = `Bearer ${SECRET}`;
9
- return h;
10
- }
11
-
12
- async function main() {
13
- let input = "";
14
- for await (const chunk of process.stdin) {
15
- input += chunk;
16
- }
17
-
18
- let data: Record<string, unknown>;
19
- try {
20
- data = JSON.parse(input);
21
- } catch {
22
- return;
23
- }
24
-
25
- const toolName = data.tool_name as string;
26
- if (!toolName) return;
27
-
28
- const fileTools = ["Edit", "Write", "Read", "Glob", "Grep"];
29
- if (!fileTools.includes(toolName)) return;
30
-
31
- const toolInput = (data.tool_input || {}) as Record<string, unknown>;
32
- const files: string[] = [];
33
- const fileKeys =
34
- toolName === "Grep"
35
- ? ["path", "file"]
36
- : ["file_path", "path", "file", "pattern"];
37
- for (const key of fileKeys) {
38
- const val = toolInput[key];
39
- if (typeof val === "string" && val.length > 0) files.push(val);
40
- }
41
- if (files.length === 0) return;
42
-
43
- const terms: string[] = [];
44
- if (toolName === "Grep" || toolName === "Glob") {
45
- const pattern = toolInput["pattern"];
46
- if (typeof pattern === "string" && pattern.length > 0) {
47
- terms.push(pattern);
48
- }
49
- }
50
-
51
- const sessionId = (data.session_id as string) || "unknown";
52
-
53
- try {
54
- const res = await fetch(`${REST_URL}/agentmemory/enrich`, {
55
- method: "POST",
56
- headers: authHeaders(),
57
- body: JSON.stringify({ sessionId, files, terms, toolName }),
58
- signal: AbortSignal.timeout(2000),
59
- });
60
-
61
- if (res.ok) {
62
- const result = (await res.json()) as { context?: string };
63
- if (result.context) {
64
- process.stdout.write(result.context);
65
- }
66
- }
67
- } catch {
68
- // don't block tool execution
69
- }
70
- }
71
-
72
- main();
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const REST_URL = process.env["AGENTMEMORY_URL"] || "http://localhost:3111";
4
- const SECRET = process.env["AGENTMEMORY_SECRET"] || "";
5
-
6
- function authHeaders(): Record<string, string> {
7
- const h: Record<string, string> = { "Content-Type": "application/json" };
8
- if (SECRET) h["Authorization"] = `Bearer ${SECRET}`;
9
- return h;
10
- }
11
-
12
- async function main() {
13
- let input = "";
14
- for await (const chunk of process.stdin) {
15
- input += chunk;
16
- }
17
-
18
- let data: Record<string, unknown>;
19
- try {
20
- data = JSON.parse(input);
21
- } catch {
22
- return;
23
- }
24
-
25
- const sessionId = (data.session_id as string) || "unknown";
26
-
27
- try {
28
- await fetch(`${REST_URL}/agentmemory/observe`, {
29
- method: "POST",
30
- headers: authHeaders(),
31
- body: JSON.stringify({
32
- hookType: "prompt_submit",
33
- sessionId,
34
- project: data.cwd || process.cwd(),
35
- cwd: data.cwd || process.cwd(),
36
- timestamp: new Date().toISOString(),
37
- data: { prompt: data.prompt },
38
- }),
39
- signal: AbortSignal.timeout(3000),
40
- });
41
- } catch {
42
- // fire and forget
43
- }
44
- }
45
-
46
- main();