import type { BundleManifest } from "../contracts/core.js"; import type { Profile } from "../profiles/types.js"; import { type AvailableRelease } from "../acquire/latest.js"; import { type DeviceIdentity } from "../acquire/license-identity.js"; import { type BundleChannel } from "../acquire/bundle.js"; import type { UpdateTrigger } from "./progress-file.js"; import { type UpdatePhase } from "./progress-file.js"; export interface ResolvedUpdate { /** كود التفعيل — لمسار ‎/setup/*‎ وحده (تثبيتٌ أوّل، إنقاذ، رجوعٌ مسمًّى). */ code?: string; /** هويّة الجهاز — مسار ‎/appliance/bundle‎ (مواصفة 003). */ identity?: DeviceIdentity; /** رابط التنزيل برمزه حين جاء العرض بالهويّة. */ downloadUrl?: string; release: AvailableRelease; installed: string; /** هل ما في المركز أحدث ممّا على القرص؟ */ newer: boolean; } export declare class UpdateRefused extends Error { /** صحيح حين السبب شبكةٌ لا رفض — يفرّق بينهما رمزُ خروجٍ ورسالةُ علاجٍ مختلفة. */ readonly unreachable: boolean; readonly remedy?: string | undefined; /** كود المركز حين رفض الجهازَ نفسه (محظور، رخصة موقوفة أو منتهية) — مواصفة 003. */ readonly refusedCode?: string | undefined; constructor(message: string, /** صحيح حين السبب شبكةٌ لا رفض — يفرّق بينهما رمزُ خروجٍ ورسالةُ علاجٍ مختلفة. */ unreachable: boolean, remedy?: string | undefined, /** كود المركز حين رفض الجهازَ نفسه (محظور، رخصة موقوفة أو منتهية) — مواصفة 003. */ refusedCode?: string | undefined); } /** * AR: يسأل المركز، **ولا يمسّ الجهاز**. كل فشلٍ هنا يقع والنظام يعمل كما كان. * EN: Asks the centre, **and touches the appliance not at all**. Every failure here happens with the * system running exactly as it was. */ export declare function resolveUpdate(input: { profile: Profile; manifest: BundleManifest; product?: string; /** ‎--code‎ أو البيئة. غيابه يعني «اقرأ المسجَّل»، وغياب ذاك يعني رفضًا صريحًا. */ code?: string; timeoutMs?: number; /** * AR: إصدارٌ مسمًّى بدل الأحدث — للرجوع (‎fantastic rollback‎، و‎updater.js --to‎). **الجسم لا * يعرف اتجاهًا**: ينزّل ويتحقّق ويبدّل ما سُمّي، و‎newer‎ يقول للمُنادي أين يقع ممّا على القرص. * EN: A named version instead of the newest — for rollback (`fantastic rollback`, and * `updater.js --to`). **The body knows no direction**: it downloads, verifies and swaps what was * named, and `newer` tells the caller where that lies relative to what is on disk. */ version?: string; /** قناة الحزمة لمسار الهويّة — ‎stable‎ افتراضًا. */ channel?: BundleChannel; }): Promise; export declare function reportRefusal(runDir: string, installed: string, message: string): void; export type UpdateOutcome = { ok: true; from: string; to: string; } | { ok: false; reason: string; rolledBack: boolean; stubborn: string[]; /** * الفشل يقول شيئًا عن **الحزمة** (بصمة، توقيع، شجرة ناقصة، لم تُقلع) فتتذكّره ذاكرة الفشل — * لا تنزيلٌ انقطع ولا شجرةٌ مشغولة. */ remember?: boolean; /** * AR: ملف التحديث لم يصلح لهذا الجهاز **قبل أن يُوقَف شيء** (2026-10-14) — تُنزَّل الحزمة الكاملة في نفس * المرّة. انظر ‎runUpdate‎. * EN: The update file did not fit this appliance **before anything was stopped** (2026-10-14) — the full * bundle is downloaded in the same run. See `runUpdate`. */ fallback?: boolean; }; export interface RunUpdateOptions { profile: Profile; resolved: ResolvedUpdate; product?: string; /** يُنادى عند كل انتقال مرحلة، وأثناء التنزيل والتحقّق عند كل واحدٍ بالمئة. ‎within‎: الموضع داخل المرحلة. */ onProgress?: (phase: UpdatePhase, percent: number, within: number) => void; /** بايتات التنزيل خامًّا — للشريط الذي يرسمه الأمر. */ onBytes?: (received: number, total: number, resumed: boolean) => void; /** ما بدأ التحديث — يُكتب في ملفّ التقدّم ويُرسَل مع النتيجة (مواصفة 003). */ trigger?: UpdateTrigger; /** * AR: **التحديث يجري داخل المشرِف نفسه** (الإقلاع مع النظام ونافذة الصيانة، مواصفة 003). عندها لا * يُوقَف ‎fantastic-supervisor.service‎: إيقافه يرسل ‎SIGTERM‎ إلى هذه العمليّة في منتصف التبديل. * ولا حاجة إليه أصلًا — المشرِف لا يُحيي الخدمات وهو مشغولٌ بتحديثها. * EN: **The update runs inside the supervisor itself** (the boot-time autostart and the maintenance * window, spec 003). Then `fantastic-supervisor.service` is not stopped: stopping it sends `SIGTERM` * to this very process mid-swap. Nor is it needed — the supervisor does not revive services while it * is busy updating them. */ insideSupervisor?: boolean; } /** * AR: ينزّل ويتحقّق ويستبدل ويهاجر ويشغّل، ويتراجع عند الفشل. **لا يرمي على فشلٍ متوقَّع**: يعيد * نتيجةً تصف ما جرى، لأن مُناديه الثاني عمليةٌ بلا إنسانٍ أمامها تكتب الجواب في ملفّ. * EN: Downloads, verifies, swaps, migrates and starts, rolling back on failure. **It does not throw * on an expected failure**: it returns a result describing what happened, because its second * caller is a process with nobody in front of it, writing the answer into a file. */ /** * AR: يُحدِّث سجلّ المثبَّت بعد تحديثٍ نجح. **كان هذا مفقودًا**: `fantastic list` يقرأ * `registry.json` لا بيانَ الحزمة، فجهازٌ رُكِّب على 0.18.0 ثم حُدِّث إلى 0.27.0 ظلّ يُعرَض * 0.18.0 — رقمٌ يقرؤه فنّيٌّ في مكالمة دعمٍ فيشخّص جهازًا غير الذي أمامه. أُضيف السطر في * 5401c1e وسقط في 9c31a96 حين استُخرجت هذه الوحدة من `update.ts`، ولم يُنقَل معها. * * **والصفّ يُلتمَس بالجذر لا بالمعرّف**: الجذر لا يتكرّر، فتصيب الكتابة الصفّ نفسه ولا تضيف * ثانيًا باسمٍ مختلف. * * **و`activationCode` يُحمَل كما هو**: `recordInstall` يستبدل الصفّ كاملًا، وكودُ تفعيلٍ لم * يُرحَّل بعدُ إلى ملفّه المحميّ كان سيُمحى هنا بلا رجعة (٠٢٦/M-1). * * **وفشل الكتابة لا يُسقط تحديثًا نجح**: `%ProgramData%` قد يُرفض لحسابٍ عاديّ، والنظام يعمل. * EN: Updates the installed-products registry after a successful update. **This was missing**: * `fantastic list` reads `registry.json` rather than the bundle manifest, so an appliance * installed at 0.18.0 and updated to 0.27.0 kept reporting 0.18.0 — a number a technician reads * on a support call and uses to diagnose an appliance other than the one in front of them. The * line was added in 5401c1e and lost in 9c31a96, when this module was extracted from * `update.ts`. * * **The row is found by root rather than by id**: a root is unique, so the write lands on that * row instead of adding a second one under a different name. * * **`activationCode` is carried across untouched**: `recordInstall` replaces the whole row, and * a code not yet migrated to its protected file would have been erased here (026/M-1). * * **A failed write never fails a successful update**: `%ProgramData%` can be refused to an * ordinary account, and the system is running. */ export declare function recordUpdatedInstall(input: { profile: Profile; root: string; version: string; product?: string; }): void; /** * AR: يثبّت التحديث، ثم **يبلّغ المركز بالنتيجة** حين جاء بهويّة الجهاز (مواصفة 003): التحديث صار * إجباريًّا بلا يد، فتقريره هو الأثر الوحيد الذي يقول أيّ جهاز على أيّ نسخة. التقرير أفضل جهد. * EN: Installs the update, then **reports the outcome to the centre** when it came by device identity * (spec 003): updating is now mandatory and hands-off, so the report is the only trace of which * device runs which version. The report is best effort. */ export declare function runUpdate(options: RunUpdateOptions): Promise; /** * AR: سببُ رفض البيان المفكوك، أو ‎null‎ إن كان سليمًا. **مُصدَّرة لتُختبَر بشجرةٍ مؤقّتة.** * EN: Why the unpacked manifest is refused, or `null` when it is sound. **Exported to be tested against * a temporary tree.** */ export declare function stagedManifestRefusal(staging: string, expectedVersion: string, allowUnsigned: boolean, publicKeys?: readonly string[]): string | null; //# sourceMappingURL=run-update.d.ts.map