agent-steward 0.0.5 → 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 (191) hide show
  1. package/CHANGELOG.md +176 -1
  2. package/README.md +9 -7
  3. package/ROADMAP-STRATEGY.md +5 -5
  4. package/ROADMAP.md +107 -17
  5. package/dist/cli.js +5 -0
  6. package/dist/core/analytics.d.ts +6 -0
  7. package/dist/core/analytics.d.ts.map +1 -1
  8. package/dist/core/analytics.js +20 -3
  9. package/dist/core/audit.d.ts +6 -0
  10. package/dist/core/audit.d.ts.map +1 -1
  11. package/dist/core/audit.js +24 -0
  12. package/dist/core/budget.d.ts +118 -0
  13. package/dist/core/budget.d.ts.map +1 -0
  14. package/dist/core/budget.js +206 -0
  15. package/dist/core/cron-to-schtasks.d.ts.map +1 -1
  16. package/dist/core/cron-to-schtasks.js +38 -0
  17. package/dist/core/dry-run.d.ts +26 -1
  18. package/dist/core/dry-run.d.ts.map +1 -1
  19. package/dist/core/dry-run.js +199 -8
  20. package/dist/core/feedback.d.ts +192 -0
  21. package/dist/core/feedback.d.ts.map +1 -0
  22. package/dist/core/feedback.js +426 -0
  23. package/dist/core/gate-integrity.d.ts +36 -0
  24. package/dist/core/gate-integrity.d.ts.map +1 -1
  25. package/dist/core/gate-integrity.js +144 -1
  26. package/dist/core/local-ai.d.ts.map +1 -1
  27. package/dist/core/local-ai.js +7 -3
  28. package/dist/core/matrix.d.ts +8 -0
  29. package/dist/core/matrix.d.ts.map +1 -1
  30. package/dist/core/matrix.js +57 -2
  31. package/dist/core/mission.d.ts +20 -0
  32. package/dist/core/mission.d.ts.map +1 -1
  33. package/dist/core/mission.js +45 -5
  34. package/dist/core/opencode-models.d.ts +2 -2
  35. package/dist/core/opencode-models.d.ts.map +1 -1
  36. package/dist/core/opencode-models.js +28 -21
  37. package/dist/core/opencode-usage.d.ts +35 -0
  38. package/dist/core/opencode-usage.d.ts.map +1 -0
  39. package/dist/core/opencode-usage.js +132 -0
  40. package/dist/core/pipeline-io.d.ts +1 -1
  41. package/dist/core/pipeline-io.d.ts.map +1 -1
  42. package/dist/core/pipeline-io.js +26 -12
  43. package/dist/core/pipeline-map.d.ts +6 -0
  44. package/dist/core/pipeline-map.d.ts.map +1 -1
  45. package/dist/core/pipeline-map.js +12 -0
  46. package/dist/core/ps-wrapper.d.ts +10 -2
  47. package/dist/core/ps-wrapper.d.ts.map +1 -1
  48. package/dist/core/ps-wrapper.js +176 -5
  49. package/dist/core/record-history.d.ts.map +1 -1
  50. package/dist/core/record-history.js +76 -4
  51. package/dist/core/run-mode.d.ts +12 -0
  52. package/dist/core/run-mode.d.ts.map +1 -0
  53. package/dist/core/run-mode.js +17 -0
  54. package/dist/core/scheduler/logs.d.ts +4 -0
  55. package/dist/core/scheduler/logs.d.ts.map +1 -1
  56. package/dist/core/scheduler/logs.js +25 -1
  57. package/dist/core/secrets.d.ts.map +1 -1
  58. package/dist/core/secrets.js +18 -8
  59. package/dist/core/self-analysis.d.ts +32 -2
  60. package/dist/core/self-analysis.d.ts.map +1 -1
  61. package/dist/core/self-analysis.js +38 -27
  62. package/dist/core/shutdown.d.ts +33 -2
  63. package/dist/core/shutdown.d.ts.map +1 -1
  64. package/dist/core/shutdown.js +58 -2
  65. package/dist/core/structured-log.d.ts +30 -0
  66. package/dist/core/structured-log.d.ts.map +1 -1
  67. package/dist/core/structured-log.js +37 -0
  68. package/dist/core/usage-surface.d.ts +25 -0
  69. package/dist/core/usage-surface.d.ts.map +1 -0
  70. package/dist/core/usage-surface.js +41 -0
  71. package/dist/core/wrappers/bash.d.ts +2 -0
  72. package/dist/core/wrappers/bash.d.ts.map +1 -1
  73. package/dist/core/wrappers/bash.js +58 -6
  74. package/dist/db/history-repo.d.ts +32 -0
  75. package/dist/db/history-repo.d.ts.map +1 -1
  76. package/dist/db/history-repo.js +85 -7
  77. package/dist/db/metrics-repo.d.ts +20 -2
  78. package/dist/db/metrics-repo.d.ts.map +1 -1
  79. package/dist/db/metrics-repo.js +33 -11
  80. package/dist/db/migrate.d.ts.map +1 -1
  81. package/dist/db/migrate.js +37 -17
  82. package/dist/db/recovery.d.ts +3 -1
  83. package/dist/db/recovery.d.ts.map +1 -1
  84. package/dist/db/recovery.js +9 -4
  85. package/dist/db/runs-repo.d.ts.map +1 -1
  86. package/dist/db/runs-repo.js +71 -56
  87. package/dist/db/schema.d.ts +2 -2
  88. package/dist/db/schema.d.ts.map +1 -1
  89. package/dist/db/schema.js +70 -1
  90. package/dist/db/templates-repo.d.ts +2 -2
  91. package/dist/db/templates-repo.d.ts.map +1 -1
  92. package/dist/db/templates-repo.js +5 -3
  93. package/dist/history.d.ts +6 -1
  94. package/dist/history.d.ts.map +1 -1
  95. package/dist/history.js +4 -2
  96. package/dist/hook-output.d.ts +2 -0
  97. package/dist/hook-output.d.ts.map +1 -0
  98. package/dist/hook-output.js +31 -0
  99. package/dist/index.d.ts +247 -53
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +999 -211
  102. package/dist/notifications.d.ts +31 -2
  103. package/dist/notifications.d.ts.map +1 -1
  104. package/dist/notifications.js +132 -13
  105. package/dist/profiles.d.ts.map +1 -1
  106. package/dist/profiles.js +66 -15
  107. package/dist/rpc.d.ts +108 -0
  108. package/dist/rpc.d.ts.map +1 -1
  109. package/dist/rpc.js +28 -0
  110. package/dist/server.d.ts +17 -2
  111. package/dist/server.d.ts.map +1 -1
  112. package/dist/server.js +77 -12
  113. package/dist/settings.d.ts +42 -0
  114. package/dist/settings.d.ts.map +1 -1
  115. package/dist/settings.js +82 -0
  116. package/dist/task-transfer.d.ts +5 -0
  117. package/dist/task-transfer.d.ts.map +1 -1
  118. package/dist/task-transfer.js +48 -3
  119. package/dist/templates.d.ts +2 -2
  120. package/dist/templates.d.ts.map +1 -1
  121. package/dist/templates.js +3 -3
  122. package/dist/types.d.ts +22 -2
  123. package/dist/types.d.ts.map +1 -1
  124. package/dist/workspaces.d.ts.map +1 -1
  125. package/dist/workspaces.js +34 -11
  126. package/docs/ARCHITECTURE.md +49 -12
  127. package/docs/COMPATIBILITY.md +2 -2
  128. package/docs/EXECUTION-LOOP.md +6 -3
  129. package/docs/FEATURES.md +65 -4
  130. package/docs/FEATURES.zh.md +45 -2
  131. package/docs/QA-A2-GUI-TUI.md +205 -0
  132. package/docs/README.ru.md +3 -3
  133. package/docs/README.zh.md +2 -2
  134. package/gui-experimental.cjs +9 -9
  135. package/locales/en.json +42 -3
  136. package/locales/ru.json +42 -3
  137. package/locales/zh.json +42 -3
  138. package/package.json +15 -2
  139. package/scripts/check-eslint-baseline.mjs +139 -0
  140. package/scripts/gen-test-plan-counters.mjs +117 -0
  141. package/scripts/github-ci-fetch.ps1 +37 -0
  142. package/scripts/pl-commit.ps1 +112 -0
  143. package/scripts/qa-a2-commit.ps1 +104 -0
  144. package/scripts/test-home.mjs +26 -2
  145. package/skills/scheduled-job-best-practices/SKILL.md +95 -1
  146. package/skills/scheduled-job-best-practices/references/recipes.md +139 -0
  147. package/src/cli.ts +5 -0
  148. package/src/core/analytics.ts +27 -4
  149. package/src/core/audit.ts +25 -0
  150. package/src/core/budget.ts +340 -0
  151. package/src/core/cron-to-schtasks.ts +42 -0
  152. package/src/core/dry-run.ts +233 -10
  153. package/src/core/feedback.ts +582 -0
  154. package/src/core/gate-integrity.ts +171 -1
  155. package/src/core/local-ai.ts +7 -3
  156. package/src/core/matrix.ts +63 -2
  157. package/src/core/mission.ts +51 -5
  158. package/src/core/opencode-models.ts +30 -21
  159. package/src/core/opencode-usage.ts +182 -0
  160. package/src/core/pipeline-io.ts +28 -11
  161. package/src/core/pipeline-map.ts +19 -0
  162. package/src/core/ps-wrapper.ts +173 -4
  163. package/src/core/record-history.ts +94 -4
  164. package/src/core/run-mode.ts +19 -0
  165. package/src/core/scheduler/logs.ts +32 -1
  166. package/src/core/secrets.ts +18 -11
  167. package/src/core/self-analysis.ts +75 -29
  168. package/src/core/shutdown.ts +90 -4
  169. package/src/core/structured-log.ts +67 -0
  170. package/src/core/usage-surface.ts +70 -0
  171. package/src/core/wrappers/bash.ts +60 -5
  172. package/src/db/history-repo.ts +153 -19
  173. package/src/db/metrics-repo.ts +38 -11
  174. package/src/db/migrate.ts +57 -32
  175. package/src/db/recovery.ts +10 -4
  176. package/src/db/runs-repo.ts +113 -61
  177. package/src/db/schema.ts +70 -1
  178. package/src/db/templates-repo.ts +5 -3
  179. package/src/gui.tsx +261 -5
  180. package/src/history.ts +10 -3
  181. package/src/hook-output.ts +39 -0
  182. package/src/index.ts +1407 -345
  183. package/src/notifications.ts +189 -39
  184. package/src/profiles.ts +72 -16
  185. package/src/rpc.ts +30 -0
  186. package/src/server.ts +107 -23
  187. package/src/settings.ts +120 -0
  188. package/src/task-transfer.ts +59 -6
  189. package/src/templates.ts +3 -3
  190. package/src/types.ts +23 -2
  191. package/src/workspaces.ts +37 -14
