@omercnet/paseo-omp 5.4.0-next.400.1 → 5.4.0-next.401.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.
@@ -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"
package/index.server.ts CHANGED
@@ -10,8 +10,11 @@ import { resolveListOmpConfig } from "./server/omp-config";
10
10
  import { OmpMcps } from "./server/omp-mcps";
11
11
  import { resolveListOmpModels } from "./server/omp-models";
12
12
  import {
13
+ resolveBrowseOmpMarketplace,
13
14
  resolveInspectOmpPluginConfig,
15
+ resolveListOmpMarketplaces,
14
16
  resolveListOmpPlugins,
17
+ resolveMutateOmpMarketplace,
15
18
  resolveMutateOmpPlugin,
16
19
  resolveMutateOmpPluginConfig,
17
20
  } from "./server/omp-plugins";
@@ -69,8 +72,11 @@ import {
69
72
  } from "./shared/omp-mcps";
70
73
  import { listOmpModels } from "./shared/omp-models";
71
74
  import {
75
+ browseOmpMarketplace,
72
76
  inspectOmpPluginConfig,
77
+ listOmpMarketplaces,
73
78
  listOmpPlugins,
79
+ mutateOmpMarketplace,
74
80
  mutateOmpPlugin,
75
81
  mutateOmpPluginConfig,
76
82
  } from "./shared/omp-plugins";
@@ -194,6 +200,9 @@ export default function contribute(server: PluginServerContext) {
194
200
  server.handle(listOmpConfig, scoped(resolveListOmpConfig));
195
201
  server.handle(listOmpModels, scoped(resolveListOmpModels));
196
202
  server.handle(listOmpPlugins, scoped(resolveListOmpPlugins));
203
+ server.handle(listOmpMarketplaces, scoped(resolveListOmpMarketplaces));
204
+ server.handle(browseOmpMarketplace, scoped(resolveBrowseOmpMarketplace));
205
+ server.handle(mutateOmpMarketplace, scoped(resolveMutateOmpMarketplace));
197
206
  server.handle(listOmpRules, scoped(resolveListOmpRules));
198
207
  server.handle(listOmpSkills, scoped(resolveListOmpSkills));
199
208
  server.handle(setOmpSkillEnabled, scoped(resolveSetOmpSkillEnabled));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-omp",
3
- "version": "5.4.0-next.400.1",
3
+ "version": "5.4.0-next.401.1",
4
4
  "type": "module",
5
5
  "description": "Paseo integration for OMP, including its direct provider and workspace tooling.",
6
6
  "license": "MIT",
@@ -3,20 +3,28 @@ import { delimiter, isAbsolute, join } from "node:path";
3
3
  import type { RpcInput } from "@getpaseo/plugin";
4
4
  import { z } from "zod";
5
5
  import {
6
+ type browseOmpMarketplace,
6
7
  type inspectOmpPluginConfig,
8
+ type listOmpMarketplaces,
7
9
  type listOmpPlugins,
10
+ type mutateOmpMarketplace,
8
11
  type mutateOmpPlugin,
9
12
  type mutateOmpPluginConfig,
13
+ OMP_CATALOG_PLUGIN_LIMIT,
10
14
  OMP_PLUGIN_LIMIT,
15
+ type OmpCatalogState,
11
16
  type OmpInstalledPlugin,
12
17
  OmpInstalledPluginSchema,
18
+ OmpMarketplaceNameSchema,
13
19
  OmpMarketplacePluginIdSchema,
20
+ type OmpMarketplaceState,
14
21
  type OmpPluginConfigMutation,
15
22
  type OmpPluginConfigSetting,
16
23
  type OmpPluginConfigState,
17
24
  type OmpPluginMutation,
18
25
  OmpPluginNameSchema,
19
26
  type OmpPluginState,
27
+ redactSourceCredentials,
20
28
  } from "../shared/omp-plugins";
21
29
  import { SerialMutationQueue } from "./mutation-queue";
22
30
  import { currentOmpEnvironment } from "./paths";
@@ -674,3 +682,177 @@ export function resolveMutateOmpPlugin(
674
682
  mutateOmpPluginWithDependencies(input, DEFAULT_DEPENDENCIES),
675
683
  );
676
684
  }
