@omercnet/paseo-omp 5.4.0 → 5.5.0-next.429.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/OVERVIEW.md +7 -1
- package/README.md +2 -1
- package/client/ast-edit.tsx +53 -0
- package/client/composer-pill-settings.tsx +0 -5
- package/client/config-sidebar.tsx +15 -0
- package/client/generated-image.tsx +79 -0
- package/client/lsp-diagnostics.tsx +69 -0
- package/client/omp-config-surface.tsx +438 -108
- package/client/omp-config-views.ts +32 -5
- package/client/omp-extensions-section.tsx +145 -0
- package/client/omp-local-models-section.tsx +215 -0
- package/client/omp-plugin-manager.tsx +198 -3
- package/client/omp-routing-editor.tsx +123 -2
- package/client/omp-rule-test.tsx +140 -0
- package/client/omp-rules-section.tsx +353 -0
- package/client/omp-security-section.tsx +99 -0
- package/client/omp-security-state.ts +14 -0
- package/client/omp-skills-section.tsx +195 -0
- package/client/omp-tool-config-section.tsx +204 -0
- package/client/omp-tool-policy-state.ts +101 -0
- package/client/omp-tool-policy.tsx +435 -0
- package/client/omp-update-row.tsx +87 -0
- package/client/provider-diagnostics-state.ts +38 -1
- package/client/provider-image.tsx +1 -1
- package/client/rule-notice.tsx +33 -0
- package/client/sidebar-compat.ts +0 -109
- package/client/web.ts +34 -0
- package/index.client.tsx +79 -46
- package/index.server.ts +77 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -4
- package/server/generated-images.ts +57 -0
- package/server/omp-agents.ts +170 -0
- package/server/omp-extensions.ts +235 -0
- package/server/omp-list-setting.ts +98 -0
- package/server/omp-local-models.ts +202 -0
- package/server/omp-models-file.ts +178 -0
- package/server/omp-plugins.ts +182 -0
- package/server/omp-prompt-files.ts +41 -0
- package/server/omp-rule-firings.ts +211 -0
- package/server/omp-rule-switch.ts +38 -0
- package/server/omp-rule-test.ts +82 -0
- package/server/omp-rules.ts +452 -0
- package/server/omp-security.ts +169 -0
- package/server/omp-settings.ts +92 -16
- package/server/omp-skills.ts +179 -0
- package/server/omp-tool-config.ts +144 -0
- package/server/omp-update.ts +203 -0
- package/server/package-version.ts +1 -1
- package/server/provider/connection.ts +1 -1
- package/server/provider/image-cache.ts +1 -1
- package/server/provider/omp-rpc-environment.ts +1 -1
- package/server/provider/session-descriptors.ts +3 -0
- package/server/provider-diagnostics.ts +26 -4
- package/server/regular-file.ts +30 -0
- package/server/rule-notices.ts +112 -0
- package/server/turn-rows.ts +59 -0
- package/server/turn-screenshots.ts +140 -0
- package/shared/ast-edit.ts +124 -0
- package/shared/composer-pill-settings.ts +0 -2
- package/shared/generated-image.ts +68 -0
- package/shared/lsp-diagnostics.ts +141 -0
- package/shared/omp-agents.ts +26 -0
- package/shared/omp-extensions.ts +45 -0
- package/shared/omp-local-models.ts +44 -0
- package/shared/omp-models-file.ts +30 -0
- package/shared/omp-plugins.ts +90 -0
- package/shared/omp-prompt-files.ts +24 -0
- package/shared/omp-rules.ts +134 -0
- package/shared/omp-security.ts +50 -0
- package/shared/omp-settings.ts +211 -2
- package/shared/omp-skills.ts +80 -0
- package/shared/omp-tool-config.ts +283 -0
- package/shared/omp-update.ts +27 -0
- package/shared/provider-image.ts +10 -3
- package/shared/rule-notices.ts +20 -0
- package/client/hub-sidebar.tsx +0 -99
- package/client/sessions-popover.tsx +0 -78
- package/server/sessions.ts +0 -58
- package/shared/sessions.ts +0 -24
|
@@ -1,30 +1,38 @@
|
|
|
1
1
|
import { type PluginSurfaceProps, useRpc } from "@getpaseo/plugin/client";
|
|
2
2
|
import { TextInput } from "@getpaseo/plugin/client/ui";
|
|
3
|
-
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { skipToken, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
4
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import type { TextStyle, ViewStyle } from "react-native";
|
|
6
6
|
import { Pressable, Switch, Text, View } from "react-native";
|
|
7
7
|
import {
|
|
8
|
+
browseOmpMarketplace,
|
|
8
9
|
inspectOmpPluginConfig,
|
|
10
|
+
listOmpMarketplaces,
|
|
9
11
|
listOmpPlugins,
|
|
12
|
+
mutateOmpMarketplace,
|
|
10
13
|
mutateOmpPlugin,
|
|
11
14
|
mutateOmpPluginConfig,
|
|
12
15
|
type OmpInstalledPlugin,
|
|
16
|
+
type OmpMarketplaceMutation,
|
|
13
17
|
type OmpPluginConfigMutation,
|
|
14
18
|
OmpPluginConfigMutationSchema,
|
|
15
19
|
type OmpPluginConfigSetting,
|
|
16
20
|
type OmpPluginConfigState,
|
|
17
21
|
OmpPluginInstallSourceSchema,
|
|
18
22
|
type OmpPluginMutation,
|
|
23
|
+
redactSourceCredentials,
|
|
19
24
|
} from "../shared/omp-plugins";
|
|
20
25
|
|
|
21
26
|
import type { OmpStore } from "../shared/omp-store";
|
|
22
27
|
import { ompStoreKey } from "./omp-store-state";
|
|
23
28
|
|
|
24
29
|
const PLUGINS_QUERY_KEY = ["paseo-omp", "plugins"] as const;
|
|
30
|
+
const MARKETPLACES_QUERY_KEY = ["paseo-omp", "marketplaces"] as const;
|
|
31
|
+
const CATALOG_ROW_LIMIT = 50;
|
|
25
32
|
|
|
26
33
|
type ConfirmationOrigin =
|
|
27
34
|
| { surface: "install" }
|
|
35
|
+
| { surface: "catalog" }
|
|
28
36
|
| { surface: "plugin"; key: string }
|
|
29
37
|
| { surface: "config"; key: string };
|
|
30
38
|
|
|
@@ -42,6 +50,13 @@ type PendingConfirmation =
|
|
|
42
50
|
origin: ConfirmationOrigin;
|
|
43
51
|
title: string;
|
|
44
52
|
warning: string;
|
|
53
|
+
}
|
|
54
|
+
| {
|
|
55
|
+
kind: "marketplace";
|
|
56
|
+
input: OmpMarketplaceMutation;
|
|
57
|
+
origin: ConfirmationOrigin;
|
|
58
|
+
title: string;
|
|
59
|
+
warning: string;
|
|
45
60
|
};
|
|
46
61
|
|
|
47
62
|
type PluginManagerStyles = {
|
|
@@ -264,7 +279,7 @@ function ConfirmationPanel({
|
|
|
264
279
|
label={busy ? "Applying…" : confirmLabel}
|
|
265
280
|
disabled={busy}
|
|
266
281
|
primary
|
|
267
|
-
danger={action === "uninstall" || action === "delete"}
|
|
282
|
+
danger={action === "uninstall" || action === "delete" || action === "remove"}
|
|
268
283
|
styles={styles}
|
|
269
284
|
onPress={onConfirm}
|
|
270
285
|
/>
|
|
@@ -688,6 +703,43 @@ export function OmpPluginManagerSection({
|
|
|
688
703
|
const [inspected, setInspected] = useState<OmpPluginConfigState | null>(null);
|
|
689
704
|
const [configEditGenerations, setConfigEditGenerations] = useState<Record<string, number>>({});
|
|
690
705
|
const inspectionGeneration = useRef(0);
|
|
706
|
+
const loadMarketplaces = useRpc(listOmpMarketplaces);
|
|
707
|
+
const browseMarketplace = useRpc(browseOmpMarketplace);
|
|
708
|
+
const mutateMarketplace = useRpc(mutateOmpMarketplace);
|
|
709
|
+
const [catalogSource, setCatalogSource] = useState("");
|
|
710
|
+
const [browsing, setBrowsing] = useState<string | null>(null);
|
|
711
|
+
const marketplaces = useQuery({
|
|
712
|
+
queryKey: [...MARKETPLACES_QUERY_KEY, ompStoreKey(store)],
|
|
713
|
+
queryFn: () => loadMarketplaces({ store }),
|
|
714
|
+
staleTime: Number.POSITIVE_INFINITY,
|
|
715
|
+
});
|
|
716
|
+
const catalog = useQuery({
|
|
717
|
+
queryKey: [...MARKETPLACES_QUERY_KEY, "catalog", ompStoreKey(store), browsing],
|
|
718
|
+
queryFn:
|
|
719
|
+
browsing === null ? skipToken : () => browseMarketplace({ store, marketplace: browsing }),
|
|
720
|
+
staleTime: Number.POSITIVE_INFINITY,
|
|
721
|
+
});
|
|
722
|
+
const marketplaceMutation = useMutation({
|
|
723
|
+
mutationKey: ["paseo-omp", "marketplace", ompStoreKey(store)],
|
|
724
|
+
mutationFn: (input: OmpMarketplaceMutation) => mutateMarketplace({ ...input, store }),
|
|
725
|
+
onSuccess: (result, input) => {
|
|
726
|
+
queryClient.setQueryData([...MARKETPLACES_QUERY_KEY, ompStoreKey(store)], result.state);
|
|
727
|
+
void queryClient.invalidateQueries({
|
|
728
|
+
queryKey: [...MARKETPLACES_QUERY_KEY, "catalog", ompStoreKey(store)],
|
|
729
|
+
refetchType: "none",
|
|
730
|
+
});
|
|
731
|
+
setNotice({ tone: result.ok ? "success" : "error", text: result.message });
|
|
732
|
+
if (result.ok && input.action === "add") setCatalogSource("");
|
|
733
|
+
if (result.ok && input.action === "remove" && input.marketplace === browsing) {
|
|
734
|
+
setBrowsing(null);
|
|
735
|
+
}
|
|
736
|
+
setConfirmation(null);
|
|
737
|
+
},
|
|
738
|
+
onError: () => {
|
|
739
|
+
setNotice({ tone: "error", text: "The marketplace operation could not be completed." });
|
|
740
|
+
setConfirmation(null);
|
|
741
|
+
},
|
|
742
|
+
});
|
|
691
743
|
const plugins = useQuery({
|
|
692
744
|
queryKey: [...PLUGINS_QUERY_KEY, ompStoreKey(store), cwd ?? "global"],
|
|
693
745
|
queryFn: () => loadPlugins(context),
|
|
@@ -744,7 +796,7 @@ export function OmpPluginManagerSection({
|
|
|
744
796
|
setConfirmation(null);
|
|
745
797
|
},
|
|
746
798
|
});
|
|
747
|
-
const busy = mutation.isPending || configMutation.isPending;
|
|
799
|
+
const busy = mutation.isPending || configMutation.isPending || marketplaceMutation.isPending;
|
|
748
800
|
useEffect(() => {
|
|
749
801
|
if (!confirmation) return;
|
|
750
802
|
const { origin } = confirmation;
|
|
@@ -816,9 +868,39 @@ export function OmpPluginManagerSection({
|
|
|
816
868
|
setConfirmation(null);
|
|
817
869
|
configInspection.mutate({ plugin, generation });
|
|
818
870
|
};
|
|
871
|
+
const requestCatalogAdd = () => {
|
|
872
|
+
const parsed = OmpPluginInstallSourceSchema.safeParse(catalogSource);
|
|
873
|
+
if (!parsed.success) {
|
|
874
|
+
setNotice({
|
|
875
|
+
tone: "error",
|
|
876
|
+
text: "Enter one valid Git source, URL, or local path without options or control characters.",
|
|
877
|
+
});
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
setNotice(null);
|
|
881
|
+
setConfirmation({
|
|
882
|
+
kind: "marketplace",
|
|
883
|
+
input: { action: "add", source: parsed.data, store },
|
|
884
|
+
origin: { surface: "catalog" },
|
|
885
|
+
title: `Add marketplace ${redactSourceCredentials(parsed.data)}?`,
|
|
886
|
+
warning:
|
|
887
|
+
"Plugins from a marketplace are trusted code. Adding it fetches the catalog on the daemon host, and any plugin you install from it can run code with that host's access.",
|
|
888
|
+
});
|
|
889
|
+
};
|
|
890
|
+
const requestCatalogRemove = (name: string) => {
|
|
891
|
+
setNotice(null);
|
|
892
|
+
setConfirmation({
|
|
893
|
+
kind: "marketplace",
|
|
894
|
+
input: { action: "remove", marketplace: name, store },
|
|
895
|
+
origin: { surface: "catalog" },
|
|
896
|
+
title: `Remove marketplace ${name}?`,
|
|
897
|
+
warning: "Removes the catalog and its cached copy. Installed plugins are not uninstalled.",
|
|
898
|
+
});
|
|
899
|
+
};
|
|
819
900
|
const applyConfirmation = () => {
|
|
820
901
|
if (!confirmation) return;
|
|
821
902
|
if (confirmation.kind === "plugin") mutation.mutate(confirmation.input);
|
|
903
|
+
else if (confirmation.kind === "marketplace") marketplaceMutation.mutate(confirmation.input);
|
|
822
904
|
else configMutation.mutate(confirmation.input);
|
|
823
905
|
};
|
|
824
906
|
|
|
@@ -835,6 +917,7 @@ export function OmpPluginManagerSection({
|
|
|
835
917
|
styles={styles}
|
|
836
918
|
onPress={() => {
|
|
837
919
|
void plugins.refetch();
|
|
920
|
+
void queryClient.invalidateQueries({ queryKey: MARKETPLACES_QUERY_KEY });
|
|
838
921
|
}}
|
|
839
922
|
/>
|
|
840
923
|
</View>
|
|
@@ -877,6 +960,118 @@ export function OmpPluginManagerSection({
|
|
|
877
960
|
)}
|
|
878
961
|
</View>
|
|
879
962
|
|
|
963
|
+
<View style={styles.card}>
|
|
964
|
+
<Text style={styles.cardTitle}>Marketplaces</Text>
|
|
965
|
+
<Text style={styles.muted}>
|
|
966
|
+
Catalogs of installable OMP plugins. Browse one to fill the install box above.
|
|
967
|
+
</Text>
|
|
968
|
+
{marketplaces.isLoading ? <Text style={styles.muted}>Loading marketplaces…</Text> : null}
|
|
969
|
+
{marketplaces.error || marketplaces.data?.error ? (
|
|
970
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
971
|
+
{marketplaces.data?.error ?? "Could not load OMP marketplaces."}
|
|
972
|
+
</Text>
|
|
973
|
+
) : null}
|
|
974
|
+
{marketplaces.data?.available && marketplaces.data.marketplaces.length === 0 ? (
|
|
975
|
+
<Text style={styles.muted}>No marketplaces configured.</Text>
|
|
976
|
+
) : null}
|
|
977
|
+
{marketplaces.data?.marketplaces.map((marketplace) => (
|
|
978
|
+
<View key={marketplace.name} style={styles.setting}>
|
|
979
|
+
<View style={styles.cardHeader}>
|
|
980
|
+
<View style={{ flexShrink: 1 }}>
|
|
981
|
+
<Text style={styles.settingName}>{marketplace.name}</Text>
|
|
982
|
+
<Text selectable style={styles.settingDescription}>
|
|
983
|
+
{marketplace.source}
|
|
984
|
+
</Text>
|
|
985
|
+
</View>
|
|
986
|
+
<View style={styles.actions}>
|
|
987
|
+
<ActionButton
|
|
988
|
+
label={browsing === marketplace.name ? "Hide" : "Browse"}
|
|
989
|
+
disabled={busy || confirmation !== null}
|
|
990
|
+
styles={styles}
|
|
991
|
+
onPress={() =>
|
|
992
|
+
setBrowsing(browsing === marketplace.name ? null : marketplace.name)
|
|
993
|
+
}
|
|
994
|
+
/>
|
|
995
|
+
<ActionButton
|
|
996
|
+
label="Remove"
|
|
997
|
+
disabled={busy || confirmation !== null}
|
|
998
|
+
danger
|
|
999
|
+
styles={styles}
|
|
1000
|
+
onPress={() => requestCatalogRemove(marketplace.name)}
|
|
1001
|
+
/>
|
|
1002
|
+
</View>
|
|
1003
|
+
</View>
|
|
1004
|
+
{browsing === marketplace.name ? (
|
|
1005
|
+
<View style={styles.settings}>
|
|
1006
|
+
{catalog.isFetching ? <Text style={styles.muted}>Loading catalog…</Text> : null}
|
|
1007
|
+
{catalog.error || catalog.data?.error ? (
|
|
1008
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
1009
|
+
{catalog.data?.error ?? "Could not load this catalog."}
|
|
1010
|
+
</Text>
|
|
1011
|
+
) : null}
|
|
1012
|
+
{catalog.data?.available && catalog.data.plugins.length === 0 ? (
|
|
1013
|
+
<Text style={styles.muted}>This catalog lists no plugins.</Text>
|
|
1014
|
+
) : null}
|
|
1015
|
+
{catalog.data?.plugins.slice(0, CATALOG_ROW_LIMIT).map((plugin) => (
|
|
1016
|
+
<View key={plugin.id} style={styles.cardHeader}>
|
|
1017
|
+
<View style={{ flexShrink: 1 }}>
|
|
1018
|
+
<Text style={styles.settingName}>
|
|
1019
|
+
{plugin.id}
|
|
1020
|
+
{plugin.version ? ` · ${plugin.version}` : ""}
|
|
1021
|
+
</Text>
|
|
1022
|
+
{plugin.description ? (
|
|
1023
|
+
<Text style={styles.settingDescription}>{plugin.description}</Text>
|
|
1024
|
+
) : null}
|
|
1025
|
+
</View>
|
|
1026
|
+
<ActionButton
|
|
1027
|
+
label="Use"
|
|
1028
|
+
disabled={busy || confirmation !== null}
|
|
1029
|
+
styles={styles}
|
|
1030
|
+
onPress={() => setSource(plugin.id)}
|
|
1031
|
+
/>
|
|
1032
|
+
</View>
|
|
1033
|
+
))}
|
|
1034
|
+
{catalog.data && catalog.data.plugins.length > CATALOG_ROW_LIMIT ? (
|
|
1035
|
+
<Text style={styles.muted}>
|
|
1036
|
+
Showing {CATALOG_ROW_LIMIT} of {catalog.data.plugins.length} plugins.
|
|
1037
|
+
</Text>
|
|
1038
|
+
) : null}
|
|
1039
|
+
</View>
|
|
1040
|
+
) : null}
|
|
1041
|
+
</View>
|
|
1042
|
+
))}
|
|
1043
|
+
<TextInput
|
|
1044
|
+
accessibilityLabel="OMP marketplace source"
|
|
1045
|
+
editable={!busy && confirmation === null}
|
|
1046
|
+
value={catalogSource}
|
|
1047
|
+
onChangeText={setCatalogSource}
|
|
1048
|
+
placeholder="owner/repo, Git URL, or local path"
|
|
1049
|
+
placeholderTextColor={theme.colors.foregroundMuted}
|
|
1050
|
+
autoCapitalize="none"
|
|
1051
|
+
autoCorrect={false}
|
|
1052
|
+
style={styles.input}
|
|
1053
|
+
/>
|
|
1054
|
+
{confirmation?.origin.surface === "catalog" ? (
|
|
1055
|
+
<ConfirmationPanel
|
|
1056
|
+
confirmation={confirmation}
|
|
1057
|
+
busy={busy}
|
|
1058
|
+
styles={styles}
|
|
1059
|
+
onCancel={() => setConfirmation(null)}
|
|
1060
|
+
onConfirm={applyConfirmation}
|
|
1061
|
+
/>
|
|
1062
|
+
) : (
|
|
1063
|
+
<View style={styles.actions}>
|
|
1064
|
+
<ActionButton
|
|
1065
|
+
label="Review add"
|
|
1066
|
+
disabled={busy || confirmation !== null || catalogSource.length === 0}
|
|
1067
|
+
primary
|
|
1068
|
+
styles={styles}
|
|
1069
|
+
onPress={requestCatalogAdd}
|
|
1070
|
+
/>
|
|
1071
|
+
</View>
|
|
1072
|
+
)}
|
|
1073
|
+
</View>
|
|
1074
|
+
|
|
880
1075
|
{notice ? (
|
|
881
1076
|
<Text
|
|
882
1077
|
accessibilityRole="alert"
|
|
@@ -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
|
)}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { type PluginSurfaceProps, useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import { TextInput } from "@getpaseo/plugin/client/ui";
|
|
3
|
+
import { useMutation } from "@tanstack/react-query";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Text, View } from "react-native";
|
|
6
|
+
import {
|
|
7
|
+
MAX_RULE_TEST_CHARS,
|
|
8
|
+
type OmpRuleTestSource,
|
|
9
|
+
OmpRuleTestSourceSchema,
|
|
10
|
+
testOmpRules,
|
|
11
|
+
} from "../shared/omp-rules";
|
|
12
|
+
import type { OmpStore } from "../shared/omp-store";
|
|
13
|
+
import { describe } from "./omp-accounts-section";
|
|
14
|
+
import type { OmpConfigStyles } from "./omp-config-styles";
|
|
15
|
+
import { Choice } from "./omp-tool-config-section";
|
|
16
|
+
|
|
17
|
+
type Theme = PluginSurfaceProps["theme"];
|
|
18
|
+
|
|
19
|
+
const SOURCES = OmpRuleTestSourceSchema.options;
|
|
20
|
+
|
|
21
|
+
export function OmpRuleTest({
|
|
22
|
+
theme,
|
|
23
|
+
styles,
|
|
24
|
+
cwd,
|
|
25
|
+
store,
|
|
26
|
+
}: {
|
|
27
|
+
theme: Theme;
|
|
28
|
+
styles: OmpConfigStyles;
|
|
29
|
+
cwd?: string;
|
|
30
|
+
store?: OmpStore;
|
|
31
|
+
}) {
|
|
32
|
+
const test = useRpc(testOmpRules);
|
|
33
|
+
const [snippet, setSnippet] = useState("");
|
|
34
|
+
const [path, setPath] = useState("");
|
|
35
|
+
const [source, setSource] = useState<OmpRuleTestSource | null>(null);
|
|
36
|
+
const run = useMutation({
|
|
37
|
+
mutationFn: () =>
|
|
38
|
+
test({
|
|
39
|
+
store,
|
|
40
|
+
...(cwd ? { cwd } : {}),
|
|
41
|
+
snippet,
|
|
42
|
+
...(path.trim() ? { path: path.trim() } : {}),
|
|
43
|
+
...(source ? { source } : {}),
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
const result = run.data;
|
|
47
|
+
return (
|
|
48
|
+
<View style={styles.card}>
|
|
49
|
+
<View style={styles.cardHeader}>
|
|
50
|
+
<Text style={styles.cardTitle}>Test a snippet</Text>
|
|
51
|
+
</View>
|
|
52
|
+
<View style={styles.setting}>
|
|
53
|
+
<Text style={styles.settingDescription}>
|
|
54
|
+
Paste text to see which rules would fire on it, in this {cwd ? "workspace" : "user"}{" "}
|
|
55
|
+
scope. Nothing is sent to a model.
|
|
56
|
+
</Text>
|
|
57
|
+
<TextInput
|
|
58
|
+
accessibilityLabel="Snippet to test"
|
|
59
|
+
multiline
|
|
60
|
+
maxLength={MAX_RULE_TEST_CHARS}
|
|
61
|
+
placeholder="Text the agent might write"
|
|
62
|
+
placeholderTextColor={theme.colors.foregroundMuted}
|
|
63
|
+
value={snippet}
|
|
64
|
+
onChangeText={setSnippet}
|
|
65
|
+
style={[styles.scalarInput, { minHeight: 120, maxWidth: undefined }]}
|
|
66
|
+
/>
|
|
67
|
+
<TextInput
|
|
68
|
+
accessibilityLabel="File path of the snippet"
|
|
69
|
+
autoCapitalize="none"
|
|
70
|
+
autoCorrect={false}
|
|
71
|
+
placeholder="File path, optional (src/app.ts)"
|
|
72
|
+
placeholderTextColor={theme.colors.foregroundMuted}
|
|
73
|
+
value={path}
|
|
74
|
+
onChangeText={setPath}
|
|
75
|
+
style={[styles.scalarInput, { maxWidth: undefined }]}
|
|
76
|
+
/>
|
|
77
|
+
<View style={styles.editorActions}>
|
|
78
|
+
<Choice styles={styles} label="Auto" selected={!source} onPress={() => setSource(null)} />
|
|
79
|
+
{SOURCES.map((option) => (
|
|
80
|
+
<Choice
|
|
81
|
+
key={option}
|
|
82
|
+
styles={styles}
|
|
83
|
+
label={option}
|
|
84
|
+
selected={source === option}
|
|
85
|
+
onPress={() => setSource(option)}
|
|
86
|
+
/>
|
|
87
|
+
))}
|
|
88
|
+
</View>
|
|
89
|
+
<View style={styles.editorActions}>
|
|
90
|
+
<Choice
|
|
91
|
+
styles={styles}
|
|
92
|
+
label={run.isPending ? "Testing..." : "Test"}
|
|
93
|
+
selected
|
|
94
|
+
disabled={snippet.trim() === "" || run.isPending}
|
|
95
|
+
onPress={() => run.mutate()}
|
|
96
|
+
/>
|
|
97
|
+
</View>
|
|
98
|
+
{run.error ? (
|
|
99
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
100
|
+
{describe(run.error)}
|
|
101
|
+
</Text>
|
|
102
|
+
) : null}
|
|
103
|
+
{result?.status === "error" ? (
|
|
104
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
105
|
+
{result.message}
|
|
106
|
+
</Text>
|
|
107
|
+
) : null}
|
|
108
|
+
{result?.status === "ready" ? (
|
|
109
|
+
<>
|
|
110
|
+
<Text style={styles.muted}>
|
|
111
|
+
{result.triggered.length === 0
|
|
112
|
+
? `No rule fired, out of ${result.evaluated} checked`
|
|
113
|
+
: `${result.triggered.length} of ${result.evaluated} rules fired`}
|
|
114
|
+
</Text>
|
|
115
|
+
{result.triggered.map((hit) => (
|
|
116
|
+
<View key={hit.name} style={styles.setting}>
|
|
117
|
+
<Text selectable style={styles.settingValue}>
|
|
118
|
+
{hit.name}
|
|
119
|
+
</Text>
|
|
120
|
+
{hit.regex.length > 0 ? (
|
|
121
|
+
<Text selectable style={styles.settingDescription}>
|
|
122
|
+
Text matched: {hit.regex.join(", ")}
|
|
123
|
+
</Text>
|
|
124
|
+
) : null}
|
|
125
|
+
{hit.ast.length > 0 ? (
|
|
126
|
+
<Text selectable style={styles.settingDescription}>
|
|
127
|
+
Code matched: {hit.ast.join(", ")}
|
|
128
|
+
</Text>
|
|
129
|
+
) : null}
|
|
130
|
+
<Text selectable style={styles.settingPath}>
|
|
131
|
+
{hit.path}
|
|
132
|
+
</Text>
|
|
133
|
+
</View>
|
|
134
|
+
))}
|
|
135
|
+
</>
|
|
136
|
+
) : null}
|
|
137
|
+
</View>
|
|
138
|
+
</View>
|
|
139
|
+
);
|
|
140
|
+
}
|