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.
Files changed (263) hide show
  1. package/CHANGELOG.md +45 -2
  2. package/CROSS_PLATFORM.md +11 -9
  3. package/README.md +11 -10
  4. package/ROADMAP-STRATEGY.md +93 -44
  5. package/ROADMAP.md +148 -1017
  6. package/dist/core/cron-to-schtasks.d.ts +0 -8
  7. package/dist/core/cron-to-schtasks.d.ts.map +1 -1
  8. package/dist/core/cron-to-schtasks.js +11 -86
  9. package/dist/core/dlq-api.d.ts +44 -0
  10. package/dist/core/dlq-api.d.ts.map +1 -0
  11. package/dist/core/dlq-api.js +68 -0
  12. package/dist/core/dry-run.d.ts.map +1 -1
  13. package/dist/core/dry-run.js +19 -2
  14. package/dist/core/file-watcher.js +9 -9
  15. package/dist/core/git-trigger.js +4 -4
  16. package/dist/core/lock.d.ts +20 -4
  17. package/dist/core/lock.d.ts.map +1 -1
  18. package/dist/core/lock.js +99 -26
  19. package/dist/core/one-shot.d.ts +31 -5
  20. package/dist/core/one-shot.d.ts.map +1 -1
  21. package/dist/core/one-shot.js +78 -10
  22. package/dist/core/opencode-cli.d.ts +28 -0
  23. package/dist/core/opencode-cli.d.ts.map +1 -0
  24. package/dist/core/opencode-cli.js +74 -0
  25. package/dist/core/opencode-models.d.ts +62 -0
  26. package/dist/core/opencode-models.d.ts.map +1 -0
  27. package/dist/core/opencode-models.js +277 -0
  28. package/dist/core/otel.js +2 -2
  29. package/dist/core/ps-wrapper.d.ts +1 -1
  30. package/dist/core/ps-wrapper.d.ts.map +1 -1
  31. package/dist/core/ps-wrapper.js +66 -36
  32. package/dist/core/record-history.d.ts +15 -0
  33. package/dist/core/record-history.d.ts.map +1 -1
  34. package/dist/core/record-history.js +78 -54
  35. package/dist/core/router/dispatch.d.ts +36 -0
  36. package/dist/core/router/dispatch.d.ts.map +1 -0
  37. package/dist/core/router/dispatch.js +59 -0
  38. package/dist/core/router/escalation.d.ts +47 -0
  39. package/dist/core/router/escalation.d.ts.map +1 -0
  40. package/dist/core/router/escalation.js +87 -0
  41. package/dist/core/router/planner.d.ts +53 -0
  42. package/dist/core/router/planner.d.ts.map +1 -0
  43. package/dist/core/router/planner.js +113 -0
  44. package/dist/core/router/rules.d.ts +46 -0
  45. package/dist/core/router/rules.d.ts.map +1 -0
  46. package/dist/core/router/rules.js +85 -0
  47. package/dist/core/run-panel-api.d.ts +94 -0
  48. package/dist/core/run-panel-api.d.ts.map +1 -0
  49. package/dist/core/run-panel-api.js +169 -0
  50. package/dist/core/schedule-gate.js +5 -1
  51. package/dist/core/schedule-v2.d.ts +36 -2
  52. package/dist/core/schedule-v2.d.ts.map +1 -1
  53. package/dist/core/schedule-v2.js +98 -12
  54. package/dist/core/scheduler/at-fallback.d.ts +95 -0
  55. package/dist/core/scheduler/at-fallback.d.ts.map +1 -0
  56. package/dist/core/scheduler/at-fallback.js +200 -0
  57. package/dist/core/scheduler/linux.d.ts +13 -2
  58. package/dist/core/scheduler/linux.d.ts.map +1 -1
  59. package/dist/core/scheduler/linux.js +67 -13
  60. package/dist/core/scheduler/mac.d.ts +14 -8
  61. package/dist/core/scheduler/mac.d.ts.map +1 -1
  62. package/dist/core/scheduler/mac.js +71 -22
  63. package/dist/core/scheduler/posix.d.ts.map +1 -1
  64. package/dist/core/scheduler/posix.js +37 -2
  65. package/dist/core/scheduler/registry.d.ts +13 -0
  66. package/dist/core/scheduler/registry.d.ts.map +1 -1
  67. package/dist/core/scheduler/registry.js +83 -21
  68. package/dist/core/scheduler/run-now.d.ts +16 -0
  69. package/dist/core/scheduler/run-now.d.ts.map +1 -0
  70. package/dist/core/scheduler/run-now.js +28 -0
  71. package/dist/core/scheduler/windows.d.ts +16 -3
  72. package/dist/core/scheduler/windows.d.ts.map +1 -1
  73. package/dist/core/scheduler/windows.js +249 -96
  74. package/dist/core/secrets.d.ts.map +1 -1
  75. package/dist/core/secrets.js +127 -30
  76. package/dist/core/self-analysis.js +55 -55
  77. package/dist/core/session.d.ts.map +1 -1
  78. package/dist/core/session.js +18 -11
  79. package/dist/core/summary.js +1 -1
  80. package/dist/core/task-name.d.ts +24 -0
  81. package/dist/core/task-name.d.ts.map +1 -0
  82. package/dist/core/task-name.js +40 -0
  83. package/dist/core/triage-chain.js +1 -1
  84. package/dist/core/triage-worker.js +2 -2
  85. package/dist/core/triage.js +1 -1
  86. package/dist/core/wrappers/bash.d.ts.map +1 -1
  87. package/dist/core/wrappers/bash.js +82 -37
  88. package/dist/db/capability-repo.d.ts +83 -0
  89. package/dist/db/capability-repo.d.ts.map +1 -0
  90. package/dist/db/capability-repo.js +182 -0
  91. package/dist/db/history-repo.d.ts +8 -0
  92. package/dist/db/history-repo.d.ts.map +1 -1
  93. package/dist/db/history-repo.js +19 -0
  94. package/dist/db/index.d.ts +6 -0
  95. package/dist/db/index.d.ts.map +1 -1
  96. package/dist/db/index.js +48 -2
  97. package/dist/db/migrate.d.ts.map +1 -1
  98. package/dist/db/migrate.js +3 -1
  99. package/dist/db/run-context.d.ts +103 -0
  100. package/dist/db/run-context.d.ts.map +1 -0
  101. package/dist/db/run-context.js +224 -0
  102. package/dist/db/run-dlq.d.ts +100 -0
  103. package/dist/db/run-dlq.d.ts.map +1 -0
  104. package/dist/db/run-dlq.js +191 -0
  105. package/dist/db/run-journal.d.ts +60 -0
  106. package/dist/db/run-journal.d.ts.map +1 -0
  107. package/dist/db/run-journal.js +143 -0
  108. package/dist/db/run-resume.d.ts +51 -0
  109. package/dist/db/run-resume.d.ts.map +1 -0
  110. package/dist/db/run-resume.js +156 -0
  111. package/dist/db/runs-repo.d.ts +128 -0
  112. package/dist/db/runs-repo.d.ts.map +1 -0
  113. package/dist/db/runs-repo.js +342 -0
  114. package/dist/db/schema.d.ts +16 -2
  115. package/dist/db/schema.d.ts.map +1 -1
  116. package/dist/db/schema.js +342 -35
  117. package/dist/db/settings-repo.d.ts +11 -0
  118. package/dist/db/settings-repo.d.ts.map +1 -1
  119. package/dist/db/settings-repo.js +25 -0
  120. package/dist/db/step-idempotency.d.ts +51 -0
  121. package/dist/db/step-idempotency.d.ts.map +1 -0
  122. package/dist/db/step-idempotency.js +136 -0
  123. package/dist/index.d.ts +5 -5
  124. package/dist/index.d.ts.map +1 -1
  125. package/dist/index.js +168 -40
  126. package/dist/notifications.js +18 -18
  127. package/dist/profiles.d.ts +7 -3
  128. package/dist/profiles.d.ts.map +1 -1
  129. package/dist/profiles.js +85 -7
  130. package/dist/rpc.d.ts +787 -0
  131. package/dist/rpc.d.ts.map +1 -1
  132. package/dist/rpc.js +324 -0
  133. package/dist/server.d.ts +33 -2
  134. package/dist/server.d.ts.map +1 -1
  135. package/dist/server.js +115 -54
  136. package/dist/shared/jobs-view.d.ts.map +1 -1
  137. package/dist/skill.js +1 -1
  138. package/dist/task-transfer.d.ts +1 -1
  139. package/dist/task-transfer.d.ts.map +1 -1
  140. package/dist/task-transfer.js +14 -10
  141. package/dist/types.d.ts +20 -4
  142. package/dist/types.d.ts.map +1 -1
  143. package/dist/types.js +44 -9
  144. package/dist/workspaces.d.ts +25 -3
  145. package/dist/workspaces.d.ts.map +1 -1
  146. package/dist/workspaces.js +44 -9
  147. package/docs/ARCHITECTURE.md +335 -9
  148. package/docs/COMPATIBILITY.md +10 -6
  149. package/docs/CONCEPT.md +183 -91
  150. package/docs/CROSS_PLATFORM.ru.md +11 -9
  151. package/docs/CROSS_PLATFORM.zh.md +11 -9
  152. package/docs/EXECUTION-LOOP.md +196 -0
  153. package/docs/FAQ.md +2 -2
  154. package/docs/FAQ.ru.md +2 -2
  155. package/docs/FAQ.zh.md +2 -2
  156. package/docs/FEATURES.md +5 -4
  157. package/docs/FEATURES.zh.md +5 -4
  158. package/docs/MIGRATION.md +34 -26
  159. package/docs/README.ru.md +27 -8
  160. package/docs/README.zh.md +11 -10
  161. package/docs/SAFETY.md +122 -0
  162. package/docs/SAVINGS.md +29 -0
  163. package/docs/SAVINGS.ru.md +29 -0
  164. package/docs/SAVINGS.zh.md +18 -0
  165. package/docs/V1-V2-COMPATIBILITY-PLAN.md +6 -6
  166. package/gui-experimental.cjs +8 -8
  167. package/index.js +1 -0
  168. package/locales/en.json +68 -0
  169. package/locales/ru.json +68 -0
  170. package/locales/zh.json +68 -0
  171. package/package.json +57 -11
  172. package/scripts/audit-bundle.mjs +215 -0
  173. package/src/core/analytics.ts +2 -2
  174. package/src/core/audit.ts +17 -17
  175. package/src/core/cron-to-schtasks.ts +14 -93
  176. package/src/core/dlq-api.ts +98 -0
  177. package/src/core/dry-run.ts +51 -27
  178. package/src/core/file-watcher.ts +17 -17
  179. package/src/core/git-trigger.ts +9 -9
  180. package/src/core/glob.ts +1 -1
  181. package/src/core/local-ai.ts +2 -2
  182. package/src/core/lock.ts +104 -31
  183. package/src/core/matrix.ts +31 -31
  184. package/src/core/native-notify.ts +2 -2
  185. package/src/core/one-shot.ts +91 -13
  186. package/src/core/opencode-cli.ts +103 -0
  187. package/src/core/opencode-models.ts +315 -0
  188. package/src/core/otel.ts +4 -4
  189. package/src/core/permissions.ts +5 -5
  190. package/src/core/prometheus.ts +17 -17
  191. package/src/core/ps-wrapper.ts +68 -38
  192. package/src/core/record-history.ts +114 -76
  193. package/src/core/retention.ts +3 -3
  194. package/src/core/router/dispatch.ts +94 -0
  195. package/src/core/router/escalation.ts +129 -0
  196. package/src/core/router/planner.ts +166 -0
  197. package/src/core/router/rules.ts +109 -0
  198. package/src/core/run-panel-api.ts +262 -0
  199. package/src/core/savings.ts +1 -1
  200. package/src/core/schedule-gate.ts +17 -13
  201. package/src/core/schedule-v2.ts +138 -29
  202. package/src/core/scheduler/at-fallback.ts +298 -0
  203. package/src/core/scheduler/index.ts +3 -3
  204. package/src/core/scheduler/linux.ts +92 -19
  205. package/src/core/scheduler/logs.ts +1 -1
  206. package/src/core/scheduler/mac.ts +112 -60
  207. package/src/core/scheduler/posix.ts +35 -2
  208. package/src/core/scheduler/registry.ts +109 -26
  209. package/src/core/scheduler/run-now.ts +32 -0
  210. package/src/core/scheduler/windows.ts +295 -125
  211. package/src/core/secrets.ts +139 -39
  212. package/src/core/self-analysis.ts +61 -61
  213. package/src/core/session.ts +26 -13
  214. package/src/core/structured-log.ts +3 -3
  215. package/src/core/summary.ts +25 -25
  216. package/src/core/task-name.ts +67 -0
  217. package/src/core/telegram.ts +16 -16
  218. package/src/core/triage-chain.ts +4 -4
  219. package/src/core/triage-compare.ts +8 -8
  220. package/src/core/triage-rules.ts +4 -4
  221. package/src/core/triage-shadow.ts +7 -7
  222. package/src/core/triage-worker.ts +6 -6
  223. package/src/core/triage.ts +23 -23
  224. package/src/core/watch-paths.ts +1 -1
  225. package/src/core/wrappers/bash.ts +90 -45
  226. package/src/db/capability-repo.ts +285 -0
  227. package/src/db/git-state-repo.ts +1 -1
  228. package/src/db/history-repo.ts +44 -22
  229. package/src/db/index.ts +53 -7
  230. package/src/db/metrics-repo.ts +10 -10
  231. package/src/db/migrate.ts +13 -11
  232. package/src/db/recovery.ts +3 -3
  233. package/src/db/run-context.ts +370 -0
  234. package/src/db/run-dlq.ts +310 -0
  235. package/src/db/run-journal.ts +212 -0
  236. package/src/db/run-resume.ts +256 -0
  237. package/src/db/runs-repo.ts +504 -0
  238. package/src/db/schema.ts +357 -44
  239. package/src/db/settings-repo.ts +33 -2
  240. package/src/db/step-idempotency.ts +185 -0
  241. package/src/db/tasks-repo.ts +10 -10
  242. package/src/db/templates-repo.ts +7 -7
  243. package/src/gui.tsx +516 -1
  244. package/src/history.ts +4 -4
  245. package/src/i18n.ts +7 -7
  246. package/src/index.ts +465 -308
  247. package/src/integrations.ts +6 -6
  248. package/src/notifications.ts +76 -76
  249. package/src/profiles.ts +98 -7
  250. package/src/rpc.ts +347 -1
  251. package/src/schtasks.ts +2 -2
  252. package/src/server.ts +155 -78
  253. package/src/settings.ts +44 -44
  254. package/src/shared/jobs-view.ts +60 -60
  255. package/src/skill.ts +1 -1
  256. package/src/task-transfer.ts +58 -56
  257. package/src/templates.ts +1 -1
  258. package/src/types.ts +54 -10
  259. package/src/workspaces.ts +73 -24
  260. package/dist/core/self-analysis.test.d.ts +0 -2
  261. package/dist/core/self-analysis.test.d.ts.map +0 -1
  262. package/dist/core/self-analysis.test.js +0 -219
  263. package/dist/gui-experimental.cjs +0 -1
