@herdctl/core 0.0.1 → 0.0.2

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 (275) hide show
  1. package/dist/config/__tests__/agent.test.js +31 -13
  2. package/dist/config/__tests__/agent.test.js.map +1 -1
  3. package/dist/config/__tests__/merge.test.js +9 -2
  4. package/dist/config/__tests__/merge.test.js.map +1 -1
  5. package/dist/config/__tests__/schema.test.js +350 -1
  6. package/dist/config/__tests__/schema.test.js.map +1 -1
  7. package/dist/config/index.d.ts +1 -1
  8. package/dist/config/index.d.ts.map +1 -1
  9. package/dist/config/index.js +3 -1
  10. package/dist/config/index.js.map +1 -1
  11. package/dist/config/schema.d.ts +828 -24
  12. package/dist/config/schema.d.ts.map +1 -1
  13. package/dist/config/schema.js +118 -6
  14. package/dist/config/schema.js.map +1 -1
  15. package/dist/fleet-manager/__tests__/coverage.test.js +11 -332
  16. package/dist/fleet-manager/__tests__/coverage.test.js.map +1 -1
  17. package/dist/fleet-manager/__tests__/errors.test.js +1 -49
  18. package/dist/fleet-manager/__tests__/errors.test.js.map +1 -1
  19. package/dist/fleet-manager/__tests__/integration.test.js +109 -0
  20. package/dist/fleet-manager/__tests__/integration.test.js.map +1 -1
  21. package/dist/fleet-manager/__tests__/reload.test.js +1 -1
  22. package/dist/fleet-manager/__tests__/reload.test.js.map +1 -1
  23. package/dist/fleet-manager/config-reload.d.ts +164 -0
  24. package/dist/fleet-manager/config-reload.d.ts.map +1 -0
  25. package/dist/fleet-manager/config-reload.js +445 -0
  26. package/dist/fleet-manager/config-reload.js.map +1 -0
  27. package/dist/fleet-manager/context.d.ts +76 -0
  28. package/dist/fleet-manager/context.d.ts.map +1 -0
  29. package/dist/fleet-manager/context.js +11 -0
  30. package/dist/fleet-manager/context.js.map +1 -0
  31. package/dist/fleet-manager/errors.d.ts +0 -25
  32. package/dist/fleet-manager/errors.d.ts.map +1 -1
  33. package/dist/fleet-manager/errors.js +0 -38
  34. package/dist/fleet-manager/errors.js.map +1 -1
  35. package/dist/fleet-manager/event-emitters.d.ts +123 -0
  36. package/dist/fleet-manager/event-emitters.d.ts.map +1 -0
  37. package/dist/fleet-manager/event-emitters.js +136 -0
  38. package/dist/fleet-manager/event-emitters.js.map +1 -0
  39. package/dist/fleet-manager/event-types.d.ts +0 -15
  40. package/dist/fleet-manager/event-types.d.ts.map +1 -1
  41. package/dist/fleet-manager/fleet-manager.d.ts +40 -653
  42. package/dist/fleet-manager/fleet-manager.d.ts.map +1 -1
  43. package/dist/fleet-manager/fleet-manager.js +95 -1720
  44. package/dist/fleet-manager/fleet-manager.js.map +1 -1
  45. package/dist/fleet-manager/index.d.ts +13 -2
  46. package/dist/fleet-manager/index.d.ts.map +1 -1
  47. package/dist/fleet-manager/index.js +19 -6
  48. package/dist/fleet-manager/index.js.map +1 -1
  49. package/dist/fleet-manager/job-control.d.ts +64 -0
  50. package/dist/fleet-manager/job-control.d.ts.map +1 -0
  51. package/dist/fleet-manager/job-control.js +296 -0
  52. package/dist/fleet-manager/job-control.js.map +1 -0
  53. package/dist/fleet-manager/log-streaming.d.ts +171 -0
  54. package/dist/fleet-manager/log-streaming.d.ts.map +1 -0
  55. package/dist/fleet-manager/log-streaming.js +503 -0
  56. package/dist/fleet-manager/log-streaming.js.map +1 -0
  57. package/dist/fleet-manager/schedule-executor.d.ts +63 -0
  58. package/dist/fleet-manager/schedule-executor.d.ts.map +1 -0
  59. package/dist/fleet-manager/schedule-executor.js +209 -0
  60. package/dist/fleet-manager/schedule-executor.js.map +1 -0
  61. package/dist/fleet-manager/schedule-management.d.ts +71 -0
  62. package/dist/fleet-manager/schedule-management.d.ts.map +1 -0
  63. package/dist/fleet-manager/schedule-management.js +171 -0
  64. package/dist/fleet-manager/schedule-management.js.map +1 -0
  65. package/dist/fleet-manager/status-queries.d.ts +105 -0
  66. package/dist/fleet-manager/status-queries.d.ts.map +1 -0
  67. package/dist/fleet-manager/status-queries.js +247 -0
  68. package/dist/fleet-manager/status-queries.js.map +1 -0
  69. package/dist/fleet-manager/types.d.ts +0 -39
  70. package/dist/fleet-manager/types.d.ts.map +1 -1
  71. package/dist/runner/__tests__/job-executor.test.js +206 -1
  72. package/dist/runner/__tests__/job-executor.test.js.map +1 -1
  73. package/dist/runner/job-executor.d.ts +9 -0
  74. package/dist/runner/job-executor.d.ts.map +1 -1
  75. package/dist/runner/job-executor.js +78 -4
  76. package/dist/runner/job-executor.js.map +1 -1
  77. package/dist/runner/types.d.ts +2 -0
  78. package/dist/runner/types.d.ts.map +1 -1
  79. package/dist/scheduler/__tests__/cron.test.d.ts +2 -0
  80. package/dist/scheduler/__tests__/cron.test.d.ts.map +1 -0
  81. package/dist/scheduler/__tests__/cron.test.js +867 -0
  82. package/dist/scheduler/__tests__/cron.test.js.map +1 -0
  83. package/dist/scheduler/__tests__/scheduler.test.js +164 -5
  84. package/dist/scheduler/__tests__/scheduler.test.js.map +1 -1
  85. package/dist/scheduler/cron.d.ts +126 -0
  86. package/dist/scheduler/cron.d.ts.map +1 -0
  87. package/dist/scheduler/cron.js +390 -0
  88. package/dist/scheduler/cron.js.map +1 -0
  89. package/dist/scheduler/errors.d.ts +81 -1
  90. package/dist/scheduler/errors.d.ts.map +1 -1
  91. package/dist/scheduler/errors.js +81 -6
  92. package/dist/scheduler/errors.js.map +1 -1
  93. package/dist/scheduler/index.d.ts +1 -0
  94. package/dist/scheduler/index.d.ts.map +1 -1
  95. package/dist/scheduler/index.js +2 -0
  96. package/dist/scheduler/index.js.map +1 -1
  97. package/dist/scheduler/schedule-runner.d.ts +2 -2
  98. package/dist/scheduler/schedule-runner.d.ts.map +1 -1
  99. package/dist/scheduler/schedule-runner.js +20 -8
  100. package/dist/scheduler/schedule-runner.js.map +1 -1
  101. package/dist/scheduler/scheduler.d.ts +4 -4
  102. package/dist/scheduler/scheduler.d.ts.map +1 -1
  103. package/dist/scheduler/scheduler.js +86 -20
  104. package/dist/scheduler/scheduler.js.map +1 -1
  105. package/dist/scheduler/types.d.ts +1 -1
  106. package/dist/scheduler/types.d.ts.map +1 -1
  107. package/dist/state/schemas/job-metadata.d.ts +2 -2
  108. package/package.json +33 -8
  109. package/.turbo/turbo-build.log +0 -4
  110. package/.turbo/turbo-test.log +0 -219
  111. package/.turbo/turbo-typecheck.log +0 -4
  112. package/coverage/base.css +0 -224
  113. package/coverage/block-navigation.js +0 -87
  114. package/coverage/coverage-final.json +0 -51
  115. package/coverage/favicon.png +0 -0
  116. package/coverage/index.html +0 -251
  117. package/coverage/prettify.css +0 -1
  118. package/coverage/prettify.js +0 -2
  119. package/coverage/sort-arrow-sprite.png +0 -0
  120. package/coverage/sorter.js +0 -210
  121. package/coverage/src/config/index.html +0 -191
  122. package/coverage/src/config/index.ts.html +0 -442
  123. package/coverage/src/config/interpolate.ts.html +0 -652
  124. package/coverage/src/config/loader.ts.html +0 -1501
  125. package/coverage/src/config/merge.ts.html +0 -823
  126. package/coverage/src/config/parser.ts.html +0 -1213
  127. package/coverage/src/config/schema.ts.html +0 -1123
  128. package/coverage/src/fleet-manager/errors.ts.html +0 -2326
  129. package/coverage/src/fleet-manager/event-types.ts.html +0 -1219
  130. package/coverage/src/fleet-manager/fleet-manager.ts.html +0 -7030
  131. package/coverage/src/fleet-manager/index.html +0 -206
  132. package/coverage/src/fleet-manager/index.ts.html +0 -469
  133. package/coverage/src/fleet-manager/job-manager.ts.html +0 -2074
  134. package/coverage/src/fleet-manager/job-queue.ts.html +0 -2479
  135. package/coverage/src/fleet-manager/types.ts.html +0 -2602
  136. package/coverage/src/index.html +0 -116
  137. package/coverage/src/index.ts.html +0 -181
  138. package/coverage/src/runner/errors.ts.html +0 -1006
  139. package/coverage/src/runner/index.html +0 -191
  140. package/coverage/src/runner/index.ts.html +0 -256
  141. package/coverage/src/runner/job-executor.ts.html +0 -1429
  142. package/coverage/src/runner/message-processor.ts.html +0 -1150
  143. package/coverage/src/runner/sdk-adapter.ts.html +0 -658
  144. package/coverage/src/runner/types.ts.html +0 -559
  145. package/coverage/src/scheduler/errors.ts.html +0 -388
  146. package/coverage/src/scheduler/index.html +0 -206
  147. package/coverage/src/scheduler/index.ts.html +0 -244
  148. package/coverage/src/scheduler/interval.ts.html +0 -652
  149. package/coverage/src/scheduler/schedule-runner.ts.html +0 -1411
  150. package/coverage/src/scheduler/schedule-state.ts.html +0 -718
  151. package/coverage/src/scheduler/scheduler.ts.html +0 -1795
  152. package/coverage/src/scheduler/types.ts.html +0 -733
  153. package/coverage/src/state/directory.ts.html +0 -736
  154. package/coverage/src/state/errors.ts.html +0 -376
  155. package/coverage/src/state/fleet-state.ts.html +0 -937
  156. package/coverage/src/state/index.html +0 -221
  157. package/coverage/src/state/index.ts.html +0 -322
  158. package/coverage/src/state/job-metadata.ts.html +0 -1420
  159. package/coverage/src/state/job-output.ts.html +0 -1033
  160. package/coverage/src/state/schemas/fleet-state.ts.html +0 -445
  161. package/coverage/src/state/schemas/index.html +0 -176
  162. package/coverage/src/state/schemas/index.ts.html +0 -286
  163. package/coverage/src/state/schemas/job-metadata.ts.html +0 -628
  164. package/coverage/src/state/schemas/job-output.ts.html +0 -616
  165. package/coverage/src/state/schemas/session-info.ts.html +0 -361
  166. package/coverage/src/state/session.ts.html +0 -844
  167. package/coverage/src/state/types.ts.html +0 -262
  168. package/coverage/src/state/utils/atomic.ts.html +0 -748
  169. package/coverage/src/state/utils/index.html +0 -146
  170. package/coverage/src/state/utils/index.ts.html +0 -103
  171. package/coverage/src/state/utils/reads.ts.html +0 -1621
  172. package/coverage/src/work-sources/adapters/github.ts.html +0 -3583
  173. package/coverage/src/work-sources/adapters/index.html +0 -131
  174. package/coverage/src/work-sources/adapters/index.ts.html +0 -277
  175. package/coverage/src/work-sources/errors.ts.html +0 -298
  176. package/coverage/src/work-sources/index.html +0 -176
  177. package/coverage/src/work-sources/index.ts.html +0 -529
  178. package/coverage/src/work-sources/manager.ts.html +0 -1324
  179. package/coverage/src/work-sources/registry.ts.html +0 -619
  180. package/coverage/src/work-sources/types.ts.html +0 -568
  181. package/dist/fleet-manager/__tests__/event-helpers.test.d.ts +0 -7
  182. package/dist/fleet-manager/__tests__/event-helpers.test.d.ts.map +0 -1
  183. package/dist/fleet-manager/__tests__/event-helpers.test.js +0 -368
  184. package/dist/fleet-manager/__tests__/event-helpers.test.js.map +0 -1
  185. package/src/config/__tests__/agent.test.ts +0 -864
  186. package/src/config/__tests__/interpolate.test.ts +0 -644
  187. package/src/config/__tests__/loader.test.ts +0 -784
  188. package/src/config/__tests__/merge.test.ts +0 -751
  189. package/src/config/__tests__/parser.test.ts +0 -533
  190. package/src/config/__tests__/schema.test.ts +0 -873
  191. package/src/config/index.ts +0 -119
  192. package/src/config/interpolate.ts +0 -189
  193. package/src/config/loader.ts +0 -472
  194. package/src/config/merge.ts +0 -246
  195. package/src/config/parser.ts +0 -376
  196. package/src/config/schema.ts +0 -346
  197. package/src/fleet-manager/__tests__/coverage.test.ts +0 -2869
  198. package/src/fleet-manager/__tests__/errors.test.ts +0 -660
  199. package/src/fleet-manager/__tests__/event-helpers.test.ts +0 -448
  200. package/src/fleet-manager/__tests__/integration.test.ts +0 -1209
  201. package/src/fleet-manager/__tests__/job-control.test.ts +0 -283
  202. package/src/fleet-manager/__tests__/job-manager.test.ts +0 -869
  203. package/src/fleet-manager/__tests__/job-queue.test.ts +0 -401
  204. package/src/fleet-manager/__tests__/reload.test.ts +0 -751
  205. package/src/fleet-manager/__tests__/status-queries.test.ts +0 -595
  206. package/src/fleet-manager/__tests__/trigger.test.ts +0 -601
  207. package/src/fleet-manager/errors.ts +0 -747
  208. package/src/fleet-manager/event-types.ts +0 -378
  209. package/src/fleet-manager/fleet-manager.ts +0 -2315
  210. package/src/fleet-manager/index.ts +0 -128
  211. package/src/fleet-manager/job-manager.ts +0 -663
  212. package/src/fleet-manager/job-queue.ts +0 -798
  213. package/src/fleet-manager/types.ts +0 -839
  214. package/src/index.ts +0 -32
  215. package/src/runner/__tests__/errors.test.ts +0 -382
  216. package/src/runner/__tests__/job-executor.test.ts +0 -1708
  217. package/src/runner/__tests__/message-processor.test.ts +0 -960
  218. package/src/runner/__tests__/sdk-adapter.test.ts +0 -626
  219. package/src/runner/errors.ts +0 -307
  220. package/src/runner/index.ts +0 -57
  221. package/src/runner/job-executor.ts +0 -448
  222. package/src/runner/message-processor.ts +0 -355
  223. package/src/runner/sdk-adapter.ts +0 -191
  224. package/src/runner/types.ts +0 -158
  225. package/src/scheduler/__tests__/errors.test.ts +0 -159
  226. package/src/scheduler/__tests__/interval.test.ts +0 -515
  227. package/src/scheduler/__tests__/schedule-runner.test.ts +0 -798
  228. package/src/scheduler/__tests__/schedule-state.test.ts +0 -671
  229. package/src/scheduler/__tests__/scheduler.test.ts +0 -1280
  230. package/src/scheduler/errors.ts +0 -101
  231. package/src/scheduler/index.ts +0 -53
  232. package/src/scheduler/interval.ts +0 -189
  233. package/src/scheduler/schedule-runner.ts +0 -442
  234. package/src/scheduler/schedule-state.ts +0 -211
  235. package/src/scheduler/scheduler.ts +0 -570
  236. package/src/scheduler/types.ts +0 -216
  237. package/src/state/__tests__/directory.test.ts +0 -595
  238. package/src/state/__tests__/fleet-state.test.ts +0 -868
  239. package/src/state/__tests__/job-metadata-schema.test.ts +0 -414
  240. package/src/state/__tests__/job-metadata.test.ts +0 -831
  241. package/src/state/__tests__/job-output.test.ts +0 -856
  242. package/src/state/__tests__/session-schema.test.ts +0 -378
  243. package/src/state/__tests__/session.test.ts +0 -604
  244. package/src/state/directory.ts +0 -217
  245. package/src/state/errors.ts +0 -97
  246. package/src/state/fleet-state.ts +0 -284
  247. package/src/state/index.ts +0 -79
  248. package/src/state/job-metadata.ts +0 -445
  249. package/src/state/job-output.ts +0 -316
  250. package/src/state/schemas/__tests__/job-output.test.ts +0 -338
  251. package/src/state/schemas/fleet-state.ts +0 -120
  252. package/src/state/schemas/index.ts +0 -67
  253. package/src/state/schemas/job-metadata.ts +0 -181
  254. package/src/state/schemas/job-output.ts +0 -177
  255. package/src/state/schemas/session-info.ts +0 -92
  256. package/src/state/session.ts +0 -253
  257. package/src/state/types.ts +0 -59
  258. package/src/state/utils/__tests__/atomic.test.ts +0 -723
  259. package/src/state/utils/__tests__/reads.test.ts +0 -1071
  260. package/src/state/utils/atomic.ts +0 -221
  261. package/src/state/utils/index.ts +0 -6
  262. package/src/state/utils/reads.ts +0 -512
  263. package/src/work-sources/__tests__/github.test.ts +0 -1800
  264. package/src/work-sources/__tests__/manager.test.ts +0 -529
  265. package/src/work-sources/__tests__/registry.test.ts +0 -477
  266. package/src/work-sources/__tests__/types.test.ts +0 -479
  267. package/src/work-sources/adapters/github.ts +0 -1166
  268. package/src/work-sources/adapters/index.ts +0 -64
  269. package/src/work-sources/errors.ts +0 -71
  270. package/src/work-sources/index.ts +0 -148
  271. package/src/work-sources/manager.ts +0 -413
  272. package/src/work-sources/registry.ts +0 -178
  273. package/src/work-sources/types.ts +0 -161
  274. package/tsconfig.json +0 -9
  275. package/vitest.config.ts +0 -19
