@xmoxmo/bncr 0.1.2 → 0.1.3

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/index.ts CHANGED
@@ -1,7 +1,7 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
1
  import { execFileSync } from 'node:child_process';
2
+ import fs from 'node:fs';
4
3
  import { createRequire } from 'node:module';
4
+ import path from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { BncrConfigSchema } from './src/core/config-schema.ts';
7
7
 
@@ -121,9 +121,7 @@ const collectOpenClawCandidates = () => {
121
121
  }
122
122
 
123
123
  const packageRoots = unique(
124
- directCandidates
125
- .map((candidate) => findOpenClawPackageRoot(candidate))
126
- .filter(Boolean),
124
+ directCandidates.map((candidate) => findOpenClawPackageRoot(candidate)).filter(Boolean),
127
125
  );
128
126
 
129
127
  return packageRoots.filter((candidate) => {
@@ -285,7 +283,9 @@ const plugin = {
285
283
  api.logger.info?.(...args);
286
284
  };
287
285
 
288
- debugLog(`bncr plugin register begin bridge=${bridge.getBridgeId?.() || 'unknown'} created=${created}`);
286
+ debugLog(
287
+ `bncr plugin register begin bridge=${bridge.getBridgeId?.() || 'unknown'} created=${created}`,
288
+ );
289
289
  if (!created) debugLog('bncr bridge api rebound');
290
290
 
291
291
  const resolveDebug = async () => {
@@ -320,16 +320,61 @@ const plugin = {
320
320
  debugLog('bncr register channel skip (already registered on this api)');
321
321
  }
322
322
 
323
- ensureGatewayMethodRegistered(api, 'bncr.connect', (opts) => bridge.handleConnect(opts), debugLog);
324
- ensureGatewayMethodRegistered(api, 'bncr.inbound', (opts) => bridge.handleInbound(opts), debugLog);
325
- ensureGatewayMethodRegistered(api, 'bncr.activity', (opts) => bridge.handleActivity(opts), debugLog);
323
+ ensureGatewayMethodRegistered(
324
+ api,
325
+ 'bncr.connect',
326
+ (opts) => bridge.handleConnect(opts),
327
+ debugLog,
328
+ );
329
+ ensureGatewayMethodRegistered(
330
+ api,
331
+ 'bncr.inbound',
332
+ (opts) => bridge.handleInbound(opts),
333
+ debugLog,
334
+ );
335
+ ensureGatewayMethodRegistered(
336
+ api,
337
+ 'bncr.activity',
338
+ (opts) => bridge.handleActivity(opts),
339
+ debugLog,
340
+ );
326
341
  ensureGatewayMethodRegistered(api, 'bncr.ack', (opts) => bridge.handleAck(opts), debugLog);
327
- ensureGatewayMethodRegistered(api, 'bncr.diagnostics', (opts) => bridge.handleDiagnostics(opts), debugLog);
328
- ensureGatewayMethodRegistered(api, 'bncr.file.init', (opts) => bridge.handleFileInit(opts), debugLog);
329
- ensureGatewayMethodRegistered(api, 'bncr.file.chunk', (opts) => bridge.handleFileChunk(opts), debugLog);
330
- ensureGatewayMethodRegistered(api, 'bncr.file.complete', (opts) => bridge.handleFileComplete(opts), debugLog);
331
- ensureGatewayMethodRegistered(api, 'bncr.file.abort', (opts) => bridge.handleFileAbort(opts), debugLog);
332
- ensureGatewayMethodRegistered(api, 'bncr.file.ack', (opts) => bridge.handleFileAck(opts), debugLog);
342
+ ensureGatewayMethodRegistered(
343
+ api,
344
+ 'bncr.diagnostics',
345
+ (opts) => bridge.handleDiagnostics(opts),
346
+ debugLog,
347
+ );
348
+ ensureGatewayMethodRegistered(
349
+ api,
350
+ 'bncr.file.init',
351
+ (opts) => bridge.handleFileInit(opts),
352
+ debugLog,
353
+ );
354
+ ensureGatewayMethodRegistered(
355
+ api,
356
+ 'bncr.file.chunk',
357
+ (opts) => bridge.handleFileChunk(opts),
358
+ debugLog,
359
+ );
360
+ ensureGatewayMethodRegistered(
361
+ api,
362
+ 'bncr.file.complete',
363
+ (opts) => bridge.handleFileComplete(opts),
364
+ debugLog,
365
+ );
366
+ ensureGatewayMethodRegistered(
367
+ api,
368
+ 'bncr.file.abort',
369
+ (opts) => bridge.handleFileAbort(opts),
370
+ debugLog,
371
+ );
372
+ ensureGatewayMethodRegistered(
373
+ api,
374
+ 'bncr.file.ack',
375
+ (opts) => bridge.handleFileAck(opts),
376
+ debugLog,
377
+ );
333
378
  debugLog('bncr plugin register done');
334
379
  },
335
380
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmoxmo/bncr",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,12 +26,17 @@
26
26
  "scripts": {
27
27
  "selfcheck": "node ./scripts/selfcheck.mjs",
28
28
  "test": "node --import ./tests/register-ts-hooks.mjs --test ./tests/*.test.mjs",
29
- "check-register-drift": "node ./scripts/check-register-drift.mjs"
29
+ "check-register-drift": "node ./scripts/check-register-drift.mjs",
30
+ "format:check": "biome format --check .",
31
+ "format": "biome format --write .",
32
+ "lint": "biome lint .",
33
+ "check": "biome check ."
30
34
  },
31
35
  "peerDependencies": {
32
36
  "openclaw": ">=2026.3.22"
33
37
  },
34
38
  "devDependencies": {
39
+ "@biomejs/biome": "^1.9.4",
35
40
  "openclaw": ">=2026.3.22"
36
41
  },
37
42
  "openclaw": {
@@ -16,11 +16,14 @@ const options = {
16
16
  for (let i = 0; i < args.length; i += 1) {
17
17
  const arg = args[i];
18
18
  if (arg === '--duration-sec') options.durationSec = readNumber(args[++i], options.durationSec);
19
- else if (arg === '--interval-sec') options.intervalSec = readNumber(args[++i], options.intervalSec);
19
+ else if (arg === '--interval-sec')
20
+ options.intervalSec = readNumber(args[++i], options.intervalSec);
20
21
  else if (arg === '--account-id') options.accountId = args[++i] || options.accountId;
21
22
  else if (arg === '--gateway-bin') options.gatewayBin = args[++i] || options.gatewayBin;
22
23
  else if (arg === '--help' || arg === '-h') {
23
- console.log(`Usage: node ./scripts/check-register-drift.mjs [--duration-sec 300] [--interval-sec 15] [--account-id Primary] [--gateway-bin openclaw]\n\nSamples bncr.diagnostics over time and reports whether register counters drift after warmup.`);
24
+ console.log(
25
+ 'Usage: node ./scripts/check-register-drift.mjs [--duration-sec 300] [--interval-sec 15] [--account-id Primary] [--gateway-bin openclaw]\n\nSamples bncr.diagnostics over time and reports whether register counters drift after warmup.',
26
+ );
24
27
  process.exit(0);
25
28
  }
26
29
  }
@@ -33,7 +36,14 @@ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
33
36
  const fetchDiagnostics = () => {
34
37
  const raw = execFileSync(
35
38
  options.gatewayBin,
36
- ['gateway', 'call', 'bncr.diagnostics', '--json', '--params', JSON.stringify({ accountId: options.accountId })],
39
+ [
40
+ 'gateway',
41
+ 'call',
42
+ 'bncr.diagnostics',
43
+ '--json',
44
+ '--params',
45
+ JSON.stringify({ accountId: options.accountId }),
46
+ ],
37
47
  { encoding: 'utf8' },
38
48
  );
39
49
  const parsed = JSON.parse(raw);
@@ -69,10 +79,12 @@ const first = samples[0] || {};
69
79
  const last = samples[samples.length - 1] || {};
70
80
  const deltaRegisterCount = (last.registerCount ?? 0) - (first.registerCount ?? 0);
71
81
  const deltaApiGeneration = (last.apiGeneration ?? 0) - (first.apiGeneration ?? 0);
72
- const deltaPostWarmupRegisterCount = (last.postWarmupRegisterCount ?? 0) - (first.postWarmupRegisterCount ?? 0);
82
+ const deltaPostWarmupRegisterCount =
83
+ (last.postWarmupRegisterCount ?? 0) - (first.postWarmupRegisterCount ?? 0);
73
84
  const historicalWarmupExternalDrift = Boolean(first.unexpectedRegisterAfterWarmup);
74
85
  const newWarmupExternalDriftDuringWindow = deltaPostWarmupRegisterCount > 0;
75
- const newDriftDuringWindow = deltaRegisterCount > 0 || deltaApiGeneration > 0 || newWarmupExternalDriftDuringWindow;
86
+ const newDriftDuringWindow =
87
+ deltaRegisterCount > 0 || deltaApiGeneration > 0 || newWarmupExternalDriftDuringWindow;
76
88
  const driftDetected = historicalWarmupExternalDrift || newDriftDuringWindow;
77
89
 
78
90
  const result = {