genesis-ai-cli 11.1.0 → 11.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.
@@ -450,6 +450,85 @@ class Daemon {
450
450
  tags: ['system', 'self-improvement', 'autopoiesis'],
451
451
  });
452
452
  }
453
+ // v11.1: Competitive Intelligence scan
454
+ if (this.config.competitiveIntel?.enabled && this.config.competitiveIntel.competitors.length > 0) {
455
+ this.scheduler.schedule({
456
+ name: 'compintel-scan',
457
+ description: 'Competitive Intelligence: scan competitors and generate insights',
458
+ schedule: { type: 'interval', intervalMs: this.config.competitiveIntel.checkIntervalMs },
459
+ priority: 'normal',
460
+ timeout: 120000, // 2 minutes max per scan
461
+ handler: async (ctx) => {
462
+ ctx.logger.info('Running CompIntel scan...');
463
+ const startTime = Date.now();
464
+ try {
465
+ const { createCompetitiveIntelService } = await import('../services/competitive-intel.js');
466
+ const { createRevenueLoop } = await import('../services/revenue-loop.js');
467
+ const ciConfig = this.config.competitiveIntel;
468
+ // Check subscription if required
469
+ if (ciConfig.requireSubscription && ciConfig.customerId) {
470
+ const revenueLoop = createRevenueLoop();
471
+ const sub = await revenueLoop.checkSubscription(ciConfig.customerId);
472
+ if (!sub.valid) {
473
+ ctx.logger.warn(`CompIntel scan skipped: ${sub.reason}`);
474
+ return {
475
+ success: true,
476
+ duration: Date.now() - startTime,
477
+ output: { skipped: true, reason: sub.reason },
478
+ };
479
+ }
480
+ ctx.logger.info(`Subscription valid: plan=${sub.plan}, competitors=${sub.maxCompetitors}`);
481
+ }
482
+ // Run scan
483
+ const service = createCompetitiveIntelService({
484
+ competitors: ciConfig.competitors,
485
+ });
486
+ const changes = await service.checkAll();
487
+ ctx.logger.info(`Scan complete: ${changes.length} changes detected`);
488
+ // Generate digest if changes found
489
+ let digest;
490
+ if (changes.length > 0) {
491
+ digest = await service.generateDigest(24);
492
+ ctx.logger.info(`Digest: ${digest.keyInsights.length} insights, ${digest.recommendations.length} recommendations`);
493
+ // Emit event for downstream consumers
494
+ this.emit({
495
+ type: 'task_completed',
496
+ timestamp: new Date(),
497
+ data: {
498
+ task: 'compintel-scan',
499
+ changes: changes.length,
500
+ insights: digest.keyInsights,
501
+ recommendations: digest.recommendations,
502
+ },
503
+ });
504
+ }
505
+ return {
506
+ success: true,
507
+ duration: Date.now() - startTime,
508
+ output: {
509
+ competitors: ciConfig.competitors.length,
510
+ changes: changes.length,
511
+ digest: digest ? {
512
+ insights: digest.keyInsights.length,
513
+ recommendations: digest.recommendations.length,
514
+ } : null,
515
+ },
516
+ };
517
+ }
518
+ catch (err) {
519
+ const error = err instanceof Error ? err : new Error(String(err));
520
+ ctx.logger.error(`CompIntel scan failed: ${error.message}`);
521
+ return {
522
+ success: false,
523
+ duration: Date.now() - startTime,
524
+ error,
525
+ };
526
+ }
527
+ },
528
+ tags: ['revenue', 'compintel', 'scan'],
529
+ });
530
+ this.log(`CompIntel daemon: monitoring ${this.config.competitiveIntel.competitors.length} competitors every ${(this.config.competitiveIntel.checkIntervalMs / 3600000).toFixed(1)}h`);
531
+ }
453
532
  }
