@xmoxmo/bncr 0.1.9 → 0.1.10

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.
Files changed (2) hide show
  1. package/index.ts +54 -1
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -276,12 +276,65 @@ const getBridgeSingleton = (api: OpenClawPluginApi) => {
276
276
  return { bridge: g.__bncrBridge, runtime: loaded, created };
277
277
  };
278
278
 
279
+ const isPlainObject = (value: unknown): value is Record<string, unknown> =>
280
+ typeof value === 'object' && value !== null && !Array.isArray(value);
281
+
282
+ const registerBncrCli = (api: OpenClawPluginApi & { registerCli?: (...args: any[]) => void }) => {
283
+ if (typeof api.registerCli !== 'function') return;
284
+ api.registerCli(
285
+ ({ program }: any) => {
286
+ const bncr = program.command('bncr').description('Bncr channel utilities');
287
+ bncr
288
+ .command('miniconfig')
289
+ .description(
290
+ 'Seed minimal channels.bncr config (adds enabled=true and allowTool=false only when missing)',
291
+ )
292
+ .action(async () => {
293
+ const cfg = (await api.runtime.config.loadConfig()) as Record<string, unknown>;
294
+ if (!isPlainObject(cfg.channels)) cfg.channels = {};
295
+
296
+ const existing = isPlainObject(cfg.channels.bncr) ? cfg.channels.bncr : {};
297
+ const bncrCfg: Record<string, unknown> = { ...existing };
298
+ const added: string[] = [];
299
+
300
+ if (bncrCfg.enabled === undefined) {
301
+ bncrCfg.enabled = true;
302
+ added.push('enabled=true');
303
+ }
304
+
305
+ if (bncrCfg.allowTool === undefined) {
306
+ bncrCfg.allowTool = false;
307
+ added.push('allowTool=false');
308
+ }
309
+
310
+ cfg.channels.bncr = bncrCfg;
311
+
312
+ if (added.length === 0) {
313
+ console.log('Minimal bncr config already present. No changes made.');
314
+ return;
315
+ }
316
+
317
+ await api.runtime.config.writeConfigFile(cfg);
318
+ console.log('Seeded minimal bncr config at channels.bncr.');
319
+ console.log(`Added missing fields: ${added.join(', ')}`);
320
+ console.log('Restart the gateway to apply changes.');
321
+ });
322
+ },
323
+ { commands: ['bncr'] },
324
+ );
325
+ };
326
+
279
327
  const plugin = {
280
328
  id: 'bncr',
281
329
  name: 'Bncr',
282
330
  description: 'Bncr channel plugin',
283
331
  configSchema: BncrConfigSchema,
284
- register(api: OpenClawPluginApi) {
332
+ register(
333
+ api: OpenClawPluginApi & { registerCli?: (...args: any[]) => void; registrationMode?: string },
334
+ ) {
335
+ registerBncrCli(api);
336
+ if (api.registrationMode === 'cli-metadata') return;
337
+
285
338
  const meta = getRegisterMeta(api);
286
339
  const { bridge, runtime, created } = getBridgeSingleton(api);
287
340
  bridge.noteRegister?.({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmoxmo/bncr",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",