@evandu/super-pi 0.1.269 → 0.1.271

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.
@@ -8,9 +8,9 @@
8
8
  <link rel="alternate icon" href="/favicon.ico" />
9
9
  <link rel="apple-touch-icon" href="/favicon.svg" />
10
10
  <title>Super Pi</title>
11
- <script type="module" crossorigin src="/assets/index-BFA-1fpt.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-CoLvWsuI.js"></script>
12
12
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
13
- <link rel="stylesheet" crossorigin href="/assets/index-Cl8iehsn.css">
13
+ <link rel="stylesheet" crossorigin href="/assets/index-DV3qc1Hh.css">
14
14
  </head>
15
15
  <body>
16
16
  <div id="root"></div>
@@ -411,6 +411,10 @@ export function createHttpServer(options) {
411
411
  return;
412
412
  }
413
413
  browserAccess.authorize(request);
414
+ if (process.env.SUPER_PI_REQUIRE_BROWSER_ACCESS === "1" && !isLoopbackAddress(request.socket.remoteAddress) && !isBrowserAuthorized(request)) {
415
+ response.writeHead(401, { "content-type": "application/json" }).end(JSON.stringify({ error: "远程访问需要服务器连接密钥。" }));
416
+ return;
417
+ }
414
418
  // Tool REGISTRATION is checked after its JSON body is parsed: an agent proves its turn capability
415
419
  // there, while an interactive browser uses the ordinary server access token. Reading and DELETING
416
420
  // the registry have no such second channel, so they are NOT exempted here and fall through to the
@@ -4,6 +4,6 @@ import type { ServiceProbe } from "../shared/managed-servers.js";
4
4
  export declare function serviceOrigin(value: string): string;
5
5
  export declare function defaultServiceOrigin(host: string, port: number): string;
6
6
  export declare function probeServiceEndpoint(origin: string, key?: string): Promise<ServiceProbe>;
7
- export declare function directJson(origin: string, path: string, key: string): Promise<Record<string, unknown>>;
7
+ export declare function directJson(origin: string, path: string, key: string, method?: string): Promise<Record<string, unknown>>;
8
8
  export declare function proxyThroughDirect(origin: string, key: string, path: string, request: IncomingMessage, response: ServerResponse, basePath: string): void;
9
9
  export declare function proxyWebSocketThroughDirect(origin: string, key: string, path: string, request: IncomingMessage, socket: Duplex, head: Buffer): void;
@@ -36,8 +36,8 @@ export async function probeServiceEndpoint(origin, key = "") {
36
36
  return result({ reachable: false, service: false, authorized: false, message: "未能连接此服务端口。请检查 IP、端口、服务监听地址、防火墙或 TLS 配置;本次未尝试 SSH。" });
37
37
  }
38
38
  }
39
- export async function directJson(origin, path, key) {
40
- const response = await fetch(new URL(path, origin), { headers: { authorization: `Bearer ${key}` }, signal: AbortSignal.timeout(5000), redirect: "error" });
39
+ export async function directJson(origin, path, key, method = "GET") {
40
+ const response = await fetch(new URL(path, origin), { method, headers: { authorization: `Bearer ${key}` }, signal: AbortSignal.timeout(5000), redirect: "error" });
41
41
  if (!response.ok || !response.headers.get("content-type")?.includes("application/json"))
42
42
  throw new Error(`Super Pi 服务直连检测失败(HTTP ${response.status})`);
43
43
  const value = await response.json();
@@ -43,7 +43,7 @@ export async function tunnelJson(client, port, path, key, method = "GET") {
43
43
  });
44
44
  const timeout = setTimeout(() => request.destroy(new Error("远端服务响应超时")), 12_000);
45
45
  request.once("close", () => clearTimeout(timeout));
46
- request.once("error", () => { agent.destroy(); reject(new Error("SSH 已连接,但远端 Super Pi 服务不可达")); });
46
+ request.once("error", () => { agent.destroy(); reject(new Error("SSH 隧道无法访问远端 Super Pi 端口")); });
47
47
  request.end();
48
48
  });
