herdctl 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 (70) hide show
  1. package/bin/herdctl.js +9 -0
  2. package/dist/commands/__tests__/config.test.d.ts +2 -0
  3. package/dist/commands/__tests__/config.test.d.ts.map +1 -0
  4. package/dist/commands/__tests__/config.test.js +299 -0
  5. package/dist/commands/__tests__/config.test.js.map +1 -0
  6. package/dist/commands/__tests__/init.test.d.ts +2 -0
  7. package/dist/commands/__tests__/init.test.d.ts.map +1 -0
  8. package/dist/commands/__tests__/init.test.js +247 -0
  9. package/dist/commands/__tests__/init.test.js.map +1 -0
  10. package/dist/commands/__tests__/start.test.d.ts +2 -0
  11. package/dist/commands/__tests__/start.test.d.ts.map +1 -0
  12. package/dist/commands/__tests__/start.test.js +185 -0
  13. package/dist/commands/__tests__/start.test.js.map +1 -0
  14. package/dist/commands/__tests__/status.test.d.ts +2 -0
  15. package/dist/commands/__tests__/status.test.d.ts.map +1 -0
  16. package/dist/commands/__tests__/status.test.js +342 -0
  17. package/dist/commands/__tests__/status.test.js.map +1 -0
  18. package/dist/commands/__tests__/stop.test.d.ts +2 -0
  19. package/dist/commands/__tests__/stop.test.d.ts.map +1 -0
  20. package/dist/commands/__tests__/stop.test.js +229 -0
  21. package/dist/commands/__tests__/stop.test.js.map +1 -0
  22. package/dist/commands/__tests__/trigger.test.d.ts +2 -0
  23. package/dist/commands/__tests__/trigger.test.d.ts.map +1 -0
  24. package/dist/commands/__tests__/trigger.test.js +321 -0
  25. package/dist/commands/__tests__/trigger.test.js.map +1 -0
  26. package/dist/commands/cancel.d.ts +20 -0
  27. package/dist/commands/cancel.d.ts.map +1 -0
  28. package/dist/commands/cancel.js +263 -0
  29. package/dist/commands/cancel.js.map +1 -0
  30. package/dist/commands/config.d.ts +26 -0
  31. package/dist/commands/config.d.ts.map +1 -0
  32. package/dist/commands/config.js +287 -0
  33. package/dist/commands/config.js.map +1 -0
  34. package/dist/commands/init.d.ts +16 -0
  35. package/dist/commands/init.d.ts.map +1 -0
  36. package/dist/commands/init.js +305 -0
  37. package/dist/commands/init.js.map +1 -0
  38. package/dist/commands/job.d.ts +19 -0
  39. package/dist/commands/job.d.ts.map +1 -0
  40. package/dist/commands/job.js +460 -0
  41. package/dist/commands/job.js.map +1 -0
  42. package/dist/commands/jobs.d.ts +23 -0
  43. package/dist/commands/jobs.d.ts.map +1 -0
  44. package/dist/commands/jobs.js +328 -0
  45. package/dist/commands/jobs.js.map +1 -0
  46. package/dist/commands/logs.d.ts +25 -0
  47. package/dist/commands/logs.d.ts.map +1 -0
  48. package/dist/commands/logs.js +360 -0
  49. package/dist/commands/logs.js.map +1 -0
  50. package/dist/commands/start.d.ts +17 -0
  51. package/dist/commands/start.d.ts.map +1 -0
  52. package/dist/commands/start.js +166 -0
  53. package/dist/commands/start.js.map +1 -0
  54. package/dist/commands/status.d.ts +18 -0
  55. package/dist/commands/status.d.ts.map +1 -0
  56. package/dist/commands/status.js +373 -0
  57. package/dist/commands/status.js.map +1 -0
  58. package/dist/commands/stop.d.ts +18 -0
  59. package/dist/commands/stop.d.ts.map +1 -0
  60. package/dist/commands/stop.js +161 -0
  61. package/dist/commands/stop.js.map +1 -0
  62. package/dist/commands/trigger.d.ts +23 -0
  63. package/dist/commands/trigger.d.ts.map +1 -0
  64. package/dist/commands/trigger.js +332 -0
  65. package/dist/commands/trigger.js.map +1 -0
  66. package/dist/index.d.ts +23 -0
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/index.js +283 -0
  69. package/dist/index.js.map +1 -0
  70. package/package.json +46 -7
