@gguf/claw
Version:
Multi-channel AI gateway with extensible messaging integrations
195 lines (193 loc) • 6.08 kB
JavaScript
import "./paths-B4BZAPZh.js";
import "./utils-CP9YLh6M.js";
import "./registry-B-j4DRfe.js";
import "./subsystem-BCQGGxdd.js";
import "./exec-DYqRzFbo.js";
import "./agent-scope-BnZW9Gh2.js";
import "./model-selection-CqaTAlhy.js";
import "./github-copilot-token-D2zp6kMZ.js";
import "./boolean-BsqeuxE6.js";
import "./env-VriqyjXT.js";
import "./message-channel-Bena1Tzd.js";
import "./config-PQiujvsf.js";
import "./manifest-registry-4k4vkhPS.js";
import { a as findTailscaleBinary } from "./tailscale-C3JsBEiY.js";
import "./sessions-Z1BZU3xh.js";
import "./dock-7F-MiPtF.js";
import "./normalize-Ci8UyR3Z.js";
import "./accounts-Bj1dJ-fd.js";
import "./accounts-DOl1Wkxo.js";
import "./accounts-t6R5_PzC.js";
import "./bindings-Dja1z-h8.js";
import "./logging-xYH6GmRT.js";
import "./plugins-CKbXkuXd.js";
import "./paths-C2NfoGZE.js";
import "./client-BdSkEtCd.js";
import "./call-BCz_8mqq.js";
import "./pairing-token-B-_eiWlR.js";
import { h as randomToken, u as normalizeGatewayTokenInput, y as validateGatewayPasswordInput } from "./onboard-helpers-DbjfBSMX.js";
import "./prompt-style-VqCNjBi8.js";
import { i as TAILSCALE_MISSING_BIN_NOTE_LINES, n as TAILSCALE_DOCS_LINES, r as TAILSCALE_EXPOSURE_OPTIONS, t as validateIPv4AddressInput } from "./ipv4-BSb3QXZR.js";
//#region src/wizard/onboarding.gateway-config.ts
const DEFAULT_DANGEROUS_NODE_DENY_COMMANDS = [
"camera.snap",
"camera.clip",
"screen.record",
"calendar.add",
"contacts.add",
"reminders.add"
];
async function configureGatewayForOnboarding(opts) {
const { flow, localPort, quickstartGateway, prompter } = opts;
let { nextConfig } = opts;
const port = flow === "quickstart" ? quickstartGateway.port : Number.parseInt(String(await prompter.text({
message: "Gateway port",
initialValue: String(localPort),
validate: (value) => Number.isFinite(Number(value)) ? void 0 : "Invalid port"
})), 10);
let bind = flow === "quickstart" ? quickstartGateway.bind : await prompter.select({
message: "Gateway bind",
options: [
{
value: "loopback",
label: "Loopback (127.0.0.1)"
},
{
value: "lan",
label: "LAN (0.0.0.0)"
},
{
value: "tailnet",
label: "Tailnet (Tailscale IP)"
},
{
value: "auto",
label: "Auto (Loopback → LAN)"
},
{
value: "custom",
label: "Custom IP"
}
]
});
let customBindHost = quickstartGateway.customBindHost;
if (bind === "custom") {
if (flow !== "quickstart" || !customBindHost) {
const input = await prompter.text({
message: "Custom IP address",
placeholder: "192.168.1.100",
initialValue: customBindHost ?? "",
validate: validateIPv4AddressInput
});
customBindHost = typeof input === "string" ? input.trim() : void 0;
}
}
let authMode = flow === "quickstart" ? quickstartGateway.authMode : await prompter.select({
message: "Gateway auth",
options: [{
value: "token",
label: "Token",
hint: "Recommended default (local + remote)"
}, {
value: "password",
label: "Password"
}],
initialValue: "token"
});
const tailscaleMode = flow === "quickstart" ? quickstartGateway.tailscaleMode : await prompter.select({
message: "Tailscale exposure",
options: [...TAILSCALE_EXPOSURE_OPTIONS]
});
if (tailscaleMode !== "off") {
if (!await findTailscaleBinary()) await prompter.note(TAILSCALE_MISSING_BIN_NOTE_LINES.join("\n"), "Tailscale Warning");
}
let tailscaleResetOnExit = flow === "quickstart" ? quickstartGateway.tailscaleResetOnExit : false;
if (tailscaleMode !== "off" && flow !== "quickstart") {
await prompter.note(TAILSCALE_DOCS_LINES.join("\n"), "Tailscale");
tailscaleResetOnExit = Boolean(await prompter.confirm({
message: "Reset Tailscale serve/funnel on exit?",
initialValue: false
}));
}
if (tailscaleMode !== "off" && bind !== "loopback") {
await prompter.note("Tailscale requires bind=loopback. Adjusting bind to loopback.", "Note");
bind = "loopback";
customBindHost = void 0;
}
if (tailscaleMode === "funnel" && authMode !== "password") {
await prompter.note("Tailscale funnel requires password auth.", "Note");
authMode = "password";
}
let gatewayToken;
if (authMode === "token") if (flow === "quickstart") gatewayToken = quickstartGateway.token ?? randomToken();
else gatewayToken = normalizeGatewayTokenInput(await prompter.text({
message: "Gateway token (blank to generate)",
placeholder: "Needed for multi-machine or non-loopback access",
initialValue: quickstartGateway.token ?? ""
})) || randomToken();
if (authMode === "password") {
const password = flow === "quickstart" && quickstartGateway.password ? quickstartGateway.password : await prompter.text({
message: "Gateway password",
validate: validateGatewayPasswordInput
});
nextConfig = {
...nextConfig,
gateway: {
...nextConfig.gateway,
auth: {
...nextConfig.gateway?.auth,
mode: "password",
password: String(password ?? "").trim()
}
}
};
} else if (authMode === "token") nextConfig = {
...nextConfig,
gateway: {
...nextConfig.gateway,
auth: {
...nextConfig.gateway?.auth,
mode: "token",
token: gatewayToken
}
}
};
nextConfig = {
...nextConfig,
gateway: {
...nextConfig.gateway,
port,
bind,
...bind === "custom" && customBindHost ? { customBindHost } : {},
tailscale: {
...nextConfig.gateway?.tailscale,
mode: tailscaleMode,
resetOnExit: tailscaleResetOnExit
}
}
};
if (!quickstartGateway.hasExisting && nextConfig.gateway?.nodes?.denyCommands === void 0 && nextConfig.gateway?.nodes?.allowCommands === void 0 && nextConfig.gateway?.nodes?.browser === void 0) nextConfig = {
...nextConfig,
gateway: {
...nextConfig.gateway,
nodes: {
...nextConfig.gateway?.nodes,
denyCommands: [...DEFAULT_DANGEROUS_NODE_DENY_COMMANDS]
}
}
};
return {
nextConfig,
settings: {
port,
bind,
customBindHost: bind === "custom" ? customBindHost : void 0,
authMode,
gatewayToken,
tailscaleMode,
tailscaleResetOnExit
}
};
}
//#endregion
export { configureGatewayForOnboarding };