@codex-ultra/cxu 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.
@@ -0,0 +1,99 @@
1
+ export type SaVmDeletePolicy = "deny" | "rename" | "move";
2
+ export type SaVmFsAccess = "read" | "write" | "deny";
3
+ export interface SaVmFsEntry {
4
+ path: string;
5
+ access: SaVmFsAccess;
6
+ }
7
+ export interface SaVmProcessExecRule {
8
+ path: string;
9
+ args?: string[];
10
+ }
11
+ export type SaVmBunProfile = "shared-typecheck" | "protocol-typecheck" | "server-typecheck" | "web-typecheck" | "free-key-typecheck" | "root-typecheck" | "shared-build" | "web-build" | "server-test-file" | "web-test-file" | "shared-test-file";
12
+ export declare const ALL_SA_VM_BUN_PROFILES: readonly SaVmBunProfile[];
13
+ export type SaVmBunSubcommand = "test" | "run" | "build" | "--filter" | "filter";
14
+ export declare const ALL_SA_VM_BUN_SUBCOMMANDS: readonly SaVmBunSubcommand[];
15
+ export declare const ALL_SA_VM_BUN_FILTER_SCRIPTS: readonly ["typecheck", "build", "test", "lint"];
16
+ export type SaVmBunFilterScript = typeof ALL_SA_VM_BUN_FILTER_SCRIPTS[number];
17
+ export declare const SA_VM_BUN_DENIED_SUBCOMMANDS: readonly string[];
18
+ export interface SaVmBunPolicyConfig {
19
+ enabled?: boolean;
20
+ allowedSubcommands?: SaVmBunSubcommand[];
21
+ }
22
+ export interface SaVmHttpAllowRule {
23
+ host: string;
24
+ methods?: string[];
25
+ paths?: string[];
26
+ }
27
+ export type SaVmRuntimeEngine = "native" | "vm";
28
+ export interface SaVmPolicyConfig {
29
+ engine?: SaVmRuntimeEngine;
30
+ fs?: {
31
+ entries?: SaVmFsEntry[];
32
+ read?: string[];
33
+ write?: string[];
34
+ transfer?: string[];
35
+ delete?: SaVmDeletePolicy;
36
+ backupDir?: string | null;
37
+ salaRoot?: string;
38
+ };
39
+ http?: {
40
+ allow?: SaVmHttpAllowRule[];
41
+ };
42
+ env?: {
43
+ allow?: string[];
44
+ };
45
+ process?: {
46
+ spawn?: boolean;
47
+ exec?: SaVmProcessExecRule[];
48
+ bunProfiles?: SaVmBunProfile[];
49
+ bun?: boolean | SaVmBunPolicyConfig;
50
+ };
51
+ execution?: {
52
+ javascript?: boolean;
53
+ python?: boolean;
54
+ };
55
+ tools?: SaVmToolsConfig;
56
+ contextSavings?: SaVmContextSavingsConfig;
57
+ }
58
+ export interface SaVmContextSavingsConfig {
59
+ locateBeforeRead?: boolean;
60
+ maxReadFileBytes?: number;
61
+ grepCircuitBreaker?: boolean;
62
+ grepMaxResults?: number;
63
+ grepMaxTokens?: number;
64
+ slimRunnerOutput?: boolean;
65
+ parallelBudget?: boolean;
66
+ parallelMaxTotalBytes?: number;
67
+ parallelMaxReadFiles?: number;
68
+ parallelDeduplication?: boolean;
69
+ tieredSkillInjection?: boolean;
70
+ foldWaterfallEvents?: boolean;
71
+ foldHistoryReadSummaries?: boolean;
72
+ historyReadFoldTurns?: number;
73
+ }
74
+ export interface SaVmToolsConfig {
75
+ replaceRead?: boolean;
76
+ replaceWrite?: boolean;
77
+ replaceApplyPatch?: boolean;
78
+ replaceExec?: boolean;
79
+ readFiles?: boolean;
80
+ editFiles?: boolean;
81
+ applyPatch?: boolean;
82
+ fastSearch?: boolean;
83
+ clearToolHistory?: boolean;
84
+ findReferences?: boolean;
85
+ renameSymbol?: boolean;
86
+ fileOutline?: boolean;
87
+ moveWithImports?: boolean;
88
+ findDefinition?: boolean;
89
+ extractToFile?: boolean;
90
+ addImport?: boolean;
91
+ getDiagnostics?: boolean;
92
+ organizeImports?: boolean;
93
+ analyzeScope?: boolean;
94
+ }
95
+ export declare const ENHANCE_TOOLS_KEYS: readonly ["readFiles", "fastSearch", "editFiles", "applyPatch", "fileOutline", "findDefinition", "renameSymbol", "extractToFile", "moveWithImports", "addImport", "getDiagnostics", "organizeImports", "analyzeScope", "findReferences", "clearToolHistory"];
96
+ export type EnhanceToolKey = typeof ENHANCE_TOOLS_KEYS[number];
97
+ export declare function hasEnhanceToolsEnabled(tools?: SaVmToolsConfig | null): boolean;
98
+ export declare function countActiveEnhanceTools(tools?: SaVmToolsConfig | null): number;
99
+ export declare function createDefaultSaVmPolicyConfig(): SaVmPolicyConfig;
@@ -0,0 +1,29 @@
1
+ import type { SaVmPolicyConfig } from "../shared-types.js";
2
+ type PatchOp = {
3
+ kind: "write";
4
+ path: string;
5
+ contents: string;
6
+ } | {
7
+ kind: "edit";
8
+ path: string;
9
+ oldContents: string;
10
+ newContents: string;
11
+ } | {
12
+ kind: "delete";
13
+ path: string;
14
+ backupPath?: string;
15
+ } | {
16
+ kind: "rename";
17
+ from: string;
18
+ to: string;
19
+ };
20
+ export type SaVmPatchOperation = PatchOp;
21
+ export type SaVmPatchResult = {
22
+ ok: true;
23
+ operations: PatchOp[];
24
+ } | {
25
+ ok: false;
26
+ reason: string;
27
+ };
28
+ export declare function parseAndCheckSaVmPatch(patch: string, cwd: string, policyConfig: SaVmPolicyConfig | undefined, additionalRoots?: string[]): SaVmPatchResult;
29
+ export {};
@@ -0,0 +1,112 @@
1
+ import type { SaVmBunSubcommand, SaVmContextSavingsConfig, SaVmDeletePolicy, SaVmHttpAllowRule, SaVmPolicyConfig, SaVmProcessExecRule } from "../shared-types.js";
2
+ export type SaVmPathOperation = "read" | "write" | "transfer";
3
+ /**
4
+ * Enhanced tools should have efficient access to external paths for read operations.
5
+ * The original design coupled enhancement with sandbox restrictions, causing models
6
+ * to fall back to inefficient terminal commands like Get-Content/Select-String.
7
+ *
8
+ * Fix: Read operations (read_file, read_lines, grep_search, list_dir, find_files)
9
+ * should allow external paths by default for efficiency. Write operations remain
10
+ * restricted to workspace + additionalRoots for safety.
11
+ */
12
+ export declare const ENHANCED_TOOLS_READ_ONLY: Set<string>;
13
+ export type SaVmPolicyDecision = {
14
+ allowed: true;
15
+ path: string;
16
+ } | {
17
+ allowed: false;
18
+ reason: string;
19
+ path?: string;
20
+ };
21
+ export type NormalizedSaVmPolicy = {
22
+ engine: "native" | "vm";
23
+ fs: {
24
+ entries: Array<{
25
+ path: string;
26
+ access: "read" | "write" | "deny";
27
+ }>;
28
+ read: string[];
29
+ write: string[];
30
+ transfer: string[];
31
+ delete: SaVmDeletePolicy;
32
+ backupDir: string | null;
33
+ };
34
+ http: {
35
+ allow: SaVmHttpAllowRule[];
36
+ };
37
+ env: {
38
+ allow: string[];
39
+ };
40
+ process: {
41
+ spawn: boolean;
42
+ exec: SaVmProcessExecRule[];
43
+ bunProfiles?: string[];
44
+ bun?: {
45
+ enabled: boolean;
46
+ allowedSubcommands: SaVmBunSubcommand[];
47
+ };
48
+ };
49
+ execution: {
50
+ javascript: boolean;
51
+ python: boolean;
52
+ };
53
+ tools: {
54
+ replaceRead: boolean;
55
+ replaceWrite: boolean;
56
+ replaceApplyPatch: boolean;
57
+ replaceExec: boolean;
58
+ readFiles?: boolean;
59
+ editFiles?: boolean;
60
+ applyPatch?: boolean;
61
+ fastSearch?: boolean;
62
+ clearToolHistory: boolean;
63
+ findReferences: boolean;
64
+ renameSymbol?: boolean;
65
+ fileOutline?: boolean;
66
+ moveWithImports?: boolean;
67
+ findDefinition?: boolean;
68
+ extractToFile?: boolean;
69
+ addImport?: boolean;
70
+ getDiagnostics?: boolean;
71
+ organizeImports?: boolean;
72
+ analyzeScope?: boolean;
73
+ };
74
+ contextSavings?: SaVmContextSavingsConfig;
75
+ };
76
+ export declare function normalizeSaVmPolicy(config: SaVmPolicyConfig | undefined, cwd: string, additionalRoots?: string[]): NormalizedSaVmPolicy;
77
+ export declare function checkSaVmPath(policy: NormalizedSaVmPolicy, operation: SaVmPathOperation, candidate: string, cwd: string): SaVmPolicyDecision;
78
+ export declare function checkSaVmDelete(policy: NormalizedSaVmPolicy, candidate: string, cwd: string): SaVmPolicyDecision;
79
+ export declare function checkSaVmHttp(policy: NormalizedSaVmPolicy, urlValue: string, methodValue?: string): SaVmPolicyDecision;
80
+ export declare function checkSaVmEnv(policy: NormalizedSaVmPolicy, name: string): SaVmPolicyDecision;
81
+ export declare function checkSaVmProcess(policy: NormalizedSaVmPolicy, executable: string, args?: string[]): SaVmPolicyDecision;
82
+ export declare function checkSaVmBunProfile(policy: NormalizedSaVmPolicy, profile: string): SaVmPolicyDecision;
83
+ export declare function checkSaVmBunExecution(policy: NormalizedSaVmPolicy, bunBinary: string, subcommand: string, args?: string[]): SaVmPolicyDecision;
84
+ export declare function isSaVmScriptExecutionAllowed(policy: NormalizedSaVmPolicy, executable: string): boolean;
85
+ export type SaVmExecutionRequestKind = "bun" | "javascript" | "python" | "other";
86
+ export declare function classifySaVmExecutionRequest(input: {
87
+ action?: unknown;
88
+ language?: unknown;
89
+ subcommand?: unknown;
90
+ args?: unknown;
91
+ test_file?: unknown;
92
+ filter?: unknown;
93
+ profile?: unknown;
94
+ }): {
95
+ kind: SaVmExecutionRequestKind;
96
+ isBun: boolean;
97
+ isJs: boolean;
98
+ isPy: boolean;
99
+ };
100
+ export declare function classifyBunRequest(input: {
101
+ action?: unknown;
102
+ subcommand?: unknown;
103
+ args?: unknown;
104
+ test_file?: unknown;
105
+ filter?: unknown;
106
+ profile?: unknown;
107
+ }): boolean;
108
+ export declare function extractCommandArgv(value: unknown): {
109
+ executable: string;
110
+ args: string[];
111
+ } | null;
112
+ export declare function pathWithin(root: string, candidate: string): boolean;
@@ -0,0 +1 @@
1
+ export declare function killProcessTree(pid: number | undefined): void;
@@ -0,0 +1,9 @@
1
+ export type SaVmRequestValidation = {
2
+ ok: true;
3
+ isParallel: boolean;
4
+ } | {
5
+ ok: false;
6
+ error: string;
7
+ code: "CUX-SA-VM-SLA-REQUIRED" | "CUX-SA-VM-INVALID-INPUT";
8
+ };
9
+ export declare function validateSaVmRequestBody(body: Record<string, unknown>): SaVmRequestValidation;
@@ -0,0 +1,12 @@
1
+ export type SaVmRunResult = {
2
+ ok: boolean;
3
+ kind: "success" | "sa_error" | "capability_denied" | "fuel_exhausted" | "timeout" | "mem_quota" | "policy_invalid" | "stack_overflow" | "crashed" | "unavailable";
4
+ exitCode: number | null;
5
+ stdout: string;
6
+ stderr: string;
7
+ saVmEvents: Array<Record<string, unknown>>;
8
+ saVmViolation: Record<string, unknown> | null;
9
+ durationMs: number;
10
+ };
11
+ export type SaVmRunResultKind = "success" | "sa_error" | "capability_denied" | "fuel_exhausted" | "timeout" | "mem_quota" | "policy_invalid" | "stack_overflow" | "crashed" | "unavailable";
12
+ export declare function resultKind(exitCode: number | null, stderr?: string): SaVmRunResultKind;
@@ -0,0 +1,353 @@
1
+ import type { SaVmPolicyConfig } from "../shared-types.js";
2
+ import { type SaVmBunProfile } from "../shared-types.js";
3
+ export type SaVmFsCapability = {
4
+ op: "read" | "write" | "append" | "edit" | "create" | "delete" | "rename" | "metadata";
5
+ path: string;
6
+ };
7
+ export type SaVmNetCapability = {
8
+ url: string;
9
+ methods?: string[];
10
+ };
11
+ export type SaVmActionType = "read" | "read_file" | "read_lines" | "read_file_tail" | "tail_file" | "tail" | "find" | "find_files" | "list_files" | "write" | "write_file" | "edit" | "edit_file" | "apply_patch" | "patch" | "delete" | "delete_file" | "remove_file" | "safe_delete" | "move" | "move_file" | "rename" | "rename_file" | "copy" | "copy_file" | "stat" | "file_info" | "test_path" | "file_exists" | "exists" | "ensure_dir" | "mkdir" | "vm-read" | "vm_read" | "count_lines" | "line_count" | "list_dir" | "grep" | "grep_search" | "grep_async" | "grep_search_async" | "async_grep" | "http_fetch" | "fetch" | "run_js" | "exec_js" | "run_py" | "run_python" | "exec_py" | "clear_tool_history" | "prune_tool_history" | "find_references" | "find_all_references" | "find_implementations" | "find_impl" | "implementations" | "file_outline" | "outline" | "rename_symbol" | "symbol_rename" | "move_file_with_imports" | "move_with_imports" | "find_definition" | "goto_definition" | "def" | "extract_to_file" | "extract_file" | "extract_module" | "add_import" | "insert_import" | "get_diagnostics" | "diagnostics" | "check_syntax" | "workspace_diagnostics" | "project_diagnostics" | "all_diagnostics" | "organize_imports" | "clean_unused_imports" | "sort_imports" | "analyze_scope" | "scope_analysis" | "run_bun" | "run_bun_profile" | "run_project_check" | "project_check" | "run_host" | "exec_host" | "host";
12
+ export declare const SA_VM_BUN_PROFILES: readonly SaVmBunProfile[];
13
+ export type { SaVmBunProfile };
14
+ export type SaVmRunInput = {
15
+ /** Built-in action shortcut. Automatically expands to standard native operations or SLA. */
16
+ action?: SaVmActionType | string;
17
+ path?: string;
18
+ file?: string;
19
+ dest?: string;
20
+ target?: string;
21
+ content?: string;
22
+ profile?: string;
23
+ subcommand?: string;
24
+ filter?: string;
25
+ test_file?: string;
26
+ keep_last_n_turns?: number;
27
+ filter_tools?: string[];
28
+ reason?: string;
29
+ symbol?: string;
30
+ old_name?: string;
31
+ new_name?: string;
32
+ statement?: string;
33
+ import_statement?: string;
34
+ symbols?: string[] | string;
35
+ exported_symbols?: string[] | string;
36
+ component_name?: string;
37
+ sort?: boolean;
38
+ remove_unused?: boolean;
39
+ merge_duplicates?: boolean;
40
+ module?: string;
41
+ include_body?: boolean;
42
+ is_type?: boolean;
43
+ dry_run?: boolean;
44
+ check_references?: boolean;
45
+ force?: boolean;
46
+ name?: string;
47
+ max_files?: number;
48
+ max_errors?: number;
49
+ detail?: boolean;
50
+ max_results?: number;
51
+ limit?: number;
52
+ candidate_files?: string[];
53
+ files?: string[];
54
+ exclude_comments?: boolean;
55
+ include_declarations?: boolean;
56
+ old_text?: string;
57
+ new_text?: string;
58
+ start_line?: number;
59
+ end_line?: number;
60
+ offset?: number;
61
+ max_tokens?: number;
62
+ max_token?: number;
63
+ maxtoken?: number;
64
+ remaining_tokens?: number;
65
+ tokens_remaining?: number;
66
+ tokens_left?: number;
67
+ max_lines?: number;
68
+ max_line_length?: number;
69
+ numbered?: boolean;
70
+ dir?: string;
71
+ pattern?: string;
72
+ type?: "all" | "file" | "directory" | string;
73
+ max_bytes?: number;
74
+ max_entries?: number;
75
+ max_depth?: number;
76
+ depth?: number;
77
+ recursive?: boolean;
78
+ patch?: string;
79
+ from?: string;
80
+ to?: string;
81
+ query?: string;
82
+ queries?: string[];
83
+ path_pattern?: string;
84
+ is_regex?: boolean;
85
+ regex?: boolean;
86
+ case_sensitive?: boolean;
87
+ lines?: number;
88
+ tail?: boolean;
89
+ max_matches?: number;
90
+ url?: string;
91
+ method?: string;
92
+ headers?: Record<string, string>;
93
+ body?: string;
94
+ timeout_ms?: number;
95
+ timeout?: number;
96
+ source?: string;
97
+ language?: "js" | "javascript" | "bun" | "ts" | "typescript" | "node" | "py" | "python" | "sa" | "sla";
98
+ exe?: string;
99
+ args?: string[];
100
+ env?: Record<string, string>;
101
+ head_lines?: number;
102
+ tail_lines?: number;
103
+ requested_caps?: {
104
+ fs?: Array<string | SaVmFsCapability>;
105
+ net?: SaVmNetCapability[];
106
+ env?: string[];
107
+ process?: boolean;
108
+ };
109
+ limits?: {
110
+ fuel?: number;
111
+ deadline_ms?: number;
112
+ mem_cap_bytes?: number;
113
+ max_call_depth?: number;
114
+ };
115
+ cwd?: string;
116
+ additionalRoots?: string[];
117
+ policy?: SaVmPolicyConfig;
118
+ parallel?: Array<Omit<SaVmRunInput, "parallel">>;
119
+ concurrency?: number;
120
+ };
121
+ export declare function expandSaVmActionInput(input: SaVmRunInput): SaVmRunInput;
122
+ export type SaVmRunResult = {
123
+ ok: boolean;
124
+ kind: "success" | "sa_error" | "capability_denied" | "fuel_exhausted" | "timeout" | "mem_quota" | "policy_invalid" | "stack_overflow" | "crashed" | "unavailable";
125
+ exitCode: number | null;
126
+ stdout: string;
127
+ stderr: string;
128
+ saVmEvents: Array<Record<string, unknown>>;
129
+ saVmViolation: Record<string, unknown> | null;
130
+ durationMs: number;
131
+ };
132
+ declare const DEFAULT_LIMITS: {
133
+ fuel: number;
134
+ deadline_ms: number;
135
+ mem_cap_bytes: number;
136
+ max_call_depth: number;
137
+ };
138
+ export declare function resolveTimeoutMs(input: {
139
+ timeout_ms?: number;
140
+ timeout?: number;
141
+ } | undefined, defaultMs?: number): number;
142
+ interface GitIgnoreRule {
143
+ negated: boolean;
144
+ dirOnly: boolean;
145
+ hasSlash: boolean;
146
+ anchored: boolean;
147
+ regex: RegExp;
148
+ }
149
+ export declare function loadGitIgnoreRules(dir: string): GitIgnoreRule[];
150
+ export declare function isGitIgnored(name: string, isDir: boolean, rules: GitIgnoreRule[], relativePath?: string): boolean;
151
+ export interface NativeReadFileOptions {
152
+ startLine?: number;
153
+ endLine?: number;
154
+ offset?: number;
155
+ maxTokens?: number;
156
+ remainingTokens?: number;
157
+ maxBytes?: number;
158
+ maxLines?: number;
159
+ maxLineLength?: number;
160
+ numbered?: boolean;
161
+ }
162
+ export declare function compileSearchMatcher(query: string, isRegex?: boolean, caseSensitive?: boolean): (content: string) => boolean;
163
+ export declare function matchesFilePattern(fileName: string, relPath: string, pattern: string, pathPattern?: string, isRegex?: boolean): boolean;
164
+ export declare function nativeDeleteFile(filePath: string, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
165
+ export declare function nativeSafeDelete(rawPath: string | undefined, options: {
166
+ path?: string;
167
+ file?: string;
168
+ target?: string;
169
+ check_references?: boolean;
170
+ force?: boolean;
171
+ max_results?: number;
172
+ timeout_ms?: number;
173
+ timeout?: number;
174
+ }, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
175
+ export declare function nativeMoveFile(fromPath: string, toPath: string, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
176
+ export declare function nativeEnsureDir(dirPath: string, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
177
+ export declare function nativeListDir(dirPath: string | undefined, maxEntries: number | undefined, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number, timeoutOpts?: {
178
+ timeout_ms?: number;
179
+ timeout?: number;
180
+ }, extraOpts?: {
181
+ depth?: number;
182
+ max_depth?: number;
183
+ recursive?: boolean;
184
+ type?: "all" | "file" | "directory" | string;
185
+ }): Promise<SaVmRunResult>;
186
+ export declare function nativeGrepSearch(query: string, searchDir: string | undefined, pattern: string | undefined, maxMatches: number | undefined, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number, timeoutOpts?: {
187
+ timeout_ms?: number;
188
+ timeout?: number;
189
+ }, extraOpts?: {
190
+ is_regex?: boolean;
191
+ regex?: boolean;
192
+ case_sensitive?: boolean;
193
+ path_pattern?: string;
194
+ }): Promise<SaVmRunResult>;
195
+ export declare function nativeGrepSearchAsync(query: string | string[], searchDir: string | undefined, pattern: string | undefined, maxMatches: number | undefined, concurrency: number | undefined, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number, timeoutOpts?: {
196
+ timeout_ms?: number;
197
+ timeout?: number;
198
+ }, extraOpts?: {
199
+ is_regex?: boolean;
200
+ regex?: boolean;
201
+ case_sensitive?: boolean;
202
+ path_pattern?: string;
203
+ }): Promise<SaVmRunResult>;
204
+ export declare function nativeFindReferences(rawSymbol: string | undefined, options: {
205
+ detail?: boolean;
206
+ candidate_files?: string[];
207
+ files?: string[];
208
+ max_results?: number;
209
+ limit?: number;
210
+ max_tokens?: number;
211
+ dir?: string;
212
+ pattern?: string;
213
+ exclude_comments?: boolean;
214
+ include_declarations?: boolean;
215
+ timeout_ms?: number;
216
+ timeout?: number;
217
+ }, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
218
+ export declare function nativeFindImplementations(rawSymbol: string | undefined, options: {
219
+ symbol?: string;
220
+ target?: string;
221
+ name?: string;
222
+ query?: string;
223
+ content?: string;
224
+ dir?: string;
225
+ pattern?: string;
226
+ candidate_files?: string[];
227
+ files?: string[];
228
+ include_body?: boolean;
229
+ detail?: boolean;
230
+ max_results?: number;
231
+ limit?: number;
232
+ max_tokens?: number;
233
+ timeout_ms?: number;
234
+ timeout?: number;
235
+ }, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
236
+ export declare function nativeFileOutline(rawPath: string, options: {
237
+ detail?: boolean;
238
+ max_tokens?: number;
239
+ }, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
240
+ export declare function nativeRenameSymbol(rawSymbol: string, rawNewName: string, options: {
241
+ path?: string;
242
+ dir?: string;
243
+ candidate_files?: string[];
244
+ files?: string[];
245
+ dry_run?: boolean;
246
+ detail?: boolean;
247
+ timeout_ms?: number;
248
+ timeout?: number;
249
+ }, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
250
+ export declare function nativeMoveFileWithImports(rawFrom: string, rawTo: string, options: {
251
+ dry_run?: boolean;
252
+ }, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
253
+ export declare function nativeFindDefinition(rawSymbol: string, rawPath: string | undefined, options: {
254
+ include_body?: boolean;
255
+ max_lines?: number;
256
+ }, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
257
+ export declare function nativeExtractToFile(rawSource: string, rawTarget: string, startLine: number | undefined, endLine: number | undefined, options: {
258
+ symbols?: string[] | string;
259
+ component_name?: string;
260
+ dry_run?: boolean;
261
+ }, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
262
+ export declare function nativeAddImport(rawPath: string, options: {
263
+ statement?: string;
264
+ symbol?: string;
265
+ module?: string;
266
+ is_type?: boolean;
267
+ dry_run?: boolean;
268
+ }, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
269
+ export declare function nativeGetDiagnostics(rawPath: string, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
270
+ export declare function nativeWorkspaceDiagnostics(rawDir: string | undefined, options: {
271
+ pattern?: string;
272
+ max_files?: number;
273
+ max_errors?: number;
274
+ max_tokens?: number;
275
+ detail?: boolean;
276
+ timeout_ms?: number;
277
+ timeout?: number;
278
+ }, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
279
+ export declare function nativeOrganizeImports(rawPath: string, options: {
280
+ sort?: boolean;
281
+ remove_unused?: boolean;
282
+ merge_duplicates?: boolean;
283
+ dry_run?: boolean;
284
+ }, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
285
+ export declare function nativeAnalyzeScope(rawPath: string, startLine: number | undefined, endLine: number | undefined, options: {
286
+ component_name?: string;
287
+ }, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
288
+ export declare function nativeApplyPatch(patchText: string, policy: SaVmPolicyConfig | undefined, cwd: string, additionalRoots: string[] | undefined, startedAt: number): Promise<SaVmRunResult>;
289
+ export declare function nativeCopyFile(fromPath: string, toPath: string, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
290
+ export declare function nativeFileInfo(filePath: string, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
291
+ export declare function nativeCountLines(filePath: string, policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
292
+ export declare function nativeHttpFetch(url: string, method?: string, headers?: Record<string, string>, body?: string, policy?: SaVmPolicyConfig, cwd?: string, startedAt?: number, timeoutOpts?: {
293
+ timeout_ms?: number;
294
+ timeout?: number;
295
+ }): Promise<SaVmRunResult>;
296
+ export declare const ALLOWED_HOST_SHORT_NAMES: Set<string>;
297
+ export declare const FORBIDDEN_HOST_SUBCOMMANDS: Set<string>;
298
+ export declare const ALLOWED_HOST_ENV_KEYS: Set<string>;
299
+ interface RunHostCacheEntry {
300
+ stdout: string;
301
+ stderr: string;
302
+ exitCode: number;
303
+ mtimeMs: number;
304
+ }
305
+ export declare const runHostHelpCache: Map<string, RunHostCacheEntry>;
306
+ export declare let runHostProcessSpawnCount: number;
307
+ export declare let runHostCacheHitCount: number;
308
+ export declare function resetRunHostCacheForTest(): void;
309
+ export declare function resolveHostExecutable(exe: string, cwd: string): {
310
+ ok: true;
311
+ path: string;
312
+ isAllowlist: boolean;
313
+ } | {
314
+ ok: false;
315
+ reason: string;
316
+ kind: "capability_denied" | "unavailable";
317
+ };
318
+ export declare function sliceAndFilterOutput(rawStdout: string, options: {
319
+ filter?: string;
320
+ head_lines?: number;
321
+ tail_lines?: number;
322
+ max_tokens?: number;
323
+ max_token?: number;
324
+ }): string;
325
+ export declare function nativeRunHost(rawInput: SaVmRunInput, _policy: SaVmPolicyConfig | undefined, cwd: string, startedAt: number): Promise<SaVmRunResult>;
326
+ export declare function detectBatchDependencyViolation(tasks: SaVmRunInput[], cwd: string): {
327
+ conflictedPath: string;
328
+ writeTaskIndex: number;
329
+ readTaskIndex: number;
330
+ } | null;
331
+ export declare function runSaVmTool(rawInput: SaVmRunInput, policyOverrideOrOptions?: SaVmPolicyConfig | {
332
+ cwd?: string;
333
+ policy?: SaVmPolicyConfig;
334
+ additionalRoots?: string[];
335
+ }, cwdOverride?: string): Promise<SaVmRunResult>;
336
+ export declare class SaVmInputError extends Error {
337
+ }
338
+ export declare class SaVmCapabilityDeniedError extends Error {
339
+ readonly exitCode = 228;
340
+ }
341
+ export declare function killProcessTree(pid: number | undefined): void;
342
+ export declare function resolvePythonBinary(): string;
343
+ export type SaVmExecutableLanguage = "js" | "py";
344
+ export declare function normalizeSaVmRunInput(rawInput: SaVmRunInput): {
345
+ source: string;
346
+ language: SaVmExecutableLanguage;
347
+ args: string[];
348
+ cwd: string;
349
+ limits: typeof DEFAULT_LIMITS;
350
+ policy: Record<string, unknown>;
351
+ };
352
+ export declare function resultKind(exitCode: number | null, stderr?: string): SaVmRunResult["kind"];
353
+ export declare function isSaVmBlockedToolName(value: unknown): boolean;