package/src/gui.tsx CHANGED
@@ -258,6 +258,60 @@ interface ProfileInfo {
258
258
  active: boolean
259
259
  }
260
260
 
261
+ /** Запись dead-letter queue (Спринт 36.6). */
262
+ interface DlqEntry {
263
+ id: string
264
+ runId: string
265
+ stepName: string
266
+ status: "open" | "retried" | "discarded" | string
267
+ reason: string | null
268
+ error: string | null
269
+ attempts: number
270
+ createdAt: string
271
+ updatedAt: string
272
+ resolvedAt: string | null
273
+ resolution: string | null
274
+ }
275
+
276
+ /** Шаг durable-запуска в панели pause/resume (Спринт 36.8). */
277
+ interface RunPanelStep {
278
+ stepName: string
279
+ position: number
280
+ status: string
281
+ attempt: number
282
+ error: string | null
283
+ anchor: string
284
+ }
285
+
286
+ /** Вставка контекста в истории запуска. */
287
+ interface RunPanelInjection {
288
+ id: string
289
+ kind: string
290
+ content: string
291
+ contentLength: number
292
+ author: string
293
+ createdAt: string
294
+ consumedAt: string | null
295
+ consumedByStep: string | null
296
+ }
297
+
298
+ /** Durable-запуск в панели pause/resume. */
299
+ interface RunPanelRun {
300
+ id: string
301
+ taskName: string
302
+ status: "pending" | "running" | "paused" | "passed" | "failed" | "cancelled"
303
+ createdAt: string
304
+ startedAt: string | null
305
+ finishedAt: string | null
306
+ error: string | null
307
+ steps: RunPanelStep[]
308
+ currentStep: RunPanelStep | null
309
+ doneSteps: number
310
+ totalSteps: number
311
+ injections: RunPanelInjection[]
312
+ pendingInjections: number
313
+ }
314
+
261
315
  function statusColor(status: JobStatus): string {
262
316
  switch (status) {
263
317
  case "running": return "#f5a623"
@@ -547,7 +601,20 @@ export default Plugin.define({
547
601
  const [secretName, setSecretName] = createSignal("")
548
602
  const [secretValue, setSecretValue] = createSignal("")
549
603
 
604
+ // Durable-запуски (Спринт 36.8): пауза, комментарий и resume в GUI.
605
+ const [runPanelRuns, setRunPanelRuns] = createSignal<RunPanelRun[]>([])
606
+ const [runPanelActive, setRunPanelActive] = createSignal(0)
607
+ const [runPanelBusy, setRunPanelBusy] = createSignal(false)
608
+ const [runPanelCollapsed, setRunPanelCollapsed] = createSignal(true)
609
+ const [runPanelFilter, setRunPanelFilter] = createSignal<"active" | "all" | "running" | "paused" | "failed">("active")
610
+ const [runPanelComments, setRunPanelComments] = createSignal<Record<string, string>>({})
611
+
550
612
  // Аудит (Спринт 26): журнал мутаций.
613
+ const [dlqEntries, setDlqEntries] = createSignal<DlqEntry[]>([])
614
+ const [dlqOpen, setDlqOpen] = createSignal(0)
615
+ const [dlqBusy, setDlqBusy] = createSignal(false)
616
+ const [dlqCollapsed, setDlqCollapsed] = createSignal(true)
617
+ const [dlqFilter, setDlqFilter] = createSignal<"open" | "all" | "retried" | "discarded">("open")
551
618
  const [auditRecords, setAuditRecords] = createSignal<{ id: number; ts: string; action: string; targetType: string | null; target: string | null; actor: string; source: string | null; details: unknown; remote: string | null }[]>([])
552
619
  const [auditBusy, setAuditBusy] = createSignal(false)
553
620
  const [auditCollapsed, setAuditCollapsed] = createSignal(true)
@@ -676,6 +743,8 @@ export default Plugin.define({
676
743
 
677
744
  void loadSecretsGui()
678
745
  void loadAuditGui()
746
+ void loadDlqGui()
747
+ void loadRunPanel()
679
748
  }
680
749
 
681
750
  /** Текущие настройки уведомлений из сигналов формы. */
@@ -930,6 +999,160 @@ export default Plugin.define({
930
999
  await persistSettings({ audit: { enabled: auditRetentionEnabled(), retentionDays: auditRetentionDays(), maxRecords: auditMaxRecords() } })
931
1000
  }
932
1001
 
1002
+ /** Загрузка durable-запусков (Спринт 36.8). */
1003
+ async function loadRunPanel() {
1004
+ setRunPanelBusy(true)
1005
+ try {
1006
+ const result = await rpc.list_durable_runs({ filter: runPanelFilter(), limit: 20 })
1007
+ if (result?.success) {
1008
+ setRunPanelRuns(result.runs ?? [])
1009
+ setRunPanelActive(Number(result.active ?? 0))
1010
+ } else if (result?.error) {
1011
+ console.error("RPC Error (list_durable_runs):", result.error)
1012
+ }
1013
+ } catch (err: any) {
1014
+ console.error("RPC Error (list_durable_runs):", err)
1015
+ } finally {
1016
+ setRunPanelBusy(false)
1017
+ }
1018
+ }
1019
+
1020
+ /** Пауза с комментарием: следующий шаг получит его при resume. */
1021
+ async function handlePauseRun(run: RunPanelRun) {
1022
+ const comment = (runPanelComments()[run.id] ?? "").trim()
1023
+ if (!window.confirm(gt("gui.runsPauseConfirm", { task: run.taskName }))) return
1024
+ setRunPanelBusy(true)
1025
+ try {
1026
+ const result = await rpc.pause_durable_run({
1027
+ runId: run.id,
1028
+ comment: comment || undefined,
1029
+ author: "gui",
1030
+ })
1031
+ if (result?.success) {
1032
+ setRunPanelComments((prev) => ({ ...prev, [run.id]: "" }))
1033
+ ctx.toast.show({
1034
+ title: gt("gui.runsPaused"),
1035
+ variant: "success",
1036
+ description: gt("gui.runsPausedDescription", { step: result.stepName ?? "—" }),
1037
+ })
1038
+ } else {
1039
+ ctx.toast.show({
1040
+ title: gt("gui.runsPauseFailed"),
1041
+ variant: "error",
1042
+ description: result?.error ?? gt("gui.runsUnknownError"),
1043
+ })
1044
+ }
1045
+ await loadRunPanel()
1046
+ } catch (err: any) {
1047
+ console.error("RPC Error (pause_durable_run):", err)
1048
+ ctx.toast.show({ title: gt("gui.runsPauseFailed"), variant: "error", description: errorMessage(err) })
1049
+ } finally {
1050
+ setRunPanelBusy(false)
1051
+ }
1052
+ }
1053
+
1054
+ /** Resume только готовит запуск: снимает паузу и выбирает следующий шаг. */
1055
+ async function handleResumeRun(run: RunPanelRun) {
1056
+ if (!window.confirm(gt("gui.runsResumeConfirm", { task: run.taskName }))) return
1057
+ setRunPanelBusy(true)
1058
+ try {
1059
+ const result = await rpc.resume_durable_run({ runId: run.id })
1060
+ if (result?.success) {
1061
+ ctx.toast.show({
1062
+ title: gt("gui.runsResumed"),
1063
+ variant: "success",
1064
+ description: gt("gui.runsResumedDescription", { step: result.stepName ?? "—" }),
1065
+ })
1066
+ } else {
1067
+ ctx.toast.show({
1068
+ title: gt("gui.runsResumeFailed"),
1069
+ variant: "error",
1070
+ description: result?.error ?? gt("gui.runsUnknownError"),
1071
+ })
1072
+ }
1073
+ await loadRunPanel()
1074
+ } catch (err: any) {
1075
+ console.error("RPC Error (resume_durable_run):", err)
1076
+ ctx.toast.show({ title: gt("gui.runsResumeFailed"), variant: "error", description: errorMessage(err) })
1077
+ } finally {
1078
+ setRunPanelBusy(false)
1079
+ }
1080
+ }
1081
+
1082
+ /** Загрузка dead-letter queue (Спринт 36.6). */
1083
+ async function loadDlqGui() {
1084
+ setDlqBusy(true)
1085
+ try {
1086
+ const result = await rpc.list_dlq({ status: dlqFilter(), limit: 100 })
1087
+ if (result?.success) {
1088
+ setDlqEntries(result.entries ?? [])
1089
+ setDlqOpen(Number(result.open ?? 0))
1090
+ } else if (result?.error) {
1091
+ console.error("RPC Error (list_dlq):", result.error)
1092
+ }
1093
+ } catch (err: any) {
1094
+ console.error("RPC Error (list_dlq):", err)
1095
+ } finally {
1096
+ setDlqBusy(false)
1097
+ }
1098
+ }
1099
+
1100
+ /** Ручной retry записи DLQ: шаг вернётся в запуск, выполнение подхватит resume. */
1101
+ async function handleRetryDlq(entry: DlqEntry) {
1102
+ if (!window.confirm(gt("gui.dlqRetryConfirm", { step: entry.stepName, run: entry.runId }))) return
1103
+ setDlqBusy(true)
1104
+ try {
1105
+ const result = await rpc.retry_dlq({ id: entry.id })
1106
+ if (result?.success) {
1107
+ ctx.toast.show({
1108
+ title: gt("gui.dlqRetried"),
1109
+ variant: "success",
1110
+ description: gt("gui.dlqRetriedDescription", { step: entry.stepName }),
1111
+ })
1112
+ } else {
1113
+ ctx.toast.show({
1114
+ title: gt("gui.dlqRetryFailed"),
1115
+ variant: "error",
1116
+ description: result?.error ?? gt("gui.dlqUnknownError"),
1117
+ })
1118
+ }
1119
+ await loadDlqGui()
1120
+ } catch (err: any) {
1121
+ console.error("RPC Error (retry_dlq):", err)
1122
+ ctx.toast.show({ title: gt("gui.dlqRetryFailed"), variant: "error", description: errorMessage(err) })
1123
+ } finally {
1124
+ setDlqBusy(false)
1125
+ }
1126
+ }
1127
+
1128
+ /** Осознанный отказ от повтора: запись закрывается, шаг остаётся failed. */
1129
+ async function handleDiscardDlq(entry: DlqEntry) {
1130
+ if (!window.confirm(gt("gui.dlqDiscardConfirm", { step: entry.stepName, run: entry.runId }))) return
1131
+ setDlqBusy(true)
1132
+ try {
1133
+ const result = await rpc.discard_dlq({ id: entry.id })
1134
+ if (result?.success) {
1135
+ ctx.toast.show({
1136
+ title: gt("gui.dlqDiscarded"),
1137
+ variant: "success",
1138
+ description: gt("gui.dlqDiscardedDescription", { step: entry.stepName }),
1139
+ })
1140
+ } else {
1141
+ ctx.toast.show({
1142
+ title: gt("gui.dlqDiscardFailed"),
1143
+ variant: "error",
1144
+ description: result?.error ?? gt("gui.dlqUnknownError"),
1145
+ })
1146
+ }
1147
+ await loadDlqGui()
1148
+ } catch (err: any) {
1149
+ console.error("RPC Error (discard_dlq):", err)
1150
+ ctx.toast.show({ title: gt("gui.dlqDiscardFailed"), variant: "error", description: errorMessage(err) })
1151
+ } finally {
1152
+ setDlqBusy(false)
1153
+ }
1154
+ }
1155
+
933
1156
  /** Кнопка «🧪 Тестовое уведомление». */
934
1157
  async function handleTestNotification() {
935
1158
  setTestNotificationBusy(true)
@@ -1220,7 +1443,7 @@ export default Plugin.define({
1220
1443
  const url = URL.createObjectURL(blob)
1221
1444
  const a = document.createElement("a")
1222
1445
  a.href = url
1223
- a.download = `windows-scheduler-tasks-${new Date().toISOString().slice(0, 10)}.json`
1446
+ a.download = `agent-steward-tasks-${new Date().toISOString().slice(0, 10)}.json`
1224
1447
  document.body.appendChild(a)
1225
1448
  a.click()
1226
1449
  document.body.removeChild(a)
@@ -3689,6 +3912,298 @@ export default Plugin.define({
3689
3912
  )}
3690
3913
  </div>
3691
3914
 
3915
+ {/* ⏯️ Durable-запуски: пауза и resume (Спринт 36.8) */}
3916
+ <div style="width:100%;max-width:900px;box-sizing:border-box;margin-top:8px;background:#1e1e1e;border:1px solid #333;border-radius:10px;overflow:hidden">
3917
+ <button
3918
+ onClick={() => setRunPanelCollapsed(!runPanelCollapsed())}
3919
+ style="display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;box-sizing:border-box;padding:10px 14px;background:transparent;border:none;color:#e0e0e0;font-size:12px;font-weight:600;cursor:pointer;text-align:left"
3920
+ >
3921
+ <span>{gt("gui.runsHeading")}</span>
3922
+ <span style="display:flex;align-items:center;gap:8px;font-size:11px;font-weight:400;color:#8e8e93">
3923
+ {gt("gui.runsActiveCount", { count: runPanelActive() })}
3924
+ <span>{runPanelCollapsed() ? "▾" : "▴"}</span>
3925
+ </span>
3926
+ </button>
3927
+
3928
+ {!runPanelCollapsed() && (
3929
+ <div style="padding:0 14px 14px;display:flex;flex-direction:column;gap:10px">
3930
+ <div style="font-size:11px;color:#8e8e93">{gt("gui.runsHint")}</div>
3931
+ <div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap">
3932
+ <label style="font-size:12px;color:#e0e0e0;white-space:nowrap">{gt("gui.runsFilter")}</label>
3933
+ <select
3934
+ value={runPanelFilter()}
3935
+ onChange={(e) => {
3936
+ setRunPanelFilter(e.currentTarget.value as "active" | "all" | "running" | "paused" | "failed")
3937
+ void loadRunPanel()
3938
+ }}
3939
+ style="padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
3940
+ >
3941
+ <option value="active">{gt("gui.runsFilterActive")}</option>
3942
+ <option value="all">{gt("gui.runsFilterAll")}</option>
3943
+ <option value="running">{gt("gui.runsFilterRunning")}</option>
3944
+ <option value="paused">{gt("gui.runsFilterPaused")}</option>
3945
+ <option value="failed">{gt("gui.runsFilterFailed")}</option>
3946
+ </select>
3947
+ <button
3948
+ onClick={() => void loadRunPanel()}
3949
+ disabled={runPanelBusy()}
3950
+ style={runPanelBusy()
3951
+ ? "padding:6px 12px;background:#666;color:white;border:none;border-radius:6px;cursor:not-allowed;font-size:12px;font-weight:500;opacity:0.6"
3952
+ : "padding:6px 12px;background:#007acc;color:white;border:none;border-radius:6px;cursor:pointer;font-size:12px;font-weight:500;opacity:1"}
3953
+ >
3954
+ {runPanelBusy() ? gt("gui.loading") : gt("gui.refresh")}
3955
+ </button>
3956
+ </div>
3957
+
3958
+ {runPanelRuns().map((run) => (
3959
+ <div style="border:1px solid #333;border-radius:8px;background:#0f0f0f;padding:10px;display:flex;flex-direction:column;gap:8px">
3960
+ <div style="display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap">
3961
+ <div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap">
3962
+ <span style="color:#5ac8fa;font-weight:600;font-size:12px">{run.taskName}</span>
3963
+ <span style="font-size:10px;color:#8e8e93">run: {run.id.slice(0, 8)}</span>
3964
+ <span
3965
+ style={`font-size:10px;font-weight:600;padding:2px 7px;border-radius:999px;border:1px solid ${
3966
+ run.status === "paused"
3967
+ ? "#ff9f0a"
3968
+ : run.status === "running"
3969
+ ? "#f5a623"
3970
+ : run.status === "failed"
3971
+ ? "#ff3b30"
3972
+ : run.status === "passed"
3973
+ ? "#34c759"
3974
+ : "#555"
3975
+ };color:#e0e0e0`}
3976
+ >
3977
+ {run.status}
3978
+ </span>
3979
+ </div>
3980
+ <span style="font-size:10px;color:#8e8e93">
3981
+ {gt("gui.runsProgress", { done: run.doneSteps, total: run.totalSteps })}
3982
+ </span>
3983
+ </div>
3984
+
3985
+ <div style="font-size:11px;color:#e0e0e0">
3986
+ {run.currentStep ? (
3987
+ <span>
3988
+ {gt("gui.runsCurrentStep")}{" "}
3989
+ <a href={`#${run.currentStep.anchor}`} style="color:#5ac8fa;text-decoration:none">
3990
+ {run.currentStep.stepName}
3991
+ </a>{" "}
3992
+ <span style="color:#8e8e93">
3993
+ · {run.currentStep.status} · attempt {run.currentStep.attempt}
3994
+ </span>
3995
+ </span>
3996
+ ) : (
3997
+ <span style="color:#8e8e93">{gt("gui.runsNoCurrentStep")}</span>
3998
+ )}
3999
+ </div>
4000
+
4001
+ {run.currentStep?.status === "running" && (
4002
+ <div style="font-size:11px;color:#ff9f0a;background:#2a1f00;border:1px solid #5a3d00;border-radius:6px;padding:6px 8px">
4003
+ {gt("gui.runsRunningWarning")}
4004
+ </div>
4005
+ )}
4006
+
4007
+ {(run.status === "pending" || run.status === "running") && (
4008
+ <div style="display:flex;align-items:center;gap:6px;flex-wrap:wrap">
4009
+ <input
4010
+ type="text"
4011
+ value={runPanelComments()[run.id] ?? ""}
4012
+ placeholder={gt("gui.runsCommentPlaceholder")}
4013
+ onInput={(e) =>
4014
+ setRunPanelComments((prev) => ({ ...prev, [run.id]: e.currentTarget.value }))
4015
+ }
4016
+ style="flex:1;min-width:180px;padding:5px 7px;background:#1e1e1e;border:1px solid #333;border-radius:5px;color:#fff;font-size:11px;outline:none"
4017
+ />
4018
+ <button
4019
+ onClick={() => void handlePauseRun(run)}
4020
+ disabled={runPanelBusy() || run.currentStep?.status === "running"}
4021
+ title={run.currentStep?.status === "running"
4022
+ ? gt("gui.runsRunningWarning")
4023
+ : gt("gui.runsPauseTitle")}
4024
+ style={runPanelBusy() || run.currentStep?.status === "running"
4025
+ ? "padding:5px 10px;background:#666;color:white;border:none;border-radius:5px;cursor:not-allowed;font-size:11px;opacity:0.6"
4026
+ : "padding:5px 10px;background:#ff9f0a;color:#1a1a1a;border:none;border-radius:5px;cursor:pointer;font-size:11px;font-weight:600"}
4027
+ >
4028
+ ⏸ {gt("gui.runsPause")}
4029
+ </button>
4030
+ </div>
4031
+ )}
4032
+
4033
+ {(run.status === "paused" || run.status === "failed") && (
4034
+ <div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap">
4035
+ <button
4036
+ onClick={() => void handleResumeRun(run)}
4037
+ disabled={runPanelBusy()}
4038
+ title={gt("gui.runsResumeTitle")}
4039
+ style="padding:5px 10px;background:#34c759;color:#0a1a0a;border:none;border-radius:5px;cursor:pointer;font-size:11px;font-weight:600"
4040
+ >
4041
+ ▶ {gt("gui.runsResume")}
4042
+ </button>
4043
+ <span style="font-size:10px;color:#8e8e93">{gt("gui.runsResumeHint")}</span>
4044
+ </div>
4045
+ )}
4046
+
4047
+ {run.error && (
4048
+ <div style="font-size:11px;color:#ff9f0a;overflow-wrap:anywhere">{shortError(run.error)}</div>
4049
+ )}
4050
+
4051
+ <div style="display:flex;flex-direction:column;gap:3px">
4052
+ {run.steps.map((step) => (
4053
+ <div
4054
+ id={step.anchor}
4055
+ style="display:flex;align-items:center;gap:8px;font-size:11px;padding:3px 5px;border-radius:4px;background:#161616"
4056
+ >
4057
+ <span style="width:18px;color:#8e8e93;text-align:right">{step.position}</span>
4058
+ <span style="flex:1;color:#e0e0e0;overflow-wrap:anywhere">{step.stepName}</span>
4059
+ <span style="color:#8e8e93">{step.status}</span>
4060
+ <span style="color:#8e8e93">#{step.attempt}</span>
4061
+ {step.error && (
4062
+ <span style="color:#ff9f0a;max-width:260px;overflow-wrap:anywhere" title={step.error}>
4063
+ {shortError(step.error, 80)}
4064
+ </span>
4065
+ )}
4066
+ </div>
4067
+ ))}
4068
+ </div>
4069
+
4070
+ {run.injections.length > 0 && (
4071
+ <div style="border-top:1px solid #222;padding-top:6px;display:flex;flex-direction:column;gap:4px">
4072
+ <div style="font-size:10px;color:#8e8e93">
4073
+ {gt("gui.runsContextHistory", { count: run.injections.length })}
4074
+ </div>
4075
+ {run.injections.slice(-3).map((injection) => (
4076
+ <div style="font-size:10px;color:#c7c7cc">
4077
+ <span style="color:#5ac8fa">{injection.author}</span>
4078
+ <span style="color:#8e8e93"> · {injection.kind} · {new Date(injection.createdAt).toLocaleString()}</span>
4079
+ {injection.consumedAt ? (
4080
+ <span style="color:#34c759"> · {gt("gui.runsConsumedBy", { step: injection.consumedByStep ?? "—" })}</span>
4081
+ ) : (
4082
+ <span style="color:#ff9f0a"> · {gt("gui.runsPending")}</span>
4083
+ )}
4084
+ <div style="color:#e0e0e0;overflow-wrap:anywhere">{injection.content}</div>
4085
+ </div>
4086
+ ))}
4087
+ </div>
4088
+ )}
4089
+ </div>
4090
+ ))}
4091
+
4092
+ {runPanelRuns().length === 0 && (
4093
+ <div style="font-size:11px;color:#8e8e93;padding:6px 0">{gt("gui.runsEmpty")}</div>
4094
+ )}
4095
+ </div>
4096
+ )}
4097
+ </div>
4098
+
4099
+ {/* ♻️ Dead-letter queue (Спринт 36.6) */}
4100
+ <div style="width:100%;max-width:900px;box-sizing:border-box;margin-top:8px;background:#1e1e1e;border:1px solid #333;border-radius:10px;overflow:hidden">
4101
+ <button
4102
+ onClick={() => setDlqCollapsed(!dlqCollapsed())}
4103
+ style="display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;box-sizing:border-box;padding:10px 14px;background:transparent;border:none;color:#e0e0e0;font-size:12px;font-weight:600;cursor:pointer;text-align:left"
4104
+ >
4105
+ <span>{gt("gui.dlqHeading")}</span>
4106
+ <span style="display:flex;align-items:center;gap:8px;font-size:11px;font-weight:400;color:#8e8e93">
4107
+ {gt("gui.dlqOpenCount", { count: dlqOpen() })}
4108
+ <span>{dlqCollapsed() ? "▾" : "▴"}</span>
4109
+ </span>
4110
+ </button>
4111
+
4112
+ {!dlqCollapsed() && (
4113
+ <div style="padding:0 14px 14px;display:flex;flex-direction:column;gap:10px">
4114
+ <div style="font-size:11px;color:#8e8e93">{gt("gui.dlqHint")}</div>
4115
+ <div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap">
4116
+ <label style="font-size:12px;color:#e0e0e0;white-space:nowrap">{gt("gui.dlqFilter")}</label>
4117
+ <select
4118
+ value={dlqFilter()}
4119
+ onChange={(e) => {
4120
+ setDlqFilter(e.currentTarget.value as "open" | "all" | "retried" | "discarded")
4121
+ void loadDlqGui()
4122
+ }}
4123
+ style="padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
4124
+ >
4125
+ <option value="open">{gt("gui.dlqFilterOpen")}</option>
4126
+ <option value="all">{gt("gui.dlqFilterAll")}</option>
4127
+ <option value="retried">{gt("gui.dlqFilterRetried")}</option>
4128
+ <option value="discarded">{gt("gui.dlqFilterDiscarded")}</option>
4129
+ </select>
4130
+ <button
4131
+ onClick={() => void loadDlqGui()}
4132
+ disabled={dlqBusy()}
4133
+ style={dlqBusy()
4134
+ ? "padding:6px 12px;background:#666;color:white;border:none;border-radius:6px;cursor:not-allowed;font-size:12px;font-weight:500;opacity:0.6"
4135
+ : "padding:6px 12px;background:#007acc;color:white;border:none;border-radius:6px;cursor:pointer;font-size:12px;font-weight:500;opacity:1"}
4136
+ >
4137
+ {dlqBusy() ? gt("gui.loading") : gt("gui.refresh")}
4138
+ </button>
4139
+ </div>
4140
+ <div style="width:100%;overflow:auto;border:1px solid #333;border-radius:6px;background:#0f0f0f">
4141
+ <table style="width:100%;border-collapse:collapse;font-size:11px">
4142
+ <thead>
4143
+ <tr style="border-bottom:1px solid #333">
4144
+ <th style="text-align:left;padding:6px 8px;color:#8e8e93">{gt("gui.dlqCreated")}</th>
4145
+ <th style="text-align:left;padding:6px 8px;color:#8e8e93">{gt("gui.dlqRun")}</th>
4146
+ <th style="text-align:left;padding:6px 8px;color:#8e8e93">{gt("gui.dlqReason")}</th>
4147
+ <th style="text-align:left;padding:6px 8px;color:#8e8e93">{gt("gui.dlqAttempts")}</th>
4148
+ <th style="text-align:left;padding:6px 8px;color:#8e8e93">{gt("gui.dlqError")}</th>
4149
+ <th style="text-align:left;padding:6px 8px;color:#8e8e93">{gt("gui.dlqActions")}</th>
4150
+ </tr>
4151
+ </thead>
4152
+ <tbody>
4153
+ {dlqEntries().map((entry) => (
4154
+ <tr key={entry.id} style="border-bottom:1px solid #222">
4155
+ <td style="padding:5px 8px;color:#8e8e93;white-space:nowrap">{new Date(entry.createdAt).toLocaleString()}</td>
4156
+ <td style="padding:5px 8px;color:#e0e0e0">
4157
+ <div style="color:#5ac8fa">{entry.stepName}</div>
4158
+ <div style="color:#8e8e93;font-size:10px">run: {entry.runId}</div>
4159
+ </td>
4160
+ <td style="padding:5px 8px;color:#e0e0e0;white-space:nowrap">
4161
+ {entry.reason === "attempts-exhausted"
4162
+ ? gt("gui.dlqReasonAttempts")
4163
+ : entry.reason === "manual"
4164
+ ? gt("gui.dlqReasonManual")
4165
+ : (entry.reason ?? "—")}
4166
+ </td>
4167
+ <td style="padding:5px 8px;color:#e0e0e0">{entry.attempts}</td>
4168
+ <td style="padding:5px 8px;color:#ff9f0a;max-width:280px;overflow-wrap:anywhere" title={entry.error ?? ""}>{entry.error ? shortError(entry.error) : "—"}</td>
4169
+ <td style="padding:5px 8px;white-space:nowrap">
4170
+ {entry.status === "open" ? (
4171
+ <div style="display:flex;align-items:center;gap:6px">
4172
+ <button
4173
+ onClick={() => void handleRetryDlq(entry)}
4174
+ disabled={dlqBusy()}
4175
+ title={gt("gui.dlqRetryTitle")}
4176
+ style="padding:3px 8px;background:#007acc;color:white;border:none;border-radius:5px;cursor:pointer;font-size:11px"
4177
+ >
4178
+ ↻ {gt("gui.dlqRetry")}
4179
+ </button>
4180
+ <button
4181
+ onClick={() => void handleDiscardDlq(entry)}
4182
+ disabled={dlqBusy()}
4183
+ title={gt("gui.dlqDiscardTitle")}
4184
+ style="padding:3px 8px;background:#3a3a3c;color:#e0e0e0;border:none;border-radius:5px;cursor:pointer;font-size:11px"
4185
+ >
4186
+ ✕ {gt("gui.dlqDiscard")}
4187
+ </button>
4188
+ </div>
4189
+ ) : (
4190
+ <span style="color:#8e8e93">{entry.status}{entry.resolution ? ` · ${entry.resolution}` : ""}</span>
4191
+ )}
4192
+ </td>
4193
+ </tr>
4194
+ ))}
4195
+ {dlqEntries().length === 0 && (
4196
+ <tr>
4197
+ <td colspan="6" style="padding:8px;color:#8e8e93">{gt("gui.dlqEmpty")}</td>
4198
+ </tr>
4199
+ )}
4200
+ </tbody>
4201
+ </table>
4202
+ </div>
4203
+ </div>
4204
+ )}
4205
+ </div>
4206
+
3692
4207
  {/* 📜 Журнал аудита (Спринт 26) */}
3693
4208
  <div style="width:100%;max-width:900px;box-sizing:border-box;margin-top:8px;background:#1e1e1e;border:1px solid #333;border-radius:10px;overflow:hidden">
3694
4209
  <div style="display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 14px">
package/src/history.ts CHANGED
@@ -61,7 +61,7 @@ export interface Metrics {
61
61
  * `records` должны быть отсортированы от новых к старым (как loadHistory).
62
62
  */
63
63
  export function latestHistoryByTask(
64
- records: readonly HistoryRecord[]
64
+ records: readonly HistoryRecord[],
65
65
  ): Map<string, HistoryRecord> {
66
66
  const latest = new Map<string, HistoryRecord>();
67
67
  for (const record of records) {
@@ -75,12 +75,12 @@ export function latestHistoryByTask(
75
75
  export async function loadHistory(
76
76
  taskName?: string | null,
77
77
  limit = 200,
78
- status?: string | null
78
+ status?: string | null,
79
79
  ): Promise<HistoryRecord[]> {
80
80
  return getHistory(taskName, limit, status).map((record) => ({
81
81
  taskName: record.taskName,
82
82
  // Незавершённые записи до recovery показываем как error для GUI.
83
- status: (record.status === "running" ? "error" : record.status) as TaskStatus,
83
+ status: (record.status === "running" ? "error" : record.status),
84
84
  startedAt: record.startedAt,
85
85
  finishedAt: record.finishedAt ?? "",
86
86
  durationMs: record.durationMs ?? 0,
@@ -120,7 +120,7 @@ export async function recordTaskRun(
120
120
  taskName: string,
121
121
  status: TaskStatus,
122
122
  durationMs: number,
123
- error?: string | null
123
+ error?: string | null,
124
124
  ): Promise<void> {
125
125
  const finishedAt = new Date().toISOString();
126
126
  const startedAt = new Date(Date.now() - durationMs).toISOString();
package/src/i18n.ts CHANGED
@@ -104,7 +104,7 @@ export function isLocaleMode(value: unknown): value is LocaleMode {
104
104
  */
105
105
  export function mapAppLocale(
106
106
  value: unknown,
107
- fallback: Locale = DEFAULT_LOCALE
107
+ fallback: Locale = DEFAULT_LOCALE,
108
108
  ): Locale {
109
109
  if (typeof value !== "string") return fallback;
110
110
  const base = value.trim().toLowerCase().split(/[-_]/)[0];
@@ -114,7 +114,7 @@ export function mapAppLocale(
114
114
  /** Приводит произвольное значение к поддерживаемой локали (с учётом BCP 47). */
115
115
  export function normalizeLocale(
116
116
  value: unknown,
117
- fallback: Locale = DEFAULT_LOCALE
117
+ fallback: Locale = DEFAULT_LOCALE,
118
118
  ): Locale {
119
119
  return mapAppLocale(value, fallback);
120
120
  }
@@ -122,7 +122,7 @@ export function normalizeLocale(
122
122
  /** Приводит значение к режиму локали: `auto` или поддерживаемая локаль. */
123
123
  export function normalizeLocaleMode(
124
124
  value: unknown,
125
- fallback: LocaleMode = DEFAULT_LOCALE
125
+ fallback: LocaleMode = DEFAULT_LOCALE,
126
126
  ): LocaleMode {
127
127
  if (value === LOCALE_AUTO) return LOCALE_AUTO;
128
128
  if (typeof value === "string") {
@@ -188,7 +188,7 @@ function readCatalog(locale: Locale): Record<string, string> {
188
188
  console.error(
189
189
  `[i18n] Не удалось прочитать ${file}: ${
190
190
  err instanceof Error ? err.message : String(err)
191
- }`
191
+ }`,
192
192
  );
193
193
  }
194
194
  }
@@ -207,7 +207,7 @@ function readCatalog(locale: Locale): Record<string, string> {
207
207
  */
208
208
  export function registerCatalog(
209
209
  locale: Locale,
210
- messages: Record<string, unknown>
210
+ messages: Record<string, unknown>,
211
211
  ): void {
212
212
  const parsed: Record<string, string> = {};
213
213
  for (const [key, value] of Object.entries(messages)) {
@@ -327,7 +327,7 @@ function renderTemplate(
327
327
  template: string,
328
328
  locale: Locale,
329
329
  params: Record<string, unknown>,
330
- count?: number
330
+ count?: number,
331
331
  ): string {
332
332
  let out = "";
333
333
  let i = 0;
@@ -358,7 +358,7 @@ function renderTemplate(
358
358
  function renderExpression(
359
359
  body: string,
360
360
  locale: Locale,
361
- params: Record<string, unknown>
361
+ params: Record<string, unknown>,
362
362
  ): string {
363
363
  const comma = topLevelCommaIndex(body);
364
364
  const name = (comma === -1 ? body : body.slice(0, comma)).trim();