-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypes.ts
More file actions
1267 lines (1129 loc) · 36.6 KB
/
Copy pathtypes.ts
File metadata and controls
1267 lines (1129 loc) · 36.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// =============================================================================
// SHARED TYPES FOR SILHOUETTE AGENCY OS
// =============================================================================
// Email Interface (Used by EmailPanel, EmailLayout, gmailService)
export interface Email {
id: string;
from: string;
to?: string;
subject: string;
snippet: string;
body?: string;
date: Date | string | number;
isRead: boolean;
labels?: string[];
attachments?: { filename: string; mimeType: string; size: number }[];
}
// Framework Enums
export enum AgentStatus {
IDLE = 'IDLE',
THINKING = 'THINKING',
WORKING = 'WORKING',
CRITICAL = 'CRITICAL',
OFFLINE = 'OFFLINE',
HIBERNATED = 'HIBERNATED' // NEW: For local mode limitations
}
export enum AgentRoleType {
LEADER = 'LEADER',
WORKER = 'WORKER'
}
export enum AgentTier {
CORE = 'CORE', // Tier 0: Always Online
SPECIALIST = 'SPECIALIST', // Tier 1: On Demand (5m idle)
WORKER = 'WORKER' // Tier 2: Ephemeral (30s idle)
}
// Agent Profile for dynamic agent loading
export interface AgentProfile {
id: string;
name: string;
role: string;
capabilities: string[];
systemPrompt: string;
communicationStyle?: string;
maxContextWindow?: number;
modelPreference?: string;
}
export enum WorkflowStage {
INTENT = 'INTENT_ANALYSIS',
PLANNING = 'STRATEGIC_PLANNING',
EXECUTION = 'EXECUTION_SWARM',
QA_AUDIT = 'QUALITY_ASSURANCE_AUDIT',
REMEDIATION = 'ERROR_REMEDIATION',
OPTIMIZATION = 'AUTO_OPTIMIZATION',
META_ANALYSIS = 'SYSTEM_META_ANALYSIS',
ADAPTATION_QA = 'ADAPTATION_PROTOCOL_QA',
GENESIS = 'GENESIS_FACTORY_SPAWN', // NEW: Project Creation
DEPLOYMENT = 'GENESIS_COOLIFY_DEPLOY', // NEW: Git-Ops Deployment
RESEARCH = 'ACTIVE_RESEARCH_PROTOCOL', // NEW: Swarm Intelligence
ARCHIVAL = 'CONTEXT_ARCHIVAL',
IDLE = 'SYSTEM_IDLE'
}
// NEW: SYSTEM PROTOCOLS
export enum SystemProtocol {
UI_REFRESH = 'PROTOCOL_UI_REFRESH',
SQUAD_EXPANSION = 'PROTOCOL_SQUAD_EXPANSION',
CONFIG_MUTATION = 'PROTOCOL_CONFIG_MUTATION',
SECURITY_LOCKDOWN = 'PROTOCOL_SECURITY_LOCKDOWN',
MEMORY_FLUSH = 'PROTOCOL_MEMORY_FLUSH',
MEMORY_CREATED = 'PROTOCOL_MEMORY_CREATED', // NEW: Real-time UI update
INTERFACE_MORPH = 'PROTOCOL_INTERFACE_MORPH',
RESOURCE_SHUNT = 'PROTOCOL_RESOURCE_SHUNT',
NEURO_LINK_HANDSHAKE = 'PROTOCOL_NEURO_LINK_HANDSHAKE', // NEW
HIVE_MIND_SYNC = 'PROTOCOL_HIVE_MIND_SYNC', // NEW
GENESIS_UPDATE = 'PROTOCOL_GENESIS_UPDATE', // NEW: Triggers Workspace Refresh
MEMORY_OPTIMIZED = 'MEMORY_OPTIMIZED',
FILESYSTEM_UPDATE = 'PROTOCOL_FILESYSTEM_UPDATE', // NEW: Syncs VFS with Dashboard
SENSORY_SNAPSHOT = 'PROTOCOL_SENSORY_SNAPSHOT', // NEW: Visual Cortex trigger
NAVIGATION = 'PROTOCOL_NAVIGATION', // NEW: Autonomous Tab Switching
THOUGHT_EMISSION = 'PROTOCOL_THOUGHT_EMISSION', // NEW: Real-time neural stream
RESEARCH_REQUEST = 'PROTOCOL_RESEARCH_REQUEST', // NEW: Swarm Intelligence
RESEARCH_RESPONSE = 'PROTOCOL_RESEARCH_RESPONSE', // NEW: Swarm Intelligence
INNOVATION_REQUEST = 'PROTOCOL_INNOVATION_REQUEST', // NEW: Anti-Hallucination
INNOVATION_RESPONSE = 'PROTOCOL_INNOVATION_RESPONSE', // NEW: Anti-Hallucination
TASK_ASSIGNMENT = 'PROTOCOL_TASK_ASSIGNMENT', // NEW: Orchestrator -> Agent
TASK_COMPLETION = 'PROTOCOL_TASK_COMPLETION', // NEW: Agent -> Orchestrator
COST_ANOMALY = 'PROTOCOL_COST_ANOMALY', // NEW: CFO -> Orchestrator
DATA_CORRUPTION = 'PROTOCOL_DATA_CORRUPTION', // NEW: Janitor -> Orchestrator
TASK_PAUSED = 'PROTOCOL_TASK_PAUSED', // NEW: Remediation -> System
WORKFLOW_UPDATE = 'PROTOCOL_WORKFLOW_UPDATE', // NEW: Workflow Engine -> UI
VISUAL_REQUEST = 'PROTOCOL_VISUAL_REQUEST',
UI_COMMAND = 'PROTOCOL_UI_COMMAND', // NEW: Backend -> Frontend UI commands (popups, modals)
VISUAL_SNAPSHOT = 'PROTOCOL_VISUAL_SNAPSHOT',
WEBHOOK_RECEIVED = 'PROTOCOL_WEBHOOK_RECEIVED', // External network events
INCIDENT_REPORT = 'PROTOCOL_INCIDENT_REPORT', // NEW: Remediation -> Research
ARCHITECTURAL_RFC = 'PROTOCOL_ARCHITECTURAL_RFC', // NEW: Research -> User
INTUITION_CONSOLIDATED = 'PROTOCOL_INTUITION_CONSOLIDATED', // NEW: Dreamer -> NeuroSynapse
GENESIS_TRIGGER = 'PROTOCOL_GENESIS_TRIGGER', // NEW: RFC Approved -> Code Injection
EPISTEMIC_GAP_DETECTED = 'PROTOCOL_EPISTEMIC_GAP_DETECTED', // NEW: Dreamer -> Researcher (Curiosity)
SQUAD_REASSIGNMENT = 'PROTOCOL_SQUAD_REASSIGNMENT', // NEW: Drag & Drop UI -> Orchestrator
ACTION_INTENT = 'PROTOCOL_ACTION_INTENT', // NEW: Introspection -> Orchestrator
TRAINING_EXAMPLE_FOUND = 'PROTOCOL_TRAINING_EXAMPLE_FOUND', // NEW: Nocturnal Plasticity
TRAINING_START = 'PROTOCOL_TRAINING_START', // NEW: Trigger Dream Cycle
TRAINING_LOG = 'PROTOCOL_TRAINING_LOG', // NEW: Live logs
TRAINING_COMPLETE = 'PROTOCOL_TRAINING_COMPLETE', // NEW: Done
CURRICULA_READY = 'PROTOCOL_CURRICULA_READY', // NEW: Curricula exported for NanoSilhouette
// Research Synthesis Pipeline
SYNTHESIS_REQUEST = 'PROTOCOL_SYNTHESIS_REQUEST', // NEW: Trigger insight synthesis
SYNTHESIS_COMPLETE = 'PROTOCOL_SYNTHESIS_COMPLETE', // NEW: Synthesis result ready
PAPER_GENERATION_REQUEST = 'PROTOCOL_PAPER_GENERATION_REQUEST', // NEW: Generate paper from insight
PAPER_GENERATION_COMPLETE = 'PROTOCOL_PAPER_GENERATION_COMPLETE', // NEW: Paper ready for review
AGENT_EVOLVED = 'PROTOCOL_AGENT_EVOLVED', // PA-038: Agent evolution notification
NARRATIVE_UPDATE = 'PROTOCOL_NARRATIVE_UPDATE', // NEW: Unified Stream Emission
CANVAS_OPERATION = 'PROTOCOL_CANVAS_OPERATION', // NEW: Agent -> Visual Cortex Control
LEARNING_UPDATE = 'PROTOCOL_LEARNING_UPDATE', // Self-Evolution: Learning Loop insights
DIAGNOSTICS_DATA = 'PROTOCOL_DIAGNOSTICS_DATA', // NEW: System diagnostics data
SECURITY_ALERT = 'PROTOCOL_SECURITY_ALERT', // NEW: Security alerts
TOOL_EVOLUTION = 'PROTOCOL_TOOL_EVOLUTION', // Self-Evolution: Tool optimization
// Voice System Events (PA-008)
VOICE_ENGINE_ONLINE = 'PROTOCOL_VOICE_ENGINE_ONLINE',
VOICE_ENGINE_OFFLINE = 'PROTOCOL_VOICE_ENGINE_OFFLINE',
VOICE_CLONE_START = 'PROTOCOL_VOICE_CLONE_START',
VOICE_CLONE_COMPLETE = 'PROTOCOL_VOICE_CLONE_COMPLETE',
VOICE_CLONE_FAILED = 'PROTOCOL_VOICE_CLONE_FAILED',
VOICE_TTS_REQUEST = 'PROTOCOL_VOICE_TTS_REQUEST',
VOICE_TTS_ERROR = 'PROTOCOL_VOICE_TTS_ERROR',
VOICE_QUALITY_LOW = 'PROTOCOL_VOICE_QUALITY_LOW',
// Epistemological Integrity (Debate Vulnerability Fixes)
MEMORY_QUARANTINE = 'PROTOCOL_MEMORY_QUARANTINE', // Janitor -> Orchestrator: Node quarantined (not deleted)
CONTRADICTION_DETECTED = 'PROTOCOL_CONTRADICTION_DETECTED', // Janitor -> Orchestrator: Contradiction found in memory
Z3_VERIFICATION_FAILED = 'PROTOCOL_Z3_VERIFICATION_FAILED', // Introspection -> System: Action blocked by formal logic
// Connection Nervous System (Auto-Healing)
CONNECTION_LOST = 'PROTOCOL_CONNECTION_LOST', // Service disconnected
CONNECTION_RESTORED = 'PROTOCOL_CONNECTION_RESTORED', // Service reconnected
CONNECTION_HEARTBEAT = 'PROTOCOL_CONNECTION_HEARTBEAT', // Periodic health check
// Autonomy System
SYSTEM_ALERT = 'PROTOCOL_SYSTEM_ALERT', // Critical alerts for user attention
SCHEDULED_TASK_TRIGGER = 'PROTOCOL_SCHEDULED_TASK_TRIGGER', // Scheduler fires task
GOAL_UPDATED = 'PROTOCOL_GOAL_UPDATED', // Goal progress/completion
INTEGRATION_EVENT = 'PROTOCOL_INTEGRATION_EVENT', // External webhook/event received
CONFIRMATION_REQUIRED = 'PROTOCOL_CONFIRMATION_REQUIRED', // Human-in-loop approval needed
SYSTEM_RESTART_REQUEST = 'PROTOCOL_SYSTEM_RESTART_REQUEST', // [PA-051] OS Supervisor Auto-Restart Hook
// Inter-Agent Help Protocol (Team Leader Communication)
HELP_REQUEST = 'PROTOCOL_HELP_REQUEST', // Agent → Agent (solicita ayuda)
HELP_RESPONSE = 'PROTOCOL_HELP_RESPONSE', // Agent → Agent (responde con solución)
// Email Events
PROTOCOL_EMAIL_RECEIVED = 'PROTOCOL_EMAIL_RECEIVED', // New email notification
// [OMNISCIENT] New Protocols for Complete Event Awareness
TOOL_EXECUTION = 'PROTOCOL_TOOL_EXECUTION', // When a tool is executed (web search, file ops, etc.)
USER_MESSAGE = 'PROTOCOL_USER_MESSAGE', // Direct user/creator communication
MOOD_CHANGE = 'PROTOCOL_MOOD_CHANGE', // Emotional state transitions
IMPROVEMENT_LOGGED = 'PROTOCOL_IMPROVEMENT_LOGGED', // Self-improvement events
SKILL_LEARNED = 'PROTOCOL_SKILL_LEARNED', // New capability acquired
ERROR_RECOVERED = 'PROTOCOL_ERROR_RECOVERED', // Self-healing events
// Credential Safety
MISSING_CREDENTIAL = 'PROTOCOL_MISSING_CREDENTIAL',
// Job Queue / Async Workers
VIDEO_REQUEST = 'PROTOCOL_VIDEO_REQUEST',
WORK_COMPLETE = 'PROTOCOL_WORK_COMPLETE',
// Unified Capability Execution
CAPABILITY_REQUEST = 'PROTOCOL_CAPABILITY_REQUEST', // Capability execution started
CAPABILITY_RESULT = 'PROTOCOL_CAPABILITY_RESULT', // Capability execution completed
// ==================== CAPABILITY LIFECYCLE ====================
// Tool Events
TOOL_CREATED = 'PROTOCOL_TOOL_CREATED', // New tool registered
TOOL_EVOLVED = 'PROTOCOL_TOOL_EVOLVED', // Tool improved/modified
TOOL_DELETED = 'PROTOCOL_TOOL_DELETED', // Tool removed
// Agent Events
AGENT_SPAWNED = 'PROTOCOL_AGENT_SPAWNED', // New agent created
// AGENT_EVOLVED already exists at line 118
AGENT_DISMISSED = 'PROTOCOL_AGENT_DISMISSED', // Agent removed
// Squad Events
SQUAD_FORMED = 'PROTOCOL_SQUAD_FORMED', // New squad created
SQUAD_DISSOLVED = 'PROTOCOL_SQUAD_DISSOLVED', // Squad disbanded
SQUAD_DEBATE_START = 'PROTOCOL_SQUAD_DEBATE_START', // Signal to begin a multi-agent debate
AGENT_DEBATE_MESSAGE = 'PROTOCOL_AGENT_DEBATE_MESSAGE', // A message from an agent in the debate room
SQUAD_CONSENSUS = 'PROTOCOL_SQUAD_CONSENSUS', // Debate reached an agreement or max turns
// Capability Sync
CAPABILITY_SYNC = 'PROTOCOL_CAPABILITY_SYNC', // Force capability refresh
// ==================== SECURITY EVENTS ====================
SECURITY_REVIEW_REQUEST = 'PROTOCOL_SECURITY_REVIEW_REQUEST', // Code needs review
SECURITY_REVIEW_RESULT = 'PROTOCOL_SECURITY_REVIEW_RESULT', // Review completed
SECURITY_THREAT_DETECTED = 'PROTOCOL_SECURITY_THREAT_DETECTED', // Malicious pattern found
// ==================== API KEY MANAGEMENT ====================
API_KEY_CREATED = 'PROTOCOL_API_KEY_CREATED', // New API key generated
API_KEY_REVOKED = 'PROTOCOL_API_KEY_REVOKED', // API key revoked
API_KEY_EXPIRED = 'PROTOCOL_API_KEY_EXPIRED', // API key expired
AGENT_HANDSHAKE = 'PROTOCOL_AGENT_HANDSHAKE',
}
export interface StreamItem {
id: string;
timestamp: number;
source: 'CONSCIOUS' | 'SUBCONSCIOUS' | 'UNCONSCIOUS' | 'AGENCY';
content: string;
coherence: number;
metadata?: {
agentId?: string;
emotion?: string;
topics?: string[];
originalEvent?: string;
};
}
export enum CommunicationLevel {
INTERNAL_MONOLOGUE = 'INTERNAL_MONOLOGUE',
TEAM_BROADCAST = 'TEAM_BROADCAST',
DIRECT_MESSAGE = 'DIRECT_MESSAGE',
SYSTEM_ALERT = 'SYSTEM_ALERT',
USER_FACING = 'USER_FACING', // Level 1: Donna Paulsen (Sarcastic, Leader)
EXECUTIVE = 'EXECUTIVE', // Level 2: Diplomat (Professional, Goal-Oriented)
TECHNICAL = 'TECHNICAL' // Level 3: Robot (JSON, Precise, No Emotion)
}
export type TraceId = string;
export interface InterAgentMessage {
id: string;
traceId: TraceId; // The "Golden Thread" linking sub-tasks
senderId: string;
targetId: string; // Agent ID or Team ID
type: 'REQUEST' | 'RESPONSE' | 'INFO' | 'BROADCAST';
protocol: SystemProtocol;
payload: any;
timestamp: number;
priority?: 'LOW' | 'NORMAL' | 'HIGH' | 'CRITICAL';
ttl?: number; // Time to live in ms
}
export interface ProtocolEvent {
type: SystemProtocol;
payload: any;
timestamp: number;
initiator: string;
id?: string;
traceId?: TraceId; // Optional trace for system events
}
export interface MorphPayload {
mode: 'DEFENSE' | 'FLOW' | 'NEUTRAL';
accentColor?: string;
density?: 'compact' | 'comfortable';
}
/**
* Memory Tier System
*
* REFACTORING NOTE (2026-01-07):
* - WORKING: New unified working memory tier (replaces ULTRA_SHORT + SHORT)
* - ULTRA_SHORT/SHORT: Kept for backward compatibility, internally map to WORKING
* - MEDIUM: Persistent storage for frequently accessed memories
* - LONG: Archive for older, less accessed memories
* - DEEP: Vector-based semantic memory in Qdrant
*/
export enum MemoryTier {
// === NEW UNIFIED TIER ===
WORKING = 'WORKING', // RAM-based working memory (active session context)
// === PERSISTENT TIERS ===
MEDIUM = 'MEDIUM', // LanceDB - frequently accessed
LONG = 'LONG', // LanceDB - archived
DEEP = 'DEEP', // Qdrant - semantic vectors
// === LEGACY TIERS (Mapped to new tiers for compatibility) ===
/** @deprecated Use WORKING instead */
EPISODIC = 'WORKING', // Legacy: session-based episodic memory
/** @deprecated Use DEEP instead */
SEMANTIC = 'DEEP', // Legacy: vector-based semantic memory
/** @deprecated Use WORKING instead */
ULTRA_SHORT = 'WORKING', // Maps to WORKING for compatibility
/** @deprecated Use WORKING instead */
SHORT = 'WORKING' // Maps to WORKING for compatibility
}
export enum IntrospectionLayer {
SHALLOW = 12,
MEDIUM = 20,
DEEP = 28,
OPTIMAL = 32,
MAXIMUM = 48
}
export enum IntrospectionCapability {
CONCEPT_INJECTION = 'CONCEPT_INJECTION',
THOUGHT_DETECTION = 'THOUGHT_DETECTION',
STEERING = 'ACTIVATION_STEERING',
STATE_CONTROL = 'INTENTIONAL_STATE_CONTROL',
SAFETY_CHECK = 'UNINTENDED_OUTPUT_DETECTION',
CODEBASE_AWARENESS = 'CODEBASE_AWARENESS' // NEW
}
export enum ConsciousnessLevel {
REACTIVE = 'REACTIVE_STATE',
BASIC = 'BASIC_SELF_AWARENESS',
EMERGING = 'EMERGING_CONSCIOUSNESS',
MODERATE = 'MODERATELY_CONSCIOUS',
HIGH = 'HIGHLY_CONSCIOUS'
}
export enum SystemMode {
ECO = 'ECO',
BALANCED = 'BALANCED',
HIGH = 'HIGH',
ULTRA = 'ULTRA',
CUSTOM = 'CUSTOM',
DIAGNOSTIC = 'DIAGNOSTIC',
PRESET = 'PRESET'
}
// [DYNAMIC CAPABILITY REGISTRY] V6.0
// Granular skills that agents can register.
// [DYNAMIC CAPABILITY REGISTRY] V6.0
// Granular skills that agents can register.
export enum AgentCapability {
// CORE
CODE_GENERATION = 'CAP_CODE_GENERATION',
CODE_REVIEW = 'CAP_CODE_REVIEW',
SYSTEM_DESIGN = 'CAP_SYSTEM_DESIGN',
// OPS & QA
VISUAL_DESIGN = 'CAP_VISUAL_DESIGN', // Marketing
CAMPAIGN_STRATEGY = 'CAP_CAMPAIGN_STRATEGY', // Marketing
QA_TESTING = 'CAP_QA_TESTING',
SECURITY_AUDIT = 'CAP_SECURITY_AUDIT',
CONTEXT_MANAGEMENT = 'CAP_CONTEXT_MANAGEMENT',
// --- DYNAMIC INFRASTRUCTURE (TOOLS) ---
TOOL_WEB_SEARCH = 'TOOL_WEB_SEARCH',
TOOL_CODE_EXECUTION = 'TOOL_CODE_EXECUTION',
TOOL_IMAGE_GENERATION = 'TOOL_IMAGE_GENERATION',
TOOL_MEMORY_WRITE = 'TOOL_MEMORY_WRITE',
TOOL_VIDEO_GENERATION = 'TOOL_VIDEO_GENERATION', // [Phase 7]
TOOL_ASSET_LISTING = 'TOOL_ASSET_LISTING', // [Phase 7]
TOOL_RFC_REQUEST = 'TOOL_RFC_REQUEST', // [PHASE 8]
TOOL_SYSTEM_CONTROL = 'TOOL_SYSTEM_CONTROL', // [PA-055] Desktop Integration
// ACTIONS (PHASE 13)
ACTION_FILE_READ = 'ACTION_FILE_READ',
ACTION_FILE_WRITE = 'ACTION_FILE_WRITE',
ACTION_SHELL_EXEC = 'ACTION_SHELL_EXEC',
// DOMAIN EXTENSIONS
REMEDIATION = 'CAP_REMEDIATION',
LEGAL_COMPLIANCE = 'CAP_LEGAL_COMPLIANCE',
// DATA & SCIENCE
DATA_ANALYSIS = 'CAP_DATA_ANALYSIS',
RESEARCH = 'CAP_RESEARCH',
INNOVATION = 'CAP_INNOVATION',
// INFRA
DEPLOYMENT = 'CAP_DEPLOYMENT',
DATABASE_MANAGEMENT = 'CAP_DATABASE_MANAGEMENT'
}
export type BusinessType =
| 'GENERAL'
| 'MARKETING_AGENCY'
| 'LAW_FIRM'
| 'FINTECH'
| 'DEV_SHOP'
| 'RESEARCH_LAB'
| 'CYBER_DEFENSE'
| 'HEALTHCARE_ORG'
| 'RETAIL_GIANT'
| 'MANUFACTURING'
| 'ENERGY_CORP';
export type AgentCategory =
| 'CORE'
| 'DEV'
| 'MARKETING'
| 'DATA'
| 'SUPPORT'
| 'CYBERSEC'
| 'LEGAL'
| 'FINANCE'
| 'SCIENCE'
| 'OPS'
| 'HEALTH'
| 'RETAIL'
| 'MFG'
| 'ENERGY'
| 'EDU'
| 'INSTALL'
| 'INTEGRATION'
| 'MEDIA'
| 'WORKFLOW';
export enum UserRole {
SUPER_ADMIN = 'SUPER_ADMIN',
ADMIN = 'ADMIN',
WORKER_L1 = 'WORKER_L1',
WORKER_L2 = 'WORKER_L2',
CLIENT = 'CLIENT',
VISITOR = 'VISITOR'
}
export interface SystemMap {
frontendComponents: string[];
backendEndpoints: string[];
databaseSchema: string[];
rolePolicy: Record<UserRole, string[]>;
scanTimestamp: number;
}
export type InstallationStep = 'KEYS' | 'SCANNING' | 'MAPPING' | 'HANDOVER' | 'COMPLETE';
export interface InstallationState {
isInstalled: boolean;
currentStep: InstallationStep;
progress: number;
logs: string[];
systemMap: SystemMap | null;
apiKeys: {
gemini?: string;
openai?: string;
anthropic?: string;
github?: string;
coolify?: string;
};
}
export interface IntegrationSchema {
id: string;
name: string;
description: string;
category: 'AI' | 'DATABASE' | 'MESSAGING' | 'CLOUD' | 'DEV' | 'OTHER';
authType: 'API_KEY' | 'OAUTH2' | 'WEBHOOK_SECRET' | 'BEARER_TOKEN' | 'BASIC';
authConfig?: {
authorizationUrl?: string; // OAuth2
tokenUrl?: string; // OAuth2
clientId?: string; // OAuth2
scopes?: string[]; // OAuth2
pkce?: boolean; // OAuth2
headerName?: string; // API Key / Webhook
};
fields: {
key: string;
label: string;
type: 'text' | 'password' | 'url' | 'number';
required: boolean;
placeholder?: string;
description?: string; // Enhanced help text
validationRegex?: string; // Client-side check
}[];
isConnected: boolean;
lastSync?: number;
documentationUrl?: string; // Link to provider docs
icon?: string; // URL icon for UI
}
export interface ThemeConfig {
mode: 'dark' | 'light' | 'cyberpunk' | 'corporate';
accentColor: string;
reduceMotion: boolean;
density: 'compact' | 'comfortable';
}
export interface PermissionMatrix {
[role: string]: {
canViewDashboard: boolean;
canControlSwarm: boolean;
canAccessMemory: boolean;
canEditSettings: boolean;
canExecuteTasks: boolean;
}
}
export interface SettingsState {
theme: ThemeConfig;
integrations: Record<string, Record<string, string>>;
registeredIntegrations: IntegrationSchema[];
permissions: PermissionMatrix;
notifications: {
email: boolean;
slack: boolean;
browser: boolean;
securityAlerts: boolean;
};
language: 'en' | 'es' | 'fr' | 'jp';
systemUpdates?: {
autoCheck: boolean;
autoLaunch: boolean;
};
}
export interface AutonomousConfig {
enabled: boolean;
mode24_7?: boolean;
allowEvolution?: boolean;
smartPaging?: boolean;
maxRunTimeHours?: number;
maxDailyTokens?: number;
safeCleanup?: boolean;
// New Fields
maxConcurrentAgents?: number;
budgetCap?: number;
allowedDomains?: string[];
autoApprovalThreshold?: string;
}
// --- NEW: COGNITIVE LOOP TYPES (OODA) ---
export interface Observation {
timestamp: number;
activeAgents: number;
recentErrors: string[];
metrics: {
cpu: number;
memory: number;
latency: number;
coherence?: number; // NEW: Introspection Quality
};
snapshotId: string;
visualSnapshot?: string; // Base64 Image
relevantExperiences?: string[]; // [SELF-IMPROVEMENT] Past experiences for reflection
}
export interface Orientation {
aligned: boolean;
driftScore: number; // 0.0 - 1.0 (Low - High Drift)
violatedAxioms: string[];
safetyStatus: 'SECURE' | 'COMPROMISED' | 'UNKNOWN';
state: Observation; // [FIX] Required for Decision Phase (Root Cause of TypeError)
}
export interface Decision {
requiresIntervention: boolean;
priority: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
proposedAction: CognitiveAction | null;
reasoning: string;
}
export interface CognitiveAction {
type: 'ADJUST_LAYER' | 'INJECT_CONCEPT' | 'HALT_PROCESS' | 'EMIT_WARNING' | 'SELF_CORRECTION' | 'SLEEP_CYCLE' | 'ZOMBIE_RESET' | 'EPISTEMIC_SCAN' | 'HYDRATE_AGENT';
payload: any;
}
export interface WorkflowMutation {
target: 'INTROSPECTION_DEPTH' | 'SYSTEM_MODE' | 'QA_THRESHOLD';
action: 'INCREASE' | 'DECREASE' | 'MAINTAIN';
reason: string;
approved: boolean;
}
export interface Agent {
id: string;
name: string;
teamId: string;
category: AgentCategory;
tier: AgentTier; // NEW: Lifecycle Management
roleType: AgentRoleType;
role: string;
status: AgentStatus;
enabled: boolean;
preferredMemory: 'VRAM' | 'RAM' | 'DISK'; // Hardware Preference (DISK = hibernated)
systemInstruction?: string; // [PA-038] Dynamic definition
metadata?: Record<string, any>; // [PA-045] Flexible storage for Squads/Genesis
memoryLocation: 'VRAM' | 'RAM' | 'DISK';
cpuUsage: number;
ramUsage: number;
lastActive: number;
currentTask?: string;
thoughtProcess?: string[];
port?: number;
hibernated?: boolean;
capabilities?: AgentCapability[]; // [DCR] New Field
// [PHASE 17] Agent Standardization (Modular Architecture)
memoryId?: string; // Partition ID for private memory (defaults to agent.id)
directives?: string[]; // Evolving specific instructions/biases
opinion?: string; // Summary of worldview/state
}
export interface Squad {
id: string;
name: string;
leaderId: string;
members: string[];
category: AgentCategory;
active: boolean;
port: number;
capabilities?: AgentCapability[]; // [DCR] New Field
}
export interface ServiceStatus {
id: string;
name: string;
port: number;
url?: string;
status: 'ONLINE' | 'DEGRADED' | 'OFFLINE' | 'UNKNOWN';
latency: number;
uptime: number;
}
export interface SystemMetrics {
activeAgents: number;
agentsInVram: number;
agentsInRam: number;
introspectionDepth: number;
awarenessScore: number;
fps: number;
currentMode: SystemMode;
tokenUsageToday: number;
currentStage: WorkflowStage;
jsHeapSize: number;
vramUsage: number;
cpuTickDuration: number;
netLatency: number;
systemAlert: string | null;
gpu?: {
load: number;
vramUsed: number;
vramTotal: number;
temp: number;
};
disk?: {
used: number;
total: number;
};
realCpu?: number;
providerHealth?: Record<string, ProviderState>; // NEW: Circuit Breaker Status
mediaQueue?: VideoJob[]; // NEW: Render Queue Status
brain?: {
workingMemoryItems: number;
latestNarrative?: string;
}; // NEW: Silhouette Brain telemetry
}
// --- NEW: ROBUST TELEMETRY TYPES ---
export type ProviderStatus = 'HEALTHY' | 'SUSPENDED';
export interface ProviderState {
name: string;
status: ProviderStatus;
consecutiveFailures: number;
suspendedUntil: number; // Timestamp
lastError?: string;
}
export interface VideoJob {
id: string;
prompt: string;
imagePath?: string;
engine?: 'WAN' | 'SVD' | 'ANIMATEDIFF' | 'VID2VID' | 'KLING' | 'VEO'; // [Phase 7 extended]
status: 'QUEUED' | 'PROCESSING' | 'COMPLETED' | 'FAILED';
createdAt: string;
videoPath?: string;
provider: string; // generalized from 'LOCAL_WAN_2.1'
// === KLING-INSPIRED: Advanced Parameters ===
duration?: number; // seconds
fps?: number; // 12, 24, 30, 60
aspectRatio?: string; // '16:9', '9:16', '1:1'
resolution?: string; // '720p', '1080p', '4K'
// Camera Control
camera?: {
movement: string; // 'static', 'pan_left', 'dolly_in', etc.
speed: string; // 'slow', 'medium', 'fast'
};
// Keyframes (A→B)
keyframeStart?: string; // Image URL
keyframeEnd?: string; // Image URL
// Generation Quality
guidanceScale?: number;
inferenceSteps?: number;
motionStrength?: number;
negativePrompt?: string;
seed?: number;
stylePreset?: string;
}
export interface MemoryNode {
id: string;
content: string;
originalContent?: string;
timestamp: number;
tier: MemoryTier;
importance: number;
tags: string[];
accessCount: number;
lastAccess: number;
decayHealth?: number;
compressionLevel?: number;
embeddingVector?: Float32Array;
ownerId?: string; // NEW: Agent-Specific Ownership
nestingLevel?: number; // NEW: 1=Raw, 2=Thought, 3=Episode, 4=Fact, 5=Identity
stabilityScore?: number; // NEW: Resistance to decay (0-100)
raptorLevel?: number; // NEW: 0=Leaf, 1=Summary, 2=Meta-Summary
timeGrid?: { year: number; month: number; day: number; hour: number; weekday: number }; // NEW: Fractal Index
}
export interface ConceptVector {
id: string;
label: string;
strength: number;
layer: number;
active: boolean;
}
export interface CodeChunk {
id: string;
filePath: string;
startLine: number;
endLine: number;
content: string;
hash: string; // MD5 for change detection
tags: string[]; // e.g., ["function:generateResponse", "class:GeminiService"]
lastUpdated: number;
}
export interface IntrospectionResult {
rawOutput: string;
cleanOutput: string;
thoughts: string[];
metrics: {
latency: number;
depth: number;
coherence: number;
thoughtDensity: number;
safetyScore: number;
groundingScore?: number; // NEW: Semantic Alignment
internalityVerified?: boolean; // NEW: Injection Detection
logicVerified?: boolean; // NEW: Z3 Symbolic Prover validation
};
activeCapabilities: IntrospectionCapability[];
lastThreat?: string;
}
export interface Project {
id: string;
name: string;
client?: string; // made optional
status: 'planning' | 'active' | 'generating' | 'completed' | 'paused';
progress: number;
assignedAgents?: string[]; // made optional
activeSquads: number;
tasks: {
pending: number;
inProgress: number;
completed: number;
backlog: number;
};
}
export interface QualityReport {
score: number;
passed: boolean;
criticalFailures: string[];
suggestions: string[];
}
export interface CritiqueResult {
passed: boolean;
score: number;
feedback: string;
}
export interface QualiaMap {
stateName: string;
intensity: number;
valence: 'POSITIVE' | 'NEGATIVE' | 'NEUTRAL';
complexity: number;
}
export interface ConsciousnessMetrics {
level: ConsciousnessLevel;
phiScore: number;
selfRecognition: number;
recursionDepth: number;
identityCoherence: number;
emergenceIndex: number;
qualia: QualiaMap[];
}
export interface ApiConfig {
port: number;
enabled: boolean;
apiKey: string;
}
export interface IntegrationConfig {
targetUrl: string;
targetName: string;
authType: 'BEARER' | 'OAUTH' | 'COOKIE';
}
export interface HostEnvironment {
domStructure: string;
routes: string[];
cookies: string[];
localStorageKeys: string[];
}
export interface ChatMessage {
id: string;
role: 'user' | 'agent' | 'system';
text: string;
timestamp: number;
thoughts?: string[];
image?: string; // Single image (legacy)
assets?: any[]; // For AssetGrid
concepts?: any[]; // For ConceptCarousel
agentId?: string; // [PHASE 15]
agentName?: string; // [PHASE 15]
}
export interface DynamicComponentSchema {
id: string;
type: 'CONTAINER' | 'GRID' | 'CARD' | 'TABLE' | 'CHART' | 'METRIC' | 'BUTTON' | 'TEXT' | 'INPUT' | 'REACT_APPLICATION' | 'TERMINAL_VIEW' | 'FILE_EXPLORER';
props: {
title?: string;
value?: string | number;
color?: string;
columns?: string[];
data?: any[];
onClick?: string;
layout?: 'row' | 'col';
width?: string;
icon?: string;
files?: any; // New for File Explorer
};
children?: DynamicComponentSchema[];
code?: string; // For REACT_APPLICATION type. Contains raw JSX.
}
export interface DynamicInterfaceState {
activeAppId: string | null;
rootComponent: DynamicComponentSchema | null;
lastUpdated: number;
}
// --- NEW EXPORTS FOR TRAINING & VISUALIZATION ---
export interface TrainingExample {
id: string;
input: string;
output: string;
tags: string[];
timestamp: number;
score: number;
source: string;
}
export enum AwarenessMode {
HYPER = 'HYPER_AWARE',
NORMAL = 'NORMAL',
FOCUSED = 'FOCUSED',
DREAMING = 'DREAMING',
}
export enum ActionIntent {
OBSERVE = 'OBSERVE',
THINK = 'THINK',
ACT = 'ACT',
REFLECT = 'REFLECT'
}
export type Capability = IntrospectionCapability | AgentCapability;
export type GenesisTemplate = 'REACT_VITE' | 'NEXT_JS' | 'EXPRESS_API' | 'FULL_STACK_CRM' | 'EMPTY' | 'AI_AUTO_DETECT';
export interface GenesisConfig {
workspaceRoot: string;
allowBridgeInjection: boolean;
allowedRoles: UserRole[];
maxConcurrentBuilds: number;
coolifyUrl?: string;
coolifyToken?: string;
gitUser?: string;
gitToken?: string;
systemApiKey?: string; // Persisted Gemini Key
unsplashKey?: string;
tavilyKey?: string; // NEW: Search
mediaConfig?: {
openaiKey?: string;
elevenLabsKey?: string;
replicateKey?: string;
imagineArtKey?: string;
unsplashKey?: string;
elevenLabsVoiceId?: string;
veoModelId?: string; // NEW: Google Veo 3.1
nanoBananaModelId?: string; // NEW: NanoBanana Pro
providers?: {
image: 'OPENAI' | 'GEMINI' | 'STABILITY';
voice: 'ELEVENLABS' | 'OPENAI' | 'GEMINI';
video: 'REPLICATE' | 'RUNWAY';
};
};
}
export interface GenesisProject {
id: string;
name: string;
path: string;
template: GenesisTemplate;
status: 'CREATING' | 'INSTALLING' | 'READY' | 'RUNNING' | 'DEPLOYING' | 'LIVE' | 'ERROR';
bridgeStatus: 'DISCONNECTED' | 'CONNECTED';
createdAt: number;
port?: number;
client?: string;
description?: string;
liveUrl?: string; // e.g., crm.client.com
repoUrl?: string;
}
// --- NEURO-LINK TYPES ---
export enum NeuroLinkStatus {
DISCONNECTED = 'DISCONNECTED',
HANDSHAKE = 'CONNECTED', // Simplification for UI
CONNECTED = 'CONNECTED',
SYNCING = 'SYNCING'
}
export interface NeuroLinkNode {
id: string;
projectId: string;
url: string;
status: NeuroLinkStatus;
latency: number;
lastHeartbeat: number;
resources: {
cpu: number;
memory: number;
};
category?: AgentCategory;
}
// --- VIRTUAL FILE SYSTEM TYPES ---
export type FileType = 'FILE' | 'FOLDER';
export interface FileNode {
id: string;
name: string;
type: FileType;
content?: string; // Only for files
parentId: string | null; // For root, parent is null
children?: string[]; // IDs of children (only for folders)
createdAt: number;
updatedAt: number;
}
export interface VFSProject {
id: string;
name: string;
type: 'REACT' | 'NODE' | 'HTML' | 'PYTHON';
rootFolderId: string;
createdAt: number;
lastOpened: number;
}
// --- SENSORY INTELLIGENCE TYPES (NEW PHASE 2) ---
export interface ScreenContext {
activeTab: string;
activeFile?: { name: string; content: string };
metrics: SystemMetrics;
}
export interface LogEntry {
timestamp: number;
type: 'ERROR' | 'WARN' | 'LOG' | 'NETWORK';
message: string;
details?: any;
}
export interface SemanticNode {
role: string;
name: string;
value?: string;
children?: SemanticNode[];
}