refactor(server): option helpers take named inputs, control types come from their schemas, and a plugin accepts launch options it opened with

A whole profile is applied by the unchanged app, so a launch-only plugin option whose value
has not changed must not fail the apply. applyProviderOptionsPatch and featuresFromControls
take one object, and the protocol control types are inferred from the wire schemas.
This commit is contained in:
Mohamed Boudra
2026-11-04 04:25:09 +01:00
parent 0f979c21e7
commit c68f8cd9df
15 changed files with 70 additions and 66 deletions
+14 -29
View File
@@ -1,5 +1,12 @@
import type { AgentMessage } from "./agent-message.js";
import type { AgentAttachment } from "./messages.js";
import type {
AgentAttachment,
AgentOptionChoiceSchema,
AgentOptionControlSchema,
AgentOptionSelectControlSchema,
AgentOptionToggleControlSchema,
} from "./messages.js";
import type { z } from "zod";
export type AgentProvider = string;
@@ -154,41 +161,19 @@ export interface AgentFeatureSelect {
export type AgentFeature = AgentFeatureToggle | AgentFeatureSelect;
export interface AgentOptionChoice {
value: string;
label: string;
description?: string;
}
export type AgentOptionChoice = z.infer<typeof AgentOptionChoiceSchema>;
interface AgentOptionControlBase {
/** Top-level provider option key this control reads and writes. */
key: string;
label: string;
description?: string;
tooltip?: string;
icon?: string;
}
/** `key` is the top-level provider option key the control reads and writes. */
export type AgentOptionToggleControl = z.infer<typeof AgentOptionToggleControlSchema>;
export interface AgentOptionToggleControl extends AgentOptionControlBase {
type: "toggle";
/** What an unset option stands for; omitted means off. */
defaultValue?: boolean;
}
export interface AgentOptionSelectControl extends AgentOptionControlBase {
type: "select";
/** Desktop toolbar presentation; omitted means labeled. Mobile selectors stay labeled. */
desktopTrigger?: "icon" | "label";
/** The choice an unset option stands for. */
defaultValue?: string;
choices: AgentOptionChoice[];
}
/** `defaultValue` is the choice an unset option stands for. */
export type AgentOptionSelectControl = z.infer<typeof AgentOptionSelectControlSchema>;
/**
* A provider's description of a composer control over one top-level option key.
* The control carries no value: it is read from the agent's effective options.
*/
export type AgentOptionControl = AgentOptionToggleControl | AgentOptionSelectControl;
export type AgentOptionControl = z.infer<typeof AgentOptionControlSchema>;
export interface AgentCapabilityFlags {
[capability: string]: boolean | undefined;