/** * Ephemeral observation of ONE background Job's retained output. * * This is deliberately not a second Job runtime, a ring, or a history. The * registry owns the output ring and the byte coordinates; everything here is * presentation state that exists only while one Job's detail stage is open. * * The read is the one that does not move the model cursor: * `JobRegistry.readAt(id, from, caller)` rather than `read(id, caller)`. The * consuming `read` is how the MODEL collects a Job's output and may carry the * producer's terminal result; a terminal UI that called it would take bytes out * of the model's own mouth. This module therefore never names `read`, and the * capability probe fails the build if that member is ever reached. * * The race discipline is upstream's (`dsh-api-job-controller`'s observer): * SUBSCRIBE FIRST, then establish the anchor, then read. An observer that read * first and subscribed second loses every append landing in between, which is * exactly the window a noisy producer spends most of its time in. * * @module dshline/work/jobs */ import type { JobChannel, JobRegistry } from '@deepseek-ai/dsh-jobs'; import type { SessionId } from '@deepseek-ai/dsh-session'; /** * How many UTF-8 bytes of one Job's output the detail presentation retains. * * Bytes, not characters and not rows, and for the same reason the ring uses * them: eviction then cuts on a code-point boundary rather than guessing, and * the number stays comparable to the retention the Harness ring applies to the * same stream. The value is chosen against what a `/work` detail can ever draw. * A bounded live region is at most the terminal's rows, and Work frames cap * around 100 columns, so one frame shows well under 4 KiB of output; 32 KiB * holds roughly an order of magnitude more than any single view can display, * which keeps a long-running Job's detail useful while bounding memory * independently of how long the Job runs. It is a PRESENTATION cap, and being * smaller than a ring a fast producer can fill is the point: local eviction is * a normal, MARKED event here rather than a failure. */ export declare const JOB_OUTPUT_TAIL_BYTES: number; /** * One line of a Job's output as the presentation layer receives it. * * The channel is carried through rather than flattened, because deciding what * `stderr` MEANS is a presentation decision and flattening it here would take * that decision away. An unrecognized channel is treated exactly like an absent * one, as the seam's own contract requires. */ export interface JobOutputLine { /** The line's text, with its terminator removed. Empty on a gap marker. */ readonly text: string; /** The channel of the chunk that OPENED this line, when the producer labelled one. */ readonly channel?: JobChannel; /** Bytes immediately before this line are missing and were not retained. */ readonly gapBefore?: true; } /** The newest retained tail of one Job's output, in authoritative ring order. */ export interface JobOutputReading { /** Newest line last. Empty when the Job has produced nothing displayable. */ readonly lines: readonly JobOutputLine[]; } /** One open Job output observation, alive only while a Job detail is on screen. */ export interface JobOutputObservation { /** * The current bounded tail. * * This MATERIALIZES what event-driven reads already absorbed; it performs no * registry read of its own, so a repaint costs no `readAt` and the frame clock * can never become a poll. * @returns the retained lines, oldest first. */ reading(): JobOutputReading; /** Stop observing synchronously. Idempotent; late events reach nothing. */ dispose(): void; } /** What {@link observeJobOutput} needs in order to read one Job. */ export interface JobObservationOptions { /** The mounted registry. Never a stand-in that answers the consuming `read`. */ readonly jobs: JobRegistry; /** The exact Job being inspected. */ readonly id: string; /** * The attached session, passed to `get`/`readAt` as the fenced caller and * used as the subscription's owner filter. An UNOWNED Job still accepts it: * the seam's access contract is owner-relative, and an unowned Job is visible * to every caller. */ readonly caller: SessionId; /** Redraw the live region after a matching Harness event. */ readonly invalidate: () => void; /** Retention cap in UTF-8 bytes; defaults to {@link JOB_OUTPUT_TAIL_BYTES}. */ readonly limitBytes?: number; } /** * Observe one Job's retained output, non-consumingly, until disposed. * * Returns `undefined` when the Job could not be observed, which is the truthful * outcome for one that settled or vanished as the stage opened. The caller owns * the handle and must dispose it: that is the whole lifetime contract. * @param options - the registry, the exact Job, the fenced caller, and the redraw. * @returns an open observation, or undefined when the Job was not observable. */ export declare function observeJobOutput(options: JobObservationOptions): JobOutputObservation | undefined; //# sourceMappingURL=jobs.d.ts.map