@songsid/agend 2.4.0-beta.17 → 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 (112) hide show
  1. package/dist/backend/claude-code.js +6 -2
  2. package/dist/backend/claude-code.js.map +1 -1
  3. package/dist/backend/claude-transcript-errors.d.ts +4 -0
  4. package/dist/backend/claude-transcript-errors.js +5 -1
  5. package/dist/backend/claude-transcript-errors.js.map +1 -1
  6. package/dist/build-provenance.json +1 -1
  7. package/dist/cli-audited.js +6 -5
  8. package/dist/cli-audited.js.map +1 -1
  9. package/dist/daemon.d.ts +8 -0
  10. package/dist/daemon.js +62 -13
  11. package/dist/daemon.js.map +1 -1
  12. package/dist/fleet-context.d.ts +1 -0
  13. package/dist/fleet-manager.d.ts +15 -1
  14. package/dist/fleet-manager.js +96 -9
  15. package/dist/fleet-manager.js.map +1 -1
  16. package/dist/fleet-windows-runtime.d.ts +1 -1
  17. package/dist/fleet-windows-runtime.js +1 -1
  18. package/dist/fleet-windows-runtime.js.map +1 -1
  19. package/dist/fleet-yaml-stringify.d.ts +3 -0
  20. package/dist/fleet-yaml-stringify.js +79 -0
  21. package/dist/fleet-yaml-stringify.js.map +1 -0
  22. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +10 -2
  23. package/dist/host-monitoring-alert-policy.d.ts +71 -0
  24. package/dist/host-monitoring-alert-policy.js +150 -0
  25. package/dist/host-monitoring-alert-policy.js.map +1 -0
  26. package/dist/host-monitoring-alert-resources.d.ts +11 -0
  27. package/dist/host-monitoring-alert-resources.js +16 -0
  28. package/dist/host-monitoring-alert-resources.js.map +1 -0
  29. package/dist/host-monitoring-alert-settings.d.ts +14 -0
  30. package/dist/host-monitoring-alert-settings.js +63 -0
  31. package/dist/host-monitoring-alert-settings.js.map +1 -0
  32. package/dist/host-monitoring-alert-store.d.ts +49 -0
  33. package/dist/host-monitoring-alert-store.js +228 -0
  34. package/dist/host-monitoring-alert-store.js.map +1 -0
  35. package/dist/host-monitoring-alert-text.d.ts +7 -0
  36. package/dist/host-monitoring-alert-text.js +10 -0
  37. package/dist/host-monitoring-alert-text.js.map +1 -0
  38. package/dist/host-monitoring-alerts.d.ts +76 -0
  39. package/dist/host-monitoring-alerts.js +261 -0
  40. package/dist/host-monitoring-alerts.js.map +1 -0
  41. package/dist/host-monitoring-footprint-policy.d.ts +45 -0
  42. package/dist/host-monitoring-footprint-policy.js +150 -0
  43. package/dist/host-monitoring-footprint-policy.js.map +1 -0
  44. package/dist/host-monitoring-footprint.d.ts +42 -0
  45. package/dist/host-monitoring-footprint.js +169 -0
  46. package/dist/host-monitoring-footprint.js.map +1 -0
  47. package/dist/host-monitoring-history-policy.d.ts +2 -0
  48. package/dist/host-monitoring-history-policy.js +16 -2
  49. package/dist/host-monitoring-history-policy.js.map +1 -1
  50. package/dist/host-monitoring-history-store.js +8 -6
  51. package/dist/host-monitoring-history-store.js.map +1 -1
  52. package/dist/host-monitoring-history-worker.js +19 -3
  53. package/dist/host-monitoring-history-worker.js.map +1 -1
  54. package/dist/host-monitoring-history.d.ts +9 -0
  55. package/dist/host-monitoring-history.js +45 -9
  56. package/dist/host-monitoring-history.js.map +1 -1
  57. package/dist/host-monitoring-process-identity.d.ts +8 -0
  58. package/dist/host-monitoring-process-identity.js +81 -0
  59. package/dist/host-monitoring-process-identity.js.map +1 -0
  60. package/dist/host-monitoring-runtime.d.ts +8 -0
  61. package/dist/host-monitoring-runtime.js +18 -3
  62. package/dist/host-monitoring-runtime.js.map +1 -1
  63. package/dist/host-monitoring.d.ts +2 -0
  64. package/dist/host-monitoring.js.map +1 -1
  65. package/dist/instance-lifecycle.js +2 -2
  66. package/dist/instance-lifecycle.js.map +1 -1
  67. package/dist/needs-you-hub.d.ts +1 -0
  68. package/dist/needs-you-hub.js +1 -0
  69. package/dist/needs-you-hub.js.map +1 -1
  70. package/dist/needs-you.d.ts +3 -2
  71. package/dist/needs-you.js +1 -0
  72. package/dist/needs-you.js.map +1 -1
  73. package/dist/public-web-gateway.js +7 -1
  74. package/dist/public-web-gateway.js.map +1 -1
  75. package/dist/runtime-cli-install.js +9 -9
  76. package/dist/runtime-cli-install.js.map +1 -1
  77. package/dist/settings-api.d.ts +2 -0
  78. package/dist/settings-api.js +56 -0
  79. package/dist/settings-api.js.map +1 -1
  80. package/dist/settings-baseline.js +5 -4
  81. package/dist/settings-baseline.js.map +1 -1
  82. package/dist/settings-effect.d.ts +2 -0
  83. package/dist/settings-effect.js +20 -1
  84. package/dist/settings-effect.js.map +1 -1
  85. package/dist/topic-commands.js +4 -0
  86. package/dist/topic-commands.js.map +1 -1
  87. package/dist/ui/chat-store.js +21 -4
  88. package/dist/ui/host-alerts.js +23 -0
  89. package/dist/ui/host-footprint.js +17 -0
  90. package/dist/ui/host-health.js +17 -12
  91. package/dist/ui/host-time.js +5 -0
  92. package/dist/ui/panel-chat.js +2 -0
  93. package/dist/ui/panel-needs.js +27 -16
  94. package/dist/ui/panel-settings.js +1 -0
  95. package/dist/ui/settings-host-alerts.js +22 -0
  96. package/dist/ui/settings-host-monitoring.js +8 -7
  97. package/dist/ui/shared/app-i18n.js +2 -2
  98. package/dist/ui/shared/app.css +50 -9
  99. package/dist/ui/shared/chat-render.js +24 -9
  100. package/dist/ui/shared/chat-strings.js +2 -2
  101. package/dist/ui/shared/chat-thread.js +3 -1
  102. package/dist/web-api.d.ts +2 -1
  103. package/dist/web-api.js +197 -6
  104. package/dist/web-api.js.map +1 -1
  105. package/dist/web-chat-history.d.ts +40 -1
  106. package/dist/web-chat-history.js +131 -9
  107. package/dist/web-chat-history.js.map +1 -1
  108. package/dist/web-guest-access.js +4 -4
  109. package/dist/web-guest-access.js.map +1 -1
  110. package/dist/web-upload.d.ts +1 -1
  111. package/dist/web-upload.js.map +1 -1
  112. 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,12 +347,25 @@ 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;
