agent-steward 0.0.4 → 0.0.6

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 (279) hide show
  1. package/CHANGELOG.md +309 -2
  2. package/CROSS_PLATFORM.md +19 -0
  3. package/README.md +55 -8
  4. package/ROADMAP-STRATEGY.md +22 -19
  5. package/ROADMAP.md +230 -159
  6. package/dist/cli.d.ts +3 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +356 -0
  9. package/dist/core/analytics.d.ts +6 -0
  10. package/dist/core/analytics.d.ts.map +1 -1
  11. package/dist/core/analytics.js +20 -3
  12. package/dist/core/audit.d.ts +6 -0
  13. package/dist/core/audit.d.ts.map +1 -1
  14. package/dist/core/audit.js +24 -0
  15. package/dist/core/budget.d.ts +118 -0
  16. package/dist/core/budget.d.ts.map +1 -0
  17. package/dist/core/budget.js +206 -0
  18. package/dist/core/cron-to-schtasks.d.ts.map +1 -1
  19. package/dist/core/cron-to-schtasks.js +38 -0
  20. package/dist/core/dry-run.d.ts +26 -1
  21. package/dist/core/dry-run.d.ts.map +1 -1
  22. package/dist/core/dry-run.js +199 -8
  23. package/dist/core/execution.d.ts +203 -0
  24. package/dist/core/execution.d.ts.map +1 -0
  25. package/dist/core/execution.js +309 -0
  26. package/dist/core/feedback.d.ts +192 -0
  27. package/dist/core/feedback.d.ts.map +1 -0
  28. package/dist/core/feedback.js +426 -0
  29. package/dist/core/gate-integrity.d.ts +71 -0
  30. package/dist/core/gate-integrity.d.ts.map +1 -0
  31. package/dist/core/gate-integrity.js +275 -0
  32. package/dist/core/git-trigger.d.ts.map +1 -1
  33. package/dist/core/git-trigger.js +14 -2
  34. package/dist/core/guard-run.d.ts +4 -0
  35. package/dist/core/guard-run.d.ts.map +1 -0
  36. package/dist/core/guard-run.js +101 -0
  37. package/dist/core/guard.d.ts +52 -0
  38. package/dist/core/guard.d.ts.map +1 -0
  39. package/dist/core/guard.js +362 -0
  40. package/dist/core/local-ai.d.ts.map +1 -1
  41. package/dist/core/local-ai.js +7 -3
  42. package/dist/core/lock.d.ts +41 -0
  43. package/dist/core/lock.d.ts.map +1 -1
  44. package/dist/core/lock.js +141 -29
  45. package/dist/core/matrix.d.ts +8 -0
  46. package/dist/core/matrix.d.ts.map +1 -1
  47. package/dist/core/matrix.js +132 -17
  48. package/dist/core/mission.d.ts +103 -0
  49. package/dist/core/mission.d.ts.map +1 -0
  50. package/dist/core/mission.js +374 -0
  51. package/dist/core/opencode-models.d.ts +2 -2
  52. package/dist/core/opencode-models.d.ts.map +1 -1
  53. package/dist/core/opencode-models.js +28 -21
  54. package/dist/core/opencode-usage.d.ts +35 -0
  55. package/dist/core/opencode-usage.d.ts.map +1 -0
  56. package/dist/core/opencode-usage.js +132 -0
  57. package/dist/core/pipeline-apply.d.ts +38 -0
  58. package/dist/core/pipeline-apply.d.ts.map +1 -0
  59. package/dist/core/pipeline-apply.js +117 -0
  60. package/dist/core/pipeline-io.d.ts +13 -0
  61. package/dist/core/pipeline-io.d.ts.map +1 -0
  62. package/dist/core/pipeline-io.js +78 -0
  63. package/dist/core/pipeline-map.d.ts +52 -0
  64. package/dist/core/pipeline-map.d.ts.map +1 -0
  65. package/dist/core/pipeline-map.js +208 -0
  66. package/dist/core/pipeline-spec.d.ts +109 -0
  67. package/dist/core/pipeline-spec.d.ts.map +1 -0
  68. package/dist/core/pipeline-spec.js +554 -0
  69. package/dist/core/ps-wrapper.d.ts +27 -2
  70. package/dist/core/ps-wrapper.d.ts.map +1 -1
  71. package/dist/core/ps-wrapper.js +424 -65
  72. package/dist/core/record-history.d.ts.map +1 -1
  73. package/dist/core/record-history.js +206 -33
  74. package/dist/core/router/rules.d.ts.map +1 -1
  75. package/dist/core/router/rules.js +6 -0
  76. package/dist/core/run-mode.d.ts +12 -0
  77. package/dist/core/run-mode.d.ts.map +1 -0
  78. package/dist/core/run-mode.js +17 -0
  79. package/dist/core/scheduler/linux.d.ts +8 -1
  80. package/dist/core/scheduler/linux.d.ts.map +1 -1
  81. package/dist/core/scheduler/linux.js +34 -9
  82. package/dist/core/scheduler/logs.d.ts +4 -0
  83. package/dist/core/scheduler/logs.d.ts.map +1 -1
  84. package/dist/core/scheduler/logs.js +25 -1
  85. package/dist/core/scheduler/mac.d.ts +44 -2
  86. package/dist/core/scheduler/mac.d.ts.map +1 -1
  87. package/dist/core/scheduler/mac.js +126 -15
  88. package/dist/core/scheduler/windows.d.ts.map +1 -1
  89. package/dist/core/scheduler/windows.js +15 -12
  90. package/dist/core/secrets.d.ts.map +1 -1
  91. package/dist/core/secrets.js +18 -8
  92. package/dist/core/self-analysis.d.ts +32 -2
  93. package/dist/core/self-analysis.d.ts.map +1 -1
  94. package/dist/core/self-analysis.js +38 -27
  95. package/dist/core/shutdown.d.ts +33 -2
  96. package/dist/core/shutdown.d.ts.map +1 -1
  97. package/dist/core/shutdown.js +58 -2
  98. package/dist/core/structured-log.d.ts +37 -1
  99. package/dist/core/structured-log.d.ts.map +1 -1
  100. package/dist/core/structured-log.js +37 -0
  101. package/dist/core/usage-surface.d.ts +25 -0
  102. package/dist/core/usage-surface.d.ts.map +1 -0
  103. package/dist/core/usage-surface.js +41 -0
  104. package/dist/core/worktree-run.d.ts +4 -0
  105. package/dist/core/worktree-run.d.ts.map +1 -0
  106. package/dist/core/worktree-run.js +164 -0
  107. package/dist/core/worktree.d.ts +115 -0
  108. package/dist/core/worktree.d.ts.map +1 -0
  109. package/dist/core/worktree.js +462 -0
  110. package/dist/core/wrappers/bash.d.ts +19 -0
  111. package/dist/core/wrappers/bash.d.ts.map +1 -1
  112. package/dist/core/wrappers/bash.js +230 -27
  113. package/dist/db/capability-repo.d.ts +43 -2
  114. package/dist/db/capability-repo.d.ts.map +1 -1
  115. package/dist/db/capability-repo.js +96 -11
  116. package/dist/db/history-repo.d.ts +70 -5
  117. package/dist/db/history-repo.d.ts.map +1 -1
  118. package/dist/db/history-repo.js +170 -29
  119. package/dist/db/metrics-repo.d.ts +20 -2
  120. package/dist/db/metrics-repo.d.ts.map +1 -1
  121. package/dist/db/metrics-repo.js +35 -13
  122. package/dist/db/migrate.d.ts.map +1 -1
  123. package/dist/db/migrate.js +37 -17
  124. package/dist/db/recovery.d.ts +3 -1
  125. package/dist/db/recovery.d.ts.map +1 -1
  126. package/dist/db/recovery.js +11 -5
  127. package/dist/db/run-journal.d.ts +33 -5
  128. package/dist/db/run-journal.d.ts.map +1 -1
  129. package/dist/db/run-journal.js +78 -14
  130. package/dist/db/run-resume.d.ts +5 -0
  131. package/dist/db/run-resume.d.ts.map +1 -1
  132. package/dist/db/run-resume.js +9 -2
  133. package/dist/db/runs-repo.d.ts +19 -2
  134. package/dist/db/runs-repo.d.ts.map +1 -1
  135. package/dist/db/runs-repo.js +91 -60
  136. package/dist/db/schema.d.ts +2 -2
  137. package/dist/db/schema.d.ts.map +1 -1
  138. package/dist/db/schema.js +132 -2
  139. package/dist/db/templates-repo.d.ts +2 -2
  140. package/dist/db/templates-repo.d.ts.map +1 -1
  141. package/dist/db/templates-repo.js +5 -3
  142. package/dist/history.d.ts +7 -2
  143. package/dist/history.d.ts.map +1 -1
  144. package/dist/history.js +4 -2
  145. package/dist/hook-output.d.ts +2 -0
  146. package/dist/hook-output.d.ts.map +1 -0
  147. package/dist/hook-output.js +31 -0
  148. package/dist/i18n.d.ts +5 -0
  149. package/dist/i18n.d.ts.map +1 -1
  150. package/dist/i18n.js +11 -4
  151. package/dist/index.d.ts +375 -47
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +1344 -192
  154. package/dist/notifications.d.ts +53 -2
  155. package/dist/notifications.d.ts.map +1 -1
  156. package/dist/notifications.js +168 -21
  157. package/dist/profiles.d.ts.map +1 -1
  158. package/dist/profiles.js +82 -10
  159. package/dist/rpc.d.ts +354 -0
  160. package/dist/rpc.d.ts.map +1 -1
  161. package/dist/rpc.js +145 -0
  162. package/dist/server.d.ts +32 -2
  163. package/dist/server.d.ts.map +1 -1
  164. package/dist/server.js +154 -30
  165. package/dist/settings.d.ts +44 -2
  166. package/dist/settings.d.ts.map +1 -1
  167. package/dist/settings.js +85 -3
  168. package/dist/shared/jobs-view.d.ts +1 -1
  169. package/dist/shared/jobs-view.d.ts.map +1 -1
  170. package/dist/shared/jobs-view.js +2 -0
  171. package/dist/task-transfer.d.ts +21 -0
  172. package/dist/task-transfer.d.ts.map +1 -1
  173. package/dist/task-transfer.js +64 -3
  174. package/dist/templates.d.ts +2 -2
  175. package/dist/templates.d.ts.map +1 -1
  176. package/dist/templates.js +3 -3
  177. package/dist/types.d.ts +22 -2
  178. package/dist/types.d.ts.map +1 -1
  179. package/dist/workspaces.d.ts.map +1 -1
  180. package/dist/workspaces.js +34 -11
  181. package/docs/ARCHITECTURE.md +319 -66
  182. package/docs/COMPATIBILITY.md +2 -2
  183. package/docs/CONCEPT.md +18 -4
  184. package/docs/CROSS_PLATFORM.ru.md +20 -0
  185. package/docs/CROSS_PLATFORM.zh.md +18 -0
  186. package/docs/EXECUTION-LOOP.md +28 -10
  187. package/docs/FEATURES.md +129 -7
  188. package/docs/FEATURES.zh.md +97 -6
  189. package/docs/MIGRATION.md +2 -2
  190. package/docs/PIPELINE.md +293 -0
  191. package/docs/QA-A2-GUI-TUI.md +205 -0
  192. package/docs/README.ru.md +43 -4
  193. package/docs/README.zh.md +44 -4
  194. package/docs/SAFETY.md +23 -3
  195. package/gui-experimental.cjs +9 -8
  196. package/locales/en.json +58 -3
  197. package/locales/ru.json +58 -3
  198. package/locales/zh.json +58 -3
  199. package/opencode.pipeline.yaml +35 -0
  200. package/package.json +36 -4
  201. package/scripts/check-eslint-baseline.mjs +139 -0
  202. package/scripts/gen-test-plan-counters.mjs +117 -0
  203. package/scripts/github-ci-fetch.ps1 +37 -0
  204. package/scripts/pl-commit.ps1 +112 -0
  205. package/scripts/qa-a2-commit.ps1 +104 -0
  206. package/scripts/test-home.mjs +107 -0
  207. package/skills/scheduled-job-best-practices/SKILL.md +95 -1
  208. package/skills/scheduled-job-best-practices/references/recipes.md +139 -0
  209. package/src/cli.ts +417 -0
  210. package/src/core/analytics.ts +27 -4
  211. package/src/core/audit.ts +25 -0
  212. package/src/core/budget.ts +340 -0
  213. package/src/core/cron-to-schtasks.ts +42 -0
  214. package/src/core/dry-run.ts +235 -12
  215. package/src/core/execution.ts +538 -0
  216. package/src/core/feedback.ts +582 -0
  217. package/src/core/file-watcher.ts +2 -2
  218. package/src/core/gate-integrity.ts +330 -0
  219. package/src/core/git-trigger.ts +18 -5
  220. package/src/core/guard-run.ts +119 -0
  221. package/src/core/guard.ts +431 -0
  222. package/src/core/local-ai.ts +7 -3
  223. package/src/core/lock.ts +178 -37
  224. package/src/core/matrix.ts +158 -52
  225. package/src/core/mission.ts +531 -0
  226. package/src/core/native-notify.ts +1 -1
  227. package/src/core/opencode-models.ts +30 -21
  228. package/src/core/opencode-usage.ts +182 -0
  229. package/src/core/pipeline-apply.ts +158 -0
  230. package/src/core/pipeline-io.ts +96 -0
  231. package/src/core/pipeline-map.ts +283 -0
  232. package/src/core/pipeline-spec.ts +775 -0
  233. package/src/core/ps-wrapper.ts +435 -66
  234. package/src/core/record-history.ts +258 -81
  235. package/src/core/router/rules.ts +6 -0
  236. package/src/core/run-mode.ts +19 -0
  237. package/src/core/schedule-gate.ts +1 -1
  238. package/src/core/scheduler/at-fallback.ts +1 -1
  239. package/src/core/scheduler/linux.ts +40 -11
  240. package/src/core/scheduler/logs.ts +34 -3
  241. package/src/core/scheduler/mac.ts +174 -14
  242. package/src/core/scheduler/registry.ts +2 -2
  243. package/src/core/scheduler/windows.ts +19 -15
  244. package/src/core/secrets.ts +26 -19
  245. package/src/core/self-analysis.ts +75 -29
  246. package/src/core/shutdown.ts +90 -4
  247. package/src/core/structured-log.ts +89 -5
  248. package/src/core/telegram.ts +2 -2
  249. package/src/core/triage-worker.ts +7 -7
  250. package/src/core/triage.ts +2 -2
  251. package/src/core/usage-surface.ts +70 -0
  252. package/src/core/worktree-run.ts +199 -0
  253. package/src/core/worktree.ts +600 -0
  254. package/src/core/wrappers/bash.ts +248 -26
  255. package/src/db/capability-repo.ts +127 -10
  256. package/src/db/history-repo.ts +281 -40
  257. package/src/db/metrics-repo.ts +40 -13
  258. package/src/db/migrate.ts +57 -32
  259. package/src/db/recovery.ts +12 -5
  260. package/src/db/run-journal.ts +100 -13
  261. package/src/db/run-resume.ts +17 -1
  262. package/src/db/runs-repo.ts +147 -65
  263. package/src/db/schema.ts +134 -2
  264. package/src/db/templates-repo.ts +5 -3
  265. package/src/gui.tsx +438 -18
  266. package/src/history.ts +11 -4
  267. package/src/hook-output.ts +39 -0
  268. package/src/i18n.ts +12 -4
  269. package/src/index.ts +1902 -320
  270. package/src/notifications.ts +227 -47
  271. package/src/profiles.ts +88 -10
  272. package/src/rpc.ts +158 -0
  273. package/src/server.ts +201 -41
  274. package/src/settings.ts +125 -5
  275. package/src/shared/jobs-view.ts +3 -1
  276. package/src/task-transfer.ts +90 -6
  277. package/src/templates.ts +3 -3
  278. package/src/types.ts +23 -2
  279. package/src/workspaces.ts +37 -14
