/** * v1 PluginInput shim (real delegation). * * The v1 plugin factory expects a `PluginInput` with an HTTP `client`, * project metadata, and a shell. v2's plugin context exposes none of these, * so this shim builds a v1-shaped input whose `client` translates the v1 * SDK call shapes (Hono-style `{path, body}` or flat `{sessionID}`) into * v2 flat session calls (`get`/`remove`/`list`/`interrupt`/`switchModel`/ * `prompt`/`context`). Delegation is real where the v2 host provides the * method and explicitly fails or degrades with a log where it does not — * the shim never fakes success shapes. * * The v2 model-switch semantics (prompts carry no model; `switchModel` * must precede the prompt) are encapsulated in the `promptAsync` * translation, which is what lets the v1 foreground-fallback pipeline work * unmodified on v2. A failed `switchModel` degrades to steering on the * current model (logged, `switched: false` on the result) because the * prompt delivery is the load-bearing action; a host with NO * `switchModel` rejects callers that declare `modelSwitch: 'required'` * (foreground-fallback) while pin-callers (orchestrator-wake) keep the * logged steer. */ import type { V2Context } from './types'; /** v2 model reference accepted by `ctx.generate.text`. */ export interface V2GenerateModelRef { id: string; providerID: string; variant?: string; } /** Optional v2 capabilities threaded into the v1 PluginInput. Absent * capabilities must leave the input object unchanged (v1 parity). */ export interface ExperimentalV2 { /** One-shot generation (`ctx.generate.text`); no session involved. */ generateText?: (prompt: string, model?: V2GenerateModelRef) => Promise<{ text: string; }>; } /** Directory from the host-reported location; cwd on hosts without * `ctx.location` (or with an empty directory). */ export declare function resolveV2Directory(ctx: V2Context): string; /** * v1 `client.session.list` over v2 `session.list`. Accepts the v1 * `{query}` call shape (or a flat query object); passes through the * filters shim callers use — `directory` and the `parentID` filter * (session id or root-only: the literal `"null"` string, with a real * `null` normalized to it) — and wraps the mapped page in the v1 * `{data}` envelope. Hosts without `session.list` keep the v1-parity * empty page (honest absence, not a fake success) after a one-time * process-level warning — stock v2 hosts match this path because the * plugin session domain does not expose `list` (see the notice above). */ export declare function createSessionListShim(s: V2Context['session']): (args: Record) => Promise<{ data: unknown[]; }>; /** Build a v1-compatible PluginInput from the v2 context. The optional * `extras` threads probed v2 capabilities (e.g. one-shot generation) * through as `experimental_v2`; when absent no `experimental_v2` key is * added so the v1 pipeline stays byte-identical. */ export declare function buildPluginInput(ctx: V2Context, extras?: ExperimentalV2): Record;