@termix-ssh/plugin-sdk 1.0.19 → 1.0.21

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/PLUGIN-GUIDE.md +8 -2
  3. package/dist/frontend.d.ts +7 -3
  4. package/dist/frontend.js +19 -3
  5. package/dist/host/{PluginsTab-YAGYRBIE.js → PluginsTab-HQGSDSHS.js} +31 -47
  6. package/dist/host/{chunk-MYBONEWZ.js → chunk-A5CULDWV.js} +18 -11
  7. package/dist/host/{chunk-2MU6WNSX.js → chunk-FGX27MAA.js} +1 -1
  8. package/dist/host/{chunk-LQKK2JJA.js → chunk-GTHINW3L.js} +1551 -1508
  9. package/dist/host/{chunk-7LEJ3HYF.js → chunk-JFQGI4OD.js} +5 -3
  10. package/dist/host/{chunk-446UEDSK.js → chunk-WWFRBU2E.js} +19 -3
  11. package/dist/host/core-classes.json +1 -1
  12. package/dist/host/{linked-server-OUF3POT7.js → linked-server-UDSFY3N7.js} +1 -1
  13. package/dist/host/{rbac-api-LZVENREG.js → rbac-api-AAAPMF52.js} +1 -1
  14. package/dist/host/testing-host.js +4 -4
  15. package/dist/host/types/src/ui/api/look-api.d.ts +2 -0
  16. package/dist/host/types/src/ui/api/plugins-api.d.ts +1 -1
  17. package/dist/host/types/src/ui/components/data-view.d.ts +7 -2
  18. package/dist/host/types/src/ui/components/panel-layout.d.ts +9 -2
  19. package/dist/host/types/src/ui/lib/app-return.d.ts +13 -0
  20. package/dist/host/types/src/ui/plugin-host/sdk-ui.d.ts +1 -1
  21. package/dist/host/types/src/ui/plugins/plugin-model.d.ts +1 -1
  22. package/dist/host/ui.js +67 -24
  23. package/dist/host/{use-permissions-BYCDS5PD.js → use-permissions-VAND5GEG.js} +1 -1
  24. package/dist/host-commands.d.ts +2 -6
  25. package/dist/host-commands.js +3 -6
  26. package/dist/host-scripts/docker.d.ts +137 -0
  27. package/dist/host-scripts/docker.js +345 -0
  28. package/dist/host-scripts/index.d.ts +15 -0
  29. package/dist/host-scripts/index.js +15 -0
  30. package/dist/host-scripts/journal.d.ts +45 -0
  31. package/dist/host-scripts/journal.js +194 -0
  32. package/dist/host-scripts/metrics.d.ts +134 -0
  33. package/dist/host-scripts/metrics.js +320 -0
  34. package/dist/host-scripts/openrc.d.ts +6 -0
  35. package/dist/host-scripts/openrc.js +90 -0
  36. package/dist/host-scripts/shell.d.ts +43 -0
  37. package/dist/host-scripts/shell.js +95 -0
  38. package/dist/host-scripts/systemd.d.ts +73 -0
  39. package/dist/host-scripts/systemd.js +320 -0
  40. package/dist/host-scripts/text.d.ts +23 -0
  41. package/dist/host-scripts/text.js +111 -0
  42. package/dist/manifest.d.ts +1 -1
  43. package/dist/manifest.js +1 -1
  44. package/package.json +5 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.21
4
+
5
+ Plugin API 1.12.0.
6
+
7
+ ### Added
8
+
9
+ - `@termix-ssh/plugin-sdk/host-scripts`: Docker, Linux metrics, systemd, journal and OpenRC command builders and parsers, plus `scriptShell()` and `passwordSudoScript()` to send scripts to `bash -s` on stdin. It has no Node or ssh2 imports, so the Termix mobile app runs the same code
10
+
11
+ ## 1.0.20
12
+
13
+ Plugin API 1.12.0.
14
+
15
+ ### Added
16
+
17
+ - `columns` and `onColumns` on `ViewToggle` show a cards per row picker: Auto fits as many as the pane has room for, or pick 1 to 6
18
+ - `size` and `minCardWidth` on `DataView`, so a card grid follows that pick, and the `GridSize` type
19
+ - `usePluginPanelView` also keeps `columns`, the cards per row pick, with `setColumns`
20
+
3
21
  ## 1.0.19