@@ -0,0 +1,373 @@
1
+ /**
2
+ * herdctl status - Show fleet and agent status
3
+ *
4
+ * Commands:
5
+ * - herdctl status Overview of all agents
6
+ * - herdctl status <agent> Detailed status of specific agent
7
+ * - herdctl status --json JSON output for scripting
8
+ */
9
+ import { FleetManager, ConfigNotFoundError, AgentNotFoundError, isFleetManagerError, } from "@herdctl/core";
10
+ /**
11
+ * Default state directory
12
+ */
13
+ const DEFAULT_STATE_DIR = ".herdctl";
14
+ /**
15
+ * Check if colors should be disabled
16
+ */
17
+ function shouldUseColor() {
18
+ // NO_COLOR takes precedence (https://no-color.org/)
19
+ if (process.env.NO_COLOR !== undefined && process.env.NO_COLOR !== "") {
20
+ return false;
21
+ }
22
+ // Also check FORCE_COLOR for override
23
+ if (process.env.FORCE_COLOR !== undefined && process.env.FORCE_COLOR !== "0") {
24
+ return true;
25
+ }
26
+ // Check if stdout is a TTY
27
+ return process.stdout.isTTY === true;
28
+ }
29
+ /**
30
+ * ANSI color codes
31
+ */
32
+ const colors = {
33
+ reset: "\x1b[0m",
34
+ bold: "\x1b[1m",
35
+ dim: "\x1b[2m",
36
+ green: "\x1b[32m",
37
+ yellow: "\x1b[33m",
38
+ red: "\x1b[31m",
39
+ cyan: "\x1b[36m",
40
+ gray: "\x1b[90m",
41
+ };
42
+ /**
43
+ * Get a colored string, respecting NO_COLOR
44
+ */
45
+ function colorize(text, color) {
46
+ if (!shouldUseColor()) {
47
+ return text;
48
+ }
49
+ return `${colors[color]}${text}${colors.reset}`;
50
+ }
51
+ /**
52
+ * Format relative time (e.g., "in 45m", "5m ago")
53
+ */
54
+ function formatRelativeTime(isoTimestamp) {
55
+ if (!isoTimestamp) {
56
+ return "-";
57
+ }
58
+ const now = Date.now();
59
+ const timestamp = new Date(isoTimestamp).getTime();
60
+ const diffMs = timestamp - now;
61
+ const absDiffMs = Math.abs(diffMs);
62
+ // Convert to appropriate unit
63
+ const seconds = Math.floor(absDiffMs / 1000);
64
+ const minutes = Math.floor(seconds / 60);
65
+ const hours = Math.floor(minutes / 60);
66
+ const days = Math.floor(hours / 24);
67
+ let timeStr;
68
+ if (days > 0) {
69
+ timeStr = `${days}d`;
70
+ }
71
+ else if (hours > 0) {
72
+ timeStr = `${hours}h`;
73
+ }
74
+ else if (minutes > 0) {
75
+ timeStr = `${minutes}m`;
76
+ }
77
+ else {
78
+ timeStr = `${seconds}s`;
79
+ }
80
+ // Future time or past time
81
+ if (diffMs > 0) {
82
+ return `in ${timeStr}`;
83
+ }
84
+ else if (diffMs < 0) {
85
+ return `${timeStr} ago`;
86
+ }
87
+ else {
88
+ return "now";
89
+ }
90
+ }
91
+ /**
92
+ * Format uptime in human-readable format
93
+ */
94
+ function formatUptime(seconds) {
95
+ if (seconds === null) {
96
+ return "-";
97
+ }
98
+ const days = Math.floor(seconds / 86400);
99
+ const hours = Math.floor((seconds % 86400) / 3600);
100
+ const minutes = Math.floor((seconds % 3600) / 60);
101
+ const secs = Math.floor(seconds % 60);
102
+ const parts = [];
103
+ if (days > 0)
104
+ parts.push(`${days}d`);
105
+ if (hours > 0)
106
+ parts.push(`${hours}h`);
107
+ if (minutes > 0)
108
+ parts.push(`${minutes}m`);
109
+ if (secs > 0 || parts.length === 0)
110
+ parts.push(`${secs}s`);
111
+ return parts.join(" ");
112
+ }
113
+ /**
114
+ * Get status color based on status string
115
+ */
116
+ function getStatusColor(status) {
117
+ switch (status) {
118
+ case "running":
119
+ return "green";
120
+ case "idle":
121
+ case "stopped":
122
+ case "initialized":
123
+ return "yellow";
124
+ case "error":
125
+ return "red";
126
+ default:
127
+ return "reset";
128
+ }
129
+ }
130
+ /**
131
+ * Format agent status with color
132
+ */
133
+ function formatStatus(status) {
134
+ const color = getStatusColor(status);
135
+ return colorize(status, color);
136
+ }
137
+ /**
138
+ * Format fleet overview table
139
+ */
140
+ function formatFleetOverview(status, agents) {
141
+ const lines = [];
142
+ // Header
143
+ lines.push("");
144
+ lines.push(colorize("Fleet Status", "bold"));
145
+ lines.push("═".repeat(60));
146
+ // Fleet state
147
+ lines.push(`State: ${formatStatus(status.state)}`);
148
+ lines.push(`Uptime: ${formatUptime(status.uptimeSeconds)}`);
149
+ // Counts
150
+ lines.push("");
151
+ lines.push(colorize("Counts", "bold"));
152
+ lines.push("─".repeat(30));
153
+ lines.push(`Agents: ${status.counts.totalAgents} total (${colorize(String(status.counts.runningAgents), "green")} running, ${colorize(String(status.counts.idleAgents), "yellow")} idle, ${colorize(String(status.counts.errorAgents), "red")} error)`);
154
+ lines.push(`Schedules: ${status.counts.totalSchedules} total (${status.counts.runningSchedules} running)`);
155
+ lines.push(`Jobs: ${status.counts.runningJobs} running`);
156
+ // Scheduler info
157
+ if (status.scheduler.status !== "stopped") {
158
+ lines.push("");
159
+ lines.push(colorize("Scheduler", "bold"));
160
+ lines.push("─".repeat(30));
161
+ lines.push(`Status: ${formatStatus(status.scheduler.status)}`);
162
+ lines.push(`Checks: ${status.scheduler.checkCount}`);
163
+ lines.push(`Triggers: ${status.scheduler.triggerCount}`);
164
+ if (status.scheduler.lastCheckAt) {
165
+ lines.push(`Last check: ${formatRelativeTime(status.scheduler.lastCheckAt)}`);
166
+ }
167
+ }
168
+ // Agents table
169
+ if (agents.length > 0) {
170
+ lines.push("");
171
+ lines.push(colorize("Agents", "bold"));
172
+ lines.push("─".repeat(60));
173
+ // Table header
174
+ const nameWidth = Math.max(6, ...agents.map(a => a.name.length)) + 2;
175
+ const statusWidth = 10;
176
+ const schedWidth = 10;
177
+ const nextRunWidth = 15;
178
+ lines.push(`${"NAME".padEnd(nameWidth)}${"STATUS".padEnd(statusWidth)}${"SCHEDULES".padEnd(schedWidth)}${"NEXT RUN".padEnd(nextRunWidth)}`);
179
+ lines.push(colorize("─".repeat(nameWidth + statusWidth + schedWidth + nextRunWidth), "dim"));
180
+ // Table rows
181
+ for (const agent of agents) {
182
+ const nextRun = getNextScheduleRun(agent.schedules);
183
+ lines.push(`${agent.name.padEnd(nameWidth)}${formatStatus(agent.status).padEnd(statusWidth + (shouldUseColor() ? colors.reset.length + colors[getStatusColor(agent.status)].length : 0))}${String(agent.scheduleCount).padEnd(schedWidth)}${formatRelativeTime(nextRun).padEnd(nextRunWidth)}`);
184
+ }
185
+ }
186
+ lines.push("");
187
+ return lines.join("\n");
188
+ }
189
+ /**
190
+ * Get the next scheduled run time across all schedules
191
+ */
192
+ function getNextScheduleRun(schedules) {
193
+ let earliest = null;
194
+ for (const schedule of schedules) {
195
+ if (schedule.nextRunAt) {
196
+ if (!earliest || new Date(schedule.nextRunAt) < new Date(earliest)) {
197
+ earliest = schedule.nextRunAt;
198
+ }
199
+ }
200
+ }
201
+ return earliest;
202
+ }
203
+ /**
204
+ * Format agent detail view
205
+ */
206
+ function formatAgentDetail(agent) {
207
+ const lines = [];
208
+ // Header
209
+ lines.push("");
210
+ lines.push(colorize(`Agent: ${agent.name}`, "bold"));
211
+ lines.push("═".repeat(60));
212
+ // Basic info
213
+ if (agent.description) {
214
+ lines.push(`Description: ${agent.description}`);
215
+ }
216
+ lines.push(`Status: ${formatStatus(agent.status)}`);
217
+ if (agent.errorMessage) {
218
+ lines.push(`Error: ${colorize(agent.errorMessage, "red")}`);
219
+ }
220
+ // Configuration
221
+ lines.push("");
222
+ lines.push(colorize("Configuration", "bold"));
223
+ lines.push("─".repeat(30));
224
+ if (agent.model) {
225
+ lines.push(`Model: ${agent.model}`);
226
+ }
227
+ if (agent.workspace) {
228
+ lines.push(`Workspace: ${agent.workspace}`);
229
+ }
230
+ lines.push(`Concurrency: ${agent.runningCount}/${agent.maxConcurrent}`);
231
+ // Job info
232
+ lines.push("");
233
+ lines.push(colorize("Jobs", "bold"));
234
+ lines.push("─".repeat(30));
235
+ lines.push(`Running: ${agent.runningCount}`);
236
+ if (agent.currentJobId) {
237
+ lines.push(`Current: ${colorize(agent.currentJobId, "cyan")}`);
238
+ }
239
+ if (agent.lastJobId) {
240
+ lines.push(`Last: ${colorize(agent.lastJobId, "dim")}`);
241
+ }
242
+ // Schedules
243
+ if (agent.schedules.length > 0) {
244
+ lines.push("");
245
+ lines.push(colorize("Schedules", "bold"));
246
+ lines.push("─".repeat(60));
247
+ for (const schedule of agent.schedules) {
248
+ lines.push("");
249
+ lines.push(` ${colorize(schedule.name, "bold")} (${schedule.type})`);
250
+ lines.push(` Status: ${formatStatus(schedule.status)}`);
251
+ if (schedule.interval) {
252
+ lines.push(` Interval: ${schedule.interval}`);
253
+ }
254
+ if (schedule.expression) {
255
+ lines.push(` Cron: ${schedule.expression}`);
256
+ }
257
+ lines.push(` Last run: ${formatRelativeTime(schedule.lastRunAt)}`);
258
+ lines.push(` Next run: ${formatRelativeTime(schedule.nextRunAt)}`);
259
+ if (schedule.lastError) {
260
+ lines.push(` Error: ${colorize(schedule.lastError, "red")}`);
261
+ }
262
+ }
263
+ }
264
+ lines.push("");
265
+ return lines.join("\n");
266
+ }
267
+ /**
268
+ * Show fleet status (herdctl status)
269
+ */
270
+ export async function statusCommand(agentName, options) {
271
+ const stateDir = options.state || DEFAULT_STATE_DIR;
272
+ // Create FleetManager
273
+ const manager = new FleetManager({
274
+ configPath: options.config,
275
+ stateDir,
276
+ });
277
+ try {
278
+ // Initialize to load configuration
279
+ await manager.initialize();
280
+ if (agentName) {
281
+ // Agent detail view
282
+ const agent = await manager.getAgentInfoByName(agentName);
283
+ if (options.json) {
284
+ const output = { agent };
285
+ console.log(JSON.stringify(output, null, 2));
286
+ }
287
+ else {
288
+ console.log(formatAgentDetail(agent));
289
+ }
290
+ }
291
+ else {
292
+ // Fleet overview
293
+ const status = await manager.getFleetStatus();
294
+ const agents = await manager.getAgentInfo();
295
+ if (options.json) {
296
+ const output = { fleet: status, agents };
297
+ console.log(JSON.stringify(output, null, 2));
298
+ }
299
+ else {
300
+ console.log(formatFleetOverview(status, agents));
301
+ }
302
+ }
303
+ }
304
+ catch (error) {
305
+ // Handle specific error types
306
+ if (error instanceof ConfigNotFoundError) {
307
+ if (options.json) {
308
+ console.log(JSON.stringify({
309
+ error: {
310
+ code: "CONFIG_NOT_FOUND",
311
+ message: "No configuration file found",
312
+ startDirectory: error.startDirectory,
313
+ },
314
+ }, null, 2));
315
+ process.exit(1);
316
+ }
317
+ console.error("");
318
+ console.error("Error: No configuration file found.");
319
+ console.error(`Searched from: ${error.startDirectory}`);
320
+ console.error("");
321
+ console.error("Run 'herdctl init' to create a configuration file.");
322
+ process.exit(1);
323
+ }
324
+ if (error instanceof AgentNotFoundError) {
325
+ if (options.json) {
326
+ console.log(JSON.stringify({
327
+ error: {
328
+ code: "AGENT_NOT_FOUND",
329
+ message: error.message,
330
+ agentName: agentName,
331
+ },
332
+ }, null, 2));
333
+ process.exit(1);
334
+ }
335
+ console.error("");
336
+ console.error(`Error: Agent '${agentName}' not found.`);
337
+ console.error("");
338
+ console.error("Run 'herdctl status' to see all agents.");
339
+ process.exit(1);
340
+ }
341
+ if (isFleetManagerError(error)) {
342
+ if (options.json) {
343
+ console.log(JSON.stringify({
344
+ error: {
345
+ code: error.code,
346
+ message: error.message,
347
+ },
348
+ }, null, 2));
349
+ process.exit(1);
350
+ }
351
+ console.error("");
352
+ console.error(`Error: ${error.message}`);
353
+ if (error.code) {
354
+ console.error(`Code: ${error.code}`);
355
+ }
356
+ process.exit(1);
357
+ }
358
+ // Generic error
359
+ if (options.json) {
360
+ console.log(JSON.stringify({
361
+ error: {
362
+ code: "UNKNOWN_ERROR",
363
+ message: error instanceof Error ? error.message : String(error),
364
+ },
365
+ }, null, 2));
366
+ process.exit(1);
367
+ }
368
+ console.error("");
369
+ console.error("Error:", error instanceof Error ? error.message : String(error));
370
+ process.exit(1);
371
+ }
372
+ }
373
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,GAIpB,MAAM,eAAe,CAAC;AAQvB;;GAEG;AACH,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAErC;;GAEG;AACH,SAAS,cAAc;IACrB,oDAAoD;IACpD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,EAAE,EAAE,CAAC;QACtE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,sCAA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,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * herdctl stop - Stop the fleet
3
+ *
4
+ * Commands:
5
+ * - herdctl stop Graceful stop (wait for jobs)
6
+ * - herdctl stop --force Immediate stop (cancel jobs)
7
+ * - herdctl stop --timeout 30 Wait max 30 seconds before force kill
8
+ */
9
+ export interface StopOptions {
10
+ force?: boolean;
11
+ timeout?: number;
12
+ state?: string;
13
+ }
14
+ /**
15
+ * Stop the fleet
16
+ */
17
+ export declare function stopCommand(options: StopOptions): Promise<void>;
18
+ //# sourceMappingURL=stop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stop.d.ts","sourceRoot":"","sources":["../../src/commands/stop.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA+FD;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAuErE"}
@@ -0,0 +1,161 @@
1
+ /**
2
+ * herdctl stop - Stop the fleet
3
+ *
4
+ * Commands:
5
+ * - herdctl stop Graceful stop (wait for jobs)
6
+ * - herdctl stop --force Immediate stop (cancel jobs)
7
+ * - herdctl stop --timeout 30 Wait max 30 seconds before force kill
8
+ */
9
+ import * as fs from "node:fs";
10
+ import * as path from "node:path";
11
+ /**
12
+ * Default state directory
13
+ */
14
+ const DEFAULT_STATE_DIR = ".herdctl";
15
+ /**
16
+ * Default timeout in seconds
17
+ */
18
+ const DEFAULT_TIMEOUT = 30;
19
+ /**
20
+ * Read PID from PID file
21
+ */
22
+ async function readPidFile(stateDir) {
23
+ const pidFile = path.join(stateDir, "herdctl.pid");
24
+ try {
25
+ const content = await fs.promises.readFile(pidFile, "utf-8");
26
+ const pid = parseInt(content.trim(), 10);
27
+ if (isNaN(pid)) {
28
+ return null;
29
+ }
30
+ return pid;
31
+ }
32
+ catch (error) {
33
+ if (error.code === "ENOENT") {
34
+ return null;
35
+ }
36
+ throw error;
37
+ }
38
+ }
39
+ /**
40
+ * Remove PID file from state directory
41
+ */
42
+ async function removePidFile(stateDir) {
43
+ const pidFile = path.join(stateDir, "herdctl.pid");
44
+ try {
45
+ await fs.promises.unlink(pidFile);
46
+ }
47
+ catch (error) {
48
+ // Ignore if file doesn't exist
49
+ if (error.code !== "ENOENT") {
50
+ throw error;
51
+ }
52
+ }
53
+ }
54
+ /**
55
+ * Check if a process is running
56
+ */
57
+ function isProcessRunning(pid) {
58
+ try {
59
+ // Sending signal 0 checks if process exists without actually signaling it
60
+ process.kill(pid, 0);
61
+ return true;
62
+ }
63
+ catch {
64
+ return false;
65
+ }
66
+ }
67
+ /**
68
+ * Send signal to process
69
+ */
70
+ function sendSignal(pid, signal) {
71
+ try {
72
+ process.kill(pid, signal);
73
+ return true;
74
+ }
75
+ catch {
76
+ return false;
77
+ }
78
+ }
79
+ /**
80
+ * Wait for a process to exit with timeout
81
+ */
82
+ async function waitForProcessExit(pid, timeoutSeconds) {
83
+ const startTime = Date.now();
84
+ const timeoutMs = timeoutSeconds * 1000;
85
+ while (Date.now() - startTime < timeoutMs) {
86
+ if (!isProcessRunning(pid)) {
87
+ return true;
88
+ }
89
+ // Check every 100ms
90
+ await new Promise((resolve) => setTimeout(resolve, 100));
91
+ }
92
+ return !isProcessRunning(pid);
93
+ }
94
+ /**
95
+ * Stop the fleet
96
+ */
97
+ export async function stopCommand(options) {
98
+ const stateDir = options.state || DEFAULT_STATE_DIR;
99
+ const timeout = options.timeout ?? DEFAULT_TIMEOUT;
100
+ const force = options.force ?? false;
101
+ // Read PID file
102
+ const pid = await readPidFile(stateDir);
103
+ if (pid === null) {
104
+ console.error("Error: No PID file found. Is the fleet running?");
105
+ console.error(`Checked: ${path.join(stateDir, "herdctl.pid")}`);
106
+ process.exit(1);
107
+ }
108
+ // Check if process is running
109
+ if (!isProcessRunning(pid)) {
110
+ console.error(`Error: Fleet process (PID ${pid}) is not running.`);
111
+ console.log("Cleaning up stale PID file...");
112
+ await removePidFile(stateDir);
113
+ console.log("PID file removed.");
114
+ process.exit(1);
115
+ }
116
+ if (force) {
117
+ // Force stop: send SIGKILL immediately
118
+ console.log(`Force stopping fleet (PID ${pid})...`);
119
+ const sent = sendSignal(pid, "SIGKILL");
120
+ if (!sent) {
121
+ console.error(`Error: Failed to send SIGKILL to process ${pid}.`);
122
+ process.exit(1);
123
+ }
124
+ // Wait briefly for the process to terminate
125
+ const exited = await waitForProcessExit(pid, 5);
126
+ if (!exited) {
127
+ console.error(`Error: Process ${pid} did not terminate after SIGKILL.`);
128
+ process.exit(1);
129
+ }
130
+ await removePidFile(stateDir);
131
+ console.log("Fleet stopped.");
132
+ }
133
+ else {
134
+ // Graceful stop: send SIGTERM first
135
+ console.log(`Stopping fleet (PID ${pid})...`);
136
+ const sent = sendSignal(pid, "SIGTERM");
137
+ if (!sent) {
138
+ console.error(`Error: Failed to send SIGTERM to process ${pid}.`);
139
+ process.exit(1);
140
+ }
141
+ console.log(`Waiting up to ${timeout} seconds for graceful shutdown...`);
142
+ const exited = await waitForProcessExit(pid, timeout);
143
+ if (exited) {
144
+ await removePidFile(stateDir);
145
+ console.log("Fleet stopped.");
146
+ }
147
+ else {
148
+ // Timeout reached, force kill
149
+ console.log(`Timeout reached. Force killing process ${pid}...`);
150
+ sendSignal(pid, "SIGKILL");
151
+ const killedExited = await waitForProcessExit(pid, 5);
152
+ if (!killedExited) {
153
+ console.error(`Error: Process ${pid} did not terminate after SIGKILL.`);
154
+ process.exit(1);
155
+ }
156
+ await removePidFile(stateDir);
157
+ console.log("Fleet stopped.");
158
+ }
159
+ }
160
+ }
161
+ //# sourceMappingURL=stop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stop.js","sourceRoot":"","sources":["../../src/commands/stop.ts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
1
+ /**
2
+ * herdctl trigger - Manually trigger an agent
3
+ *
4
+ * Commands:
5
+ * - herdctl trigger <agent> Trigger with default schedule
6
+ * - herdctl trigger <agent> --schedule <name> Trigger specific schedule
7
+ * - herdctl trigger <agent> --prompt "..." Custom prompt
8
+ * - herdctl trigger <agent> --wait Wait for job to complete
9
+ * - herdctl trigger <agent> --json JSON output
10
+ */
11
+ export interface TriggerOptions {
12
+ schedule?: string;
13
+ prompt?: string;
14
+ wait?: boolean;
15
+ json?: boolean;
16
+ state?: string;
17
+ config?: string;
18
+ }
19
+ /**
20
+ * Trigger an agent (herdctl trigger)
21
+ */
22
+ export declare function triggerCommand(agentName: string, options: TriggerOptions): Promise<void>;
23
+ //# sourceMappingURL=trigger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trigger.d.ts","sourceRoot":"","sources":["../../src/commands/trigger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAaH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAoGD;;GAEG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,IAAI,CAAC,CA2Rf"}