Files
bot/scripts/dev/gateway-smoke.ts
zeekay 0adcec2df7 rebrand: complete openclaw → hanzo bot rename across all remaining files
Rename all openclaw/claw identifiers, file paths, docs, CI configs,
shell scripts, systemd units, Docker helpers, test fixtures, and
translation files. Remove stale clawdbot/clawhub paths. Fix pre-commit
hook for bash 3 compatibility (macOS). Zero openclaw or claw brand
references remain in the working tree.
2026-02-16 14:52:03 -08:00

76 lines
2.1 KiB
TypeScript

import { createArgReader, createGatewayWsClient, resolveGatewayUrl } from "./gateway-ws-client.ts";
const { get: getArg } = createArgReader();
const urlRaw = getArg("--url") ?? process.env.BOT_GATEWAY_URL;
const token = getArg("--token") ?? process.env.BOT_GATEWAY_TOKEN;
if (!urlRaw || !token) {
// eslint-disable-next-line no-console
console.error(
"Usage: bun scripts/dev/gateway-smoke.ts --url <wss://host[:port]> --token <gateway.auth.token>\n" +
"Or set env: BOT_GATEWAY_URL / BOT_GATEWAY_TOKEN",
);
process.exit(1);
}
async function main() {
const url = resolveGatewayUrl(urlRaw);
const { request, waitOpen, close } = createGatewayWsClient({
url: url.toString(),
onEvent: (evt) => {
// Ignore noisy connect handshakes.
if (evt.event === "connect.challenge") {
return;
}
},
});
await waitOpen();
// Match iOS "operator" session defaults: token auth, no device identity.
const connectRes = await request("connect", {
minProtocol: 3,
maxProtocol: 3,
client: {
id: "bot-ios",
displayName: "bot gateway smoke test",
version: "dev",
platform: "dev",
mode: "ui",
instanceId: "bot-dev-smoke",
},
locale: "en-US",
userAgent: "gateway-smoke",
role: "operator",
scopes: ["operator.read", "operator.write", "operator.admin"],
caps: [],
auth: { token },
});
if (!connectRes.ok) {
// eslint-disable-next-line no-console
console.error("connect failed:", connectRes.error);
process.exit(2);
}
const healthRes = await request("health");
if (!healthRes.ok) {
// eslint-disable-next-line no-console
console.error("health failed:", healthRes.error);
process.exit(3);
}
const historyRes = await request("chat.history", { sessionKey: "main" }, 15000);
if (!historyRes.ok) {
// eslint-disable-next-line no-console
console.error("chat.history failed:", historyRes.error);
process.exit(4);
}
// eslint-disable-next-line no-console
console.log("ok: connected + health + chat.history");
close();
}
await main();