454
533
  buildMaintenanceContext() {
455
534
  return {
@@ -194,6 +194,18 @@ export interface SelfImprovementDaemonConfig {
194
194
  minPhiThreshold: number;
195
195
  maxImprovementsPerCycle: number;
196
196
  }
197
+ export interface CompIntelDaemonConfig {
198
+ enabled: boolean;
199
+ checkIntervalMs: number;
200
+ digestIntervalMs: number;
201
+ competitors: Array<{
202
+ name: string;
203
+ domain: string;
204
+ pages?: string[];
205
+ }>;
206
+ requireSubscription: boolean;
207
+ customerId?: string;
208
+ }
197
209
  export interface DaemonConfig {
198
210
  enabled: boolean;
199
211
  heartbeatIntervalMs: number;
@@ -207,6 +219,7 @@ export interface DaemonConfig {
207
219
  maintenance: MaintenanceConfig;
208
220
  dream: DreamConfig;
209
221
  selfImprovement: SelfImprovementDaemonConfig;
222
+ competitiveIntel: CompIntelDaemonConfig;
210
223
  logLevel: 'debug' | 'info' | 'warn' | 'error';
211
224
  logToFile: boolean;
212
225
  logFilePath?: string;
@@ -53,6 +53,14 @@ exports.DEFAULT_DAEMON_CONFIG = {
53
53
  minPhiThreshold: 0.3, // Require consciousness
54
54
  maxImprovementsPerCycle: 3, // Conservative default
55
55
  },
56
+ // v11.1: Competitive Intelligence
57
+ competitiveIntel: {
58
+ enabled: false, // Opt-in (needs competitors configured)
59
+ checkIntervalMs: 6 * 60 * 60 * 1000, // 6 hours
60
+ digestIntervalMs: 24 * 60 * 60 * 1000, // 24 hours
61
+ competitors: [],
62
+ requireSubscription: false, // Free by default (set true for paid mode)
63
+ },
56
64
  logLevel: 'info',
57
65
  logToFile: false,
58
66
  };
@@ -69,6 +69,7 @@ export declare class GenesisMCPServer extends EventEmitter {
69
69
  private matchesPattern;
70
70
  private getDefaultAuthContext;
71
71
  private registerDefaultTools;
72
+ private registerCompIntelTools;
72
73
  registerTool(config: ExposedToolConfig): void;
73
74
  registerResource(config: ExposedResourceConfig): void;
74
75
  registerPrompt(config: ExposedPromptConfig): void;
@@ -353,6 +353,7 @@ class GenesisMCPServer extends events_1.EventEmitter {
353
353
  this.metering = new MeteringService(this.config.metering);
354
354
  this.setupHandlers();
355
355
  this.registerDefaultTools();
356
+ this.registerCompIntelTools();
356
357
  }
357
358
  setupHandlers() {
358
359
  // List tools
@@ -547,6 +548,312 @@ class GenesisMCPServer extends events_1.EventEmitter {
547
548
  handler: this.handleCreate.bind(this),
548
549
  });
549
550
  }
551
+ // ============================================================================
552
+ // v11.2: CompIntel + Revenue + Daemon Tools
553
+ // ============================================================================
554
+ registerCompIntelTools() {
555
+ // genesis.compintel.scan - Run competitive intelligence scan
556
+ this.registerTool({
557
+ name: 'genesis.compintel.scan',
558
+ description: 'Run a competitive intelligence scan on specified competitors. Scrapes their pages, detects changes from baseline, and analyzes significance.',
559
+ inputSchema: {
560
+ type: 'object',
561
+ properties: {
562
+ competitors: {
563
+ type: 'array',
564
+ items: {
565
+ type: 'object',
566
+ properties: {
567
+ name: { type: 'string', description: 'Competitor name' },
568
+ domain: { type: 'string', description: 'Competitor domain (e.g. cursor.com)' },
569
+ pages: { type: 'array', items: { type: 'string' }, description: 'Specific URLs to monitor (optional, auto-inferred if empty)' },
570
+ },
571
+ required: ['name', 'domain'],
572
+ },
573
+ description: 'Competitors to scan',
574
+ },
575
+ },
576
+ required: ['competitors'],
577
+ },
578
+ requiredScopes: ['compintel'],
579
+ baseCost: 0.10,
580
+ supportsStreaming: false,
581
+ maxExecutionTime: 120000,
582
+ annotations: { readOnlyHint: true, longRunningHint: true },
583
+ handler: async (input) => {
584
+ const { createCompetitiveIntelService } = await import('../services/competitive-intel.js');
585
+ const service = createCompetitiveIntelService({ competitors: input.competitors });
586
+ const changes = await service.checkAll();
587
+ let digest;
588
+ if (changes.length > 0) {
589
+ digest = await service.generateDigest(24);
590
+ }
591
+ return {
592
+ success: true,
593
+ data: {
594
+ competitors: input.competitors.length,
595
+ pagesScraped: service.getCompetitors().reduce((sum, c) => sum + c.pages.filter((p) => p.lastContent).length, 0),
596
+ changes: changes.map((c) => ({
597
+ competitor: c.pageUrl,
598
+ type: c.changeType,
599
+ significance: c.significance,
600
+ summary: c.summary,
601
+ analysis: c.analysis,
602
+ })),
603
+ digest: digest ? {
604
+ insights: digest.keyInsights,
605
+ recommendations: digest.recommendations,
606
+ } : null,
607
+ },
608
+ };
609
+ },
610
+ });
611
+ // genesis.compintel.digest - Generate intelligence digest
612
+ this.registerTool({
613
+ name: 'genesis.compintel.digest',
614
+ description: 'Generate a strategic intelligence digest from recent competitor changes. Provides key insights and actionable recommendations.',
615
+ inputSchema: {
616
+ type: 'object',
617
+ properties: {
618
+ competitors: {
619
+ type: 'array',
620
+ items: {
621
+ type: 'object',
622
+ properties: {
623
+ name: { type: 'string' },
624
+ domain: { type: 'string' },
625
+ pages: { type: 'array', items: { type: 'string' } },
626
+ },
627
+ required: ['name', 'domain'],
628
+ },
629
+ },
630
+ periodHours: { type: 'number', description: 'Hours to look back (default: 24)', default: 24 },
631
+ },
632
+ required: ['competitors'],
633
+ },
634
+ requiredScopes: ['compintel'],
635
+ baseCost: 0.08,
636
+ supportsStreaming: false,
637
+ maxExecutionTime: 60000,
638
+ annotations: { readOnlyHint: true },
639
+ handler: async (input) => {
640
+ const { createCompetitiveIntelService } = await import('../services/competitive-intel.js');
641
+ const service = createCompetitiveIntelService({ competitors: input.competitors });
642
+ await service.checkAll();
643
+ const digest = await service.generateDigest(input.periodHours || 24);
644
+ return {
645
+ success: true,
646
+ data: digest,
647
+ };
648
+ },
649
+ });
650
+ // genesis.revenue.setup - Setup Stripe revenue loop
651
+ this.registerTool({
652
+ name: 'genesis.revenue.setup',
653
+ description: 'Initialize the Stripe revenue loop: creates product, prices ($49/$99/$199), and payment links for CompIntel subscriptions.',
654
+ inputSchema: {
655
+ type: 'object',
656
+ properties: {},
657
+ },
658
+ requiredScopes: ['revenue'],
659
+ baseCost: 0,
660
+ supportsStreaming: false,
661
+ maxExecutionTime: 30000,
662
+ annotations: { readOnlyHint: false, idempotentHint: true },
663
+ handler: async () => {
664
+ const { createRevenueLoop } = await import('../services/revenue-loop.js');
665
+ const loop = createRevenueLoop();
666
+ const { product, prices, paymentLinks } = await loop.setup();
667
+ return {
668
+ success: true,
669
+ data: {
670
+ product: { id: product.id, name: product.name },
671
+ prices: Object.fromEntries(Object.entries(prices).map(([plan, p]) => [plan, { id: p.id, amount: p.unit_amount, interval: p.recurring?.interval }])),
672
+ paymentLinks: Object.fromEntries(Object.entries(paymentLinks).map(([plan, l]) => [plan, l.url])),
673
+ },
674
+ };
675
+ },
676
+ });
677
+ // genesis.revenue.subscribe_url - Get payment link
678
+ this.registerTool({
679
+ name: 'genesis.revenue.subscribe_url',
680
+ description: 'Get the Stripe payment link for a CompIntel subscription plan.',
681
+ inputSchema: {
682
+ type: 'object',
683
+ properties: {
684
+ plan: { type: 'string', enum: ['starter', 'pro', 'enterprise'], description: 'Subscription plan' },
685
+ },
686
+ required: ['plan'],
687
+ },
688
+ requiredScopes: ['revenue'],
689
+ baseCost: 0,
690
+ supportsStreaming: false,
691
+ maxExecutionTime: 5000,
692
+ annotations: { readOnlyHint: true },
693
+ handler: async (input) => {
694
+ const { getRevenueLoop } = await import('../services/revenue-loop.js');
695
+ const loop = getRevenueLoop();
696
+ const url = loop.getPaymentUrl(input.plan);
697
+ return { success: true, data: { plan: input.plan, url } };
698
+ },
699
+ });
700
+ // genesis.revenue.check - Check subscription status
701
+ this.registerTool({
702
+ name: 'genesis.revenue.check',
703
+ description: 'Check if a Stripe customer has an active CompIntel subscription.',
704
+ inputSchema: {
705
+ type: 'object',
706
+ properties: {
707
+ customerId: { type: 'string', description: 'Stripe customer ID (cus_...)' },
708
+ },
709
+ required: ['customerId'],
710
+ },
711
+ requiredScopes: ['revenue'],
712
+ baseCost: 0,
713
+ supportsStreaming: false,
714
+ maxExecutionTime: 10000,
715
+ annotations: { readOnlyHint: true },
716
+ handler: async (input) => {
717
+ const { getRevenueLoop } = await import('../services/revenue-loop.js');
718
+ const loop = getRevenueLoop();
719
+ const check = await loop.checkSubscription(input.customerId);
720
+ return { success: true, data: check };
721
+ },
722
+ });
723
+ // genesis.revenue.paid_scan - Run a paid CompIntel scan
724
+ this.registerTool({
725
+ name: 'genesis.revenue.paid_scan',
726
+ description: 'Run a CompIntel scan gated behind Stripe subscription. Checks payment, runs scan, tracks revenue.',
727
+ inputSchema: {
728
+ type: 'object',
729
+ properties: {
730
+ customerId: { type: 'string', description: 'Stripe customer ID' },
731
+ competitors: {
732
+ type: 'array',
733
+ items: {
734
+ type: 'object',
735
+ properties: {
736
+ name: { type: 'string' },
737
+ domain: { type: 'string' },
738
+ pages: { type: 'array', items: { type: 'string' } },
739
+ },
740
+ required: ['name', 'domain'],
741
+ },
742
+ },
743
+ },
744
+ required: ['customerId', 'competitors'],
745
+ },
746
+ requiredScopes: ['revenue', 'compintel'],
747
+ baseCost: 0.10,
748
+ supportsStreaming: false,
749
+ maxExecutionTime: 120000,
750
+ annotations: { readOnlyHint: true, longRunningHint: true },
751
+ handler: async (input) => {
752
+ const { getRevenueLoop } = await import('../services/revenue-loop.js');
753
+ const loop = getRevenueLoop();
754
+ const result = await loop.runPaidScan(input.customerId, input.competitors);
755
+ return { success: result.success, data: result, error: result.error };
756
+ },
757
+ });
758
+ // genesis.daemon.compintel_start - Start daemon with CompIntel
759
+ this.registerTool({
760
+ name: 'genesis.daemon.compintel_start',
761
+ description: 'Start the Genesis daemon with CompIntel scheduled scans. Monitors competitors on interval.',
762
+ inputSchema: {
763
+ type: 'object',
764
+ properties: {
765
+ competitors: {
766
+ type: 'array',
767
+ items: {
768
+ type: 'object',
769
+ properties: {
770
+ name: { type: 'string' },
771
+ domain: { type: 'string' },
772
+ pages: { type: 'array', items: { type: 'string' } },
773
+ },
774
+ required: ['name', 'domain'],
775
+ },
776
+ },
777
+ checkIntervalMs: { type: 'number', description: 'Scan interval in ms (default: 6 hours)', default: 21600000 },
778
+ requireSubscription: { type: 'boolean', description: 'Gate behind Stripe subscription', default: false },
779
+ customerId: { type: 'string', description: 'Stripe customer ID (if requireSubscription=true)' },
780
+ },
781
+ required: ['competitors'],
782
+ },
783
+ requiredScopes: ['daemon'],
784
+ baseCost: 0,
785
+ supportsStreaming: false,
786
+ maxExecutionTime: 10000,
787
+ annotations: { readOnlyHint: false },
788
+ handler: async (input) => {
789
+ const { Daemon } = await import('../daemon/index.js');
790
+ const daemon = new Daemon({}, {
791
+ competitiveIntel: {
792
+ enabled: true,
793
+ checkIntervalMs: input.checkIntervalMs || 21600000,
794
+ digestIntervalMs: 86400000,
795
+ competitors: input.competitors,
796
+ requireSubscription: input.requireSubscription || false,
797
+ customerId: input.customerId,
798
+ },
799
+ maintenance: { enabled: false, intervalMs: 999999, healthCheckIntervalMs: 999999, memoryCleanupIntervalMs: 999999, autoRepair: false, maxConcurrentTasks: 1, unhealthyAgentThreshold: 30, memoryRetentionThreshold: 0.1, resourceUsageThreshold: 0.9 },
800
+ dream: { enabled: false, autoTrigger: false, inactivityThresholdMs: 999999, minDreamDurationMs: 60000, maxDreamDurationMs: 600000, lightSleepRatio: 0.1, deepSleepRatio: 0.6, remSleepRatio: 0.3, episodicConsolidationThreshold: 10, patternExtractionThreshold: 3, creativityTemperature: 0.7 },
801
+ selfImprovement: { enabled: false, intervalMs: 999999, autoApply: false, minPhiThreshold: 0.3, maxImprovementsPerCycle: 3 },
802
+ });
803
+ daemon.start();
804
+ // Store reference for stop
805
+ globalThis.__genesisDaemon = daemon;
806
+ return {
807
+ success: true,
808
+ data: {
809
+ state: 'running',
810
+ competitors: input.competitors.length,
811
+ intervalMs: input.checkIntervalMs || 21600000,
812
+ requireSubscription: input.requireSubscription || false,
813
+ },
814
+ };
815
+ },
816
+ });
817
+ // genesis.daemon.stop - Stop running daemon
818
+ this.registerTool({
819
+ name: 'genesis.daemon.stop',
820
+ description: 'Stop the running Genesis daemon.',
821
+ inputSchema: { type: 'object', properties: {} },
822
+ requiredScopes: ['daemon'],
823
+ baseCost: 0,
824
+ supportsStreaming: false,
825
+ maxExecutionTime: 5000,
826
+ annotations: { readOnlyHint: false },
827
+ handler: async () => {
828
+ const daemon = globalThis.__genesisDaemon;
829
+ if (daemon) {
830
+ daemon.stop();
831
+ globalThis.__genesisDaemon = null;
832
+ return { success: true, data: { state: 'stopped' } };
833
+ }
834
+ return { success: false, error: 'No daemon running' };
835
+ },
836
+ });
837
+ // genesis.daemon.status - Get daemon status
838
+ this.registerTool({
839
+ name: 'genesis.daemon.status',
840
+ description: 'Get the current status of the Genesis daemon.',
841
+ inputSchema: { type: 'object', properties: {} },
842
+ requiredScopes: ['daemon'],
843
+ baseCost: 0,
844
+ supportsStreaming: false,
845
+ maxExecutionTime: 5000,
846
+ annotations: { readOnlyHint: true },
847
+ handler: async () => {
848
+ const daemon = globalThis.__genesisDaemon;
849
+ if (daemon) {
850
+ const status = daemon.status();
851
+ return { success: true, data: status };
852
+ }
853
+ return { success: true, data: { state: 'stopped' } };
854
+ },
855
+ });
856
+ }
550
857
  registerTool(config) {
551
858
  this.tools.set(config.name, config);
552
859
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genesis-ai-cli",
3
- "version": "11.1.0",
3
+ "version": "11.3.0",
4
4
  "description": "Fully Autonomous AI System - Self-funding, Self-deploying, Production Memory, A2A Protocol & Governance",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",