feat(plugin): sync OpenClaw slash-command catalog to Fabric
- command-sync.ts: buildFabricCommandSpecs(cfg) reads OpenClaw native command specs via openclaw/plugin-sdk/native-command-registry (listNativeCommandSpecsForConfig + findCommandByNativeName), resolves dynamic arg choices to a static snapshot (resolveCommandArgChoices) — same data Discord registers as slash commands. - syncFabricCommands(): on gateway_start, after inbound starts, PUT the catalog to each connected guild (FabricClient.syncCommands -> PUT /api/commands; idempotent, one per guild). - Fabric stays a TEXT-command surface (no nativeCommands capability): execution still flows as a /<cmd> message into OpenClaw's command system; this catalog only drives frontend autocomplete. Verified: 41 specs built (args/choices incl. dynamic), synced to test-guild1, GET /api/commands round-trips count=41. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2
index.ts
2
index.ts
@@ -11,6 +11,7 @@ import { listEnabledFabricAccounts } from './src/accounts.js';
|
||||
import { registerFabricTools } from './src/tools.js';
|
||||
import { FabricClient } from './src/fabric-client.js';
|
||||
import { IdentityRegistry } from './src/identity.js';
|
||||
import { syncFabricCommands } from './src/command-sync.js';
|
||||
import path from 'node:path';
|
||||
import os from 'node:os';
|
||||
|
||||
@@ -82,6 +83,7 @@ export default defineChannelPluginEntry({
|
||||
);
|
||||
void inbound.start();
|
||||
api.logger.info(`fabric: inbound started for ${accounts.length} account(s)`);
|
||||
void syncFabricCommands(client, cfg, accounts, api.logger);
|
||||
});
|
||||
|
||||
api.on('gateway_stop', () => {
|
||||
|
||||
Reference in New Issue
Block a user