feat: expand multimodal and knowledge workflows

This commit is contained in:
lofyer
2026-08-10 21:25:47 +08:00
parent 0fab985f28
commit ad79659308
38 changed files with 3036 additions and 2416 deletions
+26 -4
View File
@@ -10,10 +10,12 @@ import {
} from 'electron'
import { open, realpath } from 'node:fs/promises'
import { basename, extname } from 'node:path'
import type {
AgentRequest,
ContextAttachment,
WindowCaptureOption
import {
maximumPastedImageBytes,
type PastedImageInput,
type AgentRequest,
type ContextAttachment,
type WindowCaptureOption
} from '../shared/contracts'
import type { ChannelMediaAttachment } from '../shared/channel-contracts'
import type {
@@ -193,6 +195,26 @@ export class ContextManager {
return this.toPublic(context)
}
storePastedImage(input: PastedImageInput): ContextAttachment {
if (
input.mimeType !== 'image/jpeg' &&
input.mimeType !== 'image/png' &&
input.mimeType !== 'image/webp'
) {
throw new Error('粘贴图片格式不受支持')
}
if (
input.data.byteLength === 0 ||
input.data.byteLength > maximumPastedImageBytes
) {
throw new Error('粘贴图片大小无效')
}
return this.storeImage(
'粘贴图片.jpg',
nativeImage.createFromBuffer(Buffer.from(input.data))
)
}
async ingestRemoteAttachment(
attachment: ChannelMediaAttachment
): Promise<ContextAttachment> {