agent-steward 0.0.2 → 0.0.3
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 +25 -2
- package/CROSS_PLATFORM.md +11 -9
- package/README.md +9 -8
- package/ROADMAP-STRATEGY.md +93 -44
- package/ROADMAP.md +114 -999
- 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/dry-run.js +1 -1
- package/dist/core/file-watcher.js +9 -9
- package/dist/core/git-trigger.js +4 -4
- package/dist/core/lock.js +2 -4
- package/dist/core/one-shot.d.ts +27 -5
- package/dist/core/one-shot.d.ts.map +1 -1
- package/dist/core/one-shot.js +53 -10
- 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 +55 -35
- package/dist/core/record-history.js +22 -22
- package/dist/core/schedule-v2.d.ts +2 -2
- package/dist/core/schedule-v2.d.ts.map +1 -1
- package/dist/core/schedule-v2.js +7 -7
- package/dist/core/scheduler/at-fallback.d.ts +42 -0
- package/dist/core/scheduler/at-fallback.d.ts.map +1 -0
- package/dist/core/scheduler/at-fallback.js +70 -0
- package/dist/core/scheduler/linux.d.ts +3 -1
- package/dist/core/scheduler/linux.d.ts.map +1 -1
- package/dist/core/scheduler/linux.js +43 -7
- 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 +12 -1
- package/dist/core/scheduler/registry.d.ts +2 -0
- package/dist/core/scheduler/registry.d.ts.map +1 -1
- 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.js +2 -2
- package/dist/core/self-analysis.js +55 -55
- package/dist/core/summary.js +1 -1
- 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.js +33 -33
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +9 -1
- 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 +48 -0
- package/dist/db/run-resume.d.ts.map +1 -0
- package/dist/db/run-resume.js +137 -0
- package/dist/db/runs-repo.d.ts +120 -0
- package/dist/db/runs-repo.d.ts.map +1 -0
- package/dist/db/runs-repo.js +319 -0
- package/dist/db/schema.d.ts +16 -2
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +190 -35
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -36
- 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 +109 -0
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +89 -0
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +20 -19
- 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 +37 -9
- package/dist/workspaces.js +1 -1
- package/docs/ARCHITECTURE.md +110 -8
- package/docs/COMPATIBILITY.md +10 -6
- package/docs/CONCEPT.md +15 -3
- package/docs/CROSS_PLATFORM.ru.md +11 -9
- package/docs/CROSS_PLATFORM.zh.md +11 -9
- 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 +26 -7
- package/docs/README.zh.md +9 -8
- package/docs/V1-V2-COMPATIBILITY-PLAN.md +6 -6
- package/gui-experimental.cjs +8 -8
- package/index.js +1 -0
- package/locales/en.json +1 -0
- package/locales/ru.json +1 -0
- package/locales/zh.json +1 -0
- package/package.json +31 -10
- 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/dry-run.ts +26 -26
- 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 +9 -9
- package/src/core/matrix.ts +31 -31
- package/src/core/native-notify.ts +2 -2
- package/src/core/one-shot.ts +63 -13
- 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 +57 -37
- package/src/core/record-history.ts +40 -40
- package/src/core/retention.ts +3 -3
- package/src/core/savings.ts +1 -1
- package/src/core/schedule-gate.ts +12 -12
- package/src/core/schedule-v2.ts +24 -24
- package/src/core/scheduler/at-fallback.ts +113 -0
- package/src/core/scheduler/index.ts +3 -3
- package/src/core/scheduler/linux.ts +64 -13
- package/src/core/scheduler/logs.ts +1 -1
- package/src/core/scheduler/mac.ts +112 -60
- package/src/core/scheduler/posix.ts +15 -1
- package/src/core/scheduler/registry.ts +6 -4
- package/src/core/scheduler/windows.ts +295 -125
- package/src/core/secrets.ts +13 -13
- package/src/core/self-analysis.ts +61 -61
- package/src/core/session.ts +3 -3
- package/src/core/structured-log.ts +3 -3
- package/src/core/summary.ts +25 -25
- 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 +41 -41
- package/src/db/git-state-repo.ts +1 -1
- package/src/db/history-repo.ts +22 -22
- package/src/db/index.ts +16 -6
- package/src/db/metrics-repo.ts +10 -10
- package/src/db/migrate.ts +10 -10
- package/src/db/recovery.ts +3 -3
- package/src/db/run-journal.ts +212 -0
- package/src/db/run-resume.ts +220 -0
- package/src/db/runs-repo.ts +481 -0
- package/src/db/schema.ts +205 -44
- package/src/db/settings-repo.ts +2 -2
- package/src/db/tasks-repo.ts +10 -10
- package/src/db/templates-repo.ts +7 -7
- package/src/gui.tsx +1 -1
- package/src/history.ts +4 -4
- package/src/i18n.ts +7 -7
- package/src/index.ts +341 -304
- package/src/integrations.ts +6 -6
- package/src/notifications.ts +76 -76
- package/src/profiles.ts +98 -7
- package/src/rpc.ts +96 -1
- package/src/schtasks.ts +2 -2
- package/src/server.ts +43 -42
- 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 +45 -10
- package/src/workspaces.ts +16 -16
- 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/telegram.ts
CHANGED
|
@@ -34,7 +34,7 @@ export interface TelegramSendOptions {
|
|
|
34
34
|
/** Экранирует текст под выбранный parse_mode. */
|
|
35
35
|
export function escapeTelegramText(
|
|
36
36
|
text: string,
|
|
37
|
-
parseMode: TelegramParseMode = ""
|
|
37
|
+
parseMode: TelegramParseMode = "",
|
|
38
38
|
): string {
|
|
39
39
|
const value = String(text ?? "");
|
|
40
40
|
if (parseMode === "HTML") {
|
|
@@ -69,7 +69,7 @@ function escapeHtmlAttribute(url: string): string {
|
|
|
69
69
|
export function formatTelegramText(
|
|
70
70
|
text: string,
|
|
71
71
|
parseMode: TelegramParseMode = "",
|
|
72
|
-
dashboardUrl?: string | null
|
|
72
|
+
dashboardUrl?: string | null,
|
|
73
73
|
): string {
|
|
74
74
|
const body = escapeTelegramText(text, parseMode);
|
|
75
75
|
const url = (dashboardUrl ?? "").trim();
|
|
@@ -148,7 +148,7 @@ const TELEGRAM_MAX_RETRIES = 3;
|
|
|
148
148
|
*/
|
|
149
149
|
export function splitTelegramMessage(
|
|
150
150
|
text: string,
|
|
151
|
-
limit = TELEGRAM_MAX_MESSAGE_LENGTH
|
|
151
|
+
limit = TELEGRAM_MAX_MESSAGE_LENGTH,
|
|
152
152
|
): string[] {
|
|
153
153
|
const value = String(text ?? "");
|
|
154
154
|
const max = Math.max(1, Math.floor(limit));
|
|
@@ -213,13 +213,13 @@ function cutRawChunk(
|
|
|
213
213
|
text: string,
|
|
214
214
|
start: number,
|
|
215
215
|
maxFormatted: number,
|
|
216
|
-
parseMode: TelegramParseMode
|
|
216
|
+
parseMode: TelegramParseMode,
|
|
217
217
|
): number {
|
|
218
218
|
let index = start;
|
|
219
219
|
let used = 0;
|
|
220
220
|
let lastNewline = -1;
|
|
221
221
|
while (index < text.length) {
|
|
222
|
-
const codePoint = text.codePointAt(index)
|
|
222
|
+
const codePoint = text.codePointAt(index)!;
|
|
223
223
|
const ch = String.fromCodePoint(codePoint);
|
|
224
224
|
const cost = escapedCharLength(ch, parseMode);
|
|
225
225
|
if (used + cost > maxFormatted) break;
|
|
@@ -233,7 +233,7 @@ function cutRawChunk(
|
|
|
233
233
|
}
|
|
234
234
|
if (index <= start) {
|
|
235
235
|
// Гарантируем прогресс хотя бы на один code point.
|
|
236
|
-
const codePoint = text.codePointAt(start)
|
|
236
|
+
const codePoint = text.codePointAt(start)!;
|
|
237
237
|
index = start + String.fromCodePoint(codePoint).length;
|
|
238
238
|
}
|
|
239
239
|
return index;
|
|
@@ -250,7 +250,7 @@ function splitRawMessageForSend(
|
|
|
250
250
|
text: string,
|
|
251
251
|
limit: number,
|
|
252
252
|
parseMode: TelegramParseMode,
|
|
253
|
-
linkReserve = 0
|
|
253
|
+
linkReserve = 0,
|
|
254
254
|
): string[] {
|
|
255
255
|
const value = String(text ?? "");
|
|
256
256
|
const max = Math.max(1, Math.floor(limit));
|
|
@@ -303,7 +303,7 @@ export async function sendTelegramMessage(
|
|
|
303
303
|
token: string,
|
|
304
304
|
chatId: string,
|
|
305
305
|
text: string,
|
|
306
|
-
options: TelegramSendOptions = {}
|
|
306
|
+
options: TelegramSendOptions = {},
|
|
307
307
|
): Promise<void> {
|
|
308
308
|
const safeToken = validateTelegramToken(token);
|
|
309
309
|
const target = (chatId ?? "").trim();
|
|
@@ -324,12 +324,12 @@ export async function sendTelegramMessage(
|
|
|
324
324
|
text,
|
|
325
325
|
TELEGRAM_MAX_MESSAGE_LENGTH,
|
|
326
326
|
parseMode,
|
|
327
|
-
linkSuffix.length
|
|
327
|
+
linkSuffix.length,
|
|
328
328
|
);
|
|
329
329
|
|
|
330
330
|
const timeoutMs = Math.max(
|
|
331
331
|
1_000,
|
|
332
|
-
Math.floor(options.timeoutMs ?? DEFAULT_TIMEOUT_MS)
|
|
332
|
+
Math.floor(options.timeoutMs ?? DEFAULT_TIMEOUT_MS),
|
|
333
333
|
);
|
|
334
334
|
const fetchImpl = options.fetchImpl ?? fetch;
|
|
335
335
|
const url = `${apiBase}/bot${safeToken}/sendMessage`;
|
|
@@ -341,7 +341,7 @@ export async function sendTelegramMessage(
|
|
|
341
341
|
const chunk = formatTelegramText(
|
|
342
342
|
rawChunks[chunkIndex],
|
|
343
343
|
parseMode,
|
|
344
|
-
isLastChunk ? dashboardUrl : null
|
|
344
|
+
isLastChunk ? dashboardUrl : null,
|
|
345
345
|
);
|
|
346
346
|
let parseModeForChunk = parseMode;
|
|
347
347
|
let downgradedParseMode = false;
|
|
@@ -398,14 +398,14 @@ export async function sendTelegramMessage(
|
|
|
398
398
|
parseModeForChunk &&
|
|
399
399
|
!downgradedParseMode &&
|
|
400
400
|
/parse entities|can't parse|unsupported start tag|can't find end/i.test(
|
|
401
|
-
description
|
|
401
|
+
description,
|
|
402
402
|
)
|
|
403
403
|
) {
|
|
404
404
|
console.warn(
|
|
405
405
|
`[notify] Telegram отклонил разметку (${sanitizeErrorText(
|
|
406
406
|
description,
|
|
407
|
-
safeToken
|
|
408
|
-
)}) — чанк повторно отправлен без parse_mode. Проверьте шаблоны
|
|
407
|
+
safeToken,
|
|
408
|
+
)}) — чанк повторно отправлен без parse_mode. Проверьте шаблоны уведомлений.`,
|
|
409
409
|
);
|
|
410
410
|
downgradedParseMode = true;
|
|
411
411
|
parseModeForChunk = "";
|
|
@@ -414,7 +414,7 @@ export async function sendTelegramMessage(
|
|
|
414
414
|
|
|
415
415
|
if (!response.ok || parsed?.ok === false) {
|
|
416
416
|
throw new Error(
|
|
417
|
-
`Telegram API: ${sanitizeErrorText(description, safeToken)}
|
|
417
|
+
`Telegram API: ${sanitizeErrorText(description, safeToken)}`,
|
|
418
418
|
);
|
|
419
419
|
}
|
|
420
420
|
break;
|
|
@@ -423,7 +423,7 @@ export async function sendTelegramMessage(
|
|
|
423
423
|
throw new Error(
|
|
424
424
|
t("notify.error.telegramTimeout", {
|
|
425
425
|
seconds: Math.floor(timeoutMs / 1000),
|
|
426
|
-
})
|
|
426
|
+
}),
|
|
427
427
|
);
|
|
428
428
|
}
|
|
429
429
|
const message = err instanceof Error ? err.message : String(err);
|
package/src/core/triage-chain.ts
CHANGED
|
@@ -33,7 +33,7 @@ const NOTIFY: TriageAction = "notify";
|
|
|
33
33
|
function ruleDecision(
|
|
34
34
|
input: TriageInput,
|
|
35
35
|
settings: TriageSettings,
|
|
36
|
-
source: TriageSource
|
|
36
|
+
source: TriageSource,
|
|
37
37
|
): TriageDecision {
|
|
38
38
|
const result = evaluateTriageRules(input, settings.rules);
|
|
39
39
|
return {
|
|
@@ -62,7 +62,7 @@ function ruleDecision(
|
|
|
62
62
|
export async function decideTriage(
|
|
63
63
|
input: TriageInput,
|
|
64
64
|
settings: TriageSettings | undefined,
|
|
65
|
-
options: TriageOptions = {}
|
|
65
|
+
options: TriageOptions = {},
|
|
66
66
|
): Promise<TriageDecision> {
|
|
67
67
|
if (!settings || settings.mode === "off") {
|
|
68
68
|
return { action: NOTIFY, source: "off", attempts: 0, latencyMs: 0 };
|
|
@@ -115,9 +115,9 @@ export async function decideTriage(
|
|
|
115
115
|
export function recordShadow(
|
|
116
116
|
input: TriageInput,
|
|
117
117
|
decision: TriageDecision,
|
|
118
|
-
shadow: TriageSettings["shadow"] | undefined
|
|
118
|
+
shadow: TriageSettings["shadow"] | undefined,
|
|
119
119
|
): void {
|
|
120
|
-
if (!shadow
|
|
120
|
+
if (!shadow?.enabled) return;
|
|
121
121
|
recordTriageOutcome(input, decision, {
|
|
122
122
|
shadowActive: isShadowActive(shadow),
|
|
123
123
|
suppressed: false,
|
|
@@ -97,7 +97,7 @@ function toCompared(
|
|
|
97
97
|
input: TriageInput,
|
|
98
98
|
decision: TriageDecision,
|
|
99
99
|
baseMessage: string,
|
|
100
|
-
dedupCount: number
|
|
100
|
+
dedupCount: number,
|
|
101
101
|
): ComparedDecision {
|
|
102
102
|
const suppressed = decision.action === "skip";
|
|
103
103
|
const message = suppressed
|
|
@@ -143,7 +143,7 @@ function timeoutDecision(): TriageDecision {
|
|
|
143
143
|
async function decideWithTimeout(
|
|
144
144
|
input: TriageInput,
|
|
145
145
|
settings: TriageSettings,
|
|
146
|
-
timeoutMs: number
|
|
146
|
+
timeoutMs: number,
|
|
147
147
|
): Promise<TriageDecision> {
|
|
148
148
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
149
149
|
return decideTriage(input, settings);
|
|
@@ -172,7 +172,7 @@ export async function compareTriage(
|
|
|
172
172
|
beforeSettings: TriageSettings | undefined,
|
|
173
173
|
afterSettings: TriageSettings | undefined,
|
|
174
174
|
dedupCount = 1,
|
|
175
|
-
timeoutMs = DEFAULT_COMPARE_TIMEOUT_MS
|
|
175
|
+
timeoutMs = DEFAULT_COMPARE_TIMEOUT_MS,
|
|
176
176
|
): Promise<CompareTriageResult> {
|
|
177
177
|
const durationMs =
|
|
178
178
|
typeof input.durationMs === "number" && Number.isFinite(input.durationMs)
|
|
@@ -187,7 +187,7 @@ export async function compareTriage(
|
|
|
187
187
|
tokens: input.tokens ?? undefined,
|
|
188
188
|
costUsd: input.costUsd ?? undefined,
|
|
189
189
|
},
|
|
190
|
-
undefined
|
|
190
|
+
undefined,
|
|
191
191
|
);
|
|
192
192
|
|
|
193
193
|
// before/after приходят из RPC как пользовательский ввод: нормализуем их
|
|
@@ -235,7 +235,7 @@ export async function compareTriage(
|
|
|
235
235
|
after: after.verdict?.confidence ?? null,
|
|
236
236
|
changed: changed(
|
|
237
237
|
before.verdict?.confidence ?? null,
|
|
238
|
-
after.verdict?.confidence ?? null
|
|
238
|
+
after.verdict?.confidence ?? null,
|
|
239
239
|
),
|
|
240
240
|
},
|
|
241
241
|
category: {
|
|
@@ -243,7 +243,7 @@ export async function compareTriage(
|
|
|
243
243
|
after: after.verdict?.category ?? null,
|
|
244
244
|
changed: changed(
|
|
245
245
|
before.verdict?.category ?? null,
|
|
246
|
-
after.verdict?.category ?? null
|
|
246
|
+
after.verdict?.category ?? null,
|
|
247
247
|
),
|
|
248
248
|
},
|
|
249
249
|
severity: {
|
|
@@ -251,7 +251,7 @@ export async function compareTriage(
|
|
|
251
251
|
after: after.verdict?.severity ?? null,
|
|
252
252
|
changed: changed(
|
|
253
253
|
before.verdict?.severity ?? null,
|
|
254
|
-
after.verdict?.severity ?? null
|
|
254
|
+
after.verdict?.severity ?? null,
|
|
255
255
|
),
|
|
256
256
|
},
|
|
257
257
|
reason: {
|
|
@@ -259,7 +259,7 @@ export async function compareTriage(
|
|
|
259
259
|
after: after.verdict?.reason ?? null,
|
|
260
260
|
changed: changed(
|
|
261
261
|
before.verdict?.reason ?? null,
|
|
262
|
-
after.verdict?.reason ?? null
|
|
262
|
+
after.verdict?.reason ?? null,
|
|
263
263
|
),
|
|
264
264
|
},
|
|
265
265
|
suppressed: {
|
package/src/core/triage-rules.ts
CHANGED
|
@@ -195,20 +195,20 @@ function conditionLabel(rule: TriageRule): string {
|
|
|
195
195
|
/** Оценивает одно уведомление по правилам. Не бросает исключений. */
|
|
196
196
|
export function evaluateTriageRules(
|
|
197
197
|
input: TriageInput,
|
|
198
|
-
rules: readonly TriageRule[] | undefined = DEFAULT_TRIAGE_RULES
|
|
198
|
+
rules: readonly TriageRule[] | undefined = DEFAULT_TRIAGE_RULES,
|
|
199
199
|
): TriageRuleResult {
|
|
200
200
|
const ordered = (rules ?? [])
|
|
201
201
|
.map((rule, index) => ({ rule, index }))
|
|
202
202
|
.sort(
|
|
203
203
|
(a, b) =>
|
|
204
|
-
(b.rule.priority ?? 0) - (a.rule.priority ?? 0) || a.index - b.index
|
|
204
|
+
(b.rule.priority ?? 0) - (a.rule.priority ?? 0) || a.index - b.index,
|
|
205
205
|
);
|
|
206
206
|
|
|
207
207
|
for (const { rule } of ordered) {
|
|
208
208
|
if (!matches(rule, input)) continue;
|
|
209
209
|
|
|
210
|
-
const category = (rule.category ?? "unknown")
|
|
211
|
-
const severity = (rule.severity ?? "medium")
|
|
210
|
+
const category = (rule.category ?? "unknown");
|
|
211
|
+
const severity = (rule.severity ?? "medium");
|
|
212
212
|
const confidence =
|
|
213
213
|
typeof rule.confidence === "number" && Number.isFinite(rule.confidence)
|
|
214
214
|
? Math.min(1, Math.max(0, rule.confidence))
|
|
@@ -76,7 +76,7 @@ function detailsOf(record: { details: unknown }): Record<string, any> {
|
|
|
76
76
|
export function recordTriageOutcome(
|
|
77
77
|
input: TriageInput,
|
|
78
78
|
decision: TriageDecision,
|
|
79
|
-
options: TriageOutcomeOptions = {}
|
|
79
|
+
options: TriageOutcomeOptions = {},
|
|
80
80
|
): number | null {
|
|
81
81
|
const shadow = Boolean(options.shadowActive);
|
|
82
82
|
const suppressed = Boolean(options.suppressed);
|
|
@@ -112,7 +112,7 @@ export function recordTriageOutcome(
|
|
|
112
112
|
/** Обратная совместимость: запись shadow-решения без деталей доставки. */
|
|
113
113
|
export function recordShadowDecision(
|
|
114
114
|
input: TriageInput,
|
|
115
|
-
decision: TriageDecision
|
|
115
|
+
decision: TriageDecision,
|
|
116
116
|
): void {
|
|
117
117
|
recordTriageOutcome(input, decision, { shadowActive: true });
|
|
118
118
|
}
|
|
@@ -124,7 +124,7 @@ export function recordShadowDecision(
|
|
|
124
124
|
* shadow-записи или все решения.
|
|
125
125
|
*/
|
|
126
126
|
export function readTriageDecisions(
|
|
127
|
-
filter: { since?: string; until?: string; taskName?: string; limit?: number } = {}
|
|
127
|
+
filter: { since?: string; until?: string; taskName?: string; limit?: number } = {},
|
|
128
128
|
): ShadowDecisionRecord[] {
|
|
129
129
|
const result = readAuditLog({
|
|
130
130
|
action: TRIAGE_AUDIT_ACTION,
|
|
@@ -185,15 +185,15 @@ export interface ShadowReport {
|
|
|
185
185
|
|
|
186
186
|
/** Сформировать отчёт по persistent-журналу за текущий/прошлый период. */
|
|
187
187
|
export function shadowReport(
|
|
188
|
-
shadow: TriageShadowSettings | undefined
|
|
188
|
+
shadow: TriageShadowSettings | undefined,
|
|
189
189
|
): ShadowReport {
|
|
190
190
|
const startedAt = shadow?.startedAt ?? null;
|
|
191
191
|
const days = shadow?.days ?? 0;
|
|
192
192
|
const until =
|
|
193
193
|
startedAt && days > 0
|
|
194
194
|
? new Date(
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
new Date(startedAt).getTime() + days * 24 * 60 * 60 * 1000,
|
|
196
|
+
).toISOString()
|
|
197
197
|
: undefined;
|
|
198
198
|
|
|
199
199
|
const records = readTriageDecisions({
|
|
@@ -231,7 +231,7 @@ export function resetShadowDecisions(): void {
|
|
|
231
231
|
.prepare(
|
|
232
232
|
`DELETE FROM audit_log
|
|
233
233
|
WHERE action = ?
|
|
234
|
-
AND json_extract(details_json, '$.shadow') = 1
|
|
234
|
+
AND json_extract(details_json, '$.shadow') = 1`,
|
|
235
235
|
)
|
|
236
236
|
.run(TRIAGE_AUDIT_ACTION);
|
|
237
237
|
} catch {
|
|
@@ -171,7 +171,7 @@ function safeUnlink(file: string | undefined): void {
|
|
|
171
171
|
export function writeTriageJob(
|
|
172
172
|
input: TriageInput,
|
|
173
173
|
triage: TriageSettings,
|
|
174
|
-
options: { tmpDir?: string } = {}
|
|
174
|
+
options: { tmpDir?: string } = {},
|
|
175
175
|
): string {
|
|
176
176
|
const payload: TriageJobPayload = {
|
|
177
177
|
version: 1,
|
|
@@ -238,7 +238,7 @@ export interface ScheduleTriageOptions {
|
|
|
238
238
|
export function scheduleTriageJob(
|
|
239
239
|
input: TriageInput,
|
|
240
240
|
triage: TriageSettings,
|
|
241
|
-
options: ScheduleTriageOptions = {}
|
|
241
|
+
options: ScheduleTriageOptions = {},
|
|
242
242
|
): { scheduled: boolean; file?: string; error?: string } {
|
|
243
243
|
let file: string | undefined;
|
|
244
244
|
try {
|
|
@@ -261,7 +261,7 @@ export function scheduleTriageJob(
|
|
|
261
261
|
stdio: "ignore",
|
|
262
262
|
windowsHide: true,
|
|
263
263
|
env: options.env ?? process.env,
|
|
264
|
-
}
|
|
264
|
+
},
|
|
265
265
|
);
|
|
266
266
|
child.unref();
|
|
267
267
|
// Если процесс не стартовал, файл задания останется сиротой — убираем.
|
|
@@ -281,7 +281,7 @@ async function main(): Promise<void> {
|
|
|
281
281
|
const index = process.argv.indexOf(TRIAGE_WORKER_FLAG);
|
|
282
282
|
const file = index >= 0 ? process.argv[index + 1] : undefined;
|
|
283
283
|
if (!file) {
|
|
284
|
-
console.error("[
|
|
284
|
+
console.error("[agent-steward] triage worker: не указан файл задания");
|
|
285
285
|
process.exitCode = 1;
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
@@ -317,9 +317,9 @@ async function drainQueue(first: string): Promise<void> {
|
|
|
317
317
|
await runTriageJob(file);
|
|
318
318
|
} catch (err: any) {
|
|
319
319
|
console.error(
|
|
320
|
-
`[
|
|
320
|
+
`[agent-steward] triage worker: ${
|
|
321
321
|
err instanceof Error ? err.message : String(err)
|
|
322
|
-
}
|
|
322
|
+
}`,
|
|
323
323
|
);
|
|
324
324
|
process.exitCode = 1;
|
|
325
325
|
} finally {
|
package/src/core/triage.ts
CHANGED
|
@@ -99,7 +99,7 @@ const SYSTEM_PROMPT = [
|
|
|
99
99
|
class ParseFailure extends Error {
|
|
100
100
|
constructor(
|
|
101
101
|
readonly failure: "invalid-json" | "invalid-schema" | "invalid-response",
|
|
102
|
-
message: string
|
|
102
|
+
message: string,
|
|
103
103
|
) {
|
|
104
104
|
super(message);
|
|
105
105
|
}
|
|
@@ -120,7 +120,7 @@ function resolveEndpoint(baseUrl: string): {
|
|
|
120
120
|
return { url: `${base}/api/chat`, protocol: "ollama" };
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
function buildMessages(input: TriageInput):
|
|
123
|
+
function buildMessages(input: TriageInput): { role: string; content: string }[] {
|
|
124
124
|
const payload = {
|
|
125
125
|
task: input.taskName,
|
|
126
126
|
status: input.status,
|
|
@@ -164,7 +164,7 @@ function parseVerdict(raw: string): TriageVerdict {
|
|
|
164
164
|
} catch (err: any) {
|
|
165
165
|
throw new ParseFailure(
|
|
166
166
|
"invalid-json",
|
|
167
|
-
`Ответ модели не парсится как JSON: ${err instanceof Error ? err.message : String(err)}
|
|
167
|
+
`Ответ модели не парсится как JSON: ${err instanceof Error ? err.message : String(err)}`,
|
|
168
168
|
);
|
|
169
169
|
}
|
|
170
170
|
|
|
@@ -232,11 +232,11 @@ const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
232
232
|
export async function classifyNotification(
|
|
233
233
|
input: TriageInput,
|
|
234
234
|
settings: TriageSettings | undefined,
|
|
235
|
-
options: TriageOptions = {}
|
|
235
|
+
options: TriageOptions = {},
|
|
236
236
|
): Promise<TriageResult> {
|
|
237
237
|
const startedAt = Date.now();
|
|
238
238
|
const model = settings?.model?.trim() ?? "";
|
|
239
|
-
if (!settings
|
|
239
|
+
if (!settings?.baseUrl?.trim() || !model) {
|
|
240
240
|
return {
|
|
241
241
|
ok: false,
|
|
242
242
|
failure: "disabled",
|
|
@@ -276,26 +276,26 @@ export async function classifyNotification(
|
|
|
276
276
|
const body: Record<string, unknown> =
|
|
277
277
|
protocol === "openai"
|
|
278
278
|
? {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
},
|
|
279
|
+
model,
|
|
280
|
+
messages,
|
|
281
|
+
temperature: 0,
|
|
282
|
+
stream: false,
|
|
283
|
+
response_format: {
|
|
284
|
+
type: "json_schema",
|
|
285
|
+
json_schema: {
|
|
286
|
+
name: "notification_triage",
|
|
287
|
+
strict: true,
|
|
288
|
+
schema: TRIAGE_SCHEMA,
|
|
290
289
|
},
|
|
291
|
-
}
|
|
290
|
+
},
|
|
291
|
+
}
|
|
292
292
|
: {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
293
|
+
model,
|
|
294
|
+
messages,
|
|
295
|
+
stream: false,
|
|
296
|
+
format: TRIAGE_SCHEMA,
|
|
297
|
+
options: { temperature: 0 },
|
|
298
|
+
};
|
|
299
299
|
|
|
300
300
|
const response = await fetch(url, {
|
|
301
301
|
method: "POST",
|
package/src/core/watch-paths.ts
CHANGED
|
@@ -42,7 +42,7 @@ export function normalizeWatchPath(watchPath: string, baseDir: string): string {
|
|
|
42
42
|
const rel = relative(baseDir, resolved);
|
|
43
43
|
if (rel === ".." || rel.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || isAbsolute(rel)) {
|
|
44
44
|
throw new Error(
|
|
45
|
-
`Путь наблюдения выходит за пределы рабочей директории задачи: "${trimmed}"
|
|
45
|
+
`Путь наблюдения выходит за пределы рабочей директории задачи: "${trimmed}".`,
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
return resolved;
|
|
@@ -169,9 +169,9 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
|
|
|
169
169
|
deniedTools,
|
|
170
170
|
policy,
|
|
171
171
|
legacyShell,
|
|
172
|
-
})
|
|
172
|
+
}),
|
|
173
173
|
)}`,
|
|
174
|
-
|
|
174
|
+
"",
|
|
175
175
|
"# cron запускает задачи с минимальным PATH — добавляем типовые каталоги.",
|
|
176
176
|
'export PATH="/opt/homebrew/bin:/usr/local/bin:$HOME/.local/bin:$HOME/.bun/bin:$PATH"',
|
|
177
177
|
"",
|
|
@@ -189,28 +189,28 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
|
|
|
189
189
|
`log ${shellQuote(`[policy] ${formatPolicyLog(effectivePermissions)}`)}`,
|
|
190
190
|
...effectivePermissions.deniedByPolicy.map(
|
|
191
191
|
(entry) =>
|
|
192
|
-
`log ${shellQuote(`[policy] deny ${entry.action}: ${entry.hint}`)}
|
|
192
|
+
`log ${shellQuote(`[policy] deny ${entry.action}: ${entry.hint}`)}`,
|
|
193
193
|
),
|
|
194
194
|
"",
|
|
195
195
|
"# Таймаут для gate/хуков: зависший скрипт не должен держать lock до истечения",
|
|
196
196
|
"# STALE_LOCK_MAX_AGE_MS. 0 — без таймаута (не рекомендуется).",
|
|
197
197
|
`GATE_TIMEOUT_SECONDS=${Math.max(0, Math.floor(gateTimeoutSeconds ?? 300))}`,
|
|
198
|
-
|
|
198
|
+
"run_with_timeout() {",
|
|
199
199
|
' GATE_LIMIT="$1"; shift',
|
|
200
200
|
' if [ "$GATE_LIMIT" -le 0 ] 2>/dev/null; then',
|
|
201
201
|
' "$@"',
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
202
|
+
" return $?",
|
|
203
|
+
" fi",
|
|
204
|
+
" # T-10: потомок получает собственную группу процессов (job control), чтобы",
|
|
205
|
+
" # watchdog убивал всё дерево (bash -c и его детей), а не только прямого ребёнка.",
|
|
206
|
+
" set -m 2>/dev/null || true",
|
|
207
207
|
' "$@" &',
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
" GATE_CHILD=$!",
|
|
209
|
+
" set +m 2>/dev/null || true",
|
|
210
210
|
' ( sleep "$GATE_LIMIT"; kill -TERM -- "-$GATE_CHILD" 2>/dev/null || kill -TERM "$GATE_CHILD" 2>/dev/null; sleep 5; kill -KILL -- "-$GATE_CHILD" 2>/dev/null || kill -KILL "$GATE_CHILD" 2>/dev/null ) >/dev/null 2>&1 &',
|
|
211
|
-
|
|
211
|
+
" GATE_WATCHDOG=$!",
|
|
212
212
|
' wait "$GATE_CHILD"',
|
|
213
|
-
|
|
213
|
+
" GATE_CODE=$?",
|
|
214
214
|
' kill "$GATE_WATCHDOG" 2>/dev/null || true',
|
|
215
215
|
' wait "$GATE_WATCHDOG" 2>/dev/null || true',
|
|
216
216
|
' return "$GATE_CODE"',
|
|
@@ -218,7 +218,7 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
|
|
|
218
218
|
"",
|
|
219
219
|
"# Спринт 19: гейт расписания — до lock, чтобы ожидание окна не держало блокировку.",
|
|
220
220
|
'if [ -n "$SCHEDULE_GATE_FILE" ]; then',
|
|
221
|
-
|
|
221
|
+
" SCHED_GATE_ARGS=()",
|
|
222
222
|
' [ -n "$SCHEDULE_CRON" ] && SCHED_GATE_ARGS+=(--cron "$SCHEDULE_CRON")',
|
|
223
223
|
' [ -n "$SCHEDULE_TZ" ] && SCHED_GATE_ARGS+=(--tz "$SCHEDULE_TZ")',
|
|
224
224
|
' [ -n "$SCHEDULE_NOT_BEFORE" ] && SCHED_GATE_ARGS+=(--not-before "$SCHEDULE_NOT_BEFORE")',
|
|
@@ -227,10 +227,10 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
|
|
|
227
227
|
' [ -n "$SCHEDULE_WINDOW_POLICY" ] && SCHED_GATE_ARGS+=(--window-policy "$SCHEDULE_WINDOW_POLICY")',
|
|
228
228
|
' [ -n "$SCHEDULE_DEFER_FILE" ] && SCHED_GATE_ARGS+=(--defer-file "$SCHEDULE_DEFER_FILE")',
|
|
229
229
|
' [ -n "$SCHEDULE_FORCE_FILE" ] && SCHED_GATE_ARGS+=(--force-file "$SCHEDULE_FORCE_FILE")',
|
|
230
|
-
|
|
230
|
+
" if ! command -v node >/dev/null 2>&1; then",
|
|
231
231
|
' log "[scheduler] Гейт расписания пропущен: node не найден в PATH."',
|
|
232
232
|
" else",
|
|
233
|
-
'
|
|
233
|
+
' node "$SCHEDULE_GATE_FILE" ${SCHED_GATE_ARGS[@]+"${SCHED_GATE_ARGS[@]}"} >> "$LOG_FILE" 2>&1',
|
|
234
234
|
" SCHED_GATE_CODE=$?",
|
|
235
235
|
' if [ "$SCHED_GATE_CODE" -eq 3 ]; then',
|
|
236
236
|
' log "[scheduler] Гейт расписания: запуск не требуется (cron/окно). Перенос или пропуск тика."',
|
|
@@ -251,24 +251,24 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
|
|
|
251
251
|
' if [ -f "$LOCK_FILE.d/pid" ]; then',
|
|
252
252
|
' LOCK_PID="$(cat "$LOCK_FILE.d/pid" 2>/dev/null || true)"',
|
|
253
253
|
" fi",
|
|
254
|
-
|
|
254
|
+
" LOCK_ALIVE=1",
|
|
255
255
|
' if [ -n "$LOCK_PID" ]; then',
|
|
256
256
|
' if kill -0 "$LOCK_PID" 2>/dev/null; then LOCK_ALIVE=1; else LOCK_ALIVE=0; fi',
|
|
257
|
-
|
|
257
|
+
" fi",
|
|
258
258
|
' if [ "$LOCK_ALIVE" -eq 1 ]; then',
|
|
259
259
|
' log "[scheduler] Задача \'$TASK_NAME\' уже выполняется (pid ${LOCK_PID:-неизвестен}) — пропуск запуска."',
|
|
260
260
|
" exit 0",
|
|
261
261
|
" fi",
|
|
262
262
|
' log "[scheduler] Вытесняю осиротевший lock \'$LOCK_FILE.d\' (pid ${LOCK_PID:-неизвестен})."',
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
" # T-03: атомарно уводим каталог в уникальное имя вместо rm -rf, чтобы не",
|
|
264
|
+
" # удалить свежий lock, созданный другим воркером после нашей проверки.",
|
|
265
265
|
' STALE_LOCK_DIR="$LOCK_FILE.d.stale-$$"',
|
|
266
266
|
' if mv "$LOCK_FILE.d" "$STALE_LOCK_DIR" 2>/dev/null; then',
|
|
267
267
|
' rm -rf "$STALE_LOCK_DIR" 2>/dev/null || true',
|
|
268
|
-
|
|
268
|
+
" else",
|
|
269
269
|
' log "[scheduler] Не удалось вытеснить осиротевший lock — пропуск запуска."',
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
" exit 0",
|
|
271
|
+
" fi",
|
|
272
272
|
' if ! mkdir "$LOCK_FILE.d" 2>/dev/null; then',
|
|
273
273
|
' log "[scheduler] Не удалось взять lock \'$LOCK_FILE.d\' — пропуск запуска."',
|
|
274
274
|
" exit 0",
|
|
@@ -310,7 +310,7 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
|
|
|
310
310
|
' log "[role-scoped] allowed=[$ALLOWED_TOOLS], denied=[$DENIED_TOOLS]"',
|
|
311
311
|
"fi",
|
|
312
312
|
"",
|
|
313
|
-
|
|
313
|
+
"if ! command -v opencode >/dev/null 2>&1; then",
|
|
314
314
|
' log "[scheduler] ОШИБКА: opencode не найден в PATH ($PATH)."',
|
|
315
315
|
" exit 127",
|
|
316
316
|
"fi",
|
|
@@ -321,17 +321,17 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
|
|
|
321
321
|
'PROMPT_BYTES="$(printf %s "$PROMPT" | wc -c | tr -d \' \')"',
|
|
322
322
|
'if [ "$PROMPT_BYTES" -gt 131072 ] 2>/dev/null; then',
|
|
323
323
|
' log "[scheduler] ОШИБКА: промпт слишком длинный для argv POSIX: ${PROMPT_BYTES} байт (максимум 131072)."',
|
|
324
|
-
|
|
325
|
-
|
|
324
|
+
" exit 1",
|
|
325
|
+
"fi",
|
|
326
326
|
'START_EPOCH="$(date +%s)"',
|
|
327
327
|
'STARTED_AT="$(date -u \'+%Y-%m-%dT%H:%M:%SZ\')"',
|
|
328
|
-
|
|
328
|
+
"EXIT_CODE=0",
|
|
329
329
|
'ERROR_MESSAGE=""',
|
|
330
330
|
'PRE_FLIGHT_STATUS="skipped"',
|
|
331
331
|
'POST_FLIGHT_STATUS="skipped"',
|
|
332
|
-
|
|
332
|
+
"SKIP_MAIN=0",
|
|
333
333
|
"",
|
|
334
|
-
|
|
334
|
+
"log \"[scheduler] Запуск задачи '$TASK_NAME'...\"",
|
|
335
335
|
"",
|
|
336
336
|
"# Crash recovery: фиксируем начало до pre-flight. Если процесс убьют,",
|
|
337
337
|
"# останется finished_at = NULL и recovery при следующем старте пометит error.",
|
|
@@ -402,10 +402,10 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
|
|
|
402
402
|
"# T-10: как и в run_with_timeout, opencode запускается в собственной группе",
|
|
403
403
|
"# процессов (exec внутри run_opencode сохраняет лидера группы), поэтому",
|
|
404
404
|
"# watchdog убивает всё дерево, а внуки не переживают таймаут.",
|
|
405
|
-
|
|
405
|
+
"set -m 2>/dev/null || true",
|
|
406
406
|
'run_opencode >> "$LOG_FILE" 2>&1 &',
|
|
407
407
|
"CHILD=$!",
|
|
408
|
-
|
|
408
|
+
"set +m 2>/dev/null || true",
|
|
409
409
|
'if [ "$TIMEOUT_SECONDS" -gt 0 ] 2>/dev/null; then',
|
|
410
410
|
' ( sleep "$TIMEOUT_SECONDS"; kill -TERM -- "-$CHILD" 2>/dev/null || kill -TERM "$CHILD" 2>/dev/null; sleep 5; kill -KILL -- "-$CHILD" 2>/dev/null || kill -KILL "$CHILD" 2>/dev/null ) &',
|
|
411
411
|
" WATCHDOG=$!",
|
|
@@ -416,9 +416,9 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
|
|
|
416
416
|
' kill "$WATCHDOG" 2>/dev/null || true',
|
|
417
417
|
' wait "$WATCHDOG" 2>/dev/null || true',
|
|
418
418
|
"fi",
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
419
|
+
"",
|
|
420
|
+
"# Конфиг прав живёт только в переменной окружения — файл не создаётся.",
|
|
421
|
+
"",
|
|
422
422
|
'if [ "$EXIT_CODE" -ne 0 ]; then',
|
|
423
423
|
' log "[scheduler] Задача \'$TASK_NAME\' завершилась с кодом $EXIT_CODE."',
|
|
424
424
|
' ERROR_MESSAGE="Код возврата $EXIT_CODE"',
|
|
@@ -460,7 +460,7 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
|
|
|
460
460
|
"fi",
|
|
461
461
|
"",
|
|
462
462
|
'END_EPOCH="$(date +%s)"',
|
|
463
|
-
|
|
463
|
+
"DURATION_MS=$(( (END_EPOCH - START_EPOCH) * 1000 ))",
|
|
464
464
|
'STATUS="error"',
|
|
465
465
|
'if [ "$EXIT_CODE" -eq 0 ]; then STATUS="success"; fi',
|
|
466
466
|
"",
|
|
@@ -476,9 +476,9 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
|
|
|
476
476
|
// История уже записана, поэтому фоновая очистка не влияет на результат.
|
|
477
477
|
...(oneShotCleanupCommand
|
|
478
478
|
? [
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
479
|
+
`(sleep 2; ${oneShotCleanupCommand}) >/dev/null 2>&1 &`,
|
|
480
|
+
"",
|
|
481
|
+
]
|
|
482
482
|
: []),
|
|
483
483
|
'exit "$EXIT_CODE"',
|
|
484
484
|
"",
|
|
@@ -492,14 +492,14 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
|
|
|
492
492
|
* Возвращает абсолютный путь к .sh-файлу.
|
|
493
493
|
*/
|
|
494
494
|
export async function writeBashWrapper(
|
|
495
|
-
options: BashWrapperOptions
|
|
495
|
+
options: BashWrapperOptions,
|
|
496
496
|
): Promise<string> {
|
|
497
497
|
await fs.mkdir(WRAPPER_DIR, { recursive: true });
|
|
498
498
|
// locks/ нужен до первого запуска: обёртка берёт lock через mkdir.
|
|
499
499
|
await fs.mkdir(path.dirname(options.lockFile), { recursive: true });
|
|
500
500
|
const scriptPath = path.join(
|
|
501
501
|
WRAPPER_DIR,
|
|
502
|
-
`run-${options.sanitizedName}.sh
|
|
502
|
+
`run-${options.sanitizedName}.sh`,
|
|
503
503
|
);
|
|
504
504
|
const script = buildBashWrapperScript(options);
|
|
505
505
|
await fs.writeFile(scriptPath, script, "utf8");
|
|
@@ -526,7 +526,7 @@ export function buildOpencodeConfig(
|
|
|
526
526
|
allowedTools?: string[],
|
|
527
527
|
deniedTools?: string[],
|
|
528
528
|
policy?: PermissionPolicy,
|
|
529
|
-
legacyShell?: boolean
|
|
529
|
+
legacyShell?: boolean,
|
|
530
530
|
): string {
|
|
531
531
|
return buildPermissionsConfig({ allowedTools, deniedTools, policy, legacyShell });
|
|
532
532
|
}
|