@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
@@ -10,8 +10,9 @@ import { GeneralLocation } from "./general-location.js";
10
10
  // The instance's own actions (details, start, stop, restart, delete) are in the header's ⋯ menu, and only the ones
11
11
  // that apply to its state are offered (#1408 rough edges 4 and 7).
12
12
  import { html, Fragment, useEffect, useLayoutEffect, useRef, useState } from "/assets/app-html.js";
13
+ import { JUMP_IDLE_MS, useJumpIdle } from "/assets/jump-idle.js";
13
14
  import { lang, register, t } from "/assets/app-i18n.js";
14
- import { AgentSheetButton } from "/assets/agent-sheet.js";
15
+ import { AgentSheetButton, AgentSheet } from "/assets/agent-sheet.js";
15
16
  import { appStore, createStore, guestPage, guestTrusted, useStore } from "/assets/app-store.js";
16
17
  import { ComposerAuth, useWebAuthorization } from "/assets/web-authorize.js";
17
18
  import { useLease } from "/assets/app-ctx.js";
@@ -19,7 +20,7 @@ import * as paneContext from "/assets/app-ctx.js";
19
20
  import { backendLabel, modelText, namesOf, namesStore, navStore as instanceNavStore, supportsInstanceFeature } from "/assets/instance-nav.js";
20
21
  import { machineName } from "/assets/machine-name.js";
21
22
  import { PanelHeader, onPanelKey, setTitle, statusClass, statusLabel, openDrawer, requestNewInstance, needsCount, openSearch } from "/assets/app-shell.js";
22
- import { detailsPath, textLinkSegments, sectionPath, NEEDS_PATH, fleetEntryPath, settingsPath, viewPath, logPath } from "/assets/app-route.js";
23
+ import { chatPath, detailsPath, textLinkSegments, sectionPath, NEEDS_PATH, fleetEntryPath, settingsPath, viewPath, logPath } from "/assets/app-route.js";
23
24
  import { InstanceSwitch } from "/assets/instance-switch.js";
24
25
  import { HeaderTools, setTextSize, textSizeStore, usageOffered, TEXT_SIZES } from "/assets/header-tools.js";
25
26
  import { UsageDialog } from "/assets/usage-dialog.js";
@@ -113,6 +114,49 @@ const needKey = (item) => String(item?.nonce || item?.id || JSON.stringify(item
113
114
  * count), Fleet, Settings — then this chat's items, and ends with 「✓ 已驗證」 (the line under the composer no longer
114
115
  * says it). A Needs-you item that arrives meanwhile, for another agent, is a short toast. A desk's ⋯ is unchanged.
115
116
  */
117
+ /** One target-bound action list for the header and sidebar; the server remains the authority. */
118
+ export function chatAgentMenuItems({ name, inst, wide, pinCount = 0, onPins, onDelete,
119
+ onDetails = () => navigate(detailsPath(name)), onSplit = () => appStore.get().chatWorkspace?.open(name) }) {
120
+ if (guestPage()) return [];
121
+ const running = inst.status === "running";
122
+ const action = async (verb) => {
123
+ let r;
124
+ try { const res = await fetch(`/ui/${verb}/${encodeURIComponent(name)}`, { method: "POST", headers: { "Content-Type": "application/json" } }); r = await res.json(); }
125
+ catch (err) { r = { error: err && err.message ? err.message : t("chat.disconnected") }; }
126
+ if (r && r.error) toast(r.error, false);
127
+ else if (r && r.held) toast(r.message);
128
+ else toast(t(verb === "start" ? "chat.started" : verb === "stop" ? "chat.stoppedInst" : "chat.restarted", name));
129
+ };
130
+ return [
131
+ // #1523 N2: Details is a page now (the Fleet side of this instance), not a dialog.
132
+ supportsInstanceFeature(inst,"details") ? { key: "details", label: t("chat.details"), icon: "info", onSelect: () => onDetails() } : null,
133
+ appStore.get().chatWorkspace ? { key: "splitChat", label: t("chatWorkspace.split"), icon: "sidebar", onSelect: () => onSplit() } : null,
134
+ inst.runtime === "windows" ? {key:"settings",label:t("app.settings"),icon:"settings",onSelect:() => navigate(sectionPath("agents"))} : null,
135
+ running || !supportsInstanceFeature(inst,"lifecycle") ? null : { key: "start", label: t("chat.start"), icon: "play", onSelect: () => action("start") },
136
+ running && supportsInstanceFeature(inst,"lifecycle") ? { key: "restart", label: t("chat.restart"), icon: "restart", onSelect: () => action("restart") } : null,
137
+ running && supportsInstanceFeature(inst,"lifecycle") ? { key: "stop", label: t("chat.stopInstance"), icon: "stop", onSelect: () => action("stop") } : null,
138
+ // #1958: its identity colour and where it shows (the public link too, as profile edits).
139
+ // #3153 P1: the folder it works in, read-only — an admin only (M-3278: over the public link too), and not an
140
+ // agent on another machine (the server also refuses General and coordinators: their folder is the fleet's own).
141
+ inst.runtime === "windows" || inst.machine_id || inst.general_topic === true ? null
142
+ : { key: "workspace", label: t("chat.wsOpen"), icon: "file", onSelect: () => openWorkspace({ key: `ws:${name}`, instance: name }) },
143
+ // M-3271: the pinned list — here too, for a phone (its header shows ← title ⋯ only) and a narrow pane.
144
+ pinCount ? { key: "pins", label: `${t("chat.pinsTitle")} · ${pinCount}`, icon: "pin", onSelect: onPins } : null,
145
+ colorMenuItem(name, inst),
146
+ // #1629: a person's control over this agent's theme — not over the public link (it only views themes).
147
+ ...themeMenuItems(name),
148
+ // #2117: its ambient — why it is not showing here (with the way to change that), and a person's Clear.
149
+ ...ambientMenuItems(name, { publicLink: false, clear: clearAmbient }), // M-3278
150
+ // AGEND-181: the activity timeline above each reply (this browser's choice), when the Log is on.
151
+ ...(activityOffered() && activityInfo(name)?.level !== "off" ? [
152
+ { key: "activity", checkbox: true, checked: activityPrefs.get().on, label: t("act.menuActivity"), onSelect: () => setActivityOn(!activityPrefs.get().on) },
153
+ ...(activityInfo(name)?.thinking ? [{ key: "thinking", checkbox: true, checked: activityPrefs.get().thinking, disabled: !activityPrefs.get().on, label: t("act.menuThinking"), onSelect: () => setActivityThinking(!activityPrefs.get().thinking) }] : []),
154
+ ] : []),
155
+ narrowScreen() ? null : { key: "fullWidth", checkbox: true, checked: wide, label: t("chat.fullWidth"), onSelect: () => setChatWide(!wide) },
156
+ { key: "delete", label: t("chat.delete"), icon: "trash", danger: true, onSelect: onDelete },
157
+ ];
158
+ }
159
+
116
160
  function ChatMoreMenu({ items, name, inst = null, card = null, navKey, lease = null }) {
117
161
  const app = useStore(appStore);
118
162
  const auth = useWebAuthorization();
@@ -596,43 +640,8 @@ function ChatView({ name, inst, lease, navKey, exec, awaiting }) {
596
640
  e.preventDefault();
597
641
  store.cancelReply(name);
598
642
  })), [lease]);
