import { getExecApprovalReplyMetadata } from "openclaw/plugin-sdk/approval-runtime"; import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; import type { ChannelPlugin } from "openclaw/plugin-sdk/core"; // Register the PlatformAdapter before any core/ module is used. import"./bridge/bootstrap.js"; import { getQQBotApprovalCapability } from "./bridge/approval/capability.js"; import { qqbotConfigAdapter, qqbotMeta, qqbotSetupAdapterShared } from "./bridge/config-shared.js"; import {
applyQQBotAccountConfig,
DEFAULT_ACCOUNT_ID,
resolveQQBotAccount,
} from "./bridge/config.js"; import { getQQBotRuntime } from "./bridge/runtime.js"; import { qqbotSetupWizard } from "./bridge/setup/surface.js"; import { qqbotChannelConfigSchema } from "./config-schema.js"; import { loadCredentialBackup, saveCredentialBackup } from "./engine/config/credential-backup.js"; import { clearAccountCredentials } from "./engine/config/credentials.js"; import {
normalizeTarget as coreNormalizeTarget,
looksLikeQQBotTarget,
} from "./engine/messaging/target-parser.js"; // Re-export text helpers from core/.
export { chunkText, TEXT_CHUNK_LIMIT } from "./engine/utils/text-chunk.js"; import type { ResolvedQQBotAccount } from "./types.js";
// Shared promise so concurrent multi-account startups serialize the dynamic // import of the gateway module, avoiding an ESM circular-dependency race.
let _gatewayModulePromise: Promise<typeofimport("./bridge/gateway.js")> | undefined; function loadGatewayModule(): Promise<typeofimport("./bridge/gateway.js")> {
_gatewayModulePromise ??= import("./bridge/gateway.js"); return _gatewayModulePromise;
}
// Recover credentials from the per-account backup if the live // config is missing appId/secret (e.g. a hot-upgrade wiped // openclaw.json). We only restore when both fields are empty so a // user's intentional clear isn't silently undone. if (!account.appId || !account.clientSecret) { const backup = loadCredentialBackup(account.accountId); if (backup?.appId && backup?.clientSecret) { try { const nextCfg = applyQQBotAccountConfig(cfg, account.accountId, {
appId: backup.appId,
clientSecret: backup.clientSecret,
}); const runtime = getQQBotRuntime(); const configApi = runtime.config as {
writeConfigFile: (cfg: OpenClawConfig) => Promise<void>;
};
await configApi.writeConfigFile(nextCfg);
cfg = nextCfg;
account = resolveQQBotAccount(nextCfg, account.accountId);
log?.info(
`[qqbot:${account.accountId}] Restored credentials from backup (appId=${account.appId})`,
);
} catch (err) {
log?.error(
`[qqbot:${account.accountId}] Failed to restore credentials from backup: ${err instanceof Error ? err.message : String(err)}`,
);
}
}
}
// Serialize the dynamic import so concurrent multi-account startups // do not hit an ESM circular-dependency race where the gateway chunk's // transitive imports have not finished evaluating yet. const { startGateway } = await loadGatewayModule();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.