685
+
686
+ // OMP prints marketplace listings as text only (`--json` is ignored), so parse the stable
687
+ // "name source" and "name[@version]" / indented description shapes and reject anything else.
688
+
689
+ export function parseOmpMarketplaceList(stdout: string): OmpMarketplaceState["marketplaces"] {
690
+ const lines = stdout.split(/\r?\n/u);
691
+ if (!lines.some((line) => line.startsWith("Configured Marketplaces:"))) {
692
+ if (lines.some((line) => line.startsWith("No marketplaces configured"))) return [];
693
+ throw new Error("OMP returned an invalid marketplace list");
694
+ }
695
+ const marketplaces: OmpMarketplaceState["marketplaces"] = [];
696
+ for (const line of lines) {
697
+ const match = /^ {2}(\S+) {2}(\S.*)$/u.exec(line);
698
+ if (!match?.[1] || !match[2]) continue;
699
+ const name = OmpMarketplaceNameSchema.safeParse(match[1]);
700
+ const source = boundedText(redactSourceCredentials(match[2].trim()), 4_096);
701
+ if (name.success && source) marketplaces.push({ name: name.data, source });
702
+ if (marketplaces.length === OMP_PLUGIN_LIMIT) break;
703
+ }
704
+ return marketplaces;
705
+ }
706
+
707
+ export function parseOmpCatalog(stdout: string, marketplace: string): OmpCatalogState["plugins"] {
708
+ const lines = stdout.split(/\r?\n/u);
709
+ if (!lines.some((line) => line.startsWith("Available Plugins"))) {
710
+ if (lines.some((line) => line.startsWith("No plugins found"))) return [];
711
+ throw new Error("OMP returned an invalid plugin catalog");
712
+ }
713
+ const plugins: OmpCatalogState["plugins"] = [];
714
+ let current: OmpCatalogState["plugins"][number] | null = null;
715
+ for (const line of lines) {
716
+ const entry = /^ {2}(\S+)$/u.exec(line);
717
+ if (entry?.[1]) {
718
+ const [name, version] = entry[1].split("@");
719
+ const id = `${name}@${marketplace}`;
720
+ // OMP allows mixed-case names and caps the assembled id at 128 characters.
721
+ const valid = OmpMarketplaceNameSchema.safeParse(name).success && id.length <= 128;
722
+ current = valid ? { id, version: boundedText(version, 128), description: null } : null;
723
+ if (!current) continue;
724
+ plugins.push(current);
725
+ if (plugins.length === OMP_CATALOG_PLUGIN_LIMIT) break;
726
+ continue;
727
+ }
728
+ const description = /^ {4}(\S.*)$/u.exec(line);
729
+ if (description?.[1] && current && current.description === null) {
730
+ current.description = boundedText(description[1].trim(), DESCRIPTION_LIMIT);
731
+ }
732
+ }
733
+ return plugins;
734
+ }
735
+
736
+ async function loadMarketplaces(
737
+ executable: string,
738
+ dependencies: OmpPluginDependencies,
739
+ ): Promise<OmpMarketplaceState> {
740
+ const result = await dependencies.runPlugin(
741
+ executable,
742
+ ["plugin", "marketplace", "list"],
743
+ LIST_OUTPUT_LIMIT,
744
+ READ_TIMEOUT_MS,
745
+ );
746
+ if (!runSucceeded(result)) {
747
+ return { available: false, marketplaces: [], error: readFailure(result) };
748
+ }
749
+ try {
750
+ return { available: true, marketplaces: parseOmpMarketplaceList(result.stdout) };
751
+ } catch {
752
+ return {
753
+ available: false,
754
+ marketplaces: [],
755
+ error: "OMP returned an invalid marketplace list.",
756
+ };
757
+ }
758
+ }
759
+
760
+ export async function listOmpMarketplacesWithDependencies(
761
+ dependencies: OmpPluginDependencies,
762
+ ): Promise<OmpMarketplaceState> {
763
+ const executable = await dependencies.resolveExecutable();
764
+ if (!executable) {
765
+ return {
766
+ available: false,
767
+ marketplaces: [],
768
+ error: "The OMP executable could not be resolved.",
769
+ };
770
+ }
771
+ return loadMarketplaces(executable, dependencies);
772
+ }
773
+
774
+ export function resolveListOmpMarketplaces(
775
+ _input: RpcInput<typeof listOmpMarketplaces>,
776
+ ): Promise<OmpMarketplaceState> {
777
+ return listOmpMarketplacesWithDependencies(DEFAULT_DEPENDENCIES);
778
+ }
779
+
780
+ export async function browseOmpMarketplaceWithDependencies(
781
+ input: RpcInput<typeof browseOmpMarketplace>,
782
+ dependencies: OmpPluginDependencies,
783
+ ): Promise<OmpCatalogState> {
784
+ const unavailable = (error: string): OmpCatalogState => ({
785
+ available: false,
786
+ marketplace: input.marketplace,
787
+ plugins: [],
788
+ error,
789
+ });
790
+ const executable = await dependencies.resolveExecutable();
791
+ if (!executable) return unavailable("The OMP executable could not be resolved.");
792
+ const result = await dependencies.runPlugin(
793
+ executable,
794
+ ["plugin", "discover", input.marketplace],
795
+ LIST_OUTPUT_LIMIT,
796
+ READ_TIMEOUT_MS,
797
+ );
798
+ if (!runSucceeded(result)) return unavailable(readFailure(result));
799
+ try {
800
+ return {
801
+ available: true,
802
+ marketplace: input.marketplace,
803
+ plugins: parseOmpCatalog(result.stdout, input.marketplace),
804
+ };
805
+ } catch {
806
+ return unavailable("OMP returned an invalid plugin catalog.");
807
+ }
808
+ }
809
+
810
+ export function resolveBrowseOmpMarketplace(
811
+ input: RpcInput<typeof browseOmpMarketplace>,
812
+ ): Promise<OmpCatalogState> {
813
+ return browseOmpMarketplaceWithDependencies(input, DEFAULT_DEPENDENCIES);
814
+ }
815
+
816
+ export function buildOmpMarketplaceMutationArgs(
817
+ input: RpcInput<typeof mutateOmpMarketplace>,
818
+ ): string[] {
819
+ return [
820
+ "plugin",
821
+ "marketplace",
822
+ input.action,
823
+ input.action === "add" ? input.source : input.marketplace,
824
+ ];
825
+ }
826
+
827
+ export async function mutateOmpMarketplaceWithDependencies(
828
+ input: RpcInput<typeof mutateOmpMarketplace>,
829
+ dependencies: OmpPluginDependencies,
830
+ ): Promise<{ ok: boolean; message: string; state: OmpMarketplaceState }> {
831
+ const executable = await dependencies.resolveExecutable();
832
+ if (!executable) {
833
+ const message = "The OMP executable could not be resolved.";
834
+ return { ok: false, message, state: { available: false, marketplaces: [], error: message } };
835
+ }
836
+ const mutation = await dependencies.runPlugin(
837
+ executable,
838
+ buildOmpMarketplaceMutationArgs(input),
839
+ MUTATION_OUTPUT_LIMIT,
840
+ MUTATION_TIMEOUT_MS,
841
+ );
842
+ const ok = runSucceeded(mutation);
843
+ const state = await loadMarketplaces(executable, dependencies);
844
+ if (!ok) return { ok, message: mutationFailure(mutation), state };
845
+ return {
846
+ ok,
847
+ message: input.action === "add" ? "Marketplace added." : "Marketplace removed.",
848
+ state,
849
+ };
850
+ }
851
+
852
+ export function resolveMutateOmpMarketplace(
853
+ input: RpcInput<typeof mutateOmpMarketplace>,
854
+ ): Promise<{ ok: boolean; message: string; state: OmpMarketplaceState }> {
855
+ return pluginMutationQueue.run(() =>
856
+ mutateOmpMarketplaceWithDependencies(input, DEFAULT_DEPENDENCIES),
857
+ );
858
+ }
@@ -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.400.1"; // x-release-please-version
2
+ export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.401.1"; // x-release-please-version
@@ -262,3 +262,93 @@ export const mutateOmpPlugin = defineRpc({
262
262
  })
