@timmeck/marketing-brain 0.2.1 → 0.3.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 (123) hide show
  1. package/dist/cli/colors.d.ts +11 -24
  2. package/dist/cli/colors.js +3 -46
  3. package/dist/cli/colors.js.map +1 -1
  4. package/dist/cli/commands/peers.d.ts +2 -0
  5. package/dist/cli/commands/peers.js +38 -0
  6. package/dist/cli/commands/peers.js.map +1 -0
  7. package/dist/db/connection.d.ts +1 -2
  8. package/dist/db/connection.js +1 -18
  9. package/dist/db/connection.js.map +1 -1
  10. package/dist/hooks/post-tool-use.d.ts +2 -0
  11. package/dist/hooks/post-tool-use.js +182 -0
  12. package/dist/hooks/post-tool-use.js.map +1 -0
  13. package/dist/index.js +2 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/ipc/client.d.ts +1 -13
  16. package/dist/ipc/client.js +1 -92
  17. package/dist/ipc/client.js.map +1 -1
  18. package/dist/ipc/protocol.d.ts +1 -8
  19. package/dist/ipc/protocol.js +1 -28
  20. package/dist/ipc/protocol.js.map +1 -1
  21. package/dist/ipc/router.js +8 -0
  22. package/dist/ipc/router.js.map +1 -1
  23. package/dist/ipc/server.d.ts +1 -14
  24. package/dist/ipc/server.js +1 -129
  25. package/dist/ipc/server.js.map +1 -1
  26. package/dist/marketing-core.d.ts +1 -0
  27. package/dist/marketing-core.js +6 -1
  28. package/dist/marketing-core.js.map +1 -1
  29. package/dist/mcp/server.js +5 -60
  30. package/dist/mcp/server.js.map +1 -1
  31. package/dist/types/ipc.types.d.ts +1 -11
  32. package/dist/utils/events.d.ts +4 -8
  33. package/dist/utils/events.js +2 -14
  34. package/dist/utils/events.js.map +1 -1
  35. package/dist/utils/hash.d.ts +1 -1
  36. package/dist/utils/hash.js +1 -4
  37. package/dist/utils/hash.js.map +1 -1
  38. package/dist/utils/logger.d.ts +3 -2
  39. package/dist/utils/logger.js +8 -35
  40. package/dist/utils/logger.js.map +1 -1
  41. package/dist/utils/paths.d.ts +2 -1
  42. package/dist/utils/paths.js +4 -13
  43. package/dist/utils/paths.js.map +1 -1
  44. package/package.json +2 -1
  45. package/.github/FUNDING.yml +0 -1
  46. package/.github/workflows/ci.yml +0 -27
  47. package/.mcp.json +0 -9
  48. package/src/api/server.ts +0 -86
  49. package/src/cli/colors.ts +0 -59
  50. package/src/cli/commands/campaign.ts +0 -66
  51. package/src/cli/commands/config.ts +0 -168
  52. package/src/cli/commands/dashboard.ts +0 -165
  53. package/src/cli/commands/doctor.ts +0 -110
  54. package/src/cli/commands/export.ts +0 -40
  55. package/src/cli/commands/import.ts +0 -84
  56. package/src/cli/commands/insights.ts +0 -44
  57. package/src/cli/commands/learn.ts +0 -24
  58. package/src/cli/commands/network.ts +0 -71
  59. package/src/cli/commands/post.ts +0 -47
  60. package/src/cli/commands/query.ts +0 -108
  61. package/src/cli/commands/rules.ts +0 -27
  62. package/src/cli/commands/start.ts +0 -100
  63. package/src/cli/commands/status.ts +0 -73
  64. package/src/cli/commands/stop.ts +0 -33
  65. package/src/cli/commands/suggest.ts +0 -64
  66. package/src/cli/ipc-helper.ts +0 -22
  67. package/src/cli/update-check.ts +0 -63
  68. package/src/config.ts +0 -110
  69. package/src/dashboard/renderer.ts +0 -136
  70. package/src/dashboard/server.ts +0 -140
  71. package/src/db/connection.ts +0 -22
  72. package/src/db/migrations/001_core_schema.ts +0 -63
  73. package/src/db/migrations/002_learning_schema.ts +0 -46
  74. package/src/db/migrations/003_synapse_schema.ts +0 -27
  75. package/src/db/migrations/004_insights_schema.ts +0 -38
  76. package/src/db/migrations/005_fts_indexes.ts +0 -77
  77. package/src/db/migrations/index.ts +0 -62
  78. package/src/db/repositories/audience.repository.ts +0 -53
  79. package/src/db/repositories/campaign.repository.ts +0 -72
  80. package/src/db/repositories/engagement.repository.ts +0 -108
  81. package/src/db/repositories/insight.repository.ts +0 -100
  82. package/src/db/repositories/post.repository.ts +0 -123
  83. package/src/db/repositories/rule.repository.ts +0 -87
  84. package/src/db/repositories/strategy.repository.ts +0 -82
  85. package/src/db/repositories/synapse.repository.ts +0 -148
  86. package/src/db/repositories/template.repository.ts +0 -76
  87. package/src/index.ts +0 -69
  88. package/src/ipc/__tests__/protocol.test.ts +0 -153
  89. package/src/ipc/client.ts +0 -110
  90. package/src/ipc/protocol.ts +0 -35
  91. package/src/ipc/router.ts +0 -126
  92. package/src/ipc/server.ts +0 -140
  93. package/src/learning/confidence-scorer.ts +0 -36
  94. package/src/learning/learning-engine.ts +0 -254
  95. package/src/marketing-core.ts +0 -285
  96. package/src/mcp/server.ts +0 -72
  97. package/src/mcp/tools.ts +0 -216
  98. package/src/research/research-engine.ts +0 -226
  99. package/src/services/analytics.service.ts +0 -73
  100. package/src/services/audience.service.ts +0 -40
  101. package/src/services/campaign.service.ts +0 -80
  102. package/src/services/insight.service.ts +0 -54
  103. package/src/services/post.service.ts +0 -116
  104. package/src/services/rule.service.ts +0 -90
  105. package/src/services/strategy.service.ts +0 -53
  106. package/src/services/synapse.service.ts +0 -32
  107. package/src/services/template.service.ts +0 -50
  108. package/src/synapses/activation.ts +0 -80
  109. package/src/synapses/decay.ts +0 -38
  110. package/src/synapses/hebbian.ts +0 -68
  111. package/src/synapses/pathfinder.ts +0 -81
  112. package/src/synapses/synapse-manager.ts +0 -115
  113. package/src/types/config.types.ts +0 -79
  114. package/src/types/ipc.types.ts +0 -8
  115. package/src/types/post.types.ts +0 -156
  116. package/src/types/synapse.types.ts +0 -43
  117. package/src/utils/__tests__/hash.test.ts +0 -39
  118. package/src/utils/__tests__/paths.test.ts +0 -70
  119. package/src/utils/events.ts +0 -44
  120. package/src/utils/hash.ts +0 -5
  121. package/src/utils/logger.ts +0 -48
  122. package/src/utils/paths.ts +0 -19
  123. package/tsconfig.json +0 -18
