import type { ByteSource } from '../../io/types.ts'; import { IOResult } from '../../io/types.ts'; import type { CallStack } from '../../shell/call_stack.ts'; import { type JobTable } from '../../shell/job_table/index.ts'; import { Channel, type JobConsole } from '../../shell/console/index.ts'; import type { SessionView } from '../../ops/types.ts'; import type { Session } from '../session/session.ts'; import type { TSNodeLike } from '../../shell/types.ts'; import { ExecutionNode } from '../types.ts'; /** Per-call overrides a caller can layer onto the walker's deps. */ export interface ExecuteNodeOpts { sink?: JobConsole; signal?: AbortSignal; } export type ExecuteNodeFn = (node: TSNodeLike, session: Session, stdin: ByteSource | null, callStack: CallStack | null, opts?: ExecuteNodeOpts) => Promise<[ByteSource | null, IOResult, ExecutionNode]>; export type JobHandlerResult = [ByteSource | null, IOResult, ExecutionNode]; /** * Send a command's output to a console as chunks arrive. * * Consuming the stream piece by piece rather than materializing it whole * is what lets a reader watch a running job. A command that computes its * output eagerly still lands in one chunk, because there was nothing to * observe before it finished. */ export declare function pump(console_: JobConsole, channel: Channel, stream: ByteSource | null): Promise; export declare function handleBackground(executeNode: ExecuteNodeFn, left: TSNodeLike, right: TSNodeLike | null, session: Session, jobTable: JobTable, agentId: string | null, stdin?: ByteSource | null, callStack?: CallStack | null): Promise; /** * Wait for background jobs, with bash's option surface. Bare `wait` * joins every job and adopts each one's output in id order (a real shell * has nothing to adopt; mirage jobs print to their console, so the shell * has to surface it or it is stranded); `wait ID...` joins those and * answers the last one's status; `-n` joins the first of the given jobs * (or of all) to finish, 127 when there is nothing to wait for; `-p VAR` * stores the id of the job whose status is answered, unsetting VAR when * none is (which is the bare form, since it reports no one job); `-f` is * accepted, since a mirage job cannot stop, only end. * * Deliberate divergence: bash stores a PID in `-p`'s variable. A mirage * job is a coroutine with no OS process, so what goes there is the job * id, the same number `%N` and `jobs` already name. */ export declare function handleWait(jobTable: JobTable, parts: string[], _session?: Session | null, view?: SessionView | null): Promise; /** * Drop jobs from the table without stopping them. No operand means the * current job (the newest), `-a` every job, `-r` the running ones, and * `%N`/`N` specs name jobs; `-h` marks a job to survive SIGHUP and leaves * it in the table, a no-op here since no hangup is ever delivered. A spec * naming no job is `no such job`, exit 1, and the others still drop. */ export declare function handleDisown(jobTable: JobTable, parts: string[], _session?: Session | null, _view?: SessionView | null): JobHandlerResult; /** * Foreground a background job: print its command line, then block on it * and adopt its output and exit code. */ export declare function handleFg(jobTable: JobTable, parts: string[], _session?: Session | null, _view?: SessionView | null): Promise; export declare function handleKill(jobTable: JobTable, parts: string[], _session?: Session | null, _view?: SessionView | null): Promise; /** * List jobs, with bash's flags applied to mirage's row shape. * * Mirage jobs are identified by table id, not pid, and never stop, so * two of GNU's flags map onto that model rather than reproducing it: * `-p` prints the job id (GNU's pid), and `-s` (stopped only) lists * nothing. `-r` keeps the running ones, `-l` adds the id column, and * `-n` lists only the jobs whose status changed since the last `jobs` * (which is every completed one not yet reaped, since reaping is what a * listing does). A jobspec operand (`%2` or `2`) filters to that job; * one that names no job is `no such job`, exit 1. `-x` is not carried, * and an unknown letter is GNU's usage line, exit 2. */ export declare function handleJobs(jobTable: JobTable, parts: string[], _session?: Session | null, _view?: SessionView | null): JobHandlerResult; export declare function handlePs(jobTable: JobTable, parts: string[], _session?: Session | null, _view?: SessionView | null): JobHandlerResult; //# sourceMappingURL=jobs.d.ts.map