build: PaddedCell-style install.mjs + SDK-aligned packaging
install.mjs (--install/--build-only/--uninstall/--openclaw-profile-path), tsconfig outDir dist/fabric, package.json openclaw file dep + main. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
46
dist/fabric/src/channel.js
vendored
Normal file
46
dist/fabric/src/channel.js
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import { createChatChannelPlugin, createChannelPluginBase, } from 'openclaw/plugin-sdk/channel-core';
|
||||
export function resolveFabricAccount(cfg, accountId) {
|
||||
const section = cfg.channels?.['fabric'];
|
||||
const centerApiBase = section?.centerApiBase;
|
||||
if (!centerApiBase)
|
||||
throw new Error('fabric: channels.fabric.centerApiBase is required');
|
||||
return {
|
||||
accountId: accountId ?? null,
|
||||
centerApiBase,
|
||||
allowFrom: section?.allowFrom ?? [],
|
||||
dmPolicy: section?.dmSecurity,
|
||||
};
|
||||
}
|
||||
// Outbound is wired by the entry (it needs the identity registry + client to
|
||||
// post as the right agent). Channel-turn visible replies go through the
|
||||
// inbound adapter's delivery callback; this object owns config/security only.
|
||||
export function buildFabricChannelPlugin(sendText) {
|
||||
return createChatChannelPlugin({
|
||||
base: createChannelPluginBase({
|
||||
id: 'fabric',
|
||||
setup: {
|
||||
resolveAccount: resolveFabricAccount,
|
||||
inspectAccount(cfg, accountId) {
|
||||
const section = cfg.channels?.['fabric'];
|
||||
const ok = Boolean(section?.centerApiBase);
|
||||
return { enabled: ok, configured: ok, tokenStatus: ok ? 'available' : 'missing' };
|
||||
},
|
||||
},
|
||||
}),
|
||||
security: {
|
||||
dm: {
|
||||
channelKey: 'fabric',
|
||||
resolvePolicy: (a) => a.dmPolicy,
|
||||
resolveAllowFrom: (a) => a.allowFrom,
|
||||
defaultPolicy: 'allowlist',
|
||||
},
|
||||
},
|
||||
// Fabric replies thread by being posted into the same channel.
|
||||
threading: { topLevelReplyToMode: 'channel' },
|
||||
outbound: {
|
||||
attachedResults: {
|
||||
sendText: async (params) => sendText(params),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user