import { BaseApp } from "./base-app.js"; import { CommonTypes } from "./types.js"; import { Account } from "./account.js"; import { Logger } from "log4js"; import { SqliteDB } from "./db.js"; import { type AdapterCapabilityManifest } from "./adapter-capability.js"; import { type UnsupportedCapabilityReason } from "./errors.js"; import { AdapterActionDefaults } from "./adapter-actions.js"; import "./adapter-types.js"; import "./adapter-types-extended.js"; /** 通用适配器基类:提供稳定动作接口,以能力清单明确平台差异。 */ export declare abstract class Adapter extends AdapterActionDefaults { #private; app: I; platform: T; accounts: Map>; icon: string; get db(): SqliteDB; get tableName(): string; protected constructor(app: I, platform: T, capabilityManifest?: AdapterCapabilityManifest); createId(id: string | number, _retries?: number): CommonTypes.Id; /** * 将配置中的账号标识转换为平台自身 ID。 * 默认平台把账号标识视为 string;数字账号平台应覆写并先恢复原始 number 类型。 */ resolveAccountId(accountId: string): CommonTypes.Id; resolveId(id: string | number | CommonTypes.Id): CommonTypes.Id; coerceId(value: CommonTypes.Id | string | number): CommonTypes.Id; /** 返回当前适配器对外声明的能力;账号级动态能力可由子类覆写。 */ describeCapabilities(_uin?: string): AdapterCapabilityManifest; unsupported(capability: string, reason?: UnsupportedCapabilityReason, message?: string): never; getSupportedActions(uin: string): Promise; /** * 从协议层调用能力清单中的动作。 * * 标准动作统一使用 `(accountId, params)`;平台扩展动作必须显式覆写 * executePlatformAction,避免将任意实例方法意外暴露为远程 API。 */ callAction(uin: string, action: string, params?: Readonly>): Promise; /** 平台扩展动作的显式远程调用入口;子类应按 action 做穷尽路由。 */ executePlatformAction(_uin: string, action: string, _params: Readonly>): Promise; /** 平台扩展动作必须同时声明可执行性,供能力契约检测清单漂移。 */ isPlatformActionImplemented(_action: string): boolean; /** 能力契约使用该方法确认清单没有把基类占位实现误报为可用能力。 */ isActionImplemented(action: string): boolean; getAccount(uin: string): Account; get logger(): Logger; get info(): { platform: T; icon: string; capabilities: AdapterCapabilityManifest; accountLifecycleControl: { online: boolean; offline: boolean; }; accounts: { uin: any; status: import("./account.js").AccountStatus; platform: string | number; avatar: string; nickname: string; dependency: string; urls: string[]; protocols: import("./account.js").ProtocolRuntimeInfo[]; startupTimeoutSeconds: number; }[]; }; /** 管理面只能展示适配器真实实现的账号在线状态控制,不能把基类占位方法当成能力。 */ get accountLifecycleControl(): { online: boolean; offline: boolean; }; setOnline(_uin: string): Promise; setOffline(_uin: string): Promise; submitVerification?(accountId: string, type: string, data: Record): void | Promise; requestSmsCode?(accountId: string): void | Promise; abstract createAccount(config: Account.Config): Account; /** * 返回账号完整启动事务的有效超时秒数。适配器可为扫码等合法长登录流程抬高边界, * 但不得缩短宿主配置的全局保护窗口。 */ resolveAccountStartupTimeoutSeconds(_config: Account.Config): number; start(account_id?: string): Promise; /** 包括批次里尚未轮到的账号,防止移除后旧启动快照又把它启动。 */ isAccountStartupPending(accountId: string): boolean; stop(account_id?: string): Promise; } export type AdapterClient = T extends Adapter ? C : never; export declare namespace Adapter { /** 注册表运行时始终只传入宿主应用,工厂类型必须与真实调用约定一致。 */ type Construct = { new (app: BaseApp): T; }; type Creator = (app: BaseApp) => T; type Factory = Construct | Creator; function isClassAdapter(obj: unknown): obj is Construct; interface Metadata { name: string; displayName: string; description: string; icon?: string; homepage?: string; author?: string; capabilities?: AdapterCapabilityManifest; } }