599
- const running = inst.status === "running";
600
- const action = async (verb) => {
601
- let r;
602
- try { const res = await fetch(`/ui/${verb}/${encodeURIComponent(name)}`, { method: "POST", headers: { "Content-Type": "application/json" } }); r = await res.json(); }
603
- catch (err) { r = { error: err && err.message ? err.message : t("chat.disconnected") }; }
604
- if (r && r.error) toast(r.error, false);
605
- else if (r && r.held) toast(r.message);
606
- else toast(t(verb === "start" ? "chat.started" : verb === "stop" ? "chat.stoppedInst" : "chat.restarted", name));
607
- };
608
- const items = [
609
- // #1523 N2: Details is a page now (the Fleet side of this instance), not a dialog.
610
- supportsInstanceFeature(inst,"details") ? { key: "details", label: t("chat.details"), icon: "info", onSelect: () => (paneNow.current?.navigate || navigate)(detailsPath(name)) } : null,
611
- appStore.get().chatWorkspace ? { key: "splitChat", label: t("chatWorkspace.split"), icon: "sidebar", onSelect: () => appStore.get().chatWorkspace.pick() } : null,
612
- inst.runtime === "windows" ? {key:"settings",label:t("app.settings"),icon:"settings",onSelect:() => navigate(sectionPath("agents"))} : null,
613
- running || !supportsInstanceFeature(inst,"lifecycle") ? null : { key: "start", label: t("chat.start"), icon: "play", onSelect: () => action("start") },
614
- running && supportsInstanceFeature(inst,"lifecycle") ? { key: "restart", label: t("chat.restart"), icon: "restart", onSelect: () => action("restart") } : null,
615
- running && supportsInstanceFeature(inst,"lifecycle") ? { key: "stop", label: t("chat.stopInstance"), icon: "stop", onSelect: () => action("stop") } : null,
616
- // #1958: its identity colour and where it shows (the public link too, as profile edits).
617
- // #3153 P1: the folder it works in, read-only — an admin only (M-3278: over the public link too), and not an
618
- // agent on another machine (the server also refuses General and coordinators: their folder is the fleet's own).
619
- inst.runtime === "windows" || inst.machine_id || inst.general_topic === true ? null
620
- : { key: "workspace", label: t("chat.wsOpen"), icon: "file", onSelect: () => openWorkspace({ key: `ws:${name}`, instance: name }) },
621
- // M-3271: the pinned list — here too, for a phone (its header shows ← title ⋯ only) and a narrow pane.
622
- pinCount ? { key: "pins", label: `${t("chat.pinsTitle")} · ${pinCount}`, icon: "pin", onSelect: openPins } : null,
623
- colorMenuItem(name, inst),
624
- // #1629: a person's control over this agent's theme — not over the public link (it only views themes).
625
- ...themeMenuItems(name),
626
- // #2117: its ambient — why it is not showing here (with the way to change that), and a person's Clear.
627
- ...ambientMenuItems(name, { publicLink: false, clear: clearAmbient }), // M-3278
628
- // AGEND-181: the activity timeline above each reply (this browser's choice), when the Log is on.
629
- ...(activityOffered() && activityInfo(name)?.level !== "off" ? [
630
- { key: "activity", checkbox: true, checked: activityPrefs.get().on, label: t("act.menuActivity"), onSelect: () => setActivityOn(!activityPrefs.get().on) },
631
- ...(activityInfo(name)?.thinking ? [{ key: "thinking", checkbox: true, checked: activityPrefs.get().thinking, disabled: !activityPrefs.get().on, label: t("act.menuThinking"), onSelect: () => setActivityThinking(!activityPrefs.get().thinking) }] : []),
632
- ] : []),
633
- narrowScreen() ? null : { key: "fullWidth", checkbox: true, checked: wide, label: t("chat.fullWidth"), onSelect: () => setChatWide(!wide) },
634
- { key: "delete", label: t("chat.delete"), icon: "trash", danger: true, onSelect: () => setDialog("delete") },
635
- ];
643
+ const items = chatAgentMenuItems({ name, inst, wide, pinCount, onPins: openPins, onDelete: () => setDialog("delete"),
644
+ onDetails: () => (paneNow.current?.navigate || navigate)(detailsPath(name)), onSplit: () => appStore.get().chatWorkspace.pick() });
636
645
  const cls = statusClass(inst, exec, awaiting);
637
646
  // #1920 phase 3: a guest has this chat only — no Details, View or Log to switch to, no lifecycle, colour, theme,
638
647
  // effect management or delete (a guest's status frame carries no model or effort either, so those chips do not show).
