mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 12:41:12 +00:00
58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
import {
|
|
defineBundledChannelEntry,
|
|
loadBundledEntryExportSync,
|
|
} from "openclaw/plugin-sdk/channel-entry-contract";
|
|
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/channel-entry-contract";
|
|
|
|
function registerMatrixCliMetadata(api: OpenClawPluginApi) {
|
|
const register = loadBundledEntryExportSync<(api: OpenClawPluginApi) => void>(import.meta.url, {
|
|
specifier: "./cli-metadata.js",
|
|
exportName: "registerMatrixCliMetadata",
|
|
});
|
|
register(api);
|
|
}
|
|
|
|
export default defineBundledChannelEntry({
|
|
id: "matrix",
|
|
name: "Matrix",
|
|
description: "Matrix channel plugin (matrix-js-sdk)",
|
|
importMetaUrl: import.meta.url,
|
|
plugin: {
|
|
specifier: "./api.js",
|
|
exportName: "matrixPlugin",
|
|
},
|
|
runtime: {
|
|
specifier: "./runtime-api.js",
|
|
exportName: "setMatrixRuntime",
|
|
},
|
|
registerCliMetadata: registerMatrixCliMetadata,
|
|
registerFull(api) {
|
|
void import("./plugin-entry.handlers.runtime.js")
|
|
.then(({ ensureMatrixCryptoRuntime }) =>
|
|
ensureMatrixCryptoRuntime({ log: api.logger.info }).catch((err: unknown) => {
|
|
const message = err instanceof Error ? err.message : String(err);
|
|
api.logger.warn?.(`matrix: crypto runtime bootstrap failed: ${message}`);
|
|
}),
|
|
)
|
|
.catch((err: unknown) => {
|
|
const message = err instanceof Error ? err.message : String(err);
|
|
api.logger.warn?.(`matrix: failed loading crypto bootstrap runtime: ${message}`);
|
|
});
|
|
|
|
api.registerGatewayMethod("matrix.verify.recoveryKey", async (ctx) => {
|
|
const { handleVerifyRecoveryKey } = await import("./plugin-entry.handlers.runtime.js");
|
|
await handleVerifyRecoveryKey(ctx);
|
|
});
|
|
|
|
api.registerGatewayMethod("matrix.verify.bootstrap", async (ctx) => {
|
|
const { handleVerificationBootstrap } = await import("./plugin-entry.handlers.runtime.js");
|
|
await handleVerificationBootstrap(ctx);
|
|
});
|
|
|
|
api.registerGatewayMethod("matrix.verify.status", async (ctx) => {
|
|
const { handleVerificationStatus } = await import("./plugin-entry.handlers.runtime.js");
|
|
await handleVerificationStatus(ctx);
|
|
});
|
|
},
|
|
});
|