@omercnet/paseo-omp 5.4.0-next.409.1 → 5.4.0-next.412.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 +193 -83
- package/client/omp-config-views.ts +7 -3
- package/client/omp-security-section.tsx +99 -0
- package/client/omp-security-state.ts +14 -0
- package/client/omp-tool-policy-state.ts +101 -0
- package/client/omp-tool-policy.tsx +435 -0
- package/index.server.ts +10 -0
- package/package.json +1 -1
- package/server/omp-models-file.ts +178 -0
- package/server/omp-security.ts +169 -0
- package/server/omp-settings.ts +68 -4
- package/server/package-version.ts +1 -1
- package/server/provider/omp-rpc-environment.ts +1 -1
- package/server/provider-diagnostics.ts +16 -2
- package/shared/omp-models-file.ts +30 -0
- package/shared/omp-security.ts +50 -0
- package/shared/omp-settings.ts +99 -4
|
@@ -14,11 +14,13 @@ import type { ComposerPillSettings } from "../shared/composer-pill-settings";
|
|
|
14
14
|
import { listOmpAgents } from "../shared/omp-agents";
|
|
15
15
|
import { listOmpConfig, type OmpConfig } from "../shared/omp-config";
|
|
16
16
|
import { listOmpModels } from "../shared/omp-models";
|
|
17
|
+
import { getOmpModelsFileStatus, refreshOmpModels } from "../shared/omp-models-file";
|
|
17
18
|
import { getOmpPromptFiles } from "../shared/omp-prompt-files";
|
|
18
19
|
import {
|
|
19
20
|
categorizeOmpSetting,
|
|
20
21
|
formatOmpSettingLabel,
|
|
21
22
|
isOmpStructuredSettingPath,
|
|
23
|
+
isOmpToolPolicyPath,
|
|
22
24
|
listOmpSettings,
|
|
23
25
|
OMP_SETTING_CATEGORIES,
|
|
24
26
|
type OmpSetting,
|
|
@@ -34,7 +36,7 @@ import { getOmpProviderHealth, type OmpProviderHealth } from "../shared/provider
|
|
|
34
36
|
import { getOmpSupportReport, OMP_SUPPORT_ISSUE_URL } from "../shared/support-diagnostics";
|
|
35
37
|
import { ComposerPillSettingsSection } from "./composer-pill-settings";
|
|
36
38
|
import { openOmpExternalUrl } from "./external-url";
|
|
37
|
-
import { OmpAccountsSection } from "./omp-accounts-section";
|
|
39
|
+
import { ActionButton, OmpAccountsSection } from "./omp-accounts-section";
|
|
38
40
|
import { type OmpConfigStyles, useConfigStyles } from "./omp-config-styles";
|
|
39
41
|
import { type OmpConfigSurfaceView as SurfaceView, surfaceViewsForScope } from "./omp-config-views";
|
|
40
42
|
import {
|
|
@@ -54,9 +56,12 @@ import {
|
|
|
54
56
|
StructuredRoutingEditor,
|
|
55
57
|
} from "./omp-routing-editor";
|
|
56
58
|
import { OmpRulesSection } from "./omp-rules-section";
|
|
59
|
+
import { OmpSecuritySection } from "./omp-security-section";
|
|
60
|
+
import { SECURITY_QUERY_KEY } from "./omp-security-state";
|
|
57
61
|
import { OmpSkillsSection } from "./omp-skills-section";
|
|
58
62
|
import { OmpStorePicker } from "./omp-store-picker";
|
|
59
63
|
import { ompStoreKey } from "./omp-store-state";
|
|
64
|
+
import { ToolPolicyCard } from "./omp-tool-policy";
|
|
60
65
|
import { OmpUpdateRow, UPDATE_QUERY_KEY } from "./omp-update-row";
|
|
61
66
|
import {
|
|
62
67
|
type BinaryHealthSummary,
|
|
@@ -89,6 +94,7 @@ const SETTINGS_QUERY_KEY = ["paseo-omp", "settings"] as const;
|
|
|
89
94
|
const CONFIG_POLL_MS = 30_000;
|
|
90
95
|
const HEALTH_QUERY_KEY = ["paseo-omp", "provider-health"] as const;
|
|
91
96
|
const PROMPT_FILES_QUERY_KEY = ["paseo-omp", "prompt-files"] as const;
|
|
97
|
+
const MODELS_FILE_QUERY_KEY = ["paseo-omp", "models-file"] as const;
|
|
92
98
|
const PROVIDERS_QUERY_KEY = ["paseo-omp", "provider-snapshot"] as const;
|
|
93
99
|
|
|
94
100
|
function KeyValueRow({
|
|
@@ -416,6 +422,72 @@ function PromptFilesSection({
|
|
|
416
422
|
);
|
|
417
423
|
}
|
|
418
424
|
|
|
425
|
+
function ModelsSection({
|
|
426
|
+
theme,
|
|
427
|
+
styles,
|
|
428
|
+
store,
|
|
429
|
+
onRefreshed,
|
|
430
|
+
}: {
|
|
431
|
+
theme: PluginSurfaceProps["theme"];
|
|
432
|
+
styles: OmpConfigStyles;
|
|
433
|
+
store?: OmpStore;
|
|
434
|
+
onRefreshed(): void;
|
|
435
|
+
}) {
|
|
436
|
+
const loadStatus = useRpc(getOmpModelsFileStatus);
|
|
437
|
+
const refreshModels = useRpc(refreshOmpModels);
|
|
438
|
+
const status = useQuery({
|
|
439
|
+
queryKey: [...MODELS_FILE_QUERY_KEY, ompStoreKey(store)],
|
|
440
|
+
queryFn: () => loadStatus({ store }),
|
|
441
|
+
});
|
|
442
|
+
const [message, setMessage] = useState<{ ok: boolean; text: string } | null>(null);
|
|
443
|
+
const refresh = useMutation({
|
|
444
|
+
mutationFn: () => refreshModels({ store }),
|
|
445
|
+
onSuccess: (result) => {
|
|
446
|
+
setMessage({
|
|
447
|
+
ok: result.ok,
|
|
448
|
+
text: result.ok
|
|
449
|
+
? "OMP refreshed its model lists. Paseo's list updates next."
|
|
450
|
+
: result.message,
|
|
451
|
+
});
|
|
452
|
+
if (result.ok) onRefreshed();
|
|
453
|
+
},
|
|
454
|
+
onError: () => setMessage({ ok: false, text: "Could not refresh models. Try again." }),
|
|
455
|
+
});
|
|
456
|
+
const current = status.data;
|
|
457
|
+
return (
|
|
458
|
+
<SectionCard styles={styles} title="Models">
|
|
459
|
+
{status.isLoading ? <Text style={styles.muted}>Checking models.yml…</Text> : null}
|
|
460
|
+
{current?.state === "ok" ? (
|
|
461
|
+
<KeyValueRow styles={styles} label="models.yml" value="No errors reported" />
|
|
462
|
+
) : null}
|
|
463
|
+
{current?.state === "invalid" ? (
|
|
464
|
+
<KeyValueRow
|
|
465
|
+
styles={styles}
|
|
466
|
+
label="models.yml"
|
|
467
|
+
value={`OMP dropped your custom providers: ${current.detail}`}
|
|
468
|
+
valueColor={theme.colors.statusDanger}
|
|
469
|
+
/>
|
|
470
|
+
) : null}
|
|
471
|
+
{current?.state === "unknown" || status.error ? (
|
|
472
|
+
<KeyValueRow styles={styles} label="models.yml" value="Could not check" />
|
|
473
|
+
) : null}
|
|
474
|
+
<View style={styles.row}>
|
|
475
|
+
<Text style={styles.rowLabel}>Model lists</Text>
|
|
476
|
+
<ActionButton
|
|
477
|
+
styles={styles}
|
|
478
|
+
theme={theme}
|
|
479
|
+
label={refresh.isPending ? "Refreshing models…" : "Refresh models"}
|
|
480
|
+
disabled={refresh.isPending}
|
|
481
|
+
onPress={() => refresh.mutate()}
|
|
482
|
+
/>
|
|
483
|
+
</View>
|
|
484
|
+
{message ? (
|
|
485
|
+
<Text style={message.ok ? styles.muted : styles.error}>{message.text}</Text>
|
|
486
|
+
) : null}
|
|
487
|
+
</SectionCard>
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
|
|
419
491
|
function ProviderHealthSection({
|
|
420
492
|
theme,
|
|
421
493
|
styles,
|
|
@@ -459,6 +531,7 @@ function ProviderHealthSection({
|
|
|
459
531
|
]);
|
|
460
532
|
if (update) queryClient.setQueryData(UPDATE_QUERY_KEY, update);
|
|
461
533
|
await queryClient.invalidateQueries({ queryKey: PROMPT_FILES_QUERY_KEY });
|
|
534
|
+
await queryClient.invalidateQueries({ queryKey: MODELS_FILE_QUERY_KEY });
|
|
462
535
|
if (result.failed) throw new Error("Could not fully refresh OMP provider health.");
|
|
463
536
|
},
|
|
464
537
|
});
|
|
@@ -515,6 +588,15 @@ function ProviderHealthSection({
|
|
|
515
588
|
{health.data ? <StorageSection theme={theme} styles={styles} health={health.data} /> : null}
|
|
516
589
|
{health.data ? <ProcessSection theme={theme} styles={styles} health={health.data} /> : null}
|
|
517
590
|
<PromptFilesSection theme={theme} styles={styles} cwd={cwd} store={store} />
|
|
591
|
+
<ModelsSection
|
|
592
|
+
theme={theme}
|
|
593
|
+
styles={styles}
|
|
594
|
+
store={store}
|
|
595
|
+
onRefreshed={() => {
|
|
596
|
+
void queryClient.invalidateQueries({ queryKey: ["paseo-omp", "models"] });
|
|
597
|
+
refresh.mutate();
|
|
598
|
+
}}
|
|
599
|
+
/>
|
|
518
600
|
|
|
519
601
|
{providers.isLoading ? <Text style={styles.muted}>Loading provider status…</Text> : null}
|
|
520
602
|
{providers.error ? (
|
|
@@ -859,6 +941,7 @@ function ConfigurationCategory({
|
|
|
859
941
|
category,
|
|
860
942
|
styles,
|
|
861
943
|
settings,
|
|
944
|
+
policySettings: allPolicySettings,
|
|
862
945
|
drafts,
|
|
863
946
|
theme,
|
|
864
947
|
modelCatalog,
|
|
@@ -876,6 +959,8 @@ function ConfigurationCategory({
|
|
|
876
959
|
modelRoles: Readonly<Record<string, unknown>>;
|
|
877
960
|
agentCatalog: OmpAgentCatalogState;
|
|
878
961
|
settings: readonly OmpSetting[];
|
|
962
|
+
/** Every stored tool policy setting, so warnings do not depend on the search text. */
|
|
963
|
+
policySettings: readonly OmpSetting[];
|
|
879
964
|
drafts: Readonly<Record<string, SettingDraft>>;
|
|
880
965
|
disabled: boolean;
|
|
881
966
|
workspaceScoped: boolean;
|
|
@@ -883,92 +968,110 @@ function ConfigurationCategory({
|
|
|
883
968
|
onOpenDocumentation(link: OmpDocumentationLink): void;
|
|
884
969
|
}) {
|
|
885
970
|
const categoryDocumentation = documentationForSettingCategory(category.id);
|
|
971
|
+
const visiblePolicySettings =
|
|
972
|
+
category.id === "tools" ? settings.filter((setting) => isOmpToolPolicyPath(setting.path)) : [];
|
|
973
|
+
const listed = settings.filter((setting) => !visiblePolicySettings.includes(setting));
|
|
886
974
|
return (
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
975
|
+
<>
|
|
976
|
+
{visiblePolicySettings.length > 0 ? (
|
|
977
|
+
<ToolPolicyCard
|
|
978
|
+
settings={allPolicySettings}
|
|
979
|
+
visiblePaths={visiblePolicySettings.map((setting) => setting.path)}
|
|
980
|
+
drafts={drafts}
|
|
981
|
+
disabled={disabled}
|
|
982
|
+
workspaceScoped={workspaceScoped}
|
|
983
|
+
resetLabel={workspaceScoped ? "Remove workspace override" : "Reset to default"}
|
|
984
|
+
styles={styles}
|
|
985
|
+
onSet={(path, value) => onDraft(path, { operation: "set", value })}
|
|
986
|
+
onReset={(path) => onDraft(path, { operation: "reset" })}
|
|
987
|
+
/>
|
|
988
|
+
) : null}
|
|
989
|
+
<SectionCard
|
|
990
|
+
styles={styles}
|
|
991
|
+
title={`${category.label} · ${listed.length}`}
|
|
992
|
+
action={
|
|
993
|
+
categoryDocumentation ? (
|
|
994
|
+
<DocumentationLink
|
|
995
|
+
link={categoryDocumentation}
|
|
996
|
+
styles={styles}
|
|
997
|
+
onOpen={onOpenDocumentation}
|
|
998
|
+
/>
|
|
999
|
+
) : undefined
|
|
1000
|
+
}
|
|
1001
|
+
>
|
|
1002
|
+
{listed.map((setting) => {
|
|
1003
|
+
const complex =
|
|
1004
|
+
Array.isArray(setting.value) ||
|
|
1005
|
+
(setting.value !== null && typeof setting.value === "object");
|
|
1006
|
+
const editable =
|
|
1007
|
+
!setting.redacted && ["boolean", "number", "string", "enum"].includes(setting.type);
|
|
1008
|
+
const structuredEditable =
|
|
1009
|
+
!setting.redacted &&
|
|
1010
|
+
isOmpStructuredSettingPath(setting.path) &&
|
|
1011
|
+
setting.type === structuredSettingType(setting.path);
|
|
1012
|
+
const settingDocumentation = documentationForSettingPath(setting.path);
|
|
1013
|
+
const draft = drafts[setting.path];
|
|
1014
|
+
return (
|
|
1015
|
+
<View key={setting.path} style={styles.setting}>
|
|
1016
|
+
<View style={styles.settingHeader}>
|
|
1017
|
+
<Text style={styles.cardTitle}>{formatOmpSettingLabel(setting.path)}</Text>
|
|
1018
|
+
{setting.workspaceOverride ? (
|
|
1019
|
+
<Text style={styles.source}>Workspace override</Text>
|
|
1020
|
+
) : null}
|
|
1021
|
+
{!complex && !editable && !structuredEditable ? (
|
|
1022
|
+
<StructuredSettingValue setting={setting} styles={styles} />
|
|
1023
|
+
) : null}
|
|
1024
|
+
</View>
|
|
1025
|
+
<Text selectable style={styles.settingPath}>
|
|
1026
|
+
{setting.path} · {setting.type}
|
|
1027
|
+
</Text>
|
|
1028
|
+
{settingDocumentation ? (
|
|
1029
|
+
<View style={styles.docsActions}>
|
|
1030
|
+
<DocumentationLink
|
|
1031
|
+
link={settingDocumentation}
|
|
1032
|
+
styles={styles}
|
|
1033
|
+
onOpen={onOpenDocumentation}
|
|
1034
|
+
/>
|
|
1035
|
+
</View>
|
|
918
1036
|
) : null}
|
|
919
|
-
{
|
|
1037
|
+
{editable ? (
|
|
1038
|
+
<EditableScalarValue
|
|
1039
|
+
setting={setting}
|
|
1040
|
+
draft={draft}
|
|
1041
|
+
disabled={disabled}
|
|
1042
|
+
resetLabel={workspaceScoped ? "Remove workspace override" : "Reset to default"}
|
|
1043
|
+
showReset={!workspaceScoped || setting.workspaceOverride === true}
|
|
1044
|
+
styles={styles}
|
|
1045
|
+
onSet={(value) => onDraft(setting.path, { operation: "set", value })}
|
|
1046
|
+
onReset={() => onDraft(setting.path, { operation: "reset" })}
|
|
1047
|
+
/>
|
|
1048
|
+
) : structuredEditable ? (
|
|
1049
|
+
<StructuredRoutingEditor
|
|
1050
|
+
setting={setting}
|
|
1051
|
+
value={draft?.operation === "set" ? draft.value : setting.value}
|
|
1052
|
+
disabled={disabled}
|
|
1053
|
+
resetLabel={workspaceScoped ? "Remove workspace override" : "Reset to default"}
|
|
1054
|
+
showReset={!workspaceScoped || setting.workspaceOverride === true}
|
|
1055
|
+
resetPending={draft?.operation === "reset"}
|
|
1056
|
+
styles={styles}
|
|
1057
|
+
theme={theme}
|
|
1058
|
+
modelCatalog={modelCatalog}
|
|
1059
|
+
modelRoles={modelRoles}
|
|
1060
|
+
agentCatalog={agentCatalog}
|
|
1061
|
+
onSet={(value) => onDraft(setting.path, { operation: "set", value })}
|
|
1062
|
+
onReset={() => onDraft(setting.path, { operation: "reset" })}
|
|
1063
|
+
/>
|
|
1064
|
+
) : complex ? (
|
|
920
1065
|
<StructuredSettingValue setting={setting} styles={styles} />
|
|
921
1066
|
) : null}
|
|
1067
|
+
{setting.description ? (
|
|
1068
|
+
<Text style={styles.settingDescription}>{setting.description}</Text>
|
|
1069
|
+
) : null}
|
|
922
1070
|
</View>
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
<View style={styles.docsActions}>
|
|
928
|
-
<DocumentationLink
|
|
929
|
-
link={settingDocumentation}
|
|
930
|
-
styles={styles}
|
|
931
|
-
onOpen={onOpenDocumentation}
|
|
932
|
-
/>
|
|
933
|
-
</View>
|
|
934
|
-
) : null}
|
|
935
|
-
{editable ? (
|
|
936
|
-
<EditableScalarValue
|
|
937
|
-
setting={setting}
|
|
938
|
-
draft={draft}
|
|
939
|
-
disabled={disabled}
|
|
940
|
-
resetLabel={workspaceScoped ? "Remove workspace override" : "Reset to default"}
|
|
941
|
-
showReset={!workspaceScoped || setting.workspaceOverride === true}
|
|
942
|
-
styles={styles}
|
|
943
|
-
onSet={(value) => onDraft(setting.path, { operation: "set", value })}
|
|
944
|
-
onReset={() => onDraft(setting.path, { operation: "reset" })}
|
|
945
|
-
/>
|
|
946
|
-
) : structuredEditable ? (
|
|
947
|
-
<StructuredRoutingEditor
|
|
948
|
-
setting={setting}
|
|
949
|
-
value={draft?.operation === "set" ? draft.value : setting.value}
|
|
950
|
-
disabled={disabled}
|
|
951
|
-
resetLabel={workspaceScoped ? "Remove workspace override" : "Reset to default"}
|
|
952
|
-
showReset={!workspaceScoped || setting.workspaceOverride === true}
|
|
953
|
-
resetPending={draft?.operation === "reset"}
|
|
954
|
-
styles={styles}
|
|
955
|
-
theme={theme}
|
|
956
|
-
modelCatalog={modelCatalog}
|
|
957
|
-
modelRoles={modelRoles}
|
|
958
|
-
agentCatalog={agentCatalog}
|
|
959
|
-
onSet={(value) => onDraft(setting.path, { operation: "set", value })}
|
|
960
|
-
onReset={() => onDraft(setting.path, { operation: "reset" })}
|
|
961
|
-
/>
|
|
962
|
-
) : complex ? (
|
|
963
|
-
<StructuredSettingValue setting={setting} styles={styles} />
|
|
964
|
-
) : null}
|
|
965
|
-
{setting.description ? (
|
|
966
|
-
<Text style={styles.settingDescription}>{setting.description}</Text>
|
|
967
|
-
) : null}
|
|
968
|
-
</View>
|
|
969
|
-
);
|
|
970
|
-
})}
|
|
971
|
-
</SectionCard>
|
|
1071
|
+
);
|
|
1072
|
+
})}
|
|
1073
|
+
</SectionCard>
|
|
1074
|
+
</>
|
|
972
1075
|
);
|
|
973
1076
|
}
|
|
974
1077
|
|
|
@@ -1130,7 +1233,7 @@ function OmpConfigContent({
|
|
|
1130
1233
|
let value: unknown = draft.value;
|
|
1131
1234
|
if (isOmpStructuredSettingPath(path)) {
|
|
1132
1235
|
const parsed = parseOmpStructuredSettingValue(path, value);
|
|
1133
|
-
if (parsed === undefined) throw new Error(`${path} contains invalid
|
|
1236
|
+
if (parsed === undefined) throw new Error(`${path} contains invalid values.`);
|
|
1134
1237
|
value = parsed;
|
|
1135
1238
|
} else if (setting.type === "number") {
|
|
1136
1239
|
const raw = String(draft.value).trim();
|
|
@@ -1148,6 +1251,7 @@ function OmpConfigContent({
|
|
|
1148
1251
|
queryClient.setQueryData(settingsQueryKey, result.catalog);
|
|
1149
1252
|
void queryClient.invalidateQueries({ queryKey: SETTINGS_QUERY_KEY });
|
|
1150
1253
|
void queryClient.invalidateQueries({ queryKey: ["paseo-omp", "config"] });
|
|
1254
|
+
void queryClient.invalidateQueries({ queryKey: SECURITY_QUERY_KEY });
|
|
1151
1255
|
if (
|
|
1152
1256
|
!result.conflict &&
|
|
1153
1257
|
!result.failed &&
|
|
@@ -1272,6 +1376,9 @@ function OmpConfigContent({
|
|
|
1272
1376
|
{view === "extensions" ? (
|
|
1273
1377
|
<OmpExtensionsSection theme={theme} styles={styles} cwd={cwd} store={store} />
|
|
1274
1378
|
) : null}
|
|
1379
|
+
{view === "security" && cwd ? (
|
|
1380
|
+
<OmpSecuritySection styles={styles} cwd={cwd} store={store} />
|
|
1381
|
+
) : null}
|
|
1275
1382
|
{view === "composer" && !cwd && onComposerPillSettingsChange ? (
|
|
1276
1383
|
<ComposerPillSettingsSection theme={theme} onChange={onComposerPillSettingsChange} />
|
|
1277
1384
|
) : null}
|
|
@@ -1457,6 +1564,9 @@ function OmpConfigContent({
|
|
|
1457
1564
|
agentCatalog={agentCatalog}
|
|
1458
1565
|
styles={styles}
|
|
1459
1566
|
settings={catalog.byCategory.get(selectedCategory.id) ?? []}
|
|
1567
|
+
policySettings={catalog.sourceSettings.filter((setting) =>
|
|
1568
|
+
isOmpToolPolicyPath(setting.path),
|
|
1569
|
+
)}
|
|
1460
1570
|
drafts={drafts}
|
|
1461
1571
|
disabled={!settingsQuery.data?.revision || save.isPending}
|
|
1462
1572
|
workspaceScoped={cwd !== undefined}
|
|
@@ -7,6 +7,7 @@ export type OmpConfigSurfaceView =
|
|
|
7
7
|
| "rules"
|
|
8
8
|
| "skills"
|
|
9
9
|
| "extensions"
|
|
10
|
+
| "security"
|
|
10
11
|
| "composer"
|
|
11
12
|
| "configuration"
|
|
12
13
|
| "diagnostics"
|
|
@@ -21,6 +22,7 @@ const SURFACE_VIEWS: readonly { id: OmpConfigSurfaceView; label: string }[] = [
|
|
|
21
22
|
{ id: "rules", label: "Rules" },
|
|
22
23
|
{ id: "skills", label: "Skills" },
|
|
23
24
|
{ id: "extensions", label: "Extensions" },
|
|
25
|
+
{ id: "security", label: "Security" },
|
|
24
26
|
{ id: "composer", label: "Composer" },
|
|
25
27
|
{ id: "configuration", label: "Configuration" },
|
|
26
28
|
{ id: "diagnostics", label: "Diagnostics" },
|
|
@@ -30,8 +32,10 @@ const SURFACE_VIEWS: readonly { id: OmpConfigSurfaceView; label: string }[] = [
|
|
|
30
32
|
/** Views that belong to the OMP store, not to a workspace's project settings. */
|
|
31
33
|
const STORE_ONLY_VIEWS: readonly OmpConfigSurfaceView[] = ["composer", "accounts", "mcps"];
|
|
32
34
|
|
|
35
|
+
/** Views about one project, which the global OMP screen has no project for. */
|
|
36
|
+
const WORKSPACE_ONLY_VIEWS: readonly OmpConfigSurfaceView[] = ["security"];
|
|
37
|
+
|
|
33
38
|
export function surfaceViewsForScope(workspaceScoped: boolean) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
: SURFACE_VIEWS;
|
|
39
|
+
const hidden = workspaceScoped ? STORE_ONLY_VIEWS : WORKSPACE_ONLY_VIEWS;
|
|
40
|
+
return SURFACE_VIEWS.filter((candidate) => !hidden.includes(candidate.id));
|
|
37
41
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import {
|
|
3
|
+
SettingsAction,
|
|
4
|
+
SettingsCard,
|
|
5
|
+
SettingsRow,
|
|
6
|
+
SettingsSection,
|
|
7
|
+
} from "@getpaseo/plugin/client/ui";
|
|
8
|
+
import { useQuery } from "@tanstack/react-query";
|
|
9
|
+
import { Text, View } from "react-native";
|
|
10
|
+
import { listOmpSecurity, type OmpSecurityScan } from "../shared/omp-security";
|
|
11
|
+
import type { OmpStore } from "../shared/omp-store";
|
|
12
|
+
import type { OmpConfigStyles } from "./omp-config-styles";
|
|
13
|
+
import { SECURITY_QUERY_KEY, severityText } from "./omp-security-state";
|
|
14
|
+
import { ompStoreKey } from "./omp-store-state";
|
|
15
|
+
|
|
16
|
+
const INFO =
|
|
17
|
+
"Scans the agent ran with OMP's security_scan tool for this project, read through omp itself. Only each scan's phase and finding counts are shown: findings are private, so titles, locations and reports stay in OMP. Starting, cancelling or validating a scan happens inside an agent session; ask the agent. Opening this tab makes OMP create an empty store entry for the project.";
|
|
18
|
+
|
|
19
|
+
/** A refetch runs up to 22 omp processes, so it is manual or at most once a minute. */
|
|
20
|
+
const STALE_MS = 60_000;
|
|
21
|
+
|
|
22
|
+
function rowLabel(scan: OmpSecurityScan): string {
|
|
23
|
+
const noun = scan.findingCount === 1 ? "finding" : "findings";
|
|
24
|
+
return `${scan.phase} · ${scan.findingCount} ${noun}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function OmpSecuritySection({
|
|
28
|
+
styles,
|
|
29
|
+
cwd,
|
|
30
|
+
store,
|
|
31
|
+
}: {
|
|
32
|
+
styles: OmpConfigStyles;
|
|
33
|
+
cwd: string;
|
|
34
|
+
store?: OmpStore;
|
|
35
|
+
}) {
|
|
36
|
+
const load = useRpc(listOmpSecurity);
|
|
37
|
+
const security = useQuery({
|
|
38
|
+
queryKey: [...SECURITY_QUERY_KEY, ompStoreKey(store), cwd],
|
|
39
|
+
queryFn: () => load({ store, cwd }),
|
|
40
|
+
staleTime: STALE_MS,
|
|
41
|
+
refetchOnWindowFocus: false,
|
|
42
|
+
});
|
|
43
|
+
const list = security.data;
|
|
44
|
+
return (
|
|
45
|
+
<View style={{ gap: 12 }}>
|
|
46
|
+
<SettingsSection title="Security scans" info={INFO}>
|
|
47
|
+
<SettingsCard>
|
|
48
|
+
<SettingsAction
|
|
49
|
+
label="Refresh list"
|
|
50
|
+
hint="Read the scans from omp again"
|
|
51
|
+
actionLabel={security.isFetching ? "Refreshing..." : "Refresh"}
|
|
52
|
+
disabled={security.isFetching}
|
|
53
|
+
onPress={() => void security.refetch()}
|
|
54
|
+
/>
|
|
55
|
+
</SettingsCard>
|
|
56
|
+
</SettingsSection>
|
|
57
|
+
{security.isLoading ? <Text style={styles.muted}>Loading security scans...</Text> : null}
|
|
58
|
+
{security.error ? (
|
|
59
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
60
|
+
Could not read OMP's security scans.
|
|
61
|
+
</Text>
|
|
62
|
+
) : null}
|
|
63
|
+
{list?.status === "error" ? (
|
|
64
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
65
|
+
{list.message}
|
|
66
|
+
</Text>
|
|
67
|
+
) : null}
|
|
68
|
+
{list?.status === "off" ? (
|
|
69
|
+
<Text style={styles.muted}>
|
|
70
|
+
Security scans are off. Turn on security.enabled in the Configuration tab to use them.
|
|
71
|
+
</Text>
|
|
72
|
+
) : null}
|
|
73
|
+
{list?.status === "ready" && list.scans.length === 0 ? (
|
|
74
|
+
<Text style={styles.muted}>No scans are stored for this project</Text>
|
|
75
|
+
) : null}
|
|
76
|
+
{list?.status === "ready" && list.skipped > 0 ? (
|
|
77
|
+
<Text style={styles.muted}>
|
|
78
|
+
{`${list.skipped} ${list.skipped === 1 ? "entry" : "entries"} in OMP's scan list could not be read`}
|
|
79
|
+
</Text>
|
|
80
|
+
) : null}
|
|
81
|
+
{list?.status === "ready" && list.scans.length > 0 ? (
|
|
82
|
+
<SettingsSection title="Scans">
|
|
83
|
+
<SettingsCard>
|
|
84
|
+
{list.scans.map((scan) => (
|
|
85
|
+
<SettingsRow
|
|
86
|
+
key={scan.id}
|
|
87
|
+
label={rowLabel(scan)}
|
|
88
|
+
hint={`${severityText(scan)} · ${scan.producer} · ${scan.createdAt}`}
|
|
89
|
+
/>
|
|
90
|
+
))}
|
|
91
|
+
</SettingsCard>
|
|
92
|
+
{list.truncated ? (
|
|
93
|
+
<Text style={styles.muted}>Only the first scans OMP lists are shown</Text>
|
|
94
|
+
) : null}
|
|
95
|
+
</SettingsSection>
|
|
96
|
+
) : null}
|
|
97
|
+
</View>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OMP_SECURITY_SEVERITIES, type OmpSecurityScan } from "../shared/omp-security";
|
|
2
|
+
|
|
3
|
+
/** The security tab's query key prefix, invalidated when a setting such as security.enabled is saved. */
|
|
4
|
+
export const SECURITY_QUERY_KEY = ["paseo-omp", "security"] as const;
|
|
5
|
+
|
|
6
|
+
/** The per-severity counts of one scan, worded for both a cut-short list and a failed read. */
|
|
7
|
+
export function severityText(scan: OmpSecurityScan): string {
|
|
8
|
+
if (scan.findingCount === 0) return "No findings";
|
|
9
|
+
const listed = OMP_SECURITY_SEVERITIES.flatMap((level) =>
|
|
10
|
+
scan.severities[level] ? [`${scan.severities[level]} ${level}`] : [],
|
|
11
|
+
).join(", ");
|
|
12
|
+
if (scan.severitiesComplete) return listed;
|
|
13
|
+
return listed === "" ? "Severity counts unavailable" : `${listed} (counts may be incomplete)`;
|
|
14
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type OmpBashRule,
|
|
3
|
+
OmpBashRuleSchema,
|
|
4
|
+
OmpBashRulesSchema,
|
|
5
|
+
OmpRestrictedFoldersSchema,
|
|
6
|
+
type OmpToolApproval,
|
|
7
|
+
OmpToolApprovalSchema,
|
|
8
|
+
OmpToolPoliciesSchema,
|
|
9
|
+
} from "../shared/omp-settings";
|
|
10
|
+
|
|
11
|
+
export type ToolPolicies = Record<string, OmpToolApproval>;
|
|
12
|
+
|
|
13
|
+
export interface ToolPolicyState {
|
|
14
|
+
policies: ToolPolicies;
|
|
15
|
+
rules: OmpBashRule[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* OMP does not validate these values when it stores them. Keep only entries Apply would accept,
|
|
20
|
+
* so one stored bad entry cannot make every later save fail.
|
|
21
|
+
*/
|
|
22
|
+
export function readToolPolicies(value: unknown): ToolPolicies {
|
|
23
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
|
|
24
|
+
const policies: ToolPolicies = {};
|
|
25
|
+
for (const [tool, approval] of Object.entries(value)) {
|
|
26
|
+
const parsed = OmpToolPoliciesSchema.safeParse({ [tool]: approval });
|
|
27
|
+
if (parsed.success) Object.assign(policies, parsed.data);
|
|
28
|
+
}
|
|
29
|
+
return policies;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function readBashRules(value: unknown): OmpBashRule[] {
|
|
33
|
+
if (!Array.isArray(value)) return [];
|
|
34
|
+
return value.flatMap((entry): OmpBashRule[] => {
|
|
35
|
+
if (entry === null || typeof entry !== "object") return [];
|
|
36
|
+
const { match, approval } = entry as { match?: unknown; approval?: unknown };
|
|
37
|
+
const parsed = OmpBashRuleSchema.safeParse({ match, approval });
|
|
38
|
+
return parsed.success ? [parsed.data] : [];
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A rule being edited can be momentarily invalid, for example an emptied pattern, and must stay on screen. */
|
|
43
|
+
export function readBashRuleDraft(value: unknown): OmpBashRule[] {
|
|
44
|
+
if (!Array.isArray(value)) return [];
|
|
45
|
+
return value.flatMap((entry): OmpBashRule[] => {
|
|
46
|
+
if (entry === null || typeof entry !== "object") return [];
|
|
47
|
+
const { match, approval } = entry as { match?: unknown; approval?: unknown };
|
|
48
|
+
const parsed = OmpToolApprovalSchema.safeParse(approval);
|
|
49
|
+
return typeof match === "string" && parsed.success ? [{ match, approval: parsed.data }] : [];
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function readFolders(value: unknown): string[] {
|
|
54
|
+
if (!Array.isArray(value)) return [];
|
|
55
|
+
const folders = value.filter((item) => OmpRestrictedFoldersSchema.safeParse([item]).success);
|
|
56
|
+
return [...new Set(folders as string[])];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Rules are first match wins, so moving a rule changes which one applies. */
|
|
60
|
+
export function moveRule<T>(rules: readonly T[], index: number, offset: -1 | 1): T[] {
|
|
61
|
+
const target = index + offset;
|
|
62
|
+
if (target < 0 || target >= rules.length) return [...rules];
|
|
63
|
+
const next = [...rules];
|
|
64
|
+
const [moved] = next.splice(index, 1);
|
|
65
|
+
if (moved === undefined) return next;
|
|
66
|
+
next.splice(target, 0, moved);
|
|
67
|
+
return next;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Effects of the saved policy that a user would not guess from the approval mode picker. */
|
|
71
|
+
export function policyWarnings({ policies, rules }: ToolPolicyState): string[] {
|
|
72
|
+
const warnings: string[] = [];
|
|
73
|
+
if (policies.bash === "allow") {
|
|
74
|
+
warnings.push(
|
|
75
|
+
"Bash is set to Allow, so it runs without asking in every mode, including Always Ask.",
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
if (rules.some((rule) => rule.approval === "allow")) {
|
|
79
|
+
warnings.push("Commands matching an Allow rule run without asking, even in Always Ask.");
|
|
80
|
+
}
|
|
81
|
+
const asks =
|
|
82
|
+
Object.values(policies).includes("prompt") || rules.some((rule) => rule.approval === "prompt");
|
|
83
|
+
if (asks) {
|
|
84
|
+
warnings.push(
|
|
85
|
+
"Subagents cannot answer prompts, so a call that matches an Ask rule fails there.",
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return warnings;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Add is offered only when the whole resulting list would pass the schema Apply uses. */
|
|
92
|
+
export function canAddToolRule(policies: ToolPolicies, tool: string): boolean {
|
|
93
|
+
return (
|
|
94
|
+
!Object.hasOwn(policies, tool) &&
|
|
95
|
+
OmpToolPoliciesSchema.safeParse({ ...policies, [tool]: "prompt" }).success
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function canAddBashRule(rules: readonly OmpBashRule[], match: string): boolean {
|
|
100
|
+
return OmpBashRulesSchema.safeParse([...rules, { match, approval: "prompt" }]).success;
|
|
101
|
+
}
|