@songsid/agend 2.3.5-alpha.11 → 2.3.5-alpha.13

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 (168) hide show
  1. package/THIRD_PARTY_NOTICES.md +4 -0
  2. package/dist/accounts-view.d.ts +3 -0
  3. package/dist/accounts-view.js +2 -2
  4. package/dist/accounts-view.js.map +1 -1
  5. package/dist/agent-workspace.d.ts +1 -2
  6. package/dist/agent-workspace.js +8 -29
  7. package/dist/agent-workspace.js.map +1 -1
  8. package/dist/auth-api.js +15 -29
  9. package/dist/auth-api.js.map +1 -1
  10. package/dist/backend/claude-code.js +16 -3
  11. package/dist/backend/claude-code.js.map +1 -1
  12. package/dist/backend/codex.d.ts +7 -14
  13. package/dist/backend/codex.js +25 -29
  14. package/dist/backend/codex.js.map +1 -1
  15. package/dist/backend/credential-profile.d.ts +16 -0
  16. package/dist/backend/credential-profile.js +44 -0
  17. package/dist/backend/credential-profile.js.map +1 -1
  18. package/dist/backend/grok-mcp.d.ts +5 -0
  19. package/dist/backend/grok-mcp.js +221 -0
  20. package/dist/backend/grok-mcp.js.map +1 -0
  21. package/dist/backend/grok.d.ts +0 -10
  22. package/dist/backend/grok.js +5 -82
  23. package/dist/backend/grok.js.map +1 -1
  24. package/dist/backend/muse.d.ts +3 -1
  25. package/dist/backend/muse.js +31 -1
  26. package/dist/backend/muse.js.map +1 -1
  27. package/dist/backend/types.d.ts +18 -1
  28. package/dist/backend/types.js.map +1 -1
  29. package/dist/build-provenance.json +1 -1
  30. package/dist/cli.js +18 -0
  31. package/dist/cli.js.map +1 -1
  32. package/dist/codex-pane-ownership.d.ts +13 -0
  33. package/dist/codex-pane-ownership.js +192 -0
  34. package/dist/codex-pane-ownership.js.map +1 -0
  35. package/dist/create-host-account.d.ts +17 -0
  36. package/dist/create-host-account.js +47 -0
  37. package/dist/create-host-account.js.map +1 -0
  38. package/dist/daemon.d.ts +25 -0
  39. package/dist/daemon.js +203 -16
  40. package/dist/daemon.js.map +1 -1
  41. package/dist/delivery-outbox.js +7 -0
  42. package/dist/delivery-outbox.js.map +1 -1
  43. package/dist/fleet-manager.d.ts +40 -9
  44. package/dist/fleet-manager.js +198 -47
  45. package/dist/fleet-manager.js.map +1 -1
  46. package/dist/general-knowledge/skills/concepts/SKILL.md +1 -1
  47. package/dist/general-knowledge/skills/kiro-engine-migration/SKILL.md +1 -1
  48. package/dist/hub/client.d.ts +1 -1
  49. package/dist/hub/client.js +11 -0
  50. package/dist/hub/client.js.map +1 -1
  51. package/dist/hub/compose/member.d.ts +2 -2
  52. package/dist/hub/compose/member.js +11 -3
  53. package/dist/hub/compose/member.js.map +1 -1
  54. package/dist/hub/member/exposure-api.d.ts +2 -0
  55. package/dist/hub/member/exposure-api.js +4 -2
  56. package/dist/hub/member/exposure-api.js.map +1 -1
  57. package/dist/hub/member/pairing-api.d.ts +2 -2
  58. package/dist/hub/member/pairing-api.js +2 -2
  59. package/dist/hub/member/pairing-api.js.map +1 -1
  60. package/dist/hub/server.js +8 -0
  61. package/dist/hub/server.js.map +1 -1
  62. package/dist/hub-pairing-summary.d.ts +3 -1
  63. package/dist/hub-pairing-summary.js +6 -3
  64. package/dist/hub-pairing-summary.js.map +1 -1
  65. package/dist/instance-lifecycle.js +29 -1
  66. package/dist/instance-lifecycle.js.map +1 -1
  67. package/dist/locale.js +13 -9
  68. package/dist/locale.js.map +1 -1
  69. package/dist/public-web-link.d.ts +5 -0
  70. package/dist/public-web-link.js +8 -0
  71. package/dist/public-web-link.js.map +1 -1
  72. package/dist/runtime-client-store.js +5 -0
  73. package/dist/runtime-client-store.js.map +1 -1
  74. package/dist/runtime-pane-private.d.ts +2 -0
  75. package/dist/runtime-pane-private.js +25 -0
  76. package/dist/runtime-pane-private.js.map +1 -1
  77. package/dist/runtime-pane-private.ps1 +74 -7
  78. package/dist/selection-card.d.ts +4 -3
  79. package/dist/selection-card.js +2 -1
  80. package/dist/selection-card.js.map +1 -1
  81. package/dist/settings-api.js +5 -17
  82. package/dist/settings-api.js.map +1 -1
  83. package/dist/settings-change.d.ts +2 -0
  84. package/dist/settings-change.js +74 -31
  85. package/dist/settings-change.js.map +1 -1
  86. package/dist/settings-confirmation.d.ts +23 -0
  87. package/dist/settings-confirmation.js +13 -2
  88. package/dist/settings-confirmation.js.map +1 -1
  89. package/dist/settings-effect.d.ts +4 -0
  90. package/dist/settings-effect.js +14 -14
  91. package/dist/settings-effect.js.map +1 -1
  92. package/dist/settings-http-confirmation.d.ts +3 -1
  93. package/dist/settings-http-confirmation.js +12 -7
  94. package/dist/settings-http-confirmation.js.map +1 -1
  95. package/dist/settings-summary.d.ts +24 -0
  96. package/dist/settings-summary.js +42 -0
  97. package/dist/settings-summary.js.map +1 -0
  98. package/dist/signin-keepalive.d.ts +25 -1
  99. package/dist/signin-keepalive.js +44 -1
  100. package/dist/signin-keepalive.js.map +1 -1
  101. package/dist/transcript-delta-reader.d.ts +9 -1
  102. package/dist/transcript-delta-reader.js +37 -8
  103. package/dist/transcript-delta-reader.js.map +1 -1
  104. package/dist/ui/accounts-view.js +9 -7
  105. package/dist/ui/agent-details-settings.js +253 -0
  106. package/dist/ui/agent-instructions-field.js +69 -0
  107. package/dist/ui/agent-page-strings.js +148 -0
  108. package/dist/ui/chat-quote.js +12 -17
  109. package/dist/ui/hub-client.js +1 -1
  110. package/dist/ui/hub-company-join-strings.js +1 -1
  111. package/dist/ui/hub-company-join.js +7 -0
  112. package/dist/ui/hub-strings.js +10 -6
  113. package/dist/ui/native-instance-settings.js +47 -14
  114. package/dist/ui/panel-chat.js +2 -1
  115. package/dist/ui/panel-details.js +38 -14
  116. package/dist/ui/panel-fleet.js +9 -3
  117. package/dist/ui/panel-settings.js +17 -8
  118. package/dist/ui/settings-access-overview.js +188 -0
  119. package/dist/ui/settings-access-strings.js +1 -1
  120. package/dist/ui/settings-confirm.js +5 -5
  121. package/dist/ui/settings-devices.js +5 -5
  122. package/dist/ui/settings-dialogs.js +208 -100
  123. package/dist/ui/settings-hub-company-join.js +69 -14
  124. package/dist/ui/settings-hub.js +13 -5
  125. package/dist/ui/settings-layout.js +1 -1
  126. package/dist/ui/settings-model.js +15 -0
  127. package/dist/ui/settings-strings.js +8 -8
  128. package/dist/ui/shared/access-overview.css +48 -0
  129. package/dist/ui/shared/app-i18n.js +2 -2
  130. package/dist/ui/shared/app-shell.js +145 -4
  131. package/dist/ui/shared/app-store.js +2 -0
  132. package/dist/ui/shared/app.css +69 -7
  133. package/dist/ui/shared/chat-render.js +17 -5
  134. package/dist/ui/shared/device-roles.js +1 -1
  135. package/dist/ui/shared/instance-nav.js +5 -1
  136. package/dist/ui/shared/signin.js +130 -43
  137. package/dist/ui/shared/usage-dialog.js +27 -15
  138. package/dist/ui/shared/view-strings.js +2 -0
  139. package/dist/ui/shared/web-authorize.js +2 -2
  140. package/dist/ui/signin.html +19 -8
  141. package/dist/update-dispatch.d.ts +50 -0
  142. package/dist/update-dispatch.js +58 -2
  143. package/dist/update-dispatch.js.map +1 -1
  144. package/dist/usage/format-rich.js +1 -1
  145. package/dist/usage/format-rich.js.map +1 -1
  146. package/dist/usage/usage-api.d.ts +8 -2
  147. package/dist/usage/usage-api.js +12 -5
  148. package/dist/usage/usage-api.js.map +1 -1
  149. package/dist/web-api.d.ts +5 -0
  150. package/dist/web-api.js +58 -0
  151. package/dist/web-api.js.map +1 -1
  152. package/dist/web-backend-login.d.ts +2 -0
  153. package/dist/web-backend-login.js.map +1 -1
  154. package/dist/web-remote-access.d.ts +71 -3
  155. package/dist/web-remote-access.js +197 -6
  156. package/dist/web-remote-access.js.map +1 -1
  157. package/dist/web-session.d.ts +4 -2
  158. package/dist/web-session.js +5 -2
  159. package/dist/web-session.js.map +1 -1
  160. package/dist/workspace-file-policy.d.ts +2 -0
  161. package/dist/workspace-file-policy.js +31 -0
  162. package/dist/workspace-file-policy.js.map +1 -0
  163. package/dist/workspace-follow.js +2 -1
  164. package/dist/workspace-follow.js.map +1 -1
  165. package/package.json +2 -2
  166. package/templates/runtime-assets/runtime-pane-private.ps1 +74 -7
  167. package/dist/ui/shared/signin-authenticator.js +0 -60
  168. package/dist/ui/signin-authenticator.html +0 -60
