/** * The durable subagent-conversation presenter. * * This is the adapter layer between Harness authority and the terminal: it * reads durable direct children from `ctx.subagents.listDescendants`, reads * one child's bounded session window from `ctx.sessionQuery`, and routes human * follow-up/steer through the one human prompt operation Harness publishes. * It owns no lifecycle, no scheduling, and no child conversation state — every * paint re-reads the current reading, and neither a refresh nor a keystroke * invents a row the authority did not publish. * * It is deliberately separate from `HarnessWork`. Work owns active lifecycle * epochs keyed by `runId`, and a settled continuable child has no epoch while * still being a durable conversation. Folding this into Work would also make * `activeWorkCount` see a settled child, which gates retiring the session. * * Interruption is deliberately NOT part of this presenter. `/work` owns the * active lifecycle epoch and its existing human interrupt; a durable child's * catalog `activity` is session-store residency, not proof that a turn is * executing, so offering interrupt here could claim a cancellation Harness * only accepted as a no-op. The durable view inspects and continues instead. * @module dshline/subagents/presenter */ import type { SessionId } from '@deepseek-ai/dsh-session'; import type { SubagentRuntime } from '@deepseek-ai/dsh-subagent'; import type { LocalCommand } from '../local-commands.ts'; import type { TuiSlots } from '../slots.ts'; import { type SubagentChildRow } from './model.ts'; import type { ChildSessionReads, HumanSubagentSeam } from './seam.ts'; /** * The subagent operations this presenter calls. * * {@link HumanSubagentSeam} plus descendant discovery, and the addition is the * adopted generation forcing it rather than a preference. `listChildren` now * answers with the parent-owned `subagentCatalog` projection alone — id, * creation time, mode, label — while residency, child presence, and the * `corrupt`/`unsupported`/`unavailable` branch diagnostics are produced only by * the recursive walk. A catalog built from the flat read would have to invent * all three, and a branch Harness says it cannot read is exactly the row a * person most needs to see. * * This widens OBSERVATION only. `interrupt` is still absent for the reason * {@link HumanSubagentSeam} gives: residency is not proof that a turn is * executing, and an open lifecycle epoch is `/work`'s premise, not this * presenter's. */ export type SubagentCatalogSeam = HumanSubagentSeam & Pick; /** Narrow dependencies the subagent-conversation presenter needs. */ export interface SubagentsPresenterDeps { /** Live-region registry that owns the overlay stack. */ readonly slots: Pick; /** The attached session, which is the durable direct parent Harness authorizes. */ readonly parentSessionId: SessionId; /** Redraw after a read or action changes presentation state. */ readonly invalidate: () => void; /** Human-authoritative subagent operations, or undefined without `ctx.subagents`. */ readonly subagents?: SubagentCatalogSeam; /** Bounded child-session reads, or undefined without `ctx.sessionQuery`. */ readonly query?: ChildSessionReads; /** Subscribe to parent-scoped subagent lifecycle edges. */ readonly onLifecycle?: (listener: () => void) => () => void; /** * Subscribe to Harness session events, for a selected child's staleness hint. * @param listener - receives the event's durable session id. */ readonly onSessionEvent?: (listener: (sessionId: string) => void) => () => void; } /** The subagent-conversation capability as one local command and entry point. */ export interface SubagentsPresenter { /** `/subagents` — browse durable direct children and inspect one. */ readonly command: LocalCommand; /** Open the catalog as the root `/subagents` surface, where Escape closes it. */ open(): void; /** Open the catalog nested over Work, where Escape returns to Work. */ openFromWork(): void; /** * Open one known durable child's conversation directly, with NO catalog * surface underneath. `child` is keyed by the durable child session id. */ openChild(child: SubagentChildRow): void; /** Abort in-flight reads and release lifecycle subscriptions. */ dispose(): void; } /** * Build the durable subagent-conversation presenter. * @param deps - narrow Harness seams, the parent address, and surface controls. * @returns the presenter's local command and Work entry point. */ export declare function createSubagentsPresenter(deps: SubagentsPresenterDeps): SubagentsPresenter; //# sourceMappingURL=presenter.d.ts.map