package/dist/index.d.ts CHANGED
@@ -1,8 +1,11 @@
1
1
  import { Plugin } from "@opencode/plugin";
2
- import { type Hooks as V1Hooks, type PluginInput as V1PluginInput } from "@opencode-ai/plugin";
2
+ import type { Hooks as V1Hooks, PluginInput as V1PluginInput } from "@opencode-ai/plugin";
3
3
  import { z } from "zod";
4
4
  import type { Tool } from "@opencode/schema/tool";
5
+ import { type TaskGuards } from "./core/guard.js";
6
+ import { type ShutdownGateState } from "./core/shutdown.js";
5
7
  import { type LocalAiPatch } from "./core/local-ai.js";
8
+ import type { McpEventTrigger, MatrixConfig, TaskDefinition } from "./task-transfer.js";
6
9
  import type { AuditEntryInput } from "./core/audit.js";
7
10
  /** Per-workspace overrides for matrix clones (Sprint 17). */
8
11
  export declare const matrixOverrideSchema: z.ZodObject<{
@@ -37,6 +40,38 @@ export declare const matrixSchema: z.ZodObject<{
37
40
  afterScript: z.ZodOptional<z.ZodString>;
38
41
  }, z.core.$strip>>>;
39
42
  }, z.core.$strip>;
