mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 23:18:28 +00:00
Revert "Onboarding: fix webchat URL loopback and canonical session"
This reverts commit 59e0e7e4ff.
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import { cancel, isCancel } from "@clack/prompts";
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { inspect } from "node:util";
|
||||
import { cancel, isCancel } from "@clack/prompts";
|
||||
import { DEFAULT_AGENT_WORKSPACE_DIR, ensureAgentWorkspace } from "../agents/workspace.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import type { NodeManagerChoice, OnboardMode, ResetScope } from "./onboard-types.js";
|
||||
import { DEFAULT_AGENT_WORKSPACE_DIR, ensureAgentWorkspace } from "../agents/workspace.js";
|
||||
import { CONFIG_PATH } from "../config/config.js";
|
||||
import { resolveMainSessionKey, resolveSessionTranscriptsDirForAgent } from "../config/sessions.js";
|
||||
import { resolveSessionTranscriptsDirForAgent } from "../config/sessions.js";
|
||||
import { callGateway } from "../gateway/call.js";
|
||||
import { normalizeControlUiBasePath } from "../gateway/control-ui-shared.js";
|
||||
import { pickPrimaryLanIPv4, isValidIPv4 } from "../gateway/net.js";
|
||||
@@ -14,7 +16,6 @@ import { isSafeExecutableValue } from "../infra/exec-safety.js";
|
||||
import { pickPrimaryTailnetIPv4 } from "../infra/tailnet.js";
|
||||
import { isWSL } from "../infra/wsl.js";
|
||||
import { runCommandWithTimeout } from "../process/exec.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { stylePromptTitle } from "../terminal/prompt-style.js";
|
||||
import {
|
||||
CONFIG_DIR,
|
||||
@@ -25,7 +26,6 @@ import {
|
||||
} from "../utils.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
||||
import { VERSION } from "../version.js";
|
||||
import type { NodeManagerChoice, OnboardMode, ResetScope } from "./onboard-types.js";
|
||||
|
||||
export function guardCancel<T>(value: T | symbol, runtime: RuntimeEnv): T {
|
||||
if (isCancel(value)) {
|
||||
@@ -454,17 +454,12 @@ function summarizeError(err: unknown): string {
|
||||
|
||||
export const DEFAULT_WORKSPACE = DEFAULT_AGENT_WORKSPACE_DIR;
|
||||
|
||||
type ControlUiLinksParams = {
|
||||
export function resolveControlUiLinks(params: {
|
||||
port: number;
|
||||
bind?: "auto" | "lan" | "loopback" | "custom" | "tailnet";
|
||||
customBindHost?: string;
|
||||
basePath?: string;
|
||||
};
|
||||
|
||||
export function resolveControlUiLinks(params: ControlUiLinksParams): {
|
||||
httpUrl: string;
|
||||
wsUrl: string;
|
||||
} {
|
||||
}): { httpUrl: string; wsUrl: string } {
|
||||
const port = params.port;
|
||||
const bind = params.bind ?? "loopback";
|
||||
const customBindHost = params.customBindHost?.trim();
|
||||
@@ -489,39 +484,3 @@ export function resolveControlUiLinks(params: ControlUiLinksParams): {
|
||||
wsUrl: `ws://${host}:${port}${wsPath}`,
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveLocalBrowserControlUiLinks(params: ControlUiLinksParams): {
|
||||
httpUrl: string;
|
||||
wsUrl: string;
|
||||
} {
|
||||
const bind = params.bind === "lan" ? "loopback" : params.bind;
|
||||
return resolveControlUiLinks({
|
||||
...params,
|
||||
bind,
|
||||
});
|
||||
}
|
||||
|
||||
export function resolveCanonicalMainSessionKey(cfg: OpenClawConfig): string {
|
||||
return resolveMainSessionKey(cfg);
|
||||
}
|
||||
|
||||
export function buildWebchatUrl(params: {
|
||||
httpUrl: string;
|
||||
sessionKey: string;
|
||||
token?: string;
|
||||
}): string {
|
||||
const base = new URL(params.httpUrl);
|
||||
if (!base.pathname.endsWith("/")) {
|
||||
base.pathname = `${base.pathname}/`;
|
||||
}
|
||||
|
||||
const chatUrl = new URL("chat", base);
|
||||
chatUrl.searchParams.set("session", params.sessionKey.trim());
|
||||
|
||||
const token = params.token?.trim();
|
||||
if (token) {
|
||||
chatUrl.hash = `token=${encodeURIComponent(token)}`;
|
||||
}
|
||||
|
||||
return chatUrl.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user