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.
Files changed (180) hide show
  1. package/CHANGELOG.md +25 -2
  2. package/CROSS_PLATFORM.md +11 -9
  3. package/README.md +9 -8
  4. package/ROADMAP-STRATEGY.md +93 -44
  5. package/ROADMAP.md +114 -999
  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/dry-run.js +1 -1
  10. package/dist/core/file-watcher.js +9 -9
  11. package/dist/core/git-trigger.js +4 -4
  12. package/dist/core/lock.js +2 -4
  13. package/dist/core/one-shot.d.ts +27 -5
  14. package/dist/core/one-shot.d.ts.map +1 -1
  15. package/dist/core/one-shot.js +53 -10
  16. package/dist/core/otel.js +2 -2
  17. package/dist/core/ps-wrapper.d.ts +1 -1
  18. package/dist/core/ps-wrapper.d.ts.map +1 -1
  19. package/dist/core/ps-wrapper.js +55 -35
  20. package/dist/core/record-history.js +22 -22
  21. package/dist/core/schedule-v2.d.ts +2 -2
  22. package/dist/core/schedule-v2.d.ts.map +1 -1
  23. package/dist/core/schedule-v2.js +7 -7
  24. package/dist/core/scheduler/at-fallback.d.ts +42 -0
  25. package/dist/core/scheduler/at-fallback.d.ts.map +1 -0
  26. package/dist/core/scheduler/at-fallback.js +70 -0
  27. package/dist/core/scheduler/linux.d.ts +3 -1
  28. package/dist/core/scheduler/linux.d.ts.map +1 -1
  29. package/dist/core/scheduler/linux.js +43 -7
  30. package/dist/core/scheduler/mac.d.ts +14 -8
  31. package/dist/core/scheduler/mac.d.ts.map +1 -1
  32. package/dist/core/scheduler/mac.js +71 -22
  33. package/dist/core/scheduler/posix.d.ts.map +1 -1
  34. package/dist/core/scheduler/posix.js +12 -1
  35. package/dist/core/scheduler/registry.d.ts +2 -0
  36. package/dist/core/scheduler/registry.d.ts.map +1 -1
  37. package/dist/core/scheduler/windows.d.ts +16 -3
  38. package/dist/core/scheduler/windows.d.ts.map +1 -1
  39. package/dist/core/scheduler/windows.js +249 -96
  40. package/dist/core/secrets.js +2 -2
  41. package/dist/core/self-analysis.js +55 -55
  42. package/dist/core/summary.js +1 -1
  43. package/dist/core/triage-chain.js +1 -1
  44. package/dist/core/triage-worker.js +2 -2
  45. package/dist/core/triage.js +1 -1
  46. package/dist/core/wrappers/bash.js +33 -33
  47. package/dist/db/index.d.ts +2 -0
  48. package/dist/db/index.d.ts.map +1 -1
  49. package/dist/db/index.js +9 -1
  50. package/dist/db/run-journal.d.ts +60 -0
  51. package/dist/db/run-journal.d.ts.map +1 -0
  52. package/dist/db/run-journal.js +143 -0
  53. package/dist/db/run-resume.d.ts +48 -0
  54. package/dist/db/run-resume.d.ts.map +1 -0
  55. package/dist/db/run-resume.js +137 -0
  56. package/dist/db/runs-repo.d.ts +120 -0
  57. package/dist/db/runs-repo.d.ts.map +1 -0
  58. package/dist/db/runs-repo.js +319 -0
  59. package/dist/db/schema.d.ts +16 -2
  60. package/dist/db/schema.d.ts.map +1 -1
  61. package/dist/db/schema.js +190 -35
  62. package/dist/index.d.ts +1 -1
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +66 -36
  65. package/dist/notifications.js +18 -18
  66. package/dist/profiles.d.ts +7 -3
  67. package/dist/profiles.d.ts.map +1 -1
  68. package/dist/profiles.js +85 -7
  69. package/dist/rpc.d.ts +109 -0
  70. package/dist/rpc.d.ts.map +1 -1
  71. package/dist/rpc.js +89 -0
  72. package/dist/server.d.ts +2 -2
  73. package/dist/server.d.ts.map +1 -1
  74. package/dist/server.js +20 -19
  75. package/dist/shared/jobs-view.d.ts.map +1 -1
  76. package/dist/skill.js +1 -1
  77. package/dist/task-transfer.d.ts +1 -1
  78. package/dist/task-transfer.d.ts.map +1 -1
  79. package/dist/task-transfer.js +14 -10
  80. package/dist/types.d.ts +20 -4
  81. package/dist/types.d.ts.map +1 -1
  82. package/dist/types.js +37 -9
  83. package/dist/workspaces.js +1 -1
  84. package/docs/ARCHITECTURE.md +110 -8
  85. package/docs/COMPATIBILITY.md +10 -6
  86. package/docs/CONCEPT.md +15 -3
  87. package/docs/CROSS_PLATFORM.ru.md +11 -9
  88. package/docs/CROSS_PLATFORM.zh.md +11 -9
  89. package/docs/FAQ.md +2 -2
  90. package/docs/FAQ.ru.md +2 -2
  91. package/docs/FAQ.zh.md +2 -2
  92. package/docs/FEATURES.md +5 -4
  93. package/docs/FEATURES.zh.md +5 -4
  94. package/docs/MIGRATION.md +34 -26
  95. package/docs/README.ru.md +26 -7
  96. package/docs/README.zh.md +9 -8
  97. package/docs/V1-V2-COMPATIBILITY-PLAN.md +6 -6
  98. package/gui-experimental.cjs +8 -8
  99. package/index.js +1 -0
  100. package/locales/en.json +1 -0
  101. package/locales/ru.json +1 -0
  102. package/locales/zh.json +1 -0
  103. package/package.json +31 -10
  104. package/src/core/analytics.ts +2 -2
  105. package/src/core/audit.ts +17 -17
  106. package/src/core/cron-to-schtasks.ts +14 -93
  107. package/src/core/dry-run.ts +26 -26
  108. package/src/core/file-watcher.ts +17 -17
  109. package/src/core/git-trigger.ts +9 -9
  110. package/src/core/glob.ts +1 -1
  111. package/src/core/local-ai.ts +2 -2
  112. package/src/core/lock.ts +9 -9
  113. package/src/core/matrix.ts +31 -31
  114. package/src/core/native-notify.ts +2 -2
  115. package/src/core/one-shot.ts +63 -13
  116. package/src/core/otel.ts +4 -4
  117. package/src/core/permissions.ts +5 -5
  118. package/src/core/prometheus.ts +17 -17
  119. package/src/core/ps-wrapper.ts +57 -37
  120. package/src/core/record-history.ts +40 -40
  121. package/src/core/retention.ts +3 -3
  122. package/src/core/savings.ts +1 -1
  123. package/src/core/schedule-gate.ts +12 -12
  124. package/src/core/schedule-v2.ts +24 -24
  125. package/src/core/scheduler/at-fallback.ts +113 -0
  126. package/src/core/scheduler/index.ts +3 -3
  127. package/src/core/scheduler/linux.ts +64 -13
  128. package/src/core/scheduler/logs.ts +1 -1
  129. package/src/core/scheduler/mac.ts +112 -60
  130. package/src/core/scheduler/posix.ts +15 -1
  131. package/src/core/scheduler/registry.ts +6 -4
  132. package/src/core/scheduler/windows.ts +295 -125
  133. package/src/core/secrets.ts +13 -13
  134. package/src/core/self-analysis.ts +61 -61
  135. package/src/core/session.ts +3 -3
  136. package/src/core/structured-log.ts +3 -3
  137. package/src/core/summary.ts +25 -25
  138. package/src/core/telegram.ts +16 -16
  139. package/src/core/triage-chain.ts +4 -4
  140. package/src/core/triage-compare.ts +8 -8
  141. package/src/core/triage-rules.ts +4 -4
  142. package/src/core/triage-shadow.ts +7 -7
  143. package/src/core/triage-worker.ts +6 -6
  144. package/src/core/triage.ts +23 -23
  145. package/src/core/watch-paths.ts +1 -1
  146. package/src/core/wrappers/bash.ts +41 -41
  147. package/src/db/git-state-repo.ts +1 -1
  148. package/src/db/history-repo.ts +22 -22
  149. package/src/db/index.ts +16 -6
  150. package/src/db/metrics-repo.ts +10 -10
  151. package/src/db/migrate.ts +10 -10
  152. package/src/db/recovery.ts +3 -3
  153. package/src/db/run-journal.ts +212 -0
  154. package/src/db/run-resume.ts +220 -0
  155. package/src/db/runs-repo.ts +481 -0
  156. package/src/db/schema.ts +205 -44
  157. package/src/db/settings-repo.ts +2 -2
  158. package/src/db/tasks-repo.ts +10 -10
  159. package/src/db/templates-repo.ts +7 -7
  160. package/src/gui.tsx +1 -1
  161. package/src/history.ts +4 -4
  162. package/src/i18n.ts +7 -7
  163. package/src/index.ts +341 -304
  164. package/src/integrations.ts +6 -6
  165. package/src/notifications.ts +76 -76
  166. package/src/profiles.ts +98 -7
  167. package/src/rpc.ts +96 -1
  168. package/src/schtasks.ts +2 -2
  169. package/src/server.ts +43 -42
  170. package/src/settings.ts +44 -44
  171. package/src/shared/jobs-view.ts +60 -60
  172. package/src/skill.ts +1 -1
  173. package/src/task-transfer.ts +58 -56
  174. package/src/templates.ts +1 -1
  175. package/src/types.ts +45 -10
  176. package/src/workspaces.ts +16 -16
  177. package/dist/core/self-analysis.test.d.ts +0 -2
  178. package/dist/core/self-analysis.test.d.ts.map +0 -1
  179. package/dist/core/self-analysis.test.js +0 -219
  180. package/dist/gui-experimental.cjs +0 -1
