mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 00:11:23 +00:00
refactor(gateway): share tailscale prompt constants
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
import type { OpenClawConfig } from "../config/config.js";
|
import type { OpenClawConfig } from "../config/config.js";
|
||||||
import type { RuntimeEnv } from "../runtime.js";
|
import type { RuntimeEnv } from "../runtime.js";
|
||||||
import { resolveGatewayPort } from "../config/config.js";
|
import { resolveGatewayPort } from "../config/config.js";
|
||||||
|
import {
|
||||||
|
TAILSCALE_DOCS_LINES,
|
||||||
|
TAILSCALE_EXPOSURE_OPTIONS,
|
||||||
|
TAILSCALE_MISSING_BIN_NOTE_LINES,
|
||||||
|
} from "../gateway/gateway-config-prompts.shared.js";
|
||||||
import { findTailscaleBinary } from "../infra/tailscale.js";
|
import { findTailscaleBinary } from "../infra/tailscale.js";
|
||||||
import { validateIPv4AddressInput } from "../shared/net/ipv4.js";
|
import { validateIPv4AddressInput } from "../shared/net/ipv4.js";
|
||||||
import { note } from "../terminal/note.js";
|
import { note } from "../terminal/note.js";
|
||||||
@@ -100,19 +105,7 @@ export async function promptGatewayConfig(
|
|||||||
let tailscaleMode = guardCancel(
|
let tailscaleMode = guardCancel(
|
||||||
await select({
|
await select({
|
||||||
message: "Tailscale exposure",
|
message: "Tailscale exposure",
|
||||||
options: [
|
options: [...TAILSCALE_EXPOSURE_OPTIONS],
|
||||||
{ value: "off", label: "Off", hint: "No Tailscale exposure" },
|
|
||||||
{
|
|
||||||
value: "serve",
|
|
||||||
label: "Serve",
|
|
||||||
hint: "Private HTTPS for your tailnet (devices on Tailscale)",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: "funnel",
|
|
||||||
label: "Funnel",
|
|
||||||
hint: "Public HTTPS via Tailscale Funnel (internet)",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}),
|
}),
|
||||||
runtime,
|
runtime,
|
||||||
);
|
);
|
||||||
@@ -121,27 +114,13 @@ export async function promptGatewayConfig(
|
|||||||
if (tailscaleMode !== "off") {
|
if (tailscaleMode !== "off") {
|
||||||
const tailscaleBin = await findTailscaleBinary();
|
const tailscaleBin = await findTailscaleBinary();
|
||||||
if (!tailscaleBin) {
|
if (!tailscaleBin) {
|
||||||
note(
|
note(TAILSCALE_MISSING_BIN_NOTE_LINES.join("\n"), "Tailscale Warning");
|
||||||
[
|
|
||||||
"Tailscale binary not found in PATH or /Applications.",
|
|
||||||
"Ensure Tailscale is installed from:",
|
|
||||||
" https://tailscale.com/download/mac",
|
|
||||||
"",
|
|
||||||
"You can continue setup, but serve/funnel will fail at runtime.",
|
|
||||||
].join("\n"),
|
|
||||||
"Tailscale Warning",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let tailscaleResetOnExit = false;
|
let tailscaleResetOnExit = false;
|
||||||
if (tailscaleMode !== "off") {
|
if (tailscaleMode !== "off") {
|
||||||
note(
|
note(TAILSCALE_DOCS_LINES.join("\n"), "Tailscale");
|
||||||
["Docs:", "https://docs.openclaw.ai/gateway/tailscale", "https://docs.openclaw.ai/web"].join(
|
|
||||||
"\n",
|
|
||||||
),
|
|
||||||
"Tailscale",
|
|
||||||
);
|
|
||||||
tailscaleResetOnExit = Boolean(
|
tailscaleResetOnExit = Boolean(
|
||||||
guardCancel(
|
guardCancel(
|
||||||
await confirm({
|
await confirm({
|
||||||
|
|||||||
27
src/gateway/gateway-config-prompts.shared.ts
Normal file
27
src/gateway/gateway-config-prompts.shared.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
export const TAILSCALE_EXPOSURE_OPTIONS = [
|
||||||
|
{ value: "off", label: "Off", hint: "No Tailscale exposure" },
|
||||||
|
{
|
||||||
|
value: "serve",
|
||||||
|
label: "Serve",
|
||||||
|
hint: "Private HTTPS for your tailnet (devices on Tailscale)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "funnel",
|
||||||
|
label: "Funnel",
|
||||||
|
hint: "Public HTTPS via Tailscale Funnel (internet)",
|
||||||
|
},
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export const TAILSCALE_MISSING_BIN_NOTE_LINES = [
|
||||||
|
"Tailscale binary not found in PATH or /Applications.",
|
||||||
|
"Ensure Tailscale is installed from:",
|
||||||
|
" https://tailscale.com/download/mac",
|
||||||
|
"",
|
||||||
|
"You can continue setup, but serve/funnel will fail at runtime.",
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export const TAILSCALE_DOCS_LINES = [
|
||||||
|
"Docs:",
|
||||||
|
"https://docs.openclaw.ai/gateway/tailscale",
|
||||||
|
"https://docs.openclaw.ai/web",
|
||||||
|
] as const;
|
||||||
@@ -12,6 +12,11 @@ import {
|
|||||||
randomToken,
|
randomToken,
|
||||||
validateGatewayPasswordInput,
|
validateGatewayPasswordInput,
|
||||||
} from "../commands/onboard-helpers.js";
|
} from "../commands/onboard-helpers.js";
|
||||||
|
import {
|
||||||
|
TAILSCALE_DOCS_LINES,
|
||||||
|
TAILSCALE_EXPOSURE_OPTIONS,
|
||||||
|
TAILSCALE_MISSING_BIN_NOTE_LINES,
|
||||||
|
} from "../gateway/gateway-config-prompts.shared.js";
|
||||||
import { findTailscaleBinary } from "../infra/tailscale.js";
|
import { findTailscaleBinary } from "../infra/tailscale.js";
|
||||||
import { validateIPv4AddressInput } from "../shared/net/ipv4.js";
|
import { validateIPv4AddressInput } from "../shared/net/ipv4.js";
|
||||||
|
|
||||||
@@ -113,46 +118,20 @@ export async function configureGatewayForOnboarding(
|
|||||||
? quickstartGateway.tailscaleMode
|
? quickstartGateway.tailscaleMode
|
||||||
: await prompter.select<GatewayWizardSettings["tailscaleMode"]>({
|
: await prompter.select<GatewayWizardSettings["tailscaleMode"]>({
|
||||||
message: "Tailscale exposure",
|
message: "Tailscale exposure",
|
||||||
options: [
|
options: [...TAILSCALE_EXPOSURE_OPTIONS],
|
||||||
{ value: "off", label: "Off", hint: "No Tailscale exposure" },
|
|
||||||
{
|
|
||||||
value: "serve",
|
|
||||||
label: "Serve",
|
|
||||||
hint: "Private HTTPS for your tailnet (devices on Tailscale)",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: "funnel",
|
|
||||||
label: "Funnel",
|
|
||||||
hint: "Public HTTPS via Tailscale Funnel (internet)",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Detect Tailscale binary before proceeding with serve/funnel setup.
|
// Detect Tailscale binary before proceeding with serve/funnel setup.
|
||||||
if (tailscaleMode !== "off") {
|
if (tailscaleMode !== "off") {
|
||||||
const tailscaleBin = await findTailscaleBinary();
|
const tailscaleBin = await findTailscaleBinary();
|
||||||
if (!tailscaleBin) {
|
if (!tailscaleBin) {
|
||||||
await prompter.note(
|
await prompter.note(TAILSCALE_MISSING_BIN_NOTE_LINES.join("\n"), "Tailscale Warning");
|
||||||
[
|
|
||||||
"Tailscale binary not found in PATH or /Applications.",
|
|
||||||
"Ensure Tailscale is installed from:",
|
|
||||||
" https://tailscale.com/download/mac",
|
|
||||||
"",
|
|
||||||
"You can continue setup, but serve/funnel will fail at runtime.",
|
|
||||||
].join("\n"),
|
|
||||||
"Tailscale Warning",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let tailscaleResetOnExit = flow === "quickstart" ? quickstartGateway.tailscaleResetOnExit : false;
|
let tailscaleResetOnExit = flow === "quickstart" ? quickstartGateway.tailscaleResetOnExit : false;
|
||||||
if (tailscaleMode !== "off" && flow !== "quickstart") {
|
if (tailscaleMode !== "off" && flow !== "quickstart") {
|
||||||
await prompter.note(
|
await prompter.note(TAILSCALE_DOCS_LINES.join("\n"), "Tailscale");
|
||||||
["Docs:", "https://docs.openclaw.ai/gateway/tailscale", "https://docs.openclaw.ai/web"].join(
|
|
||||||
"\n",
|
|
||||||
),
|
|
||||||
"Tailscale",
|
|
||||||
);
|
|
||||||
tailscaleResetOnExit = Boolean(
|
tailscaleResetOnExit = Boolean(
|
||||||
await prompter.confirm({
|
await prompter.confirm({
|
||||||
message: "Reset Tailscale serve/funnel on exit?",
|
message: "Reset Tailscale serve/funnel on exit?",
|
||||||
|
|||||||
Reference in New Issue
Block a user