@@ -773,6 +782,8 @@ function threadEntry(name, doc) {
773
782
  setPreviewOptIn, copyText, download: downloadHtml, toggleWrap,
774
783
  clickReplyButton: (id, index) => store.clickReplyButton(name, id, index), // #1266
775
784
  contactBadge: (x) => { installBadgeRefresh(); return contactBadgeHtml(x); }, // M-3339: 聯絡申請 #R… / 已准轉交 #R… (kept current)
785
+ canResend: (message) => store.canResend(name, message),
786
+ resendMessage: (key) => store.resendMessage(name, key),
776
787
  retryOutgoing: (clientId) => store.retryOutgoing(name, clientId), // a failed send's Retry and Delete
777
788
  deleteOutgoing: (clientId) => store.deleteOutgoing(name, clientId),
778
789
  putBackOutgoing: (clientId) => { recordEdit(composerField(name)); store.putBackOutgoing(name, clientId); }, // undoable, as typing
@@ -851,11 +862,14 @@ function follow(name, thread) {
851
862
  }
852
863
 
853
864
  /** The thread's view: Preact owns the scroller and the jump pill; the kept list (chat-thread.js) is put inside it. */
865
+ export { JUMP_IDLE_MS };
854
866
  function Thread({ name, label = name, th, bindings }) {
855
867
  const pane = paneContext.usePane?.(), paneNow = useRef(pane); paneNow.current = pane;
856
868
  const scroller = useRef(null), host = useRef(null);
857
869
  const [jump, setJump] = useState({ show: false, unseen: 0 });
858
870
  const [empty, setEmpty] = useState(false);
871
+ // M-3492/M-3493: 最新 fades out JUMP_IDLE_MS after the last scroll (shared with the Hub's threads: jump-idle.js).
872
+ const jumpIdle = useJumpIdle(scroller, jump.show, name);
859
873
  useLayoutEffect(() => { keptThreads.get(name)?.list.setAttribute("aria-label",t("chat.conversationWith",label)); },[name,label]);
860
874
  useLayoutEffect(() => {
861
875
  const doc = host.current.ownerDocument;
@@ -962,7 +976,8 @@ function Thread({ name, label = name, th, bindings }) {
962
976
  <div class="thread-host" ref=${host}></div>
963
977
  ${empty === "hidden" ? html`<${Empty} icon="chat" title=${t("chat.guestAllHidden")} hint=${t("chat.guestAllHiddenHint")} />`
964
978
  : empty ? html`<${Empty} icon="chat" title=${t("chat.noMessages")} />` : null}
965
- </div><div class="jump-dock">${jump.show ? html`<button data-trust="thread-control" type="button" class="jump-latest" onClick=${() => { const t2 = th.current; if (!t2) return; if (store.pagingState(name).detached) void store.backToLatest(name).then(() => t2.jumpLatest()); else t2.jumpLatest(); }}
979
+ </div><div class="jump-dock">${jump.show ? html`<button data-trust="thread-control" type="button" ref=${jumpIdle.ref} class=${`jump-latest${jumpIdle.idle ? " is-idle" : ""}`} onClick=${() => { const t2 = th.current; if (!t2) return; if (store.pagingState(name).detached) void store.backToLatest(name).then(() => t2.jumpLatest()); else t2.jumpLatest(); }}
980
+ onFocus=${jumpIdle.onFocus} onBlur=${jumpIdle.onBlur}
966
981
  aria-label=${jump.unseen > 0 ? t("chat.newBelow", jump.unseen) : t("chat.jumpLatest")}>
967
982
  <${Icon} name="down" size=${16} /><span class="jump-text">${jump.unseen > 0 ? t("chat.newBelow", jump.unseen) : t("chat.jumpLatest")}</span>${
968
983
  /* The user (before 2.4.0-beta.3): no unread counts for now — a phone's round button has no badge. */ ""}</button>` : null}</div>
@@ -1162,6 +1177,8 @@ function ModelMenu({ name, c, lease }) {
1162
1177
  return html`<div class="model-menu-scrim" onClick=${close}></div><div class="model-menu-pop" ref=${(el) => { pop.current = el; place(el); }} onKeyDown=${onKeys}>${body}</div>`;
1163
1178
  }
1164
1179
 
1180
+ const usesModelMenu = c => c?.command === "model" && (c.choices ? c.choices.step !== "backend" : c.busy && !c.error && !c.args);
1181
+
1165
1182
  function CommandCard({ name, lease }) {
1166
1183
  const c = store.state.commands[name];
1167
1184
  if (!c) return null;
@@ -1174,7 +1191,7 @@ function CommandCard({ name, lease }) {
1174
1191
  // bottom sheet on a phone — not a card above the box. A failure, its result text and /backend stay the card.
1175
1192
  // The menu is /model's list: shown with its choices, or while that list loads. A model being switched to (a pick from the
1176
1193
  // menu, a typed "/model <id>") is the card's, as before (#4003 review).
1177
- if (c.command === "model" && (c.choices ? c.choices.step !== "backend" : c.busy && !c.error && !c.args)) return html`<${ModelMenu} name=${name} c=${c} lease=${lease} />`;
1194
+ if (usesModelMenu(c)) return html`<${ModelMenu} name=${name} c=${c} lease=${lease} />`;
1178
1195
  const open = sub && sub.for === c.choices ? c.choices.options.find((o) => o.id === sub.id && o.effort) : null;
1179
1196
  const pickEffort = async (model, level) => {
1180
1197
  setSub(null);
@@ -1470,7 +1487,7 @@ function FileChip({ f, i, name, bindings }) {
1470
1487
 
1471
1488
  // ── Dialogs ──
1472
1489
 
1473
- function DeleteDialog({ name, inst, onClose }) {
1490
+ function DeleteDialog({ name, inst, onClose, onDeleted = () => navigate("/ui") }) {
1474
1491
  // The dialog's own lease: it ends when the dialog goes (closed, or the chat left for another page). The delete
1475
1492
  // may still finish on the server, and says so, but a dialog that is gone never closes or navigates the page the
1476
1493
  // person is on now (#1425 review).
@@ -1497,7 +1514,7 @@ function DeleteDialog({ name, inst, onClose }) {
1497
1514
  if (handedOver || !lease.current()) return;
1498
1515
  setBusy(false);
1499
1516
  onClose();
1500
- navigate("/ui");
1517
+ onDeleted();
1501
1518
  }
1502
1519
  return html`<${Dialog} title=${t("chat.deleteTitle", name)} onClose=${onClose} busy=${busy}
1503
1520
  actions=${html`<button type="button" class="btn" onClick=${onClose} disabled=${busy}>${t("chat.cancel")}</button>
@@ -1509,3 +1526,44 @@ function DeleteDialog({ name, inst, onClose }) {
1509
1526
  </${Dialog}>`;
1510
1527
  }
1511
1528
  ChatPanel.workspaceVersion = 1;
1529
+
1530
+ /** Session-only injection: public InstanceNav never imports this module. */
1531
+ export function SidebarChatMenu({ inst, context, onClose, favorite = null }) {
1532
+ const name = inst.name || inst.instance_name, lease = useLease(`sidebar-menu:${name}`);
1533
+ const [phase, setPhase] = useState("menu");
1534
+ const [, redraw] = useState(0);
1535
+ const wide = useStore(chatWide).on;
1536
+ useStore(themesStore); useStore(activityInfoStore); useStore(activityPrefs);
1537
+ const auth = useWebAuthorization(), card = useCard(name, inst.card_v);
1538
+ const pinCount = usePins(name).pins?.length || 0;
1539
+ useEffect(() => store?.subscribe(target => { if (target === name) redraw(n => n + 1); }), [name]);
1540
+ useEffect(() => {
1541
+ if (phase !== "menu" || !activityShown() || activityInfo(name)?.level !== undefined) return;
1542
+ const feed = observeActivity(name, { changed: () => feed.stop(), wantThinking: () => activityPrefs.get().thinking });
1543
+ feed.start(); return () => feed.stop();
1544
+ }, [name, phase, activityPrefs.get().on]);
1545
+ const command = store?.state.commands[name];
1546
+ useEffect(() => { if ((phase === "command" && !command) || (phase === "card" && !card)) setPhase(null); }, [phase, command, card]);
1547
+ useEffect(() => { if (!phase) onClose(); }, [phase]);
1548
+ const items = chatAgentMenuItems({ name, inst, wide, pinCount, onPins: () => setPhase("pins"), onDelete: () => setPhase("delete") });
1549
+ const run = command => { setPhase("command"); void store.runCommand(name, command, "", { alive: () => lease.current() && !guestPage() }); };
1550
+ const dismiss = () => setPhase(null);
1551
+ const chat = { card: !!card, onCard: () => setPhase("card"),
1552
+ ...(supportsInstanceFeature(inst, "commands") ? { onModel: () => run("model"),
1553
+ modelText: `${shortModelName(modelLabel(inst.model || modelText(inst)))}${supportsInstanceFeature(inst, "effort") && effortChip(inst) ? ` · ${effortChip(inst)}` : ""}`,
1554
+ onBackend: () => inst.runtime === "windows" ? navigate(sectionPath("agents")) : run("backend"), backendText: backendLabel(inst.backend) } : {}) };
1555
+ return html`${phase === "menu" ? narrowScreen()
1556
+ ? html`<${AgentSheet} name=${name} inst=${inst} current="chat" items=${items} extra=${[favorite, items.find(item => item?.key === "splitChat")].filter(Boolean)} chat=${chat} targetLabel=${inst.display_name || name}
1557
+ verifiedUntil=${auth.st?.state === "verified" ? auth.st.until : null} onUsage=${() => setPhase("usage")} onClose=${dismiss} />`
1558
+ : html`<${Menu} cls="agent-menu" fit=${true} topLayer=${true} ownerKey=${name} context=${{...context, onClose: dismiss}} items=${[favorite, ...items]} label=${t("agentRow.actions", inst.display_name || name)} />` : null}
1559
+ ${phase === "delete" ? html`<${DeleteDialog} name=${name} inst=${inst} onClose=${dismiss}
1560
+ onDeleted=${() => { if (navStore.get().route?.instance === name) navigate("/ui"); }} />` : null}
1561
+ ${phase === "pins" ? html`<${PinsDialog} name=${name} onClose=${dismiss} onJump=${pin => { dismiss(); navigate(`${chatPath(name)}#m=${encodeURIComponent(pin.key)}`); }} />` : null}
1562
+ ${phase === "usage" ? html`<${UsageDialog} owner=${`chat:${name}`} onClose=${dismiss} />` : null}
1563
+ ${phase === "card" && card ? html`<${Dialog} title=${t("card.label", inst.display_name || name)} onClose=${dismiss}><${IdentityCard} name=${name} card=${card} compact=${true} /></${Dialog}>` : null}
1564
+ ${phase === "command" && command ? usesModelMenu(command)
1565
+ ? html`<${CommandCard} name=${name} lease=${lease} />`
1566
+ : html`<${Dialog} title=${inst.display_name || name} onClose=${() => { store.dismissCommand(name); dismiss(); }}><${CommandCard} name=${name} lease=${lease} /></${Dialog}>` : null}`;
1567
+ }
1568
+
1569
+ SidebarChatMenu.contextVersion = Menu.contextVersion === 1 && AgentSheet.sidebarTargetVersion === 1 ? 1 : 0;
@@ -9,7 +9,7 @@ import { html, useEffect, useLayoutEffect, useRef, useState } from "/assets/app-
9
9
  import { t, register, lang } from "/assets/app-i18n.js";
10
10
  import { appStore, useStore } from "/assets/app-store.js";
11
11
  import { useLease } from "/assets/app-ctx.js";
12
- import { PanelHeader, setTitle } from "/assets/app-shell.js";
12
+ import { PanelHeader, setTitle, useCanCreate, retryable } from "/assets/app-shell.js";
13
13
  import { HeaderTools } from "/assets/header-tools.js";
14
14
  import { navigate, renavigate } from "/assets/app-nav.js";
15
15
  import { RuntimePicker, AgentDraftAssistant, NativeAgendToolsHint, tr } from "./agent-runtime.js";
@@ -47,7 +47,7 @@ register("fleet", {
47
47
  hostMemory_elevated: "Host memory pressure: elevated — new agents start one at a time, at least 5 s apart",
48
48
  hostMemory_critical: "Host memory pressure: critical — new agents wait for memory to recover",
49
49
  hostMemory_top: "Largest: {0}", hostMemory_ownerFleet: "the fleet", hostMemory_ownerTmux: "tmux", hostMemory_ownerOther: "not an instance",
50
- title: "Fleet", tasks: "Tasks", schedules: "Schedules", teams: "Teams", org: "Org chart", cache: "Cache", usage: "Usage",
50
+ title: "Fleet", tasks: "Tasks", schedules: "Schedules", teams: "Teams", org: "Org chart", cache: "Cache", usage: "Usage", "host-health": "Host health",
51
51
  docs: "Docs", docsNewTab: "Docs (opens in a new tab)",
52
52
  newSchedule: "New schedule", newTeam: "New team",
53
53
  noSchedules: "No schedules yet", noSchedulesHint: "Automate recurring work with cron.",
@@ -75,7 +75,7 @@ register("fleet", {
75
75
  hostMemory_elevated: "主機記憶體壓力偏高:新的 agent 一次啟動一個,至少間隔 5 秒",
76
76
  hostMemory_critical: "主機記憶體壓力嚴重:新的 agent 會等記憶體恢復再啟動",
77
77
  hostMemory_top: "最大:{0}", hostMemory_ownerFleet: "fleet 本身", hostMemory_ownerTmux: "tmux", hostMemory_ownerOther: "不屬於任何 Agent",
78
- title: "Fleet", tasks: "Tasks", schedules: "排程", teams: "Teams", org: "組織圖", cache: "快取", usage: "用量",
78
+ title: "Fleet", tasks: "Tasks", schedules: "排程", teams: "Teams", org: "組織圖", cache: "快取", usage: "用量", "host-health": "主機狀態",
79
79
  docs: "文件", docsNewTab: "文件(在新分頁開啟)",
80
80
  newSchedule: "新增排程", newTeam: "新增 team",
81
81
  noSchedules: "還沒有排程", noSchedulesHint: "用 cron 自動執行例行工作。",
@@ -105,7 +105,7 @@ const DOCS_SITE = "https://songsid.github.io/AgEnD";
105
105
  export function docsUrl(language = lang()) {
106
106
  return `${DOCS_SITE}${language === "zh-TW" ? "/zh-tw" : ""}/docs/web-guide/`;
107
107
  }
108
- const ICONS = { tasks: "tasks", schedules: "clock", teams: "team", org: "org", cache: "chart", usage: "chart", authorizations: "key" };
108
+ const ICONS = { tasks: "tasks", schedules: "clock", teams: "team", org: "org", cache: "chart", usage: "chart", authorizations: "key", "host-health": "chart" };
109
109
  const BACKENDS = ["claude-code", "codex", "opencode", "kiro-cli", "antigravity", "grok", "muse"];
110
110
 
111
111
  async function api(method, path, body, lease) {
@@ -213,7 +213,9 @@ export function FleetPanel({ route, navKey }) {
213
213
  const tab = route.tab;
214
214
  useEffect(() => { setTitle(`${t("fleet.title")} · ${t(`fleet.${tab}`)}`); }, [tab, navKey]);
215
215
  useEffect(() => { rememberFleetTab(tab); }, [tab]); // #2183: the sidebar's and the phone's Fleet reopen it
216
- const Body = { tasks: TaskBoardTab, schedules: Schedules, teams: Teams, org: Org, cache: Cache, usage: UsageTab, authorizations: ContactAuthorizations }[tab] || TaskBoardTab;
216
+ const admin=useCanCreate();
217
+ const visibleTabs=FLEET_TABS.filter(k=>k!=="host-health"||admin);
218
+ const Body = { tasks: TaskBoardTab, schedules: Schedules, teams: Teams, org: Org, cache: Cache, usage: UsageTab, authorizations: ContactAuthorizations, "host-health":admin?LazyHostHealth:HostAdminRequired }[tab] || TaskBoardTab;
217
219
  // #1685: host memory pressure slowing or holding new agents — shown here, where macOS's routine "elevated" is not a chat notice.
218
220
  const { hostMemory, hostMemoryTop } = useStore(appStore);
219
221
  // #2015: and which processes hold the most, and whose — text only (never chat, #1712).
@@ -221,15 +223,15 @@ export function FleetPanel({ route, navKey }) {
221
223
  const sub = hostMemory ? html`<span class=${`status host-mem ${hostMemory}`} role="status"><span class=${`dot ${hostMemory === "critical" ? "bad" : "warn"}`} aria-hidden="true"></span>${t(`fleet.hostMemory_${hostMemory}`)}${top ? html`<span class="host-mem-top" title=${top}>${top}</span>` : null}</span>` : null;
222
224
  const root = useRef(null);
223
225
  const wide = useTabsInHeader(root), phone = usePhoneWidth();
224
- // The phone's tab row scrolls sideways when it does not fit beside ☰: bring the open tab into view (用量 is the last).
226
+ // Keep the active tab visible after async administrator-only tabs arrive, on either tab row.
225
227
  useLayoutEffect(() => {
226
- const nav = phone ? root.current?.querySelector(".fleet-phone-tabs") : null, on = nav?.querySelector(".active");
228
+ const nav = root.current?.querySelector("nav[data-trust='panel-navigation']"), on = nav?.querySelector(".active");
227
229
  if (!nav || !on) return;
228
230
  const n = nav.getBoundingClientRect(), a = on.getBoundingClientRect();
229
231
  if (a.right > n.right) nav.scrollLeft += a.right - n.right;
230
232
  else if (a.left < n.left) nav.scrollLeft -= n.left - a.left;
231
- }, [phone, tab]);
232
- const tabs = (cls) => html`<nav data-trust="panel-navigation" class=${cls} aria-label=${t("fleet.title")}>${FLEET_TABS.map(k => html`<a key=${k} href=${fleetPath(k)} class=${`seg-item${k === tab ? " active" : ""}`}
233
+ }, [phone, tab, admin, wide]);
234
+ const tabs = (cls) => html`<nav data-trust="panel-navigation" class=${cls} aria-label=${t("fleet.title")}>${visibleTabs.map(k => html`<a key=${k} href=${fleetPath(k)} class=${`seg-item${k === tab ? " active" : ""}`}
233
235
  aria-current=${k === tab ? "page" : undefined}><${Icon} name=${ICONS[k]} size=${16} /><span>${t(`fleet.${k}`)}</span></a>`)}</nav>`;
234
236
  return html`<div ref=${root} data-effect-panel="fleet" class="panel p-fleet">
235
237
  ${/* M-2542: the tabs share the title row (PanelHeader's nav slot, as the instance tabs do) when everything fits
@@ -240,11 +242,22 @@ export function FleetPanel({ route, navKey }) {
240
242
  ${/* M-3166 (Argon 5, the user's OK of round 2): a phone's Fleet is two rows — its tabs in the header's row (☰, then the
241
243
  tabs; the title, search, docs and text size give way: app.css), then the page's own tools. */ ""}
242
244
  <${PanelHeader} title=${t("fleet.title")} sub=${sub} nav=${wide ? tabs("fleet-tabs") : phone ? tabs("seg fleet-phone-tabs") : null}><${DocsLink} /><${HeaderTools} navKey=${navKey} /></${PanelHeader}>
243
- ${wide || phone ? null : tabs("seg")}
244
- <div data-trust="panel-content" class="panel-body"><div class=${`col${tab === "tasks" || tab === "org" || tab === "cache" || tab === "usage" || tab === "authorizations" ? " col-wide" : ""}`}><${Body} lease=${lease} /></div></div>
245
+ ${wide || phone ? null : tabs("seg fleet-tabs-row")}
246
+ <div data-trust="panel-content" class="panel-body"><div class=${`col${tab === "tasks" || tab === "org" || tab === "cache" || tab === "usage" || tab === "authorizations" || tab === "host-health" ? " col-wide" : ""}`}><${Body} lease=${lease} /></div></div>
245
247
  </div>`;
246
248
  }
247
249
 
250
+ // Code and data load only for the active administrator tab; a failed import can retry.
251
+ const loadHostHealth=retryable(attempt=>import(attempt?`./host-health.js?retry=${attempt}`:'./host-health.js'));
252
+ function LazyHostHealth({lease}) {
253
+ const [component,setComponent]=useState(null),[error,setError]=useState(false),active=useRef(true),generation=useRef(0);
254
+ const load=()=>{const mine=++generation.current;setError(false);loadHostHealth().then(m=>{if(active.current&&lease.current()&&mine===generation.current)setComponent(()=>m.HostHealth);},()=>{if(active.current&&lease.current()&&mine===generation.current)setError(true);});};
255
+ useEffect(()=>{active.current=true;load();return()=>{active.current=false;generation.current++;};},[lease]);
256
+ return component?html`<${component} lease=${lease}/>`:error?html`<${ErrorState} onRetry=${load}/>`:html`<${Skeleton} lines=${5}/>`;
257
+ }
258
+ function HostAdminRequired(){return html`<section class="card"><h2>${t('fleet.host-health')}</h2><p>${t('hostHealthAccess.admin')}</p></section>`;}
259
+ register('hostHealthAccess',{en:{admin:'Administrator sign-in is required to view host health.'},'zh-TW':{admin:'請以管理員身分登入,才能查看主機狀態。'}});
260
+
248
261
  /** #1844: the project's docs, from the overview — a link out (a new tab, no opener), not a Fleet tab; in front of the shared controls. */
249
262
  function DocsLink() {
250
263
  return html`<a class="btn btn-ghost btn-sm hd-docs" href=${docsUrl()} target="_blank" rel="noopener noreferrer" aria-label=${t("fleet.docsNewTab")} title=${t("fleet.docsNewTab")}>
@@ -21,6 +21,7 @@ import { createStore, useStore } from "/assets/app-store.js";
21
21
  import { navigate, navStore } from "/assets/app-nav.js";
22
22
  import { Empty, ErrorState, Skeleton } from "/assets/ui-states.js";
23
23
  import { Icon } from "/assets/ui-icons.js";
24
+ import { useJumpIdle } from "/assets/jump-idle.js";
24
25
  import { confirmDialog } from "/assets/ui-confirm.js";
25
26
  import { Dialog } from "/assets/ui-dialog.js";
26
27
  import { PairingNotices } from "./hub-quick-pairing.js";
@@ -948,6 +949,8 @@ function HubThread({ store, name, panelKey, threadRef, extra = null, emptyView =
948
949
  thread.dispose(true); list.remove(); th.current = null; if (threadRef && threadRef.current === thread) threadRef.current = null;
949
950
  };
950
951
  }, [store]);
952
+ // M-3493: the Fleet chat's 最新 (M-3492): it fades out JUMP_IDLE_MS after the last scroll (shared/jump-idle.js).
953
+ const jumpIdle = useJumpIdle(scroller, jump.show, store);
951
954
  return html`<div class="scroller hub-scroller" ref=${scroller}>
952
955
  <div class="thread-host" ref=${host}></div>
953
956
  ${/* #3145: that every asker shares the agent's one conversation is said before anyone types. */ ""}
@@ -956,7 +959,8 @@ function HubThread({ store, name, panelKey, threadRef, extra = null, emptyView =
956
959
  : !loaded && store.error() ? html`<${ErrorState} message=${errText({ code: store.error() })} onRetry=${() => store.refresh()} />` : null}
957
960
  ${empty && loaded && !store.closed() && emptyView ? html`<div class="center hub-room-empty">${emptyView}</div>` : null}
958
961
  ${empty && loaded && !store.closed() && !emptyView ? html`<div class="center hub-room-empty"><${Empty} icon="chat" title=${hc("emptyRoom", name)} hint=${personalAgentQuestionHint(store.room())??`${hc("emptyRoomHint", store.room().ownerName || name)}${lang() === "zh-TW" ? "" : " "}${hw("roomShared")}`} /></div>` : null}
959
- <div class="jump-dock">${jump.show ? html`<button data-trust="thread-control" type="button" class="jump-latest" onClick=${() => th.current && th.current.jumpLatest()}>
962
+ <div class="jump-dock">${jump.show ? html`<button data-trust="thread-control" type="button" ref=${jumpIdle.ref} class=${`jump-latest${jumpIdle.idle ? " is-idle" : ""}`}
963
+ onClick=${() => th.current && th.current.jumpLatest()} onFocus=${jumpIdle.onFocus} onBlur=${jumpIdle.onBlur}>
960
964
  <${Icon} name="down" size=${16} />${jump.unseen > 0 ? t("chat.newBelow", jump.unseen) : t("chat.jumpLatest")}</button>` : null}</div>
961
965
  </div>`;
962
966
  }
@@ -1,3 +1,4 @@
1
+ import {HostAlertActions,hostAlertText,hostAlertName,hostAlertDescription} from './host-alerts.js';
1
2
  import { modelSwitchText } from "/assets/model-observation.js";
2
3
  // #1408 step 4 = #1386 part (b): the "Needs you" panel (/ui/needs) — everything waiting on the person, from every
3
4
  // world, in one list. Behind the session gate (/ui/js/), loaded the first time it is opened.
@@ -18,7 +19,7 @@ import { t, register } from "/assets/app-i18n.js";
18
19
  import { appStore, createStore, useStore } from "/assets/app-store.js";
19
20
  import { useLease } from "/assets/app-ctx.js";
20
21
  import { PanelHeader, setTitle } from "/assets/app-shell.js";
21
- import { chatPath } from "/assets/app-route.js";
22
+ import { fleetPath, chatPath } from "/assets/app-route.js";
22
23
  import { namesOf, namesStore } from "/assets/instance-nav.js";
23
24
  import { Empty, Skeleton } from "/assets/ui-states.js";
24
25
  import { Icon } from "/assets/ui-icons.js";
@@ -33,8 +34,8 @@ import { HostDirectoryNotices, hostDirectoryNoticesOffered } from "./hub-host-se
33
34
 
34
35
  // A pre-upgrade tab retains app-i18n.js. Register these reasons when the updated panel is loaded, too.
35
36
  register("app", {
36
- en: { needs_reason_stale_auth: "Codex needs a restart", needs_stale_auth_detail: "Codex cannot refresh this agent’s current sign-in. Restart the agent; sign in again only if Codex asks.", needs_reason_hub_proposal: "Hub action proposed: review locally", needs_reason_hub_execution_hold: "Hub work held: review locally", needs_reason_hub_unavailable: "Hub not running", needs_reason_tmux_hold: "Held: an old tmux server or window" },
37
- "zh-TW": { needs_reason_stale_auth: "Codex 需要重新啟動", needs_stale_auth_detail: "Codex 無法更新這個 Agent 執行中使用的登入。請重新啟動 Agent;只有 Codex 要求時才需要重新登入。", needs_reason_hub_proposal: "Hub 提議操作:請在本機檢視", needs_reason_hub_execution_hold: "Hub 工作已暫停:請在本機檢視", needs_reason_hub_unavailable: "Hub 未在執行", needs_reason_tmux_hold: "已暫停:舊的 tmux 伺服器或視窗" },
37
+ en: { needs_reason_host_health: "Host health", needs_reason_stale_auth: "Codex needs a restart", needs_stale_auth_detail: "Codex cannot refresh this agent’s current sign-in. Restart the agent; sign in again only if Codex asks.", needs_reason_hub_proposal: "Hub action proposed: review locally", needs_reason_hub_execution_hold: "Hub work held: review locally", needs_reason_hub_unavailable: "Hub not running", needs_reason_tmux_hold: "Held: an old tmux server or window" },
38
+ "zh-TW": { needs_reason_host_health: "主機狀態", needs_reason_stale_auth: "Codex 需要重新啟動", needs_stale_auth_detail: "Codex 無法更新這個 Agent 執行中使用的登入。請重新啟動 Agent;只有 Codex 要求時才需要重新登入。", needs_reason_hub_proposal: "Hub 提議操作:請在本機檢視", needs_reason_hub_execution_hold: "Hub 工作已暫停:請在本機檢視", needs_reason_hub_unavailable: "Hub 未在執行", needs_reason_tmux_hold: "已暫停:舊的 tmux 伺服器或視窗" },
38
39
  });
39
40
 
40
41
  register("needs", {
@@ -42,8 +43,8 @@ register("needs", {
42
43
  otherEmpty: "No other items are waiting for you.", title: "Needs you", empty: "Nothing needs you right now", emptyHint: "When an agent waits for you, it shows here — and in your chat app's General.", emptyHintWeb: "When an agent waits for you, it shows here.",
43
44
  open: "Open chat", kiroOpen: "Open agent", kiroMigration: "Migration instructions", openCard: "Open the card", noAssignee: "Task board (nobody assigned)", fleetSignIns: "AI accounts", signIn: "Connect account",
44
45
  gap: "not wrapped up: {0}", gapUnchecked: "{0} checklist item(s) unchecked", gapNoResult: "no result", gapJoin: ", ", acknowledge: "Acknowledge", acknowledging: "Acknowledging…", answering: "Answering…",
45
- ageNow: "just now", ageMin: "{0} min", ageHour: "{0} h", ageDay: "{0} d",
46
- notifyTitle: "Notify me on this device", notifyOn: "Notifications are on for this browser while a tab is open.",
46
+ ageNow: "just now", ageMin: "{0} min ago", ageHour: "{0} h ago", ageDay: "{0} d ago",
47
+ notifySection: "This device", notifyTitle: "Notify me on this device", notifyOn: "Notifications are on for this browser while a tab is open.",
47
48
  notifyOff: "Get a desktop notification when something new needs you while this tab is in the background.",
48
49
  notifyDenied: "This browser blocked notifications for AgEnD. Allow them in the site settings to turn this on.",
49
50
  notifyMobile: "On a phone, rely on your chat app's notification: a new item is a new post in General.", notifyMobileWeb: "On a phone, open this page to see what needs you.",
@@ -67,8 +68,8 @@ register("needs", {
67
68
  otherEmpty: "沒有其他待處理事項。", title: "等你處理", empty: "目前沒有需要你處理的事", emptyHint: "agent 在等你時,會出現在這裡——也會出現在聊天 app 的 General。", emptyHintWeb: "agent 在等你時,會出現在這裡。",
68
69
  open: "開啟聊天", kiroOpen: "開啟 Agent", kiroMigration: "遷移說明", openCard: "打開卡片", noAssignee: "任務看板(沒有負責人)", fleetSignIns: "AI 帳號", signIn: "連接帳號",
69
70
  gap: "還沒補齊:{0}", gapUnchecked: "還有 {0} 項沒勾", gapNoResult: "沒有產出總結", gapJoin: "、", acknowledge: "確認", acknowledging: "確認中…", answering: "回覆中…",
70
- ageNow: "剛剛", ageMin: "{0} 分鐘", ageHour: "{0} 小時", ageDay: "{0} 天",
71
- notifyTitle: "在這台裝置通知我", notifyOn: "這個瀏覽器的通知已開啟(需要開著分頁)。",
71
+ ageNow: "剛剛", ageMin: "{0} 分鐘前", ageHour: "{0} 小時前", ageDay: "{0} 天前",
72
+ notifySection: "這台裝置", notifyTitle: "在這台裝置通知我", notifyOn: "這個瀏覽器的通知已開啟(需要開著分頁)。",
72
73
  notifyOff: "分頁在背景時,有新的事等你處理就跳出桌面通知。",
73
74
  notifyDenied: "這個瀏覽器封鎖了 AgEnD 的通知。請在網站設定中允許後再開啟。",
74
75
  notifyMobile: "在手機上請以聊天 app 的通知為主:每個新項目都會在 General 發一則新訊息。", notifyMobileWeb: "在手機上請打開這個頁面查看等你處理的事。",
@@ -165,7 +166,7 @@ export function groupNeeds(items) {
165
166
  const groups = new Map();
166
167
  for (const item of items) {
167
168
  // Configuration issues belong to Settings, not the unassigned task/sign-in group.
168
- const key = JSON.stringify([item.instance, !item.instance && item.type === "config"]);
169
+ const key = JSON.stringify([item.instance, !item.instance && item.type === "config",item.type==='host']);
169
170
  const group = groups.get(key);
170
171
  if (group) group.items.push(item);
171
172
  else groups.set(key, { instance: item.instance, items: [item] });
@@ -217,8 +218,8 @@ export function NeedsPanel({ navKey }) {
217
218
  </section>` : null}
218
219
  ${(!ready || needsLoaded === false) && !items.length && !asks.length ? html`<${Skeleton} variant="rows" lines=${3} />`
219
220
  : !items.length && !asks.length && !decidedHere.length ? hostDirectoryNoticesOffered() ? html`<p class="muted">${tn("otherEmpty")}</p>` : html`<${Empty} icon="check" title=${tn("empty")} hint=${tn(chatApp ? "emptyHint" : "emptyHintWeb")} />`
220
- : groups.map((g) => html`<section key=${JSON.stringify([g.instance, g.items[0]?.type === "config", !!g.items[0]?.runtimeUpdate])} class="n-group" aria-label=${g.items[0]?.runtimeUpdate ? runtimeUpdateText("attention") : g.instance}>
221
- <h2 class="n-group-head">${g.items[0]?.runtimeUpdate ? runtimeUpdateText("attention") : g.instance ? html`<a href=${chatPath(g.instance)} title=${g.instance}>${nameFor(g.instance)}</a>` : g.items[0]?.type === "config" ? t("app.settings") : tn(g.items.some(i => i.type === "backend") ? "fleetSignIns" : "noAssignee")}</h2>
221
+ : groups.map((g) => html`<section key=${JSON.stringify([g.instance, g.items[0]?.type === "config",g.items[0]?.type === 'host', !!g.items[0]?.runtimeUpdate])} class="n-group" aria-label=${g.items[0]?.runtimeUpdate ? runtimeUpdateText("attention") : g.instance}>
222
+ <h2 class="n-group-head">${g.items[0]?.runtimeUpdate ? runtimeUpdateText("attention") : g.instance ? html`<a href=${chatPath(g.instance)} title=${g.instance}>${nameFor(g.instance)}</a>` : g.items[0]?.type==='host'?hostAlertText('title'):g.items[0]?.type === "config" ? t("app.settings") : tn(g.items.some(i => i.type === "backend") ? "fleetSignIns" : "noAssignee")}</h2>
222
223
  ${g.items.map((item) => item.type === "contact"
223
224
  // M-3339: a contact request or the restricted-mode suggestion — its own card (contact-needs.js; references only).
224
225
  ? html`<${ContactNeedsItem} key=${item.id} item=${item} />`
@@ -272,10 +273,11 @@ function NeedsItem({ item, nowMs, owner }) {
272
273
  return html`<article data-trust="permission" class=${`n-item${BAD.has(item.reason) ? " bad" : ""}`}>
273
274
  <span class="n-icon"><${Icon} name=${ICON[item.type] || "alert"} size=${18} /></span>
274
275
  <div class="n-body">
275
- <div class="n-title"><strong>${itemReason(item)}</strong><span class="n-age">${age(item.since, nowMs)}</span></div>
276
- ${detailOf(item) ? html`<p class="n-detail">${detailOf(item)}</p>` : null}
276
+ <div class="n-title"><strong>${item.type==='host'?hostAlertName(item.hostAlert):itemReason(item)}</strong><span class="n-age">${item.type==='host'?hostAlertText('started')+age(item.since, nowMs):age(item.since, nowMs)}</span></div>
277
+ ${item.type==='host'&&item.hostAlert?html`<p class="n-detail">${hostAlertText(item.hostAlert.level)} · ${hostAlertDescription(item.hostAlert)}</p>`:item.type==='host'?html`<p class="n-detail">${hostAlertText('failed')}</p>`:detailOf(item)?html`<p class="n-detail">${detailOf(item)}</p>`:null}
277
278
  ${item.type === "hub" && item.hubProposal ? html`<p class="n-detail">${item.hubProposal.action}</p><pre>${item.hubProposal.arguments}</pre><p class="n-detail">${item.hubProposal.consequences}</p>` : null}
278
279
  ${item.generalLocation ? html`<${GeneralLocation} name=${item.instance} attentionOnly=${true} />` : null}
280
+ ${item.type==='host'?(item.hostAlert?html`<${HostAlertActions} record=${item.hostAlert}/>`:html`<a class="btn btn-sm" href=${fleetPath('host-health')}>${hostAlertText('open')}</a>`):null}
279
281
  <div class="n-actions">
280
282
  ${item.type === "prompt" && Array.isArray(item.actions) ? item.actions.filter((a) => !a.input).map((a) => html`<button key=${a.id} type="button" class="btn btn-sm"
281
283
  disabled=${promptBusy} onClick=${() => answer(a.id)}>${(p ? p.busy : fallback === "busy") ? tn("answering") : a.label}</button>`) : null}
@@ -405,9 +407,18 @@ function NotifyToggle() {
405
407
  const { connections } = useStore(appStore);
406
408
  const note = support === "mobile" ? tn(connections > 0 ? "notifyMobile" : "notifyMobileWeb") : support === "insecure" ? tn("notifyInsecure")
407
409
  : support !== "ok" ? tn("notifyUnsupported") : state === "denied" ? tn("notifyDenied") : on ? tn("notifyOn") : tn("notifyOff");
408
- return html`<section class="card n-notify"><h3>${tn("notifyTitle")}</h3>
409
- <p class="note">${note}</p>
410
- ${support === "ok" ? html`<div><button type="button" class=${`btn btn-sm${on ? "" : " btn-primary"}`} aria-pressed=${on ? "true" : "false"} disabled=${asking} onClick=${toggle}>
411
- <${Icon} name="bell" size=${14} />${on ? tn("turnOff") : tn("turnOn")}</button></div>` : null}
410
+ // M-3503 (the user): a setting of this device, not an item waiting — its own section under the list (a rule above it,
411
+ // its own heading), drawn as an item row (icon, then the words and the button) so every card's text and buttons share
412
+ // one edge. Its own class names (styled with the items' in app.css): nothing that counts the items counts it.
413
+ return html`<section class="n-settings" aria-labelledby="n-settings-head"><h2 class="n-settings-head" id="n-settings-head">${tn("notifySection")}</h2>
414
+ <article class="n-notify">
415
+ <span class="n-notify-icon"><${Icon} name="bell" size=${18} /></span>
416
+ <div class="n-notify-body">
417
+ <div class="n-notify-title"><strong>${tn("notifyTitle")}</strong></div>
418
+ <p class="n-notify-note note">${note}</p>
419
+ ${support === "ok" ? html`<div class="n-notify-actions"><button type="button" class=${`btn btn-sm${on ? "" : " btn-primary"}`} aria-pressed=${on ? "true" : "false"} disabled=${asking} onClick=${toggle}>
420
+ <${Icon} name="bell" size=${14} />${on ? tn("turnOff") : tn("turnOn")}</button></div>` : null}
421
+ </div>
422
+ </article>
412
423
  </section>`;
413
424
  }
@@ -119,6 +119,7 @@ export async function loadAll(lease) {
119
119
  if (!lease.current()) return null;
120
120
  if (!fleet.ok) return { error: true };
121
121
  out.fleet = fleet.body || {};
122
+ if(out.schema?.host_alert_defaults){const alerts=await read(lease,'/api/settings/fleet/host-alerts');if(!lease.current())return null;out.hostAlerts=alerts.ok?alerts.body:null;}
122
123
  const classic = await read(lease, "/api/settings/classic");
123
124
  if (!lease.current()) return null;
124
125
  out.classic = classic.body || {};
@@ -528,7 +529,7 @@ export function SettingsPanel({ route, navKey }) {
528
529
  <button type="button" class="btn btn-ghost btn-sm" disabled=${!ctx || yamlStaged(staged)} title=${ctx && yamlStaged(staged) ? tn("yamlUnsaved") : undefined} onClick=${openWizard}><${Icon} name="wand" size=${16} /><span class="hide-narrow">${tn("wizardButton")}</span></button>
529
530
  <button type="button" class="icon-btn" aria-label=${tn("helpButton")} title=${tn("helpButton")} onClick=${() => setDialog({ kind: "help", key: navKey })}><${Icon} name="info" /></button>
530
531
  </${PanelHeader}>
531
- <nav data-trust="panel-navigation" class="seg s-nav" aria-label=${tn("title")}><${SettingsSearch} /><div class="s-nav-groups">${SETTINGS_GROUPS.map((g) => html`<div key=${g.id} class="s-nav-group" role="group" aria-labelledby=${`s-grp-${g.id}`}>
532
+ <nav data-trust="panel-navigation" class="seg s-nav" aria-label=${tn("title")}><${SettingsSearch} schema=${ctx?.schema} /><div class="s-nav-groups">${SETTINGS_GROUPS.map((g) => html`<div key=${g.id} class="s-nav-group" role="group" aria-labelledby=${`s-grp-${g.id}`}>
532
533
  <span class="s-nav-head" id=${`s-grp-${g.id}`}>${tn(`grp_${g.id}`)}</span>
533
534
  ${g.sections.map((k) => html`<a key=${k} href=${sectionPath(k)} class=${`seg-item${k === section ? " active" : ""}`} title=${tn(`sec_${k}`)}
534
535
  aria-current=${k === section ? "page" : undefined}><${Icon} name=${ICONS[k]} size=${16} /><span>${tn(`sec_${k}`)}</span></a>`)}</div>`)}</div></nav>
@@ -582,10 +583,10 @@ function marked(text, query) {
582
583
  * #2347 §6: search every setting — by its name, its config key, or the words people use (both languages: "token",
583
584
  * "語言", "port") — results grouped by section with where they are; Enter or a click goes there. "/" focuses it.
584
585
  */
585
- function SettingsSearch() {
586
+ function SettingsSearch({schema}) {
586
587
  const [q, setQ] = useState("");
587
588
  const [active, setActive] = useState(0);
588
- const hits = useMemo(() => searchSettings(q).slice(0, 40), [q]);
589
+ const hits = useMemo(() => searchSettings(q, schema).slice(0, 40), [q, schema]);
589
590
  // Grouped by section, the group of the best match first (its order is the ranking's): Enter takes the best.
590
591
  const groups = useMemo(() => [...new Set(hits.map((e) => e.section))].map((s) => ({ section: s, items: hits.filter((e) => e.section === s) })), [hits]);
591
592
  const flat = groups.flatMap((g) => g.items);
@@ -240,7 +240,14 @@ export function SearchDialog({ preset = {}, onClose }) {
240
240
  // While a new query runs, the last answer stays (dimmed) rather than flashing empty.
241
241
  const groups = useMemo(() => groupHits(res.hits || []), [res]);
242
242
  // #2347 §6: the settings matching the query, from the page's own registry (no request), above the messages.
243
- const settings = useMemo(() => (q.trim() && !guest ? searchSettings(q).slice(0, SETTINGS_SHOWN) : []), [q]);
243
+ const [settingsSchema,setSettingsSchema] = useState(null);
244
+ useEffect(() => {
245
+ if (guest) {setSettingsSchema(null);return;}
246
+ let current=true;const ac=new AbortController();
247
+ fetch("/api/settings/schema",{signal:ac.signal}).then(r=>r.ok?r.json():null).then(schema=>{if(current)setSettingsSchema(schema);},()=>{if(current)setSettingsSchema(null);});
248
+ return ()=>{current=false;ac.abort();};
249
+ },[guest]);
250
+ const settings = useMemo(() => (q.trim() && !guest ? searchSettings(q, settingsSchema).slice(0, SETTINGS_SHOWN) : []), [q, guest, settingsSchema]);
244
251
  const flat = useMemo(() => [...settings.map((entry) => ({ setting: entry })), ...flatHits(groups)], [settings, groups]);
245
252
  const activeFilters = (f.instance ? 1 : 0) + (f.team ? 1 : 0) + (f.since !== "any" ? 1 : 0) + (!guest && f.sources.length < SOURCES.length ? 1 : 0) + (f.mine ? 1 : 0);
246
253
 
@@ -0,0 +1,2 @@
1
+ // One visibility rule for the card, Settings search and Ctrl K. Unknown is hidden.
2
+ export const hostMonitoringVisible = schema => schema?.host_monitoring === true && schema?.host_monitoring_page === true;
@@ -0,0 +1,22 @@
1
+ import {html,useEffect} from '/assets/app-html.js';
2
+ import {register,t} from '/assets/app-i18n.js';
3
+ import {useDraft,syncStage} from './settings-draft.js';
4
+ import {hostAlertText,hostAlertDrive,hostAlertName} from './host-alerts.js';
5
+ register('hostAlertSettings',{
6
+ en:{title:'Host alert settings',needs:'Show in Needs you',general:'Send summaries to General',handoff:'General is off initially. The existing disk-watch script keeps sending its own alerts, so turning General on may send duplicate alerts.',resource:'Resource',warning:'Warning',urgent:'Urgent',clear:'Recovery',percent:'Percent used',gib:'GiB available',fixed:'Memory thresholds use the existing Normal / Elevated / Critical pressure states.',defaults:'Restore defaults',holds:'Threshold holds and recovery delays keep brief spikes from becoming alerts. Acknowledgment does not hide a problem; snooze it from Host health.',off:'Rules are saved while monitoring is off. No alert checks, notification retries or incident files run while off.'},
7
+ 'zh-TW':{title:'主機警示設定',needs:'顯示在「等你處理」',general:'傳送摘要至 General',handoff:'General 通知預設關閉。現有 disk-watch 腳本仍會傳送自己的警示,開啟 General 通知可能會收到重複提醒。',resource:'監測項目',warning:'注意',urgent:'緊急',clear:'恢復',percent:'使用率(%)',gib:'可用 GiB',fixed:'記憶體門檻沿用正常/偏高/嚴重的壓力狀態。',defaults:'還原預設值',holds:'門檻持續時間與恢復延遲可避免短暫尖峰觸發警示。標記已看過不會隱藏問題;可在主機狀態暫停提醒。',off:'監測關閉時仍可儲存規則,但不會執行警示檢查、通知重試或建立問題檔案。'}
8
+ });
9
+ const text=k=>t('hostAlertSettings.'+k);
10
+ export function HostAlertSettings({ctx,health}){
11
+ const defaults=ctx.schema?.host_alert_defaults,base=ctx.hostAlerts;
12
+ const [form,setForm]=useDraft(ctx,'host-alerts',()=>base||{version:1,needsYou:true,general:false,rules:{}});
13
+ useEffect(()=>{syncStage(ctx,'host-alerts',base&&defaults&&JSON.stringify(form)!==JSON.stringify(base)?{label:text('title'),impact:'now',request:{method:'PUT',url:'/api/settings/fleet/host-alerts',body:form}}:null);},[form,base,defaults]);
14
+ if(!base||!defaults)return null;
15
+ const disks=(health?.disks?.value?.volumes||[]).slice(0,62),resources=[{key:'cpu',kind:'cpu',name:hostAlertText('cpu')},{key:'memory',kind:'memory',name:hostAlertText('memory')},...disks.map(v=>({key:'disk:'+v.id,kind:v.roles.includes('wsl-backing')?'backing-drive':'filesystem',name:hostAlertName({key:'disk:'+v.id,kind:v.roles.includes('wsl-backing')?'backing-drive':'filesystem'})+hostAlertDrive(v.drive)}))];
16
+ for(const [key,rule] of Object.entries(form.rules))if(!resources.some(r=>r.key===key))resources.push({key,kind:rule.kind,name:hostAlertText(rule.kind==='backing-drive'?'backing':'filesystem')+' · '+key.slice(-6)});
17
+ const update=(key,kind,field,value)=>setForm(f=>({...f,rules:{...f.rules,[key]:{...defaults[kind],...f.rules[key],[field]:value}}}));
18
+ const reset=()=>setForm(f=>({...f,rules:{}}));
19
+ const choice=(key,label)=>html`<div class="s-setting-row"><div class="s-setting-copy"><label for=${'hostAlert-'+key}>${text(label)}</label></div><input id=${'hostAlert-'+key} class="s-ui-toggle" type="checkbox" role="switch" checked=${form[key]} onChange=${e=>setForm(f=>({...f,[key]:e.target.checked}))}/></div>`;
20
+ return html`<div class="host-alert-settings"><h4>${text('title')}</h4>${choice('needsYou','needs')}${choice('general','general')}<p class="note">${text('handoff')}</p>
21
+ <details><summary>${text('resource')}</summary>${resources.map(resource=>{const rule=form.rules[resource.key]||defaults[resource.kind],factor=resource.kind==='backing-drive'?1024**3:1;return html`<fieldset class="field" key=${resource.key}><legend>${resource.name}</legend>${resource.kind==='memory'?html`<p class="note">${text('fixed')}</p>`:html`<p class="note">${text(resource.kind==='backing-drive'?'gib':'percent')}</p><div class="grid2">${['warning','urgent','clear'].map(field=>html`<div class="field"><label for=${'alert-'+resource.key+'-'+field}>${text(field)}</label><input id=${'alert-'+resource.key+'-'+field} type="number" min="0" step=${resource.kind==='backing-drive'?'1':'0.1'} value=${rule[field]/factor} onInput=${e=>update(resource.key,resource.kind,field,Number(e.target.value)*factor)}/></div>`)}</div>`}</fieldset>`;})}<button class="btn btn-sm" type="button" onClick=${reset}>${text('defaults')}</button></details><p class="note">${text('holds')}</p><p class="note">${text('off')}</p></div>`;
22
+ }