@koinzhang/paseo-plugin-commands 0.2.1 → 0.3.0
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 +28 -0
- package/README.md +12 -5
- package/client/agent-picker.ts +23 -0
- package/client/agent-state.ts +4 -1
- package/client/commands.ts +77 -5
- package/client/menu-list.tsx +12 -5
- package/client/picker.tsx +31 -12
- package/client/popover-lifecycle.ts +90 -0
- package/client/runtime-notice.ts +13 -0
- package/npm-shrinkwrap.json +24 -20
- package/package.json +4 -4
- package/paseo-plugin.json +2 -2
- package/server/control.ts +30 -14
- package/shared/agent-command.ts +71 -0
- package/shared/agent-options.ts +25 -0
- package/shared/commands.ts +21 -5
- package/shared/popover-geometry.ts +3 -2
- package/shared/rpc.ts +1 -5
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,32 @@ 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.3.0] - 2026-11-30
|
|
9
|
+
|
|
10
|
+
Requires Paseo **>= 0.16.0**.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `/agent [agent]` inserts another workspace agent's `paseo agent id: <id> ` into the current prompt without sending it. The picker lists other visible, unarchived agents in the same workspace, including closed agents that have not been opened on this client; passing a title or ID skips the picker.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Web pickers anchor to the measured composer icon instead of an inferred pill box.
|
|
19
|
+
- The picker keeps its first measured width while open, preventing the `/agent` popover from shrinking frame by frame; later layout changes still update its height.
|
|
20
|
+
|
|
21
|
+
## [0.2.2] - 2026-11-26
|
|
22
|
+
|
|
23
|
+
Requires Paseo **>= 0.16.0**.
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- `/model`, `/effort`, and `/mode` use the public Composer API instead of the plugin's private daemon control connection.
|
|
28
|
+
- Align the plugin SDK and daemon client with Paseo 0.17.4.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- Desktop pickers use the native Popover lifecycle so Escape closes the menu without also triggering Paseo's global agent interrupt shortcut.
|
|
33
|
+
|
|
8
34
|
## [0.2.1] - 2026-11-06
|
|
9
35
|
|
|
10
36
|
### Changed
|
|
@@ -30,6 +56,8 @@ Requires Paseo **>= 0.9.0**.
|
|
|
30
56
|
- `/resend [text]` agent slash command to resend the latest non-empty user prompt, appending optional text on a new line.
|
|
31
57
|
- 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
58
|
|
|
59
|
+
[0.3.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.3.0
|
|
60
|
+
[0.2.2]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.2.2
|
|
33
61
|
[0.2.1]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.2.1
|
|
34
62
|
[0.2.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.2.0
|
|
35
63
|
[0.1.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.1.0
|
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ Commands:
|
|
|
12
12
|
- `/rename [-t|-w] <title>` — rename the current tab, or the workspace with `-w`
|
|
13
13
|
- `/cancel` — cancel the running turn
|
|
14
14
|
- `/resend [text]` — resend the latest non-empty user prompt, appending any text on a new line
|
|
15
|
+
- `/agent [agent]` — insert another workspace agent's `paseo agent id: <id> ` into the current prompt
|
|
15
16
|
|
|
16
17
|
Options come from what the agent's provider reports; nothing is hardcoded. Without an argument,
|
|
17
18
|
a command opens a menu right away, anchored above the composer on desktop and as a sheet on
|
|
@@ -20,6 +21,9 @@ alias: an exact match wins, then a unique prefix, then a unique substring (model
|
|
|
20
21
|
substring stage). Ambiguous input lists the candidates. `/rename` without a flag renames the
|
|
21
22
|
current tab; `-t` and `--tab` do the same, and `-w` or `--workspace` renames the workspace.
|
|
22
23
|
`/resend` resends the latest prompt as text, appending extra text after one newline.
|
|
24
|
+
`/agent` lists other visible, unarchived agents in the same workspace, including closed agents
|
|
25
|
+
that have not been opened on this client. Selecting one inserts its paseo agent id without sending
|
|
26
|
+
the prompt. Pass an agent title or ID to skip the picker.
|
|
23
27
|
|
|
24
28
|
Turn individual commands on or off in **Settings → Plugins → commands → Settings**. A disabled command disappears
|
|
25
29
|
from slash autocomplete, so the provider's own command of the same name (if any) takes over.
|
|
@@ -34,6 +38,7 @@ from slash autocomplete, so the provider's own command of the same name (if any)
|
|
|
34
38
|
/rename Payment Review
|
|
35
39
|
/rename -w Payments work
|
|
36
40
|
/resend Also cover the empty input
|
|
41
|
+
/agent Reviewer
|
|
37
42
|
```
|
|
38
43
|
|
|
39
44
|
## Install
|
|
@@ -44,9 +49,10 @@ paseo plugin add npm:@koinzhang/paseo-plugin-commands
|
|
|
44
49
|
|
|
45
50
|
To install from GitHub, use `paseo plugin add github:koinzhang/paseo-plugins:commands`.
|
|
46
51
|
|
|
47
|
-
Requires Paseo >= 0.
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
Requires Paseo >= 0.16.0. `/model`, `/effort`, and `/mode` use the public Composer API. Profile,
|
|
53
|
+
feature, rename, and cancel controls use the daemon side of the plugin, which connects to its local
|
|
54
|
+
daemon (`PASEO_LISTEN` or `$PASEO_HOME/paseo.pid`). If the daemon requires a password, set
|
|
55
|
+
`PASEO_PASSWORD` for it.
|
|
50
56
|
|
|
51
57
|
## Development
|
|
52
58
|
|
|
@@ -60,5 +66,6 @@ paseo plugin reload commands
|
|
|
60
66
|
```
|
|
61
67
|
|
|
62
68
|
Command definitions and option matching live in `shared/` (`commands.ts`, `parse.ts`,
|
|
63
|
-
`resolve-option.ts`),
|
|
64
|
-
settings UI in `client/`. Specs are
|
|
69
|
+
`resolve-option.ts`), model / effort / mode writes use the public Composer API, the remaining
|
|
70
|
+
daemon-side controls live in `server/`, and the menus plus settings UI live in `client/`. Specs are
|
|
71
|
+
in [`specs/`](./specs/).
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PluginClientContext } from "@getpaseo/plugin/client";
|
|
2
|
+
import type { AgentDirectoryOption } from "../shared/agent-command.ts";
|
|
3
|
+
|
|
4
|
+
export async function loadAgentOptions(
|
|
5
|
+
paseo: PluginClientContext["paseo"],
|
|
6
|
+
): Promise<AgentDirectoryOption[]> {
|
|
7
|
+
const agents = new Map<string, AgentDirectoryOption>();
|
|
8
|
+
let page = await paseo.agents.list({
|
|
9
|
+
filter: { includeArchived: true },
|
|
10
|
+
page: { limit: 200 },
|
|
11
|
+
});
|
|
12
|
+
for (let pages = 0; ; pages++) {
|
|
13
|
+
for (const { agent } of page.entries) agents.set(agent.id, agent);
|
|
14
|
+
if (!page.pageInfo.hasMore) return [...agents.values()];
|
|
15
|
+
if (!page.pageInfo.nextCursor || pages >= 99) {
|
|
16
|
+
throw new Error("The agent directory pagination is incomplete.");
|
|
17
|
+
}
|
|
18
|
+
page = await paseo.agents.list({
|
|
19
|
+
filter: { includeArchived: true },
|
|
20
|
+
page: { limit: 200, cursor: page.pageInfo.nextCursor },
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
package/client/agent-state.ts
CHANGED
|
@@ -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
|
|
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
|
|
package/client/commands.ts
CHANGED
|
@@ -9,10 +9,13 @@ import {
|
|
|
9
9
|
planRename,
|
|
10
10
|
type Plan,
|
|
11
11
|
} from "../shared/commands.ts";
|
|
12
|
+
import { agentPromptText, listAgentOptions, planAgent } from "../shared/agent-command.ts";
|
|
12
13
|
import { agentControl } from "../shared/rpc.ts";
|
|
13
14
|
import { composeResendPrompt, latestUserPrompt } from "../shared/resend.ts";
|
|
15
|
+
import { loadAgentOptions } from "./agent-picker.ts";
|
|
14
16
|
import { loadAgentState, loadProfiles } from "./agent-state.ts";
|
|
15
|
-
import type { PickerHost,
|
|
17
|
+
import type { PickerHost, RunPicker } from "./picker.tsx";
|
|
18
|
+
import { runtimeControlNotice } from "./runtime-notice.ts";
|
|
16
19
|
import { getDisabledCommands, subscribeDisabledCommands } from "./settings-store.ts";
|
|
17
20
|
|
|
18
21
|
type Context = PluginAgentCommandContext & { args: string };
|
|
@@ -36,6 +39,7 @@ type CommandSpec = CommandMetadata &
|
|
|
36
39
|
(
|
|
37
40
|
| { plan(context: Context): Promise<Plan>; execute?: never }
|
|
38
41
|
| { execute(context: Context): Promise<void>; plan?: never }
|
|
42
|
+
| { agentPicker: true; plan?: never; execute?: never }
|
|
39
43
|
);
|
|
40
44
|
|
|
41
45
|
async function renameCurrent(ctx: Context): Promise<void> {
|
|
@@ -72,6 +76,16 @@ async function resendLastPrompt(ctx: Context): Promise<void> {
|
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
|
|
79
|
+
const AGENT_COMMAND: CommandSpec = {
|
|
80
|
+
name: "agent",
|
|
81
|
+
description: "Insert another workspace agent's paseo agent id",
|
|
82
|
+
details:
|
|
83
|
+
"Pick another visible agent in this workspace, or pass its title or ID. The ID is inserted into the current prompt without sending it.",
|
|
84
|
+
argumentHint: "[agent]",
|
|
85
|
+
section: "prompt",
|
|
86
|
+
agentPicker: true,
|
|
87
|
+
};
|
|
88
|
+
|
|
75
89
|
export const COMMANDS: readonly CommandSpec[] = [
|
|
76
90
|
{
|
|
77
91
|
name: "model",
|
|
@@ -154,16 +168,68 @@ export const COMMANDS: readonly CommandSpec[] = [
|
|
|
154
168
|
section: "prompt",
|
|
155
169
|
execute: resendLastPrompt,
|
|
156
170
|
},
|
|
171
|
+
AGENT_COMMAND,
|
|
157
172
|
];
|
|
158
173
|
|
|
159
|
-
function controlRunner(ctx: Context):
|
|
160
|
-
return async (
|
|
174
|
+
function controlRunner(ctx: Context): RunPicker {
|
|
175
|
+
return async (entry) => {
|
|
176
|
+
const { control, note } = entry;
|
|
177
|
+
if (!control) throw new Error("This option is unavailable.");
|
|
161
178
|
const { notice } = await ctx.rpc(agentControl, control);
|
|
162
179
|
const warning = notice && notice.type !== "info" ? notice.message : null;
|
|
163
180
|
return [note, warning].filter(Boolean).join("\n") || null;
|
|
164
181
|
};
|
|
165
182
|
}
|
|
166
183
|
|
|
184
|
+
function runtimeRunner(ctx: Context): RunPicker {
|
|
185
|
+
return async (entry) => {
|
|
186
|
+
const { control, note } = entry;
|
|
187
|
+
if (!control) throw new Error("This option is unavailable.");
|
|
188
|
+
if (control.op !== "model" && control.op !== "thinking" && control.op !== "mode") {
|
|
189
|
+
throw new Error("This command must use the agent control RPC.");
|
|
190
|
+
}
|
|
191
|
+
const state = await loadAgentState(ctx.paseo, ctx.agent.id);
|
|
192
|
+
const [composer] = ctx.composers({ agentId: ctx.agent.id });
|
|
193
|
+
if (!composer) throw new Error("The agent's composer is unavailable.");
|
|
194
|
+
if (control.op === "model") await composer.setModel(control.modelId);
|
|
195
|
+
else if (control.op === "thinking") await composer.setThinking(control.thinkingOptionId);
|
|
196
|
+
else await composer.setMode(control.modeId);
|
|
197
|
+
return [note, runtimeControlNotice(state, control)].filter(Boolean).join("\n") || null;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async function insertAgentId(
|
|
202
|
+
client: PluginClientContext,
|
|
203
|
+
agentId: string,
|
|
204
|
+
targetAgentId: string,
|
|
205
|
+
): Promise<void> {
|
|
206
|
+
const [composer] = client.composers({ agentId });
|
|
207
|
+
if (!composer) throw new Error("The agent's composer is unavailable.");
|
|
208
|
+
composer.insertText(agentPromptText(targetAgentId));
|
|
209
|
+
await composer.focus();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async function executeAgentCommand(
|
|
213
|
+
ctx: Context,
|
|
214
|
+
client: PluginClientContext,
|
|
215
|
+
pickers: PickerHost,
|
|
216
|
+
): Promise<void> {
|
|
217
|
+
const options = listAgentOptions(await loadAgentOptions(ctx.paseo), {
|
|
218
|
+
workspaceId: ctx.workspace.id,
|
|
219
|
+
currentAgentId: ctx.agent.id,
|
|
220
|
+
});
|
|
221
|
+
const result = planAgent(ctx.args, options);
|
|
222
|
+
if (result.kind === "insert") {
|
|
223
|
+
await insertAgentId(client, ctx.agent.id, result.agentId);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
pickers.show({ workspaceId: ctx.workspace.id, agentId: ctx.agent.id }, result.plan, async (entry) => {
|
|
227
|
+
if (!entry.agentId) throw new Error("This option is unavailable.");
|
|
228
|
+
await insertAgentId(client, ctx.agent.id, entry.agentId);
|
|
229
|
+
return null;
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
167
233
|
function addCommand(client: PluginClientContext, pickers: PickerHost, command: CommandSpec) {
|
|
168
234
|
return client.addSlashCommand({
|
|
169
235
|
name: command.name,
|
|
@@ -171,17 +237,23 @@ function addCommand(client: PluginClientContext, pickers: PickerHost, command: C
|
|
|
171
237
|
argumentHint: command.argumentHint,
|
|
172
238
|
context: "agent",
|
|
173
239
|
async onSubmit(ctx) {
|
|
240
|
+
if ("agentPicker" in command) {
|
|
241
|
+
await executeAgentCommand({ ...ctx, args: ctx.args }, client, pickers);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
174
244
|
if (command.execute) {
|
|
175
245
|
await command.execute(ctx);
|
|
176
246
|
return;
|
|
177
247
|
}
|
|
178
248
|
const plan = await command.plan(ctx);
|
|
179
|
-
const run =
|
|
249
|
+
const run = ["model", "effort", "mode"].includes(command.name)
|
|
250
|
+
? runtimeRunner(ctx)
|
|
251
|
+
: controlRunner(ctx);
|
|
180
252
|
if (plan.kind === "picker") {
|
|
181
253
|
pickers.show({ workspaceId: ctx.agent.workspaceId, agentId: ctx.agent.id }, plan, run);
|
|
182
254
|
return;
|
|
183
255
|
}
|
|
184
|
-
const message = await run(plan.control, plan.note);
|
|
256
|
+
const message = await run({ id: plan.control.op, title: "", control: plan.control, note: plan.note });
|
|
185
257
|
if (message) throw new Error(message);
|
|
186
258
|
},
|
|
187
259
|
});
|
package/client/menu-list.tsx
CHANGED
|
@@ -48,6 +48,11 @@ function createStyles(theme: PluginTheme, compact: boolean) {
|
|
|
48
48
|
color: colors.foreground,
|
|
49
49
|
fontWeight: "400" as const,
|
|
50
50
|
},
|
|
51
|
+
subtitle: {
|
|
52
|
+
fontSize: 11,
|
|
53
|
+
lineHeight: LINE_HEIGHT,
|
|
54
|
+
color: colors.foregroundMuted,
|
|
55
|
+
},
|
|
51
56
|
trailing: {
|
|
52
57
|
marginLeft: "auto" as const,
|
|
53
58
|
alignItems: "center" as const,
|
|
@@ -89,10 +94,7 @@ export function MenuList({
|
|
|
89
94
|
}
|
|
90
95
|
return rows;
|
|
91
96
|
}, [items]);
|
|
92
|
-
const enabled = useMemo(
|
|
93
|
-
() => leaves.filter(({ entry }) => entry.disabled !== true && entry.control),
|
|
94
|
-
[leaves],
|
|
95
|
-
);
|
|
97
|
+
const enabled = useMemo(() => leaves.filter(({ entry }) => entry.disabled !== true), [leaves]);
|
|
96
98
|
|
|
97
99
|
useEffect(() => {
|
|
98
100
|
if (!autoFocus) return undefined;
|
|
@@ -135,7 +137,7 @@ export function MenuList({
|
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
function renderRow(key: string, entry: PickerLeaf) {
|
|
138
|
-
const disabled = entry.disabled === true
|
|
140
|
+
const disabled = entry.disabled === true;
|
|
139
141
|
return (
|
|
140
142
|
<Pressable
|
|
141
143
|
key={key}
|
|
@@ -163,6 +165,11 @@ export function MenuList({
|
|
|
163
165
|
<Text numberOfLines={1} style={styles.text}>
|
|
164
166
|
{entry.title}
|
|
165
167
|
</Text>
|
|
168
|
+
{entry.subtitle ? (
|
|
169
|
+
<Text numberOfLines={1} style={styles.subtitle}>
|
|
170
|
+
{entry.subtitle}
|
|
171
|
+
</Text>
|
|
172
|
+
) : null}
|
|
166
173
|
</View>
|
|
167
174
|
{entry.current ? (
|
|
168
175
|
<View style={styles.trailing}>
|
package/client/picker.tsx
CHANGED
|
@@ -19,18 +19,18 @@ import {
|
|
|
19
19
|
} from "react-native";
|
|
20
20
|
import type { Plan } from "../shared/commands.ts";
|
|
21
21
|
import {
|
|
22
|
-
|
|
22
|
+
anchorRectFromIcon,
|
|
23
23
|
placePopover,
|
|
24
24
|
visibleHeight,
|
|
25
25
|
type Rect,
|
|
26
26
|
type Size,
|
|
27
27
|
} from "../shared/popover-geometry.ts";
|
|
28
|
-
import type { AgentControl } from "../shared/rpc.ts";
|
|
29
28
|
import { MenuList, type PickerLeaf } from "./menu-list.tsx";
|
|
29
|
+
import { openPickerPopover } from "./popover-lifecycle.ts";
|
|
30
30
|
|
|
31
31
|
type PickerPlan = Extract<Plan, { kind: "picker" }>;
|
|
32
|
-
/** Applies a
|
|
33
|
-
export type
|
|
32
|
+
/** Applies a picker choice and resolves to a message to show, if any. */
|
|
33
|
+
export type RunPicker = (entry: PickerLeaf) => Promise<string | null>;
|
|
34
34
|
|
|
35
35
|
export interface PickerTarget {
|
|
36
36
|
workspaceId: string;
|
|
@@ -39,7 +39,7 @@ export interface PickerTarget {
|
|
|
39
39
|
|
|
40
40
|
interface PickerState {
|
|
41
41
|
plan: PickerPlan;
|
|
42
|
-
run:
|
|
42
|
+
run: RunPicker;
|
|
43
43
|
open: boolean;
|
|
44
44
|
close(): void;
|
|
45
45
|
}
|
|
@@ -102,10 +102,9 @@ function surfaceStyle(theme: PluginTheme) {
|
|
|
102
102
|
function useChoose(state: PickerState) {
|
|
103
103
|
const toast = useToast();
|
|
104
104
|
return (entry: PickerLeaf) => {
|
|
105
|
-
if (
|
|
106
|
-
const { control, note } = entry;
|
|
105
|
+
if (entry.disabled) return;
|
|
107
106
|
state.close();
|
|
108
|
-
state.run(
|
|
107
|
+
state.run(entry).then(
|
|
109
108
|
(message) => {
|
|
110
109
|
if (message) toast.show(message, { variant: "warning" });
|
|
111
110
|
},
|
|
@@ -128,7 +127,9 @@ function PickerPopover({
|
|
|
128
127
|
const [trigger, setTrigger] = useState<Rect | null>(null);
|
|
129
128
|
const [content, setContent] = useState<Size | null>(null);
|
|
130
129
|
const progress = useRef(new Animated.Value(0)).current;
|
|
130
|
+
const surfaceRef = useRef<View>(null);
|
|
131
131
|
const surface = useMemo(() => surfaceStyle(theme), [theme]);
|
|
132
|
+
const close = state.close;
|
|
132
133
|
|
|
133
134
|
useEffect(() => {
|
|
134
135
|
if (!state.open) {
|
|
@@ -139,7 +140,9 @@ function PickerPopover({
|
|
|
139
140
|
const statusBar = Platform.OS === "android" ? (StatusBar.currentHeight ?? 0) : 0;
|
|
140
141
|
let cancelled = false;
|
|
141
142
|
anchor.current?.measureInWindow((x, y, width, height) => {
|
|
142
|
-
if (!cancelled)
|
|
143
|
+
if (!cancelled) {
|
|
144
|
+
setTrigger(anchorRectFromIcon({ x, y: y + statusBar, width, height }, Platform.OS === "web"));
|
|
145
|
+
}
|
|
143
146
|
});
|
|
144
147
|
return () => {
|
|
145
148
|
cancelled = true;
|
|
@@ -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,
|
|
@@ -207,9 +226,9 @@ function PickerPopover({
|
|
|
207
226
|
onLayout={(event) => {
|
|
208
227
|
const { width, height } = event.nativeEvent.layout;
|
|
209
228
|
setContent((current) =>
|
|
210
|
-
current && current.
|
|
229
|
+
current && current.height === height
|
|
211
230
|
? current
|
|
212
|
-
: { width, height },
|
|
231
|
+
: { width: current?.width ?? width, height },
|
|
213
232
|
);
|
|
214
233
|
}}
|
|
215
234
|
>
|
|
@@ -287,7 +306,7 @@ export function createPickerHost(client: PluginClientContext) {
|
|
|
287
306
|
setState(agentId, null);
|
|
288
307
|
}
|
|
289
308
|
|
|
290
|
-
function show(target: PickerTarget, plan: PickerPlan, run:
|
|
309
|
+
function show(target: PickerTarget, plan: PickerPlan, run: RunPicker) {
|
|
291
310
|
const { agentId } = target;
|
|
292
311
|
setState(agentId, { plan, run, open: true, close: () => remove(agentId) });
|
|
293
312
|
const button: PluginButton = {
|
|
@@ -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
|
+
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koinzhang/paseo-plugin-commands",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@koinzhang/paseo-plugin-commands",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.3.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@getpaseo/client": "0.
|
|
12
|
+
"@getpaseo/client": "0.17.4",
|
|
13
13
|
"ws": "^8.18.3"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@getpaseo/plugin": "0.
|
|
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.
|
|
525
|
-
"resolved": "https://registry.npmjs.org/@getpaseo/client/-/client-0.
|
|
526
|
-
"integrity": "sha512-
|
|
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.
|
|
529
|
-
"@getpaseo/relay": "0.
|
|
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.
|
|
536
|
-
"resolved": "https://registry.npmjs.org/@getpaseo/plugin/-/plugin-0.
|
|
537
|
-
"integrity": "sha512-
|
|
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.
|
|
546
|
-
"@getpaseo/protocol": "0.
|
|
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.
|
|
559
|
-
"resolved": "https://registry.npmjs.org/@getpaseo/protocol/-/protocol-0.
|
|
560
|
-
"integrity": "sha512-
|
|
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.
|
|
568
|
-
"resolved": "https://registry.npmjs.org/@getpaseo/relay/-/relay-0.
|
|
569
|
-
"integrity": "sha512-
|
|
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.
|
|
3
|
+
"version": "0.3.0",
|
|
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.
|
|
30
|
+
"@getpaseo/client": "0.17.4",
|
|
31
31
|
"ws": "^8.18.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@getpaseo/plugin": "0.
|
|
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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "commands",
|
|
3
|
-
"description": "Slash commands for the current agent: /model, /effort, /profile, /mode, /feature, /rename, /cancel, /resend",
|
|
3
|
+
"description": "Slash commands for the current agent: /model, /effort, /profile, /mode, /feature, /rename, /cancel, /resend, /agent",
|
|
4
4
|
"requirements": {
|
|
5
|
-
"paseo": ">=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
|
-
|
|
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
|
|
39
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
50
|
-
|
|
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,71 @@
|
|
|
1
|
+
import type { PickerEntry, Plan } from "./commands.ts";
|
|
2
|
+
import { requireOption } from "./resolve-option.ts";
|
|
3
|
+
|
|
4
|
+
export interface AgentDirectoryOption {
|
|
5
|
+
id: string;
|
|
6
|
+
workspaceId?: string;
|
|
7
|
+
title: string | null;
|
|
8
|
+
provider: string;
|
|
9
|
+
status: string;
|
|
10
|
+
archivedAt?: string | null;
|
|
11
|
+
background?: boolean;
|
|
12
|
+
internal?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface AgentPickerOption {
|
|
16
|
+
id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
title: string;
|
|
19
|
+
subtitle: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type AgentCommandPlan =
|
|
23
|
+
| { kind: "picker"; plan: Extract<Plan, { kind: "picker" }> }
|
|
24
|
+
| { kind: "insert"; agentId: string };
|
|
25
|
+
|
|
26
|
+
export function agentPromptText(agentId: string): string {
|
|
27
|
+
return `paseo agent id: ${agentId} `;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function listAgentOptions(
|
|
31
|
+
agents: readonly AgentDirectoryOption[],
|
|
32
|
+
input: { workspaceId: string; currentAgentId: string },
|
|
33
|
+
): AgentPickerOption[] {
|
|
34
|
+
return agents
|
|
35
|
+
.filter(
|
|
36
|
+
(agent) =>
|
|
37
|
+
agent.workspaceId === input.workspaceId &&
|
|
38
|
+
agent.id !== input.currentAgentId &&
|
|
39
|
+
!agent.archivedAt &&
|
|
40
|
+
agent.background !== true &&
|
|
41
|
+
agent.internal !== true,
|
|
42
|
+
)
|
|
43
|
+
.sort((left, right) => (left.title ?? left.id).localeCompare(right.title ?? right.id))
|
|
44
|
+
.map((agent) => {
|
|
45
|
+
const label = agent.title?.trim() || agent.id;
|
|
46
|
+
return {
|
|
47
|
+
id: agent.id,
|
|
48
|
+
label,
|
|
49
|
+
title: label,
|
|
50
|
+
subtitle: `${agent.provider} · ${agent.status} · ${agent.id}`,
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function planAgent(
|
|
56
|
+
args: string,
|
|
57
|
+
options: readonly AgentPickerOption[],
|
|
58
|
+
): AgentCommandPlan {
|
|
59
|
+
if (!args.trim()) {
|
|
60
|
+
const items: PickerEntry[] = options.length
|
|
61
|
+
? options.map((option) => ({
|
|
62
|
+
id: option.id,
|
|
63
|
+
title: option.title,
|
|
64
|
+
subtitle: option.subtitle,
|
|
65
|
+
agentId: option.id,
|
|
66
|
+
}))
|
|
67
|
+
: [{ id: "empty", title: "No other agents in this workspace", disabled: true }];
|
|
68
|
+
return { kind: "picker", plan: { kind: "picker", title: "Agents", icon: "Bot", items } };
|
|
69
|
+
}
|
|
70
|
+
return { kind: "insert", agentId: requireOption("agent", args, options).id };
|
|
71
|
+
}
|
|
@@ -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
|
+
}
|
package/shared/commands.ts
CHANGED
|
@@ -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 =
|
|
@@ -51,6 +56,8 @@ export type PickerEntry =
|
|
|
51
56
|
title: string;
|
|
52
57
|
current?: boolean;
|
|
53
58
|
disabled?: boolean;
|
|
59
|
+
subtitle?: string;
|
|
60
|
+
agentId?: string;
|
|
54
61
|
control?: AgentControl;
|
|
55
62
|
note?: string;
|
|
56
63
|
}
|
|
@@ -166,7 +173,8 @@ export function formatFeatureValue(feature: Feature): string {
|
|
|
166
173
|
}
|
|
167
174
|
|
|
168
175
|
export function planFeature(args: string, state: AgentState): Plan {
|
|
169
|
-
const { agentId
|
|
176
|
+
const { agentId } = state;
|
|
177
|
+
const features = optionFeatures(state);
|
|
170
178
|
if (features.length === 0) throw new Error(`Provider "${state.provider}" exposes no features.`);
|
|
171
179
|
const { head, rest } = splitFirst(args);
|
|
172
180
|
if (!head) {
|
|
@@ -190,6 +198,12 @@ export function planFeature(args: string, state: AgentState): Plan {
|
|
|
190
198
|
items: featureValueEntries(agentId, feature),
|
|
191
199
|
};
|
|
192
200
|
}
|
|
201
|
+
if (rest === "--default") {
|
|
202
|
+
return {
|
|
203
|
+
kind: "run",
|
|
204
|
+
control: { op: "feature", agentId, featureId: feature.id, value: null },
|
|
205
|
+
};
|
|
206
|
+
}
|
|
193
207
|
if (feature.type === "toggle") {
|
|
194
208
|
const value = parseToggle(rest);
|
|
195
209
|
if (value === null) {
|
|
@@ -217,6 +231,7 @@ const PROFILE_KEYS = new Set([
|
|
|
217
231
|
"modeId",
|
|
218
232
|
"thinkingOptionId",
|
|
219
233
|
"featureValues",
|
|
234
|
+
"options",
|
|
220
235
|
]);
|
|
221
236
|
|
|
222
237
|
function trimmed(value: unknown): string {
|
|
@@ -269,12 +284,13 @@ export function profileControl(
|
|
|
269
284
|
}
|
|
270
285
|
}
|
|
271
286
|
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
287
|
+
const features = optionFeatures(state);
|
|
288
|
+
const options: Record<string, unknown> = {};
|
|
289
|
+
for (const [id, value] of Object.entries(profile.options ?? profile.featureValues ?? {})) {
|
|
290
|
+
if (features.some((feature) => feature.id === id)) options[id] = value;
|
|
275
291
|
else ignored.push(`feature "${id}"`);
|
|
276
292
|
}
|
|
277
|
-
if (Object.keys(
|
|
293
|
+
if (Object.keys(options).length > 0) config.options = options;
|
|
278
294
|
|
|
279
295
|
for (const key of Object.keys(profile)) {
|
|
280
296
|
if (!PROFILE_KEYS.has(key)) ignored.push(key);
|
|
@@ -19,8 +19,9 @@ const EDGE_PADDING = 8;
|
|
|
19
19
|
const PILL_INSET_X = 13;
|
|
20
20
|
const PILL_HEIGHT = 32;
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
export function
|
|
22
|
+
/** Web uses the measured anchor directly; other platforms retain the inferred pill box. */
|
|
23
|
+
export function anchorRectFromIcon(icon: Rect, isWeb: boolean): Rect {
|
|
24
|
+
if (isWeb) return icon;
|
|
24
25
|
return {
|
|
25
26
|
x: icon.x - PILL_INSET_X,
|
|
26
27
|
y: icon.y + icon.height / 2 - PILL_HEIGHT / 2,
|
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
|
-
|
|
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) }),
|