4
22
 
5
23
  Plugin API 1.11.0.
package/PLUGIN-GUIDE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Termix plugin guide
2
2
 
3
- SDK 1.0.19 | Plugin API 1.11.0
3
+ SDK 1.0.21 | Plugin API 1.12.0
4
4
 
5
5
  This guide is for anyone, person or AI coding tool, building a Termix plugin. It ships inside
6
6
  `@termix-ssh/plugin-sdk`, so the copy in your `node_modules` always matches the SDK you have installed.
@@ -335,7 +335,9 @@ try {
335
335
 
336
336
  `ctx.ssh.withConnection(hostId, { pool, purpose }, fn)` borrows a pooled connection for frequent short
337
337
  commands. `@termix-ssh/plugin-sdk/host-commands` has helpers to detect the OS and run package manager and
338
- sudo commands. Hosts from `ctx.hosts` never carry secrets. Pass the host or its id to `ctx.ssh`.
338
+ sudo commands. `@termix-ssh/plugin-sdk/host-scripts` builds Docker, metrics, systemd and journal
339
+ commands and parses their output; send a script on stdin to the command `scriptShell()` returns. Hosts from
340
+ `ctx.hosts` never carry secrets. Pass the host or its id to `ctx.ssh`.
339
341
 
340
342
  ### The desktop app
341
343
 
@@ -643,6 +645,9 @@ exports with props is `ui.api.txt` in the Termix repo
643
645
  `PanePrompt` for small prompts.
644
646
  - Every tab or panel sits in `PanelShell`. Lists use `PanelList` and `ListRow`, add with `AddButton`,
645
647
  forms end with `FormFooter`, empty lists show `EmptyState`.
648
+ - Card grids use `DataView` with `ViewToggle`. Pass `columns` and `onColumns` to `ViewToggle` and the same
649
+ value as `size` to `DataView`, so users can pick Auto (as many as fit) or a fixed number of cards per
650
+ row. `usePluginPanelView` keeps the choice as `columns`. Older Termix versions ignore both props.
646
651
  - Forms: `TextField`, `NumberField`, `SelectField`, `SwitchRow`, `SecretField`, `SettingRow` and friends.
647
652
  - Host sessions use `ConnectionGate` for the whole connect flow (host keys, TOTP, passphrases, errors).
648
653
  - Mobile: check `useIsMobile()` and give small screens a layout that works. The desktop app always uses the
@@ -902,6 +907,7 @@ To run your own registry instead, see https://docs.termix.site/develop/registrie
902
907
  | `@termix-ssh/plugin-sdk/testing` | `createMockCtx`, `createTestDb`, `renderWithApp`, `createFakeContext` |
903
908
  | `@termix-ssh/plugin-sdk/vitest-preset` | `pluginVitestConfig` |
904
909
  | `@termix-ssh/plugin-sdk/host-commands` | OS detection, package manager and sudo helpers over ssh2 |
910
+ | `@termix-ssh/plugin-sdk/host-scripts` | Docker, metrics, systemd and journal command builders and parsers, scripts sent to `bash -s` |
905
911
  | `@termix-ssh/plugin-sdk/ssh-certs` | `applyCertificateAuth()` for certificate based SSH auth |
906
912
  | `@termix-ssh/plugin-sdk/ssh-keys` | `generateSshKeyPair()`, `detectSshKeyType()`, `publicKeyFromPrivate()`, `validateSshKeyPair()` |
907
913
  | `@termix-ssh/plugin-sdk/desktop` | The desktop app bridge, typed. Check it exists before use |
@@ -1426,17 +1426,21 @@ export declare function usePluginUiPreferences<T extends Record<string, unknown>
1426
1426
  values: T;
1427
1427
  set: <K extends keyof T & string>(key: K, value: T[K] | null) => void;
1428
1428
  };
