@xmoxmo/bncr 0.1.2 → 0.1.4

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
 
@@ -59,6 +59,18 @@ const readOpenClawPackageName = (pkgPath: string) => {
59
59
  }
60
60
  };
61
61
 
62
+ const readPluginVersion = () => {
63
+ try {
64
+ const raw = fs.readFileSync(path.join(pluginDir, 'package.json'), 'utf8');
65
+ const parsed = JSON.parse(raw);
66
+ return typeof parsed?.version === 'string' ? parsed.version : 'unknown';
67
+ } catch {
68
+ return 'unknown';
69
+ }
70
+ };
71
+
72
+ const pluginVersion = readPluginVersion();
73
+
62
74
  const findOpenClawPackageRoot = (startPath: string) => {
63
75
  let current = startPath;
64
76
  try {
@@ -121,9 +133,7 @@ const collectOpenClawCandidates = () => {
121
133
  }
122
134
 
123
135
  const packageRoots = unique(
124
- directCandidates
125
- .map((candidate) => findOpenClawPackageRoot(candidate))
126
- .filter(Boolean),
136
+ directCandidates.map((candidate) => findOpenClawPackageRoot(candidate)).filter(Boolean),
127
137
  );
128
138
 
129
139
  return packageRoots.filter((candidate) => {
@@ -275,7 +285,7 @@ const plugin = {
275
285
  const { bridge, runtime, created } = getBridgeSingleton(api);
276
286
  bridge.noteRegister?.({
277
287
  source: '~/.openclaw/workspace/plugins/bncr/index.ts',
278
- pluginVersion: '0.1.1',
288
+ pluginVersion,
279
289
  apiRebound: !created,
280
290
  apiInstanceId: meta.apiInstanceId,
281
291
  registryFingerprint: meta.registryFingerprint,
@@ -285,7 +295,9 @@ const plugin = {
285
295
  api.logger.info?.(...args);
286
296
  };
287
297
 
288
- debugLog(`bncr plugin register begin bridge=${bridge.getBridgeId?.() || 'unknown'} created=${created}`);
298
+ debugLog(
299
+ `bncr plugin register begin bridge=${bridge.getBridgeId?.() || 'unknown'} created=${created}`,
300
+ );
289
301
  if (!created) debugLog('bncr bridge api rebound');
290
302
 
291
303
  const resolveDebug = async () => {
@@ -320,16 +332,61 @@ const plugin = {
320
332
  debugLog('bncr register channel skip (already registered on this api)');
321
333
  }
322
334
 
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);
335
+ ensureGatewayMethodRegistered(
336
+ api,
337
+ 'bncr.connect',
338
+ (opts) => bridge.handleConnect(opts),
339
+ debugLog,
340
+ );
341
+ ensureGatewayMethodRegistered(
342
+ api,
343
+ 'bncr.inbound',
344
+ (opts) => bridge.handleInbound(opts),
345
+ debugLog,
346
+ );
347
+ ensureGatewayMethodRegistered(
348
+ api,
349
+ 'bncr.activity',
350
+ (opts) => bridge.handleActivity(opts),
351
+ debugLog,
352
+ );
326
353
  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);
354
+ ensureGatewayMethodRegistered(
355
+ api,
356
+ 'bncr.diagnostics',
357
+ (opts) => bridge.handleDiagnostics(opts),
358
+ debugLog,
359
+ );
360
+ ensureGatewayMethodRegistered(
361
+ api,
362
+ 'bncr.file.init',
363
+ (opts) => bridge.handleFileInit(opts),
364
+ debugLog,
365
+ );
366
+ ensureGatewayMethodRegistered(
367
+ api,
368
+ 'bncr.file.chunk',
369
+ (opts) => bridge.handleFileChunk(opts),
370
+ debugLog,
371
+ );
372
+ ensureGatewayMethodRegistered(
373
+ api,
374
+ 'bncr.file.complete',
375
+ (opts) => bridge.handleFileComplete(opts),
376
+ debugLog,
377
+ );
378
+ ensureGatewayMethodRegistered(
379
+ api,
380
+ 'bncr.file.abort',
381
+ (opts) => bridge.handleFileAbort(opts),
382
+ debugLog,
383
+ );
384
+ ensureGatewayMethodRegistered(
385
+ api,
386
+ 'bncr.file.ack',
387
+ (opts) => bridge.handleFileAck(opts),
388
+ debugLog,
389
+ );
333
390
  debugLog('bncr plugin register done');
334
391
  },
335
392
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmoxmo/bncr",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
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 = {