@skylandnpm/octopus-proxy 0.1.65 → 0.1.66
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.
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
probeRemote,
|
|
13
13
|
remoteSessionBudget,
|
|
14
14
|
z
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-UFLXQ4HQ.js";
|
|
16
16
|
|
|
17
17
|
// ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/codegen/code.js
|
|
18
18
|
var require_code = __commonJS({
|
|
@@ -13921,17 +13921,30 @@ var TerminalManager = class {
|
|
|
13921
13921
|
import { execFile as execFile6 } from "node:child_process";
|
|
13922
13922
|
import { promisify as promisify6 } from "node:util";
|
|
13923
13923
|
import { userInfo as userInfo4 } from "node:os";
|
|
13924
|
+
import { lstat as lstat3 } from "node:fs/promises";
|
|
13924
13925
|
var exec = promisify6(execFile6);
|
|
13925
13926
|
var PlatformDesktopSession = class {
|
|
13926
|
-
constructor(system = process.platform, environment = process.env, execute3 = async (args) => (await exec("loginctl", ["--no-ask-password", ...args], { timeout: 5e3, maxBuffer: 16384 })).stdout, account = userInfo4()) {
|
|
13927
|
+
constructor(x11Session = "logind", system = process.platform, environment = process.env, execute3 = async (args) => (await exec("loginctl", ["--no-ask-password", ...args], { timeout: 5e3, maxBuffer: 16384 })).stdout, account = userInfo4(), inspectSocket = lstat3) {
|
|
13928
|
+
this.x11Session = x11Session;
|
|
13927
13929
|
this.system = system;
|
|
13928
13930
|
this.environment = environment;
|
|
13929
13931
|
this.execute = execute3;
|
|
13930
13932
|
this.account = account;
|
|
13933
|
+
this.inspectSocket = inspectSocket;
|
|
13931
13934
|
}
|
|
13932
13935
|
async sessionIdentity() {
|
|
13933
13936
|
if (this.system === "darwin") return String(this.account.uid);
|
|
13934
13937
|
if (this.system !== "linux") throw new Error("\u6B64\u5E73\u53F0\u4E0D\u652F\u6301\u8FDC\u7A0B\u684C\u9762\u4F1A\u8BDD");
|
|
13938
|
+
if (this.x11Session === "standalone") {
|
|
13939
|
+
const display = /^(?:unix)?:([0-9]+)(?:\.([0-9]+))?$/.exec(this.environment.DISPLAY ?? "");
|
|
13940
|
+
if (!display || this.account.uid === 0 || this.environment.WAYLAND_DISPLAY || this.environment.XDG_SESSION_TYPE === "wayland") throw new Error("\u72EC\u7ACB X11 \u8FDC\u63A7\u9700\u8981\u975E root \u7528\u6237\u548C\u672C\u5730 DISPLAY\uFF08\u5982 :99\uFF09\uFF0C\u4E0D\u652F\u6301 Wayland \u6216\u8FDC\u7A0B X11");
|
|
13941
|
+
const path = `/tmp/.X11-unix/X${Number(display[1])}`;
|
|
13942
|
+
const socket = await this.inspectSocket(path).catch(() => {
|
|
13943
|
+
throw new Error(`\u72EC\u7ACB X11 socket \u4E0D\u53EF\u7528\uFF1A${path}\uFF1B\u8BF7\u5148\u542F\u52A8 Xvfb/\u684C\u9762\u670D\u52A1`);
|
|
13944
|
+
});
|
|
13945
|
+
if (!socket.isSocket()) throw new Error(`\u72EC\u7ACB X11 \u8DEF\u5F84\u4E0D\u662F socket\uFF1A${path}`);
|
|
13946
|
+
return `x11:${this.account.uid}:${Number(display[1])}.${Number(display[2] ?? 0)}:${socket.dev}:${socket.ino}:${socket.ctimeMs}`;
|
|
13947
|
+
}
|
|
13935
13948
|
const ids = this.environment.XDG_SESSION_ID ? [this.environment.XDG_SESSION_ID] : (await this.execute(["list-sessions", "--no-legend"])).trim().split("\n").map((line) => line.trim().split(/\s+/)[0]).filter(Boolean);
|
|
13936
13949
|
const sessions = [];
|
|
13937
13950
|
for (const id of ids) {
|
|
@@ -14044,6 +14057,7 @@ var RemoteManager = class {
|
|
|
14044
14057
|
const permissions = await this.probe(this.host.stateDirectory, this.config);
|
|
14045
14058
|
const lockUnsupported = permissions.locked === true && permissions.lockCapture === false;
|
|
14046
14059
|
const available = permissions.session && permissions.capture && permissions.input && !lockUnsupported;
|
|
14060
|
+
if (available) await this.desktopSession.sessionIdentity();
|
|
14047
14061
|
return { ...base, available, permissions, ...!available ? { message: lockUnsupported ? "\u9501\u5C4F\u8FDC\u63A7\u9700\u8981 macOS 14 \u53CA\u4EE5\u4E0A\u53CA\u65B0\u7248 Xcode Command Line Tools\uFF1B\u5F53\u524D\u4E3B\u673A\u8BF7\u5148\u672C\u5730\u89E3\u9501" : "\u8BF7\u68C0\u67E5\u4E3B\u673A\u56FE\u5F62\u4F1A\u8BDD\uFF0C\u5E76\u4E3A\u5B9E\u9645\u8FD0\u884C Proxy \u7684\u7A0B\u5E8F\u6388\u6743\u5C4F\u5E55\u5F55\u5236\u548C\u8F85\u52A9\u529F\u80FD" } : {} };
|
|
14048
14062
|
} catch (error) {
|
|
14049
14063
|
return { ...base, available: false, message: error instanceof Error ? error.message : "\u8FDC\u63A7\u4F9D\u8D56\u4E0D\u53EF\u7528" };
|
|
@@ -14369,7 +14383,7 @@ async function runDaemon(configPath, authenticate = verifyHostPassword) {
|
|
|
14369
14383
|
secureChat?.publish(projectId, event, data);
|
|
14370
14384
|
}
|
|
14371
14385
|
const terminals = new TerminalManager(workspace, (owner, project, event, data) => secureChat?.sendTo(owner, project, event, data));
|
|
14372
|
-
const desktopBackend = new PlatformDesktop(config.stateDirectory), desktopSession = new PlatformDesktopSession();
|
|
14386
|
+
const desktopBackend = new PlatformDesktop(config.stateDirectory), desktopSession = new PlatformDesktopSession(config.desktopRemote?.x11Session);
|
|
14373
14387
|
const desktop = new DesktopManager(desktopBackend);
|
|
14374
14388
|
const remote = new RemoteManager(
|
|
14375
14389
|
config,
|
|
@@ -4104,7 +4104,8 @@ var RemoteConfigSchema = z.object({
|
|
|
4104
4104
|
stunUrls: z.array(stunUrl).min(1).max(4).optional(),
|
|
4105
4105
|
totalBitrate: z.number().int().min(1e5).max(REMOTE_DEFAULTS.totalBitrate).default(REMOTE_DEFAULTS.totalBitrate),
|
|
4106
4106
|
videoMaxBitrate: z.number().int().min(5e4).max(REMOTE_DEFAULTS.videoMaxBitrate).default(REMOTE_DEFAULTS.videoMaxBitrate),
|
|
4107
|
-
ffmpeg: z.string().min(1).default("ffmpeg")
|
|
4107
|
+
ffmpeg: z.string().min(1).default("ffmpeg"),
|
|
4108
|
+
x11Session: z.enum(["logind", "standalone"]).default("logind")
|
|
4108
4109
|
}).strict().refine((c) => c.videoMaxBitrate <= c.totalBitrate * 0.8, "\u89C6\u9891\u989D\u5EA6\u4E0D\u5F97\u8D85\u8FC7\u603B\u9884\u7B97\u7684 80%");
|
|
4109
4110
|
function remoteSessionBudget(config, quality, legacy = false) {
|
|
4110
4111
|
const profile = legacy ? REMOTE_LEGACY_PROFILE : REMOTE_QUALITY_PROFILES[quality];
|
|
@@ -4456,8 +4457,12 @@ import { join as join2 } from "node:path";
|
|
|
4456
4457
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
4457
4458
|
import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
|
|
4458
4459
|
var exec = promisify2(execFile2);
|
|
4459
|
-
function
|
|
4460
|
-
|
|
4460
|
+
function remotePlatformError(system = process.platform, arch = process.arch, env = process.env) {
|
|
4461
|
+
if (!["darwin", "linux"].includes(system) || !["arm64", "x64"].includes(arch)) return `\u8FDC\u63A7\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0 ${system}/${arch}\uFF1B\u9700\u8981 macOS 12.3+ \u6216 Linux X11\uFF08x64/ARM64\uFF09`;
|
|
4462
|
+
if (system === "linux") {
|
|
4463
|
+
if (env.WAYLAND_DISPLAY || env.XDG_SESSION_TYPE === "wayland") return "\u8FDC\u63A7\u6682\u4E0D\u652F\u6301 Wayland\uFF0C\u8BF7\u4F7F\u7528 X11 \u684C\u9762\u4F1A\u8BDD";
|
|
4464
|
+
if (!env.DISPLAY) return "Proxy \u672A\u8FDE\u63A5 X11 \u56FE\u5F62\u4F1A\u8BDD\uFF1B\u8BF7\u4E3A\u5B9E\u9645\u8FD0\u884C Proxy \u7684\u670D\u52A1\u8BBE\u7F6E\u684C\u9762\u7528\u6237\u7684 DISPLAY \u548C XAUTHORITY\uFF0C\u5BB9\u5668\u4E2D\u8BF7\u5148\u542F\u52A8 Xvfb/\u684C\u9762\u670D\u52A1";
|
|
4465
|
+
}
|
|
4461
4466
|
}
|
|
4462
4467
|
async function ensureRemoteHelper(stateDirectory) {
|
|
4463
4468
|
await mkdir2(stateDirectory, { recursive: true, mode: 448 });
|
|
@@ -4485,7 +4490,8 @@ async function ensureRemoteHelper(stateDirectory) {
|
|
|
4485
4490
|
}
|
|
4486
4491
|
}
|
|
4487
4492
|
async function probeRemote(stateDirectory, config) {
|
|
4488
|
-
|
|
4493
|
+
const platformError = remotePlatformError();
|
|
4494
|
+
if (platformError) throw new Error(platformError);
|
|
4489
4495
|
await import("@roamhq/wrtc").catch(() => {
|
|
4490
4496
|
throw new Error("WebRTC \u539F\u751F\u4F9D\u8D56\u4E0D\u53EF\u7528\uFF0C\u8BF7\u91CD\u65B0\u5B89\u88C5\u65B0\u7248 Proxy");
|
|
4491
4497
|
});
|
package/dist/cli.js
CHANGED
|
@@ -35,13 +35,13 @@ import {
|
|
|
35
35
|
supportedPlatform,
|
|
36
36
|
systemdUnitPath,
|
|
37
37
|
toolSearchDirs
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-IV5ZGRAM.js";
|
|
39
39
|
import {
|
|
40
40
|
DESKTOP_PERMISSION_GUIDANCE,
|
|
41
41
|
PlatformDesktop,
|
|
42
42
|
checkDesktop,
|
|
43
43
|
requestDesktopPermission
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-UFLXQ4HQ.js";
|
|
45
45
|
|
|
46
46
|
// src/cli.ts
|
|
47
47
|
import { spawn as spawn2 } from "node:child_process";
|
|
@@ -364,7 +364,7 @@ async function runDoctor(opts) {
|
|
|
364
364
|
}
|
|
365
365
|
if (config) {
|
|
366
366
|
results.push(...await checkDesktop(config.stateDirectory));
|
|
367
|
-
const remote = new RemoteManager(config, new PlatformDesktop(config.stateDirectory), new PlatformDesktopSession(), () => {
|
|
367
|
+
const remote = new RemoteManager(config, new PlatformDesktop(config.stateDirectory), new PlatformDesktopSession(config.desktopRemote?.x11Session), () => {
|
|
368
368
|
}, () => false);
|
|
369
369
|
try {
|
|
370
370
|
const status = await remote.status();
|
package/dist/main.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import {
|
|
3
3
|
ConfigError,
|
|
4
4
|
runDaemon
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-IV5ZGRAM.js";
|
|
6
|
+
import "./chunk-UFLXQ4HQ.js";
|
|
7
7
|
|
|
8
8
|
// src/main.ts
|
|
9
9
|
runDaemon(process.env.OCTOPUS_PROXY_CONFIG ?? "proxy.json").catch((error) => {
|
package/dist/remote-worker.js
CHANGED