@gguf/claw
Version:
Multi-channel AI gateway with extensible messaging integrations
189 lines (187 loc) • 5.89 kB
JavaScript
import "./auth-profiles-DFa1zzNy.js";
import "./exec-CBKBIMpA.js";
import "./agent-scope-RzK9Zcks.js";
import "./github-copilot-token-DuFIqfeC.js";
import "./manifest-registry-DS2iK5AZ.js";
import "./config-B2kL1ciP.js";
import "./client-CDjZdZtI.js";
import "./call-DXhJGwEy.js";
import "./message-channel-CVHJDItx.js";
import "./pairing-token-Byh6drgn.js";
import "./sessions-BD5dyLxb.js";
import "./normalize-Db7Xtx2v.js";
import "./accounts-BpzwDfBB.js";
import "./bindings-KqaGKS1E.js";
import "./logging-CFvkxgcX.js";
import "./plugins-RqhjLCb6.js";
import "./accounts-B3D4iWUP.js";
import { a as findTailscaleBinary } from "./tailscale-BzRVNhMW.js";
import "./dock-BZuwgj1O.js";
import "./accounts-Jg3_1Y-r.js";
import "./paths-CXpciDEv.js";
import { h as randomToken, u as normalizeGatewayTokenInput, y as validateGatewayPasswordInput } from "./onboard-helpers-CEx2tGVB.js";
import "./prompt-style-DwCXob2h.js";
import { i as TAILSCALE_MISSING_BIN_NOTE_LINES, n as TAILSCALE_DOCS_LINES, r as TAILSCALE_EXPOSURE_OPTIONS, t as validateIPv4AddressInput } from "./ipv4-Dz51vmVq.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 };