@@ -0,0 +1,253 @@
1
+ // one agent's "Details & settings" page — the Details tab with its settings beside the read-only facts.
2
+ // Categories on the left (a tab row in the middle, a list on a phone), each one a group of the agent's settings, with the
3
+ // read-only Overview first. The fields are the ones the Settings dialogs always had (settings-dialogs.js: useAgentForm /
4
+ // AgentFields; native-instance-settings.js; useClassicForm / ClassicFields) — this file adds only where they live:
5
+ // - the categories and their nav (the shared Settings `.s-nav`, with an icon in front of every item you can open);
6
+ // - the staging: an edit is staged at once (the Settings page's own "N changes pending" bar and its confirmations),
7
+ // and the Apply is the app's runner (settings-apply.js) — nothing here writes by itself;
8
+ // - one read of the configuration the first time a settings category is opened (#1374: nothing recurring).
9
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
10
+ import { t } from "/assets/app-i18n.js";
11
+ import { appStore, useStore } from "/assets/app-store.js";
12
+ import { navigate, setLeaveGuard } from "/assets/app-nav.js";
13
+ import { detailsPath } from "/assets/app-route.js";
14
+ import { Icon } from "/assets/ui-icons.js";
15
+ import { toast } from "/assets/ui-toast.js";
16
+ import { Skeleton, ErrorState } from "/assets/ui-states.js";
17
+ import { PageHead } from "/assets/page-head.js";
18
+ import "./settings-strings.js";
19
+ import "./settings-shared-strings.js";
20
+ import "./settings-restart-strings.js";
21
+ import "./agent-page-strings.js";
22
+ import { pt } from "./agent-page-strings.js";
23
+ import { operationActive, startOperation, takeLeftover } from "./settings-apply.js";
24
+ import { batchImpact, impactOf, shortName } from "./settings-model.js";
25
+ import { AGENT_CATEGORIES, AgentFields, CLASSIC_CATEGORIES, ClassicFields, ask, useAgentForm, useClassicForm } from "./settings-dialogs.js";
26
+ import { NATIVE_CATEGORIES, NativeFields, useNativeForm } from "./native-instance-settings.js";
27
+
28
+ const tn = (k, ...v) => t(`settings.${k}`, ...v);
29
+
30
+ /** The icon in front of each category you can open — the project's own set (ui-icons.js). */
31
+ export const CATEGORY_ICONS = { overview: "eye", basic: "idcard", runtime: "bot", work: "view", channel: "chat", adv: "code" };
32
+ /** Which kind of page this is: a ClassicBot room (classicBot.yaml), a Windows native agent, or a fleet agent. */
33
+ export const agentKind = (d, inst) => (d && d.kind === "classic" ? "classic" : inst && inst.runtime === "windows" ? "native" : "fleet");
34
+ /** The categories of a kind, Overview first. A native agent has no channel binding or idle settings; a ClassicBot room has no basic info or workspace. */
35
+ export const categoriesOf = (kind) => ["overview", ...(kind === "classic" ? CLASSIC_CATEGORIES : kind === "native" ? NATIVE_CATEGORIES : AGENT_CATEGORIES)];
36
+ export const categoryLabel = (kind, cat) => pt(kind === "classic" && cat === "channel" ? "cat_classicChannel" : `cat_${cat}`);
37
+ /** The category the address names (`?cat=`), or "" for none — the phone's list, and Overview on a wide screen. */
38
+ export function categoryFromSearch(kind, search = typeof location !== "undefined" ? location.search : "") {
39
+ const cat = new URLSearchParams(search).get("cat") || "";
40
+ if (categoriesOf(kind).includes(cat)) return cat;
41
+ // A category this kind has no page for (the sidebar's ⚙ always names Basic info) goes to its first one.
42
+ return Object.keys(CATEGORY_ICONS).includes(cat) ? categoriesOf(kind)[1] : "";
43
+ }
44
+ export const categoryPath = (name, cat) => (cat ? `${detailsPath(name)}?cat=${cat}` : detailsPath(name));
45
+
46
+ /** Which category each key of a patch belongs to (a dot on the nav says "this one has changes"). */
47
+ const AGENT_KEYS = {
48
+ basic: ["display_name", "description", "systemPrompt", "tags"],
49
+ runtime: ["backend", "model", "model_failover", "backend_options"],
50
+ work: ["working_directory", "auto_pause_after", "hang_detector", "agent_mode", "tool_set", "reply_completion_guard", "lightweight"],
51
+ channel: ["channel_id", "general_topic", "tool_progress", "cross_instance_visibility", "status_emojis"],
52
+ adv: ["log_level", "resume_interrupted_work", "mcp_proxy_reply", "board_cards_at_once", "dashboard", "office_access", "office_pack_access"],
53
+ };
54
+ const NATIVE_KEYS = { basic: ["display_name", "description", "tags"], runtime: ["model"], work: ["native_sandbox"], adv: ["systemPrompt"] };
55
+ const CLASSIC_KEYS = { runtime: ["backend", "model", "auto_pause_after"], channel: ["tool_progress", "reply_completion_guard", "reply_triggers", "collab", "web_echo", "context_lines"] };
56
+ export function dirtyCategories(kind, patch) {
57
+ const map = kind === "classic" ? CLASSIC_KEYS : kind === "native" ? NATIVE_KEYS : AGENT_KEYS;
58
+ const keys = Object.keys(patch || {});
59
+ return new Set(Object.entries(map).filter(([, list]) => keys.some((k) => list.includes(k))).map(([cat]) => cat));
60
+ }
61
+
62
+ /** What one agent's edit costs and where it is sent — the same request the dialog's Done stages (panel-settings.js makeCtx). */
63
+ export function changeFor(ctx, kind, name, inst, room, patch) {
64
+ const { schema } = ctx;
65
+ if (kind === "classic") {
66
+ const hotOnly = Object.keys(patch).every((k) => impactOf(schema, `classic.${k}`) === "now");
67
+ return { label: tn("updateAgent", room.name || room.instanceName), impact: hotOnly ? "now" : "instance",
68
+ request: { method: "PATCH", url: `/api/settings/classic/channels/${encodeURIComponent(room.key)}`, body: patch } };
69
+ }
70
+ const native = inst.runtime === "windows";
71
+ return { label: tn("updateAgent", shortName(name, { ...inst, ...patch })),
72
+ impact: native ? "now" : batchImpact(schema, Object.keys(patch), (k) => impactOf(schema, `instance.${k}`)),
73
+ request: { method: "PATCH", url: native ? `/ui/instances/${encodeURIComponent(name)}` : `/api/settings/fleet/instances/${encodeURIComponent(name)}`, body: patch } };
74
+ }
75
+
76
+ // ── The staging: this page's, with the Settings page's rules ──
77
+
78
+ let settingsModule = null;
79
+ /** panel-settings.js — its reader of the configuration, its context and its pending bar — loaded when a settings category first opens. */
80
+ const loadSettingsModule = () => (settingsModule ||= import("./panel-settings.js"));
81
+
82
+ /**
83
+ * The configuration of this page (read the first time `enabled`), the changes staged against it, and the Apply. Staged
84
+ * changes wait for the Apply bar (one runner: the app's, settings-apply.js); leaving the page with some asks first.
85
+ */
86
+ export function useAgentSettings({ name, lease, enabled, navKey }) {
87
+ const [mod, setMod] = useState(null);
88
+ const [data, setData] = useState(null);
89
+ const [staged, setStaged] = useState(() => new Map());
90
+ const stagedRef = useRef(staged);
91
+ stagedRef.current = staged;
92
+ const [epoch, setEpoch] = useState(0); // moves after a Discard and after a Save: the forms start again from what is saved
93
+ const gen = useRef(0);
94
+ const { settingsOp: op } = useStore(appStore);
95
+ const started = useRef(false);
96
+ const nameRef = useRef(name);
97
+ nameRef.current = name;
98
+ const submitted = useRef(new Map()); // the changes as they were when a Save began (what comes back after a failure keeps its confirms)
99
+
100
+ const reload = async () => {
101
+ const m = await loadSettingsModule();
102
+ const mine = ++gen.current;
103
+ const next = await m.loadAll(lease);
104
+ if (!next || mine !== gen.current || !lease.current()) return;
105
+ setMod(m);
106
+ // A read that fails after a failed Save keeps what was read before: the forms (and the draft in them) stay.
107
+ setData((prev) => (next.error && prev && !prev.error ? prev : next));
108
+ };
109
+ useEffect(() => { if (enabled && !started.current) { started.current = true; reload(); } }, [enabled]);
110
+
111
+ const stage = (key, change, quiet = true) => {
112
+ setStaged((s) => { const m = new Map(s); m.set(key, { ...change, stageKey: key }); return m; });
113
+ if (!quiet) toast(tn("queued", change.label));
114
+ return true;
115
+ };
116
+ const unstage = (key) => setStaged((s) => { if (!s.has(key)) return s; const m = new Map(s); m.delete(key); return m; });
117
+ const discard = () => { setStaged(new Map()); setEpoch((n) => n + 1); reload(); };
118
+
119
+ // Leaving the page with staged changes asks first (the Settings page's question); the same agent's other categories are not leaving.
120
+ useEffect(() => {
121
+ let asking = false;
122
+ lease.hold(setLeaveGuard((to, path) => {
123
+ const n = stagedRef.current.size;
124
+ if (!n || (to && to.panel === "details" && to.instance === nameRef.current)) return true;
125
+ if (!asking) {
126
+ asking = true;
127
+ ask(tn("discardOnLeave", n), { confirmLabel: tn("discard"), danger: true }).then((yes) => {
128
+ asking = false;
129
+ if (!yes || !lease.current()) return;
130
+ stagedRef.current = new Map();
131
+ navigate(path, { force: true });
132
+ });
133
+ }
134
+ return false;
135
+ }));
136
+ lease.on(window, "beforeunload", (e) => { if (stagedRef.current.size) { e.preventDefault(); e.returnValue = ""; } });
137
+ }, [lease]);
138
+
139
+ // Changes a failed Apply did not land come back to be staged again.
140
+ useEffect(() => {
141
+ if (!op || !op.leftover || !op.leftover.length) return;
142
+ const back = takeLeftover();
143
+ if (!back.length) return;
144
+ setStaged((s) => { const m = new Map(s); for (const c of back) { const k = c.stageKey || c.key; if (k && !m.has(k)) m.set(k, { ...(submitted.current.get(k) || {}), ...c, stageKey: k }); } return m; });
145
+ }, [op && op.leftover]);
146
+
147
+ // An Apply that finished changed the configuration: read it again, and draw the forms from it.
148
+ const lastPhase = useRef(op ? op.phase : null);
149
+ useEffect(() => {
150
+ const phase = op ? op.phase : null;
151
+ if (lastPhase.current !== phase && (phase === "done" || phase === "failed") && started.current) {
152
+ reload().finally(() => { if (phase === "done") setEpoch((n) => n + 1); });
153
+ }
154
+ lastPhase.current = phase;
155
+ }, [op && op.phase]);
156
+
157
+ const applying = useRef(false);
158
+ const apply = async () => {
159
+ if (applying.current || operationActive() || !stagedRef.current.size) return;
160
+ if ([...stagedRef.current.values()].some((c) => c.invalid)) return;
161
+ applying.current = true;
162
+ try {
163
+ for (const c of [...stagedRef.current.values()]) {
164
+ for (const k of c.confirms || []) {
165
+ const yes = await ask(k.includes(".") ? t(k) : tn(k));
166
+ if (!lease.current()) return;
167
+ if (!yes) { toast(tn("accessChangeCancelled"), false); return; }
168
+ }
169
+ }
170
+ } finally { applying.current = false; }
171
+ if (!lease.current() || operationActive()) return;
172
+ const list = [...stagedRef.current.values()].map(({ label, impact, request, stageKey, key }) => ({ label, impact, request, stageKey, key }));
173
+ if (startOperation(list)) { submitted.current = new Map(stagedRef.current); setStaged(new Map()); }
174
+ };
175
+
176
+ const ctx = mod && data && !data.error
177
+ ? mod.makeCtx(data, setData, stage, unstage, reload, reload, () => lease.current(), { drafts: new Map(), draftEpoch: epoch, staged, savingDrafts: () => null, savingStaged: () => null })
178
+ : null;
179
+ return { mod, data, ctx, staged, stage, unstage, discard, apply, op, epoch, reload };
180
+ }
181
+
182
+ // ── The nav ──
183
+
184
+ /** The categories in the shared Settings `.s-nav`: "Status" (Overview) and "Settings" (the rest), an icon in front of every item. */
185
+ export function AgentCategoryNav({ name, kind, cat, dirty }) {
186
+ const cats = categoriesOf(kind);
187
+ const item = (id) => html`<a key=${id} href=${categoryPath(name, id)} class=${`seg-item${cat === id ? " active" : ""}`} aria-current=${cat === id ? "page" : undefined} title=${categoryLabel(kind, id)}>
188
+ <${Icon} name=${CATEGORY_ICONS[id]} size=${16} /><span>${categoryLabel(kind, id)}</span>${dirty && dirty.has(id) ? html`<span class="count" role="img" aria-label=${pt("unsavedDot")} title=${pt("unsavedDot")}>●</span>` : null}</a>`;
189
+ return html`<nav data-trust="panel-navigation" class="seg s-nav" aria-label=${pt("title")}><div class="s-nav-groups">
190
+ <div class="s-nav-group" role="group" aria-labelledby="ap-grp-status"><span class="s-nav-head" id="ap-grp-status">${pt("groupStatus")}</span>${item("overview")}</div>
191
+ <div class="s-nav-group" role="group" aria-labelledby="ap-grp-settings"><span class="s-nav-head" id="ap-grp-settings">${pt("groupSettings")}</span>${cats.slice(1).map(item)}</div></div></nav>`;
192
+ }
193
+
194
+ /** The page's heading: the category's name, who it affects, and a line on what it is. */
195
+ export function AgentPageHead({ name, kind, cat, inst }) {
196
+ return html`<${PageHead} title=${categoryLabel(kind, cat)} scope=${pt("onlyThis", inst ? shortName(name, inst) : name)} lead=${cat === "overview" ? pt("leadOverview") : pt("leadSection")} />`;
197
+ }
198
+
199
+ // ── The forms ──
200
+
201
+ /**
202
+ * Every category's fields, drawn once the configuration is in and kept mounted (hidden when not current), so moving between
203
+ * categories never drops a draft. Each edit is staged as it is made; an edit put back leaves nothing staged.
204
+ */
205
+ function AgentForms({ name, kind, cat, sess, inst, room, onDirty, onDelete, deleting }) {
206
+ const { ctx } = sess;
207
+ const key = kind === "classic" ? `classic:${room.key}` : `agent:${name}`;
208
+ const form = kind === "classic" ? useClassicForm({ room, ctx }) : kind === "native" ? useNativeForm({ name, inst, ctx }) : useAgentForm({ name, inst, ctx });
209
+ const patch = form.pending();
210
+ const patchJson = JSON.stringify(patch);
211
+ const ready = form.ready;
212
+ useEffect(() => {
213
+ onDirty(dirtyCategories(kind, patch));
214
+ if (deleting) return;
215
+ if (!Object.keys(patch).length) { sess.unstage(key); return; }
216
+ const change = changeFor(ctx, kind, name, inst, room, patch);
217
+ // Turning the MCP proxy reply on is asked about first (it can post raw screen text to a channel): the Save asks.
218
+ const confirms = patch.mcp_proxy_reply === true ? ["agentPage.confirmMcpProxy"] : undefined;
219
+ sess.stage(key, { ...change, ...(confirms ? { confirms } : {}), ...(ready ? {} : { invalid: true }) });
220
+ }, [patchJson, ready, deleting]);
221
+ const cats = categoriesOf(kind).slice(1);
222
+ const Fields = kind === "classic" ? ClassicFields : kind === "native" ? NativeFields : AgentFields;
223
+ return cats.map((c) => html`<div key=${c} class="ap-panel" id=${`ap-panel-${c}`} hidden=${c !== cat}>
224
+ <${Fields} m=${form} cat=${c} onDelete=${kind === "fleet" && c === "adv" ? onDelete : undefined} /></div>`);
225
+ }
226
+
227
+ /** The settings categories' bodies: a read of the configuration first, then the forms. */
228
+ export function AgentSettingsPanels({ name, kind, cat, sess, onDirty }) {
229
+ const { data, ctx, staged, stage } = sess;
230
+ const del = staged.get(kind === "classic" ? "" : `agent:${name}`);
231
+ const deleting = !!del && del.request && del.request.method === "DELETE";
232
+ if (!data) return html`<${Skeleton} lines=${6} label=${pt("loading")} />`;
233
+ if (data.error || !ctx) return html`<${ErrorState} message=${pt("loadFailed")} onRetry=${sess.reload} />`;
234
+ const insts = (ctx.fleet && ctx.fleet.instances) || {};
235
+ const own = (o, k) => !!o && Object.prototype.hasOwnProperty.call(o, k);
236
+ let inst = null, room = null;
237
+ if (kind === "classic") {
238
+ const rooms = (ctx.classic && ctx.classic.channels) || {};
239
+ const k = Object.keys(rooms).find((x) => own(rooms, x) && rooms[x] && rooms[x].instanceName === name);
240
+ if (k) room = { key: k, ...rooms[k] };
241
+ } else if (own(insts, name)) inst = insts[name];
242
+ if (!inst && !room) return html`<p class="note">${pt("notConfigured")}</p>`;
243
+ // A deletion is staged on the same key as this agent's edits: say so, and stop staging edits over it.
244
+ const onDelete = async () => {
245
+ if (!(await ask(tn("deleteAgent", name), { confirmLabel: tn("deleteAgentMenu"), danger: true }))) return;
246
+ const native = inst.runtime === "windows";
247
+ stage(`agent:${name}`, { label: tn("deleteAgentLabel", name), impact: native ? "now" : impactOf(ctx.schema, "instance.delete"),
248
+ request: { method: "DELETE", url: native ? `/ui/instances/${encodeURIComponent(name)}` : `/api/settings/fleet/instances/${encodeURIComponent(name)}` } }, false);
249
+ };
250
+ return html`${kind === "classic" ? html`<p class="s-info"><span aria-hidden="true">ⓘ</span><span>${pt("classicNote")}</span></p>` : null}
251
+ ${deleting ? html`<p class="feedback warning" role="status">${tn("deleteAgentLabel", name)}</p>` : null}
252
+ <${AgentForms} key=${sess.epoch} name=${name} kind=${kind} cat=${cat} sess=${sess} inst=${inst} room=${room} onDirty=${onDirty} onDelete=${onDelete} deleting=${deleting} />`;
253
+ }
@@ -0,0 +1,69 @@
1
+ // The "Agent instructions" field of an agent's Basic info — the agent's `systemPrompt` (what Settings used to call "System
2
+ // prompt"; same key, same place in what the AI is told), edited as Markdown with an Edit / Preview switch. The preview is
3
+ // the chat's own Markdown renderer (chat-thread.js drawMarkdown → chat-render.js: it escapes the text first, so nothing
4
+ // typed here becomes markup); nothing is rendered by this file. A `file:` reference stays one: the preview lists the
5
+ // file instead of reading it (the daemon reads it when the agent starts).
6
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
7
+ import "/assets/chat-render.js";
8
+ import { drawMarkdown } from "/assets/chat-thread.js";
9
+ import { pt } from "./agent-page-strings.js";
10
+
11
+ /** The most the editor lets Save write, in characters. */
12
+ export const INSTRUCTIONS_MAX_CHARS = 24000;
13
+ /**
14
+ * Codex reads at most 32 KiB of AGENTS.md in total (backend/codex.ts) and AgEnD's own guidance already takes about 12 KiB
15
+ * of it, so past this many bytes of instructions the end — they come last — may be cut.
16
+ */
17
+ export const CODEX_AGENTS_MD_BYTES = 32 * 1024;
18
+ export const CODEX_NOTE_BYTES = 16 * 1024;
19
+
20
+ const utf8Bytes = (text) => (typeof TextEncoder === "function" ? new TextEncoder().encode(text).length : text.length);
21
+ /** What the counter shows: characters (what the limit counts) and bytes (what Codex counts). */
22
+ export const instructionsSize = (text) => ({ chars: text.length, bytes: utf8Bytes(text) });
23
+ const fmt = (n) => Number(n).toLocaleString("en-US");
24
+
25
+ /**
26
+ * The parts of a systemPrompt, as prompt-file-ref.ts systemPromptParts reads them: comma-separated only when at least one
27
+ * part is a `file:` reference ("file:role.md, file:rules.md", inline text allowed between them); otherwise the whole value
28
+ * is one inline text, commas and all. (tests/agent-instructions-ui.test.ts keeps the two equal.)
29
+ */
30
+ export function promptParts(value) {
31
+ const parts = value.split(",").map((part) => part.trim());
32
+ return parts.some((part) => part.startsWith("file:")) ? parts : [value];
33
+ }
34
+ const hasFileRef = (value) => promptParts(value).some((part) => part.startsWith("file:"));
35
+
36
+ function Markdown({ text }) {
37
+ const ref = useRef(null);
38
+ useEffect(() => { if (ref.current) drawMarkdown(ref.current, text); }, [text]);
39
+ return html`<div ref=${ref} class="pv-code pv-md" data-instructions-preview />`;
40
+ }
41
+
42
+ /** The preview: inline text through the chat's Markdown renderer; a `file:` part as the file it names. */
43
+ function InstructionsPreview({ text }) {
44
+ if (!text.trim()) return html`<p class="note">${pt("instrPreviewEmpty")}</p>`;
45
+ if (!hasFileRef(text)) return html`<${Markdown} text=${text} />`;
46
+ return html`<div class="instructions-parts">${promptParts(text).filter(Boolean).map((part, i) => part.startsWith("file:")
47
+ ? html`<p key=${i} class="note" data-instructions-file><code>${part.slice(5).trim()}</code> — ${pt("instrFileRead")}</p>`
48
+ : html`<${Markdown} key=${i} text=${part} />`)}</div>`;
49
+ }
50
+
51
+ /** `id`: the textarea's id (the field's label points at it). `value`/`onChange`: the draft. `saved`: the value on disk (an over-long one already there is not an error until it is edited). */
52
+ export function InstructionsField({ id, value, onChange, saved }) {
53
+ const [mode, setMode] = useState("edit");
54
+ const { chars, bytes } = instructionsSize(value);
55
+ const over = chars > INSTRUCTIONS_MAX_CHARS && value !== saved;
56
+ const files = hasFileRef(value);
57
+ const codexNear = !files && bytes > CODEX_NOTE_BYTES;
58
+ const modeBtn = (m, label) => html`<button type="button" class=${`btn btn-sm${mode === m ? " btn-primary" : ""}`} aria-pressed=${mode === m ? "true" : "false"} data-instructions-mode=${m}
59
+ onClick=${() => setMode(m)}>${label}</button>`;
60
+ return html`<div class="instructions-field">
61
+ <div class="seg-inline" role="group" aria-label=${pt("lbl_instructions")}>${modeBtn("edit", pt("instrEdit"))}${modeBtn("preview", pt("instrPreview"))}</div>
62
+ ${mode === "edit"
63
+ ? html`<textarea id=${id} rows="12" spellcheck=${false} aria-describedby=${`${id}-size`} class=${over ? "invalid" : ""} placeholder=${pt("instrPlaceholder")} value=${value}
64
+ onInput=${(e) => onChange(e.target.value)} />`
65
+ : html`<${InstructionsPreview} text=${value} />`}
66
+ <p class=${`note${over ? " feedback error" : ""}`} id=${`${id}-size`} role=${over ? "alert" : undefined} data-instructions-size>${over ? pt("instrTooLong", fmt(chars), fmt(INSTRUCTIONS_MAX_CHARS)) : pt("instrSize", fmt(chars), fmt(INSTRUCTIONS_MAX_CHARS), fmt(bytes))}</p>
67
+ <p class=${`note${codexNear ? " feedback warning" : ""}`} data-instructions-codex>${pt(files ? "instrCodexFiles" : codexNear ? "instrCodexNear" : "instrCodex")}</p>
68
+ </div>`;
69
+ }
@@ -0,0 +1,148 @@
1
+ // the words of the agent's "Details & settings" page (agent-details-settings.js) and the ⓘ beside each setting the
2
+ // agent dialogs show. A file of its own, with its own namespace, so no tab holding an older settings-strings.js can be
3
+ // missing them (see settings-shared-strings.js for why): every module that reads `agentPage.*` imports this file.
4
+ import { register, t } from "/assets/app-i18n.js";
5
+
6
+ register("agentPage", {
7
+ en: {
8
+ // The page
9
+ title: "Settings", groupStatus: "Status", groupSettings: "Settings", onlyThis: "Only affects {0}",
10
+ leadOverview: "This agent's status, usage and recent activity. To change a setting, pick a category.",
11
+ leadSection: "Changes are staged first and written when you press Save. Each setting says when it takes effect.",
12
+ loading: "Reading this agent's settings…", loadFailed: "Could not read this agent's settings.", notConfigured: "This agent is not in fleet.yaml, so it has no settings to edit here.",
13
+ checkEnable: "Enable", unsavedDot: "Has unapplied changes", nativeLimits: "Windows native agents have no auto-pause, hang detection, tool sets or channel binding (they never did); this page shows only what the agent supports.",
14
+ classicNote: "A ClassicBot room: its settings live in classicBot.yaml, not fleet.yaml.",
15
+ actions: "Actions", actionsNote: "The same actions as the ⋯ menu in the header (which also has the identity colour and the web theme lock).",
16
+ // Categories
17
+ cat_overview: "Overview", cat_basic: "Basic info", cat_runtime: "Runtime & model", cat_work: "Workspace", cat_channel: "Channels", cat_adv: "Advanced",
18
+ cat_classicChannel: "Channels & replies", openSettings: "Settings",
19
+ // Cards
20
+ cardName: "Name & description", cardRuntime: "Runtime & CLI", cardModel: "Model", cardWorkdir: "Working directory", cardIdle: "Idle & protection", cardTools: "Tools & modes",
21
+ cardChannel: "Channel & visibility", cardEmojis: "Status emojis", cardSystemPrompt: "System prompt — existing field", cardLogging: "Logging & recovery", cardBoard: "Task board",
22
+ cardDashboard: "Dashboard access", cardElsewhere: "Other settings live elsewhere", cardDanger: "Danger zone", cardWorkspace: "Workspace & permissions",
23
+ cardReplies: "Reply behaviour", cardCollab: "Collaboration & web",
24
+ // Labels of the three settings the page never showed
25
+ lbl_resumeWork: "Resume interrupted work", lbl_mcpProxy: "MCP proxy reply", lbl_boardCards: "Board cards at once",
26
+ mustBePositiveInteger: "Enter a whole number of at least 1.",
27
+ // Field help (the ⓘ)
28
+ tip_displayName: "The name this agent goes by in chat, the agent list and other agents' eyes.",
29
+ tip_tags: "Used to group and search agents in the list. The AI does not read them.",
30
+ tip_description: "One sentence on what this agent is for. It shows in the agent list, and the next time the agent starts it is put at the top of the AI's instructions as its \"Role\".",
31
+ note_description: "The AI reads it when the agent next starts; a session already running does not re-read it.",
32
+ tip_account: "Which of the CLI's named sign-ins this agent uses. Empty follows the fleet default. Changing it starts a new conversation.",
33
+ tip_model: "The model this agent runs. The list is the models AgEnD has cached for this CLI and account.",
34
+ tip_codexSpeed: "Standard or Fast (Fast costs more). Codex only.",
35
+ tip_failover: "Used automatically when the main model's quota runs out or it is unavailable. None means no fallback.",
36
+ note_effort: "Reasoning effort is not set here: switch it live in the model menu above the chat box (no restart).",
37
+ tip_workingDir: "The folder the agent's CLI runs in; it only reads and writes files there. AgEnD also puts the AI's instruction files here (such as AGENTS.md).",
38
+ note_workdir: "A new agent can only be created where Shared agent settings → Project folders allows.",
39
+ tip_autoPause: "Pause the agent after it has been idle this long, to save resources; the next message wakes it. 0 means never pause.",
40
+ tip_hang: "If there is no progress for this long, the agent is judged stuck and you are told.",
41
+ tip_toolSet: "Which AgEnD tools this agent may use (worker the fewest, coordinator can hand out work, full everything).",
42
+ tip_agentMode: "mcp: the AI calls AgEnD through MCP tools. cli: it uses the agend-agent command instead.",
43
+ tip_replyGuard: "On: when the AI ends a turn without having answered with reply, AgEnD reminds it to.",
44
+ tip_lightweight: "Loads fewer tools and less guidance to save tokens; fits an agent that only does simple work.",
45
+ tip_channel: "Which Discord or Telegram connection's channel this agent receives and sends messages in. Unbound means web chat only.",
46
+ tip_general: "Make this agent the General: it receives the bound connection's general messages and hands work to other agents.",
47
+ tip_toolProgress: "Whether progress messages appear in the channel while the AI uses tools: off none, standard a summary, verbose in full.",
48
+ tip_visibility: "How much of this agent's messages with other agents shows in the channel: full all of it, summary one line, hidden nothing. They are always delivered.",
49
+ tip_emojis: "Only affects Discord and Telegram channels; the web chat never posts emoji.",
50
+ emojisWhat: "What this is: after this agent receives a message you sent in Discord or Telegram, AgEnD puts an emoji on that message to report progress (👀 received, ⏳ queued, ✅ delivered, ❌ failed, plus a prefix on progress messages and badges for photos and files). The web chat does not do this. The AI is also told to avoid these symbols, so changing them restarts the agent. Empty uses the platform's default.",
51
+ tip_systemPrompt: "The existing field, unchanged: text, or file:path to a file under the working directory (commas join several). It is appended to the AI's instructions.",
52
+ note_systemPrompt: "This is the existing field; its behaviour and how it reaches the AI are unchanged.",
53
+ // Agent instructions: the editor of systemPrompt (formerly "System prompt"), in Basic info
54
+ cardInstructions: "Agent instructions", lbl_instructions: "Instructions",
55
+ tip_instructions: "Markdown you write for this agent: who it is, how it should work, the rules it follows. This is the field Settings used to call \"System prompt\" (`systemPrompt` in fleet.yaml) — the same field, so nothing was moved or changed for an agent that already has one. Write the text, or `file:path` for a file under the working directory (commas join several). It goes into the AI's instructions the next time the agent starts.",
56
+ note_instructions: "Plain Markdown. The AI reads it when the agent next starts — a session already running keeps what it has. Formerly \"System prompt\".",
57
+ instrEdit: "Edit", instrPreview: "Preview", instrPlaceholder: "# Role\n\nWhat this agent is for, how it should work, rules it must follow…\n\n(or file:prompts/dev.md)",
58
+ instrPreviewEmpty: "Nothing to preview yet.", instrFileRead: "a file, read when the agent starts",
59
+ instrSize: "{0} / {1} characters · {2} bytes", instrTooLong: "{0} characters — {1} is the most. Shorten it to save.",
60
+ instrCodex: "Codex reads at most 32 KiB of AGENTS.md in total, and AgEnD's own guidance already takes about 12 KiB of it.",
61
+ instrCodexNear: "Over about 16 KiB, Codex (32 KiB of AGENTS.md in total, about 12 KiB of it AgEnD's own guidance) may cut off the end of these instructions.",
62
+ instrCodexFiles: "A file's text is added when the agent starts and counts too: Codex reads at most 32 KiB of AGENTS.md in total, and AgEnD's own guidance already takes about 12 KiB of it.",
63
+ tip_logLevel: "How much detail this agent's daemon writes to its log. Raise it only to debug.",
64
+ tip_resumeWork: "After a restart or an interruption, the agent picks its unfinished work up by itself. On by default.",
65
+ tip_mcpProxy: "When the MCP server is down and the agent answered through no channel tool, the daemon posts the last text on the agent's screen to the channel (marked as a proxy reply). Off by default, and turning it on asks you to confirm: the screen text can contain secrets that AgEnD's redaction does not recognise, so only turn it on for an agent whose screen is safe to show in the channel.",
66
+ confirmMcpProxy: "Turn on the MCP proxy reply? When the MCP server is down, AgEnD will post the last text on this agent's screen to the channel. That text can contain secrets that AgEnD's redaction does not recognise. Continue?",
67
+ tip_boardCards: "How many task-board cards this agent may have in progress at once (at least 1).",
68
+ elsewhere: "Usage reminders (each agent's rule) → Settings › Notifications; fleet-wide defaults and workspace rules → Settings › Shared agent settings; fields only fleet.yaml has (restart policy, cost guard…) → Settings › Advanced › Configuration editor.",
69
+ deleteAgent: "Delete agent…", deleteNote: "You are asked to confirm first (the same flow as the agent list's More menu), and the deletion is staged until you press Save.",
70
+ tip_workdirNative: "A Windows native agent's workspace is managed by AgEnD, so it is read-only here.",
71
+ tip_sandbox: "read-only: the agent can only read. workspace-write: it may write in the workspace. Some CLIs do not support read-only.",
72
+ tip_systemPromptNative: "The existing field, unchanged: the system prompt of a Windows native agent, up to 8,000 characters.",
73
+ // ClassicBot
74
+ tip_classicBackend: "Which CLI this room uses.", tip_classicModel: "The model this room runs.", tip_classicAutoPause: "Pause the room's agent after it has been idle this long; 0 never pauses.",
75
+ tip_classicToolProgress: "Whether progress messages show in the room while the AI uses tools.", tip_classicReplyGuard: "On: when the AI ends a turn without answering with reply, AgEnD reminds it to.",
76
+ tip_classicReplyTriggers: "Off: only @bot triggers the room; on: a single-level reply to the bot counts too.", tip_classicCollab: "Let the bots in this room work with each other.",
77
+ tip_classicWebEcho: "Also post messages sent from the web chat into this room.", tip_classicContext: "How many recent chat lines are sent along with each message.",
78
+ },
79
+ "zh-TW": {
80
+ title: "設定", groupStatus: "狀態", groupSettings: "設定", onlyThis: "只影響 {0}",
81
+ leadOverview: "這個 Agent 目前的狀態、用量與最近活動。要改設定請從分類選擇。",
82
+ leadSection: "改動會先暫存,按「儲存」才寫入;每個欄位旁標明生效時機。",
83
+ loading: "正在讀取這個 Agent 的設定…", loadFailed: "讀不到這個 Agent 的設定。", notConfigured: "這個 Agent 不在 fleet.yaml 裡,沒有可在這裡編輯的設定。",
84
+ checkEnable: "啟用", unsavedDot: "有尚未套用的變更", nativeLimits: "Windows 原生 Agent 沒有自動暫停、卡住偵測、工具組與頻道綁定(原本就沒有);這一頁只顯示它支援的設定。",
85
+ classicNote: "ClassicBot 房間:設定存在 classicBot.yaml,不是 fleet.yaml。",
86
+ actions: "動作", actionsNote: "與標題列「⋯」選單同一組動作(那裡另有識別顏色、鎖定/重設網頁主題)。",
87
+ cat_overview: "概覽", cat_basic: "基本資料", cat_runtime: "Runtime 與模型", cat_work: "工作目錄", cat_channel: "頻道", cat_adv: "進階",
88
+ cat_classicChannel: "頻道與回覆", openSettings: "設定",
89
+ cardName: "名稱與描述", cardRuntime: "Runtime 與 CLI", cardModel: "模型", cardWorkdir: "工作目錄", cardIdle: "閒置與保護", cardTools: "工具與模式",
90
+ cardChannel: "頻道與可見度", cardEmojis: "Status emojis", cardSystemPrompt: "System prompt(原有欄位)", cardLogging: "記錄與恢復", cardBoard: "任務看板",
91
+ cardDashboard: "儀表板權限", cardElsewhere: "其他設定在別處", cardDanger: "危險操作", cardWorkspace: "工作區與權限",
92
+ cardReplies: "回覆行為", cardCollab: "協作與網頁",
93
+ lbl_resumeWork: "中斷後自動接續工作", lbl_mcpProxy: "MCP 代為回覆", lbl_boardCards: "同時處理的看板卡片數",
94
+ mustBePositiveInteger: "請輸入至少為 1 的整數。",
95
+ tip_displayName: "Agent 在聊天室、Agent 清單與其他 Agent 眼中的名字。",
96
+ tip_tags: "用來在 Agent 清單分類與搜尋;AI 不會讀到。",
97
+ tip_description: "一句話說明這個 Agent 負責什麼。會顯示在 Agent 清單,也會在 Agent 下次啟動時,以「Role」段落放進 AI 看到的指令最前面。",
98
+ note_description: "AI 在下次啟動時讀到;已在跑的 session 不會重讀。",
99
+ tip_account: "這個 Agent 用哪一組 CLI 登入(具名帳號)。留空=跟隨 Fleet 預設。更換帳號會開始新的對話。",
100
+ tip_model: "這個 Agent 使用的模型。清單來自 AgEnD 快取的 CLI/帳號模型清單。",
101
+ tip_codexSpeed: "標準或快速(Fast 較貴);只有 Codex 才有。",
102
+ tip_failover: "主要模型額度用完或不可用時,自動換用這個。留空表示不備援。",
103
+ note_effort: "推理強度不在這裡設定:在對話輸入框上方的模型/強度選單即時切換(不用重啟)。",
104
+ tip_workingDir: "Agent 的 CLI 在這個資料夾裡執行,檔案只讀寫這裡。AgEnD 也會把給 AI 的指令檔放在這裡(如 AGENTS.md)。",
105
+ note_workdir: "新 Agent 只能在「Shared agent settings → 專案資料夾」允許的位置建立。",
106
+ tip_autoPause: "閒置超過這段時間就暫停 Agent 以節省資源,下次有訊息會自動喚醒。0 = 不暫停。",
107
+ tip_hang: "超過這段時間沒有進展,就判定 Agent 卡住並通知你。",
108
+ tip_toolSet: "決定這個 Agent 能用哪些 AgEnD 工具(worker 最少、coordinator 可派工、full 全部)。",
109
+ tip_agentMode: "mcp:AI 用 MCP 工具呼叫 AgEnD;cli:改用 agend-agent 指令。",
110
+ tip_replyGuard: "On:AI 沒有用 reply 回覆就結束一輪時,AgEnD 會提醒它補上。",
111
+ tip_lightweight: "載入較少的工具與說明,省 token,適合只做單純工作的 Agent。",
112
+ tip_channel: "這個 Agent 在哪個 Discord/Telegram 連線的頻道裡收發訊息。「未綁定」表示只能在網頁聊天。",
113
+ tip_general: "讓這個 Agent 當 General——負責接收綁定連線的一般訊息並派工給其他 Agent。",
114
+ tip_toolProgress: "AI 用工具時,是否在頻道裡顯示進度訊息:off 不顯示、standard 摘要、verbose 完整。",
115
+ tip_visibility: "此 Agent 與其他 Agent 往來的訊息,在頻道裡顯示多少:full 全部、summary 摘要、hidden 隱藏。訊息一律會送達。",
116
+ tip_emojis: "只影響 Discord 與 Telegram 頻道;網頁聊天室不會貼 emoji。",
117
+ emojisWhat: "這是什麼:Agent 收到你在 Discord/Telegram 發的訊息後,AgEnD 會在那則訊息上貼 emoji 回報進度(👀 收到、⏳ 排隊、✅ 已送達、❌ 失敗,另有進度訊息的前綴與照片/附件章)。網頁聊天室不會貼。AI 也會被告知避開這些符號,所以改了要重啟 Agent。留空 = 用平台預設。",
118
+ tip_systemPrompt: "原有欄位,讀法與給 AI 的方式完全不變:可填文字,或 file:路徑 引用工作目錄下的檔案(逗號可串多份)。會接在給 AI 的指令裡。",
119
+ note_systemPrompt: "這是原有的欄位,行為與給 AI 的方式都沒有改變。",
120
+ // Agent 指示:systemPrompt(以前叫「System prompt」)的編輯器,放在基本資料
121
+ cardInstructions: "Agent 指示", lbl_instructions: "指示",
122
+ tip_instructions: "寫給這個 Agent 的 Markdown:它是誰、怎麼做事、要遵守的規則。這就是設定裡以前叫「System prompt」的欄位(fleet.yaml 的 `systemPrompt`)——同一個欄位,已經填過的 Agent 沒有任何搬移或改動。可以直接寫文字,或用 `file:路徑` 引用工作目錄下的檔案(逗號可串多份)。Agent 下次啟動時放進給 AI 的指令裡。",
123
+ note_instructions: "純 Markdown。AI 在 Agent 下次啟動時讀到;正在跑的對話不會重讀。以前叫「System prompt」。",
124
+ instrEdit: "編輯", instrPreview: "預覽", instrPlaceholder: "# 角色\n\n這個 Agent 負責什麼、怎麼做事、必須遵守的規則…\n\n(或寫 file:prompts/dev.md)",
125
+ instrPreviewEmpty: "還沒有內容可以預覽。", instrFileRead: "檔案,Agent 啟動時讀取",
126
+ instrSize: "{0} / {1} 字元 · {2} bytes", instrTooLong: "{0} 字元,上限 {1}。請縮短後才能儲存。",
127
+ instrCodex: "Codex 讀 AGENTS.md 一共最多 32 KiB,而 AgEnD 自己的指引已經用掉約 12 KiB。",
128
+ instrCodexNear: "超過約 16 KiB 時,Codex(AGENTS.md 一共 32 KiB,其中約 12 KiB 是 AgEnD 自己的指引)可能會把這份指示的結尾截掉。",
129
+ instrCodexFiles: "檔案的內容會在 Agent 啟動時加進來,也算在內:Codex 讀 AGENTS.md 一共最多 32 KiB,而 AgEnD 自己的指引已經用掉約 12 KiB。",
130
+ tip_logLevel: "這個 Agent 的 daemon 寫進紀錄檔的詳細程度。除錯時才調高。",
131
+ tip_resumeWork: "Agent 重啟或被打斷後,主動繼續未完成的工作。預設開。",
132
+ tip_mcpProxy: "MCP 伺服器掛掉、Agent 又沒用任何頻道工具回覆時,由 daemon 把畫面最後的文字轉貼到頻道(標示為代回覆)。預設關,開啟時會再請你確認:畫面文字可能含 AgEnD 的遮罩認不出的機密,只有畫面內容可以安全顯示在頻道的 Agent 才建議開。",
133
+ confirmMcpProxy: "要開啟 MCP 代為回覆嗎?MCP 伺服器掛掉時,AgEnD 會把這個 Agent 畫面最後的文字貼到頻道;那段文字可能含 AgEnD 的遮罩認不出的機密。要繼續嗎?",
134
+ tip_boardCards: "這個 Agent 同時最多可進行幾張看板卡片(至少 1)。",
135
+ elsewhere: "用量提醒(每個 Agent 的規則)→ 設定 › 通知;全隊預設值與工作區規則 → 設定 › Shared agent settings;只有 fleet.yaml 才有的欄位(重啟策略、成本護欄等)→ 設定 › 進階 › 設定檔編輯器。",
136
+ deleteAgent: "刪除 Agent…", deleteNote: "刪除前會再確認(與 Agent 清單「更多」選單的刪除同一流程),並先暫存,按「儲存」才會刪。",
137
+ tip_workdirNative: "Windows 原生 Agent 的工作區由 AgEnD 管理,這裡只讀。",
138
+ tip_sandbox: "read-only:只能讀;workspace-write:可寫入工作區。部分 CLI 不支援唯讀。",
139
+ tip_systemPromptNative: "原有欄位,行為不變:Windows 原生 Agent 的系統提示,上限 8,000 字。",
140
+ tip_classicBackend: "這個房間用哪一個 CLI。", tip_classicModel: "這個房間使用的模型。", tip_classicAutoPause: "房間的 Agent 閒置超過這段時間就暫停;0 = 不暫停。",
141
+ tip_classicToolProgress: "AI 用工具時,是否在房間裡顯示進度訊息。", tip_classicReplyGuard: "On:AI 沒有用 reply 回覆就結束一輪時,AgEnD 會提醒它補上。",
142
+ tip_classicReplyTriggers: "Off:只有 @bot 才觸發房間;On:也接受對該 bot 的單層回覆。", tip_classicCollab: "讓房間內的多個 bot 互相協作。",
143
+ tip_classicWebEcho: "把網頁聊天室送出的訊息也貼到這個房間。", tip_classicContext: "每次送給 AI 時附上的最近聊天行數。",
144
+ },
145
+ });
146
+
147
+ /** A word of this page (agentPage.*). */
148
+ export const pt = (key, ...values) => t(`agentPage.${key}`, ...values);
@@ -2,9 +2,9 @@
2
2
  // → a small 「引用」 pill → the passage goes into the composer as a Markdown quote ("> …") at the caret, on its own lines,