package/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { default } from './dist/index.js';
2
+ export * from './dist/index.js';
package/locales/en.json CHANGED
@@ -671,6 +671,7 @@
671
671
  "tool.error.matrixNoClones": "Matrix \"{name}\" has no clones.",
672
672
  "tool.error.matrixNotMatrix": "Task \"{name}\" is not a matrix.",
673
673
  "tool.error.matrixOverride": "Task \"{task}\": matrix.overrides contains workspace \"{workspace}\" that is not listed in workspaceIds.",
674
+ "tool.error.modelInvalid": "Invalid model \"{model}\": {error}",
674
675
  "tool.error.mcpEventRequired": "An MCP trigger requires an event name (mcpEvent.event).",
675
676
  "tool.error.onceFields": "runAt/delaySeconds are only allowed with triggerType=once.",
676
677
  "tool.error.onceMatrixSchema": "One-shot cannot be combined with matrix: a matrix is started manually only.",
package/locales/ru.json CHANGED
@@ -671,6 +671,7 @@
671
671
  "tool.error.matrixNoClones": "У матрицы \"{name}\" нет клонов.",
672
672
  "tool.error.matrixNotMatrix": "Задача \"{name}\" не является матрицей.",
673
673
  "tool.error.matrixOverride": "Задача \"{task}\": matrix.overrides содержит workspace \"{workspace}\", которого нет в workspaceIds.",
