import { a as ArtifactsCLIInput, o as ArtifactsCLIResult } from "../../shared-C9CTqSgh.js"; import { t as WorkspaceEgressPolicy } from "../../shared-3MpgXJDw.js"; import { bt as MkdirOptions, ht as GitCliResult, mt as GitCliInput, vt as WriteFileContent, yt as WriteFileOptions } from "../../shared-BTtKnEVB.js"; import { c as ReadFileOptions, d as GrepOptions, f as WorkspaceGrepMatch, m as WorkspaceFoundEntry, n as WorkspaceBackend, o as WorkspaceStatResult, s as RmOptions, t as BackendHandle, u as WorkspaceDirentResult } from "../../shared-C-sNJ-xg.js"; import { a as WorkspaceServiceProxyProps } from "../../shared-C4j1mCMr.js"; import { WorkerEntrypoint } from "cloudflare:workers"; import { CustomCommand, SecureFetch } from "just-bash"; //#region src/backends/worker-shell/adapter.d.ts interface WorkspaceFs { readFile(path: string): Promise>; readFile(path: string, encoding: "utf8"): Promise; readFile(path: string, options: ReadFileOptions): Promise>; exists(path: string): Promise; stat(path: string): Promise; statOrNull(path: string): Promise; lstat(path: string): Promise; lstatOrNull(path: string): Promise; readdir(path: string): Promise; find(directory: string, pattern?: string): Promise; ls(prefix: string): Promise; grep(pattern: string, path: string, options?: GrepOptions): Promise; readlink(path: string): Promise; writeFile(path: string, content: WriteFileContent, options?: WriteFileOptions): Promise; mkdir(path: string, options?: MkdirOptions): Promise; rm(path: string, options?: RmOptions): Promise; chmod(path: string, mode: number): Promise; symlink(target: string, path: string): Promise; rename(oldPath: string, newPath: string): Promise; } interface FsStat { isFile: boolean; isDirectory: boolean; isSymbolicLink: boolean; mode: number; size: number; mtime: Date; } interface DirentEntry { name: string; isFile: boolean; isDirectory: boolean; isSymbolicLink: boolean; } type AdapterReadFileOptions = { encoding?: "utf8" | null; } | "utf8" | null | undefined; declare class WorkspaceFsAdapter { #private; constructor(fs: WorkspaceFs); readFile(path: string, _options?: AdapterReadFileOptions): Promise; readFileBuffer(path: string): Promise; exists(path: string): Promise; stat(path: string): Promise; lstat(path: string): Promise; readdir(path: string): Promise; readdirWithFileTypes(path: string): Promise; readlink(path: string): Promise; writeFile(path: string, content: string | Uint8Array, _options?: unknown): Promise; appendFile(path: string, content: string | Uint8Array, _options?: unknown): Promise; mkdir(path: string, options?: { recursive?: boolean; }): Promise; rm(path: string, options?: { recursive?: boolean; force?: boolean; }): Promise; chmod(path: string, mode: number): Promise; symlink(target: string, linkPath: string): Promise; cp(src: string, dest: string, options?: { recursive?: boolean; }): Promise; mv(src: string, dest: string): Promise; resolvePath(base: string, path: string): string; getAllPaths(): string[]; link(_existingPath: string, _newPath: string): Promise; utimes(_path: string, _atime: Date, _mtime: Date): Promise; realpath(path: string): Promise; } //#endregion //#region src/backends/worker-shell/git-command.d.ts /** Structural subset of the host stub the command needs. */ interface GitCommandHost { git: { cli(input: GitCliInput): Promise; }; } /** * Build a `git` custom command bound to a host workspace stub. * * Forwards argv, cwd, env, and stdin to the host's * `workspace.git.cli(...)`. The env Map from `CommandContext` is * flattened into a plain object on the way through — the wire * carries JSON, and the CLI dispatcher only reads `GIT_AUTHOR_*` / * `GIT_COMMITTER_*` from it today. * * The closure captures `ws` for the duration of `bash.exec`. The * caller (`ShellWorker.exec`) keeps `ws` alive until Bash settles * via the existing `finally` block; there's no new disposal * contract here. */ declare function defineGitCommand(ws: GitCommandHost): CustomCommand; //#endregion //#region src/backends/worker-shell/artifacts-command.d.ts /** * Structural subset of the host the command needs. It owns the * artifacts client and the workspace git CLI: the `create` shorthand * registers a git remote, and the artifacts package has no git of its * own, so the command bridges the two by handing the artifacts CLI a * `remoteAdd` closure backed by `git.cli(...)`. */ interface ArtifactsCommandHost extends GitCommandHost { artifacts: { cli(input: ArtifactsCLIInput): Promise; }; } /** * Build an `artifacts` custom command bound to a host artifacts * client. * * Forwards argv and env to the client's `cli(...)`. The env Map * from `CommandContext` is flattened into a plain object on the way * through. The artifacts CLI does not read stdin, so it is dropped. */ declare function defineArtifactsCommand(host: ArtifactsCommandHost): CustomCommand; //#endregion //#region src/backends/worker-shell/assets-command.d.ts interface AssetsCommandHost { assets?: { publish(path: string, options: { expiresAfter: number; }): Promise; }; } declare function defineAssetsCommand(ws: AssetsCommandHost): CustomCommand; //#endregion //#region src/backends/worker-shell/entrypoint.d.ts interface ExecInput { command: string; cwd?: string; id?: string; timeoutMs?: number; env?: Record; stdin?: Uint8Array; } interface ShellWorkerOptions { cwd?: string; fetch?: SecureFetch | null; } interface ShellWorkerEnv { HOST: ShellHostFetcher; } interface ShellHostFetcher { getWorkspace(): Promise; } interface HostWorkspaceStub extends GitCommandHost, AssetsCommandHost { fs: WorkspaceFs; artifacts: ArtifactsCommandHost["artifacts"]; [Symbol.dispose]?: () => void; } declare class ShellWorker extends WorkerEntrypoint { #private; protected readonly shellOptions: ShellWorkerOptions; protected bashFactoryOverride: ((command: string, options: { cwd?: string; env?: Record; stdin?: Uint8Array; signal?: AbortSignal; customCommands: CustomCommand[]; }) => Promise<{ stdout: string; stderr: string; exitCode: number; }>) | undefined; /** * Subclass hook for registering additional custom commands * alongside the built-in `git` command. Symmetric with * `shellOptions`: the base class returns an empty list and * subclasses override to layer their own commands on top. * * Called once per `exec` with the live host stub the shell * already reached, so subclass commands share that stub's * lifetime without needing to refetch. */ protected extraCommands(_ws: HostWorkspaceStub): CustomCommand[]; fetch(_request: Request): Promise; exec(input: ExecInput): Promise<{ id: string; events: ReadableStream; }>; getExec(input: { id: string; }): Promise<{ id: string; events: ReadableStream; }>; killExec(input: { id: string; signal?: "SIGTERM" | "SIGKILL" | "SIGINT" | "SIGHUP"; }): Promise; } //#endregion //#region src/backends/worker-shell/runtime-modules.d.ts declare const SHELL_RUNTIME_MODULES: Readonly>; //#endregion //#region src/backends/worker-shell/shell-modules.d.ts type ShellModuleGroup = Readonly>; declare const SHELL_CORE_MODULES: ShellModuleGroup; declare function assembleShellModules(groups?: readonly ShellModuleGroup[]): Readonly>; //#endregion //#region src/backends/worker-shell/worker-shell.d.ts interface WorkerShellRuntime { exec(input: { command: string; cwd?: string; id?: string; timeoutMs?: number; env?: Record; stdin?: Uint8Array; }): Promise<{ id: string; events: ReadableStream; }>; getExec(input: { id: string; after?: number | "tail"; }): Promise<{ id: string; events: ReadableStream; }>; killExec(input: { id: string; signal?: "SIGTERM" | "SIGKILL" | "SIGINT" | "SIGHUP"; }): Promise; } interface WorkerShellLoader { get(name: string, getCode: () => WorkerLoaderCode | Promise): { getEntrypoint(name?: string): unknown; [Symbol.dispose]?: () => void; }; } interface WorkerLoaderCode { compatibilityDate: string; compatibilityFlags?: string[]; mainModule: string; modules: Record; env?: Record; globalOutbound?: unknown; } type WorkerShellSource = { type: "loader"; loader: WorkerShellLoader; workspace: WorkspaceServiceProxyProps; ctx: unknown; } | { type: "external-runtime"; connect(options: { egress: WorkspaceEgressPolicy; }): WorkerShellRuntime | Promise; }; interface WorkerShellBackendOptions { source?: WorkerShellSource; loader?: WorkerShellLoader; workspace?: WorkspaceServiceProxyProps; ctx?: unknown; loaderId?: string; compatibilityDate?: string; compatibilityFlags?: string[]; egress?: WorkspaceEgressPolicy; id?: string; commands?: readonly ShellModuleGroup[]; } /** * Runs shell commands with just-bash in a Dynamic Worker. * * Experimental: this API may change in any release and is not yet * suitable for production use. */ declare class WorkerShellBackend implements WorkspaceBackend { #private; readonly type = "worker-shell"; /** What this backend tells a model: a fast shell with a fixed command set. */ readonly description = "A just-bash shell in a Dynamic Worker. Starts fast, with no container and no direct network. Good for cat, grep, sed, awk, jq, head, tail, sort, find, text transformations, and a built-in `git` (clone, status, diff, log) that works through the workspace. Cannot run npm, node, python, or binaries outside its built-in command set."; readonly id: string; constructor(options: WorkerShellBackendOptions); connect(): Promise; } //#endregion export { type ArtifactsCommandHost, type AssetsCommandHost, type ExecInput, type GitCommandHost, SHELL_CORE_MODULES, SHELL_RUNTIME_MODULES, type ShellModuleGroup, ShellWorker, type ShellWorkerOptions, WorkerShellBackend, type WorkerShellBackendOptions, type WorkerShellLoader, type WorkerShellRuntime, type WorkerShellSource, type WorkspaceEgressPolicy, type WorkspaceFs, WorkspaceFsAdapter, assembleShellModules, defineArtifactsCommand, defineAssetsCommand, defineGitCommand }; //# sourceMappingURL=index.d.ts.map