agent-yes 1.99.0 → 1.100.0
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/SUPPORTED_CLIS-C-cenkTG.js +8 -0
- package/dist/{SUPPORTED_CLIS-eIjVu8HF.js → SUPPORTED_CLIS-DIHMEdRx.js} +2 -2
- package/dist/cli.js +3 -3
- package/dist/index.js +2 -2
- package/dist/{serve-SQYFRbm3.js → serve-C4fZSjh9.js} +5 -5
- package/dist/{subcommands-z8Y8gcD_.js → subcommands-BKY3nQV4.js} +2 -2
- package/dist/{subcommands-D3Z9cD9u.js → subcommands-dnjUZ9nY.js} +1 -1
- package/dist/{ts-BECoCPV1.js → ts-CUn393DD.js} +2 -2
- package/dist/{versionChecker-pct2j3wR.js → versionChecker-BWdncsn6.js} +2 -2
- package/lab/ui/index.html +154 -99
- package/lab/ui/room-client.js +247 -229
- package/package.json +1 -1
- package/dist/SUPPORTED_CLIS-BGUPuqya.js +0 -8
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "./ts-CUn393DD.js";
|
|
2
|
+
import "./logger-B9h0djqx.js";
|
|
3
|
+
import "./versionChecker-BWdncsn6.js";
|
|
4
|
+
import "./pidStore-DBjlqzo8.js";
|
|
5
|
+
import "./globalPidIndex-yVd3mbsV.js";
|
|
6
|
+
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-DIHMEdRx.js";
|
|
7
|
+
|
|
8
|
+
export { SUPPORTED_CLIS };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as CLIS_CONFIG } from "./ts-
|
|
1
|
+
import { t as CLIS_CONFIG } from "./ts-CUn393DD.js";
|
|
2
2
|
|
|
3
3
|
//#region ts/SUPPORTED_CLIS.ts
|
|
4
4
|
const SUPPORTED_CLIS = Object.keys(CLIS_CONFIG);
|
|
5
5
|
|
|
6
6
|
//#endregion
|
|
7
7
|
export { SUPPORTED_CLIS as t };
|
|
8
|
-
//# sourceMappingURL=SUPPORTED_CLIS-
|
|
8
|
+
//# sourceMappingURL=SUPPORTED_CLIS-DIHMEdRx.js.map
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { n as logger } from "./logger-B9h0djqx.js";
|
|
3
|
-
import { i as versionString, n as displayVersion, r as getInstalledPackage, t as checkAndAutoUpdate } from "./versionChecker-
|
|
3
|
+
import { i as versionString, n as displayVersion, r as getInstalledPackage, t as checkAndAutoUpdate } from "./versionChecker-BWdncsn6.js";
|
|
4
4
|
import { argv } from "process";
|
|
5
5
|
import { execFileSync, spawn } from "child_process";
|
|
6
6
|
import ms from "ms";
|
|
@@ -482,7 +482,7 @@ function buildRustArgs(argv, cliFromScript, supportedClis) {
|
|
|
482
482
|
{
|
|
483
483
|
const rawArg = process.argv[2];
|
|
484
484
|
const isHelpFlag = rawArg === "-h" || rawArg === "--help";
|
|
485
|
-
const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-
|
|
485
|
+
const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-dnjUZ9nY.js");
|
|
486
486
|
if (isHelpFlag && process.argv.length === 3) {
|
|
487
487
|
cmdHelp();
|
|
488
488
|
process.exit(0);
|
|
@@ -515,7 +515,7 @@ if (config.useRust) {
|
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
517
|
if (rustBinary) {
|
|
518
|
-
const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-
|
|
518
|
+
const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-C-cenkTG.js");
|
|
519
519
|
const rustArgs = buildRustArgs(process.argv, config.cli, SUPPORTED_CLIS);
|
|
520
520
|
if (config.verbose) {
|
|
521
521
|
console.log(`[rust] Using binary: ${rustBinary}`);
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts-
|
|
1
|
+
import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts-CUn393DD.js";
|
|
2
2
|
import "./logger-B9h0djqx.js";
|
|
3
|
-
import "./versionChecker-
|
|
3
|
+
import "./versionChecker-BWdncsn6.js";
|
|
4
4
|
import "./pidStore-DBjlqzo8.js";
|
|
5
5
|
import "./globalPidIndex-yVd3mbsV.js";
|
|
6
6
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import "./ts-
|
|
1
|
+
import "./ts-CUn393DD.js";
|
|
2
2
|
import "./logger-B9h0djqx.js";
|
|
3
|
-
import "./versionChecker-
|
|
3
|
+
import "./versionChecker-BWdncsn6.js";
|
|
4
4
|
import "./pidStore-DBjlqzo8.js";
|
|
5
5
|
import "./globalPidIndex-yVd3mbsV.js";
|
|
6
|
-
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-
|
|
6
|
+
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-DIHMEdRx.js";
|
|
7
7
|
import "./remotes-C3xPRtfg.js";
|
|
8
|
-
import { c as readNotes, f as snapshotStatus, l as renderRawLog, m as writeToIpc, o as listRecords, r as controlCodeFromName, u as resolveOne } from "./subcommands-
|
|
8
|
+
import { c as readNotes, f as snapshotStatus, l as renderRawLog, m as writeToIpc, o as listRecords, r as controlCodeFromName, u as resolveOne } from "./subcommands-BKY3nQV4.js";
|
|
9
9
|
import yargs from "yargs";
|
|
10
10
|
import { mkdir, open, readFile, writeFile } from "fs/promises";
|
|
11
11
|
import { homedir } from "os";
|
|
@@ -551,4 +551,4 @@ Options:
|
|
|
551
551
|
|
|
552
552
|
//#endregion
|
|
553
553
|
export { cmdServe };
|
|
554
|
-
//# sourceMappingURL=serve-
|
|
554
|
+
//# sourceMappingURL=serve-C4fZSjh9.js.map
|
|
@@ -163,7 +163,7 @@ async function runSubcommand(argv) {
|
|
|
163
163
|
case "restart": return await cmdRestart(rest);
|
|
164
164
|
case "note": return await cmdNote(rest);
|
|
165
165
|
case "serve": {
|
|
166
|
-
const { cmdServe } = await import("./serve-
|
|
166
|
+
const { cmdServe } = await import("./serve-C4fZSjh9.js");
|
|
167
167
|
return cmdServe(rest);
|
|
168
168
|
}
|
|
169
169
|
case "setup": {
|
|
@@ -1452,4 +1452,4 @@ async function cmdStatus(rest) {
|
|
|
1452
1452
|
|
|
1453
1453
|
//#endregion
|
|
1454
1454
|
export { isSubcommand as a, readNotes as c, runSubcommand as d, snapshotStatus as f, isPidAlive as i, renderRawLog as l, writeToIpc as m, cmdHelp as n, listRecords as o, stopTipForCli as p, controlCodeFromName as r, matchKeyword as s, GRACEFUL_EXIT_COMMANDS as t, resolveOne as u };
|
|
1455
|
-
//# sourceMappingURL=subcommands-
|
|
1455
|
+
//# sourceMappingURL=subcommands-BKY3nQV4.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./logger-B9h0djqx.js";
|
|
2
2
|
import "./globalPidIndex-yVd3mbsV.js";
|
|
3
3
|
import "./remotes-C3xPRtfg.js";
|
|
4
|
-
import { a as isSubcommand, c as readNotes, d as runSubcommand, f as snapshotStatus, i as isPidAlive, l as renderRawLog, m as writeToIpc, n as cmdHelp, o as listRecords, p as stopTipForCli, r as controlCodeFromName, s as matchKeyword, t as GRACEFUL_EXIT_COMMANDS, u as resolveOne } from "./subcommands-
|
|
4
|
+
import { a as isSubcommand, c as readNotes, d as runSubcommand, f as snapshotStatus, i as isPidAlive, l as renderRawLog, m as writeToIpc, n as cmdHelp, o as listRecords, p as stopTipForCli, r as controlCodeFromName, s as matchKeyword, t as GRACEFUL_EXIT_COMMANDS, u as resolveOne } from "./subcommands-BKY3nQV4.js";
|
|
5
5
|
|
|
6
6
|
export { cmdHelp, isSubcommand, runSubcommand };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as logger, t as addTransport } from "./logger-B9h0djqx.js";
|
|
2
|
-
import { r as getInstalledPackage } from "./versionChecker-
|
|
2
|
+
import { r as getInstalledPackage } from "./versionChecker-BWdncsn6.js";
|
|
3
3
|
import { n as agentYesHome, t as PidStore } from "./pidStore-DBjlqzo8.js";
|
|
4
4
|
import { i as shouldUseLock, r as releaseLock, t as acquireLock } from "./runningLock-CJxsoGdb.js";
|
|
5
5
|
import { i as readGlobalPids } from "./globalPidIndex-yVd3mbsV.js";
|
|
@@ -1714,4 +1714,4 @@ function sleep(ms) {
|
|
|
1714
1714
|
|
|
1715
1715
|
//#endregion
|
|
1716
1716
|
export { removeControlCharacters as a, AgentContext as i, agentYes as n, config as r, CLIS_CONFIG as t };
|
|
1717
|
-
//# sourceMappingURL=ts-
|
|
1717
|
+
//# sourceMappingURL=ts-CUn393DD.js.map
|
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from "url";
|
|
|
7
7
|
|
|
8
8
|
//#region package.json
|
|
9
9
|
var name = "agent-yes";
|
|
10
|
-
var version = "1.
|
|
10
|
+
var version = "1.100.0";
|
|
11
11
|
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region ts/versionChecker.ts
|
|
@@ -221,4 +221,4 @@ async function displayVersion() {
|
|
|
221
221
|
|
|
222
222
|
//#endregion
|
|
223
223
|
export { versionString as i, displayVersion as n, getInstalledPackage as r, checkAndAutoUpdate as t };
|
|
224
|
-
//# sourceMappingURL=versionChecker-
|
|
224
|
+
//# sourceMappingURL=versionChecker-BWdncsn6.js.map
|
package/lab/ui/index.html
CHANGED
|
@@ -52,14 +52,34 @@
|
|
|
52
52
|
flex children actually shrink — without it overflow:auto never engages). */
|
|
53
53
|
.app {
|
|
54
54
|
display: grid;
|
|
55
|
-
grid-template-columns:
|
|
55
|
+
grid-template-columns: var(--leftw, 42%) 1px 1fr;
|
|
56
56
|
grid-template-rows: minmax(0, 1fr);
|
|
57
57
|
height: 100vh;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/* VSCode-style splitter: the visible divider stays 1px, but a ::before
|
|
61
|
+
overlay widens the pointer hit area to ~11px so it's easy to grab. */
|
|
62
|
+
.splitter {
|
|
63
|
+
position: relative;
|
|
64
|
+
background: var(--line);
|
|
65
|
+
cursor: col-resize;
|
|
66
|
+
z-index: 5;
|
|
67
|
+
}
|
|
68
|
+
.splitter::before {
|
|
69
|
+
content: "";
|
|
70
|
+
position: absolute;
|
|
71
|
+
top: 0;
|
|
72
|
+
bottom: 0;
|
|
73
|
+
left: -5px;
|
|
74
|
+
right: -5px;
|
|
75
|
+
}
|
|
76
|
+
.splitter:hover,
|
|
77
|
+
.splitter.drag {
|
|
78
|
+
background: var(--accent);
|
|
79
|
+
}
|
|
80
|
+
|
|
60
81
|
/* ---- left: list ---- */
|
|
61
82
|
.left {
|
|
62
|
-
border-right: 1px solid var(--line);
|
|
63
83
|
display: flex;
|
|
64
84
|
flex-direction: column;
|
|
65
85
|
min-width: 0;
|
|
@@ -453,8 +473,15 @@
|
|
|
453
473
|
gap: 8px;
|
|
454
474
|
padding: 6px 18px;
|
|
455
475
|
}
|
|
476
|
+
.crow .cident {
|
|
477
|
+
font-family: var(--mono);
|
|
478
|
+
font-size: 11.5px;
|
|
479
|
+
color: var(--green);
|
|
480
|
+
flex: none;
|
|
481
|
+
}
|
|
456
482
|
.crow .cname {
|
|
457
483
|
font-weight: 600;
|
|
484
|
+
color: var(--purple);
|
|
458
485
|
flex: none;
|
|
459
486
|
}
|
|
460
487
|
.crow .ctitle {
|
|
@@ -553,50 +580,6 @@
|
|
|
553
580
|
color: var(--muted);
|
|
554
581
|
font-size: 14px;
|
|
555
582
|
}
|
|
556
|
-
.composer {
|
|
557
|
-
border-top: 1px solid var(--line);
|
|
558
|
-
padding: 12px 16px;
|
|
559
|
-
display: flex;
|
|
560
|
-
gap: 8px;
|
|
561
|
-
align-items: flex-end;
|
|
562
|
-
}
|
|
563
|
-
.composer textarea {
|
|
564
|
-
flex: 1;
|
|
565
|
-
resize: none;
|
|
566
|
-
background: var(--panel);
|
|
567
|
-
border: 1px solid var(--line);
|
|
568
|
-
border-radius: 9px;
|
|
569
|
-
color: var(--fg);
|
|
570
|
-
font: 13px var(--mono);
|
|
571
|
-
padding: 9px 12px;
|
|
572
|
-
outline: 0;
|
|
573
|
-
min-height: 40px;
|
|
574
|
-
max-height: 160px;
|
|
575
|
-
}
|
|
576
|
-
.composer textarea:focus {
|
|
577
|
-
border-color: var(--accent);
|
|
578
|
-
}
|
|
579
|
-
.send {
|
|
580
|
-
background: var(--accent);
|
|
581
|
-
color: var(--bg);
|
|
582
|
-
border: 0;
|
|
583
|
-
border-radius: 9px;
|
|
584
|
-
font-weight: 600;
|
|
585
|
-
padding: 10px 18px;
|
|
586
|
-
cursor: pointer;
|
|
587
|
-
font-size: 13px;
|
|
588
|
-
}
|
|
589
|
-
.send:disabled {
|
|
590
|
-
opacity: 0.45;
|
|
591
|
-
cursor: not-allowed;
|
|
592
|
-
}
|
|
593
|
-
.hint {
|
|
594
|
-
color: var(--muted);
|
|
595
|
-
font-size: 11px;
|
|
596
|
-
font-family: var(--mono);
|
|
597
|
-
margin-top: 6px;
|
|
598
|
-
padding: 0 16px 10px;
|
|
599
|
-
}
|
|
600
583
|
</style>
|
|
601
584
|
<link
|
|
602
585
|
rel="stylesheet"
|
|
@@ -645,6 +628,8 @@
|
|
|
645
628
|
<div class="list" id="list"></div>
|
|
646
629
|
</div>
|
|
647
630
|
|
|
631
|
+
<div class="splitter" id="splitter" title="drag to resize"></div>
|
|
632
|
+
|
|
648
633
|
<div class="right">
|
|
649
634
|
<div class="rhead" id="rhead" style="display: none">
|
|
650
635
|
<span class="dot" id="rdot"></span>
|
|
@@ -655,18 +640,9 @@
|
|
|
655
640
|
>
|
|
656
641
|
</div>
|
|
657
642
|
<div class="log" id="log">
|
|
658
|
-
<div class="placeholder"
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
<textarea
|
|
662
|
-
id="msg"
|
|
663
|
-
rows="1"
|
|
664
|
-
placeholder="message to send to the agent… (⌘/Ctrl+Enter)"
|
|
665
|
-
></textarea>
|
|
666
|
-
<button class="send" id="send">Send ⏎</button>
|
|
667
|
-
</div>
|
|
668
|
-
<div class="hint" id="hint" style="display: none">
|
|
669
|
-
POST /api/send → writes to the agent's stdin fifo, then Enter.
|
|
643
|
+
<div class="placeholder">
|
|
644
|
+
← pick an agent to tail its log; type directly into the terminal
|
|
645
|
+
</div>
|
|
670
646
|
</div>
|
|
671
647
|
</div>
|
|
672
648
|
</div>
|
|
@@ -1008,14 +984,32 @@
|
|
|
1008
984
|
},
|
|
1009
985
|
};
|
|
1010
986
|
|
|
987
|
+
// claude is the default CLI — show the cli name only when it differs, so the
|
|
988
|
+
// common case stays uncluttered and the identity (repo/branch) leads instead.
|
|
989
|
+
const cliLabel = (e) => (e.cli && e.cli !== "claude" ? e.cli : "");
|
|
990
|
+
// Parse owner/repo/branch from a cwd like .../ws/<owner>/<repo>/tree/<branch>.
|
|
991
|
+
function repoBranch(e) {
|
|
992
|
+
const m = /\/([^/]+)\/([^/]+)\/tree\/([^/]+)/.exec(e.cwd || "");
|
|
993
|
+
return m ? { owner: m[1], repo: m[2], branch: m[3] } : null;
|
|
994
|
+
}
|
|
995
|
+
// Identity string for the left panel. cap=true → repo/branch each clipped to
|
|
996
|
+
// 3 chars for the compact one-line view (e.g. "age/mai").
|
|
997
|
+
function ident(e, cap) {
|
|
998
|
+
const rb = repoBranch(e);
|
|
999
|
+
if (!rb) return "";
|
|
1000
|
+
const c = (s) => (cap && s.length > 3 ? s.slice(0, 3) : s);
|
|
1001
|
+
return `${c(rb.repo)}/${c(rb.branch)}`;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1011
1004
|
// Derive codehost-style mnemonic tags from a cwd like .../ws/<owner>/<repo>/tree/<wt>
|
|
1012
1005
|
function tagsFor(e) {
|
|
1013
1006
|
const t = [];
|
|
1014
|
-
const
|
|
1015
|
-
if (
|
|
1016
|
-
t.push(["repo", `${
|
|
1007
|
+
const rb = repoBranch(e);
|
|
1008
|
+
if (rb) {
|
|
1009
|
+
t.push(["repo", `${rb.owner}/${rb.repo}`], ["wt", rb.branch]);
|
|
1017
1010
|
}
|
|
1018
|
-
|
|
1011
|
+
const cli = cliLabel(e);
|
|
1012
|
+
if (cli) t.push(["cli", cli]);
|
|
1019
1013
|
if (e._host) t.push(["host", e._host]); // codehost rooms: which machine
|
|
1020
1014
|
return t;
|
|
1021
1015
|
}
|
|
@@ -1063,9 +1057,12 @@
|
|
|
1063
1057
|
shown
|
|
1064
1058
|
.map((e) => {
|
|
1065
1059
|
const t = e.title || e.prompt || "";
|
|
1060
|
+
const id = ident(e, true);
|
|
1061
|
+
const cli = cliLabel(e);
|
|
1066
1062
|
return `<div class="row crow ${String(e.pid) === sel ? "sel" : ""}" data-pid="${e.pid}">
|
|
1067
1063
|
<span class="dot ${esc(e.status)}"></span>
|
|
1068
|
-
|
|
1064
|
+
${id ? `<span class="cident" title="${esc(ident(e))}">${esc(id)}</span>` : ""}
|
|
1065
|
+
${cli ? `<span class="cname">${esc(cli)}</span>` : ""}
|
|
1069
1066
|
<span class="ctitle ${e.title ? "" : "dim"}" title="${esc(t)}">${esc(t)}</span>
|
|
1070
1067
|
<span class="age">${age(e)}</span></div>`;
|
|
1071
1068
|
})
|
|
@@ -1083,7 +1080,7 @@
|
|
|
1083
1080
|
.join("");
|
|
1084
1081
|
return `<div class="row ${String(e.pid) === sel ? "sel" : ""}" data-pid="${e.pid}">
|
|
1085
1082
|
<div class="r1"><span class="dot ${esc(e.status)}"></span>
|
|
1086
|
-
<span class="name">${esc(e
|
|
1083
|
+
<span class="name">${esc(cliLabel(e) || ident(e) || "agent")}</span>
|
|
1087
1084
|
<span class="badge">pid ${e.pid}</span>
|
|
1088
1085
|
<span class="age">${age(e)}</span></div>
|
|
1089
1086
|
${e.title ? `<div class="rowtitle" title="${esc(e.title)}">${esc(e.title)}</div>` : ""}
|
|
@@ -1123,12 +1120,9 @@
|
|
|
1123
1120
|
if (!e) return;
|
|
1124
1121
|
renderList();
|
|
1125
1122
|
$("rhead").style.display = "flex";
|
|
1126
|
-
$("composer").style.display = "flex";
|
|
1127
|
-
$("hint").style.display = "block";
|
|
1128
1123
|
$("rdot").className = "dot " + e.status;
|
|
1129
|
-
$("rname").textContent = e.title || e
|
|
1124
|
+
$("rname").textContent = e.title || cliLabel(e) || ident(e) || "agent";
|
|
1130
1125
|
$("rpid").textContent = "pid " + e.pid;
|
|
1131
|
-
$("msg").focus();
|
|
1132
1126
|
|
|
1133
1127
|
// Render the agent's native TUI with xterm.js by feeding it the raw PTY
|
|
1134
1128
|
// stream (ANSI/cursor control intact) — see /api/tail?raw=1.
|
|
@@ -1151,6 +1145,7 @@
|
|
|
1151
1145
|
fit = new FitAddon.FitAddon();
|
|
1152
1146
|
term.loadAddon(fit);
|
|
1153
1147
|
term.open(logEl);
|
|
1148
|
+
term.focus();
|
|
1154
1149
|
// An agent can rename itself by emitting an OSC 0/2 title sequence
|
|
1155
1150
|
// (\x1b]2;my-name\x07); xterm parses it out of the raw PTY stream we already
|
|
1156
1151
|
// feed it, so we just surface the latest title as the header name. Falls
|
|
@@ -1226,24 +1221,6 @@
|
|
|
1226
1221
|
es = { close };
|
|
1227
1222
|
}
|
|
1228
1223
|
|
|
1229
|
-
async function send() {
|
|
1230
|
-
if (!sel) return;
|
|
1231
|
-
const msg = $("msg").value;
|
|
1232
|
-
if (!msg.trim()) return;
|
|
1233
|
-
$("send").disabled = true;
|
|
1234
|
-
try {
|
|
1235
|
-
const r = await Conn.post("/api/send", { keyword: sel, msg, code: "enter" });
|
|
1236
|
-
if (r.ok) {
|
|
1237
|
-
$("msg").value = "";
|
|
1238
|
-
} else {
|
|
1239
|
-
alert("send failed: " + r.text);
|
|
1240
|
-
}
|
|
1241
|
-
} finally {
|
|
1242
|
-
$("send").disabled = false;
|
|
1243
|
-
$("msg").focus();
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
1224
|
$("list").addEventListener("click", (ev) => {
|
|
1248
1225
|
const row = ev.target.closest(".row");
|
|
1249
1226
|
if (row) select(row.dataset.pid);
|
|
@@ -1260,13 +1237,6 @@
|
|
|
1260
1237
|
fit.fit();
|
|
1261
1238
|
} catch {}
|
|
1262
1239
|
});
|
|
1263
|
-
$("send").addEventListener("click", send);
|
|
1264
|
-
$("msg").addEventListener("keydown", (ev) => {
|
|
1265
|
-
if (ev.key === "Enter" && (ev.metaKey || ev.ctrlKey)) {
|
|
1266
|
-
ev.preventDefault();
|
|
1267
|
-
send();
|
|
1268
|
-
}
|
|
1269
|
-
});
|
|
1270
1240
|
|
|
1271
1241
|
// ---- rooms: localStorage cache + a manager you open by clicking the badge ----
|
|
1272
1242
|
const ROOMS_KEY = "ay.rooms";
|
|
@@ -1572,8 +1542,7 @@
|
|
|
1572
1542
|
history.replaceState(null, document.title, location.pathname + location.search); // eat launch params
|
|
1573
1543
|
if (spec) showLaunch(spec);
|
|
1574
1544
|
setConn("● local", "var(--muted)");
|
|
1575
|
-
|
|
1576
|
-
setInterval(loadList, 3000);
|
|
1545
|
+
startPolling();
|
|
1577
1546
|
return;
|
|
1578
1547
|
}
|
|
1579
1548
|
// #k=<token> — local-mode auth from `ay serve --http`'s printed link.
|
|
@@ -1585,8 +1554,7 @@
|
|
|
1585
1554
|
// SECURITY: strip the token from the URL immediately.
|
|
1586
1555
|
history.replaceState(null, document.title, location.pathname + location.search);
|
|
1587
1556
|
setConn("● local", "var(--muted)");
|
|
1588
|
-
|
|
1589
|
-
setInterval(loadList, 3000);
|
|
1557
|
+
startPolling();
|
|
1590
1558
|
return;
|
|
1591
1559
|
}
|
|
1592
1560
|
const h = decodeURIComponent(raw);
|
|
@@ -1635,10 +1603,97 @@
|
|
|
1635
1603
|
// Render the UI immediately and refresh on a timer; connect to a room (if
|
|
1636
1604
|
// any) in the BACKGROUND so a dead/slow cached room never blanks the page.
|
|
1637
1605
|
if (!pending) setConn("● local", "var(--muted)");
|
|
1638
|
-
|
|
1639
|
-
setInterval(loadList, 3000); // refresh statuses / new agents
|
|
1606
|
+
startPolling();
|
|
1640
1607
|
if (pending) connectRoom(pending.room, pending.token, pending.host);
|
|
1641
1608
|
}
|
|
1609
|
+
|
|
1610
|
+
// ---- activity-gated polling + auto-reload on new deploy ----------------
|
|
1611
|
+
// Poll the agent list while the page is actually in use; pause when the tab
|
|
1612
|
+
// is hidden or the user has been idle for IDLE_MS, so an unattended console
|
|
1613
|
+
// stops making requests. On returning to the tab we refresh immediately.
|
|
1614
|
+
let lastActivity = Date.now();
|
|
1615
|
+
const IDLE_MS = 60_000; // no interaction for 1 min → idle → stop polling
|
|
1616
|
+
["mousemove", "keydown", "pointerdown", "wheel", "touchstart"].forEach((ev) =>
|
|
1617
|
+
window.addEventListener(ev, () => (lastActivity = Date.now()), { passive: true }),
|
|
1618
|
+
);
|
|
1619
|
+
const isActive = () =>
|
|
1620
|
+
document.visibilityState === "visible" && Date.now() - lastActivity < IDLE_MS;
|
|
1621
|
+
|
|
1622
|
+
let polling = false;
|
|
1623
|
+
function startPolling() {
|
|
1624
|
+
if (polling) return;
|
|
1625
|
+
polling = true;
|
|
1626
|
+
loadList();
|
|
1627
|
+
setInterval(() => {
|
|
1628
|
+
if (isActive()) loadList();
|
|
1629
|
+
}, 3000); // refresh statuses / new agents — only while active
|
|
1630
|
+
document.addEventListener("visibilitychange", () => {
|
|
1631
|
+
if (document.visibilityState === "visible") {
|
|
1632
|
+
lastActivity = Date.now();
|
|
1633
|
+
loadList();
|
|
1634
|
+
}
|
|
1635
|
+
});
|
|
1636
|
+
watchVersion();
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
// Auto-reload when the console's own assets change (a new deploy). HEAD the
|
|
1640
|
+
// page once a minute and compare the cache validator; reload on change.
|
|
1641
|
+
// Best-effort — ignores failures (e.g. remote rooms / cross-origin).
|
|
1642
|
+
function watchVersion() {
|
|
1643
|
+
let seen = null;
|
|
1644
|
+
const check = async () => {
|
|
1645
|
+
if (!isActive()) return;
|
|
1646
|
+
try {
|
|
1647
|
+
const r = await fetch(location.pathname, { method: "HEAD", cache: "no-store" });
|
|
1648
|
+
const tag = r.headers.get("etag") || r.headers.get("last-modified");
|
|
1649
|
+
if (!tag) return;
|
|
1650
|
+
if (seen && seen !== tag) return location.reload();
|
|
1651
|
+
seen = tag;
|
|
1652
|
+
} catch {}
|
|
1653
|
+
};
|
|
1654
|
+
check();
|
|
1655
|
+
setInterval(check, 60_000);
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
// ---- draggable middle splitter (VSCode-style) -------------------------
|
|
1659
|
+
// Drag adjusts the left column width (a CSS var on .app), clamped so neither
|
|
1660
|
+
// pane collapses, persisted per device, and refits the terminal as it moves.
|
|
1661
|
+
(function () {
|
|
1662
|
+
const sp = $("splitter");
|
|
1663
|
+
const app = document.querySelector(".app");
|
|
1664
|
+
const saved = localStorage.getItem("ay.leftw");
|
|
1665
|
+
if (saved) app.style.setProperty("--leftw", saved);
|
|
1666
|
+
let dragging = false;
|
|
1667
|
+
sp.addEventListener("pointerdown", (e) => {
|
|
1668
|
+
dragging = true;
|
|
1669
|
+
sp.classList.add("drag");
|
|
1670
|
+
sp.setPointerCapture(e.pointerId);
|
|
1671
|
+
e.preventDefault();
|
|
1672
|
+
});
|
|
1673
|
+
sp.addEventListener("pointermove", (e) => {
|
|
1674
|
+
if (!dragging) return;
|
|
1675
|
+
const w = Math.min(Math.max(e.clientX, 280), window.innerWidth - 360);
|
|
1676
|
+
app.style.setProperty("--leftw", w + "px");
|
|
1677
|
+
if (fit)
|
|
1678
|
+
try {
|
|
1679
|
+
fit.fit();
|
|
1680
|
+
} catch {}
|
|
1681
|
+
});
|
|
1682
|
+
const end = (e) => {
|
|
1683
|
+
if (!dragging) return;
|
|
1684
|
+
dragging = false;
|
|
1685
|
+
sp.classList.remove("drag");
|
|
1686
|
+
try {
|
|
1687
|
+
sp.releasePointerCapture(e.pointerId);
|
|
1688
|
+
} catch {}
|
|
1689
|
+
localStorage.setItem(
|
|
1690
|
+
"ay.leftw",
|
|
1691
|
+
getComputedStyle(app).getPropertyValue("--leftw").trim(),
|
|
1692
|
+
);
|
|
1693
|
+
};
|
|
1694
|
+
sp.addEventListener("pointerup", end);
|
|
1695
|
+
sp.addEventListener("pointercancel", end);
|
|
1696
|
+
})();
|
|
1642
1697
|
boot();
|
|
1643
1698
|
</script>
|
|
1644
1699
|
</body>
|
package/lab/ui/room-client.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
function
|
|
1
|
+
function k() {
|
|
2
2
|
return crypto.randomUUID();
|
|
3
3
|
}
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class
|
|
4
|
+
var g = 60000,
|
|
5
|
+
u = 1e4,
|
|
6
|
+
L = 1000,
|
|
7
|
+
b = 120000,
|
|
8
|
+
O = 25000;
|
|
9
|
+
class j {
|
|
10
10
|
opts;
|
|
11
11
|
peerId;
|
|
12
12
|
ws = null;
|
|
13
13
|
closed = !1;
|
|
14
|
-
reconnectDelay =
|
|
14
|
+
reconnectDelay = L;
|
|
15
15
|
reconnectTimer = null;
|
|
16
16
|
dormant = !1;
|
|
17
17
|
heartbeat = null;
|
|
@@ -19,7 +19,7 @@ class H {
|
|
|
19
19
|
openedAt = 0;
|
|
20
20
|
constructor(z) {
|
|
21
21
|
this.opts = z;
|
|
22
|
-
this.peerId = z.peerId ??
|
|
22
|
+
this.peerId = z.peerId ?? k();
|
|
23
23
|
}
|
|
24
24
|
connect() {
|
|
25
25
|
((this.closed = !1), this.attachWakeListeners(), this.open());
|
|
@@ -42,13 +42,13 @@ class H {
|
|
|
42
42
|
}
|
|
43
43
|
attachWakeListeners() {
|
|
44
44
|
globalThis.document?.addEventListener("visibilitychange", this.onWake);
|
|
45
|
-
let
|
|
46
|
-
(
|
|
45
|
+
let Q = globalThis.window;
|
|
46
|
+
(Q?.addEventListener("focus", this.onWake), Q?.addEventListener("online", this.onWake));
|
|
47
47
|
}
|
|
48
48
|
detachWakeListeners() {
|
|
49
49
|
globalThis.document?.removeEventListener("visibilitychange", this.onWake);
|
|
50
|
-
let
|
|
51
|
-
(
|
|
50
|
+
let Q = globalThis.window;
|
|
51
|
+
(Q?.removeEventListener("focus", this.onWake), Q?.removeEventListener("online", this.onWake));
|
|
52
52
|
}
|
|
53
53
|
roomUrl() {
|
|
54
54
|
return `${this.opts.url.replace(/\/+$/, "")}/room/${encodeURIComponent(this.opts.token)}`;
|
|
@@ -56,43 +56,43 @@ class H {
|
|
|
56
56
|
open() {
|
|
57
57
|
let z = new WebSocket(this.roomUrl());
|
|
58
58
|
this.ws = z;
|
|
59
|
-
let
|
|
59
|
+
let Q = setTimeout(() => {
|
|
60
60
|
if (z.readyState === 0)
|
|
61
61
|
try {
|
|
62
62
|
z.close();
|
|
63
63
|
} catch {}
|
|
64
|
-
},
|
|
64
|
+
}, u);
|
|
65
65
|
((z.onopen = () => {
|
|
66
|
-
(clearTimeout(
|
|
66
|
+
(clearTimeout(Q),
|
|
67
67
|
(this.openedAt = Date.now()),
|
|
68
68
|
this.clearStableTimer(),
|
|
69
69
|
(this.stableTimer = setTimeout(() => {
|
|
70
|
-
this.reconnectDelay =
|
|
71
|
-
},
|
|
72
|
-
let
|
|
70
|
+
this.reconnectDelay = L;
|
|
71
|
+
}, g)));
|
|
72
|
+
let Y = {
|
|
73
73
|
type: "hello",
|
|
74
74
|
role: this.opts.role,
|
|
75
75
|
peerId: this.peerId,
|
|
76
76
|
...(this.opts.meta ? { meta: this.opts.meta } : {}),
|
|
77
77
|
};
|
|
78
|
-
(z.send(JSON.stringify(
|
|
78
|
+
(z.send(JSON.stringify(Y)), this.startHeartbeat(), this.opts.onOpen?.());
|
|
79
79
|
}),
|
|
80
|
-
(z.onmessage = (
|
|
81
|
-
let
|
|
80
|
+
(z.onmessage = (Y) => {
|
|
81
|
+
let Z;
|
|
82
82
|
try {
|
|
83
|
-
|
|
83
|
+
Z = JSON.parse(String(Y.data));
|
|
84
84
|
} catch {
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
if (
|
|
88
|
-
else if (
|
|
87
|
+
if (Z.type === "peers") this.opts.onPeers?.(Z.peers);
|
|
88
|
+
else if (Z.type === "signal") this.opts.onSignal?.(Z.from, Z.data);
|
|
89
89
|
}),
|
|
90
|
-
(z.onclose = (
|
|
91
|
-
(clearTimeout(
|
|
92
|
-
let
|
|
90
|
+
(z.onclose = (Y) => {
|
|
91
|
+
(clearTimeout(Q), this.clearStableTimer(), this.stopHeartbeat());
|
|
92
|
+
let Z = this.openedAt ? Date.now() - this.openedAt : 0;
|
|
93
93
|
if (
|
|
94
94
|
((this.openedAt = 0),
|
|
95
|
-
this.opts.onClose?.({ code:
|
|
95
|
+
this.opts.onClose?.({ code: Y?.code ?? 0, reason: Y?.reason ?? "", ms: Z }),
|
|
96
96
|
!this.closed)
|
|
97
97
|
)
|
|
98
98
|
this.scheduleReconnect();
|
|
@@ -109,7 +109,7 @@ class H {
|
|
|
109
109
|
try {
|
|
110
110
|
this.ws?.send(JSON.stringify({ type: "ping" }));
|
|
111
111
|
} catch {}
|
|
112
|
-
},
|
|
112
|
+
}, O)));
|
|
113
113
|
}
|
|
114
114
|
stopHeartbeat() {
|
|
115
115
|
if (this.heartbeat != null) (clearInterval(this.heartbeat), (this.heartbeat = null));
|
|
@@ -123,7 +123,7 @@ class H {
|
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
125
|
let z = Math.round(this.reconnectDelay * (0.75 + Math.random() * 0.5));
|
|
126
|
-
((this.reconnectDelay = Math.min(this.reconnectDelay * 2,
|
|
126
|
+
((this.reconnectDelay = Math.min(this.reconnectDelay * 2, b)),
|
|
127
127
|
this.clearReconnectTimer(),
|
|
128
128
|
(this.reconnectTimer = setTimeout(() => {
|
|
129
129
|
if (((this.reconnectTimer = null), this.closed)) return;
|
|
@@ -138,14 +138,14 @@ class H {
|
|
|
138
138
|
if (this.reconnectTimer != null)
|
|
139
139
|
(clearTimeout(this.reconnectTimer), (this.reconnectTimer = null));
|
|
140
140
|
}
|
|
141
|
-
sendSignal(z,
|
|
142
|
-
let
|
|
143
|
-
this.ws?.send(JSON.stringify(
|
|
141
|
+
sendSignal(z, Q) {
|
|
142
|
+
let Y = { type: "signal", to: z, data: Q };
|
|
143
|
+
this.ws?.send(JSON.stringify(Y));
|
|
144
144
|
}
|
|
145
145
|
updateMeta(z) {
|
|
146
146
|
if (((this.opts.meta = z), this.ws?.readyState === 1)) {
|
|
147
|
-
let
|
|
148
|
-
this.ws.send(JSON.stringify(
|
|
147
|
+
let Q = { type: "meta", meta: z };
|
|
148
|
+
this.ws.send(JSON.stringify(Q));
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
close() {
|
|
@@ -160,21 +160,23 @@ class H {
|
|
|
160
160
|
} catch {}
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
var
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
var A = ["stun:stun.l.google.com:19302", "stun:stun1.l.google.com:19302"],
|
|
164
|
+
N = "codehost",
|
|
165
|
+
_ = "codehost-bulk";
|
|
166
|
+
class B {
|
|
166
167
|
opts;
|
|
167
168
|
pc;
|
|
168
169
|
channel = null;
|
|
170
|
+
bulk = null;
|
|
169
171
|
constructor(z) {
|
|
170
172
|
this.opts = z;
|
|
171
|
-
((this.pc = new RTCPeerConnection({ iceServers:
|
|
172
|
-
(this.pc.onicecandidate = (
|
|
173
|
-
if (
|
|
173
|
+
((this.pc = new RTCPeerConnection({ iceServers: A.map((Q) => ({ urls: Q })) })),
|
|
174
|
+
(this.pc.onicecandidate = (Q) => {
|
|
175
|
+
if (Q.candidate)
|
|
174
176
|
this.opts.sendSignal({
|
|
175
177
|
kind: "candidate",
|
|
176
|
-
candidate:
|
|
177
|
-
mid:
|
|
178
|
+
candidate: Q.candidate.candidate,
|
|
179
|
+
mid: Q.candidate.sdpMid ?? "0",
|
|
178
180
|
});
|
|
179
181
|
}),
|
|
180
182
|
(this.pc.onconnectionstatechange = () => {
|
|
@@ -182,60 +184,65 @@ class x {
|
|
|
182
184
|
}));
|
|
183
185
|
}
|
|
184
186
|
async start() {
|
|
185
|
-
let z = this.pc.createDataChannel(
|
|
187
|
+
let z = this.pc.createDataChannel(N, { ordered: !0 });
|
|
186
188
|
((z.binaryType = "arraybuffer"),
|
|
187
189
|
(this.channel = z),
|
|
188
190
|
(z.onopen = () => this.opts.onOpen?.(z)),
|
|
189
191
|
(z.onclose = () => this.opts.onClose?.()));
|
|
190
|
-
let
|
|
191
|
-
(
|
|
192
|
-
|
|
192
|
+
let Q = this.pc.createDataChannel(_, { ordered: !0 });
|
|
193
|
+
((Q.binaryType = "arraybuffer"), (this.bulk = Q));
|
|
194
|
+
let Y = await this.pc.createOffer();
|
|
195
|
+
(await this.pc.setLocalDescription(Y),
|
|
196
|
+
this.opts.sendSignal({ kind: "offer", type: "offer", sdp: Y.sdp ?? "" }));
|
|
193
197
|
}
|
|
194
198
|
async handleSignal(z) {
|
|
195
|
-
let
|
|
196
|
-
if (!
|
|
197
|
-
if (
|
|
198
|
-
else if (
|
|
199
|
+
let Q = z;
|
|
200
|
+
if (!Q || typeof Q !== "object") return;
|
|
201
|
+
if (Q.kind === "answer") await this.pc.setRemoteDescription({ type: "answer", sdp: Q.sdp });
|
|
202
|
+
else if (Q.kind === "candidate")
|
|
199
203
|
try {
|
|
200
|
-
await this.pc.addIceCandidate({ candidate:
|
|
201
|
-
} catch (
|
|
202
|
-
console.error("[rtc] addIceCandidate failed:",
|
|
204
|
+
await this.pc.addIceCandidate({ candidate: Q.candidate, sdpMid: Q.mid });
|
|
205
|
+
} catch (Y) {
|
|
206
|
+
console.error("[rtc] addIceCandidate failed:", Y);
|
|
203
207
|
}
|
|
204
208
|
}
|
|
205
209
|
get dataChannel() {
|
|
206
210
|
return this.channel;
|
|
207
211
|
}
|
|
212
|
+
get bulkChannel() {
|
|
213
|
+
return this.bulk;
|
|
214
|
+
}
|
|
208
215
|
async selectedPath() {
|
|
209
216
|
try {
|
|
210
217
|
let z = await this.pc.getStats(),
|
|
211
|
-
|
|
212
|
-
z.forEach((
|
|
213
|
-
if (
|
|
218
|
+
Q = null;
|
|
219
|
+
z.forEach((q) => {
|
|
220
|
+
if (q.type === "transport" && q.selectedCandidatePairId) Q = q.selectedCandidatePairId;
|
|
214
221
|
});
|
|
215
|
-
let
|
|
222
|
+
let Y = null;
|
|
216
223
|
if (
|
|
217
|
-
(z.forEach((
|
|
224
|
+
(z.forEach((q) => {
|
|
218
225
|
if (
|
|
219
|
-
|
|
226
|
+
Q ? q.id === Q : q.type === "candidate-pair" && q.state === "succeeded" && q.nominated
|
|
220
227
|
)
|
|
221
|
-
|
|
228
|
+
Y = q;
|
|
222
229
|
}),
|
|
223
|
-
!
|
|
230
|
+
!Y)
|
|
224
231
|
)
|
|
225
232
|
return null;
|
|
226
|
-
let { localCandidateId:
|
|
227
|
-
|
|
228
|
-
|
|
233
|
+
let { localCandidateId: Z, remoteCandidateId: $ } = Y,
|
|
234
|
+
G = !0,
|
|
235
|
+
V = 0;
|
|
229
236
|
if (
|
|
230
|
-
(z.forEach((
|
|
231
|
-
if (
|
|
232
|
-
if ((
|
|
237
|
+
(z.forEach((q) => {
|
|
238
|
+
if (q.id === Z || q.id === $) {
|
|
239
|
+
if ((V++, q.candidateType !== "host")) G = !1;
|
|
233
240
|
}
|
|
234
241
|
}),
|
|
235
|
-
|
|
242
|
+
V < 2)
|
|
236
243
|
)
|
|
237
244
|
return null;
|
|
238
|
-
return
|
|
245
|
+
return G ? "lan" : "p2p";
|
|
239
246
|
} catch {
|
|
240
247
|
return null;
|
|
241
248
|
}
|
|
@@ -244,77 +251,87 @@ class x {
|
|
|
244
251
|
try {
|
|
245
252
|
this.channel?.close();
|
|
246
253
|
} catch {}
|
|
254
|
+
try {
|
|
255
|
+
this.bulk?.close();
|
|
256
|
+
} catch {}
|
|
247
257
|
try {
|
|
248
258
|
this.pc.close();
|
|
249
259
|
} catch {}
|
|
250
260
|
}
|
|
251
261
|
}
|
|
252
|
-
var
|
|
253
|
-
|
|
254
|
-
function
|
|
255
|
-
let
|
|
256
|
-
|
|
257
|
-
if (((
|
|
258
|
-
return
|
|
262
|
+
var y = new TextEncoder(),
|
|
263
|
+
S = new TextDecoder();
|
|
264
|
+
function P(z, Q, Y) {
|
|
265
|
+
let Z = Y?.byteLength ?? 0,
|
|
266
|
+
$ = new Uint8Array(5 + Z);
|
|
267
|
+
if ((($[0] = z), new DataView($.buffer).setUint32(1, Q >>> 0, !1), Y && Z)) $.set(Y, 5);
|
|
268
|
+
return $;
|
|
259
269
|
}
|
|
260
|
-
function
|
|
261
|
-
return
|
|
270
|
+
function J(z, Q, Y) {
|
|
271
|
+
return P(z, Q, y.encode(JSON.stringify(Y)));
|
|
262
272
|
}
|
|
263
|
-
function
|
|
264
|
-
let
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
return { op:
|
|
273
|
+
function T(z) {
|
|
274
|
+
let Q = z instanceof Uint8Array ? z : new Uint8Array(z),
|
|
275
|
+
Y = Q[0],
|
|
276
|
+
Z = new DataView(Q.buffer, Q.byteOffset, Q.byteLength).getUint32(1, !1),
|
|
277
|
+
$ = Q.subarray(5);
|
|
278
|
+
return { op: Y, streamId: Z, payload: $ };
|
|
269
279
|
}
|
|
270
280
|
function U(z) {
|
|
271
|
-
return JSON.parse(
|
|
281
|
+
return JSON.parse(S.decode(z));
|
|
272
282
|
}
|
|
273
|
-
function
|
|
274
|
-
return
|
|
283
|
+
function E(z) {
|
|
284
|
+
return S.decode(z);
|
|
275
285
|
}
|
|
276
|
-
function*
|
|
277
|
-
for (let
|
|
286
|
+
function* C(z) {
|
|
287
|
+
for (let Q = 0; Q < z.byteLength; Q += 65531) yield z.slice(Q, Math.min(Q + 65531, z.byteLength));
|
|
278
288
|
}
|
|
279
|
-
function
|
|
289
|
+
function f(z) {
|
|
280
290
|
if (z.length === 1) return z[0];
|
|
281
|
-
let
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
for (let
|
|
285
|
-
return
|
|
291
|
+
let Q = z.reduce(($, G) => $ + G.byteLength, 0),
|
|
292
|
+
Y = new Uint8Array(Q),
|
|
293
|
+
Z = 0;
|
|
294
|
+
for (let $ of z) (Y.set($, Z), (Z += $.byteLength));
|
|
295
|
+
return Y;
|
|
286
296
|
}
|
|
287
|
-
function*
|
|
288
|
-
let
|
|
289
|
-
while (
|
|
290
|
-
yield
|
|
297
|
+
function* H(z, Q, Y) {
|
|
298
|
+
let Z = 0;
|
|
299
|
+
while (Y.byteLength - Z > 65531) (yield P(13, Q, Y.subarray(Z, Z + 65531)), (Z += 65531));
|
|
300
|
+
yield P(z, Q, Y.subarray(Z));
|
|
291
301
|
}
|
|
292
|
-
class
|
|
302
|
+
class F {
|
|
293
303
|
pending = new Map();
|
|
294
|
-
cont(z,
|
|
295
|
-
let
|
|
296
|
-
if (
|
|
297
|
-
else this.pending.set(z, [
|
|
304
|
+
cont(z, Q) {
|
|
305
|
+
let Y = this.pending.get(z);
|
|
306
|
+
if (Y) Y.push(Q.slice());
|
|
307
|
+
else this.pending.set(z, [Q.slice()]);
|
|
298
308
|
}
|
|
299
|
-
finish(z,
|
|
300
|
-
let
|
|
301
|
-
if (!
|
|
302
|
-
return (this.pending.delete(z),
|
|
309
|
+
finish(z, Q) {
|
|
310
|
+
let Y = this.pending.get(z);
|
|
311
|
+
if (!Y) return Q;
|
|
312
|
+
return (this.pending.delete(z), Y.push(Q), f(Y));
|
|
303
313
|
}
|
|
304
314
|
drop(z) {
|
|
305
315
|
this.pending.delete(z);
|
|
306
316
|
}
|
|
307
317
|
}
|
|
308
|
-
class
|
|
318
|
+
class R {
|
|
309
319
|
channel;
|
|
320
|
+
bulk;
|
|
310
321
|
nextStreamId = 1;
|
|
311
322
|
https = new Map();
|
|
312
323
|
wss = new Map();
|
|
313
|
-
wsRx = new
|
|
324
|
+
wsRx = new F();
|
|
314
325
|
textEncoder = new TextEncoder();
|
|
315
|
-
constructor(z) {
|
|
326
|
+
constructor(z, Q = null) {
|
|
316
327
|
this.channel = z;
|
|
317
|
-
|
|
328
|
+
this.bulk = Q;
|
|
329
|
+
if (
|
|
330
|
+
((z.binaryType = "arraybuffer"),
|
|
331
|
+
z.addEventListener("message", (Y) => this.onFrame(Y.data)),
|
|
332
|
+
Q)
|
|
333
|
+
)
|
|
334
|
+
((Q.binaryType = "arraybuffer"), Q.addEventListener("message", (Y) => this.onFrame(Y.data)));
|
|
318
335
|
}
|
|
319
336
|
allocId() {
|
|
320
337
|
let z = this.nextStreamId;
|
|
@@ -322,130 +339,131 @@ class j {
|
|
|
322
339
|
}
|
|
323
340
|
onFrame(z) {
|
|
324
341
|
if (typeof z === "string") return;
|
|
325
|
-
let { op:
|
|
326
|
-
switch (
|
|
342
|
+
let { op: Q, streamId: Y, payload: Z } = T(z);
|
|
343
|
+
switch (Q) {
|
|
327
344
|
case 4:
|
|
328
|
-
this.https.get(
|
|
345
|
+
this.https.get(Y)?.onHead(U(Z));
|
|
329
346
|
break;
|
|
330
347
|
case 5:
|
|
331
|
-
this.https.get(
|
|
348
|
+
this.https.get(Y)?.onBody(Z.slice());
|
|
332
349
|
break;
|
|
333
350
|
case 6:
|
|
334
|
-
(this.https.get(
|
|
351
|
+
(this.https.get(Y)?.onEnd(), this.https.delete(Y));
|
|
335
352
|
break;
|
|
336
353
|
case 12: {
|
|
337
|
-
let
|
|
338
|
-
if (
|
|
354
|
+
let $ = this.https.get(Y);
|
|
355
|
+
if ($) ($.onError(U(Z).message), this.https.delete(Y));
|
|
339
356
|
break;
|
|
340
357
|
}
|
|
341
358
|
case 8: {
|
|
342
|
-
let
|
|
343
|
-
this.wss.get(
|
|
359
|
+
let $ = U(Z);
|
|
360
|
+
this.wss.get(Y)?.onOpenAck($.ok, $.protocol);
|
|
344
361
|
break;
|
|
345
362
|
}
|
|
346
363
|
case 13:
|
|
347
|
-
this.wsRx.cont(
|
|
364
|
+
this.wsRx.cont(Y, Z);
|
|
348
365
|
break;
|
|
349
366
|
case 9:
|
|
350
|
-
this.wss.get(
|
|
367
|
+
this.wss.get(Y)?.onText(E(this.wsRx.finish(Y, Z)));
|
|
351
368
|
break;
|
|
352
369
|
case 10:
|
|
353
|
-
this.wss.get(
|
|
370
|
+
this.wss.get(Y)?.onBin(this.wsRx.finish(Y, Z).slice());
|
|
354
371
|
break;
|
|
355
372
|
case 11: {
|
|
356
|
-
let
|
|
357
|
-
(this.wsRx.drop(
|
|
358
|
-
this.wss.get(
|
|
359
|
-
this.wss.delete(
|
|
373
|
+
let $ = U(Z);
|
|
374
|
+
(this.wsRx.drop(Y),
|
|
375
|
+
this.wss.get(Y)?.onClose($.code ?? 1000, $.reason ?? ""),
|
|
376
|
+
this.wss.delete(Y));
|
|
360
377
|
break;
|
|
361
378
|
}
|
|
362
379
|
}
|
|
363
380
|
}
|
|
364
|
-
fetch(z,
|
|
365
|
-
let
|
|
366
|
-
return new Promise((
|
|
367
|
-
let
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
start: (
|
|
371
|
-
|
|
381
|
+
fetch(z, Q, Y, Z) {
|
|
382
|
+
let $ = this.allocId();
|
|
383
|
+
return new Promise((G, V) => {
|
|
384
|
+
let q = null,
|
|
385
|
+
D = null,
|
|
386
|
+
X = new ReadableStream({
|
|
387
|
+
start: (K) => {
|
|
388
|
+
D = K;
|
|
372
389
|
},
|
|
373
390
|
}),
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
(
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
)
|
|
414
|
-
for (let G of _(Y)) this.send(D(2, Z, G));
|
|
415
|
-
this.send(D(3, Z));
|
|
391
|
+
v = typeof DecompressionStream < "u" ? { ...Y, "x-codehost-accept-gzip": "1" } : Y;
|
|
392
|
+
this.https.set($, {
|
|
393
|
+
onHead: (K) => {
|
|
394
|
+
q = K;
|
|
395
|
+
let x = new Headers(K.headers),
|
|
396
|
+
M = X;
|
|
397
|
+
if (x.get("content-encoding") === "gzip")
|
|
398
|
+
((M = X.pipeThrough(new DecompressionStream("gzip"))),
|
|
399
|
+
x.delete("content-encoding"),
|
|
400
|
+
x.delete("content-length"));
|
|
401
|
+
G(
|
|
402
|
+
new Response(M, {
|
|
403
|
+
status: K.status === 204 || K.status === 304 ? K.status : K.status,
|
|
404
|
+
statusText: K.statusText,
|
|
405
|
+
headers: x,
|
|
406
|
+
}),
|
|
407
|
+
);
|
|
408
|
+
},
|
|
409
|
+
onBody: (K) => {
|
|
410
|
+
try {
|
|
411
|
+
D?.enqueue(K);
|
|
412
|
+
} catch {}
|
|
413
|
+
},
|
|
414
|
+
onEnd: () => {
|
|
415
|
+
try {
|
|
416
|
+
D?.close();
|
|
417
|
+
} catch {}
|
|
418
|
+
if (!q) V(Error("stream ended before head"));
|
|
419
|
+
},
|
|
420
|
+
onError: (K) => {
|
|
421
|
+
try {
|
|
422
|
+
D?.error(Error(K));
|
|
423
|
+
} catch {}
|
|
424
|
+
if (!q) V(Error(K));
|
|
425
|
+
},
|
|
426
|
+
});
|
|
427
|
+
let W = this.bulk?.readyState === "open" ? this.bulk : this.channel;
|
|
428
|
+
if ((this.sendOn(W, J(1, $, { method: z, path: Q, headers: v })), Z && Z.byteLength))
|
|
429
|
+
for (let K of C(Z)) this.sendOn(W, P(2, $, K));
|
|
430
|
+
this.sendOn(W, P(3, $));
|
|
416
431
|
});
|
|
417
432
|
}
|
|
418
|
-
openWs(z,
|
|
419
|
-
let
|
|
433
|
+
openWs(z, Q, Y) {
|
|
434
|
+
let Z = this.allocId();
|
|
420
435
|
return (
|
|
421
|
-
this.wss.set(
|
|
422
|
-
this.send(
|
|
436
|
+
this.wss.set(Z, Y),
|
|
437
|
+
this.send(J(7, Z, { path: z, protocols: Q })),
|
|
423
438
|
{
|
|
424
|
-
sendText: (
|
|
425
|
-
for (let
|
|
439
|
+
sendText: ($) => {
|
|
440
|
+
for (let G of H(9, Z, this.textEncoder.encode($))) this.send(G);
|
|
426
441
|
},
|
|
427
|
-
sendBin: (
|
|
428
|
-
for (let
|
|
442
|
+
sendBin: ($) => {
|
|
443
|
+
for (let G of H(10, Z, $)) this.send(G);
|
|
429
444
|
},
|
|
430
|
-
close: (
|
|
431
|
-
(this.send(
|
|
445
|
+
close: ($, G) => {
|
|
446
|
+
(this.send(J(11, Z, { code: $, reason: G })), this.wss.delete(Z));
|
|
432
447
|
},
|
|
433
448
|
}
|
|
434
449
|
);
|
|
435
450
|
}
|
|
436
451
|
send(z) {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
452
|
+
this.sendOn(this.channel, z);
|
|
453
|
+
}
|
|
454
|
+
sendOn(z, Q) {
|
|
455
|
+
if (z.readyState === "open") {
|
|
456
|
+
let Y = new Uint8Array(Q.byteLength);
|
|
457
|
+
(Y.set(Q), z.send(Y.buffer));
|
|
440
458
|
}
|
|
441
459
|
}
|
|
442
460
|
get ready() {
|
|
443
461
|
return this.channel.readyState === "open";
|
|
444
462
|
}
|
|
445
463
|
}
|
|
446
|
-
var
|
|
447
|
-
|
|
448
|
-
class
|
|
464
|
+
var I = "wss://signal.codehost.dev",
|
|
465
|
+
h = 1e4;
|
|
466
|
+
class w {
|
|
449
467
|
peers = [];
|
|
450
468
|
signaling;
|
|
451
469
|
rtcs = new Map();
|
|
@@ -453,58 +471,58 @@ class E {
|
|
|
453
471
|
dialFailedAt = new Map();
|
|
454
472
|
closed = !1;
|
|
455
473
|
constructor(z) {
|
|
456
|
-
((this.signaling = new
|
|
457
|
-
url: z.signalUrl ??
|
|
474
|
+
((this.signaling = new j({
|
|
475
|
+
url: z.signalUrl ?? I,
|
|
458
476
|
token: z.token,
|
|
459
477
|
role: "viewer",
|
|
460
478
|
onOpen: () => z.onStatus?.(!0),
|
|
461
479
|
onClose: () => z.onStatus?.(!1),
|
|
462
|
-
onPeers: (
|
|
463
|
-
((this.peers =
|
|
480
|
+
onPeers: (Q) => {
|
|
481
|
+
((this.peers = Q.filter((Y) => Y.role === "server")), z.onPeers?.(this.peers));
|
|
464
482
|
},
|
|
465
|
-
onSignal: (
|
|
483
|
+
onSignal: (Q, Y) => void this.rtcs.get(Q)?.handleSignal(Y),
|
|
466
484
|
})),
|
|
467
485
|
this.signaling.connect());
|
|
468
486
|
}
|
|
469
|
-
async fetch(z,
|
|
470
|
-
let
|
|
471
|
-
|
|
472
|
-
return
|
|
487
|
+
async fetch(z, Q, Y, Z = {}) {
|
|
488
|
+
let $ = await this.dial(z),
|
|
489
|
+
G = typeof Z.body === "string" ? new TextEncoder().encode(Z.body) : Z.body;
|
|
490
|
+
return $.fetch(Q, Y, Z.headers ?? {}, G);
|
|
473
491
|
}
|
|
474
492
|
dial(z) {
|
|
475
|
-
let
|
|
476
|
-
if (
|
|
477
|
-
let
|
|
478
|
-
if (
|
|
493
|
+
let Q = this.tunnels.get(z);
|
|
494
|
+
if (Q) return Q;
|
|
495
|
+
let Y = this.dialFailedAt.get(z);
|
|
496
|
+
if (Y != null && Date.now() - Y < h)
|
|
479
497
|
return Promise.reject(Error("dial failed recently; cooling down"));
|
|
480
|
-
let
|
|
498
|
+
let Z = () => {
|
|
481
499
|
(this.tunnels.delete(z), this.rtcs.get(z)?.close(), this.rtcs.delete(z));
|
|
482
500
|
},
|
|
483
|
-
|
|
484
|
-
let
|
|
485
|
-
(
|
|
501
|
+
$ = new Promise((G, V) => {
|
|
502
|
+
let q = setTimeout(() => {
|
|
503
|
+
(Z(), V(Error("dial timed out")));
|
|
486
504
|
}, 15000),
|
|
487
|
-
|
|
488
|
-
sendSignal: (
|
|
489
|
-
onOpen: (
|
|
490
|
-
(clearTimeout(
|
|
505
|
+
D = new B({
|
|
506
|
+
sendSignal: (X) => this.signaling.sendSignal(z, X),
|
|
507
|
+
onOpen: (X) => {
|
|
508
|
+
(clearTimeout(q), this.dialFailedAt.delete(z), G(new R(X, D.bulkChannel)));
|
|
491
509
|
},
|
|
492
|
-
onClose:
|
|
493
|
-
onState: (
|
|
494
|
-
if (
|
|
510
|
+
onClose: Z,
|
|
511
|
+
onState: (X) => {
|
|
512
|
+
if (X === "failed" || X === "disconnected") Z();
|
|
495
513
|
},
|
|
496
514
|
});
|
|
497
|
-
(this.rtcs.set(z,
|
|
498
|
-
|
|
499
|
-
(clearTimeout(
|
|
515
|
+
(this.rtcs.set(z, D),
|
|
516
|
+
D.start().catch((X) => {
|
|
517
|
+
(clearTimeout(q), Z(), V(X));
|
|
500
518
|
}));
|
|
501
519
|
});
|
|
502
520
|
return (
|
|
503
|
-
this.tunnels.set(z,
|
|
504
|
-
|
|
521
|
+
this.tunnels.set(z, $),
|
|
522
|
+
$.catch(() => {
|
|
505
523
|
(this.dialFailedAt.set(z, Date.now()), this.tunnels.delete(z));
|
|
506
524
|
}),
|
|
507
|
-
|
|
525
|
+
$
|
|
508
526
|
);
|
|
509
527
|
}
|
|
510
528
|
close() {
|
|
@@ -514,7 +532,7 @@ class E {
|
|
|
514
532
|
(this.rtcs.clear(), this.tunnels.clear(), this.signaling.close());
|
|
515
533
|
}
|
|
516
534
|
}
|
|
517
|
-
function
|
|
518
|
-
return new
|
|
535
|
+
function zz(z) {
|
|
536
|
+
return new w(z);
|
|
519
537
|
}
|
|
520
|
-
export {
|
|
538
|
+
export { zz as joinRoom, I as DEFAULT_SIGNAL_URL, w as CodehostRoom };
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import "./ts-BECoCPV1.js";
|
|
2
|
-
import "./logger-B9h0djqx.js";
|
|
3
|
-
import "./versionChecker-pct2j3wR.js";
|
|
4
|
-
import "./pidStore-DBjlqzo8.js";
|
|
5
|
-
import "./globalPidIndex-yVd3mbsV.js";
|
|
6
|
-
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-eIjVu8HF.js";
|
|
7
|
-
|
|
8
|
-
export { SUPPORTED_CLIS };
|