mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-12-01 09:15:41 +08:00
fix: 补充mac发送的类型
修复图片key
This commit is contained in:
1 parent
f16067d6d0
commit
5ca465f203
15 files changed
+335
-24
No files matched your search
+14
-2
@@ -587,7 +587,7 @@ const WECHAT_SEND_MAX_TEXT_LENGTH = 2_000
|
|||||||
const WECHAT_SEND_MAX_RECIPIENT_LENGTH = 512
|
const WECHAT_SEND_MAX_RECIPIENT_LENGTH = 512
|
||||||
const WECHAT_SEND_MAX_IDEMPOTENCY_KEY_LENGTH = 200
|
const WECHAT_SEND_MAX_IDEMPOTENCY_KEY_LENGTH = 200
|
||||||
|
|
||||||
const WECHAT_SEND_CONTENT_TYPES = ['text', 'image', 'voice'] as const
|
const WECHAT_SEND_CONTENT_TYPES = ['text', 'image', 'voice', 'file'] as const
|
||||||
type WechatSendContentType = (typeof WECHAT_SEND_CONTENT_TYPES)[number]
|
type WechatSendContentType = (typeof WECHAT_SEND_CONTENT_TYPES)[number]
|
||||||
|
|
||||||
interface WechatSendApiDependencies {
|
interface WechatSendApiDependencies {
|
||||||
@@ -731,8 +731,13 @@ function parseWechatSendPayload(payload: unknown): ParsedWechatSend {
|
|||||||
message: `filePath 指向的文件不存在:${filePath}`
|
message: `filePath 指向的文件不存在:${filePath}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (type === 'file') {
|
||||||
|
const fileName = readSendString(body.fileName)
|
||||||
|
content = { type: 'file', path: filePath, ...(fileName ? { name: fileName } : {}) }
|
||||||
|
} else {
|
||||||
content = { type, path: filePath }
|
content = { type, path: filePath }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ok: true,
|
ok: true,
|
||||||
@@ -841,7 +846,14 @@ function createWechatSendRoute(
|
|||||||
}
|
}
|
||||||
const contentType = parsed.content.type
|
const contentType = parsed.content.type
|
||||||
if (!capability.capabilities[contentType]) {
|
if (!capability.capabilities[contentType]) {
|
||||||
const label = contentType === 'text' ? '文字' : contentType === 'image' ? '图片' : '语音'
|
const label =
|
||||||
|
contentType === 'text'
|
||||||
|
? '文字'
|
||||||
|
: contentType === 'image'
|
||||||
|
? '图片'
|
||||||
|
: contentType === 'file'
|
||||||
|
? '文件'
|
||||||
|
: '语音'
|
||||||
return sendWechatSendError(res, 503, 'SEND_NOT_READY', `当前微信发送能力不支持发送${label}`, {
|
return sendWechatSendError(res, 503, 'SEND_NOT_READY', `当前微信发送能力不支持发送${label}`, {
|
||||||
capabilityStatus: capability.status,
|
capabilityStatus: capability.status,
|
||||||
capabilities: capability.capabilities
|
capabilities: capability.capabilities
|
||||||
|
|||||||
+30
-1
@@ -1940,7 +1940,12 @@ app.whenReady().then(async () => { if (isLegacyMigrationHelper) {
|
|||||||
// 排查「消息到底发没发出去」时恰好缺的就是那份证据。
|
// 排查「消息到底发没发出去」时恰好缺的就是那份证据。
|
||||||
// 普通手动发送保持 triggerType=user;带 postfixText 的日报图片由 Gateway 编排成
|
// 普通手动发送保持 triggerType=user;带 postfixText 的日报图片由 Gateway 编排成
|
||||||
// 两个 automation action,以复用同一条 3s 队列,并严格在图片 sent 后才发后置词。
|
// 两个 automation action,以复用同一条 3s 队列,并严格在图片 sent 后才发后置词。
|
||||||
if (request.type === 'text' || request.type === 'image' || request.type === 'video') {
|
if (
|
||||||
|
request.type === 'text' ||
|
||||||
|
request.type === 'image' ||
|
||||||
|
request.type === 'video' ||
|
||||||
|
request.type === 'file'
|
||||||
|
) {
|
||||||
const to = String(request.to || '').trim()
|
const to = String(request.to || '').trim()
|
||||||
const recipient = {
|
const recipient = {
|
||||||
type:
|
type:
|
||||||
@@ -1973,6 +1978,8 @@ app.whenReady().then(async () => { if (isLegacyMigrationHelper) {
|
|||||||
? 'manual_text'
|
? 'manual_text'
|
||||||
: request.type === 'video'
|
: request.type === 'video'
|
||||||
? 'manual_video'
|
? 'manual_video'
|
||||||
|
: request.type === 'file'
|
||||||
|
? 'manual_file'
|
||||||
: 'manual_image',
|
: 'manual_image',
|
||||||
triggerType: 'user',
|
triggerType: 'user',
|
||||||
recipient,
|
recipient,
|
||||||
@@ -1985,6 +1992,12 @@ app.whenReady().then(async () => { if (isLegacyMigrationHelper) {
|
|||||||
}
|
}
|
||||||
: request.type === 'video'
|
: request.type === 'video'
|
||||||
? { type: 'video', path: String(request.filePath || '') }
|
? { type: 'video', path: String(request.filePath || '') }
|
||||||
|
: request.type === 'file'
|
||||||
|
? {
|
||||||
|
type: 'file',
|
||||||
|
path: String(request.filePath || ''),
|
||||||
|
...(request.fileName ? { name: request.fileName } : {})
|
||||||
|
}
|
||||||
: { type: 'image', path: String(request.filePath || '') }
|
: { type: 'image', path: String(request.filePath || '') }
|
||||||
})
|
})
|
||||||
// 返回契约保持 `PersonalWechatSendResult`,界面判读不用改。
|
// 返回契约保持 `PersonalWechatSendResult`,界面判读不用改。
|
||||||
@@ -3675,6 +3688,22 @@ app.whenReady().then(async () => { if (isLegacyMigrationHelper) {
|
|||||||
ipcMain.handle('wechat-personal:getVoiceDiagnostic', () =>
|
ipcMain.handle('wechat-personal:getVoiceDiagnostic', () =>
|
||||||
personalWechatSendService.getLatestVoiceDiagnostic()
|
personalWechatSendService.getLatestVoiceDiagnostic()
|
||||||
)
|
)
|
||||||
|
ipcMain.handle('wechat-personal:selectFile', async (event) => {
|
||||||
|
const window = BrowserWindow.fromWebContents(event.sender)
|
||||||
|
const result = await dialog.showOpenDialog(window!, {
|
||||||
|
title: '选择要发送的文件',
|
||||||
|
properties: ['openFile']
|
||||||
|
})
|
||||||
|
if (result.canceled || result.filePaths.length === 0) return { canceled: true }
|
||||||
|
const filePath = result.filePaths[0]
|
||||||
|
let size = 0
|
||||||
|
try {
|
||||||
|
size = (await fsPromises.stat(filePath)).size
|
||||||
|
} catch {
|
||||||
|
return { canceled: true }
|
||||||
|
}
|
||||||
|
return { canceled: false, path: filePath, name: path.basename(filePath), size }
|
||||||
|
})
|
||||||
ipcMain.handle('agent-hub:selectTestImage', async (event) => {
|
ipcMain.handle('agent-hub:selectTestImage', async (event) => {
|
||||||
const window = BrowserWindow.fromWebContents(event.sender)
|
const window = BrowserWindow.fromWebContents(event.sender)
|
||||||
const result = await dialog.showOpenDialog(window!, {
|
const result = await dialog.showOpenDialog(window!, {
|
||||||
|
|||||||
@@ -55,7 +55,12 @@ export class ImageKeyConfigService {
|
|||||||
return migrated.success ? this.getConfig() : legacy
|
return migrated.success ? this.getConfig() : legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
const envAesKey = String(import.meta.env.VITE_IMAGE_AES_KEY || '').trim()
|
// 只有 dev 构建读 .env:生产包里带上开发者的 key,会让所有用户拿同一个人的密钥
|
||||||
|
// 去解自己的图,直接表现为「图片解密失败」。VITE_* 是编译期字面量,不加这道闸
|
||||||
|
// 就会被打进 app.asar。
|
||||||
|
const envAesKey = import.meta.env.DEV
|
||||||
|
? String(import.meta.env.VITE_IMAGE_AES_KEY || '').trim()
|
||||||
|
: ''
|
||||||
if (!settings.imageKeyFallbackDisabled && envAesKey) {
|
if (!settings.imageKeyFallbackDisabled && envAesKey) {
|
||||||
return this.buildResult({
|
return this.buildResult({
|
||||||
source: 'environment',
|
source: 'environment',
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ export function deriveMacWechatSenderStatus({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const runtimeCapabilities = new Set(manifest.capabilities)
|
const runtimeCapabilities = new Set(manifest.capabilities)
|
||||||
const supportsCapability = (name: 'text' | 'image' | 'voice'): boolean => {
|
const supportsCapability = (name: 'text' | 'image' | 'voice' | 'file'): boolean => {
|
||||||
if (manifest.capabilitiesByVersion) return versionCapabilities?.[name] === 'verified'
|
if (manifest.capabilitiesByVersion) return versionCapabilities?.[name] === 'verified'
|
||||||
return runtimeCapabilities.has(name)
|
return runtimeCapabilities.has(name)
|
||||||
}
|
}
|
||||||
@@ -205,6 +205,10 @@ export function deriveMacWechatSenderStatus({
|
|||||||
* 真正的发送结果仍以 Host 返回为准,不在 UI 层假装支持。
|
* 真正的发送结果仍以 Host 返回为准,不在 UI 层假装支持。
|
||||||
*/
|
*/
|
||||||
const canSendVideo = bindingReady && binding?.canSendImage === true
|
const canSendVideo = bindingReady && binding?.canSendImage === true
|
||||||
|
const canSendFile =
|
||||||
|
bindingReady &&
|
||||||
|
supportsCapability('file') &&
|
||||||
|
versionCapabilities?.textMechanism === 'tm-message-source-send'
|
||||||
const sessionAttached = identityMatches && (binding?.sessionAttached ?? false)
|
const sessionAttached = identityMatches && (binding?.sessionAttached ?? false)
|
||||||
const scriptLoaded = identityMatches && (binding?.scriptLoaded ?? false)
|
const scriptLoaded = identityMatches && (binding?.scriptLoaded ?? false)
|
||||||
|
|
||||||
@@ -228,11 +232,12 @@ export function deriveMacWechatSenderStatus({
|
|||||||
imageHookInstalled: identityMatches && (binding?.canSendImage ?? false),
|
imageHookInstalled: identityMatches && (binding?.canSendImage ?? false),
|
||||||
imageHookReady: identityMatches && (binding?.canSendImage ?? false),
|
imageHookReady: identityMatches && (binding?.canSendImage ?? false),
|
||||||
messageListenerReady: scriptLoaded,
|
messageListenerReady: scriptLoaded,
|
||||||
canSend: canSendText || canSendImage || canSendVoice || canSendVideo,
|
canSend: canSendText || canSendImage || canSendVoice || canSendVideo || canSendFile,
|
||||||
canSendText,
|
canSendText,
|
||||||
canSendImage,
|
canSendImage,
|
||||||
canSendVoice,
|
canSendVoice,
|
||||||
canSendVideo,
|
canSendVideo,
|
||||||
|
canSendFile,
|
||||||
message,
|
message,
|
||||||
error: state === 'error' ? message : undefined
|
error: state === 'error' ? message : undefined
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ export class PersonalWechatCapabilityService {
|
|||||||
text: Boolean(senderStatus.canSendText),
|
text: Boolean(senderStatus.canSendText),
|
||||||
image: Boolean(senderStatus.canSendImage),
|
image: Boolean(senderStatus.canSendImage),
|
||||||
voice: Boolean(senderStatus.canSendVoice),
|
voice: Boolean(senderStatus.canSendVoice),
|
||||||
video: Boolean(senderStatus.canSendVideo)
|
video: Boolean(senderStatus.canSendVideo),
|
||||||
|
file: Boolean(senderStatus.canSendFile)
|
||||||
}
|
}
|
||||||
const status = this.mapState(senderStatus)
|
const status = this.mapState(senderStatus)
|
||||||
const ready = status === 'ready'
|
const ready = status === 'ready'
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
writeFileSync
|
writeFileSync
|
||||||
} from 'fs'
|
} from 'fs'
|
||||||
import { homedir, tmpdir } from 'os'
|
import { homedir, tmpdir } from 'os'
|
||||||
import { delimiter, dirname, extname, join, sep } from 'path'
|
import { delimiter, dirname, extname, join, sep, basename } from 'path'
|
||||||
import { resolveBundledFfmpegPath } from '../ffmpeg-path'
|
import { resolveBundledFfmpegPath } from '../ffmpeg-path'
|
||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
import type {
|
import type {
|
||||||
@@ -36,6 +36,7 @@ const MAX_IMAGE_BYTES = 20 * 1024 * 1024
|
|||||||
const MAX_VOICE_BYTES = 20 * 1024 * 1024
|
const MAX_VOICE_BYTES = 20 * 1024 * 1024
|
||||||
/** 视频与扩展发送通道的上限保持一致。 */
|
/** 视频与扩展发送通道的上限保持一致。 */
|
||||||
const MAX_VIDEO_BYTES = 100 * 1024 * 1024
|
const MAX_VIDEO_BYTES = 100 * 1024 * 1024
|
||||||
|
const MAX_FILE_BYTES = 100 * 1024 * 1024
|
||||||
// 语音编码由 native runtime 内的 SILK 实现完成,不再是外部编码器进程。
|
// 语音编码由 native runtime 内的 SILK 实现完成,不再是外部编码器进程。
|
||||||
const VOICE_ENCODER_NAME = 'silk'
|
const VOICE_ENCODER_NAME = 'silk'
|
||||||
const VOICE_ENCODER_VERSION = 'tm-wechat-native'
|
const VOICE_ENCODER_VERSION = 'tm-wechat-native'
|
||||||
@@ -398,6 +399,66 @@ export function stageMacWechatVideoForSend(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MAC_FILE_STAGE_PREFIX = 'tm-file-'
|
||||||
|
const MAC_FILE_STAGE_RETENTION_MS = 10 * 60 * 1000
|
||||||
|
|
||||||
|
export function stageMacWechatFileForSend(
|
||||||
|
filePath: string,
|
||||||
|
wechatFilesRoot = WECHAT_FILES_ROOT
|
||||||
|
): { stagedPath: string; cleanup: () => void } {
|
||||||
|
const normalized = String(filePath || '').trim()
|
||||||
|
const containerDataRoot = dirname(dirname(wechatFilesRoot))
|
||||||
|
if (
|
||||||
|
containerDataRoot.includes('com.tencent.xinWeChat') &&
|
||||||
|
normalized.startsWith(`${containerDataRoot}${sep}`)
|
||||||
|
) {
|
||||||
|
return { stagedPath: normalized, cleanup: () => {} }
|
||||||
|
}
|
||||||
|
|
||||||
|
const documentsDir = dirname(wechatFilesRoot)
|
||||||
|
const stageDir = existsSync(documentsDir) ? documentsDir : wechatFilesRoot
|
||||||
|
mkdirSync(stageDir, { recursive: true })
|
||||||
|
|
||||||
|
const now = Date.now()
|
||||||
|
try {
|
||||||
|
for (const entry of readdirSync(stageDir)) {
|
||||||
|
if (!entry.startsWith(MAC_FILE_STAGE_PREFIX)) continue
|
||||||
|
const candidate = join(stageDir, entry)
|
||||||
|
try {
|
||||||
|
if (now - statSync(candidate).mtimeMs > MAC_FILE_STAGE_RETENTION_MS) {
|
||||||
|
unlinkSync(candidate)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Best-effort stale file cleanup.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Ignore directory listing errors.
|
||||||
|
}
|
||||||
|
|
||||||
|
const extension = extname(normalized).toLowerCase()
|
||||||
|
const safeExtension = /^\.[a-z0-9]{1,12}$/.test(extension) ? extension : '.bin'
|
||||||
|
const stagedPath = join(
|
||||||
|
stageDir,
|
||||||
|
`${MAC_FILE_STAGE_PREFIX}${randomBytes(6).toString('hex')}-${now}${safeExtension}`
|
||||||
|
)
|
||||||
|
copyFileSync(normalized, stagedPath)
|
||||||
|
|
||||||
|
return {
|
||||||
|
stagedPath,
|
||||||
|
cleanup: () => {
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
try {
|
||||||
|
unlinkSync(stagedPath)
|
||||||
|
} catch {
|
||||||
|
// Best-effort delayed cleanup after WeChat finishes asynchronous upload.
|
||||||
|
}
|
||||||
|
}, 300_000)
|
||||||
|
timer.unref?.()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Locate the current account's temporary image directory consumed by the image send path. */
|
/** Locate the current account's temporary image directory consumed by the image send path. */
|
||||||
export function findWechatImagePath(
|
export function findWechatImagePath(
|
||||||
root = WECHAT_FILES_ROOT,
|
root = WECHAT_FILES_ROOT,
|
||||||
@@ -521,6 +582,13 @@ export function buildWindowsWechatRequest(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request.type === 'file') {
|
||||||
|
return {
|
||||||
|
endpoint: '/SendMsg',
|
||||||
|
body: { toWxid: target, type: 'file', msg: String(request.filePath || '').trim() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const fromId = String(request.fromId || '').trim()
|
const fromId = String(request.fromId || '').trim()
|
||||||
const filePath = String(options.filePath || request.filePath || '').trim()
|
const filePath = String(options.filePath || request.filePath || '').trim()
|
||||||
const durationMs = options.durationMs ?? request.durationMs
|
const durationMs = options.durationMs ?? request.durationMs
|
||||||
@@ -558,6 +626,7 @@ function windowsStatusBase(host = windowsHookHost() || ''): PersonalWechatSender
|
|||||||
canSendImage: false,
|
canSendImage: false,
|
||||||
canSendVoice: false,
|
canSendVoice: false,
|
||||||
canSendVideo: false,
|
canSendVideo: false,
|
||||||
|
canSendFile: false,
|
||||||
message: '正在检查 Windows 微信消息接口'
|
message: '正在检查 Windows 微信消息接口'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -687,6 +756,7 @@ export class PersonalWechatSendService {
|
|||||||
if (request.type === 'image') return this.sendMacImage(request)
|
if (request.type === 'image') return this.sendMacImage(request)
|
||||||
if (request.type === 'voice') return this.sendMacVoice(request)
|
if (request.type === 'voice') return this.sendMacVoice(request)
|
||||||
if (request.type === 'video') return this.sendMacVideo(request)
|
if (request.type === 'video') return this.sendMacVideo(request)
|
||||||
|
if (request.type === 'file') return this.sendMacFile(request)
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
@@ -907,6 +977,56 @@ export class PersonalWechatSendService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async sendMacFile(
|
||||||
|
request: Extract<PersonalWechatSendRequest, { type: 'file' }>
|
||||||
|
): Promise<PersonalWechatSendResult> {
|
||||||
|
await macWechatRuntimeManager.ensureStarted()
|
||||||
|
const status = await macWechatRuntimeManager.buildSenderStatus()
|
||||||
|
if (!status.canSendFile) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
status,
|
||||||
|
error: status.message || '当前微信发送组件不支持文件,请升级后重试'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const filePath = String(request.filePath || '').trim()
|
||||||
|
if (!filePath || !existsSync(filePath)) {
|
||||||
|
return { success: false, status, error: '请选择有效的文件' }
|
||||||
|
}
|
||||||
|
const size = statSync(filePath).size
|
||||||
|
if (size <= 0 || size > MAX_FILE_BYTES) {
|
||||||
|
return { success: false, status, error: '文件必须小于 100 MB' }
|
||||||
|
}
|
||||||
|
const fileName = String(request.fileName || '').trim() || basename(filePath)
|
||||||
|
|
||||||
|
let staged: { stagedPath: string; cleanup: () => void } | null = null
|
||||||
|
try {
|
||||||
|
staged = stageMacWechatFileForSend(filePath, this.wechatFilesRoot)
|
||||||
|
} catch (error) {
|
||||||
|
const latest = await macWechatRuntimeManager.buildSenderStatus()
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
status: latest,
|
||||||
|
error: error instanceof Error ? error.message : '无法将文件暂存到微信沙盒目录'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await this.postMacHost(
|
||||||
|
'/sendMsg',
|
||||||
|
{ to: request.to, type: 'file', path: staged.stagedPath, name: fileName },
|
||||||
|
180_000
|
||||||
|
)
|
||||||
|
const latest = await macWechatRuntimeManager.buildSenderStatus()
|
||||||
|
if (!result?.ok) {
|
||||||
|
return { success: false, status: latest, error: result?.message || '文件发送失败' }
|
||||||
|
}
|
||||||
|
return { success: true, status: latest }
|
||||||
|
} finally {
|
||||||
|
staged.cleanup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async sendMacImage(
|
private async sendMacImage(
|
||||||
request: Extract<PersonalWechatSendRequest, { type: 'image' }>
|
request: Extract<PersonalWechatSendRequest, { type: 'image' }>
|
||||||
): Promise<PersonalWechatSendResult> {
|
): Promise<PersonalWechatSendResult> {
|
||||||
@@ -1100,6 +1220,10 @@ export class PersonalWechatSendService {
|
|||||||
}
|
}
|
||||||
request = { ...request, to, text }
|
request = { ...request, to, text }
|
||||||
} else {
|
} else {
|
||||||
|
if (request.type === 'file') {
|
||||||
|
const status = await this.getWindowsStatus()
|
||||||
|
return { success: false, status, error: 'Windows 端暂不支持文件发送' }
|
||||||
|
}
|
||||||
const filePath = String(request.filePath || '').trim()
|
const filePath = String(request.filePath || '').trim()
|
||||||
const label = request.type === 'voice' ? '语音' : request.type === 'video' ? '视频' : '图片'
|
const label = request.type === 'voice' ? '语音' : request.type === 'video' ? '视频' : '图片'
|
||||||
const limit =
|
const limit =
|
||||||
|
|||||||
@@ -443,7 +443,8 @@ export class WechatActionGateway {
|
|||||||
(request.content.type !== 'text' &&
|
(request.content.type !== 'text' &&
|
||||||
request.content.type !== 'image' &&
|
request.content.type !== 'image' &&
|
||||||
request.content.type !== 'video' &&
|
request.content.type !== 'video' &&
|
||||||
request.content.type !== 'voice')
|
request.content.type !== 'voice' &&
|
||||||
|
request.content.type !== 'file')
|
||||||
) {
|
) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -593,9 +594,18 @@ export function normalizeActionRequest(value: unknown): WechatActionRequest | nu
|
|||||||
content: { type: 'text', text, ...(at ? { at } : {}) }
|
content: { type: 'text', text, ...(at ? { at } : {}) }
|
||||||
} as WechatActionRequest
|
} as WechatActionRequest
|
||||||
}
|
}
|
||||||
if (contentType !== 'image' && contentType !== 'video' && contentType !== 'voice') return null
|
if (
|
||||||
|
contentType !== 'image' &&
|
||||||
|
contentType !== 'video' &&
|
||||||
|
contentType !== 'voice' &&
|
||||||
|
contentType !== 'file'
|
||||||
|
) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
const filePath = String((content as { path?: unknown }).path || '').trim()
|
const filePath = String((content as { path?: unknown }).path || '').trim()
|
||||||
if (!filePath) return null
|
if (!filePath) return null
|
||||||
|
const contentName =
|
||||||
|
contentType === 'file' ? String((content as { name?: unknown }).name || '').trim() : ''
|
||||||
return {
|
return {
|
||||||
...input,
|
...input,
|
||||||
origin,
|
origin,
|
||||||
@@ -612,7 +622,10 @@ export function normalizeActionRequest(value: unknown): WechatActionRequest | nu
|
|||||||
? { name: String((recipient as { name?: unknown }).name).trim() }
|
? { name: String((recipient as { name?: unknown }).name).trim() }
|
||||||
: {})
|
: {})
|
||||||
},
|
},
|
||||||
content: { type: contentType, path: filePath }
|
content:
|
||||||
|
contentType === 'file'
|
||||||
|
? { type: 'file', path: filePath, ...(contentName ? { name: contentName } : {}) }
|
||||||
|
: { type: contentType, path: filePath }
|
||||||
} as WechatActionRequest
|
} as WechatActionRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -655,6 +668,14 @@ function toPersonalWechatSendRequest(request: WechatActionRequest): PersonalWech
|
|||||||
if (request.content.type === 'video') {
|
if (request.content.type === 'video') {
|
||||||
return { ...base, type: 'video', filePath: request.content.path }
|
return { ...base, type: 'video', filePath: request.content.path }
|
||||||
}
|
}
|
||||||
|
if (request.content.type === 'file') {
|
||||||
|
return {
|
||||||
|
...base,
|
||||||
|
type: 'file',
|
||||||
|
filePath: request.content.path,
|
||||||
|
...(request.content.name ? { fileName: request.content.name } : {})
|
||||||
|
}
|
||||||
|
}
|
||||||
const metadata = request.metadata && typeof request.metadata === 'object' ? request.metadata : {}
|
const metadata = request.metadata && typeof request.metadata === 'object' ? request.metadata : {}
|
||||||
const fromId = typeof metadata.fromId === 'string' ? metadata.fromId.trim() : ''
|
const fromId = typeof metadata.fromId === 'string' ? metadata.fromId.trim() : ''
|
||||||
const durationMs =
|
const durationMs =
|
||||||
@@ -700,7 +721,12 @@ function contentAudit(
|
|||||||
content: WechatActionContent
|
content: WechatActionContent
|
||||||
): Pick<WechatActionAuditRecord, 'contentPreview' | 'contentHash'> {
|
): Pick<WechatActionAuditRecord, 'contentPreview' | 'contentHash'> {
|
||||||
const raw = content.type === 'text' ? content.text : content.path
|
const raw = content.type === 'text' ? content.text : content.path
|
||||||
const preview = content.type === 'text' ? raw : path.basename(raw)
|
const preview =
|
||||||
|
content.type === 'text'
|
||||||
|
? raw
|
||||||
|
: content.type === 'file' && content.name
|
||||||
|
? content.name
|
||||||
|
: path.basename(raw)
|
||||||
return {
|
return {
|
||||||
contentPreview: preview.slice(0, MAX_CONTENT_PREVIEW_LENGTH),
|
contentPreview: preview.slice(0, MAX_CONTENT_PREVIEW_LENGTH),
|
||||||
contentHash: createHash('sha256').update(raw).digest('hex')
|
contentHash: createHash('sha256').update(raw).digest('hex')
|
||||||
@@ -708,7 +734,15 @@ function contentAudit(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function contentTypeLabel(type: WechatActionContent['type']): string {
|
function contentTypeLabel(type: WechatActionContent['type']): string {
|
||||||
return type === 'text' ? '文字' : type === 'image' ? '图片' : type === 'video' ? '视频' : '语音'
|
return type === 'text'
|
||||||
|
? '文字'
|
||||||
|
: type === 'image'
|
||||||
|
? '图片'
|
||||||
|
: type === 'video'
|
||||||
|
? '视频'
|
||||||
|
: type === 'file'
|
||||||
|
? '文件'
|
||||||
|
: '语音'
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeAuditRecords(values: unknown[]): WechatActionAuditRecord[] {
|
function normalizeAuditRecords(values: unknown[]): WechatActionAuditRecord[] {
|
||||||
|
|||||||
Vendored
+6
@@ -797,6 +797,12 @@ declare global {
|
|||||||
sendPersonalWechatMessage: (
|
sendPersonalWechatMessage: (
|
||||||
request: PersonalWechatSendRequest
|
request: PersonalWechatSendRequest
|
||||||
) => Promise<PersonalWechatSendResult>
|
) => Promise<PersonalWechatSendResult>
|
||||||
|
selectPersonalWechatFile: () => Promise<{
|
||||||
|
canceled: boolean
|
||||||
|
path?: string
|
||||||
|
name?: string
|
||||||
|
size?: number
|
||||||
|
}>
|
||||||
/** 定时日报:「立即执行」——与 scheduler 走同一条执行链路(manual trigger)。 */
|
/** 定时日报:「立即执行」——与 scheduler 走同一条执行链路(manual trigger)。 */
|
||||||
runScheduledReportRule: (
|
runScheduledReportRule: (
|
||||||
ruleId: string
|
ruleId: string
|
||||||
|
|||||||
@@ -736,6 +736,12 @@ const api = {
|
|||||||
sendPersonalWechatMessage: (
|
sendPersonalWechatMessage: (
|
||||||
request: PersonalWechatSendRequest
|
request: PersonalWechatSendRequest
|
||||||
): Promise<PersonalWechatSendResult> => ipcRenderer.invoke('wechat-personal:send', request),
|
): Promise<PersonalWechatSendResult> => ipcRenderer.invoke('wechat-personal:send', request),
|
||||||
|
selectPersonalWechatFile: (): Promise<{
|
||||||
|
canceled: boolean
|
||||||
|
path?: string
|
||||||
|
name?: string
|
||||||
|
size?: number
|
||||||
|
}> => ipcRenderer.invoke('wechat-personal:selectFile'),
|
||||||
/**
|
/**
|
||||||
* 定时日报(Automation 的 `scheduled_report` 规则类型)。
|
* 定时日报(Automation 的 `scheduled_report` 规则类型)。
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { MessageList } from './chat/MessageList'
|
|||||||
import { PersonalWechatSendDialog } from './chat/PersonalWechatSendDialog'
|
import { PersonalWechatSendDialog } from './chat/PersonalWechatSendDialog'
|
||||||
import { mergeGroupExitEvents } from '../../../shared/group-exit-event-message'
|
import { mergeGroupExitEvents } from '../../../shared/group-exit-event-message'
|
||||||
import { useGroupExitEvents } from '../hooks/useGroupExitEvents'
|
import { useGroupExitEvents } from '../hooks/useGroupExitEvents'
|
||||||
|
import { isMac } from '../utils/runtime-environment'
|
||||||
|
|
||||||
interface ChatWindowProps {
|
interface ChatWindowProps {
|
||||||
contact: Contact | null
|
contact: Contact | null
|
||||||
@@ -59,6 +60,7 @@ const ChatWindow: React.FC<ChatWindowProps> = ({
|
|||||||
const [isAtLatest, setIsAtLatest] = useState(true)
|
const [isAtLatest, setIsAtLatest] = useState(true)
|
||||||
const [isReloadingAvatars, setIsReloadingAvatars] = useState(false)
|
const [isReloadingAvatars, setIsReloadingAvatars] = useState(false)
|
||||||
const [sendDialogOpen, setSendDialogOpen] = useState(false)
|
const [sendDialogOpen, setSendDialogOpen] = useState(false)
|
||||||
|
const [pendingFile, setPendingFile] = useState<{ path: string; name: string } | null>(null)
|
||||||
const previousScrollTopRef = useRef(0)
|
const previousScrollTopRef = useRef(0)
|
||||||
|
|
||||||
const scrollToBottom = useCallback((): void => {
|
const scrollToBottom = useCallback((): void => {
|
||||||
@@ -167,6 +169,17 @@ const ChatWindow: React.FC<ChatWindowProps> = ({
|
|||||||
setSendDialogOpen(true)
|
setSendDialogOpen(true)
|
||||||
}, [onOpenPersonalWechatSettings])
|
}, [onOpenPersonalWechatSettings])
|
||||||
|
|
||||||
|
const handleSendFile = useCallback(async (): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const picked = await window.api.selectPersonalWechatFile()
|
||||||
|
if (picked.canceled || !picked.path || !picked.name) return
|
||||||
|
setPendingFile({ path: picked.path, name: picked.name })
|
||||||
|
setSendDialogOpen(true)
|
||||||
|
} catch {
|
||||||
|
// 选择器本身失败(无窗口、无权限)时什么都不做,不要弹出一个空对话框。
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
if (!contact) return <EmptyConversationState />
|
if (!contact) return <EmptyConversationState />
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -181,6 +194,7 @@ const ChatWindow: React.FC<ChatWindowProps> = ({
|
|||||||
onContentFilterChange={onContentFilterChange || (() => undefined)}
|
onContentFilterChange={onContentFilterChange || (() => undefined)}
|
||||||
onRefresh={onRefresh}
|
onRefresh={onRefresh}
|
||||||
onTestSend={() => void handleOpenPersonalWechatSend()}
|
onTestSend={() => void handleOpenPersonalWechatSend()}
|
||||||
|
onSendFile={isMac ? () => void handleSendFile() : undefined}
|
||||||
onOpenAiSettings={onCreateGroupReport || (() => undefined)}
|
onOpenAiSettings={onCreateGroupReport || (() => undefined)}
|
||||||
onOpenLocalIndexSettings={onOpenLocalIndexSettings}
|
onOpenLocalIndexSettings={onOpenLocalIndexSettings}
|
||||||
/>
|
/>
|
||||||
@@ -215,9 +229,13 @@ const ChatWindow: React.FC<ChatWindowProps> = ({
|
|||||||
<PersonalWechatSendDialog
|
<PersonalWechatSendDialog
|
||||||
contact={contact}
|
contact={contact}
|
||||||
isGroupChat={isGroupChat}
|
isGroupChat={isGroupChat}
|
||||||
onClose={() => setSendDialogOpen(false)}
|
onClose={() => {
|
||||||
|
setSendDialogOpen(false)
|
||||||
|
setPendingFile(null)
|
||||||
|
}}
|
||||||
onOpenTextToSpeechSettings={onOpenTextToSpeechSettings}
|
onOpenTextToSpeechSettings={onOpenTextToSpeechSettings}
|
||||||
onOpenPersonalWechatSettings={onOpenPersonalWechatSettings}
|
onOpenPersonalWechatSettings={onOpenPersonalWechatSettings}
|
||||||
|
initialFile={pendingFile}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { useState } from 'react'
|
|||||||
import { Contact } from '../../../../shared/types'
|
import { Contact } from '../../../../shared/types'
|
||||||
import { Button, IconButton, Tooltip, TooltipContent, TooltipTrigger } from '../ui'
|
import { Button, IconButton, Tooltip, TooltipContent, TooltipTrigger } from '../ui'
|
||||||
import { ConversationContentSearch } from './ConversationContentSearch'
|
import { ConversationContentSearch } from './ConversationContentSearch'
|
||||||
import { AiIcon, RefreshIcon, SearchIcon, SendIcon, StatsIcon } from './icons'
|
import { AiIcon, ExportIcon, RefreshIcon, SearchIcon, SendIcon, StatsIcon } from './icons'
|
||||||
import { supportsPersonalWechatSend } from '../../utils/runtime-environment'
|
import { supportsPersonalWechatSend } from '../../utils/runtime-environment'
|
||||||
import { GroupMemberStatsDialog } from '../group-stats/GroupMemberStatsDialog'
|
import { GroupMemberStatsDialog } from '../group-stats/GroupMemberStatsDialog'
|
||||||
|
|
||||||
@@ -16,6 +16,7 @@ interface ChatHeaderProps {
|
|||||||
onContentFilterChange: (value: string) => void
|
onContentFilterChange: (value: string) => void
|
||||||
onRefresh?: () => void
|
onRefresh?: () => void
|
||||||
onTestSend: () => void
|
onTestSend: () => void
|
||||||
|
onSendFile?: () => void
|
||||||
onOpenAiSettings: () => void
|
onOpenAiSettings: () => void
|
||||||
/** 跳到「设置 · 本地索引」(群统计发现索引没追平时用)。 */
|
/** 跳到「设置 · 本地索引」(群统计发现索引没追平时用)。 */
|
||||||
onOpenLocalIndexSettings?: () => void
|
onOpenLocalIndexSettings?: () => void
|
||||||
@@ -31,6 +32,7 @@ export function ChatHeader({
|
|||||||
onContentFilterChange,
|
onContentFilterChange,
|
||||||
onRefresh,
|
onRefresh,
|
||||||
onTestSend,
|
onTestSend,
|
||||||
|
onSendFile,
|
||||||
onOpenAiSettings,
|
onOpenAiSettings,
|
||||||
onOpenLocalIndexSettings
|
onOpenLocalIndexSettings
|
||||||
}: ChatHeaderProps): React.ReactElement {
|
}: ChatHeaderProps): React.ReactElement {
|
||||||
@@ -131,6 +133,19 @@ export function ChatHeader({
|
|||||||
<TooltipContent>仅支持 macOS 和 Windows</TooltipContent>
|
<TooltipContent>仅支持 macOS 和 Windows</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
|
{supportsPersonalWechatSend && onSendFile ? (
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
className="chat-header-text-action"
|
||||||
|
aria-label="发送文件"
|
||||||
|
title="发送文件"
|
||||||
|
onClick={onSendFile}
|
||||||
|
>
|
||||||
|
<ExportIcon />
|
||||||
|
<span>发送文件</span>
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
<Button
|
<Button
|
||||||
variant="default"
|
variant="default"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export interface PersonalWechatSendDialogProps {
|
|||||||
onOpenPersonalWechatSettings?: () => void
|
onOpenPersonalWechatSettings?: () => void
|
||||||
initialMode?: 'text' | 'image' | 'voice'
|
initialMode?: 'text' | 'image' | 'voice'
|
||||||
initialImage?: SelectedLocalFile | null
|
initialImage?: SelectedLocalFile | null
|
||||||
|
initialFile?: SelectedLocalFile | null
|
||||||
}
|
}
|
||||||
|
|
||||||
function fallbackStatus(error: unknown): PersonalWechatSenderStatus {
|
function fallbackStatus(error: unknown): PersonalWechatSenderStatus {
|
||||||
@@ -62,7 +63,8 @@ function PersonalWechatMacSendDialog({
|
|||||||
isGroupChat,
|
isGroupChat,
|
||||||
onClose,
|
onClose,
|
||||||
onOpenTextToSpeechSettings,
|
onOpenTextToSpeechSettings,
|
||||||
initialImage = null
|
initialImage = null,
|
||||||
|
initialFile = null
|
||||||
}: PersonalWechatSendDialogProps): React.ReactElement {
|
}: PersonalWechatSendDialogProps): React.ReactElement {
|
||||||
const [senderStatus, setSenderStatus] = useState<PersonalWechatSenderStatus | null>(null)
|
const [senderStatus, setSenderStatus] = useState<PersonalWechatSenderStatus | null>(null)
|
||||||
const [detecting, setDetecting] = useState(true)
|
const [detecting, setDetecting] = useState(true)
|
||||||
@@ -81,7 +83,13 @@ function PersonalWechatMacSendDialog({
|
|||||||
const displayName = contact.m_nsNickName || contact.m_nsUsrName || '未命名会话'
|
const displayName = contact.m_nsNickName || contact.m_nsUsrName || '未命名会话'
|
||||||
const targetId = contact.m_nsUsrName
|
const targetId = contact.m_nsUsrName
|
||||||
const isBusy = binding || sendBusy
|
const isBusy = binding || sendBusy
|
||||||
const setupReady = Boolean(initialImage ? senderStatus?.canSendImage : senderStatus?.canSendVoice)
|
const setupReady = Boolean(
|
||||||
|
initialFile
|
||||||
|
? senderStatus?.canSendFile
|
||||||
|
: initialImage
|
||||||
|
? senderStatus?.canSendImage
|
||||||
|
: senderStatus?.canSendVoice
|
||||||
|
)
|
||||||
const { postfixText, setPostfixText, persistPostfixText } = useReportImagePostfixSetting(
|
const { postfixText, setPostfixText, persistPostfixText } = useReportImagePostfixSetting(
|
||||||
Boolean(initialImage)
|
Boolean(initialImage)
|
||||||
)
|
)
|
||||||
@@ -237,8 +245,33 @@ function PersonalWechatMacSendDialog({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleOpenVoiceDiagnostic = async (): Promise<void> => {
|
const handleSendFile = async (): Promise<void> => {
|
||||||
if (!isMac) return
|
if (!initialFile || !senderStatus?.canSendFile || sendBusy) return
|
||||||
|
setSendBusy(true)
|
||||||
|
setSendError(null)
|
||||||
|
setSendSuccess(null)
|
||||||
|
try {
|
||||||
|
const response = await window.api.sendPersonalWechatMessage({
|
||||||
|
type: 'file',
|
||||||
|
to: targetId,
|
||||||
|
isGroup: isGroupChat,
|
||||||
|
filePath: initialFile.path,
|
||||||
|
fileName: initialFile.name
|
||||||
|
} satisfies PersonalWechatSendRequest)
|
||||||
|
setSenderStatus(response.status)
|
||||||
|
if (!response.success) {
|
||||||
|
setSendError(response.error || '文件发送失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setSendSuccess('文件发送成功')
|
||||||
|
} catch (error) {
|
||||||
|
setSendError(error instanceof Error ? error.message : String(error))
|
||||||
|
} finally {
|
||||||
|
setSendBusy(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleOpenVoiceDiagnostic = async (): Promise<void> => { if (!isMac) return
|
||||||
const diagnostic = await window.api.getPersonalWechatVoiceDiagnostic()
|
const diagnostic = await window.api.getPersonalWechatVoiceDiagnostic()
|
||||||
setVoiceDiagnostic(diagnostic)
|
setVoiceDiagnostic(diagnostic)
|
||||||
setVoiceDiagnosticOpen(true)
|
setVoiceDiagnosticOpen(true)
|
||||||
@@ -263,7 +296,9 @@ function PersonalWechatMacSendDialog({
|
|||||||
{displayName.slice(0, 1)}
|
{displayName.slice(0, 1)}
|
||||||
</div>
|
</div>
|
||||||
<div className="personal-wechat-chat-heading">
|
<div className="personal-wechat-chat-heading">
|
||||||
<DialogTitle>{initialImage ? '发送日报图片' : '文字转语音'}</DialogTitle>
|
<DialogTitle>
|
||||||
|
{initialFile ? '发送文件' : initialImage ? '发送日报图片' : '文字转语音'}
|
||||||
|
</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
发送给 {displayName} · {setupReady ? '微信已连接' : '配置微信发送能力'}
|
发送给 {displayName} · {setupReady ? '微信已连接' : '配置微信发送能力'}
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
@@ -275,7 +310,7 @@ function PersonalWechatMacSendDialog({
|
|||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
<div className="personal-wechat-chat-body">
|
<div className="personal-wechat-chat-body">
|
||||||
{setupReady && !initialImage && (
|
{setupReady && !initialImage && !initialFile && (
|
||||||
<div className="personal-wechat-message-list" aria-label="消息列表">
|
<div className="personal-wechat-message-list" aria-label="消息列表">
|
||||||
{messages.length === 0 ? (
|
{messages.length === 0 ? (
|
||||||
<div className="personal-wechat-empty-message">还没有发送消息。</div>
|
<div className="personal-wechat-empty-message">还没有发送消息。</div>
|
||||||
@@ -324,7 +359,16 @@ function PersonalWechatMacSendDialog({
|
|||||||
</section>
|
</section>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{setupReady && !initialImage && (
|
{setupReady && initialFile && (
|
||||||
|
<section className="personal-wechat-composer" aria-label="文件发送">
|
||||||
|
<p>已选择文件:{initialFile.name}</p>
|
||||||
|
<Button size="sm" onClick={() => void handleSendFile()} disabled={sendBusy}>
|
||||||
|
{sendBusy ? '发送中…' : '发送文件'}
|
||||||
|
</Button>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{setupReady && !initialImage && !initialFile && (
|
||||||
<PersonalWechatChatComposer
|
<PersonalWechatChatComposer
|
||||||
status={senderStatus!}
|
status={senderStatus!}
|
||||||
targetId={targetId}
|
targetId={targetId}
|
||||||
@@ -346,7 +390,7 @@ function PersonalWechatMacSendDialog({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{setupReady && isMac && !initialImage && (
|
{setupReady && isMac && !initialImage && !initialFile && (
|
||||||
<div className="personal-wechat-chat-footer flex items-center justify-end">
|
<div className="personal-wechat-chat-footer flex items-center justify-end">
|
||||||
<Button variant="link" size="sm" onClick={() => void handleOpenVoiceDiagnostic()}>
|
<Button variant="link" size="sm" onClick={() => void handleOpenVoiceDiagnostic()}>
|
||||||
语音发送诊断
|
语音发送诊断
|
||||||
|
|||||||
@@ -67,13 +67,14 @@ export interface MacWechatRuntimeManifest {
|
|||||||
tmSendSourceSha256: string
|
tmSendSourceSha256: string
|
||||||
addressProfileSha256: string
|
addressProfileSha256: string
|
||||||
supportedWechatVersions: string[]
|
supportedWechatVersions: string[]
|
||||||
capabilities: Array<'text' | 'image' | 'voice'>
|
capabilities: Array<'text' | 'image' | 'voice' | 'file'>
|
||||||
capabilitiesByVersion?: Record<
|
capabilitiesByVersion?: Record<
|
||||||
string,
|
string,
|
||||||
{
|
{
|
||||||
text?: 'verified' | 'addresses-only' | 'unsupported'
|
text?: 'verified' | 'addresses-only' | 'unsupported'
|
||||||
image?: 'verified' | 'addresses-only' | 'unsupported'
|
image?: 'verified' | 'addresses-only' | 'unsupported'
|
||||||
voice?: 'verified' | 'addresses-only' | 'unsupported'
|
voice?: 'verified' | 'addresses-only' | 'unsupported'
|
||||||
|
file?: 'verified' | 'addresses-only' | 'unsupported'
|
||||||
downloadImage?: 'verified' | 'addresses-only' | 'unsupported'
|
downloadImage?: 'verified' | 'addresses-only' | 'unsupported'
|
||||||
textMechanism?: string
|
textMechanism?: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export interface PersonalWechatSenderStatus {
|
|||||||
canSendVoice: boolean
|
canSendVoice: boolean
|
||||||
/** 视频与图片共用媒体通道;旧 runtime 不报告该字段。 */
|
/** 视频与图片共用媒体通道;旧 runtime 不报告该字段。 */
|
||||||
canSendVideo?: boolean
|
canSendVideo?: boolean
|
||||||
|
canSendFile?: boolean
|
||||||
message: string
|
message: string
|
||||||
error?: string
|
error?: string
|
||||||
}
|
}
|
||||||
@@ -64,6 +65,7 @@ export interface PersonalWechatSendCapability {
|
|||||||
voice: boolean
|
voice: boolean
|
||||||
/** 图片/视频共用媒体通道;未报告的旧 runtime 视为 false。 */
|
/** 图片/视频共用媒体通道;未报告的旧 runtime 视为 false。 */
|
||||||
video?: boolean
|
video?: boolean
|
||||||
|
file?: boolean
|
||||||
}
|
}
|
||||||
senderStatus: PersonalWechatSenderStatus
|
senderStatus: PersonalWechatSenderStatus
|
||||||
message: string
|
message: string
|
||||||
@@ -108,11 +110,18 @@ export interface PersonalWechatSendVideoRequest extends PersonalWechatSendBaseRe
|
|||||||
filePath: string
|
filePath: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PersonalWechatSendFileRequest extends PersonalWechatSendBaseRequest {
|
||||||
|
type: 'file'
|
||||||
|
filePath: string
|
||||||
|
fileName?: string
|
||||||
|
}
|
||||||
|
|
||||||
export type PersonalWechatSendRequest =
|
export type PersonalWechatSendRequest =
|
||||||
| PersonalWechatSendTextRequest
|
| PersonalWechatSendTextRequest
|
||||||
| PersonalWechatSendImageRequest
|
| PersonalWechatSendImageRequest
|
||||||
| PersonalWechatSendVoiceRequest
|
| PersonalWechatSendVoiceRequest
|
||||||
| PersonalWechatSendVideoRequest
|
| PersonalWechatSendVideoRequest
|
||||||
|
| PersonalWechatSendFileRequest
|
||||||
|
|
||||||
/** Renderer 请求发送刚刚生成的 TTS 语音;Action 元数据由主进程补齐。 */
|
/** Renderer 请求发送刚刚生成的 TTS 语音;Action 元数据由主进程补齐。 */
|
||||||
export interface PersonalWechatGeneratedTtsVoiceRequest {
|
export interface PersonalWechatGeneratedTtsVoiceRequest {
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export type WechatActionPurpose =
|
|||||||
| 'manual_image'
|
| 'manual_image'
|
||||||
/** 用户手动发送文本。 */
|
/** 用户手动发送文本。 */
|
||||||
| 'manual_text'
|
| 'manual_text'
|
||||||
|
| 'manual_file'
|
||||||
/** 外部 Agent 经本地 HTTP API 发送;按内容类型分开,便于审计统计。 */
|
/** 外部 Agent 经本地 HTTP API 发送;按内容类型分开,便于审计统计。 */
|
||||||
| 'api_text'
|
| 'api_text'
|
||||||
| 'api_image'
|
| 'api_image'
|
||||||
@@ -76,6 +77,7 @@ export type WechatActionContent =
|
|||||||
| { type: 'image'; path: string }
|
| { type: 'image'; path: string }
|
||||||
| { type: 'video'; path: string }
|
| { type: 'video'; path: string }
|
||||||
| { type: 'voice'; path: string }
|
| { type: 'voice'; path: string }
|
||||||
|
| { type: 'file'; path: string; name?: string }
|
||||||
|
|
||||||
export interface WechatActionRequest {
|
export interface WechatActionRequest {
|
||||||
/** 可选的操作编号;未提供时会自动生成。 */
|
/** 可选的操作编号;未提供时会自动生成。 */
|
||||||
|
|||||||
Reference in new issue
Block a user