/** * Guided first run: from an installed dshline to a model that answers. * * This is a conductor, not a surface. Every step it hands the reader on to is * a browser that already exists and is already the authority for what it does * — `/connect` configures and authenticates providers, `/model` chooses among * the routes that resulted — and setup neither reimplements nor wraps either * of them. It contributes exactly two things neither could: * * 1. **A reading, committed to scrollback.** What the installation actually * is, gathered once from the surfaces that own each answer, written as * finished rows a person can scroll back to and paste into a bug report. * Deliberately not an overlay: a bounded live region would scroll the * version numbers away the moment the next thing was drawn, and this is the * output most worth keeping. * 2. **An ordering.** Configure, then choose, then go — with the second step * offered only once the first produced something to choose from. * * ## Why it is not a wizard * * There is no state machine here and nothing is remembered between runs. Each * pass re-reads Harness from scratch and offers what is true NOW, so backing * out halfway leaves nothing behind, running it twice is the same as running * it once, and there is no "have I been set up" flag anywhere on disk to * disagree with the configuration it claims to describe. The loop below is the * whole control flow. * * ## Why it opens at all * * {@link setupNeeded} asks whether this launch would reach a composer that * cannot send: nothing registered, nothing selected, a selection naming a * route no adapter registered, or a selected route whose credential Harness * positively reports absent. The first three are synchronous registry and * selection reads and settle most launches on their own; only a launch that * passes all three pays the fourth, one narrow local read of that ONE route. * No adapter is asked for a catalog either way — see {@link setupReason} for * why a route count is not the question. That is the one condition worth * interrupting for, and an installation that works never sees this flow on its * own. `/setup` runs it on demand regardless, and a pass with no interactive * repair ends without one: a clean report at `✓ Ready.`, a warning only Harness * or a shell command can answer above its closing line. `/model` and * `/connect` remain the commands for optional changes. * @module dshline/setup */ import type { Context } from '@deepseek-ai/cordis'; import type { ModelSelectionRef } from '@deepseek-ai/dsh-agent'; import type { SetupFacts } from './harness.ts'; import type { SetupCheck } from './model.ts'; export type { HarnessGeneration, SetupFacts, SetupSelection } from './harness.ts'; export { adoptedGeneration, compareGenerations, gatherSetupFacts, readHarnessGeneration } from './harness.ts'; export type { SetupCheck, SetupMark, SetupReason, SetupStep, SetupStepId } from './model.ts'; export { awaitingActivation, harnessBlocksStartup, hasActiveRoute, hasRemediation, hasWarning, needsModelChoice, setupChecks, setupReason, setupSteps, } from './model.ts'; /** * Whether one setup run left the caller able to continue into a session. * * `blocked` is not a UI state the reader can dismiss into: it is the startup * gate's verdict that a confirmed Harness generation mismatch forbids normal * operation, and the caller must not attach a session when it sees it. The * only way on is the recovery command the report already printed, followed by * a restart. */ export type SetupOutcome = 'continued' | 'blocked'; /** What the flow needs from the window running it. */ export interface SetupSpec { /** Context carrying the Harness seams and the slot registry. */ readonly ctx: Context; /** Write finished rows into the terminal's own scrollback. */ readonly commit: (lines: readonly string[]) => void; /** This frontend's version, for the report's own row. */ readonly version: string; /** The route the next model step will use, which `/model` writes through. */ readonly selection: ModelSelectionRef; /** Re-resolve model metadata after the route changes; the window owns it. */ readonly onModelChanged: () => void; /** * Whether this run still has authority to mount UI or edit window state. * * `/setup` is reachable from two callers with different lifetimes: the * window's own first-run offer, which outlives any attachment, and the * `/setup` command an attachment owns. Omitting this — as the window caller * does — means "unfenced", which is right there and wrong here, so the * attachment passes the same epoch authority `/model` and `/reasoning` use. */ readonly mayAct?: () => boolean; /** Withdraw this run's pickers when the initiating attachment retires. */ readonly signal?: AbortSignal; } /** * Whether this launch would otherwise reach a composer that cannot send. * * Two synchronous reads settle it in most cases: the route registry, and the * selection ref the window already holds. When those say the topology is fine, * one more question remains — whether the selected route can authenticate — * and it is asked of Connect's own reading for that ONE route. No adapter is * asked for a catalog and nothing is contacted; see {@link setupReason}. * @param ctx - context carrying the model registry and the credential seams. * @param selection - the window's model selection ref, as `/model` writes it. * @returns whether the guided flow should be offered before the first session. */ export declare function setupNeeded(ctx: Context, selection: ModelSelectionRef): Promise; /** * One report row as committed lines. * * Escaped whole and then styled per row, in that order and never the reverse: * a version string, a provider id, and a Harness error message all reach here * from outside this frontend, and `escapeControls` neutralizes the escape * character itself — so running it over already-coloured text would destroy * the colour, and running it after styling would leave the untrusted halves * unescaped. * @param check - the row. * @returns its lines, the mark's own colour carrying the verdict. */ export declare function checkLines(check: SetupCheck): string[]; /** * The whole report as committed lines. * @param facts - what one pass established. * @returns the lines, blank-separated from whatever is above them. */ export declare function reportLines(facts: SetupFacts): string[]; /** * The closing lines when a confirmed generation mismatch stops startup. * * The report above already carries both exact versions and the deterministic * recovery wording, so nothing here repeats them; a second copy of the command * is a second thing to drift. This states only the verdict the report's `⚠` * could not: that dshline will not continue, and how to leave. `ctrl-d` is the * window's own global quit, which is why no interactive step is offered. * @returns the lines to commit after the report. */ export declare function blockedLines(): string[]; /** * Run the guided flow until the reader leaves it. * * The caller owns key routing for the duration — the pickers this opens are * overlays, and something has to be delegating keystrokes to them — exactly as * the session browser's caller does. * @param spec - the context, the transcript, and the model selection. * @returns `continued` when the reader may go on to the composer, or `blocked` * when a confirmed generation mismatch forbids a session from starting. */ export declare function runSetup(spec: SetupSpec): Promise; //# sourceMappingURL=index.d.ts.map