nodebench-mcp 2.48.0 → 2.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,272 @@
1
+ /**
2
+ * testProviderBus.ts — Integration test for ProviderBus WebSocket event bus.
3
+ *
4
+ * Tests: auth, registration, event routing, disconnect cleanup.
5
+ * Run: npx tsx src/benchmarks/testProviderBus.ts
6
+ */
7
+ import { createServer } from "node:http";
8
+ import { WebSocket } from "ws";
9
+ import { ProviderBus, } from "../../../../server/providerBus.js";
10
+ import { generateApiKey, getMemoryStore, } from "../../../../server/mcpAuth.js";
11
+ // ═══════════════════════════════════════════════════════════════════════════
12
+ // Test helpers
13
+ // ═══════════════════════════════════════════════════════════════════════════
14
+ const results = [];
15
+ function record(name, pass, detail) {
16
+ results.push({ name, pass, detail });
17
+ const icon = pass ? "PASS" : "FAIL";
18
+ console.log(` [${icon}] ${name}${detail ? ` — ${detail}` : ""}`);
19
+ }
20
+ /** Wait for a WS message matching a predicate, with timeout. */
21
+ function waitForMessage(ws, predicate, timeoutMs = 5000) {
22
+ return new Promise((resolve, reject) => {
23
+ const timer = setTimeout(() => {
24
+ ws.removeListener("message", handler);
25
+ reject(new Error(`Timed out waiting for message (${timeoutMs}ms)`));
26
+ }, timeoutMs);
27
+ function handler(data) {
28
+ try {
29
+ const parsed = JSON.parse(typeof data === "string" ? data : data.toString("utf-8"));
30
+ if (predicate(parsed)) {
31
+ clearTimeout(timer);
32
+ ws.removeListener("message", handler);
33
+ resolve(parsed);
34
+ }
35
+ }
36
+ catch {
37
+ // ignore parse errors, keep waiting
38
+ }
39
+ }
40
+ ws.on("message", handler);
41
+ });
42
+ }
43
+ /** Connect a WS client to the bus with Bearer auth. Returns the ws + first message. */
44
+ function connectClient(port, apiKey) {
45
+ return new Promise((resolve, reject) => {
46
+ const ws = new WebSocket(`ws://127.0.0.1:${port}/bus`, {
47
+ headers: { Authorization: `Bearer ${apiKey}` },
48
+ });
49
+ let firstMessage = null;
50
+ let resolved = false;
51
+ ws.on("message", (data) => {
52
+ if (!firstMessage) {
53
+ try {
54
+ firstMessage = JSON.parse(typeof data === "string" ? data : data.toString("utf-8"));
55
+ }
56
+ catch { /* ignore */ }
57
+ if (!resolved) {
58
+ resolved = true;
59
+ resolve({ ws, firstMessage });
60
+ }
61
+ }
62
+ });
63
+ ws.on("open", () => {
64
+ // Give a brief window for the welcome message to arrive
65
+ setTimeout(() => {
66
+ if (!resolved) {
67
+ resolved = true;
68
+ resolve({ ws, firstMessage });
69
+ }
70
+ }, 500);
71
+ });
72
+ ws.on("error", (err) => {
73
+ if (!resolved) {
74
+ resolved = true;
75
+ reject(err);
76
+ }
77
+ });
78
+ });
79
+ }
80
+ // ═══════════════════════════════════════════════════════════════════════════
81
+ // Setup: HTTP server + ProviderBus + seed an API key
82
+ // ═══════════════════════════════════════════════════════════════════════════
83
+ async function run() {
84
+ console.log("\n=== ProviderBus Integration Tests ===\n");
85
+ // 1. Generate a valid API key and seed it into the in-memory store
86
+ const generated = generateApiKey();
87
+ const rawKey = generated.rawKey;
88
+ const store = getMemoryStore();
89
+ const keyRecord = {
90
+ keyHash: generated.keyHash,
91
+ keyHashPrefix: generated.keyHashPrefix,
92
+ userId: "test-user-1",
93
+ permissions: ["tools:read", "tools:execute"],
94
+ rateLimits: { perMinute: 100, perDay: 10_000 },
95
+ createdAt: Date.now(),
96
+ lastUsedAt: Date.now(),
97
+ revokedAt: null,
98
+ };
99
+ store.set(generated.keyHashPrefix, keyRecord);
100
+ // 2. Create HTTP server
101
+ const httpServer = createServer((_req, res) => {
102
+ res.writeHead(404);
103
+ res.end();
104
+ });
105
+ // 3. Create ProviderBus with short timeouts for testing
106
+ const busConfig = {
107
+ maxConnections: 10,
108
+ heartbeatIntervalMs: 60_000, // long — we don't need heartbeats during test
109
+ idleTimeoutMs: 60_000,
110
+ rateLimitPerMinute: 100,
111
+ };
112
+ const bus = new ProviderBus(busConfig);
113
+ bus.attachToServer(httpServer, "/bus");
114
+ // Wire upgrade handling
115
+ httpServer.on("upgrade", (req, socket, head) => {
116
+ const url = new URL(req.url ?? "/", `http://127.0.0.1`);
117
+ if (url.pathname === "/bus") {
118
+ bus.handleUpgrade(req, socket, head).catch((err) => {
119
+ console.error(` [ERROR] handleUpgrade error:`, err);
120
+ });
121
+ }
122
+ else {
123
+ socket.destroy();
124
+ }
125
+ });
126
+ // 4. Start listening
127
+ const port = await new Promise((resolve) => {
128
+ httpServer.listen(0, "127.0.0.1", () => {
129
+ const addr = httpServer.address();
130
+ if (typeof addr === "object" && addr !== null) {
131
+ resolve(addr.port);
132
+ }
133
+ });
134
+ });
135
+ console.log(` Server listening on 127.0.0.1:${port}`);
136
+ console.log("");
137
+ try {
138
+ // ── Test 1: Connect with valid API key ──────────────────────────────
139
+ let ws;
140
+ try {
141
+ const conn = await connectClient(port, rawKey);
142
+ ws = conn.ws;
143
+ const welcome = conn.firstMessage;
144
+ record("Connect with valid API key", welcome !== null && welcome.type === "heartbeat" && typeof welcome.providerId === "string", welcome ? `providerId=${welcome.providerId}` : "no welcome message received");
145
+ }
146
+ catch (err) {
147
+ record("Connect with valid API key", false, String(err));
148
+ // Can't continue without a connection
149
+ return;
150
+ }
151
+ // ── Test 2: Connect with invalid API key ─────────────────────────────
152
+ try {
153
+ const badConn = await connectClient(port, "nb_key_00000000000000000000000000000000");
154
+ // If we get here the connection opened — wait briefly for a close
155
+ await new Promise((resolve, reject) => {
156
+ badConn.ws.on("close", () => resolve());
157
+ badConn.ws.on("error", () => resolve());
158
+ setTimeout(() => {
159
+ badConn.ws.close();
160
+ reject(new Error("Bad key connection was not rejected"));
161
+ }, 2000);
162
+ });
163
+ record("Reject invalid API key", true);
164
+ }
165
+ catch (err) {
166
+ // Connection refused or error is also acceptable (socket destroyed before upgrade completes)
167
+ const msg = String(err);
168
+ if (msg.includes("not rejected")) {
169
+ record("Reject invalid API key", false, msg);
170
+ }
171
+ else {
172
+ record("Reject invalid API key", true, "Connection rejected/errored as expected");
173
+ }
174
+ }
175
+ // ── Test 3: Register as a provider ───────────────────────────────────
176
+ try {
177
+ ws.send(JSON.stringify({
178
+ type: "register",
179
+ registration: {
180
+ providerName: "test-agent",
181
+ providerType: "custom",
182
+ capabilities: ["chat", "tool_execution"],
183
+ version: "1.0.0",
184
+ },
185
+ }));
186
+ const registered = await waitForMessage(ws, (m) => m.type === "registered", 3000);
187
+ record("Register as provider", registered.type === "registered" && typeof registered.providerId === "string", `providerId=${registered.providerId}`);
188
+ }
189
+ catch (err) {
190
+ record("Register as provider", false, String(err));
191
+ }
192
+ // ── Test 4: Send an event ────────────────────────────────────────────
193
+ try {
194
+ const eventPromise = new Promise((resolve) => {
195
+ bus.once("event", (evt) => {
196
+ resolve(evt.type === "chat.message" && evt.payload?.text === "hello");
197
+ });
198
+ setTimeout(() => resolve(false), 3000);
199
+ });
200
+ ws.send(JSON.stringify({
201
+ type: "event",
202
+ event: {
203
+ type: "chat.message",
204
+ payload: { text: "hello" },
205
+ },
206
+ }));
207
+ const eventReceived = await eventPromise;
208
+ record("Send event and bus emits it", eventReceived);
209
+ // Verify event log
210
+ const log = bus.getEventLog(10);
211
+ const found = log.some((e) => e.type === "chat.message");
212
+ record("Event logged in event log", found, `log size=${log.length}`);
213
+ }
214
+ catch (err) {
215
+ record("Send event and bus emits it", false, String(err));
216
+ }
217
+ // ── Test 5: Health snapshot ──────────────────────────────────────────
218
+ try {
219
+ const health = bus.getHealthSnapshot();
220
+ record("Health snapshot returns data", health.status === "healthy" && health.providers.connected >= 1, `connected=${health.providers.connected}, registered=${health.providers.registered}`);
221
+ }
222
+ catch (err) {
223
+ record("Health snapshot returns data", false, String(err));
224
+ }
225
+ // ── Test 6: Connected providers list ─────────────────────────────────
226
+ try {
227
+ const providers = bus.getConnectedProviders();
228
+ const testProvider = providers.find((p) => p.providerName === "test-agent");
229
+ record("Connected providers list includes test-agent", !!testProvider && testProvider.providerType === "custom", testProvider
230
+ ? `capabilities=${testProvider.capabilities.join(",")}`
231
+ : "not found");
232
+ }
233
+ catch (err) {
234
+ record("Connected providers list includes test-agent", false, String(err));
235
+ }
236
+ // ── Test 7: Disconnect and cleanup ──────────────────────────────────
237
+ try {
238
+ const disconnectPromise = new Promise((resolve) => {
239
+ bus.once("provider:disconnected", () => resolve(true));
240
+ setTimeout(() => resolve(false), 3000);
241
+ });
242
+ ws.close();
243
+ const disconnected = await disconnectPromise;
244
+ record("Disconnect fires provider:disconnected", disconnected);
245
+ // Verify cleanup
246
+ const afterProviders = bus.getConnectedProviders();
247
+ record("Provider removed from connected list after disconnect", afterProviders.length === 0, `remaining=${afterProviders.length}`);
248
+ }
249
+ catch (err) {
250
+ record("Disconnect and cleanup", false, String(err));
251
+ }
252
+ }
253
+ finally {
254
+ // Cleanup
255
+ bus.shutdown();
256
+ store.delete(generated.keyHashPrefix);
257
+ httpServer.close();
258
+ // Summary
259
+ console.log("\n=== Summary ===");
260
+ const passed = results.filter((r) => r.pass).length;
261
+ const total = results.length;
262
+ console.log(` ${passed}/${total} tests passed\n`);
263
+ if (passed < total) {
264
+ process.exit(1);
265
+ }
266
+ }
267
+ }
268
+ run().catch((err) => {
269
+ console.error("Fatal error:", err);
270
+ process.exit(1);
271
+ });
272
+ //# sourceMappingURL=testProviderBus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testProviderBus.js","sourceRoot":"","sources":["../../src/benchmarks/testProviderBus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAA6B,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EACL,WAAW,GAEZ,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,cAAc,GAIf,MAAM,+BAA+B,CAAC;AAEvC,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E,MAAM,OAAO,GAA4D,EAAE,CAAC;AAE5E,SAAS,MAAM,CAAC,IAAY,EAAE,I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AC,qBAAqB,EAAE,CAAC;YACnD,MAAM,CACJ,uDAAuD,EACvD,cAAc,CAAC,MAAM,KAAK,CAAC,EAC3B,aAAa,cAAc,CAAC,MAAM,EAAE,CACrC,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,wBAAwB,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;YAAS,CAAC;QACT,UAAU;QACV,GAAG,CAAC,QAAQ,EAAE,CAAC;QACf,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QACtC,UAAU,CAAC,KAAK,EAAE,CAAC;QAEnB,UAAU;QACV,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACjC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;QACpD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,IAAI,KAAK,iBAAiB,CAAC,CAAC;QAEnD,IAAI,MAAM,GAAG,KAAK,EAAE,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;AACH,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAClB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * testSupermemory.ts — Unit test for SupermemoryProvider.
3
+ *
4
+ * Tests WITHOUT a real API key: verifies graceful error handling,
5
+ * interface compliance, and error class hierarchy.
6
+ * Run: npx tsx src/benchmarks/testSupermemory.ts
7
+ */
8
+ export {};
@@ -0,0 +1,187 @@
1
+ /**
2
+ * testSupermemory.ts — Unit test for SupermemoryProvider.
3
+ *
4
+ * Tests WITHOUT a real API key: verifies graceful error handling,
5
+ * interface compliance, and error class hierarchy.
6
+ * Run: npx tsx src/benchmarks/testSupermemory.ts
7
+ */
8
+ import { SupermemoryProvider, SupermemoryError, SupermemoryAuthError, SupermemoryRateLimitError, } from "../providers/supermemoryProvider.js";
9
+ // ═══════════════════════════════════════════════════════════════════════════
10
+ // Test helpers
11
+ // ═══════════════════════════════════════════════════════════════════════════
12
+ const results = [];
13
+ function record(name, pass, detail) {
14
+ results.push({ name, pass, detail });
15
+ const icon = pass ? "PASS" : "FAIL";
16
+ console.log(` [${icon}] ${name}${detail ? ` — ${detail}` : ""}`);
17
+ }
18
+ // ═══════════════════════════════════════════════════════════════════════════
19
+ // Tests
20
+ // ═══════════════════════════════════════════════════════════════════════════
21
+ async function run() {
22
+ console.log("\n=== SupermemoryProvider Tests ===\n");
23
+ // ── Test 1: Constructor creates a valid instance ───────────────────────
24
+ const provider = new SupermemoryProvider();
25
+ record("Constructor creates instance", provider instanceof SupermemoryProvider);
26
+ // ── Test 2: Implements MemoryProvider interface (all 12 methods + 2 props)
27
+ const requiredMethods = [
28
+ "connect",
29
+ "disconnect",
30
+ "isConnected",
31
+ "store",
32
+ "update",
33
+ "delete",
34
+ "recall",
35
+ "get",
36
+ "list",
37
+ "relate",
38
+ "getProfile",
39
+ "sync",
40
+ ];
41
+ const requiredProps = ["name", "type"];
42
+ let allMethodsPresent = true;
43
+ const missingMethods = [];
44
+ for (const method of requiredMethods) {
45
+ if (typeof provider[method] !== "function") {
46
+ allMethodsPresent = false;
47
+ missingMethods.push(method);
48
+ }
49
+ }
50
+ record(`Implements all ${requiredMethods.length} MemoryProvider methods`, allMethodsPresent, missingMethods.length > 0 ? `missing: ${missingMethods.join(", ")}` : undefined);
51
+ let allPropsPresent = true;
52
+ const missingProps = [];
53
+ for (const prop of requiredProps) {
54
+ if (provider[prop] === undefined) {
55
+ allPropsPresent = false;
56
+ missingProps.push(prop);
57
+ }
58
+ }
59
+ record(`Has required readonly properties (name, type)`, allPropsPresent, missingProps.length > 0 ? `missing: ${missingProps.join(", ")}` : undefined);
60
+ // ── Test 3: name and type values ─────────────────────────────────────
61
+ record("name is 'supermemory'", provider.name === "supermemory", `actual: "${provider.name}"`);
62
+ record("type is 'supermemory'", provider.type === "supermemory", `actual: "${provider.type}"`);
63
+ // ── Test 4: isConnected() before connect() ────────────────────────────
64
+ record("isConnected() is false before connect()", provider.isConnected() === false);
65
+ // ── Test 5: connect() with invalid key — should not throw ─────────────
66
+ // The provider marks itself as connected even if the API returns errors
67
+ // (except for explicit 401 from the validation request).
68
+ // With a fake key hitting a real endpoint, we may get a network error
69
+ // or a 401. The connect() method catches network errors and still marks connected.
70
+ try {
71
+ await provider.connect({ apiKey: "test-invalid-key" });
72
+ // If connect succeeds (network error caught internally), isConnected should be true
73
+ record("connect() with invalid key does not throw", true);
74
+ record("isConnected() returns true after connect()", provider.isConnected() === true);
75
+ }
76
+ catch (err) {
77
+ // connect() only rethrows SupermemoryAuthError (401).
78
+ // A real 401 from the API is expected behavior.
79
+ if (err instanceof SupermemoryAuthError) {
80
+ record("connect() with invalid key throws SupermemoryAuthError", true, "401 from API");
81
+ record("isConnected() returns false after auth failure", provider.isConnected() === false);
82
+ }
83
+ else {
84
+ record("connect() with invalid key does not throw", false, String(err));
85
+ }
86
+ }
87
+ // ── Test 6: store() with invalid key — should throw ───────────────────
88
+ // Re-connect to ensure connected state for store/recall tests
89
+ const provider2 = new SupermemoryProvider();
90
+ try {
91
+ await provider2.connect({ apiKey: "test-invalid-key-2" });
92
+ }
93
+ catch {
94
+ // If 401 from connect, we still test store behavior
95
+ }
96
+ if (provider2.isConnected()) {
97
+ // store() should fail with auth error from the API
98
+ try {
99
+ await provider2.store({ content: "test memory content" });
100
+ record("store() throws on invalid API key", false, "did not throw");
101
+ }
102
+ catch (err) {
103
+ if (err instanceof SupermemoryAuthError) {
104
+ record("store() throws SupermemoryAuthError on invalid key", true);
105
+ record("SupermemoryAuthError has statusCode 401", err.statusCode === 401, `actual: ${err.statusCode}`);
106
+ record("SupermemoryAuthError.name is correct", err.name === "SupermemoryAuthError");
107
+ }
108
+ else if (err instanceof SupermemoryError) {
109
+ // Network error or other API error — still a valid failure mode
110
+ record("store() throws SupermemoryError on invalid key", true, `${err.name}: ${err.message}`);
111
+ }
112
+ else {
113
+ record("store() throws on invalid API key", false, String(err));
114
+ }
115
+ }
116
+ // ── Test 7: recall() with invalid key — should throw ────────────────
117
+ try {
118
+ await provider2.recall("test query");
119
+ record("recall() throws on invalid API key", false, "did not throw");
120
+ }
121
+ catch (err) {
122
+ if (err instanceof SupermemoryAuthError) {
123
+ record("recall() throws SupermemoryAuthError on invalid key", true);
124
+ }
125
+ else if (err instanceof SupermemoryError) {
126
+ record("recall() throws SupermemoryError on invalid key", true, `${err.name}: ${err.message}`);
127
+ }
128
+ else {
129
+ record("recall() throws on invalid API key", false, String(err));
130
+ }
131
+ }
132
+ }
133
+ else {
134
+ record("store()/recall() tests skipped", true, "provider not connected (401 on connect)");
135
+ }
136
+ // ── Test 8: Error class hierarchy ─────────────────────────────────────
137
+ const authErr = new SupermemoryAuthError();
138
+ record("SupermemoryAuthError extends SupermemoryError", authErr instanceof SupermemoryError);
139
+ record("SupermemoryAuthError extends Error", authErr instanceof Error);
140
+ record("SupermemoryAuthError.statusCode is 401", authErr.statusCode === 401);
141
+ const rateLimitErr = new SupermemoryRateLimitError(5000);
142
+ record("SupermemoryRateLimitError extends SupermemoryError", rateLimitErr instanceof SupermemoryError);
143
+ record("SupermemoryRateLimitError.statusCode is 429", rateLimitErr.statusCode === 429);
144
+ record("SupermemoryRateLimitError.retryAfterMs is set", rateLimitErr.retryAfterMs === 5000);
145
+ // ── Test 9: sync() returns no-op result ───────────────────────────────
146
+ const provider3 = new SupermemoryProvider();
147
+ try {
148
+ await provider3.connect({ apiKey: "test-sync-key" });
149
+ }
150
+ catch {
151
+ // ignore auth error
152
+ }
153
+ if (provider3.isConnected()) {
154
+ try {
155
+ const syncResult = await provider3.sync("both");
156
+ record("sync() returns no-op SyncResult", syncResult.pushed === 0 &&
157
+ syncResult.pulled === 0 &&
158
+ syncResult.conflicts === 0 &&
159
+ syncResult.direction === "both", `direction=${syncResult.direction}, pushed=${syncResult.pushed}`);
160
+ }
161
+ catch (err) {
162
+ record("sync() returns no-op SyncResult", false, String(err));
163
+ }
164
+ }
165
+ // ── Test 10: disconnect() ─────────────────────────────────────────────
166
+ if (provider3.isConnected()) {
167
+ await provider3.disconnect();
168
+ record("disconnect() sets isConnected to false", provider3.isConnected() === false);
169
+ }
170
+ // ── Test 11: TypeScript structural compatibility ──────────────────────
171
+ // Verify the provider satisfies MemoryProvider at the type level
172
+ const _typeCheck = new SupermemoryProvider();
173
+ record("Structural type compatibility with MemoryProvider", true);
174
+ // Summary
175
+ console.log("\n=== Summary ===");
176
+ const passed = results.filter((r) => r.pass).length;
177
+ const total = results.length;
178
+ console.log(` ${passed}/${total} tests passed\n`);
179
+ if (passed < total) {
180
+ process.exit(1);
181
+ }
182
+ }
183
+ run().catch((err) => {
184
+ console.error("Fatal error:", err);
185
+ process.exit(1);
186
+ });
187
+ //# sourceMappingURL=testSupermemory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testSupermemory.js","sourceRoot":"","sources":["../../src/benchmarks/testSupermemory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,qCAAqC,CAAC;AAG7C,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E,MAAM,OAAO,GAA4D,EAAE,CAAC;AAE5E,SAAS,MAAM,CAAC,IAAY,EAAE,IAAa,EAAE,MAAe;IAC1D,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,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,CAAC,CAAC;IAElE,UAAU;IACV,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IACpD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IAC7B,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,IAAI,KAAK,iBAAiB,CAAC,CAAC;IAEnD,IAAI,MAAM,GAAG,KAAK,EAAE,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAClB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * founderTrackingTools — Temporal action tracking across sessions, days, weeks,
3
- * months, quarters, and years.
3
+ * months, quarters, and years. Plus agent compatibility validation.
4
4
  *
5
5
  * Every significant action records before/after state and reasoning.
6
6
  * Aggregation queries run in SQL for efficiency.
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * founderTrackingTools — Temporal action tracking across sessions, days, weeks,
3
- * months, quarters, and years.
3
+ * months, quarters, and years. Plus agent compatibility validation.
4
4
  *
5
5
  * Every significant action records before/after state and reasoning.
6
6
  * Aggregation queries run in SQL for efficiency.
7
7
  */
8
8
  import { getDb, genId } from "../db.js";
9
+ import { validateAgentCompatibilityTool } from "../benchmarks/agentValidation.js";
9
10
  /* ------------------------------------------------------------------ */
10
11
  /* Module-level session ID (unique per process) */
11
12
  /* ------------------------------------------------------------------ */
@@ -952,5 +953,6 @@ export const founderTrackingTools = [
952
953
  };
953
954
  },
954
955
  },
956
+ validateAgentCompatibilityTool,
955
957
  ];
956
958
  //# sourceMappingURL=founderTrackingTools.js.map