@koinzhang/paseo-plugin-commands 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ All notable changes to `@koinzhang/paseo-plugin-commands` are documented in this
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.2] - 2026-11-26
9
+
10
+ Requires Paseo **>= 0.16.0**.
11
+
12
+ ### Changed
13
+
14
+ - `/model`, `/effort`, and `/mode` use the public Composer API instead of the plugin's private daemon control connection.
15
+ - Align the plugin SDK and daemon client with Paseo 0.17.4.
16
+
17
+ ### Fixed
18
+
19
+ - Desktop pickers use the native Popover lifecycle so Escape closes the menu without also triggering Paseo's global agent interrupt shortcut.
20
+
8
21
  ## [0.2.1] - 2026-11-06
9
22
 
10
23
  ### Changed
@@ -30,6 +43,7 @@ Requires Paseo **>= 0.9.0**.
30
43
  - `/resend [text]` agent slash command to resend the latest non-empty user prompt, appending optional text on a new line.
31
44
  - Settings → Plugins → commands → Settings: turn each slash command on or off, grouped into Runtime, Session, and Prompt sections, with a short description of what it does.
32
45
 
46
+ [0.2.2]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.2.2
33
47
  [0.2.1]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.2.1
34
48
  [0.2.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.2.0
35
49
  [0.1.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.1.0
package/README.md CHANGED
@@ -44,9 +44,10 @@ paseo plugin add npm:@koinzhang/paseo-plugin-commands
44
44
 
45
45
  To install from GitHub, use `paseo plugin add github:koinzhang/paseo-plugins:commands`.
46
46
 
47
- Requires Paseo >= 0.15.0. The plugin SDK cannot change agent settings yet, so the daemon side of
48
- the plugin connects to its local daemon (`PASEO_LISTEN` or `$PASEO_HOME/paseo.pid`) and sends the
49
- same requests the app uses. If the daemon requires a password, set `PASEO_PASSWORD` for it.
47
+ Requires Paseo >= 0.16.0. `/model`, `/effort`, and `/mode` use the public Composer API. Profile,
48
+ feature, rename, and cancel controls use the daemon side of the plugin, which connects to its local
49
+ daemon (`PASEO_LISTEN` or `$PASEO_HOME/paseo.pid`). If the daemon requires a password, set
50
+ `PASEO_PASSWORD` for it.
50
51
 
51
52
  ## Development
52
53
 
@@ -60,5 +61,6 @@ paseo plugin reload commands
60
61
  ```
61
62
 
62
63
  Command definitions and option matching live in `shared/` (`commands.ts`, `parse.ts`,
63
- `resolve-option.ts`), daemon-side setting writes in `server/daemon.ts`, and the menus plus
64
- settings UI in `client/`. Specs are in [`specs/`](./specs/).
64
+ `resolve-option.ts`), model / effort / mode writes use the public Composer API, the remaining
65
+ daemon-side controls live in `server/`, and the menus plus settings UI live in `client/`. Specs are
66
+ in [`specs/`](./specs/).
@@ -1,5 +1,6 @@
1
1
  import type { PluginAgentCommandContext } from "@getpaseo/plugin/client";
2
2
  import type { AgentState, Feature, ModelOption, Profile, SelectOption } from "../shared/commands.ts";
3
+ import { optionFeatures } from "../shared/agent-options.ts";
3
4
 
4
5
  type Paseo = PluginAgentCommandContext["paseo"];
5
6
 
@@ -44,7 +45,7 @@ export async function loadAgentState(
44
45
  modes = (catalog.modes ?? []).map(toSelectOption);
45
46
  }
46
47
 
47
- const features: Feature[] = (agent.features ?? []).map((feature) =>
48
+ const features: Feature[] = optionFeatures(agent).map((feature) =>
48
49
  feature.type === "toggle"
49
50
  ? { type: "toggle", id: feature.id, label: feature.label, value: feature.value }
50
51
  : {
@@ -70,6 +71,8 @@ export async function loadAgentState(
70
71
  models,
71
72
  modes,
72
73
  features,
74
+ controls: agent.controls,
75
+ options: agent.options,
73
76
  };
74
77
  }
75
78
 
@@ -13,6 +13,7 @@ import { agentControl } from "../shared/rpc.ts";
13
13
  import { composeResendPrompt, latestUserPrompt } from "../shared/resend.ts";
14
14
  import { loadAgentState, loadProfiles } from "./agent-state.ts";
15
15
  import type { PickerHost, RunControl } from "./picker.tsx";
16
+ import { runtimeControlNotice } from "./runtime-notice.ts";
16
17
  import { getDisabledCommands, subscribeDisabledCommands } from "./settings-store.ts";
17
18
 
18
19
  type Context = PluginAgentCommandContext & { args: string };
@@ -164,6 +165,21 @@ function controlRunner(ctx: Context): RunControl {
164
165
  };
165
166
  }
166
167
 
168
+ function runtimeRunner(ctx: Context): RunControl {
169
+ return async (control, note) => {
170
+ if (control.op !== "model" && control.op !== "thinking" && control.op !== "mode") {
171
+ throw new Error("This command must use the agent control RPC.");
172
+ }
173
+ const state = await loadAgentState(ctx.paseo, ctx.agent.id);
174
+ const [composer] = ctx.composers({ agentId: ctx.agent.id });
175
+ if (!composer) throw new Error("The agent's composer is unavailable.");
176
+ if (control.op === "model") await composer.setModel(control.modelId);
177
+ else if (control.op === "thinking") await composer.setThinking(control.thinkingOptionId);
178
+ else await composer.setMode(control.modeId);
179
+ return [note, runtimeControlNotice(state, control)].filter(Boolean).join("\n") || null;
180
+ };
181
+ }
182
+
167
183
  function addCommand(client: PluginClientContext, pickers: PickerHost, command: CommandSpec) {
168
184
  return client.addSlashCommand({
169
185
  name: command.name,
@@ -176,7 +192,9 @@ function addCommand(client: PluginClientContext, pickers: PickerHost, command: C
176
192
  return;
177
193
  }
178
194
  const plan = await command.plan(ctx);
179
- const run = controlRunner(ctx);
195
+ const run = ["model", "effort", "mode"].includes(command.name)
196
+ ? runtimeRunner(ctx)
197
+ : controlRunner(ctx);
180
198
  if (plan.kind === "picker") {
181
199
  pickers.show({ workspaceId: ctx.agent.workspaceId, agentId: ctx.agent.id }, plan, run);
182
200
  return;
package/client/picker.tsx CHANGED
@@ -27,6 +27,7 @@ import {
27
27
  } from "../shared/popover-geometry.ts";
28
28
  import type { AgentControl } from "../shared/rpc.ts";
29
29
  import { MenuList, type PickerLeaf } from "./menu-list.tsx";
30
+ import { openPickerPopover } from "./popover-lifecycle.ts";
30
31
 
31
32
  type PickerPlan = Extract<Plan, { kind: "picker" }>;
32
33
  /** Applies a control and resolves to a message to show, if any. */
@@ -128,7 +129,9 @@ function PickerPopover({
128
129
  const [trigger, setTrigger] = useState<Rect | null>(null);
129
130
  const [content, setContent] = useState<Size | null>(null);
130
131
  const progress = useRef(new Animated.Value(0)).current;
132
+ const surfaceRef = useRef<View>(null);
131
133
  const surface = useMemo(() => surfaceStyle(theme), [theme]);
134
+ const close = state.close;
132
135
 
133
136
  useEffect(() => {
134
137
  if (!state.open) {
@@ -155,6 +158,11 @@ function PickerPopover({
155
158
  : null;
156
159
  const placed = position !== null;
157
160
 
161
+ useEffect(() => {
162
+ if (Platform.OS !== "web" || !state.open || !placed) return undefined;
163
+ return openPickerPopover(surfaceRef.current, close) ?? undefined;
164
+ }, [close, placed, state.open]);
165
+
158
166
  useEffect(() => {
159
167
  if (!placed) {
160
168
  progress.setValue(0);
@@ -182,9 +190,20 @@ function PickerPopover({
182
190
  onPress={state.close}
183
191
  />
184
192
  <Animated.View
193
+ ref={surfaceRef}
185
194
  accessibilityRole="menu"
186
195
  style={[
187
196
  surface,
197
+ Platform.OS === "web"
198
+ ? {
199
+ right: "auto" as const,
200
+ bottom: "auto" as const,
201
+ width: visible?.width,
202
+ height: visible?.height,
203
+ margin: 0,
204
+ padding: 0,
205
+ }
206
+ : null,
188
207
  {
189
208
  left: position?.x ?? -9999,
190
209
  top: position?.y ?? -9999,
@@ -0,0 +1,90 @@
1
+ interface PopoverToggleEvent {
2
+ newState?: string;
3
+ }
4
+
5
+ interface FocusableElement {
6
+ focus(): void;
7
+ isConnected?: boolean;
8
+ }
9
+
10
+ interface PickerDocument {
11
+ activeElement?: unknown;
12
+ }
13
+
14
+ interface PickerKeyboardEvent {
15
+ key?: string;
16
+ preventDefault(): void;
17
+ stopImmediatePropagation(): void;
18
+ }
19
+
20
+ interface PickerWindow {
21
+ addEventListener(type: "keydown", listener: (event: PickerKeyboardEvent) => void, capture?: boolean): void;
22
+ removeEventListener(type: "keydown", listener: (event: PickerKeyboardEvent) => void, capture?: boolean): void;
23
+ }
24
+
25
+ interface PopoverElement {
26
+ setAttribute(name: string, value: string): void;
27
+ addEventListener(type: "toggle", listener: (event: PopoverToggleEvent) => void): void;
28
+ removeEventListener(type: "toggle", listener: (event: PopoverToggleEvent) => void): void;
29
+ showPopover(): void;
30
+ hidePopover(): void;
31
+ }
32
+
33
+ function focusable(value: unknown): FocusableElement | null {
34
+ return typeof value === "object" && value !== null && "focus" in value && typeof value.focus === "function"
35
+ ? (value as FocusableElement)
36
+ : null;
37
+ }
38
+
39
+ function closePicker(close: () => void, previousFocus: FocusableElement | null) {
40
+ close();
41
+ if (previousFocus?.isConnected !== false) previousFocus?.focus();
42
+ }
43
+
44
+ function escapeFallback(close: () => void, previousFocus: FocusableElement | null): () => void {
45
+ const host = globalThis as { window?: PickerWindow };
46
+ const target = host.window;
47
+ if (!target) return () => {};
48
+ const onKeyDown = (event: PickerKeyboardEvent) => {
49
+ if (event.key !== "Escape") return;
50
+ event.preventDefault();
51
+ event.stopImmediatePropagation();
52
+ closePicker(close, previousFocus);
53
+ };
54
+ target.addEventListener("keydown", onKeyDown, true);
55
+ return () => target.removeEventListener("keydown", onKeyDown, true);
56
+ }
57
+
58
+ function isPopoverElement(value: unknown): value is PopoverElement {
59
+ if (typeof value !== "object" || value === null) return false;
60
+ const candidate = value as Partial<PopoverElement>;
61
+ return (
62
+ typeof candidate.setAttribute === "function" &&
63
+ typeof candidate.addEventListener === "function" &&
64
+ typeof candidate.removeEventListener === "function" &&
65
+ typeof candidate.showPopover === "function" &&
66
+ typeof candidate.hidePopover === "function"
67
+ );
68
+ }
69
+
70
+ export function openPickerPopover(element: unknown, close: () => void): (() => void) | null {
71
+ const host = globalThis as { document?: PickerDocument };
72
+ const previousFocus = focusable(host.document?.activeElement);
73
+ if (!isPopoverElement(element)) return escapeFallback(close, previousFocus);
74
+ const onToggle = (event: PopoverToggleEvent) => {
75
+ if (event.newState === "closed") closePicker(close, previousFocus);
76
+ };
77
+ element.setAttribute("popover", "auto");
78
+ element.addEventListener("toggle", onToggle);
79
+ try {
80
+ element.showPopover();
81
+ } catch {
82
+ element.removeEventListener("toggle", onToggle);
83
+ return escapeFallback(close, previousFocus);
84
+ }
85
+ return () => {
86
+ element.removeEventListener("toggle", onToggle);
87
+ element.hidePopover();
88
+ if (previousFocus?.isConnected !== false) previousFocus?.focus();
89
+ };
90
+ }
@@ -0,0 +1,13 @@
1
+ import type { AgentState } from "../shared/commands.ts";
2
+ import type { AgentControl } from "../shared/rpc.ts";
3
+
4
+ export function runtimeControlNotice(state: AgentState, control: AgentControl): string | null {
5
+ if (state.status !== "running") return null;
6
+ if (control.op === "thinking" && (state.provider === "codex" || state.provider === "claude")) {
7
+ return "Thinking level applies next turn";
8
+ }
9
+ if (control.op === "mode" && state.provider === "codex") {
10
+ return "Permission mode applies next turn";
11
+ }
12
+ return null;
13
+ }
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@koinzhang/paseo-plugin-commands",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@koinzhang/paseo-plugin-commands",
9
- "version": "0.2.1",
9
+ "version": "0.2.2",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@getpaseo/client": "0.15.1",
12
+ "@getpaseo/client": "0.17.4",
13
13
  "ws": "^8.18.3"
14
14
  },
15
15
  "devDependencies": {
16
- "@getpaseo/plugin": "0.15.1",
16
+ "@getpaseo/plugin": "0.17.4",
17
17
  "@types/node": "^24.13.5",
18
18
  "@types/react": "~19.2.0",
19
19
  "@types/ws": "^8.18.1",
@@ -521,29 +521,31 @@
521
521
  }
522
522
  },
523
523
  "node_modules/@getpaseo/client": {
524
- "version": "0.15.1",
525
- "resolved": "https://registry.npmjs.org/@getpaseo/client/-/client-0.15.1.tgz",
526
- "integrity": "sha512-LyncHlKOOeDz+ELW47OEHw5YIMzao1Qe9+0qnZXH+vMfpZdRwR5Oyxgpx348g4nk7vGiPZQDhTNbflHD+T3TZw==",
524
+ "version": "0.17.4",
525
+ "resolved": "https://registry.npmjs.org/@getpaseo/client/-/client-0.17.4.tgz",
526
+ "integrity": "sha512-R3g6Tt14aVDxiWSza9DeHJ8GSCbygb8TN38HurqlWkM0qOynuDxIYgH8hwF6/Ay7hEQs8wOz4WFaqgFVkItK4g==",
527
+ "license": "Apache-2.0",
527
528
  "dependencies": {
528
- "@getpaseo/protocol": "0.15.1",
529
- "@getpaseo/relay": "0.15.1",
529
+ "@getpaseo/protocol": "0.17.4",
530
+ "@getpaseo/relay": "0.17.4",
530
531
  "ws": "^8.20.0",
531
532
  "zod": "^4.4.3"
532
533
  }
533
534
  },
534
535
  "node_modules/@getpaseo/plugin": {
535
- "version": "0.15.1",
536
- "resolved": "https://registry.npmjs.org/@getpaseo/plugin/-/plugin-0.15.1.tgz",
537
- "integrity": "sha512-496Vr5wc4+9de4wNqXcSXRdFP9RIegQn4LK2bcWVLnNhUYFq+5DkIGq9pIsA+6Fhjepekz9hQkdpHTP8Gm9SGw==",
536
+ "version": "0.17.4",
537
+ "resolved": "https://registry.npmjs.org/@getpaseo/plugin/-/plugin-0.17.4.tgz",
538
+ "integrity": "sha512-l6t0Pj2Jr1NlvTdm7Gs4MIPMCMA+htvf0h3sY51ux51qN7Vd0kRIThALPH4cxkwVnIAHSTjX8aDlpVG3squmSQ==",
538
539
  "dev": true,
540
+ "license": "Apache-2.0",
539
541
  "dependencies": {
540
542
  "@agentclientprotocol/sdk": "^1.4.0",
541
543
  "i18next": "^26.3.0",
542
544
  "use-sync-external-store": "^1.6.0"
543
545
  },
544
546
  "peerDependencies": {
545
- "@getpaseo/client": "0.15.1",
546
- "@getpaseo/protocol": "0.15.1",
547
+ "@getpaseo/client": "0.17.4",
548
+ "@getpaseo/protocol": "0.17.4",
547
549
  "react": ">=19.1.0 <20",
548
550
  "react-native": ">=0.81.5",
549
551
  "zod": "^4.4.3"
@@ -555,18 +557,20 @@
555
557
  }
556
558
  },
557
559
  "node_modules/@getpaseo/protocol": {
558
- "version": "0.15.1",
559
- "resolved": "https://registry.npmjs.org/@getpaseo/protocol/-/protocol-0.15.1.tgz",
560
- "integrity": "sha512-G8WGOihTU4UNZPbEAKYgEV+CG4DzzXVE+2fvEQkbB3ik7J6KsLL6eTfjyqUGJoli5pSNXFCQWy8z/RpR1JuY+A==",
560
+ "version": "0.17.4",
561
+ "resolved": "https://registry.npmjs.org/@getpaseo/protocol/-/protocol-0.17.4.tgz",
562
+ "integrity": "sha512-p9Ay0wJb/WSL2bfN97gTkvhlElLk9exhH9mCJCGT6LUd9l2MN81TNsr5RgvbvFA0tCZnIcPMNURABOuKEJEy0A==",
563
+ "license": "Apache-2.0",
561
564
  "dependencies": {
562
565
  "semver": "^7.8.5",
563
566
  "zod": "^4.4.3"
564
567
  }
565
568
  },
566
569
  "node_modules/@getpaseo/relay": {
567
- "version": "0.15.1",
568
- "resolved": "https://registry.npmjs.org/@getpaseo/relay/-/relay-0.15.1.tgz",
569
- "integrity": "sha512-1zS2ovGcWXk5NW69dEawM8C8xPlflL5zGg1uaYQAAfwyi8xVzhr44AVs2PIUdpRGV/81QS7BRERcdnZuVKheRA==",
570
+ "version": "0.17.4",
571
+ "resolved": "https://registry.npmjs.org/@getpaseo/relay/-/relay-0.17.4.tgz",
572
+ "integrity": "sha512-iVR+Xkq18HhsVC//eP7cig7b/YuQjNPT7u9fQx81xIoX6UpGRyHVNm7SUGjyByS3WKFYprnst5Q365hKDjQJcA==",
573
+ "license": "Apache-2.0",
570
574
  "dependencies": {
571
575
  "@noble/ciphers": "^2.4.0",
572
576
  "@noble/curves": "^2.4.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koinzhang/paseo-plugin-commands",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Essential client-side slash commands for controlling the current Paseo agent.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,14 +24,14 @@
24
24
  ],
25
25
  "scripts": {
26
26
  "typecheck": "tsc --noEmit",
27
- "test": "node --experimental-strip-types --test shared/*.test.ts server/*.test.ts"
27
+ "test": "node --experimental-strip-types --test shared/*.test.ts client/*.test.ts server/*.test.ts"
28
28
  },
29
29
  "dependencies": {
30
- "@getpaseo/client": "0.15.1",
30
+ "@getpaseo/client": "0.17.4",
31
31
  "ws": "^8.18.3"
32
32
  },
33
33
  "devDependencies": {
34
- "@getpaseo/plugin": "0.15.1",
34
+ "@getpaseo/plugin": "0.17.4",
35
35
  "@types/node": "^24.13.5",
36
36
  "@types/react": "~19.2.0",
37
37
  "@types/ws": "^8.18.1",
package/paseo-plugin.json CHANGED
@@ -2,6 +2,6 @@
2
2
  "id": "commands",
3
3
  "description": "Slash commands for the current agent: /model, /effort, /profile, /mode, /feature, /rename, /cancel, /resend",
4
4
  "requirements": {
5
- "paseo": ">=0.15.0"
5
+ "paseo": ">=0.16.0"
6
6
  }
7
7
  }
package/server/control.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import type { DaemonClient } from "@getpaseo/client/internal/daemon-client";
2
+ import { createPaseoApi, type PaseoAgentHandle } from "@getpaseo/client";
3
+ import { assertSupportedOptions } from "../shared/agent-options.ts";
2
4
  import type { AgentControl } from "../shared/rpc.ts";
3
5
 
4
6
  type Notice = { type: "info" | "warning" | "error"; message: string } | null;
@@ -16,9 +18,11 @@ export async function runAgentControl(
16
18
  return { notice: await client.setAgentThinkingOption(agentId, input.thinkingOptionId) };
17
19
  case "mode":
18
20
  return { notice: await client.setAgentMode(agentId, input.modeId) };
19
- case "feature":
20
- await client.setAgentFeature(agentId, input.featureId, input.value);
21
+ case "feature": {
22
+ const options = { [input.featureId]: input.value };
23
+ await withSupportedOptions(client, agentId, options, (agent) => agent.setOptions(options));
21
24
  return { notice: null };
25
+ }
22
26
  case "config":
23
27
  return { notice: await applyConfig(client, agentId, input.config) };
24
28
  case "rename":
@@ -35,19 +39,31 @@ async function applyConfig(
35
39
  agentId: string,
36
40
  config: Extract<AgentControl, { op: "config" }>["config"],
37
41
  ): Promise<Notice> {
38
- if (client.getLastServerInfoMessage()?.features?.agentConfigApply === true) {
39
- return client.applyAgentConfig(agentId, config);
42
+ if (client.getLastServerInfoMessage()?.features?.agentConfigApply !== true) {
43
+ throw new Error("Update the host to apply an agent profile as one config bundle.");
40
44
  }
41
- // Older daemons: apply the same bundle one field at a time, model first so
42
- // thinking options are validated against the new model.
43
- let notice: Notice = null;
44
- if (config.modelId) await client.setAgentModel(agentId, config.modelId);
45
- if (config.modeId) notice = (await client.setAgentMode(agentId, config.modeId)) ?? notice;
46
- if (config.thinkingOptionId) {
47
- notice = (await client.setAgentThinkingOption(agentId, config.thinkingOptionId)) ?? notice;
45
+ if (config.options && Object.keys(config.options).length > 0) {
46
+ return withSupportedOptions(client, agentId, config.options, () =>
47
+ client.applyAgentConfig(agentId, config),
48
+ );
48
49
  }
49
- for (const [featureId, value] of Object.entries(config.featureValues ?? {})) {
50
- await client.setAgentFeature(agentId, featureId, value);
50
+ return client.applyAgentConfig(agentId, config);
51
+ }
52
+
53
+ async function withSupportedOptions<Result>(
54
+ client: DaemonClient,
55
+ agentId: string,
56
+ options: Record<string, unknown>,
57
+ run: (agent: PaseoAgentHandle) => Promise<Result>,
58
+ ): Promise<Result> {
59
+ const paseo = createPaseoApi(client);
60
+ try {
61
+ const agent = paseo.agents.ref(agentId);
62
+ const result = await agent.refresh();
63
+ if (!result?.agent) throw new Error("Agent not found.");
64
+ assertSupportedOptions(result.agent, options);
65
+ return await run(agent);
66
+ } finally {
67
+ await paseo.dispose();
51
68
  }
52
- return notice;
53
69
  }
@@ -0,0 +1,25 @@
1
+ import type { AgentFeature, AgentOptionControl, ProviderOptions } from "@getpaseo/protocol/agent-types";
2
+ import { featuresFromControls } from "@getpaseo/protocol/option-controls";
3
+
4
+ export interface OptionSource {
5
+ controls?: readonly AgentOptionControl[];
6
+ options?: ProviderOptions;
7
+ features?: readonly AgentFeature[];
8
+ }
9
+
10
+ export function optionFeatures(source: OptionSource): readonly AgentFeature[] {
11
+ if (source.controls !== undefined) {
12
+ return featuresFromControls({ controls: source.controls, options: source.options });
13
+ }
14
+ return source.features ?? [];
15
+ }
16
+
17
+ export function assertSupportedOptions(source: OptionSource, patch: ProviderOptions): void {
18
+ const features = optionFeatures(source);
19
+ for (const key of Object.keys(patch)) {
20
+ if (!features.some((feature) => feature.id === key)) {
21
+ const available = features.map((feature) => feature.id).join(", ") || "none";
22
+ throw new Error(`Unknown option "${key}".\nAvailable: ${available}`);
23
+ }
24
+ }
25
+ }
@@ -1,6 +1,8 @@
1
1
  import { formatToggle, parseToggle, splitFirst, TOGGLE_WORDS } from "./parse.ts";
2
2
  import { formatList, requireOption } from "./resolve-option.ts";
3
3
  import type { AgentControl } from "./rpc.ts";
4
+ import type { AgentOptionControl, ProviderOptions } from "@getpaseo/protocol/agent-types";
5
+ import { optionFeatures } from "./agent-options.ts";
4
6
 
5
7
  export interface SelectOption {
6
8
  id: string;
@@ -29,6 +31,7 @@ export interface Profile {
29
31
  modeId?: string;
30
32
  thinkingOptionId?: string;
31
33
  featureValues?: Record<string, unknown>;
34
+ options?: Record<string, unknown>;
32
35
  [key: string]: unknown;
33
36
  }
34
37
 
@@ -43,6 +46,8 @@ export interface AgentState {
43
46
  models: ModelOption[];
44
47
  modes: SelectOption[];
45
48
  features: Feature[];
49
+ controls?: AgentOptionControl[];
50
+ options?: ProviderOptions;
46
51
  }
47
52
 
48
53
  export type PickerEntry =
@@ -166,7 +171,8 @@ export function formatFeatureValue(feature: Feature): string {
166
171
  }
167
172
 
168
173
  export function planFeature(args: string, state: AgentState): Plan {
169
- const { agentId, features } = state;
174
+ const { agentId } = state;
175
+ const features = optionFeatures(state);
170
176
  if (features.length === 0) throw new Error(`Provider "${state.provider}" exposes no features.`);
171
177
  const { head, rest } = splitFirst(args);
172
178
  if (!head) {
@@ -190,6 +196,12 @@ export function planFeature(args: string, state: AgentState): Plan {
190
196
  items: featureValueEntries(agentId, feature),
191
197
  };
192
198
  }
199
+ if (rest === "--default") {
200
+ return {
201
+ kind: "run",
202
+ control: { op: "feature", agentId, featureId: feature.id, value: null },
203
+ };
204
+ }
193
205
  if (feature.type === "toggle") {
194
206
  const value = parseToggle(rest);
195
207
  if (value === null) {
@@ -217,6 +229,7 @@ const PROFILE_KEYS = new Set([
217
229
  "modeId",
218
230
  "thinkingOptionId",
219
231
  "featureValues",
232
+ "options",
220
233
  ]);
221
234
 
222
235
  function trimmed(value: unknown): string {
@@ -269,12 +282,13 @@ export function profileControl(
269
282
  }
270
283
  }
271
284
 
272
- const featureValues: Record<string, unknown> = {};
273
- for (const [id, value] of Object.entries(profile.featureValues ?? {})) {
274
- if (state.features.some((feature) => feature.id === id)) featureValues[id] = value;
285
+ const features = optionFeatures(state);
286
+ const options: Record<string, unknown> = {};
287
+ for (const [id, value] of Object.entries(profile.options ?? profile.featureValues ?? {})) {
288
+ if (features.some((feature) => feature.id === id)) options[id] = value;
275
289
  else ignored.push(`feature "${id}"`);
276
290
  }
277
- if (Object.keys(featureValues).length > 0) config.featureValues = featureValues;
291
+ if (Object.keys(options).length > 0) config.options = options;
278
292
 
279
293
  for (const key of Object.keys(profile)) {
280
294
  if (!PROFILE_KEYS.has(key)) ignored.push(key);
package/shared/rpc.ts CHANGED
@@ -1,10 +1,6 @@
1
1
  import { defineRpc } from "@getpaseo/plugin";
2
2
  import { z } from "zod";
3
3
 
4
- /**
5
- * Agent mutations the plugin SDK does not expose yet. The daemon side forwards
6
- * each one to the matching native daemon request.
7
- */
8
4
  export const AgentControlSchema = z.discriminatedUnion("op", [
9
5
  z.object({ op: z.literal("model"), agentId: z.string(), modelId: z.string() }),
10
6
  z.object({ op: z.literal("thinking"), agentId: z.string(), thinkingOptionId: z.string() }),
@@ -22,7 +18,7 @@ export const AgentControlSchema = z.discriminatedUnion("op", [
22
18
  modelId: z.string().optional(),
23
19
  modeId: z.string().optional(),
24
20
  thinkingOptionId: z.string().optional(),
25
- featureValues: z.record(z.string(), z.unknown()).optional(),
21
+ options: z.record(z.string(), z.unknown()).optional(),
26
22
  }),
27
23
  }),
28
24
  z.object({ op: z.literal("rename"), agentId: z.string(), title: z.string().min(1) }),