@songsid/agend 2.1.4-beta.15 → 2.1.4-beta.17

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/dist/daemon.js CHANGED
@@ -161,6 +161,11 @@ export class AutoPauseController {
161
161
  recordActivity(now = Date.now()) {
162
162
  this.lastActivityAt = now;
163
163
  }
164
+ /** Apply a new idle threshold and start a fresh countdown from this update. */
165
+ reconfigure(thresholdMs, now = Date.now()) {
166
+ this.thresholdMs = Math.max(0, thresholdMs);
167
+ this.lastActivityAt = now;
168
+ }
164
169
  observe(state, now = Date.now()) {
165
170
  if (this.pausedAt !== null || this.thresholdMs <= 0)
166
171
  return false;
@@ -1014,6 +1019,9 @@ export class Daemon extends EventEmitter {
1014
1019
  });
1015
1020
  }
1016
1021
  }
1022
+ else if (msg.type === "config_update") {
1023
+ this.applyConfigUpdate(msg.config);
1024
+ }
1017
1025
  else if (msg.type === "steer") {
1018
1026
  const meta = (msg.meta ?? {});
1019
1027
  this.steerMessage(msg.content, meta);
@@ -2558,6 +2566,78 @@ export class Daemon extends EventEmitter {
2558
2566
  const raw = this.config.tool_progress;
2559
2567
  return raw === "standard" || raw === "verbose" ? raw : "off";
2560
2568
  }
2569
+ /**
2570
+ * Apply a tool-progress setting without restarting the CLI session.
2571
+ *
2572
+ * Drop the current accumulator at the boundary: verbose entries may contain
2573
+ * command previews which must not survive a downgrade to standard/off, and a
2574
+ * newly enabled level should start with a clean, internally consistent list.
2575
+ */
2576
+ updateToolProgress(level) {
2577
+ const previous = this.toolProgressLevel();
2578
+ this.config.tool_progress = level;
2579
+ if (this.toolProgressLevel() !== previous)
2580
+ this.resetToolProgress();
2581
+ }
2582
+ /** Snapshot the configuration actually owned by this live daemon. */
2583
+ getConfigSnapshot() {
2584
+ return structuredClone(this.config);
2585
+ }
2586
+ /**
2587
+ * Apply the whitelisted hot configuration carried by FleetManager IPC.
2588
+ * null removes an optional value; invalid/unlisted fields are ignored rather
2589
+ * than allowing another client on the per-instance socket to mutate cold
2590
+ * process/session settings.
2591
+ */
2592
+ applyConfigUpdate(value) {
2593
+ if (!value || typeof value !== "object" || Array.isArray(value))
2594
+ return;
2595
+ const update = value;
2596
+ if (update.tool_progress === null || ["off", "standard", "verbose"].includes(String(update.tool_progress))) {
2597
+ this.updateToolProgress(update.tool_progress === null ? undefined : update.tool_progress);
2598
+ }
2599
+ if (typeof update.mcp_proxy_reply === "boolean")
2600
+ this.config.mcp_proxy_reply = update.mcp_proxy_reply;
2601
+ else if (update.mcp_proxy_reply === null)
2602
+ delete this.config.mcp_proxy_reply;
2603
+ if (typeof update.warm_cap === "number" && Number.isInteger(update.warm_cap) && update.warm_cap >= 0)
2604
+ this.config.warm_cap = update.warm_cap;
2605
+ else if (update.warm_cap === null)
2606
+ delete this.config.warm_cap;
2607
+ const nextAutoPause = typeof update.auto_pause_after === "number"
2608
+ && Number.isFinite(update.auto_pause_after)
2609
+ && update.auto_pause_after >= 0
2610
+ ? update.auto_pause_after
2611
+ : update.auto_pause_after === null ? 0 : undefined;
2612
+ if (nextAutoPause !== undefined) {
2613
+ const previousAutoPause = typeof this.config.auto_pause_after === "number" ? this.config.auto_pause_after : 0;
2614
+ if (update.auto_pause_after === null)
2615
+ delete this.config.auto_pause_after;
2616
+ else
2617
+ this.config.auto_pause_after = nextAutoPause;
2618
+ if (nextAutoPause !== previousAutoPause) {
2619
+ const isGeneral = this.config.general_topic === true || this.name === "general";
2620
+ this.autoPauseController.reconfigure((isGeneral ? 0 : nextAutoPause) * 60_000);
2621
+ }
2622
+ }
2623
+ for (const key of ["display_name", "description"]) {
2624
+ if (typeof update[key] === "string")
2625
+ this.config[key] = update[key];
2626
+ else if (update[key] === null)
2627
+ delete this.config[key];
2628
+ }
2629
+ if (Array.isArray(update.tags) && update.tags.every(tag => typeof tag === "string"))
2630
+ this.config.tags = [...update.tags];
2631
+ else if (update.tags === null)
2632
+ delete this.config.tags;
2633
+ if (["trace", "debug", "info", "warn", "error"].includes(String(update.log_level))) {
2634
+ const level = update.log_level;
2635
+ if (this.config.log_level !== level) {
2636
+ this.config.log_level = level;
2637
+ this.logger.level = level;
2638
+ }
2639
+ }
2640
+ }
2561
2641
  /**
2562
2642
  * Accumulate one semantic progress line for the channel bubble and schedule
2563
2643
  * a coalesced broadcast. Separate from publishActivity on purpose: that one