@songsid/agend 2.4.0-beta.16 → 2.4.0-beta.18

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 (172) hide show
  1. package/dist/auth-api.js +2 -0
  2. package/dist/auth-api.js.map +1 -1
  3. package/dist/backend/claude-code.d.ts +10 -1
  4. package/dist/backend/claude-code.js +7 -2
  5. package/dist/backend/claude-code.js.map +1 -1
  6. package/dist/backend/claude-transcript-errors.d.ts +4 -0
  7. package/dist/backend/claude-transcript-errors.js +5 -1
  8. package/dist/backend/claude-transcript-errors.js.map +1 -1
  9. package/dist/backend/types.d.ts +6 -0
  10. package/dist/backend/types.js.map +1 -1
  11. package/dist/build-provenance.json +1 -1
  12. package/dist/claude-credential-launch.d.ts +1 -0
  13. package/dist/claude-credential-launch.js +13 -2
  14. package/dist/claude-credential-launch.js.map +1 -1
  15. package/dist/claude-credential-vault.d.ts +7 -1
  16. package/dist/claude-credential-vault.js +26 -1
  17. package/dist/claude-credential-vault.js.map +1 -1
  18. package/dist/claude-request-observation.d.ts +7 -0
  19. package/dist/claude-request-observation.js +26 -0
  20. package/dist/claude-request-observation.js.map +1 -0
  21. package/dist/cli-audited.js +11 -8
  22. package/dist/cli-audited.js.map +1 -1
  23. package/dist/daemon.d.ts +8 -0
  24. package/dist/daemon.js +68 -13
  25. package/dist/daemon.js.map +1 -1
  26. package/dist/fleet-context.d.ts +1 -0
  27. package/dist/fleet-manager.d.ts +28 -0
  28. package/dist/fleet-manager.js +222 -10
  29. package/dist/fleet-manager.js.map +1 -1
  30. package/dist/fleet-windows-runtime.d.ts +1 -1
  31. package/dist/fleet-windows-runtime.js +1 -1
  32. package/dist/fleet-windows-runtime.js.map +1 -1
  33. package/dist/fleet-yaml-stringify.d.ts +3 -0
  34. package/dist/fleet-yaml-stringify.js +79 -0
  35. package/dist/fleet-yaml-stringify.js.map +1 -0
  36. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +17 -3
  37. package/dist/host-monitoring-alert-policy.d.ts +71 -0
  38. package/dist/host-monitoring-alert-policy.js +150 -0
  39. package/dist/host-monitoring-alert-policy.js.map +1 -0
  40. package/dist/host-monitoring-alert-resources.d.ts +11 -0
  41. package/dist/host-monitoring-alert-resources.js +16 -0
  42. package/dist/host-monitoring-alert-resources.js.map +1 -0
  43. package/dist/host-monitoring-alert-settings.d.ts +14 -0
  44. package/dist/host-monitoring-alert-settings.js +63 -0
  45. package/dist/host-monitoring-alert-settings.js.map +1 -0
  46. package/dist/host-monitoring-alert-store.d.ts +49 -0
  47. package/dist/host-monitoring-alert-store.js +228 -0
  48. package/dist/host-monitoring-alert-store.js.map +1 -0
  49. package/dist/host-monitoring-alert-text.d.ts +7 -0
  50. package/dist/host-monitoring-alert-text.js +10 -0
  51. package/dist/host-monitoring-alert-text.js.map +1 -0
  52. package/dist/host-monitoring-alerts.d.ts +76 -0
  53. package/dist/host-monitoring-alerts.js +261 -0
  54. package/dist/host-monitoring-alerts.js.map +1 -0
  55. package/dist/host-monitoring-config.d.ts +2 -1
  56. package/dist/host-monitoring-config.js +8 -3
  57. package/dist/host-monitoring-config.js.map +1 -1
  58. package/dist/host-monitoring-footprint-policy.d.ts +45 -0
  59. package/dist/host-monitoring-footprint-policy.js +150 -0
  60. package/dist/host-monitoring-footprint-policy.js.map +1 -0
  61. package/dist/host-monitoring-footprint.d.ts +42 -0
  62. package/dist/host-monitoring-footprint.js +169 -0
  63. package/dist/host-monitoring-footprint.js.map +1 -0
  64. package/dist/host-monitoring-history-files.d.ts +2 -0
  65. package/dist/host-monitoring-history-files.js +16 -0
  66. package/dist/host-monitoring-history-files.js.map +1 -0
  67. package/dist/host-monitoring-history-policy.d.ts +57 -0
  68. package/dist/host-monitoring-history-policy.js +107 -0
  69. package/dist/host-monitoring-history-policy.js.map +1 -0
  70. package/dist/host-monitoring-history-store.d.ts +52 -0
  71. package/dist/host-monitoring-history-store.js +178 -0
  72. package/dist/host-monitoring-history-store.js.map +1 -0
  73. package/dist/host-monitoring-history-worker.d.ts +1 -0
  74. package/dist/host-monitoring-history-worker.js +66 -0
  75. package/dist/host-monitoring-history-worker.js.map +1 -0
  76. package/dist/host-monitoring-history.d.ts +80 -0
  77. package/dist/host-monitoring-history.js +301 -0
  78. package/dist/host-monitoring-history.js.map +1 -0
  79. package/dist/host-monitoring-platform.d.ts +73 -0
  80. package/dist/host-monitoring-platform.js +273 -0
  81. package/dist/host-monitoring-platform.js.map +1 -0
  82. package/dist/host-monitoring-process-identity.d.ts +8 -0
  83. package/dist/host-monitoring-process-identity.js +81 -0
  84. package/dist/host-monitoring-process-identity.js.map +1 -0
  85. package/dist/host-monitoring-runtime.d.ts +42 -0
  86. package/dist/host-monitoring-runtime.js +95 -0
  87. package/dist/host-monitoring-runtime.js.map +1 -0
  88. package/dist/host-monitoring-settings-store.d.ts +5 -0
  89. package/dist/host-monitoring-settings-store.js +49 -0
  90. package/dist/host-monitoring-settings-store.js.map +1 -0
  91. package/dist/host-monitoring.d.ts +108 -0
  92. package/dist/host-monitoring.js +157 -0
  93. package/dist/host-monitoring.js.map +1 -0
  94. package/dist/instance-lifecycle.js +2 -2
  95. package/dist/instance-lifecycle.js.map +1 -1
  96. package/dist/needs-you-hub.d.ts +1 -0
  97. package/dist/needs-you-hub.js +1 -0
  98. package/dist/needs-you-hub.js.map +1 -1
  99. package/dist/needs-you.d.ts +3 -2
  100. package/dist/needs-you.js +1 -0
  101. package/dist/needs-you.js.map +1 -1
  102. package/dist/public-web-gateway.js +11 -1
  103. package/dist/public-web-gateway.js.map +1 -1
  104. package/dist/runtime-cli-install.js +17 -16
  105. package/dist/runtime-cli-install.js.map +1 -1
  106. package/dist/settings-api.d.ts +5 -0
  107. package/dist/settings-api.js +70 -7
  108. package/dist/settings-api.js.map +1 -1
  109. package/dist/settings-baseline.d.ts +1 -0
  110. package/dist/settings-baseline.js +6 -4
  111. package/dist/settings-baseline.js.map +1 -1
  112. package/dist/settings-change.js +8 -0
  113. package/dist/settings-change.js.map +1 -1
  114. package/dist/settings-effect.d.ts +4 -0
  115. package/dist/settings-effect.js +25 -4
  116. package/dist/settings-effect.js.map +1 -1
  117. package/dist/topic-commands.js +4 -0
  118. package/dist/topic-commands.js.map +1 -1
  119. package/dist/transcript-monitor.d.ts +1 -0
  120. package/dist/transcript-monitor.js +18 -0
  121. package/dist/transcript-monitor.js.map +1 -1
  122. package/dist/ui/accounts-view.js +7 -5
  123. package/dist/ui/chat-store.js +21 -4
  124. package/dist/ui/claude-credentials.js +12 -1
  125. package/dist/ui/fleet-office-pack.js +2 -2
  126. package/dist/ui/fleet-office-play.js +142 -3
  127. package/dist/ui/fleet-office-skin.js +67 -2
  128. package/dist/ui/fleet-office-store.js +41 -0
  129. package/dist/ui/fleet-office-zones.js +15 -8
  130. package/dist/ui/fleet-office.js +126 -21
  131. package/dist/ui/host-alerts.js +23 -0
  132. package/dist/ui/host-footprint.js +17 -0
  133. package/dist/ui/host-health-model.js +42 -0
  134. package/dist/ui/host-health.js +79 -0
  135. package/dist/ui/host-time.js +5 -0
  136. package/dist/ui/panel-chat.js +101 -43
  137. package/dist/ui/panel-fleet.js +24 -11
  138. package/dist/ui/panel-hub.js +5 -1
  139. package/dist/ui/panel-needs.js +27 -16
  140. package/dist/ui/panel-settings.js +4 -3
  141. package/dist/ui/search-dialog.js +8 -1
  142. package/dist/ui/settings-capabilities.js +2 -0
  143. package/dist/ui/settings-host-alerts.js +22 -0
  144. package/dist/ui/settings-host-monitoring.js +37 -18
  145. package/dist/ui/settings-registry.js +4 -1
  146. package/dist/ui/shared/accounts.css +8 -4
  147. package/dist/ui/shared/agent-sheet.js +5 -2
  148. package/dist/ui/shared/app-i18n.js +2 -2
  149. package/dist/ui/shared/app-route.js +1 -1
  150. package/dist/ui/shared/app.css +87 -9
  151. package/dist/ui/shared/app.js +1 -0
  152. package/dist/ui/shared/chat-render.js +24 -9
  153. package/dist/ui/shared/chat-strings.js +4 -4
  154. package/dist/ui/shared/chat-thread.js +45 -11
  155. package/dist/ui/shared/instance-nav.js +47 -5
  156. package/dist/ui/shared/jump-idle.js +36 -0
  157. package/dist/ui/shared/theme.js +6 -2
  158. package/dist/ui/shared/ui-menu.js +17 -11
  159. package/dist/web-api.d.ts +3 -0
  160. package/dist/web-api.js +249 -4
  161. package/dist/web-api.js.map +1 -1
  162. package/dist/web-chat-history.d.ts +47 -2
  163. package/dist/web-chat-history.js +149 -11
  164. package/dist/web-chat-history.js.map +1 -1
  165. package/dist/web-guest-access.js +4 -4
  166. package/dist/web-guest-access.js.map +1 -1
  167. package/dist/web-shell-routes.d.ts +1 -1
  168. package/dist/web-shell-routes.js +1 -1
  169. package/dist/web-shell-routes.js.map +1 -1
  170. package/dist/web-upload.d.ts +1 -1
  171. package/dist/web-upload.js.map +1 -1
  172. package/package.json +1 -1
