/** * Per-child semantic activity for Work rows. * * A live in-process subagent exposes a real child Agent, so its activity can be * folded with the exact vocabulary the main status line uses: the lifecycle * phase from its session events, live model output from its own * `agent/assistant-stream` frames, and the tool activity from its pending * calls' presentations. A remote run without a local Agent exposes none of * those, and the observer simply never attaches — the row then shows no * invented activity. * * From those same frames the observer also keeps a strictly bounded, * transient tail of the newest assistant TEXT, for the detail stage to show * that the child is answering rather than merely running. It is never a * transcript, is cleared on every attempt and turn boundary, and is dropped * with the observer. * @module dshline/work/activity */ import type { Context } from '@deepseek-ai/cordis'; import type { Agent, AgentStatus } from '@deepseek-ai/dsh-agent'; import type { ToolDefinition } from '@deepseek-ai/dsh-tools'; import type { ActivityWord } from '../activity.ts'; /** * How many UTF-16 code units of the newest assistant text a Work row keeps. * * A Work detail fact is one physical row and the widest Work frame is 100 * columns, so its content budget is under ~98 display columns. A CJK code * point is one UTF-16 code unit and two columns, and an astral code point is * two code units and two columns, so 256 code units is safely more than any one * row can display. Retention is capped at that many code units regardless of * total answer length: enough recent text for the row, bounded independently of * the response, and deliberately not a durable transcript. */ export declare const OUTPUT_TAIL_LIMIT = 256; /** * Append one streamed text delta to a bounded Work output tail. * * Retention stays capped at `limit` UTF-16 code units regardless of answer * length, and the newest text always wins. A delta at least as long as the cap * is reduced to its OWN newest suffix before the prior tail is considered, so a * single huge provider delta never has the old tail concatenated onto it. A * smaller delta is joined to the prior tail, and that intermediate is under * twice the cap because the prior tail is already bounded. The retained front * boundary is surrogate-safe, so retention cannot leave half an astral code * point. This stores recent text only; display-width truncation stays in the * renderer. * @param current - the currently retained tail. * @param delta - the newest streamed text fragment. * @param limit - the retention cap in UTF-16 code units. * @returns the new retained tail, at most `limit` units. */ export declare function appendOutputTail(current: string, delta: string, limit?: number): string; /** The live activity facts a Work row may truthfully present. */ export interface ChildActivityReading { /** * The semantic word; present only while the live child Agent is observed. * `waiting` is the honest reading for a resident child between turns. */ readonly word?: ActivityWord; /** The newest pending call's presentation title, when its tool declared one. */ readonly title?: string; /** * The newest streamed assistant text of the current attempt; absent when * there is none. Never a durable transcript, and cleared at every attempt, * turn, and observer boundary. */ readonly outputTail?: string; /** Whether the live Agent is running, which drives the row's spinner. */ readonly busy: boolean; /** The live Agent's published status, for the detail stage. */ readonly status?: AgentStatus; } /** * Observe one child Agent's semantic activity until its run epoch ends. * * Subscribed on the runner's own agent context with exact identity filters — * the same listener surface the main status uses, where scope admission already * reaches descendant sessions and agents. Everything is event-driven: no timer * exists here, and disposal is synchronous, so a replaced Agent under the same * durable id can never mutate this epoch's state. */ export declare class ChildActivityObserver { private readonly child; private readonly onChange; private phase; /** * The newest assistant text of the current attempt, bounded to * {@link OUTPUT_TAIL_LIMIT} code units. Transient presentation only. */ private output; /** The shared attempt-identity gate, so a stale frame is never folded. */ private readonly attempt; private readonly pending; private readonly disposers; private disposed; private status; /** * @param ctx - the context to subscribe on (the Work runner's agent context). * @param child - the exact live child Agent this epoch observes. * @param resolveTool - resolves a tool definition as the child sees it. * @param onChange - redraw request after any folded event. */ constructor(ctx: Context, child: Agent, resolveTool: (name: string) => ToolDefinition | undefined, onChange: () => void); /** Fold one child session event with the shared status vocabulary. */ private foldEvent; /** * Read the current semantic activity. * @returns the word, optional operation title, and animation truth for this child. */ reading(): ChildActivityReading; /** Stop observing; late events are contained and never repaint this epoch. */ dispose(): void; } //# sourceMappingURL=activity.d.ts.map