import { type GrepPlan, type GrepQuery } from "./grepQuery.js"; import type { RuntimeContext } from "../runtime/state/context.js"; import type { StateStack } from "../runtime/state/stateStack.js"; import type { ThreadStore } from "../runtime/state/threadStore.js"; import { SpawnResult } from "./abortable.js"; import { type TildeMode } from "./prepareContainedPath.js"; export type ExecOptions = { /** * Allow-list of executable names. When set, only commands whose * `command` matches one of these strings (case-insensitive, * whitespace-trimmed) will run. Empty / unset = no restriction. * Pair with `allowedPaths` to also pin the working directory. */ allowedExecutables?: string[]; /** * Block-list of executable names. When set, any command whose * `command` matches one of these strings is rejected. */ blockedCommands?: string[]; /** * Directory-allow-list for `cwd`. When set, `cwd` must resolve * inside one of these roots (symlink-aware). Empty / unset = no * restriction. */ allowedPaths?: string[]; }; /** Deprecated context-injected wrapper kept during the ALS migration; * see `_exec`. */ export declare function __internal_exec(ctx: RuntimeContext, stack: StateStack, _threads: ThreadStore, command: string, args: string[], cwd: string, timeout: number, stdin: string, options?: ExecOptions): Promise; /** ALS-reading replacement for `__internal_exec`. */ export declare function _exec(command: string, args: string[], cwd: string, timeout: number, stdin: string, options?: ExecOptions): Promise; export type BashOptions = { /** * Reject any bash string whose first non-whitespace token matches * one of these entries (prefix match). Useful to block `rm`, * `sudo`, etc. */ blockedCommands?: string[]; /** * Directory-allow-list for `cwd`. When set, `cwd` must resolve * inside one of these roots (symlink-aware). Empty / unset = no * restriction. */ allowedPaths?: string[]; }; /** Deprecated context-injected wrapper kept during the ALS migration; * see `_bash`. */ export declare function __internal_bash(ctx: RuntimeContext, stack: StateStack, _threads: ThreadStore, command: string, cwd: string, timeout: number, stdin: string, options?: BashOptions): Promise; /** ALS-reading replacement for `__internal_bash`. */ export declare function _bash(command: string, cwd: string, timeout: number, stdin: string, options?: BashOptions): Promise; export type LsEntry = { name: string; path: string; type: "file" | "dir" | "other"; size: number; }; /** * List `dir`, a directory under `rootDir` ("." for the root itself). * Entries come back relative to `dir`. Symlinked entries are left out: * a link below the root is never followed, so there is nothing to say * about it. `isRoot` surfaces a readdir failure on the scanned dir * itself, while an unreadable subdirectory during a recursive walk is * skipped rather than failing the whole listing. */ export declare function _ls(rootDir: string, dir: string, recursive: boolean, maxResults?: number, allowedPaths?: string[]): Promise; export type GrepMatch = { file: string; line: number; text: string; }; export declare const SKIP_DIRS: Set; export type SearchTarget = { dir: string; file: string | null; }; /** What `ls`, `grep`, and `glob` were pointed at. `grep` may be pointed at * one file, which it then searches alone; `ls` and `glob` need a * directory. The wrappers call this before their interrupt, so a bad * path fails before anyone is asked to approve a search of it, and the * message tells the model what to do instead. */ export declare function _searchTarget(given: string, tool: "ls" | "grep" | "glob"): Promise; /** A grep path resolved for safeBash. `argument` is the path as bash * hands it to grep, with `~` expanded. grep prints file names starting * from it, so the shell-free path renders names from it too. */ export type GrepTarget = { dir: string; file: string | null; argument: string; }; /** `_searchTarget` for a path in a safeBash command, which is relative to * safeBash's cwd rather than the run's, and whose `~` bash expands only * when the word was unquoted. */ export declare function _searchTargetIn(given: string, cwd: string, tildeMode: TildeMode): Promise; /** Matching lines, or with `filesOnly` just the paths of files that have one. */ export type GrepResults = GrepMatch[] | string[]; /** Search `dir` under `rootDir`, or just `file` under `dir` when one is * given. Returned `file` paths are relative to `dir` so callers can hand * them to `read(file, dir)` directly. */ export declare function _grep(rootDir: string, dir: string, query: GrepQuery, maxResults: number, allowedPaths?: string[], respectGitignore?: boolean, file?: string | null): Promise; type LineHit = { line: number; text: string; }; /** Up to `limit` lines of one file that the plan selects, numbered from 1, * scanning no further than it must. A file's final newline does not start * a line, the same as grep, or `invert` would report an empty line past * the end of every file. */ export declare function firstMatchingLines(text: string, plan: GrepPlan, limit: number): LineHit[]; /** Glob under `dir` in `rootDir`. Returned paths are relative to `dir`. */ export declare function _glob(rootDir: string, dir: string, pattern: string, maxResults: number, allowedPaths?: string[]): Promise; export declare function escapeRegex(s: string): string; export type StatInfo = { exists: boolean; type: "file" | "dir" | "other" | "missing"; size: number; modifiedMs: number; }; /** Probe `target` under `rootDir`. A symlink below the root reports as * missing. The root itself ("." as target) is already real, so a * standalone probe passes the path as `rootDir` and "." as `target`. */ export declare function _stat(rootDir: string, target: string, allowedPaths?: string[]): Promise; export declare function _exists(rootDir: string, target: string, allowedPaths?: string[]): Promise; export declare function _which(command: string): Promise; export {};