@termix-ssh/plugin-sdk 1.0.0
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/README.md +52 -0
- package/cli/commands/build.mjs +246 -0
- package/cli/commands/migrations.mjs +248 -0
- package/cli/commands/pack.mjs +42 -0
- package/cli/commands/sign.mjs +83 -0
- package/cli/commands/test.mjs +33 -0
- package/cli/commands/validate.mjs +215 -0
- package/cli/index.mjs +65 -0
- package/cli/lib/changelog.mjs +126 -0
- package/cli/lib/externals.mjs +46 -0
- package/cli/lib/plugin-dir.mjs +29 -0
- package/cli/lib/signing.mjs +86 -0
- package/cli/lib/static-url-imports.mjs +54 -0
- package/cli/lib/tmxplug.mjs +106 -0
- package/cli/patches/guacamole-common-js-flush.cjs +76 -0
- package/cli/patches/xterm-android-ime.cjs +130 -0
- package/client.d.ts +13 -0
- package/dist/backend.d.ts +1777 -0
- package/dist/backend.js +84 -0
- package/dist/capabilities.d.ts +38 -0
- package/dist/capabilities.js +71 -0
- package/dist/db.d.ts +112 -0
- package/dist/db.js +189 -0
- package/dist/ddl.d.ts +76 -0
- package/dist/ddl.js +678 -0
- package/dist/desktop.d.ts +346 -0
- package/dist/desktop.js +5 -0
- package/dist/frontend.d.ts +1206 -0
- package/dist/frontend.js +388 -0
- package/dist/host/chunk-F3SDZDDG.js +6017 -0
- package/dist/host/chunk-XGWE7BTJ.js +90 -0
- package/dist/host/chunk-XH5NXL6Y.js +56314 -0
- package/dist/host/chunk-YC2MAKSP.js +14 -0
- package/dist/host/linked-server-FZGWQW32.js +12 -0
- package/dist/host/rbac-api-6KDMBVDZ.js +52 -0
- package/dist/host/testing-host.js +414 -0
- package/dist/host/theme.css +91 -0
- package/dist/host/types/src/types/auth-protocols.d.ts +10 -0
- package/dist/host/types/src/types/connection-log.d.ts +13 -0
- package/dist/host/types/src/types/credential-sidebar-preferences.d.ts +38 -0
- package/dist/host/types/src/types/host-defaults.d.ts +60 -0
- package/dist/host/types/src/types/host-sidebar-preferences.d.ts +55 -0
- package/dist/host/types/src/types/index.d.ts +298 -0
- package/dist/host/types/src/types/keybindings.d.ts +27 -0
- package/dist/host/types/src/types/ui-preferences.d.ts +102 -0
- package/dist/host/types/src/types/ui-types.d.ts +260 -0
- package/dist/host/types/src/ui/api/admin-user-data-api.d.ts +11 -0
- package/dist/host/types/src/ui/api/auth-methods-api.d.ts +63 -0
- package/dist/host/types/src/ui/api/credential-sidebar-preferences-api.d.ts +3 -0
- package/dist/host/types/src/ui/api/credentials-api.d.ts +56 -0
- package/dist/host/types/src/ui/api/dashboard-api.d.ts +23 -0
- package/dist/host/types/src/ui/api/external-account-api.d.ts +8 -0
- package/dist/host/types/src/ui/api/host-sidebar-preferences-api.d.ts +3 -0
- package/dist/host/types/src/ui/api/host-status-api.d.ts +11 -0
- package/dist/host/types/src/ui/api/open-tabs-api.d.ts +74 -0
- package/dist/host/types/src/ui/api/plugins-api.d.ts +128 -0
- package/dist/host/types/src/ui/api/rbac-api.d.ts +167 -0
- package/dist/host/types/src/ui/api/settings-api.d.ts +22 -0
- package/dist/host/types/src/ui/api/ssh-host-management-api.d.ts +65 -0
- package/dist/host/types/src/ui/api/sync-api.d.ts +93 -0
- package/dist/host/types/src/ui/api/system-status-api.d.ts +49 -0
- package/dist/host/types/src/ui/api/ui-preferences-api.d.ts +8 -0
- package/dist/host/types/src/ui/api/user-management-api.d.ts +80 -0
- package/dist/host/types/src/ui/auth/Auth.d.ts +12 -0
- package/dist/host/types/src/ui/auth/auth-bits.d.ts +11 -0
- package/dist/host/types/src/ui/auth/silent-signin.d.ts +2 -0
- package/dist/host/types/src/ui/components/FullScreenAppWrapper.d.ts +9 -0
- package/dist/host/types/src/ui/components/alert-dialog.d.ts +14 -0
- package/dist/host/types/src/ui/components/alert.d.ts +9 -0
- package/dist/host/types/src/ui/components/badge.d.ts +9 -0
- package/dist/host/types/src/ui/components/button.d.ts +13 -0
- package/dist/host/types/src/ui/components/card-grid/CardGridCanvas.d.ts +22 -0
- package/dist/host/types/src/ui/components/card-grid/layout-utils.d.ts +26 -0
- package/dist/host/types/src/ui/components/card-grid/types.d.ts +29 -0
- package/dist/host/types/src/ui/components/card-masonry.d.ts +16 -0
- package/dist/host/types/src/ui/components/card.d.ts +11 -0
- package/dist/host/types/src/ui/components/charts/BarSeries.d.ts +16 -0
- package/dist/host/types/src/ui/components/charts/LineChart.d.ts +17 -0
- package/dist/host/types/src/ui/components/charts/RadialGauge.d.ts +18 -0
- package/dist/host/types/src/ui/components/charts/Sparkline.d.ts +22 -0
- package/dist/host/types/src/ui/components/charts/StatRow.d.ts +15 -0
- package/dist/host/types/src/ui/components/charts/geometry.d.ts +20 -0
- package/dist/host/types/src/ui/components/charts/index.d.ts +4 -0
- package/dist/host/types/src/ui/components/checkbox.d.ts +4 -0
- package/dist/host/types/src/ui/components/connection/ConnectionGate.d.ts +56 -0
- package/dist/host/types/src/ui/components/connection/ConnectionLogPanel.d.ts +9 -0
- package/dist/host/types/src/ui/components/connection/ConnectionScreen.d.ts +34 -0
- package/dist/host/types/src/ui/components/connection/connection-status.d.ts +1 -0
- package/dist/host/types/src/ui/components/data-view.d.ts +32 -0
- package/dist/host/types/src/ui/components/dialog.d.ts +17 -0
- package/dist/host/types/src/ui/components/dropdown-menu.d.ts +29 -0
- package/dist/host/types/src/ui/components/empty-state.d.ts +19 -0
- package/dist/host/types/src/ui/components/form-fields.d.ts +115 -0
- package/dist/host/types/src/ui/components/input.d.ts +3 -0
- package/dist/host/types/src/ui/components/kbd.d.ts +12 -0
- package/dist/host/types/src/ui/components/label.d.ts +4 -0
- package/dist/host/types/src/ui/components/manager-card.d.ts +25 -0
- package/dist/host/types/src/ui/components/meter.d.ts +14 -0
- package/dist/host/types/src/ui/components/metric-card.d.ts +18 -0
- package/dist/host/types/src/ui/components/panel-layout.d.ts +83 -0
- package/dist/host/types/src/ui/components/password-input.d.ts +4 -0
- package/dist/host/types/src/ui/components/popover.d.ts +7 -0
- package/dist/host/types/src/ui/components/scroll-area.d.ts +5 -0
- package/dist/host/types/src/ui/components/section-card.d.ts +29 -0
- package/dist/host/types/src/ui/components/select.d.ts +15 -0
- package/dist/host/types/src/ui/components/select2.d.ts +8 -0
- package/dist/host/types/src/ui/components/separator.d.ts +4 -0
- package/dist/host/types/src/ui/components/sheet.d.ts +14 -0
- package/dist/host/types/src/ui/components/sidebar.d.ts +69 -0
- package/dist/host/types/src/ui/components/skeleton.d.ts +2 -0
- package/dist/host/types/src/ui/components/slider.d.ts +4 -0
- package/dist/host/types/src/ui/components/sonner.d.ts +4 -0
- package/dist/host/types/src/ui/components/surface/prompt-styles.d.ts +4 -0
- package/dist/host/types/src/ui/components/surface/surface-scope.d.ts +79 -0
- package/dist/host/types/src/ui/components/switch.d.ts +4 -0
- package/dist/host/types/src/ui/components/tab-strip.d.ts +19 -0
- package/dist/host/types/src/ui/components/tabs.d.ts +7 -0
- package/dist/host/types/src/ui/components/textarea.d.ts +4 -0
- package/dist/host/types/src/ui/components/theme-provider.d.ts +14 -0
- package/dist/host/types/src/ui/components/tooltip.d.ts +7 -0
- package/dist/host/types/src/ui/contexts/BrandingContext.d.ts +15 -0
- package/dist/host/types/src/ui/contexts/UiPreferencesContext.d.ts +38 -0
- package/dist/host/types/src/ui/contexts/branding-document.d.ts +10 -0
- package/dist/host/types/src/ui/dashboard/dashboard-cards-registry.d.ts +30 -0
- package/dist/host/types/src/ui/hooks/use-action-slot.d.ts +10 -0
- package/dist/host/types/src/ui/hooks/use-adaptive-polling.d.ts +5 -0
- package/dist/host/types/src/ui/hooks/use-mobile.d.ts +1 -0
- package/dist/host/types/src/ui/hooks/use-permissions.d.ts +29 -0
- package/dist/host/types/src/ui/hooks/use-status-color-scheme.d.ts +12 -0
- package/dist/host/types/src/ui/hooks/use-sync-status.d.ts +4 -0
- package/dist/host/types/src/ui/hooks/useSshAuthProviders.d.ts +17 -0
- package/dist/host/types/src/ui/i18n/i18n.d.ts +52 -0
- package/dist/host/types/src/ui/lib/ServerStatusContext.d.ts +33 -0
- package/dist/host/types/src/ui/lib/adaptive-polling.d.ts +29 -0
- package/dist/host/types/src/ui/lib/adaptive-resource-budget.d.ts +39 -0
- package/dist/host/types/src/ui/lib/app-keyboard-shortcuts.d.ts +8 -0
- package/dist/host/types/src/ui/lib/base-path.d.ts +1 -0
- package/dist/host/types/src/ui/lib/clipboard-provider.d.ts +9 -0
- package/dist/host/types/src/ui/lib/clipboard.d.ts +20 -0
- package/dist/host/types/src/ui/lib/connection-origin.d.ts +47 -0
- package/dist/host/types/src/ui/lib/db-health-monitor.d.ts +34 -0
- package/dist/host/types/src/ui/lib/device-id.d.ts +1 -0
- package/dist/host/types/src/ui/lib/electron.d.ts +1 -0
- package/dist/host/types/src/ui/lib/embedded-server-status.d.ts +15 -0
- package/dist/host/types/src/ui/lib/error-message.d.ts +9 -0
- package/dist/host/types/src/ui/lib/frontend-logger.d.ts +67 -0
- package/dist/host/types/src/ui/lib/global-shortcut-handler.d.ts +3 -0
- package/dist/host/types/src/ui/lib/host-defaults-context.d.ts +48 -0
- package/dist/host/types/src/ui/lib/hosts-request-cache.d.ts +9 -0
- package/dist/host/types/src/ui/lib/keybinding-match.d.ts +3 -0
- package/dist/host/types/src/ui/lib/linked-server.d.ts +10 -0
- package/dist/host/types/src/ui/lib/local-adaptive-engine.d.ts +40 -0
- package/dist/host/types/src/ui/lib/permissions.d.ts +16 -0
- package/dist/host/types/src/ui/lib/plugin-i18n.d.ts +11 -0
- package/dist/host/types/src/ui/lib/plugin-icon.d.ts +11 -0
- package/dist/host/types/src/ui/lib/plugin-transport.d.ts +50 -0
- package/dist/host/types/src/ui/lib/registry.d.ts +29 -0
- package/dist/host/types/src/ui/lib/rem.d.ts +7 -0
- package/dist/host/types/src/ui/lib/remote-server-api.d.ts +11 -0
- package/dist/host/types/src/ui/lib/server-status-store.d.ts +37 -0
- package/dist/host/types/src/ui/lib/sync-events.d.ts +2 -0
- package/dist/host/types/src/ui/lib/sync-status.d.ts +6 -0
- package/dist/host/types/src/ui/lib/tab-jump-hotkey.d.ts +4 -0
- package/dist/host/types/src/ui/lib/theme.d.ts +21 -0
- package/dist/host/types/src/ui/lib/ttl-request-cache.d.ts +10 -0
- package/dist/host/types/src/ui/lib/usage-color.d.ts +5 -0
- package/dist/host/types/src/ui/lib/utils.d.ts +2 -0
- package/dist/host/types/src/ui/lib/visible-interval.d.ts +5 -0
- package/dist/host/types/src/ui/lib/widget-title.d.ts +8 -0
- package/dist/host/types/src/ui/lib/ws-auth.d.ts +1 -0
- package/dist/host/types/src/ui/main-axios.d.ts +170 -0
- package/dist/host/types/src/ui/plugin-host/PluginViewPlaceholder.d.ts +13 -0
- package/dist/host/types/src/ui/plugin-host/app.d.ts +18 -0
- package/dist/host/types/src/ui/plugin-host/auth-registry.d.ts +50 -0
- package/dist/host/types/src/ui/plugin-host/bridge.d.ts +26 -0
- package/dist/host/types/src/ui/plugin-host/component-registry.d.ts +24 -0
- package/dist/host/types/src/ui/plugin-host/desktop.d.ts +7 -0
- package/dist/host/types/src/ui/plugin-host/extension-registry.d.ts +16 -0
- package/dist/host/types/src/ui/plugin-host/host-scope.d.ts +26 -0
- package/dist/host/types/src/ui/plugin-host/loader.d.ts +52 -0
- package/dist/host/types/src/ui/plugin-host/plugin-store.d.ts +40 -0
- package/dist/host/types/src/ui/plugin-host/scope.d.ts +20 -0
- package/dist/host/types/src/ui/plugin-host/sdk-ui.d.ts +99 -0
- package/dist/host/types/src/ui/plugin-host/shell-bridge.d.ts +67 -0
- package/dist/host/types/src/ui/plugin-host/view-ownership.d.ts +31 -0
- package/dist/host/types/src/ui/settings/HostPluginSections.d.ts +31 -0
- package/dist/host/types/src/ui/settings/SettingsFields.d.ts +22 -0
- package/dist/host/types/src/ui/settings/host-feature-tabs.d.ts +11 -0
- package/dist/host/types/src/ui/settings/settings-components.d.ts +32 -0
- package/dist/host/types/src/ui/settings/settings-fields-util.d.ts +11 -0
- package/dist/host/types/src/ui/shell/ActionSlot.d.ts +41 -0
- package/dist/host/types/src/ui/shell/TabContext.d.ts +30 -0
- package/dist/host/types/src/ui/shell/action-registry.d.ts +99 -0
- package/dist/host/types/src/ui/shell/keybinding-registry.d.ts +62 -0
- package/dist/host/types/src/ui/shell/palette-registry.d.ts +55 -0
- package/dist/host/types/src/ui/shell/panel-registry.d.ts +24 -0
- package/dist/host/types/src/ui/shell/tab-registry.d.ts +92 -0
- package/dist/host/types/src/ui/sidebar/HostManagerTabs.d.ts +65 -0
- package/dist/host/types/src/ui/sidebar/host-contributions.d.ts +72 -0
- package/dist/host/types/src/ui/sidebar/host-defaults/catalog.d.ts +17 -0
- package/dist/host/types/src/ui/sidebar/host-protocols.d.ts +49 -0
- package/dist/host/types/src/ui/sidebar/quick-connect-host.d.ts +21 -0
- package/dist/host/types/src/ui/sidebar/rail-items.d.ts +103 -0
- package/dist/host/types/src/ui/ssh/connection-log/ConnectionLogContext.d.ts +17 -0
- package/dist/host/types/src/ui/ssh/dialogs/BrowserSignInDialog.d.ts +18 -0
- package/dist/host/types/src/ui/ssh/dialogs/HostKeyVerificationDialog.d.ts +17 -0
- package/dist/host/types/src/ui/ssh/dialogs/PassphraseDialog.d.ts +15 -0
- package/dist/host/types/src/ui/ssh/dialogs/SSHAuthDialog.d.ts +20 -0
- package/dist/host/types/src/ui/ssh/dialogs/TOTPDialog.d.ts +13 -0
- package/dist/host/ui.d.ts +1 -0
- package/dist/host/ui.js +31754 -0
- package/dist/host/use-permissions-NULZL43J.js +18 -0
- package/dist/host-commands.d.ts +89 -0
- package/dist/host-commands.js +387 -0
- package/dist/manifest.d.ts +461 -0
- package/dist/manifest.js +1499 -0
- package/dist/settings.d.ts +43 -0
- package/dist/settings.js +168 -0
- package/dist/ssh-certs.d.ts +25 -0
- package/dist/ssh-certs.js +234 -0
- package/dist/ssh-options.d.ts +23 -0
- package/dist/ssh-options.js +1 -0
- package/dist/table-builder.d.ts +26 -0
- package/dist/table-builder.js +87 -0
- package/dist/testing/safe-ports.d.ts +10 -0
- package/dist/testing/safe-ports.js +59 -0
- package/dist/testing/setup.d.ts +7 -0
- package/dist/testing/setup.js +146 -0
- package/dist/testing.d.ts +537 -0
- package/dist/testing.js +1451 -0
- package/dist/vitest-preset.d.ts +54 -0
- package/dist/vitest-preset.js +96 -0
- package/package.json +143 -0
- package/schema/changelog.schema.json +67 -0
- package/schema/manifest.schema.json +1160 -0
- package/tsconfig.plugin.json +31 -0
|
@@ -0,0 +1,1206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The frontend contract: what a plugin's frontend entry receives, and the
|
|
3
|
+
* hooks its components use.
|
|
4
|
+
*
|
|
5
|
+
* A plugin frontend is `src/frontend/index.tsx` exporting `activate(app)` and
|
|
6
|
+
* optionally `deactivate()`. Everything it contributes goes through `app`, and
|
|
7
|
+
* everything registered there is removed when the plugin is disabled, without
|
|
8
|
+
* a page reload.
|
|
9
|
+
*
|
|
10
|
+
* This module has no runtime dependencies. The hooks delegate to a host that
|
|
11
|
+
* core installs at startup (`__setPluginHost`), because React, i18next and the
|
|
12
|
+
* shell's state all live in core and must be one instance across the shell
|
|
13
|
+
* and every plugin bundle.
|
|
14
|
+
*/
|
|
15
|
+
import type { ComponentType, ReactNode, Ref } from "react";
|
|
16
|
+
import type { PluginManifest } from "./manifest.js";
|
|
17
|
+
import type { HostSshOptions } from "./ssh-options.js";
|
|
18
|
+
export type { HostSshOptions } from "./ssh-options.js";
|
|
19
|
+
export type Disposer = () => void;
|
|
20
|
+
/** A Lucide icon or anything with the same props. */
|
|
21
|
+
export type IconComponent = ComponentType<{
|
|
22
|
+
className?: string;
|
|
23
|
+
size?: number | string;
|
|
24
|
+
strokeWidth?: number | string;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* A host as the shell hands it to a plugin. Every field is listed here and
|
|
28
|
+
* core builds the record field by field, so a plugin cannot come to depend on
|
|
29
|
+
* a core column that is not part of this contract. A plugin's own host
|
|
30
|
+
* settings are in `pluginSettings[<plugin id>]`.
|
|
31
|
+
*/
|
|
32
|
+
export interface PluginHostRecord {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
ip: string;
|
|
36
|
+
port: number;
|
|
37
|
+
username?: string;
|
|
38
|
+
folder?: string;
|
|
39
|
+
tags?: string[];
|
|
40
|
+
pin?: boolean;
|
|
41
|
+
notes?: string;
|
|
42
|
+
/** Stable across a desktop and the server it syncs with. */
|
|
43
|
+
syncId?: string | null;
|
|
44
|
+
/** Sub-host nesting: the host this one is organized under. */
|
|
45
|
+
parentHostId?: string | null;
|
|
46
|
+
authType?: string;
|
|
47
|
+
credentialId?: string | number | null;
|
|
48
|
+
overrideCredentialUsername?: boolean;
|
|
49
|
+
/** "ssh", or the id of the plugin protocol a host without SSH uses. */
|
|
50
|
+
connectionType?: string;
|
|
51
|
+
/** Desktop app: where connections to this host start from. */
|
|
52
|
+
connectionOrigin?: "local" | "remote" | null;
|
|
53
|
+
enableSsh?: boolean;
|
|
54
|
+
sshPort?: number;
|
|
55
|
+
jumpHosts?: {
|
|
56
|
+
hostId: string | number;
|
|
57
|
+
}[];
|
|
58
|
+
statusCheckEnabled?: boolean;
|
|
59
|
+
/** Seconds between status checks; null follows the global setting. */
|
|
60
|
+
statusCheckInterval?: number | null;
|
|
61
|
+
/** Keepalive, legacy algorithms, agent and environment options. */
|
|
62
|
+
sshOptions?: HostSshOptions | null;
|
|
63
|
+
/**
|
|
64
|
+
* This plugin's own host settings, under its id, secrets redacted. Another
|
|
65
|
+
* plugin's settings never appear here; ask that plugin through an action.
|
|
66
|
+
*/
|
|
67
|
+
pluginSettings?: Record<string, Record<string, unknown>>;
|
|
68
|
+
/** Each declared protocol's login, secrets left out. */
|
|
69
|
+
protocolAuth?: Record<string, HostProtocolAuthSummary>;
|
|
70
|
+
/** Set on a Quick Connect host, which is never saved. */
|
|
71
|
+
quickConnectLogin?: QuickConnectLogin;
|
|
72
|
+
/** Quick Connect only: core can save this host as it is. */
|
|
73
|
+
quickConnectSavable?: boolean;
|
|
74
|
+
/** Assigned when a host is opened in a tab; tells duplicate tabs apart. */
|
|
75
|
+
instanceId?: string;
|
|
76
|
+
/** Core's status: "online" when the host answers. */
|
|
77
|
+
status?: "online" | "reachable" | "offline" | "unknown";
|
|
78
|
+
online?: boolean;
|
|
79
|
+
/** Someone else owns this host and shared it with the user. */
|
|
80
|
+
isShared?: boolean;
|
|
81
|
+
permissionLevel?: "connect" | "view" | "edit" | "manage";
|
|
82
|
+
sharedExpiresAt?: string;
|
|
83
|
+
ownerUsername?: string;
|
|
84
|
+
/**
|
|
85
|
+
* A shared host's login per protocol ("ssh" or a plugin protocol): whether
|
|
86
|
+
* the owner shared theirs, and the recipient's own credential if they had
|
|
87
|
+
* to pick one.
|
|
88
|
+
*/
|
|
89
|
+
authOverrides?: Partial<Record<string, HostAuthOverrideSummary>>;
|
|
90
|
+
/** A read-only copy of a host shared with the linked account. */
|
|
91
|
+
sharedCopy?: boolean;
|
|
92
|
+
/** Desktop only: kept on this device, never synced to the server. */
|
|
93
|
+
localOnly?: boolean;
|
|
94
|
+
}
|
|
95
|
+
export interface HostAuthOverrideSummary {
|
|
96
|
+
credentialId?: number | string;
|
|
97
|
+
required: boolean;
|
|
98
|
+
ownerAuthShared: boolean;
|
|
99
|
+
}
|
|
100
|
+
/** The protocol login a Quick Connect host carries, in plain text. */
|
|
101
|
+
export interface QuickConnectLogin {
|
|
102
|
+
protocol: string;
|
|
103
|
+
username?: string;
|
|
104
|
+
password?: string;
|
|
105
|
+
/** "domain" when the protocol's Quick Connect entry shows that field. */
|
|
106
|
+
fields?: Record<string, string>;
|
|
107
|
+
}
|
|
108
|
+
/** "direct" (a username and password), "credential" (a saved one) or "none". */
|
|
109
|
+
export type HostProtocolAuthType = "direct" | "credential" | "none";
|
|
110
|
+
/** A host's login for a protocol a plugin declares, as the host API returns it. */
|
|
111
|
+
export interface HostProtocolAuthSummary {
|
|
112
|
+
authType: HostProtocolAuthType;
|
|
113
|
+
/** Left out for a shared recipient at connect level. */
|
|
114
|
+
credentialId?: number | null;
|
|
115
|
+
username?: string | null;
|
|
116
|
+
/** The declared non-secret credential fields. */
|
|
117
|
+
fields?: Record<string, string>;
|
|
118
|
+
/** Owner only. */
|
|
119
|
+
hasPassword?: boolean;
|
|
120
|
+
/** Owner only: the secret credential fields that hold a value. */
|
|
121
|
+
secretFieldKeys?: string[];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* One protocol's login in the host editor form (`form.protocolAuth[id]`).
|
|
125
|
+
* Core sends it with the host; `password` and secret fields hold
|
|
126
|
+
* HOST_PROTOCOL_SECRET_KEPT while the saved value is left alone.
|
|
127
|
+
*/
|
|
128
|
+
export interface HostProtocolAuthForm {
|
|
129
|
+
authType: HostProtocolAuthType;
|
|
130
|
+
credentialId: string;
|
|
131
|
+
username: string;
|
|
132
|
+
password: string;
|
|
133
|
+
fields: Record<string, string>;
|
|
134
|
+
}
|
|
135
|
+
/** Stands in for a saved protocol secret the editor has not changed. */
|
|
136
|
+
export declare const HOST_PROTOCOL_SECRET_KEPT = "existing_protocol_secret";
|
|
137
|
+
/** An open tab as the shell holds it. `data` is the plugin's own payload. */
|
|
138
|
+
export interface PluginTabRecord {
|
|
139
|
+
id: string;
|
|
140
|
+
type: string;
|
|
141
|
+
label: string;
|
|
142
|
+
host?: PluginHostRecord;
|
|
143
|
+
data?: Record<string, unknown>;
|
|
144
|
+
/** Stable across restores, for a session tab to reattach by. */
|
|
145
|
+
instanceId?: string;
|
|
146
|
+
/** A backend session a session tab should reattach to. */
|
|
147
|
+
restoredSessionId?: string | null;
|
|
148
|
+
[key: string]: unknown;
|
|
149
|
+
}
|
|
150
|
+
export interface OpenTabOptions {
|
|
151
|
+
label?: string;
|
|
152
|
+
/** Open a second tab even when one for this host and type exists. */
|
|
153
|
+
forceNewTab?: boolean;
|
|
154
|
+
/** Plugin payload, stored on the tab and restored with it. */
|
|
155
|
+
data?: Record<string, unknown>;
|
|
156
|
+
}
|
|
157
|
+
/** A saved arrangement of tabs, used by workspaces. Opaque to plugins. */
|
|
158
|
+
export interface ShellLayout {
|
|
159
|
+
version: number;
|
|
160
|
+
[key: string]: unknown;
|
|
161
|
+
}
|
|
162
|
+
/** What a plugin may ask of the shell. */
|
|
163
|
+
/** Fields a plugin can fill in when it opens the host editor. */
|
|
164
|
+
export interface HostDraft {
|
|
165
|
+
name?: string;
|
|
166
|
+
ip?: string;
|
|
167
|
+
port?: number;
|
|
168
|
+
username?: string;
|
|
169
|
+
authType?: string;
|
|
170
|
+
}
|
|
171
|
+
export interface ShellApi {
|
|
172
|
+
openTab: (host: PluginHostRecord | null, type: string, options?: OpenTabOptions) => void;
|
|
173
|
+
openSingletonTab: (type: string, options?: OpenTabOptions) => void;
|
|
174
|
+
/**
|
|
175
|
+
* Connects to a host the way clicking it in the host list does: its
|
|
176
|
+
* default connection, or `type` when given.
|
|
177
|
+
*/
|
|
178
|
+
connectHost: (host: PluginHostRecord, type?: string) => void;
|
|
179
|
+
closeTab: (tabId: string) => void;
|
|
180
|
+
renameTab: (tabId: string, label: string) => void;
|
|
181
|
+
/** Saves a quick-connect tab's host as a real host. Absent in some shells. */
|
|
182
|
+
saveQuickConnect?: (tab: PluginTabRecord, host: PluginHostRecord) => Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Opens the host editor for a new host with these fields filled in. The
|
|
185
|
+
* user reviews and saves it. Absent in some shells.
|
|
186
|
+
*/
|
|
187
|
+
openHostEditor?: (draft?: HostDraft) => void;
|
|
188
|
+
/** Opens a rail view in the left sidebar. */
|
|
189
|
+
openRailView: (id: string) => void;
|
|
190
|
+
/** Closes a rail view wherever it is shown. */
|
|
191
|
+
closeRailView: (id: string) => void;
|
|
192
|
+
/**
|
|
193
|
+
* Asks a yes or no question over the main area, for code that runs outside
|
|
194
|
+
* a panel or tab (a keybinding, a toolbar action). Inside one, prefer
|
|
195
|
+
* useConfirm from @termix-ssh/plugin-sdk/ui, which asks over that surface.
|
|
196
|
+
*/
|
|
197
|
+
confirm?: (options: ConfirmRequest) => Promise<boolean>;
|
|
198
|
+
}
|
|
199
|
+
export interface ConfirmRequest {
|
|
200
|
+
title: string;
|
|
201
|
+
description?: string;
|
|
202
|
+
confirmLabel?: string;
|
|
203
|
+
cancelLabel?: string;
|
|
204
|
+
/** Red confirm button. Defaults to true. */
|
|
205
|
+
destructive?: boolean;
|
|
206
|
+
}
|
|
207
|
+
export interface TabsApi extends Pick<ShellApi, "openTab" | "openSingletonTab" | "connectHost" | "closeTab" | "openRailView"> {
|
|
208
|
+
/** The current tabs and split layout, or null before the shell mounts. */
|
|
209
|
+
getLayout: () => ShellLayout | null;
|
|
210
|
+
/**
|
|
211
|
+
* Replaces the open tabs with a saved layout. `name` labels a restored
|
|
212
|
+
* split. Resolves with the tabs that could not be reopened, e.g. because
|
|
213
|
+
* their host was deleted.
|
|
214
|
+
*/
|
|
215
|
+
applyLayout: (layout: ShellLayout, options?: {
|
|
216
|
+
name?: string;
|
|
217
|
+
}) => Promise<{
|
|
218
|
+
skipped: string[];
|
|
219
|
+
}>;
|
|
220
|
+
/** Called whenever tabs open, close or move. */
|
|
221
|
+
onChange: (listener: () => void) => Disposer;
|
|
222
|
+
/** Called once the shell has restored its tabs after login. */
|
|
223
|
+
onReady: (listener: () => void) => Disposer;
|
|
224
|
+
}
|
|
225
|
+
export interface RailItemContribution {
|
|
226
|
+
/** Must be declared in manifest contributes.tabs or contributes.panels. */
|
|
227
|
+
id: string;
|
|
228
|
+
icon: IconComponent;
|
|
229
|
+
titleKey: string;
|
|
230
|
+
/** "panel" opens the left sidebar, "tab" opens a tab. Default "panel". */
|
|
231
|
+
kind?: "panel" | "tab";
|
|
232
|
+
/** Users may hide it from Appearance > Sidebar > Navigation. Default true. */
|
|
233
|
+
hideable?: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Stays visible in the Simple interface preset, which hides every other
|
|
236
|
+
* plugin rail item. For the one or two things a new user reaches for.
|
|
237
|
+
*/
|
|
238
|
+
simplePreset?: boolean;
|
|
239
|
+
/** Can also open as a full-width tab. */
|
|
240
|
+
promotable?: boolean;
|
|
241
|
+
/** Can open in the right dock. */
|
|
242
|
+
rightDockable?: boolean;
|
|
243
|
+
/** Shown on the mobile bar's primary row. */
|
|
244
|
+
mobilePrimary?: boolean;
|
|
245
|
+
/** Desktop app only. */
|
|
246
|
+
electronOnly?: boolean;
|
|
247
|
+
separatorAfter?: boolean;
|
|
248
|
+
/**
|
|
249
|
+
* Which band of the rail it sits in: things you keep (objects), things you
|
|
250
|
+
* do (tools) or the instance itself (system). Default "tools".
|
|
251
|
+
*/
|
|
252
|
+
group?: "objects" | "tools" | "system";
|
|
253
|
+
/** Hidden without being unregistered, e.g. while a feature is switched off. */
|
|
254
|
+
hidden?: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* A permission the user needs to see the item at all, usually one of the
|
|
257
|
+
* plugin's own short names. The rail, the mobile bar, the palette and the
|
|
258
|
+
* Navigation toggles all leave it out otherwise.
|
|
259
|
+
*/
|
|
260
|
+
permission?: string;
|
|
261
|
+
/** Place it after this rail id rather than at the end. */
|
|
262
|
+
after?: string;
|
|
263
|
+
/** Lower sorts first among plugin items. */
|
|
264
|
+
order?: number;
|
|
265
|
+
/**
|
|
266
|
+
* "footer" puts it at the bottom of the rail, above the user's profile,
|
|
267
|
+
* for something always at hand like an inbox. Default "main".
|
|
268
|
+
*/
|
|
269
|
+
placement?: "main" | "footer";
|
|
270
|
+
/**
|
|
271
|
+
* A hook the rail calls to show a count on the icon, e.g. unread alerts.
|
|
272
|
+
* Zero or nothing shows no badge.
|
|
273
|
+
*/
|
|
274
|
+
useBadge?: () => number | null | undefined;
|
|
275
|
+
}
|
|
276
|
+
export interface PanelProps {
|
|
277
|
+
/**
|
|
278
|
+
* The command-target tab (see TabOptions.commandTarget) the user is working
|
|
279
|
+
* in: the active one, else the one focused last. For panels that act on it.
|
|
280
|
+
*/
|
|
281
|
+
targetTab?: PluginTabRecord;
|
|
282
|
+
/** Whether the panel is the one currently shown. */
|
|
283
|
+
active: boolean;
|
|
284
|
+
shell: ShellApi;
|
|
285
|
+
/**
|
|
286
|
+
* Tells the shell the panel is editing, which widens the sidebar. "wide"
|
|
287
|
+
* widens it further for tables. InlineView does this on its own.
|
|
288
|
+
*/
|
|
289
|
+
setEditing: (editing: boolean | "wide") => void;
|
|
290
|
+
/** Type of the focused tab, if any. */
|
|
291
|
+
activeTabType?: string;
|
|
292
|
+
/** Where the panel is rendered. */
|
|
293
|
+
placement: "left" | "right" | "tab";
|
|
294
|
+
}
|
|
295
|
+
export interface PanelOptions {
|
|
296
|
+
/** Keep the panel mounted after the user switches away. */
|
|
297
|
+
keepMounted?: boolean;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* What a session tab hands the shell through `handleRef`, so split view, tab
|
|
301
|
+
* close and reconnect-all can drive it without knowing what kind it is.
|
|
302
|
+
*/
|
|
303
|
+
export interface TabHandle {
|
|
304
|
+
focus?: () => void;
|
|
305
|
+
fit?: () => void;
|
|
306
|
+
reconnect?: () => void;
|
|
307
|
+
/** Start a manual reconnect only when disconnected and idle; return whether it started. */
|
|
308
|
+
reconnectIfDisconnected?: () => boolean;
|
|
309
|
+
disconnect?: () => void;
|
|
310
|
+
isConnected?: () => boolean;
|
|
311
|
+
sendInput?: (data: string) => void;
|
|
312
|
+
paste?: (text: string) => void;
|
|
313
|
+
/** Repaint only. The shell calls it every time the tab becomes active. */
|
|
314
|
+
refresh?: () => void;
|
|
315
|
+
notifyResize?: () => void;
|
|
316
|
+
/** Asked before the tab closes; resolve false to keep it open. */
|
|
317
|
+
confirmClose?: () => boolean | Promise<boolean>;
|
|
318
|
+
[key: string]: unknown;
|
|
319
|
+
}
|
|
320
|
+
export interface TabProps {
|
|
321
|
+
tab: PluginTabRecord;
|
|
322
|
+
host?: PluginHostRecord;
|
|
323
|
+
/** The host in the shape the connection APIs take. */
|
|
324
|
+
sshHost?: Record<string, unknown>;
|
|
325
|
+
label: string;
|
|
326
|
+
isVisible: boolean;
|
|
327
|
+
/** The pane the user is working in, or the active tab outside a split. */
|
|
328
|
+
isFocusedPane: boolean;
|
|
329
|
+
/**
|
|
330
|
+
* Shown in a split pane next to other tabs. The shell moves focus between
|
|
331
|
+
* panes itself, so a tab should not grab focus on its own while this is set.
|
|
332
|
+
*/
|
|
333
|
+
inSplit?: boolean;
|
|
334
|
+
/** Forward to a component exposing `refresh()` or `disconnect()`. */
|
|
335
|
+
handleRef: Ref<unknown>;
|
|
336
|
+
shell: ShellApi;
|
|
337
|
+
}
|
|
338
|
+
export interface StandaloneViewProps {
|
|
339
|
+
hostId?: string;
|
|
340
|
+
view: string;
|
|
341
|
+
params: URLSearchParams;
|
|
342
|
+
}
|
|
343
|
+
export interface TabOptions {
|
|
344
|
+
icon?: IconComponent;
|
|
345
|
+
/** Label for singleton tabs and anywhere the type is named. */
|
|
346
|
+
titleKey?: string;
|
|
347
|
+
/** Needs a host; renders `noHostMessageKey` without one. */
|
|
348
|
+
requiresHost?: boolean;
|
|
349
|
+
noHostMessageKey?: string;
|
|
350
|
+
/** Reopened after login. */
|
|
351
|
+
persistent?: boolean;
|
|
352
|
+
/** One tab of this type at a time, keyed by type. */
|
|
353
|
+
singleton?: boolean;
|
|
354
|
+
/** A live session: asks before closing and can be refreshed. */
|
|
355
|
+
session?: boolean;
|
|
356
|
+
/** Restorable without a host. */
|
|
357
|
+
hostless?: boolean;
|
|
358
|
+
/** Decides whether a saved tab for this host may be restored. */
|
|
359
|
+
restore?: (host: PluginHostRecord) => boolean;
|
|
360
|
+
/** Recent-activity types that open this tab. */
|
|
361
|
+
activityTypes?: string[];
|
|
362
|
+
/** Rendered for `?view=<type>` full-screen links. */
|
|
363
|
+
standalone?: ComponentType<StandaloneViewProps>;
|
|
364
|
+
/** Extra `?view=` names that also open `standalone`. */
|
|
365
|
+
standaloneViews?: string[];
|
|
366
|
+
/** Wrap in the readable-width frame used by panels opened as tabs. */
|
|
367
|
+
panelFrame?: boolean;
|
|
368
|
+
/** False keeps the tab out of saved layouts and workspaces. Default true. */
|
|
369
|
+
inLayouts?: boolean;
|
|
370
|
+
/**
|
|
371
|
+
* Its session takes typed commands: the history, macros and SSH tools
|
|
372
|
+
* panels act on the one focused last.
|
|
373
|
+
*/
|
|
374
|
+
commandTarget?: boolean;
|
|
375
|
+
/** Paints its own background, so the shell leaves its frame transparent. */
|
|
376
|
+
ownBackground?: boolean;
|
|
377
|
+
/** Every open is a new tab, labelled "<title> (2)" and so on. */
|
|
378
|
+
multiInstance?: boolean;
|
|
379
|
+
/** Warms the tab's code before it is opened. */
|
|
380
|
+
preload?: () => Promise<unknown>;
|
|
381
|
+
}
|
|
382
|
+
export interface HostEditorSectionProps {
|
|
383
|
+
form: any;
|
|
384
|
+
setField: (key: string, value: unknown) => void;
|
|
385
|
+
/** Sets several fields at once, computed from the latest form. */
|
|
386
|
+
updateForm: (patch: (form: Record<string, unknown>) => Record<string, unknown>) => void;
|
|
387
|
+
host?: PluginHostRecord;
|
|
388
|
+
credentials?: unknown[];
|
|
389
|
+
/** Set while an admin edits another user's host from the admin panel. */
|
|
390
|
+
adminTargetUserId?: string;
|
|
391
|
+
/** Which connection protocols are switched on for this host. */
|
|
392
|
+
protocols: Record<string, boolean>;
|
|
393
|
+
/**
|
|
394
|
+
* "defaults" while the editor sets a level of host defaults (server, user
|
|
395
|
+
* or folder) rather than one host. There is no `host` then, and the form
|
|
396
|
+
* holds the defaults. Only a section registered with `defaults: true` is
|
|
397
|
+
* shown in that mode.
|
|
398
|
+
*/
|
|
399
|
+
mode?: "host" | "defaults";
|
|
400
|
+
}
|
|
401
|
+
export interface HostEditorSectionContribution {
|
|
402
|
+
id: string;
|
|
403
|
+
/** "top" sits in the main tab strip, "ssh" under the SSH group. */
|
|
404
|
+
group: "top" | "ssh";
|
|
405
|
+
titleKey: string;
|
|
406
|
+
icon?: IconComponent;
|
|
407
|
+
/**
|
|
408
|
+
* Position among the group's tabs, core ones included. Top: General 0,
|
|
409
|
+
* SSH 10. SSH group: General 0, Terminal 10, Tunnels 20, Files 60.
|
|
410
|
+
*/
|
|
411
|
+
order?: number;
|
|
412
|
+
/** Whether to offer the tab, from the host's enabled protocols. */
|
|
413
|
+
visible?: (protocols: Record<string, boolean>) => boolean;
|
|
414
|
+
/**
|
|
415
|
+
* Also shown in the host defaults editor. Only for a section whose fields
|
|
416
|
+
* are this plugin's host settings kept on the form, and that makes no
|
|
417
|
+
* calls about one particular host. Off by default. "only" shows it in the
|
|
418
|
+
* defaults editor and never for a host.
|
|
419
|
+
*/
|
|
420
|
+
defaults?: boolean | "only";
|
|
421
|
+
component: ComponentType<HostEditorSectionProps>;
|
|
422
|
+
}
|
|
423
|
+
export interface HostActionContribution {
|
|
424
|
+
id: string;
|
|
425
|
+
titleKey: string;
|
|
426
|
+
icon: IconComponent;
|
|
427
|
+
/**
|
|
428
|
+
* "connect" is a way to open a session (terminal, remote desktop) and is offered as a
|
|
429
|
+
* host's default action by priority. "open" opens a tool for the host.
|
|
430
|
+
*/
|
|
431
|
+
kind: "connect" | "open";
|
|
432
|
+
/** Higher wins when choosing a host's default connect action. */
|
|
433
|
+
priority?: number;
|
|
434
|
+
/** Opened with shell.openTab when `run` is absent. */
|
|
435
|
+
tabType?: string;
|
|
436
|
+
when: (host: PluginHostRecord) => boolean;
|
|
437
|
+
run?: (host: PluginHostRecord, shell: ShellApi) => void;
|
|
438
|
+
/** Shows a quick button on the host row. Default true. */
|
|
439
|
+
tray?: boolean;
|
|
440
|
+
/** `?view=` name for "Copy link". */
|
|
441
|
+
copyUrlView?: string;
|
|
442
|
+
/** Where a host overview (the dashboard's host status list) sends a click. */
|
|
443
|
+
overview?: boolean;
|
|
444
|
+
/**
|
|
445
|
+
* Offered as a button in Quick Connect, next to the default connect button,
|
|
446
|
+
* for an address that is never saved. Opens tabType.
|
|
447
|
+
*/
|
|
448
|
+
quickConnect?: boolean;
|
|
449
|
+
/**
|
|
450
|
+
* Position in the host row. Core: Files 20, Tunnel 40, Tmux 70. Connect
|
|
451
|
+
* actions default to 100 and sit after a separator.
|
|
452
|
+
*/
|
|
453
|
+
order?: number;
|
|
454
|
+
/** A label worked out per host, e.g. a single endpoint's name. */
|
|
455
|
+
label?: (host: PluginHostRecord) => string | undefined;
|
|
456
|
+
/** Several targets: two or more become a picker, one runs directly. */
|
|
457
|
+
items?: (host: PluginHostRecord) => {
|
|
458
|
+
id: string;
|
|
459
|
+
label: string;
|
|
460
|
+
run: (host: PluginHostRecord, shell: ShellApi) => void;
|
|
461
|
+
}[];
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* A connection protocol next to SSH, shown as a switch in the host editor's
|
|
465
|
+
* General tab and in host filters and Quick Connect. Its switch and port are
|
|
466
|
+
* this plugin's own host settings (declare both in contributes.settings.host).
|
|
467
|
+
*/
|
|
468
|
+
export interface HostProtocolContribution {
|
|
469
|
+
id: string;
|
|
470
|
+
/** Boolean host setting that turns the protocol on. */
|
|
471
|
+
settingKey: string;
|
|
472
|
+
/** Number host setting holding the port. */
|
|
473
|
+
portKey?: string;
|
|
474
|
+
defaultPort: number;
|
|
475
|
+
titleKey: string;
|
|
476
|
+
descriptionKey?: string;
|
|
477
|
+
/** Added to the host editor's connection origin help while the protocol is on. */
|
|
478
|
+
connectionOriginNoteKey?: string;
|
|
479
|
+
icon: IconComponent;
|
|
480
|
+
order?: number;
|
|
481
|
+
/** Offer it in Quick Connect, optionally with a domain field. */
|
|
482
|
+
quickConnect?: {
|
|
483
|
+
showDomain?: boolean;
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
export interface HostBadgeContribution {
|
|
487
|
+
id: string;
|
|
488
|
+
when: (host: PluginHostRecord) => boolean;
|
|
489
|
+
component: ComponentType<{
|
|
490
|
+
host: PluginHostRecord;
|
|
491
|
+
}>;
|
|
492
|
+
}
|
|
493
|
+
export interface HostContextMenuItemContribution {
|
|
494
|
+
id: string;
|
|
495
|
+
titleKey: string;
|
|
496
|
+
icon?: IconComponent;
|
|
497
|
+
when: (host: PluginHostRecord) => boolean;
|
|
498
|
+
run: (host: PluginHostRecord, shell: ShellApi) => void;
|
|
499
|
+
}
|
|
500
|
+
export interface PaletteEntryContribution {
|
|
501
|
+
id: string;
|
|
502
|
+
titleKey: string;
|
|
503
|
+
icon?: IconComponent;
|
|
504
|
+
keywords?: string[];
|
|
505
|
+
/** "global" entries stand alone, "host" entries appear under a host. */
|
|
506
|
+
scope: "global" | "host";
|
|
507
|
+
when?: (host?: PluginHostRecord) => boolean;
|
|
508
|
+
run: (shell: ShellApi, host?: PluginHostRecord) => void;
|
|
509
|
+
}
|
|
510
|
+
/** What a palette item's run gets. */
|
|
511
|
+
export interface PaletteRunContext {
|
|
512
|
+
/** The command-target tab the user is working in, if any. */
|
|
513
|
+
targetTab?: PluginTabRecord;
|
|
514
|
+
shell: ShellApi;
|
|
515
|
+
}
|
|
516
|
+
/** One searchable row in a palette group. */
|
|
517
|
+
export interface PaletteItem {
|
|
518
|
+
id: string;
|
|
519
|
+
/** Already translated; items are data, not keys. */
|
|
520
|
+
title: string;
|
|
521
|
+
description?: string;
|
|
522
|
+
icon?: IconComponent;
|
|
523
|
+
/** Extra words the search matches. */
|
|
524
|
+
keywords?: string[];
|
|
525
|
+
/** Acts on the command-target tab, so it is greyed out without one. */
|
|
526
|
+
needsTarget?: boolean;
|
|
527
|
+
/** Short text at the row's end, e.g. "Run in terminal". */
|
|
528
|
+
hint?: string;
|
|
529
|
+
run: (context: PaletteRunContext) => void;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* A group of items in the command palette, e.g. the user's snippets. `load`
|
|
533
|
+
* runs each time the palette opens; the palette filters the items by what
|
|
534
|
+
* the user types.
|
|
535
|
+
*/
|
|
536
|
+
export interface PaletteGroupContribution {
|
|
537
|
+
id: string;
|
|
538
|
+
titleKey: string;
|
|
539
|
+
/** Lower sorts first. */
|
|
540
|
+
order?: number;
|
|
541
|
+
load: () => PaletteItem[] | Promise<PaletteItem[]>;
|
|
542
|
+
/** Show the items before anything is typed. Default false. */
|
|
543
|
+
showWhenEmpty?: boolean;
|
|
544
|
+
}
|
|
545
|
+
/** A keybinding action's parameter editor in Appearance > Keybindings. */
|
|
546
|
+
export interface KeybindingActionEditorProps {
|
|
547
|
+
action: KeybindingAction;
|
|
548
|
+
onChange: (action: KeybindingAction) => void;
|
|
549
|
+
}
|
|
550
|
+
/** Where a keybinding action runs when the terminal hands it on. */
|
|
551
|
+
export interface KeybindingRunContext {
|
|
552
|
+
/** The session the key was pressed in. */
|
|
553
|
+
sessionId?: string;
|
|
554
|
+
host?: {
|
|
555
|
+
ip?: string;
|
|
556
|
+
username?: string;
|
|
557
|
+
port?: number | string;
|
|
558
|
+
name?: string;
|
|
559
|
+
} | null;
|
|
560
|
+
/** Writes raw input to that session. */
|
|
561
|
+
send?: (data: string) => void;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* A keybinding action. `id` is stored as the binding's action.type and must
|
|
565
|
+
* be declared in contributes.keybindingActions, which is what the server
|
|
566
|
+
* validates saved bindings against.
|
|
567
|
+
*/
|
|
568
|
+
export interface KeybindingActionContribution {
|
|
569
|
+
id: string;
|
|
570
|
+
titleKey: string;
|
|
571
|
+
/**
|
|
572
|
+
* "session" runs while a session tab such as a terminal has focus (the
|
|
573
|
+
* default). "global" runs anywhere in the app.
|
|
574
|
+
*/
|
|
575
|
+
scope?: "session" | "global";
|
|
576
|
+
/** Draws the action's parameters in the binding form. */
|
|
577
|
+
editor?: ComponentType<KeybindingActionEditorProps>;
|
|
578
|
+
/** Drawn after the action's name in the binding list, e.g. a warning. */
|
|
579
|
+
summary?: ComponentType<KeybindingActionEditorProps>;
|
|
580
|
+
/** A plugin translation key when the action cannot be saved yet. */
|
|
581
|
+
validate?: (action: KeybindingAction) => string | null;
|
|
582
|
+
/**
|
|
583
|
+
* Runs it. A terminal hands on every bound action it does not handle
|
|
584
|
+
* itself; a global action runs from anywhere.
|
|
585
|
+
*/
|
|
586
|
+
run?: (action: KeybindingAction, context: KeybindingRunContext) => void;
|
|
587
|
+
}
|
|
588
|
+
/** A built-in key the user can rebind in Appearance > Keybindings. */
|
|
589
|
+
export interface KeybindingDefaultContribution {
|
|
590
|
+
id: string;
|
|
591
|
+
combo: KeyCombo;
|
|
592
|
+
descriptionKey: string;
|
|
593
|
+
}
|
|
594
|
+
export interface DashboardCardProps {
|
|
595
|
+
isVisible: boolean;
|
|
596
|
+
shell: ShellApi;
|
|
597
|
+
}
|
|
598
|
+
export interface DashboardCardContribution {
|
|
599
|
+
/** Must be declared in manifest contributes.dashboardCards. */
|
|
600
|
+
id: string;
|
|
601
|
+
titleKey: string;
|
|
602
|
+
defaultHeight?: number;
|
|
603
|
+
/** Which column a preset places this card in by default. Defaults to "main". */
|
|
604
|
+
defaultPanel?: "main" | "side";
|
|
605
|
+
/**
|
|
606
|
+
* "framed" draws a titled header over the card, "bare" lets it run edge to
|
|
607
|
+
* edge, for a strip of numbers. Defaults to "framed".
|
|
608
|
+
*/
|
|
609
|
+
frame?: "framed" | "bare";
|
|
610
|
+
component: ComponentType<DashboardCardProps>;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* One item in a named list another plugin reads (app.registerExtension). The
|
|
614
|
+
* reading plugin owns the point id and the item shape. Components go under
|
|
615
|
+
* `components` so core can scope them to the registering plugin.
|
|
616
|
+
*/
|
|
617
|
+
export interface ExtensionContribution {
|
|
618
|
+
id: string;
|
|
619
|
+
/** Set by core to the registering plugin's id; a plugin never sets this itself. */
|
|
620
|
+
pluginId?: string;
|
|
621
|
+
components?: Record<string, ComponentType<any>>;
|
|
622
|
+
[key: string]: unknown;
|
|
623
|
+
}
|
|
624
|
+
export interface SettingsComponentProps {
|
|
625
|
+
pluginId: string;
|
|
626
|
+
values: Record<string, unknown>;
|
|
627
|
+
setValue: (key: string, value: unknown) => void;
|
|
628
|
+
running: boolean;
|
|
629
|
+
}
|
|
630
|
+
export type ActionHandler = (...args: never[]) => unknown;
|
|
631
|
+
export interface ActionSlotDefinition {
|
|
632
|
+
id: string;
|
|
633
|
+
/** Contribution kinds the slot renders: "button", "component". */
|
|
634
|
+
accepts: string[];
|
|
635
|
+
}
|
|
636
|
+
export interface SlotContribution {
|
|
637
|
+
actionId: string;
|
|
638
|
+
titleKey: string;
|
|
639
|
+
/** Secondary text, for slots that show one (onboarding cards). */
|
|
640
|
+
descriptionKey?: string;
|
|
641
|
+
icon?: IconComponent;
|
|
642
|
+
kind?: "button" | "component" | string;
|
|
643
|
+
/** For kind "component". Receives the slot owner's props. */
|
|
644
|
+
component?: ComponentType<Record<string, unknown>>;
|
|
645
|
+
/** Extra condition on top of the action's permission. */
|
|
646
|
+
when?: (context: Record<string, unknown>) => boolean;
|
|
647
|
+
order?: number;
|
|
648
|
+
}
|
|
649
|
+
export interface SshAuthEditorProps {
|
|
650
|
+
form: Record<string, unknown>;
|
|
651
|
+
setField: (key: string, value: unknown) => void;
|
|
652
|
+
}
|
|
653
|
+
export interface SshAuthEditorContribution {
|
|
654
|
+
/** The value stored in the host's authType. */
|
|
655
|
+
authType: string;
|
|
656
|
+
titleKey: string;
|
|
657
|
+
hintKey?: string;
|
|
658
|
+
component?: ComponentType<SshAuthEditorProps>;
|
|
659
|
+
}
|
|
660
|
+
/** What the login screen hands a login method's UI. */
|
|
661
|
+
export interface LoginMethodUIProps {
|
|
662
|
+
methodId: string;
|
|
663
|
+
/** Enabled instances from the server, e.g. one per SSO provider. */
|
|
664
|
+
instances: Array<{
|
|
665
|
+
id: string;
|
|
666
|
+
label: string;
|
|
667
|
+
}>;
|
|
668
|
+
rememberMe: boolean;
|
|
669
|
+
disabled: boolean;
|
|
670
|
+
/** What the user typed in the username field, when there is one. */
|
|
671
|
+
username?: string;
|
|
672
|
+
/**
|
|
673
|
+
* Form methods: posts the body to the method's verify endpoint, then the
|
|
674
|
+
* login screen finishes the login or shows the second-factor step.
|
|
675
|
+
*/
|
|
676
|
+
submit: (body: Record<string, unknown>, instanceId?: string) => Promise<void>;
|
|
677
|
+
/** Redirect methods: sends the browser (or the system browser) away. */
|
|
678
|
+
startRedirect: (instanceId?: string) => Promise<void>;
|
|
679
|
+
/** Hands a login response from a request the UI made itself. */
|
|
680
|
+
complete: (response: Record<string, unknown>) => Promise<void>;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* A button or form on the login screen. `id` matches the login method the
|
|
684
|
+
* backend registered with ctx.auth.registerLoginMethod; the screen shows it
|
|
685
|
+
* only while the server reports that method as enabled.
|
|
686
|
+
*/
|
|
687
|
+
export interface LoginMethodContribution {
|
|
688
|
+
id: string;
|
|
689
|
+
titleKey: string;
|
|
690
|
+
icon?: IconComponent;
|
|
691
|
+
component: ComponentType<LoginMethodUIProps>;
|
|
692
|
+
/**
|
|
693
|
+
* "inline" also draws the method under the password form, for a local
|
|
694
|
+
* method people use instead of a password (a passkey). Otherwise it only
|
|
695
|
+
* shows in the list of other sign-in methods.
|
|
696
|
+
*/
|
|
697
|
+
placement?: "inline";
|
|
698
|
+
/** Enrolment, shown in Settings > Security (registering a passkey). */
|
|
699
|
+
enrollment?: ComponentType<Record<string, unknown>>;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* How an SSH keyboard-interactive prompt is shown by TOTPDialog: a code field
|
|
703
|
+
* (the default), a password, a menu choice, or a push approval.
|
|
704
|
+
*/
|
|
705
|
+
export type MFAPromptMode = "totp" | "password" | "menu" | "push";
|
|
706
|
+
/** What the second-factor step hands a factor's UI. */
|
|
707
|
+
export interface SecondFactorUIProps {
|
|
708
|
+
factorId: string;
|
|
709
|
+
rememberMe: boolean;
|
|
710
|
+
disabled: boolean;
|
|
711
|
+
/** Sends the user's answer; the login screen finishes or shows the error. */
|
|
712
|
+
verify: (body: Record<string, unknown>) => Promise<void>;
|
|
713
|
+
/** Whatever the backend factor's challenge() returns. */
|
|
714
|
+
challenge: () => Promise<unknown>;
|
|
715
|
+
cancel: () => void;
|
|
716
|
+
}
|
|
717
|
+
export interface SecondFactorContribution {
|
|
718
|
+
/** Matches the id the backend registered with ctx.auth.registerSecondFactor. */
|
|
719
|
+
id: string;
|
|
720
|
+
titleKey: string;
|
|
721
|
+
/** The challenge shown after the first login step. */
|
|
722
|
+
component: ComponentType<SecondFactorUIProps>;
|
|
723
|
+
/** Enrolment, shown in Settings > Security. */
|
|
724
|
+
enrollment?: ComponentType<Record<string, unknown>>;
|
|
725
|
+
}
|
|
726
|
+
/** The subset of axios a plugin uses, rooted at /plugin-api/<id>/. */
|
|
727
|
+
export interface PluginApiClient {
|
|
728
|
+
get<T = unknown>(url: string, config?: unknown): Promise<{
|
|
729
|
+
data: T;
|
|
730
|
+
}>;
|
|
731
|
+
delete<T = unknown>(url: string, config?: unknown): Promise<{
|
|
732
|
+
data: T;
|
|
733
|
+
}>;
|
|
734
|
+
post<T = unknown>(url: string, body?: unknown, config?: unknown): Promise<{
|
|
735
|
+
data: T;
|
|
736
|
+
}>;
|
|
737
|
+
put<T = unknown>(url: string, body?: unknown, config?: unknown): Promise<{
|
|
738
|
+
data: T;
|
|
739
|
+
}>;
|
|
740
|
+
patch<T = unknown>(url: string, body?: unknown, config?: unknown): Promise<{
|
|
741
|
+
data: T;
|
|
742
|
+
}>;
|
|
743
|
+
}
|
|
744
|
+
export interface PluginWsTarget {
|
|
745
|
+
url: string;
|
|
746
|
+
protocols?: string[];
|
|
747
|
+
}
|
|
748
|
+
/** Where the frontend runs, for a plugin that behaves differently in the desktop app. */
|
|
749
|
+
export interface DesktopApi {
|
|
750
|
+
/** True inside the Termix desktop app. */
|
|
751
|
+
readonly available: boolean;
|
|
752
|
+
/**
|
|
753
|
+
* The remote server the desktop app is connected to for sync, or null
|
|
754
|
+
* outside the desktop app and while it runs standalone.
|
|
755
|
+
*/
|
|
756
|
+
remoteServerUrl: () => Promise<string | null>;
|
|
757
|
+
/** Called when the desktop app connects to or leaves a remote server. */
|
|
758
|
+
onRemoteServerChange: (listener: () => void) => Disposer;
|
|
759
|
+
}
|
|
760
|
+
export interface TermixAppInfo {
|
|
761
|
+
readonly pluginId: string;
|
|
762
|
+
readonly manifest: PluginManifest;
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* Registration surface for a plugin frontend. Every `register*` returns a
|
|
766
|
+
* disposer, and anything not disposed by hand is disposed when the plugin is
|
|
767
|
+
* disabled.
|
|
768
|
+
*/
|
|
769
|
+
export interface TermixApp extends TermixAppInfo {
|
|
770
|
+
/**
|
|
771
|
+
* True on anonymous guest pages (a shared-session link). Only plugins with
|
|
772
|
+
* contributes.guest run there, and they should register just what a guest
|
|
773
|
+
* sees: there is no user, so API calls needing a login will fail.
|
|
774
|
+
*/
|
|
775
|
+
readonly guest: boolean;
|
|
776
|
+
registerRailItem: (item: RailItemContribution) => Disposer;
|
|
777
|
+
registerPanel: (id: string, component: ComponentType<PanelProps>, options?: PanelOptions) => Disposer;
|
|
778
|
+
registerTab: (type: string, component: ComponentType<TabProps>, options?: TabOptions) => Disposer;
|
|
779
|
+
registerHostEditorSection: (section: HostEditorSectionContribution) => Disposer;
|
|
780
|
+
registerHostAction: (action: HostActionContribution) => Disposer;
|
|
781
|
+
registerHostProtocol: (protocol: HostProtocolContribution) => Disposer;
|
|
782
|
+
registerHostBadge: (badge: HostBadgeContribution) => Disposer;
|
|
783
|
+
registerHostContextMenuItem: (item: HostContextMenuItemContribution) => Disposer;
|
|
784
|
+
registerPaletteEntry: (entry: PaletteEntryContribution) => Disposer;
|
|
785
|
+
registerPaletteGroup: (group: PaletteGroupContribution) => Disposer;
|
|
786
|
+
registerKeybindingAction: (action: KeybindingActionContribution) => Disposer;
|
|
787
|
+
registerKeybindingDefault: (binding: KeybindingDefaultContribution) => Disposer;
|
|
788
|
+
registerDashboardCard: (card: DashboardCardContribution) => Disposer;
|
|
789
|
+
registerExtension: (pointId: string, extension: ExtensionContribution) => Disposer;
|
|
790
|
+
/**
|
|
791
|
+
* Every host the user can see, fetched now. Like every host record a plugin
|
|
792
|
+
* gets, `pluginSettings` holds only this plugin's own settings.
|
|
793
|
+
*/
|
|
794
|
+
listHosts: () => Promise<PluginHostRecord[]>;
|
|
795
|
+
/** A saved host from the shell's list, or undefined. No request is made. */
|
|
796
|
+
getHost: (hostId: string | number) => PluginHostRecord | undefined;
|
|
797
|
+
registerSettingsComponent: (componentId: string, component: ComponentType<SettingsComponentProps>) => Disposer;
|
|
798
|
+
registerAction: (id: string, handler: ActionHandler, options?: {
|
|
799
|
+
permission?: string;
|
|
800
|
+
}) => Disposer;
|
|
801
|
+
declareActionSlot: (slot: ActionSlotDefinition) => Disposer;
|
|
802
|
+
registerSlotContribution: (slotId: string, contribution: SlotContribution) => Disposer;
|
|
803
|
+
invokeAction: (id: string, ...args: unknown[]) => Promise<unknown>;
|
|
804
|
+
/**
|
|
805
|
+
* Offers a component to other plugins and to core by id, rendered where
|
|
806
|
+
* they choose with `PluginComponent` from @termix-ssh/plugin-sdk/ui or
|
|
807
|
+
* `usePluginComponent`. The id should start with a name the plugin owns
|
|
808
|
+
* ("terminal.view"). The props are the owner's contract; document them.
|
|
809
|
+
*/
|
|
810
|
+
registerComponent: (id: string, component: ComponentType<Record<string, unknown>>) => Disposer;
|
|
811
|
+
registerSshAuthEditor: (editor: SshAuthEditorContribution) => Disposer;
|
|
812
|
+
registerLoginMethod: (method: LoginMethodContribution) => Disposer;
|
|
813
|
+
registerSecondFactorUI: (factor: SecondFactorContribution) => Disposer;
|
|
814
|
+
/**
|
|
815
|
+
* Translates a key from the plugin's own locales, for code outside a
|
|
816
|
+
* component (a toast from activate). Components use useTranslation().
|
|
817
|
+
*/
|
|
818
|
+
t: TranslateFn;
|
|
819
|
+
/**
|
|
820
|
+
* Whether the current user holds a permission, for code outside a
|
|
821
|
+
* component. A short name resolves to <id>.<name>, as usePermission does.
|
|
822
|
+
* Resolves false before sign-in and when the lookup fails.
|
|
823
|
+
*/
|
|
824
|
+
hasPermission: (permission: string) => Promise<boolean>;
|
|
825
|
+
/** HTTP client for this plugin's /plugin-api/<id>/ routes. */
|
|
826
|
+
api: PluginApiClient;
|
|
827
|
+
/**
|
|
828
|
+
* The same client for a resolved connection origin: "remote" reaches the
|
|
829
|
+
* desktop app's connected remote server, anything else is `api`.
|
|
830
|
+
*/
|
|
831
|
+
apiFor: (origin?: unknown) => PluginApiClient;
|
|
832
|
+
/**
|
|
833
|
+
* A raw fetch on /plugin-api/<id>/<path> with core's auth, for a response
|
|
834
|
+
* read as a stream (server-sent events), which `api` cannot do.
|
|
835
|
+
*/
|
|
836
|
+
fetch: (path: string, init?: RequestInit) => Promise<Response>;
|
|
837
|
+
/** WebSocket URL and auth subprotocols for /plugin-ws/<id>/<path>. */
|
|
838
|
+
wsUrl: (path: string, options?: {
|
|
839
|
+
origin?: unknown;
|
|
840
|
+
}) => Promise<PluginWsTarget | null>;
|
|
841
|
+
tabs: TabsApi;
|
|
842
|
+
/**
|
|
843
|
+
* Asks a yes or no question over the main area. For code that runs outside
|
|
844
|
+
* a panel or tab; inside one, useConfirm from @termix-ssh/plugin-sdk/ui asks
|
|
845
|
+
* over that surface instead.
|
|
846
|
+
*/
|
|
847
|
+
confirm: (options: ConfirmRequest) => Promise<boolean>;
|
|
848
|
+
/** The desktop app, when the frontend runs in it. */
|
|
849
|
+
desktop: DesktopApi;
|
|
850
|
+
/**
|
|
851
|
+
* Fires after this plugin's settings are saved from the settings screen or
|
|
852
|
+
* the host editor. Disposed automatically.
|
|
853
|
+
*/
|
|
854
|
+
onSettingsChanged: (listener: (change: {
|
|
855
|
+
scope: "admin" | "user" | "host";
|
|
856
|
+
hostId?: number;
|
|
857
|
+
}) => void) => Disposer;
|
|
858
|
+
/** Registered cleanup, run when the plugin is disabled. */
|
|
859
|
+
onDispose: (dispose: Disposer) => void;
|
|
860
|
+
}
|
|
861
|
+
export type FrontendActivate = (app: TermixApp) => void | Promise<void>;
|
|
862
|
+
export interface FrontendModule {
|
|
863
|
+
activate: FrontendActivate;
|
|
864
|
+
deactivate?: () => void | Promise<void>;
|
|
865
|
+
}
|
|
866
|
+
export declare function definePluginFrontend(plugin: FrontendModule): FrontendModule;
|
|
867
|
+
export type TranslateFn = (key: string, options?: Record<string, unknown> | string) => string;
|
|
868
|
+
export interface CurrentUser {
|
|
869
|
+
userId: string;
|
|
870
|
+
username: string;
|
|
871
|
+
isAdmin: boolean;
|
|
872
|
+
}
|
|
873
|
+
export interface ToastApi {
|
|
874
|
+
success: (message: string) => void;
|
|
875
|
+
error: (message: string) => void;
|
|
876
|
+
info: (message: string) => void;
|
|
877
|
+
warning: (message: string) => void;
|
|
878
|
+
}
|
|
879
|
+
export type SettingsScope = "admin" | "user" | "host";
|
|
880
|
+
export interface SettingsState {
|
|
881
|
+
values: Record<string, unknown>;
|
|
882
|
+
loaded: boolean;
|
|
883
|
+
save: (values: Record<string, unknown>) => Promise<void>;
|
|
884
|
+
}
|
|
885
|
+
/** An SSH auth type the server can connect with. */
|
|
886
|
+
export interface SshAuthTypeInfo {
|
|
887
|
+
type: string;
|
|
888
|
+
/** Core translation key, or the plugin editor's title. */
|
|
889
|
+
labelKey: string;
|
|
890
|
+
pluginId: string;
|
|
891
|
+
/** Also offered as a stored credential type. */
|
|
892
|
+
credentialType: boolean;
|
|
893
|
+
/** Can connect unattended, for polling. */
|
|
894
|
+
supportsBackground: boolean;
|
|
895
|
+
/** Offered in Quick Connect, for a host that is never saved. */
|
|
896
|
+
quickConnect: boolean;
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* What core implements behind the hooks. Internal: a plugin never calls this.
|
|
900
|
+
*/
|
|
901
|
+
export interface PluginHostBridge {
|
|
902
|
+
usePluginId: () => string;
|
|
903
|
+
useTranslation: (pluginId: string) => {
|
|
904
|
+
t: TranslateFn;
|
|
905
|
+
language: string;
|
|
906
|
+
};
|
|
907
|
+
usePermission: (pluginId: string, permission: string) => boolean;
|
|
908
|
+
useSettings: (pluginId: string, scope: SettingsScope, hostId?: number | string) => SettingsState;
|
|
909
|
+
useHost: (hostId: string | number | undefined) => PluginHostRecord | null;
|
|
910
|
+
useHosts: () => {
|
|
911
|
+
hosts: PluginHostRecord[];
|
|
912
|
+
loaded: boolean;
|
|
913
|
+
};
|
|
914
|
+
useCurrentUser: () => CurrentUser | null;
|
|
915
|
+
useTheme: () => {
|
|
916
|
+
theme: "light" | "dark";
|
|
917
|
+
};
|
|
918
|
+
toast: ToastApi;
|
|
919
|
+
getApi: (pluginId: string) => PluginApiClient;
|
|
920
|
+
getApiFor: (pluginId: string, origin: unknown) => PluginApiClient;
|
|
921
|
+
useTabs: () => TabsApi;
|
|
922
|
+
invokeAction: (id: string, ...args: unknown[]) => Promise<unknown>;
|
|
923
|
+
useSshAuthTypes: () => {
|
|
924
|
+
types: SshAuthTypeInfo[];
|
|
925
|
+
loaded: boolean;
|
|
926
|
+
};
|
|
927
|
+
useSlotContributions: (slotId: string, context?: Record<string, unknown>) => SlotContribution[];
|
|
928
|
+
usePluginComponent: (id: string) => ComponentType<Record<string, unknown>> | undefined;
|
|
929
|
+
hostProtocols: (host: PluginHostRecord) => string[];
|
|
930
|
+
useHostStatus: (hostId: number | undefined) => HostStatusInfo | null;
|
|
931
|
+
useHostActions: () => HostActionContribution[];
|
|
932
|
+
useActivityTypes: () => string[];
|
|
933
|
+
activityTarget: (type: string) => ActivityTargetInfo | undefined;
|
|
934
|
+
useExtensions: (pointId: string) => ExtensionContribution[];
|
|
935
|
+
getExtension: (pointId: string, id: string) => ExtensionContribution | undefined;
|
|
936
|
+
core: PluginCoreApi;
|
|
937
|
+
usePluginUiPreferences: (pluginId: string) => {
|
|
938
|
+
values: Record<string, unknown>;
|
|
939
|
+
set: (key: string, value: unknown) => void;
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
/** A key combination a user bound in Appearance > Keybindings. */
|
|
943
|
+
export interface KeyCombo {
|
|
944
|
+
key: string;
|
|
945
|
+
isCode: boolean;
|
|
946
|
+
ctrl: boolean;
|
|
947
|
+
alt: boolean;
|
|
948
|
+
shift: boolean;
|
|
949
|
+
meta: boolean;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* The shell's own actions (nextTab, previousTab, openCommandPalette,
|
|
953
|
+
* reconnectSession) or one a plugin declared in contributes.keybindingActions.
|
|
954
|
+
*/
|
|
955
|
+
export type KeybindingActionType = string;
|
|
956
|
+
/** A bound action: its type plus the parameters its declaration lists. */
|
|
957
|
+
export interface KeybindingAction {
|
|
958
|
+
type: KeybindingActionType;
|
|
959
|
+
[param: string]: unknown;
|
|
960
|
+
}
|
|
961
|
+
export interface CustomKeybinding {
|
|
962
|
+
id: string;
|
|
963
|
+
combo: KeyCombo;
|
|
964
|
+
action: KeybindingAction;
|
|
965
|
+
enabled: boolean;
|
|
966
|
+
overridesDefaultId?: string;
|
|
967
|
+
createdAt: string;
|
|
968
|
+
updatedAt: string;
|
|
969
|
+
}
|
|
970
|
+
/** Core calls a plugin frontend makes for the signed-in user. */
|
|
971
|
+
export interface PluginCoreApi {
|
|
972
|
+
/** Adds a recent-activity entry. `type` is one of the plugin's activityTypes. */
|
|
973
|
+
logActivity: (type: string, hostId: number, hostName: string) => Promise<void>;
|
|
974
|
+
/** A host's stored password or sudo password, for autofill. Null when unset. */
|
|
975
|
+
getHostPassword: (hostId: number, field: "password" | "sudoPassword") => Promise<string | null>;
|
|
976
|
+
/** Updates the saved open-tab record a page reload reattaches from. */
|
|
977
|
+
patchOpenTab: (instanceId: string, updates: {
|
|
978
|
+
hostId?: number;
|
|
979
|
+
label?: string;
|
|
980
|
+
tabOrder?: number;
|
|
981
|
+
backendSessionId?: string | null;
|
|
982
|
+
}) => Promise<void>;
|
|
983
|
+
/** The user's custom keybindings, enabled or not. */
|
|
984
|
+
getCustomKeybindings: () => Promise<CustomKeybinding[]>;
|
|
985
|
+
/**
|
|
986
|
+
* Runs a bound action through whoever registered it (a plugin's
|
|
987
|
+
* registerKeybindingAction, or the shell for its own). False when nothing
|
|
988
|
+
* running handles that type.
|
|
989
|
+
*/
|
|
990
|
+
runKeybindingAction: (action: KeybindingAction, context?: KeybindingRunContext) => boolean;
|
|
991
|
+
/** A browser-side UI preference (a cookie, or the desktop app's store). */
|
|
992
|
+
getClientPreference: (name: string) => string | undefined;
|
|
993
|
+
/** Saves a browser-side UI preference where getClientPreference reads it. */
|
|
994
|
+
setClientPreference: (name: string, value: string) => void;
|
|
995
|
+
/**
|
|
996
|
+
* Every host the user can see, fetched now rather than from the shell's
|
|
997
|
+
* cache, carrying only `pluginId`'s host settings.
|
|
998
|
+
*/
|
|
999
|
+
listHosts: (pluginId: string) => Promise<PluginHostRecord[]>;
|
|
1000
|
+
/** The user's stored credentials, without their secrets. */
|
|
1001
|
+
listCredentials: () => Promise<PluginCredentialSummary[]>;
|
|
1002
|
+
/** Tells the shell hosts were added or changed, so lists reload. */
|
|
1003
|
+
notifyHostsChanged: () => void;
|
|
1004
|
+
/** How the user wants host status shown: the brand accent, or green/red. */
|
|
1005
|
+
getHostStatusColorScheme: () => "accent" | "status";
|
|
1006
|
+
/**
|
|
1007
|
+
* The token the desktop app's embedded backend accepts, for work the
|
|
1008
|
+
* desktop main process does on the renderer's behalf. Null in a browser.
|
|
1009
|
+
*/
|
|
1010
|
+
getLocalAuthToken: () => string | null;
|
|
1011
|
+
}
|
|
1012
|
+
/** A stored credential as a picker needs it. Secrets never leave core. */
|
|
1013
|
+
export interface PluginCredentialSummary {
|
|
1014
|
+
id: number;
|
|
1015
|
+
name: string;
|
|
1016
|
+
username?: string;
|
|
1017
|
+
authType?: string;
|
|
1018
|
+
}
|
|
1019
|
+
/** What a recent-activity entry opens and how it is labelled. */
|
|
1020
|
+
export interface ActivityTargetInfo {
|
|
1021
|
+
icon?: IconComponent;
|
|
1022
|
+
/** Tab type the entry reopens. */
|
|
1023
|
+
tab: string;
|
|
1024
|
+
titleKey?: string;
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Core's status for a host, the one behind the host list's dot. online: the
|
|
1028
|
+
* port answers. offline: it does not. unknown: not checked yet. "reachable"
|
|
1029
|
+
* is no longer sent and stays only so older plugins still type check.
|
|
1030
|
+
*/
|
|
1031
|
+
export interface HostStatusInfo {
|
|
1032
|
+
status: "online" | "reachable" | "offline" | "unknown";
|
|
1033
|
+
/** @deprecated No longer sent. */
|
|
1034
|
+
reason?: "host_key_changed";
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* Called once by core, before any plugin loads. Not part of the plugin API:
|
|
1038
|
+
* once set it cannot be swapped, so a plugin cannot replace the bridge every
|
|
1039
|
+
* other plugin talks through.
|
|
1040
|
+
*/
|
|
1041
|
+
export declare function __setPluginHost(bridge: PluginHostBridge | null): void;
|
|
1042
|
+
/** The id of the plugin that registered the component being rendered. */
|
|
1043
|
+
export declare function usePluginId(): string;
|
|
1044
|
+
/**
|
|
1045
|
+
* Translation bound to this plugin's namespace. Keys the plugin does not
|
|
1046
|
+
* define fall back to core's shared strings (common.*, hosts.*).
|
|
1047
|
+
*/
|
|
1048
|
+
export declare function useTranslation(): {
|
|
1049
|
+
t: TranslateFn;
|
|
1050
|
+
language: string;
|
|
1051
|
+
};
|
|
1052
|
+
/**
|
|
1053
|
+
* Whether the current user holds a permission. A short name resolves to this
|
|
1054
|
+
* plugin's own namespace, a dotted id is taken as given. UI only: the backend
|
|
1055
|
+
* route checks again.
|
|
1056
|
+
*/
|
|
1057
|
+
export declare function usePermission(permission: string): boolean;
|
|
1058
|
+
export declare function useSettings(scope: SettingsScope, hostId?: number | string): SettingsState;
|
|
1059
|
+
export declare function useHost(hostId: string | number | undefined): PluginHostRecord | null;
|
|
1060
|
+
export declare function useHosts(): {
|
|
1061
|
+
hosts: PluginHostRecord[];
|
|
1062
|
+
loaded: boolean;
|
|
1063
|
+
};
|
|
1064
|
+
/**
|
|
1065
|
+
* Core's status for one host, kept current by the shell's own polling. Null
|
|
1066
|
+
* outside the app shell (a standalone window) and for hosts with status
|
|
1067
|
+
* checks off.
|
|
1068
|
+
*/
|
|
1069
|
+
export declare function useHostStatus(hostId: number | undefined): HostStatusInfo | null;
|
|
1070
|
+
export declare function useCurrentUser(): CurrentUser | null;
|
|
1071
|
+
export declare function useTheme(): {
|
|
1072
|
+
theme: "light" | "dark";
|
|
1073
|
+
};
|
|
1074
|
+
export declare function useToast(): ToastApi;
|
|
1075
|
+
export declare function logActivity(type: string, hostId: number, hostName: string): Promise<void>;
|
|
1076
|
+
/** Tells the shell hosts were added or changed, so its lists reload. */
|
|
1077
|
+
export declare function notifyHostsChanged(): void;
|
|
1078
|
+
/** How the user wants host status shown: the brand accent, or green/red. */
|
|
1079
|
+
export declare function getHostStatusColorScheme(): "accent" | "status";
|
|
1080
|
+
/** The desktop app's local backend token, or null in a browser. */
|
|
1081
|
+
export declare function getLocalAuthToken(): string | null;
|
|
1082
|
+
export declare function getHostPassword(hostId: number, field: "password" | "sudoPassword"): Promise<string | null>;
|
|
1083
|
+
export declare function patchOpenTab(instanceId: string, updates: Parameters<PluginCoreApi["patchOpenTab"]>[1]): Promise<void>;
|
|
1084
|
+
export declare function getCustomKeybindings(): Promise<CustomKeybinding[]>;
|
|
1085
|
+
export declare function runKeybindingAction(action: KeybindingAction, context?: KeybindingRunContext): boolean;
|
|
1086
|
+
export declare function getClientPreference(name: string): string | undefined;
|
|
1087
|
+
export declare function setClientPreference(name: string, value: string): void;
|
|
1088
|
+
export declare function listCredentials(): Promise<PluginCredentialSummary[]>;
|
|
1089
|
+
export declare function usePluginApi(): PluginApiClient;
|
|
1090
|
+
/**
|
|
1091
|
+
* This plugin's client for a resolved connection origin: "remote" reaches the
|
|
1092
|
+
* desktop app's connected remote server, anything else is usePluginApi's.
|
|
1093
|
+
*/
|
|
1094
|
+
export declare function usePluginApiFor(origin: unknown): PluginApiClient;
|
|
1095
|
+
/**
|
|
1096
|
+
* This plugin's Appearance area: the preset it declared in
|
|
1097
|
+
* contributes.uiPresets for the user's level, with the user's changes on top.
|
|
1098
|
+
* `set` saves one change; null clears it back to the preset.
|
|
1099
|
+
*/
|
|
1100
|
+
export declare function usePluginUiPreferences<T extends Record<string, unknown> = Record<string, unknown>>(): {
|
|
1101
|
+
values: T;
|
|
1102
|
+
set: <K extends keyof T & string>(key: K, value: T[K] | null) => void;
|
|
1103
|
+
};
|
|
1104
|
+
/**
|
|
1105
|
+
* Grid or list and row density for one of this plugin's views, kept in its
|
|
1106
|
+
* Appearance area as `<prefix>viewMode` and `<prefix>density`. Declare those
|
|
1107
|
+
* keys in contributes.uiPresets so each preset level can pick a default.
|
|
1108
|
+
*/
|
|
1109
|
+
export declare function usePluginPanelView(prefix?: string): {
|
|
1110
|
+
view: "grid" | "list";
|
|
1111
|
+
density: "comfortable" | "compact";
|
|
1112
|
+
compact: boolean;
|
|
1113
|
+
setView: (view: "grid" | "list") => void;
|
|
1114
|
+
setDensity: (density: "comfortable" | "compact") => void;
|
|
1115
|
+
};
|
|
1116
|
+
export declare function useTabs(): TabsApi;
|
|
1117
|
+
/**
|
|
1118
|
+
* The SSH auth types this server can connect with, core's and every enabled
|
|
1119
|
+
* plugin's, for pickers such as a default auth type.
|
|
1120
|
+
*/
|
|
1121
|
+
export declare function useSshAuthTypes(): {
|
|
1122
|
+
types: SshAuthTypeInfo[];
|
|
1123
|
+
loaded: boolean;
|
|
1124
|
+
};
|
|
1125
|
+
/**
|
|
1126
|
+
* The visible contributions to a slot another plugin owns, with their
|
|
1127
|
+
* metadata (id, titleKey, component). For an owner that needs to build a
|
|
1128
|
+
* catalog from what was contributed rather than just render it in place, e.g.
|
|
1129
|
+
* host-metrics listing manager cards plugins added to "host-metrics.managers"
|
|
1130
|
+
* next to its own. Same permission and `when` filtering as ComponentSlot;
|
|
1131
|
+
* `context` is what each contribution's `when` sees.
|
|
1132
|
+
*/
|
|
1133
|
+
/**
|
|
1134
|
+
* The connection protocols a host has switched on: "ssh" plus every protocol
|
|
1135
|
+
* a running plugin registered with registerHostProtocol. Lets a
|
|
1136
|
+
* plugin offer a protocol without knowing which plugin owns its settings.
|
|
1137
|
+
*/
|
|
1138
|
+
export declare function hostProtocols(record: PluginHostRecord): string[];
|
|
1139
|
+
export declare function useSlotContributions(slotId: string, context?: Record<string, unknown>): SlotContribution[];
|
|
1140
|
+
/**
|
|
1141
|
+
* Every host action any running plugin (and core) registered with
|
|
1142
|
+
* registerHostAction, for a plugin that offers a picker over "what can I do
|
|
1143
|
+
* with this host" without knowing which plugin provides each one - a quick
|
|
1144
|
+
* connect widget, say. Reactive: it re-renders as plugins enable and disable.
|
|
1145
|
+
*/
|
|
1146
|
+
export declare function useHostActions(): HostActionContribution[];
|
|
1147
|
+
/**
|
|
1148
|
+
* Recent-activity types every registered tab claims (registerTab's
|
|
1149
|
+
* activityTypes), core's and plugins'. For a filter that lists what a user
|
|
1150
|
+
* can pick, without knowing which plugin owns each activity type.
|
|
1151
|
+
*/
|
|
1152
|
+
export declare function useActivityTypes(): string[];
|
|
1153
|
+
/**
|
|
1154
|
+
* What a recent-activity entry of this type opens and how it is labelled -
|
|
1155
|
+
* the tab type claiming it through registerTab's activityTypes, core's or a
|
|
1156
|
+
* plugin's. undefined for a type nothing claims (its plugin is gone).
|
|
1157
|
+
*/
|
|
1158
|
+
export declare function activityTarget(type: string): ActivityTargetInfo | undefined;
|
|
1159
|
+
/**
|
|
1160
|
+
* Every item any running plugin added to `pointId` with registerExtension.
|
|
1161
|
+
* Reactive: it re-renders as plugins enable and disable.
|
|
1162
|
+
*/
|
|
1163
|
+
export declare function useExtensions<T extends ExtensionContribution>(pointId: string): T[];
|
|
1164
|
+
/** A single item added to `pointId`, by id, or undefined if none. */
|
|
1165
|
+
export declare function getExtension<T extends ExtensionContribution>(pointId: string, id: string): T | undefined;
|
|
1166
|
+
/**
|
|
1167
|
+
* The component another plugin registered under `id` with
|
|
1168
|
+
* app.registerComponent, or undefined while that plugin is off.
|
|
1169
|
+
*/
|
|
1170
|
+
export declare function usePluginComponent(id: string): ComponentType<Record<string, unknown>> | undefined;
|
|
1171
|
+
/**
|
|
1172
|
+
* Runs an action another plugin registered, from anywhere in a plugin's code.
|
|
1173
|
+
* Resolves undefined when nobody registered it, so an optional dependency
|
|
1174
|
+
* that is switched off reads as "nothing there".
|
|
1175
|
+
*/
|
|
1176
|
+
export declare function invokeAction(id: string, ...args: unknown[]): Promise<unknown>;
|
|
1177
|
+
export type ConnectionRetryStatus = "connecting" | "connected" | "error" | "disconnected";
|
|
1178
|
+
export interface UseConnectionRetryOptions {
|
|
1179
|
+
connect: () => void | Promise<void>;
|
|
1180
|
+
maxAttempts?: number;
|
|
1181
|
+
baseDelayMs?: number;
|
|
1182
|
+
maxDelayMs?: number;
|
|
1183
|
+
enabled?: boolean;
|
|
1184
|
+
autoStart?: boolean;
|
|
1185
|
+
}
|
|
1186
|
+
export interface UseConnectionRetryResult {
|
|
1187
|
+
status: ConnectionRetryStatus;
|
|
1188
|
+
attempt: number;
|
|
1189
|
+
maxAttempts: number;
|
|
1190
|
+
nextRetryInMs: number | null;
|
|
1191
|
+
markConnected: () => void;
|
|
1192
|
+
markFailed: () => void;
|
|
1193
|
+
retryNow: () => void;
|
|
1194
|
+
reset: () => void;
|
|
1195
|
+
}
|
|
1196
|
+
export declare function computeReconnectDelay(attempt: number, baseDelayMs: number, maxDelayMs: number, random?: () => number): number;
|
|
1197
|
+
/**
|
|
1198
|
+
* Exponential-backoff reconnect with jitter, for a plugin's own connect flow
|
|
1199
|
+
* (docker's console, host-metrics polling, remote desktop tokens, the file
|
|
1200
|
+
* manager). Promoted here once a fourth plugin needed its own copy of the
|
|
1201
|
+
* same hook.
|
|
1202
|
+
*/
|
|
1203
|
+
export declare function useConnectionRetry({ connect, maxAttempts, baseDelayMs, maxDelayMs, enabled, autoStart, }: UseConnectionRetryOptions): UseConnectionRetryResult;
|
|
1204
|
+
export type { PluginManifest } from "./manifest.js";
|
|
1205
|
+
export type { ReactNode };
|
|
1206
|
+
export type * from "./desktop.js";
|