@ai-dossier/cli 0.89.4 → 0.89.5-next.548.1

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 CHANGED
@@ -1411,8 +1411,10 @@ respectively; `get --json` includes the comment's `author`.
1411
1411
  ```bash
1412
1412
  ai-dossier sched enqueue --issues 101,105..109 [--mode full|slot] [--batch b1] [--more-members-expected] [--deps 100,104] [--tier mechanical|mid|strong] [--priority <n>] [--repo owner/name]
1413
1413
  ai-dossier sched enqueue --from-manifest batch-prep.json [--repo owner/name]
1414
- ai-dossier sched start [--interval <seconds>] [--once] [--auto-upgrade] [--json]
1415
- ai-dossier sched status [--json] [--anchors] # ⚠ health warnings: long pause, stale lease, stuck / stale-closed slots (#776), kept worktrees on done batches (#791)
1414
+ ai-dossier sched start [--interval <seconds>] [--once] [--auto-upgrade] [--alert-issue <n>] [--json]
1415
+ ai-dossier sched service install [--mode systemd|cron] [--alert-issue <n>] [--no-auto-upgrade] | uninstall | status # THE way to run the engine (#945): systemd user unit or cron watchdog, restarts it by itself
1416
+ ai-dossier sched ensure-running [--disable|--enable] # the cron watchdog: start the engine if no live one holds the lease
1417
+ ai-dossier sched status [--json] [--anchors] [--alert] # ⚠ health warnings: long pause, stale lease, stuck / stale-closed slots (#776), kept worktrees on done batches (#791)
1416
1418
  ai-dossier sched pause | resume
1417
1419
  ai-dossier sched resume --batch <id> # gate-inconclusive: re-run the gate (#583); blocked over landed work (dissolve-refused / tail-blocked / members-mismatch / respawn-cap:tail): re-run gate + tail over the landed members (#822)
1418
1420
  ai-dossier sched stop (--issue 42 | --batch b1) [--reason "..."]
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `sched service install|uninstall|status` and `sched ensure-running` (#945 AC1).
3
+ * The logic lives in `../sched-service` and `../sched-ensure` (injectable, unit
4
+ * tested); this file is only argument handling and process wiring.
5
+ */
6
+ import type { Command } from 'commander';
7
+ /**
8
+ * `crontab -l`, strictly: `''` only for the verifiable "no crontab for <user>"
9
+ * case. A missing binary, a permission error or a timeout THROWS — an empty
10
+ * string there would make install overwrite the user's real crontab.
11
+ */
12
+ export declare function readCrontabStrict(): string;
13
+ export declare function registerSchedServiceCommands(sched: Command): void;
14
+ //# sourceMappingURL=sched-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sched-service.d.ts","sourceRoot":"","sources":["../../src/commands/sched-service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6CzC;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAQ1C;AAyED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAmLjE"}
@@ -0,0 +1,290 @@
1
+ "use strict";
2
+ /**
3
+ * `sched service install|uninstall|status` and `sched ensure-running` (#945 AC1).
4
+ * The logic lives in `../sched-service` and `../sched-ensure` (injectable, unit
5
+ * tested); this file is only argument handling and process wiring.
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.readCrontabStrict = readCrontabStrict;
42
+ exports.registerSchedServiceCommands = registerSchedServiceCommands;
43
+ const node_child_process_1 = require("node:child_process");
44
+ const fs = __importStar(require("node:fs"));
45
+ const os = __importStar(require("node:os"));
46
+ const sched_1 = require("@ai-dossier/sched");
47
+ const helpers_1 = require("../helpers");
48
+ const sched_alert_1 = require("../sched-alert");
49
+ const sched_ensure_1 = require("../sched-ensure");
50
+ const sched_service_1 = require("../sched-service");
51
+ const run = (file, args) => {
52
+ try {
53
+ return String((0, node_child_process_1.execFileSync)(file, args, {
54
+ encoding: 'utf8',
55
+ stdio: ['ignore', 'pipe', 'ignore'],
56
+ timeout: 30_000,
57
+ })).trim();
58
+ }
59
+ catch {
60
+ return null;
61
+ }
62
+ };
63
+ /**
64
+ * `crontab -l`, strictly: `''` only for the verifiable "no crontab for <user>"
65
+ * case. A missing binary, a permission error or a timeout THROWS — an empty
66
+ * string there would make install overwrite the user's real crontab.
67
+ */
68
+ function readCrontabStrict() {
69
+ const res = (0, node_child_process_1.spawnSync)('crontab', ['-l'], { encoding: 'utf8', timeout: 30_000 });
70
+ if (res.error)
71
+ throw new Error(`crontab -l failed: ${res.error.message}`);
72
+ if (res.status === 0)
73
+ return res.stdout ?? '';
74
+ const stderr = (res.stderr ?? '').trim();
75
+ const noCrontabForCurrentUser = `no crontab for ${os.userInfo().username}`;
76
+ if (res.status === 1 && stderr.toLowerCase() === noCrontabForCurrentUser.toLowerCase())
77
+ return '';
78
+ throw new Error(`crontab -l exited ${res.status}: ${stderr || 'no output'}`);
79
+ }
80
+ function realIo(opts) {
81
+ return {
82
+ run,
83
+ unitDir: opts.unitDir ?? (0, sched_service_1.defaultUnitDir)(),
84
+ readCrontab: readCrontabStrict,
85
+ writeCrontab: (text) => {
86
+ try {
87
+ (0, node_child_process_1.execFileSync)('crontab', ['-'], { input: text, stdio: ['pipe', 'ignore', 'ignore'] });
88
+ return true;
89
+ }
90
+ catch {
91
+ return false;
92
+ }
93
+ },
94
+ render: opts.activate === false,
95
+ };
96
+ }
97
+ function projectOf(opts) {
98
+ return opts.project ?? (0, sched_1.resolveProjectSlug)(sched_1.defaultExec);
99
+ }
100
+ /**
101
+ * The project's MAIN checkout — from inside a linked worktree `--show-toplevel`
102
+ * is an ephemeral path; `git worktree list` names the main one first.
103
+ */
104
+ function mainCheckout(cwd) {
105
+ const list = run('git', ['worktree', 'list', '--porcelain']);
106
+ const first = list?.split('\n').find((l) => l.startsWith('worktree '));
107
+ if (first)
108
+ return first.slice('worktree '.length);
109
+ return run('git', ['rev-parse', '--show-toplevel']) ?? cwd;
110
+ }
111
+ function buildSpec(opts, project) {
112
+ const repoDir = opts.repoDir ?? mainCheckout(process.cwd()) ?? process.cwd();
113
+ const repoProject = (0, sched_1.resolveProjectSlug)(sched_1.defaultExec, repoDir);
114
+ if (repoProject !== project) {
115
+ (0, helpers_1.fail)([
116
+ `${repoDir} belongs to project '${repoProject}', not '${project}' — run from the right checkout or pass --repo-dir <path>`,
117
+ ]);
118
+ }
119
+ const cliPath = process.argv[1];
120
+ if (!cliPath)
121
+ (0, helpers_1.fail)(['cannot determine the ai-dossier entry point (process.argv[1] is empty)']);
122
+ let alertIssue;
123
+ try {
124
+ alertIssue = (0, sched_alert_1.parseAlertIssue)(opts.alertIssue);
125
+ }
126
+ catch (err) {
127
+ (0, helpers_1.fail)([err.message]);
128
+ }
129
+ const spec = {
130
+ project,
131
+ nodePath: process.execPath,
132
+ cliPath,
133
+ repoDir,
134
+ envPath: (0, sched_service_1.serviceEnvPath)(process.env.PATH),
135
+ // The service default is self-upgrading (#945): a supervised engine that never upgrades drifts.
136
+ autoUpgrade: opts.autoUpgrade !== false,
137
+ ...(alertIssue !== undefined ? { alertIssue } : {}),
138
+ };
139
+ const { errors, warnings } = (0, sched_service_1.validateServicePaths)(spec);
140
+ if (errors.length > 0)
141
+ (0, helpers_1.fail)(errors);
142
+ for (const w of warnings)
143
+ process.stderr.write(`⚠ ${w}\n`);
144
+ return spec;
145
+ }
146
+ function chooseMode(raw, io) {
147
+ if (raw === 'systemd' || raw === 'cron')
148
+ return raw;
149
+ if (raw !== undefined && raw !== 'auto')
150
+ (0, helpers_1.fail)([`--mode must be systemd, cron or auto, got '${raw}'`]);
151
+ return io.render || (0, sched_service_1.systemdUserAvailable)(io.run) ? 'systemd' : 'cron';
152
+ }
153
+ function registerSchedServiceCommands(sched) {
154
+ const service = sched
155
+ .command('service')
156
+ .description('Run the engine supervised (#945): a systemd user unit (Restart=always, KillMode=process) or, without systemd, a cron @reboot + per-minute `sched ensure-running` watchdog. THE supported way to run it.');
157
+ service
158
+ .command('install')
159
+ .description('Write and enable the supervisor for this project (idempotent; re-run to update)')
160
+ .option('--project <slug>', 'Project slug (default: owner-repo of the current directory)')
161
+ .option('--mode <mode>', 'systemd | cron | auto (default auto: systemd when a user manager is running)')
162
+ .option('--no-auto-upgrade', 'Do not run the engine with --auto-upgrade (default: on under the service)')
163
+ .option('--alert-issue <n>', 'Tracking issue the engine comments on when it restarts after a crash')
164
+ .option('--unit-dir <dir>', 'Where to write the systemd unit (default ~/.config/systemd/user)')
165
+ .option('--repo-dir <path>', "The project's main checkout (default: the main worktree of the current repository, never a linked worktree)")
166
+ .option('--no-activate', 'Only write the unit / render the cron block — never call systemctl or crontab')
167
+ .option('--print', 'Print the unit / cron block instead of installing anything')
168
+ .action((opts) => {
169
+ const project = projectOf(opts);
170
+ const spec = buildSpec(opts, project);
171
+ const io = realIo(opts);
172
+ const mode = chooseMode(opts.mode, io);
173
+ if (opts.print) {
174
+ console.log(mode === 'systemd' ? (0, sched_service_1.renderSystemdUnit)(spec) : (0, sched_service_1.renderCronBlock)(spec));
175
+ return;
176
+ }
177
+ const result = (0, sched_service_1.installService)(spec, mode, io);
178
+ if (result.ok)
179
+ (0, sched_ensure_1.setEnsureDisabled)(new sched_1.SchedStore((0, sched_1.schedStateDir)(project)), false);
180
+ if (!result.ok) {
181
+ console.error(`✗ [${project}] ${mode} supervisor NOT installed`);
182
+ for (const n of result.notes)
183
+ console.error(` ${n}`);
184
+ process.exit(1);
185
+ }
186
+ if (!result.activated) {
187
+ console.log(`[${project}] ${mode} supervisor rendered only (--no-activate) — NOT installed or running${result.unitPath ? `; unit file written to ${result.unitPath} but not enabled` : '; print it with --print and install it yourself'}`);
188
+ return;
189
+ }
190
+ console.log(`✓ [${project}] ${mode} supervisor ${result.changed ? 'installed/updated' : 'already up to date'}${result.unitPath ? ` (${result.unitPath})` : ''}`);
191
+ for (const n of result.notes)
192
+ console.log(` ${n}`);
193
+ });
194
+ service
195
+ .command('uninstall')
196
+ .description('Disable and remove the supervisor (systemd unit and/or cron block) for this project')
197
+ .option('--project <slug>', 'Project slug (default: owner-repo of the current directory)')
198
+ .option('--unit-dir <dir>', 'Systemd unit directory (default ~/.config/systemd/user)')
199
+ .option('--no-activate', 'Only remove files — never call systemctl or crontab')
200
+ .action((opts) => {
201
+ const project = projectOf(opts);
202
+ const { removed, errors } = (0, sched_service_1.uninstallService)(project, realIo(opts));
203
+ if (errors.length > 0) {
204
+ console.error(`✗ [${project}] uninstall incomplete${removed.length ? ` (removed: ${removed.join(', ')})` : ''}`);
205
+ for (const e of errors)
206
+ console.error(` ${e}`);
207
+ process.exit(1);
208
+ }
209
+ console.log(removed.length > 0
210
+ ? `✓ [${project}] removed: ${removed.join(', ')}`
211
+ : `[${project}] no supervisor installed`);
212
+ });
213
+ service
214
+ .command('status')
215
+ .description('Is the engine supervised, and is it running?')
216
+ .option('--project <slug>', 'Project slug (default: owner-repo of the current directory)')
217
+ .option('--unit-dir <dir>', 'Systemd unit directory (default ~/.config/systemd/user)')
218
+ .option('--json', 'Output as JSON')
219
+ .action((opts) => {
220
+ const project = projectOf(opts);
221
+ const status = (0, sched_service_1.serviceStatus)(project, realIo(opts));
222
+ const lease = new sched_1.SchedStore((0, sched_1.schedStateDir)(project)).engineLeaseStatus();
223
+ if (opts.json) {
224
+ console.log(JSON.stringify({ ...status, engine_lease: lease }, null, 2));
225
+ return;
226
+ }
227
+ console.log(`Project: ${project}`);
228
+ console.log(`systemd unit: ${status.systemd.installed ? `installed (${status.systemd.enabled ?? '?'}, ${status.systemd.active ?? '?'})` : 'not installed'}`);
229
+ console.log(`cron watchdog: ${status.cron.error ? `unknown (${status.cron.error})` : status.cron.installed ? 'installed' : 'not installed'}`);
230
+ console.log(`engine: ${lease ? `pid ${lease.pid} ${lease.alive ? 'live' : 'STALE'}${lease.updated_at ? `, heartbeat ${lease.updated_at}` : ''}` : 'no lease (not running)'}`);
231
+ if (!status.supervised) {
232
+ console.log('⚠ NOT supervised — a crash or reboot leaves the queue unattended. Run `ai-dossier sched service install`.');
233
+ }
234
+ });
235
+ sched
236
+ .command('ensure-running')
237
+ .description('Watchdog (cron, every minute): start the engine detached if no live engine holds the lease, after raising the once-per-episode stale-lease alert (#945)')
238
+ .option('--project <slug>', 'Project slug (default: owner-repo of the current directory)')
239
+ .option('--auto-upgrade', 'Start the engine with --auto-upgrade')
240
+ .option('--alert-issue <n>', 'Tracking issue for stale-lease / crash alerts')
241
+ .option('--disable', 'Stop resurrecting the engine (operator stopped it on purpose)')
242
+ .option('--enable', 'Resume resurrecting the engine')
243
+ .action((opts) => {
244
+ const project = projectOf(opts);
245
+ const store = new sched_1.SchedStore((0, sched_1.schedStateDir)(project));
246
+ if (opts.disable || opts.enable) {
247
+ (0, sched_ensure_1.setEnsureDisabled)(store, opts.disable === true);
248
+ console.log(`✓ [${project}] ensure-running ${opts.disable ? 'disabled' : 'enabled'}`);
249
+ return;
250
+ }
251
+ let alertIssue;
252
+ try {
253
+ alertIssue = (0, sched_alert_1.parseAlertIssue)(opts.alertIssue);
254
+ }
255
+ catch (err) {
256
+ (0, helpers_1.fail)([err.message]);
257
+ }
258
+ const outcome = (0, sched_ensure_1.ensureRunning)({
259
+ store,
260
+ journal: new sched_1.Journal(store.dir),
261
+ // Lazy repo: `gh repo view` only when an alert is actually raised, never on a healthy minute.
262
+ notify: (0, sched_alert_1.createAlertNotifier)(project, () => (0, sched_1.resolveProjectRepo)(project, sched_1.defaultExec) ?? undefined, alertIssue, { stateDir: store.dir }),
263
+ now: () => new Date(),
264
+ spawnEngine: (logFile) => {
265
+ try {
266
+ fs.mkdirSync(store.dir, { recursive: true, mode: 0o700 });
267
+ const fd = fs.openSync(logFile, 'a', 0o600);
268
+ const child = (0, node_child_process_1.spawn)(process.execPath, [
269
+ process.argv[1],
270
+ 'sched',
271
+ 'start',
272
+ '--project',
273
+ project,
274
+ ...(opts.autoUpgrade ? ['--auto-upgrade'] : []),
275
+ ...(alertIssue !== undefined ? ['--alert-issue', String(alertIssue)] : []),
276
+ ], { cwd: process.cwd(), detached: true, stdio: ['ignore', fd, fd] });
277
+ child.unref();
278
+ fs.closeSync(fd);
279
+ return child.pid ?? null;
280
+ }
281
+ catch {
282
+ return null;
283
+ }
284
+ },
285
+ });
286
+ if (outcome !== 'alive')
287
+ console.log(`[${project}] ensure-running: ${outcome}`);
288
+ });
289
+ }
290
+ //# sourceMappingURL=sched-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sched-service.js","sourceRoot":"","sources":["../../src/commands/sched-service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DH,8CAQC;AAyED,oEAmLC;AAjUD,2DAAoE;AACpE,4CAA8B;AAC9B,4CAA8B;AAC9B,6CAO2B;AAE3B,wCAAkC;AAClC,gDAAsE;AACtE,kDAAmE;AACnE,oDAa0B;AAc1B,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,IAAc,EAAiB,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,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;qBAC3E,EACD,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAClE,CAAC;oBACF,KAAK,CAAC,KAAK,EAAE,CAAC;oBACd,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;oBACjB,OAAO,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC;gBAC3B,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;SACF,CAAC,CAAC;QACH,IAAI,OAAO,KAAK,OAAO;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,qBAAqB,OAAO,EAAE,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sched.d.ts","sourceRoot":"","sources":["../../src/commands/sched.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAKV,oBAAoB,EAQrB,MAAM,mBAAmB,CAAC;AAuF3B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkDzC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,CAAC,EAAE;IACjD,yGAAyG;IACzG,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,oBAAoB,CA4DnE;AAooFD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkB3D"}
1
+ {"version":3,"file":"sched.d.ts","sourceRoot":"","sources":["../../src/commands/sched.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAKV,oBAAoB,EAQrB,MAAM,mBAAmB,CAAC;AAuF3B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmDzC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,CAAC,EAAE;IACjD,yGAAyG;IACzG,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,oBAAoB,CA4DnE;AAsoFD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmB3D"}
@@ -73,6 +73,7 @@ const sched_alert_1 = require("../sched-alert");
73
73
  const sched_run_stats_1 = require("../sched-run-stats");
74
74
  const table_1 = require("../table");
75
75
  const batch_prep_1 = require("../usage/batch-prep");
76
+ const sched_service_1 = require("./sched-service");
76
77
  /**
77
78
  * Batch-worktree `ai-dossier cap run <id>` runner for the per-member
78
79
  * incremental gate (#523 AC2). `cap run`'s `task-failed` outcome — a
@@ -1215,7 +1216,7 @@ function registerStatusSubcommand(cmd) {
1215
1216
  process.stderr.write(`⚠ sched status --alert: ${err.message} — alerting on stderr/journal only\n`);
1216
1217
  }
1217
1218
  try {
1218
- (0, sched_1.checkStaleLeaseAlert)(store, new sched_1.Journal(store.dir), (0, sched_alert_1.createAlertNotifier)(project, (0, sched_1.resolveProjectRepo)(project, sched_1.defaultExec) ?? undefined, alertIssue), new Date(), {
1219
+ (0, sched_1.checkStaleLeaseAlert)(store, new sched_1.Journal(store.dir), (0, sched_alert_1.createAlertNotifier)(project, () => (0, sched_1.resolveProjectRepo)(project, sched_1.defaultExec) ?? undefined, alertIssue, { stateDir: store.dir }), new Date(), {
1219
1220
  hungAfterMs: (0, sched_1.resolveHungAfterMs)((0, sched_1.resolveDispatch)(store.loadConfig()).reconcileIntervalMs),
1220
1221
  });
1221
1222
  }
@@ -2103,7 +2104,7 @@ function registerStartSubcommand(cmd) {
2103
2104
  journalAtStart.append({ event: 'engine-started', pid: process.pid, detail: 'loop' });
2104
2105
  }
2105
2106
  if (acquisition.reclaimed) {
2106
- (0, sched_1.reportCrashRestart)(journalAtStart, acquisition.reclaimed, (0, sched_alert_1.createAlertNotifier)(project, (0, sched_1.resolveProjectRepo)(project, sched_1.defaultExec) ?? undefined, alertIssue), new Date(), previousStop !== null && previousStop.pid === acquisition.reclaimed.pid
2107
+ (0, sched_1.reportCrashRestart)(journalAtStart, acquisition.reclaimed, (0, sched_alert_1.createAlertNotifier)(project, () => (0, sched_1.resolveProjectRepo)(project, sched_1.defaultExec) ?? undefined, alertIssue, { stateDir: store.dir }), new Date(), previousStop !== null && previousStop.pid === acquisition.reclaimed.pid
2107
2108
  ? previousStop
2108
2109
  : null);
2109
2110
  }
@@ -2390,5 +2391,6 @@ function registerSchedCommand(program) {
2390
2391
  registerReprioritizeSubcommand(schedCmd);
2391
2392
  registerStartSubcommand(schedCmd);
2392
2393
  registerStatsSubcommand(schedCmd);
2394
+ (0, sched_service_1.registerSchedServiceCommands)(schedCmd);
2393
2395
  }
2394
2396
  //# sourceMappingURL=sched.js.map