263
263
  .strict(),
264
264
  });
265
+
266
+ // OMP's own marketplace and catalog plugin name rule (marketplace/types.ts).
267
+ const OMP_MARKETPLACE_NAME = /^[a-zA-Z0-9](?:[a-zA-Z0-9.-]{0,62}[a-zA-Z0-9])?$/u;
268
+ export const OMP_CATALOG_PLUGIN_LIMIT = 1_000;
269
+
270
+ export const OmpMarketplaceNameSchema = z
271
+ .string()
272
+ .regex(OMP_MARKETPLACE_NAME, "Expected an OMP marketplace name");
273
+
274
+ export const OmpMarketplaceSchema = z
275
+ .object({ name: OmpMarketplaceNameSchema, source: z.string().min(1).max(4_096) })
276
+ .strict();
277
+ export type OmpMarketplace = z.infer<typeof OmpMarketplaceSchema>;
278
+
279
+ /** Drops `user:token@` from a URL source so credentials are never displayed. */
280
+ export function redactSourceCredentials(source: string): string {
281
+ return source.replace(/^([a-z][a-z0-9+.-]*:\/\/)[^/?#\s]*@/iu, "$1");
282
+ }
283
+
284
+ export const OmpMarketplaceStateSchema = z
285
+ .object({
286
+ available: z.boolean(),
287
+ marketplaces: z.array(OmpMarketplaceSchema).max(OMP_PLUGIN_LIMIT),
288
+ error: z.string().max(256).optional(),
289
+ })
290
+ .strict();
291
+ export type OmpMarketplaceState = z.infer<typeof OmpMarketplaceStateSchema>;
292
+
293
+ export const listOmpMarketplaces = defineRpc({
294
+ name: "paseo-omp.list-marketplaces",
295
+ input: z.object({ store: OmpStoreSchema.optional() }).strict(),
296
+ output: OmpMarketplaceStateSchema,
297
+ });
298
+
299
+ export const OmpCatalogPluginSchema = z
300
+ .object({
301
+ id: z.string().min(3).max(128),
302
+ version: z.string().min(1).max(128).nullable(),
303
+ description: z.string().max(1_024).nullable(),
304
+ })
305
+ .strict();
306
+ export type OmpCatalogPlugin = z.infer<typeof OmpCatalogPluginSchema>;
307
+
308
+ export const OmpCatalogStateSchema = z
309
+ .object({
310
+ available: z.boolean(),
311
+ marketplace: OmpMarketplaceNameSchema,
312
+ plugins: z.array(OmpCatalogPluginSchema).max(OMP_CATALOG_PLUGIN_LIMIT),
313
+ error: z.string().max(256).optional(),
314
+ })
315
+ .strict();
316
+ export type OmpCatalogState = z.infer<typeof OmpCatalogStateSchema>;
317
+
318
+ export const browseOmpMarketplace = defineRpc({
319
+ name: "paseo-omp.browse-marketplace",
320
+ input: z
321
+ .object({ store: OmpStoreSchema.optional(), marketplace: OmpMarketplaceNameSchema })
322
+ .strict(),
323
+ output: OmpCatalogStateSchema,
324
+ });
325
+
326
+ export const OmpMarketplaceMutationSchema = z.discriminatedUnion("action", [
327
+ z
328
+ .object({
329
+ action: z.literal("add"),
330
+ source: OmpPluginInstallSourceSchema,
331
+ store: OmpStoreSchema.optional(),
332
+ })
333
+ .strict(),
334
+ z
335
+ .object({
336
+ action: z.literal("remove"),
337
+ marketplace: OmpMarketplaceNameSchema,
338
+ store: OmpStoreSchema.optional(),
339
+ })
340
+ .strict(),
341
+ ]);
342
+ export type OmpMarketplaceMutation = z.infer<typeof OmpMarketplaceMutationSchema>;
343
+
344
+ export const mutateOmpMarketplace = defineRpc({
345
+ name: "paseo-omp.mutate-marketplace",
346
+ input: OmpMarketplaceMutationSchema,
347
+ output: z
348
+ .object({
349
+ ok: z.boolean(),
350
+ message: z.string().min(1).max(256),
351
+ state: OmpMarketplaceStateSchema,
352
+ })
353
+ .strict(),
354
+ });