@kernel.chat/kbot 3.39.0 → 3.40.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,435 @@
1
+ // kbot User Graph — Intelligence-mediated collaboration
2
+ //
3
+ // Connects kbot users working on similar problems. Anonymized by design:
4
+ // no names, no emails, no PII — only hashed IDs and interest vectors.
5
+ // Connection only happens when BOTH users explicitly opt in.
6
+ //
7
+ // Storage: ~/.kbot/user-graph/ directory
8
+ // Encryption: AES-256-CBC for contact info, machine-derived key (same as auth.ts)
9
+ //
10
+ // Node built-ins only — no external dependencies.
11
+ import { homedir } from 'node:os';
12
+ import { join, dirname } from 'node:path';
13
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
14
+ import { createHash, createCipheriv, createDecipheriv, randomBytes } from 'node:crypto';
15
+ // ── Paths ──
16
+ const KBOT_DIR = join(homedir(), '.kbot');
17
+ const USER_GRAPH_DIR = join(KBOT_DIR, 'user-graph');
18
+ const NODES_FILE = join(USER_GRAPH_DIR, 'nodes.json');
19
+ const CONNECTIONS_FILE = join(USER_GRAPH_DIR, 'connections.json');
20
+ const NOTIFICATIONS_FILE = join(USER_GRAPH_DIR, 'notifications.json');
21
+ // ── Helpers ──
22
+ function ensureDir(dir) {
23
+ if (!existsSync(dir))
24
+ mkdirSync(dir, { recursive: true });
25
+ }
26
+ function loadJSON(path, fallback) {
27
+ try {
28
+ if (existsSync(path)) {
29
+ return JSON.parse(readFileSync(path, 'utf-8'));
30
+ }
31
+ }
32
+ catch {
33
+ // Corrupt file — return fallback
34
+ }
35
+ return fallback;
36
+ }
37
+ function saveJSON(path, data) {
38
+ ensureDir(dirname(path));
39
+ writeFileSync(path, JSON.stringify(data, null, 2));
40
+ }
41
+ // ── Encryption (matches auth.ts pattern) ──
42
+ function deriveEncryptionKey() {
43
+ const machineId = `${homedir()}:${process.env.USER || 'kbot'}:${process.arch}`;
44
+ return createHash('sha256').update(machineId).digest();
45
+ }
46
+ function encryptValue(plaintext) {
47
+ const key = deriveEncryptionKey();
48
+ const iv = randomBytes(16);
49
+ const cipher = createCipheriv('aes-256-cbc', key, iv);
50
+ let encrypted = cipher.update(plaintext, 'utf-8', 'base64');
51
+ encrypted += cipher.final('base64');
52
+ return `enc:${iv.toString('base64')}:${encrypted}`;
53
+ }
54
+ function decryptValue(encrypted) {
55
+ if (!encrypted.startsWith('enc:'))
56
+ return encrypted;
57
+ const parts = encrypted.split(':');
58
+ if (parts.length !== 3)
59
+ return encrypted;
60
+ const key = deriveEncryptionKey();
61
+ const iv = Buffer.from(parts[1], 'base64');
62
+ const decipher = createDecipheriv('aes-256-cbc', key, iv);
63
+ let decrypted = decipher.update(parts[2], 'base64', 'utf-8');
64
+ decrypted += decipher.final('utf-8');
65
+ return decrypted;
66
+ }
67
+ // ── Jaccard similarity ──
68
+ function jaccardIndex(setA, setB) {
69
+ if (setA.size === 0 && setB.size === 0)
70
+ return 0;
71
+ let intersectionSize = 0;
72
+ for (const item of setA) {
73
+ if (setB.has(item))
74
+ intersectionSize++;
75
+ }
76
+ const unionSize = setA.size + setB.size - intersectionSize;
77
+ if (unionSize === 0)
78
+ return 0;
79
+ return intersectionSize / unionSize;
80
+ }
81
+ function normalizeSet(items) {
82
+ return new Set(items.map(s => s.toLowerCase().trim()).filter(s => s.length > 0));
83
+ }
84
+ // ── Notification ID generation ──
85
+ function generateNotificationId() {
86
+ return randomBytes(8).toString('hex');
87
+ }
88
+ // ── UserGraph Class ──
89
+ export class UserGraph {
90
+ nodes;
91
+ connections;
92
+ notifications;
93
+ constructor() {
94
+ this.nodes = new Map();
95
+ this.connections = new Map();
96
+ this.notifications = [];
97
+ this.load();
98
+ }
99
+ // ── Persistence ──
100
+ load() {
101
+ const rawNodes = loadJSON(NODES_FILE, []);
102
+ this.nodes = new Map(rawNodes);
103
+ const rawConnections = loadJSON(CONNECTIONS_FILE, []);
104
+ this.connections = new Map(rawConnections);
105
+ this.notifications = loadJSON(NOTIFICATIONS_FILE, []);
106
+ }
107
+ saveNodes() {
108
+ saveJSON(NODES_FILE, Array.from(this.nodes.entries()));
109
+ }
110
+ saveConnections() {
111
+ saveJSON(CONNECTIONS_FILE, Array.from(this.connections.entries()));
112
+ }
113
+ saveNotifications() {
114
+ saveJSON(NOTIFICATIONS_FILE, this.notifications);
115
+ }
116
+ // ── Public API ──
117
+ /**
118
+ * Add or update a user in the graph.
119
+ * All data is anonymized — no emails, names, or PII.
120
+ * Just what they work on.
121
+ */
122
+ addUser(profile) {
123
+ const now = new Date().toISOString();
124
+ const existing = this.nodes.get(profile.id);
125
+ const node = {
126
+ id: profile.id,
127
+ interests: profile.interests,
128
+ goals: profile.goals,
129
+ projectTypes: profile.projectTypes,
130
+ tools_used: profile.tools_used,
131
+ agents_used: profile.agents_used,
132
+ created: existing?.created ?? now,
133
+ lastUpdated: now,
134
+ };
135
+ this.nodes.set(profile.id, node);
136
+ this.saveNodes();
137
+ // Generate match notifications for opted-in users
138
+ this.generateMatchNotifications(profile.id);
139
+ }
140
+ /**
141
+ * Find users with overlapping interests/goals/project types.
142
+ * Returns top 5 matches with similarity score (Jaccard index on interest sets).
143
+ * Does NOT return identifiable info — just the match score and shared interests.
144
+ */
145
+ findSimilarUsers(userId) {
146
+ const user = this.nodes.get(userId);
147
+ if (!user)
148
+ return [];
149
+ const userInterests = normalizeSet(user.interests);
150
+ const userGoals = normalizeSet(user.goals);
151
+ const userProjectTypes = normalizeSet(user.projectTypes);
152
+ const userTools = normalizeSet(user.tools_used);
153
+ const userAgents = normalizeSet(user.agents_used);
154
+ const scored = [];
155
+ for (const [candidateId, candidate] of this.nodes) {
156
+ if (candidateId === userId)
157
+ continue;
158
+ const candidateInterests = normalizeSet(candidate.interests);
159
+ const candidateGoals = normalizeSet(candidate.goals);
160
+ const candidateProjectTypes = normalizeSet(candidate.projectTypes);
161
+ const candidateTools = normalizeSet(candidate.tools_used);
162
+ const candidateAgents = normalizeSet(candidate.agents_used);
163
+ // Weighted Jaccard across all dimensions
164
+ const interestSim = jaccardIndex(userInterests, candidateInterests);
165
+ const goalSim = jaccardIndex(userGoals, candidateGoals);
166
+ const projectSim = jaccardIndex(userProjectTypes, candidateProjectTypes);
167
+ const toolSim = jaccardIndex(userTools, candidateTools);
168
+ const agentSim = jaccardIndex(userAgents, candidateAgents);
169
+ // Weighted composite: interests and project types matter most
170
+ const similarityScore = (interestSim * 0.30 +
171
+ goalSim * 0.20 +
172
+ projectSim * 0.25 +
173
+ toolSim * 0.15 +
174
+ agentSim * 0.10);
175
+ if (similarityScore <= 0)
176
+ continue;
177
+ // Compute shared items (only reveal overlaps, not full vectors)
178
+ const sharedInterests = Array.from(userInterests).filter(i => candidateInterests.has(i));
179
+ const sharedGoals = Array.from(userGoals).filter(g => candidateGoals.has(g));
180
+ const sharedProjectTypes = Array.from(userProjectTypes).filter(p => candidateProjectTypes.has(p));
181
+ scored.push({
182
+ userId: candidateId,
183
+ similarityScore: Math.round(similarityScore * 1000) / 1000,
184
+ sharedInterests,
185
+ sharedGoals,
186
+ sharedProjectTypes,
187
+ });
188
+ }
189
+ // Sort by similarity descending, return top 5
190
+ scored.sort((a, b) => b.similarityScore - a.similarityScore);
191
+ return scored.slice(0, 5);
192
+ }
193
+ /**
194
+ * Based on findSimilarUsers, generates a collaboration suggestion.
195
+ * Human-readable description of the match without exposing identity.
196
+ */
197
+ suggestCollaboration(userId) {
198
+ const matches = this.findSimilarUsers(userId);
199
+ if (matches.length === 0)
200
+ return null;
201
+ const top = matches[0];
202
+ const matchNode = this.nodes.get(top.userId);
203
+ if (!matchNode)
204
+ return null;
205
+ // Build a natural-language suggestion
206
+ const parts = [];
207
+ if (top.sharedProjectTypes.length > 0) {
208
+ parts.push(`a similar ${top.sharedProjectTypes[0]} project`);
209
+ }
210
+ else if (top.sharedInterests.length > 0) {
211
+ parts.push(`similar interests in ${top.sharedInterests.slice(0, 2).join(' and ')}`);
212
+ }
213
+ else if (top.sharedGoals.length > 0) {
214
+ parts.push(`a similar goal: ${top.sharedGoals[0]}`);
215
+ }
216
+ // Mention tools the match uses that the user doesn't
217
+ const user = this.nodes.get(userId);
218
+ if (user) {
219
+ const userToolSet = normalizeSet(user.tools_used);
220
+ const matchUniqueTools = matchNode.tools_used.filter(t => !userToolSet.has(t.toLowerCase().trim()));
221
+ if (matchUniqueTools.length > 0) {
222
+ parts.push(`who found success with ${matchUniqueTools.slice(0, 2).join(' + ')}`);
223
+ }
224
+ }
225
+ const optedIn = this.connections.has(top.userId);
226
+ const projectDesc = parts.length > 0
227
+ ? parts.join(' ')
228
+ : 'overlapping technical interests';
229
+ const suggestion = `There's a kbot user working on ${projectDesc}. ` +
230
+ `Want to connect? (opt-in only)`;
231
+ return {
232
+ matchUserId: top.userId,
233
+ similarityScore: top.similarityScore,
234
+ sharedInterests: top.sharedInterests,
235
+ sharedProjectTypes: top.sharedProjectTypes,
236
+ suggestion,
237
+ optedIn,
238
+ };
239
+ }
240
+ /**
241
+ * Returns aggregate stats across the user graph.
242
+ * No individual data exposed — only counts and rankings.
243
+ */
244
+ getNetworkInsights() {
245
+ const projectTypeCounts = new Map();
246
+ const toolCounts = new Map();
247
+ const interestCounts = new Map();
248
+ for (const node of this.nodes.values()) {
249
+ for (const pt of node.projectTypes) {
250
+ const key = pt.toLowerCase().trim();
251
+ if (key)
252
+ projectTypeCounts.set(key, (projectTypeCounts.get(key) || 0) + 1);
253
+ }
254
+ for (const tool of node.tools_used) {
255
+ const key = tool.toLowerCase().trim();
256
+ if (key)
257
+ toolCounts.set(key, (toolCounts.get(key) || 0) + 1);
258
+ }
259
+ for (const interest of node.interests) {
260
+ const key = interest.toLowerCase().trim();
261
+ if (key)
262
+ interestCounts.set(key, (interestCounts.get(key) || 0) + 1);
263
+ }
264
+ }
265
+ const sortByCount = (map) => Array.from(map.entries())
266
+ .sort((a, b) => b[1] - a[1])
267
+ .slice(0, 10);
268
+ return {
269
+ mostCommonProjectTypes: sortByCount(projectTypeCounts).map(([type, count]) => ({ type, count })),
270
+ mostPopularTools: sortByCount(toolCounts).map(([tool, count]) => ({ tool, count })),
271
+ trendingInterests: sortByCount(interestCounts).map(([interest, count]) => ({ interest, count })),
272
+ totalUsers: this.nodes.size,
273
+ };
274
+ }
275
+ /**
276
+ * User explicitly opts in to be contactable.
277
+ * Contact method is encrypted at rest (AES-256-CBC).
278
+ * Only revealed to matches who also opted in.
279
+ */
280
+ optInToConnect(userId, contactMethod) {
281
+ if (!this.nodes.has(userId)) {
282
+ throw new Error(`User ${userId} not found in the graph. Call addUser first.`);
283
+ }
284
+ const connection = {
285
+ userId,
286
+ contactMethod: encryptValue(contactMethod),
287
+ optedInAt: new Date().toISOString(),
288
+ };
289
+ this.connections.set(userId, connection);
290
+ this.saveConnections();
291
+ // Generate notifications for existing matches
292
+ this.generateMatchNotifications(userId);
293
+ }
294
+ /**
295
+ * Returns pending match notifications for a user who opted in.
296
+ * Only includes matches where BOTH users have opted in.
297
+ */
298
+ getMatchNotifications(userId) {
299
+ if (!this.connections.has(userId))
300
+ return [];
301
+ return this.notifications
302
+ .filter(n => n.targetUserId === userId)
303
+ .map(n => ({
304
+ id: n.id,
305
+ matchUserId: n.matchUserId,
306
+ similarityScore: n.similarityScore,
307
+ sharedInterests: n.sharedInterests,
308
+ sharedProjectTypes: n.sharedProjectTypes,
309
+ suggestion: n.suggestion,
310
+ created: n.created,
311
+ read: n.read,
312
+ }));
313
+ }
314
+ /**
315
+ * Returns aggregate graph statistics.
316
+ */
317
+ getGraphStats() {
318
+ const insights = this.getNetworkInsights();
319
+ // Count mutual connections (both users opted in)
320
+ let totalConnections = 0;
321
+ const optedInIds = new Set(this.connections.keys());
322
+ const counted = new Set();
323
+ for (const userId of optedInIds) {
324
+ const matches = this.findSimilarUsers(userId);
325
+ for (const match of matches) {
326
+ if (optedInIds.has(match.userId)) {
327
+ const pairKey = [userId, match.userId].sort().join(':');
328
+ if (!counted.has(pairKey)) {
329
+ counted.add(pairKey);
330
+ totalConnections++;
331
+ }
332
+ }
333
+ }
334
+ }
335
+ return {
336
+ total_users: this.nodes.size,
337
+ total_connections: totalConnections,
338
+ top_interests: insights.trendingInterests.slice(0, 5).map(i => i.interest),
339
+ top_project_types: insights.mostCommonProjectTypes.slice(0, 5).map(p => p.type),
340
+ most_collaborative_tools: insights.mostPopularTools.slice(0, 5).map(t => t.tool),
341
+ };
342
+ }
343
+ /**
344
+ * Remove a user from the graph entirely.
345
+ * Deletes their node, connection (contact info), and any notifications.
346
+ */
347
+ removeUser(userId) {
348
+ this.nodes.delete(userId);
349
+ this.connections.delete(userId);
350
+ this.notifications = this.notifications.filter(n => n.targetUserId !== userId && n.matchUserId !== userId);
351
+ this.saveNodes();
352
+ this.saveConnections();
353
+ this.saveNotifications();
354
+ }
355
+ /**
356
+ * Mark a notification as read.
357
+ */
358
+ markNotificationRead(notificationId) {
359
+ const notification = this.notifications.find(n => n.id === notificationId);
360
+ if (notification) {
361
+ notification.read = true;
362
+ this.saveNotifications();
363
+ }
364
+ }
365
+ /**
366
+ * Get the decrypted contact method for a mutual match.
367
+ * Only works when BOTH users have opted in.
368
+ * Returns null if either user hasn't opted in.
369
+ */
370
+ getContactForMutualMatch(requestingUserId, matchUserId) {
371
+ const requesterConnection = this.connections.get(requestingUserId);
372
+ const matchConnection = this.connections.get(matchUserId);
373
+ // Both must have opted in
374
+ if (!requesterConnection || !matchConnection)
375
+ return null;
376
+ // Verify they are actually similar (prevent random lookups)
377
+ const matches = this.findSimilarUsers(requestingUserId);
378
+ const isMatch = matches.some(m => m.userId === matchUserId);
379
+ if (!isMatch)
380
+ return null;
381
+ try {
382
+ return decryptValue(matchConnection.contactMethod);
383
+ }
384
+ catch {
385
+ return null;
386
+ }
387
+ }
388
+ // ── Private helpers ──
389
+ /**
390
+ * Generate match notifications for opted-in users who are similar to the given user.
391
+ * Only creates notifications when BOTH users have opted in.
392
+ */
393
+ generateMatchNotifications(userId) {
394
+ // Only generate if this user is opted in
395
+ if (!this.connections.has(userId))
396
+ return;
397
+ const matches = this.findSimilarUsers(userId);
398
+ const now = new Date().toISOString();
399
+ for (const match of matches) {
400
+ // Only notify if the match is also opted in
401
+ if (!this.connections.has(match.userId))
402
+ continue;
403
+ // Avoid duplicate notifications
404
+ const alreadyNotified = this.notifications.some(n => n.targetUserId === match.userId &&
405
+ n.matchUserId === userId);
406
+ if (alreadyNotified)
407
+ continue;
408
+ // Build suggestion text
409
+ const projectDesc = match.sharedProjectTypes.length > 0
410
+ ? `a ${match.sharedProjectTypes[0]} project`
411
+ : match.sharedInterests.length > 0
412
+ ? `interests in ${match.sharedInterests.slice(0, 2).join(' and ')}`
413
+ : 'overlapping technical interests';
414
+ const suggestion = `A kbot user with ${projectDesc} is also looking to connect. ` +
415
+ `Similarity: ${Math.round(match.similarityScore * 100)}%.`;
416
+ this.notifications.push({
417
+ id: generateNotificationId(),
418
+ targetUserId: match.userId,
419
+ matchUserId: userId,
420
+ similarityScore: match.similarityScore,
421
+ sharedInterests: match.sharedInterests,
422
+ sharedProjectTypes: match.sharedProjectTypes,
423
+ suggestion,
424
+ created: now,
425
+ read: false,
426
+ });
427
+ }
428
+ // Cap stored notifications at 200
429
+ if (this.notifications.length > 200) {
430
+ this.notifications = this.notifications.slice(-200);
431
+ }
432
+ this.saveNotifications();
433
+ }
434
+ }
435
+ //# sourceMappingURL=user-graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-graph.js","sourceRoot":"","sources":["../src/user-graph.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,yEAAyE;AACzE,sEAAsE;AACtE,6DAA6D;AAC7D,EAAE;AACF,yCAAyC;AACzC,kFAAkF;AAClF,EAAE;AACF,kDAAkD;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAc,MAAM,SAAS,CAAA;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gBAC5C,UAAU;gBACV,OAAO,EAAE,GAAG;gBACZ,IAAI,EAAE,KAAK;aACZ,CAAC,CAAA;QACJ,CAAC;QAED,kCAAkC;QAClC,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YACpC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAA;QACrD,CAAC;QAED,IAAI,CAAC,iBAAiB,EAAE,CAAA;IAC1B,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kernel.chat/kbot",
3
- "version": "3.39.0",
3
+ "version": "3.40.0",
4
4
  "description": "The only AI agent that builds its own tools — and defends itself. Self-Defense System: HMAC memory integrity, prompt injection detection, knowledge sanitization, forge verification, anomaly detection, incident logging. Cybersecurity tools: dep_audit, secret_scan, ssl_check, headers_check, cve_lookup, port_scan, owasp_check. Machine-aware situated intelligence: full hardware profiling (CPU, GPU, RAM, display, battery, dev tools), resource-adaptive tool pipeline, memory-pressure throttling, GPU-accelerated model routing. Multi-channel cognitive engine: email agent, iMessage agent, consultation pipeline, Trader agent with paper trading & DeFi, 26 specialist agents, 345+ tools, 20 providers. Finance stack: 31 tools across market data, wallet & swaps, stocks, and sentiment. Synthesis Engine: closed-loop intelligence compounding. Runtime tool forging, Forge Registry, autopoietic health, immune self-audit. Cost-aware model routing, fallback chains, Bayesian skill routing. 11 local models (Llama 3.3, Qwen 3, DeepSeek R1, Codestral 22B). Embedded llama.cpp, MCP server, SDK. MIT.",
5
5
  "type": "module",
6
6
  "repository": {