674
+ "tool.error.modelInvalid": "Недопустимая модель «{model}»: {error}",
674
675
  "tool.error.mcpEventRequired": "Для MCP-триггера нужно указать имя события (mcpEvent.event).",
675
676
  "tool.error.onceFields": "runAt/delaySeconds допустимы только при triggerType=once.",
676
677
  "tool.error.onceMatrixSchema": "One-shot нельзя комбинировать с matrix: матрица запускается только вручную.",
package/locales/zh.json CHANGED
@@ -671,6 +671,7 @@
671
671
  "tool.error.matrixNoClones": "矩阵 “{name}” 没有克隆。",
672
672
  "tool.error.matrixNotMatrix": "任务 “{name}” 不是矩阵。",
673
673
  "tool.error.matrixOverride": "任务 “{task}”:matrix.overrides 包含未在 workspaceIds 中列出的工作区 “{workspace}”。",
674
+ "tool.error.modelInvalid": "无效的模型 “{model}”:{error}",
674
675
  "tool.error.mcpEventRequired": "MCP 触发器需要事件名称(mcpEvent.event)。",
675
676
  "tool.error.onceFields": "runAt/delaySeconds 仅在 triggerType=once 时允许。",
676
677
  "tool.error.onceMatrixSchema": "One-shot 不能与矩阵组合:矩阵仅可手动启动。",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-steward",
3
- "version": "0.0.2",
4
- "description": "OpenCode v2 plugin for scheduling and orchestrating AI agent jobs: cron, one-shot runs, DAG pipelines, matrix builds, quality gates, SQLite history, metrics and a local web dashboard. Windows, macOS and Linux. Free and open source (MIT).",
3
+ "version": "0.0.3",
4
+ "description": "OpenCode plugin for V1 and V2: scheduling and orchestrating AI agent jobs — cron, one-shot runs, DAG pipelines, matrix builds, quality gates, SQLite history, metrics and a local web dashboard. Windows, macOS and Linux. Free and open source (MIT).",
5
5
  "license": "MIT",
6
6
  "author": "agent-steward contributors",
7
7
  "homepage": "https://github.com/DeadSno/agent-steward#readme",
@@ -38,9 +38,13 @@
38
38
  "types": "dist/index.d.ts",
39
39
  "type": "module",
40
40
  "exports": {
41
- ".": "./dist/index.js",
41
+ ".": {
42
+ "types": "./dist/index.d.ts",
43
+ "default": "./dist/index.js"
44
+ },
42
45
  "./tui": "./src/tui.tsx",
43
- "./gui-experimental": "./gui-experimental.cjs"
46
+ "./gui-experimental": "./gui-experimental.cjs",
47
+ "./package.json": "./package.json"
44
48
  },
45
49
  "files": [
46
50
  "dist",
@@ -48,7 +52,7 @@
48
52
  "index.js",
49
53
  "gui-experimental.cjs",
50
54
  "skills",
51
- "locales",
55
+ "locales",
52
56
  "scripts",
53
57
  "docs",
54
58
  "README.md",
@@ -66,14 +70,20 @@
66
70
  },
