nodebench-mcp 2.70.0 → 3.0.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.
Files changed (214) hide show
  1. package/README.md +95 -41
  2. package/dist/agents/alertRouter.d.ts +38 -0
  3. package/dist/agents/alertRouter.js +151 -0
  4. package/dist/agents/alertRouter.js.map +1 -0
  5. package/dist/agents/entityMemory.d.ts +40 -0
  6. package/dist/agents/entityMemory.js +64 -0
  7. package/dist/agents/entityMemory.js.map +1 -0
  8. package/dist/agents/subAgents.d.ts +35 -0
  9. package/dist/agents/subAgents.js +62 -0
  10. package/dist/agents/subAgents.js.map +1 -0
  11. package/dist/benchmarks/benchmarkRunner.js +14 -0
  12. package/dist/benchmarks/benchmarkRunner.js.map +1 -1
  13. package/dist/benchmarks/chainEval.js +107 -0
  14. package/dist/benchmarks/chainEval.js.map +1 -1
  15. package/dist/benchmarks/llmJudgeEval.js +85 -0
  16. package/dist/benchmarks/llmJudgeEval.js.map +1 -1
  17. package/dist/benchmarks/searchQualityEval.js +118 -5
  18. package/dist/benchmarks/searchQualityEval.js.map +1 -1
  19. package/dist/cli/search.d.ts +13 -0
  20. package/dist/cli/search.js +130 -0
  21. package/dist/cli/search.js.map +1 -0
  22. package/dist/db.d.ts +6 -2
  23. package/dist/db.js +470 -3
  24. package/dist/db.js.map +1 -1
  25. package/dist/index.js +349 -64
  26. package/dist/index.js.map +1 -1
  27. package/dist/profiler/behaviorStore.d.ts +97 -0
  28. package/dist/profiler/behaviorStore.js +276 -0
  29. package/dist/profiler/behaviorStore.js.map +1 -0
  30. package/dist/profiler/eventCollector.d.ts +119 -0
  31. package/dist/profiler/eventCollector.js +267 -0
  32. package/dist/profiler/eventCollector.js.map +1 -0
  33. package/dist/profiler/index.d.ts +15 -0
  34. package/dist/profiler/index.js +16 -0
  35. package/dist/profiler/index.js.map +1 -0
  36. package/dist/profiler/mcpProxy.d.ts +49 -0
  37. package/dist/profiler/mcpProxy.js +123 -0
  38. package/dist/profiler/mcpProxy.js.map +1 -0
  39. package/dist/profiler/modelRouter.d.ts +30 -0
  40. package/dist/profiler/modelRouter.js +99 -0
  41. package/dist/profiler/modelRouter.js.map +1 -0
  42. package/dist/profiler/otelReceiver.d.ts +17 -0
  43. package/dist/profiler/otelReceiver.js +62 -0
  44. package/dist/profiler/otelReceiver.js.map +1 -0
  45. package/dist/profiler/proofEngine.d.ts +41 -0
  46. package/dist/profiler/proofEngine.js +93 -0
  47. package/dist/profiler/proofEngine.js.map +1 -0
  48. package/dist/profiler/workflowTemplates.d.ts +41 -0
  49. package/dist/profiler/workflowTemplates.js +95 -0
  50. package/dist/profiler/workflowTemplates.js.map +1 -0
  51. package/dist/providers/localMemoryProvider.js +3 -2
  52. package/dist/providers/localMemoryProvider.js.map +1 -1
  53. package/dist/runtimeConfig.d.ts +11 -0
  54. package/dist/runtimeConfig.js +27 -0
  55. package/dist/runtimeConfig.js.map +1 -0
  56. package/dist/security/auditLog.js +8 -3
  57. package/dist/security/auditLog.js.map +1 -1
  58. package/dist/subconscious/blocks.d.ts +43 -0
  59. package/dist/subconscious/blocks.js +158 -0
  60. package/dist/subconscious/blocks.js.map +1 -0
  61. package/dist/subconscious/classifier.d.ts +22 -0
  62. package/dist/subconscious/classifier.js +118 -0
  63. package/dist/subconscious/classifier.js.map +1 -0
  64. package/dist/subconscious/graphEngine.d.ts +65 -0
  65. package/dist/subconscious/graphEngine.js +234 -0
  66. package/dist/subconscious/graphEngine.js.map +1 -0
  67. package/dist/subconscious/index.d.ts +19 -0
  68. package/dist/subconscious/index.js +20 -0
  69. package/dist/subconscious/index.js.map +1 -0
  70. package/dist/subconscious/tools.d.ts +5 -0
  71. package/dist/subconscious/tools.js +255 -0
  72. package/dist/subconscious/tools.js.map +1 -0
  73. package/dist/subconscious/whisperPolicy.d.ts +20 -0
  74. package/dist/subconscious/whisperPolicy.js +171 -0
  75. package/dist/subconscious/whisperPolicy.js.map +1 -0
  76. package/dist/sweep/engine.d.ts +27 -0
  77. package/dist/sweep/engine.js +244 -0
  78. package/dist/sweep/engine.js.map +1 -0
  79. package/dist/sweep/index.d.ts +9 -0
  80. package/dist/sweep/index.js +8 -0
  81. package/dist/sweep/index.js.map +1 -0
  82. package/dist/sweep/sources/github_trending.d.ts +6 -0
  83. package/dist/sweep/sources/github_trending.js +37 -0
  84. package/dist/sweep/sources/github_trending.js.map +1 -0
  85. package/dist/sweep/sources/hackernews.d.ts +7 -0
  86. package/dist/sweep/sources/hackernews.js +57 -0
  87. package/dist/sweep/sources/hackernews.js.map +1 -0
  88. package/dist/sweep/sources/openbb_finance.d.ts +9 -0
  89. package/dist/sweep/sources/openbb_finance.js +46 -0
  90. package/dist/sweep/sources/openbb_finance.js.map +1 -0
  91. package/dist/sweep/sources/producthunt.d.ts +6 -0
  92. package/dist/sweep/sources/producthunt.js +41 -0
  93. package/dist/sweep/sources/producthunt.js.map +1 -0
  94. package/dist/sweep/sources/web_signals.d.ts +7 -0
  95. package/dist/sweep/sources/web_signals.js +63 -0
  96. package/dist/sweep/sources/web_signals.js.map +1 -0
  97. package/dist/sweep/sources/yahoo_finance.d.ts +6 -0
  98. package/dist/sweep/sources/yahoo_finance.js +47 -0
  99. package/dist/sweep/sources/yahoo_finance.js.map +1 -0
  100. package/dist/sweep/types.d.ts +50 -0
  101. package/dist/sweep/types.js +9 -0
  102. package/dist/sweep/types.js.map +1 -0
  103. package/dist/sync/founderEpisodeStore.d.ts +98 -0
  104. package/dist/sync/founderEpisodeStore.js +230 -0
  105. package/dist/sync/founderEpisodeStore.js.map +1 -0
  106. package/dist/sync/hyperloopArchive.d.ts +51 -0
  107. package/dist/sync/hyperloopArchive.js +153 -0
  108. package/dist/sync/hyperloopArchive.js.map +1 -0
  109. package/dist/sync/hyperloopEval.d.ts +123 -0
  110. package/dist/sync/hyperloopEval.js +389 -0
  111. package/dist/sync/hyperloopEval.js.map +1 -0
  112. package/dist/sync/hyperloopEval.test.d.ts +4 -0
  113. package/dist/sync/hyperloopEval.test.js +60 -0
  114. package/dist/sync/hyperloopEval.test.js.map +1 -0
  115. package/dist/sync/protocol.d.ts +172 -0
  116. package/dist/sync/protocol.js +9 -0
  117. package/dist/sync/protocol.js.map +1 -0
  118. package/dist/sync/sessionMemory.d.ts +47 -0
  119. package/dist/sync/sessionMemory.js +138 -0
  120. package/dist/sync/sessionMemory.js.map +1 -0
  121. package/dist/sync/store.d.ts +384 -0
  122. package/dist/sync/store.js +1435 -0
  123. package/dist/sync/store.js.map +1 -0
  124. package/dist/sync/store.test.d.ts +4 -0
  125. package/dist/sync/store.test.js +43 -0
  126. package/dist/sync/store.test.js.map +1 -0
  127. package/dist/sync/syncBridgeClient.d.ts +30 -0
  128. package/dist/sync/syncBridgeClient.js +172 -0
  129. package/dist/sync/syncBridgeClient.js.map +1 -0
  130. package/dist/tools/autonomousDeliveryTools.d.ts +2 -0
  131. package/dist/tools/autonomousDeliveryTools.js +1104 -0
  132. package/dist/tools/autonomousDeliveryTools.js.map +1 -0
  133. package/dist/tools/claudeCodeIngestTools.d.ts +10 -0
  134. package/dist/tools/claudeCodeIngestTools.js +347 -0
  135. package/dist/tools/claudeCodeIngestTools.js.map +1 -0
  136. package/dist/tools/coreWorkflowTools.d.ts +2 -0
  137. package/dist/tools/coreWorkflowTools.js +488 -0
  138. package/dist/tools/coreWorkflowTools.js.map +1 -0
  139. package/dist/tools/deltaTools.d.ts +15 -0
  140. package/dist/tools/deltaTools.js +1522 -0
  141. package/dist/tools/deltaTools.js.map +1 -0
  142. package/dist/tools/entityLookupTools.d.ts +14 -0
  143. package/dist/tools/entityLookupTools.js +159 -0
  144. package/dist/tools/entityLookupTools.js.map +1 -0
  145. package/dist/tools/entityTemporalTools.d.ts +12 -0
  146. package/dist/tools/entityTemporalTools.js +330 -0
  147. package/dist/tools/entityTemporalTools.js.map +1 -0
  148. package/dist/tools/founderLocalPipeline.d.ts +215 -0
  149. package/dist/tools/founderLocalPipeline.js +1516 -2
  150. package/dist/tools/founderLocalPipeline.js.map +1 -1
  151. package/dist/tools/founderOperatingModel.d.ts +120 -0
  152. package/dist/tools/founderOperatingModel.js +469 -0
  153. package/dist/tools/founderOperatingModel.js.map +1 -0
  154. package/dist/tools/founderOperatingModelTools.d.ts +2 -0
  155. package/dist/tools/founderOperatingModelTools.js +169 -0
  156. package/dist/tools/founderOperatingModelTools.js.map +1 -0
  157. package/dist/tools/founderStrategicOpsTools.d.ts +2 -0
  158. package/dist/tools/founderStrategicOpsTools.js +1310 -0
  159. package/dist/tools/founderStrategicOpsTools.js.map +1 -0
  160. package/dist/tools/graphifyTools.d.ts +19 -0
  161. package/dist/tools/graphifyTools.js +375 -0
  162. package/dist/tools/graphifyTools.js.map +1 -0
  163. package/dist/tools/index.d.ts +3 -0
  164. package/dist/tools/index.js +4 -0
  165. package/dist/tools/index.js.map +1 -1
  166. package/dist/tools/monteCarloTools.d.ts +16 -0
  167. package/dist/tools/monteCarloTools.js +225 -0
  168. package/dist/tools/monteCarloTools.js.map +1 -0
  169. package/dist/tools/packetCompilerTools.d.ts +12 -0
  170. package/dist/tools/packetCompilerTools.js +322 -0
  171. package/dist/tools/packetCompilerTools.js.map +1 -0
  172. package/dist/tools/planSynthesisTools.d.ts +15 -0
  173. package/dist/tools/planSynthesisTools.js +455 -0
  174. package/dist/tools/planSynthesisTools.js.map +1 -0
  175. package/dist/tools/profilerTools.d.ts +20 -0
  176. package/dist/tools/profilerTools.js +364 -0
  177. package/dist/tools/profilerTools.js.map +1 -0
  178. package/dist/tools/savingsTools.d.ts +11 -0
  179. package/dist/tools/savingsTools.js +155 -0
  180. package/dist/tools/savingsTools.js.map +1 -0
  181. package/dist/tools/scenarioCompilerTools.d.ts +14 -0
  182. package/dist/tools/scenarioCompilerTools.js +290 -0
  183. package/dist/tools/scenarioCompilerTools.js.map +1 -0
  184. package/dist/tools/sharedContextTools.d.ts +2 -0
  185. package/dist/tools/sharedContextTools.js +423 -0
  186. package/dist/tools/sharedContextTools.js.map +1 -0
  187. package/dist/tools/sitemapTools.d.ts +15 -0
  188. package/dist/tools/sitemapTools.js +560 -0
  189. package/dist/tools/sitemapTools.js.map +1 -0
  190. package/dist/tools/sweepTools.d.ts +9 -0
  191. package/dist/tools/sweepTools.js +112 -0
  192. package/dist/tools/sweepTools.js.map +1 -0
  193. package/dist/tools/syncBridgeTools.d.ts +2 -0
  194. package/dist/tools/syncBridgeTools.js +258 -0
  195. package/dist/tools/syncBridgeTools.js.map +1 -0
  196. package/dist/tools/toolRegistry.js +1216 -49
  197. package/dist/tools/toolRegistry.js.map +1 -1
  198. package/dist/tools/workspaceTools.d.ts +19 -0
  199. package/dist/tools/workspaceTools.js +762 -0
  200. package/dist/tools/workspaceTools.js.map +1 -0
  201. package/dist/toolsetRegistry.js +88 -2
  202. package/dist/toolsetRegistry.js.map +1 -1
  203. package/package.json +36 -36
  204. package/rules/nodebench-agentic-reliability.md +32 -0
  205. package/rules/nodebench-analyst-diagnostic.md +25 -0
  206. package/rules/nodebench-auto-qa.md +31 -0
  207. package/rules/nodebench-completion-traceability.md +22 -0
  208. package/rules/nodebench-flywheel-continuous.md +25 -0
  209. package/rules/nodebench-pre-release-review.md +24 -0
  210. package/rules/nodebench-qa-dogfood.md +26 -0
  211. package/rules/nodebench-scenario-testing.md +30 -0
  212. package/rules/nodebench-self-direction.md +23 -0
  213. package/rules/nodebench-self-judge-loop.md +24 -0
  214. package/scripts/install.sh +215 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Graph Engine — knowledge graph operations on existing object_nodes + object_edges tables.