349
354
  private hostMonitor;
350
355
  private hostHistory;
356
+ private hostAlerts;
357
+ private hostAlertConfig;
358
+ private hostAlertSettingsLoaded;
359
+ private hostAlertSettingsFailed;
351
360
  private startHostMonitoringRuntime;
352
361
  hostHistoryQuery(range: unknown, series: unknown): Promise<import('./host-monitoring-history.js').HostHistoryResult>;
353
362
  hostMonitoringAvailable(): boolean;
354
- hostHealthSnapshot(): import("./host-monitoring.js").HostHealthSnapshot;
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;
355
369
  /** Effective Settings view: the drive is intentionally outside FleetConfig/fleet.yaml. */
356
370
  hostMonitoringSettings(): import('./host-monitoring-config.js').HostMonitoringConfig;
357
371
  saveHostMonitoringSettings(patch: Partial<import('./host-monitoring-config.js').HostMonitoringConfig>): import('./host-monitoring-config.js').HostMonitoringConfig;
@@ -1,3 +1,9 @@
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';
1
7
  import { readHostMonitoringDrive, writeHostMonitoringDrive, validMonitoringDrive } from './host-monitoring-settings-store.js';
2
8
  import { HostMonitoringHistory } from './host-monitoring-history.js';
3
9
  import { HostMonitoringRuntime } from "./host-monitoring-runtime.js";