@@ -1,839 +0,0 @@
1
- /**
2
- * Type definitions for the FleetManager module
3
- *
4
- * Provides interfaces for fleet manager configuration, state tracking,
5
- * and event definitions.
6
- */
7
-
8
- import type { SchedulerLogger, SchedulerState } from "../scheduler/types.js";
9
- import type { Schedule } from "../config/index.js";
10
- import type { AgentState, ScheduleState } from "../state/schemas/fleet-state.js";
11
- import type { WorkItem } from "../work-sources/types.js";
12
-
13
- // Re-export event types from dedicated event-types module
14
- export type {
15
- FleetManagerEventMap,
16
- FleetManagerEventName,
17
- FleetManagerEventPayload,
18
- FleetManagerEventListener,
19
- ConfigChange,
20
- ConfigReloadedPayload,
21
- AgentStartedPayload,
22
- AgentStoppedPayload,
23
- ScheduleTriggeredPayload,
24
- ScheduleSkippedPayload,
25
- JobCreatedPayload,
26
- JobOutputPayload,
27
- JobCompletedPayload,
28
- JobFailedPayload,
29
- // Job control events (US-6)
30
- JobCancelledPayload,
31
- JobForkedPayload,
32
- } from "./event-types.js";
33
-
34
- // =============================================================================
35
- // Fleet Manager Options
36
- // =============================================================================
37
-
38
- /**
39
- * Logger interface for fleet manager operations
40
- * Reuses the same interface as the scheduler for consistency
41
- */
42
- export type FleetManagerLogger = SchedulerLogger;
43
-
44
- /**
45
- * Options for configuring the FleetManager
46
- *
47
- * @example
48
- * ```typescript
49
- * const options: FleetManagerOptions = {
50
- * configPath: './herdctl.yaml',
51
- * stateDir: './.herdctl',
52
- * };
53
- * ```
54
- */
55
- export interface FleetManagerOptions {
56
- /**
57
- * Path to the herdctl.yaml configuration file
58
- *
59
- * Can be:
60
- * - An absolute path to the config file
61
- * - A relative path to the config file
62
- * - A directory path (will search for herdctl.yaml/herdctl.yml)
63
- *
64
- * If not provided, will auto-discover by searching up from cwd.
65
- */
66
- configPath?: string;
67
-
68
- /**
69
- * Path to the state directory (e.g., .herdctl)
70
- *
71
- * This directory stores:
72
- * - Job artifacts and outputs
73
- * - Session state
74
- * - Schedule state
75
- * - Logs
76
- *
77
- * Will be created if it doesn't exist.
78
- */
79
- stateDir: string;
80
-
81
- /**
82
- * Logger for fleet manager operations
83
- *
84
- * Default: console-based logger with [fleet-manager] prefix
85
- */
86
- logger?: FleetManagerLogger;
87
-
88
- /**
89
- * Interval in milliseconds between scheduler checks
90
- *
91
- * Default: 1000 (1 second)
92
- */
93
- checkInterval?: number;
94
- }
95
-
96
- // =============================================================================
97
- // Fleet Manager State
98
- // =============================================================================
99
-
100
- /**
101
- * Current status of the fleet manager
102
- */
103
- export type FleetManagerStatus =
104
- | "uninitialized" // Initial state, before initialize() is called
105
- | "initialized" // After initialize(), ready to start
106
- | "starting" // During start(), transitioning to running
107
- | "running" // Scheduler is active, processing schedules
108
- | "stopping" // During stop(), shutting down gracefully
109
- | "stopped" // After stop(), fully shut down
110
- | "error"; // An error occurred during operation
111
-
112
- /**
113
- * Detailed fleet manager state for monitoring
114
- */
115
- export interface FleetManagerState {
116
- /**
117
- * Current fleet manager status
118
- */
119
- status: FleetManagerStatus;
120
-
121
- /**
122
- * ISO timestamp of when the fleet manager was initialized
123
- */
124
- initializedAt: string | null;
125
-
126
- /**
127
- * ISO timestamp of when the fleet manager was started
128
- */
129
- startedAt: string | null;
130
-
131
- /**
132
- * ISO timestamp of when the fleet manager was stopped
133
- */
134
- stoppedAt: string | null;
135
-
136
- /**
137
- * Number of agents loaded from configuration
138
- */
139
- agentCount: number;
140
-
141
- /**
142
- * Last error message if status is 'error'
143
- */
144
- lastError: string | null;
145
- }
146
-
147
- // =============================================================================
148
- // Fleet Manager Events (Legacy - for backwards compatibility)
149
- // =============================================================================
150
-
151
- /**
152
- * Events emitted by the FleetManager
153
- *
154
- * @deprecated Use FleetManagerEventMap from ./event-types.js for strongly-typed events.
155
- * This interface is kept for backwards compatibility but may be removed in a future version.
156
- */
157
- export interface FleetManagerEvents {
158
- /**
159
- * Emitted when initialization completes successfully
160
- */
161
- initialized: [];
162
-
163
- /**
164
- * Emitted when the fleet manager starts running
165
- */
166
- started: [];
167
-
168
- /**
169
- * Emitted when the fleet manager stops
170
- */
171
- stopped: [];
172
-
173
- /**
174
- * Emitted when an error occurs
175
- */
176
- error: [error: Error];
177
-
178
- /**
179
- * Emitted when a schedule triggers an agent run
180
- * @deprecated Use 'schedule:triggered' event instead
181
- */
182
- "schedule:trigger": [agentName: string, scheduleName: string];
183
-
184
- /**
185
- * Emitted when an agent run completes successfully
186
- * @deprecated Use 'job:completed' event instead
187
- */
188
- "schedule:complete": [agentName: string, scheduleName: string];
189
-
190
- /**
191
- * Emitted when an agent run fails
192
- * @deprecated Use 'job:failed' event instead
193
- */
194
- "schedule:error": [agentName: string, scheduleName: string, error: Error];
195
- }
196
-
197
- // =============================================================================
198
- // Fleet Status Query Types (US-3)
199
- // =============================================================================
200
-
201
- /**
202
- * Schedule information within an AgentInfo
203
- *
204
- * Combines static schedule configuration with runtime state.
205
- */
206
- export interface ScheduleInfo {
207
- /**
208
- * Name of the schedule
209
- */
210
- name: string;
211
-
212
- /**
213
- * Name of the agent this schedule belongs to
214
- */
215
- agentName: string;
216
-
217
- /**
218
- * Schedule type (interval, cron, webhook, chat)
219
- */
220
- type: string;
221
-
222
- /**
223
- * Interval expression (e.g., "5m", "1h") for interval schedules
224
- */
225
- interval?: string;
226
-
227
- /**
228
- * Cron expression for cron schedules
229
- */
230
- expression?: string;
231
-
232
- /**
233
- * Current schedule status (idle, running, disabled)
234
- */
235
- status: "idle" | "running" | "disabled";
236
-
237
- /**
238
- * ISO timestamp of when this schedule last ran
239
- */
240
- lastRunAt: string | null;
241
-
242
- /**
243
- * ISO timestamp of when this schedule will next run
244
- */
245
- nextRunAt: string | null;
246
-
247
- /**
248
- * Last error message if the schedule encountered an error
249
- */
250
- lastError: string | null;
251
- }
252
-
253
- /**
254
- * Information about a single agent for status queries
255
- *
256
- * Combines static configuration with runtime state.
257
- *
258
- * @example
259
- * ```typescript
260
- * const agent = manager.getAgent('my-agent');
261
- * console.log(`Agent: ${agent.name}`);
262
- * console.log(`Status: ${agent.status}`);
263
- * console.log(`Schedules: ${agent.scheduleCount}`);
264
- * ```
265
- */
266
- export interface AgentInfo {
267
- /**
268
- * Agent name (unique identifier)
269
- */
270
- name: string;
271
-
272
- /**
273
- * Agent description from configuration
274
- */
275
- description?: string;
276
-
277
- /**
278
- * Current agent status
279
- */
280
- status: "idle" | "running" | "error";
281
-
282
- /**
283
- * ID of the currently running job, if any
284
- */
285
- currentJobId: string | null;
286
-
287
- /**
288
- * ID of the last completed job
289
- */
290
- lastJobId: string | null;
291
-
292
- /**
293
- * Maximum concurrent instances allowed for this agent
294
- */
295
- maxConcurrent: number;
296
-
297
- /**
298
- * Number of currently running instances
299
- */
300
- runningCount: number;
301
-
302
- /**
303
- * Error message if status is 'error'
304
- */
305
- errorMessage: string | null;
306
-
307
- /**
308
- * Number of schedules configured for this agent
309
- */
310
- scheduleCount: number;
311
-
312
- /**
313
- * Detailed information about each schedule
314
- */
315
- schedules: ScheduleInfo[];
316
-
317
- /**
318
- * Model configured for this agent (if any)
319
- */
320
- model?: string;
321
-
322
- /**
323
- * Workspace path for this agent
324
- */
325
- workspace?: string;
326
- }
327
-
328
- /**
329
- * Summary counts for quick fleet overview
330
- */
331
- export interface FleetCounts {
332
- /**
333
- * Total number of configured agents
334
- */
335
- totalAgents: number;
336
-
337
- /**
338
- * Number of agents currently idle
339
- */
340
- idleAgents: number;
341
-
342
- /**
343
- * Number of agents currently running jobs
344
- */
345
- runningAgents: number;
346
-
347
- /**
348
- * Number of agents in error state
349
- */
350
- errorAgents: number;
351
-
352
- /**
353
- * Total number of schedules across all agents
354
- */
355
- totalSchedules: number;
356
-
357
- /**
358
- * Number of schedules currently running
359
- */
360
- runningSchedules: number;
361
-
362
- /**
363
- * Total number of jobs currently running
364
- */
365
- runningJobs: number;
366
- }
367
-
368
- /**
369
- * Overall fleet status information
370
- *
371
- * Provides a comprehensive snapshot of the fleet state for CLI `herdctl status`.
372
- *
373
- * @example
374
- * ```typescript
375
- * const status = manager.getStatus();
376
- * console.log(`Fleet: ${status.state}`);
377
- * console.log(`Uptime: ${status.uptimeSeconds}s`);
378
- * console.log(`Agents: ${status.counts.totalAgents}`);
379
- * console.log(`Running jobs: ${status.counts.runningJobs}`);
380
- * ```
381
- */
382
- export interface FleetStatus {
383
- /**
384
- * Current fleet manager state
385
- */
386
- state: FleetManagerStatus;
387
-
388
- /**
389
- * Fleet uptime in seconds (time since started)
390
- * Null if fleet has never been started
391
- */
392
- uptimeSeconds: number | null;
393
-
394
- /**
395
- * ISO timestamp of when the fleet was initialized
396
- */
397
- initializedAt: string | null;
398
-
399
- /**
400
- * ISO timestamp of when the fleet was started
401
- */
402
- startedAt: string | null;
403
-
404
- /**
405
- * ISO timestamp of when the fleet was stopped
406
- */
407
- stoppedAt: string | null;
408
-
409
- /**
410
- * Summary counts for agents and jobs
411
- */
412
- counts: FleetCounts;
413
-
414
- /**
415
- * Scheduler state information
416
- */
417
- scheduler: {
418
- /**
419
- * Scheduler status (stopped, running, stopping)
420
- */
421
- status: "stopped" | "running" | "stopping";
422
-
423
- /**
424
- * Total number of schedule checks performed
425
- */
426
- checkCount: number;
427
-
428
- /**
429
- * Total number of triggers fired
430
- */
431
- triggerCount: number;
432
-
433
- /**
434
- * ISO timestamp of last schedule check
435
- */
436
- lastCheckAt: string | null;
437
-
438
- /**
439
- * Check interval in milliseconds
440
- */
441
- checkIntervalMs: number;
442
- };
443
-
444
- /**
445
- * Last error message if state is 'error'
446
- */
447
- lastError: string | null;
448
- }
449
-
450
- // =============================================================================
451
- // Trigger Options (US-5)
452
- // =============================================================================
453
-
454
- /**
455
- * Options for manually triggering an agent
456
- *
457
- * These options allow overriding agent defaults and passing runtime
458
- * configuration when triggering an agent outside its normal schedule.
459
- *
460
- * @example
461
- * ```typescript
462
- * // Trigger with default schedule settings
463
- * const job = await manager.trigger('my-agent');
464
- *
465
- * // Trigger a specific schedule
466
- * const job = await manager.trigger('my-agent', 'hourly');
467
- *
468
- * // Trigger with runtime options
469
- * const job = await manager.trigger('my-agent', 'hourly', {
470
- * prompt: 'Review the latest PR',
471
- * workItems: [{ id: '123', title: 'Bug fix PR' }],
472
- * });
473
- * ```
474
- */
475
- export interface TriggerOptions {
476
- /**
477
- * Override the prompt for this trigger
478
- *
479
- * This prompt will be used instead of the schedule's configured prompt
480
- * or the agent's default prompt.
481
- */
482
- prompt?: string;
483
-
484
- /**
485
- * Work items to process during this trigger
486
- *
487
- * These work items will be passed to the agent instead of fetching
488
- * from the configured work source.
489
- */
490
- workItems?: WorkItem[];
491
-
492
- /**
493
- * Whether to bypass concurrency limits for this trigger
494
- *
495
- * When true, the agent will be triggered even if it's at max_concurrent.
496
- * Use with caution - this can lead to resource contention.
497
- *
498
- * Default: false
499
- */
500
- bypassConcurrencyLimit?: boolean;
501
- }
502
-
503
- /**
504
- * Result of a manual trigger operation
505
- *
506
- * Contains information about the job that was created.
507
- */
508
- export interface TriggerResult {
509
- /**
510
- * Unique identifier for the created job
511
- */
512
- jobId: string;
513
-
514
- /**
515
- * Name of the agent that was triggered
516
- */
517
- agentName: string;
518
-
519
- /**
520
- * Name of the schedule used (if any)
521
- */
522
- scheduleName: string | null;
523
-
524
- /**
525
- * ISO timestamp when the job was created
526
- */
527
- startedAt: string;
528
-
529
- /**
530
- * The prompt that was used for the trigger
531
- */
532
- prompt?: string;
533
- }
534
-
535
- // =============================================================================
536
- // Stop Options (US-8)
537
- // =============================================================================
538
-
539
- /**
540
- * Options for stopping the FleetManager gracefully
541
- *
542
- * These options control how the fleet manager handles running jobs
543
- * during shutdown.
544
- *
545
- * @example
546
- * ```typescript
547
- * // Stop with default options (wait for jobs, 30s timeout)
548
- * await manager.stop();
549
- *
550
- * // Stop with custom timeout
551
- * await manager.stop({ timeout: 60000 });
552
- *
553
- * // Stop immediately without waiting for jobs
554
- * await manager.stop({ waitForJobs: false });
555
- *
556
- * // Force cancel jobs after timeout
557
- * await manager.stop({
558
- * timeout: 30000,
559
- * cancelOnTimeout: true,
560
- * });
561
- * ```
562
- */
563
- export interface FleetManagerStopOptions {
564
- /**
565
- * Whether to wait for running jobs to complete before stopping
566
- *
567
- * When true, the stop operation will wait for all currently running
568
- * jobs to complete before finishing the shutdown. When false, the
569
- * fleet manager will stop immediately, leaving jobs running in the
570
- * background (not recommended).
571
- *
572
- * Default: true
573
- */
574
- waitForJobs?: boolean;
575
-
576
- /**
577
- * Maximum time in milliseconds to wait for running jobs to complete
578
- *
579
- * Only applies when waitForJobs is true. After this timeout:
580
- * - If cancelOnTimeout is true, running jobs will be cancelled
581
- * - If cancelOnTimeout is false (default), a FleetManagerShutdownError is thrown
582
- *
583
- * Default: 30000 (30 seconds)
584
- */
585
- timeout?: number;
586
-
587
- /**
588
- * Whether to cancel jobs that are still running after the timeout
589
- *
590
- * When true, jobs that don't complete within the timeout will be
591
- * cancelled via the cancelJob method. The fleet manager will wait
592
- * for the cancellation to complete before emitting 'stopped'.
593
- *
594
- * When false, a FleetManagerShutdownError is thrown if jobs are
595
- * still running after timeout.
596
- *
597
- * Default: false
598
- */
599
- cancelOnTimeout?: boolean;
600
-
601
- /**
602
- * Timeout in milliseconds for cancelling individual jobs
603
- *
604
- * Only applies when cancelOnTimeout is true. This is the time
605
- * given to each job to respond to SIGTERM before being forcefully
606
- * killed with SIGKILL.
607
- *
608
- * Default: 10000 (10 seconds)
609
- */
610
- cancelTimeout?: number;
611
- }
612
-
613
- // =============================================================================
614
- // Job Control Types (US-6)
615
- // =============================================================================
616
-
617
- // =============================================================================
618
- // Log Streaming Types (US-11)
619
- // =============================================================================
620
-
621
- /**
622
- * Log levels for filtering log entries
623
- */
624
- export type LogLevel = "debug" | "info" | "warn" | "error";
625
-
626
- /**
627
- * Source type for log entries
628
- */
629
- export type LogSource = "fleet" | "agent" | "job" | "scheduler";
630
-
631
- /**
632
- * A single log entry from the fleet
633
- *
634
- * @example
635
- * ```typescript
636
- * const entry: LogEntry = {
637
- * timestamp: '2024-01-15T10:30:00.000Z',
638
- * level: 'info',
639
- * source: 'agent',
640
- * agentName: 'my-agent',
641
- * jobId: 'job-2024-01-15-abc123',
642
- * message: 'Processing work item',
643
- * data: { itemId: '456' },
644
- * };
645
- * ```
646
- */
647
- export interface LogEntry {
648
- /**
649
- * ISO timestamp when the log was generated
650
- */
651
- timestamp: string;
652
-
653
- /**
654
- * Log level
655
- */
656
- level: LogLevel;
657
-
658
- /**
659
- * Source of the log entry
660
- */
661
- source: LogSource;
662
-
663
- /**
664
- * Agent name (if applicable)
665
- */
666
- agentName?: string;
667
-
668
- /**
669
- * Job ID (if applicable)
670
- */
671
- jobId?: string;
672
-
673
- /**
674
- * Schedule name (if applicable)
675
- */
676
- scheduleName?: string;
677
-
678
- /**
679
- * Log message
680
- */
681
- message: string;
682
-
683
- /**
684
- * Additional structured data
685
- */
686
- data?: Record<string, unknown>;
687
- }
688
-
689
- /**
690
- * Options for streaming logs
691
- *
692
- * @example
693
- * ```typescript
694
- * // Stream all logs at info level and above
695
- * const stream = manager.streamLogs({ level: 'info' });
696
- *
697
- * // Stream only error logs for a specific agent
698
- * const stream = manager.streamLogs({
699
- * level: 'error',
700
- * agentName: 'my-agent',
701
- * });
702
- * ```
703
- */
704
- export interface LogStreamOptions {
705
- /**
706
- * Minimum log level to include
707
- *
708
- * Filters logs to only include entries at this level or higher severity.
709
- * Severity order: debug < info < warn < error
710
- *
711
- * Default: 'info'
712
- */
713
- level?: LogLevel;
714
-
715
- /**
716
- * Filter logs to a specific agent
717
- */
718
- agentName?: string;
719
-
720
- /**
721
- * Filter logs to a specific job
722
- */
723
- jobId?: string;
724
-
725
- /**
726
- * Whether to include historical logs before streaming new ones
727
- *
728
- * When true, completed jobs will replay their history before
729
- * streaming ends. When false, only new logs are streamed.
730
- *
731
- * Default: true
732
- */
733
- includeHistory?: boolean;
734
-
735
- /**
736
- * Maximum number of historical entries to include
737
- *
738
- * Only applies when includeHistory is true.
739
- *
740
- * Default: 1000
741
- */
742
- historyLimit?: number;
743
- }
744
-
745
- /**
746
- * Modifications to apply when forking a job
747
- *
748
- * Allows overriding specific configuration when creating a new job
749
- * based on an existing one. Any field not specified will be copied
750
- * from the original job.
751
- *
752
- * @example
753
- * ```typescript
754
- * // Fork with a modified prompt
755
- * const newJob = await manager.forkJob('job-2024-01-15-abc123', {
756
- * prompt: 'Retry the previous task with more detailed logging',
757
- * });
758
- *
759
- * // Fork to a different schedule
760
- * const newJob = await manager.forkJob('job-2024-01-15-abc123', {
761
- * schedule: 'daily',
762
- * });
763
- * ```
764
- */
765
- export interface JobModifications {
766
- /**
767
- * Override the prompt for the forked job
768
- */
769
- prompt?: string;
770
-
771
- /**
772
- * Override the schedule name for the forked job
773
- */
774
- schedule?: string;
775
-
776
- /**
777
- * Work items to process in the forked job
778
- * (replaces work items from the original job)
779
- */
780
- workItems?: WorkItem[];
781
- }
782
-
783
- /**
784
- * Result of canceling a job
785
- */
786
- export interface CancelJobResult {
787
- /**
788
- * ID of the job that was canceled
789
- */
790
- jobId: string;
791
-
792
- /**
793
- * Whether the cancellation was successful
794
- */
795
- success: boolean;
796
-
797
- /**
798
- * How the job was terminated
799
- * - 'graceful': Job responded to SIGTERM and exited cleanly
800
- * - 'forced': Job was killed with SIGKILL after timeout
801
- * - 'already_stopped': Job was not running when cancel was called
802
- */
803
- terminationType: 'graceful' | 'forced' | 'already_stopped';
804
-
805
- /**
806
- * ISO timestamp when the job was canceled
807
- */
808
- canceledAt: string;
809
- }
810
-
811
- /**
812
- * Result of forking a job
813
- */
814
- export interface ForkJobResult {
815
- /**
816
- * ID of the newly created job
817
- */
818
- jobId: string;
819
-
820
- /**
821
- * ID of the job that was forked
822
- */
823
- forkedFromJobId: string;
824
-
825
- /**
826
- * Name of the agent executing the new job
827
- */
828
- agentName: string;
829
-
830
- /**
831
- * ISO timestamp when the forked job was created
832
- */
833
- startedAt: string;
834
-
835
- /**
836
- * The prompt that was used for the forked job
837
- */
838
- prompt?: string;
839
- }