@xmoxmo/bncr 0.1.6 → 0.1.8
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 +18 -11
- package/package.json +1 -1
- package/src/channel.ts +382 -268
- package/src/core/logging.ts +65 -0
- package/src/core/targets.ts +97 -0
- package/src/messaging/inbound/commands.ts +4 -2
- package/src/messaging/inbound/dispatch.ts +4 -3
- package/src/messaging/outbound/media.ts +3 -1
- package/src/messaging/outbound/send.ts +11 -1
- package/src/messaging/outbound/session-route.ts +73 -0
- package/src/messaging/outbound/target-resolver.ts +56 -0
package/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { createRequire } from 'node:module';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { BncrConfigSchema } from './src/core/config-schema.ts';
|
|
7
|
+
import { emitBncrLogLine } from './src/core/logging.ts';
|
|
7
8
|
|
|
8
9
|
const pluginFile = fileURLToPath(import.meta.url);
|
|
9
10
|
const pluginDir = path.dirname(pluginFile);
|
|
@@ -254,12 +255,12 @@ const ensureGatewayMethodRegistered = (
|
|
|
254
255
|
) => {
|
|
255
256
|
const meta = getRegisterMeta(api);
|
|
256
257
|
if (meta.methods?.has(name)) {
|
|
257
|
-
debugLog(`
|
|
258
|
+
debugLog(`register method skip ${name} (already registered on this api)`);
|
|
258
259
|
return;
|
|
259
260
|
}
|
|
260
261
|
api.registerGatewayMethod(name, handler);
|
|
261
262
|
meta.methods?.add(name);
|
|
262
|
-
debugLog(`
|
|
263
|
+
debugLog(`register method ok ${name}`);
|
|
263
264
|
};
|
|
264
265
|
|
|
265
266
|
const getBridgeSingleton = (api: OpenClawPluginApi) => {
|
|
@@ -291,14 +292,20 @@ const plugin = {
|
|
|
291
292
|
registryFingerprint: meta.registryFingerprint,
|
|
292
293
|
});
|
|
293
294
|
const debugLog = (...args: any[]) => {
|
|
294
|
-
|
|
295
|
-
|
|
295
|
+
const rendered = args
|
|
296
|
+
.map((arg) => (typeof arg === 'string' ? arg : JSON.stringify(arg)))
|
|
297
|
+
.join(' ')
|
|
298
|
+
.trim();
|
|
299
|
+
if (!rendered) return;
|
|
300
|
+
emitBncrLogLine('info', `[bncr] debug ${rendered}`, { debugOnly: true }, () =>
|
|
301
|
+
Boolean(bridge.isDebugEnabled?.()),
|
|
302
|
+
);
|
|
296
303
|
};
|
|
297
304
|
|
|
298
305
|
debugLog(
|
|
299
|
-
`
|
|
306
|
+
`register begin bridge=${bridge.getBridgeId?.() || 'unknown'} created=${created}`,
|
|
300
307
|
);
|
|
301
|
-
if (!created) debugLog('
|
|
308
|
+
if (!created) debugLog('bridge api rebound');
|
|
302
309
|
|
|
303
310
|
const resolveDebug = async () => {
|
|
304
311
|
try {
|
|
@@ -319,17 +326,17 @@ const plugin = {
|
|
|
319
326
|
stop: bridge.stopService,
|
|
320
327
|
});
|
|
321
328
|
meta.service = true;
|
|
322
|
-
debugLog('
|
|
329
|
+
debugLog('register service ok');
|
|
323
330
|
} else {
|
|
324
|
-
debugLog('
|
|
331
|
+
debugLog('register service skip (already registered on this api)');
|
|
325
332
|
}
|
|
326
333
|
|
|
327
334
|
if (!meta.channel) {
|
|
328
335
|
api.registerChannel({ plugin: runtime.createBncrChannelPlugin(bridge) });
|
|
329
336
|
meta.channel = true;
|
|
330
|
-
debugLog('
|
|
337
|
+
debugLog('register channel ok');
|
|
331
338
|
} else {
|
|
332
|
-
debugLog('
|
|
339
|
+
debugLog('register channel skip (already registered on this api)');
|
|
333
340
|
}
|
|
334
341
|
|
|
335
342
|
ensureGatewayMethodRegistered(
|
|
@@ -387,7 +394,7 @@ const plugin = {
|
|
|
387
394
|
(opts) => bridge.handleFileAck(opts),
|
|
388
395
|
debugLog,
|
|
389
396
|
);
|
|
390
|
-
debugLog('
|
|
397
|
+
debugLog('register done');
|
|
391
398
|
},
|
|
392
399
|
};
|
|
393
400
|
|