67
71
  "scripts": {
68
72
  "build": "tsc",
73
+ "lint": "eslint src",
74
+ "lint-job": "eslint src",
69
75
  "build:gui": "vite build",
70
76
  "demo": "node scripts/demo-dashboard.mjs",
71
77
  "bench:local": "node scripts/bench-local.mjs",
72
78
  "prepare": "npm run build",
73
79
  "prepublishOnly": "npm run build && npm run build:gui",
74
80
  "pretest": "npm run build",
75
- "test": "node test-sqlite.mjs && node test-crash-recovery.mjs && node test-workspaces.mjs && node test-role-scoped.mjs && node test-permissions-policy.mjs && node test-dry-run.mjs && node test-matrix.mjs && node test-matrix-lifecycle.mjs && node test-matrix-sync.mjs && node test-retention.mjs && node test-metrics.mjs && node test-savings.mjs && node test-schedule-v2.mjs && node test-notifications-v2.mjs && node test-notifications-dedup.mjs && node test-notifications-embedding.mjs && node test-notifications-summary.mjs && node test-settings.mjs && node test-notifications-v3.mjs && node test-triage.mjs && node test-triage-rules.mjs && node test-triage-compare.mjs && node test-triage-chain.mjs && node test-triage-shadow.mjs && node test-triage-audit.mjs && node test-triage-async.mjs && node test-local-ai.mjs && node test-secrets.mjs && node test-audit.mjs && node test-profiles.mjs && node test-env.mjs && node test-agent-tools.mjs && node test-skill.mjs && node test-integrations.mjs && node test-one-shot.mjs && node test-session-continuity.mjs && node test-task-status.mjs && node test-jobs-view.mjs && node test-dag.mjs && node test-dashboard.mjs && node test-dashboard-trust.mjs && node test-dashboard-dag.mjs && node test-dashboard-json.mjs && node test-docs.mjs && node test-glob.mjs && node test-git-trigger.mjs && node test-window-v3.mjs && node test-i18n.mjs && node test-gui-bundle.mjs && node test-stale-lock.mjs && node test-task-name-limit.mjs && node test-task-name-limit-profile.mjs && node test-delete-profile.mjs && node test-execution-hardening.mjs && node test-path-safety.mjs && node test-watch-paths.mjs && node test-windows-oem.mjs && node test-schtasks-errors.mjs && node test-shutdown.mjs && node test-dual-entry.mjs && node test-v1-integration.mjs && node test-usage-from-log.mjs && node test-posix-e2e.mjs",
81
+ "test": "node test-sqlite.mjs && node test-user-version.mjs && node test-run-state.mjs && node test-run-journal.mjs && node test-run-resume.mjs && node test-crash-recovery.mjs && node test-workspaces.mjs && node test-role-scoped.mjs && node test-permissions-policy.mjs && node test-dry-run.mjs && node test-matrix.mjs && node test-matrix-lifecycle.mjs && node test-matrix-sync.mjs && node test-retention.mjs && node test-metrics.mjs && node test-savings.mjs && node test-schedule-v2.mjs && node test-notifications-v2.mjs && node test-notifications-dedup.mjs && node test-notifications-embedding.mjs && node test-notifications-summary.mjs && node test-settings.mjs && node test-notifications-v3.mjs && node test-triage.mjs && node test-triage-rules.mjs && node test-triage-compare.mjs && node test-triage-chain.mjs && node test-triage-shadow.mjs && node test-triage-audit.mjs && node test-triage-async.mjs && node test-local-ai.mjs && node test-secrets.mjs && node test-audit.mjs && node test-profiles.mjs && node test-env.mjs && node test-agent-tools.mjs && node test-self-analysis.mjs && node test-skill.mjs && node test-integrations.mjs && node test-one-shot.mjs && node test-session-continuity.mjs && node test-task-status.mjs && node test-jobs-view.mjs && node test-dag.mjs && node test-dashboard.mjs && node test-dashboard-trust.mjs && node test-dashboard-dag.mjs && node test-dashboard-json.mjs && node test-docs.mjs && node test-glob.mjs && node test-git-trigger.mjs && node test-window-v3.mjs && node test-i18n.mjs && node test-gui-bundle.mjs && node test-stale-lock.mjs && node test-task-name-limit.mjs && node test-task-name-limit-profile.mjs && node test-delete-profile.mjs && node test-execution-hardening.mjs && node test-path-safety.mjs && node test-watch-paths.mjs && node test-windows-oem.mjs && node test-schtasks-errors.mjs && node test-schtasks-locales.mjs && node test-cron-to-schtasks.mjs && node test-mac-cron.mjs && node test-at-fallback.mjs && node test-shutdown.mjs && node test-dual-entry.mjs && node test-v1-integration.mjs && node test-usage-from-log.mjs && node test-posix-e2e.mjs && node test-model-validation.mjs",
76
82
  "test:sqlite": "node test-sqlite.mjs",
83
+ "test:user-version": "node test-user-version.mjs",
84
+ "test:run-state": "node test-run-state.mjs",
85
+ "test:run-journal": "node test-run-journal.mjs",
86
+ "test:run-resume": "node test-run-resume.mjs",
77
87
  "test:crash": "node test-crash-recovery.mjs",
78
88
  "test:workspaces": "node test-workspaces.mjs",
79
89
  "test:role": "node test-role-scoped.mjs",
@@ -89,6 +99,7 @@
89
99
  "test:settings": "node test-settings.mjs",
90
100
  "test:triage": "node test-triage.mjs",
91
101
  "test:triage-rules": "node test-triage-rules.mjs",
102
+ "test:triage-compare": "node test-triage-compare.mjs",
92
103
  "test:triage-chain": "node test-triage-chain.mjs",
93
104
  "test:triage-shadow": "node test-triage-shadow.mjs",
94
105
  "test:triage-audit": "node test-triage-audit.mjs",
@@ -114,20 +125,26 @@
114
125
  "test:git-trigger": "node test-git-trigger.mjs",
115
126
  "test:window-v3": "node test-window-v3.mjs",
116
127
  "test:self-analysis": "node test-self-analysis.mjs",
117
- "test:i18n": "node test-i18n.mjs",
118
- "test:gui-bundle": "node test-gui-bundle.mjs",
128
+ "test:i18n": "node test-i18n.mjs",
129
+ "test:gui-bundle": "node test-gui-bundle.mjs",
119
130
  "test:stale-lock": "node test-stale-lock.mjs",
120
131
  "test:task-name-limit": "node test-task-name-limit.mjs && node test-task-name-limit-profile.mjs",
121
132
  "test:delete-profile": "node test-delete-profile.mjs",
122
133
  "test:windows-oem": "node test-windows-oem.mjs",
134
+ "test:schtasks-locales": "node test-schtasks-locales.mjs",
123
135
  "test:schtasks-errors": "node test-schtasks-errors.mjs",
136
+ "test:cron-to-schtasks": "node test-cron-to-schtasks.mjs",
137
+ "test:mac-cron": "node test-mac-cron.mjs",
138
+ "test:at-fallback": "node test-at-fallback.mjs",
124
139
  "test:shutdown": "node test-shutdown.mjs",
125
140
  "test:usage-from-log": "node test-usage-from-log.mjs",
126
141
  "test:posix-e2e": "node test-posix-e2e.mjs",
142
+ "test:model": "node test-model-validation.mjs",
127
143
  "test:watch-paths": "node test-watch-paths.mjs",
128
144
  "test:en": "node scripts/test-locale.mjs en",
129
145
  "test:zh": "node scripts/test-locale.mjs zh",
130
146
  "test:parallel": "node scripts/run-tests.mjs",
147
+ "pretest:parallel": "npm run build",
131
148
  "test:parallel:en": "node scripts/run-tests.mjs --locale=en",
132
149
  "test:parallel:zh": "node scripts/run-tests.mjs --locale=zh"
133
150
  },
