feat: generate and edit conversation images across runtimes

Add model-controlled image invocation and read-only runtime assignments. Route image tools through Main so accepted operations retain their originating conversation when chat runtimes change, with saved references, cancellation, and manual recovery.

Keep Node hashing outside browser-shared contracts to restore production builds. Validation includes the production build, typecheck, lint, focused regressions, real Host transport checks, and two successful real image requests. Full UI-driven runtime switching acceptance remains documented as pending.

Release note: 开启图片模型的会话调用后,聊天助手可调用图片生成与编辑工具,Runtime 分配自动管理。图片成果保存在原会话,可继续修改,并独立显示生成状态和取消入口。
This commit is contained in:
mesalogo
2026-09-15 15:51:52 +08:00
parent e5aa9ed688
commit f8d07419d2
78 changed files with 2948 additions and 330 deletions
+10 -2
View File
@@ -2681,9 +2681,15 @@ export class ModelAgentRuntime implements AgentRuntime {
return history
}
/** Strict image service entry point; direct-image conversations retain their fallback policy. */
generateImage(request: AgentExecutionRequest, signal: AbortSignal): AsyncGenerator<RuntimeEvent, void, void> {
return this.runImageGeneration(request, signal, false)
}
private async *runImageGeneration(
request: AgentExecutionRequest,
signal: AbortSignal
signal: AbortSignal,
allowEditingFallback = true
): AsyncGenerator<RuntimeEvent, void, void> {
const images = request.images ?? []
const prompt = imageConversationPrompt(request)
@@ -2744,7 +2750,7 @@ export class ModelAgentRuntime implements AgentRuntime {
)
const providerMessage = getErrorMessage(errorPayload)
if (
images.length > 0 &&
allowEditingFallback && images.length > 0 &&
isImageEditingUnavailable(response.status, providerMessage)
) {
signal.throwIfAborted()
@@ -3417,6 +3423,7 @@ export class ModelAgentRuntime implements AgentRuntime {
wakeNestedEvents = undefined
}
const toolContext: ModelToolCallContext = {
imageToolBinding: request.imageToolBinding,
conversationId: request.conversationId,
browserTabId: request.browserTabId,
browserConversationId: request.browserConversationId,
@@ -3743,6 +3750,7 @@ export class ModelAgentRuntime implements AgentRuntime {
let roundContextBytes = 0
const roundCallIds = new Set<string>()
for (const call of response.toolCalls) {
toolContext.toolCallId = call.id
signal.throwIfAborted()
if (roundCallIds.has(call.id)) {
throw new Error('模型重复使用了工具调用 ID')