@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 +60 -15
- package/package.json +7 -2
- package/scripts/check-register-drift.mjs +17 -5
- package/src/channel.ts +572 -252
- package/src/core/accounts.ts +7 -1
- package/src/core/permissions.ts +3 -1
- package/src/core/probe.ts +2 -1
- package/src/core/status.ts +9 -3
- package/src/core/targets.ts +151 -41
- package/src/messaging/inbound/commands.ts +34 -10
- package/src/messaging/inbound/dispatch.ts +40 -4
- package/src/messaging/inbound/gate.ts +1 -3
- package/src/messaging/inbound/parse.ts +5 -2
- package/src/messaging/outbound/media.ts +24 -5
- package/src/messaging/outbound/send.ts +25 -5
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(
|
|
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(
|
|
324
|
-
|
|
325
|
-
|
|
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(
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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.
|
|
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')
|
|
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(
|
|
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
|
-
[
|
|
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 =
|
|
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 =
|
|
86
|
+
const newDriftDuringWindow =
|
|
87
|
+
deltaRegisterCount > 0 || deltaApiGeneration > 0 || newWarmupExternalDriftDuringWindow;
|
|
76
88
|
const driftDetected = historicalWarmupExternalDrift || newDriftDuringWindow;
|
|
77
89
|
|
|
78
90
|
const result = {
|