升级插件安全策略、包管理和运行时能力

This commit is contained in:
2026-08-17 09:06:32 +08:00
parent 92e5c330f2
commit c3a8737fd6
50 changed files with 4409 additions and 2646 deletions
+22
View File
@@ -0,0 +1,22 @@
export {};
type BridgeErrorCode = "invalid_request" | "session_invalid" | "plugin_unavailable" | "legacy_bridge_disabled" | "permission_not_declared" | "permission_not_granted" | "permission_scope_denied" | "payload_too_large" | "concurrency_limit" | "timeout" | "network_denied" | "unsupported" | "host_failure";
interface BridgeError extends Error { code: BridgeErrorCode; }
interface HttpRequest { url: string; method?: string; headers?: Record<string, string>; body?: string; }
interface HttpResponse { status: number; ok: boolean; content: string; headers: Record<string, string>; }
interface YmhutBridge {
input: { get(): Promise<unknown>; set(value: unknown): Promise<boolean>; onInputChanged(handler: (value: unknown) => void): void };
output: { set(value: unknown): Promise<boolean>; append(value: unknown): Promise<boolean>; clear(): Promise<boolean> };
log: { info(message: string, detail?: string): Promise<boolean>; warn(message: string, detail?: string): Promise<boolean>; error(message: string, detail?: string): Promise<boolean> };
storage: { get(key: string): Promise<string | null>; set(key: string, value: string): Promise<boolean>; remove(key: string): Promise<boolean>; list(): Promise<Record<string, string>> };
http: { fetch(request: HttpRequest): Promise<HttpResponse> };
network: { diagnostics(): Promise<unknown>; ping(request: unknown): Promise<unknown>; dnsLookup(request: unknown): Promise<unknown>; traceRoute(request: unknown): Promise<unknown> };
clipboard: { readText(): Promise<string>; writeText(text: string): Promise<boolean> };
file: { openPicker(): Promise<{ name: string; content: string } | null>; savePicker(name: string, value: string): Promise<{ name: string } | null> };
tool: { run(toolId: string, input: string): Promise<unknown> };
openExternal(url: string, options?: { target?: "safe" | "system" }): Promise<boolean>;
}
declare global { interface Window { ymhut: YmhutBridge; } }