export declare const UPDATE_PROGRESS_FILE = "update-progress.json"; export type UpdatePhase = "downloading" | "verifying" | "stopping" | "installing" | "migrating" | "starting" | "done" | "failed"; /** * AR: ما الذي بدأ هذا التحديث (مواصفة 003): التشغيل، أو الإقلاع مع النظام، أو نافذة الصيانة، أو أمرٌ * يدويّ. يُرسَل إلى المركز مع النتيجة، فيُعرف أيّ مسارٍ يعمل على الأسطول. * EN: What started this update (spec 003): a start, the boot-time autostart, the maintenance window, * or a manual command. It goes to the centre with the outcome, so which path works on the fleet * is known. */ export type UpdateTrigger = "boot" | "start" | "window" | "manual"; export interface UpdateProgress { phase: UpdatePhase; /** ما بدأ التحديث — غائب في ملفّات كتبتها أداة أقدم. */ trigger?: UpdateTrigger; /** الإصدار المُركَّب قبل هذا التحديث. */ from: string; /** الإصدار المقصود. */ to: string; /** ‎0..100‎ على الشريط كلّه، لا على الخطوة الحالية. */ percent: number; startedAt: string; finishedAt?: string; /** * AR: العملية التي تكتب هذا الملفّ. **بدونه لا يُفرَّق بين تحديثٍ يجري وتحديثٍ مات.** * انقطاعُ كهرباء في منتصف تنزيلٍ يترك ملفًّا يقول «downloading 42%» إلى الأبد، وقارئُه * ينتظر تقدّمًا لن يأتي — واللوحة ترفض بدء تحديثٍ جديد لأن واحدًا «يجري». * EN: The process writing this file. **Without it, an update in progress cannot be told from one * that died.** A power cut mid-download leaves a file saying "downloading 42%" forever, and its * reader waits on progress that never comes — while the dashboard refuses to start a new update * because one is "running". */ pid: number; /** سبب الفشل حين ‎failed‎، ونصّ التراجع معه. لا يُملأ عند النجاح. */ message?: string; } /** * AR: موضع الشريط كلّه من مرحلةٍ وتقدّمٍ داخلها. **دالّة نقيّة لأن الخطأ فيها لا يُرى إلّا * كارتدادٍ في الشريط أمام المالك**، وهو ما يُقرأ عطلًا لا تقدّمًا. * * و‎within‎ يخصّ التنزيل والتحقّق وحدهما — فيهما ما يُعَدّ (بايتات، ملفّات). بقيّة المراحل خطواتٌ لا تُقاس، * فتُرسَم عند بداية مداها ويتقدّم الشريط بانتقالها. ادّعاءُ نسبةٍ داخل «تطبيق الهجرات» اختراعٌ لا قياس. * EN: The position on the whole bar, from a phase and the progress within it. **A pure function * because a mistake in it is visible only as the bar going backwards in front of the owner** — * which reads as a fault rather than as progress. * * `within` concerns the download and the verification alone, where there is something to count (bytes, * files): the other phases are steps that cannot be measured, so * each is drawn at the start of its range and the bar advances as they change. Claiming a * percentage inside "applying migrations" would be invention, not measurement. */ export declare function overallPercent(phase: UpdatePhase, within?: number): number; /** * AR: يكتب الحالة، **ولا يرمي أبدًا**. هذا الملفّ رفاهيةُ عرض؛ وتعذّرُ كتابته — قرصٌ ممتلئ، أو * صلاحية — لا يجوز أن يُسقط تحديثًا يجري على شجرة عميل. * EN: Writes the state, **and never throws**. This file is a display convenience; failing to write it * — a full disk, a permission — must never bring down an update in progress on a customer's tree. */ export declare function writeUpdateProgress(runDir: string, progress: UpdateProgress): void; /** * AR: هل ثمّة تحديثٌ يجري الآن؟ **دالّة نقيّة، وحياةُ العملية تُمرَّر إليها لا تُسأل داخلها.** * * القرار هنا يمنع أسوأ ما يمكن أن يقع لهذه الشجرة: **تحديثان يبدّلان نفس المجلدات معًا**. وهو * أيضًا القرار الذي يُعلِّق اللوحة إلى الأبد لو أخطأ في الاتجاه الآخر — فيُختبَر الطرفان. * EN: Is an update running right now? **A pure function, with the process's liveness passed in rather * than asked for inside.** * * This decision prevents the worst thing that can happen to this tree: **two updates swapping the * same directories at once**. It is also the decision that hangs the dashboard forever if it errs * the other way — so both sides are tested. */ export declare function isUpdateRunning(progress: UpdateProgress | undefined, alive: (pid: number) => boolean): boolean; /** هل العملية حيّة؟ ‎signal 0‎ يسأل بلا أن يرسل شيئًا؛ و‎EPERM‎ يعني حيّةً بحسابٍ آخر. */ export declare function processAlive(pid: number): boolean; /** * AR: هل هذه العملية **عمليةُ Node** — المُحدِّث أو المشرف أو الـ CLI — لا مجرّد عمليةٍ حيّة؟ (فحص 2026-10-08، U6). قفل * التحديث والصيانة يثق بـ‎pid‎ في ملفّ التقدّم ما دام حيّاً، فمن يكتب الملف بـ‎pid‎ عمليةٍ تعيش طويلاً (مستكشف * الملفات مثلاً) يمنع كل تحديثٍ وصيانة — الأمنيّة منها أيضاً. صلاحيات ‎run‎ (U1) تمنع الكتابة أصلاً؛ هذا دفاعٌ * ثانٍ. سؤالٌ يتعذّر (أداة غائبة، صلاحية) يُجاب «نعم»: لا يُكسر قفلٌ صادق لأن السؤال فشل. * EN: Is this a Node process — the updater, supervisor or CLI — rather than merely a live one? (U6.) The run folder's * ACL (U1) already stops the forgery; this is a second line. A failed question answers yes, so an honest lock * is never broken because the check failed. */ export declare function isNodeProcess(pid: number, platform?: NodeJS.Platform): boolean; /** حامل قفل الشجرة: حيٌّ **و**عمليةُ Node. */ export declare function lockHolderAlive(pid: number): boolean; /** يقرأ آخر حالة مكتوبة، أو ‎undefined‎ حين لا ملفّ — ولا يرمي على ملفٍّ تالف. */ export declare function readUpdateProgress(runDir: string): UpdateProgress | undefined; //# sourceMappingURL=progress-file.d.ts.map