agent-steward 0.0.2 → 0.0.4
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/CHANGELOG.md +45 -2
- package/CROSS_PLATFORM.md +11 -9
- package/README.md +11 -10
- package/ROADMAP-STRATEGY.md +93 -44
- package/ROADMAP.md +148 -1017
- package/dist/core/cron-to-schtasks.d.ts +0 -8
- package/dist/core/cron-to-schtasks.d.ts.map +1 -1
- package/dist/core/cron-to-schtasks.js +11 -86
- package/dist/core/dlq-api.d.ts +44 -0
- package/dist/core/dlq-api.d.ts.map +1 -0
- package/dist/core/dlq-api.js +68 -0
- package/dist/core/dry-run.d.ts.map +1 -1
- package/dist/core/dry-run.js +19 -2
- package/dist/core/file-watcher.js +9 -9
- package/dist/core/git-trigger.js +4 -4
- package/dist/core/lock.d.ts +20 -4
- package/dist/core/lock.d.ts.map +1 -1
- package/dist/core/lock.js +99 -26
- package/dist/core/one-shot.d.ts +31 -5
- package/dist/core/one-shot.d.ts.map +1 -1
- package/dist/core/one-shot.js +78 -10
- package/dist/core/opencode-cli.d.ts +28 -0
- package/dist/core/opencode-cli.d.ts.map +1 -0
- package/dist/core/opencode-cli.js +74 -0
- package/dist/core/opencode-models.d.ts +62 -0
- package/dist/core/opencode-models.d.ts.map +1 -0
- package/dist/core/opencode-models.js +277 -0
- package/dist/core/otel.js +2 -2
- package/dist/core/ps-wrapper.d.ts +1 -1
- package/dist/core/ps-wrapper.d.ts.map +1 -1
- package/dist/core/ps-wrapper.js +66 -36
- package/dist/core/record-history.d.ts +15 -0
- package/dist/core/record-history.d.ts.map +1 -1
- package/dist/core/record-history.js +78 -54
- package/dist/core/router/dispatch.d.ts +36 -0
- package/dist/core/router/dispatch.d.ts.map +1 -0
- package/dist/core/router/dispatch.js +59 -0
- package/dist/core/router/escalation.d.ts +47 -0
- package/dist/core/router/escalation.d.ts.map +1 -0
- package/dist/core/router/escalation.js +87 -0
- package/dist/core/router/planner.d.ts +53 -0
- package/dist/core/router/planner.d.ts.map +1 -0
- package/dist/core/router/planner.js +113 -0
- package/dist/core/router/rules.d.ts +46 -0
- package/dist/core/router/rules.d.ts.map +1 -0
- package/dist/core/router/rules.js +85 -0
- package/dist/core/run-panel-api.d.ts +94 -0
- package/dist/core/run-panel-api.d.ts.map +1 -0
- package/dist/core/run-panel-api.js +169 -0
- package/dist/core/schedule-gate.js +5 -1
- package/dist/core/schedule-v2.d.ts +36 -2
- package/dist/core/schedule-v2.d.ts.map +1 -1
- package/dist/core/schedule-v2.js +98 -12
- package/dist/core/scheduler/at-fallback.d.ts +95 -0
- package/dist/core/scheduler/at-fallback.d.ts.map +1 -0
- package/dist/core/scheduler/at-fallback.js +200 -0
- package/dist/core/scheduler/linux.d.ts +13 -2
- package/dist/core/scheduler/linux.d.ts.map +1 -1
- package/dist/core/scheduler/linux.js +67 -13
- package/dist/core/scheduler/mac.d.ts +14 -8
- package/dist/core/scheduler/mac.d.ts.map +1 -1
- package/dist/core/scheduler/mac.js +71 -22
- package/dist/core/scheduler/posix.d.ts.map +1 -1
- package/dist/core/scheduler/posix.js +37 -2
- package/dist/core/scheduler/registry.d.ts +13 -0
- package/dist/core/scheduler/registry.d.ts.map +1 -1
- package/dist/core/scheduler/registry.js +83 -21
- package/dist/core/scheduler/run-now.d.ts +16 -0
- package/dist/core/scheduler/run-now.d.ts.map +1 -0
- package/dist/core/scheduler/run-now.js +28 -0
- package/dist/core/scheduler/windows.d.ts +16 -3
- package/dist/core/scheduler/windows.d.ts.map +1 -1
- package/dist/core/scheduler/windows.js +249 -96
- package/dist/core/secrets.d.ts.map +1 -1
- package/dist/core/secrets.js +127 -30
- package/dist/core/self-analysis.js +55 -55
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +18 -11
- package/dist/core/summary.js +1 -1
- package/dist/core/task-name.d.ts +24 -0
- package/dist/core/task-name.d.ts.map +1 -0
- package/dist/core/task-name.js +40 -0
- package/dist/core/triage-chain.js +1 -1
- package/dist/core/triage-worker.js +2 -2
- package/dist/core/triage.js +1 -1
- package/dist/core/wrappers/bash.d.ts.map +1 -1
- package/dist/core/wrappers/bash.js +82 -37
- package/dist/db/capability-repo.d.ts +83 -0
- package/dist/db/capability-repo.d.ts.map +1 -0
- package/dist/db/capability-repo.js +182 -0
- package/dist/db/history-repo.d.ts +8 -0
- package/dist/db/history-repo.d.ts.map +1 -1
- package/dist/db/history-repo.js +19 -0
- package/dist/db/index.d.ts +6 -0
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +48 -2
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +3 -1
- package/dist/db/run-context.d.ts +103 -0
- package/dist/db/run-context.d.ts.map +1 -0
- package/dist/db/run-context.js +224 -0
- package/dist/db/run-dlq.d.ts +100 -0
- package/dist/db/run-dlq.d.ts.map +1 -0
- package/dist/db/run-dlq.js +191 -0
- package/dist/db/run-journal.d.ts +60 -0
- package/dist/db/run-journal.d.ts.map +1 -0
- package/dist/db/run-journal.js +143 -0
- package/dist/db/run-resume.d.ts +51 -0
- package/dist/db/run-resume.d.ts.map +1 -0
- package/dist/db/run-resume.js +156 -0
- package/dist/db/runs-repo.d.ts +128 -0
- package/dist/db/runs-repo.d.ts.map +1 -0
- package/dist/db/runs-repo.js +342 -0
- package/dist/db/schema.d.ts +16 -2
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +342 -35
- package/dist/db/settings-repo.d.ts +11 -0
- package/dist/db/settings-repo.d.ts.map +1 -1
- package/dist/db/settings-repo.js +25 -0
- package/dist/db/step-idempotency.d.ts +51 -0
- package/dist/db/step-idempotency.d.ts.map +1 -0
- package/dist/db/step-idempotency.js +136 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +168 -40
- package/dist/notifications.js +18 -18
- package/dist/profiles.d.ts +7 -3
- package/dist/profiles.d.ts.map +1 -1
- package/dist/profiles.js +85 -7
- package/dist/rpc.d.ts +787 -0
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +324 -0
- package/dist/server.d.ts +33 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +115 -54
- package/dist/shared/jobs-view.d.ts.map +1 -1
- package/dist/skill.js +1 -1
- package/dist/task-transfer.d.ts +1 -1
- package/dist/task-transfer.d.ts.map +1 -1
- package/dist/task-transfer.js +14 -10
- package/dist/types.d.ts +20 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +44 -9
- package/dist/workspaces.d.ts +25 -3
- package/dist/workspaces.d.ts.map +1 -1
- package/dist/workspaces.js +44 -9
- package/docs/ARCHITECTURE.md +335 -9
- package/docs/COMPATIBILITY.md +10 -6
- package/docs/CONCEPT.md +183 -91
- package/docs/CROSS_PLATFORM.ru.md +11 -9
- package/docs/CROSS_PLATFORM.zh.md +11 -9
- package/docs/EXECUTION-LOOP.md +196 -0
- package/docs/FAQ.md +2 -2
- package/docs/FAQ.ru.md +2 -2
- package/docs/FAQ.zh.md +2 -2
- package/docs/FEATURES.md +5 -4
- package/docs/FEATURES.zh.md +5 -4
- package/docs/MIGRATION.md +34 -26
- package/docs/README.ru.md +27 -8
- package/docs/README.zh.md +11 -10
- package/docs/SAFETY.md +122 -0
- package/docs/SAVINGS.md +29 -0
- package/docs/SAVINGS.ru.md +29 -0
- package/docs/SAVINGS.zh.md +18 -0
- package/docs/V1-V2-COMPATIBILITY-PLAN.md +6 -6
- package/gui-experimental.cjs +8 -8
- package/index.js +1 -0
- package/locales/en.json +68 -0
- package/locales/ru.json +68 -0
- package/locales/zh.json +68 -0
- package/package.json +57 -11
- package/scripts/audit-bundle.mjs +215 -0
- package/src/core/analytics.ts +2 -2
- package/src/core/audit.ts +17 -17
- package/src/core/cron-to-schtasks.ts +14 -93
- package/src/core/dlq-api.ts +98 -0
- package/src/core/dry-run.ts +51 -27
- package/src/core/file-watcher.ts +17 -17
- package/src/core/git-trigger.ts +9 -9
- package/src/core/glob.ts +1 -1
- package/src/core/local-ai.ts +2 -2
- package/src/core/lock.ts +104 -31
- package/src/core/matrix.ts +31 -31
- package/src/core/native-notify.ts +2 -2
- package/src/core/one-shot.ts +91 -13
- package/src/core/opencode-cli.ts +103 -0
- package/src/core/opencode-models.ts +315 -0
- package/src/core/otel.ts +4 -4
- package/src/core/permissions.ts +5 -5
- package/src/core/prometheus.ts +17 -17
- package/src/core/ps-wrapper.ts +68 -38
- package/src/core/record-history.ts +114 -76
- package/src/core/retention.ts +3 -3
- package/src/core/router/dispatch.ts +94 -0
- package/src/core/router/escalation.ts +129 -0
- package/src/core/router/planner.ts +166 -0
- package/src/core/router/rules.ts +109 -0
- package/src/core/run-panel-api.ts +262 -0
- package/src/core/savings.ts +1 -1
- package/src/core/schedule-gate.ts +17 -13
- package/src/core/schedule-v2.ts +138 -29
- package/src/core/scheduler/at-fallback.ts +298 -0
- package/src/core/scheduler/index.ts +3 -3
- package/src/core/scheduler/linux.ts +92 -19
- package/src/core/scheduler/logs.ts +1 -1
- package/src/core/scheduler/mac.ts +112 -60
- package/src/core/scheduler/posix.ts +35 -2
- package/src/core/scheduler/registry.ts +109 -26
- package/src/core/scheduler/run-now.ts +32 -0
- package/src/core/scheduler/windows.ts +295 -125
- package/src/core/secrets.ts +139 -39
- package/src/core/self-analysis.ts +61 -61
- package/src/core/session.ts +26 -13
- package/src/core/structured-log.ts +3 -3
- package/src/core/summary.ts +25 -25
- package/src/core/task-name.ts +67 -0
- package/src/core/telegram.ts +16 -16
- package/src/core/triage-chain.ts +4 -4
- package/src/core/triage-compare.ts +8 -8
- package/src/core/triage-rules.ts +4 -4
- package/src/core/triage-shadow.ts +7 -7
- package/src/core/triage-worker.ts +6 -6
- package/src/core/triage.ts +23 -23
- package/src/core/watch-paths.ts +1 -1
- package/src/core/wrappers/bash.ts +90 -45
- package/src/db/capability-repo.ts +285 -0
- package/src/db/git-state-repo.ts +1 -1
- package/src/db/history-repo.ts +44 -22
- package/src/db/index.ts +53 -7
- package/src/db/metrics-repo.ts +10 -10
- package/src/db/migrate.ts +13 -11
- package/src/db/recovery.ts +3 -3
- package/src/db/run-context.ts +370 -0
- package/src/db/run-dlq.ts +310 -0
- package/src/db/run-journal.ts +212 -0
- package/src/db/run-resume.ts +256 -0
- package/src/db/runs-repo.ts +504 -0
- package/src/db/schema.ts +357 -44
- package/src/db/settings-repo.ts +33 -2
- package/src/db/step-idempotency.ts +185 -0
- package/src/db/tasks-repo.ts +10 -10
- package/src/db/templates-repo.ts +7 -7
- package/src/gui.tsx +516 -1
- package/src/history.ts +4 -4
- package/src/i18n.ts +7 -7
- package/src/index.ts +465 -308
- package/src/integrations.ts +6 -6
- package/src/notifications.ts +76 -76
- package/src/profiles.ts +98 -7
- package/src/rpc.ts +347 -1
- package/src/schtasks.ts +2 -2
- package/src/server.ts +155 -78
- package/src/settings.ts +44 -44
- package/src/shared/jobs-view.ts +60 -60
- package/src/skill.ts +1 -1
- package/src/task-transfer.ts +58 -56
- package/src/templates.ts +1 -1
- package/src/types.ts +54 -10
- package/src/workspaces.ts +73 -24
- package/dist/core/self-analysis.test.d.ts +0 -2
- package/dist/core/self-analysis.test.d.ts.map +0 -1
- package/dist/core/self-analysis.test.js +0 -219
- package/dist/gui-experimental.cjs +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { getProfileDir, getProfileName } from "../../profiles.js";
|
|
4
|
+
import { LockManager, withLockWait } from "../lock.js";
|
|
4
5
|
import type { TriggerType } from "./types.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -27,16 +28,24 @@ export interface RegistryEntry {
|
|
|
27
28
|
model?: string;
|
|
28
29
|
/** Приоритет задачи 0..10 (опционально). */
|
|
29
30
|
priority?: number;
|
|
31
|
+
/** IANA-таймзона задачи (опционально, undefined — системная). */
|
|
32
|
+
timezone?: string;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
/** Реестр задач конкретного бэкенда: <pluginDir>/scheduler-<backend>.json. */
|
|
33
36
|
export class TaskRegistry {
|
|
34
37
|
private readonly file: string;
|
|
35
38
|
private readonly dir: string;
|
|
39
|
+
private readonly backendId: string;
|
|
40
|
+
private readonly lock: LockManager;
|
|
36
41
|
|
|
37
42
|
constructor(backendId: string, profile: string = getProfileName()) {
|
|
43
|
+
this.backendId = backendId;
|
|
38
44
|
this.dir = getProfileDir(profile);
|
|
39
45
|
this.file = path.join(this.dir, `scheduler-${backendId}.json`);
|
|
46
|
+
// P2-16: мутации реестра — read-modify-write. Лок сериализует их между
|
|
47
|
+
// процессами (хост OpenCode, CLI, detached record-history).
|
|
48
|
+
this.lock = new LockManager(path.join(this.dir, "locks"));
|
|
40
49
|
}
|
|
41
50
|
|
|
42
51
|
/** Путь к файлу реестра (для диагностики). */
|
|
@@ -44,18 +53,69 @@ export class TaskRegistry {
|
|
|
44
53
|
return this.file;
|
|
45
54
|
}
|
|
46
55
|
|
|
56
|
+
/** Маркер того, что реестр был повреждён и перемещён в карантин. */
|
|
57
|
+
private get blockedPath(): string {
|
|
58
|
+
return `${this.file}.blocked`;
|
|
59
|
+
}
|
|
60
|
+
|
|
47
61
|
async load(): Promise<RegistryEntry[]> {
|
|
62
|
+
let raw: string;
|
|
48
63
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
raw = await fs.readFile(this.file, "utf8");
|
|
65
|
+
} catch (err: any) {
|
|
66
|
+
if (err?.code === "ENOENT") {
|
|
67
|
+
// Карантин уже переместил файл. Пустой реестр нельзя выдавать за
|
|
68
|
+
// «задач нет»: rebuildCrontab вычистил бы все cron-строки плагина.
|
|
69
|
+
const blocked = await fs.readFile(this.blockedPath, "utf8").catch(() => null);
|
|
70
|
+
if (blocked) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`Реестр задач повреждён (карантин: ${blocked.trim()}). ` +
|
|
73
|
+
`Восстановите ${this.file} вручную или удалите маркер ${this.blockedPath}.`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
throw err;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let parsed: unknown;
|
|
82
|
+
try {
|
|
83
|
+
parsed = JSON.parse(raw);
|
|
84
|
+
} catch (err) {
|
|
85
|
+
return this.quarantineCorrupt(err);
|
|
86
|
+
}
|
|
87
|
+
if (!Array.isArray(parsed)) {
|
|
88
|
+
return this.quarantineCorrupt(new Error("expected an array of registry entries"));
|
|
89
|
+
}
|
|
90
|
+
return parsed.filter(
|
|
91
|
+
(entry): entry is RegistryEntry =>
|
|
92
|
+
entry && typeof entry.name === "string" && typeof entry.command === "string",
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Перемещает повреждённый файл в карантин и блокирует дальнейшие записи. */
|
|
97
|
+
private async quarantineCorrupt(err: unknown): Promise<never> {
|
|
98
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
99
|
+
const target = `${this.file}.corrupt-${stamp}`;
|
|
100
|
+
let moved = "";
|
|
101
|
+
try {
|
|
102
|
+
await fs.rename(this.file, target);
|
|
103
|
+
await fs.writeFile(this.blockedPath, target, "utf8");
|
|
104
|
+
moved = ` Файл перемещён в ${target}.`;
|
|
105
|
+
console.warn(
|
|
106
|
+
`[scheduler] Реестр ${path.basename(this.file)} повреждён и перемещён в ${target}. ` +
|
|
107
|
+
`Запись заблокирована маркером ${this.blockedPath}.`,
|
|
108
|
+
err,
|
|
109
|
+
);
|
|
110
|
+
} catch (renameErr) {
|
|
111
|
+
console.error(
|
|
112
|
+
`[scheduler] Не удалось переместить повреждённый реестр ${this.file} в ${target}.`,
|
|
113
|
+
renameErr,
|
|
55
114
|
);
|
|
56
|
-
} catch {
|
|
57
|
-
return [];
|
|
58
115
|
}
|
|
116
|
+
throw new Error(
|
|
117
|
+
`Реестр задач повреждён.${moved} Восстановите ${this.file} вручную или удалите маркер ${this.blockedPath}.`,
|
|
118
|
+
);
|
|
59
119
|
}
|
|
60
120
|
|
|
61
121
|
async save(entries: RegistryEntry[]): Promise<void> {
|
|
@@ -63,6 +123,28 @@ export class TaskRegistry {
|
|
|
63
123
|
const tmp = `${this.file}.tmp`;
|
|
64
124
|
await fs.writeFile(tmp, JSON.stringify(entries, null, 2), "utf8");
|
|
65
125
|
await fs.rename(tmp, this.file);
|
|
126
|
+
await fs.rm(this.blockedPath, { force: true }).catch(() => {
|
|
127
|
+
/* маркера могло не быть */
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Read-modify-write под межпроцессной блокировкой: два процесса на одном
|
|
133
|
+
* профиле не должны терять чужие записи (P2-16).
|
|
134
|
+
*/
|
|
135
|
+
private async mutate<T>(fn: (entries: RegistryEntry[]) => T | Promise<T>): Promise<T> {
|
|
136
|
+
await this.lock.initialize();
|
|
137
|
+
return withLockWait(
|
|
138
|
+
this.lock,
|
|
139
|
+
`registry-${this.backendId}`,
|
|
140
|
+
async () => {
|
|
141
|
+
const entries = await this.load();
|
|
142
|
+
const result = await fn(entries);
|
|
143
|
+
await this.save(entries);
|
|
144
|
+
return result;
|
|
145
|
+
},
|
|
146
|
+
{ timeoutMs: 15000, staleMs: 60000 },
|
|
147
|
+
);
|
|
66
148
|
}
|
|
67
149
|
|
|
68
150
|
async find(name: string): Promise<RegistryEntry | undefined> {
|
|
@@ -71,29 +153,30 @@ export class TaskRegistry {
|
|
|
71
153
|
}
|
|
72
154
|
|
|
73
155
|
async upsert(entry: RegistryEntry): Promise<void> {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
156
|
+
await this.mutate((entries) => {
|
|
157
|
+
const index = entries.findIndex(
|
|
158
|
+
(e) => e.name.toLowerCase() === entry.name.toLowerCase(),
|
|
159
|
+
);
|
|
160
|
+
if (index === -1) entries.push(entry);
|
|
161
|
+
else entries[index] = entry;
|
|
162
|
+
});
|
|
81
163
|
}
|
|
82
164
|
|
|
83
165
|
async remove(name: string): Promise<void> {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
166
|
+
await this.mutate((entries) => {
|
|
167
|
+
const index = entries.findIndex(
|
|
168
|
+
(e) => e.name.toLowerCase() === name.toLowerCase(),
|
|
169
|
+
);
|
|
170
|
+
if (index !== -1) entries.splice(index, 1);
|
|
171
|
+
});
|
|
88
172
|
}
|
|
89
173
|
|
|
90
174
|
async setPaused(name: string, paused: boolean): Promise<void> {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
await this.save(entries);
|
|
175
|
+
await this.mutate((entries) => {
|
|
176
|
+
const entry = entries.find(
|
|
177
|
+
(e) => e.name.toLowerCase() === name.toLowerCase(),
|
|
178
|
+
);
|
|
179
|
+
if (entry) entry.paused = paused;
|
|
180
|
+
});
|
|
98
181
|
}
|
|
99
182
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import { requestImmediateRun } from "../ps-wrapper.js";
|
|
3
|
+
import { createSchedulerBackend } from "./index.js";
|
|
4
|
+
import type { RunTaskResult, SchedulerBackend } from "./types.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Немедленный запуск задачи в обход schedule-gate.
|
|
8
|
+
*
|
|
9
|
+
* Зачем: для poll-режима (расширенный cron / чужая IANA-таймзона / окно
|
|
10
|
+
* запуска) обёртка всегда прогоняет schedule-gate, и запуск вне cron-окна
|
|
11
|
+
* молча завершается с exit 3. Это касается не только `run_task_now`, но и
|
|
12
|
+
* цепочек (nextTaskOnSuccess / nextTaskOnError), DAG-зависимостей и retry:
|
|
13
|
+
* они тоже запускают задачу «сейчас», а не «по расписанию».
|
|
14
|
+
*
|
|
15
|
+
* Маркер `requestImmediateRun` снимает проверку расписания внутри обёртки.
|
|
16
|
+
* Если планировщик не принял запуск, маркер удаляется, чтобы он не «разрешил»
|
|
17
|
+
* следующий плановый тик в обход расписания.
|
|
18
|
+
*/
|
|
19
|
+
export async function runTaskNow(
|
|
20
|
+
taskName: string,
|
|
21
|
+
backend: SchedulerBackend = createSchedulerBackend(),
|
|
22
|
+
): Promise<RunTaskResult> {
|
|
23
|
+
const forceFile = await requestImmediateRun(taskName);
|
|
24
|
+
try {
|
|
25
|
+
return await backend.runTask(taskName);
|
|
26
|
+
} catch (err) {
|
|
27
|
+
await fs.unlink(forceFile).catch(() => {
|
|
28
|
+
/* маркер мог быть уже поглощён gate'ом или удалён по TTL */
|
|
29
|
+
});
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
32
|
+
}
|