@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,124 +0,0 @@
1
- import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
2
- import { IndexPersistence } from "../src/state/index-persistence.js";
3
- import { SearchIndex } from "../src/state/search-index.js";
4
- import { VectorIndex } from "../src/state/vector-index.js";
5
- import type { CompressedObservation } from "../src/types.js";
6
-
7
- function mockKV() {
8
- const store = new Map<string, Map<string, unknown>>();
9
- return {
10
- get: async <T>(scope: string, key: string): Promise<T | null> => {
11
- return (store.get(scope)?.get(key) as T) ?? null;
12
- },
13
- set: async <T>(scope: string, key: string, data: T): Promise<T> => {
14
- if (!store.has(scope)) store.set(scope, new Map());
15
- store.get(scope)!.set(key, data);
16
- return data;
17
- },
18
- delete: async (scope: string, key: string): Promise<void> => {
19
- store.get(scope)?.delete(key);
20
- },
21
- list: async <T>(scope: string): Promise<T[]> => {
22
- const entries = store.get(scope);
23
- return entries ? (Array.from(entries.values()) as T[]) : [];
24
- },
25
- };
26
- }
27
-
28
- function makeObs(
29
- overrides: Partial<CompressedObservation> = {},
30
- ): CompressedObservation {
31
- return {
32
- id: "obs_1",
33
- sessionId: "ses_1",
34
- timestamp: new Date().toISOString(),
35
- type: "file_edit",
36
- title: "Edit auth middleware",
37
- subtitle: "JWT validation",
38
- facts: ["Added token check"],
39
- narrative: "Modified the auth middleware to validate JWT tokens",
40
- concepts: ["authentication", "jwt"],
41
- files: ["src/middleware/auth.ts"],
42
- importance: 7,
43
- ...overrides,
44
- };
45
- }
46
-
47
- describe("IndexPersistence", () => {
48
- let kv: ReturnType<typeof mockKV>;
49
-
50
- beforeEach(() => {
51
- vi.useFakeTimers();
52
- kv = mockKV();
53
- });
54
-
55
- afterEach(() => {
56
- vi.useRealTimers();
57
- });
58
-
59
- it("saves and loads BM25 index round-trip", async () => {
60
- const bm25 = new SearchIndex();
61
- bm25.add(makeObs({ id: "obs_1", title: "auth handler" }));
62
-
63
- const persistence = new IndexPersistence(kv as never, bm25, null);
64
- await persistence.save();
65
-
66
- const loaded = await persistence.load();
67
- expect(loaded.bm25).not.toBeNull();
68
- expect(loaded.bm25!.size).toBe(1);
69
- const results = loaded.bm25!.search("auth");
70
- expect(results.length).toBe(1);
71
- });
72
-
73
- it("saves and loads vector index round-trip", async () => {
74
- const bm25 = new SearchIndex();
75
- const vector = new VectorIndex();
76
- vector.add("obs_1", "ses_1", new Float32Array([0.1, 0.2, 0.3]));
77
-
78
- const persistence = new IndexPersistence(kv as never, bm25, vector);
79
- await persistence.save();
80
-
81
- const loaded = await persistence.load();
82
- expect(loaded.vector).not.toBeNull();
83
- expect(loaded.vector!.size).toBe(1);
84
- });
85
-
86
- it("scheduleSave debounces multiple calls", async () => {
87
- const bm25 = new SearchIndex();
88
- const persistence = new IndexPersistence(kv as never, bm25, null);
89
-
90
- persistence.scheduleSave();
91
- persistence.scheduleSave();
92
- persistence.scheduleSave();
93
-
94
- await expect(kv.get("mem:index:bm25", "data")).resolves.toBeNull();
95
-
96
- vi.advanceTimersByTime(5000);
97
- await vi.runAllTimersAsync();
98
-
99
- const saved = await kv.get<string>("mem:index:bm25", "data");
100
- expect(saved).not.toBeNull();
101
- });
102
-
103
- it("stop clears the pending timer", async () => {
104
- const bm25 = new SearchIndex();
105
- bm25.add(makeObs({ id: "obs_1", title: "auth handler" }));
106
- const persistence = new IndexPersistence(kv as never, bm25, null);
107
-
108
- persistence.scheduleSave();
109
- persistence.stop();
110
-
111
- vi.advanceTimersByTime(10000);
112
- const saved = await kv.get<string>("mem:index:bm25", "data");
113
- expect(saved).toBeNull();
114
- });
115
-
116
- it("returns null indexes when nothing has been saved", async () => {
117
- const bm25 = new SearchIndex();
118
- const persistence = new IndexPersistence(kv as never, bm25, null);
119
-
120
- const loaded = await persistence.load();
121
- expect(loaded.bm25).toBeNull();
122
- expect(loaded.vector).toBeNull();
123
- });
124
- });
@@ -1,265 +0,0 @@
1
- import { describe, it, expect, beforeAll, afterAll } from "vitest";
2
-
3
- const BASE_URL = process.env["AGENTMEMORY_URL"] || "http://localhost:3111";
4
- const SECRET = process.env["AGENTMEMORY_SECRET"] || "";
5
-
6
- const SESSION_ID = `test_${Date.now()}`;
7
- const PROJECT = "/tmp/test-project";
8
-
9
- function url(path: string): string {
10
- return `${BASE_URL}${path}`;
11
- }
12
-
13
- function authHeaders(): Record<string, string> {
14
- const headers: Record<string, string> = {
15
- "Content-Type": "application/json",
16
- };
17
- if (SECRET) {
18
- headers["Authorization"] = `Bearer ${SECRET}`;
19
- }
20
- return headers;
21
- }
22
-
23
- async function json(res: Response): Promise<unknown> {
24
- const text = await res.text();
25
- try {
26
- return JSON.parse(text);
27
- } catch {
28
- return text;
29
- }
30
- }
31
-
32
- describe("agentmemory integration", () => {
33
- beforeAll(async () => {
34
- const res = await fetch(url("/agentmemory/health")).catch(() => null);
35
- if (!res || !res.ok) {
36
- throw new Error(
37
- `agentmemory is not running at ${BASE_URL}. Start it with: docker compose up -d && npm start`,
38
- );
39
- }
40
- });
41
-
42
- describe("health", () => {
43
- it("returns ok", async () => {
44
- const res = await fetch(url("/agentmemory/health"));
45
- expect(res.status).toBe(200);
46
- const body = (await json(res)) as { status: string; service: string };
47
- expect(["ok", "healthy"]).toContain(body.status);
48
- expect(body.service).toBe("agentmemory");
49
- });
50
- });
51
-
52
- describe("session lifecycle", () => {
53
- it("starts a session", async () => {
54
- const res = await fetch(url("/agentmemory/session/start"), {
55
- method: "POST",
56
- headers: authHeaders(),
57
- body: JSON.stringify({
58
- sessionId: SESSION_ID,
59
- project: PROJECT,
60
- cwd: PROJECT,
61
- }),
62
- });
63
- expect(res.status).toBe(200);
64
- const body = (await json(res)) as {
65
- session: { id: string; status: string };
66
- context: string;
67
- };
68
- expect(body.session.id).toBe(SESSION_ID);
69
- expect(body.session.status).toBe("active");
70
- expect(typeof body.context).toBe("string");
71
- });
72
-
73
- it("lists sessions including the new one", async () => {
74
- const res = await fetch(url("/agentmemory/sessions"));
75
- expect(res.status).toBe(200);
76
- const body = (await json(res)) as {
77
- sessions: Array<{ id: string }>;
78
- };
79
- expect(Array.isArray(body.sessions)).toBe(true);
80
- const found = body.sessions.find((s) => s.id === SESSION_ID);
81
- expect(found).toBeDefined();
82
- });
83
-
84
- it("ends the session", async () => {
85
- const res = await fetch(url("/agentmemory/session/end"), {
86
- method: "POST",
87
- headers: authHeaders(),
88
- body: JSON.stringify({ sessionId: SESSION_ID }),
89
- });
90
- expect(res.status).toBe(200);
91
- const body = (await json(res)) as { success: boolean };
92
- expect(body.success).toBe(true);
93
- });
94
-
95
- it("session is marked completed", async () => {
96
- const res = await fetch(url("/agentmemory/sessions"));
97
- const body = (await json(res)) as {
98
- sessions: Array<{ id: string; status: string; endedAt?: string }>;
99
- };
100
- const session = body.sessions.find((s) => s.id === SESSION_ID);
101
- expect(session).toBeDefined();
102
- expect(session!.status).toBe("completed");
103
- expect(session!.endedAt).toBeDefined();
104
- });
105
- });
106
-
107
- describe("observations", () => {
108
- const OBS_SESSION = `test_obs_${Date.now()}`;
109
-
110
- beforeAll(async () => {
111
- await fetch(url("/agentmemory/session/start"), {
112
- method: "POST",
113
- headers: authHeaders(),
114
- body: JSON.stringify({
115
- sessionId: OBS_SESSION,
116
- project: PROJECT,
117
- cwd: PROJECT,
118
- }),
119
- });
120
- });
121
-
122
- afterAll(async () => {
123
- await fetch(url("/agentmemory/session/end"), {
124
- method: "POST",
125
- headers: authHeaders(),
126
- body: JSON.stringify({ sessionId: OBS_SESSION }),
127
- });
128
- });
129
-
130
- it("captures an observation", async () => {
131
- const res = await fetch(url("/agentmemory/observe"), {
132
- method: "POST",
133
- headers: authHeaders(),
134
- body: JSON.stringify({
135
- hookType: "post_tool_use",
136
- sessionId: OBS_SESSION,
137
- project: PROJECT,
138
- cwd: PROJECT,
139
- timestamp: new Date().toISOString(),
140
- data: {
141
- tool: "Edit",
142
- file: "src/auth.ts",
143
- content: "Added JWT token validation middleware",
144
- },
145
- }),
146
- });
147
- expect(res.status).toBe(201);
148
- });
149
-
150
- it("captures a second observation", async () => {
151
- const res = await fetch(url("/agentmemory/observe"), {
152
- method: "POST",
153
- headers: authHeaders(),
154
- body: JSON.stringify({
155
- hookType: "post_tool_use",
156
- sessionId: OBS_SESSION,
157
- project: PROJECT,
158
- cwd: PROJECT,
159
- timestamp: new Date().toISOString(),
160
- data: {
161
- tool: "Bash",
162
- command: "npm test",
163
- output: "Tests: 12 passed, 0 failed",
164
- },
165
- }),
166
- });
167
- expect(res.status).toBe(201);
168
- });
169
-
170
- it("lists observations for the session", async () => {
171
- const res = await fetch(
172
- url(`/agentmemory/observations?sessionId=${OBS_SESSION}`),
173
- );
174
- expect(res.status).toBe(200);
175
- const body = (await json(res)) as {
176
- observations: Array<{ id: string; sessionId: string }>;
177
- };
178
- expect(Array.isArray(body.observations)).toBe(true);
179
- });
180
-
181
- it("returns 400 without sessionId", async () => {
182
- const res = await fetch(url("/agentmemory/observations"));
183
- expect(res.status).toBe(400);
184
- const body = (await json(res)) as { error: string };
185
- expect(body.error).toBe("sessionId required");
186
- });
187
- });
188
-
189
- describe("search", () => {
190
- it("searches observations", async () => {
191
- const res = await fetch(url("/agentmemory/search"), {
192
- method: "POST",
193
- headers: authHeaders(),
194
- body: JSON.stringify({ query: "auth", limit: 5 }),
195
- });
196
- expect(res.status).toBe(200);
197
- const body = await json(res);
198
- expect(body).toBeDefined();
199
- });
200
-
201
- it("returns results for empty limit", async () => {
202
- const res = await fetch(url("/agentmemory/search"), {
203
- method: "POST",
204
- headers: authHeaders(),
205
- body: JSON.stringify({ query: "test" }),
206
- });
207
- expect(res.status).toBe(200);
208
- });
209
- });
210
-
211
- describe("context", () => {
212
- it("generates context for a project", async () => {
213
- const res = await fetch(url("/agentmemory/context"), {
214
- method: "POST",
215
- headers: authHeaders(),
216
- body: JSON.stringify({
217
- sessionId: "ctx-test",
218
- project: PROJECT,
219
- }),
220
- });
221
- expect(res.status).toBe(200);
222
- const body = (await json(res)) as { context: string };
223
- expect(typeof body.context).toBe("string");
224
- });
225
- });
226
-
227
- describe("viewer", () => {
228
- it("serves the viewer HTML", async () => {
229
- const res = await fetch(url("/agentmemory/viewer"));
230
- expect(res.status).toBe(200);
231
- const body = await res.text();
232
- expect(body).toContain("html");
233
- });
234
- });
235
-
236
- describe("auth", () => {
237
- it("health endpoint is always public", async () => {
238
- const res = await fetch(url("/agentmemory/health"));
239
- expect(res.status).toBe(200);
240
- });
241
-
242
- if (SECRET) {
243
- it("rejects unauthenticated requests", async () => {
244
- const res = await fetch(url("/agentmemory/search"), {
245
- method: "POST",
246
- headers: { "Content-Type": "application/json" },
247
- body: JSON.stringify({ query: "test" }),
248
- });
249
- expect(res.status).toBe(401);
250
- });
251
-
252
- it("rejects wrong bearer token", async () => {
253
- const res = await fetch(url("/agentmemory/search"), {
254
- method: "POST",
255
- headers: {
256
- "Content-Type": "application/json",
257
- Authorization: "Bearer wrong-token",
258
- },
259
- body: JSON.stringify({ query: "test" }),
260
- });
261
- expect(res.status).toBe(401);
262
- });
263
- }
264
- });
265
- });