@keyou007/agent-bot 0.1.27-alpha.0 → 0.1.27-alpha.1
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/CHANGELOG.md +11 -0
- package/README.md +11 -5
- package/README.zh.md +10 -4
- package/SECURITY.md +4 -4
- package/dist/feishu/CardRenderer.js +2 -2
- package/dist/feishu/CardRenderer.js.map +1 -1
- package/dist/local-files/GitDiffPreview.js +163 -0
- package/dist/local-files/GitDiffPreview.js.map +1 -0
- package/dist/local-files/LocalFileViewerServer.js +63 -9
- package/dist/local-files/LocalFileViewerServer.js.map +1 -1
- package/dist/local-files/TurnPreviewPage.js +106 -48
- package/dist/local-files/TurnPreviewPage.js.map +1 -1
- package/dist/terminal/TerminalPage.js +42 -13
- package/dist/terminal/TerminalPage.js.map +1 -1
- package/dist/terminal/TerminalServer.js +25 -20
- package/dist/terminal/TerminalServer.js.map +1 -1
- package/docs/technical-reference.md +14 -4
- package/docs/technical-reference.zh.md +14 -4
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/skills/agent-bot/SKILL.md +4 -2
- package/src/feishu/CardRenderer.ts +2 -2
- package/src/local-files/GitDiffPreview.ts +141 -0
- package/src/local-files/LocalFileViewerServer.ts +54 -9
- package/src/local-files/TurnPreviewPage.ts +124 -60
- package/src/terminal/TerminalPage.ts +43 -13
- package/src/terminal/TerminalServer.ts +25 -16
|
@@ -11,6 +11,7 @@ import dockerfile from "highlight.js/lib/languages/dockerfile";
|
|
|
11
11
|
import powershell from "highlight.js/lib/languages/powershell";
|
|
12
12
|
import MarkdownIt from "markdown-it";
|
|
13
13
|
import { CSV_PREVIEW_CSS, renderCsvPreview, csvSourcePreview } from "./CsvPreview.js";
|
|
14
|
+
import { GIT_DIFF_PREVIEW_CSS, readGitFileDiff, renderGitFileDiff } from "./GitDiffPreview.js";
|
|
14
15
|
import { enableDiagramFences, DIAGRAM_PREVIEW_CLIENT_SCRIPT, DIAGRAM_PREVIEW_CSS } from "./DiagramPreview.js";
|
|
15
16
|
import { isFileUrl, rewriteMarkdownFileLinks } from "./MarkdownFileLinks.js";
|
|
16
17
|
import {
|
|
@@ -404,18 +405,20 @@ export class LocalFileViewerServer {
|
|
|
404
405
|
} catch { return undefined; }
|
|
405
406
|
}
|
|
406
407
|
|
|
407
|
-
createFileUrl(filePath: string, reference?: string): string | undefined {
|
|
408
|
+
createFileUrl(filePath: string, reference?: string, options?: { diff?: boolean }): string | undefined {
|
|
408
409
|
if (!this.address || !this.secret) return undefined;
|
|
409
410
|
const absolutePath = normalizeAbsolutePath(filePath);
|
|
410
411
|
if (!absolutePath) return undefined;
|
|
411
412
|
try {
|
|
412
413
|
const stat = fs.statSync(absolutePath);
|
|
413
414
|
if (!stat.isFile() && !stat.isDirectory()) return undefined;
|
|
414
|
-
|
|
415
|
-
|
|
415
|
+
if (options?.diff && stat.isDirectory()) return undefined;
|
|
416
|
+
} catch (error) {
|
|
417
|
+
if (!options?.diff || !["ENOENT", "ENOTDIR"].includes((error as NodeJS.ErrnoException).code ?? "")) return undefined;
|
|
416
418
|
}
|
|
417
419
|
|
|
418
420
|
const url = this.createPreviewUrl(absolutePath);
|
|
421
|
+
if (options?.diff) url.searchParams.set("diff", "1");
|
|
419
422
|
const line = parseLineReference(reference);
|
|
420
423
|
if (line !== undefined) url.hash = `L${line}`;
|
|
421
424
|
return url.toString();
|
|
@@ -513,7 +516,7 @@ export class LocalFileViewerServer {
|
|
|
513
516
|
&& (snapshot.fullToolOutputs?.[tool.id]?.length ?? 0) > outputAppend.length
|
|
514
517
|
? { key, revision: String(tool.tool.previewRevision), content: "", outputAppend,
|
|
515
518
|
footer: renderToolFooter(tool.tool, snapshot.fullToolOutputs?.[tool.id]?.length ?? 0, language) }
|
|
516
|
-
: renderTurnPreviewDetail(snapshot, key, (filePath) => this.createFileUrl(filePath), language);
|
|
519
|
+
: renderTurnPreviewDetail(snapshot, key, (filePath, options) => this.createFileUrl(filePath, undefined, options), language);
|
|
517
520
|
setSecurityHeaders(response);
|
|
518
521
|
response.statusCode = detail ? 200 : 404;
|
|
519
522
|
response.setHeader("Cache-Control", "no-store");
|
|
@@ -533,7 +536,7 @@ export class LocalFileViewerServer {
|
|
|
533
536
|
state: snapshot,
|
|
534
537
|
eventsUrl: eventsUrl.toString(),
|
|
535
538
|
scriptPath: `${this.basePath}/assets/turn-preview.js`.replace(/\/{2,}/gu, "/"),
|
|
536
|
-
localFileUrl: (filePath) => this.createFileUrl(filePath),
|
|
539
|
+
localFileUrl: (filePath, options) => this.createFileUrl(filePath, undefined, options),
|
|
537
540
|
diagramScriptPath: `${this.basePath}/assets/mermaid.js`.replace(/\/{2,}/gu, "/"),
|
|
538
541
|
language,
|
|
539
542
|
});
|
|
@@ -558,6 +561,24 @@ export class LocalFileViewerServer {
|
|
|
558
561
|
return;
|
|
559
562
|
}
|
|
560
563
|
|
|
564
|
+
if (requestUrl.searchParams.get("diff") === "1" && requestUrl.searchParams.get("raw") !== "1"
|
|
565
|
+
&& legacyMatch?.[1] !== "raw" && requestUrl.searchParams.get("render") !== "html"
|
|
566
|
+
&& requestUrl.searchParams.get("events") !== "1") {
|
|
567
|
+
const content = await readGitDiffPreview(filePath);
|
|
568
|
+
if (content !== undefined) {
|
|
569
|
+
const original = this.createFileUrl(filePath);
|
|
570
|
+
const actions: Array<{ href: string; label: string }> = [];
|
|
571
|
+
if (original) {
|
|
572
|
+
const raw = new URL(original); raw.searchParams.set("raw", "1");
|
|
573
|
+
const download = new URL(raw); download.searchParams.set("download", "1");
|
|
574
|
+
actions.push({ href: original, label: "查看文件" }, { href: raw.toString(), label: "打开原始文件" }, { href: download.toString(), label: "下载" });
|
|
575
|
+
}
|
|
576
|
+
this.sendHtml(response, 200, renderViewerPage({ title: path.basename(filePath), filePath,
|
|
577
|
+
metadata: ["Git diff", "完整文件", "当前工作区"], actions, content }), request.method === "HEAD");
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
561
582
|
let stat: fs.Stats;
|
|
562
583
|
try {
|
|
563
584
|
stat = fs.statSync(filePath);
|
|
@@ -853,7 +874,7 @@ export class LocalFileViewerServer {
|
|
|
853
874
|
if (!batch.records.length) {
|
|
854
875
|
const state = projection.state;
|
|
855
876
|
if (state && ["completed", "cancelled", "failed"].includes(state.status)) {
|
|
856
|
-
const update = renderTurnPreviewPatch(state, new Set(), new Set(), (file) => this.createFileUrl(file), language);
|
|
877
|
+
const update = renderTurnPreviewPatch(state, new Set(), new Set(), (file, options) => this.createFileUrl(file, undefined, options), language);
|
|
857
878
|
response.write(`id: ${offset}\nevent: patch\ndata: ${JSON.stringify(update)}\n\n`);
|
|
858
879
|
cleanup(); response.end();
|
|
859
880
|
}
|
|
@@ -864,8 +885,8 @@ export class LocalFileViewerServer {
|
|
|
864
885
|
const state = projection.state;
|
|
865
886
|
if (!state) return;
|
|
866
887
|
const render = initial
|
|
867
|
-
? renderTurnPreviewSnapshot(state, (file) => this.createFileUrl(file), language, { deferDetails: true })
|
|
868
|
-
: renderTurnPreviewPatch(state, projection.changed, projection.removed, (file) => this.createFileUrl(file), language);
|
|
888
|
+
? renderTurnPreviewSnapshot(state, (file, options) => this.createFileUrl(file, undefined, options), language, { deferDetails: true })
|
|
889
|
+
: renderTurnPreviewPatch(state, projection.changed, projection.removed, (file, options) => this.createFileUrl(file, undefined, options), language);
|
|
869
890
|
// A terminal record can share a batch with later metadata. Drain the captured prefix first.
|
|
870
891
|
render.terminal = render.terminal && batch.end;
|
|
871
892
|
waitingDrain = !response.write(`id: ${offset}\nevent: ${initial ? "update" : "patch"}\ndata: ${JSON.stringify(render)}\n\n`);
|
|
@@ -916,7 +937,7 @@ export class LocalFileViewerServer {
|
|
|
916
937
|
const serialized = JSON.stringify(state);
|
|
917
938
|
if (serialized === previousSnapshot) return;
|
|
918
939
|
previousSnapshot = serialized;
|
|
919
|
-
const snapshot = renderTurnPreviewSnapshot(state, (filePath) => this.createFileUrl(filePath), language, { deferDetails: true });
|
|
940
|
+
const snapshot = renderTurnPreviewSnapshot(state, (filePath, options) => this.createFileUrl(filePath, undefined, options), language, { deferDetails: true });
|
|
920
941
|
writeServerSentEvent(response, "update", JSON.stringify(snapshot));
|
|
921
942
|
};
|
|
922
943
|
sendSnapshot();
|
|
@@ -1149,6 +1170,7 @@ function renderViewerPage(input: {
|
|
|
1149
1170
|
.markdown-body img { max-width: 100%; height: auto; }
|
|
1150
1171
|
.markdown-body hr { height: 1px; margin: 1.5em 0; border: 0; background: #dfe3e8; }
|
|
1151
1172
|
${CSV_PREVIEW_CSS}
|
|
1173
|
+
${GIT_DIFF_PREVIEW_CSS}
|
|
1152
1174
|
.media { display: grid; place-items: center; min-height: 220px; }
|
|
1153
1175
|
.media img, .media video { max-width: 100%; max-height: calc(100vh - 70px); }
|
|
1154
1176
|
.media audio { width: min(720px, 100%); }
|
|
@@ -1350,6 +1372,29 @@ function parseDirectoryPage(value: string | null): number {
|
|
|
1350
1372
|
return Number.isSafeInteger(page) && page >= 0 ? page : 0;
|
|
1351
1373
|
}
|
|
1352
1374
|
|
|
1375
|
+
async function readGitDiffPreview(filePath: string): Promise<string | undefined> {
|
|
1376
|
+
try {
|
|
1377
|
+
const before = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
1378
|
+
let text = "";
|
|
1379
|
+
if (before) {
|
|
1380
|
+
if (!before.isFile() || before.size > MAX_TEXT_PREVIEW_BYTES) return undefined;
|
|
1381
|
+
const classification = classifyFileContent(filePath, before.size);
|
|
1382
|
+
if (classification.kind !== "text") return undefined;
|
|
1383
|
+
const preview = readTextPreview(filePath, before.size, classification.encoding);
|
|
1384
|
+
if (preview.truncated) return undefined;
|
|
1385
|
+
text = preview.text;
|
|
1386
|
+
}
|
|
1387
|
+
const diff = await readGitFileDiff(filePath);
|
|
1388
|
+
if (!diff) return undefined;
|
|
1389
|
+
const after = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
1390
|
+
if (before?.size !== after?.size || before?.mtimeMs !== after?.mtimeMs || before?.ctimeMs !== after?.ctimeMs
|
|
1391
|
+
|| before?.ino !== after?.ino || before?.dev !== after?.dev) return undefined;
|
|
1392
|
+
return renderGitFileDiff(diff, text);
|
|
1393
|
+
} catch {
|
|
1394
|
+
return undefined;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1353
1398
|
function readTextPreview(
|
|
1354
1399
|
filePath: string,
|
|
1355
1400
|
size: number,
|
|
@@ -13,6 +13,8 @@ import { visibleTurnActivities } from "../presentation/visibleTurnActivities.js"
|
|
|
13
13
|
import { displayRuntimeError } from "../runtime/responseErrors.js";
|
|
14
14
|
import { isFileUrl, rewriteMarkdownFileLinks } from "./MarkdownFileLinks.js";
|
|
15
15
|
|
|
16
|
+
type PreviewFileUrl = (filePath: string, options?: { diff?: boolean }) => string | undefined;
|
|
17
|
+
|
|
16
18
|
const MARKDOWN = new MarkdownIt({
|
|
17
19
|
breaks: true,
|
|
18
20
|
html: false,
|
|
@@ -236,7 +238,9 @@ export const TURN_PREVIEW_CLIENT_SCRIPT = DIAGRAM_PREVIEW_CLIENT_SCRIPT + `(() =
|
|
|
236
238
|
});
|
|
237
239
|
|
|
238
240
|
let source;
|
|
241
|
+
let eventCursor;
|
|
239
242
|
const terminalAtLoad = document.body.dataset.terminal === "true";
|
|
243
|
+
let terminal = terminalAtLoad;
|
|
240
244
|
const updateElapsed = () => {
|
|
241
245
|
document.querySelectorAll("[data-live-elapsed]").forEach((element) => {
|
|
242
246
|
const startedAt = Number(element.dataset.startedAt);
|
|
@@ -270,7 +274,37 @@ export const TURN_PREVIEW_CLIENT_SCRIPT = DIAGRAM_PREVIEW_CLIENT_SCRIPT + `(() =
|
|
|
270
274
|
});
|
|
271
275
|
};
|
|
272
276
|
updateElapsed();
|
|
273
|
-
|
|
277
|
+
let clock = terminalAtLoad ? undefined : setInterval(updateElapsed, 1000);
|
|
278
|
+
|
|
279
|
+
const historyKey = "agentBotTurnPreview";
|
|
280
|
+
const turnId = document.body.dataset.turnId;
|
|
281
|
+
const disclosureStates = new Map();
|
|
282
|
+
const restoredDisclosures = new WeakSet();
|
|
283
|
+
try {
|
|
284
|
+
const saved = window.history?.state?.[historyKey];
|
|
285
|
+
if (saved?.turnId === turnId && Array.isArray(saved.details)) {
|
|
286
|
+
for (const entry of saved.details) {
|
|
287
|
+
if (Array.isArray(entry) && typeof entry[0] === "string" && typeof entry[1] === "boolean") disclosureStates.set(entry[0], entry[1]);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
} catch {}
|
|
291
|
+
const saveDisclosures = () => {
|
|
292
|
+
for (const details of content.querySelectorAll("details[data-activity-id]")) {
|
|
293
|
+
disclosureStates.set(details.dataset.activityId, details.hasAttribute("open"));
|
|
294
|
+
}
|
|
295
|
+
try {
|
|
296
|
+
window.history?.replaceState({ ...window.history.state,
|
|
297
|
+
[historyKey]: { turnId, details: Array.from(disclosureStates) } }, "");
|
|
298
|
+
} catch {}
|
|
299
|
+
};
|
|
300
|
+
const restoreDisclosures = () => {
|
|
301
|
+
for (const details of content.querySelectorAll("details[data-activity-id]")) {
|
|
302
|
+
if (restoredDisclosures.has(details)) continue;
|
|
303
|
+
restoredDisclosures.add(details);
|
|
304
|
+
const open = disclosureStates.get(details.dataset.activityId);
|
|
305
|
+
if (typeof open === "boolean") details.toggleAttribute("open", open);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
274
308
|
|
|
275
309
|
const nodeKey = (node) => {
|
|
276
310
|
if (node.nodeType !== 1) return undefined;
|
|
@@ -441,6 +475,7 @@ export const TURN_PREVIEW_CLIENT_SCRIPT = DIAGRAM_PREVIEW_CLIENT_SCRIPT + `(() =
|
|
|
441
475
|
};
|
|
442
476
|
content.addEventListener("toggle", (event) => {
|
|
443
477
|
const details = event.target;
|
|
478
|
+
if (details.matches?.("details[data-activity-id]")) saveDisclosures();
|
|
444
479
|
if (!details.matches?.("details[data-detail-key]")) return;
|
|
445
480
|
if (details.open) { void loadDetails(details, true); return; }
|
|
446
481
|
const state = detailState(details);
|
|
@@ -451,13 +486,22 @@ export const TURN_PREVIEW_CLIENT_SCRIPT = DIAGRAM_PREVIEW_CLIENT_SCRIPT + `(() =
|
|
|
451
486
|
if (message) message.textContent = "";
|
|
452
487
|
}, true);
|
|
453
488
|
const refreshDetails = () => {
|
|
489
|
+
restoreDisclosures();
|
|
454
490
|
for (const details of content.querySelectorAll("details[data-detail-key][open]")) void loadDetails(details);
|
|
455
491
|
};
|
|
456
492
|
window.addEventListener("pagehide", () => {
|
|
493
|
+
saveDisclosures();
|
|
457
494
|
source?.close();
|
|
495
|
+
source = undefined;
|
|
458
496
|
clearInterval(clock);
|
|
459
|
-
|
|
460
|
-
|
|
497
|
+
clock = undefined;
|
|
498
|
+
for (const details of content.querySelectorAll("details[data-detail-key]")) {
|
|
499
|
+
const state = detailStates.get(details);
|
|
500
|
+
state?.pending?.controller.abort();
|
|
501
|
+
if (state) state.pending = undefined;
|
|
502
|
+
details.querySelector("[data-detail-body]")?.removeAttribute("aria-busy");
|
|
503
|
+
}
|
|
504
|
+
});
|
|
461
505
|
let previousContent;
|
|
462
506
|
let previousMetadata;
|
|
463
507
|
const applySnapshot = (update) => {
|
|
@@ -533,38 +577,58 @@ export const TURN_PREVIEW_CLIENT_SCRIPT = DIAGRAM_PREVIEW_CLIENT_SCRIPT + `(() =
|
|
|
533
577
|
refreshDetails();
|
|
534
578
|
updateElapsed();
|
|
535
579
|
};
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
if (
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
580
|
+
const connect = () => {
|
|
581
|
+
if (terminal || source || typeof EventSource !== "function") return;
|
|
582
|
+
const resumeUrl = eventCursor ? new URL(eventsUrl, window.location.href) : undefined;
|
|
583
|
+
if (resumeUrl) resumeUrl.searchParams.set("after", eventCursor);
|
|
584
|
+
const connection = new EventSource(resumeUrl?.toString() ?? eventsUrl);
|
|
585
|
+
source = connection;
|
|
586
|
+
connection.addEventListener("patch", (event) => {
|
|
587
|
+
if (source !== connection) return;
|
|
588
|
+
try {
|
|
589
|
+
const update = JSON.parse(event.data);
|
|
590
|
+
applyPatch(update);
|
|
591
|
+
eventCursor = event.lastEventId || eventCursor;
|
|
592
|
+
live.textContent = update.terminal ? "" : labels.live;
|
|
593
|
+
live.className = update.terminal ? "live terminal" : "live connected";
|
|
594
|
+
if (update.terminal) { terminal = true; connection.close(); clearInterval(clock); }
|
|
595
|
+
} catch { live.textContent = labels.waitingForUpdates; }
|
|
596
|
+
});
|
|
597
|
+
connection.addEventListener("update", (event) => {
|
|
598
|
+
if (source !== connection) return;
|
|
599
|
+
try {
|
|
600
|
+
const update = JSON.parse(event.data);
|
|
601
|
+
if (typeof update.content !== "string" || typeof update.metadata !== "string") return;
|
|
602
|
+
applySnapshot(update);
|
|
603
|
+
eventCursor = event.lastEventId || eventCursor;
|
|
604
|
+
live.textContent = update.terminal ? "" : labels.live;
|
|
605
|
+
live.className = update.terminal ? "live terminal" : "live connected";
|
|
606
|
+
if (update.terminal) { terminal = true; connection.close(); clearInterval(clock); }
|
|
607
|
+
} catch {
|
|
608
|
+
live.textContent = labels.waitingForUpdates;
|
|
609
|
+
live.className = "live";
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
connection.addEventListener("unavailable", () => {
|
|
613
|
+
if (source !== connection) return;
|
|
614
|
+
live.textContent = labels.unavailable;
|
|
615
|
+
live.className = "live disconnected";
|
|
616
|
+
});
|
|
617
|
+
connection.onerror = () => {
|
|
618
|
+
if (source !== connection) return;
|
|
619
|
+
live.textContent = labels.reconnecting;
|
|
620
|
+
live.className = "live disconnected";
|
|
621
|
+
};
|
|
567
622
|
};
|
|
623
|
+
window.addEventListener("pageshow", (event) => {
|
|
624
|
+
if (!event.persisted) return;
|
|
625
|
+
updateElapsed();
|
|
626
|
+
refreshDetails();
|
|
627
|
+
if (!terminal && clock === undefined) clock = setInterval(updateElapsed, 1000);
|
|
628
|
+
connect();
|
|
629
|
+
});
|
|
630
|
+
refreshDetails();
|
|
631
|
+
connect();
|
|
568
632
|
})();
|
|
569
633
|
`;
|
|
570
634
|
|
|
@@ -594,7 +658,7 @@ export function renderTurnPreviewPage(input: {
|
|
|
594
658
|
eventsUrl: string;
|
|
595
659
|
scriptPath: string;
|
|
596
660
|
diagramScriptPath?: string;
|
|
597
|
-
localFileUrl?:
|
|
661
|
+
localFileUrl?: PreviewFileUrl;
|
|
598
662
|
language?: TurnPreviewLanguage;
|
|
599
663
|
}): string {
|
|
600
664
|
const language = input.language ?? "zh";
|
|
@@ -608,7 +672,7 @@ export function renderTurnPreviewPage(input: {
|
|
|
608
672
|
<title>${escapeHtml(title)} · Agent Bot</title>
|
|
609
673
|
<style>${TURN_PREVIEW_CSS}${DIAGRAM_PREVIEW_CSS}${PREVIEW_SYNTAX_CSS}</style>
|
|
610
674
|
</head>
|
|
611
|
-
<body data-terminal="${snapshot.terminal}" data-events-url="${escapeAttribute(input.eventsUrl)}" data-diagram-script="${escapeAttribute(input.diagramScriptPath ?? "")}">
|
|
675
|
+
<body data-turn-id="${escapeAttribute(input.state.turnId)}" data-terminal="${snapshot.terminal}" data-events-url="${escapeAttribute(input.eventsUrl)}" data-diagram-script="${escapeAttribute(input.diagramScriptPath ?? "")}">
|
|
612
676
|
<header class="page-header">
|
|
613
677
|
<div class="header-inner">
|
|
614
678
|
<div class="header-top">
|
|
@@ -627,7 +691,7 @@ export function renderTurnPreviewPage(input: {
|
|
|
627
691
|
|
|
628
692
|
export function renderTurnPreviewPatch(
|
|
629
693
|
state: TurnViewState, changed: Set<string>, removed: Set<string>,
|
|
630
|
-
localFileUrl:
|
|
694
|
+
localFileUrl: PreviewFileUrl, language: TurnPreviewLanguage,
|
|
631
695
|
): TurnPreviewSnapshot & { removed: string[]; before: Record<string, string> } {
|
|
632
696
|
const visible = visibleTurnActivities(state);
|
|
633
697
|
const visibleIds = new Set(visible.map((activity) => activity.id));
|
|
@@ -646,15 +710,15 @@ export function renderTurnPreviewPatch(
|
|
|
646
710
|
|
|
647
711
|
export function renderTurnPreviewSnapshot(
|
|
648
712
|
state: TurnViewState,
|
|
649
|
-
localFileUrl?:
|
|
713
|
+
localFileUrl?: PreviewFileUrl,
|
|
650
714
|
language: TurnPreviewLanguage = "zh",
|
|
651
715
|
options: { deferDetails?: boolean } = {},
|
|
652
716
|
): TurnPreviewSnapshot {
|
|
653
717
|
const labels = previewLabels(language);
|
|
654
|
-
const resolveFileUrl = localFileUrl ? (filePath
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
return localFileUrl(
|
|
718
|
+
const resolveFileUrl: PreviewFileUrl | undefined = localFileUrl ? (filePath, options) => {
|
|
719
|
+
const target = path.isAbsolute(filePath) || path.win32.isAbsolute(filePath) ? filePath
|
|
720
|
+
: state.projectCwd && path.isAbsolute(state.projectCwd) ? path.resolve(state.projectCwd, filePath) : undefined;
|
|
721
|
+
return target ? options ? localFileUrl(target, options) : localFileUrl(target) : undefined;
|
|
658
722
|
} : undefined;
|
|
659
723
|
const renderText = (value: string): string => renderMarkdown(value, state.projectCwd, localFileUrl, language);
|
|
660
724
|
const timeline = renderTimeline({ ...state, activities: visibleTurnActivities(state) }, renderText, resolveFileUrl, state.fullToolOutputs, state.fullToolErrors, language, state.projectCwd, options.deferDetails);
|
|
@@ -736,7 +800,7 @@ function renderPlan(state: TurnViewState, language: TurnPreviewLanguage): string
|
|
|
736
800
|
function renderTimeline(
|
|
737
801
|
state: TurnViewState,
|
|
738
802
|
renderText: (value: string) => string,
|
|
739
|
-
localFileUrl?:
|
|
803
|
+
localFileUrl?: PreviewFileUrl,
|
|
740
804
|
fullToolOutputs?: Record<string, string>,
|
|
741
805
|
fullToolErrors?: Record<string, string>,
|
|
742
806
|
language: TurnPreviewLanguage = "zh",
|
|
@@ -800,7 +864,7 @@ function leadingReasoningHeading(text: string): { title: string; body: string }
|
|
|
800
864
|
function renderReasoningItem(
|
|
801
865
|
item: TurnReasoningItem,
|
|
802
866
|
cwd: string | undefined,
|
|
803
|
-
localFileUrl:
|
|
867
|
+
localFileUrl: PreviewFileUrl | undefined,
|
|
804
868
|
language: TurnPreviewLanguage,
|
|
805
869
|
deferDetails: boolean,
|
|
806
870
|
): string {
|
|
@@ -819,7 +883,7 @@ function renderReasoningItem(
|
|
|
819
883
|
function renderReasoningBody(
|
|
820
884
|
item: TurnReasoningItem,
|
|
821
885
|
cwd: string | undefined,
|
|
822
|
-
localFileUrl:
|
|
886
|
+
localFileUrl: PreviewFileUrl | undefined,
|
|
823
887
|
language: TurnPreviewLanguage,
|
|
824
888
|
presentation = reasoningPresentation(item),
|
|
825
889
|
): string {
|
|
@@ -838,7 +902,7 @@ function reasoningRevision(item: TurnReasoningItem, cwd?: string): string {
|
|
|
838
902
|
function renderActivity(
|
|
839
903
|
activity: Exclude<TurnActivity, { kind: "reasoning" }>,
|
|
840
904
|
renderText: (value: string) => string,
|
|
841
|
-
localFileUrl?:
|
|
905
|
+
localFileUrl?: PreviewFileUrl,
|
|
842
906
|
fullToolOutputs?: Record<string, string>,
|
|
843
907
|
fullToolErrors?: Record<string, string>,
|
|
844
908
|
language: TurnPreviewLanguage = "zh",
|
|
@@ -862,7 +926,7 @@ function renderMessageActivity(id: string, text: string, kind: string, renderTex
|
|
|
862
926
|
return `<article class="activity message ${kind}" data-activity="${escapeAttribute(id)}"><div class="markdown">${renderText(text)}${images}</div></article>`;
|
|
863
927
|
}
|
|
864
928
|
|
|
865
|
-
function renderMessageImages(paths: string[] | undefined, localFileUrl:
|
|
929
|
+
function renderMessageImages(paths: string[] | undefined, localFileUrl: PreviewFileUrl | undefined, language: TurnPreviewLanguage): string {
|
|
866
930
|
if (!paths?.length) return "";
|
|
867
931
|
return [...new Set(paths)].map((filePath, index) => {
|
|
868
932
|
const label = language === "zh" ? `图片 ${index + 1}` : `Image ${index + 1}`;
|
|
@@ -883,7 +947,7 @@ function renderMessageImages(paths: string[] | undefined, localFileUrl: ((filePa
|
|
|
883
947
|
function renderToolActivity(
|
|
884
948
|
activityId: string,
|
|
885
949
|
tool: ToolState,
|
|
886
|
-
localFileUrl?:
|
|
950
|
+
localFileUrl?: PreviewFileUrl,
|
|
887
951
|
fullToolOutputs?: Record<string, string>,
|
|
888
952
|
fullToolErrors?: Record<string, string>,
|
|
889
953
|
language: TurnPreviewLanguage = "zh",
|
|
@@ -916,7 +980,7 @@ function renderToolActivity(
|
|
|
916
980
|
function renderToolBody(
|
|
917
981
|
activityId: string,
|
|
918
982
|
tool: ToolState,
|
|
919
|
-
localFileUrl?:
|
|
983
|
+
localFileUrl?: PreviewFileUrl,
|
|
920
984
|
fullToolOutputs?: Record<string, string>,
|
|
921
985
|
fullToolErrors?: Record<string, string>,
|
|
922
986
|
language: TurnPreviewLanguage = "zh",
|
|
@@ -1109,7 +1173,7 @@ function formatShortDuration(duration: string): string {
|
|
|
1109
1173
|
|
|
1110
1174
|
function renderToolImage(
|
|
1111
1175
|
tool: ToolState,
|
|
1112
|
-
localFileUrl?:
|
|
1176
|
+
localFileUrl?: PreviewFileUrl,
|
|
1113
1177
|
language: TurnPreviewLanguage = "zh",
|
|
1114
1178
|
): string {
|
|
1115
1179
|
if (!tool.imagePath || !localFileUrl) return "";
|
|
@@ -1127,7 +1191,7 @@ function renderToolImage(
|
|
|
1127
1191
|
function renderFileSummary(
|
|
1128
1192
|
state: TurnViewState,
|
|
1129
1193
|
language: TurnPreviewLanguage,
|
|
1130
|
-
localFileUrl?:
|
|
1194
|
+
localFileUrl?: PreviewFileUrl,
|
|
1131
1195
|
deferDetails = false,
|
|
1132
1196
|
): string {
|
|
1133
1197
|
const labels = previewLabels(language);
|
|
@@ -1136,7 +1200,7 @@ function renderFileSummary(
|
|
|
1136
1200
|
return `<details class="files-summary" data-activity-id="turn:files-summary"${lazy}><summary><h2>${escapeHtml(labels.fileChanges)} <span>${state.fileSummary.length}</span></h2></summary>${body}</details>`;
|
|
1137
1201
|
}
|
|
1138
1202
|
|
|
1139
|
-
function renderFileSummaryBody(state: TurnViewState, localFileUrl?:
|
|
1203
|
+
function renderFileSummaryBody(state: TurnViewState, localFileUrl?: PreviewFileUrl): string {
|
|
1140
1204
|
return `<ul class="files">${state.fileSummary.map((file) => renderFileEntry(file, localFileUrl, state.projectCwd)).join("")}</ul>`;
|
|
1141
1205
|
}
|
|
1142
1206
|
|
|
@@ -1167,13 +1231,13 @@ export interface TurnPreviewDetail {
|
|
|
1167
1231
|
export function renderTurnPreviewDetail(
|
|
1168
1232
|
state: TurnViewState,
|
|
1169
1233
|
key: string,
|
|
1170
|
-
localFileUrl?:
|
|
1234
|
+
localFileUrl?: PreviewFileUrl,
|
|
1171
1235
|
language: TurnPreviewLanguage = "zh",
|
|
1172
1236
|
): TurnPreviewDetail | undefined {
|
|
1173
|
-
const resolveFileUrl = localFileUrl ? (filePath
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
return localFileUrl(
|
|
1237
|
+
const resolveFileUrl: PreviewFileUrl | undefined = localFileUrl ? (filePath, options) => {
|
|
1238
|
+
const target = path.isAbsolute(filePath) || path.win32.isAbsolute(filePath) ? filePath
|
|
1239
|
+
: state.projectCwd && path.isAbsolute(state.projectCwd) ? path.resolve(state.projectCwd, filePath) : undefined;
|
|
1240
|
+
return target ? options ? localFileUrl(target, options) : localFileUrl(target) : undefined;
|
|
1177
1241
|
} : undefined;
|
|
1178
1242
|
if (key === "files" && state.fileSummary.length > 0) {
|
|
1179
1243
|
return { key, revision: fileSummaryRevision(state), content: renderFileSummaryBody(state, resolveFileUrl) };
|
|
@@ -1195,9 +1259,9 @@ export function renderTurnPreviewDetail(
|
|
|
1195
1259
|
};
|
|
1196
1260
|
}
|
|
1197
1261
|
|
|
1198
|
-
function renderFileEntry(file: FileSummary, localFileUrl?:
|
|
1262
|
+
function renderFileEntry(file: FileSummary, localFileUrl?: PreviewFileUrl, projectCwd?: string): string {
|
|
1199
1263
|
const label = `<code>${escapeHtml(displayFilePath(file.path, projectCwd))}</code>`;
|
|
1200
|
-
const url = localFileUrl?.(file.path);
|
|
1264
|
+
const url = localFileUrl?.(file.path, { diff: true });
|
|
1201
1265
|
const link = url
|
|
1202
1266
|
? `<a class="file-link" href="${escapeAttribute(url)}" target="_blank" rel="noreferrer noopener">${label}</a>`
|
|
1203
1267
|
: label;
|
|
@@ -1238,7 +1302,7 @@ function previewTitle(state: TurnViewState): string {
|
|
|
1238
1302
|
return value.length > 80 ? `${value.slice(0, 79)}…` : value;
|
|
1239
1303
|
}
|
|
1240
1304
|
|
|
1241
|
-
function renderMarkdown(value: string, projectCwd?: string, localFileUrl?:
|
|
1305
|
+
function renderMarkdown(value: string, projectCwd?: string, localFileUrl?: PreviewFileUrl, language: TurnPreviewLanguage = "zh"): string {
|
|
1242
1306
|
const environment = { language };
|
|
1243
1307
|
const tokens = MARKDOWN.parse(value, environment);
|
|
1244
1308
|
// Only the directory is used to resolve relative links; no Markdown file is created.
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import { DEFAULT_TERMINAL_PASSWORD } from "../config/schema.js";
|
|
2
|
+
|
|
3
|
+
export function terminalPage(base: string, recovery = false, autoResume = false, defaultPassword = false): string {
|
|
4
|
+
defaultPassword = defaultPassword && !autoResume;
|
|
2
5
|
base = base.replaceAll("&", "&").replaceAll(String.fromCharCode(34), """).replaceAll("<", "<").replaceAll(">", ">");
|
|
3
6
|
return `<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
4
7
|
<title>AgentBot Terminal</title><link rel="stylesheet" href="${base}/assets/xterm.css"><link rel="stylesheet" href="${base}/assets/terminal.css">
|
|
5
8
|
<script defer src="${base}/assets/xterm.js"></script><script defer src="${base}/assets/fit.js"></script><script defer src="${base}/assets/terminal.js"></script></head>
|
|
6
|
-
<body data-base="${base}" data-recovery="${recovery}"><header><strong>AgentBot <span>Terminal</span></strong><div id="status" role="status">尚未连接</div><button id="connect">连接</button><button id="interrupt" disabled>Ctrl+C</button><button id="close" disabled>关闭终端</button></header>
|
|
7
|
-
<section id="welcome"><h1>连接终端</h1><p>此终端拥有 AgentBot 所在电脑的系统用户权限。</p><label for="password">终端密码</label><div class="password-row"><input id="password" type="password" autocomplete="current-password" maxlength="256" autofocus><button id="welcome-connect" type="button">连接</button></div></section><div id="terminal"></div>
|
|
8
|
-
|
|
9
|
+
<body data-base="${base}" data-recovery="${recovery}" data-resume="${autoResume}" data-default-password="${defaultPassword}"><header><strong>AgentBot <span>Terminal</span></strong><div id="status" role="status">尚未连接</div><button id="connect">连接</button><button id="interrupt" disabled>Ctrl+C</button><button id="close" title="前台连接不因空闲关闭;后台空闲或网页断开 30 分钟后关闭。重连重新计时,可从原会话的终端管理卡打开或关闭终端。" disabled>关闭终端</button></header>
|
|
10
|
+
<section id="welcome"><h1>连接终端</h1><p>此终端拥有 AgentBot 所在电脑的系统用户权限。</p><label for="password">终端密码</label><div class="password-row"><input id="password" type="password" autocomplete="current-password" maxlength="256" value="${defaultPassword ? DEFAULT_TERMINAL_PASSWORD : ""}" aria-describedby="password-hint" autofocus><button id="welcome-connect" type="button">连接</button></div><p id="password-hint">可在飞书 /setting → 高级 → 终端密码中修改默认密码。</p></section><div id="terminal"></div>
|
|
11
|
+
</body></html>`;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
export const TERMINAL_CSS = `
|
|
12
15
|
#welcome-connect{padding:10px 20px;font:inherit}
|
|
13
16
|
#welcome{width:100%}.password-row{display:flex;gap:12px;margin-top:8px;max-width:440px}#password{min-width:0;flex:1;background:#191f2b;border:1px solid #415775;border-radius:6px;padding:10px 12px;color:inherit;font:inherit}#password:focus{outline:2px solid #84c1ff;outline-offset:2px}
|
|
14
|
-
:root{color-scheme:dark;font:14px system-ui,sans-serif;background:#10141b;color:#dbe4f1}*{box-sizing:border-box}body{margin:0;height:100dvh;display:flex;flex-direction:column}header{display:flex;gap:12px;align-items:center;padding:12px 18px;background:#191f2b;border-bottom:1px solid #303a4d;flex-wrap:wrap}header strong{font-size:17px}header strong span{font-weight:400;color:#9aacc7}#status{flex:1;color:#adbfdb;font-size:13px}button{background:#25334a;border:1px solid #415775;border-radius:7px;padding:8px 12px;color:#e5efff;cursor:pointer}button:hover{background:#304661}button:disabled{opacity:.45;cursor:default}#close{border-color:#86505a}#welcome{margin:40px auto;max-width:780px;padding:0 24px;line-height:1.8}h1{font-size:25px}#terminal{flex:1;min-height:0;padding:12px 14px;display:none}.xterm{height:100%}
|
|
17
|
+
:root{color-scheme:dark;font:14px system-ui,sans-serif;background:#10141b;color:#dbe4f1}*{box-sizing:border-box}body{margin:0;height:100dvh;display:flex;flex-direction:column}header{display:flex;gap:12px;align-items:center;padding:12px 18px;background:#191f2b;border-bottom:1px solid #303a4d;flex-wrap:wrap}header strong{font-size:17px}header strong span{font-weight:400;color:#9aacc7}#status{flex:1;color:#adbfdb;font-size:13px}button{background:#25334a;border:1px solid #415775;border-radius:7px;padding:8px 12px;color:#e5efff;cursor:pointer}button:hover{background:#304661}button:disabled{opacity:.45;cursor:default}#close{border-color:#86505a}#welcome{margin:40px auto;max-width:780px;padding:0 24px;line-height:1.8}h1{font-size:25px}#terminal{flex:1;min-height:0;padding:12px 14px;display:none}.xterm{height:100%}body.connected #welcome{display:none}body.connected #terminal{display:block}
|
|
18
|
+
@media(max-width:650px){header{padding:4px 6px;gap:6px;flex-shrink:0}header strong{display:none}#status{flex:0 0 100%;min-width:0;font-size:12px;line-height:1.4;overflow-wrap:anywhere}#status:has(.terminal-directory){flex:1}.terminal-directory{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px}header button{flex-shrink:0;min-height:44px;padding:6px 8px;font-size:12px}#terminal{padding:6px}}
|
|
15
19
|
`;
|
|
16
20
|
|
|
17
21
|
export const TERMINAL_SCRIPT = String.raw`(() => {
|
|
@@ -24,8 +28,12 @@ export const TERMINAL_SCRIPT = String.raw`(() => {
|
|
|
24
28
|
const interrupt = document.getElementById('interrupt');
|
|
25
29
|
const storageKey = 'agentbot-terminal:' + location.pathname;
|
|
26
30
|
const recovery = document.body.dataset.recovery === 'true';
|
|
31
|
+
const autoResume = recovery && document.body.dataset.resume === 'true';
|
|
32
|
+
const defaultPassword = document.body.dataset.defaultPassword === 'true';
|
|
33
|
+
const initialPassword = password.value;
|
|
34
|
+
if (autoResume) document.getElementById('welcome').hidden = true;
|
|
27
35
|
if (recovery) document.querySelector('#welcome h1').textContent = '恢复已有终端';
|
|
28
|
-
let session, ws, term, observer, retryTimer, socketTimer, checking, visibilityTimer;
|
|
36
|
+
let session, ws, term, observer, retryTimer, socketTimer, checking, visibilityTimer, countdownTimer;
|
|
29
37
|
let socketReady = false;
|
|
30
38
|
let epoch = 0, failures = 0, stopped = false, pageHidden = false, offline = false, busy = false;
|
|
31
39
|
try { session = JSON.parse(sessionStorage.getItem(storageKey) || 'null'); } catch {}
|
|
@@ -57,12 +65,26 @@ export const TERMINAL_SCRIPT = String.raw`(() => {
|
|
|
57
65
|
password.disabled = busy;
|
|
58
66
|
}
|
|
59
67
|
function invalidate() {
|
|
68
|
+
cancelDefaultConnect();
|
|
60
69
|
epoch++; clearTimeout(retryTimer); clearTimeout(socketTimer);
|
|
61
70
|
clearTimeout(visibilityTimer); socketReady = false;
|
|
62
71
|
checking?.abort(); checking = undefined;
|
|
63
72
|
const old = ws; ws = undefined; old?.close(); interrupt.disabled = true;
|
|
64
73
|
if (term) term.options.disableStdin = true;
|
|
65
74
|
}
|
|
75
|
+
function cancelDefaultConnect() {
|
|
76
|
+
if (countdownTimer === undefined) return;
|
|
77
|
+
clearTimeout(countdownTimer); countdownTimer = undefined;
|
|
78
|
+
status.textContent = '已取消自动连接';
|
|
79
|
+
}
|
|
80
|
+
function countdown(seconds = 5) {
|
|
81
|
+
if (!awake() || busy || session || password.value !== initialPassword) { cancelDefaultConnect(); return; }
|
|
82
|
+
status.textContent = '使用默认密码,' + seconds + ' 秒后自动连接';
|
|
83
|
+
countdownTimer = setTimeout(() => {
|
|
84
|
+
if (!awake() || password.value !== initialPassword) { cancelDefaultConnect(); return; }
|
|
85
|
+
if (seconds === 1) connect.click(); else countdown(seconds - 1);
|
|
86
|
+
}, 1000);
|
|
87
|
+
}
|
|
66
88
|
function forget() {
|
|
67
89
|
session = undefined; sessionStorage.removeItem(storageKey);
|
|
68
90
|
buttons(true);
|
|
@@ -133,7 +155,10 @@ export const TERMINAL_SCRIPT = String.raw`(() => {
|
|
|
133
155
|
const restored = () => {
|
|
134
156
|
if (!active()) return;
|
|
135
157
|
terminal.options.disableStdin = false; terminal.focus();
|
|
136
|
-
status.textContent = '已连接 · '
|
|
158
|
+
status.textContent = '已连接 · ';
|
|
159
|
+
const directory = document.createElement('span');
|
|
160
|
+
directory.className = 'terminal-directory'; directory.textContent = result.cwd; directory.title = result.cwd;
|
|
161
|
+
status.append(directory); interrupt.disabled = false; buttons();
|
|
137
162
|
};
|
|
138
163
|
// xterm parses asynchronously. Keep replay silent until its write callback,
|
|
139
164
|
// before subsequently queued live output is parsed. Startup output is live.
|
|
@@ -174,23 +199,25 @@ export const TERMINAL_SCRIPT = String.raw`(() => {
|
|
|
174
199
|
stopped = false; failures = 0; invalidate();
|
|
175
200
|
if (session) { status.textContent = '正在恢复已有终端授权…'; buttons(); check(); return; }
|
|
176
201
|
document.body.classList.remove('connected');
|
|
177
|
-
if (!password.value) { status.textContent = '请输入终端密码'; password.focus(); return; }
|
|
178
|
-
busy = true; buttons(); status.textContent = '正在验证密码…';
|
|
202
|
+
if (!autoResume && !password.value) { status.textContent = '请输入终端密码'; password.focus(); return; }
|
|
203
|
+
busy = true; buttons(); status.textContent = autoResume ? '正在恢复原终端…' : '正在验证密码…';
|
|
179
204
|
try {
|
|
180
205
|
if (!globalThis.crypto?.getRandomValues) throw new Error('浏览器不支持安全随机数,请使用新版浏览器。');
|
|
181
206
|
const browserKey = Array.from(crypto.getRandomValues(new Uint8Array(32)), (n) => n.toString(16).padStart(2,'0')).join('');
|
|
182
|
-
const result = await post('request', {launch:location.pathname,browserKey,password:password.value});
|
|
207
|
+
const result = await post('request', {launch:location.pathname,browserKey,password:autoResume ? undefined : password.value});
|
|
183
208
|
password.value = '';
|
|
184
209
|
session = {requestId:result.requestId,browserKey}; sessionStorage.setItem(storageKey,JSON.stringify(session));
|
|
185
|
-
status.textContent = '密码已验证,正在连接终端…';
|
|
210
|
+
status.textContent = autoResume ? '正在恢复原终端…' : '密码已验证,正在连接终端…';
|
|
186
211
|
} catch (error) { status.textContent = '连接失败:' + message(error); password.focus(); }
|
|
187
212
|
finally { busy = false; buttons(!session); }
|
|
188
213
|
check();
|
|
189
214
|
};
|
|
190
215
|
password.addEventListener('keydown', (event) => { if (event.key === 'Enter') { event.preventDefault(); welcomeConnect.click(); } });
|
|
216
|
+
password.addEventListener('input', cancelDefaultConnect);
|
|
217
|
+
password.addEventListener('change', cancelDefaultConnect);
|
|
191
218
|
interrupt.onclick = () => { if (ws?.readyState === WebSocket.OPEN && !interrupt.disabled) ws.send(JSON.stringify({type:'input',data:String.fromCharCode(3)})); };
|
|
192
219
|
close.onclick = async () => {
|
|
193
|
-
if (busy || !session || !confirm('关闭该终端和 Shell
|
|
220
|
+
if (busy || !session || !confirm('关闭该终端和 Shell?\n' + close.title + '\n已脱离终端的后台进程可能继续运行。')) return;
|
|
194
221
|
busy = true; stopped = true; invalidate(); buttons();
|
|
195
222
|
try { await post('close',session); end('终端已关闭'); }
|
|
196
223
|
catch (error) {
|
|
@@ -212,5 +239,8 @@ export const TERMINAL_SCRIPT = String.raw`(() => {
|
|
|
212
239
|
window.addEventListener('offline', () => { offline = true; suspend(); });
|
|
213
240
|
window.addEventListener('online', () => { offline = false; resume(); });
|
|
214
241
|
window.addEventListener('focus', resume);
|
|
215
|
-
buttons();
|
|
242
|
+
buttons();
|
|
243
|
+
if (!session && autoResume) connect.click();
|
|
244
|
+
else if (!session && defaultPassword) countdown();
|
|
245
|
+
else check();
|
|
216
246
|
})();`;
|