vanspod 0.4.13 → 0.4.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/page.js CHANGED
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.modelStatus = modelStatus;
4
+ exports.localToolApprovalBodyResponse = localToolApprovalBodyResponse;
5
+ exports.localToolsStateText = localToolsStateText;
6
+ exports.remoteAgentLogEntryResponse = remoteAgentLogEntryResponse;
4
7
  exports.environmentStageText = environmentStageText;
5
8
  exports.environmentStatus = environmentStatus;
6
9
  exports.renderPage = renderPage;
7
10
  exports.renderInspectorPage = renderInspectorPage;
11
+ exports.renderRemoteAgentPage = renderRemoteAgentPage;
8
12
  const version_1 = require("./version");
13
+ const html_1 = require("./html");
9
14
  const appearance_1 = require("./appearance");
10
15
  const installProgress_1 = require("./installProgress");
11
16
  const environmentProgress_1 = require("./environmentProgress");
@@ -17,6 +22,8 @@ const clientIcons_1 = require("./clientIcons");
17
22
  const environmentIcons_1 = require("./environmentIcons");
18
23
  const classroomApp_1 = require("./classroomApp");
19
24
  const promptCapture_1 = require("./promptCapture");
25
+ const localToolApproval_1 = require("./localToolApproval");
26
+ const remoteAgentLogView_1 = require("./remoteAgentLogView");
20
27
  const inspectorView_1 = require("./inspectorView");
21
28
  const versionUpdateView_1 = require("./versionUpdateView");
22
29
  const powerMenuView_1 = require("./powerMenuView");
@@ -26,14 +33,6 @@ const VERSION = `v${version_1.VERSION}`;
26
33
  const COPY_ICON = `<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`;
27
34
  const MOON = `<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z"/></svg>`;
28
35
  const SUN = `<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4" fill="currentColor"/><path stroke="currentColor" stroke-width="2" stroke-linecap="round" d="M12 2.5v2M12 19.5v2M2.5 12h2M19.5 12h2M5 5l1.4 1.4M17.6 17.6 19 19M19 5l-1.4 1.4M6.4 17.6 5 19"/></svg>`;
29
- function escapeHtml(value) {
30
- return value
31
- .replaceAll("&", "&amp;")
32
- .replaceAll("<", "&lt;")
33
- .replaceAll(">", "&gt;")
34
- .replaceAll('"', "&quot;")
35
- .replaceAll("'", "&#39;");
36
- }
37
36
  function locked(view) {
38
37
  return view.commandRunning ? " disabled" : "";
39
38
  }
@@ -53,7 +52,7 @@ function restartHtml(view) {
53
52
  const joined = names.length === 1
54
53
  ? names[0]
55
54
  : `${names.slice(0, -1).join("、")} 與 ${names[names.length - 1]}`;
56
- parts.push(`<p>設定幫你更新好了,${escapeHtml(joined)} 還在裝睡。重新開啟 ${escapeHtml(joined)} 後生效,披風可不包叫醒服務。</p>`);
55
+ parts.push(`<p>設定幫你更新好了,${(0, html_1.escapeHtml)(joined)} 還在裝睡。重新開啟 ${(0, html_1.escapeHtml)(joined)} 後生效,披風可不包叫醒服務。</p>`);
57
56
  }
