@fangyb/ahchat-bridge 0.1.22 → 0.1.23
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.
- package/dist/cli.cjs +17 -5
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -50926,6 +50926,18 @@ function resolveUserPath(input) {
|
|
|
50926
50926
|
}
|
|
50927
50927
|
return import_node_path11.default.isAbsolute(value) ? import_node_path11.default.normalize(value) : import_node_path11.default.resolve(value);
|
|
50928
50928
|
}
|
|
50929
|
+
function assertBridgeUserSlug(user) {
|
|
50930
|
+
const value = user.trim();
|
|
50931
|
+
if (!/^[A-Za-z0-9_-]+$/.test(value)) {
|
|
50932
|
+
throw new Error('Bridge --user may only contain letters, numbers, "_" and "-"');
|
|
50933
|
+
}
|
|
50934
|
+
return value;
|
|
50935
|
+
}
|
|
50936
|
+
function resolveBridgeDataDir(opts) {
|
|
50937
|
+
if (opts.dataDir) return resolveUserPath(opts.dataDir);
|
|
50938
|
+
if (opts.user) return resolveUserPath(`~/.ahchat/users/${assertBridgeUserSlug(opts.user)}`);
|
|
50939
|
+
return void 0;
|
|
50940
|
+
}
|
|
50929
50941
|
function normalizeBridgeServerUrls(rawUrl) {
|
|
50930
50942
|
const url2 = new URL(rawUrl);
|
|
50931
50943
|
if (url2.protocol === "http:" || url2.protocol === "https:") {
|
|
@@ -52816,7 +52828,7 @@ function readCliVersion() {
|
|
|
52816
52828
|
logger30.warn("Unable to read CLI package version candidate", { error: e7, candidate });
|
|
52817
52829
|
}
|
|
52818
52830
|
}
|
|
52819
|
-
return "0.1.
|
|
52831
|
+
return "0.1.23";
|
|
52820
52832
|
}
|
|
52821
52833
|
function parseAhchatUrl(url2) {
|
|
52822
52834
|
try {
|
|
@@ -52846,7 +52858,7 @@ function assertSupportedNode() {
|
|
|
52846
52858
|
async function run(args) {
|
|
52847
52859
|
assertSupportedNode();
|
|
52848
52860
|
process.env.PATH = buildAugmentedPath();
|
|
52849
|
-
const dataDir =
|
|
52861
|
+
const dataDir = resolveBridgeDataDir(args);
|
|
52850
52862
|
let config2 = loadBridgeConfig(dataDir ? { dataDir } : void 0);
|
|
52851
52863
|
if (args.serverUrl) {
|
|
52852
52864
|
const urls = normalizeBridgeServerUrls(args.serverUrl);
|
|
@@ -52876,7 +52888,7 @@ function buildDoctorReport(args) {
|
|
|
52876
52888
|
npm: probeCommand("npm"),
|
|
52877
52889
|
npx: probeCommand("npx"),
|
|
52878
52890
|
claude: claude ? { ok: true, name: claude.name, path: claude.path } : { ok: false, name: "claude", message: "claude was not found on PATH" },
|
|
52879
|
-
dataDir:
|
|
52891
|
+
dataDir: resolveBridgeDataDir(args) ?? resolveUserPath("~/.ahchat"),
|
|
52880
52892
|
server,
|
|
52881
52893
|
tokenProvided: Boolean(args.token),
|
|
52882
52894
|
pathPreview: (process.env.PATH ?? "").split(import_node_path23.default.delimiter).slice(0, 12)
|
|
@@ -52923,13 +52935,13 @@ function doctor(args) {
|
|
|
52923
52935
|
writeDoctorText(report);
|
|
52924
52936
|
}
|
|
52925
52937
|
var cli = dist_default("ahchat-bridge");
|
|
52926
|
-
cli.command("run", "Start the bridge and connect to server").option("--server-url <url>", "WebSocket URL of the AHChat server").option("--token <token>", "Auth token for server registration").option("--data-dir <dir>", "Data directory (default: ~/.ahchat)").option("--log-level <level>", "Log level (default: INFO)").action((args) => {
|
|
52938
|
+
cli.command("run", "Start the bridge and connect to server").option("--server-url <url>", "WebSocket URL of the AHChat server").option("--token <token>", "Auth token for server registration").option("--user <slug>", "User data-dir slug; derives ~/.ahchat/users/<slug>").option("--data-dir <dir>", "Data directory (default: ~/.ahchat)").option("--log-level <level>", "Log level (default: INFO)").action((args) => {
|
|
52927
52939
|
void run(args).catch((e7) => {
|
|
52928
52940
|
logger30.error("Bridge failed to start", { error: e7 });
|
|
52929
52941
|
process.exit(1);
|
|
52930
52942
|
});
|
|
52931
52943
|
});
|
|
52932
|
-
cli.command("doctor", "Check Node, npm, Claude CLI, PATH, and bridge launch options").option("--server-url <url>", "WebSocket URL of the AHChat server").option("--token <token>", "Auth token for server registration").option("--data-dir <dir>", "Data directory (default: ~/.ahchat)").option("--json", "Print machine-readable JSON").action((args) => {
|
|
52944
|
+
cli.command("doctor", "Check Node, npm, Claude CLI, PATH, and bridge launch options").option("--server-url <url>", "WebSocket URL of the AHChat server").option("--token <token>", "Auth token for server registration").option("--user <slug>", "User data-dir slug; derives ~/.ahchat/users/<slug>").option("--data-dir <dir>", "Data directory (default: ~/.ahchat)").option("--json", "Print machine-readable JSON").action((args) => {
|
|
52933
52945
|
doctor(args);
|
|
52934
52946
|
});
|
|
52935
52947
|
cli.command("launch", "Launch bridge from ahchat:// URL (called by OS)").option("--url <url>", "ahchat:// URL with server and token params").action((args) => {
|