1429
+ type PanelGridSize = "auto" | "1" | "2" | "3" | "4" | "5" | "6";
1429
1430
  /**
1430
- * Grid or list and row density for one of this plugin's views, kept in its
1431
- * Appearance area as `<prefix>viewMode` and `<prefix>density`. Declare those
1432
- * keys in contributes.uiPresets so each preset level can pick a default.
1431
+ * Grid or list, row density and cards per row for one of this plugin's
1432
+ * views, kept in its Appearance area as `<prefix>viewMode`, `<prefix>density`
1433
+ * and `<prefix>columns`. Declare those keys in contributes.uiPresets so each
1434
+ * preset level can pick a default. Hand columns to ViewToggle and DataView.
1433
1435
  */
1434
1436
  export declare function usePluginPanelView(prefix?: string): {
1435
1437
  view: "grid" | "list";
1436
1438
  density: "comfortable" | "compact";
1437
1439
  compact: boolean;
1440
+ columns: PanelGridSize;
1438
1441
  setView: (view: "grid" | "list") => void;
1439
1442
  setDensity: (density: "comfortable" | "compact") => void;
1443
+ setColumns: (columns: PanelGridSize) => void;
1440
1444
  };
1441
1445
  export declare function useTabs(): TabsApi;
1442
1446
  /**
package/dist/frontend.js CHANGED
@@ -165,21 +165,37 @@ export function usePluginUiPreferences() {
165
165
  const bridge = requireHost();
166
166
  return bridge.usePluginUiPreferences(bridge.usePluginId());
167
167
  }
168
+ const PANEL_GRID_SIZES = [
169
+ "auto",
170
+ "1",
171
+ "2",
172
+ "3",
173
+ "4",
174
+ "5",
175
+ "6",
176
+ ];
168
177
  /**
169
- * Grid or list and row density for one of this plugin's views, kept in its
170
- * Appearance area as `<prefix>viewMode` and `<prefix>density`. Declare those
171
- * keys in contributes.uiPresets so each preset level can pick a default.
178
+ * Grid or list, row density and cards per row for one of this plugin's
179
+ * views, kept in its Appearance area as `<prefix>viewMode`, `<prefix>density`
180
+ * and `<prefix>columns`. Declare those keys in contributes.uiPresets so each
181
+ * preset level can pick a default. Hand columns to ViewToggle and DataView.
172
182
  */
173
183
  export function usePluginPanelView(prefix = "") {
174
184
  const { values, set } = usePluginUiPreferences();
175
185
  const view = values[`${prefix}viewMode`] === "list" ? "list" : "grid";
176
186
  const density = values[`${prefix}density`] === "compact" ? "compact" : "comfortable";
187
+ const saved = values[`${prefix}columns`];
188
+ const columns = typeof saved === "string" && PANEL_GRID_SIZES.includes(saved)
189
+ ? saved
190
+ : "auto";
177
191
  return {
178
192
  view,
179
193
  density,
180
194
  compact: density === "compact",
195
+ columns,
181
196
  setView: (next) => set(`${prefix}viewMode`, next),
182
197
  setDensity: (next) => set(`${prefix}density`, next),
198
+ setColumns: (next) => set(`${prefix}columns`, next),
183
199
  };
184
200
  }
