agent-steward 0.0.3 → 0.0.5

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 (287) hide show
  1. package/CHANGELOG.md +154 -2
  2. package/CROSS_PLATFORM.md +19 -0
  3. package/README.md +54 -9
  4. package/ROADMAP-STRATEGY.md +23 -20
  5. package/ROADMAP.md +140 -143
  6. package/dist/cli.d.ts +3 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +351 -0
  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 +18 -1
  14. package/dist/core/execution.d.ts +203 -0
  15. package/dist/core/execution.d.ts.map +1 -0
  16. package/dist/core/execution.js +309 -0
  17. package/dist/core/gate-integrity.d.ts +35 -0
  18. package/dist/core/gate-integrity.d.ts.map +1 -0
  19. package/dist/core/gate-integrity.js +132 -0
  20. package/dist/core/git-trigger.d.ts.map +1 -1
  21. package/dist/core/git-trigger.js +14 -2
  22. package/dist/core/guard-run.d.ts +4 -0
  23. package/dist/core/guard-run.d.ts.map +1 -0
  24. package/dist/core/guard-run.js +101 -0
  25. package/dist/core/guard.d.ts +52 -0
  26. package/dist/core/guard.d.ts.map +1 -0
  27. package/dist/core/guard.js +362 -0
  28. package/dist/core/lock.d.ts +61 -4
  29. package/dist/core/lock.d.ts.map +1 -1
  30. package/dist/core/lock.js +213 -26
  31. package/dist/core/matrix.d.ts.map +1 -1
  32. package/dist/core/matrix.js +75 -15
  33. package/dist/core/mission.d.ts +83 -0
  34. package/dist/core/mission.d.ts.map +1 -0
  35. package/dist/core/mission.js +334 -0
  36. package/dist/core/one-shot.d.ts +5 -1
  37. package/dist/core/one-shot.d.ts.map +1 -1
  38. package/dist/core/one-shot.js +33 -8
  39. package/dist/core/opencode-cli.d.ts +28 -0
  40. package/dist/core/opencode-cli.d.ts.map +1 -0
  41. package/dist/core/opencode-cli.js +74 -0
  42. package/dist/core/opencode-models.d.ts +62 -0
  43. package/dist/core/opencode-models.d.ts.map +1 -0
  44. package/dist/core/opencode-models.js +277 -0
  45. package/dist/core/pipeline-apply.d.ts +38 -0
  46. package/dist/core/pipeline-apply.d.ts.map +1 -0
  47. package/dist/core/pipeline-apply.js +117 -0
  48. package/dist/core/pipeline-io.d.ts +13 -0
  49. package/dist/core/pipeline-io.d.ts.map +1 -0
  50. package/dist/core/pipeline-io.js +64 -0
  51. package/dist/core/pipeline-map.d.ts +46 -0
  52. package/dist/core/pipeline-map.d.ts.map +1 -0
  53. package/dist/core/pipeline-map.js +196 -0
  54. package/dist/core/pipeline-spec.d.ts +109 -0
  55. package/dist/core/pipeline-spec.d.ts.map +1 -0
  56. package/dist/core/pipeline-spec.js +554 -0
  57. package/dist/core/ps-wrapper.d.ts +19 -2
  58. package/dist/core/ps-wrapper.d.ts.map +1 -1
  59. package/dist/core/ps-wrapper.js +261 -63
  60. package/dist/core/record-history.d.ts +15 -0
  61. package/dist/core/record-history.d.ts.map +1 -1
  62. package/dist/core/record-history.js +183 -58
  63. package/dist/core/router/dispatch.d.ts +36 -0
  64. package/dist/core/router/dispatch.d.ts.map +1 -0
  65. package/dist/core/router/dispatch.js +59 -0
  66. package/dist/core/router/escalation.d.ts +47 -0
  67. package/dist/core/router/escalation.d.ts.map +1 -0
  68. package/dist/core/router/escalation.js +87 -0
  69. package/dist/core/router/planner.d.ts +53 -0
  70. package/dist/core/router/planner.d.ts.map +1 -0
  71. package/dist/core/router/planner.js +113 -0
  72. package/dist/core/router/rules.d.ts +46 -0
  73. package/dist/core/router/rules.d.ts.map +1 -0
  74. package/dist/core/router/rules.js +91 -0
  75. package/dist/core/run-panel-api.d.ts +94 -0
  76. package/dist/core/run-panel-api.d.ts.map +1 -0
  77. package/dist/core/run-panel-api.js +169 -0
  78. package/dist/core/schedule-gate.js +5 -1
  79. package/dist/core/schedule-v2.d.ts +34 -0
  80. package/dist/core/schedule-v2.d.ts.map +1 -1
  81. package/dist/core/schedule-v2.js +91 -5
  82. package/dist/core/scheduler/at-fallback.d.ts +55 -2
  83. package/dist/core/scheduler/at-fallback.d.ts.map +1 -1
  84. package/dist/core/scheduler/at-fallback.js +135 -5
  85. package/dist/core/scheduler/linux.d.ts +18 -2
  86. package/dist/core/scheduler/linux.d.ts.map +1 -1
  87. package/dist/core/scheduler/linux.js +63 -20
  88. package/dist/core/scheduler/mac.d.ts +44 -2
  89. package/dist/core/scheduler/mac.d.ts.map +1 -1
  90. package/dist/core/scheduler/mac.js +126 -15
  91. package/dist/core/scheduler/posix.d.ts.map +1 -1
  92. package/dist/core/scheduler/posix.js +25 -1
  93. package/dist/core/scheduler/registry.d.ts +11 -0
  94. package/dist/core/scheduler/registry.d.ts.map +1 -1
  95. package/dist/core/scheduler/registry.js +83 -21
  96. package/dist/core/scheduler/run-now.d.ts +16 -0
  97. package/dist/core/scheduler/run-now.d.ts.map +1 -0
  98. package/dist/core/scheduler/run-now.js +28 -0
  99. package/dist/core/scheduler/windows.d.ts.map +1 -1
  100. package/dist/core/scheduler/windows.js +15 -12
  101. package/dist/core/secrets.d.ts.map +1 -1
  102. package/dist/core/secrets.js +125 -28
  103. package/dist/core/session.d.ts.map +1 -1
  104. package/dist/core/session.js +18 -11
  105. package/dist/core/structured-log.d.ts +7 -1
  106. package/dist/core/structured-log.d.ts.map +1 -1
  107. package/dist/core/task-name.d.ts +24 -0
  108. package/dist/core/task-name.d.ts.map +1 -0
  109. package/dist/core/task-name.js +40 -0
  110. package/dist/core/worktree-run.d.ts +4 -0
  111. package/dist/core/worktree-run.d.ts.map +1 -0
  112. package/dist/core/worktree-run.js +164 -0
  113. package/dist/core/worktree.d.ts +115 -0
  114. package/dist/core/worktree.d.ts.map +1 -0
  115. package/dist/core/worktree.js +462 -0
  116. package/dist/core/wrappers/bash.d.ts +17 -0
  117. package/dist/core/wrappers/bash.d.ts.map +1 -1
  118. package/dist/core/wrappers/bash.js +224 -28
  119. package/dist/db/capability-repo.d.ts +124 -0
  120. package/dist/db/capability-repo.d.ts.map +1 -0
  121. package/dist/db/capability-repo.js +267 -0
  122. package/dist/db/history-repo.d.ts +46 -5
  123. package/dist/db/history-repo.d.ts.map +1 -1
  124. package/dist/db/history-repo.js +107 -25
  125. package/dist/db/index.d.ts +4 -0
  126. package/dist/db/index.d.ts.map +1 -1
  127. package/dist/db/index.js +39 -1
  128. package/dist/db/metrics-repo.js +2 -2
  129. package/dist/db/migrate.d.ts.map +1 -1
  130. package/dist/db/migrate.js +3 -1
  131. package/dist/db/recovery.d.ts.map +1 -1
  132. package/dist/db/recovery.js +5 -4
  133. package/dist/db/run-context.d.ts +103 -0
  134. package/dist/db/run-context.d.ts.map +1 -0
  135. package/dist/db/run-context.js +224 -0
  136. package/dist/db/run-dlq.d.ts +100 -0
  137. package/dist/db/run-dlq.d.ts.map +1 -0
  138. package/dist/db/run-dlq.js +191 -0
  139. package/dist/db/run-journal.d.ts +33 -5
  140. package/dist/db/run-journal.d.ts.map +1 -1
  141. package/dist/db/run-journal.js +78 -14
  142. package/dist/db/run-resume.d.ts +10 -2
  143. package/dist/db/run-resume.d.ts.map +1 -1
  144. package/dist/db/run-resume.js +39 -13
  145. package/dist/db/runs-repo.d.ts +32 -7
  146. package/dist/db/runs-repo.d.ts.map +1 -1
  147. package/dist/db/runs-repo.js +50 -11
  148. package/dist/db/schema.d.ts +2 -2
  149. package/dist/db/schema.d.ts.map +1 -1
  150. package/dist/db/schema.js +216 -3
  151. package/dist/db/settings-repo.d.ts +11 -0
  152. package/dist/db/settings-repo.d.ts.map +1 -1
  153. package/dist/db/settings-repo.js +25 -0
  154. package/dist/db/step-idempotency.d.ts +51 -0
  155. package/dist/db/step-idempotency.d.ts.map +1 -0
  156. package/dist/db/step-idempotency.js +136 -0
  157. package/dist/history.d.ts +1 -1
  158. package/dist/history.d.ts.map +1 -1
  159. package/dist/i18n.d.ts +5 -0
  160. package/dist/i18n.d.ts.map +1 -1
  161. package/dist/i18n.js +11 -4
  162. package/dist/index.d.ts +140 -6
  163. package/dist/index.d.ts.map +1 -1
  164. package/dist/index.js +480 -18
  165. package/dist/notifications.d.ts +22 -0
  166. package/dist/notifications.d.ts.map +1 -1
  167. package/dist/notifications.js +36 -8
  168. package/dist/profiles.d.ts.map +1 -1
  169. package/dist/profiles.js +25 -4
  170. package/dist/rpc.d.ts +924 -0
  171. package/dist/rpc.d.ts.map +1 -1
  172. package/dist/rpc.js +352 -0
  173. package/dist/server.d.ts +46 -0
  174. package/dist/server.d.ts.map +1 -1
  175. package/dist/server.js +172 -53
  176. package/dist/settings.d.ts +2 -2
  177. package/dist/settings.d.ts.map +1 -1
  178. package/dist/settings.js +3 -3
  179. package/dist/shared/jobs-view.d.ts +1 -1
  180. package/dist/shared/jobs-view.d.ts.map +1 -1
  181. package/dist/shared/jobs-view.js +2 -0
  182. package/dist/task-transfer.d.ts +16 -0
  183. package/dist/task-transfer.d.ts.map +1 -1
  184. package/dist/task-transfer.js +16 -0
  185. package/dist/types.d.ts.map +1 -1
  186. package/dist/types.js +7 -0
  187. package/dist/workspaces.d.ts +25 -3
  188. package/dist/workspaces.d.ts.map +1 -1
  189. package/dist/workspaces.js +43 -8
  190. package/docs/ARCHITECTURE.md +498 -58
  191. package/docs/COMPATIBILITY.md +2 -2
  192. package/docs/CONCEPT.md +185 -91
  193. package/docs/CROSS_PLATFORM.ru.md +20 -0
  194. package/docs/CROSS_PLATFORM.zh.md +18 -0
  195. package/docs/EXECUTION-LOOP.md +211 -0
  196. package/docs/FEATURES.md +65 -4
  197. package/docs/FEATURES.zh.md +52 -4
  198. package/docs/MIGRATION.md +2 -2
  199. package/docs/PIPELINE.md +293 -0
  200. package/docs/README.ru.md +44 -5
  201. package/docs/README.zh.md +46 -6
  202. package/docs/SAFETY.md +142 -0
  203. package/docs/SAVINGS.md +29 -0
  204. package/docs/SAVINGS.ru.md +29 -0
  205. package/docs/SAVINGS.zh.md +18 -0
  206. package/gui-experimental.cjs +9 -8
  207. package/locales/en.json +84 -1
  208. package/locales/ru.json +84 -1
  209. package/locales/zh.json +84 -1
  210. package/opencode.pipeline.yaml +35 -0
  211. package/package.json +46 -2
  212. package/scripts/audit-bundle.mjs +215 -0
  213. package/scripts/test-home.mjs +83 -0
  214. package/src/cli.ts +412 -0
  215. package/src/core/dlq-api.ts +98 -0
  216. package/src/core/dry-run.ts +27 -3
  217. package/src/core/execution.ts +538 -0
  218. package/src/core/file-watcher.ts +2 -2
  219. package/src/core/gate-integrity.ts +160 -0
  220. package/src/core/git-trigger.ts +18 -5
  221. package/src/core/guard-run.ts +119 -0
  222. package/src/core/guard.ts +431 -0
  223. package/src/core/lock.ts +244 -30
  224. package/src/core/matrix.ts +95 -50
  225. package/src/core/mission.ts +485 -0
  226. package/src/core/native-notify.ts +1 -1
  227. package/src/core/one-shot.ts +36 -8
  228. package/src/core/opencode-cli.ts +103 -0
  229. package/src/core/opencode-models.ts +315 -0
  230. package/src/core/pipeline-apply.ts +158 -0
  231. package/src/core/pipeline-io.ts +79 -0
  232. package/src/core/pipeline-map.ts +264 -0
  233. package/src/core/pipeline-spec.ts +775 -0
  234. package/src/core/ps-wrapper.ts +274 -64
  235. package/src/core/record-history.ts +229 -104
  236. package/src/core/router/dispatch.ts +94 -0
  237. package/src/core/router/escalation.ts +129 -0
  238. package/src/core/router/planner.ts +166 -0
  239. package/src/core/router/rules.ts +115 -0
  240. package/src/core/run-panel-api.ts +262 -0
  241. package/src/core/schedule-gate.ts +7 -3
  242. package/src/core/schedule-v2.ts +114 -5
  243. package/src/core/scheduler/at-fallback.ts +190 -5
  244. package/src/core/scheduler/linux.ts +72 -21
  245. package/src/core/scheduler/logs.ts +2 -2
  246. package/src/core/scheduler/mac.ts +174 -14
  247. package/src/core/scheduler/posix.ts +20 -1
  248. package/src/core/scheduler/registry.ts +107 -26
  249. package/src/core/scheduler/run-now.ts +32 -0
  250. package/src/core/scheduler/windows.ts +19 -15
  251. package/src/core/secrets.ts +131 -31
  252. package/src/core/session.ts +23 -10
  253. package/src/core/structured-log.ts +22 -5
  254. package/src/core/task-name.ts +67 -0
  255. package/src/core/telegram.ts +2 -2
  256. package/src/core/triage-worker.ts +7 -7
  257. package/src/core/triage.ts +2 -2
  258. package/src/core/worktree-run.ts +199 -0
  259. package/src/core/worktree.ts +600 -0
  260. package/src/core/wrappers/bash.ts +239 -27
  261. package/src/db/capability-repo.ts +402 -0
  262. package/src/db/history-repo.ts +151 -22
  263. package/src/db/index.ts +37 -1
  264. package/src/db/metrics-repo.ts +2 -2
  265. package/src/db/migrate.ts +3 -1
  266. package/src/db/recovery.ts +5 -4
  267. package/src/db/run-context.ts +370 -0
  268. package/src/db/run-dlq.ts +310 -0
  269. package/src/db/run-journal.ts +100 -13
  270. package/src/db/run-resume.ts +65 -13
  271. package/src/db/runs-repo.ts +66 -13
  272. package/src/db/schema.ts +218 -3
  273. package/src/db/settings-repo.ts +31 -0
  274. package/src/db/step-idempotency.ts +185 -0
  275. package/src/gui.tsx +692 -13
  276. package/src/history.ts +1 -1
  277. package/src/i18n.ts +12 -4
  278. package/src/index.ts +648 -8
  279. package/src/notifications.ts +38 -8
  280. package/src/profiles.ts +26 -4
  281. package/src/rpc.ts +379 -0
  282. package/src/server.ts +206 -54
  283. package/src/settings.ts +5 -5
  284. package/src/shared/jobs-view.ts +3 -1
  285. package/src/task-transfer.ts +31 -0
  286. package/src/types.ts +9 -0
  287. package/src/workspaces.ts +58 -9