@@ -1,53 +0,0 @@
1
- import type { StrategyRepository } from '../db/repositories/strategy.repository.js';
2
- import type { SynapseManager } from '../synapses/synapse-manager.js';
3
- import type { Strategy, StrategyCreate } from '../types/post.types.js';
4
- import { getEventBus } from '../utils/events.js';
5
-
6
- export class StrategyService {
7
- constructor(
8
- private strategyRepo: StrategyRepository,
9
- private synapseManager: SynapseManager,
10
- ) {}
11
-
12
- report(data: StrategyCreate): Strategy {
13
- const id = this.strategyRepo.create(data);
14
- const strategy = this.strategyRepo.getById(id)!;
15
-
16
- if (data.post_id) {
17
- this.synapseManager.strengthen(
18
- { type: 'strategy', id },
19
- { type: 'post', id: data.post_id },
20
- 'improves',
21
- );
22
- getEventBus().emit('strategy:reported', { strategyId: id, postId: data.post_id });
23
- }
24
-
25
- return strategy;
26
- }
27
-
28
- suggest(query: string, limit: number = 5): Strategy[] {
29
- return this.strategyRepo.search(query, limit);
30
- }
31
-
32
- getTopStrategies(minConfidence: number = 0.7, limit: number = 10): Strategy[] {
33
- return this.strategyRepo.topByConfidence(minConfidence, limit);
34
- }
35
-
36
- getById(id: number): Strategy | undefined {
37
- return this.strategyRepo.getById(id);
38
- }
39
-
40
- listAll(limit?: number): Strategy[] {
41
- return this.strategyRepo.listAll(limit);
42
- }
43
-
44
- updateConfidence(id: number, confidence: number): void {
45
- this.strategyRepo.update(id, { confidence });
46
- }
47
-
48
- getStats() {
49
- return {
50
- total: this.strategyRepo.countAll(),
51
- };
52
- }
53
- }
@@ -1,32 +0,0 @@
1
- import type { SynapseManager } from '../synapses/synapse-manager.js';
2
- import type { NodeType } from '../types/synapse.types.js';
3
-
4
- export class SynapseService {
5
- constructor(private synapseManager: SynapseManager) {}
6
-
7
- getPostContext(postId: number) {
8
- return this.synapseManager.getPostContext(postId);
9
- }
10
-
11
- findPath(fromType: NodeType, fromId: number, toType: NodeType, toId: number) {
12
- return this.synapseManager.findPath(
13
- { type: fromType, id: fromId },
14
- { type: toType, id: toId },
15
- );
16
- }
17
-
18
- getRelated(opts: { nodeType: NodeType; nodeId: number; maxDepth?: number }) {
19
- return this.synapseManager.activate(
20
- { type: opts.nodeType, id: opts.nodeId },
21
- opts.maxDepth,
22
- );
23
- }
24
-
25
- getNetworkStats() {
26
- return this.synapseManager.getNetworkStats();
27
- }
28
-
29
- getStrongest(limit?: number) {
30
- return this.synapseManager.getStrongestSynapses(limit);
31
- }
32
- }
@@ -1,50 +0,0 @@
1
- import type { TemplateRepository } from '../db/repositories/template.repository.js';
2
- import type { SynapseManager } from '../synapses/synapse-manager.js';
3
- import type { ContentTemplate, ContentTemplateCreate } from '../types/post.types.js';
4
- import { getEventBus } from '../utils/events.js';
5
-
6
- export class TemplateService {
7
- constructor(
8
- private templateRepo: TemplateRepository,
9
- private synapseManager: SynapseManager,
10
- ) {}
11
-
12
- create(data: ContentTemplateCreate): ContentTemplate {
13
- const id = this.templateRepo.create(data);
14
- const template = this.templateRepo.getById(id)!;
15
-
16
- getEventBus().emit('template:created', { templateId: id, platform: data.platform ?? 'any' });
17
- return template;
18
- }
19
-
20
- find(query: string, limit: number = 5): ContentTemplate[] {
21
- return this.templateRepo.search(query, limit);
22
- }
23
-
24
- findByPlatform(platform: string, limit: number = 10): ContentTemplate[] {
25
- return this.templateRepo.listByPlatform(platform, limit);
26
- }
27
-
28
- useTemplate(templateId: number, postId: number): void {
29
- this.templateRepo.incrementUseCount(templateId);
30
- this.synapseManager.strengthen(
31
- { type: 'template', id: templateId },
32
- { type: 'post', id: postId },
33
- 'generated_from',
34
- );
35
- }
36
-
37
- getById(id: number): ContentTemplate | undefined {
38
- return this.templateRepo.getById(id);
39
- }
40
-
41
- listAll(limit?: number): ContentTemplate[] {
42
- return this.templateRepo.listAll(limit);
43
- }
44
-
45
- getStats() {
46
- return {
47
- total: this.templateRepo.countAll(),
48
- };
49
- }
50
- }
@@ -1,80 +0,0 @@
1
- import type { NodeType } from '../types/synapse.types.js';
2
- import type { SynapseRepository } from '../db/repositories/synapse.repository.js';
3
-
4
- export interface ActivationNode {
5
- type: NodeType;
6
- id: number;
7
- }
8
-
9
- export interface ActivationResult {
10
- node: ActivationNode;
11
- activation: number;
12
- depth: number;
13
- path: string[];
14
- }
15
-
16
- export function spreadingActivation(
17
- repo: SynapseRepository,
18
- startNode: ActivationNode,
19
- maxDepth: number = 3,
20
- minWeight: number = 0.2,
21
- ): ActivationResult[] {
22
- const visited = new Set<string>();
23
- const results: ActivationResult[] = [];
24
-
25
- const queue: Array<{
26
- node: ActivationNode;
27
- depth: number;
28
- pathWeight: number;
29
- path: string[];
30
- }> = [{ node: startNode, depth: 0, pathWeight: 1.0, path: [] }];
31
-
32
- while (queue.length > 0) {
33
- const current = queue.shift()!;
34
- const key = `${current.node.type}:${current.node.id}`;
35
-
36
- if (visited.has(key)) continue;
37
- if (current.depth > maxDepth) continue;
38
- if (current.pathWeight < minWeight) continue;
39
-
40
- visited.add(key);
41
-
42
- if (current.depth > 0) {
43
- results.push({
44
- node: current.node,
45
- activation: current.pathWeight,
46
- depth: current.depth,
47
- path: current.path,
48
- });
49
- }
50
-
51
- const outgoing = repo.getOutgoing(current.node.type, current.node.id);
52
- const incoming = repo.getIncoming(current.node.type, current.node.id);
53
-
54
- for (const synapse of outgoing) {
55
- const nextWeight = current.pathWeight * synapse.weight;
56
- if (nextWeight >= minWeight) {
57
- queue.push({
58
- node: { type: synapse.target_type, id: synapse.target_id },
59
- depth: current.depth + 1,
60
- pathWeight: nextWeight,
61
- path: [...current.path, `--${synapse.synapse_type}-->`],
62
- });
63
- }
64
- }
65
-
66
- for (const synapse of incoming) {
67
- const nextWeight = current.pathWeight * synapse.weight;
68
- if (nextWeight >= minWeight) {
69
- queue.push({
70
- node: { type: synapse.source_type, id: synapse.source_id },
71
- depth: current.depth + 1,
72
- pathWeight: nextWeight,
73
- path: [...current.path, `<--${synapse.synapse_type}--`],
74
- });
75
- }
76
- }
77
- }
78
-
79
- return results.sort((a, b) => b.activation - a.activation);
80
- }
@@ -1,38 +0,0 @@
1
- import type { SynapseRepository } from '../db/repositories/synapse.repository.js';
2
-
3
- export interface DecayConfig {
4
- decayHalfLifeDays: number;
5
- decayAfterDays: number;
6
- pruneThreshold: number;
7
- }
8
-
9
- export function timeDecayFactor(lastActivatedAt: string, halfLifeDays: number): number {
10
- const now = Date.now();
11
- const activated = new Date(lastActivatedAt).getTime();
12
- const ageDays = (now - activated) / (1000 * 60 * 60 * 24);
13
- return Math.pow(0.5, ageDays / halfLifeDays);
14
- }
15
-
16
- export function decayAll(repo: SynapseRepository, config: DecayConfig): { decayed: number; pruned: number } {
17
- const cutoff = new Date();
18
- cutoff.setDate(cutoff.getDate() - config.decayAfterDays);
19
-
20
- const stale = repo.findInactiveSince(cutoff.toISOString());
21
- let pruned = 0;
22
- let decayed = 0;
23
-
24
- for (const synapse of stale) {
25
- const factor = timeDecayFactor(synapse.last_activated_at, config.decayHalfLifeDays);
26
- const newWeight = synapse.weight * factor;
27
-
28
- if (newWeight < config.pruneThreshold) {
29
- repo.delete(synapse.id);
30
- pruned++;
31
- } else {
32
- repo.update(synapse.id, { weight: newWeight });
33
- decayed++;
34
- }
35
- }
36
-
37
- return { decayed, pruned };
38
- }
@@ -1,68 +0,0 @@
1
- import type { SynapseRecord, NodeType, SynapseType } from '../types/synapse.types.js';
2
- import type { SynapseRepository } from '../db/repositories/synapse.repository.js';
3
-
4
- export interface HebbianConfig {
5
- initialWeight: number;
6
- learningRate: number;
7
- pruneThreshold: number;
8
- }
9
-
10
- export interface NodeRef {
11
- type: NodeType;
12
- id: number;
13
- }
14
-
15
- export function strengthen(
16
- repo: SynapseRepository,
17
- source: NodeRef,
18
- target: NodeRef,
19
- synapseType: SynapseType,
20
- config: HebbianConfig,
21
- context?: Record<string, unknown>,
22
- ): SynapseRecord {
23
- const existing = repo.findBySourceTarget(
24
- source.type, source.id, target.type, target.id, synapseType,
25
- );
26
-
27
- if (existing) {
28
- const newWeight = Math.min(
29
- 1.0,
30
- existing.weight + (1.0 - existing.weight) * config.learningRate,
31
- );
32
- repo.update(existing.id, {
33
- weight: newWeight,
34
- activation_count: existing.activation_count + 1,
35
- last_activated_at: new Date().toISOString(),
36
- });
37
- return { ...existing, weight: newWeight, activation_count: existing.activation_count + 1 };
38
- }
39
-
40
- const id = repo.create({
41
- source_type: source.type,
42
- source_id: source.id,
43
- target_type: target.type,
44
- target_id: target.id,
45
- synapse_type: synapseType,
46
- weight: config.initialWeight,
47
- metadata: context ? JSON.stringify(context) : null,
48
- });
49
-
50
- return repo.getById(id)!;
51
- }
52
-
53
- export function weaken(
54
- repo: SynapseRepository,
55
- synapseId: number,
56
- config: HebbianConfig,
57
- factor: number = 0.5,
58
- ): void {
59
- const synapse = repo.getById(synapseId);
60
- if (!synapse) return;
61
-
62
- const newWeight = synapse.weight * factor;
63
- if (newWeight < config.pruneThreshold) {
64
- repo.delete(synapseId);
65
- } else {
66
- repo.update(synapseId, { weight: newWeight });
67
- }
68
- }
@@ -1,81 +0,0 @@
1
- import type { NodeType, SynapseRecord } from '../types/synapse.types.js';
2
- import type { SynapseRepository } from '../db/repositories/synapse.repository.js';
3
-
4
- export interface PathNode {
5
- type: NodeType;
6
- id: number;
7
- }
8
-
9
- export interface SynapsePath {
10
- from: PathNode;
11
- to: PathNode;
12
- synapses: SynapseRecord[];
13
- totalWeight: number;
14
- hops: number;
15
- }
16
-
17
- export function findPath(
18
- repo: SynapseRepository,
19
- from: PathNode,
20
- to: PathNode,
21
- maxDepth: number = 5,
22
- ): SynapsePath | null {
23
- const visited = new Set<string>();
24
-
25
- const queue: Array<{
26
- node: PathNode;
27
- path: SynapseRecord[];
28
- totalWeight: number;
29
- }> = [{ node: from, path: [], totalWeight: 1.0 }];
30
-
31
- let bestPath: SynapsePath | null = null;
32
-
33
- while (queue.length > 0) {
34
- const current = queue.shift()!;
35
- const key = `${current.node.type}:${current.node.id}`;
36
-
37
- if (visited.has(key)) continue;
38
- visited.add(key);
39
-
40
- if (current.node.type === to.type && current.node.id === to.id) {
41
- if (!bestPath || current.totalWeight > bestPath.totalWeight) {
42
- bestPath = {
43
- from,
44
- to,
45
- synapses: current.path,
46
- totalWeight: current.totalWeight,
47
- hops: current.path.length,
48
- };
49
- }
50
- continue;
51
- }
52
-
53
- if (current.path.length >= maxDepth) continue;
54
-
55
- const outgoing = repo.getOutgoing(current.node.type, current.node.id);
56
- for (const synapse of outgoing) {
57
- const targetKey = `${synapse.target_type}:${synapse.target_id}`;
58
- if (!visited.has(targetKey)) {
59
- queue.push({
60
- node: { type: synapse.target_type, id: synapse.target_id },
61
- path: [...current.path, synapse],
62
- totalWeight: current.totalWeight * synapse.weight,
63
- });
64
- }
65
- }
66
-
67
- const incoming = repo.getIncoming(current.node.type, current.node.id);
68
- for (const synapse of incoming) {
69
- const sourceKey = `${synapse.source_type}:${synapse.source_id}`;
70
- if (!visited.has(sourceKey)) {
71
- queue.push({
72
- node: { type: synapse.source_type, id: synapse.source_id },
73
- path: [...current.path, synapse],
74
- totalWeight: current.totalWeight * synapse.weight,
75
- });
76
- }
77
- }
78
- }
79
-
80
- return bestPath;
81
- }
@@ -1,115 +0,0 @@
1
- import type { SynapsesConfig } from '../types/config.types.js';
2
- import type { NodeType, SynapseType, SynapseRecord, NetworkStats } from '../types/synapse.types.js';
3
- import type { SynapseRepository } from '../db/repositories/synapse.repository.js';
4
- import { strengthen, weaken, type NodeRef } from './hebbian.js';
5
- import { decayAll } from './decay.js';
6
- import { spreadingActivation, type ActivationResult } from './activation.js';
7
- import { findPath, type SynapsePath } from './pathfinder.js';
8
- import { getLogger } from '../utils/logger.js';
9
-
10
- export class SynapseManager {
11
- private logger = getLogger();
12
-
13
- constructor(
14
- private repo: SynapseRepository,
15
- private config: SynapsesConfig,
16
- ) {}
17
-
18
- strengthen(
19
- source: NodeRef,
20
- target: NodeRef,
21
- synapseType: SynapseType,
22
- context?: Record<string, unknown>,
23
- ): SynapseRecord {
24
- this.logger.debug(`Strengthening synapse ${source.type}:${source.id} --${synapseType}--> ${target.type}:${target.id}`);
25
- return strengthen(this.repo, source, target, synapseType, {
26
- initialWeight: this.config.initialWeight,
27
- learningRate: this.config.learningRate,
28
- pruneThreshold: this.config.pruneThreshold,
29
- }, context);
30
- }
31
-
32
- weaken(synapseId: number, factor: number = 0.5): void {
33
- this.logger.debug(`Weakening synapse ${synapseId} by factor ${factor}`);
34
- weaken(this.repo, synapseId, {
35
- initialWeight: this.config.initialWeight,
36
- learningRate: this.config.learningRate,
37
- pruneThreshold: this.config.pruneThreshold,
38
- }, factor);
39
- }
40
-
41
- find(
42
- source: NodeRef,
43
- target: NodeRef,
44
- synapseType: SynapseType,
45
- ): SynapseRecord | undefined {
46
- return this.repo.findBySourceTarget(
47
- source.type, source.id, target.type, target.id, synapseType,
48
- );
49
- }
50
-
51
- activate(
52
- startNode: NodeRef,
53
- maxDepth?: number,
54
- minWeight?: number,
55
- ): ActivationResult[] {
56
- return spreadingActivation(
57
- this.repo,
58
- startNode,
59
- maxDepth ?? this.config.maxDepth,
60
- minWeight ?? this.config.minActivationWeight,
61
- );
62
- }
63
-
64
- findPath(from: NodeRef, to: NodeRef, maxDepth?: number): SynapsePath | null {
65
- return findPath(this.repo, from, to, maxDepth ?? this.config.maxDepth + 2);
66
- }
67
-
68
- runDecay(): { decayed: number; pruned: number } {
69
- this.logger.info('Running synapse decay cycle');
70
- const result = decayAll(this.repo, {
71
- decayHalfLifeDays: this.config.decayHalfLifeDays,
72
- decayAfterDays: this.config.decayAfterDays,
73
- pruneThreshold: this.config.pruneThreshold,
74
- });
75
- this.logger.info(`Decay complete: ${result.decayed} decayed, ${result.pruned} pruned`);
76
- return result;
77
- }
78
-
79
- getPostContext(postId: number): {
80
- campaigns: ActivationResult[];
81
- similarPosts: ActivationResult[];
82
- strategies: ActivationResult[];
83
- rules: ActivationResult[];
84
- templates: ActivationResult[];
85
- insights: ActivationResult[];
86
- } {
87
- const all = this.activate({ type: 'post', id: postId });
88
- return {
89
- campaigns: all.filter(a => a.node.type === 'campaign'),
90
- similarPosts: all.filter(a => a.node.type === 'post'),
91
- strategies: all.filter(a => a.node.type === 'strategy'),
92
- rules: all.filter(a => a.node.type === 'rule'),
93
- templates: all.filter(a => a.node.type === 'template'),
94
- insights: all.filter(a => a.node.type === 'insight'),
95
- };
96
- }
97
-
98
- getStrongestSynapses(limit: number = 20): SynapseRecord[] {
99
- return this.repo.topByWeight(limit);
100
- }
101
-
102
- getDiverseSynapses(perType: number = 25): SynapseRecord[] {
103
- return this.repo.topDiverse(perType);
104
- }
105
-
106
- getNetworkStats(): NetworkStats {
107
- return {
108
- totalNodes: this.repo.countNodes(),
109
- totalSynapses: this.repo.totalCount(),
110
- avgWeight: this.repo.avgWeight(),
111
- nodesByType: {} as Record<NodeType, number>,
112
- synapsesByType: this.repo.countByType() as Record<SynapseType, number>,
113
- };
114
- }
115
- }
@@ -1,79 +0,0 @@
1
- export interface IpcConfig {
2
- pipeName: string;
3
- timeout: number;
4
- }
5
-
6
- export interface LearningConfig {
7
- intervalMs: number;
8
- minOccurrences: number;
9
- minConfidence: number;
10
- pruneThreshold: number;
11
- decayHalfLifeDays: number;
12
- }
13
-
14
- export interface SynapsesConfig {
15
- initialWeight: number;
16
- learningRate: number;
17
- decayHalfLifeDays: number;
18
- pruneThreshold: number;
19
- decayAfterDays: number;
20
- maxDepth: number;
21
- minActivationWeight: number;
22
- }
23
-
24
- export interface ResearchConfig {
25
- intervalMs: number;
26
- initialDelayMs: number;
27
- minDataPoints: number;
28
- trendWindowDays: number;
29
- insightExpiryDays: number;
30
- }
31
-
32
- export interface MatchingConfig {
33
- similarityThreshold: number;
34
- maxResults: number;
35
- }
36
-
37
- export interface ApiConfig {
38
- port: number;
39
- enabled: boolean;
40
- apiKey?: string;
41
- }
42
-
43
- export interface McpHttpConfig {
44
- port: number;
45
- enabled: boolean;
46
- }
47
-
48
- export interface DashboardConfig {
49
- port: number;
50
- enabled: boolean;
51
- }
52
-
53
- export interface LogConfig {
54
- level: string;
55
- file: string;
56
- maxSize: number;
57
- maxFiles: number;
58
- }
59
-
60
- export interface RetentionConfig {
61
- postDays: number;
62
- strategyDays: number;
63
- insightDays: number;
64
- }
65
-
66
- export interface MarketingBrainConfig {
67
- dataDir: string;
68
- dbPath: string;
69
- ipc: IpcConfig;
70
- api: ApiConfig;
71
- mcpHttp: McpHttpConfig;
72
- dashboard: DashboardConfig;
73
- learning: LearningConfig;
74
- matching: MatchingConfig;
75
- synapses: SynapsesConfig;
76
- research: ResearchConfig;
77
- log: LogConfig;
78
- retention: RetentionConfig;
79
- }
@@ -1,8 +0,0 @@
1
- export interface IpcMessage {
2
- id: string;
3
- type: 'request' | 'response' | 'notification';
4
- method?: string;
5
- params?: unknown;
6
- result?: unknown;
7
- error?: { code: number; message: string };
8
- }