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
package/src/core/dry-run.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { loadTaskDefinitions } from "../task-transfer.js";
|
|
|
10
10
|
import { getHistory } from "../db/history-repo.js";
|
|
11
11
|
import { getWorkspace } from "../workspaces.js";
|
|
12
12
|
import { expandMatrixTask } from "./matrix.js";
|
|
13
|
-
import { nextRun, activeWindowState } from "./schedule-v2.js";
|
|
13
|
+
import { nextRun, activeWindowState, assessCronWindowFeasibility, windowFeasibilityReasonText } from "./schedule-v2.js";
|
|
14
14
|
import { checkGitTrigger } from "./git-trigger.js";
|
|
15
15
|
import { t } from "../i18n.js";
|
|
16
16
|
import type { TaskDefinition } from "../task-transfer.js";
|
|
@@ -118,7 +118,7 @@ const ESTIMATE_SAMPLE = 10;
|
|
|
118
118
|
export const ESTIMATED_COST_PER_1K_TOKENS_USD = 0.003;
|
|
119
119
|
|
|
120
120
|
/** Опасные паттерны, о которых обязательно предупреждаем (ключи каталога). */
|
|
121
|
-
const DANGEROUS_PATTERNS:
|
|
121
|
+
const DANGEROUS_PATTERNS: { test: RegExp; messageKey: string }[] = [
|
|
122
122
|
{ test: /rm\s+-rf\s+\/(?:\s|$)/, messageKey: "dryRun.danger.rmRoot" },
|
|
123
123
|
{ test: /git\s+push\s+.*--force(?:\s|$)/, messageKey: "dryRun.danger.forcePush" },
|
|
124
124
|
];
|
|
@@ -165,7 +165,7 @@ async function describeTrigger(opts: DescribeTriggerOptions): Promise<DryRunTrig
|
|
|
165
165
|
paths: def.gitPaths ?? undefined,
|
|
166
166
|
ignore: def.gitIgnore ?? undefined,
|
|
167
167
|
},
|
|
168
|
-
{ persist: false }
|
|
168
|
+
{ persist: false },
|
|
169
169
|
);
|
|
170
170
|
base.git = {
|
|
171
171
|
branch: result.branch ?? null,
|
|
@@ -180,7 +180,7 @@ async function describeTrigger(opts: DescribeTriggerOptions): Promise<DryRunTrig
|
|
|
180
180
|
warnings.push(t("dryRun.git.notRepo"));
|
|
181
181
|
} else if (result.status === "branch-mismatch") {
|
|
182
182
|
warnings.push(
|
|
183
|
-
t("dryRun.git.branchMismatch", { branch: def.gitBranch ?? "" })
|
|
183
|
+
t("dryRun.git.branchMismatch", { branch: def.gitBranch ?? "" }),
|
|
184
184
|
);
|
|
185
185
|
}
|
|
186
186
|
} catch (err: any) {
|
|
@@ -213,14 +213,14 @@ async function describeTrigger(opts: DescribeTriggerOptions): Promise<DryRunTrig
|
|
|
213
213
|
|
|
214
214
|
case "mcp-event": {
|
|
215
215
|
const ev = def.mcpEvent;
|
|
216
|
-
base.explanation = ev
|
|
216
|
+
base.explanation = ev?.event
|
|
217
217
|
? t("dryRun.mcp.event", {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
218
|
+
server: ev.server,
|
|
219
|
+
event: ev.event,
|
|
220
|
+
filter: ev.filter
|
|
221
|
+
? t("dryRun.mcp.filter", { filter: ev.filter })
|
|
222
|
+
: "",
|
|
223
|
+
})
|
|
224
224
|
: t("dryRun.mcp.missing");
|
|
225
225
|
break;
|
|
226
226
|
}
|
|
@@ -228,9 +228,9 @@ async function describeTrigger(opts: DescribeTriggerOptions): Promise<DryRunTrig
|
|
|
228
228
|
case "cron": {
|
|
229
229
|
base.explanation = def.timezone
|
|
230
230
|
? t("dryRun.cronTimezone", {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
schedule: def.schedule,
|
|
232
|
+
timezone: def.timezone,
|
|
233
|
+
})
|
|
234
234
|
: t("dryRun.cron", { schedule: def.schedule });
|
|
235
235
|
break;
|
|
236
236
|
}
|
|
@@ -273,16 +273,40 @@ async function describeTrigger(opts: DescribeTriggerOptions): Promise<DryRunTrig
|
|
|
273
273
|
warnings.push(
|
|
274
274
|
iso
|
|
275
275
|
? t("dryRun.window.postpone", { reason, nextOpenAt: iso })
|
|
276
|
-
: t("dryRun.window.noOpening", { reason })
|
|
276
|
+
: t("dryRun.window.noOpening", { reason }),
|
|
277
277
|
);
|
|
278
278
|
}
|
|
279
279
|
} else if (!state.active && policy === "run") {
|
|
280
280
|
warnings.push(
|
|
281
281
|
t("dryRun.window.run", {
|
|
282
282
|
reason: state.reason ?? t("dryRun.window.outside"),
|
|
283
|
-
})
|
|
283
|
+
}),
|
|
284
284
|
);
|
|
285
285
|
}
|
|
286
|
+
|
|
287
|
+
// P2-24: даже если сейчас окно откроется, cron может никогда в него не
|
|
288
|
+
// попадать (например, daily 09:00 при окне 22:00–06:00). Предупреждаем
|
|
289
|
+
// заранее — иначе задача молча не выполняется из-за лимита переноса 12 ч.
|
|
290
|
+
if ((def.triggerType ?? "cron") === "cron" && def.schedule) {
|
|
291
|
+
const feasibility = assessCronWindowFeasibility(
|
|
292
|
+
def.schedule,
|
|
293
|
+
{
|
|
294
|
+
notBefore: def.notBefore ?? undefined,
|
|
295
|
+
notAfter: def.notAfter ?? undefined,
|
|
296
|
+
days: def.activeDays ?? undefined,
|
|
297
|
+
timeZone: def.timezone ?? undefined,
|
|
298
|
+
},
|
|
299
|
+
policy,
|
|
300
|
+
);
|
|
301
|
+
if (!feasibility.feasible) {
|
|
302
|
+
warnings.push(
|
|
303
|
+
t("dryRun.window.unreachable", {
|
|
304
|
+
cron: def.schedule,
|
|
305
|
+
reason: windowFeasibilityReasonText(feasibility.reason),
|
|
306
|
+
}),
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
286
310
|
}
|
|
287
311
|
|
|
288
312
|
return base;
|
|
@@ -376,13 +400,13 @@ export async function simulatePipeline(taskName: string): Promise<DryRunReport>
|
|
|
376
400
|
|
|
377
401
|
// Matrix (Спринт 15): родитель сам не выполняется — вместо него в отчёте
|
|
378
402
|
// показываем клоны, по одному на workspace, с их cwd и оценками.
|
|
379
|
-
const units:
|
|
403
|
+
const units: { def: TaskDefinition; matrixParent?: string }[] = [];
|
|
380
404
|
for (const def of ordered) {
|
|
381
405
|
if (def.matrix) {
|
|
382
406
|
try {
|
|
383
407
|
const clones = expandMatrixTask(def);
|
|
384
408
|
warnings.push(
|
|
385
|
-
t("dryRun.matrix.parent", { name: def.name, count: clones.length })
|
|
409
|
+
t("dryRun.matrix.parent", { name: def.name, count: clones.length }),
|
|
386
410
|
);
|
|
387
411
|
for (const clone of clones) units.push({ def: clone, matrixParent: def.name });
|
|
388
412
|
} catch (err: any) {
|
|
@@ -390,7 +414,7 @@ export async function simulatePipeline(taskName: string): Promise<DryRunReport>
|
|
|
390
414
|
list.push(
|
|
391
415
|
t("dryRun.matrix.expandError", {
|
|
392
416
|
error: err instanceof Error ? err.message : String(err),
|
|
393
|
-
})
|
|
417
|
+
}),
|
|
394
418
|
);
|
|
395
419
|
warningsPerTask.set(def.name.toLowerCase(), list);
|
|
396
420
|
warnings.push(`[${def.name}] ${list[list.length - 1]}`);
|
|
@@ -404,7 +428,7 @@ export async function simulatePipeline(taskName: string): Promise<DryRunReport>
|
|
|
404
428
|
const parallelMatrixParents = new Set(
|
|
405
429
|
allDefs
|
|
406
430
|
.filter((d) => d.matrix && (d.matrix.strategy ?? "parallel") !== "sequential")
|
|
407
|
-
.map((d) => d.name.toLowerCase())
|
|
431
|
+
.map((d) => d.name.toLowerCase()),
|
|
408
432
|
);
|
|
409
433
|
const parallelGroups = new Map<string, { maxDuration: number }>();
|
|
410
434
|
|
|
@@ -481,7 +505,7 @@ export async function simulatePipeline(taskName: string): Promise<DryRunReport>
|
|
|
481
505
|
for (const { test, messageKey } of DANGEROUS_PATTERNS) {
|
|
482
506
|
if (test.test(scanned)) {
|
|
483
507
|
taskWarnings.push(
|
|
484
|
-
t("dryRun.dangerPattern", { message: t(messageKey) })
|
|
508
|
+
t("dryRun.dangerPattern", { message: t(messageKey) }),
|
|
485
509
|
);
|
|
486
510
|
}
|
|
487
511
|
}
|
|
@@ -519,7 +543,7 @@ export async function simulatePipeline(taskName: string): Promise<DryRunReport>
|
|
|
519
543
|
}
|
|
520
544
|
} catch {
|
|
521
545
|
taskWarnings.push(
|
|
522
|
-
t("dryRun.cronParseError", { schedule: def.schedule })
|
|
546
|
+
t("dryRun.cronParseError", { schedule: def.schedule }),
|
|
523
547
|
);
|
|
524
548
|
}
|
|
525
549
|
scheduleDetails = {
|
|
@@ -581,14 +605,14 @@ export async function simulatePipeline(taskName: string): Promise<DryRunReport>
|
|
|
581
605
|
}
|
|
582
606
|
|
|
583
607
|
const hasAnyEstimate = tasks.some(
|
|
584
|
-
(t) => t.estimatedDurationSec != null || t.estimatedCostUsd != null || t.estimatedTokens != null
|
|
608
|
+
(t) => t.estimatedDurationSec != null || t.estimatedCostUsd != null || t.estimatedTokens != null,
|
|
585
609
|
);
|
|
586
610
|
const totals: DryRunTotals = hasAnyEstimate
|
|
587
611
|
? {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
612
|
+
estimatedDurationSec: totalDuration != null ? Math.round(totalDuration * 10) / 10 : null,
|
|
613
|
+
estimatedCostUsd: totalCost != null ? Math.round(totalCost * 10000) / 10000 : null,
|
|
614
|
+
estimatedTokens: totalTokens != null ? Math.round(totalTokens) : null,
|
|
615
|
+
}
|
|
592
616
|
: { estimatedDurationSec: null, estimatedCostUsd: null, estimatedTokens: null };
|
|
593
617
|
|
|
594
618
|
return {
|
package/src/core/file-watcher.ts
CHANGED
|
@@ -39,7 +39,7 @@ export class FileWatchManager {
|
|
|
39
39
|
|
|
40
40
|
constructor(
|
|
41
41
|
private readonly handler: FileTriggerHandler,
|
|
42
|
-
private readonly debounceMs: number = FILE_TRIGGER_DEBOUNCE_MS
|
|
42
|
+
private readonly debounceMs: number = FILE_TRIGGER_DEBOUNCE_MS,
|
|
43
43
|
) {}
|
|
44
44
|
|
|
45
45
|
/** Сколько задач сейчас отслеживается. */
|
|
@@ -61,7 +61,7 @@ export class FileWatchManager {
|
|
|
61
61
|
(d) =>
|
|
62
62
|
d.triggerType === "file" &&
|
|
63
63
|
typeof d.watchPath === "string" &&
|
|
64
|
-
d.watchPath.trim().length > 0
|
|
64
|
+
d.watchPath.trim().length > 0,
|
|
65
65
|
)
|
|
66
66
|
.map((d) => ({
|
|
67
67
|
name: d.name.trim(),
|
|
@@ -79,13 +79,13 @@ export class FileWatchManager {
|
|
|
79
79
|
// watcher на путях с управляющими символами или выходом через `..`.
|
|
80
80
|
if (hasPathControlChars(d.path)) {
|
|
81
81
|
console.error(
|
|
82
|
-
`[
|
|
82
|
+
`[agent-steward] Задача "${d.name}": путь наблюдения содержит управляющие символы — пропущен.`,
|
|
83
83
|
);
|
|
84
84
|
return false;
|
|
85
85
|
}
|
|
86
86
|
if (!isAbsolute(d.path) && d.path.split(/[\\/]/).includes("..")) {
|
|
87
87
|
console.error(
|
|
88
|
-
`[
|
|
88
|
+
`[agent-steward] Задача "${d.name}": относительный путь наблюдения выходит за рабочую директорию — пропущен.`,
|
|
89
89
|
);
|
|
90
90
|
return false;
|
|
91
91
|
}
|
|
@@ -130,7 +130,7 @@ export class FileWatchManager {
|
|
|
130
130
|
name: string,
|
|
131
131
|
watchPath: string,
|
|
132
132
|
globs: string[] = [],
|
|
133
|
-
ignore: string[] = []
|
|
133
|
+
ignore: string[] = [],
|
|
134
134
|
): void {
|
|
135
135
|
// Спринт 27: маски с "**" требуют рекурсивного обхода директории.
|
|
136
136
|
const needsRecursive = globs.some((g) => g.includes("**"));
|
|
@@ -148,9 +148,9 @@ export class FileWatchManager {
|
|
|
148
148
|
});
|
|
149
149
|
} catch (err: any) {
|
|
150
150
|
console.error(
|
|
151
|
-
`[
|
|
151
|
+
`[agent-steward] Не удалось начать отслеживание "${watchPath}" для задачи "${name}": ${
|
|
152
152
|
err instanceof Error ? err.message : String(err)
|
|
153
|
-
}
|
|
153
|
+
}`,
|
|
154
154
|
);
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
@@ -174,7 +174,7 @@ export class FileWatchManager {
|
|
|
174
174
|
const rel = relativeTo(watchPath, changedPath);
|
|
175
175
|
const candidates = rel ? [rel, changedPath] : [changedPath];
|
|
176
176
|
return candidates.some(
|
|
177
|
-
(candidate) => filterPaths([candidate], globs, ignore).length > 0
|
|
177
|
+
(candidate) => filterPaths([candidate], globs, ignore).length > 0,
|
|
178
178
|
);
|
|
179
179
|
};
|
|
180
180
|
|
|
@@ -187,20 +187,20 @@ export class FileWatchManager {
|
|
|
187
187
|
if (this.stopped) return;
|
|
188
188
|
try {
|
|
189
189
|
const result = this.handler(name, changedPath);
|
|
190
|
-
if (result && typeof (result
|
|
191
|
-
(result
|
|
190
|
+
if (result && typeof (result).catch === "function") {
|
|
191
|
+
(result).catch((err: any) => {
|
|
192
192
|
console.error(
|
|
193
|
-
`[
|
|
193
|
+
`[agent-steward] Ошибка запуска задачи "${name}" по изменению файла: ${
|
|
194
194
|
err instanceof Error ? err.message : String(err)
|
|
195
|
-
}
|
|
195
|
+
}`,
|
|
196
196
|
);
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
199
|
} catch (err: any) {
|
|
200
200
|
console.error(
|
|
201
|
-
`[
|
|
201
|
+
`[agent-steward] Ошибка запуска задачи "${name}" по изменению файла: ${
|
|
202
202
|
err instanceof Error ? err.message : String(err)
|
|
203
|
-
}
|
|
203
|
+
}`,
|
|
204
204
|
);
|
|
205
205
|
}
|
|
206
206
|
}, this.debounceMs);
|
|
@@ -216,15 +216,15 @@ export class FileWatchManager {
|
|
|
216
216
|
|
|
217
217
|
watcher.on("error", (err) => {
|
|
218
218
|
console.error(
|
|
219
|
-
`[
|
|
219
|
+
`[agent-steward] Ошибка наблюдения за "${watchPath}" (задача "${name}"): ${
|
|
220
220
|
(err as any)?.message ?? String(err)
|
|
221
|
-
}
|
|
221
|
+
}`,
|
|
222
222
|
);
|
|
223
223
|
});
|
|
224
224
|
|
|
225
225
|
this.entries.set(name.toLowerCase(), entry);
|
|
226
226
|
console.log(
|
|
227
|
-
`[
|
|
227
|
+
`[agent-steward] Слежу за "${watchPath}" — задача "${name}" запускается при изменении файла.`,
|
|
228
228
|
);
|
|
229
229
|
}
|
|
230
230
|
|
package/src/core/git-trigger.ts
CHANGED
|
@@ -70,11 +70,11 @@ const defaultRunner: GitRunner = (cwd, args) =>
|
|
|
70
70
|
{ timeout: GIT_COMMAND_TIMEOUT_MS, windowsHide: true, maxBuffer: 4 * 1024 * 1024 },
|
|
71
71
|
(err, stdout) => {
|
|
72
72
|
if (err) {
|
|
73
|
-
reject(err);
|
|
73
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
resolve(String(stdout ?? ""));
|
|
77
|
-
}
|
|
77
|
+
},
|
|
78
78
|
);
|
|
79
79
|
});
|
|
80
80
|
|
|
@@ -113,7 +113,7 @@ export async function gitChangedFiles(
|
|
|
113
113
|
cwd: string,
|
|
114
114
|
from: string | null,
|
|
115
115
|
to: string,
|
|
116
|
-
run: GitRunner = defaultRunner
|
|
116
|
+
run: GitRunner = defaultRunner,
|
|
117
117
|
): Promise<string[]> {
|
|
118
118
|
const args = from
|
|
119
119
|
? ["diff", "--name-only", `${from}..${to}`]
|
|
@@ -126,7 +126,7 @@ export async function gitChangedFiles(
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
function branchMatches(branch: string | null, pattern?: string): boolean {
|
|
129
|
-
if (!pattern
|
|
129
|
+
if (!pattern?.trim()) return true;
|
|
130
130
|
if (!branch) return false;
|
|
131
131
|
const normalize = (value: string) =>
|
|
132
132
|
process.platform === "win32" ? value.toLowerCase() : value;
|
|
@@ -151,7 +151,7 @@ function branchMatches(branch: string | null, pattern?: string): boolean {
|
|
|
151
151
|
*/
|
|
152
152
|
export async function checkGitTrigger(
|
|
153
153
|
task: GitTriggerTask,
|
|
154
|
-
options: { run?: GitRunner; persist?: boolean } = {}
|
|
154
|
+
options: { run?: GitRunner; persist?: boolean } = {},
|
|
155
155
|
): Promise<GitCheckResult> {
|
|
156
156
|
const run = options.run ?? defaultRunner;
|
|
157
157
|
const persist = options.persist !== false;
|
|
@@ -328,7 +328,7 @@ export class GitTriggerManager {
|
|
|
328
328
|
return checkGitTrigger(this.taskSpec(managed.def), { run: this.run });
|
|
329
329
|
}
|
|
330
330
|
const def = (await loadTaskDefinitions()).find(
|
|
331
|
-
(d) => d.triggerType === "git" && d.name.toLowerCase() === taskName.toLowerCase()
|
|
331
|
+
(d) => d.triggerType === "git" && d.name.toLowerCase() === taskName.toLowerCase(),
|
|
332
332
|
);
|
|
333
333
|
if (!def) return null;
|
|
334
334
|
return checkGitTrigger(this.taskSpec(def), { run: this.run });
|
|
@@ -354,13 +354,13 @@ export class GitTriggerManager {
|
|
|
354
354
|
if (result.status === "changed") {
|
|
355
355
|
await this.handler(managed.def.name, { ...result, cwd: cwdOf(managed.def) });
|
|
356
356
|
} else if (result.status === "error") {
|
|
357
|
-
console.error(`[
|
|
357
|
+
console.error(`[agent-steward] git-триггер «${managed.def.name}»: ${result.message}`);
|
|
358
358
|
}
|
|
359
359
|
} catch (err: any) {
|
|
360
360
|
console.error(
|
|
361
|
-
`[
|
|
361
|
+
`[agent-steward] git-триггер «${managed.def.name}»: ${
|
|
362
362
|
err instanceof Error ? err.message : String(err)
|
|
363
|
-
}
|
|
363
|
+
}`,
|
|
364
364
|
);
|
|
365
365
|
} finally {
|
|
366
366
|
managed.busy = false;
|
package/src/core/glob.ts
CHANGED
|
@@ -196,7 +196,7 @@ export function isIgnored(path: unknown, ignore: unknown): boolean {
|
|
|
196
196
|
export function filterPaths(
|
|
197
197
|
files: string[],
|
|
198
198
|
include?: string[] | null,
|
|
199
|
-
ignore?: string[] | null
|
|
199
|
+
ignore?: string[] | null,
|
|
200
200
|
): string[] {
|
|
201
201
|
const list = Array.isArray(files) ? files : [];
|
|
202
202
|
const includes = Array.isArray(include) ? include.filter(Boolean) : [];
|
package/src/core/local-ai.ts
CHANGED
|
@@ -70,7 +70,7 @@ export function protocolFor(baseUrl: string): "openai" | "ollama" {
|
|
|
70
70
|
*/
|
|
71
71
|
export function applyLocalAiPatch(
|
|
72
72
|
current: TriageSettings,
|
|
73
|
-
patch: LocalAiPatch
|
|
73
|
+
patch: LocalAiPatch,
|
|
74
74
|
): { settings: TriageSettings; changed: string[] } {
|
|
75
75
|
const next: TriageSettings = { ...current, shadow: { ...current.shadow } as TriageShadowSettings };
|
|
76
76
|
const changed: string[] = [];
|
|
@@ -98,7 +98,7 @@ export function applyLocalAiPatch(
|
|
|
98
98
|
patch.timeoutMs,
|
|
99
99
|
LOCAL_AI_TIMEOUT_MIN,
|
|
100
100
|
LOCAL_AI_TIMEOUT_MAX,
|
|
101
|
-
current.timeoutMs
|
|
101
|
+
current.timeoutMs,
|
|
102
102
|
);
|
|
103
103
|
if (timeoutMs !== current.timeoutMs) {
|
|
104
104
|
next.timeoutMs = timeoutMs;
|
package/src/core/lock.ts
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
3
4
|
import { LOCK_DIR, STALE_LOCK_MAX_AGE_MS } from "../types.js";
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Проверяет, жив ли процесс-владелец lock-файла.
|
|
8
|
+
*
|
|
9
|
+
* `process.kill(pid, 0)` не посылает сигнал, а только проверяет существование.
|
|
10
|
+
* EPERM означает, что процесс есть, но у нас нет прав на сигнал — считаем живым.
|
|
11
|
+
* Остальные ошибки трактуем консервативно как «жив», чтобы не вытеснить
|
|
12
|
+
* чужую критическую секцию.
|
|
13
|
+
*/
|
|
14
|
+
export function isProcessAlive(pid: number): boolean {
|
|
15
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
16
|
+
try {
|
|
17
|
+
process.kill(pid, 0);
|
|
18
|
+
return true;
|
|
19
|
+
} catch (err: any) {
|
|
20
|
+
if (err?.code === "ESRCH") return false;
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** PID владельца из токена lock-файла (`<pid>-<timestamp>-<uuid>`). */
|
|
26
|
+
function ownerPidFromToken(content: string): number | null {
|
|
27
|
+
const match = /^(\d+)-/.exec(content.trim());
|
|
28
|
+
if (!match) return null;
|
|
29
|
+
const pid = Number.parseInt(match[1], 10);
|
|
30
|
+
return Number.isInteger(pid) ? pid : null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
5
34
|
/**
|
|
6
35
|
* Менеджер файловых блокировок для предотвращения наложения запусков одной задачи.
|
|
7
36
|
*
|
|
@@ -60,6 +89,21 @@ export class LockManager {
|
|
|
60
89
|
const stat = await fs.stat(fullPath);
|
|
61
90
|
const age = now - stat.mtimeMs;
|
|
62
91
|
if (age > STALE_LOCK_MAX_AGE_MS) {
|
|
92
|
+
// P2-18: возраст — только повод проверить владельца. Задача может
|
|
93
|
+
// легально работать дольше 24 ч (timeoutSeconds: 0), поэтому живой
|
|
94
|
+
// процесс не вытесняем: иначе после рестарта плагина появится дубль.
|
|
95
|
+
if (isLockFile) {
|
|
96
|
+
const content = await fs.readFile(fullPath, "utf8").catch(() => "");
|
|
97
|
+
const ownerPid = ownerPidFromToken(content);
|
|
98
|
+
if (ownerPid !== null && isProcessAlive(ownerPid)) {
|
|
99
|
+
console.log(
|
|
100
|
+
`[agent-steward] Lock ${file} старше ${Math.round(
|
|
101
|
+
age / 1000,
|
|
102
|
+
)} с, но процесс ${ownerPid} жив — оставляем.`,
|
|
103
|
+
);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
63
107
|
// T-03: не удаляем lock напрямую. Два воркера могли одновременно
|
|
64
108
|
// снести один и тот же файл, после чего один из них удалял свежий
|
|
65
109
|
// lock, созданный другим, и задача запускалась повторно. Атомарный
|
|
@@ -72,11 +116,11 @@ export class LockManager {
|
|
|
72
116
|
continue;
|
|
73
117
|
}
|
|
74
118
|
await fs.rm(stalePath, { recursive: true, force: true }).catch(() => {});
|
|
75
|
-
|
|
119
|
+
|
|
76
120
|
console.log(
|
|
77
|
-
`[
|
|
78
|
-
age / 1000
|
|
79
|
-
)} с)
|
|
121
|
+
`[agent-steward] Вытеснен зависший lock: ${file} (возраст ${Math.round(
|
|
122
|
+
age / 1000,
|
|
123
|
+
)} с)`,
|
|
80
124
|
);
|
|
81
125
|
}
|
|
82
126
|
} catch {
|
|
@@ -87,20 +131,24 @@ export class LockManager {
|
|
|
87
131
|
|
|
88
132
|
/**
|
|
89
133
|
* Пытается захватить блокировку для задачи.
|
|
90
|
-
* Возвращает
|
|
91
|
-
*
|
|
134
|
+
* Возвращает уникальный токен владельца (он же содержимое lock-файла) или
|
|
135
|
+
* null, если блокировка уже удерживается другим запуском.
|
|
136
|
+
*
|
|
137
|
+
* Токен нужен release(): процесс, чей lock был вытеснен по stale-таймауту,
|
|
138
|
+
* не должен удалять файл нового владельца.
|
|
92
139
|
*/
|
|
93
|
-
async acquire(taskName: string): Promise<
|
|
140
|
+
async acquire(taskName: string): Promise<string | null> {
|
|
94
141
|
await fs.mkdir(this.lockDir, { recursive: true });
|
|
95
142
|
const lockPath = this.lockFilePath(taskName);
|
|
143
|
+
const token = `${process.pid}-${Date.now()}-${randomUUID()}`;
|
|
96
144
|
|
|
97
145
|
try {
|
|
98
146
|
// 'wx' — exclusive create: ошибка если файл уже существует.
|
|
99
|
-
await fs.writeFile(lockPath,
|
|
100
|
-
return
|
|
147
|
+
await fs.writeFile(lockPath, token, { flag: "wx" });
|
|
148
|
+
return token;
|
|
101
149
|
} catch (err: any) {
|
|
102
150
|
if (err.code === "EEXIST") {
|
|
103
|
-
return
|
|
151
|
+
return null;
|
|
104
152
|
}
|
|
105
153
|
throw err;
|
|
106
154
|
}
|
|
@@ -108,14 +156,28 @@ export class LockManager {
|
|
|
108
156
|
|
|
109
157
|
/**
|
|
110
158
|
* Освобождает блокировку задачи (удаляет lock-файл).
|
|
159
|
+
*
|
|
160
|
+
* Удаляет файл только если в нём лежит токен этого владельца. Если lock
|
|
161
|
+
* успели вытеснить и перехватить, release ничего не трогает и возвращает
|
|
162
|
+
* false — иначе старый процесс снёс бы чужую критическую секцию.
|
|
111
163
|
* Не выбрасывает ошибку, если файл уже удалён.
|
|
112
164
|
*/
|
|
113
|
-
async release(taskName: string): Promise<
|
|
165
|
+
async release(taskName: string, token: string): Promise<boolean> {
|
|
114
166
|
const lockPath = this.lockFilePath(taskName);
|
|
167
|
+
let current: string;
|
|
168
|
+
try {
|
|
169
|
+
current = await fs.readFile(lockPath, "utf8");
|
|
170
|
+
} catch (err: any) {
|
|
171
|
+
if (err.code === "ENOENT") return false;
|
|
172
|
+
throw err;
|
|
173
|
+
}
|
|
174
|
+
if (current !== token) return false;
|
|
115
175
|
try {
|
|
116
176
|
await fs.unlink(lockPath);
|
|
177
|
+
return true;
|
|
117
178
|
} catch (err: any) {
|
|
118
|
-
if (err.code
|
|
179
|
+
if (err.code === "ENOENT") return false;
|
|
180
|
+
throw err;
|
|
119
181
|
}
|
|
120
182
|
}
|
|
121
183
|
|
|
@@ -142,13 +204,13 @@ export class LockManager {
|
|
|
142
204
|
export async function withLock<T>(
|
|
143
205
|
lockManager: LockManager,
|
|
144
206
|
taskName: string,
|
|
145
|
-
fn: () => Promise<T
|
|
207
|
+
fn: () => Promise<T>,
|
|
146
208
|
): Promise<T | null> {
|
|
147
|
-
const
|
|
148
|
-
if (!
|
|
149
|
-
|
|
209
|
+
const token = await lockManager.acquire(taskName);
|
|
210
|
+
if (!token) {
|
|
211
|
+
|
|
150
212
|
console.log(
|
|
151
|
-
`[
|
|
213
|
+
`[agent-steward] Запуск задачи "${taskName}" пропущен: удерживается активная блокировка.`,
|
|
152
214
|
);
|
|
153
215
|
return null;
|
|
154
216
|
}
|
|
@@ -156,7 +218,7 @@ export async function withLock<T>(
|
|
|
156
218
|
try {
|
|
157
219
|
return await fn();
|
|
158
220
|
} finally {
|
|
159
|
-
await lockManager.release(taskName);
|
|
221
|
+
await lockManager.release(taskName, token);
|
|
160
222
|
}
|
|
161
223
|
}
|
|
162
224
|
|
|
@@ -171,32 +233,43 @@ export async function withLockWait<T>(
|
|
|
171
233
|
lockManager: LockManager,
|
|
172
234
|
taskName: string,
|
|
173
235
|
fn: () => Promise<T>,
|
|
174
|
-
options: { timeoutMs?: number; retryDelayMs?: number; staleMs?: number } = {}
|
|
236
|
+
options: { timeoutMs?: number; retryDelayMs?: number; staleMs?: number } = {},
|
|
175
237
|
): Promise<T> {
|
|
176
238
|
const timeoutMs = options.timeoutMs ?? 15000;
|
|
177
239
|
const retryDelayMs = options.retryDelayMs ?? 50;
|
|
178
240
|
const staleMs = options.staleMs ?? 60000;
|
|
179
241
|
const deadline = Date.now() + timeoutMs;
|
|
180
242
|
const lockPath = lockManager.pathFor(taskName);
|
|
243
|
+
let token: string | null = null;
|
|
181
244
|
|
|
182
245
|
for (;;) {
|
|
183
|
-
|
|
246
|
+
token = await lockManager.acquire(taskName);
|
|
247
|
+
if (token) break;
|
|
184
248
|
|
|
185
249
|
// Осиротевший lock: короткая операция не может длиться дольше staleMs.
|
|
186
250
|
if (staleMs > 0) {
|
|
187
251
|
try {
|
|
188
252
|
const stat = await fs.stat(lockPath);
|
|
189
253
|
if (Date.now() - stat.mtimeMs > staleMs) {
|
|
190
|
-
//
|
|
191
|
-
//
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
254
|
+
// P2-18: staleMs — не приговор. Если владелец ещё жив, его
|
|
255
|
+
// критическая секция может быть легально долгой (crontab RMW,
|
|
256
|
+
// длинная задача). Вытесняем только мёртвый/неизвестный lock.
|
|
257
|
+
const content = await fs.readFile(lockPath, "utf8").catch(() => "");
|
|
258
|
+
const ownerPid = ownerPidFromToken(content);
|
|
259
|
+
if (ownerPid !== null && isProcessAlive(ownerPid)) {
|
|
260
|
+
// Ждём дальше; по deadline вернём понятную ошибку.
|
|
261
|
+
} else {
|
|
262
|
+
// T-03-совместимое вытеснение: атомарный rename выигрывает ровно
|
|
263
|
+
// один процесс, остальные получают ENOENT и повторяют попытку.
|
|
264
|
+
const stalePath = `${lockPath}.stale-${process.pid}-${Date.now()}`;
|
|
265
|
+
try {
|
|
266
|
+
await fs.rename(lockPath, stalePath);
|
|
267
|
+
await fs.rm(stalePath, { force: true }).catch(() => {});
|
|
268
|
+
} catch {
|
|
269
|
+
// Кто-то успел раньше — просто повторяем acquire.
|
|
270
|
+
}
|
|
271
|
+
continue;
|
|
198
272
|
}
|
|
199
|
-
continue;
|
|
200
273
|
}
|
|
201
274
|
} catch {
|
|
202
275
|
// lock исчез — сразу пробуем acquire снова.
|
|
@@ -205,7 +278,7 @@ export async function withLockWait<T>(
|
|
|
205
278
|
|
|
206
279
|
if (Date.now() >= deadline) {
|
|
207
280
|
throw new Error(
|
|
208
|
-
`Не удалось получить блокировку "${taskName}" за ${timeoutMs}
|
|
281
|
+
`Не удалось получить блокировку "${taskName}" за ${timeoutMs} мс.`,
|
|
209
282
|
);
|
|
210
283
|
}
|
|
211
284
|
await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
|
|
@@ -214,6 +287,6 @@ export async function withLockWait<T>(
|
|
|
214
287
|
try {
|
|
215
288
|
return await fn();
|
|
216
289
|
} finally {
|
|
217
|
-
await lockManager.release(taskName);
|
|
290
|
+
if (token) await lockManager.release(taskName, token);
|
|
218
291
|
}
|
|
219
292
|
}
|