49
49
  }
@@ -77,6 +77,11 @@ export async function handleManagedHttp(context, request, response, url) {
77
77
  context.managedServers.answerVerification(body.id, body.verificationId, body.answers);
78
78
  else if (body.action === "cancelVerification")
79
79
  await context.managedServers.cancelVerification(body.id, body.verificationId);
80
+ else if (body.action === "applyListener") {
81
+ if (typeof body.id !== "string")
82
+ throw new Error("请选择服务器");
83
+ await context.managedServers.applyListener(body.id, body.serviceHost);
84
+ }
80
85
  else if (body.action === "updateSelected") {
81
86
  if (!Array.isArray(body.updates) || body.updates.some((item) => typeof item?.id !== "string" || typeof item.version !== "string"))
82
87
  throw new Error("更新目标无效");
@@ -14,6 +14,7 @@ export declare class ManagedServers {
14
14
  private readonly verifications;
15
15
  private readonly authBlocked;
16
16
  private readonly jobs;
17
+ private readonly tunneledRequests;
17
18
  private readonly recoveries;
18
19
  private readonly vault;
19
20
  private readonly gateway;
@@ -45,8 +46,13 @@ export declare class ManagedServers {
45
46
  deployedAt?: string;
46
47
  remoteRoot?: string;
47
48
  serviceUrl?: string;
49
+ allowServiceTunnel?: boolean;
48
50
  transport?: "direct" | "ssh";
49
51
  serviceError?: string;
52
+ sshError?: string;
53
+ modelError?: string;
54
+ serviceHost?: import("../shared/managed-servers.js").ServiceListenHost;
55
+ deployedServiceHost?: import("../shared/managed-servers.js").ServiceListenHost;
50
56
  ssh: "offline" | "connecting" | "online" | "needsTrust" | "awaitingVerification";
51
57
  service: "unknown" | "offline" | "online";
52
58
  modelChannel: "offline" | "online";
@@ -78,13 +84,17 @@ export declare class ManagedServers {
78
84
  connect(id: string): Promise<Client>;
79
85
  private openConnection;
80
86
  private reverseModelChannel;
81
- syncModels(id: string, force?: boolean): Promise<void>;
87
+ private restoreModelChannel;
88
+ private serviceJson;
89
+ syncModels(id: string, force?: boolean, reload?: boolean): Promise<void>;
82
90
  private health;
83
91
  private checkDirect;
84
92
  private detectExisting;
93
+ private discoverExisting;
85
94
  private startExisting;
86
95
  private ensureService;
87
96
  private progress;
97
+ preparePackage(): Promise<any>;
88
98
  deploy(id: string, updateVersion?: string): ManagedServerProfile;
89
99
  updateSelected(updates: {
90
100
  id: string;
@@ -94,6 +104,7 @@ export declare class ManagedServers {
94
104
  errors: Record<string, string>;
95
105
  };
96
106
  waitForUpdates(ids: string[]): Promise<void>;
107
+ applyListener(id: string, host: unknown): Promise<ManagedServerProfile>;
97
108
  action(id: string, action: string): Promise<ManagedServerProfile | undefined>;
98
109
  private maintain;
99
110
  connectionProfiles(): {
@@ -108,6 +119,8 @@ export declare class ManagedServers {
108
119
  identity: string | undefined;
109
120
  revision: number;
110
121
  }[];
122
+ private trackServiceTunnel;
123
+ private closeServiceTunnel;
111
124
  proxy(id: string, path: string, request: IncomingMessage, response: ServerResponse): void;
112
125
  upgrade(id: string, path: string, request: IncomingMessage, socket: Duplex, head: Buffer): Promise<void>;
113
126
  close(): Promise<void>;