Files
Termix/src/backend/plugins/auto-update.ts
T
62ac931468 v26.10.1 (#1599)
* feat: AI translations at release, 7 new languages and regional fallback

* fix: proper plural forms for count strings and full translations

* fix: plural forms for selected, hidden and active counts

* fix: synced plugin updates failing on desktop and server-only plugins shown as stopped

* fix: restore rounded corners on app icons and favicon

* feat: desktop app auto updates with automatic, ask first or never modes

* feat: community and custom plugin registries

* feat: plugin guide for AI tools in the SDK with a lint check

* fix: keep the terminal WebSocket open past nginx's 60s default (#1588)

* chore: update changelog

* feat: show plugin download counts only and stop CI builds inflating them

* feat: hide installed plugins in the browse tab by default

* chore: pin bundled plugins to latest releases

* chore: update translations

* fix: focusing a saved password field and saving no longer erases it

* fix: tell desktop users when their 2.8 data needs 2.9 first

* fix: point windows update info at the x64 installer

* fix: keep desktop client tunnel sockets alive behind proxies

* chore: pin bundled plugins to latest releases

* fix: cover client tunnel keepalive in the c2s runtime tests

* fix: typing after opening a host no longer goes to the host search

* fix: accept tab and = separators in SSH config import (#1598)

* chore: update changelog

* chore: drop plugin versions from core changelog

* chore: update translations

* chore: lint, format, and bump version to 26.10.1

---------

Co-authored-by: Darnel Hunter <68697450+innotelinc@users.noreply.github.com>
Co-authored-by: Iain <Iain1970@protonmail.com>
2026-10-12 11:35:48 -05:00

64 lines
2.1 KiB
TypeScript

/**
* The registry timer: refreshes the store's download counts and applies
* plugin updates for plugins with auto-update on. An update that asks for a
* new capability is never applied here; admins get an alert and review it in
* the Plugins tab. Nothing is ever installed from here.
*/
import { pluginLogger } from "../utils/logger.js";
const FIRST_CHECK_MS = 2 * 60_000;
const CHECK_EVERY_MS = 6 * 60 * 60_000;
let timer: NodeJS.Timeout | null = null;
export async function runPluginAutoUpdate(): Promise<void> {
const { syncDownloadCounts } = await import("./download-counts.js");
await syncDownloadCounts();
const { isLinkedDesktop, updateAllPlugins } = await import("./manage.js");
if (await isLinkedDesktop()) return;
const result = await updateAllPlugins({ userId: null, onlyAutoUpdate: true });
for (const done of result.updated) {
pluginLogger.info(`Auto-updated plugin ${done.id} to ${done.version}`, {
operation: "plugin_auto_update",
});
}
for (const failed of result.failed) {
pluginLogger.warn(`Auto-update of ${failed.id} failed: ${failed.error}`, {
operation: "plugin_auto_update",
});
}
if (result.needsReview.length === 0) return;
const { sendCoreAlert } = await import("../notify/core-notify.js");
for (const entry of result.needsReview) {
await sendCoreAlert({
title: `A plugin update needs review`,
body: `The new version of ${entry.id} asks for more access, so it was not installed on its own. Review it in Plugins.`,
severity: "info",
category: "termix.plugin-update",
dedupeKey: `plugin-review:${entry.id}:${entry.capabilities.join(",")}`,
audience: "admins",
});
}
}
export function startPluginAutoUpdate(): void {
if (timer) return;
const run = () =>
void runPluginAutoUpdate().catch((error) => {
pluginLogger.warn(
`Plugin auto-update check failed: ${
error instanceof Error ? error.message : String(error)
}`,
{ operation: "plugin_auto_update" },
);
});
setTimeout(run, FIRST_CHECK_MS).unref?.();
timer = setInterval(run, CHECK_EVERY_MS);
timer.unref?.();
}