@@ -108,6 +114,7 @@ import { MemoryPressure } from "./memory-pressure.js";
108
114
  import { replyDedupText, ReplyDeduper } from "./reply-dedup.js";
109
115
  import { isMap, isScalar, parseDocument } from "yaml";
110
116
  import { changedOutside, detachForWrite } from "./yaml-shared-nodes.js";
117
+ import { stringifyFleetYaml } from "./fleet-yaml-stringify.js";
111
118
  import { tmuxExecHelper } from "./tmux-exec-helper.js";
112
119
  import { kiroLogGate } from "./kiro-log-gate.js";
113
120
  const __filename = fileURLToPath(import.meta.url);
@@ -809,12 +816,49 @@ export class FleetManager {
809
816
  stormWindow;
810
817
  spawnGate;
811
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
+ }
812
834
  hostMonitor = null;
813
835
  hostHistory = null;
836
+ hostAlerts = null;
837
+ hostAlertConfig = defaultHostAlertSettings();
838
+ hostAlertSettingsLoaded = false;
839
+ hostAlertSettingsFailed = false;
814
840
  startHostMonitoringRuntime() {
815
- this.hostHistory ??= new HostMonitoringHistory({ path: join(this.dataDir, 'host-monitoring.sqlite'), unblocked: () => this.hostMonitor?.apply() });
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()) });
816
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); },
817
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() },
818
862
  supported: () => process.platform === "linux" || process.platform === "darwin",
819
863
  drive: () => readHostMonitoringDrive(this.dataDir),
820
864
  committed: () => monitoringConfig(this.fleetConfig?.monitoring),
@@ -827,7 +871,45 @@ export class FleetManager {
827
871
  }
828
872
  hostHistoryQuery(range, series) { return this.hostHistory?.query(range, series) ?? Promise.resolve({ ok: false, reason: 'history_unavailable' }); }
829
873
  hostMonitoringAvailable() { return this.hostMonitor?.available() === true; }
830
- hostHealthSnapshot() { return this.hostMonitor?.snapshot() ?? disabledHostHealth(); }
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
+ }
831
913
  /** Effective Settings view: the drive is intentionally outside FleetConfig/fleet.yaml. */
