/** * task-xml.ts — Task Scheduler XML for the daemon task (D1). * * Why XML instead of `schtasks /create /sc onlogon ...`: * - CLI-created tasks carry a DEFAULT ExecutionTimeLimit of 72 hours — * Task Scheduler silently kills the daemon after 3 days. Only XML can * express PT0S (no limit). * - Only XML can express a logon trigger WITH a repetition interval — * the PT5M repetition is our no-admin watchdog: a healthy daemon makes * the re-run exit in <100ms (single-instance lock), a dead daemon gets * restarted within 5 minutes. * - MultipleInstancesPolicy=IgnoreNew prevents pile-ups if a run is slow. * - StartWhenAvailable=true catches up a missed logon trigger. * * Issue #370 — repetition arms only at the NEXT logon, not at registration: * Task Scheduler only starts a trigger's `` pattern once that * trigger itself fires. A ``'s repetition therefore stays * completely dormant from the moment of (re)registration until the next * interactive logon — a `reinstall` (or `service install`) run mid-session * leaves the just-registered task's keepalive/hang-probe repetition dead * until the box is next rebooted or the user logs back in, with * `LastTaskResult` still reading a healthy `0` the whole time (it simply * never runs). Both `AstraMemoryD` (PT5M keepalive) and * `AstraMemoryDWatchdog` (hang-probe, schtasks.ts's `installWatchdogTimer`) * share this trigger shape and therefore both go dormant on every * (re)registration. Fix: add a SECOND trigger — `` with * `StartBoundary` set to registration time, carrying the exact same * `` block — alongside the `` (not instead of it; * the logon trigger still matters for a cold-boot scenario where the task * is registered but the box then reboots before the time-trigger's own * repetition would have caught up). A `` fires once its * `StartBoundary` is reached — effectively immediately at registration — so * its `` arms right away with no logon required, and repeats on * the same cadence forever after, independent of the logon trigger. A * schedule-type switch (`/SC MINUTE`) was considered and rejected: it can * only be expressed via the CLI `/create` form, which regresses the * ExecutionTimeLimit=PT0S fix above (CLI-created tasks default to 72h). */ /** * Minimal ISO-8601 duration parser — deliberately NOT general-purpose. Only * supports the `PT[nH][nM][nS]` subset this codebase's own callers ever * produce (task-xml.ts's own `repetitionIso` values, schtasks.ts's * `PT${intervalSec}S`) — no days/weeks/months/years, no fractional * components. Throws on anything outside that subset so a typo in a literal * this file controls fails loudly at import time rather than silently * producing 0. Exported so both `DEFAULT_REPETITION_SEC` below and the "Task * repetition dormancy" doctor canary (issue #370 review) can derive a * seconds value from a single ISO-8601 literal instead of hand-mirroring a * second numeric constant that can drift out of sync. */ export declare function parseSimpleIso8601DurationSeconds(iso: string): number; /** The daemon task's own keepalive repetition (schtasks.ts's `install()`). * `buildTaskXml` uses this as `repetitionIso`'s default (below) — the ISO * literal is the single source of truth; `DEFAULT_REPETITION_SEC` is * derived from it, not a hand-mirrored second constant. */ export declare const DEFAULT_REPETITION_ISO = "PT5M"; /** Numeric seconds equivalent of {@link DEFAULT_REPETITION_ISO}, derived (not * hand-mirrored) so the "Task repetition dormancy" doctor canary (issue * #370) can compute a staleness threshold without re-implementing ISO-8601 * duration parsing or risking a second literal drifting out of sync with * the first. */ export declare const DEFAULT_REPETITION_SEC: number; export interface TaskXmlOpts { /** Full command to execute (the stable shim .cmd path). */ command: string; /** Optional arguments string. */ args?: string; /** Working directory for the task. */ workingDir?: string; /** User id for the principal — DOMAIN\user or plain username. */ userId: string; description?: string; /** * ISO-8601 duration for the Repetition Interval shared by BOTH triggers * (LogonTrigger and TimeTrigger, issue #370). Defaults to 'PT5M' (the * daemon task's own keepalive tick). The hang-watchdog probe task * (schtasks.ts's installWatchdogTimer, issue #206) reuses this exact same * dual-trigger-with-repetition mechanism at WATCHDOG_PROBE_INTERVAL_SEC's * cadence instead — same proven trigger shape (fires once at logon or at * registration time, then repeats indefinitely with no Duration), just a * different command and interval. */ repetitionIso?: string; /** * StartBoundary for the TimeTrigger (issue #370) — local time, no * milliseconds/offset, matching the existing CalendarTrigger convention * below. Defaults to "now" (formatted via {@link localIsoNow}). Test-only * override — production callers should never need to set this; a fixed * value here would mean a stale, already-past StartBoundary at every real * registration, which Task Scheduler still fires immediately (a past * StartBoundary is not an error), so this is a pure determinism seam, not * a behavior lever. */ startBoundaryIso?: string; } /** * Daily-trigger variant (backup timer): CalendarTrigger at `startTime` * every day. Same Settings block reasons as the daemon task — most * importantly registered via XML so it installs without elevation on the * same boxes where the CLI form gets "Access is denied". */ export declare function buildDailyTaskXml(opts: TaskXmlOpts & { startTime?: string; description?: string; }): string; export declare function buildTaskXml(opts: TaskXmlOpts): string;