/** * Config and credential facts for the describe-image tool. Holds the validated * ResolvedConfig snapshot (defaults, bounds, and endpoint facts), the API-key * resolution seams, and the schemastery section that doubles as the plugin's * settings card schema. Kept separate from tool registration and the vision * HTTP client so single purpose stays single file. * @module @linxin666/dsh-tool-describe-image/config */ import type { Context } from '@deepseek-ai/cordis'; import z from 'schemastery'; import type { CredentialRef } from '@deepseek-ai/dsh-credentials'; import type { SettingsNamespace } from '@deepseek-ai/dsh-settings'; /** Environment-variable name the API key resolves through when no inline key is configured. */ export declare const DEFAULT_API_KEY_ENV = "VISION_API_KEY"; /** Per-call output-token cap sent to the vision model. */ export declare const DEFAULT_MAX_OUTPUT_TOKENS = 1024; /** Thinking-level suffixes accepted after the model id: `:off` disables thinking, the rest enable it. */ export declare const THINKING_SUFFIXES: readonly ["off", "low", "medium", "high"]; /** One parsed thinking level from a model-id suffix, or undefined when the model id carries none. */ export type ThinkingMode = typeof THINKING_SUFFIXES[number]; /** Per-call vision request timeout in milliseconds. */ export declare const DEFAULT_TIMEOUT_MS = 120000; /** Protocol styles the tool can speak to the configured endpoint. */ export declare const API_STYLES: readonly ["chat-completions", "responses", "anthropic-messages"]; export type ApiStyle = typeof API_STYLES[number]; /** Protocol style used unless the configuration overrides it. */ export declare const DEFAULT_API_STYLE: ApiStyle; /** Rotation modes between configured vision endpoints. */ export declare const ROTATION_MODES: readonly ["round-robin", "failover"]; export type RotationMode = typeof ROTATION_MODES[number]; /** Rotation mode used unless the configuration overrides it. */ export declare const DEFAULT_ROTATION_MODE: RotationMode; /** Whether to automatically try the next candidate endpoint on failure. */ export declare const DEFAULT_RETRY_NEXT_ON_FAILURE = true; /** Whether conversation image references upgrade into inline thumbnails unless configured otherwise. */ export declare const DEFAULT_RENDER_IMAGE_PREVIEW = true; /** Whether image-bearing sends are rewritten into describe-image references at submit (issue #301). */ export declare const DEFAULT_INTERCEPT_IMAGE_SEND = true; /** Instruction sent when the model does not pass its own prompt. */ export declare const DEFAULT_PROMPT = "Analyze this image: describe what is visible factually, transcribe legible text verbatim, and call out layout, notable details, or anything anomalous."; /** * Split a model id into the id the endpoint receives and its thinking-level suffix. A trailing * `:off` / `:low` / `:medium` / `:high` is the plugin's shorthand for the thinking control: * the suffix never reaches the endpoint, and a model id without one (or with any other suffix) is * forwarded verbatim with no thinking control. * @param model - the raw configured model id. * @returns the cleaned id and the parsed level, if any. */ export declare function splitModelSuffix(model: string): { model: string; thinking: ThinkingMode | undefined; }; /** Configuration for a single vision endpoint in a multi-endpoint setup. */ export interface VisionEndpointConfig { /** Optional human-readable name or label for this endpoint. */ name?: string; /** Endpoint root URL. */ baseURL: string; /** Vision model id, optionally with a trailing thinking suffix. */ model: string; /** Inline API key for this endpoint; prefer apiKeyEnv with credential references. */ apiKey?: string; /** Credential reference (environment variable name) for this endpoint. */ apiKeyEnv?: string; /** Protocol style of this endpoint. */ apiStyle?: ApiStyle; /** Output-token cap sent to this endpoint. */ maxOutputTokens?: number; /** Whether this endpoint is enabled in the rotation list. Defaults to true. */ enabled?: boolean; } /** Schemastery schema for a single vision endpoint. */ export declare const VisionEndpointConfig: z; /** One validated, resolved vision endpoint ready for invocation. */ export interface ResolvedEndpoint { name: string | undefined; baseURL: string; model: string; apiKey: string | undefined; apiKeyEnv: CredentialRef | undefined; apiStyle: ApiStyle; thinking: ThinkingMode | undefined; maxOutputTokens: number; enabled: boolean; } /** * Deployment configuration for the describe-image tool. The interface keeps every field optional so * programmatic construction is re-judged by {@link resolveConfig}; the schema requires `baseURL` and * `model` for single-endpoint composition entries. */ export interface Config { /** Endpoint root; Anthropic style also accepts a `/v1` root or complete `/v1/messages` endpoint. Trailing slashes are stripped. */ baseURL?: string; /** * Vision model id for the configured endpoint, optionally with a trailing thinking suffix * (`:off` / `:low` / `:medium` / `:high`) — see {@link splitModelSuffix}. The suffix * controls the thinking field the request sends and is stripped before the id reaches the endpoint. */ model?: string; /** Inline API key; prefer `apiKeyEnv` with the credential seam. Feed from the environment via `!!js process.env.VISION_API_KEY`. */ apiKey?: string; /** Credential reference (environment-variable name) for the API key; defaults to `VISION_API_KEY`. */ apiKeyEnv?: string; /** List of candidate vision endpoints for rotation and fallback (Issue #1234). */ endpoints?: VisionEndpointConfig[]; /** Rotation mode between configured vision endpoints: `round-robin` (default) or `failover`. */ rotationMode?: RotationMode; /** Whether to automatically try the next candidate endpoint on failure. Defaults to true. */ retryNextOnFailure?: boolean; /** Instruction used when a call omits its `prompt`; defaults to a concise factual description. */ defaultPrompt?: string; /** Image byte bound; defaults to {@link DEFAULT_MAX_BYTES}. */ maxBytes?: number; /** Output-token cap sent to the vision model; defaults to {@link DEFAULT_MAX_OUTPUT_TOKENS}. */ maxOutputTokens?: number; /** Per-call request timeout; defaults to {@link DEFAULT_TIMEOUT_MS}. */ timeoutMs?: number; /** Protocol style of the endpoint; defaults to {@link DEFAULT_API_STYLE} (`chat-completions`). */ apiStyle?: ApiStyle; /** * Whether describe-image references in the conversation upgrade in place into inline * thumbnails; defaults to {@link DEFAULT_RENDER_IMAGE_PREVIEW}. The web shell renders * user messages as plain text, so a sent reference would otherwise sit in the * transcript as raw markdown. Display-only: the message text, the session log, and * the model side are untouched. If the raw route is unreachable through the current * origin, the thumbnail load fails and the reference text stays as-is. */ renderImagePreview?: boolean; /** * Whether image-bearing sends are rewritten at submit into describe-image * references; defaults to {@link DEFAULT_INTERCEPT_IMAGE_SEND}. Turn off to * hand the raw image blocks to other vision plugins sharing the session. */ interceptImageSend?: boolean; } /** Schemastery configuration for the describe-image tool; doubles as the `describe-image` settings-section schema. */ export declare const Config: z; /** Settings namespace carrying the endpoint, model, and key reference the Plugins card edits. */ export declare const DESCRIBE_IMAGE_SETTINGS_NAMESPACE: SettingsNamespace; /** One resolved, validated configuration snapshot; defaults and beyond-schema constraints applied. */ export interface ResolvedConfig { baseURL: string; model: string; apiKey: string | undefined; apiKeyEnv: CredentialRef | undefined; defaultPrompt: string; maxBytes: number; maxOutputTokens: number; timeoutMs: number; apiStyle: ApiStyle; thinking: ThinkingMode | undefined; renderImagePreview: boolean; interceptImageSend: boolean; endpoints: ResolvedEndpoint[]; rotationMode: RotationMode; retryNextOnFailure: boolean; } /** * Resolve raw config into validated connection facts. Programmatic construction may bypass * Schemastery normalization, so every default and bound is re-judged here; a non-empty composition * entry is validated at load so misconfiguration fails loud (an unconfigured family mount only * hits it per call, inside {@link apply}). * @param config - raw plugin config. * @returns validated facts. */ export declare function resolveConfig(config: Config): ResolvedConfig; /** * Resolve the API key for one call or endpoint: an explicit inline key wins; otherwise the credential seam * (which owns environment and managed-store layers) resolves the reference; without the seam the launch environment * is the whole credential plane. * @param ctx - registrant context. * @param target - validated configuration or specific endpoint. * @returns the resolved key. */ export declare function resolveApiKey(ctx: Context, target: Pick): Promise; //# sourceMappingURL=config-resolve.d.ts.map