@p697/clawket 0.4.4 → 0.4.5
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/index.js +23 -12
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -208,8 +208,8 @@ function normalizeGatewayQrUrl(url) {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
// ../../packages/bridge-core/dist/pairing.js
|
|
211
|
-
var
|
|
212
|
-
var
|
|
211
|
+
var PACKAGED_DEFAULT_REGISTRY_BASE = "https://registry.clawket.ai"?.trim() ?? "";
|
|
212
|
+
var PACKAGED_DEFAULT_REGISTRY_FALLBACK_BASE = "https://clawket-registry.clawket.workers.dev"?.trim() ?? "";
|
|
213
213
|
async function pairGateway(input) {
|
|
214
214
|
const baseUrl = normalizeHttpBase(input.serverUrl);
|
|
215
215
|
const existing = readPairingConfig();
|
|
@@ -358,10 +358,12 @@ function isCloudflareChallengeResponse(response) {
|
|
|
358
358
|
function resolveCloudflareChallengeFallbackUrl(url, response) {
|
|
359
359
|
if (!isCloudflareChallengeResponse(response))
|
|
360
360
|
return null;
|
|
361
|
+
if (!PACKAGED_DEFAULT_REGISTRY_BASE || !PACKAGED_DEFAULT_REGISTRY_FALLBACK_BASE)
|
|
362
|
+
return null;
|
|
361
363
|
const requestUrl = new URL(url);
|
|
362
|
-
if (requestUrl.origin !==
|
|
364
|
+
if (requestUrl.origin !== PACKAGED_DEFAULT_REGISTRY_BASE)
|
|
363
365
|
return null;
|
|
364
|
-
return `${
|
|
366
|
+
return `${PACKAGED_DEFAULT_REGISTRY_FALLBACK_BASE}${requestUrl.pathname}${requestUrl.search}`;
|
|
365
367
|
}
|
|
366
368
|
function summarizeFailedResponse(text) {
|
|
367
369
|
const collapsed = text.replace(/\s+/g, " ").trim();
|
|
@@ -1827,7 +1829,7 @@ var BridgeRuntime = class {
|
|
|
1827
1829
|
return;
|
|
1828
1830
|
this.stopped = false;
|
|
1829
1831
|
this.updateSnapshot({ running: true, gatewayUrl: this.options.gatewayUrl });
|
|
1830
|
-
this.log(`runtime starting gatewayUrl=${redactGatewayWsUrl(this.options.gatewayUrl)}`);
|
|
1832
|
+
this.log(`runtime starting gatewayId=${this.options.config.gatewayId} instanceId=${this.options.config.instanceId} gatewayUrl=${redactGatewayWsUrl(this.options.gatewayUrl)}`);
|
|
1831
1833
|
void this.connectRelay();
|
|
1832
1834
|
}
|
|
1833
1835
|
async stop() {
|
|
@@ -2610,7 +2612,7 @@ function redactAuthorizationHeader(value) {
|
|
|
2610
2612
|
return /^Bearer\s+/i.test(trimmed) ? "Bearer <redacted>" : "<redacted>";
|
|
2611
2613
|
}
|
|
2612
2614
|
function sanitizeRuntimeLogLine(line) {
|
|
2613
|
-
return line
|
|
2615
|
+
return line;
|
|
2614
2616
|
}
|
|
2615
2617
|
function redactGatewayWsUrl(rawUrl) {
|
|
2616
2618
|
const parsed = new URL(rawUrl);
|
|
@@ -3107,7 +3109,7 @@ async function main() {
|
|
|
3107
3109
|
if ("error" in gatewayAuth) {
|
|
3108
3110
|
throw new Error(gatewayAuth.error);
|
|
3109
3111
|
}
|
|
3110
|
-
const server =
|
|
3112
|
+
const server = resolvePairServer(args);
|
|
3111
3113
|
const name = readFlag(args, "--name") ?? readFlag(args, "-n") ?? getDefaultBridgeDisplayName();
|
|
3112
3114
|
const qrFile = readFlag(args, "--qr-file");
|
|
3113
3115
|
const paired = await pairGateway({
|
|
@@ -3289,18 +3291,18 @@ async function main() {
|
|
|
3289
3291
|
config,
|
|
3290
3292
|
gatewayUrl,
|
|
3291
3293
|
onLog: (line) => {
|
|
3292
|
-
emitRuntimeLine(
|
|
3294
|
+
emitRuntimeLine(`[clawket] ${line}`);
|
|
3293
3295
|
},
|
|
3294
3296
|
onStatus: (snapshot) => {
|
|
3295
3297
|
if (snapshot.lastError) {
|
|
3296
|
-
emitRuntimeLine(
|
|
3298
|
+
emitRuntimeLine(
|
|
3297
3299
|
`[status] relay=${snapshot.relayConnected ? "up" : "down"} gateway=${snapshot.gatewayConnected ? "up" : "down"} clients=${snapshot.clientCount} error=${snapshot.lastError}`
|
|
3298
|
-
)
|
|
3300
|
+
);
|
|
3299
3301
|
return;
|
|
3300
3302
|
}
|
|
3301
|
-
emitRuntimeLine(
|
|
3303
|
+
emitRuntimeLine(
|
|
3302
3304
|
`[status] relay=${snapshot.relayConnected ? "up" : "down"} gateway=${snapshot.gatewayConnected ? "up" : "down"} clients=${snapshot.clientCount}`
|
|
3303
|
-
)
|
|
3305
|
+
);
|
|
3304
3306
|
},
|
|
3305
3307
|
onPendingPairRequest: () => {
|
|
3306
3308
|
emitRuntimeLine("[pair-request] pending");
|
|
@@ -3414,6 +3416,15 @@ function readFlag(args, name) {
|
|
|
3414
3416
|
function hasFlag(args, name) {
|
|
3415
3417
|
return args.includes(name);
|
|
3416
3418
|
}
|
|
3419
|
+
function resolvePairServer(args) {
|
|
3420
|
+
const explicit = readFlag(args, "--server") ?? readFlag(args, "-s");
|
|
3421
|
+
if (explicit?.trim()) return explicit;
|
|
3422
|
+
const envServer = process.env.CLAWKET_REGISTRY_URL?.trim() || "https://registry.clawket.ai"?.trim();
|
|
3423
|
+
if (envServer) return envServer;
|
|
3424
|
+
throw new Error(
|
|
3425
|
+
"No registry server configured. Pass --server https://registry.example.com or set CLAWKET_REGISTRY_URL."
|
|
3426
|
+
);
|
|
3427
|
+
}
|
|
3417
3428
|
function readPairSubcommand(args) {
|
|
3418
3429
|
for (const arg of args) {
|
|
3419
3430
|
if (!arg.startsWith("-")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@p697/clawket",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Clawket CLI for pairing and running the Relay bridge runtime",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"node": ">=20"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build:bundle": "npm run --workspace @clawket/bridge-core build && npm run --workspace @clawket/bridge-runtime build &&
|
|
21
|
+
"build:bundle": "npm run --workspace @clawket/bridge-core build && npm run --workspace @clawket/bridge-runtime build && node scripts/build-bundle.mjs",
|
|
22
22
|
"build": "npm run build:bundle",
|
|
23
23
|
"typecheck": "npm run --workspace @clawket/bridge-core build && npm run --workspace @clawket/bridge-runtime build && tsc -p tsconfig.json --noEmit",
|
|
24
24
|
"test": "npm run --workspace @clawket/bridge-core build && npm run --workspace @clawket/bridge-runtime build && vitest run --passWithNoTests",
|