@koinzhang/paseo-plugin-commands 0.2.0 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koinzhang/paseo-plugin-commands",
3
- "version": "0.2.0",
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",
@@ -19,18 +19,19 @@
19
19
  "shared/",
20
20
  "!**/*.test.ts",
21
21
  "LICENSE",
22
- "README.md"
22
+ "README.md",
23
+ "npm-shrinkwrap.json"
23
24
  ],
24
25
  "scripts": {
25
26
  "typecheck": "tsc --noEmit",
26
- "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"
27
28
  },
28
29
  "dependencies": {
29
- "@getpaseo/client": "0.15.1",
30
+ "@getpaseo/client": "0.17.4",
30
31
  "ws": "^8.18.3"
31
32
  },
32
33
  "devDependencies": {
33
- "@getpaseo/plugin": "0.15.1",
34
+ "@getpaseo/plugin": "0.17.4",
34
35
  "@types/node": "^24.13.5",
35
36
  "@types/react": "~19.2.0",
36
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) }),