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.
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APPROVAL_TIMEOUT_MS = exports.AUTO_APPROVAL_EXCEPTION_LABELS = void 0;
4
+ exports.askApproval = askApproval;
5
+ exports.approvalRefusal = approvalRefusal;
6
+ exports.autoApprovalException = autoApprovalException;
7
+ exports.createApprovalQueue = createApprovalQueue;
8
+ const projectPath_1 = require("./projectPath");
9
+ /**
10
+ * Asks `approver` and turns anything but approval into the reply for the agent.
11
+ * `notDone` says what did not happen, for example "沒有寫入檔案".
12
+ */
13
+ async function askApproval(approver, request, signal, notDone) {
14
+ const outcome = await approver.request(request, signal);
15
+ return outcome === "approved" || outcome === "auto" ? undefined : approvalRefusal(outcome, notDone);
16
+ }
17
+ function approvalRefusal(outcome, notDone) {
18
+ if (outcome === "timeout")
19
+ return { ok: false, error: "approval_timeout", message: `學生在 ${exports.APPROVAL_TIMEOUT_MS / 60_000} 分鐘內沒有決定,${notDone}。` };
20
+ if (outcome === "access_off")
21
+ return { ok: false, error: "denied", message: `學生關閉了「允許 Agent 使用這台電腦」,${notDone}。` };
22
+ if (outcome === "cancelled")
23
+ return { ok: false, error: "denied", message: `這個呼叫已被取消,${notDone}。` };
24
+ return { ok: false, error: "denied", message: `學生拒絕了,${notDone}。` };
25
+ }
26
+ exports.AUTO_APPROVAL_EXCEPTION_LABELS = {
27
+ secret_file: "碰到機密檔案",
28
+ delete_outside: "刪除專案資料夾以外的檔案",
29
+ };
30
+ // The words of a command, split at spaces, quotes and shell punctuation.
31
+ const commandWords = (command) => command.split(/[\s'"`=<>|;&()]+/).filter(Boolean);
32
+ // A target outside the Project Folder: absolute, the home folder, the parent folder, or a drive letter.
33
+ const OUTSIDE_TARGET = /^(\/|~|\$HOME\b|\$\{HOME\}|\.\.|[A-Za-z]:)/;
34
+ // The parts of a command that run on their own: split at `;`, `&&`, `||`, `|`, `&`, line ends, `( )`, `$(` and backquotes.
35
+ const COMMAND_BREAKS = /&&|\|\||\$\(|[;|&\n()`]/;
36
+ // `rm` as a command word, also with a path such as `/bin/rm`.
37
+ const isRm = (word) => word === "rm" || word.endsWith("/rm");
38
+ // An `rm` anywhere in the command, also inside `bash -c "..."`, `$( )` or after `xargs`, with -r/-f and a target outside.
39
+ function deletesOutside(command) {
40
+ for (const part of command.split(COMMAND_BREAKS)) {
41
+ const words = part.replace(/["']/g, " ").trim().split(/\s+/);
42
+ const at = words.findIndex(isRm);
43
+ if (at < 0)
44
+ continue;
45
+ const rest = words.slice(at + 1);
46
+ const forced = rest.some(word => word === "--recursive" || word === "--force" || /^-[^-]*[rRf]/.test(word));
47
+ if (forced && rest.some(word => !word.startsWith("-") && OUTSIDE_TARGET.test(word)))
48
+ return true;
49
+ }
50
+ return false;
51
+ }
52
+ /**
53
+ * The Auto Approval Exception of a request, or undefined. The rules match text, so they catch only clear cases (ADR 0014).
54
+ * The Secret File check is the one that `read_file` uses: the file name, and for `write_file` also a private key in the text.
55
+ */
56
+ function autoApprovalException(request) {
57
+ if (request.tool === "write_file") {
58
+ const secret = (0, projectPath_1.isSecretFileName)(request.target) || (request.contents ?? []).some(projectPath_1.hasPrivateKey);
59
+ return secret ? "secret_file" : undefined;
60
+ }
61
+ if (request.tool !== "bash")
62
+ return undefined;
63
+ if (commandWords(request.target).some(projectPath_1.isSecretFileName))
64
+ return "secret_file";
65
+ return deletesOutside(request.target) ? "delete_outside" : undefined;
66
+ }
67
+ /** The default time limit, from when an approval is shown (ADR 0013). */
68
+ exports.APPROVAL_TIMEOUT_MS = 120_000;
69
+ function createApprovalQueue(options = {}) {
70
+ const timeoutMs = options.timeoutMs ?? exports.APPROVAL_TIMEOUT_MS;
71
+ const entries = [];
72
+ const listeners = new Set();
73
+ let shown;
74
+ let timer;
75
+ let auto;
76
+ let autoTimer;
77
+ let nextId = 0;
78
+ const snapshot = () => shown && { ...shown, waiting: entries.length - 1 };
79
+ const notify = () => {
80
+ const current = snapshot();
81
+ for (const listener of [...listeners]) {
82
+ try {
83
+ listener(current);
84
+ }
85
+ catch { /* one listener must not stop the others */ }
86
+ }
87
+ };
88
+ /** Shows the first entry if nothing is shown, and tells the listeners when the shown approval changed. */
89
+ const showNext = (changed) => {
90
+ if (!shown && entries.length > 0) {
91
+ const first = entries[0];
92
+ const shownAt = Date.now();
93
+ shown = { id: first.id, request: first.request, ...(first.exception ? { exception: first.exception } : {}), shownAt, expiresAt: shownAt + timeoutMs, waiting: 0 };
94
+ timer = setTimeout(() => end(first.id, "timeout"), timeoutMs);
95
+ changed = true;
96
+ }
97
+ if (changed)
98
+ notify();
99
+ };
100
+ /** Ends one entry, shown or waiting. False when it has already ended. */
101
+ const end = (id, outcome) => {
102
+ const index = entries.findIndex(entry => entry.id === id);
103
+ if (index < 0)
104
+ return false;
105
+ const [entry] = entries.splice(index, 1);
106
+ const wasShown = shown?.id === id;
107
+ if (wasShown) {
108
+ shown = undefined;
109
+ if (timer)
110
+ clearTimeout(timer);
111
+ timer = undefined;
112
+ }
113
+ entry.settle(outcome);
114
+ showNext(wasShown);
115
+ return true;
116
+ };
117
+ /** Ends Auto Approval. True when it was on. */
118
+ const endAuto = () => {
119
+ if (!auto)
120
+ return false;
121
+ auto = undefined;
122
+ if (autoTimer)
123
+ clearTimeout(autoTimer);
124
+ autoTimer = undefined;
125
+ return true;
126
+ };
127
+ return {
128
+ request(request, signal) {
129
+ if (signal?.aborted)
130
+ return Promise.resolve("cancelled");
131
+ const exception = autoApprovalException(request);
132
+ if (auto && !exception)
133
+ return Promise.resolve("auto");
134
+ return new Promise(resolve => {
135
+ const id = `approval-${++nextId}`;
136
+ const onAbort = () => end(id, "cancelled");
137
+ signal?.addEventListener("abort", onAbort, { once: true });
138
+ entries.push({
139
+ id,
140
+ request,
141
+ ...(exception ? { exception } : {}),
142
+ settle(outcome) { signal?.removeEventListener("abort", onAbort); resolve(outcome); },
143
+ });
144
+ // A new waiting approval changes the count that the shown one carries.
145
+ showNext(shown !== undefined);
146
+ });
147
+ },
148
+ shown: snapshot,
149
+ decide(id, decision) {
150
+ if (shown?.id !== id)
151
+ return false;
152
+ return end(id, decision === "approve" ? "approved" : "denied");
153
+ },
154
+ denyAll() {
155
+ const changed = endAuto();
156
+ for (const entry of [...entries].reverse())
157
+ end(entry.id, "access_off");
158
+ if (changed)
159
+ notify();
160
+ },
161
+ startAutoApproval(durationMs) {
162
+ endAuto();
163
+ auto = durationMs === undefined ? {} : { endsAt: Date.now() + durationMs };
164
+ if (durationMs !== undefined)
165
+ autoTimer = setTimeout(() => { if (endAuto())
166
+ notify(); }, durationMs);
167
+ for (const entry of entries.filter(entry => !entry.exception))
168
+ end(entry.id, "auto");
169
+ notify();
170
+ },
171
+ stopAutoApproval() {
172
+ if (endAuto())
173
+ notify();
174
+ },
175
+ autoApproval: () => auto && { ...auto },
176
+ subscribe(listener) {
177
+ listeners.add(listener);
178
+ return () => { listeners.delete(listener); };
179
+ },
180
+ };
181
+ }
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.localSystem = exports.MAX_READ_CHARS = exports.NO_PROJECT_FOLDER_NOTE = void 0;
7
+ exports.createLocalTools = createLocalTools;
8
+ exports.findGitBash = findGitBash;
9
+ // The Local Tools that a Device answers for a Remote Agent (ADR 0013).
10
+ // A tool that is not built yet answers `unknown_tool`.
11
+ const promises_1 = __importDefault(require("node:fs/promises"));
12
+ const node_os_1 = __importDefault(require("node:os"));
13
+ const node_path_1 = __importDefault(require("node:path"));
14
+ const lineChanges_1 = require("./lineChanges");
15
+ const localCommands_1 = require("./localCommands");
16
+ const localToolApproval_1 = require("./localToolApproval");
17
+ const projectPath_1 = require("./projectPath");
18
+ const remoteAgentLog_1 = require("./remoteAgentLog");
19
+ const saveImage_1 = require("./saveImage");
20
+ const systemPath_1 = require("./systemPath");
21
+ const windowsEnvironmentSystem_1 = require("./windowsEnvironmentSystem");
22
+ const MAX_ENTRIES = 200;
23
+ exports.NO_PROJECT_FOLDER_NOTE = "學生還沒有在 VansPod 選擇專案資料夾。請學生打開 VansPod,按「選擇專案資料夾」。";
24
+ async function topLevelEntries(folder) {
25
+ const found = await promises_1.default.readdir(folder, { withFileTypes: true });
26
+ const entries = found
27
+ .map(entry => ({ name: entry.name, type: entry.isDirectory() ? "folder" : "file" }))
28
+ .sort((a, b) => a.type === b.type ? a.name.localeCompare(b.name, "en", { sensitivity: "base" }) : a.type === "folder" ? -1 : 1);
29
+ return { entries: entries.slice(0, MAX_ENTRIES), truncated: entries.length > MAX_ENTRIES };
30
+ }
31
+ async function localStatus(options) {
32
+ const [bash, python] = await Promise.all([options.system.gitBash(), options.system.python()]);
33
+ const result = {
34
+ os: options.system.os(),
35
+ shell: bash ? { name: "Git Bash", available: true, path: bash } : { name: "Git Bash", available: false },
36
+ };
37
+ const folder = options.projectFolder();
38
+ if (!folder) {
39
+ result.project_folder = null;
40
+ result.project_folder_note = exports.NO_PROJECT_FOLDER_NOTE;
41
+ }
42
+ else {
43
+ result.project_folder = folder;
44
+ try {
45
+ const { entries, truncated } = await topLevelEntries(folder);
46
+ result.entries = entries;
47
+ if (truncated)
48
+ result.entries_truncated = true;
49
+ }
50
+ catch {
51
+ result.project_folder_note = "VansPod 讀不到這個專案資料夾,它可能已被移動或刪除。";
52
+ }
53
+ }
54
+ result.python = python ?? null;
55
+ return { ok: true, result };
56
+ }
57
+ async function listFiles(projectFolder, args) {
58
+ const target = await (0, projectPath_1.resolveProjectPath)(projectFolder, args.path ?? ".");
59
+ if (!target.ok)
60
+ return target;
61
+ if (!(await promises_1.default.stat(target.absolute)).isDirectory()) {
62
+ return { ok: false, error: "invalid_arguments", message: `「${target.relative}」是檔案,不是資料夾。請用 read_file 讀取它。` };
63
+ }
64
+ const { entries, truncated } = await topLevelEntries(target.absolute);
65
+ return { ok: true, result: truncated ? { path: target.relative, entries, truncated: true } : { path: target.relative, entries } };
66
+ }
67
+ exports.MAX_READ_CHARS = 30_000;
68
+ // A UTF-8 character has at most 4 bytes, so this many bytes always hold MAX_READ_CHARS characters.
69
+ const MAX_READ_BYTES = exports.MAX_READ_CHARS * 4;
70
+ async function readFile(projectFolder, args) {
71
+ const target = await (0, projectPath_1.resolveProjectPath)(projectFolder, args.path);
72
+ if (!target.ok)
73
+ return target;
74
+ if ((0, projectPath_1.isSecretFileName)(target.relative) || (0, projectPath_1.isSecretFileName)(target.absolute))
75
+ return (0, projectPath_1.secretFileRefusal)(target.relative);
76
+ const stat = await promises_1.default.stat(target.absolute);
77
+ if (stat.isDirectory()) {
78
+ return { ok: false, error: "invalid_arguments", message: `「${target.relative}」是資料夾,不是檔案。請用 list_files 看裡面有什麼。` };
79
+ }
80
+ const file = await promises_1.default.open(target.absolute, "r");
81
+ let bytes;
82
+ try {
83
+ const buffer = Buffer.alloc(Math.min(stat.size, MAX_READ_BYTES));
84
+ const { bytesRead } = await file.read(buffer, 0, buffer.length, 0);
85
+ bytes = buffer.subarray(0, bytesRead);
86
+ }
87
+ finally {
88
+ await file.close();
89
+ }
90
+ if (bytes.includes(0)) {
91
+ return { ok: false, error: "failed", message: `「${target.relative}」不是文字檔,read_file 只能讀取文字檔。` };
92
+ }
93
+ const text = new TextDecoder("utf-8").decode(bytes);
94
+ if ((0, projectPath_1.hasPrivateKey)(text))
95
+ return (0, projectPath_1.secretFileRefusal)(target.relative);
96
+ const chars = Array.from(text);
97
+ const truncated = chars.length > exports.MAX_READ_CHARS || stat.size > bytes.length;
98
+ if (!truncated)
99
+ return { ok: true, result: { path: target.relative, content: text, truncated: false } };
100
+ return {
101
+ ok: true,
102
+ result: {
103
+ path: target.relative,
104
+ content: chars.slice(0, exports.MAX_READ_CHARS).join(""),
105
+ truncated: true,
106
+ note: `檔案太長,只回傳前 ${exports.MAX_READ_CHARS.toLocaleString("en-US")} 個字元(檔案共 ${stat.size} 位元組)。`,
107
+ },
108
+ };
109
+ }
110
+ const NOT_WRITTEN = "沒有寫入檔案";
111
+ async function writeFile(projectFolder, args, signal, context) {
112
+ if (typeof args.content !== "string")
113
+ return { ok: false, error: "invalid_arguments", message: "content 必須是要寫入的文字。" };
114
+ const content = args.content;
115
+ const target = await (0, projectPath_1.resolveProjectPath)(projectFolder, args.path, { allowMissing: true });
116
+ if (!target.ok)
117
+ return target;
118
+ let title = `寫入新檔案 ${target.relative}`;
119
+ let body = content;
120
+ let before;
121
+ if (target.exists) {
122
+ if ((await promises_1.default.stat(target.absolute)).isDirectory()) {
123
+ return { ok: false, error: "invalid_arguments", message: `「${target.relative}」是資料夾,不能寫成檔案。` };
124
+ }
125
+ const old = await promises_1.default.readFile(target.absolute);
126
+ title = `修改檔案 ${target.relative}`;
127
+ before = old.includes(0) ? undefined : old.toString("utf8");
128
+ body = before === undefined
129
+ ? `(原本不是文字檔,整個檔案會換成下面的內容)\n${content}`
130
+ : (0, lineChanges_1.lineChanges)(before, content);
131
+ context.call.wrote(content, before, false);
132
+ }
133
+ else {
134
+ context.call.wrote(content, undefined, true);
135
+ }
136
+ const contents = before === undefined ? [content] : [content, before];
137
+ const refusal = await (0, localToolApproval_1.askApproval)(context.approver, { tool: "write_file", title, body, target: target.relative, folder: projectFolder, contents }, signal, NOT_WRITTEN);
138
+ if (refusal)
139
+ return refusal;
140
+ // Resolve again: the folder may have changed while the student decided.
141
+ const now = await (0, projectPath_1.resolveProjectPath)(projectFolder, args.path, { allowMissing: true });
142
+ if (!now.ok)
143
+ return now;
144
+ try {
145
+ await promises_1.default.mkdir(node_path_1.default.dirname(now.absolute), { recursive: true });
146
+ await promises_1.default.writeFile(now.absolute, content, "utf8");
147
+ }
148
+ catch (error) {
149
+ return { ok: false, error: "failed", message: `無法寫入「${now.relative}」:${error instanceof Error ? error.message : "原因不明"}。` };
150
+ }
151
+ return { ok: true, result: { path: now.relative, created: !now.exists } };
152
+ }
153
+ /** Add a Project Folder tool here. */
154
+ const PROJECT_TOOLS = {
155
+ list_files: listFiles,
156
+ read_file: readFile,
157
+ write_file: writeFile,
158
+ bash: localCommands_1.bashTool,
159
+ save_image: saveImage_1.saveImage,
160
+ };
161
+ /** The path or the command of a call, for the Remote Agent Log. */
162
+ function callTarget(tool, args) {
163
+ const text = (value) => typeof value === "string" ? value : "";
164
+ if (tool === "bash")
165
+ return text(args.command);
166
+ if (tool === "list_files")
167
+ return text(args.path ?? ".");
168
+ if (tool === "save_image")
169
+ return `images/${text(args.file_name)}`;
170
+ if (tool === "local_status")
171
+ return "";
172
+ return text(args.path);
173
+ }
174
+ function createLocalTools(options) {
175
+ const log = options.log ?? (0, remoteAgentLog_1.createRemoteAgentLog)();
176
+ return (tool, args, signal) => log.record(tool, callTarget(tool, args), async (call) => {
177
+ if (tool === "local_status")
178
+ return localStatus(options);
179
+ const projectTool = Object.hasOwn(PROJECT_TOOLS, tool) ? PROJECT_TOOLS[tool] : undefined;
180
+ if (projectTool) {
181
+ const folder = options.projectFolder();
182
+ if (!folder)
183
+ return { ok: false, error: "no_project_folder", message: exports.NO_PROJECT_FOLDER_NOTE };
184
+ // The entry keeps how each Local Tool Approval ended.
185
+ const approver = { request: (request, abort) => call.ask(options.approver, request, abort) };
186
+ return projectTool(folder, args, signal, { approver, call, gitBash: () => options.system.gitBash() });
187
+ }
188
+ return { ok: false, error: "unknown_tool", message: `這台電腦的 VansPod 不認識工具「${tool}」,請更新 VansPod。` };
189
+ });
190
+ }
191
+ function osName() {
192
+ const release = node_os_1.default.release();
193
+ if (process.platform === "win32") {
194
+ const build = Number(release.split(".")[2]);
195
+ return `Windows ${build >= 22000 ? "11" : "10"} (${release}, ${node_os_1.default.arch()})`;
196
+ }
197
+ return `${process.platform === "darwin" ? "macOS" : process.platform} (${release}, ${node_os_1.default.arch()})`;
198
+ }
199
+ /** Git Bash is `bin\bash.exe` in Git's install folder (git.exe is in `cmd\` or `mingw64\bin\`). */
200
+ async function findGitBash() {
201
+ const env = await (0, systemPath_1.envWithRegistryPath)();
202
+ if (process.platform !== "win32")
203
+ return (0, windowsEnvironmentSystem_1.resolveCommand)("bash", env);
204
+ const git = await (0, windowsEnvironmentSystem_1.resolveCommand)("git", env);
205
+ const gitFolders = git ? [node_path_1.default.dirname(node_path_1.default.dirname(git)), node_path_1.default.dirname(node_path_1.default.dirname(node_path_1.default.dirname(git)))] : [];
206
+ // process.env, not the copied env: only process.env reads Windows names in any case.
207
+ const programs = [process.env.ProgramFiles, process.env["ProgramFiles(x86)"], process.env.LOCALAPPDATA && node_path_1.default.join(process.env.LOCALAPPDATA, "Programs")]
208
+ .filter((folder) => Boolean(folder))
209
+ .map(folder => node_path_1.default.join(folder, "Git"));
210
+ const candidates = [...gitFolders, ...programs].map(folder => node_path_1.default.join(folder, "bin", "bash.exe"));
211
+ for (const candidate of candidates) {
212
+ try {
213
+ if ((await promises_1.default.stat(candidate)).isFile())
214
+ return candidate;
215
+ }
216
+ catch { /* next one */ }
217
+ }
218
+ return undefined;
219
+ }
220
+ async function pythonVersion() {
221
+ const tries = process.platform === "win32"
222
+ ? [["python", ["--version"]], ["py", ["-3", "--version"]]]
223
+ : [["python3", ["--version"]], ["python", ["--version"]]];
224
+ for (const [command, args] of tries) {
225
+ const result = await windowsEnvironmentSystem_1.windowsEnvironmentSystem.run(command, args, { timeoutMs: 10_000 });
226
+ const output = result.output.trim();
227
+ if (result.exitCode === 0 && /^Python \d+\.\d+/.test(output))
228
+ return output.split(/\r?\n/)[0];
229
+ }
230
+ return undefined;
231
+ }
232
+ exports.localSystem = { os: osName, gitBash: findGitBash, python: pythonVersion };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.modelStatusScript = void 0;
3
+ exports.approvalFullScript = exports.modelStatusScript = void 0;
4
4
  exports.modelStatusScript = `
5
5
  async function refreshModelStatus() {
6
6
  try {
@@ -15,6 +15,26 @@ exports.modelStatusScript = `
15
15
  setTimeout(refreshModelStatus, 1000);
16
16
  }
17
17
  function applyModelStatus(status) {
18
+ if (status.localTools) {
19
+ var statusBar = document.querySelector("[data-remote-status]");
20
+ var remoteStatus = status.localTools.status;
21
+ if (statusBar && remoteStatus && (statusBar.getAttribute("data-status-key") || "") !== remoteStatus.key) statusBar.outerHTML = remoteStatus.html;
22
+ var logList = document.querySelector("[data-log-list]");
23
+ var log = status.localTools.log;
24
+ if (logList && log && (logList.getAttribute("data-log-key") || "") !== log.key && typeof replaceRemoteAgentLog === "function") replaceRemoteAgentLog(log);
25
+ var approvalBlock = document.querySelector("[data-local-approval]");
26
+ if (approvalBlock) {
27
+ var approval = status.localTools.approval;
28
+ if ((approvalBlock.getAttribute("data-approval-key") || null) !== (approval ? approval.key : null)) {
29
+ approvalBlock.outerHTML = approval ? approval.html : '<div data-local-approval hidden></div>';
30
+ } else if (approval) {
31
+ var seconds = approvalBlock.querySelector("[data-approval-seconds]");
32
+ if (seconds) seconds.textContent = String(approval.secondsLeft);
33
+ var bar = approvalBlock.querySelector("[data-approval-bar]");
34
+ if (bar) bar.style.width = approval.bar;
35
+ }
36
+ }
37
+ }
18
38
  document.querySelectorAll("[data-client-light]").forEach(function (light) {
19
39
  var next = status.lights[light.getAttribute("data-client-light")];
20
40
  if (!next || (light.className === next.className && light.title === next.status)) return;
@@ -40,3 +60,20 @@ exports.modelStatusScript = `
40
60
  }
41
61
  setTimeout(refreshModelStatus, 1000);
42
62
  `;
63
+ // 「顯示全部」 on a cut Local Tool Approval body: loads the full body of that approval once.
64
+ // The status poll redraws the block only when the shown approval changes, so the full body stays.
65
+ exports.approvalFullScript = `
66
+ document.addEventListener("click", async function (event) {
67
+ var button = event.target && event.target.closest && event.target.closest("[data-approval-full]");
68
+ if (!button) return;
69
+ try {
70
+ var response = await fetch("/local-tool-approval-body?id=" + encodeURIComponent(button.getAttribute("data-approval-full")), { cache: "no-store" });
71
+ if (!response.ok) return;
72
+ var answer = await response.json();
73
+ var block = button.closest("[data-local-approval]");
74
+ var pre = block && block.querySelector(".local-approval-body");
75
+ if (pre) pre.textContent = answer.body;
76
+ button.remove();
77
+ } catch (error) {}
78
+ });
79
+ `;