Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(plugins): add net.anyHost install-time egress grant
v_wyxgwang11be6b008624
diff --git a/apps/desktop/electron/main/ipc/plugin-ui-ipc.ts b/apps/desktop/electron/main/ipc/plugin-ui-ipc.tsindex d4d5ba959..37128b80b 100644--- a/apps/desktop/electron/main/ipc/plugin-ui-ipc.ts+++ b/apps/desktop/electron/main/ipc/plugin-ui-ipc.ts@@ -211,6 +211,7 @@ export function registerPluginUiIpc({theme: getPluginPanelTheme(),htmlPath,netDomains: loaded.manifest.net?.domains?.map((domain) => String(domain)),+ netAnyHost: loaded.permissions.has("net.anyHost"),// The browser view owns an address bar and its own history, so its// location keeps going through `browserHost`; every other contributed// view receives the opener's subject untouched (D320 follow-up).diff --git a/apps/desktop/electron/main/plugin-panel-host.ts b/apps/desktop/electron/main/plugin-panel-host.tsindex 08c7ed7db..22efeab30 100644--- a/apps/desktop/electron/main/plugin-panel-host.ts+++ b/apps/desktop/electron/main/plugin-panel-host.ts@@ -2,7 +2,10 @@ import { BrowserWindow, ipcMain, Menu, session, systemPreferences } from "electrimport { pathToFileURL } from "node:url";import { join, resolve } from "node:path";import { catalogs, resolveLocale } from "@pi-desktop/i18n";-import { isNetUrlAllowed, THEME_ASSET_SCHEME } from "@pi-desktop/plugin-sdk";+import {+ isNetUrlAllowedWithGrant,+ THEME_ASSET_SCHEME,+} from "@pi-desktop/plugin-sdk";import { builtinWindowBackground } from "@pi-desktop/shared";import { suppressLinuxFramelessSystemMenu } from "./frameless-system-menu";import { PanelSenders, pageGoneWithin, resolvePanelInvocation } from "./plugin-panel-senders";@@ -44,6 +47,12 @@ export type PluginPanelOpenRequest = {* an unmetered outbound channel that bypasses the `net.fetch` permission.*/netDomains?: readonly string[];+ /**+ * The install-time `net.anyHost` grant. It lifts the same allowlist for the+ * panel page, so every egress path answers to one decision, except cloud+ * metadata hosts, which stay refused.+ */+ netAnyHost?: boolean;/** Allows microphone audio for plugins with the explicit ui.microphone grant. */allowMicrophone?: boolean;/** Adds a development-only reminder for the non-clickable drag band. */@@ -82,7 +91,8 @@ export type PluginPanelBlockedRequest = (input: {}) => void;/**- * Confine everything a plugin's web contents can reach to its declared domains.+ * Confine everything a plugin's web contents can reach to its declared+ * domains, lifted by the install-time `net.anyHost` grant when present.** Shared by the detached panel window and the docked work-panel view: both are* full web pages under the same plugin identity, so one policy governs both.@@ -95,11 +105,13 @@ export function applyPluginEgressPolicy(input: {pluginId: string;netDomains?: readonly string[];+ netAnyHost?: boolean;allowMicrophone?: boolean;onBlockedRequest?: PluginPanelBlockedRequest;},): void {const domains = input.netDomains ?? [];+ const grant = { domains, anyHost: input.netAnyHost === true };ses.webRequest.onBeforeRequest({ urls: ["<all_urls>"] }, (details, callback) => {let scheme = "";try {@@ -113,7 +125,7 @@ export function applyPluginEgressPolicy(callback({ cancel: false });return;}- if (isNetUrlAllowed(details.url, domains)) {+ if (isNetUrlAllowedWithGrant(details.url, grant)) {callback({ cancel: false });return;}diff --git a/apps/desktop/electron/main/plugin-runtime.ts b/apps/desktop/electron/main/plugin-runtime.tsindex 0379931c1..361dc5dd8 100644--- a/apps/desktop/electron/main/plugin-runtime.ts+++ b/apps/desktop/electron/main/plugin-runtime.ts@@ -19,8 +19,8 @@ import {isFsPathInScope,isValidBusTopic,isValidBusTopicPattern,- isNetUrlAllowed,- isNetSocketUrlAllowed,+ isNetSocketUrlAllowedWithGrant,+ isNetUrlAllowedWithGrant,matchesBusTopic,matchFsGlob,normalizeFsPath,@@ -58,6 +58,7 @@ import {type PluginNativeNotificationInput,type PluginNativeNotificationResult,type PluginNotificationPermission,+ type PluginNetEgressGrant,type PluginServiceContrib,type PluginSettingContrib,type PluginSkillContrib,@@ -224,6 +225,8 @@ export type PluginPanelRequest = {resizable?: boolean;/** The plugin's egress allowlist; the panel session is confined to it. */netDomains?: readonly string[];+ /** The install-time `net.anyHost` grant lifts the panel's allowlist too. */+ netAnyHost?: boolean;/** Allows the isolated panel to request microphone audio, never camera access. */allowMicrophone?: boolean;/** Development panels show the host drag-band reminder in their chrome. */@@ -3532,10 +3535,11 @@ export class PluginRuntime {continue;}// An http MCP endpoint is an outbound channel like any other, so it- // answers to the same allowlist rather than to its permission alone.+ // answers to the same egress decision as pi.net.fetch: the allowlist,+ // plus the install-time net.anyHost grant.if (server.transport === "http") {const url = String(server.url ?? "");- if (!isNetUrlAllowed(url, this.netDomains(loaded))) {+ if (!isNetUrlAllowedWithGrant(url, this.netEgressGrant(loaded))) {this.skipMcpServer(pluginId,server.id,@@ -3930,15 +3934,28 @@ export class PluginRuntime {return parsed.ok ? (parsed.domains ?? []) : [];}+ /**+ * The plugin's egress decision input: its allowlist plus whether the user+ * granted `net.anyHost` at install. One shape for every chokepoint so the+ * grant means the same thing everywhere.+ */+ private netEgressGrant(loaded: LoadedPlugin): PluginNetEgressGrant {+ return {+ domains: this.netDomains(loaded),+ anyHost: loaded.permissions.has("net.anyHost"),+ };+ }+/*** Confine one outbound URL to the allowlist. Reading a secret only becomes a* leak when it can leave, so every host-owned egress path funnels through- * here — and an undeclared `net.domains` means nothing leaves at all.+ * here — an undeclared `net.domains` means nothing leaves at all, unless the+ * install-time `net.anyHost` grant lifted the allowlist.*/private assertEgress(loaded: LoadedPlugin, url: string, api: string): void {- const domains = this.netDomains(loaded);- if (isNetUrlAllowed(url, domains)) return;- this.refuseEgress(loaded, url, api, domains);+ const grant = this.netEgressGrant(loaded);+ if (isNetUrlAllowedWithGrant(url, grant)) return;+ this.refuseEgress(loaded, url, api, grant.domains);}/**@@ -3947,9 +3964,9 @@ export class PluginRuntime {* the transport never opens a connection to an undeclared host.*/private assertSocketEgress(loaded: LoadedPlugin, url: string): void {- const domains = this.netDomains(loaded);- if (isNetSocketUrlAllowed(url, domains)) return;- this.refuseEgress(loaded, url, "net.websocket.connect", domains);+ const grant = this.netEgressGrant(loaded);+ if (isNetSocketUrlAllowedWithGrant(url, grant)) return;+ this.refuseEgress(loaded, url, "net.websocket.connect", grant.domains);}/** One refusal path for both schemes: same audit shape, same message. */@@ -4866,6 +4883,7 @@ export class PluginRuntime {height: loaded.manifest.ui?.height ?? 360,htmlPath,netDomains: this.netDomains(loaded),+ netAnyHost: loaded.permissions.has("net.anyHost"),allowMicrophone: loaded.permissions.has("ui.microphone"),...(loaded.development ? { development: true } : {}),});diff --git a/apps/desktop/electron/main/plugin-view-host.ts b/apps/desktop/electron/main/plugin-view-host.tsindex 468f8228a..b55f79173 100644--- a/apps/desktop/electron/main/plugin-view-host.ts+++ b/apps/desktop/electron/main/plugin-view-host.ts@@ -59,6 +59,8 @@ export type PluginViewOpenRequest = {htmlPath: string;/** Egress allowlist from `manifest.net.domains`. */netDomains?: readonly string[];+ /** The install-time `net.anyHost` grant, passed through to the egress policy. */+ netAnyHost?: boolean;/*** What this view should show, when the opener knows (D320 follow-up).*@@ -414,6 +416,7 @@ export class PluginViewHost {applyPluginEgressPolicy(ses, {pluginId: request.pluginId,netDomains: request.netDomains,+ netAnyHost: request.netAnyHost,onBlockedRequest: this.onBlockedRequest,});diff --git a/apps/desktop/src/features/plugins/model.ts b/apps/desktop/src/features/plugins/model.tsindex 0234979ff..d2ec8deed 100644--- a/apps/desktop/src/features/plugins/model.ts+++ b/apps/desktop/src/features/plugins/model.ts@@ -37,6 +37,8 @@ export type RiskTier = "high" | "medium" | "low";/** Mirrors the risk column of docs/spec/07-plugins/13-plugin-permissions-matrix.md. */export const PERMISSION_RISK: Record<string, RiskTier> = {"net.fetch": "high",+ // Reaches any host the user types in; same tier as the outbound paths.+ "net.anyHost": "high","fs.write": "high","fs.delete": "high","fs.write.workspace": "high",diff --git a/docs/spec/07-plugins/02-plugin-manifest-schema.md b/docs/spec/07-plugins/02-plugin-manifest-schema.mdindex a57370705..1a407d886 100644--- a/docs/spec/07-plugins/02-plugin-manifest-schema.md+++ b/docs/spec/07-plugins/02-plugin-manifest-schema.md@@ -327,6 +327,7 @@ type PluginPermission =| "agent.prompt.inject"| "provider.register"| "net.fetch"+ | "net.anyHost"| "shell.openExternal"| "mcp.server.local"| "mcp.server.remote"@@ -411,6 +412,18 @@ covers the domain and its subdomains.connect is confined to `manifest.net.domains`, and a host that is not declaredis refused before the transport is asked to open anything.+### 5.3.1 net.anyHost — the escape hatch++`"net.anyHost"` lifts the allowlist for a plugin whose endpoints the user types+in (a self-hosted server, a personal domain no manifest written ahead of time+can name). With the grant, every egress path above admits any host over+http(s)/ws(s) — except cloud metadata endpoints (`169.254.169.254` and peers),+which the grant never reaches: their answers are instance credentials. A host+declared in `net.domains` keeps today's behavior, so existing manifests are+unaffected; a plugin without the grant sees no change either. The grant is+an install-time permission like any other: the user sees it in the review+dialog and nothing prompts at request time.+## 5.1 Bus topic grammarTopics are dot-separated segments matching `[a-zA-Z0-9][a-zA-Z0-9_-]*`, at mostdiff --git a/docs/spec/07-plugins/13-plugin-permissions-matrix.md b/docs/spec/07-plugins/13-plugin-permissions-matrix.mdindex cc2ee0ac9..5cfe225be 100644--- a/docs/spec/07-plugins/13-plugin-permissions-matrix.md+++ b/docs/spec/07-plugins/13-plugin-permissions-matrix.md@@ -27,6 +27,7 @@ Provide a permission–capability–risk–default-policy reference table for re| `provider.register` | high | `contributes.providers` become rows in the native provider list, owned by the plugin and refreshed from the manifest on load | Explicit confirmation; local imports and development plugins only in v1.1, matching `agent.extension` | The user path refuses the row (`PROVIDER_OWNED_BY_PLUGIN`); credentials stay in the Host secret store under the usual provider refs; `oauth` declarations are not enabled yet || `net.fetch` | high | `net.fetch` | Deny by default | Confined to `manifest.net.domains`; an empty or malformed list means no egress (§2A) || `net.websocket` | high | `pi.net.websocket.connect` / `send` / `close` (host-owned sockets; at most 4 per plugin, 1 MiB frames) | Deny by default | Confined to `manifest.net.domains` like `net.fetch`; a refused host never reaches the transport, and every socket is closed when the plugin unloads, is disabled, or crashes |+| `net.anyHost` | high | Any host-owned egress path (`net.fetch`, `net.websocket`, panel session, remote HTTP MCP) | Confirm at install | Lifts the `manifest.net.domains` allowlist for user-typed endpoints (self-hosted servers); cloud metadata endpoints stay refused; nothing prompts at request time || `shell.openExternal` | medium | Open external link | Confirm on first use | Prevents phishing links || `mcp.server.local` | high | Spawn a `transport: "stdio"` MCP server declared in the manifest | Deny by default | Runs a local executable; its tools reach the agent || `mcp.server.remote` | high | Connect a `transport: "http"` MCP server | Deny by default | Sends tool arguments to a third-party endpoint; non-loopback HTTP is unencrypted |diff --git a/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md b/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.mdindex 37251cee1..c1c6b7f7f 100644--- a/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md+++ b/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md@@ -278,6 +278,7 @@ type PluginPermission =| "agent.prompt.inject"| "provider.register"| "net.fetch"+ | "net.anyHost"| "shell.openExternal"| "mcp.server.local"| "mcp.server.remote"@@ -359,6 +360,15 @@ type PluginNetDomains = string[]; // "api.example.com" 或 "*.example.com"连接被限定在 `manifest.net.domains` 之内,未被声明的主机会在传输被要求打开任何东西之前就被拒绝。+### 5.3.1 net.anyHost —— 豁免通道++`"net.anyHost"` 面向端点由用户填写(自建服务器、个人域名等清单无法提前+写明)的插件。持有该权限后,上述所有出网路径都对任意 http(s)/ws(s) 主机+放行 —— 云元数据端点(`169.254.169.254` 等)除外,授权永远到不了那里:+它们的应答是实例凭据。`net.domains` 已声明的主机保持现有行为,存量清单+不受影响;未持有该权限的插件同样零变化。它与其他权限一样在安装/更新+确认页展示,请求时不再有任何弹窗。+## 5. 1 总线主题语法主题最多是与 `[a-zA-Z0-9][a-zA-Z0-9_-]*` 匹配的点分隔段diff --git a/docs/zh-CN/spec/07-plugins/13-plugin-permissions-matrix.md b/docs/zh-CN/spec/07-plugins/13-plugin-permissions-matrix.mdindex f373b4b84..b4f474f85 100644--- a/docs/zh-CN/spec/07-plugins/13-plugin-permissions-matrix.md+++ b/docs/zh-CN/spec/07-plugins/13-plugin-permissions-matrix.md@@ -30,6 +30,7 @@| `provider.register` | 高 | `contributes.providers` 成为原生 Provider 列表中的行,归插件所有并在每次加载时按 manifest 刷新 | 显式确认;v1.1 仅限本地导入和开发插件,与 `agent.extension` 一致 | 用户路径拒绝该行(`PROVIDER_OWNED_BY_PLUGIN`);凭据仍存放在 Host secret store 的常规 provider 引用下;暂不启用 `oauth` 声明 || `net.fetch` | 高 | `net.fetch` | 默认拒绝 | 限定在 `manifest.net.domains` 之内;列表为空或非法即完全不放行出网(§2A) || `net.websocket` | 高 | `pi.net.websocket.connect` / `send` / `close`(套接字由宿主持有;每个插件最多 4 个,帧封顶 1 MiB) | 默认拒绝 | 与 `net.fetch` 一样被限制在 `manifest.net.domains` 之内;被拒绝的主机永远到不了传输层,插件卸载、被禁用或崩溃时每个套接字都会被关闭 |+| `net.anyHost` | 高 | 主机掌握的所有出网路径(`net.fetch`、`net.websocket`、面板 session、远程 HTTP MCP) | 安装时确认 | 对用户自填端点(自建服务器等)解除 `manifest.net.domains` 白名单;云元数据端点始终拒绝;请求时不再弹窗 || `shell.openExternal` | 中等 | 打开外部链接 | 首次使用时确认 | 防止网络钓鱼链接 || `mcp.server.local` | 高 | 生成清单中声明的 `transport: "stdio"` MCP 服务器 | 默认拒绝 | 运行本地可执行文件;其工具到达代理 || `mcp.server.remote` | 高 | 连接 `transport: "http"` MCP 服务器 | 默认拒绝 | 将工具参数发送到第三方端点;非回环 HTTP 不加密 |diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.tsindex c732e4a52..c1475e7a9 100644--- a/packages/i18n/src/locales/de/index.ts+++ b/packages/i18n/src/locales/de/index.ts@@ -2119,6 +2119,7 @@ sklm: {"speech.adapter.register": "Einen Sprachadapter registrieren","keyboard.globalShortcut": "Systemweite Tastaturkürzel registrieren","net.websocket": "Echtzeitverbindungen öffnen",+ "net.anyHost": "Auf beliebige Netzwerkadressen zugreifen","bus.publish": "Nachrichten an andere Plugins senden","bus.subscribe": "Nachrichten von anderen Plugins empfangen","browser.cdp": "Den Arbeitspanel-Browser steuern",@@ -2157,6 +2158,7 @@ sklm: {"speech.adapter.register": "Kann ein Transkriptions- oder Sprachprotokoll hinzufügen, das vorhandene Anbieterschlüssel nutzt. Das Plugin sieht den Schlüssel nie.","keyboard.globalShortcut": "Registriert systemweite Tastaturkürzel, die die eigenen Befehle dieses Plugins auslösen, während PI-Desktop nicht fokussiert ist.","net.websocket": "Öffnet bidirektionale Echtzeitverbindungen zu den Hosts, die das Plugin deklariert hat.",+ "net.anyHost": "Kann jeden Server über HTTP(S) oder WebSocket(S) erreichen, einschließlich vom Nutzer eingegebener selbst gehosteter Adressen. Cloud-Metadata-Endpunkte bleiben blockiert.","bus.publish": "Kann Nachrichten zu den angegebenen Themen senden.","bus.subscribe": "Kann Nachrichten zu den angegebenen Themen empfangen.","browser.cdp": "Kann im Arbeitsbereichsbrowser navigieren, die Seite lesen, JavaScript ausführen und auf der Zulassungsliste stehende Chrome DevTools-Befehle senden. Cookies und Speichermethoden sind blockiert.",diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.tsindex 4e188e378..c158291e1 100644--- a/packages/i18n/src/locales/en/index.ts+++ b/packages/i18n/src/locales/en/index.ts@@ -2138,6 +2138,7 @@ importConfirm: "Imported extensions run inside the agent process with the same a"speech.adapter.register": "Register a speech adapter","keyboard.globalShortcut": "Register system-wide shortcuts","net.websocket": "Open real-time connections",+ "net.anyHost": "Access any network address","bus.publish": "Send messages to other plugins","bus.subscribe": "Receive messages from other plugins","browser.cdp": "Control the work-panel browser",@@ -2189,6 +2190,7 @@ importConfirm: "Imported extensions run inside the agent process with the same a"speech.adapter.register": "Can add a transcription or speech protocol that uses your existing provider keys. The plugin never sees the key.","keyboard.globalShortcut": "Registers system-wide keyboard shortcuts that trigger this plugin's own commands while PI-Desktop is not focused.","net.websocket": "Opens real-time two-way connections to the hostnames the plugin declared.",+ "net.anyHost": "Can reach any server over HTTP(S) or WebSocket(S), including user-entered self-hosted addresses. Cloud metadata endpoints stay blocked.","bus.publish": "Can send messages on the topics it declared.","bus.subscribe": "Can receive messages on the topics it declared.","browser.cdp":diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.tsindex 21036082e..9336a7bf0 100644--- a/packages/i18n/src/locales/es/index.ts+++ b/packages/i18n/src/locales/es/index.ts@@ -2119,6 +2119,7 @@ sklm: {"speech.adapter.register": "Registrar un adaptador de voz","keyboard.globalShortcut": "Registrar atajos de teclado del sistema","net.websocket": "Abrir conexiones en tiempo real",+ "net.anyHost": "Acceder a cualquier dirección de red","bus.publish": "Enviar mensajes a otros complementos","bus.subscribe": "Recibir mensajes de otros complementos","browser.cdp": "Controlar el navegador del panel de trabajo",@@ -2157,6 +2158,7 @@ sklm: {"speech.adapter.register": "Puede añadir un protocolo de transcripción o voz que use tus claves de proveedor. El complemento nunca ve la clave.","keyboard.globalShortcut": "Registra atajos de teclado del sistema que activan los comandos propios de este complemento mientras PI-Desktop no tiene el foco.","net.websocket": "Abre conexiones bidireccionales en tiempo real con los hosts que declara el complemento.",+ "net.anyHost": "Puede contactar cualquier servidor por HTTP(S) o WebSocket(S), incluidas direcciones autoalojadas introducidas por el usuario. Los endpoints de metadatos de la nube siguen bloqueados.","bus.publish": "Puede enviar mensajes sobre los temas que declaró.","bus.subscribe": "Puede recibir mensajes sobre los temas que declaró.","browser.cdp": "Puede navegar por el navegador del panel de trabajo, leer la página, ejecutar JavaScript y enviar comandos de Chrome DevTools incluidos en la lista permitida. Las cookies y los métodos de almacenamiento están bloqueados.",diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.tsindex 094c4ba36..0eb03b7aa 100644--- a/packages/i18n/src/locales/fr/index.ts+++ b/packages/i18n/src/locales/fr/index.ts@@ -2119,6 +2119,7 @@ sklm: {"speech.adapter.register": "Enregistrer un adaptateur vocal","keyboard.globalShortcut": "Enregistrer des raccourcis clavier système","net.websocket": "Ouvrir des connexions en temps réel",+ "net.anyHost": "Accéder à n'importe quelle adresse réseau","bus.publish": "Envoyer des messages à d'autres plugins","bus.subscribe": "Recevoir des messages d'autres plugins","browser.cdp": "Contrôler le navigateur du panneau de travail",@@ -2157,6 +2158,7 @@ sklm: {"speech.adapter.register": "Peut ajouter un protocole de transcription ou de synthèse qui réutilise vos clés fournisseur. Le plugin ne voit jamais la clé.","keyboard.globalShortcut": "Enregistre des raccourcis clavier système qui déclenchent les commandes propres à ce plugin lorsque PI-Desktop n'est pas au premier plan.","net.websocket": "Ouvre des connexions bidirectionnelles en temps réel vers les hôtes déclarés par le plugin.",+ "net.anyHost": "Peut joindre n'importe quel serveur en HTTP(S) ou WebSocket(S), y compris les adresses auto-hébergées saisies par l'utilisateur. Les points de terminaison de métadonnées cloud restent bloqués.","bus.publish": "Peut envoyer des messages sur les sujets qu'il a déclarés.","bus.subscribe": "Peut recevoir des messages sur les sujets qu'il a déclarés.","browser.cdp": "Peut naviguer dans le navigateur du panneau de travail, lire la page, exécuter JavaScript et envoyer des commandes Chrome DevTools sur liste autorisée. Les cookies et les méthodes de stockage sont bloqués.",diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.tsindex 456ff4a2c..3d3ef40b7 100644--- a/packages/i18n/src/locales/ko/index.ts+++ b/packages/i18n/src/locales/ko/index.ts@@ -2135,6 +2135,7 @@ importConfirm: "가져온 확장은 에이전트 프로세스 안에서 에이"speech.adapter.register": "음성 어댑터 등록","keyboard.globalShortcut": "시스템 전역 키보드 단축키 등록","net.websocket": "실시간 연결 열기",+ "net.anyHost": "모든 네트워크 주소 접근","bus.publish": "다른 플러그인에 메시지 보내기","bus.subscribe": "다른 플러그인의 메시지 받기","browser.cdp": "작업 패널 브라우저 제어",@@ -2184,6 +2185,7 @@ importConfirm: "가져온 확장은 에이전트 프로세스 안에서 에이"speech.adapter.register": "기존 제공자 키를 쓰는 받아쓰기 또는 낭독 프로토콜을 추가할 수 있습니다. 플러그인은 키를 보지 못합니다.","keyboard.globalShortcut": "PI-Desktop이 포커스되지 않은 상태에서 이 플러그인 자체 명령을 실행하는 시스템 전역 키보드 단축키를 등록합니다.","net.websocket": "플러그인이 선언한 호스트로 실시간 양방향 연결을 엽니다.",+ "net.anyHost": "HTTP(S) 또는 WebSocket(S)으로 사용자가 입력한 자체 호스팅 주소를 포함한 모든 서버에 접속할 수 있습니다. 클라우드 메타데이터 엔드포인트는 항상 차단됩니다.","bus.publish": "선언한 주제로 메시지를 보낼 수 있습니다.","bus.subscribe": "선언한 주제의 메시지를 받을 수 있습니다.","browser.cdp":diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.tsindex 0e9a375af..9b0cafb93 100644--- a/packages/i18n/src/locales/pt-BR/index.ts+++ b/packages/i18n/src/locales/pt-BR/index.ts@@ -2070,6 +2070,7 @@ export const ptBR = {"speech.adapter.register": "Registrar um adaptador de fala","keyboard.globalShortcut": "Registrar atalhos de teclado do sistema","net.websocket": "Abrir conexões em tempo real",+ "net.anyHost": "Acessar qualquer endereço de rede","bus.publish": "Enviar mensagens a outros plugins","bus.subscribe": "Receber mensagens de outros plugins","browser.cdp": "Controlar o navegador do painel de trabalho",@@ -2109,6 +2110,7 @@ export const ptBR = {"speech.adapter.register": "Pode adicionar um protocolo de transcrição ou fala usando suas chaves de provedor existentes. O plugin nunca vê a chave.","keyboard.globalShortcut": "Registra atalhos de teclado do sistema que acionam comandos próprios deste plugin mesmo quando o PI-Desktop não está em foco.","net.websocket": "Abre conexões bidirecionais em tempo real com os nomes de host declarados pelo plugin.",+ "net.anyHost": "Pode acessar qualquer servidor via HTTP(S) ou WebSocket(S), incluindo endereços self-hosted informados pelo usuário. Endpoints de metadados de nuvem permanecem bloqueados.","bus.publish": "Pode enviar mensagens nos tópicos que declarou.","bus.subscribe": "Pode receber mensagens nos tópicos que declarou.","browser.cdp": "Pode navegar pelo navegador do painel de trabalho, ler páginas, executar JavaScript e enviar comandos permitidos do Chrome DevTools. Métodos de cookies e armazenamento são bloqueados.",diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.tsindex 6e4cef052..688c8b620 100644--- a/packages/i18n/src/locales/tr/index.ts+++ b/packages/i18n/src/locales/tr/index.ts@@ -2125,6 +2125,7 @@ importConfirm: "İçe aktarılan uzantılar ajan sürecinde, ajanın kendi araç"speech.adapter.register": "Bir konuşma bağdaştırıcısı kaydet","keyboard.globalShortcut": "Sistem geneli klavye kısayolları kaydet","net.websocket": "Gerçek zamanlı bağlantılar aç",+ "net.anyHost": "Herhangi bir ağ adresine eriş","bus.publish": "Diğer eklentilere ileti gönder","bus.subscribe": "Diğer eklentilerden ileti al","browser.cdp": "Çalışma paneli tarayıcısını kontrol et",@@ -2174,6 +2175,7 @@ importConfirm: "İçe aktarılan uzantılar ajan sürecinde, ajanın kendi araç"speech.adapter.register": "Mevcut sağlayıcı anahtarlarınızı kullanan bir yazıya dökme veya konuşma protokolü ekleyebilir. Eklenti anahtarı asla görmez.","keyboard.globalShortcut": "PI-Desktop odakta değilken bu eklentinin kendi komutlarını tetikleyen sistem geneli klavye kısayollarını kaydeder.","net.websocket": "Eklentinin bildirdiği ana makinelere gerçek zamanlı iki yönlü bağlantılar açar.",+ "net.anyHost": "Kullanıcının girdiği kendi sunucuları dahil HTTP(S) veya WebSocket(S) üzerinden herhangi bir sunucuya bağlanabilir. Bulut meta veri uç noktaları her zaman engellenir.","bus.publish": "Bildirdiği konularda ileti gönderebilir.","bus.subscribe": "Bildirdiği konularda ileti alabilir.","browser.cdp":diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.tsindex 5b40880af..c47a2fc36 100644--- a/packages/i18n/src/locales/zh-CN/index.ts+++ b/packages/i18n/src/locales/zh-CN/index.ts@@ -2104,6 +2104,7 @@ sklm: {"speech.adapter.register": "注册语音适配器","keyboard.globalShortcut": "注册系统级快捷键","net.websocket": "建立实时双向连接",+ "net.anyHost": "访问任意网络地址","bus.publish": "向其他插件发送消息","bus.subscribe": "接收其他插件的消息","browser.cdp": "控制工作面板浏览器",@@ -2144,6 +2145,7 @@ sklm: {"speech.adapter.register": "可以添加转写或朗读协议,复用你已有的服务密钥。插件拿不到密钥。","keyboard.globalShortcut": "注册系统级快捷键,在 PI-Desktop 未聚焦时触发本插件自己的命令。","net.websocket": "与插件声明的域名建立实时双向连接。",+ "net.anyHost": "可访问任意服务器(HTTP(S)/WebSocket(S)),包括用户自行填写的自建服务地址。云元数据地址始终拒绝。","bus.publish": "可在其声明的主题上发送消息。","bus.subscribe": "可在其声明的主题上接收消息。","browser.cdp":diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.tsindex 8830af02c..7043ca6c9 100644--- a/packages/i18n/src/locales/zh-TW/index.ts+++ b/packages/i18n/src/locales/zh-TW/index.ts@@ -2104,6 +2104,7 @@ sklm: {"speech.adapter.register": "註冊語音轉接器","keyboard.globalShortcut": "註冊系統級快捷鍵","net.websocket": "建立即時雙向連線",+ "net.anyHost": "存取任意網路位址","bus.publish": "向其他外掛傳送訊息","bus.subscribe": "接收其他外掛的訊息","browser.cdp": "控制工作面板瀏覽器",@@ -2143,6 +2144,7 @@ sklm: {"speech.adapter.register": "可以新增轉寫或朗讀協定,沿用你既有的服務金鑰。外掛拿不到金鑰。","keyboard.globalShortcut": "註冊系統級快捷鍵,在 PI-Desktop 未聚焦時觸發此外掛自己的命令。","net.websocket": "與外掛宣告的網域建立即時雙向連線。",+ "net.anyHost": "可存取任意伺服器(HTTP(S)/WebSocket(S)),包括使用者自行填寫的自建服務位址。雲端中繼資料位址一律拒絕。","bus.publish": "可在其宣告的主題上傳送訊息。","bus.subscribe": "可在其宣告的主題上接收訊息。","browser.cdp":diff --git a/packages/plugin-devkit/src/check.ts b/packages/plugin-devkit/src/check.tsindex 2bb41d2a9..eac576314 100644--- a/packages/plugin-devkit/src/check.ts+++ b/packages/plugin-devkit/src/check.ts@@ -26,6 +26,7 @@ import {*/export const HIGH_RISK_PERMISSIONS = ["net.fetch",+ "net.anyHost","net.websocket","fs.write","fs.delete",diff --git a/packages/plugin-sdk/src/index.ts b/packages/plugin-sdk/src/index.tsindex fd172445d..982797ef7 100644--- a/packages/plugin-sdk/src/index.ts+++ b/packages/plugin-sdk/src/index.ts@@ -1314,7 +1314,10 @@ export const PLUGIN_PERMISSIONS = [// Read-only usage facts (pi.usage.listTurns):// completed-turn counters and session titles, never message bodies."usage.read",- "net.fetch",+ // Install-time escape hatch from the net.domains allowlist (issue #1201):+ // user-typed endpoints, e.g. a self-hosted server, that no manifest written+ // ahead of time can name. Enforced by net-policy's grant-aware checks.+ "net.anyHost","shell.openExternal","mcp.server.local","mcp.server.remote",diff --git a/packages/plugin-sdk/src/net-policy.test.ts b/packages/plugin-sdk/src/net-policy.test.tsindex bda99ee82..ffff5a272 100644--- a/packages/plugin-sdk/src/net-policy.test.ts+++ b/packages/plugin-sdk/src/net-policy.test.ts@@ -1,5 +1,13 @@import { describe, expect, it } from "vitest";-import { isLocalNetDomain, isNetHostAllowed, isNetUrlAllowed, parseNetDomains } from "./net-policy.js";+import {+ isLocalNetDomain,+ isMetadataNetHost,+ isNetHostAllowed,+ isNetSocketUrlAllowedWithGrant,+ isNetUrlAllowed,+ isNetUrlAllowedWithGrant,+ parseNetDomains,+} from "./net-policy.js";describe("parseNetDomains", () => {it("treats an absent list as no egress rather than an error", () => {@@ -121,3 +129,64 @@ describe("isNetUrlAllowed", () => {expect(isNetUrlAllowed("not a url", ["api.github.com"])).toBe(false);});});++describe("isMetadataNetHost", () => {+ it("recognizes cloud metadata endpoints", () => {+ for (const host of ["169.254.169.254", "metadata.google.internal", "metadata", "METADATA."]) {+ expect(isMetadataNetHost(host), host).toBe(true);+ }+ });++ it("leaves ordinary and private hosts alone", () => {+ for (const host of ["api.github.com", "192.168.1.10", "10.0.0.1", "localhost"]) {+ expect(isMetadataNetHost(host), host).toBe(false);+ }+ });+});++describe("isNetUrlAllowedWithGrant", () => {+ it("keeps the allowlist decision unchanged without the grant", () => {+ const grant = { domains: ["api.github.com"], anyHost: false };+ expect(isNetUrlAllowedWithGrant("https://api.github.com/x", grant)).toBe(true);+ expect(isNetUrlAllowedWithGrant("https://my-self-hosted.example/x", grant)).toBe(false);+ });++ it("admits any http(s) host once the grant is held", () => {+ const grant = { domains: [], anyHost: true };+ expect(isNetUrlAllowedWithGrant("https://my-self-hosted.example:8443/x", grant)).toBe(true);+ expect(isNetUrlAllowedWithGrant("http://192.168.1.10/api", grant)).toBe(true);+ });++ it("never admits cloud metadata endpoints, grant or not", () => {+ const grant = { domains: [], anyHost: true };+ expect(isNetUrlAllowedWithGrant("http://169.254.169.254/latest/meta-data", grant)).toBe(false);+ expect(isNetUrlAllowedWithGrant("http://metadata.google.internal/", grant)).toBe(false);+ });++ it("still refuses non-http schemes and unparseable input under the grant", () => {+ const grant = { domains: [], anyHost: true };+ expect(isNetUrlAllowedWithGrant("file:///etc/passwd", grant)).toBe(false);+ expect(isNetUrlAllowedWithGrant("ws://my-self-hosted.example", grant)).toBe(false);+ expect(isNetUrlAllowedWithGrant("not a url", grant)).toBe(false);+ });++ it("prefers the allowlist when the host is declared", () => {+ const grant = { domains: ["169.254.169.254"], anyHost: true };+ expect(isNetUrlAllowedWithGrant("http://169.254.169.254/latest/meta-data", grant)).toBe(true);+ });+});++describe("isNetSocketUrlAllowedWithGrant", () => {+ it("admits any ws(s) host under the grant, metadata excepted", () => {+ const grant = { domains: [], anyHost: true };+ expect(isNetSocketUrlAllowedWithGrant("wss://my-self-hosted.example/ws", grant)).toBe(true);+ expect(isNetSocketUrlAllowedWithGrant("http://my-self-hosted.example", grant)).toBe(false);+ expect(isNetSocketUrlAllowedWithGrant("ws://169.254.169.254/", grant)).toBe(false);+ });++ it("changes nothing without the grant", () => {+ const grant = { domains: ["api.github.com"] };+ expect(isNetSocketUrlAllowedWithGrant("wss://api.github.com/ws", grant)).toBe(true);+ expect(isNetSocketUrlAllowedWithGrant("wss://other.example/ws", grant)).toBe(false);+ });+});diff --git a/packages/plugin-sdk/src/net-policy.ts b/packages/plugin-sdk/src/net-policy.tsindex d2bd186cc..e3900a047 100644--- a/packages/plugin-sdk/src/net-policy.ts+++ b/packages/plugin-sdk/src/net-policy.ts@@ -7,6 +7,12 @@* every egress chokepoint it owns: the panel session, `pi.net.fetch`, and* remote MCP endpoints. Absent `manifest.net.domains`, a plugin gets no egress* at all — which is what makes a generous `fs.read` grant affordable.+ *+ * The one escape hatch is the `net.anyHost` permission: an install-time grant+ * that lifts the allowlist for every http(s)/ws(s) host except the cloud+ * metadata service, whose answers are instance credentials. It exists for+ * plugins whose endpoints the user types in (self-hosted servers), where no+ * manifest written ahead of time can name the hosts.*//** Hostname, or `*.suffix` for "this domain and its subdomains". */@@ -54,8 +60,9 @@ export function isLocalNetDomain(entry: string): boolean {/*** Validate `manifest.net.domains`. Patterns are hostnames only: no scheme, no- * port, no path, and no bare `*`. A plugin that genuinely needs arbitrary hosts- * has to ask the user at call time instead of declaring its way there.+ * port, no path, and no bare `*`. A plugin that genuinely needs arbitrary,+ * user-chosen hosts declares the `net.anyHost` permission instead — there is+ * no way to declare its way there.*/export function parseNetDomains(raw: unknown): {ok: boolean;@@ -136,3 +143,61 @@ export function isNetSocketUrlAllowed(url: string, domains: readonly string[]):if (parsed.protocol !== "wss:" && parsed.protocol !== "ws:") return false;return isNetHostAllowed(parsed.hostname, domains);}++/**+ * Whether `host` is a cloud metadata endpoint. The `net.anyHost` grant never+ * reaches these: their answers are instance credentials, and wide egress+ * exists to keep a plugin from exfiltrating exactly that. A declared allowlist+ * entry keeps today's behavior — tooling warns about it, it stays valid.+ */+export function isMetadataNetHost(host: string): boolean {+ return CLOUD_METADATA_HOSTS.has(host.trim().toLowerCase().replace(/\.$/, ""));+}++/** What a plugin's egress decision needs: its allowlist plus the anyHost grant. */+export type PluginNetEgressGrant = {+ domains: readonly string[];+ anyHost?: boolean;+};++/**+ * `isNetUrlAllowed` with the `net.anyHost` escape hatch: the declared+ * allowlist wins first (unchanged semantics), then the grant admits any other+ * http(s) host except a cloud metadata endpoint. Unparseable input and+ * non-http schemes are refused either way.+ */+export function isNetUrlAllowedWithGrant(+ url: string,+ grant: PluginNetEgressGrant,+): boolean {+ if (isNetUrlAllowed(url, grant.domains)) return true;+ if (!grant.anyHost) return false;+ let parsed: URL;+ try {+ parsed = new URL(url);+ } catch {+ return false;+ }+ if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return false;+ return !isMetadataNetHost(parsed.hostname);+}++/**+ * The socket half of the grant: same decision shape as+ * `isNetUrlAllowedWithGrant` over `ws`/`wss`.+ */+export function isNetSocketUrlAllowedWithGrant(+ url: string,+ grant: PluginNetEgressGrant,+): boolean {+ if (isNetSocketUrlAllowed(url, grant.domains)) return true;+ if (!grant.anyHost) return false;+ let parsed: URL;+ try {+ parsed = new URL(url);+ } catch {+ return false;+ }+ if (parsed.protocol !== "wss:" && parsed.protocol !== "ws:") return false;+ return !isMetadataNetHost(parsed.hostname);+}