import { resolveRuntimeServiceVersion } from "openclaw/plugin-sdk/cli-runtime"; import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; import {
registerVersionResolver,
registerPluginVersion,
registerApproveRuntimeGetter,
} from "../engine/commands/slash-commands-impl.js"; import {
startGateway as coreStartGateway,
type CoreGatewayContext,
} from "../engine/gateway/gateway.js"; import type { GatewayAccount } from "../engine/gateway/types.js"; import { registerOutboundAudioAdapterFactory } from "../engine/messaging/outbound.js"; import { initSender, registerAccount } from "../engine/messaging/sender.js"; import type { EngineLogger } from "../engine/types.js"; import * as _audioModule from "../engine/utils/audio.js"; import { debugLog, debugError } from "../engine/utils/log.js"; import { registerTextChunker } from "../engine/utils/text-chunk.js"; import type { ResolvedQQBotAccount } from "../types.js"; import { ensurePlatformAdapter } from "./bootstrap.js"; import { setBridgeLogger } from "./logger.js"; import { resolveQQBotPluginVersion } from "./plugin-version.js"; import { getQQBotRuntime, getQQBotRuntimeForEngine } from "./runtime.js";
// Register framework SDK version resolver for core/ slash commands.
registerVersionResolver(resolveRuntimeServiceVersion);
// Inject plugin + framework versions into sender and into the slash // command registry. The plugin version is read from this plugin's own // `package.json` by walking up from this file's URL, which is robust // against source-vs-dist layout differences. const _pluginVersion = resolveQQBotPluginVersion(import.meta.url);
initSender({
pluginVersion: _pluginVersion,
openclawVersion: resolveRuntimeServiceVersion(),
});
registerPluginVersion(_pluginVersion);
// Register audio adapter factory so outbound.sendMedia can lazy-init even // when startGateway() hasn't run yet (bundler chunk-splitting scenario).
registerOutboundAudioAdapterFactory(() => { // Use a synchronous require-like approach: the audio module should already // be loaded by the time the factory is invoked (gateway has started). // We import it at the top and reference it here. return {
audioFileToSilkBase64: async (p: string, f?: string[]) =>
(await _audioModule.audioFileToSilkBase64(p, f)) ?? undefined,
isAudioFile: (p: string, m?: string) => _audioModule.isAudioFile(p, m),
shouldTranscodeVoice: (p: string) => _audioModule.shouldTranscodeVoice(p),
waitForFile: (p: string, ms?: number) => _audioModule.waitForFile(p, ms),
};
});
/** *StarttheGatewayWebSocketconnection. * *PassesthePluginRuntimetocore/gateway/gateway.ts. *Allotherdependenciesareimporteddirectlybythecoremodule.
*/
export async function startGateway(ctx: GatewayContext): Promise<void> { // Ensure the PlatformAdapter is registered before any engine code runs. // When the bundler splits code into separate chunks, bootstrap.ts's // side-effect registration may not have executed yet at this point.
ensurePlatformAdapter();
const runtime = getQQBotRuntimeForEngine();
// Create per-account logger with auto [qqbot:{accountId}] prefix. const accountLogger = createAccountLogger(ctx.log, ctx.account.accountId);
// Register into engine sender (per-appId logger + API config) and bridge layer.
registerAccount(ctx.account.appId, {
logger: accountLogger,
markdownSupport: ctx.account.markdownSupport,
});
setBridgeLogger(accountLogger);
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.