UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

57 lines • 3.27 kB
import type { RedirectResult } from '../../../../context/session_context.ts'; import type { ByteSource } from '../../../../io/types.ts'; import type { MountRegistry } from '../../../mount/registry.ts'; import type { SessionState } from '../../../session/session.ts'; import type { BuiltinCall, ExecuteStringFn } from '../types.ts'; /** GNU's report of a command timeout finds nothing to run for. */ export declare function timeoutMissing(name: string): string; /** * A timeout DURATION in seconds: a C float plus an optional s/m/h/d. * * GNU timeout 9.7 takes the longest C-locale floating-point number at the * front of the word, leading whitespace, an exponent, a hex float and inf * included; at most one suffix letter may follow, and a negative or NaN * interval is refused. */ export declare function durationSeconds(raw: string): number | null; /** * The signal a `-s` value names, null if it names none. Measured on GNU * timeout 9.7: a number (decimal digits only, no sign or blank) may carry a * shell's 128 or 256 offset, as `$?` does; a name is read in any case, with * or without `SIG`, and `SIG` before digits takes only 0 to 64. `RTMIN+n` * and `RTMAX-n` stay inside the realtime range. Mirrors Python's * parse_signal. */ export declare function parseSignal(operand: string): number | null; /** * A signal's name as `timeout -v` prints it, or its number. The realtime * range is named from RTMIN up to its middle (RTMIN+15 is 49) and from RTMAX * above it (50 is RTMAX-14), as GNU 9.7 and bash do. Mirrors Python's * signal_name. */ export declare function signalName(number: number): string; /** * Run `timeout [OPTION] DURATION COMMAND [ARG...]` (GNU timeout). * * The inner line is built with shellJoin so already-expanded words survive * re-parsing as one token each (GNU timeout execs the command without a * shell). The command reads timeout's stdin. At the deadline the command * gets -s's signal (TERM by default), and a command here is a promise, not a * process, so the signal's default action decides: one that terminates * aborts the run, and 124 reports it, or the status a shell would show with * --preserve-status; one that is ignored (0, CHLD, CONT, URG, WINCH) lets * the run carry on, and -k's KILL ends it later with 137; a stop halts it * until that KILL. timeout signals its own process group unless * --foreground, so it dies of what it cannot ignore (KILL, 32, 33), stops * itself on STOP, and never wakes after CHLD; each ends as GNU's does. -v * says each signal on stderr. The deadline aborts the inner run, not just * the wait for it: a promise cannot be cancelled, so the signal is what * stops a `tail -f` from polling on after 124 was already returned. The * command's stdout goes out as it writes it, as GNU's command writes to * timeout's own stdout; the status, stderr and node settle once that stream * ends. */ export declare function handleTimeout(executeFn: ExecuteStringFn, args: readonly string[], session: SessionState, stdin?: ByteSource | null, registry?: MountRegistry | null, lineSignal?: AbortSignal): Promise<RedirectResult>; /** The `timeout` arm. */ export declare function timeoutBuiltin(call: BuiltinCall): Promise<RedirectResult>; //# sourceMappingURL=timeout.d.ts.map