- 外围功能模块(补字幕、原站视图、桌面模式、网页搜索、MCP、定时任务)声明 manifest,与 FEATURES 一一对应; 系统提示「能力地图」末尾列出外围功能(没有开关,能力只列本次可用的) - 补字幕:订阅 organization.finished(认出值得补字幕的整理,自动补字幕还没做,不建任务), 写入字幕后在同一事务发 subtitle.written;原有行为不变 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
57 lines
2.2 KiB
TypeScript
57 lines
2.2 KiB
TypeScript
import { featureManifest } from "@umt/contracts";
|
|
import { sourcesIdentityModule } from "../sources-identity/index.ts";
|
|
import type { ServerContext, ServerModule } from "../types.ts";
|
|
import { registerBrowserCapabilities } from "./capabilities.ts";
|
|
import { registerBrowserRoutes } from "./routes.ts";
|
|
import { type BrowserModuleOptions, BrowserService } from "./service.ts";
|
|
|
|
/** 进程内:ServerContext → 本模块为它建的 BrowserService(agent 模块的视觉子流程要与能力共用同一实例) */
|
|
const byCtx = new WeakMap<ServerContext, BrowserService>();
|
|
|
|
/** 取浏览器模块为这个上下文建的服务;浏览器模块没装配时返回 null */
|
|
export function browserServiceFor(ctx: ServerContext): BrowserService | null {
|
|
return byCtx.get(ctx) ?? null;
|
|
}
|
|
|
|
/**
|
|
* C1-E 浏览器:BrowserProvider(camofox)之上的站点浏览器会话、原站视图与人工接管、Agent 浏览器能力。
|
|
* 会话/标签/租约以数据库(0023 四张表)为准;站点限流与 sources-identity 共享;下载产物只进后端暂存核验,
|
|
* 提交走 POST /acquisition-plans 同一流程。运维与真实实例核验见 docs/runbook/browser.md。
|
|
*/
|
|
export function createBrowserModule(opts: BrowserModuleOptions = {}): ServerModule & {
|
|
service(ctx: ServerContext): BrowserService;
|
|
} {
|
|
const services = new WeakMap<ServerContext, BrowserService>();
|
|
const options: BrowserModuleOptions = {
|
|
runtime: (ctx) => sourcesIdentityModule.runtime(ctx),
|
|
...opts,
|
|
};
|
|
const service = (ctx: ServerContext) => {
|
|
let s = services.get(ctx);
|
|
if (!s) {
|
|
s = new BrowserService(ctx, options);
|
|
services.set(ctx, s);
|
|
byCtx.set(ctx, s);
|
|
}
|
|
return s;
|
|
};
|
|
return {
|
|
name: "browser",
|
|
manifest: featureManifest("browser"),
|
|
service,
|
|
registerRoutes(app, ctx) {
|
|
registerBrowserRoutes(app, () => service(ctx));
|
|
},
|
|
registerTasks(_registry, ctx) {
|
|
// worker 里的 refresh-login 也要能从浏览器 profile 读回 Cookie(BR-2):建服务即注册读回钩子
|
|
service(ctx);
|
|
},
|
|
registerCapabilities(registry, ctx) {
|
|
service(ctx);
|
|
registerBrowserCapabilities(registry, () => service(ctx));
|
|
},
|
|
};
|
|
}
|
|
|
|
export const browserModule = createBrowserModule();
|