@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 +73 -16
- package/package.json +7 -2
- package/scripts/check-register-drift.mjs +17 -5
- package/src/channel.ts +589 -334
- 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 +42 -16
- package/src/messaging/inbound/dispatch.ts +48 -10
- package/src/messaging/inbound/gate.ts +1 -3
- package/src/messaging/inbound/parse.ts +5 -2
- package/src/messaging/inbound/reply-config.ts +50 -0
- 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
|
|
|
@@ -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
|
|
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(
|
|
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(
|
|
324
|
-
|
|
325
|
-
|
|
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(
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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.
|
|
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')
|
|
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 = {
|