Files
WechatExplorer/src/shared/personal-wechat.ts
T
Wxw-Gu 5d4ba73771 feat: 发送支持群聊@成员
生命周期整理
清理残留整理
完善skill
2026-11-12 11:18:32 +08:00

152 lines
3.7 KiB
TypeScript

export type PersonalWechatSenderState =
| 'checking'
| 'unsupported_platform'
| 'wechat_not_running'
| 'sip_enabled'
| 'unsupported_version'
| 'runtime_missing'
| 'hook_not_ready'
| 'stopped'
| 'starting'
| 'rebinding'
| 'online'
| 'error'
export interface PersonalWechatSenderStatus {
state: PersonalWechatSenderState
platform: string
arch: string
sipDisabled: boolean
wechatRunning: boolean
wechatPid?: number
boundWechatPid?: number
endpoint: string
endpointReady: boolean
wechatVersion?: string
runtimeReady: boolean
executablePath?: string
configPath?: string
imagePath?: string
attachReady: boolean
baseAddress?: string
baseAddressReady: boolean
textHookInstalled: boolean
textHookReady: boolean
imageHookInstalled: boolean
imageHookReady: boolean
messageListenerReady: boolean
canSend: boolean
canSendText: boolean
canSendImage: boolean
canSendVoice: boolean
message: string
error?: string
}
/** Stable, feature-facing send capability derived from the low-level sender status. */
export type PersonalWechatSendCapabilityState =
| 'unsupported'
| 'unconfigured'
| 'needs_binding'
| 'initializing'
| 'ready'
| 'error'
export interface PersonalWechatSendCapability {
supported: boolean
ready: boolean
status: PersonalWechatSendCapabilityState
capabilities: {
text: boolean
image: boolean
voice: boolean
}
senderStatus: PersonalWechatSenderStatus
message: string
error?: string
}
interface PersonalWechatSendBaseRequest {
to: string
isGroup: boolean
}
export interface PersonalWechatSendTextRequest extends PersonalWechatSendBaseRequest {
type: 'text'
text: string
at?: Record<string, string>
}
export interface PersonalWechatSendImageRequest extends PersonalWechatSendBaseRequest {
type: 'image'
filePath: string
/** 日报图片成功后再发送的文字;undefined 表示普通图片发送,不启用日报序列。 */
postfixText?: string
}
export interface PersonalWechatSendVoiceRequest extends PersonalWechatSendBaseRequest {
type: 'voice'
filePath: string
/** Internal comparison switch for the temporary voice regression test. */
voiceSendMode?: 'normalized' | 'legacy'
fromId?: string
durationMs?: number
}
export type PersonalWechatSendRequest =
| PersonalWechatSendTextRequest
| PersonalWechatSendImageRequest
| PersonalWechatSendVoiceRequest
/** Renderer 请求发送刚刚生成的 TTS 语音;Action 元数据由主进程补齐。 */
export interface PersonalWechatGeneratedTtsVoiceRequest {
to: string
isGroup: boolean
filePath: string
}
export interface PersonalWechatGeneratedTtsVoiceResult {
action: import('./wechat-action').WechatActionResult
status: PersonalWechatSenderStatus
}
export interface PersonalWechatSendResult {
success: boolean
status: PersonalWechatSenderStatus
error?: string
postfixSent?: boolean
postfixError?: string
}
export const DEFAULT_REPORT_IMAGE_POSTFIX_TEXT = '今日日报'
/** Safe, user-copyable metadata for the most recent voice send attempt. */
export interface PersonalWechatVoiceDiagnostic {
request_id: string
voice_id: string
phase: 'prepared' | 'completed' | 'failed'
encoder_name: string
encoder_version: string
input_bytes?: number
normalized_input_bytes?: number
pcm_size?: number
sample_rate?: number
channels?: number
input_duration_ms?: number
upload_result?: string
upload_data_len?: number
silk_duration_ms?: number
send_result?: string
voice_send_mode?: 'normalized' | 'legacy'
failure_phase?: string
error?: string
}
export interface PersonalWechatImageSelectionResult {
canceled: boolean
path?: string
name?: string
}
export type PersonalWechatVoiceSelectionResult = PersonalWechatImageSelectionResult