fix(agent-browser): restore bounded presentation lifecycle

This commit is contained in:
2026-09-06 12:50:18 +08:00
parent 5c61110f46
commit 9fed0cc7c4
20 changed files with 1714 additions and 49 deletions

View File

@@ -1,6 +1,7 @@
import { accessSync, constants } from 'node:fs';
import path from 'node:path';
import type { AgentBrowserModule } from '../agent-browser';
import type { AgentBrowserSnapshot } from '../../shared/agent-browser';
import { CodingAttachmentStore } from '../coding-projects/attachment-store';
import { createCodingConversationStore } from '../coding-projects/conversation-store';
import { CodingProjectService } from '../coding-projects/project-service';
@@ -102,6 +103,8 @@ export interface CreateCodingCompositionOptions {
accountCache?: AccountPluginCache;
clientVersion?: string;
policyClient?: PluginPolicyClient;
requestAgentBrowserPresentation?(snapshot: AgentBrowserSnapshot): void;
publishAgentBrowserState?(snapshot: AgentBrowserSnapshot): void;
}
type PiWorkerExecutableProbe = (candidate: string) => boolean;
@@ -241,6 +244,8 @@ export function createCodingComposition(
bundledSkillsDir: options.paths.bundledSkillsDir,
modelToolRegistry,
devicePackageTools,
requestAgentBrowserPresentation: options.requestAgentBrowserPresentation,
publishAgentBrowserState: options.publishAgentBrowserState,
pluginSkillSources,
getPluginSkillSources: async () => effectiveResolver
? (await effectiveResolver.getSkillSources()).map((source) => ({
@@ -543,6 +548,9 @@ export function createCodingComposition(
runtime.dispose(conversationId, reason)
)));
if (reason === 'background_sleep' && runtime.hasActiveWork()) return;
if (reason === 'background_sleep') {
await options.browser.close().catch(() => undefined);
}
await agentServer.stop();
},
async shutdown() {