bashbros 0.1.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 (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +453 -0
  3. package/dist/audit-MCFNGOIM.js +11 -0
  4. package/dist/audit-MCFNGOIM.js.map +1 -0
  5. package/dist/chunk-43W3RVEL.js +2910 -0
  6. package/dist/chunk-43W3RVEL.js.map +1 -0
  7. package/dist/chunk-4R4GV5V2.js +213 -0
  8. package/dist/chunk-4R4GV5V2.js.map +1 -0
  9. package/dist/chunk-7OCVIDC7.js +12 -0
  10. package/dist/chunk-7OCVIDC7.js.map +1 -0
  11. package/dist/chunk-CSRPOGHY.js +354 -0
  12. package/dist/chunk-CSRPOGHY.js.map +1 -0
  13. package/dist/chunk-DEAF6PYM.js +212 -0
  14. package/dist/chunk-DEAF6PYM.js.map +1 -0
  15. package/dist/chunk-DLP2O6PN.js +273 -0
  16. package/dist/chunk-DLP2O6PN.js.map +1 -0
  17. package/dist/chunk-GD5VNHIN.js +519 -0
  18. package/dist/chunk-GD5VNHIN.js.map +1 -0
  19. package/dist/chunk-ID2O2QTI.js +269 -0
  20. package/dist/chunk-ID2O2QTI.js.map +1 -0
  21. package/dist/chunk-J37RHCFJ.js +357 -0
  22. package/dist/chunk-J37RHCFJ.js.map +1 -0
  23. package/dist/chunk-SB4JS3GU.js +456 -0
  24. package/dist/chunk-SB4JS3GU.js.map +1 -0
  25. package/dist/chunk-SG752FZC.js +200 -0
  26. package/dist/chunk-SG752FZC.js.map +1 -0
  27. package/dist/cli.d.ts +2 -0
  28. package/dist/cli.js +2448 -0
  29. package/dist/cli.js.map +1 -0
  30. package/dist/config-CZMIGNPF.js +13 -0
  31. package/dist/config-CZMIGNPF.js.map +1 -0
  32. package/dist/config-parser-XHE7BC7H.js +13 -0
  33. package/dist/config-parser-XHE7BC7H.js.map +1 -0
  34. package/dist/db-EHQDB5OL.js +11 -0
  35. package/dist/db-EHQDB5OL.js.map +1 -0
  36. package/dist/display-IN4NRJJS.js +18 -0
  37. package/dist/display-IN4NRJJS.js.map +1 -0
  38. package/dist/engine-PKLXW6OF.js +9 -0
  39. package/dist/engine-PKLXW6OF.js.map +1 -0
  40. package/dist/index.d.ts +1498 -0
  41. package/dist/index.js +552 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/moltbot-DXZFVK3X.js +11 -0
  44. package/dist/moltbot-DXZFVK3X.js.map +1 -0
  45. package/dist/ollama-HY35OHW4.js +9 -0
  46. package/dist/ollama-HY35OHW4.js.map +1 -0
  47. package/dist/risk-scorer-Y6KF2XCZ.js +9 -0
  48. package/dist/risk-scorer-Y6KF2XCZ.js.map +1 -0
  49. package/dist/static/index.html +410 -0
  50. package/package.json +68 -0
@@ -0,0 +1,1498 @@
1
+ import { EventEmitter } from 'events';
2
+
3
+ interface BashBrosConfig {
4
+ agent: AgentType;
5
+ profile: SecurityProfile;
6
+ commands: CommandPolicy;
7
+ paths: PathPolicy;
8
+ secrets: SecretsPolicy;
9
+ audit: AuditPolicy;
10
+ rateLimit: RateLimitPolicy;
11
+ riskScoring: RiskScoringPolicy;
12
+ loopDetection: LoopDetectionPolicy;
13
+ anomalyDetection: AnomalyDetectionPolicy;
14
+ outputScanning: OutputScanningPolicy;
15
+ undo: UndoPolicy;
16
+ ward: WardPolicy;
17
+ dashboard: DashboardPolicy;
18
+ }
19
+ type AgentType = 'claude-code' | 'clawdbot' | 'moltbot' | 'gemini-cli' | 'aider' | 'opencode' | 'custom';
20
+ interface MoltbotGatewayInfo {
21
+ port: number;
22
+ host: string;
23
+ sandboxMode: boolean;
24
+ authToken?: boolean;
25
+ }
26
+ interface MoltbotSessionContext {
27
+ inMoltbotSession: boolean;
28
+ sessionId?: string;
29
+ agentName?: string;
30
+ sandboxMode: boolean;
31
+ customConfigPath?: string;
32
+ }
33
+ interface MoltbotSecurityAuditResult {
34
+ passed: boolean;
35
+ findings: MoltbotSecurityFinding[];
36
+ timestamp: Date;
37
+ }
38
+ interface MoltbotSecurityFinding {
39
+ severity: 'info' | 'warning' | 'critical';
40
+ category: string;
41
+ message: string;
42
+ recommendation?: string;
43
+ }
44
+ type SecurityProfile = 'balanced' | 'strict' | 'permissive' | 'custom';
45
+ interface CommandPolicy {
46
+ allow: string[];
47
+ block: string[];
48
+ }
49
+ interface PathPolicy {
50
+ allow: string[];
51
+ block: string[];
52
+ }
53
+ interface SecretsPolicy {
54
+ enabled: boolean;
55
+ mode: 'block' | 'audit';
56
+ patterns: string[];
57
+ }
58
+ interface AuditPolicy {
59
+ enabled: boolean;
60
+ destination: 'local' | 'remote' | 'both';
61
+ remotePath?: string;
62
+ }
63
+ interface RateLimitPolicy {
64
+ enabled: boolean;
65
+ maxPerMinute: number;
66
+ maxPerHour: number;
67
+ }
68
+ interface RiskScoringPolicy {
69
+ enabled: boolean;
70
+ blockThreshold: number;
71
+ warnThreshold: number;
72
+ customPatterns: RiskPattern[];
73
+ }
74
+ interface RiskPattern {
75
+ pattern: string;
76
+ score: number;
77
+ factor: string;
78
+ }
79
+ interface LoopDetectionPolicy {
80
+ enabled: boolean;
81
+ maxRepeats: number;
82
+ maxTurns: number;
83
+ similarityThreshold: number;
84
+ cooldownMs: number;
85
+ windowSize: number;
86
+ action: 'warn' | 'block';
87
+ }
88
+ interface AnomalyDetectionPolicy {
89
+ enabled: boolean;
90
+ workingHours: [number, number];
91
+ typicalCommandsPerMinute: number;
92
+ learningCommands: number;
93
+ suspiciousPatterns: string[];
94
+ action: 'warn' | 'block';
95
+ }
96
+ interface OutputScanningPolicy {
97
+ enabled: boolean;
98
+ scanForSecrets: boolean;
99
+ scanForErrors: boolean;
100
+ maxOutputLength: number;
101
+ redactPatterns: string[];
102
+ }
103
+ interface UndoPolicy {
104
+ enabled: boolean;
105
+ maxStackSize: number;
106
+ maxFileSize: number;
107
+ ttlMinutes: number;
108
+ backupPath: string;
109
+ }
110
+ interface CommandResult {
111
+ command: string;
112
+ allowed: boolean;
113
+ output?: string;
114
+ error?: string;
115
+ exitCode?: number;
116
+ duration: number;
117
+ violations: PolicyViolation[];
118
+ }
119
+ interface PolicyViolation {
120
+ type: 'command' | 'path' | 'secrets' | 'rate_limit';
121
+ rule: string;
122
+ message: string;
123
+ }
124
+ interface AuditEntry {
125
+ timestamp: Date;
126
+ command: string;
127
+ allowed: boolean;
128
+ violations: PolicyViolation[];
129
+ exitCode?: number;
130
+ duration: number;
131
+ agent: AgentType;
132
+ }
133
+ interface WardPolicy {
134
+ enabled: boolean;
135
+ exposure: {
136
+ scanInterval: number;
137
+ externalProbe: boolean;
138
+ severityActions: {
139
+ low: 'alert' | 'block' | 'block_and_kill';
140
+ medium: 'alert' | 'block' | 'block_and_kill';
141
+ high: 'alert' | 'block' | 'block_and_kill';
142
+ critical: 'alert' | 'block' | 'block_and_kill';
143
+ };
144
+ };
145
+ connectors: {
146
+ proxyAllMcp: boolean;
147
+ telemetryRetention: string;
148
+ };
149
+ egress: {
150
+ defaultAction: 'block' | 'alert' | 'log';
151
+ patternsFile?: string;
152
+ };
153
+ }
154
+ interface DashboardPolicy {
155
+ enabled: boolean;
156
+ port: number;
157
+ bind: string;
158
+ }
159
+
160
+ declare class BashBros extends EventEmitter {
161
+ private config;
162
+ private policy;
163
+ private audit;
164
+ private ptyProcess;
165
+ private shell;
166
+ private pendingCommand;
167
+ private commandStartTime;
168
+ constructor(configPath?: string);
169
+ start(): void;
170
+ execute(command: string): CommandResult;
171
+ validateOnly(command: string): PolicyViolation[];
172
+ isAllowed(command: string): boolean;
173
+ resize(cols: number, rows: number): void;
174
+ write(data: string): void;
175
+ stop(): void;
176
+ getConfig(): BashBrosConfig;
177
+ }
178
+
179
+ declare class PolicyEngine {
180
+ private config;
181
+ private commandFilter;
182
+ private pathSandbox;
183
+ private secretsGuard;
184
+ private rateLimiter;
185
+ constructor(config: BashBrosConfig);
186
+ validate(command: string): PolicyViolation[];
187
+ private extractPaths;
188
+ isAllowed(command: string): boolean;
189
+ }
190
+
191
+ declare function loadConfig(path?: string): BashBrosConfig;
192
+
193
+ declare class AuditLogger {
194
+ private policy;
195
+ private logPath;
196
+ private lockPath;
197
+ constructor(policy: AuditPolicy);
198
+ log(entry: AuditEntry): void;
199
+ private formatEntry;
200
+ /**
201
+ * SECURITY FIX: Write with file locking and rotation
202
+ */
203
+ private writeLocal;
204
+ /**
205
+ * Simple file-based locking
206
+ */
207
+ private acquireLock;
208
+ private releaseLock;
209
+ private sleep;
210
+ /**
211
+ * Rotate log if it exceeds max size
212
+ */
213
+ private rotateIfNeeded;
214
+ /**
215
+ * SECURITY FIX: Secure remote transmission with HTTPS enforcement
216
+ */
217
+ private sendRemote;
218
+ getLogPath(): string;
219
+ }
220
+
221
+ /**
222
+ * Add a command to the session allowlist
223
+ */
224
+ declare function allowForSession(command: string): void;
225
+ /**
226
+ * Check if a command is allowed for this session
227
+ */
228
+ declare function isAllowedForSession(command: string): boolean;
229
+ /**
230
+ * Get all commands allowed for this session
231
+ */
232
+ declare function getSessionAllowlist(): string[];
233
+ /**
234
+ * Clear the session allowlist
235
+ */
236
+ declare function clearSessionAllowlist(): void;
237
+
238
+ interface SystemProfile {
239
+ platform: string;
240
+ arch: string;
241
+ shell: string;
242
+ cpuCores: number;
243
+ memoryGB: number;
244
+ python: VersionInfo | null;
245
+ node: VersionInfo | null;
246
+ rust: VersionInfo | null;
247
+ go: VersionInfo | null;
248
+ java: VersionInfo | null;
249
+ ruby: VersionInfo | null;
250
+ npm: VersionInfo | null;
251
+ pnpm: VersionInfo | null;
252
+ yarn: VersionInfo | null;
253
+ pip: VersionInfo | null;
254
+ cargo: VersionInfo | null;
255
+ brew: VersionInfo | null;
256
+ git: VersionInfo | null;
257
+ docker: VersionInfo | null;
258
+ kubectl: VersionInfo | null;
259
+ aws: VersionInfo | null;
260
+ gcloud: VersionInfo | null;
261
+ claude: boolean;
262
+ clawdbot: boolean;
263
+ aider: boolean;
264
+ ollama: OllamaInfo | null;
265
+ projectType: string | null;
266
+ projectDeps: string[];
267
+ envVars: string[];
268
+ commonCommands: CommandPattern[];
269
+ workingHours: string | null;
270
+ preferredEditor: string | null;
271
+ timestamp: Date;
272
+ }
273
+ interface VersionInfo {
274
+ version: string;
275
+ path: string;
276
+ }
277
+ interface OllamaInfo {
278
+ version: string;
279
+ models: string[];
280
+ }
281
+ interface CommandPattern {
282
+ command: string;
283
+ frequency: number;
284
+ lastUsed: Date;
285
+ }
286
+ declare class SystemProfiler {
287
+ private profile;
288
+ private profilePath;
289
+ constructor();
290
+ scan(): Promise<SystemProfile>;
291
+ scanProject(projectPath: string): Partial<SystemProfile>;
292
+ private detectShell;
293
+ /**
294
+ * SECURITY FIX: Use execFileSync with array args instead of string concatenation
295
+ */
296
+ private getVersionSafe;
297
+ private parseVersion;
298
+ /**
299
+ * SECURITY FIX: Use execFileSync for which/where command
300
+ */
301
+ private getCommandPathSafe;
302
+ private commandExists;
303
+ private getOllamaInfo;
304
+ private getEnvVarNames;
305
+ private detectEditor;
306
+ private detectProjectType;
307
+ private detectDependencies;
308
+ load(): SystemProfile | null;
309
+ private save;
310
+ get(): SystemProfile | null;
311
+ toContext(): string;
312
+ }
313
+
314
+ type RouteDecision = 'bro' | 'main' | 'both';
315
+ interface RoutingResult {
316
+ decision: RouteDecision;
317
+ reason: string;
318
+ confidence: number;
319
+ }
320
+ declare class TaskRouter {
321
+ private rules;
322
+ private profile;
323
+ constructor(profile?: SystemProfile | null);
324
+ private buildDefaultRules;
325
+ route(command: string): RoutingResult;
326
+ private looksSimple;
327
+ addRule(pattern: RegExp, route: RouteDecision, reason: string): void;
328
+ updateProfile(profile: SystemProfile): void;
329
+ }
330
+
331
+ interface Suggestion {
332
+ command: string;
333
+ description: string;
334
+ confidence: number;
335
+ source: 'pattern' | 'history' | 'context' | 'model';
336
+ }
337
+ declare class CommandSuggester {
338
+ private history;
339
+ private profile;
340
+ private patterns;
341
+ constructor(profile?: SystemProfile | null);
342
+ private initPatterns;
343
+ suggest(context: SuggestionContext): Suggestion[];
344
+ private suggestFromPatterns;
345
+ private suggestFromHistory;
346
+ private suggestFromContext;
347
+ private dedupeAndRank;
348
+ recordCommand(entry: AuditEntry): void;
349
+ updateProfile(profile: SystemProfile): void;
350
+ }
351
+ interface SuggestionContext {
352
+ lastCommand?: string;
353
+ lastOutput?: string;
354
+ lastError?: string;
355
+ cwd?: string;
356
+ projectType?: string;
357
+ files?: string[];
358
+ }
359
+
360
+ interface BackgroundTask {
361
+ id: string;
362
+ command: string;
363
+ status: 'running' | 'completed' | 'failed' | 'cancelled';
364
+ startTime: Date;
365
+ endTime?: Date;
366
+ output: string[];
367
+ exitCode?: number;
368
+ }
369
+ declare class BackgroundWorker extends EventEmitter {
370
+ private tasks;
371
+ private processes;
372
+ private taskIdCounter;
373
+ spawn(command: string, cwd?: string): BackgroundTask;
374
+ cancel(taskId: string): boolean;
375
+ getTask(taskId: string): BackgroundTask | undefined;
376
+ getRunningTasks(): BackgroundTask[];
377
+ getAllTasks(): BackgroundTask[];
378
+ getRecentTasks(limit?: number): BackgroundTask[];
379
+ private cleanupOldTasks;
380
+ private notifyCompletion;
381
+ formatStatus(): string;
382
+ }
383
+
384
+ interface BroConfig {
385
+ modelEndpoint?: string;
386
+ modelName?: string;
387
+ enableSuggestions?: boolean;
388
+ enableRouting?: boolean;
389
+ enableBackground?: boolean;
390
+ enableOllama?: boolean;
391
+ enableBashgymIntegration?: boolean;
392
+ }
393
+ declare class BashBro extends EventEmitter {
394
+ private profiler;
395
+ private router;
396
+ private suggester;
397
+ private worker;
398
+ private ollama;
399
+ private profile;
400
+ private config;
401
+ private ollamaAvailable;
402
+ private bashgymModelVersion;
403
+ constructor(config?: BroConfig);
404
+ /**
405
+ * Initialize bashgym integration for model hot-swap
406
+ */
407
+ private initBashgymIntegration;
408
+ /**
409
+ * Handle model update from bashgym (hot-swap)
410
+ */
411
+ private handleModelUpdate;
412
+ initialize(): Promise<void>;
413
+ private isProfileStale;
414
+ scanProject(projectPath: string): void;
415
+ route(command: string): RoutingResult;
416
+ suggest(context: SuggestionContext): Suggestion[];
417
+ /**
418
+ * SECURITY FIX: Safe command execution with validation
419
+ */
420
+ execute(command: string): Promise<string>;
421
+ runBackground(command: string, cwd?: string): BackgroundTask;
422
+ cancelBackground(taskId: string): boolean;
423
+ getBackgroundTasks(): BackgroundTask[];
424
+ getSystemContext(): string;
425
+ getProfile(): SystemProfile | null;
426
+ /**
427
+ * Check if Ollama is available for AI features
428
+ */
429
+ isOllamaAvailable(): boolean;
430
+ /**
431
+ * Ask Bash Bro (via Ollama) to suggest the next command
432
+ */
433
+ aiSuggest(context: string): Promise<string | null>;
434
+ /**
435
+ * Ask Bash Bro to explain a command
436
+ */
437
+ aiExplain(command: string): Promise<string>;
438
+ /**
439
+ * Ask Bash Bro to fix a failed command
440
+ */
441
+ aiFix(command: string, error: string): Promise<string | null>;
442
+ /**
443
+ * Set the Ollama model to use
444
+ */
445
+ setModel(model: string): void;
446
+ /**
447
+ * Generate a shell script from natural language description
448
+ */
449
+ aiGenerateScript(description: string): Promise<string | null>;
450
+ /**
451
+ * Analyze command for security risks using AI
452
+ */
453
+ aiAnalyzeSafety(command: string): Promise<{
454
+ safe: boolean;
455
+ risk: 'low' | 'medium' | 'high' | 'critical';
456
+ explanation: string;
457
+ suggestions: string[];
458
+ }>;
459
+ /**
460
+ * Summarize a terminal session
461
+ */
462
+ aiSummarize(commands: {
463
+ command: string;
464
+ output?: string;
465
+ error?: string;
466
+ }[]): Promise<string>;
467
+ /**
468
+ * Get AI help for a topic or command
469
+ */
470
+ aiHelp(topic: string): Promise<string>;
471
+ /**
472
+ * Convert natural language to command
473
+ */
474
+ aiToCommand(description: string): Promise<string | null>;
475
+ /**
476
+ * Get bashgym sidekick model version (if using)
477
+ */
478
+ getBashgymModelVersion(): string | null;
479
+ /**
480
+ * Check if using bashgym-trained sidekick model
481
+ */
482
+ isUsingBashgymModel(): boolean;
483
+ /**
484
+ * Force refresh the bashgym model (check for updates)
485
+ */
486
+ refreshBashgymModel(): boolean;
487
+ status(): string;
488
+ }
489
+
490
+ /**
491
+ * Simple Ollama client for local model inference.
492
+ * Keeps it minimal - just what we need for Bash Bro.
493
+ */
494
+ interface OllamaConfig {
495
+ host: string;
496
+ model: string;
497
+ timeout: number;
498
+ }
499
+ interface ChatMessage {
500
+ role: 'system' | 'user' | 'assistant';
501
+ content: string;
502
+ }
503
+ declare class OllamaClient {
504
+ private config;
505
+ constructor(config?: Partial<OllamaConfig>);
506
+ /**
507
+ * Check if Ollama is running and accessible
508
+ */
509
+ isAvailable(): Promise<boolean>;
510
+ /**
511
+ * List available models
512
+ */
513
+ listModels(): Promise<string[]>;
514
+ /**
515
+ * Generate a response from the model
516
+ */
517
+ generate(prompt: string, systemPrompt?: string): Promise<string>;
518
+ /**
519
+ * Chat with the model (multi-turn conversation)
520
+ */
521
+ chat(messages: ChatMessage[]): Promise<string>;
522
+ /**
523
+ * Ask Bash Bro to suggest a command
524
+ */
525
+ suggestCommand(context: string): Promise<string | null>;
526
+ /**
527
+ * Ask Bash Bro to explain a command
528
+ */
529
+ explainCommand(command: string): Promise<string>;
530
+ /**
531
+ * Ask Bash Bro to fix a command that failed
532
+ */
533
+ fixCommand(command: string, error: string): Promise<string | null>;
534
+ setModel(model: string): void;
535
+ getModel(): string;
536
+ /**
537
+ * Generate a shell script from a natural language description
538
+ */
539
+ generateScript(description: string, shell?: string): Promise<string | null>;
540
+ /**
541
+ * Analyze command safety and provide recommendations
542
+ */
543
+ analyzeCommandSafety(command: string): Promise<{
544
+ safe: boolean;
545
+ risk: 'low' | 'medium' | 'high' | 'critical';
546
+ explanation: string;
547
+ suggestions: string[];
548
+ }>;
549
+ /**
550
+ * Summarize a series of commands and their outputs
551
+ */
552
+ summarizeSession(commands: {
553
+ command: string;
554
+ output?: string;
555
+ error?: string;
556
+ }[]): Promise<string>;
557
+ /**
558
+ * Get help for a specific tool or command
559
+ */
560
+ getHelp(topic: string): Promise<string>;
561
+ /**
562
+ * Convert natural language to a command
563
+ */
564
+ naturalToCommand(description: string): Promise<string | null>;
565
+ }
566
+
567
+ /**
568
+ * Command Risk Scoring
569
+ * Scores commands 1-10 based on potential danger
570
+ */
571
+ interface RiskScore {
572
+ score: number;
573
+ level: 'safe' | 'caution' | 'dangerous' | 'critical';
574
+ factors: string[];
575
+ }
576
+ declare class RiskScorer {
577
+ private customPatterns;
578
+ /**
579
+ * Score a command's risk level
580
+ */
581
+ score(command: string): RiskScore;
582
+ private applyHeuristics;
583
+ private scoreToLevel;
584
+ /**
585
+ * Add custom risk patterns
586
+ */
587
+ addPattern(pattern: RegExp, score: number, factor: string): void;
588
+ /**
589
+ * Check if command should be blocked based on score threshold
590
+ */
591
+ shouldBlock(command: string, threshold?: number): boolean;
592
+ /**
593
+ * Get color for terminal display
594
+ */
595
+ static levelColor(level: RiskScore['level']): string;
596
+ }
597
+
598
+ /**
599
+ * Loop Detection
600
+ * Detects when agents get stuck in repetitive patterns
601
+ */
602
+ interface LoopConfig {
603
+ maxRepeats: number;
604
+ maxTurns: number;
605
+ similarityThreshold: number;
606
+ cooldownMs: number;
607
+ windowSize: number;
608
+ }
609
+ interface LoopAlert {
610
+ type: 'exact_repeat' | 'semantic_repeat' | 'tool_hammering' | 'max_turns';
611
+ command: string;
612
+ count: number;
613
+ message: string;
614
+ }
615
+ declare class LoopDetector {
616
+ private config;
617
+ private history;
618
+ private turnCount;
619
+ constructor(config?: Partial<LoopConfig>);
620
+ /**
621
+ * Record a command and check for loops
622
+ */
623
+ check(command: string): LoopAlert | null;
624
+ /**
625
+ * Normalize command for comparison
626
+ */
627
+ private normalize;
628
+ /**
629
+ * Calculate similarity between two strings (Jaccard index on words)
630
+ */
631
+ private similarity;
632
+ /**
633
+ * Get current turn count
634
+ */
635
+ getTurnCount(): number;
636
+ /**
637
+ * Get command frequency map
638
+ */
639
+ getFrequencyMap(): Map<string, number>;
640
+ /**
641
+ * Reset detector state
642
+ */
643
+ reset(): void;
644
+ /**
645
+ * Get stats for reporting
646
+ */
647
+ getStats(): {
648
+ turnCount: number;
649
+ uniqueCommands: number;
650
+ topCommands: [string, number][];
651
+ };
652
+ }
653
+
654
+ /**
655
+ * Anomaly Detection
656
+ * Flag unusual patterns without ML
657
+ */
658
+ interface AnomalyConfig {
659
+ workingHours?: [number, number];
660
+ typicalCommandsPerMinute?: number;
661
+ knownPaths?: string[];
662
+ suspiciousPatterns?: RegExp[];
663
+ enabled?: boolean;
664
+ }
665
+ interface Anomaly {
666
+ type: 'timing' | 'frequency' | 'path' | 'pattern' | 'behavior';
667
+ severity: 'info' | 'warning' | 'alert';
668
+ message: string;
669
+ details: Record<string, unknown>;
670
+ }
671
+ declare class AnomalyDetector {
672
+ private config;
673
+ private commands;
674
+ private baselinePaths;
675
+ private baselineCommands;
676
+ private learningMode;
677
+ private learningCount;
678
+ private readonly LEARNING_THRESHOLD;
679
+ constructor(config?: AnomalyConfig);
680
+ /**
681
+ * Check a command for anomalies
682
+ */
683
+ check(command: string, cwd?: string): Anomaly[];
684
+ /**
685
+ * Learn from command (build baseline)
686
+ */
687
+ private learn;
688
+ /**
689
+ * Check for timing anomalies
690
+ */
691
+ private checkTiming;
692
+ /**
693
+ * Check for frequency anomalies
694
+ */
695
+ private checkFrequency;
696
+ /**
697
+ * Check for unusual path access
698
+ */
699
+ private checkPath;
700
+ /**
701
+ * Check for suspicious patterns
702
+ */
703
+ private checkPatterns;
704
+ /**
705
+ * Check for behavioral anomalies
706
+ */
707
+ private checkBehavior;
708
+ /**
709
+ * Get anomaly stats
710
+ */
711
+ getStats(): {
712
+ learningMode: boolean;
713
+ learningProgress: number;
714
+ baselineCommands: number;
715
+ baselinePaths: number;
716
+ recentCommandRate: number;
717
+ };
718
+ /**
719
+ * Force end learning mode
720
+ */
721
+ endLearning(): void;
722
+ /**
723
+ * Reset and restart learning
724
+ */
725
+ reset(): void;
726
+ }
727
+
728
+ declare class CommandFilter {
729
+ private policy;
730
+ private allowPatterns;
731
+ private blockPatterns;
732
+ constructor(policy: CommandPolicy);
733
+ check(command: string): PolicyViolation | null;
734
+ private globToRegex;
735
+ }
736
+
737
+ declare class PathSandbox {
738
+ private policy;
739
+ private allowedPaths;
740
+ private blockedPaths;
741
+ constructor(policy: PathPolicy);
742
+ check(path: string): PolicyViolation | null;
743
+ /**
744
+ * SECURITY FIX: Resolve symlinks to detect escape attempts
745
+ */
746
+ private resolvePath;
747
+ private normalizePath;
748
+ /**
749
+ * Check if a path would escape the sandbox via symlink
750
+ */
751
+ isSymlinkEscape(path: string): boolean;
752
+ }
753
+
754
+ declare class SecretsGuard {
755
+ private policy;
756
+ private patterns;
757
+ constructor(policy: SecretsPolicy);
758
+ check(command: string, paths: string[]): PolicyViolation | null;
759
+ /**
760
+ * SECURITY FIX: Detect base64/hex encoded secret access
761
+ */
762
+ private containsEncodedSecretAccess;
763
+ private isSecretPath;
764
+ private globToRegex;
765
+ }
766
+
767
+ declare class RateLimiter {
768
+ private policy;
769
+ private minuteWindow;
770
+ private hourWindow;
771
+ constructor(policy: RateLimitPolicy);
772
+ check(): PolicyViolation | null;
773
+ record(): void;
774
+ private cleanup;
775
+ getStats(): {
776
+ minute: number;
777
+ hour: number;
778
+ };
779
+ }
780
+
781
+ /**
782
+ * Output Scanner
783
+ * Scan command output for leaked secrets and sensitive data
784
+ */
785
+
786
+ interface ScanResult {
787
+ hasSecrets: boolean;
788
+ hasErrors: boolean;
789
+ redactedOutput: string;
790
+ findings: Finding[];
791
+ }
792
+ interface Finding {
793
+ type: 'secret' | 'error' | 'sensitive';
794
+ pattern: string;
795
+ message: string;
796
+ line?: number;
797
+ }
798
+ declare class OutputScanner {
799
+ private secretPatterns;
800
+ private redactPatterns;
801
+ private policy;
802
+ constructor(policy: OutputScanningPolicy);
803
+ /**
804
+ * Scan output for secrets and sensitive data
805
+ */
806
+ scan(output: string): ScanResult;
807
+ /**
808
+ * Scan for secrets in output
809
+ */
810
+ private scanForSecrets;
811
+ /**
812
+ * Scan for error patterns in output
813
+ */
814
+ private scanForErrors;
815
+ /**
816
+ * Redact sensitive data from output
817
+ */
818
+ redact(output: string): string;
819
+ /**
820
+ * Check if output contains any secrets
821
+ */
822
+ hasSecrets(output: string): boolean;
823
+ /**
824
+ * Get summary of findings
825
+ */
826
+ static summarize(findings: Finding[]): string;
827
+ }
828
+
829
+ /**
830
+ * Session Metrics
831
+ * Track what the agent is doing for observability
832
+ */
833
+
834
+ interface CommandMetric {
835
+ command: string;
836
+ timestamp: Date;
837
+ duration: number;
838
+ allowed: boolean;
839
+ riskScore: RiskScore;
840
+ violations: PolicyViolation[];
841
+ exitCode?: number;
842
+ }
843
+ interface SessionMetrics {
844
+ sessionId: string;
845
+ startTime: Date;
846
+ endTime?: Date;
847
+ duration: number;
848
+ commandCount: number;
849
+ blockedCount: number;
850
+ uniqueCommands: number;
851
+ topCommands: [string, number][];
852
+ riskDistribution: {
853
+ safe: number;
854
+ caution: number;
855
+ dangerous: number;
856
+ critical: number;
857
+ };
858
+ avgRiskScore: number;
859
+ avgExecutionTime: number;
860
+ totalExecutionTime: number;
861
+ filesModified: string[];
862
+ pathsAccessed: string[];
863
+ violationsByType: Record<string, number>;
864
+ }
865
+ declare class MetricsCollector {
866
+ private sessionId;
867
+ private startTime;
868
+ private commands;
869
+ private filesModified;
870
+ private pathsAccessed;
871
+ constructor();
872
+ private generateSessionId;
873
+ /**
874
+ * Record a command execution
875
+ */
876
+ record(metric: CommandMetric): void;
877
+ /**
878
+ * Get current session metrics
879
+ */
880
+ getMetrics(): SessionMetrics;
881
+ /**
882
+ * Extract paths from a command
883
+ */
884
+ private extractPaths;
885
+ /**
886
+ * Check if command modifies files
887
+ */
888
+ private isWriteCommand;
889
+ /**
890
+ * Get recent commands
891
+ */
892
+ getRecentCommands(n?: number): CommandMetric[];
893
+ /**
894
+ * Get blocked commands
895
+ */
896
+ getBlockedCommands(): CommandMetric[];
897
+ /**
898
+ * Get high-risk commands
899
+ */
900
+ getHighRiskCommands(threshold?: number): CommandMetric[];
901
+ /**
902
+ * Format duration for display
903
+ */
904
+ static formatDuration(ms: number): string;
905
+ /**
906
+ * Reset collector
907
+ */
908
+ reset(): void;
909
+ }
910
+
911
+ /**
912
+ * Cost Estimation
913
+ * Estimate API costs based on session complexity
914
+ */
915
+ interface CostEstimate {
916
+ estimatedTokens: number;
917
+ estimatedCost: number;
918
+ breakdown: {
919
+ inputTokens: number;
920
+ outputTokens: number;
921
+ toolCalls: number;
922
+ contextTokens: number;
923
+ };
924
+ model: string;
925
+ confidence: 'low' | 'medium' | 'high';
926
+ }
927
+ interface ModelPricing {
928
+ inputPer1k: number;
929
+ outputPer1k: number;
930
+ }
931
+ declare class CostEstimator {
932
+ private model;
933
+ private pricing;
934
+ private totalInputTokens;
935
+ private totalOutputTokens;
936
+ private toolCallCount;
937
+ constructor(model?: string);
938
+ /**
939
+ * Estimate tokens from text
940
+ */
941
+ estimateTokens(text: string): number;
942
+ /**
943
+ * Record a tool call with input and output
944
+ */
945
+ recordToolCall(input: string, output?: string): void;
946
+ /**
947
+ * Get current cost estimate
948
+ */
949
+ getEstimate(): CostEstimate;
950
+ /**
951
+ * Format cost for display
952
+ */
953
+ static formatCost(cost: number): string;
954
+ /**
955
+ * Get cost projection for N more commands
956
+ */
957
+ projectCost(additionalCommands: number): CostEstimate;
958
+ /**
959
+ * Set model for pricing
960
+ */
961
+ setModel(model: string): void;
962
+ /**
963
+ * Reset counters
964
+ */
965
+ reset(): void;
966
+ /**
967
+ * Add custom model pricing
968
+ */
969
+ static addModelPricing(model: string, pricing: ModelPricing): void;
970
+ }
971
+
972
+ /**
973
+ * Session Reports
974
+ * Generate human-readable reports of agent activity
975
+ */
976
+
977
+ interface ReportOptions {
978
+ showCommands?: boolean;
979
+ showBlocked?: boolean;
980
+ showRisk?: boolean;
981
+ showPaths?: boolean;
982
+ showCost?: boolean;
983
+ format?: 'text' | 'json' | 'markdown';
984
+ }
985
+ declare class ReportGenerator {
986
+ /**
987
+ * Generate a session report
988
+ */
989
+ static generate(metrics: SessionMetrics, cost?: CostEstimate, options?: ReportOptions): string;
990
+ /**
991
+ * Generate text report
992
+ */
993
+ private static generateText;
994
+ /**
995
+ * Generate markdown report
996
+ */
997
+ private static generateMarkdown;
998
+ /**
999
+ * Generate JSON report
1000
+ */
1001
+ private static generateJSON;
1002
+ /**
1003
+ * Generate a simple progress bar
1004
+ */
1005
+ private static progressBar;
1006
+ /**
1007
+ * Format duration
1008
+ */
1009
+ private static formatDuration;
1010
+ /**
1011
+ * Format cost
1012
+ */
1013
+ private static formatCost;
1014
+ /**
1015
+ * Generate a one-line summary
1016
+ */
1017
+ static oneLine(metrics: SessionMetrics): string;
1018
+ }
1019
+
1020
+ /**
1021
+ * Claude Code Hook Integration
1022
+ * Seamlessly integrate BashBros with Claude Code
1023
+ */
1024
+ interface ClaudeSettings {
1025
+ hooks?: {
1026
+ PreToolUse?: HookConfig[];
1027
+ PostToolUse?: HookConfig[];
1028
+ SessionEnd?: HookConfig[];
1029
+ };
1030
+ [key: string]: unknown;
1031
+ }
1032
+ interface HookConfig {
1033
+ matcher?: string;
1034
+ hooks: {
1035
+ type: string;
1036
+ command: string;
1037
+ }[];
1038
+ }
1039
+ declare class ClaudeCodeHooks {
1040
+ /**
1041
+ * Check if Claude Code is installed
1042
+ */
1043
+ static isClaudeInstalled(): boolean;
1044
+ /**
1045
+ * Load current Claude settings
1046
+ */
1047
+ static loadSettings(): ClaudeSettings;
1048
+ /**
1049
+ * Save Claude settings
1050
+ */
1051
+ static saveSettings(settings: ClaudeSettings): void;
1052
+ /**
1053
+ * Install BashBros hooks into Claude Code
1054
+ */
1055
+ static install(): {
1056
+ success: boolean;
1057
+ message: string;
1058
+ };
1059
+ /**
1060
+ * Uninstall BashBros hooks from Claude Code
1061
+ */
1062
+ static uninstall(): {
1063
+ success: boolean;
1064
+ message: string;
1065
+ };
1066
+ /**
1067
+ * Check if BashBros hooks are installed
1068
+ */
1069
+ static isInstalled(settings?: ClaudeSettings): boolean;
1070
+ /**
1071
+ * Get hook status
1072
+ */
1073
+ static getStatus(): {
1074
+ claudeInstalled: boolean;
1075
+ hooksInstalled: boolean;
1076
+ hooks: string[];
1077
+ };
1078
+ }
1079
+ /**
1080
+ * Gate command - called by PreToolUse hook
1081
+ * Returns exit code 0 to allow, non-zero to block
1082
+ */
1083
+ declare function gateCommand(command: string): Promise<{
1084
+ allowed: boolean;
1085
+ reason?: string;
1086
+ riskScore?: number;
1087
+ }>;
1088
+
1089
+ /**
1090
+ * Moltbot Hook Integration
1091
+ * Seamlessly integrate BashBros with Moltbot (formerly clawd.bot)
1092
+ */
1093
+
1094
+ interface MoltbotSettings {
1095
+ hooks?: {
1096
+ preBash?: MoltbotHookEntry[];
1097
+ postBash?: MoltbotHookEntry[];
1098
+ sessionEnd?: MoltbotHookEntry[];
1099
+ };
1100
+ gateway?: {
1101
+ port?: number;
1102
+ host?: string;
1103
+ auth?: unknown;
1104
+ };
1105
+ agents?: {
1106
+ defaults?: {
1107
+ sandbox?: {
1108
+ mode?: string;
1109
+ };
1110
+ };
1111
+ };
1112
+ [key: string]: unknown;
1113
+ }
1114
+ interface MoltbotHookEntry {
1115
+ command: string;
1116
+ [key: string]: unknown;
1117
+ }
1118
+ interface MoltbotStatus {
1119
+ moltbotInstalled: boolean;
1120
+ clawdbotInstalled: boolean;
1121
+ hooksInstalled: boolean;
1122
+ hooks: string[];
1123
+ configPath: string | null;
1124
+ gatewayRunning: boolean;
1125
+ sandboxMode: string | null;
1126
+ }
1127
+ interface MoltbotGatewayStatus {
1128
+ running: boolean;
1129
+ port: number;
1130
+ host: string;
1131
+ sandboxMode: boolean;
1132
+ error?: string;
1133
+ }
1134
+ declare class MoltbotHooks {
1135
+ /**
1136
+ * Check if moltbot command is installed
1137
+ */
1138
+ static isMoltbotInstalled(): boolean;
1139
+ /**
1140
+ * Check if clawdbot command is installed (legacy)
1141
+ */
1142
+ static isClawdbotInstalled(): boolean;
1143
+ /**
1144
+ * Find the config file path
1145
+ */
1146
+ static findConfigPath(): string | null;
1147
+ /**
1148
+ * Get the config directory (creating if needed)
1149
+ */
1150
+ static getConfigDir(): string;
1151
+ /**
1152
+ * Load current moltbot settings
1153
+ */
1154
+ static loadSettings(): MoltbotSettings;
1155
+ /**
1156
+ * Save moltbot settings
1157
+ */
1158
+ static saveSettings(settings: MoltbotSettings): void;
1159
+ /**
1160
+ * Install BashBros hooks into moltbot
1161
+ */
1162
+ static install(): {
1163
+ success: boolean;
1164
+ message: string;
1165
+ };
1166
+ /**
1167
+ * Uninstall BashBros hooks from moltbot
1168
+ */
1169
+ static uninstall(): {
1170
+ success: boolean;
1171
+ message: string;
1172
+ };
1173
+ /**
1174
+ * Check if BashBros hooks are installed
1175
+ */
1176
+ static isInstalled(settings?: MoltbotSettings): boolean;
1177
+ /**
1178
+ * Check if moltbot gateway is running
1179
+ */
1180
+ static isGatewayRunning(): Promise<boolean>;
1181
+ /**
1182
+ * Get gateway status
1183
+ */
1184
+ static getGatewayStatus(): Promise<MoltbotGatewayStatus>;
1185
+ /**
1186
+ * Get gateway info (for type system)
1187
+ */
1188
+ static getGatewayInfo(): Promise<MoltbotGatewayInfo | null>;
1189
+ /**
1190
+ * Run security audit using moltbot CLI
1191
+ */
1192
+ static runSecurityAudit(): Promise<MoltbotSecurityAuditResult>;
1193
+ /**
1194
+ * Run basic security checks when moltbot audit is not available
1195
+ */
1196
+ private static runBasicSecurityChecks;
1197
+ /**
1198
+ * Get comprehensive hook status
1199
+ */
1200
+ static getStatus(): MoltbotStatus;
1201
+ }
1202
+ declare function getMoltbotHooks(): typeof MoltbotHooks;
1203
+
1204
+ /**
1205
+ * Moltbot Runtime Session Detection
1206
+ * Detects when running inside a moltbot session via environment variables
1207
+ */
1208
+
1209
+ /**
1210
+ * Detect if we're running inside a moltbot session
1211
+ * Checks environment variables set by moltbot when spawning commands
1212
+ */
1213
+ declare function detectMoltbotSession(): MoltbotSessionContext;
1214
+ /**
1215
+ * Check if we're in a moltbot session (simple boolean check)
1216
+ */
1217
+ declare function isInMoltbotSession(): boolean;
1218
+ /**
1219
+ * Get the moltbot session ID if running in a session
1220
+ */
1221
+ declare function getMoltbotSessionId(): string | undefined;
1222
+ /**
1223
+ * Get the moltbot agent name if running in a session
1224
+ */
1225
+ declare function getMoltbotAgentName(): string | undefined;
1226
+ /**
1227
+ * Check if sandbox mode is enabled in the current session
1228
+ */
1229
+ declare function isSandboxEnabled(): boolean;
1230
+
1231
+ /**
1232
+ * Undo Stack
1233
+ * Track file changes for rollback capability
1234
+ */
1235
+
1236
+ interface UndoEntry {
1237
+ id: string;
1238
+ timestamp: Date;
1239
+ path: string;
1240
+ operation: 'create' | 'modify' | 'delete';
1241
+ backupPath?: string;
1242
+ originalContent?: string;
1243
+ command?: string;
1244
+ }
1245
+ interface UndoResult {
1246
+ success: boolean;
1247
+ message: string;
1248
+ entry?: UndoEntry;
1249
+ }
1250
+ interface UndoConfig {
1251
+ maxStackSize: number;
1252
+ maxFileSize: number;
1253
+ ttlMinutes: number;
1254
+ backupPath: string;
1255
+ enabled: boolean;
1256
+ }
1257
+ declare class UndoStack {
1258
+ private stack;
1259
+ private sessionId;
1260
+ private config;
1261
+ private undoDir;
1262
+ constructor(policy?: Partial<UndoPolicy>);
1263
+ private ensureUndoDir;
1264
+ /**
1265
+ * Clean up backups older than TTL
1266
+ */
1267
+ cleanupOldBackups(): number;
1268
+ private generateId;
1269
+ /**
1270
+ * Check if undo is enabled
1271
+ */
1272
+ isEnabled(): boolean;
1273
+ /**
1274
+ * Record a file creation
1275
+ */
1276
+ recordCreate(path: string, command?: string): UndoEntry;
1277
+ /**
1278
+ * Record a file modification (backs up original)
1279
+ */
1280
+ recordModify(path: string, command?: string): UndoEntry | null;
1281
+ /**
1282
+ * Record a file deletion (backs up content)
1283
+ */
1284
+ recordDelete(path: string, command?: string): UndoEntry | null;
1285
+ /**
1286
+ * Auto-detect operation from command
1287
+ */
1288
+ recordFromCommand(command: string, paths: string[]): UndoEntry[];
1289
+ /**
1290
+ * Undo the last operation
1291
+ */
1292
+ undo(): UndoResult;
1293
+ /**
1294
+ * Undo a specific entry
1295
+ */
1296
+ undoEntry(entry: UndoEntry): UndoResult;
1297
+ /**
1298
+ * Undo all operations in the session
1299
+ */
1300
+ undoAll(): UndoResult[];
1301
+ /**
1302
+ * Get the undo stack
1303
+ */
1304
+ getStack(): UndoEntry[];
1305
+ /**
1306
+ * Get stack size
1307
+ */
1308
+ size(): number;
1309
+ /**
1310
+ * Clear the stack (and backups)
1311
+ */
1312
+ clear(): void;
1313
+ /**
1314
+ * Push entry to stack
1315
+ */
1316
+ private push;
1317
+ /**
1318
+ * Format stack for display
1319
+ */
1320
+ formatStack(): string;
1321
+ }
1322
+
1323
+ /**
1324
+ * Bashgym Integration for Bashbros
1325
+ *
1326
+ * Provides integration between bashbros (security middleware + AI sidekick) and
1327
+ * bashgym (self-improving agent training) through a shared directory protocol.
1328
+ *
1329
+ * Key features:
1330
+ * - Trace export to shared directory
1331
+ * - Settings synchronization
1332
+ * - Model update watcher for hot-swap
1333
+ *
1334
+ * Data Flow:
1335
+ * bashbros captures traces -> bashgym trains -> GGUF to Ollama -> bashbros sidekick improves
1336
+ */
1337
+
1338
+ type CaptureMode = 'everything' | 'successful_only' | 'sidekick_curated';
1339
+ type TrainingTrigger = 'manual' | 'quality_based' | 'scheduled';
1340
+ interface IntegrationSettings {
1341
+ version: string;
1342
+ updated_at: string | null;
1343
+ updated_by: string | null;
1344
+ integration: {
1345
+ enabled: boolean;
1346
+ linked_at: string | null;
1347
+ };
1348
+ capture: {
1349
+ mode: CaptureMode;
1350
+ auto_stream: boolean;
1351
+ };
1352
+ training: {
1353
+ auto_enabled: boolean;
1354
+ quality_threshold: number;
1355
+ trigger: TrainingTrigger;
1356
+ };
1357
+ security: {
1358
+ bashbros_primary: boolean;
1359
+ policy_path: string | null;
1360
+ };
1361
+ model_sync: {
1362
+ auto_export_ollama: boolean;
1363
+ ollama_model_name: string;
1364
+ notify_on_update: boolean;
1365
+ };
1366
+ }
1367
+ interface TraceData {
1368
+ version: string;
1369
+ metadata: {
1370
+ user_initial_prompt: string;
1371
+ source_tool: string;
1372
+ task_id?: string;
1373
+ verification_passed: boolean;
1374
+ capture_mode: CaptureMode;
1375
+ session_id: string;
1376
+ };
1377
+ trace: TraceStep[];
1378
+ bashbros_extensions: {
1379
+ security_events: SecurityEvent[];
1380
+ sidekick_annotations: SidekickAnnotations;
1381
+ };
1382
+ }
1383
+ interface TraceStep {
1384
+ tool_name: string;
1385
+ command: string;
1386
+ output: string;
1387
+ success: boolean;
1388
+ exit_code?: number;
1389
+ timestamp: string;
1390
+ cwd?: string;
1391
+ }
1392
+ interface SecurityEvent {
1393
+ type: string;
1394
+ timestamp: string;
1395
+ command?: string;
1396
+ violation?: PolicyViolation;
1397
+ }
1398
+ interface SidekickAnnotations {
1399
+ teachable_moment: boolean;
1400
+ complexity: 'easy' | 'medium' | 'hard';
1401
+ tags?: string[];
1402
+ }
1403
+ interface ModelManifest {
1404
+ latest: string;
1405
+ versions: ModelVersion[];
1406
+ rollback_available: boolean;
1407
+ }
1408
+ interface ModelVersion {
1409
+ version: string;
1410
+ created: string;
1411
+ traces_used: number;
1412
+ quality_avg: number;
1413
+ gguf_path: string | null;
1414
+ }
1415
+ declare class BashgymIntegration extends EventEmitter {
1416
+ private integrationDir;
1417
+ private settings;
1418
+ private manifest;
1419
+ private settingsWatcher;
1420
+ private modelWatcher;
1421
+ private sessionId;
1422
+ private traceBuffer;
1423
+ private securityEvents;
1424
+ private currentPrompt;
1425
+ private tracesDir;
1426
+ private pendingDir;
1427
+ private modelsDir;
1428
+ private configDir;
1429
+ private statusDir;
1430
+ constructor(integrationDir?: string);
1431
+ /**
1432
+ * Initialize the integration
1433
+ */
1434
+ initialize(): Promise<boolean>;
1435
+ /**
1436
+ * Check if bashgym is available
1437
+ */
1438
+ isAvailable(): boolean;
1439
+ /**
1440
+ * Check if integration is linked
1441
+ */
1442
+ isLinked(): boolean;
1443
+ getSettings(): IntegrationSettings | null;
1444
+ private loadSettings;
1445
+ updateSettings(updates: Partial<IntegrationSettings>): void;
1446
+ /**
1447
+ * Start a new trace session
1448
+ */
1449
+ startSession(prompt: string): void;
1450
+ /**
1451
+ * Add a step to the current trace
1452
+ */
1453
+ addStep(step: Omit<TraceStep, 'timestamp'>): void;
1454
+ /**
1455
+ * Add a command result to the trace
1456
+ */
1457
+ addCommandResult(result: CommandResult): void;
1458
+ /**
1459
+ * Add a file operation to the trace
1460
+ */
1461
+ addFileOperation(operation: 'Read' | 'Write' | 'Edit', path: string, success: boolean, output?: string): void;
1462
+ /**
1463
+ * End the session and export the trace
1464
+ */
1465
+ endSession(verificationPassed?: boolean): Promise<string | null>;
1466
+ private clearSession;
1467
+ private determineTeachableMoment;
1468
+ private determineComplexity;
1469
+ /**
1470
+ * Get current model version
1471
+ */
1472
+ getCurrentModelVersion(): string | null;
1473
+ /**
1474
+ * Get model manifest
1475
+ */
1476
+ getModelManifest(): ModelManifest | null;
1477
+ private loadManifest;
1478
+ /**
1479
+ * Get path to latest GGUF model
1480
+ */
1481
+ getLatestModelPath(): string | null;
1482
+ /**
1483
+ * Get Ollama model name for sidekick
1484
+ */
1485
+ getOllamaModelName(): string;
1486
+ private startWatching;
1487
+ stopWatching(): void;
1488
+ private updateStatus;
1489
+ /**
1490
+ * Check if bashgym is actively running
1491
+ */
1492
+ isBashgymRunning(): boolean;
1493
+ dispose(): void;
1494
+ }
1495
+ declare function getBashgymIntegration(): BashgymIntegration;
1496
+ declare function resetBashgymIntegration(): void;
1497
+
1498
+ export { type AgentType, type Anomaly, type AnomalyConfig, type AnomalyDetectionPolicy, AnomalyDetector, type AuditEntry, AuditLogger, type AuditPolicy, type BackgroundTask, BackgroundWorker, BashBro, BashBros, type BashBrosConfig, BashgymIntegration, type BroConfig, type CaptureMode, ClaudeCodeHooks, type ClaudeSettings, CommandFilter, type CommandMetric, type CommandPolicy, type CommandResult, CommandSuggester, type CostEstimate, CostEstimator, type Finding, type IntegrationSettings, type LoopAlert, type LoopConfig, type LoopDetectionPolicy, LoopDetector, MetricsCollector, type ModelManifest, type ModelPricing, type ModelVersion, type MoltbotGatewayInfo, type MoltbotGatewayStatus, MoltbotHooks, type MoltbotSecurityAuditResult, type MoltbotSecurityFinding, type MoltbotSessionContext, type MoltbotSettings, type MoltbotStatus, OllamaClient, type OllamaInfo, OutputScanner, type OutputScanningPolicy, type PathPolicy, PathSandbox, PolicyEngine, type PolicyViolation, type RateLimitPolicy, RateLimiter, ReportGenerator, type ReportOptions, type RiskPattern, type RiskScore, RiskScorer, type RiskScoringPolicy, type RouteDecision, type RoutingResult, type ScanResult, SecretsGuard, type SecretsPolicy, type SecurityProfile, type SessionMetrics, type Suggestion, type SuggestionContext, type SystemProfile, SystemProfiler, TaskRouter, type TraceData, type TraceStep, type TrainingTrigger, type UndoConfig, type UndoEntry, type UndoPolicy, type UndoResult, UndoStack, type VersionInfo, allowForSession, clearSessionAllowlist, detectMoltbotSession, gateCommand, getBashgymIntegration, getMoltbotAgentName, getMoltbotHooks, getMoltbotSessionId, getSessionAllowlist, isAllowedForSession, isInMoltbotSession, isSandboxEnabled, loadConfig, resetBashgymIntegration };