832
914
  hostMonitoringSettings() {
833
915
  const drive = readHostMonitoringDrive(this.dataDir);
@@ -6360,6 +6442,7 @@ export class FleetManager {
6360
6442
  onDaemonReady(name, daemonBootId) {
6361
6443
  const daemon = this.daemons.get(name);
6362
6444
  if (daemon?.bootId === daemonBootId) {
6445
+ daemon.setHostFootprintEnabled?.(this.hostFootprintEnabled);
6363
6446
  this.listenForWorkingState(name, daemon);
6364
6447
  const cfg = this.fleetConfig?.instances[name];
6365
6448
  if (cfg?.general_topic && !this.generalLocationFlights.has(name) && daemon.getProcessStatus() === "running"
@@ -18043,7 +18126,7 @@ export class FleetManager {
18043
18126
  if (stray)
18044
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.`);
18045
18128
  noteSettingsWrite(this.configPath, this.savedFleetConfigSnapshot, this.fleetConfig);
18046
- const output = String(this.rawFleetDocument);
18129
+ const output = stringifyFleetYaml(this.rawFleetDocument, source);
18047
18130
  if (redundantPaths.length > 0)
18048
18131
  this.writeFleetConfigBackup(source);
18049
18132
  // Atomic write with fsync. The beforeRename hook runs after fsync and
@@ -19471,7 +19554,7 @@ export class FleetManager {
19471
19554
  return;
19472
19555
  const m = this.webChatHistory.setDelivery(instanceName, messageId, status);
19473
19556
  if (m)
19474
- 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 } : {}) });
19475
19558
  }
19476
19559
  /**
19477
19560
  * Apply a terminal delivery verdict. On Telegram the built-in delivered is
@@ -20832,6 +20915,7 @@ export class FleetManager {
20832
20915
  return owner !== undefined && this.worlds.has(owner) ? owner : undefined;
20833
20916
  };
20834
20917
  this.needsYou = new NeedsYouHub({
20918
+ hostAlerts: () => this.hostNeedsYouItems(),
20835
20919
  contactSuggestions: () => this.contactSuggestions(),
20836
20920
  dataDir: this.dataDir,
20837
20921
  now: () => Date.now(),
@@ -20840,10 +20924,10 @@ export class FleetManager {
20840
20924
  clearTimer: h => clearTimeout(h),
20841
20925
  prompts: () => this.needsYouPrompts(),
20842
20926
  instances: () => this.needsYouInstances(),
20843
- deliveries: since => (this.deliveryOutbox?.isOpen ? this.deliveryOutbox.needsAttention(since) : []).map(d => ({
20844
- deliveryId: d.deliveryId, state: d.state, source: d.sourceInstance, target: d.targetInstance, kind: d.kind,
20845
- finishedAt: Date.parse(d.finishedAt) || 0,
20846
- })),
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),
20847
20931
  ownerOf,
20848
20932
  worlds: () => [...this.worlds.values()].map((w) => ({ id: w.id, adapter: w.adapter, place: worldPlaceOf(w) })),
20849
20933
  noticeTarget: world => {
@@ -20864,6 +20948,8 @@ export class FleetManager {
20864
20948
  fleetAdmins: world => (this.getChannelConfig(world)?.access?.allowed_users ?? []).map(String),
20865
20949
  emitSse: (event, data) => this.emitSseEvent(event, data),
20866
20950
  acknowledge: (deliveryId, by) => {
20951
+ if (deliveryId.startsWith("web:"))
20952
+ return this.webChatHistory.acknowledgeWebDelivery(deliveryId);
20867
20953
  if (!this.deliveryOutbox?.isOpen)
20868
20954
  throw new Error("the delivery outbox is not open");
20869
20955
  return this.deliveryOutbox.acknowledge(deliveryId, by);
@@ -26191,7 +26277,7 @@ export class FleetManager {
26191
26277
  /** Push an SSE event to all connected Web UI clients. */
26192
26278
  emitSseEvent(event, data) {
26193
26279
  // #1386: a prompt opened or closed, or an instance's state moved — "Needs you" may have changed.
26194
- if (event === "prompt" || event === "prompt_resolved" || event === "activity")
26280
+ if (event === "prompt" || event === "prompt_resolved" || event === "activity" || event === "delivery")
26195
26281
  this.needsYou?.poke();
26196
26282
  const onError = (err) => this.logger.debug({ err }, "SSE client write failed; evicting");
26197
26283
  if (event === "message" && data && typeof data === "object") {
@@ -26205,6 +26291,7 @@ export class FleetManager {
26205
26291
  messageId: typeof m.messageId === "string" ? m.messageId : undefined,
26206
26292
  anchor: typeof m.anchor === "string" ? m.anchor : undefined,
26207
26293
  role: typeof m.role === "string" ? m.role : undefined,
26294
+ retryOwner: m.retryOwner,
26208
26295
  buttons: m.buttons,
26209
26296
  previews: m.previews,
26210
26297
  click: m.click,