@juanibiapina/pi-gob 0.6.0 → 0.7.0

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.
package/package.json CHANGED
@@ -1,19 +1,13 @@
1
1
  {
2
2
  "name": "@juanibiapina/pi-gob",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Pi extension for managing gob background jobs",
5
5
  "type": "module",
6
- "main": "dist/index.js",
7
- "types": "./dist/index.d.ts",
8
6
  "scripts": {
9
- "clean": "rm -rf dist",
10
- "build": "tsc -p tsconfig.build.json",
11
- "dev": "tsc -p tsconfig.build.json --watch",
12
- "check": "biome check --write --error-on-warnings . && tsc --noEmit",
13
- "prepublishOnly": "npm run clean && npm run build && npm run check"
7
+ "check": "biome check --write --error-on-warnings . && tsc --noEmit"
14
8
  },
15
9
  "files": [
16
- "dist/**/*",
10
+ "src/**/*",
17
11
  "README.md"
18
12
  ],
19
13
  "keywords": [
@@ -25,7 +19,7 @@
25
19
  ],
26
20
  "pi": {
27
21
  "extensions": [
28
- "./dist/index.js"
22
+ "./src/index.ts"
29
23
  ]
30
24
  },
31
25
  "author": "Juan Ibiapina",
@@ -37,10 +31,6 @@
37
31
  "engines": {
38
32
  "node": ">=20.0.0"
39
33
  },
40
- "peerDependencies": {
41
- "@earendil-works/pi-coding-agent": "*",
42
- "@earendil-works/pi-tui": "*"
43
- },
44
34
  "devDependencies": {
45
35
  "@biomejs/biome": "2.4.15",
46
36
  "@earendil-works/pi-coding-agent": "^0.75.3",
@@ -0,0 +1,240 @@
1
+ /**
2
+ * Daemon client for connecting to gob daemon via Unix socket.
3
+ * Uses the newline-delimited JSON protocol defined in gob's daemon package.
4
+ */
5
+
6
+ import * as net from "node:net";
7
+ import * as os from "node:os";
8
+ import * as path from "node:path";
9
+ import type { Event, JobResponse, Request, Response } from "./types.js";
10
+
11
+ /**
12
+ * Get the gob daemon socket path.
13
+ * Uses $XDG_RUNTIME_DIR/gob/daemon.sock if set.
14
+ * Falls back to ~/Library/Application Support/gob/daemon.sock on macOS
15
+ * (matching adrg/xdg Go library behavior).
16
+ * Falls back to /run/user/<uid>/gob/daemon.sock on Linux.
17
+ */
18
+ function getSocketPath(): string {
19
+ const xdgRuntime = process.env.XDG_RUNTIME_DIR;
20
+ if (xdgRuntime) {
21
+ return path.join(xdgRuntime, "gob", "daemon.sock");
22
+ }
23
+ // macOS fallback — adrg/xdg uses ~/Library/Application Support as RuntimeDir
24
+ if (process.platform === "darwin") {
25
+ return path.join(os.homedir(), "Library", "Application Support", "gob", "daemon.sock");
26
+ }
27
+ // Linux fallback if XDG_RUNTIME_DIR not set
28
+ return path.join("/run/user", String(process.getuid?.()), "gob", "daemon.sock");
29
+ }
30
+
31
+ /**
32
+ * Send a single request over a new ephemeral connection and return the response.
33
+ * The daemon closes the connection after each response (except subscribe).
34
+ */
35
+ async function sendEphemeralRequest(socketPath: string, req: Request): Promise<Response> {
36
+ return new Promise((resolve, reject) => {
37
+ const conn = net.createConnection(socketPath);
38
+ let buffer = "";
39
+
40
+ conn.on("connect", () => {
41
+ conn.write(`${JSON.stringify(req)}\n`);
42
+ });
43
+
44
+ conn.on("data", (data) => {
45
+ buffer += data.toString();
46
+ const newlineIdx = buffer.indexOf("\n");
47
+ if (newlineIdx !== -1) {
48
+ const line = buffer.slice(0, newlineIdx);
49
+ try {
50
+ const resp = JSON.parse(line) as Response;
51
+ conn.destroy();
52
+ resolve(resp);
53
+ } catch (err) {
54
+ conn.destroy();
55
+ reject(new Error(`Failed to parse response: ${err}`));
56
+ }
57
+ }
58
+ });
59
+
60
+ conn.on("error", (err) => {
61
+ reject(err);
62
+ });
63
+
64
+ conn.on("close", () => {
65
+ if (buffer.trim()) {
66
+ try {
67
+ resolve(JSON.parse(buffer.trim()) as Response);
68
+ } catch {
69
+ reject(new Error("Connection closed before complete response"));
70
+ }
71
+ }
72
+ });
73
+
74
+ // Timeout after 5 seconds
75
+ conn.setTimeout(5000, () => {
76
+ conn.destroy();
77
+ reject(new Error("Connection timed out"));
78
+ });
79
+ });
80
+ }
81
+
82
+ export class DaemonClient {
83
+ private socketPath: string;
84
+ private subscriptionConn: net.Socket | null = null;
85
+ private _connected = false;
86
+
87
+ constructor() {
88
+ this.socketPath = getSocketPath();
89
+ }
90
+
91
+ get connected(): boolean {
92
+ return this._connected;
93
+ }
94
+
95
+ /**
96
+ * Probe the daemon socket and verify it's reachable.
97
+ * Does NOT auto-start the daemon.
98
+ * Returns true if daemon is running, false otherwise.
99
+ */
100
+ async connect(): Promise<boolean> {
101
+ try {
102
+ const resp = await sendEphemeralRequest(this.socketPath, {
103
+ type: "version",
104
+ payload: { client_version: "pi-extension" },
105
+ });
106
+ if (resp.success) {
107
+ this._connected = true;
108
+ return true;
109
+ }
110
+ return false;
111
+ } catch {
112
+ return false;
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Send a request to the daemon over an ephemeral connection.
118
+ */
119
+ async sendRequest(type: string, payload?: Record<string, unknown>): Promise<Response> {
120
+ const req: Request = { type: type as Request["type"] };
121
+ if (payload) {
122
+ req.payload = payload;
123
+ }
124
+ return sendEphemeralRequest(this.socketPath, req);
125
+ }
126
+
127
+ /**
128
+ * List jobs, optionally filtered by workdir.
129
+ */
130
+ async list(workdir?: string): Promise<JobResponse[]> {
131
+ const payload: Record<string, unknown> = {};
132
+ if (workdir) {
133
+ payload.workdir = workdir;
134
+ }
135
+ const resp = await this.sendRequest("list", payload);
136
+ if (!resp.success) {
137
+ throw new Error(`list failed: ${resp.error}`);
138
+ }
139
+ const jobs = resp.data?.jobs;
140
+ if (!jobs || !Array.isArray(jobs)) {
141
+ return [];
142
+ }
143
+ return jobs as JobResponse[];
144
+ }
145
+
146
+ /**
147
+ * Subscribe to daemon events. Returns an unsubscribe function.
148
+ * The subscription uses a persistent connection that streams events.
149
+ *
150
+ * @param workdir - Filter events to jobs in this workdir
151
+ * @param onEvent - Callback for each event
152
+ * @param onError - Callback when the subscription disconnects
153
+ */
154
+ subscribe(workdir: string | undefined, onEvent: (event: Event) => void, onError: (err: Error) => void): () => void {
155
+ // Close existing subscription if any
156
+ this.closeSubscription();
157
+
158
+ const conn = net.createConnection(this.socketPath);
159
+ this.subscriptionConn = conn;
160
+ let buffer = "";
161
+ let gotInitialResponse = false;
162
+
163
+ conn.on("connect", () => {
164
+ const req: Request = { type: "subscribe" };
165
+ if (workdir) {
166
+ req.payload = { workdir };
167
+ }
168
+ conn.write(`${JSON.stringify(req)}\n`);
169
+ });
170
+
171
+ conn.on("data", (data) => {
172
+ buffer += data.toString();
173
+ // Process all complete lines
174
+ for (let newlineIdx = buffer.indexOf("\n"); newlineIdx !== -1; newlineIdx = buffer.indexOf("\n")) {
175
+ const line = buffer.slice(0, newlineIdx);
176
+ buffer = buffer.slice(newlineIdx + 1);
177
+
178
+ if (!line.trim()) continue;
179
+
180
+ try {
181
+ const parsed = JSON.parse(line);
182
+
183
+ if (!gotInitialResponse) {
184
+ // First message is the subscribe response
185
+ gotInitialResponse = true;
186
+ if (!parsed.success) {
187
+ conn.destroy();
188
+ onError(new Error(`Subscribe failed: ${parsed.error}`));
189
+ return;
190
+ }
191
+ continue;
192
+ }
193
+
194
+ // Subsequent messages are events
195
+ onEvent(parsed as Event);
196
+ } catch {
197
+ // Skip malformed lines
198
+ }
199
+ }
200
+ });
201
+
202
+ conn.on("error", (err) => {
203
+ this.subscriptionConn = null;
204
+ onError(err);
205
+ });
206
+
207
+ conn.on("close", () => {
208
+ const wasSubscription = this.subscriptionConn === conn;
209
+ if (wasSubscription) {
210
+ this.subscriptionConn = null;
211
+ onError(new Error("Subscription connection closed"));
212
+ }
213
+ });
214
+
215
+ // Return unsubscribe function
216
+ return () => {
217
+ if (this.subscriptionConn === conn) {
218
+ this.closeSubscription();
219
+ }
220
+ };
221
+ }
222
+
223
+ /**
224
+ * Close the subscription connection.
225
+ */
226
+ private closeSubscription(): void {
227
+ if (this.subscriptionConn) {
228
+ this.subscriptionConn.destroy();
229
+ this.subscriptionConn = null;
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Disconnect from the daemon, closing the subscription.
235
+ */
236
+ disconnect(): void {
237
+ this.closeSubscription();
238
+ this._connected = false;
239
+ }
240
+ }
package/src/index.ts ADDED
@@ -0,0 +1,439 @@
1
+ /**
2
+ * Gob Extension
3
+ *
4
+ * Manages gob background jobs from within pi.
5
+ * Connects to the gob daemon via Unix socket for real-time job monitoring.
6
+ * Emits powerbar:update events with segment id "gob" showing running jobs.
7
+ * Use /gob to view and interact with running and stopped jobs.
8
+ */
9
+
10
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
11
+ import { DynamicBorder } from "@earendil-works/pi-coding-agent";
12
+ import { Container, Key, matchesKey, type SelectItem, SelectList, Text } from "@earendil-works/pi-tui";
13
+ import { DaemonClient } from "./daemon-client.js";
14
+ import { formatJobSegment } from "./segment.js";
15
+ import type { Event, JobResponse } from "./types.js";
16
+
17
+ const SEGMENT_ID = "gob";
18
+ const RECONNECT_DELAY_MS = 5000;
19
+ const TICK_INTERVAL_MS = 1000;
20
+
21
+ export default function (pi: ExtensionAPI) {
22
+ // Register powerbar segment
23
+ pi.events.emit("powerbar:register-segment", { id: "gob", label: "Gob Jobs" });
24
+
25
+ const client = new DaemonClient();
26
+
27
+ // Map of running jobs by ID (only running jobs for the current workdir)
28
+ const runningJobs = new Map<string, JobResponse>();
29
+
30
+ // Session CWD
31
+ let sessionCwd: string | undefined;
32
+
33
+ // Cleanup handles
34
+ let unsubscribe: (() => void) | undefined;
35
+ let reconnectTimer: ReturnType<typeof setTimeout> | undefined;
36
+ let tickInterval: ReturnType<typeof setInterval> | undefined;
37
+
38
+ /**
39
+ * Emit a powerbar:update event with current running jobs.
40
+ */
41
+ function updateSegment(): void {
42
+ const jobs = Array.from(runningJobs.values());
43
+
44
+ if (jobs.length === 0) {
45
+ // Clear the segment
46
+ pi.events.emit("powerbar:update", { id: SEGMENT_ID });
47
+ stopTick();
48
+ return;
49
+ }
50
+
51
+ const segment = formatJobSegment(jobs);
52
+
53
+ pi.events.emit("powerbar:update", {
54
+ id: SEGMENT_ID,
55
+ text: segment.text,
56
+ icon: segment.icon,
57
+ color: segment.color,
58
+ });
59
+
60
+ startTick();
61
+ }
62
+
63
+ /**
64
+ * Start the 1-second tick interval for updating elapsed times.
65
+ */
66
+ function startTick(): void {
67
+ if (tickInterval) return;
68
+ tickInterval = setInterval(() => {
69
+ if (runningJobs.size > 0) {
70
+ updateSegment();
71
+ } else {
72
+ stopTick();
73
+ }
74
+ }, TICK_INTERVAL_MS);
75
+ }
76
+
77
+ /**
78
+ * Stop the tick interval.
79
+ */
80
+ function stopTick(): void {
81
+ if (tickInterval) {
82
+ clearInterval(tickInterval);
83
+ tickInterval = undefined;
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Handle a daemon event by updating the running jobs map.
89
+ */
90
+ function handleEvent(event: Event): void {
91
+ const job = event.job;
92
+
93
+ switch (event.type) {
94
+ case "job_added":
95
+ case "job_started":
96
+ case "run_started":
97
+ case "job_updated":
98
+ case "ports_updated":
99
+ if (job.status === "running") {
100
+ runningJobs.set(job.id, job);
101
+ } else {
102
+ runningJobs.delete(job.id);
103
+ }
104
+ break;
105
+
106
+ case "job_stopped":
107
+ case "run_stopped":
108
+ runningJobs.delete(job.id);
109
+ break;
110
+
111
+ case "job_removed":
112
+ case "run_removed":
113
+ runningJobs.delete(job.id);
114
+ break;
115
+ }
116
+
117
+ updateSegment();
118
+ }
119
+
120
+ /**
121
+ * Connect to daemon, fetch initial state, and subscribe to events.
122
+ */
123
+ async function connectAndSubscribe(): Promise<void> {
124
+ // Clear any pending reconnect
125
+ if (reconnectTimer) {
126
+ clearTimeout(reconnectTimer);
127
+ reconnectTimer = undefined;
128
+ }
129
+
130
+ const ok = await client.connect();
131
+ if (!ok) {
132
+ // Daemon not running, schedule reconnect
133
+ scheduleReconnect();
134
+ return;
135
+ }
136
+
137
+ try {
138
+ // Fetch initial list of jobs
139
+ const jobs = await client.list(sessionCwd);
140
+ runningJobs.clear();
141
+ for (const job of jobs) {
142
+ if (job.status === "running") {
143
+ runningJobs.set(job.id, job);
144
+ }
145
+ }
146
+ updateSegment();
147
+ } catch {
148
+ // Failed to list, schedule reconnect
149
+ scheduleReconnect();
150
+ return;
151
+ }
152
+
153
+ // Subscribe to events
154
+ unsubscribe = client.subscribe(
155
+ sessionCwd,
156
+ (event) => handleEvent(event),
157
+ (_err) => {
158
+ // Subscription disconnected, try to reconnect
159
+ unsubscribe = undefined;
160
+ runningJobs.clear();
161
+ updateSegment();
162
+ scheduleReconnect();
163
+ },
164
+ );
165
+ }
166
+
167
+ /**
168
+ * Schedule a reconnection attempt.
169
+ */
170
+ function scheduleReconnect(): void {
171
+ if (reconnectTimer) return;
172
+ reconnectTimer = setTimeout(() => {
173
+ reconnectTimer = undefined;
174
+ connectAndSubscribe();
175
+ }, RECONNECT_DELAY_MS);
176
+ }
177
+
178
+ /**
179
+ * Cleanup all connections and timers.
180
+ */
181
+ function cleanup(): void {
182
+ if (unsubscribe) {
183
+ unsubscribe();
184
+ unsubscribe = undefined;
185
+ }
186
+ if (reconnectTimer) {
187
+ clearTimeout(reconnectTimer);
188
+ reconnectTimer = undefined;
189
+ }
190
+ stopTick();
191
+ client.disconnect();
192
+ runningJobs.clear();
193
+ }
194
+
195
+ // ── Lifecycle ──────────────────────────────────────────
196
+
197
+ pi.on("session_start", async (_event, ctx) => {
198
+ sessionCwd = ctx.cwd;
199
+ await connectAndSubscribe();
200
+ });
201
+
202
+ pi.on("session_shutdown", async () => {
203
+ cleanup();
204
+ pi.events.emit("powerbar:update", { id: SEGMENT_ID });
205
+ });
206
+
207
+ // ── Job list UI ──
208
+
209
+ async function fetchJobs(): Promise<JobResponse[]> {
210
+ // Try daemon protocol first
211
+ if (client.connected) {
212
+ try {
213
+ return await client.list(sessionCwd);
214
+ } catch {
215
+ // Fall through to CLI
216
+ }
217
+ }
218
+
219
+ // CLI fallback
220
+ const result = await pi.exec("gob", ["list"]);
221
+ if (result.code !== 0) {
222
+ return [];
223
+ }
224
+ return parseGobList(result.stdout);
225
+ }
226
+
227
+ function parseGobList(output: string): JobResponse[] {
228
+ const jobs: JobResponse[] = [];
229
+ const lines = output.split("\n").filter((l) => l.trim().length > 0);
230
+
231
+ let i = 0;
232
+ while (i < lines.length) {
233
+ const line = lines[i];
234
+ // Format: <job_id>: [<pid>] <status> (<exit_code>): <command>
235
+ const match = line.match(/^(\S+): \[(\S+)\] (\S+)(?: \((\d+)\))?: (.+)$/);
236
+ if (match) {
237
+ const description =
238
+ i + 1 < lines.length && lines[i + 1].startsWith(" ") ? lines[i + 1].trim() : undefined;
239
+
240
+ if (description) i++;
241
+
242
+ jobs.push({
243
+ id: match[1],
244
+ pid: Number.parseInt(match[2], 10) || 0,
245
+ status: match[3],
246
+ command: match[5].split(" "),
247
+ workdir: "",
248
+ description,
249
+ created_at: "",
250
+ started_at: "",
251
+ stdout_path: "",
252
+ stderr_path: "",
253
+ exit_code: match[4] ? Number.parseInt(match[4], 10) : undefined,
254
+ run_count: 0,
255
+ success_count: 0,
256
+ failure_count: 0,
257
+ success_rate: 0,
258
+ avg_duration_ms: 0,
259
+ failure_avg_duration_ms: 0,
260
+ min_duration_ms: 0,
261
+ max_duration_ms: 0,
262
+ });
263
+ }
264
+ i++;
265
+ }
266
+
267
+ return jobs;
268
+ }
269
+
270
+ async function executeJobAction(action: string, jobId: string): Promise<{ message: string; success: boolean }> {
271
+ // Try daemon protocol first
272
+ if (client.connected) {
273
+ try {
274
+ const resp = await client.sendRequest(action, { job_id: jobId });
275
+ if (resp.success) {
276
+ const verb =
277
+ action === "stop"
278
+ ? "Stopped"
279
+ : action === "start"
280
+ ? "Started"
281
+ : action === "restart"
282
+ ? "Restarted"
283
+ : action === "remove"
284
+ ? "Removed"
285
+ : action;
286
+ return { message: `${verb} ${jobId}`, success: true };
287
+ }
288
+ return { message: `Error: ${resp.error}`, success: false };
289
+ } catch {
290
+ // Fall through to CLI
291
+ }
292
+ }
293
+
294
+ // CLI fallback
295
+ const result = await pi.exec("gob", [action, jobId]);
296
+ if (result.code === 0) {
297
+ const verb =
298
+ action === "stop"
299
+ ? "Stopped"
300
+ : action === "start"
301
+ ? "Started"
302
+ : action === "restart"
303
+ ? "Restarted"
304
+ : action === "remove"
305
+ ? "Removed"
306
+ : action;
307
+ return { message: `${verb} ${jobId}`, success: true };
308
+ }
309
+ return { message: `Error: ${result.stderr}`, success: false };
310
+ }
311
+
312
+ const showJobList = async (ctx: ExtensionContext) => {
313
+ if (!ctx.hasUI) {
314
+ ctx.ui.notify("No UI available", "error");
315
+ return;
316
+ }
317
+
318
+ const jobs = await fetchJobs();
319
+
320
+ if (jobs.length === 0) {
321
+ ctx.ui.notify("No gob jobs found", "info");
322
+ return;
323
+ }
324
+
325
+ await ctx.ui.custom<void>((tui, theme, _kb, done) => {
326
+ const container = new Container();
327
+
328
+ // Top border
329
+ container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
330
+
331
+ // Title
332
+ container.addChild(new Text(theme.fg("accent", theme.bold(" Gob Jobs")), 0, 0));
333
+
334
+ // Build select items
335
+ const items: SelectItem[] = jobs.map((job) => {
336
+ const statusColor = job.status === "running" ? "success" : "muted";
337
+ const statusIcon = job.status === "running" ? "●" : "○";
338
+ const exitInfo =
339
+ job.status === "stopped" && job.exit_code != null ? theme.fg("dim", ` (${job.exit_code})`) : "";
340
+ const status = theme.fg(statusColor, statusIcon);
341
+ const cmdStr = job.command.join(" ");
342
+ const label = `${status} ${theme.fg("dim", job.id)} ${cmdStr}${exitInfo}`;
343
+ const description = job.description ? theme.fg("muted", job.description) : undefined;
344
+ return {
345
+ value: job.id,
346
+ label,
347
+ description,
348
+ };
349
+ });
350
+
351
+ const visibleRows = Math.min(jobs.length, 15);
352
+ let currentIndex = 0;
353
+
354
+ const selectList = new SelectList(items, visibleRows, {
355
+ selectedPrefix: (t) => theme.fg("accent", t),
356
+ selectedText: (t) => t,
357
+ description: (t) => t,
358
+ scrollInfo: (t) => theme.fg("dim", t),
359
+ noMatch: (t) => theme.fg("warning", t),
360
+ });
361
+
362
+ selectList.onSelect = async (item) => {
363
+ done();
364
+ const job = jobs.find((j) => j.id === item.value);
365
+ if (job) {
366
+ await showJobActions(ctx, job);
367
+ }
368
+ };
369
+ selectList.onCancel = () => done();
370
+ selectList.onSelectionChange = (item) => {
371
+ currentIndex = items.indexOf(item);
372
+ };
373
+ container.addChild(selectList);
374
+
375
+ // Help text
376
+ container.addChild(new Text(theme.fg("dim", " ↑↓ navigate • ←→ page • enter actions • esc close"), 0, 0));
377
+
378
+ // Bottom border
379
+ container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
380
+
381
+ return {
382
+ render: (w) => container.render(w),
383
+ invalidate: () => container.invalidate(),
384
+ handleInput: (data) => {
385
+ if (matchesKey(data, Key.left)) {
386
+ currentIndex = Math.max(0, currentIndex - visibleRows);
387
+ selectList.setSelectedIndex(currentIndex);
388
+ } else if (matchesKey(data, Key.right)) {
389
+ currentIndex = Math.min(items.length - 1, currentIndex + visibleRows);
390
+ selectList.setSelectedIndex(currentIndex);
391
+ } else {
392
+ selectList.handleInput(data);
393
+ }
394
+ tui.requestRender();
395
+ },
396
+ };
397
+ });
398
+ };
399
+
400
+ const showJobActions = async (ctx: ExtensionContext, job: JobResponse) => {
401
+ const actions: string[] = [];
402
+
403
+ if (job.status === "running") {
404
+ actions.push("logs", "stop", "restart");
405
+ } else {
406
+ actions.push("logs", "start", "restart", "remove");
407
+ }
408
+
409
+ const cmdStr = job.command.join(" ");
410
+ const action = await ctx.ui.select(`${job.id}: ${cmdStr}`, actions);
411
+ if (!action) return;
412
+
413
+ switch (action) {
414
+ case "logs": {
415
+ const result = await pi.exec("gob", ["logs", "--tail", "50", job.id], { timeout: 5000 });
416
+ if (result.code === 0 && result.stdout.trim()) {
417
+ ctx.ui.notify(`Logs for ${job.id}:\n${result.stdout.trim()}`, "info");
418
+ } else {
419
+ ctx.ui.notify(`No logs for ${job.id}`, "info");
420
+ }
421
+ break;
422
+ }
423
+ case "stop":
424
+ case "start":
425
+ case "restart":
426
+ case "remove": {
427
+ const result = await executeJobAction(action, job.id);
428
+ ctx.ui.notify(result.message, result.success ? "info" : "error");
429
+ break;
430
+ }
431
+ }
432
+ };
433
+
434
+ // Register /gob command
435
+ pi.registerCommand("gob", {
436
+ description: "View and manage gob background jobs",
437
+ handler: async (_args, ctx) => showJobList(ctx),
438
+ });
439
+ }