@@ -72,6 +72,7 @@ export interface FleetContext {
72
72
  /** A read-only, bounded pane capture tied to the current daemon/launch. */
73
73
  getPaneContextSource?(name: string): PaneContextSource | null;
74
74
  getSysInfo(): SysInfo;
75
+ hostHealthSnapshot?(): import('./host-monitoring.js').HostHealthSnapshot;
75
76
  /** Read cached CLI versions without triggering a probe. */
76
77
  getBackendCliVersionSnapshot?(): BackendCliVersionSnapshot;
77
78
  /** Refresh stale/missing CLI versions after the sysinfo reply has been sent. */
@@ -1,3 +1,4 @@
1
+ import { type HostAlertSettings } from './host-monitoring-alert-settings.js';
1
2
  import { type SetupTokenOwner, type SetupTokenRequest } from "./claude-setup-token.js";
2
3
  import { type ClaudeCredentialKind, type ClaudeCredentialMetadata, type CredentialActor } from "./claude-credential-vault.js";
3
4
  import { type ContactFileLease } from "./contact-auth-files.js";
@@ -346,6 +347,28 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
346
347
  readonly stormWindow: StormWindow;
347
348
  readonly spawnGate: SpawnGate;
348
349
  readonly memoryPressure: MemoryPressure;
350
+ private hostFootprint;
351
+ private hostFootprintEnabled;
352
+ private hostFootprintLabels;
353
+ private hostFootprintRoots;
354
+ private hostMonitor;
355
+ private hostHistory;
356
+ private hostAlerts;
357
+ private hostAlertConfig;
358
+ private hostAlertSettingsLoaded;
359
+ private hostAlertSettingsFailed;
360
+ private startHostMonitoringRuntime;
361
+ hostHistoryQuery(range: unknown, series: unknown): Promise<import('./host-monitoring-history.js').HostHistoryResult>;
362
+ hostMonitoringAvailable(): boolean;
363
+ private hostHealthSnapshotInternal;
364
+ hostHealthSnapshot(agentOffset?: number): import("./host-monitoring.js").HostHealthSnapshot;
365
+ hostAlertSettings(): HostAlertSettings;
366
+ saveHostAlertSettings(input: unknown): HostAlertSettings;
367
+ hostAlertAction(key: string, revision: number, actor: string, snoozeMs?: number): Promise<boolean>;
368
+ private hostNeedsYouItems;
369
+ /** Effective Settings view: the drive is intentionally outside FleetConfig/fleet.yaml. */
370
+ hostMonitoringSettings(): import('./host-monitoring-config.js').HostMonitoringConfig;
371
+ saveHostMonitoringSettings(patch: Partial<import('./host-monitoring-config.js').HostMonitoringConfig>): import('./host-monitoring-config.js').HostMonitoringConfig;
349
372
  /** Fleet-level backend reachability memory (fed by pty_error / startup panes). */
350
373
  readonly backendOutage: BackendOutageTracker;
351
374
  /** Stable for this FleetManager OS-process lifetime; Daemon objects have their own boot IDs. */
@@ -3320,6 +3343,11 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
3320
3343
  private landedInOwnChannel;
3321
3344
  /** #1920 §5.2 (#2085 review): a platform click's buttons are in the instance's own place — else not its channel's. */
3322
3345
  private clickInOwnChannel;
3346
+ /**
3347
+ * M-3491: the platform message id a reply to `id` uses on `adapterId`'s chat and thread — the copy there of the kept
3348
+ * web-chat message `id` names (#2281 posts) — or undefined when the chat keeps no such message or it has no copy there.
3349
+ */
3350
+ nativeReplyTo(instance: string, id: string, adapterId: string, chatId: string, threadId: string): string | undefined;
3323
3351
  captureReplyPreview(instance: string, args: Record<string, unknown>): ((result: unknown) => void) | undefined;
3324
3352
  private afterReplyRouted;
3325
3353
  /**
@@ -1,3 +1,15 @@
1
+ import { HostFootprint } from "./host-monitoring-footprint.js";
2
+ import { hostAlertSummary } from './host-monitoring-alert-text.js';
3
+ import { HostMonitoringAlerts } from './host-monitoring-alerts.js';
4
+ import { readHostAlertSettings, writeHostAlertSettings, defaultHostAlertSettings, parseHostAlertSettings } from './host-monitoring-alert-settings.js';
5
+ import { hostAlertResources } from './host-monitoring-alert-resources.js';
6
+ import { validateHostAlertRule } from './host-monitoring-alert-policy.js';
7
+ import { readHostMonitoringDrive, writeHostMonitoringDrive, validMonitoringDrive } from './host-monitoring-settings-store.js';
8
+ import { HostMonitoringHistory } from './host-monitoring-history.js';
9
+ import { HostMonitoringRuntime } from "./host-monitoring-runtime.js";
10
+ import { NativeHostMonitoring } from "./host-monitoring-platform.js";
11
+ import { disabledHostHealth } from "./host-monitoring.js";
12
+ import { monitoringConfig } from "./host-monitoring-config.js";
1
13
  import { ClaudeSetupTokens } from "./claude-setup-token.js";
2
14
  import { changeIdleClaudeCredential } from "./claude-credential-change.js";
3
15
  import { readClaudeCredentialSelection, claudeSubscriptionSuppressed } from "./claude-credential-launch.js";
@@ -102,6 +114,7 @@ import { MemoryPressure } from "./memory-pressure.js";
102
114
  import { replyDedupText, ReplyDeduper } from "./reply-dedup.js";
103
115
  import { isMap, isScalar, parseDocument } from "yaml";
104
116
  import { changedOutside, detachForWrite } from "./yaml-shared-nodes.js";
117
+ import { stringifyFleetYaml } from "./fleet-yaml-stringify.js";
105
118
  import { tmuxExecHelper } from "./tmux-exec-helper.js";
106
119
  import { kiroLogGate } from "./kiro-log-gate.js";
107
120
  const __filename = fileURLToPath(import.meta.url);
@@ -249,7 +262,7 @@ import { createNativeWindowsInstance, updateNativeWindowsInstance } from "./nati
249
262
  import { NativeInstanceConfigEdit, parseNativeInstanceCreate } from "./native-instance-input.js";
250
263
  import { LogService, thinkingOn } from "./log-service.js";
251
264
  import { viewHistory } from "./view-history.js";
252
- import { WebChatHistory, WEB_CHAT_TEXT_MAX, isWebMessageId, newWebMessageId, webChatFrom } from "./web-chat-history.js";
265
+ import { WebChatHistory, WEB_CHAT_TEXT_MAX, isWebMessageId, newWebMessageId, webChatFrom, webChatReplyRef } from "./web-chat-history.js";
253
266
  import { WEB_ECHO_COPIES_MAX, WEB_MIRROR_TIMEOUT_MS, webReactionEmoji, webReactionProblem } from "./web-reactions.js";
254
267
  import { WebChatDiskStore, isSafeInstanceDirName } from "./web-chat-store.js";
255
268
  import { WebChatArchive } from "./web-chat-archive.js";
@@ -803,6 +816,134 @@ export class FleetManager {
803
816
  stormWindow;
804
817
  spawnGate;
805
818
  memoryPressure;
819
+ hostFootprint = null;
820
+ hostFootprintEnabled = false;
821
+ hostFootprintLabels = new Map();
822
+ hostFootprintRoots() {
823
+ const roots = [];
824
+ this.hostFootprintLabels.clear();
825
+ for (const [name, daemon] of this.daemons) {
826
+ const root = daemon.hostFootprintRoot?.(), id = createHash("sha256").update(name).digest("hex").slice(0, 16);
827
+ roots.push({ id, pid: root?.pid ?? 0, owner: root?.owner ?? "unavailable", observedAt: root?.observedAt ?? 0, files: [join(this.getInstanceDir(name), "output.log")] });
828
+ if (roots.length > 128)
829
+ break;
830
+ this.hostFootprintLabels.set(id, this.fleetConfig?.instances[name]?.display_name ?? name);
831
+ }
832
+ return roots;
833
+ }
834
+ hostMonitor = null;
835
+ hostHistory = null;
836
+ hostAlerts = null;
837
+ hostAlertConfig = defaultHostAlertSettings();
838
+ hostAlertSettingsLoaded = false;
839
+ hostAlertSettingsFailed = false;
840
+ startHostMonitoringRuntime() {
841
+ if (!this.hostAlertSettingsLoaded) {
842
+ this.hostAlertSettingsLoaded = true;
843
+ try {
844
+ this.hostAlertConfig = readHostAlertSettings(this.dataDir);
845
+ }
846
+ catch {
847
+ this.hostAlertSettingsFailed = true;
848
+ }
849
+ }
850
+ this.hostHistory ??= new HostMonitoringHistory({ path: join(this.dataDir, 'host-monitoring.sqlite'), incidents: true, incidentReady: () => this.hostAlerts?.ready(), unblocked: () => this.hostMonitor?.apply() });
851
+ this.hostAlerts ??= new HostMonitoringAlerts({ persistence: this.hostHistory, changed: () => this.needsYou?.poke(), deliver: (changes, ack) => {
852
+ return this.notifyFleetError(hostAlertSummary(changes, getLocale()), { throttle: false, ack });
853
+ } });
854
+ this.hostFootprint ??= new HostFootprint({ roots: () => this.hostFootprintRoots(), changed: () => this.hostHistory?.ingest(this.hostHealthSnapshotInternal()) });
855
+ this.hostMonitor ??= new HostMonitoringRuntime({
856
+ footprint: this.hostFootprint,
857
+ footprintEnabled: enabled => { this.hostFootprintEnabled = enabled; for (const daemon of this.daemons.values())
858
+ daemon.setHostFootprintEnabled?.(enabled); },
859
+ history: this.hostHistory,
860
+ alerts: { configure: enabled => { this.hostAlerts.configure(enabled, this.hostAlertConfig); if (this.hostAlertSettingsFailed)
861
+ this.hostAlerts.unavailable(); }, stop: () => this.hostAlerts.stop(), ingest: snapshot => this.hostAlerts.ingest(snapshot), snapshot: () => this.hostAlerts.snapshot() },
862
+ supported: () => process.platform === "linux" || process.platform === "darwin",
863
+ drive: () => readHostMonitoringDrive(this.dataDir),
864
+ committed: () => monitoringConfig(this.fleetConfig?.monitoring),
865
+ raw: () => { if (!this.configPath)
866
+ throw Error("config unavailable"); return { monitoring: loadRawFleetConfig(this.configPath).monitoring }; },
867
+ pin: patches => this.saveFleetConfig(patches),
868
+ factory: () => new NativeHostMonitoring({ statePath: this.dataDir, memory: () => this.memoryPressure.snapshot(), wslDrive: readHostMonitoringDrive(this.dataDir) }),
869
+ });
870
+ this.hostMonitor.start();
871
+ }
872
+ hostHistoryQuery(range, series) { return this.hostHistory?.query(range, series) ?? Promise.resolve({ ok: false, reason: 'history_unavailable' }); }
873
+ hostMonitoringAvailable() { return this.hostMonitor?.available() === true; }
874
+ hostHealthSnapshotInternal() { return this.hostMonitor?.snapshot() ?? disabledHostHealth(); }
875
+ hostHealthSnapshot(agentOffset = 0) {
876
+ const snapshot = this.hostHealthSnapshotInternal(), reading = snapshot.footprint?.reading;
877
+ if (reading) {
878
+ const labels = this.hostFootprintLabels;
879
+ reading.rows = reading.rows.slice(agentOffset, agentOffset + 50).map(row => ({ ...row, label: labels?.get(row.id) ?? 'Agent' }));
880
+ Object.assign(reading, { offset: agentOffset, hasMore: agentOffset + 50 < reading.total });
881
+ }
882
+ return snapshot;
883
+ }
884
+ hostAlertSettings() { return structuredClone(this.hostAlertConfig); }
885
+ saveHostAlertSettings(input) {
886
+ const next = parseHostAlertSettings(input), resources = hostAlertResources(this.hostHealthSnapshot(), Date.now());
887
+ for (const [key, rule] of Object.entries(next.rules)) {
888
+ const resource = resources.find(r => r.key === key);
889
+ if (!resource) {
890
+ if (JSON.stringify(rule) === JSON.stringify(this.hostAlertConfig.rules[key]))
891
+ continue;
892
+ throw Error('invalid_alert_resource');
893
+ }
894
+ if (resource.kind !== rule.kind)
895
+ throw Error('invalid_alert_resource');
896
+ validateHostAlertRule(rule, resource.capacity);
897
+ }
898
+ writeHostAlertSettings(this.dataDir, next);
899
+ this.hostAlertConfig = next;
900
+ this.hostAlertSettingsFailed = false;
901
+ this.hostAlerts?.configure(this.fleetConfig?.monitoring?.enabled === true, next);
902
+ return this.hostAlertSettings();
903
+ }
904
+ hostAlertAction(key, revision, actor, snoozeMs) { return this.hostAlerts?.act(key, revision, actor, snoozeMs) ?? Promise.resolve(false); }
905
+ hostNeedsYouItems() {
906
+ const alerts = this.hostAlerts?.snapshot();
907
+ if (!alerts || alerts.state === 'off' || !alerts.needsYou)
908
+ return [];
909
+ if (alerts.state === 'failed')
910
+ return [{ id: 'host:unavailable', type: 'host', reason: 'host_health', instance: '', detail: 'Host alerts unavailable. Open Host health.', since: 0 }];
911
+ return alerts.active.map(record => ({ id: `host:${record.key}:${record.openedAt}`, type: 'host', reason: 'host_health', instance: '', detail: `${record.level}: ${record.kind}`, since: record.openedAt, hostAlert: record }));
912
+ }
913
+ /** Effective Settings view: the drive is intentionally outside FleetConfig/fleet.yaml. */
914
+ hostMonitoringSettings() {
915
+ const drive = readHostMonitoringDrive(this.dataDir);
916
+ return { ...monitoringConfig(this.fleetConfig?.monitoring), ...(drive ? { wsl_drive: drive } : {}) };
917
+ }
918
+ saveHostMonitoringSettings(patch) {
919
+ if (!this.fleetConfig || !this.configPath)
920
+ throw Error('fleet unavailable');
921
+ const previous = this.fleetConfig.monitoring, oldDrive = readHostMonitoringDrive(this.dataDir);
922
+ const raw = loadRawFleetConfig(this.configPath).monitoring;
923
+ const legacy = raw && Object.hasOwn(raw, 'wsl_drive');
924
+ const change = Object.hasOwn(patch, 'wsl_drive') || legacy;
925
+ const nextDrive = Object.hasOwn(patch, 'wsl_drive') ? patch.wsl_drive : legacy ? raw.wsl_drive : oldDrive;
926
+ // Sidecar first: failure cannot leave new YAML pointing at an unsaved selection.
927
+ if (change) {
928
+ if (!validMonitoringDrive(nextDrive))
929
+ throw Error('invalid_monitoring_drive');
930
+ writeHostMonitoringDrive(this.dataDir, nextDrive);
931
+ }
932
+ try {
933
+ this.fleetConfig.monitoring = monitoringConfig({ ...monitoringConfig(previous), ...patch });
934
+ this.saveFleetConfig([
935
+ ...Object.entries(this.fleetConfig.monitoring).map(([key, value]) => ({ path: ['monitoring', key], value })),
936
+ { path: ['monitoring', 'wsl_drive'], remove: true },
937
+ ]);
938
+ }
939
+ catch (error) {
940
+ this.fleetConfig.monitoring = previous;
941
+ if (change)
942
+ writeHostMonitoringDrive(this.dataDir, oldDrive ?? '');
943
+ throw error;
944
+ }
945
+ return this.hostMonitoringSettings();
946
+ }
806
947
  /** Fleet-level backend reachability memory (fed by pty_error / startup panes). */
807
948
  backendOutage = new BackendOutageTracker();
808
949
  /** Stable for this FleetManager OS-process lifetime; Daemon objects have their own boot IDs. */
@@ -4210,6 +4351,7 @@ export class FleetManager {
4210
4351
  generalLocation: input => this.previewGeneralLocation(input),
4211
4352
  hubMembership: raw => hubMembershipSettings(raw),
4212
4353
  hubPageSharing: raw => hubPageSharingSettings(raw),
4354
+ hostMonitoringAvailable: () => this.hostMonitoringAvailable(),
4213
4355
  hubPilotTrust: raw => hubPilotTrustSettings(raw, RUNNING_AGEND_VERSION),
4214
4356
  // S3c (S-55): a Hub exposure publish's confirmation summary, while a member composition is attached.
4215
4357
  hubBrowserCertificate: (input, binding) => {
@@ -6300,6 +6442,7 @@ export class FleetManager {
6300
6442
  onDaemonReady(name, daemonBootId) {
6301
6443
  const daemon = this.daemons.get(name);
6302
6444
  if (daemon?.bootId === daemonBootId) {
6445
+ daemon.setHostFootprintEnabled?.(this.hostFootprintEnabled);
6303
6446
  this.listenForWorkingState(name, daemon);
6304
6447
  const cfg = this.fleetConfig?.instances[name];
6305
6448
  if (cfg?.general_topic && !this.generalLocationFlights.has(name) && daemon.getProcessStatus() === "running"
@@ -6333,6 +6476,18 @@ export class FleetManager {
6333
6476
  if (this.workingStateListeners.has(daemon))
6334
6477
  return;
6335
6478
  this.workingStateListeners.add(daemon);
6479
+ daemon.on("claude_credential_request", (event) => {
6480
+ try {
6481
+ if (this.daemons.get(name) !== daemon || !sameInteractionOwner(event.owner, daemon.getInteractionSnapshot().owner) || resolvePath(event.binding.home) !== resolvePath(this.dataDir) || event.binding.kind === "subscription")
6482
+ return;
6483
+ const { binding, record } = event, kind = binding.kind;
6484
+ if (kind === "subscription")
6485
+ return;
6486
+ if (this.withClaudeVault(vault => vault.observeRequest(binding.profile, binding.id, binding.revision, kind, record)))
6487
+ broadcastSseEvent(this.sseClients, "backend_login", {}, () => { });
6488
+ }
6489
+ catch { /* Metadata observation never changes the source or interrupts work. */ }
6490
+ });
6336
6491
  daemon.on("working_state", (event) => {
6337
6492
  try {
6338
6493
  if (this.daemons.get(name) !== daemon || !sameInteractionOwner(event.observation.owner, daemon.getInteractionSnapshot().owner))
@@ -7334,6 +7489,9 @@ export class FleetManager {
7334
7489
  process.env.AGEND_FLEET_CONFIG_PATH = resolvePath(configPath);
7335
7490
  if (options.remember !== false && existsSync(configPath))
7336
7491
  history.accepted("fleet.yaml", configPath, selected);
7492
+ // The normal lossless writer owns migration; never hand-edit YAML or retain this beta.17-only key for rollback.
7493
+ if (options.startup && raw.monitoring && Object.hasOwn(raw.monitoring, 'wsl_drive'))
7494
+ this.saveFleetConfig();
7337
7495
  return this.fleetConfig;
7338
7496
  }
7339
7497
  relayLoginModeWarned = false;
@@ -9927,8 +10085,10 @@ export class FleetManager {
9927
10085
  }
9928
10086
  // CLI single-instance cold starts bypass startAll. Start diagnostics before
9929
10087
  // any lifecycle/wake work; a shutdown must not revive the stopped sampler.
9930
- if (!this.shuttingDown)
10088
+ if (!this.shuttingDown) {
9931
10089
  this.memoryPressure?.start();
10090
+ this.startHostMonitoringRuntime();
10091
+ }
9932
10092
  // Any start supersedes a pending automatic retry (it would otherwise fire
9933
10093
  // into a running instance — harmless, but noisy — or race this start).
9934
10094
  this.cancelStartupRetry(name);
@@ -12792,6 +12952,7 @@ export class FleetManager {
12792
12952
  // Must run before the first General/CLI spawn: pressure can hold startup.
12793
12953
  // Logs remain available even before the adapters and health listener exist.
12794
12954
  this.memoryPressure.start();
12955
+ this.startHostMonitoringRuntime();
12795
12956
  // #2910: a web-only fleet's agents run in topic mode too (their cross-instance tools work; the dashboard is their place).
12796
12957
  const topicMode = daemonTopicMode(fleet);
12797
12958
  // Set tmux socket isolation for custom AGEND_HOME
@@ -16205,6 +16366,14 @@ export class FleetManager {
16205
16366
  });
16206
16367
  }
16207
16368
  };
16369
+ // M-3491: a `reply_to` that names a kept web-chat message (by its web id, or a copy elsewhere) becomes that
16370
+ // message's copy on this platform, so the reply is a native reply there; an id the chat does not know is left as
16371
+ // it is (the adapter ignores one that is not its own: no quote, no error, as before).
16372
+ if (typeof args.reply_to === "string" && args.reply_to && outAdapter !== WEB_ONLY_REPLY_SINK) {
16373
+ const native = this.nativeReplyTo(instanceName, args.reply_to, outAdapter.id ?? contextAdapterId ?? "", String(args.chat_id ?? ""), String(args.thread_id ?? threadId ?? ""));
16374
+ if (native)
16375
+ args.reply_to = native;
16376
+ }
16208
16377
  if (routeToolCall(outAdapter, tool, args, threadId, respondAndRecord, { ...restrictedExtras, ...(replySet ? { replyButtons: replySet.callbacks, ...(replySet.poll ? { replyPoll: replySet.poll } : {}) } : {}) })) {
16209
16378
  return;
16210
16379
  }
@@ -16274,6 +16443,18 @@ export class FleetManager {
16274
16443
  return false;
16275
16444
  }
16276
16445
  }
16446
+ /**
16447
+ * M-3491: the platform message id a reply to `id` uses on `adapterId`'s chat and thread — the copy there of the kept
16448
+ * web-chat message `id` names (#2281 posts) — or undefined when the chat keeps no such message or it has no copy there.
16449
+ */
16450
+ nativeReplyTo(instance, id, adapterId, chatId, threadId) {
16451
+ const row = this.webChatHistory.findByReplyId(instance, id);
16452
+ if (!row || !adapterId)
16453
+ return undefined;
16454
+ const here = this.webChatHistory.postsOf(row).filter(p => p.adapterId === adapterId && p.chatId === chatId && (p.threadId ?? "") === threadId);
16455
+ // An id that already is one of its copies here (its buttons message, say) stays the one the agent named.
16456
+ return here.find(p => p.messageId === id)?.messageId ?? here[0]?.messageId;
16457
+ }
16277
16458
  captureReplyPreview(instance, args) {
16278
16459
  if (!replyPreviews(args.previews)?.length)
16279
16460
  return undefined;
@@ -16288,6 +16469,13 @@ export class FleetManager {
16288
16469
  const sent = (sentAs?.result && typeof sentAs.result === "object" ? sentAs.result : {});
16289
16470
  const post = inChannel && sentAs && typeof sent.messageId === "string" && typeof sent.chatId === "string"
16290
16471
  ? { adapterId: sentAs.adapterId, chatId: sent.chatId, ...(typeof sent.threadId === "string" && sent.threadId ? { threadId: sent.threadId } : {}), messageId: sent.messageId } : undefined;
16472
+ // M-3491: a long reply's buttons ride its last part, a message of its own: a later `reply_to` may name that one.
16473
+ const buttonsPost = post && typeof sent.buttonsMessageId === "string" && sent.buttonsMessageId && sent.buttonsMessageId !== post.messageId
16474
+ ? { ...post, messageId: sent.buttonsMessageId } : undefined;
16475
+ // M-3491: what the reply quotes in the web chat — the kept message its `reply_to` names (a web id, the id an earlier
16476
+ // reply returned, or a Discord/Telegram copy's id), taken now; an id the chat does not keep quotes nothing, as before.
16477
+ const quotedRow = typeof args.reply_to === "string" && args.reply_to ? this.webChatHistory.findByReplyId(instanceName, args.reply_to) : undefined;
16478
+ const quoted = quotedRow ? webChatReplyRef(quotedRow) : undefined;
16291
16479
  // A reply is NOT proof the turn is over (#410) — but it is not proof of
16292
16480
  // more work either. Split the difference: an instance that is clearly
16293
16481
  // idle loses the button now; one that looks busy keeps it (re-posted
@@ -16334,7 +16522,8 @@ export class FleetManager {
16334
16522
  ...(buttons ? { buttons } : {}), // #1266
16335
16523
  ...(replyPreviews(args.previews)?.length ? { previews: replyPreviews(args.previews) } : {}),
16336
16524
  ...(inChannel ? { channel: true } : {}), // #1920 §5.2
16337
- ...(post ? { posts: [post] } : {}), // #2281
16525
+ ...(post ? { posts: buttonsPost ? [post, buttonsPost] : [post] } : {}), // #2281 (M-3491: and its buttons message)
16526
+ ...(quoted ? { replyTo: quoted } : {}), // M-3491
16338
16527
  ...(typeof returned === "string" && returned ? { anchor: returned } : {}), // AGEND-181: what the reply call returned
16339
16528
  ...(reserved !== undefined ? { reserved } : {}), // #1774
16340
16529
  });
@@ -17877,6 +18066,22 @@ export class FleetManager {
17877
18066
  this.rawFleetConfig = loadRawFleetConfig(this.configPath);
17878
18067
  // #2208: what the file says before this save, aliases expanded — every write below is recorded, and anything that
17879
18068
  // changes outside them (a place sharing a node with one written) refuses the save.
18069
+ // Any save repairs a legacy drive key. A Settings transaction which already saved its sidecar supplies remove.
18070
+ const drivePath = (p) => p.path.length === 2 && p.path[0] === 'monitoring' && p.path[1] === 'wsl_drive';
18071
+ const requestedDrive = explicitPatches.find(p => drivePath(p) && !p.remove);
18072
+ const removesDrive = explicitPatches.some(p => drivePath(p) && p.remove);
18073
+ const rawMonitoring = this.rawFleetConfig.monitoring;
18074
+ const legacyDrive = rawMonitoring && Object.hasOwn(rawMonitoring, 'wsl_drive');
18075
+ if (requestedDrive || legacyDrive && !removesDrive) {
18076
+ const value = requestedDrive ? requestedDrive.value : rawMonitoring.wsl_drive;
18077
+ if (!validMonitoringDrive(value))
18078
+ throw Error('invalid_monitoring_drive');
18079
+ writeHostMonitoringDrive(this.dataDir, value);
18080
+ }
18081
+ if (this.fleetConfig.monitoring)
18082
+ this.fleetConfig.monitoring = monitoringConfig(this.fleetConfig.monitoring);
18083
+ explicitPatches = explicitPatches.filter(p => !drivePath(p));
18084
+ explicitPatches.push({ path: ['monitoring', 'wsl_drive'], remove: true });
17880
18085
  const fileBefore = this.rawFleetDocument.toJS({ maxAliasCount: -1 });
17881
18086
  const writes = this.fleetDocumentWrites = []; // a throw below leaves it to the next save
17882
18087
  this.patchFleetDocument(this.rawFleetDocument, [], this.savedFleetConfigSnapshot, this.fleetConfig);
@@ -17921,7 +18126,7 @@ export class FleetManager {
17921
18126
  if (stray)
17922
18127
  throw new Error(`Refusing to save fleet.yaml: this change would also change ${stray}, which shares a value with what it edits. Give each its own value in fleet.yaml.`);
17923
18128
  noteSettingsWrite(this.configPath, this.savedFleetConfigSnapshot, this.fleetConfig);
17924
- const output = String(this.rawFleetDocument);
18129
+ const output = stringifyFleetYaml(this.rawFleetDocument, source);
17925
18130
  if (redundantPaths.length > 0)
17926
18131
  this.writeFleetConfigBackup(source);
17927
18132
  // Atomic write with fsync. The beforeRename hook runs after fsync and
@@ -17968,6 +18173,7 @@ export class FleetManager {
17968
18173
  this.logger.info({ path: this.configPath, strippedDefaults: redundantPaths.length }, "Saved fleet config (lossless patch)");
17969
18174
  this.observeRuntimeSwitches(); // M-2255: a saved Windows runtime switch applies now
17970
18175
  this.observeHubSwitches(); // S-51: so does a saved Hub switch
18176
+ this.hostMonitor?.apply();
17971
18177
  }
17972
18178
  /** A permission tightening is effective when its save returns, independently of the later apply job or IPC. */
17973
18179
  refreshSavedDashboardPermissions() {
@@ -19348,7 +19554,7 @@ export class FleetManager {
19348
19554
  return;
19349
19555
  const m = this.webChatHistory.setDelivery(instanceName, messageId, status);
19350
19556
  if (m)
19351
- this.emitSseEvent("delivery", { instance: instanceName, messageId, delivery: m.delivery });
19557
+ this.emitSseEvent("delivery", { instance: instanceName, messageId, delivery: m.delivery, ...(m.retry ? { boot: m.boot, id: m.id, retry: m.retry } : {}) });
19352
19558
  }
19353
19559
  /**
19354
19560
  * Apply a terminal delivery verdict. On Telegram the built-in delivered is
@@ -20709,6 +20915,7 @@ export class FleetManager {
20709
20915
  return owner !== undefined && this.worlds.has(owner) ? owner : undefined;
20710
20916
  };
20711
20917
  this.needsYou = new NeedsYouHub({
20918
+ hostAlerts: () => this.hostNeedsYouItems(),
20712
20919
  contactSuggestions: () => this.contactSuggestions(),
20713
20920
  dataDir: this.dataDir,
20714
20921
  now: () => Date.now(),
@@ -20717,10 +20924,10 @@ export class FleetManager {
20717
20924
  clearTimer: h => clearTimeout(h),
20718
20925
  prompts: () => this.needsYouPrompts(),
20719
20926
  instances: () => this.needsYouInstances(),
20720
- deliveries: since => (this.deliveryOutbox?.isOpen ? this.deliveryOutbox.needsAttention(since) : []).map(d => ({
20721
- deliveryId: d.deliveryId, state: d.state, source: d.sourceInstance, target: d.targetInstance, kind: d.kind,
20722
- finishedAt: Date.parse(d.finishedAt) || 0,
20723
- })),
20927
+ deliveries: since => [...(this.deliveryOutbox?.isOpen ? this.deliveryOutbox.needsAttention(since) : []).map(d => ({
20928
+ deliveryId: d.deliveryId, state: d.state, source: d.sourceInstance, target: d.targetInstance, kind: d.kind,
20929
+ finishedAt: Date.parse(d.finishedAt) || 0,
20930
+ })), ...this.webChatHistory.failedWebDeliveries(Date.parse(since) || 0)].sort((a, b) => b.finishedAt - a.finishedAt).slice(0, 50),
20724
20931
  ownerOf,
20725
20932
  worlds: () => [...this.worlds.values()].map((w) => ({ id: w.id, adapter: w.adapter, place: worldPlaceOf(w) })),
20726
20933
  noticeTarget: world => {
@@ -20741,6 +20948,8 @@ export class FleetManager {
20741
20948
  fleetAdmins: world => (this.getChannelConfig(world)?.access?.allowed_users ?? []).map(String),
20742
20949
  emitSse: (event, data) => this.emitSseEvent(event, data),
20743
20950
  acknowledge: (deliveryId, by) => {
20951
+ if (deliveryId.startsWith("web:"))
20952
+ return this.webChatHistory.acknowledgeWebDelivery(deliveryId);
20744
20953
  if (!this.deliveryOutbox?.isOpen)
20745
20954
  throw new Error("the delivery outbox is not open");
20746
20955
  return this.deliveryOutbox.acknowledge(deliveryId, by);
@@ -26068,7 +26277,7 @@ export class FleetManager {
26068
26277
  /** Push an SSE event to all connected Web UI clients. */
26069
26278
  emitSseEvent(event, data) {
26070
26279
  // #1386: a prompt opened or closed, or an instance's state moved — "Needs you" may have changed.
26071
- if (event === "prompt" || event === "prompt_resolved" || event === "activity")
26280
+ if (event === "prompt" || event === "prompt_resolved" || event === "activity" || event === "delivery")
26072
26281
  this.needsYou?.poke();
26073
26282
  const onError = (err) => this.logger.debug({ err }, "SSE client write failed; evicting");
26074
26283
  if (event === "message" && data && typeof data === "object") {
@@ -26082,6 +26291,7 @@ export class FleetManager {
26082
26291
  messageId: typeof m.messageId === "string" ? m.messageId : undefined,
26083
26292
  anchor: typeof m.anchor === "string" ? m.anchor : undefined,
26084
26293
  role: typeof m.role === "string" ? m.role : undefined,
26294
+ retryOwner: m.retryOwner,
26085
26295
  buttons: m.buttons,
26086
26296
  previews: m.previews,
26087
26297
  click: m.click,
@@ -29751,6 +29961,7 @@ export class FleetManager {
29751
29961
  // because we asked it to. Set synchronously — doStopAll runs to its first
29752
29962
  // await in the same tick as the signal handler, so no event can slip in.
29753
29963
  this.shuttingDown = true;
29964
+ this.hostMonitor?.stop();
29754
29965
  this.stopQuotaObserver?.();
29755
29966
  this.stopQuotaObserver = null;
29756
29967
  const quotaNoticesStopped = this.quotaNotices?.stop();
@@ -30277,6 +30488,7 @@ export class FleetManager {
30277
30488
  this.reregisterClassicChannels();
30278
30489
  this.scheduler?.reload();
30279
30490
  this.reconcilePreviewListener();
30491
+ this.hostMonitor?.apply();
30280
30492
  this.publicWebLink?.refresh();
30281
30493
  const newInstances = this.fleetConfig.instances;
30282
30494
  const topicMode = daemonTopicMode(this.fleetConfig);