/** * The operator's `/wechat` subcommands. * * This module owns no state. It is the control panel: every subcommand reads * the shared state and drives the channel through `CommandsOps`, and the two * facts are related — a facade over a state machine has the state machine's * surface, and that surface is the interface below. * * What each subcommand *prints* lives in `ui.ts`, and what it *parses* with * it: a string the operator reads is worth a test, and none of that needs * state. What is left here is the part that acts. * * The seven places that used to assign to the closure's state directly * (`loginDesired = true`, `isLoggedIn = false`, …) are now named methods on * the Ops interface, because each of them was a transition with a name — * "we want the channel up", "we are logged out" — that nothing said out loud. */ import type { ExtensionAPI } from '@earendil-works/pi-coding-agent'; import type { ExtToWorkerCmd } from '../ipc.js'; import type { Logger } from '../log.js'; import { type OwnerNotice, type StatusSnapshot } from '../ui.js'; import { type ChannelState } from './core.js'; import type { OperatorLink } from './operator.js'; /** * Every call this module makes into state it does not own. * * Read it as the channel's operator-facing API: `/wechat status` reports the * whole machine, `/wechat login` drives the worker, `/wechat cancel` drives * the turn in flight. A facade is coupled to what it is a facade over, and * the honest place to see how much is right here. */ export interface CommandsOps { retireInstance(reason: string): void; snapshot(): StatusSnapshot; claimChannel(opts?: { force?: boolean; }): void; startWorker(): void; stopWorker(): void; waitForWorkerReady(): Promise; waitForQrUrl(): Promise; sendTracked(cmd: ExtToWorkerCmd): Promise; /** `loginDesired = true; reloginAttempts = 0` — we want the channel up. */ wantChannelUp(): void; /** Clear the stale QR, drop any silent login in flight, ask for a new one. */ startQrLogin(force: boolean): void; /** `isLoggedIn = false; accountId = ''` — the credentials are gone. */ markLoggedOut(): void; setOwner(userId: string): void; clearOwner(): void; cancelCurrentTurn(): string | null; notifyOwner(userId: string, notice: OwnerNotice): void; } export interface CommandsDeps { pi: ExtensionAPI; log: Logger; /** * Everything this module says to the operator. A collaborator alongside * `pi` rather than an entry in `ops`: it is not a call back into index.ts's * state, and a subcommand's output is not something the channel does. */ link: OperatorLink; /** Read-only: this module owns nothing, by design. */ S: Readonly; ops: CommandsOps; } export declare function registerWeChatCommand({ pi, log, link, S, ops }: CommandsDeps): void; //# sourceMappingURL=commands.d.ts.map