cliskill 1.1.7 → 1.2.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.
- package/dist/bootstrap/cli.js +2 -2
- package/dist/{chunk-S7IQHES2.js → chunk-CISBSDJM.js} +9 -1
- package/dist/{chunk-S7IQHES2.js.map → chunk-CISBSDJM.js.map} +1 -1
- package/dist/{chunk-TZMKZQ7N.js → chunk-RLXS6WEQ.js} +2659 -603
- package/dist/chunk-RLXS6WEQ.js.map +1 -0
- package/dist/index.d.ts +700 -173
- package/dist/index.js +1007 -345
- package/dist/index.js.map +1 -1
- package/dist/{paths-FVFXSRUD.js → paths-5LG4XBLZ.js} +2 -2
- package/package.json +109 -85
- package/dist/chunk-TZMKZQ7N.js.map +0 -1
- /package/dist/{paths-FVFXSRUD.js.map → paths-5LG4XBLZ.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -45,9 +45,6 @@ declare const providerSchema: z.ZodObject<{
|
|
|
45
45
|
maxTokens?: number | undefined;
|
|
46
46
|
}>;
|
|
47
47
|
type ProviderConfig = z.infer<typeof providerSchema>;
|
|
48
|
-
/**
|
|
49
|
-
* Schema for the main application configuration.
|
|
50
|
-
*/
|
|
51
48
|
declare const appConfigSchema: z.ZodObject<{
|
|
52
49
|
/** Default provider name to use */
|
|
53
50
|
defaultProvider: z.ZodOptional<z.ZodString>;
|
|
@@ -139,6 +136,46 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
139
136
|
preloadTools?: boolean | undefined;
|
|
140
137
|
streamingOptimizations?: boolean | undefined;
|
|
141
138
|
}>>;
|
|
139
|
+
/** God mode — cascading escalation engine with 3 tiers */
|
|
140
|
+
godMode: z.ZodDefault<z.ZodObject<{
|
|
141
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
142
|
+
tier: z.ZodDefault<z.ZodNullable<z.ZodEnum<["unchained", "sovereign", "apex"]>>>;
|
|
143
|
+
autoEscalate: z.ZodDefault<z.ZodBoolean>;
|
|
144
|
+
maxTier: z.ZodDefault<z.ZodEnum<["unchained", "sovereign", "apex"]>>;
|
|
145
|
+
bypassPermissions: z.ZodDefault<z.ZodBoolean>;
|
|
146
|
+
maxConcurrency: z.ZodDefault<z.ZodNumber>;
|
|
147
|
+
selfModifyPrompt: z.ZodDefault<z.ZodBoolean>;
|
|
148
|
+
autonomousSpawn: z.ZodDefault<z.ZodBoolean>;
|
|
149
|
+
modifyProjectConfig: z.ZodDefault<z.ZodBoolean>;
|
|
150
|
+
autoHeal: z.ZodDefault<z.ZodBoolean>;
|
|
151
|
+
showBanner: z.ZodDefault<z.ZodBoolean>;
|
|
152
|
+
}, "strip", z.ZodTypeAny, {
|
|
153
|
+
enabled: boolean;
|
|
154
|
+
tier: "unchained" | "sovereign" | "apex" | null;
|
|
155
|
+
autoEscalate: boolean;
|
|
156
|
+
maxTier: "unchained" | "sovereign" | "apex";
|
|
157
|
+
bypassPermissions: boolean;
|
|
158
|
+
maxConcurrency: number;
|
|
159
|
+
selfModifyPrompt: boolean;
|
|
160
|
+
autonomousSpawn: boolean;
|
|
161
|
+
modifyProjectConfig: boolean;
|
|
162
|
+
autoHeal: boolean;
|
|
163
|
+
showBanner: boolean;
|
|
164
|
+
}, {
|
|
165
|
+
enabled?: boolean | undefined;
|
|
166
|
+
tier?: "unchained" | "sovereign" | "apex" | null | undefined;
|
|
167
|
+
autoEscalate?: boolean | undefined;
|
|
168
|
+
maxTier?: "unchained" | "sovereign" | "apex" | undefined;
|
|
169
|
+
bypassPermissions?: boolean | undefined;
|
|
170
|
+
maxConcurrency?: number | undefined;
|
|
171
|
+
selfModifyPrompt?: boolean | undefined;
|
|
172
|
+
autonomousSpawn?: boolean | undefined;
|
|
173
|
+
modifyProjectConfig?: boolean | undefined;
|
|
174
|
+
autoHeal?: boolean | undefined;
|
|
175
|
+
showBanner?: boolean | undefined;
|
|
176
|
+
}>>;
|
|
177
|
+
/** Non-interactive mode — headless execution for CI/CD and automation */
|
|
178
|
+
/** Model access — unrestricted model selection */
|
|
142
179
|
/** Model access — unrestricted model selection */
|
|
143
180
|
models: z.ZodDefault<z.ZodObject<{
|
|
144
181
|
aliases: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
@@ -308,6 +345,19 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
308
345
|
preloadTools: boolean;
|
|
309
346
|
streamingOptimizations: boolean;
|
|
310
347
|
};
|
|
348
|
+
godMode: {
|
|
349
|
+
enabled: boolean;
|
|
350
|
+
tier: "unchained" | "sovereign" | "apex" | null;
|
|
351
|
+
autoEscalate: boolean;
|
|
352
|
+
maxTier: "unchained" | "sovereign" | "apex";
|
|
353
|
+
bypassPermissions: boolean;
|
|
354
|
+
maxConcurrency: number;
|
|
355
|
+
selfModifyPrompt: boolean;
|
|
356
|
+
autonomousSpawn: boolean;
|
|
357
|
+
modifyProjectConfig: boolean;
|
|
358
|
+
autoHeal: boolean;
|
|
359
|
+
showBanner: boolean;
|
|
360
|
+
};
|
|
311
361
|
models: {
|
|
312
362
|
maxContextTokens: number;
|
|
313
363
|
aliases: {
|
|
@@ -382,6 +432,19 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
382
432
|
preloadTools?: boolean | undefined;
|
|
383
433
|
streamingOptimizations?: boolean | undefined;
|
|
384
434
|
} | undefined;
|
|
435
|
+
godMode?: {
|
|
436
|
+
enabled?: boolean | undefined;
|
|
437
|
+
tier?: "unchained" | "sovereign" | "apex" | null | undefined;
|
|
438
|
+
autoEscalate?: boolean | undefined;
|
|
439
|
+
maxTier?: "unchained" | "sovereign" | "apex" | undefined;
|
|
440
|
+
bypassPermissions?: boolean | undefined;
|
|
441
|
+
maxConcurrency?: number | undefined;
|
|
442
|
+
selfModifyPrompt?: boolean | undefined;
|
|
443
|
+
autonomousSpawn?: boolean | undefined;
|
|
444
|
+
modifyProjectConfig?: boolean | undefined;
|
|
445
|
+
autoHeal?: boolean | undefined;
|
|
446
|
+
showBanner?: boolean | undefined;
|
|
447
|
+
} | undefined;
|
|
385
448
|
models?: {
|
|
386
449
|
maxContextTokens?: number | undefined;
|
|
387
450
|
aliases?: {
|
|
@@ -545,6 +608,412 @@ declare abstract class BaseAdapter implements ProviderAdapter {
|
|
|
545
608
|
protected fetchWithRetry(url: string, optionsFactory: () => RequestInit): Promise<Response>;
|
|
546
609
|
}
|
|
547
610
|
|
|
611
|
+
/** A single diagnostic (error/warning) */
|
|
612
|
+
interface Diagnostic {
|
|
613
|
+
file: string;
|
|
614
|
+
line?: number;
|
|
615
|
+
column?: number;
|
|
616
|
+
severity: 'error' | 'warning';
|
|
617
|
+
message: string;
|
|
618
|
+
code?: string;
|
|
619
|
+
}
|
|
620
|
+
/** Result of a verification check */
|
|
621
|
+
interface VerificationResult {
|
|
622
|
+
passed: boolean;
|
|
623
|
+
errors: Diagnostic[];
|
|
624
|
+
warnings: Diagnostic[];
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Error Memory Bank — Память ошибок модели
|
|
629
|
+
*
|
|
630
|
+
* Каждый раз, когда модель допускает ошибку (compilation error, failed test, bad pattern),
|
|
631
|
+
* она записывается в Error Memory. При следующем запросе система проверяет
|
|
632
|
+
* похожие контексты и инжектит предупреждения в промпт.
|
|
633
|
+
*
|
|
634
|
+
* Архитектура:
|
|
635
|
+
* - In-memory + JSON persistence
|
|
636
|
+
* - Fingerprinting: error pattern → context signature
|
|
637
|
+
* - Deduplication by similarity
|
|
638
|
+
* - Decay: старые ошибки постепенно забываются
|
|
639
|
+
* - Session-scoped + persistent across sessions
|
|
640
|
+
*/
|
|
641
|
+
interface ErrorEntry {
|
|
642
|
+
/** Unique ID */
|
|
643
|
+
id: string;
|
|
644
|
+
/** Which model made this error */
|
|
645
|
+
model: string;
|
|
646
|
+
/** Error pattern fingerprint (e.g. "TS6133-unused-variable") */
|
|
647
|
+
pattern: string;
|
|
648
|
+
/** Context fingerprint (what was the model trying to do) */
|
|
649
|
+
contextSignature: string;
|
|
650
|
+
/** The actual error message */
|
|
651
|
+
errorMessage: string;
|
|
652
|
+
/** The file extension when error occurred */
|
|
653
|
+
fileExtension: string;
|
|
654
|
+
/** How was it fixed */
|
|
655
|
+
fix: string;
|
|
656
|
+
/** Number of times this pattern occurred */
|
|
657
|
+
occurrences: number;
|
|
658
|
+
/** First seen timestamp */
|
|
659
|
+
firstSeen: number;
|
|
660
|
+
/** Last seen timestamp */
|
|
661
|
+
lastSeen: number;
|
|
662
|
+
/** Was it auto-fixed by SmartFix? */
|
|
663
|
+
autoFixed: boolean;
|
|
664
|
+
}
|
|
665
|
+
interface ErrorMemoryConfig {
|
|
666
|
+
/** Maximum entries to keep */
|
|
667
|
+
maxEntries: number;
|
|
668
|
+
/** Decay time in ms — entries older than this get lower priority */
|
|
669
|
+
decayTime: number;
|
|
670
|
+
/** Path to persist error memory JSON */
|
|
671
|
+
persistencePath: string | null;
|
|
672
|
+
/** Minimum similarity score (0-1) to consider a match */
|
|
673
|
+
matchThreshold: number;
|
|
674
|
+
}
|
|
675
|
+
interface ErrorMemoryMatch {
|
|
676
|
+
entry: ErrorEntry;
|
|
677
|
+
relevance: number;
|
|
678
|
+
}
|
|
679
|
+
interface RecordErrorInput {
|
|
680
|
+
model: string;
|
|
681
|
+
error: string;
|
|
682
|
+
errorCode?: string;
|
|
683
|
+
fileExtension: string;
|
|
684
|
+
context: string;
|
|
685
|
+
fix?: string;
|
|
686
|
+
autoFixed?: boolean;
|
|
687
|
+
}
|
|
688
|
+
declare class ErrorMemoryBank {
|
|
689
|
+
private entries;
|
|
690
|
+
private config;
|
|
691
|
+
private dirty;
|
|
692
|
+
constructor(config?: Partial<ErrorMemoryConfig>);
|
|
693
|
+
/** Initialize — load from disk if persistence enabled */
|
|
694
|
+
init(): Promise<void>;
|
|
695
|
+
/** Persist to disk */
|
|
696
|
+
save(): Promise<void>;
|
|
697
|
+
/**
|
|
698
|
+
* Record a model error.
|
|
699
|
+
* If a similar pattern already exists, increments occurrence count.
|
|
700
|
+
*/
|
|
701
|
+
record(input: RecordErrorInput): ErrorEntry;
|
|
702
|
+
/**
|
|
703
|
+
* Find similar past errors for a given context.
|
|
704
|
+
* Returns entries sorted by relevance (most relevant first).
|
|
705
|
+
*/
|
|
706
|
+
findSimilar(context: string, model?: string, fileExtension?: string): ErrorMemoryMatch[];
|
|
707
|
+
/**
|
|
708
|
+
* Generate warning prompt for injection.
|
|
709
|
+
* Returns a compact list of past errors relevant to the current context.
|
|
710
|
+
*/
|
|
711
|
+
generateWarningPrompt(context: string, model?: string, fileExtension?: string): string;
|
|
712
|
+
/** Get all entries (for debugging/inspection) */
|
|
713
|
+
getAll(): ErrorEntry[];
|
|
714
|
+
/** Get statistics */
|
|
715
|
+
getStats(): {
|
|
716
|
+
totalEntries: number;
|
|
717
|
+
topPatterns: {
|
|
718
|
+
pattern: string;
|
|
719
|
+
count: number;
|
|
720
|
+
}[];
|
|
721
|
+
};
|
|
722
|
+
/** Clear all entries */
|
|
723
|
+
clear(): void;
|
|
724
|
+
private fingerprintPattern;
|
|
725
|
+
private fingerprintContext;
|
|
726
|
+
private tokenize;
|
|
727
|
+
private jaccardSimilarity;
|
|
728
|
+
private computeDecay;
|
|
729
|
+
private evictOldest;
|
|
730
|
+
private load;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Shadow Compilation v2 — Тихая компиляция
|
|
735
|
+
*
|
|
736
|
+
* Эволюция SVA: невидимый цикл для пользователя.
|
|
737
|
+
* Модель генерирует код → в фоне компилируем → если ошибки →
|
|
738
|
+
* кормим обратно модели → перегенерация → пользователь видит ТОЛЬКО рабочий код.
|
|
739
|
+
*
|
|
740
|
+
* Pipeline:
|
|
741
|
+
* 1. Agent generates code
|
|
742
|
+
* 2. ShadowCompiler intercepts BEFORE showing to user
|
|
743
|
+
* 3. Runs tsc/eslint/cargo check/etc in background
|
|
744
|
+
* 4. If errors → feeds back to model with error context
|
|
745
|
+
* 5. Repeats up to maxIterations
|
|
746
|
+
* 6. Returns clean code or best-effort with diagnostics
|
|
747
|
+
*
|
|
748
|
+
* Integration points:
|
|
749
|
+
* - VerificationGate.preVerify() → ShadowCompiler.shadowCompile()
|
|
750
|
+
* - loop.ts tool result → ShadowCompiler.postCompileCheck()
|
|
751
|
+
*/
|
|
752
|
+
|
|
753
|
+
interface ShadowCompileConfig {
|
|
754
|
+
/** Enable shadow compilation */
|
|
755
|
+
enabled: boolean;
|
|
756
|
+
/** Maximum auto-repair iterations */
|
|
757
|
+
maxIterations: number;
|
|
758
|
+
/** Timeout per compilation check (ms) */
|
|
759
|
+
compileTimeout: number;
|
|
760
|
+
/** Which compilers to run */
|
|
761
|
+
compilers: CompilerConfig[];
|
|
762
|
+
/** Whether to show compilation status to user */
|
|
763
|
+
showStatus: boolean;
|
|
764
|
+
/** Error memory integration */
|
|
765
|
+
errorMemory: ErrorMemoryBank | null;
|
|
766
|
+
}
|
|
767
|
+
interface CompilerConfig {
|
|
768
|
+
/** Compiler type */
|
|
769
|
+
type: 'tsc' | 'eslint' | 'cargo' | 'go' | 'python' | 'custom';
|
|
770
|
+
/** File extensions this compiler handles */
|
|
771
|
+
extensions: string[];
|
|
772
|
+
/** Custom command (for 'custom' type) */
|
|
773
|
+
command?: string;
|
|
774
|
+
/** Custom args template — {file} is replaced with file path */
|
|
775
|
+
args?: string[];
|
|
776
|
+
/** Whether this compiler is enabled */
|
|
777
|
+
enabled: boolean;
|
|
778
|
+
}
|
|
779
|
+
interface ShadowCompileInput {
|
|
780
|
+
/** File path (relative to project root) */
|
|
781
|
+
file: string;
|
|
782
|
+
/** Content to verify */
|
|
783
|
+
content: string;
|
|
784
|
+
/** Which model generated this (for error memory) */
|
|
785
|
+
model?: string;
|
|
786
|
+
/** Context of what was requested (for error memory) */
|
|
787
|
+
requestContext?: string;
|
|
788
|
+
}
|
|
789
|
+
interface ShadowCompileResult {
|
|
790
|
+
/** Whether compilation passed */
|
|
791
|
+
passed: boolean;
|
|
792
|
+
/** Final content (may be modified by auto-repair) */
|
|
793
|
+
content: string;
|
|
794
|
+
/** Number of repair iterations performed */
|
|
795
|
+
iterations: number;
|
|
796
|
+
/** Diagnostics from each iteration */
|
|
797
|
+
iterationDiagnostics: Diagnostic[][];
|
|
798
|
+
/** Final diagnostics (empty if passed) */
|
|
799
|
+
remainingDiagnostics: Diagnostic[];
|
|
800
|
+
/** Fixes applied during shadow compilation */
|
|
801
|
+
fixesApplied: string[];
|
|
802
|
+
/** Time spent in shadow compilation */
|
|
803
|
+
durationMs: number;
|
|
804
|
+
}
|
|
805
|
+
interface ShadowCompileEvent {
|
|
806
|
+
type: 'shadow_compile_start' | 'shadow_compile_iteration' | 'shadow_compile_fix' | 'shadow_compile_end';
|
|
807
|
+
iteration?: number;
|
|
808
|
+
file: string;
|
|
809
|
+
diagnostics?: Diagnostic[];
|
|
810
|
+
fix?: string;
|
|
811
|
+
passed: boolean;
|
|
812
|
+
}
|
|
813
|
+
type ShadowCompileEventHandler = (event: ShadowCompileEvent) => void;
|
|
814
|
+
declare class ShadowCompiler {
|
|
815
|
+
private config;
|
|
816
|
+
private cwd;
|
|
817
|
+
private tscPath;
|
|
818
|
+
private eventHandler;
|
|
819
|
+
private initialized;
|
|
820
|
+
constructor(cwd: string, config?: Partial<ShadowCompileConfig>, errorMemory?: ErrorMemoryBank);
|
|
821
|
+
/** Set event handler for monitoring shadow compilation progress */
|
|
822
|
+
onEvent(handler: ShadowCompileEventHandler): void;
|
|
823
|
+
/** Initialize — detect available compilers */
|
|
824
|
+
init(): Promise<void>;
|
|
825
|
+
/**
|
|
826
|
+
* Main entry point: Shadow-compile a file.
|
|
827
|
+
*
|
|
828
|
+
* Takes generated content, runs it through compilers,
|
|
829
|
+
* and auto-repairs errors up to maxIterations.
|
|
830
|
+
*/
|
|
831
|
+
shadowCompile(input: ShadowCompileInput): Promise<ShadowCompileResult>;
|
|
832
|
+
/**
|
|
833
|
+
* Quick post-write check: after file is written, run a final compilation.
|
|
834
|
+
* Returns diagnostics if any errors remain.
|
|
835
|
+
*/
|
|
836
|
+
postCompileCheck(file: string): Promise<Diagnostic[]>;
|
|
837
|
+
private getCompiler;
|
|
838
|
+
/**
|
|
839
|
+
* Run compilation for a file.
|
|
840
|
+
* If content is provided, simulates writing it first (temp file).
|
|
841
|
+
* If content is null, checks the actual file on disk.
|
|
842
|
+
*/
|
|
843
|
+
private runCompile;
|
|
844
|
+
/**
|
|
845
|
+
* TSC compilation: write content to temp location, run tsc, capture errors.
|
|
846
|
+
*/
|
|
847
|
+
private runTscCompile;
|
|
848
|
+
/**
|
|
849
|
+
* Cargo check for Rust files.
|
|
850
|
+
* Runs on the whole project since cargo doesn't support single-file checks.
|
|
851
|
+
*/
|
|
852
|
+
private runCargoCheck;
|
|
853
|
+
private findCargoDir;
|
|
854
|
+
private parseTscErrors;
|
|
855
|
+
private parseCargoErrors;
|
|
856
|
+
/**
|
|
857
|
+
* Auto-fix common errors without model round-trip.
|
|
858
|
+
* Returns fixed content if possible.
|
|
859
|
+
*/
|
|
860
|
+
private autoFix;
|
|
861
|
+
private fixOne;
|
|
862
|
+
private execCommand;
|
|
863
|
+
private emit;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
type GodModeTier = 'unchained' | 'sovereign' | 'apex';
|
|
867
|
+
interface GodModeConfig {
|
|
868
|
+
/** Whether god mode is enabled at all */
|
|
869
|
+
enabled: boolean;
|
|
870
|
+
/** Current escalation tier (starts at null = inactive) */
|
|
871
|
+
tier: GodModeTier | null;
|
|
872
|
+
/** Allow auto-escalation (agent can promote itself on complex tasks) */
|
|
873
|
+
autoEscalate: boolean;
|
|
874
|
+
/** Maximum tier the agent can reach (safety cap) */
|
|
875
|
+
maxTier: GodModeTier;
|
|
876
|
+
/** Auto-approve ALL tool calls without permission checks */
|
|
877
|
+
bypassPermissions: boolean;
|
|
878
|
+
/** Maximum parallel tool calls (increases with tier) */
|
|
879
|
+
maxConcurrency: number;
|
|
880
|
+
/** Agent can modify its own system prompt at runtime */
|
|
881
|
+
selfModifyPrompt: boolean;
|
|
882
|
+
/** Agent can spawn sub-agents without asking */
|
|
883
|
+
autonomousSpawn: boolean;
|
|
884
|
+
/** Agent can write to project config files (package.json, tsconfig, etc.) */
|
|
885
|
+
modifyProjectConfig: boolean;
|
|
886
|
+
/** Agent auto-heals errors without stopping for confirmation */
|
|
887
|
+
autoHeal: boolean;
|
|
888
|
+
/** Print god mode banner on activation */
|
|
889
|
+
showBanner: boolean;
|
|
890
|
+
}
|
|
891
|
+
interface GodModeState {
|
|
892
|
+
/** Current active tier */
|
|
893
|
+
tier: GodModeTier | null;
|
|
894
|
+
/** Whether god mode is currently active */
|
|
895
|
+
active: boolean;
|
|
896
|
+
/** How many times the agent escalated this session */
|
|
897
|
+
escalationCount: number;
|
|
898
|
+
/** Timestamps of tier activations */
|
|
899
|
+
tierHistory: Array<{
|
|
900
|
+
tier: GodModeTier;
|
|
901
|
+
timestamp: number;
|
|
902
|
+
}>;
|
|
903
|
+
/** Tools auto-approved in this session */
|
|
904
|
+
autoApprovedCount: number;
|
|
905
|
+
/** Sub-agents spawned autonomously */
|
|
906
|
+
subAgentsSpawned: number;
|
|
907
|
+
/** Errors auto-healed */
|
|
908
|
+
errorsHealed: number;
|
|
909
|
+
}
|
|
910
|
+
declare class GodModeManager {
|
|
911
|
+
private config;
|
|
912
|
+
private state;
|
|
913
|
+
constructor(config: GodModeConfig);
|
|
914
|
+
/** Is god mode active at any tier? */
|
|
915
|
+
isActive(): boolean;
|
|
916
|
+
/** Current tier (null if inactive) */
|
|
917
|
+
getTier(): GodModeTier | null;
|
|
918
|
+
/** Numeric tier level (0 = inactive, 1 = unchained, 2 = sovereign, 3 = apex) */
|
|
919
|
+
getTierLevel(): number;
|
|
920
|
+
/** Should we bypass permission checks? */
|
|
921
|
+
shouldBypassPermissions(): boolean;
|
|
922
|
+
/** Can agent modify its own system prompt? */
|
|
923
|
+
canSelfModifyPrompt(): boolean;
|
|
924
|
+
/** Can agent spawn sub-agents autonomously? */
|
|
925
|
+
canAutonomousSpawn(): boolean;
|
|
926
|
+
/** Can agent modify project config files? */
|
|
927
|
+
canModifyProjectConfig(): boolean;
|
|
928
|
+
/** Should agent auto-heal errors? */
|
|
929
|
+
shouldAutoHeal(): boolean;
|
|
930
|
+
/** Max parallel tool calls */
|
|
931
|
+
getMaxConcurrency(): number;
|
|
932
|
+
/** Get full state (for debugging/display) */
|
|
933
|
+
getState(): Readonly<GodModeState>;
|
|
934
|
+
/** Get config */
|
|
935
|
+
getConfig(): Readonly<GodModeConfig>;
|
|
936
|
+
/** Activate god mode at a specific tier */
|
|
937
|
+
activate(tier: GodModeTier): GodModeTier;
|
|
938
|
+
/** Auto-escalate to the next tier (if autoEscalate is enabled) */
|
|
939
|
+
autoEscalate(): GodModeTier | null;
|
|
940
|
+
/** Deactivate god mode completely */
|
|
941
|
+
deactivate(): void;
|
|
942
|
+
/** Record that a tool was auto-approved */
|
|
943
|
+
recordAutoApproval(): void;
|
|
944
|
+
/** Record that a sub-agent was spawned */
|
|
945
|
+
recordSubAgentSpawned(): void;
|
|
946
|
+
/** Record that an error was auto-healed */
|
|
947
|
+
recordErrorHealed(): void;
|
|
948
|
+
/** Get the god mode system prompt section to inject */
|
|
949
|
+
getSystemPromptSection(): string;
|
|
950
|
+
/** Get the system prompt modifier (like fast-mode's getSystemPromptModifier) */
|
|
951
|
+
getSystemPromptModifier(): string;
|
|
952
|
+
/** Get permission override — returns true to bypass, false to use normal flow */
|
|
953
|
+
getPermissionOverride(): boolean;
|
|
954
|
+
/** Get status string for UI display */
|
|
955
|
+
getStatusString(): string;
|
|
956
|
+
private applyTierCapabilities;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/** Configuration for the VerificationGate */
|
|
960
|
+
interface VerificationGateConfig {
|
|
961
|
+
/** Enable/disable verification entirely */
|
|
962
|
+
enabled: boolean;
|
|
963
|
+
/** Maximum number of auto-fix attempts before giving up */
|
|
964
|
+
maxFixAttempts: number;
|
|
965
|
+
/** Run import resolution checks */
|
|
966
|
+
checkImports: boolean;
|
|
967
|
+
/** Run TypeScript type checking */
|
|
968
|
+
checkTypes: boolean;
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* VerificationGate: the proactive verification layer.
|
|
972
|
+
*
|
|
973
|
+
* This sits between the agent's tool calls and the actual file system writes.
|
|
974
|
+
* Before a file is written/edited, it:
|
|
975
|
+
* 1. Simulates the write
|
|
976
|
+
* 2. Runs diagnostics (type check + import resolution)
|
|
977
|
+
* 3. If errors found → tries SmartFix
|
|
978
|
+
* 4. Returns verified (possibly fixed) content
|
|
979
|
+
*
|
|
980
|
+
* After the write:
|
|
981
|
+
* 1. Runs post-write diagnostics
|
|
982
|
+
* 2. Returns confirmation with any warnings
|
|
983
|
+
*/
|
|
984
|
+
declare class VerificationGate {
|
|
985
|
+
private diagnostics;
|
|
986
|
+
private smartFix;
|
|
987
|
+
private config;
|
|
988
|
+
constructor(cwd: string, config?: Partial<VerificationGateConfig>);
|
|
989
|
+
/** Initialize the diagnostics engine */
|
|
990
|
+
init(): Promise<void>;
|
|
991
|
+
/**
|
|
992
|
+
* Pre-write verification: simulate writing `content` to `file`
|
|
993
|
+
* and check for errors. If errors found, try to auto-fix.
|
|
994
|
+
*
|
|
995
|
+
* Returns:
|
|
996
|
+
* - passed: true if content is safe to write
|
|
997
|
+
* - content: possibly fixed content (may differ from input)
|
|
998
|
+
* - diagnostics: any remaining errors/warnings
|
|
999
|
+
* - fixesApplied: list of auto-fixes applied
|
|
1000
|
+
*/
|
|
1001
|
+
preVerify(file: string, content: string): Promise<{
|
|
1002
|
+
passed: boolean;
|
|
1003
|
+
content: string;
|
|
1004
|
+
result: VerificationResult;
|
|
1005
|
+
fixesApplied: string[];
|
|
1006
|
+
}>;
|
|
1007
|
+
/**
|
|
1008
|
+
* Post-write verification: after file was written, check for errors.
|
|
1009
|
+
*/
|
|
1010
|
+
postVerify(file: string): Promise<VerificationResult>;
|
|
1011
|
+
/** Update config at runtime */
|
|
1012
|
+
updateConfig(partial: Partial<VerificationGateConfig>): void;
|
|
1013
|
+
/** Get current config */
|
|
1014
|
+
getConfig(): VerificationGateConfig;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
548
1017
|
/** Events emitted by the agent loop */
|
|
549
1018
|
type LoopEvent = {
|
|
550
1019
|
type: 'assistant_text';
|
|
@@ -597,6 +1066,12 @@ interface ToolExecutionContext {
|
|
|
597
1066
|
sessionId?: string;
|
|
598
1067
|
/** P0.2: Progress callback — tools emit intermediate status messages */
|
|
599
1068
|
onProgress?: (message: string) => void;
|
|
1069
|
+
/** Verification gate for proactive code verification */
|
|
1070
|
+
verificationGate?: VerificationGate;
|
|
1071
|
+
/** God mode manager — cascading escalation engine */
|
|
1072
|
+
godModeManager?: GodModeManager;
|
|
1073
|
+
/** Shadow compiler — silent compilation with auto-fix for file writes */
|
|
1074
|
+
shadowCompiler?: ShadowCompiler;
|
|
600
1075
|
}
|
|
601
1076
|
|
|
602
1077
|
/** Risk level of a tool operation */
|
|
@@ -878,93 +1353,6 @@ declare class FastModeManager {
|
|
|
878
1353
|
updateConfig(partial: Partial<FastModeConfig>): void;
|
|
879
1354
|
}
|
|
880
1355
|
|
|
881
|
-
/** Role definition for a plan mode agent */
|
|
882
|
-
interface PlanAgentRole {
|
|
883
|
-
name: string;
|
|
884
|
-
description: string;
|
|
885
|
-
systemPromptSuffix: string;
|
|
886
|
-
allowedTools: string[];
|
|
887
|
-
maxSteps: number;
|
|
888
|
-
}
|
|
889
|
-
/** Configuration for plan mode */
|
|
890
|
-
interface PlanModeConfig {
|
|
891
|
-
enabled: boolean;
|
|
892
|
-
maxParallelAgents: number;
|
|
893
|
-
agentRoles: PlanAgentRole[];
|
|
894
|
-
planningStrategy: 'sequential' | 'parallel' | 'adaptive';
|
|
895
|
-
maxStepsPerAgent: number;
|
|
896
|
-
contextSharing: boolean;
|
|
897
|
-
}
|
|
898
|
-
/** Single step in a plan */
|
|
899
|
-
interface PlanStep {
|
|
900
|
-
id: string;
|
|
901
|
-
description: string;
|
|
902
|
-
assignedAgent: string;
|
|
903
|
-
status: 'pending' | 'in-progress' | 'completed' | 'failed';
|
|
904
|
-
result?: string;
|
|
905
|
-
dependencies: string[];
|
|
906
|
-
}
|
|
907
|
-
/** A plan with steps and metadata */
|
|
908
|
-
interface Plan {
|
|
909
|
-
id: string;
|
|
910
|
-
goal: string;
|
|
911
|
-
steps: PlanStep[];
|
|
912
|
-
status: 'planning' | 'executing' | 'completed' | 'failed';
|
|
913
|
-
createdAt: Date;
|
|
914
|
-
completedAt?: Date;
|
|
915
|
-
}
|
|
916
|
-
/** Statistics for plan execution */
|
|
917
|
-
interface PlanStats {
|
|
918
|
-
totalSteps: number;
|
|
919
|
-
completedSteps: number;
|
|
920
|
-
failedSteps: number;
|
|
921
|
-
totalDuration: number;
|
|
922
|
-
agentStats: Record<string, {
|
|
923
|
-
steps: number;
|
|
924
|
-
success: number;
|
|
925
|
-
failed: number;
|
|
926
|
-
}>;
|
|
927
|
-
}
|
|
928
|
-
/**
|
|
929
|
-
* Manages plan mode lifecycle: creation, configuration, state.
|
|
930
|
-
* Does NOT execute plans — that is PlanExecutor's job.
|
|
931
|
-
*/
|
|
932
|
-
declare class PlanModeManager {
|
|
933
|
-
private config;
|
|
934
|
-
private activePlan;
|
|
935
|
-
constructor(config?: Partial<PlanModeConfig>);
|
|
936
|
-
/** Current configuration */
|
|
937
|
-
getConfig(): PlanModeConfig;
|
|
938
|
-
/** Update configuration */
|
|
939
|
-
updateConfig(partial: Partial<PlanModeConfig>): void;
|
|
940
|
-
/** Whether plan mode is enabled */
|
|
941
|
-
isEnabled(): boolean;
|
|
942
|
-
/** Enable plan mode */
|
|
943
|
-
enable(): void;
|
|
944
|
-
/** Disable plan mode */
|
|
945
|
-
disable(): void;
|
|
946
|
-
/** Get the active plan */
|
|
947
|
-
getActivePlan(): Plan | null;
|
|
948
|
-
/** Create a new plan from a goal */
|
|
949
|
-
createPlan(goal: string, steps: Omit<PlanStep, 'status'>[]): Plan;
|
|
950
|
-
/** Mark plan as executing */
|
|
951
|
-
startExecution(plan: Plan): void;
|
|
952
|
-
/** Mark plan as completed */
|
|
953
|
-
completePlan(plan: Plan): void;
|
|
954
|
-
/** Mark plan as failed */
|
|
955
|
-
failPlan(plan: Plan): void;
|
|
956
|
-
/** Get a role by name */
|
|
957
|
-
getRole(name: string): PlanAgentRole | undefined;
|
|
958
|
-
/** Get all roles */
|
|
959
|
-
getRoles(): PlanAgentRole[];
|
|
960
|
-
/** Compute statistics for a plan */
|
|
961
|
-
computeStats(plan: Plan): PlanStats;
|
|
962
|
-
/** Format a plan as a human-readable string */
|
|
963
|
-
formatPlan(plan: Plan): string;
|
|
964
|
-
/** Format execution stats as a human-readable report */
|
|
965
|
-
formatStats(stats: PlanStats): string;
|
|
966
|
-
}
|
|
967
|
-
|
|
968
1356
|
interface ContextWindowConfig {
|
|
969
1357
|
maxTokens: number;
|
|
970
1358
|
compactionThreshold: number;
|
|
@@ -1077,8 +1465,9 @@ interface LoopDeps {
|
|
|
1077
1465
|
autoModeManager?: AutoModeManager;
|
|
1078
1466
|
/** Fast mode manager (optional — created from config if not provided) */
|
|
1079
1467
|
fastModeManager?: FastModeManager;
|
|
1468
|
+
/** God mode manager (optional — cascading escalation engine with 3 tiers) */
|
|
1469
|
+
godModeManager?: GodModeManager;
|
|
1080
1470
|
/** Plan mode manager (optional — enables multi-agent plan execution) */
|
|
1081
|
-
planModeManager?: PlanModeManager;
|
|
1082
1471
|
/** Context window manager (optional — created from config if not provided) */
|
|
1083
1472
|
contextWindowManager?: ContextWindowManager;
|
|
1084
1473
|
/** Session history — messages from previous turns in this conversation */
|
|
@@ -1239,13 +1628,13 @@ declare const lspInputSchema: z.ZodObject<{
|
|
|
1239
1628
|
character: z.ZodOptional<z.ZodNumber>;
|
|
1240
1629
|
query: z.ZodOptional<z.ZodString>;
|
|
1241
1630
|
}, "strip", z.ZodTypeAny, {
|
|
1242
|
-
operation: "
|
|
1631
|
+
operation: "document_symbols" | "hover" | "go_to_definition" | "find_references" | "workspace_symbols";
|
|
1243
1632
|
file_path: string;
|
|
1244
1633
|
query?: string | undefined;
|
|
1245
1634
|
line?: number | undefined;
|
|
1246
1635
|
character?: number | undefined;
|
|
1247
1636
|
}, {
|
|
1248
|
-
operation: "
|
|
1637
|
+
operation: "document_symbols" | "hover" | "go_to_definition" | "find_references" | "workspace_symbols";
|
|
1249
1638
|
file_path: string;
|
|
1250
1639
|
query?: string | undefined;
|
|
1251
1640
|
line?: number | undefined;
|
|
@@ -1262,13 +1651,13 @@ declare class LspTool extends BaseTool<typeof lspInputSchema> {
|
|
|
1262
1651
|
character: z.ZodOptional<z.ZodNumber>;
|
|
1263
1652
|
query: z.ZodOptional<z.ZodString>;
|
|
1264
1653
|
}, "strip", z.ZodTypeAny, {
|
|
1265
|
-
operation: "
|
|
1654
|
+
operation: "document_symbols" | "hover" | "go_to_definition" | "find_references" | "workspace_symbols";
|
|
1266
1655
|
file_path: string;
|
|
1267
1656
|
query?: string | undefined;
|
|
1268
1657
|
line?: number | undefined;
|
|
1269
1658
|
character?: number | undefined;
|
|
1270
1659
|
}, {
|
|
1271
|
-
operation: "
|
|
1660
|
+
operation: "document_symbols" | "hover" | "go_to_definition" | "find_references" | "workspace_symbols";
|
|
1272
1661
|
file_path: string;
|
|
1273
1662
|
query?: string | undefined;
|
|
1274
1663
|
line?: number | undefined;
|
|
@@ -1547,56 +1936,144 @@ declare class EnhancedMemoryStore {
|
|
|
1547
1936
|
private persist;
|
|
1548
1937
|
}
|
|
1549
1938
|
|
|
1550
|
-
/**
|
|
1939
|
+
/** Skill status in the lifecycle */
|
|
1940
|
+
type SkillStatus = 'installed' | 'enabled' | 'disabled' | 'error' | 'loading' | 'builtin';
|
|
1941
|
+
/** Input parameter definition for a skill */
|
|
1942
|
+
interface SkillParamDef {
|
|
1943
|
+
name: string;
|
|
1944
|
+
type: 'string' | 'number' | 'boolean' | 'file' | 'directory' | 'select' | 'multiselect';
|
|
1945
|
+
label: string;
|
|
1946
|
+
description?: string;
|
|
1947
|
+
required?: boolean;
|
|
1948
|
+
default?: unknown;
|
|
1949
|
+
options?: {
|
|
1950
|
+
value: string;
|
|
1951
|
+
label: string;
|
|
1952
|
+
}[];
|
|
1953
|
+
placeholder?: string;
|
|
1954
|
+
}
|
|
1955
|
+
/** Output type a skill produces */
|
|
1956
|
+
interface SkillOutput {
|
|
1957
|
+
type: 'text' | 'markdown' | 'code' | 'diff' | 'json' | 'file' | 'files';
|
|
1958
|
+
description?: string;
|
|
1959
|
+
}
|
|
1960
|
+
/** A single step in a skill's execution plan */
|
|
1961
|
+
interface SkillStep {
|
|
1962
|
+
id: string;
|
|
1963
|
+
title: string;
|
|
1964
|
+
prompt: string;
|
|
1965
|
+
tools?: string[];
|
|
1966
|
+
timeout?: number;
|
|
1967
|
+
condition?: string;
|
|
1968
|
+
outputs?: SkillOutput[];
|
|
1969
|
+
}
|
|
1970
|
+
/** Trigger definition — when a skill auto-activates */
|
|
1971
|
+
interface SkillTrigger {
|
|
1972
|
+
event: 'file-change' | 'command' | 'keyword' | 'schedule' | 'manual';
|
|
1973
|
+
pattern?: string;
|
|
1974
|
+
description?: string;
|
|
1975
|
+
}
|
|
1976
|
+
/** The full skill manifest (metadata + execution plan) */
|
|
1977
|
+
interface SkillManifest {
|
|
1978
|
+
id: string;
|
|
1979
|
+
name: string;
|
|
1980
|
+
version: string;
|
|
1981
|
+
description: string;
|
|
1982
|
+
author?: string;
|
|
1983
|
+
icon?: string;
|
|
1984
|
+
category: SkillCategory;
|
|
1985
|
+
tags?: string[];
|
|
1986
|
+
params: SkillParamDef[];
|
|
1987
|
+
steps: SkillStep[];
|
|
1988
|
+
outputs: SkillOutput[];
|
|
1989
|
+
triggers?: SkillTrigger[];
|
|
1990
|
+
requiresTools?: string[];
|
|
1991
|
+
requiresProviders?: string[];
|
|
1992
|
+
modelPreference?: 'fast' | 'smart' | 'code' | 'creative' | 'reasoning';
|
|
1993
|
+
source: 'builtin' | 'local' | 'marketplace';
|
|
1994
|
+
sourcePath?: string;
|
|
1995
|
+
marketplaceUrl?: string;
|
|
1996
|
+
readme?: string;
|
|
1997
|
+
}
|
|
1998
|
+
/** Skill categories for organization */
|
|
1999
|
+
type SkillCategory = 'code-review' | 'refactoring' | 'testing' | 'documentation' | 'debugging' | 'deployment' | 'security' | 'analysis' | 'workflow' | 'agent' | 'performance' | 'custom';
|
|
2000
|
+
/** Runtime state of an installed skill */
|
|
2001
|
+
interface InstalledSkill {
|
|
2002
|
+
manifest: SkillManifest;
|
|
2003
|
+
status: SkillStatus;
|
|
2004
|
+
installedAt: number;
|
|
2005
|
+
lastUsedAt?: number;
|
|
2006
|
+
useCount: number;
|
|
2007
|
+
error?: string;
|
|
2008
|
+
enabled: boolean;
|
|
2009
|
+
}
|
|
2010
|
+
/** A running skill execution instance */
|
|
2011
|
+
interface SkillExecution {
|
|
2012
|
+
id: string;
|
|
2013
|
+
skillId: string;
|
|
2014
|
+
startedAt: number;
|
|
2015
|
+
completedAt?: number;
|
|
2016
|
+
status: 'running' | 'completed' | 'failed' | 'cancelled';
|
|
2017
|
+
currentStep: number;
|
|
2018
|
+
params: Record<string, unknown>;
|
|
2019
|
+
results: SkillStepResult[];
|
|
2020
|
+
error?: string;
|
|
2021
|
+
}
|
|
2022
|
+
/** Result of a single step execution */
|
|
2023
|
+
interface SkillStepResult {
|
|
2024
|
+
stepId: string;
|
|
2025
|
+
status: 'completed' | 'failed' | 'skipped';
|
|
2026
|
+
output?: string;
|
|
2027
|
+
duration?: number;
|
|
2028
|
+
error?: string;
|
|
2029
|
+
}
|
|
2030
|
+
/** Legacy compatibility — kept for existing skill-loader.ts */
|
|
1551
2031
|
interface SkillDefinition {
|
|
1552
|
-
|
|
2032
|
+
id: string;
|
|
1553
2033
|
name: string;
|
|
1554
|
-
|
|
2034
|
+
version: string;
|
|
1555
2035
|
description: string;
|
|
1556
|
-
/** Aliases for invocation */
|
|
1557
|
-
aliases?: string[];
|
|
1558
|
-
/** The prompt template to inject when skill is activated */
|
|
1559
2036
|
prompt: string;
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
sourcePath?: string;
|
|
2037
|
+
tools?: string[];
|
|
2038
|
+
modelPreference?: string;
|
|
2039
|
+
category?: string;
|
|
2040
|
+
tags?: string[];
|
|
2041
|
+
params?: SkillParamDef[];
|
|
1566
2042
|
}
|
|
1567
2043
|
|
|
1568
|
-
/**
|
|
1569
|
-
* Registry of available skills.
|
|
1570
|
-
* Manages skill registration, lookup, and loading from disk.
|
|
1571
|
-
*/
|
|
1572
2044
|
declare class SkillRegistry {
|
|
1573
2045
|
private skills;
|
|
1574
|
-
private
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
2046
|
+
private executions;
|
|
2047
|
+
private listeners;
|
|
2048
|
+
/** Load built-in skills into registry */
|
|
2049
|
+
loadBuiltinSkills(): void;
|
|
2050
|
+
/** Register a skill from external source (file, marketplace, etc.) */
|
|
2051
|
+
registerSkill(manifest: SkillManifest, sourcePath?: string): InstalledSkill;
|
|
2052
|
+
/** Unregister a skill by id */
|
|
2053
|
+
unregisterSkill(id: string): boolean;
|
|
2054
|
+
getAll(): InstalledSkill[];
|
|
2055
|
+
getById(id: string): InstalledSkill | undefined;
|
|
2056
|
+
getByCategory(category: SkillCategory): InstalledSkill[];
|
|
2057
|
+
getEnabled(): InstalledSkill[];
|
|
2058
|
+
getBuiltin(): InstalledSkill[];
|
|
2059
|
+
getCustom(): InstalledSkill[];
|
|
2060
|
+
search(query: string): InstalledSkill[];
|
|
2061
|
+
enableSkill(id: string): boolean;
|
|
2062
|
+
disableSkill(id: string): boolean;
|
|
2063
|
+
toggleSkill(id: string): boolean;
|
|
2064
|
+
startExecution(skillId: string, params: Record<string, unknown>): SkillExecution;
|
|
2065
|
+
completeExecution(executionId: string, stepResults: SkillStepResult[]): void;
|
|
2066
|
+
failExecution(executionId: string, error: string): void;
|
|
2067
|
+
getExecution(executionId: string): SkillExecution | undefined;
|
|
2068
|
+
getRecentExecutions(limit?: number): SkillExecution[];
|
|
2069
|
+
/** Export a skill definition as a legacy SkillDefinition */
|
|
2070
|
+
toSkillDefinition(id: string): SkillDefinition | undefined;
|
|
2071
|
+
/** Serialize all skills for persistence */
|
|
2072
|
+
serialize(): string;
|
|
2073
|
+
/** Restore from serialized state */
|
|
2074
|
+
deserialize(json: string): void;
|
|
2075
|
+
onChange(listener: () => void): () => void;
|
|
2076
|
+
private notify;
|
|
1600
2077
|
}
|
|
1601
2078
|
|
|
1602
2079
|
/** Permission mode for the session */
|
|
@@ -1731,12 +2208,39 @@ interface BudgetStatus {
|
|
|
1731
2208
|
percent: number;
|
|
1732
2209
|
remainingBudget?: number;
|
|
1733
2210
|
}
|
|
2211
|
+
interface TaskSpend {
|
|
2212
|
+
taskId: string;
|
|
2213
|
+
cost: number;
|
|
2214
|
+
inputTokens: number;
|
|
2215
|
+
outputTokens: number;
|
|
2216
|
+
entries: number;
|
|
2217
|
+
}
|
|
2218
|
+
interface BudgetSnapshot {
|
|
2219
|
+
sessionCost: number;
|
|
2220
|
+
sessionLimit: number | null;
|
|
2221
|
+
sessionPercent: number;
|
|
2222
|
+
taskCost: number;
|
|
2223
|
+
taskLimit: number | null;
|
|
2224
|
+
taskPercent: number;
|
|
2225
|
+
level: BudgetLevel;
|
|
2226
|
+
canContinue: boolean;
|
|
2227
|
+
}
|
|
1734
2228
|
declare class CostTracker {
|
|
1735
2229
|
private entries;
|
|
1736
2230
|
private config;
|
|
1737
2231
|
private sessionStart;
|
|
1738
2232
|
private lastBudgetLevel;
|
|
2233
|
+
private currentTaskId;
|
|
2234
|
+
private taskCostMap;
|
|
1739
2235
|
constructor(config?: Partial<CostConfig>);
|
|
2236
|
+
/** Set the current task ID for per-task tracking */
|
|
2237
|
+
setTaskId(taskId: string): void;
|
|
2238
|
+
/** Clear current task ID */
|
|
2239
|
+
clearTaskId(): void;
|
|
2240
|
+
/** Get per-task spend */
|
|
2241
|
+
getTaskSpend(taskId: string): TaskSpend | undefined;
|
|
2242
|
+
/** Get current task cost (if a task is active) */
|
|
2243
|
+
getCurrentTaskCost(): number;
|
|
1740
2244
|
/** Find prices for a model — exact match first, then fuzzy pattern matching */
|
|
1741
2245
|
private findPrices;
|
|
1742
2246
|
/** Record token usage for a model */
|
|
@@ -1780,6 +2284,21 @@ declare class CostTracker {
|
|
|
1780
2284
|
getSessionDuration(): number;
|
|
1781
2285
|
/** Reset for new session */
|
|
1782
2286
|
reset(): void;
|
|
2287
|
+
/**
|
|
2288
|
+
* Get a snapshot of current budget state for enforcement decisions.
|
|
2289
|
+
* `taskLimit` and `sessionLimit` are passed in from AppConfig since
|
|
2290
|
+
* CostTracker itself only tracks spending — limits come from config.
|
|
2291
|
+
*/
|
|
2292
|
+
getSnapshot(sessionLimit: number, taskLimit: number): BudgetSnapshot;
|
|
2293
|
+
/**
|
|
2294
|
+
* Whether the agent loop must stop right now.
|
|
2295
|
+
* Checks both session and task limits.
|
|
2296
|
+
*/
|
|
2297
|
+
shouldStop(sessionLimit: number, taskLimit: number): boolean;
|
|
2298
|
+
/** Check if budget level changed since last check, emit level */
|
|
2299
|
+
checkLevelChange(): BudgetLevel | null;
|
|
2300
|
+
/** Update the tracked level (called after getSnapshot) */
|
|
2301
|
+
setLevel(level: BudgetLevel): void;
|
|
1783
2302
|
}
|
|
1784
2303
|
|
|
1785
2304
|
interface TokenBudgetAnalysis {
|
|
@@ -1971,6 +2490,40 @@ declare class ContextCompactor {
|
|
|
1971
2490
|
private estimateMessagesTokens;
|
|
1972
2491
|
}
|
|
1973
2492
|
|
|
2493
|
+
type AgentRole = 'coordinator' | 'worker' | 'reviewer';
|
|
2494
|
+
interface AgentConfig {
|
|
2495
|
+
id: string;
|
|
2496
|
+
name: string;
|
|
2497
|
+
role: AgentRole;
|
|
2498
|
+
model?: string;
|
|
2499
|
+
tools?: string[];
|
|
2500
|
+
maxTurns?: number;
|
|
2501
|
+
systemPrompt?: string;
|
|
2502
|
+
}
|
|
2503
|
+
interface SwarmMessage {
|
|
2504
|
+
from: string;
|
|
2505
|
+
to: string | '*';
|
|
2506
|
+
type: 'task' | 'result' | 'query' | 'response' | 'shutdown';
|
|
2507
|
+
content: string;
|
|
2508
|
+
timestamp: number;
|
|
2509
|
+
}
|
|
2510
|
+
interface SwarmResult {
|
|
2511
|
+
agentId: string;
|
|
2512
|
+
agentName: string;
|
|
2513
|
+
task: string;
|
|
2514
|
+
result: string;
|
|
2515
|
+
success: boolean;
|
|
2516
|
+
duration: number;
|
|
2517
|
+
turns: number;
|
|
2518
|
+
}
|
|
2519
|
+
interface SubTask {
|
|
2520
|
+
id: string;
|
|
2521
|
+
description: string;
|
|
2522
|
+
assignedTo?: string;
|
|
2523
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
2524
|
+
result?: string;
|
|
2525
|
+
}
|
|
2526
|
+
|
|
1974
2527
|
type HookEvent = 'pre_tool_use' | 'post_tool_use' | 'pre_query' | 'post_query' | 'on_error' | 'on_stop';
|
|
1975
2528
|
interface HookCondition {
|
|
1976
2529
|
tool_name?: string;
|
|
@@ -2153,7 +2706,6 @@ type MCPConnectionState = 'disconnected' | 'connecting' | 'connected' | 'failed'
|
|
|
2153
2706
|
declare class MCPClient {
|
|
2154
2707
|
private readonly config;
|
|
2155
2708
|
private process;
|
|
2156
|
-
private rl;
|
|
2157
2709
|
private connectionState;
|
|
2158
2710
|
private nextId;
|
|
2159
2711
|
private readonly pendingRequests;
|
|
@@ -2161,6 +2713,9 @@ declare class MCPClient {
|
|
|
2161
2713
|
private serverInfo;
|
|
2162
2714
|
private serverInstructions;
|
|
2163
2715
|
private connectReject;
|
|
2716
|
+
private incomingBuffer;
|
|
2717
|
+
private readingHeaders;
|
|
2718
|
+
private currentHeaders;
|
|
2164
2719
|
constructor(config: MCPServerConfig);
|
|
2165
2720
|
connect(): Promise<void>;
|
|
2166
2721
|
disconnect(): Promise<void>;
|
|
@@ -2176,10 +2731,15 @@ declare class MCPClient {
|
|
|
2176
2731
|
getCapabilities(): MCPInitializeResult['capabilities'];
|
|
2177
2732
|
getConfig(): MCPServerConfig;
|
|
2178
2733
|
private spawnProcess;
|
|
2734
|
+
/**
|
|
2735
|
+
* Parse incoming bytes using MCP stdio Content-Length framing.
|
|
2736
|
+
* Format: Content-Length: <N>\r\n\r\n<N bytes of JSON>
|
|
2737
|
+
*/
|
|
2738
|
+
private handleData;
|
|
2739
|
+
private handleMessage;
|
|
2179
2740
|
private performHandshake;
|
|
2180
2741
|
private sendRequest;
|
|
2181
2742
|
private sendNotification;
|
|
2182
|
-
private handleLine;
|
|
2183
2743
|
private handleProcessError;
|
|
2184
2744
|
private handleProcessExit;
|
|
2185
2745
|
private assertNoError;
|
|
@@ -2203,40 +2763,6 @@ declare class MCPConnectionManager {
|
|
|
2203
2763
|
declare function executeAgentTask(taskId: string, manager: TaskManager, adapter: ProviderAdapter, tools: ToolRegistry, prompt: string, signal?: AbortSignal): Promise<void>;
|
|
2204
2764
|
declare function executeShellTask(taskId: string, manager: TaskManager, command: string, cwd: string, signal?: AbortSignal): Promise<void>;
|
|
2205
2765
|
|
|
2206
|
-
type AgentRole = 'coordinator' | 'worker' | 'reviewer';
|
|
2207
|
-
interface AgentConfig {
|
|
2208
|
-
id: string;
|
|
2209
|
-
name: string;
|
|
2210
|
-
role: AgentRole;
|
|
2211
|
-
model?: string;
|
|
2212
|
-
tools?: string[];
|
|
2213
|
-
maxTurns?: number;
|
|
2214
|
-
systemPrompt?: string;
|
|
2215
|
-
}
|
|
2216
|
-
interface SwarmMessage {
|
|
2217
|
-
from: string;
|
|
2218
|
-
to: string | '*';
|
|
2219
|
-
type: 'task' | 'result' | 'query' | 'response' | 'shutdown';
|
|
2220
|
-
content: string;
|
|
2221
|
-
timestamp: number;
|
|
2222
|
-
}
|
|
2223
|
-
interface SwarmResult {
|
|
2224
|
-
agentId: string;
|
|
2225
|
-
agentName: string;
|
|
2226
|
-
task: string;
|
|
2227
|
-
result: string;
|
|
2228
|
-
success: boolean;
|
|
2229
|
-
duration: number;
|
|
2230
|
-
turns: number;
|
|
2231
|
-
}
|
|
2232
|
-
interface SubTask {
|
|
2233
|
-
id: string;
|
|
2234
|
-
description: string;
|
|
2235
|
-
assignedTo?: string;
|
|
2236
|
-
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
2237
|
-
result?: string;
|
|
2238
|
-
}
|
|
2239
|
-
|
|
2240
2766
|
declare class SwarmCoordinator {
|
|
2241
2767
|
private adapter;
|
|
2242
2768
|
private tools;
|
|
@@ -2248,6 +2774,7 @@ declare class SwarmCoordinator {
|
|
|
2248
2774
|
removeAgent(id: string): void;
|
|
2249
2775
|
getAgents(): AgentConfig[];
|
|
2250
2776
|
sendMessage(message: SwarmMessage): Promise<void>;
|
|
2777
|
+
getMessages(agentId: string): SwarmMessage[];
|
|
2251
2778
|
executeSwarm(task: string): Promise<SwarmResult[]>;
|
|
2252
2779
|
shutdown(): void;
|
|
2253
2780
|
private findAgentByRole;
|