3
3
  // the caret left on the next line for the answer. Repeatable: quote, answer, quote the next passage, answer…
4
4
  //
5
- // - Desktop: the pill is anchored to where the selection ends (a pointer at the exact spot), above that line — or below
6
- // it when that covers less of the neighbouring lines' text (the passage itself never counts). After a quote the
7
- // composer takes the focus.
5
+ // - Desktop: the pill is anchored to where the selection ends (a pointer at the exact spot), below that line — clear of
6
+ // the browser's own menu above a selection (Edge's mini menu sits there, and a page can't turn it off; M-2872) — and
7
+ // above it only when there is no room below in the thread's visible box. After a quote the composer takes the focus.
8
8
  // - Phone (a coarse pointer): the pill 「引用選取的文字」 docks above the composer's whole box inside the 16-px gutter — clear
9
9
  // of the system's own copy toolbar (above a selection) and of the finger — or at the top of the thread when the
10
10
  // passage sits there. The keyboard does NOT open after a quote (the user's choice): more passages can be selected;
@@ -177,21 +177,16 @@ export function installQuoteSelection(list, deps) {
177
177
  const last = rects[rects.length - 1];
178
178
  let left, top, tip = null;
179
179
  if (!phone) {
180
- // The other lines of the message (the passage's own never count as covered).
181
- const lines = [];
182
- if (typeof doc.createTreeWalker === "function" && typeof doc.createRange === "function") {
183
- const w = doc.createTreeWalker(passage.el, 4 /* text */);
184
- while (w.nextNode()) {
185
- const rg = doc.createRange(); rg.selectNodeContents(w.currentNode);
186
- for (const z of rg.getClientRects()) if (z.width > 0 && !rects.some((q) => overlap(q, z) > 0)) lines.push(z);
187
- }
188
- }
180
+ // Room is the thread's visible box (the chat scroller, above the composer), within the window.
181
+ const th = deps.threadBox?.()?.getBoundingClientRect?.();
182
+ const vh = win?.innerHeight ?? 800;
183
+ const box = th && th.bottom > th.top ? th : { top: 0, bottom: vh };
184
+ const floor = Math.min(vh, box.bottom) - 4, ceil = Math.max(0, box.top) + 4;
189
185
  left = Math.max(8, Math.min(last.right - pr.width / 2, vw - pr.width - 8));
190
- const above = { left, right: left + pr.width, top: last.top - pr.height - 10, bottom: last.top - 10 };
191
- const below = { left, right: left + pr.width, top: last.bottom + 10, bottom: last.bottom + 10 + pr.height };
192
- const cover = (a) => lines.reduce((n, z) => n + overlap(a, z), 0);
193
- const under = cover(below) < cover(above) || above.top < 4;
194
- top = under ? below.top : above.top;
186
+ const aboveTop = last.top - pr.height - 10, belowTop = last.bottom + 10;
187
+ // Below unless it would run out of the box and above fits (with no room either side, below).
188
+ const under = belowTop + pr.height <= floor || aboveTop < ceil;
189
+ top = under ? belowTop : aboveTop;
195
190
  tip = { side: under ? "up" : "down", x: Math.max(10, Math.min(last.right - left - 5, pr.width - 20)) };
196
191
  } else {
197
192
  const box = deps.composerBox?.()?.getBoundingClientRect?.();
@@ -43,7 +43,7 @@ export function hubName(doc = typeof document !== "undefined" ? document : null)
43
43
  * - { state: "key_changed", hub: {…approved, fingerprint (hub-key)}, offered (hub-key) }
44
44
  * nothing connects; the offered value is never accepted automatically — re-pair or disconnect
45
45
  * - { state: "held", hold, memberOrigin? }
46
- * a safety hold, visible: hold ∈ "unknown_outcome" | "expired" | "unsaved" | "refused" | "revoked" | "disconnected"
46
+ * a safety hold, visible: hold ∈ "unknown_outcome" | "expired" | "unsaved" | "refused" | "revoked" | "rejected" | "disconnected"
47
47
  * — never shown as paired, never as a successful unpair ("unavailable": an older host, shown as one line, not a hold)
48
48
  * @typedef {object} HubPairingView
49
49
  */
@@ -34,7 +34,7 @@ register("companyJoin", {
34
34
  },
35
35
  "zh-TW": {
36
36
  title: "連接 Hub", lead: "使用公司帳號登入,連接成功後會啟用成員功能,不會分享任何 Agent。",
37
- address: "Hub 位址或公司連結", addressHint: "貼上 Hub 管理員提供的公司連結,或輸入 Hub 網頁位址。",
37
+ address: "Hub 位址或公司連結", addressHint: "貼上 Hub 管理員提供的公司連結,或輸入 Hub 網址。",
38
38
  fleetName: "Fleet 名稱", defaultFleet: "我的 Fleet", start: "以公司帳號登入", pending: "等待本機授權確認…", loading: "正在讀取連線狀態…",
39
39
  joining: "正在連接 Fleet…", awaiting: "請在 Hub 頁面完成公司帳號登入。", saved: "Fleet 已連接", offline: "連線資料已儲存,正在等待 Hub 連線…",
40
40
  stop: "取消連接", resume: "恢復這次連接", retry: "再次檢查", held: "連接需要處理", cancelled: "已取消連接",
@@ -1,3 +1,4 @@
1
+ import { register, t } from "/assets/app-i18n.js";
1
2
  /** Hub-only join page and Administration contents; the shell remains panel-hub's. */
2
3
  import { html, useEffect, useRef, useState } from "/assets/app-html.js";
3
4
  import { Skeleton, ErrorState } from "/assets/ui-states.js";
@@ -79,6 +80,11 @@ export function HubCompanyJoinPage({ session }) {
79
80
  ${error ? html`<${ErrorState} message=${error} onRetry=${() => { setError(null); retry(); }} />` : null}
80
81
  </section></div></div>`;
81
82
  }
83
+ register("companyJoin", {
84
+ en: { "guide.title": "How colleagues connect", "guide.one": "Copy the colleague connection link here.", "guide.two": "In their Fleet’s Settings → Hub, paste the link and choose {0}.", "guide.three": "Sign in on the Hub and choose Sign in and connect Fleet. Allowed groups need no further approval." },
85
+ "zh-TW": { "guide.title": "同仁如何連接", "guide.one": "在這裡複製同仁連線連結。", "guide.two": "在自己的 Fleet「設定 → Hub」貼上連結,按「{0}」。", "guide.three": "在 Hub 登入並按「登入並連接 Fleet」。允許的群組不需要另外核准。" },
86
+ });
87
+ const guide = (key, ...args) => t(`companyJoin.guide.${key}`, ...args);
82
88
  export const companyJoinAdminEntryV1 = entryWords.companyAdminStringsV1 === true;
83
89
  export function CompanyJoinAdminCard({ entry = false, groups = false } = {}) {
84
90
  const [view, setView] = useState(null), [error, setError] = useState(null), [busy, setBusy] = useState(false), [copied, setCopied] = useState(false);
@@ -110,6 +116,7 @@ export function CompanyJoinAdminCard({ entry = false, groups = false } = {}) {
110
116
  <p class="note">${hj("accessLead")}</p>
111
117
  <div class="field-row">${groups ? html`<a class="btn btn-primary" href="/ui/hub/admin?view=groups">${hj("groupOpen")}</a>` : null}
112
118
  <button type="button" class="btn" disabled=${!view?.enabled || !view?.companyLink || busy || !!error} aria-describedby="hubColleagueLinkHint" onClick=${async () => { try { await navigator.clipboard.writeText(view.companyLink); if (live.current) setCopied(true); } catch { if (live.current) setError(hj("copyFailed")); } }}>${hj(copied ? "copied" : "colleagueCopy")}</button></div>
119
+ <div class="form hub-company-guide"><h4>${guide("title")}</h4><ol class="note"><li>${guide("one")}</li><li>${guide("two", hj("start"))}</li><li>${guide("three")}</li></ol></div>
113
120
  <p class="note" id="hubColleagueLinkHint">${hj(view ? view.enabled ? "colleagueHint" : "offHint" : "loading")}</p>
114
121
  ${!view && !error ? html`<${Skeleton} variant="form" lines=${3} />` : null}
115
122
  ${error ? html`<${ErrorState} message=${error} onRetry=${read} />` : null}