portable-agent-layer 0.76.0 → 0.77.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.
@@ -6,6 +6,7 @@
6
6
  * `pal cli server start|stop|status` owns the process; this file only serves.
7
7
  */
8
8
 
9
+ import { autoUpdateStatus, spawnAutoUpdate } from "../../hooks/lib/auto-update";
9
10
  import { loadMachine } from "../../hooks/lib/machine";
10
11
  import { readAllProjects } from "../../hooks/lib/projects";
11
12
  import { isServesKind, setServes } from "../../hooks/lib/serves";
@@ -25,6 +26,7 @@ import {
25
26
  isQuadrant,
26
27
  QUADRANTS,
27
28
  readInstallSettings,
29
+ setAutoUpdate,
28
30
  setIscStatus,
29
31
  setPlacement,
30
32
  type WriteOutcome,
@@ -255,6 +257,26 @@ async function readWrite(request: Request): Promise<Response> {
255
257
  return json({ marked: markRead(ids as string[]) });
256
258
  }
257
259
 
260
+ async function autoUpdateWrite(request: Request): Promise<Response> {
261
+ const body = await readBody(request);
262
+ if (!body) return json({ error: "expected a JSON body" }, 400);
263
+ const { enabled } = body;
264
+ if (typeof enabled !== "boolean") {
265
+ return json({ error: "enabled must be true or false" }, 400);
266
+ }
267
+ const outcome = setAutoUpdate(enabled);
268
+ return outcome.ok ? json(autoUpdateStatus()) : answer(outcome, {});
269
+ }
270
+
271
+ /**
272
+ * The button runs the update the daily gate would have run, bypassing the
273
+ * schedule but not the dirty-tree guard the child applies to itself.
274
+ */
275
+ function updateNow(): Promise<Response> {
276
+ spawnAutoUpdate();
277
+ return Promise.resolve(json({ started: true }, 202));
278
+ }
279
+
258
280
  async function prefsWrite(request: Request): Promise<Response> {
259
281
  const body = await readBody(request);
260
282
  if (!body) return json({ error: "expected a JSON body" }, 400);
@@ -270,6 +292,8 @@ const WRITES: Record<string, (request: Request) => Promise<Response>> = {
270
292
  "/api/snooze": snoozeWrite,
271
293
  "/api/attention/read": readWrite,
272
294
  "/api/prefs": prefsWrite,
295
+ "/api/update": autoUpdateWrite,
296
+ "/api/update/run": updateNow,
273
297
  };
274
298
 
275
299
  export function startControlRoom(port: number = DEFAULT_PORT) {
@@ -312,6 +336,8 @@ export function startControlRoom(port: number = DEFAULT_PORT) {
312
336
  return json(readInstallSettings());
313
337
  case "/api/prefs":
314
338
  return json(readPrefs());
339
+ case "/api/update":
340
+ return json(autoUpdateStatus());
315
341
  case "/api/attention":
316
342
  return json(attention());
317
343
  case "/api/status":