@opencode/browse 0.0.6-dev.18 → 0.0.6-dev.20
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/{cli-z00ttket.mjs → cli-anqhds1e.mjs} +771 -643
- package/dist/cli.mjs +8 -8
- package/dist/{relay-helpers-6a2vvzx9.mjs → helpers-n4k4pdag.mjs} +9 -9
- package/dist/{main-jjny7bmm.mjs → main-0nta0a2z.mjs} +200 -191
- package/dist/{main-9y22cffn.mjs → main-20ahaz2q.mjs} +3 -3
- package/dist/{main-w5sta7hq.mjs → main-3rsfghef.mjs} +4 -4
- package/dist/{main-d7rbre73.mjs → main-42qfr69q.mjs} +4 -4
- package/dist/main-arx3pfyn.mjs +4 -0
- package/dist/{main-0egy8naa.mjs → main-hywb9qbv.mjs} +5 -5
- package/dist/{main-ha5bnd77.mjs → main-ma25hhqh.mjs} +120 -118
- package/dist/{main-fkhwazsm.mjs → main-yd1d7qr1.mjs} +1708 -1532
- package/dist/{mcp-qh25n9s0.mjs → mcp-j9e2da4y.mjs} +584 -481
- package/dist/{relay-zs96tkfm.mjs → relay-cvhz2f0a.mjs} +16299 -15709
- package/dist/{runtime-update-8wte78jj.mjs → runtime-update-baranjc5.mjs} +5 -5
- package/dist/{setup-cqjdfcy0.mjs → setup-7shrgdza.mjs} +811 -705
- package/dist/{update-st5c8grg.mjs → update-vkspb2rz.mjs} +2 -2
- package/dist/{version-6g6gtnra.mjs → version-gfpqxbzm.mjs} +1 -1
- package/package.json +1 -2
- package/dist/main-ppz7sv9s.mjs +0 -4
package/dist/cli.mjs
CHANGED
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
// src/main.ts
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
var embeddedVersion = "0.0.6-dev.
|
|
5
|
+
var embeddedVersion = "0.0.6-dev.20";
|
|
6
6
|
var setupCommands = new Set(["install", "uninstall", "extension", "pair", "rollback", "set"]);
|
|
7
7
|
var command = process.argv[2];
|
|
8
8
|
var invokedAs = path.basename(process.argv[1] ?? "");
|
|
9
9
|
if (command === "--version" || command === "-v") {
|
|
10
|
-
const opencodeBrowserVersion = embeddedVersion ?? (await import("./version-
|
|
10
|
+
const opencodeBrowserVersion = embeddedVersion ?? (await import("./version-gfpqxbzm.mjs")).opencodeBrowserVersion;
|
|
11
11
|
process.stdout.write(`${opencodeBrowserVersion}
|
|
12
12
|
`);
|
|
13
13
|
} else if (invokedAs === "opencode-browser-mcp" || command === "mcp" && process.argv.length === 3) {
|
|
14
14
|
const { NodeRuntime } = await import("@effect/platform-node");
|
|
15
|
-
const { runMcpServer } = await import("./mcp-
|
|
15
|
+
const { runMcpServer } = await import("./mcp-j9e2da4y.mjs");
|
|
16
16
|
runMcpServer.pipe(NodeRuntime.runMain);
|
|
17
17
|
} else if (command === "runtime-install" || command === "runtime-switch") {
|
|
18
|
-
const { runRuntimeInstall, runRuntimeSwitch } = await import("./runtime-update-
|
|
18
|
+
const { runRuntimeInstall, runRuntimeSwitch } = await import("./runtime-update-baranjc5.mjs");
|
|
19
19
|
await (command === "runtime-install" ? runRuntimeInstall : runRuntimeSwitch)(process.argv.slice(3));
|
|
20
20
|
} else if (command === "update") {
|
|
21
|
-
const { runUpdateCommand } = await import("./update-
|
|
21
|
+
const { runUpdateCommand } = await import("./update-vkspb2rz.mjs");
|
|
22
22
|
await runUpdateCommand(process.argv.slice(3));
|
|
23
23
|
} else if (command && setupCommands.has(command)) {
|
|
24
|
-
const { runSetup } = await import("./setup-
|
|
24
|
+
const { runSetup } = await import("./setup-7shrgdza.mjs");
|
|
25
25
|
await runSetup(command, process.argv.slice(3));
|
|
26
26
|
} else {
|
|
27
27
|
if (!command || command === "--help" || command === "-h") {
|
|
@@ -55,9 +55,9 @@ if (command === "--version" || command === "-v") {
|
|
|
55
55
|
`);
|
|
56
56
|
}
|
|
57
57
|
if (command === "status" && !process.argv.includes("--json")) {
|
|
58
|
-
const { printSetupStatus } = await import("./setup-
|
|
58
|
+
const { printSetupStatus } = await import("./setup-7shrgdza.mjs");
|
|
59
59
|
printSetupStatus();
|
|
60
60
|
}
|
|
61
|
-
const { runCli } = await import("./cli-
|
|
61
|
+
const { runCli } = await import("./cli-anqhds1e.mjs");
|
|
62
62
|
runCli();
|
|
63
63
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
defaultHost2,
|
|
3
|
-
defaultPort2,
|
|
4
|
-
stableUnpackedExtensionOrigin2,
|
|
5
|
-
chromeExtensionOriginForPath2,
|
|
6
|
-
parseAdditionalExtensionOrigins2,
|
|
7
2
|
HttpRouteError2,
|
|
8
3
|
formatHostForUrl2,
|
|
9
|
-
validateHostHeader2,
|
|
10
|
-
validateBrowserFetchSite2,
|
|
11
|
-
validateWebSocketOrigin2,
|
|
12
4
|
listenHttpServer2,
|
|
13
5
|
closeHttpServer2,
|
|
14
6
|
closeWebSocketServer2,
|
|
15
7
|
logCloseError2,
|
|
16
8
|
sendJson2,
|
|
17
9
|
readJsonBody2,
|
|
10
|
+
stableUnpackedExtensionOrigin2,
|
|
11
|
+
chromeExtensionOriginForPath2,
|
|
12
|
+
parseAdditionalExtensionOrigins2,
|
|
13
|
+
validateHostHeader2,
|
|
14
|
+
validateBrowserFetchSite2,
|
|
15
|
+
validateWebSocketOrigin2,
|
|
16
|
+
defaultHost2,
|
|
17
|
+
defaultPort2,
|
|
18
18
|
optionalSessionId2,
|
|
19
19
|
isValidSessionId2,
|
|
20
20
|
requiredSessionId2,
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
isRestrictedTarget2,
|
|
32
32
|
isRestrictedUrl2,
|
|
33
33
|
dataUrlDocument2
|
|
34
|
-
} from "./main-
|
|
34
|
+
} from "./main-0nta0a2z.mjs";
|
|
35
35
|
export {
|
|
36
36
|
HttpRouteError2 as HttpRouteError,
|
|
37
37
|
chromeExtensionOriginForPath2 as chromeExtensionOriginForPath,
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
+
cliCommand,
|
|
3
|
+
installCommand,
|
|
4
|
+
npmRuntime,
|
|
2
5
|
unpackedExtensionId,
|
|
3
6
|
extensionReconnectAlarmPeriodMs,
|
|
4
7
|
extensionProtocolAdvice,
|
|
5
|
-
parseJsonObject
|
|
6
|
-
|
|
7
|
-
installCommand,
|
|
8
|
-
npmRuntime
|
|
9
|
-
} from "./main-ha5bnd77.mjs";
|
|
8
|
+
parseJsonObject
|
|
9
|
+
} from "./main-ma25hhqh.mjs";
|
|
10
10
|
import {
|
|
11
11
|
relayAuthorization
|
|
12
|
-
} from "./main-
|
|
12
|
+
} from "./main-20ahaz2q.mjs";
|
|
13
13
|
import {
|
|
14
14
|
opencodeBrowserBuildId2
|
|
15
|
-
} from "./main-
|
|
15
|
+
} from "./main-arx3pfyn.mjs";
|
|
16
16
|
|
|
17
|
-
// src/relay
|
|
18
|
-
import
|
|
19
|
-
import { Effect, Option, Predicate, Schema as Schema2 } from "effect";
|
|
17
|
+
// src/relay/helpers.ts
|
|
18
|
+
import { Option, Predicate, Schema as Schema3 } from "effect";
|
|
20
19
|
|
|
21
|
-
// src/relay
|
|
20
|
+
// src/relay/http.ts
|
|
21
|
+
import { Effect, Schema as Schema2 } from "effect";
|
|
22
|
+
|
|
23
|
+
// src/relay/schema.ts
|
|
22
24
|
import { Schema } from "effect";
|
|
23
25
|
var SessionSummary = Schema.Struct({
|
|
24
26
|
id: Schema.String,
|
|
@@ -524,37 +526,7 @@ var ErrorEnvelope = Schema.Struct({
|
|
|
524
526
|
code: Schema.optionalKey(RelayErrorCode)
|
|
525
527
|
});
|
|
526
528
|
|
|
527
|
-
// src/relay
|
|
528
|
-
var defaultHost2 = "127.0.0.1";
|
|
529
|
-
var defaultPort2 = 19988;
|
|
530
|
-
var stableUnpackedExtensionOrigin2 = `chrome-extension://${unpackedExtensionId}`;
|
|
531
|
-
function chromeExtensionOriginForPath2(extensionPath, platform = process.platform) {
|
|
532
|
-
const normalizedPath = platform === "win32" && /^[a-z]:/.test(extensionPath) ? extensionPath.charAt(0).toUpperCase() + extensionPath.slice(1) : extensionPath;
|
|
533
|
-
const pathBytes = platform === "win32" ? Buffer.from(normalizedPath, "utf16le") : normalizedPath;
|
|
534
|
-
const digest = crypto.createHash("sha256").update(pathBytes).digest();
|
|
535
|
-
let extensionId = "";
|
|
536
|
-
for (const byte of digest.subarray(0, 16)) {
|
|
537
|
-
extensionId += String.fromCharCode(97 + (byte >> 4), 97 + (byte & 15));
|
|
538
|
-
}
|
|
539
|
-
return `chrome-extension://${extensionId}`;
|
|
540
|
-
}
|
|
541
|
-
var chromeExtensionOriginPattern = /^chrome-extension:\/\/[a-p]+$/;
|
|
542
|
-
function parseAdditionalExtensionOrigins2(raw) {
|
|
543
|
-
if (!raw) {
|
|
544
|
-
return [];
|
|
545
|
-
}
|
|
546
|
-
const seen = new Set;
|
|
547
|
-
const origins = [];
|
|
548
|
-
for (const token of raw.split(/[\s,]+/)) {
|
|
549
|
-
const value = token.trim();
|
|
550
|
-
if (!value || !chromeExtensionOriginPattern.test(value) || seen.has(value)) {
|
|
551
|
-
continue;
|
|
552
|
-
}
|
|
553
|
-
seen.add(value);
|
|
554
|
-
origins.push(value);
|
|
555
|
-
}
|
|
556
|
-
return origins;
|
|
557
|
-
}
|
|
529
|
+
// src/relay/http.ts
|
|
558
530
|
var maxCliBodyBytes = 1e6;
|
|
559
531
|
|
|
560
532
|
class HttpRouteError2 extends Schema2.TaggedError()("HttpApi.HttpRouteError", { message: Schema2.String, status: Schema2.Number, code: RelayErrorCode }) {
|
|
@@ -565,98 +537,6 @@ function formatHostForUrl2(host) {
|
|
|
565
537
|
}
|
|
566
538
|
return host;
|
|
567
539
|
}
|
|
568
|
-
function validateHostHeader2(options) {
|
|
569
|
-
const parsed = parseHostHeader(options.hostHeader);
|
|
570
|
-
if (!parsed) {
|
|
571
|
-
return "Invalid Host header";
|
|
572
|
-
}
|
|
573
|
-
if (parsed.port !== undefined && parsed.port !== options.port) {
|
|
574
|
-
return "Invalid Host header port";
|
|
575
|
-
}
|
|
576
|
-
const allowedHosts = new Set(["localhost", "127.0.0.1", "::1", normalizeHostname(options.host)]);
|
|
577
|
-
if (!allowedHosts.has(parsed.hostname)) {
|
|
578
|
-
return "Invalid Host header";
|
|
579
|
-
}
|
|
580
|
-
return;
|
|
581
|
-
}
|
|
582
|
-
function validateBrowserFetchSite2(request) {
|
|
583
|
-
const secFetchSite = request.headers["sec-fetch-site"];
|
|
584
|
-
const value = Array.isArray(secFetchSite) ? secFetchSite[0] : secFetchSite;
|
|
585
|
-
if (!value || value === "same-origin" || value === "none") {
|
|
586
|
-
return;
|
|
587
|
-
}
|
|
588
|
-
return "Cross-origin browser requests are not allowed";
|
|
589
|
-
}
|
|
590
|
-
function validateWebSocketOrigin2(options) {
|
|
591
|
-
if (!options.origin) {
|
|
592
|
-
return options.requireChromeExtension ? "Extension WebSocket origin is required" : undefined;
|
|
593
|
-
}
|
|
594
|
-
if (options.origin === stableUnpackedExtensionOrigin2 || options.additionalChromeExtensionOrigins?.has(options.origin)) {
|
|
595
|
-
return;
|
|
596
|
-
}
|
|
597
|
-
if (options.requireChromeExtension) {
|
|
598
|
-
return "Extension WebSocket origin is not allowed";
|
|
599
|
-
}
|
|
600
|
-
return "WebSocket origin is not allowed";
|
|
601
|
-
}
|
|
602
|
-
function normalizeHostname(host) {
|
|
603
|
-
const value = host.trim().toLowerCase();
|
|
604
|
-
if (value.startsWith("[") && value.endsWith("]")) {
|
|
605
|
-
return value.slice(1, -1);
|
|
606
|
-
}
|
|
607
|
-
return value;
|
|
608
|
-
}
|
|
609
|
-
function parseHostHeader(hostHeader) {
|
|
610
|
-
const value = hostHeader?.trim().toLowerCase();
|
|
611
|
-
if (!value) {
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
if (value.startsWith("[")) {
|
|
615
|
-
const closingBracket = value.indexOf("]");
|
|
616
|
-
if (closingBracket === -1) {
|
|
617
|
-
return;
|
|
618
|
-
}
|
|
619
|
-
const hostname = value.slice(1, closingBracket);
|
|
620
|
-
const rest = value.slice(closingBracket + 1);
|
|
621
|
-
if (!hostname) {
|
|
622
|
-
return;
|
|
623
|
-
}
|
|
624
|
-
if (!rest) {
|
|
625
|
-
return { hostname };
|
|
626
|
-
}
|
|
627
|
-
if (!rest.startsWith(":")) {
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
630
|
-
const port = parsePort(rest.slice(1));
|
|
631
|
-
return port === undefined ? undefined : { hostname, port };
|
|
632
|
-
}
|
|
633
|
-
if (value === "::1") {
|
|
634
|
-
return { hostname: "::1" };
|
|
635
|
-
}
|
|
636
|
-
const colonCount = value.split(":").length - 1;
|
|
637
|
-
if (colonCount > 1) {
|
|
638
|
-
return;
|
|
639
|
-
}
|
|
640
|
-
if (colonCount === 0) {
|
|
641
|
-
return { hostname: value };
|
|
642
|
-
}
|
|
643
|
-
const [hostname, portText] = value.split(":");
|
|
644
|
-
if (!hostname || portText === undefined) {
|
|
645
|
-
return;
|
|
646
|
-
}
|
|
647
|
-
const port = parsePort(portText);
|
|
648
|
-
return port === undefined ? undefined : { hostname, port };
|
|
649
|
-
}
|
|
650
|
-
function parsePort(value) {
|
|
651
|
-
if (!/^\d+$/.test(value)) {
|
|
652
|
-
return;
|
|
653
|
-
}
|
|
654
|
-
const port = Number(value);
|
|
655
|
-
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
656
|
-
return;
|
|
657
|
-
}
|
|
658
|
-
return port;
|
|
659
|
-
}
|
|
660
540
|
function listenHttpServer2(options) {
|
|
661
541
|
return Effect.callback((resume) => {
|
|
662
542
|
const onError = (error) => {
|
|
@@ -791,22 +671,149 @@ function readJsonBody2(request) {
|
|
|
791
671
|
});
|
|
792
672
|
});
|
|
793
673
|
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
674
|
+
|
|
675
|
+
// src/relay/origins.ts
|
|
676
|
+
import crypto from "node:crypto";
|
|
677
|
+
var stableUnpackedExtensionOrigin2 = `chrome-extension://${unpackedExtensionId}`;
|
|
678
|
+
function chromeExtensionOriginForPath2(extensionPath, platform = process.platform) {
|
|
679
|
+
const normalizedPath = platform === "win32" && /^[a-z]:/.test(extensionPath) ? extensionPath.charAt(0).toUpperCase() + extensionPath.slice(1) : extensionPath;
|
|
680
|
+
const pathBytes = platform === "win32" ? Buffer.from(normalizedPath, "utf16le") : normalizedPath;
|
|
681
|
+
const digest = crypto.createHash("sha256").update(pathBytes).digest();
|
|
682
|
+
let extensionId = "";
|
|
683
|
+
for (const byte of digest.subarray(0, 16)) {
|
|
684
|
+
extensionId += String.fromCharCode(97 + (byte >> 4), 97 + (byte & 15));
|
|
685
|
+
}
|
|
686
|
+
return `chrome-extension://${extensionId}`;
|
|
687
|
+
}
|
|
688
|
+
var chromeExtensionOriginPattern = /^chrome-extension:\/\/[a-p]+$/;
|
|
689
|
+
function parseAdditionalExtensionOrigins2(raw) {
|
|
690
|
+
if (!raw) {
|
|
691
|
+
return [];
|
|
692
|
+
}
|
|
693
|
+
const seen = new Set;
|
|
694
|
+
const origins = [];
|
|
695
|
+
for (const token of raw.split(/[\s,]+/)) {
|
|
696
|
+
const value = token.trim();
|
|
697
|
+
if (!value || !chromeExtensionOriginPattern.test(value) || seen.has(value)) {
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
seen.add(value);
|
|
701
|
+
origins.push(value);
|
|
702
|
+
}
|
|
703
|
+
return origins;
|
|
704
|
+
}
|
|
705
|
+
function validateHostHeader2(options) {
|
|
706
|
+
const parsed = parseHostHeader(options.hostHeader);
|
|
707
|
+
if (!parsed) {
|
|
708
|
+
return "Invalid Host header";
|
|
709
|
+
}
|
|
710
|
+
if (parsed.port !== undefined && parsed.port !== options.port) {
|
|
711
|
+
return "Invalid Host header port";
|
|
712
|
+
}
|
|
713
|
+
const allowedHosts = new Set(["localhost", "127.0.0.1", "::1", normalizeHostname(options.host)]);
|
|
714
|
+
if (!allowedHosts.has(parsed.hostname)) {
|
|
715
|
+
return "Invalid Host header";
|
|
716
|
+
}
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
function validateBrowserFetchSite2(request) {
|
|
720
|
+
const secFetchSite = request.headers["sec-fetch-site"];
|
|
721
|
+
const value = Array.isArray(secFetchSite) ? secFetchSite[0] : secFetchSite;
|
|
722
|
+
if (!value || value === "same-origin" || value === "none") {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
return "Cross-origin browser requests are not allowed";
|
|
726
|
+
}
|
|
727
|
+
function validateWebSocketOrigin2(options) {
|
|
728
|
+
if (!options.origin) {
|
|
729
|
+
return options.requireChromeExtension ? "Extension WebSocket origin is required" : undefined;
|
|
730
|
+
}
|
|
731
|
+
if (options.origin === stableUnpackedExtensionOrigin2 || options.additionalChromeExtensionOrigins?.has(options.origin)) {
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
if (options.requireChromeExtension) {
|
|
735
|
+
return "Extension WebSocket origin is not allowed";
|
|
736
|
+
}
|
|
737
|
+
return "WebSocket origin is not allowed";
|
|
738
|
+
}
|
|
739
|
+
function normalizeHostname(host) {
|
|
740
|
+
const value = host.trim().toLowerCase();
|
|
741
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
742
|
+
return value.slice(1, -1);
|
|
743
|
+
}
|
|
744
|
+
return value;
|
|
745
|
+
}
|
|
746
|
+
function parseHostHeader(hostHeader) {
|
|
747
|
+
const value = hostHeader?.trim().toLowerCase();
|
|
748
|
+
if (!value) {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
if (value.startsWith("[")) {
|
|
752
|
+
const closingBracket = value.indexOf("]");
|
|
753
|
+
if (closingBracket === -1) {
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
const hostname = value.slice(1, closingBracket);
|
|
757
|
+
const rest = value.slice(closingBracket + 1);
|
|
758
|
+
if (!hostname) {
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
if (!rest) {
|
|
762
|
+
return { hostname };
|
|
763
|
+
}
|
|
764
|
+
if (!rest.startsWith(":")) {
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
const port = parsePort(rest.slice(1));
|
|
768
|
+
return port === undefined ? undefined : { hostname, port };
|
|
769
|
+
}
|
|
770
|
+
if (value === "::1") {
|
|
771
|
+
return { hostname: "::1" };
|
|
772
|
+
}
|
|
773
|
+
const colonCount = value.split(":").length - 1;
|
|
774
|
+
if (colonCount > 1) {
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
if (colonCount === 0) {
|
|
778
|
+
return { hostname: value };
|
|
779
|
+
}
|
|
780
|
+
const [hostname, portText] = value.split(":");
|
|
781
|
+
if (!hostname || portText === undefined) {
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
const port = parsePort(portText);
|
|
785
|
+
return port === undefined ? undefined : { hostname, port };
|
|
786
|
+
}
|
|
787
|
+
function parsePort(value) {
|
|
788
|
+
if (!/^\d+$/.test(value)) {
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
const port = Number(value);
|
|
792
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
return port;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// src/relay/helpers.ts
|
|
799
|
+
var defaultHost2 = "127.0.0.1";
|
|
800
|
+
var defaultPort2 = 19988;
|
|
801
|
+
var RawTargetSelection = Schema3.Struct({
|
|
802
|
+
urlIncludes: Schema3.optionalKey(Schema3.String),
|
|
803
|
+
index: Schema3.optionalKey(Schema3.Int.check(Schema3.isGreaterThanOrEqualTo(0)))
|
|
797
804
|
});
|
|
798
|
-
var decodeRawTargetSelection =
|
|
799
|
-
var RawTargetInfo =
|
|
800
|
-
targetId:
|
|
801
|
-
type:
|
|
802
|
-
title:
|
|
803
|
-
url:
|
|
804
|
-
canAccessOpener:
|
|
805
|
-
browserContextId:
|
|
806
|
-
openerId:
|
|
807
|
-
parentFrameId:
|
|
805
|
+
var decodeRawTargetSelection = Schema3.decodeUnknownOption(RawTargetSelection);
|
|
806
|
+
var RawTargetInfo = Schema3.Struct({
|
|
807
|
+
targetId: Schema3.String,
|
|
808
|
+
type: Schema3.Literals(["page", "iframe", "worker"]),
|
|
809
|
+
title: Schema3.optionalKey(Schema3.String),
|
|
810
|
+
url: Schema3.String,
|
|
811
|
+
canAccessOpener: Schema3.optionalKey(Schema3.Boolean),
|
|
812
|
+
browserContextId: Schema3.optionalKey(Schema3.String),
|
|
813
|
+
openerId: Schema3.optionalKey(Schema3.String),
|
|
814
|
+
parentFrameId: Schema3.optionalKey(Schema3.String)
|
|
808
815
|
});
|
|
809
|
-
var decodeRawTargetInfo =
|
|
816
|
+
var decodeRawTargetInfo = Schema3.decodeUnknownOption(RawTargetInfo);
|
|
810
817
|
function optionalSessionId2(value) {
|
|
811
818
|
if (!Predicate.isString(value) || !value.trim()) {
|
|
812
819
|
return;
|
|
@@ -946,54 +953,62 @@ async function dataUrlDocument2(url) {
|
|
|
946
953
|
return;
|
|
947
954
|
}
|
|
948
955
|
|
|
949
|
-
// src/relay
|
|
956
|
+
// src/relay/lifecycle.ts
|
|
957
|
+
import { Config as Config2, Effect as Effect3, Result, Schedule, Schema as Schema5 } from "effect";
|
|
958
|
+
import { spawn } from "node:child_process";
|
|
959
|
+
import crypto2 from "node:crypto";
|
|
960
|
+
import path from "node:path";
|
|
961
|
+
import process2 from "node:process";
|
|
962
|
+
import { fileURLToPath } from "node:url";
|
|
963
|
+
|
|
964
|
+
// src/relay/client.ts
|
|
950
965
|
import { NodeHttpClient } from "@effect/platform-node";
|
|
951
|
-
import { Config, Context, Effect as Effect2, Layer, Option as Option2, Schema as
|
|
966
|
+
import { Config, Context, Effect as Effect2, Layer, Option as Option2, Schema as Schema4 } from "effect";
|
|
952
967
|
import { HttpClient, HttpClientRequest } from "effect/http";
|
|
953
968
|
var portConfig = Config.Int("OPENCODE_BROWSER_PORT").pipe(Config.withDefault(defaultPort2));
|
|
954
969
|
var extensionOriginsConfig = Config.String("OPENCODE_BROWSER_EXTENSION_ORIGINS").pipe(Config.withDefault(""));
|
|
955
970
|
var endpointForPort = (port) => `http://127.0.0.1:${port}`;
|
|
956
971
|
|
|
957
|
-
class RelayUnreachable extends
|
|
958
|
-
message:
|
|
959
|
-
endpoint:
|
|
960
|
-
path:
|
|
961
|
-
cause:
|
|
972
|
+
class RelayUnreachable extends Schema4.TaggedError()("RelayClient.RelayUnreachable", {
|
|
973
|
+
message: Schema4.String,
|
|
974
|
+
endpoint: Schema4.String,
|
|
975
|
+
path: Schema4.String,
|
|
976
|
+
cause: Schema4.Defect()
|
|
962
977
|
}) {
|
|
963
978
|
}
|
|
964
979
|
|
|
965
|
-
class RelayRejected extends
|
|
966
|
-
message:
|
|
967
|
-
status:
|
|
968
|
-
path:
|
|
969
|
-
code:
|
|
980
|
+
class RelayRejected extends Schema4.TaggedError()("RelayClient.RelayRejected", {
|
|
981
|
+
message: Schema4.String,
|
|
982
|
+
status: Schema4.Number,
|
|
983
|
+
path: Schema4.String,
|
|
984
|
+
code: Schema4.optionalKey(RelayErrorCode)
|
|
970
985
|
}) {
|
|
971
986
|
}
|
|
972
987
|
|
|
973
|
-
class RelayDecodeFailed extends
|
|
974
|
-
message:
|
|
975
|
-
path:
|
|
976
|
-
cause:
|
|
988
|
+
class RelayDecodeFailed extends Schema4.TaggedError()("RelayClient.RelayDecodeFailed", {
|
|
989
|
+
message: Schema4.String,
|
|
990
|
+
path: Schema4.String,
|
|
991
|
+
cause: Schema4.Defect()
|
|
977
992
|
}) {
|
|
978
993
|
}
|
|
979
994
|
|
|
980
|
-
class RelayEncodeFailed extends
|
|
981
|
-
message:
|
|
982
|
-
path:
|
|
983
|
-
cause:
|
|
995
|
+
class RelayEncodeFailed extends Schema4.TaggedError()("RelayClient.RelayEncodeFailed", {
|
|
996
|
+
message: Schema4.String,
|
|
997
|
+
path: Schema4.String,
|
|
998
|
+
cause: Schema4.Defect()
|
|
984
999
|
}) {
|
|
985
1000
|
}
|
|
986
1001
|
|
|
987
|
-
class RelayConfigInvalid extends
|
|
988
|
-
message:
|
|
989
|
-
cause:
|
|
1002
|
+
class RelayConfigInvalid extends Schema4.TaggedError()("RelayClient.RelayConfigInvalid", {
|
|
1003
|
+
message: Schema4.String,
|
|
1004
|
+
cause: Schema4.Defect()
|
|
990
1005
|
}) {
|
|
991
1006
|
}
|
|
992
1007
|
|
|
993
1008
|
class Service extends Context.Service()("opencode-browser-cli/RelayClient") {
|
|
994
1009
|
}
|
|
995
|
-
var decodeErrorEnvelope =
|
|
996
|
-
var decodeErrorMessage =
|
|
1010
|
+
var decodeErrorEnvelope = Schema4.decodeUnknownOption(ErrorEnvelope);
|
|
1011
|
+
var decodeErrorMessage = Schema4.decodeUnknownOption(Schema4.Struct({ error: Schema4.String }));
|
|
997
1012
|
var make = Effect2.fn("RelayClient.make")(function* (options) {
|
|
998
1013
|
const port = yield* portConfig.pipe(Effect2.mapError((cause) => new RelayConfigInvalid({
|
|
999
1014
|
message: `Invalid OPENCODE_BROWSER_PORT configuration: ${cause.message}`,
|
|
@@ -1017,7 +1032,7 @@ var make = Effect2.fn("RelayClient.make")(function* (options) {
|
|
|
1017
1032
|
...Option2.isSome(envelope) && envelope.value.code ? { code: envelope.value.code } : {}
|
|
1018
1033
|
}));
|
|
1019
1034
|
}
|
|
1020
|
-
return
|
|
1035
|
+
return Schema4.decodeUnknownEffect(schema)(body).pipe(Effect2.mapError((cause) => new RelayDecodeFailed({
|
|
1021
1036
|
message: `Relay response for ${path} did not match the expected shape: ${cause.message}`,
|
|
1022
1037
|
path,
|
|
1023
1038
|
cause
|
|
@@ -1118,14 +1133,8 @@ function mcpClientPid() {
|
|
|
1118
1133
|
}
|
|
1119
1134
|
var layerFetchMcp = Layer.effect(Service, make({ clientPid: mcpClientPid() })).pipe(Layer.provide(NodeHttpClient.layerNodeHttp));
|
|
1120
1135
|
|
|
1121
|
-
// src/relay
|
|
1122
|
-
|
|
1123
|
-
import { spawn } from "node:child_process";
|
|
1124
|
-
import crypto2 from "node:crypto";
|
|
1125
|
-
import path from "node:path";
|
|
1126
|
-
import process2 from "node:process";
|
|
1127
|
-
import { fileURLToPath } from "node:url";
|
|
1128
|
-
var loadedCliEntrypoint = fileURLToPath(new URL(import.meta.url.endsWith(".ts") ? "./main.ts" : "./cli.mjs", import.meta.url));
|
|
1136
|
+
// src/relay/lifecycle.ts
|
|
1137
|
+
var loadedCliEntrypoint = fileURLToPath(new URL(import.meta.url.endsWith(".ts") ? "../main.ts" : "./cli.mjs", import.meta.url));
|
|
1129
1138
|
var clientInstanceId = crypto2.randomUUID();
|
|
1130
1139
|
function shouldWaitForExtensionReconnect(readiness) {
|
|
1131
1140
|
return readiness.started || readiness.waitForReconnect === true;
|
|
@@ -1134,19 +1143,19 @@ function shouldWaitForExtensionReconnect(readiness) {
|
|
|
1134
1143
|
class RelayStillRunning extends Error {
|
|
1135
1144
|
}
|
|
1136
1145
|
|
|
1137
|
-
class RelayStartFailed extends
|
|
1138
|
-
message:
|
|
1139
|
-
endpoint:
|
|
1140
|
-
cause:
|
|
1146
|
+
class RelayStartFailed extends Schema5.TaggedError()("RelayLifecycle.RelayStartFailed", {
|
|
1147
|
+
message: Schema5.String,
|
|
1148
|
+
endpoint: Schema5.String,
|
|
1149
|
+
cause: Schema5.Defect()
|
|
1141
1150
|
}) {
|
|
1142
1151
|
}
|
|
1143
1152
|
|
|
1144
|
-
class ExtensionDisconnected extends
|
|
1153
|
+
class ExtensionDisconnected extends Schema5.TaggedError()("RelayLifecycle.ExtensionDisconnected", { message: Schema5.String, needsPairing: Schema5.optionalKey(Schema5.Boolean) }) {
|
|
1145
1154
|
}
|
|
1146
1155
|
|
|
1147
|
-
class ExtensionProtocolIncompatible extends
|
|
1148
|
-
message:
|
|
1149
|
-
protocolVersion:
|
|
1156
|
+
class ExtensionProtocolIncompatible extends Schema5.TaggedError()("RelayLifecycle.ExtensionProtocolIncompatible", {
|
|
1157
|
+
message: Schema5.String,
|
|
1158
|
+
protocolVersion: Schema5.NullOr(Schema5.Number)
|
|
1150
1159
|
}) {
|
|
1151
1160
|
}
|
|
1152
1161
|
function supersededRuntime() {
|
|
@@ -1422,4 +1431,4 @@ function isRelayStartingOrUnreachable(error) {
|
|
|
1422
1431
|
return isRelayStarting(error) || isRelayUnreachable(error);
|
|
1423
1432
|
}
|
|
1424
1433
|
|
|
1425
|
-
export { ExecuteRequest, SessionAdoptRequest, SessionNewRequest, SessionEnsureRequest, SessionIdRequest, SessionAllowlistRequest, AuthenticatedJsonRequest, AuthenticatedJsonOutcome, RelayShutdownRequest, NetworkStartRequest, NetworkSessionRequest, NetworkStopRequest, DeadboltLoginsRequest, AuthProfileRequest, AuthRefreshRequest, AuthRunRequest, RecordingTargetRequest, RecordingStartRequest, FlightRecorderStartRequest, FlightRecorderSaveRequest,
|
|
1434
|
+
export { ExecuteRequest, SessionAdoptRequest, SessionNewRequest, SessionEnsureRequest, SessionIdRequest, SessionAllowlistRequest, AuthenticatedJsonRequest, AuthenticatedJsonOutcome, RelayShutdownRequest, NetworkStartRequest, NetworkSessionRequest, NetworkStopRequest, DeadboltLoginsRequest, AuthProfileRequest, AuthRefreshRequest, AuthRunRequest, RecordingTargetRequest, RecordingStartRequest, FlightRecorderStartRequest, FlightRecorderSaveRequest, HttpRouteError2, formatHostForUrl2, listenHttpServer2, closeHttpServer2, closeWebSocketServer2, logCloseError2, sendJson2, readJsonBody2, stableUnpackedExtensionOrigin2, chromeExtensionOriginForPath2, parseAdditionalExtensionOrigins2, validateHostHeader2, validateBrowserFetchSite2, validateWebSocketOrigin2, defaultHost2, defaultPort2, optionalSessionId2, isValidSessionId2, requiredSessionId2, parseTargetSelection2, generateSessionId2, sendCdpResponse2, sendCdpEvent2, getObject2, getString2, getNumber2, getIdText2, headerValue2, getTargetInfo2, isRestrictedTarget2, isRestrictedUrl2, dataUrlDocument2, portConfig, extensionOriginsConfig, endpointForPort, RelayUnreachable, RelayRejected, Service, layerFetch, layerFetchMcp, shouldWaitForExtensionReconnect, relayBuildProblem, ensureRelay, restartRelay, extensionReconnectWaitMs, ensureExtensionConnected, stoppedRelayStatus, statusCollections, startManagedRelay };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
dataRoot
|
|
3
|
-
} from "./main-
|
|
3
|
+
} from "./main-ma25hhqh.mjs";
|
|
4
4
|
|
|
5
|
-
// src/relay
|
|
5
|
+
// src/relay/secrets.ts
|
|
6
6
|
import crypto2 from "node:crypto";
|
|
7
7
|
import fs2 from "node:fs";
|
|
8
8
|
import path2 from "node:path";
|
|
@@ -65,7 +65,7 @@ function writePrivateJsonFileSync(filePath, value, options = {}) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
// src/relay
|
|
68
|
+
// src/relay/secrets.ts
|
|
69
69
|
var relayTokenQueryParam = "opencodeBrowserToken";
|
|
70
70
|
var tokenPattern = /^[A-Za-z0-9_-]{43}$/;
|
|
71
71
|
function relayTokenPath(root = dataRoot()) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
unpackedReloadAdvice,
|
|
3
2
|
dataRoot,
|
|
4
3
|
checkoutRoot,
|
|
5
4
|
cliCommand,
|
|
6
5
|
compareVersions,
|
|
7
6
|
npmRuntime,
|
|
8
|
-
autoUpdateStatus
|
|
9
|
-
|
|
7
|
+
autoUpdateStatus,
|
|
8
|
+
unpackedReloadAdvice
|
|
9
|
+
} from "./main-ma25hhqh.mjs";
|
|
10
10
|
|
|
11
11
|
// src/update.ts
|
|
12
12
|
import { execFile, spawnSync } from "node:child_process";
|
|
@@ -312,7 +312,7 @@ function runUpdate(args, deps) {
|
|
|
312
312
|
async function runUpdateCommand2(args) {
|
|
313
313
|
const log = (line) => process.stdout.write(line + `
|
|
314
314
|
`);
|
|
315
|
-
const { runNpmUpdate } = await import("./runtime-update-
|
|
315
|
+
const { runNpmUpdate } = await import("./runtime-update-baranjc5.mjs");
|
|
316
316
|
if (await runNpmUpdate(args))
|
|
317
317
|
return;
|
|
318
318
|
if (args.includes("--check")) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isNodeError
|
|
3
|
-
} from "./main-
|
|
3
|
+
} from "./main-20ahaz2q.mjs";
|
|
4
4
|
import {
|
|
5
5
|
dataRoot
|
|
6
|
-
} from "./main-
|
|
6
|
+
} from "./main-ma25hhqh.mjs";
|
|
7
7
|
import {
|
|
8
8
|
isValidSessionId2
|
|
9
|
-
} from "./main-
|
|
9
|
+
} from "./main-0nta0a2z.mjs";
|
|
10
10
|
|
|
11
|
-
// src/session-journal.ts
|
|
11
|
+
// src/session-manager/journal.ts
|
|
12
12
|
import fs from "node:fs";
|
|
13
13
|
import path from "node:path";
|
|
14
14
|
import { Option, Schema } from "effect";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
writePrivateJsonFileSync
|
|
3
|
-
} from "./main-
|
|
3
|
+
} from "./main-20ahaz2q.mjs";
|
|
4
4
|
import {
|
|
5
5
|
dataRoot,
|
|
6
6
|
devExtensionUrl,
|
|
7
7
|
devExtensionFolder
|
|
8
|
-
} from "./main-
|
|
8
|
+
} from "./main-ma25hhqh.mjs";
|
|
9
9
|
|
|
10
|
-
// src/browser-pairing.ts
|
|
10
|
+
// src/relay/browser-pairing.ts
|
|
11
11
|
import crypto from "node:crypto";
|
|
12
12
|
import fs from "node:fs";
|
|
13
13
|
import path from "node:path";
|
|
@@ -155,7 +155,7 @@ function wrapToken(sessionKey, token) {
|
|
|
155
155
|
return Buffer.from(Buffer.from(token, "base64url").map((byte, index) => byte ^ mask[index])).toString("base64url");
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
// src/dev-extension.ts
|
|
158
|
+
// src/setup/dev-extension.ts
|
|
159
159
|
import { createHash } from "node:crypto";
|
|
160
160
|
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
161
161
|
import path2 from "node:path";
|
|
@@ -268,7 +268,7 @@ function unzip(zip) {
|
|
|
268
268
|
return entries;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
// src/relay
|
|
271
|
+
// src/relay/config.ts
|
|
272
272
|
import fs2 from "node:fs";
|
|
273
273
|
import path3 from "node:path";
|
|
274
274
|
var relayConfigPath = (root = dataRoot()) => path3.join(root, "config.json");
|