升级插件安全策略、包管理和运行时能力
This commit is contained in:
Vendored
+22
@@ -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; } }
|
||||
Reference in New Issue
Block a user