package/dist/index.d.ts CHANGED
@@ -1,10 +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
5
  import { type TaskGuards } from "./core/guard.js";
6
+ import { type ShutdownGateState } from "./core/shutdown.js";
6
7
  import { type LocalAiPatch } from "./core/local-ai.js";
7
- import type { McpEventTrigger, MatrixConfig } from "./task-transfer.js";
8
+ import type { McpEventTrigger, MatrixConfig, TaskDefinition } from "./task-transfer.js";
8
9
  import type { AuditEntryInput } from "./core/audit.js";
9
10
  /** Per-workspace overrides for matrix clones (Sprint 17). */
10
11
  export declare const matrixOverrideSchema: z.ZodObject<{
@@ -51,6 +52,26 @@ export declare const guardsSchema: z.ZodObject<{
51
52
  changedSince: z.ZodOptional<z.ZodString>;
52
53
  }, z.core.$strip>>;
53
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;
54
75
  /** Zod-схема аргументов schedule_task */
55
76
  export declare const scheduleTaskSchema: z.ZodObject<{
56
77
  name: z.ZodString;
@@ -87,7 +108,8 @@ export declare const scheduleTaskSchema: z.ZodObject<{
87
108
  }>>;
88
109
  mcpEvent: z.ZodOptional<z.ZodObject<{
89
110
  server: z.ZodString;
90
- event: z.ZodString;
111
+ event: z.ZodOptional<z.ZodString>;
112
+ eventName: z.ZodOptional<z.ZodString>;
91
113
  filter: z.ZodOptional<z.ZodString>;
92
114
  }, z.core.$strip>>;
93
115
  watchPath: z.ZodOptional<z.ZodString>;
@@ -121,6 +143,7 @@ export declare const scheduleTaskSchema: z.ZodObject<{
121
143
  changedSince: z.ZodOptional<z.ZodString>;
122
144
  }, z.core.$strip>>;
123
145
  }, z.core.$strip>>;
146
+ tokenBudget: z.ZodOptional<z.ZodNumber>;
124
147
  matrix: z.ZodOptional<z.ZodObject<{
125
148
  workspaceIds: z.ZodArray<z.ZodString>;
126
149
  strategy: z.ZodOptional<z.ZodEnum<{
@@ -194,7 +217,8 @@ export declare const updateTaskSchema: z.ZodObject<{
194
217
  }>>;
195
218
  mcpEvent: z.ZodOptional<z.ZodObject<{
196
219
  server: z.ZodString;
197
- event: z.ZodString;
220
+ event: z.ZodOptional<z.ZodString>;
221
+ eventName: z.ZodOptional<z.ZodString>;
198
222
  filter: z.ZodOptional<z.ZodString>;
199
223
  }, z.core.$strip>>;
200
224
  watchPath: z.ZodOptional<z.ZodString>;
@@ -215,6 +239,7 @@ export declare const updateTaskSchema: z.ZodObject<{
215
239
  changedSince: z.ZodOptional<z.ZodString>;
216
240
  }, z.core.$strip>>;
217
241
  }, z.core.$strip>>;
242
+ tokenBudget: z.ZodOptional<z.ZodNumber>;
218
243
  matrix: z.ZodOptional<z.ZodNullable<z.ZodObject<{
219
244
  workspaceIds: z.ZodArray<z.ZodString>;
220
245
  strategy: z.ZodOptional<z.ZodEnum<{
@@ -240,26 +265,34 @@ export declare const updateTaskSchema: z.ZodObject<{
240
265
  }, z.core.$strip>>>;
241
266
  }, z.core.$strip>>>;
242
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>;
243
273
  /** pipeline_validate — проверить опencode.pipeline.yaml (путь или исходник). */
244
274
  export declare const pipelineValidateSchema: z.ZodObject<{
245
275
  path: z.ZodOptional<z.ZodString>;
246
276
  source: z.ZodOptional<z.ZodString>;
277
+ workingDirectory: z.ZodOptional<z.ZodString>;
247
278
  dryRun: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
248
279
  }, z.core.$strip>;
249
280
  /** pipeline_apply — применить opencode.pipeline.yaml к текущему набору задач. */
250
281
  export declare const pipelineApplySchema: z.ZodObject<{
251
282
  path: z.ZodOptional<z.ZodString>;
252
283
  source: z.ZodOptional<z.ZodString>;
284
+ workingDirectory: z.ZodOptional<z.ZodString>;
253
285
  dryRun: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
254
286
  }, z.core.$strip>;
255
287
  /** pipeline_export — выгрузить задачи конвейера как opencode.pipeline.yaml. */
256
288
  export declare const pipelineExportSchema: z.ZodObject<{
257
- pipeline: z.ZodString;
289
+ pipeline: z.ZodOptional<z.ZodString>;
290
+ pipelineName: z.ZodOptional<z.ZodString>;
258
291
  }, z.core.$strip>;
259
292
  export declare const matrixControlSchema: z.ZodObject<{
260
293
  action: z.ZodEnum<{
261
- preview: "preview";
262
294
  results: "results";
295
+ preview: "preview";
263
296
  cancel: "cancel";
264
297
  cleanup: "cleanup";
265
298
  }>;
@@ -296,6 +329,7 @@ export declare const selfAnalysisSchema: z.ZodObject<{
296
329
  /** manage_settings — глобальные настройки планировщика. */
297
330
  export declare const manageSettingsSchema: z.ZodObject<{
298
331
  action: z.ZodEnum<{
332
+ list: "list";
299
333
  update: "update";
300
334
  get: "get";
301
335
  }>;
@@ -321,6 +355,18 @@ export declare const manageSettingsSchema: z.ZodObject<{
321
355
  legacy: "legacy";
322
356
  }>>;
323
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>>;
324
370
  }, z.core.$strip>;
325
371
  /** manage_local_ai — настройки локального ассистента и триажа (Спринт 30.7). */
326
372
  export declare const manageLocalAiSchema: z.ZodObject<{
@@ -379,7 +425,8 @@ export declare const manageTemplatesSchema: z.ZodObject<{
379
425
  }>>;
380
426
  mcpEvent: z.ZodOptional<z.ZodObject<{
381
427
  server: z.ZodString;
382
- event: z.ZodString;
428
+ event: z.ZodOptional<z.ZodString>;
429
+ eventName: z.ZodOptional<z.ZodString>;
383
430
  filter: z.ZodOptional<z.ZodString>;
384
431
  }, z.core.$strip>>;
385
432
  watchPath: z.ZodOptional<z.ZodString>;
@@ -419,6 +466,26 @@ export declare const sendNotificationSchema: z.ZodObject<{
419
466
  all: "all";
420
467
  }>>;
421
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>;
422
489
  /** get_dashboard_info — сведения о панели управления. */
423
490
  export declare const getDashboardInfoSchema: z.ZodObject<{}, z.core.$strip>;
424
491
  /** cleanup_history — удаление старой истории. */
@@ -430,6 +497,7 @@ export declare const cleanupHistorySchema: z.ZodObject<{
430
497
  export declare const emitEventSchema: z.ZodObject<{
431
498
  eventName: z.ZodString;
432
499
  payload: z.ZodOptional<z.ZodAny>;
500
+ server: z.ZodOptional<z.ZodString>;
433
501
  }, z.core.$strip>;
434
502
  /** manage_secrets — зашифрованное хранилище секретов (Спринт 26). */
435
503
  export declare const manageSecretsSchema: z.ZodObject<{
@@ -450,6 +518,13 @@ export declare const getAuditLogSchema: z.ZodObject<{
450
518
  until: z.ZodOptional<z.ZodString>;
451
519
  limit: z.ZodOptional<z.ZodNumber>;
452
520
  }, z.core.$strip>;
521
+ /**
522
+ * Общий контекст execute-обработчиков. Обработчики не читают поля контекста,
523
+ * а контексты V1 и V2 устроены по-разному, поэтому на границе адаптеров он
524
+ * сводится к `unknown`. Это позволяет не тащить `Tool.Context` из
525
+ * @opencode/schema/tool в общий контракт инструментов.
526
+ */
527
+ type ToolExecuteContext = unknown;
453
528
  /** schedule_task — создаёт задачу в schtasks через общий schedulerCreateTask. */
454
529
  declare const scheduleTaskExecute: (input: {
455
530
  name: string;
@@ -476,7 +551,8 @@ declare const scheduleTaskExecute: (input: {
476
551
  triggerType?: "cron" | "file" | "git" | "mcp-event" | "once" | undefined;
477
552
  mcpEvent?: {
478
553
  server: string;
479
- event: string;
554
+ event?: string | undefined;
555
+ eventName?: string | undefined;
480
556
  filter?: string | undefined;
481
557
  } | undefined;
482
558
  watchPath?: string | undefined;
@@ -506,6 +582,7 @@ declare const scheduleTaskExecute: (input: {
506
582
  changedSince?: string | undefined;
507
583
  } | undefined;
508
584
  } | undefined;
585
+ tokenBudget?: number | undefined;
509
586
  matrix?: {
510
587
  workspaceIds: string[];
511
588
  strategy?: "parallel" | "sequential" | undefined;
@@ -521,17 +598,17 @@ declare const scheduleTaskExecute: (input: {
521
598
  afterScript?: string | undefined;
522
599
  }> | undefined;
523
600
  } | undefined;
524
- }, context: Tool.Context) => Promise<Tool.Result>;
601
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
525
602
  /** list_tasks — список задач плагина (та же логика, что и у get_tasks). */
526
- 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>;
527
604
  /** delete_task — удаление задачи по имени (/f) */
528
605
  declare const deleteTaskExecute: (input: {
529
606
  name: string;
530
- }, context: Tool.Context) => Promise<Tool.Result>;
607
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
531
608
  /** run_task_now — немедленный запуск задачи */
532
609
  declare const runTaskNowExecute: (input: {
533
610
  name: string;
534
- }, context: Tool.Context) => Promise<Tool.Result>;
611
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
535
612
  /** update_task — частичное обновление существующей задачи. */
536
613
  declare const updateTaskExecute: (input: {
537
614
  name: string;
@@ -567,7 +644,8 @@ declare const updateTaskExecute: (input: {
567
644
  triggerType?: "cron" | "file" | "git" | "mcp-event" | "once" | undefined;
568
645
  mcpEvent?: {
569
646
  server: string;
570
- event: string;
647
+ event?: string | undefined;
648
+ eventName?: string | undefined;
571
649
  filter?: string | undefined;
572
650
  } | undefined;
573
651
  watchPath?: string | undefined;
@@ -588,6 +666,7 @@ declare const updateTaskExecute: (input: {
588
666
  changedSince?: string | undefined;
589
667
  } | undefined;
590
668
  } | undefined;
669
+ tokenBudget?: number | undefined;
591
670
  matrix?: {
592
671
  workspaceIds: string[];
593
672
  strategy?: "parallel" | "sequential" | undefined;
@@ -603,45 +682,49 @@ declare const updateTaskExecute: (input: {
603
682
  afterScript?: string | undefined;
604
683
  }> | undefined;
605
684
  } | null | undefined;
606
- }, context: Tool.Context) => Promise<Tool.Result>;
685
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
607
686
  declare const pauseTaskExecute: (input: {
608
687
  name: string;
609
688
  until?: string | undefined;
610
- }, context: Tool.Context) => Promise<Tool.Result>;
689
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
611
690
  declare const resumeTaskExecute: (input: {
612
691
  name: string;
613
- }, context: Tool.Context) => Promise<Tool.Result>;
692
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
614
693
  /** get_history — история запусков с фильтрами по задаче и статусу. */
615
694
  declare const getHistoryExecute: (input: {
616
695
  taskName?: string | undefined;
617
- status?: "error" | "running" | "partial" | "success" | "timeout" | undefined;
696
+ status?: "error" | "running" | "success" | "partial" | "timeout" | undefined;
618
697
  limit?: number | undefined;
619
- }, context: Tool.Context) => Promise<Tool.Result>;
698
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
620
699
  /** get_task_logs — последние строки лога задачи. */
621
700
  declare const getTaskLogsExecute: (input: {
622
- name: string;
701
+ name?: string | undefined;
702
+ taskName?: string | undefined;
623
703
  lines?: number | undefined;
624
- }, context: Tool.Context) => Promise<Tool.Result>;
704
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
625
705
  /** dry_run — симуляция пайплайна без выполнения. */
626
706
  declare const dryRunExecute: (input: {
627
707
  name?: string | undefined;
628
- }, context: Tool.Context) => Promise<Tool.Result>;
708
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
629
709
  /** pipeline_validate — проверить opencode.pipeline.yaml (путь или исходник). */
630
710
  declare const pipelineValidateExecute: (input: {
631
711
  dryRun: boolean;
632
712
  path?: string | undefined;
633
713
  source?: string | undefined;
634
- }, context: Tool.Context) => Promise<Tool.Result>;
714
+ workingDirectory?: string | undefined;
715
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
635
716
  /** pipeline_apply — применить opencode.pipeline.yaml к текущему набору задач. */
636
717
  declare const pipelineApplyExecute: (input: {
637
718
  dryRun: boolean;
638
719
  path?: string | undefined;
639
720
  source?: string | undefined;
640
- }, context: Tool.Context) => Promise<Tool.Result>;
721
+ workingDirectory?: string | undefined;
722
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
641
723
  /** pipeline_export — выгрузить задачи конвейера как opencode.pipeline.yaml. */
642
724
  declare const pipelineExportExecute: (input: {
643
- pipeline: string;
644
- }, context: Tool.Context) => Promise<Tool.Result>;
725
+ pipeline?: string | undefined;
726
+ pipelineName?: string | undefined;
727
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
645
728
  /** manage_workspaces — CRUD multi-repo workspace-ов. */
646
729
  declare const manageWorkspacesExecute: (input: {
647
730
  action: "delete" | "list" | "add" | "update";
@@ -651,23 +734,23 @@ declare const manageWorkspacesExecute: (input: {
651
734
  color?: string | undefined;
652
735
  env?: Record<string, string> | null | undefined;
653
736
  envFile?: string | null | undefined;
654
- }, context: Tool.Context) => Promise<Tool.Result>;
737
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
655
738
  /** matrix_control — результаты, отмена, очистка и предпросмотр матриц. */
656
739
  declare const matrixControlExecute: (input: {
657
- action: "preview" | "results" | "cancel" | "cleanup";
740
+ action: "results" | "preview" | "cancel" | "cleanup";
658
741
  name?: string | undefined;
659
742
  workspaceIds?: string[] | undefined;
660
743
  strategy?: "parallel" | "sequential" | undefined;
661
744
  failureMode?: "continue" | "stop" | undefined;
662
745
  aggregation?: "summary" | "per-task" | undefined;
663
- }, context: Tool.Context) => Promise<Tool.Result>;
746
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
664
747
  /** get_metrics — суммарная статистика запусков. */
665
- 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>;
666
749
  /** get_analytics — аналитика запусков и стоимости за период. */
667
750
  declare const getAnalyticsExecute: (input: {
668
751
  days?: number | undefined;
669
752
  topLimit?: number | undefined;
670
- }, context: Tool.Context) => Promise<Tool.Result>;
753
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
671
754
  /** self_analysis — система самоанализа: здоровье, аномалии, тренды, рекомендации. */
672
755
  declare const selfAnalysisExecute: (input: {
673
756
  days?: number | undefined;
@@ -675,10 +758,10 @@ declare const selfAnalysisExecute: (input: {
675
758
  includeAnomalies?: boolean | undefined;
676
759
  includeTrends?: boolean | undefined;
677
760
  includeRecommendations?: boolean | undefined;
678
- }, context: Tool.Context) => Promise<Tool.Result>;
761
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
679
762
  /** manage_settings — чтение и изменение глобальных настроек. */
680
763
  declare const manageSettingsExecute: (input: {
681
- action: "update" | "get";
764
+ action: "list" | "update" | "get";
682
765
  maxConcurrent?: number | undefined;
683
766
  locale?: "ru" | "en" | "zh" | "auto" | undefined;
684
767
  winterMode?: boolean | undefined;
@@ -692,7 +775,19 @@ declare const manageSettingsExecute: (input: {
692
775
  permissions?: {
693
776
  defaultPolicy?: "hybrid" | "secure" | "legacy" | undefined;
694
777
  } | undefined;
695
- }, 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>;
696
791
  /** Один классификационный запрос — общий путь для инструмента и GUI. */
697
792
  export declare function runLocalAiTest(patch?: LocalAiPatch): Promise<{
698
793
  success: boolean;
@@ -722,7 +817,7 @@ declare const manageLocalAiExecute: (input: {
722
817
  days?: number | undefined;
723
818
  startedAt?: string | null | undefined;
724
819
  } | undefined;
725
- }, context: Tool.Context) => Promise<Tool.Result>;
820
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
726
821
  /** manage_templates — список, сохранение и удаление шаблонов задач. */
727
822
  declare const manageTemplatesExecute: (input: {
728
823
  action: "delete" | "list" | "save";
@@ -744,48 +839,82 @@ declare const manageTemplatesExecute: (input: {
744
839
  triggerType?: "cron" | "file" | "mcp-event" | undefined;
745
840
  mcpEvent?: {
746
841
  server: string;
747
- event: string;
842
+ event?: string | undefined;
843
+ eventName?: string | undefined;
748
844
  filter?: string | undefined;
749
845
  } | undefined;
750
846
  watchPath?: string | undefined;
751
847
  workingDirectory?: string | undefined;
752
848
  allowedTools?: string[] | undefined;
753
849
  deniedTools?: string[] | undefined;
754
- }, context: Tool.Context) => Promise<Tool.Result>;
850
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
755
851
  /** manage_profiles — список, создание, переключение и удаление профилей. */
756
852
  declare const manageProfilesExecute: (input: {
757
853
  action: "delete" | "list" | "create" | "switch";
758
854
  name?: string | undefined;
759
855
  port?: number | undefined;
760
- }, context: Tool.Context) => Promise<Tool.Result>;
856
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
761
857
  /** transfer_tasks — экспорт и импорт задач. */
762
858
  declare const transferTasksExecute: (input: {
763
859
  action: "export" | "import";
764
860
  data?: string | undefined;
765
- }, context: Tool.Context) => Promise<Tool.Result>;
861
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
766
862
  /** send_notification — тестовое уведомление или дайджест. */
767
863
  declare const sendNotificationExecute: (input: {
768
864
  action: "test" | "digest";
769
865
  channel?: "webhook" | "telegram" | "native" | "all" | undefined;
770
- }, 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>;
771
878
  /** get_dashboard_info — порт дашборда, платформа и активный профиль. */
772
- 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>;
773
880
  /** cleanup_history — удаление старых записей истории. */
774
881
  declare const cleanupHistoryExecute: (input: {
775
882
  retentionDays?: number | undefined;
776
883
  maxRecords?: number | undefined;
777
- }, 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>;
778
906
  /** emit_event — запуск задач, подписанных на MCP-событие. */
779
907
  declare const emitEventExecute: (input: {
780
908
  eventName: string;
781
909
  payload?: any;
782
- }, context: Tool.Context) => Promise<Tool.Result>;
910
+ server?: string | undefined;
911
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
783
912
  /** manage_secrets — зашифрованное хранилище секретов. */
784
913
  declare const manageSecretsExecute: (input: {
785
914
  action: "delete" | "list" | "set";
786
915
  name?: string | undefined;
787
916
  value?: string | undefined;
788
- }, context: Tool.Context) => Promise<Tool.Result>;
917
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
789
918
  /** get_audit_log — чтение журнала мутаций. */
790
919
  declare const getAuditLogExecute: (input: {
791
920
  action?: string | undefined;
@@ -794,7 +923,7 @@ declare const getAuditLogExecute: (input: {
794
923
  since?: string | undefined;
795
924
  until?: string | undefined;
796
925
  limit?: number | undefined;
797
- }, context: Tool.Context) => Promise<Tool.Result>;
926
+ }, context: ToolExecuteContext) => Promise<Tool.Result>;
798
927
  /**
799
928
  * Минимальный контракт контекста, который нужен общему ядру.
800
929
  * V2 передаёт сюда setup-контекст, V1 — контекст из `server()`.
@@ -849,6 +978,7 @@ export interface ToolHandlers {
849
978
  manage_profiles: typeof manageProfilesExecute;
850
979
  transfer_tasks: typeof transferTasksExecute;
851
980
  send_notification: typeof sendNotificationExecute;
981
+ report_bug: typeof reportBugExecute;
852
982
  get_dashboard_info: typeof getDashboardInfoExecute;
853
983
  cleanup_history: typeof cleanupHistoryExecute;
854
984
  emit_event: typeof emitEventExecute;
@@ -881,13 +1011,27 @@ export declare function createShutdownHandler(runtime: SchedulerRuntime, registr
881
1011
  * Декларативное описание инструмента: всё, что нужно любому entrypoint'у,
882
1012
  * чтобы зарегистрировать его в своей версии API.
883
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"];
884
1026
  export interface ToolSpec {
885
1027
  name: string;
886
- input: any;
1028
+ input: z.ZodTypeAny;
1029
+ /** PL-43: схема структурированного output (только V2 Code Mode; V1 использует content). */
1030
+ output?: z.ZodTypeAny;
887
1031
  description: string;
888
- execute: (args: any, context: Tool.Context) => Promise<Tool.Result>;
1032
+ execute: ToolSpecExecute;
889
1033
  /** Правила аудита; null/undefined — операция не пишется в журнал. */
890
- audit?: (args: any) => Omit<AuditEntryInput, "actor"> | null;
1034
+ audit?: ToolSpecAudit;
891
1035
  }
892
1036
  /**
893
1037
  * Собирает полный список инструментов для конкретного ядра.
@@ -896,23 +1040,38 @@ export interface ToolSpec {
896
1040
  * одинаковые имена, схемы, описания и обработчики. Аудит навешивается здесь
897
1041
  * один раз, чтобы обе линии вели журнал одинаково.
898
1042
  */
899
- export declare function createToolSpecs(runtime: SchedulerRuntime): ToolSpec[];
1043
+ export declare function createToolSpecs(runtime: SchedulerRuntime, env?: NodeJS.ProcessEnv): ToolSpec[];
900
1044
  /**
901
1045
  * Приводит результат V2-обработчика (`Tool.Result`) к формату V1 (`ToolResult`).
902
1046
  * V1 ждёт строку или `{ output, metadata }`; V2 отдаёт `{ content }`.
903
1047
  */
904
- 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;
905
1053
  /**
906
1054
  * V1 `tool()` принимает `z.ZodRawShape`, а спецификации хранят `z.object(...)`.
907
1055
  * Возвращаем именно shape, чтобы V1 не получил готовый объект схемы.
908
1056
  */
909
- export declare function toV1ToolArgs(spec: ToolSpec): Record<string, any>;
1057
+ export declare function toV1ToolArgs(spec: ToolSpec): z.ZodRawShape;
910
1058
  /**
911
1059
  * V1-реестр инструментов: те же имена, описания, схемы и обработчики, что в
912
1060
  * V2, плюс тот же аудит. Отличие одно — у V1 `tool()` нет `codemode`, поэтому
913
1061
  * флаг не передаётся (см. docs/COMPATIBILITY.md).
914
1062
  */
915
- 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;
916
1075
  /**
917
1076
  * V1-entrypoint (OpenCode 1.x): module contract `{ id?, server }`.
918
1077
  *
@@ -952,7 +1111,26 @@ export interface TriggerExtras {
952
1111
  gitIgnore?: string[];
953
1112
  gitPollSeconds?: number;
954
1113
  }
955
- 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?: McpEventTrigger, workspaceId?: string, allowedTools?: string[], deniedTools?: string[], matrix?: MatrixConfig, matrixParentId?: string,
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,
956
1134
  /** create — пересоздать клонов с нуля; sync — только diff (Спринт 17). */
957
1135
  matrixMode?: "create" | "sync",
958
1136
  /** IANA-зона задачи (Спринт 19). Не системная зона → poll-режим шлюза. */
@@ -988,5 +1166,21 @@ legacyShell?: boolean,
988
1166
  /** W-1: одноразовый git worktree на каждый запуск. */
989
1167
  worktree?: boolean,
990
1168
  /** W-3: guard-условия перед запуском opencode. */
991
- guards?: TaskGuards): Promise<void>;
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
+ }
992
1186
  //# sourceMappingURL=index.d.ts.map