@@ -140,11 +157,15 @@
140
157
  },
141
158
  "devDependencies": {
142
159
  "@opencode-ai/plugin": "1.19.5",
143
- "@opentui/core": ">=0.8.1",
144
- "@opentui/solid": ">=0.8.1",
160
+ "@opentui/core": "0.8.4",
161
+ "@opentui/solid": "0.8.4",
145
162
  "@types/node": "^22.0.0",
163
+ "@typescript-eslint/eslint-plugin": "^8.73.0",
164
+ "@typescript-eslint/parser": "^8.73.0",
165
+ "eslint": "^10.15.0",
146
166
  "solid-js": "^1.9.0",
147
167
  "typescript": "^5.9.3",
168
+ "typescript-eslint": "^8.73.0",
148
169
  "vite": "^7.0.0",
149
170
  "vite-plugin-solid": "^2.11.0"
150
171
  }
@@ -164,7 +164,7 @@ function percent(part: number, total: number): number {
164
164
  */
165
165
  export function buildAnalytics(
166
166
  records: AnalyticsRecord[],
167
- options: BuildAnalyticsOptions = {}
167
+ options: BuildAnalyticsOptions = {},
168
168
  ): AnalyticsReport {
169
169
  const windowDays = Math.max(1, Math.floor(options.days ?? 14));
170
170
  const topLimit = Math.max(1, Math.floor(options.topLimit ?? 10));
@@ -416,7 +416,7 @@ export function historyToCsv(records: AnalyticsRecord[]): string {
416
416
  record.error ?? "",
417
417
  ]
418
418
  .map(csvCell)
419
- .join(";")
419
+ .join(";"),
420
420
  );
421
421
  }
422
422
  // BOM, чтобы Excel корректно открыл UTF-8 с кириллицей.
package/src/core/audit.ts CHANGED
@@ -110,7 +110,7 @@ export function recordAudit(entry: AuditEntryInput): number | null {
110
110
  .prepare(
111
111
  `INSERT INTO audit_log
112
112
  (ts, action, target_type, target, actor, source, details_json, remote)
113
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
113
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
114
114
  )
115
115
  .run(
116
116
  ts,
@@ -120,7 +120,7 @@ export function recordAudit(entry: AuditEntryInput): number | null {
120
120
  String(entry.actor || "system").slice(0, 32),
121
121
  entry.source == null ? null : String(entry.source).slice(0, 128),
122
122
  safeJson(entry.details),
123
- entry.remote == null ? null : String(entry.remote).slice(0, 128)
123
+ entry.remote == null ? null : String(entry.remote).slice(0, 128),
124
124
  );
125
125
  maybeCleanup();
126
126
  return Number(result.lastInsertRowid) || null;
@@ -129,7 +129,7 @@ export function recordAudit(entry: AuditEntryInput): number | null {
129
129
  console.warn(
130
130
  `[audit] не удалось записать событие: ${
131
131
  err instanceof Error ? err.message : String(err)
132
- }`
132
+ }`,
133
133
  );
134
134
  } catch {
135
135
  // console недоступен — молча игнорируем.
@@ -222,21 +222,21 @@ export function recordTaskToolBlocks(
222
222
  actor: AuditActor = "system",
223
223
  source = "policy",
224
224
  policy?: PermissionPolicy,
225
- legacyShell?: boolean
225
+ legacyShell?: boolean,
226
226
  ): number {
227
227
  const normalizedDenied = Array.from(
228
228
  new Set(
229
229
  (deniedTools ?? [])
230
230
  .map((tool) => String(tool).trim())
231
- .filter(Boolean)
232
- )
231
+ .filter(Boolean),
232
+ ),
233
233
  );
234
234
  const normalizedAllowed = Array.from(
235
235
  new Set(
236
236
  (allowedTools ?? [])
237
237
  .map((tool) => String(tool).trim())
238
- .filter(Boolean)
239
- )
238
+ .filter(Boolean),
239
+ ),
240
240
  );