43
+ /** W-3: guard-условия задачи. */
44
+ export declare const guardsSchema: z.ZodObject<{
45
+ command: z.ZodOptional<z.ZodString>;
46
+ timeoutSeconds: z.ZodOptional<z.ZodNumber>;
47
+ semantic: z.ZodOptional<z.ZodObject<{
48
+ filesExist: z.ZodOptional<z.ZodArray<z.ZodString>>;
49
+ filesMissing: z.ZodOptional<z.ZodArray<z.ZodString>>;
50
+ branch: z.ZodOptional<z.ZodString>;
51
+ changedPaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
52
+ changedSince: z.ZodOptional<z.ZodString>;
53
+ }, z.core.$strip>>;
54
+ }, z.core.$strip>;
55
+ /**
56
+ * QA-P2.1: единая проверка диапазонов для MCP и RPC.
57
+ * Zod-схемы защищают только MCP-путь; RPC (create_task/update_task) принимает
58
+ * сырой JSON и вызывает эту функцию явно, до normalizePriority(), который
59
+ * молча обрезает priority до 0..10.
60
+ * Возвращает текст ошибки или null.
61
+ */
62
+ export declare function validateTaskInputRanges(input: {
63
+ prompt?: string;
64
+ timeoutSeconds?: number;
65
+ priority?: number;
66
+ retryCount?: number;
67
+ retryDelay?: number;
68
+ watchPath?: string;
69
+ triggerType?: string;
70
+ watchGlobs?: string[];
71
+ watchIgnore?: string[];
72
+ gitPaths?: string[];
73
+ gitIgnore?: string[];
74
+ }): string | null;
40
75
  /** Zod-схема аргументов schedule_task */