@@ -639,13 +639,43 @@ function embeddingKey(taskName: string, status: string): string {
639
639
  return `emb:${(taskName + "|" + status).toLowerCase()}`;
640
640
  }
641
641
 
642
- /** Простой токенизатор: слова, цифры, нижний регистр. */
643
- function tokenize(text: string): string[] {
644
- return text
645
- .toLowerCase()
646
- .replace(/[^a-zа-яё0-9\s]/g, " ")
647
- .split(/\s+/)
648
- .filter((t) => t.length > 0);
642
+ /**
643
+ * CJK-символы: хирагана, катакана, хань, совместимые идеограммы, хангыль.
644
+ * Регэксп без `g`, проверяется посимвольно.
645
+ */
646
+ const CJK_CHAR_RE = /[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uac00-\ud7af]/;
647
+
648
+ /** Латиница, кириллица, цифры и диакритика — как раньше, но без вырезания CJK. */
649
+ const TOKEN_CHUNK_RE =
650
+ /[a-z\u00c0-\u024f\u0400-\u04ff0-9]+|[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uac00-\ud7af]+/g;
651
+
652
+ /**
653
+ * Простой токенизатор: слова, цифры, нижний регистр.
654
+ *
655
+ * B14: CJK-блоки больше не вырезаются. Иероглифы не разделены пробелами,
656
+ * поэтому слово режется на перекрывающиеся биграммы («任务失败» → «任务»,
657
+ * «务失», «失败»); одиночный иероглиф остаётся униграммой. Это даёт
658
+ * ненулевой вектор для `zh`/`ja`/`ko` и работает без словарей и
659
+ * `Intl.Segmenter`, одинаково на всех платформах.
660
+ */
661
+ export function tokenize(text: string): string[] {
662
+ const tokens: string[] = [];
663
+ for (const match of text.toLowerCase().matchAll(TOKEN_CHUNK_RE)) {
664
+ const chunk = match[0];
665
+ if (CJK_CHAR_RE.test(chunk[0])) {
666
+ const chars = Array.from(chunk);
667
+ if (chars.length === 1) {
668
+ tokens.push(chars[0]);
669
+ continue;
670
+ }
671
+ for (let i = 0; i < chars.length - 1; i++) {
672
+ tokens.push(chars[i] + chars[i + 1]);
673
+ }
674
+ } else {
675
+ tokens.push(chunk);
676
+ }
677
+ }
678
+ return tokens;
649
679
  }
650
680
 
651
681
  /**
@@ -659,7 +689,7 @@ function tokenize(text: string): string[] {
659
689
  * Вес — 1 + log(tf), L2-нормализация; знак из старшего бита хеша снижает
660
690
  * влияние коллизий.
661
691
  */
662
- function textToVector(text: string): number[] {
692
+ export function textToVector(text: string): number[] {
663
693
  const tokens = tokenize(text);
664
694
  const vec: number[] = new Array(EMBEDDING_DIMENSION).fill(0);
665
695
  if (tokens.length === 0) return vec;
package/src/profiles.ts CHANGED
@@ -253,16 +253,38 @@ export function listProfiles(): ProfileInfo[] {
253
253
  });
254
254
  }
255
255
 
256
- /** Свободный порт для нового профиля: 3782+N, занятые profile.json пропускаются. */
256
+ /**
257
+ * Порты, зарезервированные за профилем default: основной (PREFERRED_PORT
258
+ * в server.ts) и запасной. У default может не быть profile.json, поэтому
259
+ * в listProfiles() его порт — null, и раньше аллокатор выдавал 3782 второму
260
+ * профилю: два дашборда дрались за один порт.
261
+ */
262
+ const DEFAULT_PROFILE_PORTS = new Set([3782, 4782]);
263
+ const FIRST_PROFILE_PORT = 3783;
264
+ const LAST_PORT = 65535;
265
+
266
+ /**
267
+ * Свободный порт для нового профиля (B4.2).
268
+ *
269
+ * Исключает зарезервированные порты default, порты из profile.json всех
270
+ * профилей и порт, заданный через OPENCODE_SCHEDULER_PORT. Сканирует диапазон
271
+ * от 3783 до 65535 и берёт первый не занятый — прежняя формула
272
+ * `3782 + used.size` могла выдать уже занятый порт (например, при
273
+ * зарезервированном 3783 и одном профиле).
274
+ */
257
275
  function allocateProfilePort(): number {
258
- const used = new Set<number>();
276
+ const used = new Set<number>(DEFAULT_PROFILE_PORTS);
259
277
  for (const profile of listProfiles()) {
260
278
  if (profile.port) used.add(profile.port);
261
279
  }
262
- for (let port = 3782; port < 3882; port += 1) {
280
+ const fromEnv = Number(process.env.OPENCODE_SCHEDULER_PORT);
281
+ if (Number.isFinite(fromEnv) && fromEnv >= 1 && fromEnv <= LAST_PORT) {
282
+ used.add(Math.floor(fromEnv));
283
+ }
284
+ for (let port = FIRST_PROFILE_PORT; port <= LAST_PORT; port += 1) {
263
285
  if (!used.has(port)) return port;
264
286
  }
265
- return 3782 + used.size;
287
+ throw new Error("Не удалось выделить порт профилю: свободных портов не осталось.");
266
288
  }
267
289
 
268
290
  /**
package/src/rpc.ts CHANGED
@@ -306,6 +306,54 @@ const DeleteTaskOutput = {
306
306
 
307
307
  const RunTaskOutput = DeleteTaskOutput;
308
308
 
309
+ const RunMissionInput = {
310
+ type: "object" as const,
311
+ properties: {
312
+ prompt: { type: "string" },
313
+ cwd: { type: "string" },
314
+ taskName: { type: "string" },
315
+ taskType: { type: "string" },
316
+ model: { type: "string" },
317
+ session: { type: "string", enum: ["new", "reuse", "last"] },
318
+ sessionId: { type: "string" },
319
+ timeoutSeconds: { type: "number" },
320
+ gate: { type: "string" },
321
+ gateTimeoutSeconds: { type: "number" },
322
+ policy: { type: "string", enum: ["hybrid", "secure", "legacy"] },
323
+ allowedTools: { type: "array", items: { type: "string" } },
324
+ deniedTools: { type: "array", items: { type: "string" } },
325
+ dryRun: { type: "boolean" },
326
+ },
327
+ required: ["prompt"],
328
+ } as const;
329
+
330
+ const RunMissionOutput = {
331
+ type: "object" as const,
332
+ properties: {
333
+ success: { type: "boolean" },
334
+ dryRun: { type: "boolean" },
335
+ runId: { type: "string" },
336
+ status: { type: "string" },
337
+ description: { type: "string" },
338
+ error: { type: "string" },
339
+ steps: {
340
+ type: "array",
341
+ items: {
342
+ type: "object",
343
+ properties: {
344
+ stepName: { type: "string" },
345
+ taskType: { type: "string" },
346
+ target: { type: "string" },
347
+ status: { type: "string" },
348
+ attempt: { type: "number" },
349
+ error: { type: "string" },
350
+ },
351
+ },
352
+ },
353
+ },
354
+ required: ["success", "dryRun", "status", "description"],
355
+ } as const;
356
+
309
357
  const GetTaskLogsInput = NameOnly;
310
358
 
311
359
  const GetTaskLogsOutput = {
@@ -899,6 +947,251 @@ const GetAuditOutput = {
899
947
  required: ["success", "records", "total"],
900
948
  } as const;
901
949
 
950
+ /** Запись dead-letter queue (Спринт 36.6). */
951
+ const DlqEntrySchema = {
952
+ type: "object" as const,
953
+ properties: {
954
+ id: { type: "string" },
955
+ runId: { type: "string" },
956
+ stepName: { type: "string" },
957
+ status: { type: "string" },
958
+ reason: { type: ["string", "null"] },
959
+ error: { type: ["string", "null"] },
960
+ attempts: { type: "number" },
961
+ createdAt: { type: "string" },
962
+ updatedAt: { type: "string" },
963
+ resolvedAt: { type: ["string", "null"] },
964
+ resolution: { type: ["string", "null"] },
965
+ },
966
+ required: [
967
+ "id",
968
+ "runId",
969
+ "stepName",
970
+ "status",
971
+ "reason",
972
+ "error",
973
+ "attempts",
974
+ "createdAt",
975
+ "updatedAt",
976
+ "resolvedAt",
977
+ "resolution",
978
+ ],
979
+ } as const;
980
+
981
+ const ListDlqInput = {
982
+ type: "object" as const,
983
+ properties: {
984
+ /** open (по умолчанию) | retried | discarded | all. */
985
+ status: { type: "string" },
986
+ /** Сколько записей вернуть (по умолчанию 100, максимум 500). */
987
+ limit: { type: "number" },
988
+ },
989
+ additionalProperties: false,
990
+ } as const;
991
+
992
+ const ListDlqOutput = {
993
+ type: "object" as const,
994
+ properties: {
995
+ success: { type: "boolean" },
996
+ entries: { type: "array", items: DlqEntrySchema },
997
+ open: { type: "number" },
998
+ error: { type: "string" },
999
+ },
1000
+ required: ["success", "entries", "open"],
1001
+ additionalProperties: false,
1002
+ } as const;
1003
+
1004
+ const RetryDlqInput = {
1005
+ type: "object" as const,
1006
+ properties: {
1007
+ id: { type: "string" },
1008
+ },
1009
+ required: ["id"],
1010
+ additionalProperties: false,
1011
+ } as const;
1012
+
1013
+ const RetryDlqOutput = {
1014
+ type: "object" as const,
1015
+ properties: {
1016
+ success: { type: "boolean" },
1017
+ error: { type: "string" },
1018
+ entry: DlqEntrySchema,
1019
+ runId: { type: "string" },
1020
+ stepName: { type: "string" },
1021
+ runReopened: { type: "boolean" },
1022
+ },
1023
+ required: ["success"],
1024
+ additionalProperties: false,
1025
+ } as const;
1026
+
1027
+ const DiscardDlqInput = {
1028
+ type: "object" as const,
1029
+ properties: {
1030
+ id: { type: "string" },
1031
+ /** Причина отказа для журнала (по умолчанию discarded). */
1032
+ resolution: { type: "string" },
1033
+ },
1034
+ required: ["id"],
1035
+ additionalProperties: false,
1036
+ } as const;
1037
+
1038
+ const DiscardDlqOutput = {
1039
+ type: "object" as const,
1040
+ properties: {
1041
+ success: { type: "boolean" },
1042
+ error: { type: "string" },
1043
+ entry: DlqEntrySchema,
1044
+ },
1045
+ required: ["success"],
1046
+ additionalProperties: false,
1047
+ } as const;
1048
+
1049
+ /** Шаг durable-запуска для панели (Спринт 36.8). */
1050
+ const RunPanelStepSchema = {
1051
+ type: "object" as const,
1052
+ properties: {
1053
+ stepName: { type: "string" },
1054
+ position: { type: "number" },
1055
+ status: { type: "string" },
1056
+ attempt: { type: "number" },
1057
+ error: { type: ["string", "null"] },
1058
+ anchor: { type: "string" },
1059
+ },
1060
+ required: ["stepName", "position", "status", "attempt", "error", "anchor"],
1061
+ } as const;
1062
+
1063
+ /** Вставка контекста в истории запуска. */
1064
+ const RunPanelInjectionSchema = {
1065
+ type: "object" as const,
1066
+ properties: {
1067
+ id: { type: "string" },
1068
+ kind: { type: "string" },
1069
+ content: { type: "string" },
1070
+ contentLength: { type: "number" },
1071
+ author: { type: "string" },
1072
+ createdAt: { type: "string" },
1073
+ consumedAt: { type: ["string", "null"] },
1074
+ consumedByStep: { type: ["string", "null"] },
1075
+ },
1076
+ required: [
1077
+ "id",
1078
+ "kind",
1079
+ "content",
1080
+ "contentLength",
1081
+ "author",
1082
+ "createdAt",
1083
+ "consumedAt",
1084
+ "consumedByStep",
1085
+ ],
1086
+ } as const;
1087
+
1088
+ /** Durable-запуск в панели паузы/resume. */
1089
+ const RunPanelRunSchema = {
1090
+ type: "object" as const,
1091
+ properties: {
1092
+ id: { type: "string" },
1093
+ taskName: { type: "string" },
1094
+ status: { type: "string" },
1095
+ createdAt: { type: "string" },
1096
+ startedAt: { type: ["string", "null"] },
1097
+ finishedAt: { type: ["string", "null"] },
1098
+ error: { type: ["string", "null"] },
1099
+ steps: { type: "array", items: RunPanelStepSchema },
1100
+ currentStep: { type: ["object", "null"], properties: RunPanelStepSchema.properties },
1101
+ doneSteps: { type: "number" },
1102
+ totalSteps: { type: "number" },
1103
+ injections: { type: "array", items: RunPanelInjectionSchema },
1104
+ pendingInjections: { type: "number" },
1105
+ },
1106
+ required: [
1107
+ "id",
1108
+ "taskName",
1109
+ "status",
1110
+ "createdAt",
1111
+ "startedAt",
1112
+ "finishedAt",
1113
+ "error",
1114
+ "steps",
1115
+ "currentStep",
1116
+ "doneSteps",
1117
+ "totalSteps",
1118
+ "injections",
1119
+ "pendingInjections",
1120
+ ],
1121
+ } as const;
1122
+
1123
+ const ListDurableRunsInput = {
1124
+ type: "object" as const,
1125
+ properties: {
1126
+ /** active (по умолчанию) | all | pending | running | paused | passed | failed | cancelled. */
1127
+ filter: { type: "string" },
1128
+ /** Сколько запусков вернуть (по умолчанию 20, максимум 100). */
1129
+ limit: { type: "number" },
1130
+ },
1131
+ additionalProperties: false,
1132
+ } as const;
1133
+
1134
+ const ListDurableRunsOutput = {
1135
+ type: "object" as const,
1136
+ properties: {
1137
+ success: { type: "boolean" },
1138
+ runs: { type: "array", items: RunPanelRunSchema },
1139
+ active: { type: "number" },
1140
+ error: { type: "string" },
1141
+ },
1142
+ required: ["success", "runs", "active"],
1143
+ additionalProperties: false,
1144
+ } as const;
1145
+
1146
+ const PauseDurableRunInput = {
1147
+ type: "object" as const,
1148
+ properties: {
1149
+ runId: { type: "string" },
1150
+ /** Явный шаг-получатель; по умолчанию первый незавершённый. */
1151
+ stepName: { type: "string" },
1152
+ /** Комментарий, который получит шаг при resume. */
1153
+ comment: { type: "string" },
1154
+ /** Автор комментария (по умолчанию local-user). */
1155
+ author: { type: "string" },
1156
+ },
1157
+ required: ["runId"],
1158
+ additionalProperties: false,
1159
+ } as const;
1160
+
1161
+ const PauseDurableRunOutput = {
1162
+ type: "object" as const,
1163
+ properties: {
1164
+ success: { type: "boolean" },
1165
+ error: { type: "string" },
1166
+ run: RunPanelRunSchema,
1167
+ stepName: { type: ["string", "null"] },
1168
+ },
1169
+ required: ["success"],
1170
+ additionalProperties: false,
1171
+ } as const;
1172
+
1173
+ const ResumeDurableRunInput = {
1174
+ type: "object" as const,
1175
+ properties: {
1176
+ runId: { type: "string" },
1177
+ },
1178
+ required: ["runId"],
1179
+ additionalProperties: false,
1180
+ } as const;
1181
+
1182
+ const ResumeDurableRunOutput = {
1183
+ type: "object" as const,
1184
+ properties: {
1185
+ success: { type: "boolean" },
1186
+ error: { type: "string" },
1187
+ run: RunPanelRunSchema,
1188
+ stepName: { type: ["string", "null"] },
1189
+ prepared: { type: "boolean" },
1190
+ },
1191
+ required: ["success"],
1192
+ additionalProperties: false,
1193
+ } as const;
1194
+
902
1195
  /** Сравнение триажа «до/после» (Спринт 31.5). */
903
1196
  const CompareTriageInput = {
904
1197
  type: "object" as const,
@@ -1420,6 +1713,82 @@ const DryRunAllOutput = {
1420
1713
  required: ["success", "reports"],
1421
1714
  } as const;
1422
1715
 
1716
+ /* === Pipeline-as-code (спринт 32) === */
1717
+
1718
+ const PipelineValidateInput = {
1719
+ type: "object" as const,
1720
+ properties: {
1721
+ path: { type: "string" },
1722
+ source: { type: "string" },
1723
+ dryRun: { type: "boolean" },
1724
+ },
1725
+ additionalProperties: false,
1726
+ } as const;
1727
+
1728
+ const PipelineIssue = {
1729
+ type: "object" as const,
1730
+ properties: {
1731
+ path: { type: "string" },
1732
+ message: { type: "string" },
1733
+ },
1734
+ required: ["path", "message"],
1735
+ } as const;
1736
+
1737
+ const PipelineValidationOutput = {
1738
+ type: "object" as const,
1739
+ properties: {
1740
+ ok: { type: "boolean" },
1741
+ errors: { type: "array", items: PipelineIssue },
1742
+ warnings: { type: "array", items: PipelineIssue },
1743
+ spec: {},
1744
+ },
1745
+ required: ["ok", "errors", "warnings"],
1746
+ } as const;
1747
+
1748
+ const PipelineApplyInput = {
1749
+ type: "object" as const,
1750
+ properties: {
1751
+ path: { type: "string" },
1752
+ source: { type: "string" },
1753
+ dryRun: { type: "boolean" },
1754
+ },
1755
+ additionalProperties: false,
1756
+ } as const;
1757
+
1758
+ const PipelineApplyOutput = {
1759
+ type: "object" as const,
1760
+ properties: {
1761
+ created: { type: "number" },
1762
+ updated: { type: "number" },
1763
+ unchanged: { type: "number" },
1764
+ stale: { type: "number" },
1765
+ warnings: { type: "array", items: { type: "string" } },
1766
+ errors: { type: "array", items: PipelineIssue },
1767
+ },
1768
+ required: ["created", "updated", "unchanged", "stale"],
1769
+ } as const;
1770
+
1771
+ const PipelineExportInput = {
1772
+ type: "object" as const,
1773
+ properties: {
1774
+ pipeline: { type: "string" },
1775
+ },
1776
+ required: ["pipeline"],
1777
+ additionalProperties: false,
1778
+ } as const;
1779
+
1780
+ const PipelineExportOutput = {
1781
+ type: "object" as const,
1782
+ properties: {
1783
+ ok: { type: "boolean" },
1784
+ spec: {},
1785
+ error: { type: "string" },
1786
+ },
1787
+ required: ["ok"],
1788
+ } as const;
1789
+
1790
+ /* === end Pipeline-as-code === */
1791
+
1423
1792
  /** Детальный отчёт по одному клону матрицы. */
1424
1793
  const MatrixCloneResult = {
1425
1794
  type: "object" as const,
@@ -1627,6 +1996,7 @@ export const SchedulerRpc = Rpc.define({
1627
1996
  create_task: { input: CreateTaskInput, output: CreateTaskOutput },
1628
1997
  delete_task: { input: DeleteTaskInput, output: DeleteTaskOutput },
1629
1998
  run_task: { input: RunTaskInput, output: RunTaskOutput },
1999
+ run_mission: { input: RunMissionInput, output: RunMissionOutput },
1630
2000
  pause_task: { input: PauseResumeInput, output: DeleteTaskOutput },
1631
2001
  resume_task: { input: PauseResumeInput, output: DeleteTaskOutput },
1632
2002
  update_task: { input: UpdateTaskInput, output: UpdateTaskOutput },
@@ -1637,6 +2007,9 @@ export const SchedulerRpc = Rpc.define({
1637
2007
  get_platform: { input: GetPlatformInput, output: GetPlatformOutput },
1638
2008
  dry_run: { input: DryRunInput, output: DryRunReportOutput },
1639
2009
  dry_run_all: { input: GetTasksInput, output: DryRunAllOutput },
2010
+ pipeline_validate: { input: PipelineValidateInput, output: PipelineValidationOutput },
2011
+ pipeline_apply: { input: PipelineApplyInput, output: PipelineApplyOutput },
2012
+ pipeline_export: { input: PipelineExportInput, output: PipelineExportOutput },
1640
2013
  get_matrix_results: {
1641
2014
  input: GetMatrixResultsInput,
1642
2015
  output: GetMatrixResultsOutput,
@@ -1681,6 +2054,12 @@ export const SchedulerRpc = Rpc.define({
1681
2054
  save_secret: { input: SaveSecretInput, output: SaveSecretOutput },
1682
2055
  delete_secret: { input: DeleteSecretInput, output: DeleteSecretOutput },
1683
2056
  get_audit: { input: GetAuditInput, output: GetAuditOutput },
2057
+ list_dlq: { input: ListDlqInput, output: ListDlqOutput },
2058
+ retry_dlq: { input: RetryDlqInput, output: RetryDlqOutput },
2059
+ discard_dlq: { input: DiscardDlqInput, output: DiscardDlqOutput },
2060
+ list_durable_runs: { input: ListDurableRunsInput, output: ListDurableRunsOutput },
2061
+ pause_durable_run: { input: PauseDurableRunInput, output: PauseDurableRunOutput },
2062
+ resume_durable_run: { input: ResumeDurableRunInput, output: ResumeDurableRunOutput },
1684
2063
  compare_triage: {
1685
2064
  input: CompareTriageInput,
1686
2065
  output: CompareTriageOutput,