241
241
  const details = {
242
242
  reason: "deniedTools",
@@ -331,17 +331,17 @@ export function readAuditLog(filter: ReadAuditFilter = {}): ReadAuditResult {
331
331
  const db = getDb();
332
332
  const totalRow = db
333
333
  .prepare(`SELECT COUNT(*) AS count FROM audit_log ${clause}`)
334
- .get(...params) as any;
334
+ .get(...params);
335
335
  const rows = db
336
336
  .prepare(`SELECT * FROM audit_log ${clause} ORDER BY ts DESC, id DESC LIMIT ?`)
337
- .all(...params, limit) as any[];
337
+ .all(...params, limit);
338
338
  return { records: rows.map(rowToRecord), total: Number(totalRow?.count) || 0 };
339
339
  } catch (err) {
340
340
  try {
341
341
  console.warn(
342
342
  `[audit] не удалось прочитать журнал: ${
343
343
  err instanceof Error ? err.message : String(err)
344
- }`
344
+ }`,
345
345
  );
346
346
  } catch {
347
347
  // ignore
@@ -360,23 +360,23 @@ export function cleanupAuditLog(options: {
360
360
  } = {}): number {
361
361
  const retentionDays = Math.max(
362
362
  0,
363
- Math.floor(options.retentionDays ?? DEFAULT_AUDIT_RETENTION_DAYS) || 0
363
+ Math.floor(options.retentionDays ?? DEFAULT_AUDIT_RETENTION_DAYS) || 0,
364
364
  );
365
365
  const maxRecords = Math.max(
366
366
  100,
367
- Math.floor(options.maxRecords ?? DEFAULT_AUDIT_MAX_RECORDS) || DEFAULT_AUDIT_MAX_RECORDS
367
+ Math.floor(options.maxRecords ?? DEFAULT_AUDIT_MAX_RECORDS) || DEFAULT_AUDIT_MAX_RECORDS,
368
368
  );
369
369
  let deleted = 0;
370
370
  try {
371
371
  const db = getDb();
372
372
  if (retentionDays > 0) {
373
373
  const cutoff = new Date(
374
- Date.now() - retentionDays * 24 * 60 * 60 * 1000
374
+ Date.now() - retentionDays * 24 * 60 * 60 * 1000,
375
375
  ).toISOString();
376
376
  const result = db.prepare("DELETE FROM audit_log WHERE ts < ?").run(cutoff);
377
377
  deleted += Number(result.changes) || 0;
378
378
  }
379
- const countRow = db.prepare("SELECT COUNT(*) AS count FROM audit_log").get() as any;
379
+ const countRow = db.prepare("SELECT COUNT(*) AS count FROM audit_log").get();
380
380
  const count = Number(countRow?.count) || 0;
381
381
  if (count > maxRecords) {
382
382
  const excess = count - maxRecords;
@@ -384,7 +384,7 @@ export function cleanupAuditLog(options: {
384
384
  .prepare(
385
385
  `DELETE FROM audit_log WHERE id IN (
386
386
  SELECT id FROM audit_log ORDER BY ts ASC, id ASC LIMIT ?
387
- )`
387
+ )`,
388
388
  )
389
389
  .run(excess);
390
390
  deleted += Number(result.changes) || 0;
@@ -394,7 +394,7 @@ export function cleanupAuditLog(options: {
394
394
  console.warn(
395
395
  `[audit] не удалось очистить журнал: ${
396
396
  err instanceof Error ? err.message : String(err)
397
- }`
397
+ }`,
398
398
  );
399
399
  } catch {
400
400
  // ignore
@@ -46,7 +46,7 @@ function isStar(value: string): boolean {
46
46
  * Возвращает N или undefined.
47
47
  */
48
48
  function parseStep(value: string): number | undefined {
49
- const match = value.match(/^\*\/(\d+)$/);
49
+ const match = /^\*\/(\d+)$/.exec(value);
50
50
  if (!match) return undefined;
51
51
  const n = parseInt(match[1], 10);
52
52
  return n > 0 ? n : undefined;
@@ -74,7 +74,7 @@ export function convertCronToSchTasks(cron: string): CronConversion {
74
74
  "Ожидалось 5 полей cron-выражения (минута час день_месяца месяц день_недели), получено " +
75
75
  fields.length +
76
76
  ".\n\n" +
77
- UNSUPPORTED_ERROR
77
+ UNSUPPORTED_ERROR,
78
78
  );
79
79
  }
80
80
 
@@ -108,24 +108,30 @@ export function convertCronToSchTasks(cron: string): CronConversion {
108
108
  "Интервал /mo " +
109
109
  stepN +
110
110
  " минут превышает максимально допустимый для schtasks (1439 минут).\n\n" +
111
- UNSUPPORTED_ERROR
111
+ UNSUPPORTED_ERROR,
112
112
  );
113
113
  }
114
- // schtasks /mo N запускает задачу каждые N минут начиная с момента создания
115
- // задачи, а cron */N — в минуты 0, N, 2N внутри каждого часа. Семантики
116
- // совпадают только когда N делит 60 без остатка; иначе отдаём задачу в
117
- // минутный опрос с gate во враппере (needsPollMode).
114
+ // schtasks /mo Nanchors на момент создания задачи, а cron */N означает
115
+ // минуты 0, N, 2N … внутри часа. Семантики совпадают только когда N
116
+ // делит 60 без остатка И есть выровненный старт (00:00), поэтому ниже
117
+ // добавляется startTime: "00:00". Для N, не делящих 60, выбрасывается
118
+ // ошибка — задача уходит в минутный опрос с gate во враппере
119
+ // (needsPollMode в windows.ts), а не конвертируется здесь нативно.
118
120
  if (60 % stepN !== 0) {
119
121
  throw new Error(
120
122
  "Интервал */" +
121
123
  stepN +
122
124
  " не делит час нацело: cron и schtasks понимают его по-разному.\n\n" +
123
- UNSUPPORTED_ERROR
125
+ UNSUPPORTED_ERROR,
124
126
  );
125
127
  }
126
128
  return {
127
129
  sc: "MINUTE",
128
130
  extraFlags: ["/mo", String(stepN)],
131
+ // schtasks /mo Nanchors на момент создания задачи; cron */N означает
132
+ // минуты 0, N, 2N … внутри часа. Выровненный старт 00:00 делает
133
+ // расписание идентичным cron для любого N, делящего 60.
134
+ startTime: "00:00",
129
135
  };
130
136
  }
131
137
 
@@ -186,91 +192,6 @@ export function convertCronToSchTasks(cron: string): CronConversion {
186
192
  throw new Error(UNSUPPORTED_ERROR);
187
193
  }
188
194
 
189
- /**
190
- * Вычисляет ближайшее прошедшее (<= now) время срабатывания для поддерживаемых
191
- * cron-выражений. Нужно для восстановления пропущенных запусков (catch-up):
192
- * сравнивая это время с историей, можно понять, выполнялась ли задача.
193
- *
194
- * Возвращает null, если выражение не поддерживается или не распознано.
195
- */
196
- export function previousRunTime(cron: string, now: Date = new Date()): Date | null {
197
- const fields = cron.trim().split(/\s+/);
198
- if (fields.length !== 5) return null;
199
-
200
- const [minute, hour, dayOfMonth, month, dayOfWeek] = fields;
201
- const star = (value: string) => value === "*";
202
- const intIn = (value: string, min: number, max: number): number | undefined => {
203
- if (!/^\d+$/.test(value)) return undefined;
204
- const n = parseInt(value, 10);
205
- return n >= min && n <= max ? n : undefined;
206
- };
207
- const nowMs = now.getTime();
208
-
209
- // * * * * * — каждую минуту: последняя граница минуты.
210
- if (star(minute) && star(hour) && star(dayOfMonth) && star(month) && star(dayOfWeek)) {
211
- return new Date(Math.floor(nowMs / 60000) * 60000);
212
- }
213
-
214
- // */N * * * * — каждые N минут внутри часа (минуты 0, N, 2N...).
215
- const step = /^\*\/(\d+)$/.exec(minute);
216
- if (step && star(hour) && star(dayOfMonth) && star(month) && star(dayOfWeek)) {
217
- const n = parseInt(step[1], 10);
218
- if (n > 0) {
219
- const result = new Date(now);
220
- result.setSeconds(0, 0);
221
- const minuteOfHour = result.getMinutes();
222
- result.setMinutes(n >= 60 ? 0 : minuteOfHour - (minuteOfHour % n));
223
- return result;
224
- }
225
- return null;
226
- }
227
-
228
- // M * * * * — каждый час в минуту M.
229
- const hourlyMinute = intIn(minute, 0, 59);
230
- if (
231
- hourlyMinute !== undefined &&
232
- star(hour) &&
233
- star(dayOfMonth) &&
234
- star(month) &&
235
- star(dayOfWeek)
236
- ) {
237
- const result = new Date(now);
238
- result.setSeconds(0, 0);
239
- result.setMinutes(hourlyMinute);
240
- if (result.getTime() > nowMs) result.setHours(result.getHours() - 1);
241
- return result;
242
- }
243
-
244
- const m = intIn(minute, 0, 59);
245
- const h = intIn(hour, 0, 23);
246
- if (m === undefined || h === undefined || !star(dayOfMonth) || !star(month)) {
247
- return null;
248
- }
249
-
250
- // M H * * * — ежедневно в HH:MM.
251
- if (star(dayOfWeek)) {
252
- const result = new Date(now);
253
- result.setSeconds(0, 0);
254
- result.setHours(h, m, 0, 0);
255
- if (result.getTime() > nowMs) result.setDate(result.getDate() - 1);
256
- return result;
257
- }
258
-
259
- // M H * * D — еженедельно в день D (0 и 7 — воскресенье) в HH:MM.
260
- const dow = intIn(dayOfWeek, 0, 7);
261
- if (dow === undefined) return null;
262
- const targetDow = dow === 7 ? 0 : dow;
263
- const result = new Date(now);
264
- result.setSeconds(0, 0);
265
- result.setHours(h, m, 0, 0);
266
- // Не больше 8 итераций: одна неделя гарантированно содержит нужный день.
267
- for (let i = 0; i <= 8; i += 1) {
268
- if (result.getTime() <= nowMs && result.getDay() === targetDow) return result;
269
- result.setDate(result.getDate() - 1);
270
- }
271
- return null;
272
- }
273
-
274
195
  /**
275
196
  * Формирует массив флагов расписания для schtasks на основе CronConversion.
276
197
  * Включает /sc, /st (если есть), и дополнительные флаги (/mo, /d).
@@ -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: Array<{ test: RegExp; messageKey: string }> = [
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 && ev.event
216
+ base.explanation = ev?.event
217
217
  ? t("dryRun.mcp.event", {
218
- server: ev.server,
219
- event: ev.event,
220
- filter: ev.filter
221
- ? t("dryRun.mcp.filter", { filter: ev.filter })
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
- schedule: def.schedule,
232
- timezone: def.timezone,
233
- })
231
+ schedule: def.schedule,
232
+ timezone: def.timezone,
233
+ })
234
234
  : t("dryRun.cron", { schedule: def.schedule });
235
235
  break;
236
236
  }
@@ -273,14 +273,14 @@ 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
286
  }
@@ -376,13 +376,13 @@ export async function simulatePipeline(taskName: string): Promise<DryRunReport>
376
376
 
377
377
  // Matrix (Спринт 15): родитель сам не выполняется — вместо него в отчёте
378
378
  // показываем клоны, по одному на workspace, с их cwd и оценками.
379
- const units: Array<{ def: TaskDefinition; matrixParent?: string }> = [];
379
+ const units: { def: TaskDefinition; matrixParent?: string }[] = [];
380
380
  for (const def of ordered) {
381
381
  if (def.matrix) {
382
382
  try {
383
383
  const clones = expandMatrixTask(def);
384
384
  warnings.push(
385
- t("dryRun.matrix.parent", { name: def.name, count: clones.length })
385
+ t("dryRun.matrix.parent", { name: def.name, count: clones.length }),
386
386
  );
387
387
  for (const clone of clones) units.push({ def: clone, matrixParent: def.name });
388
388
  } catch (err: any) {
@@ -390,7 +390,7 @@ export async function simulatePipeline(taskName: string): Promise<DryRunReport>
390
390
  list.push(
391
391
  t("dryRun.matrix.expandError", {
392
392
  error: err instanceof Error ? err.message : String(err),
393
- })
393
+ }),
394
394
  );
395
395
  warningsPerTask.set(def.name.toLowerCase(), list);
396
396
  warnings.push(`[${def.name}] ${list[list.length - 1]}`);
@@ -404,7 +404,7 @@ export async function simulatePipeline(taskName: string): Promise<DryRunReport>
404
404
  const parallelMatrixParents = new Set(
405
405
  allDefs
406
406
  .filter((d) => d.matrix && (d.matrix.strategy ?? "parallel") !== "sequential")
407
- .map((d) => d.name.toLowerCase())
407
+ .map((d) => d.name.toLowerCase()),
408
408
  );
409
409
  const parallelGroups = new Map<string, { maxDuration: number }>();
410
410
 
@@ -481,7 +481,7 @@ export async function simulatePipeline(taskName: string): Promise<DryRunReport>
481
481
  for (const { test, messageKey } of DANGEROUS_PATTERNS) {
482
482
  if (test.test(scanned)) {
483
483
  taskWarnings.push(
484
- t("dryRun.dangerPattern", { message: t(messageKey) })
484
+ t("dryRun.dangerPattern", { message: t(messageKey) }),
485
485
  );
486
486
  }
487
487
  }
@@ -519,7 +519,7 @@ export async function simulatePipeline(taskName: string): Promise<DryRunReport>
519
519
  }
520
520
  } catch {
521
521
  taskWarnings.push(
522
- t("dryRun.cronParseError", { schedule: def.schedule })
522
+ t("dryRun.cronParseError", { schedule: def.schedule }),
523
523
  );
524
524
  }
525
525
  scheduleDetails = {
@@ -581,14 +581,14 @@ export async function simulatePipeline(taskName: string): Promise<DryRunReport>
581
581
  }
582
582
 
583
583
  const hasAnyEstimate = tasks.some(
584
- (t) => t.estimatedDurationSec != null || t.estimatedCostUsd != null || t.estimatedTokens != null
584
+ (t) => t.estimatedDurationSec != null || t.estimatedCostUsd != null || t.estimatedTokens != null,
585
585
  );
586
586
  const totals: DryRunTotals = hasAnyEstimate
587
587
  ? {
588
- estimatedDurationSec: totalDuration != null ? Math.round(totalDuration * 10) / 10 : null,
589
- estimatedCostUsd: totalCost != null ? Math.round(totalCost * 10000) / 10000 : null,
590
- estimatedTokens: totalTokens != null ? Math.round(totalTokens) : null,
591
- }
588
+ estimatedDurationSec: totalDuration != null ? Math.round(totalDuration * 10) / 10 : null,
589
+ estimatedCostUsd: totalCost != null ? Math.round(totalCost * 10000) / 10000 : null,
590
+ estimatedTokens: totalTokens != null ? Math.round(totalTokens) : null,
591
+ }
592
592
  : { estimatedDurationSec: null, estimatedCostUsd: null, estimatedTokens: null };
593
593
 
594
594
  return {