185
201
  export function useTabs() {
@@ -29,7 +29,7 @@ import {
29
29
  sortPlugins,
30
30
  uploadEntry,
31
31
  youtubeEmbedUrl
32
- } from "./chunk-446UEDSK.js";
32
+ } from "./chunk-WWFRBU2E.js";
33
33
  import {
34
34
  ArrowDownWideNarrow,
35
35
  BookOpen,
@@ -38,7 +38,6 @@ import {
38
38
  Check,
39
39
  ChevronLeft,
40
40
  ChevronRight,
41
- Columns3,
42
41
  DEVELOPER_MODE_CHANGED_EVENT,
43
42
  Database,
44
43
  DocsLink,
@@ -47,6 +46,7 @@ import {
47
46
  Facts,
48
47
  FakeSwitch,
49
48
  FlaskConical,
49
+ GRID_SIZES,
50
50
  Globe,
51
51
  GroupHeading,
52
52
  InlineView,
@@ -107,8 +107,8 @@ import {
107
107
  updatePlugin,
108
108
  uploadPlugin,
109
109
  useConfirm
110
- } from "./chunk-LQKK2JJA.js";
111
- import "./chunk-7LEJ3HYF.js";
110
+ } from "./chunk-GTHINW3L.js";
111
+ import "./chunk-JFQGI4OD.js";
112
112
  import {
113
113
  __toESM,
114
114
  define_import_meta_env_default,
@@ -1845,7 +1845,6 @@ function usePluginsManager() {
1845
1845
 
1846
1846
  // src/ui/plugins/PluginsTab.tsx
1847
1847
  import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1848
- var GRID_SIZES = ["auto", "2", "3", "4", "5", "6"];
1849
1848
  function useStoredChoice(key, allowed, fallback) {
1850
1849
  const [value, setValue] = useState5(() => {
1851
1850
  try {
@@ -2075,45 +2074,15 @@ function LayoutControls({
2075
2074
  onView,
2076
2075
  onColumns
2077
2076
  }) {
2078
- const { t } = useTranslation7();
2079
- return /* @__PURE__ */ jsxs6(Fragment4, { children: [
2080
- layout.view === "grid" && /* @__PURE__ */ jsxs6(
2081
- Select,
2082
- {
2083
- value: layout.columns,
2084
- onValueChange: (v) => onColumns(v),
2085
- children: [
2086
- /* @__PURE__ */ jsxs6(
2087
- SelectTrigger,
2088
- {
2089
- size: "sm",
2090
- className: "w-auto gap-1.5 text-xs",
2091
- title: t("plugins.manager.columns.title"),
2092
- "aria-label": t("plugins.manager.columns.title"),
2093
- children: [
2094
- /* @__PURE__ */ jsx6(Columns3, { className: "size-3.5 text-muted-foreground" }),
2095
- /* @__PURE__ */ jsx6(SelectValue, {})
2096
- ]
2097
- }
2098
- ),
2099
- /* @__PURE__ */ jsx6(SelectContent, { children: GRID_SIZES.map((size) => /* @__PURE__ */ jsx6(SelectItem, { value: size, className: "text-xs", children: size === "auto" ? t("plugins.manager.columns.auto") : t("plugins.manager.columns.count", { count: Number(size) }) }, size)) })
2100
- ]
2101
- }
2102
- ),
2103
- /* @__PURE__ */ jsx6(ViewToggle, { view: layout.view, onView })
2104
- ] });
2105
- }
2106
- function gridStyle(columns) {
2107
- if (columns === "auto") {
2108
- return {
2109
- gridTemplateColumns: "repeat(auto-fill, minmax(min(100%, 400px), 1fr))"
2110
- };
2111
- }
2112
- const n = Number(columns);
2113
- const gaps = (n - 1) * 12;
2114
- return {
2115
- gridTemplateColumns: `repeat(auto-fill, minmax(max(220px, calc((100% - ${gaps}px) / ${n} - 0.5px)), 1fr))`
2116
- };
2077
+ return /* @__PURE__ */ jsx6(
2078
+ ViewToggle,
2079
+ {
2080
+ view: layout.view,
2081
+ onView,
2082
+ columns: layout.columns,
2083
+ onColumns
2084
+ }
2085
+ );
2117
2086
  }
2118
2087
  function PluginCollection({
2119
2088
  plugins,
@@ -2137,7 +2106,20 @@ function PluginCollection({
2137
2106
  }
2138
2107
  );
2139
2108
  }
2140
- return /* @__PURE__ */ jsx6("div", { className: "grid gap-3", style: gridStyle(layout.columns), children: plugins.map((p) => /* @__PURE__ */ jsx6("div", { className: "flex flex-col *:flex-1", children: renderCard(p) }, p.id)) });
2109
+ return /* @__PURE__ */ jsx6(
2110
+ DataView,
2111
+ {
2112
+ items: plugins,
2113
+ view: "grid",
2114
+ getKey: (p) => p.id,
2115
+ renderCard,
2116
+ columns: {},
2117
+ size: layout.columns,
2118
+ minCardWidth: 400,
2119
+ listColumns,
2120
+ empty: null
2121
+ }
2122
+ );
2141
2123
  }
2142
2124
  function NameCell({ plugin, muted }) {
2143
2125
  return /* @__PURE__ */ jsxs6("div", { className: "flex min-w-0 items-center gap-2", children: [
@@ -2699,7 +2681,7 @@ function InstalledCard({
2699
2681
  )
2700
2682
  ] }) : !running ? /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2 border-t border-border px-3 py-2", children: [
2701
2683
  /* @__PURE__ */ jsx6("span", { className: "size-1.5 shrink-0 bg-muted-foreground/40" }),
2702
- /* @__PURE__ */ jsx6("span", { className: "text-[11px] text-muted-foreground", children: plugin.status === "server" ? t("plugins.manager.status.server") : t("plugins.manager.status.disabled") })
2684
+ /* @__PURE__ */ jsx6("span", { className: "text-[11px] text-muted-foreground", children: plugin.status === "server" ? t("plugins.manager.status.server") : plugin.status === "safeMode" ? t("plugins.manager.status.safeMode") : t("plugins.manager.status.disabled") })
2703
2685
  ] }) : /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2 border-t border-border px-3 py-2", children: [
2704
2686
  /* @__PURE__ */ jsx6("span", { className: "size-1.5 shrink-0 bg-green-500" }),
2705
2687
  /* @__PURE__ */ jsx6("span", { className: "text-[11px] text-muted-foreground", children: plugin.pinnedVersion ? t("plugins.manager.pinnedTo", {
@@ -2777,7 +2759,9 @@ function StatusCell({ plugin }) {
2777
2759
  const { t } = useTranslation7();
2778
2760
  const running = plugin.status === "running";
2779
2761
  const failed = plugin.status === "failed" || plugin.status === "blocked";
2780
- const label = plugin.status === "blocked" ? t("plugins.manager.status.blocked") : failed ? t("plugins.manager.status.failed") : plugin.status === "server" ? t("plugins.manager.status.server") : !running ? t("plugins.manager.status.disabled") : plugin.pinnedVersion ? t("plugins.manager.pinnedTo", { version: plugin.pinnedVersion }) : t("plugins.manager.status.running");
2762
+ const label = plugin.status === "blocked" ? t("plugins.manager.status.blocked") : failed ? t("plugins.manager.status.failed") : plugin.status === "server" ? t("plugins.manager.status.server") : plugin.status === "safeMode" ? t("plugins.manager.status.safeMode") : !running ? t("plugins.manager.status.disabled") : plugin.pinnedVersion ? t("plugins.manager.pinnedTo", {
2763
+ version: plugin.pinnedVersion
2764
+ }) : t("plugins.manager.status.running");
2781
2765
  return /* @__PURE__ */ jsxs6(
2782
2766
  "span",
2783
2767
  {
@@ -3,7 +3,7 @@ import {
3
3
  hasPermission,
4
4
  resetPermissionsCache,
5
5
  usePermissions
6
- } from "./chunk-2MU6WNSX.js";
6
+ } from "./chunk-FGX27MAA.js";
7
7
  import {
8
8
  ArrowDownToLine,
9
9
  ArrowLeftToLine,
@@ -83,7 +83,7 @@ import {
83
83
  withIconBoundary,
84
84
  withPluginContext,
85
85
  withPluginScope
86
- } from "./chunk-LQKK2JJA.js";
86
+ } from "./chunk-GTHINW3L.js";
87
87
  import {
88
88
  SYNC_CHANGED_EVENT,
89
89
  TRUST_TOKEN_KEY,
@@ -132,7 +132,7 @@ import {
132
132
  usePluginStore,
133
133
  useTabTypes,
134
134
  websocketAuthProtocols
135
- } from "./chunk-7LEJ3HYF.js";
135
+ } from "./chunk-JFQGI4OD.js";
136
136
  import {
137
137
  define_import_meta_env_default,
138
138
  init_define_import_meta_env
@@ -1144,6 +1144,10 @@ var en_default = {
1144
1144
  ready: "Termix {{version}} is ready to install",
1145
1145
  readyHint: "It installs the next time Termix restarts."
1146
1146
  },
1147
+ safeMode: {
1148
+ title: "Safe mode",
1149
+ description: "Only layout and theme plugins are running. Restart the server without TERMIX_SAFE_MODE to turn the rest back on."
1150
+ },
1147
1151
  companion: {
1148
1152
  close: "Close panel",
1149
1153
  moveSide: "Move panel",
@@ -2007,6 +2011,8 @@ var en_default = {
2007
2011
  resetEveryone: "Reset the default for everyone",
2008
2012
  update: "Update {{name}} to {{version}}",
2009
2013
  disable: "Turn off {{name}}",
2014
+ enable: "Turn on {{name}}",
2015
+ startAgain: "Start {{name}} again",
2010
2016
  install: "Find layouts and themes",
2011
2017
  installTitle: "Layouts and themes",
2012
2018
  installButton: "Install",
@@ -2218,7 +2224,8 @@ var en_default = {
2218
2224
  disabled: "Disabled",
2219
2225
  failed: "Stopped unexpectedly",
2220
2226
  blocked: "Waiting on another plugin",
2221
- server: "Runs on your server"
2227
+ server: "Runs on your server",
2228
+ safeMode: "Off in safe mode"
2222
2229
  },
2223
2230
  groups: {
2224
2231
  running: "Running",
@@ -2232,11 +2239,6 @@ var en_default = {
2232
2239
  updated: "Recently updated",
2233
2240
  category: "Category"
2234
2241
  },
2235
- columns: {
2236
- title: "Columns",
2237
- auto: "Auto",
2238
- count: "{{count}} wide"
2239
- },
2240
2242
  table: {
2241
2243
  name: "Name",
2242
2244
  description: "Description",
@@ -2561,7 +2563,12 @@ var en_default = {
2561
2563
  gridView: "Grid",
2562
2564
  listView: "List",
2563
2565
  compactRows: "Compact rows",
2564
- comfortableRows: "Comfortable rows"
2566
+ comfortableRows: "Comfortable rows",
2567
+ columns: {
2568
+ title: "Columns",
2569
+ auto: "Auto",
2570
+ count: "{{count}} wide"
2571
+ }
2565
2572
  },
2566
2573
  fields: {
2567
2574
  secretSaved: "Saved. Type to replace it."
@@ -10261,7 +10268,7 @@ function CompanionLayout({
10261
10268
  // src/ui/shell/tabUtils.tsx
10262
10269
  import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
10263
10270
  var PluginsTab = lazy(
10264
- () => import("./PluginsTab-YAGYRBIE.js").then((m) => ({ default: m.PluginsTab }))
10271
+ () => import("./PluginsTab-HQGSDSHS.js").then((m) => ({ default: m.PluginsTab }))
10265
10272
  );
10266
10273
  function preloadTabSurface(type) {
10267
10274
  const loader = getTabType(type)?.preload;
@@ -26,7 +26,7 @@ var inFlight = null;
26
26
  function load() {
27
27
  if (cache) return Promise.resolve(cache);
28
28
  if (inFlight) return inFlight;
29
- inFlight = import("./rbac-api-LZVENREG.js").then(({ getMyPermissions }) => getMyPermissions()).then((result) => {
29
+ inFlight = import("./rbac-api-AAAPMF52.js").then(({ getMyPermissions }) => getMyPermissions()).then((result) => {
30
30
  cache = {
31
31
  permissions: result.permissions ?? [],
32
32
  isAdmin: !!result.isAdmin