@omercnet/paseo-omp 5.4.0-next.403.1 → 5.4.0-next.404.1
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/client/omp-config-surface.tsx +34 -4
- package/client/omp-routing-editor.tsx +123 -2
- package/index.server.ts +3 -0
- package/package.json +1 -1
- package/server/omp-agents.ts +170 -0
- package/server/omp-settings.ts +3 -3
- package/server/package-version.ts +1 -1
- package/shared/omp-agents.ts +26 -0
- package/shared/omp-settings.ts +21 -1
|
@@ -11,6 +11,7 @@ import type { ReactNode } from "react";
|
|
|
11
11
|
import { useCallback, useMemo, useState } from "react";
|
|
12
12
|
import { Pressable, ScrollView, Switch, Text, View } from "react-native";
|
|
13
13
|
import type { ComposerPillSettings } from "../shared/composer-pill-settings";
|
|
14
|
+
import { listOmpAgents } from "../shared/omp-agents";
|
|
14
15
|
import { listOmpConfig, type OmpConfig } from "../shared/omp-config";
|
|
15
16
|
import { listOmpModels } from "../shared/omp-models";
|
|
16
17
|
import {
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
type OmpSettingCategory,
|
|
24
25
|
orderOmpToolSettings,
|
|
25
26
|
parseOmpStructuredSettingValue,
|
|
27
|
+
structuredSettingType,
|
|
26
28
|
updateOmpSettings,
|
|
27
29
|
} from "../shared/omp-settings";
|
|
28
30
|
import { type OmpStore, storeLabel } from "../shared/omp-store";
|
|
@@ -44,7 +46,11 @@ import {
|
|
|
44
46
|
import { OmpMcpsSection } from "./omp-mcps-section";
|
|
45
47
|
import { normalizeOmpModels } from "./omp-model-picker-state";
|
|
46
48
|
import { OmpPluginManagerSection } from "./omp-plugin-manager";
|
|
47
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
type OmpAgentCatalogState,
|
|
51
|
+
type OmpModelCatalogState,
|
|
52
|
+
StructuredRoutingEditor,
|
|
53
|
+
} from "./omp-routing-editor";
|
|
48
54
|
import { OmpRulesSection } from "./omp-rules-section";
|
|
49
55
|
import { OmpSkillsSection } from "./omp-skills-section";
|
|
50
56
|
import { OmpStorePicker } from "./omp-store-picker";
|
|
@@ -815,6 +821,7 @@ function ConfigurationCategory({
|
|
|
815
821
|
theme,
|
|
816
822
|
modelCatalog,
|
|
817
823
|
modelRoles,
|
|
824
|
+
agentCatalog,
|
|
818
825
|
disabled,
|
|
819
826
|
workspaceScoped,
|
|
820
827
|
onDraft,
|
|
@@ -825,6 +832,7 @@ function ConfigurationCategory({
|
|
|
825
832
|
theme: PluginSurfaceProps["theme"];
|
|
826
833
|
modelCatalog: OmpModelCatalogState;
|
|
827
834
|
modelRoles: Readonly<Record<string, unknown>>;
|
|
835
|
+
agentCatalog: OmpAgentCatalogState;
|
|
828
836
|
settings: readonly OmpSetting[];
|
|
829
837
|
drafts: Readonly<Record<string, SettingDraft>>;
|
|
830
838
|
disabled: boolean;
|
|
@@ -856,7 +864,7 @@ function ConfigurationCategory({
|
|
|
856
864
|
const structuredEditable =
|
|
857
865
|
!setting.redacted &&
|
|
858
866
|
isOmpStructuredSettingPath(setting.path) &&
|
|
859
|
-
setting.type === (setting.path
|
|
867
|
+
setting.type === structuredSettingType(setting.path);
|
|
860
868
|
const settingDocumentation = documentationForSettingPath(setting.path);
|
|
861
869
|
const draft = drafts[setting.path];
|
|
862
870
|
return (
|
|
@@ -905,6 +913,7 @@ function ConfigurationCategory({
|
|
|
905
913
|
theme={theme}
|
|
906
914
|
modelCatalog={modelCatalog}
|
|
907
915
|
modelRoles={modelRoles}
|
|
916
|
+
agentCatalog={agentCatalog}
|
|
908
917
|
onSet={(value) => onDraft(setting.path, { operation: "set", value })}
|
|
909
918
|
onReset={() => onDraft(setting.path, { operation: "reset" })}
|
|
910
919
|
/>
|
|
@@ -973,6 +982,7 @@ function OmpConfigContent({
|
|
|
973
982
|
const loadSettings = useRpc(listOmpSettings);
|
|
974
983
|
const updateSettings = useRpc(updateOmpSettings);
|
|
975
984
|
const loadModels = useRpc(listOmpModels);
|
|
985
|
+
const loadAgents = useRpc(listOmpAgents);
|
|
976
986
|
const queryClient = useQueryClient();
|
|
977
987
|
const context = { store, ...(cwd ? { cwd } : {}) };
|
|
978
988
|
const pendingMutations = useIsMutating({ mutationKey: ["paseo-omp"] });
|
|
@@ -992,6 +1002,18 @@ function OmpConfigContent({
|
|
|
992
1002
|
queryFn: () => loadModels(context),
|
|
993
1003
|
staleTime: 30_000,
|
|
994
1004
|
});
|
|
1005
|
+
const agentsQuery = useQuery({
|
|
1006
|
+
queryKey: ["paseo-omp", "agents", ompStoreKey(store), cwd ?? "global"],
|
|
1007
|
+
queryFn: () => loadAgents(context),
|
|
1008
|
+
staleTime: 5 * 60_000,
|
|
1009
|
+
});
|
|
1010
|
+
const agentCatalog: OmpAgentCatalogState = {
|
|
1011
|
+
agents: agentsQuery.data?.agents ?? [],
|
|
1012
|
+
loading: agentsQuery.isLoading,
|
|
1013
|
+
...(agentsQuery.error || agentsQuery.data?.error
|
|
1014
|
+
? { error: "Could not list every OMP agent. Typed names remain available." }
|
|
1015
|
+
: {}),
|
|
1016
|
+
};
|
|
995
1017
|
const [view, setView] = useState<SurfaceView>("overview");
|
|
996
1018
|
const [activeCategory, setActiveCategory] = useState<OmpSettingCategory>("appearance");
|
|
997
1019
|
const [search, setSearch] = useState("");
|
|
@@ -1227,19 +1249,26 @@ function OmpConfigContent({
|
|
|
1227
1249
|
accessibilityLabel="Refresh OMP configuration"
|
|
1228
1250
|
style={styles.refresh}
|
|
1229
1251
|
disabled={
|
|
1230
|
-
configQuery.isFetching ||
|
|
1252
|
+
configQuery.isFetching ||
|
|
1253
|
+
settingsQuery.isFetching ||
|
|
1254
|
+
modelsQuery.isFetching ||
|
|
1255
|
+
agentsQuery.isFetching
|
|
1231
1256
|
}
|
|
1232
1257
|
onPress={() => {
|
|
1233
1258
|
void Promise.all([
|
|
1234
1259
|
configQuery.refetch(),
|
|
1235
1260
|
settingsQuery.refetch(),
|
|
1236
1261
|
modelsQuery.refetch(),
|
|
1262
|
+
agentsQuery.refetch(),
|
|
1237
1263
|
]);
|
|
1238
1264
|
}}
|
|
1239
1265
|
>
|
|
1240
1266
|
<Icon name="RefreshCw" size={14} color={theme.colors.foreground} />
|
|
1241
1267
|
<Text style={styles.refreshLabel}>
|
|
1242
|
-
{configQuery.isFetching ||
|
|
1268
|
+
{configQuery.isFetching ||
|
|
1269
|
+
settingsQuery.isFetching ||
|
|
1270
|
+
modelsQuery.isFetching ||
|
|
1271
|
+
agentsQuery.isFetching
|
|
1243
1272
|
? "Refreshing…"
|
|
1244
1273
|
: "Refresh"}
|
|
1245
1274
|
</Text>
|
|
@@ -1380,6 +1409,7 @@ function OmpConfigContent({
|
|
|
1380
1409
|
theme={theme}
|
|
1381
1410
|
modelCatalog={modelCatalog}
|
|
1382
1411
|
modelRoles={modelRoles}
|
|
1412
|
+
agentCatalog={agentCatalog}
|
|
1383
1413
|
styles={styles}
|
|
1384
1414
|
settings={catalog.byCategory.get(selectedCategory.id) ?? []}
|
|
1385
1415
|
drafts={drafts}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
2
2
|
import { TextInput } from "@getpaseo/plugin/client/ui";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import { Pressable, Text, View } from "react-native";
|
|
4
|
+
import { Pressable, Switch, Text, View } from "react-native";
|
|
5
|
+
import type { OmpAgent } from "../shared/omp-agents";
|
|
5
6
|
import {
|
|
6
7
|
formatOmpSettingLabel,
|
|
7
8
|
isOmpStructuredSettingPath,
|
|
@@ -24,6 +25,12 @@ export type OmpModelCatalogState = {
|
|
|
24
25
|
error?: string;
|
|
25
26
|
};
|
|
26
27
|
|
|
28
|
+
export type OmpAgentCatalogState = {
|
|
29
|
+
agents: readonly OmpAgent[];
|
|
30
|
+
loading: boolean;
|
|
31
|
+
error?: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
27
34
|
type StructuredRoutingEditorProps = {
|
|
28
35
|
setting: OmpSetting;
|
|
29
36
|
value: unknown;
|
|
@@ -35,6 +42,7 @@ type StructuredRoutingEditorProps = {
|
|
|
35
42
|
theme: PluginSurfaceProps["theme"];
|
|
36
43
|
modelCatalog: OmpModelCatalogState;
|
|
37
44
|
modelRoles: Readonly<Record<string, unknown>>;
|
|
45
|
+
agentCatalog: OmpAgentCatalogState;
|
|
38
46
|
onSet(value: unknown): void;
|
|
39
47
|
onReset(): void;
|
|
40
48
|
};
|
|
@@ -128,6 +136,99 @@ function OrderedRoleEditor({
|
|
|
128
136
|
);
|
|
129
137
|
}
|
|
130
138
|
|
|
139
|
+
function AgentPicker({
|
|
140
|
+
agents,
|
|
141
|
+
taken,
|
|
142
|
+
disabled,
|
|
143
|
+
styles,
|
|
144
|
+
onSelect,
|
|
145
|
+
}: {
|
|
146
|
+
agents: readonly OmpAgent[];
|
|
147
|
+
taken: readonly string[];
|
|
148
|
+
disabled: boolean;
|
|
149
|
+
styles: OmpConfigStyles;
|
|
150
|
+
onSelect(name: string): void;
|
|
151
|
+
}) {
|
|
152
|
+
const [open, setOpen] = useState(false);
|
|
153
|
+
const choices = agents.filter((agent) => !taken.includes(agent.name));
|
|
154
|
+
if (choices.length === 0) return null;
|
|
155
|
+
return (
|
|
156
|
+
<View style={styles.recordList}>
|
|
157
|
+
<RowButton
|
|
158
|
+
label={open ? "Close agents" : "Choose agent"}
|
|
159
|
+
disabled={disabled}
|
|
160
|
+
styles={styles}
|
|
161
|
+
onPress={() => setOpen((current) => !current)}
|
|
162
|
+
/>
|
|
163
|
+
{open
|
|
164
|
+
? choices.map((agent) => (
|
|
165
|
+
<RowButton
|
|
166
|
+
key={agent.name}
|
|
167
|
+
label={`${agent.name} (${agent.source})`}
|
|
168
|
+
disabled={disabled}
|
|
169
|
+
styles={styles}
|
|
170
|
+
onPress={() => {
|
|
171
|
+
onSelect(agent.name);
|
|
172
|
+
setOpen(false);
|
|
173
|
+
}}
|
|
174
|
+
/>
|
|
175
|
+
))
|
|
176
|
+
: null}
|
|
177
|
+
</View>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Turning off the default agent fails every task call that names no agent. */
|
|
182
|
+
const DEFAULT_AGENT = "task";
|
|
183
|
+
|
|
184
|
+
function DisabledAgentsEditor({
|
|
185
|
+
value,
|
|
186
|
+
agentCatalog,
|
|
187
|
+
disabled,
|
|
188
|
+
styles,
|
|
189
|
+
onSet,
|
|
190
|
+
}: Pick<StructuredRoutingEditorProps, "value" | "agentCatalog" | "disabled" | "styles" | "onSet">) {
|
|
191
|
+
const switchedOff = asStringArray(value);
|
|
192
|
+
const listed = agentCatalog.agents.map((agent) => agent.name);
|
|
193
|
+
const names = [...listed, ...switchedOff.filter((name) => !listed.includes(name))];
|
|
194
|
+
return (
|
|
195
|
+
<View style={styles.recordList}>
|
|
196
|
+
{agentCatalog.error ? (
|
|
197
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
198
|
+
{agentCatalog.error}
|
|
199
|
+
</Text>
|
|
200
|
+
) : null}
|
|
201
|
+
{names.length === 0 ? (
|
|
202
|
+
<Text style={styles.muted}>
|
|
203
|
+
{agentCatalog.loading ? "Loading agents…" : "No agents found."}
|
|
204
|
+
</Text>
|
|
205
|
+
) : null}
|
|
206
|
+
{names.map((name) => {
|
|
207
|
+
const off = switchedOff.includes(name);
|
|
208
|
+
const locked = name === DEFAULT_AGENT && !off;
|
|
209
|
+
return (
|
|
210
|
+
<View key={name} style={styles.recordRow}>
|
|
211
|
+
<Text style={styles.recordKey}>{name}</Text>
|
|
212
|
+
<Switch
|
|
213
|
+
accessibilityLabel={`Agent ${name} is ${off ? "off" : "on"}`}
|
|
214
|
+
value={!off}
|
|
215
|
+
disabled={disabled || locked}
|
|
216
|
+
onValueChange={(on) =>
|
|
217
|
+
onSet(on ? switchedOff.filter((item) => item !== name) : [...switchedOff, name])
|
|
218
|
+
}
|
|
219
|
+
/>
|
|
220
|
+
{locked ? (
|
|
221
|
+
<Text style={styles.muted}>
|
|
222
|
+
The default agent stays on: without it every task call that names no agent fails.
|
|
223
|
+
</Text>
|
|
224
|
+
) : null}
|
|
225
|
+
</View>
|
|
226
|
+
);
|
|
227
|
+
})}
|
|
228
|
+
</View>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
131
232
|
function RecordRoutingEditor({
|
|
132
233
|
setting,
|
|
133
234
|
value,
|
|
@@ -136,10 +237,19 @@ function RecordRoutingEditor({
|
|
|
136
237
|
theme,
|
|
137
238
|
modelCatalog,
|
|
138
239
|
modelRoles,
|
|
240
|
+
agentCatalog,
|
|
139
241
|
onSet,
|
|
140
242
|
}: Pick<
|
|
141
243
|
StructuredRoutingEditorProps,
|
|
142
|
-
|
|
244
|
+
| "setting"
|
|
245
|
+
| "value"
|
|
246
|
+
| "disabled"
|
|
247
|
+
| "styles"
|
|
248
|
+
| "onSet"
|
|
249
|
+
| "theme"
|
|
250
|
+
| "modelCatalog"
|
|
251
|
+
| "modelRoles"
|
|
252
|
+
| "agentCatalog"
|
|
143
253
|
>) {
|
|
144
254
|
const record = asRecord(value);
|
|
145
255
|
const [keyErrors, setKeyErrors] = useState<Record<string, string>>({});
|
|
@@ -199,6 +309,15 @@ function RecordRoutingEditor({
|
|
|
199
309
|
{keyErrors[key]}
|
|
200
310
|
</Text>
|
|
201
311
|
) : null}
|
|
312
|
+
{setting.path.startsWith("task.") ? (
|
|
313
|
+
<AgentPicker
|
|
314
|
+
agents={agentCatalog.agents}
|
|
315
|
+
taken={Object.keys(record)}
|
|
316
|
+
disabled={disabled}
|
|
317
|
+
styles={styles}
|
|
318
|
+
onSelect={(name) => onSet(replaceRecordKey(record, key, name))}
|
|
319
|
+
/>
|
|
320
|
+
) : null}
|
|
202
321
|
<TextInput
|
|
203
322
|
accessibilityLabel={`${formatOmpSettingLabel(setting.path)} ${valueLabel} ${index + 1}`}
|
|
204
323
|
editable={!disabled}
|
|
@@ -287,6 +406,8 @@ export function StructuredRoutingEditor(props: StructuredRoutingEditorProps) {
|
|
|
287
406
|
<Text style={props.styles.muted}>{props.resetLabel} when changes are applied</Text>
|
|
288
407
|
) : props.setting.path === "cycleOrder" ? (
|
|
289
408
|
<OrderedRoleEditor {...props} />
|
|
409
|
+
) : props.setting.path === "task.disabledAgents" ? (
|
|
410
|
+
<DisabledAgentsEditor {...props} />
|
|
290
411
|
) : (
|
|
291
412
|
<RecordRoutingEditor {...props} />
|
|
292
413
|
)}
|
package/index.server.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from "./server/mcp-browser";
|
|
7
7
|
import { resolveListOmpMemory } from "./server/memory";
|
|
8
8
|
import { OmpAccounts } from "./server/omp-accounts";
|
|
9
|
+
import { resolveListOmpAgents } from "./server/omp-agents";
|
|
9
10
|
import { resolveListOmpConfig } from "./server/omp-config";
|
|
10
11
|
import { OmpMcps } from "./server/omp-mcps";
|
|
11
12
|
import { resolveListOmpModels } from "./server/omp-models";
|
|
@@ -62,6 +63,7 @@ import {
|
|
|
62
63
|
startOmpAccountLogin,
|
|
63
64
|
submitOmpAccountLoginCode,
|
|
64
65
|
} from "./shared/omp-accounts";
|
|
66
|
+
import { listOmpAgents } from "./shared/omp-agents";
|
|
65
67
|
import { listOmpConfig } from "./shared/omp-config";
|
|
66
68
|
import {
|
|
67
69
|
addOmpMcp,
|
|
@@ -201,6 +203,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
201
203
|
server.handle(listOmpMemory, scoped(resolveListOmpMemory));
|
|
202
204
|
server.handle(listOmpConfig, scoped(resolveListOmpConfig));
|
|
203
205
|
server.handle(listOmpModels, scoped(resolveListOmpModels));
|
|
206
|
+
server.handle(listOmpAgents, scoped(resolveListOmpAgents));
|
|
204
207
|
server.handle(listOmpPlugins, scoped(resolveListOmpPlugins));
|
|
205
208
|
server.handle(listOmpMarketplaces, scoped(resolveListOmpMarketplaces));
|
|
206
209
|
server.handle(browseOmpMarketplace, scoped(resolveBrowseOmpMarketplace));
|
package/package.json
CHANGED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { mkdtemp, readdir, readFile, rm, stat } from "node:fs/promises";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { isAbsolute, join, relative } from "node:path";
|
|
4
|
+
import type { RpcInput } from "@getpaseo/plugin";
|
|
5
|
+
import { parse as parseYaml } from "yaml";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { type listOmpAgents, OMP_AGENT_LIMIT, type OmpAgent } from "../shared/omp-agents";
|
|
8
|
+
import { OmpAgentNameSchema } from "../shared/omp-settings";
|
|
9
|
+
import { resolveOmpExecutable } from "./omp-settings";
|
|
10
|
+
import { currentOmpEnvironment, ompAgentDir } from "./paths";
|
|
11
|
+
import { buildStatefulCommandEnv, defaultSpawn, runBounded } from "./provider-diagnostics";
|
|
12
|
+
|
|
13
|
+
const UNPACK_TIMEOUT_MS = 15_000;
|
|
14
|
+
const KILL_GRACE_MS = 1_000;
|
|
15
|
+
const UNPACK_OUTPUT_LIMIT = 64 * 1024;
|
|
16
|
+
const AGENT_FILE_LIMIT = 256 * 1024;
|
|
17
|
+
const FRONTMATTER = /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---/u;
|
|
18
|
+
const BUNDLED_FAILURE = "Bundled agents could not be listed.";
|
|
19
|
+
|
|
20
|
+
/** Everything OMP would use to relocate its config, data, state, cache or agent directory. */
|
|
21
|
+
const OMP_LOCATION_ENV = [
|
|
22
|
+
"OMP_AGENT_DIR",
|
|
23
|
+
"OMP_PROFILE",
|
|
24
|
+
"OMP_SESSION_DIR",
|
|
25
|
+
"PASEO_OMP_AGENT_DIR",
|
|
26
|
+
"PI_CODING_AGENT_DIR",
|
|
27
|
+
"PI_CODING_AGENT_SESSION_DIR",
|
|
28
|
+
"PI_CONFIG_DIR",
|
|
29
|
+
"PI_PROFILE",
|
|
30
|
+
"XDG_CACHE_HOME",
|
|
31
|
+
"XDG_CONFIG_HOME",
|
|
32
|
+
"XDG_DATA_HOME",
|
|
33
|
+
"XDG_STATE_HOME",
|
|
34
|
+
] as const;
|
|
35
|
+
|
|
36
|
+
const UnpackResultSchema = z.object({ written: z.array(z.string()) });
|
|
37
|
+
|
|
38
|
+
export interface OmpAgentDependencies {
|
|
39
|
+
/** Names of the agents OMP ships with. Rejects when OMP cannot list them. */
|
|
40
|
+
bundledNames(): Promise<string[]>;
|
|
41
|
+
userAgentsDir(): string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Names OMP reserves for itself and never registers from an agent file. */
|
|
45
|
+
const RESERVED_AGENT_NAMES: readonly string[] = ["main", "sub"];
|
|
46
|
+
|
|
47
|
+
/** The name OMP registers for an agent file: its frontmatter `name`, which needs a `description`. */
|
|
48
|
+
async function agentNameFromFile(path: string): Promise<string | null> {
|
|
49
|
+
const metadata = await stat(path);
|
|
50
|
+
if (!metadata.isFile() || metadata.size > AGENT_FILE_LIMIT) return null;
|
|
51
|
+
const frontmatter = FRONTMATTER.exec(await readFile(path, "utf8"));
|
|
52
|
+
if (!frontmatter?.[1]) return null;
|
|
53
|
+
let fields: unknown;
|
|
54
|
+
try {
|
|
55
|
+
fields = parseYaml(frontmatter[1]);
|
|
56
|
+
} catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
if (fields === null || typeof fields !== "object") return null;
|
|
60
|
+
const { name, description } = fields as Record<string, unknown>;
|
|
61
|
+
if (typeof description !== "string" || description.length === 0) return null;
|
|
62
|
+
if (typeof name !== "string" || RESERVED_AGENT_NAMES.includes(name.trim().toLowerCase())) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
// OMP keeps the name as written; one with surrounding whitespace cannot be routed, so skip it.
|
|
66
|
+
const parsed = OmpAgentNameSchema.safeParse(name);
|
|
67
|
+
return parsed.success ? parsed.data : null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function agentNamesFrom(paths: readonly string[]): Promise<string[]> {
|
|
71
|
+
const names: string[] = [];
|
|
72
|
+
for (const path of paths.slice(0, OMP_AGENT_LIMIT)) {
|
|
73
|
+
if (!path.endsWith(".md")) continue;
|
|
74
|
+
const name = await agentNameFromFile(path).catch(() => null);
|
|
75
|
+
if (name) names.push(name);
|
|
76
|
+
}
|
|
77
|
+
return names;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function agentNamesIn(directory: string): Promise<string[]> {
|
|
81
|
+
try {
|
|
82
|
+
const entries = await readdir(directory, { withFileTypes: true });
|
|
83
|
+
return agentNamesFrom(
|
|
84
|
+
entries.filter((entry) => entry.isFile()).map((entry) => join(directory, entry.name)),
|
|
85
|
+
);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return [];
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** A scratch-only OMP environment: nothing inherited can point OMP at a real directory. */
|
|
93
|
+
export function scratchOmpEnvironment(base: NodeJS.ProcessEnv, scratch: string): NodeJS.ProcessEnv {
|
|
94
|
+
const environment = { ...base };
|
|
95
|
+
for (const key of OMP_LOCATION_ENV) delete environment[key];
|
|
96
|
+
return {
|
|
97
|
+
...environment,
|
|
98
|
+
HOME: scratch,
|
|
99
|
+
USERPROFILE: scratch,
|
|
100
|
+
PI_CODING_AGENT_DIR: join(scratch, "agent"),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* OMP has no agent list command, but `agents unpack` writes the bundled set to a folder. The
|
|
106
|
+
* folder and the whole OMP home are throwaway, so an OMP that ignores `--dir` still writes
|
|
107
|
+
* nothing into a real agent directory.
|
|
108
|
+
*/
|
|
109
|
+
async function unpackBundledNames(): Promise<string[]> {
|
|
110
|
+
const executable = await resolveOmpExecutable();
|
|
111
|
+
if (!executable) throw new Error("The OMP executable could not be resolved.");
|
|
112
|
+
const scratch = await mkdtemp(join(tmpdir(), "paseo-omp-agents-"));
|
|
113
|
+
try {
|
|
114
|
+
const result = await runBounded(
|
|
115
|
+
defaultSpawn,
|
|
116
|
+
executable,
|
|
117
|
+
["agents", "unpack", "--dir", join(scratch, "out"), "--json"],
|
|
118
|
+
scratchOmpEnvironment(buildStatefulCommandEnv(currentOmpEnvironment()), scratch),
|
|
119
|
+
UNPACK_TIMEOUT_MS,
|
|
120
|
+
KILL_GRACE_MS,
|
|
121
|
+
UNPACK_OUTPUT_LIMIT,
|
|
122
|
+
scratch,
|
|
123
|
+
);
|
|
124
|
+
if (result.outcome !== "exited" || result.exitCode !== 0 || result.truncated) {
|
|
125
|
+
throw new Error("OMP could not unpack its bundled agents.");
|
|
126
|
+
}
|
|
127
|
+
const { written } = UnpackResultSchema.parse(JSON.parse(result.stdout));
|
|
128
|
+
const inside = written.filter((path) => {
|
|
129
|
+
const within = relative(scratch, path);
|
|
130
|
+
return isAbsolute(path) && !within.startsWith("..") && !isAbsolute(within);
|
|
131
|
+
});
|
|
132
|
+
return await agentNamesFrom(inside);
|
|
133
|
+
} finally {
|
|
134
|
+
await rm(scratch, { recursive: true, force: true });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const DEFAULT_DEPENDENCIES: OmpAgentDependencies = {
|
|
139
|
+
bundledNames: unpackBundledNames,
|
|
140
|
+
userAgentsDir: () => join(ompAgentDir(), "agents"),
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export async function listOmpAgentsWithDependencies(
|
|
144
|
+
input: RpcInput<typeof listOmpAgents>,
|
|
145
|
+
dependencies: OmpAgentDependencies,
|
|
146
|
+
): Promise<{ agents: OmpAgent[]; error?: string }> {
|
|
147
|
+
// The most specific source wins when a name exists in several places.
|
|
148
|
+
const bySource = new Map<string, OmpAgent["source"]>();
|
|
149
|
+
let error: string | undefined;
|
|
150
|
+
try {
|
|
151
|
+
for (const name of await dependencies.bundledNames()) bySource.set(name, "bundled");
|
|
152
|
+
} catch {
|
|
153
|
+
error = BUNDLED_FAILURE;
|
|
154
|
+
}
|
|
155
|
+
for (const name of await agentNamesIn(dependencies.userAgentsDir())) bySource.set(name, "user");
|
|
156
|
+
if (input.cwd && isAbsolute(input.cwd)) {
|
|
157
|
+
for (const name of await agentNamesIn(join(input.cwd, ".omp", "agents"))) {
|
|
158
|
+
bySource.set(name, "project");
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const agents = [...bySource]
|
|
162
|
+
.map(([name, source]) => ({ name, source }))
|
|
163
|
+
.sort((left, right) => left.name.localeCompare(right.name))
|
|
164
|
+
.slice(0, OMP_AGENT_LIMIT);
|
|
165
|
+
return error ? { agents, error } : { agents };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function resolveListOmpAgents(input: RpcInput<typeof listOmpAgents>) {
|
|
169
|
+
return listOmpAgentsWithDependencies(input, DEFAULT_DEPENDENCIES);
|
|
170
|
+
}
|
package/server/omp-settings.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
type OmpSettingType,
|
|
14
14
|
OmpSettingTypeSchema,
|
|
15
15
|
parseOmpStructuredSettingValue,
|
|
16
|
+
structuredSettingType,
|
|
16
17
|
type updateOmpSettings,
|
|
17
18
|
} from "../shared/omp-settings";
|
|
18
19
|
import { SerialMutationQueue } from "./mutation-queue";
|
|
@@ -315,8 +316,7 @@ async function loadCatalog(
|
|
|
315
316
|
|
|
316
317
|
function serializeSettingValue(setting: OmpSetting, value: unknown): string | null {
|
|
317
318
|
if (isOmpStructuredSettingPath(setting.path)) {
|
|
318
|
-
|
|
319
|
-
if (setting.type !== expectedType) return null;
|
|
319
|
+
if (setting.type !== structuredSettingType(setting.path)) return null;
|
|
320
320
|
const parsed = parseOmpStructuredSettingValue(setting.path, value);
|
|
321
321
|
return parsed === undefined ? null : JSON.stringify(parsed);
|
|
322
322
|
}
|
|
@@ -332,7 +332,7 @@ function isEditableSetting(setting: OmpSetting): boolean {
|
|
|
332
332
|
if (setting.redacted) return false;
|
|
333
333
|
if (["boolean", "number", "string", "enum"].includes(setting.type)) return true;
|
|
334
334
|
if (!isOmpStructuredSettingPath(setting.path)) return false;
|
|
335
|
-
return setting.type === (setting.path
|
|
335
|
+
return setting.type === structuredSettingType(setting.path);
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
export async function listOmpSettingsWithDependencies(
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Release Please keeps this bundle-safe constant aligned with package.json. */
|
|
2
|
-
export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.
|
|
2
|
+
export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.404.1"; // x-release-please-version
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineRpc } from "@getpaseo/plugin";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { OmpWorkspaceCwdSchema } from "./hub";
|
|
4
|
+
import { OmpAgentNameSchema } from "./omp-settings";
|
|
5
|
+
import { OmpStoreSchema } from "./omp-store";
|
|
6
|
+
|
|
7
|
+
export const OMP_AGENT_LIMIT = 256;
|
|
8
|
+
|
|
9
|
+
export const OmpAgentSchema = z
|
|
10
|
+
.object({ name: OmpAgentNameSchema, source: z.enum(["bundled", "user", "project"]) })
|
|
11
|
+
.strict();
|
|
12
|
+
export type OmpAgent = z.infer<typeof OmpAgentSchema>;
|
|
13
|
+
|
|
14
|
+
export const listOmpAgents = defineRpc({
|
|
15
|
+
name: "paseo-omp.list-agents",
|
|
16
|
+
input: z
|
|
17
|
+
.object({ store: OmpStoreSchema.optional(), cwd: OmpWorkspaceCwdSchema.optional() })
|
|
18
|
+
.strict(),
|
|
19
|
+
output: z
|
|
20
|
+
.object({
|
|
21
|
+
agents: z.array(OmpAgentSchema).max(OMP_AGENT_LIMIT),
|
|
22
|
+
/** Set when the bundled agents could not be listed; user and project agents still appear. */
|
|
23
|
+
error: z.string().max(256).optional(),
|
|
24
|
+
})
|
|
25
|
+
.strict(),
|
|
26
|
+
});
|
package/shared/omp-settings.ts
CHANGED
|
@@ -67,7 +67,7 @@ export function isValidOmpModelSelector(value: string): boolean {
|
|
|
67
67
|
return OmpModelSelectorSchema.safeParse(value).success;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
const OmpAgentNameSchema = z
|
|
70
|
+
export const OmpAgentNameSchema = z
|
|
71
71
|
.string()
|
|
72
72
|
.min(1)
|
|
73
73
|
.max(128)
|
|
@@ -138,6 +138,11 @@ export const OmpAgentAdvisorSchema = z
|
|
|
138
138
|
"Too many agent advisor overrides.",
|
|
139
139
|
);
|
|
140
140
|
|
|
141
|
+
export const OmpDisabledAgentsSchema = z
|
|
142
|
+
.array(OmpAgentNameSchema)
|
|
143
|
+
.max(MAX_ROUTING_ENTRIES)
|
|
144
|
+
.refine((value) => new Set(value).size === value.length, "Disabled agents must be unique.");
|
|
145
|
+
|
|
141
146
|
export const OMP_STRUCTURED_SETTING_PATHS = [
|
|
142
147
|
"modelRoles",
|
|
143
148
|
"retry.fallbackChains",
|
|
@@ -146,6 +151,7 @@ export const OMP_STRUCTURED_SETTING_PATHS = [
|
|
|
146
151
|
"task.agentServiceTierOverrides",
|
|
147
152
|
"task.agentPrewalk",
|
|
148
153
|
"task.agentAdvisor",
|
|
154
|
+
"task.disabledAgents",
|
|
149
155
|
] as const;
|
|
150
156
|
export type OmpStructuredSettingPath = (typeof OMP_STRUCTURED_SETTING_PATHS)[number];
|
|
151
157
|
|
|
@@ -165,6 +171,8 @@ export function parseOmpStructuredSettingValue(path: string, value: unknown): un
|
|
|
165
171
|
return OmpAgentPrewalkSchema.safeParse(value).data;
|
|
166
172
|
case "task.agentAdvisor":
|
|
167
173
|
return OmpAgentAdvisorSchema.safeParse(value).data;
|
|
174
|
+
case "task.disabledAgents":
|
|
175
|
+
return OmpDisabledAgentsSchema.safeParse(value).data;
|
|
168
176
|
default:
|
|
169
177
|
return undefined;
|
|
170
178
|
}
|
|
@@ -174,6 +182,11 @@ export function isOmpStructuredSettingPath(path: string): path is OmpStructuredS
|
|
|
174
182
|
return (OMP_STRUCTURED_SETTING_PATHS as readonly string[]).includes(path);
|
|
175
183
|
}
|
|
176
184
|
|
|
185
|
+
/** The OMP value type each structured path must have to be editable. */
|
|
186
|
+
export function structuredSettingType(path: OmpStructuredSettingPath): "array" | "record" {
|
|
187
|
+
return path === "cycleOrder" || path === "task.disabledAgents" ? "array" : "record";
|
|
188
|
+
}
|
|
189
|
+
|
|
177
190
|
export const OmpSettingSchema = z
|
|
178
191
|
.object({
|
|
179
192
|
path: z.string(),
|
|
@@ -490,6 +503,13 @@ const OmpStructuredSettingChangeSchema = z.discriminatedUnion("path", [
|
|
|
490
503
|
value: OmpAgentAdvisorSchema,
|
|
491
504
|
})
|
|
492
505
|
.strict(),
|
|
506
|
+
z
|
|
507
|
+
.object({
|
|
508
|
+
operation: z.literal("set"),
|
|
509
|
+
path: z.literal("task.disabledAgents"),
|
|
510
|
+
value: OmpDisabledAgentsSchema,
|
|
511
|
+
})
|
|
512
|
+
.strict(),
|
|
493
513
|
]);
|
|
494
514
|
|
|
495
515
|
const OmpSettingChangeSchema = z.union([
|