feat: 增加共享 Agent Browser 调试能力
需求:在 AI 编程会话中让用户与 Agent 共享同一浏览器页面,并查看控制台与网络信息。 实现:新增沙箱浏览器内核、Host API/渲染器面板、OpenCode 工具接入及安全边界测试。
This commit is contained in:
21
electron/api/renderer-capability.ts
Normal file
21
electron/api/renderer-capability.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { randomBytes } from 'node:crypto';
|
||||
import type { IncomingMessage } from 'node:http';
|
||||
|
||||
export const RENDERER_CAPABILITY_HEADER = 'x-niancode-renderer-capability';
|
||||
|
||||
let rendererCapability = '';
|
||||
|
||||
export function rotateRendererCapability(): void {
|
||||
rendererCapability = randomBytes(32).toString('hex');
|
||||
}
|
||||
|
||||
export function getRendererCapability(): string {
|
||||
return rendererCapability;
|
||||
}
|
||||
|
||||
export function hasRendererCapability(req: IncomingMessage): boolean {
|
||||
const value = req.headers[RENDERER_CAPABILITY_HEADER];
|
||||
return typeof value === 'string'
|
||||
&& rendererCapability.length > 0
|
||||
&& value === rendererCapability;
|
||||
}
|
||||
Reference in New Issue
Block a user