3
+ *
4
+ * Reuses the existing schema (no new tables). Adds BFS traversal,
5
+ * entity resolution, and contradiction detection.
6
+ *
7
+ * Entity types follow Parselyfi's LINKUP_COMPANY_SCHEMA pattern:
8
+ * company, person, initiative, packet, decision, event, concept, requirement.
9
+ */
10
+ export type EntityType = "company" | "person" | "initiative" | "packet" | "decision" | "event" | "concept" | "requirement";
11
+ export type RelationType = "related_to" | "caused_by" | "supports" | "contradicts" | "follows" | "references" | "part_of" | "derived_from" | "competes_with" | "leads" | "offers" | "announced";
12
+ export interface GraphEntity {
13
+ id: string;
14
+ kind: EntityType;
15
+ label: string;
16
+ source: string;
17
+ status: "active" | "archived";
18
+ properties: Record<string, unknown>;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ }
22
+ export interface GraphEdge {
23
+ id: string;
24
+ fromId: string;
25
+ toId: string;
26
+ edgeType: RelationType;
27
+ confidence: number;
28
+ metadata: Record<string, unknown>;
29
+ createdAt: string;
30
+ }
31
+ export interface TraversalResult {
32
+ entity: GraphEntity;
33
+ hopDistance: number;
34
+ path: GraphEdge[];
35
+ reachedVia: RelationType;
36
+ confidence: number;
37
+ }
38
+ export interface GraphSummary {
39
+ totalEntities: number;
40
+ totalEdges: number;
41
+ entitiesByType: Record<string, number>;
42
+ edgesByType: Record<string, number>;
43
+ recentEntities: Array<{
44
+ label: string;
45
+ kind: string;
46
+ updatedAt: string;
47
+ }>;
48
+ }
49
+ export declare function upsertEntity(label: string, kind: EntityType, source: string, properties?: Record<string, unknown>): GraphEntity;
50
+ export declare function findEntity(label: string, kind?: EntityType): GraphEntity | null;
51
+ export declare function searchEntities(query: string, limit?: number): GraphEntity[];
52
+ export declare function resolveEntity(nameOrId: string): GraphEntity | null;
53
+ export declare function addEdge(fromId: string, toId: string, edgeType: RelationType, confidence?: number, metadata?: Record<string, unknown>): GraphEdge | null;
54
+ export declare function getEdgesFrom(entityId: string, relationFilter?: RelationType[]): GraphEdge[];
55
+ export declare function getEdgesTo(entityId: string, relationFilter?: RelationType[]): GraphEdge[];
56
+ export declare function traverseGraph(startEntityId: string, maxDepth?: number, relationFilter?: RelationType[]): TraversalResult[];
57
+ /**
58
+ * Find all entities connected by "contradicts" edges within N hops.
59
+ */
60
+ export declare function findContradictions(entityId: string, maxDepth?: number): TraversalResult[];
61
+ /**
62
+ * Trace derivation chain: derived_from → part_of → caused_by
63
+ */
64
+ export declare function traceLineage(entityId: string, maxDepth?: number): TraversalResult[];
65
+ export declare function getGraphSummary(): GraphSummary;
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Graph Engine — knowledge graph operations on existing object_nodes + object_edges tables.
3
+ *
4
+ * Reuses the existing schema (no new tables). Adds BFS traversal,
5
+ * entity resolution, and contradiction detection.
6
+ *
7
+ * Entity types follow Parselyfi's LINKUP_COMPANY_SCHEMA pattern:
8
+ * company, person, initiative, packet, decision, event, concept, requirement.
9
+ */
10
+ import { getDb, genId } from "../db.js";
11
+ // ── Entity CRUD ────────────────────────────────────────────────────────────
12
+ export function upsertEntity(label, kind, source, properties = {}) {
13
+ const db = getDb();
14
+ const id = genId("ent");
15
+ // Check if entity with same label + kind exists
16
+ const existing = db
17
+ .prepare("SELECT * FROM object_nodes WHERE label = ? AND kind = ?")
18
+ .get(label, kind);
19
+ if (existing) {
20
+ // Merge properties
21
+ const existingProps = JSON.parse(existing.metadata_json || "{}");
22
+ const mergedProps = { ...existingProps, ...properties };
23
+ const mentionCount = (existingProps._mentionCount || 0) + 1;
24
+ mergedProps._mentionCount = mentionCount;
25
+ db.prepare(`UPDATE object_nodes SET metadata_json = ?, updated_at = datetime('now') WHERE id = ?`).run(JSON.stringify(mergedProps), existing.id);
26
+ return rowToEntity(db.prepare("SELECT * FROM object_nodes WHERE id = ?").get(existing.id));
27
+ }
28
+ // Create new
29
+ properties._mentionCount = 1;
30
+ db.prepare(`INSERT INTO object_nodes (id, kind, label, source, status, metadata_json)
31
+ VALUES (?, ?, ?, ?, 'active', ?)`).run(id, kind, label, source, JSON.stringify(properties));
32
+ return rowToEntity(db.prepare("SELECT * FROM object_nodes WHERE id = ?").get(id));
33
+ }
34
+ export function findEntity(label, kind) {
35
+ const db = getDb();
36
+ let row;
37
+ if (kind) {
38
+ row = db
39
+ .prepare("SELECT * FROM object_nodes WHERE label = ? AND kind = ?")
40
+ .get(label, kind);
41
+ }
42
+ else {
43
+ row = db
44
+ .prepare("SELECT * FROM object_nodes WHERE label = ? ORDER BY updated_at DESC LIMIT 1")
45
+ .get(label);
46
+ }
47
+ return row ? rowToEntity(row) : null;
48
+ }
49
+ export function searchEntities(query, limit = 10) {
50
+ const db = getDb();
51
+ // Try FTS5 first
52
+ try {
53
+ const rows = db
54
+ .prepare(`SELECT n.* FROM object_nodes_fts fts
55
+ JOIN object_nodes n ON n.rowid = fts.rowid
56
+ WHERE object_nodes_fts MATCH ?
57
+ ORDER BY rank
58
+ LIMIT ?`)
59
+ .all(query, limit);
60
+ return rows.map(rowToEntity);
61
+ }
62
+ catch {
63
+ // Fallback to LIKE
64
+ const rows = db
65
+ .prepare(`SELECT * FROM object_nodes
66
+ WHERE label LIKE ? OR metadata_json LIKE ?
67
+ ORDER BY updated_at DESC
68
+ LIMIT ?`)
69
+ .all(`%${query}%`, `%${query}%`, limit);
70
+ return rows.map(rowToEntity);
71
+ }
72
+ }
73
+ export function resolveEntity(nameOrId) {
74
+ const db = getDb();
75
+ // Try by ID
76
+ let row = db.prepare("SELECT * FROM object_nodes WHERE id = ?").get(nameOrId);
77
+ if (row)
78
+ return rowToEntity(row);
79
+ // Try by exact label
80
+ row = db
81
+ .prepare("SELECT * FROM object_nodes WHERE label = ? ORDER BY updated_at DESC LIMIT 1")
82
+ .get(nameOrId);
83
+ if (row)
84
+ return rowToEntity(row);
85
+ // Try fuzzy
86
+ const results = searchEntities(nameOrId, 1);
87
+ return results.length > 0 ? results[0] : null;
88
+ }
89
+ // ── Edge CRUD ──────────────────────────────────────────────────────────────
90
+ export function addEdge(fromId, toId, edgeType, confidence = 0.8, metadata = {}) {
91
+ const db = getDb();
92
+ const id = genId("edge");
93
+ try {
94
+ db.prepare(`INSERT OR IGNORE INTO object_edges (id, from_id, to_id, edge_type, confidence, metadata_json)
95
+ VALUES (?, ?, ?, ?, ?, ?)`).run(id, fromId, toId, edgeType, confidence, JSON.stringify(metadata));
96
+ const row = db.prepare("SELECT * FROM object_edges WHERE id = ?").get(id);
97
+ return row ? rowToEdge(row) : null;
98
+ }
99
+ catch {
100
+ return null;
101
+ }
102
+ }
103
+ export function getEdgesFrom(entityId, relationFilter) {
104
+ const db = getDb();
105
+ if (relationFilter && relationFilter.length > 0) {
106
+ const placeholders = relationFilter.map(() => "?").join(",");
107
+ return db
108
+ .prepare(`SELECT * FROM object_edges WHERE from_id = ? AND edge_type IN (${placeholders})`)
109
+ .all(entityId, ...relationFilter).map(rowToEdge);
110
+ }
111
+ return db.prepare("SELECT * FROM object_edges WHERE from_id = ?").all(entityId).map(rowToEdge);
112
+ }
113
+ export function getEdgesTo(entityId, relationFilter) {
114
+ const db = getDb();
115
+ if (relationFilter && relationFilter.length > 0) {
116
+ const placeholders = relationFilter.map(() => "?").join(",");
117
+ return db
118
+ .prepare(`SELECT * FROM object_edges WHERE to_id = ? AND edge_type IN (${placeholders})`)
119
+ .all(entityId, ...relationFilter).map(rowToEdge);
120
+ }
121
+ return db.prepare("SELECT * FROM object_edges WHERE to_id = ?").all(entityId).map(rowToEdge);
122
+ }
123
+ // ── BFS Graph Traversal ────────────────────────────────────────────────────
124
+ export function traverseGraph(startEntityId, maxDepth = 2, relationFilter) {
125
+ const visited = new Set();
126
+ const queue = [
127
+ { entityId: startEntityId, depth: 0, path: [] },
128
+ ];
129
+ const results = [];
130
+ const db = getDb();
131
+ while (queue.length > 0) {
132
+ const { entityId, depth, path } = queue.shift();
133
+ if (depth > maxDepth || visited.has(entityId))
134
+ continue;
135
+ visited.add(entityId);
136
+ // Get both outgoing and incoming edges
137
+ const outEdges = getEdgesFrom(entityId, relationFilter);
138
+ const inEdges = getEdgesTo(entityId, relationFilter);
139
+ const allEdges = [
140
+ ...outEdges.map((e) => ({ edge: e, neighborId: e.toId })),
141
+ ...inEdges.map((e) => ({ edge: e, neighborId: e.fromId })),
142
+ ];
143
+ for (const { edge, neighborId } of allEdges) {
144
+ if (visited.has(neighborId))
145
+ continue;
146
+ const newPath = [...path, edge];
147
+ const entityRow = db
148
+ .prepare("SELECT * FROM object_nodes WHERE id = ?")
149
+ .get(neighborId);
150
+ if (!entityRow)
151
+ continue;
152
+ results.push({
153
+ entity: rowToEntity(entityRow),
154
+ hopDistance: depth + 1,
155
+ path: newPath,
156
+ reachedVia: edge.edgeType,
157
+ confidence: newPath.reduce((acc, e) => acc * e.confidence, 1),
158
+ });
159
+ if (depth + 1 < maxDepth) {
160
+ queue.push({ entityId: neighborId, depth: depth + 1, path: newPath });
161
+ }
162
+ }
163
+ }
164
+ return results.sort((a, b) => b.confidence - a.confidence);
165
+ }
166
+ /**
167
+ * Find all entities connected by "contradicts" edges within N hops.
168
+ */
169
+ export function findContradictions(entityId, maxDepth = 2) {
170
+ return traverseGraph(entityId, maxDepth, ["contradicts"]);
171
+ }
172
+ /**
173
+ * Trace derivation chain: derived_from → part_of → caused_by
174
+ */
175
+ export function traceLineage(entityId, maxDepth = 5) {
176
+ return traverseGraph(entityId, maxDepth, ["derived_from", "part_of", "caused_by"]);
177
+ }
178
+ // ── Summary ────────────────────────────────────────────────────────────────
179
+ export function getGraphSummary() {
180
+ const db = getDb();
181
+ const totalEntities = db.prepare("SELECT COUNT(*) as c FROM object_nodes").get().c;
182
+ const totalEdges = db.prepare("SELECT COUNT(*) as c FROM object_edges").get().c;
183
+ const kindCounts = db
184
+ .prepare("SELECT kind, COUNT(*) as c FROM object_nodes GROUP BY kind")
185
+ .all();
186
+ const entitiesByType = {};
187
+ for (const row of kindCounts)
188
+ entitiesByType[row.kind] = row.c;
189
+ const edgeTypeCounts = db
190
+ .prepare("SELECT edge_type, COUNT(*) as c FROM object_edges GROUP BY edge_type")
191
+ .all();
192
+ const edgesByType = {};
193
+ for (const row of edgeTypeCounts)
194
+ edgesByType[row.edge_type] = row.c;
195
+ const recent = db
196
+ .prepare("SELECT label, kind, updated_at FROM object_nodes ORDER BY updated_at DESC LIMIT 10")
197
+ .all();
198
+ return {
199
+ totalEntities,
200
+ totalEdges,
201
+ entitiesByType,
202
+ edgesByType,
203
+ recentEntities: recent.map((r) => ({
204
+ label: r.label,
205
+ kind: r.kind,
206
+ updatedAt: r.updated_at,
207
+ })),
208
+ };
209
+ }
210
+ // ── Helpers ────────────────────────────────────────────────────────────────
211
+ function rowToEntity(row) {
212
+ return {
213
+ id: row.id,
214
+ kind: row.kind,
215
+ label: row.label,
216
+ source: row.source,
217
+ status: row.status,
218
+ properties: JSON.parse(row.metadata_json || "{}"),
219
+ createdAt: row.created_at,
220
+ updatedAt: row.updated_at,
221
+ };
222
+ }
223
+ function rowToEdge(row) {
224
+ return {
225
+ id: row.id,
226
+ fromId: row.from_id,
227
+ toId: row.to_id,
228
+ edgeType: row.edge_type,
229
+ confidence: row.confidence,
230
+ metadata: JSON.parse(row.metadata_json || "{}"),
231
+ createdAt: row.created_at,
232
+ };
233
+ }
234
+ //# sourceMappingURL=graphEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphEngine.js","sourceRoot":"","sources":["../../src/subconscious/graphEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAkDxC,8EAA8E;AAE9E,MAAM,UAAU,YAAY,CAC1B,KAAa,EACb,IAAgB,EAChB,MAAc,EACd,aAAsC,EAAE;IAExC,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAExB,gDAAgD;IAChD,MAAM,QAAQ,GAAG,EAAE;SAChB,OAAO,CAAC,yDAAyD,CAAC;SAClE,GAAG,CAAC,KAAK,EAAE,IAAI,CAAQ,CAAC;IAE3B,IAAI,QAAQ,EAAE,CAAC;QACb,mBAAmB;QACnB,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,IAAI,IAAI,CAAC,CAAC;QACjE,MAAM,WAAW,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,UAAU,EAAE,CAAC;QACxD,MAAM,YAAY,GAAG,CAAC,aAAa,CAAC,aAAa,IAAI,CAAC,CAAC,GAAG,CAA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rF;SACA,GAAG,EAAW,CAAC;IAElB,OAAO;QACL,aAAa;QACb,UAAU;QACV,cAAc;QACd,WAAW;QACX,cAAc,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;YACtC,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,SAAS,EAAE,CAAC,CAAC,UAAU;SACxB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED,8EAA8E;AAE9E,SAAS,WAAW,CAAC,GAAQ;IAC3B,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,IAAI,EAAE,GAAG,CAAC,IAAkB;QAC5B,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,MAAM,EAAE,GAAG,CAAC,MAA+B;QAC3C,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,IAAI,IAAI,CAAC;QACjD,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,SAAS,EAAE,GAAG,CAAC,UAAU;KAC1B,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,GAAQ;IACzB,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,MAAM,EAAE,GAAG,CAAC,OAAO;QACnB,IAAI,EAAE,GAAG,CAAC,KAAK;QACf,QAAQ,EAAE,GAAG,CAAC,SAAyB;QACvC,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,IAAI,IAAI,CAAC;QAC/C,SAAS,EAAE,GAAG,CAAC,UAAU;KAC1B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * NodeBench Subconscious — background intelligence agent.
3
+ *
4
+ * Watches founder/coding sessions, maintains company truth memory blocks,
5
+ * builds a knowledge graph of entities + relationships, and whispers
6
+ * packet-aware guidance back into Claude Code and NodeBench surfaces.
7
+ *
8
+ * Architecture:
9
+ * - 12 typed memory blocks (blocks.ts)
10
+ * - Prompt classifier (classifier.ts)
11
+ * - Knowledge graph on existing object_nodes + object_edges (graphEngine.ts)
12
+ * - Whisper policy with suppression rules (whisperPolicy.ts)
13
+ * - 10 MCP tools (tools.ts)
14
+ */
15
+ export { subconsciousTools } from "./tools.js";
16
+ export { type BlockType, type SubconsciousBlock, ALL_BLOCK_TYPES, getBlock, getAllBlocks, updateBlock, getStaleBlocks, getBlockSummary, ensureBlocksExist, } from "./blocks.js";
17
+ export { type PromptClassification, type ClassificationResult, classifyPrompt, extractEntities, isTrivialPrompt, } from "./classifier.js";
18
+ export { type EntityType, type RelationType, type GraphEntity, type GraphEdge, type TraversalResult, upsertEntity, findEntity, searchEntities, resolveEntity, addEdge, traverseGraph, findContradictions, traceLineage, getGraphSummary, } from "./graphEngine.js";
19
+ export { type SubconsciousMode, type WhisperResult, generateWhisper, } from "./whisperPolicy.js";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * NodeBench Subconscious — background intelligence agent.
3
+ *
4
+ * Watches founder/coding sessions, maintains company truth memory blocks,
5
+ * builds a knowledge graph of entities + relationships, and whispers
6
+ * packet-aware guidance back into Claude Code and NodeBench surfaces.
7
+ *
8
+ * Architecture:
9
+ * - 12 typed memory blocks (blocks.ts)
10
+ * - Prompt classifier (classifier.ts)
11
+ * - Knowledge graph on existing object_nodes + object_edges (graphEngine.ts)
12
+ * - Whisper policy with suppression rules (whisperPolicy.ts)
13
+ * - 10 MCP tools (tools.ts)
14
+ */
15
+ export { subconsciousTools } from "./tools.js";
16
+ export { ALL_BLOCK_TYPES, getBlock, getAllBlocks, updateBlock, getStaleBlocks, getBlockSummary, ensureBlocksExist, } from "./blocks.js";
17
+ export { classifyPrompt, extractEntities, isTrivialPrompt, } from "./classifier.js";
18
+ export { upsertEntity, findEntity, searchEntities, resolveEntity, addEdge, traverseGraph, findContradictions, traceLineage, getGraphSummary, } from "./graphEngine.js";
19
+ export { generateWhisper, } from "./whisperPolicy.js";
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/subconscious/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAGL,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,cAAc,EACd,eAAe,EACf,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EAGL,cAAc,EACd,eAAe,EACf,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAML,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,OAAO,EACP,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAGL,eAAe,GAChB,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Subconscious MCP Tools — 10 tools for querying subconscious state + graph.
3
+ */
4
+ import type { McpTool } from "../types.js";
5
+ export declare const subconsciousTools: McpTool[];
@@ -0,0 +1,255 @@
1
+ /**
2
+ * Subconscious MCP Tools — 10 tools for querying subconscious state + graph.
3
+ */
4
+ import { getAllBlocks, getBlock, updateBlock, getStaleBlocks, getBlockSummary, ALL_BLOCK_TYPES, } from "./blocks.js";
5
+ import { generateWhisper } from "./whisperPolicy.js";
6
+ import { traverseGraph, findContradictions, traceLineage, resolveEntity, getGraphSummary, } from "./graphEngine.js";
7
+ export const subconsciousTools = [
8
+ // ── Block Tools ────────────────────────────────────────────────────────
9
+ {
10
+ name: "get_company_truth",
11
+ description: "Get current canonical company truth from subconscious memory blocks. " +
12
+ "Returns all populated blocks or specific ones by ID. " +
13
+ "Block types: founder_identity, company_identity, current_wedge, top_priorities, " +
14
+ "open_contradictions, readiness_gaps, validated_workflows, recent_important_changes, " +
15
+ "entity_watchlist, agent_preferences, artifact_preferences, packet_lineage.",
16
+ inputSchema: {
17
+ type: "object",
18
+ properties: {
19
+ blocks: {
20
+ type: "array",
21
+ items: { type: "string" },
22
+ description: "Specific block IDs to retrieve. Omit for all blocks.",
23
+ },
24
+ },
25
+ },
26
+ handler: async (args) => {
27
+ if (args.blocks && args.blocks.length > 0) {
28
+ const validIds = args.blocks.filter((b) => ALL_BLOCK_TYPES.includes(b));
29
+ const blocks = validIds.map(getBlock);
30
+ return { blocks };
31
+ }
32
+ return { blocks: getAllBlocks().filter((b) => b.value.length > 0) };
33
+ },
34
+ },
35
+ {
36
+ name: "update_company_truth",
37
+ description: "Update a subconscious memory block with new information. " +
38
+ "Use when the user states company facts, changes direction, or corrects assumptions.",
39
+ inputSchema: {
40
+ type: "object",
41
+ properties: {
42
+ block_id: {
43
+ type: "string",
44
+ description: "Block ID to update (e.g. 'current_wedge', 'company_identity')",
45
+ },
46
+ value: { type: "string", description: "New block content (markdown)" },
47
+ confidence: {
48
+ type: "string",
49
+ enum: ["high", "medium", "low"],
50
+ description: "Confidence level. Default: medium.",
51
+ },
52
+ },
53
+ required: ["block_id", "value"],
54
+ },
55
+ handler: async (args) => {
56
+ if (!ALL_BLOCK_TYPES.includes(args.block_id)) {
57
+ return { error: `Invalid block_id. Valid: ${ALL_BLOCK_TYPES.join(", ")}` };
58
+ }
59
+ const updated = updateBlock(args.block_id, {
60
+ value: args.value,
61
+ confidence: args.confidence ?? "medium",
62
+ sourceEvent: `manual_update_${Date.now()}`,
63
+ });
64
+ return { updated };
65
+ },
66
+ },
67
+ {
68
+ name: "get_subconscious_hint",
69
+ description: "Get the subconscious's current guidance for a task. " +
70
+ "Classifies the prompt, selects relevant memory blocks, checks for " +
71
+ "contradictions and stale packets, and generates a whisper.",
72
+ inputSchema: {
73
+ type: "object",
74
+ properties: {
75
+ task: { type: "string", description: "Description of the current task" },
76
+ mode: {
77
+ type: "string",
78
+ enum: ["whisper", "packet", "full"],
79
+ description: "Injection verbosity. Default: whisper.",
80
+ },
81
+ session_id: {
82
+ type: "string",
83
+ description: "Session ID for dedup tracking. Default: anonymous.",
84
+ },
85
+ },
86
+ required: ["task"],
87
+ },
88
+ handler: async (args) => {
89
+ const result = generateWhisper(args.task, args.session_id ?? "anonymous", args.mode ?? "whisper");
90
+ return {
91
+ classification: result.classification.classification,
92
+ confidence: result.classification.confidence,
93
+ entities: result.classification.entities,
94
+ whisper: result.whisperText,
95
+ suppressed: result.suppressed,
96
+ suppressionReason: result.suppressionReason,
97
+ contradictions: result.contradictions,
98
+ stalePackets: result.stalePackets,
99
+ blocksUsed: result.blockIdsUsed,
100
+ };
101
+ },
102
+ },
103
+ {
104
+ name: "list_contradictions",
105
+ description: "List all open contradictions between memory blocks and graph entities.",
106
+ inputSchema: { type: "object", properties: {} },
107
+ handler: async () => {
108
+ const block = getBlock("open_contradictions");
109
+ return {
110
+ blockContent: block.value || "(no contradictions recorded)",
111
+ version: block.version,
112
+ confidence: block.confidence,
113
+ updatedAt: block.updatedAt,
114
+ };
115
+ },
116
+ },
117
+ {
118
+ name: "list_stale_packets",
119
+ description: "List memory blocks and packets that need refresh.",
120
+ inputSchema: {
121
+ type: "object",
122
+ properties: {
123
+ max_age_days: {
124
+ type: "number",
125
+ description: "Max age in days before a block is considered stale. Default: 7.",
126
+ },
127
+ },
128
+ },
129
+ handler: async (args) => {
130
+ const stale = getStaleBlocks(args.max_age_days ?? 7);
131
+ return {
132
+ staleCount: stale.length,
133
+ staleBlocks: stale.map((b) => ({
134
+ id: b.id,
135
+ label: b.label,
136
+ lastUpdated: b.updatedAt,
137
+ version: b.version,
138
+ })),
139
+ };
140
+ },
141
+ },
142
+ {
143
+ name: "refresh_subconscious",
144
+ description: "Get a summary of all subconscious memory blocks and their status.",
145
+ inputSchema: { type: "object", properties: {} },
146
+ handler: async () => {
147
+ return {
148
+ summary: getBlockSummary(),
149
+ staleCount: getStaleBlocks(7).length,
150
+ totalBlocks: ALL_BLOCK_TYPES.length,
151
+ populatedBlocks: getAllBlocks().filter((b) => b.value.length > 0).length,
152
+ };
153
+ },
154
+ },
155
+ // ── Graph Tools ────────────────────────────────────────────────────────
156
+ {
157
+ name: "traverse_entity_graph",
158
+ description: "Find all entities and relationships connected to a starting entity within N hops. " +
159
+ "Uses BFS traversal on the knowledge graph.",
160
+ inputSchema: {
161
+ type: "object",
162
+ properties: {
163
+ entity: { type: "string", description: "Entity name or ID to start from" },
164
+ max_depth: {
165
+ type: "number",
166
+ description: "Max traversal depth (1-3). Default: 2.",
167
+ },
168
+ relation_filter: {
169
+ type: "array",
170
+ items: { type: "string" },
171
+ description: "Filter by relation type (e.g. ['contradicts', 'supports']). Omit for all.",
172
+ },
173
+ },
174
+ required: ["entity"],
175
+ },
176
+ handler: async (args) => {
177
+ const resolved = resolveEntity(args.entity);
178
+ if (!resolved)
179
+ return { error: `Entity not found: ${args.entity}` };
180
+ const results = traverseGraph(resolved.id, Math.min(args.max_depth ?? 2, 3), args.relation_filter);
181
+ return {
182
+ startEntity: { id: resolved.id, label: resolved.label, kind: resolved.kind },
183
+ connected: results.map((r) => ({
184
+ entity: { id: r.entity.id, label: r.entity.label, kind: r.entity.kind },
185
+ hopDistance: r.hopDistance,
186
+ reachedVia: r.reachedVia,
187
+ confidence: r.confidence,
188
+ pathLength: r.path.length,
189
+ })),
190
+ totalResults: results.length,
191
+ };
192
+ },
193
+ },
194
+ {
195
+ name: "find_contradictions_for",
196
+ description: "Find all entities that contradict a given entity or concept.",
197
+ inputSchema: {
198
+ type: "object",
199
+ properties: {
200
+ entity: { type: "string", description: "Entity name or ID" },
201
+ },
202
+ required: ["entity"],
203
+ },
204
+ handler: async (args) => {
205
+ const resolved = resolveEntity(args.entity);
206
+ if (!resolved)
207
+ return { error: `Entity not found: ${args.entity}` };
208
+ const contradictions = findContradictions(resolved.id, 2);
209
+ return {
210
+ entity: { id: resolved.id, label: resolved.label, kind: resolved.kind },
211
+ contradictions: contradictions.map((c) => ({
212
+ entity: { id: c.entity.id, label: c.entity.label, kind: c.entity.kind },
213
+ confidence: c.confidence,
214
+ hopDistance: c.hopDistance,
215
+ })),
216
+ };
217
+ },
218
+ },
219
+ {
220
+ name: "get_packet_lineage",
221
+ description: "Trace the full derivation chain for a packet or entity.",
222
+ inputSchema: {
223
+ type: "object",
224
+ properties: {
225
+ entity: { type: "string", description: "Packet or entity name/ID" },
226
+ max_depth: { type: "number", description: "Max chain depth. Default: 5." },
227
+ },
228
+ required: ["entity"],
229
+ },
230
+ handler: async (args) => {
231
+ const resolved = resolveEntity(args.entity);
232
+ if (!resolved)
233
+ return { error: `Entity not found: ${args.entity}` };
234
+ const lineage = traceLineage(resolved.id, args.max_depth ?? 5);
235
+ return {
236
+ entity: { id: resolved.id, label: resolved.label, kind: resolved.kind },
237
+ lineage: lineage.map((l) => ({
238
+ entity: { id: l.entity.id, label: l.entity.label, kind: l.entity.kind },
239
+ relation: l.reachedVia,
240
+ hopDistance: l.hopDistance,
241
+ confidence: l.confidence,
242
+ })),
243
+ };
244
+ },
245
+ },
246
+ {
247
+ name: "get_entity_graph_summary",
248
+ description: "Get a summary of the knowledge graph: entity counts by type, edge counts by relation, recent additions.",
249
+ inputSchema: { type: "object", properties: {} },
250
+ handler: async () => {
251
+ return getGraphSummary();
252
+ },
253
+ },
254
+ ];
255
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/subconscious/tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACL,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EACnD,eAAe,EAAqC,eAAe,GACpE,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,eAAe,EAAyB,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EACL,aAAa,EAAE,kBAAkB,EAAE,YAAY,EAC/C,aAAa,EAAkB,eAAe,GAE/C,MAAM,kBAAkB,CAAC;AAE1B,MAAM,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**
2
+ * Whisper Policy — decides what to inject and what to suppress.
3
+ *
4
+ * Suppression-first: default is NO whisper unless high-value signal.
5
+ * Classification-driven: prompt type determines which blocks to inject.
6
+ */
7
+ import { type BlockType } from "./blocks.js";
8
+ import { type ClassificationResult } from "./classifier.js";
9
+ export type SubconsciousMode = "off" | "whisper" | "packet" | "full" | "review";
10
+ export interface WhisperResult {
11
+ mode: SubconsciousMode;
12
+ classification: ClassificationResult;
13
+ whisperText: string;
14
+ suppressed: boolean;
15
+ suppressionReason: string | null;
16
+ blockIdsUsed: BlockType[];
17
+ contradictions: string[];
18
+ stalePackets: string[];
19
+ }
20
+ export declare function generateWhisper(prompt: string, sessionId: string, mode?: SubconsciousMode): WhisperResult;