41
76
  export declare const scheduleTaskSchema: z.ZodObject<{
42
77
  name: z.ZodString;
@@ -73,7 +108,8 @@ export declare const scheduleTaskSchema: z.ZodObject<{
73
108
  }>>;
74
109
  mcpEvent: z.ZodOptional<z.ZodObject<{
75
110
  server: z.ZodString;
76
- event: z.ZodString;
111
+ event: z.ZodOptional<z.ZodString>;
112
+ eventName: z.ZodOptional<z.ZodString>;
77
113
  filter: z.ZodOptional<z.ZodString>;
78
114
  }, z.core.$strip>>;
79
115
  watchPath: z.ZodOptional<z.ZodString>;
@@ -95,6 +131,19 @@ export declare const scheduleTaskSchema: z.ZodObject<{
95
131
  deniedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
96
132
  legacyShell: z.ZodOptional<z.ZodBoolean>;
97
133
  runWhenLoggedOff: z.ZodOptional<z.ZodBoolean>;
134
+ worktree: z.ZodOptional<z.ZodBoolean>;
135
+ guards: z.ZodOptional<z.ZodObject<{
136
+ command: z.ZodOptional<z.ZodString>;
137
+ timeoutSeconds: z.ZodOptional<z.ZodNumber>;
138
+ semantic: z.ZodOptional<z.ZodObject<{
139
+ filesExist: z.ZodOptional<z.ZodArray<z.ZodString>>;
140
+ filesMissing: z.ZodOptional<z.ZodArray<z.ZodString>>;
141
+ branch: z.ZodOptional<z.ZodString>;
142
+ changedPaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
143
+ changedSince: z.ZodOptional<z.ZodString>;
144
+ }, z.core.$strip>>;
145
+ }, z.core.$strip>>;
146
+ tokenBudget: z.ZodOptional<z.ZodNumber>;
98
147
  matrix: z.ZodOptional<z.ZodObject<{
99
148
  workspaceIds: z.ZodArray<z.ZodString>;
100
149
  strategy: z.ZodOptional<z.ZodEnum<{
@@ -168,7 +217,8 @@ export declare const updateTaskSchema: z.ZodObject<{
168
217
  }>>;
169
218
  mcpEvent: z.ZodOptional<z.ZodObject<{
170
219
  server: z.ZodString;
171
- event: z.ZodString;
220
+ event: z.ZodOptional<z.ZodString>;
221
+ eventName: z.ZodOptional<z.ZodString>;
172
222
  filter: z.ZodOptional<z.ZodString>;
173
223
  }, z.core.$strip>>;
174
224
  watchPath: z.ZodOptional<z.ZodString>;
@@ -177,6 +227,19 @@ export declare const updateTaskSchema: z.ZodObject<{
177
227
  allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
178
228
  deniedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
179
229
  legacyShell: z.ZodOptional<z.ZodBoolean>;
230
+ worktree: z.ZodOptional<z.ZodBoolean>;
231
+ guards: z.ZodOptional<z.ZodObject<{
232
+ command: z.ZodOptional<z.ZodString>;
233
+ timeoutSeconds: z.ZodOptional<z.ZodNumber>;
234
+ semantic: z.ZodOptional<z.ZodObject<{
235
+ filesExist: z.ZodOptional<z.ZodArray<z.ZodString>>;
236
+ filesMissing: z.ZodOptional<z.ZodArray<z.ZodString>>;
237
+ branch: z.ZodOptional<z.ZodString>;
238
+ changedPaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
239
+ changedSince: z.ZodOptional<z.ZodString>;
240
+ }, z.core.$strip>>;
241
+ }, z.core.$strip>>;
242
+ tokenBudget: z.ZodOptional<z.ZodNumber>;
180
243
  matrix: z.ZodOptional<z.ZodNullable<z.ZodObject<{
181
244
  workspaceIds: z.ZodArray<z.ZodString>;
182
245
  strategy: z.ZodOptional<z.ZodEnum<{
@@ -202,10 +265,34 @@ export declare const updateTaskSchema: z.ZodObject<{
202
265
  }, z.core.$strip>>>;
203
266
  }, z.core.$strip>>>;
204
267
  }, z.core.$strip>;
268
+ export declare const getTaskLogsSchema: z.ZodObject<{
269
+ name: z.ZodOptional<z.ZodString>;
270
+ taskName: z.ZodOptional<z.ZodString>;
271
+ lines: z.ZodOptional<z.ZodNumber>;
272
+ }, z.core.$strip>;
273
+ /** pipeline_validate — проверить опencode.pipeline.yaml (путь или исходник). */
274
+ export declare const pipelineValidateSchema: z.ZodObject<{
275
+ path: z.ZodOptional<z.ZodString>;
276
+ source: z.ZodOptional<z.ZodString>;
277
+ workingDirectory: z.ZodOptional<z.ZodString>;
278
+ dryRun: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
279
+ }, z.core.$strip>;
280
+ /** pipeline_apply — применить opencode.pipeline.yaml к текущему набору задач. */
281
+ export declare const pipelineApplySchema: z.ZodObject<{
282
+ path: z.ZodOptional<z.ZodString>;
283
+ source: z.ZodOptional<z.ZodString>;
284
+ workingDirectory: z.ZodOptional<z.ZodString>;
285
+ dryRun: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
286
+ }, z.core.$strip>;
287
+ /** pipeline_export — выгрузить задачи конвейера как opencode.pipeline.yaml. */
288
+ export declare const pipelineExportSchema: z.ZodObject<{
289
+ pipeline: z.ZodOptional<z.ZodString>;
290
+ pipelineName: z.ZodOptional<z.ZodString>;
291
+ }, z.core.$strip>;
205
292
  export declare const matrixControlSchema: z.ZodObject<{
206
293
  action: z.ZodEnum<{
207
- preview: "preview";
208
294
  results: "results";
295
+ preview: "preview";
209
296
  cancel: "cancel";
210
297
  cleanup: "cleanup";
211
298
  }>;
@@ -242,6 +329,7 @@ export declare const selfAnalysisSchema: z.ZodObject<{
242
329
  /** manage_settings — глобальные настройки планировщика. */
243
330
  export declare const manageSettingsSchema: z.ZodObject<{
244
331
  action: z.ZodEnum<{
332
+ list: "list";
245
333
  update: "update";
246
334
  get: "get";
247
335
  }>;
@@ -267,6 +355,18 @@ export declare const manageSettingsSchema: z.ZodObject<{
267
355
  legacy: "legacy";
268
356
  }>>;
269
357
  }, z.core.$strip>>;
358
+ budgets: z.ZodOptional<z.ZodObject<{
359
+ enabled: z.ZodOptional<z.ZodBoolean>;
360
+ dailyUsd: z.ZodOptional<z.ZodNumber>;
361
+ weeklyUsd: z.ZodOptional<z.ZodNumber>;
362
+ }, z.core.$strip>>;
363
+ feedback: z.ZodOptional<z.ZodObject<{
364
+ enabled: z.ZodOptional<z.ZodBoolean>;
365
+ endpoint: z.ZodOptional<z.ZodString>;
366
+ includeLogs: z.ZodOptional<z.ZodBoolean>;
367
+ contactEmail: z.ZodOptional<z.ZodString>;
368
+ maxPerHour: z.ZodOptional<z.ZodNumber>;
369
+ }, z.core.$strip>>;
270
370
  }, z.core.$strip>;
271
371
  /** manage_local_ai — настройки локального ассистента и триажа (Спринт 30.7). */
272
372
  export declare const manageLocalAiSchema: z.ZodObject<{
@@ -325,7 +425,8 @@ export declare const manageTemplatesSchema: z.ZodObject<{
325
425
  }>>;
326
426
  mcpEvent: z.ZodOptional<z.ZodObject<{
327
427
  server: z.ZodString;
328
- event: z.ZodString;
428
+ event: z.ZodOptional<z.ZodString>;
429
+ eventName: z.ZodOptional<z.ZodString>;
329
430
  filter: z.ZodOptional<z.ZodString>;
330
431
  }, z.core.$strip>>;
331
432
  watchPath: z.ZodOptional<z.ZodString>;
@@ -355,8 +456,8 @@ export declare const transferTasksSchema: z.ZodObject<{
355
456
  /** send_notification — проверка уведомлений и дайджест. */
356
457
  export declare const sendNotificationSchema: z.ZodObject<{
357
458
  action: z.ZodEnum<{
358
- digest: "digest";
359
459
  test: "test";
460
+ digest: "digest";
360
461
  }>;
361
462
  channel: z.ZodOptional<z.ZodEnum<{
362
463
  webhook: "webhook";
@@ -365,6 +466,26 @@ export declare const sendNotificationSchema: z.ZodObject<{
365
466
  all: "all";
366
467
  }>>;
367
468
  }, z.core.$strip>;
469
+ /** report_bug — отчёт о баге; по умолчанию уходит автору через приёмник F-2 (Деталь 3.8). */
470
+ export declare const reportBugSchema: z.ZodObject<{
471
+ description: z.ZodString;
472
+ taskName: z.ZodOptional<z.ZodString>;
473
+ includeLogs: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
474
+ includeAnalytics: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
475
+ channel: z.ZodOptional<z.ZodEnum<{
476
+ webhook: "webhook";
477
+ telegram: "telegram";
478
+ native: "native";
479
+ all: "all";
480
+ }>>;
481
+ destination: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
482
+ author: "author";
483
+ local: "local";
484
+ both: "both";
485
+ }>>>;
486
+ contactEmail: z.ZodOptional<z.ZodString>;
487
+ dryRun: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
488
+ }, z.core.$strip>;
368
489
  /** get_dashboard_info — сведения о панели управления. */
369
490
  export declare const getDashboardInfoSchema: z.ZodObject<{}, z.core.$strip>;
370
491
  /** cleanup_history — удаление старой истории. */
@@ -376,6 +497,7 @@ export declare const cleanupHistorySchema: z.ZodObject<{
376
497
  export declare const emitEventSchema: z.ZodObject<{
377
498
  eventName: z.ZodString;
378
499
  payload: z.ZodOptional<z.ZodAny>;
500
+ server: z.ZodOptional<z.ZodString>;
379
501
  }, z.core.$strip>;
380
502
  /** manage_secrets — зашифрованное хранилище секретов (Спринт 26). */
381
503
  export declare const manageSecretsSchema: z.ZodObject<{
@@ -396,6 +518,13 @@ export declare const getAuditLogSchema: z.ZodObject<{
396
518
  until: z.ZodOptional<z.ZodString>;
397
519
  limit: z.ZodOptional<z.ZodNumber>;
398
520
  }, z.core.$strip>;
521
+ /**
522
+ * Общий контекст execute-обработчиков. Обработчики не читают поля контекста,
523
+ * а контексты V1 и V2 устроены по-разному, поэтому на границе адаптеров он
524
+ * сводится к `unknown`. Это позволяет не тащить `Tool.Context` из
525
+ * @opencode/schema/tool в общий контракт инструментов.
526
+ */
527
+ type ToolExecuteContext = unknown;
399
528
  /** schedule_task — создаёт задачу в schtasks через общий schedulerCreateTask. */
400
529
  declare const scheduleTaskExecute: (input: {
401
530
  name: string;
@@ -422,7 +551,8 @@ declare const scheduleTaskExecute: (input: {
422
551
  triggerType?: "cron" | "file" | "git" | "mcp-event" | "once" | undefined;
423
552
  mcpEvent?: {
424
553
  server: string;
425
- event: string;
554
+ event?: string | undefined;
555
+ eventName?: string | undefined;
426
556
  filter?: string | undefined;
427
557
  } | undefined;
428
558
  watchPath?: string | undefined;
@@ -440,6 +570,19 @@ declare const scheduleTaskExecute: (input: {
440
570
  deniedTools?: string[] | undefined;
441
571
  legacyShell?: boolean | undefined;
442
572
  runWhenLoggedOff?: boolean | undefined;
573
+ worktree?: boolean | undefined;
574
+ guards?: {
575
+ command?: string | undefined;
576
+ timeoutSeconds?: number | undefined;
577
+ semantic?: {
578
+ filesExist?: string[] | undefined;
579
+ filesMissing?: string[] | undefined;
580
+ branch?: string | undefined;
581
+ changedPaths?: string[] | undefined;
582
+ changedSince?: string | undefined;
583
+ } | undefined;
584
+ } | undefined;
585
+ tokenBudget?: number | undefined;
443
586
  matrix?: {
444
587
  workspaceIds: string[];
445
588
  strategy?: "parallel" | "sequential" | undefined;
@@ -455,17 +598,17 @@ declare const scheduleTaskExecute: (input: {
455
598
  afterScript?: string | undefined;
456
599
  }> | undefined;
457
600
  } | undefined;
458
- }, context: Tool.Context) => Promise<Tool.Result>;
601
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
459
602
  /** list_tasks — список задач плагина (та же логика, что и у get_tasks). */
460
- declare const listTasksExecute: (input: Record<string, never>, context: Tool.Context) => Promise<Tool.Result>;
603
+ declare const listTasksExecute: (input: Record<string, never>, context: ToolExecuteContext) => Promise<Tool.Result>;
461
604
  /** delete_task — удаление задачи по имени (/f) */
462
605
  declare const deleteTaskExecute: (input: {
463
606
  name: string;
464
- }, context: Tool.Context) => Promise<Tool.Result>;
607
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
465
608
  /** run_task_now — немедленный запуск задачи */
466
609
  declare const runTaskNowExecute: (input: {
467
610
  name: string;
468
- }, context: Tool.Context) => Promise<Tool.Result>;
611
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
469
612
  /** update_task — частичное обновление существующей задачи. */
470
613
  declare const updateTaskExecute: (input: {
471
614
  name: string;
@@ -501,7 +644,8 @@ declare const updateTaskExecute: (input: {
501
644
  triggerType?: "cron" | "file" | "git" | "mcp-event" | "once" | undefined;
502
645
  mcpEvent?: {
503
646
  server: string;
504
- event: string;
647
+ event?: string | undefined;
648
+ eventName?: string | undefined;
505
649
  filter?: string | undefined;
506
650
  } | undefined;
507
651
  watchPath?: string | undefined;
@@ -510,6 +654,19 @@ declare const updateTaskExecute: (input: {
510
654
  allowedTools?: string[] | undefined;
511
655
  deniedTools?: string[] | undefined;
512
656
  legacyShell?: boolean | undefined;
657
+ worktree?: boolean | undefined;
658
+ guards?: {
659
+ command?: string | undefined;
660
+ timeoutSeconds?: number | undefined;
661
+ semantic?: {
662
+ filesExist?: string[] | undefined;
663
+ filesMissing?: string[] | undefined;
664
+ branch?: string | undefined;
665
+ changedPaths?: string[] | undefined;
666
+ changedSince?: string | undefined;
667
+ } | undefined;
668
+ } | undefined;
669
+ tokenBudget?: number | undefined;
513
670
  matrix?: {
514
671
  workspaceIds: string[];
515
672
  strategy?: "parallel" | "sequential" | undefined;
@@ -525,29 +682,49 @@ declare const updateTaskExecute: (input: {
525
682
  afterScript?: string | undefined;
526
683
  }> | undefined;
527
684
  } | null | undefined;
528
- }, context: Tool.Context) => Promise<Tool.Result>;
685
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
529
686
  declare const pauseTaskExecute: (input: {
530
687
  name: string;
531
688
  until?: string | undefined;
532
- }, context: Tool.Context) => Promise<Tool.Result>;
689
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
533
690
  declare const resumeTaskExecute: (input: {
534
691
  name: string;
535
- }, context: Tool.Context) => Promise<Tool.Result>;
692
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
536
693
  /** get_history — история запусков с фильтрами по задаче и статусу. */
537
694
  declare const getHistoryExecute: (input: {
538
695
  taskName?: string | undefined;
539
- status?: "error" | "running" | "partial" | "success" | "timeout" | undefined;
696
+ status?: "error" | "running" | "success" | "partial" | "timeout" | undefined;
540
697
  limit?: number | undefined;
541
- }, context: Tool.Context) => Promise<Tool.Result>;
698
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
542
699
  /** get_task_logs — последние строки лога задачи. */
543
700
  declare const getTaskLogsExecute: (input: {
544
- name: string;
701
+ name?: string | undefined;
702
+ taskName?: string | undefined;
545
703
  lines?: number | undefined;
546
- }, context: Tool.Context) => Promise<Tool.Result>;
704
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
547
705
  /** dry_run — симуляция пайплайна без выполнения. */
548
706
  declare const dryRunExecute: (input: {
549
707
  name?: string | undefined;
550
- }, context: Tool.Context) => Promise<Tool.Result>;
708
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
709
+ /** pipeline_validate — проверить opencode.pipeline.yaml (путь или исходник). */
710
+ declare const pipelineValidateExecute: (input: {
711
+ dryRun: boolean;
712
+ path?: string | undefined;
713
+ source?: string | undefined;
714
+ workingDirectory?: string | undefined;
715
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
716
+ /** pipeline_apply — применить opencode.pipeline.yaml к текущему набору задач. */
717
+ declare const pipelineApplyExecute: (input: {
718
+ dryRun: boolean;
719
+ path?: string | undefined;
720
+ source?: string | undefined;
721
+ workingDirectory?: string | undefined;
722
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
723
+ /** pipeline_export — выгрузить задачи конвейера как opencode.pipeline.yaml. */
724
+ declare const pipelineExportExecute: (input: {
725
+ pipeline?: string | undefined;
726
+ pipelineName?: string | undefined;
727
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
551
728
  /** manage_workspaces — CRUD multi-repo workspace-ов. */
552
729
  declare const manageWorkspacesExecute: (input: {
553
730
  action: "delete" | "list" | "add" | "update";
@@ -557,23 +734,23 @@ declare const manageWorkspacesExecute: (input: {
557
734
  color?: string | undefined;
558
735
  env?: Record<string, string> | null | undefined;
559
736
  envFile?: string | null | undefined;
560
- }, context: Tool.Context) => Promise<Tool.Result>;
737
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
561
738
  /** matrix_control — результаты, отмена, очистка и предпросмотр матриц. */
562
739
  declare const matrixControlExecute: (input: {
563
- action: "preview" | "results" | "cancel" | "cleanup";
740
+ action: "results" | "preview" | "cancel" | "cleanup";
564
741
  name?: string | undefined;
565
742
  workspaceIds?: string[] | undefined;
566
743
  strategy?: "parallel" | "sequential" | undefined;
567
744
  failureMode?: "continue" | "stop" | undefined;
568
745
  aggregation?: "summary" | "per-task" | undefined;
569
- }, context: Tool.Context) => Promise<Tool.Result>;
746
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
570
747
  /** get_metrics — суммарная статистика запусков. */
571
- declare const getMetricsExecute: (input: Record<string, never>, context: Tool.Context) => Promise<Tool.Result>;
748
+ declare const getMetricsExecute: (input: Record<string, never>, context: ToolExecuteContext) => Promise<Tool.Result>;
572
749
  /** get_analytics — аналитика запусков и стоимости за период. */
573
750
  declare const getAnalyticsExecute: (input: {
574
751
  days?: number | undefined;
575
752
  topLimit?: number | undefined;
576
- }, context: Tool.Context) => Promise<Tool.Result>;
753
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
577
754
  /** self_analysis — система самоанализа: здоровье, аномалии, тренды, рекомендации. */
578
755
  declare const selfAnalysisExecute: (input: {
579
756
  days?: number | undefined;
@@ -581,10 +758,10 @@ declare const selfAnalysisExecute: (input: {
581
758
  includeAnomalies?: boolean | undefined;
582
759
  includeTrends?: boolean | undefined;
583
760
  includeRecommendations?: boolean | undefined;
584
- }, context: Tool.Context) => Promise<Tool.Result>;
761
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
585
762
  /** manage_settings — чтение и изменение глобальных настроек. */
586
763
  declare const manageSettingsExecute: (input: {
587
- action: "update" | "get";
764
+ action: "list" | "update" | "get";
588
765
  maxConcurrent?: number | undefined;
589
766
  locale?: "ru" | "en" | "zh" | "auto" | undefined;
590
767
  winterMode?: boolean | undefined;
@@ -598,7 +775,19 @@ declare const manageSettingsExecute: (input: {
598
775
  permissions?: {
599
776
  defaultPolicy?: "hybrid" | "secure" | "legacy" | undefined;
600
777
  } | undefined;
601
- }, context: Tool.Context) => Promise<Tool.Result>;
778
+ budgets?: {
779
+ enabled?: boolean | undefined;
780
+ dailyUsd?: number | undefined;
781
+ weeklyUsd?: number | undefined;
782
+ } | undefined;
783
+ feedback?: {
784
+ enabled?: boolean | undefined;
785
+ endpoint?: string | undefined;
786
+ includeLogs?: boolean | undefined;
787
+ contactEmail?: string | undefined;
788
+ maxPerHour?: number | undefined;
789
+ } | undefined;
790
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
602
791
  /** Один классификационный запрос — общий путь для инструмента и GUI. */
603
792
  export declare function runLocalAiTest(patch?: LocalAiPatch): Promise<{
604
793
  success: boolean;
@@ -628,7 +817,7 @@ declare const manageLocalAiExecute: (input: {
628
817
  days?: number | undefined;
629
818
  startedAt?: string | null | undefined;
630
819
  } | undefined;
631
- }, context: Tool.Context) => Promise<Tool.Result>;
820
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
632
821
  /** manage_templates — список, сохранение и удаление шаблонов задач. */
633
822
  declare const manageTemplatesExecute: (input: {
634
823
  action: "delete" | "list" | "save";
@@ -650,48 +839,82 @@ declare const manageTemplatesExecute: (input: {
650
839
  triggerType?: "cron" | "file" | "mcp-event" | undefined;
651
840
  mcpEvent?: {
652
841
  server: string;
653
- event: string;
842
+ event?: string | undefined;
843
+ eventName?: string | undefined;
654
844
  filter?: string | undefined;
655
845
  } | undefined;
656
846
  watchPath?: string | undefined;
657
847
  workingDirectory?: string | undefined;
658
848
  allowedTools?: string[] | undefined;
659
849
  deniedTools?: string[] | undefined;
660
- }, context: Tool.Context) => Promise<Tool.Result>;
850
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
661
851
  /** manage_profiles — список, создание, переключение и удаление профилей. */
662
852
  declare const manageProfilesExecute: (input: {
663
853
  action: "delete" | "list" | "create" | "switch";
664
854
  name?: string | undefined;
665
855
  port?: number | undefined;
666
- }, context: Tool.Context) => Promise<Tool.Result>;
856
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
667
857
  /** transfer_tasks — экспорт и импорт задач. */
668
858
  declare const transferTasksExecute: (input: {
669
859
  action: "export" | "import";
670
860
  data?: string | undefined;
671
- }, context: Tool.Context) => Promise<Tool.Result>;
861
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
672
862
  /** send_notification — тестовое уведомление или дайджест. */
673
863
  declare const sendNotificationExecute: (input: {
674
- action: "digest" | "test";
864
+ action: "test" | "digest";
675
865
  channel?: "webhook" | "telegram" | "native" | "all" | undefined;
676
- }, context: Tool.Context) => Promise<Tool.Result>;
866
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
867
+ /** report_bug — отчёт о баге; по умолчанию уходит автору через приёмник F-2. */
868
+ declare const reportBugExecute: (input: {
869
+ description: string;
870
+ includeLogs: boolean;
871
+ includeAnalytics: boolean;
872
+ destination: "author" | "local" | "both";
873
+ dryRun: boolean;
874
+ taskName?: string | undefined;
875
+ channel?: "webhook" | "telegram" | "native" | "all" | undefined;
876
+ contactEmail?: string | undefined;
877
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
677
878
  /** get_dashboard_info — порт дашборда, платформа и активный профиль. */
678
- declare const getDashboardInfoExecute: (input: Record<string, never>, context: Tool.Context) => Promise<Tool.Result>;
879
+ declare const getDashboardInfoExecute: (input: Record<string, never>, context: ToolExecuteContext) => Promise<Tool.Result>;
679
880
  /** cleanup_history — удаление старых записей истории. */
680
881
  declare const cleanupHistoryExecute: (input: {
681
882
  retentionDays?: number | undefined;
682
883
  maxRecords?: number | undefined;
683
- }, context: Tool.Context) => Promise<Tool.Result>;
884
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
885
+ /** PL-35: единый обработчик события для агентского инструмента и RPC/GUI. */
886
+ type EmitEventCode = "no_subscribers" | "start_failed" | "ok";
887
+ interface EmitEventResult {
888
+ success: boolean;
889
+ code: EmitEventCode;
890
+ event: string;
891
+ matched: string[];
892
+ triggered: string[];
893
+ failed: {
894
+ name: string;
895
+ error: string;
896
+ }[];
897
+ message: string;
898
+ }
899
+ /**
900
+ * QV-3: проверка, что задача подписана на MCP-событие. Источник `server`
901
+ * сравнивается только когда он передан вызывающим — это сохраняет обратную
902
+ * совместимость со старыми вызовами emit_event без указания источника.
903
+ */
904
+ export declare function matchesMcpEventSubscription(def: TaskDefinition, event: string, server?: string, payload?: unknown): boolean;
905
+ export declare function emitEventCore(rawEventName: string | undefined, payload: unknown, server?: string): Promise<EmitEventResult>;
684
906
  /** emit_event — запуск задач, подписанных на MCP-событие. */
685
907
  declare const emitEventExecute: (input: {
686
908
  eventName: string;
687
909
  payload?: any;
688
- }, context: Tool.Context) => Promise<Tool.Result>;
910
+ server?: string | undefined;
911
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
689
912
  /** manage_secrets — зашифрованное хранилище секретов. */
690
913
  declare const manageSecretsExecute: (input: {
691
914
  action: "delete" | "list" | "set";
692
915
  name?: string | undefined;
693
916
  value?: string | undefined;
694
- }, context: Tool.Context) => Promise<Tool.Result>;
917
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
695
918
  /** get_audit_log — чтение журнала мутаций. */
696
919
  declare const getAuditLogExecute: (input: {
697
920
  action?: string | undefined;
@@ -700,7 +923,7 @@ declare const getAuditLogExecute: (input: {
700
923
  since?: string | undefined;
701
924
  until?: string | undefined;
702
925
  limit?: number | undefined;
703
- }, context: Tool.Context) => Promise<Tool.Result>;
926
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
704
927
  /**
705
928
  * Минимальный контракт контекста, который нужен общему ядру.
706
929
  * V2 передаёт сюда setup-контекст, V1 — контекст из `server()`.
@@ -741,6 +964,9 @@ export interface ToolHandlers {
741
964
  get_history: typeof getHistoryExecute;
742
965
  get_task_logs: typeof getTaskLogsExecute;
743
966
  dry_run: typeof dryRunExecute;
967
+ pipeline_validate: typeof pipelineValidateExecute;
968
+ pipeline_apply: typeof pipelineApplyExecute;
969
+ pipeline_export: typeof pipelineExportExecute;
744
970
  manage_workspaces: typeof manageWorkspacesExecute;
745
971
  matrix_control: typeof matrixControlExecute;
746
972
  get_metrics: typeof getMetricsExecute;
@@ -752,6 +978,7 @@ export interface ToolHandlers {
752
978
  manage_profiles: typeof manageProfilesExecute;
753
979
  transfer_tasks: typeof transferTasksExecute;
754
980
  send_notification: typeof sendNotificationExecute;
981
+ report_bug: typeof reportBugExecute;
755
982
  get_dashboard_info: typeof getDashboardInfoExecute;
756
983
  cleanup_history: typeof cleanupHistoryExecute;
757
984
  emit_event: typeof emitEventExecute;
@@ -784,13 +1011,27 @@ export declare function createShutdownHandler(runtime: SchedulerRuntime, registr
784
1011
  * Декларативное описание инструмента: всё, что нужно любому entrypoint'у,
785
1012
  * чтобы зарегистрировать его в своей версии API.
786
1013
  */
1014
+ /**
1015
+ * Бивариантные сигнатуры (паттерн `bivarianceHack`). Типизированные
1016
+ * обработчики из `ToolHandlers` принимают конкретные `z.infer`-аргументы,
1017
+ * а реестр хранит их как `unknown`: вход проверен Zod-схемой инструмента
1018
+ * до вызова, поэтому приведение типов здесь не требуется.
1019
+ */
1020
+ type ToolSpecExecute = {
1021
+ bivarianceHack(args: unknown, context: ToolExecuteContext): Promise<Tool.Result>;
1022
+ }["bivarianceHack"];
1023
+ type ToolSpecAudit = {
1024
+ bivarianceHack(args: unknown): Omit<AuditEntryInput, "actor"> | null;
1025
+ }["bivarianceHack"];
787
1026
  export interface ToolSpec {
788
1027
  name: string;
789
- input: any;
1028
+ input: z.ZodTypeAny;
1029
+ /** PL-43: схема структурированного output (только V2 Code Mode; V1 использует content). */
1030
+ output?: z.ZodTypeAny;
790
1031
  description: string;
791
- execute: (args: any, context: Tool.Context) => Promise<Tool.Result>;
1032
+ execute: ToolSpecExecute;
792
1033
  /** Правила аудита; null/undefined — операция не пишется в журнал. */
793
- audit?: (args: any) => Omit<AuditEntryInput, "actor"> | null;
1034
+ audit?: ToolSpecAudit;
794
1035
  }
795
1036
  /**
796
1037
  * Собирает полный список инструментов для конкретного ядра.
@@ -799,23 +1040,38 @@ export interface ToolSpec {
799
1040
  * одинаковые имена, схемы, описания и обработчики. Аудит навешивается здесь
800
1041
  * один раз, чтобы обе линии вели журнал одинаково.
801
1042
  */
802
- export declare function createToolSpecs(runtime: SchedulerRuntime): ToolSpec[];
1043
+ export declare function createToolSpecs(runtime: SchedulerRuntime, env?: NodeJS.ProcessEnv): ToolSpec[];
803
1044
  /**
804
1045
  * Приводит результат V2-обработчика (`Tool.Result`) к формату V1 (`ToolResult`).
805
1046
  * V1 ждёт строку или `{ output, metadata }`; V2 отдаёт `{ content }`.
806
1047
  */
807
- export declare function toV1ToolResult(result: any): any;
1048
+ type V1ToolResult = string | {
1049
+ output: string;
1050
+ metadata?: Tool.Result["metadata"];
1051
+ };
1052
+ export declare function toV1ToolResult(result: Tool.Result | string): V1ToolResult;
808
1053
  /**
809
1054
  * V1 `tool()` принимает `z.ZodRawShape`, а спецификации хранят `z.object(...)`.
810
1055
  * Возвращаем именно shape, чтобы V1 не получил готовый объект схемы.
811
1056
  */
812
- export declare function toV1ToolArgs(spec: ToolSpec): Record<string, any>;
1057
+ export declare function toV1ToolArgs(spec: ToolSpec): z.ZodRawShape;
813
1058
  /**
814
1059
  * V1-реестр инструментов: те же имена, описания, схемы и обработчики, что в
815
1060
  * V2, плюс тот же аудит. Отличие одно — у V1 `tool()` нет `codemode`, поэтому
816
1061
  * флаг не передаётся (см. docs/COMPATIBILITY.md).
817
1062
  */
818
- export declare function createV1Tools(runtime: SchedulerRuntime): Record<string, any>;
1063
+ /**
1064
+ * Локальное описание V1-реестра. V1-плагин тянет свою копию zod (4.1.8),
1065
+ * поэтому его `ToolDefinition` структурно несовместим с нашим zod (4.6.7).
1066
+ * Приведение типов делается один раз на границе `createV1Hooks`.
1067
+ */
1068
+ interface V1ToolDefinition {
1069
+ description: string;
1070
+ args: z.ZodRawShape;
1071
+ execute(args: unknown, context: unknown): Promise<V1ToolResult>;
1072
+ }
1073
+ type V1ToolRegistry = Record<string, V1ToolDefinition>;
1074
+ export declare function createV1Tools(runtime: SchedulerRuntime): V1ToolRegistry;
819
1075
  /**
820
1076
  * V1-entrypoint (OpenCode 1.x): module contract `{ id?, server }`.
821
1077
  *
@@ -855,4 +1111,76 @@ export interface TriggerExtras {
855
1111
  gitIgnore?: string[];
856
1112
  gitPollSeconds?: number;
857
1113
  }
1114
+ /**
1115
+ * PL-42: вход нормализации mcpEvent. `eventName` — алиас `event`, который
1116
+ * присылает `emit_event`; оба поля необязательны, но хотя бы одно нужно
1117
+ * для triggerType=mcp-event (проверяется после нормализации).
1118
+ */
1119
+ interface McpEventInput {
1120
+ server?: string;
1121
+ /** Каноническое имя события. Приоритетнее алиаса. */
1122
+ event?: string;
1123
+ /** Алиас emit_event; используется, только если event пуст. */
1124
+ eventName?: string;
1125
+ filter?: string;
1126
+ }
1127
+ /**
1128
+ * PL-42: приводит mcpEvent к каноническому виду `{ server, event, filter? }`.
1129
+ * `event` имеет приоритет: если заданы оба поля и они различаются, alias
1130
+ * `eventName` игнорируется — так поведение старых задач не меняется.
1131
+ */
1132
+ export declare function normalizeMcpEventTrigger(mcpEvent?: McpEventInput): McpEventTrigger | undefined;
1133
+ export declare function schedulerCreateTask(name: string, schedule: string, prompt: string, timeoutSeconds?: number, workingDirectory?: string, retryCount?: number, retryDelay?: number, qualityGate?: string, nextTaskOnSuccess?: string, nextTaskOnError?: string, triggerType?: "cron" | "file" | "git" | "mcp-event" | "once", watchPath?: string, dependsOn?: string[], model?: string, priority?: number, beforeScript?: string, afterScript?: string, mcpEvent?: McpEventInput, workspaceId?: string, allowedTools?: string[], deniedTools?: string[], matrix?: MatrixConfig, matrixParentId?: string,
1134
+ /** create — пересоздать клонов с нуля; sync — только diff (Спринт 17). */
1135
+ matrixMode?: "create" | "sync",
1136
+ /** IANA-зона задачи (Спринт 19). Не системная зона → poll-режим шлюза. */
1137
+ timezone?: string,
1138
+ /** Окно запуска: начало "HH:MM" (вне окна запуск переносится). */
1139
+ notBefore?: string,
1140
+ /** Окончание окна "HH:MM"; может быть меньше notBefore (через полночь). */
1141
+ notAfter?: string,
1142
+ /** Пауза до момента ISO; после него задача возобновляется автоматически. */
1143
+ pausedUntil?: string,
1144
+ /** Абсолютное время однократного запуска (ISO, только triggerType=once). */
1145
+ runAt?: string,
1146
+ /** Режим сессии OpenCode (Спринт 24): new (по умолчанию), reuse, last. */
1147
+ session?: "new" | "reuse" | "last",
1148
+ /** ID сессии для reuse (генерируется автоматически; пользователь не задаёт). */
1149
+ sessionId?: string,
1150
+ /** Сколько запусков переживает reuse-сессия до ротации (0/undefined — без ограничения). */
1151
+ sessionMaxRuns?: number,
1152
+ /** Спринт 27: дни недели, политика окна, glob- и git-фильтры. */
1153
+ triggerExtras?: TriggerExtras,
1154
+ /** Спринт 27.5.4: Windows — запускать без входа пользователя (/ru SYSTEM). */
1155
+ runWhenLoggedOff?: boolean,
1156
+ /**
1157
+ * Спринт 27.5.8: пересоздать задачу сразу отключённой (пауза переживает
1158
+ * update). Для матрицы пауза применяется к клонам.
1159
+ */
1160
+ paused?: boolean,
1161
+ /**
1162
+ * Спринт 32 / релиз 1.6: переходный флаг для гибридной политики.
1163
+ * true возвращает shell задаче, созданной до обновления поведения.
1164
+ */
1165
+ legacyShell?: boolean,
1166
+ /** W-1: одноразовый git worktree на каждый запуск. */
1167
+ worktree?: boolean,
1168
+ /** W-3: guard-условия перед запуском opencode. */
1169
+ guards?: TaskGuards,
1170
+ /** Economics v2 (E-2): per-run token budget. 0/omitted = no limit (fail-open). */
1171
+ tokenBudget?: number): Promise<void>;
1172
+ /**
1173
+ * PL-1.1: структурированная ошибка отказа запуска во время выгрузки плагина.
1174
+ * Текст `message` сохранён дословно для совместимости с существующими
1175
+ * вызывающими; `code` и `hint` дают кнопке повтора/оператору понятный путь.
1176
+ */
1177
+ export declare class PluginShutdownError extends Error {
1178
+ readonly code = "PLUGIN_SHUTTING_DOWN";
1179
+ readonly hint: string;
1180
+ /** PL-10/QV-2: наблюдаемое состояние ворот в момент отказа. */
1181
+ readonly state: ShutdownGateState;
1182
+ /** PL-45: повтор возможен после перерегистрации плагина. */
1183
+ readonly retryable = true;
1184
+ constructor(message: string, hint: string, state: ShutdownGateState);
1185
+ }
858
1186
  //# sourceMappingURL=index.d.ts.map