58
57
  if (clients.includes("vscode")) {
59
58
  parts.push(`<p>設定幫你更新好了,VS Code 還在裝睡。請完全退出 VS Code 再打開,不要只重載視窗。別敷衍牠,牠真的會繼續睡。</p>`);
@@ -66,10 +65,10 @@ function statusWord(view) {
66
65
  return view.mode === "classroom" ? "Classroom" : "Native";
67
66
  }
68
67
  function notices(view) {
69
- const notice = view.notice && view.notice !== view.connectionNotice ? `<p class="notice">${escapeHtml(view.notice)}</p>` : "";
68
+ const notice = view.notice && view.notice !== view.connectionNotice ? `<p class="notice">${(0, html_1.escapeHtml)(view.notice)}</p>` : "";
70
69
  const running = view.commandRunning ? `<p class="running">執行中</p>` : "";
71
70
  const klass = view.classLabel
72
- ? `<p class="class-label">${escapeHtml(view.classLabel)}</p>`
71
+ ? `<p class="class-label">${(0, html_1.escapeHtml)(view.classLabel)}</p>`
73
72
  : "";
74
73
  return `${klass}${notice}${running}`;
75
74
  }
@@ -77,7 +76,7 @@ function connectionFeedback(view) {
77
76
  const original = view.connectionError || view.connectionNotice || (view.detail !== "Classroom API Key 已設定。" ? view.detail : "");
78
77
  const message = original === classroomApp_1.COPIED_KEY_NOTICE
79
78
  ? "複製好了!API Key 不是群組伴手禮,別發給不信任的人喔。" : original;
80
- const feedback = `<div class="connection-feedback">${message ? `<div class="${view.connectionError ? "connection-error" : "connection-message"}" role="${view.connectionError ? "alert" : "status"}"><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8"><circle cx="12" cy="12" r="9"/><path d="M12 7v6M12 15v2"/></svg><p>${escapeHtml(message)}</p></div>` : ""}</div>`;
79
+ const feedback = `<div class="connection-feedback">${message ? `<div class="${view.connectionError ? "connection-error" : "connection-message"}" role="${view.connectionError ? "alert" : "status"}"><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8"><circle cx="12" cy="12" r="9"/><path d="M12 7v6M12 15v2"/></svg><p>${(0, html_1.escapeHtml)(message)}</p></div>` : ""}</div>`;
81
80
  return feedback;
82
81
  }
83
82
  function connectInner(view) {
@@ -92,17 +91,17 @@ function connectInner(view) {
92
91
  </form>${feedback}`;
93
92
  }
94
93
  return `<form class="stack" method="post" action="/redeem">
95
- <label>邀請碼 <input name="invite_code" autocomplete="off" value="${escapeHtml(view.connectionDraft?.inviteCode ?? "")}"${locked(view)}></label>
96
- <label>課堂暱稱 <input name="nickname" autocomplete="off" value="${escapeHtml(view.connectionDraft?.nickname ?? "")}"${locked(view)}></label>
94
+ <label>邀請碼 <input name="invite_code" autocomplete="off" value="${(0, html_1.escapeHtml)(view.connectionDraft?.inviteCode ?? "")}"${locked(view)}></label>
95
+ <label>課堂暱稱 <input name="nickname" autocomplete="off" value="${(0, html_1.escapeHtml)(view.connectionDraft?.nickname ?? "")}"${locked(view)}></label>
97
96
  ${feedback}
98
97
  <button type="submit" class="go"${locked(view)}>連線</button>
99
98
  </form>`;
100
99
  }
101
100
  function folderInner(view) {
102
- const value = view.projectFolder ? ` value="${escapeHtml(view.projectFolder)}"` : "";
101
+ const value = view.projectFolder ? ` value="${(0, html_1.escapeHtml)(view.projectFolder)}"` : "";
103
102
  const off = locked(view);
104
103
  const note = view.installNotice
105
- ? `<p class="hint">${escapeHtml(view.installNotice)}</p>`
104
+ ? `<p class="hint">${(0, html_1.escapeHtml)(view.installNotice)}</p>`
106
105
  : "";
107
106
  return `<form class="stack" method="post" action="/project-folder">
108
107
  <label>專案資料夾 <input name="project_folder" autocomplete="off"${value}${off}></label>
@@ -114,7 +113,7 @@ function modelInner(view) {
114
113
  const off = locked(view);
115
114
  const models = view.allowedModels ?? (view.modelId ? [view.modelId] : []);
116
115
  const list = models.length
117
- ? `<ul class="allowed-model-list">${models.map(id => `<li>${escapeHtml(id)}</li>`).join("")}</ul>`
116
+ ? `<ul class="allowed-model-list">${models.map(id => `<li>${(0, html_1.escapeHtml)(id)}</li>`).join("")}</ul>`
118
117
  : `<p class="hint">${view.connected ? "這堂課尚無可用模型。" : "連線課堂後可查看。"}</p>`;
119
118
  return `
120
119
  ${restartHtml(view)}
@@ -140,8 +139,132 @@ function modelStatus(view) {
140
139
  return {
141
140
  lights: { codex: clientLight(view, "codex"), claude: clientLight(view, "claude"), vscode: clientLight(view, "vscode") },
142
141
  restart: restartHtml(view),
142
+ ...(view.localTools ? { localTools: { on: view.localTools.on, status: remoteStatus(view), approval: approvalStatus(view.localTools.approval, Boolean(view.localTools.autoApproval)), ...(view.localTools.log ? { log: (0, remoteAgentLogView_1.logListStatus)(view.localTools.log) } : {}) } } : {}),
143
+ };
144
+ }
145
+ // The poll redraws the card only when the shown approval, the count or Auto Approval changes; the seconds and the bar change every poll.
146
+ function approvalStatus(approval, auto) {
147
+ return approval ? { key: approvalKey(approval, auto), secondsLeft: approval.secondsLeft, bar: approvalBarWidth(approval), html: approvalBlock(approval, auto) } : null;
148
+ }
149
+ function approvalBarWidth(approval) {
150
+ const total = localToolApproval_1.APPROVAL_TIMEOUT_MS / 1000;
151
+ return `${Math.round(Math.min(1, Math.max(0, approval.secondsLeft / total)) * 1000) / 10}%`;
152
+ }
153
+ function approvalKey(approval, auto) {
154
+ return `${approval.id}:${approval.waiting}${auto ? ":auto" : ""}`;
155
+ }
156
+ const BOLT = `<svg class="auto-bolt" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M13 2 4 14h7l-1 8 9-12h-7z"/></svg>`;
157
+ /** The 自動允許 ▾ menu on the approval card. Each item opens the reminder dialog; only 確定打開 starts Auto Approval. */
158
+ function autoApprovalMenu() {
159
+ const items = Object.entries(classroomApp_1.AUTO_APPROVAL_DURATIONS)
160
+ .map(([duration, { label }]) => `<button type="button" role="menuitem" data-auto-approval="${duration}">${(0, html_1.escapeHtml)(label)}</button>`).join("");
161
+ return `<details class="auto-menu"><summary class="auto-menu-button">自動允許 ▾</summary><div class="auto-menu-list" role="menu">${items}</div></details>`;
162
+ }
163
+ const NO_APPROVAL = `<div data-local-approval hidden></div>`;
164
+ /**
165
+ * The page sends the approval on every status poll, so a long body is cut here.
166
+ * 「顯示全部」 loads the full body from GET /local-tool-approval-body. The Approval Popup has its own view.
167
+ */
168
+ const MAX_SHOWN_BODY = 10_000;
169
+ function shownBody(body) {
170
+ const chars = Array.from(body);
171
+ if (chars.length <= MAX_SHOWN_BODY)
172
+ return { text: body, cut: false };
173
+ return {
174
+ text: `${chars.slice(0, MAX_SHOWN_BODY).join("")}
175
+ …(內容太長,頁面只顯示前 ${MAX_SHOWN_BODY.toLocaleString("en-US")} 個字元,共 ${chars.length.toLocaleString("en-US")} 個字元。)`,
176
+ cut: true,
143
177
  };
144
178
  }
179
+ /** The answer of GET /local-tool-approval-body?id=...: the full body of the shown approval, or 404. */
180
+ function localToolApprovalBodyResponse(app, id) {
181
+ const body = app.localToolApprovalBody(id);
182
+ return body === undefined ? { status: 404, body: { error: "這個確認已經結束。" } } : { status: 200, body: { id, body } };
183
+ }
184
+ // Local Tool Approval on the page (ADR 0013). No text field and no autofocus, so Enter cannot approve.
185
+ function approvalBodyHtml(approval) {
186
+ const { text, cut } = shownBody(approval.body);
187
+ const more = cut ? `<button type="button" class="local-approval-full" data-approval-full="${(0, html_1.escapeHtml)(approval.id)}">顯示全部</button>` : "";
188
+ return `<pre class="local-approval-body">${(0, html_1.escapeHtml)(text)}</pre>${more}`;
189
+ }
190
+ // During Auto Approval only exceptions are shown: the card says why, and has no 自動允許 ▾ (ADR 0014).
191
+ function approvalBlock(approval, auto) {
192
+ if (!approval)
193
+ return NO_APPROVAL;
194
+ const waiting = approval.waiting > 0 ? `<span class="remote-chip local-approval-queue">還有 ${approval.waiting} 個在排隊</span>` : "";
195
+ const exception = auto && approval.exception;
196
+ return `<section class="tile local-approval${exception ? " is-exception" : ""}" role="group" aria-label="Local Tool 確認" data-local-approval data-approval-key="${(0, html_1.escapeHtml)(approvalKey(approval, auto))}">`
197
+ + (exception ? `<p class="local-approval-exception">${BOLT}自動允許期間仍要確認:<b>${(0, html_1.escapeHtml)(exception)}</b></p>` : "")
198
+ + `<div class="local-approval-head"><p class="local-approval-title">Agent 想要:<strong>${(0, html_1.escapeHtml)(approval.title)}</strong></p><code>${(0, html_1.escapeHtml)(approval.tool)}</code>${waiting}</div>`
199
+ + `<p class="hint">電腦:${(0, html_1.escapeHtml)(approval.device)} 資料夾:${(0, html_1.escapeHtml)(approval.folder)}</p>`
200
+ + approvalBodyHtml(approval)
201
+ + `<div class="local-approval-timer"><span data-approval-bar style="width: ${approvalBarWidth(approval)}"></span></div>`
202
+ + `<form class="local-approval-actions" method="post" action="/local-tool-approval"><input type="hidden" name="id" value="${(0, html_1.escapeHtml)(approval.id)}">`
203
+ + `<span class="hint"><span data-approval-seconds>${approval.secondsLeft}</span> 秒後自動拒絕</span>`
204
+ + `<button type="submit" name="decision" value="deny" class="local-approval-deny">拒絕</button><button type="submit" name="decision" value="approve" class="local-approval-approve">允許一次</button>${auto ? "" : autoApprovalMenu()}</form></section>`;
205
+ }
206
+ /** One line about Local Tool Access for the student: the relay's message, or the connection state. */
207
+ function localToolsStateText(local) {
208
+ if (local.message)
209
+ return local.message;
210
+ if (local.state === "connected")
211
+ return "已連上,Agent 可以使用這台電腦。";
212
+ if (local.state === "connecting")
213
+ return "正在連線…";
214
+ if (local.state === "retrying")
215
+ return `連線中斷,${Math.max(1, Math.round((local.retryInMs ?? 1000) / 1000))} 秒後重新連線。`;
216
+ return "已關閉,Agent 不能使用這台電腦。";
217
+ }
218
+ const LOCAL_TOOL_ACCESS = "允許 Agent 使用這台電腦";
219
+ // The status bar of the 遠端 Agent page: the connection, the names to match, and the
220
+ // 允許 Agent 使用這台電腦 switch (Local Tool Access, ADR 0013). `key` changes only when the bar changes.
221
+ function remoteStatus(view) {
222
+ const local = view.localTools;
223
+ if (!local)
224
+ return { key: "", html: `<section class="tile remote-status" data-remote-status data-status-key=""><p class="hint">這個 VansPod 不能讓 Agent 使用這台電腦。</p></section>` };
225
+ const chip = (label, value) => `<span class="remote-chip">${label} <b>${(0, html_1.escapeHtml)(value)}</b></span>`;
226
+ const chips = chip("電腦", local.device) + (local.nickname ? chip("暱稱", local.nickname) : "") + chip("資料夾", view.projectFolder ?? "還沒選");
227
+ const lit = local.on && local.state === "connected";
228
+ const guidance = !view.connected
229
+ ? `<p class="remote-setup">請先到「教室設定」兌換課堂連線,才能讓 Agent 使用這台電腦。</p>`
230
+ : local.on ? ""
231
+ : `<p class="remote-setup">${local.nickname ? `在 Agent 的 MCP 授權頁選「暱稱」,輸入 <b>${(0, html_1.escapeHtml)(local.nickname)}</b>(大小寫要一樣)。` : ""}這台電腦會顯示為 <b>${(0, html_1.escapeHtml)(local.device)}</b>。每次啟動 VansPod,這個開關都會關閉。</p>`;
232
+ const auto = local.autoApproval;
233
+ const main = `<div class="remote-status-main"><span class="remote-dot${lit ? " on" : ""}${auto ? " auto" : ""}"></span><div><strong role="status">${(0, html_1.escapeHtml)(localToolsStateText(local))}</strong><div class="remote-chips">${chips}</div></div></div>`;
234
+ const toggle = `<form class="remote-switch-row" method="post" action="/local-tools"><span>${LOCAL_TOOL_ACCESS}</span><button type="submit" name="on" value="${local.on ? "0" : "1"}" role="switch" aria-checked="${local.on}" aria-label="${LOCAL_TOOL_ACCESS}" class="remote-switch" data-local-tools-switch></button></form>`;
235
+ // The key leaves out the time left, which the page counts down by itself.
236
+ const autoLine = (time) => auto
237
+ ? `<div class="remote-auto-line">${BOLT}<b>自動允許中</b>${time}<span class="hint">Agent 的動作不會再問你。碰到機密檔案,或刪除專案資料夾以外的檔案,仍然會問。</span>`
238
+ + `<form method="post" action="/auto-approval-stop"><button type="submit" class="remote-auto-stop">停止自動允許</button></form></div>`
239
+ : "";
240
+ const time = !auto ? "" : auto.endsAt === undefined
241
+ ? `<span class="remote-auto-time">${(0, html_1.escapeHtml)(auto.label)}</span>`
242
+ : `<span class="remote-auto-time" data-auto-ends-at="${auto.endsAt}">剩 ${timeLeftText(auto.secondsLeft ?? 0)}</span>`;
243
+ const key = statusKey(`${main}${toggle}${autoLine(auto?.endsAt === undefined ? "" : String(auto.endsAt))}${guidance}`);
244
+ const body = `${main}${toggle}${autoLine(time)}${guidance}`;
245
+ return { key, html: `<section class="tile remote-status${auto ? " is-auto" : ""}" data-remote-status data-status-key="${(0, html_1.escapeHtml)(key)}">${body}</section>` };
246
+ }
247
+ /** The time left of Auto Approval, for example "9:41". */
248
+ function timeLeftText(seconds) {
249
+ const whole = Math.max(0, Math.ceil(seconds));
250
+ return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, "0")}`;
251
+ }
252
+ // A short key of the status bar, so that the poll redraws it only when it changes.
253
+ function statusKey(html) {
254
+ let hash = 0;
255
+ for (let i = 0; i < html.length; i++)
256
+ hash = (hash * 31 + html.charCodeAt(i)) | 0;
257
+ return `${html.length}:${(hash >>> 0).toString(36)}`;
258
+ }
259
+ /** The 遠端 Agent page body that the poll and the page actions redraw: status bar, approval card, Remote Agent Log. */
260
+ function remoteAgentBody(view) {
261
+ const log = view.localTools?.log;
262
+ return `${remoteStatus(view).html}${approvalBlock(view.localTools?.approval, Boolean(view.localTools?.autoApproval))}${log ? (0, remoteAgentLogView_1.remoteAgentLogBlock)(log) : ""}`;
263
+ }
264
+ /** The answer of GET /remote-agent-log-entry?id=...: the details of one Remote Agent Log entry, or 404. */
265
+ function remoteAgentLogEntryResponse(view, id) {
266
+ return (0, remoteAgentLogView_1.logEntryResponse)(view.localTools?.log, id);
267
+ }
145
268
  function adapterForms(view) {
146
269
  const selected = view.adapters ?? { codex: "responses", claude: "responses" };
147
270
  const forms = ["codex", "claude", "vscode"].map(client => {
@@ -157,7 +280,7 @@ function adapterForms(view) {
157
280
  return `<div class="model-client"><div class="client-head"><span class="adapter-label"><span class="${className}" tabindex="0" title="${status}" aria-label="${status}" data-client-light="${client}"></span>${clientIcons_1.clientIcons[client]}<span>${clientLabel(client)}</span></span><form class="modes client-modes" method="post" action="/switch"><input type="hidden" name="client" value="${client}"><button type="submit" name="mode" value="native" aria-pressed="${mode === "native"}" class="${mode === "native" ? "on" : ""}"${locked(view)}>個人</button><button type="submit" name="mode" value="classroom" aria-pressed="${mode === "classroom"}" class="${mode === "classroom" ? "on" : ""}"${!available || !routeHealthy || view.commandRunning ? " disabled" : ""}>課堂</button></form></div><form class="adapter-row" method="post" action="/adapter"><input type="hidden" name="client" value="${client}"><span class="adapter-select"><select name="adapter" aria-label="${clientLabel(client)} API 協定"${adapterDisabled ? " disabled" : ""}>${options}</select><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="m7 10 5 5 5-5"/></svg></span></form><span class="client-flow" data-client-flow="${client}" aria-hidden="true"></span></div>`;
158
281
  }).join("");
159
282
  return forms +
160
- (view.adapterNotice ? `<p class="hint">${escapeHtml(view.adapterNotice)}</p>` : "");
283
+ (view.adapterNotice ? `<p class="hint">${(0, html_1.escapeHtml)(view.adapterNotice)}</p>` : "");
161
284
  }
162
285
  /** Environment Tool Readiness 與按下「確認安裝」後對該工具做的事。 */
163
286
  const READINESS_MARK = {
@@ -210,17 +333,17 @@ function environmentInner(view) {
210
333
  const tools = view.tools
211
334
  .map((tool) => {
212
335
  const checked = tool.selected ? " checked" : "";
213
- const title = tool.reason ? ` title="${escapeHtml(tool.reason)}"` : "";
336
+ const title = tool.reason ? ` title="${(0, html_1.escapeHtml)(tool.reason)}"` : "";
214
337
  // 安裝中的工具顯示階段;頁面輪詢 /environment-status 更新這段文字。
215
338
  const mark = view.environmentInstalling && tool.progress
216
- ? `<span class="tool-stage" data-environment-stage="${escapeHtml(tool.id)}">${escapeHtml(environmentStageText(tool.progress))}</span>`
339
+ ? `<span class="tool-stage" data-environment-stage="${(0, html_1.escapeHtml)(tool.id)}">${(0, html_1.escapeHtml)(environmentStageText(tool.progress))}</span>`
217
340
  : READINESS_MARK[tool.readiness];
218
- return `<label class="tool"><input type="checkbox" name="tool" value="${escapeHtml(tool.id)}"${checked}${off}> ${environmentIcons_1.environmentIcons[tool.id]}<span${title}>${escapeHtml(tool.label)}</span> ${mark}</label>`;
341
+ return `<label class="tool"><input type="checkbox" name="tool" value="${(0, html_1.escapeHtml)(tool.id)}"${checked}${off}> ${environmentIcons_1.environmentIcons[tool.id]}<span${title}>${(0, html_1.escapeHtml)(tool.label)}</span> ${mark}</label>`;
219
342
  })
220
343
  .join("");
221
344
  const polling = environmentPolling(view) ? " data-environment-progress" : "";
222
345
  const note = view.environmentNotice
223
- ? `<p class="hint">${escapeHtml(view.environmentNotice)}</p>`
346
+ ? `<p class="hint">${(0, html_1.escapeHtml)(view.environmentNotice)}</p>`
224
347
  : "";
225
348
  // 紀錄資料夾的路徑不放進頁面;伺服器開啟 ClassroomApp 記得的最近一次。
226
349
  const openLog = view.environmentLogFolder && !view.commandRunning
@@ -248,10 +371,10 @@ function catalogInner(view) {
248
371
  return `<p class="empty">這台電腦還沒有課程清單。</p>`;
249
372
  }
250
373
  const error = view.catalogError
251
- ? `<p class="error">${escapeHtml(view.catalogError)}</p>`
374
+ ? `<p class="error">${(0, html_1.escapeHtml)(view.catalogError)}</p>`
252
375
  : "";
253
376
  const note = view.catalog?.localNote
254
- ? `<p class="hint">${escapeHtml(view.catalog.localNote)}</p>`
377
+ ? `<p class="hint">${(0, html_1.escapeHtml)(view.catalog.localNote)}</p>`
255
378
  : "";
256
379
  return `${note}${error}`;
257
380
  }
@@ -261,7 +384,7 @@ function commandInner(view) {
261
384
  return `<p class="empty">沒有待確認的指令。</p>`;
262
385
  }
263
386
  const command = view.pendingCommand
264
- ? `<pre class="pending">${escapeHtml(view.pendingCommand)}</pre>`
387
+ ? `<pre class="pending">${(0, html_1.escapeHtml)(view.pendingCommand)}</pre>`
265
388
  : "";
266
389
  // 執行中保留「確認執行」的空間,讓「停止安裝」落在「取消」的位置,避免連點誤觸。
267
390
  const running = view.commandRunning;
@@ -273,17 +396,17 @@ function commandInner(view) {
273
396
  </div>`
274
397
  : "";
275
398
  const output = hasOutput
276
- ? `<h3>指令輸出</h3><pre>${escapeHtml(view.commandOutput ?? "")}</pre>`
399
+ ? `<h3>指令輸出</h3><pre>${(0, html_1.escapeHtml)(view.commandOutput ?? "")}</pre>`
277
400
  : "";
278
401
  return `${command}${choices}${output}`;
279
402
  }
280
403
  function snippetInner(snippet) {
281
404
  const hint = snippet.pasteHint
282
- ? `<p class="hint">${escapeHtml(snippet.pasteHint)}</p>`
405
+ ? `<p class="hint">${(0, html_1.escapeHtml)(snippet.pasteHint)}</p>`
283
406
  : "";
284
- return `<h3>${escapeHtml(snippet.title)}</h3>
407
+ return `<h3>${(0, html_1.escapeHtml)(snippet.title)}</h3>
285
408
  ${hint}
286
- <pre>${escapeHtml(snippet.body)}</pre>`;
409
+ <pre>${(0, html_1.escapeHtml)(snippet.body)}</pre>`;
287
410
  }
288
411
  function catalogTable(view) {
289
412
  const head = catalogInner(view);
@@ -291,13 +414,13 @@ function catalogTable(view) {
291
414
  .map((action) => {
292
415
  const off = view.commandRunning ? " disabled" : "";
293
416
  const description = action.description
294
- ? `<p class="hint">${escapeHtml(action.description)}</p>`
417
+ ? `<p class="hint">${(0, html_1.escapeHtml)(action.description)}</p>`
295
418
  : "";
296
419
  return `<tr>
297
- <td>${escapeHtml((0, courseCatalog_1.actionKindLabel)(action.kind))}</td>
298
- <td><strong>${escapeHtml(action.title)}</strong>${description}<code>${escapeHtml(action.command)}</code></td>
420
+ <td>${(0, html_1.escapeHtml)((0, courseCatalog_1.actionKindLabel)(action.kind))}</td>
421
+ <td><strong>${(0, html_1.escapeHtml)(action.title)}</strong>${description}<code>${(0, html_1.escapeHtml)(action.command)}</code></td>
299
422
  <td><form method="post" action="/prepare">
300
- <input type="hidden" name="action_id" value="${escapeHtml(action.id)}">
423
+ <input type="hidden" name="action_id" value="${(0, html_1.escapeHtml)(action.id)}">
301
424
  <button type="submit"${off}>查看完整指令</button>
302
425
  </form></td>
303
426
  </tr>`;
@@ -618,6 +741,12 @@ const SIDE_PAGES = [
618
741
  label: "Prompt 觀察室",
619
742
  icon: `<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="6.5"/><path d="m20 20-4.4-4.4M8 9.5h6M8 12.5h4"/></svg>`,
620
743
  },
744
+ {
745
+ id: "remote-agent",
746
+ href: "/remote-agent",
747
+ label: "遠端 Agent",
748
+ icon: `<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="13" rx="2"/><path d="m7 9 2.5 2L7 13M12 13h4M8 21h8M12 17v4"/></svg>`,
749
+ },
621
750
  ];
622
751
  const BRAND = `<div class="brand"><div class="logo-badge"><img src="/brand-logo.png" alt=""></div><h1 class="brand-title">${PRODUCT}</h1><span class="ver">${VERSION}</span></div>`;
623
752
  /** 兩頁共用的側欄:行動版頂列、抽屜遮罩、選單與外觀切換。 */
@@ -694,7 +823,7 @@ function basePage(view) {
694
823
  <button type="button" data-appearance-toggle aria-label="切換外觀"></button>
695
824
  </header>
696
825
  <main>
697
- <p class="display">${escapeHtml(statusWord(view))}</p>
826
+ <p class="display">${(0, html_1.escapeHtml)(statusWord(view))}</p>
698
827
  ${notices(view)}
699
828
  <div class="modules">
700
829
  ${tile("連線", connectInner(view))}
@@ -714,10 +843,10 @@ function installActionCards(view) {
714
843
  .map((action, index) => {
715
844
  const number = index + 1;
716
845
  const description = action.description
717
- ? `<p class="hint">${escapeHtml(action.description)}</p>`
846
+ ? `<p class="hint">${(0, html_1.escapeHtml)(action.description)}</p>`
718
847
  : "";
719
848
  const installed = view.installedActionIds?.includes(action.id) ?? false;
720
- return `<article class="install-card${installed ? " installed" : ""}"><span class="install-number" aria-hidden="true">${number}</span><div class="install-main"><div class="install-line"><strong><span class="visually-hidden">安裝 ${number}:</span>${escapeHtml(action.title)}</strong><span data-kind="${escapeHtml(action.kind)}" class="kind-tag">${escapeHtml((0, courseCatalog_1.actionKindLabel)(action.kind))}</span></div>${description}</div><form method="post" action="/prepare"><input type="hidden" name="action_id" value="${escapeHtml(action.id)}"><button type="submit"${installed ? ' class="quiet"' : ""}${off}>${installed ? "重新安裝" : "安裝"}</button></form></article>`;
849
+ return `<article class="install-card${installed ? " installed" : ""}"><span class="install-number" aria-hidden="true">${number}</span><div class="install-main"><div class="install-line"><strong><span class="visually-hidden">安裝 ${number}:</span>${(0, html_1.escapeHtml)(action.title)}</strong><span data-kind="${(0, html_1.escapeHtml)(action.kind)}" class="kind-tag">${(0, html_1.escapeHtml)((0, courseCatalog_1.actionKindLabel)(action.kind))}</span></div>${description}</div><form method="post" action="/prepare"><input type="hidden" name="action_id" value="${(0, html_1.escapeHtml)(action.id)}"><button type="submit"${installed ? ' class="quiet"' : ""}${off}>${installed ? "重新安裝" : "安裝"}</button></form></article>`;
721
850
  })
722
851
  .join("");
723
852
  }
@@ -736,7 +865,7 @@ function presentCommand(body, view) {
736
865
  return { inline, dialog };
737
866
  }
738
867
  function projectFolderRow(view) {
739
- return `<div class="project-folder-row"><div class="project-folder-info"><span class="hint">專案資料夾</span><p class="folder-path"${view.projectFolder ? ` title="${escapeHtml(view.projectFolder)}"` : ""}>${escapeHtml(view.projectFolder || "尚未選擇安裝位置")}</p></div><form method="post" action="/pick-folder"><button type="submit" class="quiet"${locked(view)}>${view.projectFolder ? "變更" : "選擇專案資料夾"}</button></form>${view.folderError ? `<p class="error" role="alert">${escapeHtml(view.folderError)}</p>` : ""}${view.installNotice ? `<p class="hint" role="status">${escapeHtml(view.installNotice)}</p>` : ""}</div>`;
868
+ return `<div class="project-folder-row"><div class="project-folder-info"><span class="hint">專案資料夾</span><p class="folder-path"${view.projectFolder ? ` title="${(0, html_1.escapeHtml)(view.projectFolder)}"` : ""}>${(0, html_1.escapeHtml)(view.projectFolder || "尚未選擇安裝位置")}</p></div><form method="post" action="/pick-folder"><button type="submit" class="quiet"${locked(view)}>${view.projectFolder ? "變更" : "選擇專案資料夾"}</button></form>${view.folderError ? `<p class="error" role="alert">${(0, html_1.escapeHtml)(view.folderError)}</p>` : ""}${view.installNotice ? `<p class="hint" role="status">${(0, html_1.escapeHtml)(view.installNotice)}</p>` : ""}</div>`;
740
869
  }
741
870
  function splitCourseCards(html, view) {
742
871
  const commandMatch = html.match(/<section class="tile wide"><h2>指令<\/h2>([\s\S]*?)<\/section>/);
@@ -753,12 +882,12 @@ function splitCourseCards(html, view) {
753
882
  const copied = new Set(view.copiedSnippetIds ?? []);
754
883
  const snippetBody = (view.catalog?.snippets ?? []).map((snippet, index) => {
755
884
  const number = index + 1;
756
- const title = escapeHtml(snippet.title);
885
+ const title = (0, html_1.escapeHtml)(snippet.title);
757
886
  const done = copied.has(snippet.id);
758
887
  const hint = snippet.pasteHint
759
- ? `<span class="snippet-hint">${escapeHtml(snippet.pasteHint)}</span>`
888
+ ? `<span class="snippet-hint">${(0, html_1.escapeHtml)(snippet.pasteHint)}</span>`
760
889
  : "";
761
- return `<article class="snippet-card${done ? " copied" : ""}"><span class="snippet-number" aria-hidden="true">${number}</span><div class="snippet-main"><div class="snippet-line"><strong><span class="visually-hidden">片段 ${number}:</span>${title}</strong>${hint}</div><details class="snippet-peek"><summary>查看內容</summary><pre class="snippet-code">${escapeHtml(snippet.body)}</pre></details></div><button type="button"${done ? ' class="quiet"' : ""} data-copy-snippet="${escapeHtml(snippet.id)}" aria-label="${done ? "再複製一次" : "複製"}「${title}」">${COPY_ICON}<span>${done ? "✓ 已複製" : "複製"}</span></button><span class="visually-hidden" data-snippet-copy-status role="status" aria-live="polite"></span></article>`;
890
+ return `<article class="snippet-card${done ? " copied" : ""}"><span class="snippet-number" aria-hidden="true">${number}</span><div class="snippet-main"><div class="snippet-line"><strong><span class="visually-hidden">片段 ${number}:</span>${title}</strong>${hint}</div><details class="snippet-peek"><summary>查看內容</summary><pre class="snippet-code">${(0, html_1.escapeHtml)(snippet.body)}</pre></details></div><button type="button"${done ? ' class="quiet"' : ""} data-copy-snippet="${(0, html_1.escapeHtml)(snippet.id)}" aria-label="${done ? "再複製一次" : "複製"}「${title}」">${COPY_ICON}<span>${done ? "✓ 已複製" : "複製"}</span></button><span class="visually-hidden" data-snippet-copy-status role="status" aria-live="polite"></span></article>`;
762
891
  }).join("") || `<p class="empty">這堂課沒有片段。</p>`;
763
892
  const chevron = `<svg class="course-chevron" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2"><path d="m9 6 6 6-6 6"/></svg>`;
764
893
  const install = `<section class="tile wide"><details class="course-section" data-course-section="install" open><summary class="tile-head"><h2>課程安裝</h2>${chevron}</summary><div class="course-content">${courseBody}${presented.inline}</div></details></section>${presented.dialog}`;
@@ -869,7 +998,7 @@ function organizeSettings(html, view) {
869
998
  const quote = view.connectionError === "請先輸入邀請碼與課堂暱稱,再按「連線」。"
870
999
  ? "我披風都穿好了,你的邀請碼跟暱稱呢?"
871
1000
  : "連線這關還沒過,披風倒是先上班了。照下面的提示再試一次!";
872
- const speech = `<div class="mascot-speech"><p class="mascot-quote">${escapeHtml(quote)}</p>${feedback}</div>`;
1001
+ const speech = `<div class="mascot-speech"><p class="mascot-quote">${(0, html_1.escapeHtml)(quote)}</p>${feedback}</div>`;
873
1002
  body += connectionMascot_1.connectionMascot.replace('class="connection-mascot"', 'class="connection-mascot mascot-waiting"').replace('<div class="mascot-traveler">', `${speech}<div class="mascot-traveler">`);
874
1003
  }
875
1004
  }
@@ -939,11 +1068,11 @@ function renderPage(view) {
939
1068
  if (view.connected && view.canCopyKey) {
940
1069
  const off = view.commandRunning ? " disabled" : "";
941
1070
  const course = view.courseTitle
942
- ? `<p class="course-title">${escapeHtml(view.courseTitle)}</p>`
1071
+ ? `<p class="course-title">${(0, html_1.escapeHtml)(view.courseTitle)}</p>`
943
1072
  : "";
944
1073
  const meta = [view.sessionTitle, view.nickname]
945
1074
  .filter((value) => Boolean(value))
946
- .map((value) => `<span>${escapeHtml(value)}</span>`)
1075
+ .map((value) => `<span>${(0, html_1.escapeHtml)(value)}</span>`)
947
1076
  .join('<span class="connection-separator" aria-hidden="true">·</span>');
948
1077
  const identity = course || meta
949
1078
  ? `<div class="connection-identity">${course}${meta ? `<p class="connection-meta">${meta}</p>` : ""}</div>`
@@ -1174,3 +1303,152 @@ function renderInspectorPage(view) {
1174
1303
  </body>
1175
1304
  </html>`;
1176
1305
  }
1306
+ // The page actions of 遠端 Agent: post without a reload, then redraw the page body from the answer.
1307
+ // settingsBusy is the name that modelStatusScript reads to hold the status poll while an action runs.
1308
+ const remoteAgentActionsScript = `
1309
+ var settingsBusy = false;
1310
+ document.addEventListener("submit", async function (event) {
1311
+ var form = event.target;
1312
+ if (!form?.matches?.('form[action="/local-tools"], form[action="/local-tool-approval"], form[action="/remote-agent-log-stop"], form[action="/auto-approval-start"], form[action="/auto-approval-stop"]')) return;
1313
+ event.preventDefault();
1314
+ if (settingsBusy) return;
1315
+ settingsBusy = true;
1316
+ var app = document.getElementById("remote-app");
1317
+ app.querySelector(".remote-action-error")?.remove();
1318
+ var body = new URLSearchParams(new FormData(form));
1319
+ if (event.submitter?.name) body.set(event.submitter.name, event.submitter.value);
1320
+ var buttons = app.querySelectorAll("button");
1321
+ buttons.forEach(function (button) { button.disabled = true; });
1322
+ try {
1323
+ var response = await fetch(form.action, { method: "POST", headers: { "X-Remote-Agent": "1" }, body: body });
1324
+ if (!response.ok) throw new Error("remote agent action failed");
1325
+ var next = new DOMParser().parseFromString(await response.text(), "text/html").getElementById("remote-app");
1326
+ if (!next) throw new Error("remote agent page unavailable");
1327
+ keepRemoteAgentLogPlace(function () { app.replaceChildren(...next.childNodes); });
1328
+ form.closest("dialog")?.close();
1329
+ } catch (error) {
1330
+ buttons.forEach(function (button) { button.disabled = false; });
1331
+ var message = document.createElement("p");
1332
+ message.className = "error remote-action-error";
1333
+ message.setAttribute("role", "alert");
1334
+ message.textContent = "操作未完成,請再試一次。";
1335
+ app.prepend(message);
1336
+ } finally {
1337
+ settingsBusy = false;
1338
+ }
1339
+ });
1340
+ `;
1341
+ // Auto Approval on the page: 自動允許 ▾ opens the reminder dialog (not a browser dialog), and the
1342
+ // status bar counts the time left down by itself between polls.
1343
+ const autoApprovalScript = `
1344
+ document.addEventListener("click", function (event) {
1345
+ var item = event.target.closest && event.target.closest("[data-auto-approval]");
1346
+ var dialog = document.querySelector("[data-auto-dialog]");
1347
+ if (item && dialog) {
1348
+ dialog.querySelector("[data-auto-dialog-duration]").value = item.getAttribute("data-auto-approval");
1349
+ dialog.querySelector("[data-auto-dialog-label]").textContent = item.textContent;
1350
+ item.closest("details")?.removeAttribute("open");
1351
+ dialog.showModal();
1352
+ return;
1353
+ }
1354
+ if (event.target.closest && event.target.closest("[data-auto-dialog-cancel]")) dialog?.close();
1355
+ });
1356
+ setInterval(function () {
1357
+ document.querySelectorAll("[data-auto-ends-at]").forEach(function (time) {
1358
+ var seconds = Math.max(0, Math.ceil((Number(time.getAttribute("data-auto-ends-at")) - Date.now()) / 1000));
1359
+ time.textContent = "剩 " + Math.floor(seconds / 60) + ":" + String(seconds % 60).padStart(2, "0");
1360
+ });
1361
+ }, 1000);
1362
+ `;
1363
+ /** The reminder before Auto Approval starts (ADR 0014). It stays outside #remote-app, so the poll does not redraw it. */
1364
+ const AUTO_APPROVAL_DIALOG = `<dialog class="auto-dialog" data-auto-dialog aria-label="打開自動允許"><form method="post" action="/auto-approval-start"><input type="hidden" name="duration" value="10" data-auto-dialog-duration>`
1365
+ + `<h3>${BOLT}打開自動允許(<span data-auto-dialog-label>10 分鐘</span>)</h3>`
1366
+ + `<p>自動允許期間,Agent 可以不經過你,直接執行指令、寫入檔案和儲存圖片。</p>`
1367
+ + `<p class="auto-dialog-warn">如果你的 Agent 會讀網頁或電子郵件,那些內容可能藏著給 Agent 的指令。</p>`
1368
+ + `<p class="hint">下面這兩種情況仍然會問你:</p><ul class="hint"><li>碰到機密檔案,例如 <code>.env</code>、私密金鑰</li><li>刪除專案資料夾以外的檔案</li></ul>`
1369
+ + `<p class="hint">排隊中的確認也會一起允許。你隨時可以按「停止自動允許」。</p>`
1370
+ + `<div class="auto-dialog-actions"><button type="button" data-auto-dialog-cancel>取消</button><button type="submit" class="auto-dialog-ok">確定打開</button></div></form></dialog>`;
1371
+ const REMOTE_AGENT_STYLES = `
1372
+ main.remote-main { width: min(72rem, 100%); }
1373
+ main.remote-main, .auto-dialog { --auto: light-dark(#7c3aed, #a78bfa); --auto-err: light-dark(#c0362c, #ff7b72); }
1374
+ #remote-app { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
1375
+ .remote-main .tile { gap: 10px; padding: 16px 18px; min-width: 0; }
1376
+ .remote-main .hint { color: var(--muted); font-size: 13px; line-height: 1.6; }
1377
+ .remote-status { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px 16px; }
1378
+ .remote-status-main { display: flex; align-items: center; gap: 10px; flex: 1 1 20rem; min-width: 0; }
1379
+ .remote-status-main strong { font-size: 14px; overflow-wrap: anywhere; }
1380
+ .remote-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
1381
+ .remote-dot.on { background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
1382
+ .remote-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
1383
+ .remote-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--input); color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
1384
+ .remote-chip b { color: var(--text); font-weight: 600; }
1385
+ .remote-switch-row { display: flex; flex-direction: row; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
1386
+ /* 頁面的一般 button 樣式會改變開關大小,所以開關有自己的固定尺寸。 */
1387
+ main button.remote-switch { box-sizing: border-box; position: relative; width: 44px; height: 26px; min-width: 44px; min-height: 26px; max-height: 26px; padding: 0; line-height: 0; flex: 0 0 44px; border: 0; border-radius: 999px; background: var(--modes); }
1388
+ .remote-switch::after { content: ""; position: absolute; top: 50%; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transform: translateY(-50%); transition: left 0.15s; }
1389
+ main button.remote-switch[aria-checked="true"] { background: var(--accent); }
1390
+ .remote-switch[aria-checked="true"]::after { left: calc(100% - 23px); }
1391
+ .remote-setup { flex-basis: 100%; margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--input); color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
1392
+ .local-approval { border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: inset 4px 0 0 var(--accent); }
1393
+ .local-approval-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
1394
+ .local-approval-title { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
1395
+ .local-approval-queue { margin-left: auto; }
1396
+ .local-approval-body { margin: 0; max-height: 16rem; overflow: auto; padding: 8px 10px; background: var(--input); border-radius: 6px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
1397
+ main button.local-approval-full { align-self: flex-start; min-height: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
1398
+ .local-approval-timer { height: 4px; border-radius: 999px; background: var(--modes); overflow: hidden; }
1399
+ .local-approval-timer span { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }
1400
+ .local-approval-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
1401
+ .local-approval-actions .hint { margin-right: auto; }
1402
+ main button.local-approval-deny { background: transparent; color: var(--text); border-color: var(--line); }
1403
+ .auto-bolt { width: 14px; height: 14px; flex-shrink: 0; }
1404
+ .remote-main .tile.remote-status.is-auto { border-color: color-mix(in srgb, var(--auto) 55%, transparent); box-shadow: inset 4px 0 0 var(--auto); }
1405
+ .remote-dot.auto { background: var(--auto); box-shadow: 0 0 0 4px color-mix(in srgb, var(--auto) 22%, transparent); }
1406
+ .remote-auto-line { flex-basis: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--auto) 12%, transparent); color: var(--auto); font-size: 13px; }
1407
+ .remote-auto-line .hint { flex: 1 1 18rem; }
1408
+ .remote-auto-time { font-family: Consolas, "Cascadia Mono", monospace; font-variant-numeric: tabular-nums; font-weight: 700; }
1409
+ main button.remote-auto-stop { min-height: 0; padding: 4px 12px; background: transparent; color: var(--auto); border: 1px solid color-mix(in srgb, var(--auto) 55%, transparent); }
1410
+ .remote-main .tile.local-approval.is-exception { border-color: color-mix(in srgb, var(--auto-err) 55%, transparent); box-shadow: inset 4px 0 0 var(--auto-err); }
1411
+ .local-approval-exception { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--auto-err); }
1412
+ .auto-menu { position: relative; }
1413
+ .auto-menu-button { list-style: none; cursor: pointer; padding: 6px 14px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--auto) 55%, transparent); color: var(--auto); font-size: 13px; }
1414
+ .auto-menu-button::-webkit-details-marker { display: none; }
1415
+ .auto-menu-list { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 30; display: flex; flex-direction: column; min-width: 10rem; padding: 4px; border-radius: 10px; background: var(--tile, var(--bg)); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); }
1416
+ main .auto-menu-list button { min-height: 0; text-align: left; padding: 8px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font-size: 13px; }
1417
+ main .auto-menu-list button:hover { background: var(--modes); }
1418
+ .auto-dialog { width: min(30rem, calc(100% - 32px)); padding: 20px 22px; border-radius: 14px; border: 1px solid var(--line); background: var(--tile, var(--bg)); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4); font-size: 14px; line-height: 1.6; }
1419
+ .auto-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
1420
+ .auto-dialog form { display: flex; flex-direction: column; gap: 8px; }
1421
+ .auto-dialog h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; font-size: 16px; color: var(--auto); }
1422
+ .auto-dialog p, .auto-dialog ul { margin: 0; }
1423
+ .auto-dialog ul { padding-left: 1.2rem; }
1424
+ .auto-dialog .hint { color: var(--muted); font-size: 13px; }
1425
+ .auto-dialog-warn { color: var(--auto-err); }
1426
+ .auto-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
1427
+ .auto-dialog-actions button { padding: 7px 16px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
1428
+ .auto-dialog-actions .auto-dialog-ok { background: var(--auto); color: #fff; border-color: transparent; font-weight: 600; }
1429
+ ${remoteAgentLogView_1.REMOTE_AGENT_LOG_STYLES}`;
1430
+ /** 遠端 Agent:Local Tool Access 的開關、確認卡片和 Remote Agent Log,與其他頁共用頁殼、側欄、主題與法鬥超人頁首。 */
1431
+ function renderRemoteAgentPage(view) {
1432
+ return `${documentHead()}
1433
+ <body>
1434
+ ${sideMenu("remote-agent")}
1435
+ <main class="remote-main">
1436
+ <header class="page-head pi-head"><div class="pi-head-text"><h2>遠端 Agent</h2><p>看看 Agent 透過 MCP 在這台電腦做了哪些事。</p></div>${connectionMascot_1.connectionMascot}</header>
1437
+ <div id="remote-app">${remoteAgentBody(view)}</div>
1438
+ </main>
1439
+ ${AUTO_APPROVAL_DIALOG}
1440
+ <style>
1441
+ ${SHELL_LAYOUT_STYLES}
1442
+ ${SHELL_CONTROL_STYLES}
1443
+ .pi-head { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 0 16px; }
1444
+ .pi-head-text { flex: 0 1 auto; padding-bottom: 12px; }
1445
+ .pi-head .connection-mascot { flex: 1 1 260px; height: 144px; }
1446
+ ${connectionMascot_1.connectionMascotStyles}
1447
+ ${headPatrol.styles}
1448
+ ${REMOTE_AGENT_STYLES}
1449
+ </style>
1450
+ ${headPatrol.sheet}
1451
+ <script>${drawerScript()}${powerMenuView_1.powerMenuScript}${connectionMascot_1.connectionMascotScript}${headPatrol.script}${remoteAgentActionsScript}${autoApprovalScript}${remoteAgentLogView_1.remoteAgentLogScript}${modelStatus_1.modelStatusScript}${modelStatus_1.approvalFullScript}</script>
1452
+ </body>
1453
+ </html>`;
1454
+ }